Sendinblue - Version 1.2.4

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.2.4
Comparing to
See all releases


Code changes from version 1.1.0 to 1.2.4

Files changed (39) hide show
  1. app/code/community/Sendinblue/Sendinblue/Block/Sendinblue.php +120 -0
  2. app/code/{local → community}/Sendinblue/Sendinblue/Helper/Data.php +0 -3
  3. app/code/{local → community}/Sendinblue/Sendinblue/Model/Email.php +0 -0
  4. app/code/{local → community}/Sendinblue/Sendinblue/Model/Email/Template.php +6 -20
  5. app/code/{local → community}/Sendinblue/Sendinblue/Model/Mysql4/Sendinblue.php +0 -0
  6. app/code/{local → community}/Sendinblue/Sendinblue/Model/Mysql4/Sendinblue/Collection.php +0 -0
  7. app/code/community/Sendinblue/Sendinblue/Model/Observer.php +251 -0
  8. app/code/community/Sendinblue/Sendinblue/Model/Psmailin.php +1187 -0
  9. app/code/community/Sendinblue/Sendinblue/Model/Sendinblue.php +1579 -0
  10. app/code/{local → community}/Sendinblue/Sendinblue/Model/Status.php +0 -0
  11. app/code/community/Sendinblue/Sendinblue/controllers/Adminhtml/MyformController.php +593 -0
  12. app/code/{local → community}/Sendinblue/Sendinblue/controllers/Adminhtml/NotifyController.php +1 -2
  13. app/code/{local → community}/Sendinblue/Sendinblue/controllers/Adminhtml/SyncController.php +1 -2
  14. app/code/community/Sendinblue/Sendinblue/controllers/AjaxController.php +766 -0
  15. app/code/{local → community}/Sendinblue/Sendinblue/controllers/IndexController.php +0 -0
  16. app/code/{local → community}/Sendinblue/Sendinblue/etc/adminhtml.xml +0 -0
  17. app/code/{local → community}/Sendinblue/Sendinblue/etc/config.xml +321 -325
  18. app/code/{local/Sendinblue/Sendinblue/sql/sendinblue_setup/install-0.1.0.php → community/Sendinblue/Sendinblue/sql/sendinblue_setup/mysql4-install-0.1.0.php} +0 -0
  19. app/code/community/Sendinblue/Sendinblue/sql/sendinblue_setup/mysql4-upgrade-0.1.0-0.2.0.php +14 -0
  20. app/code/local/Sendinblue/Sendinblue/Block/Sendinblue.php +0 -90
  21. app/code/local/Sendinblue/Sendinblue/Model/Observer.php +0 -260
  22. app/code/local/Sendinblue/Sendinblue/Model/Sendinblue.php +0 -1072
  23. app/code/local/Sendinblue/Sendinblue/controllers/Adminhtml/MyformController.php +0 -520
  24. app/code/local/Sendinblue/Sendinblue/controllers/AjaxController.php +0 -473
  25. app/code/local/Sendinblue/Sendinblue/sql/sendinblue_setup/mysql4-upgrade-0.1.0-0.2.0.php +0 -22
  26. app/design/adminhtml/default/default/layout/sendinblue.xml +4 -8
  27. app/design/adminhtml/default/default/template/sendinblue/myform.phtml +267 -99
  28. app/etc/modules/Sendinblue_Sendinblue.xml +2 -2
  29. app/locale/en_US/template/email/doubleoptin_temp.html +58 -0
  30. app/locale/en_US/template/email/sendin_notification.html +3 -3
  31. app/locale/en_US/template/email/sendinsmtp_conf.html +3 -3
  32. app/locale/fr_FR/Sendinblue.csv +25 -2
  33. app/locale/fr_FR/template/email/doubleoptin_temp.html +58 -0
  34. app/locale/fr_FR/template/email/sendin_notification.html +3 -3
  35. app/locale/fr_FR/template/email/sendinsmtp_conf.html +3 -3
  36. package.xml +16 -16
  37. skin/adminhtml/default/default/sendinblue/css/styles.css +24 -44
  38. skin/adminhtml/default/default/sendinblue/js/sendinblue.js +434 -375
  39. skin/adminhtml/default/default/sendinblue/js/sendinblue.min.js +1 -1
app/code/community/Sendinblue/Sendinblue/Block/Sendinblue.php ADDED
@@ -0,0 +1,120 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @author Sendinblue plateform <contact@sendinblue.com>
4
+ * @copyright 2013-2014 Sendinblue
5
+ * URL: https:www.sendinblue.com
6
+ * Do not edit or add to this file if you wish to upgrade Sendinblue Magento plugin to newer
7
+ * versions in the future. If you wish to customize Sendinblue magento plugin for your
8
+ * needs then we can't provide a technical support.
9
+ **/
10
+
11
+ class Sendinblue_Sendinblue_Block_Sendinblue extends Mage_Core_Block_Template
12
+ {
13
+ public function _prepareLayout()
14
+ {
15
+ return parent::_prepareLayout();
16
+ }
17
+ public function getPagerHtml()
18
+ {
19
+ return $this->getChildHtml('pager');
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
+ $attributesName = $sendinblueData->allAttributesName();
31
+ $resp = array();
32
+
33
+ $lastOrderId = Mage::getSingleton('checkout/session')->getLastRealOrderId();
34
+ $customer = Mage::getSingleton('customer/session')->getCustomer();
35
+ $order = Mage::getModel('sales/order')->loadByIncrementId($lastOrderId);
36
+ $dataDisplay = $order->getBillingAddress()->getData();
37
+ $orderData = $order->getData();
38
+ $custData = $customer->getData();
39
+ $locale = Mage::app()->getLocale()->getLocaleCode();
40
+
41
+ if($get_Enable_Status && $get_order_status)
42
+ {
43
+ if (!empty($dataDisplay['telephone']) && !empty($dataDisplay['country_id']))
44
+ {
45
+ $country_code = $sendinblueData->getCountryCode($dataDisplay['country_id']);
46
+ $dataDisplay['telephone'] = $sendinblueData->checkMobileNumber($dataDisplay['telephone'],$country_code);
47
+ }
48
+ $ref_num = $orderData['increment_id'];
49
+ $orderprice = $orderData['grand_total'];
50
+ $currencycode = $orderData['base_currency_code'];
51
+ $orderdate = $orderData['created_at'];
52
+ if ($locale == 'fr_FR')
53
+ $ord_date = date('d/m/Y', strtotime($orderdate));
54
+ else
55
+ $ord_date = date('m/d/Y', strtotime($orderdate));
56
+ $total_pay = $orderprice.' '.$currencycode;
57
+ $msgbody = $sendinblueData->getSendSmsmOrderMessage();
58
+ $fname = str_replace('{first_name}', $dataDisplay['firstname'], $msgbody);
59
+ $lname = str_replace('{last_name}', $dataDisplay['lastname']."\r\n", $fname);
60
+ $procuct_price = str_replace('{order_price}', $total_pay, $lname);
61
+ $order_date = str_replace('{order_date}', $ord_date."\r\n", $procuct_price);
62
+ $msgbody = str_replace('{order_reference}', $ref_num, $order_date);
63
+
64
+ $arr = array();
65
+ $arr['to'] = $dataDisplay['telephone'];
66
+ $arr['from'] = $sendinblueData->getSendSmsOrderSubject();
67
+ $arr['text'] = $msgbody;
68
+ $responce = $sendinblueData->sendSmsApi($arr);
69
+ }
70
+ $allData = array_merge($dataDisplay, $custData);
71
+ $resp = $sendinblueData->merge_my_array($attributesName, $allData);
72
+ if (!empty($custData['firstname'])|| !empty($custData['firstname']))
73
+ $client = 1;
74
+ else
75
+ $client = 0;
76
+ $resp['CLIENT'] = $client;
77
+ $email = $custData['email']; // for email address
78
+ $costomer_data = Mage::getModel('newsletter/subscriber')->loadByEmail($email);
79
+ $nlStatus = $costomer_data->getStatus();
80
+ $user_lang =$custData['created_in'];
81
+
82
+ if ($nlStatus == 1)
83
+ $sendinblueData->emailAdd($email, $resp, $nlStatus);
84
+
85
+ if ($get_Enable_Status == 1 && $get_Tracking_Status == 1 && $nlStatus == 1)
86
+ {
87
+ $value_config = $sendinblueData->getApiConfigValue();
88
+ if ($value_config->date_format == 'dd-mm-yyyy')
89
+ $date = date('d-m-Y', strtotime($orderData['created_at']));
90
+ else
91
+ $date = date('m-d-Y', strtotime($orderData['created_at']));
92
+
93
+ $html = '';
94
+ $html .= '<script type="text/javascript">
95
+ /**Code for NB tracking*/
96
+ function loadScript(url,callback){var script=document.createElement("script");script.type="text/javascript";if(script.readyState){script.onreadystatechange=function(){
97
+ if(script.readyState=="loaded"||script.readyState=="complete"){script.onreadystatechange=null;callback(url)}}}else{
98
+ script.onload=function(){callback(url)}}script.src=url;if(document.body){document.body.appendChild(script)}else{
99
+ document.head.appendChild(script)}}
100
+ var nbJsURL = (("https:" == document.location.protocol) ? "https://my-tracking-orders.googlecode.com/files" : "http://my-tracking-orders.googlecode.com/files");
101
+ var nbBaseURL = "http://tracking.mailin.fr/";
102
+ loadScript(nbJsURL+"/nbv2.js",
103
+ function(){
104
+ /*You can put your custom variables here as shown in example.*/
105
+ try {
106
+ var nbTracker = nb.getTracker(nbBaseURL , "'.$value->result->tracking_data->site_id.'");
107
+ var list = ["'.$get_User_lists.'"];
108
+ var attributes = ["EMAIL","PRENOM","NOM","ORDER_ID","ORDER_DATE","ORDER_PRICE"];
109
+ var values = ["'.$email.'","'.$custData['firstname'].'","'.$custData['lastname'].'","'.$ref_num.'","'.$date.'","'.$orderprice.'"];
110
+ nbTracker.setListData(list);
111
+ nbTracker.setTrackingData(attributes,values);
112
+ nbTracker.trackPageView();
113
+ } catch( err ) {}
114
+ });
115
+
116
+ </script>';
117
+ echo $html;
118
+ }
119
+ }
120
+ }
app/code/{local → community}/Sendinblue/Sendinblue/Helper/Data.php RENAMED
@@ -30,9 +30,6 @@ class Sendinblue_Sendinblue_Helper_Data extends Mage_Core_Helper_Abstract
30
  $config['port'] = $port;
31
  $config['ssl'] = null;
32
  $config['auth'] = $auth;
33
- //echo "<pre>";
34
- //print_r($config);
35
- //die;
36
  $transport = new Zend_Mail_Transport_Smtp($host, $config);
37
  }
38
  else
30
  $config['port'] = $port;
31
  $config['ssl'] = null;
32
  $config['auth'] = $auth;
 
 
 
33
  $transport = new Zend_Mail_Transport_Smtp($host, $config);
34
  }
35
  else
app/code/{local → community}/Sendinblue/Sendinblue/Model/Email.php RENAMED
File without changes
app/code/{local → community}/Sendinblue/Sendinblue/Model/Email/Template.php RENAMED
@@ -17,10 +17,8 @@ class Sendinblue_Sendinblue_Model_Email_Template extends Mage_Core_Model_Email_T
17
  // If it's not enabled, just return the parent result.
18
  if (Mage::helper('sendinblue')->isEnabled()==0 || Mage::helper('sendinblue')->ModuleisEnabled()==0) {
19
  return parent::send($email, $name, $variables);
20
- }
21
-
22
-
23
-
24
  if(!$this->isValidForSend()) {
25
  Mage::log('SMTP: Email not valid for sending - check template, and smtp enabled/disabled setting');
26
  Mage::logException(new Exception('This letter cannot be sent.')); // translation is intentionally omitted
@@ -40,24 +38,17 @@ class Sendinblue_Sendinblue_Model_Email_Template extends Mage_Core_Model_Email_T
40
  $variables['name'] = reset($names);
41
 
42
  $mail = $this->getMail();
43
-
44
-
45
-
46
- if (true) {
47
-
48
  $email = Mage::getStoreConfig('contacts/email/recipient_email', $this->getDesignConfig()->getStore());
49
- Mage::log("Development mode set to send all emails to contact form recipient: " . $email);
50
-
51
  }
52
 
53
- // In Magento core they set the Return-Path here, for the sendmail command.
54
-
55
 
56
  foreach ($emails as $key => $email) {
57
  $mail->addTo($email, '=?utf-8?B?' . base64_encode($names[$key]) . '?=');
58
  }
59
-
60
-
61
  $this->setUseAbsoluteLinks(true);
62
  $text = $this->getProcessedTemplate($variables, true);
63
 
@@ -69,8 +60,6 @@ class Sendinblue_Sendinblue_Model_Email_Template extends Mage_Core_Model_Email_T
69
 
70
  $mail->setSubject('=?utf-8?B?'.base64_encode($this->getProcessedTemplateSubject($variables)).'?=');
71
  $mail->setFrom($this->getSenderEmail(), $this->getSenderName());
72
-
73
-
74
  $transport = Mage::helper('sendinblue')->getTransport();
75
 
76
  try {
@@ -88,8 +77,6 @@ class Sendinblue_Sendinblue_Model_Email_Template extends Mage_Core_Model_Email_T
88
  $mail->send($transport); // Zend_Mail warning..
89
 
90
  Mage::log('Finished sending email');
91
-
92
-
93
  $this->_mail = null;
94
  } catch (Exception $e) {
95
 
@@ -99,6 +86,5 @@ class Sendinblue_Sendinblue_Model_Email_Template extends Mage_Core_Model_Email_T
99
  }
100
  $responceArr = array('result'=>true);
101
  return json_encode($responceArr);
102
-
103
  }
104
  }
17
  // If it's not enabled, just return the parent result.
18
  if (Mage::helper('sendinblue')->isEnabled()==0 || Mage::helper('sendinblue')->ModuleisEnabled()==0) {
19
  return parent::send($email, $name, $variables);
20
+ }
21
+
 
 
22
  if(!$this->isValidForSend()) {
23
  Mage::log('SMTP: Email not valid for sending - check template, and smtp enabled/disabled setting');
24
  Mage::logException(new Exception('This letter cannot be sent.')); // translation is intentionally omitted
38
  $variables['name'] = reset($names);
39
 
40
  $mail = $this->getMail();
41
+
42
+ if (true) {
 
 
 
43
  $email = Mage::getStoreConfig('contacts/email/recipient_email', $this->getDesignConfig()->getStore());
44
+ Mage::log("Development mode set to send all emails to contact form recipient: " . $email);
 
45
  }
46
 
47
+ // In Magento core they set the Return-Path here, for the sendmail command.
 
48
 
49
  foreach ($emails as $key => $email) {
50
  $mail->addTo($email, '=?utf-8?B?' . base64_encode($names[$key]) . '?=');
51
  }
 
 
52
  $this->setUseAbsoluteLinks(true);
53
  $text = $this->getProcessedTemplate($variables, true);
54
 
60
 
61
  $mail->setSubject('=?utf-8?B?'.base64_encode($this->getProcessedTemplateSubject($variables)).'?=');
62
  $mail->setFrom($this->getSenderEmail(), $this->getSenderName());
 
 
63
  $transport = Mage::helper('sendinblue')->getTransport();
64
 
65
  try {
77
  $mail->send($transport); // Zend_Mail warning..
78
 
79
  Mage::log('Finished sending email');
 
 
80
  $this->_mail = null;
81
  } catch (Exception $e) {
82
 
86
  }
87
  $responceArr = array('result'=>true);
88
  return json_encode($responceArr);
 
89
  }
90
  }
app/code/{local → community}/Sendinblue/Sendinblue/Model/Mysql4/Sendinblue.php RENAMED
File without changes
app/code/{local → community}/Sendinblue/Sendinblue/Model/Mysql4/Sendinblue/Collection.php RENAMED
File without changes
app/code/community/Sendinblue/Sendinblue/Model/Observer.php ADDED
@@ -0,0 +1,251 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @author Sendinblue plateform <contact@sendinblue.com>
4
+ * @copyright 2013-2014 Sendinblue
5
+ * URL: https:www.sendinblue.com
6
+ * Do not edit or add to this file if you wish to upgrade Sendinblue Magento plugin to newer
7
+ * versions in the future. If you wish to customize Sendinblue magento plugin for your
8
+ * needs then we can't provide a technical support.
9
+ **/
10
+ class Sendinblue_Sendinblue_Model_Observer
11
+ {
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
+ $nbSubscriber = Mage::getModel('newsletter/subscriber');
21
+ foreach ($params['subscriber'] as $costomer_id)
22
+ {
23
+ $costomer_data = $nbSubscriber->load($costomer_id)->toArray();
24
+ $customer_email[] = empty($costomer_data['subscriber_email'])?array():$costomer_data['subscriber_email'];
25
+ }
26
+ $customer_emails = implode('|', $customer_email);
27
+ $responce = Mage::getModel('sendinblue/sendinblue')->emailDelete($customer_emails);
28
+ }
29
+ if ($responce->result)
30
+ Mage::getModel('core/session')->addSuccess('Total of '.$responce->result->unsubEmailsCounts.' record(s) were Unsubscribed');
31
+ return $this;
32
+ }
33
+
34
+ public function adminCustomerDelete($observer)
35
+ {
36
+ $params = Mage::app()->getRequest()->getParams();
37
+ $params = empty($params)?array():$params;
38
+ if (isset($params['customer']) && count($params['customer'] > 0))
39
+ {
40
+ $customer_email = array();
41
+ $customerObj = Mage::getModel('customer/customer');
42
+ foreach ($params['customer'] as $costomer_id)
43
+ {
44
+ $costomer_data = $customerObj->load($costomer_id)->toArray();
45
+ $customer_email[] = empty($costomer_data['email'])?array():$costomer_data['email'];
46
+ }
47
+ $customer_emails = implode('|', $customer_email);
48
+ $responce = Mage::getModel('sendinblue/sendinblue')->emailDelete($customer_emails);
49
+ }
50
+ if ($responce->result)
51
+ Mage::getModel('core/session')->addSuccess('Total of '.$responce->result->unsubEmailsCounts.' record(s) were Unsubscribed');
52
+ return $this;
53
+ }
54
+ public function adminCustomerSubscribe($observer)
55
+ {
56
+ $params = Mage::app()->getRequest()->getParams();
57
+ $params = empty($params)?array():$params;
58
+ if (isset($params['customer']) && count($params['customer'] > 0))
59
+ {
60
+ $customer_email = array();
61
+ $customerObj = Mage::getModel('customer/customer');
62
+ foreach ($params['customer'] as $costomer_id)
63
+ {
64
+ $costomer_data = $customerObj->load($costomer_id)->toArray();
65
+ $customer_email[] = empty($costomer_data['email'])?array():$costomer_data['email'];
66
+ }
67
+ $customer_emails = implode('|', $customer_email);
68
+ $responce = Mage::getModel('sendinblue/sendinblue')->addEmailList($customer_emails);
69
+ }
70
+ if ($responce->result)
71
+ Mage::getModel('core/session')->addSuccess('Total of '.$responce->result->infoUpdatedCount.' record(s) were subscribed');
72
+ return $this;
73
+ }
74
+ public function subscribeObserver($observer)
75
+ {
76
+ $extra = array();
77
+ $params = Mage::app()->getRequest()->getParams();
78
+ $params = empty($params)?array():$params;
79
+ $extra = Mage::getModel('newsletter/subscriber')->loadByEmail($params['email'])->getData();
80
+ $sendinModule = Mage::getModel('sendinblue/sendinblue');
81
+ $attributesName = $sendinModule->allAttributesName();
82
+
83
+ if ($params['email'] != '')
84
+ $newsletter_status = 0;
85
+
86
+ $client = 0;
87
+ $resp = $sendinModule->merge_my_array($attributesName, $extra);
88
+ $resp['CLIENT'] = $client;
89
+ $responce = $sendinModule->emailAdd($params['email'], $resp, $newsletter_status);
90
+ return $this;
91
+ }
92
+ public function updateNewObserver($observer)
93
+ {
94
+ $params = Mage::app()->getRequest()->getParams();
95
+ $params = empty($params)?array():$params;
96
+ $cus_session = Mage::getSingleton('customer/session')->getCustomer();
97
+ $sendinModule = Mage::getModel('sendinblue/sendinblue');
98
+ $attributesName = $sendinModule->allAttributesName();
99
+
100
+ $customerSessionEmail = $cus_session->getEmail();
101
+ if (empty($customerSessionEmail)) {
102
+ $customer = $observer->getCustomer();
103
+ $customerData = $customer->getData();
104
+ }
105
+ else
106
+ $customerData = $cus_session->getData();
107
+
108
+ $user_lang = isset($customerData['created_in'])? $customerData['created_in'] :'';
109
+ $email = $customerData['email'];
110
+ $cid = isset($customerData['entity_id'])?$customerData['entity_id']:'';
111
+ $collectionAddress = Mage::getModel('customer/address')->getCollection()->addAttributeToSelect('telephone')->addAttributeToSelect('firstname')->addAttributeToSelect('lastname')->addAttributeToSelect('company')->addAttributeToSelect('street')->addAttributeToSelect('postcode')->addAttributeToSelect('region')->addAttributeToSelect('country_id')->addAttributeToSelect('city')->addAttributeToFilter('parent_id',$cid);
112
+
113
+ $telephone = '';
114
+ $customer_addr = array();
115
+ $customer_addr_data = array();
116
+ foreach ($collectionAddress as $customerPhno) {
117
+ $customer_addr = $customerPhno->getData();
118
+ if (!empty($customer_addr['telephone']))
119
+ {
120
+ if(!empty($customer_addr['country_id']))
121
+ {
122
+ $country_code = $sendinModule->getCountryCode($customer_addr['country_id']);
123
+ $customer_addr['telephone'] = $sendinModule->checkMobileNumber($customer_addr['telephone'], $country_code);
124
+ }
125
+ }
126
+ }
127
+ $customer_addr_data = array_merge($customer_addr, $customerData);
128
+ if (!empty($customerData['firstname']) && !empty($customerData['lastname']))
129
+ $client = 1;
130
+ else
131
+ $client = 0;
132
+
133
+ $is_subscribed = !empty($customer_addr_data['is_subscribed'])?$customer_addr_data['is_subscribed']:$params['is_subscribed'];
134
+
135
+ if (!empty($customerData['firstname']) || !empty($customer_addr['telephone']) || !empty($email))
136
+ {
137
+ $costomer_data = Mage::getModel('newsletter/subscriber')->loadByEmail($email);
138
+ $nlStatus = $costomer_data->getStatus();
139
+ $resp = $sendinModule->merge_my_array($attributesName, $customer_addr_data);
140
+ $resp['CLIENT'] = $client;
141
+ if (isset($is_subscribed) && $is_subscribed == 1 && empty($nlStatus))
142
+ {
143
+ $responce = $sendinModule->emailAdd($email, $resp, $is_subscribed);
144
+ $sendinModule->sendWsTemplateMail($email);
145
+ }
146
+ elseif (!empty($nlStatus))
147
+ {
148
+ $responce = $sendinModule->emailAdd($email, $resp);
149
+ }
150
+ }
151
+
152
+ if (isset($is_subscribed) && !empty($is_subscribed) && $is_subscribed === 0) {
153
+
154
+ $responce = $sendinModule->emailDelete($email);
155
+ }
156
+
157
+ return $this;
158
+
159
+ }
160
+ public function syncData()
161
+ {
162
+ $responce = Mage::getModel('sendinblue/sendinblue')->syncData();
163
+ return $this;
164
+ }
165
+ public function updateStatus($observer)
166
+ {
167
+ $order = $observer->getEvent()->getOrder();
168
+
169
+ if ($order->getState() == Mage_Sales_Model_Order::STATE_PROCESSING)
170
+ {
171
+ $history = $order->getShipmentsCollection();
172
+ $history_array=$history->toarray();
173
+ if($history_array['totalRecords'] > 0)
174
+ {
175
+ $order_id = isset($history_array['items']['0']['order_id'])?$history_array['items']['0']['order_id']:'';
176
+ $shippingaddrid = isset($history_array['items']['0']['shipping_address_id'])?$history_array['items']['0']['shipping_address_id']:'';
177
+ $_order = Mage::getModel('sales/order')->load($order_id);
178
+ $_shippingAddress = $_order->getShippingAddress();
179
+ $locale = Mage::app()->getLocale()->getLocaleCode();
180
+ $mobile_sms = $_shippingAddress->getTelephone();
181
+ $mobile_sms = !empty($mobile_sms)?$mobile_sms:'';
182
+ $countryid = $_shippingAddress->getCountryId();
183
+ $countryid = !empty($countryid)?$countryid:'';
184
+ $codeResource = Mage::getSingleton('core/resource');
185
+ $tableCountry = $codeResource->getTableName('sendinblue_country_codes');
186
+ $sql = 'SELECT `country_prefix` FROM '.$tableCountry.' WHERE iso_code = "'.$countryid.'" ';
187
+ $connection = $codeResource->getConnection('core_read');
188
+ $data = $connection->fetchRow($sql);
189
+ $mobile = '';
190
+ $country_prefix = $data['country_prefix'];
191
+ $sendinblueModule = Mage::getModel('sendinblue/sendinblue');
192
+ if(isset($country_prefix) && !empty($country_prefix))
193
+ $mobile = $sendinblueModule->checkMobileNumber($mobile_sms,$country_prefix);
194
+ $firstname = $_shippingAddress->getFirstname();
195
+ $firstname = !empty($firstname )?$firstname :'';
196
+ $lastname = $_shippingAddress->getLastname();
197
+ $lastname = !empty($lastname)?$lastname:'';
198
+ $ref_num = $_order->getIncrementId();
199
+ $ref_num = !empty($ref_num)?$ref_num:'';
200
+ $orderprice = $_order->getGrandTotal();
201
+ $orderprice = !empty($orderprice)?$orderprice:'';
202
+ $courrencycode = $_order->getBaseCurrencyCode();
203
+ $courrencycode = !empty($courrencycode)?$courrencycode:'';
204
+ $orderdate = $_order->getCreatedAt();
205
+ $orderdate = !empty($orderdate)?$orderdate:'';
206
+ if ($locale == 'fr_FR')
207
+ $ord_date = date('d/m/Y', strtotime($orderdate));
208
+ else
209
+ $ord_date = date('m/d/Y', strtotime($orderdate));
210
+
211
+ $total_pay = $orderprice.' '.$courrencycode;
212
+ $msgbody = $sendinblueModule->getSendSmsShipingMessage();
213
+ $fname = str_replace('{first_name}', $firstname, $msgbody);
214
+ $lname = str_replace('{last_name}', $lastname."\r\n", $fname);
215
+ $procuct_price = str_replace('{order_price}', $total_pay, $lname);
216
+ $order_date = str_replace('{order_date}', $ord_date."\r\n", $procuct_price);
217
+ $msgbody = str_replace('{order_reference}', $ref_num, $order_date);
218
+
219
+ $arr = array();
220
+ $arr['to'] = $mobile;
221
+ $arr['from'] = $sendinblueModule->getSendSmsShipingSubject();
222
+ $arr['text'] = $msgbody;
223
+ $sendinblueModule->sendSmsApi($arr);
224
+ }
225
+ }
226
+ }
227
+
228
+ public function subscribedToNewsletter($observer)
229
+ {
230
+ $data = $observer->subscriber;
231
+ $params = Mage::app()->getRequest()->getParams();
232
+ $params = empty($params)?array():$params;
233
+
234
+ if (empty($params['firstname']) && empty($params['lastname']))
235
+ {
236
+ $sibObj = Mage::getModel('sendinblue/sendinblue');
237
+ $subscriber_email = $data->subscriber_email;
238
+
239
+ if($data->subscriber_status == 3)
240
+ $sibObj->emailDelete($subscriber_email);
241
+ elseif ($data->subscriber_status == 1 && !empty($subscriber_email))
242
+ {
243
+ $sibObj->emailSubscribe($data->subscriber_email);
244
+ if( !isset($params['newsletter'])) {
245
+ $sibObj->sendWsTemplateMail($data->subscriber_email);
246
+ }
247
+ }
248
+ }
249
+ }
250
+
251
+ }
app/code/community/Sendinblue/Sendinblue/Model/Psmailin.php ADDED
@@ -0,0 +1,1187 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * 2007-2014 PrestaShop
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Academic Free License (AFL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/afl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@prestashop.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade PrestaShop to newer
18
+ * versions in the future. If you wish to customize PrestaShop for your
19
+ * needs please refer to http://www.prestashop.com for more information.
20
+ *
21
+ * @author PrestaShop SA <contact@prestashop.com>
22
+ * @copyright 2007-2014 PrestaShop SA
23
+ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
24
+ * International Registered Trademark & Property of PrestaShop SA
25
+ */
26
+
27
+ class Sendinblue_Sendinblue_Model_Psmailin
28
+ {
29
+ public $api_key;
30
+ public $base_url;
31
+ public function __construct($params)
32
+ {
33
+ if (!function_exists('curl_init')) {
34
+ throw new Exception('Mailin requires CURL module');
35
+ }
36
+
37
+ $this->base_url = $params['url'];
38
+ $this->api_key = $params['api_key'];
39
+
40
+ }
41
+ /**
42
+ * Do CURL request with authorization
43
+ */
44
+
45
+ private function doRequest($resource, $method, $input)
46
+ {
47
+ $called_url = $this->base_url."/".$resource;
48
+ $ch = curl_init($called_url);
49
+ $auth_header = 'api-key:'.$this->api_key;
50
+ $content_header = "Content-Type:application/json";
51
+ if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
52
+ // Windows only over-ride
53
+ curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
54
+ }
55
+ curl_setopt($ch, CURLOPT_HTTPHEADER, array($auth_header, $content_header));
56
+ curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
57
+ curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $method);
58
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
59
+ curl_setopt($ch, CURLOPT_HEADER, 0);
60
+ curl_setopt($ch, CURLOPT_POSTFIELDS, $input);
61
+ $data = curl_exec($ch);
62
+ if (curl_errno($ch)) {
63
+ echo '<div style="background:#d14836; padding:10px; color:#fff; font-weight:600; position:aboslute;width:100%;top:0;">Curl error: '.curl_error($ch).'</div>';
64
+ }
65
+ curl_close($ch);
66
+ return json_decode($data, true);
67
+ }
68
+ public function get($resource, $input)
69
+ {
70
+ return $this->doRequest($resource, "GET", $input);
71
+ }
72
+ public function put($resource, $input)
73
+ {
74
+ return $this->doRequest($resource, "PUT", $input);
75
+ }
76
+ public function post($resource, $input)
77
+ {
78
+ return $this->doRequest($resource, "POST", $input);
79
+ }
80
+ public function delete($resource, $input)
81
+ {
82
+ return $this->doRequest($resource, "DELETE", $input);
83
+ }
84
+
85
+ /*
86
+ Get Account.
87
+ No input required
88
+ */
89
+ public function getAccount()
90
+ {
91
+ return $this->get("account", "");
92
+ }
93
+
94
+ /*
95
+ Get SMTP details.
96
+ No input required
97
+ */
98
+ public function getSmtpDetails()
99
+ {
100
+ return $this->get("account/smtpdetail", "");
101
+ }
102
+
103
+ /*
104
+ Create Child Account.
105
+ @param {Array} data contains php array with key value pair.
106
+ @options data {String} child_email: Email address of Reseller child [Mandatory]
107
+ @options data {String} password: Password of Reseller child to login [Mandatory]
108
+ @options data {String} company_org: Name of Reseller child’s company [Mandatory]
109
+ @options data {String} first_name: First name of Reseller child [Mandatory]
110
+ @options data {String} last_name: Last name of Reseller child [Mandatory]
111
+ @options data {Array} credits: Number of email & sms credits respectively, which will be
112
+ assigned to the Reseller child’s account [Optional]
113
+ - email_credit {Integer} number of email credits
114
+ - sms_credit {Integer} Number of sms credts
115
+ @options data {Array} associate_ip: Associate dedicated IPs to reseller child.
116
+ You can use commas to separate multiple IPs [Optional]
117
+ */
118
+ public function createChildAccount($data)
119
+ {
120
+ return $this->post("account", json_encode($data));
121
+ }
122
+
123
+ /*
124
+ Update Child Account.
125
+ @param {Array} data contains php array with key value pair.
126
+ @options data {String} auth_key: 16 character authorization key of Reseller child to
127
+ be modified [Mandatory]
128
+ @options data {String} company_org: Name of Reseller child’s company [Optional]
129
+ @options data {String} first_name: First name of Reseller child [Optional]
130
+ @options data {String} last_name: Last name of Reseller child [Optional]
131
+ @options data {String} password: Password of Reseller child to login [Optional]
132
+ @options data {Array} associate_ip: Associate dedicated IPs to reseller child. You can use
133
+ commas to separate multiple IPs [Optional]
134
+ @options data {Array} disassociate_ip: Disassociate dedicated IPs from reseller child. You can
135
+ use commas to separate multiple IPs [Optional]
136
+ */
137
+ public function updateChildAccount($data)
138
+ {
139
+ return $this->put("account", json_decode($data));
140
+ }
141
+
142
+ /*
143
+ Delete Child Account.
144
+ @param {Array} data contains php array with key value pair.
145
+ @options data {String} auth_key: 16 character authorization key of Reseller child to be
146
+ deleted [Mandatory]
147
+ */
148
+ public function deleteChildAccount($data)
149
+ {
150
+ return $this->delete("account/".$data['auth_key'], "");
151
+ }
152
+
153
+ /*
154
+ Get Reseller child Account.
155
+ @param {Array} data contains php array with key value pair.
156
+ @options data {String} auth_key: 16 character authorization key of Reseller child.
157
+ Example : To get the details of more than one child account, use, {"key1":"abC01De2fGHI3jkL",
158
+ "key2":"mnO45Pq6rSTU7vWX"} [Mandatory]
159
+ */
160
+ public function getResellerChild($data)
161
+ {
162
+ return $this->post("account/getchildv2", json_encode($data));
163
+ }
164
+
165
+ /*
166
+ Add/Remove Reseller child's Email/Sms credits.
167
+ @param {Array} data contains php array with key value pair.
168
+ @options data {String} auth_key: 16 character authorization key of Reseller child to modify
169
+ credits [Mandatory]
170
+ @options data {Array} add_credit: Number of email & sms credits to be added. You can assign
171
+ either email or sms credits, one at a time other will remain 0. [Mandatory: if rmv_credit is empty]
172
+ - email_credit {Integer} number of email credits
173
+ - sms_credit {Integer} Number of sms credts
174
+ @options data {Array} rmv_credit: Number of email & sms credits to be removed. You can assign
175
+ either email or sms credits, one at a time other will remain 0. [Mandatory: if add_credits is empty]
176
+ - email_credit {Integer} number of email credits
177
+ - sms_credit {Integer} Number of sms credts
178
+ */
179
+ public function addRemoveChildCredits($data)
180
+ {
181
+ return $this->post("account/addrmvcredit", json_decode($data));
182
+ }
183
+
184
+ /*
185
+ Get a particular campaign detail.
186
+ @param {Array} data contains php array with key value pair.
187
+ @options data {Integer} id: Unique Id of the campaign [Mandatory]
188
+ */
189
+ public function getCampaignV2($data)
190
+ {
191
+ return $this->get("campaign/".$data['id']."/detailsv2", "");
192
+ }
193
+
194
+ /*
195
+ Get all campaigns detail.
196
+ @param {Array} data contains php array with key value pair.
197
+ @options data {String} type: Type of campaign. Possible values – classic, trigger,
198
+ sms, template ( case sensitive ) [Optional]
199
+ @options data {String} status: Status of campaign. Possible values – draft, sent, archive
200
+ , queued, suspended, in_process, temp_active, temp_inactive ( case sensitive ) [Optional]
201
+ @options data {Integer} page: Maximum number of records per request is 500, if there are
202
+ more than 500 campaigns then you can use this parameter to get next 500 results [Optional]
203
+ @options data {Integer} page_limit: This should be a valid number between 1-500 [Optional]
204
+ */
205
+ public function getCampaignsV2($data)
206
+ {
207
+ return $this->get("campaign/detailsv2", json_decode($data));
208
+ }
209
+
210
+ /*
211
+ Create and Schedule your campaigns. It returns the ID of the created campaign.
212
+ @param {Array} data contains php array with key value pair.
213
+ @options data {String} category: Tag name of the campaign [Optional]
214
+ @options data {String} from_name: Sender name from which the campaign emails are sent
215
+ [Mandatory: for Dedicated IP clients, please make sure that the sender details are defined
216
+ here, and in case of no sender, you can add them also via API & for Shared IP clients, if
217
+ sender exists]
218
+ @options data {String} name: Name of the campaign [Mandatory]
219
+ @options data {String} bat: Email address for test mail [Optional]
220
+ @options data {String} html_content: Body of the content. The HTML content field must have
221
+ more than 10 characters [Mandatory: if html_url is empty]
222
+ @options data {String} html_url: Url which content is the body of content [Mandatory: if
223
+ html_content is empty]
224
+ @options data {Array} listid: These are the lists to which the campaign has been sent
225
+ [Mandatory: if scheduled_date is not empty]
226
+ @options data {String} scheduled_date: The day on which the campaign is supposed to run[Optional]
227
+ @options data {String} subject: Subject of the campaign [Mandatory]
228
+ @options data {String} from_email: Sender email from which the campaign emails are sent
229
+ [Mandatory: for Dedicated IP clients, please make sure that the sender details are defined
230
+ here, and in case of no sender, you can add them also via API & for Shared IP clients, if
231
+ sender exists]
232
+ @options data {String} reply_to: The reply to email in the campaign emails [Optional]
233
+ @options data {String} to_field: This is to personalize the «To» Field. If you want to
234
+ include the first name and last name of your recipient, add [PRENOM] [NOM] To use the contact
235
+ attributes here, these should already exist in SendinBlue account [Optional]
236
+ @options data {Array} exclude_list: These are the lists which must be excluded from the campaign [Optional]
237
+ @options data {String} attachment_url: Provide the absolute url of the attachment [Optional]
238
+ @options data {Integer} inline_image: Status of inline image. Possible values = 0 (default)
239
+ & 1. inline_image = 0 means image can’t be embedded, & inline_image = 1 means image can be
240
+ embedded, in the email [Optional]
241
+ @options data {Integer} mirror_active: Status of mirror links in campaign. Possible values = 0
242
+ & 1 (default). mirror_active = 0 means mirror links are deactivated, & mirror_active = 1
243
+ means mirror links are activated, in the campaign [Optional]
244
+ @options data {Integer} send_now: Flag to send campaign now. Possible values = 0 (default)
245
+ & 1. send_now = 0 means campaign can’t be send now, & send_now = 1 means campaign ready to
246
+ send now [Optional]
247
+
248
+ */
249
+ public function createCampaign($data)
250
+ {
251
+ return $this->post("campaign", json_decode($data));
252
+ }
253
+
254
+ /*
255
+ Update your campaign.
256
+ @param {Array} data contains php array with key value pair.
257
+ @options data {Integer} id: Id of campaign to be modified [Mandatory]
258
+ @options data {String} category: Tag name of the campaign [Optional]
259
+ @options data {String} from_name: Sender name from which the campaign emails are sent
260
+ [Mandatory: for Dedicated IP clients, please make sure that the sender details are defined
261
+ here, and in case of no sender, you can add them also via API & for Shared IP clients, if
262
+ sender exists]
263
+ @options data {String} name: Name of the campaign [Optional]
264
+ @options data {String} bat: Email address for test mail [Optional]
265
+ @options data {String} html_content: Body of the content. The HTML content field must have
266
+ more than 10 characters [Optional]
267
+ @options data {String} html_url: Url which content is the body of content [Optional]
268
+ @options data {Array} listid These are the lists to which the campaign has been sent
269
+ [Mandatory: if scheduled_date is not empty]
270
+ @options data {String} scheduled_date: The day on which the campaign is supposed to
271
+ run[Optional]
272
+ @options data {String} subject: Subject of the campaign.
273
+ @options data {String} from_email: Sender email from which the campaign emails are sent
274
+ [Mandatory: for Dedicated IP clients, please make sure that the sender details are defined
275
+ here, and in case of no sender, you can add them also via API & for Shared IP clients,
276
+ if sender exists]
277
+ @options data {String} reply_to: The reply to email in the campaign emails [Optional]
278
+ @options data {String} to_field: This is to personalize the «To» Field. If you want to
279
+ include the first name and last name of your recipient, add [PRENOM] [NOM]. To use the
280
+ contact attributes here, these should already exist in SendinBlue account [Optional]
281
+ @options data {Array} exclude_list: These are the lists which must be excluded from the
282
+ campaign [Optional]
283
+ @options data {String} attachment_url: Provide the absolute url of the attachment [Optional]
284
+ @options data {Integer} inline_image: Status of inline image. Possible values = 0
285
+ (default) & 1. inline_image = 0 means image can’t be embedded, & inline_image = 1
286
+ means image can be embedded, in the email [Optional]
287
+ @options data {Integer} mirror_active: Status of mirror links in campaign. Possible
288
+ values = 0 & 1 (default). mirror_active = 0 means mirror links are deactivated, &
289
+ mirror_active = 1 means mirror links are activated, in the campaign [Optional]
290
+ @options data {Integer} send_now: Flag to send campaign now. Possible values = 0
291
+ (default) & 1. send_now = 0 means campaign can’t be send now, & send_now = 1 means
292
+ campaign ready to send now [Optional]
293
+ */
294
+ public function updateCampaign($data)
295
+ {
296
+ $id = $data['id'];
297
+ unset($data['id']);
298
+ return $this->put("campaign/".$id, json_decode($data));
299
+ }
300
+
301
+ /*
302
+ Delete your campaigns.
303
+ @param {Array} data contains php array with key value pair.
304
+ @options data {Integer} id: Id of campaign to be deleted [Mandatory]
305
+ */
306
+ public function deleteCampaign($data)
307
+ {
308
+ return $this->delete("campaign/".$data['id'], "");
309
+ }
310
+
311
+ /*
312
+ Send report of Sent and Archived campaign.
313
+ @param {Array} data contains php array with key value pair.
314
+ @options data {Integer} id: Id of campaign to send its report [Mandatory]
315
+ @options data {String} lang: Language of email content. Possible values – fr
316
+ (default), en, es, it & pt [Optional]
317
+ @options data {String} email_subject: Message subject [Mandatory]
318
+ @options data {Array} email_to: Email address of the recipient(s). Example:
319
+ "test@example.net". You can use commas to separate multiple recipients [Mandatory]
320
+ @options data {String} email_content_type: Body of the message in text/HTML version.
321
+ Possible values – text & html [Mandatory]
322
+ @options data {Array} email_bcc: Same as email_to but for Bcc [Optional]
323
+ @options data {Array} email_cc: Same as email_to but for Cc [Optional]
324
+ @options data {String} email_body: Body of the message [Mandatory]
325
+ */
326
+ public function campaignReportEmail($data)
327
+ {
328
+ $id = $data['id'];
329
+ unset($data['id']);
330
+ return $this->post("campaign/".$id."/report", json_decode($data));
331
+ }
332
+
333
+ /*
334
+ Export the recipients of a specified campaign.
335
+ @param {Array} data contains php array with key value pair.
336
+ @options data {Integer} id: Id of campaign to export its recipients [Mandatory]
337
+ @options data {String} notify_url: URL that will be called once the export process
338
+ is finished [Mandatory]
339
+ @options data {String} type: Type of recipients. Possible values – all, non_clicker,
340
+ non_opener, clicker, opener, soft_bounces, hard_bounces & unsubscribes [Mandatory]
341
+ */
342
+ public function campaignRecipientsExport($data)
343
+ {
344
+ $id = $data['id'];
345
+ unset($data['id']);
346
+ return $this->post("campaign/".$id."/recipients", json_decode($data));
347
+ }
348
+
349
+ /*
350
+ Get the Campaign name, subject and share link of the classic type campaigns only which
351
+ are sent, for those which are not sent and the rest of campaign types like trigger, template
352
+ & sms, will return an error message of share link not available.
353
+ @param {Array} data contains php array with key value pair.
354
+ @options data {Array} camp_ids: Id of campaign to get share link. You can use commas to
355
+ separate multiple ids [Mandatory]
356
+ */
357
+
358
+ public function shareCampaign($data)
359
+ {
360
+ return $this->post("campaign/sharelinkv2", json_encode($data));
361
+ }
362
+
363
+ /*
364
+ Send a Test Campaign.
365
+ @param {Array} data contains php array with key value pair.
366
+ @options data {Integer} id: Id of the campaign [Mandatory]
367
+ @options data {Array} emails: Email address of recipient(s) existing in the one of the lists &
368
+ should not be blacklisted. Example: "test@example.net". You can use commas to separate multiple
369
+ recipients [Mandatory]
370
+ */
371
+ public function sendBatEmail($data)
372
+ {
373
+ $id = $data['id'];
374
+ unset($data['id']);
375
+ return $this->post("campaign/".$id."/test", json_encode($data));
376
+ }
377
+
378
+ /*
379
+ Update the Campaign status.
380
+ @param {Array} data contains php array with key value pair.
381
+ @options data {Integer} id: Id of campaign to update its status [Mandatory]
382
+ @options data {String} status: Types of status. Possible values – suspended,
383
+ archive, darchive, sent, queued, replicate and replicate_template ( case sensitive )
384
+ [Mandatory]
385
+ */
386
+ public function updateCampaignStatus($data)
387
+ {
388
+ $id = $data['id'];
389
+ unset($data['id']);
390
+ return $this->put("campaign/".$id."/updatecampstatus", json_encode($data));
391
+ }
392
+
393
+ /*
394
+ Create and schedule your Trigger campaigns.
395
+ @param {Array} data contains php array with key value pair.
396
+ @options data {String} category: Tag name of the campaign [Optional]
397
+ @options data {String} from_name: Sender name from which the campaign emails are
398
+ sent [Mandatory: for Dedicated IP clients, please make sure that the sender details
399
+ are defined here, and in case of no sender, you can add them also via API & for Shared
400
+ IP clients, if sender exists]
401
+ @options data {String} trigger_name: Name of the campaign [Mandatory]
402
+ @options data {String} bat: Email address for test mail [Optional]
403
+ @options data {String} html_content: Body of the content. The HTML content field must
404
+ have more than 10 characters [Mandatory: if html_url is empty]
405
+ @options data {String} html_url: Url which content is the body of content [Mandatory: if
406
+ html_content is empty]
407
+ @options data {Array} listid: These are the lists to which the campaign has been sent
408
+ [Mandatory: if scheduled_date is not empty]
409
+ @options data {String} scheduled_date: The day on which the campaign is supposed to
410
+ run[Optional]
411
+ @options data {String} subject: Subject of the campaign [Mandatory]
412
+ @options data {String} from_email: Sender email from which the campaign emails are sent
413
+ [Mandatory: for Dedicated IP clients, please make sure that the sender details are defined
414
+ here, and in case of no sender, you can add them also via API & for Shared IP clients, if
415
+ sender exists]
416
+ @options data {String} reply_to: The reply to email in the campaign emails [Optional]
417
+ @options data {String} to_field: This is to personalize the «To» Field. If you want to include
418
+ the first name and last name of your recipient, add [PRENOM] [NOM]. To use the contact attributes
419
+ here, these should already exist in SendinBlue account [Optional]
420
+ @options data {Array} exclude_list: These are the lists which must be excluded from the campaign
421
+ [Optional]
422
+ @options data {Integer} recurring: Type of trigger campaign. Possible values = 0 (default) & 1.
423
+ recurring = 0 means contact can receive the same Trigger campaign only once, & recurring = 1
424
+ means contact can receive the same Trigger campaign several times [Optional]
425
+ @options data {String} attachment_url: Provide the absolute url of the attachment [Optional]
426
+ @options data {Integer} inline_image: Status of inline image. Possible values = 0 (default) &
427
+ 1. inline_image = 0 means image can’t be embedded, & inline_image = 1 means image can be embedded,
428
+ in the email [Optional]
429
+ @options data {Integer} mirror_active: Status of mirror links in campaign. Possible values = 0 & 1
430
+ (default). mirror_active = 0 means mirror links are deactivated, & mirror_active = 1 means mirror
431
+ links are activated, in the campaign [Optional]
432
+ @options data {Integer} send_now: Flag to send campaign now. Possible values = 0 (default) & 1.
433
+ send_now = 0 means campaign can’t be send now, & send_now = 1 means campaign ready to send now
434
+ [Optional]
435
+ */
436
+ public function createTriggerCampaign($data)
437
+ {
438
+ return $this->post("campaign", json_encode($data));
439
+ }
440
+
441
+ /*
442
+ Update and schedule your Trigger campaigns.
443
+ @param {Array} data contains php array with key value pair.
444
+ @options data {Integer} id: Id of Trigger campaign to be modified [Mandatory]
445
+ @options data {String} category: Tag name of the campaign [Optional]
446
+ @options data {String} from_name: Sender name from which the campaign emails are sent
447
+ [Mandatory: for Dedicated IP clients, please make sure that the sender details are defined here,
448
+ and in case of no sender, you can add them also via API & for Shared IP clients, if sender exists]
449
+ @options data {String} trigger_name: Name of the campaign [Mandatory]
450
+ @options data {String} bat Email address for test mail [Optional]
451
+ @options data {String} html_content: Body of the content. The HTML content field must have more
452
+ than 10 characters [Mandatory: if html_url is empty]
453
+ @options data {String} html_url: Url which content is the body of content [Mandatory: if
454
+ html_content is empty]
455
+ @options data {Array} listid: These are the lists to which the campaign has been sent [Mandatory:
456
+ if scheduled_date is not empty]
457
+ @options data {String} scheduled_date: The day on which the campaign is supposed to run[Optional]
458
+ @options data {String} subject: Subject of the campaign [Mandatory]
459
+ @options data {String} from_email: Sender email from which the campaign emails are sent [Mandatory:
460
+ for Dedicated IP clients, please make sure that the sender details are defined here, and in case of
461
+ no sender, you can add them also via API & for Shared IP clients, if sender exists]
462
+ @options data {String} reply_to: The reply to email in the campaign emails [Optional]
463
+ @options data {String} to_field: This is to personalize the «To» Field. If you want to include the
464
+ first name and last name of your recipient, add [PRENOM] [NOM]. To use the contact attributes here
465
+ , these should already exist in SendinBlue account [Optional]
466
+ @options data {Array} exclude_list: These are the lists which must be excluded from the campaign
467
+ [Optional]
468
+ @options data {Integer} recurring: Type of trigger campaign. Possible values = 0 (default) & 1.
469
+ recurring = 0 means contact can receive the same Trigger campaign only once, & recurring = 1
470
+ means contact can receive the same Trigger campaign several times [Optional]
471
+ @options data {String} attachment_url: Provide the absolute url of the attachment [Optional]
472
+ @options data {Integer} inline_image: Status of inline image. Possible values = 0 (default) &
473
+ 1. inline_image = 0 means image can’t be embedded, & inline_image = 1 means image can be embedded,
474
+ in the email [Optional]
475
+ @options data {Integer} mirror_active: Status of mirror links in campaign. Possible values = 0 &
476
+ 1 (default). mirror_active = 0 means mirror links are deactivated, & mirror_active = 1 means mirror
477
+ links are activated, in the campaign [Optional]
478
+ @options data {Integer} send_now: Flag to send campaign now. Possible values = 0 (default) & 1.
479
+ send_now = 0 means campaign can’t be send now, & send_now = 1 means campaign ready to send now
480
+ [Optional]
481
+ */
482
+ public function updateTriggerCampaign($data)
483
+ {
484
+ $id = $data['id'];
485
+ unset($data['id']);
486
+ return $this->put("campaign/".$id, json_encode($data));
487
+ }
488
+
489
+ /*
490
+ Get all folders detail.
491
+ @param {Array} data contains php array with key value pair.
492
+ @options data {Integer} page: Maximum number of records per request is 50,
493
+ if there are more than 50 folders then you can use this parameter to get next 50 results [Mandatory]
494
+ @options data {Integer} page_limit: This should be a valid number between 1-50 [Mandatory]
495
+ */
496
+ public function getFolders($data)
497
+ {
498
+ return $this->get("folder", json_encode($data));
499
+ }
500
+
501
+ /*
502
+ Get a particular folder detail.
503
+ @param {Array} data contains php array with key value pair.
504
+ @options data {Integer} id: Id of folder to get details [Mandatory]
505
+ */
506
+ public function getFolder($data)
507
+ {
508
+ return $this->get("folder/".$data['id'], "");
509
+ }
510
+
511
+ /*
512
+ Create a new folder.
513
+ @param {Array} data contains php array with key value pair.
514
+ @options data {String} name: Desired name of the folder to be created [Mandatory]
515
+ */
516
+ public function createFolder($data)
517
+ {
518
+ return $this->post("folder", json_encode($data));
519
+ }
520
+
521
+ /*
522
+ Delete a specific folder information.
523
+ @param {Array} data contains php array with key value pair.
524
+ @options data {Integer} id: Id of folder to be deleted [Mandatory]
525
+ */
526
+ public function deleteFolder($data)
527
+ {
528
+ return $this->delete("folder/".$data['id'], "");
529
+ }
530
+
531
+ /*
532
+ Update an existing folder.
533
+ @param {Array} data contains php array with key value pair.
534
+ @options data {Integer} id: Id of folder to be modified [Mandatory]
535
+ @options data {String} name: Desired name of the folder to be modified [Mandatory]
536
+ */
537
+ public function updateFolder($data)
538
+ {
539
+ $id = $data['id'];
540
+ unset($data['id']);
541
+ return $this->put("folder/".$id, json_encode($data));
542
+ }
543
+
544
+ /*
545
+ Get all lists detail.
546
+ @param {Array} data contains php array with key value pair.
547
+ @options data {Integer} list_parent: This is the existing folder id & can be used to
548
+ get all lists belonging to it [Optional]
549
+ @options data {Integer} page: Maximum number of records per request is 50, if there are
550
+ more than 50 processes then you can use this parameter to get next 50 results [Mandatory]
551
+ @options data {Integer} page_limit: This should be a valid number between 1-50 [Mandatory]
552
+ */
553
+ public function getLists($data)
554
+ {
555
+ return $this->get("list", json_encode($data));
556
+ }
557
+
558
+ /*
559
+ Get a particular list detail.
560
+ @param {Array} data contains php array with key value pair.
561
+ @options data {Integer} id: Id of list to get details [Mandatory]
562
+ */
563
+ public function getList($data)
564
+ {
565
+ return $this->get("list/".$data['id'], "");
566
+ }
567
+
568
+ /*
569
+ Create a new list.
570
+ @param {Array} data contains php array with key value pair.
571
+ @options data {String} list_name: Desired name of the list to be created [Mandatory]
572
+ @options data {Integer} list_parent: Folder ID [Mandatory]
573
+ */
574
+ public function createList($data)
575
+ {
576
+ return $this->post("list", json_encode($data));
577
+ }
578
+
579
+ /*
580
+ Update a list.
581
+ @param {Array} data contains php array with key value pair.
582
+ @options data {Integer} id: Id of list to be modified [Mandatory]
583
+ @options data {String} list_name: Desired name of the list to be modified [Optional]
584
+ @options data {Integer} list_parent: Folder ID [Mandatory]
585
+ */
586
+ public function updateList($data)
587
+ {
588
+ $id = $data['id'];
589
+ unset($data['id']);
590
+ return $this->put("list/".$id, json_encode($data));
591
+ }
592
+
593
+ /*
594
+ Delete a specific list.
595
+ @param {Array} data contains php array with key value pair.
596
+ @options data {Integer} id: Id of list to be deleted [Mandatory]
597
+ */
598
+ public function deleteList($data)
599
+ {
600
+ return $this->delete("list/".$data['id'], "");
601
+ }
602
+
603
+ /*
604
+ Display details of all users for the given lists.
605
+ @param {Array} data contains php array with key value pair.
606
+ @options data {Array} listids: These are the list ids to get their data. The ids found
607
+ will display records [Mandatory]
608
+ @options data {String} timestamp: This is date-time filter to fetch modified user records >=
609
+ this time. Valid format Y-m-d H:i:s. Example: "2015-05-22 14:30:00" [Optional]
610
+ @options data {Integer} page: Maximum number of records per request is 500, if in your list
611
+ there are more than 500 users then you can use this parameter to get next 500 results [Optional]
612
+ @options data {Integer} page_limit: This should be a valid number between 1-500 [Optional]
613
+ */
614
+ public function displayListUsers($data)
615
+ {
616
+ return $this->post("list/display", json_encode($data));
617
+ }
618
+
619
+ /*
620
+ Add already existing users in the SendinBlue contacts to the list.
621
+ @param {Array} data contains php array with key value pair.
622
+ @options data {Integer} id: Id of list to link users in it [Mandatory]
623
+ @options data {Array} users: Email address of the already existing user(s) in the
624
+ SendinBlue contacts. Example: "test@example.net". You can use commas to separate multiple
625
+ users [Mandatory]
626
+ */
627
+
628
+ public function addUsersList($data)
629
+ {
630
+ $id = $data['id'];
631
+ unset($data['id']);
632
+ return $this->post("list/".$id."/users", json_encode($data));
633
+ }
634
+
635
+ /*
636
+ Delete already existing users in the SendinBlue contacts from the list.
637
+ @param {Array} data contains php array with key value pair.
638
+ @options data {Integer} id: Id of list to unlink users from it [Mandatory]
639
+ @options data {Array} users: Email address of the already existing user(s) in the
640
+ SendinBlue contacts to be modified. Example: "test@example.net". You can use commas
641
+ to separate multiple users [Mandatory]
642
+ */
643
+ public function deleteUsersList($data)
644
+ {
645
+ $id = $data['id'];
646
+ unset($data['id']);
647
+ return $this->delete("list/".$id."/delusers", json_encode($data));
648
+ }
649
+
650
+ /*
651
+ Access all the attributes information under the account.
652
+ No input required
653
+ */
654
+ public function getAttributes()
655
+ {
656
+ return $this->get("attribute", "");
657
+ }
658
+
659
+ /*
660
+ Access the specific type of attribute information.
661
+ @param {Array} data contains php array with key value pair.
662
+ @options data {String} type: Type of attribute. Possible values – normal, transactional,
663
+ category, calculated & global [Optional]
664
+ */
665
+ public function getAttribute($data)
666
+ {
667
+ return $this->get("attribute/".$data['type'], "");
668
+ }
669
+
670
+ /*
671
+ Create an Attribute.
672
+ @param {Array} data contains php array with key value pair.
673
+ @options data {String} type: Type of attribute. Possible values – normal, transactional,
674
+ category, calculated & global ( case sensitive ) [Mandatory]
675
+ @options data {Array} data: The name and data type of ‘normal’ & ‘transactional’ attribute
676
+ to be created in your SendinBlue account. It should be sent as an associative array. Example:
677
+ array(‘ATTRIBUTE_NAME1′ => ‘DATA_TYPE1′, ‘ATTRIBUTE_NAME2’=> ‘DATA_TYPE2′).
678
+ The name and data value of ‘category’, ‘calculated’ & ‘global’, should be sent as JSON string.
679
+ Example: ‘[{ "name":"ATTRIBUTE_NAME1", "value":"Attribute_value1" }, { "name":"ATTRIBUTE_NAME2",
680
+ "value":"Attribute_value2" }]’. You can use commas to separate multiple attributes [Mandatory]
681
+ */
682
+ public function createAttribute($data)
683
+ {
684
+ return $this->post("attribute/", json_encode($data));
685
+ }
686
+
687
+ /*
688
+ Delete a specific type of attribute information.
689
+ @param {Array} data contains php array with key value pair.
690
+ @options data {Integer} type: Type of attribute to be deleted [Mandatory]
691
+ */
692
+ public function deleteAttribute($type, $data)
693
+ {
694
+ $type = $data['type'];
695
+ unset($data['type']);
696
+ return $this->post("attribute/".$type, json_encode($data));
697
+ }
698
+
699
+ /*
700
+ Create a new user if an email provided as input, doesn’t exists in the contact list
701
+ of your SendinBlue account, otherwise it will update the existing user.
702
+ @param {Array} data contains php array with key value pair.
703
+ @options data {String} email: Email address of the user to be created in SendinBlue contacts.
704
+ Already existing email address of user in the SendinBlue contacts to be modified [Mandatory]
705
+ @options data {Array} attributes: The name of attribute present in your SendinBlue account.
706
+ It should be sent as an associative array. Example: array("NAME"=>"name"). You can use commas
707
+ to separate multiple attributes [Optional]
708
+ @options data {Integer} blacklisted: This is used to blacklist/ Unblacklist a user. Possible
709
+ values – 0 & 1. blacklisted = 1 means user has been blacklisted [Optional]
710
+ @options data {Array} listid: The list id(s) to be linked from user [Optional]
711
+ @options data {Array} listid_unlink: The list id(s) to be unlinked from user [Optional]
712
+ @options data {Array} blacklisted_sms: This is used to blacklist/ Unblacklist a user’s SMS
713
+ number. Possible values – 0 & 1. blacklisted_sms = 1 means user’s SMS number has been
714
+ blacklisted [Optional]
715
+ */
716
+ public function createUpdateUser($data)
717
+ {
718
+ return $this->post("user/createdituser", json_encode($data));
719
+ }
720
+
721
+ /*
722
+ Get Access a specific user Information.
723
+ @param {Array} data contains php array with key value pair.
724
+ @options data {String} email: Email address of the already existing user in the SendinBlue
725
+ contacts [Mandatory]
726
+ */
727
+ public function getUser($data)
728
+ {
729
+ return $this->get("user/".$data['email'], "");
730
+ }
731
+
732
+ /*
733
+ Unlink existing user from all lists.
734
+ @param {Array} data contains php array with key value pair.
735
+ @options data {String} email: Email address of the already existing user in the SendinBlue
736
+ contacts to be unlinked from all lists [Mandatory]
737
+ */
738
+ public function deleteUser($data)
739
+ {
740
+ return $this->delete("user/".$data['email'], "");
741
+ }
742
+
743
+ /*
744
+ Import Users Information.
745
+ @param {Array} data contains php array with key value pair.
746
+ @options data {String} url: The URL of the file to be imported. Possible file types – .txt,
747
+ .csv [Mandatory: if body is empty]
748
+ @options data {String} body: The Body with csv content to be imported. Example: ‘NAME;SURNAME;
749
+ EMAIL\n"Name1";"Surname1";"example1@example.net"\n"Name2";"Surname2";"example2@example.net"‘,
750
+ where \n separates each user data. You can use semicolon to separate multiple attributes
751
+ [Mandatory: if url is empty]
752
+ @options data {Array} listids: These are the list ids in which the the users will be imported
753
+ [Mandatory: if name is empty]
754
+ @options data {String} notify_url: URL that will be called once the import process is finished
755
+ [Optional] In notify_url, we are sending the content using POST method
756
+ @options data {String} name: This is new list name which will be created first & then users will
757
+ be imported in it [Mandatory: if listids is empty]
758
+ @options data {Integer} list_parent: This is the existing folder id & can be used with name
759
+ parameter to make newly created list’s desired parent [Optional]
760
+ */
761
+ public function importUsers($data)
762
+ {
763
+ return $this->post("user/import", json_encode($data));
764
+ }
765
+
766
+ /*
767
+ Export Users Information.
768
+ @param {Array} data contains php array with key value pair.
769
+ @options data {String} export_attrib: The name of attribute present in your SendinBlue account.
770
+ You can use commas to separate multiple attributes. Example: "EMAIL,NAME,SMS" [Optional]
771
+ @options data {String} filter: Filter can be added to export users. Example: "{\"blacklisted\":1}",
772
+ will export all blacklisted users [Mandatory]
773
+ @options data {String} notify_url: URL that will be called once the export process is finished
774
+ [Optional]
775
+ */
776
+ public function exportUsers($data)
777
+ {
778
+ return $this->post("user/export", json_encode($data));
779
+ }
780
+
781
+ /*
782
+ Get all the processes information under the account.
783
+ @param {Array} data contains php array with key value pair.
784
+ @options data {Integer} page: Maximum number of records per request is 50, if there are more than 50
785
+ processes then you can use this parameter to get next 50 results [Mandatory]
786
+ @options data {Integer} page_limit: This should be a valid number between 1-50 [Mandatory]
787
+ */
788
+ public function getProcesses($data)
789
+ {
790
+ return $this->get("process", json_encode($data));
791
+ }
792
+
793
+ /*
794
+ Get the process information.
795
+ @param {Array} data contains php array with key value pair.
796
+ @options data {Integer} id: Id of process to get details [Mandatory]
797
+ */
798
+ public function getProcess($data)
799
+ {
800
+ return $this->get("process/".$data['id'], "");
801
+ }
802
+
803
+ /*
804
+ To retrieve details of all webhooks.
805
+ @param {Array} data contains php array with key value pair.
806
+ @options data {String} is_plat: Flag to get webhooks. Possible values – 0 & 1. Example: to get
807
+ Transactional webhooks, use $is_plat=0, to get Marketing webhooks, use $is_plat=1, & to get all
808
+ webhooks, use $is_plat="" [Optional]
809
+ */
810
+ public function getWebhooks($data)
811
+ {
812
+ return $this->get("webhook", json_encode($data));
813
+ }
814
+
815
+ /*
816
+ To retrieve details of any particular webhook.
817
+ @param {Array} data contains php array with key value pair.
818
+ @options data {Integer} id: Id of webhook to get details [Mandatory]
819
+ */
820
+ public function getWebhook($data)
821
+ {
822
+ return $this->get("webhook/".$data['id'], "");
823
+ }
824
+
825
+ /*
826
+ Create a Webhook.
827
+ @param {Array} data contains php array with key value pair.
828
+ @options data {String} url: URL that will be triggered by a webhook [Mandatory]
829
+ @options data {String} description: Webook description [Optional]
830
+ @options data {Array} events: Set of events. You can use commas to separate multiple events.
831
+ Possible values for Transcational webhook – request, delivered, hard_bounce, soft_bounce, blocked,
832
+ spam, invalid_email, deferred, click, & opened and Possible Values for Marketing webhook – spam,
833
+ opened, click, hard_bounce, unsubscribe, soft_bounce & list_addition ( case sensitive ) [Mandatory]
834
+ @options data {Integer} is_plat: Flag to create webhook type. Possible values – 0 (default) & 1.
835
+ Example: to create Transactional webhooks, use $is_plat=0, & to create Marketing webhooks, use
836
+ $is_plat=1 [Optional]
837
+ */
838
+ public function createWebhook($data)
839
+ {
840
+ return $this->post("webhook", json_encode($data));
841
+ }
842
+
843
+ /*
844
+ Delete a webhook.
845
+ @param {Array} data contains php array with key value pair.
846
+ @options data {Integer} id: Id of webhook to be deleted [Mandatory]
847
+ */
848
+ public function deleteWebhook($data)
849
+ {
850
+ return $this->delete("webhook/".$data['id'], "");
851
+ }
852
+
853
+ /*
854
+ Update a webhook.
855
+ @param {Array} data contains php array with key value pair.
856
+ @options data {Integer} id: Id of webhook to be modified [Mandatory]
857
+ @options data {String} url: URL that will be triggered by a webhook [Mandatory]
858
+ @options data {String} description: Webook description [Optional]
859
+ @options data {Array} events: Set of events. You can use commas to separate multiple events.
860
+ Possible values for Transcational webhook – request, delivered, hard_bounce, soft_bounce, blocked,
861
+ spam, invalid_email, deferred, click, & opened and Possible Values for Marketing webhook – spam,
862
+ opened, click, hard_bounce, unsubscribe, soft_bounce & list_addition ( case sensitive ) [Mandatory]
863
+ */
864
+ public function updateWebhook($data)
865
+ {
866
+ $id = $data['id'];
867
+ unset($data['id']);
868
+ return $this->put("webhook/".$id, json_encode($data));
869
+ }
870
+
871
+ /*
872
+ Get Access of created senders information.
873
+ @param {Array} data contains php array with key value pair.
874
+ @options data {String} option: Options to get senders. Possible options – IP-wise, & Domain-wise
875
+ ( only for dedicated IP clients ). Example: to get senders with specific IP, use $option=’1.2.3.4′,
876
+ to get senders with specific domain use, $option=’domain.com’, & to get all senders, use $option=""
877
+ [Optional]
878
+ */
879
+ public function getSenders($data)
880
+ {
881
+ return $this->get("advanced", json_encode($data));
882
+ }
883
+
884
+ /*
885
+ Create your Senders.
886
+ @param {Array} data contains php array with key value pair.
887
+ @options data {String} name: Name of the sender [Mandatory]
888
+ @options data {String} email: Email address of the sender [Mandatory]
889
+ @options data {Array} ip_domain: Pass pipe ( | ) separated Dedicated IP and its associated Domain.
890
+ Example: "1.2.3.4|mydomain.com". You can use commas to separate multiple ip_domain’s [Mandatory: Only
891
+ for Dedicated IP clients, for Shared IP clients, it should be kept blank]
892
+ */
893
+ public function createSender($data)
894
+ {
895
+ return $this->post("advanced", json_encode($data));
896
+ }
897
+
898
+ /*
899
+ Update your Senders.
900
+ @param {Array} data contains php array with key value pair.
901
+ @options data {Integer} id: Id of sender to be modified [Mandatory]
902
+ @options data {String} name: Name of the sender [Mandatory]
903
+ @options data {Array} ip_domain: Pass pipe ( | ) separated Dedicated IP and its associated Domain.
904
+ Example: "1.2.3.4|mydomain.com". You can use commas to separate multiple ip_domain’s [Mandatory:
905
+ Only for Dedicated IP clients, for Shared IP clients, it should be kept blank]
906
+ */
907
+ public function updateSender($data)
908
+ {
909
+ $id = $data['id'];
910
+ unset($data['id']);
911
+ return $this->put("advanced/".$id, json_encode($data));
912
+ }
913
+
914
+ /*
915
+ Delete your Sender Information.
916
+ @param {Array} data contains php array with key value pair.
917
+ @options data {Integer} id: Id of sender to be deleted [Mandatory]
918
+ */
919
+ public function deleteSender($data)
920
+ {
921
+ return $this->delete("advanced/".$data['id'], "");
922
+ }
923
+
924
+ /*
925
+ Send Transactional Email.
926
+ @param {Array} data contains php array with key value pair.
927
+ @options data {Array} to: Email address of the recipient(s). It should be sent as an associative
928
+ array. Example: array("to@example.net"=>"to whom"). You can use commas to separate multiple recipients
929
+ [Mandatory]
930
+ @options data {String} subject: Message subject [Mandatory]
931
+ @options data {Array} from Email address for From header. It should be sent as an array. Example: array
932
+ ("from@email.com","from email") [Mandatory]
933
+ @options data {String} html: Body of the message. (HTML version) [Mandatory]. To send inline images,
934
+ use <img src="{YourFileName.Extension}" alt="image" border="0" >, the 'src' attribute value inside {}
935
+ (curly braces) should be same as the filename used in 'inline_image' parameter
936
+ @options data {String} text: Body of the message. (text version) [Optional]
937
+ @options data {Array} cc: Same as to but for Cc. Example: array("cc@example.net","cc whom") [Optional]
938
+ @options data {Array} bcc: Same as to but for Bcc. Example: array("bcc@example.net","bcc whom")
939
+ [Optional]
940
+ @options data {Array} replyto: Same as from but for Reply To. Example: array("from@email.com","from
941
+ email") [Optional]
942
+ @options data {Array} attachment: Provide the absolute url of the attachment/s. Possible extension
943
+ values = gif, png, bmp, cgm, jpg, jpeg, txt, css, shtml, html, htm, csv, zip, pdf, xml, doc, xls, ppt,
944
+ tar, and ez. To send attachment/s generated on the fly you have to pass your attachment/s filename &
945
+ its base64 encoded chunk data as an associative array. Example: array("YourFileName.
946
+ Extension"=>"Base64EncodedChunkData"). You can use commas to separate multiple attachments [Optional]
947
+ @options data {Array} headers: The headers will be sent along with the mail headers in original email.
948
+ Example: array("Content-Type"=>"text/html; charset=iso-8859-1"). You can use commas to separate
949
+ multiple headers [Optional]
950
+ @options data {Array} inline_image: Pass your inline image/s filename & its base64 encoded chunk
951
+ data as an associative array. Example: array("YourFileName.Extension"=>"Base64EncodedChunkData").
952
+ You can use commas to separate multiple inline images [Optional]
953
+ */
954
+ public function sendEmail($data)
955
+ {
956
+ return $this->post("email", json_encode($data));
957
+ }
958
+
959
+ /*
960
+ Aggregate / date-wise report of the SendinBlue SMTP account.
961
+ @param {Array} data contains php array with key value pair.
962
+ @options data {Integer} aggregate: This is used to indicate, you are interested in all-time totals.
963
+ Possible values – 0 & 1. aggregate = 0 means it will not aggregate records, and will show stats per
964
+ day/date wise [Optional]
965
+ @options data {String} start_date: The start date to look up statistics. Date must be in YYYY-MM-DD
966
+ format and should be before the end_date [Optional]
967
+ @options data {String} end_date: The end date to look up statistics. Date must be in YYYY-MM-DD
968
+ format and should be after the start_date [Optional]
969
+ @options data {Integer} days: Number of days in the past to include statistics ( Includes today ).
970
+ It must be an integer greater than 0 [Optional]
971
+ @options data {String} tag: The tag you will specify to retrieve detailed stats. It must be an
972
+ existing tag that has statistics [Optional]
973
+ */
974
+ public function getStatistics($data)
975
+ {
976
+ return $this->post("statistics", json_encode($data));
977
+ }
978
+
979
+ /*
980
+ Get Email Event report.
981
+ @param {Array} data contains php array with key value pair.
982
+ @options data {Integer} limit: To limit the number of results returned. It should be an integer
983
+ [Optional]
984
+ @options data {String} start_date: The start date to get report from. Date must be in YYYY-MM-DD
985
+ format and should be before the end_date [Optional]
986
+ @options data {String} end_date: The end date to get report till date. Date must be in YYYY-MM-DD
987
+ format and should be after the start_date [Optional]
988
+ @options data {Integer} offset: Beginning point in the list to retrieve from. It should be an integer
989
+ [Optional]
990
+ @options data {String} date: Specific date to get its report. Date must be in YYYY-MM-DD format and
991
+ should be earlier than todays date [Optional]
992
+ @options data {Integer} days: Number of days in the past (includes today). If specified, must be an
993
+ integer greater than 0 [Optional]
994
+ @options data {String} email: Email address to search report for [Optional]
995
+ */
996
+ public function getReport($data)
997
+ {
998
+ return $this->post("report", json_encode($data));
999
+ }
1000
+
1001
+ /*
1002
+ Delete any hardbounce, which actually would have been blocked due to some temporary ISP failures.
1003
+ @param {Array} data contains php array with key value pair.
1004
+ @options data {String} start_date: The start date to get report from. Date must be in
1005
+ YYYY-MM-DD format and should be before the end_date [Optional]
1006
+ @options data {String} end_date: The end date to get report till date. Date must be in
1007
+ YYYY-MM-DD format and should be after the start_date [Optional]
1008
+ @options data {String} email: Email address to delete its bounces [Optional]
1009
+ */
1010
+ public function deleteBounces($data)
1011
+ {
1012
+ return $this->post("bounces", json_encode($data));
1013
+ }
1014
+
1015
+ /*
1016
+ Send templates created on SendinBlue, through SendinBlue SMTP (transactional mails).
1017
+ @param {Array} data contains php array with key value pair.
1018
+ @options data {Integer} id: Id of the template created on SendinBlue account [Mandatory]
1019
+ @options data {String} to: Email address of the recipient(s). You can use pipe ( | )
1020
+ to separate multiple recipients. Example: "to-example@example.net|to2-example@example.net"
1021
+ [Mandatory]
1022
+ @options data {String} cc: Same as to but for Cc [Optional]
1023
+ @options data {String} bcc: Same as to but for Bcc [Optional]
1024
+ @options data {Array} attrv The name of attribute present in your SendinBlue account. It should
1025
+ be sent as an associative array. Example: array("NAME"=>"name"). You can use commas to separate
1026
+ multiple attributes [Optional]
1027
+ @options data {String} attachment_url: Provide the absolute url of the attachment. Url not allowed
1028
+ from local machine. File must be hosted somewhere [Optional]
1029
+ @options data {Array} attachment: To send attachment/s generated on the fly you have to pass
1030
+ your attachment/s filename & its base64 encoded chunk data as an associative array [Optional]
1031
+ */
1032
+ public function sendTransactionalTemplate($data)
1033
+ {
1034
+ $id = $data['id'];
1035
+ unset($data['id']);
1036
+ return $this->put("template/".$id, json_encode($data));
1037
+ }
1038
+
1039
+ /*
1040
+ Create a Template.
1041
+ @param {Array} data contains php array with key value pair.
1042
+ @options data {String} from_name: Sender name from which the campaign emails are sent
1043
+ [Mandatory: for Dedicated IP clients & for Shared IP clients, if sender exists]
1044
+ @options data {String} template_name: Name of the Template [Mandatory]
1045
+ @options data {String} bat: Email address for test mail [Optional]
1046
+ @options data {String} html_content: Body of the content. The HTML content field must have more
1047
+ than 10 characters [Mandatory: if html_url is empty]
1048
+ @options data {String} html_url Url: which content is the body of content [Mandatory: if
1049
+ html_content is empty]
1050
+ @options data {String} subject: Subject of the campaign [Mandatory]
1051
+ @options data {String} from_email: Sender email from which the campaign emails are sent
1052
+ [Mandatory: for Dedicated IP clients & for Shared IP clients, if sender exists]
1053
+ @options data {String} reply_to: The reply to email in the campaign emails [Optional]
1054
+ @options data {String} to_fieldv This is to personalize the «To» Field. If you want to include
1055
+ the first name and last name of your recipient, add [PRENOM] [NOM]. To use the contact attributes
1056
+ here, these should already exist in SendinBlue account [Optional]
1057
+ @options data {Integer} status: Status of template. Possible values = 0 (default) & 1. status = 0
1058
+ means template is inactive, & status = 1 means template is active [Optional]
1059
+ @options data {Integer} attachment: Status of attachment. Possible values = 0 (default) & 1.
1060
+ attach = 0 means an attachment can’t be sent, & attach = 1 means an attachment can be sent, in
1061
+ the email [Optional]
1062
+ */
1063
+ public function createTemplate($data)
1064
+ {
1065
+ return $this->post("template", json_encode($data));
1066
+ }
1067
+
1068
+ /*
1069
+ Update a Template.
1070
+ @param {Array} data contains php array with key value pair.
1071
+ @options data {Integer} id: Id of Template to be modified [Mandatory]
1072
+ @options data {String} from_name: Sender name from which the campaign emails are sent
1073
+ [Mandatory: for Dedicated IP clients & for Shared IP clients, if sender exists]
1074
+ @options data {String} template_name: Name of the Template [Mandatory]
1075
+ @options data {String} bat: Email address for test mail [Optional]
1076
+ @options data {String} html_content: Body of the content. The HTML content field must have
1077
+ more than 10 characters [Mandatory: if html_url is empty]
1078
+ @options data {String} html_url: Url which content is the body of content [Mandatory: if
1079
+ html_content is empty]
1080
+ @options data {String} subject: Subject of the campaign [Mandatory]
1081
+ @options data {String} from_email: Sender email from which the campaign emails are sent
1082
+ [Mandatory: for Dedicated IP clients & for Shared IP clients, if sender exists]
1083
+ @options data {String} reply_to: The reply to email in the campaign emails [Optional]
1084
+ @options data {String} to_field: This is to personalize the «To» Field. If you want to include the
1085
+ first name and last name of your recipient, add [PRENOM] [NOM]. To use the contact attributes here,
1086
+ these should already exist in SendinBlue account [Optional]
1087
+ @options data {Integer} status: Status of template. Possible values = 0 (default) & 1. status = 0
1088
+ means template is inactive, & status = 1 means template is active [Optional]
1089
+ @options data {Integer} attachment: Status of attachment. Possible values = 0 (default) & 1.
1090
+ attach = 0 means an attachment can’t be sent, & attach = 1 means an attachment can be sent, in the
1091
+ email [Optional]
1092
+ */
1093
+ public function updateTemplate($data)
1094
+ {
1095
+ $id = $data['id'];
1096
+ unset($data['id']);
1097
+ return $this->put("template/".$id, json_encode($data));
1098
+ }
1099
+
1100
+ /*
1101
+ Send a transactional SMS.
1102
+ @param {Array} data contains php array with key value pair.
1103
+ @options data {String} to: The mobile number to send SMS to with country code [Mandatory]
1104
+ @options data {String} from: The name of the sender. The number of characters is limited to 11
1105
+ (alphanumeric format) [Mandatory]
1106
+ @options data {String} text: The text of the message. The maximum characters used per SMS is 160,
1107
+ if used more than that, it will be counted as more than one SMS [Mandatory]
1108
+ @options data {String} web_url: The web URL that can be called once the message is successfully
1109
+ delivered [Optional]
1110
+ @options data {String} tag: The tag that you can associate with the message [Optional]
1111
+ @options data {String} type: Type of message. Possible values – marketing (default) & transactional.
1112
+ You can use marketing for sending marketing SMS, & for sending transactional SMS, use transactional
1113
+ type [Optional]
1114
+ */
1115
+ public function sendSms($data)
1116
+ {
1117
+ return $this->post("sms", json_encode($data));
1118
+ }
1119
+
1120
+ /*
1121
+ Create & Schedule your SMS campaigns.
1122
+ @param {Array} data contains php array with key value pair.
1123
+ @options data {String} name: Name of the SMS campaign [Mandatory]
1124
+ @options data {String} sender: This allows you to customize the SMS sender. The number of
1125
+ characters is limited to 11 ( alphanumeric format ) [Optional]
1126
+ @options data {String} content: Content of the message. The maximum characters used per SMS is 160,
1127
+ if used more than that, it will be counted as more than one SMS [Optional]
1128
+ @options data {String} bat: Mobile number with the country code to send test SMS. The mobile number
1129
+ defined here should belong to one of your contacts in SendinBlue account and should not be blacklisted
1130
+ [Optional]
1131
+ @options data {Array} listid: These are the list ids to which the SMS campaign is sent [Mandatory: if
1132
+ scheduled_date is not empty]
1133
+ @options data {Array} exclude_list: These are the list ids which will be excluded from the SMS
1134
+ campaign [Optional]
1135
+ @options data {String} scheduled_date: The day on which the SMS campaign is supposed to run [Optional]
1136
+ @options data {Integer} send_now: Flag to send campaign now. Possible values = 0 (default) & 1.
1137
+ send_now = 0 means campaign can’t be send now, & send_now = 1 means campaign ready to send now
1138
+ [Optional]
1139
+ */
1140
+ public function createSmsCampaign($data)
1141
+ {
1142
+ return $this->post("sms", json_encode($data));
1143
+ }
1144
+
1145
+ /*
1146
+ Update your SMS campaigns.
1147
+ @param {Array} data contains php array with key value pair.
1148
+ @options data {Integer} id: Id of the SMS campaign [Mandatory]
1149
+ @options data {String} name: Name of the SMS campaign [Optional]
1150
+ @options data {String} sender: This allows you to customize the SMS sender. The number of characters
1151
+ is limited to 11 ( alphanumeric format ) [Optional]
1152
+ @options data {String} content: Content of the message. The maximum characters used per SMS is 160,
1153
+ if used more than that, it will be counted as more than one SMS [Optional]
1154
+ @options data {String} bat: Mobile number with the country code to send test SMS. The mobile number
1155
+ defined here should belong to one of your contacts in SendinBlue account and should not be blacklisted
1156
+ [Optional]
1157
+ @options data {Array} listid: hese are the list ids to which the SMS campaign is sent [Mandatory: if
1158
+ scheduled_date is not empty]
1159
+ @options data {Array} exclude_list: These are the list ids which will be excluded from the SMS campaign
1160
+ [Optional]
1161
+ @options data {String} scheduled_date: The day on which the SMS campaign is supposed to run [Optional]
1162
+ @options data {Integer} send_now: Flag to send campaign now. Possible values = 0 (default) & 1.
1163
+ send_now = 0 means campaign can’t be send now, & send_now = 1 means campaign ready to send now
1164
+ [Optional]
1165
+ */
1166
+ public function updateSmsCampaign($data)
1167
+ {
1168
+ $id = $data['id'];
1169
+ unset($data['id']);
1170
+ return $this->put("sms/".$id, json_encode($data));
1171
+ }
1172
+
1173
+ /*
1174
+ Send a Test SMS.
1175
+ @param {Array} data contains php array with key value pair.
1176
+ @options data {Integer} id: Id of the SMS campaign [Mandatory]
1177
+ @options data {String} to: Mobile number with the country code to send test SMS. The mobile
1178
+ number defined here should belong to one of your contacts in SendinBlue account and should not be
1179
+ blacklisted [Mandatory]
1180
+ */
1181
+ public function sendBatSms($data)
1182
+ {
1183
+ $id = $data['id'];
1184
+ unset($data['id']);
1185
+ return $this->get("sms/".$id, json_encode($data));
1186
+ }
1187
+ }
app/code/community/Sendinblue/Sendinblue/Model/Sendinblue.php ADDED
@@ -0,0 +1,1579 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @author Sendinblue plateform <contact@sendinblue.com>
4
+ * @copyright 2013-2014 Sendinblue
5
+ * URL: https:www.sendinblue.com
6
+ * Do not edit or add to this file if you wish to upgrade Sendinblue Magento plugin to newer
7
+ * versions in the future. If you wish to customize Sendinblue magento plugin for your
8
+ * needs then we can't provide a technical support.
9
+ **/
10
+ class Sendinblue_Sendinblue_Model_Sendinblue extends Mage_Core_Model_Abstract
11
+ {
12
+ var $api_url;
13
+ var $api_key;
14
+ var $smtp_status;
15
+ var $error_message;
16
+ var $error_code;
17
+ var $lists_ids;
18
+ var $module_enable;
19
+ var $st;
20
+ public function _construct()
21
+ {
22
+ parent::_construct();
23
+ $this->_init('sendinblue/sendinblue');
24
+ $this->MIAPI();
25
+ }
26
+ /**
27
+ * functions used for set module config
28
+ */
29
+ public function MIAPI()
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
+ $value_language = $this->getApiConfigValue();
36
+ $this->user_language = $value_language->language;
37
+ if (!$this->lists_ids)
38
+ $this->lists_ids = str_replace(',', '|', $this->getUserlists($scope));
39
+
40
+ $params = Mage::app()->getRequest()->getParams();
41
+ $params = empty($params)?array():$params;
42
+ if (isset($params['sendin_apikey']) && $params['sendin_apikey'] != '')
43
+ $this->CreateFolderCaseTwo();
44
+ }
45
+
46
+ public function checkMobileNumber($number, $call_prefix)
47
+ {
48
+ $number = preg_replace('/\s+/', '', $number);
49
+ $charone = substr($number, 0, 1);
50
+ $chartwo = substr($number, 0, 2);
51
+
52
+ if (preg_match('/^'.$call_prefix.'/', $number))
53
+ return '00'.$number;
54
+
55
+ elseif ($charone == '0' && $chartwo != '00')
56
+ {
57
+ if (preg_match('/^0'.$call_prefix.'/', $number))
58
+ return '00'.substr($number, 1);
59
+ else
60
+ return '00'.$call_prefix.substr($number, 1);
61
+ }
62
+ elseif ($chartwo == '00')
63
+ {
64
+ if (preg_match('/^00'.$call_prefix.'/', $number))
65
+ return $number;
66
+ else
67
+ return '00'.$call_prefix.substr($number, 2);
68
+ }
69
+ elseif ($charone == '+')
70
+ {
71
+ if (preg_match('/^\+'.$call_prefix.'/', $number))
72
+ return '00'.substr($number, 1);
73
+ else
74
+ return '00'.$call_prefix.substr($number, 1);
75
+ }
76
+ elseif ($charone != '0')
77
+ return '00'.$call_prefix.$number;
78
+ }
79
+ /**
80
+ * functions used for getting module status
81
+ */
82
+ public function getEnableStatus()
83
+ {
84
+ $status = $this->getGeneralConfig('enabled', Mage::app()->getStore()->getStoreId());
85
+ if (!$status)
86
+ return false;
87
+ return $status;
88
+ }
89
+ /**
90
+ * functions used for send order sms module status
91
+ */
92
+ public function getOrderSmsStatus()
93
+ {
94
+ $status = $this->getGeneralConfig('sms/order', Mage::app()->getStore()->getStoreId());
95
+ if (!$status)
96
+ return false;
97
+ return $status;
98
+ }
99
+ /**
100
+ * functions used for getting notify sms status
101
+ */
102
+ public function getNotifySmsStatus()
103
+ {
104
+ $status = $this->getGeneralConfig('sms/credit', Mage::app()->getStore()->getStoreId());
105
+ if (!$status)
106
+ return false;
107
+ return $status;
108
+ }
109
+ /**
110
+ * functions used for getting Notify value limit
111
+ */
112
+ public function getNotifyValueStatus()
113
+ {
114
+ $status = $this->getGeneralConfig('Sendin_Notify_Value', Mage::app()->getStore()->getStoreId());
115
+ if (!$status)
116
+ return false;
117
+ return $status;
118
+ }
119
+ /**
120
+ * functions used for getting Notify email limit
121
+ */
122
+ public function getNotifyEmailStatus()
123
+ {
124
+ $status = $this->getGeneralConfig('Sendin_Notify_Email', Mage::app()->getStore()->getStoreId());
125
+ if (!$status)
126
+ return false;
127
+ return $status;
128
+ }
129
+ /**
130
+ * functions used for getting Notify email limit
131
+ */
132
+ public function getNotifyCronStatus()
133
+ {
134
+ $status = $this->getGeneralConfig('Sendin_Notify_Cron_Executed', Mage::app()->getStore()->getStoreId());
135
+ if (!$status)
136
+ return false;
137
+ return $status;
138
+ }
139
+ /**
140
+ * functions used for getting shiping sms status
141
+ */
142
+ public function getShipingSmsStatus()
143
+ {
144
+ $status = $this->getGeneralConfig('sms/shiping', Mage::app()->getStore()->getStoreId());
145
+ if (!$status)
146
+ return false;
147
+ return $status;
148
+ }
149
+
150
+ /**
151
+ * functions used for getting campaign sms status
152
+ */
153
+ public function getCampaignStatus()
154
+ {
155
+ $status = $this->getGeneralConfig('sms/campaign', Mage::app()->getStore()->getStoreId());
156
+ if (!$status)
157
+ return false;
158
+ return $status;
159
+ }
160
+
161
+ /**
162
+ * functions used for getting send sms order subject
163
+ */
164
+ public function getSendSmsOrderSubject()
165
+ {
166
+ $status = $this->getGeneralConfig('Sendin_Sender_Order', Mage::app()->getStore()->getStoreId());
167
+ if (!$status)
168
+ return false;
169
+ return $status;
170
+ }
171
+
172
+ /**
173
+ * functions used for getting order sms message
174
+ */
175
+ public function getSendSmsmOrderMessage()
176
+ {
177
+ $status = $this->getGeneralConfig('Sendin_Sender_Order_Message', Mage::app()->getStore()->getStoreId());
178
+ if (!$status)
179
+ return false;
180
+ return $status;
181
+ }
182
+
183
+ /**
184
+ *functions used for getting send sms shiping subject
185
+ */
186
+ public function getSendSmsShipingSubject()
187
+ {
188
+ $status = $this->getGeneralConfig('Sendin_Sender_Shipment', Mage::app()->getStore()->getStoreId());
189
+ if (!$status)
190
+ return false;
191
+ return $status;
192
+ }
193
+
194
+ /**
195
+ *functions used for getting shiping sms message
196
+ */
197
+ public function getSendSmsShipingMessage()
198
+ {
199
+ $status = $this->getGeneralConfig('Sendin_Sender_Shipment_Message', Mage::app()->getStore()->getStoreId());
200
+ if (!$status)
201
+ return false;
202
+ return $status;
203
+ }
204
+
205
+ /**
206
+ * functions used for get api key
207
+ */
208
+ public function getApiKey()
209
+ {
210
+ $apikey = $this->getGeneralConfig('api', Mage::app()->getStore()->getStoreId());
211
+ if (!$apikey)
212
+ return false;
213
+ return $apikey;
214
+ }
215
+
216
+ /**
217
+ * functions used for get SMPT password
218
+ */
219
+ public function getSmtpPassword()
220
+ {
221
+ $smtpPassword = $this->getSendinSmtpStatus('password', Mage::app()->getStore()->getStoreId());
222
+ if (!$smtpPassword)
223
+ return false;
224
+ return $smtpPassword;
225
+ }
226
+
227
+ /**
228
+ * functions used for get user name
229
+ */
230
+ public function getUserName()
231
+ {
232
+ $userName = $this->getSendinSmtpStatus('username', Mage::app()->getStore()->getStoreId());
233
+ if (!$userName)
234
+ return false;
235
+ return $userName;
236
+ }
237
+
238
+ /**
239
+ * functions used for getting smtp status
240
+ */
241
+ public function getSmtpStatus()
242
+ {
243
+ $status = $this->getSendinSmtpStatus('status', Mage::app()->getStore()->getStoreId());
244
+ if (!$status)
245
+ return false;
246
+ return $status;
247
+ }
248
+
249
+ /**
250
+ * functions used for getting tracking status
251
+ */
252
+ public function getTrackingStatus()
253
+ {
254
+ $status = $this->getSendinTrackingCodeStatus('code', Mage::app()->getStore()->getStoreId());
255
+ if (!$status) {
256
+ return false;
257
+ }
258
+ return $status;
259
+ }
260
+
261
+ /**
262
+ * functions used for getting tracking status
263
+ */
264
+ public function getTrackingHistoryStatus()
265
+ {
266
+ $status = $this->getSendinTrackingHistoryStatus('history', Mage::app()->getStore()->getStoreId());
267
+ if (!$status) {
268
+ return false;
269
+ }
270
+ return $status;
271
+ }
272
+
273
+ /**
274
+ * functions used for getting userlists
275
+ */
276
+ public function getUserlists()
277
+ {
278
+ $userlist = $this->getGeneralConfig('list', Mage::app()->getStore()->getStoreId());
279
+ if (!$userlist)
280
+ return false;
281
+ return $userlist;
282
+ }
283
+
284
+ /**
285
+ * functions used for getting importOldSubscribers status
286
+ */
287
+ public function getImportOldSubsStatus()
288
+ {
289
+ $importStatus = $this->getGeneralConfig('importOldUserStatus', Mage::app()->getStore()->getStoreId());
290
+ if (!$importStatus)
291
+ return false;
292
+ return $importStatus;
293
+ }
294
+
295
+ /**
296
+ * functions used for get templateid
297
+ */
298
+ public function getTemplateId()
299
+ {
300
+ $TemplateId = $this->getGeneralConfig('SendinTemplateId', Mage::app()->getStore()->getStoreId());
301
+ if (!$TemplateId)
302
+ return false;
303
+ return $TemplateId;
304
+ }
305
+ /**
306
+ * functions used for get value final email recive.
307
+ */
308
+ public function getFinalTemplate()
309
+ {
310
+ $FinalTemplate = $this->getGeneralConfig('SendinTemplateFinal', Mage::app()->getStore()->getStoreId());
311
+ if (!$FinalTemplate)
312
+ return false;
313
+ return $FinalTemplate;
314
+ }
315
+ /**
316
+ * functions used for get value subscribe type like doubleoptin and simple.
317
+ */
318
+ public function getSubscribeConfirmType()
319
+ {
320
+ $SubscribeConfirmType = $this->getGeneralConfig('SendinSubscribeConfirmType', Mage::app()->getStore()->getStoreId());
321
+ if (!$SubscribeConfirmType)
322
+ return false;
323
+ return $SubscribeConfirmType;
324
+ }
325
+ /**
326
+ * functions used for get value for redirect url
327
+ */
328
+ public function getOptinRedirectUrlCheck()
329
+ {
330
+ $OptinRedirectUrlCheck = $this->getGeneralConfig('SendinOptinRedirectUrlCheck', Mage::app()->getStore()->getStoreId());
331
+ if (!$OptinRedirectUrlCheck)
332
+ return false;
333
+ return $OptinRedirectUrlCheck;
334
+ }
335
+ /**
336
+ * functions used for get double optin redirect url after click email link.
337
+ */
338
+ public function getSendinDoubleoptinRedirectUrl()
339
+ {
340
+ $SendinDoubleoptinRedirectUr = $this->getGeneralConfig('SendinDoubleoptinRedirectUrl', Mage::app()->getStore()->getStoreId());
341
+ if (!$SendinDoubleoptinRedirectUr)
342
+ return false;
343
+ return $SendinDoubleoptinRedirectUr;
344
+ }
345
+ /**
346
+ * functions used for get final confirmation email for double optin functionality.
347
+ */
348
+ public function getSendinFinalConfirmEmail()
349
+ {
350
+ $SendinFinalConfirmEmail = $this->getGeneralConfig('SendinFinalConfirmEmail', Mage::app()->getStore()->getStoreId());
351
+ if (!$SendinFinalConfirmEmail)
352
+ return false;
353
+ return $SendinFinalConfirmEmail;
354
+ }
355
+
356
+ /**
357
+ * functions used for get doubleoptin id geting by sendinblue.
358
+ */
359
+ public function getSendinOptinListId()
360
+ {
361
+ $SendinOptinListId = $this->getGeneralConfig('SendinOptinListId', Mage::app()->getStore()->getStoreId());
362
+ if (!$SendinOptinListId)
363
+ return false;
364
+ return $SendinOptinListId;
365
+ }
366
+
367
+ /**
368
+ * functions used for getting general config
369
+ */
370
+ public function getGeneralConfig($field, $store = null)
371
+ {
372
+ return Mage::getStoreConfig('sendinblue/'.$field, $store);
373
+ }
374
+
375
+ /**
376
+ * functions used for get sendinsmtp status
377
+ */
378
+ public function getSendinSmtpStatus($field, $store = null)
379
+ {
380
+ return Mage::getStoreConfig('sendinblue/smtp/'.$field, $store);
381
+ }
382
+
383
+ /**
384
+ * functions used for get sendinblue email status
385
+ */
386
+ public function getSyncronizeStatus()
387
+ {
388
+ return $this->getGeneralConfig('syncronize', Mage::app()->getStore()->getStoreId());
389
+ }
390
+ /**
391
+ * functions used for get sendin tracking status
392
+ */
393
+ public function getSendinTrackingCodeStatus($field, $store = null)
394
+ {
395
+ return Mage::getStoreConfig('sendinblue/tracking/'.$field, $store);
396
+ }
397
+
398
+ /**
399
+ * functions used for get sendin tracking history status
400
+ */
401
+ public function getSendinTrackingHistoryStatus($field, $store = null)
402
+ {
403
+ return Mage::getStoreConfig('sendinblue/improt/'.$field, $store);
404
+ }
405
+
406
+ /**
407
+ * functions used for module functionality
408
+ */
409
+ public function getLists()
410
+ {
411
+ return $this->lists();
412
+ }
413
+
414
+ /**
415
+ * functions used for email adds
416
+ */
417
+ public function emailAdd($email, $extra, $is_subscribed = '', $list_id = '')
418
+ {
419
+ $attributesName = $this->allAttributesName();
420
+ if ($this->module_enable == 1 && $this->getSyncronizeStatus())
421
+ {
422
+ $apikey = $this->api_key;
423
+ if (!$apikey)
424
+ return false;
425
+
426
+ $Sendin_Confirm_Type = Mage::getStoreConfig('sendinblue/SendinSubscribeConfirmType');
427
+ if (empty($list_id)) {
428
+ if (isset($Sendin_Confirm_Type) && $Sendin_Confirm_Type === 'doubleoptin') {
429
+ $list_id = Mage::getStoreConfig('sendinblue/SendinOptinListId');
430
+ } else {
431
+ $list_id = $this->lists_ids;
432
+ }
433
+ }
434
+ $params = array();
435
+ $params['email'] = $email;
436
+ $params['id'] = '';
437
+ if ($is_subscribed != '')
438
+ $params['blacklisted'] = 0;
439
+
440
+ if ($extra != null)
441
+ {
442
+ $key_value = array_keys($attributesName);
443
+ $attrName = implode('|', $key_value);
444
+ $params['attributes_name'] = $attrName;
445
+ $attrValue = implode('|', $extra);
446
+ $params['attributes_value'] = $attrValue;
447
+ } else
448
+ {
449
+ $params['attributes_value'] = $email;
450
+ }
451
+ $params['listid'] = $list_id;
452
+
453
+ return $this->callServer('USERCREADITM', $params);
454
+ } else
455
+ return false;
456
+ }
457
+
458
+ /**
459
+ * functions subscribeuser
460
+ */
461
+ public function emailSubscribe($email)
462
+ {
463
+ if ($this->module_enable == 1 && $this->getSyncronizeStatus())
464
+ {
465
+ $apikey = $this->api_key;
466
+ $timezone = Mage::app()->getStore()->getConfig('general/locale/timezone');
467
+ $timez = str_replace('Calcutta', 'Kolkata', $timezone);
468
+ $tm = date("Y-m-d H:i:s", Mage::getModel('core/date')->timestamp(time()));
469
+
470
+ if (!$apikey)
471
+ return false;
472
+ $data = array();
473
+ $data['key'] = $apikey;
474
+ $data['webaction'] = 'UPDATE-USER-SUBSCRIPTION-STATUS';
475
+ $data['timezone'] = $timez;
476
+ $data['user_status'] = $email.', '.'1'.', '.$tm;
477
+ return $this->curlRequest($data);
478
+ } else
479
+ return false;
480
+ }
481
+
482
+ /**
483
+ * functions used for sync data
484
+ */
485
+ public function syncData()
486
+ {
487
+ if ($this->module_enable == 1 && $this->getSyncronizeStatus())
488
+ {
489
+ $apikey = $this->api_key;
490
+ if (!$apikey)
491
+ return false;
492
+ $params = array();
493
+ $params['listids'] = str_replace(',', '|', $this->lists_ids);
494
+ $response = $this->callServer('DISPLAYLISTDATABLACK', $params);
495
+ $result_arr = $response->result;
496
+ $collection = Mage::getResourceModel('newsletter/subscriber_collection')->showStoreInfo()->showCustomerInfo()->toArray();
497
+ $subscriber_data = $collection['items'];
498
+ $emails = array();
499
+ $subscriber_data_email = array();
500
+ foreach($subscriber_data as $s)
501
+ {
502
+ $subscriber_data_email[$s['subscriber_email']] = $s;
503
+ }
504
+
505
+ if (count($result_arr) > 0)
506
+ {
507
+ $newsletterSub = Mage::getModel('newsletter/subscriber');
508
+ foreach ($result_arr as $key => $value)
509
+ {
510
+ foreach ($value as $user_data)
511
+ {
512
+ if(isset($subscriber_data_email[$user_data->email]))
513
+ {
514
+ // on a trouvé le subscriber magento
515
+ $data = $subscriber_data_email[$user_data->email];
516
+ $temp_sub_status = ($data['subscriber_status'] == 3) ? 1 : 0;
517
+ if ($temp_sub_status != $user_data->blacklisted)
518
+ {
519
+ $emails[] = $data['subscriber_email'];
520
+ $subscribe_data['subscriber_id'] = $data['subscriber_id'];
521
+ $subscribe_data['subscriber_status'] = ($user_data->blacklisted == 1)?3:1;
522
+ $costomer_data = $newsletterSub->loadByEmail($data['subscriber_email']);
523
+ $costomer_data->setStatus($subscribe_data['subscriber_status']);
524
+ $costomer_data->setIsStatusChanged(true);
525
+ $costomer_data->save();
526
+ }
527
+ }
528
+ }
529
+ }
530
+ }
531
+ if (count($emails) > 0)
532
+ Mage::getModel('core/session')->addSuccess(count($emails).Mage::helper('sendinblue')->__(' Total of record(s) have been updated'));
533
+ else
534
+ Mage::getModel('core/session')->addSuccess(count($emails).Mage::helper('sendinblue')->__(' Total of record(s) have been updated'));
535
+ return true;
536
+ }
537
+ else
538
+ return false;
539
+ }
540
+ /**
541
+ * This method is used for add email list
542
+ */
543
+ public function addEmailList($email, $list_id = '')
544
+ {
545
+ if ($this->module_enable == 1 && $this->getSyncronizeStatus())
546
+ {
547
+ $apikey = $this->api_key;
548
+ if (!$apikey)
549
+ return false;
550
+
551
+ $Sendin_Confirm_Type = Mage::getStoreConfig('sendinblue/SendinSubscribeConfirmType');
552
+ if (empty($list_id)) {
553
+ if (isset($Sendin_Confirm_Type) && $Sendin_Confirm_Type === 'doubleoptin') {
554
+ $list_id = Mage::getStoreConfig('sendinblue/SendinOptinListId');
555
+ } else {
556
+ $list_id = $this->lists_ids;
557
+ }
558
+ }
559
+ $params = array();
560
+ $params['email'] = $email;
561
+ $params['id'] = '';
562
+ $params['blacklisted'] = 0;
563
+ $params['attributes_name'] = '';
564
+ $params['attributes_value'] = '';
565
+ $params['listid'] = $list_id;
566
+ return $this->callServer('USERCREADITM', $params);
567
+ } else
568
+ return false;
569
+ }
570
+ /**
571
+ * This method is used used for email unsubscribe
572
+ */
573
+ public function emailDelete($email)
574
+ {
575
+ if ($this->module_enable == 1 && $this->getSyncronizeStatus())
576
+ {
577
+ $apikey = $this->api_key;
578
+ if (!$apikey)
579
+ return false;
580
+ $params = array();
581
+ $params['email'] = $email;
582
+ $params['listid'] = $this->lists_ids;
583
+ return $this->callServer('UNSUBAPI', $params);
584
+ } else
585
+ return false;
586
+ }
587
+
588
+ /**
589
+ * This method is used used for check api status
590
+ */
591
+ public function checkApikey($api_key)
592
+ {
593
+ $params['key'] = $api_key;
594
+ $response = $this->callServer('DISPLAYLISTDATA', $params);
595
+ if (isset($response->errorMsg) && !empty($response->errorMsg))
596
+ return $lists['error'] = $response->errorMsg;
597
+ }
598
+
599
+ /**
600
+ * functions used for smtp details and order tracking
601
+ */
602
+ public function SmtpDetailsWithTracking()
603
+ {
604
+ $params['key'] = $this->api_key;
605
+ $response = $this->callServer('TRACKINGDATA', $params);
606
+ if (isset($response->errorMsg) && !empty($response->errorMsg))
607
+ {
608
+ $tracking['error'] = $response->errorMsg;
609
+ return $tracking;
610
+ }
611
+ return $response;
612
+ }
613
+
614
+ /**
615
+ * Fetches all the list of the user from the Sendinblue platform.
616
+ */
617
+ public function lists($filters = array())
618
+ {
619
+ $params = array();
620
+ $response = $this->callServer('DISPLAYLISTDATA', $params);
621
+ if (isset($response->errorMsg) && !empty($response->errorMsg))
622
+ {
623
+ $this->error_message = $response->errorMsg;
624
+ $lists['error'] = $response->errorMsg;
625
+ } else
626
+ {
627
+ $i = 0;
628
+ $lists = array();
629
+ foreach ($response->result as $list_data)
630
+ {
631
+ $lists[$i]['id'] = $list_data->id;
632
+ $lists[$i]['name'] = $list_data->name;
633
+ $i++;
634
+ }
635
+ }
636
+ return $lists;
637
+ }
638
+
639
+ /**
640
+ * Fetches the list status of the user from the Sendinblue platform.
641
+ */
642
+ public function getUserListStats()
643
+ {
644
+ if ($this->module_enable == 1)
645
+ {
646
+ $params = array();
647
+ $params['list'] = 'ALL';
648
+ return $this->callServer('DISPLAYLISTDATA', $params);
649
+ } else
650
+ return Mage::getModel('core/session')->addError('Sendinblue not enabled');
651
+ }
652
+
653
+ /**
654
+ * Fetches all folders and all list within each folder of the user's Sendinblue
655
+ * account and displays them to the user.
656
+ */
657
+ public function checkFolderListDoubleoptin()
658
+ {
659
+ $params = array();
660
+ $s_array = array();
661
+ $list_response = $this->callServer('DISPLAY-FOLDERS-LISTS', $params);
662
+ $list_response = json_encode($list_response);
663
+ $res = json_decode($list_response, true);
664
+ if (isset($res) && !empty($res))
665
+ {
666
+ foreach ($res as $value)
667
+ {
668
+ if (strtolower($value['name']) == 'form')
669
+ {
670
+ if (!empty($value['lists']))
671
+ {
672
+ foreach ($value['lists'] as $key => $val)
673
+ {
674
+ if ($val['name'] == 'Temp - DOUBLE OPTIN')
675
+ $s_array['optin_id'] = $key;
676
+ }
677
+ }
678
+ }
679
+ }
680
+ if (count($s_array) > 0) {
681
+ $return = $s_array;
682
+ } else {
683
+ $return = false;
684
+ }
685
+ }
686
+ return $return;
687
+ }
688
+ /**
689
+ * Create temporary doubleoptin list if not exist in Sendinblue.
690
+ */
691
+ public function createListIdDoubleoptin()
692
+ {
693
+ $data = array();
694
+ $data['foldername'] = 'FORM';
695
+ $res = $this->callServer('ADDFOLDER', $data);
696
+ $folder_id = $res->folder_id;
697
+ if (!empty($folder_id)) {
698
+ $params = array();
699
+ $params['listname'] = 'Temp - DOUBLE OPTIN';
700
+ $params['list_parent'] = $folder_id;
701
+ $list_response = $this->callServer('NEWLIST', $params);
702
+ $list_id = $list_response->result;
703
+ }
704
+ return $list_id;
705
+ }
706
+
707
+ /**
708
+ * Fetches all folders and all list within each folder of the user's Sendinblue
709
+ * account and displays them to the user.
710
+ */
711
+ public function checkFolderList()
712
+ {
713
+ $params = array();
714
+ $array = array();
715
+ $list_response = $this->callServer('DISPLAY-FOLDERS-LISTS', $params);
716
+ $list_response = json_encode($list_response);
717
+ $res = json_decode($list_response, true);
718
+ if (isset($res) && !empty($res))
719
+ {
720
+ foreach ($res as $key => $value)
721
+ {
722
+ if (strtolower($value['name']) == 'magento')
723
+ {
724
+ $array[] = $key;
725
+ $array[] = $value['name'];
726
+ }
727
+ if (!empty($value['lists']))
728
+ {
729
+ foreach ($value['lists'] as $val)
730
+ {
731
+ if (strtolower($val['name']) == 'magento')
732
+ $array[] = $val['name'];
733
+ }
734
+ }
735
+ }
736
+ }
737
+ return $array;
738
+ }
739
+ /**
740
+ * folder create in Sendinblue after removing from Sendinblue
741
+ */
742
+ public function createFolderCaseTwo()
743
+ {
744
+ $apikey = $this->api_key;
745
+ if($apikey == '')
746
+ return false;
747
+ $response = $this->checkApikey($apikey); // check api key is valid or not
748
+ if ($this->module_enable != 1 && $apikey == '' && $response['error'] != '' && $this->getSyncronizeStatus())
749
+ return false;
750
+ $result = $this->checkFolderList();
751
+ $list_name = 'magento';
752
+ $param = array();
753
+ $data = array();
754
+ $folder_id = $result[0];
755
+ $exist_list = $result[2];
756
+ if (empty($result[1]))
757
+ {
758
+ $params = array();
759
+ $params['foldername'] = 'magento';
760
+ $res = $this->callServer('ADDFOLDER', $params);
761
+ $folder_id = $res->folder_id;
762
+ $params = array();
763
+ $params['listname'] = $list_name;
764
+ $params['list_parent'] = $folder_id; //folder id
765
+ $list_response = $this->callServer('NEWLIST', $params);
766
+ $this->sendAllMailIDToSendin($list_response);
767
+ } elseif (empty($exist_list))
768
+ {
769
+ $params = array();
770
+ $params['listname'] = $list_name;
771
+ $params['list_parent'] = $folder_id; //folder id
772
+ $list_response = $this->callServer('NEWLIST', $params);
773
+ $this->sendAllMailIDToSendin($list_response);
774
+ }
775
+ }
776
+
777
+ /**
778
+ * folder create in Sendinblue after installing
779
+ */
780
+ public function createFolderName($api_key)
781
+ {
782
+ $this->api_key = $api_key;
783
+ $this->createAttributesName();
784
+ $result = $this->checkFolderList();
785
+ if (empty($result[1]))
786
+ {
787
+ $params = array();
788
+ $params['foldername'] = 'magento';
789
+ $res = $this->callServer('ADDFOLDER', $params);
790
+ $folder_id = $res->folder_id;
791
+ $exist_list = '';
792
+ } else
793
+ {
794
+ $folder_id = $result[0];
795
+ $exist_list = $result[2];
796
+ }
797
+ $this->createNewList($folder_id, $exist_list);
798
+ $this->partnerMagento();
799
+ }
800
+
801
+ /**
802
+ * Method is used to add the partner's name in Sendinblue.
803
+ * In this case its "MAGENTO".
804
+ */
805
+ public function partnerMagento()
806
+ {
807
+ $params = array();
808
+ $params['partner'] = 'MAGENTO';
809
+ $this->callServer('MAILIN-PARTNER', $params);
810
+ }
811
+
812
+ /**
813
+ * Creates a list by the name "magento" on user's Sendinblue account.
814
+ */
815
+ public function createNewList($response, $exist_list)
816
+ {
817
+ if ($exist_list != '')
818
+ {
819
+ $date = date('dmY');
820
+ $list_name = 'magento_'.$date;
821
+ }
822
+ else
823
+ $list_name = 'magento';
824
+ $params = array();
825
+ $params['listname'] = $list_name;
826
+ $params['list_parent'] = $response;
827
+ $list_response = $this->callServer('NEWLIST', $params);
828
+ $this->sendAllMailIDToSendin($list_response);
829
+ $this->createAttributesName();
830
+ }
831
+
832
+ /**
833
+ * Fetch attributes and their values
834
+ * on Sendinblue platform. This is necessary for the Prestashop to add subscriber's details.
835
+ */
836
+ public function allAttributesName()
837
+ {
838
+ if ($this->user_language == 'fr')
839
+ $params = array('PRENOM'=>'firstname', 'NOM'=>'lastname', 'MAGENTO_LANG'=>'created_in','CLIENT'=>'client','SMS'=>'telephone','COMPANY'=>'company','CITY'=>'city','COUNTRY_ID'=>'country_id','POSTCODE'=>'postcode','STREET'=>'street','REGION'=>'region','STORE_ID'=>'store_id');
840
+ else
841
+ $params = array('NAME'=>'firstname', 'SURNAME'=>'lastname', 'MAGENTO_LANG'=>'created_in','CLIENT'=>'client','SMS'=>'telephone','COMPANY'=>'company','CITY'=>'city','COUNTRY_ID'=>'country_id','POSTCODE'=>'postcode','STREET'=>'street','REGION'=>'region','STORE_ID'=>'store_id');
842
+ return $params;
843
+ }
844
+
845
+ /**
846
+ * Fetch attributes name and type
847
+ * on Sendinblue platform. This is necessary for the Prestashop to add subscriber's details.
848
+ */
849
+ public function allAttributesType()
850
+ {
851
+ if ($this->user_language == 'fr')
852
+ $params = array('PRENOM'=>'text', 'NOM'=>'text', 'MAGENTO_LANG'=>'text','CLIENT'=>'number','SMS'=>'text','COMPANY'=>'text','CITY'=>'text','COUNTRY_ID'=>'text','POSTCODE'=>'number','STREET'=>'text','REGION'=>'text','STORE_ID'=>'number');
853
+ else
854
+ $params = array('NAME'=>'text', 'SURNAME'=>'text', 'MAGENTO_LANG'=>'text','CLIENT'=>'number','SMS'=>'text','COMPANY'=>'text','CITY'=>'text','COUNTRY_ID'=>'text','POSTCODE'=>'number','STREET'=>'text','REGION'=>'text','STORE_ID'=>'number');
855
+ return $params;
856
+ }
857
+
858
+ /**
859
+ * Fetch all Transactional Attributes
860
+ * on Sendinblue platform. This is necessary for the Prestashop to add subscriber's details.
861
+ */
862
+ public function allTransactionalAttributes()
863
+ {
864
+ $params = array('ORDER_ID'=>'id', 'ORDER_DATE'=>'date', 'ORDER_PRICE'=>'number');
865
+ return $params;
866
+ }
867
+
868
+ /**
869
+ * Create Normal, Transactional, Calculated and Global attributes and their values
870
+ * on Sendinblue platform. This is necessary for the Prestashop to add subscriber's details.
871
+ */
872
+ public function createAttributesName()
873
+ {
874
+ $params = array();
875
+ $attrData = array();
876
+ $transData = array();
877
+ $attributesName = $this->allAttributesName();
878
+ $attributesType = $this->allAttributesType();
879
+ $tranArray = $this->allTransactionalAttributes();
880
+ $keyValue = array_keys($attributesName);
881
+ foreach ($keyValue as $value)
882
+ {
883
+ $attr = $attributesType[$value];
884
+ $attrData[] = $value.','.$attr;
885
+ }
886
+ $normalAttributes = implode('|', $attrData);
887
+ $tranKey = array_keys($tranArray);
888
+ $params['normal_attributes'] = $normalAttributes;
889
+ foreach ($tranKey as $value)
890
+ {
891
+ $attr = $tranArray[$value];
892
+ $transData[] = $value.','.$attr;
893
+ }
894
+ $transAttributes = implode('|', $transData);
895
+ $params['transactional_attributes'] = $transAttributes;
896
+ $this->callServer('ATTRIBUTES_CREATION', $params);
897
+ }
898
+ /**
899
+ * Method is used to send all the subscribers from magento to
900
+ * Sendinblue for adding / updating purpose.
901
+ */
902
+ public function sendAllMailIDToSendin($list)
903
+ {
904
+ $sendin_switch = new Mage_Core_Model_Config();
905
+ $allemail = $this->getcustomers();
906
+ if ($allemail > 0)
907
+ {
908
+ $params = array();
909
+ $params['webaction'] = 'IMPORTUSERS';
910
+ $params['key'] = $this->api_key;
911
+ $params['url'] = Mage::getBaseUrl('media').'sendinblue_csv/ImportSubUsersToSendinblue.csv';
912
+ $params['listids'] = $list->result;
913
+ $params['notify_url'] = Mage::getBaseUrl().'sendinblue/ajax/emptySubsUserToSendinblue';
914
+ $responce_data = $this->curlRequestAsyc($params);
915
+ $res_value = json_decode($responce_data);
916
+ $sendin_switch->saveConfig('sendinblue/importOldUserStatus', 0, 'default', 0);
917
+ if (empty($res_value->process_id))
918
+ {
919
+ $sendin_switch->saveConfig('sendinblue/importOldUserStatus', 1);
920
+ }
921
+ }
922
+ $sendin_switch->saveConfig('sendinblue/list', $list->result, 'default', 0);
923
+ }
924
+
925
+ /**
926
+ * Send SMS from Sendin.
927
+ */
928
+ public function sendSmsApi($array)
929
+ {
930
+ $params = array();
931
+ $params['key'] = $this->api_key;
932
+ $params['to'] = $array['to'];
933
+ $params['from'] = $array['from'];
934
+ $params['text'] = $array['text'];
935
+ return $this->callServer('SENDSMS', $params);
936
+ }
937
+
938
+ public function sendOrder($mobile)
939
+ {
940
+ $sendin_switch = new Mage_Core_Model_Config();
941
+ if (isset($mobile))
942
+ {
943
+ $arr = array();
944
+ $arr['to'] = $mobile;
945
+ $arr['from'] = $this->getSendSmsOrderSubject();
946
+ $arr['text'] = $this->getSendSmsmOrderMessage();
947
+
948
+ return $result = $this->sendSmsApi($arr);
949
+ }
950
+ }
951
+
952
+ public function notifySmsEmail()
953
+ {
954
+ $sendin_switch = new Mage_Core_Model_Config();
955
+
956
+ if($this->getSmsCredit() < $this->getNotifyValueStatus() && $this->module_enable == 1 && $this->getNotifySmsStatus() == 1)
957
+ {
958
+ if($this->getNotifyCronStatus() == 0)
959
+ {
960
+ $sendin_switch->saveConfig('sendinblue/Sendin_Notify_Cron_Executed', 1, 'default', 0);
961
+ $locale = Mage::app()->getLocale()->getLocaleCode();
962
+ $email_template_variables = array();
963
+ if ($locale == 'fr_FR')
964
+ {
965
+ $email_template_variables['text0'] = ' [SendinBlue] Alerte: Vos crédits SMS seront bientôt épuisés';
966
+ $sender_name = 'SendinBlue';
967
+ $sender_email = 'contact@sendinblue.com';
968
+ }
969
+ else
970
+ {
971
+ $email_template_variables['text0'] = '[SendinBlue] Alert: You do not have enough credits SMS';
972
+ $sender_name = 'SendinBlue';
973
+ $sender_email = 'contact@sendinblue.com';
974
+ }
975
+ $email = $this->getNotifyEmailStatus();
976
+
977
+ $email_template = Mage::getModel('core/email_template')->loadDefault('notification_template');
978
+ $temp = $email_template->template_text;
979
+ $web_site = Mage::app()->getWebsite()->getName();
980
+ $credit = $this->getSmsCredit();
981
+ preg_match_all('#{(.*)}#', $temp, $match);
982
+
983
+ $temp_params = array(
984
+ '{site_name}'=>$web_site,
985
+ '{present_credit}'=>$credit
986
+ );
987
+ foreach($match[0] as $var=>$value){
988
+ $temp = preg_replace('#'.$value.'#',$temp_params[$value],$temp);
989
+ }
990
+ $email_template->template_text = $temp;
991
+ $email_template->getProcessedTemplate($email_template_variables);
992
+ $email_template->setSenderName($sender_name);
993
+ $email_template->setSenderEmail($sender_email);
994
+ $email_template->setTemplateSubject($email_template_variables['text0']);
995
+ $email_template->send($email, '', $email_template_variables);
996
+ }
997
+ }
998
+ else
999
+ {
1000
+ $sendin_switch->saveConfig('sendinblue/Sendin_Notify_Cron_Executed', 0, 'default', 0);
1001
+ }
1002
+
1003
+ Mage::getModel('core/session')->addSuccess(Mage::helper('sendinblue')->__('Notification mail has been sent'));
1004
+ }
1005
+
1006
+ /**
1007
+ * show SMS credit from Sendinblue.
1008
+ */
1009
+ public function getSmsCredit()
1010
+ {
1011
+ $params = array();
1012
+ $params['key'] = $this->api_key;
1013
+ $result = $this->callServer('USER-CURRENT-PLAN', $params);
1014
+
1015
+ foreach($result as $val)
1016
+ {
1017
+ if(is_object($val)){
1018
+ if($val->plan_type=='SMS')
1019
+ {
1020
+ return $val->credits;
1021
+ }
1022
+ }
1023
+ }
1024
+ }
1025
+
1026
+ /**
1027
+ * Method is used to send test email to the user.
1028
+ */
1029
+ public function sendTestMail($email)
1030
+ {
1031
+ $locale = Mage::app()->getLocale()->getLocaleCode();
1032
+ $email_template_variables = array();
1033
+ if ($locale == 'fr_FR')
1034
+ {
1035
+ $email_template_variables['text0'] = '[SendinBlue SMTP] e-mail de test';
1036
+ $sender_name = 'SendinBlue';
1037
+ $sender_email = 'contact@sendinblue.com';
1038
+ }
1039
+ else
1040
+ {
1041
+ $email_template_variables['text0'] = '[SendinBlue SMTP] test email';
1042
+ $sender_name = 'SendinBlue';
1043
+ $sender_email = 'contact@sendinblue.com';
1044
+ }
1045
+ try {
1046
+ $email_template = Mage::getModel('core/email_template')->loadDefault('custom_template');
1047
+ $email_template->getProcessedTemplate($email_template_variables);
1048
+ $email_template->setSenderName($sender_name);
1049
+ $email_template->setSenderEmail($sender_email);
1050
+ $email_template->setTemplateSubject($email_template_variables['text0']);
1051
+ return $email_template->send($email, '', $email_template_variables);
1052
+ }
1053
+ catch(Exception $e) {
1054
+
1055
+ }
1056
+ }
1057
+
1058
+ /**
1059
+ * This method is used to compare key and value
1060
+ * return all value in array whose present in array key
1061
+ */
1062
+ public function merge_my_array($one, $two)
1063
+ {
1064
+ $resArr = array();
1065
+ if (count($one) > 0) {
1066
+ foreach($one as $k => $v) {
1067
+ $resArr[$k] = isset($two[$v])?$two[$v]:'';
1068
+ }
1069
+ }
1070
+ return $resArr;
1071
+ }
1072
+
1073
+ /**
1074
+ * This method is used to fetch all users from the default customer table to list
1075
+ * them in the Sendinblue magento module.
1076
+ */
1077
+ public function getcustomers()
1078
+ {
1079
+ $data = array();
1080
+ $customer_addr_data = array();
1081
+ $attributesName = $this->allAttributesName();
1082
+ $collection = Mage::getModel('customer/customer')->getCollection()->addAttributeToSelect('email')->addAttributeToSelect('firstname')->addAttributeToSelect('lastname')->addAttributeToSelect('created_in');
1083
+ $customerAddressCollection = Mage::getModel('customer/address');
1084
+ foreach ($collection as $customer)
1085
+ {
1086
+ $start_detail = array();
1087
+ $resp = array();
1088
+ $respone = array();
1089
+
1090
+ $respone = $customer->getData();
1091
+ $email = $respone['email'];
1092
+ $cid = $respone['entity_id'];
1093
+ $user_lang = $respone['created_in'];
1094
+
1095
+ $collectionAddress = $customerAddressCollection->getCollection()->addAttributeToSelect('telephone')->addAttributeToSelect('country_id')->addAttributeToSelect('company')->addAttributeToSelect('street')->addAttributeToSelect('postcode')->addAttributeToSelect('region')->addAttributeToSelect('city')->addAttributeToFilter('parent_id',(int)$cid);
1096
+ $telephone = '';
1097
+ $customer_addr = array();
1098
+ foreach ($collectionAddress as $customerPhno) {
1099
+ $customer_addr = $customerPhno->getData();
1100
+ $customer_addr['client'] = $cid>0?1:0;
1101
+ }
1102
+ $customer_addr_data[$email] = array_merge($respone, $customer_addr);
1103
+ }
1104
+ $newsletterArr = array();
1105
+ $newsletter = Mage::getResourceModel('newsletter/subscriber_collection')->addFieldToFilter('subscriber_status', array('eq' => 1))->load();
1106
+ $cnt = 0;
1107
+ foreach ( $newsletter->getItems() as $subscriber)
1108
+ {
1109
+ $subsdata = $subscriber->getData();
1110
+ $subscriber_email = $subsdata['subscriber_email'];
1111
+
1112
+ if ( !empty($customer_addr_data[$subscriber_email]) ) {
1113
+ $customer_addr_data[$subscriber_email]['email'] = $subscriber_email;
1114
+ $resp[$cnt] = $this->merge_my_array($attributesName, $customer_addr_data[$subscriber_email]);
1115
+ $resp[$cnt]['EMAIL'] = $subscriber_email;
1116
+ }
1117
+ else
1118
+ {
1119
+ $newsletterArr['client'] = $subsdata['customer_id']>0?1:0;
1120
+ $resp[$cnt] = $this->merge_my_array($attributesName, $newsletterArr);
1121
+ $resp[$cnt]['EMAIL'] = $subscriber_email;
1122
+ $resp[$cnt]['STORE_ID'] = $subsdata['store_id'];
1123
+ }
1124
+ $cnt++;
1125
+ }
1126
+
1127
+ if (!is_dir(Mage::getBaseDir('media').'/sendinblue_csv'))
1128
+ mkdir(Mage::getBaseDir('media').'/sendinblue_csv', 0777, true);
1129
+
1130
+ $handle = fopen(Mage::getBaseDir('media').'/sendinblue_csv/ImportSubUsersToSendinblue.csv', 'w+');
1131
+ $key_value = array_keys($attributesName);
1132
+ $key_value[] = 'EMAIL';
1133
+ fwrite($handle, implode(',', $key_value)."\n");
1134
+
1135
+ foreach ($resp as $newsdata)
1136
+ {
1137
+ if(!empty($newsdata['COUNTRY_ID']) && !empty($newsdata['SMS']))
1138
+ {
1139
+ $country_id = $this->getCountryCode($newsdata['COUNTRY_ID']);
1140
+ $newsdata['SMS'] = $this->checkMobileNumber($newsdata['SMS'], $country_id);
1141
+ }
1142
+ $key_value = $newsdata;
1143
+ fwrite($handle, str_replace("\n", "",implode(',', $key_value))."\n");
1144
+ }
1145
+ fclose($handle);
1146
+ $total_value = count($resp);
1147
+ return $total_value;
1148
+ }
1149
+
1150
+ /**
1151
+ * This method is used to fetch all users from the default newsletter table to list
1152
+ * them in the Sendinblue magento module.
1153
+ */
1154
+ public function getNewsletterSubscribe($start, $per_page)
1155
+ {
1156
+ $customer_addr_data = array();
1157
+ $attributesName = $this->allAttributesName();
1158
+ $attributesName['email'] = 'email';
1159
+ $attributesName['customer_id'] = 'entity_id';
1160
+
1161
+ $collection = Mage::getModel('customer/customer')->getCollection()->addAttributeToSelect('email');
1162
+ $customerAddressCollection = Mage::getModel('customer/address');
1163
+ foreach ($collection as $customer)
1164
+ {
1165
+ $start_detail = array();
1166
+ $respone = array();
1167
+ $respone = $customer->getData();
1168
+ $email = $respone['email'];
1169
+ $cid = $respone['entity_id'];
1170
+ $user_lang = $respone['created_in'];
1171
+
1172
+ $collectionAddress = $customerAddressCollection->getCollection()->addAttributeToSelect('telephone')->addAttributeToSelect('country_id')->addAttributeToFilter('parent_id',(int)$cid);
1173
+ $telephone = '';
1174
+ $customer_addr = array();
1175
+ foreach ($collectionAddress as $customerPhno) {
1176
+ $customer_addr = $customerPhno->getData();
1177
+ if (!empty($customer_addr['telephone']) && !empty($customer_addr['country_id']))
1178
+ {
1179
+ $country_code = $this->getCountryCode($customer_addr['country_id']);
1180
+ $customer_addr['telephone'] = $this->checkMobileNumber($customer_addr['telephone'], $country_code);
1181
+ }
1182
+ $customer_addr['client'] = $cid>0?1:0;
1183
+ }
1184
+ $customer_addr_data[$email] = array_merge($respone, $customer_addr);
1185
+ }
1186
+
1187
+ $newsletterArr = array();
1188
+ $newsletter = Mage::getResourceModel('newsletter/subscriber_collection')->load();
1189
+ $cnt = 0;
1190
+ $resp = array();
1191
+ foreach ( $newsletter->getItems() as $subscriber)
1192
+ {
1193
+ $subsdata = $subscriber->getData();
1194
+ $subscriber_email = $subsdata['subscriber_email'];
1195
+ $subscriber_status = $subsdata['subscriber_status'];
1196
+ if ( !empty($customer_addr_data[$subscriber_email]) ) {
1197
+ $resp[$cnt] = $this->merge_my_array($attributesName, $customer_addr_data[$subscriber_email]);
1198
+ unset($customer_addr_data[$subscriber_email]);
1199
+ $resp[$cnt]['subscriber_status'] = $subscriber_status;
1200
+ $resp[$cnt]['email'] = $subscriber_email;
1201
+ }
1202
+ else
1203
+ {
1204
+ $newsletterArr['client'] = $subsdata['customer_id']>0?1:0;
1205
+ $resp[$cnt] = $this->merge_my_array($attributesName, $newsletterArr);
1206
+ $resp[$cnt]['subscriber_status'] = $subscriber_status;
1207
+ $resp[$cnt]['email'] = $subscriber_email;
1208
+ }
1209
+ $cnt++;
1210
+ }
1211
+ if (count($customer_addr_data) > 0) {
1212
+ foreach ($customer_addr_data as $email => $cVal) {
1213
+ $resp[$cnt] = $this->merge_my_array($attributesName, $cVal);
1214
+ $resp[$cnt]['subscriber_status'] = 3;
1215
+ $resp[$cnt]['email'] = $email;
1216
+
1217
+ $cnt++;
1218
+ }
1219
+ }
1220
+ return array_slice($resp, $start, $per_page, true);
1221
+ }
1222
+
1223
+ /**
1224
+ * This method is used to fetch total count unsubscribe users from the default newsletter table to list
1225
+ * them in the Sendinblue magento module.
1226
+ */
1227
+ public function getNewsletterUnSubscribeCount()
1228
+ {
1229
+ $coreResource = Mage::getSingleton('core/resource');
1230
+ $tableCustomer = $coreResource->getTableName('customer/entity');
1231
+ $tableNewsletter = $coreResource->getTableName('newsletter/subscriber');
1232
+ $sql = 'SELECT count(*) as totalcoutn FROM '.$tableCustomer.' CE
1233
+ LEFT JOIN '.$tableNewsletter.' NS
1234
+ ON CE.entity_id=NS.customer_id WHERE subscriber_status != 1 or subscriber_status is null';
1235
+ $unsubs_count1 = $coreResource->getConnection('core_read')->fetchRow($sql);
1236
+
1237
+ $sql = 'SELECT count(*) as totalcoutn FROM '.$tableNewsletter.' WHERE customer_id = 0 AND subscriber_status = 3';
1238
+ $unsubs_count2 = $coreResource->getConnection('core_read')->fetchRow($sql);
1239
+ return ($unsubs_count1['totalcoutn'] + $unsubs_count2['totalcoutn']);
1240
+ }
1241
+
1242
+ /**
1243
+ * This method is used to fetch total count subscribe users from the default newsletter table to list
1244
+ * them in the Sendinblue magento module.
1245
+ */
1246
+ public function getNewsletterSubscribeCount()
1247
+ {
1248
+ $coreResource = Mage::getSingleton('core/resource');
1249
+ $tableNewsletter = $coreResource->getTableName('newsletter/subscriber');
1250
+ $sql = 'SELECT count(*) as totalvalue from '.$tableNewsletter.' where subscriber_status = 1';
1251
+ $data = $coreResource->getConnection('core_read')->fetchRow($sql);
1252
+ return $data['totalvalue'];
1253
+ }
1254
+
1255
+ /**
1256
+ * This method is used to check the subscriber's newsletter subscription status in Sendinblue
1257
+ */
1258
+ public function checkUserSendinStatus($result)
1259
+ {
1260
+ $userstatus = array();
1261
+ foreach ($result as $subscriber)
1262
+ $userstatus[] = $subscriber['email'];
1263
+ $email = implode(',', $userstatus);
1264
+ $params = array();
1265
+ $params['key'] = $this->api_key;
1266
+ $params['email'] = $email;
1267
+ $response = $this->callServer('USERS-STATUS-BLACKLIST', $params);
1268
+ $response = json_encode($response);
1269
+ return json_decode($response, true);
1270
+ }
1271
+
1272
+ /**
1273
+ * Fetches the SMTP and order tracking details
1274
+ */
1275
+ public function TrackingSmtp()
1276
+ {
1277
+ $params = array();
1278
+ $params['key'] = $this->api_key;
1279
+ return $this->callServer('TRACKINGDATA', $params);
1280
+ }
1281
+
1282
+ /**
1283
+ * CURL function to send request to the Sendinblue API server
1284
+ */
1285
+ public function callServer($method, $params)
1286
+ {
1287
+ $host = $this->api_url;
1288
+ $params['key'] = (isset($params['key']) && !empty($params['key'])) ? $params['key'] : $this->api_key;
1289
+ $params['webaction'] = $method;
1290
+ $this->error_message = '';
1291
+ $this->error_code = '';
1292
+ $response = $this->curlRequest($params);
1293
+ return json_decode($response);
1294
+ }
1295
+
1296
+ /**
1297
+ * CURL function to send request to the Sendinblue API server
1298
+ */
1299
+ public function curlRequest($data)
1300
+ {
1301
+ $url = $this->api_url; // WS URL
1302
+ $ch = curl_init();
1303
+ $ndata = '';
1304
+ $data['source'] = 'MagentoNew';
1305
+ if (is_array($data))
1306
+ {
1307
+ foreach ($data as $key => $value)
1308
+ $ndata .= $key.'='.urlencode($value).'&';
1309
+ }
1310
+ else
1311
+ $ndata = $data;
1312
+ curl_setopt($ch, CURLOPT_HTTPHEADER, array(
1313
+ 'Expect:'
1314
+ ));
1315
+
1316
+ $ndata = trim($ndata,'&');
1317
+ curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
1318
+ curl_setopt($ch, CURLOPT_POST, 1);
1319
+ curl_setopt($ch, CURLOPT_POSTFIELDS, $ndata);
1320
+ curl_setopt($ch, CURLOPT_HEADER, 0);
1321
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
1322
+ curl_setopt($ch, CURLOPT_URL, $url);
1323
+ $data2 = curl_exec($ch);
1324
+ curl_close($ch);
1325
+ return $data2;
1326
+ }
1327
+ /**
1328
+ * CURL function to send request to the Sendinblue API server
1329
+ */
1330
+ public function curlRequestAsyc($data)
1331
+ {
1332
+ $url = $this->api_url; // WS URL
1333
+ $ch = curl_init();
1334
+ $ndata = '';
1335
+ $data['source'] = 'MagentoNew';
1336
+ if (is_array($data))
1337
+ {
1338
+ foreach ($data as $key => $value)
1339
+ $ndata .= $key.'='.urlencode($value).'&';
1340
+ }
1341
+ else
1342
+ $ndata = $data;
1343
+ curl_setopt($ch, CURLOPT_HTTPHEADER, array(
1344
+ 'Expect:'
1345
+ ));
1346
+
1347
+ $ndata = trim($ndata,'&');
1348
+ curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
1349
+ curl_setopt($ch, CURLOPT_POST, 1);
1350
+ curl_setopt($ch, CURLOPT_POSTFIELDS, $ndata);
1351
+ curl_setopt($ch, CURLOPT_HEADER, 0);
1352
+ curl_setopt($ch, CURLOPT_TIMEOUT, 0);
1353
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
1354
+ curl_setopt($ch, CURLOPT_URL, $url);
1355
+ $data2 = curl_exec($ch);
1356
+ curl_close($ch);
1357
+ return $data2;
1358
+ }
1359
+
1360
+ public function removeOldEntry()
1361
+ {
1362
+ $sendin_switch = new Mage_Core_Model_Config();
1363
+ $sendin_switch->saveConfig('sendinblue/smtp/status', '');
1364
+ $sendin_switch->saveConfig('sendinblue/smtp/authentication', '');
1365
+ $sendin_switch->saveConfig('sendinblue/smtp/username', '');
1366
+ $sendin_switch->saveConfig('sendinblue/smtp/password', '');
1367
+ $sendin_switch->saveConfig('sendinblue/smtp/host', '');
1368
+ $sendin_switch->saveConfig('sendinblue/smtp/port', '');
1369
+ $sendin_switch->saveConfig('sendinblue/smtp/ssl', '');
1370
+ $sendin_switch->saveConfig('sendinblue/smtp/option', '');
1371
+ $sendin_switch->saveConfig('sendinblue/tracking/code', '');
1372
+ }
1373
+ protected function _uninstallResourceDb($version)
1374
+ {
1375
+ Mage::dispatchEvent('module_uninstall', array('resource' => $this->_resourceName));
1376
+ $this->_modifyResourceDb(self::TYPE_DB_UNINSTALL, $version, '');
1377
+ return $this;
1378
+ }
1379
+
1380
+ /**
1381
+ * This method is used to fetch all subscribe users from the default customer table to list
1382
+ * them in the Sendinblue magento module.
1383
+ */
1384
+ public function smsCampaignList()
1385
+ {
1386
+ $customer_addr_data = array();
1387
+ $attributesName = $this->allAttributesName();
1388
+ $collection = Mage::getModel('customer/customer')->getCollection()->addAttributeToSelect('email')->addAttributeToSelect('firstname')->addAttributeToSelect('lastname')->addAttributeToSelect('created_in');
1389
+ $customerAddressCollection = Mage::getModel('customer/address');
1390
+ foreach ($collection as $customer)
1391
+ {
1392
+ $start_detail = array();
1393
+ $resp = array();
1394
+ $respone = array();
1395
+
1396
+ $respone = $customer->getData();
1397
+ $email = $respone['email'];
1398
+ $cid = $respone['entity_id'];
1399
+ $user_lang = $respone['created_in'];
1400
+
1401
+ $collectionAddress = $customerAddressCollection->getCollection()->addAttributeToSelect('telephone')->addAttributeToSelect('country_id')->addAttributeToSelect('company')->addAttributeToSelect('street')->addAttributeToSelect('postcode')->addAttributeToSelect('region')->addAttributeToSelect('city')->addAttributeToFilter('parent_id',(int)$cid);
1402
+ $telephone = '';
1403
+ $customer_addr = array();
1404
+ foreach ($collectionAddress as $customerPhno) {
1405
+ $customer_addr = $customerPhno->getData();
1406
+ if (!empty($customer_addr['telephone']) && !empty($customer_addr['country_id']))
1407
+ {
1408
+ $country_code = $this->getCountryCode($customer_addr['country_id']);
1409
+ $customer_addr['telephone'] = $this->checkMobileNumber($customer_addr['telephone'], $country_code);
1410
+ }
1411
+ $customer_addr['client'] = $cid>0?1:0;
1412
+ }
1413
+ $customer_addr_data[$email] = array_merge($respone, $customer_addr);
1414
+ }
1415
+ $newsletterArr = array();
1416
+ $newsletter = Mage::getResourceModel('newsletter/subscriber_collection')->addFieldToFilter('subscriber_status', array('eq' => 1))->load();
1417
+ $cnt = 0;
1418
+ foreach ( $newsletter->getItems() as $subscriber)
1419
+ {
1420
+ $subsdata = $subscriber->getData();
1421
+ $subscriber_email = $subsdata['subscriber_email'];
1422
+ $subscriber_status = $subsdata['subscriber_status'];
1423
+ if ( !empty($customer_addr_data[$subscriber_email]) ) {
1424
+ $customer_addr_data[$subscriber_email]['email'] = $subscriber_email;
1425
+ $resp[$cnt] = $this->merge_my_array($attributesName, $customer_addr_data[$subscriber_email]);
1426
+ $resp[$cnt]['EMAIL'] = $subscriber_email;
1427
+ $resp[$cnt]['subscriber_status'] = $subscriber_status;
1428
+ }
1429
+ else
1430
+ {
1431
+ $newsletterArr['client'] = $subsdata['customer_id']>0?1:0;
1432
+ $resp[$cnt] = $this->merge_my_array($attributesName, $newsletterArr);
1433
+ $resp[$cnt]['EMAIL'] = $subscriber_email;
1434
+ $resp[$cnt]['subscriber_status'] = $subscriber_status;
1435
+ $resp[$cnt]['STORE_ID'] = $subsdata['store_id'];
1436
+ }
1437
+ $cnt++;
1438
+ }
1439
+ $i = 0;
1440
+ $data = array();
1441
+ foreach($resp as $result)
1442
+ {
1443
+ if(!empty($result['SMS']))
1444
+ {
1445
+ $data[$i]= $result;
1446
+ }
1447
+ $i++;
1448
+ }
1449
+ return json_encode($data);
1450
+ }
1451
+ /**
1452
+ * API config value from SendinBlue.
1453
+ */
1454
+ public function getApiConfigValue()
1455
+ {
1456
+ $data = array();
1457
+ $data['key'] = $this->api_key;
1458
+ $data['webaction'] = 'PLUGIN-CONFIG';
1459
+ $value_config = $this->curlRequest($data);
1460
+ $result = json_decode($value_config);
1461
+ return $result;
1462
+ }
1463
+
1464
+ /**
1465
+ * Send template email by sendinblue for newsletter subscriber user .
1466
+ */
1467
+ public function sendWsTemplateMail($to, $templateid = false)
1468
+ {
1469
+ $mail_url = "http://mysmtp.mailin.fr/ws/template/"; //Curl url
1470
+
1471
+ $Sendin_Confirm_Type = $this->getSubscribeConfirmType();
1472
+ if (empty($Sendin_Confirm_Type) || $Sendin_Confirm_Type == 'nocon') {
1473
+ return false;
1474
+ }
1475
+ if (!$templateid) {
1476
+ if ($Sendin_Confirm_Type == 'simplemail') {
1477
+ $temp_id_value = $this->getTemplateId();
1478
+ $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.
1479
+ }
1480
+
1481
+ if ($Sendin_Confirm_Type == 'doubleoptin') {
1482
+ $path_resp = '';
1483
+ $email_user = base64_encode($to);
1484
+ $path_resp = Mage::getBaseUrl().'sendinblue/ajax/mailResponce?value='.base64_encode($to);
1485
+ return $this->defaultDoubleoptinTemp($to, $path_resp);
1486
+ }
1487
+ }
1488
+ $smtpPassword = $this->getSmtpPassword();
1489
+ $user = $this->getUserName();
1490
+ //$to = str_replace('+', '%2B', $to);
1491
+ $post_data['to'] = $to;
1492
+ $post_data['key'] = $smtpPassword;
1493
+ $post_data['user'] = $user;
1494
+ $post_data['templateid'] = $templateid;
1495
+ $post_data = http_build_query($post_data);
1496
+ $ch = curl_init();
1497
+
1498
+ curl_setopt ($ch, CURLOPT_POST, 1);
1499
+ curl_setopt ($ch, CURLOPT_URL, $mail_url);
1500
+ curl_setopt ($ch, CURLOPT_POSTFIELDS, $post_data);
1501
+ curl_setopt ($ch, CURLOPT_RETURNTRANSFER, true);
1502
+ $return_data = curl_exec ($ch);
1503
+ curl_close ($ch);
1504
+
1505
+ $res = json_decode($return_data, true);
1506
+ return $res;
1507
+ }
1508
+ /**
1509
+ * send double optin template and manage.
1510
+ */
1511
+ public function defaultDoubleoptinTemp($subscriber_email, $doubleoptin_url)
1512
+ {
1513
+ $locale = Mage::app()->getLocale()->getLocaleCode();
1514
+ $email_template_variables = array();
1515
+ if ($locale == 'fr_FR')
1516
+ {
1517
+ $email_template_variables['text0'] = 'Confirmez votre inscription';
1518
+ $sender_name = 'SendinBlue';
1519
+ $sender_email = 'contact@sendinblue.com';
1520
+ }
1521
+ else
1522
+ {
1523
+ $email_template_variables['text0'] = 'Please confirm your subscription';
1524
+ $sender_name = 'SendinBlue';
1525
+ $sender_email = 'contact@sendinblue.com';
1526
+ }
1527
+ try {
1528
+ $email_template = Mage::getModel('core/email_template')->loadDefault('doubleoptin_template');
1529
+ $temp = $email_template->template_text;
1530
+ $web_site = Mage::app()->getWebsite()->getName();
1531
+ preg_match_all('#{(.*)}#', $temp, $match);
1532
+
1533
+ $temp_params = array(
1534
+ '{double_optin}'=>$doubleoptin_url,
1535
+ '{site_name}'=> $web_site
1536
+ );
1537
+ foreach($match[0] as $var=>$value){
1538
+ $temp = preg_replace('#'.$value.'#',$temp_params[$value],$temp);
1539
+ }
1540
+
1541
+ $email_template->template_text = $temp;
1542
+ $email_template->getProcessedTemplate($email_template_variables);
1543
+ $email_template->setSenderName($sender_name);
1544
+ $email_template->setSenderEmail($sender_email);
1545
+ $email_template->setTemplateSubject($email_template_variables['text0']);
1546
+ return $email_template->send($subscriber_email, '', $email_template_variables);
1547
+
1548
+ }
1549
+ catch(Exception $e) {
1550
+
1551
+ }
1552
+
1553
+ }
1554
+
1555
+ /**
1556
+ * Get all temlpate list id by sendinblue.
1557
+ */
1558
+ public function templateDisplay()
1559
+ {
1560
+ $data = array();
1561
+ $data['key'] = $this->api_key;
1562
+ $data['webaction'] = 'CAMPAIGNDETAIL';
1563
+ $data['show'] = 'ALL';
1564
+ $data['messageType'] = 'template';
1565
+ return json_decode($this->curlRequest($data));
1566
+ }
1567
+
1568
+ /**
1569
+ * Get getCountryCode from sendinblue_country table,
1570
+ */
1571
+ public function getCountryCode($countryid)
1572
+ {
1573
+ $tableCountry = Mage::getSingleton('core/resource')->getTableName('sendinblue_country_codes');
1574
+ $sql = 'SELECT country_prefix FROM '.$tableCountry.' WHERE iso_code = "'.$countryid.'"';
1575
+ $country_id = Mage::getSingleton('core/resource') ->getConnection('core_read')->fetchRow($sql);
1576
+ $country_prefix = $country_id['country_prefix'];
1577
+ return $country_prefix;
1578
+ }
1579
+ }
app/code/{local → community}/Sendinblue/Sendinblue/Model/Status.php RENAMED
File without changes
app/code/community/Sendinblue/Sendinblue/controllers/Adminhtml/MyformController.php ADDED
@@ -0,0 +1,593 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @author Sendinblue plateform <contact@sendinblue.com>
4
+ * @copyright 2013-2014 Sendinblue
5
+ * URL: https:www.sendinblue.com
6
+ * Do not edit or add to this file if you wish to upgrade Sendinblue Magento plugin to newer
7
+ * versions in the future. If you wish to customize Sendinblue magento plugin for your
8
+ * needs then we can't provide a technical support.
9
+ **/
10
+
11
+ class Sendinblue_Sendinblue_Adminhtml_MyformController extends Mage_Adminhtml_Controller_Action
12
+ {
13
+ public function indexAction()
14
+ {
15
+ $params = Mage::app()->getRequest()->getParams();
16
+ if (isset($params['sendin_apikey']) && $params['sendin_apikey'] != '')
17
+ $this->CreateFolderCaseTwo();
18
+
19
+ $this->loadLayout();
20
+ $this->renderLayout();
21
+ }
22
+ public function syncronizepostAction()
23
+ {
24
+ $post = $this->getRequest()->getPost();
25
+ try {
26
+ if (empty($post))
27
+ Mage::throwException($this->__('Invalid form data.'));
28
+ $sendin_switch = new Mage_Core_Model_Config();
29
+
30
+ if (isset($post['syncronizeSubmit']))
31
+ {
32
+ $sendin_switch->saveConfig('sendinblue/syncronize', $post['syncronize']);
33
+ if (!empty($post['subscribe_confirm_type']))
34
+ {
35
+ $sendin_switch->saveConfig('sendinblue/SendinSubscribeConfirmType', $post['subscribe_confirm_type']);
36
+ $sendin_switch->saveConfig('sendinblue/SendinTemplateId', $post['template_simple']);
37
+ $sendin_switch->saveConfig('sendinblue/SendinOptinRedirectUrlCheck', $post['optin_redirect_url_check']);
38
+ $sendin_switch->saveConfig('sendinblue/SendinDoubleoptinRedirectUrl', $post['doubleoptin-redirect-url']);
39
+ $sendin_switch->saveConfig('sendinblue/SendinFinalConfirmEmail', $post['final_confirm_email']);
40
+ $sendin_switch->saveConfig('sendinblue/SendinTemplateFinal', $post['template_final']);
41
+ $sendinModule = Mage::getModel('sendinblue/sendinblue');
42
+ if ($post['subscribe_confirm_type'] === 'doubleoptin') {
43
+ $res_optin = $sendinModule->checkFolderListDoubleoptin();
44
+ if (!empty($res_optin['optin_id'])) {
45
+ $sendin_switch->saveConfig('sendinblue/SendinOptinListId', $res_optin['optin_id']);
46
+ }
47
+ if ($res_optin === false) {
48
+ $optin_id = $sendinModule->createListIdDoubleoptin();
49
+ $sendin_switch->saveConfig('sendinblue/SendinOptinListId', $optin_id);
50
+ }
51
+ }
52
+ $message = $this->__('Your setting has been successfully saved');
53
+ }
54
+
55
+ if (!empty($post['sendin_list']))
56
+ {
57
+ $list = implode('|', $post['sendin_list']);
58
+ $sendin_switch->saveConfig('sendinblue/list', $list);
59
+ $message = $this->__('Your setting has been successfully saved');
60
+ Mage::getModel('adminhtml/session')->addSuccess($message);
61
+ } else
62
+ {
63
+ $message = $this->__('Please select a list');
64
+ Mage::getModel('adminhtml/session')->addError($message);
65
+ }
66
+ }
67
+ }
68
+ catch (Exception $e)
69
+ {
70
+ Mage::getModel('adminhtml/session')->addError($e->getMessage());
71
+ }
72
+ $this->_redirect('*/*');
73
+ }
74
+
75
+ public function reimportpostAction()
76
+ {
77
+ $post = $this->getRequest()->getPost();
78
+ try {
79
+ if (empty($post))
80
+ Mage::throwException($this->__('Invalid form data.'));
81
+
82
+ $sendinModule = Mage::getModel('sendinblue/sendinblue');
83
+ $sendin_switch = new Mage_Core_Model_Config();
84
+ if (isset($post['importoldSubmit']) && !empty($post['importoldSubmit']))
85
+ {
86
+ $list = $sendinModule->getUserlists();
87
+ $list_id = str_replace('|', ',', $list);
88
+ $apikey = $sendinModule->getApiKey();
89
+ $allemail = $sendinModule->getcustomers();
90
+ if ($allemail > 0)
91
+ {
92
+ $params = array();
93
+ $params['webaction'] = 'IMPORTUSERS';
94
+ $params['key'] = $apikey;
95
+ $params['url'] = Mage::getBaseUrl('media').'sendinblue_csv/ImportSubUsersToSendinblue.csv';
96
+ $params['listids'] = $list_id;
97
+ $params['notify_url'] = Mage::getBaseUrl().'sendinblue/ajax/emptySubsUserToSendinblue';
98
+ $responce_data = $sendinModule->curlRequestAsyc($params);
99
+
100
+ $res_value = json_decode($responce_data);
101
+ $sendin_switch->saveConfig('sendinblue/importOldUserStatus', 0);
102
+ if (empty($res_value->process_id))
103
+ {
104
+ $sendin_switch->saveConfig('sendinblue/importOldUserStatus', 1);
105
+ $message = $this->__('Old subscribers not imported successfully, please click on Import Old Subscribers button to import them again');
106
+ Mage::getModel('adminhtml/session')->addError($message);
107
+ }
108
+ else
109
+ {
110
+ $message = $this->__('Your setting has been successfully saved');
111
+ Mage::getModel('adminhtml/session')->addSuccess($message);
112
+ }
113
+ }
114
+ }
115
+ }
116
+ catch (Exception $e)
117
+ {
118
+ Mage::getModel('adminhtml/session')->addError($e->getMessage());
119
+ }
120
+ $this->_redirect('*/*');
121
+ }
122
+
123
+ public function apikeypostAction()
124
+ {
125
+ $post = $this->getRequest()->getPost();
126
+ $sendinModule = Mage::getModel('sendinblue/sendinblue');
127
+ try {
128
+ if (empty($post))
129
+ Mage::throwException($this->__('Invalid form data.'));
130
+ elseif (isset($post['sendin_apikey']) && !empty($post['sendin_apikey']))
131
+ {
132
+ $sendin_switch = new Mage_Core_Model_Config();
133
+ $result = $sendinModule->checkApikey(trim($post['sendin_apikey']));
134
+ if (empty($result['error']))
135
+ {
136
+ $get_key = $sendinModule->getApiKey();
137
+ if ($get_key == '')
138
+ $sendinModule->createFolderName($post['sendin_apikey']);
139
+ elseif ($get_key != $post['sendin_apikey'])
140
+ $sendinModule->createFolderName($post['sendin_apikey']);
141
+
142
+ $sendin_switch->saveConfig('sendinblue/api', trim($post['sendin_apikey']));
143
+ $sendin_switch->saveConfig('sendinblue/enabled', $post['sendin_api_status']);
144
+ $sendin_switch->saveConfig('sendinblue/syncronize', 1);
145
+ $sendinModule->removeOldEntry();
146
+ if($sendinModule->getImportOldSubsStatus() == 1)
147
+ {
148
+ $message = $this->__('Old subscribers not imported successfully, please click on Import Old Subscribers button to import them again');
149
+ Mage::getModel('core/session')->addError($message);
150
+ }
151
+ else
152
+ {
153
+ $message = $this->__('Your setting has been successfully saved');
154
+ Mage::getModel('adminhtml/session')->addSuccess($message);
155
+ }
156
+
157
+ } else if (isset($result['error']))
158
+ {
159
+ $message = $this->__('You have entered wrong api key');
160
+ Mage::getModel('core/session')->addError($message);
161
+ }
162
+ }
163
+ }
164
+ catch (Exception $e)
165
+ {
166
+ Mage::getModel('adminhtml/session')->addError($e->getMessage());
167
+ }
168
+ $this->_redirect('*/*');
169
+ }
170
+ public function sendmailAction()
171
+ {
172
+ $post = $this->getRequest()->getPost();
173
+ $sendinModule = Mage::getModel('sendinblue/sendinblue');
174
+ try {
175
+ if (empty($post))
176
+ Mage::throwException($this->__('Invalid form data.'));
177
+ elseif (isset($post['SmtpSubmit']) && !empty($post['SmtpSubmit']))
178
+ {
179
+ $sendin_switch = new Mage_Core_Model_Config();
180
+ $get_key = $sendinModule->getApiKey();
181
+ $result = $sendinModule->checkApikey($get_key);
182
+ if (empty($result['error']))
183
+ {
184
+ $smtp_response = $sendinModule->TrackingSmtp(); // get tracking code
185
+
186
+ if ($smtp_response->result->relay_data->status == 'enabled')
187
+ {
188
+ $sendin_switch->saveConfig('sendinblue/smtp/authentication', 'crammd5', 'default', 0);
189
+ $sendin_switch->saveConfig('sendinblue/smtp/username', $smtp_response->result->relay_data->data->username, 'default', 0);
190
+ $sendin_switch->saveConfig('sendinblue/smtp/password', $smtp_response->result->relay_data->data->password, 'default', 0);
191
+ $sendin_switch->saveConfig('sendinblue/smtp/host', $smtp_response->result->relay_data->data->relay, 'default', 0);
192
+ $sendin_switch->saveConfig('sendinblue/smtp/port', $smtp_response->result->relay_data->data->port, 'default', 0);
193
+ $sendin_switch->saveConfig('sendinblue/smtp/ssl', 'null', 'default', 0);
194
+ $sendin_switch->saveConfig('sendinblue/smtp/option', 'smtp', 'default', 0);
195
+ if ($post['email'])
196
+ {
197
+ $data11 = $sendinModule->sendTestMail($post['email']);
198
+ $resArr = json_decode($data11, true);
199
+ if ($resArr['result'] != true) {
200
+ $message = $this->__('Mail not sent').' '.$this->__(trim($resArr['error']));
201
+ Mage::getModel('adminhtml/session')->addError($message);
202
+ }
203
+ else {
204
+ $message = $this->__('Mail sent!');
205
+ Mage::getModel('core/session')->addSuccess($message);
206
+ }
207
+
208
+ } else
209
+ {
210
+ $message = $this->__('Mail not sent');
211
+ Mage::getModel('adminhtml/session')->addError($message);
212
+ }
213
+ }
214
+ else
215
+ {
216
+ $sendin_switch->saveConfig('sendinblue/smtp/status', 0);
217
+ $message = $this->__('Your SMTP account is not activated and therefore you can not use SendinBlue SMTP. For more informations, Please contact our support to: contact@sendinblue.com');
218
+ Mage::getModel('adminhtml/session')->addError($message);
219
+ }
220
+ } elseif (isset($responce['error']))
221
+ {
222
+ $message = $this->__('You have entered wrong api key');
223
+ Mage::getModel('core/session')->addError($message);
224
+ }
225
+ }
226
+ }
227
+ catch (Exception $e)
228
+ {
229
+ Mage::getModel('adminhtml/session')->addError($e->getMessage());
230
+ }
231
+ $this->_redirect('*/*');
232
+ }
233
+ public function sendorderAction()
234
+ {
235
+ $post = $this->getRequest()->getPost();
236
+ try
237
+ {
238
+ if (empty($post))
239
+ Mage::throwException($this->__('Invalid form data.'));
240
+ $sendin_switch = new Mage_Core_Model_Config();
241
+ if (isset($post['sender_order_save']))
242
+ {
243
+ $sender_order = $post['sender_order'];
244
+ $sender_order_message = $post['sender_order_message'];
245
+
246
+ if (isset($sender_order) && $sender_order == '')
247
+ {
248
+ $message = $this->__('Please fill the message field');
249
+ Mage::getModel('adminhtml/session')->addError($message);
250
+ }
251
+ else if ($sender_order_message == '')
252
+ {
253
+ $message = $this->__('Please fill the message field');
254
+ Mage::getModel('adminhtml/session')->addError($message);
255
+ }
256
+ else
257
+ {
258
+ $sendin_switch->saveConfig('sendinblue/Sendin_Sender_Order', $sender_order);
259
+ $sendin_switch->saveConfig('sendinblue/Sendin_Sender_Order_Message', $sender_order_message);
260
+ $message = $this->__('Your setting has been successfully saved');
261
+ Mage::getModel('adminhtml/session')->addSuccess($message);
262
+ }
263
+
264
+ }
265
+ }
266
+ catch (Exception $e)
267
+ {
268
+ Mage::getModel('adminhtml/session')->addError($e->getMessage());
269
+ }
270
+ $this->_redirect('*/*');
271
+ }
272
+ public function sendshipmentAction()
273
+ {
274
+ $post = $this->getRequest()->getPost();
275
+ try {
276
+ if (empty($post))
277
+ Mage::throwException($this->__('Invalid form data.'));
278
+
279
+ $sendin_switch = new Mage_Core_Model_Config();
280
+ if (isset($post['sender_shipment_save']))
281
+ {
282
+ $sender_shipment = $post['sender_shipment'];
283
+ $sender_shipment_message = $post['sender_shipment_message'];
284
+
285
+ if (isset($sender_shipment) && $sender_shipment == '')
286
+ {
287
+ $message = $this->__('Please fill the message field');
288
+ Mage::getModel('adminhtml/session')->addError($message);
289
+ }
290
+ else if ($sender_shipment_message == '')
291
+ {
292
+ $message = $this->__('Please fill the message field');
293
+ Mage::getModel('adminhtml/session')->addError($message);
294
+ }
295
+ else
296
+ {
297
+ $sendin_switch->saveConfig('sendinblue/Sendin_Sender_Shipment', $sender_shipment);
298
+ $sendin_switch->saveConfig('sendinblue/Sendin_Sender_Shipment_Message', $sender_shipment_message);
299
+ $message = $this->__('Your setting has been successfully saved');
300
+ Mage::getModel('adminhtml/session')->addSuccess($message);
301
+ }
302
+
303
+ }
304
+ }
305
+ catch (Exception $e)
306
+ {
307
+ Mage::getModel('adminhtml/session')->addError($e->getMessage());
308
+ }
309
+ $this->_redirect('*/*');
310
+ }
311
+
312
+ /**
313
+ * This method is called when the user test Shipment Sms and hits the submit button.
314
+ */
315
+
316
+ public function sendordertestAction()
317
+ {
318
+ $sendinModule = Mage::getModel('sendinblue/sendinblue');
319
+ $post = $this->getRequest()->getPost();
320
+ try {
321
+ if (empty($post))
322
+ Mage::throwException($this->__('Invalid form data.'));
323
+
324
+ $sendin_switch = new Mage_Core_Model_Config();
325
+
326
+ if (isset($post['sender_order_submit']))
327
+ {
328
+ $arr = array();
329
+ $arr['to'] = $post['sender_order_number'];
330
+ $arr['from'] = $sendinModule->getSendSmsOrderSubject();
331
+ $arr['text'] = $sendinModule->getSendSmsmOrderMessage();
332
+
333
+ $result = $sendinModule->sendSmsApi($arr);
334
+
335
+ if (isset($result->status) && $result->status == 'OK')
336
+ {
337
+ $message = $this->__('Message has been sent successfully');
338
+ Mage::getModel('adminhtml/session')->addSuccess($message);
339
+ }
340
+ else
341
+ {
342
+ $message = $this->__('Message has not been sent successfully');
343
+ Mage::getModel('adminhtml/session')->addError($message);
344
+ }
345
+
346
+ }
347
+ }
348
+ catch (Exception $e)
349
+ {
350
+ Mage::getModel('adminhtml/session')->addError($e->getMessage());
351
+ }
352
+ $this->_redirect('*/*');
353
+ }
354
+
355
+
356
+ /**
357
+ * This method is called when the user test Shipment Sms and hits the submit button.
358
+ */
359
+
360
+ public function sendshipmenttestAction()
361
+ {
362
+ $sendinModule = Mage::getModel('sendinblue/sendinblue');
363
+ $post = $this->getRequest()->getPost();
364
+ try {
365
+ if (empty($post))
366
+ Mage::throwException($this->__('Invalid form data.'));
367
+
368
+ $sendin_switch = new Mage_Core_Model_Config();
369
+
370
+ if (isset($post['sender_shipment_submit']))
371
+ {
372
+ $arr = array();
373
+ $arr['to'] = $post['sender_shipment_number'];
374
+ $arr['from'] = $sendinModule->getSendSmsShipingSubject();
375
+ $arr['text'] = $sendinModule->getSendSmsShipingMessage();
376
+
377
+ $result = $sendinModule->sendSmsApi($arr);
378
+
379
+ if (isset($result->status) && $result->status == 'OK')
380
+ {
381
+ $message = $this->__('Message has been sent successfully');
382
+ Mage::getModel('adminhtml/session')->addSuccess($message);
383
+ }
384
+ else
385
+ {
386
+ $message = $this->__('Message has not been sent successfully');
387
+ Mage::getModel('adminhtml/session')->addError($message);
388
+ }
389
+
390
+ }
391
+ }
392
+ catch (Exception $e)
393
+ {
394
+ Mage::getModel('adminhtml/session')->addError($e->getMessage());
395
+ }
396
+ $this->_redirect('*/*');
397
+ }
398
+
399
+ public function sendnotifysmsAction()
400
+ {
401
+ $post = $this->getRequest()->getPost();
402
+ try {
403
+ if (empty($post))
404
+ Mage::throwException($this->__('Invalid form data.'));
405
+
406
+ $sendin_switch = new Mage_Core_Model_Config();
407
+
408
+ if (isset($post['notify_sms_mail']))
409
+ {
410
+ $sendin_switch->saveConfig('sendinblue/Sendin_Notify_Value', $post['sendin_notify_value']);
411
+ $sendin_switch->saveConfig('sendinblue/Sendin_Notify_Email', $post['sendin_notify_email']);
412
+ $message = $this->__('Your setting has been successfully saved');
413
+ Mage::getModel('adminhtml/session')->addSuccess($message);
414
+ }
415
+ }
416
+ catch (Exception $e)
417
+ {
418
+ Mage::getModel('adminhtml/session')->addError($e->getMessage());
419
+ }
420
+ $this->_redirect('*/*');
421
+ }
422
+
423
+ public function sendcampaignAction()
424
+ {
425
+ $post = $this->getRequest()->getPost();
426
+ $sendinModule = Mage::getModel('sendinblue/sendinblue');
427
+ try {
428
+ if (empty($post))
429
+ Mage::throwException($this->__('Invalid form data.'));
430
+
431
+ $sendin_switch = new Mage_Core_Model_Config();
432
+
433
+ if (isset($post['sender_campaign_save']) && $post['Sendin_Sms_Choice'] == 1)
434
+ {
435
+ $arr = array();
436
+ $arr['to'] = $post['singlechoice'];
437
+ $arr['from'] = $post['sender_campaign'];
438
+ $arr['text'] = $post['sender_campaign_message'];
439
+
440
+ $result = $sendinModule->sendSmsApi($arr);
441
+ if (isset($result->status) && $result->status == 'OK')
442
+ {
443
+ $message = $this->__('Message has been sent successfully');
444
+ Mage::getModel('adminhtml/session')->addSuccess($message);
445
+ }
446
+ else
447
+ {
448
+ $message = $this->__('Message has not been sent successfully');
449
+ Mage::getModel('adminhtml/session')->addError($message);
450
+ }
451
+ }
452
+ else if(isset($post['sender_campaign_save']) && $post['Sendin_Sms_Choice'] == 0)
453
+ {
454
+ $smscredit = $sendinModule->getSmsCredit();
455
+ $collection = Mage::getModel('customer/customer')
456
+ ->getCollection()
457
+ ->addAttributeToSelect('*')
458
+ ->joinAttribute('shipping_telephone', 'customer_address/telephone', 'default_shipping', null, 'left')
459
+ ->joinAttribute('shipping_country_code', 'customer_address/country_id', 'default_shipping', null, 'left');
460
+
461
+ $results = array();
462
+ foreach ($collection as $customer) {
463
+ $results[] = $customer->toArray();
464
+ }
465
+
466
+ foreach ($results as $i => $result)
467
+ {
468
+ if(!empty($result['shipping_telephone']) && !empty($result['shipping_country_code']))
469
+ {
470
+ $country_code = $sendinModule->getCountryCode($result['shipping_country_code']);
471
+ $number = $sendinModule->checkMobileNumber($result['shipping_telephone'],$country_code);
472
+ $firstname = !empty($result['firstname'])?$result['firstname']:'';
473
+ $lastname = !empty($result['lastname'])?$result['lastname']:'';
474
+ $msgbody = !empty($post['sender_campaign_message'])?$post['sender_campaign_message']:'';
475
+ $fname = str_replace('{first_name}', $firstname, $msgbody);
476
+ $msgbody = str_replace('{last_name}', $lastname."\r\n", $fname);
477
+ $arr = array();
478
+ $arr['to'] = $number;
479
+ $arr['from'] = !empty($post['sender_campaign'])?$post['sender_campaign']:'';
480
+ $arr['text'] = $msgbody;
481
+ $sendinModule->sendSmsApi($arr);
482
+ }
483
+ }
484
+ if ($smscredit >= 1)
485
+ {
486
+ $message = $this->__('Message has been sent successfully');
487
+ Mage::getModel('adminhtml/session')->addSuccess($message);
488
+ }
489
+ else
490
+ {
491
+ $message = $this->__('Message has not been sent successfully');
492
+ Mage::getModel('adminhtml/session')->addError($message);
493
+ }
494
+ }
495
+ else if(isset($post['sender_campaign_save']) && $post['Sendin_Sms_Choice'] == 2)
496
+ {
497
+ $smscredit = $sendinModule->getSmsCredit();
498
+
499
+ $schedule_month = $post['sib_datetimepicker'];
500
+ $schedule_hour = $post['hour'];
501
+ $schedule_minute = $post['minute'];
502
+ if ($schedule_hour < 10) {
503
+ $schedule_hour = '0'.$schedule_hour;
504
+ }
505
+ if ($schedule_minute < 10) {
506
+ $schedule_minute = '0'.$schedule_minute;
507
+ }
508
+ $schedule_time = $schedule_month.' '.$schedule_hour.':'.$schedule_minute.':00';
509
+
510
+ $current_time = date('Y-m-d H:i:s', time() + 300);
511
+ $currenttm = strtotime($current_time);
512
+ $scheduletm = strtotime($schedule_time);
513
+
514
+ if ($schedule_time != '' || $scheduletm >= $currenttm)
515
+ {
516
+ $camp_name = 'SMS_'.date('Ymd');
517
+ $key = $sendinModule->getApiKey();
518
+ if ($key == '')
519
+ return false;
520
+ $param['key'] = $key;
521
+ $param['listname'] = $camp_name;
522
+ $param['webaction'] = 'NEWLIST';
523
+ $param['list_parent'] = '1';
524
+ //folder id
525
+ $list_response = $sendinModule->curlRequest($param);
526
+ $res = json_decode($list_response);
527
+ $list_id = $res->result;
528
+ // import old user to SendinBlue
529
+
530
+ $iso_code = $this->context->language->iso_code;
531
+ $allemail = $sendinModule->smsCampaignList();
532
+
533
+ $data['webaction'] = 'MULTI-USERCREADIT';
534
+ $data['key'] = $key;
535
+ $data['attributes'] = $allemail;
536
+ $data['listid'] = $list_id;
537
+ // List id should be optional
538
+
539
+ $data_responce = $sendinModule->curlRequest($data);
540
+ $msgbody = $post['sender_campaign_message'];
541
+ $value_langauge = $sendinModule->getApiConfigValue();
542
+ if ($value_langauge->language == 'fr')
543
+ {
544
+ $firstname = '{NOM}';
545
+ $lastname = '{PRENOM}';
546
+ }
547
+ else
548
+ {
549
+ $firstname = '{NAME}';
550
+ $lastname = '{SURNAME}';
551
+ }
552
+ $fname = str_replace('{first_name}', $firstname, $msgbody);
553
+ $msgbody = str_replace('{last_name}', $lastname."\r\n", $fname);
554
+ $arr = array();
555
+ $sender_campaign = $post['sender_campaign'];
556
+ $content = $msgbody;
557
+ $arr['key'] =$sendinModule->getApiKey();
558
+ $arr['webaction'] = 'SMSCAMPCREADIT';
559
+ $arr['camp_name'] = $camp_name; // mandatory
560
+ $arr['sender'] = $sender_campaign;
561
+ $arr['content'] = $content;
562
+ $arr['bat_sent'] = '';
563
+ $arr['listids'] = $list_id; // mandatory if SMS campaign is scheduled
564
+ $arr['exclude_list'] = '';
565
+ $arr['schedule'] = $scheduletm;
566
+
567
+ $data_camp = $sendinModule->curlRequest($arr);
568
+
569
+ if ($smscredit >= 1)
570
+ {
571
+ $message = $this->__('Message has been sent successfully');
572
+ Mage::getModel('adminhtml/session')->addSuccess($message);
573
+ }
574
+ else
575
+ {
576
+ $message = $this->__('Message has not been sent successfully');
577
+ Mage::getModel('adminhtml/session')->addError($message);
578
+ }
579
+ }
580
+ else
581
+ {
582
+ $message = $this->__('Scheduled date may not be prior to the current date');
583
+ Mage::getModel('adminhtml/session')->addError($message);
584
+ }
585
+ }
586
+ }
587
+ catch (Exception $e)
588
+ {
589
+ Mage::getModel('adminhtml/session')->addError($e->getMessage());
590
+ }
591
+ $this->_redirect('*/*');
592
+ }
593
+ }
app/code/{local → community}/Sendinblue/Sendinblue/controllers/Adminhtml/NotifyController.php RENAMED
@@ -13,9 +13,8 @@ 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/");
20
  }
21
  }
13
  public function indexAction()
14
  {
15
  $responce = Mage::getModel('sendinblue/sendinblue')->notifySmsEmail();
 
16
  $msg_disp = $this->__('The CRON has been well executed.');
17
+ Mage::getModel('adminhtml/session')->addSuccess($msg_disp);
18
  $this->_redirect("sendinblue/adminhtml_myform/");
19
  }
20
  }
app/code/{local → community}/Sendinblue/Sendinblue/controllers/Adminhtml/SyncController.php RENAMED
@@ -13,9 +13,8 @@ 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/");
20
  }
21
  }
13
  public function indexAction()
14
  {
15
  $responce = Mage::getModel('sendinblue/sendinblue')->syncData();
 
16
  $msg_disp = $this->__('The CRON has been well executed.');
17
+ Mage::getModel('adminhtml/session')->addSuccess($msg_disp);
18
  $this->_redirect("sendinblue/adminhtml_myform/");
19
  }
20
  }
app/code/community/Sendinblue/Sendinblue/controllers/AjaxController.php ADDED
@@ -0,0 +1,766 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @author Sendinblue plateform <contact@sendinblue.com>
4
+ * @copyright 2013-2014 Sendinblue
5
+ * URL: https:www.sendinblue.com
6
+ * Do not edit or add to this file if you wish to upgrade Sendinblue Magento plugin to newer
7
+ * versions in the future. If you wish to customize Sendinblue magento plugin for your
8
+ * needs then we can't provide a technical support.
9
+ **/
10
+
11
+ class Sendinblue_Sendinblue_AjaxController extends Mage_Core_Controller_Front_Action
12
+ {
13
+ public function indexAction()
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()
24
+ {
25
+ $post = $this->getRequest()->getPost();
26
+ try {
27
+ if (empty($post))
28
+ echo Mage::throwException($this->__('Invalid form data.'));
29
+ $sendin_switch = new Mage_Core_Model_Config();
30
+ $sendin_switch->saveConfig('sendinblue/sms/campaign', $post['campaignSetting']);
31
+ echo $this->__('Your setting has been successfully saved');
32
+ }
33
+ catch (Exception $e)
34
+ {
35
+ echo $this->__($e->getMessage());
36
+ }
37
+ }
38
+ public function orderAction()
39
+ {
40
+ $post = $this->getRequest()->getPost();
41
+ try {
42
+ if (empty($post))
43
+ Mage::throwException($this->__('Invalid form data.'));
44
+ $sendin_switch = new Mage_Core_Model_Config();
45
+ $sendin_switch->saveConfig('sendinblue/sms/order', $post['orderSetting']);
46
+ echo $this->__('Your setting has been successfully saved');
47
+ }
48
+ catch (Exception $e)
49
+ {
50
+ echo $this->__($e->getMessage());
51
+ }
52
+ }
53
+ public function creditAction()
54
+ {
55
+ $post = $this->getRequest()->getPost();
56
+ try {
57
+ if (empty($post))
58
+ Mage::throwException($this->__('Invalid form data.'));
59
+ $sendin_switch = new Mage_Core_Model_Config();
60
+ $sendin_switch->saveConfig('sendinblue/sms/credit', $post['sms_credit']);
61
+ echo $this->__('Your setting has been successfully saved');
62
+ }
63
+ catch (Exception $e)
64
+ {
65
+ echo $this->__($e->getMessage());
66
+ }
67
+ }
68
+ public function shipingAction()
69
+ {
70
+ $post = $this->getRequest()->getPost();
71
+ try {
72
+ if (empty($post))
73
+ Mage::throwException($this->__('Invalid form data.'));
74
+ $sendin_switch = new Mage_Core_Model_Config();
75
+ $sendin_switch->saveConfig('sendinblue/sms/shiping', $post['shipingSetting']);
76
+ echo $this->__('Your setting has been successfully saved');
77
+ }
78
+ catch (Exception $e)
79
+ {
80
+ echo $this->__($e->getMessage());
81
+ }
82
+ }
83
+ public function codepostAction()
84
+ {
85
+ $post = $this->getRequest()->getPost();
86
+ try {
87
+ if (empty($post))
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 mailResponceAction()
120
+ {
121
+ $post = $this->getRequest()->getParams();
122
+ try {
123
+ if (empty($post))
124
+ Mage::throwException($this->__('Invalid form data.'));
125
+
126
+ $user_email = base64_decode($post['value']);
127
+ if ($user_email != '') {
128
+ $newsletter = Mage::getResourceModel('newsletter/subscriber_collection')->addFieldToFilter('subscriber_email', array('eq' => $user_email))->load();;
129
+ foreach ($newsletter->getItems() as $subscriber) {
130
+ $subsdata = $subscriber->getData();
131
+ $subscriber_email = $subsdata['subscriber_email'];
132
+ $subscriber_status = $subsdata['subscriber_status'];
133
+ }
134
+ $sendinModule = Mage::getModel('sendinblue/sendinblue');
135
+ if (!empty($subscriber_email) && $subscriber_status == 1) {
136
+ $listId = $sendinModule->getUserlists();
137
+ $doubleOptinId = Mage::getStoreConfig('sendinblue/SendinOptinListId');
138
+ $api_key = $sendinModule->getApiKey();
139
+ $params['url'] = "https://api.sendinblue.com/v2.0";
140
+ $params['api_key'] = $api_key;
141
+ $obj_mailin = Mage::getModel('sendinblue/psmailin',$params);
142
+
143
+ $data = array( "email" => $subscriber_email,
144
+ "attributes" => array(),
145
+ "blacklisted" => 0,
146
+ "listid" => array($listId),
147
+ "listid_unlink" => array($doubleOptinId),
148
+ "blacklisted_sms" => 0
149
+ );
150
+
151
+ $responce = $obj_mailin->createUpdateUser($data);
152
+ $finalStatus = Mage::getStoreConfig('sendinblue/SendinFinalConfirmEmail');
153
+ if ($finalStatus === 'yes') {
154
+ $finalTempId = Mage::getStoreConfig('sendinblue/SendinTemplateFinal');
155
+ $sendinModule->sendWsTemplateMail($subscriber_email, $finalTempId);
156
+
157
+ }
158
+ $urlStatus = $sendinModule->getOptinRedirectUrlCheck();
159
+
160
+ if ($urlStatus == 'yes') {
161
+ $urlValue = $sendinModule->getSendinDoubleoptinRedirectUrl();
162
+ $this->_redirectUrl($urlValue);
163
+ } else {
164
+ $configValue = Mage::getStoreConfig('web/secure/base_url');
165
+ $this->_redirectUrl($configValue);
166
+ }
167
+ }
168
+ }
169
+ }
170
+ catch (Exception $e)
171
+ {
172
+ echo $this->__($e->getMessage());
173
+ }
174
+ }
175
+ public function emptyImportOldOrderAction()
176
+ {
177
+ $post = $this->getRequest()->getPost();
178
+ try {
179
+ if (empty($post))
180
+ Mage::throwException($this->__('Invalid form data.'));
181
+ if ($post['proc_success'] != '')
182
+ {
183
+ $handle = fopen(Mage::getBaseDir('media').'/sendinblue_csv/ImportOldOrdersToSendinblue.csv', 'w+');
184
+ $key_value = array();
185
+ $key_value[] = '';
186
+ fputcsv($handle, $key_value);
187
+ fclose($handle);
188
+ }
189
+ }
190
+ catch (Exception $e)
191
+ {
192
+ echo $this->__($e->getMessage());
193
+ }
194
+ }
195
+ public function orderhistoryAction()
196
+ {
197
+ $sendinModule = Mage::getModel('sendinblue/sendinblue');
198
+ $post = $this->getRequest()->getPost();
199
+ try {
200
+ if (empty($post))
201
+ Mage::throwException($this->__('Invalid form data.'));
202
+
203
+ if ($post['history_status'] == 1)
204
+ {
205
+ $value = $sendinModule->TrackingSmtp();
206
+ $date_value = $sendinModule->getApiConfigValue();
207
+ if (!is_dir(Mage::getBaseDir('media').'/sendinblue_csv'))
208
+ mkdir(Mage::getBaseDir('media').'/sendinblue_csv', 0777, true);
209
+
210
+ $handle = fopen(Mage::getBaseDir('media').'/sendinblue_csv/ImportOldOrdersToSendinblue.csv', 'w+');
211
+
212
+ fwrite($handle, 'EMAIL,ORDER_ID,ORDER_PRICE,ORDER_DATE'.PHP_EOL);
213
+
214
+
215
+ $collection = Mage::getModel('customer/customer')->getCollection()->addAttributeToSelect('email');
216
+
217
+ $salesOrderColection = Mage::getModel('sales/order');
218
+ foreach ($collection as $customer)
219
+ {
220
+ $cid = $customer->getData('entity_id');
221
+ $email = $customer->getData('email');
222
+ $total_orders = $salesOrderColection->getCollection()->addFieldToFilter('customer_id', $cid);
223
+ $orderCnt = $total_orders->count();
224
+ if ($orderCnt > 0)
225
+ {
226
+ $data = array();
227
+ $data['key'] = $sendinModule->getApiKey();
228
+ $data['webaction'] = 'USERS-STATUS';
229
+ $data['email'] = $email;
230
+ $curl_responce = $sendinModule->curlRequest($data);
231
+ $user_status = json_decode($curl_responce);
232
+ }
233
+ if (isset($user_status->result) != '')
234
+ {
235
+ foreach($total_orders as $order_data)
236
+ {
237
+ if ($date_value->date_format == 'dd-mm-yyyy')
238
+ $date = date('d-m-Y', strtotime($order_data['created_at']));
239
+ else
240
+ $date = date('m-d-Y', strtotime($order_data['created_at']));
241
+ $history_data= array();
242
+ $history_data[] = array($order_data['customer_email'],$order_data['increment_id'],$order_data['grand_total'],$date);
243
+ foreach ($history_data as $line)
244
+ fputcsv($handle, $line);
245
+ }
246
+ }
247
+ }
248
+
249
+ fclose($handle);
250
+
251
+ $get_User_lists = $sendinModule->getUserlists();
252
+ $list = str_replace('|', ',', $get_User_lists);
253
+ if (preg_match('/^[0-9,]+$/', $list))
254
+ $list = $list;
255
+ else
256
+ $list = '';
257
+
258
+ $import_data = array();
259
+ $import_data['webaction'] = 'IMPORTUSERS';
260
+ $import_data['key'] = $sendinModule->getApiKey();
261
+ $import_data['url'] = Mage::getBaseUrl('media').'sendinblue_csv/ImportOldOrdersToSendinblue.csv';
262
+ $import_data['listids'] = $list;
263
+ $import_data['notify_url'] = Mage::getBaseUrl().'sendinblue/ajax/emptyImportOldOrder';
264
+ /**
265
+ * List id should be optional
266
+ */
267
+ $sendinModule->curlRequestAsyc($import_data);
268
+
269
+ $sendin_switch = new Mage_Core_Model_Config();
270
+ $sendin_switch->saveConfig('sendinblue/improt/history', 0);
271
+ if($post['langvalue'] == 'fr_FR')
272
+ $msg = 'Historique des commandes a été importé avec succès.';
273
+ else
274
+ $msg = 'Order history has been import successfully';
275
+
276
+ echo $msg;
277
+ }
278
+ }
279
+ catch (Exception $e)
280
+ {
281
+ echo $this->__($e->getMessage());
282
+ }
283
+ }
284
+ public function smtppostAction()
285
+ {
286
+ $sendinModule = Mage::getModel('sendinblue/sendinblue');
287
+ $post = $this->getRequest()->getPost();
288
+ try {
289
+ if (empty($post))
290
+ Mage::throwException($this->__('Invalid form data.'));
291
+ else
292
+ {
293
+ $sendin_switch = new Mage_Core_Model_Config();
294
+ $get_key = $sendinModule->getApiKey();
295
+ $result = $sendinModule->checkApikey($get_key);
296
+ if (empty($result['error']))
297
+ {
298
+ $sendin_switch->saveConfig('sendinblue/smtp/status', $post['smtptest']);
299
+ $smtp_response = $sendinModule->TrackingSmtp(); // get tracking code
300
+ if ($smtp_response->result->relay_data->status == 'enabled')
301
+ {
302
+ $sendin_switch->saveConfig('sendinblue/smtp/authentication', 'crammd5', 'default', 0);
303
+ $sendin_switch->saveConfig('sendinblue/smtp/username', $smtp_response->result->relay_data->data->username, 'default', 0);
304
+ $sendin_switch->saveConfig('sendinblue/smtp/password', $smtp_response->result->relay_data->data->password, 'default', 0);
305
+ $sendin_switch->saveConfig('sendinblue/smtp/host', $smtp_response->result->relay_data->data->relay, 'default', 0);
306
+ $sendin_switch->saveConfig('sendinblue/smtp/port', $smtp_response->result->relay_data->data->port, 'default', 0);
307
+ $sendin_switch->saveConfig('sendinblue/smtp/ssl', 'null', 'default', 0);
308
+ $sendin_switch->saveConfig('sendinblue/smtp/option', 'smtp', 'default', 0);
309
+ echo $this->__('Your setting has been successfully saved');
310
+ }else
311
+ {
312
+ $sendin_switch->saveConfig('sendinblue/smtp/status', 0);
313
+ echo $this->__('Your SMTP account is not activated and therefore you can\'t use SendinBlue SMTP. For more informations, please contact our support to: contact@sendinblue.com');
314
+ }
315
+ }elseif (isset($responce['error']))
316
+ echo $this->__('You have entered wrong api key');
317
+ }
318
+ }
319
+ catch (Exception $e)
320
+ {
321
+ echo $this->__($e->getMessage());
322
+ }
323
+ }
324
+ public function ajaxcontentAction()
325
+ {
326
+ $sendinModule = Mage::getModel('sendinblue/sendinblue');
327
+ $post = $this->getRequest()->getPost();
328
+ try {
329
+ if (empty($post))
330
+ Mage::throwException($this->__('Invalid form data.'));
331
+ else
332
+ {
333
+ $locale = Mage::app()->getLocale()->getLocaleCode();
334
+ if ($locale == 'fr_FR')
335
+ {
336
+ $title1 = 'Inscrire le contact';
337
+ $title2 = 'Désinscrire le contact';
338
+ $title3 = 'Inscrire le sms';
339
+ $title4 = 'Désinscrire le sms';
340
+ $first = 'Première page';
341
+ $last = 'Dernière page';
342
+ $previous = 'Précédente';
343
+ $next = 'Suivante';
344
+ $yes = 'oui';
345
+ $no = 'non';
346
+ } else
347
+ {
348
+ $title1 = 'Unsubscribe the contact';
349
+ $title2 = 'Subscribe the contact';
350
+ $title3 = 'Unsubscribe the sms';
351
+ $title4 = 'Subscribe the sms';
352
+ $first = 'First';
353
+ $last = 'Last';
354
+ $previous = 'Previous';
355
+ $next = 'Next';
356
+ $yes = 'yes';
357
+ $no = 'no';
358
+ }
359
+ $page = (int)$post['page'];
360
+ $cur_page = $page;
361
+ $page -= 1;
362
+ $per_page = 20;
363
+ $previous_btn = true;
364
+ $next_btn = true;
365
+ $first_btn = true;
366
+ $last_btn = true;
367
+ $start = $page * $per_page;
368
+ $count = $sendinModule->getNewsletterSubscribeCount() + $sendinModule->getNewsletterUnSubscribeCount();
369
+ $no_of_paginations = ceil($count / $per_page);
370
+ if ($cur_page >= 7)
371
+ {
372
+ $start_loop = $cur_page - 3;
373
+ if ($no_of_paginations > $cur_page + 3)
374
+ $end_loop = $cur_page + 3;
375
+ else if ($cur_page <= $no_of_paginations && $cur_page > $no_of_paginations - 6)
376
+ {
377
+ $start_loop = $no_of_paginations - 6;
378
+ $end_loop = $no_of_paginations;
379
+ } else
380
+ $end_loop = $no_of_paginations;
381
+ } else
382
+ {
383
+ $start_loop = 1;
384
+ if ($no_of_paginations > 7)
385
+ $end_loop = 7;
386
+ else
387
+ $end_loop = $no_of_paginations;
388
+ }
389
+ $collection = $sendinModule->getNewsletterSubscribe($start, $per_page);
390
+ $sendin_status = $sendinModule->checkUserSendinStatus($collection);
391
+ $sendin_result = isset($sendin_status['result'])?$sendin_status['result']:'';
392
+ if (count($collection) > 0)
393
+ {
394
+ $i = 1;
395
+ $msg = '';
396
+ $skinUrl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_SKIN);
397
+ foreach ($collection as $subscriber)
398
+ {
399
+ $email = isset($subscriber['email'])?$subscriber['email']:'';
400
+ $phone = isset($subscriber['SMS'])?$subscriber['SMS'] : '';
401
+
402
+ if (!empty($subscriber['customer_id']) > 0)
403
+ $client = $yes;
404
+ else
405
+ $client = $no;
406
+
407
+ $show_status = '';
408
+ $sms_status = '';
409
+ if(isset($sendin_result[$email])) {
410
+ $email_bl_value = isset($sendin_result[$email]['email_bl'])?$sendin_result[$email]['email_bl']:'';
411
+ if ($email_bl_value === 1 || $sendin_result[$email] == null)
412
+ $show_status = 0;
413
+ if ($email_bl_value === 0)
414
+ $show_status = 1;
415
+
416
+ $sms_bl = isset($sendin_result[$email]['sms_bl'])?$sendin_result[$email]['sms_bl']:'';
417
+ $sms_exist = isset($sendin_result[$email]['sms_exist'])?$sendin_result[$email]['sms_exist']:'';
418
+ $subs_telephone = isset($subscriber['SMS'])?$subscriber['SMS']:'';
419
+ if ($sms_bl === 1 && $sms_exist > 0)
420
+ $sms_status = 0;
421
+ elseif ($sms_bl === 0 && $sms_exist > 0)
422
+ $sms_status = 1;
423
+ elseif ($sms_exist <= 0 && empty($subs_telephone))
424
+ $sms_status = 2;
425
+ else if ($sms_exist <= 0 && !empty($subs_telephone))
426
+ $sms_status = 3;
427
+ }
428
+ if ($subscriber['subscriber_status'] != 3)
429
+ $img_magento = '<img src="'.$skinUrl.'adminhtml/default/default/sendinblue/images/enabled.gif" >';
430
+ else
431
+ $img_magento = '<img src="'.$skinUrl.'adminhtml/default/default/sendinblue/images/disabled.gif" >';
432
+
433
+ $sms_status = $sms_status >= 0?$sms_status:'';
434
+
435
+ if ($sms_status === 1)
436
+ $img_sms = '<img src="'.$skinUrl.'adminhtml/default/default/sendinblue/images/enabled.gif"
437
+ id="ajax_contact_status_'.$i.'" title="'.$title3.'" >';
438
+ else if ($sms_status === 0)
439
+ $img_sms = '<img src="'.$skinUrl.'adminhtml/default/default/sendinblue/images/disabled.gif"
440
+ id="ajax_contact_status_'.$i.'" title="'.$title4.'" >';
441
+ else if ($sms_status === 2 || $sms_status === '')
442
+ $img_sms = '';
443
+ else if ($sms_status === 3)
444
+ $img_sms = 'Not synchronized';
445
+ $show_status = !empty($show_status)?$show_status:'0';
446
+ if ($show_status == 1)
447
+ $img_sendin = '<img src="'.$skinUrl.'adminhtml/default/default/sendinblue/images/enabled.gif"
448
+ id="ajax_contact_status_'.$i.'" title="'.$title1.'" >';
449
+ else
450
+ $img_sendin = '<img src="'.$skinUrl.'adminhtml/default/default/sendinblue/images/disabled.gif"
451
+ id="ajax_contact_status_'.$i.'" title="'.$title2.'" >';
452
+ $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>
453
+ <td class="a-left"><a status="'.$show_status.'" email="'.$email.'" class="ajax_contacts_href" href="javascript:void(0)">
454
+ '.$img_sendin.'</a></td><td class="a-left last"><a status="'.$sms_status.'" email="'.$email.'" class="ajax_sms_subs_href" href="javascript:void(0)">
455
+ '.$img_sms.'</a></td></tr>';
456
+ $i++;
457
+ }
458
+ }
459
+ $msg_paging = '';
460
+ $msg_paging .= '<tr><td colspan="7"><div class="pagination"><ul class="pull-left">';
461
+ if ($first_btn && $cur_page > 1)
462
+ $msg_paging .= '<li p="1" class="active">'.$first.'</li>';
463
+ else if ($first_btn)
464
+ $msg_paging .= '<li p="1" class="inactive">'.$first.'</li>';
465
+ if ($previous_btn && $cur_page > 1)
466
+ {
467
+ $pre = $cur_page - 1;
468
+ $msg_paging .= '<li p="'.$pre.'" class="active">'.$previous.'</li>';
469
+ } else if ($previous_btn)
470
+ $msg_paging .= '<li class="inactive">'.$previous.'</li>';
471
+ for ($i = $start_loop; $i <= $end_loop; $i++)
472
+ {
473
+ if ($cur_page == $i)
474
+ $msg_paging .= '<li p="'.$i.'" style="color:#fff;background-color:#000000;" class="active">'.$i.'</li>';
475
+ else
476
+ $msg_paging .= '<li p="'.$i.'" class="active">'.$i.'</li>';
477
+ }
478
+ if ($next_btn && $cur_page < $no_of_paginations)
479
+ {
480
+ $nex = $cur_page + 1;
481
+ $msg_paging .= '<li p="'.$nex.'" class="active">'.$next.'</li>';
482
+ } else if ($next_btn)
483
+ $msg_paging .= '<li class="inactive">'.$next.'</li>';
484
+ if ($last_btn && $cur_page < $no_of_paginations)
485
+ $msg_paging .= '<li p="'.$no_of_paginations.'" class="active">'.$last.'</li>';
486
+ else if ($last_btn)
487
+ $msg_paging .= '<li p="'.$no_of_paginations.'" class="inactive">'.$last.'</li>';
488
+ if ($count != 0)
489
+ echo $msg.$msg_paging.'</td></tr>';
490
+ }
491
+ }catch (Exception $e)
492
+ {
493
+ echo $this->__($e->getMessage());
494
+ }
495
+ }
496
+ public function ajaxsmssubscribeAction()
497
+ {
498
+ $sendinModule = Mage::getModel('sendinblue/sendinblue');
499
+ $post = $this->getRequest()->getPost();
500
+ try {
501
+ if (empty($post))
502
+ Mage::throwException($this->__('Invalid form data.'));
503
+ $email = $post['email'];
504
+ $data = array();
505
+ $data['key'] = $sendinModule->getApiKey();
506
+ $data['webaction'] = 'USERUNSUBSCRIBEDSMS';
507
+ $data['email'] = $email;
508
+ $sendinModule->curlRequest($data);
509
+ }
510
+ catch (Exception $e)
511
+ {
512
+ echo $this->__($e->getMessage());
513
+ }
514
+ }
515
+ public function ajaxupdateAction()
516
+ {
517
+ $post = $this->getRequest()->getPost();
518
+ $coreResource = Mage::getSingleton('core/resource');
519
+ $tableCustomer = $coreResource->getTableName('customer/entity');
520
+ $tableNewsletter = $coreResource->getTableName('newsletter/subscriber');
521
+ $sendinModule = Mage::getModel('sendinblue/sendinblue');
522
+ $attributesName = $sendinModule->allAttributesName();
523
+ try {
524
+ if (empty($post))
525
+ Mage::throwException($this->__('Invalid form data.'));
526
+ $list_id = str_replace(',', '|', $sendinModule->getUserlists());
527
+ $post_email = !empty($post['email'])?$post['email']:'';
528
+ $post_newsletter = !empty($post['newsletter'])?$post['newsletter']:'';
529
+ $temp_sub_status = ($post_newsletter == 0) ? 1 : 3;
530
+ $sql = 'SELECT `store_id`, `entity_id` from '.$tableCustomer.' where email = "'.$post_email.'" ';
531
+ $connection = $coreResource->getConnection('core_read');
532
+ $custdata = $connection->fetchRow($sql);
533
+ if (!empty($post_email) && $post_newsletter == 0)
534
+ {
535
+ $locale = Mage::app()->getLocale()->getLocaleCode();
536
+ $responce = $sendinModule->emailSubscribe($post_email);
537
+ $responce_data = json_decode($responce);
538
+ $customerAddr = array();
539
+ if (isset($responce_data->errorMsg) == 'User not exists')
540
+ {
541
+ if (isset($custdata['entity_id']) != '')
542
+ {
543
+ $collectionAddress = Mage::getModel('customer/address')->getCollection()->addAttributeToSelect('telephone')->addAttributeToSelect('country_id')->addAttributeToSelect('company')->addAttributeToSelect('street')->addAttributeToSelect('postcode')->addAttributeToSelect('region')->addAttributeToSelect('city')->addAttributeToFilter('parent_id',(int)$custdata['entity_id']);
544
+ $telephone = '';
545
+ foreach ($collectionAddress as $customerPhno)
546
+ {
547
+ $customerAddr = $customerPhno->getData();
548
+ if (!empty($customerAddr['telephone']) && !empty($customerAddr['country_id']))
549
+ {
550
+ $country_code = $sendinModule->getCountryCode($customerAddr['country_id']);
551
+ $customerAddr['telephone'] = $sendinModule->checkMobileNumber($customerAddr['telephone'], $country_code);
552
+ }
553
+ }
554
+ $customer = Mage::getModel("customer/customer");
555
+ $customer->setWebsiteId(Mage::app()->getWebsite()->getId());
556
+ $customer->loadByEmail($post_email); //load customer by email id
557
+ $customer_name = $customer->getData();
558
+ $user_lang = isset($customer_name['created_in'])?$customer_name['created_in'] : '';
559
+ $customerData = array_merge($customerAddr, $customer_name);
560
+ $resp = $sendinModule->merge_my_array($attributesName, $customerData);
561
+ $resp['CLIENT'] = 1;
562
+ $resp['MAGENTO_LANG'] = $user_lang;
563
+ $responce = $sendinModule->emailAdd($post_email, $resp, $post_newsletter, $list_id);
564
+ }
565
+ else
566
+ {
567
+ $client = 0;
568
+ $customerData = array();
569
+ $subsdata = Mage::getModel('newsletter/subscriber')->loadByEmail($email)->getData();
570
+ $resp = $sendinModule->merge_my_array($attributesName, $subsdata);
571
+ $resp['CLIENT'] = $client;
572
+ $responce = $sendinModule->emailAdd($post_email, $resp, $post_newsletter, $list_id);
573
+ }
574
+ }
575
+ $sql = 'SELECT `subscriber_email` from '.$tableNewsletter.' where subscriber_email = "'.$post_email.'" ';
576
+ $custdatanews = $connection->fetchRow($sql);
577
+ if ($custdata['entity_id'] !='' && $custdatanews['subscriber_email'] == '' )
578
+ {
579
+ $connection->query("insert into ".$tableNewsletter."(store_id, customer_id, subscriber_email, subscriber_status)
580
+ values('".$custdata['store_id']."','".$custdata['entity_id']."','".$post_email."','1')");
581
+
582
+ }
583
+ else
584
+ {
585
+ $costomer_data = Mage::getModel('newsletter/subscriber')->loadByEmail($post_email);
586
+ $costomer_data->setStatus($temp_sub_status);
587
+ $costomer_data->setIsStatusChanged(true);
588
+ $costomer_data->save();
589
+ }
590
+
591
+ }
592
+ else{
593
+ $responce = $sendinModule->emailDelete($post_email);
594
+ $costomer_data = Mage::getModel('newsletter/subscriber')->loadByEmail($post_email);
595
+
596
+ if (!$costomer_data->getStoreId())
597
+ {
598
+ $costomer_data->setSubscriberEmail($post_email);
599
+ $costomer_data->setCustomerId($custdata['entity_id']);
600
+ $costomer_data->setStoreId($custdata['store_id']);
601
+ }
602
+ $costomer_data->setStatus($temp_sub_status);
603
+ $costomer_data->setIsStatusChanged(true);
604
+ $costomer_data->save();
605
+ }
606
+ }
607
+ catch (Exception $e)
608
+ {
609
+ echo $this->__($e->getMessage());
610
+ }
611
+ }
612
+
613
+ public function ajaxordersmsAction($sender='', $message='', $number='')
614
+ {
615
+ $post = $this->getRequest()->getPost();
616
+ try {
617
+ if (empty($post))
618
+ Mage::throwException($this->__('Invalid form data.'));
619
+ $number = $post['number'];
620
+ $charone = substr($number, 0, 1);
621
+ $chartwo = substr($number, 0, 2);
622
+ if ($charone == '0' && $chartwo == '00')
623
+ $number = $number;
624
+
625
+ if (isset($number))
626
+ {
627
+ $adminUserModel = Mage::getModel('admin/user');
628
+ $userCollection = $adminUserModel->getCollection()->load();
629
+ $admin_data = $userCollection->getData();
630
+ $firstname = isset($admin_data[0]['firstname'])?$admin_data[0]['firstname']:'';
631
+ $lastname = isset($admin_data[0]['lastname'])?$admin_data[0]['lastname']:'';
632
+ $characters = '1234567890';
633
+ $ref_num = '';
634
+ for ($i = 0; $i < 9; $i++)
635
+ $ref_num .= $characters[rand(0, strlen($characters) - 1)];
636
+
637
+ $locale = Mage::app()->getLocale()->getLocaleCode();
638
+ if ($locale == 'fr_FR')
639
+ $ord_date = date('d/m/Y');
640
+ else
641
+ $ord_date = date('m/d/Y');
642
+ $orderprice = rand(10, 1000);
643
+ $total_pay = $orderprice.'.00'.' '.Mage::app()->getStore()-> getCurrentCurrencyCode();
644
+ $msgbody = $post['message'];
645
+ $fname = str_replace('{first_name}', $firstname, $msgbody);
646
+ $lname = str_replace('{last_name}', $lastname."\r\n", $fname);
647
+ $procuct_price = str_replace('{order_price}', $total_pay, $lname);
648
+ $order_date = str_replace('{order_date}', $ord_date."\r\n", $procuct_price);
649
+ $msgbody = str_replace('{order_reference}', $ref_num, $order_date);
650
+ $arr = array();
651
+ $arr['to'] = $number;
652
+ $arr['from'] = isset($post['sender'])?$post['sender']:'';
653
+ $arr['text'] = $msgbody;
654
+
655
+ $result = Mage::getModel('sendinblue/sendinblue')->sendSmsApi($arr);
656
+ if (isset($result->status) && $result->status == 'OK')
657
+ echo 'OK';
658
+ else
659
+ echo 'KO';
660
+ }
661
+
662
+ }
663
+ catch (Exception $e)
664
+ {
665
+ echo $this->__($e->getMessage());
666
+ }
667
+ }
668
+
669
+ public function ajaxordershippedAction($sender='', $message='', $number='')
670
+ {
671
+ $post = $this->getRequest()->getPost();
672
+ try {
673
+ if (empty($post))
674
+ Mage::throwException($this->__('Invalid form data.'));
675
+ $number = $post['number'];
676
+ $charone = substr($number, 0, 1);
677
+ $chartwo = substr($number, 0, 2);
678
+
679
+ if ($charone == '0' && $chartwo == '00')
680
+ $number = $number;
681
+
682
+ if (isset($number))
683
+ {
684
+ $adminUserModel = Mage::getModel('admin/user');
685
+ $userCollection = $adminUserModel->getCollection()->load();
686
+ $admin_data = $userCollection->getData();
687
+ $firstname = isset($admin_data[0]['firstname'])?$admin_data[0]['firstname']:'';
688
+ $lastname = isset($admin_data[0]['lastname'])?$admin_data[0]['lastname']:'';
689
+ $characters = '1234567890';
690
+ $ref_num = '';
691
+ for ($i = 0; $i < 9; $i++)
692
+ $ref_num .= $characters[rand(0, strlen($characters) - 1)];
693
+
694
+ $locale = Mage::app()->getLocale()->getLocaleCode();
695
+ if ($locale == 'fr_FR')
696
+ $ord_date = date('d/m/Y');
697
+ else
698
+ $ord_date = date('m/d/Y');
699
+ $orderprice = rand(10, 1000);
700
+ $total_pay = $orderprice.'.00'.' '.Mage::app()->getStore()-> getCurrentCurrencyCode();
701
+ $msgbody = $post['message'];
702
+ $fname = str_replace('{first_name}', $firstname, $msgbody);
703
+ $lname = str_replace('{last_name}', $lastname."\r\n", $fname);
704
+ $procuct_price = str_replace('{order_price}', $total_pay, $lname);
705
+ $order_date = str_replace('{order_date}', $ord_date."\r\n", $procuct_price);
706
+ $msgbody = str_replace('{order_reference}', $ref_num, $order_date);
707
+ $arr = array();
708
+ $arr['to'] = $number;
709
+ $arr['from'] = !empty($post['sender'])?$post['sender']:'';
710
+ $arr['text'] = $msgbody;
711
+
712
+ $result = Mage::getModel('sendinblue/sendinblue')->sendSmsApi($arr);
713
+ if (isset($result->status) && $result->status == 'OK')
714
+ echo 'OK';
715
+ else
716
+ echo 'KO';exit;
717
+ }
718
+
719
+ }
720
+ catch (Exception $e)
721
+ {
722
+ echo $this->__($e->getMessage());
723
+ }
724
+ }
725
+
726
+ public function ajaxsmscampaignAction($sender='', $message='', $number='')
727
+ {
728
+ $post = $this->getRequest()->getPost();
729
+ try {
730
+ if (empty($post))
731
+ Mage::throwException($this->__('Invalid form data.'));
732
+ $number = $post['number'];
733
+ $charone = substr($number, 0, 1);
734
+ $chartwo = substr($number, 0, 2);
735
+ if ($charone == '0' && $chartwo == '00')
736
+ $number = $number;
737
+
738
+ if (isset($number))
739
+ {
740
+ $adminUserModel = Mage::getModel('admin/user');
741
+ $userCollection = $adminUserModel->getCollection()->load();
742
+ $admin_data = $userCollection->getData();
743
+ $firstname = isset($admin_data[0]['firstname'])?$admin_data[0]['firstname']:'';
744
+ $lastname = isset($admin_data[0]['lastname'])?$admin_data[0]['lastname']:'';
745
+ $msgbody = $post['message'];
746
+ $fname = str_replace('{first_name}', $firstname, $msgbody);
747
+ $msgbody = str_replace('{last_name}', $lastname."\r\n", $fname);
748
+ $arr = array();
749
+ $arr['to'] = $number;
750
+ $arr['from'] = !empty($post['sender'])?$post['sender']:'';
751
+ $arr['text'] = $msgbody;
752
+ $result = Mage::getModel('sendinblue/sendinblue')->sendSmsApi($arr);
753
+ if (isset($result->status) && $result->status == 'OK')
754
+ echo 'OK';
755
+ else
756
+ echo 'KO';
757
+ }
758
+
759
+ }
760
+ catch (Exception $e)
761
+ {
762
+ echo $this->__($e->getMessage());
763
+ }
764
+ }
765
+
766
+ }
app/code/{local → community}/Sendinblue/Sendinblue/controllers/IndexController.php RENAMED
File without changes
app/code/{local → community}/Sendinblue/Sendinblue/etc/adminhtml.xml RENAMED
File without changes
app/code/{local → community}/Sendinblue/Sendinblue/etc/config.xml RENAMED
@@ -1,325 +1,321 @@
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.2.4</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
+ <doubleoptin_template>
208
+ <label>Sendinblue doubleoptin email module</label>
209
+ <file>doubleoptin_temp.html</file>
210
+ <type>html</type>
211
+ </doubleoptin_template>
212
+ </email>
213
+ </template>
214
+
215
+ <models>
216
+ <core>
217
+ <rewrite>
218
+ <email>Sendinblue_Sendinblue_Model_Email</email>
219
+ <email_template>Sendinblue_Sendinblue_Model_Email_Template</email_template>
220
+ </rewrite>
221
+ </core>
222
+ <sendinblue>
223
+ <class>Sendinblue_Sendinblue_Model</class>
224
+ <resourceModel>sendinblue_mysql4</resourceModel>
225
+ </sendinblue>
226
+ <sendinblue_mysql4>
227
+ <class>Sendinblue_Sendinblue_Model_Mysql4</class>
228
+ <entities>
229
+ <sendinblue>
230
+ <table>sendinblue_country_codes</table>
231
+ </sendinblue>
232
+ </entities>
233
+ </sendinblue_mysql4>
234
+ </models>
235
+ <resources>
236
+ <sendinblue_setup>
237
+ <setup>
238
+ <module>Sendinblue_Sendinblue</module>
239
+ </setup>
240
+ <connection>
241
+ <use>core_setup</use>
242
+ </connection>
243
+ </sendinblue_setup>
244
+ <sendinblue_write>
245
+ <connection>
246
+ <use>core_write</use>
247
+ </connection>
248
+ </sendinblue_write>
249
+ <sendinblue_read>
250
+ <connection>
251
+ <use>core_read</use>
252
+ </connection>
253
+ </sendinblue_read>
254
+ </resources>
255
+
256
+ <helpers>
257
+ <sendinblue>
258
+ <class>Sendinblue_Sendinblue_Helper</class>
259
+ </sendinblue>
260
+ </helpers>
261
+ <blocks>
262
+ <sendinblue>
263
+ <class>Sendinblue_Sendinblue_Block</class>
264
+ </sendinblue>
265
+ </blocks>
266
+
267
+ </global>
268
+ <crontab>
269
+ <jobs>
270
+ <sendinblue_sendinblue>
271
+ <schedule>
272
+ <cron_expr>*/5 * * * *</cron_expr>
273
+ </schedule>
274
+ <run>
275
+ <model>sendinblue/observer::syncData</model>
276
+ </run>
277
+ </sendinblue_sendinblue>
278
+ </jobs>
279
+ </crontab>
280
+ <default>
281
+ <sendinblue>
282
+ <general>
283
+ <enabled>0</enabled>
284
+ <test>0</test>
285
+ <test_address />
286
+ </general>
287
+ <smtp>
288
+ <host>sendinblue.fr</host>
289
+ <port />
290
+ <login />
291
+ <password />
292
+ <ssl />
293
+ </smtp>
294
+ </sendinblue>
295
+ </default>
296
+ <frontend>
297
+ <events>
298
+ <!--use when new subcriber add for newsletter-->
299
+ <controller_action_postdispatch_newsletter_subscriber_new>
300
+ <observers>
301
+ <sendinblue_subscribe_new_observer>
302
+ <type>singleton</type>
303
+ <class>Sendinblue_Sendinblue_Model_Observer</class>
304
+ <method>subscribeObserver</method>
305
+ </sendinblue_subscribe_new_observer>
306
+ </observers>
307
+ </controller_action_postdispatch_newsletter_subscriber_new>
308
+
309
+ <!--use when new user register check (is_subscribed = 1)-->
310
+ </events>
311
+
312
+ <layout>
313
+ <updates>
314
+ <sendinblue_sendinblue>
315
+ <file>sendinblue.xml</file>
316
+ </sendinblue_sendinblue>
317
+ </updates>
318
+ </layout>
319
+
320
+ </frontend>
321
+ </config>
 
 
 
 
app/code/{local/Sendinblue/Sendinblue/sql/sendinblue_setup/install-0.1.0.php → community/Sendinblue/Sendinblue/sql/sendinblue_setup/mysql4-install-0.1.0.php} RENAMED
File without changes
app/code/community/Sendinblue/Sendinblue/sql/sendinblue_setup/mysql4-upgrade-0.1.0-0.2.0.php ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @author Sendinblue plateform <contact@sendinblue.com>
4
+ * @copyright 2013-2014 Sendinblue
5
+ * URL: https:www.sendinblue.com
6
+ * Do not edit or add to this file if you wish to upgrade Sendinblue Magento plugin to newer
7
+ * versions in the future. If you wish to customize Sendinblue magento plugin for your
8
+ * needs then we can't provide a technical support.
9
+ **/
10
+
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
+ //die();
13
+
14
+ ?>
app/code/local/Sendinblue/Sendinblue/Block/Sendinblue.php DELETED
@@ -1,90 +0,0 @@
1
- <?php
2
- /**
3
- * @author Sendinblue plateform <contact@sendinblue.com>
4
- * @copyright 2013-2014 Sendinblue
5
- * URL: https:www.sendinblue.com
6
- * Do not edit or add to this file if you wish to upgrade Sendinblue Magento plugin to newer
7
- * versions in the future. If you wish to customize Sendinblue magento plugin for your
8
- * needs then we can't provide a technical support.
9
- **/
10
-
11
- class Sendinblue_Sendinblue_Block_Sendinblue extends Mage_Core_Block_Template
12
- {
13
- public function _prepareLayout()
14
- {
15
- return parent::_prepareLayout();
16
- }
17
- public function getPagerHtml()
18
- {
19
- return $this->getChildHtml('pager');
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
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/local/Sendinblue/Sendinblue/Model/Observer.php DELETED
@@ -1,260 +0,0 @@
1
- <?php
2
- /**
3
- * @author Sendinblue plateform <contact@sendinblue.com>
4
- * @copyright 2013-2014 Sendinblue
5
- * URL: https:www.sendinblue.com
6
- * Do not edit or add to this file if you wish to upgrade Sendinblue Magento plugin to newer
7
- * versions in the future. If you wish to customize Sendinblue magento plugin for your
8
- * needs then we can't provide a technical support.
9
- **/
10
- class Sendinblue_Sendinblue_Model_Observer
11
- {
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);
26
- }
27
- if ($responce->result)
28
- Mage::getSingleton('core/session')->addSuccess('Total of '.$responce->result->unsubEmailsCounts.' record(s) were Unsubscribed');
29
- return $this;
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);
44
- }
45
- if ($responce->result)
46
- Mage::getSingleton('core/session')->addSuccess('Total of '.$responce->result->unsubEmailsCounts.' record(s) were Unsubscribed');
47
- return $this;
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);
62
- }
63
- if ($responce->result)
64
- Mage::getSingleton('core/session')->addSuccess('Total of '.$responce->result->infoUpdatedCount.' record(s) were subscribed');
65
- return $this;
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
- {
137
- $responce = Mage::getModel('sendinblue/sendinblue')->syncData();
138
- return $this;
139
- }
140
- public function updateStatus($observer)
141
- {
142
- $order = $observer->getEvent()->getOrder();
143
-
144
- if ($order->getState() == Mage_Sales_Model_Order::STATE_PROCESSING)
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
- {
251
- $action = $observer->getEvent()->getControllerAction();
252
-
253
- if ($action instanceof Sendinblue_Sendinblue_Adminhtml_MyformController) { // eg. Mage_Catalog_ProductController
254
- $request = $action->getRequest();
255
- $cache = Mage::app()->getCacheInstance();
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
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/local/Sendinblue/Sendinblue/Model/Sendinblue.php DELETED
@@ -1,1072 +0,0 @@
1
- <?php
2
- /**
3
- * @author Sendinblue plateform <contact@sendinblue.com>
4
- * @copyright 2013-2014 Sendinblue
5
- * URL: https:www.sendinblue.com
6
- * Do not edit or add to this file if you wish to upgrade Sendinblue Magento plugin to newer
7
- * versions in the future. If you wish to customize Sendinblue magento plugin for your
8
- * needs then we can't provide a technical support.
9
- **/
10
- class Sendinblue_Sendinblue_Model_Sendinblue extends Mage_Core_Model_Abstract
11
- {
12
- var $api_url;
13
- var $api_key;
14
- var $smtp_status;
15
- var $error_message;
16
- var $error_code;
17
- var $lists_ids;
18
- var $module_enable;
19
- var $st;
20
- public function _construct()
21
- {
22
- parent::_construct();
23
- $this->_init('sendinblue/sendinblue');
24
- $this->MIAPI();
25
- }
26
- /**
27
- * functions used for set module config
28
- */
29
- public function MIAPI()
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
57
- */
58
- public function getEnableStatus()
59
- {
60
- $status = $this->getGeneralConfig('enabled', Mage::app()->getStore()->getStoreId());
61
- if (!$status)
62
- return false;
63
- return $status;
64
- }
65
- /**
66
- * functions used for send order sms module status
67
- */
68
- public function getOrderSmsStatus()
69
- {
70
- $status = $this->getGeneralConfig('sms/order', Mage::app()->getStore()->getStoreId());
71
- if (!$status)
72
- return false;
73
- return $status;
74
- }
75
- /**
76
- * functions used for getting notify sms status
77
- */
78
- public function getNotifySmsStatus()
79
- {
80
- $status = $this->getGeneralConfig('sms/credit', Mage::app()->getStore()->getStoreId());
81
- if (!$status)
82
- return false;
83
- return $status;
84
- }
85
- /**
86
- * functions used for getting Notify value limit
87
- */
88
- public function getNotifyValueStatus()
89
- {
90
- $status = $this->getGeneralConfig('Sendin_Notify_Value', Mage::app()->getStore()->getStoreId());
91
- if (!$status)
92
- return false;
93
- return $status;
94
- }
95
- /**
96
- * functions used for getting Notify email limit
97
- */
98
- public function getNotifyEmailStatus()
99
- {
100
- $status = $this->getGeneralConfig('Sendin_Notify_Email', Mage::app()->getStore()->getStoreId());
101
- if (!$status)
102
- return false;
103
- return $status;
104
- }
105
- /**
106
- * functions used for getting Notify email limit
107
- */
108
- public function getNotifyCronStatus()
109
- {
110
- $status = $this->getGeneralConfig('Sendin_Notify_Cron_Executed', Mage::app()->getStore()->getStoreId());
111
- if (!$status)
112
- return false;
113
- return $status;
114
- }
115
- /**
116
- * functions used for getting shiping sms status
117
- */
118
- public function getShipingSmsStatus()
119
- {
120
- $status = $this->getGeneralConfig('sms/shiping', Mage::app()->getStore()->getStoreId());
121
- if (!$status)
122
- return false;
123
- return $status;
124
- }
125
- /**
126
- * functions used for getting campaign sms status
127
- */
128
- public function getCampaignStatus()
129
- {
130
- $status = $this->getGeneralConfig('sms/campaign', Mage::app()->getStore()->getStoreId());
131
- if (!$status)
132
- return false;
133
- return $status;
134
- }
135
- /**
136
- * functions used for getting send sms order subject
137
- */
138
- public function getSendSmsOrderSubject()
139
- {
140
- $status = $this->getGeneralConfig('Sendin_Sender_Order', Mage::app()->getStore()->getStoreId());
141
- if (!$status)
142
- return false;
143
- return $status;
144
- }
145
- /**
146
- * functions used for getting order sms message
147
- */
148
- public function getSendSmsmOrderMessage()
149
- {
150
- $status = $this->getGeneralConfig('Sendin_Sender_Order_Message', Mage::app()->getStore()->getStoreId());
151
- if (!$status)
152
- return false;
153
- return $status;
154
- }
155
- /**
156
- *functions used for getting send sms shiping subject
157
- */
158
- public function getSendSmsShipingSubject()
159
- {
160
- $status = $this->getGeneralConfig('Sendin_Sender_Shipment', Mage::app()->getStore()->getStoreId());
161
- if (!$status)
162
- return false;
163
- return $status;
164
- }
165
- /**
166
- *functions used for getting shiping sms message
167
- */
168
- public function getSendSmsShipingMessage()
169
- {
170
- $status = $this->getGeneralConfig('Sendin_Sender_Shipment_Message', Mage::app()->getStore()->getStoreId());
171
- if (!$status)
172
- return false;
173
- return $status;
174
- }
175
- /**
176
- * functions used for get api key
177
- */
178
- public function getApiKey()
179
- {
180
- $apikey = $this->getGeneralConfig('api', Mage::app()->getStore()->getStoreId());
181
- if (!$apikey)
182
- return false;
183
- return $apikey;
184
- }
185
- /**
186
- * functions used for getting smtp status
187
- */
188
- public function getSmtpStatus()
189
- {
190
- $status = $this->getSendinSmtpStatus('status', Mage::app()->getStore()->getStoreId());
191
- if (!$status)
192
- return false;
193
- return $status;
194
- }
195
- /**
196
- * functions used for getting tracking status
197
- */
198
- public function getTrackingStatus()
199
- {
200
- $status = $this->getSendinTrackingCodeStatus('code', Mage::app()->getStore()->getStoreId());
201
- if (!$status) {
202
- return false;
203
- }
204
- return $status;
205
- }
206
- /**
207
- * functions used for getting userlists
208
- */
209
- public function getUserlists()
210
- {
211
- $userlist = $this->getGeneralConfig('list', Mage::app()->getStore()->getStoreId());
212
- if (!$userlist)
213
- return false;
214
- return $userlist;
215
- }
216
- /**
217
- * functions used for getting general config
218
- */
219
- public function getGeneralConfig($field, $store = null)
220
- {
221
- return Mage::getStoreConfig('sendinblue/'.$field, $store);
222
- }
223
- /**
224
- * functions used for get sendinsmtp status
225
- */
226
- public function getSendinSmtpStatus($field, $store = null)
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
- }
234
- /**
235
- * functions used for get sendin tracking status
236
- */
237
- public function getSendinTrackingCodeStatus($field, $store = null)
238
- {
239
- return Mage::getStoreConfig('sendinblue/tracking/'.$field, $store);
240
- }
241
- /**
242
- * functions used for module functionality
243
- */
244
- public function getLists()
245
- {
246
- return $this->lists();
247
- }
248
- /**
249
- * functions used for email adds
250
- */
251
- public function emailAdd($email, $extra)
252
- {
253
- if ($this->module_enable == 1 && $this->getSyncronizeStatus())
254
- {
255
- $apikey = $this->api_key;
256
- if (!$apikey)
257
- return false;
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
- {
268
- $params['attributes_value'] = $email;
269
-
270
- }
271
- $params['listid'] = $this->lists_ids;
272
- return $this->callServer('USERCREADITM', $params);
273
- } else
274
- return false;
275
- }
276
- /**
277
- * functions subscribeuser
278
- */
279
- public function emailSubscribe($email)
280
- {
281
- if ($this->module_enable == 1 && $this->getSyncronizeStatus())
282
- {
283
- $apikey = $this->api_key;
284
- $timezone = Mage::app()->getStore()->getConfig('general/locale/timezone');
285
- $timez = str_replace('Calcutta', 'Kolkata', $timezone);
286
- $tm = date("Y-m-d H:i:s", Mage::getModel('core/date')->timestamp(time()));
287
-
288
- if (!$apikey)
289
- return false;
290
- $data = array();
291
- $data['key'] = $apikey;
292
- $data['webaction']='UPDATE-USER-SUBSCRIPTION-STATUS';
293
- $data['timezone'] = $timez;
294
- $data['user_status'] = $email.', '.'1'.', '.$tm;
295
- return $this->curlRequest($data);
296
- } else
297
- return false;
298
- }
299
-
300
- /**
301
- * functions used for sync data
302
- */
303
- public function syncData()
304
- {
305
- if ($this->module_enable == 1 && $this->getSyncronizeStatus())
306
- {
307
- $apikey = $this->api_key;
308
- if (!$apikey)
309
- return false;
310
- $params = array();
311
- $params['listids'] = str_replace(',', '|', $this->lists_ids);
312
- $response = $this->callServer('DISPLAYLISTDATABLACK', $params);
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'];
330
- $subscribe_data['subscriber_status'] = ($user_data->blacklisted == 1)?3:1;
331
- $costomer_data = Mage::getModel('newsletter/subscriber')->loadByEmail($data['subscriber_email']);
332
- $costomer_data->setStatus($subscribe_data['subscriber_status']);
333
- $costomer_data->setIsStatusChanged(true);
334
- $costomer_data->save();
335
- }
336
- }
337
- }
338
- }
339
- }
340
- if (count($emails) > 0)
341
- Mage::getSingleton('core/session')->addSuccess(count($emails).Mage::helper('sendinblue')->__(' Total of record(s) have been updated'));
342
- else
343
- Mage::getSingleton('core/session')->addSuccess(count($emails).Mage::helper('sendinblue')->__(' Total of record(s) have been updated'));
344
- return true;
345
- }
346
- else
347
- return false;
348
- }
349
- /**
350
- * This method is used for add email list
351
- */
352
- public function addEmailList($email)
353
- {
354
- if ($this->module_enable == 1 && $this->getSyncronizeStatus())
355
- {
356
- $apikey = $this->api_key;
357
- if (!$apikey)
358
- return false;
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;
366
- return $this->callServer('USERCREADITM', $params);
367
- } else
368
- return false;
369
- }
370
- /**
371
- * This method is used used for email unsubscribe
372
- */
373
- public function emailDelete($email)
374
- {
375
- if ($this->module_enable == 1 && $this->getSyncronizeStatus())
376
- {
377
- $apikey = $this->api_key;
378
- if (!$apikey)
379
- return false;
380
- $params = array();
381
- $params['email'] = $email;
382
- $params['listid'] = $this->lists_ids;
383
- return $this->callServer('UNSUBAPI', $params);
384
- } else
385
- return false;
386
- }
387
- /**
388
- * This method is used used for check api status
389
- */
390
- public function checkApikey($api_key)
391
- {
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
399
- */
400
- public function SmtpDetailsWithTracking()
401
- {
402
- $params['key'] = $this->api_key;
403
- $response = $this->callServer('TRACKINGDATA', $params);
404
- if (isset($response->errorMsg) && !empty($response->errorMsg))
405
- {
406
- $tracking['error'] = $response->errorMsg;
407
- return $tracking;
408
- }
409
- return $response;
410
- }
411
- /**
412
- * Fetches all the list of the user from the Sendinblue platform.
413
- */
414
- public function lists($filters = array())
415
- {
416
- $params = array();
417
- $response = $this->callServer('DISPLAYLISTDATA', $params);
418
- if (isset($response->errorMsg) && !empty($response->errorMsg))
419
- {
420
- $this->error_message = $response->errorMsg;
421
- $lists['error'] = $response->errorMsg;
422
- } else
423
- {
424
- $i = 0;
425
- $lists = array();
426
- foreach ($response->result as $list_data)
427
- {
428
- $lists[$i]['id'] = $list_data->id;
429
- $lists[$i]['name'] = $list_data->name;
430
- $i++;
431
- }
432
- }
433
- return $lists;
434
- }
435
- /**
436
- * Fetches the list status of the user from the Sendinblue platform.
437
- */
438
- public function getUserListStats()
439
- {
440
- if ($this->module_enable == 1)
441
- {
442
- $params = array();
443
- $params['list'] = 'ALL';
444
- return $this->callServer('DISPLAYLISTDATA', $params);
445
- } else
446
- return Mage::getSingleton('core/session')->addError('Sendinblue not enabled');
447
- }
448
- /**
449
- * Fetches all folders and all list within each folder of the user's Sendinblue
450
- * account and displays them to the user.
451
- */
452
- public function checkFolderList()
453
- {
454
- $params = array();
455
- $array = array();
456
- $list_response = $this->callServer('DISPLAY-FOLDERS-LISTS', $params);
457
- $list_response = json_encode($list_response);
458
- $res = json_decode($list_response, true);
459
- if (isset($res) && !empty($res))
460
- {
461
- foreach ($res as $key => $value)
462
- {
463
- if (strtolower($value['name']) == 'magento')
464
- {
465
- $array[] = $key;
466
- $array[] = $value['name'];
467
- }
468
- if (!empty($value['lists']))
469
- {
470
- foreach ($value['lists'] as $val)
471
- {
472
- if (strtolower($val['name']) == 'magento')
473
- $array[] = $val['name'];
474
- }
475
- }
476
- }
477
- }
478
- return $array;
479
- }
480
- /**
481
- * folder create in Sendinblue after removing from Sendinblue
482
- */
483
- public function createFolderCaseTwo()
484
- {
485
- $apikey = $this->api_key;
486
- if($apikey == '')
487
- return false;
488
- $response = $this->checkApikey($apikey); // check api key is valid or not
489
- if ($this->module_enable != 1 && $apikey == '' && $response['error'] != '' && $this->getSyncronizeStatus())
490
- return false;
491
- $result = $this->checkFolderList();
492
- $list_name = 'magento';
493
- $param = array();
494
- $data = array();
495
- $folder_id = $result[0];
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
532
- */
533
- public function createFolderName($api_key)
534
- {
535
- $this->api_key = $api_key;
536
- $this->createAttributesName();
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
- {
547
- $folder_id = $result[0];
548
- $exist_list = $result[2];
549
- }
550
- $this->createNewList($folder_id, $exist_list);
551
- $this->partnerMagento();
552
- }
553
- /**
554
- * Method is used to add the partner's name in Sendinblue.
555
- * In this case its "MAGENTO".
556
- */
557
- public function partnerMagento()
558
- {
559
- $params = array();
560
- $params['partner'] = 'MAGENTO';
561
- $this->callServer('MAILIN-PARTNER', $params);
562
- }
563
- /**
564
- * Creates a list by the name "magento" on user's Sendinblue account.
565
- */
566
- public function createNewList($response, $exist_list)
567
- {
568
- if ($exist_list != '')
569
- {
570
- $date = date('dmY');
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;
578
- $list_response = $this->callServer('NEWLIST', $params);
579
- $this->sendAllMailIDToSendin($list_response);
580
- $this->createAttributesName();
581
- }
582
- /**
583
- * Create Normal, Transactional, Calculated and Global attributes and their values
584
- * on Sendinblue platform. This is necessary for the Prestashop to add subscriber's details.
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();
615
- $params['key'] = $this->api_key;
616
- $params['to'] = $array['to'];
617
- $params['from'] = $array['from'];
618
- $params['text'] = $array['text'];
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')
648
- {
649
- $email_template_variables['text0'] = ' [SendinBlue] Alerte: Vos crédits SMS seront bientôt épuisés';
650
- $sender_name = 'SendinBlue';
651
- $sender_email = 'contact@sendinblue.com';
652
- }
653
- else
654
- {
655
- $email_template_variables['text0'] = '[SendinBlue] Alert: You do not have enough credits SMS';
656
- $sender_name = 'SendinBlue';
657
- $sender_email = 'contact@sendinblue.com';
658
- }
659
- $email = $this->getNotifyEmailStatus();
660
-
661
- $email_template = Mage::getModel('core/email_template')->loadDefault('notification_template');
662
- $temp=$email_template->template_text;
663
- $web_site = Mage::app()->getWebsite()->getName();
664
- $credit = $this->getSmsCredit();
665
- preg_match_all('#{(.*)}#', $temp, $match);
666
-
667
- $temp_params = array(
668
- '{site_name}'=>$web_site,
669
- '{present_credit}'=>$credit
670
-
671
- );
672
- foreach($match[0] as $var=>$value){
673
- $temp = preg_replace('#'.$value.'#',$temp_params[$value],$temp);
674
- }
675
- $email_template->template_text = $temp;
676
- $email_template->getProcessedTemplate($email_template_variables);
677
- $email_template->setSenderName($sender_name);
678
- $email_template->setSenderEmail($sender_email);
679
- $email_template->setTemplateSubject($email_template_variables['text0']);
680
- return $email_template->send($email, '', $email_template_variables);
681
-
682
- }
683
-
684
-
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'));
692
- }
693
- /**
694
- * show SMS credit from Sendinblue.
695
- */
696
- public function getSmsCredit()
697
- {
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.
706
- */
707
- public function sendTestMail($email)
708
- {
709
- $locale = Mage::app()->getLocale()->getLocaleCode();
710
- $email_template_variables = array();
711
- if ($locale == 'fr_FR')
712
- {
713
- $email_template_variables['text0'] = '[SendinBlue SMTP] e-mail de test';
714
- $sender_name = 'SendinBlue';
715
- $sender_email = 'contact@sendinblue.com';
716
- }
717
- else
718
- {
719
- $email_template_variables['text0'] = '[SendinBlue SMTP] test email';
720
- $sender_name = 'SendinBlue';
721
- $sender_email = 'contact@sendinblue.com';
722
- }
723
- try {
724
- $email_template = Mage::getModel('core/email_template')->loadDefault('custom_template');
725
- $email_template->getProcessedTemplate($email_template_variables);
726
- $email_template->setSenderName($sender_name);
727
- $email_template->setSenderEmail($sender_email);
728
- $email_template->setTemplateSubject($email_template_variables['text0']);
729
- return $email_template->send($email, '', $email_template_variables);
730
- }
731
- catch(Exception $e) {
732
-
733
- }
734
- }
735
-
736
- /**
737
- * This method is used to fetch all users from the default customer table to list
738
- * them in the Sendinblue magento module.
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
801
- * them in the Sendinblue magento module.
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
828
- );
829
- }
830
-
831
- $newsletterArr = array();
832
- $newsletter = Mage::getResourceModel('newsletter/subscriber_collection')->load();
833
-
834
- $cnt = 0;
835
- foreach ( $newsletter->getItems() as $subscriber )
836
- {
837
- $customer_id = $subscriber->getCustomerId();;
838
- $subscriber_email = $subscriber->getSubscriberEmail();
839
- $subscriber_status = $subscriber->getSubscriberStatus();
840
-
841
- if ( !empty($customer_select[$subscriber_email]) ) {
842
- $newsletterArr[$cnt] = $customer_select[$subscriber_email];
843
- $newsletterArr[$cnt]['subscriber_status'] = $subscriber_status;
844
- unset($customer_select[$subscriber_email]);
845
- }
846
- else {
847
- $newsletterArr[$cnt] = array(
848
- 'email' => $subscriber_email,
849
- 'firstname' => '',
850
- 'lastname' => '',
851
- 'telephone' => '',
852
- 'country_id' => ''
853
- );
854
- $newsletterArr[$cnt]['customer_id'] = $customer_id;
855
- $newsletterArr[$cnt]['subscriber_status'] = $subscriber_status;
856
- }
857
- $cnt++;
858
- }
859
-
860
- if ( count($customer_select) > 0 ) {
861
- foreach ( $customer_select as $cData ) {
862
- $newsletterArr[$cnt] = $cData;
863
- $newsletterArr[$cnt]['subscriber_status'] = 3;
864
- $cnt++;
865
- }
866
- }
867
-
868
- return array_slice($newsletterArr, $start, $per_page, true);
869
- }
870
- /**
871
- * This method is used to fetch total count users from the default newsletter table to list
872
- * them in the Sendinblue magento module.
873
- */
874
- public function getTotalCount()
875
- {
876
- $collection = Mage::getModel('customer/customer')->getCollection()->addAttributeToSelect('email')->addAttributeToSelect('firstname')->addAttributeToSelect('lastname');
877
- foreach ($collection as $customer)
878
- {
879
-
880
- $email = $customer->getData('email');
881
- $firstname = $customer->getData('firstname');
882
- $lastname = $customer->getData('lastname');
883
- $cid = $customer->getData('entity_id');
884
-
885
- $collectionAddress = Mage::getModel('customer/address')->getCollection()->addAttributeToSelect('telephone')->addAttributeToSelect('country_id')->addAttributeToFilter('parent_id',(int)$cid);
886
- $telephone = '';
887
- foreach ($collectionAddress as $customerPhno) {
888
- $telephone = $customerPhno->getData('telephone');
889
- $country_id = $customerPhno->getData('country_id');
890
- }
891
-
892
- $customer_select[$email] = array(
893
- 'email' => $email,
894
- 'firstname' => $firstname,
895
- 'lastname' => $lastname,
896
- 'telephone' => $telephone,
897
- 'country_id' => $country_id,
898
- 'customer_id' => $cid
899
- );
900
- }
901
-
902
- $newsletterArr = array();
903
- $newsletter = Mage::getResourceModel('newsletter/subscriber_collection')->load();
904
-
905
- $cnt = 0;
906
- foreach ( $newsletter->getItems() as $subscriber )
907
- {
908
- $customer_id = $subscriber->getCustomerId();;
909
- $subscriber_email = $subscriber->getSubscriberEmail();
910
- $subscriber_status = $subscriber->getSubscriberStatus();
911
-
912
- if ( !empty($customer_select[$subscriber_email]) ) {
913
- $newsletterArr[$cnt] = $customer_select[$subscriber_email];
914
- $newsletterArr[$cnt]['subscriber_status'] = $subscriber_status;
915
- unset($customer_select[$subscriber_email]);
916
- }
917
- else {
918
- $newsletterArr[$cnt] = array(
919
- 'email' => $subscriber_email,
920
- 'firstname' => '',
921
- 'lastname' => '',
922
- 'telephone' => '',
923
- 'country_id' => ''
924
- );
925
- $newsletterArr[$cnt]['customer_id'] = $customer_id;
926
- $newsletterArr[$cnt]['subscriber_status'] = $subscriber_status;
927
- }
928
- $cnt++;
929
- }
930
-
931
- if ( count($customer_select) > 0 ) {
932
- foreach ( $customer_select as $cData ) {
933
- $newsletterArr[$cnt] = $cData;
934
- $newsletterArr[$cnt]['subscriber_status'] = 3;
935
- $cnt++;
936
- }
937
- }
938
-
939
- return count($newsletterArr);
940
- }
941
- /**
942
- * This method is used to fetch total count unsubscribe users from the default newsletter table to list
943
- * them in the Sendinblue magento module.
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
-
956
- }
957
- /**
958
- * This method is used to fetch total count subscribe users from the default newsletter table to list
959
- * them in the Sendinblue magento module.
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
- }
967
- /**
968
- * This method is used to check the subscriber's newsletter subscription status in Sendinblue
969
- */
970
- public function checkUserSendinStatus($result)
971
- {
972
- $userstatus = array();
973
- foreach ($result as $subscriber)
974
- $userstatus[] = $subscriber['email'];
975
- $email = implode(',', $userstatus);
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
- }
983
- /**
984
- * Fetches the SMTP and order tracking details
985
- */
986
- public function TrackingSmtp()
987
- {
988
- $params = array();
989
- $params['key'] = $this->api_key;
990
- return $this->callServer('TRACKINGDATA', $params);
991
- }
992
- /**
993
- * CURL function to send request to the Sendinblue API server
994
- */
995
- public function callServer($method, $params)
996
- {
997
- $host = $this->api_url;
998
- $params['key'] = (isset($params['key']) && !empty($params['key'])) ? $params['key'] : $this->api_key;
999
- $params['webaction'] = $method;
1000
- $this->error_message = '';
1001
- $this->error_code = '';
1002
- $response = $this->curlRequest($params);
1003
- return json_decode($response);
1004
- }
1005
- /**
1006
- * CURL function to send request to the Sendinblue API server
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)
1021
- $ndata .= $key.'='.urlencode($value).'&';
1022
- } else
1023
- $ndata = $data;
1024
- curl_setopt($ch, CURLOPT_HTTPHEADER, array(
1025
- 'Expect:'
1026
- ));
1027
-
1028
- $ndata = trim($ndata,'&');
1029
- curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
1030
- curl_setopt($ch, CURLOPT_POST, 1);
1031
- curl_setopt($ch, CURLOPT_POSTFIELDS, $ndata);
1032
- curl_setopt($ch, CURLOPT_HEADER, 0);
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
-
1040
- public function removeOldEntry()
1041
- {
1042
- $sendin_switch = new Mage_Core_Model_Config();
1043
- $sendin_switch->saveConfig('sendinblue/smtp/status', '');
1044
- $sendin_switch->saveConfig('sendinblue/smtp/authentication', '');
1045
- $sendin_switch->saveConfig('sendinblue/smtp/username', '');
1046
- $sendin_switch->saveConfig('sendinblue/smtp/password', '');
1047
- $sendin_switch->saveConfig('sendinblue/smtp/host', '');
1048
- $sendin_switch->saveConfig('sendinblue/smtp/port', '');
1049
- $sendin_switch->saveConfig('sendinblue/smtp/ssl', '');
1050
- $sendin_switch->saveConfig('sendinblue/smtp/option', '');
1051
- $sendin_switch->saveConfig('sendinblue/tracking/code', '');
1052
- }
1053
- protected function _uninstallResourceDb($version)
1054
- {
1055
- Mage::dispatchEvent('module_uninstall', array('resource' => $this->_resourceName));
1056
-
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
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/local/Sendinblue/Sendinblue/controllers/Adminhtml/MyformController.php DELETED
@@ -1,520 +0,0 @@
1
- <?php
2
- /**
3
- * @author Sendinblue plateform <contact@sendinblue.com>
4
- * @copyright 2013-2014 Sendinblue
5
- * URL: https:www.sendinblue.com
6
- * Do not edit or add to this file if you wish to upgrade Sendinblue Magento plugin to newer
7
- * versions in the future. If you wish to customize Sendinblue magento plugin for your
8
- * needs then we can't provide a technical support.
9
- **/
10
-
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
- {
22
- $post = $this->getRequest()->getPost();
23
- try {
24
- if (empty($post))
25
- Mage::throwException($this->__('Invalid form data.'));
26
- $sendin_switch = new Mage_Core_Model_Config();
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']);
33
- $sendin_switch->saveConfig('sendinblue/list', $list);
34
- $message = $this->__('Your setting has been successfully saved');
35
- Mage::getSingleton('adminhtml/session')->addSuccess($message);
36
- } else
37
- {
38
- $message = $this->__('Please select a list');
39
- Mage::getSingleton('adminhtml/session')->addError($message);
40
- }
41
- }
42
- }
43
- catch (Exception $e)
44
- {
45
- Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
46
- }
47
- $this->_redirect('*/*');
48
- }
49
- public function apikeypostAction()
50
- {
51
- $post = $this->getRequest()->getPost();
52
- try {
53
- if (empty($post))
54
- Mage::throwException($this->__('Invalid form data.'));
55
- elseif (isset($post['sendin_apikey']) && !empty($post['sendin_apikey']))
56
- {
57
- $sendin_switch = new Mage_Core_Model_Config();
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']);
65
- elseif ($get_key != $post['sendin_apikey'])
66
- Mage::getModel('sendinblue/sendinblue')->createFolderName($post['sendin_apikey']);
67
-
68
- $sendin_switch->saveConfig('sendinblue/api', trim($post['sendin_apikey']));
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');
77
- Mage::getSingleton('core/session')->addError($message);
78
- }
79
- }
80
- }
81
- catch (Exception $e)
82
- {
83
- Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
84
- }
85
- $this->_redirect('*/*');
86
- }
87
- public function sendmailAction()
88
- {
89
- $post = $this->getRequest()->getPost();
90
-
91
- try {
92
- if (empty($post))
93
- Mage::throwException($this->__('Invalid form data.'));
94
- elseif (isset($post['SmtpSubmit']) && !empty($post['SmtpSubmit']))
95
- {
96
- $sendin_switch = new Mage_Core_Model_Config();
97
- $get_key = Mage::getModel('sendinblue/sendinblue')->getApiKey();
98
- $result = Mage::getModel('sendinblue/sendinblue')->checkApikey($get_key);
99
- if (empty($result['error']))
100
- {
101
- $smtp_response = Mage::getModel('sendinblue/sendinblue')->TrackingSmtp(); // get tracking code
102
-
103
- if ($smtp_response->result->relay_data->status == 'enabled')
104
- {
105
- $sendin_switch->saveConfig('sendinblue/smtp/authentication', 'crammd5', 'default', 0);
106
- $sendin_switch->saveConfig('sendinblue/smtp/username', $smtp_response->result->relay_data->data->username, 'default', 0);
107
- $sendin_switch->saveConfig('sendinblue/smtp/password', $smtp_response->result->relay_data->data->password, 'default', 0);
108
- $sendin_switch->saveConfig('sendinblue/smtp/host', $smtp_response->result->relay_data->data->relay, 'default', 0);
109
- $sendin_switch->saveConfig('sendinblue/smtp/port', $smtp_response->result->relay_data->data->port, 'default', 0);
110
- $sendin_switch->saveConfig('sendinblue/smtp/ssl', 'null', 'default', 0);
111
- $sendin_switch->saveConfig('sendinblue/smtp/option', 'smtp', 'default', 0);
112
- if ($post['email'])
113
- {
114
- $data11 = Mage::getModel('sendinblue/sendinblue')->sendTestMail($post['email']);
115
- $resArr = json_decode($data11, true);
116
- if ($resArr['result'] != true) {
117
- $message = $this->__('Mail not sent').' '.$this->__(trim($resArr['error']));
118
- Mage::getSingleton('adminhtml/session')->addError($message);
119
- }
120
- else {
121
- $message = $this->__('Mail sent!');
122
- Mage::getSingleton('core/session')->addSuccess($message);
123
-
124
- }
125
-
126
- } else
127
- {
128
- $message = $this->__('Mail not sent');
129
- Mage::getSingleton('adminhtml/session')->addError($message);
130
- }
131
- }
132
- else
133
- {
134
- $sendin_switch->saveConfig('sendinblue/smtp/status', 0);
135
- $message = $this->__('Your SMTP account is not activated and therefore you can not use SendinBlue SMTP. For more informations, Please contact our support to: contact@sendinblue.com');
136
- Mage::getSingleton('adminhtml/session')->addError($message);
137
-
138
- }
139
- } elseif (isset($responce['error']))
140
- {
141
- $message = $this->__('You have entered wrong api key');
142
- Mage::getSingleton('core/session')->addError($message);
143
- }
144
- }
145
- }
146
- catch (Exception $e)
147
- {
148
- Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
149
- }
150
- $this->_redirect('*/*');
151
- }
152
- public function sendorderAction()
153
- {
154
- $post = $this->getRequest()->getPost();
155
- try
156
- {
157
- if (empty($post))
158
- Mage::throwException($this->__('Invalid form data.'));
159
- $sendin_switch = new Mage_Core_Model_Config();
160
- if (isset($post['sender_order_save']))
161
- {
162
- $sender_order = $post['sender_order'];
163
- $sender_order_message = $post['sender_order_message'];
164
-
165
- if (isset($sender_order) && $sender_order == '')
166
- {
167
- $message = $this->__('Please fill the message field');
168
- Mage::getSingleton('adminhtml/session')->addError($message);
169
- }
170
- else if ($sender_order_message == '')
171
- {
172
- $message = $this->__('Please fill the message field');
173
- Mage::getSingleton('adminhtml/session')->addError($message);
174
- }
175
- else
176
- {
177
- $sendin_switch->saveConfig('sendinblue/Sendin_Sender_Order', $sender_order);
178
- $sendin_switch->saveConfig('sendinblue/Sendin_Sender_Order_Message', $sender_order_message);
179
- $message = $this->__('Your setting has been successfully saved');
180
- Mage::getSingleton('adminhtml/session')->addSuccess($message);
181
- }
182
-
183
- }
184
- }
185
- catch (Exception $e)
186
- {
187
- Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
188
- }
189
- $this->_redirect('*/*');
190
- }
191
- public function sendshipmentAction()
192
- {
193
- $post = $this->getRequest()->getPost();
194
- try {
195
- if (empty($post))
196
- Mage::throwException($this->__('Invalid form data.'));
197
-
198
- $sendin_switch = new Mage_Core_Model_Config();
199
- if (isset($post['sender_shipment_save']))
200
- {
201
- $sender_shipment = $post['sender_shipment'];
202
- $sender_shipment_message = $post['sender_shipment_message'];
203
-
204
- if (isset($sender_shipment) && $sender_shipment == '')
205
- {
206
- $message = $this->__('Please fill the message field');
207
- Mage::getSingleton('adminhtml/session')->addError($message);
208
- }
209
- else if ($sender_shipment_message == '')
210
- {
211
- $message = $this->__('Please fill the message field');
212
- Mage::getSingleton('adminhtml/session')->addError($message);
213
- }
214
- else
215
- {
216
- $sendin_switch->saveConfig('sendinblue/Sendin_Sender_Shipment', $sender_shipment);
217
- $sendin_switch->saveConfig('sendinblue/Sendin_Sender_Shipment_Message', $sender_shipment_message);
218
- $message = $this->__('Your setting has been successfully saved');
219
- Mage::getSingleton('adminhtml/session')->addSuccess($message);
220
- }
221
-
222
- }
223
- }
224
- catch (Exception $e)
225
- {
226
- Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
227
- }
228
- $this->_redirect('*/*');
229
- }
230
-
231
- /**
232
- * This method is called when the user test Shipment Sms and hits the submit button.
233
- */
234
-
235
- public function sendordertestAction()
236
- {
237
- $post = $this->getRequest()->getPost();
238
- try {
239
- if (empty($post))
240
- Mage::throwException($this->__('Invalid form data.'));
241
-
242
- $sendin_switch = new Mage_Core_Model_Config();
243
-
244
- if (isset($post['sender_order_submit']))
245
- {
246
- $arr = array();
247
- $arr['to'] = $post['sender_order_number'];
248
- $arr['from'] = Mage::getModel('sendinblue/sendinblue')->getSendSmsOrderSubject();
249
- $arr['text'] = Mage::getModel('sendinblue/sendinblue')->getSendSmsmOrderMessage();
250
-
251
- $result = Mage::getModel('sendinblue/sendinblue')->sendSmsApi($arr);
252
-
253
- if (isset($result->status) && $result->status == 'OK')
254
- {
255
- $message = $this->__('Message has been sent successfully');
256
- Mage::getSingleton('adminhtml/session')->addSuccess($message);
257
- }
258
- else
259
- {
260
- $message = $this->__('Message has not been sent successfully');
261
- Mage::getSingleton('adminhtml/session')->addError($message);
262
- }
263
-
264
- }
265
- }
266
- catch (Exception $e)
267
- {
268
- Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
269
- }
270
- $this->_redirect('*/*');
271
- }
272
-
273
-
274
- /**
275
- * This method is called when the user test Shipment Sms and hits the submit button.
276
- */
277
-
278
- public function sendshipmenttestAction()
279
- {
280
- $post = $this->getRequest()->getPost();
281
- try {
282
- if (empty($post))
283
- Mage::throwException($this->__('Invalid form data.'));
284
-
285
- $sendin_switch = new Mage_Core_Model_Config();
286
-
287
- if (isset($post['sender_shipment_submit']))
288
- {
289
- $arr = array();
290
- $arr['to'] = $post['sender_shipment_number'];
291
- $arr['from'] = Mage::getModel('sendinblue/sendinblue')->getSendSmsShipingSubject();
292
- $arr['text'] = Mage::getModel('sendinblue/sendinblue')->getSendSmsShipingMessage();
293
-
294
- $result = Mage::getModel('sendinblue/sendinblue')->sendSmsApi($arr);
295
-
296
- if (isset($result->status) && $result->status == 'OK')
297
- {
298
- $message = $this->__('Message has been sent successfully');
299
- Mage::getSingleton('adminhtml/session')->addSuccess($message);
300
- }
301
- else
302
- {
303
- $message = $this->__('Message has not been sent successfully');
304
- Mage::getSingleton('adminhtml/session')->addError($message);
305
- }
306
-
307
- }
308
- }
309
- catch (Exception $e)
310
- {
311
- Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
312
- }
313
- $this->_redirect('*/*');
314
- }
315
-
316
- public function sendnotifysmsAction()
317
- {
318
- $post = $this->getRequest()->getPost();
319
- try {
320
- if (empty($post))
321
- Mage::throwException($this->__('Invalid form data.'));
322
-
323
- $sendin_switch = new Mage_Core_Model_Config();
324
-
325
- if (isset($post['notify_sms_mail']))
326
- {
327
- $sendin_switch->saveConfig('sendinblue/Sendin_Notify_Value', $post['sendin_notify_value']);
328
- $sendin_switch->saveConfig('sendinblue/Sendin_Notify_Email', $post['sendin_notify_email']);
329
- $message = $this->__('Your setting has been successfully saved');
330
- Mage::getSingleton('adminhtml/session')->addSuccess($message);
331
- }
332
- }
333
- catch (Exception $e)
334
- {
335
- Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
336
- }
337
- $this->_redirect('*/*');
338
-
339
- }
340
-
341
-
342
- public function sendcampaignAction()
343
- {
344
- $post = $this->getRequest()->getPost();
345
- try {
346
- if (empty($post))
347
- Mage::throwException($this->__('Invalid form data.'));
348
-
349
- $sendin_switch = new Mage_Core_Model_Config();
350
-
351
- if (isset($post['sender_campaign_save']) && $post['Sendin_Sms_Choice'] == 1)
352
- {
353
- $arr = array();
354
- $arr['to'] = $post['singlechoice'];
355
- $arr['from'] = $post['sender_campaign'];
356
- $arr['text'] = $post['sender_campaign_message'];
357
-
358
- $result = Mage::getModel('sendinblue/sendinblue')->sendSmsApi($arr);
359
- if (isset($result->status) && $result->status == 'OK')
360
- {
361
- $message = $this->__('Message has been sent successfully');
362
- Mage::getSingleton('adminhtml/session')->addSuccess($message);
363
- }
364
- else
365
- {
366
- $message = $this->__('Message has not been sent successfully');
367
- Mage::getSingleton('adminhtml/session')->addError($message);
368
- }
369
-
370
-
371
- }else if(isset($post['sender_campaign_save']) && $post['Sendin_Sms_Choice'] == 0)
372
- {
373
- $smscredit = Mage::getModel('sendinblue/sendinblue')->getSmsCredit();
374
- $collection = Mage::getModel('customer/customer')
375
- ->getCollection()
376
- ->addAttributeToSelect('*')
377
- ->joinAttribute('shipping_telephone', 'customer_address/telephone', 'default_shipping', null, 'left')
378
- ->joinAttribute('shipping_country_code', 'customer_address/country_id', 'default_shipping', null, 'left');
379
-
380
- $results = array();
381
- foreach ($collection as $customer) {
382
- $results[] = $customer->toArray();
383
- }
384
-
385
- //$count = count($result);
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
- }
406
- }
407
- if ($smscredit >= 1)
408
- {
409
- $message = $this->__('Message has been sent successfully');
410
- Mage::getSingleton('adminhtml/session')->addSuccess($message);
411
- }
412
- else
413
- {
414
- $message = $this->__('Message has not been sent successfully');
415
- Mage::getSingleton('adminhtml/session')->addError($message);
416
- }
417
-
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
- }
513
- catch (Exception $e)
514
- {
515
- Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
516
- }
517
- $this->_redirect('*/*');
518
- }
519
-
520
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/local/Sendinblue/Sendinblue/controllers/AjaxController.php DELETED
@@ -1,473 +0,0 @@
1
- <?php
2
- /**
3
- * @author Sendinblue plateform <contact@sendinblue.com>
4
- * @copyright 2013-2014 Sendinblue
5
- * URL: https:www.sendinblue.com
6
- * Do not edit or add to this file if you wish to upgrade Sendinblue Magento plugin to newer
7
- * versions in the future. If you wish to customize Sendinblue magento plugin for your
8
- * needs then we can't provide a technical support.
9
- **/
10
-
11
- class Sendinblue_Sendinblue_AjaxController extends Mage_Core_Controller_Front_Action
12
- {
13
- public function indexAction()
14
- {
15
- $this->loadLayout();
16
- $this->renderLayout();
17
- Mage::getModel('sendinblue/sendinblue')->createFolderCaseTwo();
18
- }
19
-
20
- public function campaignAction()
21
- {
22
- $post = $this->getRequest()->getPost();
23
- try {
24
- if (empty($post))
25
- echo Mage::throwException($this->__('Invalid form data.'));
26
- $sendin_switch = new Mage_Core_Model_Config();
27
- $sendin_switch->saveConfig('sendinblue/sms/campaign', $post['campaignSetting']);
28
- echo $this->__('Your setting has been successfully saved');
29
- }
30
- catch (Exception $e)
31
- {
32
- echo $this->__($e->getMessage());
33
- }
34
- }
35
- public function orderAction()
36
- {
37
- $post = $this->getRequest()->getPost();
38
- try {
39
- if (empty($post))
40
- Mage::throwException($this->__('Invalid form data.'));
41
- $sendin_switch = new Mage_Core_Model_Config();
42
- $sendin_switch->saveConfig('sendinblue/sms/order', $post['orderSetting']);
43
- echo $this->__('Your setting has been successfully saved');
44
- }
45
- catch (Exception $e)
46
- {
47
- echo $this->__($e->getMessage());
48
- }
49
- }
50
- public function creditAction()
51
- {
52
- $post = $this->getRequest()->getPost();
53
- try {
54
- if (empty($post))
55
- Mage::throwException($this->__('Invalid form data.'));
56
- $sendin_switch = new Mage_Core_Model_Config();
57
- $sendin_switch->saveConfig('sendinblue/sms/credit', $post['sms_credit']);
58
- echo $this->__('Your setting has been successfully saved');
59
- }
60
- catch (Exception $e)
61
- {
62
- echo $this->__($e->getMessage());
63
- }
64
- }
65
- public function shipingAction()
66
- {
67
- $post = $this->getRequest()->getPost();
68
- try {
69
- if (empty($post))
70
- Mage::throwException($this->__('Invalid form data.'));
71
- $sendin_switch = new Mage_Core_Model_Config();
72
- $sendin_switch->saveConfig('sendinblue/sms/shiping', $post['shipingSetting']);
73
- echo $this->__('Your setting has been successfully saved');
74
- }
75
- catch (Exception $e)
76
- {
77
- echo $this->__($e->getMessage());
78
- }
79
- }
80
- public function codepostAction()
81
- {
82
- $post = $this->getRequest()->getPost();
83
- try {
84
- if (empty($post))
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
- {
97
- $post = $this->getRequest()->getPost();
98
- try {
99
- if (empty($post))
100
- Mage::throwException($this->__('Invalid form data.'));
101
- else
102
- {
103
- $sendin_switch = new Mage_Core_Model_Config();
104
- $get_key = Mage::getModel('sendinblue/sendinblue')->getApiKey();
105
- $result = Mage::getModel('sendinblue/sendinblue')->checkApikey($get_key);
106
- if (empty($result['error']))
107
- {
108
- $sendin_switch->saveConfig('sendinblue/smtp/status', $post['smtptest']);
109
- $smtp_response = Mage::getModel('sendinblue/sendinblue')->TrackingSmtp(); // get tracking code
110
- if ($smtp_response->result->relay_data->status == 'enabled')
111
- {
112
- $sendin_switch->saveConfig('sendinblue/smtp/authentication', 'crammd5', 'default', 0);
113
- $sendin_switch->saveConfig('sendinblue/smtp/username', $smtp_response->result->relay_data->data->username, 'default', 0);
114
- $sendin_switch->saveConfig('sendinblue/smtp/password', $smtp_response->result->relay_data->data->password, 'default', 0);
115
- $sendin_switch->saveConfig('sendinblue/smtp/host', $smtp_response->result->relay_data->data->relay, 'default', 0);
116
- $sendin_switch->saveConfig('sendinblue/smtp/port', $smtp_response->result->relay_data->data->port, 'default', 0);
117
- $sendin_switch->saveConfig('sendinblue/smtp/ssl', 'null', 'default', 0);
118
- $sendin_switch->saveConfig('sendinblue/smtp/option', 'smtp', 'default', 0);
119
- echo $this->__('Your setting has been successfully saved');
120
- }else
121
- {
122
- $sendin_switch->saveConfig('sendinblue/smtp/status', 0);
123
- echo $this->__('Your SMTP account is not activated and therefore you can\'t use SendinBlue SMTP. For more informations, please contact our support to: contact@sendinblue.com');
124
- }
125
- }elseif (isset($responce['error']))
126
- echo $this->__('You have entered wrong api key');
127
- }
128
- }
129
- catch (Exception $e)
130
- {
131
- echo $this->__($e->getMessage());
132
- }
133
- }
134
- public function ajaxcontentAction()
135
- {
136
- $post = $this->getRequest()->getPost();
137
- try {
138
- if (empty($post))
139
- Mage::throwException($this->__('Invalid form data.'));
140
- else
141
- {
142
- $locale = Mage::app()->getLocale()->getLocaleCode();
143
- if ($locale == 'fr_FR')
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';
150
- $next = 'Suivante';
151
- $yes = 'oui';
152
- $no = 'non';
153
- } else
154
- {
155
- $title1 = 'Unsubscribe the contact';
156
- $title2 = 'Subscribe the contact';
157
- $first = 'First';
158
- $last = 'Last';
159
- $previous = 'Previous';
160
- $next = 'Next';
161
- $yes = 'yes';
162
- $no = 'no';
163
- }
164
- $page = (int)$post['page'];
165
- $cur_page = $page;
166
- $page -= 1;
167
- $per_page = 20;
168
- $previous_btn = true;
169
- $next_btn = true;
170
- $first_btn = true;
171
- $last_btn = true;
172
- $start = $page * $per_page;
173
- $count = Mage::getModel('sendinblue/sendinblue')->getTotalCount();
174
- $no_of_paginations = ceil($count / $per_page);
175
- if ($cur_page >= 7)
176
- {
177
- $start_loop = $cur_page - 3;
178
- if ($no_of_paginations > $cur_page + 3)
179
- $end_loop = $cur_page + 3;
180
- else if ($cur_page <= $no_of_paginations && $cur_page > $no_of_paginations - 6)
181
- {
182
- $start_loop = $no_of_paginations - 6;
183
- $end_loop = $no_of_paginations;
184
- } else
185
- $end_loop = $no_of_paginations;
186
- } else
187
- {
188
- $start_loop = 1;
189
- if ($no_of_paginations > 7)
190
- $end_loop = 7;
191
- else
192
- $end_loop = $no_of_paginations;
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
- }
237
- $msg_paging = '';
238
- $msg_paging .= '<tr><td colspan="7"><div class="pagination"><ul class="pull-left">';
239
- if ($first_btn && $cur_page > 1)
240
- $msg_paging .= '<li p="1" class="active">'.$first.'</li>';
241
- else if ($first_btn)
242
- $msg_paging .= '<li p="1" class="inactive">'.$first.'</li>';
243
- if ($previous_btn && $cur_page > 1)
244
- {
245
- $pre = $cur_page - 1;
246
- $msg_paging .= '<li p="'.$pre.'" class="active">'.$previous.'</li>';
247
- } else if ($previous_btn)
248
- $msg_paging .= '<li class="inactive">'.$previous.'</li>';
249
- for ($i = $start_loop; $i <= $end_loop; $i++)
250
- {
251
- if ($cur_page == $i)
252
- $msg_paging .= '<li p="'.$i.'" style="color:#fff;background-color:#000000;" class="active">'.$i.'</li>';
253
- else
254
- $msg_paging .= '<li p="'.$i.'" class="active">'.$i.'</li>';
255
- }
256
- if ($next_btn && $cur_page < $no_of_paginations)
257
- {
258
- $nex = $cur_page + 1;
259
- $msg_paging .= '<li p="'.$nex.'" class="active">'.$next.'</li>';
260
- } else if ($next_btn)
261
- $msg_paging .= '<li class="inactive">'.$next.'</li>';
262
- if ($last_btn && $cur_page < $no_of_paginations)
263
- $msg_paging .= '<li p="'.$no_of_paginations.'" class="active">'.$last.'</li>';
264
- else if ($last_btn)
265
- $msg_paging .= '<li p="'.$no_of_paginations.'" class="inactive">'.$last.'</li>';
266
- if ($count != 0)
267
- echo $msg.$msg_paging.'</td></tr>';
268
- }
269
- }catch (Exception $e)
270
- {
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
-
355
- if (!$costomer_data->getStoreId())
356
- {
357
- $costomer_data->setSubscriberEmail($custdata['email']);
358
- $costomer_data->setCustomerId($custdata['entity_id']);
359
- $costomer_data->setStoreId($custdata['store_id']);
360
- }
361
- $costomer_data->setStatus($temp_sub_status);
362
- $costomer_data->setIsStatusChanged(true);
363
- $costomer_data->save();
364
- }
365
- }
366
- catch (Exception $e)
367
- {
368
- echo $this->__($e->getMessage());
369
- }
370
- }
371
-
372
- public function ajaxordersmsAction($sender, $message, $number)
373
- {
374
- $post = $this->getRequest()->getPost();
375
- try {
376
- if (empty($post))
377
- Mage::throwException($this->__('Invalid form data.'));
378
- $number = $post['number'];
379
- $charone = substr($number, 0, 1);
380
- $chartwo = substr($number, 0, 2);
381
- if ($charone == '0' && $chartwo == '00')
382
- $number = $number;
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
- }
399
- catch (Exception $e)
400
- {
401
- echo $this->__($e->getMessage());
402
- }
403
- }
404
-
405
- public function ajaxordershippedAction($sender,$message,$number)
406
- {
407
- $post = $this->getRequest()->getPost();
408
- try {
409
- if (empty($post))
410
- Mage::throwException($this->__('Invalid form data.'));
411
- $number = $post['number'];
412
- $charone = substr($number, 0, 1);
413
- $chartwo = substr($number, 0, 2);
414
-
415
- if ($charone == '0' && $chartwo == '00')
416
- $number = $number;
417
-
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
430
- echo 'KO';exit;
431
- }
432
-
433
- }
434
- catch (Exception $e)
435
- {
436
- echo $this->__($e->getMessage());
437
- }
438
- }
439
-
440
- public function ajaxsmscampaignAction($sender,$message,$number)
441
- {
442
- $post = $this->getRequest()->getPost();
443
- try {
444
- if (empty($post))
445
- Mage::throwException($this->__('Invalid form data.'));
446
- $number = $post['number'];
447
- $charone = substr($number, 0, 1);
448
- $chartwo = substr($number, 0, 2);
449
- if ($charone == '0' && $chartwo == '00')
450
- $number = $number;
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
463
- echo 'KO';
464
- }
465
-
466
- }
467
- catch (Exception $e)
468
- {
469
- echo $this->__($e->getMessage());
470
- }
471
- }
472
-
473
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/local/Sendinblue/Sendinblue/sql/sendinblue_setup/mysql4-upgrade-0.1.0-0.2.0.php DELETED
@@ -1,22 +0,0 @@
1
- <?php
2
- /**
3
- * @author Sendinblue plateform <contact@sendinblue.com>
4
- * @copyright 2013-2014 Sendinblue
5
- * URL: https:www.sendinblue.com
6
- * Do not edit or add to this file if you wish to upgrade Sendinblue Magento plugin to newer
7
- * versions in the future. If you wish to customize Sendinblue magento plugin for your
8
- * needs then we can't provide a technical support.
9
- **/
10
-
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
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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,24 +8,28 @@
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'); ?>";
15
  </script>
16
- <script type="text/javascript" src="<?php echo Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_SKIN);?>adminhtml/default/default/sendinblue/js/jquery-1.9.1.min.js"></script>
17
- <script type="text/javascript" src="<?php echo Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_SKIN);?>adminhtml/default/default/sendinblue/js/jquery-ui.min.js"></script>
18
- <script type="text/javascript" src="<?php echo Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_SKIN);?>adminhtml/default/default/sendinblue/js/jquery.multiselect.min.js"></script>
19
- <script type="text/javascript" src="<?php echo Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_SKIN);?>adminhtml/default/default/sendinblue/js/sendinblue.js"></script>
 
 
 
20
  <div class="entry-edit">
21
  <div class="">
22
- <img class="sendin-logo" src="<?php echo Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_SKIN);?>adminhtml/default/default/sendinblue/images/<?php echo $this->__('sendinblue.png'); ?>">
23
  <div class="slogan">
24
  <?php echo $this->__('SendinBlue : THE all-in-one plugin for your marketing and transactional emails.'); ?></div><div class="clear"></div>
25
  </div>
 
26
  <div class="sendin_row">
27
  <fieldset class="fields">
28
- <legend class="lgend"><img src="<?php echo Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_SKIN);?>adminhtml/default/default/sendinblue/images/logo.gif">
29
  <?php echo $this->__('SendinBlue'); ?></legend>
30
  <div class="contact-details">
31
  <h2 style="color:#268CCD;"> <?php echo $this->__('Contact SendinBlue team'); ?></h2>
@@ -35,7 +39,7 @@
35
  <?php echo $this->__('contact@sendinblue.com'); ?></a>
36
  <br><?php echo $this->__('Phone : 0899 25 30 61'); ?></p>
37
  <p style="padding-top:20px;"><b><?php echo $this->__('For further informations, please visit our website:'); ?></b>
38
- <br><a href="<?php echo $this->__('https://www.sendinblue.com'); ?>" target="_blank" style="color:#268CCD; text-decoration: none;">
39
  <?php echo $this->__('https://www.sendinblue.com'); ?></a></p>
40
  </div>
41
  <div><p><?php echo $this->__('With the SendinBlue plugin, you can find everything you need to easily and efficiently send your email & SMS campaigns to your prospects and customers.'); ?></p>
@@ -56,38 +60,48 @@
56
  </fieldset>
57
  </div>
58
  <?php
59
- $module_status = Mage::getModel('sendinblue/sendinblue')->getEnableStatus()?1:0;
 
 
 
60
  if ($module_status)
61
- $style = '';
62
  else
63
  $style = 'style="display:none;"';
64
- $api_key = Mage::getModel('sendinblue/sendinblue')->getApiKey();
65
- $get_syncronize = Mage::getModel('sendinblue/sendinblue')->getSyncronizeStatus();
66
 
 
 
 
 
 
 
 
 
 
67
  ?>
68
 
69
  <div class="sendin_row">
70
  <fieldset class="fields">
71
- <legend class="lgend"><img src="<?php echo Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_SKIN);?>adminhtml/default/default/sendinblue/images/logo.gif">
72
  <?php echo $this->__('Prerequisites'); ?></legend>
73
  <span><?php echo $this->__('- You should have a SendinBlue account. You can create a free account here:'); ?>
74
- <a href="<?php echo $this->__('https://www.sendinblue.com'); ?>" target="_blank" style="text-decoration: none; color: #268CCD;">
75
  &nbsp;<?php echo $this->__('https://www.sendinblue.com'); ?></a><br></span></fieldset>
76
  </div>
77
 
78
  <div class="sendin_row" >
79
  <form id="edit_formapik" name="edit_form" method="post" action="<?php echo $this->getUrl('*/*/apikeypost'); ?>">
80
- <input name="form_key" type="hidden" value="<?php echo Mage::getSingleton('core/session')->getFormKey() ?>" />
81
- <input name="skin_url" id ='skin_url' type="hidden" value="<?php echo Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_SKIN);?>" />
82
  <div class="section-config active">
83
  <fieldset class="fields">
84
- <legend class="lgend"><img src="<?php echo Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_SKIN);?>adminhtml/default/default/sendinblue/images/logo.gif"> <?php echo $this->__('Settings'); ?></legend>
85
  <table cellspacing="0" class="form-list3">
86
  <tr>
87
  <td class="fix_width2"><label><?php echo $this->__('Activate the SendinBlue module:'); ?></label></td>
88
  <td class="input-ele">
89
- <input type="radio" <?php if(Mage::getModel('sendinblue/sendinblue')->getEnableStatus()==1) { echo 'checked'; } ?> name="sendin_api_status" class="sendin_api_status radio_nospaceing" value="1" /> <?php echo $this->__('Yes'); ?>
90
- <input type="radio" name="sendin_api_status" <?php if(Mage::getModel('sendinblue/sendinblue')->getEnableStatus()==0) { echo 'checked'; } ?> class="sendin_api_status radio_spaceing2" value="0" /> <?php echo $this->__('No'); ?>
91
  <input type="hidden" name="apistatuskey" id="apistatuskey" value="<?php echo $module_status;?>">
92
  </td>
93
  </tr>
@@ -95,7 +109,7 @@ $get_syncronize = Mage::getModel('sendinblue/sendinblue')->getSyncronizeStatus()
95
  <tr <?php echo $style; ?> id="sendin_apikey">
96
  <td><label><?php echo $this->__('API Key:'); ?></label></td>
97
  <td class="input-ele">
98
- <input type="text" name="sendin_apikey" id="sendin_apikey_val" class="input-text" value="<?php echo Mage::getModel('sendinblue/sendinblue')->getApiKey(); ?>" />
99
  <span class="toolTip" title="<?php echo stripslashes($this->__('Please enter your API key from your SendinBlue account and if you don\'t have it yet, please go to www.sendinblue.com and subscribe. You can then get the API key from https://my.sendinblue.com/advanced/apikey')); ?>">&nbsp;</span>
100
  </td>
101
  </tr>
@@ -116,29 +130,30 @@ $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">
122
- <legend class="lgend"><img src="<?php echo Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_SKIN);?>adminhtml/default/default/sendinblue/images/logo.gif"> <?php echo $this->__('Activate SendinBlue to manage subscribers'); ?></legend>
123
  <table cellspacing="0" class="form-list">
124
  <tr>
125
  <td class="fix_width"><label><?php echo $this->__('Activate SendinBlue to manage subscribers'); ?></label>
126
  </td>
127
  <td class="input-ele">
128
- <input type="radio" <?php if(Mage::getModel('sendinblue/sendinblue')->getSyncronizeStatus()==1) { echo "checked"; } ?> name="syncronize" value="1" class="radio_nospaceing hdtab"/> <?php echo $this->__('Yes'); ?>
129
- <input type="radio" <?php if(Mage::getModel('sendinblue/sendinblue')->getSyncronizeStatus()==0) { echo "checked"; } ?> name="syncronize" value="0" class="radio_spaceing2 hdtab" /> <?php echo $this->__('No'); ?> <span title="<?php echo $this->__('If you activate this feature, your new contacts will be automatically added to SendinBlue or unsubscribed from SendinBlue. To synchronize the other way (SendinBlue to Magento), you should run the url (mentioned below) each day.'); ?>" class="toolTip">&nbsp;</span>
130
  </td>
131
  </tr>
132
  <tr>
133
  <td colspan="2">
134
- <div id="hidetabselect" <?php if(!Mage::getModel('sendinblue/sendinblue')->getSyncronizeStatus()) {?>style="display:none;"<?php } ?>>
135
  <table>
136
  <tr>
137
  <td><label><?php echo $this->__('Your Lists'); ?></label></td>
138
  <td class="input-ele"><?php
139
- $list = Mage::getModel('sendinblue/sendinblue')->lists();
140
 
141
- $selectedlist = Mage::getModel('sendinblue/sendinblue')->getUserlists();
142
  if($selectedlist!=NULL){
143
  $list_array = explode('|',$selectedlist);
144
  }else{
@@ -154,7 +169,112 @@ $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 +282,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,39 +306,39 @@ $get_syncronize = Mage::getModel('sendinblue/sendinblue')->getSyncronizeStatus()
173
  </table>
174
  </fieldset>
175
  </div>
176
- </form>
177
  </div>
178
  <?php
179
  }
180
- $module_status = Mage::getModel('sendinblue/sendinblue')->getSmtpStatus();
181
  if ($module_status == 0)
182
  $style_smtp = 'style="display:none;"';
183
  else
184
- $style_smtp = '';
185
 
186
  ?>
187
  <?php if ($api_key != '') { ?>
188
  <div class="sendin_row alldiv" <?php echo $style; ?> >
189
  <form id="edit_formsmtp" name="edit_form" method="post" action="<?php echo $this->getUrl('*/*/sendmail'); ?>">
190
- <input name="form_key" type="hidden" value="<?php echo Mage::getSingleton('core/session')->getFormKey() ?>" />
191
  <input name="smtpUrl" type="hidden" id="smtpUrl" value="<?php echo $this->getUrl('sendinblue/ajax/smtppost'); ?>" />
192
  <div class="section-config active">
193
  <fieldset class="fields">
194
- <legend class="lgend"><img src="<?php echo Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_SKIN);?>adminhtml/default/default/sendinblue/images/logo.gif"> <?php echo $this->__('Activate SendinBlue SMTP for your transactional emails'); ?></legend>
195
  <table cellspacing="0" class="form-list">
196
 
197
  <tr>
198
  <td class="fix_width"><label><?php echo $this->__('Activate SendinBlue SMTP for your transactional emails'); ?></label></td>
199
  <td class="input-ele">
200
- <input type="radio" class = 'smtpStatus radio_nospaceing' <?php if(Mage::getModel('sendinblue/sendinblue')->getSmtpStatus()==1) { echo 'checked'; } ?> name="smtp" value="1" /> <?php echo $this->__('Yes'); ?>
201
- <input <?php if(Mage::getModel('sendinblue/sendinblue')->getSmtpStatus()==0) { echo 'checked'; } ?> type="radio" class = 'smtpStatus radio_spaceing2' name="smtp" value="0" /> <?php echo $this->__('No'); ?><span title="<?php echo $this->__('Transactional email is an expected email because it is triggered automatically after a transaction or a specific event. Common examples of transactional email are : account opening and welcome message, order shipment confirmation, shipment tracking and purchase order status, registration via a contact form, account termination, payment confirmation, invoice etc.'); ?>" class="toolTip">&nbsp;</span>
202
  </td>
203
  <td>&nbsp;</td>
204
  </tr>
205
 
206
  <tr <?php echo $style_smtp; ?> class='smtptest'>
207
  <td class="fix_width"><label><?php echo $this->__('Send email test From / To :'); ?></label></td>
208
- <td class="input-ele"><input class="input-text" name="email" id="email" value="" size="40"/>
209
  <input type="submit" class="btn" style="margin-left:3px;" name="SmtpSubmit" onclick="return smtpvalidate('<?php echo $this->__('Please provide valid Email!') ;?>');" value ="<?php echo $this->__('Send'); ?>" />
210
  </td>
211
  </tr>
@@ -221,17 +354,30 @@ $style_smtp = '';
221
  <div class="section-config active">
222
  <input name="trackingUrl" type="hidden" id="trackingUrl" value="<?php echo $this->getUrl('sendinblue/ajax/codepost'); ?>" />
223
  <fieldset id="my-fieldset" class="fields">
224
- <legend class="lgend"><img src="<?php echo Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_SKIN);?>adminhtml/default/default/sendinblue/images/logo.gif"> <?php echo $this->__('Code tracking'); ?> </legend>
225
  <table cellspacing="0" class="form-list">
226
  <tr>
227
  <td class="fix_width"><label><?php echo $this->__('Do you want to install a tracking code when validating an order'); ?></label>
228
  </td>
229
  <td class="input-ele">
230
- <input type="radio" <?php if(Mage::getModel('sendinblue/sendinblue')->getTrackingStatus()==1) { echo 'checked'; } ?> name="Tracking" class='Tracking radio_nospaceing' value="1" /> <?php echo $this->__('Yes'); ?>
231
- <input type="radio" <?php if(Mage::getModel('sendinblue/sendinblue')->getTrackingStatus()==0) { echo 'checked'; } ?> name="Tracking" class='Tracking radio_spaceing2' value="0" /> <?php echo $this->__('No'); ?>
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>
@@ -239,7 +385,7 @@ $style_smtp = '';
239
 
240
  <div class="sendin_row hidetableblock" <?php echo $style; ?> >
241
  <fieldset class="fields">
242
- <legend class="lgend"><img src="<?php echo Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_SKIN);?>adminhtml/default/default/sendinblue/images/logo.gif">
243
  <?php echo $this->__('Manage SMS'); ?></legend>
244
  <table width="100%" cellspacing="0" cellpadding="0" class="table hidetableblock form-list">
245
 
@@ -248,29 +394,31 @@ $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;">
256
  <?php echo $this->__('here'); ?></a></span></td></tr>
257
  <tr>
258
  <td>
259
  <label>
260
  <?php echo $this->__('You want to be notified by e-mail when you do not have enough credits?'); ?></label>
261
- <input name="sms_credit" <?php if(Mage::getModel('sendinblue/sendinblue')->getNotifySmsStatus()==1) { echo 'checked'; } ?> type="radio" value="1" class="sms_credit radio_nospaceing" style="margin-right:10px;" />
262
  <?php echo $this->__('Yes'); ?>
263
- <input name="sms_credit" <?php if(Mage::getModel('sendinblue/sendinblue')->getNotifySmsStatus()==0) { echo 'checked'; } ?> type="radio" value="0" class="sms_credit radio_spaceing2" style="margin-left:20px;margin-right:10px;" />
264
  <?php echo $this->__('No'); ?>
265
  <input name="credit" type="hidden" id="credits" value="<?php echo $this->getUrl('sendinblue/ajax/credit'); ?>" />
266
  <div class="hideCredit" id="div_email_test" style="padding-top:20px;">
267
  <form action="<?php echo $this->getUrl('*/*/sendnotifysms'); ?>" method="POST" name="notify_sms_mail_form">
268
- <input name="form_key" type="hidden" value="<?php echo Mage::getSingleton('core/session')->getFormKey() ?>" />
269
  <p class="form-data"><label><?php echo $this->__('Email'); ?></label>
270
- <input name="sendin_notify_email" id="sendin_notify_email" type="text" class="input-text" value="<?php echo Mage::getModel('sendinblue/sendinblue')->getNotifyEmailStatus(); ?>" size="40" />
271
  </p>
272
  <p class="form-data"> <label><?php echo $this->__('Limit'); ?></label>
273
- <input name="sendin_notify_value" id="sendin_notify_value" type="text" class="input-text" value="<?php echo Mage::getModel('sendinblue/sendinblue')->getNotifyValueStatus(); ?>" size="40" /><span class="toolTip" title="<?php echo $this->__('Alert threshold for remaining credits'); ?>">&nbsp;</span>
274
  </p>
275
  <p class="form-data" style="width:705px"><input name="notify_sms_mail" type="submit" value="<?php echo $this->__('Save'); ?>" onclick="return validate('<?php echo $this->__('Please provide valid Email!') ;?>','<?php echo $this->__('Please provide a limit in integer format') ; ?>');" class="button btn" style=" float:right;"/></p>
276
  <p class="mrgin-left" style="float:left;"><?php echo $this->__('To get the email notification, you should run '); ?> <a href="<?php echo Mage::helper("adminhtml")->getUrl("sendinblue/adminhtml_notify/index/",array()); ?>" style="color: #000000; outline: 0 none; text-decoration: none;"><?php echo $this->__('this link'); ?> </a> <?php echo $this->__(' atleast one time per day. '); ?>
@@ -303,9 +451,9 @@ $style_smtp = '';
303
  <label class="r_label">
304
  <?php echo $this->__('Send SMS after order confirmation'); ?></label>
305
  <div class="radio_bx">
306
- <input name="sms_order_setting" <?php if(Mage::getModel('sendinblue/sendinblue')->getOrderSmsStatus()==1) { echo 'checked'; } ?> class="sms_order_setting radio_nospaceing" type="radio" value="1" />
307
  <?php echo $this->__('Yes'); ?>
308
- <input name="sms_order_setting" <?php if(Mage::getModel('sendinblue/sendinblue')->getOrderSmsStatus()==0) { echo 'checked'; } ?> class="sms_order_setting radio_spaceing2" type="radio" value="0" />
309
  <?php echo $this->__('No'); ?>
310
  </div>
311
  <div style="clear:both;"></div>
@@ -316,7 +464,7 @@ $style_smtp = '';
316
  <tr>
317
  <td>
318
  <form method="POST" action="<?php echo $this->getUrl('*/*/sendorder'); ?>" name="sender_order_form">
319
- <input name="form_key" type="hidden" value="<?php echo Mage::getSingleton('core/session')->getFormKey() ?>" />
320
  <table width="100%" border="0" cellspacing="0" cellpadding="0" class="form-list3 no-padding">
321
  <tr>
322
  <td class="fix_width2" valign="top">
@@ -324,18 +472,18 @@ $style_smtp = '';
324
  <?php echo $this->__('Sender'); ?></label>
325
  </td>
326
  <td>
327
- <input name="sender_order" id="sender_order" type="text" value="<?php echo Mage::getModel('sendinblue/sendinblue')->getSendSmsOrderSubject(); ?>" class="input_bx" autocomplete="off" />
328
- <span class="toolTip" title="<?php echo $this->__('This field allows you to personalize the SMS sender. Attention, there is a limited number of characters.If you enter a name, it is limited to 11 characters, and special characters (é, à ...) are not accepted. If you enter a phone number, it is limited to 17 characters; the number should be preceded by 00 and the country code (for instance, for France mobile 06 12 34 56 78 use 0033612345678 with 0033 is France prefix ).'); ?>">&nbsp;</span>
329
- <div class="hintmsg"><em><?php echo $this->__('Number of characters left: '); ?><span id="sender_order_text">17</span></em>
330
  </div>
331
-
332
  </td>
333
  </tr>
334
  <tr>
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>
@@ -356,7 +504,7 @@ $style_smtp = '';
356
  <tr>
357
  <td colspan="2" valign="top" border="0">
358
  <form method="POST" action="<?php echo $this->getUrl('*/*/sendordertest'); ?>" name="sender_order_testForm">
359
- <input name="form_key" type="hidden" value="<?php echo Mage::getSingleton('core/session')->getFormKey() ?>" />
360
  <table width="100%" border="0" cellspacing="0" cellpadding="0" class="form-data">
361
  <tr>
362
  <td>
@@ -388,9 +536,9 @@ $style_smtp = '';
388
  <label class="r_label">
389
  <?php echo $this->__('Send a SMS confirmation for the shipment of the order'); ?></label>
390
  <div class="radio_bx">
391
- <input name="sms_shiping_setting" <?php if(Mage::getModel('sendinblue/sendinblue')->getShipingSmsStatus()==1) { echo 'checked'; } ?> class="sms_shiping_setting radio_nospaceing" type="radio" value="1" />
392
  <?php echo $this->__('Yes'); ?>
393
- <input name="sms_shiping_setting" type="radio" value="0" class="sms_shiping_setting radio_spaceing2" <?php if(Mage::getModel('sendinblue/sendinblue')->getShipingSmsStatus()==0) { echo 'checked'; } ?>/>
394
  <?php echo $this->__('No'); ?>
395
  </div>
396
  <div style="clear:both;"></div>
@@ -402,14 +550,14 @@ $style_smtp = '';
402
  <td>
403
  <div class="" style="width:500px;">
404
  <form method="post" action="<?php echo $this->getUrl('*/*/sendshipment'); ?>" name="sender_shipment_form">
405
- <input name="form_key" type="hidden" value="<?php echo Mage::getSingleton('core/session')->getFormKey() ?>" />
406
  <table width="100%" border="0" cellspacing="0" cellpadding="0">
407
  <tr>
408
  <td class="fix_width2" valign="top"><label><?php echo $this->__('Sender'); ?></label></td>
409
  <td>
410
- <input name="sender_shipment" maxlength="17" id="sender_shipment" type="text" value="<?php echo Mage::getModel('sendinblue/sendinblue')->getSendSmsShipingSubject(); ?>" class="input_bx" autocomplete="off" />
411
- <span class="toolTip" title="<?php echo $this->__('This field allows you to personalize the SMS sender. Attention, there is a limited number of characters.If you enter a name, it is limited to 11 characters, and special characters (é, à ...) are not accepted. If you enter a phone number, it is limited to 17 characters; the number should be preceded by 00 and the country code (for instance, for France mobile 06 12 34 56 78 use 0033612345678 with 0033 is France prefix ).'); ?>">&nbsp;</span>
412
- <div class="hintmsg"><em><?php echo $this->__('Number of characters left: '); ?><span id="sender_shipment_text">17</span></em>
413
  </div>
414
 
415
  </td>
@@ -417,8 +565,8 @@ $style_smtp = '';
417
  <tr>
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>
@@ -440,7 +588,7 @@ $style_smtp = '';
440
  <tr>
441
  <td colspan="2" valign="top" border="0">
442
  <form method="post" action="<?php echo $this->getUrl('*/*/sendshipmenttest'); ?>" name="sender_order_testForm">
443
- <input name="form_key" type="hidden" value="<?php echo Mage::getSingleton('core/session')->getFormKey() ?>" />
444
  <table width="100%" border="0" cellspacing="0" cellpadding="0">
445
  <tr>
446
  <td valign="top" colspan="2">
@@ -471,9 +619,9 @@ $style_smtp = '';
471
  <td class="row1 fix_width2">
472
  <label class="r_label"><?php echo $this->__('Send a campaign SMS'); ?></label>
473
  <div class="radio_bx">
474
- <input name="sms_campaign_setting" <?php if(Mage::getModel('sendinblue/sendinblue')->getCampaignStatus()==1) { echo 'checked'; } ?> class="sms_campaign_setting radio_nospaceing" type="radio" value="1" />
475
  <?php echo $this->__('Yes'); ?>
476
- <input name="sms_campaign_setting" <?php if(Mage::getModel('sendinblue/sendinblue')->getCampaignStatus()==0) { echo 'checked'; } ?> class="sms_campaign_setting radio_spaceing2" type="radio" value="0" />
477
  <?php echo $this->__('No'); ?>
478
  </div>
479
  <div class="hideCampaign">
@@ -483,18 +631,18 @@ $style_smtp = '';
483
  <tr>
484
  <td>
485
  <form method="post" action="<?php echo $this->getUrl('*/*/sendcampaign'); ?>" name="sender_campaign_form">
486
- <input name="form_key" type="hidden" value="<?php echo Mage::getSingleton('core/session')->getFormKey() ?>" />
487
  <table width="100%" border="0" cellspacing="0" cellpadding="0" class="form-list3 no-padding" >
488
  <tr>
489
  <td class="fix_width2" valign="top"> <label><?php echo $this->__('To'); ?></label></td>
490
  <td>
491
- <input name="Sendin_Sms_Choice" id="r1_Sendin_Sms_Choice" class="Sendin_Sms_Choice radio_nospaceing" type="radio" value="1" <?php if(Mage::getModel('sendinblue/sendinblue')->getShipingSmsStatus()==1) { echo 'checked'; } ?> />
492
  <?php echo $this->__('A single contact'); ?>
493
 
494
- <input name="Sendin_Sms_Choice" id="r2_Sendin_Sms_Choice" class="Sendin_Sms_Choice radio_spaceing2" type="radio" value="0" <?php if(Mage::getModel('sendinblue/sendinblue')->getShipingSmsStatus()==0) { echo 'checked'; } ?> />
495
  <?php echo $this->__('All my Magento customers'); ?>
496
 
497
- <input name="Sendin_Sms_Choice" id="r3_Sendin_Sms_Choice" class="Sendin_Sms_Choice radio_spaceing2" type="radio" value="2" <?php if(Mage::getModel('sendinblue/sendinblue')->getShipingSmsStatus()==0) { echo 'checked'; } ?> />
498
  <?php echo $this->__('Only subscribed customers'); ?>
499
  </td>
500
  </tr>
@@ -515,12 +663,32 @@ $style_smtp = '';
515
  </td>
516
  </tr>
517
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
518
  <tr>
519
  <td valign="top"><label><?php echo $this->__('Sender'); ?></label></td>
520
  <td>
521
- <input name="sender_campaign" maxlength="17" id="sender_campaign" type="text" value="" class="input_bx" autocomplete="off" />
522
- <span class="toolTip" title="<?php echo $this->__('This field allows you to personalize the SMS sender. Attention, there is a limited number of characters.If you enter a name, it is limited to 11 characters, and special characters (é, à ...) are not accepted. If you enter a phone number, it is limited to 17 characters; the number should be preceded by 00 and the country code (for instance, for France mobile 06 12 34 56 78 use 0033612345678 with 0033 is France prefix ).'); ?>">&nbsp;</span>
523
- <div class="hintmsg"><em><?php echo $this->__('Number of characters left: '); ?><span id="sender_campaign_text">17</span></em>
524
  </div>
525
 
526
  </td>
@@ -529,7 +697,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>
@@ -543,26 +711,25 @@ $style_smtp = '';
543
  </table>
544
  </form>
545
  <table width="100%" border="0" cellspacing="0" cellpadding="0" class="form-data">
546
- <tr>
547
- <td>
548
- <div class="hintmsg"><em><?php echo $this->__('Sending a test SMS will be deducted from your SMS credits.'); ?></em></div>
549
- <label><?php echo $this->__('Send a test SMS'); ?></label>
550
- <input name="sender_campaigntest_number" id="sender_campaigntest_number" maxlength="17" type="text" value="" class="input_bx" />
551
- <span class="toolTip" title="<?php echo $this->__('The phone number should be in this form: 0033663309741 for this France mobile 06 63 30 97 41 (0033 is France prefix)'); ?>">&nbsp;</span>
552
- <input name="sender_campaignsms_submit" type="button" value="<?php echo $this->__('Send'); ?>" onclick="return testCampaignSmsSend('<?php echo $this->__('Please fill the Sender field'); ?>','<?php echo $this->__('Please fill the Message field'); ?>','<?php echo $this->__('Please fill the Mobile Phone field'); ?>');" class="button btn" />
553
- <input type="hidden" name="smsCampError" id="smsCampError" style="display:none;" value="<?php echo $this->__('Message has not been sent successfully'); ?>"><input type="hidden" id="smsCampSuccess" name="smsCampSuccess" value="<?php echo $this->__('Message has been sent successfully'); ?>">
554
- </td>
555
- </tr>
556
- </table>
557
  </td>
558
  </tr>
559
  </table>
560
-
561
- </div></span>
562
  </td>
563
  </tr>
564
  </table>
565
- </div>
566
  </div>
567
  </div>
568
  </div>
@@ -576,20 +743,21 @@ $style_smtp = '';
576
  <?php if($get_syncronize == 1) { ?>
577
  <div class="sendin_row alldiv" <?php echo $style; ?> >
578
  <fieldset id="my-fieldset" class="fields">
579
- <legend class="lgend"><img src="<?php echo Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_SKIN);?>adminhtml/default/default/sendinblue/images/logo.gif"> <?php echo $this->__('Contacts list'); ?> </legend>
580
 
581
  <input name="ajaxcontentUrl" type="hidden" id="ajaxcontentUrl" value="<?php echo $this->getUrl('sendinblue/ajax/ajaxcontent'); ?>" />
582
  <input name="ajaxUrl" type="hidden" id="ajaxUrl" value="<?php echo $this->getUrl('sendinblue/ajax/ajaxupdate'); ?>" />
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">
589
  <div class="hor-scroll">
590
- <?php echo $this->__('You have '); ?> <?php echo Mage::getModel('sendinblue/sendinblue')->getNewsletterSubscribeCount(); ?>
591
  <?php echo $this->__(' contacts subscribed and '); ?>
592
- <?php echo Mage::getModel('sendinblue/sendinblue')->getNewsletterUnSubscribeCount(); ?>
593
  <?php echo $this->__(' contacts unsubscribed from Magento.'); ?><span id="Spantextmore" >
594
  <?php echo $this->__(' For more details,'); ?></span><span id="Spantextless" style="display: none;" >
595
  <?php echo $this->__(' For less details,'); ?></span><b>
@@ -603,15 +771,15 @@ $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'>
610
-
611
  </tbody>
612
  </table>
613
- </div></div></div>
614
  </fieldset>
615
- </div>
616
  <?php }} ?>
617
-
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'); ?>";
15
  </script>
16
+ <?php
17
+ $skinUrl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_SKIN);
18
+ ?>
19
+ <script type="text/javascript" src="<?php echo $skinUrl;?>adminhtml/default/default/sendinblue/js/jquery-1.9.1.min.js"></script>
20
+ <script type="text/javascript" src="<?php echo $skinUrl;?>adminhtml/default/default/sendinblue/js/jquery-ui.min.js"></script>
21
+ <script type="text/javascript" src="<?php echo $skinUrl;?>adminhtml/default/default/sendinblue/js/jquery.multiselect.min.js"></script>
22
+ <script type="text/javascript" src="<?php echo $skinUrl;?>adminhtml/default/default/sendinblue/js/sendinblue.js"></script>
23
  <div class="entry-edit">
24
  <div class="">
25
+ <img class="sendin-logo" src="<?php echo $skinUrl;?>adminhtml/default/default/sendinblue/images/<?php echo $this->__('sendinblue.png'); ?>">
26
  <div class="slogan">
27
  <?php echo $this->__('SendinBlue : THE all-in-one plugin for your marketing and transactional emails.'); ?></div><div class="clear"></div>
28
  </div>
29
+ <input type="hidden" name="langvalue" value="<?php echo Mage::app()->getLocale()->getLocaleCode(); ?>" id="langvalue">
30
  <div class="sendin_row">
31
  <fieldset class="fields">
32
+ <legend class="lgend"><img src="<?php echo $skinUrl;?>adminhtml/default/default/sendinblue/images/logo.gif">
33
  <?php echo $this->__('SendinBlue'); ?></legend>
34
  <div class="contact-details">
35
  <h2 style="color:#268CCD;"> <?php echo $this->__('Contact SendinBlue team'); ?></h2>
39
  <?php echo $this->__('contact@sendinblue.com'); ?></a>
40
  <br><?php echo $this->__('Phone : 0899 25 30 61'); ?></p>
41
  <p style="padding-top:20px;"><b><?php echo $this->__('For further informations, please visit our website:'); ?></b>
42
+ <br><a href="<?php echo $this->__('https://www.sendinblue.com?utm_source=magento_plugin&utm_medium=plugin&utm_campaign=module_link'); ?>" target="_blank" style="color:#268CCD; text-decoration: none;">
43
  <?php echo $this->__('https://www.sendinblue.com'); ?></a></p>
44
  </div>
45
  <div><p><?php echo $this->__('With the SendinBlue plugin, you can find everything you need to easily and efficiently send your email & SMS campaigns to your prospects and customers.'); ?></p>
60
  </fieldset>
61
  </div>
62
  <?php
63
+ $sendinModule = Mage::getModel('sendinblue/sendinblue');
64
+ $sendinStatus = $sendinModule->getEnableStatus();
65
+
66
+ $module_status = isset($sendinStatus)?1:0;
67
  if ($module_status)
68
+ $style = '';
69
  else
70
  $style = 'style="display:none;"';
 
 
71
 
72
+ $api_key = $sendinModule->getApiKey();
73
+ $get_syncronize = $sendinModule->getSyncronizeStatus();
74
+ $trackStatus = $sendinModule->getTrackingStatus();
75
+ $trackingHistory = $sendinModule->getTrackingHistoryStatus();
76
+ $notifySmsStatus = $sendinModule->getNotifySmsStatus();
77
+ $orderSmsStatus = $sendinModule->getOrderSmsStatus();
78
+ $campaignStatus = $sendinModule->getCampaignStatus();
79
+ $shipingSmsStatus = $sendinModule->getShipingSmsStatus();
80
+ $formKey = Mage::getSingleton('core/session')->getFormKey();
81
  ?>
82
 
83
  <div class="sendin_row">
84
  <fieldset class="fields">
85
+ <legend class="lgend"><img src="<?php echo $skinUrl;?>adminhtml/default/default/sendinblue/images/logo.gif">
86
  <?php echo $this->__('Prerequisites'); ?></legend>
87
  <span><?php echo $this->__('- You should have a SendinBlue account. You can create a free account here:'); ?>
88
+ <a href="<?php echo $this->__('https://www.sendinblue.com?utm_source=magento_plugin&utm_medium=plugin&utm_campaign=module_link'); ?>" target="_blank" style="text-decoration: none; color: #268CCD;">
89
  &nbsp;<?php echo $this->__('https://www.sendinblue.com'); ?></a><br></span></fieldset>
90
  </div>
91
 
92
  <div class="sendin_row" >
93
  <form id="edit_formapik" name="edit_form" method="post" action="<?php echo $this->getUrl('*/*/apikeypost'); ?>">
94
+ <input name="form_key" type="hidden" value="<?php echo $formKey; ?>" />
95
+ <input name="skin_url" id ='skin_url' type="hidden" value="<?php echo $skinUrl;?>" />
96
  <div class="section-config active">
97
  <fieldset class="fields">
98
+ <legend class="lgend"><img src="<?php echo $skinUrl;?>adminhtml/default/default/sendinblue/images/logo.gif"> <?php echo $this->__('Settings'); ?></legend>
99
  <table cellspacing="0" class="form-list3">
100
  <tr>
101
  <td class="fix_width2"><label><?php echo $this->__('Activate the SendinBlue module:'); ?></label></td>
102
  <td class="input-ele">
103
+ <input type="radio" <?php if($sendinStatus == 1) { echo 'checked'; } ?> name="sendin_api_status" class="sendin_api_status radio_nospaceing" value="1" /> <?php echo $this->__('Yes'); ?>
104
+ <input type="radio" name="sendin_api_status" <?php if($sendinStatus == 0) { echo 'checked'; } ?> class="sendin_api_status radio_spaceing2" value="0" /> <?php echo $this->__('No'); ?>
105
  <input type="hidden" name="apistatuskey" id="apistatuskey" value="<?php echo $module_status;?>">
106
  </td>
107
  </tr>
109
  <tr <?php echo $style; ?> id="sendin_apikey">
110
  <td><label><?php echo $this->__('API Key:'); ?></label></td>
111
  <td class="input-ele">
112
+ <input type="text" name="sendin_apikey" id="sendin_apikey_val" class="input-text" value="<?php echo $api_key; ?>" />
113
  <span class="toolTip" title="<?php echo stripslashes($this->__('Please enter your API key from your SendinBlue account and if you don\'t have it yet, please go to www.sendinblue.com and subscribe. You can then get the API key from https://my.sendinblue.com/advanced/apikey')); ?>">&nbsp;</span>
114
  </td>
115
  </tr>
130
  <?php if ($api_key != '') { ?>
131
  <div class="sendin_row alldiv" <?php echo $style; ?> >
132
  <form id="edit_form" name="edit_form" method="post" action="<?php echo $this->getUrl('*/*/syncronizepost'); ?>">
133
+
134
  <div class="section-config active">
135
+ <input name="form_key" type="hidden" value="<?php echo $formKey; ?>" />
136
  <fieldset id="my-fieldset" class="fields">
137
+ <legend class="lgend"><img src="<?php echo $skinUrl;?>adminhtml/default/default/sendinblue/images/logo.gif"> <?php echo $this->__('Activate SendinBlue to manage subscribers'); ?></legend>
138
  <table cellspacing="0" class="form-list">
139
  <tr>
140
  <td class="fix_width"><label><?php echo $this->__('Activate SendinBlue to manage subscribers'); ?></label>
141
  </td>
142
  <td class="input-ele">
143
+ <input type="radio" <?php if($get_syncronize == 1) { echo "checked"; } ?> name="syncronize" value="1" class="radio_nospaceing hdtab"/> <?php echo $this->__('Yes'); ?>
144
+ <input type="radio" <?php if($get_syncronize == 0) { echo "checked"; } ?> name="syncronize" value="0" class="radio_spaceing2 hdtab" /> <?php echo $this->__('No'); ?> <span title="<?php echo $this->__('If you activate this feature, your new contacts will be automatically added to SendinBlue or unsubscribed from SendinBlue. To synchronize the other way (SendinBlue to Magento), you should run the url (mentioned below) each day.'); ?>" class="toolTip">&nbsp;</span>
145
  </td>
146
  </tr>
147
  <tr>
148
  <td colspan="2">
149
+ <div id="hidetabselect" <?php if(!$get_syncronize) {?>style="display:none;"<?php } ?>>
150
  <table>
151
  <tr>
152
  <td><label><?php echo $this->__('Your Lists'); ?></label></td>
153
  <td class="input-ele"><?php
154
+ $list = $sendinModule->lists();
155
 
156
+ $selectedlist = $sendinModule->getUserlists();
157
  if($selectedlist!=NULL){
158
  $list_array = explode('|',$selectedlist);
159
  }else{
169
  <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>
170
  </td>
171
  </tr>
172
+ <!-- double optin functionality -->
173
+ <tr>
174
+ <td></td>
175
+ <td>
176
+ <div class="col-md-6 left-wrapper radio_group_option">
177
+ <div class="form-group manage_subscribe_block">
178
+ <div>
179
+ <input type="radio" value="nocon" <?php if(Mage::getStoreConfig('sendinblue/SendinSubscribeConfirmType') == 'nocon') echo 'checked="checked"'; ?> name="subscribe_confirm_type" id="no_follow_email">
180
+ <label for="no_follow_email" class="radio-label"> <?php echo $this->__('No confirmation'); ?></label>
181
+ </div>
182
+ <div class="clearfix"></div>
183
+ <div style="display:block;" class="inner_manage_box">
184
+ <div class="ver_5" id="no-templates"><?php echo $this->__('With this option, contacts are directly added to your list when they enter their email address. No confirmation email is sent.'); ?></div>
185
+ </div>
186
+ </div>
187
+ <div class="form-group manage_subscribe_block">
188
+ <div class="col-md-10">
189
+ <input type="radio" value="simplemail" <?php if(Mage::getStoreConfig('sendinblue/SendinSubscribeConfirmType') == 'simplemail') echo 'checked="checked"'; ?> id="follow_mail" name="subscribe_confirm_type">
190
+ <label for="follow_mail" class="radio-label"> <?php echo $this->__('Simple confirmation'); ?></label><span title="<?php echo $this->__('This confirmation email is one of your SMTP templates. By default, we have created a Default Template - Single Confirmation. You can create and activate your SMTP templates by clicking here'); ?>" class="toolTip">
191
+ </span>
192
+ </div>
193
+ <div class="inner_manage_box">
194
+ <div class="clearfix"></div>
195
+ <div class="ver_5" id="create-templates"> <?php echo $this->__('By selecting this option, contacts are directly added to your list when they enter their email address on the form. A confirmation email will automatically be sent following their subscription.'); ?></div>
196
+ <div class="clearfix"></div>
197
+ <div id="mail-templates">
198
+ <div class="listData ver_5 managesubscribeBlock"><select class="ui-state-default" name="template_simple"><option value=""><?php echo $this->__('Select Template'); ?></option>
199
+ <?php
200
+ $templatelist = $sendinModule->templateDisplay();
201
+
202
+ if (!empty($templatelist->result->campaign_records))
203
+ {
204
+ foreach ($templatelist->result->campaign_records as $template_data)
205
+ { if ($template_data->templ_status === 'Active' && stristr($template_data->html_content, 'DOUBLEOPTIN') === false)
206
+ { ?>
207
+ <option value="<?php echo $template_data->id; ?>" <?php if($template_data->id == Mage::getStoreConfig('sendinblue/SendinTemplateId')) echo 'selected = "selected"'; ?> ><?php echo $template_data->campaign_name; ?></option>
208
+ <?php }}} ?>
209
+ </select><span title="<?php echo $this->__('Select a SendinBlue template that will be sent personalized for each contact that subscribes to your newsletter'); ?>" class="toolTip"></span>
210
+ </div>
211
+ </div>
212
+ <div class="clearfix"></div>
213
+ <div id="mail-templates-active-state"></div>
214
+ </div>
215
+ <div class="clearfix"></div>
216
+ </div>
217
+ <div class="clearfix"></div>
218
+ <div class="form-group manage_subscribe_block">
219
+ <div class="col-md-10">
220
+ <input type="radio" value="doubleoptin" <?php if(Mage::getStoreConfig('sendinblue/SendinSubscribeConfirmType') == 'doubleoptin') echo 'checked="checked"'; ?> id="double_optin" name="subscribe_confirm_type">
221
+ <label for="double_optin" class="radio-label"> <?php echo $this->__('Double opt-in confirmation'); ?></label><span title="<?php echo $this->__("If you select the Double Opt-in confirmation, subscribers will receive an email inviting them to confirm their subscription.Contact will be saved in the 'FORM' folder, on the 'Temp - DOUBLE OPT-IN' list. After confirmation, the contact will be saved in the 'Corresponding List' selected below."); ?>" class="toolTip">
222
+ </span></div>
223
+ <div class="inner_manage_box">
224
+ <div class="clearfix"></div>
225
+ <!-- Please select a template with the [DOUBLEOPTIN] link -->
226
+ <div id="create-doubleoptin-templates">
227
+ <p><?php echo $this->__('Once the form has been completed, your contact will receive an email with a link to confirm their subscription.'); ?></p></div>
228
+ <!-- Redirect URL after click on the validation email -->
229
+ <div class="clearfix"></div>
230
+ <div id="doubleoptin-redirect-url-area" class="form-group clearfix">
231
+ <input type="checkbox" class="openCollapse" <?php if(Mage::getStoreConfig('sendinblue/SendinOptinRedirectUrlCheck') == 'yes') echo 'checked="checked"'; ?> value="yes" name="optin_redirect_url_check" id="doptin_redirect_span_icon">
232
+ <a href=""> <?php echo $this->__('Redirect URL after clicking in the validation email'); ?> </a>
233
+ <!-- <label style="margin-bottom: 5px;"></label> -->
234
+
235
+ <div id="mail-doubleoptin-redirect" class="collapse">
236
+ <p style="width: 90%;text-align: justify;text-justify: inter-word;">
237
+ <?php echo $this->__('Redirect your contacts to a landing page or to your website once they have clicked on the confirmation link in the email.'); ?></p>
238
+ <input type="url" style="margin-bottom:10px;width:370px" value="<?php echo Mage::getStoreConfig('sendinblue/SendinDoubleoptinRedirectUrl'); ?>" placeholder="http://your-domain.com" class="form-control" name="doubleoptin-redirect-url" id="doubleoptin-redirect-url">
239
+ <div class="clearfix"></div>
240
+ <div class="pull-left" id="doubleoptin-redirect-message"> </div>
241
+ <div class="clearfix"></div>
242
+ </div>
243
+ </div>
244
+
245
+ <!-- Send a final confirmation email -->
246
+ <div class="clearfix"></div>
247
+ <div id="doubleoptin-final-confirmation-area" class="form-group clearfix">
248
+ <input type="checkbox" class="openCollapse" <?php if(Mage::getStoreConfig('sendinblue/SendinFinalConfirmEmail') == 'yes') echo 'checked="checked"'; ?> value="yes" name="final_confirm_email" id="doptin_final_confirm_email">
249
+ <a href="#doubleoptin-final-confirm"> <?php echo $this->__('Send a final confirmation email'); ?> </a>
250
+
251
+ <div id="doubleoptin-final-confirm" class="collapse">
252
+ <p><?php echo $this->__('Once a contact has clicked in the double opt-in confirmation email, send them a final confirmation email'); ?></p>
253
+ <div style="text-align: left;" class="listData ver_5 managesubscribeBlock"><select class="ui-state-default" name="template_final"><option value=""><?php echo $this->__('Select Template'); ?></option>
254
+ <?php
255
+ $templatelist = $sendinModule->templateDisplay();
256
+
257
+ if (!empty($templatelist->result->campaign_records))
258
+ {
259
+ foreach ($templatelist->result->campaign_records as $template_data)
260
+ { if ($template_data->templ_status === 'Active' && stristr($template_data->html_content, 'DOUBLEOPTIN') === false)
261
+ { ?>
262
+ <option value="<?php echo $template_data->id; ?>" <?php if($template_data->id == Mage::getStoreConfig('sendinblue/SendinTemplateFinal')) echo 'selected = "selected"'; ?> ><?php echo $template_data->campaign_name; ?></option>
263
+ <?php }}} ?></select><span title="<?php echo $this->__('Select a SendinBlue template that will be sent personalized for each contact that subscribes to your newsletter'); ?>"class="toolTip"></span></div>
264
+ <div class="clearfix"></div>
265
+ <div class="pull-left" id="final-mail-templates"></div>
266
+ <div class="clearfix"></div>
267
+ </div>
268
+ <div id="doubleoptin-templates-active-state">
269
+
270
+ </div>
271
+ </div>
272
+ </div>
273
+ </div>
274
+ <div class="clearfix"></div>
275
+
276
+ </td>
277
+ </tr>
278
  <tr>
279
  <td>&nbsp;</td>
280
  <td class="a-left">
282
  <input type="submit" class="btn" name="syncronizeSubmit" value ="<?php echo $this->__('Update'); ?>" /></div>
283
  </td>
284
  </tr>
285
+ </form>
286
+
287
+ <?php if($sendinModule->getImportOldSubsStatus()==1){ ?>
288
+ <form id="reimport_form" name="reimport_form" method="post" action="<?php echo $this->getUrl('*/*/reimportpost'); ?>">
289
+ <input name="form_key" type="hidden" value="<?php echo $formKey; ?>" />
290
+ <tr>
291
+ <td>&nbsp;</td>
292
+ <td class="a-left">
293
+ <div class="btnmrgn-right">
294
+ <input type="submit" class="btn" name="importoldSubmit" value ="<?php echo $this->__('Import Old Subscribers'); ?>" /></div>
295
+ </td>
296
+ </tr></form>
297
+ <?php } ?>
298
  <tr><td colspan="2">
299
  <?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>
300
  </td></tr>
306
  </table>
307
  </fieldset>
308
  </div>
309
+
310
  </div>
311
  <?php
312
  }
313
+ $module_status = $sendinModule->getSmtpStatus();
314
  if ($module_status == 0)
315
  $style_smtp = 'style="display:none;"';
316
  else
317
+ $style_smtp = '';
318
 
319
  ?>
320
  <?php if ($api_key != '') { ?>
321
  <div class="sendin_row alldiv" <?php echo $style; ?> >
322
  <form id="edit_formsmtp" name="edit_form" method="post" action="<?php echo $this->getUrl('*/*/sendmail'); ?>">
323
+ <input name="form_key" type="hidden" value="<?php echo $formKey; ?>" />
324
  <input name="smtpUrl" type="hidden" id="smtpUrl" value="<?php echo $this->getUrl('sendinblue/ajax/smtppost'); ?>" />
325
  <div class="section-config active">
326
  <fieldset class="fields">
327
+ <legend class="lgend"><img src="<?php echo $skinUrl;?>adminhtml/default/default/sendinblue/images/logo.gif"> <?php echo $this->__('Activate SendinBlue SMTP for your transactional emails'); ?></legend>
328
  <table cellspacing="0" class="form-list">
329
 
330
  <tr>
331
  <td class="fix_width"><label><?php echo $this->__('Activate SendinBlue SMTP for your transactional emails'); ?></label></td>
332
  <td class="input-ele">
333
+ <input type="radio" class = 'smtpStatus radio_nospaceing' <?php if($module_status == 1) { echo 'checked'; } ?> name="smtp" value="1" /> <?php echo $this->__('Yes'); ?>
334
+ <input <?php if($module_status == 0) { echo 'checked'; } ?> type="radio" class = 'smtpStatus radio_spaceing2' name="smtp" value="0" /> <?php echo $this->__('No'); ?><span title="<?php echo $this->__('Transactional email is an expected email because it is triggered automatically after a transaction or a specific event. Common examples of transactional email are : account opening and welcome message, order shipment confirmation, shipment tracking and purchase order status, registration via a contact form, account termination, payment confirmation, invoice etc.'); ?>" class="toolTip">&nbsp;</span>
335
  </td>
336
  <td>&nbsp;</td>
337
  </tr>
338
 
339
  <tr <?php echo $style_smtp; ?> class='smtptest'>
340
  <td class="fix_width"><label><?php echo $this->__('Send email test From / To :'); ?></label></td>
341
+ <td class="input-ele"><input class="input-text input-height" name="email" id="email" value="" size="40"/>
342
  <input type="submit" class="btn" style="margin-left:3px;" name="SmtpSubmit" onclick="return smtpvalidate('<?php echo $this->__('Please provide valid Email!') ;?>');" value ="<?php echo $this->__('Send'); ?>" />
343
  </td>
344
  </tr>
354
  <div class="section-config active">
355
  <input name="trackingUrl" type="hidden" id="trackingUrl" value="<?php echo $this->getUrl('sendinblue/ajax/codepost'); ?>" />
356
  <fieldset id="my-fieldset" class="fields">
357
+ <legend class="lgend"><img src="<?php echo $skinUrl;?>adminhtml/default/default/sendinblue/images/logo.gif"> <?php echo $this->__('Code tracking'); ?> </legend>
358
  <table cellspacing="0" class="form-list">
359
  <tr>
360
  <td class="fix_width"><label><?php echo $this->__('Do you want to install a tracking code when validating an order'); ?></label>
361
  </td>
362
  <td class="input-ele">
363
+ <input type="radio" <?php if($trackStatus == 1) { echo 'checked'; } ?> name="Tracking" class='Tracking radio_nospaceing' value="1" /> <?php echo $this->__('Yes'); ?>
364
+ <input type="radio" <?php if($trackStatus == 0) { echo 'checked'; } ?> name="Tracking" class='Tracking radio_spaceing2' value="0" /> <?php echo $this->__('No'); ?>
365
  <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>
366
  </td>
367
  </tr>
368
+ <?php
369
+ if ($trackStatus == 1 && $trackingHistory == 1)
370
+ $style_track = '';
371
+ else
372
+ $style_track = 'style="display:none;"';
373
+ if($trackStatus == 1 && $trackingHistory == 1) { ?>
374
+ <tr <?php echo $style_track; ?> class='ordertracking'>
375
+ <td>&nbsp;</td>
376
+ <input type="hidden" name="history_status" value="<?php echo $trackingHistory; ?>" id="history_status">
377
+ <input name="importordertrackingUrl" type="hidden" id="importordertrackingUrl" value="<?php echo $this->getUrl('sendinblue/ajax/orderhistory'); ?>" />
378
+ <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>
379
+ </tr>
380
+ <?php } ?>
381
  </table>
382
  </fieldset>
383
  </div>
385
 
386
  <div class="sendin_row hidetableblock" <?php echo $style; ?> >
387
  <fieldset class="fields">
388
+ <legend class="lgend"><img src="<?php echo $skinUrl;?>adminhtml/default/default/sendinblue/images/logo.gif">
389
  <?php echo $this->__('Manage SMS'); ?></legend>
390
  <table width="100%" cellspacing="0" cellpadding="0" class="table hidetableblock form-list">
391
 
394
  <td class="row1" colspan="2" style="border:none; padding-top:10px;">
395
  <span style="margin-bottom:10px; color:#333333;">
396
  <?php echo $this->__('Currently you have '); ?>
397
+ <?php $credit = $sendinModule->getSmsCredit();
398
+ $notify_value = $sendinModule->getNotifyValueStatus();
399
+ ?>
400
+ <?php if ($credit >= $notify_value){ ?> <strong style="color:#000000;"><?php echo $credit; ?></strong><?php } else {?><strong style="color:#F03D25;"><?php echo $credit; ?></strong><?php } ?>
401
 
402
  <?php echo $this->__(' credits sms. To buy more credits, please click'); ?>
403
+ <a target="_blank" href ="<?php echo $this->__('https://www.sendinblue.com/pricing?utm_source=magento_plugin&utm_medium=plugin&utm_campaign=module_link'); ?>" style="color: #000000; outline: 0 none; text-decoration: none;">
404
  <?php echo $this->__('here'); ?></a></span></td></tr>
405
  <tr>
406
  <td>
407
  <label>
408
  <?php echo $this->__('You want to be notified by e-mail when you do not have enough credits?'); ?></label>
409
+ <input name="sms_credit" <?php if($notifySmsStatus == 1) { echo 'checked'; } ?> type="radio" value="1" class="sms_credit radio_nospaceing" style="margin-right:10px;" />
410
  <?php echo $this->__('Yes'); ?>
411
+ <input name="sms_credit" <?php if($notifySmsStatus == 0) { echo 'checked'; } ?> type="radio" value="0" class="sms_credit radio_spaceing2" style="margin-left:20px;margin-right:10px;" />
412
  <?php echo $this->__('No'); ?>
413
  <input name="credit" type="hidden" id="credits" value="<?php echo $this->getUrl('sendinblue/ajax/credit'); ?>" />
414
  <div class="hideCredit" id="div_email_test" style="padding-top:20px;">
415
  <form action="<?php echo $this->getUrl('*/*/sendnotifysms'); ?>" method="POST" name="notify_sms_mail_form">
416
+ <input name="form_key" type="hidden" value="<?php echo $formKey; ?>" />
417
  <p class="form-data"><label><?php echo $this->__('Email'); ?></label>
418
+ <input name="sendin_notify_email" id="sendin_notify_email" type="text" class="input-text" value="<?php echo $sendinModule->getNotifyEmailStatus(); ?>" size="40" />
419
  </p>
420
  <p class="form-data"> <label><?php echo $this->__('Limit'); ?></label>
421
+ <input name="sendin_notify_value" id="sendin_notify_value" type="text" class="input-text" value="<?php echo $sendinModule->getNotifyValueStatus(); ?>" size="40" /><span class="toolTip" title="<?php echo $this->__('Alert threshold for remaining credits'); ?>">&nbsp;</span>
422
  </p>
423
  <p class="form-data" style="width:705px"><input name="notify_sms_mail" type="submit" value="<?php echo $this->__('Save'); ?>" onclick="return validate('<?php echo $this->__('Please provide valid Email!') ;?>','<?php echo $this->__('Please provide a limit in integer format') ; ?>');" class="button btn" style=" float:right;"/></p>
424
  <p class="mrgin-left" style="float:left;"><?php echo $this->__('To get the email notification, you should run '); ?> <a href="<?php echo Mage::helper("adminhtml")->getUrl("sendinblue/adminhtml_notify/index/",array()); ?>" style="color: #000000; outline: 0 none; text-decoration: none;"><?php echo $this->__('this link'); ?> </a> <?php echo $this->__(' atleast one time per day. '); ?>
451
  <label class="r_label">
452
  <?php echo $this->__('Send SMS after order confirmation'); ?></label>
453
  <div class="radio_bx">
454
+ <input name="sms_order_setting" <?php if($orderSmsStatus == 1) { echo 'checked'; } ?> class="sms_order_setting radio_nospaceing" type="radio" value="1" />
455
  <?php echo $this->__('Yes'); ?>
456
+ <input name="sms_order_setting" <?php if($orderSmsStatus == 0) { echo 'checked'; } ?> class="sms_order_setting radio_spaceing2" type="radio" value="0" />
457
  <?php echo $this->__('No'); ?>
458
  </div>
459
  <div style="clear:both;"></div>
464
  <tr>
465
  <td>
466
  <form method="POST" action="<?php echo $this->getUrl('*/*/sendorder'); ?>" name="sender_order_form">
467
+ <input name="form_key" type="hidden" value="<?php echo $formKey; ?>" />
468
  <table width="100%" border="0" cellspacing="0" cellpadding="0" class="form-list3 no-padding">
469
  <tr>
470
  <td class="fix_width2" valign="top">
472
  <?php echo $this->__('Sender'); ?></label>
473
  </td>
474
  <td>
475
+ <input name="sender_order" id="sender_order" type="text" value="<?php echo $sendinModule->getSendSmsOrderSubject(); ?>" class="input_bx" autocomplete="off" />
476
+ <span class="toolTip" title="<?php echo $this->__('This field allows you to customize the SMS sender. The number of characters is limited to 11 alphanumeric characters. You can´t configure your Sender with a phone number.'); ?>">&nbsp;</span>
477
+ <div class="hintmsg"><em><?php echo $this->__('Number of characters left: '); ?><span id="sender_order_text">11</span></em>
478
  </div>
479
+
480
  </td>
481
  </tr>
482
  <tr>
483
  <td valign="top"><label><?php echo $this->__('Message'); ?></label></td>
484
  <td>
485
+ <textarea name="sender_order_message" id="sender_order_message" cols="45" rows="5" class="textarea_bx"><?php echo $sendinModule->getSendSmsmOrderMessage(); ?></textarea>
486
+ <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>
487
  <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>
488
  <div class="hintmsg"><em><?php echo $this->__('Number of characters left: '); ?></em><span id="sender_order_message_text">160</span></div>
489
  <div class="hintmsg"><em><?php echo $this->__('Attention line break is counted as a single character.'); ?></em>
504
  <tr>
505
  <td colspan="2" valign="top" border="0">
506
  <form method="POST" action="<?php echo $this->getUrl('*/*/sendordertest'); ?>" name="sender_order_testForm">
507
+ <input name="form_key" type="hidden" value="<?php echo $formKey; ?>" />
508
  <table width="100%" border="0" cellspacing="0" cellpadding="0" class="form-data">
509
  <tr>
510
  <td>
536
  <label class="r_label">
537
  <?php echo $this->__('Send a SMS confirmation for the shipment of the order'); ?></label>
538
  <div class="radio_bx">
539
+ <input name="sms_shiping_setting" <?php if($shipingSmsStatus==1) { echo 'checked'; } ?> class="sms_shiping_setting radio_nospaceing" type="radio" value="1" />
540
  <?php echo $this->__('Yes'); ?>
541
+ <input name="sms_shiping_setting" type="radio" value="0" class="sms_shiping_setting radio_spaceing2" <?php if($shipingSmsStatus == 0) { echo 'checked'; } ?>/>
542
  <?php echo $this->__('No'); ?>
543
  </div>
544
  <div style="clear:both;"></div>
550
  <td>
551
  <div class="" style="width:500px;">
552
  <form method="post" action="<?php echo $this->getUrl('*/*/sendshipment'); ?>" name="sender_shipment_form">
553
+ <input name="form_key" type="hidden" value="<?php echo $formKey; ?>" />
554
  <table width="100%" border="0" cellspacing="0" cellpadding="0">
555
  <tr>
556
  <td class="fix_width2" valign="top"><label><?php echo $this->__('Sender'); ?></label></td>
557
  <td>
558
+ <input name="sender_shipment" maxlength="11" id="sender_shipment" type="text" value="<?php echo $sendinModule->getSendSmsShipingSubject(); ?>" class="input_bx" autocomplete="off" />
559
+ <span class="toolTip" title="<?php echo $this->__('This field allows you to customize the SMS sender. The number of characters is limited to 11 alphanumeric characters. You can´t configure your Sender with a phone number.'); ?>">&nbsp;</span>
560
+ <div class="hintmsg"><em><?php echo $this->__('Number of characters left: '); ?><span id="sender_shipment_text">11</span></em>
561
  </div>
562
 
563
  </td>
565
  <tr>
566
  <td valign="top"><label><?php echo $this->__('Message'); ?></label></td>
567
  <td>
568
+ <textarea name="sender_shipment_message" id="sender_shipment_message" cols="45" rows="5" class="textarea_bx"><?php echo $sendinModule->getSendSmsShipingMessage(); ?></textarea>
569
+ <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>
570
  <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>
571
  <div class="hintmsg"><em><?php echo $this->__('Number of characters left: '); ?></em><span id="sender_shipment_message_text">160</span></div>
572
  <div class="hintmsg"><em><?php echo $this->__('Attention line break is counted as a single character.'); ?></em>
588
  <tr>
589
  <td colspan="2" valign="top" border="0">
590
  <form method="post" action="<?php echo $this->getUrl('*/*/sendshipmenttest'); ?>" name="sender_order_testForm">
591
+ <input name="form_key" type="hidden" value="<?php echo $formKey; ?>" />
592
  <table width="100%" border="0" cellspacing="0" cellpadding="0">
593
  <tr>
594
  <td valign="top" colspan="2">
619
  <td class="row1 fix_width2">
620
  <label class="r_label"><?php echo $this->__('Send a campaign SMS'); ?></label>
621
  <div class="radio_bx">
622
+ <input name="sms_campaign_setting" <?php if($campaignStatus == 1) { echo 'checked'; } ?> class="sms_campaign_setting radio_nospaceing" type="radio" value="1" />
623
  <?php echo $this->__('Yes'); ?>
624
+ <input name="sms_campaign_setting" <?php if($campaignStatus == 0) { echo 'checked'; } ?> class="sms_campaign_setting radio_spaceing2" type="radio" value="0" />
625
  <?php echo $this->__('No'); ?>
626
  </div>
627
  <div class="hideCampaign">
631
  <tr>
632
  <td>
633
  <form method="post" action="<?php echo $this->getUrl('*/*/sendcampaign'); ?>" name="sender_campaign_form">
634
+ <input name="form_key" type="hidden" value="<?php echo $formKey; ?>" />
635
  <table width="100%" border="0" cellspacing="0" cellpadding="0" class="form-list3 no-padding" >
636
  <tr>
637
  <td class="fix_width2" valign="top"> <label><?php echo $this->__('To'); ?></label></td>
638
  <td>
639
+ <input name="Sendin_Sms_Choice" id="r1_Sendin_Sms_Choice" class="Sendin_Sms_Choice radio_nospaceing" type="radio" value="1" <?php if($shipingSmsStatus == 1) { echo 'checked'; } ?> />
640
  <?php echo $this->__('A single contact'); ?>
641
 
642
+ <input name="Sendin_Sms_Choice" id="r2_Sendin_Sms_Choice" class="Sendin_Sms_Choice radio_spaceing2" type="radio" value="0" <?php if($shipingSmsStatus == 0) { echo 'checked'; } ?> />
643
  <?php echo $this->__('All my Magento customers'); ?>
644
 
645
+ <input name="Sendin_Sms_Choice" id="r3_Sendin_Sms_Choice" class="Sendin_Sms_Choice radio_spaceing2" type="radio" value="2" <?php if($shipingSmsStatus == 0) { echo 'checked'; } ?> />
646
  <?php echo $this->__('Only subscribed customers'); ?>
647
  </td>
648
  </tr>
663
  </td>
664
  </tr>
665
 
666
+ <tr class='sib_datepicker' style="display:none;">
667
+ <td valign="top"><label><?php echo $this->__('Schedule your sms campaign'); ?></label></td>
668
+ <td>
669
+ <input name="sib_datetimepicker" class="input_bx Datepicker" id="sib_datetimepicker" type="text" value="" autocomplete="off" />&nbsp;&nbsp;
670
+ <select name="hour">
671
+ <option value='0'><?php echo $this->__('Hour'); ?></option>
672
+ <?php for($i=1;$i<=23;$i++){ ?>
673
+ <option><?php echo $i; ?></option>
674
+ <?php } ?>
675
+ </select>&nbsp;&nbsp;
676
+ <select name="minute">
677
+ <option value='0'><?php echo $this->__('Minute'); ?></option>
678
+ <?php for($i=5;$i<=55;$i=$i+5){ ?>
679
+ <option><?php echo $i; ?></option>
680
+ <?php } ?>
681
+ </select>
682
+
683
+ </td>
684
+ </tr>
685
+
686
  <tr>
687
  <td valign="top"><label><?php echo $this->__('Sender'); ?></label></td>
688
  <td>
689
+ <input name="sender_campaign" maxlength="11" id="sender_campaign" type="text" value="" class="input_bx" autocomplete="off" />
690
+ <span class="toolTip" title="<?php echo $this->__('This field allows you to customize the SMS sender. The number of characters is limited to 11 alphanumeric characters. You can´t configure your Sender with a phone number.'); ?>">&nbsp;</span>
691
+ <div class="hintmsg"><em><?php echo $this->__('Number of characters left: '); ?><span id="sender_campaign_text">11</span></em>
692
  </div>
693
 
694
  </td>
697
  <td valign="top"><label><?php echo $this->__('Message'); ?></label></td>
698
  <td>
699
  <textarea name="sender_campaign_message" id="sender_campaign_message" cols="45" rows="5" class="textarea_bx"></textarea>
700
+ <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>
701
  <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>
702
  <div class="hintmsg"><em><?php echo $this->__('Number of characters left: '); ?></em><span id="sender_campaign_message_text">160</span></div>
703
  <div class="hintmsg"><em><?php echo $this->__('Attention line break is counted as a single character.'); ?></em>
711
  </table>
712
  </form>
713
  <table width="100%" border="0" cellspacing="0" cellpadding="0" class="form-data">
714
+ <tr>
715
+ <td>
716
+ <div class="hintmsg"><em><?php echo $this->__('Sending a test SMS will be deducted from your SMS credits.'); ?></em></div>
717
+ <label><?php echo $this->__('Send a test SMS'); ?></label>
718
+ <input name="sender_campaigntest_number" id="sender_campaigntest_number" maxlength="17" type="text" value="" class="input_bx" />
719
+ <span class="toolTip" title="<?php echo $this->__('The phone number should be in this form: 0033663309741 for this France mobile 06 63 30 97 41 (0033 is France prefix)'); ?>">&nbsp;</span>
720
+ <input name="sender_campaignsms_submit" type="button" value="<?php echo $this->__('Send'); ?>" onclick="return testCampaignSmsSend('<?php echo $this->__('Please fill the Sender field'); ?>','<?php echo $this->__('Please fill the Message field'); ?>','<?php echo $this->__('Please fill the Mobile Phone field'); ?>');" class="button btn" />
721
+ <input type="hidden" name="smsCampError" id="smsCampError" style="display:none;" value="<?php echo $this->__('Message has not been sent successfully'); ?>"><input type="hidden" id="smsCampSuccess" name="smsCampSuccess" value="<?php echo $this->__('Message has been sent successfully'); ?>">
722
+ </td>
723
+ </tr>
724
+ </table>
725
  </td>
726
  </tr>
727
  </table>
728
+ </div></span>
 
729
  </td>
730
  </tr>
731
  </table>
732
+ </div>
733
  </div>
734
  </div>
735
  </div>
743
  <?php if($get_syncronize == 1) { ?>
744
  <div class="sendin_row alldiv" <?php echo $style; ?> >
745
  <fieldset id="my-fieldset" class="fields">
746
+ <legend class="lgend"><img src="<?php echo $skinUrl;?>adminhtml/default/default/sendinblue/images/logo.gif"> <?php echo $this->__('Contacts list'); ?> </legend>
747
 
748
  <input name="ajaxcontentUrl" type="hidden" id="ajaxcontentUrl" value="<?php echo $this->getUrl('sendinblue/ajax/ajaxcontent'); ?>" />
749
  <input name="ajaxUrl" type="hidden" id="ajaxUrl" value="<?php echo $this->getUrl('sendinblue/ajax/ajaxupdate'); ?>" />
750
  <input name="ajaxOrderSmsUrl" type="hidden" id="ajaxOrderSmsUrl" value="<?php echo $this->getUrl('sendinblue/ajax/ajaxordersms'); ?>" />
751
  <input name="ajaxOrderShippedUrl" type="hidden" id="ajaxOrderShippedUrl" value="<?php echo $this->getUrl('sendinblue/ajax/ajaxordershipped'); ?>" />
752
  <input name="ajaxSmsCampaignUrl" type="hidden" id="ajaxSmsCampaignUrl" value="<?php echo $this->getUrl('sendinblue/ajax/ajaxsmscampaign'); ?>" />
753
+ <input name="ajaxSmsSubscribeUrl" type="hidden" id="ajaxSmsSubscribeUrl" value="<?php echo $this->getUrl('sendinblue/ajax/ajaxsmssubscribe'); ?>" />
754
  <input type="hidden" name="pagenumber" id="pagenumber" value="1" />
755
  <div id="userGrid">
756
  <div class="grid">
757
  <div class="hor-scroll">
758
+ <?php echo $this->__('You have '); ?> <?php echo $sendinModule->getNewsletterSubscribeCount(); ?>
759
  <?php echo $this->__(' contacts subscribed and '); ?>
760
+ <?php echo $sendinModule->getNewsletterUnSubscribeCount(); ?>
761
  <?php echo $this->__(' contacts unsubscribed from Magento.'); ?><span id="Spantextmore" >
762
  <?php echo $this->__(' For more details,'); ?></span><span id="Spantextless" style="display: none;" >
763
  <?php echo $this->__(' For less details,'); ?></span><b>
771
  <th class="no-link"><span class="nobr"><?php echo $this->__('clients'); ?></span></th>
772
  <th class="no-link"><span class="nobr"><?php echo $this->__('SMS'); ?></span></th>
773
  <th class="no-link"><span class="nobr"><?php echo $this->__('Newsletter Magento Status'); ?></span></th>
774
+ <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>
775
+ <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>
776
  </tr>
777
  </thead>
778
  <tbody class='midleft'>
 
779
  </tbody>
780
  </table>
781
+ </div></div></div>
782
  </fieldset>
783
+ </div>
784
  <?php }} ?>
785
+
app/etc/modules/Sendinblue_Sendinblue.xml CHANGED
@@ -3,7 +3,7 @@
3
  <modules>
4
  <Sendinblue_Sendinblue>
5
  <active>true</active>
6
- <codePool>local</codePool>
7
  </Sendinblue_Sendinblue>
8
  </modules>
9
- </config>
3
  <modules>
4
  <Sendinblue_Sendinblue>
5
  <active>true</active>
6
+ <codePool>community</codePool>
7
  </Sendinblue_Sendinblue>
8
  </modules>
9
+ </config>
app/locale/en_US/template/email/doubleoptin_temp.html ADDED
@@ -0,0 +1,58 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
2
+ <html xmlns="http://www.w3.org/1999/xhtml"><head>
3
+ <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
4
+ <title>{title}</title>
5
+ </head>
6
+ <body style="font-family: Arial, Helvetica, sans-serif;font-size: 12px;color: #222;">
7
+ <div class="moz-forward-container">
8
+ <br>
9
+ <table cellspacing="0" cellpadding="0" border="0" width="100%" style="background-color:#ffffff">
10
+ <tbody>
11
+ <tr style="border-collapse:collapse;">
12
+ <td align="center" style="border-collapse:collapse;">
13
+ <table cellspacing="0" cellpadding="0" border="0" width="570">
14
+ <tbody>
15
+ <tr>
16
+ <td height="20" style="line-height:0; font-size:0;"><img width="0" height="0" alt="{shop_name}" src="{shop_logo}"></td>
17
+ </tr>
18
+ </tbody>
19
+ </table>
20
+ <table cellpadding="0" cellspacing="0" border="0" width="540">
21
+ <tbody>
22
+ <tr>
23
+ <td style="line-height:0; font-size:0;" height="20">
24
+ <div style="font-family:arial,sans-serif; color:#61a6f3; font-size:20px; font-weight:bold; line-height:28px;">
25
+ Please confirm your subscription</div>
26
+ </td>
27
+ </tr>
28
+ </tbody>
29
+ </table>
30
+ <table cellspacing="0" cellpadding="0" border="0" width="540">
31
+ <tbody>
32
+ <tr>
33
+ <td align="left">
34
+
35
+ <div style="font-family:arial,sans-serif; font-size:14px; margin:0; line-height:24px; color:#555555;">
36
+ <br>
37
+ Do you want to receive newsletters from {site_name} ?<br>
38
+ <br>
39
+ <a href="{double_optin}" style="color:#ffffff;display:inline-block;font-family:Arial,sans-serif;width:auto;white-space:nowrap;min-height:32px;margin:5px 5px 0 0;padding:0 22px;text-decoration:none;text-align:center;font-weight:bold;font-style:normal;font-size:15px;line-height:32px;border:0;border-radius:4px;vertical-align:top;background-color:#3276b1" target="_blank">
40
+ <span style="display:inline;font-family:Arial,sans-serif;text-decoration:none;font-weight:bold;font-style:normal;font-size:15px;line-height:32px;border:none;background-color:#3276b1;color:#ffffff">Yes, subscribe me to this list.</span></a>
41
+ <br>
42
+ <br>
43
+ If you received this email by mistake, simply delete it. You will not be subscribed to this list if you don't click the confirmation link above.
44
+ <br><br>
45
+ {site_name}</div>
46
+ </td>
47
+ </tr>
48
+ </tbody>
49
+ </table>
50
+ </td>
51
+ </tr>
52
+ </tbody>
53
+ </table>
54
+ <br>
55
+ </div>
56
+
57
+
58
+ </body></html>
app/locale/en_US/template/email/sendin_notification.html CHANGED
@@ -123,12 +123,12 @@
123
  style="font-family:arial,sans-serif;
124
  font-size:12px; margin:0;
125
  line-height:16px; color:#7e7e7e;">
126
- 118, rue de Tocqueville</div>
127
  <div
128
  style="font-family:arial,sans-serif;
129
  font-size:12px; margin:0;
130
  line-height:16px; color:#7e7e7e;">
131
- 75017 Paris - France</div>
132
  <div
133
  style="font-family:arial,sans-serif;
134
  font-size:12px; margin:0;
@@ -148,7 +148,7 @@
148
  <div style="font-family:arial,sans-serif; font-size:12px; margin:0; line-height:20px; color:#7e7e7e;">
149
  <a href="http://www.facebook.com/SendinBlue" style="color:#2f8bee; text-decoration:none;" target="_blank"> <img alt="Facebook" src="https://my.sendinblue.com/public/upload/14406/images/523693143fe88.gif" style="border:none;"> </a> <a href="https://twitter.com/SendinBlue" style="color:#2f8bee; text-decoration:none;" target="_blank"> <img alt="Twitter" src="https://my.sendinblue.com/public/upload/14406/images/5236931746c01.gif" style="border:none;"> </a> <a href="http://www.linkedin.com/company/mailin" style="color:#2f8bee; text-decoration:none;" target="_blank"> <img alt="Linkedin" src="https://my.sendinblue.com/public/upload/14406/images/5236931ad253b.gif" style="border:none;"> </a> <a href="http://sendinblue.tumblr.com/" style="color:#2f8bee; text-decoration:none;" target="_blank">Blog</a></div>
150
  <div style="font-family:arial,sans-serif; font-size:10px; margin:0; line-height:14px; color:#7e7e7e;">
151
- © 2013-2014 SendinBlue, all rights reserved.</div>
152
  <div style="font-family:arial,sans-serif; font-size:10px; margin:0; line-height:14px; color:#7e7e7e;">
153
  This is an automatic message generated by SendinBlue.</div>
154
  <div style="font-family:arial,sans-serif; font-size:10px; margin:0; line-height:14px; color:#7e7e7e;">
123
  style="font-family:arial,sans-serif;
124
  font-size:12px; margin:0;
125
  line-height:16px; color:#7e7e7e;">
126
+ 59 rue Beaubourg</div>
127
  <div
128
  style="font-family:arial,sans-serif;
129
  font-size:12px; margin:0;
130
  line-height:16px; color:#7e7e7e;">
131
+ 75003 Paris - France</div>
132
  <div
133
  style="font-family:arial,sans-serif;
134
  font-size:12px; margin:0;
148
  <div style="font-family:arial,sans-serif; font-size:12px; margin:0; line-height:20px; color:#7e7e7e;">
149
  <a href="http://www.facebook.com/SendinBlue" style="color:#2f8bee; text-decoration:none;" target="_blank"> <img alt="Facebook" src="https://my.sendinblue.com/public/upload/14406/images/523693143fe88.gif" style="border:none;"> </a> <a href="https://twitter.com/SendinBlue" style="color:#2f8bee; text-decoration:none;" target="_blank"> <img alt="Twitter" src="https://my.sendinblue.com/public/upload/14406/images/5236931746c01.gif" style="border:none;"> </a> <a href="http://www.linkedin.com/company/mailin" style="color:#2f8bee; text-decoration:none;" target="_blank"> <img alt="Linkedin" src="https://my.sendinblue.com/public/upload/14406/images/5236931ad253b.gif" style="border:none;"> </a> <a href="http://sendinblue.tumblr.com/" style="color:#2f8bee; text-decoration:none;" target="_blank">Blog</a></div>
150
  <div style="font-family:arial,sans-serif; font-size:10px; margin:0; line-height:14px; color:#7e7e7e;">
151
+ © 2014-2015 SendinBlue, all rights reserved.</div>
152
  <div style="font-family:arial,sans-serif; font-size:10px; margin:0; line-height:14px; color:#7e7e7e;">
153
  This is an automatic message generated by SendinBlue.</div>
154
  <div style="font-family:arial,sans-serif; font-size:10px; margin:0; line-height:14px; color:#7e7e7e;">
app/locale/en_US/template/email/sendinsmtp_conf.html CHANGED
@@ -119,10 +119,10 @@
119
  color:#7e7e7e;"> <strong style="color:#2f8bee;">SendinBlue</strong></div>
120
  <div style="font-family:arial,sans-serif;
121
  font-size:12px; margin:0; line-height:16px;
122
- color:#7e7e7e;"> 118, rue de Tocqueville</div>
123
  <div style="font-family:arial,sans-serif;
124
  font-size:12px; margin:0; line-height:16px;
125
- color:#7e7e7e;"> 75017 Paris - France</div>
126
  <div style="font-family:arial,sans-serif;
127
  font-size:12px; margin:0; line-height:16px;
128
  color:#7e7e7e;"> T&eacute;l : 0899 25 30 61</div>
@@ -136,7 +136,7 @@
136
  <div style="font-family:arial,sans-serif; font-size:12px; margin:0; line-height:20px; color:#7e7e7e;">
137
  <a href="http://www.facebook.com/SendinBlue" style="color:#2f8bee; text-decoration:none;" target="_blank"> <img alt="Facebook" src="https://my.sendinblue.com/public/upload/14406/images/523693143fe88.gif" style="border:none;"> </a> <a href="https://twitter.com/SendinBlue" style="color:#2f8bee; text-decoration:none;" target="_blank"> <img alt="Twitter" src="https://my.sendinblue.com/public/upload/14406/images/5236931746c01.gif" style="border:none;"> </a> <a href="http://www.linkedin.com/company/mailin" style="color:#2f8bee; text-decoration:none;" target="_blank"> <img alt="Linkedin" src="https://my.sendinblue.com/public/upload/14406/images/5236931ad253b.gif" style="border:none;"> </a> <a href="http://sendinblue.tumblr.com/" style="color:#2f8bee; text-decoration:none;" target="_blank">Blog</a></div>
138
  <div style="font-family:arial,sans-serif; font-size:10px; margin:0; line-height:14px; color:#7e7e7e;">
139
- © 2013-2014 SendinBlue, all rights reserved.</div>
140
  <div style="font-family:arial,sans-serif; font-size:10px; margin:0; line-height:14px; color:#7e7e7e;">
141
  This is an automatic message generated by SendinBlue.</div>
142
  <div style="font-family:arial,sans-serif; font-size:10px; margin:0; line-height:14px; color:#7e7e7e;">
119
  color:#7e7e7e;"> <strong style="color:#2f8bee;">SendinBlue</strong></div>
120
  <div style="font-family:arial,sans-serif;
121
  font-size:12px; margin:0; line-height:16px;
122
+ color:#7e7e7e;"> 59 rue Beaubourg</div>
123
  <div style="font-family:arial,sans-serif;
124
  font-size:12px; margin:0; line-height:16px;
125
+ color:#7e7e7e;"> 75003 Paris - France</div>
126
  <div style="font-family:arial,sans-serif;
127
  font-size:12px; margin:0; line-height:16px;
128
  color:#7e7e7e;"> T&eacute;l : 0899 25 30 61</div>
136
  <div style="font-family:arial,sans-serif; font-size:12px; margin:0; line-height:20px; color:#7e7e7e;">
137
  <a href="http://www.facebook.com/SendinBlue" style="color:#2f8bee; text-decoration:none;" target="_blank"> <img alt="Facebook" src="https://my.sendinblue.com/public/upload/14406/images/523693143fe88.gif" style="border:none;"> </a> <a href="https://twitter.com/SendinBlue" style="color:#2f8bee; text-decoration:none;" target="_blank"> <img alt="Twitter" src="https://my.sendinblue.com/public/upload/14406/images/5236931746c01.gif" style="border:none;"> </a> <a href="http://www.linkedin.com/company/mailin" style="color:#2f8bee; text-decoration:none;" target="_blank"> <img alt="Linkedin" src="https://my.sendinblue.com/public/upload/14406/images/5236931ad253b.gif" style="border:none;"> </a> <a href="http://sendinblue.tumblr.com/" style="color:#2f8bee; text-decoration:none;" target="_blank">Blog</a></div>
138
  <div style="font-family:arial,sans-serif; font-size:10px; margin:0; line-height:14px; color:#7e7e7e;">
139
+ © 2014-2015 SendinBlue, all rights reserved.</div>
140
  <div style="font-family:arial,sans-serif; font-size:10px; margin:0; line-height:14px; color:#7e7e7e;">
141
  This is an automatic message generated by SendinBlue.</div>
142
  <div style="font-family:arial,sans-serif; font-size:10px; margin:0; line-height:14px; color:#7e7e7e;">
app/locale/fr_FR/Sendinblue.csv CHANGED
@@ -71,7 +71,7 @@
71
  "Send a campaign SMS", "Envoyer une campagne SMS"
72
  "SMS settings", "Paramètres du SMS"
73
  "Sender", "Expéditeur"
74
- "This field allows you to personalize the SMS sender. Attention, there is a limited number of characters.If you enter a name, it is limited to 11 characters, and special characters (é, à ...) are not accepted. If you enter a phone number, it is limited to 17 characters; the number should be preceded by 00 and the country code (for instance, for France mobile 06 12 34 56 78 use 0033612345678 with 0033 is France prefix ).", "Ce champ vous permet de personnaliser l'expéditeur du SMS. Attention, il y 'a un nombre limité de caractères. Si vous entrez un nom, il sera limité à 11 caractères (les caractères spéciaux (é, à ...) ne sont pas acceptés) et si vous entrez un numéro de téléphone, il sera limité à 17 caractères. Le numéro devrait être précédé par 00 et le code du pays (par exemple, pour un numéro de téléphone mobile français 06 12 34 56 78 il faudra utiliser 0033612345678 (0033 est l'indicatif de la France)"
75
  "Number of characters left: ", "Nombre de caractères restants: "
76
  "Attention line break is counted as a single character.", "Attention, un saut de ligne est compté comme un seul caractère. "
77
  " 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.", "Créer le contenu de vos SMS avec une limite de 160 caractères. Au-delà de 160 caractères, il sera compté comme un second SMS. Ainsi, si vous écrivez un SMS de 240 caractères, il sera compté comme deux SMS."
@@ -127,4 +127,27 @@
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 :"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
71
  "Send a campaign SMS", "Envoyer une campagne SMS"
72
  "SMS settings", "Paramètres du SMS"
73
  "Sender", "Expéditeur"
74
+ "This field allows you to customize the SMS sender. The number of characters is limited to 11 alphanumeric characters. You can´t configure your Sender with a phone number.", "Ce champs permet de personnaliser l'expéditeur du SMS. Il ne doit pas contenir plus de 11 caractères. Les caractères spéciaux (é, à ...) ne sont pas acceptés."
75
  "Number of characters left: ", "Nombre de caractères restants: "
76
  "Attention line break is counted as a single character.", "Attention, un saut de ligne est compté comme un seul caractère. "
77
  " 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.", "Créer le contenu de vos SMS avec une limite de 160 caractères. Au-delà de 160 caractères, il sera compté comme un second SMS. Ainsi, si vous écrivez un SMS de 240 caractères, il sera compté comme deux SMS."
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"
139
+ "Old subscribers not imported successfully, please click on Import Old Subscribers button to import them again", "Les anciens abonnés n'ont pas été importé. Merci de bien cliquez à nouveau sur le bouton"
140
+ "Import Old Subscribers", "Importer les anciens abonnés"
141
+ "No confirmation", "Aucune confirmation"
142
+ "With this option, contacts are directly added to your list when they enter their email address. No confirmation email is sent.","Avec cette option, votre contact s'inscrit directement à votre liste en laissant son adresse email. Aucun email de confirmation lui est envoyé."
143
+ "Simple confirmation", "Confirmation simple"
144
+ "This confirmation email is one of your SMTP templates. By default, we have created a Default Template - Single Confirmation. You can create and activate your SMTP templates by clicking here", "Cet email de confirmation fait partie de vos templates SMTP. Par défaut, nous en avons créé un 'Default Template - Simple Confirmation'."
145
+ "Double opt-in confirmation", "Double opt-in confirmation"
146
+ "If you select the Double Opt-in confirmation, subscribers will receive an email inviting them to confirm their subscription.Contact will be saved in the "FORM" folder, on the "Temp - DOUBLE OPT-IN" list. After confirmation, the contact will be saved in the "Corresponding List" selected below.", "Si vous choisissez la confirmation Double Opt-in, l'abonné recevra un email l'invitant à confirmer son inscription. Avant la confirmation, le contact est sauvegardé dans le dossier 'FORM', liste 'Temp - DOUBLE OPTIN', après confirmation, le contact est sauvegardé dans la 'Liste correspondante' choisie ci-dessous."
147
+ "Once the form has been completed, your contact will receive an email with a link to confirm their subscription.", "Lorsque le formulaire est rempli, votre contact recevra un email avec un lien de confirmation d'inscription."
148
+ "Redirect URL after clicking in the validation email", "URL de redirection après clic dans l'email de validation"
149
+ "Redirect your contacts to a landing page or to your website once they have clicked on the confirmation link in the email.", "Redirigez votre contact vers une landing page ou votre site après qu'il ait validé le lien de confirmation dans l'email."
150
+ "Send a final confirmation email", "Envoyer un email de confirmation final"
151
+ "Once a contact has clicked in the double opt-in confirmation email, send them a final confirmation email", "Lorsqu'un contact a cliqué dans le lien de l'email de confirmation double opt-in, lui envoyer un email final de confirmation"
152
+ "If you select the Double Opt-in confirmation, subscribers will receive an email inviting them to confirm their subscription.Contact will be saved in the 'FORM' folder, on the 'Temp - DOUBLE OPT-IN' list. After confirmation, the contact will be saved in the 'Corresponding List' selected below.", "Si vous choisissez la confirmation Double Opt-in, l'abonné recevra un email l'invitant à confirmer son inscription. Avant la confirmation, le contact est sauvegardé dans le dossier 'FORM', liste 'Temp - DOUBLE OPTIN', après confirmation, le contact est sauvegardé dans la 'Liste correspondante' choisie ci-dessous."
153
+ "By selecting this option, contacts are directly added to your list when they enter their email address on the form. A confirmation email will automatically be sent following their subscription.", "En choisissant cette option, votre contact s'inscrira directement à la liste en laissant son adresse email dans le formulaire. Un email de confirmation de son inscription lui sera automatiquement envoyé à la suite de son inscription."
app/locale/fr_FR/template/email/doubleoptin_temp.html ADDED
@@ -0,0 +1,58 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
2
+ <html xmlns="http://www.w3.org/1999/xhtml"><head>
3
+ <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
4
+ <title>{title}</title>
5
+ </head>
6
+ <body style="font-family: Arial, Helvetica, sans-serif;font-size: 12px;color: #222;">
7
+ <div class="moz-forward-container">
8
+ <br>
9
+ <table cellspacing="0" cellpadding="0" border="0" width="100%" style="background-color:#ffffff">
10
+ <tbody>
11
+ <tr style="border-collapse:collapse;">
12
+ <td align="center" style="border-collapse:collapse;">
13
+ <table cellspacing="0" cellpadding="0" border="0" width="570">
14
+ <tbody>
15
+ <tr>
16
+ <td height="20" style="line-height:0; font-size:0;"><img width="0" height="0" alt="{shop_name}" src="{shop_logo}"></td>
17
+ </tr>
18
+ </tbody>
19
+ </table>
20
+ <table cellpadding="0" cellspacing="0" border="0" width="540">
21
+ <tbody>
22
+ <tr>
23
+ <td style="line-height:0; font-size:0;" height="20">
24
+ <div style="font-family:arial,sans-serif; color:#61a6f3; font-size:20px; font-weight:bold; line-height:28px;">
25
+ Confirmez votre inscription</div>
26
+ </td>
27
+ </tr>
28
+ </tbody>
29
+ </table>
30
+ <table cellspacing="0" cellpadding="0" border="0" width="540">
31
+ <tbody>
32
+ <tr>
33
+ <td align="left">
34
+
35
+ <div style="font-family:arial,sans-serif; font-size:14px; margin:0; line-height:24px; color:#555555;">
36
+ <br>
37
+ Voulez vous recevoir les newsletters de {site_name} ?<br>
38
+ <br>
39
+ <a href="{double_optin}" style="color:#ffffff;display:inline-block;font-family:Arial,sans-serif;width:auto;white-space:nowrap;min-height:32px;margin:5px 5px 0 0;padding:0 22px;text-decoration:none;text-align:center;font-weight:bold;font-style:normal;font-size:15px;line-height:32px;border:0;border-radius:4px;vertical-align:top;background-color:#3276b1" target="_blank">
40
+ <span style="display:inline;font-family:Arial,sans-serif;text-decoration:none;font-weight:bold;font-style:normal;font-size:15px;line-height:32px;border:none;background-color:#3276b1;color:#ffffff">Oui, je confirme mon inscription</span></a>
41
+ <br>
42
+ <br>
43
+ Si vous recevez cet email par erreur, vous pouvez simplement le supprimer. Vous ne serez pas inscrit à la newsletter si vous ne cliquez pas sur le lien de confirmation ci-dessus.
44
+ <br><br>
45
+ {site_name}</div>
46
+ </td>
47
+ </tr>
48
+ </tbody>
49
+ </table>
50
+ </td>
51
+ </tr>
52
+ </tbody>
53
+ </table>
54
+ <br>
55
+ </div>
56
+
57
+
58
+ </body></html>
app/locale/fr_FR/template/email/sendin_notification.html CHANGED
@@ -117,10 +117,10 @@
117
  color:#7e7e7e;"> <strong style="color:#2f8bee;">SendinBlue</strong></div>
118
  <div style="font-family:arial,sans-serif;
119
  font-size:12px; margin:0; line-height:16px;
120
- color:#7e7e7e;"> 118, rue de Tocqueville</div>
121
  <div style="font-family:arial,sans-serif;
122
  font-size:12px; margin:0; line-height:16px;
123
- color:#7e7e7e;"> 75017 Paris - France</div>
124
  <div style="font-family:arial,sans-serif;
125
  font-size:12px; margin:0; line-height:16px;
126
  color:#7e7e7e;"> T&eacute;l : 0899 25 30 61</div>
@@ -133,7 +133,7 @@
133
  <td align="right" valign="top">
134
  <div style="font-family:arial,sans-serif; font-size:12px; margin:0; line-height:20px; color:#7e7e7e;">
135
  <a href="http://www.facebook.com/SendinBlue" style="color:#2f8bee; text-decoration:none;" target="_blank"> <img alt="Facebook" src="https://my.sendinblue.com/public/upload/14406/images/523693143fe88.gif" style="border:none;"> </a> <a href="https://twitter.com/SendinBlue" style="color:#2f8bee; text-decoration:none;" target="_blank"> <img alt="Twitter" src="https://my.sendinblue.com/public/upload/14406/images/5236931746c01.gif" style="border:none;"> </a> <a href="http://www.linkedin.com/company/mailin" style="color:#2f8bee; text-decoration:none;" target="_blank"> <img alt="Linkedin" src="https://my.sendinblue.com/public/upload/14406/images/5236931ad253b.gif" style="border:none;"> </a> <a href="http://sendinblue.tumblr.com/" style="color:#2f8bee; text-decoration:none;" target="_blank">Blog</a></div>
136
- <div style="font-family:arial,sans-serif; font-size:10px; margin:0; line-height:14px; color:#7e7e7e;"> &copy; 2013-2014 SendinBlue, tous droits
137
  r&eacute;serv&eacute;s.
138
  </div>
139
  <div style="font-family:arial,sans-serif; font-size:10px; margin:0; line-height:14px; color:#7e7e7e;"> Ceci est un message automatique
117
  color:#7e7e7e;"> <strong style="color:#2f8bee;">SendinBlue</strong></div>
118
  <div style="font-family:arial,sans-serif;
119
  font-size:12px; margin:0; line-height:16px;
120
+ color:#7e7e7e;"> 59 rue Beaubourg</div>
121
  <div style="font-family:arial,sans-serif;
122
  font-size:12px; margin:0; line-height:16px;
123
+ color:#7e7e7e;"> 75003 Paris - France</div>
124
  <div style="font-family:arial,sans-serif;
125
  font-size:12px; margin:0; line-height:16px;
126
  color:#7e7e7e;"> T&eacute;l : 0899 25 30 61</div>
133
  <td align="right" valign="top">
134
  <div style="font-family:arial,sans-serif; font-size:12px; margin:0; line-height:20px; color:#7e7e7e;">
135
  <a href="http://www.facebook.com/SendinBlue" style="color:#2f8bee; text-decoration:none;" target="_blank"> <img alt="Facebook" src="https://my.sendinblue.com/public/upload/14406/images/523693143fe88.gif" style="border:none;"> </a> <a href="https://twitter.com/SendinBlue" style="color:#2f8bee; text-decoration:none;" target="_blank"> <img alt="Twitter" src="https://my.sendinblue.com/public/upload/14406/images/5236931746c01.gif" style="border:none;"> </a> <a href="http://www.linkedin.com/company/mailin" style="color:#2f8bee; text-decoration:none;" target="_blank"> <img alt="Linkedin" src="https://my.sendinblue.com/public/upload/14406/images/5236931ad253b.gif" style="border:none;"> </a> <a href="http://sendinblue.tumblr.com/" style="color:#2f8bee; text-decoration:none;" target="_blank">Blog</a></div>
136
+ <div style="font-family:arial,sans-serif; font-size:10px; margin:0; line-height:14px; color:#7e7e7e;"> &copy; 2014-2015 SendinBlue, tous droits
137
  r&eacute;serv&eacute;s.
138
  </div>
139
  <div style="font-family:arial,sans-serif; font-size:10px; margin:0; line-height:14px; color:#7e7e7e;"> Ceci est un message automatique
app/locale/fr_FR/template/email/sendinsmtp_conf.html CHANGED
@@ -119,10 +119,10 @@
119
  color:#7e7e7e;"> <strong style="color:#2f8bee;">SendinBlue</strong></div>
120
  <div style="font-family:arial,sans-serif;
121
  font-size:12px; margin:0; line-height:16px;
122
- color:#7e7e7e;"> 118, rue de Tocqueville</div>
123
  <div style="font-family:arial,sans-serif;
124
  font-size:12px; margin:0; line-height:16px;
125
- color:#7e7e7e;"> 75017 Paris - France</div>
126
  <div style="font-family:arial,sans-serif;
127
  font-size:12px; margin:0; line-height:16px;
128
  color:#7e7e7e;"> T&eacute;l : 0899 25 30 61</div>
@@ -135,7 +135,7 @@
135
  <td align="right" valign="top">
136
  <div style="font-family:arial,sans-serif; font-size:12px; margin:0; line-height:20px; color:#7e7e7e;">
137
  <a href="http://www.facebook.com/SendinBlue" style="color:#2f8bee; text-decoration:none;" target="_blank"> <img alt="Facebook" src="https://my.sendinblue.com/public/upload/14406/images/523693143fe88.gif" style="border:none;"> </a> <a href="https://twitter.com/SendinBlue" style="color:#2f8bee; text-decoration:none;" target="_blank"> <img alt="Twitter" src="https://my.sendinblue.com/public/upload/14406/images/5236931746c01.gif" style="border:none;"> </a> <a href="http://www.linkedin.com/company/mailin" style="color:#2f8bee; text-decoration:none;" target="_blank"> <img alt="Linkedin" src="https://my.sendinblue.com/public/upload/14406/images/5236931ad253b.gif" style="border:none;"> </a> <a href="http://sendinblue.tumblr.com/" style="color:#2f8bee; text-decoration:none;" target="_blank">Blog</a></div>
138
- <div style="font-family:arial,sans-serif; font-size:10px; margin:0; line-height:14px; color:#7e7e7e;"> &copy; 2013-2014 SendinBlue, tous droits
139
  r&eacute;serv&eacute;s.
140
  </div>
141
  <div style="font-family:arial,sans-serif; font-size:10px; margin:0; line-height:14px; color:#7e7e7e;"> Ceci est un message automatique
119
  color:#7e7e7e;"> <strong style="color:#2f8bee;">SendinBlue</strong></div>
120
  <div style="font-family:arial,sans-serif;
121
  font-size:12px; margin:0; line-height:16px;
122
+ color:#7e7e7e;"> 59 rue Beaubourg</div>
123
  <div style="font-family:arial,sans-serif;
124
  font-size:12px; margin:0; line-height:16px;
125
+ color:#7e7e7e;"> 75003 Paris - France</div>
126
  <div style="font-family:arial,sans-serif;
127
  font-size:12px; margin:0; line-height:16px;
128
  color:#7e7e7e;"> T&eacute;l : 0899 25 30 61</div>
135
  <td align="right" valign="top">
136
  <div style="font-family:arial,sans-serif; font-size:12px; margin:0; line-height:20px; color:#7e7e7e;">
137
  <a href="http://www.facebook.com/SendinBlue" style="color:#2f8bee; text-decoration:none;" target="_blank"> <img alt="Facebook" src="https://my.sendinblue.com/public/upload/14406/images/523693143fe88.gif" style="border:none;"> </a> <a href="https://twitter.com/SendinBlue" style="color:#2f8bee; text-decoration:none;" target="_blank"> <img alt="Twitter" src="https://my.sendinblue.com/public/upload/14406/images/5236931746c01.gif" style="border:none;"> </a> <a href="http://www.linkedin.com/company/mailin" style="color:#2f8bee; text-decoration:none;" target="_blank"> <img alt="Linkedin" src="https://my.sendinblue.com/public/upload/14406/images/5236931ad253b.gif" style="border:none;"> </a> <a href="http://sendinblue.tumblr.com/" style="color:#2f8bee; text-decoration:none;" target="_blank">Blog</a></div>
138
+ <div style="font-family:arial,sans-serif; font-size:10px; margin:0; line-height:14px; color:#7e7e7e;"> &copy; 2014-2015 SendinBlue, tous droits
139
  r&eacute;serv&eacute;s.
140
  </div>
141
  <div style="font-family:arial,sans-serif; font-size:10px; margin:0; line-height:14px; color:#7e7e7e;"> Ceci est un message automatique
package.xml CHANGED
@@ -1,28 +1,28 @@
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>
28
  </package>
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Sendinblue</name>
4
+ <version>1.2.4</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="magecommunity"><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="Psmailin.php" hash="735ede0b7d71a71e2ce82690937bf678"/><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"/><file name="doubleoptin_temp.html" hash="ec6aa9880db3cc1227ad87bf0e92f233"/>
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"/><file name="doubleoptin_temp.html" hash="1653f3195b1ef9e1e971c08df3b5ac04"/></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>
28
  </package>
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,19 @@ 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;}
301
+ .inner_manage_box {
302
+ display: none;
303
+ }
304
+ .radio_group_option label{width:auto;}
305
+ .radio_group_option input[type=radio]{float: left;margin-right: 5px;}
306
+ .radio_group_option .manage_subscribe_block{margin-bottom: 8px;}
307
+ .inner_manage_box{margin: 3px 0 0 20px;}
308
+ .manage_subscribe_block label{padding-right:5px;}
309
+ .clearfix{clear:both;width:100%;}
310
+ .tableblock tr td{padding:5px; border-bottom:0px;}
311
+
312
+ .manage_subscribe_block label{text-align:left; width: auto;}
skin/adminhtml/default/default/sendinblue/js/sendinblue.js CHANGED
@@ -11,33 +11,60 @@ jQuery.noConflict();
11
  jQuery(document)
12
  .ready(
13
  function() {
14
-
15
-
16
  var apistatuskey = jQuery('#apistatuskey').val();
17
-
18
  jQuery("#select").multiselect();
19
-
20
  jQuery(".sendin_api_status").click(function()
21
- {
22
  if (apistatuskey == 1 && jQuery(this).val() == 1)
23
- {
24
-
25
  jQuery("#sendin_apikey").show();
26
  jQuery(".alldiv").show();
27
  jQuery(".hidetableblock").show();
28
-
29
- }
30
  else{
31
  if(jQuery(this).val() == 1)
32
  {
33
- jQuery("#sendin_apikey").show();
34
  }else{
35
  jQuery("#sendin_apikey").hide();
36
  jQuery(".alldiv").hide();
37
  }
38
- }
39
-
40
  });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
41
  function loadData(page) {
42
  var ajaxcontentUrl = jQuery("#ajaxcontentUrl").val();
43
  jQuery.ajax({
@@ -59,26 +86,19 @@ jQuery(document)
59
  });
60
  }
61
  });
62
-
63
-
64
-
65
  }
66
 
67
  jQuery('.hdtab').click(function(){
68
- if(parseInt(jQuery(this).val())) { jQuery('#hidetabselect').css('display','block');}
69
-
70
  });
71
-
72
 
73
  jQuery('body').on('click',' .pagination li.active',function() {
74
  var page = jQuery(this).attr('p');
75
  jQuery('#pagenumber').val(page);
76
  loadData(page);
77
-
78
  });
79
 
80
-
81
- jQuery('.toolTip').hover(function () {
82
  var title = jQuery(this).attr('title');
83
  var offset = jQuery(this).offset();
84
 
@@ -95,24 +115,23 @@ jQuery(document)
95
  jQuery('#sender_order').mouseover(function () {
96
  var val = jQuery(this).val();
97
  if(isInteger(val) || val == ''){
98
- jQuery("#sender_order").attr('maxlength','17');
99
- jQuery('#sender_order_text').text((17 - val.length));
100
 
101
  }
102
  else{
103
  jQuery("#sender_order").attr('maxlength','11');
104
  var str7 = val.length > 11 ? val.substr(1,11) : val;
105
  jQuery("#sender_order").val(str7);
106
- jQuery('#sender_order_text').text((11 - val.length));
107
-
108
- }
109
  });
110
 
111
  jQuery('#sender_order').keyup(function () {
112
  var val = jQuery(this).val();
113
  if(isInteger(val) || val == ''){
114
- jQuery("#sender_order").attr('maxlength','17');
115
- jQuery('#sender_order_text').text((17 - val.length));
116
 
117
  }
118
  else{
@@ -124,129 +143,119 @@ jQuery(document)
124
  }
125
  });
126
 
 
 
 
 
 
127
 
128
 
129
  if(jQuery('#sender_order').val() != '')
130
  {
131
  var val = jQuery('#sender_order').val();
132
  if(isInteger(val)){
133
- jQuery("#sender_order").attr('maxlength','17');
134
- jQuery('#sender_order_text').text((17 - val.length));
135
 
136
  }
137
  else{
138
  jQuery("#sender_order").attr('maxlength','11');
139
- jQuery('#sender_order_text').text((11 - val.length));
140
-
141
  }
142
  }
143
-
144
  jQuery('#sender_order_message').keyup(function () {
145
-
146
- var chars = this.value.length,
147
  messages = Math.ceil(chars / 160),
148
- remaining = messages * 160 - (chars % (messages * 160) || messages * 160);
149
- if(remaining == 0)
150
- {
151
- remaining = 160.
152
- }
153
 
154
  jQuery('#sender_order_message_text').text(remaining);
155
 
156
  jQuery('#sender_order_message_text_count').text(messages);
157
-
158
  });
159
 
160
  if(jQuery('#sender_order_message').val() != '')
161
  {
162
  var chars = jQuery('#sender_order_message').val().length,
163
  messages = Math.ceil(chars / 160),
164
- remaining = messages * 160 - (chars % (messages * 160) || messages * 160);
165
 
166
  jQuery('#sender_order_message_text').text(remaining);
167
 
168
  jQuery('#sender_order_message_text_count').text(messages);
169
  }
170
-
171
  jQuery('#sender_shipment').mouseover(function () {
172
  var val = jQuery(this).val();
173
 
174
  if(isInteger(val) || val == ''){
175
- jQuery("#sender_shipment").attr('maxlength','17');
176
- jQuery('#sender_shipment_text').text((17 - val.length));
177
-
178
  }
179
  else{
180
  jQuery("#sender_shipment").attr('maxlength','11');
181
  var str7 = val.length > 11 ? val.substr(1,11) : val;
182
  jQuery("#sender_shipment").val(str7);
183
- jQuery('#sender_shipment_text').text((11 - val.length));
184
-
185
  }
186
  });
187
  jQuery('#sender_shipment').keyup(function () {
188
- var val = jQuery(this).val();
189
-
190
  if(isInteger(val) || val == ''){
191
- jQuery("#sender_shipment").attr('maxlength','17');
192
- jQuery('#sender_shipment_text').text((17 - val.length));
193
-
194
  }
195
  else{
196
  jQuery("#sender_shipment").attr('maxlength','11');
197
  var str7 = val.length > 11 ? val.substr(1,11) : val;
198
  jQuery("#sender_shipment").val(str7);
199
- jQuery('#sender_shipment_text').text((11 - val.length));
200
-
201
  }
202
  });
203
-
 
 
 
 
 
204
  if(jQuery('#sender_shipment').val() != '')
205
  {
206
  var val = jQuery('#sender_shipment').val();
207
  if(isInteger(val)){
208
- jQuery("#sender_shipment").attr('maxlength','17');
209
- jQuery('#sender_shipment_text').text((17 - val.length));
210
-
211
  }
212
  else{
213
  jQuery("#sender_shipment").attr('maxlength','11');
214
- jQuery('#sender_shipment_text').text((11 - val.length));
215
-
216
  }
217
  }
218
-
219
  jQuery('#sender_shipment_message').keyup(function () {
220
 
221
  var chars = this.value.length,
222
  messages = Math.ceil(chars / 160),
223
- remaining = messages * 160 - (chars % (messages * 160) || messages * 160);
224
- if(remaining == 0)
225
- {
226
- remaining = 160.
227
- }
228
- jQuery('#sender_shipment_message_text').text(remaining);
229
 
230
- jQuery('#sender_shipment_message_text_count').text(messages);
231
-
232
  });
233
-
234
  if(jQuery('#sender_shipment_message').val() != '')
235
  {
236
  var chars = jQuery('#sender_shipment_message').val().length,
237
  messages = Math.ceil(chars / 160),
238
- remaining = messages * 160 - (chars % (messages * 160) || messages * 160);
239
 
240
  jQuery('#sender_shipment_message_text').text(remaining);
241
-
242
  jQuery('#sender_shipment_message_text_count').text(messages);
243
  }
244
-
245
  jQuery('#sender_campaign').mouseover(function () {
246
  var val = jQuery(this).val();
247
  if(isInteger(val) || val == ''){
248
- jQuery("#sender_campaign").attr('maxlength','17');
249
- jQuery('#sender_campaign_text').text((17 - val.length));
250
 
251
  }
252
  else{
@@ -261,26 +270,28 @@ jQuery(document)
261
  var val = jQuery(this).val();
262
 
263
  if(isInteger(val) || val == ''){
264
- jQuery("#sender_campaign").attr('maxlength','17');
265
- jQuery('#sender_campaign_text').text((17 - val.length));
266
-
267
  }
268
  else{
269
  jQuery("#sender_campaign").attr('maxlength','11');
270
  var str7 = val.length > 11 ? val.substr(1,11) : val;
271
  jQuery("#sender_campaign").val(str7);
272
- jQuery('#sender_campaign_text').text((11 - val.length));
273
-
274
  }
275
  });
276
-
 
 
 
 
 
277
  if(jQuery('#sender_campaign').val() != '')
278
  {
279
- var val = jQuery('#sender_campaign').val();
280
-
281
  if(isInteger(val)){
282
- jQuery("#sender_campaign").attr('maxlength','17');
283
- jQuery('#sender_campaign_text').text((17 - val.length));
284
  }
285
  else{
286
  jQuery("#sender_campaign").attr('maxlength','11');
@@ -293,15 +304,11 @@ jQuery(document)
293
  var chars = this.value.length,
294
  messages = Math.ceil(chars / 160),
295
  remaining = messages * 160 - (chars % (messages * 160) || messages * 160);
296
- if(remaining == 0)
297
- {
298
- remaining = 160.
299
- }
300
  jQuery('#sender_campaign_message_text').text(remaining);
301
- jQuery('#sender_campaign_message_text_count').text(messages);
302
-
303
  });
304
-
305
  if(jQuery('#sender_campaign_message').val() != '')
306
  {
307
  var chars = jQuery('#sender_campaign_message').val().length,
@@ -309,10 +316,9 @@ jQuery(document)
309
  remaining = messages * 160 - (chars % (messages * 160) || messages * 160);
310
 
311
  jQuery('#sender_campaign_message_text').text(remaining);
312
-
313
  jQuery('#sender_campaign_message_text_count').text(messages);
314
  }
315
-
316
  jQuery(".sms_order_setting").click(function () {
317
  var orderSetting = jQuery(this).val();
318
  var orderUrl = jQuery("#order").val();
@@ -333,13 +339,13 @@ jQuery(document)
333
  jQuery(".hideOrder").hide();
334
  }
335
  }
336
- });
337
-
338
  });
 
339
  jQuery(".sms_shiping_setting").click(function () {
340
  var shipingSetting = jQuery(this).val();
341
  var shipingUrl = jQuery("#shiping").val();
342
-
343
  jQuery.ajax({
344
  type: "POST",
345
  async: false,
@@ -357,7 +363,6 @@ jQuery(document)
357
  }
358
  }
359
  });
360
-
361
  });
362
 
363
  jQuery(".sms_campaign_setting").click(function () {
@@ -380,10 +385,9 @@ jQuery(document)
380
  jQuery(".hideCampaign").hide();
381
  }
382
  }
383
- });
384
-
385
  });
386
-
387
  if (jQuery('input:radio[name=sms_order_setting]:checked').val() == 0)
388
  {
389
  jQuery('.hideOrder').hide();
@@ -392,7 +396,7 @@ jQuery(document)
392
  }
393
 
394
  jQuery(".Sendin_Sms_Choice").click(function ()
395
- {
396
  if (jQuery(this).val() == 1) {
397
  jQuery(".multiplechoice").hide();
398
  jQuery(".singlechoice").show();
@@ -401,6 +405,14 @@ jQuery(document)
401
  jQuery(".singlechoice").hide();
402
  }
403
  });
 
 
 
 
 
 
 
 
404
 
405
  if (jQuery('input:radio[name=Sendin_Sms_Choice]:checked').val() == 0)
406
  {
@@ -418,15 +430,13 @@ jQuery(document)
418
  } else {
419
  jQuery(".hideShiping").hide();
420
  }
421
- });
422
-
423
-
424
  if (jQuery('input:radio[name=sms_credit]:checked').val() == 0)
425
  jQuery(".hideCredit").hide();
426
  else
427
  jQuery(".hideCredit").show();
428
-
429
-
430
  jQuery(".sms_credit").click(function (){
431
 
432
  var sms_credit = jQuery(this).val();
@@ -503,252 +513,296 @@ jQuery(document)
503
  return true
504
  }
505
  return false;
506
- }
507
-
508
-
509
- jQuery('#showUserlist').click(function(){
510
-
511
- if(jQuery('.userDetails').is(':hidden'))
512
- {
513
- loadData(1);
514
- jQuery('#Spantextless').show();
515
- jQuery('#Spantextmore').hide();
516
- }else
517
- {
518
- jQuery('#Spantextmore').show();
519
- jQuery('#Spantextless').hide();
520
- }
521
- jQuery('.userDetails').slideToggle();
522
- });
523
-
524
- var base_url = getBaseURL();
525
 
526
- jQuery(".Tracking").click(function()
527
- {
528
- var Tracking = jQuery(this).val();
529
- var trackingUrl = jQuery("#trackingUrl").val();
530
- jQuery.ajax({
531
- type : "POST",
532
- async : false,
533
- url : trackingUrl,
534
- data : "script=" + Tracking,
535
- beforeSend : function(){
536
- jQuery('#ajax-busy').show();
537
- },
538
- success : function(msg){
539
- jQuery('#ajax-busy').hide();
540
- }
541
- });
542
- });
543
-
544
-
545
-
546
-
547
- jQuery(".smtpStatus").click(function() {
548
-
549
- var smtptest = jQuery(this).val();
550
- var smtpUrl = jQuery("#smtpUrl").val();
551
- if (smtptest == 0) {
552
- jQuery('.smtptest').hide();
553
- }
554
- if (smtptest == 1) {
555
- jQuery('.smtptest').show();
556
- }
557
- jQuery.ajax({
558
- type : "POST",
559
- async : false,
560
- url : smtpUrl,
561
- data : "smtptest=" + smtptest,
562
- beforeSend : function() {
563
- jQuery('#ajax-busy').show();
564
- },
565
- success : function(msg) {
566
- jQuery('#ajax-busy').hide();
567
- }
568
- });
569
- });
570
-
571
-
572
- var skin_url = jQuery('#skin_url').val()
573
- jQuery('<div id="ajax-busy"/> loading..')
574
- .css(
575
- {
576
- opacity : 0.5,
577
- position : 'fixed',
578
- top : 0,
579
- left : 0,
580
- width : '100%',
581
- height : jQuery(window).height() + 'px',
582
- background : 'white url('+skin_url+'adminhtml/default/default/sendinblue/images/loader.gif) no-repeat center'
583
- }).hide().appendTo('body');
584
-
585
- // get site base url
586
- function getBaseURL() {
587
- var sBase = location.href.substr(0, location.href.lastIndexOf("/") + 1);
588
- var sp = sBase.split('/');
589
- var lastFolder = sp[ sp.length - 2 ];
590
- return sBase.replace(lastFolder+'/', '');
591
- }
592
-
593
-
594
-
595
- jQuery('body').on('click', '.ajax_contacts_href', function (e) {
596
-
597
- var email = jQuery(this).attr('email');
598
- var status = jQuery(this).attr('status');
599
- var ajaxUrl = jQuery("#ajaxUrl").val();
600
-
601
- jQuery.ajax({
602
- type : "POST",
603
- async : false,
604
- url : ajaxUrl,
605
- data : {"email":email,"newsletter":status},
606
- beforeSend : function() {
607
- jQuery('#ajax-busy').show();
608
- },
609
- success : function(msg) {
610
- jQuery('#ajax-busy').hide();
611
- }
612
- });
613
-
614
- var page_no = jQuery('#pagenumber').val();
615
- loadData(page_no); // For first time page load
616
-
617
- });
618
-
619
- });
620
-
621
- function testsmssend(sendererr,messageerr,mobileerr) {
622
- var sender = jQuery('#sender_order').val();
623
- var message =jQuery('#sender_order_message').val();
624
- var number = jQuery("#sender_order_number").val();
625
- var ajaxOrderSmsUrl = jQuery('#ajaxOrderSmsUrl').val();
626
- var smsCampError = jQuery("#smsCampError").val();
627
- var smsCampSuccess = jQuery("#smsCampSuccess").val();
628
- if(sender == '' || isValid(sender) == false)
629
  {
630
- alert(sendererr);
631
- }
632
- else if( message == '')
 
633
  {
634
- alert(messageerr);
 
635
  }
636
- else if(number == '')
637
- {
638
- alert(mobileerr);
 
 
 
 
 
 
 
 
 
 
 
639
  }
640
- else {
641
  jQuery.ajax({
642
  type : "POST",
643
  async : false,
644
- url : ajaxOrderSmsUrl,
645
- data : {"sender":sender,"message":message,"number":number} ,
646
- beforeSend : function() {
647
  jQuery('#ajax-busy').show();
648
  },
649
- success : function(msg) {
650
  jQuery('#ajax-busy').hide();
651
- if(msg.trim() == 'OK')
652
- { alert(smsCampSuccess); }
653
- else { alert(smsCampError); }
654
  }
655
- });}
656
- return false;
657
- }
658
-
659
- function testShippedSmsSend(sendererr,messageerr,mobileerr) {
660
-
661
- var sender = jQuery('#sender_shipment').val();
662
- var message =jQuery('#sender_shipment_message').val();
663
- var number = jQuery("#sender_shipment_number").val();
664
- var ajaxOrderShippedUrl = jQuery('#ajaxOrderShippedUrl').val();
665
- var smsCampError = jQuery("#smsCampError").val();
666
- var smsCampSuccess = jQuery("#smsCampSuccess").val();
667
- if(sender == '' || isValid(sender) == false)
668
- {
669
- alert(sendererr);
670
- }
671
- else if( message == '')
672
- {
673
- alert(messageerr);
674
- }
675
- else if(number == '')
676
- {
677
- alert(mobileerr);
678
- }
679
- else {
680
- jQuery.ajax({
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
681
  type : "POST",
682
  async : false,
683
- url : ajaxOrderShippedUrl,
684
- data : {"sender":sender,"message":message,"number":number} ,
685
  beforeSend : function() {
686
  jQuery('#ajax-busy').show();
687
  },
688
  success : function(msg) {
689
- jQuery('#ajax-busy').hide();
690
- if(msg.trim() == 'OK')
691
- { alert(smsCampSuccess); }
692
- else { alert(smsCampError); }
693
  }
694
- });}
695
- return false;
696
- }
697
- function testCampaignSmsSend(sendererr,messageerr,mobileerr) {
698
-
699
- var sender = jQuery('#sender_campaign').val();
700
- var message =jQuery('#sender_campaign_message').val();
701
- var number = jQuery("#sender_campaigntest_number").val();
702
- var ajaxSmsCampaignUrl = jQuery('#ajaxSmsCampaignUrl').val();
703
- var smsCampError = jQuery("#smsCampError").val();
704
- var smsCampSuccess = jQuery("#smsCampSuccess").val();
705
-
706
- if(sender == '' || isValid(sender) == false)
707
- {
708
- alert(sendererr);
709
- }
710
- else if( message == '')
711
- {
712
- alert(messageerr);
 
 
 
713
  }
714
- else if(number == '' || isMobilevalidation(number) == false)
715
- {
716
- alert(mobileerr);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
717
  }
718
- else {
719
- jQuery.ajax({
720
- type : "POST",
721
- async : false,
722
- url : ajaxSmsCampaignUrl,
723
- data : {"sender":sender,"message":message,"number":number} ,
724
- beforeSend : function() {
725
- jQuery('#ajax-busy').show();
726
- },
727
- success : function(msg) {
728
- jQuery('#ajax-busy').hide();
729
- if(msg.trim() == 'OK')
730
- { alert(smsCampSuccess); }
731
- else { alert(smsCampError); }
732
- }
733
- });}
734
- return false;
 
 
 
 
 
735
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
736
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
737
  function senderOrderSaveValid(sendererr,messageerr)
738
  {
739
  var sender = jQuery('#sender_order').val();
740
  var message =jQuery('#sender_order_message').val();
741
  if(sender == '' || isValid(sender) == false)
742
- {
743
- alert(sendererr);
744
- return false;
745
- }
746
- else if( message == '')
747
- {
748
- alert(messageerr);
749
- return false;
750
- }
751
  }
 
752
  function senderShipmentSaveValid(sendererr,messageerr)
753
  {
754
  var sender = jQuery('#sender_shipment').val();
@@ -764,52 +818,55 @@ function senderShipmentSaveValid(sendererr,messageerr)
764
  return false;
765
  }
766
  }
 
767
  function senderCampaignSaveValid(sendererr,messageerr,mobileerr)
768
  {
769
- var sender = jQuery('#sender_campaign').val();
770
- var message =jQuery('#sender_campaign_message').val();
771
- var number = jQuery("#singlechoice").val();
772
- var radiovalue = jQuery("input[name=Sendin_Sms_Choice]:checked").val();
773
- if(radiovalue == 1)
774
- {
775
- if(number == '' || isMobilevalidation(number) == false)
776
- {
777
- alert(mobileerr);
778
- return false;
779
- }
780
- else if(sender == '' || isValid(sender) == false)
781
- {
782
- alert(sendererr);
783
- return false;
784
- }
785
- else if(message == '')
786
- {
787
- alert(messageerr);
788
- return false;
789
- }
790
- }
791
- else{
792
- if(sender == '' || isValid(sender) == false)
793
- {
794
- alert(sendererr);
795
- return false;
796
- }
797
- else if(message == '')
798
- {
799
- alert(messageerr);
800
- return false;
801
- }
802
- }
803
  }
804
 
805
  function isMobilevalidation(str)
806
  {
807
  return /^(?:\+|00)[1-9][0-9]{5,15}$/.test(str);
808
- }
 
809
  function isNormalInteger(str)
810
  {
811
  return /^\+?(0|[1-9]\d*)$/.test(str);
812
  }
 
813
  function isValid(str) {
814
  var iChars = "~`!#$%^&*+=-[]\\\';,/{}|\":<>?";
815
 
@@ -820,16 +877,16 @@ function isValid(str) {
820
  }
821
  return true;
822
  }
 
823
  function RegexEmail(email)
824
  {
825
  var emailRegexStr = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/;
826
  var isvalid = emailRegexStr.test(email);
827
  return isvalid;
828
  }
 
829
  function validate(emailerr,limiter)
830
  {
831
-
832
-
833
  if( document.notify_sms_mail_form.sendin_notify_email.value == "" || RegexEmail(document.notify_sms_mail_form.sendin_notify_email.value) == false )
834
  {
835
  alert(emailerr);
@@ -843,11 +900,12 @@ function validate(emailerr,limiter)
843
  document.notify_sms_mail_form.sendin_notify_value.focus() ;
844
  return false;
845
  }
846
-
847
  return( true );
848
- }
 
849
  function smtpvalidate(emailerr)
850
- {
851
  var email = jQuery('#email').val();
852
  if(email == "" || RegexEmail(email) == false )
853
  {
@@ -855,16 +913,17 @@ function smtpvalidate(emailerr)
855
  jQuery('#email').focus();
856
  return false;
857
  }
858
- }
 
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();
867
- return false;
868
- }
869
-
870
- }
11
  jQuery(document)
12
  .ready(
13
  function() {
 
 
14
  var apistatuskey = jQuery('#apistatuskey').val();
15
+
16
  jQuery("#select").multiselect();
17
+
18
  jQuery(".sendin_api_status").click(function()
19
+ {
20
  if (apistatuskey == 1 && jQuery(this).val() == 1)
21
+ {
 
22
  jQuery("#sendin_apikey").show();
23
  jQuery(".alldiv").show();
24
  jQuery(".hidetableblock").show();
25
+ }
 
26
  else{
27
  if(jQuery(this).val() == 1)
28
  {
29
+ jQuery("#sendin_apikey").show();
30
  }else{
31
  jQuery("#sendin_apikey").hide();
32
  jQuery(".alldiv").hide();
33
  }
34
+ }
 
35
  });
36
+
37
+
38
+ //date picker function
39
+ jQuery('#sib_datetimepicker').datepicker({ dateFormat: 'yy-mm-dd' });
40
+ //Double optin function
41
+ jQuery('.manage_subscribe_block input[name=subscribe_confirm_type]').click(function(){
42
+ jQuery('.manage_subscribe_block .inner_manage_box').slideUp();
43
+ jQuery(this).parents('.manage_subscribe_block').find('.inner_manage_box').slideDown();
44
+
45
+ });
46
+
47
+ jQuery('.openCollapse').each(function(){
48
+ if(!jQuery(this).is(":checked")){
49
+ jQuery(this).parent('.form-group').find('.collapse').hide();
50
+ }
51
+ });
52
+
53
+ jQuery('input[name=subscribe_confirm_type]').each(function(){
54
+ if(jQuery(this).is(":checked")){
55
+ jQuery(this).parents('.manage_subscribe_block').find('.inner_manage_box').show();
56
+ }
57
+ });
58
+
59
+ jQuery('.openCollapse').click(function() {
60
+
61
+ if (jQuery(this).is(":checked")){
62
+ jQuery(this).parent('.form-group').find('.collapse').slideDown();
63
+ } else {
64
+ jQuery(this).parent('.form-group').find('.collapse').slideUp();
65
+ }
66
+ });
67
+
68
  function loadData(page) {
69
  var ajaxcontentUrl = jQuery("#ajaxcontentUrl").val();
70
  jQuery.ajax({
86
  });
87
  }
88
  });
 
 
 
89
  }
90
 
91
  jQuery('.hdtab').click(function(){
92
+ if(parseInt(jQuery(this).val())) { jQuery('#hidetabselect').css('display','block');}
 
93
  });
 
94
 
95
  jQuery('body').on('click',' .pagination li.active',function() {
96
  var page = jQuery(this).attr('p');
97
  jQuery('#pagenumber').val(page);
98
  loadData(page);
 
99
  });
100
 
101
+ jQuery('.toolTip').hover(function () {
 
102
  var title = jQuery(this).attr('title');
103
  var offset = jQuery(this).offset();
104
 
115
  jQuery('#sender_order').mouseover(function () {
116
  var val = jQuery(this).val();
117
  if(isInteger(val) || val == ''){
118
+ jQuery("#sender_order").attr('maxlength','11');
119
+ jQuery('#sender_order_text').text((11 - val.length));
120
 
121
  }
122
  else{
123
  jQuery("#sender_order").attr('maxlength','11');
124
  var str7 = val.length > 11 ? val.substr(1,11) : val;
125
  jQuery("#sender_order").val(str7);
126
+ jQuery('#sender_order_text').text((11 - val.length));
127
+ }
 
128
  });
129
 
130
  jQuery('#sender_order').keyup(function () {
131
  var val = jQuery(this).val();
132
  if(isInteger(val) || val == ''){
133
+ jQuery("#sender_order").attr('maxlength','11');
134
+ jQuery('#sender_order_text').text((11 - val.length));
135
 
136
  }
137
  else{
143
  }
144
  });
145
 
146
+ jQuery("#sender_order").keydown(function (event) {
147
+ if (event.keyCode == 32) {
148
+ event.preventDefault();
149
+ }
150
+ });
151
 
152
 
153
  if(jQuery('#sender_order').val() != '')
154
  {
155
  var val = jQuery('#sender_order').val();
156
  if(isInteger(val)){
157
+ jQuery("#sender_order").attr('maxlength','11');
158
+ jQuery('#sender_order_text').text((11 - val.length));
159
 
160
  }
161
  else{
162
  jQuery("#sender_order").attr('maxlength','11');
163
+ jQuery('#sender_order_text').text((11 - val.length));
 
164
  }
165
  }
166
+
167
  jQuery('#sender_order_message').keyup(function () {
168
+ var chars = this.value.length,
 
169
  messages = Math.ceil(chars / 160),
170
+ remaining = messages * 160 - chars;
 
 
 
 
171
 
172
  jQuery('#sender_order_message_text').text(remaining);
173
 
174
  jQuery('#sender_order_message_text_count').text(messages);
 
175
  });
176
 
177
  if(jQuery('#sender_order_message').val() != '')
178
  {
179
  var chars = jQuery('#sender_order_message').val().length,
180
  messages = Math.ceil(chars / 160),
181
+ remaining = messages * 160 - chars;
182
 
183
  jQuery('#sender_order_message_text').text(remaining);
184
 
185
  jQuery('#sender_order_message_text_count').text(messages);
186
  }
187
+
188
  jQuery('#sender_shipment').mouseover(function () {
189
  var val = jQuery(this).val();
190
 
191
  if(isInteger(val) || val == ''){
192
+ jQuery("#sender_shipment").attr('maxlength','11');
193
+ jQuery('#sender_shipment_text').text((11 - val.length));
 
194
  }
195
  else{
196
  jQuery("#sender_shipment").attr('maxlength','11');
197
  var str7 = val.length > 11 ? val.substr(1,11) : val;
198
  jQuery("#sender_shipment").val(str7);
199
+ jQuery('#sender_shipment_text').text((11 - val.length));
 
200
  }
201
  });
202
  jQuery('#sender_shipment').keyup(function () {
203
+ var val = jQuery(this).val();
 
204
  if(isInteger(val) || val == ''){
205
+ jQuery("#sender_shipment").attr('maxlength','11');
206
+ jQuery('#sender_shipment_text').text((11 - val.length));
 
207
  }
208
  else{
209
  jQuery("#sender_shipment").attr('maxlength','11');
210
  var str7 = val.length > 11 ? val.substr(1,11) : val;
211
  jQuery("#sender_shipment").val(str7);
212
+ jQuery('#sender_shipment_text').text((11 - val.length));
 
213
  }
214
  });
215
+ jQuery("#sender_shipment").keydown(function (event) {
216
+ if (event.keyCode == 32) {
217
+ event.preventDefault();
218
+ }
219
+ });
220
+
221
  if(jQuery('#sender_shipment').val() != '')
222
  {
223
  var val = jQuery('#sender_shipment').val();
224
  if(isInteger(val)){
225
+ jQuery("#sender_shipment").attr('maxlength','11');
226
+ jQuery('#sender_shipment_text').text((11 - val.length));
 
227
  }
228
  else{
229
  jQuery("#sender_shipment").attr('maxlength','11');
230
+ jQuery('#sender_shipment_text').text((11 - val.length));
 
231
  }
232
  }
233
+
234
  jQuery('#sender_shipment_message').keyup(function () {
235
 
236
  var chars = this.value.length,
237
  messages = Math.ceil(chars / 160),
238
+ remaining = messages * 160 - chars;
 
 
 
 
 
239
 
240
+ jQuery('#sender_shipment_message_text').text(remaining);
241
+ jQuery('#sender_shipment_message_text_count').text(messages);
242
  });
243
+
244
  if(jQuery('#sender_shipment_message').val() != '')
245
  {
246
  var chars = jQuery('#sender_shipment_message').val().length,
247
  messages = Math.ceil(chars / 160),
248
+ remaining = messages * 160 - chars;
249
 
250
  jQuery('#sender_shipment_message_text').text(remaining);
 
251
  jQuery('#sender_shipment_message_text_count').text(messages);
252
  }
253
+
254
  jQuery('#sender_campaign').mouseover(function () {
255
  var val = jQuery(this).val();
256
  if(isInteger(val) || val == ''){
257
+ jQuery("#sender_campaign").attr('maxlength','11');
258
+ jQuery('#sender_campaign_text').text((11 - val.length));
259
 
260
  }
261
  else{
270
  var val = jQuery(this).val();
271
 
272
  if(isInteger(val) || val == ''){
273
+ jQuery("#sender_campaign").attr('maxlength','11');
274
+ jQuery('#sender_campaign_text').text((11 - val.length));
 
275
  }
276
  else{
277
  jQuery("#sender_campaign").attr('maxlength','11');
278
  var str7 = val.length > 11 ? val.substr(1,11) : val;
279
  jQuery("#sender_campaign").val(str7);
280
+ jQuery('#sender_campaign_text').text((11 - val.length));
 
281
  }
282
  });
283
+ jQuery("#sender_campaign").keydown(function (event) {
284
+ if (event.keyCode == 32) {
285
+ event.preventDefault();
286
+ }
287
+ });
288
+
289
  if(jQuery('#sender_campaign').val() != '')
290
  {
291
+ var val = jQuery('#sender_campaign').val();
 
292
  if(isInteger(val)){
293
+ jQuery("#sender_campaign").attr('maxlength','11');
294
+ jQuery('#sender_campaign_text').text((11 - val.length));
295
  }
296
  else{
297
  jQuery("#sender_campaign").attr('maxlength','11');
304
  var chars = this.value.length,
305
  messages = Math.ceil(chars / 160),
306
  remaining = messages * 160 - (chars % (messages * 160) || messages * 160);
307
+
 
 
 
308
  jQuery('#sender_campaign_message_text').text(remaining);
309
+ jQuery('#sender_campaign_message_text_count').text(messages);
 
310
  });
311
+
312
  if(jQuery('#sender_campaign_message').val() != '')
313
  {
314
  var chars = jQuery('#sender_campaign_message').val().length,
316
  remaining = messages * 160 - (chars % (messages * 160) || messages * 160);
317
 
318
  jQuery('#sender_campaign_message_text').text(remaining);
 
319
  jQuery('#sender_campaign_message_text_count').text(messages);
320
  }
321
+
322
  jQuery(".sms_order_setting").click(function () {
323
  var orderSetting = jQuery(this).val();
324
  var orderUrl = jQuery("#order").val();
339
  jQuery(".hideOrder").hide();
340
  }
341
  }
342
+ });
 
343
  });
344
+
345
  jQuery(".sms_shiping_setting").click(function () {
346
  var shipingSetting = jQuery(this).val();
347
  var shipingUrl = jQuery("#shiping").val();
348
+
349
  jQuery.ajax({
350
  type: "POST",
351
  async: false,
363
  }
364
  }
365
  });
 
366
  });
367
 
368
  jQuery(".sms_campaign_setting").click(function () {
385
  jQuery(".hideCampaign").hide();
386
  }
387
  }
388
+ });
 
389
  });
390
+
391
  if (jQuery('input:radio[name=sms_order_setting]:checked').val() == 0)
392
  {
393
  jQuery('.hideOrder').hide();
396
  }
397
 
398
  jQuery(".Sendin_Sms_Choice").click(function ()
399
+ {
400
  if (jQuery(this).val() == 1) {
401
  jQuery(".multiplechoice").hide();
402
  jQuery(".singlechoice").show();
405
  jQuery(".singlechoice").hide();
406
  }
407
  });
408
+ jQuery(".Sendin_Sms_Choice").click(function ()
409
+ {
410
+ if (jQuery(this).val() == 2) {
411
+ jQuery(".sib_datepicker").show();
412
+ } else {
413
+ jQuery(".sib_datepicker").hide();
414
+ }
415
+ });
416
 
417
  if (jQuery('input:radio[name=Sendin_Sms_Choice]:checked').val() == 0)
418
  {
430
  } else {
431
  jQuery(".hideShiping").hide();
432
  }
433
+ });
434
+
 
435
  if (jQuery('input:radio[name=sms_credit]:checked').val() == 0)
436
  jQuery(".hideCredit").hide();
437
  else
438
  jQuery(".hideCredit").show();
439
+
 
440
  jQuery(".sms_credit").click(function (){
441
 
442
  var sms_credit = jQuery(this).val();
513
  return true
514
  }
515
  return false;
516
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
517
 
518
+ jQuery('#showUserlist').click(function(){
519
+
520
+ if(jQuery('.userDetails').is(':hidden'))
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
521
  {
522
+ loadData(1);
523
+ jQuery('#Spantextless').show();
524
+ jQuery('#Spantextmore').hide();
525
+ }else
526
  {
527
+ jQuery('#Spantextmore').show();
528
+ jQuery('#Spantextless').hide();
529
  }
530
+ jQuery('.userDetails').slideToggle();
531
+ });
532
+
533
+ var base_url = getBaseURL();
534
+
535
+ jQuery(".Tracking").click(function()
536
+ {
537
+ var Tracking = jQuery(this).val();
538
+ var trackingUrl = jQuery("#trackingUrl").val();
539
+ if (Tracking == 0) {
540
+ jQuery('.ordertracking').hide();
541
+ }
542
+ if (Tracking == 1) {
543
+ jQuery('.ordertracking').show();
544
  }
 
545
  jQuery.ajax({
546
  type : "POST",
547
  async : false,
548
+ url : trackingUrl,
549
+ data : "script=" + Tracking,
550
+ beforeSend : function(){
551
  jQuery('#ajax-busy').show();
552
  },
553
+ success : function(msg){
554
  jQuery('#ajax-busy').hide();
 
 
 
555
  }
556
+ });
557
+ });
558
+
559
+ //for import old order history
560
+ jQuery(".Trackhistory").click(function()
561
+ {
562
+ var history_status = jQuery("#history_status").val();
563
+ var langvalue = jQuery("#langvalue").val();
564
+ var ordertrackingUrl = jQuery("#importordertrackingUrl").val();
565
+
566
+ jQuery.ajax({
567
+ type : "POST",
568
+ async : false,
569
+ url : ordertrackingUrl,
570
+ data : {"history_status":history_status,"langvalue":langvalue},
571
+ beforeSend : function(){
572
+ jQuery('#ajax-busy').show();
573
+ },
574
+ success : function(msg){
575
+ jQuery('#ajax-busy').hide();
576
+ jQuery('.ordertracking').hide();
577
+ alert(msg);
578
+ }
579
+ });
580
+ });
581
+
582
+ jQuery(".smtpStatus").click(function() {
583
+
584
+ var smtptest = jQuery(this).val();
585
+ var smtpUrl = jQuery("#smtpUrl").val();
586
+ if (smtptest == 0) {
587
+ jQuery('.smtptest').hide();
588
+ }
589
+ if (smtptest == 1) {
590
+ jQuery('.smtptest').show();
591
+ }
592
+ jQuery.ajax({
593
+ type : "POST",
594
+ async : false,
595
+ url : smtpUrl,
596
+ data : "smtptest=" + smtptest,
597
+ beforeSend : function() {
598
+ jQuery('#ajax-busy').show();
599
+ },
600
+ success : function(msg) {
601
+ jQuery('#ajax-busy').hide();
602
+ }
603
+ });
604
+ });
605
+
606
+ var skin_url = jQuery('#skin_url').val()
607
+ jQuery('<div id="ajax-busy"/> loading..')
608
+ .css(
609
+ {
610
+ opacity : 0.5,
611
+ position : 'fixed',
612
+ top : 0,
613
+ left : 0,
614
+ width : '100%',
615
+ height : jQuery(window).height() + 'px',
616
+ background : 'white url('+skin_url+'adminhtml/default/default/sendinblue/images/loader.gif) no-repeat center'
617
+ }).hide().appendTo('body');
618
+
619
+ // get site base url
620
+ function getBaseURL() {
621
+ var sBase = location.href.substr(0, location.href.lastIndexOf("/") + 1);
622
+ var sp = sBase.split('/');
623
+ var lastFolder = sp[ sp.length - 2 ];
624
+ return sBase.replace(lastFolder+'/', '');
625
+ }
626
+
627
+ jQuery('body').on('click', '.ajax_contacts_href', function (e) {
628
+ var email = jQuery(this).attr('email');
629
+ var status = jQuery(this).attr('status');
630
+ var ajaxUrl = jQuery("#ajaxUrl").val();
631
+
632
+ jQuery.ajax({
633
  type : "POST",
634
  async : false,
635
+ url : ajaxUrl,
636
+ data : {"email":email,"newsletter":status},
637
  beforeSend : function() {
638
  jQuery('#ajax-busy').show();
639
  },
640
  success : function(msg) {
641
+ jQuery('#ajax-busy').hide();
 
 
 
642
  }
643
+ });
644
+
645
+ var page_no = jQuery('#pagenumber').val();
646
+ loadData(page_no); // For first time page load
647
+ });
648
+
649
+ jQuery('body').on('click', '.ajax_sms_subs_href', function (e) {
650
+
651
+ var email = jQuery(this).attr('email');
652
+ var status = jQuery(this).attr('status');
653
+ var ajaxSmsUrl = jQuery("#ajaxSmsSubscribeUrl").val();
654
+
655
+ jQuery.ajax({
656
+ type : "POST",
657
+ async : false,
658
+ url : ajaxSmsUrl,
659
+ data : {"email":email,"sms":status},
660
+ beforeSend : function() {
661
+ jQuery('#ajax-busy').show();
662
+ },
663
+ success : function(msg) {
664
+ jQuery('#ajax-busy').hide();
665
  }
666
+ });
667
+
668
+ var page_no = jQuery('#pagenumber').val();
669
+ loadData(page_no); // For first time page load
670
+
671
+ });
672
+ });
673
+
674
+ function testsmssend(sendererr,messageerr,mobileerr) {
675
+ var sender = jQuery('#sender_order').val();
676
+ var message =jQuery('#sender_order_message').val();
677
+ var number = jQuery("#sender_order_number").val();
678
+ var ajaxOrderSmsUrl = jQuery('#ajaxOrderSmsUrl').val();
679
+ var smsCampError = jQuery("#smsCampError").val();
680
+ var smsCampSuccess = jQuery("#smsCampSuccess").val();
681
+ if(sender == '' || isValid(sender) == false)
682
+ {
683
+ alert(sendererr);
684
+ }
685
+ else if( message == '')
686
+ {
687
+ alert(messageerr);
688
+ }
689
+ else if(number == '')
690
+ {
691
+ alert(mobileerr);
692
+ }
693
+ else {
694
+ jQuery.ajax({
695
+ type : "POST",
696
+ async : false,
697
+ url : ajaxOrderSmsUrl,
698
+ data : {"sender":sender,"message":message,"number":number} ,
699
+ beforeSend : function() {
700
+ jQuery('#ajax-busy').show();
701
+ },
702
+ success : function(msg) {
703
+ jQuery('#ajax-busy').hide();
704
+ if(msg.trim() == 'OK')
705
+ { alert(smsCampSuccess); }
706
+ else { alert(smsCampError); }
707
  }
708
+ });}
709
+ return false;
710
+ }
711
+
712
+ function testShippedSmsSend(sendererr,messageerr,mobileerr) {
713
+ var sender = jQuery('#sender_shipment').val();
714
+ var message =jQuery('#sender_shipment_message').val();
715
+ var number = jQuery("#sender_shipment_number").val();
716
+ var ajaxOrderShippedUrl = jQuery('#ajaxOrderShippedUrl').val();
717
+ var smsCampError = jQuery("#smsCampError").val();
718
+ var smsCampSuccess = jQuery("#smsCampSuccess").val();
719
+ if(sender == '' || isValid(sender) == false)
720
+ {
721
+ alert(sendererr);
722
+ }
723
+ else if( message == '')
724
+ {
725
+ alert(messageerr);
726
+ }
727
+ else if(number == '')
728
+ {
729
+ alert(mobileerr);
730
  }
731
+ else {
732
+ jQuery.ajax({
733
+ type : "POST",
734
+ async : false,
735
+ url : ajaxOrderShippedUrl,
736
+ data : {"sender":sender,"message":message,"number":number} ,
737
+ beforeSend : function() {
738
+ jQuery('#ajax-busy').show();
739
+ },
740
+ success : function(msg) {
741
+ jQuery('#ajax-busy').hide();
742
+ if(msg.trim() == 'OK')
743
+ { alert(smsCampSuccess); }
744
+ else { alert(smsCampError); }
745
+ }
746
+ }); }
747
+ return false;
748
+ }
749
+
750
+ function testCampaignSmsSend(sendererr,messageerr,mobileerr) {
751
+
752
+ var sender = jQuery('#sender_campaign').val();
753
+ var message =jQuery('#sender_campaign_message').val();
754
+ var number = jQuery("#sender_campaigntest_number").val();
755
+ var ajaxSmsCampaignUrl = jQuery('#ajaxSmsCampaignUrl').val();
756
+ var smsCampError = jQuery("#smsCampError").val();
757
+ var smsCampSuccess = jQuery("#smsCampSuccess").val();
758
 
759
+ if(sender == '' || isValid(sender) == false)
760
+ {
761
+ alert(sendererr);
762
+ }
763
+ else if( message == '')
764
+ {
765
+ alert(messageerr);
766
+ }
767
+ else if(number == '' || isMobilevalidation(number) == false)
768
+ {
769
+ alert(mobileerr);
770
+ }
771
+ else {
772
+ jQuery.ajax({
773
+ type : "POST",
774
+ async : false,
775
+ url : ajaxSmsCampaignUrl,
776
+ data : {"sender":sender,"message":message,"number":number} ,
777
+ beforeSend : function() {
778
+ jQuery('#ajax-busy').show();
779
+ },
780
+ success : function(msg) {
781
+ jQuery('#ajax-busy').hide();
782
+ if(msg.trim() == 'OK')
783
+ { alert(smsCampSuccess); }
784
+ else { alert(smsCampError); }
785
+ }
786
+ });}
787
+ return false;
788
+ }
789
+
790
  function senderOrderSaveValid(sendererr,messageerr)
791
  {
792
  var sender = jQuery('#sender_order').val();
793
  var message =jQuery('#sender_order_message').val();
794
  if(sender == '' || isValid(sender) == false)
795
+ {
796
+ alert(sendererr);
797
+ return false;
798
+ }
799
+ else if( message == '')
800
+ {
801
+ alert(messageerr);
802
+ return false;
803
+ }
804
  }
805
+
806
  function senderShipmentSaveValid(sendererr,messageerr)
807
  {
808
  var sender = jQuery('#sender_shipment').val();
818
  return false;
819
  }
820
  }
821
+
822
  function senderCampaignSaveValid(sendererr,messageerr,mobileerr)
823
  {
824
+ var sender = jQuery('#sender_campaign').val();
825
+ var message =jQuery('#sender_campaign_message').val();
826
+ var number = jQuery("#singlechoice").val();
827
+ var radiovalue = jQuery("input[name=Sendin_Sms_Choice]:checked").val();
828
+ if(radiovalue == 1)
829
+ {
830
+ if(number == '' || isMobilevalidation(number) == false)
831
+ {
832
+ alert(mobileerr);
833
+ return false;
834
+ }
835
+ else if(sender == '' || isValid(sender) == false)
836
+ {
837
+ alert(sendererr);
838
+ return false;
839
+ }
840
+ else if(message == '')
841
+ {
842
+ alert(messageerr);
843
+ return false;
844
+ }
845
+ }
846
+ else{
847
+ if(sender == '' || isValid(sender) == false)
848
+ {
849
+ alert(sendererr);
850
+ return false;
851
+ }
852
+ else if(message == '')
853
+ {
854
+ alert(messageerr);
855
+ return false;
856
+ }
857
+ }
858
  }
859
 
860
  function isMobilevalidation(str)
861
  {
862
  return /^(?:\+|00)[1-9][0-9]{5,15}$/.test(str);
863
+ }
864
+
865
  function isNormalInteger(str)
866
  {
867
  return /^\+?(0|[1-9]\d*)$/.test(str);
868
  }
869
+
870
  function isValid(str) {
871
  var iChars = "~`!#$%^&*+=-[]\\\';,/{}|\":<>?";
872
 
877
  }
878
  return true;
879
  }
880
+
881
  function RegexEmail(email)
882
  {
883
  var emailRegexStr = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/;
884
  var isvalid = emailRegexStr.test(email);
885
  return isvalid;
886
  }
887
+
888
  function validate(emailerr,limiter)
889
  {
 
 
890
  if( document.notify_sms_mail_form.sendin_notify_email.value == "" || RegexEmail(document.notify_sms_mail_form.sendin_notify_email.value) == false )
891
  {
892
  alert(emailerr);
900
  document.notify_sms_mail_form.sendin_notify_value.focus() ;
901
  return false;
902
  }
903
+
904
  return( true );
905
+ }
906
+
907
  function smtpvalidate(emailerr)
908
+ {
909
  var email = jQuery('#email').val();
910
  if(email == "" || RegexEmail(email) == false )
911
  {
913
  jQuery('#email').focus();
914
  return false;
915
  }
916
+ }
917
+
918
  function apikvalidate(apierr)
919
+ {
920
+ var sendin_apikey_val = jQuery('#sendin_apikey_val').val();
921
+ var sendin_api_check = jQuery("input[name=sendin_api_status]:checked").val();
922
 
923
+ if(sendin_apikey_val.trim() == "" && sendin_api_check !=0)
924
  {
925
+ alert(apierr);
926
+ jQuery('#sendin_apikey_val').focus();
927
+ return false;
928
+ }
929
+ }
 
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
+ function testsmssend(e,r,t){var a=jQuery("#sender_order").val(),n=jQuery("#sender_order_message").val(),s=jQuery("#sender_order_number").val(),i=jQuery("#ajaxOrderSmsUrl").val(),u=jQuery("#smsCampError").val(),y=jQuery("#smsCampSuccess").val();return""==a||0==isValid(a)?alert(e):""==n?alert(r):""==s?alert(t):jQuery.ajax({type:"POST",async:!1,url:i,data:{sender:a,message:n,number:s},beforeSend:function(){jQuery("#ajax-busy").show()},success:function(e){jQuery("#ajax-busy").hide(),alert("OK"==e.trim()?y:u)}}),!1}function testShippedSmsSend(e,r,t){var a=jQuery("#sender_shipment").val(),n=jQuery("#sender_shipment_message").val(),s=jQuery("#sender_shipment_number").val(),i=jQuery("#ajaxOrderShippedUrl").val(),u=jQuery("#smsCampError").val(),y=jQuery("#smsCampSuccess").val();return""==a||0==isValid(a)?alert(e):""==n?alert(r):""==s?alert(t):jQuery.ajax({type:"POST",async:!1,url:i,data:{sender:a,message:n,number:s},beforeSend:function(){jQuery("#ajax-busy").show()},success:function(e){jQuery("#ajax-busy").hide(),alert("OK"==e.trim()?y:u)}}),!1}function testCampaignSmsSend(e,r,t){var a=jQuery("#sender_campaign").val(),n=jQuery("#sender_campaign_message").val(),s=jQuery("#sender_campaigntest_number").val(),i=jQuery("#ajaxSmsCampaignUrl").val(),u=jQuery("#smsCampError").val(),y=jQuery("#smsCampSuccess").val();return""==a||0==isValid(a)?alert(e):""==n?alert(r):""==s||0==isMobilevalidation(s)?alert(t):jQuery.ajax({type:"POST",async:!1,url:i,data:{sender:a,message:n,number:s},beforeSend:function(){jQuery("#ajax-busy").show()},success:function(e){jQuery("#ajax-busy").hide(),alert("OK"==e.trim()?y:u)}}),!1}function senderOrderSaveValid(e,r){var t=jQuery("#sender_order").val(),a=jQuery("#sender_order_message").val();return""==t||0==isValid(t)?(alert(e),!1):""==a?(alert(r),!1):void 0}function senderShipmentSaveValid(e,r){var t=jQuery("#sender_shipment").val(),a=jQuery("#sender_shipment_message").val();return""==t||0==isValid(t)?(alert(e),!1):""==a?(alert(r),!1):void 0}function senderCampaignSaveValid(e,r,t){var a=jQuery("#sender_campaign").val(),n=jQuery("#sender_campaign_message").val(),s=jQuery("#singlechoice").val(),i=jQuery("input[name=Sendin_Sms_Choice]:checked").val();if(1==i){if(""==s||0==isMobilevalidation(s))return alert(t),!1;if(""==a||0==isValid(a))return alert(e),!1;if(""==n)return alert(r),!1}else{if(""==a||0==isValid(a))return alert(e),!1;if(""==n)return alert(r),!1}}function isMobilevalidation(e){return/^(?:\+|00)[1-9][0-9]{5,15}$/.test(e)}function isNormalInteger(e){return/^\+?(0|[1-9]\d*)$/.test(e)}function isValid(e){for(var r="~`!#$%^&*+=-[]\\';,/{}|\":<>?",t=0;t<e.length;t++)if(-1!=r.indexOf(e.charAt(t)))return!1;return!0}function RegexEmail(e){var r=/^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/,t=r.test(e);return t}function validate(e,r){return""==document.notify_sms_mail_form.sendin_notify_email.value||0==RegexEmail(document.notify_sms_mail_form.sendin_notify_email.value)?(alert(e),document.notify_sms_mail_form.sendin_notify_email.focus(),!1):""==document.notify_sms_mail_form.sendin_notify_value.value||0==isNormalInteger(document.notify_sms_mail_form.sendin_notify_value.value)?(alert(r),document.notify_sms_mail_form.sendin_notify_value.focus(),!1):!0}function smtpvalidate(e){var r=jQuery("#email").val();return""==r||0==RegexEmail(r)?(alert(e),jQuery("#email").focus(),!1):void 0}function apikvalidate(e){var r=jQuery("#sendin_apikey_val").val(),t=jQuery("input[name=sendin_api_status]:checked").val();return""==r.trim()&&0!=t?(alert(e),jQuery("#sendin_apikey_val").focus(),!1):void 0}jQuery.noConflict(),jQuery(document).ready(function(){function e(e){var r=jQuery("#ajaxcontentUrl").val();jQuery.ajax({type:"POST",async:!1,url:r,data:"page="+e,beforeSend:function(){jQuery("#ajax-busy").show()},success:function(e){jQuery("#ajax-busy").hide(),jQuery(".midleft").html(e),jQuery(".midleft").ajaxComplete(function(r,t,a){jQuery(".midleft").html(e)})}})}function r(e){var r=/^[+-]?\d+(\.\d+)?([eE][+-]?\d+)?$/;return r.test(e)?!0:!1}function t(){var e=location.href.substr(0,location.href.lastIndexOf("/")+1),r=e.split("/"),t=r[r.length-2];return e.replace(t+"/","")}var a=jQuery("#apistatuskey").val();if(jQuery("#select").multiselect(),jQuery(".sendin_api_status").click(function(){1==a&&1==jQuery(this).val()?(jQuery("#sendin_apikey").show(),jQuery(".alldiv").show(),jQuery(".hidetableblock").show()):1==jQuery(this).val()?jQuery("#sendin_apikey").show():(jQuery("#sendin_apikey").hide(),jQuery(".alldiv").hide())}),jQuery("#sib_datetimepicker").datepicker({dateFormat:"yy-mm-dd"}),jQuery(".manage_subscribe_block input[name=subscribe_confirm_type]").click(function(){jQuery(".manage_subscribe_block .inner_manage_box").slideUp(),jQuery(this).parents(".manage_subscribe_block").find(".inner_manage_box").slideDown()}),jQuery(".openCollapse").each(function(){jQuery(this).is(":checked")||jQuery(this).parent(".form-group").find(".collapse").hide()}),jQuery("input[name=subscribe_confirm_type]").each(function(){jQuery(this).is(":checked")&&jQuery(this).parents(".manage_subscribe_block").find(".inner_manage_box").show()}),jQuery(".openCollapse").click(function(){jQuery(this).is(":checked")?jQuery(this).parent(".form-group").find(".collapse").slideDown():jQuery(this).parent(".form-group").find(".collapse").slideUp()}),jQuery(".hdtab").click(function(){parseInt(jQuery(this).val())&&jQuery("#hidetabselect").css("display","block")}),jQuery("body").on("click"," .pagination li.active",function(){var r=jQuery(this).attr("p");jQuery("#pagenumber").val(r),e(r)}),jQuery(".toolTip").hover(function(){var e=jQuery(this).attr("title"),r=jQuery(this).offset();jQuery("body").append('<div id="tipkk" style="top:'+r.top+"px; left:"+r.left+'px; ">'+e+"</div>");var t=jQuery("#tipkk").height()+25;jQuery("#tipkk").css("top",r.top-t+"px")},function(){jQuery("#tipkk").remove()}),jQuery("#sender_order").mouseover(function(){var e=jQuery(this).val();if(r(e)||""==e)jQuery("#sender_order").attr("maxlength","11"),jQuery("#sender_order_text").text(11-e.length);else{jQuery("#sender_order").attr("maxlength","11");var t=e.length>11?e.substr(1,11):e;jQuery("#sender_order").val(t),jQuery("#sender_order_text").text(11-e.length)}}),jQuery("#sender_order").keyup(function(){var e=jQuery(this).val();if(r(e)||""==e)jQuery("#sender_order").attr("maxlength","11"),jQuery("#sender_order_text").text(11-e.length);else{jQuery("#sender_order").attr("maxlength","11");var t=e.length>11?e.substr(1,11):e;jQuery("#sender_order").val(t),jQuery("#sender_order_text").text(11-e.length)}}),jQuery("#sender_order").keydown(function(e){32==e.keyCode&&e.preventDefault()}),""!=jQuery("#sender_order").val()){var n=jQuery("#sender_order").val();r(n)?(jQuery("#sender_order").attr("maxlength","11"),jQuery("#sender_order_text").text(11-n.length)):(jQuery("#sender_order").attr("maxlength","11"),jQuery("#sender_order_text").text(11-n.length))}if(jQuery("#sender_order_message").keyup(function(){var e=this.value.length,r=Math.ceil(e/160),t=160*r-e;jQuery("#sender_order_message_text").text(t),jQuery("#sender_order_message_text_count").text(r)}),""!=jQuery("#sender_order_message").val()){var s=jQuery("#sender_order_message").val().length,i=Math.ceil(s/160),u=160*i-s;jQuery("#sender_order_message_text").text(u),jQuery("#sender_order_message_text_count").text(i)}if(jQuery("#sender_shipment").mouseover(function(){var e=jQuery(this).val();if(r(e)||""==e)jQuery("#sender_shipment").attr("maxlength","11"),jQuery("#sender_shipment_text").text(11-e.length);else{jQuery("#sender_shipment").attr("maxlength","11");var t=e.length>11?e.substr(1,11):e;jQuery("#sender_shipment").val(t),jQuery("#sender_shipment_text").text(11-e.length)}}),jQuery("#sender_shipment").keyup(function(){var e=jQuery(this).val();if(r(e)||""==e)jQuery("#sender_shipment").attr("maxlength","11"),jQuery("#sender_shipment_text").text(11-e.length);else{jQuery("#sender_shipment").attr("maxlength","11");var t=e.length>11?e.substr(1,11):e;jQuery("#sender_shipment").val(t),jQuery("#sender_shipment_text").text(11-e.length)}}),jQuery("#sender_shipment").keydown(function(e){32==e.keyCode&&e.preventDefault()}),""!=jQuery("#sender_shipment").val()){var n=jQuery("#sender_shipment").val();r(n)?(jQuery("#sender_shipment").attr("maxlength","11"),jQuery("#sender_shipment_text").text(11-n.length)):(jQuery("#sender_shipment").attr("maxlength","11"),jQuery("#sender_shipment_text").text(11-n.length))}if(jQuery("#sender_shipment_message").keyup(function(){var e=this.value.length,r=Math.ceil(e/160),t=160*r-e;jQuery("#sender_shipment_message_text").text(t),jQuery("#sender_shipment_message_text_count").text(r)}),""!=jQuery("#sender_shipment_message").val()){var s=jQuery("#sender_shipment_message").val().length,i=Math.ceil(s/160),u=160*i-s;jQuery("#sender_shipment_message_text").text(u),jQuery("#sender_shipment_message_text_count").text(i)}if(jQuery("#sender_campaign").mouseover(function(){var e=jQuery(this).val();if(r(e)||""==e)jQuery("#sender_campaign").attr("maxlength","11"),jQuery("#sender_campaign_text").text(11-e.length);else{jQuery("#sender_campaign").attr("maxlength","11");var t=e.length>11?e.substr(1,11):e;jQuery("#sender_campaign").val(t),jQuery("#sender_campaign_text").text(11-e.length)}}),jQuery("#sender_campaign").keyup(function(){var e=jQuery(this).val();if(r(e)||""==e)jQuery("#sender_campaign").attr("maxlength","11"),jQuery("#sender_campaign_text").text(11-e.length);else{jQuery("#sender_campaign").attr("maxlength","11");var t=e.length>11?e.substr(1,11):e;jQuery("#sender_campaign").val(t),jQuery("#sender_campaign_text").text(11-e.length)}}),jQuery("#sender_campaign").keydown(function(e){32==e.keyCode&&e.preventDefault()}),""!=jQuery("#sender_campaign").val()){var n=jQuery("#sender_campaign").val();r(n)?(jQuery("#sender_campaign").attr("maxlength","11"),jQuery("#sender_campaign_text").text(11-n.length)):(jQuery("#sender_campaign").attr("maxlength","11"),jQuery("#sender_campaign_text").text(11-n.length))}if(jQuery("#sender_campaign_message").keyup(function(){var e=this.value.length,r=Math.ceil(e/160),t=160*r-(e%(160*r)||160*r);jQuery("#sender_campaign_message_text").text(t),jQuery("#sender_campaign_message_text_count").text(r)}),""!=jQuery("#sender_campaign_message").val()){var s=jQuery("#sender_campaign_message").val().length,i=Math.ceil(s/160),u=160*i-(s%(160*i)||160*i);jQuery("#sender_campaign_message_text").text(u),jQuery("#sender_campaign_message_text_count").text(i)}jQuery(".sms_order_setting").click(function(){var e=jQuery(this).val(),r=jQuery("#order").val();jQuery.ajax({type:"POST",async:!1,url:r,data:"orderSetting="+e,beforeSend:function(){jQuery("#ajax-busy").show()},success:function(r){jQuery("#ajax-busy").hide(),1==e?jQuery(".hideOrder").show():jQuery(".hideOrder").hide()}})}),jQuery(".sms_shiping_setting").click(function(){var e=jQuery(this).val(),r=jQuery("#shiping").val();jQuery.ajax({type:"POST",async:!1,url:r,data:"shipingSetting="+e,beforeSend:function(){jQuery("#ajax-busy").show()},success:function(r){jQuery("#ajax-busy").hide(),1==e?jQuery(".hideShiping").show():jQuery(".hideShiping").hide()}})}),jQuery(".sms_campaign_setting").click(function(){var e=jQuery(this).val(),r=jQuery("#campaign").val();jQuery.ajax({type:"POST",async:!1,url:r,data:"campaignSetting="+e,beforeSend:function(){jQuery("#ajax-busy").show()},success:function(r){jQuery("#ajax-busy").hide(),1==e?jQuery(".hideCampaign").show():jQuery(".hideCampaign").hide()}})}),0==jQuery("input:radio[name=sms_order_setting]:checked").val()?jQuery(".hideOrder").hide():jQuery(".hideOrder").show(),jQuery(".Sendin_Sms_Choice").click(function(){1==jQuery(this).val()?(jQuery(".multiplechoice").hide(),jQuery(".singlechoice").show()):(jQuery(".multiplechoice").show(),jQuery(".singlechoice").hide())}),jQuery(".Sendin_Sms_Choice").click(function(){2==jQuery(this).val()?jQuery(".sib_datepicker").show():jQuery(".sib_datepicker").hide()}),0==jQuery("input:radio[name=Sendin_Sms_Choice]:checked").val()?(jQuery(".multiplechoice").show(),jQuery(".singlechoice").hide()):(jQuery(".singlechoice").show(),jQuery(".multiplechoice").hide()),jQuery(".sms_shiping_setting").click(function(){1==jQuery(this).val()?jQuery(".hideShiping").show():jQuery(".hideShiping").hide()}),0==jQuery("input:radio[name=sms_credit]:checked").val()?jQuery(".hideCredit").hide():jQuery(".hideCredit").show(),jQuery(".sms_credit").click(function(){var e=jQuery(this).val(),r=jQuery("#credits").val();jQuery.ajax({type:"POST",async:!1,url:r,data:"sms_credit="+e,beforeSend:function(){jQuery("#ajax-busy").show()},success:function(r){jQuery("#ajax-busy").hide(),1==e?jQuery(".hideCredit").show():jQuery(".hideCredit").hide()}})}),0==jQuery("input:radio[name=sms_shiping_setting]:checked").val()?jQuery(".hideShiping").hide():jQuery(".hideShiping").show(),jQuery(".sms_campaign_setting").click(function(){1==jQuery(this).val()?jQuery(".hideCampaign").show():jQuery(".hideCampaign").hide()}),0==jQuery("input:radio[name=sms_campaign_setting]:checked").val()?jQuery(".hideCampaign").hide():jQuery(".hideCampaign").show(),jQuery("#selectSmsList").multiselect({header:!1,checkall:!1}),jQuery("#tabs li").click(function(){jQuery("#tabs li").removeClass("active"),jQuery(this).addClass("active"),jQuery(".tab_content").hide();var e=jQuery(this).find("a").attr("href");return jQuery(e).fadeIn(),!1}),jQuery("#showUserlist").click(function(){jQuery(".userDetails").is(":hidden")?(e(1),jQuery("#Spantextless").show(),jQuery("#Spantextmore").hide()):(jQuery("#Spantextmore").show(),jQuery("#Spantextless").hide()),jQuery(".userDetails").slideToggle()});t();jQuery(".Tracking").click(function(){var e=jQuery(this).val(),r=jQuery("#trackingUrl").val();0==e&&jQuery(".ordertracking").hide(),1==e&&jQuery(".ordertracking").show(),jQuery.ajax({type:"POST",async:!1,url:r,data:"script="+e,beforeSend:function(){jQuery("#ajax-busy").show()},success:function(e){jQuery("#ajax-busy").hide()}})}),jQuery(".Trackhistory").click(function(){var e=jQuery("#history_status").val(),r=jQuery("#langvalue").val(),t=jQuery("#importordertrackingUrl").val();jQuery.ajax({type:"POST",async:!1,url:t,data:{history_status:e,langvalue:r},beforeSend:function(){jQuery("#ajax-busy").show()},success:function(e){jQuery("#ajax-busy").hide(),jQuery(".ordertracking").hide(),alert(e)}})}),jQuery(".smtpStatus").click(function(){var e=jQuery(this).val(),r=jQuery("#smtpUrl").val();0==e&&jQuery(".smtptest").hide(),1==e&&jQuery(".smtptest").show(),jQuery.ajax({type:"POST",async:!1,url:r,data:"smtptest="+e,beforeSend:function(){jQuery("#ajax-busy").show()},success:function(e){jQuery("#ajax-busy").hide()}})});var y=jQuery("#skin_url").val();jQuery('<div id="ajax-busy"/> loading..').css({opacity:.5,position:"fixed",top:0,left:0,width:"100%",height:jQuery(window).height()+"px",background:"white url("+y+"adminhtml/default/default/sendinblue/images/loader.gif) no-repeat center"}).hide().appendTo("body"),jQuery("body").on("click",".ajax_contacts_href",function(r){var t=jQuery(this).attr("email"),a=jQuery(this).attr("status"),n=jQuery("#ajaxUrl").val();jQuery.ajax({type:"POST",async:!1,url:n,data:{email:t,newsletter:a},beforeSend:function(){jQuery("#ajax-busy").show()},success:function(e){jQuery("#ajax-busy").hide()}});var s=jQuery("#pagenumber").val();e(s)}),jQuery("body").on("click",".ajax_sms_subs_href",function(r){var t=jQuery(this).attr("email"),a=jQuery(this).attr("status"),n=jQuery("#ajaxSmsSubscribeUrl").val();jQuery.ajax({type:"POST",async:!1,url:n,data:{email:t,sms:a},beforeSend:function(){jQuery("#ajax-busy").show()},success:function(e){jQuery("#ajax-busy").hide()}});var s=jQuery("#pagenumber").val();e(s)})});