OctopushSms - Version 1.0.0

Version Notes

First package of this extension.

Download this release

Release Info

Developer Carl
Extension OctopushSms
Version 1.0.0
Comparing to
See all releases


Version 1.0.0

Files changed (79) hide show
  1. app/code/local/Octopush/OctopushSms/Block/Campaign/Ajax.php +5 -0
  2. app/code/local/Octopush/OctopushSms/Block/Campaign/Controller/Grid.php +90 -0
  3. app/code/local/Octopush/OctopushSms/Block/Campaign/Edit.php +118 -0
  4. app/code/local/Octopush/OctopushSms/Block/Campaign/Edit/Form.php +98 -0
  5. app/code/local/Octopush/OctopushSms/Block/Campaign/Edit/FormToErase.php +98 -0
  6. app/code/local/Octopush/OctopushSms/Block/Campaign/Edit/Info.php +47 -0
  7. app/code/local/Octopush/OctopushSms/Block/Campaign/Edit/Tabs.php +23 -0
  8. app/code/local/Octopush/OctopushSms/Block/Campaign/Edit_1.php +93 -0
  9. app/code/local/Octopush/OctopushSms/Block/Campaign/Grid.php +24 -0
  10. app/code/local/Octopush/OctopushSms/Block/Campaign/Renderer/Price.php +9 -0
  11. app/code/local/Octopush/OctopushSms/Block/Campaign/Renderer/Status.php +9 -0
  12. app/code/local/Octopush/OctopushSms/Block/Campaignblock.php +31 -0
  13. app/code/local/Octopush/OctopushSms/Block/CampaignblockTODOREMOVE.php +31 -0
  14. app/code/local/Octopush/OctopushSms/Block/Messages.php +199 -0
  15. app/code/local/Octopush/OctopushSms/Block/Messages_1.php +174 -0
  16. app/code/local/Octopush/OctopushSms/Block/News.php +47 -0
  17. app/code/local/Octopush/OctopushSms/Block/Recipient/Controller/Grid.php +112 -0
  18. app/code/local/Octopush/OctopushSms/Block/Recipient/Grid.php +18 -0
  19. app/code/local/Octopush/OctopushSms/Block/Recipient/Renderer/Status.php +10 -0
  20. app/code/local/Octopush/OctopushSms/Block/Setting.php +29 -0
  21. app/code/local/Octopush/OctopushSms/Helper/API.php +393 -0
  22. app/code/local/Octopush/OctopushSms/Helper/API_SMS_PHP_Octopush/balance.php +19 -0
  23. app/code/local/Octopush/OctopushSms/Helper/API_SMS_PHP_Octopush/campagne.php +37 -0
  24. app/code/local/Octopush/OctopushSms/Helper/API_SMS_PHP_Octopush/config.inc.php +179 -0
  25. app/code/local/Octopush/OctopushSms/Helper/API_SMS_PHP_Octopush/create_sub_account.php +23 -0
  26. app/code/local/Octopush/OctopushSms/Helper/API_SMS_PHP_Octopush/credit_sub_account.php +18 -0
  27. app/code/local/Octopush/OctopushSms/Helper/API_SMS_PHP_Octopush/edit_options.php +26 -0
  28. app/code/local/Octopush/OctopushSms/Helper/API_SMS_PHP_Octopush/get_user_info.php +20 -0
  29. app/code/local/Octopush/OctopushSms/Helper/API_SMS_PHP_Octopush/octopush_web_services.inc.php +247 -0
  30. app/code/local/Octopush/OctopushSms/Helper/API_SMS_PHP_Octopush/sms.inc.php +555 -0
  31. app/code/local/Octopush/OctopushSms/Helper/API_SMS_PHP_Octopush/sms_batch.php +23 -0
  32. app/code/local/Octopush/OctopushSms/Helper/API_SMS_PHP_Octopush/sms_parts.php +45 -0
  33. app/code/local/Octopush/OctopushSms/Helper/Campaign.php +251 -0
  34. app/code/local/Octopush/OctopushSms/Helper/Customer.php +63 -0
  35. app/code/local/Octopush/OctopushSms/Helper/Data.php +7 -0
  36. app/code/local/Octopush/OctopushSms/Helper/Message.php +696 -0
  37. app/code/local/Octopush/OctopushSms/Helper/Statistic.php +48 -0
  38. app/code/local/Octopush/OctopushSms/Model/Campaign.php +58 -0
  39. app/code/local/Octopush/OctopushSms/Model/Message.php +9 -0
  40. app/code/local/Octopush/OctopushSms/Model/Mysql4/Campaign.php +14 -0
  41. app/code/local/Octopush/OctopushSms/Model/Mysql4/Campaign/Collection.php +10 -0
  42. app/code/local/Octopush/OctopushSms/Model/Mysql4/Message.php +13 -0
  43. app/code/local/Octopush/OctopushSms/Model/Mysql4/Message/Collection.php +10 -0
  44. app/code/local/Octopush/OctopushSms/Model/Mysql4/Phoneprefix.php +13 -0
  45. app/code/local/Octopush/OctopushSms/Model/Mysql4/Phoneprefix/Collection.php +10 -0
  46. app/code/local/Octopush/OctopushSms/Model/Mysql4/Recipient.php +14 -0
  47. app/code/local/Octopush/OctopushSms/Model/Mysql4/Recipient/Collection.php +10 -0
  48. app/code/local/Octopush/OctopushSms/Model/Mysql4/Setting.php +13 -0
  49. app/code/local/Octopush/OctopushSms/Model/Mysql4/Setting/Collection.php +10 -0
  50. app/code/local/Octopush/OctopushSms/Model/Mysql4/Test.php +8 -0
  51. app/code/local/Octopush/OctopushSms/Model/Mysql4/Test/Collection.php +9 -0
  52. app/code/local/Octopush/OctopushSms/Model/Observer/AbstractObserver.php +11 -0
  53. app/code/local/Octopush/OctopushSms/Model/Observer/Observer.php +186 -0
  54. app/code/local/Octopush/OctopushSms/Model/Phoneprefix.php +10 -0
  55. app/code/local/Octopush/OctopushSms/Model/Recipient.php +28 -0
  56. app/code/local/Octopush/OctopushSms/Model/Setting.php +85 -0
  57. app/code/local/Octopush/OctopushSms/Model/Test.php +12 -0
  58. app/code/local/Octopush/OctopushSms/controllers/Adminhtml/IndexController.php +774 -0
  59. app/code/local/Octopush/OctopushSms/controllers/IndexController.php +34 -0
  60. app/code/local/Octopush/OctopushSms/etc/config.xml +231 -0
  61. app/code/local/Octopush/OctopushSms/sql/octopush_octopushsms_setup/install-1.0.0.php +108 -0
  62. app/code/local/Octopush/OctopushSms/sql/octopush_octopushsms_setup/mysql4-install-0.1.0 +112 -0
  63. app/code/local/Octopush/OctopushSms/tmp.txt +8 -0
  64. app/design/adminhtml/default/default/layout/octopushsms.xml +78 -0
  65. app/design/adminhtml/default/default/template/octopushsms/afficher.phtml +194 -0
  66. app/design/adminhtml/default/default/template/octopushsms/ajax.phtml +1 -0
  67. app/design/adminhtml/default/default/template/octopushsms/campaign.phtml +321 -0
  68. app/design/adminhtml/default/default/template/octopushsms/chooseRecipient.phtml +113 -0
  69. app/design/adminhtml/default/default/template/octopushsms/info.phtml +55 -0
  70. app/design/adminhtml/default/default/template/octopushsms/messages.phtml +28 -0
  71. app/design/adminhtml/default/default/template/octopushsms/news.phtml +2 -0
  72. app/design/adminhtml/default/default/template/octopushsms/notice.phtml +21 -0
  73. app/etc/modules/Octopush_OctopushSms.xml +14 -0
  74. app/locale/fr_FR/Octopush_OctopushSms.csv +271 -0
  75. js/octopushsms/octopushsms.js +409 -0
  76. media/octopushsms/example.csv +4 -0
  77. package.xml +22 -0
  78. skin/adminhtml/base/default/octopushsms/grid.css +242 -0
  79. skin/adminhtml/base/default/octopushsms/octopushsms.css +30 -0
app/code/local/Octopush/OctopushSms/Block/Campaign/Ajax.php ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
1
+ <?php
2
+
3
+ class Octopush_OctopushSms_Block_Campaign_Ajax extends Mage_Core_Block_Template {
4
+
5
+ }
app/code/local/Octopush/OctopushSms/Block/Campaign/Controller/Grid.php ADDED
@@ -0,0 +1,90 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Octopush_OctopushSms_Block_Campaign_Controller_Grid extends Mage_Adminhtml_Block_Widget_Grid {
4
+
5
+ public function __construct() {
6
+ parent::__construct();
7
+ $this->setId('campaignGrid');
8
+ $this->setDefaultSort('id_sendsms_campaign');
9
+ $this->setDefaultDir('DESC');
10
+ $this->setSaveParametersInSession(true);
11
+ }
12
+
13
+ protected function _prepareCollection() {
14
+ $collection = Mage::getModel('octopushsms/campaign')->getCollection();
15
+ if ($this->getRequest()->getActionName() == 'history') {
16
+ $collection->addFieldToFilter('status', array('in' => array(3, 4, 5)));
17
+ } else {
18
+ $collection->addFieldToFilter('status', array('nin' => array(3, 4, 5)));
19
+ }
20
+ $this->setCollection($collection);
21
+ return parent::_prepareCollection();
22
+ }
23
+
24
+ protected function _prepareColumns() {
25
+ $this->addColumn('id_sendsms_campaign', array(
26
+ 'header' => 'ID',
27
+ 'align' => 'right',
28
+ 'width' => '50px',
29
+ 'index' => 'id_sendsms_campaign',
30
+ ));
31
+ $this->addColumn('ticket', array(
32
+ 'header' => __('Ticket'),
33
+ 'align' => 'left',
34
+ 'index' => 'ticket',
35
+ ));
36
+ $this->addColumn('title', array(
37
+ 'header' => __('Title'),
38
+ 'align' => 'left',
39
+ 'index' => 'title',
40
+ ));
41
+ $values = Mage::helper('octopushsms/Campaign')->get_status_array();
42
+ $this->addColumn('status', array(
43
+ 'header' => __('Status'),
44
+ 'align' => 'left',
45
+ 'index' => 'status',
46
+ 'type' => 'options',
47
+ 'options' => $values,
48
+ 'renderer' => 'Octopush_OctopushSms_Block_Campaign_Renderer_Status',
49
+ ));
50
+ $this->addColumn('nb_recipients', array(
51
+ 'header' => __('Nb recipients'),
52
+ 'align' => 'left',
53
+ 'index' => 'nb_recipients',
54
+ ));
55
+ $this->addColumn('price', array(
56
+ 'header' => __('Price'),
57
+ 'align' => 'left',
58
+ 'index' => 'price',
59
+ 'renderer' => 'Octopush_OctopushSms_Block_Campaign_Renderer_Price',
60
+ ));
61
+ $this->addColumn('date_send', array(
62
+ 'header' => __('Sending date'),
63
+ 'align' => 'left',
64
+ 'index' => 'date_send',
65
+ ));
66
+ //TODO user action
67
+ $link = Mage::getUrl('*/*/edit', array('id' => '$entity_id'));
68
+ $this->addColumn('action_edit', array(
69
+ 'header' => $this->helper('octopushsms')->__('Action'),
70
+ 'width' => 15,
71
+ 'getter' => 'getId',
72
+ 'sortable' => false,
73
+ 'filter' => false,
74
+ 'type' => 'action',
75
+ 'actions' => array(
76
+ array(
77
+ 'url' => array('base' => '*/*/edit'),
78
+ 'caption' => $this->helper('octopushsms')->__('Edit'),
79
+ 'field' => 'id'
80
+ ),
81
+ )
82
+ ));
83
+ return parent::_prepareColumns();
84
+ }
85
+
86
+ public function getRowUrl($row) {
87
+ return $this->getUrl('*/*/edit', array('id' => $row->getId()));
88
+ }
89
+
90
+ }
app/code/local/Octopush/OctopushSms/Block/Campaign/Edit.php ADDED
@@ -0,0 +1,118 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Octopush_OctopushSms_Block_Campaign_Edit extends Mage_Core_Block_Template {
4
+
5
+ public $setting;
6
+ public $b_auth;
7
+ public $campaign;
8
+ protected $Helper_api;
9
+ protected $Helper_campaign;
10
+ protected $balance;
11
+ public $back_url;
12
+
13
+ public function __construct() {
14
+ $setting = Mage::getModel('octopushsms/setting')->load('1');
15
+ $this->b_auth = $setting->getData('octopush_sms_email') ? true : false;
16
+ $this->campaign = Mage::registry('campaign_data');
17
+ $this->Helper_api = Mage::helper('octopushsms/API');
18
+ $this->Helper_campaign = Mage::helper('octopushsms/Campaign');
19
+ $api_balance = $this->Helper_api->get_balance();
20
+ $this->balance = $api_balance !== '001' ? $api_balance : 0;
21
+
22
+ if ($this->getRequest()->getActionName() != 'history') {
23
+ $this->back_url = Mage::helper("adminhtml")->getUrl('adminoctopushsms/adminhtml_index/campaign/');
24
+ } else {
25
+ $this->back_url = Mage::helper("adminhtml")->getUrl('adminoctopushsms/adminhtml_index/history/');
26
+ }
27
+ parent::_construct();
28
+ }
29
+
30
+ public function output_button() {
31
+ //setLocation(\'' . $this->getUrl('*/*/campaign') . '\')
32
+ ?>
33
+
34
+ <div class="content-header">
35
+ <h3 class="icon-head head-campaign"><?php echo __('Edit campaign') ?></h3>
36
+ <p class="form-buttons" style="display: <?php (isset($_REQUEST['sendsms_transmit']) && $this->campaign == 1 ? 'none' : 'block') ?>">
37
+ <button id="id_back" title="Back" type="button" class="scalable back" onclick="setLocation('<?php echo $this->back_url; ?>')" style="">
38
+ <span><span><span>Back</span></span></span>
39
+ </button>
40
+ <!--TODO remove <button id="id_5e4de885b14e6e9025bfb2c135241f29" title="delete campaign" type="button" class="scalable delete" onclick="deleteConfirm('Are you sure you want to do this?', 'http://localhost/mag/index.php/adminoctopushsms/adminhtml_index/delete/id/11/key/03f696c687944087e06e2591b97a905d/')" style="">
41
+ <span><span><span>delete campaign</span></span></span>
42
+ </button>-->
43
+ <?php if ($this->getRequest()->getActionName() == 'edit') { ?>
44
+ <button id="sendsms_save" name="sendsms_save" title="<?php echo __('Save this campaign') ?>" type="button" class="scalable save" style="" onclick="submitForm(this);">
45
+ <span><span><span><?php echo __('Save this campaign') ?></span></span></span>
46
+ </button>
47
+ <button <?php (!$this->b_auth ? 'disabled="disabled"' : '') ?> id="sendsms_transmit" name="sendsms_transmit" title="<?php echo __('Transmit to Octopush') ?>" type="button" class="scalable save" onclick="submitForm(this);" style="">
48
+ <span><span><span><?php echo __('Transmit to Octopush') ?></span></span></span>
49
+ </button>
50
+ <?php if ($this->campaign->getData('status') < 3) { ?>
51
+ <button <?php (!$this->b_auth ? 'disabled="disabled"' : '') ?> id="sendsms_validate" name="sendsms_validate" title="<?php echo __('Accept & Send') ?>" type="button" class="scalable save" onclick="submitForm(this);" style="">
52
+ <span><span><span><?php echo __('Accept & Send') ?></span></span></span>
53
+ </button>
54
+ <?php
55
+ }
56
+ }
57
+ if ($this->campaign->getData('status') >= 1 || $this->campaign->getData('status') < 3 || ($this->campaign->getData('status') == 3 && Mage::getModel('core/date')->date('Y-m-d H:m:s') < $this->campaign->getData('date_send'))) {
58
+ ?>
59
+ <button <?php (!$this->b_auth ? 'disabled="disabled"' : '') ?> id="sendsms_cancel" name="sendsms_cancel" title="<?php echo __('Cancel this campaign') ?>" type="button" class="scalable save" onclick="submitForm(this);" style="">
60
+ <span><span><span><?php echo __('Cancel this campaign') ?></span></span></span>
61
+ </button>
62
+ <?php } ?>
63
+ <button <?php (!$this->b_auth ? 'disabled="disabled"' : '') ?> id="sendsms_delete" name="sendsms_delete" title="<?php echo __('Delete this campaign') ?>" type="button" class="scalable delete" onclick="submitForm(this);" style="">
64
+ <span><span><span><?php echo __('Delete this campaign') ?></span></span></span>
65
+ </button>
66
+ <?php if ($this->campaign->getData('event') == 'sendsmsFree') { ?>
67
+ <button <?php (!$this->b_auth ? 'disabled="disabled"' : '') ?> id="sendsms_duplicate" name="sendsms_duplicate" title="<?php echo __('Duplicate this campaign') ?>" type="button" class="scalable save" onclick="submitForm(this);" style="">
68
+ <span><span><span><?php echo __('Duplicate this campaign') ?></span></span></span>
69
+ </button>
70
+ <?php } ?>
71
+ </p>
72
+ </div>
73
+ <?php
74
+ }
75
+
76
+ public function getHeaderText() {
77
+ if (Mage::registry('campaign_data') && Mage::registry('campaign_data')->getId()) {
78
+ return __('Edit campaign ') . $this->htmlEscape(
79
+ Mage::registry('campaign_data')->getTitle()) . '<br />';
80
+ } else {
81
+ return __('Add campaign');
82
+ }
83
+ }
84
+
85
+ public function output_campaign_details() {
86
+ echo '
87
+ <fieldset class="box" id="block_infos">
88
+
89
+ <h2><span class="dashicons dashicons-info vmiddle"></span>' . __('Information') . '</h2>
90
+ <div class="toastgrid">
91
+ <div class="toastgrid__col toastgrid__col--3-of-5">' . __('Amount in your account') . '</div>
92
+ <div id="balance" class="toastgrid__col toastgrid__col--2-of-5">' . $this->balance . ' &euro;</div>
93
+ <div class="toastgrid__col toastgrid__col--3-of-5">' . __('Campaign ID') . '</div>
94
+ <div id="id_campaign" class="toastgrid__col toastgrid__col--2-of-5">' . $this->campaign->getId() . '</div>
95
+ <div class="toastgrid__col toastgrid__col--3-of-5">' . __('Ticket') . '</div>
96
+ <div id="ticket" class="toastgrid__col toastgrid__col--2-of-5">' . $this->campaign->ticket . '</div>
97
+ <div class="toastgrid__col toastgrid__col--3-of-5">' . __('Status') . '</div>
98
+ <div id="status" class="toastgrid__col toastgrid__col--2-of-5">' . $this->Helper_campaign->get_status($this->campaign->getStatus()) . '</div>
99
+ '.
100
+ ($this->campaign->status == 5 ? '
101
+ <div class="toastgrid__col toastgrid__col--3-of-5">' . __('Error') . '</div>
102
+ <div id="error_code" class="toastgrid__col toastgrid__col--2-of-5">' . $this->Helper_api->get_error_SMS($this->campaign->getErrorCode()) . '</div>
103
+ ' : '') .'
104
+ <div class="toastgrid__col toastgrid__col--3-of-5">' . __('Recipients') . '</div>
105
+ <div id="nb_recipients" class="toastgrid__col toastgrid__col--2-of-5">' . $this->campaign->getNbRecipients() . '</div>
106
+ <div class="toastgrid__col toastgrid__col--3-of-5">' . __('Price') . '</div>
107
+ <div id="price" class="toastgrid__col toastgrid__col--2-of-5">' . number_format($this->campaign->getPrice(), 3, '.', '') . ' €</div>
108
+ <div class="toastgrid__col toastgrid__col--3-of-5">' . __('Send date') . '</div>
109
+ <div class="toastgrid__col toastgrid__col--2-of-5">' . ($this->campaign->getDateSend() != "0000-00-00 00:00:00" ? Mage::helper('core')->formatDate($this->campaign->getDateSend(), 'medium', true) : '') . '</div>
110
+ <div class="toastgrid__col toastgrid__col--3-of-5">' . __('Transmition date') . '</div>
111
+ <div class="toastgrid__col toastgrid__col--2-of-5">' . ($this->campaign->getDateTransmitted() != "" ? Mage::helper('core')->formatDate($this->campaign->getDateTransmitted(), 'medium', true) : '') . '</div>
112
+ <div class="toastgrid__col toastgrid__col--3-of-5">' . __('Validation date') . '</div>
113
+ <div class="toastgrid__col toastgrid__col--2-of-5">' . ($this->campaign->getDateValidation() != "" ? Mage::helper('core')->formatDate($this->campaign->getDateValidation(), 'medium', true) : '') . '</div>
114
+ </div>
115
+ </fieldset>';
116
+ }
117
+
118
+ }
app/code/local/Octopush/OctopushSms/Block/Campaign/Edit/Form.php ADDED
@@ -0,0 +1,98 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Octopush_OctopushSms_Block_Campaign_Edit_Form extends
4
+ Mage_Adminhtml_Block_Widget_Form {
5
+
6
+ protected function _prepareForm() {
7
+ //get the campaign
8
+ $campaignModel = Mage::registry('campaign_data');
9
+ $form = new Varien_Data_Form(
10
+ array(
11
+ 'id' => 'edit_form',
12
+ 'action' => $this->getUrl('*/*/save', array('id' => $this->getRequest()->getParam('id'))
13
+ ),
14
+ 'method' => 'post',
15
+ )
16
+ );
17
+
18
+ $form->setUseContainer(true);
19
+ //$this->setForm($form);
20
+ $this->setForm($form);
21
+
22
+ //set legend of this block
23
+ $legend = __('SMS Details');
24
+ if ($campaignModel->getStatus() == 0) {
25
+ $legend = __('SMS Settings');
26
+ }
27
+
28
+
29
+ $fieldset = $form->addFieldset('campaign_form', array('legend' => $legend));
30
+
31
+ $setting = Mage::getModel('octopushsms/setting')->load('1');
32
+ $b_auth = $setting->getData('sendsms_mail') ? true : false;
33
+
34
+ if (!$b_auth) {
35
+ $fieldset->addField('note', 'note', array(
36
+ 'text' => '<span class="failed> ' . __('Before sending a message, you have to enter your account information in the Settings Tab.') . '</span><br/><br/>',
37
+ ));
38
+ }
39
+
40
+ //TODO remove $notice=$this->getLayout()->createBlock('octopushsms/campaign_edit_info')->setTemplate('octopushsms/notice.phtml')->toHtml();
41
+
42
+
43
+ $fieldset->addField('id_sendsms_campaign', 'hidden', array(
44
+ 'name' => 'id_sendsms_campaign',
45
+ ));
46
+
47
+ $fieldset->addField('note2', 'note', array(
48
+ 'text' => "model:" . $campaignModel->getStatus() . "|" . ($campaignModel->getStatus() < 2) . "|" . empty($campaignModel->getStatus()),
49
+ ));
50
+
51
+
52
+ $fieldset->addField('title', 'text', array(
53
+ 'label' => __('Title of the campaign'),
54
+ 'class' => 'required-entry',
55
+ 'required' => true,
56
+ 'name' => 'title',
57
+ 'maxlength' => "255",
58
+ ));
59
+ $fieldset->addField('message', 'textarea', array(
60
+ 'label' => __('Message'),
61
+ 'class' => 'required-entry',
62
+ 'required' => true,
63
+ 'name' => 'message',
64
+ 'onclick' => "",
65
+ 'onchange' => "",
66
+ 'value' => '',
67
+ 'disabled' => ($campaignModel->getStatus() < 2) == 1 ? false : true,
68
+ //'readonly' => ($campaignModel->getStatus() < 2 )==1 ? "false" : true,
69
+ 'after_element_html' => '<br/><small>' . __('Variables you can use : {firstname}, {lastname}') . '</small>',
70
+ 'tabindex' => 1
71
+ ));
72
+ /* $fieldset->addField('telephone', 'text', array(
73
+ 'label' => 'telephone',
74
+ 'class' => 'required-entry',
75
+ 'required' => true,
76
+ 'name' => 'telephone',
77
+ )); */
78
+ $fieldset->addField('date_send', 'date', array(
79
+ 'label' => __('Send date'),
80
+ 'name' => 'date_send', // should match with your table column name where the data should be inserted
81
+ 'time' => true,
82
+ //'class' => 'required-entry',
83
+ //'required' => true,
84
+ 'format' => $this->escDates(),
85
+ 'image' => $this->getSkinUrl('images/grid-cal.gif')
86
+ ));
87
+ if (Mage::registry('campaign_data')) {
88
+ $form->setValues(Mage::registry('campaign_data')->getData());
89
+ }
90
+ return parent::_prepareForm();
91
+ }
92
+
93
+ private function escDates() {
94
+ return 'yyyy-MM-dd HH:mm:ss';
95
+ //Mage_Core_Model_Locale::F
96
+ }
97
+
98
+ }
app/code/local/Octopush/OctopushSms/Block/Campaign/Edit/FormToErase.php ADDED
@@ -0,0 +1,98 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Octopush_OctopushSms_Block_Campaign_Edit_Form extends
4
+ Mage_Adminhtml_Block_Widget_Form {
5
+
6
+ protected function _prepareForm() {
7
+ //get the campaign
8
+ $campaignModel = Mage::registry('campaign_data');
9
+ $form = new Varien_Data_Form(
10
+ array(
11
+ 'id' => 'edit_form',
12
+ 'action' => $this->getUrl('*/*/save', array('id' => $this->getRequest()->getParam('id'))
13
+ ),
14
+ 'method' => 'post',
15
+ )
16
+ );
17
+
18
+ $form->setUseContainer(true);
19
+ //$this->setForm($form);
20
+ $this->setForm($form);
21
+
22
+ //set legend of this block
23
+ $legend = __('SMS Details');
24
+ if ($campaignModel->getStatus() == 0) {
25
+ $legend = __('SMS Settings');
26
+ }
27
+
28
+
29
+ $fieldset = $form->addFieldset('campaign_form', array('legend' => $legend));
30
+
31
+ $setting = Mage::getModel('octopushsms/setting')->load('1');
32
+ $b_auth = $setting->getData('sendsms_mail') ? true : false;
33
+
34
+ if (!$b_auth) {
35
+ $fieldset->addField('note', 'note', array(
36
+ 'text' => '<span class="failed> ' . __('Before sending a message, you have to enter your account information in the Settings Tab.') . '</span><br/><br/>',
37
+ ));
38
+ }
39
+
40
+ //TODO remove $notice=$this->getLayout()->createBlock('octopushsms/campaign_edit_info')->setTemplate('octopushsms/notice.phtml')->toHtml();
41
+
42
+
43
+ $fieldset->addField('id_sendsms_campaign', 'hidden', array(
44
+ 'name' => 'id_sendsms_campaign',
45
+ ));
46
+
47
+ $fieldset->addField('note2', 'note', array(
48
+ 'text' => "model:" . $campaignModel->getStatus() . "|" . ($campaignModel->getStatus() < 2) . "|" . empty($campaignModel->getStatus()),
49
+ ));
50
+
51
+
52
+ $fieldset->addField('title', 'text', array(
53
+ 'label' => __('Title of the campaign'),
54
+ 'class' => 'required-entry',
55
+ 'required' => true,
56
+ 'name' => 'title',
57
+ 'maxlength' => "255",
58
+ ));
59
+ $fieldset->addField('message', 'textarea', array(
60
+ 'label' => __('Message'),
61
+ 'class' => 'required-entry',
62
+ 'required' => true,
63
+ 'name' => 'message',
64
+ 'onclick' => "",
65
+ 'onchange' => "",
66
+ 'value' => '',
67
+ 'disabled' => ($campaignModel->getStatus() < 2) == 1 ? false : true,
68
+ //'readonly' => ($campaignModel->getStatus() < 2 )==1 ? "false" : true,
69
+ 'after_element_html' => '<br/><small>' . __('Variables you can use : {firstname}, {lastname}') . '</small>',
70
+ 'tabindex' => 1
71
+ ));
72
+ /* $fieldset->addField('telephone', 'text', array(
73
+ 'label' => 'telephone',
74
+ 'class' => 'required-entry',
75
+ 'required' => true,
76
+ 'name' => 'telephone',
77
+ )); */
78
+ $fieldset->addField('date_send', 'date', array(
79
+ 'label' => __('Send date'),
80
+ 'name' => 'date_send', // should match with your table column name where the data should be inserted
81
+ 'time' => true,
82
+ //'class' => 'required-entry',
83
+ //'required' => true,
84
+ 'format' => $this->escDates(),
85
+ 'image' => $this->getSkinUrl('images/grid-cal.gif')
86
+ ));
87
+ if (Mage::registry('campaign_data')) {
88
+ $form->setValues(Mage::registry('campaign_data')->getData());
89
+ }
90
+ return parent::_prepareForm();
91
+ }
92
+
93
+ private function escDates() {
94
+ return 'yyyy-MM-dd HH:mm:ss';
95
+ //Mage_Core_Model_Locale::F
96
+ }
97
+
98
+ }
app/code/local/Octopush/OctopushSms/Block/Campaign/Edit/Info.php ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Octopush_OctopushSms_Block_Campaign_Edit_Info extends Mage_Core_Block_Template {
4
+
5
+ protected $Helper_api;
6
+ protected $Helper_campaign;
7
+ protected $balance;
8
+ protected $campaignModel;
9
+
10
+ public function __construct() {
11
+ $this->Helper_api = Mage::helper('octopushsms/API');
12
+ $this->Helper_campaign = Mage::helper('octopushsms/Campaign');
13
+ $api_balance = $this->Helper_api->get_balance();
14
+ $this->balance = $api_balance !== '001' ? $api_balance : 0;
15
+ //get the campaign
16
+ $this->campaignModel = Mage::registry('campaign_data');
17
+ parent::__construct();
18
+ }
19
+
20
+ /**
21
+ *
22
+ * @return string
23
+ */
24
+ public function getHeadInformation() {
25
+ $notice_text = '<div class="box">';
26
+ $notice_text .= "<p>";
27
+ $notice_text.=__('This module allows you to send SMS to the admin, or to customers on different events.');
28
+ $notice_text.=__('It also allows to send Bulk SMS for marketing campaign.');
29
+ $notice_text.="</p>";
30
+ $notice_text.=__('First, you have to create an account on ');
31
+ $notice_text.='<b><a href="http://www.octopush.com/inscription" target="_blank">www.octopush.com</a></b>';
32
+ $notice_text.=__(' and credit this account to be able to send SMS.');
33
+ $notice_text.="</p><p>";
34
+ $notice_text.=__('Then, please fill your identification settings, and set your options.');
35
+ $notice_text.="</p><p>";
36
+ $notice_text.=__('If you want that the customers pay for the notification service, first create a product representing the SMS service, then fill the product ID field.');
37
+ $notice_text.=__('Finally, you have to activate/desactivate events you want on the "Messages" tab, and if needed, customize the text that will be sent for each event.');
38
+ $notice_text.="</p><p>";
39
+ $notice_text.=__('Enjoy !');
40
+ $notice_text.="</p></div>";
41
+
42
+ return $notice_text;
43
+ }
44
+
45
+
46
+ }
47
+
app/code/local/Octopush/OctopushSms/Block/Campaign/Edit/Tabs.php ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Octopush_OctopushSms_Block_Campaign_Edit_Tabs extends Mage_Adminhtml_Block_Widget_Tabs
4
+ {
5
+ public function __construct()
6
+ {
7
+ parent::__construct();
8
+ $this->setId('test_tabs');
9
+ $this->setDestElementId('edit_form');
10
+ $this->setTitle('Information sur le contact');
11
+ }
12
+ protected function _beforeToHtml()
13
+ {
14
+ $this->addTab('form_section', array(
15
+ 'label' => 'Contact Information',
16
+ 'title' => 'Contact Information',
17
+ 'content' => $this->getLayout()
18
+ ->createBlock('octopushsms/campaign_edit_tab_form')
19
+ ->toHtml()
20
+ ));
21
+ return parent::_beforeToHtml();
22
+ }
23
+ }
app/code/local/Octopush/OctopushSms/Block/Campaign/Edit_1.php ADDED
@@ -0,0 +1,93 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Octopush_OctopushSms_Block_Campaign_Edit extends
4
+ Mage_Adminhtml_Block_Widget_Form_Container {
5
+
6
+ public function output_button() {
7
+ $b_auth = get_option('octopush_sms_email') ? true : false;
8
+ ?>
9
+ <div id="sendsms_buttons">
10
+ <div id="buttons" class="clear center" style="display: <?php (isset($_REQUEST['sendsms_transmit']) && $this->_campaign->status == 1 && !sizeof(self::$errors) ? 'none' : 'block') ?>">
11
+ <?php if (get_class($this) == 'Octopush_Sms_Send_Tab') { ?>
12
+ <input type="submit" id="sendsms_save" name="sendsms_save" value="<?php _e('Save this campaign', 'octopush-sms') ?>" class="button button-primary" />
13
+ <input <?php (!$b_auth ? 'disabled="disabled"' : '') ?> type="submit" id="sendsms_transmit" name="sendsms_transmit" value="<?php _e('Transmit to Octopush', 'octopush-sms') ?>" class="button button-primary" />
14
+ <?php if ($this->_campaign->status < 3) { ?>
15
+ <input <?php (!$b_auth ? 'disabled="disabled"' : '') ?> type="submit" id="sendsms_validate" name="sendsms_validate" value="<?php _e('Accept & Send', 'octopush-sms') ?>" class="button button-primary" />
16
+ <?php } ?>
17
+ <?php
18
+ }
19
+ if ($this->_campaign->status >= 1 || $this->_campaign->status < 3 || ($this->_campaign->status == 3 && the_date('Y-m-d H:i:s') < $this->_campaign->date_send)) {
20
+ ?>
21
+ <input <?php (!$b_auth ? 'disabled' : '') ?> type="submit" id="sendsms_cancel" name="sendsms_cancel" value="<?php _e('Cancel this campaign', 'octopush-sms') ?>" class="button button-primary" />
22
+ <?php } ?>
23
+ <input type="submit" id="sendsms_delete" name="sendsms_delete" value="<?php _e('Delete this campaign', 'octopush-sms') ?>" class="button button-primary" />
24
+ <?php if ($this->_campaign->event == 'sendsmsFree') { ?>
25
+ <input type="submit" id="sendsms_duplicate" name="sendsms_duplicate" value="<?php _e('Duplicate this campaign', 'octopush-sms') ?>" class="button button-primary" />
26
+ <?php } ?>
27
+ </div>
28
+ </div>
29
+ <?php
30
+ if (get_class($this) == 'Octopush_Sms_Send_Tab' && isset($_POST['sendsms_transmit']) && $this->_campaign->status == 1 && !sizeof(self::$errors)) {
31
+ echo '<div id="progress_bar" class="error fade">' . __('Transfer in progress :', 'octopush-sms') . ' <span id="waiting_transfert">' . $this->_campaign->nb_recipients . '</span> ' . __('recipients left', 'octopush-sms') . '</div>';
32
+ }
33
+ }
34
+
35
+ public function __construct() {
36
+ $data = array(
37
+ 'label' => __('Back'),
38
+ 'onclick' => 'setLocation(\'' . $this->getUrl('*/*/campaign') . '\')',
39
+ 'class' => 'back'
40
+ );
41
+ //'Transmit to Octopush'
42
+ //'Accept & Send'
43
+ //'Cancel this campaign'
44
+ //'Delete this campaign'
45
+ //'Duplicate this campaign'
46
+
47
+ //TODO barre d'avancement
48
+ $transmit = array(
49
+ 'label' => __('Transmit to Octopush'),
50
+ 'onclick' => 'transmitToOWS();',
51
+ 'class' => 'transmit'
52
+ );
53
+ $accept = array(
54
+ 'label' => __('Accept & Send'),
55
+ 'onclick' => 'transmitToOWS();',
56
+ 'class' => 'accept'
57
+ );
58
+ $cancel= array(
59
+ 'label' => __('Cancel this campaign'),
60
+ //'onclick' => 'transmitToOWS();',
61
+ 'class' => 'cancel'
62
+ );
63
+ $duplicate= array(
64
+ 'label' => __('Duplicate this campaign'),
65
+ //'onclick' => 'transmitToOWS();',
66
+ 'class' => 'cancel'
67
+ );
68
+
69
+ parent::__construct();
70
+ $this->_removeButton('back');
71
+ $this->addButton('my_back', $data, 0, -200, 'header');
72
+ $this->_removeButton('reset');
73
+
74
+ $this->_objectId = 'id';
75
+ //vous remarquerez qu’on lui assigne le même blockGroup que le Grid Container
76
+ $this->_blockGroup = 'octopushsms';
77
+ //et le meme controlleur
78
+ $this->_controller = 'campaign';
79
+ //on definit les labels pour les boutons save et les boutons delete
80
+ $this->_updateButton('save', 'label', __('Save this campaign'));
81
+ $this->_updateButton('delete', 'label', __('delete campaign'));
82
+ }
83
+
84
+ public function getHeaderText() {
85
+ if (Mage::registry('campaign_data') && Mage::registry('campaign_data')->getId()) {
86
+ return __('Edit campaign ') . $this->htmlEscape(
87
+ Mage::registry('campaign_data')->getTitle()) . '<br />';
88
+ } else {
89
+ return __('Add campaign');
90
+ }
91
+ }
92
+
93
+ }
app/code/local/Octopush/OctopushSms/Block/Campaign/Grid.php ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Octopush_OctopushSms_Block_Campaign_Grid extends Mage_Adminhtml_Block_Widget_Grid_Container {
4
+
5
+ public function __construct() {
6
+ $this->_controller = 'campaign_controller';
7
+ $this->_blockGroup = 'octopushsms';
8
+ //name of the button to add a campaign
9
+ if ($this->getRequest()->getActionName() == 'history') {
10
+ $this->_headerText = __('Campaigns history');
11
+ } else {
12
+ $this->_headerText = __('Campaigns that have not yet been sent');
13
+ }
14
+ $this->_addButtonLabel = __('Create a new campaign / Send a new SMS');
15
+ parent::__construct();
16
+ $this->setSaveParametersInSession(true);
17
+ $this->setUseAjax(true);
18
+ }
19
+
20
+ public function getGridUrl() {
21
+ return $this->getUrl('*/*/grid', array('_current' => true));
22
+ }
23
+
24
+ }
app/code/local/Octopush/OctopushSms/Block/Campaign/Renderer/Price.php ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Octopush_OctopushSms_Block_Campaign_Renderer_Price extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract {
4
+
5
+ public function render(Varien_Object $row) {
6
+ return $row->getData($this->getColumn()->getIndex()). ' €';
7
+ }
8
+
9
+ }
app/code/local/Octopush/OctopushSms/Block/Campaign/Renderer/Status.php ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Octopush_OctopushSms_Block_Campaign_Renderer_Status extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract {
4
+
5
+ public function render(Varien_Object $row) {
6
+ return Mage::helper('octopushsms/Campaign')->get_status($row->getData($this->getColumn()->getIndex()));
7
+ }
8
+
9
+ }
app/code/local/Octopush/OctopushSms/Block/Campaignblock.php ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Octopush_OctopushSms_Block_Campaignblock extends Mage_Core_Block_Template {
4
+
5
+
6
+ /**
7
+ *
8
+ * @return string
9
+ */
10
+ public function getHeadInformation() {
11
+ $notice_text = '<div class="box">';
12
+ $notice_text .= "<p>";
13
+ $notice_text.=__('This module allows you to send SMS to the admin, or to customers on different events.');
14
+ $notice_text.=__('It also allows to send Bulk SMS for marketing campaign.');
15
+ $notice_text.="</p>";
16
+ $notice_text.=__('First, you have to create an account on ');
17
+ $notice_text.='<b><a href="http://www.octopush.com/inscription" target="_blank">www.octopush.com</a></b>';
18
+ $notice_text.=__(' to be able to send SMS, and make a deposit on this account.');
19
+ $notice_text.="</p><p>";
20
+ $notice_text.=__('Then, please fill your identification settings, and set your options.');
21
+ $notice_text.="</p><p>";
22
+ $notice_text.=__('If you want that the customers pay for the notification service, first create a product representing the SMS service, then fill the product ID field.');
23
+ $notice_text.=__('Finally, you have to activate/desactivate events you want on the "Messages" tab, and if needed, customize the text that will be sent for each event.');
24
+ $notice_text.="</p><p>";
25
+ $notice_text.=__('Enjoy !');
26
+ $notice_text.="</p></div>";
27
+
28
+ return $notice_text;
29
+ }
30
+
31
+ }
app/code/local/Octopush/OctopushSms/Block/CampaignblockTODOREMOVE.php ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Octopush_OctopushSms_Block_Campaignblock extends Mage_Core_Block_Template {
4
+
5
+
6
+ /**
7
+ *
8
+ * @return string
9
+ */
10
+ public function getHeadInformation() {
11
+ $notice_text = '<div class="box">';
12
+ $notice_text .= "<p>";
13
+ $notice_text.=__('This module allows you to send SMS to the admin, or to customers on different events.');
14
+ $notice_text.=__('It also allows to send Bulk SMS for marketing campaign.');
15
+ $notice_text.="</p>";
16
+ $notice_text.=__('First, you have to create an account on ');
17
+ $notice_text.='<b><a href="http://www.octopush.com/inscription" target="_blank">www.octopush.com</a></b>';
18
+ $notice_text.=__(' to be able to send SMS, and make a deposit on this account.');
19
+ $notice_text.="</p><p>";
20
+ $notice_text.=__('Then, please fill your identification settings, and set your options.');
21
+ $notice_text.="</p><p>";
22
+ $notice_text.=__('If you want that the customers pay for the notification service, first create a product representing the SMS service, then fill the product ID field.');
23
+ $notice_text.=__('Finally, you have to activate/desactivate events you want on the "Messages" tab, and if needed, customize the text that will be sent for each event.');
24
+ $notice_text.="</p><p>";
25
+ $notice_text.=__('Enjoy !');
26
+ $notice_text.="</p></div>";
27
+
28
+ return $notice_text;
29
+ }
30
+
31
+ }
app/code/local/Octopush/OctopushSms/Block/Messages.php ADDED
@@ -0,0 +1,199 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Block to dislay messages from octopush
5
+ */
6
+ class Octopush_OctopushSms_Block_Messages extends Mage_Core_Block_Template {
7
+
8
+ private $api;
9
+ private $message;
10
+
11
+ public function __construct(array $args = array()) {
12
+ parent::__construct($args);
13
+ $this->api = Mage::helper('octopushsms/API');
14
+ $this->message = Mage::helper('octopushsms/Message');
15
+ }
16
+
17
+ public function getBody() {
18
+ //save is date is send
19
+ //$this->_post_process();
20
+ //WC_Admin_Settings::show_messages();
21
+ //$defaultLanguage = (int) $this->context->language->id;
22
+
23
+ $admin_html = '';
24
+ //display messages for each possible admin hook
25
+ foreach ($this->message->admin_config as $hookId => $hookName) {
26
+ $admin_html .= $this->_get_code($hookId, $hookName, true);
27
+ }
28
+
29
+ $customer_html = '';
30
+ foreach ($this->message->customer_config as $hookId => $hookName) {
31
+ if ($hookId != 'action_order_status_update') {
32
+ /* TODO to validate if ($hookId == 'action_validate_order' || $hookId == 'action_admin_orders_tracking_number_update') {
33
+ $customer_html .= $this->_get_code($hookId, $hookName, false, null, true);
34
+ } else { */
35
+ $customer_html .= $this->_get_code($hookId, $hookName, false);
36
+ //}
37
+ } else {
38
+ //specific hook when status of a command change
39
+ $statusCollection = Mage::getModel('sales/order_status')->getResourceCollection()->getData();
40
+ foreach ($statusCollection as $status) {
41
+ $customer_html .= $this->_get_code($hookId . "_".$status['status'], $hookName . " (".$status['label'].")", false, null, true);
42
+ }
43
+ }
44
+ }
45
+
46
+ $html = '
47
+ <div id="' . get_class($this) . '">
48
+ <br /><b>' . __('Choose SMS you want to activate, and customize their text.') . '</b><br /><br />';
49
+ $html .=
50
+ __('On the right side you can see a preview to check that everything is ok.') . '<br /><br />
51
+ <div class="clear"></div>
52
+ <div class="wrap woocommerce">
53
+ <form action="' . Mage::getUrl('adminoctopushsms/adminhtml_index/saveMessages') . '" method="post" id="edit_form" enctype="multipart/form-data" >
54
+ <div>
55
+ <input name="form_key" type="hidden" value="' . Mage::getSingleton('core/session')->getFormKey() . '"/>
56
+ <input id="action" name="action" value="edit" type="hidden">
57
+ </div>
58
+
59
+ <div class="entry-edit">
60
+ <div class="section-config">
61
+ <div class="entry-edit-head collapseable">
62
+ <a id="sms_admin-head" href="#" onclick="Fieldset.toggleCollapse(\'sms_admin\', \'#\');
63
+ return false;" class="">'. __('SMS for Admin') .'</a>
64
+ </div>
65
+ <fieldset class="config collapseable" id="sms_admin" >
66
+ <legend>'. __('SMS for Admin') .'</legend>
67
+ <div class="os_row">' .
68
+ $admin_html . '
69
+ </div>
70
+ </fieldset>
71
+ <script type="text/javascript">//<![CDATA[
72
+ $("sms_admin-head").collapsed=0;
73
+ Fieldset.applyCollapse(\'sms_admin\');
74
+ //]]></script>
75
+ </div>
76
+ </div>
77
+
78
+ <div class="entry-edit">
79
+ <div class="section-config">
80
+ <div class="entry-edit-head collapseable">
81
+ <a id="sms_customer-head" href="#" onclick="Fieldset.toggleCollapse(\'sms_customer\', \'#\');
82
+ return false;" class="">' . __('SMS for Customer') . '</a>
83
+ </div>
84
+ <fieldset class="config collapseable" id="sms_customer">
85
+ <legend>' . __('SMS for Customer') . '</legend>
86
+ <div class="os_row">' .
87
+ $customer_html . '
88
+ </div>
89
+ </fieldset>
90
+ <script type="text/javascript">//<![CDATA[
91
+ $("sms_customer-head").collapsed=0;
92
+ Fieldset.applyCollapse(\'sms_customer\');
93
+ //]]></script>
94
+ </div>
95
+ </div>
96
+
97
+ </form>
98
+ </div>
99
+ </div>';
100
+ return $html;
101
+ }
102
+
103
+ /**
104
+ * Get html fragment for this hook
105
+ * @param type $hookId the id of the hook
106
+ * @param type $hookName the short description of the hook
107
+ * @param type $bAdmin
108
+ * @param type $comment
109
+ * @param type $bPaid
110
+ * @return string
111
+ */
112
+ private function _get_code($hookId, $hookName, $bAdmin = false, $comment = null, $bPaid = false) {
113
+
114
+ $message = $this->message->get_message($hookId, $bAdmin);
115
+ //echo var_dump($message->debug());
116
+ //$defaultLanguage = (int)$this->context->language->id;
117
+
118
+ $keyActive = $this->message->_get_isactive_hook_key($message);
119
+
120
+ //To test with dummy values
121
+ $values = $this->message->get_sms_values_for_test($hookId);
122
+
123
+ $key = $this->message->_get_hook_key($message);
124
+
125
+ $code = '
126
+ <div class="ows">
127
+ <table class="messages_data">
128
+ <tr valign="top" class="sms">
129
+ <th scope="row" class="titledesc text_td">
130
+ <label for="octopush_sms_email">' . __($hookName);
131
+
132
+ //if option is not free and the customer pay for it
133
+ if ($bPaid && (int) Mage::getModel('octopushsms/setting')->load('1')->getData('freeoption') == 0) {
134
+ $code .= '<br/><span style="font-weight: normal">' . __('Sent only if customer pay the option') . '</span>';
135
+ }
136
+ $code.='</label>
137
+ </th>
138
+ <td class="forminp forminp-' . $message->getData('id_message') . ' data_td">';
139
+ $code .= '<input ' . ($this->message->is_active($message) == 1 ? 'checked' : '') . ' type="checkbox" name="' . $keyActive . '" value="1"/> ' . __('Activate') . ' ?<br/>';
140
+
141
+ $messageHook = $message->getData('message');
142
+ $txt = $this->api->replace_for_GSM7($messageHook ? $messageHook : $this->message->get_sms_default_text($message));
143
+ //TODO test
144
+ $txt_test = $this->api->replace_for_GSM7(str_replace(array_keys($values), array_values($values), $txt));
145
+ $bGSM7 = $this->api->is_GSM7($txt_test);
146
+
147
+ $code .= '<textarea name="' . $key . '" rows="4" class="message_textarea">' . $txt
148
+ . '</textarea>
149
+ <br/><span class="description">' .
150
+ (!$bGSM7 ? '<img src="../img/admin/warning.gif"> ' . __('This message will be divided in 70 chars parts, because of non standard characters : ') . ' ' . $this->api->not_GSM7($txt_test) : __('This message will be divided in 160 chars parts')) .
151
+ '</span>'
152
+ . '<br/>';
153
+ $code.= '<span class="description">' . __('Variables you can use : ') . ' ' . implode(', ', array_keys($values)) . '</span>
154
+ </td>
155
+ <td class="forminp forminp-' . $hookId . '-example" class="text_td">
156
+ <br />
157
+ <textarea class="check" readonly rows="4" class="message_textarea">' . $txt_test . '</textarea>';
158
+ $code .= '</td>
159
+ </tr>
160
+ </table>
161
+ </div>';
162
+ //TODO ? no mulitlangual support
163
+ return $code;
164
+ }
165
+
166
+ /**
167
+ * Update option corresponding to the hook
168
+ * @param type $hook
169
+ * @param type $b_admin
170
+ */
171
+ public function update_message_option($hook, $b_admin = false) {
172
+ //if is active
173
+ $hook_is_active = $this->api->_get_isactive_hook_key($hook, $b_admin);
174
+ if (array_key_exists($hook_is_active, $_POST)) {
175
+ $value = wc_clean($_POST[$hook_is_active]);
176
+ //save the option
177
+ update_option($hook_is_active, (int) $value);
178
+ } else {
179
+ update_option($hook_is_active, 0);
180
+ }
181
+ //message text
182
+ $hook_key = $this->api->_get_hook_key($hook, $b_admin);
183
+ if (array_key_exists($hook_key, $_POST)) {
184
+ $value = stripslashes($_POST[$hook_key]);
185
+ //save the option
186
+ update_option($hook_key, $this->api->replace_for_GSM7(trim($value)));
187
+ }
188
+ //specific case of 'action_order_status_update'
189
+ if ($hook == 'action_order_status_update') {
190
+ global $wp_post_statuses;
191
+ foreach ($wp_post_statuses as $key => $value) {
192
+ if (strstr($key, 'wc-')) {
193
+ $this->update_message_option($hook . "_$key", $b_admin);
194
+ }
195
+ }
196
+ }
197
+ }
198
+
199
+ }
app/code/local/Octopush/OctopushSms/Block/Messages_1.php ADDED
@@ -0,0 +1,174 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Block to dislay messages from octopush
5
+ */
6
+ class Octopush_OctopushSms_Block_Messages extends Mage_Core_Block_Template {
7
+
8
+ private $api;
9
+ private $message;
10
+
11
+ public function __construct(array $args = array()) {
12
+ parent::__construct($args);
13
+ $this->api = Mage::helper('octopushsms/API');
14
+ $this->message = Mage::helper('octopushsms/Message');
15
+ }
16
+
17
+ public function getBody() {
18
+ //save is date is send
19
+ //$this->_post_process();
20
+ //WC_Admin_Settings::show_messages();
21
+ //$defaultLanguage = (int) $this->context->language->id;
22
+
23
+ $admin_html = '';
24
+ //display messages for each possible admin hook
25
+ foreach ($this->message->admin_config as $hookId => $hookName) {
26
+ $admin_html .= $this->_get_code($hookId, $hookName, true);
27
+ }
28
+
29
+ $customer_html = '';
30
+ foreach ($this->message->customer_config as $hookId => $hookName) {
31
+ if ($hookId != 'action_order_status_update') {
32
+ /* TODO to validate if ($hookId == 'action_validate_order' || $hookId == 'action_admin_orders_tracking_number_update') {
33
+ $customer_html .= $this->_get_code($hookId, $hookName, false, null, true);
34
+ } else { */
35
+ $customer_html .= $this->_get_code($hookId, $hookName, false);
36
+ //}
37
+ } else {
38
+ //specific hook when status of a command change
39
+ $statusCollection = Mage::getModel('sales/order_status')->getResourceCollection()->getData();
40
+ foreach ($statusCollection as $status) {
41
+ $customer_html .= $this->_get_code($hookId . "_".$status['status'], $hookName . " (".$status['label'].")", false, null, true);
42
+ }
43
+ }
44
+ }
45
+
46
+ $html = '
47
+ <div id="' . get_class($this) . '">
48
+ <br /><b>' . __('Choose SMS you want to activate, and customize their text.') . '</b><br /><br />';
49
+ $html .=
50
+ __('On the right side you can see a preview to check that everything is ok.') . '<br /><br />
51
+ <div class="clear"></div>
52
+ <div class="wrap woocommerce">
53
+ <form action="' . Mage::getUrl('adminoctopushsms/adminhtml_index/saveMessages') . '" method="post" id="edit_form" enctype="multipart/form-data" >
54
+ <div>
55
+ <input name="form_key" type="hidden" value="' . Mage::getSingleton('core/session')->getFormKey() . '"/>
56
+ <input id="action" name="action" value="edit" type="hidden">
57
+ </div>
58
+ <h3>' . __('SMS for Admin') . '</h3>
59
+ <div class="os_row">' .
60
+ $admin_html . '
61
+ </div>
62
+ <br />
63
+ <input name="save" class="button-primary" type="submit" value="' . __('Update') . '" />
64
+ <br /><br />
65
+ <h3>' . __('SMS for Customer') . '</h3>
66
+ <div class="os_row">' .
67
+ $customer_html . '
68
+ </div>
69
+ <br />
70
+ <input class="button-primary" type="submit" name="save2" value="' . __('Update') . '" class="button" />
71
+ <input class="button-primary" type="submit" name="resettxt" value="' . __('Reset all messages') . '" class="button" />
72
+ </form>
73
+ </div>
74
+ </div>';
75
+ return $html;
76
+ }
77
+
78
+ /**
79
+ * Get html fragment for this hook
80
+ * @param type $hookId the id of the hook
81
+ * @param type $hookName the short description of the hook
82
+ * @param type $bAdmin
83
+ * @param type $comment
84
+ * @param type $bPaid
85
+ * @return string
86
+ */
87
+ private function _get_code($hookId, $hookName, $bAdmin = false, $comment = null, $bPaid = false) {
88
+
89
+ $message = $this->message->get_message($hookId, $bAdmin);
90
+ //echo var_dump($message->debug());
91
+ //$defaultLanguage = (int)$this->context->language->id;
92
+
93
+ $keyActive = $this->message->_get_isactive_hook_key($message);
94
+
95
+ //To test with dummy values
96
+ $values = $this->message->get_sms_values_for_test($hookId);
97
+
98
+ $key = $this->message->_get_hook_key($message);
99
+
100
+ $code = '
101
+ <div class="ows">
102
+ <table class="messages_data">
103
+ <tr valign="top" class="sms">
104
+ <th scope="row" class="titledesc text_td">
105
+ <label for="octopush_sms_email">' . __($hookName);
106
+
107
+ //if option is not free and the customer pay for it
108
+ if ($bPaid && (int) Mage::getModel('octopushsms/setting')->load('1')->getData('freeoption') == 0) {
109
+ $code .= '<br/><span style="font-weight: normal">' . __('Sent only if customer pay the option') . '</span>';
110
+ }
111
+ $code.='</label>
112
+ </th>
113
+ <td class="forminp forminp-' . $message->getData('id_message') . ' data_td">';
114
+ $code .= '<input ' . ($this->message->is_active($message) == 1 ? 'checked' : '') . ' type="checkbox" name="' . $keyActive . '" value="1"/> ' . __('Activate') . ' ?<br/>';
115
+
116
+ $messageHook = $message->getData('message');
117
+ $txt = $this->api->replace_for_GSM7($messageHook ? $messageHook : $this->message->get_sms_default_text($message));
118
+ //TODO test
119
+ $txt_test = $this->api->replace_for_GSM7(str_replace(array_keys($values), array_values($values), $txt));
120
+ $bGSM7 = $this->api->is_GSM7($txt_test);
121
+
122
+ $code .= '<textarea name="' . $key . '" rows="4" class="message_textarea">' . $txt
123
+ . '</textarea>
124
+ <br/><span class="description">' .
125
+ (!$bGSM7 ? '<img src="../img/admin/warning.gif"> ' . __('This message will be divided in 70 chars parts, because of non standard characters : ') . ' ' . $this->api->not_GSM7($txt_test) : __('This message will be divided in 160 chars parts')) .
126
+ '</span>'
127
+ . '<br/>';
128
+ $code.= '<span class="description">' . __('Variables you can use : ') . ' ' . implode(', ', array_keys($values)) . '</span>
129
+ </td>
130
+ <td class="forminp forminp-' . $hookId . '-example" class="text_td">
131
+ <br />
132
+ <textarea class="check" readonly rows="4" class="message_textarea">' . $txt_test . '</textarea>';
133
+ $code .= '</td>
134
+ </tr>
135
+ </table>
136
+ </div>';
137
+ //TODO ? no mulitlangual support
138
+ return $code;
139
+ }
140
+
141
+ /**
142
+ * Update option corresponding to the hook
143
+ * @param type $hook
144
+ * @param type $b_admin
145
+ */
146
+ public function update_message_option($hook, $b_admin = false) {
147
+ //if is active
148
+ $hook_is_active = $this->api->_get_isactive_hook_key($hook, $b_admin);
149
+ if (array_key_exists($hook_is_active, $_POST)) {
150
+ $value = wc_clean($_POST[$hook_is_active]);
151
+ //save the option
152
+ update_option($hook_is_active, (int) $value);
153
+ } else {
154
+ update_option($hook_is_active, 0);
155
+ }
156
+ //message text
157
+ $hook_key = $this->api->_get_hook_key($hook, $b_admin);
158
+ if (array_key_exists($hook_key, $_POST)) {
159
+ $value = stripslashes($_POST[$hook_key]);
160
+ //save the option
161
+ update_option($hook_key, $this->api->replace_for_GSM7(trim($value)));
162
+ }
163
+ //specific case of 'action_order_status_update'
164
+ if ($hook == 'action_order_status_update') {
165
+ global $wp_post_statuses;
166
+ foreach ($wp_post_statuses as $key => $value) {
167
+ if (strstr($key, 'wc-')) {
168
+ $this->update_message_option($hook . "_$key", $b_admin);
169
+ }
170
+ }
171
+ }
172
+ }
173
+
174
+ }
app/code/local/Octopush/OctopushSms/Block/News.php ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Block to dislay newsreceive from octopush
5
+ */
6
+ class Octopush_OctopushSms_Block_News extends Mage_Core_Block_Template {
7
+
8
+ public function __construct(array $args = array()) {
9
+ parent::__construct($args);
10
+ }
11
+
12
+ public function displayNews() {
13
+ $helperAPI = Mage::helper('octopushsms/API');
14
+ $xml = $helperAPI->get_news();
15
+ if (!key_exists('error_code', $xml) || $xml->error_code == '000') {
16
+ //display information message if the language receive is different of your language
17
+ $locale = Mage::app()->getLocale()->getLocaleCode();
18
+ if (!isset($xml->news) ) {
19
+ //Mage::getSingleton('adminhtml/session')->addError(__('No news available'));
20
+ echo '<ul class="messages"><li class="error-msg"><ul><li>'.__('No news available').'</li></ul></li></ul>';
21
+ return;
22
+ }
23
+ if (substr($locale, 0, 2) != $xml->news->new[0]->lang) {
24
+ echo '<ul class="messages"><li class="warning-msg"><ul><li>'._('News in your language are not available.').'</li></ul></li></ul>';
25
+ }
26
+ //display each news
27
+ echo '<ul>';
28
+ foreach ($xml->news->new as $new) {
29
+ ?>
30
+ <li class="box">
31
+ <a class="rsswidget" href="http://octopush.com">
32
+ <?php echo str_replace(']]>', '', str_replace('<![CDATA[', '', $new->title)); ?>
33
+ </a>
34
+ &nbsp;<span class="rss-date"><?php echo $new->date . ' ' . __('author', 'octopush-sms') . ': ' . $new->author; ?></span>
35
+ <div class="rssSummary">
36
+ <?php echo str_replace(']]>', '', str_replace('<![CDATA[', '', $new->text)); ?>
37
+ </div>
38
+ </li>
39
+ <?php
40
+ }
41
+ echo '</ul>';
42
+ } else {
43
+ Mage::getSingleton('adminhtml/session')->addError($helperAPI->get_error_SMS($xml->error_code));
44
+ }
45
+ }
46
+
47
+ }
app/code/local/Octopush/OctopushSms/Block/Recipient/Controller/Grid.php ADDED
@@ -0,0 +1,112 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Octopush_OctopushSms_Block_Recipient_Controller_Grid extends Mage_Adminhtml_Block_Widget_Grid {
4
+
5
+ public function __construct() {
6
+ parent::__construct();
7
+ $this->setId('recipientGrid');
8
+ $this->setDefaultSort('id_sendsms_recipient');
9
+ $this->setDefaultDir('DESC');
10
+ $this->setSaveParametersInSession(true);
11
+ $this->setUseAjax(true);
12
+ }
13
+
14
+ public function getGridUrl() {
15
+ return $this->getUrl('*/*/gridRecipient', array('_current' => true,'id'=>Mage::registry('campaign_data')->getId()));
16
+ }
17
+
18
+ protected function _prepareCollection() {
19
+ $collection = Mage::getModel('octopushsms/recipient')->getCollection();
20
+ if (Mage::registry('campaign_data') && Mage::registry('campaign_data')->getId()>0) {
21
+ $collection->addFieldToFilter('id_sendsms_campaign', Mage::registry('campaign_data')->getId());
22
+ } else {
23
+ $collection->addFieldToFilter('id_sendsms_campaign', -1);
24
+ }
25
+ $this->setCollection($collection);
26
+ return parent::_prepareCollection();
27
+ }
28
+
29
+ protected function _prepareColumns() {
30
+ $this->addColumn('id_sendsms_recipient', array(
31
+ 'header' => __('ID'),
32
+ 'align' => 'right',
33
+ 'width' => '50px',
34
+ 'index' => 'id_sendsms_recipient',
35
+ ));
36
+ $this->addColumn('firstname', array(
37
+ 'header' => __('Firstname'),
38
+ 'align' => 'left',
39
+ 'index' => 'firstname',
40
+ ));
41
+ $this->addColumn('lastname', array(
42
+ 'header' => __('Lastname'),
43
+ 'align' => 'left',
44
+ 'index' => 'lastname',
45
+ ));
46
+ $this->addColumn('phone', array(
47
+ 'header' => __('Phone'),
48
+ 'align' => 'left',
49
+ 'index' => 'phone',
50
+ ));
51
+ $this->addColumn('iso_country', array(
52
+ 'header' => __('Country'),
53
+ 'align' => 'left',
54
+ 'index' => 'iso_country',
55
+ ));
56
+ if (Mage::registry('campaign_data')) {
57
+ $_campaign = Mage::registry('campaign_data');
58
+ if (intval($_campaign->getData('status')) == 0) {
59
+ /* $this->addColumn('iso_country', array(
60
+ 'header' => __('Country'),
61
+ 'align' => 'left',
62
+ 'index' => 'iso_country',
63
+ ));
64
+ $column_to_add = array('user_actions' => __('Actions', 'octopush-sms'));
65
+ $columns = array_merge($columns, $column_to_add); */
66
+ } else if (intval($_campaign->getData('status')) >= 1) {
67
+ $this->addColumn('price', array(
68
+ 'header' => __('Price'),
69
+ 'align' => 'left',
70
+ 'index' => 'price',
71
+ ));
72
+ $this->addColumn('transmitted', array(
73
+ 'header' => __('Transmited to Octopush'),
74
+ 'align' => 'left',
75
+ 'index' => 'transmitted',
76
+ ));
77
+ $values = Mage::helper('octopushsms/Campaign')->get_status_array();
78
+ $this->addColumn('status', array(
79
+ 'header' => __('Status / Error'),
80
+ 'align' => 'left',
81
+ 'index' => 'status',
82
+ //'type' => 'options',
83
+ //'options' => $values,
84
+ 'renderer' => 'Octopush_OctopushSms_Block_Recipient_Renderer_Status',
85
+ ));
86
+ }
87
+ }
88
+ $this->addColumn('action', array(
89
+ 'header' => Mage::helper('octopushsms')->__('Action'),
90
+ 'width' => '100',
91
+ 'type' => 'action',
92
+ 'getter' => 'getId',
93
+ 'actions' => array(
94
+ array(
95
+ 'caption' => Mage::helper('octopushsms')->__('Delete'),
96
+ 'url' => array('base' => '*/*/deleteRecipient'),//'$entity_id'
97
+ 'field' => 'id',
98
+ )),
99
+ 'filter' => false,
100
+ 'sortable' => false,
101
+ //'index' => 'stores',
102
+ 'is_system' => true,
103
+ ));
104
+ return parent::_prepareColumns();
105
+ }
106
+
107
+ public function getRowUrl($row) {
108
+ //no edit possible
109
+ //return $this->getUrl('*/*/editRecipient', array('id' => $row->getId()));
110
+ }
111
+
112
+ }
app/code/local/Octopush/OctopushSms/Block/Recipient/Grid.php ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Octopush_OctopushSms_Block_Recipient_Grid extends Mage_Adminhtml_Block_Widget_Grid_Container {
4
+
5
+ public function __construct() {
6
+ $this->_controller = 'recipient_controller';
7
+ $this->_blockGroup = 'octopushsms';
8
+ $this->_headerText = __('Recipients');
9
+ parent::__construct();
10
+ $this->_removeButton('add');
11
+ $this->setUseAjax(true);
12
+ }
13
+
14
+ public function getGridUrl() {
15
+ return $this->getUrl('*/*/gridRecipient', array('_current' => true));
16
+ }
17
+
18
+ }
app/code/local/Octopush/OctopushSms/Block/Recipient/Renderer/Status.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Octopush_OctopushSms_Block_Recipient_Renderer_Status extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract {
4
+
5
+ public function render(Varien_Object $row) {
6
+ $value = $row->getData($this->getColumn()->getIndex());
7
+ return Mage::helper('octopushsms/API')->get_error_SMS($value);
8
+ }
9
+
10
+ }
app/code/local/Octopush/OctopushSms/Block/Setting.php ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Octopush_OctopushSms_Block_Setting extends Mage_Core_Block_Template {
4
+ /**
5
+ *
6
+ * @return string
7
+ */
8
+ public function getHeadInformation() {
9
+ $notice_text = '<div class="box">';
10
+ $notice_text .= "<p>";
11
+ $notice_text.=__('This module allows you to send SMS to the admin, or to customers on different events.');
12
+ $notice_text.=__('It also allows to send Bulk SMS for marketing campaign.');
13
+ $notice_text.="</p>";
14
+ $notice_text.=__('First, you have to create an account on ');
15
+ $notice_text.='<b><a href="http://www.octopush.com/inscription" target="_blank">www.octopush.com</a></b>';
16
+ $notice_text.=__(' to be able to send SMS, and make a deposit on this account.');
17
+ $notice_text.="</p><p>";
18
+ $notice_text.=__('Then, please fill your identification settings, and set your options.');
19
+ $notice_text.="</p><p>";
20
+ $notice_text.=__('If you want that the customers pay for the notification service, first create a product representing the SMS service, then fill the product ID field.');
21
+ $notice_text.=__('Finally, you have to activate/desactivate events you want on the "Messages" tab, and if needed, customize the text that will be sent for each event.');
22
+ $notice_text.="</p><p>";
23
+ $notice_text.=__('Enjoy !');
24
+ $notice_text.="</p></div>";
25
+
26
+ return $notice_text;
27
+ }
28
+
29
+ }
app/code/local/Octopush/OctopushSms/Helper/API.php ADDED
@@ -0,0 +1,393 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ //API give by octopush
4
+ require_once __DIR__ . DIRECTORY_SEPARATOR . 'API_SMS_PHP_Octopush/octopush_web_services.inc.php';
5
+ require_once __DIR__ . DIRECTORY_SEPARATOR . 'API_SMS_PHP_Octopush/sms.inc.php';
6
+
7
+ class Octopush_OctopushSms_Helper_API extends Mage_Core_Helper_Abstract {
8
+
9
+ private static $octopush_sms_api;
10
+ public $_phone = null;
11
+ public $_recipients = null;
12
+ public $sms_type = SMS_WORLD; // ou encore SMS_STANDARD,SMS_PREMIUM
13
+ public $sms_mode = DIFFERE; // ou encore DIFFERE
14
+ public $sms_sender;
15
+ //for campaign
16
+ private $_recipient;
17
+ private $_paid_by_customer = 0;
18
+ private $_event = '';
19
+
20
+ /**
21
+ * Admin messages with their title
22
+ */
23
+ public $admin_config;
24
+ public $customer_config;
25
+
26
+ /* TODO remove public static function get_instance() {
27
+ global $octopush_sms_api;
28
+ if (is_null($octopush_sms_api)) {
29
+ $setting = Mage::getModel('octopushsms/setting')->load('1');
30
+ $octopush_sms_api = new Octopush_OctopushSms_Helper_API($setting->getData('email'), $setting->getData('key'));
31
+ }
32
+ return $octopush_sms_api;
33
+ } */
34
+
35
+ /**
36
+ * Octopush user login
37
+ * @var string
38
+ * @access public
39
+ * @since 1.0.0
40
+ */
41
+ public $user_login;
42
+
43
+ /**
44
+ * Octopush API Key
45
+ * @var string
46
+ * @access public
47
+ * @since 1.0.0
48
+ */
49
+ public $api_key;
50
+
51
+ /**
52
+ * Constructor
53
+ * @param string $user_login
54
+ * @param string $api_key
55
+ */
56
+ public function __construct() {
57
+ $setting = Mage::getModel('octopushsms/setting')->load('1');
58
+ $this->user_login = $setting->getData('email');
59
+ $this->api_key = $setting->getData('key');
60
+ $this->sms_sender = $setting->getData('sender');
61
+
62
+ //initialisation of possible admin message
63
+ $this->admin_config = array(
64
+ 'action_create_account' => __('Create account'), //don't suppress
65
+ //'action_send_message' => __('Send Message'),
66
+ //'action_validate_order' => __('Validate Order'),
67
+ //'action_order_return' => __('Order return'),
68
+ //'action_update_quantity' => __('Stock notification'),
69
+ //'action_admin_alert' => __('Admin alert'),
70
+ //'action_daily_report' => __('Daily report', 'octopush-sms')
71
+ );
72
+
73
+ $this->customer_config = array(
74
+ 'action_create_account' => __('Create account'),
75
+ 'action_password_renew' => __('Send SMS when customer has lost his password'),
76
+ //'action_customer_alert' => __('Send SMS when product is available'),
77
+ 'action_send_message' => __('Send Message'),
78
+ 'action_validate_order' => __('Validate Order'),
79
+ //'action_admin_orders_tracking_number_update' => __('Order tracking number update'),
80
+ 'action_order_status_update' => __('Status update', 'octopush-sms'));
81
+ }
82
+
83
+ public function get_account() {
84
+ Mage::log("octopush-sms - get_account ,parameters $this->user_login , $this->api_key", Zend_Log::DEBUG, "octopushsms.log");
85
+ if (!empty($this->user_login) && !empty($this->api_key)) {
86
+ $sms = new OWS();
87
+ $sms->set_user_login($this->user_login);
88
+ $sms->set_api_key($this->api_key);
89
+ Mage::log("octopush-sms - get_account ", Zend_Log::DEBUG, "octopushsms.log");
90
+ $xml0 = $sms->get_balance();
91
+ $xml = simplexml_load_string($xml0);
92
+ if (!key_exists('error_code', $xml) || $xml->error_code == '000') {
93
+ //if balance greater than alert_level init 'octopush_sms_admin_alert_sent' to say we don't have send the alert sms message
94
+ $setting = Mage::getModel("octopushsms/setting")->load('1');
95
+ $alert_level = $setting->getAdminAlert();
96
+ if ($alert_level > 0 && (float) $xml->credit[0] > $alert_level) {
97
+ $setting->setAdminAlertSent(0);
98
+ $setting->save();
99
+ }
100
+ //return the balance
101
+ return (float) $xml->credit[0];
102
+ } else if ($xml->error_code == '001') {
103
+ // connexion failed
104
+ return '001';
105
+ } else {
106
+ return false;
107
+ }
108
+ }
109
+ return false;
110
+ }
111
+
112
+ public function get_balance() {
113
+ $result = $this->get_account();
114
+ return $result;
115
+ }
116
+
117
+ /**
118
+ * Get thenews on octopush server
119
+ * @return string|boolean
120
+ */
121
+ public function get_news() {
122
+ Mage::log("octopush-sms - get_news ", Zend_Log::DEBUG, "octopushsms.log");
123
+ $sms = new SMS();
124
+ $locale = Mage::app()->getLocale()->getLocaleCode();
125
+ $sms->set_user_lang(substr($locale, 0, 2));
126
+ $xml = simplexml_load_string($sms->getNews(), 'SimpleXMLElement', LIBXML_NOCDATA);
127
+ Mage::log("octopush-sms - xml ".$xml->asXML(), Zend_Log::DEBUG, "octopushsms.log");
128
+
129
+ return $xml;
130
+ }
131
+
132
+ public function send_trame($id_campaign, $recipients, $txt, $finished) {
133
+ $values = array('{firstname}' => '(ch1)', '{lastname}' => '(ch2)');
134
+ $this->_event = 'sendsmsFree';
135
+ $this->_paid_by_customer = 0;
136
+ $this->_recipient = $recipients;
137
+
138
+ //if (!empty($this->user_login) && !empty($this->api_key)) {
139
+ $sms = new SMS();
140
+ $sms->set_user_login($this->user_login);
141
+ $sms->set_api_key($this->api_key);
142
+ $sms->set_sms_mode($this->sms_mode);
143
+ $sms->set_sms_type($this->sms_type);
144
+
145
+ //campaign message
146
+ $sms_text = str_replace(array_keys($values), array_values($values), $this->replace_for_GSM7($txt));
147
+ $sms->set_sms_text($sms_text);
148
+ $sms->set_sms_sender($this->sms_sender);
149
+ $sms->set_option_transactional(1);
150
+
151
+ $phones = array();
152
+ $firstnames = array();
153
+ $lastnames = array();
154
+ foreach ($recipients as $recipient) {
155
+ $phones[] = $recipient['phone'];
156
+ if (strpos($txt, '(ch1)') !== false)
157
+ $firstnames[] = $recipient['firstname'];
158
+ if (strpos($txt, '(ch2)') !== false)
159
+ $lastnames[] = $recipient['lastname'];
160
+ }
161
+ $sms->set_sms_recipients($phones);
162
+ $sms->set_recipients_first_names($firstnames);
163
+ $sms->set_recipients_last_names($lastnames);
164
+ $sms->set_user_batch_id($id_campaign);
165
+
166
+ $sms->set_finished($finished ? 1 : 0);
167
+
168
+ //TODO une fois finis on appelle status en boucle toute les minutes jusqu'à avoir statut
169
+ return $sms->sendSMSParts();
170
+ }
171
+
172
+ /**
173
+ * Send a sms (depends of the hook and parameters given)
174
+ * @param type $hookName
175
+ * @param type $hookId
176
+ * @param type $params
177
+ */
178
+
179
+
180
+ public function _is_everything_valid_for_sending() {
181
+ $setting = Mage::getModel("octopushsms/setting")->load('1');
182
+ Mage::log("_is_everything_valid_for_sending()=".$setting->getKey() ." && ". $setting->getSender() ." && ". $setting->getData('admin_phone') ." && ". !empty($this->_phone) ." && ". is_array($this->_phone), Zend_Log::DEBUG, "octopushsms.log");
183
+ return ( $setting->getKey() && $setting->getSender() && $setting->getData('admin_phone') && !empty($this->_phone) && is_array($this->_phone));
184
+ }
185
+
186
+ /**
187
+ * Set the phone attribut (convert the phone number to international phone number)
188
+ * @param type $phone
189
+ * @param type $country iso country code (ex. FR)
190
+ * @param type $b_admin
191
+ */
192
+ public function _set_phone($phone = null, $country = null, $b_admin = false) {
193
+ $this->_phone = null;
194
+ if ($b_admin) {
195
+ $setting = Mage::getModel("octopushsms/setting")->load('1');
196
+ $this->_phone = array($setting->getData('admin_phone'));
197
+ } else if (!empty($country)) {
198
+ if (!empty($phone) && !empty($country)) {
199
+ $this->_phone = array($this->convert_phone_to_international($phone, $country));
200
+ }
201
+ }
202
+ }
203
+
204
+ /**
205
+ * Send sms
206
+ * @param type $text_to_send the textto send
207
+ * @param type $recipients the recipients
208
+ * @return boolean
209
+ */
210
+ public function _send_sms($sms_text) {
211
+ Mage::log('_send_sms ' . $sms_text . ' phone:' . print_r($this->_phone, true), Zend_Log::DEBUG, "octopushsms.log");
212
+ $sms = new SMS();
213
+
214
+ $sms_type = SMS_WORLD; //SMS_STANDARD; // ou encore SMS_STANDARD,SMS_PREMIUM
215
+ $sms_mode = INSTANTANE; // ou encore DIFFERE
216
+ $sms_sender = Mage::getModel('octopushsms/setting')->load('1')->getData('sender');
217
+ $sms->set_user_login($this->user_login);
218
+ $sms->set_api_key($this->api_key);
219
+ $sms->set_sms_mode($sms_mode);
220
+ $sms->set_sms_text($this->replace_for_GSM7($sms_text));
221
+ $sms->set_sms_recipients($this->_phone);
222
+ $sms->set_sms_type($sms_type);
223
+ $sms->set_sms_sender($sms_sender);
224
+ $sms->set_sms_request_id(uniqid());
225
+ $sms->set_option_with_replies(0);
226
+ //$sms->set_sms_fields_1(array(''));
227
+ //$sms->set_sms_fields_2(array('a'));
228
+ $sms->set_option_transactional(1);
229
+ $sms->set_sender_is_msisdn(0);
230
+ //$sms->set_date(2016, 4, 17, 10, 19); // En cas d'envoi différé.
231
+ //$sms->set_request_keys('TRS');
232
+
233
+ Mage::log('***** _send_sms ' . print_r($sms, true), Zend_Log::DEBUG, "octopushsms.log");
234
+ $xml = $sms->send();
235
+ Mage::log('***** Result ' . $xml, Zend_Log::DEBUG, "octopushsms.log");
236
+ if ($xml = simplexml_load_string($xml)) {
237
+ if ($xml->error_code != '000') {
238
+ Mage::log($this->get_error_SMS($xml->error_code), Zend_Log::ERR, "octopushsms.log");
239
+ }
240
+ }
241
+
242
+ //check account and send sms if necessary
243
+
244
+ }
245
+
246
+ private function _set_recipient($customer) {
247
+ $this->_recipients = $customer;
248
+ }
249
+
250
+ public function replace_for_GSM7($txt) {
251
+ $search = array('À', 'Á', 'Â', 'Ã', 'È', 'Ê', 'Ë', 'Ì', 'Í', 'Î', 'Ï', 'Ð', 'Ò', 'Ó', 'Ô', 'Õ', 'Ù', 'Ú', 'Û', 'Ý', 'Ÿ', 'á', 'â', 'ã', 'ê', 'ë', 'í', 'î', 'ï', 'ð', 'ó', 'ô', 'õ', 'ú', 'û', 'µ', 'ý', 'ÿ', 'ç', 'Þ', '°', '¨', '^', '«', '»', '|', '\\');
252
+ $replace = array('A', 'A', 'A', 'A', 'E', 'E', 'E', 'I', 'I', 'I', 'I', 'D', 'O', 'O', 'O', 'O', 'U', 'U', 'U', 'Y', 'Y', 'a', 'a', 'a', 'e', 'e', 'i', 'i', 'i', 'o', 'o', 'o', 'o', 'u', 'u', 'u', 'y', 'y', 'c', 'y', 'o', '-', '-', '"', '"', 'I', '/');
253
+ return str_replace($search, $replace, $txt);
254
+ }
255
+
256
+ public function is_GSM7($txt) {
257
+ if (preg_match("/^[ÀÁÂÃÈÊËÌÍÎÏÐÒÓÔÕÙÚÛÝŸáâãêëíîïðóôõúûµýÿçÞ°{|}~¡£¤¥§¿ÄÅÆÇÉÑÖØÜßàäåæèéìñòöøùü,\.\-!\"#$%&()*+\/:;<=>?@€\[\]\^\w\s\\']*$/u", $txt))
258
+ return true;
259
+ else
260
+ return false;
261
+ }
262
+
263
+ public function not_GSM7($txt) {
264
+ return preg_replace("/[ÀÁÂÃÈÊËÌÍÎÏÐÒÓÔÕÙÚÛÝŸáâãêëíîïðóôõúûµýÿçÞ°{|}~¡£¤¥§¿ÄÅÆÇÉÑÖØÜßàäåæèéìñòöøùü,\.\-!\"#$%&()*+\/:;<=>?@€\[\]\^\w\s\\']/u", "", $txt);
265
+ }
266
+
267
+ /**
268
+ * Convert phone number to international phone number.
269
+ *
270
+ * @global type $wpdb
271
+ * @param type $phone
272
+ * @param type $iso_country
273
+ * @param type $prefix
274
+ * @return type
275
+ */
276
+ public function convert_phone_to_international($phone, $iso_country, $prefix = null) {
277
+ $phonePrefixCollection = Mage::getModel('octopushsms/phoneprefix')->getCollection();
278
+ //$phonePrefixCollection->addFieldToFilter('iso_code', array('eq' => $iso_country));
279
+
280
+ $phone = preg_replace("/[^+0-9]/", "", $phone);
281
+
282
+ if (is_null($prefix)) {
283
+ $prefixModel = $phonePrefixCollection->addFieldToFilter('iso_code', array('eq' => $iso_country))->getFirstItem();
284
+ if (!empty($prefixModel)) {
285
+ $prefix = $prefixModel->getData('prefix');
286
+ }
287
+ }
288
+ if (empty($prefix)) {
289
+ return null;
290
+ } else {
291
+ // s'il commence par + il est déjà international
292
+ if (substr($phone, 0, 1) == '+') {
293
+ return $phone;
294
+ }
295
+ // s'il commence par 00 on les enlève et on vérifie le code pays pour ajouter le +
296
+ else if (substr($phone, 0, 2) == '00') {
297
+ $phone = substr($phone, 2);
298
+ if (strpos($phone, $prefix) === 0) {
299
+ return '+' . $phone;
300
+ } else {
301
+ return null;
302
+ }
303
+ }
304
+ // s'il commence par 0, on enlève le 0 et on ajoute le prefix du pays
305
+ else if (substr($phone, 0, 1) == '0') {
306
+ return '+' . $prefix . substr($phone, 1);
307
+ }
308
+ // s'il commence par le prefix du pays, on ajoute le +
309
+ else if (strpos($phone, $prefix) === 0) {
310
+ return '+' . $phone;
311
+ } else {
312
+ return '+' . $prefix . $phone;
313
+ }
314
+ }
315
+ }
316
+
317
+ /**
318
+ * Validate the campaign.
319
+ *
320
+ * @param type $id_campaign
321
+ * @param type $time
322
+ * @return type
323
+ */
324
+ public function validate_campaign($ticket, $time) {
325
+ $sms = new SMS();
326
+ $action = 'send';
327
+ $sms->set_user_login($this->user_login);
328
+ $sms->set_api_key($this->api_key);
329
+ $sms->set_user_batch_id($ticket);
330
+ $sms->set_sms_type(SMS_WORLD);
331
+
332
+ //Be careful to convert in function of the sms shop time GMT +1
333
+ $gmt_offset = Mage::getModel('core/date')->calculateOffset();
334
+ $sms->set_sms_mode(DIFFERE);
335
+ $date_send = date_parse_from_format("Y-m-d H:i:s", $time - $gmt_offset + 60);
336
+ $sms->set_date($date_send['year'], $date_send['month'], $date_send['day'], $date_send['hour'] - $gmt_offset, $date_send['minute']); // En cas d'envoi diffÈrÈ.
337
+ Mage::log("validate_campaign sms:" . print_r($sms, true) . " JSON_ENCODE_SMS: " . json_encode($sms), Zend_Log::DEBUG, "octopushsms.log");
338
+ $xml = $sms->SMSBatchAction($action);
339
+ Mage::log("validate_campaign($ticket, $time) : $xml", Zend_Log::DEBUG, "octopushsms.log");
340
+ //TODO alert if account under a certain level
341
+ //Octopush_Sms_Admin::get_instance()->action_admin_alert();
342
+
343
+ return $xml;
344
+ }
345
+
346
+ /**
347
+ * Get the campaign status on octopush.
348
+ *
349
+ * @param type $id_campaign
350
+ * @param type $time
351
+ * @return type
352
+ */
353
+ public function get_campaign_status($id_campaign) {
354
+ $sms = new SMS();
355
+ $action = 'status';
356
+ $sms->set_user_login($this->user_login);
357
+ $sms->set_api_key($this->api_key);
358
+ $sms->set_user_batch_id($id_campaign);
359
+ Mage::log("get_campaign_status:" . print_r($sms, true), Zend_Log::DEBUG, "octopushsms.log");
360
+ $xml = $sms->SMSBatchAction($action);
361
+ Mage::log("get_campaign_status($id_campaign) : $xml", Zend_Log::DEBUG, "octopushsms.log");
362
+ return $xml;
363
+ }
364
+
365
+ /**
366
+ * Cancel a campaign on octopus server if it is possible.
367
+ * @param type $id_campaign
368
+ * @return type
369
+ */
370
+ public function cancel_campaign($id_campaign) {
371
+ $sms = new SMS();
372
+ $action = 'delete';
373
+ $sms->set_user_login($this->user_login);
374
+ $sms->set_api_key($this->api_key);
375
+ $sms->set_user_batch_id($id_campaign);
376
+ $xml = $sms->SMSBatchAction($action);
377
+ Mage::log("cancel_campaign($id_campaign) : $xml", Zend_Log::DEBUG, "octopushsms.log");
378
+ return $xml;
379
+ }
380
+
381
+ /**
382
+ * Return error message
383
+ * @param type $code
384
+ * @return type
385
+ */
386
+ public function get_error_SMS($code) {
387
+ if (isset($code) && array_key_exists(intval($code), $GLOBALS['errors'])) {
388
+ return $GLOBALS['errors'][intval($code)];
389
+ }
390
+ return __('Error unknown', 'octopush-sms') . " $code";
391
+ }
392
+
393
+ }
app/code/local/Octopush/OctopushSms/Helper/API_SMS_PHP_Octopush/balance.php ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ // Exemple de consultation du crédit SMS
3
+
4
+
5
+ require('octopush_web_services.inc.php');
6
+
7
+ $user_login = '************@********';
8
+ $api_key = '****************';
9
+
10
+ $sms = new OWS();
11
+
12
+ $sms->set_user_login($user_login);
13
+ $sms->set_api_key($api_key);
14
+
15
+ $xml = $sms->get_balance();
16
+ echo $xml;
17
+ echo '<br />';
18
+ echo '<textarea style="width:600px;height:600px;">' . $xml . '</textarea>';
19
+ ?>
app/code/local/Octopush/OctopushSms/Helper/API_SMS_PHP_Octopush/campagne.php ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ // Exemple de envoi instantane de SMS
3
+
4
+ require('sms.inc.php');
5
+
6
+ $user_login = '************@********';
7
+ $api_key = '****************';
8
+
9
+ $sms_recipients = array('0000000000');
10
+ $sms_text = 'test d\'envoi à ' . date('Y-m-d H:i:s') . ' '; //{ch1} {ch2}
11
+
12
+ $sms_type = SMS_PREMIUM; // ou encore SMS_STANDARD,SMS_PREMIUM
13
+ $sms_mode = INSTANTANE; // ou encore DIFFERE
14
+ $sms_sender = 'UnSender';
15
+
16
+ $sms = new SMS();
17
+
18
+ $sms->set_user_login($user_login);
19
+ $sms->set_api_key($api_key);
20
+ $sms->set_sms_mode($sms_mode);
21
+ $sms->set_sms_text($sms_text);
22
+ $sms->set_sms_recipients($sms_recipients);
23
+ $sms->set_sms_type($sms_type);
24
+ $sms->set_sms_sender($sms_sender);
25
+ $sms->set_sms_request_id(uniqid());
26
+ $sms->set_option_with_replies(0);
27
+ //$sms->set_sms_fields_1(array(''));
28
+ //$sms->set_sms_fields_2(array('a'));
29
+ $sms->set_option_transactional(1);
30
+ $sms->set_sender_is_msisdn(0);
31
+ //$sms->set_date(2016, 4, 17, 10, 19); // En cas d'envoi différé.
32
+ $sms->set_request_keys('TRS');
33
+ $xml = $sms->send();
34
+ echo $xml;
35
+ echo '<br />';
36
+ echo '<textarea style="width:600px;height:600px;">' . $xml . '</textarea>';
37
+ ?>
app/code/local/Octopush/OctopushSms/Helper/API_SMS_PHP_Octopush/config.inc.php ADDED
@@ -0,0 +1,179 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Librairie d'envoi de SMS via POST HTTP
4
+ *
5
+ * Auteur Yoni Guimberteau yoni@octopush.com
6
+ *
7
+ * copyright (c) 2014 Yoni Guimberteau
8
+ * licence : utilisation, modification, commercialisation.
9
+ * L'auteur ainsi se decharge de toute responsabilite
10
+ * concernant une quelconque utilisation de ce code, livre sans aucune garantie.
11
+ * Il n'est distribue qu'a titre d'exemple de fonctionnement du module POST HTTP de OCTOPUSH,
12
+ * Vous pourrez toutefois telecharger une version actualisee sur www.octopush.com
13
+ */
14
+
15
+ //send one sms https://www.octopush-dm.com/api_wooc_os/sms_send
16
+ //send trames https://www.octopush-dm.com/api_wooc_os/sms_parts
17
+ //statut delete send https://www.octopush-dm.com/api_wooc_os/sms_batch
18
+
19
+ define('DOMAIN', 'http://www.octopush-dm.com');
20
+ define('CHANNEL','magento');
21
+ define('PORT', '80');
22
+ define('PATH', '');
23
+ define('PATH_BIS', '');
24
+ $path = PATH;
25
+
26
+ define('PATH_SMS', $path . '/api/sms');
27
+ define('PATH_BALANCE', $path . '/api/credit');
28
+ define('PATH_NEWS', $path . '/api/news');
29
+
30
+ // Options ouvertes sur demande. Demandez la documention annexe pour utiliser ces webservices.
31
+ define('PATH_SUB_ACCOUNT', $path . '/api_sub/add_sub_account');
32
+ define('PATH_CREDIT_SUB_ACCOUNT_TOKEN', $path . '/api_sub/credit_sub_account_get_session');
33
+ define('PATH_CREDIT_SUB_ACCOUNT', $path . '/api_sub/credit_sub_account');
34
+ define('PATH_OSTP', $path . '/api/open_single_temp_session');
35
+ define('PATH_EDIT_OPTIONS', $path . '/api/edit_options');
36
+ define('PATH_GET_USER_INFO', $path . '/api_sub/get_user_info');
37
+
38
+ define('PATH_SMS_PARTS', $path . '/api_mag_ss/sms_parts');
39
+ define('PATH_BATCH', $path . '/api_mag_ss/sms_batch');
40
+
41
+ define('_CUT_', 7);
42
+
43
+ define('SMS_STANDARD', 'XXX');
44
+ define('SMS_WORLD', 'WWW');
45
+ define('SMS_PREMIUM', 'FR');
46
+
47
+ define('INSTANTANE', 1);
48
+ define('DIFFERE', 2);
49
+
50
+ define('SIMULATION', 'simu');
51
+ define('REEL', 'real');
52
+
53
+ define('_STR_STOP_', 'STOP au XXXXX');
54
+
55
+ //error
56
+ define('_ERROR_OK_', 'OK');
57
+ define('_ERROR_KO_', 'KO');
58
+ define('_ERROR_CODE_OK_', 0);
59
+ define('_ERROR_CODE_KO_', 500);
60
+ define('_ERROR_MISSING_POST_PARAMETERS_', 100);
61
+ define('_ERROR_WRONG_IDENTIFIERS_',101);
62
+ define('_ERROR_SMS_TOO_LONG_',102);
63
+ define('_ERROR_NO_RECIPIENTS_', 103);
64
+ define('_ERROR_LOW_MONEY_', 104);
65
+ define('_ERROR_LOW_MONEY_BUT_ORDER_', 105);
66
+ define('_ERROR_BAD_SENDER_', 106);
67
+ define('_ERROR_MISSING_PARAMETER_TEXT_', 107);
68
+ define('_ERROR_MISSING_PARAMETER_LOGIN_', 108);
69
+ define('_ERROR_MISSING_PARAMETER_PASSWORD_', 109);
70
+ define('_ERROR_MISSING_PARAMETER_RECIPIENTS_', 110);
71
+ define('_ERROR_MISSING_PARAMETER_DEST_CHOSE_WAY_', 111);
72
+ define('_ERROR_MISSING_PARAMETER_QUALITY_', 112);
73
+ define('_ERROR_UNCHECKED_PHONE_', 113);
74
+ define('_ERROR_BLACKLISTED_USER_', 114);
75
+ define('_ERROR_RECIPIENTS_PARAMS_NUMBER_', 115);
76
+ define('_ERROR_MAILING_UNAVAILABLE_', 116);
77
+ define('_ERROR_RECIPIENTS_WRONG_FORMAT_', 117);
78
+ define('_ERROR_NOT_ANY_CHECKED_CHECKBOX_', 118);
79
+ define('_ERROR_LONG_LOWCOST_SMS_NOT_ALLOWED_', 119);
80
+ define('_ERROR_REQUEST_ID_ALREADY_EXISTS_', 120);
81
+ define('_ERROR_STOP_MENTION_IS_MISSING_', 121);
82
+ define('_ERROR_NO_PUB_MENTION_IS_MISSING_', 122);
83
+ define('_ERROR_STRING_SHA1_IS_MISSING_', 123);
84
+ define('_ERROR_STRING_SHA1_IS_WRONG_', 124);
85
+ define('_ERROR_AN_UNKNOWN_ERROR_HAS_OCCURED_', 125);
86
+ define('_ERROR_HUGE_CAMPAIGN_ALREADY_AWAITING_', 126);
87
+ define('_ERROR_HUGE_CAMPAIGN_BEING_COMPUTED_', 127);
88
+ define('_ERROR_TOO_MUCH_SUBMITIONS_', 128);
89
+ define('_ERROR_BATCH_SMS_PROSSESSING_', 129);
90
+ define('_ERROR_BATCH_SMS_NOT_FINISHED_', 130);
91
+ define('_ERROR_BATCH_SMS_NOT_FOUND_', 131);
92
+ define('_ERROR_BATCH_SMS_ALREADY_SENT_', 132);
93
+
94
+ define('_ERROR_UNFOUND_COUNTRY_CODE_', 150);
95
+ define('_ERROR_COUNTRY_UNAVAILABLE_', 151);
96
+ define('_ERROR_COUNTRY_NOT_AVAILABLE_IN_LC_', 152);
97
+ define('_ERROR_ROUTE_NOT_UNAVAILABLE_LC_', 153);
98
+
99
+ define('_ERROR_U_R_NOT_ALLOWED_SUB_USERS_', 201);
100
+ define('_ERROR_SUB_USER_WRONG_EMAIL_', 202);
101
+ define('_ERROR_SUB_USER_TOO_MUCH_TOKENS_', 203);
102
+ define('_ERROR_SUB_USER_WRONG_TOKEN_', 204);
103
+ define('_ERROR_SUB_USER_NB_SMS_TOO_LOW_', 205);
104
+ define('_ERROR_SUB_USER_CANT_TRANSFER_CAMPAIGN_', 206);
105
+ define('_ERROR_SUB_USER_CANT_ACCESS_', 207);
106
+ define('_ERROR_SUB_USER_WRONG_SMS_TYPE_', 208);
107
+ define('_ERROR_SUB_USER_FORBIDDEN_', 209);
108
+ define('_ERROR_EMAIL_DOES_NOT_BELONG_TO_YOURS_', 210);
109
+
110
+ define('_ERROR_U_R_NOT_ALLOWED_LISTS_', 300);
111
+ define('_ERROR_MAX_NUMBER_OF_LISTS_REACHED_', 301);
112
+ define('_ERROR_A_LIST_ALLREADY_EXISTS_', 302);
113
+ define('_ERROR_LIST_DOESNT_EXIST_', 303);
114
+ define('_ERROR_LIST_IS_FULL_', 304);
115
+ define('_ERROR_TO_MUCH_CONTACTS_IN_REQUEST_', 305);
116
+ define('_ERROR_LIST_ACTION_UNKNOWN_', 306);
117
+
118
+ $GLOBALS['errors'] = array(
119
+ _ERROR_OK_ => __('OK','octopush-sms'),
120
+ _ERROR_KO_ => __('KO','octopush-sms'),
121
+ _ERROR_CODE_OK_ => __('OK','octopush-sms'),
122
+ _ERROR_CODE_KO_ => __('Impossible to process requested action','octopush-sms'),
123
+ _ERROR_MISSING_POST_PARAMETERS_ => __('POST request missing.','octopush-sms'),
124
+ _ERROR_WRONG_IDENTIFIERS_ => __('Incorrect login details.','octopush-sms'),
125
+ _ERROR_SMS_TOO_LONG_ => __('Your SMS exceeds 160 characters','octopush-sms'),
126
+ _ERROR_NO_RECIPIENTS_ => __('Your message has no recipients','octopush-sms'),
127
+ _ERROR_LOW_MONEY_ => __('You have run out of credit.','octopush-sms'),
128
+ _ERROR_LOW_MONEY_BUT_ORDER_ => __('You don\'t have enough credit on your balance your last order is being validated','octopush-sms'),
129
+ _ERROR_BAD_SENDER_ => __('You have entered the Sender incorrectly. 3 to 11 characters, chosen from 0 to 9, a to z, A to Z. No accents, spaces or punctuation.','octopush-sms'),
130
+ _ERROR_MISSING_PARAMETER_TEXT_ => __('The text of your message is missing.','octopush-sms'),
131
+ _ERROR_MISSING_PARAMETER_QUALITY_ => __('You have not defined the quality of your message.','octopush-sms'),
132
+ _ERROR_MISSING_PARAMETER_LOGIN_ => __('You have not entered your login details.','octopush-sms'),
133
+ _ERROR_MISSING_PARAMETER_PASSWORD_ => __('You have not entered your password.','octopush-sms'),
134
+ _ERROR_MISSING_PARAMETER_RECIPIENTS_ => __('You have not entered the list of recipients.','octopush-sms'),
135
+ _ERROR_MISSING_PARAMETER_DEST_CHOSE_WAY_ => __('You have not chosen a way to enter your recipients.','octopush-sms'),
136
+ _ERROR_RECIPIENTS_PARAMS_NUMBER_ => __('Your recipient list does not contain a valid number.','octopush-sms'),
137
+ _ERROR_UNCHECKED_PHONE_ => __('Your account is not validated. Log in and go to the "User interface" section.','octopush-sms'),
138
+ 'error_web_' . _ERROR_UNCHECKED_PHONE_ => __('Your account is not validated. <br /><br /> Click on the button below to activate it.','octopush-sms'),
139
+ _ERROR_BLACKLISTED_USER_ => __('You are under investigation for the fraudulent use of our services.','octopush-sms'),
140
+ _ERROR_RECIPIENTS_PARAMS_NUMBER_ => __('The recipient number is different from the number of one of the parameters that you have related it to.','octopush-sms'),
141
+ _ERROR_MAILING_UNAVAILABLE_ => __('The mailing option only works by using a contact list.','octopush-sms'),
142
+ _ERROR_RECIPIENTS_WRONG_FORMAT_ => __('Your recipient list contains no correct numbers. Have you formated your numbers by including the international dialling code? Contact us if you have any problems.','octopush-sms'),
143
+ _ERROR_NOT_ANY_CHECKED_CHECKBOX_ => __('You must tick one of the two boxes to indicate if <u> you do not wish to send test SMS </u> or if <u>you have correctly received and validated it</u>.','octopush-sms'),
144
+ _ERROR_LONG_LOWCOST_SMS_NOT_ALLOWED_ => __('You cannot send SMS with more than x characters for this type of SMS','octopush-sms'),
145
+ _ERROR_REQUEST_ID_ALREADY_EXISTS_ => __('A SMS with the same request_id has already been sent.','octopush-sms'),
146
+ _ERROR_STOP_MENTION_IS_MISSING_ => __('In Premium SMS, the mention "'._STR_STOP_.'" is mandatory and must belong to your text (respect the case).','octopush-sms'),
147
+ _ERROR_NO_PUB_MENTION_IS_MISSING_ => __('In Standard SMS, the mention _STR_NO_PUB_ is mandatory and must belong to your text (respect the case).','octopush-sms'),
148
+ _ERROR_STRING_SHA1_IS_MISSING_ => __('The field request_sha1 is missing.','octopush-sms'),
149
+ _ERROR_STRING_SHA1_IS_WRONG_ => __('The field request_sha1 does not match. The data is wrong, or the query string contains an error or the frame contains an error : the request is rejected.','octopush-sms'),
150
+ _ERROR_AN_UNKNOWN_ERROR_HAS_OCCURED_ => __('An undefined error has occurred. Please contact support.','octopush-sms'),
151
+ _ERROR_HUGE_CAMPAIGN_ALREADY_AWAITING_ => __('An SMS campaign is already waiting for approval to send. You must validate or Cancel it in order to to start another.','octopush-sms'),
152
+ _ERROR_HUGE_CAMPAIGN_BEING_COMPUTED_ => __('An SMS campaign is already being processed. You must wait for processing to be completed in order to start another.','octopush-sms'),
153
+ _ERROR_TOO_MUCH_SUBMITIONS_ => __('Too many attempts have been made. You need to start a new campaign.','octopush-sms'),
154
+ _ERROR_BATCH_SMS_PROSSESSING_ => __('Campaign is being built.','octopush-sms'),
155
+ _ERROR_BATCH_SMS_NOT_FINISHED_ => __('Campagne has not been set as finished.','octopush-sms'),
156
+ _ERROR_BATCH_SMS_NOT_FOUND_ => __('Campaign not found.','octopush-sms'),
157
+ _ERROR_BATCH_SMS_ALREADY_SENT_ => __('Campaign sent.','octopush-sms'),
158
+ _ERROR_UNFOUND_COUNTRY_CODE_ => __('No country was found for this prefixe.','octopush-sms'),
159
+ _ERROR_COUNTRY_UNAVAILABLE_ => __('The recipient country is not part of the countries serviced.','octopush-sms'),
160
+ _ERROR_COUNTRY_NOT_AVAILABLE_IN_LC_ => __('You cannot send low cost SMS to this country. Choose Premium SMS','octopush-sms'),
161
+ _ERROR_ROUTE_NOT_UNAVAILABLE_LC_ => __('The route is congested. This type of SMS cannot be dispatched immediately. If your order is urgent, please use another type of SMS.','octopush-sms'),
162
+ _ERROR_U_R_NOT_ALLOWED_SUB_USERS_ => __('This option is only available on request. Do not hesitate to request access if you need it.','octopush-sms'),
163
+ _ERROR_SUB_USER_WRONG_EMAIL_ => __('The email account you wish to credit is incorrect.','octopush-sms'),
164
+ _ERROR_SUB_USER_TOO_MUCH_TOKENS_ => __('You already have tokens in use. You can only have one session open at a time.','octopush-sms'),
165
+ _ERROR_SUB_USER_WRONG_TOKEN_ => __('You specified a wrong token.','octopush-sms'),
166
+ _ERROR_SUB_USER_NB_SMS_TOO_LOW_ => __('The number of text messages you want to transfer is too low.','octopush-sms'),
167
+ _ERROR_SUB_USER_CANT_TRANSFER_CAMPAIGN_ => __('You may not run campaigns during a credit transfer.','octopush-sms'),
168
+ _ERROR_SUB_USER_CANT_ACCESS_ => __('You do not have access to this feature.','octopush-sms'),
169
+ _ERROR_SUB_USER_WRONG_SMS_TYPE_ => __('Wrong type of SMS.','octopush-sms'),
170
+ _ERROR_SUB_USER_FORBIDDEN_ => __('You are not allowed to send SMS messages to this user.','octopush-sms'),
171
+ _ERROR_EMAIL_DOES_NOT_BELONG_TO_YOURS_ => __('This email is not specified in any of your sub accounts or affiliate users.','octopush-sms'),
172
+ _ERROR_U_R_NOT_ALLOWED_LISTS_ => __('You are not authorized to manage your lists by API.','octopush-sms'),
173
+ _ERROR_MAX_NUMBER_OF_LISTS_REACHED_ => __('You have reached the maximum number of lists.','octopush-sms'),
174
+ _ERROR_A_LIST_ALLREADY_EXISTS_ => __('A list with the same name already exists.','octopush-sms'),
175
+ _ERROR_LIST_DOESNT_EXIST_ => __('The specified list does not exist.','octopush-sms'),
176
+ _ERROR_LIST_IS_FULL_ => __('The list is already full.','octopush-sms'),
177
+ _ERROR_TO_MUCH_CONTACTS_IN_REQUEST_ => __('There are too many contacts in the query.','octopush-sms'),
178
+ _ERROR_LIST_ACTION_UNKNOWN_ => __('The requested action is unknown.','octopush-sms'));
179
+ ?>
app/code/local/Octopush/OctopushSms/Helper/API_SMS_PHP_Octopush/create_sub_account.php ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ // Exemple de envoi instantane de SMS
3
+
4
+ require('sms.inc.php');
5
+
6
+ $user_login = '************@********';
7
+ $api_key = '****************';
8
+
9
+ $first_name = 'Prenom';
10
+ $last_name = 'Nom';
11
+ $raison_sociale = 'Raison';
12
+ $alert_bound = '243';
13
+ $alert_sms_type = 'FR';
14
+
15
+ $sms = new SMS();
16
+
17
+ $sms->set_user_login($user_login);
18
+ $sms->set_api_key($api_key);
19
+ $xml = $sms->create_sub_account($first_name, $last_name, $raison_sociale, $alert_bound, $alert_sms_type);
20
+ echo $xml;
21
+ echo '<br />';
22
+ echo '<textarea style="width:600px;height:600px;">' . $xml . '</textarea>';
23
+ ?>
app/code/local/Octopush/OctopushSms/Helper/API_SMS_PHP_Octopush/credit_sub_account.php ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ // Exemple de envoi instantane de SMS
3
+
4
+ require('sms.inc.php');
5
+
6
+ $user_login = '************@********';
7
+ $api_key = '****************';
8
+
9
+ $login_account = 'xxxxxxxxxxxxxxxxxxx@sub-accounts.com';
10
+ $nb_sms = '1000';
11
+ $sms_type = 'FR';
12
+
13
+ $sms = new SMS();
14
+ $xml = $sms->credit_sub_account($user_login, $api_key, $login_account, $nb_sms, $sms_type);
15
+ echo $xml;
16
+ echo '<br />';
17
+ echo '<textarea style="width:600px;height:600px;">' . $xml . '</textarea>';
18
+ ?>
app/code/local/Octopush/OctopushSms/Helper/API_SMS_PHP_Octopush/edit_options.php ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ // Exemple de envoi instantane de SMS
3
+
4
+ require('octopush_web_services.inc.php');
5
+
6
+ $user_login = '************@********';
7
+ $api_key = '****************';
8
+
9
+ $sms_type = SMS_WORLD; // ou encore SMS_STANDARD,SMS_PREMIUM
10
+ $sms_mode = INSTANTANE; // ou encore DIFFERE
11
+ $sms_sender = 'Octopush';
12
+
13
+ $ows = new OWS();
14
+
15
+ $ows->set_user_login($user_login);
16
+ $ows->set_api_key($api_key);
17
+ $ows->set_sms_alert_bound(1111);
18
+ $ows->set_sms_alert_type(SMS_STANDARD);
19
+ $ows->set_answer_email('un@emailvalide.com');
20
+
21
+ $xml = $ows->edit_options();
22
+
23
+ echo $xml;
24
+ echo '<br />';
25
+ echo '<textarea style="width:600px;height:600px;">' . $xml . '</textarea>';
26
+ ?>
app/code/local/Octopush/OctopushSms/Helper/API_SMS_PHP_Octopush/get_user_info.php ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ // Exemple de envoi instantane de SMS
4
+
5
+ require('octopush_web_services.inc.php');
6
+
7
+ $user_login = '************@********';
8
+ $api_key = '****************';
9
+
10
+ $login_account = 'xxxxxxxxxx@sub-accounts.com';
11
+
12
+ $ows = new OWS();
13
+
14
+ $ows->set_user_login($user_login);
15
+ $ows->set_api_key($api_key);
16
+ $xml = $ows->get_user_info($login_account);
17
+ echo $xml;
18
+ echo '<br />';
19
+ echo '<textarea style="width:600px;height:600px;">' . $xml . '</textarea>';
20
+ ?>
app/code/local/Octopush/OctopushSms/Helper/API_SMS_PHP_Octopush/octopush_web_services.inc.php ADDED
@@ -0,0 +1,247 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Librairie de services complémentaires via POST HTTP
5
+ *
6
+ * Auteur Yoni Guimberteau yoni@octopush.com
7
+ *
8
+ * copyright (c) 2013 Yoni Guimberteau
9
+ * licence : utilisation, modification, commercialisation.
10
+ * L'auteur ainsi se decharge de toute responsabilite
11
+ * concernant une quelconque utilisation de ce code, livre sans aucune garantie.
12
+ * Il n'est distribue qu'a titre d'exemple de fonctionnement du module POST HTTP de OCTOPUSH,
13
+ * Vous pourrez toutefois telecharger une version actualisee sur www.octopush.com
14
+ */
15
+ include_once ('config.inc.php');
16
+
17
+ class OWS
18
+ {
19
+
20
+ public $user_login; // string
21
+ public $api_key; // string
22
+ public $answer_email; // string
23
+ public $sms_alert_bound; // int
24
+ public $sms_alert_type; // FR ou XXX
25
+
26
+ public function __construct()
27
+ {
28
+ $this->user_login = '';
29
+ $this->api_key = '';
30
+
31
+ $this->answer_email = -1;
32
+ $this->sms_alert_bound = -1;
33
+ $this->sms_alert_type = -1;
34
+ }
35
+
36
+ /*
37
+ * Fonction credit_sub_account
38
+ *
39
+ * Make the request -> token -> request from server to server to execute the transfer
40
+ *
41
+ */
42
+
43
+ public function credit_sub_account($user_login, $api_key, $sub_account_email, $sms_amount, $sms_type)
44
+ {
45
+ $domain = DOMAIN;
46
+ $path = PATH_CREDIT_SUB_ACCOUNT_TOKEN;
47
+ $port = PORT;
48
+
49
+ $data = array(
50
+ 'user_login' => $user_login,
51
+ 'api_key' => $api_key,
52
+ 'sub_account_email' => $sub_account_email
53
+ );
54
+
55
+ $xml_return = trim($this->_httpRequest($domain, $path, $port, $data));
56
+ /* $xml_return = '<?xml version="1.0" encoding="UTF-8"?>
57
+ <octopush>
58
+ <token>F76C90C4F269289575363AE34BF6E399</token>
59
+ </octopush>'; */
60
+ libxml_use_internal_errors(true);
61
+ if (($xml = simplexml_load_string($xml_return)) !== false)
62
+ {
63
+ $res = (array) $xml->xpath('/octopush');
64
+ $tt = ((array) $res[0]);
65
+ $token = $tt['token'];
66
+ }
67
+ else
68
+ {
69
+ return 'An error as occured.';
70
+ }
71
+
72
+ /* Now, the token is ready, we can ask for the transfer to be done */
73
+
74
+ $domain = DOMAIN;
75
+ $path = PATH_CREDIT_SUB_ACCOUNT;
76
+ $port = PORT;
77
+
78
+ /* We check that the type of the sms belong to the usual values */
79
+ if ($sms_type != 'FR' && $sms_type != 'XXX')
80
+ {
81
+ $sms_type = 'FR';
82
+ }
83
+
84
+ $data = array(
85
+ 'user_login' => $user_login,
86
+ 'api_key' => $api_key,
87
+ 'sub_account_email' => $sub_account_email,
88
+ 'sms_number' => $sms_amount,
89
+ 'sms_type' => $sms_type,
90
+ 'token' => $token
91
+ );
92
+
93
+ $xml_return = trim($this->_httpRequest($domain, $path, $port, $data));
94
+ return $xml_return;
95
+ }
96
+
97
+ public function edit_options()
98
+ {
99
+ $domain = DOMAIN;
100
+ $path = PATH_EDIT_OPTIONS;
101
+ $port = PORT;
102
+
103
+ $data = array(
104
+ 'user_login' => $this->user_login,
105
+ 'api_key' => $this->api_key);
106
+
107
+ if ($this->answer_email !== -1)
108
+ $data['answer_email'] = $this->answer_email;
109
+ if ($this->sms_alert_bound !== -1)
110
+ $data['sms_alert_bound'] = $this->sms_alert_bound;
111
+ if ($this->sms_alert_type !== -1)
112
+ $data['sms_alert_type'] = $this->sms_alert_type;
113
+
114
+ $xml_return = trim($this->_httpRequest($domain, $path, $port, $data));
115
+ return $xml_return;
116
+ }
117
+
118
+ public function get_balance()
119
+ {
120
+ $domain = DOMAIN;
121
+ $path = PATH_BALANCE;
122
+ $port = PORT;
123
+
124
+ $data = array(
125
+ 'user_login' => $this->user_login,
126
+ 'api_key' => $this->api_key
127
+ );
128
+
129
+ return trim($this->_httpRequest($domain, $path, $port, $data));
130
+ }
131
+
132
+ private function _httpRequest($domain, $path, $port, $A_fields = array())
133
+ {
134
+ $ssl = $domain . $path;
135
+ @set_time_limit(0);
136
+ $qs = array();
137
+ foreach ($A_fields as $k => $v)
138
+ {
139
+ $qs[] = $k . '=' . urlencode($v);
140
+ }
141
+
142
+ $request = join('&', $qs);
143
+ Mage::log("_httprequest: $ssl $port $request", Zend_Log::DEBUG, "octopushsms.log");
144
+
145
+ if (function_exists('curl_init') AND $ch = curl_init(substr($domain, _CUT_) . $path))
146
+ {
147
+ curl_setopt($ch, CURLOPT_POST, true);
148
+ curl_setopt($ch, CURLOPT_PORT, $port);
149
+
150
+ curl_setopt($ch, CURLOPT_POSTFIELDS, $request);
151
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
152
+ curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
153
+
154
+ $result = curl_exec($ch);
155
+ curl_close($ch);
156
+
157
+ Mage::log("_httprequest result: $result", Zend_Log::DEBUG, "octopushsms.log");
158
+ return $result;
159
+ }
160
+ else if (ini_get('allow_url_fopen'))
161
+ {
162
+ $fp = fsockopen(substr($domain, _CUT_), $port, $errno, $errstr, 100);
163
+ if (!$fp)
164
+ {
165
+ Mage::log("Unable to connect to host. Try again later.", Zend_Log::DEBUG, "octopushsms.log");
166
+ echo 'Unable to connect to host. Try again later.';
167
+ return null;
168
+ }
169
+ $header = "POST " . $path . " HTTP/1.1\r\n";
170
+ $header .= 'Host: ' . substr($domain, _CUT_) . "\r\n";
171
+ $header .= "Accept: text\r\n";
172
+ $header .= "User-Agent: Octopush\r\n";
173
+ $header .= "Content-Type: application/x-www-form-urlencoded\r\n";
174
+ $header .= "Content-Length: " . strlen($request) . "\r\n";
175
+ $header .= "Connection: close\r\n\r\n";
176
+ $header .= "{$request}\r\n\r\n";
177
+
178
+ fputs($fp, $header);
179
+ $result = '';
180
+ while (!feof($fp))
181
+ $result .= fgets($fp, 1024);
182
+ fclose($fp);
183
+
184
+ $result = substr($result, strpos($result, "\r\n\r\n") + 4);
185
+ Mage::log("_httprequest result: $result", Zend_Log::DEBUG, "octopushsms.log");
186
+ return $result;
187
+ }
188
+ else
189
+ {
190
+ Mage::log('Server does not support HTTP(S) requests.', Zend_Log::INFO, "octopushsms.log");
191
+ die('Server does not support HTTP(S) requests.');
192
+ }
193
+ Mage::log("_httprequest response: $response", Zend_Log::DEBUG, "octopushsms.log");
194
+
195
+ return $response;
196
+ }
197
+
198
+ public function set_user_login($user_login)
199
+ {
200
+ $this->user_login = $user_login;
201
+ }
202
+
203
+ public function set_api_key($api_key)
204
+ {
205
+ $this->api_key = $api_key;
206
+ }
207
+
208
+ public function set_answer_email($answer_email)
209
+ {
210
+ $this->answer_email = $answer_email;
211
+ }
212
+
213
+ public function set_sms_alert_bound($sms_alert_bound)
214
+ {
215
+ $this->sms_alert_bound = intval($sms_alert_bound);
216
+ }
217
+
218
+ public function set_sms_alert_type($sms_alert_type)
219
+ {
220
+ if (in_array($sms_alert_type, array(SMS_PREMIUM, SMS_STANDARD)))
221
+ $this->sms_alert_type = $sms_alert_type;
222
+ }
223
+
224
+ /*
225
+ * XML PARSING FUNCTIONS
226
+ */
227
+
228
+ public function parse_octopush_token_result($xml)
229
+ {
230
+ libxml_use_internal_errors(true);
231
+ if (($xml = simplexml_load_string($xml)) !== false)
232
+ {
233
+ $result = $xml->xpath('/octopush');
234
+ $res = (array) $result[0];
235
+ $token = $res['token'];
236
+ }
237
+ else
238
+ {
239
+ $token = '';
240
+ }
241
+
242
+ return $token;
243
+ }
244
+
245
+ }
246
+
247
+ ?>
app/code/local/Octopush/OctopushSms/Helper/API_SMS_PHP_Octopush/sms.inc.php ADDED
@@ -0,0 +1,555 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Librairie d'envoi de SMS via POST HTTP
5
+ *
6
+ * Auteur Yoni Guimberteau yoni@octopush.com
7
+ *
8
+ * copyright (c) 2014 Yoni Guimberteau
9
+ * licence : utilisation, modification, commercialisation.
10
+ * L'auteur ainsi se decharge de toute responsabilite
11
+ * concernant une quelconque utilisation de ce code, livre sans aucune garantie.
12
+ * Il n'est distribue qu'a titre d'exemple de fonctionnement du module POST HTTP de OCTOPUSH,
13
+ * Vous pourrez toutefois telecharger une version actualisee sur www.octopush.com
14
+ */
15
+ include_once ('config.inc.php');
16
+
17
+ class SMS
18
+ {
19
+
20
+ public $user_login; // string
21
+ public $api_key; // string
22
+ public $sms_text; // string
23
+ public $user_lang; //string for news api
24
+ public $sms_recipients; // array
25
+ public $recipients_first_names; // array
26
+ public $recipients_last_names; // array
27
+ public $sms_fields_1; // array
28
+ public $sms_fields_2; // array
29
+ public $sms_fields_3; // array
30
+ public $sms_mode; // int (instantanous or deffered)
31
+ public $sms_type; // int (standard or pro)
32
+ public $sending_date; // int
33
+ public $sms_sender; // string
34
+ public $request_mode; // string
35
+ public $request_id; // string
36
+ public $sms_ticket; // string
37
+ public $with_replies; // int
38
+ public $transactional; // int
39
+ public $msisdn_sender; // int
40
+ public $request_keys; // int
41
+ // SMS parts
42
+ public $user_batch_id; // string
43
+ public $finished; // int
44
+ public $action; // string
45
+
46
+ public function __construct()
47
+ {
48
+ $this->user_login = '';
49
+ $this->api_key = '';
50
+ $this->user_lang = '';
51
+ $this->sms_text = '';
52
+
53
+ $this->sms_recipients = array();
54
+ $this->recipients_first_names = array();
55
+ $this->recipients_last_names = array();
56
+ $this->sms_fields_1 = array();
57
+ $this->sms_fields_2 = array();
58
+ $this->sms_fields_3 = array();
59
+
60
+ $this->sms_mode = INSTANTANE;
61
+ $this->sending_date = time();
62
+ $this->sms_d = date('d');
63
+ $this->sms_m = date('m');
64
+ $this->sms_h = date('H');
65
+ $this->sms_i = date('i');
66
+ $this->sms_y = date('Y');
67
+
68
+ $this->sms_sender = 'CampagneSMS';
69
+ $this->sms_type = SMS_STANDARD;
70
+ $this->sms_mode = INSTANTANE;
71
+ $this->request_mode = REEL;
72
+ $this->request_id = '';
73
+ $this->with_replies = 0;
74
+ $this->transactional = 0;
75
+ $this->msisdn_sender = 0;
76
+ $this->request_keys = '';
77
+
78
+ // SMS parts
79
+ $this->user_batch_id = '';
80
+ }
81
+
82
+ public function send()
83
+ {
84
+ $domain = DOMAIN;
85
+ $path = PATH_SMS;
86
+ $port = PORT;
87
+
88
+ $data = array(
89
+ 'user_login' => $this->user_login,
90
+ 'api_key' => $this->api_key,
91
+ 'sms_text' => $this->sms_text,
92
+ 'sms_recipients' => implode(',', $this->sms_recipients),
93
+ 'recipients_first_names' => implode(',', $this->recipients_first_names),
94
+ 'recipients_last_names' => implode(',', $this->recipients_last_names),
95
+ 'sms_fields_1' => implode(',', $this->sms_fields_1),
96
+ 'sms_fields_2' => implode(',', $this->sms_fields_2),
97
+ 'sms_fields_3' => implode(',', $this->sms_fields_3),
98
+ 'sms_mode' => $this->sms_mode,
99
+ 'sms_type' => $this->sms_type,
100
+ 'sms_sender' => $this->sms_sender,
101
+ 'request_mode' => $this->request_mode,
102
+ 'request_id' => $this->request_id,
103
+ 'with_replies' => $this->with_replies,
104
+ 'transactional' => $this->transactional,
105
+ 'msisdn_sender' => $this->msisdn_sender
106
+ );
107
+ if ($this->sms_mode == DIFFERE)
108
+ {
109
+ // GMT + 1 (Europe/Paris)
110
+ $data['sending_date'] = $this->sending_date;
111
+ }
112
+
113
+ // Si des champs sont définis, on calcule la clé
114
+ if ($this->request_keys !== '')
115
+ {
116
+ $data['request_keys'] = $this->request_keys;
117
+ $data['request_sha1'] = $this->_get_request_sha1_string($this->request_keys, $data);
118
+ }
119
+
120
+ return trim($this->_httpRequest($domain, $path, $port, $data));
121
+ }
122
+
123
+ public function sendSMSParts()
124
+ {
125
+ $domain = DOMAIN;
126
+ $path = PATH_SMS_PARTS;
127
+ $port = PORT;
128
+
129
+ $data = array(
130
+ 'user_login' => $this->user_login,
131
+ 'api_key' => $this->api_key,
132
+ 'sms_text' => $this->sms_text,
133
+ 'sms_recipients' => implode(',', $this->sms_recipients),
134
+ 'recipients_first_names' => implode(',', $this->recipients_first_names),
135
+ 'recipients_last_names' => implode(',', $this->recipients_last_names),
136
+ 'sms_fields_1' => implode(',', $this->sms_fields_1),
137
+ 'sms_fields_2' => implode(',', $this->sms_fields_2),
138
+ 'sms_fields_3' => implode(',', $this->sms_fields_3),
139
+ 'sms_mode' => $this->sms_mode,
140
+ 'sms_type' => $this->sms_type,
141
+ 'sms_sender' => $this->sms_sender,
142
+ 'request_mode' => $this->request_mode,
143
+ 'request_id' => $this->request_id,
144
+ 'with_replies' => $this->with_replies,
145
+ 'msisdn_sender' => $this->msisdn_sender,
146
+ 'user_batch_id' => $this->user_batch_id,
147
+ 'finished' => $this->finished
148
+ );
149
+
150
+ return trim($this->_httpRequest($domain, $path, $port, $data));
151
+ }
152
+
153
+ /*
154
+ * Fonction SMSBatchAction
155
+ *
156
+ * Allow to send ("send"), to delete ("delete") or to get the status ("status") of a campaign
157
+ * sent with sendSMSParts
158
+ *
159
+ */
160
+
161
+ public function SMSBatchAction($action)
162
+ {
163
+ $domain = DOMAIN;
164
+ $path = PATH_BATCH;
165
+ $port = PORT;
166
+
167
+ $data = array(
168
+ 'user_login' => $this->user_login,
169
+ 'api_key' => $this->api_key,
170
+ 'action' => $action,
171
+ 'user_batch_id' => $this->user_batch_id,
172
+ 'sending_time' => $this->sending_date
173
+ );
174
+
175
+ return trim($this->_httpRequest($domain, $path, $port, $data));
176
+ }
177
+
178
+ /*
179
+ * Fonction create_sub_account
180
+ *
181
+ */
182
+
183
+ public function create_sub_account($first_name, $last_name, $raison_sociale, $alert_bound, $alert_sms_type)
184
+ {
185
+ $domain = DOMAIN;
186
+ $path = PATH_SUB_ACCOUNT;
187
+ $port = PORT;
188
+
189
+ $data = array(
190
+ 'user_login' => $this->user_login,
191
+ 'api_key' => $this->api_key,
192
+ 'first_name' => $first_name,
193
+ 'last_name' => $last_name,
194
+ 'raison_sociale' => $raison_sociale,
195
+ 'alert_bound' => intval($alert_bound),
196
+ 'alert_sms_type' => $alert_sms_type
197
+ );
198
+
199
+ return trim($this->_httpRequest($domain, $path, $port, $data));
200
+ }
201
+
202
+ /*
203
+ * Fonction credit_sub_account
204
+ *
205
+ * Make the request = get the token + use the token into a request from server to server to execute the transfer
206
+ *
207
+ */
208
+
209
+ public function credit_sub_account($user_login, $api_key, $sub_account_email, $sms_amount, $sms_type)
210
+ {
211
+ $domain = DOMAIN;
212
+ $path = PATH_CREDIT_SUB_ACCOUNT_TOKEN;
213
+ $port = PORT;
214
+
215
+ $data = array(
216
+ 'user_login' => $user_login,
217
+ 'api_key' => $api_key,
218
+ 'sub_account_email' => $sub_account_email
219
+ );
220
+
221
+ $xml_return = trim($this->_httpRequest($domain, $path, $port, $data));
222
+ /* $xml_return = '<?xml version="1.0" encoding="UTF-8"?>
223
+ <octopush>
224
+ <token>F76C90C4F269289575363AE34BF6E399</token>
225
+ </octopush>'; */
226
+ libxml_use_internal_errors(true);
227
+ if (($xml = simplexml_load_string($xml_return)) !== false)
228
+ {
229
+ $res = (array) $xml->xpath('/octopush');
230
+ $tt = ((array) $res[0]);
231
+ if (isset($tt['error_code']) && $tt['error_code'] !== '000')
232
+ return 'An error ' . $tt['error_code'] . ' has occured.';
233
+
234
+ if (!isset($tt['token']))
235
+ return 'An error has occured.';
236
+ $token = $tt['token'];
237
+ }
238
+ else
239
+ {
240
+ return 'An error has occured.';
241
+ }
242
+
243
+ /* Now, the token is ready, we can ask for the transfer to be done */
244
+
245
+ $domain = DOMAIN;
246
+ $path = PATH_CREDIT_SUB_ACCOUNT;
247
+ $port = PORT;
248
+
249
+ /* We check that the type of the sms belong to the usual values */
250
+ if ($sms_type != 'FR' && $sms_type != 'XXX')
251
+ {
252
+ $sms_type = 'FR';
253
+ }
254
+
255
+ $data = array(
256
+ 'user_login' => $user_login,
257
+ 'api_key' => $api_key,
258
+ 'sub_account_email' => $sub_account_email,
259
+ 'sms_number' => $sms_amount,
260
+ 'sms_type' => $sms_type,
261
+ 'token' => $token
262
+ );
263
+
264
+ $xml_return = trim($this->_httpRequest($domain, $path, $port, $data));
265
+ return $xml_return;
266
+ }
267
+
268
+ public function getBalance()
269
+ {
270
+ $domain = DOMAIN;
271
+ $path = PATH_BALANCE;
272
+ $port = PORT;
273
+
274
+ $data = array(
275
+ 'user_login' => $this->user_login,
276
+ 'api_key' => $this->api_key
277
+ );
278
+
279
+ return trim($this->_httpRequest($domain, $path, $port, $data));
280
+ }
281
+
282
+ public function set_user_lang($lang) {
283
+ $this->user_lang = $lang;
284
+ }
285
+
286
+ public function getNews()
287
+ {
288
+ $domain = DOMAIN;
289
+ $path = PATH_NEWS;
290
+ $port = PORT;
291
+
292
+ $data = array(
293
+ 'lang' => $this->user_lang,
294
+ 'channel' => CHANNEL
295
+ );
296
+
297
+ return trim($this->_httpRequest($domain, $path, $port, $data));
298
+
299
+ }
300
+
301
+ private function _get_request_sha1_string($request_keys, $data)
302
+ {
303
+ $A_char_to_field = array(
304
+ 'T' => 'sms_text',
305
+ 'R' => 'sms_recipients',
306
+ 'M' => 'sms_mode',
307
+ 'Y' => 'sms_type',
308
+ 'S' => 'sms_sender',
309
+ 'D' => 'sms_date',
310
+ 'a' => 'recipients_first_names',
311
+ 'b' => 'recipients_last_names',
312
+ 'c' => 'sms_fields_1',
313
+ 'd' => 'sms_fields_2',
314
+ 'e' => 'sms_fields_3',
315
+ 'W' => 'with_replies',
316
+ 'N' => 'transactional',
317
+ 'Q' => 'request_id'
318
+ );
319
+ $request_string = '';
320
+ for ($i = 0, $n = strlen($this->request_keys); $i < $n; $i++)
321
+ {
322
+ $char = $this->request_keys[$i];
323
+
324
+ if (!isset($A_char_to_field[$char]) || !isset($data[$A_char_to_field[$char]]))
325
+ continue;
326
+ $request_string .= $data[$A_char_to_field[$char]];
327
+ }
328
+ $request_sha1 = sha1($request_string);
329
+ return $request_sha1;
330
+ }
331
+
332
+ private function _httpRequest($domain, $path, $port, $A_fields = array()) {
333
+ Mage::log("$domain, $path, $port,A_fields:".json_encode($A_fields), Zend_Log::DEBUG,"octopushsms.log");
334
+ $ssl = $domain . $path;
335
+ @set_time_limit(0);
336
+ $qs = array();
337
+ foreach ($A_fields as $k => $v)
338
+ {
339
+ $qs[] = $k . '=' . urlencode($v);
340
+ }
341
+
342
+ $request = join('&', $qs);
343
+
344
+ Mage::log("Request:".substr($domain, _CUT_) . $path, Zend_Log::DEBUG);
345
+
346
+ if (function_exists('curl_init') AND $ch = curl_init(substr($domain, _CUT_) . $path))
347
+ {
348
+ curl_setopt($ch, CURLOPT_POST, true);
349
+ curl_setopt($ch, CURLOPT_PORT, $port);
350
+
351
+ curl_setopt($ch, CURLOPT_POSTFIELDS, $request);
352
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
353
+ curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
354
+
355
+ $result = curl_exec($ch);
356
+ curl_close($ch);
357
+
358
+ return $result;
359
+ }
360
+ else if (ini_get('allow_url_fopen'))
361
+ {
362
+ $fp = fsockopen(substr($domain, _CUT_), $port, $errno, $errstr, 100);
363
+ if (!$fp)
364
+ {
365
+ echo 'Unable to connect to host. Try again later.';
366
+ return null;
367
+ }
368
+ $header = "POST " . $path . " HTTP/1.1\r\n";
369
+ $header .= 'Host: ' . substr($domain, _CUT_) . "\r\n";
370
+ $header .= "Accept: text\r\n";
371
+ $header .= "User-Agent: Octopush\r\n";
372
+ $header .= "Content-Type: application/x-www-form-urlencoded\r\n";
373
+ $header .= "Content-Length: " . strlen($request) . "\r\n";
374
+ $header .= "Connection: close\r\n\r\n";
375
+ $header .= "{$request}\r\n\r\n";
376
+
377
+ fputs($fp, $header);
378
+ $result = '';
379
+ while (!feof($fp))
380
+ $result .= fgets($fp, 1024);
381
+ fclose($fp);
382
+
383
+ $result = substr($result, strpos($result, "\r\n\r\n") + 4);
384
+ return $result;
385
+ }
386
+ else
387
+ {
388
+ die('Server does not support HTTP(S) requests.');
389
+ }
390
+ return $response;
391
+ }
392
+
393
+ public function set_user_login($user_login)
394
+ {
395
+ $this->user_login = $user_login;
396
+ }
397
+
398
+ public function set_api_key($api_key)
399
+ {
400
+ $this->api_key = $api_key;
401
+ }
402
+
403
+ public function set_sms_text($sms_text)
404
+ {
405
+ $this->sms_text = $sms_text;
406
+ }
407
+
408
+ public function set_sms_type($sms_type)
409
+ {
410
+ $this->sms_type = $sms_type;
411
+ }
412
+
413
+ public function set_sms_recipients($sms_recipients)
414
+ {
415
+ $this->sms_recipients = $sms_recipients;
416
+ }
417
+
418
+ public function set_recipients_first_names($first_names)
419
+ {
420
+ $this->recipients_first_names = $first_names;
421
+ }
422
+
423
+ public function set_recipients_last_names($last_names)
424
+ {
425
+ $this->recipients_last_names = $last_names;
426
+ }
427
+
428
+ public function set_sms_fields_1($sms_fields_1)
429
+ {
430
+ $this->sms_fields_1 = $sms_fields_1;
431
+ }
432
+
433
+ public function set_sms_fields_2($sms_fields_2)
434
+ {
435
+ $this->sms_fields_2 = $sms_fields_2;
436
+ }
437
+
438
+ public function set_sms_fields_3($sms_fields_3)
439
+ {
440
+ $this->sms_fields_3 = $sms_fields_3;
441
+ }
442
+
443
+ public function set_sms_mode($sms_mode)
444
+ {
445
+ $this->sms_mode = $sms_mode;
446
+ }
447
+
448
+ public function set_sms_sender($sms_sender)
449
+ {
450
+ $this->sms_sender = $sms_sender;
451
+ }
452
+
453
+ public function set_date($y, $m, $d, $h, $i)
454
+ {
455
+ $this->sms_y = intval($y);
456
+ $this->sms_d = intval($d);
457
+ $this->sms_m = intval($m);
458
+ $this->sms_h = intval($h);
459
+ $this->sms_i = intval($i);
460
+
461
+ $this->sending_date = mktime($this->sms_h, $this->sms_i, 0, $this->sms_m, $this->sms_d);
462
+ }
463
+
464
+ public function set_simulation_mode()
465
+ {
466
+ $this->request_mode = SIMULATION;
467
+ }
468
+
469
+ public function set_sms_ticket($sms_ticket)
470
+ {
471
+ $this->sms_ticket = $sms_ticket;
472
+ }
473
+
474
+ public function set_sms_request_id($request_id)
475
+ {
476
+ $this->request_id = preg_replace('`[^0-9a-zA-Z]*`', '', $request_id);
477
+ }
478
+
479
+ /*
480
+ * Notify Octopush plateform that you want to recieve the answers that your recipients will send back to your sending(s)
481
+ */
482
+
483
+ public function set_option_with_replies($with_replies)
484
+ {
485
+ if (!isset($with_replies) || intval($with_replies) !== 1)
486
+ {
487
+ $this->with_replies = 0;
488
+ }
489
+ else
490
+ {
491
+ $this->with_replies = 1;
492
+ }
493
+ }
494
+
495
+ /*
496
+ * Notify Octopush that you are making a transactional sending.
497
+ * With this option, sending marketing SMS is strongly forbidden, and may make your account blocked in case of abuses.
498
+ * DO NOT USE this option if you are not sure to understand what a transactional SMS is.
499
+ */
500
+
501
+ public function set_option_transactional($transactional)
502
+ {
503
+ if (!isset($transactional) || intval($transactional) !== 1)
504
+ {
505
+ $this->transactional = 0;
506
+ }
507
+ else
508
+ {
509
+ $this->transactional = 1;
510
+ }
511
+ }
512
+
513
+ /*
514
+ * Use a MSISDN number.
515
+ */
516
+
517
+ public function set_sender_is_msisdn($msisdn_sender)
518
+ {
519
+ $this->msisdn_sender = $msisdn_sender;
520
+ }
521
+
522
+ public function set_request_keys($request_keys)
523
+ {
524
+ $this->request_keys = $request_keys;
525
+ }
526
+
527
+ public function set_user_batch_id($user_batch_id)
528
+ {
529
+ $this->user_batch_id = preg_replace('`[^0-9a-zA-Z]*`', '', $user_batch_id);
530
+ }
531
+
532
+ /*
533
+ * Finish the transmission of trames and allow platform to build campaign from package.
534
+ */
535
+
536
+ public function set_finished($finished)
537
+ {
538
+ if (intval($finished) === 1)
539
+ $this->finished = 1;
540
+ else
541
+ $this->finished = 0;
542
+ }
543
+
544
+ /*
545
+ * get the "status", "send" or "delete" a campaign.
546
+ */
547
+
548
+ public function set_action($action)
549
+ {
550
+ $this->action = $action;
551
+ }
552
+
553
+ }
554
+
555
+ ?>
app/code/local/Octopush/OctopushSms/Helper/API_SMS_PHP_Octopush/sms_batch.php ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ // Exemple de envoi instantane de SMS
3
+
4
+ require('sms.inc.php');
5
+
6
+ $user_login = '************@********';
7
+ $api_key = '****************';
8
+
9
+ $user_batch_id = '1423514025';
10
+ $action = 'status';
11
+
12
+ $sms = new SMS();
13
+ $sms->set_user_login($user_login);
14
+ $sms->set_api_key($api_key);
15
+ $sms->set_user_batch_id($user_batch_id);
16
+
17
+ // $sms->set_date(2013, 4, 25, 15, 12); // En cas d'envoi diffÈrÈ.
18
+ $xml = $sms->SMSBatchAction($action);
19
+
20
+ //echo $xml;
21
+ //echo '<br />';
22
+ echo '<textarea style="width:600px;height:600px;">' . $xml . '</textarea>';
23
+ ?>
app/code/local/Octopush/OctopushSms/Helper/API_SMS_PHP_Octopush/sms_parts.php ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ // Exemple de envoi instantane de SMS
3
+
4
+ require('sms.inc.php');
5
+
6
+ $user_login = '************@********';
7
+ $api_key = '****************';
8
+
9
+ $sms_recipients_1 = array('0600000000');
10
+ $sms_recipients_2 = array('0600000001');
11
+ $sms_recipients_3 = array('0600000002');
12
+ $sms_recipients_n = array('0600000003');
13
+ $sms_text = 'test de campagne compositée avec un long sms. test de campagne composite avec un long sms. test de campagne composite avec un long sms. test de campagne composite avec un long sms. test de campagne composite avec un long sms. STOP au XXXXX';
14
+
15
+ $sms_type = SMS_PREMIUM; // ou encore SMS_STANDARD,SMS_WORLD
16
+ $sms_mode = INSTANTANE; // ou encore DIFFERE
17
+ $sms_sender = 'XXXXX';
18
+ $user_batch_id = '5222erz98tre3ffe' . rand(1, 10000);
19
+ echo 'user_batch_id created : ' . $user_batch_id . '<br />';
20
+
21
+ $sms = new SMS();
22
+
23
+ $sms->set_user_login($user_login);
24
+ $sms->set_api_key($api_key);
25
+ $sms->set_sms_mode($sms_mode);
26
+ $sms->set_sms_text($sms_text);
27
+ $sms->set_sms_recipients($sms_recipients_1);
28
+ $sms->set_sms_type($sms_type);
29
+ $sms->set_sms_sender($sms_sender);
30
+ $sms->set_user_batch_id($user_batch_id);
31
+ $sms->set_finished(0);
32
+
33
+ $xml1 = $sms->sendSMSParts();
34
+ $sms->set_sms_recipients($sms_recipients_2);
35
+ $xml2 = $sms->sendSMSParts();
36
+ $sms->set_sms_recipients($sms_recipients_3);
37
+ $xml3 = $sms->sendSMSParts();
38
+ $sms->set_sms_recipients($sms_recipients_n);
39
+ $sms->set_finished(1);
40
+ $xml4 = $sms->sendSMSParts();
41
+
42
+ //echo $xml4;
43
+ //echo '<br />';
44
+ echo '<textarea style="width:600px;height:600px;">' . $xml4 . '</textarea>';
45
+ ?>
app/code/local/Octopush/OctopushSms/Helper/Campaign.php ADDED
@@ -0,0 +1,251 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Octopush_OctopushSms_Helper_Campaign extends Mage_Core_Helper_Abstract {
4
+
5
+ public static function get_status_array() {
6
+ return array(
7
+ 0 => __('In construction'),
8
+ 1 => __('Transfer in progess'),
9
+ 2 => __('Waiting for validation'),
10
+ 3 => __('Sent'),
11
+ 4 => __('Canceled'),
12
+ 5 => __('Error'),
13
+ );
14
+ }
15
+
16
+ public static function get_status($status) {
17
+ $status_array = self::get_status_array();
18
+ if (array_key_exists($status, $status_array)) {
19
+ return $status_array[$status];
20
+ }
21
+ }
22
+
23
+ /**
24
+ * Calculate the totals and setthe status
25
+ */
26
+ public static function compute_campaign($campaign, $status = 0) {
27
+ $resource = Mage::getSingleton('core/resource');
28
+ //TODO remove $tableCampaign = $resource->getTableName('octopushsms/campaign');
29
+ //$tableRecipient = $resource->getTableName('octopushsms/recipient');
30
+ $readConnection = $resource->getConnection('core_read');
31
+
32
+ $query = 'SELECT COUNT(id_sendsms_recipient) AS nb_recipients, SUM(nb_sms) AS nb_sms, SUM(price) AS price
33
+ FROM `' . $resource->getTableName('octopushsms/recipient') . '`
34
+ WHERE `id_sendsms_campaign`=' . (int) $campaign->getData('id_sendsms_campaign') . '
35
+ AND `status`=0';
36
+ /**
37
+ * Execute the query and store the results in $results
38
+ */
39
+ $results = $readConnection->fetchAll($query);
40
+ $result = $results[0];
41
+ $campaign->setData('nb_recipients', (int) $result['nb_recipients']);
42
+ $campaign->setData('nb_sms', (int) $result['nb_sms']);
43
+ $campaign->setData('price', (float) $result['price']);
44
+ $campaign->setData('status', $status);
45
+ $campaign->save();
46
+ }
47
+
48
+ /**
49
+ * Get the nbr of french recipients (=phone begin by +33) of the campaign
50
+ * @param type $campaign
51
+ * @return type
52
+ */
53
+ public static function nbr_french_recipient($campaign) {
54
+ $resource = Mage::getSingleton('core/resource');
55
+ $readConnection = $resource->getConnection('core_read');
56
+ $query = "
57
+ SELECT count(*) as count
58
+ FROM " . $resource->getTableName('octopushsms/recipient') . "
59
+ WHERE id_sendsms_campaign=" . (int) $campaign->getData('id_sendsms_campaign') . "
60
+ AND phone like '+33%' ";
61
+ /**
62
+ * Execute the query
63
+ */
64
+ $results = $readConnection->fetchAll($query);
65
+ return $results[0]['count'];
66
+ }
67
+
68
+ public static function duplicate($campaign) {
69
+ $old_id = $campaign->getData('id_sendsms_campaign');
70
+ $newCampaign = Mage::getModel('octopushsms/campaign');
71
+ $newCampaign->addData($campaign->getData());
72
+ $newCampaign->setData('id_sendsms_campaign', null);
73
+ $newCampaign->setData('status', 0);
74
+ $newCampaign->setData('nb_recipients', 0);
75
+ $newCampaign->setData('nb_sms', 0);
76
+ $newCampaign->setData('price', 0);
77
+ $newCampaign->setData('ticket', (string) time());
78
+ $newCampaign->setData('date_transmitted', NULL);
79
+ $newCampaign->setData('date_validation', NULL);
80
+ $newCampaign->setData('date_add', NULL);
81
+ $newCampaign->setData('date_upd', NULL);
82
+ $newCampaign->save();
83
+
84
+ //duplicate the recipients
85
+ $resource = Mage::getSingleton('core/resource');
86
+ $writeConnection = $resource->getConnection('core_write');
87
+ $query = 'INSERT INTO `' . $resource->getTableName('octopushsms/recipient') . '` (`id_sendsms_campaign`, `id_customer`, `firstname`, `lastname`, `phone`, `iso_country`, `transmitted`, `price`, `nb_sms`, `status`, `ticket`, `date_add`, `date_upd`)
88
+ SELECT ' . $newCampaign->getData('id_sendsms_campaign') . ', `id_customer`, `firstname`, `lastname`, `phone`, `iso_country`, 0, 0, 0, 0, NULL, NOW(), NOW() FROM `' . $resource->getTableName('octopushsms/recipient') . '` WHERE `id_sendsms_campaign`=' . $old_id;
89
+ $writeConnection->query($query);
90
+ self::compute_campaign($newCampaign);
91
+ return $newCampaign;
92
+ /* TODO remove $nb_recipients = $wpdb->get_var('SELECT count(*) AS total FROM `' . $wpdb->prefix . 'octopushsms_recipient` WHERE `id_sendsms_campaign`=' . $indexController->_campaign->id_sendsms_campaign);
93
+ $indexController->_campaign->nb_recipients = $nb_recipients;
94
+ $indexController->_campaign->save(); */
95
+ }
96
+
97
+ /**
98
+ * Stat of transfer in progress campaign
99
+ * @param type $campaign
100
+ */
101
+ public static function get_recipient_to_transmit($campaign) {
102
+ $resource = Mage::getSingleton('core/resource');
103
+ $readConnection = $resource->getConnection('core_read');
104
+ $query = "SELECT SQL_CALC_FOUND_ROWS *
105
+ FROM `" . $resource->getTableName('octopushsms/recipient') . "`
106
+ WHERE id_sendsms_campaign=" . (int) $campaign->getData('id_sendsms_campaign') . "
107
+ AND transmitted = 0
108
+ ORDER BY id_sendsms_recipient ASC
109
+ LIMIT 200";
110
+ /**
111
+ * Execute the query
112
+ */
113
+ $results = $readConnection->fetchAll($query);
114
+ return $results;
115
+ }
116
+
117
+ public static function get_total_nbr_of_recipient_to_transmit() {
118
+ $resource = Mage::getSingleton('core/resource');
119
+ $readConnection = $resource->getConnection('core_read');
120
+ $query = "SELECT FOUND_ROWS() AS NbRows";
121
+ /**
122
+ * Execute the query
123
+ */
124
+ $results = $readConnection->fetchAll($query);
125
+ return $results[0]['NbRows'];
126
+ }
127
+
128
+ public static function get_recipients_from_query($indexController, $campaignModel, $count = true) {
129
+ //date format (if ingnore years is set or not)
130
+ $birthday_format = $register_format = $lastivisit_format = '%Y-%m-%d';
131
+ if ($indexController->getRequest()->getParam('sendsms_query_birthday_years'))
132
+ $birthday_format = '%m-%d';
133
+ if ($indexController->getRequest()->getParam('sendsms_query_registered_years'))
134
+ $register_format = '%m-%d';
135
+ if ($indexController->getRequest()->getParam('sendsms_query_connected_years'))
136
+ $lastivisit_format = '%m-%d';
137
+
138
+ $collection = Mage::getResourceModel('customer/customer_collection')
139
+ ->addNameToSelect()
140
+ ->addAttributeToSelect('email')
141
+ ->addAttributeToSelect('created_at')
142
+ ->addAttributeToSelect('group_id')
143
+ //->addExpressionAttributeToSelect('created_at_f', "date_format({{created_at}},'$register_format')", "created_at")
144
+ //->addExpressionAttributeToSelect('login_at_f', "date_format({{login_at}},'$lastivisit_format')", "login_at")
145
+ ->joinAttribute('billing_postcode', 'customer_address/postcode', 'default_billing', null, 'left')
146
+ ->joinAttribute('billing_city', 'customer_address/city', 'default_billing', null, 'left')
147
+ ->joinAttribute('billing_telephone', 'customer_address/telephone', 'default_billing', null, 'inner')
148
+ ->joinAttribute('billing_region', 'customer_address/region', 'default_billing', null, 'left')
149
+ ->joinAttribute('billing_country_id', 'customer_address/country_id', 'default_billing', null, 'left');
150
+
151
+ if ($indexController->getRequest()->getParam('sendsms_query_group') && $indexController->getRequest()->getParam('sendsms_query_group') != '*') {
152
+ $collection->addAttributeToFilter('group_id', $indexController->getRequest()->getParam('sendsms_query_group'));
153
+ }
154
+ if ($indexController->getRequest()->getParam('sendsms_query_shop') && $indexController->getRequest()->getParam('sendsms_query_shop') != '*') {
155
+ $collection->addAttributeToFilter('store_id', $indexController->getRequest()->getParam('sendsms_query_shop'));
156
+ }
157
+ if ($indexController->getRequest()->getParam('sendsms_query_country') && $indexController->getRequest()->getParam('sendsms_query_country') != '*') {
158
+ $collection->addAttributeToFilter('billing_country_id', $indexController->getRequest()->getParam('sendsms_query_country'));
159
+ }
160
+ if ($indexController->getRequest()->getParam('sendsms_query_newsletter') == '0') {
161
+ $collection->joinTable(Mage::getSingleton('core/resource')->getTableName('newsletter_subscriber'), 'customer_id=entity_id', array('subscriber_status' => 'subscriber_status'), null, 'left');
162
+ $collection->addAttributeToFilter(array(
163
+ array('attribute' => 'subscriber_status', 'eq' => $indexController->getRequest()->getParam('sendsms_query_newsletter')),
164
+ array('attribute' => 'subscriber_status', 'null' => true)
165
+ ));
166
+ }
167
+ if ($indexController->getRequest()->getParam('sendsms_query_newsletter') == '1') {
168
+ $collection->joinTable(Mage::getSingleton('core/resource')->getTableName('newsletter_subscriber'), 'customer_id=entity_id', array('subscriber_status' => 'subscriber_status'), null, 'left');
169
+ //$collection->addAttributeToFilter('subscriber_status', $indexController->getRequest()->getParam('sendsms_query_newsletter'));
170
+ $collection->addAttributeToFilter(array(
171
+ array('attribute' => 'subscriber_status', 'eq' => $indexController->getRequest()->getParam('sendsms_query_newsletter')),
172
+ array('attribute' => 'subscriber_status', 'is null')
173
+ ));
174
+ }
175
+
176
+ //created_at
177
+ if ($indexController->getRequest()->getParam('sendsms_query_registered_from') || $indexController->getRequest()->getParam('sendsms_query_registered_to')) {
178
+ if (!empty($indexController->getRequest()->getParam('sendsms_query_registered_from'))) {
179
+ $from = $indexController->getRequest()->getParam('sendsms_query_registered_from');
180
+ $collection->getSelect()->where("date_format(created_at,'$register_format') >= date_format('$from','$register_format')");
181
+ }
182
+ if (!empty($indexController->getRequest()->getParam('sendsms_query_registered_to'))) {
183
+ $to = $indexController->getRequest()->getParam('sendsms_query_registered_to');
184
+ $collection->getSelect()->where("date_format(created_at,'$register_format') <= date_format('$to','$register_format')");
185
+ }
186
+ }
187
+
188
+ //log
189
+ if ($indexController->getRequest()->getParam('sendsms_query_connected_from') || $indexController->getRequest()->getParam('sendsms_query_connected_to')) {
190
+ $collection->joinTable(Mage::getSingleton('core/resource')->getTableName('log_customer'), 'customer_id=entity_id', array('login_at' => 'login_at'), null, 'left');
191
+
192
+ if ($indexController->getRequest()->getParam('sendsms_query_connected_from')) {
193
+ $from = $indexController->getRequest()->getParam('sendsms_query_connected_from');
194
+ /* $collection->addAttributeToFilter('login_at', array(
195
+ 'from' => $from,
196
+ 'date' => true, // specifies conversion of comparison values
197
+ )); */
198
+ $collection->getSelect()->where("date_format(login_at,'$lastivisit_format') >= date_format('$from','$lastivisit_format')");
199
+ }
200
+ if ($indexController->getRequest()->getParam('sendsms_query_connected_to')) {
201
+ $to = $indexController->getRequest()->getParam('sendsms_query_connected_to');
202
+ /* $collection->addAttributeToFilter('login_at', array(
203
+ 'to' => $to,
204
+ 'date' => true, // specifies conversion of comparison values
205
+ )); */
206
+ $collection->getSelect()->where("date_format(login_at,'$lastivisit_format') <= date_format('$to','$lastivisit_format')");
207
+ }
208
+ }
209
+ //birth
210
+ if ($indexController->getRequest()->getParam('sendsms_query_birthday_from') || $indexController->getRequest()->getParam('sendsms_query_birthday_to')) {
211
+ $collection->joinAttribute('dob', 'customer/dob', 'entity_id', null, 'left');
212
+ if ($indexController->getRequest()->getParam('sendsms_query_birthday_from')) {
213
+ $from = $indexController->getRequest()->getParam('sendsms_query_birthday_from');
214
+ $collection->getSelect()->where("date_format(at_dob.value,'$birthday_format') >= date_format('$from','$birthday_format')");
215
+ }
216
+ if ($indexController->getRequest()->getParam('sendsms_query_birthday_to')) {
217
+ $to = $indexController->getRequest()->getParam('sendsms_query_birthday_to');
218
+ $collection->getSelect()->where("date_format(at_dob.value,'$birthday_format') <= date_format('$to','$birthday_format')");
219
+ }
220
+ }
221
+
222
+ //orders
223
+ if ($indexController->getRequest()->getParam('sendsms_query_orders_from')
224
+ || $indexController->getRequest()->getParam('sendsms_query_orders_to')
225
+ || $indexController->getRequest()->getParam('sendsms_query_orders_none')) {
226
+ //$collection->addAttributeToSelect('order_id');
227
+ $collection->joinTable(Mage::getSingleton('core/resource')->getTableName('sales_flat_order'), 'customer_id=entity_id', array('order_id' => 'entity_id'), null, 'left');
228
+ $collection->addExpressionAttributeToSelect('order_nbr', 'COUNT({{entity_id}})', 'entity_id');
229
+ $collection->groupByAttribute('entity_id');
230
+ //$collection->getSelect()->select("COUNT(mag_sales_flat_order.customer_id) AS `order_nbr`");
231
+
232
+ if ($indexController->getRequest()->getParam('sendsms_query_orders_from')) {
233
+ $collection->getSelect()->having('COUNT(mag_sales_flat_order.customer_id) >= ' . $indexController->getRequest()->getParam('sendsms_query_orders_from'));
234
+ //$collection->addAttributeToFilter('order_nbr', array('gteq'=>$indexController->getRequest()->getParam('sendsms_query_orders_from')));
235
+ }
236
+ if ($indexController->getRequest()->getParam('sendsms_query_orders_to')) {
237
+ $collection->getSelect()->having('COUNT(mag_sales_flat_order.customer_id) <= ' . $indexController->getRequest()->getParam('sendsms_query_orders_to'));
238
+ }
239
+ if ($indexController->getRequest()->getParam('sendsms_query_orders_none')) {
240
+ $collection->getSelect()->having('COUNT(mag_sales_flat_order.customer_id) = 0 or order_nbr is null');
241
+ }
242
+ }
243
+
244
+ if ($count) {
245
+ return count($collection);
246
+ } else {
247
+ return $collection;
248
+ }
249
+ }
250
+
251
+ }
app/code/local/Octopush/OctopushSms/Helper/Customer.php ADDED
@@ -0,0 +1,63 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ * To change this license header, choose License Headers in Project Properties.
5
+ * To change this template file, choose Tools | Templates
6
+ * and open the template in the editor.
7
+ */
8
+
9
+ class Octopush_OctopushSms_Helper_Customer extends Mage_Core_Helper_Abstract {
10
+
11
+ /**
12
+ * Find customer id where $q is in firstname or lastname or phone or entity_id.
13
+ * Telephone has to be not null.
14
+ * @return the list of customer id corresponding to the search
15
+ */
16
+ public function find_customer_id($s) {
17
+ $collection = Mage::getResourceModel('customer/customer_collection')
18
+ ->addNameToSelect()
19
+ ->addAttributeToSelect('email')
20
+ ->addAttributeToSelect('created_at')
21
+ ->addAttributeToSelect('group_id')
22
+ ->addAttributeToFilter('entity_id', $s)
23
+ ->joinAttribute('billing_postcode', 'customer_address/postcode', 'default_billing', null, 'left')
24
+ ->joinAttribute('billing_city', 'customer_address/city', 'default_billing', null, 'left')
25
+ ->joinAttribute('billing_telephone', 'customer_address/telephone', 'default_billing', null, 'left')
26
+ ->joinAttribute('billing_region', 'customer_address/region', 'default_billing', null, 'left')
27
+ ->joinAttribute('billing_country_id', 'customer_address/country_id', 'default_billing', null, 'left')
28
+ ->setPageSize('50');
29
+ return $collection;
30
+ }
31
+
32
+ /**
33
+ * Find customer id where $q is in firstname or lastname or phone or entity_id.
34
+ * Telephone has to be not null.
35
+ * @return the list of customer id corresponding to the search
36
+ */
37
+ public function find_customer($s) {
38
+ $collection = Mage::getResourceModel('customer/customer_collection')
39
+ ->addNameToSelect()
40
+ ->addAttributeToSelect('email')
41
+ ->addAttributeToSelect('created_at')
42
+ ->addAttributeToSelect('group_id')
43
+ ->joinAttribute('billing_telephone', 'customer_address/telephone', 'default_billing', null, 'left')
44
+ ->joinAttribute('billing_country_id', 'customer_address/country_id', 'default_billing', null, 'left')
45
+ ->addAttributeToFilter(array(
46
+ array('attribute' => 'billing_telephone', 'like' => '%' . $s . '%'),
47
+ array('attribute' => 'entity_id', 'like' => '%' . $s . '%'),
48
+ array('attribute' => 'firstname', 'like' => '%' . $s . '%'),
49
+ array('attribute' => 'lastname', 'like' => '%' . $s . '%'),
50
+
51
+ ))
52
+ ->setPageSize('50');
53
+ return $collection;
54
+ }
55
+
56
+ public function find_customer_by_email($email) {
57
+ $customer = Mage::getModel("customer/customer");
58
+ $customer->setWebsiteId(Mage::app()->getStore()->getWebsiteId());
59
+ $customer->loadByEmail($email);
60
+ return $customer;
61
+ }
62
+
63
+ }
app/code/local/Octopush/OctopushSms/Helper/Data.php ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Octopush_OctopushSms_Helper_Data extends Mage_Core_Helper_Abstract
4
+ {
5
+
6
+ }
7
+
app/code/local/Octopush/OctopushSms/Helper/Message.php ADDED
@@ -0,0 +1,696 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Octopush_OctopushSms_Helper_Message extends Mage_Core_Helper_Abstract {
4
+
5
+ /**
6
+ * Admin messages with their title
7
+ */
8
+ public $admin_config;
9
+ public $customer_config;
10
+
11
+ /**
12
+ * Initialize the class and set its properties.
13
+ *
14
+ * @since 1.0.0
15
+ * @var string $octopush_sms The name of this plugin.
16
+ * @var string $version The version of this plugin.
17
+ */
18
+ public function __construct() {
19
+ //initialisation of possible admin message
20
+ $this->admin_config = array(
21
+ 'action_create_account' => __('Create an account'), //don't suppress
22
+ 'action_send_message' => __('Send Message'),
23
+ 'action_validate_order' => __('Validate Order'),
24
+ //'action_order_return' => __('Order return'),
25
+ 'action_update_quantity' => __('Stock notification'),
26
+ 'action_admin_alert' => __('Admin alert'),
27
+ 'action_daily_report' => __('Daily report', 'octopush-sms')
28
+ );
29
+
30
+ $this->customer_config = array(
31
+ 'action_create_account' => __('Create an account'),
32
+ 'action_password_renew' => __('Send SMS when customer has lost his password'),
33
+ 'action_customer_alert' => __('Send SMS when product is available'),
34
+ 'action_send_message' => __('Send Message'),
35
+ 'action_validate_order' => __('Validate Order'),
36
+ 'action_admin_orders_tracking_number_update' => __('Update tracking number order'),
37
+ 'action_order_status_update' => __('Status update', 'octopush-sms'));
38
+ }
39
+
40
+ /**
41
+ * Get the key of a "hook".
42
+ *
43
+ * @param type $hookId
44
+ * @param type $b_admin
45
+ * @param type $params
46
+ * @return type
47
+ */
48
+ public function _get_hook_key($message) {
49
+ return $message->getData('id_message') . '[message]';
50
+ }
51
+
52
+ /**
53
+ * Return the key of isvalid for this "hook".
54
+ *
55
+ * @param type $hookId
56
+ * @param type $b_admin
57
+ * @param type $params
58
+ * @return type
59
+ */
60
+ public function _get_isactive_hook_key($message) {
61
+ return $message->getData('id_message') . '[isactive]';
62
+ }
63
+
64
+ /**
65
+ * Get values for specific hook: action_creat_account
66
+ * This function returns the values to be replace in the sms send for this hook and the recipients list.
67
+ * @param type $bSimu if true, return dummy values for an example, if false give the values in function of the parameters given in array params
68
+ * @param type $b_admin il this is for admin or for customer
69
+ * @return array values to be replaced in the sms send.
70
+ */
71
+ private function _get_action_create_account_values($bSimu = false, $b_admin = false, $params = null) {
72
+ if ($bSimu) {
73
+ $test_values = array(
74
+ '{firstname}' => 'John',
75
+ '{lastname}' => 'Doe'
76
+ );
77
+ $values = array_merge($test_values, self::_getBaseValues());
78
+ } else {
79
+ $api = Mage::helper('octopushsms/API');
80
+ //get customer id
81
+ $customer_id = $params['customer_id'];
82
+ $helperCustomer = Mage::Helper('octopushsms/customer');
83
+ $customer = $helperCustomer->find_customer_id($customer_id)->getFirstItem();
84
+ //set sender phone and recipient
85
+ $api->_set_phone($customer->getData('billing_telephone'), $customer->getData('billing_country_id'), $b_admin);
86
+
87
+ $store_id = $customer->getStoreID();
88
+ $store = Mage::getModel('core/store')->load($store_id);
89
+ $values = array(
90
+ '{firstname}' => $customer->getData('firstname'),
91
+ '{lastname}' => $customer->getData('lastname'),
92
+ '{shopname}' => $store->getName(),
93
+ '{shopurl}' => $store->getUrl(),
94
+ );
95
+ }
96
+ Mage::log('action_create_account - _get_action_create_account_values ' . print_r($values, true), Zend_Log::DEBUG);
97
+ return array_merge($values, self::_getBaseValues());
98
+ }
99
+
100
+ public function _get_action_admin_orders_tracking_number_update_values($bSimu = false, $b_admin = false, $params = null) {
101
+ if ($bSimu) {
102
+ $currency = Mage::app()->getDefaultStoreView()->getDefaultCurrencyCode();
103
+ $values = array(
104
+ '{firstname}' => 'John',
105
+ '{lastname}' => 'Doe',
106
+ '{order_id}' => '000001',
107
+ '{shipping_number}' => 'ABC001',
108
+ '{payment}' => 'Paypal',
109
+ '{total_paid}' => '100',
110
+ '{currency}' => $currency
111
+ );
112
+ } else {
113
+ $track = $params['track'];
114
+ if ($track) {
115
+ //load order
116
+ $order_id = $track->getData('order_id');
117
+ $order = Mage::getModel('sales/order')->load($order_id);
118
+
119
+ $billing = $order->getBillingAddress();
120
+ $this->_recipients = null;
121
+ $this->_phone = null;
122
+ //the send of this sms is optionnal. Verify that you can send it.
123
+ if (!$this->can_send_optional_sms($order_id, $b_admin)) {
124
+ return null;
125
+ }
126
+ $api = Mage::helper('octopushsms/API');
127
+ //set sender phone and recipient
128
+ $api->_set_phone($billing->getData('telephone'), $billing->getData('country_id'), $b_admin);
129
+ //get payment method
130
+ $payment_method = $order->getPayment()->getMethodInstance()->getTitle();
131
+ $values = array(
132
+ '{firstname}' => $billing->getData('firstname'),
133
+ '{lastname}' => $billing->getData('lastname'),
134
+ '{order_id}' => $order_id,
135
+ '{order_state}' => $order->getData('status'),
136
+ '{payment}' => $payment_method,
137
+ '{total_paid}' => $order->getGrandTotal(),
138
+ '{currency}' => $order->getBaseCurrencyCode(),
139
+ '{shipping_number}' => $track->getData('track_number'),
140
+ '{shipping_title}' => $track->getData('track_title'),
141
+ '{shipping_carrier_code}' => $track->getData('carrier_code'),
142
+ );
143
+ }
144
+ }
145
+ return array_merge($values, self::_getBaseValues());
146
+ }
147
+
148
+ /**
149
+ * Get values for specific hook: action_admin_alert
150
+ * This function returns the values to be replace in the sms send for this hook and the recipients list.
151
+ * @param boolean $bSimu if true, return dummy values for an example, if false give the values in function of the parameters given in array params
152
+ * @param boolean $b_admin
153
+ * @return array if not null, return values to be replace in the sms text otherwise if null no value is set and no message have to be send
154
+ */
155
+ public function _get_action_admin_alert_values($bSimu = false, $b_admin = false, $params = null) {
156
+ Mage::log('octopush-sms - _get_action_admin_alert_values - BEGIN', Zend_Log::DEBUG);
157
+ if ($bSimu) {
158
+ $values = array(
159
+ '{balance}' => number_format('10', 3, ',', ' '),
160
+ );
161
+ } else {
162
+ $api = Mage::helper('octopushsms/API');
163
+ $this->_phone = null;
164
+ //only for admin sms
165
+ if (!$b_admin) {
166
+ return null;
167
+ }
168
+ $api->_set_phone(null, null, true);
169
+ $values = array(
170
+ '{balance}' => number_format($params['balance'], 3, ',', ' '),
171
+ );
172
+ }
173
+ return array_merge($values, self::_getBaseValues());
174
+ }
175
+
176
+ public function _get_action_customer_alert_values($bSimu = false, $b_admin = false, $params = array()) {
177
+ if ($bSimu) {
178
+ $valuesPart = array(
179
+ '{firstname}' => 'John',
180
+ '{lastname}' => 'Doe',
181
+ '{product}' => 'Ipod Nano',
182
+ );
183
+ $values = array_merge($valuesPart, self::_getBaseValues());
184
+ } else {
185
+ if ($b_admin) {
186
+ $api->_set_phone(null, null, false);
187
+ return null;
188
+ }
189
+ $customer = $params['customer'];
190
+ $product = $params['product'];
191
+ $address=Mage::getModel('customer/address')->load($customer->getDefaultBilling());
192
+ $api = Mage::helper('octopushsms/API');
193
+ //set sender phone and recipient
194
+ Mage::log("la01", Zend_Log::DEBUG, "octopushsms.log");
195
+ $api->_set_phone($address->getTelephone(), $address->getCountryId(), false);
196
+
197
+ Mage::log("la02", Zend_Log::DEBUG, "octopushsms.log");
198
+
199
+ $store_id = $customer->getStoreID();
200
+ $store = Mage::getModel('core/store')->load($store_id);
201
+ Mage::log("la03", Zend_Log::DEBUG, "octopushsms.log");
202
+
203
+ $values = array(
204
+ '{firstname}' => $address->getData('firstname'),
205
+ '{lastname}' => $address->getData('lastname'),
206
+ '{shopname}' => $store->getName(),
207
+ '{shopurl}' => $store->getUrl(),
208
+ '{product}' => $product->getName(),
209
+ );
210
+ Mage::log("la04", Zend_Log::DEBUG, "octopushsms.log");
211
+ }
212
+ Mage::log("values:".print_r($values,true), Zend_Log::DEBUG, "octopushsms.log");
213
+
214
+ return $values;
215
+ }
216
+
217
+ function _get_action_order_status_update_values($bSimu = false, $b_admin = false, $params = array()) {
218
+ $currency = Mage::app()->getDefaultStoreView()->getDefaultCurrencyCode();
219
+ if ($bSimu) {
220
+ $values = array(
221
+ '{firstname}' => 'John',
222
+ '{lastname}' => 'Doe',
223
+ '{order_id}' => '000001',
224
+ '{order_state}' => 'xxx',
225
+ '{total_paid}' => '100',
226
+ '{currency}' => $currency
227
+ );
228
+ } else {
229
+ if ($b_admin) {
230
+ //not for admin
231
+ return null;
232
+ }
233
+ $order = $params['order'];
234
+ if ($order) {
235
+ $billing = $order->getBillingAddress();
236
+ $this->_recipients = null;
237
+ $this->_phone = null;
238
+ //the send of this sms is optionnal. Verify that you can send it.
239
+ if (!$this->can_send_optional_sms($order->getId(), $b_admin)) {
240
+ return null;
241
+ }
242
+ $api = Mage::helper('octopushsms/API');
243
+
244
+ //set sender phone and recipient
245
+ $api->_set_phone($billing->getData('telephone'), $billing->getData('country_id'), $b_admin);
246
+ //get payment method
247
+ $payment_method = $order->getPayment()->getMethodInstance()->getTitle();
248
+ $values = array(
249
+ '{firstname}' => $billing->getData('firstname'),
250
+ '{lastname}' => $billing->getData('lastname'),
251
+ '{order_id}' => $order->getId(),
252
+ '{order_state}' => $order->getData('status'),
253
+ '{payment}' => $payment_method,
254
+ '{total_paid}' => $order->getGrandTotal(),
255
+ '{currency}' => $order->getBaseCurrencyCode(),
256
+ );
257
+ } else {
258
+ return null;
259
+ }
260
+ }
261
+ return array_merge($values, self::_getBaseValues());
262
+ }
263
+
264
+ /**
265
+ * Get values for specific hook: action_validate_order
266
+ * This function returns the values to be replace in the sms send for this hook and the recipients list.
267
+ * @param type $bSimu if true, return dummy values for an example, if false give the values in function of the parameters given in array params
268
+ * @param type $b_admin
269
+ * @param type $params
270
+ * @return type
271
+ */
272
+ public function _get_action_validate_order_values($bSimu = false, $b_admin = false, $params = null) {
273
+ $currency = Mage::app()->getDefaultStoreView()->getDefaultCurrencyCode();
274
+ if ($bSimu) {
275
+ $values = array(
276
+ '{firstname}' => 'John',
277
+ '{lastname}' => 'Doe',
278
+ '{order_id}' => '000001',
279
+ '{payment}' => 'Paypal',
280
+ '{total_paid}' => '100',
281
+ '{currency}' => $currency,
282
+ );
283
+ } else {
284
+ //init values
285
+ $order_id = $params['order_id'];
286
+ $this->_recipients = null;
287
+ $this->_phone = null;
288
+ //the send of this sms is optionnal. Verify that you can send it.
289
+ if (!$this->can_send_optional_sms($params['order_id'], $b_admin)) {
290
+ return null;
291
+ }
292
+ $api = Mage::helper('octopushsms/API');
293
+
294
+ $order = Mage::getModel('sales/order')->load($order_id);
295
+ $address = $order->getBillingAddress();
296
+ $custName = $address->getFirstname();
297
+ //set sender phone and recipient
298
+ $api->_set_phone($address->getTelephone(), $address->getCountryId(), $b_admin);
299
+ //get payment method
300
+ $payment_method = $order->getPayment()->getMethodInstance()->getTitle();
301
+ $values = array(
302
+ '{firstname}' => $custName,
303
+ '{lastname}' => $order->getData('customer_lastname'),
304
+ '{order_id}' => $params['order_id'],
305
+ '{payment}' => $payment_method,
306
+ '{total_paid}' => $order->getGrandTotal(),
307
+ '{currency}' => $order->getBaseCurrencyCode(),
308
+ );
309
+ }
310
+ return array_merge($values, self::_getBaseValues());
311
+ }
312
+
313
+ /**
314
+ * Get values for specific hook: action_password_renew
315
+ * This function returns the values to be replace in the sms send for this hook and the recipients list.
316
+ * @param type $bSimu if true, return dummy values for an example, if false give the values in function of the parameters given in array params
317
+ * @param type $b_admin
318
+ * @param type $params
319
+ * @return array values to replace in sms text
320
+ */
321
+ public function _get_action_password_renew_values($bSimu = false, $b_admin = false, $params = array()) {
322
+ if ($bSimu) {
323
+ $valuesSimu = array(
324
+ '{firstname}' => 'John',
325
+ '{lastname}' => 'Doe',
326
+ //'{password}' => 'YourNewPass',
327
+ );
328
+ $values = array_merge($valuesSimu, self::_getBaseValues());
329
+ } else {
330
+ try {
331
+ $customer_id = $params['customer_id'];
332
+ $api = Mage::helper('octopushsms/API');
333
+ $helperCustomer = Mage::Helper('octopushsms/customer');
334
+ $customer = $helperCustomer->find_customer_id($customer_id);
335
+ //set sender phone and recipient
336
+ $api->_set_phone($customer->getData('billing_telephone'), $customer->getData('billing_country_id'), $b_admin);
337
+
338
+ $store_id = $customer->getStoreID();
339
+ $store = Mage::getModel('core/store')->load($store_id);
340
+ $values = array(
341
+ '{firstname}' => $customer->getData('firstname'),
342
+ '{lastname}' => $customer->getData('lastname'),
343
+ '{shopname}' => $store->getName(),
344
+ '{shopurl}' => $store->getUrl(),
345
+ );
346
+ } catch (Exception $e) {
347
+ Mage::log("Exception : " . $e->getMessage(), Zend_Log::ERR);
348
+ return null;
349
+ }
350
+ }
351
+ return $values;
352
+ }
353
+
354
+ //action_update_quantity
355
+ public function _get_action_update_quantity_values($bSimu = false, $b_admin = false, $params = array()) {
356
+ if ($bSimu) {
357
+ $values = array(
358
+ '{product_id}' => '000001', //id
359
+ '{product_ref}' => 'REF-001', //sku
360
+ '{product_name}' => 'Ipod Nano', //name
361
+ '{quantity}' => '2'
362
+ );
363
+ } else {
364
+ $api = Mage::helper('octopushsms/API');
365
+ $product = $params['product'];
366
+
367
+ $api->_set_phone(null, null, $b_admin);
368
+
369
+ $values = array(
370
+ '{product_id}' => $product->getId(),
371
+ '{product_ref}' => $product->getSku(),
372
+ '{product_name}' => $product->getName(),
373
+ '{quantity}' => intval(Mage::getModel('cataloginventory/stock_item')->loadByProduct($product->getProductId())->getQty()),
374
+ );
375
+ }
376
+ return array_merge($values, self::_getBaseValues());
377
+ }
378
+
379
+ private function _get_action_send_message_values($bSimu = false, $b_admin = false, $params = array()) {
380
+ if ($bSimu) {
381
+ $values = array(
382
+ '{contact_name}' => 'webmaster',
383
+ '{contact_mail}' => 'webmaster@woocommerce.com',
384
+ '{from}' => 'johndoe@gmail.com',
385
+ '{message}' => 'This is a message'
386
+ );
387
+ } else {
388
+ $api = Mage::helper('octopushsms/API');
389
+ $comment = $params['comment'];
390
+ if ($b_admin) {
391
+ $api->_set_phone(null, null, $b_admin);
392
+ } else {
393
+ //otherwise send to customer
394
+ if (isset($comment['telephone'])) {
395
+ $api->_set_phone($comment['telephone'], null, false);
396
+ }
397
+ }
398
+
399
+ $from_email = Mage::getStoreConfig('trans_email/ident_general/email'); //fetch sender email Admin
400
+ $from_name = Mage::getStoreConfig('trans_email/ident_general/name'); //fetch sender name Admin
401
+
402
+ $values = array(
403
+ '{contact_name}' => $from_name,
404
+ '{contact_mail}' => $from_email,
405
+ '{from}' => $comment['name'],
406
+ '{message}' => $comment['comment'],
407
+ );
408
+ }
409
+ return array_merge($values, self::_getBaseValues());
410
+ }
411
+
412
+ /**
413
+ * Get values for specific hook: action_daily_report
414
+ * This function returns the values to be replace in the sms send for this hook and the recipients list.
415
+ * @param boolean $bSimu if true, return dummy values for an example, if false give the values in function of the parameters given in array params
416
+ * @param boolean $b_admin
417
+ * @return array if not null, return values to be replace in the sms text otherwise if null no value is set and no message have to be send
418
+ */
419
+ function _get_action_daily_report_values($bSimu = false, $b_admin = false, $params = array()) {
420
+ $currency = Mage::app()->getDefaultStoreView()->getDefaultCurrencyCode();
421
+ if ($bSimu) {
422
+ $values = array(
423
+ '{date}' => date('Y-m-d'),
424
+ '{subs}' => '5', //subscription
425
+ '{visitors}' => '42', //visitor
426
+ //'{visits}' => '70',
427
+ '{orders}' => '8', //order of day
428
+ '{day_sales}' => "50 $currency", //sales of day
429
+ '{month_sales}' => "1000 $currency", //sales of month
430
+ );
431
+ } else {
432
+ $api = Mage::helper('octopushsms/API');
433
+ $statisticHelper = Mage::helper('octopushsms/statistic');
434
+ $values = array_merge(array('{date}' => date('Y-m-d')), $statisticHelper->getSales(), $statisticHelper->getVisits(), $statisticHelper->getSubscriptions());
435
+ $api->_set_phone(null, null, $b_admin);
436
+ }
437
+ return array_merge($values, self::_getBaseValues());
438
+ }
439
+
440
+ /**
441
+ * Get dummy value to generate message for test.
442
+ * The method to call is generated from the hook (not good)
443
+ * @param type $hook
444
+ * @return type
445
+ */
446
+ public function get_sms_values_for_test($hook) {
447
+ $values = array();
448
+ $method = '_get_' . $hook . '_values';
449
+ if (strstr($hook, 'action_order_status_update')) {
450
+ $method = '_get_action_order_status_update_values';
451
+ }
452
+ if (method_exists(__CLASS__, $method)) {
453
+ $values = self::$method(true);
454
+ }
455
+ return $values;
456
+ }
457
+
458
+ /**
459
+ * Update option corresponding to the hook
460
+ * @param type $hook
461
+ * @param type $b_admin
462
+ */
463
+ public function update_message_option($hook, $b_admin = false) {
464
+ //if is active
465
+ $hook_is_active = Octopush_Sms_Admin::get_instance()->_get_isactive_hook_key($hook, $b_admin);
466
+ if (array_key_exists($hook_is_active, $_POST)) {
467
+ $value = wc_clean($_POST[$hook_is_active]);
468
+ //save the option
469
+ update_option($hook_is_active, (int) $value);
470
+ } else {
471
+ update_option($hook_is_active, 0);
472
+ }
473
+ //message text
474
+ $hook_key = Octopush_Sms_Admin::get_instance()->_get_hook_key($hook, $b_admin);
475
+ if (array_key_exists($hook_key, $_POST)) {
476
+ $value = stripslashes($_POST[$hook_key]);
477
+ //save the option
478
+ update_option($hook_key, Octopush_Sms_API::get_instance()->replace_for_GSM7(trim($value)));
479
+ }
480
+ //specific case of 'action_order_status_update'
481
+ if ($hook == 'action_order_status_update') {
482
+ global $wp_post_statuses;
483
+ foreach ($wp_post_statuses as $key => $value) {
484
+ if (strstr($key, 'wc-')) {
485
+ $this->update_message_option($hook . "_$key", $b_admin);
486
+ }
487
+ }
488
+ }
489
+ }
490
+
491
+ public function is_active($message) {
492
+ //load message elementfrom database
493
+ /* TODO remove$message = Mage::getResourceModel('octpushsms/message_collection')
494
+ ->addFieldToFilter('hook_id', $bAdmin)
495
+ ->addFieldToFilter('bAdmin', $bAdmin)
496
+ ->getFirstItem(); */
497
+ return ($message && $message->getData('is_active'));
498
+ }
499
+
500
+ public function get_message($hook_id, $bAdmin) {
501
+ //load message elementfrom database
502
+ $collection = Mage::getResourceModel('octopushsms/message_collection')
503
+ ->addFieldToFilter('hook_id', $hook_id)
504
+ ->addFieldToFilter('bAdmin', $bAdmin);
505
+ if ($collection->getSize() > 0) {
506
+ return $collection->getFirstItem();
507
+ }
508
+ //create in database
509
+ $message = Mage::getModel('octopushsms/message');
510
+ $message->setData('hook_id', $hook_id);
511
+ $message->setData('bAdmin', $bAdmin);
512
+ $message->setData('message', $this->get_sms_default_text($hook_id, $bAdmin));
513
+ $message->save();
514
+
515
+ return $message;
516
+ }
517
+
518
+ private function _getBaseValues() {
519
+ $values = array(
520
+ '{shopname}' => Mage::app()->getStore()->getName(),
521
+ '{shopurl}' => Mage::app()->getStore()->getUrl(),
522
+ );
523
+ return $values;
524
+ }
525
+
526
+ public function get_sms_default_text_from_message($message) {
527
+ return $this->get_sms_default_text($message->getData('hook_id'), $message->getData('bAdmin'));
528
+ }
529
+
530
+ /**
531
+ * Return the default text
532
+ * @param type $hookId
533
+ */
534
+ public function get_sms_default_text($hook_key, $bAdmin) {
535
+ //$hook_key = $message->getData('hook_key');
536
+ //$bAdmin = $message->getData('bAdmin');
537
+ $defaultMessage = "";
538
+ $hookText = $hook_key;
539
+ if ($bAdmin) {
540
+ $hookText.="_admin";
541
+ }
542
+ switch ($hookText) {
543
+ case 'action_create_account_admin':
544
+ $defaultMessage = __("{firstname} {lastname} has just registered on {shopname}", 'octopush-sms');
545
+ break;
546
+ case 'action_send_message_admin' :
547
+ $defaultMessage = __("{from} has sent a message to{contact_name} ({contact_mail}) : {message}", 'octopush-sms');
548
+ break;
549
+ case 'action_validate_order_admin' :
550
+ $defaultMessage = __("New order from {firstname} {lastname}, id: {order_id}, paiement: {payment}, total: {total_paid} {currency}.", 'octopush-sms');
551
+ break;
552
+ case 'action_order_return_admin' :
553
+ $defaultMessage = __("Back order ({return_id}) done by the client {customer_id} about the order {order_id}. Reason : {message}", 'octopush-sms');
554
+ break;
555
+ case 'action_update_quantity_admin' :
556
+ $defaultMessage = __("This item is almost out of order, id: {product_id}, réf: {product_ref}, name: {product_name}, quantity: {quantity}", 'octopush-sms');
557
+ break;
558
+ case 'action_admin_alert_admin' :
559
+ $defaultMessage = __("Your SMS credit is almost empty. Your remaining balance is {balance} SMS available.", 'octopush-sms');
560
+ break;
561
+ case 'action_daily_report_admin' :
562
+ $defaultMessage = __("date: {date}, inscriptions: {subs}, orders: {orders}, sales: {day_sales}, for the month of: {month_sales}", 'octopush-sms');
563
+ break;
564
+ case 'action_create_account' :
565
+ $defaultMessage = __("{firstname} {lastname}, Welcome to {shopname} !", 'octopush-sms');
566
+ break;
567
+ case 'action_password_renew' :
568
+ $defaultMessage = __("{firstname} {lastname}, you reset your password to access to {shopname} , {shopurl}", 'octopush-sms');
569
+ break;
570
+ case 'action_customer_alert' :
571
+ $defaultMessage = __("{firstname} {lastname}, the item {product} is now available on {shopname} ({shopurl})", 'octopush-sms');
572
+ break;
573
+ case 'action_send_message' :
574
+ $defaultMessage = __("Thank you for your message. We will answer it very shortly. {shopname}", 'octopush-sms');
575
+ break;
576
+ case 'action_validate_order' :
577
+ $defaultMessage = __("{firstname} {lastname}, we do confirm your order {order_id}, of {total_paid} {currency}. Thank you. {shopname}", 'octopush-sms');
578
+ break;
579
+ case 'action_admin_orders_tracking_number_update' :
580
+ $defaultMessage = __("{firstname} {lastname}, your order {order_id} was delivered. Your shipping number is {shipping_number}. {shopname}", 'octopush-sms');
581
+ break;
582
+ default:
583
+ //specific case for action_order_status_update where the hook key is action_order_status_update_[order_state] where [order_state] can take differents values
584
+ if (strstr($hook_key, 'action_order_status_update')) {
585
+ $defaultMessage = __('{firstname} {lastname}, your order {order_id} on {shopname} has a new status : {order_state}', 'octopush-sms');
586
+ } else {
587
+ $defaultMessage = __('Not defined', 'octopush-sms');
588
+ $defaultMessage .= $hookText;
589
+ }
590
+ break;
591
+ }
592
+ return $defaultMessage;
593
+ }
594
+
595
+ /**
596
+ * Construct the sms values before send it.
597
+ * The SMS values depend of the hook
598
+ * @param type $b_admin
599
+ */
600
+ public function _prepare_sms($hook_id, $params, $b_admin = false) {
601
+ Mage::log("==========================|> _prepare_sms hook_id:$hook_id , admin:$b_admin==================================================", Zend_Log::DEBUG, "octopushsms.log");
602
+
603
+ //defined the method name to call to set the recipient phone and the value to replave in the sms text
604
+ $method = '_get_' . $hook_id . '_values';
605
+ //Mage::log('_prepare_sms ' . $method . ' params: ' . print_r($params, true), Zend_Log::DEBUG, "octopushsms.log");
606
+
607
+ $api = Mage::helper('octopushsms/API');
608
+
609
+ //if method to get the values corresponding to this hook exist we continue
610
+ //specific case of update status
611
+ $hook_id_adapted = null;
612
+ if ($hook_id == 'action_order_status_update') {
613
+ $hook_id_adapted = $hook_id . "_" . $params['order']->getStatus();
614
+ } else {
615
+ $hook_id_adapted = $hook_id;
616
+ }
617
+
618
+ $message = $this->get_message($hook_id_adapted, $b_admin);
619
+ if ($message->getId() <= 0 || !method_exists(__CLASS__, $method)) {
620
+ Mage::log($hook_id . ' not exit or no method ' . $method . ' exists : no sms send', Zend_Log::INFO, "octopushsms.log");
621
+ return false;
622
+ }
623
+ $api->_recipients = null;
624
+ $api->_phone = null;
625
+ //this internal hook is active?
626
+ $is_active = $message->getData('is_active');
627
+ $text = $message->getData('message');
628
+ //TODO remove ? $locale = get_locale();
629
+ //if active and a text exists
630
+ if ($is_active && $text) {
631
+ Mage::log("=========la", Zend_Log::DEBUG, "octopushsms.log");
632
+
633
+ //get values to replace in sms text
634
+ $values = $this->$method(false, $b_admin, $params);
635
+ //check if everything is valid for sending the sms (if $this->_phone is not set, nothing is send)
636
+ Mage::log("=========lae", Zend_Log::DEBUG, "octopushsms.log");
637
+
638
+ if (!$api->_is_everything_valid_for_sending()) {
639
+ return false;
640
+ }
641
+ Mage::log("=========laee", Zend_Log::DEBUG, "octopushsms.log");
642
+
643
+ //if we can send the sms, we send it
644
+ if (is_array($values)) {
645
+ $text_to_send = str_replace(array_keys($values), array_values($values), $text);
646
+ $api->_send_sms($text_to_send);
647
+ }
648
+ }
649
+ }
650
+
651
+ public function send($hook, $params) {
652
+ //send sms for the client (check if sending the sms is needed, create the mesage...)
653
+ self::_prepare_sms($hook, $params);
654
+ //send sms for admin (check if sending the sms is needed, create the mesage...)
655
+ self::_prepare_sms($hook, $params, true);
656
+ if ($hook != 'action_admin_alert') {
657
+ $this->ckeck_balance_for_admin_alert();
658
+ }
659
+ }
660
+
661
+ public function can_send_optional_sms($order_id, $b_admin) {
662
+ if ($b_admin) {
663
+ return true;
664
+ }
665
+ //test setting value
666
+ $setting = Mage::getModel('octopushsms/setting')->load(1);
667
+ if ($setting->getData('free_option')) {
668
+ return true;
669
+ }
670
+
671
+ //option is not free test if the product is in the order
672
+ $product_id = $this->setting->getData('id_product');
673
+ Mage::getModel('sales/order');
674
+ $order = Mage::getModel('sales/order')->load($order_id);
675
+ $orderItems = $order->getItemsCollection()
676
+ ->addAttributeToSelect('*')
677
+ ->addAttributeToFilter('product_id', array('eq' => $product_id))
678
+ ->load();
679
+ return ($orderItems->getSize() > 0);
680
+ }
681
+
682
+ public function ckeck_balance_for_admin_alert() {
683
+ $api = Mage::helper('octopushsms/API');
684
+ $balance = $api->get_balance();
685
+ $setting = Mage::getModel("octopushsms/setting")->load('1');
686
+ $alert_level = $setting->getAdminAlert();
687
+ if ($alert_level > 0 && (float) $balance < $alert_level && $setting->getAdminAlertSent() == 0) {
688
+ $messageHelper = Mage::helper('octopushsms/message');
689
+ $params = array('balance' => $balance);
690
+ $messageHelper->send('action_admin_alert', $params);
691
+ $setting->setAdminAlertSent(1);
692
+ $setting->save();
693
+ }
694
+ }
695
+
696
+ }
app/code/local/Octopush/OctopushSms/Helper/Statistic.php ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Octopush_OctopushSms_Helper_Statistic extends Mage_Core_Helper_Abstract {
4
+
5
+ public function getSales() {
6
+ $orders = Mage::getModel('sales/order')->getCollection()
7
+ //->addAttributeToFilter('status', Mage_Sales_Model_Order::STATE_COMPLETE)
8
+ //->addAttributeToFilter('status', 'complete')
9
+ ->addAttributeToFilter('created_at', array('from' => date('Y-m-d')))
10
+ //->addAttributeToFilter( 'created_at', array( 'from' => date( 'Y-m-d', strtotime( '-100 days' ) ), 'to' => date( 'Y-m-d' ) ) )
11
+ ->addAttributeToSelect('grand_total')
12
+ ->getColumnValues('grand_total');
13
+
14
+ $day_sales = Mage::getModel('sales/order')->getCollection()
15
+ ->addAttributeToFilter('status', Mage_Sales_Model_Order::STATE_COMPLETE)
16
+ ->addAttributeToFilter('status', 'complete')
17
+ ->addAttributeToFilter('created_at', array('from' => date('Y-m-d')))
18
+ //->addAttributeToFilter( 'created_at', array( 'from' => date( 'Y-m-d', strtotime( '-100 days' ) ), 'to' => date( 'Y-m-d' ) ) )
19
+ ->addAttributeToSelect('grand_total')
20
+ ->getColumnValues('grand_total');
21
+
22
+ $month_sales = Mage::getModel('sales/order')->getCollection()
23
+ ->addAttributeToFilter('status', Mage_Sales_Model_Order::STATE_COMPLETE)
24
+ ->addAttributeToFilter('status', 'complete')
25
+ ->addAttributeToFilter('created_at', array('from' => date('Y-m-01')))
26
+ //->addAttributeToFilter( 'created_at', array( 'from' => date( 'Y-m-d', strtotime( '-100 days' ) ), 'to' => date( 'Y-m-d' ) ) )
27
+ ->addAttributeToSelect('grand_total')
28
+ ->getColumnValues('grand_total');
29
+
30
+ $totalMonthSum = Mage::helper('core')->currency(array_sum($month_sales), true, false);
31
+ $totalDaySum = Mage::helper('core')->currency(array_sum($day_sales), true, false);
32
+ return array('{day_sales}' => $totalDaySum, '{month_sales}' => $totalMonthSum,'{orders}'=>count($orders));
33
+ }
34
+
35
+ public function getVisits() {
36
+ $collectionVisitor = Mage::getModel('log/visitor')->getCollection()->addFieldToFilter('first_visit_at', array('from' => date('Y-m-d')));
37
+ return array('{visitors}'=>count($collectionVisitor));//,'visitors'=>count($collectionCustomer));
38
+ }
39
+
40
+ public function getSubscriptions() {
41
+ $collection = Mage::getResourceModel('customer/customer_collection')
42
+ ->addNameToSelect()
43
+ ->addAttributeToSelect('created_at')
44
+ ->addAttributeToFilter('created_at', array('from' => date('Y-m-d')));
45
+ return array('{subs}'=>count($collection));
46
+ }
47
+
48
+ }
app/code/local/Octopush/OctopushSms/Model/Campaign.php ADDED
@@ -0,0 +1,58 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Campaign of octopushsms module
5
+ */
6
+ class Octopush_OctopushSms_Model_Campaign extends Mage_Core_Model_Abstract {
7
+
8
+ var $balance = 0;
9
+
10
+ public function _construct() {
11
+ parent::_construct();
12
+ $this->_init('octopushsms/campaign');
13
+ }
14
+
15
+ /**
16
+ * Processing object before save data
17
+ *
18
+ * @return Mage_Core_Model_Abstract
19
+ */
20
+ protected function _beforeSave() {
21
+ if (empty($this->getData('date_add'))) {
22
+ $this->setDateAdd(
23
+ Mage::getSingleton('core/date')
24
+ ->gmtDate()
25
+ );
26
+ }
27
+ if (empty($this->getData('date_send'))) {
28
+ //if the send date is not set, we set the send date to now
29
+ $this->setData('date_send', Mage::getModel('core/date')->date('Y-m-d H:m:s'));
30
+ }
31
+ if (empty($this->getData('ticket'))) {
32
+ //if the send date is not set, we set the send date to now
33
+ $this->setData('ticket', (string) time());
34
+ }
35
+ //$this->setData('date_add',Mage::getModel('core/date')->date('Y-m-d HH:mm:ss'));
36
+ $this->setDateUpd(Mage::getSingleton('core/date')->gmtDate());
37
+ return parent::_beforeSave();
38
+ }
39
+
40
+ public function validate() {
41
+ $errors = array();
42
+ $helper = Mage::helper('octopushsms');
43
+ if (empty($this->getData('title'))) {
44
+ $errors[] = $helper->__('Please enter a title');
45
+ }
46
+ if (empty($this->getData('message'))) {
47
+ $errors[] = $helper->__('Please enter a message');
48
+ }
49
+ if (empty($this->getData('date_send'))) {
50
+ $errors[] = $helper->__('Please enter a valid send date');
51
+ }
52
+ if (empty($errors) || $this->getShouldIgnoreValidation()) {
53
+ return true;
54
+ }
55
+ return $errors;
56
+ }
57
+
58
+ }
app/code/local/Octopush/OctopushSms/Model/Message.php ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Octopush_OctopushSms_Model_Message extends Mage_Core_Model_Abstract {
4
+ public function _construct() {
5
+ parent::_construct();
6
+ $this->_init('octopushsms/message');
7
+ }
8
+ }
9
+
app/code/local/Octopush/OctopushSms/Model/Mysql4/Campaign.php ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+
4
+ /**
5
+ * Setting of octopushsms module
6
+ */
7
+ class Octopush_OctopushSms_Model_Mysql4_Campaign extends Mage_Core_Model_Mysql4_Abstract {
8
+
9
+ public function _construct() {
10
+ $this->_init('octopushsms/campaign', 'id_sendsms_campaign');
11
+ }
12
+
13
+
14
+ }
app/code/local/Octopush/OctopushSms/Model/Mysql4/Campaign/Collection.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Octopush_OctopushSms_Model_Mysql4_Campaign_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
4
+ {
5
+ public function _construct()
6
+ {
7
+ parent::_construct();
8
+ $this->_init('octopushsms/campaign');
9
+ }
10
+ }
app/code/local/Octopush/OctopushSms/Model/Mysql4/Message.php ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Setting of octopushsms module
5
+ */
6
+ class Octopush_OctopushSms_Model_Mysql4_Message extends Mage_Core_Model_Mysql4_Abstract {
7
+
8
+ public function _construct() {
9
+ $this->_init('octopushsms/message', 'id_message');
10
+ }
11
+
12
+ }
13
+
app/code/local/Octopush/OctopushSms/Model/Mysql4/Message/Collection.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Octopush_OctopushSms_Model_Mysql4_Message_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
4
+ {
5
+ public function _construct()
6
+ {
7
+ parent::_construct();
8
+ $this->_init('octopushsms/message');
9
+ }
10
+ }
app/code/local/Octopush/OctopushSms/Model/Mysql4/Phoneprefix.php ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Setting of octopushsms module
5
+ */
6
+ class Octopush_OctopushSms_Model_Mysql4_Phoneprefix extends Mage_Core_Model_Mysql4_Abstract {
7
+
8
+ public function _construct() {
9
+ $this->_init('octopushsms/phoneprefix', 'iso_code');
10
+ }
11
+
12
+
13
+ }
app/code/local/Octopush/OctopushSms/Model/Mysql4/Phoneprefix/Collection.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Octopush_OctopushSms_Model_Mysql4_Phoneprefix_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
4
+ {
5
+ public function _construct()
6
+ {
7
+ parent::_construct();
8
+ $this->_init('octopushsms/phoneprefix');
9
+ }
10
+ }
app/code/local/Octopush/OctopushSms/Model/Mysql4/Recipient.php ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+
4
+ /**
5
+ * Setting of octopushsms module
6
+ */
7
+ class Octopush_OctopushSms_Model_Mysql4_Recipient extends Mage_Core_Model_Mysql4_Abstract {
8
+
9
+ public function _construct() {
10
+ $this->_init('octopushsms/recipient', 'id_sendsms_recipient');
11
+ }
12
+
13
+
14
+ }
app/code/local/Octopush/OctopushSms/Model/Mysql4/Recipient/Collection.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Octopush_OctopushSms_Model_Mysql4_Recipient_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
4
+ {
5
+ public function _construct()
6
+ {
7
+ parent::_construct();
8
+ $this->_init('octopushsms/recipient');
9
+ }
10
+ }
app/code/local/Octopush/OctopushSms/Model/Mysql4/Setting.php ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Setting of octopushsms module
5
+ */
6
+ class Octopush_OctopushSms_Model_Mysql4_Setting extends Mage_Core_Model_Mysql4_Abstract {
7
+
8
+ public function _construct() {
9
+ $this->_init('octopushsms/setting', 'id_octopushsms_setting');
10
+ }
11
+
12
+
13
+ }
app/code/local/Octopush/OctopushSms/Model/Mysql4/Setting/Collection.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Octopush_OctopushSms_Model_Mysql4_Setting_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
4
+ {
5
+ public function _construct()
6
+ {
7
+ parent::_construct();
8
+ $this->_init('octopushsms/setting');
9
+ }
10
+ }
app/code/local/Octopush/OctopushSms/Model/Mysql4/Test.php ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Octopush_OctopushSms_Model_Mysql4_Test extends Mage_Core_Model_Mysql4_Abstract
3
+ {
4
+ public function _construct()
5
+ {
6
+ $this->_init('octopushsms/test', 'id_octopush_test');
7
+ }
8
+ }
app/code/local/Octopush/OctopushSms/Model/Mysql4/Test/Collection.php ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Octopush_OctopushSms_Model_Mysql4_Test_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
3
+ {
4
+ public function _construct()
5
+ {
6
+ parent::_construct();
7
+ $this->_init('octopushsms/test');
8
+ }
9
+ }
app/code/local/Octopush/OctopushSms/Model/Observer/AbstractObserver.php ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ * To change this license header, choose License Headers in Project Properties.
5
+ * To change this template file, choose Tools | Templates
6
+ * and open the template in the editor.
7
+ */
8
+ abstract class AbstractObserver {
9
+
10
+ }
11
+
app/code/local/Octopush/OctopushSms/Model/Observer/Observer.php ADDED
@@ -0,0 +1,186 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Observer: Mage::dispatchEvent('checkout_submit_all_after', array('order' => $order, 'quote' => $quote));
5
+ *
6
+ */
7
+ class Octopush_OctopushSms_Model_Observer_Observer extends Varien_Event_Observer {
8
+
9
+ public function __construct() {
10
+
11
+ }
12
+
13
+ public function checkoutSubmitAllAfterObserve($observer) {
14
+ $order = $observer->getEvent()->getOrder();
15
+ Mage::log('Event - ' . $observer->getEvent()->getName() . ' order id:' . $order->getId(), Zend_Log::DEBUG);
16
+ $messageHelper = Mage::helper('octopushsms/message');
17
+ $params = array('order_id' => $order->getId());
18
+ $messageHelper->send('action_validate_order', $params);
19
+ //test quantity if it is needed to send low stock sms
20
+ $orderIncrementId = $order->getIncrementId();
21
+ $salesOrder = Mage::getModel('sales/order')->loadByIncrementId($orderIncrementId);
22
+ $items = $salesOrder->getAllVisibleItems();
23
+ foreach ($items as $i) {
24
+ $stockItem = Mage::getModel('cataloginventory/stock_item')->loadByProduct($i->getProductId());
25
+ if ($stockItem->getQty() < $stockItem->getNotifyStockQty()) {
26
+ $params = array('product' => $i);
27
+ $messageHelper->send('action_update_quantity', $params);
28
+ }
29
+ }
30
+ Mage::register('checkout_submit_all_after_' . $order->getId(), true);
31
+ }
32
+
33
+ /**
34
+ * Observer method for event cataloginventory_stock_item_save_after
35
+ * @param type $observer
36
+ */
37
+ public function cataloginventoryStockItemSaveAfterObserve($observer) {
38
+ Mage::log("SLIPS8 cataloginventoryStockItemSaveAfterObserve", Zend_Log::DEBUG, "octopushsms.log");
39
+
40
+ $messageHelper = Mage::helper('octopushsms/message');
41
+ $i = Mage::getModel('catalog/product')->load($observer->getEvent()->getDataObject()->getProductId());
42
+ $stockItem = Mage::getModel('cataloginventory/stock_item')->loadByProduct($i->getProductId());
43
+ if ($stockItem->getQty() < $stockItem->getNotifyStockQty()) {
44
+ $params = array('product' => $i);
45
+ $messageHelper->send('action_update_quantity', $params);
46
+ }
47
+ }
48
+
49
+ /**
50
+ * controller_action_postdispatch_contacts_index_post
51
+ *
52
+ * controller_action_postdispatch_review
53
+ */
54
+ public function controllerActionPostdispatchContactsIndexPostObserve($observer) {
55
+ $data = $observer->getData(); //['controller_action'];
56
+ Mage::log("SLIPS " . print_r($data['controller_action'], true), Zend_Log::DEBUG, "octopushsms.log");
57
+ $controller_action = $data['controller_action'];
58
+ $post = $controller_action->getRequest()->getPost();
59
+ if ($post) {
60
+ Mage::log("SLIPS " . print_r($post, true), Zend_Log::DEBUG, "octopushsms.log");
61
+ $messageHelper = Mage::helper('octopushsms/message');
62
+ $params = array('comment' => $post);
63
+ $messageHelper->send('action_send_message', $params);
64
+ }
65
+ }
66
+
67
+ public function dailyReportCron() {
68
+ $messageHelper = Mage::helper('octopushsms/message');
69
+ $messageHelper->send('action_daily_report', array());
70
+ }
71
+
72
+ public function createAccountObserve($observer) {
73
+ $customer = $observer->getEvent()->getCustomer();
74
+ if (Mage::registry('customer_save_after_' . $customer->getId())) {
75
+ return $this;
76
+ }
77
+ Mage::log('Event - ' . $observer->getEvent()->getName() . ' customer id:' . $customer->getId(), Zend_Log::DEBUG);
78
+ /* $currentTimestamp = Mage::getModel('core/date')->timestamp(time());
79
+ echo $currentDate = date('Y-m-d H:i:s', $currentTimestamp);
80
+ Mage::log('Event - ' . $currentDate.' customer id:' . print_r($customer->debug(),true), Zend_Log::DEBUG,"octopushsms.log"); */
81
+
82
+ $messageHelper = Mage::helper('octopushsms/message');
83
+ if ($customer->getData('created_at') == $customer->getData('updated_at')) {
84
+ $params = array('customer_id' => $customer->getId());
85
+ $messageHelper->send('action_create_account', $params);
86
+ Mage::register('customer_save_observer_executed_' . $customer->getId(), true);
87
+ }
88
+ }
89
+
90
+ public function forgotPasswordObserve($observer) {
91
+ //Mage::log("SLIPS " . print_r($observer, true), Zend_Log::DEBUG, "octopushsms.log");
92
+ $_object = $observer->getEvent()->getObject();
93
+ $_post = Mage::app()->getRequest()->getPost();
94
+
95
+ if ($_object instanceof Mage_Log_Model_Visitor) {
96
+ //Mage::log("SLIPS " . $_object->getData('http_referer') . " " . print_r($_post, true), Zend_Log::DEBUG, "octopushsms.log");
97
+ if ($_object->getData('http_referer') && strstr($_object->getData('http_referer'), 'forgotpassword') && isset($_post['email'])) {
98
+ $messageHelper = Mage::helper('octopushsms/message');
99
+ $customerHelper = Mage::helper('octopushsms/customer');
100
+ $customer = $customerHelper->find_customer_by_email($_post['email']);
101
+ Mage::log("SLIPSO " . print_r($customer->debug(), true), Zend_Log::DEBUG, "octopushsms.log");
102
+ $params = array('customer_id' => $customer->getId());
103
+ $messageHelper->send('action_password_renew', $params);
104
+ }
105
+ }
106
+ }
107
+
108
+ //sales_order_save_after
109
+ public function orderStateChangeObserve($observer) {
110
+ $order = $observer->getEvent()->getOrder();
111
+ $oldstatus = $order->getOrigData('status');
112
+ $Newstatus = $order->getData('status');
113
+ if ($oldstatus != $Newstatus) {
114
+ $params = array('order' => $order);
115
+ $messageHelper = Mage::helper('octopushsms/message');
116
+ $messageHelper->send('action_order_status_update', $params);
117
+ }
118
+ }
119
+
120
+ //sales_order_shipment_track_save_after
121
+ public function shipmentTrackObserve($observer) {
122
+ $track = $observer->getEvent()->getTrack();
123
+ //Mage::log("SLIPS track " . print_r($track->debug(), true), Zend_Log::DEBUG, "octopushsms.log");
124
+ $params = array('track' => $track);
125
+ $messageHelper = Mage::helper('octopushsms/message');
126
+ $messageHelper->send('action_admin_orders_tracking_number_update', $params);
127
+ }
128
+
129
+ public function checkStockChangeObserve($observer) {
130
+ Mage::log("registry " . Mage::registry('action_customer_alert'), Zend_Log::DEBUG);
131
+ if (!Mage::registry('action_customer_alert')) {
132
+ $product = Mage::getModel('catalog/product')->load($observer->getEvent()->getDataObject()->getProductId());
133
+ $stock = Mage::getModel('cataloginventory/stock_item')->loadByProduct($product->getProductId());
134
+ if ($stock->getIsInStock() == 1 && $stock->getOrigData('is_in_stock') == 0) {
135
+ $websites = Mage::app()->getWebsites();
136
+ foreach ($websites as $website) {
137
+ /* @var $website Mage_Core_Model_Website */
138
+ if (!$website->getDefaultGroup() || !$website->getDefaultGroup()->getDefaultStore()) {
139
+ continue;
140
+ }
141
+ if (!Mage::getStoreConfig(
142
+ 'catalog/productalert/allow_stock', $website->getDefaultGroup()->getDefaultStore()->getId()
143
+ )) {
144
+ continue;
145
+ }
146
+ try {
147
+ $collection = Mage::getModel('productalert/stock')
148
+ ->getCollection()
149
+ ->addWebsiteFilter($website->getId())
150
+ ->addStatusFilter(0)
151
+ ->setCustomerOrder();
152
+ } catch (Exception $e) {
153
+ $this->_errors[] = $e->getMessage();
154
+ return $this;
155
+ }
156
+
157
+ $previousCustomer = null;
158
+ // $email->setWebsite($website);
159
+ foreach ($collection as $alert) {
160
+ try {
161
+ $customer = Mage::getModel('customer/customer')->load($alert->getCustomerId());
162
+ if (!$customer) {
163
+ continue;
164
+ }
165
+ $product = Mage::getModel('catalog/product')
166
+ ->setStoreId($website->getDefaultStore()->getId())
167
+ ->load($alert->getProductId());
168
+ /* @var $product Mage_Catalog_Model_Product */
169
+ if (!$product) {
170
+ continue;
171
+ }
172
+ //TODO send sms
173
+ $params = array("customer" => $customer, "product" => $product);
174
+ $messageHelper = Mage::helper('octopushsms/message');
175
+ $messageHelper->send('action_customer_alert', $params);
176
+ } catch (Exception $e) {
177
+ Mage::log("Error to send sms stock notification " . $e->getMessage(), Zend_Log::ERR);
178
+ }
179
+ }
180
+ }
181
+ }
182
+ Mage::register('action_customer_alert', true);
183
+ }
184
+ }
185
+
186
+ }
app/code/local/Octopush/OctopushSms/Model/Phoneprefix.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Octopush_OctopushSms_Model_PhonePrefix extends Mage_Core_Model_Abstract {
4
+
5
+ public function _construct() {
6
+ parent::_construct();
7
+ $this->_init('octopushsms/phoneprefix');
8
+ }
9
+
10
+ }
app/code/local/Octopush/OctopushSms/Model/Recipient.php ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Recipient of octopushsms module
5
+ */
6
+ class Octopush_OctopushSms_Model_Recipient extends Mage_Core_Model_Abstract {
7
+
8
+ var $balance = 0;
9
+
10
+ public function _construct() {
11
+ parent::_construct();
12
+ $this->_init('octopushsms/recipient');
13
+ }
14
+
15
+ public function validate() {
16
+ $errors = array();
17
+ //$helper = Mage::helper('octopushsms');
18
+ if (!Zend_Validate::is($this->getData('phone'), 'NotEmpty') || !preg_match('/^\+[0-9]{6,16}$/', $this->getData('phone'))) {
19
+ $errors[] = __('The phone number is wrong');
20
+ }
21
+
22
+ if (empty($errors) || $this->getShouldIgnoreValidation()) {
23
+ return true;
24
+ }
25
+ return $errors;
26
+ }
27
+
28
+ }
app/code/local/Octopush/OctopushSms/Model/Setting.php ADDED
@@ -0,0 +1,85 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Setting of octopushsms module
5
+ */
6
+ class Octopush_OctopushSms_Model_Setting extends Mage_Core_Model_Abstract {
7
+
8
+ var $balance = 0;
9
+
10
+ public function _construct() {
11
+ parent::_construct();
12
+ $this->_init('octopushsms/setting');
13
+ }
14
+
15
+ public function validate() {
16
+ $errors = array();
17
+ $helper = Mage::helper('octopushsms');
18
+
19
+ if (!Zend_Validate::is($this->getEmail(), 'NotEmpty') ||
20
+ !Zend_Validate::is($this->getKey(), 'NotEmpty')) {
21
+ $errors[] = $helper->__('Please enter your account information to login to www.octopush.com');
22
+ } else if (!Zend_Validate::is($this->getEmail(), 'EmailAddress')) {
23
+ $errors[] = $helper->__('The email you entered is not a valid email.');
24
+ } else {
25
+ $api = Mage::helper('octopushsms/API');
26
+ $api->user_login = $this->getData('email');
27
+ $api->api_key = $this->getData('key');
28
+ $api->sms_sender = $this->getData('sender');
29
+ $this->balance = $api->get_balance();
30
+ if ($this->balance === false) {
31
+ $errors[] = $helper->__('This account is not a valid account on www.octopush.com');
32
+ } else if ($this->balance === '001') {
33
+ $errors[] = $helper->__('This account is not a valid account on www.octopush.com');
34
+ $error = $api->get_error_SMS('001');
35
+ $errors[] = $helper->$error;
36
+ }
37
+ }
38
+
39
+ //sender
40
+ if (!preg_match('/^[[:digit:]]{1,16}$/', $this->getSender()) && !preg_match('/^[[:alnum:]]{1,11}$/', $this->getSender())) {
41
+ $errors[] = $helper->__('Please enter a valid sender name : 11 chars max (letters + digits)');
42
+ }
43
+
44
+
45
+ //Admin phone
46
+ if (!Zend_Validate::is($this->getAdminPhone(), 'NotEmpty') || !preg_match('/^\+[0-9]{6,16}$/', $this->getAdminPhone())) {
47
+ $errors[] = $helper->__('Please enter a valid admin mobile number');
48
+ }
49
+
50
+ //Admin alert
51
+ if (!Zend_Validate::is($this->getAdminAlert(), 'Int')) {
52
+ $errors[] = $helper->__('Please enter a valid integer value for alert');
53
+ }
54
+
55
+ //id_product
56
+ //check only is not free_option
57
+ if ($this->getFreeOption()==0) {
58
+ $products=Mage::getResourceModel('catalog/product_collection')->addAttributeToFilter('entity_id',$this->getIdProduct());
59
+ if ($products->count()==0) {
60
+ $errors[] = $helper->__('The product with entity_id %s does not exist',$this->getIdProduct());
61
+ }
62
+ }
63
+ /*
64
+ //free option
65
+ if (isset($freeoption)) {
66
+ if (!is_numeric($product_id)) {
67
+ WC_Admin_Settings::add_error(__('Please enter a valid integer value for product_id', 'octopush-sms'));
68
+ } else {
69
+ //TODO verify product exist
70
+ update_option('octopush_sms_option_id_product', $product_id);
71
+ }
72
+ update_option('octopush_sms_freeoption', $freeoption);
73
+ }
74
+ }
75
+ $this->balance = Octopush_Sms_API::get_instance()->get_balance();
76
+ $this->bAuth = $this->balance === false || $this->balance === '001' ? false : true;
77
+ } */
78
+
79
+ if (empty($errors) || $this->getShouldIgnoreValidation()) {
80
+ return true;
81
+ }
82
+ return $errors;
83
+ }
84
+
85
+ }
app/code/local/Octopush/OctopushSms/Model/Test.php ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Octopush_OctopushSms_Model_Test extends Mage_Core_Model_Abstract {
4
+
5
+ public function _construct() {
6
+ parent::_construct();
7
+ $this->_init('octopushsms/test');
8
+ }
9
+
10
+
11
+
12
+ }
app/code/local/Octopush/OctopushSms/controllers/Adminhtml/IndexController.php ADDED
@@ -0,0 +1,774 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ * Controller of octopushsms plugin
5
+ * (class has to be inherited from Mage_Core_Controller_action)
6
+ */
7
+
8
+ class Octopush_OctopushSms_Adminhtml_IndexController extends Mage_Adminhtml_Controller_Action {
9
+
10
+ var $setting = null;
11
+ var $balance = null;
12
+ var $bAuth = null;
13
+
14
+ /* protected function _construct()
15
+ {
16
+ parent::_construct();
17
+ $this->setting=Mage::getModel('octopushsms/setting')->load('1');
18
+ } */
19
+
20
+ /**
21
+ * TODO remove
22
+ * @return boolean
23
+ */
24
+ public function test() {
25
+ /*$product = Mage::getModel('catalog/product')->load(2);
26
+ Mage::log($product->debug());
27
+ $i = Mage::getModel('cataloginventory/stock_item')
28
+ ->loadByProduct(2);
29
+ Mage::log($i->getQty());
30
+ Mage::log($i->getMinQty());
31
+ Mage::log($i->getNotifyStockQty());*/
32
+
33
+ /* $messageHelper = Mage::helper('octopushsms/message');
34
+
35
+ $salesOrder = Mage::getModel('sales/order')->loadByIncrementId(100000030);
36
+ $items = $salesOrder->getAllVisibleItems();
37
+ foreach($items as $i) {
38
+ if ($stockItem->getQty()<$stockItem->getNotifyStockQty()) {
39
+ $params=array('product'=>$i);
40
+ Mage::log($i->getId().' '.$i->getSku().' '.$i->getName());
41
+ $messageHelper->send('action_update_quantity', $params);
42
+ }
43
+ //Mage::log($i->debug());
44
+ }*/
45
+ /*$api = Mage::helper('octopushsms/API');
46
+
47
+
48
+
49
+ //if method to get the values corresponding to this hook exist we continue
50
+ $api->_recipients = null;
51
+ $api->_phone = null;
52
+
53
+ $api->_set_phone('+33651534631', 'FR', true);
54
+ //check if everything is valid for sending the sms (if $this->_phone is not set, nothing is send)
55
+ if (!$api->_is_everything_valid_for_sending()) {
56
+ return false;
57
+ }
58
+ $api->_send_sms('ok on y va');*/
59
+
60
+ /*echo print_r(Mage::helper('octopushsms/statistic')->getSales(),true);
61
+ echo print_r(Mage::helper('octopushsms/statistic')->getVisits(),true);
62
+ echo print_r(Mage::helper('octopushsms/statistic')->getSubscriptions(),true);*/
63
+ //echo Mage::getLo
64
+ }
65
+
66
+ public function indexAction() {
67
+ //TODO remove
68
+ $this->test();
69
+ $this->setting = Mage::getModel('octopushsms/setting')->load('1');
70
+ $this->displaySettings();
71
+ }
72
+
73
+ private function displaySettings() {
74
+ $api = Mage::helper('octopushsms/API');
75
+ $api->user_login = $this->setting->getData('email');
76
+ $api->api_key = $this->setting->getData('key');
77
+ $api->sms_sender = $this->setting->getData('sender');
78
+
79
+ $this->balance = $api->get_balance();
80
+ $this->bAuth = $this->balance === false || $this->balance === '001' ? false : true;
81
+
82
+ Mage::register('setting', $this->setting);
83
+ Mage::register('balance', $this->balance);
84
+ Mage::register('bAuth', $this->bAuth);
85
+ $this->loadLayout();
86
+ $this->renderLayout();
87
+ }
88
+
89
+ /**
90
+ * Filter customer
91
+ */
92
+ public function ajaxFilterCustomerAction() {
93
+ $s = !empty($this->getRequest()->getParam('q')) ? stripslashes($this->getRequest()->getParam('q')) : '';
94
+
95
+ $helperCustomer = Mage::Helper('octopushsms/customer');
96
+ $collection = $helperCustomer->find_customer($s);
97
+
98
+ if (count($collection) == 0) {
99
+ echo "<ul></ul>";
100
+ return "";
101
+ }
102
+ echo "<ul>";
103
+ foreach ($collection as $customer) {
104
+ //var_dump($customer->debug());
105
+ if ($customer->getData('billing_telephone')) {
106
+ $api = Mage::Helper('octopushsms/API');
107
+ $phone=$api->convert_phone_to_international($customer->getData('billing_telephone'), $customer->getData('billing_country_id'));
108
+ echo "<li title='{\"id_customer\":\"".$customer->getId()."\",\"firstname\":\"".$customer->getFirstname()."\",\"lastname\":\"".$customer->getLastname()."\",\"telephone\":\"".$phone."\"}'>" . $customer->getName() . " " . $phone . "</li>";
109
+ }
110
+ }
111
+ echo "</ul>";
112
+ return;
113
+ }
114
+
115
+
116
+ public function savesettingsAction() {
117
+ $this->setting = Mage::getModel('octopushsms/setting')->load('1');
118
+ //Zend_Debug::dump($this->setting);
119
+ //on recuperes les données envoyées en POST
120
+ $this->setting->setData('email', $this->getRequest()->getPost('octopush_sms_email'));
121
+ $this->setting->setData('key', $this->getRequest()->getPost('octopush_sms_key'));
122
+ $this->setting->setData('admin_phone', $this->getRequest()->getPost('octopush_sms_admin_phone'));
123
+ $this->setting->setData('sender', $this->getRequest()->getPost('octopush_sms_sender'));
124
+ $this->setting->setData('admin_alert', $this->getRequest()->getPost('octopush_sms_admin_alert'));
125
+ //specific case of radio button group
126
+ $this->setting->setData('free_option', $this->getRequest()->getPost('octopush_sms_free_option'));
127
+ $this->setting->setData('id_product', $this->getRequest()->getPost('octopush_sms_id_product'));
128
+ //$this->setting->setData('admin_alert_sent',$this->getRequest()->getPost('octopush_sms_email'));
129
+ $validate = $this->setting->validate();
130
+ //Zend_Debug::dump($validate);
131
+ if ($validate === true) {
132
+ $this->setting->save();
133
+ Mage::getSingleton('adminhtml/session')->addSuccess(__('Settings have been save.'));
134
+ } else {
135
+ foreach ($validate as $error) {
136
+ Mage::getSingleton('adminhtml/session')->addError($error);
137
+ }
138
+ }
139
+ $messageHelper=Mage::helper('octopushsms/message');
140
+ $messageHelper->ckeck_balance_for_admin_alert();
141
+ $this->displaySettings();
142
+ }
143
+
144
+ public function campaignAction() {
145
+ $this->loadLayout();
146
+ $this->_setActiveMenu('octopushsms/Messages');
147
+ $this->renderLayout();
148
+ }
149
+
150
+ public function historyAction() {
151
+ $this->loadLayout();
152
+ $this->_setActiveMenu('octopushsms/Messages');
153
+ $this->renderLayout();
154
+ }
155
+
156
+ /**
157
+ * Edit a campaign
158
+ */
159
+ public function editAction() {
160
+ $campaignId = $this->getRequest()->getParam('id');
161
+ $campaignModel = Mage::getModel('octopushsms/campaign')->load($campaignId);
162
+ if ($campaignModel->getId() || $campaignId == 0) {
163
+ Mage::register('campaign_data', $campaignModel);
164
+ $this->loadLayout();
165
+ $this->_setActiveMenu('octopushsms/Messages');
166
+ //$this->_addBreadcrumb('test Manager', 'test Manager');
167
+ //$this->_addBreadcrumb('Test Description', 'Test Description');
168
+ $this->getLayout()->getBlock('head')
169
+ ->setCanLoadExtJs(true);
170
+ /* $this->_addContent($this->getLayout()
171
+ ->createBlock('octopushsms/campaign_edit'));
172
+ $this->_addLeft($this->getLayout()
173
+ ->createBlock('octopushsms/campaign_edit_info')
174
+ ); */
175
+ /* ->_addLeft($this->getLayout()
176
+ ->createBlock('octopushsms/campaign_edit_tabs')
177
+ ); */
178
+ $this->renderLayout();
179
+ } else {
180
+ Mage::getSingleton('adminhtml/session')
181
+ ->addError(__('Campaign does not exist'));
182
+ $this->_redirect('*/*/');
183
+ }
184
+ }
185
+
186
+ /**
187
+ * New campaign
188
+ */
189
+ public function newAction() {
190
+ $this->_forward('edit');
191
+ }
192
+
193
+ /**
194
+ * Save a campaign
195
+ * @return type
196
+ */
197
+ public function saveCampaignAction() {
198
+ if (!$this->getRequest()->getPost()) {
199
+ $this->_redirect('*/*/');
200
+ }
201
+ try {
202
+ $postData = $this->getRequest()->getPost();
203
+ $campaignModel = Mage::getModel('octopushsms/campaign');
204
+ if ($this->getRequest()->getParam('id_sendsms_campaign') > 0) {
205
+ $campaignModel->load(intval($this->getRequest()->getParam('id_sendsms_campaign')));
206
+ }
207
+ $campaignModel
208
+ ->addData($postData);
209
+ if (!$this->getRequest()->getParam('id_sendsms_campaign') > 0) {
210
+ $campaignModel->setData('id_sendsms_campaign', null);
211
+ }
212
+ } catch (Exception $e) {
213
+ Mage::getSingleton('adminhtml/session')
214
+ ->addError($e->getMessage());
215
+ Mage::getSingleton('adminhtml/session')
216
+ ->settestData($this->getRequest()
217
+ ->getPost());
218
+ $this->_redirect('*/*/edit', array('id' => $this->getRequest()
219
+ ->getParam('id_sendsms_campaign')));
220
+ return;
221
+ }
222
+
223
+ $action = $this->getRequest()->getParam('button_id');
224
+ $helper_api = Mage::Helper('octopushsms/API'); //define API constant
225
+ if ($action == 'sendsms_save' && $campaignModel->getData('status') == 0) {
226
+ //create campaign
227
+ $validate = $campaignModel->validate();
228
+ if ($validate === true) {
229
+ if ($campaignModel->save()) {
230
+ Mage::getSingleton('adminhtml/session')->addSuccess(__('Your campaign has been saved.'));
231
+ } else {
232
+ Mage::getSingleton('adminhtml/session')->addError(print_r($campaignModel->getErrors(), true));
233
+ }
234
+ } else {
235
+ foreach ($validate as $error) {
236
+ Mage::getSingleton('adminhtml/session')->addError($error);
237
+ }
238
+ }
239
+ } else if ($campaignModel->getData('status') == 0 && isset($_FILES['sendsms_csv']['tmp_name']) && !empty($_FILES['sendsms_csv']['tmp_name'])) {
240
+ //import a csv file
241
+ //create campaign if it not exists
242
+ $validate = $campaignModel->validate();
243
+ if ($this->getRequest()->getParam('id_sendsms_campaign') <= 0) {
244
+ $campaignModel->setData('ticket', (string) time());
245
+ if (!empty($this->getRequest()->getParam('title'))) {
246
+ $campaignModel->setData('title', $this->getRequest()->getParam('title'));
247
+ } else {
248
+ $campaignModel->setData('title', 'CAMPAIGN-' . $campaignModel->getData('ticket'));
249
+ }
250
+ if (!empty($this->getRequest()->getParam('message'))) {
251
+ $campaignModel->setData('message', $this->getRequest()->getParam('message'));
252
+ } else {
253
+ $campaignModel->setData('message', __('Write your message here...'));
254
+ }
255
+ if (!empty($this->getRequest()->getParam('date_send'))) {
256
+ $campaignModel->setData('date_send', $this->getRequest()->getParam('date_send'));
257
+ } else {
258
+ $campaignModel->setData('date_send', Mage::getModel('core/date')->date('Y-m-d H:m:s'));
259
+ }
260
+ $validate = $campaignModel->validate();
261
+ if ($validate === true) {
262
+ if ($campaignModel->save()) {
263
+ Mage::getSingleton('adminhtml/session')->addSuccess(__('Your campaign has been saved.'));
264
+ } else {
265
+ Mage::getSingleton('adminhtml/session')->addError(print_r($campaignModel->getErrors(), true));
266
+ }
267
+ } else {
268
+ foreach ($validate as $error) {
269
+ Mage::getSingleton('adminhtml/session')->addError($error);
270
+ }
271
+ }
272
+ }
273
+ $tempFile = $_FILES['sendsms_csv']['tmp_name'];
274
+ if (!is_uploaded_file($tempFile)) {
275
+ Mage::getSingleton('adminhtml/session')->addError(__('The file has not been uploaded'));
276
+ } else if ($validate === true) {
277
+ $cpt = 0;
278
+ $line = 0;
279
+ if (($fd = fopen($tempFile, "r")) !== FALSE) {
280
+ while (($data = fgetcsv($fd, 1000, ";")) !== FALSE) {
281
+ $line++;
282
+ if (count($data) >= 1) {
283
+ $phone = $data[0];
284
+ // If not international phone
285
+ if (substr($phone, 0, 1) != '+')
286
+ continue;
287
+ $firstname = isset($data[1]) ? $data[1] : null;
288
+ $lastname = isset($data[2]) ? $data[2] : null;
289
+ // if phone is not valid
290
+
291
+ $recipient = Mage::getModel('octopushsms/recipient');
292
+ $recipient->setData('id_sendsms_campaign', $campaignModel->getData('id_sendsms_campaign'));
293
+ $recipient->setData('firstname', $firstname);
294
+ $recipient->setData('lastname', $lastname);
295
+ $recipient->setData('phone', $phone);
296
+ $recipient->setData('status', 0);
297
+
298
+ //if valid, we save
299
+ if ($recipient->validate() === true) {
300
+ // can fail if that phone number already exist for that campaign
301
+ try {
302
+ $res = $recipient->save();
303
+ if ($res->isObjectNew())
304
+ $cpt++;
305
+ } catch (Exception $e) {
306
+
307
+ }
308
+ }
309
+ }
310
+ }
311
+ fclose($fd);
312
+ }
313
+ if ($line == 0)
314
+ Mage::getSingleton('adminhtml/session')->addError(__('That file is not a valid CSV file.'));
315
+ else {
316
+ Mage::helper('octopushsms/Campaign')->compute_campaign($campaignModel);
317
+ Mage::getSingleton('adminhtml/session')->addSuccess($cpt . ' ' . __('new recipient(s) were added to the list.') . ($line - $cpt > 0 ? ' ' . ($line - $cpt) . ' ' . __('line(s) ignored.') : ''));
318
+ }
319
+ }
320
+ } else if ($action == 'sendsms_transmit' && $campaignModel->getData('status') <= 1) {
321
+ //transmit the campaign to Octopush
322
+ $validate = $campaignModel->validate();
323
+ if ($validate === true) {
324
+ $campaignModel->save();
325
+ Mage::getSingleton('adminhtml/session')->addSuccess(__('Your campaign has been saved.'));
326
+ } else {
327
+ foreach ($validate as $error) {
328
+ Mage::getSingleton('adminhtml/session')->addError($error);
329
+ }
330
+ }
331
+ // if it's the first time we call "transmit"
332
+ if ($validate === true && $campaignModel->getData('status') == 0) {
333
+ //check if there is a french number (beginning with +33)
334
+ //if this is the case, verify that the mention "STOP au XXXXX" is here
335
+ $count = Mage::Helper('octopushsms/Campaign')->nbr_french_recipient($campaignModel);
336
+ if ($count > 0 && strpos($campaignModel->getData('message'), _STR_STOP_) == false) {
337
+ Mage::getSingleton('adminhtml/session')->addError($helper_api->get_error_SMS(_ERROR_STOP_MENTION_IS_MISSING_));
338
+ } else {
339
+ $campaignModel->setData('date_transmitted', time());
340
+ //TODO remove $date = strtotime($this->post['sendsms_date'] . ' ' . (int) (isset($this->post['sendsms_date_hour']) ? $this->post['sendsms_date_hour'] : 0) . ':' . (isset($this->post['sendsms_date_minute']) ? $this->post['sendsms_date_minute'] : 0) . ':00');
341
+ //$this->_campaign->date_send = date('Y-m-d H:i:s', $date);
342
+ $campaignModel->setData('status', 1);
343
+ }
344
+ $campaignModel->save();
345
+ } else {
346
+ Mage::getSingleton('adminhtml/session')->addSuccess(__('Your campaign is currently being transmitted, please do not close the window.'));
347
+ }
348
+ } else if ($action == 'sendsms_validate' && $campaignModel->getData('status') == 2) {
349
+ //validate the campaign to say to octopush that this campaign can be send
350
+ if ($campaignModel->validate() === true) {
351
+ //TODO remove$this->_campaign->title = sanitize_text_field($this->post['sendsms_title']);
352
+ //$date = strtotime($this->post['sendsms_date'] . ' ' . (int) (isset($this->post['sendsms_date_hour']) ? $this->post['sendsms_date_hour'] : 0) . ':' . (isset($this->post['sendsms_date_minute']) ? $this->post['sendsms_date_minute'] : 0) . ':00');
353
+ //$this->_campaign->date_send = date_i18n('Y-m-d H:i:s', $date);
354
+ $campaignModel->save();
355
+
356
+ //TODO ? $date = new DateTime(strtotime($this->_campaign->date_send));
357
+ //$date->setTimezone(new DateTimeZone('Europe/Paris'));
358
+ $xml0 = $helper_api->validate_campaign($campaignModel->getData('ticket'), $campaignModel->getData('date_send'));
359
+ $xml = simplexml_load_string($xml0);
360
+ if ($xml->error_code == '000') {
361
+ $campaignModel->setData('status', 3);
362
+ $campaignModel->setData('date_validation', time());
363
+ Mage::getSingleton('adminhtml/session')->addSuccess(__('Your campaign is now validated and will be sent at') . ' ' . Mage::helper('core')->formatDate($campaignModel->getData('date_send'),'medium',true));
364
+ $campaignModel->save();
365
+ } else {
366
+ Mage::getSingleton('adminhtml/session')->addError($helper_api->get_error_SMS($xml->error_code));
367
+ }
368
+ } else {
369
+ Mage::getSingleton('adminhtml/session')->addError($helper_api->get_error_SMS($xml->error_code));
370
+ }
371
+ } else if ($action == 'sendsms_cancel' && $campaignModel->getData('status') >= 1 && $campaignModel->getData('status') < 3 && !($campaignModel->getData('status') == 3 && time() > $campaignModel->getData('date_send'))) {
372
+ //cancel a campaign if it is possible
373
+ if ($campaignModel->getData('nb_recipients') > 0) {
374
+ $xml = $helper_api->cancel_campaign($campaignModel->getData('ticket'));
375
+ $xml = simplexml_load_string($xml);
376
+ if ($xml->error_code == '000' || intval($xml->error_code) == _ERROR_BATCH_SMS_NOT_FOUND_) {
377
+ $campaignModel->setData('status', 4);
378
+ $campaignModel->save();
379
+ Mage::getSingleton('adminhtml/session')->addSuccess(__('Your campaign is now canceled on octopushsms and can be deleted'));
380
+ } else {
381
+ Mage::getSingleton('adminhtml/session')->addError($helper_api->get_error_SMS($xml->error_code));
382
+ }
383
+ } else {
384
+ $campaignModel->setData('status', 4);
385
+ $campaignModel->save();
386
+ Mage::getSingleton('adminhtml/session')->addSuccess(__('Your campaign is now canceled and can be deleted'));
387
+ }
388
+ } else if ($action == 'sendsms_duplicate' && $campaignModel->getData('id_sendsms_campaign')) {
389
+ //duplicate a campaign
390
+ $newCampaign = Mage::helper('octopushsms/Campaign')->duplicate($campaignModel);
391
+ $campaignModel = $newCampaign;
392
+ Mage::getSingleton('adminhtml/session')->addSuccess(__('Your campaign has been duplicated, you are now working on the new one.'));
393
+ } else if ($action == 'sendsms_delete' && ($campaignModel->getData('status') == 0 || $campaignModel->getData('status') >= 3)) {
394
+ //delete the campaign if it is possible
395
+ $res = $campaignModel->delete();
396
+ if ($res == false) {
397
+ Mage::getSingleton('adminhtml/session')->addError(__('Your campaign can not be deleted.'));
398
+ } else {
399
+ $campaignModel->setData('id_sendsms_campaign', 0);
400
+ Mage::getSingleton('adminhtml/session')->addSuccess(__('Your campaign has been deleted.'));
401
+ $this->_redirect('*/*/campaign');
402
+ return;
403
+ }
404
+ }
405
+ $this->_redirect('*/*/edit', array('id' => $campaignModel->getData('id_sendsms_campaign')));
406
+ }
407
+
408
+ /**
409
+ * Delete a campaign.
410
+ */
411
+ public function deleteAction() {
412
+ if ($this->getRequest()->getParam('id') > 0) {
413
+ try {
414
+ $campaignModel = Mage::getModel('octopushsms/campaign');
415
+ $campaignModel->setId($this->getRequest()
416
+ ->getParam('id'))
417
+ ->delete();
418
+ Mage::getSingleton('adminhtml/session')
419
+ ->addSuccess(__('successfully deleted'));
420
+ $this->_redirect('*/*/');
421
+ } catch (Exception $e) {
422
+ Mage::getSingleton('adminhtml/session')
423
+ ->addError($e->getMessage());
424
+ $this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id')));
425
+ }
426
+ }
427
+ $this->_redirect('*/*/');
428
+ }
429
+
430
+ /**
431
+ * For grid ajax reload
432
+ */
433
+ public function gridAction() {
434
+ $this->loadLayout();
435
+ $this->getResponse()->setBody(
436
+ $this->getLayout()->createBlock('octopushsms/campaign_grid')->toHtml()
437
+ );
438
+ }
439
+
440
+ /**
441
+ * For grid ajax reload
442
+ */
443
+ public function gridRecipientAction() {
444
+ if ($this->getRequest()->getParam('id') > 0) {
445
+ $campaignModel = Mage::getModel('octopushsms/campaign')->load($this->getRequest()->getParam('id'));
446
+ if ($campaignModel->getId()) {
447
+ Mage::register('campaign_data', $campaignModel);
448
+ }
449
+ }
450
+ $this->loadLayout();
451
+ $this->getResponse()->setBody(
452
+ $this->getLayout()->createBlock('octopushsms/recipient_grid')->toHtml()
453
+ );
454
+ }
455
+
456
+ /**
457
+ * For grid ajax reload TODO useful?
458
+ */
459
+ public function deleteRecipientAction() {
460
+ $campaign = null;
461
+ if ($this->getRequest()->getParam('id') > 0) {
462
+ try {
463
+ $recipientModel = Mage::getModel('octopushsms/recipient')->load($this->getRequest()->getParam('id'));
464
+ //get the recipient campaign
465
+ $campaign = Mage::getModel('octopushsms/campaign')->load(intval($recipientModel->getData('id_sendsms_campaign')));
466
+ if ($campaign->getId() && $campaign->getData('status') == 0) {
467
+ $recipientModel->delete();
468
+ Mage::helper('octopushsms/Campaign')->compute_campaign($campaign);
469
+ Mage::getSingleton('adminhtml/session')
470
+ ->addSuccess(__('successfully deleted'));
471
+ } else {
472
+ Mage::getSingleton('adminhtml/session')
473
+ ->addError(__('Internal error: you can\'t delete recipient in campaign in status ' . $campaign->getData('status')));
474
+ }
475
+ } catch (Exception $e) {
476
+ Mage::getSingleton('adminhtml/session')
477
+ ->addError($e->getMessage());
478
+ }
479
+ }
480
+ $this->_redirect('*/*/edit', array('id' => $campaign->getId()));
481
+ }
482
+
483
+ /**
484
+ * Action for all ajax call
485
+ */
486
+ public function ajaxAddRecipientAction() {
487
+ $this->getResponse()->setHeader('Content-type', 'application/json');
488
+ $api = Mage::helper('octopushsms/API');
489
+
490
+ $post = $_REQUEST;
491
+ //$phone = $this->getRequest()->getParam(''phone'];
492
+ $id = $this->getRequest()->getParam('id_sendsms_campaign'); //$this->getRequest()->getParam(''id_sendsms_campaign']
493
+ //TODO remove var_dump($this->getRequest()->getParams()); return;
494
+ $id_customer = $this->getRequest()->getParam('id_customer');
495
+ $phone = $this->getRequest()->getParam('phone');
496
+ $title = $this->getRequest()->getParam('title');
497
+ $iso_country = $this->getRequest()->getParam('iso_country');
498
+ $message = $this->getRequest()->getParam('message');
499
+ $date_send = $this->getRequest()->getParam('date_send');
500
+
501
+ // if phone is not valid
502
+ if (!Zend_Validate::is($phone, 'NotEmpty') || !preg_match('/^\+[0-9]{6,16}$/', $phone)) {
503
+ $errors['error'] = __('That phone number is invalid.');
504
+ $jsonData = Mage::helper('core')->jsonEncode($errors);
505
+ $this->getResponse()->setBody($jsonData);
506
+ return;
507
+ }
508
+
509
+ // if we know the country, try to convert the phone to international
510
+ if ($iso_country) {
511
+ $phone = $api->convert_phone_to_international($phone, $iso_country);
512
+ if (is_null($phone)) {
513
+ $this->getResponse()->setBody(Mage::helper('core')->jsonEncode(array('error' => __('The phone number and the country does not match.'))));
514
+ }
515
+ }
516
+
517
+ if (!$id) {
518
+ $campaign = Mage::getModel('octopushsms/campaign');
519
+ $campaign->setData('ticket', (string) time());
520
+ $campaign->setData('title', ($title == '' ? 'CAMPAIGN-' . $campaign->getData('ticket') : $title));
521
+ $campaign->message = $message;
522
+ //TODO remove $date = strtotime($this->getRequest()->getParam(''sendsms_date'] . ' ' . (int) (isset($this->getRequest()->getParam(''sendsms_date_hour']) ? $this->getRequest()->getParam(''sendsms_date_hour'] : 0) . ':' . (isset($this->getRequest()->getParam(''sendsms_date_minute']) ? $this->getRequest()->getParam(''sendsms_date_minute'] : 0) . ':00');
523
+ if ($date_send)
524
+ $campaign->setData('date_send', $date_send);
525
+ $campaign->save();
526
+ } else {
527
+ $campaign = Mage::getModel('octopushsms/campaign')->load($id);
528
+ }
529
+
530
+ //create recipients
531
+ $recipient = Mage::getModel('octopushsms/recipient');
532
+ $recipient->setData('id_sendsms_campaign', $campaign->getData('id_sendsms_campaign'));
533
+ $recipient->setData('id_customer', $id_customer);
534
+ $recipient->setData('firstname', isset($post['sendsms_firstname']) ? $post['sendsms_firstname'] : '');
535
+ $recipient->setData('lastname', isset($post['sendsms_lastname']) ? $post['sendsms_lastname'] : '');
536
+ if ($recipient->getData('firstname') == '' && isset($post['firstname'])) {
537
+ $recipient->setData('firstname', $post['firstname']);
538
+ }
539
+ if ($recipient->getData('lastname') == '' && isset($post['lastname'])) {
540
+ $recipient->setData('lastname', $post['lastname']);
541
+ }
542
+ $recipient->setData('phone', $phone);
543
+ $recipient->setData('iso_country', $post['iso_country']);
544
+ $recipient->setData('status', 0);
545
+ // can fail if that phone number already exist for that campaign
546
+ try {
547
+ $recipient->save();
548
+ $helperCampaign = Mage::helper('octopushsms/Campaign');
549
+ $helperCampaign->compute_campaign($campaign);
550
+ $jsonData = '{"campaign":' . Zend_Json::encode($campaign) . ',"recipient":' . Zend_Json::encode($recipient) . "}";
551
+ $this->getResponse()->setBody($jsonData);
552
+ return;
553
+ } catch (Exception $e) {
554
+ $jsonData = Mage::helper('core')->jsonEncode(array('error' => __('That phone number is already in the list.')));
555
+ $this->getResponse()->setBody($jsonData);
556
+ return;
557
+ }
558
+ }
559
+
560
+ /**
561
+ * Transmit the campaign on octopush server.
562
+ * @return type
563
+ */
564
+ public function ajaxTransmitOwsAction() {
565
+ $this->getResponse()->setHeader('Content-type', 'application/json');
566
+ if ($this->getRequest()->getParam('id_sendsms_campaign')) {
567
+
568
+ $campaign = Mage::getModel('octopushsms/campaign')->load($this->getRequest()->getParam('id_sendsms_campaign'));
569
+ $helperCampaign = Mage::helper('octopushsms/Campaign');
570
+ $helperAPI = Mage::helper('octopushsms/API');
571
+ //send 200 by 200 recipients
572
+ $result = $helperCampaign->get_recipient_to_transmit($campaign);
573
+ $size = count($result);
574
+ $total_rows = $helperCampaign->get_total_nbr_of_recipient_to_transmit();
575
+ Mage::log('Ajax transmitOWS ' . $size . " " . $total_rows, Zend_Log::DEBUG);
576
+ $finished = false;
577
+ $campaign_can_be_send = false;
578
+ if ((int) $size == (int) $total_rows)
579
+ $finished = true;
580
+
581
+ $error = false;
582
+ $message = false;
583
+ //if there are other recipients to add
584
+ if ($size != 0) {
585
+ //send recipient
586
+ $recipients = array();
587
+ foreach ($result as $recipient) {
588
+ $recipients[$recipient['phone']] = $recipient;
589
+ }
590
+ // call OWS and get XML result
591
+ $xml0 = $helperAPI->send_trame($campaign->getData('ticket'), $recipients, $campaign->getData('message'), $finished);
592
+ $xml = simplexml_load_string($xml0);
593
+ Mage::log('Ajax transmitOWS xml result' . print_r($xml, true), Zend_Log::DEBUG);
594
+
595
+ if ($xml->error_code == '000') {
596
+ // success
597
+ foreach ($xml->successs->success as $success) {
598
+ $phone = (string) $success->recipient;
599
+ $recipients[$phone]['price'] = $success->cost;
600
+ //TODO $recipients[$phone]->nb_sms = $success->sms_needed;
601
+ $recipients[$phone]['status'] = 0;
602
+ $recipients[$phone]['ticket'] = (string) $xml->ticket;
603
+ $recipients[$phone]['transmitted'] = 1;
604
+ $recipients[$phone]['country_code'] = (string) $xml->country_code;
605
+ }
606
+
607
+ // errors
608
+ foreach ($xml->failures->failure as $failure) {
609
+ $phone = (string) $failure->recipient;
610
+ $recipients[$phone]['price'] = 0;
611
+ //TODO $recipients[$phone]->nb_sms = 0;
612
+ $recipients[$phone]['status'] = $failure->error_code;
613
+ $recipients[$phone]['ticket'] = (string) $xml->ticket;
614
+ $recipients[$phone]['transmitted'] = 1;
615
+ $recipients[$phone]['country_code'] = (string) $xml->country_code;
616
+ }
617
+
618
+ // convert recipient to Recipient model
619
+ foreach ($recipients as $key => $recipient) {
620
+ // update th recipient information
621
+ $collectionRecipient = Mage::getModel('octopushsms/recipient')->getCollection();
622
+ $collectionRecipient->addFieldToFilter('phone', $key);
623
+ $collectionRecipient->addFieldToFilter('id_sendsms_campaign', $campaign->getData('id_sendsms_campaign'));
624
+ foreach ($collectionRecipient as $recipientDb) {
625
+ $recipientDb->setData('price', $recipient['price']);
626
+ $recipientDb->setData('status', $recipient['status']);
627
+ $recipientDb->setData('ticket', $recipient['ticket']);
628
+ $recipientDb->setData('iso_country', $recipient['country_code']);
629
+ //TODO country
630
+ $recipientDb->setData('transmitted', $recipient['transmitted']);
631
+ $query = $recipientDb->save();
632
+ Mage::log("save query below: ", Zend_Log::DEBUG); //I get this string
633
+ Mage::log($query->toString(), Zend_Log::DEBUG);
634
+ }
635
+ }
636
+
637
+ // update the campaign totals
638
+ $campaign->setData('date_transmitted', (string) time());
639
+ $helperCampaign->compute_campaign($campaign, 1);
640
+ $campaign->setData('status_label', $helperCampaign->get_status($campaign->getData('status')));
641
+ $message=__('Transfer in progress : ') . ($total_rows - $size) . ' ' . __('recipients left');
642
+ } else {
643
+ $error = $helperAPI->get_error_SMS($xml->error_code);
644
+ }
645
+ }
646
+
647
+ //if there is no more recipient to send, we check the status on octopush
648
+ //if size=0, no more recipients to send, we only have to check the status
649
+ //until octopush finish to do what he has to do
650
+ if (!$error && $finished) {
651
+ $xml0 = $helperAPI->get_campaign_status($campaign->getData('ticket'));
652
+ $xml = simplexml_load_string($xml0);
653
+ if ($xml->error_code == '000') {
654
+ $campaign->setData('status', 2);
655
+ $campaign->setData('status_label', $helperCampaign->get_status($campaign->status));
656
+ $campaign->setData('price', floatval($xml->cost));
657
+ $campaign->save();
658
+ $campaign_can_be_send = true;
659
+ } else if ($xml->error_code == _ERROR_BATCH_SMS_PROSSESSING_) {
660
+ //we wait until octopush finish to build
661
+ sleep(10);
662
+ $message = $helperAPI->get_error_SMS($xml->error_code);
663
+ } else {
664
+ $error = $helperAPI->get_error_SMS($xml->error_code);
665
+ }
666
+ }
667
+ $jsonData = Mage::helper('core')->jsonEncode(array('campaign' => $campaign->getData(), 'finished' => $campaign_can_be_send, 'total_rows' => $total_rows - $size, 'error' => $error, 'message' => $message));
668
+ $this->getResponse()->setBody($jsonData);
669
+ return;
670
+ }
671
+ }
672
+
673
+ public function ajaxCountRecipientFromQueryAction() {
674
+ $campaignId = $this->getRequest()->getParam('id_sendsms_campaign');
675
+ $campaignModel = Mage::getModel('octopushsms/campaign')->load($campaignId);
676
+ $result = Mage::helper('octopushsms/Campaign')->get_recipients_from_query($this, $campaignModel, true);
677
+ $jsonData = Mage::helper('core')->jsonEncode(array('total_rows' => (int) $result));
678
+ $this->getResponse()->setHeader('Content-type', 'application/json');
679
+ $this->getResponse()->setBody($jsonData);
680
+ return;
681
+ }
682
+
683
+ public function ajaxAddRecipientsFromQueryAction() {
684
+ $campaignId = $this->getRequest()->getParam('id_sendsms_campaign');
685
+ if (!$campaignId) {
686
+ $jsonData = Mage::helper('core')->jsonEncode(array('error' => __('campaignId is null.')));
687
+ $this->getResponse()->setHeader('Content-type', 'application/json');
688
+ $this->getResponse()->setBody($jsonData);
689
+ return;
690
+ }
691
+ $campaign = Mage::getModel('octopushsms/campaign')->load($campaignId);
692
+ $collection = Mage::helper('octopushsms/Campaign')->get_recipients_from_query($this, $campaign, false);
693
+
694
+ $cpt = 0;
695
+ $api = Mage::helper('octopushsms/API');
696
+ foreach ($collection as $customer) {
697
+ $recipient = Mage::getModel('octopushsms/recipient');
698
+ $recipient->setData('id_sendsms_campaign', $campaign->getData('id_sendsms_campaign'));
699
+ $recipient->setData('id_customer', $customer->getData('entity_id'));
700
+ $recipient->setData('firstname', $customer->getData('firstname'));
701
+ $recipient->setData('lastname', $customer->getData('lastname'));
702
+ $phone = $api->convert_phone_to_international($customer->getData('billing_telephone'), $customer->getData('billing_country_id'));
703
+ if (is_null($phone))
704
+ continue;
705
+ $recipient->setData('phone', $phone);
706
+ $recipient->setData('iso_country', $customer->getData('billing_country_id'));
707
+ $recipient->setData('status', 0);
708
+ // can fail if that phone number already exist for that campaign
709
+ try {
710
+ $recipient->save();
711
+ $cpt++;
712
+ } catch (Exception $e) {
713
+ //do nothing, we skip this customer
714
+ }
715
+ }
716
+ $helperCampaign = Mage::helper('octopushsms/Campaign');
717
+ $helperCampaign->compute_campaign($campaign);
718
+ $jsonData = Mage::helper('core')->jsonEncode(array('campaign' => Zend_Json::encode($campaign), 'total_rows' => (int) $cpt));
719
+ $this->getResponse()->setBody($jsonData);
720
+ return;
721
+ }
722
+
723
+ /**
724
+ * Action to display news from octopush
725
+ */
726
+ public function newsAction() {
727
+ $this->loadLayout();
728
+ $this->_setActiveMenu('octopushsms/Messages');
729
+ $this->renderLayout();
730
+ }
731
+
732
+ /**
733
+ * Action to display the messages configuration page
734
+ */
735
+ public function messagesAction() {
736
+ $this->loadLayout();
737
+ $this->_setActiveMenu('octopushsms/Messages');
738
+ $this->renderLayout();
739
+ }
740
+
741
+ public function saveMessagesAction() {
742
+ if (!$this->getRequest()->getPost()) {
743
+ $this->_redirect('*/*/');
744
+ }
745
+
746
+ //var_dump($this->getRequest()->getParams());
747
+
748
+ //if clear all messages
749
+ if ($this->getRequest()->getParam('action') == 'clear') {
750
+ $messageHelper = Mage::helper('octopushsms/message');
751
+ //put default text for all messages
752
+ $collection = Mage::getModel('octopushsms/message')->getCollection();
753
+ foreach ($collection as $message) {
754
+ $message->setData('message', $messageHelper->get_sms_default_text_from_message($message));
755
+ $message->save();
756
+ }
757
+ } else {
758
+ //for each post
759
+ foreach ($this->getRequest()->getParams() as $key => $message) {
760
+ if (is_int($key)) {
761
+ //load message from database
762
+ $messageModel = Mage::getModel('octopushsms/message')->load($key);
763
+ if ($messageModel->hasData()) {
764
+ $messageModel->setData('is_active', array_key_exists('isactive', $message));
765
+ $messageModel->setData('message', $message['message']);
766
+ $messageModel->save();
767
+ }
768
+ }
769
+ }
770
+ }
771
+ $this->_redirect('routeradmin/adminhtml_index/messages');
772
+ }
773
+
774
+ }
app/code/local/Octopush/OctopushSms/controllers/IndexController.php ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Octopush_OctopushSms_IndexController extends Mage_Core_Controller_Front_Action {
4
+
5
+ public function indexAction() {
6
+ //echo "toto";
7
+ $this->loadLayout(); //Va chercher les elements à afficher
8
+ $this->renderLayout(); //Affiche les elements
9
+ }
10
+
11
+ public function saveAction() {
12
+ //on recuperes les données envoyées en POST
13
+ $nom = '' . $this->getRequest()->getPost('nom');
14
+ $prenom = '' . $this->getRequest()->getPost('prenom');
15
+ $telephone = '' . $this->getRequest()->getPost('telephone');
16
+ //on verifie que les champs ne sont pas vide
17
+ if (isset($nom) && ($nom != '') && isset($prenom) && ($prenom != '') && isset($telephone) && ($telephone != '')) {
18
+ //on cree notre objet et on l'enregistre en base
19
+ $contact = Mage::getModel('octopushsms/test');
20
+ $contact->setData('nom', $nom);
21
+ $contact->setData('prenom', $prenom);
22
+ $contact->setData('telephone', $telephone);
23
+ $contact->save();
24
+ }
25
+ //on redirige l’utilisateur vers la méthode index du controller indexController
26
+ //de notre module <strong>test</strong>
27
+ $this->_redirect('test/index/index');
28
+ }
29
+
30
+ public function mamethodeAction() {
31
+ echo 'test mamethode';
32
+ }
33
+
34
+ }
app/code/local/Octopush/OctopushSms/etc/config.xml ADDED
@@ -0,0 +1,231 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" ?>
2
+ <!-- Root node for Magento configuration files -->
3
+ <config>
4
+ <!-- modules node provides basic information about the module -->
5
+ <modules>
6
+ <!-- This node's name has to be the same as module's full name
7
+ including namespace -->
8
+ <Octopush_OctopushSms>
9
+ <!-- Current version of module -->
10
+ <version>1.0.0</version>
11
+ </Octopush_OctopushSms>
12
+ </modules>
13
+ <global>
14
+ <helpers>
15
+ <octopushsms>
16
+ <class>Octopush_OctopushSms_Helper</class>
17
+ </octopushsms>
18
+ </helpers>
19
+ <blocks>
20
+ <octopushsms>
21
+ <class>Octopush_OctopushSms_Block</class>
22
+ </octopushsms>
23
+ </blocks>
24
+ <events>
25
+ <adminhtml_customer_save_after>
26
+ <observers>
27
+ <Octopush_OctopushSms_Model_Observer_Createaccount>
28
+ <type>singleton</type>
29
+ <class>octopushsms/observer_observer</class>
30
+ <method>createAccountObserve</method>
31
+ </Octopush_OctopushSms_Model_Observer_Createaccount>
32
+ </observers>
33
+ </adminhtml_customer_save_after>
34
+ <customer_save_after>
35
+ <observers>
36
+ <createaccount>
37
+ <type>singleton</type>
38
+ <class>octopushsms/observer_observer</class>
39
+ <method>createAccountObserve</method>
40
+ </createaccount>
41
+ </observers>
42
+ </customer_save_after>
43
+ <model_save_before>
44
+ <observers>
45
+ <renewpassword>
46
+ <type>singleton</type>
47
+ <class>octopushsms/observer_observer</class>
48
+ <method>forgotPasswordObserve</method>
49
+ </renewpassword>
50
+ </observers>
51
+ </model_save_before>
52
+ <sales_order_save_after>
53
+ <observers>
54
+ <statechange>
55
+ <type>singleton</type>
56
+ <class>octopushsms/observer_observer</class>
57
+ <method>orderStateChangeObserve</method>
58
+ </statechange>
59
+ </observers>
60
+ </sales_order_save_after>
61
+ <sales_order_shipment_track_save_after>
62
+ <observers>
63
+ <shipmenttrack>
64
+ <type>singleton</type>
65
+ <class>octopushsms/observer_observer</class>
66
+ <method>shipmentTrackObserve</method>
67
+ </shipmenttrack>
68
+ </observers>
69
+ </sales_order_shipment_track_save_after>
70
+ <checkout_submit_all_after>
71
+ <observers>
72
+ <lowstock>
73
+ <type>singleton</type>
74
+ <class>octopushsms/observer_observer</class>
75
+ <method>checkoutSubmitAllAfterObserve</method>
76
+ </lowstock>
77
+ </observers>
78
+ </checkout_submit_all_after>
79
+ <controller_action_postdispatch_contacts_index_post>
80
+ <observers>
81
+ <receivemessage>
82
+ <type>singleton</type>
83
+ <class>octopushsms/observer_observer</class>
84
+ <method>controllerActionPostdispatchContactsIndexPostObserve</method>
85
+ </receivemessage>
86
+ </observers>
87
+ </controller_action_postdispatch_contacts_index_post>
88
+ <cataloginventory_stock_item_save_after>
89
+ <observers>
90
+ <alertinstock>
91
+ <class>octopushsms/observer_observer</class>
92
+ <method>checkStockChangeObserve</method>
93
+ </alertinstock>
94
+ </observers>
95
+ </cataloginventory_stock_item_save_after>
96
+ <cataloginventory_stock_item_save_after>
97
+ <observers>
98
+ <lowstock>
99
+ <type>singleton</type>
100
+ <class>octopushsms/observer_observer</class>
101
+ <method>cataloginventoryStockItemSaveAfterObserve</method>
102
+ </lowstock>
103
+ </observers>
104
+ </cataloginventory_stock_item_save_after>
105
+ </events>
106
+ <models>
107
+ <octopushsms>
108
+ <class>Octopush_OctopushSms_Model</class>
109
+ <resourceModel>octopushsms_mysql4</resourceModel>
110
+ </octopushsms>
111
+ <octopushsms_mysql4>
112
+ <class>Octopush_OctopushSms_Model_Mysql4</class>
113
+ <entities>
114
+ <test>
115
+ <table>octopush_test</table>
116
+ </test>
117
+ <setting>
118
+ <table>octopushsms_setting</table>
119
+ </setting>
120
+ <phoneprefix>
121
+ <table>octopushsms_phone_prefix</table>
122
+ </phoneprefix>
123
+ <campaign>
124
+ <table>octopushsms_campaign</table>
125
+ </campaign>
126
+ <recipient>
127
+ <table>octopushsms_recipient</table>
128
+ </recipient>
129
+ <message>
130
+ <table>octopushsms_message</table>
131
+ </message>
132
+ </entities>
133
+ </octopushsms_mysql4>
134
+ </models>
135
+ <!-- permet au module de lire et ecrire -->
136
+ <resources>
137
+ <!-- connection pour ecrire -->
138
+ <octopushsms_write>
139
+ <connection>
140
+ <use>core_write</use>
141
+ </connection>
142
+ </octopushsms_write>
143
+ <!-- connection pour lire-->
144
+ <octopushsms_read>
145
+ <connection>
146
+ <use>core_read</use>
147
+ </connection>
148
+ </octopushsms_read>
149
+ <octopush_octopushsms_setup>
150
+ <setup>
151
+ <module>Octopush_OctopushSms</module>
152
+ </setup>
153
+ </octopush_octopushsms_setup>
154
+ </resources>
155
+ </global>
156
+ <admin>
157
+ <routers>
158
+ <routeradmin>
159
+ <use>admin</use>
160
+ <args>
161
+ <module>Octopush_OctopushSms</module>
162
+ <frontName>adminoctopushsms</frontName>
163
+ </args>
164
+ </routeradmin>
165
+ </routers>
166
+ </admin>
167
+ <adminhtml>
168
+ <layout>
169
+ <updates>
170
+ <octopushsms>
171
+ <file>octopushsms.xml</file>
172
+ </octopushsms>
173
+ </updates>
174
+ </layout>
175
+ <menu>
176
+ <octopushsms translate="title" module="adminhtml">
177
+ <title>Send SMS</title>
178
+ <sort_order>100</sort_order>
179
+ <children>
180
+ <items>
181
+ <title>Messages</title>
182
+ <sort_order>0</sort_order>
183
+ <action>routeradmin/adminhtml_index/messages</action>
184
+ </items>
185
+ <items1>
186
+ <title>Settings</title>
187
+ <sort_order>1</sort_order>
188
+ <action>routeradmin/adminhtml_index/index</action>
189
+ </items1>
190
+ <items2>
191
+ <title>Campaigns</title>
192
+ <sort_order>2</sort_order>
193
+ <action>routeradmin/adminhtml_index/campaign</action>
194
+ </items2>
195
+ <items3>
196
+ <title>History</title>
197
+ <sort_order>3</sort_order>
198
+ <action>routeradmin/adminhtml_index/history</action>
199
+ </items3>
200
+ <items4>
201
+ <title>News</title>
202
+ <sort_order>4</sort_order>
203
+ <action>routeradmin/adminhtml_index/news</action>
204
+ </items4>
205
+ </children>
206
+ </octopushsms>
207
+ </menu>
208
+ <translate>
209
+ <modules>
210
+ <Octopush_OctopushSms>
211
+ <files>
212
+ <default>Octopush_OctopushSms.csv</default>
213
+ </files>
214
+ </Octopush_OctopushSms>
215
+ </modules>
216
+ </translate>
217
+ </adminhtml>
218
+ <crontab>
219
+ <jobs>
220
+ <daily_report_sms>
221
+ <schedule>
222
+ <cron_expr>0 8 * * *</cron_expr>
223
+ </schedule>
224
+ <run>
225
+ <model>octopushsms/observer_observer::dailyReportCron</model>
226
+ </run>
227
+ </daily_report_sms>
228
+ </jobs>
229
+ </crontab>
230
+ </config>
231
+
app/code/local/Octopush/OctopushSms/sql/octopush_octopushsms_setup/install-1.0.0.php ADDED
@@ -0,0 +1,108 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ $installer = $this;
3
+ /* @var $installer Mage_Core_Model_Resource_Setup */
4
+
5
+ $installer->startSetup();
6
+
7
+ $installer->run("
8
+ DROP TABLE IF EXISTS `{$this->getTable('octopushsms_message')}`;
9
+ CREATE TABLE `{$this->getTable('octopushsms_message')}` (
10
+ `id_message` int NOT NULL AUTO_INCREMENT PRIMARY KEY,
11
+ `hook_id` varchar(100) NOT NULL,
12
+ `is_active` int(1) NOT NULL,
13
+ `iso_code` varchar(3) NOT NULL,
14
+ `message` varchar(750) NOT NULL
15
+ ) COMMENT='';
16
+
17
+ DROP TABLE IF EXISTS `{$this->getTable('octopushsms_setting')}`;
18
+ CREATE TABLE IF NOT EXISTS `{$this->getTable('octopushsms_setting')}` (
19
+ `id_octopushsms_setting` int NOT NULL AUTO_INCREMENT PRIMARY KEY,
20
+ `email` varchar(255) NOT NULL,
21
+ `key` varchar(255) NOT NULL,
22
+ `sender` varchar(11) NOT NULL,
23
+ `admin_phone` varchar(50) NOT NULL,
24
+ `free_option` int(1) NOT NULL,
25
+ `id_product` int NOT NULL
26
+ ) ENGINE=InnoDB AUTO_INCREMENT=0 DEFAULT CHARSET=utf8;
27
+
28
+ DROP TABLE IF EXISTS `$this->getTable('octopushsms_campaign')}`;
29
+ CREATE TABLE IF NOT EXISTS `{$this->getTable('octopushsms_campaign')}` (
30
+ id_sendsms_campaign int unsigned NOT NULL auto_increment,
31
+ ticket varchar(255) NOT NULL,
32
+ title varchar(255) default NULL,
33
+ status tinyint(1) unsigned NOT NULL default 0 COMMENT '0=in construction, 1=in transfert, 2=waiting for validation, 3=sent, 4=canceled, 5=error',
34
+ error_code varchar(4) default NULL,
35
+ message text default NULL,
36
+ nb_recipients int unsigned NOT NULL default 0,
37
+ nb_sms int unsigned NOT NULL default 0,
38
+ price double(5,3) NOT NULL default 0,
39
+ event varchar(64) NOT NULL default 'sendsmsFree',
40
+ paid_by_customer tinyint(1) unsigned NOT NULL default 0,
41
+ simulation tinyint(1) unsigned NOT NULL default 0,
42
+ date_send datetime default NULL,
43
+ date_transmitted datetime default NULL,
44
+ date_validation datetime default NULL,
45
+ date_add datetime NOT NULL,
46
+ date_upd datetime NOT NULL,
47
+ PRIMARY KEY (id_sendsms_campaign)
48
+ ) ENGINE=InnoDB AUTO_INCREMENT=0 DEFAULT CHARSET=utf8;
49
+
50
+ DROP TABLE IF EXISTS `{$this->getTable('octopushsms_recipient')}`;
51
+ CREATE TABLE IF NOT EXISTS `{$this->getTable('octopushsms_recipient')}` (
52
+ id_sendsms_recipient int unsigned NOT NULL auto_increment,
53
+ id_sendsms_campaign int unsigned NOT NULL,
54
+ id_customer int unsigned default NULL,
55
+ firstname varchar(32) default NULL,
56
+ lastname varchar(100) default NULL,
57
+ phone varchar(16) NOT NULL,
58
+ iso_country char(2) NULL,
59
+ transmitted tinyint(1) unsigned NOT NULL default 0,
60
+ price double(5,3) NOT NULL default 0,
61
+ nb_sms int unsigned NOT NULL default 0,
62
+ status int unsigned NOT NULL DEFAULT 0,
63
+ ticket varchar(255) default NULL,
64
+ date_add datetime NOT NULL,
65
+ date_upd datetime NOT NULL,
66
+ PRIMARY KEY (id_sendsms_recipient),
67
+ UNIQUE index_unique_phone (id_sendsms_campaign , phone)
68
+ ) ENGINE=InnoDB AUTO_INCREMENT=0 DEFAULT CHARSET=utf8;
69
+
70
+ DROP TABLE IF EXISTS `{$this->getTable('octopushsms_phone_prefix')}`;
71
+ CREATE TABLE `{$this->getTable('octopushsms_phone_prefix')}` (
72
+ iso_code varchar(3) NOT NULL,
73
+ prefix int(10) unsigned DEFAULT NULL,
74
+ PRIMARY KEY (iso_code)
75
+ ) ENGINE=InnoDB AUTO_INCREMENT=0 DEFAULT CHARSET=utf8;
76
+
77
+ INSERT INTO `{$this->getTable('octopushsms_phone_prefix')}` (iso_code, prefix) VALUES
78
+ ('AD', 376),('AE', 971),('AF', 93),('AG', 1268),('AI', 1264),('AL', 355),('AM', 374),('AN', 599),('AO', 244),
79
+ ('AQ', 672),('AR', 54),('AS', 1684),('AT', 43),('AU', 61),('AW', 297),('AX', NULL),('AZ', 994),('BA', 387),
80
+ ('BB', 1246),('BD', 880),('BE', 32),('BF', 226),('BG', 359),('BH', 973),('BI', 257),('BJ', 229),('BL', 590),('BM', 1441),
81
+ ('BN', 673),('BO', 591),('BR', 55),('BS', 1242),('BT', 975),('BV', NULL),('BW', 267),('BY', 375),('BZ', 501),
82
+ ('CA', 1),('CC', 61),('CD', 242),('CF', 236),('CG', 243),('CH', 41),('CI', 225),('CK', 682),('CL', 56),('CM', 237),
83
+ ('CN', 86),('CO', 57),('CR', 506),('CU', 53),('CV', 238),('CX', 61),('CY', 357),('CZ', 420),('DE', 49),('DJ', 253),
84
+ ('DK', 45),('DM', 1767),('DO', 1809),('DZ', 213),('EC', 593),('EE', 372),('EG', 20),('EH', NULL),('ER', 291),('ES', 34),
85
+ ('ET', 251),('FI', 358),('FJ', 679),('FK', 500),('FM', 691),('FO', 298),('FR', 33),('GA', 241),('GB', 44),('GD', 1473),
86
+ ('GE', 995),('GF', 594),('GG', NULL),('GH', 233),('GI', 350),('GL', 299),('GM', 220),('GN', 224),('GP', 590),('GQ', 240),
87
+ ('GR', 30),('GS', NULL),('GT', 502),('GU', 1671),('GW', 245),('GY', 592),('HK', 852),('HM', NULL),('HN', 504),('HR', 385),
88
+ ('HT', 509),('HU', 36),('ID', 62),('IE', 353),('IL', 972),('IM', 44),('IN', 91),('IO', 1284),('IQ', 964),('IR', 98),
89
+ ('IS', 354),('IT', 39),('JE', 44),('JM', 1876),('JO', 962),('JP', 81),('KE', 254),('KG', 996),('KH', 855),('KI', 686),
90
+ ('KM', 269),('KN', 1869),('KP', 850),('KR', 82),('KW', 965),('KY', 1345),('KZ', 7),('LA', 856),('LB', 961),('LC', 1758),
91
+ ('LI', 423),('LK', 94),('LR', 231),('LS', 266),('LT', 370),('LU', 352),('LV', 371),('LY', 218),('MA', 212),('MC', 377),
92
+ ('MD', 373),('ME', 382),('MF', 1599),('MG', 261),('MH', 692),('MK', 389),('ML', 223),('MM', 95),('MN', 976),('MO', 853),
93
+ ('MP', 1670),('MQ', 596),('MR', 222),('MS', 1664),('MT', 356),('MU', 230),('MV', 960),('MW', 265),('MX', 52),('MY', 60),
94
+ ('MZ', 258),('NA', 264),('NC', 687),('NE', 227),('NF', 672),('NG', 234),('NI', 505),('NL', 31),('NO', 47),('NP', 977),
95
+ ('NR', 674),('NU', 683),('NZ', 64),('OM', 968),('PA', 507),('PE', 51),('PF', 689),('PG', 675),('PH', 63),('PK', 92),
96
+ ('PL', 48),('PM', 508),('PN', 870),('PR', 1),('PS', NULL),('PT', 351),('PW', 680),('PY', 595),('QA', 974),('RE', 262),
97
+ ('RO', 40),('RS', 381),('RU', 7),('RW', 250),('SA', 966),('SB', 677),('SC', 248),('SD', 249),('SE', 46),('SG', 65),
98
+ ('SI', 386),('SJ', NULL),('SK', 421),('SL', 232),('SM', 378),('SN', 221),('SO', 252),('SR', 597),('ST', 239),('SV', 503),
99
+ ('SY', 963),('SZ', 268),('TC', 1649),('TD', 235),('TF', NULL),('TG', 228),('TH', 66),('TJ', 992),('TK', 690),('TL', 670),
100
+ ('TM', 993),('TN', 216),('TO', 676),('TR', 90),('TT', 1868),('TV', 688),('TW', 886),('TZ', 255),('UA', 380),('UG', 256),
101
+ ('US', 1),('UY', 598),('UZ', 998),('VA', 379),('VC', 1784),('VE', 58),('VG', 1284),('VI', 1340),('VN', 84),('VU', 678),
102
+ ('WF', 681),('WS', 685),('YE', 967),('YT', 262),('ZA', 27),('ZM', 260),('ZW', 263);
103
+ ");
104
+
105
+ $installer->endSetup();
106
+
107
+
108
+
app/code/local/Octopush/OctopushSms/sql/octopush_octopushsms_setup/mysql4-install-0.1.0 ADDED
@@ -0,0 +1,112 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ <?php
4
+
5
+ $installer = $this;
6
+ /* @var $installer Mage_Core_Model_Resource_Setup */
7
+
8
+ $installer->startSetup();
9
+
10
+ $installer->run("
11
+
12
+ DROP TABLE IF EXISTS `{$this->getTable('octopushsms_message')}`;
13
+ CREATE TABLE `{$this->getTable('octopushsms_message')}` (
14
+ `id_message` int NOT NULL AUTO_INCREMENT PRIMARY KEY,
15
+ `hook_id` varchar(40) NOT NULL,
16
+ `is_active` int(1) NOT NULL,
17
+ `iso_code` varchar(3) NOT NULL,
18
+ `message` varchar(750) NOT NULL
19
+ ) COMMENT='';
20
+
21
+ DROP TABLE IF EXISTS `{$this->getTable('octopushsms_setting')}`;
22
+ CREATE TABLE IF NOT EXISTS `{$this->getTable('octopushsms_setting')}` (
23
+ `id_octopushsms_setting` int NOT NULL AUTO_INCREMENT PRIMARY KEY,
24
+ `email` varchar(255) NOT NULL,
25
+ `key` varchar(255) NOT NULL,
26
+ `sender` varchar(11) NOT NULL,
27
+ `admin_phone` varchar(50) NOT NULL,
28
+ `free_option` int(1) NOT NULL,
29
+ `id_product` int NOT NULL
30
+ ) ENGINE=InnoDB AUTO_INCREMENT=0 DEFAULT CHARSET=utf8;
31
+
32
+ DROP TABLE IF EXISTS `$this->getTable('octopushsms_campaign')}`;
33
+ CREATE TABLE IF NOT EXISTS `{$this->getTable('octopushsms_campaign')}` (
34
+ id_sendsms_campaign int unsigned NOT NULL auto_increment,
35
+ ticket varchar(255) NOT NULL,
36
+ title varchar(255) default NULL,
37
+ status tinyint(1) unsigned NOT NULL default 0 COMMENT '0=in construction, 1=in transfert, 2=waiting for validation, 3=sent, 4=canceled, 5=error',
38
+ error_code varchar(4) default NULL,
39
+ message text default NULL,
40
+ nb_recipients int unsigned NOT NULL default 0,
41
+ nb_sms int unsigned NOT NULL default 0,
42
+ price double(5,3) NOT NULL default 0,
43
+ event varchar(64) NOT NULL default 'sendsmsFree',
44
+ paid_by_customer tinyint(1) unsigned NOT NULL default 0,
45
+ simulation tinyint(1) unsigned NOT NULL default 0,
46
+ date_send datetime default NULL,
47
+ date_transmitted datetime default NULL,
48
+ date_validation datetime default NULL,
49
+ date_add datetime NOT NULL,
50
+ date_upd datetime NOT NULL,
51
+ PRIMARY KEY (id_sendsms_campaign)
52
+ ) ENGINE=InnoDB AUTO_INCREMENT=0 DEFAULT CHARSET=utf8;
53
+
54
+ DROP TABLE IF EXISTS `{$this->getTable('octopushsms_recipient')}`;
55
+ CREATE TABLE IF NOT EXISTS `{$this->getTable('octopushsms_recipient')}` (
56
+ id_sendsms_recipient int unsigned NOT NULL auto_increment,
57
+ id_sendsms_campaign int unsigned NOT NULL,
58
+ id_customer int unsigned default NULL,
59
+ firstname varchar(32) default NULL,
60
+ lastname varchar(100) default NULL,
61
+ phone varchar(16) NOT NULL,
62
+ iso_country char(2) NULL,
63
+ transmitted tinyint(1) unsigned NOT NULL default 0,
64
+ price double(5,3) NOT NULL default 0,
65
+ nb_sms int unsigned NOT NULL default 0,
66
+ status int unsigned NOT NULL DEFAULT 0,
67
+ ticket varchar(255) default NULL,
68
+ date_add datetime NOT NULL,
69
+ date_upd datetime NOT NULL,
70
+ PRIMARY KEY (id_sendsms_recipient),
71
+ UNIQUE index_unique_phone (id_sendsms_campaign , phone)
72
+ ) ENGINE=InnoDB AUTO_INCREMENT=0 DEFAULT CHARSET=utf8;
73
+
74
+ DROP TABLE IF EXISTS `{$this->getTable('octopushsms_phone_prefix')}`;
75
+ CREATE TABLE `{$this->getTable('octopushsms_phone_prefix')}` (
76
+ iso_code varchar(3) NOT NULL,
77
+ prefix int(10) unsigned DEFAULT NULL,
78
+ PRIMARY KEY (iso_code)
79
+ ) ENGINE=InnoDB AUTO_INCREMENT=0 DEFAULT CHARSET=utf8;
80
+
81
+ INSERT INTO `{$this->getTable('octopushsms_phone_prefix')}` (iso_code, prefix) VALUES
82
+ ('AD', 376),('AE', 971),('AF', 93),('AG', 1268),('AI', 1264),('AL', 355),('AM', 374),('AN', 599),('AO', 244),
83
+ ('AQ', 672),('AR', 54),('AS', 1684),('AT', 43),('AU', 61),('AW', 297),('AX', NULL),('AZ', 994),('BA', 387),
84
+ ('BB', 1246),('BD', 880),('BE', 32),('BF', 226),('BG', 359),('BH', 973),('BI', 257),('BJ', 229),('BL', 590),('BM', 1441),
85
+ ('BN', 673),('BO', 591),('BR', 55),('BS', 1242),('BT', 975),('BV', NULL),('BW', 267),('BY', 375),('BZ', 501),
86
+ ('CA', 1),('CC', 61),('CD', 242),('CF', 236),('CG', 243),('CH', 41),('CI', 225),('CK', 682),('CL', 56),('CM', 237),
87
+ ('CN', 86),('CO', 57),('CR', 506),('CU', 53),('CV', 238),('CX', 61),('CY', 357),('CZ', 420),('DE', 49),('DJ', 253),
88
+ ('DK', 45),('DM', 1767),('DO', 1809),('DZ', 213),('EC', 593),('EE', 372),('EG', 20),('EH', NULL),('ER', 291),('ES', 34),
89
+ ('ET', 251),('FI', 358),('FJ', 679),('FK', 500),('FM', 691),('FO', 298),('FR', 33),('GA', 241),('GB', 44),('GD', 1473),
90
+ ('GE', 995),('GF', 594),('GG', NULL),('GH', 233),('GI', 350),('GL', 299),('GM', 220),('GN', 224),('GP', 590),('GQ', 240),
91
+ ('GR', 30),('GS', NULL),('GT', 502),('GU', 1671),('GW', 245),('GY', 592),('HK', 852),('HM', NULL),('HN', 504),('HR', 385),
92
+ ('HT', 509),('HU', 36),('ID', 62),('IE', 353),('IL', 972),('IM', 44),('IN', 91),('IO', 1284),('IQ', 964),('IR', 98),
93
+ ('IS', 354),('IT', 39),('JE', 44),('JM', 1876),('JO', 962),('JP', 81),('KE', 254),('KG', 996),('KH', 855),('KI', 686),
94
+ ('KM', 269),('KN', 1869),('KP', 850),('KR', 82),('KW', 965),('KY', 1345),('KZ', 7),('LA', 856),('LB', 961),('LC', 1758),
95
+ ('LI', 423),('LK', 94),('LR', 231),('LS', 266),('LT', 370),('LU', 352),('LV', 371),('LY', 218),('MA', 212),('MC', 377),
96
+ ('MD', 373),('ME', 382),('MF', 1599),('MG', 261),('MH', 692),('MK', 389),('ML', 223),('MM', 95),('MN', 976),('MO', 853),
97
+ ('MP', 1670),('MQ', 596),('MR', 222),('MS', 1664),('MT', 356),('MU', 230),('MV', 960),('MW', 265),('MX', 52),('MY', 60),
98
+ ('MZ', 258),('NA', 264),('NC', 687),('NE', 227),('NF', 672),('NG', 234),('NI', 505),('NL', 31),('NO', 47),('NP', 977),
99
+ ('NR', 674),('NU', 683),('NZ', 64),('OM', 968),('PA', 507),('PE', 51),('PF', 689),('PG', 675),('PH', 63),('PK', 92),
100
+ ('PL', 48),('PM', 508),('PN', 870),('PR', 1),('PS', NULL),('PT', 351),('PW', 680),('PY', 595),('QA', 974),('RE', 262),
101
+ ('RO', 40),('RS', 381),('RU', 7),('RW', 250),('SA', 966),('SB', 677),('SC', 248),('SD', 249),('SE', 46),('SG', 65),
102
+ ('SI', 386),('SJ', NULL),('SK', 421),('SL', 232),('SM', 378),('SN', 221),('SO', 252),('SR', 597),('ST', 239),('SV', 503),
103
+ ('SY', 963),('SZ', 268),('TC', 1649),('TD', 235),('TF', NULL),('TG', 228),('TH', 66),('TJ', 992),('TK', 690),('TL', 670),
104
+ ('TM', 993),('TN', 216),('TO', 676),('TR', 90),('TT', 1868),('TV', 688),('TW', 886),('TZ', 255),('UA', 380),('UG', 256),
105
+ ('US', 1),('UY', 598),('UZ', 998),('VA', 379),('VC', 1784),('VE', 58),('VG', 1284),('VI', 1340),('VN', 84),('VU', 678),
106
+ ('WF', 681),('WS', 685),('YE', 967),('YT', 262),('ZA', 27),('ZM', 260),('ZW', 263);
107
+ ");
108
+
109
+
110
+
111
+ $installer->endSetup();
112
+
app/code/local/Octopush/OctopushSms/tmp.txt ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
1
+ /home/mathieu/projets/mag/app/design/adminhtml/default/default/template/octopushsms/chooseRecipient.phtml: <h2><span class="dashicons dashicons-search vmiddle"></span><?php echo __('Choose the recipients') ?></h2>
2
+ /home/mathieu/projets/mag/app/design/adminhtml/default/default/template/octopushsms/campaign.phtml: <h2><span class="dashicons dashicons-search vmiddle"></span><?php echo __('Choose the recipients') ?></h2>
3
+ /home/mathieu/projets/mag/app/locale/fr_FR/Octopush_OctopushSms.csv:"Choose the recipients","Choose the recipients"
4
+ /home/mathieu/projets/mag/app/locale/fr_FR/Octopush_OctopushSms.csv:"Choose the recipients","Choose the recipients"
5
+ /home/mathieu/projets/mag/app/locale/fr_FR/Octopush_OctopushSms_1.csv:"Choose the recipients",
6
+ /home/mathieu/projets/mag/app/locale/fr_FR/Octopush_OctopushSms_1.csv:"Choose the recipients",
7
+ /home/mathieu/projets/mag/app/locale/fr_FR/Octopush_OctopushSms_2.csv:"Choose the recipients","Choose the recipients"
8
+ /home/mathieu/projets/mag/app/locale/fr_FR/Octopush_OctopushSms_2.csv:"Choose the recipients","Choose the recipients"
app/design/adminhtml/default/default/layout/octopushsms.xml ADDED
@@ -0,0 +1,78 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" ?>
2
+ <layout version="0.1.0">
3
+ <routeradmin_adminhtml_index_index>
4
+ <reference name="content">
5
+ <block type="octopushsms/setting" name="afficher_setting"
6
+ template="octopushsms/afficher.phtml" />
7
+ </reference>
8
+ </routeradmin_adminhtml_index_index>
9
+ <routeradmin_adminhtml_index_messages>
10
+ <reference name="head">
11
+ <action method="addCss">
12
+ <stylesheet>octopushsms/octopushsms.css</stylesheet>
13
+ </action>
14
+ </reference>
15
+ <reference name="content">
16
+ <block type="octopushsms/messages" name="display_messages"
17
+ template="octopushsms/messages.phtml" />
18
+ </reference>
19
+ </routeradmin_adminhtml_index_messages>
20
+ <routeradmin_adminhtml_index_news>
21
+ <reference name="content">
22
+ <block type="octopushsms/news" name="display_news"
23
+ template="octopushsms/news.phtml" />
24
+ </reference>
25
+ </routeradmin_adminhtml_index_news>
26
+ <routeradmin_adminhtml_index_savesettings>
27
+ <reference name="content">
28
+ <block type="octopushsms/setting" name="afficher_setting"
29
+ template="octopushsms/afficher.phtml" />
30
+ </reference>
31
+ </routeradmin_adminhtml_index_savesettings>
32
+ <routeradmin_adminhtml_index_campaign>
33
+ <reference name="content">
34
+ <block type="octopushsms/campaign_grid" name="campaign" />
35
+ </reference>
36
+ </routeradmin_adminhtml_index_campaign>
37
+ <routeradmin_adminhtml_index_history>
38
+ <reference name="head">
39
+ <action method="addCss">
40
+ <stylesheet>octopushsms/octopushsms.css</stylesheet>
41
+ </action>
42
+ <action method="addCss">
43
+ <stylesheet>octopushsms/grid.css</stylesheet>
44
+ </action>
45
+ </reference>
46
+ <reference name="content">
47
+ <block type="octopushsms/campaign_grid" name="campaign" />
48
+ </reference>
49
+ </routeradmin_adminhtml_index_history>
50
+ <routeradmin_adminhtml_index_edit>
51
+ <reference name="head">
52
+ <action method="addItem">
53
+ <type>js</type>
54
+ <name>lib/jquery/jquery-1.10.2.js</name>
55
+ </action>
56
+ <action method="addItem">
57
+ <type>js</type>
58
+ <name>lib/jquery/noconflict.js</name>
59
+ </action>
60
+ <action method="addItem">
61
+ <type>js</type>
62
+ <name>octopushsms/octopushsms.js</name>
63
+ </action>
64
+ <action method="addCss">
65
+ <stylesheet>octopushsms/octopushsms.css</stylesheet>
66
+ </action>
67
+ <action method="addCss">
68
+ <stylesheet>octopushsms/grid.css</stylesheet>
69
+ </action>
70
+ </reference>
71
+ <reference name="content">
72
+ <block type="octopushsms/campaign_edit_info" name="notice" template="octopushsms/notice.phtml"/>
73
+ <block type="octopushsms/campaign_edit" name="campaign" template="octopushsms/campaign.phtml"/>
74
+ <block type="octopushsms/recipient_grid" name="recipient_grid"/>
75
+ </reference>
76
+ </routeradmin_adminhtml_index_edit>
77
+ </layout>
78
+
app/design/adminhtml/default/default/template/octopushsms/afficher.phtml ADDED
@@ -0,0 +1,194 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Get necessary variable
4
+ */
5
+ $setting = Mage::registry('setting');
6
+ $bAuth = Mage::registry('bAuth');
7
+ $balance = Mage::registry('balance');
8
+ ?>
9
+
10
+ <div class="content-header">
11
+ <table cellspacing="0">
12
+ <tbody><tr>
13
+ <td>
14
+ <h3><?php echo $this->__('Settings'); ?></h3>
15
+ </td>
16
+ <td class="form-buttons"><button id="id_a0cb33c5c7628247e28f74122833c1df" title="Save Config" type="button" class="scalable save" onclick="configForm.submit()" style=""><span><span><span><?php echo $this->__('Save Config'); ?></span></span></span></button></td>
17
+ </tr>
18
+ </tbody></table>
19
+ </div>
20
+
21
+ <table cellspacing="0">
22
+ <tbody>
23
+ <tr>
24
+ <td style="width:80%">
25
+ <?php
26
+ echo $this->getHeadInformation();
27
+ ?>
28
+ </td>
29
+ <td style="width:20%">
30
+ <div class="box" style="margin-left: 1em" >
31
+ <?php if (!$bAuth) { ?>
32
+ <h2><?php echo __('Create your Octopush account'); ?></h2>
33
+ <p><?php echo __('Create your account by clicking on the following image and start sending SMS now to improve your sales !'); ?></p>
34
+ <p class="center"><a href="http://www.octopush.com"><img src="<?php echo Mage::getDesign()->getSkinUrl('images/octopushsms/octopush.png'); ?>" style="margin-top: 15px" alt="Octopush"/></a></p>
35
+ <?php
36
+ } else {
37
+ echo '<h2>' . __('Amount in your account') . '<br><br>' . $balance . ' &euro;</h2>';
38
+ }
39
+ ?>
40
+ </div>
41
+ </td>
42
+ </tr>
43
+ </tbody>
44
+ </table>
45
+
46
+ <form action="<?php echo Mage::getUrl('adminoctopushsms/adminhtml_index/savesettings') ?>" method="post" id="configedit_form" enctype="multipart/form-data">
47
+ <div><input name="form_key" type="hidden" value="<?php echo Mage::getSingleton('core/session')->getFormKey() ?>" /></div>
48
+ <div class="entry-edit">
49
+ <div class="section-config active">
50
+ <div class="entry-edit-head ">
51
+ <a class="open" id="otopush_parameter-head" href="#" onclick="Fieldset.toggleCollapse('otopush_parameter', 'http://localhost/mag/index.php/admin/system_config/state/key/e4f0951783686cbd5eacb79d3f64f677/');
52
+ return false;"><?php echo $this->__('Parameters'); ?></a>
53
+ </div>
54
+ <input id="otopush_parameter-state" name="config_state[otopush_parameter]" value="1" type="hidden">
55
+ <fieldset class="config collapseable" id="otopush_parameter">
56
+ <legend><?php echo $this->__('Parameters'); ?></legend>
57
+ <table class="form-list" cellspacing="0">
58
+ <colgroup class="label"></colgroup>
59
+ <colgroup class="value"></colgroup>
60
+ <colgroup class="scope-label"></colgroup>
61
+ <colgroup class=""></colgroup>
62
+ <tbody>
63
+ <tr id="row_octopush_sms_email">
64
+ <td class="label">
65
+ <label for="octopush_sms_email"><?php echo $this->__('Email'); ?><span class="required">*</span></label>
66
+ </td>
67
+ <td class="value">
68
+ <input id="octopush_sms_email" name="octopush_sms_email" value="<?php echo $setting->getData('email'); ?>" class="input-text required-entry validate-email" type="email">
69
+ </td>
70
+ <td class="scope-label"><?php echo $this->__('You can find it on your Octopush'); ?>
71
+ <a href='http://www.octopush.com/mes-parametres' target='_blank'><?php echo $this->__('Personal Data'); ?></a></td>
72
+ <td class=""></td>
73
+ </tr>
74
+ <tr id="row_octopush_sms_key">
75
+ <td class="label">
76
+ <label for="octopush_sms_key"><?php echo $this->__('Key Octopush'); ?><span class="required">*</span></label>
77
+ </td>
78
+ <td class="value">
79
+ <input id="octopush_sms_key" name="octopush_sms_key" value="<?php echo $setting->getData('key'); ?>" class=" input-text" type="text" maxlength="255">
80
+ </td>
81
+ <td class="scope-label"></td>
82
+ <td class=""></td>
83
+ </tr>
84
+ <tr id="octopush_sms_admin_phone">
85
+ <td class="label">
86
+ <label for="octopush_sms_admin_phone"><?php echo $this->__('Admin mobile number'); ?><span class="required">*</span></label>
87
+ </td>
88
+ <td class="value">
89
+ <input id="octopush_sms_admin_phone" name="octopush_sms_admin_phone" value="<?php echo $setting->getData('admin_phone'); ?>" class="input-text required-entry validate-phoneOctopush" type="text" maxlength="15">
90
+ </td>
91
+ <td class="scope-label"><?php echo $this->__('ex : +33612345678'); ?></td>
92
+ <td class=""></td>
93
+ </tr>
94
+ <tr id="octopush_sms_sender">
95
+ <td class="label">
96
+ <label for="octopush_sms_sender"><?php echo $this->__('Sender name'); ?></label>
97
+ </td>
98
+ <td class="value">
99
+ <input id="octopush_sms_sender" name="octopush_sms_sender" value="<?php echo $setting->getData('sender'); ?>" class="input-text validate-length" type="text" maxlength="11">
100
+ </td>
101
+ <td class="scope-label"><?php echo $this->__('11 characters maximum'); ?></td>
102
+ <td class=""></td>
103
+ </tr>
104
+ <tr id="octopush_sms_admin_alert">
105
+ <td class="label">
106
+ <label for="octopush_sms_admin_alert"><?php echo $this->__('Send an alert when your account is under'); ?></label>
107
+ </td>
108
+ <td class="value">
109
+ <input id="octopush_sms_admin_alert" name="octopush_sms_admin_alert" value="<?php echo $setting->getData('admin_alert'); ?>" class="input-text validate-number" type="text" maxlength="5">
110
+ </td>
111
+ <td class="scope-label"></td>
112
+ <td class=""></td>
113
+ </tr>
114
+
115
+ <tr id="octopush_sms_free_option">
116
+ <td class="label">
117
+ <label for="octopush_sms_free_option"><?php echo $this->__('Notification status order free'); ?></label>
118
+ </td>
119
+ <td class="value">
120
+ <label for="octopush_sms_free_option_1"> <?php echo $this->__('Yes'); ?> </label>
121
+ <input id="octopush_sms_free_option_1" name="octopush_sms_free_option"
122
+ value="1" class="input-radio"
123
+ type="radio" onClick="Element.hide('octopush_sms_id_product');"
124
+ <?php if ((int) $setting->getData('free_option') == 1) echo 'checked'; ?>
125
+ >
126
+ <label for="octopush_sms_free_option_0"> <?php echo $this->__('No'); ?> </label>
127
+ <input
128
+ name="octopush_sms_free_option"
129
+ id="octopush_sms_free_option_0"
130
+ type="radio"
131
+ class="input-radio"
132
+ <?php if ((int) $setting->getData('free_option') == 0) echo 'checked'; ?>
133
+ value="0"
134
+ onClick="Element.show('octopush_sms_id_product');"
135
+ />
136
+ </td>
137
+ <td class="scope-label"></td>
138
+ <td class=""></td>
139
+ </tr>
140
+ <tr id="octopush_sms_id_product" <?php if ((int) (int) $setting->getData('free_option') == 1) echo ' style="display:none" '; ?>>
141
+ <td class="label">
142
+ <label for="octopush_sms_id_product"><?php echo $this->__('SMS notification product ID'); ?></label>
143
+ </td>
144
+ <td class="value">
145
+ <input id="octopush_sms_admin_alert" name="octopush_sms_id_product" value="<?php echo $setting->getData('id_product'); ?>" class="input-text validate-number" type="text" maxlength="5">
146
+ </td>
147
+ <td class="scope-label"><?php echo $this->__('Enter a valid product id.'); ?></td>
148
+ <td class=""></td>
149
+ </tr>
150
+ </tbody>
151
+ </table>
152
+ </fieldset>
153
+ </div>
154
+ </div>
155
+ </form>
156
+ <script type="text/javascript">
157
+ //<![CDATA[
158
+ /*Validation.add('validate-phoneOctopush', '<?php echo $this->__('TODOPlease enter a valid phone number. For example +33612345678.'); ?>', function (v) {
159
+ return Validation.get('IsEmpty').test(v) || /^([a-zA-Z0-9]+[a-zA-Z0-9._%-]*@gmail\.com)$/i.test(v)
160
+ });*/
161
+ var configForm = new varienForm('configedit_form');
162
+
163
+ //]]>
164
+ </script>
165
+ <div class="entry-edit">
166
+ <div class="section-config active">
167
+ <div class="entry-edit-head ">
168
+ <a class="open" id="octopush_information-head" href="#" onclick="Fieldset.toggleCollapse('octopush_information', 'http://localhost/mag/index.php/admin/system_config/state/key/e4f0951783686cbd5eacb79d3f64f677/');
169
+ return false;"><?php echo $this->__('Informations'); ?></a>
170
+ </div>
171
+ <input id="octopush_information-state" name="config_state[octopush_information]" value="1" type="hidden">
172
+ <fieldset class="config collapseable" id="octopush_information">
173
+ <p class="clear">
174
+ <?php echo __('Standard message is divided in 160 chars long parts and each part cost 1 SMS, if all chars are in list below. If one or more chars are not in this list, then message is divided in 70 chars parts, and each part cost 1 SMS. You can see if your message will be divided in 70 chars long parts in the "Manage message" tab and which char is not supported in standard.'); ?>
175
+ </p>
176
+ <p>
177
+ <br><b><?php echo __('Before applying mentioned rule, these characters are automatically replaced'); ?></b>
178
+ <br/>
179
+ <div style="float: left; width: 130px"><?php echo __('Original character'); ?></div>: À Á Â Ã È Ê Ë Ì Í Î Ï Ð Ò Ó Ô Õ Ù Ú Û Ý Ÿ á â ã ê ë í î ï ð ó ô õ ú û µ ý ÿ ç Þ ° ¨ ^ « » | \
180
+ <br style="clear: both"/><div style="float: left; width: 130px"><?php echo __('Replaced by'); ?></div>: A A A A E E E I I I I D O O O O U U U Y Y a a a e e i i i o o o o u u u y y c y o - - " " I /
181
+ </p>
182
+ <p class="clear">
183
+ <br><b><?php echo __('Authorized characters'); ?></b>
184
+ <br/>0 1 2 3 4 5 6 7 8 9
185
+ <br/>a A b B c C d D e E f F g G h H i I j J k K l L m M n N o O p P q Q r R s S t T u U v V w W x X y Y z Z
186
+ <br/>à À á Á â Â ã Ã ä Ä å Å æ Æ ç Ç è È ê Ê ë Ë é É ì Ì í Í î Î ï Ï ð Ð ñ Ñ ò Ò ó Ó ô Ô õ Õ ö Ö ø Ø ù Ù ú Ú û Û ü Ü ÿ Ÿ ý Ý Þ ß
187
+ <br/>{ } ~ ¤ ¡ ¿ ! ? " # $ % & \' ^ * + - _ , . / : ; < = > § @ ( ) [ ]
188
+ <!--<br/>Γ Δ Θ Λ Ξ Π Σ Φ Ψ Ω € £ ¥-->
189
+ <br/><br/><?php echo __('These chars count as 2 chars :'); ?> { } € [ ] ~
190
+ </p>
191
+ </fieldset>
192
+ </div>
193
+ <?php
194
+ //echo $this->methodblock();
app/design/adminhtml/default/default/template/octopushsms/ajax.phtml ADDED
@@ -0,0 +1 @@
 
1
+ ok
app/design/adminhtml/default/default/template/octopushsms/campaign.phtml ADDED
@@ -0,0 +1,321 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php ?>
2
+ <div id="campaign_id">
3
+
4
+ <style type="text/css">
5
+ #post-body-content, #titlediv, #major-publishing-actions, #minor-publishing-actions, #visibility, #submitdiv { display:none }
6
+ </style>
7
+
8
+ <?php $this->output_button(); ?>
9
+
10
+ <form action="<?php echo Mage::getUrl('adminoctopushsms/adminhtml_index/saveCampaign') ?>" method="post" id="sendsms_form" enctype="multipart/form-data">
11
+ <div><input id="form_key" name="form_key" type="hidden" value="<?php echo Mage::getSingleton('core/session')->getFormKey() ?>" /></div>
12
+ <input type="hidden" id="action" name="action" value="<?php echo $this->getRequest()->getActionName(); ?>"/>
13
+ <input type="hidden" id="id_sendsms_campaign" name="id_sendsms_campaign" value="<?php echo $this->campaign->getData('id_sendsms_campaign'); ?>"/>
14
+ <input type="hidden" id="current_status" value="<?php echo $this->campaign->getData('status') ?>"/>
15
+ <input type="hidden" id="button_id" name="button_id" value=""/>
16
+
17
+ <div id="poststuff">
18
+ <div class="toastgrid">
19
+ <div class="toastgrid__col toastgrid__col--3-of-5">
20
+ <div class="box">
21
+ <h2><span class="dashicons dashicons-admin-settings vmiddle"></span><span><?php echo ($this->campaign->getData('status') == 0 ? __('SMS Settings') : __('SMS Details')) ?></span></h2>
22
+
23
+ <?php
24
+ if (!$this->b_auth) {
25
+ echo '<span class="failed> ' . __('Before sending a message, you have to enter your account information in the Settings Tab.') . '</span><br/><br/>';
26
+ } else {
27
+ echo '';
28
+ }
29
+ ?>
30
+
31
+ <!-- campaign title -->
32
+ <p class="form-field form-field-wide">
33
+ <label for="sendsms_title"><?php echo __('Title of the campaign') ?></label><br/>
34
+ <input type="text" id="title" name="title" maxlength="255" class="required-entry input-text" type="text" value="<?php echo htmlentities($this->campaign->getData('title'), ENT_QUOTES, 'utf-8'); ?>" />
35
+ </p>
36
+
37
+
38
+ <!-- campaign message-->
39
+ <p class="form-field form-field-wide">
40
+ <label for="message"><?php echo __('Message') ?></label><br/>
41
+ <textarea class="required-entry"
42
+ <?php echo ($this->campaign->getData('status') == 0 ? '' : 'readonly') ?>
43
+ rows="5" cols="50" name="message"><?php echo htmlentities($this->campaign->getData('message'), ENT_QUOTES, 'utf-8'); ?></textarea>
44
+ <br/><?php echo __('Variables you can use : {firstname}, {lastname}'); ?>
45
+ </p>
46
+
47
+ <!-- campaign date -->
48
+ <!-- TODO non editable en fonction du statut $this->campaign->getData('status') < 2 -->
49
+ <p class="form-field form-field-wide"><label for="sendsms_date"><?php echo __('Send date') ?></label><br/>
50
+ <input name="date_send" id="date_send" value="<?php echo $this->campaign->getData('date_send'); ?>" class="required-entry input-text" style="width:110px !important;" type="text">
51
+ <img src="<?php echo Mage::getDesign()->getSkinUrl('/images/grid-cal.gif'); ?>" alt="" class="v-middle" id="date_send_trig" title="Select Date" style="">
52
+ <script type="text/javascript">
53
+ //<![CDATA[
54
+ Calendar.setup({
55
+ inputField: "date_send",
56
+ ifFormat: "%Y-%m-%d %H:%M:%S",
57
+ showsTime: true,
58
+ button: "date_send_trig",
59
+ align: "Bl",
60
+ singleClick: true
61
+ });
62
+ //]]>
63
+ </script>
64
+ </p>
65
+ </div>
66
+ </div>
67
+ <div class="toastgrid__col toastgrid__col--2-of-5">
68
+ <?php $this->output_campaign_details(); ?>
69
+ </div>
70
+ </div>
71
+ </div>
72
+
73
+ <?php
74
+ //choose_recipient
75
+ if ($this->campaign->getData('status') == 0) {
76
+ ?>
77
+ <div class="poststuff">
78
+ <div id="sendsms_choose_recipient" class="box">
79
+ <h2><span class="dashicons dashicons-search vmiddle"></span><?php echo __('Choose recipients') ?></h2>
80
+ <div><h3><span class="dashicons dashicons-info vmiddle"></span><?php echo __('4 methods to choose your recipients') ?></h3></div>
81
+
82
+
83
+ <table class="form-table">
84
+
85
+ <tbody>
86
+ <tr valign="top">
87
+ <th scope="row" class="titledesc">
88
+ <label for="sendsms_recipient"><span class="dashicons dashicons-arrow-right"></span><?php echo __('Enter your recipient details') ?></label>
89
+ </th>
90
+ <td class="forminp">
91
+ <div class="toastgrid">
92
+ <div class="toastgrid__col toastgrid__col--3-of-10">
93
+ <input placeholder="<?php echo __('Phone (international e.g: +33612345678)') ?>" type="text" size="30" maxlength="16" name="sendsms_phone" id="sendsms_phone" />
94
+ </div>
95
+ <div class="toastgrid__col toastgrid__col--3-of-10">
96
+ <input placeholder="<?php echo __('Firstname (optional)') ?>" type="text" size="30" maxlength="32" name="sendsms_firstname" id="sendsms_firstname" />
97
+ </div>
98
+ <div class="toastgrid__col toastgrid__col--3-of-10">
99
+ <input placeholder="<?php echo __('Lastname (optional)') ?>" type="text" size="30" maxlength="32" name="sendsms_lastname" id="sendsms_lastname" />
100
+ </div>
101
+ <div class="toastgrid__col toastgrid__col--1-of-10">
102
+ <span id="add_recipient"><img src="<?php echo Mage::getDesign()->getSkinUrl('images/add_btn_icon.gif'); ?>"/></span>
103
+ </div>
104
+ </div>
105
+ </td>
106
+ </tr>
107
+
108
+ <tr valign="top">
109
+ <th scope="row" class="titledesc">
110
+ <label for="sendsms_customer"><span class="dashicons dashicons-arrow-right"></span><?php echo __('Or search for customers') ?></label>
111
+ </th>
112
+ <td class="forminp forminp-select">
113
+ <div>
114
+ <input type="text" size="30" id="sendsms_customer_filter" name="q" value="" /> <?php echo __('Search will be applied on phone, id_customer, firstname, lastname') ?>
115
+ <div id="search_customer_autocomplete" class="octopushsms-autocomplete" ></div>
116
+ </div>
117
+ </td>
118
+ </tr>
119
+
120
+ <!-- <form id="search_customer_form" action="<?php echo Mage::helper("adminhtml")->getUrl('adminoctopushsms/adminhtml_index/ajaxFilterCustomer/') ?>" method="get">-->
121
+ <div class="form-search">
122
+ <button type="submit" style="display:none" title="<?php echo $this->__('Search') ?>" class="button"><span><span><?php echo $this->__('Search') ?></span></span></button>
123
+ <script type="text/javascript">
124
+ //<![CDATA[
125
+ var searchForm = new Octopushsms.searchForm('sendsms_form', 'sendsms_customer_filter', '<?php echo $this->__('Search') ?>');
126
+ searchForm.initAutocomplete('<?php echo Mage::helper("adminhtml")->getUrl('adminoctopushsms/adminhtml_index/ajaxFilterCustomer/') ?>', 'search_customer_autocomplete');
127
+ //]]>
128
+ </script>
129
+ </div>
130
+ <!--</form>-->
131
+
132
+ <tr valign="top" class="">
133
+ <th scope="row" class="titledesc"><span class="dashicons dashicons-arrow-right"></span><?php echo __('Or upload a CSV file') ?></th>
134
+ <td class="forminp forminp-checkbox" >
135
+ <input id="sendsms_csv" type="file" name="sendsms_csv" />
136
+ <span class="plus" id="add_csv"><img src="<?php echo Mage::getDesign()->getSkinUrl('images/add_btn_icon.gif'); ?>"/></span>
137
+ <br/>
138
+ <?php echo __('Phone in 1st column (international format), Firstname in 2nd (optional), Lastname in 3rd (optional)') ?>
139
+ <a href="<?php echo Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA) . 'octopushsms/' ?>example.csv"><?php echo __('See example') ?></a>
140
+ </td>
141
+ </tr>
142
+ <tr valign="top" >
143
+ <th scope="row" class="titledesc">
144
+ <label for="woocommerce_demo_store_notice"><span class="dashicons dashicons-arrow-right"></span><?php echo __('Or create your own Query') ?></label>
145
+ </th>
146
+ <td class="forminp forminp-text" id="sendsms_query">
147
+ <div>
148
+ <div style="display:block;float:left">
149
+ <!-- choose a country -->
150
+ <?php $_countries = Mage::getResourceModel('directory/country_collection')->loadByStore()->toOptionArray(false)
151
+ ?>
152
+ <?php if (count($_countries) > 0): ?>
153
+ <select name="sendsms_query_country" id="sendsms_query_country" class="">
154
+ <option value="*"><?php echo __('-- All countries --'); ?></option>
155
+ <?php foreach ($_countries as $_country): ?>
156
+ <option value="<?php echo $_country['value'] ?>">
157
+ <?php echo $_country['label'] ?>
158
+ </option>
159
+ <?php endforeach; ?>
160
+ </select>
161
+ <?php endif; ?>
162
+
163
+ <select name="sendsms_query_shop">
164
+ <option value="*"><?php echo $this->__('-- All stores --') ?></option>
165
+ <?php
166
+ $allStores = Mage::app()->getStores();
167
+ foreach ($allStores as $store) {
168
+ echo '<option value="' . $store->getData('entity_id') . '">' . $store->getName() . '</option>';
169
+ }
170
+ ?>
171
+ </select>
172
+
173
+ <select name="sendsms_query_group">
174
+ <option value="*"><?php echo $this->__('-- All groups --') ?></option>
175
+ <?php
176
+ $groups = Mage::getResourceModel('customer/group_collection')
177
+ ->addFieldToFilter('customer_group_id', array('gt' => 0))
178
+ ->load();
179
+ foreach ($groups as $group) {
180
+ echo '<option value="' . $group->getId() . '">' . $group->getCode() . '</option>';
181
+ }
182
+ ?>
183
+ </select>
184
+ <select name="sendsms_query_newsletter">
185
+ <option value=""><?php echo $this->__('-- Newsletter --') ?></option>
186
+ <option value="1"><?php echo $this->__('Yes') ?></option>
187
+ <option value="0"><?php echo $this->__('No') ?></option>
188
+ </select>
189
+
190
+ <br />
191
+ <span class="filter_label"><?php echo __('Registered') ?></span> <?php echo __('From') ?> <input type="text" class="datepicker" id="sendsms_query_registered_from" name="sendsms_query_registered_from" size="10" maxlength="10" />
192
+ <?php echo __('To') ?> <input type="text" class="datepicker" id="sendsms_query_registered_to" name="sendsms_query_registered_to" size="10" maxlength="10" />
193
+ <span class="filter_label"><?php echo __('Ignore years') ?></span> <input type="checkbox" name="sendsms_query_registered_years" value="1" /><br>
194
+
195
+ <script type="text/javascript">
196
+ //<![CDATA[
197
+ Calendar.setup({
198
+ inputField: "sendsms_query_registered_from",
199
+ ifFormat: "%Y-%m-%d",
200
+ showsTime: false,
201
+ button: "sendsms_query_registered_from",
202
+ align: "Bl",
203
+ singleClick: true
204
+ });
205
+ Calendar.setup({
206
+ inputField: "sendsms_query_registered_to",
207
+ ifFormat: "%Y-%m-%d",
208
+ showsTime: false,
209
+ button: "sendsms_query_registered_to",
210
+ align: "Bl",
211
+ singleClick: true
212
+ });
213
+ //]]>
214
+ </script>
215
+
216
+ <span class="filter_label"><?php echo __('Connected') ?></span> <?php echo __('From') ?> <input type="text" class="datepicker" id="sendsms_query_connected_from" name="sendsms_query_connected_from" size="10" maxlength="10" />
217
+ <?php echo __('To') ?> <input type="text" class="datepicker" id="sendsms_query_connected_to" name="sendsms_query_connected_to" size="10" maxlength="10" />
218
+ <span class="filter_label"><?php echo __('Ignore years') ?></span> <input type="checkbox" name="sendsms_query_connected_years" value="1" /><br>
219
+ <script type="text/javascript">
220
+ //<![CDATA[
221
+ Calendar.setup({
222
+ inputField: "sendsms_query_connected_from",
223
+ ifFormat: "%Y-%m-%d",
224
+ showsTime: false,
225
+ button: "sendsms_query_connected_from",
226
+ align: "Bl",
227
+ singleClick: true
228
+ });
229
+ Calendar.setup({
230
+ inputField: "sendsms_query_connected_to",
231
+ ifFormat: "%Y-%m-%d",
232
+ showsTime: false,
233
+ button: "sendsms_query_connected_to",
234
+ align: "Bl",
235
+ singleClick: true
236
+ });
237
+ //]]>
238
+ </script>
239
+
240
+ <span class="filter_label"><?php echo __('Birthday') ?></span> <?php echo __('From') ?> <input type="text" class="datepicker" id="sendsms_query_birthday_from" name="sendsms_query_birthday_from" size="10" maxlength="10" />
241
+ <?php echo __('To') ?> <input type="text" class="datepicker" id="sendsms_query_birthday_to" name="sendsms_query_birthday_to" size="10" maxlength="10" />
242
+ <span class="filter_label"><?php echo __('Ignore years') ?></span> <input type="checkbox" name="sendsms_query_birthday_years" value="1" /><br>
243
+ <script type="text/javascript">
244
+ //<![CDATA[
245
+ Calendar.setup({
246
+ inputField: "sendsms_query_birthday_from",
247
+ ifFormat: "%Y-%m-%d",
248
+ showsTime: false,
249
+ button: "sendsms_query_birthday_from",
250
+ align: "Bl",
251
+ singleClick: true
252
+ });
253
+ Calendar.setup({
254
+ inputField: "sendsms_query_birthday_to",
255
+ ifFormat: "%Y-%m-%d",
256
+ showsTime: false,
257
+ button: "sendsms_query_birthday_to",
258
+ align: "Bl",
259
+ singleClick: true
260
+ });
261
+ //]]>
262
+ </script>
263
+ <!-- -->
264
+
265
+ <span class="filter_label"><?php echo __('Number of orders') ?></span> <?php echo __('From') ?> <input type="text" id="sendsms_query_orders_from" id="sendsms_query_orders_from" name="sendsms_query_orders_from" size="10" maxlength="10" />
266
+ <?php echo __('To') ?> <input type="text" id="sendsms_query_orders_to" name="sendsms_query_orders_to" size="10" maxlength="10" />
267
+ <span class="filter_label"><?php echo __('Or no order') ?></span> <input type="checkbox" id="sendsms_query_orders_none" id="sendsms_query_orders_none" name="sendsms_query_orders_none" value="1" />
268
+ </div>
269
+ <div style="display:block;float:left">
270
+ <span id="sendsms_query_result"></span> <?php echo __('customer(s) found') ?> <span id="sendsms_query_add" title="<?php echo __('Add') ?>"><img src="<?php echo Mage::getDesign()->getSkinUrl('images/add_btn_icon.gif'); ?>"/></span>
271
+ </div>
272
+ </div>
273
+ </td>
274
+
275
+
276
+ </tr>
277
+ </tbody>
278
+ </table>
279
+ <?php if ($this->campaign->getData('status') == 0) { ?>
280
+ <div style="line-height:30px"><span class="dashicons dashicons-info"></span> <?php echo __('All doublons will be automatically removed') ?></div>
281
+ <?php } ?>
282
+
283
+ </div>
284
+ </div>
285
+ <?php } ?>
286
+
287
+ <?php
288
+ $jsScript = '';
289
+
290
+ if ($this->campaign->getData('status') == 0) {
291
+ $jsScript .= '
292
+ var sendsms_msg_delRecipient = "' . __('Deleting recipient.') . '";
293
+ var sendsms_error_phone_invalid = "' . __('That phone number is invalid.') . '";
294
+ var sendsms_error_csv = "' . __('Please choose a valid CSV file') . '";
295
+ var sendsms_error_orders = "' . __('That number must be greater or equal to 1') . '";
296
+ var sendsms_confirm_cancel = "' . __('Are you sure you want to cancel that campaign ?') . '";
297
+ var sendsms_confirm_delete = "' . __('Are you sure you want to delete that campaign ?') . '";';
298
+ }
299
+ $jsScript .= '
300
+ var campaignForm = new varienForm("sendsms_form");
301
+ //var searchForm = new Varien.searchForm("search_customer_form", "sendsms_customer_filter", "Search entire store here...");
302
+ //searchForm.initAutocomplete(\'' . Mage::helper("adminhtml")->getUrl('adminoctopushsms/adminhtml_index/ajaxFilterCustomer/') . '\', \'search_autocomplete\');
303
+ $j(document).ready(function() {
304
+ var ajaxurl = "' . Mage::getUrl('adminoctopushsms/adminhtml_index/') . '";
305
+ initTab(ajaxurl);
306
+ initButtons(true); ';
307
+
308
+
309
+ //transmit to ocopush via ajax if it is necessary
310
+ if ($this->getRequest()->getActionName() == 'edit' && $this->campaign->getData('status') == 1 && !sizeof($this->campaign->getErrors())) {
311
+ $jsScript .= 'Octopushsms.showWaiting("' . __('Transfer in progress : ') . $this->campaign->getData('nb_recipients') . ' ' . __('recipients left') . '");';
312
+ $jsScript .= 'transmitToOWS();';
313
+ }
314
+ $jsScript .= '});';
315
+
316
+ echo '<script type="text/javascript">' . $jsScript . '</script>';
317
+ echo "<br/>";
318
+ ?>
319
+ </form>
320
+
321
+
app/design/adminhtml/default/default/template/octopushsms/chooseRecipient.phtml ADDED
@@ -0,0 +1,113 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ if ($this->campaignModel->getData('status') == 0) {
3
+ ?>
4
+ <div class="poststuff">
5
+ <div id="sendsms_choose_recipient" class="postbox">
6
+ <h2><span class="dashicons dashicons-search vmiddle"></span><?php echo __('Choose recipients') ?></h2>
7
+ <div><h3><span class="dashicons dashicons-info vmiddle"></span><?php echo __('4 methods to choose your recipients') ?></h3></div>
8
+
9
+
10
+ <table class="form-table">
11
+
12
+ <tbody>
13
+ <tr valign="top">
14
+ <th scope="row" class="titledesc">
15
+ <label for="sendsms_recipient"><span class="dashicons dashicons-arrow-right"></span><?php echo __('Enter your recipient details') ?></label>
16
+ </th>
17
+ <td class="forminp" style="width:80%">
18
+ <input placeholder="<?php echo __('Phone (international e.g: +33612345678)') ?>" type="text" size="30" maxlength="16" name="sendsms_phone" id="sendsms_phone" />
19
+ <input placeholder="<?php echo __('Firstname (optional)') ?>" type="text" size="30" maxlength="32" name="sendsms_firstname" id="sendsms_firstname" /></div>
20
+ <input placeholder="<?php echo __('Lastname (optional)') ?>" type="text" size="30" maxlength="32" name="sendsms_lastname" id="sendsms_lastname" /></div>
21
+ <span id="add_recipient"><img src="<?php echo Mage::getDesign()->getSkinUrl('images/add_btn_icon.gif'); ?>"/></span>
22
+ </td>
23
+ </tr>
24
+ <tr valign="top">
25
+ <th scope="row" class="titledesc">
26
+ <label for="sendsms_customer"><span class="dashicons dashicons-arrow-right"></span><?php echo __('Or search for customers') ?></label>
27
+ </th>
28
+ <td class="forminp forminp-select">
29
+ <input type="text" size="30" id="sendsms_customer_filter" value="" /> <?php echo __('Search will be applied on phone, id_customer, firstname, lastname') ?>
30
+ </td>
31
+ </tr>
32
+ <tr valign="top" class="">
33
+ <th scope="row" class="titledesc"><span class="dashicons dashicons-arrow-right"></span><?php echo __('Or upload a CSV file') ?></th>
34
+ <td class="forminp forminp-checkbox" >
35
+ <input id="sendsms_csv" type="file" name="sendsms_csv" />
36
+ <span class="plus" id="add_csv"><img src="<?php echo Mage::getDesign()->getSkinUrl('images/add_btn_icon.gif'); ?>"/></span>
37
+ <br/>
38
+ <?php echo __('Phone in 1st column (international format), Firstname in 2nd (optional), Lastname in 3rd (optional)') ?>
39
+ <a href="<?php echo Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA) . 'octopushsms/' ?>example.csv"><?php echo __('See example') ?></a>
40
+ </td>
41
+ </tr>
42
+ <tr valign="top" >
43
+ <th scope="row" class="titledesc">
44
+ <label for="woocommerce_demo_store_notice"><span class="dashicons dashicons-arrow-right"></span><?php echo __('Or create your own Query') ?></label>
45
+ </th>
46
+ <td class="forminp forminp-text" id="sendsms_query">
47
+ <div>
48
+ <div style="display:block;float:left">
49
+ <!-- choose a country -->
50
+ <?php $_countries = Mage::getResourceModel('directory/country_collection')->loadByStore()->toOptionArray(false)
51
+ ?>
52
+ <?php if (count($_countries) > 0): ?>
53
+ <select name="sendsms_query_country" id="sendsms_query_country" class="validate-select">
54
+ <option value=""><?php echo __('-- All countries --'); ?></option>
55
+ <?php foreach ($_countries as $_country): ?>
56
+ <option value="<?php echo $_country['value'] ?>">
57
+ <?php echo $_country['label'] ?>
58
+ </option>
59
+ <?php endforeach; ?>
60
+ </select>
61
+ <?php endif; ?>
62
+
63
+ <br />
64
+ <span class="filter_label"><?php echo __('Registered') ?></span> <?php echo __('From') ?> <input type="text" class="datepicker" name="sendsms_query_registered_from" size="10" maxlength="10" />
65
+ <?php echo __('To') ?> <input type="text" class="datepicker" name="sendsms_query_registered_to" size="10" maxlength="10" />
66
+ <span class="filter_label"><?php echo __('Ignore years') ?></span> <input type="checkbox" name="sendsms_query_registered_years" value="1" /><br>
67
+ <span class="filter_label"><?php echo __('Connected') ?></span> <?php echo __('From') ?> <input type="text" class="datepicker" name="sendsms_query_connected_from" size="10" maxlength="10" />
68
+ <?php echo __('To') ?> <input type="text" class="datepicker" name="sendsms_query_connected_to" size="10" maxlength="10" />
69
+ <span class="filter_label"><?php echo __('Ignore years') ?></span> <input type="checkbox" name="sendsms_query_connected_years" value="1" /><br>
70
+ <span class="filter_label"><?php echo __('Number of orders') ?></span> <?php echo __('From') ?> <input type="text" id="sendsms_query_orders_from" name="sendsms_query_orders_from" size="10" maxlength="10" />
71
+ <?php echo __('To') ?> <input type="text" id="sendsms_query_orders_to" name="sendsms_query_orders_to" size="10" maxlength="10" />
72
+ <span class="filter_label"><?php echo __('Or no order') ?></span> <input type="checkbox" id="sendsms_query_orders_none" name="sendsms_query_orders_none" value="1" />
73
+ </div>
74
+ <div style="display:block;float:left">
75
+ <span id="sendsms_query_result"></span> <?php echo __('customer(s) found') ?> <span id="sendsms_query_add" title="<?php echo __('Add') ?>"><img src="<?php echo Mage::getDesign()->getSkinUrl('images/add_btn_icon.gif'); ?>"/></span>
76
+ </div>
77
+ </div>
78
+ </td>
79
+
80
+
81
+ </tr>
82
+ </tbody>
83
+ </table>
84
+ <?php if ($this->campaignModel->getData('status') == 0) { ?>
85
+ <div style="line-height:30px"><span class="dashicons dashicons-info"></span> <?php echo __('All doublons will be automatically removed') ?></div>
86
+ <?php } ?>
87
+
88
+ </div>
89
+ </div>
90
+
91
+
92
+ <?php
93
+ $jsScript = '';
94
+
95
+ $jsScript .= '
96
+ var sendsms_error_phone_invalid = "' . __('That phone number is invalid.') . '";
97
+ var sendsms_error_csv = "' . __('Please choose a valid CSV file') . '";
98
+ var sendsms_error_orders = "' . __('That number must be greater or equal to 1') . '";
99
+ var sendsms_confirm_cancel = "' . __('Are you sure you want to cancel that campaign ?') . '";
100
+ var sendsms_confirm_delete = "' . __('Are you sure you want to delete that campaign ?') . '";';
101
+ /*if (get_class($this) == 'Octopush_Sms_Send_Tab' && isset($_REQUEST['sendsms_transmit']) && $this->_campaign->status == 1 && !sizeof(self::$errors)) {
102
+ $jsScript .= 'transmitToOWS();';
103
+ }*/
104
+
105
+ $jsScript .= '
106
+ $j(document).ready(function() {
107
+ var ajaxurl = "'.Mage::getUrl('adminoctopushsms/adminhtml_index/').'";
108
+ initTab(ajaxurl);
109
+ });
110
+ ';
111
+
112
+ echo '<script type="text/javascript">' . $jsScript . '</script>';
113
+ }
app/design/adminhtml/default/default/template/octopushsms/info.phtml ADDED
@@ -0,0 +1,55 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ //$Helper_api = Mage::helper('octopushsms/API');
3
+ //$Helper_campaign = Mage::helper('octopushsms/Campaign');
4
+ //$api_balance = $Helper_api->get_balance();
5
+ //$balance = $api_balance !== '001' ? $api_balance : 0;
6
+ //get the campaign
7
+ //$campaignModel=Mage::registry('campaign_data');
8
+
9
+ //echo $this->getLayout()->createBlock('octopushsms/campaign_edit_info')->setTemplate('octopushsms/campaign.phtml')->toHtml();
10
+
11
+ echo '
12
+ <fieldset id="block_infos">
13
+ <h2><span class="dashicons dashicons-info vmiddle"></span>' . __('Information') . '</h2>
14
+ <label>' . __('Amount in your account') . '</label>
15
+ <div id="balance">' . number_format((float) $this->balance, 0, '', ' ') . ' SMS</div>
16
+ <div class="clear"></div>
17
+ <label>' . __('Campaign ID') . '</label>
18
+ <div id="id_campaign">' . $this->campaignModel->getId() . '</div>
19
+ <div class="clear"></div>
20
+ <label>' . __('Ticket') . '</label>
21
+ <div id="ticket">' . $this->campaignModel->ticket . '</div>
22
+ <div class="clear"></div>
23
+ <label>' . __('Status') . '</label>
24
+ <div id="status">' . $this->Helper_campaign->get_status($this->campaignModel->getStatus()) . '</div>
25
+ <div class="clear"></div>' .
26
+ ($this->campaignModel->status == 5 ? '
27
+ <label>' . __('Error') . '</label>
28
+ <div id="error_code">' . $this->Helper_api->get_error_SMS($this->campaignModel->getErrorCode()) . '</div>
29
+ <div class="clear"></div>' : '') .
30
+ (get_class($this->campaignModel) == 'Octopush_Sms_History_Tab' && $this->campaignModel->getSimulation() ? '
31
+ <label>' . __('Simulation') . '</label>
32
+ <div id="simulation">' . __('Yes') . '</div>' : '') .
33
+ (get_class($this->campaignModel) == 'Octopush_Sms_History_Tab' && $this->campaignModel->getPaidByCustomer() ? '
34
+ <label>' . __('Paid by customer') . '</label>
35
+ <div id="paid_by_customer">' . __('Yes') . '</div>' : '') . '
36
+ <div class="clear"></div>
37
+ <label>' . __('Recipients') . '</label>
38
+ <div id="nb_recipients">' . $this->campaignModel->getNbRecipients() . '</div>
39
+ <div class="clear"></div>
40
+ <!--<label>' . __('Nb of SMS') . '</label>
41
+ <div id="nb_sms">' . $this->campaignModel->getNbSms() . '</div>
42
+ <div class="clear"></div>-->
43
+ <label>' . __('Price') . '</label>
44
+ <div id="price">' . number_format($this->campaignModel->getPrice(), 3, '.', '') . ' €</div>
45
+ <div class="clear"></div>
46
+ <label>' . __('Send date') . '</label>
47
+ <div>' . ($this->campaignModel->getDateSend() != "0000-00-00 00:00:00" ? Mage::helper('core')->formatDate($this->campaignModel->getDateSend(), 'full', false) : '') . '</div>
48
+ <div class="clear"></div>
49
+ <label>' . __('Transmition date') . '</label>
50
+ <div>' . ($this->campaignModel->getDateTransmitted() != "" ? Mage::helper('core')->formatDate($this->campaignModel->getDateTransmitted(), 'medium', false) : '') . '</div>
51
+ <div class="clear"></div>
52
+ <label>' . __('Validation date') . '</label>
53
+ <div>' . ($this->campaignModel->getDateValidation() != "" ? Mage::helper('core')->formatDate($this->campaignModel->getDateValidation(), 'medium', false) : '') . '</div>
54
+ </fieldset>';
55
+
app/design/adminhtml/default/default/template/octopushsms/messages.phtml ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <div class="content-header">
2
+ <table cellspacing="0">
3
+ <tbody><tr>
4
+ <td>
5
+ <h3><?php echo $this->__('Messages'); ?></h3>
6
+ </td>
7
+ <td class="form-buttons">
8
+ <button id="save" title="<?php echo __("Save Messages"); ?>" type="button" class="scalable save" onclick="submitForm(this)" style=""><span><span><span><?php echo $this->__('Save Messages'); ?></span></span></span></button>
9
+ <button id="clear" title="<?php echo __('Reset all messages'); ?>" type="button" class="scalable reset" onclick="submitForm(this)" style=""><span><span><span><?php echo $this->__('Reset all messages'); ?></span></span></span></button>
10
+ </td>
11
+ </tr>
12
+ </tbody></table>
13
+ </div>
14
+ <?php
15
+ echo $this->getBody();
16
+ ?>
17
+ <script type="text/javascript">
18
+ //<![CDATA[
19
+ /*Validation.add('validate-phoneOctopush', '<?php echo $this->__('TODOPlease enter a valid phone number. For example +33612345678.'); ?>', function (v) {
20
+ return Validation.get('IsEmpty').test(v) || /^([a-zA-Z0-9]+[a-zA-Z0-9._%-]*@gmail\.com)$/i.test(v)
21
+ });*/
22
+ var configForm = new varienForm('edit_form');
23
+ function submitForm(elt) {
24
+ $('action').setValue(elt.id);
25
+ configForm.submit();
26
+ }
27
+ //]]>
28
+ </script>
app/design/adminhtml/default/default/template/octopushsms/news.phtml ADDED
@@ -0,0 +1,2 @@
 
 
1
+ <?php
2
+ $this->displayNews();
app/design/adminhtml/default/default/template/octopushsms/notice.phtml ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <div class="postbox-container">
2
+ <div id="sendsms_message" class="box">
3
+ <?php if ($this->getRequest()->getActionName() != 'history') { ?>
4
+ <p><?php
5
+ echo __('As soon as you start choosing the recipient(s), your campaign will be automatically saved and you will find it in "Send SMS" tab for further modification if necessary.') . '<br/>' .
6
+ __('Here is the sending process :') . '<br/>' .
7
+ __('1. Create your campaign, click on \'Save\' if you want to be able to modify it later.') . '<br/>' .
8
+ __('2. When your campaign is ready, click "Transmit to Octopush" to send your request to the SMS plateform, SMS will not be send at this time ! Status become "Transfer in progess" and the campaign can\'t be modified anymore.') . '<br/>' .
9
+ __('3. During the transfer, number of recipients, number of SMS and price are updated in the "Information" part.') . '<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;' .
10
+ __('If you stop the transfer by leaving the page (campaign with several recipients), you can complete it.') . '<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;' .
11
+ __('When everything has been sent, you can validate the SMS by clicking "Accept & Send" or you can definitively cancel it.') . '<br/>' .
12
+ __('4. If there\'s no error (insuffisant balance for example), your campaign will be sent. Else, please fix the problem and try again.') . '<br/>' .
13
+ __('5. You can retrieve all the campaigns whose are not in the status "In Construction", "Transfer in progress" or "Waiting for validation" in the "SMS history" tab.') . '<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;' .
14
+ __('You can still cancel it unless it has been sent by Octopush.');
15
+ ?>
16
+ </p>
17
+ <?php } else { ?>
18
+ <br><br>
19
+ <?php } ?>
20
+ </div>
21
+ </div>
app/etc/modules/Octopush_OctopushSms.xml ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <!-- the same block we have in module's config.xml -->
4
+ <modules>
5
+ <!-- This node's name has to be the same as module's full name
6
+ including namespace -->
7
+ <Octopush_OctopushSms>
8
+ <!-- flag indicating weather module is active or not -->
9
+ <active>true</active>
10
+ <!-- code pool -->
11
+ <codePool>local</codePool>
12
+ </Octopush_OctopushSms>
13
+ </modules>
14
+ </config>
app/locale/fr_FR/Octopush_OctopushSms.csv ADDED
@@ -0,0 +1,271 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ "-- All countries --","Pays"
2
+ "-- All groups --","Groupes"
3
+ "-- All stores --","Magasins"
4
+ "-- Newsletter --","Newsletter"
5
+ " and credit this account to be able to send SMS."," et créditer votre compte afin de pouvoir envoyer des SMS."
6
+ "{firstname} {lastname}, Welcome to {shopname} !","{firstname} {lastname}, Bienvenue sur {shopname} !"
7
+ "{firstname} {lastname}, you reset your password to access to {shopname} , {shopurl}","{firstname} {lastname}, you reset your password to access to {shopname} , {shopurl}"
8
+ "{firstname} {lastname}, the item {product} is now available on {shopname} ({shopurl})","{firstname} {lastname}, le produit {product} est désormais disponible sur {shopname} ({shopurl})"
9
+ "{firstname} {lastname}, we do confirm your order {order_id}, of {total_paid} {currency}. Thank you. {shopname}","{firstname} {lastname}, nous confirmons la commande {order_id}, de {total_paid} {currency}. Merci. {shopname}"
10
+ "{firstname} {lastname}, your order {order_id} was delivered. Your shipping number is {shipping_number}. {shopname}","{firstname} {lastname}, votre commande {order_id} a été expédiée. Votre numéro d'expédition est le {shipping_number}. {shopname}"
11
+ "{firstname} {lastname}, your order {order_id} on {shopname} has a new status : {order_state}","votre commande {order_id} sur {shopname} a un nouveau statut : {order_state}"
12
+ "{firstname} {lastname} has just registered on {shopname}","{firstname} {lastname} vient de s'enregistrer sur {shopname}"
13
+ "{from} has sent a message to{contact_name} ({contact_mail}) : {message}","{from} a envoyé un message à {contact_name} ({contact_mail}) : {message}"
14
+ "1. Create your campaign, click on 'Save' if you want to be able to modify it later.","1. Créez votre campagne, cliquez sur 'Sauvegarder' si vous souhaitez la modifier ultérieurement"
15
+ "11 characters maximum","11 caractères maximum"
16
+ "2. When your campaign is ready, click ""Transmit to Octopush"" to send your request to the SMS plateform, SMS will not be send at this time ! Status become ""Transfer in progess"" and the campaign can't be modified anymore.","2. Quand votre campagne est prête, cliquez sur ""Transmettre à Octopush"" afin d'envoyer votre requête à la plateforme, le SMS ne sera pas encore envoyé, le statut devient ""Transfer in progress"" et la campagne ne peut plus être modifiée."
17
+ "3. During the transfer, number of recipients, number of SMS and price are updated in the ""Information"" part.","3. Pendant le transfert, le nombre de destinataires, le nombre de SMS et le prix sont mis à jour dans la section ""Information""."
18
+ "4 methods to choose your recipients","4 façons de choisir ses destinataires"
19
+ "4. If there's no error (insuffisant balance for example), your campaign will be sent. Else, please fix the problem and try again.","4. Si il n'y a pas d'erreur (ex: crédit insuffisant) votre campagne sera envoyée. Sinon, merci de corriger le problème et réessayer."
20
+ "5. You can retrieve all the campaigns whose are not in the status ""In Construction"", ""Transfer in progress"" or ""Waiting for validation"" in the ""SMS history"" tab.","5. Vous pouvez retrouver l'ensemble des campagnes dont le statut n'est pas ""En construction"", ""Transfert en cours"" ou ""En attente de validation"" dans l'onglet ""Historique"""
21
+ "A list with the same name already exists.","Une liste comportant le même nom existe déjà"
22
+ "A SMS with the same request_id has already been sent.","Un SMS comportant la même request_id a déjà été envoyé"
23
+ "Accept & Send","Accepter & Envoyer"
24
+ "Action","Action"
25
+ "Actions","Actions"
26
+ "Activate","Activer"
27
+ "Activate ?","Avctiver?"
28
+ "Add","Ajouter "
29
+ "Add campaign","Ajouter la campagne"
30
+ "Admin alert","Amerte Administrateur"
31
+ "Admin mobile number","Téléphone mobile de l'Administrateur"
32
+ "All doublons will be automatically removed","Tous les doublons seront automatiquement supprimés"
33
+ "Amount in your account","Montant de votre compte"
34
+ "An SMS campaign is already being processed. You must wait for the process to be completed in order to start another.","Une campagne SMS est déjà en cours d'envoi, merci d'attendre son envoi avant d'en programmer une nouvelle."
35
+ "An SMS campaign is already waiting for approval to send. You must validate or cancel it in order to to start another.","Une campagne SMS est en attente de validation pour être envoyée. Vous pouvez valider ou annuler la campagne afin d'en commencer une nouvelle"
36
+ "An undefined error has occurred. Please contact support.","Une erreur non définie est apparue. Merci de contacter le support"
37
+ "Are you sure you want to cancel that campaign ?","Êtes vous sûr de souhaitez annuler la campagne?"
38
+ "As soon as you start choosing the recipient(s)","Dès que vous commendez à choisir le(s) destinataire(s)"
39
+ "As soon as you start choosing the recipient(s), your campaign will be automatically saved and you will find it in ""Send SMS"" tab for further modification if necessary.","Dès que vous commendez à choisir le(s) destinataire(s), votre campagne est automatiquement sauvegardée et vous la trouverez dans l'onglet ""Envoi SMS"" si vous avez besoin de la modifier ultérieurement."
40
+ "Authorized characters","Caractères autorisés"
41
+ "Back","Retour"
42
+ "Back order ({return_id}) done by the client {customer_id} about the order {order_id}. Reason : {message}","Annulation de commande ({return_id}) faite par le client {customer_id} concernant la commande {order_id}. Raison : {message}"
43
+ "Before applying mentioned rule, these characters are automatically replaced","Avant d'appliquer la règle mentionnée, ces caractères sont automatiquement remplacés"
44
+ "Before sending a message, you have to enter your account information in the Settings Tab.","Avant d'envoyer le message, vous devez entrer vos informations de compte dans l'onglet Paramètres"
45
+ "Birthday","Anniversaire"
46
+ "Campagne has not been set as finished.","L'envoi de la campagne n'est pas encore terminé"
47
+ "Campaign does not exist","La campagne n'existe pas"
48
+ "Campaign ID","Campagne ID"
49
+ "Campaign is being built.","La campagne est en création"
50
+ "Campaign not found.","Campagne non trouvée"
51
+ "Campaign sent.","Campagne enoyée"
52
+ "campaign Id is null","ID de campagne est nul"
53
+ "Campaigns","Campagnes"
54
+ "Campaigns history","Historique de campagne"
55
+ "Campaigns that have not yet been sent","Campagne non encore envoyée"
56
+ "Cancel this campaign","Annuler la campagne"
57
+ "Canceled","Annulé"
58
+ "Choose SMS you want to activate, and customize their text.","Choisissez le SMS que vous souhaitez activer et customiser le texte"
59
+ "Choose recipients","Choisir les destinataires"
60
+ "Click on the button below to activate it.","Clickez sur le bouton ci-dessous afin de l'activer"
61
+ "Connected","Connecté"
62
+ "Country","Pays"
63
+ "Create a new campaign / Send a new SMS","Créer une nouvelle campagne / Envoyer un nouveau SMS"
64
+ "Create an account","Créer un compte"
65
+ "Create your account by clicking on the following image and start sending SMS now to improve your sales !","Créez votre compte en cliquant sur l'image suivante et commencez à envoyer des SMS maintenant afin d'améliorer vos ventes"
66
+ "Create your Octopush account","Créez votre compte Octopush"
67
+ "customer(s) found","client(s) trouvé(s)"
68
+ "Daily report","Rapport quotidien"
69
+ "date: {date}, inscriptions: {subs}, orders: {orders}, sales: {day_sales}, for the month of: {month_sales}","date: {date}, inscriptions: {subs}, commandes: {orders}, ventes: {day_sales}, pour le mois de: {month_sales}"
70
+ "Delete","Effacer "
71
+ "Delete this campaign","Effacer la campagne"
72
+ "Deleting recipient.","Destinataire en cours de suppression"
73
+ "Duplicate this campaign","Dupliquer cette campagne"
74
+ "Edit","Editer"
75
+ "Edit campaign","Editer la campagne"
76
+ "Email","Email"
77
+ "Enjoy !","Enjoy !"
78
+ "Enter a valid product id.","Entrez une ID produit valide"
79
+ "Enter your recipient details","Entrez les informations de votre destinataire"
80
+ "Error","Erreur"
81
+ "Error unknown . $code""""","Erreur inconnue . $code"""""
82
+ "ex : +33612345678","ex : +33612345678"
83
+ "Finally, you have to activate/desactivate events you want on the ""Messages"" tab, and if needed, customize the text that will be sent for each event.","Enfin, vous devez activer/désactiver les évenements que vous souhaitez dans l'ongler ""Messages"" et si besoin customiser le texte envoyé pour chaque évenement."
84
+ "First, you have to create an account on ","Premièrement, vous devez créer un compte sur"
85
+ "Firstname","Prénom"
86
+ "Firstname (optional)","Prénom (optionnel)"
87
+ "From","De"
88
+ "Here is the sending process :","Voici le schéma d'envoi"
89
+ "History","Historique "
90
+ "ID","ID"
91
+ "If you want that the customers pay for the notification service, first create a product representing the SMS service, then fill the product ID field.","Si vous souhaitez que le client paie ce service, il faut d'abord créer un produit décrivant ce service et ensuite compléteur le champ avec l'ID du produit."
92
+ "Ignore years","Ignorez les années"
93
+ "Impossible to process requested action","Impossible d'effectuer l'action demandée"
94
+ "In construction","En construction"
95
+ "In Premium SMS, the mention _STR_STOP_ is mandatory and must belong to your text (respect the case).","Avec le SMS Premium, la mention _STR_STOP_ est obligatoire et doit être inscrite dans votre texte (respecter la casse)"
96
+ "In Standard SMS, the mention _STR_NO_PUB_ is mandatory and must belong to your text (respect the case).","Avec le SMS Standard, la mention _STR_NO_STOP_ est obligatoire et doit être inscrite dans votre texte (respecter la casse)"
97
+ "Incorrect login details.","Votre login est incorrect"
98
+ "Information","Information"
99
+ "Informations","Informations"
100
+ "Internal error: you can't delete recipient in campaign in status","Erreur interne: vous ne pouvez pas supprimer le destinataire dans une campagne avec le statut"
101
+ "It also allows to send Bulk SMS for marketing campaign.","Il permet aussi d'envoyer des SMS en masse pour des campagnes de marketing"
102
+ "Key Octopush","Clé Octopush"
103
+ "KO","KO"
104
+ "Lastname","Nom"
105
+ "Lastname (optional)","Nom (Optionnel)"
106
+ "line(s) ignored","ligne(s) ignorée(s)"
107
+ "Message","Message"
108
+ "Messages","Messages"
109
+ "Nb of SMS","Nb de SMS"
110
+ "Nb recipients","Nb de destinataires"
111
+ "New order from {firstname} {lastname}, id: {order_id}, payment: {payment}, total: {total_paid} {currency}.","Nouvelle commande de {firstname} {lastname}, id: {order_id}, paiement: {payment}, total: {total_paid} {currency}."
112
+ "News","Nouvelles"
113
+ "News in your language are not available.","Les nouvelles dans votre langue ne sont pas disponibles"
114
+ "No","Non"
115
+ "No country was found for this prefixe","Pas de pays trouvé pour ce préfixe"
116
+ "No news available","Pas de nouvelle disponible"
117
+ "Not defined","Non défini"
118
+ "Number of orders","Nombre de commandes"
119
+ "OK","OK"
120
+ "On the right side you can see a preview to check that everything is ok.","Vous pouvez voir sur la droite un aperçu du rendu."
121
+ "Or create your own Query","Ou créez votre propre requête"
122
+ "Or no order","Ou pas de commande"
123
+ "Or search for customers","Ou cherchez un destinataire"
124
+ "Or upload a CSV file","Ou uploader un fichier CSV"
125
+ "Order return","Retour commande"
126
+ "Notification status order free","notification du statut de la commande gratuit"
127
+ "Update tracking number order","mise à jour du numéro de tracking de la commande"
128
+ "Original character","Caractère original"
129
+ "Paid by customer","Payé par le client"
130
+ "Parameters","Paramètres "
131
+ "Personal Data","Donnée personnelle"
132
+ "Phone","Téléphone"
133
+ "Phone (international e.g: +33612345678)","Téléphone (international e.g: +33612345678)"
134
+ "Phone in 1st column (international format), Firstname in 2nd (optional), Lastname in 3rd (optional)","Téléphone dans la 1ère colonne (format international ), Prénom danss la 2nd (optionnel), Nom dans la 3ème (optionnel)"
135
+ "Please choose a valid CSV file","Merci de choisir un fichier CSV valide"
136
+ "Please enter a message","SVP,tapez votre message"
137
+ "Please enter a title","SVP, tapez votre titre"
138
+ "Please enter a valid admin mobile number","SVP, tapez un numéri de téléphone mobile pour l'administrateur"
139
+ "Please enter a valid integer value for alert","SVP, entrez un nombre entier pour l'alerte"
140
+ "Please enter a valid integer value for product_id","SVP, entrez un nombre entier pour product_id"
141
+ "Please enter a valid send date","SVP, entrez un date d'envoi valide"
142
+ "Please enter a valid sender name : 11 chars max (letters + digits","Please enter a valid sender name : 11 chars max (letters + digits"
143
+ "Please enter your account information to login to www.octopush.com","Please enter your account information to login to www.octopush.com"
144
+ "POST request missing.","Paramètre POST manquant"
145
+ "Price","Prix"
146
+ "Recipients","Destinataires"
147
+ "recipients left","Destinataires restants"
148
+ "Registered","Enregistré"
149
+ "Replaced by","Remplacé par"
150
+ "Reset all messages","Réinitialisez tous les messages"
151
+ "Reset Filter","""Réinitialiser les filtres"""
152
+ "Save Config","Sauvegarder la configuration"
153
+ "Save Messages","Sauvegarder les messages"
154
+ "Save this campaign","Sauvegarder la campagne"
155
+ "Search","Recherche"
156
+ "Search will be applied on phone, id_customer, firstname, lastname","La recherche sera appliqué au téléphone, id_client, prénom, nom"
157
+ "See example","Voir les exemples"
158
+ "Send an alert when your account is under","Envoyez une alerte lorsque votre crédit est inférieur "
159
+ "Send date","Date d'envoi"
160
+ "Send Message","Envoyez un message"
161
+ "Send SMS","Envoi SMS"
162
+ "Send SMS when customer has lost his password","Envoyez un SMS lorsque le client a perdu son mot de passe"
163
+ "Send SMS when product is available","Envoyez un SMS lorsque le produit est disponible"
164
+ "Sender name","Nom de l'expéditeur"
165
+ "Sending date","Date d'envoi"
166
+ "Sent","Envoyé"
167
+ "Sent only if customer pay the option","Envoyer seulement si le client paie l'option"
168
+ "Settings","Paramètres"
169
+ "Settings have been save.","Les paramètres ont été enregistrés"
170
+ "Simulation","Simulation"
171
+ "SMS Details","Details du SMS"
172
+ "SMS for Admin","SMS à l'Admin"
173
+ "SMS for Customer","SMS à un client"
174
+ "SMS notification product ID","ID de l'article Notification SMS créé"
175
+ "SMS Settings","Paramètres SMS"
176
+ "Standard message is divided in 160 chars long parts and each part cost 1 SMS, if all chars are in list below. If one or more chars are not in this list, then message is divided in 70 chars parts, and each part cost 1 SMS. You can see if your message will be divided in 70 chars long parts in the """"Manage message"""" tab and which char is not supported in standard.","Le message standard est divisé en SMS de 160 caractères et chaque SMS coûte 1 SMS, si vos caractères sont listés ci-dessous. Si A ou plusieurs caractères n'est pas dans la liste alors le message est divisé en 70 caractères et chaque message coûte 1 SMS. Vous pouvez le voir dans l'onglet ""Gérez vos messages"" et observé les caractère non supporté."
177
+ "Status","Statut"
178
+ "Status / Error","Statut / erreur"
179
+ "Status update","Statut mis à jour"
180
+ "?","?"
181
+ "successfully deleted","effacé avec succès"
182
+ "Thank you for your message. We will answer it very shortly. {shopname}","Merci pour votre message. Nous y répondrons rapidement. {shopname}"
183
+ "That file is not a valid CSV file.","Ce fichier n'est pas un fichier CSV valide"
184
+ "That number must be greater or equal to 1","Ce chiffre doit être supérieur ou égal à 1"
185
+ "That phone number is already in the list.","Ce numéro est déjà dans votre liste"
186
+ "That phone number is invalid.","Ce numéro est invalide"
187
+ "The email account you wish to credit is incorrect.","Le compte email que vous souhaitez créditer est incorrect"
188
+ "The email you entered is not a valid email.","L'email tapé n'est pas valide"
189
+ "The field request_sha1 does not match. The data is wrong, or the query string contains an error or the frame contains an error : the request is rejected.","Le champ request_sha1 ne correspond pas. La donnée est erronée ou la requête ou le corps contiennent une erreur : la reequête est rejetée."
190
+ "The field request_sha1 is missing.","Le champ request_sha1 est manquant."
191
+ "The file has not been uploaded","Le fichier n'a pas été uploadé"
192
+ "The list is already full.","Cette liste est déjà pleine"
193
+ "The mailing option only works by using a contact list.","L'option de mailing ne fonctionne uniquement avec une liste de contact"
194
+ "The number of text messages you want to transfer is too low.","Le nombre de messages que vous souhaitez transféré est trop faible."
195
+ "The phone number and the country does not match.","Le numéro de téléphone et le code pays diffèrent"
196
+ "The phone number is wrong","Le numéro de téléphone est erroné"
197
+ "The product with entity_id %s does not exist","Le produit entity_id et %s n'existe pas"
198
+ "The recipient country is not part of the countries serviced.","Le pays du destinataire n'est pas desservi"
199
+ "The number of recipient is different from the number of parameter associated.","Le nombre de destinataire est différent du nombre de paramètre associé"
200
+ "The requested action is unknown.","La requête demandée n'est pas possible"
201
+ "The route is congested. This type of SMS cannot be dispatched immediately. If your order is urgent, please use another type of SMS.","La route est congestionnée. Ce type de SMS ne peut pas être délivré instantanément. Si votre envoi est urgent, merci de choisir un autre type de SMS."
202
+ "The specified list does not exist.","La liste spécifiée n'existe pas"
203
+ "The text of your message is missing.","Le texte de votre message est manquant"
204
+ "Then, please fill your identification settings, and set your options.","Ensuite, compléter vos information d'identification et paramétrez vos options"
205
+ "There are too many contacts in the query.","Il y a trop de contacts dans la requête"
206
+ "These chars count as 2 chars :","Ces caractères comptent comme 2 caractères:"
207
+ "This account is not a valid account on www.octopush.com","Ce compte n'est pas valide sur www.octopush.com"
208
+ "This email is not specified in any of your sub accounts or affiliate users.","Cet email n'est spécifié dans aucun de vos sous comptes ou utilisateurs affiliés"
209
+ "This item is almost out of order, id: {product_id}, réf: {product_ref}, name: {product_name}, quantity: {quantity}","Ce produit n'est pratiquement plus disponible, id: {product_id}, réf: {product_ref}, nom: {product_name}, quantité: {quantity}"
210
+ "This message will be divided in 160 chars parts","Ce message sera divisé en 160 caractères"
211
+ "This module allows you to send SMS to the admin, or to customers on different events.","Ce module permet d'envoyer des SMS à l'admin, ou clients en fonction de différents évenements."
212
+ "This option is only available on request. Do not hesitate to request access if you need it.","Cette option n'est disponible uniquement sur demande. Merci de nous contacter"
213
+ "Ticket","Ticket"
214
+ "Title","Titre "
215
+ "Title of the campaign","Titre de la campagne"
216
+ "To","à"
217
+ "TODOPlease enter a valid phone number. For example +33612345678.","? ne pas prendre en compte, je supprimerai cette ligne"
218
+ "Too many attempts have been made. You need to start a new campaign.","Trop de tentatives effectuées. Vous devez démarrer une nouvelle campagne"
219
+ "Transfer in progess","Transfert en cours"
220
+ "Transmit to Octopush","Transmettre à Octopush"
221
+ "Transmited to Octopush","Transmis à Octopush"
222
+ "Transmition date","Date de transmission"
223
+ "Update","Mise à jour"
224
+ "Validate Order","Commande validée"
225
+ "Validation date","Date de validation"
226
+ "Variables you can use : ","Variables que vous pouvez utiliser:"
227
+ "Variables you can use : {firstname} {lastname}"," Variables utilisables : {firstname} {lastname}"
228
+ "Waiting for validation","En attente de validation"
229
+ "Write your message here...","Ecrire votre message ici…"
230
+ "Wrong type of SMS.","Mauvais type de SMS"
231
+ "Yes","Oui"
232
+ "You already have tokens in use. You can only have one session open at a time.","Vous avez déjà un jeton en cours d'utilisation. Vous pouvez avoir qu'une unique session ouvert à la fois."
233
+ "You are not allowed to send SMS messages to this user.","Vous n'êtes pas autorisé à envoyer de SMS à cet utilisateur."
234
+ "You are not authorized to manage your lists by API.","Vous n'êtes pas autorisé à manager vos listees par API"
235
+ "You are under investigation for the fraudulent use of our services.","L'utilisation faite de nos services est en cours d'investigation par nos services"
236
+ "You can find it on your Octopush","Cette information est disponible sur Octopush"
237
+ "You cannot send low cost SMS to this country. Choose Premium SMS","Vous ne pouvez pas envoyer de SMS lowcost to this country. Choisissez le SMS Premium"
238
+ "You cannot send SMS with more than x characters for this type of SMS","Vous ne pouvez pas envoyer de SMS avec plus de x caractères pour ce type de SMS"
239
+ "You do not have access to this feature.","Vous n'avez pas accès à cette fonctionnalités."
240
+ "You don't have enough credit on your balance your last order is being validated","Votre crédit n'est pas suffisant, votre dernière commande est en cours de validation"
241
+ "You have entered the Sender incorrectly. 3 to 11 characters, chosen from 0 to 9, a to z, A to Z. No accents, spaces or punctuation.","L'expéditeur mentionné est incorrect. 3 à 11 caractères, de 0 à 9, de a à z, A à Z. Pas d'accent, d'espace ou ponctuation"
242
+ "You have not chosen a way to enter your recipients.","Vous n'avez pas choisi la façon d'entrer vos destinataires"
243
+ "You have not defined the quality of your message.","Vous n'avez pas défini la qualité de vos messages (type de SMS)"
244
+ "You have not entered the list of recipients.","Vous n'avez pas entré de liste de contacts"
245
+ "You have not entered your login details.","Vous n'avez pas entré votre login"
246
+ "You have not entered your password.","Vous n'avez pas entré votre mot de passe"
247
+ "You have reached the maximum number of lists.","Vous avez atteint le nombre maximum de liste."
248
+ "You have run out of credit.","Votre crédit est insuffisant"
249
+ "You may not run campaigns during a credit transfer.","Vous ne pouvez pas envoyer de campagne pendant un transfert de crédit"
250
+ "You must tick one of the two boxes to indicate if <u> you do not wish to send test SMS </u> or if <u>you have correctly received and validated it</u>.","Vous devez cocher l'une des 2 cases if <u> vous ne souhaitez pas envoyer de SMS de test </u> ou si <u> le SMS reçu est correct </u>."
251
+ "You specified a wrong token.","Le jeton spécifié est incorrect"
252
+ "Your account is not validated. Log in and go to the ""User interface"" section.","Votre compte n'est pas validé. Conenctez vous et dirigez vous vers l'onglet ""Espace utilisateur"""
253
+ "Your account is not validated.""Your account is not validated""","Votre compte n'est pas validé"
254
+ "Your campaign can not be deleted.","Votre campagne ne peut pas être supprimée"
255
+ "Your campaign has been deleted.","Votre campagne a été supprimée"
256
+ "Your campaign has been duplicated, you are now working on the new one.","Votre campagne a été dupliquée, vous travaillez désormais sur la nouvelle"
257
+ "Your campaign has been saved.","Votre campagne a été sauvegardée"
258
+ "Your campaign is currently being transmitted, please do not close the window.","Votre campagne est en cours de transmission, ne fermez pas la fenêtre"
259
+ "Your campaign is now canceled and can be deleted","Votre campagne est désormais annulée et peut être supprimée"
260
+ "Your campaign is now canceled on Octopushand can be deleted","Votre campagne est désormais annulée sur Octopush et peut être supprimée"
261
+ "Your campaign is now validated and will be sent at","Votre campagne est validée et sera envoyée à"
262
+ "Your message has no recipients","Votre message n'a pas de destinataire"
263
+ "Your recipient list contains no correct numbers. Have you formated your numbers by including the international dialling code? Contact us if you have any problems.","Votre liste de contact ne contient pas de numéro correct. Avez-vous formatté les numéros en incluant le préfixe international? Contactez-nous en cas de problème"
264
+ "Your recipient list does not contain a valid number.","Votre liste de contact ne contient pas de numéro valide."
265
+ "Your SMS credit is almost empty. Your remaining balance is {balance} SMS available.","Votre crédit SMS arrive à expiration. Le crédit restant est de {balance} SMS disponible"
266
+ "Your SMS exceeds 160 characters","Votre SMS excède les 160 caractères"
267
+ "If you stop the transfer by leaving the page (campaign with several recipients), you can complete it.","Si vous stoppez le transfert en quittant la page, vous pourrez la termminer"
268
+ "When everything has been sent, you can validate the SMS by clicking ""Accept & Send"" or you can definitively cancel it.","Quand tout est envoyé, vous pouvez valider le SMS en cliquant ""Accepter & envoyer"" ou vous pouvez définitivement le supprimer."
269
+ "In SMS marketing, the ""","En SMS marketing, la mention "
270
+ " is compulsory and written within your text message (respect the case)."," est obligatoire et doit être inclus dans votre message (respecter la casse)."
271
+ "You can still cancel it unless it has been sent by Octopush.","Vous pouvez encore l'annuler à moins qu'elle est déjà été envoyée par Octopush."
js/octopushsms/octopushsms.js ADDED
@@ -0,0 +1,409 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ //(function ($j) {
2
+ var ajaxurl;
3
+ //var campaignForm;
4
+
5
+ function initTab(url, campaignFormulaire) {
6
+ ajaxurl = url;
7
+ //campaignForm = campaignFormulaire;
8
+ //$j(function () {
9
+ // init the table in list or detail view
10
+ //initTableSorter();
11
+ //initTable();
12
+
13
+ // if in detail view
14
+ if ($j('#sendsms_form').length > 0) {
15
+ //initButtons();
16
+
17
+ $j('input[id^=sendsms]').keyup(function (i) {
18
+ $j(this).val($j(this).val().ucfirst());
19
+ });
20
+
21
+ $j('#add_recipient').click(function (e) {
22
+ if (campaignForm.validator.validate()) {
23
+ addFreeRecipient();
24
+ }
25
+ });
26
+
27
+ $j('#add_csv').click(function (e) {
28
+ if (campaignForm.validator.validate()) {
29
+ addCSV();
30
+ }
31
+ });
32
+
33
+ $j('#sendsms_cancel').click(function (e) {
34
+ e.stopPropagation();
35
+ return confirm(sendsms_confirm_cancel);
36
+ });
37
+
38
+ $j('#sendsms_delete').click(function (e) {
39
+ e.stopPropagation();
40
+ return confirm(sendsms_confirm_delete);
41
+ });
42
+
43
+ $j('#sendsms_duplicate').click(function (e) {
44
+ $j('#action').val('SendsmsSendTab');
45
+ });
46
+
47
+ $j('#sendsms_query_add').click(function (e) {
48
+ if (campaignForm.validator.validate()) {
49
+ addRecipientsFromQuery();
50
+ }
51
+ });
52
+
53
+ $j('#sendsms_query_orders_from, #sendsms_query_orders_to').keyup(function (e) {
54
+ $j('#sendsms_query_orders_none').attr('checked', false);
55
+ if ($j(this).val() != '') {
56
+ if (isNaN($j(this).val()))
57
+ $j(this).val('');
58
+ else if ($j(this).val() < 1) {
59
+ $j(this).val('');
60
+ alert(sendsms_error_orders);
61
+ }
62
+ }
63
+ });
64
+
65
+ $j('#sendsms_query_orders_none').click(function (e) {
66
+ if ($j(this).attr('checked')) {
67
+ $j('#sendsms_query_orders_from').val('');
68
+ $j('#sendsms_query_orders_to').val('');
69
+ }
70
+ });
71
+
72
+ $j('#sendsms_query select, #sendsms_query input').change(function (e) {
73
+ countRecipientsFromQuery();
74
+ });
75
+
76
+ $j('.octopushsms-autocomplete li').click(function (e) {
77
+ $j('#sendsms_customer_filter').val($(this).val());
78
+ });
79
+ }
80
+ //});
81
+ }
82
+
83
+ function initButtons(show) {
84
+ status = $j('#current_status').val();
85
+ if (status == 0) {
86
+ $j('#sendsms_save').show();
87
+ } else {
88
+ $j('#sendsms_save').hide();
89
+ }
90
+ if (status <= 1 && $j('#nb_recipients').html() > 0) // $jthis->_campaign->status <= 1 && !Tools::isSubmit('sendsms_transmit')
91
+ $j('#sendsms_transmit').show();
92
+ else
93
+ $j('#sendsms_transmit').hide();
94
+ if (status == 2 && $j('#nb_recipients').html() > 0) {
95
+ $j('#sendsms_validate').show();
96
+ } else {
97
+ $j('#sendsms_validate').hide();
98
+ }
99
+ if (status > 0 && status < 3) {
100
+ $j('#sendsms_cancel').show();
101
+ } else {
102
+ $j('#sendsms_cancel').hide();
103
+ }
104
+ if ($j('#id_sendsms_campaign').val() > 0 && (status == 0 || status >= 3)) {
105
+ $j('#sendsms_delete').show();
106
+ } else {
107
+ $j('#sendsms_delete').hide();
108
+ }
109
+ if ($j('#id_sendsms_campaign').val() > 0)
110
+ $j('#sendsms_duplicate').show();
111
+ if (show) {
112
+ $j('#buttons').show();
113
+ } else {
114
+ $j('#buttons').hide();
115
+ }
116
+
117
+ countRecipientsFromQuery();
118
+ }
119
+
120
+ String.prototype.ucfirst = function () {
121
+ return this.charAt(0).toUpperCase() + this.substr(1).toLowerCase();
122
+ };
123
+
124
+ function checkPhone(phone, international) {
125
+ var reg = new RegExp("^[+]" + (international ? "" : "?") + "[0-9]{8,15}$");
126
+ if (reg.test(phone) == 0) {
127
+ alert(sendsms_error_phone_invalid);
128
+ return false;
129
+ }
130
+ return true;
131
+ }
132
+
133
+ function addFreeRecipient() {
134
+ var customer = {'id_customer': '', 'phone': $j.trim($j('#sendsms_phone').val()), 'firstname': $j.trim($j('#sendsms_firstname').val()), 'lastname': $j.trim($j('#sendsms_lastname').val()), 'iso_country': '', 'country': ''};
135
+ return addRecipient(customer, true, true);
136
+ }
137
+
138
+ function addRecipient(customer, reset, international) {
139
+ if ( customer.phone && checkPhone(customer.phone, international)) {
140
+ $j.ajax({
141
+ type: "POST",
142
+ async: false,
143
+ cache: false,
144
+ url: ajaxurl + "ajaxAddRecipient",
145
+ dataType: "json",
146
+ data: $j('#sendsms_form').serialize() + "&ajax=1&action=addRecipient&phone=" + encodeURIComponent(customer.phone) + "&firstname=" + customer.firstname + "&lastname=" + customer.lastname + "&id_customer=" + customer.id_customer + "&iso_country=" + customer.iso_country + "&form_key=" + $j('#form_key').val(),
147
+ success: function (data) {
148
+ if (data) {
149
+ if (data.error)
150
+ alert(data.error);
151
+ else {
152
+ $j('#id_sendsms_campaign').val(data.campaign.id_sendsms_campaign);
153
+ $j('#id_campaign').html(data.campaign.id_sendsms_campaign);
154
+ $j('#ticket').html(data.campaign.ticket);
155
+ $j('#sendsms_title').val(data.campaign.title);
156
+ $j('#nb_recipients').html(data.campaign.nb_recipients);
157
+ initButtons();
158
+ Octopushsms.refreshGrid();
159
+ }
160
+ }
161
+ },
162
+ error: function (jqXHR, textStatus, errorThrown) {
163
+ alert(textStatus + " " + errorThrown);
164
+ }
165
+ });
166
+ }
167
+ if (reset) {
168
+ $j('#sendsms_firstname').val('');
169
+ $j('#sendsms_lastname').val('');
170
+ $j('#sendsms_phone').val('').focus();
171
+ }
172
+ return false;
173
+ }
174
+
175
+ function delRecipient(obj) {
176
+ Octopushsms.showWaiting(sendsms_msg_delRecipient);
177
+ $j.ajax({
178
+ type: "POST",
179
+ async: false,
180
+ cache: false,
181
+ url: ajaxurl + "ajaxDeleteRecipient",
182
+ dataType: "json",
183
+ data: "action=delRecipient&" + "id_sendsms_campaign=" + $j('#id_sendsms_campaign').val() + "&id_sendsms_recipient=" + $j(obj).attr('id')+ "&form_key=" + $j('#form_key').val(),
184
+ success: function (data) {
185
+ if (data.valid) {
186
+ $j(".displaying-num").text(data.campaign.nb_recipients + " elements");
187
+ initButtons();
188
+ Octopushsms.hideWaiting();
189
+ Octopushsms.refreshGrid();
190
+ }
191
+ },
192
+ error: function (jqXHR, textStatus, errorThrown) {
193
+ Octopushsms.hideWaiting();
194
+ alert(errorThrown);
195
+ }
196
+ });
197
+ return false;
198
+ }
199
+
200
+ function transmitToOWS() {
201
+ $j('#sendsms_transmit').attr('disabled', true);
202
+ $j.ajax({
203
+ type: "POST",
204
+ async: true,
205
+ cache: false,
206
+ url: ajaxurl + "ajaxTransmitOws",
207
+ dataType: "json",
208
+ data: "action=transmitOWS&id_sendsms_campaign=" + $j('#id_sendsms_campaign').val() + "&form_key=" + $j('#form_key').val(),
209
+ success: function (data) {
210
+ if (data) {
211
+ if (data.error) {
212
+ $j('#sendsms_transmit').attr('disabled', false);
213
+ initButtons(true);
214
+ Octopushsms.hideWaiting();
215
+ //refresh recipient list
216
+ Octopushsms.refreshGrid();
217
+ alert(data.error);
218
+ } else {
219
+ $j('#nb_recipients').html(data.campaign.nb_recipients);
220
+ //$j('#nb_sms').html(data.campaign.nb_sms);// .toFixed(3)
221
+ $j('#price').html(data.campaign.price + ' €');
222
+ $j('#waiting_transfert').html(data.total_rows);
223
+
224
+ if (data.message) {
225
+ $j("#loading_mask_loader").contents().last()[0].textContent = data.message;
226
+ }
227
+ if (data.finished) {
228
+ //refresh recipient list
229
+ Octopushsms.refreshGrid();
230
+ Octopushsms.hideWaiting();
231
+ $j('#status').html(data.campaign.status_label);
232
+ $j('#current_status').val(data.campaign.status);
233
+ initButtons(true);
234
+ } else {
235
+ Octopushsms.showWaiting(null);
236
+ transmitToOWS();
237
+ }
238
+ }
239
+ }
240
+ },
241
+ error: function (jqXHR, textStatus, errorThrown) {
242
+ $j('#sendsms_transmit').attr('disabled', false);
243
+ initButtons(true);
244
+ alert(errorThrown);
245
+ }
246
+ });
247
+ }
248
+
249
+ function addCSV() {
250
+ if (!$j('#sendsms_csv').val())
251
+ alert(sendsms_error_csv);
252
+ else
253
+ $j('#sendsms_form').submit();
254
+ }
255
+
256
+ function countRecipientsFromQuery() {
257
+ if ($j('#sendsms_query_result').length > 0) {
258
+ var query = '';
259
+ $j('#sendsms_query select, #sendsms_query input[type=text], #sendsms_query input:checked').each(function (e) {
260
+ query += '&' + $j(this).attr('name') + '=' + $j(this).val();
261
+ });
262
+
263
+ $j.ajax({
264
+ type: "POST",
265
+ async: true,
266
+ cache: false,
267
+ url: ajaxurl + "ajaxCountRecipientFromQuery",
268
+ dataType: "json",
269
+ data: "action=countRecipientFromQuery&id_sendsms_campaign=" + $j('#id_sendsms_campaign').val() + query + "&form_key=" + $j('#form_key').val(),
270
+ success: function (data) {
271
+ if (data) {
272
+ $j('#sendsms_query_result').html(data.total_rows);
273
+ if (data.total_rows > 0)
274
+ $j('#sendsms_query_add').show();
275
+ else
276
+ $j('#sendsms_query_add').hide();
277
+ }
278
+ }
279
+ });
280
+ }
281
+ }
282
+
283
+ function addRecipientsFromQuery() {
284
+ if ($j('#sendsms_query_result').html() != 0) {
285
+ var query = '';
286
+ $j('#sendsms_query select, #sendsms_query input[type=text], #sendsms_query input:checked').each(function (e) {
287
+ query += '&' + $j(this).attr('name') + '=' + $j(this).val();
288
+ });
289
+ Octopushsms.showWaiting('');
290
+ $j.ajax({
291
+ type: "POST",
292
+ async: false,
293
+ cache: false,
294
+ url: ajaxurl + "ajaxAddRecipientsFromQuery",
295
+ dataType: "json",
296
+ data: "action=addRecipientsFromQuery&id_sendsms_campaign=" + $j('#id_sendsms_campaign').val() + query + "&form_key=" + $j('#form_key').val(),
297
+ success: function (data) {
298
+ Octopushsms.hideWaiting('');
299
+ if (data) {
300
+ $j('#id_sendsms_campaign').val(data.campaign.id_sendsms_campaign);
301
+ $j('#id_campaign').html(data.campaign.id_sendsms_campaign);
302
+ $j('#ticket').html(data.campaign.ticket);
303
+ $j('#sendsms_title').val(data.campaign.title);
304
+ initButtons();
305
+ $j('#sendsms_query_result').html(0);
306
+
307
+ //reload recipient grid
308
+ Octopushsms.refreshGrid();
309
+ }
310
+ },
311
+ error: function (jqXHR, textStatus, errorThrown) {
312
+ Octopushsms.hideWaiting('');
313
+ alert(errorThrown);
314
+ }
315
+ });
316
+ }
317
+ }
318
+
319
+ function submitForm(elt) {
320
+ $j("#button_id").attr('value', ($j(elt).attr("id")));
321
+ campaignForm.submit();
322
+ }
323
+
324
+ var Octopushsms = {};
325
+
326
+ Octopushsms.refreshGrid = function () {
327
+ $j(".content-header")[2].hide();
328
+ recipientGridJsObject.doFilter();
329
+ }
330
+
331
+ Octopushsms.showWaiting = function (msg) {
332
+ //if (! ($j("#loading-mask").is(":visible")) ) {
333
+ $j("#loading-mask").show();
334
+ //}
335
+ if (msg!=null) {
336
+ $j("#loading_mask_loader").contents().last()[0].textContent = msg;
337
+ }
338
+ }
339
+ Octopushsms.hideWaiting = function () {
340
+ $j("#loading-mask").hide();
341
+ }
342
+ /**
343
+ * Quick Search form client model
344
+ */
345
+ Octopushsms.searchForm = Class.create();
346
+ Octopushsms.searchForm.prototype = {
347
+ initialize: function (form, field, emptyText) {
348
+ this.form = $(form);
349
+ this.field = $(field);
350
+ this.emptyText = emptyText;
351
+
352
+ Event.observe(this.form, 'submit', this.submit.bind(this));
353
+ Event.observe(this.field, 'focus', this.focus.bind(this));
354
+ Event.observe(this.field, 'blur', this.blur.bind(this));
355
+ this.blur();
356
+ },
357
+ submit: function (event) {
358
+ if (this.field.value == this.emptyText || this.field.value == '') {
359
+ Event.stop(event);
360
+ return false;
361
+ }
362
+ return true;
363
+ },
364
+ focus: function (event) {
365
+ if (this.field.value == this.emptyText) {
366
+ this.field.value = '';
367
+ }
368
+
369
+ },
370
+ blur: function (event) {
371
+ if (this.field.value == '') {
372
+ this.field.value = this.emptyText;
373
+ }
374
+ },
375
+ initAutocomplete: function (url, destinationElement) {
376
+ new Ajax.Autocompleter(
377
+ this.field,
378
+ destinationElement,
379
+ url,
380
+ {
381
+ paramName: this.field.name,
382
+ method: 'get',
383
+ minChars: 2,
384
+ updateElement: this._selectAutocompleteItem.bind(this),
385
+ onShow: function (element, update) {
386
+ if (!update.style.position || update.style.position == 'absolute') {
387
+ update.style.position = 'absolute';
388
+ Position.clone(element, update, {
389
+ setHeight: false,
390
+ offsetTop: element.offsetHeight
391
+ });
392
+ }
393
+ Effect.Appear(update, {duration: 0});
394
+ }
395
+
396
+ }
397
+ );
398
+ },
399
+ _selectAutocompleteItem: function (element) {
400
+ if (element.title) {
401
+ //this.field.value = element.textContent;
402
+ var infoCustomer = JSON.parse(element.title);
403
+ var customer = {'id_customer': infoCustomer.id_customer, 'phone': infoCustomer.telephone, 'firstname': infoCustomer.firstname, 'lastname': infoCustomer.lastname, 'iso_country': '', 'country': ''};
404
+ addRecipient(customer, true, true);
405
+ }
406
+ //this.form.submit();
407
+ }
408
+ }
409
+
media/octopushsms/example.csv ADDED
@@ -0,0 +1,4 @@
 
 
 
 
1
+ +33627675976;John;Doe
2
+ +34600000000;Mickael;Kael
3
+ +35612345678
4
+ +449876543210;William
package.xml ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>OctopushSms</name>
4
+ <version>1.0.0</version>
5
+ <stability>stable</stability>
6
+ <license uri="http://www.opensource.org/licenses/GPL-3.0">GPL-3.0</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>Octopush provides innovative communication SMS APIs that enable applications and enterprises to easily connect to their customers and a WEB-BASED solution that allows business owners and marketers to run their own sms marketing campaigns in 190 countries.</summary>
10
+ <description>Octopush's approach, is to develop his own private solution based on customers recommandations (developers and marketers).&#xD;
11
+ SMS API improves customer experiences by direct to carriers approach in 190 countries.&#xD;
12
+ SMS Web based solution allows marketers to empower the strenght of emarketing managing in a clic their own sms &amp; email marketing campaigns. &#xD;
13
+ &#xD;
14
+ Start sending SMS internationally in minutes for free at www.octopush.com</description>
15
+ <notes>First package of this extension.</notes>
16
+ <authors><author><name>Carl</name><user>Jean</user><email>jeancarl@octopush.com</email></author></authors>
17
+ <date>2015-10-15</date>
18
+ <time>18:17:13</time>
19
+ <contents><target name="magelocal"><dir name="Octopush"><dir name="OctopushSms"><dir name="Block"><dir name="Campaign"><file name="Ajax.php" hash="6acb63c670e33053db475ef576731605"/><dir name="Controller"><file name="Grid.php" hash="0b5f93c36433090785780668a2f31591"/></dir><dir name="Edit"><file name="Form.php" hash="f4c6a1ac30ada017afdd4149319eb261"/><file name="FormToErase.php" hash="f4c6a1ac30ada017afdd4149319eb261"/><file name="Info.php" hash="0ff8ce3fae558f1982cc4115a4a04331"/><file name="Tabs.php" hash="15656dbf68cd725801979221a7678838"/></dir><file name="Edit.php" hash="d2de6bcb6c3395b12098cf7c0e4691ae"/><file name="Edit_1.php" hash="8eff35e48abcc8fa606426e97d84f7ee"/><file name="Grid.php" hash="cd97067217c69769270a243fc2186b60"/><dir name="Renderer"><file name="Price.php" hash="3f1b77457071b1971aa6f1e3ec5c5a93"/><file name="Status.php" hash="e14c4ca98a7a9230e238c8d67dcb5e68"/></dir></dir><file name="Campaignblock.php" hash="24f864bcc3f703f0dc1fd7effa011c78"/><file name="CampaignblockTODOREMOVE.php" hash="24f864bcc3f703f0dc1fd7effa011c78"/><file name="Messages.php" hash="7736dea4c99e80b2f57fc96e6267bca0"/><file name="Messages_1.php" hash="11f190ec56c7a9fee9a84af3709990a7"/><file name="News.php" hash="4e1d1a5a4fb0afaa4d563004309396f0"/><dir name="Recipient"><dir name="Controller"><file name="Grid.php" hash="5d3913aef12b14ceae7a2ebfe22dd5d4"/></dir><file name="Grid.php" hash="155fece3a61e8a91b15052d5ab0e409d"/><dir name="Renderer"><file name="Status.php" hash="b711614af483bfc14137e7f109f99c83"/></dir></dir><file name="Setting.php" hash="ed48a9a756770877d538bc0f18b85cec"/></dir><dir name="Helper"><file name="API.php" hash="d124fef4d4f30f4636fdb1a662f3aa3c"/><dir name="API_SMS_PHP_Octopush"><file name="balance.php" hash="b1c84ddd97b15e92dfd704b958945319"/><file name="campagne.php" hash="1cd358405cc76e3a76e809016716499f"/><file name="config.inc.php" hash="9c1aedb02dec9811fafc5abe5497f03f"/><file name="create_sub_account.php" hash="634dce45c5a23c85057f3806b28c3d05"/><file name="credit_sub_account.php" hash="63449fc16317b605ebbfbdfbe751d69c"/><file name="edit_options.php" hash="2209b44376cdb8b4108f387b9ba4010c"/><file name="get_user_info.php" hash="f365fb69be5f5fb1fd6f93978aff3af2"/><file name="octopush_web_services.inc.php" hash="37eb272884abaabb01994250f02214d2"/><file name="sms.inc.php" hash="f6b7d8f9d0552e1ad82333a4b7d77720"/><file name="sms_batch.php" hash="cfd9734b3174fe4c833c7ec486752cd3"/><file name="sms_parts.php" hash="1118bb35c335be40e057b7731ef7f7db"/></dir><file name="Campaign.php" hash="d1c60677f3aee638b0dd7aa9f8c3886d"/><file name="Customer.php" hash="135a4bb59e5114e10756f667f1cd0729"/><file name="Data.php" hash="3431cd751668a151f299234282612bc4"/><file name="Message.php" hash="c21ecf0083607deab9144a6717ba1772"/><file name="Statistic.php" hash="7168eeef1746e11fbf4a6137352ed4c9"/></dir><dir name="Model"><file name="Campaign.php" hash="61a10d764678aec9610a36351b95ec64"/><file name="Message.php" hash="b521126d88b488b745b98fc590d23ade"/><dir name="Mysql4"><dir name="Campaign"><file name="Collection.php" hash="b886665385c56cea89a379fcdc4178fd"/></dir><file name="Campaign.php" hash="524b16d86938da59a8f24a2f127ef7e6"/><dir name="Message"><file name="Collection.php" hash="9884cb7f2fcdf9c5c515d22f93eb7b80"/></dir><file name="Message.php" hash="0249a5083bfa83dc2e18282aceef3ae8"/><dir name="Phoneprefix"><file name="Collection.php" hash="cf285b0566cb3f725c02a917e3a1027a"/></dir><file name="Phoneprefix.php" hash="ce55722a6f0b184977f4fb0c3e88367a"/><dir name="Recipient"><file name="Collection.php" hash="cb508d0aee6bd3c4667bd755218e728e"/></dir><file name="Recipient.php" hash="3e3692352c270d18b60819061cb0e88d"/><dir name="Setting"><file name="Collection.php" hash="50bc38837e68d9dda688a8c1bac15b7d"/></dir><file name="Setting.php" hash="0aab6597aff3741b25ce62987a3f4575"/><dir name="Test"><file name="Collection.php" hash="28b4c8e3b6e7472dc0b8c059cb71b85a"/></dir><file name="Test.php" hash="78492f4f04c78e60a99d3b8b4f78bca5"/></dir><dir name="Observer"><file name="AbstractObserver.php" hash="35054701f97419284864fa36b72df797"/><file name="Observer.php" hash="e3a37bacb73b1f171f9f4fc034cc7c49"/></dir><file name="Phoneprefix.php" hash="3952360248f22460e53d875a7ae50a93"/><file name="Recipient.php" hash="5012fb1f627b1f0606060a4bff16d9ea"/><file name="Setting.php" hash="8d94e08235cee80d1534075cba68c30c"/><file name="Test.php" hash="412e20ccf1327506c7625266b56d4733"/></dir><dir name="controllers"><dir name="Adminhtml"><file name="IndexController.php" hash="aac902b74c53d6b76caaccb68d69f30a"/></dir><file name="IndexController.php" hash="394b7e9a13ec21d3956d2b9894539710"/></dir><dir name="etc"><file name="config.xml" hash="d87991201587d04f14de7fe87412fc23"/></dir><dir name="sql"><dir name="octopush_octopushsms_setup"><file name="install-1.0.0.php" hash="c40d77ece545d29ab3bc1b2834d799d5"/><file name="mysql4-install-0.1.0" hash="2ce4a90dc189ea22ab687010cb1572c1"/></dir></dir><file name="tmp.txt" hash="7f06d4475de3b74e3fa057957828ac5f"/></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="template"><dir name="octopushsms"><file name="afficher.phtml" hash="59c55903782b736d3ebcc257ab52b5b8"/><file name="ajax.phtml" hash="444bcb3a3fcf8389296c49467f27e1d6"/><file name="campaign.phtml" hash="b1e2293a0cec50b2cb5a324029723d39"/><file name="chooseRecipient.phtml" hash="945312c148607f8a4e425133073bd3a3"/><file name="info.phtml" hash="a4f214d4cdb0cefa928947f7f2239028"/><file name="messages.phtml" hash="bc549ddfc2c2288a69a938e9cb76a340"/><file name="news.phtml" hash="3789e8398e767fe7d279a440794694a4"/><file name="notice.phtml" hash="5acbab29e39cf589fc560b80afaf5501"/></dir></dir><dir name="layout"><file name="octopushsms.xml" hash="bce18d854b9bf0a01a991e757804281e"/></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Octopush_OctopushSms.xml" hash="3d2fd26a34985dd42c36cda41316803e"/></dir></target><target name="magelocale"><dir name="fr_FR"><file name="Octopush_OctopushSms.csv" hash="2fbe75d88ea1f03010015b28f635e3c4"/></dir></target><target name="magemedia"><dir name="octopushsms"><file name="example.csv" hash="3d824c528256e2639bba00cbcb1c23a0"/></dir></target><target name="mage"><dir name="js"><dir name="octopushsms"><file name="octopushsms.js" hash="6c546a37ee03bb90ac3dccd6b9856192"/></dir></dir></target><target name="mageskin"><dir name="adminhtml"><dir name="base"><dir name="default"><dir name="octopushsms"><file name="octopushsms.css" hash="fecbbe3fc42b6a8c017e37b09201f0c2"/><file name="grid.css" hash="97327fd006e503b3e1697aa15bfb38b9"/></dir></dir></dir></dir></target></contents>
20
+ <compatible/>
21
+ <dependencies><required><php><min>5.3.2</min><max>6.0.0</max></php></required></dependencies>
22
+ </package>
skin/adminhtml/base/default/octopushsms/grid.css ADDED
@@ -0,0 +1,242 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ @charset "UTF-8";
2
+ /*-----------------------------------*\
3
+
4
+ $TOAST-GRID
5
+
6
+ An insane toastgrid.
7
+ You'd be mad to use it.
8
+
9
+ Usage
10
+ =====
11
+
12
+ Assuming default values:
13
+
14
+ <div class="toastgrid">
15
+ <div class="toastgrid__col toastgrid__col--1-of-2">
16
+ A half-width column.
17
+ </div>
18
+ <div class="toastgrid__col toastgrid__col--1-of-4 toastgrid__col--pull-1-of-4">
19
+ A quarter, pulled left by its own width. You get this, right?
20
+ </div>
21
+ </div>
22
+
23
+
24
+ Customisation
25
+ =============
26
+
27
+ $toastgrid-namespace and $toastgrid-column-namespace
28
+ adjusts the class names for the toastgrid. With
29
+ default values, toastgrid wrappers have a class
30
+ of '.toastgrid' and columns '.toastgrid__col'.
31
+
32
+ $col-groups(n) adjusts column divisions.
33
+ For example, $col-groups(12) will produce
34
+ a 12-column toastgrid. $col-groups(3,6,8)
35
+ will produce a 3-, 6-, and 8-column toastgrid.
36
+
37
+ $gutter-width is—you guessed it—the gutter
38
+ width. Accepts any unit.
39
+
40
+ That's it. Have fun.
41
+
42
+ \*-----------------------------------*/
43
+ .toastgrid {
44
+ list-style: none;
45
+ margin-left: -20px; }
46
+ .toastgrid > .toastgrid__col--2-of-2, .toastgrid > .toastgrid__col--3-of-3, .toastgrid > .toastgrid__col--4-of-4, .toastgrid > .toastgrid__col--5-of-5, .toastgrid > .toastgrid__col--6-of-6, .toastgrid > .toastgrid__col--8-of-8, .toastgrid > .toastgrid__col--12-of-12 {
47
+ width: 100%; }
48
+ .toastgrid > .toastgrid__col--1-of-2, .toastgrid > .toastgrid__col--2-of-4, .toastgrid > .toastgrid__col--3-of-6, .toastgrid > .toastgrid__col--4-of-8, .toastgrid > .toastgrid__col--6-of-12 {
49
+ width: 50%; }
50
+ .toastgrid > .toastgrid__col--1-of-3, .toastgrid > .toastgrid__col--2-of-6, .toastgrid > .toastgrid__col--4-of-12 {
51
+ width: 33.33333%; }
52
+ .toastgrid > .toastgrid__col--2-of-3, .toastgrid > .toastgrid__col--4-of-6, .toastgrid > .toastgrid__col--8-of-12 {
53
+ width: 66.66667%; }
54
+ .toastgrid > .toastgrid__col--1-of-4, .toastgrid > .toastgrid__col--2-of-8, .toastgrid > .toastgrid__col--3-of-12 {
55
+ width: 25%; }
56
+ .toastgrid > .toastgrid__col--3-of-4, .toastgrid > .toastgrid__col--6-of-8, .toastgrid > .toastgrid__col--9-of-12 {
57
+ width: 75%; }
58
+ .toastgrid > .toastgrid__col--push-2-of-2, .toastgrid > .toastgrid__col--push-3-of-3, .toastgrid > .toastgrid__col--push-4-of-4, .toastgrid > .toastgrid__col--push-5-of-5, .toastgrid > .toastgrid__col--push-6-of-6, .toastgrid > .toastgrid__col--push-8-of-8, .toastgrid > .toastgrid__col--push-12-of-12 {
59
+ margin-left: 100%; }
60
+ .toastgrid > .toastgrid__col--push-1-of-2, .toastgrid > .toastgrid__col--push-2-of-4, .toastgrid > .toastgrid__col--push-3-of-6, .toastgrid > .toastgrid__col--push-4-of-8, .toastgrid > .toastgrid__col--push-6-of-12 {
61
+ margin-left: 50%; }
62
+ .toastgrid > .toastgrid__col--push-1-of-3, .toastgrid > .toastgrid__col--push-2-of-6, .toastgrid > .toastgrid__col--push-4-of-12 {
63
+ margin-left: 33.33333%; }
64
+ .toastgrid > .toastgrid__col--push-2-of-3, .toastgrid > .toastgrid__col--push-4-of-6, .toastgrid > .toastgrid__col--push-8-of-12 {
65
+ margin-left: 66.66667%; }
66
+ .toastgrid > .toastgrid__col--push-1-of-4, .toastgrid > .toastgrid__col--push-2-of-8, .toastgrid > .toastgrid__col--push-3-of-12 {
67
+ margin-left: 25%; }
68
+ .toastgrid > .toastgrid__col--push-3-of-4, .toastgrid > .toastgrid__col--push-6-of-8, .toastgrid > .toastgrid__col--push-9-of-12 {
69
+ margin-left: 75%; }
70
+ .toastgrid > .toastgrid__col--pull-2-of-2, .toastgrid > .toastgrid__col--pull-3-of-3, .toastgrid > .toastgrid__col--pull-4-of-4, .toastgrid > .toastgrid__col--pull-5-of-5, .toastgrid > .toastgrid__col--pull-6-of-6, .toastgrid > .toastgrid__col--pull-8-of-8, .toastgrid > .toastgrid__col--pull-12-of-12 {
71
+ margin-left: -100%; }
72
+ .toastgrid > .toastgrid__col--pull-1-of-2, .toastgrid > .toastgrid__col--pull-2-of-4, .toastgrid > .toastgrid__col--pull-3-of-6, .toastgrid > .toastgrid__col--pull-4-of-8, .toastgrid > .toastgrid__col--pull-6-of-12 {
73
+ margin-left: -50%; }
74
+ .toastgrid > .toastgrid__col--pull-1-of-3, .toastgrid > .toastgrid__col--pull-2-of-6, .toastgrid > .toastgrid__col--pull-4-of-12 {
75
+ margin-left: -33.33333%; }
76
+ .toastgrid > .toastgrid__col--pull-2-of-3, .toastgrid > .toastgrid__col--pull-4-of-6, .toastgrid > .toastgrid__col--pull-8-of-12 {
77
+ margin-left: -66.66667%; }
78
+ .toastgrid > .toastgrid__col--pull-1-of-4, .toastgrid > .toastgrid__col--pull-2-of-8, .toastgrid > .toastgrid__col--pull-3-of-12 {
79
+ margin-left: -25%; }
80
+ .toastgrid > .toastgrid__col--pull-3-of-4, .toastgrid > .toastgrid__col--pull-6-of-8, .toastgrid > .toastgrid__col--pull-9-of-12 {
81
+ margin-left: -75%; }
82
+ .toastgrid > .toastgrid__col--1-of-5 {
83
+ width: 20%; }
84
+ .toastgrid > .toastgrid__col--push-1-of-5 {
85
+ margin-left: 20%; }
86
+ .toastgrid > .toastgrid__col--pull-1-of-5 {
87
+ margin-left: -20%; }
88
+ .toastgrid > .toastgrid__col--2-of-5 {
89
+ width: 40%; }
90
+ .toastgrid > .toastgrid__col--push-2-of-5 {
91
+ margin-left: 40%; }
92
+ .toastgrid > .toastgrid__col--pull-2-of-5 {
93
+ margin-left: -40%; }
94
+ .toastgrid > .toastgrid__col--3-of-5 {
95
+ width: 60%; }
96
+ .toastgrid > .toastgrid__col--push-3-of-5 {
97
+ margin-left: 60%; }
98
+ .toastgrid > .toastgrid__col--pull-3-of-5 {
99
+ margin-left: -60%; }
100
+ .toastgrid > .toastgrid__col--4-of-5 {
101
+ width: 80%; }
102
+ .toastgrid > .toastgrid__col--push-4-of-5 {
103
+ margin-left: 80%; }
104
+ .toastgrid > .toastgrid__col--pull-4-of-5 {
105
+ margin-left: -80%; }
106
+ .toastgrid > .toastgrid__col--1-of-6 {
107
+ width: 16.66667%; }
108
+ .toastgrid > .toastgrid__col--push-1-of-6 {
109
+ margin-left: 16.66667%; }
110
+ .toastgrid > .toastgrid__col--pull-1-of-6 {
111
+ margin-left: -16.66667%; }
112
+ .toastgrid > .toastgrid__col--5-of-6 {
113
+ width: 83.33333%; }
114
+ .toastgrid > .toastgrid__col--push-5-of-6 {
115
+ margin-left: 83.33333%; }
116
+ .toastgrid > .toastgrid__col--pull-5-of-6 {
117
+ margin-left: -83.33333%; }
118
+ .toastgrid > .toastgrid__col--1-of-8 {
119
+ width: 12.5%; }
120
+ .toastgrid > .toastgrid__col--push-1-of-8 {
121
+ margin-left: 12.5%; }
122
+ .toastgrid > .toastgrid__col--pull-1-of-8 {
123
+ margin-left: -12.5%; }
124
+ .toastgrid > .toastgrid__col--3-of-8 {
125
+ width: 37.5%; }
126
+ .toastgrid > .toastgrid__col--push-3-of-8 {
127
+ margin-left: 37.5%; }
128
+ .toastgrid > .toastgrid__col--pull-3-of-8 {
129
+ margin-left: -37.5%; }
130
+ .toastgrid > .toastgrid__col--5-of-8 {
131
+ width: 62.5%; }
132
+ .toastgrid > .toastgrid__col--push-5-of-8 {
133
+ margin-left: 62.5%; }
134
+ .toastgrid > .toastgrid__col--pull-5-of-8 {
135
+ margin-left: -62.5%; }
136
+ .toastgrid > .toastgrid__col--7-of-8 {
137
+ width: 87.5%; }
138
+ .toastgrid > .toastgrid__col--push-7-of-8 {
139
+ margin-left: 87.5%; }
140
+ .toastgrid > .toastgrid__col--pull-7-of-8 {
141
+ margin-left: -87.5%; }
142
+ .toastgrid > .toastgrid__col--1-of-12 {
143
+ width: 8.33333%; }
144
+ .toastgrid > .toastgrid__col--push-1-of-12 {
145
+ margin-left: 8.33333%; }
146
+ .toastgrid > .toastgrid__col--pull-1-of-12 {
147
+ margin-left: -8.33333%; }
148
+ .toastgrid > .toastgrid__col--2-of-12 {
149
+ width: 16.66667%; }
150
+ .toastgrid > .toastgrid__col--push-2-of-12 {
151
+ margin-left: 16.66667%; }
152
+ .toastgrid > .toastgrid__col--pull-2-of-12 {
153
+ margin-left: -16.66667%; }
154
+ .toastgrid > .toastgrid__col--5-of-12 {
155
+ width: 41.66667%; }
156
+ .toastgrid > .toastgrid__col--push-5-of-12 {
157
+ margin-left: 41.66667%; }
158
+ .toastgrid > .toastgrid__col--pull-5-of-12 {
159
+ margin-left: -41.66667%; }
160
+ .toastgrid > .toastgrid__col--7-of-12 {
161
+ width: 58.33333%; }
162
+ .toastgrid > .toastgrid__col--push-7-of-12 {
163
+ margin-left: 58.33333%; }
164
+ .toastgrid > .toastgrid__col--pull-7-of-12 {
165
+ margin-left: -58.33333%; }
166
+ .toastgrid > .toastgrid__col--10-of-12 {
167
+ width: 83.33333%; }
168
+ .toastgrid > .toastgrid__col--push-10-of-12 {
169
+ margin-left: 83.33333%; }
170
+ .toastgrid > .toastgrid__col--pull-10-of-12 {
171
+ margin-left: -83.33333%; }
172
+ .toastgrid > .toastgrid__col--11-of-12 {
173
+ width: 91.66667%; }
174
+ .toastgrid > .toastgrid__col--push-11-of-12 {
175
+ margin-left: 91.66667%; }
176
+ .toastgrid > .toastgrid__col--pull-11-of-12 {
177
+ margin-left: -91.66667%; }
178
+ .toastgrid .toastgrid__col {
179
+ -webkit-box-sizing: border-box;
180
+ -moz-box-sizing: border-box;
181
+ box-sizing: border-box;
182
+ display: inline-block;
183
+ margin-right: -.25em;
184
+ min-height: 1px;
185
+ padding-left: 20px;
186
+ vertical-align: top; }
187
+ @media (max-width: 700px) {
188
+ .toastgrid .toastgrid__col {
189
+ display: block;
190
+ margin-left: 0;
191
+ margin-right: 0;
192
+ width: auto; } }
193
+ @media (max-width: 700px) and (min-width: 480px) {
194
+ .toastgrid .toastgrid__col[class*="toastgrid__col--m-"] {
195
+ display: inline-block;
196
+ margin-right: -.24em; }
197
+ .toastgrid .toastgrid__col.toastgrid__col--m-1-of-2, .toastgrid .toastgrid__col.toastgrid__col--m-2-of-4 {
198
+ width: 50%; }
199
+ .toastgrid .toastgrid__col.toastgrid__col--m-1-of-3 {
200
+ width: 33.33333%; }
201
+ .toastgrid .toastgrid__col.toastgrid__col--m-2-of-3 {
202
+ width: 66.66667%; }
203
+ .toastgrid .toastgrid__col.toastgrid__col--m-1-of-4 {
204
+ width: 25%; }
205
+ .toastgrid .toastgrid__col.toastgrid__col--m-3-of-4 {
206
+ width: 75%; } }
207
+ @media (max-width: 480px) {
208
+ .toastgrid .toastgrid__col[class*="toastgrid__col--s-"] {
209
+ display: inline-block;
210
+ margin-right: -.24em; }
211
+ .toastgrid .toastgrid__col.toastgrid__col--s-1-of-2, .toastgrid .toastgrid__col.toastgrid__col--s-2-of-4 {
212
+ width: 50%; }
213
+ .toastgrid .toastgrid__col.toastgrid__col--s-1-of-3 {
214
+ width: 33.33333%; }
215
+ .toastgrid .toastgrid__col.toastgrid__col--s-2-of-3 {
216
+ width: 66.66667%; }
217
+ .toastgrid .toastgrid__col.toastgrid__col--s-1-of-4 {
218
+ width: 25%; }
219
+ .toastgrid .toastgrid__col.toastgrid__col--s-3-of-4 {
220
+ width: 75%; } }
221
+ .toastgrid .toastgrid__col--centered {
222
+ display: block;
223
+ margin-left: auto;
224
+ margin-right: auto; }
225
+ .toastgrid .toastgrid__col--d-first {
226
+ float: left; }
227
+ .toastgrid .toastgrid__col--d-last {
228
+ float: right; }
229
+ .toastgrid.toastgrid--no-gutter {
230
+ margin-left: 0;
231
+ width: 100%; }
232
+ .toastgrid.toastgrid--no-gutter .toastgrid__col {
233
+ padding-left: 0; }
234
+ .toastgrid.toastgrid--no-gutter .toastgrid__col--span-all {
235
+ margin-left: 0;
236
+ width: 100%; }
237
+ .toastgrid .toastgrid__col--ab {
238
+ vertical-align: bottom; }
239
+ .toastgrid .toastgrid__col--am {
240
+ vertical-align: middle; }
241
+
242
+ /*# sourceMappingURL=toastgrid.css.map */
skin/adminhtml/base/default/octopushsms/octopushsms.css ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ .octopushsms-autocomplete ul { border:1px solid #5c7989; background-color:#f9f5f0; }
2
+ .octopushsms-autocomplete li { text-align:left; border-bottom:1px solid #f4eee7; padding:2px 8px 1px 8px; cursor:pointer; }
3
+ .octopushsms-autocomplete li.odd { background-color:#fffefb; }
4
+ .octopushsms-autocomplete li.selected { background-color:#f7e8dd; }
5
+ .octopushsms-autocomplete li:hover { background-color:#f7e8dd; }
6
+
7
+ .text_td {width:25%;vertical-align:top}
8
+ th.text_td{vertical-align: middle}
9
+ .data_td {width:50%}
10
+ .message_textarea {width:90%;}
11
+ .os_row{width: 100%; display: table;}
12
+ table.messages_data{max-width:1024px;width:100%}
13
+
14
+ #block_infos label {
15
+ width: 45%;
16
+ }
17
+ #block_infos label + div {
18
+ padding-top: 3px;
19
+ float: right;
20
+ width: 50%;
21
+ }
22
+ #block_infos #balance {
23
+ font-weight: bold;
24
+ color: red;
25
+ }
26
+
27
+
28
+
29
+
30
+