Version Notes
Sms notification
Download this release
Release Info
Developer | Carotechs |
Extension | Carotechs_Smsnotify |
Version | 0.1.6 |
Comparing to | |
See all releases |
Code changes from version 0.1.5 to 0.1.6
- app/code/local/Carotechs/Smsnotify/Block/Adminhtml/Smsnotify.php +12 -0
- app/code/local/Carotechs/Smsnotify/Helper/Data.php +1 -3
- app/code/local/Carotechs/Smsnotify/controllers/Adminhtml/SmsnotifyController.php +101 -0
- app/code/local/Carotechs/Smsnotify/etc/adminhtml.xml +36 -23
- app/code/local/Carotechs/Smsnotify/etc/config.xml +38 -19
- app/design/adminhtml/default/default/layout/smsnotify.xml +8 -0
- app/design/adminhtml/default/default/template/smsnotify/sendsms.phtml +98 -0
- package.xml +9 -9
app/code/local/Carotechs/Smsnotify/Block/Adminhtml/Smsnotify.php
ADDED
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Carotechs_Smsnotify_Block_Adminhtml_Smsnotify extends Mage_Adminhtml_Block_Template
|
3 |
+
{
|
4 |
+
public function __construct()
|
5 |
+
{
|
6 |
+
$this->_controller = 'adminhtml_smsnotify';
|
7 |
+
$this->setFormAction(Mage::getUrl('*/*/sendsms'));
|
8 |
+
$this->_headerText = Mage::helper('smsnotify')->__('Send SMS');
|
9 |
+
|
10 |
+
}
|
11 |
+
|
12 |
+
}
|
app/code/local/Carotechs/Smsnotify/Helper/Data.php
CHANGED
@@ -189,8 +189,6 @@ class Carotechs_Smsnotify_Helper_Data extends Mage_Core_Helper_Data
|
|
189 |
|
190 |
public function file_get_contents_curl($url)
|
191 |
{
|
192 |
-
|
193 |
-
$ch = curl_init();
|
194 |
|
195 |
curl_setopt($ch, CURLOPT_HEADER, 0);
|
196 |
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); //Set curl to return the data instead of printing it to the browser.
|
@@ -204,7 +202,7 @@ class Carotechs_Smsnotify_Helper_Data extends Mage_Core_Helper_Data
|
|
204 |
|
205 |
public function file_get_contents_curl_POST($url,$data)
|
206 |
{
|
207 |
-
|
208 |
$ch = curl_init($url);
|
209 |
curl_setopt($ch, CURLOPT_POST, true);
|
210 |
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
|
189 |
|
190 |
public function file_get_contents_curl($url)
|
191 |
{
|
|
|
|
|
192 |
|
193 |
curl_setopt($ch, CURLOPT_HEADER, 0);
|
194 |
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); //Set curl to return the data instead of printing it to the browser.
|
202 |
|
203 |
public function file_get_contents_curl_POST($url,$data)
|
204 |
{
|
205 |
+
|
206 |
$ch = curl_init($url);
|
207 |
curl_setopt($ch, CURLOPT_POST, true);
|
208 |
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
|
app/code/local/Carotechs/Smsnotify/controllers/Adminhtml/SmsnotifyController.php
ADDED
@@ -0,0 +1,101 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Carotechs_Smsnotify_Adminhtml_SmsnotifyController extends Mage_Adminhtml_Controller_action
|
4 |
+
{
|
5 |
+
|
6 |
+
protected function _initAction() {
|
7 |
+
$this->loadLayout()
|
8 |
+
->_setActiveMenu('customer/customer')
|
9 |
+
->_addBreadcrumb(Mage::helper('smsnotify')->__('Items Manager'), Mage::helper('smsnotify')->__('Item Manager'));
|
10 |
+
|
11 |
+
return $this;
|
12 |
+
}
|
13 |
+
|
14 |
+
public function indexAction() {
|
15 |
+
|
16 |
+
$this->_initAction();
|
17 |
+
$this->loadLayout()
|
18 |
+
->_setActiveMenu('customer/customer')
|
19 |
+
->renderLayout();
|
20 |
+
}
|
21 |
+
|
22 |
+
public function sendsmsAction()
|
23 |
+
{
|
24 |
+
extract($_POST);
|
25 |
+
if(isset($_POST))
|
26 |
+
{
|
27 |
+
$phone_array = explode(',',$phone_numbers);
|
28 |
+
//Gateway credentials
|
29 |
+
|
30 |
+
$api_url = Mage::helper('smsnotify')->getAPI();
|
31 |
+
$message_field_name = Mage::helper('smsnotify')->getMessageField();
|
32 |
+
$to_field_name = Mage::helper('smsnotify')->getToField();
|
33 |
+
|
34 |
+
if($message_field_name=='')
|
35 |
+
{
|
36 |
+
$message_field_name = 'msg';
|
37 |
+
}
|
38 |
+
if($to_field_name=='')
|
39 |
+
{
|
40 |
+
$to_field_name = 'to';
|
41 |
+
}
|
42 |
+
$sent_method = Mage::helper('smsnotify')->getSentMethod();
|
43 |
+
|
44 |
+
|
45 |
+
/*handling error*/
|
46 |
+
$flag = 1;
|
47 |
+
$error_message = "Error: Send SMS - Not able to send SMS. Make sure that your provided correct API URL,Username and Password.";
|
48 |
+
if($api_url=='')
|
49 |
+
{
|
50 |
+
$flag = 0;
|
51 |
+
}
|
52 |
+
|
53 |
+
|
54 |
+
if($flag==1)
|
55 |
+
{
|
56 |
+
for($i=0;$i<count($phone_array);$i++)
|
57 |
+
{
|
58 |
+
if($phone_array[$i]!='')
|
59 |
+
{
|
60 |
+
if($sent_method)
|
61 |
+
{
|
62 |
+
$data = '';
|
63 |
+
$data .= '?'.$message_field_name.'=' . $message;
|
64 |
+
$data .= '&'.$to_field_name.'=' . $phone_array[$i];
|
65 |
+
|
66 |
+
$method = 'GET';
|
67 |
+
$url = $api_url.$data;
|
68 |
+
$sendSms = Mage::helper('smsnotify')->sendSms($url);
|
69 |
+
}
|
70 |
+
else
|
71 |
+
{
|
72 |
+
$post_data = array();
|
73 |
+
$post_data[$message_field_name] = $message;
|
74 |
+
$post_data[$to_field_name] = $phone_array[$i];
|
75 |
+
$url = $api_url;
|
76 |
+
$sendSms = Mage::helper('smsnotify')->sendSms($url,$post_data);
|
77 |
+
}
|
78 |
+
}
|
79 |
+
}
|
80 |
+
Mage::getSingleton('core/session')->setSmsstatus('success');
|
81 |
+
Mage::getSingleton('core/session')->setSmsmsg('Message sent successfully.');
|
82 |
+
$this->_redirect('*/*/');
|
83 |
+
}
|
84 |
+
else
|
85 |
+
{
|
86 |
+
Mage::log($error_message,null,'smsnotify.log');
|
87 |
+
}
|
88 |
+
|
89 |
+
|
90 |
+
}
|
91 |
+
else
|
92 |
+
{
|
93 |
+
Mage::getSingleton('core/session')->setSmsstatus('error');
|
94 |
+
Mage::getSingleton('core/session')->setSmsmsg('Unable to send SMS.');
|
95 |
+
$this->_redirect('*/*/');
|
96 |
+
}
|
97 |
+
|
98 |
+
$this->loadLayout();
|
99 |
+
$this->renderLayout();
|
100 |
+
}
|
101 |
+
}
|
app/code/local/Carotechs/Smsnotify/etc/adminhtml.xml
CHANGED
@@ -1,23 +1,36 @@
|
|
1 |
-
<?xml version="1.0" encoding="
|
2 |
-
<
|
3 |
-
<acl>
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0" encoding="UTF-8"?>
|
2 |
+
<config>
|
3 |
+
<acl>
|
4 |
+
<resources>
|
5 |
+
<all>
|
6 |
+
<title>Allow Everything</title>
|
7 |
+
</all>
|
8 |
+
<admin>
|
9 |
+
<children>
|
10 |
+
<!-- acl for menu -->
|
11 |
+
<customer>
|
12 |
+
<children>
|
13 |
+
<smsnotify translate="title" module="smsnotify">
|
14 |
+
<title>Send SMS</title>
|
15 |
+
<sort_order>200</sort_order>
|
16 |
+
</smsnotify>
|
17 |
+
</children>
|
18 |
+
</customer>
|
19 |
+
<!-- acl for configuration -->
|
20 |
+
<system>
|
21 |
+
<children>
|
22 |
+
<config>
|
23 |
+
<children>
|
24 |
+
<smsnotify translate="title">
|
25 |
+
<title>SMS</title>
|
26 |
+
<sort_order>100</sort_order>
|
27 |
+
</smsnotify>
|
28 |
+
</children>
|
29 |
+
</config>
|
30 |
+
</children>
|
31 |
+
</system>
|
32 |
+
</children>
|
33 |
+
</admin>
|
34 |
+
</resources>
|
35 |
+
</acl>
|
36 |
+
</config>
|
app/code/local/Carotechs/Smsnotify/etc/config.xml
CHANGED
@@ -13,31 +13,50 @@
|
|
13 |
</Carotechs_Smsnotify>
|
14 |
</modules>
|
15 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
16 |
<adminhtml>
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
<children>
|
25 |
-
<smsnotify translate="title" module="smsnotify">
|
26 |
-
<title>SMS</title>
|
27 |
-
<sort_order>0</sort_order>
|
28 |
</smsnotify>
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
|
|
|
|
|
|
37 |
</adminhtml>
|
38 |
|
39 |
|
40 |
<global>
|
|
|
|
|
|
|
|
|
|
|
|
|
41 |
<models>
|
42 |
<smsnotify>
|
43 |
<class>Carotechs_Smsnotify_Model</class>
|
13 |
</Carotechs_Smsnotify>
|
14 |
</modules>
|
15 |
|
16 |
+
|
17 |
+
<admin>
|
18 |
+
<routers>
|
19 |
+
<smsnotify>
|
20 |
+
<use>admin</use>
|
21 |
+
<args>
|
22 |
+
<module>Carotechs_Smsnotify</module>
|
23 |
+
<frontName>smsnotify</frontName>
|
24 |
+
</args>
|
25 |
+
</smsnotify>
|
26 |
+
</routers>
|
27 |
+
</admin>
|
28 |
+
|
29 |
+
|
30 |
<adminhtml>
|
31 |
+
<menu>
|
32 |
+
<customer>
|
33 |
+
<children>
|
34 |
+
<smsnotify module="smsnotify">
|
35 |
+
<title>Send SMS</title>
|
36 |
+
<sort_order>200</sort_order>
|
37 |
+
<action>smsnotify/adminhtml_smsnotify/index</action>
|
|
|
|
|
|
|
|
|
38 |
</smsnotify>
|
39 |
+
</children>
|
40 |
+
</customer>
|
41 |
+
</menu>
|
42 |
+
|
43 |
+
<layout>
|
44 |
+
<updates>
|
45 |
+
<smsnotify>
|
46 |
+
<file>smsnotify.xml</file>
|
47 |
+
</smsnotify>
|
48 |
+
</updates>
|
49 |
+
</layout>
|
50 |
</adminhtml>
|
51 |
|
52 |
|
53 |
<global>
|
54 |
+
<blocks>
|
55 |
+
<smsnotify>
|
56 |
+
<class>Carotechs_Smsnotify_Block</class>
|
57 |
+
</smsnotify>
|
58 |
+
</blocks>
|
59 |
+
|
60 |
<models>
|
61 |
<smsnotify>
|
62 |
<class>Carotechs_Smsnotify_Model</class>
|
app/design/adminhtml/default/default/layout/smsnotify.xml
ADDED
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<layout version="0.1.0">
|
3 |
+
<smsnotify_adminhtml_smsnotify_index>
|
4 |
+
<reference name="content">
|
5 |
+
<block type="smsnotify/adminhtml_smsnotify" name="smsnotify" template="smsnotify/sendsms.phtml"/>
|
6 |
+
</reference>
|
7 |
+
</smsnotify_adminhtml_smsnotify_index>
|
8 |
+
</layout>
|
app/design/adminhtml/default/default/template/smsnotify/sendsms.phtml
ADDED
@@ -0,0 +1,98 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<script type="text/javascript">
|
2 |
+
function validateValue()
|
3 |
+
{
|
4 |
+
var p_numbers = document.getElementById('phone_numbers').value;
|
5 |
+
var message = document.getElementById('text_message').value;
|
6 |
+
if(p_numbers=='' || message=='')
|
7 |
+
{
|
8 |
+
alert("Please enter all required values.");
|
9 |
+
return false;
|
10 |
+
}
|
11 |
+
else
|
12 |
+
{
|
13 |
+
var x = confirm("Are you sure to send this message?");
|
14 |
+
if(x)
|
15 |
+
{
|
16 |
+
document.getElementById('loading-mask').style.display='block';
|
17 |
+
return true;
|
18 |
+
}
|
19 |
+
else
|
20 |
+
{
|
21 |
+
return false;
|
22 |
+
}
|
23 |
+
|
24 |
+
}
|
25 |
+
}
|
26 |
+
</script>
|
27 |
+
<div id="page:main-container">
|
28 |
+
<?php
|
29 |
+
$status = Mage::getSingleton('core/session')->getSmsstatus(true);
|
30 |
+
|
31 |
+
if($status == 'success')
|
32 |
+
{
|
33 |
+
?>
|
34 |
+
<div id="messages"><ul class="messages"><li class="success-msg"><ul><li><span><?php echo Mage::getSingleton('core/session')->getSmsmsg(true);?></span></li></ul></li></ul></div>
|
35 |
+
<?php
|
36 |
+
}
|
37 |
+
if($status == 'error')
|
38 |
+
{
|
39 |
+
?>
|
40 |
+
<div id="messages"><ul class="messages"><li class="error-msg"><ul><li><span><?php echo Mage::getSingleton('core/session')->getSmsmsg(true);?></span></li></ul></li></ul></div>
|
41 |
+
<?php
|
42 |
+
}
|
43 |
+
|
44 |
+
// Mage::getSingleton('core/session')->setSmsstatus('');
|
45 |
+
?>
|
46 |
+
<div class="box-center">
|
47 |
+
|
48 |
+
<div style="display: none;" id="loading-mask">
|
49 |
+
<p id="loading_mask_loader" class="loader">
|
50 |
+
<img alt="Loading..." src="<?php echo $this->getSkinUrl('images/ajax-loader-tr.gif');?>"><br>Please wait...</p>
|
51 |
+
</div>
|
52 |
+
|
53 |
+
<!--Order Information-->
|
54 |
+
<div class="entry-edit">
|
55 |
+
|
56 |
+
<div class="entry-edit-head">
|
57 |
+
|
58 |
+
<h4 class="icon-head head-account">Send SMS Notification</h4>
|
59 |
+
|
60 |
+
</div>
|
61 |
+
<div class="fieldset" align="center">
|
62 |
+
<form method="post" action="<?php echo $this->getFormAction(); ?>" id="sendsms" name="sendsms" onsubmit="return validateValue();">
|
63 |
+
<input type="hidden" name="po_id" value=""/>
|
64 |
+
|
65 |
+
<input type="hidden" name="form_key" value="<?php echo $this->getFormKey(); ?>" />
|
66 |
+
|
67 |
+
<table cellspacing="0" class="form-list">
|
68 |
+
|
69 |
+
<tbody>
|
70 |
+
<tr>
|
71 |
+
<td class="label"><br/><label>Customer Telephone Number(s) : </label></td>
|
72 |
+
<td class="value"><br/><textarea id="phone_numbers" style="width:270px;height:50px;" name="phone_numbers"></textarea><p class="note"><span>Comma-separated.</span></p></td>
|
73 |
+
</tr>
|
74 |
+
|
75 |
+
<tr>
|
76 |
+
<td class="label"><br/><label>Message:</label></td>
|
77 |
+
<td class="value"><br/><textarea id="text_message" name="message"></textarea></td>
|
78 |
+
</tr>
|
79 |
+
|
80 |
+
|
81 |
+
|
82 |
+
<tr>
|
83 |
+
<td class="label"><br/><label></label></td>
|
84 |
+
<td align="left"><br/><input onclick="confirmsend()" type="submit" name="submit" value="Send SMS"/><p class="note"><span>Make sure that you have set all the required parameters in<br/>System->Configuration->SMS notifications section.</span></p></td>
|
85 |
+
</tr>
|
86 |
+
|
87 |
+
|
88 |
+
</tbody>
|
89 |
+
</table>
|
90 |
+
|
91 |
+
</form>
|
92 |
+
|
93 |
+
|
94 |
+
</div>
|
95 |
+
</div>
|
96 |
+
</div>
|
97 |
+
|
98 |
+
</div>
|
package.xml
CHANGED
@@ -1,18 +1,18 @@
|
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>Carotechs_Smsnotify</name>
|
4 |
-
<version>0.1.
|
5 |
<stability>stable</stability>
|
6 |
<license uri="http://opensource.org/licenses/osl-3.0.php">OSLv3.0</license>
|
7 |
<channel>community</channel>
|
8 |
<extends/>
|
9 |
-
<summary>
|
10 |
-
<description>
|
11 |
-
<notes>
|
12 |
-
<authors><author><name>
|
13 |
-
<date>2014-12-
|
14 |
-
<time>09:44
|
15 |
-
<contents><target name="mageetc"><dir name="modules"><file name="Carotechs_Smsnotify.xml" hash="cbc54fef2beda0afca8e70da6b1cb64e"/></dir></target><target name="magelocal"><dir name="Carotechs"><dir name="Smsnotify"><dir name="Helper"><file name="Data.php" hash="
|
16 |
<compatible/>
|
17 |
-
<dependencies><required><php><min>5.1.0</min><max>6.0.0</max></php></required></dependencies>
|
18 |
</package>
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>Carotechs_Smsnotify</name>
|
4 |
+
<version>0.1.6</version>
|
5 |
<stability>stable</stability>
|
6 |
<license uri="http://opensource.org/licenses/osl-3.0.php">OSLv3.0</license>
|
7 |
<channel>community</channel>
|
8 |
<extends/>
|
9 |
+
<summary>SMS notification</summary>
|
10 |
+
<description>SMS notification</description>
|
11 |
+
<notes>Sms notification</notes>
|
12 |
+
<authors><author><name>Carotechs</name><user>Carotechs</user><email>apps@carotechs.com</email></author></authors>
|
13 |
+
<date>2014-12-31</date>
|
14 |
+
<time>09:25:44</time>
|
15 |
+
<contents><target name="mageetc"><dir name="modules"><file name="Carotechs_Smsnotify.xml" hash="cbc54fef2beda0afca8e70da6b1cb64e"/></dir></target><target name="magelocal"><dir name="Carotechs"><dir name="Smsnotify"><dir name="Block"><dir name="Adminhtml"><file name="Smsnotify.php" hash="f6be5c24ff0fdf5d1f5762dc6143e5d3"/></dir></dir><dir name="Helper"><file name="Data.php" hash="2ec7d62b4b02c351c2241a0b0d648cbf"/></dir><dir name="Model"><dir name="Dropdown"><file name="Values.php" hash="c4b45a94203c6d01ad5c68254e9a47ef"/></dir><file name="Observer.php" hash="4d868dc8e1dbc7dfac8a520e986f641a"/></dir><dir name="controllers"><dir name="Adminhtml"><file name="SmsnotifyController.php" hash="264c71915d0f6cbe23ae6d3dd9975d97"/></dir></dir><dir name="etc"><file name="adminhtml.xml" hash="e99746e0ff62933de319ad34edb31ec1"/><file name="config.xml" hash="a5cb4bd1d8e7433b30600ba33e130e0d"/><file name="system.xml" hash="264f6be93060b3c9624af49cff3cac45"/></dir></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="smsnotify.xml" hash="0cec03163537aa5471b459f8698e56b4"/></dir><dir name="template"><dir name="smsnotify"><file name="sendsms.phtml" hash="a9f51355cb85c439c72b65b3236aa61a"/></dir></dir></dir></dir></dir></target></contents>
|
16 |
<compatible/>
|
17 |
+
<dependencies><required><php><min>5.1.0</min><max>6.0.0</max></php><package><name></name><channel>connect.magentocommerce.com/core</channel><min></min><max></max></package></required></dependencies>
|
18 |
</package>
|