Sendinblue - Version 1.3.2

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


Code changes from version 1.1.0 to 1.3.2

Files changed (42) hide show
  1. app/code/community/Sendinblue/Sendinblue/Block/Sendinblue.php +98 -0
  2. app/code/community/Sendinblue/Sendinblue/Helper/Data.php +51 -0
  3. app/code/community/Sendinblue/Sendinblue/Model/Email.php +38 -0
  4. app/code/community/Sendinblue/Sendinblue/Model/Email/Template.php +86 -0
  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 +240 -0
  8. app/code/community/Sendinblue/Sendinblue/Model/Psmailin.php +1284 -0
  9. app/code/community/Sendinblue/Sendinblue/Model/Sendinblue.php +1636 -0
  10. app/code/{local → community}/Sendinblue/Sendinblue/Model/Status.php +9 -9
  11. app/code/community/Sendinblue/Sendinblue/controllers/Adminhtml/AjaxController.php +801 -0
  12. app/code/{local/Sendinblue/Sendinblue/controllers → community/Sendinblue/Sendinblue/controllers/Adminhtml}/IndexController.php +5 -5
  13. app/code/community/Sendinblue/Sendinblue/controllers/Adminhtml/MyformController.php +652 -0
  14. app/code/{local → community}/Sendinblue/Sendinblue/controllers/Adminhtml/NotifyController.php +7 -8
  15. app/code/{local → community}/Sendinblue/Sendinblue/controllers/Adminhtml/SyncController.php +7 -8
  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/Helper/Data.php +0 -54
  22. app/code/local/Sendinblue/Sendinblue/Model/Email.php +0 -36
  23. app/code/local/Sendinblue/Sendinblue/Model/Email/Template.php +0 -104
  24. app/code/local/Sendinblue/Sendinblue/Model/Observer.php +0 -260
  25. app/code/local/Sendinblue/Sendinblue/Model/Sendinblue.php +0 -1072
  26. app/code/local/Sendinblue/Sendinblue/controllers/Adminhtml/MyformController.php +0 -520
  27. app/code/local/Sendinblue/Sendinblue/controllers/AjaxController.php +0 -473
  28. app/code/local/Sendinblue/Sendinblue/sql/sendinblue_setup/mysql4-upgrade-0.1.0-0.2.0.php +0 -22
  29. app/design/adminhtml/default/default/layout/sendinblue.xml +6 -10
  30. app/design/adminhtml/default/default/template/sendinblue/myform.phtml +550 -362
  31. app/etc/modules/Sendinblue_Sendinblue.xml +2 -2
  32. app/locale/en_US/template/email/doubleoptin_temp.html +58 -0
  33. app/locale/en_US/template/email/sendin_notification.html +3 -3
  34. app/locale/en_US/template/email/sendinsmtp_conf.html +3 -3
  35. app/locale/fr_FR/Sendinblue.csv +26 -3
  36. app/locale/fr_FR/template/email/doubleoptin_temp.html +58 -0
  37. app/locale/fr_FR/template/email/sendin_notification.html +3 -3
  38. app/locale/fr_FR/template/email/sendinsmtp_conf.html +3 -3
  39. package.xml +16 -17
  40. skin/adminhtml/default/default/sendinblue/css/styles.css +24 -44
  41. skin/adminhtml/default/default/sendinblue/js/sendinblue.js +434 -375
  42. skin/adminhtml/default/default/sendinblue/js/sendinblue.min.js +1 -1
app/code/community/Sendinblue/Sendinblue/Block/Sendinblue.php ADDED
@@ -0,0 +1,98 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ $getEnableStatus = $sendinblueData->getEnableStatus();
26
+ $getTrackingStatus = $sendinblueData->getTrackingStatus();
27
+ $getOrderStatus = $sendinblueData->getOrderSmsStatus();
28
+ $getUserLists = $sendinblueData->getUserlists();
29
+ $smtpData = $sendinblueData->trackingSmtp();
30
+
31
+ $attributesName = $sendinblueData->allAttributesName();
32
+ $afterArrayMerge = array();
33
+
34
+ $lastOrderId = Mage::getSingleton('checkout/session')->getLastRealOrderId();
35
+ $customer = Mage::getSingleton('customer/session')->getCustomer();
36
+ $order = Mage::getModel('sales/order')->loadByIncrementId($lastOrderId);
37
+ $dataDisplay = $order->getBillingAddress()->getData();
38
+ $orderData = $order->getData();
39
+ $custmerData = $customer->getData();
40
+ $localeCode = Mage::app()->getLocale()->getLocaleCode();
41
+
42
+ if($getEnableStatus && $getOrderStatus) {
43
+ if (!empty($dataDisplay['telephone']) && !empty($dataDisplay['country_id'])) {
44
+ $countryCode = $sendinblueData->getCountryCode($dataDisplay['country_id']);
45
+ $dataDisplay['telephone'] = $sendinblueData->checkMobileNumber($dataDisplay['telephone'],$countryCode);
46
+ }
47
+ $referenceNumber = $orderData['increment_id'];
48
+ $orderprice = $orderData['grand_total'];
49
+ $currencyCode = $orderData['base_currency_code'];
50
+ if ($localeCode == 'fr_FR') {
51
+ $orderCreatedDate = date('d/m/Y', strtotime($orderData['created_at']));
52
+ }
53
+ else {
54
+ $orderCreatedDate = date('m/d/Y', strtotime($orderData['created_at']));
55
+ }
56
+
57
+ $totalPay = $orderprice.' '.$currencyCode;
58
+ $msgbody = $sendinblueData->getSendSmsmOrderMessage();
59
+ $firstName = str_replace('{first_name}', $dataDisplay['firstname'], $msgbody);
60
+ $lastName = str_replace('{last_name}', $dataDisplay['lastname']."\r\n", $firstName);
61
+ $procuctPrice = str_replace('{order_price}', $totalPay, $lastName);
62
+ $orderDate = str_replace('{order_date}', $orderCreatedDate."\r\n", $procuctPrice);
63
+ $msgbody = str_replace('{order_reference}', $referenceNumber, $orderDate);
64
+
65
+ $sendSmsData = array();
66
+ $sendSmsData['to'] = $dataDisplay['telephone'];
67
+ $sendSmsData['from'] = $sendinblueData->getSendSmsOrderSubject();
68
+ $sendSmsData['text'] = $msgbody;
69
+ $responce = $sendinblueData->sendSmsApi($sendSmsData);
70
+ }
71
+ $allData = array_merge($dataDisplay, $custmerData);
72
+ $afterArrayMerge = $sendinblueData->mergeMyArray($attributesName, $allData);
73
+ $client = (!empty($custmerData['firstname'])|| !empty($custmerData['firstname'])) ? 1 : 0 ;
74
+
75
+ $afterArrayMerge['CLIENT'] = $client;
76
+ $email = $custmerData['email']; // for email address
77
+ $costomerInformation = Mage::getModel('newsletter/subscriber')->loadByEmail($email);
78
+ $nlStatus = $costomerInformation->getStatus();
79
+
80
+ if ($nlStatus == 1) {
81
+ $sendinblueData->emailAdd($email, $afterArrayMerge, $nlStatus);
82
+ }
83
+
84
+ if ($getEnableStatus == 1 && $getTrackingStatus == 1 && $nlStatus == 1) {
85
+ $valueConfig = $sendinblueData->getApiConfigValue();
86
+ if (isset($valueConfig['data']['date_format']) && $valueConfig['data']['date_format'] == 'dd-mm-yyyy') {
87
+ $date = date('d-m-Y', strtotime($orderData['created_at']));
88
+ }
89
+ else {
90
+ $date = date('m-d-Y', strtotime($orderData['created_at']));
91
+ }
92
+
93
+ $getUserLists = array($getUserLists);
94
+ $attributesValues = array("PRENOM" => $custmerData['firstname'], "NOM" => $custmerData['lastname'], "ORDER_ID" => $referenceNumber, "ORDER_DATE" => $date, "ORDER_PRICE" => $orderprice);
95
+ $sendinblueData->importTransactionalData($email, $attributesValues, $getUserLists);
96
+ }
97
+ }
98
+ }
app/code/community/Sendinblue/Sendinblue/Helper/Data.php ADDED
@@ -0,0 +1,51 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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_Helper_Data extends Mage_Core_Helper_Abstract
12
+ {
13
+ public function getSMTP()
14
+ {
15
+ return Mage::getStoreConfig('sendinblue/smtp/option') == 'smtp';
16
+ }
17
+
18
+ public function getTransport()
19
+ {
20
+ if ($this->getSMTP()) {
21
+ $username = Mage::getStoreConfig('sendinblue/smtp/username');
22
+ $password = Mage::getStoreConfig('sendinblue/smtp/password');
23
+ $host = Mage::getStoreConfig('sendinblue/smtp/host');
24
+ $port = Mage::getStoreConfig('sendinblue/smtp/port');
25
+ $auth = Mage::getStoreConfig('sendinblue/smtp/authentication');
26
+ $config = array();
27
+ $config['username'] = $username;
28
+ $config['password'] = $password;
29
+ $config['port'] = $port;
30
+ $config['ssl'] = null;
31
+ $config['auth'] = $auth;
32
+ $transport = new Zend_Mail_Transport_Smtp($host, $config);
33
+ }
34
+ else {
35
+ Mage::log('Disabled, or no matching transport');
36
+ return null;
37
+ }
38
+ Mage::log('Returning transport');
39
+ return $transport;
40
+ }
41
+
42
+ public function ModuleisEnabled()
43
+ {
44
+ return Mage::getStoreConfig('sendinblue/enabled');
45
+ }
46
+
47
+ public function isEnabled()
48
+ {
49
+ return Mage::getStoreConfig('sendinblue/smtp/status');
50
+ }
51
+ }
app/code/community/Sendinblue/Sendinblue/Model/Email.php ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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_Model_Email extends Mage_Core_Model_Email {
12
+ /**
13
+ * override send function
14
+ */
15
+ public function send()
16
+ {
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
+ Mage::log('SendinblueSMTP is enabled, sending email in Sendinblue_Sendinblue_Model_Sendinblue');
21
+ $mail = new Zend_Mail();
22
+ if (strtolower($this->getType()) == 'html') {
23
+ $mail->setBodyHtml($this->getBody());
24
+ }
25
+ else {
26
+ $mail->setBodyText($this->getBody());
27
+ }
28
+ $transport = Mage::helper('sendinblue')->getTransport();
29
+ $email = Mage::getStoreConfig('contacts/email/recipient_email');
30
+ $mail->setFrom($this->getFromEmail(), $this->getFromName())
31
+ ->addTo($email, $this->getToName())
32
+ ->setSubject($this->getSubject());
33
+ Mage::log('About to send email');
34
+ $mail->send($transport);
35
+ Mage::log('Finished sending email');
36
+ return $this;
37
+ }
38
+ }
app/code/community/Sendinblue/Sendinblue/Model/Email/Template.php ADDED
@@ -0,0 +1,86 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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_Model_Email_Template extends Mage_Core_Model_Email_Template {
12
+
13
+ public function send($email, $name=null, array $variables = array())
14
+ {
15
+ // If it's not enabled, just return the parent result.
16
+ // If it's not enabled, just return the parent result.
17
+ if (Mage::helper('sendinblue')->isEnabled()==0 || Mage::helper('sendinblue')->ModuleisEnabled()==0) {
18
+ return parent::send($email, $name, $variables);
19
+ }
20
+
21
+ if(!$this->isValidForSend()) {
22
+ Mage::log('SMTP: Email not valid for sending - check template, and smtp enabled/disabled setting');
23
+ Mage::logException(new Exception('This letter cannot be sent.')); // translation is intentionally omitted
24
+ return false;
25
+ }
26
+ $emails = array_values((array)$email);
27
+ $names = is_array($name) ? $name : (array)$name;
28
+ $names = array_values($names);
29
+
30
+ foreach ($emails as $key => $email) {
31
+ if (!isset($names[$key])) {
32
+ $names[$key] = substr($email, 0, strpos($email, '@'));
33
+ }
34
+ }
35
+ $variables['email'] = reset($emails);
36
+ $variables['name'] = reset($names);
37
+ $mail = $this->getMail();
38
+
39
+ if (true) {
40
+ $email = Mage::getStoreConfig('contacts/email/recipient_email', $this->getDesignConfig()->getStore());
41
+ Mage::log("Development mode set to send all emails to contact form recipient: " . $email);
42
+ }
43
+ // In Magento core they set the Return-Path here, for the sendmail command.
44
+
45
+ foreach ($emails as $key => $email) {
46
+ $mail->addTo($email, '=?utf-8?B?' . base64_encode($names[$key]) . '?=');
47
+ }
48
+ $this->setUseAbsoluteLinks(true);
49
+ $text = $this->getProcessedTemplate($variables, true);
50
+
51
+ if($this->isPlain()) {
52
+ $mail->setBodyText($text);
53
+ }
54
+ else {
55
+ $mail->setBodyHTML($text);
56
+ }
57
+
58
+ $mail->setSubject('=?utf-8?B?'.base64_encode($this->getProcessedTemplateSubject($variables)).'?=');
59
+ $mail->setFrom($this->getSenderEmail(), $this->getSenderName());
60
+ $transport = Mage::helper('sendinblue')->getTransport();
61
+
62
+ try {
63
+ // adding new Event dispatch in case anyone wants to interrogate an email before being sent
64
+ // throwing an Exception in the Event Observer will prevent the mail being sent,
65
+ // and will return false to the calling function
66
+ Mage::dispatchEvent('sendin_email_after_send', array(
67
+ 'mail' => $mail,
68
+ 'template' => $this->getTemplateId(),
69
+ 'subject' => $this->getProcessedTemplateSubject($variables),
70
+ ));
71
+
72
+ Mage::log('About to send email');
73
+ $mail->send($transport); // Zend_Mail warning..
74
+
75
+ Mage::log('Finished sending email');
76
+ $this->_mail = null;
77
+ }
78
+ catch (Exception $exception) {
79
+ Mage::logException($exception);
80
+ $responceData = array('result'=>false, 'error'=>$exception->getMessage());
81
+ return json_encode($responceData);
82
+ }
83
+ $responceData = array('result'=>true);
84
+ return json_encode($responceData);
85
+ }
86
+ }
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,240 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ $requestParameters = Mage::app()->getRequest()->getParams();
16
+ if (isset($requestParameters['subscriber']) && count($requestParameters['subscriber'] > 0)) {
17
+ $customerEmail = array();
18
+ $newsLatterSubscriber = Mage::getModel('newsletter/subscriber');
19
+ foreach ($requestParameters['subscriber'] as $costomerId) {
20
+ $costomerData = $newsLatterSubscriber->load($costomerId)->toArray();
21
+ $customerEmail[] = empty($costomerData['subscriber_email']) ? array() : $costomerData['subscriber_email'];
22
+ }
23
+ $customerEmails = implode('|', $customerEmail);
24
+ $emailDeleteResponce = Mage::getModel('sendinblue/sendinblue')->emailDelete($customerEmails);
25
+ }
26
+
27
+ if (isset($emailDeleteResponce['data']['unsubEmails'])){
28
+ Mage::getModel('core/session')->addSuccess(Mage::helper('sendinblue')->__('Total of '. count($emailDeleteResponce['data']['unsubEmails']) .' record(s) were Unsubscribed'));
29
+ }
30
+ return $this;
31
+ }
32
+
33
+ public function adminCustomerDelete($observer)
34
+ {
35
+ $requestParameters = Mage::app()->getRequest()->getParams();
36
+ if (isset($requestParameters['customer']) && count($requestParameters['customer'] > 0)) {
37
+ $customerEmail = array();
38
+ $customerObj = Mage::getModel('customer/customer');
39
+ foreach ($requestParameters['customer'] as $costomerId) {
40
+ $costomerData = $customerObj->load($costomerId)->toArray();
41
+ $customerEmail[] = empty($costomerData['email'])?array():$costomerData['email'];
42
+ }
43
+ $customerEmails = implode('|', $customerEmail);
44
+ $emailDeleteResponce = Mage::getModel('sendinblue/sendinblue')->emailDelete($customerEmails);
45
+ }
46
+
47
+ if (isset($emailDeleteResponce['data']['unsubEmails'])) {
48
+ Mage::getModel('core/session')->addSuccess(Mage::helper('sendinblue')->__('Total of '. count($emailDeleteResponce['data']['unsubEmails']) .' record(s) were Unsubscribed'));
49
+ }
50
+ return $this;
51
+ }
52
+
53
+ public function adminCustomerSubscribe($observer)
54
+ {
55
+ $requestParameters = Mage::app()->getRequest()->getParams();
56
+ if (isset($requestParameters['customer']) && count($requestParameters['customer'] > 0)) {
57
+ $customerEmail = array();
58
+ $customerObj = Mage::getModel('customer/customer');
59
+ foreach ($requestParameters['customer'] as $costomerId) {
60
+ $costomerData = $customerObj->load($costomerId)->toArray();
61
+ $customerEmail[] = empty($costomerData['email'])?array():$costomerData['email'];
62
+ }
63
+ $customerEmails = implode('|', $customerEmail);
64
+ $addEmailResponce = Mage::getModel('sendinblue/sendinblue')->addEmailList($customerEmails);
65
+ }
66
+ if (isset($addEmailResponce['code']) && $addEmailResponce['code'] == 'success') {
67
+ Mage::getModel('core/session')->addSuccess(Mage::helper('sendinblue')->__('Email has been subscribed successfully.'));
68
+ }
69
+ return $this;
70
+ }
71
+
72
+ public function subscribeObserver($observer)
73
+ {
74
+ $extra = array();
75
+ $requestParameters = Mage::app()->getRequest()->getParams();
76
+ $extra = Mage::getModel('newsletter/subscriber')->loadByEmail($requestParameters['email'])->getData();
77
+ $sendinModule = Mage::getModel('sendinblue/sendinblue');
78
+ $attributesName = $sendinModule->allAttributesName();
79
+
80
+ if ($requestParameters['email'] != '') {
81
+ $newsletterStatus = 0;
82
+ }
83
+
84
+ $client = 0;
85
+ $mergeArrayResponse = $sendinModule->mergeMyArray($attributesName, $extra);
86
+ $mergeArrayResponse['CLIENT'] = $client;
87
+ $emailAddResponce = $sendinModule->emailAdd($requestParameters['email'], $mergeArrayResponse, $newsletterStatus);
88
+ return $this;
89
+ }
90
+
91
+ public function updateNewObserver($observer)
92
+ {
93
+ $requestParameters = Mage::app()->getRequest()->getParams();
94
+ $costomerSession = Mage::getSingleton('customer/session')->getCustomer();
95
+ $sendinModule = Mage::getModel('sendinblue/sendinblue');
96
+ $attributesName = $sendinModule->allAttributesName();
97
+
98
+ $customerSessionEmail = $costomerSession->getEmail();
99
+ if (empty($customerSessionEmail)) {
100
+ $customer = $observer->getCustomer();
101
+ $customerData = $customer->getData();
102
+ }
103
+ else{
104
+ $customerData = $costomerSession->getData();
105
+ }
106
+
107
+ $email = $customerData['email'];
108
+ $costomerEntityId = isset($customerData['entity_id'])?$customerData['entity_id']:'';
109
+ $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',$costomerEntityId);
110
+
111
+ $telephone = '';
112
+ $customerAddress = array();
113
+ $customerAddressData = array();
114
+ foreach ($collectionAddress as $customerPhno) {
115
+ $customerAddress = $customerPhno->getData();
116
+ if (!empty($customerAddress['telephone'])) {
117
+ if(!empty($customerAddress['country_id'])) {
118
+ $countryCode = $sendinModule->getCountryCode($customerAddress['country_id']);
119
+ $customerAddress['telephone'] = $sendinModule->checkMobileNumber($customerAddress['telephone'], $countryCode);
120
+ }
121
+ }
122
+ }
123
+
124
+ $customerAddressData = array_merge($customerAddress, $customerData);
125
+ if (!empty($customerData['firstname']) && !empty($customerData['lastname'])) {
126
+ $client = 1;
127
+ }
128
+ else {
129
+ $client = 0;
130
+ }
131
+
132
+ $isSubscribed = !empty($customerAddressData['is_subscribed']) ? $customerAddressData['is_subscribed'] : $requestParameters['is_subscribed'];
133
+ if (!empty($customerData['firstname']) || !empty($customerAddress['telephone']) || !empty($email)) {
134
+ $costomerData = Mage::getModel('newsletter/subscriber')->loadByEmail($email);
135
+ $costomerDataStatus = $costomerData->getStatus();
136
+ $mergeArrayResponse = $sendinModule->mergeMyArray($attributesName, $customerAddressData);
137
+ $mergeArrayResponse['CLIENT'] = $client;
138
+ if (isset($isSubscribed) && $isSubscribed == 1 && empty($costomerDataStatus)) {
139
+ $responce = $sendinModule->emailAdd($email, $mergeArrayResponse, $isSubscribed);
140
+ $sendinModule->sendWsTemplateMail($email);
141
+ }
142
+ elseif (!empty($costomerDataStatus)) {
143
+ $responce = $sendinModule->emailAdd($email, $mergeArrayResponse);
144
+ }
145
+ }
146
+
147
+ if (isset($isSubscribed) && !empty($isSubscribed) && $isSubscribed === 0) {
148
+ $responce = $sendinModule->emailDelete($email);
149
+ }
150
+ return $this;
151
+ }
152
+
153
+ public function syncData()
154
+ {
155
+ $responce = Mage::getModel('sendinblue/sendinblue')->syncData();
156
+ return $this;
157
+ }
158
+
159
+ public function updateStatus($observer)
160
+ {
161
+ $order = $observer->getEvent()->getOrder();
162
+ if ($order->getState() == Mage_Sales_Model_Order::STATE_PROCESSING) {
163
+ $history = $order->getShipmentsCollection();
164
+ $shipmentHistoryData=$history->toarray();
165
+ if($shipmentHistoryData['totalRecords'] > 0) {
166
+ $orderId = isset($shipmentHistoryData['items']['0']['order_id']) ? $shipmentHistoryData['items']['0']['order_id'] : '';
167
+ $shippingaddrid = isset($shipmentHistoryData['items']['0']['shipping_address_id']) ? $shipmentHistoryData['items']['0']['shipping_address_id'] : '';
168
+ $_order = Mage::getModel('sales/order')->load($orderId);
169
+ $_shippingAddress = $_order->getShippingAddress();
170
+ $locale = Mage::app()->getLocale()->getLocaleCode();
171
+ $mobileSms = $_shippingAddress->getTelephone();
172
+ $mobileSms = !empty($mobileSms) ? $mobileSms : '';
173
+ $countryid = $_shippingAddress->getCountryId();
174
+ $countryid = !empty($countryid) ? $countryid : '';
175
+ $codeResource = Mage::getSingleton('core/resource');
176
+ $tableCountry = $codeResource->getTableName('sendinblue_country_codes');
177
+ $readDbObject = Mage::getSingleton("core/resource")->getConnection("core_read");
178
+ $queryCountryCode = $readDbObject->select()
179
+ ->from($tableCountry, array('country_prefix'))
180
+ ->where("iso_code = ?", $countryid);
181
+ $stmtCountryCode = $readDbObject->query($queryCountryCode);
182
+ $data = $stmtCountryCode->fetch();
183
+ $mobile = '';
184
+ $countryPrefix = $data['country_prefix'];
185
+ $sendinblueModule = Mage::getModel('sendinblue/sendinblue');
186
+ if(isset($countryPrefix) && !empty($countryPrefix)){
187
+ $mobile = $sendinblueModule->checkMobileNumber($mobileSms,$countryPrefix);
188
+ }
189
+ $firstname = $_shippingAddress->getFirstname();
190
+ $firstname = !empty($firstname ) ? $firstname : '';
191
+ $lastname = $_shippingAddress->getLastname();
192
+ $lastname = !empty($lastname) ? $lastname : '';
193
+ $refNum = $_order->getIncrementId();
194
+ $refNum = !empty($refNum) ? $refNum : '';
195
+ $orderprice = $_order->getGrandTotal();
196
+ $orderprice = !empty($orderprice) ? $orderprice:'';
197
+ $courrencycode = $_order->getBaseCurrencyCode();
198
+ $courrencycode = !empty($courrencycode) ? $courrencycode:'';
199
+ $orderdate = $_order->getCreatedAt();
200
+ $orderdate = !empty($orderdate) ? $orderdate : '';
201
+
202
+ $ordDate = ($locale == 'fr_FR') ? date('d/m/Y', strtotime($orderdate)) : date('m/d/Y', strtotime($orderdate));
203
+
204
+ $totalPay = $orderprice.' '.$courrencycode;
205
+ $messageBody = $sendinblueModule->getSendSmsShipingMessage();
206
+ $fname = str_replace('{first_name}', $firstname, $messageBody);
207
+ $lname = str_replace('{last_name}', $lastname."\r\n", $fname);
208
+ $procuctPrice = str_replace('{order_price}', $totalPay, $lname);
209
+ $orderDate = str_replace('{order_date}', $ordDate."\r\n", $procuctPrice);
210
+ $messageBody = str_replace('{order_reference}', $refNum, $orderDate);
211
+
212
+ $smsInformation = array();
213
+ $smsInformation['to'] = $mobile;
214
+ $smsInformation['from'] = $sendinblueModule->getSendSmsShipingSubject();
215
+ $smsInformation['text'] = $messageBody;
216
+ $sendinblueModule->sendSmsApi($smsInformation);
217
+ }
218
+ }
219
+ }
220
+
221
+ public function subscribedToNewsletter($observer)
222
+ {
223
+ $data = $observer->subscriber;
224
+ $requestParameters = Mage::app()->getRequest()->getParams();
225
+ if (empty($requestParameters['firstname']) && empty($requestParameters['lastname'])) {
226
+ $sibObj = Mage::getModel('sendinblue/sendinblue');
227
+ $subscriberEmail = $data->subscriber_email;
228
+
229
+ if($data->subscriber_status == 3) {
230
+ $sibObj->emailDelete($subscriberEmail);
231
+ }
232
+ else if ($data->subscriber_status == 1 && !empty($subscriberEmail)) {
233
+ $sibObj->emailSubscribe($data->subscriber_email);
234
+ if( !isset($requestParameters['newsletter'])) {
235
+ $sibObj->sendWsTemplateMail($data->subscriber_email);
236
+ }
237
+ }
238
+ }
239
+ }
240
+ }
app/code/community/Sendinblue/Sendinblue/Model/Psmailin.php ADDED
@@ -0,0 +1,1284 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ $this->base_url = "https://api.sendinblue.com/v2.0";
37
+ $this->api_key = $params['api_key'];
38
+
39
+ }
40
+
41
+ /**
42
+ * Do CURL request with authorization
43
+ */
44
+ private function doRequest($resource, $method, $input)
45
+ {
46
+ $called_url = $this->base_url."/".$resource;
47
+ $ch = curl_init($called_url);
48
+ $auth_header = 'api-key:'.$this->api_key;
49
+ $content_header = "Content-Type:application/json";
50
+ $track_header = "sib-plugin:magento-1.3.2";
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, $track_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
+
69
+ public function get($resource, $input)
70
+ {
71
+ return $this->doRequest($resource, "GET", $input);
72
+ }
73
+ public function put($resource, $input)
74
+ {
75
+ return $this->doRequest($resource, "PUT", $input);
76
+ }
77
+ public function post($resource, $input)
78
+ {
79
+ return $this->doRequest($resource, "POST", $input);
80
+ }
81
+ public function delete($resource, $input)
82
+ {
83
+ return $this->doRequest($resource, "DELETE", $input);
84
+ }
85
+
86
+ /*
87
+ Get Account.
88
+ No input required
89
+ */
90
+ public function getAccount()
91
+ {
92
+ return $this->get("account", "");
93
+ }
94
+
95
+ /*
96
+ Get SMTP details.
97
+ No input required
98
+ */
99
+ public function getSmtpDetails()
100
+ {
101
+ return $this->get("account/smtpdetail", "");
102
+ }
103
+
104
+ /*
105
+ Create Child Account.
106
+ @param {Array} data contains php array with key value pair.
107
+ @options data {String} child_email: Email address of Reseller child [Mandatory]
108
+ @options data {String} password: Password of Reseller child to login [Mandatory]
109
+ @options data {String} company_org: Name of Reseller child’s company [Mandatory]
110
+ @options data {String} first_name: First name of Reseller child [Mandatory]
111
+ @options data {String} last_name: Last name of Reseller child [Mandatory]
112
+ @options data {Array} credits: Number of email & sms credits respectively, which will be
113
+ assigned to the Reseller child’s account [Optional]
114
+ - email_credit {Integer} number of email credits
115
+ - sms_credit {Integer} Number of sms credts
116
+ @options data {Array} associate_ip: Associate dedicated IPs to reseller child.
117
+ You can use commas to separate multiple IPs [Optional]
118
+ */
119
+ public function createChildAccount($data)
120
+ {
121
+ return $this->post("account", json_encode($data));
122
+ }
123
+
124
+ /*
125
+ Update Child Account.
126
+ @param {Array} data contains php array with key value pair.
127
+ @options data {String} auth_key: 16 character authorization key of Reseller child to
128
+ be modified [Mandatory]
129
+ @options data {String} company_org: Name of Reseller child’s company [Optional]
130
+ @options data {String} first_name: First name of Reseller child [Optional]
131
+ @options data {String} last_name: Last name of Reseller child [Optional]
132
+ @options data {String} password: Password of Reseller child to login [Optional]
133
+ @options data {Array} associate_ip: Associate dedicated IPs to reseller child. You can use
134
+ commas to separate multiple IPs [Optional]
135
+ @options data {Array} disassociate_ip: Disassociate dedicated IPs from reseller child. You can
136
+ use commas to separate multiple IPs [Optional]
137
+ */
138
+ public function updateChildAccount($data)
139
+ {
140
+ return $this->put("account", json_decode($data));
141
+ }
142
+
143
+ /*
144
+ Delete Child Account.
145
+ @param {Array} data contains php array with key value pair.
146
+ @options data {String} auth_key: 16 character authorization key of Reseller child to be
147
+ deleted [Mandatory]
148
+ */
149
+ public function deleteChildAccount($data)
150
+ {
151
+ return $this->delete("account/".$data['auth_key'], "");
152
+ }
153
+
154
+ /*
155
+ Get Reseller child Account.
156
+ @param {Array} data contains php array with key value pair.
157
+ @options data {String} auth_key: 16 character authorization key of Reseller child.
158
+ Example : To get the details of more than one child account, use, {"key1":"abC01De2fGHI3jkL",
159
+ "key2":"mnO45Pq6rSTU7vWX"} [Mandatory]
160
+ */
161
+ public function getResellerChild($data)
162
+ {
163
+ return $this->post("account/getchildv2", json_encode($data));
164
+ }
165
+
166
+ /*
167
+ Add/Remove Reseller child's Email/Sms credits.
168
+ @param {Array} data contains php array with key value pair.
169
+ @options data {String} auth_key: 16 character authorization key of Reseller child to modify
170
+ credits [Mandatory]
171
+ @options data {Array} add_credit: Number of email & sms credits to be added. You can assign
172
+ either email or sms credits, one at a time other will remain 0. [Mandatory: if rmv_credit is empty]
173
+ - email_credit {Integer} number of email credits
174
+ - sms_credit {Integer} Number of sms credts
175
+ @options data {Array} rmv_credit: Number of email & sms credits to be removed. You can assign
176
+ either email or sms credits, one at a time other will remain 0. [Mandatory: if add_credits is empty]
177
+ - email_credit {Integer} number of email credits
178
+ - sms_credit {Integer} Number of sms credts
179
+ */
180
+ public function addRemoveChildCredits($data)
181
+ {
182
+ return $this->post("account/addrmvcredit", json_decode($data));
183
+ }
184
+
185
+ /*
186
+ Get a particular campaign detail.
187
+ @param {Array} data contains php array with key value pair.
188
+ @options data {Integer} id: Unique Id of the campaign [Mandatory]
189
+ */
190
+ public function getCampaignV2($data)
191
+ {
192
+ return $this->get("campaign/".$data['id']."/detailsv2", "");
193
+ }
194
+
195
+ /*
196
+ Get all campaigns detail.
197
+ @param {Array} data contains php array with key value pair.
198
+ @options data {String} type: Type of campaign. Possible values – classic, trigger,
199
+ sms, template ( case sensitive ) [Optional]
200
+ @options data {String} status: Status of campaign. Possible values – draft, sent, archive
201
+ , queued, suspended, in_process, temp_active, temp_inactive ( case sensitive ) [Optional]
202
+ @options data {Integer} page: Maximum number of records per request is 500, if there are
203
+ more than 500 campaigns then you can use this parameter to get next 500 results [Optional]
204
+ @options data {Integer} page_limit: This should be a valid number between 1-500 [Optional]
205
+ */
206
+ public function getCampaignsV2($data)
207
+ {
208
+ return $this->get("campaign/detailsv2", json_decode($data));
209
+ }
210
+
211
+ /*
212
+ Create and Schedule your campaigns. It returns the ID of the created campaign.
213
+ @param {Array} data contains php array with key value pair.
214
+ @options data {String} category: Tag name of the campaign [Optional]
215
+ @options data {String} from_name: Sender name from which the campaign emails are sent
216
+ [Mandatory: for Dedicated IP clients, please make sure that the sender details are defined
217
+ here, and in case of no sender, you can add them also via API & for Shared IP clients, if
218
+ sender exists]
219
+ @options data {String} name: Name of the campaign [Mandatory]
220
+ @options data {String} bat: Email address for test mail [Optional]
221
+ @options data {String} html_content: Body of the content. The HTML content field must have
222
+ more than 10 characters [Mandatory: if html_url is empty]
223
+ @options data {String} html_url: Url which content is the body of content [Mandatory: if
224
+ html_content is empty]
225
+ @options data {Array} listid: These are the lists to which the campaign has been sent
226
+ [Mandatory: if scheduled_date is not empty]
227
+ @options data {String} scheduled_date: The day on which the campaign is supposed to run[Optional]
228
+ @options data {String} subject: Subject of the campaign [Mandatory]
229
+ @options data {String} from_email: Sender email from which the campaign emails are sent
230
+ [Mandatory: for Dedicated IP clients, please make sure that the sender details are defined
231
+ here, and in case of no sender, you can add them also via API & for Shared IP clients, if
232
+ sender exists]
233
+ @options data {String} reply_to: The reply to email in the campaign emails [Optional]
234
+ @options data {String} to_field: This is to personalize the «To» Field. If you want to
235
+ include the first name and last name of your recipient, add [PRENOM] [NOM] To use the contact
236
+ attributes here, these should already exist in SendinBlue account [Optional]
237
+ @options data {Array} exclude_list: These are the lists which must be excluded from the campaign [Optional]
238
+ @options data {String} attachment_url: Provide the absolute url of the attachment [Optional]
239
+ @options data {Integer} inline_image: Status of inline image. Possible values = 0 (default)
240
+ & 1. inline_image = 0 means image can’t be embedded, & inline_image = 1 means image can be
241
+ embedded, in the email [Optional]
242
+ @options data {Integer} mirror_active: Status of mirror links in campaign. Possible values = 0
243
+ & 1 (default). mirror_active = 0 means mirror links are deactivated, & mirror_active = 1
244
+ means mirror links are activated, in the campaign [Optional]
245
+ @options data {Integer} send_now: Flag to send campaign now. Possible values = 0 (default)
246
+ & 1. send_now = 0 means campaign can’t be send now, & send_now = 1 means campaign ready to
247
+ send now [Optional]
248
+
249
+ */
250
+ public function createCampaign($data)
251
+ {
252
+ return $this->post("campaign", json_decode($data));
253
+ }
254
+
255
+ /*
256
+ Update your campaign.
257
+ @param {Array} data contains php array with key value pair.
258
+ @options data {Integer} id: Id of campaign to be modified [Mandatory]
259
+ @options data {String} category: Tag name of the campaign [Optional]
260
+ @options data {String} from_name: Sender name from which the campaign emails are sent
261
+ [Mandatory: for Dedicated IP clients, please make sure that the sender details are defined
262
+ here, and in case of no sender, you can add them also via API & for Shared IP clients, if
263
+ sender exists]
264
+ @options data {String} name: Name of the campaign [Optional]
265
+ @options data {String} bat: Email address for test mail [Optional]
266
+ @options data {String} html_content: Body of the content. The HTML content field must have
267
+ more than 10 characters [Optional]
268
+ @options data {String} html_url: Url which content is the body of content [Optional]
269
+ @options data {Array} listid These are the lists to which the campaign has been sent
270
+ [Mandatory: if scheduled_date is not empty]
271
+ @options data {String} scheduled_date: The day on which the campaign is supposed to
272
+ run[Optional]
273
+ @options data {String} subject: Subject of the campaign.
274
+ @options data {String} from_email: Sender email from which the campaign emails are sent
275
+ [Mandatory: for Dedicated IP clients, please make sure that the sender details are defined
276
+ here, and in case of no sender, you can add them also via API & for Shared IP clients,
277
+ if sender exists]
278
+ @options data {String} reply_to: The reply to email in the campaign emails [Optional]
279
+ @options data {String} to_field: This is to personalize the «To» Field. If you want to
280
+ include the first name and last name of your recipient, add [PRENOM] [NOM]. To use the
281
+ contact attributes here, these should already exist in SendinBlue account [Optional]
282
+ @options data {Array} exclude_list: These are the lists which must be excluded from the
283
+ campaign [Optional]
284
+ @options data {String} attachment_url: Provide the absolute url of the attachment [Optional]
285
+ @options data {Integer} inline_image: Status of inline image. Possible values = 0
286
+ (default) & 1. inline_image = 0 means image can’t be embedded, & inline_image = 1
287
+ means image can be embedded, in the email [Optional]
288
+ @options data {Integer} mirror_active: Status of mirror links in campaign. Possible
289
+ values = 0 & 1 (default). mirror_active = 0 means mirror links are deactivated, &
290
+ mirror_active = 1 means mirror links are activated, in the campaign [Optional]
291
+ @options data {Integer} send_now: Flag to send campaign now. Possible values = 0
292
+ (default) & 1. send_now = 0 means campaign can’t be send now, & send_now = 1 means
293
+ campaign ready to send now [Optional]
294
+ */
295
+ public function updateCampaign($data)
296
+ {
297
+ $id = $data['id'];
298
+ unset($data['id']);
299
+ return $this->put("campaign/".$id, json_decode($data));
300
+ }
301
+
302
+ /*
303
+ Delete your campaigns.
304
+ @param {Array} data contains php array with key value pair.
305
+ @options data {Integer} id: Id of campaign to be deleted [Mandatory]
306
+ */
307
+ public function deleteCampaign($data)
308
+ {
309
+ return $this->delete("campaign/".$data['id'], "");
310
+ }
311
+
312
+ /*
313
+ Send report of Sent and Archived campaign.
314
+ @param {Array} data contains php array with key value pair.
315
+ @options data {Integer} id: Id of campaign to send its report [Mandatory]
316
+ @options data {String} lang: Language of email content. Possible values – fr
317
+ (default), en, es, it & pt [Optional]
318
+ @options data {String} email_subject: Message subject [Mandatory]
319
+ @options data {Array} email_to: Email address of the recipient(s). Example:
320
+ "test@example.net". You can use commas to separate multiple recipients [Mandatory]
321
+ @options data {String} email_content_type: Body of the message in text/HTML version.
322
+ Possible values – text & html [Mandatory]
323
+ @options data {Array} email_bcc: Same as email_to but for Bcc [Optional]
324
+ @options data {Array} email_cc: Same as email_to but for Cc [Optional]
325
+ @options data {String} email_body: Body of the message [Mandatory]
326
+ */
327
+ public function campaignReportEmail($data)
328
+ {
329
+ $id = $data['id'];
330
+ unset($data['id']);
331
+ return $this->post("campaign/".$id."/report", json_decode($data));
332
+ }
333
+
334
+ /*
335
+ Export the recipients of a specified campaign.
336
+ @param {Array} data contains php array with key value pair.
337
+ @options data {Integer} id: Id of campaign to export its recipients [Mandatory]
338
+ @options data {String} notify_url: URL that will be called once the export process
339
+ is finished [Mandatory]
340
+ @options data {String} type: Type of recipients. Possible values – all, non_clicker,
341
+ non_opener, clicker, opener, soft_bounces, hard_bounces & unsubscribes [Mandatory]
342
+ */
343
+ public function campaignRecipientsExport($data)
344
+ {
345
+ $id = $data['id'];
346
+ unset($data['id']);
347
+ return $this->post("campaign/".$id."/recipients", json_decode($data));
348
+ }
349
+
350
+ /*
351
+ Get the Campaign name, subject and share link of the classic type campaigns only which
352
+ are sent, for those which are not sent and the rest of campaign types like trigger, template
353
+ & sms, will return an error message of share link not available.
354
+ @param {Array} data contains php array with key value pair.
355
+ @options data {Array} camp_ids: Id of campaign to get share link. You can use commas to
356
+ separate multiple ids [Mandatory]
357
+ */
358
+
359
+ public function shareCampaign($data)
360
+ {
361
+ return $this->post("campaign/sharelinkv2", json_encode($data));
362
+ }
363
+
364
+ /*
365
+ Send a Test Campaign.
366
+ @param {Array} data contains php array with key value pair.
367
+ @options data {Integer} id: Id of the campaign [Mandatory]
368
+ @options data {Array} emails: Email address of recipient(s) existing in the one of the lists &
369
+ should not be blacklisted. Example: "test@example.net". You can use commas to separate multiple
370
+ recipients [Mandatory]
371
+ */
372
+ public function sendBatEmail($data)
373
+ {
374
+ $id = $data['id'];
375
+ unset($data['id']);
376
+ return $this->post("campaign/".$id."/test", json_encode($data));
377
+ }
378
+
379
+ /*
380
+ Update the Campaign status.
381
+ @param {Array} data contains php array with key value pair.
382
+ @options data {Integer} id: Id of campaign to update its status [Mandatory]
383
+ @options data {String} status: Types of status. Possible values – suspended,
384
+ archive, darchive, sent, queued, replicate and replicate_template ( case sensitive )
385
+ [Mandatory]
386
+ */
387
+ public function updateCampaignStatus($data)
388
+ {
389
+ $id = $data['id'];
390
+ unset($data['id']);
391
+ return $this->put("campaign/".$id."/updatecampstatus", json_encode($data));
392
+ }
393
+
394
+ /*
395
+ Create and schedule your Trigger campaigns.
396
+ @param {Array} data contains php array with key value pair.
397
+ @options data {String} category: Tag name of the campaign [Optional]
398
+ @options data {String} from_name: Sender name from which the campaign emails are
399
+ sent [Mandatory: for Dedicated IP clients, please make sure that the sender details
400
+ are defined here, and in case of no sender, you can add them also via API & for Shared
401
+ IP clients, if sender exists]
402
+ @options data {String} trigger_name: Name of the campaign [Mandatory]
403
+ @options data {String} bat: Email address for test mail [Optional]
404
+ @options data {String} html_content: Body of the content. The HTML content field must
405
+ have more than 10 characters [Mandatory: if html_url is empty]
406
+ @options data {String} html_url: Url which content is the body of content [Mandatory: if
407
+ html_content is empty]
408
+ @options data {Array} listid: These are the lists to which the campaign has been sent
409
+ [Mandatory: if scheduled_date is not empty]
410
+ @options data {String} scheduled_date: The day on which the campaign is supposed to
411
+ run[Optional]
412
+ @options data {String} subject: Subject of the campaign [Mandatory]
413
+ @options data {String} from_email: Sender email from which the campaign emails are sent
414
+ [Mandatory: for Dedicated IP clients, please make sure that the sender details are defined
415
+ here, and in case of no sender, you can add them also via API & for Shared IP clients, if
416
+ sender exists]
417
+ @options data {String} reply_to: The reply to email in the campaign emails [Optional]
418
+ @options data {String} to_field: This is to personalize the «To» Field. If you want to include
419
+ the first name and last name of your recipient, add [PRENOM] [NOM]. To use the contact attributes
420
+ here, these should already exist in SendinBlue account [Optional]
421
+ @options data {Array} exclude_list: These are the lists which must be excluded from the campaign
422
+ [Optional]
423
+ @options data {Integer} recurring: Type of trigger campaign. Possible values = 0 (default) & 1.
424
+ recurring = 0 means contact can receive the same Trigger campaign only once, & recurring = 1
425
+ means contact can receive the same Trigger campaign several times [Optional]
426
+ @options data {String} attachment_url: Provide the absolute url of the attachment [Optional]
427
+ @options data {Integer} inline_image: Status of inline image. Possible values = 0 (default) &
428
+ 1. inline_image = 0 means image can’t be embedded, & inline_image = 1 means image can be embedded,
429
+ in the email [Optional]
430
+ @options data {Integer} mirror_active: Status of mirror links in campaign. Possible values = 0 & 1
431
+ (default). mirror_active = 0 means mirror links are deactivated, & mirror_active = 1 means mirror
432
+ links are activated, in the campaign [Optional]
433
+ @options data {Integer} send_now: Flag to send campaign now. Possible values = 0 (default) & 1.
434
+ send_now = 0 means campaign can’t be send now, & send_now = 1 means campaign ready to send now
435
+ [Optional]
436
+ */
437
+ public function createTriggerCampaign($data)
438
+ {
439
+ return $this->post("campaign", json_encode($data));
440
+ }
441
+
442
+ /*
443
+ Update and schedule your Trigger campaigns.
444
+ @param {Array} data contains php array with key value pair.
445
+ @options data {Integer} id: Id of Trigger campaign to be modified [Mandatory]
446
+ @options data {String} category: Tag name of the campaign [Optional]
447
+ @options data {String} from_name: Sender name from which the campaign emails are sent
448
+ [Mandatory: for Dedicated IP clients, please make sure that the sender details are defined here,
449
+ and in case of no sender, you can add them also via API & for Shared IP clients, if sender exists]
450
+ @options data {String} trigger_name: Name of the campaign [Mandatory]
451
+ @options data {String} bat Email address for test mail [Optional]
452
+ @options data {String} html_content: Body of the content. The HTML content field must have more
453
+ than 10 characters [Mandatory: if html_url is empty]
454
+ @options data {String} html_url: Url which content is the body of content [Mandatory: if
455
+ html_content is empty]
456
+ @options data {Array} listid: These are the lists to which the campaign has been sent [Mandatory:
457
+ if scheduled_date is not empty]
458
+ @options data {String} scheduled_date: The day on which the campaign is supposed to run[Optional]
459
+ @options data {String} subject: Subject of the campaign [Mandatory]
460
+ @options data {String} from_email: Sender email from which the campaign emails are sent [Mandatory:
461
+ for Dedicated IP clients, please make sure that the sender details are defined here, and in case of
462
+ no sender, you can add them also via API & for Shared IP clients, if sender exists]
463
+ @options data {String} reply_to: The reply to email in the campaign emails [Optional]
464
+ @options data {String} to_field: This is to personalize the «To» Field. If you want to include the
465
+ first name and last name of your recipient, add [PRENOM] [NOM]. To use the contact attributes here
466
+ , these should already exist in SendinBlue account [Optional]
467
+ @options data {Array} exclude_list: These are the lists which must be excluded from the campaign
468
+ [Optional]
469
+ @options data {Integer} recurring: Type of trigger campaign. Possible values = 0 (default) & 1.
470
+ recurring = 0 means contact can receive the same Trigger campaign only once, & recurring = 1
471
+ means contact can receive the same Trigger campaign several times [Optional]
472
+ @options data {String} attachment_url: Provide the absolute url of the attachment [Optional]
473
+ @options data {Integer} inline_image: Status of inline image. Possible values = 0 (default) &
474
+ 1. inline_image = 0 means image can’t be embedded, & inline_image = 1 means image can be embedded,
475
+ in the email [Optional]
476
+ @options data {Integer} mirror_active: Status of mirror links in campaign. Possible values = 0 &
477
+ 1 (default). mirror_active = 0 means mirror links are deactivated, & mirror_active = 1 means mirror
478
+ links are activated, in the campaign [Optional]
479
+ @options data {Integer} send_now: Flag to send campaign now. Possible values = 0 (default) & 1.
480
+ send_now = 0 means campaign can’t be send now, & send_now = 1 means campaign ready to send now
481
+ [Optional]
482
+ */
483
+ public function updateTriggerCampaign($data)
484
+ {
485
+ $id = $data['id'];
486
+ unset($data['id']);
487
+ return $this->put("campaign/".$id, json_encode($data));
488
+ }
489
+
490
+ /*
491
+ Get all folders detail.
492
+ @param {Array} data contains php array with key value pair.
493
+ @options data {Integer} page: Maximum number of records per request is 50,
494
+ if there are more than 50 folders then you can use this parameter to get next 50 results [Mandatory]
495
+ @options data {Integer} page_limit: This should be a valid number between 1-50 [Mandatory]
496
+ */
497
+ public function getFolders($data)
498
+ {
499
+ return $this->get("folder", json_encode($data));
500
+ }
501
+
502
+ /*
503
+ Get a particular folder detail.
504
+ @param {Array} data contains php array with key value pair.
505
+ @options data {Integer} id: Id of folder to get details [Mandatory]
506
+ */
507
+ public function getFolder($data)
508
+ {
509
+ return $this->get("folder/".$data['id'], "");
510
+ }
511
+
512
+ /*
513
+ Create a new folder.
514
+ @param {Array} data contains php array with key value pair.
515
+ @options data {String} name: Desired name of the folder to be created [Mandatory]
516
+ */
517
+ public function createFolder($data)
518
+ {
519
+ return $this->post("folder", json_encode($data));
520
+ }
521
+
522
+ /*
523
+ Delete a specific folder information.
524
+ @param {Array} data contains php array with key value pair.
525
+ @options data {Integer} id: Id of folder to be deleted [Mandatory]
526
+ */
527
+ public function deleteFolder($data)
528
+ {
529
+ return $this->delete("folder/".$data['id'], "");
530
+ }
531
+
532
+ /*
533
+ Update an existing folder.
534
+ @param {Array} data contains php array with key value pair.
535
+ @options data {Integer} id: Id of folder to be modified [Mandatory]
536
+ @options data {String} name: Desired name of the folder to be modified [Mandatory]
537
+ */
538
+ public function updateFolder($data)
539
+ {
540
+ $id = $data['id'];
541
+ unset($data['id']);
542
+ return $this->put("folder/".$id, json_encode($data));
543
+ }
544
+
545
+ /*
546
+ Get all lists detail.
547
+ @param {Array} data contains php array with key value pair.
548
+ @options data {Integer} list_parent: This is the existing folder id & can be used to
549
+ get all lists belonging to it [Optional]
550
+ @options data {Integer} page: Maximum number of records per request is 50, if there are
551
+ more than 50 processes then you can use this parameter to get next 50 results [Mandatory]
552
+ @options data {Integer} page_limit: This should be a valid number between 1-50 [Mandatory]
553
+ */
554
+ public function getLists($data)
555
+ {
556
+ return $this->get("list", json_encode($data));
557
+ }
558
+
559
+ /*
560
+ Get a particular list detail.
561
+ @param {Array} data contains php array with key value pair.
562
+ @options data {Integer} id: Id of list to get details [Mandatory]
563
+ */
564
+ public function getList($data)
565
+ {
566
+ return $this->get("list/".$data['id'], "");
567
+ }
568
+
569
+ /*
570
+ Create a new list.
571
+ @param {Array} data contains php array with key value pair.
572
+ @options data {String} list_name: Desired name of the list to be created [Mandatory]
573
+ @options data {Integer} list_parent: Folder ID [Mandatory]
574
+ */
575
+ public function createList($data)
576
+ {
577
+ return $this->post("list", json_encode($data));
578
+ }
579
+
580
+ /*
581
+ Update a list.
582
+ @param {Array} data contains php array with key value pair.
583
+ @options data {Integer} id: Id of list to be modified [Mandatory]
584
+ @options data {String} list_name: Desired name of the list to be modified [Optional]
585
+ @options data {Integer} list_parent: Folder ID [Mandatory]
586
+ */
587
+ public function updateList($data)
588
+ {
589
+ $id = $data['id'];
590
+ unset($data['id']);
591
+ return $this->put("list/".$id, json_encode($data));
592
+ }
593
+
594
+ /*
595
+ Delete a specific list.
596
+ @param {Array} data contains php array with key value pair.
597
+ @options data {Integer} id: Id of list to be deleted [Mandatory]
598
+ */
599
+ public function deleteList($data)
600
+ {
601
+ return $this->delete("list/".$data['id'], "");
602
+ }
603
+
604
+ /*
605
+ Display details of all users for the given lists.
606
+ @param {Array} data contains php array with key value pair.
607
+ @options data {Array} listids: These are the list ids to get their data. The ids found
608
+ will display records [Mandatory]
609
+ @options data {String} timestamp: This is date-time filter to fetch modified user records >=
610
+ this time. Valid format Y-m-d H:i:s. Example: "2015-05-22 14:30:00" [Optional]
611
+ @options data {Integer} page: Maximum number of records per request is 500, if in your list
612
+ there are more than 500 users then you can use this parameter to get next 500 results [Optional]
613
+ @options data {Integer} page_limit: This should be a valid number between 1-500 [Optional]
614
+ */
615
+ public function displayListUsers($data)
616
+ {
617
+ return $this->post("list/display", json_encode($data));
618
+ }
619
+
620
+ /*
621
+ Add already existing users in the SendinBlue contacts to the list.
622
+ @param {Array} data contains php array with key value pair.
623
+ @options data {Integer} id: Id of list to link users in it [Mandatory]
624
+ @options data {Array} users: Email address of the already existing user(s) in the
625
+ SendinBlue contacts. Example: "test@example.net". You can use commas to separate multiple
626
+ users [Mandatory]
627
+ */
628
+
629
+ public function addUsersList($data)
630
+ {
631
+ $id = $data['id'];
632
+ unset($data['id']);
633
+ return $this->post("list/".$id."/users", json_encode($data));
634
+ }
635
+
636
+ /*
637
+ Delete already existing users in the SendinBlue contacts from the list.
638
+ @param {Array} data contains php array with key value pair.
639
+ @options data {Integer} id: Id of list to unlink users from it [Mandatory]
640
+ @options data {Array} users: Email address of the already existing user(s) in the
641
+ SendinBlue contacts to be modified. Example: "test@example.net". You can use commas
642
+ to separate multiple users [Mandatory]
643
+ */
644
+ public function deleteUsersList($data)
645
+ {
646
+ $id = $data['id'];
647
+ unset($data['id']);
648
+ return $this->delete("list/".$id."/delusers", json_encode($data));
649
+ }
650
+
651
+ /*
652
+ Access all the attributes information under the account.
653
+ No input required
654
+ */
655
+ public function getAttributes()
656
+ {
657
+ return $this->get("attribute", "");
658
+ }
659
+
660
+ /*
661
+ Access the specific type of attribute information.
662
+ @param {Array} data contains php array with key value pair.
663
+ @options data {String} type: Type of attribute. Possible values – normal, transactional,
664
+ category, calculated & global [Optional]
665
+ */
666
+ public function getAttribute($data)
667
+ {
668
+ return $this->get("attribute/".$data['type'], "");
669
+ }
670
+
671
+ /*
672
+ Create an Attribute.
673
+ @param {Array} data contains php array with key value pair.
674
+ @options data {String} type: Type of attribute. Possible values – normal, transactional,
675
+ category, calculated & global ( case sensitive ) [Mandatory]
676
+ @options data {Array} data: The name and data type of ‘normal’ & ‘transactional’ attribute
677
+ to be created in your SendinBlue account. It should be sent as an associative array. Example:
678
+ array(‘ATTRIBUTE_NAME1′ => ‘DATA_TYPE1′, ‘ATTRIBUTE_NAME2’=> ‘DATA_TYPE2′).
679
+ The name and data value of ‘category’, ‘calculated’ & ‘global’, should be sent as JSON string.
680
+ Example: ‘[{ "name":"ATTRIBUTE_NAME1", "value":"Attribute_value1" }, { "name":"ATTRIBUTE_NAME2",
681
+ "value":"Attribute_value2" }]’. You can use commas to separate multiple attributes [Mandatory]
682
+ */
683
+ public function createAttribute($data)
684
+ {
685
+ return $this->post("attribute/", json_encode($data));
686
+ }
687
+
688
+ /*
689
+ Delete a specific type of attribute information.
690
+ @param {Array} data contains php array with key value pair.
691
+ @options data {Integer} type: Type of attribute to be deleted [Mandatory]
692
+ */
693
+ public function deleteAttribute($type, $data)
694
+ {
695
+ $type = $data['type'];
696
+ unset($data['type']);
697
+ return $this->post("attribute/".$type, json_encode($data));
698
+ }
699
+
700
+ /*
701
+ Create a new user if an email provided as input, doesn’t exists in the contact list
702
+ of your SendinBlue account, otherwise it will update the existing user.
703
+ @param {Array} data contains php array with key value pair.
704
+ @options data {String} email: Email address of the user to be created in SendinBlue contacts.
705
+ Already existing email address of user in the SendinBlue contacts to be modified [Mandatory]
706
+ @options data {Array} attributes: The name of attribute present in your SendinBlue account.
707
+ It should be sent as an associative array. Example: array("NAME"=>"name"). You can use commas
708
+ to separate multiple attributes [Optional]
709
+ @options data {Integer} blacklisted: This is used to blacklist/ Unblacklist a user. Possible
710
+ values – 0 & 1. blacklisted = 1 means user has been blacklisted [Optional]
711
+ @options data {Array} listid: The list id(s) to be linked from user [Optional]
712
+ @options data {Array} listid_unlink: The list id(s) to be unlinked from user [Optional]
713
+ @options data {Array} blacklisted_sms: This is used to blacklist/ Unblacklist a user’s SMS
714
+ number. Possible values – 0 & 1. blacklisted_sms = 1 means user’s SMS number has been
715
+ blacklisted [Optional]
716
+ */
717
+ public function createUpdateUser($data)
718
+ {
719
+ return $this->post("user/createdituser", json_encode($data));
720
+ }
721
+
722
+ /*
723
+ Get Access a specific user Information.
724
+ @param {Array} data contains php array with key value pair.
725
+ @options data {String} email: Email address of the already existing user in the SendinBlue
726
+ contacts [Mandatory]
727
+ */
728
+ public function getUser($data)
729
+ {
730
+ return $this->get("user/".$data['email'], "");
731
+ }
732
+
733
+ /*
734
+ Unlink existing user from all lists.
735
+ @param {Array} data contains php array with key value pair.
736
+ @options data {String} email: Email address of the already existing user in the SendinBlue
737
+ contacts to be unlinked from all lists [Mandatory]
738
+ */
739
+ public function deleteUser($data)
740
+ {
741
+ return $this->delete("user/".$data['email'], "");
742
+ }
743
+
744
+ /*
745
+ Import Users Information.
746
+ @param {Array} data contains php array with key value pair.
747
+ @options data {String} url: The URL of the file to be imported. Possible file types – .txt,
748
+ .csv [Mandatory: if body is empty]
749
+ @options data {String} body: The Body with csv content to be imported. Example: ‘NAME;SURNAME;
750
+ EMAIL\n"Name1";"Surname1";"example1@example.net"\n"Name2";"Surname2";"example2@example.net"‘,
751
+ where \n separates each user data. You can use semicolon to separate multiple attributes
752
+ [Mandatory: if url is empty]
753
+ @options data {Array} listids: These are the list ids in which the the users will be imported
754
+ [Mandatory: if name is empty]
755
+ @options data {String} notify_url: URL that will be called once the import process is finished
756
+ [Optional] In notify_url, we are sending the content using POST method
757
+ @options data {String} name: This is new list name which will be created first & then users will
758
+ be imported in it [Mandatory: if listids is empty]
759
+ @options data {Integer} list_parent: This is the existing folder id & can be used with name
760
+ parameter to make newly created list’s desired parent [Optional]
761
+ */
762
+ public function importUsers($data)
763
+ {
764
+ return $this->post("user/import", json_encode($data));
765
+ }
766
+
767
+ /*
768
+ Export Users Information.
769
+ @param {Array} data contains php array with key value pair.
770
+ @options data {String} export_attrib: The name of attribute present in your SendinBlue account.
771
+ You can use commas to separate multiple attributes. Example: "EMAIL,NAME,SMS" [Optional]
772
+ @options data {String} filter: Filter can be added to export users. Example: "{\"blacklisted\":1}",
773
+ will export all blacklisted users [Mandatory]
774
+ @options data {String} notify_url: URL that will be called once the export process is finished
775
+ [Optional]
776
+ */
777
+ public function exportUsers($data)
778
+ {
779
+ return $this->post("user/export", json_encode($data));
780
+ }
781
+
782
+ /*
783
+ Get all the processes information under the account.
784
+ @param {Array} data contains php array with key value pair.
785
+ @options data {Integer} page: Maximum number of records per request is 50, if there are more than 50
786
+ processes then you can use this parameter to get next 50 results [Mandatory]
787
+ @options data {Integer} page_limit: This should be a valid number between 1-50 [Mandatory]
788
+ */
789
+ public function getProcesses($data)
790
+ {
791
+ return $this->get("process", json_encode($data));
792
+ }
793
+
794
+ /*
795
+ Get the process information.
796
+ @param {Array} data contains php array with key value pair.
797
+ @options data {Integer} id: Id of process to get details [Mandatory]
798
+ */
799
+ public function getProcess($data)
800
+ {
801
+ return $this->get("process/".$data['id'], "");
802
+ }
803
+
804
+ /*
805
+ To retrieve details of all webhooks.
806
+ @param {Array} data contains php array with key value pair.
807
+ @options data {String} is_plat: Flag to get webhooks. Possible values – 0 & 1. Example: to get
808
+ Transactional webhooks, use $is_plat=0, to get Marketing webhooks, use $is_plat=1, & to get all
809
+ webhooks, use $is_plat="" [Optional]
810
+ */
811
+ public function getWebhooks($data)
812
+ {
813
+ return $this->get("webhook", json_encode($data));
814
+ }
815
+
816
+ /*
817
+ To retrieve details of any particular webhook.
818
+ @param {Array} data contains php array with key value pair.
819
+ @options data {Integer} id: Id of webhook to get details [Mandatory]
820
+ */
821
+ public function getWebhook($data)
822
+ {
823
+ return $this->get("webhook/".$data['id'], "");
824
+ }
825
+
826
+ /*
827
+ Create a Webhook.
828
+ @param {Array} data contains php array with key value pair.
829
+ @options data {String} url: URL that will be triggered by a webhook [Mandatory]
830
+ @options data {String} description: Webook description [Optional]
831
+ @options data {Array} events: Set of events. You can use commas to separate multiple events.
832
+ Possible values for Transcational webhook – request, delivered, hard_bounce, soft_bounce, blocked,
833
+ spam, invalid_email, deferred, click, & opened and Possible Values for Marketing webhook – spam,
834
+ opened, click, hard_bounce, unsubscribe, soft_bounce & list_addition ( case sensitive ) [Mandatory]
835
+ @options data {Integer} is_plat: Flag to create webhook type. Possible values – 0 (default) & 1.
836
+ Example: to create Transactional webhooks, use $is_plat=0, & to create Marketing webhooks, use
837
+ $is_plat=1 [Optional]
838
+ */
839
+ public function createWebhook($data)
840
+ {
841
+ return $this->post("webhook", json_encode($data));
842
+ }
843
+
844
+ /*
845
+ Delete a webhook.
846
+ @param {Array} data contains php array with key value pair.
847
+ @options data {Integer} id: Id of webhook to be deleted [Mandatory]
848
+ */
849
+ public function deleteWebhook($data)
850
+ {
851
+ return $this->delete("webhook/".$data['id'], "");
852
+ }
853
+
854
+ /*
855
+ Update a webhook.
856
+ @param {Array} data contains php array with key value pair.
857
+ @options data {Integer} id: Id of webhook to be modified [Mandatory]
858
+ @options data {String} url: URL that will be triggered by a webhook [Mandatory]
859
+ @options data {String} description: Webook description [Optional]
860
+ @options data {Array} events: Set of events. You can use commas to separate multiple events.
861
+ Possible values for Transcational webhook – request, delivered, hard_bounce, soft_bounce, blocked,
862
+ spam, invalid_email, deferred, click, & opened and Possible Values for Marketing webhook – spam,
863
+ opened, click, hard_bounce, unsubscribe, soft_bounce & list_addition ( case sensitive ) [Mandatory]
864
+ */
865
+ public function updateWebhook($data)
866
+ {
867
+ $id = $data['id'];
868
+ unset($data['id']);
869
+ return $this->put("webhook/".$id, json_encode($data));
870
+ }
871
+
872
+ /*
873
+ Get Access of created senders information.
874
+ @param {Array} data contains php array with key value pair.
875
+ @options data {String} option: Options to get senders. Possible options – IP-wise, & Domain-wise
876
+ ( only for dedicated IP clients ). Example: to get senders with specific IP, use $option=’1.2.3.4′,
877
+ to get senders with specific domain use, $option=’domain.com’, & to get all senders, use $option=""
878
+ [Optional]
879
+ */
880
+ public function getSenders($data)
881
+ {
882
+ return $this->get("advanced", json_encode($data));
883
+ }
884
+
885
+ /*
886
+ Create your Senders.
887
+ @param {Array} data contains php array with key value pair.
888
+ @options data {String} name: Name of the sender [Mandatory]
889
+ @options data {String} email: Email address of the sender [Mandatory]
890
+ @options data {Array} ip_domain: Pass pipe ( | ) separated Dedicated IP and its associated Domain.
891
+ Example: "1.2.3.4|mydomain.com". You can use commas to separate multiple ip_domain’s [Mandatory: Only
892
+ for Dedicated IP clients, for Shared IP clients, it should be kept blank]
893
+ */
894
+ public function createSender($data)
895
+ {
896
+ return $this->post("advanced", json_encode($data));
897
+ }
898
+
899
+ /*
900
+ Update your Senders.
901
+ @param {Array} data contains php array with key value pair.
902
+ @options data {Integer} id: Id of sender to be modified [Mandatory]
903
+ @options data {String} name: Name of the sender [Mandatory]
904
+ @options data {Array} ip_domain: Pass pipe ( | ) separated Dedicated IP and its associated Domain.
905
+ Example: "1.2.3.4|mydomain.com". You can use commas to separate multiple ip_domain’s [Mandatory:
906
+ Only for Dedicated IP clients, for Shared IP clients, it should be kept blank]
907
+ */
908
+ public function updateSender($data)
909
+ {
910
+ $id = $data['id'];
911
+ unset($data['id']);
912
+ return $this->put("advanced/".$id, json_encode($data));
913
+ }
914
+
915
+ /*
916
+ Delete your Sender Information.
917
+ @param {Array} data contains php array with key value pair.
918
+ @options data {Integer} id: Id of sender to be deleted [Mandatory]
919
+ */
920
+ public function deleteSender($data)
921
+ {
922
+ return $this->delete("advanced/".$data['id'], "");
923
+ }
924
+
925
+ /*
926
+ Send Transactional Email.
927
+ @param {Array} data contains php array with key value pair.
928
+ @options data {Array} to: Email address of the recipient(s). It should be sent as an associative
929
+ array. Example: array("to@example.net"=>"to whom"). You can use commas to separate multiple recipients
930
+ [Mandatory]
931
+ @options data {String} subject: Message subject [Mandatory]
932
+ @options data {Array} from Email address for From header. It should be sent as an array. Example: array
933
+ ("from@email.com","from email") [Mandatory]
934
+ @options data {String} html: Body of the message. (HTML version) [Mandatory]. To send inline images,
935
+ use <img src="{YourFileName.Extension}" alt="image" border="0" >, the 'src' attribute value inside {}
936
+ (curly braces) should be same as the filename used in 'inline_image' parameter
937
+ @options data {String} text: Body of the message. (text version) [Optional]
938
+ @options data {Array} cc: Same as to but for Cc. Example: array("cc@example.net","cc whom") [Optional]
939
+ @options data {Array} bcc: Same as to but for Bcc. Example: array("bcc@example.net","bcc whom")
940
+ [Optional]
941
+ @options data {Array} replyto: Same as from but for Reply To. Example: array("from@email.com","from
942
+ email") [Optional]
943
+ @options data {Array} attachment: Provide the absolute url of the attachment/s. Possible extension
944
+ values = gif, png, bmp, cgm, jpg, jpeg, txt, css, shtml, html, htm, csv, zip, pdf, xml, doc, xls, ppt,
945
+ tar, and ez. To send attachment/s generated on the fly you have to pass your attachment/s filename &
946
+ its base64 encoded chunk data as an associative array. Example: array("YourFileName.
947
+ Extension"=>"Base64EncodedChunkData"). You can use commas to separate multiple attachments [Optional]
948
+ @options data {Array} headers: The headers will be sent along with the mail headers in original email.
949
+ Example: array("Content-Type"=>"text/html; charset=iso-8859-1"). You can use commas to separate
950
+ multiple headers [Optional]
951
+ @options data {Array} inline_image: Pass your inline image/s filename & its base64 encoded chunk
952
+ data as an associative array. Example: array("YourFileName.Extension"=>"Base64EncodedChunkData").
953
+ You can use commas to separate multiple inline images [Optional]
954
+ */
955
+ public function sendEmail($data)
956
+ {
957
+ return $this->post("email", json_encode($data));
958
+ }
959
+
960
+ /*
961
+ Aggregate / date-wise report of the SendinBlue SMTP account.
962
+ @param {Array} data contains php array with key value pair.
963
+ @options data {Integer} aggregate: This is used to indicate, you are interested in all-time totals.
964
+ Possible values – 0 & 1. aggregate = 0 means it will not aggregate records, and will show stats per
965
+ day/date wise [Optional]
966
+ @options data {String} start_date: The start date to look up statistics. Date must be in YYYY-MM-DD
967
+ format and should be before the end_date [Optional]
968
+ @options data {String} end_date: The end date to look up statistics. Date must be in YYYY-MM-DD
969
+ format and should be after the start_date [Optional]
970
+ @options data {Integer} days: Number of days in the past to include statistics ( Includes today ).
971
+ It must be an integer greater than 0 [Optional]
972
+ @options data {String} tag: The tag you will specify to retrieve detailed stats. It must be an
973
+ existing tag that has statistics [Optional]
974
+ */
975
+ public function getStatistics($data)
976
+ {
977
+ return $this->post("statistics", json_encode($data));
978
+ }
979
+
980
+ /*
981
+ Get Email Event report.
982
+ @param {Array} data contains php array with key value pair.
983
+ @options data {Integer} limit: To limit the number of results returned. It should be an integer
984
+ [Optional]
985
+ @options data {String} start_date: The start date to get report from. Date must be in YYYY-MM-DD
986
+ format and should be before the end_date [Optional]
987
+ @options data {String} end_date: The end date to get report till date. Date must be in YYYY-MM-DD
988
+ format and should be after the start_date [Optional]
989
+ @options data {Integer} offset: Beginning point in the list to retrieve from. It should be an integer
990
+ [Optional]
991
+ @options data {String} date: Specific date to get its report. Date must be in YYYY-MM-DD format and
992
+ should be earlier than todays date [Optional]
993
+ @options data {Integer} days: Number of days in the past (includes today). If specified, must be an
994
+ integer greater than 0 [Optional]
995
+ @options data {String} email: Email address to search report for [Optional]
996
+ */
997
+ public function getReport($data)
998
+ {
999
+ return $this->post("report", json_encode($data));
1000
+ }
1001
+
1002
+ /*
1003
+ Delete any hardbounce, which actually would have been blocked due to some temporary ISP failures.
1004
+ @param {Array} data contains php array with key value pair.
1005
+ @options data {String} start_date: The start date to get report from. Date must be in
1006
+ YYYY-MM-DD format and should be before the end_date [Optional]
1007
+ @options data {String} end_date: The end date to get report till date. Date must be in
1008
+ YYYY-MM-DD format and should be after the start_date [Optional]
1009
+ @options data {String} email: Email address to delete its bounces [Optional]
1010
+ */
1011
+ public function deleteBounces($data)
1012
+ {
1013
+ return $this->post("bounces", json_encode($data));
1014
+ }
1015
+
1016
+ /*
1017
+ Send templates created on SendinBlue, through SendinBlue SMTP (transactional mails).
1018
+ @param {Array} data contains php array with key value pair.
1019
+ @options data {Integer} id: Id of the template created on SendinBlue account [Mandatory]
1020
+ @options data {String} to: Email address of the recipient(s). You can use pipe ( | )
1021
+ to separate multiple recipients. Example: "to-example@example.net|to2-example@example.net"
1022
+ [Mandatory]
1023
+ @options data {String} cc: Same as to but for Cc [Optional]
1024
+ @options data {String} bcc: Same as to but for Bcc [Optional]
1025
+ @options data {Array} attrv The name of attribute present in your SendinBlue account. It should
1026
+ be sent as an associative array. Example: array("NAME"=>"name"). You can use commas to separate
1027
+ multiple attributes [Optional]
1028
+ @options data {String} attachment_url: Provide the absolute url of the attachment. Url not allowed
1029
+ from local machine. File must be hosted somewhere [Optional]
1030
+ @options data {Array} attachment: To send attachment/s generated on the fly you have to pass
1031
+ your attachment/s filename & its base64 encoded chunk data as an associative array [Optional]
1032
+ */
1033
+ public function sendTransactionalTemplate($data)
1034
+ {
1035
+ $id = $data['id'];
1036
+ unset($data['id']);
1037
+ return $this->put("template/".$id, json_encode($data));
1038
+ }
1039
+
1040
+ /*
1041
+ Create a Template.
1042
+ @param {Array} data contains php array with key value pair.
1043
+ @options data {String} from_name: Sender name from which the campaign emails are sent
1044
+ [Mandatory: for Dedicated IP clients & for Shared IP clients, if sender exists]
1045
+ @options data {String} template_name: Name of the Template [Mandatory]
1046
+ @options data {String} bat: Email address for test mail [Optional]
1047
+ @options data {String} html_content: Body of the content. The HTML content field must have more
1048
+ than 10 characters [Mandatory: if html_url is empty]
1049
+ @options data {String} html_url Url: which content is the body of content [Mandatory: if
1050
+ html_content is empty]
1051
+ @options data {String} subject: Subject of the campaign [Mandatory]
1052
+ @options data {String} from_email: Sender email from which the campaign emails are sent
1053
+ [Mandatory: for Dedicated IP clients & for Shared IP clients, if sender exists]
1054
+ @options data {String} reply_to: The reply to email in the campaign emails [Optional]
1055
+ @options data {String} to_fieldv This is to personalize the «To» Field. If you want to include
1056
+ the first name and last name of your recipient, add [PRENOM] [NOM]. To use the contact attributes
1057
+ here, these should already exist in SendinBlue account [Optional]
1058
+ @options data {Integer} status: Status of template. Possible values = 0 (default) & 1. status = 0
1059
+ means template is inactive, & status = 1 means template is active [Optional]
1060
+ @options data {Integer} attachment: Status of attachment. Possible values = 0 (default) & 1.
1061
+ attach = 0 means an attachment can’t be sent, & attach = 1 means an attachment can be sent, in
1062
+ the email [Optional]
1063
+ */
1064
+ public function createTemplate($data)
1065
+ {
1066
+ return $this->post("template", json_encode($data));
1067
+ }
1068
+
1069
+ /*
1070
+ Update a Template.
1071
+ @param {Array} data contains php array with key value pair.
1072
+ @options data {Integer} id: Id of Template to be modified [Mandatory]
1073
+ @options data {String} from_name: Sender name from which the campaign emails are sent
1074
+ [Mandatory: for Dedicated IP clients & for Shared IP clients, if sender exists]
1075
+ @options data {String} template_name: Name of the Template [Mandatory]
1076
+ @options data {String} bat: Email address for test mail [Optional]
1077
+ @options data {String} html_content: Body of the content. The HTML content field must have
1078
+ more than 10 characters [Mandatory: if html_url is empty]
1079
+ @options data {String} html_url: Url which content is the body of content [Mandatory: if
1080
+ html_content is empty]
1081
+ @options data {String} subject: Subject of the campaign [Mandatory]
1082
+ @options data {String} from_email: Sender email from which the campaign emails are sent
1083
+ [Mandatory: for Dedicated IP clients & for Shared IP clients, if sender exists]
1084
+ @options data {String} reply_to: The reply to email in the campaign emails [Optional]
1085
+ @options data {String} to_field: This is to personalize the «To» Field. If you want to include the
1086
+ first name and last name of your recipient, add [PRENOM] [NOM]. To use the contact attributes here,
1087
+ these should already exist in SendinBlue account [Optional]
1088
+ @options data {Integer} status: Status of template. Possible values = 0 (default) & 1. status = 0
1089
+ means template is inactive, & status = 1 means template is active [Optional]
1090
+ @options data {Integer} attachment: Status of attachment. Possible values = 0 (default) & 1.
1091
+ attach = 0 means an attachment can’t be sent, & attach = 1 means an attachment can be sent, in the
1092
+ email [Optional]
1093
+ */
1094
+ public function updateTemplate($data)
1095
+ {
1096
+ $id = $data['id'];
1097
+ unset($data['id']);
1098
+ return $this->put("template/".$id, json_encode($data));
1099
+ }
1100
+
1101
+ /*
1102
+ Send a transactional SMS.
1103
+ @param {Array} data contains php array with key value pair.
1104
+ @options data {String} to: The mobile number to send SMS to with country code [Mandatory]
1105
+ @options data {String} from: The name of the sender. The number of characters is limited to 11
1106
+ (alphanumeric format) [Mandatory]
1107
+ @options data {String} text: The text of the message. The maximum characters used per SMS is 160,
1108
+ if used more than that, it will be counted as more than one SMS [Mandatory]
1109
+ @options data {String} web_url: The web URL that can be called once the message is successfully
1110
+ delivered [Optional]
1111
+ @options data {String} tag: The tag that you can associate with the message [Optional]
1112
+ @options data {String} type: Type of message. Possible values – marketing (default) & transactional.
1113
+ You can use marketing for sending marketing SMS, & for sending transactional SMS, use transactional
1114
+ type [Optional]
1115
+ */
1116
+ public function sendSms($data)
1117
+ {
1118
+ return $this->post("sms", json_encode($data));
1119
+ }
1120
+
1121
+ /*
1122
+ Create & Schedule your SMS campaigns.
1123
+ @param {Array} data contains php array with key value pair.
1124
+ @options data {String} name: Name of the SMS campaign [Mandatory]
1125
+ @options data {String} sender: This allows you to customize the SMS sender. The number of
1126
+ characters is limited to 11 ( alphanumeric format ) [Optional]
1127
+ @options data {String} content: Content of the message. The maximum characters used per SMS is 160,
1128
+ if used more than that, it will be counted as more than one SMS [Optional]
1129
+ @options data {String} bat: Mobile number with the country code to send test SMS. The mobile number
1130
+ defined here should belong to one of your contacts in SendinBlue account and should not be blacklisted
1131
+ [Optional]
1132
+ @options data {Array} listid: These are the list ids to which the SMS campaign is sent [Mandatory: if
1133
+ scheduled_date is not empty]
1134
+ @options data {Array} exclude_list: These are the list ids which will be excluded from the SMS
1135
+ campaign [Optional]
1136
+ @options data {String} scheduled_date: The day on which the SMS campaign is supposed to run [Optional]
1137
+ @options data {Integer} send_now: Flag to send campaign now. Possible values = 0 (default) & 1.
1138
+ send_now = 0 means campaign can’t be send now, & send_now = 1 means campaign ready to send now
1139
+ [Optional]
1140
+ */
1141
+ public function createSmsCampaign($data)
1142
+ {
1143
+ return $this->post("sms", json_encode($data));
1144
+ }
1145
+
1146
+ /*
1147
+ Update your SMS campaigns.
1148
+ @param {Array} data contains php array with key value pair.
1149
+ @options data {Integer} id: Id of the SMS campaign [Mandatory]
1150
+ @options data {String} name: Name of the SMS campaign [Optional]
1151
+ @options data {String} sender: This allows you to customize the SMS sender. The number of characters
1152
+ is limited to 11 ( alphanumeric format ) [Optional]
1153
+ @options data {String} content: Content of the message. The maximum characters used per SMS is 160,
1154
+ if used more than that, it will be counted as more than one SMS [Optional]
1155
+ @options data {String} bat: Mobile number with the country code to send test SMS. The mobile number
1156
+ defined here should belong to one of your contacts in SendinBlue account and should not be blacklisted
1157
+ [Optional]
1158
+ @options data {Array} listid: hese are the list ids to which the SMS campaign is sent [Mandatory: if
1159
+ scheduled_date is not empty]
1160
+ @options data {Array} exclude_list: These are the list ids which will be excluded from the SMS campaign
1161
+ [Optional]
1162
+ @options data {String} scheduled_date: The day on which the SMS campaign is supposed to run [Optional]
1163
+ @options data {Integer} send_now: Flag to send campaign now. Possible values = 0 (default) & 1.
1164
+ send_now = 0 means campaign can’t be send now, & send_now = 1 means campaign ready to send now
1165
+ [Optional]
1166
+ */
1167
+ public function updateSmsCampaign($data)
1168
+ {
1169
+ $id = $data['id'];
1170
+ unset($data['id']);
1171
+ return $this->put("sms/".$id, json_encode($data));
1172
+ }
1173
+
1174
+ /*
1175
+ Send a Test SMS.
1176
+ @param {Array} data contains php array with key value pair.
1177
+ @options data {Integer} id: Id of the SMS campaign [Mandatory]
1178
+ @options data {String} to: Mobile number with the country code to send test SMS. The mobile
1179
+ number defined here should belong to one of your contacts in SendinBlue account and should not be
1180
+ blacklisted [Mandatory]
1181
+ */
1182
+ public function sendBatSms($data)
1183
+ {
1184
+ $id = $data['id'];
1185
+ unset($data['id']);
1186
+ return $this->get("sms/".$id, json_encode($data));
1187
+ }
1188
+
1189
+
1190
+ public function updateMailinParter($data)
1191
+ {
1192
+ return $this->put("account/mailin_partner", json_encode($data));
1193
+ }
1194
+
1195
+ /*
1196
+ Get SMTP details.
1197
+ */
1198
+ public function getPluginConfig()
1199
+ {
1200
+ return $this->get("account/plugin_config", "");
1201
+ }
1202
+
1203
+ /*
1204
+ Get blacklist status of user and other details retrieved.
1205
+ @param {Array} data contains php array with key value pair.
1206
+ @options data {String} Emailids: get list of email ids [Mandatory]
1207
+ */
1208
+ public function getUsersBlacklistStatus($data)
1209
+ {
1210
+ return $this->post("user/get_blacklist_status",json_encode($data));
1211
+ }
1212
+
1213
+ /*
1214
+ This api is used to synchronize user status.
1215
+ */
1216
+ public function syncUsersStatus($data)
1217
+ {
1218
+ return $this->put("user/sync_status", json_encode($data));
1219
+ }
1220
+
1221
+ /*
1222
+ Get all folders and it lists data for that user.
1223
+ */
1224
+ public function displayFoldersLists()
1225
+ {
1226
+ return $this->get("folder/display_folder_lists", "");
1227
+ }
1228
+
1229
+ /*
1230
+ Get all lists of data for that user.
1231
+ */
1232
+ public function displayListForPlugin()
1233
+ {
1234
+ return $this->get("list/display_list_for_plugin", "");
1235
+ }
1236
+
1237
+ /*
1238
+ This API is used to update user subscription status.
1239
+ @param {Array} data contains php array with key value pair.
1240
+ @options data {string} timezone: Time zone of that user [Mandatory]
1241
+ @options data {String} user_status: User status that inclue email, status, and Time [Mandatory]
1242
+ */
1243
+ public function updateUserSubscriptionStatus($data)
1244
+ {
1245
+ return $this->post("user/update_user_subscription_status", json_encode($data));
1246
+ }
1247
+
1248
+ /*
1249
+ This is used to get black list data.
1250
+ @param {Array} data contains php array with key value pair.
1251
+ @options data {string} listids: List of ids [Mandatory]
1252
+ */
1253
+ public function getListUsersBlacklistStatus($data)
1254
+ {
1255
+ return $this->post("list/display_list_users_blacklist_status", json_encode($data));
1256
+ }
1257
+
1258
+ /*
1259
+ This function is used to unsubscribe a user by email id and list id.
1260
+ @param {Array} data contains php array with key value pair.
1261
+ @options data {String} Emails: List of emails
1262
+ @options data {Integer} Ids: id of lists
1263
+ */
1264
+ public function unSubscribApi($data)
1265
+ {
1266
+ return $this->post("user/un_subscrib_api", json_encode($data));
1267
+ }
1268
+
1269
+ /*
1270
+ This api is used to Add multiple users.
1271
+ */
1272
+ public function addMultipleUser($data)
1273
+ {
1274
+ return $this->post("user/add_multiple_users", json_encode($data));
1275
+ }
1276
+
1277
+ /*
1278
+ This function is used to unsubscribe a user SMS service by email id and list id.
1279
+ */
1280
+ public function userSmsUnsubscribed($data)
1281
+ {
1282
+ return $this->post("user/user_sms_unsubscribed", json_encode($data));
1283
+ }
1284
+ }
app/code/community/Sendinblue/Sendinblue/Model/Sendinblue.php ADDED
@@ -0,0 +1,1636 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 $apiKey;
13
+ var $smtpStatus;
14
+ var $errorMessage;
15
+ var $errorCode;
16
+ var $listsIds;
17
+ var $moduleEnable;
18
+ var $st;
19
+ public function _construct()
20
+ {
21
+ parent::_construct();
22
+ $this->_init('sendinblue/sendinblue');
23
+ $this->MIAPI();
24
+
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->moduleEnable = $this->getEnableStatus($scope);
33
+ $this->apiKey = $this->getApiKey();
34
+ $valueLanguage = $this->getApiConfigValue();
35
+ if(isset($valueLanguage['data']['language'])) {
36
+ $this->userLanguage = $valueLanguage['data']['language'];
37
+ }
38
+
39
+ if (!$this->listsIds) {
40
+ $this->listsIds = str_replace(',', '|', $this->getUserlists($scope));
41
+ }
42
+
43
+ $params = Mage::app()->getRequest()->getParams();
44
+ $params = empty($params)?array():$params;
45
+ if (isset($params['sendin_apikey']) && $params['sendin_apikey'] != '') {
46
+ $this->CreateFolderCaseTwo();
47
+ }
48
+ }
49
+
50
+ public function checkMobileNumber($number, $callPrefix)
51
+ {
52
+ $number = preg_replace('/\s+/', '', $number);
53
+ $charOne = substr($number, 0, 1);
54
+ $charTwo = substr($number, 0, 2);
55
+
56
+ if (preg_match('/^'.$callPrefix.'/', $number)) {
57
+ return '00'.$number;
58
+ }
59
+
60
+ elseif ($charOne == '0' && $charTwo != '00') {
61
+ if (preg_match('/^0'.$callPrefix.'/', $number)) {
62
+ return '00'.substr($number, 1);
63
+ }
64
+ else {
65
+ return '00'.$callPrefix.substr($number, 1);
66
+ }
67
+ }
68
+ elseif ($charTwo == '00') {
69
+ if (preg_match('/^00'.$callPrefix.'/', $number)) {
70
+ return $number;
71
+ }
72
+ else {
73
+ return '00'.$callPrefix.substr($number, 2);
74
+ }
75
+ }
76
+ elseif ($charOne == '+') {
77
+ if (preg_match('/^\+'.$callPrefix.'/', $number)) {
78
+ return '00'.substr($number, 1);
79
+ }
80
+ else {
81
+ return '00'.$callPrefix.substr($number, 1);
82
+ }
83
+ }
84
+ elseif ($charOne != '0') {
85
+ return '00'.$callPrefix.$number;
86
+ }
87
+ }
88
+ /**
89
+ * functions used for getting module status
90
+ */
91
+ public function getEnableStatus()
92
+ {
93
+ $status = $this->getGeneralConfig('enabled', Mage::app()->getStore()->getStoreId());
94
+ if (!$status) {
95
+ return false;
96
+ }
97
+ return $status;
98
+ }
99
+ /**
100
+ * functions used for send order sms module status
101
+ */
102
+ public function getOrderSmsStatus()
103
+ {
104
+ $status = $this->getGeneralConfig('sms/order', Mage::app()->getStore()->getStoreId());
105
+ if (!$status) {
106
+ return false;
107
+ }
108
+ return $status;
109
+ }
110
+ /**
111
+ * functions used for getting notify sms status
112
+ */
113
+ public function getNotifySmsStatus()
114
+ {
115
+ $status = $this->getGeneralConfig('sms/credit', Mage::app()->getStore()->getStoreId());
116
+ if (!$status) {
117
+ return false;
118
+ }
119
+ return $status;
120
+ }
121
+ /**
122
+ * functions used for getting Notify value limit
123
+ */
124
+ public function getNotifyValueStatus()
125
+ {
126
+ $status = $this->getGeneralConfig('Sendin_Notify_Value', Mage::app()->getStore()->getStoreId());
127
+ if (!$status) {
128
+ return false;
129
+ }
130
+ return $status;
131
+ }
132
+ /**
133
+ * functions used for getting Notify email limit
134
+ */
135
+ public function getNotifyEmailStatus()
136
+ {
137
+ $status = $this->getGeneralConfig('Sendin_Notify_Email', Mage::app()->getStore()->getStoreId());
138
+ if (!$status) {
139
+ return false;
140
+ }
141
+ return $status;
142
+ }
143
+ /**
144
+ * functions used for getting Notify email limit
145
+ */
146
+ public function getNotifyCronStatus()
147
+ {
148
+ $status = $this->getGeneralConfig('Sendin_Notify_Cron_Executed', Mage::app()->getStore()->getStoreId());
149
+ if (!$status) {
150
+ return false;
151
+ }
152
+ return $status;
153
+ }
154
+ /**
155
+ * functions used for getting shiping sms status
156
+ */
157
+ public function getShipingSmsStatus()
158
+ {
159
+ $status = $this->getGeneralConfig('sms/shiping', Mage::app()->getStore()->getStoreId());
160
+ if (!$status) {
161
+ return false;
162
+ }
163
+ return $status;
164
+ }
165
+
166
+ /**
167
+ * functions used for getting campaign sms status
168
+ */
169
+ public function getCampaignStatus()
170
+ {
171
+ $status = $this->getGeneralConfig('sms/campaign', Mage::app()->getStore()->getStoreId());
172
+ if (!$status) {
173
+ return false;
174
+ }
175
+ return $status;
176
+ }
177
+
178
+ /**
179
+ * functions used for getting send sms order subject
180
+ */
181
+ public function getSendSmsOrderSubject()
182
+ {
183
+ $status = $this->getGeneralConfig('Sendin_Sender_Order', Mage::app()->getStore()->getStoreId());
184
+ if (!$status) {
185
+ return false;
186
+ }
187
+ return $status;
188
+ }
189
+
190
+ /**
191
+ * functions used for getting order sms message
192
+ */
193
+ public function getSendSmsmOrderMessage()
194
+ {
195
+ $status = $this->getGeneralConfig('Sendin_Sender_Order_Message', Mage::app()->getStore()->getStoreId());
196
+ if (!$status) {
197
+ return false;
198
+ }
199
+ return $status;
200
+ }
201
+
202
+ /**
203
+ *functions used for getting send sms shiping subject
204
+ */
205
+ public function getSendSmsShipingSubject()
206
+ {
207
+ $status = $this->getGeneralConfig('Sendin_Sender_Shipment', Mage::app()->getStore()->getStoreId());
208
+ if (!$status) {
209
+ return false;
210
+ }
211
+ return $status;
212
+ }
213
+
214
+ /**
215
+ *functions used for getting shiping sms message
216
+ */
217
+ public function getSendSmsShipingMessage()
218
+ {
219
+ $status = $this->getGeneralConfig('Sendin_Sender_Shipment_Message', Mage::app()->getStore()->getStoreId());
220
+ if (!$status) {
221
+ return false;
222
+ }
223
+ return $status;
224
+ }
225
+
226
+ /**
227
+ * functions used for get api key
228
+ */
229
+ public function getApiKey()
230
+ {
231
+ $apikey = $this->getGeneralConfig('api', Mage::app()->getStore()->getStoreId());
232
+ if (!$apikey) {
233
+ return false;
234
+ }
235
+ return $apikey;
236
+ }
237
+
238
+ /**
239
+ * functions used for get SMPT password
240
+ */
241
+ public function getSmtpPassword()
242
+ {
243
+ $smtpPassword = $this->getSendinSmtpStatus('password', Mage::app()->getStore()->getStoreId());
244
+ if (!$smtpPassword) {
245
+ return false;
246
+ }
247
+ return $smtpPassword;
248
+ }
249
+
250
+ /**
251
+ * functions used for get user name
252
+ */
253
+ public function getUserName()
254
+ {
255
+ $userName = $this->getSendinSmtpStatus('username', Mage::app()->getStore()->getStoreId());
256
+ if (!$userName) {
257
+ return false;
258
+ }
259
+ return $userName;
260
+ }
261
+
262
+ /**
263
+ * functions used for getting smtp status
264
+ */
265
+ public function getSmtpStatus()
266
+ {
267
+ $status = $this->getSendinSmtpStatus('status', Mage::app()->getStore()->getStoreId());
268
+ if (!$status) {
269
+ return false;
270
+ }
271
+ return $status;
272
+ }
273
+
274
+ /**
275
+ * functions used for getting tracking status
276
+ */
277
+ public function getTrackingStatus()
278
+ {
279
+ $status = $this->getSendinTrackingCodeStatus('code', Mage::app()->getStore()->getStoreId());
280
+ if (!$status) {
281
+ return false;
282
+ }
283
+ return $status;
284
+ }
285
+
286
+ /**
287
+ * functions used for getting tracking status
288
+ */
289
+ public function getTrackingHistoryStatus()
290
+ {
291
+ $status = $this->getSendinTrackingHistoryStatus('history', Mage::app()->getStore()->getStoreId());
292
+ if (!$status) {
293
+ return false;
294
+ }
295
+ return $status;
296
+ }
297
+
298
+ /**
299
+ * functions used for getting userlists
300
+ */
301
+ public function getUserlists()
302
+ {
303
+ $userlist = $this->getGeneralConfig('list', Mage::app()->getStore()->getStoreId());
304
+ if (!$userlist) {
305
+ return false;
306
+ }
307
+ return $userlist;
308
+ }
309
+
310
+ /**
311
+ * functions used for getting importOldSubscribers status
312
+ */
313
+ public function getImportOldSubsStatus()
314
+ {
315
+ $importStatus = $this->getGeneralConfig('importOldUserStatus', Mage::app()->getStore()->getStoreId());
316
+ if (!$importStatus) {
317
+ return false;
318
+ }
319
+ return $importStatus;
320
+ }
321
+
322
+ /**
323
+ * functions used for get templateid
324
+ */
325
+ public function getTemplateId()
326
+ {
327
+ $templateId = $this->getGeneralConfig('SendinTemplateId', Mage::app()->getStore()->getStoreId());
328
+ if (!$templateId) {
329
+ return false;
330
+ }
331
+ return $templateId;
332
+ }
333
+ /**
334
+ * functions used for get value final email recive.
335
+ */
336
+ public function getFinalTemplate()
337
+ {
338
+ $finalTemplate = $this->getGeneralConfig('SendinTemplateFinal', Mage::app()->getStore()->getStoreId());
339
+ if (!$finalTemplate) {
340
+ return false;
341
+ }
342
+ return $finalTemplate;
343
+ }
344
+ /**
345
+ * functions used for get value subscribe type like doubleoptin and simple.
346
+ */
347
+ public function getSubscribeConfirmType()
348
+ {
349
+ $subscribeConfirmType = $this->getGeneralConfig('SendinSubscribeConfirmType', Mage::app()->getStore()->getStoreId());
350
+ if (!$subscribeConfirmType) {
351
+ return false;
352
+ }
353
+ return $subscribeConfirmType;
354
+ }
355
+
356
+ /**
357
+ * functions used to get Double optin Template Id in case of doubleoptin type selected.
358
+ */
359
+ public function getDoubleoptinTemplateId()
360
+ {
361
+ $doubleoptinTemplateId = $this->getGeneralConfig('SendinDoubleoptinTemplateId', Mage::app()->getStore()->getStoreId());
362
+ if (!$doubleoptinTemplateId) {
363
+ return false;
364
+ }
365
+ return $doubleoptinTemplateId;
366
+ }
367
+
368
+ /**
369
+ * functions used for get value for redirect url
370
+ */
371
+ public function getOptinRedirectUrlCheck()
372
+ {
373
+ $optionRedirectUrlCheck = $this->getGeneralConfig('SendinOptinRedirectUrlCheck', Mage::app()->getStore()->getStoreId());
374
+ if (!$optionRedirectUrlCheck) {
375
+ return false;
376
+ }
377
+ return $optionRedirectUrlCheck;
378
+ }
379
+ /**
380
+ * functions used for get double optin redirect url after click email link.
381
+ */
382
+ public function getSendinDoubleoptinRedirectUrl()
383
+ {
384
+ $sendinDoubleoptinRedirectUrl = $this->getGeneralConfig('SendinDoubleoptinRedirectUrl', Mage::app()->getStore()->getStoreId());
385
+ if (!$sendinDoubleoptinRedirectUrl) {
386
+ return false;
387
+ }
388
+ return $sendinDoubleoptinRedirectUrl;
389
+ }
390
+ /**
391
+ * functions used for get final confirmation email for double optin functionality.
392
+ */
393
+ public function getSendinFinalConfirmEmail()
394
+ {
395
+ $sendinFinalConfirmEmail = $this->getGeneralConfig('SendinFinalConfirmEmail', Mage::app()->getStore()->getStoreId());
396
+ if (!$sendinFinalConfirmEmail) {
397
+ return false;
398
+ }
399
+ return $sendinFinalConfirmEmail;
400
+ }
401
+
402
+ /**
403
+ * functions used for get doubleoptin id geting by sendinblue.
404
+ */
405
+ public function getSendinOptinListId()
406
+ {
407
+ $sendinOptionListId = $this->getGeneralConfig('SendinOptinListId', Mage::app()->getStore()->getStoreId());
408
+ if (!$sendinOptionListId) {
409
+ return false;
410
+ }
411
+ return $sendinOptionListId;
412
+ }
413
+
414
+ /**
415
+ * functions used for getting general config
416
+ */
417
+ public function getGeneralConfig($field, $store = null)
418
+ {
419
+ return Mage::getStoreConfig('sendinblue/'.$field, $store);
420
+ }
421
+
422
+ /**
423
+ * functions used for get sendinsmtp status
424
+ */
425
+ public function getSendinSmtpStatus($field, $store = null)
426
+ {
427
+ return Mage::getStoreConfig('sendinblue/smtp/'.$field, $store);
428
+ }
429
+
430
+ /**
431
+ * functions used for get sendinblue email status
432
+ */
433
+ public function getSyncronizeStatus()
434
+ {
435
+ return $this->getGeneralConfig('syncronize', Mage::app()->getStore()->getStoreId());
436
+ }
437
+ /**
438
+ * functions used for get sendin tracking status
439
+ */
440
+ public function getSendinTrackingCodeStatus($field, $store = null)
441
+ {
442
+ return Mage::getStoreConfig('sendinblue/tracking/'.$field, $store);
443
+ }
444
+
445
+ /**
446
+ * functions used for get sendin tracking history status
447
+ */
448
+ public function getSendinTrackingHistoryStatus($field, $store = null)
449
+ {
450
+ return Mage::getStoreConfig('sendinblue/improt/'.$field, $store);
451
+ }
452
+
453
+ /**
454
+ * functions used for module functionality
455
+ */
456
+ public function getLists()
457
+ {
458
+ return $this->lists();
459
+ }
460
+
461
+ /**
462
+ * functions used for email adds
463
+ */
464
+ public function emailAdd($email, $extra, $isSubscribed = '', $listId = '')
465
+ {
466
+ $attributesName = $this->allAttributesName();
467
+ if ($this->moduleEnable == 1 && $this->getSyncronizeStatus())
468
+ {
469
+ $apikey = $this->apiKey;
470
+ if (!$apikey) {
471
+ return false;
472
+ }
473
+ $sendinConfirmType = Mage::getStoreConfig('sendinblue/SendinSubscribeConfirmType');
474
+ if (empty($listId)) {
475
+ if (isset($sendinConfirmType) && $sendinConfirmType === 'doubleoptin') {
476
+ $listId = Mage::getStoreConfig('sendinblue/SendinOptinListId');
477
+ }
478
+ else {
479
+ $listId = $this->listsIds;
480
+ }
481
+ }
482
+ $userData = array();
483
+ $userData['email'] = $email;
484
+ $userData['id'] = '';
485
+ if ($isSubscribed != '') {
486
+ $userData['blacklisted'] = 0;
487
+ }
488
+ if ($extra != null) {
489
+ $keyValue = array_keys($attributesName);
490
+ $attributesName = is_array($keyValue) ? $keyValue : array($keyValue);
491
+ $attributesValue = is_array($extra) ? $extra : array($extra);
492
+ $userData['attributes'] = array_combine($attributesName, $attributesValue);
493
+ }
494
+ else {
495
+ $userData['attributes_value'] = $email;
496
+ }
497
+ $userData['listid'] = (is_array($listId)) ? $listId : array($listId);
498
+ $params['api_key'] = $this->apiKey;
499
+ $psmailinObj = Mage::getModel('sendinblue/psmailin', $params);
500
+ return $psmailinObj->createUpdateUser($userData);
501
+ }
502
+ else {
503
+ return false;
504
+ }
505
+ }
506
+
507
+ /**
508
+ * functions subscribeuser
509
+ */
510
+ public function emailSubscribe($email)
511
+ {
512
+ if ($this->moduleEnable == 1 && $this->getSyncronizeStatus()) {
513
+ $apikey = $this->apiKey;
514
+ $timezone = Mage::app()->getStore()->getConfig('general/locale/timezone');
515
+ $userTimeZone = str_replace('Calcutta', 'Kolkata', $timezone);
516
+ $dateValue = date("Y-m-d H:i:s", Mage::getModel('core/date')->timestamp(time()));
517
+
518
+ if (!$apikey) {
519
+ return false;
520
+ }
521
+ $userData = array();
522
+ $userData['timezone'] = $userTimeZone;
523
+ $userData['user_status'] = $email.', '.'1'.', '.$dateValue;
524
+ $params['api_key'] = $this->apiKey;
525
+ $psmailinObj = Mage::getModel('sendinblue/psmailin', $params);
526
+ return $psmailinObj->updateUserSubscriptionStatus($userData);
527
+ }
528
+ else {
529
+ return false;
530
+ }
531
+ }
532
+
533
+ /**
534
+ * functions used for sync data
535
+ */
536
+ public function syncData()
537
+ {
538
+ if ($this->moduleEnable == 1 && $this->getSyncronizeStatus()) {
539
+ $apikey = $this->apiKey;
540
+ if (!$apikey) {
541
+ return false;
542
+ }
543
+ $listIds = array();
544
+ $listIds['listids'] = str_replace(',', '|', $this->listsIds);
545
+
546
+ $params['api_key'] = $this->apiKey;
547
+ $psmailinObj = Mage::getModel('sendinblue/psmailin', $params);
548
+ $blockUsersLists = $psmailinObj->getListUsersBlacklistStatus($listIds);
549
+
550
+ $blockUsers = $blockUsersLists['data'];
551
+ $collection = Mage::getResourceModel('newsletter/subscriber_collection')->showStoreInfo()->showCustomerInfo()->toArray();
552
+ $subScriberData = $collection['items'];
553
+ $emails = array();
554
+ $subScriberDataEmail = array();
555
+ foreach($subScriberData as $s) {
556
+ $subScriberDataEmail[$s['subscriber_email']] = $s;
557
+ }
558
+
559
+ if (count($blockUsers) > 0) {
560
+ $newsLetterSubscriber = Mage::getModel('newsletter/subscriber');
561
+ foreach ($blockUsers as $key => $value) {
562
+ foreach ($value as $userData) {
563
+ if(isset($subScriberDataEmail[$userData['email']])) {
564
+ // on a trouvé le subscriber magento
565
+ $data = $subScriberDataEmail[$userData['email']];
566
+ $tempSubStatus = ($data['subscriber_status'] == 3) ? 1 : 0;
567
+ if ($tempSubStatus != $userData['blacklisted']) {
568
+ $emails[] = $data['subscriber_email'];
569
+ $subscribeData['subscriber_id'] = $data['subscriber_id'];
570
+ $subscribeData['subscriber_status'] = ($userData['blacklisted'] == 1) ? 3 : 1;
571
+ $costomerData = $newsLetterSubscriber->loadByEmail($data['subscriber_email']);
572
+ $costomerData->setStatus($subscribeData['subscriber_status']);
573
+ $costomerData->setIsStatusChanged(true);
574
+ $costomerData->save();
575
+ }
576
+ }
577
+ }
578
+ }
579
+ }
580
+
581
+ if (count($emails) > 0) {
582
+ Mage::getModel('core/session')->addSuccess(count($emails).Mage::helper('sendinblue')->__(' Total of record(s) have been updated'));
583
+ }
584
+ else {
585
+ Mage::getModel('core/session')->addSuccess(count($emails).Mage::helper('sendinblue')->__(' Total of record(s) have been updated'));
586
+ }
587
+ return true;
588
+ }
589
+ else {
590
+ return false;
591
+ }
592
+ }
593
+
594
+ /**
595
+ * This method is used for add email list
596
+ */
597
+ public function addEmailList($email, $listId = '')
598
+ {
599
+ if ($this->moduleEnable == 1 && $this->getSyncronizeStatus()) {
600
+ $apikey = $this->apiKey;
601
+ if (!$apikey) {
602
+ return false;
603
+ }
604
+ $sendinConfirmType = Mage::getStoreConfig('sendinblue/SendinSubscribeConfirmType');
605
+ if (empty($listId)) {
606
+ if (isset($sendinConfirmType) && $sendinConfirmType === 'doubleoptin') {
607
+ $listId = Mage::getStoreConfig('sendinblue/SendinOptinListId');
608
+ }
609
+ else {
610
+ $listId = $this->listsIds;
611
+ }
612
+ }
613
+ $userData = array();
614
+ $userData['email'] = $email;
615
+ $userData['id'] = '';
616
+ $userData['blacklisted'] = 0;
617
+ $userData['attributes'] = array();
618
+ $userData['listid'] = (is_array($listId)) ? $listId : array($listId);
619
+ $params['api_key'] = $this->apiKey;
620
+ $psmailinObj = Mage::getModel('sendinblue/psmailin', $params);
621
+ return $psmailinObj->createUpdateUser($userData);
622
+ }
623
+ else {
624
+ return false;
625
+ }
626
+ }
627
+
628
+ /**
629
+ * This method is used used for email unsubscribe
630
+ */
631
+ public function emailDelete($email)
632
+ {
633
+ if ($this->moduleEnable == 1 && $this->getSyncronizeStatus()) {
634
+ $apikey = $this->apiKey;
635
+ if (!$apikey) {
636
+ return false;
637
+ }
638
+ $userData = array();
639
+ $userData['email'] = $email;
640
+ $userData['listid'] = $this->listsIds;
641
+ $params['api_key'] = $this->apiKey;
642
+ $psmailinObj = Mage::getModel('sendinblue/psmailin', $params);
643
+ return $psmailinObj->unSubscribApi($userData);
644
+ }
645
+ else {
646
+ return false;
647
+ }
648
+ }
649
+
650
+ /**
651
+ * This method is used used for check api status
652
+ */
653
+ public function checkApikey($userApiKey)
654
+ {
655
+ $params['api_key'] = (!empty($userApiKey)) ? $userApiKey : $this->apiKey;
656
+ $psmailinObj = Mage::getModel('sendinblue/psmailin',$params);
657
+ $keyResponse = $psmailinObj->getAccount();
658
+
659
+ if (isset($keyResponse['code']) && $keyResponse['code'] == 'failure' && isset($keyResponse['message']) && $keyResponse['message'] == 'Key Not Found In Database') {
660
+ $lists['error'] = $keyResponse['message'];
661
+ return $lists;
662
+ }
663
+ }
664
+
665
+ /**
666
+ * Fetches all the list of the user from the Sendinblue platform.
667
+ */
668
+ public function lists($filters = array())
669
+ {
670
+ $params = array();
671
+ $params['api_key'] = $this->apiKey;
672
+ $psmailinObj = Mage::getModel('sendinblue/psmailin', $params);
673
+ $response = $psmailinObj->displayListForPlugin();
674
+
675
+ if (isset($response['code']) && $response['code'] == 'failure'){
676
+ $this->errorMessage = $response['message'];
677
+ $lists['error'] = $response['message'];
678
+ }
679
+ else {
680
+ $i = 0;
681
+ $lists = array();
682
+ foreach ($response['data'] as $listData) {
683
+ $lists[$i]['id'] = $listData['id'];
684
+ $lists[$i]['name'] = $listData['name'];
685
+ $i++;
686
+ }
687
+ }
688
+ return $lists;
689
+ }
690
+
691
+ /**
692
+ * Fetches the list status of the user from the Sendinblue platform.
693
+ */
694
+ public function getUserListStats()
695
+ {
696
+ if ($this->moduleEnable == 1) {
697
+ $params['api_key'] = $this->apiKey;
698
+ $psmailinObj = Mage::getModel('sendinblue/psmailin', $params);
699
+ return $psmailinObj->displayListForPlugin();
700
+ }
701
+ else {
702
+ return Mage::getModel('core/session')->addError('Sendinblue not enabled');
703
+ }
704
+ }
705
+
706
+ /**
707
+ * Fetches all folders and all list within each folder of the user's Sendinblue
708
+ * account and displays them to the user.
709
+ */
710
+ public function checkFolderListDoubleoptin()
711
+ {
712
+ $returnData = array();
713
+ $params['api_key'] = $this->apiKey;
714
+ $psmailinObj = Mage::getModel('sendinblue/psmailin', $params);
715
+ $foldersListResponse = $psmailinObj->displayFoldersLists();
716
+ if (!empty($foldersListResponse['data'])) {
717
+ foreach ($foldersListResponse['data'] as $value) {
718
+ if (strtolower($value['name']) == 'form') {
719
+ if (!empty($value['lists'])) {
720
+ foreach ($value['lists'] as $key => $val) {
721
+ if ($val['name'] == 'Temp - DOUBLE OPTIN') {
722
+ $returnData['optin_id'] = $key;
723
+ }
724
+ }
725
+ }
726
+ }
727
+ }
728
+ if (count($returnData) > 0) {
729
+ $return = $returnData;
730
+ }
731
+ else {
732
+ $return = false;
733
+ }
734
+ }
735
+ return $return;
736
+ }
737
+
738
+ /**
739
+ * Create temporary doubleoptin list if not exist in Sendinblue.
740
+ */
741
+ public function createListIdDoubleoptin()
742
+ {
743
+ $folderInfomation = array();
744
+ $folderId = ''; $listId = '';
745
+ $folderInfomation['name'] = 'FORM';
746
+ $params['api_key'] = $this->apiKey;
747
+ $psmailinObj = Mage::getModel('sendinblue/psmailin', $params);
748
+ $returnFolderId = $psmailinObj->createFolder($folderInfomation);
749
+
750
+ if(isset($returnFolderId['data']['id'])) {
751
+ $folderId = $returnFolderId['data']['id'];
752
+ }
753
+ if (!empty($folderId)) {
754
+ $listInformation = array();
755
+ $listInformation['list_name'] = 'Temp - DOUBLE OPTIN';
756
+ $listInformation['list_parent'] = $folderId;
757
+ $listIdResponse = $psmailinObj->createList($listInformation);
758
+ $listId = $listIdResponse['data']['id'];
759
+ }
760
+ return $listId;
761
+ }
762
+
763
+ /**
764
+ * Fetches all folders and all list within each folder of the user's Sendinblue
765
+ * account and displays them to the user.
766
+ */
767
+ public function checkFolderList()
768
+ {
769
+ $params = array();
770
+ $array = array();
771
+ $params['api_key'] = $this->apiKey;
772
+ $psmailinObj = Mage::getModel('sendinblue/psmailin', $params);
773
+ $foldersListResponse = $psmailinObj->displayFoldersLists();
774
+
775
+ if (!empty($foldersListResponse['data'])) {
776
+ foreach ($foldersListResponse['data'] as $key => $value) {
777
+ if (strtolower($value['name']) == 'magento') {
778
+ $array[] = $key;
779
+ $array[] = $value['name'];
780
+ }
781
+ if (!empty($value['lists'])) {
782
+ foreach ($value['lists'] as $val) {
783
+ if (strtolower($val['name']) == 'magento') {
784
+ $array[] = $val['name'];
785
+ }
786
+ }
787
+ }
788
+ }
789
+ }
790
+ return $array;
791
+ }
792
+
793
+ /**
794
+ * folder create in Sendinblue after removing from Sendinblue
795
+ */
796
+ public function createFolderCaseTwo()
797
+ {
798
+ $apiKey = $this->apiKey;
799
+ if($apiKey == '') {
800
+ return false;
801
+ }
802
+ $apiKeyResponse = $this->checkApikey($apiKey); // check api key is valid or not
803
+ if($this->moduleEnable != 1 && $apiKey == '' && $apiKeyResponse['error'] != '' && $this->getSyncronizeStatus()) {
804
+ return false;
805
+ }
806
+ $result = $this->checkFolderList();
807
+ $listName = 'magento';
808
+ $data = array();
809
+ $params['api_key'] = $this->apiKey;
810
+ $psmailinObj = Mage::getModel('sendinblue/psmailin', $params);
811
+ $folderId = $result[0];
812
+ $existList = $result[2];
813
+ if (empty($result[1])) {
814
+ $createListParameters = array();
815
+ $createListParameters['name'] = 'magento';
816
+ $folderResponse = $psmailinObj->createFolder($data);
817
+ if(isset($folderResponse['data']['id'])) {
818
+ $folderId = $folderResponse['data']['id'];
819
+ }
820
+ $createListParameters = array();
821
+ $createListParameters['list_name'] = $listName;
822
+ $createListParameters['list_parent'] = $folderId; //folder id
823
+ $listResponse = $psmailinObj->createList($createListParameters);
824
+ $this->sendAllMailIDToSendin($listResponse['data']['id']);
825
+ }
826
+ elseif (empty($existList)) {
827
+ $createListParameters = array();
828
+ $createListParameters['list_name'] = $listName;
829
+ $createListParameters['list_parent'] = $folderId; //folder id
830
+ $listResponse = $psmailinObj->createList($createListParameters);
831
+ $this->sendAllMailIDToSendin($listResponse['data']['id']);
832
+ }
833
+ }
834
+
835
+ /**
836
+ * folder create in Sendinblue after installing
837
+ */
838
+ public function createFolderName($apiKey)
839
+ {
840
+ $this->apiKey = $apiKey;
841
+ $this->createAttributesName();
842
+ $folderInformation = $this->checkFolderList();
843
+ $folderId = '';
844
+ if (empty($folderInformation[1])) {
845
+ $folderData = array();
846
+ $params['api_key'] = $this->apiKey;
847
+ $psmailinObj = Mage::getModel('sendinblue/psmailin', $params);
848
+ $folderData['name'] = 'magento';
849
+ $responseFolderId = $psmailinObj->createFolder($folderData);
850
+ if(isset($responseFolderId['data']['id'])) {
851
+ $folderId = $responseFolderId['data']['id'];
852
+ }
853
+ $existList = '';
854
+ }
855
+ else {
856
+ $folderId = $folderInformation[0];
857
+ $existList = $folderInformation[2];
858
+ }
859
+ $this->createNewList($folderId, $existList);
860
+ $this->partnerMagento();
861
+ }
862
+
863
+ /**
864
+ * Method is used to add the partner's name in Sendinblue.
865
+ * In this case its "MAGENTO".
866
+ */
867
+ public function partnerMagento()
868
+ {
869
+ $mailinPartnerParameters = array();
870
+ $params['api_key'] = $this->apiKey;
871
+ $psmailinObj = Mage::getModel('sendinblue/psmailin', $params);
872
+ $mailinPartnerParameters['partner'] = 'MAGENTO';
873
+ $psmailinObj->updateMailinParter($mailinPartnerParameters);
874
+ }
875
+
876
+ /**
877
+ * Creates a list by the name "magento" on user's Sendinblue account.
878
+ */
879
+ public function createNewList($response, $existList)
880
+ {
881
+ $params['api_key'] = $this->apiKey;
882
+ $psmailinObj = Mage::getModel('sendinblue/psmailin', $params);
883
+ if ($existList != '') {
884
+ $date = date('dmY');
885
+ $listName = 'magento_'.$date;
886
+ }
887
+ else {
888
+ $listName = 'magento';
889
+ }
890
+ $listData = array();
891
+ $listData['list_name'] = $listName;
892
+ $listData['list_parent'] = $response;
893
+ $listResponse = $psmailinObj->createList($listData);
894
+ $this->sendAllMailIDToSendin($listResponse['data']['id']);
895
+ $this->createAttributesName();
896
+ }
897
+
898
+ /**
899
+ * Fetch attributes and their values
900
+ * on Sendinblue platform. This is necessary for the Prestashop to add subscriber's details.
901
+ */
902
+ public function allAttributesName()
903
+ {
904
+ if ($this->userLanguage == 'fr') {
905
+ $attributesName = 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');
906
+ }
907
+ else {
908
+ $attributesName = 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');
909
+ }
910
+ return $attributesName;
911
+ }
912
+
913
+ /**
914
+ * Fetch attributes name and type
915
+ * on Sendinblue platform. This is necessary for the Prestashop to add subscriber's details.
916
+ */
917
+ public function allAttributesType()
918
+ {
919
+ if ($this->userLanguage == 'fr') {
920
+ $attributesType = 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');
921
+ }
922
+ else {
923
+ $attributesType = 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');
924
+ }
925
+ return $attributesType;
926
+ }
927
+
928
+ /**
929
+ * Fetch all Transactional Attributes
930
+ * on Sendinblue platform. This is necessary for the Prestashop to add subscriber's details.
931
+ */
932
+ public function allTransactionalAttributes()
933
+ {
934
+ $transactionalAttributes = array('ORDER_ID'=>'id', 'ORDER_DATE'=>'date', 'ORDER_PRICE'=>'number');
935
+ return $transactionalAttributes;
936
+ }
937
+
938
+ /**
939
+ * Create Normal, Transactional, Calculated and Global attributes and their values
940
+ * on Sendinblue platform. This is necessary for the Prestashop to add subscriber's details.
941
+ */
942
+ public function createAttributesName()
943
+ {
944
+ $normalAttributesData = array();
945
+ $transactionalAttributesData = array();
946
+ $params['api_key'] = $this->apiKey;
947
+ $psmailinObj = Mage::getModel('sendinblue/psmailin', $params);
948
+ $noramalAttributes = $this->allAttributesType();
949
+ $transactionalAttributes = $this->allTransactionalAttributes();
950
+
951
+ $normalAttributesData = array(
952
+ "type" => "normal",
953
+ "data" => $noramalAttributes
954
+ );
955
+ $psmailinObj->createAttribute($normalAttributesData);
956
+
957
+ $transactionalAttributesData = array(
958
+ "type" => "transactional",
959
+ "data" => $transactionalAttributes
960
+ );
961
+ $psmailinObj->createAttribute($transactionalAttributesData);
962
+ }
963
+
964
+ /**
965
+ * Method is used to send all the subscribers from magento to
966
+ * Sendinblue for adding / updating purpose.
967
+ */
968
+ public function sendAllMailIDToSendin($list)
969
+ {
970
+ $sendinSwitch = Mage::getModel('core/config');
971
+ $allEmail = $this->getcustomers();
972
+ if ($allEmail > 0) {
973
+ $userDataInformation = array();
974
+ $params['api_key'] = $this->apiKey;
975
+ $psmailinObj = Mage::getModel('sendinblue/psmailin', $params);
976
+ $userDataInformation['key'] = $this->apiKey;
977
+ $userDataInformation['url'] = Mage::getBaseUrl('media').'sendinblue_csv/ImportSubUsersToSendinblue.csv';
978
+ $userDataInformation['listids'] = array($list); // $list;
979
+ $userDataInformation['notify_url'] = Mage::getBaseUrl().'sendinblue/ajax/emptySubsUserToSendinblue';
980
+ $responseValue = $psmailinObj->importUsers($userDataInformation);
981
+ $sendinSwitch->saveConfig('sendinblue/importOldUserStatus', 0, 'default', 0);
982
+ if (empty($responseValue['data']['process_id'])) {
983
+ $sendinSwitch->saveConfig('sendinblue/importOldUserStatus', 1);
984
+ }
985
+ }
986
+ $sendinSwitch->saveConfig('sendinblue/list', $list, 'default', 0);
987
+ }
988
+
989
+ /**
990
+ * Send SMS from Sendin.
991
+ */
992
+ public function sendSmsApi($array)
993
+ {
994
+ $smsSendData = array();
995
+ $smsSendData['to'] = $array['to'];
996
+ $smsSendData['from'] = $array['from'];
997
+ $smsSendData['text'] = $array['text'];
998
+ $params['api_key'] = $this->apiKey;
999
+ $psmailinObj = Mage::getModel('sendinblue/psmailin', $params);
1000
+ $sendSmsStatus = $psmailinObj->sendSms($smsSendData);
1001
+ return $sendSmsStatus['data'];
1002
+ }
1003
+
1004
+ public function sendOrder($mobile)
1005
+ {
1006
+ if (isset($mobile)) {
1007
+ $sendOrderData = array();
1008
+ $sendOrderData['to'] = $mobile;
1009
+ $sendOrderData['from'] = $this->getSendSmsOrderSubject();
1010
+ $sendOrderData['text'] = $this->getSendSmsmOrderMessage();
1011
+ return $this->sendSmsApi($sendOrderData);
1012
+ }
1013
+ }
1014
+
1015
+ public function notifySmsEmail()
1016
+ {
1017
+ $sendinSwitch = Mage::getModel('core/config');
1018
+ if($this->getSmsCredit() < $this->getNotifyValueStatus() && $this->moduleEnable == 1 && $this->getNotifySmsStatus() == 1) {
1019
+ if($this->getNotifyCronStatus() == 0) {
1020
+ $sendinSwitch->saveConfig('sendinblue/Sendin_Notify_Cron_Executed', 1, 'default', 0);
1021
+ $localeCode = Mage::app()->getLocale()->getLocaleCode();
1022
+ $emailTemplateVariables = array();
1023
+
1024
+ $emailTemplateVariables['text0'] = '[SendinBlue] Alert: You do not have enough credits SMS';
1025
+ $senderName = 'SendinBlue';
1026
+ $senderEmail = 'contact@sendinblue.com';
1027
+
1028
+ if ($localeCode == 'fr_FR') {
1029
+ $emailTemplateVariables['text0'] = ' [SendinBlue] Alerte: Vos crédits SMS seront bientôt épuisés';
1030
+ $senderName = 'SendinBlue';
1031
+ $senderEmail = 'contact@sendinblue.com';
1032
+ }
1033
+
1034
+ $email = $this->getNotifyEmailStatus();
1035
+ $emailTemplate = Mage::getModel('core/email_template')->loadDefault('notification_template');
1036
+ $templateText = $emailTemplate->template_text;
1037
+ $webSite = Mage::app()->getWebsite()->getName();
1038
+ $credit = $this->getSmsCredit();
1039
+ preg_match_all('#{(.*)}#', $templateText, $match);
1040
+
1041
+ $tempParams = array(
1042
+ '{site_name}'=>$webSite,
1043
+ '{present_credit}'=>$credit
1044
+ );
1045
+ foreach($match[0] as $var=>$value){
1046
+ $templateText = preg_replace('#'.$value.'#',$tempParams[$value],$templateText);
1047
+ }
1048
+ $emailTemplate->template_text = $templateText;
1049
+ $emailTemplate->getProcessedTemplate($emailTemplateVariables);
1050
+ $emailTemplate->setSenderName($senderName);
1051
+ $emailTemplate->setSenderEmail($senderEmail);
1052
+ $emailTemplate->setTemplateSubject($emailTemplateVariables['text0']);
1053
+ $emailTemplate->send($email, '', $emailTemplateVariables);
1054
+ }
1055
+ }
1056
+ else {
1057
+ $sendinSwitch->saveConfig('sendinblue/Sendin_Notify_Cron_Executed', 0, 'default', 0);
1058
+ }
1059
+ Mage::getModel('core/session')->addSuccess(Mage::helper('sendinblue')->__('Notification mail has been sent'));
1060
+ }
1061
+
1062
+ /**
1063
+ * show SMS credit from Sendinblue.
1064
+ */
1065
+ public function getSmsCredit()
1066
+ {
1067
+ $params['api_key'] = $this->apiKey;
1068
+ $psmailinObj = Mage::getModel('sendinblue/psmailin', $params);
1069
+ $userCurrentPlanInfo = $psmailinObj->getAccount();
1070
+ if(isset($userCurrentPlanInfo['data'])) {
1071
+ foreach($userCurrentPlanInfo['data'] as $planData) {
1072
+ if(isset($planData['plan_type']) && $planData['plan_type'] == 'SMS') {
1073
+ return $planData['credits'];
1074
+ }
1075
+ }
1076
+ }
1077
+ }
1078
+
1079
+ /**
1080
+ * Method is used to send test email to the user.
1081
+ */
1082
+ public function sendTestMail($email)
1083
+ {
1084
+ $localeCode = Mage::app()->getLocale()->getLocaleCode();
1085
+ $emailTemplateVariables = array();
1086
+
1087
+ $emailTemplateVariables['text0'] = '[SendinBlue SMTP] test email';
1088
+ $senderName = 'SendinBlue';
1089
+ $senderEmail = 'contact@sendinblue.com';
1090
+
1091
+ if ($localeCode == 'fr_FR') {
1092
+ $emailTemplateVariables['text0'] = '[SendinBlue SMTP] e-mail de test';
1093
+ $senderName = 'SendinBlue';
1094
+ $senderEmail = 'contact@sendinblue.com';
1095
+ }
1096
+
1097
+ try {
1098
+ $emailTemplate = Mage::getModel('core/email_template')->loadDefault('custom_template');
1099
+ $emailTemplate->getProcessedTemplate($emailTemplateVariables);
1100
+ $emailTemplate->setSenderName($senderName);
1101
+ $emailTemplate->setSenderEmail($senderEmail);
1102
+ $emailTemplate->setTemplateSubject($emailTemplateVariables['text0']);
1103
+ return $emailTemplate->send($email, '', $emailTemplateVariables);
1104
+ }
1105
+ catch(Exception $e) {
1106
+
1107
+ }
1108
+ }
1109
+
1110
+ /**
1111
+ * This method is used to compare key and value
1112
+ * return all value in array whose present in array key
1113
+ */
1114
+ public function mergeMyArray($one, $two, $email = "")
1115
+ {
1116
+ $emailData = $email ? array('EMAIL'=> $email) : array();
1117
+ if (count($one) > 0) {
1118
+ foreach($one as $k => $v) {
1119
+ $emailData[$k] = isset($two[$v])?str_replace(';',',', $two[$v]):'';
1120
+ }
1121
+ }
1122
+ return $emailData;
1123
+ }
1124
+
1125
+ /**
1126
+ * This method is used to fetch all users from the default customer table to list
1127
+ * them in the Sendinblue magento module.
1128
+ */
1129
+ public function getcustomers()
1130
+ {
1131
+ $data = array();
1132
+ $customerAddressData = array();
1133
+ $attributesName = $this->allAttributesName();
1134
+ $collection = Mage::getModel('customer/customer')->getCollection()->addAttributeToSelect('email')->addAttributeToSelect('firstname')->addAttributeToSelect('lastname')->addAttributeToSelect('created_in');
1135
+ $customerAddressCollection = Mage::getModel('customer/address');
1136
+ foreach ($collection as $customer) {
1137
+ $responseByMerge = array();
1138
+ $customerData = array();
1139
+ $customerData = $customer->getData();
1140
+ $email = $customerData['email'];
1141
+ $customerId = $customerData['entity_id'];
1142
+
1143
+ $collectionAddress = $customerAddressCollection->getCollection()->addAttributeToSelect('telephone')->addAttributeToSelect('country_id')->addAttributeToSelect('company')->addAttributeToSelect('street')->addAttributeToSelect('postcode')->addAttributeToSelect('region')->addAttributeToSelect('city')->addAttributeToFilter('parent_id',(int)$customerId);
1144
+ $telephone = '';
1145
+ $customerAddress = array();
1146
+ foreach ($collectionAddress as $customerPhno) {
1147
+ $customerAddress = $customerPhno->getData();
1148
+ $customerAddress['client'] = $customerId>0?1:0;
1149
+ }
1150
+ $customerAddressData[$email] = array_merge($customerData, $customerAddress);
1151
+ }
1152
+ $newsLetterData = array();
1153
+ $newsletter = Mage::getResourceModel('newsletter/subscriber_collection')->addFieldToFilter('subscriber_status', array('eq' => 1))->load();
1154
+ $count = 0;
1155
+ foreach ( $newsletter->getItems() as $subscriber) {
1156
+ $subsdata = $subscriber->getData();
1157
+ $subscriberEmail = $subsdata['subscriber_email'];
1158
+
1159
+ if ( !empty($customerAddressData[$subscriberEmail]) ) {
1160
+ $customerAddressData[$subscriberEmail]['email'] = $subscriberEmail;
1161
+ $responseByMerge[$count] = $this->mergeMyArray($attributesName, $customerAddressData[$subscriberEmail], $subscriberEmail);
1162
+ }
1163
+ else {
1164
+ $newsLetterData['client'] = $subsdata['customer_id']>0?1:0;
1165
+ $responseByMerge[$count] = $this->mergeMyArray($attributesName, $newsLetterData, $subscriberEmail);
1166
+ $responseByMerge[$count]['STORE_ID'] = $subsdata['store_id'];
1167
+ }
1168
+ $count++;
1169
+ }
1170
+
1171
+ if (!is_dir(Mage::getBaseDir('media').'/sendinblue_csv')) {
1172
+ mkdir(Mage::getBaseDir('media').'/sendinblue_csv', 0777, true);
1173
+ }
1174
+
1175
+ $handle = fopen(Mage::getBaseDir('media').'/sendinblue_csv/ImportSubUsersToSendinblue.csv', 'w+');
1176
+ $keyValue = array_keys($attributesName);
1177
+ array_splice($keyValue, 0, 0, 'EMAIL');
1178
+
1179
+ fwrite($handle, implode(';', $keyValue)."\n");
1180
+ foreach ($responseByMerge as $newsdata) {
1181
+ if(!empty($newsdata['COUNTRY_ID']) && !empty($newsdata['SMS'])) {
1182
+ $countryId = $this->getCountryCode($newsdata['COUNTRY_ID']);
1183
+ $newsdata['SMS'] = $this->checkMobileNumber($newsdata['SMS'], $countryId);
1184
+ }
1185
+ $keyValue = $newsdata;
1186
+ fwrite($handle, str_replace("\n", "",implode(';', $keyValue))."\n");
1187
+ }
1188
+ fclose($handle);
1189
+ $totalValue = count($responseByMerge);
1190
+ return $totalValue;
1191
+ }
1192
+
1193
+ /**
1194
+ * This method is used to fetch all users from the default newsletter table to list
1195
+ * them in the Sendinblue magento module.
1196
+ */
1197
+ public function getNewsletterSubscribe($start, $perPage)
1198
+ {
1199
+ $customerAddressData = array();
1200
+ $attributesName = $this->allAttributesName();
1201
+ $attributesName['email'] = 'email';
1202
+ $attributesName['customer_id'] = 'entity_id';
1203
+
1204
+ $collection = Mage::getModel('customer/customer')->getCollection()->addAttributeToSelect('email');
1205
+ $customerAddressCollection = Mage::getModel('customer/address');
1206
+ foreach ($collection as $customer) {
1207
+ $customerData = array();
1208
+ $customerData = $customer->getData();
1209
+ $email = $customerData['email'];
1210
+ $customerId = $customerData['entity_id'];
1211
+ $collectionAddress = $customerAddressCollection->getCollection()->addAttributeToSelect('telephone')->addAttributeToSelect('country_id')->addAttributeToFilter('parent_id',(int)$customerId);
1212
+ $telephone = '';
1213
+ $customerAddress = array();
1214
+ foreach ($collectionAddress as $customerPhno) {
1215
+ $customerAddress = $customerPhno->getData();
1216
+ if (!empty($customerAddress['telephone']) && !empty($customerAddress['country_id'])) {
1217
+ $countryCode = $this->getCountryCode($customerAddress['country_id']);
1218
+ $customerAddress['telephone'] = $this->checkMobileNumber($customerAddress['telephone'], $countryCode);
1219
+ }
1220
+ $customerAddress['client'] = $customerId>0?1:0;
1221
+ }
1222
+ $customerAddressData[$email] = array_merge($customerData, $customerAddress);
1223
+ }
1224
+
1225
+ $newsLetterData = array();
1226
+ $newsletter = Mage::getResourceModel('newsletter/subscriber_collection')->load();
1227
+ $count = 0;
1228
+ $responseData = array();
1229
+ foreach ( $newsletter->getItems() as $subscriber) {
1230
+ $subsdata = $subscriber->getData();
1231
+ $subscriberEmail = $subsdata['subscriber_email'];
1232
+ $subscriberStatus = $subsdata['subscriber_status'];
1233
+ if ( !empty($customerAddressData[$subscriberEmail]) ) {
1234
+ $responseData[$count] = $this->mergeMyArray($attributesName, $customerAddressData[$subscriberEmail]);
1235
+ unset($customerAddressData[$subscriberEmail]);
1236
+ $responseData[$count]['subscriber_status'] = $subscriberStatus;
1237
+ $responseData[$count]['email'] = $subscriberEmail;
1238
+ }
1239
+ else {
1240
+ $newsLetterData['client'] = $subsdata['customer_id']> 0 ? 1 : 0;
1241
+ $responseData[$count] = $this->mergeMyArray($attributesName, $newsLetterData);
1242
+ $responseData[$count]['subscriber_status'] = $subscriberStatus;
1243
+ $responseData[$count]['email'] = $subscriberEmail;
1244
+ }
1245
+ $count++;
1246
+ }
1247
+
1248
+ if (count($customerAddressData) > 0) {
1249
+ foreach ($customerAddressData as $email => $cVal) {
1250
+ $responseData[$count] = $this->mergeMyArray($attributesName, $cVal);
1251
+ $responseData[$count]['subscriber_status'] = 3;
1252
+ $responseData[$count]['email'] = $email;
1253
+ $count++;
1254
+ }
1255
+ }
1256
+ return array_slice($responseData, $start, $perPage, true);
1257
+ }
1258
+
1259
+ /**
1260
+ * This method is used to fetch total count unsubscribe users from the default newsletter table to list
1261
+ * them in the Sendinblue magento module.
1262
+ */
1263
+ public function getNewsletterUnSubscribeCount()
1264
+ {
1265
+ $coreResource = Mage::getSingleton('core/resource');
1266
+ $tableCustomer = $coreResource->getTableName('customer/entity');
1267
+ $tableNewsletter = $coreResource->getTableName('newsletter/subscriber');
1268
+
1269
+ $readDbObject = Mage::getSingleton("core/resource")->getConnection("core_read");
1270
+ $queryUnSubscribCounter1 = $readDbObject->select()
1271
+ ->from(
1272
+ array('CE' => $tableCustomer),
1273
+ array(''))
1274
+ ->join(array('NS' => $tableNewsletter),
1275
+ 'CE.entity_id=NS.customer_id',
1276
+ array('totalcoutn' => 'COUNT(*)'))
1277
+ ->where("subscriber_status != 1 or subscriber_status is null");
1278
+ $stmtUnSubscribCounter1 = $readDbObject->query($queryUnSubscribCounter1);
1279
+ $unSubscribCounter1 = $stmtUnSubscribCounter1->fetch();
1280
+
1281
+ $queryUnSubscribCounter2 = $readDbObject->select()
1282
+ ->from($tableNewsletter,array('totalcoutn' => 'COUNT(*)'))
1283
+ ->where("customer_id = 0 AND subscriber_status = 3");
1284
+ $stmtUnSubscribCounter2 = $readDbObject->query($queryUnSubscribCounter2);
1285
+ $unSubscribCounter2 = $stmtUnSubscribCounter2->fetch();
1286
+
1287
+ return ($unSubscribCounter1['totalcoutn'] + $unSubscribCounter2['totalcoutn']);
1288
+ }
1289
+
1290
+ /**
1291
+ * This method is used to fetch total count subscribe users from the default newsletter table to list
1292
+ * them in the Sendinblue magento module.
1293
+ */
1294
+ public function getNewsletterSubscribeCount()
1295
+ {
1296
+ $coreResource = Mage::getSingleton('core/resource');
1297
+ $tableNewsletter = $coreResource->getTableName('newsletter/subscriber');
1298
+ $readDbObject = Mage::getSingleton("core/resource")->getConnection("core_read");
1299
+ $queryUnSubscribCounter = $readDbObject->select()
1300
+ ->from($tableNewsletter,array('totalvalue' => 'COUNT(*)'))
1301
+ ->where("subscriber_status = 1");
1302
+ $stmtUnSubscribCounter = $readDbObject->query($queryUnSubscribCounter);
1303
+ $unSubscribCounter = $stmtUnSubscribCounter->fetch();
1304
+ return $unSubscribCounter['totalvalue'];
1305
+ }
1306
+
1307
+ /**
1308
+ * This method is used to check the subscriber's newsletter subscription status in Sendinblue
1309
+ */
1310
+ public function checkUserSendinStatus($result)
1311
+ {
1312
+ $userStatus = array();
1313
+ foreach ($result as $subscriber) {
1314
+ $userStatus[] = $subscriber['email'];
1315
+ }
1316
+ $allUsers = array('users' => $userStatus );
1317
+ $params['api_key'] = $this->apiKey;
1318
+ $psmailinObj = Mage::getModel('sendinblue/psmailin', $params);
1319
+ $usersBlackListData = $psmailinObj->getUsersBlacklistStatus($allUsers);
1320
+ return $usersBlackListData;
1321
+
1322
+ }
1323
+
1324
+ /**
1325
+ * Fetches the SMTP and order tracking details
1326
+ */
1327
+ public function trackingSmtp()
1328
+ {
1329
+ $params['api_key'] = $this->apiKey;
1330
+ $psmailinObj = Mage::getModel('sendinblue/psmailin', $params);
1331
+ $smtpDetails = $psmailinObj->getSmtpDetails();
1332
+ return $smtpDetails;
1333
+ }
1334
+
1335
+ public function removeOldEntry()
1336
+ {
1337
+ $sendinSwitch = Mage::getModel('core/config');
1338
+ $sendinSwitch->saveConfig('sendinblue/smtp/status', '');
1339
+ $sendinSwitch->saveConfig('sendinblue/smtp/authentication', '');
1340
+ $sendinSwitch->saveConfig('sendinblue/smtp/username', '');
1341
+ $sendinSwitch->saveConfig('sendinblue/smtp/password', '');
1342
+ $sendinSwitch->saveConfig('sendinblue/smtp/host', '');
1343
+ $sendinSwitch->saveConfig('sendinblue/smtp/port', '');
1344
+ $sendinSwitch->saveConfig('sendinblue/smtp/ssl', '');
1345
+ $sendinSwitch->saveConfig('sendinblue/smtp/option', '');
1346
+ $sendinSwitch->saveConfig('sendinblue/tracking/code', '');
1347
+ }
1348
+
1349
+ protected function _uninstallResourceDb($version)
1350
+ {
1351
+ Mage::dispatchEvent('module_uninstall', array('resource' => $this->_resourceName));
1352
+ $this->_modifyResourceDb(self::TYPE_DB_UNINSTALL, $version, '');
1353
+ return $this;
1354
+ }
1355
+
1356
+ /**
1357
+ * This method is used to fetch all subscribe users from the default customer table to list
1358
+ * them in the Sendinblue magento module.
1359
+ */
1360
+ public function smsCampaignList()
1361
+ {
1362
+ $customerAddressData = array();
1363
+ $attributesName = $this->allAttributesName();
1364
+ $collection = Mage::getModel('customer/customer')->getCollection()->addAttributeToSelect('email')->addAttributeToSelect('firstname')->addAttributeToSelect('lastname')->addAttributeToSelect('created_in');
1365
+ $customerAddressCollection = Mage::getModel('customer/address');
1366
+
1367
+ foreach ($collection as $customer) {
1368
+ $responceData = array();
1369
+ $customerData = array();
1370
+
1371
+ $customerData = $customer->getData();
1372
+ $email = $customerData['email'];
1373
+ $customerId = $customerData['entity_id'];
1374
+
1375
+ $collectionAddress = $customerAddressCollection->getCollection()->addAttributeToSelect('telephone')->addAttributeToSelect('country_id')->addAttributeToSelect('company')->addAttributeToSelect('street')->addAttributeToSelect('postcode')->addAttributeToSelect('region')->addAttributeToSelect('city')->addAttributeToFilter('parent_id',(int)$customerId);
1376
+ $telephone = '';
1377
+ $customerAddress = array();
1378
+ foreach ($collectionAddress as $customerPhno) {
1379
+ $customerAddress = $customerPhno->getData();
1380
+ if (!empty($customerAddress['telephone']) && !empty($customerAddress['country_id'])) {
1381
+ $countryCode = $this->getCountryCode($customerAddress['country_id']);
1382
+ $customerAddress['telephone'] = $this->checkMobileNumber($customerAddress['telephone'], $countryCode);
1383
+ }
1384
+ $customerAddress['client'] = $customerId > 0 ? 1 : 0;
1385
+ }
1386
+ $customerAddressData[$email] = array_merge($customerData, $customerAddress);
1387
+ }
1388
+ $newsLetterData = array();
1389
+ $newsletter = Mage::getResourceModel('newsletter/subscriber_collection')->addFieldToFilter('subscriber_status', array('eq' => 1))->load();
1390
+ $count = 0;
1391
+
1392
+ foreach ( $newsletter->getItems() as $subscriber) {
1393
+ $subsdata = $subscriber->getData();
1394
+ $subscriberEmail = $subsdata['subscriber_email'];
1395
+ $subscriberStatus = $subsdata['subscriber_status'];
1396
+ if ( !empty($customerAddressData[$subscriberEmail]) ) {
1397
+ $customerAddressData[$subscriberEmail]['email'] = $subscriberEmail;
1398
+ $responceData[$count] = $this->mergeMyArray($attributesName, $customerAddressData[$subscriberEmail]);
1399
+ $responceData[$count]['EMAIL'] = $subscriberEmail;
1400
+ $responceData[$count]['subscriber_status'] = $subscriberStatus;
1401
+ }
1402
+ else {
1403
+ $newsLetterData['client'] = $subsdata['customer_id']>0?1:0;
1404
+ $responceData[$count] = $this->mergeMyArray($attributesName, $newsLetterData);
1405
+ $responceData[$count]['EMAIL'] = $subscriberEmail;
1406
+ $responceData[$count]['subscriber_status'] = $subscriberStatus;
1407
+ $responceData[$count]['STORE_ID'] = $subsdata['store_id'];
1408
+ }
1409
+ $count++;
1410
+ }
1411
+
1412
+ $i = 0;
1413
+ $data = array();
1414
+ foreach($responceData as $result) {
1415
+ if(!empty($result['SMS'])) {
1416
+ $data[$i]= $result;
1417
+ }
1418
+ $i++;
1419
+ }
1420
+
1421
+ return json_encode($data);
1422
+ }
1423
+
1424
+ /**
1425
+ * API config value from SendinBlue.
1426
+ */
1427
+ public function getApiConfigValue()
1428
+ {
1429
+ $params['api_key'] = $this->apiKey;
1430
+ $psmailinObj = Mage::getModel('sendinblue/psmailin', $params);
1431
+ $valueConfig = $psmailinObj->getPluginConfig();
1432
+ return $valueConfig;
1433
+ }
1434
+
1435
+ /**
1436
+ * Send template email by sendinblue for newsletter subscriber user .
1437
+ */
1438
+ public function sendWsTemplateMail($to, $templateId = false)
1439
+ {
1440
+ $params['api_key'] = $this->apiKey;
1441
+ $psmailinObj = Mage::getModel('sendinblue/psmailin', $params);
1442
+ $sendinConfirmType = $this->getSubscribeConfirmType();
1443
+ $doubleoptinTemplateId = $this->getDoubleoptinTemplateId();
1444
+ if (empty($sendinConfirmType) || $sendinConfirmType == 'nocon') {
1445
+ return false;
1446
+ }
1447
+
1448
+ if (!$templateId) {
1449
+ if ($sendinConfirmType == 'simplemail') {
1450
+ $templateIdValue = $this->getTemplateId();
1451
+ $templateId = !empty($templateIdValue) ? $templateIdValue : '';// 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.
1452
+
1453
+ $simpleEmailData = array(
1454
+ "id" => intval($templateId),
1455
+ "to" => $to,
1456
+ "cc" => "",
1457
+ "bcc" => "",
1458
+ "attr" => "",
1459
+ //"headers" => array("Content-Type"=> "text/html;charset=iso-8859-1", "X-Mailin-tag"=>$transactional_tags )
1460
+ );
1461
+ return $psmailinObj->sendTransactionalTemplate($simpleEmailData);
1462
+ }
1463
+
1464
+ $pathResponce = '';
1465
+ $emailUser = base64_encode($to);
1466
+ $pathResponce = Mage::getBaseUrl().'admin/ajax/mailResponce?value='.base64_encode($to);
1467
+ if ($sendinConfirmType == 'doubleoptin' && $doubleoptinTemplateId == '') {
1468
+ return $this->defaultDoubleoptinTemp($to, $pathResponce);
1469
+ }
1470
+ else if ($sendinConfirmType == 'doubleoptin' && $doubleoptinTemplateId > 0) {
1471
+ $templateId = $doubleoptinTemplateId;
1472
+ $senderName = 'SendinBlue';
1473
+ $senderEmail = 'contact@sendinblue.com';
1474
+ $doubleOptinRedirectUrlCheck = $this->getOptinRedirectUrlCheck();
1475
+ $data = array(
1476
+ 'id' => $templateId
1477
+ );
1478
+ $response = $psmailinObj->getCampaignV2($data);
1479
+
1480
+ if($response['code'] == 'success') {
1481
+ $htmlContent = $response['data'][0]['html_content'];
1482
+ if (trim($response['data'][0]['subject']) != '') {
1483
+ $subject = trim($response['data'][0]['subject']);
1484
+ }
1485
+ if (($response['data'][0]['from_name'] != '[DEFAULT_FROM_NAME]') &&
1486
+ ($response['data'][0]['from_email'] != '[DEFAULT_FROM_EMAIL]') &&
1487
+ ($response['data'][0]['from_email'] != '')) {
1488
+ $senderName = $response['data'][0]['from_name'];
1489
+ $senderEmail = $response['data'][0]['from_email'];
1490
+ }
1491
+ $transactionalTags = $response['data'][0]['campaign_name'];
1492
+ }
1493
+ $doubleoptinRedirectUrl = Mage::getBaseUrl();
1494
+ $sendinFinalConfirmEmail = $this->getSendinFinalConfirmEmail();
1495
+ $getFinalTemplateId = $this->getFinalTemplate();
1496
+
1497
+ if($doubleOptinRedirectUrlCheck == 'yes') {
1498
+ $sendinDoubleoptinRedirectUrl = $this->getSendinDoubleoptinRedirectUrl();
1499
+ if(!empty($sendinDoubleoptinRedirectUrl)) {
1500
+ $doubleoptinRedirectUrl = $sendinDoubleoptinRedirectUrl;
1501
+ }
1502
+ }
1503
+
1504
+ if($sendinFinalConfirmEmail == 'yes' && $getFinalTemplateId > 0)
1505
+ {
1506
+ $doubleoptinRedirectUrl = $pathResponce;
1507
+ }
1508
+
1509
+ $from = array($senderEmail, $senderName);
1510
+ $htmlContent = str_replace('{title}', $subject, $htmlContent);
1511
+ $htmlContent = str_replace('https://[DOUBLEOPTIN]', "$doubleoptinRedirectUrl", $htmlContent);
1512
+ $htmlContent = str_replace('http://[DOUBLEOPTIN]', "$doubleoptinRedirectUrl", $htmlContent);
1513
+ $htmlContent = str_replace('[DOUBLEOPTIN]', "$doubleoptinRedirectUrl", $htmlContent);
1514
+ $headers = array("Content-Type"=> "text/html;charset=iso-8859-1", "X-Mailin-tag"=>$transactionalTags );
1515
+ $sendMailData = array( "to" => array("$to" => ""),
1516
+ "from" => $from,
1517
+ "subject" => $subject,
1518
+ "html" => $htmlContent,
1519
+ "attachment" => array(),
1520
+ "headers" => $headers,
1521
+ );
1522
+ return $psmailinObj->sendEmail($sendMailData);
1523
+ }
1524
+ }
1525
+ else
1526
+ {
1527
+ $reConfirmEmail = array(
1528
+ "id" => intval($templateId),
1529
+ "to" => $to,
1530
+ "cc" => "",
1531
+ "bcc" => "",
1532
+ "attr" => "",
1533
+ //"headers" => array("Content-Type"=> "text/html;charset=iso-8859-1", "X-Mailin-tag"=>$transactional_tags )
1534
+ );
1535
+ return $psmailinObj->sendTransactionalTemplate($reConfirmEmail);
1536
+ }
1537
+ }
1538
+
1539
+ /**
1540
+ * send double optin template and manage.
1541
+ */
1542
+ public function defaultDoubleoptinTemp($subscriberEmail, $doubleoptinUrl)
1543
+ {
1544
+ $localeCode = Mage::app()->getLocale()->getLocaleCode();
1545
+ $emailTemplateVariables = array();
1546
+
1547
+ $emailTemplateVariables['text0'] = 'Please confirm your subscription';
1548
+ $senderName = 'SendinBlue';
1549
+ $senderEmail = 'contact@sendinblue.com';
1550
+
1551
+ if ($localeCode == 'fr_FR') {
1552
+ $emailTemplateVariables['text0'] = 'Confirmez votre inscription';
1553
+ $senderName = 'SendinBlue';
1554
+ $senderEmail = 'contact@sendinblue.com';
1555
+ }
1556
+ try {
1557
+ $emailTemplate = Mage::getModel('core/email_template')->loadDefault('doubleoptin_template');
1558
+ $templateText = $emailTemplate->template_text;
1559
+ $webSite = Mage::app()->getWebsite()->getName();
1560
+ preg_match_all('#{(.*)}#', $templateText, $match);
1561
+
1562
+ $sendinFinalConfirmEmail = $this->getSendinFinalConfirmEmail();
1563
+ if($sendinFinalConfirmEmail == 'yes') {
1564
+ $getFinalTemplateId = $this->getFinalTemplate();
1565
+ if($getFinalTemplateId <= 0 || empty($getFinalTemplateId)) {
1566
+ $doubleoptinUrl = $this->getSendinDoubleoptinRedirectUrl();
1567
+ }
1568
+ }
1569
+ else {
1570
+ $doubleoptinUrl = $this->getSendinDoubleoptinRedirectUrl();
1571
+ }
1572
+
1573
+ $templateData = array(
1574
+ '{double_optin}'=>$doubleoptinUrl,
1575
+ '{site_name}'=> $webSite
1576
+ );
1577
+ foreach($match[0] as $var=>$value){
1578
+ $templateText = preg_replace('#'.$value.'#',$templateData[$value],$templateText);
1579
+ }
1580
+ $emailTemplate->template_text = $templateText;
1581
+ $emailTemplate->getProcessedTemplate($emailTemplateVariables);
1582
+ $emailTemplate->setSenderName($senderName);
1583
+ $emailTemplate->setSenderEmail($senderEmail);
1584
+ $emailTemplate->setTemplateSubject($emailTemplateVariables['text0']);
1585
+ return $emailTemplate->send($subscriberEmail, '', $emailTemplateVariables);
1586
+ }
1587
+ catch(Exception $e) {
1588
+ }
1589
+ }
1590
+
1591
+ /**
1592
+ * Get all temlpate list id by sendinblue.
1593
+ */
1594
+ public function templateDisplay()
1595
+ {
1596
+ $listData = array();
1597
+ $listData['show'] = 'ALL';
1598
+ $listData['messageType'] = 'template';
1599
+ $params['api_key'] = $this->apiKey;
1600
+ $psmailinObj = Mage::getModel('sendinblue/psmailin', $params);
1601
+ return $psmailinObj->getCampaignsV2($listData);
1602
+ }
1603
+
1604
+ /**
1605
+ * Get getCountryCode from sendinblue_country table,
1606
+ */
1607
+ public function getCountryCode($countryids)
1608
+ {
1609
+ $tableCountry = Mage::getSingleton('core/resource')->getTableName('sendinblue_country_codes');
1610
+ $readDbObject = Mage::getSingleton("core/resource")->getConnection("core_read");
1611
+
1612
+ $queryCountryCode = $readDbObject->select()
1613
+ ->from($tableCountry,array('country_prefix'))
1614
+ ->where("iso_code = ?", $countryids);
1615
+ $stmtCountryCode = $readDbObject->query($queryCountryCode);
1616
+ $countryPrefixData = $stmtCountryCode->fetch();
1617
+
1618
+ $countryPrefix = $countryPrefixData['country_prefix'];
1619
+ return $countryPrefix;
1620
+ }
1621
+
1622
+ /**
1623
+ * Import transactional data,
1624
+ */
1625
+ public function importTransactionalData($email, $attributesValues, $getUserList)
1626
+ {
1627
+ $userData = array();
1628
+ $userData['email'] = $email;
1629
+ $userData['attributes'] = $attributesValues;
1630
+ $userData['listid'] = (is_array($getUserList)) ? $getUserList : array($getUserList);
1631
+ $params['api_key'] = $this->apiKey;
1632
+
1633
+ $psmailinObj = Mage::getModel('sendinblue/psmailin', $params);
1634
+ return $psmailinObj->createUpdateUser($userData);
1635
+ }
1636
+ }
app/code/{local → community}/Sendinblue/Sendinblue/Model/Status.php RENAMED
@@ -10,14 +10,14 @@
10
 
11
  class Sendinblue_Sendinblue_Model_Status extends Varien_Object
12
  {
13
- const STATUS_ENABLED = 1;
14
- const STATUS_DISABLED = 2;
15
 
16
- static public function getOptionArray()
17
- {
18
- return array(
19
- self::STATUS_ENABLED => Mage::helper('sendinblue')->__('Enabled'),
20
- self::STATUS_DISABLED => Mage::helper('sendinblue')->__('Disabled')
21
- );
22
- }
23
  }
10
 
11
  class Sendinblue_Sendinblue_Model_Status extends Varien_Object
12
  {
13
+ const STATUS_ENABLED = 1;
14
+ const STATUS_DISABLED = 2;
15
 
16
+ static public function getOptionArray()
17
+ {
18
+ return array(
19
+ self::STATUS_ENABLED => Mage::helper('sendinblue')->__('Enabled'),
20
+ self::STATUS_DISABLED => Mage::helper('sendinblue')->__('Disabled')
21
+ );
22
+ }
23
  }
app/code/community/Sendinblue/Sendinblue/controllers/Adminhtml/AjaxController.php ADDED
@@ -0,0 +1,801 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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_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
+
24
+ public function campaignAction()
25
+ {
26
+ $postData = $this->getRequest()->getPost();
27
+ try {
28
+ if (empty($postData)) {
29
+ echo Mage::throwException($this->__('Invalid form data.'));
30
+ }
31
+ $sendinSwitch = Mage::getModel('core/config');
32
+ $sendinSwitch->saveConfig('sendinblue/sms/campaign', $postData['campaignSetting']);
33
+ echo $this->__('Your setting has been successfully saved');
34
+ }
35
+ catch (Exception $exception) {
36
+ echo $this->__($exception->getMessage());
37
+ }
38
+ }
39
+
40
+ public function orderAction()
41
+ {
42
+ $postData = $this->getRequest()->getPost();
43
+ try {
44
+ if (empty($postData)) {
45
+ Mage::throwException($this->__('Invalid form data.'));
46
+ }
47
+ $sendinSwitch = Mage::getModel('core/config');
48
+ $sendinSwitch->saveConfig('sendinblue/sms/order', $postData['orderSetting']);
49
+ echo $this->__('Your setting has been successfully saved');
50
+ }
51
+ catch (Exception $exception) {
52
+ echo $this->__($exception->getMessage());
53
+ }
54
+ }
55
+
56
+ public function creditAction()
57
+ {
58
+ $postData = $this->getRequest()->getPost();
59
+ try {
60
+ if (empty($postData)) {
61
+ Mage::throwException($this->__('Invalid form data.'));
62
+ }
63
+ $sendinSwitch = Mage::getModel('core/config');
64
+ $sendinSwitch->saveConfig('sendinblue/sms/credit', $postData['sms_credit']);
65
+ echo $this->__('Your setting has been successfully saved');
66
+ }
67
+ catch (Exception $exception) {
68
+ echo $this->__($exception->getMessage());
69
+ }
70
+ }
71
+
72
+ public function shipingAction()
73
+ {
74
+ $postData = $this->getRequest()->getPost();
75
+ try {
76
+ if (empty($postData)) {
77
+ Mage::throwException($this->__('Invalid form data.'));
78
+ }
79
+ $sendinSwitch = Mage::getModel('core/config');
80
+ $sendinSwitch->saveConfig('sendinblue/sms/shiping', $postData['shipingSetting']);
81
+ echo $this->__('Your setting has been successfully saved');
82
+ }
83
+ catch (Exception $exception) {
84
+ echo $this->__($exception->getMessage());
85
+ }
86
+ }
87
+
88
+ public function codepostAction()
89
+ {
90
+ $postData = $this->getRequest()->getPost();
91
+ try {
92
+ if (empty($postData)) {
93
+ Mage::throwException($this->__('Invalid form data.'));
94
+ }
95
+ $sendinSwitch = Mage::getModel('core/config');
96
+ $sendinSwitch->saveConfig('sendinblue/tracking/code', $postData['script']);
97
+ $sendinSwitch->saveConfig('sendinblue/improt/history', $postData['script']);
98
+ echo $this->__('Your setting has been successfully saved');
99
+ }
100
+ catch (Exception $exception) {
101
+ echo $this->__($exception->getMessage());
102
+ }
103
+ }
104
+
105
+ public function emptySubsUserToSendinblueAction()
106
+ {
107
+ $postData = $this->getRequest()->getPost();
108
+ try {
109
+ if (empty($postData)) {
110
+ Mage::throwException($this->__('Invalid form data.'));
111
+ }
112
+ if ($postData['proc_success'] != '') {
113
+ $handle = fopen(Mage::getBaseDir('media').'/sendinblue_csv/ImportSubUsersToSendinblue.csv', 'w+');
114
+ $keyValue = array();
115
+ $keyValue[] = '';
116
+ fputcsv($handle, $keyValue);
117
+ fclose($handle);
118
+ }
119
+ }
120
+ catch (Exception $exception) {
121
+ echo $this->__($exception->getMessage());
122
+ }
123
+ }
124
+
125
+ public function mailResponceAction()
126
+ {
127
+ $postData = $this->getRequest()->getParams();
128
+ try {
129
+ if (empty($postData)) {
130
+ Mage::throwException($this->__('Invalid form data.'));
131
+ }
132
+ $userEmail = base64_decode($postData['value']);
133
+ if ($userEmail != '') {
134
+ $newsletter = Mage::getResourceModel('newsletter/subscriber_collection')->addFieldToFilter('subscriber_email', array('eq' => $userEmail))->load();;
135
+ foreach ($newsletter->getItems() as $subscriber) {
136
+ $subScriberData = $subscriber->getData();
137
+ $subScriberEmail = $subScriberData['subscriber_email'];
138
+ $subScriberStatus = $subScriberData['subscriber_status'];
139
+ }
140
+ $sendinModule = Mage::getModel('sendinblue/sendinblue');
141
+ if (!empty($subScriberEmail) && $subScriberStatus == 1) {
142
+ $listId = $sendinModule->getUserlists();
143
+ $doubleOptinId = Mage::getStoreConfig('sendinblue/SendinOptinListId');
144
+ $apiDetails['api_key'] = $sendinModule->getApiKey();
145
+ $objPsmailin = Mage::getModel('sendinblue/psmailin',$apiDetails);
146
+
147
+ $userData = array( "email" => $subScriberEmail,
148
+ "attributes" => array(),
149
+ "blacklisted" => 0,
150
+ "listid" => (is_array($listId)) ? $listId : array($listId),
151
+ "listid_unlink" => array($doubleOptinId),
152
+ "blacklisted_sms" => 0
153
+ );
154
+
155
+ $responce = $objPsmailin->createUpdateUser($userData);
156
+ $finalStatus = Mage::getStoreConfig('sendinblue/SendinFinalConfirmEmail');
157
+ if ($finalStatus === 'yes') {
158
+ $finalTemplateId = Mage::getStoreConfig('sendinblue/SendinTemplateFinal');
159
+ $sendinModule->sendWsTemplateMail($subScriberEmail, $finalTemplateId);
160
+ }
161
+ $urlStatus = $sendinModule->getOptinRedirectUrlCheck();
162
+
163
+ if ($urlStatus == 'yes') {
164
+ $urlValue = $sendinModule->getSendinDoubleoptinRedirectUrl();
165
+ $this->_redirectUrl($urlValue);
166
+ } else {
167
+ $configValue = Mage::getStoreConfig('web/secure/base_url');
168
+ $this->_redirectUrl($configValue);
169
+ }
170
+ }
171
+ }
172
+ }
173
+ catch (Exception $exception) {
174
+ echo $this->__($exception->getMessage());
175
+ }
176
+ }
177
+
178
+ public function emptyImportOldOrderAction()
179
+ {
180
+ $postData = $this->getRequest()->getPost();
181
+ try {
182
+ if (empty($postData)) {
183
+ Mage::throwException($this->__('Invalid form data.'));
184
+ }
185
+
186
+ if ($postData['proc_success'] != '') {
187
+ $handle = fopen(Mage::getBaseDir('media').'/sendinblue_csv/ImportOldOrdersToSendinblue.csv', 'w+');
188
+ $keyValue = array();
189
+ $keyValue[] = '';
190
+ fputcsv($handle, $keyValue);
191
+ fclose($handle);
192
+ }
193
+ }
194
+ catch (Exception $exception) {
195
+ echo $this->__($exception->getMessage());
196
+ }
197
+ }
198
+
199
+ public function orderhistoryAction()
200
+ {
201
+ $sendinModule = Mage::getModel('sendinblue/sendinblue');
202
+ $apiDetails['api_key'] = $sendinModule->getApiKey();
203
+ $psmailinObj = Mage::getModel('sendinblue/psmailin',$apiDetails);
204
+
205
+ $postData = $this->getRequest()->getPost();
206
+ try {
207
+ if (empty($postData)) {
208
+ Mage::throwException($this->__('Invalid form data.'));
209
+ }
210
+
211
+ if ($postData['history_status'] == 1) {
212
+ $value = $sendinModule->trackingSmtp();
213
+ $dateValue = $sendinModule->getApiConfigValue();
214
+ if (!is_dir(Mage::getBaseDir('media').'/sendinblue_csv')) {
215
+ mkdir(Mage::getBaseDir('media').'/sendinblue_csv', 0777, true);
216
+ }
217
+ $handle = fopen(Mage::getBaseDir('media').'/sendinblue_csv/ImportOldOrdersToSendinblue.csv', 'w+');
218
+ fwrite($handle, 'EMAIL,ORDER_ID,ORDER_PRICE,ORDER_DATE'.PHP_EOL);
219
+
220
+ $collection = Mage::getModel('customer/customer')->getCollection();
221
+ $collection->addNameToSelect()
222
+ ->joinTable('newsletter_subscriber', 'customer_id = entity_id', array('subscriber_status'), '{{table}}.subscriber_status = 1');
223
+
224
+ $salesOrderColection = Mage::getModel('sales/order');
225
+ foreach ($collection as $customer) {
226
+ $customerId = $customer->getData('entity_id');
227
+ $totalOrders = $salesOrderColection->getCollection()->addFieldToFilter('customer_id', $customerId);
228
+ foreach($totalOrders as $orderData) {
229
+ if(count($orderData) > 0) {
230
+ if (isset($dateValue['data']['date_format']) && $dateValue['data']['date_format'] == 'dd-mm-yyyy') {
231
+ $orderDate = date('d-m-Y', strtotime($orderData['created_at']));
232
+ }
233
+ else {
234
+ $orderDate = date('m-d-Y', strtotime($orderData['created_at']));
235
+ }
236
+ $historyData= array();
237
+ $historyData[] = array($orderData['customer_email'], $orderData['increment_id'], $orderData['grand_total'], $orderDate);
238
+ foreach ($historyData as $line) {
239
+ fputcsv($handle, $line);
240
+ }
241
+ }
242
+ }
243
+ }
244
+
245
+ fclose($handle);
246
+ $getUserLists = $sendinModule->getUserlists();
247
+ $list = str_replace('|', ',', $getUserLists);
248
+ $list = (preg_match('/^[0-9,]+$/', $list)) ? $list : '';
249
+ $importData = array();
250
+ $importData['url'] = Mage::getBaseUrl('media').'sendinblue_csv/ImportOldOrdersToSendinblue.csv';
251
+ $importData['listids'] = array($list);
252
+ $importData['notify_url'] = Mage::getBaseUrl().'sendinblue/ajax/emptyImportOldOrder';
253
+ /**
254
+ * List id should be optional
255
+ */
256
+
257
+ $psmailinObj->importUsers($importData);
258
+ $sendinSwitch = Mage::getModel('core/config');
259
+ $sendinSwitch->saveConfig('sendinblue/improt/history', 0);
260
+ if($postData['langvalue'] == 'fr_FR') {
261
+ $msg = 'Historique des commandes a été importé avec succès.';
262
+ }
263
+ else {
264
+ $msg = 'Order history has been import successfully';
265
+ }
266
+ echo $msg;
267
+ }
268
+ }
269
+ catch (Exception $exception) {
270
+ echo $this->__($exception->getMessage());
271
+ }
272
+ }
273
+
274
+ public function smtppostAction()
275
+ {
276
+ $sendinModule = Mage::getModel('sendinblue/sendinblue');
277
+ $postData = $this->getRequest()->getPost();
278
+ try {
279
+ if (empty($postData)) {
280
+ Mage::throwException($this->__('Invalid form data.'));
281
+ }
282
+ else {
283
+ $sendinSwitch = Mage::getModel('core/config');
284
+ $getKey = $sendinModule->getApiKey();
285
+ $apiKeyStatus = $sendinModule->checkApikey($getKey);
286
+ if (empty($apiKeyStatus['error'])) {
287
+ $sendinSwitch->saveConfig('sendinblue/smtp/status', $postData['smtptest']);
288
+ $smtpResponse = $sendinModule->trackingSmtp(); // get tracking code
289
+ if (isset($smtpResponse['data']['relay_data']['status']) && $smtpResponse['data']['relay_data']['status'] == 'enabled') {
290
+ $sendinSwitch->saveConfig('sendinblue/smtp/authentication', 'crammd5', 'default', 0);
291
+ $sendinSwitch->saveConfig('sendinblue/smtp/username', $smtpResponse['data']['relay_data']['data']['username'], 'default', 0);
292
+ $sendinSwitch->saveConfig('sendinblue/smtp/password', $smtpResponse['data']['relay_data']['data']['password'], 'default', 0);
293
+ $sendinSwitch->saveConfig('sendinblue/smtp/host', $smtpResponse['data']['relay_data']['data']['relay'], 'default', 0);
294
+ $sendinSwitch->saveConfig('sendinblue/smtp/port', $smtpResponse['data']['relay_data']['data']['port'], 'default', 0);
295
+ $sendinSwitch->saveConfig('sendinblue/smtp/ssl', 'null', 'default', 0);
296
+ $sendinSwitch->saveConfig('sendinblue/smtp/option', 'smtp', 'default', 0);
297
+ echo $this->__('Your setting has been successfully saved');
298
+ }
299
+ else {
300
+ $sendinSwitch->saveConfig('sendinblue/smtp/status', 0);
301
+ 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');
302
+ }
303
+ }
304
+ else if(isset($responce['error'])) {
305
+ echo $this->__('You have entered wrong api key');
306
+ }
307
+ }
308
+ }
309
+ catch (Exception $exception) {
310
+ echo $this->__($exception->getMessage());
311
+ }
312
+ }
313
+
314
+ public function ajaxcontentAction()
315
+ {
316
+ $sendinModule = Mage::getModel('sendinblue/sendinblue');
317
+ $postData = $this->getRequest()->getPost();
318
+
319
+ try {
320
+ if (empty($postData)) {
321
+ Mage::throwException($this->__('Invalid form data.'));
322
+ }
323
+ else {
324
+ $localeCode = Mage::app()->getLocale()->getLocaleCode();
325
+ if ($localeCode == 'fr_FR') {
326
+ $title1 = 'Inscrire le contact';
327
+ $title2 = 'Désinscrire le contact';
328
+ $title3 = 'Inscrire le sms';
329
+ $title4 = 'Désinscrire le sms';
330
+ $first = 'Première page';
331
+ $last = 'Dernière page';
332
+ $previous = 'Précédente';
333
+ $next = 'Suivante';
334
+ $yes = 'oui';
335
+ $no = 'non';
336
+ }
337
+ else {
338
+ $title1 = 'Unsubscribe the contact';
339
+ $title2 = 'Subscribe the contact';
340
+ $title3 = 'Unsubscribe the sms';
341
+ $title4 = 'Subscribe the sms';
342
+ $first = 'First';
343
+ $last = 'Last';
344
+ $previous = 'Previous';
345
+ $next = 'Next';
346
+ $yes = 'yes';
347
+ $no = 'no';
348
+ }
349
+
350
+ $page = (int)$postData['page'];
351
+ $currentPage = $page;
352
+ $page -= 1;
353
+ $perPage = 20;
354
+ $previousButton = true;
355
+ $nextButton = true;
356
+ $firstButton = true;
357
+ $lastButton = true;
358
+ $start = $page * $perPage;
359
+ $count = $sendinModule->getNewsletterSubscribeCount() + $sendinModule->getNewsletterUnSubscribeCount();
360
+ $noOfPaginations = ceil($count / $perPage);
361
+ if ($currentPage >= 7) {
362
+ $startLoop = $currentPage - 3;
363
+ if ($noOfPaginations > $currentPage + 3) {
364
+ $endLoop = $currentPage + 3;
365
+ }
366
+ else if ($currentPage <= $noOfPaginations && $currentPage > $noOfPaginations - 6) {
367
+ $startLoop = $noOfPaginations - 6;
368
+ $endLoop = $noOfPaginations;
369
+ }
370
+ else {
371
+ $endLoop = $noOfPaginations;
372
+ }
373
+ }
374
+ else {
375
+ $startLoop = 1;
376
+ if ($noOfPaginations > 7) {
377
+ $endLoop = 7;
378
+ }
379
+ else {
380
+ $endLoop = $noOfPaginations;
381
+ }
382
+ }
383
+
384
+ $collection = $sendinModule->getNewsletterSubscribe($start, $perPage);
385
+ $sendinUserStatus = $sendinModule->checkUserSendinStatus($collection);
386
+
387
+ $sendinUserResult = isset($sendinUserStatus['data']) ? $sendinUserStatus['data'] : '';
388
+ if (count($collection) > 0) {
389
+ $i = 1;
390
+ $message = '';
391
+ $skinUrl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_SKIN);
392
+ foreach ($collection as $subscriber) {
393
+ $email = isset($subscriber['email']) ? $subscriber['email'] : '';
394
+ $phone = isset($subscriber['SMS']) ? $subscriber['SMS'] : '';
395
+
396
+ $client = (!empty($subscriber['customer_id']) > 0) ? $yes : $no ;
397
+ $showStatus = '';
398
+ $smsStatus = '';
399
+ if(isset($sendinUserResult[$email])) {
400
+ $emailBalanceValue = isset($sendinUserResult[$email]['email_bl']) ? $sendinUserResult[$email]['email_bl'] : '';
401
+
402
+ if ($emailBalanceValue === 1 || $sendinUserResult[$email] == null) {
403
+ $showStatus = 0;
404
+ }
405
+
406
+ if ($emailBalanceValue === 0) {
407
+ $showStatus = 1;
408
+ }
409
+
410
+ $smsBalance = isset($sendinUserResult[$email]['sms_bl']) ? $sendinUserResult[$email]['sms_bl'] : '';
411
+ $smsExist = isset($sendinUserResult[$email]['sms_exist']) ? $sendinUserResult[$email]['sms_exist'] : '';
412
+ $subScriberTelephone = isset($subscriber['SMS']) ? $subscriber['SMS'] : '';
413
+
414
+ if ($smsBalance === 1 && $smsExist > 0) {
415
+ $smsStatus = 0;
416
+ }
417
+ else if ($smsBalance === 0 && $smsExist > 0) {
418
+ $smsStatus = 1;
419
+ }
420
+ else if ($smsExist <= 0 && empty($subScriberTelephone)) {
421
+ $smsStatus = 2;
422
+ }
423
+ else if ($smsExist <= 0 && !empty($subScriberTelephone)) {
424
+ $smsStatus = 3;
425
+ }
426
+ }
427
+
428
+ if ($subscriber['subscriber_status'] != 3) {
429
+ $imgMagento = '<img src="'.$skinUrl.'adminhtml/default/default/sendinblue/images/enabled.gif" >';
430
+ }
431
+ else {
432
+ $imgMagento = '<img src="'.$skinUrl.'adminhtml/default/default/sendinblue/images/disabled.gif" >';
433
+ }
434
+
435
+ $smsStatus = $smsStatus >= 0 ? $smsStatus : '';
436
+
437
+ if ($smsStatus === 1) {
438
+ $imgSms = '<img src="'.$skinUrl.'adminhtml/default/default/sendinblue/images/enabled.gif" id="ajax_contact_status_'.$i.'" title="'.$title3.'" >';
439
+ }
440
+ else if ($smsStatus === 0) {
441
+ $imgSms = '<img src="'.$skinUrl.'adminhtml/default/default/sendinblue/images/disabled.gif" id="ajax_contact_status_'.$i.'" title="'.$title4.'" >';
442
+ }
443
+ else if ($smsStatus === 2 || $smsStatus === '') {
444
+ $imgSms = '';
445
+ }
446
+ else if ($smsStatus === 3) {
447
+ $imgSms = 'Not synchronized';
448
+ }
449
+
450
+ $showStatus = !empty($showStatus) ? $showStatus : '0';
451
+
452
+ if ($showStatus == 1) {
453
+ $imgSendinBlue = '<img src="'.$skinUrl.'adminhtml/default/default/sendinblue/images/enabled.gif" id="ajax_contact_status_'.$i.'" title="'.$title1.'" >';
454
+ }
455
+ else {
456
+ $imgSendinBlue = '<img src="'.$skinUrl.'adminhtml/default/default/sendinblue/images/disabled.gif" id="ajax_contact_status_'.$i.'" title="'.$title2.'" >';
457
+ }
458
+
459
+ $message .= '<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">'.$imgMagento.'</td>
460
+ <td class="a-left"><a status="'.$showStatus.'" email="'.$email.'" class="ajax_contacts_href" href="javascript:void(0)">
461
+ '.$imgSendinBlue.'</a></td><td class="a-left last"><a status="'.$smsStatus.'" email="'.$email.'" class="ajax_sms_subs_href" href="javascript:void(0)">
462
+ '.$imgSms.'</a></td></tr>';
463
+
464
+ $i++;
465
+ }
466
+ }
467
+ $messagePaging = '';
468
+ $messagePaging .= '<tr><td colspan="7"><div class="pagination"><ul class="pull-left">';
469
+
470
+ if ($firstButton && $currentPage > 1) {
471
+ $messagePaging .= '<li p="1" class="active">'.$first.'</li>';
472
+ }
473
+ else if ($firstButton) {
474
+ $messagePaging .= '<li p="1" class="inactive">'.$first.'</li>';
475
+ }
476
+
477
+ if ($previousButton && $currentPage > 1) {
478
+ $previousValue = $currentPage - 1;
479
+ $messagePaging .= '<li p="'.$previousValue.'" class="active">'.$previous.'</li>';
480
+ }
481
+ else if ($previousButton) {
482
+ $messagePaging .= '<li class="inactive">'.$previous.'</li>';
483
+ }
484
+
485
+ for ($i = $startLoop; $i <= $endLoop; $i++) {
486
+ if ($currentPage == $i) {
487
+ $messagePaging .= '<li p="'.$i.'" style="color:#fff;background-color:#000000;" class="active">'.$i.'</li>';
488
+ }
489
+ else {
490
+ $messagePaging .= '<li p="'.$i.'" class="active">'.$i.'</li>';
491
+ }
492
+ }
493
+
494
+ if ($nextButton && $currentPage < $noOfPaginations) {
495
+ $nextValue = $currentPage + 1;
496
+ $messagePaging .= '<li p="'.$nextValue.'" class="active">'.$next.'</li>';
497
+ }
498
+ else if ($nextButton) {
499
+ $messagePaging .= '<li class="inactive">'.$next.'</li>';
500
+ }
501
+
502
+ if ($lastButton && $currentPage < $noOfPaginations) {
503
+ $messagePaging .= '<li p="'.$noOfPaginations.'" class="active">'.$last.'</li>';
504
+ }
505
+ else if ($lastButton) {
506
+ $messagePaging .= '<li p="'.$noOfPaginations.'" class="inactive">'.$last.'</li>';
507
+ }
508
+
509
+ if ($count != 0) {
510
+ echo $message . $messagePaging.'</td></tr>';
511
+ }
512
+ }
513
+ }
514
+ catch (Exception $exception) {
515
+ echo $this->__($exception->getMessage());
516
+ }
517
+ }
518
+
519
+ public function ajaxsmssubscribeAction()
520
+ {
521
+ $sendinModule = Mage::getModel('sendinblue/sendinblue');
522
+ $apiDetails['api_key'] = $sendinModule->getApiKey();
523
+ $psmailinObj = Mage::getModel('sendinblue/psmailin',$apiDetails);
524
+
525
+ $postData = $this->getRequest()->getPost();
526
+ try {
527
+ if (empty($postData)) {
528
+ Mage::throwException($this->__('Invalid form data.'));
529
+ }
530
+ $email = $postData['email'];
531
+ $userData = array();
532
+ $userData['email'] = $email;
533
+ $psmailinObj->userSmsUnsubscribed($userData);
534
+ }
535
+ catch (Exception $exception) {
536
+ echo $this->__($exception->getMessage());
537
+ }
538
+ }
539
+
540
+ public function ajaxupdateAction()
541
+ {
542
+ $postData = $this->getRequest()->getPost();
543
+ $coreResource = Mage::getSingleton('core/resource');
544
+ $tableCustomer = $coreResource->getTableName('customer/entity');
545
+ $tableNewsletter = $coreResource->getTableName('newsletter/subscriber');
546
+ $sendinModule = Mage::getModel('sendinblue/sendinblue');
547
+ $attributesName = $sendinModule->allAttributesName();
548
+
549
+ $readDbObject = Mage::getSingleton("core/resource")->getConnection("core_read");
550
+ $writeDbObject = Mage::getSingleton("core/resource")->getConnection("core_write");
551
+
552
+ try {
553
+ if (empty($postData)) {
554
+ Mage::throwException($this->__('Invalid form data.'));
555
+ }
556
+
557
+ $listId = str_replace(',', '|', $sendinModule->getUserlists());
558
+ $postEmail = !empty($postData['email']) ? $postData['email'] : '';
559
+ $postNewsLetter = !empty($postData['newsletter']) ? $postData['newsletter'] : '';
560
+ $templateSubscribeStatus = ($postNewsLetter == 0) ? 1 : 3;
561
+
562
+ $queryCustomerEntity = $readDbObject->select()
563
+ ->from($tableCustomer, array('store_id', 'entity_id'))
564
+ ->where("email = ?", $postEmail);
565
+ $stmtCustomerEntity = $readDbObject->query($queryCustomerEntity);
566
+ $customerData = $stmtCustomerEntity->fetch();
567
+
568
+ if (!empty($postEmail) && $postNewsLetter == 0) {
569
+
570
+ $localeCode = Mage::app()->getLocale()->getLocaleCode();
571
+ $emailSubscribeResponce = $sendinModule->emailSubscribe($postEmail);
572
+
573
+ $customerAddress = array();
574
+ if (isset($emailSubscribeResponce['code']) && $emailSubscribeResponce['code'] == 'failure' && $emailSubscribeResponce['message'] == 'User not exists') {
575
+ if (isset($customerData['entity_id']) != '') {
576
+ $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)$customerData['entity_id']);
577
+ $telephone = '';
578
+ foreach ($collectionAddress as $customerPhno) {
579
+ $customerAddress = $customerPhno->getData();
580
+ if (!empty($customerAddress['telephone']) && !empty($customerAddress['country_id'])) {
581
+ $countryCode = $sendinModule->getCountryCode($customerAddress['country_id']);
582
+ $customerAddress['telephone'] = $sendinModule->checkMobileNumber($customerAddress['telephone'], $countryCode);
583
+ }
584
+ }
585
+ $customer = Mage::getModel("customer/customer");
586
+ $customer->setWebsiteId(Mage::app()->getWebsite()->getId());
587
+ $customer->loadByEmail($postEmail); //load customer by email id
588
+ $customerName = $customer->getData();
589
+ $userLanguage = isset($customerName['created_in'])?$customerName['created_in'] : '';
590
+ $customerData = array_merge($customerAddress, $customerName);
591
+ $resp = $sendinModule->mergeMyArray($attributesName, $customerData);
592
+ $resp['CLIENT'] = 1;
593
+ $resp['MAGENTO_LANG'] = $userLanguage;
594
+ $responce = $sendinModule->emailAdd($postEmail, $resp, $postNewsLetter, $listId);
595
+ }
596
+ else {
597
+ $client = 0;
598
+ $customerData = array();
599
+ $subsdata = Mage::getModel('newsletter/subscriber')->loadByEmail($email)->getData();
600
+ $resp = $sendinModule->mergeMyArray($attributesName, $subsdata);
601
+ $resp['CLIENT'] = $client;
602
+ $responce = $sendinModule->emailAdd($postEmail, $resp, $postNewsLetter, $listId);
603
+ }
604
+ }
605
+
606
+ $querySubscriberEmail = $readDbObject->select()
607
+ ->from($tableNewsletter, array('subscriber_email'))
608
+ ->where("subscriber_email = ?", $postEmail);
609
+ $stmtSubscriberEmail = $readDbObject->query($querySubscriberEmail);
610
+ $customerDataNews = $stmtSubscriberEmail->fetch();
611
+
612
+ if ($customerData['entity_id'] !='' && $customerDataNews['subscriber_email'] == '' ) {
613
+ $newsLetterData = array(
614
+ "store_id" => $customerData['store_id'],
615
+ "customer_id" => $customerData['entity_id'],
616
+ "subscriber_email" => $postEmail,
617
+ "subscriber_status" => 1,
618
+ );
619
+ $writeDbObject->insert($tableNewsletter, $data);
620
+ }
621
+ else {
622
+ $costomerInformation = Mage::getModel('newsletter/subscriber')->loadByEmail($postEmail);
623
+ $costomerInformation->setStatus($templateSubscribeStatus);
624
+ $costomerInformation->setIsStatusChanged(true);
625
+ $costomerInformation->save();
626
+ }
627
+
628
+ }
629
+ else{
630
+ $responce = $sendinModule->emailDelete($postEmail);
631
+ $costomerInformation = Mage::getModel('newsletter/subscriber')->loadByEmail($postEmail);
632
+
633
+ if (!$costomerInformation->getStoreId()) {
634
+ $costomerInformation->setSubscriberEmail($postEmail);
635
+ $costomerInformation->setCustomerId($customerData['entity_id']);
636
+ $costomerInformation->setStoreId($customerData['store_id']);
637
+ }
638
+ $costomerInformation->setStatus($templateSubscribeStatus);
639
+ $costomerInformation->setIsStatusChanged(true);
640
+ $costomerInformation->save();
641
+ }
642
+ }
643
+ catch (Exception $exception) {
644
+ echo $this->__($exception->getMessage());
645
+ }
646
+ }
647
+
648
+ public function ajaxordersmsAction($sender='', $message='', $number='')
649
+ {
650
+ $postData = $this->getRequest()->getPost();
651
+ try {
652
+ if (empty($postData)) {
653
+ Mage::throwException($this->__('Invalid form data.'));
654
+ }
655
+ $number = $postData['number'];
656
+ $charone = substr($number, 0, 1);
657
+ $chartwo = substr($number, 0, 2);
658
+ if ($charone == '0' && $chartwo == '00') {
659
+ $number = $number;
660
+ }
661
+
662
+ if (isset($number)) {
663
+ $adminUserModel = Mage::getModel('admin/user');
664
+ $userCollection = $adminUserModel->getCollection()->load();
665
+ $adminData = $userCollection->getData();
666
+ $firstname = isset($adminData[0]['firstname']) ? $adminData[0]['firstname'] : '';
667
+ $lastname = isset($adminData[0]['lastname']) ? $admin_data[0]['lastname'] : '';
668
+ $characters = '1234567890';
669
+ $referenceNumber = '';
670
+ for ($i = 0; $i < 9; $i++) {
671
+ $referenceNumber .= $characters[rand(0, strlen($characters) - 1)];
672
+ }
673
+
674
+ $localeCode = Mage::app()->getLocale()->getLocaleCode();
675
+ $orderDateFormat = ($localeCode == 'fr_FR') ? date('d/m/Y') : date('m/d/Y');
676
+ $orderprice = rand(10, 1000);
677
+ $totalPay = $orderprice.'.00'.' '.Mage::app()->getStore()-> getCurrentCurrencyCode();
678
+ $firstName = str_replace('{first_name}', $firstname, $postData['message']);
679
+ $lastName = str_replace('{last_name}', $lastname."\r\n", $firstName);
680
+ $procuctPrice = str_replace('{order_price}', $totalPay, $lastName);
681
+ $orderDate = str_replace('{order_date}', $orderDateFormat."\r\n", $procuctPrice);
682
+ $msgbody = str_replace('{order_reference}', $referenceNumber, $orderDate);
683
+ $smsData = array();
684
+ $smsData['to'] = $number;
685
+ $smsData['from'] = isset($postData['sender']) ? $postData['sender'] : '';
686
+ $smsData['text'] = $msgbody;
687
+
688
+ $sendSmsResponce = Mage::getModel('sendinblue/sendinblue')->sendSmsApi($smsData);
689
+ if (isset($sendSmsResponce['status']) && $sendSmsResponce['status'] == 'OK') {
690
+ echo 'OK';
691
+ }
692
+ else {
693
+ echo 'KO';
694
+ }
695
+ }
696
+ }
697
+ catch (Exception $exception) {
698
+ echo $this->__($exception->getMessage());
699
+ }
700
+ }
701
+
702
+ public function ajaxordershippedAction($sender='', $message='', $number='')
703
+ {
704
+ $postData = $this->getRequest()->getPost();
705
+ try {
706
+ if (empty($postData)) {
707
+ Mage::throwException($this->__('Invalid form data.'));
708
+ }
709
+
710
+ $number = $postData['number'];
711
+ $charone = substr($number, 0, 1);
712
+ $chartwo = substr($number, 0, 2);
713
+
714
+ if ($charone == '0' && $chartwo == '00') {
715
+ $number = $number;
716
+ }
717
+
718
+ if (isset($number)) {
719
+ $adminUserModel = Mage::getModel('admin/user');
720
+ $userCollection = $adminUserModel->getCollection()->load();
721
+ $adminData = $userCollection->getData();
722
+ $firstname = isset($adminData[0]['firstname'])?$adminData[0]['firstname']:'';
723
+ $lastname = isset($adminData[0]['lastname'])?$adminData[0]['lastname']:'';
724
+ $characters = '1234567890';
725
+ $referenceNumber = '';
726
+ for ($i = 0; $i < 9; $i++) {
727
+ $referenceNumber .= $characters[rand(0, strlen($characters) - 1)];
728
+ }
729
+
730
+ $localeCode = Mage::app()->getLocale()->getLocaleCode();
731
+ $orderDateFormat = ($localeCode == 'fr_FR') ? date('d/m/Y') : date('m/d/Y') ;
732
+
733
+ $orderprice = rand(10, 1000);
734
+ $totalPay = $orderprice.'.00'.' '.Mage::app()->getStore()-> getCurrentCurrencyCode();
735
+ $msgbody = $postData['message'];
736
+ $firstName = str_replace('{first_name}', $firstname, $msgbody);
737
+ $lastName = str_replace('{last_name}', $lastname."\r\n", $firstName);
738
+ $procuctPrice = str_replace('{order_price}', $totalPay, $lastName);
739
+ $orderDate = str_replace('{order_date}', $orderDateFormat."\r\n", $procuctPrice);
740
+ $msgbody = str_replace('{order_reference}', $referenceNumber, $orderDate);
741
+ $smsData = array();
742
+ $smsData['to'] = $number;
743
+ $smsData['from'] = !empty($postData['sender'])?$postData['sender']:'';
744
+ $smsData['text'] = $msgbody;
745
+
746
+ $sendSmsResponce = Mage::getModel('sendinblue/sendinblue')->sendSmsApi($smsData);
747
+ if (isset($sendSmsResponce['status']) && $sendSmsResponce['status'] == 'OK') {
748
+ echo 'OK';
749
+ }
750
+ else {
751
+ echo 'KO';
752
+ }
753
+ exit;
754
+ }
755
+
756
+ }
757
+ catch (Exception $exception) {
758
+ echo $this->__($exception->getMessage());
759
+ }
760
+ }
761
+
762
+ public function ajaxsmscampaignAction($sender='', $message='', $number='')
763
+ {
764
+ $postData = $this->getRequest()->getPost();
765
+ try {
766
+ if (empty($postData)) {
767
+ Mage::throwException($this->__('Invalid form data.'));
768
+ }
769
+ $number = $postData['number'];
770
+ $charone = substr($number, 0, 1);
771
+ $chartwo = substr($number, 0, 2);
772
+ if ($charone == '0' && $chartwo == '00') {
773
+ $number = $number;
774
+ }
775
+ if (isset($number)) {
776
+ $adminUserModel = Mage::getModel('admin/user');
777
+ $userCollection = $adminUserModel->getCollection()->load();
778
+ $adminData = $userCollection->getData();
779
+ $firstname = isset($adminData[0]['firstname'])?$adminData[0]['firstname']:'';
780
+ $lastname = isset($adminData[0]['lastname'])?$adminData[0]['lastname']:'';
781
+ $msgbody = $postData['message'];
782
+ $firstName = str_replace('{first_name}', $firstname, $msgbody);
783
+ $msgbody = str_replace('{last_name}', $lastname."\r\n", $firstName);
784
+ $smsData = array();
785
+ $smsData['to'] = $number;
786
+ $smsData['from'] = !empty($postData['sender'])?$postData['sender']:'';
787
+ $smsData['text'] = $msgbody;
788
+ $sendSmsResponce = Mage::getModel('sendinblue/sendinblue')->sendSmsApi($smsData);
789
+ if (isset($sendSmsResponce['status']) && $sendSmsResponce['status'] == 'OK') {
790
+ echo 'OK';
791
+ }
792
+ else {
793
+ echo 'KO';
794
+ }
795
+ }
796
+ }
797
+ catch (Exception $exception) {
798
+ echo $this->__($exception->getMessage());
799
+ }
800
+ }
801
+ }
app/code/{local/Sendinblue/Sendinblue/controllers → community/Sendinblue/Sendinblue/controllers/Adminhtml}/IndexController.php RENAMED
@@ -10,9 +10,9 @@
10
 
11
  class Sendinblue_Sendinblue_IndexController extends Mage_Core_Controller_Front_Action
12
  {
13
- public function indexAction()
14
- {
15
- $this->loadLayout();
16
- $this->renderLayout();
17
- }
18
  }
10
 
11
  class Sendinblue_Sendinblue_IndexController extends Mage_Core_Controller_Front_Action
12
  {
13
+ public function indexAction()
14
+ {
15
+ $this->loadLayout();
16
+ $this->renderLayout();
17
+ }
18
  }
app/code/community/Sendinblue/Sendinblue/controllers/Adminhtml/MyformController.php ADDED
@@ -0,0 +1,652 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ $sendinModule = Mage::getModel('sendinblue/sendinblue');
20
+ $configDataObj = Mage::getModel('core/config_data')->getCollection()->addFieldToFilter('path', array('like' => '%sendinblue%'));
21
+ $sendinblueEnabledStatus = '';
22
+ $apiKey = '';
23
+ $getSyncronize = '';
24
+ $trackStatus = '';
25
+ $trackingHistory = '';
26
+ $notifySmsStatus = '';
27
+ $orderSmsStatus = '';
28
+ $campaignStatus = '';
29
+ $shipingSmsStatus = '';
30
+ $sendinSubscribeConfirmType = '';
31
+ $sendinTemplateId = '';
32
+ $sendinDoubleoptinTemplateId = '';
33
+ $sendinOptinRedirectUrlCheck = '';
34
+ $sendinDoubleoptinRedirectUrl = '';
35
+ $sendinFinalConfirmEmail = '';
36
+ $sendinTemplateFinal = '';
37
+ $formKey = '';
38
+ $moduleStatus = '';
39
+
40
+ foreach ($configDataObj as $configData) {
41
+ $sendinblueEnabled = $configData->getData();
42
+ if(count($sendinblueEnabled) > 0) {
43
+ if($sendinblueEnabled['path'] == 'sendinblue/enabled') {
44
+ $sendinblueEnabledStatus = $sendinblueEnabled['value'];
45
+ }
46
+ else if($sendinblueEnabled['path'] == 'sendinblue/api') {
47
+ $apiKey = $sendinblueEnabled['value'];
48
+ }
49
+ else if($sendinblueEnabled['path'] == 'sendinblue/syncronize') {
50
+ $getSyncronize = $sendinblueEnabled['value'];
51
+ }
52
+ else if($sendinblueEnabled['path'] == 'sendinblue/tracking/code') {
53
+ $trackStatus = $sendinblueEnabled['value'];
54
+ }
55
+ else if($sendinblueEnabled['path'] == 'sendinblue/improt/history') {
56
+ $trackingHistory = $sendinblueEnabled['value'];
57
+ }
58
+ else if($sendinblueEnabled['path'] == 'sendinblue/sms/credit') {
59
+ $notifySmsStatus = $sendinblueEnabled['value'];
60
+ }
61
+ else if($sendinblueEnabled['path'] == 'sendinblue/sms/order') {
62
+ $orderSmsStatus = $sendinblueEnabled['value'];
63
+ }
64
+ else if($sendinblueEnabled['path'] == 'sendinblue/sms/campaign') {
65
+ $campaignStatus = $sendinblueEnabled['value'];
66
+ }
67
+ else if($sendinblueEnabled['path'] == 'sendinblue/sms/shiping') {
68
+ $shipingSmsStatus = $sendinblueEnabled['value'];
69
+ }
70
+ else if($sendinblueEnabled['path'] == 'sendinblue/SendinSubscribeConfirmType') {
71
+ $sendinSubscribeConfirmType = $sendinblueEnabled['value'];
72
+ }
73
+ else if($sendinblueEnabled['path'] == 'sendinblue/SendinTemplateId') {
74
+ $sendinTemplateId = $sendinblueEnabled['value'];
75
+ }
76
+ else if($sendinblueEnabled['path'] == 'sendinblue/SendinDoubleoptinTemplateId') {
77
+ $sendinDoubleoptinTemplateId = $sendinblueEnabled['value'];
78
+ }
79
+ else if($sendinblueEnabled['path'] == 'sendinblue/SendinOptinRedirectUrlCheck') {
80
+ $sendinOptinRedirectUrlCheck = $sendinblueEnabled['value'];
81
+ }
82
+ else if($sendinblueEnabled['path'] == 'sendinblue/SendinDoubleoptinRedirectUrl') {
83
+ $sendinDoubleoptinRedirectUrl = $sendinblueEnabled['value'];
84
+ }
85
+ else if($sendinblueEnabled['path'] == 'sendinblue/SendinFinalConfirmEmail') {
86
+ $sendinFinalConfirmEmail = $sendinblueEnabled['value'];
87
+ }
88
+ else if($sendinblueEnabled['path'] == 'sendinblue/SendinTemplateFinal') {
89
+ $sendinTemplateFinal = $sendinblueEnabled['value'];
90
+ }
91
+ else if($sendinblueEnabled['path'] == 'sendinblue/smtp/status') {
92
+ $moduleStatus = $sendinblueEnabled['value'];
93
+ }
94
+ }
95
+ }
96
+
97
+ $list = $sendinModule->lists();
98
+ $selectedlist = $sendinModule->getUserlists();
99
+ $templatelist = $sendinModule->templateDisplay();
100
+ $importOldSubsStatus = $sendinModule->getImportOldSubsStatus();
101
+ $credit = $sendinModule->getSmsCredit();
102
+ $notifyEmailStatus = $sendinModule->getNotifyEmailStatus();
103
+ $notifyValueStatus = $sendinModule->getNotifyValueStatus();
104
+ $sendSmsOrderSubject = $sendinModule->getSendSmsOrderSubject();
105
+ $sendSmsmOrderMessage = $sendinModule->getSendSmsmOrderMessage();
106
+ $sendSmsShipingSubject = $sendinModule->getSendSmsShipingSubject();
107
+ $sendSmsShipingMessage = $sendinModule->getSendSmsShipingMessage();
108
+ $newsletterSubscribeCount = $sendinModule->getNewsletterSubscribeCount();
109
+ $newsletterUnSubscribeCount = $sendinModule->getNewsletterUnSubscribeCount();
110
+ $formKey = Mage::getSingleton('core/session')->getFormKey();
111
+ $viewData = array(
112
+ "formKey" => $formKey,
113
+ "sendinStatus" => $sendinblueEnabledStatus,
114
+ "apiKey" => $apiKey,
115
+ "getSyncronize" => $getSyncronize,
116
+ "trackStatus" => $trackStatus,
117
+ "trackingHistory" => $trackingHistory,
118
+ "notifySmsStatus" => $notifySmsStatus,
119
+ "orderSmsStatus" => $orderSmsStatus,
120
+ "campaignStatus" => $campaignStatus,
121
+ "shipingSmsStatus" => $shipingSmsStatus,
122
+ "list" => $list,
123
+ "selectedlist" => $selectedlist,
124
+ "templatelist" => $templatelist,
125
+ "importOldSubsStatus" => $importOldSubsStatus,
126
+ "moduleStatus" => $moduleStatus,
127
+ "credit" => $credit,
128
+ "notify_value" => $notifyValue,
129
+ "notifyEmailStatus" => $notifyEmailStatus,
130
+ "notifyValueStatus" => $notifyValueStatus,
131
+ "sendSmsOrderSubject" => $sendSmsOrderSubject,
132
+ "sendSmsmOrderMessage" => $sendSmsmOrderMessage,
133
+ "sendSmsShipingSubject" => $sendSmsShipingSubject,
134
+ "sendSmsShipingMessage" => $sendSmsShipingMessage,
135
+ "newsletterSubscribeCount" => $newsletterSubscribeCount,
136
+ "newsletterUnSubscribeCount" => $newsletterUnSubscribeCount,
137
+ "sendinSubscribeConfirmType" => $sendinSubscribeConfirmType,
138
+ "sendinTemplateId" => $sendinTemplateId,
139
+ "sendinDoubleoptinTemplateId" => $sendinDoubleoptinTemplateId,
140
+ "sendinOptinRedirectUrlCheck" => $sendinOptinRedirectUrlCheck,
141
+ "sendinDoubleoptinRedirectUrl" => $sendinDoubleoptinRedirectUrl,
142
+ "sendinFinalConfirmEmail" => $sendinFinalConfirmEmail,
143
+ "sendinTemplateFinal" => $sendinTemplateFinal
144
+ );
145
+ Mage::register('viewData', $viewData);
146
+ $this->loadLayout();
147
+ $this->renderLayout();
148
+ }
149
+
150
+ public function syncronizepostAction()
151
+ {
152
+ $requestParameter = $this->getRequest()->getPost();
153
+ try {
154
+ if (empty($requestParameter)){
155
+ Mage::throwException($this->__('Invalid form data.'));
156
+ }
157
+ $sendinSwitch = Mage::getModel('core/config');
158
+
159
+ if (isset($requestParameter['syncronizeSubmit'])) {
160
+ $sendinSwitch->saveConfig('sendinblue/syncronize', $requestParameter['syncronize']);
161
+ if (!empty($requestParameter['subscribe_confirm_type'])) {
162
+ $sendinSwitch->saveConfig('sendinblue/SendinSubscribeConfirmType', $requestParameter['subscribe_confirm_type']);
163
+ $sendinSwitch->saveConfig('sendinblue/SendinTemplateId', $requestParameter['template_simple']);
164
+ $sendinSwitch->saveConfig('sendinblue/SendinOptinRedirectUrlCheck', $requestParameter['optin_redirect_url_check']);
165
+ $sendinSwitch->saveConfig('sendinblue/SendinDoubleoptinRedirectUrl', $requestParameter['doubleoptin-redirect-url']);
166
+ $sendinSwitch->saveConfig('sendinblue/SendinDoubleoptinTemplateId', $requestParameter['doubleoptin_template_id']);
167
+ $sendinSwitch->saveConfig('sendinblue/SendinFinalConfirmEmail', $requestParameter['final_confirm_email']);
168
+ $sendinSwitch->saveConfig('sendinblue/SendinTemplateFinal', $requestParameter['template_final']);
169
+ $sendinModule = Mage::getModel('sendinblue/sendinblue');
170
+ if ($requestParameter['subscribe_confirm_type'] === 'doubleoptin') {
171
+ $responseDoubleOption = $sendinModule->checkFolderListDoubleoptin();
172
+ if (!empty($responseDoubleOption['optin_id'])) {
173
+ $sendinSwitch->saveConfig('sendinblue/SendinOptinListId', $responseDoubleOption['optin_id']);
174
+ }
175
+ if ($responseDoubleOption === false) {
176
+ $optinId = $sendinModule->createListIdDoubleoptin();
177
+ $sendinSwitch->saveConfig('sendinblue/SendinOptinListId', $optinId);
178
+ }
179
+ }
180
+ $message = $this->__('Your setting has been successfully saved, please clean your cache.');
181
+ }
182
+
183
+ if (!empty($requestParameter['sendin_list'])) {
184
+ $list = implode('|', $requestParameter['sendin_list']);
185
+ $sendinSwitch->saveConfig('sendinblue/list', $list);
186
+ $message = $this->__('Your setting has been successfully saved, please clean your cache.');
187
+ Mage::getModel('adminhtml/session')->addSuccess($message);
188
+ }
189
+ else {
190
+ $message = $this->__('Please select a list');
191
+ Mage::getModel('adminhtml/session')->addError($message);
192
+ }
193
+ }
194
+ }
195
+ catch (Exception $exception) {
196
+ Mage::getModel('adminhtml/session')->addError($exception->getMessage());
197
+ }
198
+ $this->_redirect('*/*');
199
+ }
200
+
201
+ public function reimportpostAction()
202
+ {
203
+ $requestParameter = $this->getRequest()->getPost();
204
+ try {
205
+ if (empty($requestParameter)){
206
+ Mage::throwException($this->__('Invalid form data.'));
207
+ }
208
+ $sendinModule = Mage::getModel('sendinblue/sendinblue');
209
+ $sendinSwitch = Mage::getModel('core/config');
210
+ if (!empty($requestParameter['importoldSubmit'])) {
211
+ $list = $sendinModule->getUserlists();
212
+ $listId = str_replace('|', ',', $list);
213
+ $allemail = $sendinModule->getcustomers();
214
+ if ($allemail > 0) {
215
+ $userData = array();
216
+ $userData['url'] = Mage::getBaseUrl('media').'sendinblue_csv/ImportSubUsersToSendinblue.csv';
217
+ $userData['listids'] = $listId;
218
+ $userData['notify_url'] = Mage::getBaseUrl().'sendinblue/ajax/emptySubsUserToSendinblue';
219
+ $apiDetails['api_key'] = $sendinModule->getApiKey();
220
+ $psmailinObj = Mage::getModel('sendinblue/psmailin',$apiDetails);
221
+ $responseImportUser = $psmailinObj->importUsers($userData);
222
+ $sendinSwitch->saveConfig('sendinblue/importOldUserStatus', 0);
223
+ if (empty($responseImportUser['data']['process_id'])) {
224
+ $sendinSwitch->saveConfig('sendinblue/importOldUserStatus', 1);
225
+ $message = $this->__('Old subscribers not imported successfully, please click on Import Old Subscribers button to import them again');
226
+ Mage::getModel('adminhtml/session')->addError($message);
227
+ }
228
+ else {
229
+ $message = $this->__('Your setting has been successfully saved');
230
+ Mage::getModel('adminhtml/session')->addSuccess($message);
231
+ }
232
+ }
233
+ }
234
+ }
235
+ catch (Exception $exception) {
236
+ Mage::getModel('adminhtml/session')->addError($exception->getMessage());
237
+ }
238
+ $this->_redirect('*/*');
239
+ }
240
+
241
+ public function apikeypostAction()
242
+ {
243
+ $requestParameter = $this->getRequest()->getPost();
244
+ $sendinModule = Mage::getModel('sendinblue/sendinblue');
245
+ try {
246
+ if (empty($requestParameter)) {
247
+ Mage::throwException($this->__('Invalid form data.'));
248
+ }
249
+ else if (!empty($requestParameter['sendin_apikey'])) {
250
+ $sendinSwitch = Mage::getModel('core/config');
251
+ $apiKeyStatus = $sendinModule->checkApikey($requestParameter['sendin_apikey']);
252
+ if (empty($apiKeyStatus['error'])) {
253
+ $getKey = $sendinModule->getApiKey();
254
+ if ($getKey == '' || $getKey != $requestParameter['sendin_apikey']) {
255
+ $sendinModule->createFolderName($requestParameter['sendin_apikey']);
256
+ }
257
+
258
+ $sendinSwitch->saveConfig('sendinblue/api', trim($requestParameter['sendin_apikey']));
259
+ $sendinSwitch->saveConfig('sendinblue/enabled', $requestParameter['sendin_api_status']);
260
+ $sendinSwitch->saveConfig('sendinblue/Sendin_Notify_Cron_Executed', 0, 'default', 0);
261
+ $sendinSwitch->saveConfig('sendinblue/syncronize', 1);
262
+ $sendinModule->removeOldEntry();
263
+ if($sendinModule->getImportOldSubsStatus() == 1) {
264
+ $message = $this->__('Old subscribers not imported successfully, please click on Import Old Subscribers button to import them again and clean your cache.');
265
+ Mage::getModel('core/session')->addError($message);
266
+ }
267
+ else {
268
+ $message = $this->__('Your setting has been successfully saved, please clean your cache.');
269
+ Mage::getModel('adminhtml/session')->addSuccess($message);
270
+ }
271
+
272
+ }
273
+ else if (isset($apiKeyStatus['error'])) {
274
+ $message = $this->__('You have entered wrong api key');
275
+ Mage::getModel('core/session')->addError($message);
276
+ }
277
+ }
278
+ }
279
+ catch (Exception $exception) {
280
+ Mage::getModel('adminhtml/session')->addError($exception->getMessage());
281
+ }
282
+ $this->_redirect('*/*');
283
+ }
284
+
285
+ public function sendmailAction()
286
+ {
287
+ $requestParameter = $this->getRequest()->getPost();
288
+ $sendinModule = Mage::getModel('sendinblue/sendinblue');
289
+ try {
290
+ if (empty($requestParameter)) {
291
+ Mage::throwException($this->__('Invalid form data.'));
292
+ }
293
+ else if (!empty($requestParameter['SmtpSubmit'])) {
294
+ $sendinSwitch = Mage::getModel('core/config');
295
+ $getKey = $sendinModule->getApiKey();
296
+ $apiKeyStatus = $sendinModule->checkApikey($getKey);
297
+ if (empty($apiKeyStatus['error'])) {
298
+ $smtpResponse = $sendinModule->trackingSmtp(); // get tracking code
299
+ if (isset($smtpResponse['data']['relay_data']['status']) && $smtpResponse['data']['relay_data']['status'] == 'enabled') {
300
+ $sendinSwitch->saveConfig('sendinblue/smtp/authentication', 'crammd5', 'default', 0);
301
+ $sendinSwitch->saveConfig('sendinblue/smtp/username', $smtpResponse['data']['relay_data']['data']['username'], 'default', 0);
302
+ $sendinSwitch->saveConfig('sendinblue/smtp/password', $smtpResponse['data']['relay_data']['data']['password'], 'default', 0);
303
+ $sendinSwitch->saveConfig('sendinblue/smtp/host', $smtpResponse['data']['relay_data']['data']['relay'], 'default', 0);
304
+ $sendinSwitch->saveConfig('sendinblue/smtp/port', $smtpResponse['data']['relay_data']['data']['port'], 'default', 0);
305
+ $sendinSwitch->saveConfig('sendinblue/smtp/ssl', 'null', 'default', 0);
306
+ $sendinSwitch->saveConfig('sendinblue/smtp/option', 'smtp', 'default', 0);
307
+ if ($requestParameter['email']) {
308
+ $responceSendTestMail = $sendinModule->sendTestMail($requestParameter['email']);
309
+ $responceSendTestData = json_decode($responceSendTestMail, true);
310
+
311
+ if ($responceSendTestData['result'] != true) {
312
+ $message = $this->__('Mail not sent').' '.$this->__(trim($responceSendTestData['error']));
313
+ Mage::getModel('adminhtml/session')->addError($message);
314
+ }
315
+ else {
316
+ $message = $this->__('Mail sent!');
317
+ Mage::getModel('core/session')->addSuccess($message);
318
+ }
319
+ }
320
+ else {
321
+ $message = $this->__('Mail not sent');
322
+ Mage::getModel('adminhtml/session')->addError($message);
323
+ }
324
+ }
325
+ else {
326
+ $sendinSwitch->saveConfig('sendinblue/smtp/status', 0);
327
+ $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');
328
+ Mage::getModel('adminhtml/session')->addError($message);
329
+ }
330
+ }
331
+ elseif (isset($apiKeyStatus['error'])) {
332
+ $message = $this->__('You have entered wrong api key');
333
+ Mage::getModel('core/session')->addError($message);
334
+ }
335
+ }
336
+ }
337
+ catch (Exception $exception) {
338
+ Mage::getModel('adminhtml/session')->addError($exception->getMessage());
339
+ }
340
+ $this->_redirect('*/*');
341
+ }
342
+
343
+ public function sendorderAction()
344
+ {
345
+ $requestParameter = $this->getRequest()->getPost();
346
+ try {
347
+ if (empty($requestParameter)){
348
+ Mage::throwException($this->__('Invalid form data.'));
349
+ }
350
+ $sendinSwitch = Mage::getModel('core/config');
351
+ if (isset($requestParameter['sender_order_save'])) {
352
+ $senderOrder = isset($requestParameter['sender_order']) ? $requestParameter['sender_order'] : NULL;
353
+ $senderOrderMessage = $requestParameter['sender_order_message'];
354
+
355
+ if ($senderOrder == '') {
356
+ $message = $this->__('Please fill the message field');
357
+ Mage::getModel('adminhtml/session')->addError($message);
358
+ }
359
+ else if ($senderOrderMessage == '') {
360
+ $message = $this->__('Please fill the message field');
361
+ Mage::getModel('adminhtml/session')->addError($message);
362
+ }
363
+ else {
364
+ $sendinSwitch->saveConfig('sendinblue/Sendin_Sender_Order', $senderOrder);
365
+ $sendinSwitch->saveConfig('sendinblue/Sendin_Sender_Order_Message', $senderOrderMessage);
366
+ $message = $this->__('Your setting has been successfully saved, please clean your cache');
367
+ Mage::getModel('adminhtml/session')->addSuccess($message);
368
+ }
369
+ }
370
+ }
371
+ catch (Exception $exception) {
372
+ Mage::getModel('adminhtml/session')->addError($exception->getMessage());
373
+ }
374
+ $this->_redirect('*/*');
375
+ }
376
+
377
+ public function sendshipmentAction()
378
+ {
379
+ $requestParameter = $this->getRequest()->getPost();
380
+ try {
381
+ if (empty($requestParameter)) {
382
+ Mage::throwException($this->__('Invalid form data.'));
383
+ }
384
+ $sendinSwitch = Mage::getModel('core/config');
385
+ if (isset($requestParameter['sender_shipment_save'])) {
386
+ $senderShipment = isset($requestParameter['sender_shipment']) ? $requestParameter['sender_shipment'] : NULL;
387
+ $senderShipmentMessage = $requestParameter['sender_shipment_message'];
388
+
389
+ if ($senderShipment == '') {
390
+ $message = $this->__('Please fill the sender field');
391
+ Mage::getModel('adminhtml/session')->addError($message);
392
+ }
393
+ else if ($senderShipmentMessage == '') {
394
+ $message = $this->__('Please fill the message field');
395
+ Mage::getModel('adminhtml/session')->addError($message);
396
+ }
397
+ else {
398
+ $sendinSwitch->saveConfig('sendinblue/Sendin_Sender_Shipment', $senderShipment);
399
+ $sendinSwitch->saveConfig('sendinblue/Sendin_Sender_Shipment_Message', $senderShipmentMessage);
400
+ $message = $this->__('Your setting has been successfully saved, please clean your cache');
401
+ Mage::getModel('adminhtml/session')->addSuccess($message);
402
+ }
403
+ }
404
+ }
405
+ catch (Exception $exception) {
406
+ Mage::getModel('adminhtml/session')->addError($exception->getMessage());
407
+ }
408
+ $this->_redirect('*/*');
409
+ }
410
+
411
+ /**
412
+ * This method is called when the user test Shipment Sms and hits the submit button.
413
+ */
414
+
415
+ public function sendordertestAction()
416
+ {
417
+ $sendinModule = Mage::getModel('sendinblue/sendinblue');
418
+ $requestParameter = $this->getRequest()->getPost();
419
+ try {
420
+ if (empty($requestParameter)) {
421
+ Mage::throwException($this->__('Invalid form data.'));
422
+ }
423
+ $sendinSwitch = Mage::getModel('core/config');
424
+
425
+ if (isset($requestParameter['sender_order_submit'])) {
426
+ $smsData = array();
427
+ $smsData['to'] = $requestParameter['sender_order_number'];
428
+ $smsData['from'] = $sendinModule->getSendSmsOrderSubject();
429
+ $smsData['text'] = $sendinModule->getSendSmsmOrderMessage();
430
+
431
+ $sendSmsResponce = $sendinModule->sendSmsApi($smsData);
432
+ if (isset($sendSmsResponce['status']) && $sendSmsResponce['status'] == 'OK') {
433
+ $message = $this->__('Message has been sent successfully');
434
+ Mage::getModel('adminhtml/session')->addSuccess($message);
435
+ }
436
+ else {
437
+ $message = $this->__('Message has not been sent successfully');
438
+ Mage::getModel('adminhtml/session')->addError($message);
439
+ }
440
+ }
441
+ }
442
+ catch (Exception $exception) {
443
+ Mage::getModel('adminhtml/session')->addError($exception->getMessage());
444
+ }
445
+ $this->_redirect('*/*');
446
+ }
447
+
448
+ /**
449
+ * This method is called when the user test Shipment Sms and hits the submit button.
450
+ */
451
+
452
+ public function sendshipmenttestAction()
453
+ {
454
+ $sendinModule = Mage::getModel('sendinblue/sendinblue');
455
+ $requestParameter = $this->getRequest()->getPost();
456
+ try {
457
+ if (empty($requestParameter)) {
458
+ Mage::throwException($this->__('Invalid form data.'));
459
+ }
460
+ $sendinSwitch = Mage::getModel('core/config');
461
+
462
+ if (isset($requestParameter['sender_shipment_submit'])) {
463
+ $smsData = array();
464
+ $smsData['to'] = $requestParameter['sender_shipment_number'];
465
+ $smsData['from'] = $sendinModule->getSendSmsShipingSubject();
466
+ $smsData['text'] = $sendinModule->getSendSmsShipingMessage();
467
+
468
+ $sendSmsResponce = $sendinModule->sendSmsApi($smsData);
469
+
470
+ if (isset($sendSmsResponce['status']) && $sendSmsResponce['status'] == 'OK') {
471
+ $message = $this->__('Message has been sent successfully');
472
+ Mage::getModel('adminhtml/session')->addSuccess($message);
473
+ }
474
+ else {
475
+ $message = $this->__('Message has not been sent successfully');
476
+ Mage::getModel('adminhtml/session')->addError($message);
477
+ }
478
+ }
479
+ }
480
+ catch (Exception $exception) {
481
+ Mage::getModel('adminhtml/session')->addError($exception->getMessage());
482
+ }
483
+ $this->_redirect('*/*');
484
+ }
485
+
486
+ public function sendnotifysmsAction()
487
+ {
488
+ $requestParameter = $this->getRequest()->getPost();
489
+ try {
490
+ if (empty($requestParameter)) {
491
+ Mage::throwException($this->__('Invalid form data.'));
492
+ }
493
+ $sendinSwitch = Mage::getModel('core/config');
494
+
495
+ if (isset($requestParameter['notify_sms_mail'])) {
496
+ $sendinSwitch->saveConfig('sendinblue/Sendin_Notify_Value', $requestParameter['sendin_notify_value']);
497
+ $sendinSwitch->saveConfig('sendinblue/Sendin_Notify_Email', $requestParameter['sendin_notify_email']);
498
+ $sendinSwitch->saveConfig('sendinblue/Sendin_Notify_Cron_Executed', 0, 'default', 0);
499
+ $message = $this->__('Your setting has been successfully saved');
500
+ Mage::getModel('adminhtml/session')->addSuccess($message);
501
+ }
502
+ }
503
+ catch (Exception $exception) {
504
+ Mage::getModel('adminhtml/session')->addError($exception->getMessage());
505
+ }
506
+ $this->_redirect('*/*');
507
+ }
508
+
509
+ public function sendcampaignAction()
510
+ {
511
+ $requestParameter = $this->getRequest()->getPost();
512
+ $sendinModule = Mage::getModel('sendinblue/sendinblue');
513
+ $apiDetails['api_key'] = $sendinModule->getApiKey();
514
+ $psmailinObj = Mage::getModel('sendinblue/psmailin',$apiDetails);
515
+
516
+ try {
517
+ if (empty($requestParameter)) {
518
+ Mage::throwException($this->__('Invalid form data.'));
519
+ }
520
+ $sendinSwitch = Mage::getModel('core/config');
521
+
522
+ if (isset($requestParameter['sender_campaign_save']) && $requestParameter['Sendin_Sms_Choice'] == 1) {
523
+ $smsData = array();
524
+ $smsData['to'] = $requestParameter['singlechoice'];
525
+ $smsData['from'] = $requestParameter['sender_campaign'];
526
+ $smsData['text'] = $requestParameter['sender_campaign_message'];
527
+
528
+ $sendSmsResponce = $sendinModule->sendSmsApi($smsData);
529
+ if (isset($sendSmsResponce['status']) && $sendSmsResponce['status'] == 'OK') {
530
+ $message = $this->__('Message has been sent successfully');
531
+ Mage::getModel('adminhtml/session')->addSuccess($message);
532
+ }
533
+ else {
534
+ $message = $this->__('Message has not been sent successfully');
535
+ Mage::getModel('adminhtml/session')->addError($message);
536
+ }
537
+ }
538
+ else if(isset($requestParameter['sender_campaign_save']) && $requestParameter['Sendin_Sms_Choice'] == 0) {
539
+ $smsCredit = $sendinModule->getSmsCredit();
540
+ $collection = Mage::getModel('customer/customer')
541
+ ->getCollection()
542
+ ->addAttributeToSelect('*')
543
+ ->joinAttribute('shipping_telephone', 'customer_address/telephone', 'default_shipping', null, 'left')
544
+ ->joinAttribute('shipping_country_code', 'customer_address/country_id', 'default_shipping', null, 'left');
545
+
546
+ $results = array();
547
+ foreach ($collection as $customer) {
548
+ $results[] = $customer->toArray();
549
+ }
550
+
551
+ foreach ($results as $i => $result) {
552
+ if(!empty($result['shipping_telephone']) && !empty($result['shipping_country_code'])) {
553
+ $countryCode = $sendinModule->getCountryCode($result['shipping_country_code']);
554
+ $number = $sendinModule->checkMobileNumber($result['shipping_telephone'],$countryCode);
555
+ $firstname = !empty($result['firstname']) ? $result['firstname'] : '';
556
+ $lastname = !empty($result['lastname']) ? $result['lastname'] : '';
557
+ $messageBody = !empty($requestParameter['sender_campaign_message'])?$requestParameter['sender_campaign_message']:'';
558
+ $fname = str_replace('{first_name}', $firstname, $messageBody);
559
+ $messageBody = str_replace('{last_name}', $lastname."\r\n", $fname);
560
+ $smsData = array();
561
+ $smsData['to'] = $number;
562
+ $smsData['from'] = !empty($requestParameter['sender_campaign'])?$requestParameter['sender_campaign']:'';
563
+ $smsData['text'] = $messageBody;
564
+ $sendinModule->sendSmsApi($smsData);
565
+ }
566
+ }
567
+
568
+ if ($smsCredit >= 1) {
569
+ $message = $this->__('Message has been sent successfully');
570
+ Mage::getModel('adminhtml/session')->addSuccess($message);
571
+ }
572
+ else {
573
+ $message = $this->__('Message has not been sent successfully');
574
+ Mage::getModel('adminhtml/session')->addError($message);
575
+ }
576
+ }
577
+ else if(isset($requestParameter['sender_campaign_save']) && $requestParameter['Sendin_Sms_Choice'] == 2) {
578
+ $smsCredit = $sendinModule->getSmsCredit();
579
+ $scheduleMonth = $requestParameter['sib_datetimepicker'];
580
+ $scheduleHour = $requestParameter['hour'];
581
+ $scheduleMinute = $requestParameter['minute'];
582
+ if ($scheduleHour < 10) {
583
+ $scheduleHour = '0'.$scheduleHour;
584
+ }
585
+ if ($scheduleMinute < 10) {
586
+ $scheduleMinute = '0'.$scheduleMinute;
587
+ }
588
+ $scheduleTime = $scheduleMonth.' '.$scheduleHour.':'.$scheduleMinute.':00';
589
+ $currentTime = date('Y-m-d H:i:s', time() + 300);
590
+ $currentTimeExact = strtotime($currentTime);
591
+ $scheduleTimeExact = strtotime($scheduleTime);
592
+
593
+ if ($scheduleTime != '' || $scheduleTimeExact >= $currentTimeExact)
594
+ {
595
+ $campaignName = 'SMS_'.date('Ymd');
596
+ $key = $sendinModule->getApiKey();
597
+ if ($key == '') {
598
+ return false;
599
+ }
600
+ $ListId = Mage::getStoreConfig('sendinblue/list');
601
+ $isoCode = $this->context->language->iso_code;
602
+ $allemail = $sendinModule->smsCampaignList();
603
+
604
+ $userData['attributes'] = $allemail;
605
+ $userData['listid'] = $ListId;
606
+ $psmailinObj->addMultipleUser($userData);
607
+
608
+ $messageBody = $requestParameter['sender_campaign_message'];
609
+ $langaugeValue = $sendinModule->getApiConfigValue();
610
+ if (isset($langaugeValue['data']['language']) && $langaugeValue['data']['language'] == 'fr') {
611
+ $firstname = '{NOM}';
612
+ $lastname = '{PRENOM}';
613
+ }
614
+ else {
615
+ $firstname = '{NAME}';
616
+ $lastname = '{SURNAME}';
617
+ }
618
+
619
+ $fname = str_replace('{first_name}', $firstname, $messageBody);
620
+ $messageBody = str_replace('{last_name}', $lastname."\r\n", $fname);
621
+ $smsCampaignData = array();
622
+ $smsCampaignData['name'] = $campaignName; // mandatory
623
+ $smsCampaignData['sender'] = $requestParameter['sender_campaign'];
624
+ $smsCampaignData['content'] = $messageBody;
625
+ $smsCampaignData['bat_sent'] = '';
626
+ $smsCampaignData['listid'] = array($ListId); // mandatory if SMS campaign is scheduled
627
+ $smsCampaignData['exclude_list'] = '';
628
+ $smsCampaignData['scheduled_date'] = $scheduleTime;
629
+ $campaignDataRespose = $psmailinObj->createSmsCampaign($smsCampaignData);
630
+
631
+ if ($smsCredit >= 1) {
632
+ $message = $this->__('Message has been sent successfully');
633
+ Mage::getModel('adminhtml/session')->addSuccess($message);
634
+ }
635
+ else {
636
+ $message = $this->__('Message has not been sent successfully');
637
+ Mage::getModel('adminhtml/session')->addError($message);
638
+ }
639
+ }
640
+ else {
641
+ $message = $this->__('Scheduled date may not be prior to the current date');
642
+ Mage::getModel('adminhtml/session')->addError($message);
643
+ }
644
+ }
645
+ }
646
+ catch (Exception $exception)
647
+ {
648
+ Mage::getModel('adminhtml/session')->addError($exception->getMessage());
649
+ }
650
+ $this->_redirect('*/*');
651
+ }
652
+ }
app/code/{local → community}/Sendinblue/Sendinblue/controllers/Adminhtml/NotifyController.php RENAMED
@@ -10,12 +10,11 @@
10
 
11
  class Sendinblue_Sendinblue_Adminhtml_NotifyController extends Mage_Adminhtml_Controller_Action
12
  {
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
  }
10
 
11
  class Sendinblue_Sendinblue_Adminhtml_NotifyController extends Mage_Adminhtml_Controller_Action
12
  {
13
+ public function indexAction()
14
+ {
15
+ $responce = Mage::getModel('sendinblue/sendinblue')->notifySmsEmail();
16
+ $messageDisplay = $this->__('The CRON has been well executed.');
17
+ Mage::getModel('adminhtml/session')->addSuccess($messageDisplay);
18
+ $this->_redirect("adminhtml/myform/");
19
+ }
 
20
  }
app/code/{local → community}/Sendinblue/Sendinblue/controllers/Adminhtml/SyncController.php RENAMED
@@ -10,12 +10,11 @@
10
 
11
  class Sendinblue_Sendinblue_Adminhtml_SyncController extends Mage_Adminhtml_Controller_Action
12
  {
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
  }
10
 
11
  class Sendinblue_Sendinblue_Adminhtml_SyncController extends Mage_Adminhtml_Controller_Action
12
  {
13
+ public function indexAction()
14
+ {
15
+ $responce = Mage::getModel('sendinblue/sendinblue')->syncData();
16
+ $messageDisplay = $this->__('The CRON has been well executed.');
17
+ Mage::getModel('adminhtml/session')->addSuccess($messageDisplay);
18
+ $this->_redirect("adminhtml/myform/");
19
+ }
 
20
  }
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.3.2</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>adminhtml/myform</action>
16
+ <sort_order>0</sort_order>
17
+ </mails>
18
+ </children>
19
+ </system>
20
+ </menu>
21
+ <translate></translate>
22
+ <events>
23
+ <!--use for delete customer (post) -->
24
+ <controller_action_postdispatch_adminhtml_customer_massDelete>
25
+ <observers>
26
+ <sendinblue_customer_massDelete>
27
+ <type>singleton</type>
28
+ <class>Sendinblue_Sendinblue_Model_Observer</class>
29
+ <method>adminCustomerDelete</method>
30
+ </sendinblue_customer_massDelete>
31
+ </observers>
32
+ </controller_action_postdispatch_adminhtml_customer_massDelete>
33
+
34
+ <!--use for delete newsletter subcriber (post) -->
35
+ <controller_action_postdispatch_adminhtml_newsletter_subscriber_massDelete>
36
+ <observers>
37
+ <sendinblue_newsletter_massDelete>
38
+ <type>singleton</type>
39
+ <class>Sendinblue_Sendinblue_Model_Observer</class>
40
+ <method>adminSubcriberDelete</method>
41
+ </sendinblue_newsletter_massDelete>
42
+ </observers>
43
+ </controller_action_postdispatch_adminhtml_newsletter_subscriber_massDelete>
44
+
45
+ <!--use for subscribe customer (subscribe customer for newsletter from admin) (post) -->
46
+ <controller_action_postdispatch_adminhtml_customer_massSubscribe>
47
+ <observers>
48
+ <sendinblue_customer_massSubscribe>
49
+ <type>singleton</type>
50
+ <class>Sendinblue_Sendinblue_Model_Observer</class>
51
+ <method>adminCustomerSubscribe</method>
52
+ </sendinblue_customer_massSubscribe>
53
+ </observers>
54
+ </controller_action_postdispatch_adminhtml_customer_massSubscribe>
55
+
56
+ <!--use for unsubscribe customer (post) -->
57
+ <controller_action_postdispatch_adminhtml_customer_massUnsubscribe>
58
+ <observers>
59
+ <sendinblue_customer_massUnsubscribe>
60
+ <type>singleton</type>
61
+ <class>Sendinblue_Sendinblue_Model_Observer</class>
62
+ <method>adminCustomerDelete</method>
63
+ </sendinblue_customer_massUnsubscribe>
64
+ </observers>
65
+ </controller_action_postdispatch_adminhtml_customer_massUnsubscribe>
66
+
67
+ <!--use for unsubscribe newsletter subscriber (post) -->
68
+ <controller_action_predispatch_adminhtml_newsletter_subscriber_massUnsubscribe>
69
+ <observers>
70
+ <sendinblue_newsletter_massUnsubscribe>
71
+ <type>singleton</type>
72
+ <class>Sendinblue_Sendinblue_Model_Observer</class>
73
+ <method>adminSubcriberDelete</method>
74
+ </sendinblue_newsletter_massUnsubscribe>
75
+ </observers>
76
+ </controller_action_predispatch_adminhtml_newsletter_subscriber_massUnsubscribe>
77
+
78
+
79
+ <sales_order_save_after>
80
+ <observers>
81
+ <sendinblue_update_data>
82
+ <type>singleton</type>
83
+ <class>Sendinblue_Sendinblue_Model_Observer</class>
84
+ <method>updateStatus</method>
85
+ </sendinblue_update_data>
86
+ </observers>
87
+ </sales_order_save_after>
88
+ </events>
89
+
90
+ <acl>
91
+ <resources>
92
+ <all>
93
+ <title>Allow Everything</title>
94
+ </all>
95
+ <admin>
96
+ <children>
97
+ <mails>
98
+ <children>
99
+ <mails>
100
+ <title>Sendinblue</title>
101
+ </mails>
102
+ </children>
103
+ </mails>
104
+ <system>
105
+ <children>
106
+ <config>
107
+ <children>
108
+ <sendinblue>
109
+ <title>Sendinblue</title>
110
+ </sendinblue>
111
+ </children>
112
+ </config>
113
+ </children>
114
+ </system>
115
+ </children>
116
+ <children>
117
+ <system>
118
+ <children>
119
+ <mails translate="title" module="sendinblue">
120
+ <title>Sendinblue Settings</title>
121
+ <sort_order>0</sort_order>
122
+ <action></action>
123
+ </mails>
124
+ </children>
125
+ </system>
126
+ </children>
127
+ </admin>
128
+ </resources>
129
+ </acl>
130
+
131
+ <translate>
132
+ <modules>
133
+ <Sendinblue_Sendinblue>
134
+ <files>
135
+ <default>Sendinblue.csv</default>
136
+ </files>
137
+ </Sendinblue_Sendinblue>
138
+ </modules>
139
+ </translate>
140
+
141
+
142
+ <layout>
143
+ <updates>
144
+ <sendinblue_sendinblue>
145
+ <file>sendinblue.xml</file>
146
+ </sendinblue_sendinblue>
147
+ </updates>
148
+ </layout>
149
+
150
+ </adminhtml>
151
+ <admin>
152
+ <routers>
153
+ <adminhtml>
154
+ <args>
155
+ <modules>
156
+ <sendinblue after="Mage_Adminhtml">Sendinblue_Sendinblue_Adminhtml</sendinblue>
157
+ <frontName>sendinblue</frontName>
158
+ </modules>
159
+ </args>
160
+ </adminhtml>
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
+ </global>
267
+
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
+
281
+ <default>
282
+ <sendinblue>
283
+ <general>
284
+ <enabled>0</enabled>
285
+ <test>0</test>
286
+ <test_address />
287
+ </general>
288
+ <smtp>
289
+ <host>sendinblue.fr</host>
290
+ <port />
291
+ <login />
292
+ <password />
293
+ <ssl />
294
+ </smtp>
295
+ </sendinblue>
296
+ </default>
297
+
298
+ <frontend>
299
+ <events>
300
+ <!--use when new subcriber add for newsletter-->
301
+ <controller_action_postdispatch_newsletter_subscriber_new>
302
+ <observers>
303
+ <sendinblue_subscribe_new_observer>
304
+ <type>singleton</type>
305
+ <class>Sendinblue_Sendinblue_Model_Observer</class>
306
+ <method>subscribeObserver</method>
307
+ </sendinblue_subscribe_new_observer>
308
+ </observers>
309
+ </controller_action_postdispatch_newsletter_subscriber_new>
310
+ <!--use when new user register check (is_subscribed = 1)-->
311
+ </events>
312
+
313
+ <layout>
314
+ <updates>
315
+ <sendinblue_sendinblue>
316
+ <file>sendinblue.xml</file>
317
+ </sendinblue_sendinblue>
318
+ </updates>
319
+ </layout>
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/Helper/Data.php DELETED
@@ -1,54 +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_Helper_Data extends Mage_Core_Helper_Abstract
12
- {
13
- public function getSMTP()
14
- {
15
- return Mage::getStoreConfig('sendinblue/smtp/option') == 'smtp';
16
- }
17
- public function getTransport()
18
- {
19
- if ($this->getSMTP())
20
- {
21
- $username = Mage::getStoreConfig('sendinblue/smtp/username');
22
- $password = Mage::getStoreConfig('sendinblue/smtp/password');
23
- $host = Mage::getStoreConfig('sendinblue/smtp/host');
24
- $port = Mage::getStoreConfig('sendinblue/smtp/port');
25
- $ssl = Mage::getStoreConfig('sendinblue/smtp/ssl');
26
- $auth = Mage::getStoreConfig('sendinblue/smtp/authentication');
27
- $config = array();
28
- $config['username'] = $username;
29
- $config['password'] = $password;
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
39
- {
40
- Mage::log('Disabled, or no matching transport');
41
- return null;
42
- }
43
- Mage::log('Returning transport');
44
- return $transport;
45
- }
46
- public function ModuleisEnabled()
47
- {
48
- return Mage::getStoreConfig('sendinblue/enabled');
49
- }
50
- public function isEnabled()
51
- {
52
- return Mage::getStoreConfig('sendinblue/smtp/status');
53
- }
54
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/local/Sendinblue/Sendinblue/Model/Email.php DELETED
@@ -1,36 +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_Model_Email extends Mage_Core_Model_Email {
12
- /**
13
- * override send function
14
- */
15
- public function send()
16
- {
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
- Mage::log('SendinblueSMTP is enabled, sending email in Sendinblue_Sendinblue_Model_Sendinblue');
21
- $mail = new Zend_Mail();
22
- if (strtolower($this->getType()) == 'html')
23
- $mail->setBodyHtml($this->getBody());
24
- else
25
- $mail->setBodyText($this->getBody());
26
- $transport = Mage::helper('sendinblue')->getTransport();
27
- $email = Mage::getStoreConfig('contacts/email/recipient_email');
28
- $mail->setFrom($this->getFromEmail(), $this->getFromName())
29
- ->addTo($email, $this->getToName())
30
- ->setSubject($this->getSubject());
31
- Mage::log('About to send email');
32
- $mail->send($transport);
33
- Mage::log('Finished sending email');
34
- return $this;
35
- }
36
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/local/Sendinblue/Sendinblue/Model/Email/Template.php DELETED
@@ -1,104 +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_Model_Email_Template extends Mage_Core_Model_Email_Template {
12
-
13
- public function send($email, $name=null, array $variables = array()) {
14
-
15
- // If it's not enabled, just return the parent result.
16
-
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
27
- return false;
28
- }
29
-
30
- $emails = array_values((array)$email);
31
- $names = is_array($name) ? $name : (array)$name;
32
- $names = array_values($names);
33
- foreach ($emails as $key => $email) {
34
- if (!isset($names[$key])) {
35
- $names[$key] = substr($email, 0, strpos($email, '@'));
36
- }
37
- }
38
-
39
- $variables['email'] = reset($emails);
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
-
64
- if($this->isPlain()) {
65
- $mail->setBodyText($text);
66
- } else {
67
- $mail->setBodyHTML($text);
68
- }
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 {
77
-
78
- // adding new Event dispatch in case anyone wants to interrogate an email before being sent
79
- // throwing an Exception in the Event Observer will prevent the mail being sent,
80
- // and will return false to the calling function
81
- Mage::dispatchEvent('sendin_email_after_send', array(
82
- 'mail' => $mail,
83
- 'template' => $this->getTemplateId(),
84
- 'subject' => $this->getProcessedTemplateSubject($variables),
85
- ));
86
-
87
- Mage::log('About to send email');
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
-
96
- Mage::logException($e);
97
- $responceArr = array('result'=>false, 'error'=>$e->getMessage());
98
- return json_encode($responceArr);
99
- }
100
- $responceArr = array('result'=>true);
101
- return json_encode($responceArr);
102
-
103
- }
104
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ <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
+ </adminhtml_myform_index>
 
 
 
 
 
 
 
 
12
  </layout>
app/design/adminhtml/default/default/template/sendinblue/myform.phtml CHANGED
@@ -8,272 +8,438 @@
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>
32
- <div style="clear: both;"></div>
33
- <p> <?php echo $this->__('Contact us:'); ?>
34
- <br><br>Email:<a href="mailto:<?php echo $this->__('contact@sendinblue.com'); ?>" style="color:#268CCD; text-decoration: none;">
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>
42
- <ul class="listt">
43
- <li>&nbsp;<?php echo $this->__('Synchronize your subscribers with SendinBlue (subscribed and unsubscribed contacts)'); ?></li>
44
- <li>&nbsp;<?php echo $this->__('Easily create good looking emailings'); ?></li>
45
- <li>&nbsp;<?php echo $this->__('Schedule your campaigns'); ?></li>
46
- <li>&nbsp;<?php echo $this->__('Track your results and optimize'); ?></li>
47
- <li>&nbsp;<?php echo $this->__('Monitor your transactional emails (purchase confirmation, password reset …) with a better deliverability and real-time analytics'); ?></li>
48
- </ul>
49
- <b><?php echo $this->__('Why should you use SendinBlue ?'); ?></b>
50
- <ul class="listt">
51
- <li>&nbsp;<?php echo $this->__('Optimized deliverability'); ?></li>
52
- <li>&nbsp;<?php echo $this->__('Unbeatable pricing &ndash; best value in the industry'); ?></li>
53
- <li>&nbsp;<?php echo $this->__('Technical support, by phone or by email'); ?></li>
54
- </ul>
55
- </div><div style="clear:both;">&nbsp;</div>
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>
94
-
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>
102
-
103
- <tr>
104
- <td>&nbsp;</td>
105
- <td class="a-left">
106
- <div class="btnmrgn-right">
107
- <input type="submit" class="btn" name="SmtpSubmit" onclick="return apikvalidate('<?php echo $this->__('Please enter your API key') ;?>');" value ="<?php echo $this->__('Update'); ?>" /></div>
108
- </td>
109
- </tr>
110
-
111
- </table>
112
- </fieldset>
113
- </div>
114
- </form>
115
- </div>
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{
145
- $list_array = array();
146
- }
 
147
 
148
  ?>
149
  <select multiple="multiple" name="sendin_list[]" id="select">
150
  <?php foreach($list as $value ){ ?>
151
- <option value="<?php echo $value['id']; ?>" <?php if(in_array($value['id'],$list_array)) echo 'selected = "selected"' ?> ><?php echo $value['name']; ?></option>
152
  <?php } ?>
153
  </select>
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">
161
  <div class="btnmrgn-right">
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>
168
  </table>
169
  </div>
170
- </td>
171
- </tr>
172
-
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>
212
-
213
- </table>
214
- </fieldset>
215
- </div>
216
- </form>
217
 
218
- </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
219
 
220
- <div class="sendin_row alldiv" <?php echo $style; ?> >
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>
238
- </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
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
 
246
  <tbody>
247
  <tr>
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. '); ?>
277
  <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>
278
  </p>
279
  </form>
@@ -289,23 +455,23 @@ $style_smtp = '';
289
  <li><a class="icon_accept" href="#tab2">
290
  <?php echo $this->__('Send a SMS confirmation for the shipment of the order'); ?></a></li>
291
  <li><a href="#tab3">
292
- <?php echo $this->__('Send a campaign SMS'); ?>
293
- </a></li>
294
  </ul>
295
  </div>
296
  <div id="tabs_content_container">
297
  <div id="tab1" class="tab_content" style="display: block;">
298
  <div class="wrapper" style="margin-top:15px;">
299
  <table width="100%" border="0" cellspacing="0" cellpadding="0" class="form-list3 ">
300
- <input name="order" type="hidden" id="order" value="<?php echo $this->getUrl('sendinblue/ajax/order'); ?>" />
301
  <tr>
302
  <td class="row1 fix_width2" >
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,26 +482,26 @@ $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">
323
  <label>
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 +522,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>
@@ -382,15 +548,15 @@ $style_smtp = '';
382
  <div id="tab2" class="tab_content">
383
  <div class="wrapper" style="margin-top:15px;">
384
  <table width="100%" border="0" cellspacing="0" cellpadding="0" class="form-list3">
385
- <input name="shiping" type="hidden" id="shiping" value="<?php echo $this->getUrl('sendinblue/ajax/shiping'); ?>" />
386
  <tr>
387
  <td class="row1 fix-width2">
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 +568,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 +583,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 +606,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">
@@ -466,103 +632,122 @@ $style_smtp = '';
466
  <div id="tab3" class="tab_content">
467
  <div class="wrapper" style="margin-top:15px;">
468
  <table width="100%" border="0" cellspacing="0" cellpadding="0" class="form-list3">
469
- <input name="campaign" type="hidden" id="campaign" value="<?php echo $this->getUrl('sendinblue/ajax/campaign'); ?>" />
470
  <tr>
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">
480
  <div class="form_table ">
481
 
482
- <table width="100%" border="0" cellspacing="0" cellpadding="0" >
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>
501
- <script>
502
- jQuery('#r1_Sendin_Sms_Choice').attr('checked', true);
503
- </script>
504
- <tr>
505
- <td><h4 style="margin-top:0;"><?php echo $this->__('SMS settings'); ?></h4></td>
506
- <td>&nbsp;</td>
507
- </tr>
508
-
 
 
 
 
 
509
 
510
- <tr class="singlechoice">
511
- <td valign="top"><label><?php echo $this->__('Phone number of the contact'); ?>
512
- </label></td>
513
- <td>
514
- <input name="singlechoice" id="singlechoice" maxlength="17" type="text" value="" class="input_bx" /><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>
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>
527
- </tr>
528
- <tr>
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>
536
- </div><br>
537
- <div class="hintmsg"><em><?php echo $this->__('If you want to personalize the SMS, you can use the variables below:'); ?></em></div>
538
- <div class="hintmsg"><em><?php echo $this->__('- For first name use {first_name}'); ?></em></div>
539
- <div class="hintmsg"><em><?php echo $this->__('- For last name use {last_name}'); ?></em></div>
540
- <input type="submit" class="button mrgn-right btn" value="<?php echo $this->__('Send the campaign'); ?>" name="sender_campaign_save" onclick="return senderCampaignSaveValid('<?php echo $this->__('Please fill the Sender field'); ?>','<?php echo $this->__('Please fill the Message field'); ?>','<?php echo $this->__('Please enter the valid Mobile Number'); ?>');"">
541
- </td>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
542
  </tr>
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>
@@ -573,45 +758,48 @@ $style_smtp = '';
573
  </table>
574
  </fieldset>
575
  </div>
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>
596
- <a href="javascript:void(0);" id="showUserlist" style="color: #000000; outline: 0 none; text-decoration: none;"><?php echo $this->__('click here'); ?></a></b>
597
- <br><br>
 
598
 
599
- <table cellspacing="0" id="userGrid_table " class="data userDetails" style='display:none;'>
600
- <thead>
601
- <tr class="headings">
602
- <th class="no-link"><span class="nobr"><?php echo $this->__('Email'); ?></span></th>
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'); ?>
34
+ </legend>
35
+ <div class="contact-details">
36
+ <h2 style="color:#268CCD;"> <?php echo $this->__('Contact SendinBlue team'); ?></h2>
37
+ <div style="clear: both;"></div>
38
+ <p> <?php echo $this->__('Contact us:'); ?>
39
+ <br><br>Email:<a href="mailto:<?php echo $this->__('contact@sendinblue.com'); ?>" style="color:#268CCD; text-decoration: none;">
40
+ <?php echo $this->__('contact@sendinblue.com'); ?></a>
41
+ <br><?php echo $this->__('Phone : 0899 25 30 61'); ?></p>
42
+ <p style="padding-top:20px;"><b><?php echo $this->__('For further informations, please visit our website:'); ?></b>
43
+ <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;">
44
+ <?php echo $this->__('https://www.sendinblue.com'); ?></a></p>
45
+ </div>
46
+ <div>
47
+ <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>
48
+ <ul class="listt">
49
+ <li>&nbsp;<?php echo $this->__('Synchronize your subscribers with SendinBlue (subscribed and unsubscribed contacts)'); ?></li>
50
+ <li>&nbsp;<?php echo $this->__('Easily create good looking emailings'); ?></li>
51
+ <li>&nbsp;<?php echo $this->__('Schedule your campaigns'); ?></li>
52
+ <li>&nbsp;<?php echo $this->__('Track your results and optimize'); ?></li>
53
+ <li>&nbsp;<?php echo $this->__('Monitor your transactional emails (purchase confirmation, password reset …) with a better deliverability and real-time analytics'); ?></li>
54
+ </ul>
55
+ <b><?php echo $this->__('Why should you use SendinBlue ?'); ?></b>
56
+ <ul class="listt">
57
+ <li>&nbsp;<?php echo $this->__('Optimized deliverability'); ?></li>
58
+ <li>&nbsp;<?php echo $this->__('Unbeatable pricing &ndash; best value in the industry'); ?></li>
59
+ <li>&nbsp;<?php echo $this->__('Technical support, by phone or by email'); ?></li>
60
+ </ul>
61
+ </div>
62
+ <div style="clear:both;">&nbsp;</div>
63
+ </fieldset>
64
+ </div>
65
+ <?php
66
+ $viewData = array();
67
+ $viewData = Mage::registry('viewData');
68
+ $sendinStatus = $viewData['sendinStatus'];
69
+ $moduleStatus = isset($sendinStatus) ? 1 : 0;
70
+ $style = ($moduleStatus) ? '' : 'style="display:none;"';
71
+ $apiKey = $viewData['apiKey'];
72
+ $getSyncronize = $viewData['getSyncronize'];
73
+ $trackStatus = $viewData['trackStatus'];
74
+ $trackingHistory = $viewData['trackingHistory'];
75
+ $notifySmsStatus = $viewData['notifySmsStatus'];
76
+ $orderSmsStatus = $viewData['orderSmsStatus'];
77
+ $campaignStatus = $viewData['campaignStatus'];
78
+ $shipingSmsStatus = $viewData['shipingSmsStatus'];
79
+ $formKey = $viewData['formKey'];
80
+ ?>
81
+ <div class="sendin_row">
82
+ <fieldset class="fields">
83
+ <legend class="lgend"><img src="<?php echo $skinUrl;?>adminhtml/default/default/sendinblue/images/logo.gif">
84
+ <?php echo $this->__('Prerequisites'); ?>
85
+ </legend>
86
+ <span><?php echo $this->__('- You should have a SendinBlue account. You can create a free account here:'); ?>
87
+ <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;">
88
+ &nbsp;<?php echo $this->__('https://www.sendinblue.com'); ?></a><br></span>
89
+ </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 $moduleStatus;?>">
106
+ </td>
107
+ </tr>
108
+
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 $apiKey; ?>" />
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/integration')); ?>">&nbsp;</span>
114
+ </td>
115
+ </tr>
116
+
117
+ <tr>
118
+ <td>&nbsp;</td>
119
+ <td class="a-left">
120
+ <div class="btnmrgn-right">
121
+ <input type="submit" class="btn" name="SmtpSubmit" onclick="return apikvalidate('<?php echo $this->__('Please enter your API key') ;?>');" value ="<?php echo $this->__('Update'); ?>" /></div>
122
+ </td>
123
+ </tr>
124
+ </table>
125
+ </fieldset>
126
+ </div>
127
+ </form>
128
+ </div>
129
+ <?php if ($apiKey != '') { ?>
130
+ <div class="sendin_row alldiv" <?php echo $style; ?> >
131
+ <form id="edit_form" name="edit_form" method="post" action="<?php echo $this->getUrl('*/*/syncronizepost'); ?>">
132
+ <div class="section-config active">
133
+ <input name="form_key" type="hidden" value="<?php echo $formKey; ?>" />
134
+ <fieldset id="my-fieldset" class="fields">
135
+ <legend class="lgend"><img src="<?php echo $skinUrl;?>adminhtml/default/default/sendinblue/images/logo.gif"> <?php echo $this->__('Activate SendinBlue to manage subscribers'); ?></legend>
136
+ <table cellspacing="0" class="form-list">
137
+ <tr>
138
+ <td class="fix_width"><label><?php echo $this->__('Activate SendinBlue to manage subscribers'); ?></label></td>
139
+ <td class="input-ele">
140
+ <input type="radio" <?php if($getSyncronize == 1) { echo "checked"; } ?> name="syncronize" value="1" class="radio_nospaceing hdtab"/> <?php echo $this->__('Yes'); ?>
141
+ <input type="radio" <?php if($getSyncronize == 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>
142
+ </td>
143
+ </tr>
144
+ <tr>
 
 
 
 
 
 
 
 
 
 
 
145
  <td colspan="2">
146
+ <div id="hidetabselect" <?php if(!$getSyncronize) {?>style="display:none;"<?php } ?>>
147
+ <table>
148
+ <tr>
149
+ <td><label><?php echo $this->__('Your Lists'); ?></label></td>
150
  <td class="input-ele"><?php
151
+ $list = $viewData['list'];
152
+ $selectedlist = $viewData['selectedlist'];
 
153
  if($selectedlist!=NULL){
154
  $list_array = explode('|',$selectedlist);
155
+ }
156
+ else{
157
+ $list_array = array();
158
+ }
159
 
160
  ?>
161
  <select multiple="multiple" name="sendin_list[]" id="select">
162
  <?php foreach($list as $value ){ ?>
163
+ <option value="<?php echo $value['id']; ?>" <?php if(in_array($value['id'],$list_array)) echo 'selected = "selected"' ?> ><?php echo $value['name']; ?></option>
164
  <?php } ?>
165
  </select>
166
  <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>
167
+ </td>
168
  </tr>
169
+ <!-- double optin functionality -->
170
  <tr>
171
+ <td></td>
172
+ <td>
173
+ <div class="col-md-6 left-wrapper radio_group_option">
174
+ <div class="form-group manage_subscribe_block">
175
+ <div>
176
+ <input type="radio" value="nocon" <?php if(isset($viewData['sendinSubscribeConfirmType']) && $viewData['sendinSubscribeConfirmType'] == 'nocon') echo 'checked="checked"'; ?> name="subscribe_confirm_type" id="no_follow_email">
177
+ <label for="no_follow_email" class="radio-label"> <?php echo $this->__('No confirmation'); ?></label>
178
+ </div>
179
+ <div class="clearfix"></div>
180
+ <div style="display:block;" class="inner_manage_box">
181
+ <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>
182
+ </div>
183
+ </div>
184
+ <div class="form-group manage_subscribe_block">
185
+ <div class="col-md-10">
186
+ <input type="radio" value="simplemail" <?php if(isset($viewData['sendinSubscribeConfirmType']) && $viewData['sendinSubscribeConfirmType'] == 'simplemail') echo 'checked="checked"'; ?> id="follow_mail" name="subscribe_confirm_type">
187
+ <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">
188
+ </span>
189
+ </div>
190
+ <div class="inner_manage_box">
191
+ <div class="clearfix"></div>
192
+ <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>
193
+ <div class="clearfix"></div>
194
+ <div id="mail-templates">
195
+ <div class="listData ver_5 managesubscribeBlock">
196
+ <select class="ui-state-default" name="template_simple"><option value=""><?php echo $this->__('Select Template'); ?></option>
197
+ <?php
198
+ $templatelist = $viewData['templatelist'];
199
+ if (!empty($templatelist['data']['campaign_records'])) {
200
+ foreach ($templatelist['data']['campaign_records'] as $template_data) {
201
+ if ($template_data['templ_status'] === 'Active' && stristr($template_data['html_content'], 'DOUBLEOPTIN') === false) { ?>
202
+
203
+ <option value="<?php echo $template_data['id']; ?>" <?php if(isset($viewData['sendinTemplateId']) && $template_data['id'] == $viewData['sendinTemplateId']) echo 'selected = "selected"'; ?> ><?php echo $template_data['campaign_name']; ?></option>
204
+ <?php
205
+ }
206
+ }
207
+ }
208
+ ?>
209
+ </select>
210
+ <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>
211
+ </div>
212
+ </div>
213
+ <div class="clearfix"></div>
214
+ <div id="mail-templates-active-state"></div>
215
+ </div>
216
+ <div class="clearfix"></div>
217
+ </div>
218
+ <div class="clearfix"></div>
219
+ <div class="form-group manage_subscribe_block">
220
+ <div class="col-md-10">
221
+ <input type="radio" value="doubleoptin" <?php if(isset($viewData['sendinSubscribeConfirmType']) && $viewData['sendinSubscribeConfirmType'] == 'doubleoptin') echo 'checked="checked"'; ?> id="double_optin" name="subscribe_confirm_type">
222
+ <label for="double_optin" class="radio-label"> <?php echo $this->__('Double opt-in confirmation'); ?></label>
223
+ <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">
224
+ </span>
225
+ </div>
226
+ <div class="inner_manage_box">
227
+ <div class="clearfix"></div>
228
+ <!-- Please select a template with the [DOUBLEOPTIN] link -->
229
+ <div id="create-doubleoptin-templates">
230
+ <p><?php echo $this->__('Once the form has been completed, your contact will receive an email with a link to confirm their subscription.'); ?></p>
231
+ <select class="ui-state-default" name="doubleoptin_template_id">
232
+ <option value=""><?php echo $this->__('Select Template'); ?></option>
233
+ <?php
234
+ $templatelist = $viewData['templatelist'];
235
+ if (!empty($templatelist['data']['campaign_records'])) {
236
+ foreach ($templatelist['data']['campaign_records'] as $template_data) {
237
+ if ($template_data['templ_status'] === 'Active' && stristr($template_data['html_content'], '[DOUBLEOPTIN]')) {
238
+ ?>
239
+ <option value="<?php echo $template_data['id']; ?>" <?php if(isset($viewData['sendinDoubleoptinTemplateId']) && $template_data['id'] == $viewData['sendinDoubleoptinTemplateId']) echo 'selected = "selected"'; ?> ><?php echo $template_data['campaign_name']; ?></option>
240
+ <?php
241
+ }
242
+ }
243
+ }
244
+ ?>
245
+ </select>
246
+ </div>
247
+ <!-- Redirect URL after click on the validation email -->
248
+ <div class="clearfix"></div>
249
+ <div id="doubleoptin-redirect-url-area" class="form-group clearfix">
250
+ <input type="checkbox" class="openCollapse" <?php if(isset($viewData['sendinOptinRedirectUrlCheck']) && $viewData['sendinOptinRedirectUrlCheck'] == 'yes') echo 'checked="checked"'; ?> value="yes" name="optin_redirect_url_check" id="doptin_redirect_span_icon">
251
+ <a href=""> <?php echo $this->__('Redirect URL after clicking in the validation email'); ?> </a>
252
+ <!-- <label style="margin-bottom: 5px;"></label> -->
253
+
254
+ <div id="mail-doubleoptin-redirect" class="collapse">
255
+ <p style="width: 90%;text-align: justify;text-justify: inter-word;">
256
+ <?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>
257
+ <input type="url" style="margin-bottom:10px;width:370px" value="<?php echo $viewData['sendinDoubleoptinRedirectUrl']; ?>" placeholder="http://your-domain.com" class="form-control" name="doubleoptin-redirect-url" id="doubleoptin-redirect-url">
258
+ <div class="clearfix"></div>
259
+ <div class="pull-left" id="doubleoptin-redirect-message"> </div>
260
+ <div class="clearfix"></div>
261
+ </div>
262
+ </div>
263
+
264
+ <!-- Send a final confirmation email -->
265
+ <div class="clearfix"></div>
266
+ <div id="doubleoptin-final-confirmation-area" class="form-group clearfix">
267
+ <input type="checkbox" class="openCollapse" <?php if(isset($viewData['sendinFinalConfirmEmail']) && $viewData['sendinFinalConfirmEmail'] == 'yes') echo 'checked="checked"'; ?> value="yes" name="final_confirm_email" id="doptin_final_confirm_email">
268
+ <a href="#doubleoptin-final-confirm"> <?php echo $this->__('Send a final confirmation email'); ?> </a>
269
+ <div id="doubleoptin-final-confirm" class="collapse">
270
+ <p><?php echo $this->__('Once a contact has clicked in the double opt-in confirmation email, send them a final confirmation email'); ?></p>
271
+ <div style="text-align: left;" class="listData ver_5 managesubscribeBlock">
272
+ <select class="ui-state-default" name="template_final">
273
+ <option value=""><?php echo $this->__('Select Template'); ?></option>
274
+ <?php
275
+ $templatelist = $viewData['templatelist'];
276
+ if (!empty($templatelist['data']['campaign_records'])) {
277
+ foreach ($templatelist['data']['campaign_records'] as $template_data) {
278
+ if ($template_data['templ_status'] === 'Active' && stristr($template_data['html_content'], 'DOUBLEOPTIN') === false) {
279
+ ?>
280
+ <option value="<?php echo $template_data['id']; ?>" <?php if(isset($viewData['sendinTemplateFinal']) && $template_data['id'] == $viewData['sendinTemplateFinal']) echo 'selected = "selected"'; ?> ><?php echo $template_data['campaign_name']; ?></option>
281
+ <?php
282
+ }
283
+ }
284
+ }
285
+ ?>
286
+ </select>
287
+ <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>
288
+ </div>
289
+ <div class="clearfix"></div>
290
+ <div class="pull-left" id="final-mail-templates"></div>
291
+ <div class="clearfix"></div>
292
+ </div>
293
+ <div id="doubleoptin-templates-active-state"> </div>
294
+ </div>
295
+ </div>
296
+ </div>
297
+ <div class="clearfix"></div>
298
+
299
+ </td>
300
+ </tr>
301
+ <tr>
302
  <td>&nbsp;</td>
303
  <td class="a-left">
304
  <div class="btnmrgn-right">
305
  <input type="submit" class="btn" name="syncronizeSubmit" value ="<?php echo $this->__('Update'); ?>" /></div>
306
  </td>
307
+ </tr>
308
+ </form>
309
+ <?php if(isset($viewData['importOldSubsStatus']) && $viewData['importOldSubsStatus'] == 1){ ?>
310
+ <form id="reimport_form" name="reimport_form" method="post" action="<?php echo $this->getUrl('*/*/reimportpost'); ?>">
311
+ <input name="form_key" type="hidden" value="<?php echo $formKey; ?>" />
312
+ <tr>
313
+ <td>&nbsp;</td>
314
+ <td class="a-left">
315
+ <div class="btnmrgn-right">
316
+ <input type="submit" class="btn" name="importoldSubmit" value ="<?php echo $this->__('Import Old Subscribers'); ?>" /></div>
317
+ </td>
318
+ </tr></form>
319
+ <?php } ?>
320
+ <tr><td colspan="2">
321
+ <?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("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>
322
  </td></tr>
323
  </table>
324
  </div>
325
+ </td>
326
+ </tr>
327
+ </table>
328
+ </fieldset>
329
+ </div>
330
+ </div>
331
+ <?php
332
+ }
 
 
 
 
 
 
 
333
 
334
+ $moduleStatus = $viewData['moduleStatus'];
335
+ $styleSmtp = ($moduleStatus == 0) ? 'style="display:none;"' : '' ;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
336
 
337
+ ?>
338
+ <?php if ($apiKey != '') { ?>
339
+ <div class="sendin_row alldiv" <?php echo $style; ?> >
340
+ <form id="edit_formsmtp" name="edit_form" method="post" action="<?php echo $this->getUrl('*/*/sendmail'); ?>">
341
+ <input name="form_key" type="hidden" value="<?php echo $formKey; ?>" />
342
+ <input name="smtpUrl" type="hidden" id="smtpUrl" value="<?php echo $this->getUrl('adminhtml/ajax/smtppost'); ?>" />
343
+ <div class="section-config active">
344
+ <fieldset class="fields">
345
+ <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>
346
+ <table cellspacing="0" class="form-list">
347
+
348
+ <tr>
349
+ <td class="fix_width"><label><?php echo $this->__('Activate SendinBlue SMTP for your transactional emails'); ?></label></td>
350
+ <td class="input-ele">
351
+ <input type="radio" class = 'smtpStatus radio_nospaceing' <?php if($moduleStatus == 1) { echo 'checked'; } ?> name="smtp" value="1" /> <?php echo $this->__('Yes'); ?>
352
+ <input <?php if($moduleStatus == 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>
353
+ </td>
354
+ <td>&nbsp;</td>
355
+ </tr>
356
+
357
+ <tr <?php echo $styleSmtp; ?> class='smtptest'>
358
+ <td class="fix_width"><label><?php echo $this->__('Send email test From / To :'); ?></label></td>
359
+ <td class="input-ele"><input class="input-text input-height" name="email" id="email" value="" size="40"/>
360
+ <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'); ?>" />
361
+ </td>
362
+ </tr>
363
+
364
+ </table>
365
+ </fieldset>
366
+ </div>
367
+ </form>
368
+ </div>
369
 
370
+ <div class="sendin_row alldiv" <?php echo $style; ?> >
371
+ <div class="section-config active">
372
+ <input name="trackingUrl" type="hidden" id="trackingUrl" value="<?php echo $this->getUrl('adminhtml/ajax/codepost'); ?>" />
373
+ <fieldset id="my-fieldset" class="fields">
374
+ <legend class="lgend"><img src="<?php echo $skinUrl;?>adminhtml/default/default/sendinblue/images/logo.gif"> <?php echo $this->__('Code tracking'); ?> </legend>
375
+ <table cellspacing="0" class="form-list">
376
+ <tr>
377
+ <td class="fix_width"><label><?php echo $this->__('Do you want to install a tracking code when validating an order'); ?></label>
378
+ </td>
379
+ <td class="input-ele">
380
+ <input type="radio" <?php if($trackStatus == 1) { echo 'checked'; } ?> name="Tracking" class='Tracking radio_nospaceing' value="1" /> <?php echo $this->__('Yes'); ?>
381
+ <input type="radio" <?php if($trackStatus == 0) { echo 'checked'; } ?> name="Tracking" class='Tracking radio_spaceing2' value="0" /> <?php echo $this->__('No'); ?>
382
+ <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>
383
+ </td>
384
+ </tr>
385
+ <?php
386
+ if ($trackStatus == 1 && $trackingHistory == 1)
387
+ $style_track = '';
388
+ else
389
+ $style_track = 'style="display:none;"';
390
+ if($trackStatus == 1 && $trackingHistory == 1) { ?>
391
+ <tr <?php echo $style_track; ?> class='ordertracking'>
392
+ <td>&nbsp;</td>
393
+ <input type="hidden" name="history_status" value="<?php echo $trackingHistory; ?>" id="history_status">
394
+ <input name="importordertrackingUrl" type="hidden" id="importordertrackingUrl" value="<?php echo $this->getUrl('adminhtml/ajax/orderhistory'); ?>" />
395
+ <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>
396
+ </tr>
397
+ <?php } ?>
398
+ </table>
399
+ </fieldset>
400
+ </div>
401
+ </div>
402
 
403
  <div class="sendin_row hidetableblock" <?php echo $style; ?> >
404
  <fieldset class="fields">
405
+ <legend class="lgend"><img src="<?php echo $skinUrl;?>adminhtml/default/default/sendinblue/images/logo.gif">
406
+ <?php echo $this->__('Manage SMS'); ?></legend>
407
  <table width="100%" cellspacing="0" cellpadding="0" class="table hidetableblock form-list">
408
 
409
  <tbody>
410
  <tr>
411
  <td class="row1" colspan="2" style="border:none; padding-top:10px;">
412
  <span style="margin-bottom:10px; color:#333333;">
413
+ <?php echo $this->__('Currently you have '); ?>
414
+ <?php
415
+ $credit = $viewData['credit'];
416
+ $notify_value = $viewData['notifyValueStatus'];
417
+ ?>
418
+ <?php if ($credit >= $notify_value){ ?> <strong style="color:#000000;"><?php echo $credit; ?></strong><?php } else {?><strong style="color:#F03D25;"><?php echo $credit; ?></strong><?php } ?>
419
+
420
+ <?php echo $this->__(' credits sms. To buy more credits, please click'); ?>
421
+ <a target="_blank" href ="<?php echo $this->__('https://www.sendinblue.com/pricing?utm_source=magento_plugin&utm_medium=plugin&utm_campaign=module_link/#tab-plan-smsplan'); ?>" style="color: #000000; outline: 0 none; text-decoration: none;">
422
+ <?php echo $this->__('here'); ?></a></span></td></tr>
423
  <tr>
424
  <td>
425
  <label>
426
+ <?php echo $this->__('You want to be notified by e-mail when you do not have enough credits?'); ?></label>
427
+ <input name="sms_credit" <?php if($notifySmsStatus == 1) { echo 'checked'; } ?> type="radio" value="1" class="sms_credit radio_nospaceing" style="margin-right:10px;" />
428
  <?php echo $this->__('Yes'); ?>
429
+ <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;" />
430
  <?php echo $this->__('No'); ?>
431
+ <input name="credit" type="hidden" id="credits" value="<?php echo $this->getUrl('adminhtml/ajax/credit'); ?>" />
432
  <div class="hideCredit" id="div_email_test" style="padding-top:20px;">
433
  <form action="<?php echo $this->getUrl('*/*/sendnotifysms'); ?>" method="POST" name="notify_sms_mail_form">
434
+ <input name="form_key" type="hidden" value="<?php echo $formKey; ?>" />
435
  <p class="form-data"><label><?php echo $this->__('Email'); ?></label>
436
+ <input name="sendin_notify_email" id="sendin_notify_email" type="text" class="input-text" value="<?php echo $viewData['notifyEmailStatus']; ?>" size="40" />
437
  </p>
438
  <p class="form-data"> <label><?php echo $this->__('Limit'); ?></label>
439
+ <input name="sendin_notify_value" id="sendin_notify_value" type="text" class="input-text" value="<?php echo $viewData['notifyValueStatus']; ?>" size="40" /><span class="toolTip" title="<?php echo $this->__('Alert threshold for remaining credits'); ?>">&nbsp;</span>
440
  </p>
441
  <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>
442
+ <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("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. '); ?>
443
  <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>
444
  </p>
445
  </form>
455
  <li><a class="icon_accept" href="#tab2">
456
  <?php echo $this->__('Send a SMS confirmation for the shipment of the order'); ?></a></li>
457
  <li><a href="#tab3">
458
+ <?php echo $this->__('Send a campaign SMS'); ?>
459
+ </a></li>
460
  </ul>
461
  </div>
462
  <div id="tabs_content_container">
463
  <div id="tab1" class="tab_content" style="display: block;">
464
  <div class="wrapper" style="margin-top:15px;">
465
  <table width="100%" border="0" cellspacing="0" cellpadding="0" class="form-list3 ">
466
+ <input name="order" type="hidden" id="order" value="<?php echo $this->getUrl('adminhtml/ajax/order'); ?>" />
467
  <tr>
468
  <td class="row1 fix_width2" >
469
  <label class="r_label">
470
+ <?php echo $this->__('Send SMS after order confirmation'); ?></label>
471
  <div class="radio_bx">
472
+ <input name="sms_order_setting" <?php if($orderSmsStatus == 1) { echo 'checked'; } ?> class="sms_order_setting radio_nospaceing" type="radio" value="1" />
473
  <?php echo $this->__('Yes'); ?>
474
+ <input name="sms_order_setting" <?php if($orderSmsStatus == 0) { echo 'checked'; } ?> class="sms_order_setting radio_spaceing2" type="radio" value="0" />
475
  <?php echo $this->__('No'); ?>
476
  </div>
477
  <div style="clear:both;"></div>
482
  <tr>
483
  <td>
484
  <form method="POST" action="<?php echo $this->getUrl('*/*/sendorder'); ?>" name="sender_order_form">
485
+ <input name="form_key" type="hidden" value="<?php echo $formKey; ?>" />
486
  <table width="100%" border="0" cellspacing="0" cellpadding="0" class="form-list3 no-padding">
487
  <tr>
488
  <td class="fix_width2" valign="top">
489
  <label>
490
+ <?php echo $this->__('Sender'); ?></label>
491
  </td>
492
  <td>
493
+ <input name="sender_order" id="sender_order" type="text" value="<?php echo $viewData['sendSmsOrderSubject']; ?>" class="input_bx" autocomplete="off" />
494
+ <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>
495
+ <div class="hintmsg"><em><?php echo $this->__('Number of characters left: '); ?><span id="sender_order_text">11</span></em>
496
  </div>
497
+
498
  </td>
499
  </tr>
500
  <tr>
501
  <td valign="top"><label><?php echo $this->__('Message'); ?></label></td>
502
  <td>
503
+ <textarea name="sender_order_message" id="sender_order_message" cols="45" rows="5" class="textarea_bx"><?php echo $viewData['sendSmsmOrderMessage']; ?></textarea>
504
+ <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>
505
  <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>
506
  <div class="hintmsg"><em><?php echo $this->__('Number of characters left: '); ?></em><span id="sender_order_message_text">160</span></div>
507
  <div class="hintmsg"><em><?php echo $this->__('Attention line break is counted as a single character.'); ?></em>
522
  <tr>
523
  <td colspan="2" valign="top" border="0">
524
  <form method="POST" action="<?php echo $this->getUrl('*/*/sendordertest'); ?>" name="sender_order_testForm">
525
+ <input name="form_key" type="hidden" value="<?php echo $formKey; ?>" />
526
  <table width="100%" border="0" cellspacing="0" cellpadding="0" class="form-data">
527
  <tr>
528
  <td>
548
  <div id="tab2" class="tab_content">
549
  <div class="wrapper" style="margin-top:15px;">
550
  <table width="100%" border="0" cellspacing="0" cellpadding="0" class="form-list3">
551
+ <input name="shiping" type="hidden" id="shiping" value="<?php echo $this->getUrl('adminhtml/ajax/shiping'); ?>" />
552
  <tr>
553
  <td class="row1 fix-width2">
554
  <label class="r_label">
555
+ <?php echo $this->__('Send a SMS confirmation for the shipment of the order'); ?></label>
556
  <div class="radio_bx">
557
+ <input name="sms_shiping_setting" <?php if($shipingSmsStatus==1) { echo 'checked'; } ?> class="sms_shiping_setting radio_nospaceing" type="radio" value="1" />
558
  <?php echo $this->__('Yes'); ?>
559
+ <input name="sms_shiping_setting" type="radio" value="0" class="sms_shiping_setting radio_spaceing2" <?php if($shipingSmsStatus == 0) { echo 'checked'; } ?>/>
560
  <?php echo $this->__('No'); ?>
561
  </div>
562
  <div style="clear:both;"></div>
568
  <td>
569
  <div class="" style="width:500px;">
570
  <form method="post" action="<?php echo $this->getUrl('*/*/sendshipment'); ?>" name="sender_shipment_form">
571
+ <input name="form_key" type="hidden" value="<?php echo $formKey; ?>" />
572
  <table width="100%" border="0" cellspacing="0" cellpadding="0">
573
  <tr>
574
  <td class="fix_width2" valign="top"><label><?php echo $this->__('Sender'); ?></label></td>
575
  <td>
576
+ <input name="sender_shipment" maxlength="11" id="sender_shipment" type="text" value="<?php echo $viewData['sendSmsShipingSubject']; ?>" class="input_bx" autocomplete="off" />
577
+ <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>
578
+ <div class="hintmsg"><em><?php echo $this->__('Number of characters left: '); ?><span id="sender_shipment_text">11</span></em>
579
  </div>
580
 
581
  </td>
583
  <tr>
584
  <td valign="top"><label><?php echo $this->__('Message'); ?></label></td>
585
  <td>
586
+ <textarea name="sender_shipment_message" id="sender_shipment_message" cols="45" rows="5" class="textarea_bx"><?php echo $viewData['sendSmsShipingMessage']; ?></textarea>
587
+ <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>
588
  <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>
589
  <div class="hintmsg"><em><?php echo $this->__('Number of characters left: '); ?></em><span id="sender_shipment_message_text">160</span></div>
590
  <div class="hintmsg"><em><?php echo $this->__('Attention line break is counted as a single character.'); ?></em>
606
  <tr>
607
  <td colspan="2" valign="top" border="0">
608
  <form method="post" action="<?php echo $this->getUrl('*/*/sendshipmenttest'); ?>" name="sender_order_testForm">
609
+ <input name="form_key" type="hidden" value="<?php echo $formKey; ?>" />
610
  <table width="100%" border="0" cellspacing="0" cellpadding="0">
611
  <tr>
612
  <td valign="top" colspan="2">
632
  <div id="tab3" class="tab_content">
633
  <div class="wrapper" style="margin-top:15px;">
634
  <table width="100%" border="0" cellspacing="0" cellpadding="0" class="form-list3">
635
+ <input name="campaign" type="hidden" id="campaign" value="<?php echo $this->getUrl('adminhtml/ajax/campaign'); ?>" />
636
  <tr>
637
  <td class="row1 fix_width2">
638
  <label class="r_label"><?php echo $this->__('Send a campaign SMS'); ?></label>
639
  <div class="radio_bx">
640
+ <input name="sms_campaign_setting" <?php if($campaignStatus == 1) { echo 'checked'; } ?> class="sms_campaign_setting radio_nospaceing" type="radio" value="1" />
641
  <?php echo $this->__('Yes'); ?>
642
+ <input name="sms_campaign_setting" <?php if($campaignStatus == 0) { echo 'checked'; } ?> class="sms_campaign_setting radio_spaceing2" type="radio" value="0" />
643
  <?php echo $this->__('No'); ?>
644
  </div>
645
  <div class="hideCampaign">
646
  <div class="form_table ">
647
 
648
+ <table width="100%" border="0" cellspacing="0" cellpadding="0" >
 
 
 
 
 
649
  <tr>
650
+ <td>
651
+ <form method="post" action="<?php echo $this->getUrl('*/*/sendcampaign'); ?>" name="sender_campaign_form">
652
+ <input name="form_key" type="hidden" value="<?php echo $formKey; ?>" />
653
+ <table width="100%" border="0" cellspacing="0" cellpadding="0" class="form-list3 no-padding" >
654
+ <tr>
655
+ <td class="fix_width2" valign="top"> <label><?php echo $this->__('To'); ?></label></td>
656
+ <td>
657
+ <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'; } ?> />
658
+ <?php echo $this->__('A single contact'); ?>
659
+
660
+ <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'; } ?> />
661
+ <?php echo $this->__('All my Magento customers'); ?>
662
+
663
+ <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'; } ?> />
664
+ <?php echo $this->__('Only subscribed customers'); ?>
665
+ </td>
666
+ </tr>
667
+ <script>
668
+ jQuery('#r1_Sendin_Sms_Choice').attr('checked', true);
669
+ </script>
670
+ <tr>
671
+ <td><h4 style="margin-top:0;"><?php echo $this->__('SMS settings'); ?></h4></td>
672
+ <td>&nbsp;</td>
673
+ </tr>
674
+
675
 
676
+ <tr class="singlechoice">
677
+ <td valign="top"><label><?php echo $this->__('Phone number of the contact'); ?>
678
+ </label></td>
679
+ <td>
680
+ <input name="singlechoice" id="singlechoice" maxlength="17" type="text" value="" class="input_bx" /><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>
681
+ </td>
682
+ </tr>
683
+
684
+ <tr class='sib_datepicker' style="display:none;">
685
+ <td valign="top"><label><?php echo $this->__('Schedule your sms campaign'); ?></label></td>
686
+ <td>
687
+ <input name="sib_datetimepicker" class="input_bx Datepicker" id="sib_datetimepicker" type="text" value="" autocomplete="off" />&nbsp;&nbsp;
688
+ <select name="hour">
689
+ <option value='0'><?php echo $this->__('Hour'); ?></option>
690
+ <?php for($i=1;$i<=23;$i++){ ?>
691
+ <option><?php echo $i; ?></option>
692
+ <?php } ?>
693
+ </select>&nbsp;&nbsp;
694
+ <select name="minute">
695
+ <option value='0'><?php echo $this->__('Minute'); ?></option>
696
+ <?php for($i=5;$i<=55;$i=$i+5){ ?>
697
+ <option><?php echo $i; ?></option>
698
+ <?php } ?>
699
+ </select>
700
+
701
+ </td>
702
+ </tr>
703
+
704
+ <tr>
705
+ <td valign="top"><label><?php echo $this->__('Sender'); ?></label></td>
706
+ <td>
707
+ <input name="sender_campaign" maxlength="11" id="sender_campaign" type="text" value="" class="input_bx" autocomplete="off" />
708
+ <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>
709
+ <div class="hintmsg"><em><?php echo $this->__('Number of characters left: '); ?><span id="sender_campaign_text">11</span></em>
710
+ </div>
711
+
712
+ </td>
713
+ </tr>
714
+ <tr>
715
+ <td valign="top"><label><?php echo $this->__('Message'); ?></label></td>
716
+ <td>
717
+ <textarea name="sender_campaign_message" id="sender_campaign_message" cols="45" rows="5" class="textarea_bx"></textarea>
718
+ <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>
719
+ <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>
720
+ <div class="hintmsg"><em><?php echo $this->__('Number of characters left: '); ?></em><span id="sender_campaign_message_text">160</span></div>
721
+ <div class="hintmsg"><em><?php echo $this->__('Attention line break is counted as a single character.'); ?></em>
722
+ </div><br>
723
+ <div class="hintmsg"><em><?php echo $this->__('If you want to personalize the SMS, you can use the variables below:'); ?></em></div>
724
+ <div class="hintmsg"><em><?php echo $this->__('- For first name use {first_name}'); ?></em></div>
725
+ <div class="hintmsg"><em><?php echo $this->__('- For last name use {last_name}'); ?></em></div>
726
+ <input type="submit" class="button mrgn-right btn" value="<?php echo $this->__('Send the campaign'); ?>" name="sender_campaign_save" onclick="return senderCampaignSaveValid('<?php echo $this->__('Please fill the Sender field'); ?>','<?php echo $this->__('Please fill the Message field'); ?>','<?php echo $this->__('Please enter the valid Mobile Number'); ?>');"">
727
+ </td>
728
+ </tr>
729
+ </table>
730
+ </form>
731
+ <table width="100%" border="0" cellspacing="0" cellpadding="0" class="form-data">
732
+ <tr>
733
+ <td>
734
+ <div class="hintmsg"><em><?php echo $this->__('Sending a test SMS will be deducted from your SMS credits.'); ?></em></div>
735
+ <label><?php echo $this->__('Send a test SMS'); ?></label>
736
+ <input name="sender_campaigntest_number" id="sender_campaigntest_number" maxlength="17" type="text" value="" class="input_bx" />
737
+ <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>
738
+ <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" />
739
+ <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'); ?>">
740
+ </td>
741
+ </tr>
742
+ </table>
743
+ </td>
744
  </tr>
745
+ </table>
746
+ </div></span>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
747
  </td>
748
  </tr>
749
  </table>
750
+ </div>
751
  </div>
752
  </div>
753
  </div>
758
  </table>
759
  </fieldset>
760
  </div>
761
+ <?php if($getSyncronize == 1) { ?>
762
  <div class="sendin_row alldiv" <?php echo $style; ?> >
763
+ <fieldset id="my-fieldset" class="fields">
764
+ <legend class="lgend"><img src="<?php echo $skinUrl;?>adminhtml/default/default/sendinblue/images/logo.gif"> <?php echo $this->__('Contacts list'); ?> </legend>
765
 
766
+ <input name="ajaxcontentUrl" type="hidden" id="ajaxcontentUrl" value="<?php echo $this->getUrl('adminhtml/ajax/ajaxcontent'); ?>" />
767
+ <input name="ajaxUrl" type="hidden" id="ajaxUrl" value="<?php echo $this->getUrl('adminhtml/ajax/ajaxupdate'); ?>" />
768
+ <input name="ajaxOrderSmsUrl" type="hidden" id="ajaxOrderSmsUrl" value="<?php echo $this->getUrl('adminhtml/ajax/ajaxordersms'); ?>" />
769
+ <input name="ajaxOrderShippedUrl" type="hidden" id="ajaxOrderShippedUrl" value="<?php echo $this->getUrl('adminhtml/ajax/ajaxordershipped'); ?>" />
770
+ <input name="ajaxSmsCampaignUrl" type="hidden" id="ajaxSmsCampaignUrl" value="<?php echo $this->getUrl('adminhtml/ajax/ajaxsmscampaign'); ?>" />
771
+ <input name="ajaxSmsSubscribeUrl" type="hidden" id="ajaxSmsSubscribeUrl" value="<?php echo $this->getUrl('adminhtml/ajax/ajaxsmssubscribe'); ?>" />
772
+ <input type="hidden" name="pagenumber" id="pagenumber" value="1" />
773
+ <div id="userGrid">
774
+ <div class="grid">
775
+ <div class="hor-scroll">
776
+ <?php echo $this->__('You have '); ?> <?php echo $viewData['newsletterSubscribeCount']; ?>
777
+ <?php echo $this->__(' contacts subscribed and '); ?>
778
+ <?php echo $viewData['newsletterUnSubscribeCount']; ?>
779
+ <?php echo $this->__(' contacts unsubscribed from Magento.'); ?><span id="Spantextmore" >
780
+ <?php echo $this->__(' For more details,'); ?></span><span id="Spantextless" style="display: none;" >
781
+ <?php echo $this->__(' For less details,'); ?></span><b>
782
+ <a href="javascript:void(0);" id="showUserlist" style="color: #000000; outline: 0 none; text-decoration: none;"><?php echo $this->__('click here'); ?></a></b>
783
+ <br><br>
784
 
785
+ <table cellspacing="0" id="userGrid_table " class="data userDetails" style='display:none;'>
786
+ <thead>
787
+ <tr class="headings">
788
+ <th class="no-link"><span class="nobr"><?php echo $this->__('Email'); ?></span></th>
789
+ <th class="no-link"><span class="nobr"><?php echo $this->__('clients'); ?></span></th>
790
+ <th class="no-link"><span class="nobr"><?php echo $this->__('SMS'); ?></span></th>
791
+ <th class="no-link"><span class="nobr"><?php echo $this->__('Newsletter Magento Status'); ?></span></th>
792
+ <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>
793
+ <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>
794
+ </tr>
795
+ </thead>
796
+ <tbody class='midleft'>
797
+ </tbody>
798
+ </table>
799
+ </div>
800
+ </div>
801
+ </div>
802
+ </fieldset>
803
+ </div>
804
  <?php }} ?>
805
+
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
@@ -20,7 +20,7 @@
20
  "No", "Non"
21
  "API Key:", "Clé API:"
22
  "Validate &amp; Save", "Valider et enregistrer"
23
- "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", "Veuillez renseigner votre clé API qui est liée à votre compte SendinBlue. Elle est disponible sur cette page: https://my.sendinblue.com/advanced/apikey. Si vous ne possédez pas de compte SendinBlue, vous devez créer un compte sur le site https://www.sendinblue.com"
24
  "Your lists", "Vos listes"
25
  "Activate SendinBlue to manage subscribers", "Activer SendinBlue pour gérer vos contacts"
26
  "Your Lists", "Vos listes"
@@ -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 :"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
20
  "No", "Non"
21
  "API Key:", "Clé API:"
22
  "Validate &amp; Save", "Valider et enregistrer"
23
+ "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/integration", "Veuillez renseigner votre clé API qui est liée à votre compte SendinBlue. Elle est disponible sur cette page: https://my.sendinblue.com/integration. Si vous ne possédez pas de compte SendinBlue, vous devez créer un compte sur le site https://www.sendinblue.com"
24
  "Your lists", "Vos listes"
25
  "Activate SendinBlue to manage subscribers", "Activer SendinBlue pour gérer vos contacts"
26
  "Your Lists", "Vos listes"
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,27 @@
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Sendinblue</name>
4
- <version>1.1.0</version>
5
  <stability>stable</stability>
6
- <license uri="http://opensource.org/licenses/osl-3.0.php">OSL V1.0</license>
7
  <channel>community</channel>
8
  <extends/>
9
  <summary>Synchronize your Magento contacts with SendinBlue platform, easily send your marketing and transactional emails and SMS.</summary>
10
- <description>With the SendinBlue plugin, you can find everything you need to easily and efficiently send your email and SMS campaigns to your prospects and customers.
11
- Synchronize your subscribers with SendinBlue (subscribed and unsubscribed contacts)
12
- Easily create good looking emailings
13
- Schedule your campaigns
14
- Track your results and optimize
15
- Monitor your transactional emails (purchase confirmation, password reset, etc) with a better deliverability and real-time analytics
16
- Why should you use SendinBlue
17
- Optimized deliverability
18
- Unbeatable pricingbest value in the industry
19
  Technical support, by phone or by email</description>
20
  <notes>Synchronize your Magento contacts with SendinBlue platform, send your marketing and transactional emails and SMS</notes>
21
- <authors><author><name>SendinBlue</name><user>Sendinblue_Team</user><email>contact@sendinblue.com</email></author></authors>
22
- <date>2014-02-28</date>
23
- <time>10:05:32</time>
24
- <contents><target name="magelocal"><dir name="Sendinblue"><dir name="Sendinblue"><dir name="Block"><file name="Sendinblue.php" hash="4b5adae031b714e188d576e306bfd5a1"/></dir><dir name="Helper"><file name="Data.php" hash="0532b48f611c1cc623589d5792e0dbf2"/></dir><dir name="Model"><dir name="Email"><file name="Template.php" hash="6d2d6eac00b7bd6da3ff53d2abe40dd4"/></dir><file name="Email.php" hash="fe07aa2dba951ee117bda2cefebfb875"/><dir name="Mysql4"><dir name="Sendinblue"><file name="Collection.php" hash="d6aff03eda9a6b2ee1c42b8dd50df402"/></dir><file name="Sendinblue.php" hash="c000c1f6a277f7c9a91ad628b02eb001"/></dir><file name="Observer.php" hash="250cc069aa5194652f6503e2cc0f8194"/><file name="Sendinblue.php" hash="963c473c2f3ca66f23d00de0c4c9292f"/><file name="Status.php" hash="444fe4d099bd23a9d87cdf7e2b2e6cbb"/></dir><dir name="controllers"><dir name="Adminhtml"><file name="MyformController.php" hash="67dd963b1f003d2b2f25c8b4643d4715"/><file name="NotifyController.php" hash="e3b43db59f8c5b7c8cd54a58a7bc2d1b"/><file name="SyncController.php" hash="352fd0d804701d0228bad7e7b92afb58"/></dir><file name="AjaxController.php" hash="b4914ddac9d4e836ecf53869055a6a82"/><file name="IndexController.php" hash="2cf5287ba31d6960eb28c2cbc03a60ed"/></dir><dir name="etc"><file name="adminhtml.xml" hash="640ba5382a16c749fc56a2a8283682ee"/><file name="config.xml" hash="ba48680b7267a4b2d27f4645792b2393"/></dir><dir name="sql"><dir name="sendinblue_setup"><file name="install-0.1.0.php" hash="58bb365dcb29115c66f2fa3f17dcb697"/><file name="mysql4-upgrade-0.1.0-0.2.0.php" hash="b50e876441a247cd5feb2614ff649fd3"/></dir></dir></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="sendinblue.xml" hash="e23253764fbbf0e3a2f1cb5ff65eb318"/></dir><dir name="template"><dir name="sendinblue"><file name="myform.phtml" hash="2a4748e2e456d2b95d9828bf2da90bd8"/></dir></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="sendinblue.xml" hash="61346d8b2b321b10c09a77fef39ec112"/></dir><dir name="template"><dir name="sendinblue"><dir name="account"><file name="edit.phtml" hash="c2b17e90e59e1d13791feded28982330"/></dir></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Sendinblue_Sendinblue.xml" hash="1a245999d412c36ea9666b56bfc63e2d"/></dir></target><target name="magelocale"><dir name="fr_FR"><file name="Sendinblue.csv" hash="72507895f18a8c4a80611065790aba56"/></dir></target><target name="mage"><dir name="app"><dir name="locale"><dir name="fr_FR"><dir name="template"><dir name="email"><file name="sendin_notification.html" hash="557ddb7212800b4a99937b2d8956270c"/><file name="sendinsmtp_conf.html" hash="b1c790c78605b2beb4cd38152cd8f0ca"/>
25
- </dir></dir></dir><dir name="en_US"><dir name="template"><dir name="email"><file name="sendin_notification.html" hash="de646d23657f68387d32683d14ea215a"/><file name="sendinsmtp_conf.html" hash="a35979191ec11cd5cbebc0efece1c472"/></dir></dir></dir></dir></dir></target><target name="mageskin"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="sendinblue"><dir name="css"><file name="jquery-ui.css" hash="3f3d39116de928eb9c3cc33004efae77"/><file name="jquery.multiselect.css" hash="b2ecda55b895b485e49baa5759cc61fe"/><file name="styles.css" hash="61f4da300d2b59cc4d22af19d6abc742"/></dir><dir name="images"><file name="close.png" hash="223ea7c82841be9da96aec80bd68b7f5"/><file name="disabled.gif" hash="21ff0e6ba24381e63789116139180cf0"/><file name="enabled.gif" hash="0db2c4f24c0f0c3f7958a05181af897a"/><file name="help.gif" hash="19002f53dd724465717c27f0399c0a90"/><file name="index.php" hash="507d846db3efc2563672c8f60ac080f4"/><file name="loader.gif" hash="394bafc3cc4dfb3a0ee48c1f54669539"/><file name="loading_anim.gif" hash="b494fceca79586281a29c9462b09c85a"/><file name="logo.gif" hash="b13ce89934c4aa2aeb76d75896efe40f"/><file name="logo.png" hash="76ecf5757c096639a3b27ed5fc470d48"/><file name="sendinblue.png" hash="4bb823a9290b79546cc99d57de304db9"/><file name="ui-icons_ef8c08_256x240.png" hash="47fc08e06aba0b7ac0a6d3b9f92894cb"/><file name="ui-icons_ef8c08_256x240.png.png" hash="47fc08e06aba0b7ac0a6d3b9f92894cb"/></dir><dir name="js"><file name="index.php" hash="36aa6e5d248b48fd910a4dfa1987ca56"/><file name="jquery-1.9.1.min.js" hash="397754ba49e9e0cf4e7c190da78dda05"/><file name="jquery-ui.min.js" hash="3e6acb1e6426ef90d2e786a006a4ea28"/><file name="jquery.multiselect.js" hash="9851bb7a2509099e28ee789fc864570e"/><file name="jquery.multiselect.min.js" hash="efb34f759712b9da1172c3a2efe8ef6b"/><file name="sendinblue.js" hash="e5d8ac61766af444255eb9226a0cb344"/><file name="sendinblue.min.js" hash="60a1241bec9edc538c360ac459890927"/></dir></dir></dir></dir></dir></target></contents>
26
  <compatible/>
27
- <dependencies><required><php><min>5.0.0</min><max>6.0.0</max></php></required></dependencies>
28
  </package>
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Sendinblue</name>
4
+ <version>1.3.2</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"/><file name="AjaxController.php" hash="b4914ddac9d4e836ecf53869055a6a82"/><file name="IndexController.php" hash="2cf5287ba31d6960eb28c2cbc03a60ed"/></dir></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"/></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>
 
25
  <compatible/>
26
+ <dependencies><required><php><min>5.0.0</min><max>7.0.0</max></php></required></dependencies>
27
  </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)})});