Eadesigndev_Xpertmessaging - Version 1.0.1

Version Notes

The first version.

Download this release

Release Info

Developer EaDesign
Extension Eadesigndev_Xpertmessaging
Version 1.0.1
Comparing to
See all releases


Version 1.0.1

app/code/local/Eadesigndev/Smsxpertmessaging/Helper/Data.php ADDED
@@ -0,0 +1,163 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * EaDesgin
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Academic Free License (AFL 3.0)
9
+ * that is bundled with this package in the file LICENSE_AFL.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/afl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to license@eadesign.ro so we can send you a copy immediately.
15
+ *
16
+ * @category Eadesigndev_Followup
17
+ * @copyright Copyright (c) 2008-2015 EaDesign by Eco Active S.R.L.
18
+ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
19
+ */
20
+ class Eadesigndev_Smsxpertmessaging_Helper_Data extends Mage_Core_Helper_Abstract
21
+ {
22
+
23
+ private $_phone;
24
+
25
+ public function generateXmlParams($template)
26
+ {
27
+ $xml = '';
28
+ $xml .= '<PALO><HEAD>';
29
+ $xml .= '<FROM>' . $this->getCodSender() . '</FROM>';
30
+ $xml .= '<APP USER="' . $this->getSmsUser() . '" PASSWORD="' . $this->getSmsPass() . '">LA</APP>';
31
+ $xml .= '<CMD>sendtextmt</CMD>';
32
+ $xml .= '</HEAD><BODY>';
33
+ $xml .= '<SENDER>' . $this->getDeLa() . '</SENDER>';
34
+ $xml .= '<CONTENT><![CDATA[' . $template . ']]></CONTENT>';
35
+ $xml .= '<DEST_LIST>';
36
+ $xml .= '<TO>' . $this->getCodTara() . $this->_getPhone() . '</TO>';
37
+ $xml .= '</DEST_LIST>';
38
+ $xml .= '</BODY><OPTIONAL>';
39
+ $xml .= '<MSG_ID>{msg id you wish to add}</MSG_ID>';
40
+ $xml .= '</OPTIONAL></PALO>';
41
+
42
+ $this->connectAndSend($xml);
43
+
44
+ }
45
+
46
+ public function connectAndSend($xml)
47
+ {
48
+
49
+ $xml = str_replace("%", "%25", $xml);
50
+ $xml = str_replace(" ", "%20", $xml);
51
+ $xml = str_replace("#", "%23", $xml);
52
+ $xml = str_replace("&", "%26", $xml);
53
+ $xml = str_replace("?", "%3F", $xml);
54
+ $xml = str_replace("+", "%2B", $xml);
55
+
56
+ $url_request = 'https://xpertmessaging.com/api/unistart5.asp';
57
+ $curl = curl_init();
58
+ $headers[] = "Content-type: application/x-www-form-urlencoded";
59
+ curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
60
+ curl_setopt($curl, CURLOPT_URL, $url_request);
61
+ curl_setopt($curl, CURLOPT_POST, 1);
62
+ curl_setopt($curl, CURLOPT_POSTFIELDS, "XMLString=$xml");
63
+ curl_setopt($curl, CURLOPT_USERAGENT, 'User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.26) Gecko/20120128 Firefox/3.6.26');
64
+ curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
65
+ $ReturnSmsNotification = curl_exec($curl);
66
+ curl_close($curl);
67
+
68
+ // exit($ReturnSmsNotification);
69
+
70
+ }
71
+
72
+
73
+ public function processSmsTemplate($data)
74
+ {
75
+
76
+ if (!is_array($data)) {
77
+ return;
78
+ }
79
+
80
+ if (!$this->getSmsNew()) {
81
+ return;
82
+ }
83
+
84
+ $this->_phone = $data['customer-phone'];
85
+
86
+
87
+ $template = Mage::getModel('core/email_template')
88
+ ->load($this->getSmsNew())
89
+ ->getProcessedTemplate($data);
90
+
91
+ $this->generateXmlParams($template);
92
+
93
+ }
94
+
95
+ public function processSmsTemplateAwb($data)
96
+ {
97
+
98
+ if (!is_array($data)) {
99
+ return;
100
+ }
101
+
102
+ if (!$this->getSmsAwb()) {
103
+ return;
104
+ }
105
+
106
+ $this->_phone = $data['customer-phone'];
107
+
108
+
109
+ $template = Mage::getModel('core/email_template')
110
+ ->load($this->getSmsAwb())
111
+ ->getProcessedTemplate($data);
112
+
113
+ $this->generateXmlParams($template);
114
+
115
+ }
116
+
117
+ private function _getPhone()
118
+ {
119
+ return $this->_phone;
120
+ }
121
+
122
+ public function isActive()
123
+ {
124
+ return Mage::getStoreConfig('sms_settings/sms_opt/active');
125
+ }
126
+
127
+ public function getSmsUser()
128
+ {
129
+ return Mage::getStoreConfig('sms_settings/sms_opt/sms_user');
130
+ }
131
+
132
+ public function getSmsPass()
133
+ {
134
+ return Mage::getStoreConfig('sms_settings/sms_opt/sms_pass');
135
+ }
136
+
137
+ public function getCodSender()
138
+ {
139
+ return Mage::getStoreConfig('sms_settings/sms_opt/sms_code');
140
+ }
141
+
142
+ public function getCodTara()
143
+ {
144
+ return Mage::getStoreConfig('sms_settings/sms_opt/sms_cc');
145
+ }
146
+
147
+ public function getDeLa()
148
+ {
149
+ return Mage::getStoreConfig('sms_settings/sms_opt/sms_from');
150
+ }
151
+
152
+ public function getSmsNew()
153
+ {
154
+ return Mage::getStoreConfig('sms_settings/sms_opt/sms_new');
155
+ }
156
+
157
+ public function getSmsAwb()
158
+ {
159
+ return Mage::getStoreConfig('sms_settings/sms_opt/sms_complete');
160
+ }
161
+
162
+
163
+ }
app/code/local/Eadesigndev/Smsxpertmessaging/Model/Observer.php ADDED
@@ -0,0 +1,94 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Created by IntelliJ IDEA.
5
+ * User: eadesignpc
6
+ * Date: 6/23/2015
7
+ * Time: 11:56 AM
8
+ */
9
+ class Eadesigndev_Smsxpertmessaging_Model_Observer
10
+ {
11
+ public function sendSms($observer)
12
+ {
13
+
14
+ $helper = Mage::helper('smsxpertmessaging');
15
+
16
+ if (!$helper->isActive()) {
17
+ return;
18
+ }
19
+
20
+ $order = $observer->getOrder();
21
+
22
+ $orderNumber = '# ' . $order->getData('increment_id');
23
+
24
+ if ($order->getCustomerIsGuest()) {
25
+ $name = $order->getBillingAddress()->getName();
26
+ } else {
27
+ $name = $order->getCustomerName();
28
+ }
29
+
30
+ $phoneData = explode('7', $order->getBillingAddress()->getTelephone(), 2);
31
+
32
+ $phone = '7' . $phoneData[1];
33
+
34
+ $data = array(
35
+ 'customer-name' => $name,
36
+ 'customer-phone' => $phone,
37
+ 'order-number' => $orderNumber,
38
+ );
39
+
40
+ $helper->processSmsTemplate($data);
41
+
42
+ }
43
+
44
+ public function sendSmsCompleate($observer)
45
+ {
46
+
47
+ $helper = Mage::helper('smsxpertmessaging');
48
+
49
+ if (!$helper->isActive()) {
50
+ return;
51
+ }
52
+
53
+ $order = $observer->getShipment()->getOrder();
54
+
55
+ $trakings = $observer->getShipment()->getAllTracks();
56
+
57
+ if(!count($trakings)){
58
+ return;
59
+ }
60
+
61
+ $trackNums = array();
62
+ $trackTitles = array();
63
+ foreach($trakings as $tracknum)
64
+ {
65
+ $trackNums[]=$tracknum->getNumber();
66
+ $trackTitles[]=$tracknum->getTitle();
67
+ }
68
+
69
+ $trackNum = end($trackNums);
70
+ $trackTitle = end($trackTitles);
71
+
72
+ $orderNumber = '# ' . $order->getData('increment_id');
73
+
74
+ if ($order->getCustomerIsGuest()) {
75
+ $name = $order->getBillingAddress()->getName();
76
+ } else {
77
+ $name = $order->getCustomerName();
78
+ }
79
+
80
+ $phoneData = explode('7', $order->getBillingAddress()->getTelephone(), 2);
81
+
82
+ $phone = '7' . $phoneData[1];
83
+
84
+ $data = array(
85
+ 'customer-name' => $name,
86
+ 'customer-phone' => $phone,
87
+ 'order-number' => $orderNumber,
88
+ 'awb-number' => $trackNum,
89
+ 'awb-title' => $trackTitle,
90
+ );
91
+
92
+ $helper->processSmsTemplateAwb($data);
93
+ }
94
+ }
app/code/local/Eadesigndev/Smsxpertmessaging/Model/System/Smslist.php ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Eadesigndev_Smsxpertmessaging_Model_System_Smslist
4
+ {
5
+ public function toOptionArray()
6
+ {
7
+ $result = array();
8
+ $collection = Mage::getResourceModel('core/email_template_collection')
9
+ ->load();
10
+ $options = $collection->toOptionArray();
11
+ $defOptions = Mage_Core_Model_Email_Template::getDefaultTemplatesAsOptionsArray();
12
+ foreach ($defOptions as $v) {
13
+ $options[] = $v;
14
+ }
15
+ foreach ($options as $v) {
16
+ $result[$v['value']] = $v['label'];
17
+ }
18
+
19
+ $options = array();
20
+ $options[] = array('value' => '', 'label' => '---------Choose Email Template---------');
21
+ foreach ($result as $k => $v) {
22
+ if (!is_int($k))
23
+ continue;
24
+ $options[] = array('value' => $k, 'label' => $v);
25
+ }
26
+
27
+ $result = $options;
28
+
29
+ return $result;
30
+ }
31
+ }
app/code/local/Eadesigndev/Smsxpertmessaging/etc/config.xml ADDED
@@ -0,0 +1,66 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <config>
3
+ <modules>
4
+ <Eadesigndev_Smsxpertmessaging>
5
+ <version>1.0.1</version>
6
+ </Eadesigndev_Smsxpertmessaging>
7
+ </modules>
8
+ <global>
9
+ <helpers>
10
+ <smsxpertmessaging>
11
+ <class>Eadesigndev_Smsxpertmessaging_Helper</class>
12
+ </smsxpertmessaging>
13
+ </helpers>
14
+ <blocks>
15
+ <smsxpertmessaging>
16
+ <class>Eadesigndev_Smsxpertmessaging_Block</class>
17
+ </smsxpertmessaging>
18
+ </blocks>
19
+ <models>
20
+ <smsxpertmessaging>
21
+ <class>Eadesigndev_Smsxpertmessaging_Model</class>
22
+ </smsxpertmessaging>
23
+ </models>
24
+ <events>
25
+ <sales_order_place_before>
26
+ <observers>
27
+ <send_sms>
28
+ <type>model</type>
29
+ <class>smsxpertmessaging/observer</class>
30
+ <method>sendSms</method>
31
+ </send_sms>
32
+ </observers>
33
+ </sales_order_place_before>
34
+ <sales_order_shipment_save_after>
35
+ <observers>
36
+ <send_sms_complete>
37
+ <type>model</type>
38
+ <class>smsxpertmessaging/observer</class>
39
+ <method>sendSmsCompleate</method>
40
+ </send_sms_complete>
41
+ </observers>
42
+ </sales_order_shipment_save_after>
43
+ </events>
44
+ </global>
45
+ <adminhtml>
46
+ <acl>
47
+ <resources>
48
+ <admin>
49
+ <children>
50
+ <system>
51
+ <children>
52
+ <config>
53
+ <children>
54
+ <sms_settings>
55
+ <title>EaDesign SMS</title>
56
+ </sms_settings>
57
+ </children>
58
+ </config>
59
+ </children>
60
+ </system>
61
+ </children>
62
+ </admin>
63
+ </resources>
64
+ </acl>
65
+ </adminhtml>
66
+ </config>
app/code/local/Eadesigndev/Smsxpertmessaging/etc/system.xml ADDED
@@ -0,0 +1,112 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <config>
3
+ <tabs>
4
+ <eadesigndevconfig translate="label" module="smsxpertmessaging">
5
+ <label>EaDesign</label>
6
+ <sort_order>999</sort_order>
7
+ </eadesigndevconfig>
8
+ </tabs>
9
+
10
+ <sections>
11
+ <sms_settings translate="label" module="smsxpertmessaging"> <!--Sections meniu stanga activ cu click-->
12
+ <label>EaDesign SMS</label>
13
+ <tab>eadesigndevconfig</tab>
14
+ <frontend_type>text</frontend_type>
15
+ <sort_order>1000</sort_order>
16
+ <show_in_default>1</show_in_default>
17
+ <show_in_website>1</show_in_website>
18
+ <show_in_store>1</show_in_store>
19
+ <groups>
20
+ <sms_opt translate="label">
21
+ <label>Settings</label>
22
+ <frontend_type>text</frontend_type>
23
+ <sort_order>1</sort_order>
24
+ <show_in_default>1</show_in_default>
25
+ <show_in_website>1</show_in_website>
26
+ <show_in_store>1</show_in_store>
27
+ <fields>
28
+ <active translate="label">
29
+ <label>Activat</label>
30
+ <frontend_type>select</frontend_type>
31
+ <source_model>adminhtml/system_config_source_yesno</source_model>
32
+ <sort_order>1</sort_order>
33
+ <show_in_default>1</show_in_default>
34
+ <show_in_website>1</show_in_website>
35
+ <show_in_store>0</show_in_store>
36
+ </active>
37
+ <sms_user translate="label" module="core">
38
+ <label>User</label>
39
+ <frontend_type>text</frontend_type>
40
+ <sort_order>2</sort_order>
41
+ <show_in_default>1</show_in_default>
42
+ <show_in_website>1</show_in_website>
43
+ <show_in_store>1</show_in_store>
44
+ </sms_user>
45
+ <sms_pass translate="label" module="core">
46
+ <label>Password</label>
47
+ <frontend_type>text</frontend_type>
48
+ <sort_order>2</sort_order>
49
+ <show_in_default>1</show_in_default>
50
+ <show_in_website>1</show_in_website>
51
+ <show_in_store>1</show_in_store>
52
+ </sms_pass>
53
+ <sms_from translate="label" module="core">
54
+ <label>From</label>
55
+ <frontend_type>text</frontend_type>
56
+ <sort_order>3</sort_order>
57
+ <show_in_default>1</show_in_default>
58
+ <show_in_website>1</show_in_website>
59
+ <show_in_store>1</show_in_store>
60
+ <comment><![CDATA[Ex: 1245]]></comment>
61
+ </sms_from>
62
+ <sms_cc translate="label" module="core">
63
+ <label>Cod tara</label>
64
+ <frontend_type>text</frontend_type>
65
+ <sort_order>3</sort_order>
66
+ <show_in_default>1</show_in_default>
67
+ <show_in_website>1</show_in_website>
68
+ <show_in_store>1</show_in_store>
69
+ <comment><![CDATA[Ex: +40]]></comment>
70
+ </sms_cc>
71
+ <sms_code translate="label" module="core">
72
+ <label>Cod sender</label>
73
+ <frontend_type>text</frontend_type>
74
+ <sort_order>3</sort_order>
75
+ <show_in_default>1</show_in_default>
76
+ <show_in_website>1</show_in_website>
77
+ <show_in_store>1</show_in_store>
78
+ </sms_code>
79
+ <sms_cc translate="label" module="core">
80
+ <label>Cod tara</label>
81
+ <frontend_type>text</frontend_type>
82
+ <sort_order>3</sort_order>
83
+ <show_in_default>1</show_in_default>
84
+ <show_in_website>1</show_in_website>
85
+ <show_in_store>1</show_in_store>
86
+ </sms_cc>
87
+ <sms_new translate="label" module="core">
88
+ <label>Sms new</label>
89
+ <frontend_type>select</frontend_type>
90
+ <source_model>smsxpertmessaging/system_smslist</source_model>
91
+ <sort_order>4</sort_order>
92
+ <show_in_default>1</show_in_default>
93
+ <show_in_website>1</show_in_website>
94
+ <show_in_store>1</show_in_store>
95
+ <comment><![CDATA[Template tranazatonal pentru comanda noua]]></comment>
96
+ </sms_new>
97
+ <sms_complete translate="label" module="core">
98
+ <label>Sms awb</label>
99
+ <frontend_type>select</frontend_type>
100
+ <source_model>smsxpertmessaging/system_smslist</source_model>
101
+ <sort_order>4</sort_order>
102
+ <show_in_default>1</show_in_default>
103
+ <show_in_website>1</show_in_website>
104
+ <show_in_store>1</show_in_store>
105
+ <comment><![CDATA[Template tranazatonal pentru awb nou]]></comment>
106
+ </sms_complete>
107
+ </fields>
108
+ </sms_opt>
109
+ </groups>
110
+ </sms_settings>
111
+ </sections>
112
+ </config>
app/etc/modules/Eadesigndev_Smsxpertmessaging.xml ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Eadesigndev_Smsxpertmessaging>
5
+ <active>true</active>
6
+ <codePool>local</codePool>
7
+ </Eadesigndev_Smsxpertmessaging>
8
+ </modules>
9
+ </config>
package.xml ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>Eadesigndev_Xpertmessaging</name>
4
+ <version>1.0.1</version>
5
+ <stability>stable</stability>
6
+ <license uri="http://opensource.org/licenses/osl-3.0.php">Extension license name (OSL v3.0)</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>The extension will send sms messages when the user places an order and when is complete.</summary>
10
+ <description>The extension integrates Magento with Xpertmessaging. Using this extension ou will be able to send sms messages to your clients when the place an order or when you add tracking numbers. The extension uses transnational emails to send sms.</description>
11
+ <notes>The first version.</notes>
12
+ <authors><author><name>EaDesign</name><user>eadesign</user><email>office@eadesign.ro</email></author></authors>
13
+ <date>2015-11-19</date>
14
+ <time>08:43:42</time>
15
+ <contents><target name="magelocal"><dir name="Eadesigndev"><dir name="Smsxpertmessaging"><dir name="Helper"><file name="Data.php" hash="340839062e0ef868c896c5a61da47212"/></dir><dir name="Model"><file name="Observer.php" hash="6027401f1964302a2ba331b7559500df"/><dir name="System"><file name="Smslist.php" hash="c4f0b204cf3170e8f6681d29ea8baaed"/></dir></dir><dir name="etc"><file name="config.xml" hash="8e59350aaa27777429f65fdfedaabea8"/><file name="system.xml" hash="f287a6d412c1b3bcfb041a7b7444dff9"/></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Eadesigndev_Smsxpertmessaging.xml" hash="ba19374d0b3261156bf696e843155849"/></dir></target></contents>
16
+ <compatible/>
17
+ <dependencies><required><php><min>5.2.0</min><max>5.6.3</max></php></required></dependencies>
18
+ </package>