Version Notes
Initla Release
Download this release
Release Info
Developer | Textlocal |
Extension | txtlocal_sendsms |
Version | 1.0.0 |
Comparing to | |
See all releases |
Version 1.0.0
- app/code/local/txtlocal/sendsms/Block/Adminhtml/Sendsms.php +11 -0
- app/code/local/txtlocal/sendsms/Block/Adminhtml/Sendsms/Edit.php +26 -0
- app/code/local/txtlocal/sendsms/Block/Adminhtml/Sendsms/Edit/Form.php +19 -0
- app/code/local/txtlocal/sendsms/Block/Adminhtml/Sendsms/Edit/Tab/Form.php +44 -0
- app/code/local/txtlocal/sendsms/Block/Adminhtml/Sendsms/Edit/Tabs.php +24 -0
- app/code/local/txtlocal/sendsms/Block/Adminhtml/Sendsms/Grid.php +89 -0
- app/code/local/txtlocal/sendsms/Block/Buttons.php +19 -0
- app/code/local/txtlocal/sendsms/Block/Sendsms.php +17 -0
- app/code/local/txtlocal/sendsms/Block/System/Config/Buycredits.php +22 -0
- app/code/local/txtlocal/sendsms/Block/System/Config/Info.php +23 -0
- app/code/local/txtlocal/sendsms/Helper/Data.php +182 -0
- app/code/local/txtlocal/sendsms/Model/Mysql4/Sendsms.php +10 -0
- app/code/local/txtlocal/sendsms/Model/Mysql4/Sendsms/Collection.php +10 -0
- app/code/local/txtlocal/sendsms/Model/Observer.php +223 -0
- app/code/local/txtlocal/sendsms/Model/Sendsms.php +10 -0
- app/code/local/txtlocal/sendsms/controllers/Adminhtml/SendsmsController.php +173 -0
- app/code/local/txtlocal/sendsms/controllers/IndexController.php +9 -0
- app/code/local/txtlocal/sendsms/etc/config.xml +219 -0
- app/code/local/txtlocal/sendsms/etc/system.xml +300 -0
- app/code/local/txtlocal/sendsms/sql/sendsms_setup/mysql4-install-1.0.0.php +24 -0
- app/etc/modules/txtlocal_sendsms.xml +9 -0
- package.xml +18 -0
app/code/local/txtlocal/sendsms/Block/Adminhtml/Sendsms.php
ADDED
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class txtlocal_sendsms_Block_Adminhtml_Sendsms extends Mage_Adminhtml_Block_Widget_Grid_Container
|
3 |
+
{
|
4 |
+
public function __construct()
|
5 |
+
{
|
6 |
+
$this->_controller = 'adminhtml_sendsms';
|
7 |
+
$this->_blockGroup = 'sendsms';
|
8 |
+
$this->_addButtonLabel = Mage::helper('sendsms')->__('Send Manual SMS');
|
9 |
+
parent::__construct();
|
10 |
+
}
|
11 |
+
}
|
app/code/local/txtlocal/sendsms/Block/Adminhtml/Sendsms/Edit.php
ADDED
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class txtlocal_sendsms_Block_Adminhtml_Sendsms_Edit extends Mage_Adminhtml_Block_Widget_Form_Container
|
4 |
+
{
|
5 |
+
public function __construct()
|
6 |
+
{
|
7 |
+
parent::__construct();
|
8 |
+
|
9 |
+
$this->_objectId = 'id';
|
10 |
+
$this->_blockGroup = 'sendsms';
|
11 |
+
$this->_controller = 'adminhtml_sendsms';
|
12 |
+
|
13 |
+
$this->_updateButton('save', 'label', Mage::helper('sendsms')->__('Send SMS'));
|
14 |
+
$this->_updateButton('delete', 'label', Mage::helper('sendsms')->__('Delete Item'));
|
15 |
+
|
16 |
+
}
|
17 |
+
|
18 |
+
public function getHeaderText()
|
19 |
+
{
|
20 |
+
if( Mage::registry('sendsms_data') && Mage::registry('sendsms_data')->getId() ) {
|
21 |
+
return Mage::helper('sendsms')->__("Edit Item '%s'", $this->htmlEscape(Mage::registry('sendsms_data')->getTitle()));
|
22 |
+
} else {
|
23 |
+
return Mage::helper('sendsms')->__('Send Manual SMS');
|
24 |
+
}
|
25 |
+
}
|
26 |
+
}
|
app/code/local/txtlocal/sendsms/Block/Adminhtml/Sendsms/Edit/Form.php
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class txtlocal_sendsms_Block_Adminhtml_Sendsms_Edit_Form extends Mage_Adminhtml_Block_Widget_Form
|
4 |
+
{
|
5 |
+
protected function _prepareForm()
|
6 |
+
{
|
7 |
+
$form = new Varien_Data_Form(array(
|
8 |
+
'id' => 'edit_form',
|
9 |
+
'action' => $this->getUrl('*/*/save', array('id' => $this->getRequest()->getParam('id'))),
|
10 |
+
'method' => 'post',
|
11 |
+
'enctype' => 'multipart/form-data'
|
12 |
+
)
|
13 |
+
);
|
14 |
+
|
15 |
+
$form->setUseContainer(true);
|
16 |
+
$this->setForm($form);
|
17 |
+
return parent::_prepareForm();
|
18 |
+
}
|
19 |
+
}
|
app/code/local/txtlocal/sendsms/Block/Adminhtml/Sendsms/Edit/Tab/Form.php
ADDED
@@ -0,0 +1,44 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class txtlocal_sendsms_Block_Adminhtml_Sendsms_Edit_Tab_Form extends Mage_Adminhtml_Block_Widget_Form
|
4 |
+
{
|
5 |
+
protected function _prepareForm()
|
6 |
+
{
|
7 |
+
$form = new Varien_Data_Form();
|
8 |
+
$this->setForm($form);
|
9 |
+
$fieldset = $form->addFieldset('sendsms_form', array('legend'=>Mage::helper('sendsms')->__('SMS information')));
|
10 |
+
|
11 |
+
$fieldset->addField('from', 'text', array(
|
12 |
+
'label' => Mage::helper('sendsms')->__('From'),
|
13 |
+
'required' => true,
|
14 |
+
'name' => 'from',
|
15 |
+
'after_element_html' => '<br/><small>'.Mage::helper('sendsms')->__('Name or Telephone').'</small>',
|
16 |
+
));
|
17 |
+
|
18 |
+
$fieldset->addField('to', 'text', array(
|
19 |
+
'label' => Mage::helper('sendsms')->__('To (or Order number)'),
|
20 |
+
'required' => true,
|
21 |
+
'name' => 'to',
|
22 |
+
'after_element_html' => '<br/><small>'.Mage::helper('sendsms')->__('Telephone (ex: +40740123456 or 100000001)').'</small>',
|
23 |
+
));
|
24 |
+
|
25 |
+
$fieldset->addField('sms_message', 'editor', array(
|
26 |
+
'name' => 'sms_message',
|
27 |
+
'label' => Mage::helper('sendsms')->__('Message'),
|
28 |
+
'title' => Mage::helper('sendsms')->__('Message'),
|
29 |
+
'style' => 'width:274px; height:15em;',
|
30 |
+
'after_element_html' => Mage::helper('sendsms')->__('Message Template (160 characters)'),
|
31 |
+
'wysiwyg' => false,
|
32 |
+
'required' => true,
|
33 |
+
));
|
34 |
+
|
35 |
+
if ( Mage::getSingleton('adminhtml/session')->getSendsmsData() )
|
36 |
+
{
|
37 |
+
$form->setValues(Mage::getSingleton('adminhtml/session')->getSendsmsData());
|
38 |
+
Mage::getSingleton('adminhtml/session')->setSendsmsData(null);
|
39 |
+
} elseif ( Mage::registry('sendsms_data') ) {
|
40 |
+
$form->setValues(Mage::registry('sendsms_data')->getData());
|
41 |
+
}
|
42 |
+
return parent::_prepareForm();
|
43 |
+
}
|
44 |
+
}
|
app/code/local/txtlocal/sendsms/Block/Adminhtml/Sendsms/Edit/Tabs.php
ADDED
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class txtlocal_sendsms_Block_Adminhtml_Sendsms_Edit_Tabs extends Mage_Adminhtml_Block_Widget_Tabs
|
4 |
+
{
|
5 |
+
|
6 |
+
public function __construct()
|
7 |
+
{
|
8 |
+
parent::__construct();
|
9 |
+
$this->setId('sendsms_tabs');
|
10 |
+
$this->setDestElementId('edit_form');
|
11 |
+
$this->setTitle(Mage::helper('sendsms')->__('SMS Information'));
|
12 |
+
}
|
13 |
+
|
14 |
+
protected function _beforeToHtml()
|
15 |
+
{
|
16 |
+
$this->addTab('form_section', array(
|
17 |
+
'label' => Mage::helper('sendsms')->__('SMS Information'),
|
18 |
+
'title' => Mage::helper('sendsms')->__('SMS Information'),
|
19 |
+
'content' => $this->getLayout()->createBlock('sendsms/adminhtml_sendsms_edit_tab_form')->toHtml(),
|
20 |
+
));
|
21 |
+
|
22 |
+
return parent::_beforeToHtml();
|
23 |
+
}
|
24 |
+
}
|
app/code/local/txtlocal/sendsms/Block/Adminhtml/Sendsms/Grid.php
ADDED
@@ -0,0 +1,89 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class txtlocal_sendsms_Block_Adminhtml_Sendsms_Grid extends Mage_Adminhtml_Block_Widget_Grid
|
4 |
+
{
|
5 |
+
public function __construct()
|
6 |
+
{
|
7 |
+
parent::__construct();
|
8 |
+
$this->setId('sendsmsGrid');
|
9 |
+
$this->setDefaultSort('sendsms_id');
|
10 |
+
$this->setDefaultDir('DESC');
|
11 |
+
$this->setSaveParametersInSession(true);
|
12 |
+
}
|
13 |
+
|
14 |
+
protected function _prepareCollection()
|
15 |
+
{
|
16 |
+
$collection = Mage::getModel('sendsms/sendsms')->getCollection();
|
17 |
+
$this->setCollection($collection);
|
18 |
+
return parent::_prepareCollection();
|
19 |
+
}
|
20 |
+
|
21 |
+
protected function _prepareColumns()
|
22 |
+
{
|
23 |
+
$this->addColumn('sendsms_id', array(
|
24 |
+
'header' => Mage::helper('sendsms')->__('ID'),
|
25 |
+
'align' =>'right',
|
26 |
+
'width' => '50px',
|
27 |
+
'index' => 'sendsms_id',
|
28 |
+
));
|
29 |
+
|
30 |
+
$this->addColumn('order_id', array(
|
31 |
+
'header' => Mage::helper('sendsms')->__('Order Id'),
|
32 |
+
'align' =>'left',
|
33 |
+
'index' => 'order_id',
|
34 |
+
));
|
35 |
+
|
36 |
+
$this->addColumn('from', array(
|
37 |
+
'header' => Mage::helper('sendsms')->__('From'),
|
38 |
+
'align' =>'left',
|
39 |
+
'index' => 'from',
|
40 |
+
));
|
41 |
+
|
42 |
+
$this->addColumn('to', array(
|
43 |
+
'header' => Mage::helper('sendsms')->__('To'),
|
44 |
+
'align' =>'left',
|
45 |
+
'index' => 'to',
|
46 |
+
));
|
47 |
+
|
48 |
+
$this->addColumn('sms_message', array(
|
49 |
+
'header' => Mage::helper('sendsms')->__('SMS Message'),
|
50 |
+
'align' =>'left',
|
51 |
+
'index' => 'sms_message',
|
52 |
+
));
|
53 |
+
|
54 |
+
$this->addColumn('status', array(
|
55 |
+
'header' => Mage::helper('sendsms')->__('Status'),
|
56 |
+
'align' =>'left',
|
57 |
+
'index' => 'status',
|
58 |
+
));
|
59 |
+
|
60 |
+
$this->addColumn('status_message', array(
|
61 |
+
'header' => Mage::helper('sendsms')->__('Status Message'),
|
62 |
+
'align' =>'left',
|
63 |
+
'index' => 'status_message',
|
64 |
+
));
|
65 |
+
|
66 |
+
$this->addColumn('created_time', array(
|
67 |
+
'header' => Mage::helper('sendsms')->__('Created Time'),
|
68 |
+
'align' =>'left',
|
69 |
+
'index' => 'created_time',
|
70 |
+
'type' => 'datetime',
|
71 |
+
));
|
72 |
+
|
73 |
+
return parent::_prepareColumns();
|
74 |
+
}
|
75 |
+
|
76 |
+
protected function _prepareMassaction()
|
77 |
+
{
|
78 |
+
$this->setMassactionIdField('sendsms_id');
|
79 |
+
$this->getMassactionBlock()->setFormFieldName('sendsms');
|
80 |
+
|
81 |
+
$this->getMassactionBlock()->addItem('delete', array(
|
82 |
+
'label' => Mage::helper('sendsms')->__('Delete'),
|
83 |
+
'url' => $this->getUrl('*/*/massDelete'),
|
84 |
+
'confirm' => Mage::helper('sendsms')->__('Are you sure?')
|
85 |
+
));
|
86 |
+
|
87 |
+
return $this;
|
88 |
+
}
|
89 |
+
}
|
app/code/local/txtlocal/sendsms/Block/Buttons.php
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class txtlocal_sendsms_Block_Buttons extends Mage_Adminhtml_Block_System_Config_Form_Field
|
3 |
+
{
|
4 |
+
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
|
5 |
+
{
|
6 |
+
$this->setElement($element);
|
7 |
+
$url = 'http://control.txtlocal.co.uk';
|
8 |
+
|
9 |
+
$html = $this->getLayout()->createBlock('adminhtml/widget_button')
|
10 |
+
->setType('button')
|
11 |
+
->setClass('button')
|
12 |
+
->setLabel(Mage::helper('sendsms')->__('Get an Account'))
|
13 |
+
->setOnClick("window.open('$url','window1','width=870, height=705, scrollbars=1, resizable=1'); return false;")
|
14 |
+
->toHtml();
|
15 |
+
|
16 |
+
return $html;
|
17 |
+
}
|
18 |
+
}
|
19 |
+
?>
|
app/code/local/txtlocal/sendsms/Block/Sendsms.php
ADDED
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class txtlocal_sendsms_Block_Sendsms extends Mage_Core_Block_Template
|
3 |
+
{
|
4 |
+
public function _prepareLayout()
|
5 |
+
{
|
6 |
+
return parent::_prepareLayout();
|
7 |
+
}
|
8 |
+
|
9 |
+
public function getSendsms()
|
10 |
+
{
|
11 |
+
if (!$this->hasData('sendsms')) {
|
12 |
+
$this->setData('sendsms', Mage::registry('sendsms'));
|
13 |
+
}
|
14 |
+
return $this->getData('sendsms');
|
15 |
+
|
16 |
+
}
|
17 |
+
}
|
app/code/local/txtlocal/sendsms/Block/System/Config/Buycredits.php
ADDED
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class txtlocal_sendsms_Block_System_Config_Buycredits
|
3 |
+
extends Mage_Adminhtml_Block_Abstract
|
4 |
+
implements Varien_Data_Form_Element_Renderer_Interface
|
5 |
+
{
|
6 |
+
|
7 |
+
/**
|
8 |
+
* Render fieldset html
|
9 |
+
*
|
10 |
+
* @param Varien_Data_Form_Element_Abstract $element
|
11 |
+
* @return string
|
12 |
+
*/
|
13 |
+
public function render(Varien_Data_Form_Element_Abstract $element)
|
14 |
+
{
|
15 |
+
$html = '<div style="margin-bottom:10px;padding:10px 5px 5px;">
|
16 |
+
<iframe src="https://control.txtlocal.co.uk/order/" width="100%" height="705px"></iframe>
|
17 |
+
</div>';
|
18 |
+
//display iFrame of buy credits page!
|
19 |
+
|
20 |
+
return $html;
|
21 |
+
}
|
22 |
+
}
|
app/code/local/txtlocal/sendsms/Block/System/Config/Info.php
ADDED
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class txtlocal_sendsms_Block_System_Config_Info
|
3 |
+
extends Mage_Adminhtml_Block_Abstract
|
4 |
+
implements Varien_Data_Form_Element_Renderer_Interface
|
5 |
+
{
|
6 |
+
|
7 |
+
/**
|
8 |
+
* Render fieldset html
|
9 |
+
*
|
10 |
+
* @param Varien_Data_Form_Element_Abstract $element
|
11 |
+
* @return string
|
12 |
+
*/
|
13 |
+
public function render(Varien_Data_Form_Element_Abstract $element)
|
14 |
+
{
|
15 |
+
$html = '<div style="border:1px solid #CCCCCC;margin-bottom:10px;padding:10px 5px 5px;">
|
16 |
+
<h4>Magento SMS - powered by TextLocal</h4>
|
17 |
+
<p>Find out more <a href="http://www.txtlocal.com" target="_blank">about us</a></p>
|
18 |
+
<p>If you have any questions or need any help, feel free to contact us at <a href="mailto:support@txtlocal.com">support@txtlocal.com</a></p>
|
19 |
+
</div>';
|
20 |
+
|
21 |
+
return $html;
|
22 |
+
}
|
23 |
+
}
|
app/code/local/txtlocal/sendsms/Helper/Data.php
ADDED
@@ -0,0 +1,182 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class txtlocal_sendsms_Helper_Data extends Mage_Core_Helper_Abstract
|
4 |
+
{
|
5 |
+
const CONFIG_PATH = 'sendsms/';
|
6 |
+
|
7 |
+
public function isOrdersEnabled()
|
8 |
+
{
|
9 |
+
return Mage::getStoreConfig(self::CONFIG_PATH.'orders/enabled');
|
10 |
+
}
|
11 |
+
|
12 |
+
public function isGroupEnabled()
|
13 |
+
{
|
14 |
+
return Mage::getStoreConfig(self::CONFIG_PATH.'orders/contacts');
|
15 |
+
}
|
16 |
+
|
17 |
+
public function isOrderHoldEnabled()
|
18 |
+
{
|
19 |
+
return Mage::getStoreConfig(self::CONFIG_PATH.'order_hold/enabled');
|
20 |
+
}
|
21 |
+
|
22 |
+
public function isOrderUnholdEnabled()
|
23 |
+
{
|
24 |
+
return Mage::getStoreConfig(self::CONFIG_PATH.'order_unhold/enabled');
|
25 |
+
}
|
26 |
+
|
27 |
+
public function isOrderCanceledEnabled()
|
28 |
+
{
|
29 |
+
return Mage::getStoreConfig(self::CONFIG_PATH.'order_canceled/enabled');
|
30 |
+
}
|
31 |
+
|
32 |
+
public function isShipmentsEnabled()
|
33 |
+
{
|
34 |
+
return Mage::getStoreConfig(self::CONFIG_PATH.'shipments/enabled');
|
35 |
+
}
|
36 |
+
|
37 |
+
public function getUsername()
|
38 |
+
{
|
39 |
+
return Mage::getStoreConfig(self::CONFIG_PATH.'general/username');
|
40 |
+
}
|
41 |
+
|
42 |
+
public function getPassword()
|
43 |
+
{
|
44 |
+
return Mage::getStoreConfig(self::CONFIG_PATH.'general/password');
|
45 |
+
}
|
46 |
+
|
47 |
+
public function getSender()
|
48 |
+
{
|
49 |
+
return Mage::getStoreConfig(self::CONFIG_PATH.'orders/sender');
|
50 |
+
}
|
51 |
+
|
52 |
+
public function getSenderForOrderHold()
|
53 |
+
{
|
54 |
+
return Mage::getStoreConfig(self::CONFIG_PATH.'order_hold/sender');
|
55 |
+
}
|
56 |
+
|
57 |
+
public function getSenderForOrderUnhold()
|
58 |
+
{
|
59 |
+
return Mage::getStoreConfig(self::CONFIG_PATH.'order_unhold/sender');
|
60 |
+
}
|
61 |
+
|
62 |
+
public function getSenderForOrderCanceled()
|
63 |
+
{
|
64 |
+
return Mage::getStoreConfig(self::CONFIG_PATH.'order_canceled/sender');
|
65 |
+
}
|
66 |
+
|
67 |
+
public function getSenderForShipment()
|
68 |
+
{
|
69 |
+
return Mage::getStoreConfig(self::CONFIG_PATH.'shipments/sender');
|
70 |
+
}
|
71 |
+
|
72 |
+
public function getMessage(Mage_Sales_Model_Order $order)
|
73 |
+
{
|
74 |
+
$billingAddress = $order->getBillingAddress();
|
75 |
+
$whatArray = array('{{firstname}}');
|
76 |
+
$withWhatArray = array($billingAddress->getFirstname());
|
77 |
+
|
78 |
+
return str_replace($whatArray,$withWhatArray,Mage::getStoreConfig(self::CONFIG_PATH.'orders/message'));
|
79 |
+
}
|
80 |
+
|
81 |
+
public function getMessageForOrderHold(Mage_Sales_Model_Order $order)
|
82 |
+
{
|
83 |
+
$billingAddress = $order->getBillingAddress();
|
84 |
+
$whatArray = array('{{firstname}}','{{order_id}}');
|
85 |
+
$withWhatArray = array($billingAddress->getFirstname(),$order->getIncrementId());
|
86 |
+
|
87 |
+
return str_replace($whatArray,$withWhatArray,Mage::getStoreConfig(self::CONFIG_PATH.'order_hold/message'));
|
88 |
+
}
|
89 |
+
|
90 |
+
public function getMessageForOrderUnhold(Mage_Sales_Model_Order $order)
|
91 |
+
{
|
92 |
+
$billingAddress = $order->getBillingAddress();
|
93 |
+
$whatArray = array('{{firstname}}','{{order_id}}');
|
94 |
+
$withWhatArray = array($billingAddress->getFirstname(),$order->getIncrementId());
|
95 |
+
|
96 |
+
return str_replace($whatArray,$withWhatArray,Mage::getStoreConfig(self::CONFIG_PATH.'order_unhold/message'));
|
97 |
+
}
|
98 |
+
|
99 |
+
public function getMessageForOrderCanceled(Mage_Sales_Model_Order $order)
|
100 |
+
{
|
101 |
+
$billingAddress = $order->getBillingAddress();
|
102 |
+
$whatArray = array('{{firstname}}','{{order_id}}');
|
103 |
+
$withWhatArray = array($billingAddress->getFirstname(),$order->getIncrementId());
|
104 |
+
|
105 |
+
return str_replace($whatArray,$withWhatArray,Mage::getStoreConfig(self::CONFIG_PATH.'order_canceled/message'));
|
106 |
+
}
|
107 |
+
|
108 |
+
public function getMessageForShipment(Mage_Sales_Model_Order $order)
|
109 |
+
{
|
110 |
+
$billingAddress = $order->getBillingAddress();
|
111 |
+
$whatArray = array('{{firstname}}','{{order_id}}');
|
112 |
+
$withWhatArray = array($billingAddress->getFirstname(),$order->getIncrementId());
|
113 |
+
|
114 |
+
return str_replace($whatArray,$withWhatArray,Mage::getStoreConfig(self::CONFIG_PATH.'shipments/message'));
|
115 |
+
}
|
116 |
+
|
117 |
+
public function getNameForOrder(Mage_Sales_Model_Order $order)
|
118 |
+
{
|
119 |
+
$billingAddress = $order->getBillingAddress();
|
120 |
+
$withWhatArray = array('firstname' => $billingAddress->getFirstname(), 'lastname' => $order->getCustomerLastname());
|
121 |
+
|
122 |
+
return $withWhatArray;
|
123 |
+
}
|
124 |
+
|
125 |
+
public function getTelephoneFromOrder(Mage_Sales_Model_Order $order)
|
126 |
+
{
|
127 |
+
$billingAddress = $order->getBillingAddress();
|
128 |
+
|
129 |
+
$number = $billingAddress->getTelephone();
|
130 |
+
$number = preg_replace('#[^\+\d]#', '', trim($number));
|
131 |
+
|
132 |
+
if (substr($number, 0, 1) === '+') {
|
133 |
+
$number = substr($number, 1);
|
134 |
+
} elseif (substr($number, 0, 2) === '00') {
|
135 |
+
$number = substr($number, 2);
|
136 |
+
} else {
|
137 |
+
if (substr($number, 0, 1) === '0') {
|
138 |
+
$number = substr($number, 1);
|
139 |
+
}
|
140 |
+
$expectedPrefix = Zend_Locale_Data::getContent(Mage::app()->getLocale()->getLocale(), 'phonetoterritory', $billingAddress->getCountry());
|
141 |
+
if (!empty($expectedPrefix)) {
|
142 |
+
$prefix = substr($number, 0, strlen($expectedPrefix));
|
143 |
+
if ($prefix !== $expectedPrefix) {
|
144 |
+
$number = $expectedPrefix . $number;
|
145 |
+
}
|
146 |
+
}
|
147 |
+
}
|
148 |
+
$number = preg_replace('#[^\d]#', '', trim($number));
|
149 |
+
|
150 |
+
return $number;
|
151 |
+
}
|
152 |
+
|
153 |
+
public function isOrdersNotify()
|
154 |
+
{
|
155 |
+
return Mage::getStoreConfig(self::CONFIG_PATH.'orders/notify');
|
156 |
+
}
|
157 |
+
|
158 |
+
public function getAdminTelephone()
|
159 |
+
{
|
160 |
+
return Mage::getStoreConfig(self::CONFIG_PATH.'orders/receiver');
|
161 |
+
}
|
162 |
+
|
163 |
+
public function sendSms($url) {
|
164 |
+
try {
|
165 |
+
$sendSms = $this->file_get_contents_curl($url);
|
166 |
+
}
|
167 |
+
catch(Exception $e) {
|
168 |
+
$sendSms = '';
|
169 |
+
}
|
170 |
+
return $sendSms;
|
171 |
+
}
|
172 |
+
|
173 |
+
public function file_get_contents_curl($url) {
|
174 |
+
$ch = curl_init($url);
|
175 |
+
|
176 |
+
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
177 |
+
$response = curl_exec($ch);
|
178 |
+
curl_close($ch);
|
179 |
+
|
180 |
+
return $response;
|
181 |
+
}
|
182 |
+
}
|
app/code/local/txtlocal/sendsms/Model/Mysql4/Sendsms.php
ADDED
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class txtlocal_sendsms_Model_Mysql4_Sendsms extends Mage_Core_Model_Mysql4_Abstract
|
4 |
+
{
|
5 |
+
public function _construct()
|
6 |
+
{
|
7 |
+
// Note that the sendsms_id refers to the key field in your database table.
|
8 |
+
$this->_init('sendsms/sendsms', 'sendsms_id');
|
9 |
+
}
|
10 |
+
}
|
app/code/local/txtlocal/sendsms/Model/Mysql4/Sendsms/Collection.php
ADDED
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class txtlocal_sendsms_Model_Mysql4_Sendsms_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
|
4 |
+
{
|
5 |
+
public function _construct()
|
6 |
+
{
|
7 |
+
parent::_construct();
|
8 |
+
$this->_init('sendsms/sendsms');
|
9 |
+
}
|
10 |
+
}
|
app/code/local/txtlocal/sendsms/Model/Observer.php
ADDED
@@ -0,0 +1,223 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class txtlocal_sendsms_Model_Observer
|
3 |
+
{
|
4 |
+
public function sendSmsOnOrderCreated(Varien_Event_Observer $observer)
|
5 |
+
{
|
6 |
+
if($this->getHelper()->isOrdersEnabled()) {
|
7 |
+
$orders = $observer->getEvent()->getOrderIds();
|
8 |
+
$order = Mage::getModel('sales/order')->load($orders['0']);
|
9 |
+
if ($order instanceof Mage_Sales_Model_Order) {
|
10 |
+
$host = "http://api.txtlocal.com/send/";
|
11 |
+
$username = $this->getHelper()->getUsername();
|
12 |
+
$password = $this->getHelper()->getPassword();
|
13 |
+
$smsto = $this->getHelper()->getTelephoneFromOrder($order);
|
14 |
+
$smsfrom = $this->getHelper()->getSender();
|
15 |
+
$smsmsg = $this->getHelper()->getMessage($order);
|
16 |
+
$data = '?username=' . urlencode($username);
|
17 |
+
$data .= '&hash=' . urlencode($password);
|
18 |
+
$data .= '&numbers=' . urlencode($smsto);
|
19 |
+
$data .= '&sender=' . urlencode($smsfrom);
|
20 |
+
$data .= '&message=' . urlencode($smsmsg);
|
21 |
+
$url = $host.$data;
|
22 |
+
$sendSms = $this->getHelper()->sendSms($url);
|
23 |
+
if($this->getHelper()->isGroupEnabled()){
|
24 |
+
$host = "http://api.txtlocal.com/create_contacts_bulk/";
|
25 |
+
$newData = '?username=' . urlencode($username);
|
26 |
+
$newData .= '&hash=' . urlencode($password);
|
27 |
+
$newData .= '&group_id=5';
|
28 |
+
$names = $this->getHelper()->getNameForOrder($order);
|
29 |
+
$firstName = $names['firstname'];
|
30 |
+
$lastName = $names['lastname'];
|
31 |
+
$contacts = urlencode(json_encode(array(array('number' => $smsto, 'first_name' => $firstName, 'last_name' => $lastName))));
|
32 |
+
$newData .= '&contacts=' . $contacts;
|
33 |
+
$url = $host.$newData;
|
34 |
+
$this->getHelper()->sendSms($url);
|
35 |
+
}
|
36 |
+
try {
|
37 |
+
Mage::getModel('sendsms/sendsms')
|
38 |
+
->setOrderId($order->getIncrementId())
|
39 |
+
->setFrom($smsfrom)
|
40 |
+
->setTo($smsto)
|
41 |
+
->setSmsMessage($smsmsg)
|
42 |
+
->setStatus($sendSms['status'])
|
43 |
+
->setStatusMessage($sendSms['status_message'])
|
44 |
+
->setCreatedTime(now())
|
45 |
+
->save();
|
46 |
+
}
|
47 |
+
catch (Exception $e) {}
|
48 |
+
|
49 |
+
if($this->getHelper()->isOrdersNotify() and $this->getHelper()->getAdminTelephone()) {
|
50 |
+
$smsto = $this->getHelper()->getAdminTelephone();
|
51 |
+
$smsmsg = Mage::helper('sendsms')->__('A new order has been placed: %s',$order->getIncrementId());
|
52 |
+
$data = '?username=' . urlencode($username);
|
53 |
+
$data .= '&hash=' . urlencode($password);
|
54 |
+
$data .= '&numbers=' . urlencode($smsto);
|
55 |
+
$data .= '&sender=' . urlencode($smsfrom);
|
56 |
+
$data .= '&message=' . urlencode($smsmsg);
|
57 |
+
$url = $host.$data;
|
58 |
+
$sendSms = $this->getHelper()->sendSms($url);
|
59 |
+
try {
|
60 |
+
Mage::getModel('sendsms/sendsms')
|
61 |
+
->setOrderId($order->getIncrementId())
|
62 |
+
->setFrom($smsfrom)
|
63 |
+
->setTo($smsto)
|
64 |
+
->setSmsMessage($smsmsg)
|
65 |
+
->setStatus($sendSms['status'])
|
66 |
+
->setStatusMessage($sendSms['status_message'])
|
67 |
+
->setCreatedTime(now())
|
68 |
+
->save();
|
69 |
+
}
|
70 |
+
catch (Exception $e) {}
|
71 |
+
}
|
72 |
+
}
|
73 |
+
}
|
74 |
+
}
|
75 |
+
|
76 |
+
public function sendSmsOnOrderHold(Varien_Event_Observer $observer)
|
77 |
+
{
|
78 |
+
if($this->getHelper()->isOrderHoldEnabled()) {
|
79 |
+
$order = $observer->getOrder();
|
80 |
+
if ($order instanceof Mage_Sales_Model_Order) {
|
81 |
+
if ($order->getState() !== $order->getOrigData('state') && $order->getState() === Mage_Sales_Model_Order::STATE_HOLDED) {
|
82 |
+
$host = "http://api.txtlocal.com/send/";
|
83 |
+
$username = $this->getHelper()->getUsername();
|
84 |
+
$password = $this->getHelper()->getPassword();
|
85 |
+
$smsto = $this->getHelper()->getTelephoneFromOrder($order);
|
86 |
+
$smsfrom = $this->getHelper()->getSenderForOrderHold();
|
87 |
+
$smsmsg = $this->getHelper()->getMessageForOrderHold($order);
|
88 |
+
$data = '?username=' . urlencode($username);
|
89 |
+
$data .= '&hash=' . urlencode($password);
|
90 |
+
$data .= '&numbers=' . urlencode($smsto);
|
91 |
+
$data .= '&sender=' . urlencode($smsfrom);
|
92 |
+
$data .= '&message=' . urlencode($smsmsg);
|
93 |
+
$url = $host.$data;
|
94 |
+
$sendSms = $this->getHelper()->sendSms($url);
|
95 |
+
try {
|
96 |
+
Mage::getModel('sendsms/sendsms')
|
97 |
+
->setOrderId($order->getIncrementId())
|
98 |
+
->setFrom($smsfrom)
|
99 |
+
->setTo($smsto)
|
100 |
+
->setSmsMessage($smsmsg)
|
101 |
+
->setStatus($sendSms['status'])
|
102 |
+
->setStatusMessage($sendSms['status_message'])
|
103 |
+
->setCreatedTime(now())
|
104 |
+
->save();
|
105 |
+
}
|
106 |
+
catch (Exception $e) {}
|
107 |
+
}
|
108 |
+
}
|
109 |
+
}
|
110 |
+
}
|
111 |
+
|
112 |
+
public function sendSmsOnOrderUnhold(Varien_Event_Observer $observer)
|
113 |
+
{
|
114 |
+
if($this->getHelper()->isOrderUnholdEnabled()) {
|
115 |
+
$order = $observer->getOrder();
|
116 |
+
if ($order instanceof Mage_Sales_Model_Order) {
|
117 |
+
if ($order->getState() !== $order->getOrigData('state') && $order->getOrigData('state') === Mage_Sales_Model_Order::STATE_HOLDED) {
|
118 |
+
$host = "http://api.txtlocal.com/send/";
|
119 |
+
$username = $this->getHelper()->getUsername();
|
120 |
+
$password = $this->getHelper()->getPassword();
|
121 |
+
$smsto = $this->getHelper()->getTelephoneFromOrder($order);
|
122 |
+
$smsfrom = $this->getHelper()->getSenderForOrderHold();
|
123 |
+
$smsmsg = $this->getHelper()->getMessageForOrderHold($order);
|
124 |
+
$data = '?username=' . urlencode($username);
|
125 |
+
$data .= '&hash=' . urlencode($password);
|
126 |
+
$data .= '&numbers=' . urlencode($smsto);
|
127 |
+
$data .= '&sender=' . urlencode($smsfrom);
|
128 |
+
$data .= '&message=' . urlencode($smsmsg);
|
129 |
+
$url = $host.$data;
|
130 |
+
$sendSms = $this->getHelper()->sendSms($url);
|
131 |
+
try {
|
132 |
+
Mage::getModel('sendsms/sendsms')
|
133 |
+
->setOrderId($order->getIncrementId())
|
134 |
+
->setFrom($smsfrom)
|
135 |
+
->setTo($smsto)
|
136 |
+
->setSmsMessage($smsmsg)
|
137 |
+
->setStatus($sendSms['status'])
|
138 |
+
->setStatusMessage($sendSms['status_message'])
|
139 |
+
->setCreatedTime(now())
|
140 |
+
->save();
|
141 |
+
}
|
142 |
+
catch (Exception $e) {}
|
143 |
+
}
|
144 |
+
}
|
145 |
+
}
|
146 |
+
}
|
147 |
+
|
148 |
+
public function sendSmsOnOrderCanceled(Varien_Event_Observer $observer)
|
149 |
+
{
|
150 |
+
if($this->getHelper()->isOrderCanceledEnabled()) {
|
151 |
+
$order = $observer->getOrder();
|
152 |
+
if ($order instanceof Mage_Sales_Model_Order) {
|
153 |
+
if ($order->getState() !== $order->getOrigData('state') && $order->getState() === Mage_Sales_Model_Order::STATE_CANCELED) {
|
154 |
+
$host = "http://api.txtlocal.com/send/";
|
155 |
+
$username = $this->getHelper()->getUsername();
|
156 |
+
$password = $this->getHelper()->getPassword();
|
157 |
+
$smsto = $this->getHelper()->getTelephoneFromOrder($order);
|
158 |
+
$smsfrom = $this->getHelper()->getSenderForOrderHold();
|
159 |
+
$smsmsg = $this->getHelper()->getMessageForOrderHold($order);
|
160 |
+
$data = '?username=' . urlencode($username);
|
161 |
+
$data .= '&hash=' . urlencode($password);
|
162 |
+
$data .= '&numbers=' . urlencode($smsto);
|
163 |
+
$data .= '&sender=' . urlencode($smsfrom);
|
164 |
+
$data .= '&message=' . urlencode($smsmsg);
|
165 |
+
$url = $host.$data;
|
166 |
+
$sendSms = $this->getHelper()->sendSms($url);
|
167 |
+
try {
|
168 |
+
Mage::getModel('sendsms/sendsms')
|
169 |
+
->setOrderId($order->getIncrementId())
|
170 |
+
->setFrom($smsfrom)
|
171 |
+
->setTo($smsto)
|
172 |
+
->setSmsMessage($smsmsg)
|
173 |
+
->setStatus($sendSms['status'])
|
174 |
+
->setStatusMessage($sendSms['status_message'])
|
175 |
+
->setCreatedTime(now())
|
176 |
+
->save();
|
177 |
+
}
|
178 |
+
catch (Exception $e) {}
|
179 |
+
}
|
180 |
+
}
|
181 |
+
}
|
182 |
+
}
|
183 |
+
|
184 |
+
public function sendSmsOnShipmentCreated(Varien_Event_Observer $observer)
|
185 |
+
{
|
186 |
+
if($this->getHelper()->isShipmentsEnabled()) {
|
187 |
+
$shipment = $observer->getEvent()->getShipment();
|
188 |
+
$order = $shipment->getOrder();
|
189 |
+
if ($order instanceof Mage_Sales_Model_Order) {
|
190 |
+
$host = "http://api.txtlocal.com/send/";
|
191 |
+
$username = $this->getHelper()->getUsername();
|
192 |
+
$password = $this->getHelper()->getPassword();
|
193 |
+
$smsto = $this->getHelper()->getTelephoneFromOrder($order);
|
194 |
+
$smsfrom = $this->getHelper()->getSenderForOrderHold();
|
195 |
+
$smsmsg = $this->getHelper()->getMessageForOrderHold($order);
|
196 |
+
$data = '?username=' . urlencode($username);
|
197 |
+
$data .= '&hash=' . urlencode($password);
|
198 |
+
$data .= '&numbers=' . urlencode($smsto);
|
199 |
+
$data .= '&sender=' . urlencode($smsfrom);
|
200 |
+
$data .= '&message=' . urlencode($smsmsg);
|
201 |
+
$url = $host.$data;
|
202 |
+
$sendSms = $this->getHelper()->sendSms($url);
|
203 |
+
try {
|
204 |
+
Mage::getModel('sendsms/sendsms')
|
205 |
+
->setOrderId($order->getIncrementId())
|
206 |
+
->setFrom($smsfrom)
|
207 |
+
->setTo($smsto)
|
208 |
+
->setSmsMessage($smsmsg)
|
209 |
+
->setStatus($sendSms['status'])
|
210 |
+
->setStatusMessage($sendSms['status_message'])
|
211 |
+
->setCreatedTime(now())
|
212 |
+
->save();
|
213 |
+
}
|
214 |
+
catch (Exception $e) {}
|
215 |
+
}
|
216 |
+
}
|
217 |
+
}
|
218 |
+
|
219 |
+
public function getHelper()
|
220 |
+
{
|
221 |
+
return Mage::helper('sendsms/Data');
|
222 |
+
}
|
223 |
+
}
|
app/code/local/txtlocal/sendsms/Model/Sendsms.php
ADDED
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class txtlocal_sendsms_Model_Sendsms extends Mage_Core_Model_Abstract
|
4 |
+
{
|
5 |
+
public function _construct()
|
6 |
+
{
|
7 |
+
parent::_construct();
|
8 |
+
$this->_init('sendsms/sendsms');
|
9 |
+
}
|
10 |
+
}
|
app/code/local/txtlocal/sendsms/controllers/Adminhtml/SendsmsController.php
ADDED
@@ -0,0 +1,173 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class txtlocal_sendsms_Adminhtml_SendsmsController extends Mage_Adminhtml_Controller_action
|
4 |
+
{
|
5 |
+
|
6 |
+
protected function _initAction() {
|
7 |
+
$this->loadLayout()
|
8 |
+
->_setActiveMenu('sendsms/items')
|
9 |
+
->_addBreadcrumb(Mage::helper('adminhtml')->__('Items Manager'), Mage::helper('adminhtml')->__('Item Manager'));
|
10 |
+
|
11 |
+
return $this;
|
12 |
+
}
|
13 |
+
|
14 |
+
public function indexAction() {
|
15 |
+
$this->_initAction()
|
16 |
+
->renderLayout();
|
17 |
+
}
|
18 |
+
|
19 |
+
public function editAction() {
|
20 |
+
$id = $this->getRequest()->getParam('id');
|
21 |
+
$model = Mage::getModel('sendsms/sendsms')->load($id);
|
22 |
+
|
23 |
+
if ($model->getId() || $id == 0) {
|
24 |
+
$data = Mage::getSingleton('adminhtml/session')->getFormData(true);
|
25 |
+
if (!empty($data)) {
|
26 |
+
$model->setData($data);
|
27 |
+
}
|
28 |
+
|
29 |
+
Mage::register('sendsms_data', $model);
|
30 |
+
|
31 |
+
$this->loadLayout();
|
32 |
+
$this->_setActiveMenu('sendsms/items');
|
33 |
+
|
34 |
+
$this->_addBreadcrumb(Mage::helper('adminhtml')->__('Item Manager'), Mage::helper('adminhtml')->__('Item Manager'));
|
35 |
+
$this->_addBreadcrumb(Mage::helper('adminhtml')->__('Item News'), Mage::helper('adminhtml')->__('Item News'));
|
36 |
+
|
37 |
+
$this->getLayout()->getBlock('head')->setCanLoadExtJs(true);
|
38 |
+
|
39 |
+
$this->_addContent($this->getLayout()->createBlock('sendsms/adminhtml_sendsms_edit'))
|
40 |
+
->_addLeft($this->getLayout()->createBlock('sendsms/adminhtml_sendsms_edit_tabs'));
|
41 |
+
|
42 |
+
$this->renderLayout();
|
43 |
+
} else {
|
44 |
+
Mage::getSingleton('adminhtml/session')->addError(Mage::helper('sendsms')->__('Item does not exist'));
|
45 |
+
$this->_redirect('*/*/');
|
46 |
+
}
|
47 |
+
}
|
48 |
+
|
49 |
+
public function newAction() {
|
50 |
+
$this->_forward('edit');
|
51 |
+
}
|
52 |
+
|
53 |
+
public function saveAction() {
|
54 |
+
if ($data = $this->getRequest()->getPost()) {
|
55 |
+
//check if destination input is an order
|
56 |
+
$order = Mage::getModel('sales/order')->loadByIncrementId($data['to']);
|
57 |
+
if($order instanceof Mage_Sales_Model_Order and $order->getData()) {
|
58 |
+
$data['to'] = $this->getHelper()->getTelephoneFromOrder($order);
|
59 |
+
}
|
60 |
+
//send the SMS
|
61 |
+
$host = "https://api.txtlocal.com/send/";
|
62 |
+
$username = $this->getHelper()->getUsername();
|
63 |
+
$hash = $this->getHelper()->getPassword();
|
64 |
+
$smsto = $data['to'];
|
65 |
+
$smsfrom = $data['from'];
|
66 |
+
$smsmsg = $data['sms_message'];
|
67 |
+
$_data = '?username=' . 'malb2_11@uni.worc.ac.uk';
|
68 |
+
$_data .= '&hash=' . '5ef4dc464216d1dd73e99934438f91b95c8b1d24';
|
69 |
+
$_data .= '&numbers=' . '447528824325';
|
70 |
+
$_data .= '&sender=' . 'Ben';
|
71 |
+
$_data .= '&message=' . 'Testings';
|
72 |
+
$_data = urlencode($_data);
|
73 |
+
// Send the GET request with cURL
|
74 |
+
$ch = curl_init($host . $_data);
|
75 |
+
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
76 |
+
$response = curl_exec($ch);
|
77 |
+
curl_close($ch);
|
78 |
+
Mage::log(
|
79 |
+
"($response} updated",
|
80 |
+
null,
|
81 |
+
'product-updates.log'
|
82 |
+
);
|
83 |
+
$data['status_message'] = $response;
|
84 |
+
|
85 |
+
$model = Mage::getModel('sendsms/sendsms');
|
86 |
+
$model->setData($data)
|
87 |
+
->setId($this->getRequest()->getParam('id'));
|
88 |
+
|
89 |
+
try {
|
90 |
+
$model->setCreatedTime(now());
|
91 |
+
$model->save();
|
92 |
+
|
93 |
+
Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('sendsms')->__('Item was successfully saved'));
|
94 |
+
Mage::getSingleton('adminhtml/session')->setFormData(false);
|
95 |
+
|
96 |
+
if ($this->getRequest()->getParam('back')) {
|
97 |
+
$this->_redirect('*/*/edit', array('id' => $model->getId()));
|
98 |
+
return;
|
99 |
+
}
|
100 |
+
$this->_redirect('*/*/');
|
101 |
+
return;
|
102 |
+
} catch (Exception $e) {
|
103 |
+
Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
|
104 |
+
Mage::getSingleton('adminhtml/session')->setFormData($data);
|
105 |
+
$this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id')));
|
106 |
+
return;
|
107 |
+
}
|
108 |
+
}
|
109 |
+
Mage::getSingleton('adminhtml/session')->addError(Mage::helper('sendsms')->__('Unable to find item to save'));
|
110 |
+
$this->_redirect('*/*/');
|
111 |
+
}
|
112 |
+
|
113 |
+
public function deleteAction() {
|
114 |
+
if( $this->getRequest()->getParam('id') > 0 ) {
|
115 |
+
try {
|
116 |
+
$model = Mage::getModel('sendsms/sendsms');
|
117 |
+
|
118 |
+
$model->setId($this->getRequest()->getParam('id'))
|
119 |
+
->delete();
|
120 |
+
|
121 |
+
Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('adminhtml')->__('Item was successfully deleted'));
|
122 |
+
$this->_redirect('*/*/');
|
123 |
+
} catch (Exception $e) {
|
124 |
+
Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
|
125 |
+
$this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id')));
|
126 |
+
}
|
127 |
+
}
|
128 |
+
$this->_redirect('*/*/');
|
129 |
+
}
|
130 |
+
|
131 |
+
public function massDeleteAction() {
|
132 |
+
$sendsmsIds = $this->getRequest()->getParam('sendsms');
|
133 |
+
if(!is_array($sendsmsIds)) {
|
134 |
+
Mage::getSingleton('adminhtml/session')->addError(Mage::helper('adminhtml')->__('Please select item(s)'));
|
135 |
+
} else {
|
136 |
+
try {
|
137 |
+
foreach ($sendsmsIds as $sendsmsId) {
|
138 |
+
$sendsms = Mage::getModel('sendsms/sendsms')->load($sendsmsId);
|
139 |
+
$sendsms->delete();
|
140 |
+
}
|
141 |
+
Mage::getSingleton('adminhtml/session')->addSuccess(
|
142 |
+
Mage::helper('adminhtml')->__(
|
143 |
+
'Total of %d record(s) were successfully deleted', count($sendsmsIds)
|
144 |
+
)
|
145 |
+
);
|
146 |
+
} catch (Exception $e) {
|
147 |
+
Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
|
148 |
+
}
|
149 |
+
}
|
150 |
+
$this->_redirect('*/*/index');
|
151 |
+
}
|
152 |
+
|
153 |
+
protected function _sendUploadResponse($fileName, $content, $contentType='application/octet-stream')
|
154 |
+
{
|
155 |
+
$response = $this->getResponse();
|
156 |
+
$response->setHeader('HTTP/1.1 200 OK','');
|
157 |
+
$response->setHeader('Pragma', 'public', true);
|
158 |
+
$response->setHeader('Cache-Control', 'must-revalidate, post-check=0, pre-check=0', true);
|
159 |
+
$response->setHeader('Content-Disposition', 'attachment; filename='.$fileName);
|
160 |
+
$response->setHeader('Last-Modified', date('r'));
|
161 |
+
$response->setHeader('Accept-Ranges', 'bytes');
|
162 |
+
$response->setHeader('Content-Length', strlen($content));
|
163 |
+
$response->setHeader('Content-type', $contentType);
|
164 |
+
$response->setBody($content);
|
165 |
+
$response->sendResponse();
|
166 |
+
die;
|
167 |
+
}
|
168 |
+
|
169 |
+
public function getHelper()
|
170 |
+
{
|
171 |
+
return Mage::helper('sendsms/Data');
|
172 |
+
}
|
173 |
+
}
|
app/code/local/txtlocal/sendsms/controllers/IndexController.php
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class txtlocal_sendsms_IndexController extends Mage_Core_Controller_Front_Action
|
3 |
+
{
|
4 |
+
public function indexAction()
|
5 |
+
{
|
6 |
+
$this->loadLayout();
|
7 |
+
$this->renderLayout();
|
8 |
+
}
|
9 |
+
}
|
app/code/local/txtlocal/sendsms/etc/config.xml
ADDED
@@ -0,0 +1,219 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<!--
|
3 |
+
/**
|
4 |
+
* @category MN
|
5 |
+
* @package txtlocal_sendsms
|
6 |
+
* @author TextLocal
|
7 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
8 |
+
*/
|
9 |
+
-->
|
10 |
+
<config>
|
11 |
+
<modules>
|
12 |
+
<txtlocal_sendsms>
|
13 |
+
<version>1.0.0</version>
|
14 |
+
</txtlocal_sendsms>
|
15 |
+
</modules>
|
16 |
+
<admin>
|
17 |
+
<routers>
|
18 |
+
<sendsms>
|
19 |
+
<use>admin</use>
|
20 |
+
<args>
|
21 |
+
<module>txtlocal_sendsms</module>
|
22 |
+
<frontName>sendsms</frontName>
|
23 |
+
</args>
|
24 |
+
</sendsms>
|
25 |
+
</routers>
|
26 |
+
</admin>
|
27 |
+
<adminhtml>
|
28 |
+
<translate>
|
29 |
+
<modules>
|
30 |
+
<txtlocal_sendsms>
|
31 |
+
<files>
|
32 |
+
<default>txtlocal_sendsms.csv</default>
|
33 |
+
</files>
|
34 |
+
</txtlocal_sendsms>
|
35 |
+
</modules>
|
36 |
+
</translate>
|
37 |
+
<menu>
|
38 |
+
<sendsms translate="title" module="sendsms">
|
39 |
+
<title>TextLocal</title>
|
40 |
+
<sort_order>71</sort_order>
|
41 |
+
<children>
|
42 |
+
<credits translate="title" module="sendsms">
|
43 |
+
<title>Buy Credits</title>
|
44 |
+
<sort_order>0</sort_order>
|
45 |
+
<action>adminhtml/system_config/edit/section/buycredits</action>
|
46 |
+
</credits>
|
47 |
+
<settings translate="title" module="sendsms">
|
48 |
+
<title>Settings</title>
|
49 |
+
<sort_order>15</sort_order>
|
50 |
+
<action>adminhtml/system_config/edit/section/sendsms</action>
|
51 |
+
</settings>
|
52 |
+
</children>
|
53 |
+
</sendsms>
|
54 |
+
</menu>
|
55 |
+
<acl>
|
56 |
+
<resources>
|
57 |
+
<all>
|
58 |
+
<title>Allow Everything</title>
|
59 |
+
</all>
|
60 |
+
<admin>
|
61 |
+
<children>
|
62 |
+
<sendsms translate="title" module="sendsms">
|
63 |
+
<title>TextLocal</title>
|
64 |
+
<sort_order>71</sort_order>
|
65 |
+
<children>
|
66 |
+
<credits translate="title" module="sendsms">
|
67 |
+
<title>Buy Credits</title>
|
68 |
+
<sort_order>0</sort_order>
|
69 |
+
</credits>
|
70 |
+
<settings translate="title" module="sendsms">
|
71 |
+
<title>Settings</title>
|
72 |
+
<sort_order>15</sort_order>
|
73 |
+
</settings>
|
74 |
+
</children>
|
75 |
+
</sendsms>
|
76 |
+
<system>
|
77 |
+
<children>
|
78 |
+
<config>
|
79 |
+
<children>
|
80 |
+
<buycredits translate="title" module="sendsms">
|
81 |
+
<title>Buy Credits</title>
|
82 |
+
<sort_order>55</sort_order>
|
83 |
+
</buycredits>
|
84 |
+
<sendsms translate="title" module="sendsms">
|
85 |
+
<title>Settings</title>
|
86 |
+
<sort_order>50</sort_order>
|
87 |
+
</sendsms>
|
88 |
+
</children>
|
89 |
+
</config>
|
90 |
+
</children>
|
91 |
+
</system>
|
92 |
+
</children>
|
93 |
+
</admin>
|
94 |
+
</resources>
|
95 |
+
</acl>
|
96 |
+
<layout>
|
97 |
+
<updates>
|
98 |
+
<sendsms>
|
99 |
+
<file>sendsms.xml</file>
|
100 |
+
</sendsms>
|
101 |
+
</updates>
|
102 |
+
</layout>
|
103 |
+
</adminhtml>
|
104 |
+
<global>
|
105 |
+
<models>
|
106 |
+
<sendsms>
|
107 |
+
<class>txtlocal_sendsms_Model</class>
|
108 |
+
<resourceModel>sendsms_mysql4</resourceModel>
|
109 |
+
</sendsms>
|
110 |
+
<sendsms_mysql4>
|
111 |
+
<class>txtlocal_sendsms_Model_Mysql4</class>
|
112 |
+
<entities>
|
113 |
+
<sendsms>
|
114 |
+
<table>sendsms</table>
|
115 |
+
</sendsms>
|
116 |
+
</entities>
|
117 |
+
</sendsms_mysql4>
|
118 |
+
</models>
|
119 |
+
<resources>
|
120 |
+
<sendsms_setup>
|
121 |
+
<setup>
|
122 |
+
<module>txtlocal_sendsms</module>
|
123 |
+
</setup>
|
124 |
+
<connection>
|
125 |
+
<use>core_setup</use>
|
126 |
+
</connection>
|
127 |
+
</sendsms_setup>
|
128 |
+
<sendsms_write>
|
129 |
+
<connection>
|
130 |
+
<use>core_write</use>
|
131 |
+
</connection>
|
132 |
+
</sendsms_write>
|
133 |
+
<sendsms_read>
|
134 |
+
<connection>
|
135 |
+
<use>core_read</use>
|
136 |
+
</connection>
|
137 |
+
</sendsms_read>
|
138 |
+
</resources>
|
139 |
+
<blocks>
|
140 |
+
<sendsms>
|
141 |
+
<class>txtlocal_sendsms_Block</class>
|
142 |
+
</sendsms>
|
143 |
+
</blocks>
|
144 |
+
<helpers>
|
145 |
+
<sendsms>
|
146 |
+
<class>txtlocal_sendsms_Helper</class>
|
147 |
+
</sendsms>
|
148 |
+
</helpers>
|
149 |
+
<events>
|
150 |
+
<checkout_onepage_controller_success_action>
|
151 |
+
<observers>
|
152 |
+
<txtlocal_sendsms_Created>
|
153 |
+
<type>singleton</type>
|
154 |
+
<class>txtlocal_sendsms_Model_Observer</class>
|
155 |
+
<method>sendSmsOnOrderCreated</method>
|
156 |
+
</txtlocal_sendsms_Created>
|
157 |
+
</observers>
|
158 |
+
</checkout_onepage_controller_success_action>
|
159 |
+
<sales_order_save_after>
|
160 |
+
<observers>
|
161 |
+
<txtlocal_sendsms_Order_Hold>
|
162 |
+
<type>singleton</type>
|
163 |
+
<class>txtlocal_sendsms_Model_Observer</class>
|
164 |
+
<method>sendSmsOnOrderHold</method>
|
165 |
+
</txtlocal_sendsms_Order_Hold>
|
166 |
+
<txtlocal_sendsms_Order_Unhold>
|
167 |
+
<type>singleton</type>
|
168 |
+
<class>txtlocal_sendsms_Model_Observer</class>
|
169 |
+
<method>sendSmsOnOrderUnhold</method>
|
170 |
+
</txtlocal_sendsms_Order_Unhold>
|
171 |
+
<txtlocal_sendsms_Order_Canceled>
|
172 |
+
<type>singleton</type>
|
173 |
+
<class>txtlocal_sendsms_Model_Observer</class>
|
174 |
+
<method>sendSmsOnOrderCanceled</method>
|
175 |
+
</txtlocal_sendsms_Order_Canceled>
|
176 |
+
</observers>
|
177 |
+
</sales_order_save_after>
|
178 |
+
<sales_order_shipment_save_after>
|
179 |
+
<observers>
|
180 |
+
<txtlocal_sendsms_Shipment_Created>
|
181 |
+
<type>singleton</type>
|
182 |
+
<class>txtlocal_sendsms_Model_Observer</class>
|
183 |
+
<method>sendSmsOnShipmentCreated</method>
|
184 |
+
</txtlocal_sendsms_Shipment_Created>
|
185 |
+
</observers>
|
186 |
+
</sales_order_shipment_save_after>
|
187 |
+
</events>
|
188 |
+
</global>
|
189 |
+
<default>
|
190 |
+
<sendsms>
|
191 |
+
<orders>
|
192 |
+
<enabled>0</enabled>
|
193 |
+
<sender>Magento</sender>
|
194 |
+
<message>Hello {{firstname}}. Your order has been received. Thank you for your purchase!</message>
|
195 |
+
<notify>0</notify>
|
196 |
+
</orders>
|
197 |
+
<order_hold>
|
198 |
+
<enabled>0</enabled>
|
199 |
+
<sender>Magento</sender>
|
200 |
+
<message>Hello {{firstname}}. Your order {{order_id}} has been placed on hold.</message>
|
201 |
+
</order_hold>
|
202 |
+
<order_unhold>
|
203 |
+
<enabled>0</enabled>
|
204 |
+
<sender>Magento</sender>
|
205 |
+
<message>Hello {{firstname}}. Your order {{order_id}} has been released from holding status.</message>
|
206 |
+
</order_unhold>
|
207 |
+
<order_canceled>
|
208 |
+
<enabled>0</enabled>
|
209 |
+
<sender>Magento</sender>
|
210 |
+
<message>Hello {{firstname}}. Your order {{order_id}} has been cancelled.</message>
|
211 |
+
</order_canceled>
|
212 |
+
<shipments>
|
213 |
+
<enabled>0</enabled>
|
214 |
+
<sender>Magento</sender>
|
215 |
+
<message>Hello {{firstname}}. Your order ({{order_id}}) has been shipped. Thank you for buying from us!</message>
|
216 |
+
</shipments>
|
217 |
+
</sendsms>
|
218 |
+
</default>
|
219 |
+
</config>
|
app/code/local/txtlocal/sendsms/etc/system.xml
ADDED
@@ -0,0 +1,300 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<tabs>
|
4 |
+
<txtlocal translate="label" module="sendsms">
|
5 |
+
<label>TextLocal</label>
|
6 |
+
<sort_order>300</sort_order>
|
7 |
+
</txtlocal>
|
8 |
+
</tabs>
|
9 |
+
<sections>
|
10 |
+
<buycredits translate="label" module="sendsms">
|
11 |
+
<label>Buy Credits</label>
|
12 |
+
<tab>txtlocal</tab>
|
13 |
+
<frontend_type>text</frontend_type>
|
14 |
+
<sort_order>190</sort_order>
|
15 |
+
<show_in_default>1</show_in_default>
|
16 |
+
<show_in_website>1</show_in_website>
|
17 |
+
<show_in_store>1</show_in_store>
|
18 |
+
<groups>
|
19 |
+
<info>
|
20 |
+
<frontend_model>sendsms/system_config_buycredits</frontend_model>
|
21 |
+
<sort_order>10</sort_order>
|
22 |
+
<show_in_default>1</show_in_default>
|
23 |
+
<show_in_website>1</show_in_website>
|
24 |
+
<show_in_store>1</show_in_store>
|
25 |
+
</info>
|
26 |
+
</groups>
|
27 |
+
</buycredits>
|
28 |
+
<sendsms translate="label" module="sendsms">
|
29 |
+
<label>Settings</label>
|
30 |
+
<tab>txtlocal</tab>
|
31 |
+
<frontend_type>text</frontend_type>
|
32 |
+
<sort_order>200</sort_order>
|
33 |
+
<show_in_default>1</show_in_default>
|
34 |
+
<show_in_website>1</show_in_website>
|
35 |
+
<show_in_store>1</show_in_store>
|
36 |
+
<groups>
|
37 |
+
<info>
|
38 |
+
<frontend_model>sendsms/system_config_info</frontend_model>
|
39 |
+
<sort_order>0</sort_order>
|
40 |
+
<show_in_default>1</show_in_default>
|
41 |
+
<show_in_website>1</show_in_website>
|
42 |
+
<show_in_store>1</show_in_store>
|
43 |
+
</info>
|
44 |
+
<general translate="label">
|
45 |
+
<label>Credentials</label>
|
46 |
+
<frontend_type>text</frontend_type>
|
47 |
+
<sort_order>10</sort_order>
|
48 |
+
<show_in_default>1</show_in_default>
|
49 |
+
<show_in_website>1</show_in_website>
|
50 |
+
<show_in_store>1</show_in_store>
|
51 |
+
<fields>
|
52 |
+
<username translate="label">
|
53 |
+
<label>TextLocal Username</label>
|
54 |
+
<frontend_type>text</frontend_type>
|
55 |
+
<sort_order>5</sort_order>
|
56 |
+
<show_in_default>1</show_in_default>
|
57 |
+
<show_in_website>1</show_in_website>
|
58 |
+
<show_in_store>1</show_in_store>
|
59 |
+
</username>
|
60 |
+
<password translate="label">
|
61 |
+
<label>TextLocal API Hash</label>
|
62 |
+
<frontend_type>password</frontend_type>
|
63 |
+
<comment>Found in your TextLocal Messenger under - Help > All Documentation</comment>
|
64 |
+
<sort_order>10</sort_order>
|
65 |
+
<show_in_default>1</show_in_default>
|
66 |
+
<show_in_website>1</show_in_website>
|
67 |
+
<show_in_store>1</show_in_store>
|
68 |
+
</password>
|
69 |
+
</fields>
|
70 |
+
</general>
|
71 |
+
<orders translate="label">
|
72 |
+
<label>Orders</label>
|
73 |
+
<frontend_type>text</frontend_type>
|
74 |
+
<sort_order>15</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 |
+
<fields>
|
79 |
+
<enabled translate="label comment">
|
80 |
+
<label>Enabled</label>
|
81 |
+
<comment>Automatically sends a text message to the customer when an order is made</comment>
|
82 |
+
<frontend_type>select</frontend_type>
|
83 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
84 |
+
<sort_order>5</sort_order>
|
85 |
+
<show_in_default>1</show_in_default>
|
86 |
+
<show_in_website>1</show_in_website>
|
87 |
+
<show_in_store>1</show_in_store>
|
88 |
+
</enabled>
|
89 |
+
<contacts translate="label comment">
|
90 |
+
<label>Contacts</label>
|
91 |
+
<comment>Adds a number to your group when an order is placed</comment>
|
92 |
+
<frontend_type>select</frontend_type>
|
93 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
94 |
+
<sort_order>5</sort_order>
|
95 |
+
<show_in_default>1</show_in_default>
|
96 |
+
<show_in_website>1</show_in_website>
|
97 |
+
<show_in_store>1</show_in_store>
|
98 |
+
</contacts>
|
99 |
+
<sender translate="label comment">
|
100 |
+
<label>Sender Name</label>
|
101 |
+
<comment>Name of the sender - Max 13 Characters</comment>
|
102 |
+
<validate>required-entry</validate>
|
103 |
+
<frontend_type>text</frontend_type>
|
104 |
+
<sort_order>10</sort_order>
|
105 |
+
<show_in_default>1</show_in_default>
|
106 |
+
<show_in_website>1</show_in_website>
|
107 |
+
<show_in_store>1</show_in_store>
|
108 |
+
</sender>
|
109 |
+
<message translate="label comment">
|
110 |
+
<label>Message</label>
|
111 |
+
<comment>Message Template (160 characters)</comment>
|
112 |
+
<tooltip>{{firstname}} = First Name</tooltip>
|
113 |
+
<validate>required-entry</validate>
|
114 |
+
<frontend_type>textarea</frontend_type>
|
115 |
+
<sort_order>15</sort_order>
|
116 |
+
<show_in_default>1</show_in_default>
|
117 |
+
<show_in_website>1</show_in_website>
|
118 |
+
<show_in_store>1</show_in_store>
|
119 |
+
</message>
|
120 |
+
</fields>
|
121 |
+
</orders>
|
122 |
+
<order_hold translate="label">
|
123 |
+
<label>Order Hold</label>
|
124 |
+
<frontend_type>text</frontend_type>
|
125 |
+
<sort_order>20</sort_order>
|
126 |
+
<show_in_default>1</show_in_default>
|
127 |
+
<show_in_website>1</show_in_website>
|
128 |
+
<show_in_store>1</show_in_store>
|
129 |
+
<fields>
|
130 |
+
<enabled translate="label comment">
|
131 |
+
<label>Enabled</label>
|
132 |
+
<comment>Automatically sends a text message to the customer when an order is placed on hold</comment>
|
133 |
+
<frontend_type>select</frontend_type>
|
134 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
135 |
+
<sort_order>5</sort_order>
|
136 |
+
<show_in_default>1</show_in_default>
|
137 |
+
<show_in_website>1</show_in_website>
|
138 |
+
<show_in_store>1</show_in_store>
|
139 |
+
</enabled>
|
140 |
+
<sender translate="label comment">
|
141 |
+
<label>Sender Name</label>
|
142 |
+
<comment>Name of the sender - Max 13 Characters</comment>
|
143 |
+
<validate>required-entry</validate>
|
144 |
+
<frontend_type>text</frontend_type>
|
145 |
+
<sort_order>10</sort_order>
|
146 |
+
<show_in_default>1</show_in_default>
|
147 |
+
<show_in_website>1</show_in_website>
|
148 |
+
<show_in_store>1</show_in_store>
|
149 |
+
</sender>
|
150 |
+
<message translate="label comment">
|
151 |
+
<label>Message</label>
|
152 |
+
<comment>Message Template (160 characters)</comment>
|
153 |
+
<tooltip>{{firstname}} = First Name {{order_id}} = Order Id</tooltip>
|
154 |
+
<validate>required-entry</validate>
|
155 |
+
<frontend_type>textarea</frontend_type>
|
156 |
+
<sort_order>15</sort_order>
|
157 |
+
<show_in_default>1</show_in_default>
|
158 |
+
<show_in_website>1</show_in_website>
|
159 |
+
<show_in_store>1</show_in_store>
|
160 |
+
</message>
|
161 |
+
</fields>
|
162 |
+
</order_hold>
|
163 |
+
<order_unhold translate="label">
|
164 |
+
<label>Order Unhold</label>
|
165 |
+
<frontend_type>text</frontend_type>
|
166 |
+
<sort_order>25</sort_order>
|
167 |
+
<show_in_default>1</show_in_default>
|
168 |
+
<show_in_website>1</show_in_website>
|
169 |
+
<show_in_store>1</show_in_store>
|
170 |
+
<fields>
|
171 |
+
<enabled translate="label comment">
|
172 |
+
<label>Enabled</label>
|
173 |
+
<comment>Automatically sends a text message to the customer when an order has been released from holding status</comment>
|
174 |
+
<frontend_type>select</frontend_type>
|
175 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
176 |
+
<sort_order>5</sort_order>
|
177 |
+
<show_in_default>1</show_in_default>
|
178 |
+
<show_in_website>1</show_in_website>
|
179 |
+
<show_in_store>1</show_in_store>
|
180 |
+
</enabled>
|
181 |
+
<sender translate="label comment">
|
182 |
+
<label>Sender Name</label>
|
183 |
+
<comment>Name of the sender - Max 13 Characters</comment>
|
184 |
+
<validate>required-entry</validate>
|
185 |
+
<frontend_type>text</frontend_type>
|
186 |
+
<sort_order>10</sort_order>
|
187 |
+
<show_in_default>1</show_in_default>
|
188 |
+
<show_in_website>1</show_in_website>
|
189 |
+
<show_in_store>1</show_in_store>
|
190 |
+
</sender>
|
191 |
+
<message translate="label comment">
|
192 |
+
<label>Message</label>
|
193 |
+
<comment>Message Template (160 characters)</comment>
|
194 |
+
<tooltip>{{firstname}} = First Name {{order_id}} = Order Id</tooltip>
|
195 |
+
<validate>required-entry</validate>
|
196 |
+
<frontend_type>textarea</frontend_type>
|
197 |
+
<sort_order>15</sort_order>
|
198 |
+
<show_in_default>1</show_in_default>
|
199 |
+
<show_in_website>1</show_in_website>
|
200 |
+
<show_in_store>1</show_in_store>
|
201 |
+
</message>
|
202 |
+
</fields>
|
203 |
+
</order_unhold>
|
204 |
+
<order_canceled translate="label">
|
205 |
+
<label>Order Cancelled</label>
|
206 |
+
<frontend_type>text</frontend_type>
|
207 |
+
<sort_order>30</sort_order>
|
208 |
+
<show_in_default>1</show_in_default>
|
209 |
+
<show_in_website>1</show_in_website>
|
210 |
+
<show_in_store>1</show_in_store>
|
211 |
+
<fields>
|
212 |
+
<enabled translate="label comment">
|
213 |
+
<label>Enabled</label>
|
214 |
+
<comment>Automatically sends a text message to the customer when an order has been canceled</comment>
|
215 |
+
<frontend_type>select</frontend_type>
|
216 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
217 |
+
<sort_order>5</sort_order>
|
218 |
+
<show_in_default>1</show_in_default>
|
219 |
+
<show_in_website>1</show_in_website>
|
220 |
+
<show_in_store>1</show_in_store>
|
221 |
+
</enabled>
|
222 |
+
<sender translate="label comment">
|
223 |
+
<label>Sender Name</label>
|
224 |
+
<comment>Name of the sender - Max 13 Characters</comment>
|
225 |
+
<validate>required-entry</validate>
|
226 |
+
<frontend_type>text</frontend_type>
|
227 |
+
<sort_order>10</sort_order>
|
228 |
+
<show_in_default>1</show_in_default>
|
229 |
+
<show_in_website>1</show_in_website>
|
230 |
+
<show_in_store>1</show_in_store>
|
231 |
+
</sender>
|
232 |
+
<message translate="label comment">
|
233 |
+
<label>Message</label>
|
234 |
+
<comment>Message Template (160 characters)</comment>
|
235 |
+
<tooltip>{{firstname}} = First Name {{order_id}} = Order Id</tooltip>
|
236 |
+
<validate>required-entry</validate>
|
237 |
+
<frontend_type>textarea</frontend_type>
|
238 |
+
<sort_order>15</sort_order>
|
239 |
+
<show_in_default>1</show_in_default>
|
240 |
+
<show_in_website>1</show_in_website>
|
241 |
+
<show_in_store>1</show_in_store>
|
242 |
+
</message>
|
243 |
+
</fields>
|
244 |
+
</order_canceled>
|
245 |
+
<shipments translate="label">
|
246 |
+
<label>Shipments</label>
|
247 |
+
<frontend_type>text</frontend_type>
|
248 |
+
<sort_order>35</sort_order>
|
249 |
+
<show_in_default>1</show_in_default>
|
250 |
+
<show_in_website>1</show_in_website>
|
251 |
+
<show_in_store>1</show_in_store>
|
252 |
+
<fields>
|
253 |
+
<enabled translate="label comment">
|
254 |
+
<label>Enabled</label>
|
255 |
+
<comment>Automatically sends a text message to the customer when the shipment is made</comment>
|
256 |
+
<frontend_type>select</frontend_type>
|
257 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
258 |
+
<sort_order>5</sort_order>
|
259 |
+
<show_in_default>1</show_in_default>
|
260 |
+
<show_in_website>1</show_in_website>
|
261 |
+
<show_in_store>1</show_in_store>
|
262 |
+
</enabled>
|
263 |
+
<sender translate="label comment">
|
264 |
+
<label>Sender Name</label>
|
265 |
+
<comment>Name of the sender - Max 13 Characters</comment>
|
266 |
+
<validate>required-entry</validate>
|
267 |
+
<frontend_type>text</frontend_type>
|
268 |
+
<sort_order>10</sort_order>
|
269 |
+
<show_in_default>1</show_in_default>
|
270 |
+
<show_in_website>1</show_in_website>
|
271 |
+
<show_in_store>1</show_in_store>
|
272 |
+
</sender>
|
273 |
+
<message translate="label comment">
|
274 |
+
<label>Message</label>
|
275 |
+
<comment>Message Template (160 characters)</comment>
|
276 |
+
<tooltip>{{firstname}} = First Name {{order_id}} = Order Id</tooltip>
|
277 |
+
<validate>required-entry</validate>
|
278 |
+
<frontend_type>textarea</frontend_type>
|
279 |
+
<sort_order>15</sort_order>
|
280 |
+
<show_in_default>1</show_in_default>
|
281 |
+
<show_in_website>1</show_in_website>
|
282 |
+
<show_in_store>1</show_in_store>
|
283 |
+
</message>
|
284 |
+
</fields>
|
285 |
+
</shipments>
|
286 |
+
<contacts translate="label">
|
287 |
+
<label>Contacts</label>
|
288 |
+
<frontend_type>text</frontend_type>
|
289 |
+
<sort_order>35</sort_order>
|
290 |
+
<show_in_default>1</show_in_default>
|
291 |
+
<show_in_website>1</show_in_website>
|
292 |
+
<show_in_store>1</show_in_store>
|
293 |
+
<fields>
|
294 |
+
|
295 |
+
</fields>
|
296 |
+
</contacts>
|
297 |
+
</groups>
|
298 |
+
</sendsms>
|
299 |
+
</sections>
|
300 |
+
</config>
|
app/code/local/txtlocal/sendsms/sql/sendsms_setup/mysql4-install-1.0.0.php
ADDED
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
$installer = $this;
|
4 |
+
|
5 |
+
$installer->startSetup();
|
6 |
+
|
7 |
+
$installer->run("
|
8 |
+
|
9 |
+
DROP TABLE IF EXISTS {$this->getTable('sendsms')};
|
10 |
+
CREATE TABLE {$this->getTable('sendsms')} (
|
11 |
+
`sendsms_id` int(11) unsigned NOT NULL AUTO_INCREMENT,
|
12 |
+
`order_id` varchar(255) NOT NULL DEFAULT '',
|
13 |
+
`from` varchar(255) NOT NULL DEFAULT '',
|
14 |
+
`to` varchar(255) NOT NULL DEFAULT '',
|
15 |
+
`sms_message` text NOT NULL,
|
16 |
+
`status` varchar(255) NOT NULL DEFAULT '',
|
17 |
+
`status_message` varchar(255) NOT NULL DEFAULT '',
|
18 |
+
`created_time` datetime DEFAULT NULL,
|
19 |
+
PRIMARY KEY (`sendsms_id`)
|
20 |
+
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
21 |
+
|
22 |
+
");
|
23 |
+
|
24 |
+
$installer->endSetup();
|
app/etc/modules/txtlocal_sendsms.xml
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<modules>
|
4 |
+
<txtlocal_sendsms>
|
5 |
+
<active>true</active>
|
6 |
+
<codePool>local</codePool>
|
7 |
+
</txtlocal_sendsms>
|
8 |
+
</modules>
|
9 |
+
</config>
|
package.xml
ADDED
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<package>
|
3 |
+
<name>txtlocal_sendsms</name>
|
4 |
+
<version>1.0.0</version>
|
5 |
+
<stability>stable</stability>
|
6 |
+
<license uri="www.opensource.org/licenses/osl-3.0.php">OSL v3.0</license>
|
7 |
+
<channel>community</channel>
|
8 |
+
<extends/>
|
9 |
+
<summary>A SMS extension, allowing messages to be sent when orders update using the Txtlocal system.</summary>
|
10 |
+
<description>SendSMS uses the Txtlocal API to send messages to the customers handset when an order is either, placed, held, unheld or shipped.</description>
|
11 |
+
<notes>Initla Release</notes>
|
12 |
+
<authors><author><name>Textlocal</name><user>Textlocal</user><email>tech@txtlocal.com</email></author></authors>
|
13 |
+
<date>2014-01-08</date>
|
14 |
+
<time>14:09:23</time>
|
15 |
+
<contents><target name="magelocal"><dir name="txtlocal"><dir name="sendsms"><dir name="Block"><dir name="Adminhtml"><dir name="Sendsms"><dir name="Edit"><file name="Form.php" hash="52fddfb6cddf6dce8240de5eefad3e1e"/><dir name="Tab"><file name="Form.php" hash="c32af2969c7601037ab80b8fa0d79c8c"/></dir><file name="Tabs.php" hash="81b64aeffe439192b0b9ae1ea4860b8d"/></dir><file name="Edit.php" hash="02eeedabea09ebe73a97aaee55d426bc"/><file name="Grid.php" hash="9de03e783006a23e9c003841a4bfaf48"/></dir><file name="Sendsms.php" hash="45d7b1228ea8247dc6a6fdb18da7ac1b"/></dir><file name="Buttons.php" hash="8fae5d5b50150a9c145855a17dcabf2a"/><file name="Sendsms.php" hash="8ce10ae6c015820b0108a029d269179a"/><dir name="System"><dir name="Config"><file name="Buycredits.php" hash="9eed593919db4e53f73602ade5f18b22"/><file name="Info.php" hash="6b3f57fe9ca363ed2c3b6d10e5bd4b2c"/></dir></dir></dir><dir name="Helper"><file name="Data.php" hash="720faa2ce03ff17baebee9c3b144c023"/></dir><dir name="Model"><dir name="Mysql4"><dir name="Sendsms"><file name="Collection.php" hash="312eb4705c9202ba736fbe7531a0a93a"/></dir><file name="Sendsms.php" hash="517ba93245d84cde383e192966c2fdf0"/></dir><file name="Observer.php" hash="8ccff9952532afc3bcadb12436344105"/><file name="Sendsms.php" hash="5ae3a979f0c0367ac8efe8aafa2c1737"/></dir><dir name="controllers"><dir name="Adminhtml"><file name="SendsmsController.php" hash="74d669ecb7245296944baa23e3da8d1a"/></dir><file name="IndexController.php" hash="35ab71b3ee2cf0842b7a7250aaafdade"/></dir><dir name="etc"><file name="config.xml" hash="4dc5073d4a0e50007ca4e0e80b0282ff"/><file name="system.xml" hash="4648722041959eb24aab5eb4e1b7d64d"/></dir><dir name="sql"><dir name="sendsms_setup"><file name="mysql4-install-1.0.0.php" hash="cb023dc60556fc7ec4d67cbe21b91cfb"/></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="txtlocal_sendsms.xml" hash="1c834f1147e4a94dbffaa7997693765e"/></dir></target></contents>
|
16 |
+
<compatible/>
|
17 |
+
<dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
|
18 |
+
</package>
|