Smsapi_Sms - Version 0.1.0

Version Notes

SMSAPI SMS v 0.1.0

Download this release

Release Info

Developer Marek Jasiukiewicz
Extension Smsapi_Sms
Version 0.1.0
Comparing to
See all releases


Version 0.1.0

app/code/community/Smsapi/Sms/Block/Adminhtml/System/Config/Fieldset/Branding.php ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Smsapi_Sms_Block_Adminhtml_System_Config_Fieldset_Branding
4
+ extends Mage_Adminhtml_Block_Abstract
5
+ implements Varien_Data_Form_Element_Renderer_Interface
6
+ {
7
+ protected $_template = 'sms/system/config/fieldset/branding.phtml';
8
+
9
+ /**
10
+ * Render fieldset html
11
+ *
12
+ * @param Varien_Data_Form_Element_Abstract $element
13
+ * @return string
14
+ */
15
+ public function render(Varien_Data_Form_Element_Abstract $element)
16
+ {
17
+ $elementOriginalData = $element->getOriginalData();
18
+ return $this->toHtml();
19
+ }
20
+ }
app/code/community/Smsapi/Sms/Block/Buttons.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Smsapi_Sms_Block_Buttons extends Mage_Adminhtml_Block_System_Config_Form_Field {
4
+
5
+ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element){
6
+
7
+ $this->setElement($element);
8
+
9
+ $url = 'https://ssl.smsapi.pl/rejestracja?lang=pl';
10
+
11
+
12
+ $html = $this->getLayout()->createBlock('adminhtml/widget_button')
13
+ ->setType('button')
14
+ ->setClass('button')
15
+ ->setLabel(Mage::helper('sms')->__('Open registration form'))
16
+ ->setOnClick("window.open('$url','window1','width=970, height=705, scrollbars=1, resizable=1'); return false;")
17
+ ->toHtml();
18
+
19
+ return $html;
20
+
21
+ }
22
+ }
app/code/community/Smsapi/Sms/Helper/Data.php ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Smsapi_Sms_Helper_Data extends Mage_Core_Helper_Abstract
4
+ {
5
+
6
+ }
app/code/community/Smsapi/Sms/Model/Adminhtml/Attributes.php ADDED
@@ -0,0 +1,60 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ //File: app/code/community/Smsapi/Sms/Model/Adminhtml/Attributes.php
3
+
4
+ /**
5
+ * SMS API Configuration attributes class
6
+ *
7
+ * @category Smsapi
8
+ * @package SMS
9
+ * @copyright Copyright (c) 2012 Smsapi (http://smsapi.pl/)
10
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
11
+ * @author Marek Jasiukiewicz <dev@jasiukiewicz.pl>
12
+ * ...
13
+ */
14
+
15
+
16
+ class Smsapi_Sms_Model_Adminhtml_Attributes {
17
+
18
+
19
+ /**
20
+ * Getting senders from SMSAPI and
21
+ * generate attributes for configuration panel
22
+ *
23
+ *
24
+ * @return array
25
+ */
26
+ public function toOptionArray() {
27
+
28
+ $attributes = array(
29
+ //array('label'=>Mage::helper('sms')->__('Use ECO SMS (cheaper version without sender)'),'value'=>'eco_msg') //eco messages disabled
30
+ );
31
+
32
+
33
+ $api = Mage::getModel('sms/apiClient');
34
+ $config = Mage::getModel('sms/config');
35
+
36
+ try {
37
+
38
+ $response = $api->connect()->getSenders();
39
+ if ($response->result!=0)
40
+ return $attributes;
41
+
42
+ if (!empty($response->senders)) foreach ($response->senders as $sender) {
43
+ array_push($attributes, array('label'=>$sender,'value'=>$sender));
44
+ }
45
+
46
+ }
47
+ catch ( Exception $e) {
48
+ Mage::log('SMSAPI (getSenders()): '.$e->getMessage());
49
+ }
50
+
51
+ if (empty($attributes))
52
+ array_push($attributes, array('label'=>'SMSAPI.pl','value'=>'SMSAPI.pl'));
53
+
54
+ return $attributes;
55
+
56
+ }
57
+
58
+
59
+
60
+ }
app/code/community/Smsapi/Sms/Model/ApiClient.php ADDED
@@ -0,0 +1,148 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ //File: app/code/community/Smsapi/Sms/Model/ApiClient.php
4
+
5
+ /**
6
+ * SMS API client class
7
+ *
8
+ * @category Smsapi
9
+ * @package SMS
10
+ * @copyright Copyright (c) 2012 Smsapi (http://smsapi.pl/)
11
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
12
+ * @author Marek Jasiukiewicz <dev@jasiukiewicz.pl>
13
+ * ...
14
+ */
15
+
16
+ class Smsapi_Sms_Model_ApiClient {
17
+
18
+
19
+ protected $_client = array();
20
+ protected $_sms = array();
21
+ protected $_hSopa;
22
+
23
+
24
+
25
+
26
+ public function __construct() {
27
+
28
+ $this->getClientData();
29
+
30
+ }
31
+
32
+
33
+
34
+
35
+ /**
36
+ * Get user authorization data from config and save it to $_client
37
+ *
38
+ * @param type $ssl
39
+ * @return \Smsapi_Sms_Model_ApiClient
40
+ */
41
+ public function getClientData() {
42
+
43
+ $config = Mage::getModel('sms/config');
44
+
45
+ $this->_client = array(
46
+ 'username' => $config->getApiLogin(),
47
+ 'password' => md5($config->getApiPassword())
48
+ );
49
+
50
+ return $this->_client;
51
+
52
+ }
53
+
54
+
55
+ /**
56
+ * Run SoapClient connection
57
+ *
58
+ * @param type $ssl
59
+ * @return \Smsapi_Sms_Model_ApiClient
60
+ */
61
+ public function connect($ssl = true) {
62
+
63
+ $this->_hSopa = new SoapClient(
64
+ ( $ssl == true ? 'https' : 'http' ) .'://www.smsapi.pl/soap/v2/webservice?wsdl',
65
+ array(
66
+ 'features' => SOAP_SINGLE_ELEMENT_ARRAYS,
67
+ 'cache_wsdl' => WSDL_CACHE_NONE,
68
+ 'trace' => TRUE
69
+ )
70
+ );
71
+
72
+ return $this;
73
+
74
+
75
+ }
76
+
77
+
78
+
79
+ /**
80
+ * Adding to SMS additional data
81
+ * for SMSAPI Soap Client
82
+ *
83
+ *
84
+ * @param type $sms_data
85
+ * @return \Smsapi_Sms_Model_ApiClient
86
+ */
87
+
88
+
89
+
90
+ public function msgContent($sms_data) {
91
+
92
+ $this->_sms = $sms_data;
93
+ $this->_sms['idx'] = uniqid();
94
+ $this->_sms['date_send'] = 0;
95
+ $this->_sms['details'] = 1;
96
+
97
+ return $this;
98
+
99
+ }
100
+
101
+
102
+
103
+ /**
104
+ * Sending SMS to client.
105
+ *
106
+ * @return type
107
+ */
108
+ public function send() {
109
+
110
+ $params = array(
111
+ 'client' => $this->_client,
112
+ 'sms' => $this->_sms
113
+ );
114
+
115
+ return $this->_hSopa->send_sms($params);
116
+
117
+ }
118
+
119
+
120
+
121
+ /**
122
+ * Getting Senders list from SMSAPI site
123
+ *
124
+ * @return type
125
+ */
126
+ public function getSenders() {
127
+
128
+ return $this->_hSopa->get_senders($this->_client);
129
+
130
+
131
+ }
132
+
133
+
134
+
135
+ /**
136
+ * Getting points amount from SMSAPI account
137
+ *
138
+ * @return type
139
+ */
140
+ public function getPoints() {
141
+
142
+ return $this->_hSopa->get_points($this->_client);
143
+
144
+ }
145
+
146
+
147
+
148
+ }
app/code/community/Smsapi/Sms/Model/Config.php ADDED
@@ -0,0 +1,128 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ //File: app/code/community/Smsapi/Sms/Model/Config.php
3
+
4
+ /**
5
+ * SMS API config class
6
+ *
7
+ *
8
+ * @category Smsapi
9
+ * @package SMS
10
+ * @copyright Copyright (c) 2012 Smsapi (http://smsapi.pl/)
11
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
12
+ * @author Marek Jasiukiewicz <dev@jasiukiewicz.pl>
13
+ * ...
14
+ */
15
+
16
+
17
+ class Smsapi_Sms_Model_Config {
18
+
19
+ const LOW_POINTS_WARNING_MESSAGE = 'Warning: Low points level at your SMSAPI account. Buy credit.';
20
+
21
+
22
+ /**
23
+ * getting API login from SMSAPI config
24
+ * @return string
25
+ */
26
+ public function getApiLogin() {
27
+ return Mage::getStoreConfig('sms/main_conf/apilogin');
28
+
29
+
30
+ }
31
+
32
+
33
+ /**
34
+ * getting API password from SMSAPI config
35
+ * @return string
36
+ */
37
+ public function getApiPassword() {
38
+ $encrypted_pass = Mage::getStoreConfig('sms/main_conf/apipassword');
39
+ return Mage::helper('core')->decrypt($encrypted_pass);
40
+
41
+ }
42
+
43
+
44
+ /**
45
+ * getting storename from SMSAPI config
46
+ * @return string
47
+ */
48
+ public function getApiStoreName() {
49
+ return Mage::getStoreConfig('sms/main_conf/storename');
50
+ }
51
+
52
+
53
+ /**
54
+ * Checks if allowed only single message
55
+ * @return int
56
+ */
57
+ public function isSingle() {
58
+ $confRule = Mage::getStoreConfig('sms/main_conf/allow_long_sms');
59
+
60
+ return ($confRule == 1) ? 0:1;
61
+
62
+ }
63
+
64
+ /**
65
+ * Checks if message is Eco
66
+ * @return int
67
+ */
68
+
69
+ public function isEco() {
70
+
71
+ return 0; //ECO messages turned off
72
+
73
+ //$confRule = Mage::getStoreConfig('sms/main_conf/sender');
74
+ //return ($confRule == 'eco_msg') ? 1:0;
75
+
76
+ }
77
+
78
+ /**
79
+ * getting message sender
80
+ * @return string
81
+ */
82
+ public function getSender() {
83
+
84
+ return Mage::getStoreConfig('sms/main_conf/sender');
85
+
86
+ }
87
+
88
+ /**
89
+ * getting SMS templates from SMSAPI config
90
+ * @return string
91
+ */
92
+ public function getMessageTemplate($template) {
93
+
94
+ $templateContent = Mage::getStoreConfig('sms/templates/status_'.$template);
95
+
96
+ if (Mage::getStoreConfig('sms/templates/status_'. $template .'_active') && !empty($templateContent))
97
+ return $templateContent;
98
+
99
+ }
100
+
101
+ public function pointsAllertLimit() {
102
+ return floatval(str_replace(',','.',Mage::getStoreConfig('sms/main_conf/points_alert_limit')));
103
+ }
104
+
105
+ /**
106
+ * checks if module is in test/devel mode
107
+ * @return string
108
+ */
109
+ public function testMode() {
110
+
111
+ $testmode = Mage::getStoreConfig('sms/admin_mode/test_mode');
112
+
113
+ return ($testmode==1) ? 1:0;
114
+
115
+ }
116
+
117
+ /**
118
+ * checks if SMSAPI module is enabled
119
+ * @return string
120
+ */
121
+ public function isApiEnabled() {
122
+
123
+ return Mage::getStoreConfig('sms/main_conf/active');
124
+
125
+ }
126
+
127
+
128
+ }
app/code/community/Smsapi/Sms/Model/Observer.php ADDED
@@ -0,0 +1,161 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ //File: app/code/community/Smsapi/Sms/Model/Observer.php
3
+
4
+ /**
5
+ * @category Smsapi
6
+ * @package SMS
7
+ * @copyright Copyright (c) 2012 Smsapi (http://smsapi.pl/)
8
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
9
+ * @author Marek Jasiukiewicz <dev@jasiukiewicz.pl>
10
+ * ...
11
+ */
12
+ class Smsapi_Sms_Model_Observer {
13
+
14
+ /**
15
+ *
16
+ * @param type $observer
17
+ * @return type
18
+ */
19
+
20
+ public function handleStatus($observer) {
21
+
22
+ $config = Mage::getModel('sms/config');
23
+ if ($config->isApiEnabled()==0) return; //do nothing if api is disabled
24
+
25
+ $order = $observer->getEvent()->getOrder();
26
+ $newStatus = $order->getData('status');
27
+ $origStatus = $order->getOrigData('status');
28
+
29
+
30
+ //if status has changed run action
31
+ if ($newStatus!=$origStatus) {
32
+
33
+ $message = $config->getMessageTemplate($newStatus); //get template for new status (if active and exists)
34
+ if (!$message) //return if no active message template
35
+ return;
36
+
37
+
38
+ //getting last tracking number
39
+ $trackings = Mage::getResourceModel('sales/order_shipment_track_collection')->setOrderFilter($order)->getData();
40
+
41
+ if (!empty($trackings)) {
42
+ $last = count($trackings)-1;
43
+ $last_tracking_number = $trackings[$last]['track_number'];
44
+ }
45
+ else
46
+ $last_tracking_number = 'no_tracking'; //if no tracking number set "no_tracking" message for {TRACKINGNUMBER} template
47
+
48
+
49
+ //getting order data to generate message template
50
+ $messageOrderData['{NAME}'] = $order->getShippingAddress()->getData('firstname');
51
+ $messageOrderData['{ORDERNUMBER}'] = $order->getIncrement_id();
52
+ $messageOrderData['{ORDERSTATUS}'] = $newStatus;
53
+ $messageOrderData['{TRACKINGNUMBER}'] = $last_tracking_number;
54
+ $messageOrderData['{STORENAME}'] = $config->getApiStoreName();
55
+
56
+ $message = strtr($message,$messageOrderData);
57
+
58
+
59
+ try { //try to send message
60
+
61
+ $api = Mage::getModel('sms/apiClient');
62
+ $api->connect();
63
+
64
+ //prepare sms content
65
+ $msg['recipient'] = $order->getShippingAddress()->getData('telephone'); //or getBillingAddress
66
+ $msg['message'] = $message;
67
+ $msg['eco'] = $config->isEco(); //eco version - without sender
68
+ $msg['test'] = $config->testMode();
69
+ $msg['single_message'] = $config->isSingle(); //allow_long_sms
70
+ $msg['sender'] = $config->getSender();//sender
71
+
72
+
73
+ //sending sms and getting API response
74
+
75
+ try {
76
+ $response = $api->msgContent($msg)->send();
77
+ $newComment = Mage::helper('sms')->__('SMS notification sent (SMS id:').$response->response[0]->id.') ' ;
78
+ $order->addStatusToHistory($order->getStatus(),$newComment,true);
79
+
80
+
81
+ } catch (Exception $e) {
82
+ $newComment = Mage::helper('sms')->__('SMS notification sending error: "').$e->getMessage().'"';
83
+ $order->addStatusToHistory($order->getStatus(),$newComment,false);
84
+ }
85
+
86
+ $this->checkPointsLimit(); //check
87
+
88
+
89
+ } catch ( Exception $e ) {
90
+ Mage::log('exception'.$e->getMessage());
91
+ }
92
+
93
+ }
94
+
95
+ }
96
+
97
+
98
+
99
+ /**
100
+ * Generating alert notification if SMSAPI account balance is low
101
+ *
102
+ * @return none
103
+ */
104
+
105
+ function checkPointsLimit() {
106
+
107
+ $config = Mage::getModel('sms/config');
108
+ if ($config->isApiEnabled()==0) return; //do nothing if api is disabled
109
+
110
+
111
+ $limit = $config->pointsAllertLimit();
112
+
113
+ if ($limit==0) return; //If limit allert is turned off
114
+
115
+
116
+ try {
117
+
118
+ $api = Mage::getModel('sms/apiClient');
119
+ $api->connect();
120
+ $res = $api->getPoints();
121
+
122
+ if ($res->points < $limit) { //alert admin if API account balance is lower than $limit
123
+
124
+ Mage::getSingleton('core/session')->addError(Mage::helper('sms')->__($config::LOW_POINTS_WARNING_MESSAGE));
125
+
126
+ }
127
+ }
128
+ catch (Exception $e) {
129
+ Mage::log('SMSAPI: '.$e->getMessage());
130
+ }
131
+
132
+ }
133
+
134
+ /**
135
+ * Check SMSAPI authorization data (login/password)
136
+ * and throw error notification to admin panel
137
+ *
138
+ * @return none
139
+ */
140
+ public function checkAuthorizationData() {
141
+ $config = Mage::getModel('sms/config');
142
+ if ($config->isApiEnabled()==0) return; //do nothing if api is disabled
143
+
144
+ if ($config->getApiLogin() && $config->getApiPassword()) {
145
+
146
+ try {
147
+ $api = Mage::getModel('sms/apiClient');
148
+ $api->connect()->getPoints();
149
+ }
150
+ catch (Exception $e) {
151
+ Mage::getSingleton('core/session')->addError(Mage::helper('sms')->__('SMSAPI: Wrong Password and/or Username'));
152
+ }
153
+ }
154
+
155
+
156
+ }
157
+
158
+
159
+
160
+
161
+ }
app/code/community/Smsapi/Sms/etc/config.xml ADDED
@@ -0,0 +1,139 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!--
3
+ File: app/code/community/Smsapi/Sms/etc/config.xml
4
+
5
+ /**
6
+ * Smsapi SMS Module
7
+ *
8
+ * NOTICE OF LICENSE
9
+ *
10
+ * This source file is subject to the Open Software License (OSL 3.0)
11
+ * that is bundled with this package in the file LICENSE.txt.
12
+ * It is also available through the world-wide-web at this URL:
13
+ * http://opensource.org/licenses/osl-3.0.php
14
+ * If you did not receive a copy of the license and are unable to
15
+ * obtain it through the world-wide-web, please send an email
16
+ * to license@magentocommerce.com so we can send you a copy immediately.
17
+ *
18
+ * DISCLAIMER
19
+ *
20
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
21
+ * versions in the future. If you wish to customize Magento for your
22
+ * needs please refer to http://www.magentocommerce.com for more information.
23
+ *
24
+ * Short Message Service (SMS) API
25
+ *
26
+ * @category Smsapi
27
+ * @package SMS
28
+ * @copyright Copyright (c) 2012 Smsapi (http://smsapi.pl/)
29
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
30
+ * @author Marek Jasiukiewicz <dev@jasiukiewicz.pl>
31
+ */
32
+
33
+ -->
34
+ <config>
35
+
36
+ <modules>
37
+ <Smsapi_Sms>
38
+ <version>0.1.0</version>
39
+ </Smsapi_Sms>
40
+ </modules>
41
+
42
+ <global>
43
+ <helpers>
44
+ <sms>
45
+ <class>Smsapi_Sms_Helper</class>
46
+ </sms>
47
+ </helpers>
48
+ <models>
49
+ <sms>
50
+ <class>Smsapi_Sms_Model</class>
51
+ </sms>
52
+ </models>
53
+ <events>
54
+ <sales_order_save_before>
55
+ <observers>
56
+ <order_new_status>
57
+ <class>Smsapi_Sms_Model_Observer</class>
58
+ <method>handleStatus</method>
59
+ </order_new_status>
60
+ </observers>
61
+ </sales_order_save_before>
62
+ </events>
63
+ <blocks>
64
+ <sms>
65
+ <class>Smsapi_Sms_Block</class>
66
+ </sms>
67
+ </blocks>
68
+ </global>
69
+ <default>
70
+ <sms>
71
+ <main_conf>
72
+ <points_alert_limit>0</points_alert_limit>
73
+ </main_conf>
74
+ <admin_conf>
75
+ <test_mode>1</test_mode>
76
+ </admin_conf>
77
+ </sms>
78
+ </default>
79
+ <adminhtml>
80
+ <layout>
81
+ <updates>
82
+ <Smsapi_Sms>
83
+ <file>Smsapi_Sms.xml</file>
84
+ </Smsapi_Sms>
85
+ </updates>
86
+ </layout>
87
+ <translate>
88
+ <modules>
89
+ <Smsapi_Sms>
90
+ <files>
91
+ <default>Smsapi_Sms.csv</default>
92
+ </files>
93
+ </Smsapi_Sms>
94
+ </modules>
95
+ </translate>
96
+ <events>
97
+ <admin_session_user_login_success>
98
+ <observers>
99
+ <sms_check_limits>
100
+ <class>Smsapi_Sms_Model_Observer</class>
101
+ <method>checkPointsLimit</method>
102
+ </sms_check_limits>
103
+ </observers>
104
+ </admin_session_user_login_success>
105
+ <admin_system_config_changed_section_sms>
106
+ <observers>
107
+ <sms_check_authorization_data>
108
+ <class>Smsapi_Sms_Model_Observer</class>
109
+ <method>checkAuthorizationData</method>
110
+ </sms_check_authorization_data>
111
+ </observers>
112
+ </admin_system_config_changed_section_sms>
113
+ </events>
114
+ <acl>
115
+ <resources>
116
+ <all>
117
+ <title>Allow Everything</title>
118
+ </all>
119
+ <admin>
120
+ <children>
121
+ <system>
122
+ <children>
123
+ <config>
124
+ <children>
125
+ <sms translate="title">
126
+ <title>SMS API</title>
127
+ <sort_order>100</sort_order>
128
+ </sms>
129
+ </children>
130
+ </config>
131
+ </children>
132
+ </system>
133
+ </children>
134
+ </admin>
135
+ </resources>
136
+ </acl>
137
+ </adminhtml>
138
+
139
+ </config>
app/code/community/Smsapi/Sms/etc/system.xml ADDED
@@ -0,0 +1,307 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!--
3
+ /**
4
+ * Smsapi Short Message Service (SMS) API
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-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@magentocommerce.com so we can send you a copy immediately.
15
+ *
16
+ * DISCLAIMER
17
+ *
18
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
19
+ * versions in the future. If you wish to customize Magento for your
20
+ * needs please refer to http://www.magentocommerce.com for more information.
21
+ *
22
+ * Short Message Service (SMS) API
23
+ *
24
+ * @category Smsapi
25
+ * @package SMS
26
+ * @copyright Copyright (c) 2012 Smsapi (http://smsapi.pl/)
27
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
28
+ * @author Marek Jasiukiewicz <dev@jasiukiewicz.pl>
29
+ */
30
+
31
+ -->
32
+
33
+ <config>
34
+ <tabs>
35
+ <smsapi translate="label">
36
+ <label>Smsapi</label>
37
+ <sort_order>1</sort_order>
38
+ </smsapi>
39
+ </tabs>
40
+ <sections>
41
+ <sms translate="label" module="sms">
42
+ <label>SMS API</label>
43
+ <tab>smsapi</tab>
44
+ <frontend_type>text</frontend_type>
45
+ <sort_order>1000</sort_order>
46
+ <show_in_default>1</show_in_default>
47
+ <show_in_website>1</show_in_website>
48
+ <show_in_store>1</show_in_store>
49
+ <groups>
50
+ <branding_header translate="label" module="storesms">
51
+ <frontend_model>sms/adminhtml_system_config_fieldset_branding</frontend_model>
52
+ <sort_order>0</sort_order>
53
+ <show_in_default>1</show_in_default>
54
+ <show_in_website>1</show_in_website>
55
+ <show_in_store>1</show_in_store>
56
+ </branding_header>
57
+ <main_conf translate="label comment" module="sms">
58
+ <label>Main Configuration</label>
59
+ <frontend_type>text</frontend_type>
60
+ <sort_order>99</sort_order>
61
+ <show_in_default>1</show_in_default>
62
+ <show_in_website>1</show_in_website>
63
+ <show_in_store>1</show_in_store>
64
+ <expanded>1</expanded>
65
+ <fields>
66
+ <active translate="label">
67
+ <label>Enabled</label>
68
+ <frontend_type>select</frontend_type>
69
+ <source_model>adminhtml/system_config_source_yesno</source_model>
70
+ <sort_order>1</sort_order>
71
+ <show_in_default>1</show_in_default>
72
+ <show_in_website>1</show_in_website>
73
+ <show_in_store>1</show_in_store>
74
+ </active>
75
+
76
+ <apilogin translate="label">
77
+ <label>API Login</label>
78
+ <frontend_type>text</frontend_type>
79
+ <sort_order>2</sort_order>
80
+ <show_in_default>1</show_in_default>
81
+ <show_in_website>1</show_in_website>
82
+ <show_in_store>1</show_in_store>
83
+ </apilogin>
84
+
85
+ <apipassword translate="label">
86
+ <label>API Password</label>
87
+ <frontend_type>obscure</frontend_type>
88
+ <backend_model>adminhtml/system_config_backend_encrypted</backend_model>
89
+ <sort_order>3</sort_order>
90
+ <show_in_default>1</show_in_default>
91
+ <show_in_website>1</show_in_website>
92
+ <show_in_store>1</show_in_store>
93
+ </apipassword>
94
+
95
+ <storename translate="label">
96
+ <label>Store name</label>
97
+ <frontend_type>text</frontend_type>
98
+ <sort_order>4</sort_order>
99
+ <show_in_default>1</show_in_default>
100
+ <show_in_website>1</show_in_website>
101
+ <show_in_store>1</show_in_store>
102
+ </storename>
103
+
104
+ <sender translate="label comment">
105
+ <label>SMS Sender</label>
106
+ <frontend_type>select</frontend_type>
107
+ <sort_order>5</sort_order>
108
+ <source_model>sms/adminhtml_attributes</source_model>
109
+ <show_in_default>1</show_in_default>
110
+ <show_in_website>1</show_in_website>
111
+ <show_in_store>1</show_in_store>
112
+ <comment>To add new SMS Sender go to "http://www.sms.pl" -> (left menu) USTAWIENIA -> POLA NADAWCY</comment>
113
+ </sender>
114
+
115
+ <allow_long_sms translate="label">
116
+ <label>Allow long messages (more than 160 chars)</label>
117
+ <frontend_type>select</frontend_type>
118
+ <source_model>adminhtml/system_config_source_yesno</source_model>
119
+ <sort_order>6</sort_order>
120
+ <show_in_default>1</show_in_default>
121
+ <show_in_website>1</show_in_website>
122
+ <show_in_store>1</show_in_store>
123
+ </allow_long_sms>
124
+
125
+ <points_alert_limit translate="label comment">
126
+ <label>Notify if my SMSAPI account points is below:</label>
127
+ <comment>0 - turn off/no alert</comment>
128
+ <frontend_type>text</frontend_type>
129
+ <sort_order>7</sort_order>
130
+ <show_in_default>1</show_in_default>
131
+ <show_in_website>1</show_in_website>
132
+ <show_in_store>1</show_in_store>
133
+ <validate>validate-zero-or-greater</validate>
134
+ </points_alert_limit>
135
+ </fields>
136
+ </main_conf>
137
+
138
+ <templates translate="label comment" module="sms">
139
+ <label>Message templates</label>
140
+ <frontend_type>text</frontend_type>
141
+ <comment><![CDATA[<div style="padding:10px;background-color:#fff;border:1px solid #CCC;margin-bottom:7px;">In each template you can use dynamic data. You can add <br />- {NAME} - customer name <br />- {ORDERSTATUS} - status of an order <br />- {ORDERNUMBER} - order number<br />- {TRACKINGNUMBER} - tracking number (if exists)<br />- {STORENAME} - the name of the store<br />Example: Your order #{ORDERNUMBER} waits for a fee. Regards {STORENAME}<br />SMS Content: Your order #100000012 waits for a fee. Regards smsapi.pl</div><div id="counterContainer">Message length: <span id="counter">0</span> chars.<br /> <span id="toolongalert"> Warning: The template can be to long for 1 SMS. Please shorten the message or allow to send long messages in Main Configuration.</span></div><br />]]></comment>
142
+ <sort_order>100</sort_order>
143
+ <show_in_default>1</show_in_default>
144
+ <show_in_website>1</show_in_website>
145
+ <show_in_store>1</show_in_store>
146
+ <expanded>1</expanded>
147
+ <fields>
148
+
149
+ <status_pending_payment_active translate="label">
150
+ <label>Send SMS after status changed to "Pending Payment"</label>
151
+ <frontend_type>select</frontend_type>
152
+ <source_model>adminhtml/system_config_source_yesno</source_model>
153
+ <sort_order>3</sort_order>
154
+ <show_in_default>1</show_in_default>
155
+ <show_in_website>1</show_in_website>
156
+ <show_in_store>1</show_in_store>
157
+ </status_pending_payment_active>
158
+ <status_pending_payment translate="label">
159
+ <label>Template</label>
160
+ <frontend_type>textarea</frontend_type>
161
+ <sort_order>4</sort_order>
162
+ <show_in_default>1</show_in_default>
163
+ <show_in_website>1</show_in_website>
164
+ <show_in_store>1</show_in_store>
165
+ <depends><status_pending_payment_active>1</status_pending_payment_active></depends>
166
+ </status_pending_payment>
167
+
168
+ <status_holded_active translate="label">
169
+ <label>Send SMS after status changed to "On Hold"</label>
170
+ <frontend_type>select</frontend_type>
171
+ <source_model>adminhtml/system_config_source_yesno</source_model>
172
+ <sort_order>5</sort_order>
173
+ <show_in_default>1</show_in_default>
174
+ <show_in_website>1</show_in_website>
175
+ <show_in_store>1</show_in_store>
176
+ </status_holded_active>
177
+ <status_holded translate="label">
178
+ <label>Template</label>
179
+ <frontend_type>textarea</frontend_type>
180
+ <sort_order>6</sort_order>
181
+ <show_in_default>1</show_in_default>
182
+ <show_in_website>1</show_in_website>
183
+ <show_in_store>1</show_in_store>
184
+ <depends><status_holded_active>1</status_holded_active></depends>
185
+ </status_holded>
186
+
187
+ <status_processing_active translate="label">
188
+ <label>Send SMS after status changed to "Processing"</label>
189
+ <frontend_type>select</frontend_type>
190
+ <source_model>adminhtml/system_config_source_yesno</source_model>
191
+ <sort_order>7</sort_order>
192
+ <show_in_default>1</show_in_default>
193
+ <show_in_website>1</show_in_website>
194
+ <show_in_store>1</show_in_store>
195
+ </status_processing_active>
196
+ <status_processing translate="label">
197
+ <label>Template</label>
198
+ <frontend_type>textarea</frontend_type>
199
+ <sort_order>8</sort_order>
200
+ <show_in_default>1</show_in_default>
201
+ <show_in_website>1</show_in_website>
202
+ <show_in_store>1</show_in_store>
203
+ <depends><status_processing_active>1</status_processing_active></depends>
204
+ </status_processing>
205
+
206
+ <status_canceled_active translate="label">
207
+ <label>Send SMS after status changed to "Canceled"</label>
208
+ <frontend_type>select</frontend_type>
209
+ <source_model>adminhtml/system_config_source_yesno</source_model>
210
+ <sort_order>9</sort_order>
211
+ <show_in_default>1</show_in_default>
212
+ <show_in_website>1</show_in_website>
213
+ <show_in_store>1</show_in_store>
214
+ </status_canceled_active>
215
+ <status_canceled translate="label">
216
+ <label>Template</label>
217
+ <frontend_type>textarea</frontend_type>
218
+ <sort_order>10</sort_order>
219
+ <show_in_default>1</show_in_default>
220
+ <show_in_website>1</show_in_website>
221
+ <show_in_store>1</show_in_store>
222
+ <depends><status_canceled_active>1</status_canceled_active></depends>
223
+ </status_canceled>
224
+
225
+ <status_complete_active translate="label">
226
+ <label>Send SMS after status changed to "Complete"</label>
227
+ <frontend_type>select</frontend_type>
228
+ <source_model>adminhtml/system_config_source_yesno</source_model>
229
+ <sort_order>11</sort_order>
230
+ <show_in_default>1</show_in_default>
231
+ <show_in_website>1</show_in_website>
232
+ <show_in_store>1</show_in_store>
233
+ </status_complete_active>
234
+ <status_complete translate="label">
235
+ <label>Template</label>
236
+ <frontend_type>textarea</frontend_type>
237
+ <sort_order>12</sort_order>
238
+ <show_in_default>1</show_in_default>
239
+ <show_in_website>1</show_in_website>
240
+ <show_in_store>1</show_in_store>
241
+ <depends><status_complete_active>1</status_complete_active></depends>
242
+ </status_complete>
243
+
244
+ <status_closed_active translate="label">
245
+ <label>Send SMS after status changed to "Closed"</label>
246
+ <frontend_type>select</frontend_type>
247
+ <source_model>adminhtml/system_config_source_yesno</source_model>
248
+ <sort_order>13</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
+ </status_closed_active>
253
+ <status_closed translate="label">
254
+ <label>Template</label>
255
+ <frontend_type>textarea</frontend_type>
256
+ <sort_order>14</sort_order>
257
+ <show_in_default>1</show_in_default>
258
+ <show_in_website>1</show_in_website>
259
+ <show_in_store>1</show_in_store>
260
+ <depends><status_closed_active>1</status_closed_active></depends>
261
+ </status_closed>
262
+ </fields>
263
+ </templates>
264
+
265
+ <admin_mode translate="label" module="sms">
266
+ <label>Test configuration</label>
267
+ <frontend_type>text</frontend_type>
268
+ <sort_order>101</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
+ <expanded>0</expanded>
273
+ <fields>
274
+ <test_mode translate="label comment">
275
+ <label>Turn on "Test mode"</label>
276
+ <frontend_type>select</frontend_type>
277
+ <source_model>adminhtml/system_config_source_yesno</source_model>
278
+ <comment>In test mode. API working like in normal mode (sending errors, checking sent data etc.) whithout SMS sending.</comment>
279
+ <sort_order>1</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
+ </test_mode>
284
+ </fields>
285
+ </admin_mode>
286
+ <registration translate="label" module="sms">
287
+ <label>Registration</label>
288
+ <frontend_type>text</frontend_type>
289
+ <sort_order>150</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
+ <buttons translate="label">
295
+ <label>Registration</label>
296
+ <frontend_model>sms/buttons</frontend_model>
297
+ <sort_order>101</sort_order>
298
+ <show_in_default>1</show_in_default>
299
+ <show_in_website>1</show_in_website>
300
+ <show_in_store>1</show_in_store>
301
+ </buttons>
302
+ </fields>
303
+ </registration>
304
+ </groups>
305
+ </sms>
306
+ </sections>
307
+ </config>
app/design/adminhtml/base/default/layout/Smsapi_Sms.xml ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <layout version="0.1.0">
3
+ <default>
4
+ <reference name="head">
5
+ <action method="addJs"><script>smsapi/sms/counter.js</script></action>
6
+ </reference>
7
+ </default>
8
+ </layout>
9
+
app/design/adminhtml/base/default/template/sms/system/config/fieldset/branding.phtml ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
1
+ <style type="text/css">
2
+
3
+ .entry-edit .entry-edit-head { background:#0383cc !important; }
4
+ .content-header { margin-bottom: 0px !important; }
5
+
6
+ </style>
7
+ <div style="overflow: hidden;"><img src="<?php echo $this->getSkinUrl('images/smsapi/sms/smsapi_logo.jpg'); ?>"></div>
app/etc/modules/Smsapi_Sms.xml ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Smsapi_Sms>
5
+ <active>true</active>
6
+ <codePool>community</codePool>
7
+ </Smsapi_Sms>
8
+ </modules>
9
+ </config>
app/locale/pl_PL/Smsapi_Sms.csv ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ "Main Configuration","SMS API - konfiguracja podstawowa"
2
+ "Enabled","Włączone"
3
+ "API Login","API - login"
4
+ "API Password","API - hasło"
5
+ "Store name","Nazwa sklepu"
6
+ "SMS Sender","Nadawca SMS"
7
+ "Allow long messages (more than 160 chars)","Zezwalaj na kilkuczęściowe SMSy (dłuższe niż 160 znaków)"
8
+ "Message templates","Szablony wiadomości"
9
+ "Template","Szablon"
10
+ "Send SMS after status changed to ""Pending Payment""","Wyślij SMS-a po zmianie statusu na ""Pending Payment/Oczekuje na płatność"""
11
+ "Send SMS after status changed to ""On Hold""","Wyślij SMS-a po zmianie statusu na ""On Hold/Wstrzymano"""
12
+ "Send SMS after status changed to ""Canceled""","Wyślij SMS-a po zmianie statusu na ""Canceled/Anulowane"""
13
+ "Send SMS after status changed to ""Complete""","Wyślij SMS-a po zmianie statusu na ""Complete/Zakończone"""
14
+ "Send SMS after status changed to ""Closed""","Wyślij SMS-a po zmianie statusu na ""Closed/Zamknięty"""
15
+ "Send SMS after status changed to ""Processing""","Wyślij SMS-a po zmianie statusu na ""Processing/Przetwarzam"""
16
+ "To add new SMS Sender go to ""http://www.sms.pl"" -> (left menu) USTAWIENIA -> POLA NADAWCY","Aby dodać nowe pole nadawcy, zaloguj się do Panelu SMSAPI na stronie: ""http://www.smsapi.pl"" -> (lewe menu) USTAWIENIA -> POLA NADAWCY"
17
+ "Pending Payment","Oczekuje na płatność"
18
+ "On Hold","Wstrzymano"
19
+ "Canceled","Anulowane"
20
+ "Complete","Zakończone"
21
+ "Closed","Zamknięty"
22
+ "Processing","Przetwarzam"
23
+ "Use ECO SMS (cheaper version without sender)","SMS Ekonomiczny (tańsza wersja bez nadawcy)"
24
+ "Notify if my SMSAPI account points is below:","Informuj mnie jeśli ilość punktów na koncie SMSAPI spadnie poniżej: (0 - powiadomienie wyłączone)"
25
+ "0 - turn off/no alert","0 - wyłącz/bez powiadomienia"
26
+ "Warning: Low points level at your SMSAPI account. Buy credit.","Ostrzeżenie: Niski stan punktów na Twoim koncie SMSAPI. Doładuj konto."
27
+ "<div style=""padding:10px;background-color:#fff;border:1px solid #CCC;margin-bottom:7px;"">In each template you can use dynamic data. You can add <br />- {NAME} - customer name <br />- {ORDERSTATUS} - status of an order <br />- {ORDERNUMBER} - order number<br />- {TRACKINGNUMBER} - tracking number (if exists)<br />- {STORENAME} - the name of the store<br />Example: Your order #{ORDERNUMBER} waits for a fee. Regards {STORENAME}<br />SMS Content: Your order #100000012 waits for a fee. Regards smsapi.pl</div><div id=""counterContainer"">Message length: <span id=""counter"">0</span> chars.<br /> <span id=""toolongalert""> Warning: The template can be to long for 1 SMS. Please shorten the message or allow to send long messages in Main Configuration.</span></div><br />","<div style=""padding:10px;background-color:#fff;border:1px solid #CCC;margin-bottom:7px;""> <p>W każdym szablonie możesz używać danych dynamicznych. Możesz dodać:<br /> - {NAME} - imię klienta <br /> - {ORDERSTATUS} - status przesyłki <br /> - {ORDERNUMBER} - nr zamówienia<br /> - {TRACKINGNUMBER} - nr pozwalający na śledzenie przesyłki (jeśli istnieje)<br /> - {STORENAME} - nazwa sklepu<br /> Przykład: Twoje zamówienie nr {ORDERNUMBER} czeka na wpłatę. Pozdrawiamy {STORENAME}.<br /> Treść wysłanego SMSa: Twoje zamówienie nr 100000012 czeka na wpłatę. Pozdrawiamy smsapi.pl.</p></div><div id=""counterContainer"">Długość wiadomości: <span id=""counter"">0</span> znaków.<br /> <span id=""toolongalert""> Ostrzeżenie: Wiadomość zawarta w szablonie może być zbyt długa na pojedynczą wiadomość SMS. Proszę skrócić wiadomość lub zezwolić na wysyłanie długich wiadomości SMS w konfiguracji podstawowej.</span></div><br />"
28
+ "SMS notification sent (SMS id:","Wysłano SMS z powiadomieniem (id SMS-a:"
29
+ "SMS notification sending error: ""","Błąd podczas wysyłania SMS-a z powiadomieniem. Treść błędu: """
30
+ "In test mode. API working like in normal mode (sending errors, checking sent data etc.) whithout SMS sending.","W trybie testowym, API działa normalnie (odbiera błędy, sprawdza wysłane dane itp.) jednak nie wysyła SMS-a"
31
+ "Test configuration","Konfiguracja testowa"
32
+ "Turn on ""Test mode""","Włącz tryb testowy"
33
+ "Failed to send SMS notification. Please configure Your SMS API","Nie udało się wysłać powiadomienia SMS. Proszę poprawnie skonfigurować API"
34
+ "SMSAPI: Wrong Password and/or Username","SMS API: Nieprawidłowa nazwa użytkownika lub hasło."
35
+ "Registration","Rejestracja"
36
+ "Open registration form","Otwórz formularz rejestracyjny"
js/smsapi/sms/counter.js ADDED
@@ -0,0 +1,83 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // Create the class
2
+
3
+ var mySmsapiCounter = Class.create({
4
+
5
+ initialize:function(eventToObserve) // Is called when the page has finished loading by the Event.observe code below
6
+ {
7
+
8
+ var counter = document.getElementById('counter');
9
+ var counterContainer = document.getElementById('counterContainer');
10
+ var maxchars = 160;
11
+ var childAdded = false;
12
+ var activeTextArea = false;
13
+ var textAreaId = false;
14
+
15
+ $('sms_templates').observe(eventToObserve, function(event) {
16
+ var textlength = 0;
17
+ activeTextArea = event.findElement('textarea');
18
+
19
+ if(activeTextArea) {
20
+
21
+ counterContainer.show(); //snow counter div at starts
22
+
23
+ if (textAreaId != activeTextArea.id) {
24
+ counterContainer.remove(); //remove old counterContainer
25
+ activeTextArea.insert({ //reinitialize conterContainer in new position
26
+ after: counterContainer
27
+ });
28
+ }
29
+
30
+ textlength = activeTextArea.value.length;
31
+ counter.update(textlength);
32
+
33
+ if(textlength<=(maxchars-50)) {
34
+
35
+ $('counter').setStyle({
36
+ border:'0px',
37
+ fontWeight:' normal',
38
+ color: 'inherit',
39
+ backgroundColor: 'inherit'
40
+ });
41
+ $('toolongalert').hide();
42
+
43
+ }
44
+ else if(textlength<=(maxchars-20)) {
45
+
46
+ $('counter').setStyle({
47
+ border:'1px solid orange',
48
+ fontWeight:' normal',
49
+ color: 'black',
50
+ backgroundColor: 'yellow'
51
+ });
52
+ $('toolongalert').hide();
53
+
54
+ } else {
55
+
56
+ $('counter').setStyle ({
57
+ border:'1px solid red',
58
+ fontWeight:' bold',
59
+ color: 'white',
60
+ backgroundColor: '#900'
61
+ });
62
+ $('toolongalert').show();
63
+
64
+ }
65
+
66
+
67
+ }
68
+
69
+
70
+
71
+
72
+ });
73
+
74
+ }
75
+
76
+ });
77
+ // Global variable for the instance of the class
78
+ // Creating an instance of the class if the page has finished loading
79
+ Event.observe(window, 'load', function() {
80
+ document.getElementById('counterContainer').hide(); //hide counter div at start
81
+ new mySmsapiCounter('click');
82
+ new mySmsapiCounter('keyup');
83
+ });
package.xml ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>Smsapi_Sms</name>
4
+ <version>0.1.0</version>
5
+ <stability>stable</stability>
6
+ <license>SMSAPI licence</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>SMSAPI SMS module</summary>
10
+ <description>SMSAPI SMS module</description>
11
+ <notes>SMSAPI SMS v 0.1.0</notes>
12
+ <authors><author><name>Marek Jasiukiewicz</name><user>jasiukiewicz_m</user><email>dev@jasiukiewicz.pl</email></author><author><name>Snowdog</name><user>snowdog</user><email>support@snowdog.pl</email></author><author><name>SMSAPI</name><user>smsapi</user><email>info@smsapi.pl</email></author></authors>
13
+ <date>2013-03-15</date>
14
+ <time>13:32:36</time>
15
+ <contents><target name="magecommunity"><dir name="Smsapi"><dir name="Sms"><dir><dir name="Block"><dir name="Adminhtml"><dir name="System"><dir name="Config"><dir name="Fieldset"><file name="Branding.php" hash="849bdf4e1e79bc1e83a871a5d92d69b4"/></dir></dir></dir></dir><file name="Buttons.php" hash="9c3419026c5a9e89ccd6d0203faeee51"/></dir><dir name="Helper"><file name="Data.php" hash="c9f5c5eda233f035bf8d44d5bdf040ea"/></dir><dir name="Model"><dir name="Adminhtml"><file name="Attributes.php" hash="daec22c1bf38a90c4cce45a264f82516"/></dir><file name="ApiClient.php" hash="74ab753538d8effa2d837ac50ebb9b40"/><file name="Config.php" hash="e19170fc3519ba96493770096f730ba0"/><file name="Observer.php" hash="e71f9053b6ae7728d85d2f12fe716db3"/></dir><dir name="etc"><file name="config.xml" hash="1141efc0f4baefe9d01354f1a0d26e98"/><file name="system.xml" hash="5f8df5a6d5b25742dfab72038a87d7a3"/></dir></dir></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="base"><dir name="default"><dir name="layout"><file name="Smsapi_Sms.xml" hash="93d7067aa579e4c268b0174164e9f4ff"/></dir><dir name="template"><dir name="sms"><dir name="system"><dir name="config"><dir name="fieldset"><file name="branding.phtml" hash="13191207a7a8c105f360e67f5b3a5151"/></dir></dir></dir></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Smsapi_Sms.xml" hash="4e65007f9573a00788a27745861bcaab"/></dir></target><target name="mage"><dir name="js"><dir name="smsapi"><dir name="sms"><file name="counter.js" hash="5ff48e9e8c365324e76526cf160b0c39"/></dir></dir></dir></target><target name="magelocale"><dir name="pl_PL"><file name="Smsapi_Sms.csv" hash="91af27e99ee271d5b69b6d9fb754096b"/></dir></target><target name="mageskin"><dir name="adminhtml"><dir name="base"><dir name="default"><dir name="images"><dir name="smsapi"><dir name="sms"><file name="smsapi_logo.jpg" hash="8fe4a8d39c915d9e5d138cadf4a3fca4"/></dir></dir></dir></dir></dir></dir></target></contents>
16
+ <compatible/>
17
+ <dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
18
+ </package>
skin/adminhtml/base/default/images/smsapi/sms/smsapi_logo.jpg ADDED
Binary file