Licentia_Fidelitas - Version 2.2.2.0

Version Notes

Email marketing

Download this release

Release Info

Developer bento
Extension Licentia_Fidelitas
Version 2.2.2.0
Comparing to
See all releases


Version 2.2.2.0

Files changed (85) hide show
  1. app/code/community/Licentia/Fidelitas/.DS_Store +0 -0
  2. app/code/community/Licentia/Fidelitas/Block/Adminhtml/Account.php +33 -0
  3. app/code/community/Licentia/Fidelitas/Block/Adminhtml/Account/New.php +29 -0
  4. app/code/community/Licentia/Fidelitas/Block/Adminhtml/Account/New/Edit.php +37 -0
  5. app/code/community/Licentia/Fidelitas/Block/Adminhtml/Account/New/Edit/Form.php +34 -0
  6. app/code/community/Licentia/Fidelitas/Block/Adminhtml/Account/New/Edit/Tab/Api.php +40 -0
  7. app/code/community/Licentia/Fidelitas/Block/Adminhtml/Account/New/Edit/Tab/Form.php +118 -0
  8. app/code/community/Licentia/Fidelitas/Block/Adminhtml/Account/New/Edit/Tabs.php +46 -0
  9. app/code/community/Licentia/Fidelitas/Block/Adminhtml/Account/Support.php +29 -0
  10. app/code/community/Licentia/Fidelitas/Block/Adminhtml/Account/Support/Edit.php +37 -0
  11. app/code/community/Licentia/Fidelitas/Block/Adminhtml/Account/Support/Edit/Form.php +34 -0
  12. app/code/community/Licentia/Fidelitas/Block/Adminhtml/Account/Support/Edit/Tab/Form.php +65 -0
  13. app/code/community/Licentia/Fidelitas/Block/Adminhtml/Account/Support/Edit/Tabs.php +40 -0
  14. app/code/community/Licentia/Fidelitas/Block/Adminhtml/Account/Sync.php +28 -0
  15. app/code/community/Licentia/Fidelitas/Block/Adminhtml/Account/Sync/Edit.php +36 -0
  16. app/code/community/Licentia/Fidelitas/Block/Adminhtml/Account/Sync/Edit/Form.php +34 -0
  17. app/code/community/Licentia/Fidelitas/Block/Adminhtml/Account/Sync/Edit/Tab/Form.php +51 -0
  18. app/code/community/Licentia/Fidelitas/Block/Adminhtml/Account/Sync/Edit/Tabs.php +40 -0
  19. app/code/community/Licentia/Fidelitas/Block/Adminhtml/Autoresponders.php +29 -0
  20. app/code/community/Licentia/Fidelitas/Block/Adminhtml/Autoresponders/Edit.php +48 -0
  21. app/code/community/Licentia/Fidelitas/Block/Adminhtml/Autoresponders/Edit/Form.php +32 -0
  22. app/code/community/Licentia/Fidelitas/Block/Adminhtml/Autoresponders/Edit/Tab/Data.php +128 -0
  23. app/code/community/Licentia/Fidelitas/Block/Adminhtml/Autoresponders/Edit/Tab/Main.php +141 -0
  24. app/code/community/Licentia/Fidelitas/Block/Adminhtml/Autoresponders/Edit/Tabs.php +50 -0
  25. app/code/community/Licentia/Fidelitas/Block/Adminhtml/Autoresponders/Grid.php +100 -0
  26. app/code/community/Licentia/Fidelitas/Block/Adminhtml/Events.php +30 -0
  27. app/code/community/Licentia/Fidelitas/Block/Adminhtml/Events/Grid.php +137 -0
  28. app/code/community/Licentia/Fidelitas/Block/Adminhtml/Lists.php +32 -0
  29. app/code/community/Licentia/Fidelitas/Block/Adminhtml/Lists/Edit.php +50 -0
  30. app/code/community/Licentia/Fidelitas/Block/Adminhtml/Lists/Edit/Form.php +34 -0
  31. app/code/community/Licentia/Fidelitas/Block/Adminhtml/Lists/Edit/Tab/Main.php +105 -0
  32. app/code/community/Licentia/Fidelitas/Block/Adminhtml/Lists/Edit/Tabs.php +25 -0
  33. app/code/community/Licentia/Fidelitas/Block/Adminhtml/Lists/Grid.php +80 -0
  34. app/code/community/Licentia/Fidelitas/Block/Adminhtml/Subscribers.php +32 -0
  35. app/code/community/Licentia/Fidelitas/Block/Adminhtml/Subscribers/Edit.php +38 -0
  36. app/code/community/Licentia/Fidelitas/Block/Adminhtml/Subscribers/Edit/Form.php +34 -0
  37. app/code/community/Licentia/Fidelitas/Block/Adminhtml/Subscribers/Edit/Tab/Form.php +58 -0
  38. app/code/community/Licentia/Fidelitas/Block/Adminhtml/Subscribers/Edit/Tabs.php +39 -0
  39. app/code/community/Licentia/Fidelitas/Block/Adminhtml/Subscribers/Grid.php +139 -0
  40. app/code/community/Licentia/Fidelitas/Block/Adminhtml/System/Config/Form/Field/Test.php +13 -0
  41. app/code/community/Licentia/Fidelitas/Block/Egoimmerce.php +133 -0
  42. app/code/community/Licentia/Fidelitas/Helper/Data.php +30 -0
  43. app/code/community/Licentia/Fidelitas/Model/Account.php +41 -0
  44. app/code/community/Licentia/Fidelitas/Model/Autoresponders.php +269 -0
  45. app/code/community/Licentia/Fidelitas/Model/Egoi.php +572 -0
  46. app/code/community/Licentia/Fidelitas/Model/Events.php +25 -0
  47. app/code/community/Licentia/Fidelitas/Model/Extra.php +93 -0
  48. app/code/community/Licentia/Fidelitas/Model/Lists.php +207 -0
  49. app/code/community/Licentia/Fidelitas/Model/Mysql4/Account.php +24 -0
  50. app/code/community/Licentia/Fidelitas/Model/Mysql4/Account/Collection.php +25 -0
  51. app/code/community/Licentia/Fidelitas/Model/Mysql4/Autoresponders.php +24 -0
  52. app/code/community/Licentia/Fidelitas/Model/Mysql4/Autoresponders/Collection.php +25 -0
  53. app/code/community/Licentia/Fidelitas/Model/Mysql4/Events.php +24 -0
  54. app/code/community/Licentia/Fidelitas/Model/Mysql4/Events/Collection.php +25 -0
  55. app/code/community/Licentia/Fidelitas/Model/Mysql4/Extra.php +11 -0
  56. app/code/community/Licentia/Fidelitas/Model/Mysql4/Extra/Collection.php +13 -0
  57. app/code/community/Licentia/Fidelitas/Model/Mysql4/Lists.php +24 -0
  58. app/code/community/Licentia/Fidelitas/Model/Mysql4/Lists/Collection.php +25 -0
  59. app/code/community/Licentia/Fidelitas/Model/Mysql4/Subscribers.php +24 -0
  60. app/code/community/Licentia/Fidelitas/Model/Mysql4/Subscribers/Collection.php +26 -0
  61. app/code/community/Licentia/Fidelitas/Model/Observer.php +43 -0
  62. app/code/community/Licentia/Fidelitas/Model/Source/Addressattributes.php +19 -0
  63. app/code/community/Licentia/Fidelitas/Model/Source/Method.php +15 -0
  64. app/code/community/Licentia/Fidelitas/Model/Source/Sender.php +18 -0
  65. app/code/community/Licentia/Fidelitas/Model/Subscribers.php +611 -0
  66. app/code/community/Licentia/Fidelitas/controllers/Adminhtml/Fidelitas/AccountController.php +290 -0
  67. app/code/community/Licentia/Fidelitas/controllers/Adminhtml/Fidelitas/AutorespondersController.php +208 -0
  68. app/code/community/Licentia/Fidelitas/controllers/Adminhtml/Fidelitas/EventsController.php +85 -0
  69. app/code/community/Licentia/Fidelitas/controllers/Adminhtml/Fidelitas/ListsController.php +121 -0
  70. app/code/community/Licentia/Fidelitas/controllers/Adminhtml/Fidelitas/SubscribersController.php +169 -0
  71. app/code/community/Licentia/Fidelitas/controllers/CallbackController.php +57 -0
  72. app/code/community/Licentia/Fidelitas/etc/adminhtml.xml +84 -0
  73. app/code/community/Licentia/Fidelitas/etc/config.xml +241 -0
  74. app/code/community/Licentia/Fidelitas/etc/system.xml +119 -0
  75. app/code/community/Licentia/Fidelitas/sql/fidelitas_setup/mysql4-install-2.0.0.0.php +157 -0
  76. app/code/community/Licentia/Fidelitas/sql/fidelitas_setup/mysql4-upgrade-2.0.0.5-2.1.0.0.php +70 -0
  77. app/code/community/Licentia/Fidelitas/sql/fidelitas_setup/mysql4-upgrade-2.1.0.4-2.1.0.5.php +24 -0
  78. app/code/community/Licentia/Fidelitas/sql/fidelitas_setup/mysql4-upgrade-2.2.0.4-2.2.0.5.php +24 -0
  79. app/design/adminhtml/default/default/layout/fidelitas.xml +8 -0
  80. app/design/adminhtml/default/default/template/fidelitas/account/account.phtml +128 -0
  81. app/design/adminhtml/default/default/template/fidelitas/account/new.phtml +40 -0
  82. app/design/frontend/base/default/layout/fidelitas.xml +8 -0
  83. app/design/frontend/base/default/template/fidelitas/egoimmerce.phtml +80 -0
  84. app/etc/modules/Licentia_Fidelitas.xml +10 -0
  85. package.xml +18 -0
app/code/community/Licentia/Fidelitas/.DS_Store ADDED
Binary file
app/code/community/Licentia/Fidelitas/Block/Adminhtml/Account.php ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Licentia Fidelitas - Advanced Email and SMS Marketing Automation for E-Goi
5
+ *
6
+ * NOTICE OF LICENSE
7
+ * This source file is subject to the Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International
8
+ * It is available through the world-wide-web at this URL:
9
+ * http://creativecommons.org/licenses/by-nc-nd/4.0/
10
+ *
11
+ * @title Advanced Email and SMS Marketing Automation
12
+ * @category Marketing
13
+ * @package Licentia
14
+ * @author Bento Vilas Boas <bento@licentia.pt>
15
+ * @copyright Copyright (c) 2016 E-Goi - http://e-goi.com
16
+ * @license Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International
17
+ */
18
+ class Licentia_Fidelitas_Block_Adminhtml_Account extends Mage_Adminhtml_Block_Template
19
+ {
20
+
21
+ public function __construct()
22
+ {
23
+ parent::__construct();
24
+
25
+ $result = Mage::getModel('fidelitas/account')->getAccount();
26
+
27
+ $this->setTitle($this->__('Account Details'));
28
+ $this->setCompany($result);
29
+
30
+ $this->setTemplate('fidelitas/account/account.phtml');
31
+ }
32
+
33
+ }
app/code/community/Licentia/Fidelitas/Block/Adminhtml/Account/New.php ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Licentia Fidelitas - Advanced Email and SMS Marketing Automation for E-Goi
5
+ *
6
+ * NOTICE OF LICENSE
7
+ * This source file is subject to the Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International
8
+ * It is available through the world-wide-web at this URL:
9
+ * http://creativecommons.org/licenses/by-nc-nd/4.0/
10
+ *
11
+ * @title Advanced Email and SMS Marketing Automation
12
+ * @category Marketing
13
+ * @package Licentia
14
+ * @author Bento Vilas Boas <bento@licentia.pt>
15
+ * @copyright Copyright (c) 2016 E-Goi - http://e-goi.com
16
+ * @license Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International
17
+ */
18
+ class Licentia_Fidelitas_Block_Adminhtml_Account_New extends Mage_Adminhtml_Block_Template
19
+ {
20
+
21
+ public function __construct()
22
+ {
23
+ parent::__construct();
24
+
25
+ $this->setTitle('Welcome');
26
+ $this->setTemplate('fidelitas/account/new.phtml');
27
+ }
28
+
29
+ }
app/code/community/Licentia/Fidelitas/Block/Adminhtml/Account/New/Edit.php ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Licentia Fidelitas - Advanced Email and SMS Marketing Automation for E-Goi
5
+ *
6
+ * NOTICE OF LICENSE
7
+ * This source file is subject to the Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International
8
+ * It is available through the world-wide-web at this URL:
9
+ * http://creativecommons.org/licenses/by-nc-nd/4.0/
10
+ *
11
+ * @title Advanced Email and SMS Marketing Automation
12
+ * @category Marketing
13
+ * @package Licentia
14
+ * @author Bento Vilas Boas <bento@licentia.pt>
15
+ * @copyright Copyright (c) 2016 E-Goi - http://e-goi.com
16
+ * @license Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International
17
+ */
18
+ class Licentia_Fidelitas_Block_Adminhtml_Account_New_Edit extends Mage_Adminhtml_Block_Widget_Form_Container
19
+ {
20
+
21
+ public function __construct()
22
+ {
23
+ parent::__construct();
24
+ $this->_objectId = "source_id";
25
+ $this->_blockGroup = "fidelitas";
26
+ $this->_controller = "adminhtml_subscribers";
27
+ $this->_removeButton('back');
28
+ $this->_removeButton('reset');
29
+ }
30
+
31
+ public function getHeaderText()
32
+ {
33
+
34
+ return $this->__("Welcome");
35
+ }
36
+
37
+ }
app/code/community/Licentia/Fidelitas/Block/Adminhtml/Account/New/Edit/Form.php ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Licentia Fidelitas - Advanced Email and SMS Marketing Automation for E-Goi
5
+ *
6
+ * NOTICE OF LICENSE
7
+ * This source file is subject to the Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International
8
+ * It is available through the world-wide-web at this URL:
9
+ * http://creativecommons.org/licenses/by-nc-nd/4.0/
10
+ *
11
+ * @title Advanced Email and SMS Marketing Automation
12
+ * @category Marketing
13
+ * @package Licentia
14
+ * @author Bento Vilas Boas <bento@licentia.pt>
15
+ * @copyright Copyright (c) 2016 E-Goi - http://e-goi.com
16
+ * @license Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International
17
+ */
18
+ class Licentia_Fidelitas_Block_Adminhtml_Account_New_Edit_Form extends Mage_Adminhtml_Block_Widget_Form
19
+ {
20
+
21
+ protected function _prepareForm()
22
+ {
23
+ $form = new Varien_Data_Form(array(
24
+ "id" => "edit_form",
25
+ "action" => $this->getUrl("*/*/save", array("id" => $this->getRequest()->getParam("id"))),
26
+ "method" => "post",
27
+ )
28
+ );
29
+ $form->setUseContainer(true);
30
+ $this->setForm($form);
31
+ return parent::_prepareForm();
32
+ }
33
+
34
+ }
app/code/community/Licentia/Fidelitas/Block/Adminhtml/Account/New/Edit/Tab/Api.php ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Licentia Fidelitas - Advanced Email and SMS Marketing Automation for E-Goi
5
+ *
6
+ * NOTICE OF LICENSE
7
+ * This source file is subject to the Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International
8
+ * It is available through the world-wide-web at this URL:
9
+ * http://creativecommons.org/licenses/by-nc-nd/4.0/
10
+ *
11
+ * @title Advanced Email and SMS Marketing Automation
12
+ * @category Marketing
13
+ * @package Licentia
14
+ * @author Bento Vilas Boas <bento@licentia.pt>
15
+ * @copyright Copyright (c) 2016 E-Goi - http://e-goi.com
16
+ * @license Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International
17
+ */
18
+ class Licentia_Fidelitas_Block_Adminhtml_Account_New_Edit_Tab_Api extends Mage_Adminhtml_Block_Widget_Form
19
+ {
20
+
21
+ protected function _prepareForm()
22
+ {
23
+
24
+ $form = new Varien_Data_Form();
25
+ $this->setForm($form);
26
+ $fieldset = $form->addFieldset("fidelitas_form", array("legend" => $this->__("New E-Goi Customers")));
27
+
28
+ $fieldset->addField('api_key', "text", array(
29
+ "name" => 'api_key',
30
+ "label" => $this->__('Your APi Key'),
31
+ "note" => $this->__('To get your API Key, login into your E-goi.com panel, go to your user menu (upper right corner), select "Integrations" and copy the account API key.'),
32
+ "class" => "required-entry",
33
+ "required" => true,
34
+ ));
35
+
36
+
37
+ return parent::_prepareForm();
38
+ }
39
+
40
+ }
app/code/community/Licentia/Fidelitas/Block/Adminhtml/Account/New/Edit/Tab/Form.php ADDED
@@ -0,0 +1,118 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Licentia Fidelitas - Advanced Email and SMS Marketing Automation for E-Goi
5
+ *
6
+ * NOTICE OF LICENSE
7
+ * This source file is subject to the Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International
8
+ * It is available through the world-wide-web at this URL:
9
+ * http://creativecommons.org/licenses/by-nc-nd/4.0/
10
+ *
11
+ * @title Advanced Email and SMS Marketing Automation
12
+ * @category Marketing
13
+ * @package Licentia
14
+ * @author Bento Vilas Boas <bento@licentia.pt>
15
+ * @copyright Copyright (c) 2016 E-Goi - http://e-goi.com
16
+ * @license Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International
17
+ */
18
+ class Licentia_Fidelitas_Block_Adminhtml_Account_New_Edit_Tab_Form extends Mage_Adminhtml_Block_Widget_Form
19
+ {
20
+
21
+ protected function _prepareForm()
22
+ {
23
+
24
+ $current = Mage::registry("current_account");
25
+
26
+ $form = new Varien_Data_Form();
27
+ $this->setForm($form);
28
+ $fieldset = $form->addFieldset("fidelitas_form", array("legend" => $this->__("New E-Goi Customers")));
29
+
30
+
31
+ $fieldset->addField('idioma', "select", array(
32
+ "values" => array('pt' => 'Portuguese', 'br' => 'Brazilian', 'en' => 'English'),
33
+ "name" => 'idioma',
34
+ "label" => $this->__('Language'),
35
+ ));
36
+
37
+ $fieldset->addField('primeiro_nome', "text", array(
38
+ "label" => $this->__('First Name'),
39
+ "required" => true,
40
+ "name" => 'primeiro_nome',
41
+ ));
42
+
43
+ $fieldset->addField('ultimo_nome', "text", array(
44
+ "label" => $this->__('Last Name'),
45
+ "required" => true,
46
+ "name" => 'ultimo_nome',
47
+ ));
48
+
49
+ $fieldset->addField('email', "text", array(
50
+ "label" => $this->__('Email'),
51
+ "class" => "required-entry validate-email",
52
+ "required" => true,
53
+ "name" => 'email',
54
+ ));
55
+
56
+ $fieldset->addField('utilizador', "text", array(
57
+ "label" => $this->__('Username'),
58
+ "class" => "required-entry",
59
+ "required" => true,
60
+ "name" => 'utilizador',
61
+ ));
62
+
63
+ $fieldset->addField('password', "password", array(
64
+ "label" => $this->__('Password'),
65
+ "class" => "required-entry",
66
+ "required" => true,
67
+ "name" => 'password',
68
+ ));
69
+
70
+ $fieldset->addField('telefone_ind', "select", array(
71
+ "label" => $this->__('Telephone Prefix'),
72
+ 'values' => Licentia_Fidelitas_Model_Subscribers::getPhonePrefixs(),
73
+ "name" => 'telefone_ind',
74
+ ));
75
+
76
+ $fieldset->addField('telefone_numero', "text", array(
77
+ "label" => $this->__('Telephone Number'),
78
+ "name" => 'telefone_numero',
79
+ ));
80
+
81
+
82
+ $fieldset->addField('empresa', "text", array(
83
+ "label" => $this->__('Company'),
84
+ "required" => true,
85
+ "name" => 'empresa',
86
+ ));
87
+
88
+ $fieldset->addField('localidade', "text", array(
89
+ "label" => $this->__('City'),
90
+ "required" => true,
91
+ "name" => 'localidade',
92
+ ));
93
+
94
+ $countries = Mage::getModel('core/locale')->getCountryTranslationList();
95
+ $countries = array_combine(array_values($countries), $countries);
96
+
97
+ $fieldset->addField('pais', "select", array(
98
+ "label" => $this->__('Country'),
99
+ "options" => $countries,
100
+ "name" => 'pais',
101
+ ));
102
+
103
+ $fieldset->addField('terms', "checkbox", array(
104
+ "label" => $this->__('I agree with E-Goi terms and conditions'),
105
+ "note" => $this->__('<a href="http://bo.e-goi.com/termos_uso_en.php" target="_blank" >Click here to read them</a>'),
106
+ "checked" => '1',
107
+ "disabled" => '1',
108
+ "name" => 'terms',
109
+ ));
110
+
111
+ if ($current->getData()) {
112
+ $form->setValues($current->getData());
113
+ }
114
+
115
+ return parent::_prepareForm();
116
+ }
117
+
118
+ }
app/code/community/Licentia/Fidelitas/Block/Adminhtml/Account/New/Edit/Tabs.php ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Licentia Fidelitas - Advanced Email and SMS Marketing Automation for E-Goi
5
+ *
6
+ * NOTICE OF LICENSE
7
+ * This source file is subject to the Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International
8
+ * It is available through the world-wide-web at this URL:
9
+ * http://creativecommons.org/licenses/by-nc-nd/4.0/
10
+ *
11
+ * @title Advanced Email and SMS Marketing Automation
12
+ * @category Marketing
13
+ * @package Licentia
14
+ * @author Bento Vilas Boas <bento@licentia.pt>
15
+ * @copyright Copyright (c) 2016 E-Goi - http://e-goi.com
16
+ * @license Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International
17
+ */
18
+ class Licentia_Fidelitas_Block_Adminhtml_Account_New_Edit_Tabs extends Mage_Adminhtml_Block_Widget_Tabs
19
+ {
20
+
21
+ public function __construct()
22
+ {
23
+ parent::__construct();
24
+ $this->setId("fidelitas_tabs");
25
+ $this->setDestElementId("edit_form");
26
+ $this->setTitle($this->__("E-Goi Integration"));
27
+ }
28
+
29
+ protected function _beforeToHtml()
30
+ {
31
+
32
+ if ($this->getRequest()->getParam('op') == 'api') {
33
+ $tab = 'api';
34
+ } else {
35
+ $tab = 'form';
36
+ }
37
+
38
+ $this->addTab("form_section", array(
39
+ "label" => $this->__("Setup"),
40
+ "title" => $this->__("Setup"),
41
+ "content" => $this->getLayout()->createBlock("fidelitas/adminhtml_account_new_edit_tab_" . $tab)->toHtml(),
42
+ ));
43
+ return parent::_beforeToHtml();
44
+ }
45
+
46
+ }
app/code/community/Licentia/Fidelitas/Block/Adminhtml/Account/Support.php ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Licentia Fidelitas - Advanced Email and SMS Marketing Automation for E-Goi
5
+ *
6
+ * NOTICE OF LICENSE
7
+ * This source file is subject to the Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International
8
+ * It is available through the world-wide-web at this URL:
9
+ * http://creativecommons.org/licenses/by-nc-nd/4.0/
10
+ *
11
+ * @title Advanced Email and SMS Marketing Automation
12
+ * @category Marketing
13
+ * @package Licentia
14
+ * @author Bento Vilas Boas <bento@licentia.pt>
15
+ * @copyright Copyright (c) 2016 E-Goi - http://e-goi.com
16
+ * @license Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International
17
+ */
18
+ class Licentia_Fidelitas_Block_Adminhtml_Account_Support extends Mage_Adminhtml_Block_Widget_Grid_Container
19
+ {
20
+
21
+ public function __construct()
22
+ {
23
+ $this->_controller = 'adminhtml_account_support';
24
+ $this->_blockGroup = 'fidelitas';
25
+
26
+ parent::__construct();
27
+ }
28
+
29
+ }
app/code/community/Licentia/Fidelitas/Block/Adminhtml/Account/Support/Edit.php ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Licentia Fidelitas - Advanced Email and SMS Marketing Automation for E-Goi
5
+ *
6
+ * NOTICE OF LICENSE
7
+ * This source file is subject to the Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International
8
+ * It is available through the world-wide-web at this URL:
9
+ * http://creativecommons.org/licenses/by-nc-nd/4.0/
10
+ *
11
+ * @title Advanced Email and SMS Marketing Automation
12
+ * @category Marketing
13
+ * @package Licentia
14
+ * @author Bento Vilas Boas <bento@licentia.pt>
15
+ * @copyright Copyright (c) 2016 E-Goi - http://e-goi.com
16
+ * @license Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International
17
+ */
18
+ class Licentia_Fidelitas_Block_Adminhtml_Account_Support_Edit extends Mage_Adminhtml_Block_Widget_Form_Container
19
+ {
20
+
21
+ public function __construct()
22
+ {
23
+ parent::__construct();
24
+ $this->_blockGroup = 'fidelitas';
25
+ $this->_controller = "adminhtml_account_support";
26
+ $this->_removeButton('reset');
27
+
28
+ $this->_updateButton('save', 'label', 'Send');
29
+ }
30
+
31
+ public function getHeaderText()
32
+ {
33
+
34
+ return $this->__("Information");
35
+ }
36
+
37
+ }
app/code/community/Licentia/Fidelitas/Block/Adminhtml/Account/Support/Edit/Form.php ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Licentia Fidelitas - Advanced Email and SMS Marketing Automation for E-Goi
5
+ *
6
+ * NOTICE OF LICENSE
7
+ * This source file is subject to the Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International
8
+ * It is available through the world-wide-web at this URL:
9
+ * http://creativecommons.org/licenses/by-nc-nd/4.0/
10
+ *
11
+ * @title Advanced Email and SMS Marketing Automation
12
+ * @category Marketing
13
+ * @package Licentia
14
+ * @author Bento Vilas Boas <bento@licentia.pt>
15
+ * @copyright Copyright (c) 2016 E-Goi - http://e-goi.com
16
+ * @license Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International
17
+ */
18
+ class Licentia_Fidelitas_Block_Adminhtml_Account_Support_Edit_Form extends Mage_Adminhtml_Block_Widget_Form
19
+ {
20
+
21
+ protected function _prepareForm()
22
+ {
23
+ $form = new Varien_Data_Form(array(
24
+ "id" => "edit_form",
25
+ "action" => $this->getUrl("*/*/support"),
26
+ "method" => "post",
27
+ )
28
+ );
29
+ $form->setUseContainer(true);
30
+ $this->setForm($form);
31
+ return parent::_prepareForm();
32
+ }
33
+
34
+ }
app/code/community/Licentia/Fidelitas/Block/Adminhtml/Account/Support/Edit/Tab/Form.php ADDED
@@ -0,0 +1,65 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Licentia_Fidelitas_Block_Adminhtml_Account_Support_Edit_Tab_Form extends Mage_Adminhtml_Block_Widget_Form
4
+ {
5
+
6
+ protected function _prepareForm()
7
+ {
8
+
9
+ $current = Mage::registry('current_account');
10
+
11
+ $form = new Varien_Data_Form();
12
+ $this->setForm($form);
13
+ $fieldset = $form->addFieldset("fidelitas_form", array("legend" => $this->__("Information Channel")));
14
+
15
+ $fieldset->addField('first_name', "text", array(
16
+ "label" => $this->__('First Name'),
17
+ "required" => true,
18
+ "name" => 'name',
19
+ ));
20
+
21
+ $fieldset->addField('last_name', "text", array(
22
+ "label" => $this->__('Last Name'),
23
+ "required" => true,
24
+ "name" => 'name',
25
+ ));
26
+
27
+ $eOp = array();
28
+ $eOp[] = array('value' => 'bug', 'label' => $this->__('Bug Report'));
29
+ $eOp[] = array('value' => 'request', 'label' => $this->__('Request'));
30
+ $eOp[] = array('value' => 'other', 'label' => $this->__('Other Information'));
31
+
32
+
33
+ $fieldset->addField('reason', "select", array(
34
+ "label" => $this->__('Contact Reason'),
35
+ "required" => true,
36
+ 'values' => $eOp,
37
+ "name" => 'reason',
38
+ ));
39
+
40
+ $fieldset->addField('message', "textarea", array(
41
+ "label" => $this->__('Message'),
42
+ "required" => true,
43
+ "name" => 'message',
44
+ "note" => $this->__('Please be as descriptive as possible'),
45
+ ));
46
+
47
+
48
+ $fieldset->addField('email', "text", array(
49
+ "label" => $this->__('Email'),
50
+ "required" => true,
51
+ "name" => 'email',
52
+ ));
53
+
54
+ $fieldset->addField('cellphone', "text", array(
55
+ "label" => $this->__('Phone'),
56
+ "name" => 'cellphone',
57
+ "note" => $this->__('Also include your country prefix'),
58
+ ));
59
+
60
+ $form->setValues($current);
61
+
62
+ return parent::_prepareForm();
63
+ }
64
+
65
+ }
app/code/community/Licentia/Fidelitas/Block/Adminhtml/Account/Support/Edit/Tabs.php ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Licentia Fidelitas - Advanced Email and SMS Marketing Automation for E-Goi
5
+ *
6
+ * NOTICE OF LICENSE
7
+ * This source file is subject to the Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International
8
+ * It is available through the world-wide-web at this URL:
9
+ * http://creativecommons.org/licenses/by-nc-nd/4.0/
10
+ *
11
+ * @title Advanced Email and SMS Marketing Automation
12
+ * @category Marketing
13
+ * @package Licentia
14
+ * @author Bento Vilas Boas <bento@licentia.pt>
15
+ * @copyright Copyright (c) 2016 E-Goi - http://e-goi.com
16
+ * @license Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International
17
+ */
18
+ class Licentia_Fidelitas_Block_Adminhtml_Account_Support_Edit_Tabs extends Mage_Adminhtml_Block_Widget_Tabs
19
+ {
20
+
21
+ public function __construct()
22
+ {
23
+ parent::__construct();
24
+ $this->setId("fidelitas_tabs");
25
+ $this->setDestElementId("edit_form");
26
+ $this->setTitle($this->__("Information"));
27
+ }
28
+
29
+ protected function _beforeToHtml()
30
+ {
31
+
32
+ $this->addTab("form_section", array(
33
+ "label" => $this->__("Information"),
34
+ "title" => $this->__("Information"),
35
+ "content" => $this->getLayout()->createBlock("fidelitas/adminhtml_account_support_edit_tab_form")->toHtml(),
36
+ ));
37
+ return parent::_beforeToHtml();
38
+ }
39
+
40
+ }
app/code/community/Licentia/Fidelitas/Block/Adminhtml/Account/Sync.php ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Licentia Fidelitas - Advanced Email and SMS Marketing Automation for E-Goi
5
+ *
6
+ * NOTICE OF LICENSE
7
+ * This source file is subject to the Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International
8
+ * It is available through the world-wide-web at this URL:
9
+ * http://creativecommons.org/licenses/by-nc-nd/4.0/
10
+ *
11
+ * @title Advanced Email and SMS Marketing Automation
12
+ * @category Marketing
13
+ * @package Licentia
14
+ * @author Bento Vilas Boas <bento@licentia.pt>
15
+ * @copyright Copyright (c) 2016 E-Goi - http://e-goi.com
16
+ * @license Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International
17
+ */
18
+ class Licentia_Fidelitas_Block_Adminhtml_Account_Sync extends Mage_Adminhtml_Block_Template
19
+ {
20
+
21
+ public function __construct()
22
+ {
23
+ parent::__construct();
24
+
25
+ $this->setTitle('Welcome');
26
+ }
27
+
28
+ }
app/code/community/Licentia/Fidelitas/Block/Adminhtml/Account/Sync/Edit.php ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Licentia Fidelitas - Advanced Email and SMS Marketing Automation for E-Goi
5
+ *
6
+ * NOTICE OF LICENSE
7
+ * This source file is subject to the Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International
8
+ * It is available through the world-wide-web at this URL:
9
+ * http://creativecommons.org/licenses/by-nc-nd/4.0/
10
+ *
11
+ * @title Advanced Email and SMS Marketing Automation
12
+ * @category Marketing
13
+ * @package Licentia
14
+ * @author Bento Vilas Boas <bento@licentia.pt>
15
+ * @copyright Copyright (c) 2016 E-Goi - http://e-goi.com
16
+ * @license Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International
17
+ */
18
+ class Licentia_Fidelitas_Block_Adminhtml_Account_Sync_Edit extends Mage_Adminhtml_Block_Widget_Form_Container
19
+ {
20
+
21
+ public function __construct()
22
+ {
23
+ parent::__construct();
24
+ $this->_blockGroup = "fidelitas";
25
+ $this->_controller = "adminhtml_account_sync";
26
+ $this->_removeButton('back');
27
+ $this->_removeButton('reset');
28
+ }
29
+
30
+ public function getHeaderText()
31
+ {
32
+
33
+ return $this->__("Map Existing E-Goi Lists to your Magento Store Views");
34
+ }
35
+
36
+ }
app/code/community/Licentia/Fidelitas/Block/Adminhtml/Account/Sync/Edit/Form.php ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Licentia Fidelitas - Advanced Email and SMS Marketing Automation for E-Goi
5
+ *
6
+ * NOTICE OF LICENSE
7
+ * This source file is subject to the Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International
8
+ * It is available through the world-wide-web at this URL:
9
+ * http://creativecommons.org/licenses/by-nc-nd/4.0/
10
+ *
11
+ * @title Advanced Email and SMS Marketing Automation
12
+ * @category Marketing
13
+ * @package Licentia
14
+ * @author Bento Vilas Boas <bento@licentia.pt>
15
+ * @copyright Copyright (c) 2016 E-Goi - http://e-goi.com
16
+ * @license Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International
17
+ */
18
+ class Licentia_Fidelitas_Block_Adminhtml_Account_Sync_Edit_Form extends Mage_Adminhtml_Block_Widget_Form
19
+ {
20
+
21
+ protected function _prepareForm()
22
+ {
23
+ $form = new Varien_Data_Form(array(
24
+ "id" => "edit_form",
25
+ "action" => $this->getUrl("*/*/map"),
26
+ "method" => "post",
27
+ )
28
+ );
29
+ $form->setUseContainer(true);
30
+ $this->setForm($form);
31
+ return parent::_prepareForm();
32
+ }
33
+
34
+ }
app/code/community/Licentia/Fidelitas/Block/Adminhtml/Account/Sync/Edit/Tab/Form.php ADDED
@@ -0,0 +1,51 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Licentia Fidelitas - Advanced Email and SMS Marketing Automation for E-Goi
5
+ *
6
+ * NOTICE OF LICENSE
7
+ * This source file is subject to the Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International
8
+ * It is available through the world-wide-web at this URL:
9
+ * http://creativecommons.org/licenses/by-nc-nd/4.0/
10
+ *
11
+ * @title Advanced Email and SMS Marketing Automation
12
+ * @category Marketing
13
+ * @package Licentia
14
+ * @author Bento Vilas Boas <bento@licentia.pt>
15
+ * @copyright Copyright (c) 2016 E-Goi - http://e-goi.com
16
+ * @license Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International
17
+ */
18
+ class Licentia_Fidelitas_Block_Adminhtml_Account_Sync_Edit_Tab_Form extends Mage_Adminhtml_Block_Widget_Form
19
+ {
20
+
21
+ protected function _prepareForm()
22
+ {
23
+
24
+ $current = Mage::registry("egoi_lists");
25
+
26
+ $mls = array();
27
+ $mls[0] = $this->__('Create New List');
28
+ foreach ($current->getData() as $ml) {
29
+ $mls[$ml['listnum']] = $ml['title'];
30
+ }
31
+
32
+ $stores = Mage::getSingleton('adminhtml/system_store')->getStoreCollection();
33
+
34
+ $form = new Varien_Data_Form();
35
+ $this->setForm($form);
36
+ $fieldset = $form->addFieldset("fidelitas_form", array("legend" => $this->__("Existing Stores")));
37
+
38
+ foreach ($stores as $store) {
39
+
40
+ $fieldset->addField($store->getId(), "select", array(
41
+ "name" => 'store[' . $store->getId() . ']',
42
+ "values" => $mls,
43
+ "label" => $this->__('Store View') . ' - ' . $store->getName(),
44
+ "note" => Mage::getModel('adminhtml/system_store')->getStoreNameWithWebsite($store->getId()),
45
+ ));
46
+ }
47
+
48
+ return parent::_prepareForm();
49
+ }
50
+
51
+ }
app/code/community/Licentia/Fidelitas/Block/Adminhtml/Account/Sync/Edit/Tabs.php ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Licentia Fidelitas - Advanced Email and SMS Marketing Automation for E-Goi
5
+ *
6
+ * NOTICE OF LICENSE
7
+ * This source file is subject to the Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International
8
+ * It is available through the world-wide-web at this URL:
9
+ * http://creativecommons.org/licenses/by-nc-nd/4.0/
10
+ *
11
+ * @title Advanced Email and SMS Marketing Automation
12
+ * @category Marketing
13
+ * @package Licentia
14
+ * @author Bento Vilas Boas <bento@licentia.pt>
15
+ * @copyright Copyright (c) 2016 E-Goi - http://e-goi.com
16
+ * @license Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International
17
+ */
18
+ class Licentia_Fidelitas_Block_Adminhtml_Account_Sync_Edit_Tabs extends Mage_Adminhtml_Block_Widget_Tabs
19
+ {
20
+
21
+ public function __construct()
22
+ {
23
+ parent::__construct();
24
+ $this->setId("fidelitas_tabs");
25
+ $this->setDestElementId("edit_form");
26
+ $this->setTitle($this->__("E-Goi Integration"));
27
+ }
28
+
29
+ protected function _beforeToHtml()
30
+ {
31
+
32
+ $this->addTab("form_section", array(
33
+ "label" => $this->__("Setup"),
34
+ "title" => $this->__("Setup"),
35
+ "content" => $this->getLayout()->createBlock("fidelitas/adminhtml_account_sync_edit_tab_form")->toHtml(),
36
+ ));
37
+ return parent::_beforeToHtml();
38
+ }
39
+
40
+ }
app/code/community/Licentia/Fidelitas/Block/Adminhtml/Autoresponders.php ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Licentia Fidelitas - SMS Notifications for E-Goi
5
+ *
6
+ * NOTICE OF LICENSE
7
+ * This source file is subject to the Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International
8
+ * It is available through the world-wide-web at this URL:
9
+ * http://creativecommons.org/licenses/by-nc-nd/4.0/
10
+ *
11
+ * @title SMS Notifications
12
+ * @category Marketing
13
+ * @package Licentia
14
+ * @author Bento Vilas Boas <bento@licentia.pt>
15
+ * @copyright Copyright (c) 2016 E-Goi - http://e-goi.com
16
+ * @license Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International
17
+ */
18
+ class Licentia_Fidelitas_Block_Adminhtml_Autoresponders extends Mage_Adminhtml_Block_Widget_Grid_Container {
19
+
20
+ public function __construct() {
21
+ $this->_controller = 'adminhtml_autoresponders';
22
+ $this->_blockGroup = 'fidelitas';
23
+ $this->_headerText = $this->__('SMS Notifications');
24
+ $this->_addButtonLabel = $this->__('New Notification');
25
+
26
+ parent::__construct();
27
+ }
28
+
29
+ }
app/code/community/Licentia/Fidelitas/Block/Adminhtml/Autoresponders/Edit.php ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Licentia Fidelitas - SMS Notifications for E-Goi
5
+ *
6
+ * NOTICE OF LICENSE
7
+ * This source file is subject to the Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International
8
+ * It is available through the world-wide-web at this URL:
9
+ * http://creativecommons.org/licenses/by-nc-nd/4.0/
10
+ *
11
+ * @title SMS Notifications
12
+ * @category Marketing
13
+ * @package Licentia
14
+ * @author Bento Vilas Boas <bento@licentia.pt>
15
+ * @copyright Copyright (c) 2016 E-Goi - http://e-goi.com
16
+ * @license Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International
17
+ */
18
+ class Licentia_Fidelitas_Block_Adminhtml_Autoresponders_Edit extends Mage_Adminhtml_Block_Widget_Form_Container {
19
+
20
+ public function __construct() {
21
+ parent::__construct();
22
+ $this->_objectId = "autoresponder_id";
23
+ $this->_blockGroup = "fidelitas";
24
+ $this->_controller = "adminhtml_autoresponders";
25
+
26
+ $this->_addButton("saveandcontinuebarcode", array(
27
+ "label" => $this->__("Save and Continue Edit"),
28
+ "onclick" => "saveAndContinueEdit()",
29
+ "class" => "save",
30
+ ), -100);
31
+
32
+ $this->_formScripts[] = " function saveAndContinueEdit(){
33
+ editForm.submit($('edit_form').action+'back/edit/');
34
+ }";
35
+ }
36
+
37
+ public function getHeaderText() {
38
+
39
+ if (Mage::registry("current_autoresponder") && Mage::registry("current_autoresponder")->getId()) {
40
+
41
+ return $this->__("Edit Notification");
42
+ } else {
43
+
44
+ return $this->__("Add Notification");
45
+ }
46
+ }
47
+
48
+ }
app/code/community/Licentia/Fidelitas/Block/Adminhtml/Autoresponders/Edit/Form.php ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Licentia Fidelitas - SMS Notifications for E-Goi
5
+ *
6
+ * NOTICE OF LICENSE
7
+ * This source file is subject to the Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International
8
+ * It is available through the world-wide-web at this URL:
9
+ * http://creativecommons.org/licenses/by-nc-nd/4.0/
10
+ *
11
+ * @title SMS Notifications
12
+ * @category Marketing
13
+ * @package Licentia
14
+ * @author Bento Vilas Boas <bento@licentia.pt>
15
+ * @copyright Copyright (c) 2016 E-Goi - http://e-goi.com
16
+ * @license Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International
17
+ */
18
+ class Licentia_Fidelitas_Block_Adminhtml_Autoresponders_Edit_Form extends Mage_Adminhtml_Block_Widget_Form {
19
+
20
+ protected function _prepareForm() {
21
+ $form = new Varien_Data_Form(array(
22
+ "id" => "edit_form",
23
+ "action" => $this->getUrl("*/*/save", array("id" => $this->getRequest()->getParam("id"))),
24
+ "method" => "post",
25
+ )
26
+ );
27
+ $form->setUseContainer(true);
28
+ $this->setForm($form);
29
+ return parent::_prepareForm();
30
+ }
31
+
32
+ }
app/code/community/Licentia/Fidelitas/Block/Adminhtml/Autoresponders/Edit/Tab/Data.php ADDED
@@ -0,0 +1,128 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Licentia Fidelitas - SMS Notifications for E-Goi
5
+ *
6
+ * NOTICE OF LICENSE
7
+ * This source file is subject to the Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International
8
+ * It is available through the world-wide-web at this URL:
9
+ * http://creativecommons.org/licenses/by-nc-nd/4.0/
10
+ *
11
+ * @title SMS Notifications
12
+ * @category Marketing
13
+ * @package Licentia
14
+ * @author Bento Vilas Boas <bento@licentia.pt>
15
+ * @copyright Copyright (c) 2016 E-Goi - http://e-goi.com
16
+ * @license Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International
17
+ */
18
+ class Licentia_Fidelitas_Block_Adminhtml_Autoresponders_Edit_Tab_Data extends Mage_Adminhtml_Block_Widget_Form
19
+ {
20
+
21
+ protected function _prepareForm()
22
+ {
23
+
24
+ $current = Mage::registry('current_autoresponder');
25
+
26
+ $form = new Varien_Data_Form();
27
+ $form->setHtmlIdPrefix('page_');
28
+
29
+ $event = $this->getRequest()->getParam('event');
30
+
31
+ if ($current->getId()) {
32
+ $event = $current->getEvent();
33
+ }
34
+
35
+
36
+ $fieldset2 = $form->addFieldset('content_fieldset', array('legend' => $this->__('Content')));
37
+
38
+ $fieldset2->addField('name', 'text', array(
39
+ 'name' => 'name',
40
+ 'label' => $this->__('Name'),
41
+ 'title' => $this->__('Name'),
42
+ "required" => true,
43
+ ));
44
+
45
+ $js = '
46
+ <style type="text/css">#togglepage_message, .add-image{ display:none !important;} #message{width:275px !important;height:125px !important; }</style>
47
+ <script type="text/javascript">
48
+ function checkChars(field,divHtml){
49
+ var size = 160 - $F(field).length
50
+ $(divHtml).update(size);
51
+ }
52
+ </script>';
53
+
54
+ $wysiwygConfig = Mage::getSingleton('cms/wysiwyg_config')->getConfig(
55
+ array('tab_id' => $this->getTabId())
56
+ );
57
+
58
+ $wysiwygConfig->setData('hidden', 1);
59
+ $wysiwygConfig->setData('add_images', false);
60
+
61
+ $extraMsg = '';
62
+ if ($event == 'new_shipment') {
63
+ $extraMsg = "Use {track_number} and {track_title} to be replaced by carrier name and tracking number.";
64
+ }
65
+
66
+
67
+ $fieldset2->addField('message', 'editor', array(
68
+ "label" => $this->__("Message"),
69
+ "class" => "required-entry",
70
+ "required" => true,
71
+ "onkeyup" => "checkChars(this,'charsLeft')",
72
+ "name" => "message",
73
+ 'config' => $wysiwygConfig,
74
+ 'wysiwyg' => true,
75
+ 'required' => true,
76
+ "note" => $this->__($extraMsg . ' 160 characters limit. [<span id="charsLeft">160</span> left]'),
77
+ ))->setAfterElementHtml($js);
78
+
79
+
80
+ if (!Mage::app()->isSingleStoreMode()) {
81
+ $field = $fieldset2->addField('store_ids', 'multiselect', array(
82
+ 'name' => 'store_ids[]',
83
+ 'label' => Mage::helper('cms')->__('Store View'),
84
+ 'title' => Mage::helper('cms')->__('Store View'),
85
+ 'required' => true,
86
+ 'values' => Mage::getSingleton('adminhtml/system_store')->getStoreValuesForForm(false, true),
87
+ ));
88
+ $renderer = $this->getLayout()->createBlock('adminhtml/store_switcher_form_renderer_fieldset_element');
89
+ $field->setRenderer($renderer);
90
+ } else {
91
+ $fieldset2->addField('store_ids', 'hidden', array(
92
+ 'name' => 'store_ids[]',
93
+ 'value' => Mage::app()->getStore(true)->getId(),
94
+ ));
95
+ $current->setStoreIds(Mage::app()->getStore(true)->getId());
96
+ }
97
+
98
+ $outputFormatDate = Mage::app()->getLocale()->getDateFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT);
99
+ $fieldset2->addField('from_date', 'date', array(
100
+ 'name' => 'from_date',
101
+ 'format' => $outputFormatDate,
102
+ 'label' => $this->__('Active From Date'),
103
+ 'image' => $this->getSkinUrl('images/grid-cal.gif'),
104
+ ));
105
+ $fieldset2->addField('to_date', 'date', array(
106
+ 'name' => 'to_date',
107
+ 'format' => $outputFormatDate,
108
+ 'label' => $this->__('Active To Date'),
109
+ 'image' => $this->getSkinUrl('images/grid-cal.gif'),
110
+ ));
111
+
112
+
113
+ $fieldset2->addField('active', "select", array(
114
+ "label" => $this->__('Status'),
115
+ "options" => array('1' => $this->__('Active'), '0' => $this->__('Inactive')),
116
+ "name" => 'active',
117
+ ));
118
+
119
+ $this->setForm($form);
120
+
121
+ if ($current) {
122
+ $form->addValues($current->getData());
123
+ }
124
+
125
+ return parent::_prepareForm();
126
+ }
127
+
128
+ }
app/code/community/Licentia/Fidelitas/Block/Adminhtml/Autoresponders/Edit/Tab/Main.php ADDED
@@ -0,0 +1,141 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Licentia Fidelitas - SMS Notifications for E-Goi
5
+ *
6
+ * NOTICE OF LICENSE
7
+ * This source file is subject to the Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International
8
+ * It is available through the world-wide-web at this URL:
9
+ * http://creativecommons.org/licenses/by-nc-nd/4.0/
10
+ *
11
+ * @title SMS Notifications
12
+ * @category Marketing
13
+ * @package Licentia
14
+ * @author Bento Vilas Boas <bento@licentia.pt>
15
+ * @copyright Copyright (c) 2016 E-Goi - http://e-goi.com
16
+ * @license Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International
17
+ */
18
+ class Licentia_Fidelitas_Block_Adminhtml_Autoresponders_Edit_Tab_Main extends Mage_Adminhtml_Block_Widget_Form
19
+ {
20
+
21
+ protected function _prepareForm()
22
+ {
23
+
24
+ $current = Mage::registry('current_autoresponder');
25
+
26
+ $form = new Varien_Data_Form();
27
+ $form->setHtmlIdPrefix('page_');
28
+
29
+ $event = $this->getRequest()->getparam('event');
30
+ $campaignId = $this->getRequest()->getparam('campaign_id');
31
+ $sendMoment = $this->getRequest()->getparam('send_moment');
32
+ $type = $this->getRequest()->getParam('type');
33
+
34
+ $productName = '';
35
+ if ($current->getId()) {
36
+ $event = $current->getEvent();
37
+ $type = $current->getChannel();
38
+
39
+ if ($sendMoment) {
40
+ $current->setData('send_moment', $sendMoment);
41
+ }
42
+
43
+ $sendMoment = $current->getSendMoment();
44
+
45
+ if ($current->getProduct()) {
46
+ $productName = Mage::getModel('catalog/product')->load($current->getProduct())->getName();
47
+ }
48
+ } else {
49
+ $current->setData('event', $event);
50
+ $current->setData('send_moment', $sendMoment);
51
+ }
52
+
53
+ $fieldset = $form->addFieldset('params_fieldset', array('legend' => $this->__('Settings')));
54
+
55
+ $location = $this->getUrl('*/*/*', array('_current' => true)) . 'event/';
56
+
57
+ $options = Mage::getModel('fidelitas/autoresponders')->toOptionArray();
58
+
59
+ if (!$event) {
60
+ array_unshift($options, $this->__('Please Select'));
61
+ }
62
+
63
+ $fieldset->addField('event', 'select', array(
64
+ 'name' => 'event',
65
+ 'label' => $this->__('Event Trigger'),
66
+ 'title' => $this->__('Event Trigger'),
67
+ 'options' => $options,
68
+ 'disabled' => $current->getId() ? true : false,
69
+ "required" => true,
70
+ "onchange" => "window.location='$location'+this.value",
71
+ ));
72
+
73
+
74
+ if ($event == 'order_product') {
75
+
76
+ $fieldset->addField('product', 'text', array(
77
+ 'name' => 'product',
78
+ 'label' => $this->__('Product ID'),
79
+ 'title' => $this->__('Product ID'),
80
+ "note" => $productName . ' <a target="_blank" href="' . $this->getUrl('*/catalog_product') . '">' . $this->__('Go to Product Listing') . '</a>',
81
+ "required" => true,
82
+ ));
83
+
84
+ }
85
+
86
+ if ($event) {
87
+ $location = $this->getUrl('*/*/*', array('_current' => true, 'send_moment' => false)) . 'send_moment/';
88
+ $location = "window.location='$location'+this.value";
89
+
90
+ $options = array();
91
+
92
+ if (!$current->getId() && !$sendMoment) {
93
+ $options[''] = $this->__('Please Select');
94
+ }
95
+ $options['occurs'] = $this->__('When triggered');
96
+ $options['after'] = $this->__('After...');
97
+
98
+ $fieldset->addField('send_moment', "select", array(
99
+ "label" => $this->__('Send Moment'),
100
+ "options" => $options,
101
+ "name" => 'send_moment',
102
+ "required" => true,
103
+ "onchange" => "$location",
104
+ ));
105
+ }
106
+
107
+ if ($sendMoment == 'after') {
108
+ $fieldset->addField('after_hours', "select", array(
109
+ "label" => $this->__('After Hours'),
110
+ "options" => array_combine(range(0, 23), range(0, 23)),
111
+ "name" => 'after_hours',
112
+ ));
113
+
114
+
115
+ $fieldset->addField('after_days', "select", array(
116
+ "label" => $this->__('After Days...'),
117
+ "options" => array_combine(range(0, 30), range(0, 30)),
118
+ "name" => 'after_days',
119
+ ));
120
+ }
121
+
122
+
123
+ if ($event == 'order_status' && $sendMoment) {
124
+ $fieldset->addField('order_status', "select", array(
125
+ "label" => $this->__('New Status'),
126
+ "options" => Mage::getSingleton('sales/order_config')->getStatuses(),
127
+ "name" => 'order_status',
128
+ ));
129
+ }
130
+
131
+
132
+ $this->setForm($form);
133
+
134
+ if ($current) {
135
+ $form->addValues($current->getData());
136
+ }
137
+
138
+ return parent::_prepareForm();
139
+ }
140
+
141
+ }
app/code/community/Licentia/Fidelitas/Block/Adminhtml/Autoresponders/Edit/Tabs.php ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Licentia Fidelitas - SMS Notifications for E-Goi
5
+ *
6
+ * NOTICE OF LICENSE
7
+ * This source file is subject to the Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International
8
+ * It is available through the world-wide-web at this URL:
9
+ * http://creativecommons.org/licenses/by-nc-nd/4.0/
10
+ *
11
+ * @title SMS Notifications
12
+ * @category Marketing
13
+ * @package Licentia
14
+ * @author Bento Vilas Boas <bento@licentia.pt>
15
+ * @copyright Copyright (c) 2016 E-Goi - http://e-goi.com
16
+ * @license Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International
17
+ */
18
+ class Licentia_Fidelitas_Block_Adminhtml_Autoresponders_Edit_Tabs extends Mage_Adminhtml_Block_Widget_Tabs {
19
+
20
+ public function __construct() {
21
+ parent::__construct();
22
+ $this->setId("fidelitas_tabs");
23
+ $this->setDestElementId("edit_form");
24
+ $this->setTitle($this->__("SMS Notifications Information"));
25
+ }
26
+
27
+ protected function _beforeToHtml() {
28
+
29
+ $current = Mage::registry('current_autoresponder');
30
+
31
+
32
+ $this->addTab("main_section", array(
33
+ "label" => $this->__("Settings"),
34
+ "title" => $this->__("Settings"),
35
+ "content" => $this->getLayout()->createBlock("fidelitas/adminhtml_autoresponders_edit_tab_main")->toHtml(),
36
+ ));
37
+
38
+ if (($this->getRequest()->getparam('send_moment') || $current->getId())) {
39
+ $this->addTab("data_section", array(
40
+ "label" => $this->__("Information"),
41
+ "title" => $this->__("Information"),
42
+ "content" => $this->getLayout()->createBlock("fidelitas/adminhtml_autoresponders_edit_tab_data")->toHtml(),
43
+ ));
44
+
45
+ }
46
+
47
+ return parent::_beforeToHtml();
48
+ }
49
+
50
+ }
app/code/community/Licentia/Fidelitas/Block/Adminhtml/Autoresponders/Grid.php ADDED
@@ -0,0 +1,100 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Licentia Fidelitas - SMS Notifications for E-Goi
5
+ *
6
+ * NOTICE OF LICENSE
7
+ * This source file is subject to the Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International
8
+ * It is available through the world-wide-web at this URL:
9
+ * http://creativecommons.org/licenses/by-nc-nd/4.0/
10
+ *
11
+ * @title SMS Notifications
12
+ * @category Marketing
13
+ * @package Licentia
14
+ * @author Bento Vilas Boas <bento@licentia.pt>
15
+ * @copyright Copyright (c) 2016 E-Goi - http://e-goi.com
16
+ * @license Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International
17
+ */
18
+ class Licentia_Fidelitas_Block_Adminhtml_Autoresponders_Grid extends Mage_Adminhtml_Block_Widget_Grid {
19
+
20
+ public function __construct() {
21
+ parent::__construct();
22
+ $this->setId('campaign_grid');
23
+ $this->setDefaultSort('autoresponder_id');
24
+ $this->setDefaultDir('DESC');
25
+ $this->setSaveParametersInSession(true);
26
+ }
27
+
28
+ protected function _prepareCollection() {
29
+ $collection = Mage::getModel('fidelitas/autoresponders')
30
+ ->getResourceCollection();
31
+
32
+ $this->setCollection($collection);
33
+ return parent::_prepareCollection();
34
+ }
35
+
36
+ protected function _prepareColumns() {
37
+ $this->addColumn('autoresponder_id', array(
38
+ 'header' => $this->__('ID'),
39
+ 'align' => 'right',
40
+ 'width' => '50px',
41
+ 'index' => 'autoresponder_id',
42
+ ));
43
+
44
+
45
+ $this->addColumn('event', array(
46
+ 'header' => $this->__('Event'),
47
+ 'align' => 'left',
48
+ 'index' => 'event',
49
+ 'type' => 'options',
50
+ 'options' => Mage::getModel('fidelitas/autoresponders')->toOptionArray(),
51
+ ));
52
+
53
+
54
+ $this->addColumn('name', array(
55
+ 'header' => $this->__('Name'),
56
+ 'align' => 'left',
57
+ 'index' => 'name',
58
+ ));
59
+
60
+ $this->addColumn('number_subscribers', array(
61
+ 'header' => $this->__('N. Subscribers'),
62
+ 'align' => 'right',
63
+ 'type' => 'number',
64
+ 'index' => 'number_subscribers',
65
+ ));
66
+
67
+ $this->addColumn('active', array(
68
+ 'header' => $this->__('Is Active?'),
69
+ 'align' => 'left',
70
+ 'width' => '80px',
71
+ 'index' => 'active',
72
+ 'type' => 'options',
73
+ 'options' => array('0' => $this->__('No'), '1' => $this->__('Yes')),
74
+ ));
75
+
76
+ $this->addColumn('from_date', array(
77
+ 'header' => $this->__('From Date'),
78
+ 'align' => 'left',
79
+ 'width' => '120px',
80
+ 'type' => 'date',
81
+ 'default' => '-NA-',
82
+ 'index' => 'from_date',
83
+ ));
84
+
85
+ $this->addColumn('to_date', array(
86
+ 'header' => $this->__('To Date'),
87
+ 'align' => 'left',
88
+ 'width' => '120px',
89
+ 'type' => 'date',
90
+ 'default' => '-NA-',
91
+ 'index' => 'to_date',
92
+ ));
93
+ return parent::_prepareColumns();
94
+ }
95
+
96
+ public function getRowUrl($row) {
97
+ return $this->getUrl('*/*/edit', array('id' => $row->getId()));
98
+ }
99
+
100
+ }
app/code/community/Licentia/Fidelitas/Block/Adminhtml/Events.php ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Licentia Fidelitas - SMS Notifications for E-Goi
5
+ *
6
+ * NOTICE OF LICENSE
7
+ * This source file is subject to the Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International
8
+ * It is available through the world-wide-web at this URL:
9
+ * http://creativecommons.org/licenses/by-nc-nd/4.0/
10
+ *
11
+ * @title SMS Notifications
12
+ * @category Marketing
13
+ * @package Licentia
14
+ * @author Bento Vilas Boas <bento@licentia.pt>
15
+ * @copyright Copyright (c) 2016 E-Goi - http://e-goi.com
16
+ * @license Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International
17
+ */
18
+ class Licentia_Fidelitas_Block_Adminhtml_Events extends Mage_Adminhtml_Block_Widget_Grid_Container {
19
+
20
+ public function __construct() {
21
+ $this->_controller = 'adminhtml_events';
22
+ $this->_blockGroup = 'fidelitas';
23
+ $this->_headerText = $this->__('Notifications Logs');
24
+
25
+ parent::__construct();
26
+
27
+ $this->_removeButton('add');
28
+ }
29
+
30
+ }
app/code/community/Licentia/Fidelitas/Block/Adminhtml/Events/Grid.php ADDED
@@ -0,0 +1,137 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Licentia Fidelitas - SMS Notifications for E-Goi
5
+ *
6
+ * NOTICE OF LICENSE
7
+ * This source file is subject to the Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International
8
+ * It is available through the world-wide-web at this URL:
9
+ * http://creativecommons.org/licenses/by-nc-nd/4.0/
10
+ *
11
+ * @title SMS Notifications
12
+ * @category Marketing
13
+ * @package Licentia
14
+ * @author Bento Vilas Boas <bento@licentia.pt>
15
+ * @copyright Copyright (c) 2016 E-Goi - http://e-goi.com
16
+ * @license Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International
17
+ */
18
+ class Licentia_Fidelitas_Block_Adminhtml_Events_Grid extends Mage_Adminhtml_Block_Widget_Grid
19
+ {
20
+
21
+ public function __construct()
22
+ {
23
+ parent::__construct();
24
+ $this->setId('events_grid');
25
+ $this->setDefaultSort('event_id');
26
+ $this->setDefaultDir('DESC');
27
+ $this->setSaveParametersInSession(true);
28
+ }
29
+
30
+ protected function _prepareCollection()
31
+ {
32
+ $collection = Mage::getModel('fidelitas/events')
33
+ ->getResourceCollection();
34
+
35
+ $this->setCollection($collection);
36
+ return parent::_prepareCollection();
37
+ }
38
+
39
+ protected function _prepareColumns()
40
+ {
41
+
42
+ $this->addColumn('event_id', array(
43
+ 'header' => $this->__('ID'),
44
+ 'align' => 'right',
45
+ 'width' => '50px',
46
+ 'index' => 'event_id',
47
+ ));
48
+ $this->addColumn('event', array(
49
+ 'header' => $this->__('Event'),
50
+ 'index' => 'event',
51
+ 'type' => 'options',
52
+ 'options' => Mage::getModel('fidelitas/autoresponders')->toOptionArray(),
53
+ ));
54
+
55
+ $this->addColumn('autoresponder_id', array(
56
+ 'header' => $this->__('Notification'),
57
+ 'index' => 'autoresponder_id',
58
+ 'type' => 'options',
59
+ 'options' => Mage::getModel('fidelitas/autoresponders')->toFormValues(),
60
+ ));
61
+
62
+ $this->addColumn('customer_id', array(
63
+ 'header' => $this->__('Customer ID'),
64
+ 'index' => 'customer_id',
65
+ 'frame_callback' => array($this, 'customerResult'),
66
+ ));
67
+
68
+ $this->addColumn('customer_name', array(
69
+ 'header' => $this->__('Customer Name'),
70
+ 'index' => 'customer_name',
71
+ ));
72
+ /*
73
+ $this->addColumn('customer_email', array(
74
+ 'header' => $this->__('Customer Email'),
75
+ 'index' => 'customer_email',
76
+ ));
77
+ */
78
+
79
+ $this->addColumn('cellphone', array(
80
+ 'header' => $this->__('Cellphone'),
81
+ 'index' => 'cellphone',
82
+ ));
83
+
84
+ $this->addColumn('message', array(
85
+ 'header' => $this->__('Message'),
86
+ 'index' => 'message',
87
+ ));
88
+
89
+ $this->addColumn('sent_at', array(
90
+ 'header' => $this->__('Sent at'),
91
+ 'align' => 'left',
92
+ 'width' => '170px',
93
+ 'type' => 'datetime',
94
+ 'index' => 'sent_at',
95
+ ));
96
+
97
+ $this->addColumn('sent', array(
98
+ 'header' => $this->__('Sent?'),
99
+ 'align' => 'left',
100
+ 'width' => '80px',
101
+ 'index' => 'sent',
102
+ 'type' => 'options',
103
+ 'options' => array('0' => $this->__('No'), '1' => $this->__('Yes')),
104
+ ));
105
+
106
+ $this->addExportType('*/*/exportCsv', $this->__('CSV'));
107
+ $this->addExportType('*/*/exportXml', $this->__('Excel XML'));
108
+
109
+ return parent::_prepareColumns();
110
+ }
111
+
112
+ protected function _prepareMassaction()
113
+ {
114
+ $this->setMassactionIdField('event_id');
115
+ $this->getMassactionBlock()->setFormFieldName('events');
116
+
117
+ $this->getMassactionBlock()->addItem('delete', array(
118
+ 'label' => $this->__('Delete'),
119
+ 'url' => $this->getUrl('*/fidelitas_events/massDelete'),
120
+ 'confirm' => Mage::helper('customer')->__('Are you sure?'),
121
+ ));
122
+
123
+ return $this;
124
+ }
125
+
126
+ public function customerResult($value)
127
+ {
128
+
129
+ if ((int)$value > 0) {
130
+ $url = $this->getUrl('/customer/edit', array('id' => $value));
131
+ return '<a href="' . $url . '">' . $this->__('Yes') . '</a>';
132
+ }
133
+
134
+ return $this->__('No');
135
+ }
136
+
137
+ }
app/code/community/Licentia/Fidelitas/Block/Adminhtml/Lists.php ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Licentia Fidelitas - Advanced Email and SMS Marketing Automation for E-Goi
5
+ *
6
+ * NOTICE OF LICENSE
7
+ * This source file is subject to the Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International
8
+ * It is available through the world-wide-web at this URL:
9
+ * http://creativecommons.org/licenses/by-nc-nd/4.0/
10
+ *
11
+ * @title Advanced Email and SMS Marketing Automation
12
+ * @category Marketing
13
+ * @package Licentia
14
+ * @author Bento Vilas Boas <bento@licentia.pt>
15
+ * @copyright Copyright (c) 2016 E-Goi - http://e-goi.com
16
+ * @license Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International
17
+ */
18
+ class Licentia_Fidelitas_Block_Adminhtml_Lists extends Mage_Adminhtml_Block_Widget_Grid_Container
19
+ {
20
+
21
+ public function __construct()
22
+ {
23
+ $this->_controller = 'adminhtml_lists';
24
+ $this->_blockGroup = 'fidelitas';
25
+ $this->_headerText = $this->__('Lists');
26
+ $this->_addButtonLabel = $this->__('Add List');
27
+ parent::__construct();
28
+
29
+ $this->_removeButton('add');
30
+ }
31
+
32
+ }
app/code/community/Licentia/Fidelitas/Block/Adminhtml/Lists/Edit.php ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Licentia Fidelitas - Advanced Email and SMS Marketing Automation for E-Goi
5
+ *
6
+ * NOTICE OF LICENSE
7
+ * This source file is subject to the Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International
8
+ * It is available through the world-wide-web at this URL:
9
+ * http://creativecommons.org/licenses/by-nc-nd/4.0/
10
+ *
11
+ * @title Advanced Email and SMS Marketing Automation
12
+ * @category Marketing
13
+ * @package Licentia
14
+ * @author Bento Vilas Boas <bento@licentia.pt>
15
+ * @copyright Copyright (c) 2016 E-Goi - http://e-goi.com
16
+ * @license Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International
17
+ */
18
+ class Licentia_Fidelitas_Block_Adminhtml_Lists_Edit extends Mage_Adminhtml_Block_Widget_Form_Container
19
+ {
20
+
21
+ public function __construct()
22
+ {
23
+ parent::__construct();
24
+ $this->_objectId = "list_id";
25
+ $this->_blockGroup = "fidelitas";
26
+ $this->_controller = "adminhtml_lists";
27
+
28
+ $this->_removeButton('delete');
29
+
30
+ $this->_addButton("saveandcontinuebarcode", array(
31
+ "label" => $this->__("Save and Continue Edit"),
32
+ "onclick" => "saveAndContinueEdit()",
33
+ "class" => "save",
34
+ ), -100);
35
+
36
+ $this->_formScripts[] = " function saveAndContinueEdit(){
37
+ editForm.submit($('edit_form').action+'back/edit/');
38
+ }";
39
+ }
40
+
41
+ public function getHeaderText()
42
+ {
43
+ if (Mage::registry("current_list")->getId()) {
44
+ return $this->__("Edit List '%s'", $this->htmlEscape(Mage::registry("current_list")->getTitle()));
45
+ } else {
46
+ return $this->__("Add List");
47
+ }
48
+ }
49
+
50
+ }
app/code/community/Licentia/Fidelitas/Block/Adminhtml/Lists/Edit/Form.php ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Licentia Fidelitas - Advanced Email and SMS Marketing Automation for E-Goi
5
+ *
6
+ * NOTICE OF LICENSE
7
+ * This source file is subject to the Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International
8
+ * It is available through the world-wide-web at this URL:
9
+ * http://creativecommons.org/licenses/by-nc-nd/4.0/
10
+ *
11
+ * @title Advanced Email and SMS Marketing Automation
12
+ * @category Marketing
13
+ * @package Licentia
14
+ * @author Bento Vilas Boas <bento@licentia.pt>
15
+ * @copyright Copyright (c) 2016 E-Goi - http://e-goi.com
16
+ * @license Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International
17
+ */
18
+ class Licentia_Fidelitas_Block_Adminhtml_Lists_Edit_Form extends Mage_Adminhtml_Block_Widget_Form
19
+ {
20
+
21
+ protected function _prepareForm()
22
+ {
23
+ $form = new Varien_Data_Form(array(
24
+ "id" => "edit_form",
25
+ "action" => $this->getUrl("*/*/save", array("id" => $this->getRequest()->getParam("id"))),
26
+ "method" => "post",
27
+ )
28
+ );
29
+ $form->setUseContainer(true);
30
+ $this->setForm($form);
31
+ return parent::_prepareForm();
32
+ }
33
+
34
+ }
app/code/community/Licentia/Fidelitas/Block/Adminhtml/Lists/Edit/Tab/Main.php ADDED
@@ -0,0 +1,105 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Licentia_Fidelitas_Block_Adminhtml_Lists_Edit_Tab_Main extends Mage_Adminhtml_Block_Widget_Form
4
+ {
5
+
6
+ protected function _prepareForm()
7
+ {
8
+
9
+ $current = Mage::registry("current_list");
10
+
11
+ $form = new Varien_Data_Form();
12
+ $this->setForm($form);
13
+ $fieldset = $form->addFieldset("fidelitas_form", array("legend" => $this->__("List Information")));
14
+
15
+
16
+ $fieldset->addField("nome", "text", array(
17
+ "label" => $this->__("List Name"),
18
+ "class" => "required-entry",
19
+ "required" => true,
20
+ "name" => "nome",
21
+ ));
22
+
23
+ $fieldset->addField("internal_name", "text", array(
24
+ "label" => $this->__("Internal Name"),
25
+ "class" => "required-entry",
26
+ "required" => true,
27
+ "name" => "internal_name",
28
+ ));
29
+
30
+ if ($current->getId()) {
31
+
32
+ $remoteList = Mage::getModel('fidelitas/egoi')->getLists($current->getListnum())->getData('0');
33
+
34
+
35
+ $productAttributes = Mage::getResourceSingleton('customer/customer')
36
+ ->loadAllAttributes()
37
+ ->getAttributesByCode();
38
+
39
+ $attrToRemove = array('increment_id', 'updated_at', 'attribute_set_id', 'entity_type_id', 'confirmation', 'default_billing', 'default_shipping', 'password_hash');
40
+
41
+ $attributes = array('0' => $this->__('--Ignore--'));
42
+ foreach ($productAttributes as $attribute) {
43
+ if (in_array($attribute->getAttributeCode(), $attrToRemove)) {
44
+ continue;
45
+ }
46
+
47
+ if (strlen($attribute->getFrontendLabel()) == 0) {
48
+ continue;
49
+ }
50
+
51
+ $attributes[$attribute->getAttributeCode()] = $attribute->getFrontendLabel() . ' - (Account)';
52
+ }
53
+
54
+ asort($attributes);
55
+
56
+ $address = Mage::getModel('fidelitas/source_addressattributes')->toOptionArray();
57
+ foreach ($address as $field) {
58
+ $attributes['addr_' . $field['value']] = $field['label'] . ' - (Addresss)';
59
+ }
60
+
61
+ $attributes['static_store_id'] = $this->__("Store ID - (Global)");
62
+
63
+ if (isset($remoteList['extra_fields']) && count($remoteList['extra_fields'])>2) {
64
+
65
+ $fieldset2 = $form->addFieldset("map_form", array("legend" => $this->__("Map List Attributes")));
66
+
67
+ foreach ($remoteList['extra_fields'] as $field) {
68
+
69
+ if ($field['ref'] == 'magento_store' || $field['ref'] == 'magento_store_id' || $field['ref'] == 'magento_locale') {
70
+ continue;
71
+ }
72
+
73
+ $fieldset2->addField("extra_" . $field['id'], "select", array(
74
+ "label" => $this->__($field['ref']),
75
+ "options" => $attributes,
76
+ "required" => true,
77
+ "name" => "extra_" . $field['id'],
78
+ ));
79
+ }
80
+ }
81
+ }
82
+
83
+ if ($current) {
84
+
85
+ $currentValues = $current->getData();
86
+
87
+ if (count($currentValues) > 0) {
88
+ $currentValues['nome'] = $currentValues['title'];
89
+ }
90
+
91
+ $form->setValues($currentValues);
92
+
93
+ if (count($currentValues) > 0) {
94
+
95
+ $fieldset->addField("listID", "hidden", array(
96
+ "value" => $currentValues['listnum'],
97
+ "no_span" => true,
98
+ "name" => "listID",
99
+ ));
100
+ }
101
+ }
102
+ return parent::_prepareForm();
103
+ }
104
+
105
+ }
app/code/community/Licentia/Fidelitas/Block/Adminhtml/Lists/Edit/Tabs.php ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+
4
+ class Licentia_Fidelitas_Block_Adminhtml_Lists_Edit_Tabs extends Mage_Adminhtml_Block_Widget_Tabs
5
+ {
6
+
7
+ public function __construct()
8
+ {
9
+ parent::__construct();
10
+ $this->setId("fidelitas_tabs");
11
+ $this->setDestElementId("edit_form");
12
+ $this->setTitle($this->__("List Information"));
13
+ }
14
+
15
+ protected function _beforeToHtml()
16
+ {
17
+ $this->addTab("form_section", array(
18
+ "label" => $this->__("General"),
19
+ "title" => $this->__("General"),
20
+ "content" => $this->getLayout()->createBlock("fidelitas/adminhtml_lists_edit_tab_main")->toHtml(),
21
+ ));
22
+ return parent::_beforeToHtml();
23
+ }
24
+
25
+ }
app/code/community/Licentia/Fidelitas/Block/Adminhtml/Lists/Grid.php ADDED
@@ -0,0 +1,80 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Licentia_Fidelitas_Block_Adminhtml_Lists_Grid extends Mage_Adminhtml_Block_Widget_Grid
4
+ {
5
+
6
+ public function __construct()
7
+ {
8
+ parent::__construct();
9
+ $this->setId('importerGrid');
10
+ $this->setDefaultSort('list_id');
11
+ $this->setDefaultDir('DESC');
12
+ $this->setSaveParametersInSession(true);
13
+ $this->setUseAjax(true);
14
+ }
15
+
16
+ protected function _prepareCollection()
17
+ {
18
+
19
+ $collection = Mage::getModel('fidelitas/lists')->getCollection();
20
+ $this->setCollection($collection);
21
+ return parent::_prepareCollection();
22
+ }
23
+
24
+ protected function _prepareColumns()
25
+ {
26
+ $this->addColumn('list_id', array(
27
+ 'header' => $this->__('ID'),
28
+ 'width' => '50px',
29
+ 'index' => 'list_id',
30
+ ));
31
+
32
+ $this->addColumn('title', array(
33
+ 'header' => $this->__('List Title'),
34
+ 'align' => 'left',
35
+ 'index' => 'title',
36
+ ));
37
+
38
+ $this->addColumn('internal_name', array(
39
+ 'header' => $this->__('Internal Name'),
40
+ 'align' => 'left',
41
+ 'index' => 'internal_name',
42
+ ));
43
+
44
+ /*
45
+ $this->addColumn('subs_total', array(
46
+ 'header' => $this->__('Total Subscribers'),
47
+ 'type' => 'number',
48
+ 'width' => '60px',
49
+ 'index' => 'subs_total',
50
+ ));
51
+
52
+
53
+ $this->addColumn('action', array(
54
+ 'header' => $this->__('Action'),
55
+ 'type' => 'action',
56
+ 'width' => '150px',
57
+ 'filter' => false,
58
+ 'sortable' => false,
59
+ 'actions' => array(array(
60
+ 'url' => $this->getUrl('adminhtml/fidelitas_subscribers/index', array('listnum' => '$listnum')),
61
+ 'caption' => $this->__('View Subscribers'),
62
+ )),
63
+ 'index' => 'type',
64
+ 'sortable' => false,
65
+ ));
66
+ */
67
+ return parent::_prepareColumns();
68
+ }
69
+
70
+ public function getGridUrl()
71
+ {
72
+ return $this->getUrl('*/*/grid', array('_current' => true));
73
+ }
74
+
75
+ public function getRowUrl($row)
76
+ {
77
+ return $this->getUrl('*/*/edit', array('id' => $row->getId()));
78
+ }
79
+
80
+ }
app/code/community/Licentia/Fidelitas/Block/Adminhtml/Subscribers.php ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Licentia Fidelitas - Advanced Email and SMS Marketing Automation for E-Goi
5
+ *
6
+ * NOTICE OF LICENSE
7
+ * This source file is subject to the Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International
8
+ * It is available through the world-wide-web at this URL:
9
+ * http://creativecommons.org/licenses/by-nc-nd/4.0/
10
+ *
11
+ * @title Advanced Email and SMS Marketing Automation
12
+ * @category Marketing
13
+ * @package Licentia
14
+ * @author Bento Vilas Boas <bento@licentia.pt>
15
+ * @copyright Copyright (c) 2016 E-Goi - http://e-goi.com
16
+ * @license Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International
17
+ */
18
+ class Licentia_Fidelitas_Block_Adminhtml_Subscribers extends Mage_Adminhtml_Block_Widget_Grid_Container
19
+ {
20
+
21
+ public function __construct()
22
+ {
23
+
24
+ parent::__construct();
25
+ $this->_controller = 'adminhtml_subscribers';
26
+ $this->_blockGroup = 'fidelitas';
27
+ $this->_headerText = $this->__('Subscribers');
28
+ $this->_addButtonLabel = $this->__('Add Subscriber');
29
+
30
+ }
31
+
32
+ }
app/code/community/Licentia/Fidelitas/Block/Adminhtml/Subscribers/Edit.php ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Licentia_Fidelitas_Block_Adminhtml_Subscribers_Edit extends Mage_Adminhtml_Block_Widget_Form_Container
4
+ {
5
+
6
+ public function __construct()
7
+ {
8
+ parent::__construct();
9
+ $this->_objectId = "source_id";
10
+ $this->_blockGroup = "fidelitas";
11
+ $this->_controller = "adminhtml_subscribers";
12
+
13
+ $this->_addButton("saveandcontinuebarcode", array(
14
+ "label" => $this->__("Save and Continue Edit"),
15
+ "onclick" => "saveAndContinueEdit()",
16
+ "class" => "save",
17
+ ), -100);
18
+
19
+ $this->_formScripts[] = " function saveAndContinueEdit(){
20
+ editForm.submit($('edit_form').action+'back/edit/');
21
+ }";
22
+
23
+ }
24
+
25
+ public function getHeaderText()
26
+ {
27
+
28
+ $current = Mage::registry("current_subscriber");
29
+
30
+ if ($current && $current->getData()) {
31
+
32
+ return $this->__("Edit Subscriber: " . $current->getData('last_name') . ', ' . $current->getData('first_name'));
33
+ } else {
34
+ return $this->__("Add Subscriber");
35
+ }
36
+ }
37
+
38
+ }
app/code/community/Licentia/Fidelitas/Block/Adminhtml/Subscribers/Edit/Form.php ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Licentia Fidelitas - Advanced Email and SMS Marketing Automation for E-Goi
5
+ *
6
+ * NOTICE OF LICENSE
7
+ * This source file is subject to the Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International
8
+ * It is available through the world-wide-web at this URL:
9
+ * http://creativecommons.org/licenses/by-nc-nd/4.0/
10
+ *
11
+ * @title Advanced Email and SMS Marketing Automation
12
+ * @category Marketing
13
+ * @package Licentia
14
+ * @author Bento Vilas Boas <bento@licentia.pt>
15
+ * @copyright Copyright (c) 2016 E-Goi - http://e-goi.com
16
+ * @license Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International
17
+ */
18
+ class Licentia_Fidelitas_Block_Adminhtml_Subscribers_Edit_Form extends Mage_Adminhtml_Block_Widget_Form
19
+ {
20
+
21
+ protected function _prepareForm()
22
+ {
23
+ $form = new Varien_Data_Form(array(
24
+ "id" => "edit_form",
25
+ "action" => $this->getUrl("*/*/save", array("id" => $this->getRequest()->getParam("id"))),
26
+ "method" => "post",
27
+ )
28
+ );
29
+ $form->setUseContainer(true);
30
+ $this->setForm($form);
31
+ return parent::_prepareForm();
32
+ }
33
+
34
+ }
app/code/community/Licentia/Fidelitas/Block/Adminhtml/Subscribers/Edit/Tab/Form.php ADDED
@@ -0,0 +1,58 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Licentia_Fidelitas_Block_Adminhtml_Subscribers_Edit_Tab_Form extends Mage_Adminhtml_Block_Widget_Form
4
+ {
5
+
6
+ protected function _prepareForm()
7
+ {
8
+
9
+ $current = Mage::registry('current_subscriber');
10
+
11
+ $form = new Varien_Data_Form();
12
+ $this->setForm($form);
13
+ $fieldset = $form->addFieldset("fidelitas_form", array("legend" => $this->__("Subscriber Information")));
14
+
15
+
16
+ $fieldset->addField('email', "text", array(
17
+ "label" => $this->__('Email'),
18
+ "class" => "required-entry validate-email",
19
+ "required" => true,
20
+ "name" => 'email',
21
+ ));
22
+
23
+ $fields = array('first_name', 'last_name',);
24
+
25
+ foreach ($fields as $element) {
26
+ $fieldset->addField($element, "text", array(
27
+ "label" => $this->__(ucwords(str_replace('_', ' ', $element))),
28
+ "name" => $element,
29
+ ));
30
+ }
31
+
32
+ $fieldset->addField('cellphone_prefix', "select", array(
33
+ "label" => $this->__('Cellphone Prefix'),
34
+ 'values' => Licentia_Fidelitas_Model_Subscribers::getPhonePrefixs(),
35
+ "name" => 'cellphone_prefix',
36
+ ));
37
+
38
+ $fieldset->addField('cellphone', "text", array(
39
+ "label" => $this->__('Cellphone Number'),
40
+ "name" => 'cellphone',
41
+ ));
42
+
43
+ $fieldset->addField('status', "select", array(
44
+ "label" => $this->__('Status'),
45
+ "name" => 'status',
46
+ 'options' => array(4 => 'inactive', 1 => 'subscribed'),
47
+ ));
48
+
49
+ if ($current->getId()) {
50
+ $form->addValues($current->getData());
51
+ } else {
52
+ $form->addValues(array('status' => 1));
53
+ }
54
+
55
+ return parent::_prepareForm();
56
+ }
57
+
58
+ }
app/code/community/Licentia/Fidelitas/Block/Adminhtml/Subscribers/Edit/Tabs.php ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Licentia Fidelitas - Advanced Email and SMS Marketing Automation for E-Goi
5
+ *
6
+ * NOTICE OF LICENSE
7
+ * This source file is subject to the Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International
8
+ * It is available through the world-wide-web at this URL:
9
+ * http://creativecommons.org/licenses/by-nc-nd/4.0/
10
+ *
11
+ * @title Advanced Email and SMS Marketing Automation
12
+ * @category Marketing
13
+ * @package Licentia
14
+ * @author Bento Vilas Boas <bento@licentia.pt>
15
+ * @copyright Copyright (c) 2016 E-Goi - http://e-goi.com
16
+ * @license Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International
17
+ */
18
+ class Licentia_Fidelitas_Block_Adminhtml_Subscribers_Edit_Tabs extends Mage_Adminhtml_Block_Widget_Tabs
19
+ {
20
+
21
+ public function __construct()
22
+ {
23
+ parent::__construct();
24
+ $this->setId("fidelitas_tabs");
25
+ $this->setDestElementId("edit_form");
26
+ $this->setTitle($this->__("Subscriber Information"));
27
+ }
28
+
29
+ protected function _beforeToHtml()
30
+ {
31
+ $this->addTab("form_section", array(
32
+ "label" => $this->__("General"),
33
+ "title" => $this->__("General"),
34
+ "content" => $this->getLayout()->createBlock("fidelitas/adminhtml_subscribers_edit_tab_form")->toHtml(),
35
+ ));
36
+ return parent::_beforeToHtml();
37
+ }
38
+
39
+ }
app/code/community/Licentia/Fidelitas/Block/Adminhtml/Subscribers/Grid.php ADDED
@@ -0,0 +1,139 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Licentia_Fidelitas_Block_Adminhtml_Subscribers_Grid extends Mage_Adminhtml_Block_Widget_Grid
4
+ {
5
+
6
+ public function __construct()
7
+ {
8
+ parent::__construct();
9
+ $this->setId('campaign_grid');
10
+ $this->setDefaultSort('subscriber_id');
11
+ $this->setDefaultDir('DESC');
12
+ $this->setSaveParametersInSession(true);
13
+ $this->setUseAjax(true);
14
+ }
15
+
16
+ protected function _prepareCollection()
17
+ {
18
+
19
+ $collection = Mage::getModel('fidelitas/subscribers')
20
+ ->getResourceCollection();
21
+
22
+ $this->setCollection($collection);
23
+ return parent::_prepareCollection();
24
+ }
25
+
26
+ protected function _prepareColumns()
27
+ {
28
+ $this->addColumn('uid', array(
29
+ 'header' => $this->__('ID'),
30
+ 'align' => 'right',
31
+ 'width' => '90px',
32
+ 'index' => 'uid',
33
+ ));
34
+ $this->addColumn('customer_id', array(
35
+ 'header' => $this->__('Customer'),
36
+ 'align' => 'center',
37
+ 'width' => '50px',
38
+ 'index' => 'customer_id',
39
+ 'frame_callback' => array($this, 'customerResult'),
40
+ ));
41
+
42
+ $this->addColumn('store_id', array(
43
+ 'header' => $this->__('List Store View'),
44
+ 'type' => 'store',
45
+ 'width' => '150px',
46
+ 'index' => 'store_id',
47
+ ));
48
+
49
+ $this->addColumn('first_name', array(
50
+ 'header' => $this->__('First Name'),
51
+ 'align' => 'left',
52
+ 'index' => 'first_name',
53
+ ));
54
+
55
+ $this->addColumn('last_name', array(
56
+ 'header' => $this->__('Last Name'),
57
+ 'align' => 'left',
58
+ 'index' => 'last_name',
59
+ ));
60
+
61
+ $this->addColumn('email', array(
62
+ 'header' => $this->__('Email'),
63
+ 'align' => 'left',
64
+ 'index' => 'email',
65
+ ));
66
+
67
+ $this->addColumn('cellphone', array(
68
+ 'header' => $this->__('Cellphone'),
69
+ 'align' => 'left',
70
+ 'index' => 'cellphone',
71
+ ));
72
+
73
+ $this->addColumn('status', array(
74
+ 'header' => $this->__('Status'),
75
+ 'align' => 'left',
76
+ 'index' => 'status',
77
+ 'type' => 'options',
78
+ 'options' => array(0 => 'unsubscribed', '1' => 'subscribed'),
79
+ ));
80
+
81
+ $this->addColumn('email_sent', array(
82
+ 'header' => $this->__('Emails Sent'),
83
+ 'align' => 'left',
84
+ 'index' => 'email_sent',
85
+ 'type' => 'number',
86
+ 'width' => '40px',
87
+ ));
88
+
89
+ $this->addColumn('email_views', array(
90
+ 'header' => $this->__('Email Views'),
91
+ 'align' => 'left',
92
+ 'index' => 'email_views',
93
+ 'type' => 'number',
94
+ 'width' => '50px',
95
+ ));
96
+
97
+ $this->addColumn('sms_delivered', array(
98
+ 'header' => $this->__('SMS Delivered'),
99
+ 'align' => 'left',
100
+ 'index' => 'sms_delivered',
101
+ 'type' => 'number',
102
+ 'width' => '50px',
103
+ ));
104
+
105
+ return parent::_prepareColumns();
106
+ }
107
+
108
+ protected function _filterStoreCondition($collection, $column)
109
+ {
110
+ if (!$value = $column->getFilter()->getValue()) {
111
+ return;
112
+ }
113
+
114
+ $this->getCollection()->addStoreFilter($value);
115
+ }
116
+
117
+ public function customerResult($value)
118
+ {
119
+
120
+ if ((int)$value > 0) {
121
+ $url = $this->getUrl('adminhtml/customer/edit', array('id' => $value));
122
+ return '<a href="' . $url . '">' . $this->__('Yes') . '</a>';
123
+ }
124
+
125
+ return $this->__('No');
126
+ }
127
+
128
+ public function getGridUrl()
129
+ {
130
+ $list = Mage::registry('current_list');
131
+ return $this->getUrl('*/*/grid', array('_current' => true, 'list' => $list->getId()));
132
+ }
133
+
134
+ public function getRowUrl($row)
135
+ {
136
+ return $this->getUrl('*/*/edit', array('id' => $row->getId()));
137
+ }
138
+
139
+ }
app/code/community/Licentia/Fidelitas/Block/Adminhtml/System/Config/Form/Field/Test.php ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+
4
+ class Licentia_Fidelitas_Block_Adminhtml_System_Config_Form_Field_Test extends Mage_Adminhtml_Block_System_Config_Form_Field {
5
+
6
+ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element) {
7
+
8
+ $url = $this->getUrl('*/fidelitas_autoresponders/validateEnvironment');
9
+
10
+ return '<button onclick="window.location=\'' . $url . 'number/\'+$F(\'fidelitas_test_number\')" class="scalable" type="button" ><span><span><span>' . Mage::helper('fidelitas')->__('Test Now') . '</span></span></span></button>';
11
+ }
12
+
13
+ }
app/code/community/Licentia/Fidelitas/Block/Egoimmerce.php ADDED
@@ -0,0 +1,133 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Licentia_Fidelitas_Block_Egoimmerce extends Mage_Core_Block_Template
4
+ {
5
+
6
+ public function getPageName()
7
+ {
8
+ return $this->_getData('page_name');
9
+ }
10
+
11
+ protected function _getOrdersTrackingCode()
12
+ {
13
+ $orderIds = $this->getOrderIds();
14
+ if (empty($orderIds) || !is_array($orderIds)) {
15
+ return;
16
+ }
17
+
18
+ $collection = Mage::getResourceModel('sales/order_collection')
19
+ ->addFieldToFilter('entity_id', array('in' => $orderIds));
20
+ $result = array();
21
+
22
+ foreach ($collection as $order) {
23
+ foreach ($order->getAllVisibleItems() as $item) {
24
+
25
+ //get category name
26
+ $product_id = $item->product_id;
27
+ $_product = Mage::getModel('catalog/product')->load($product_id);
28
+ $cats = $_product->getCategoryIds();
29
+ $category_id = $cats[0]; // just grab the first id
30
+ $category = Mage::getModel('catalog/category')->load($category_id);
31
+ $category_name = $category->getName();
32
+
33
+
34
+ if ($item->getQtyOrdered()) {
35
+ $qty = number_format($item->getQtyOrdered(), 0, '.', '');
36
+ } else {
37
+ $qty = '0';
38
+ }
39
+ $result[] = sprintf("_egoiaq.push(['addEcommerceItem', '%s', '%s', '%s', %s, %s]);", $this->jsQuoteEscape($item->getSku()), $this->jsQuoteEscape($item->getName()), $category_name, $item->getBasePrice(), $qty
40
+ );
41
+ }
42
+ foreach ($collection as $order) {
43
+ if ($order->getGrandTotal()) {
44
+ $subtotal = $order->getGrandTotal() - $order->getShippingAmount() - $order->getShippingTaxAmount();
45
+ } else {
46
+ $subtotal = '0.00';
47
+ }
48
+ $result[] = sprintf("_egoiaq.push(['trackEcommerceOrder', '%s', %s, %s, %s, %s]);", $order->getIncrementId(), $order->getBaseGrandTotal(), $subtotal, $order->getBaseTaxAmount(), $order->getBaseShippingAmount()
49
+ );
50
+ }
51
+ }
52
+ return implode("\n", $result);
53
+ }
54
+
55
+ protected function _getEcommerceCartUpdate()
56
+ {
57
+
58
+ $cart = Mage::getModel('checkout/cart')->getQuote()->getAllVisibleItems();
59
+
60
+ foreach ($cart as $cartitem) {
61
+
62
+ //get category name
63
+ $product_id = $cartitem->product_id;
64
+ $_product = Mage::getModel('catalog/product')->load($product_id);
65
+ $cats = $_product->getCategoryIds();
66
+ if (isset($cats)) {
67
+ $category_id = $cats[0];
68
+ } // just grab the first id
69
+ $category = Mage::getModel('catalog/category')->load($category_id);
70
+ $category_name = $category->getName();
71
+ $nameofproduct = str_replace('"', "", $cartitem->getName());
72
+
73
+ if ($cartitem->getPrice() == 0 || $cartitem->getPrice() < 0.00001) {
74
+ continue;
75
+ }
76
+
77
+ echo '_egoiaq.push(["addEcommerceItem", "' . $cartitem->getSku() . '","' . $nameofproduct . '","' . $category_name . '",' . $cartitem->getPrice() . ',' . $cartitem->getQty() . ']);';
78
+ echo "\n";
79
+ }
80
+
81
+ //total in cart
82
+ $grandTotal = Mage::getModel('checkout/cart')->getQuote()->getGrandTotal();
83
+ if ($grandTotal == 0) {
84
+ echo '';
85
+ } else {
86
+ echo '_egoiaq.push(["trackEcommerceCartUpdate", ' . $grandTotal . ']);';
87
+ }
88
+ echo "\n";
89
+ }
90
+
91
+ protected function _getProductPageview()
92
+ {
93
+
94
+ $currentproduct = Mage::registry('current_product');
95
+
96
+ if (!($currentproduct instanceof Mage_Catalog_Model_Product)) {
97
+ return;
98
+ }
99
+
100
+ $product_id = $currentproduct->getId();
101
+ $_product = Mage::getModel('catalog/product')->load($product_id);
102
+ $cats = $_product->getCategoryIds();
103
+ $category_id = $cats[0]; // just grab the first id
104
+ //$category_id = if (isset($cats[0]) {$category_id = $cats[0]} else $category_id = null; potential fix when no catgeories
105
+ $category = Mage::getModel('catalog/category')->load($category_id);
106
+ $category_name = $category->getName();
107
+ $product = str_replace('"', "", $currentproduct->getName());
108
+
109
+
110
+ echo '_egoiaq.push(["setEcommerceView", "' . $currentproduct->getSku() . '", "' . $product . '","' . $category_name . '",' . $currentproduct->getPrice() . ']);';
111
+ Mage::unregister('current_category');
112
+ }
113
+
114
+ protected function _getCategoryPageview()
115
+ {
116
+ $currentcategory = Mage::registry('current_category');
117
+
118
+ if (!($currentcategory instanceof Mage_Catalog_Model_Category)) {
119
+ return;
120
+ }
121
+ echo '_egoiaq.push(["setEcommerceView", false,false,"' . $currentcategory->getName() . '"]);';
122
+ Mage::unregister('current_product');
123
+ }
124
+
125
+ protected function _toHtml()
126
+ {
127
+ if (!Mage::helper('fidelitas')->isEgoimmerceAvailable()) {
128
+ return '';
129
+ }
130
+ return str_replace("\n\n", "\n", parent::_toHtml());
131
+ }
132
+
133
+ }
app/code/community/Licentia/Fidelitas/Helper/Data.php ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Licentia_Fidelitas_Helper_Data extends Mage_Core_Helper_Abstract
4
+ {
5
+
6
+ const XML_PATH_ACTIVE = 'fidelitas/config/analytics';
7
+
8
+
9
+ /**
10
+ *
11
+ * @param mixed $store
12
+ *
13
+ * @return bool
14
+ */
15
+ public function isEgoimmerceAvailable($store = null)
16
+ {
17
+ return Mage::getStoreConfigFlag(self::XML_PATH_ACTIVE, $store);
18
+ }
19
+
20
+
21
+ public function isCustomerSubscribed($customerId)
22
+ {
23
+ $col = Mage::getModel('fidelitas/subscribers')
24
+ ->getCollection()
25
+ ->addFieldToFilter('customer_id', $customerId);
26
+
27
+ return $col->getSize() > 0 ? $col->getFirstItem() : false;
28
+ }
29
+
30
+ }
app/code/community/Licentia/Fidelitas/Model/Account.php ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Licentia_Fidelitas_Model_Account extends Mage_Core_Model_Abstract
4
+ {
5
+
6
+ protected function _construct()
7
+ {
8
+
9
+ $this->_init('fidelitas/account');
10
+ }
11
+
12
+ public function getAccount()
13
+ {
14
+ $col = $this->getCollection()->getFirstItem();
15
+
16
+ if (!$col->getId()) {
17
+ $this->save(array('company_name' => ' '));
18
+ return $this;
19
+ }
20
+
21
+ return $col;
22
+
23
+ }
24
+
25
+ function cron()
26
+ {
27
+
28
+ $fid = Mage::getModel('fidelitas/egoi');
29
+ $result = $fid->getAccountDetails()->getData();
30
+ $result[0]['account_id'] = 1;
31
+ $account = Mage::getModel('fidelitas/account')->getAccount();
32
+
33
+ if ($account->getId()) {
34
+ $account->setData($result[0])->save();
35
+ } else {
36
+ Mage::getModel('fidelitas/account')->setData($result[0])->save();
37
+ }
38
+
39
+ }
40
+
41
+ }
app/code/community/Licentia/Fidelitas/Model/Autoresponders.php ADDED
@@ -0,0 +1,269 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Licentia Fidelitas - SMS Notifications for E-Goi
5
+ *
6
+ * NOTICE OF LICENSE
7
+ * This source file is subject to the Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International
8
+ * It is available through the world-wide-web at this URL:
9
+ * http://creativecommons.org/licenses/by-nc-nd/4.0/
10
+ *
11
+ * @title SMS Notifications
12
+ * @category Marketing
13
+ * @package Licentia
14
+ * @author Bento Vilas Boas <bento@licentia.pt>
15
+ * @copyright Copyright (c) 2016 E-Goi - http://e-goi.com
16
+ * @license Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International
17
+ */
18
+ class Licentia_Fidelitas_Model_Autoresponders extends Mage_Core_Model_Abstract
19
+ {
20
+
21
+ const MYSQL_DATE = 'yyyy-MM-dd';
22
+ const MYSQL_DATETIME = 'yyyy-MM-dd HH:mm:ss';
23
+
24
+ protected function _construct()
25
+ {
26
+
27
+ $this->_init('fidelitas/autoresponders');
28
+ }
29
+
30
+ public function toOptionArray()
31
+ {
32
+
33
+ $return = array(
34
+ 'order_new' => Mage::helper('fidelitas')->__('Order - New Order'),
35
+ #'order_product' => Mage::helper('fidelitas')->__('Order - Bought Specific Product'),
36
+ 'order_status' => Mage::helper('fidelitas')->__('Order - Order Status Changes'),
37
+ 'new_invoice' => Mage::helper('fidelitas')->__('New Invoice'),
38
+ 'new_shipment' => Mage::helper('fidelitas')->__('New Shipment'),
39
+ 'new_creditmemo' => Mage::helper('fidelitas')->__('New Creditmemo'),
40
+ );
41
+
42
+
43
+ return $return;
44
+ }
45
+
46
+ public function newOrderDocument($event)
47
+ {
48
+
49
+ $document = $event->getEvent()->getDataObject();
50
+
51
+ if ($document instanceof Mage_Sales_Model_Order_Invoice) {
52
+ $type = 'new_invoice';
53
+ } elseif ($document instanceof Mage_Sales_Model_Order_Shipment) {
54
+ $type = 'new_shipment';
55
+ } elseif ($document instanceof Mage_Sales_Model_Order_Creditmemo) {
56
+ $type = 'new_creditmemo';
57
+ } else {
58
+ return false;
59
+ }
60
+
61
+ $order = $document->getOrder();
62
+
63
+ $phone = Mage::getModel('fidelitas/egoi')->getPhone($order);
64
+
65
+ if (!$phone) {
66
+ return false;
67
+ }
68
+
69
+ $autoresponders = $this->_getCollection($order->getStoreId())
70
+ ->addFieldToFilter('event', $type);
71
+
72
+ $customer = new Varien_Object;
73
+ $customer->setName($order->getCustomerName())
74
+ ->setEmail($order->getCustomerEmail())
75
+ ->setId($order->getCustomerId());
76
+
77
+ foreach ($autoresponders as $autoresponder) {
78
+ $this->_insertData($autoresponder, $phone, $order->getStoreId(), $customer, $document->getId());
79
+ }
80
+ }
81
+
82
+ public function changeStatus($event)
83
+ {
84
+
85
+ $order = $event->getEvent()->getOrder();
86
+ $newStatus = $order->getData('status');
87
+ $olderStatus = $order->getOrigData('status');
88
+
89
+ if ($newStatus == $olderStatus) {
90
+ return;
91
+ }
92
+
93
+ $phone = Mage::getModel('fidelitas/egoi')->getPhone($order);
94
+
95
+ if (!$phone) {
96
+ return false;
97
+ }
98
+
99
+ $autoresponders = $this->_getCollection($order->getStoreId())
100
+ ->addFieldToFilter('event', 'order_status')
101
+ ->addFieldToFilter('order_status', $newStatus);
102
+
103
+ $customer = new Varien_Object;
104
+ $customer->setName($order->getCustomerName())
105
+ ->setEmail($order->getCustomerEmail())
106
+ ->setId($order->getCustomerId());
107
+
108
+ foreach ($autoresponders as $autoresponder) {
109
+ $this->_insertData($autoresponder, $phone, $order->getStoreId(), $customer, $order->getId());
110
+ }
111
+ }
112
+
113
+ public function newOrder($event)
114
+ {
115
+
116
+ $order = $event->getEvent()->getOrder();
117
+
118
+ $autoresponders = $this->_getCollection($order->getStoreId())
119
+ ->addFieldToFilter('event', array('in' => array('order_product', 'order_new')));
120
+
121
+ $customer = new Varien_Object;
122
+ $customer->setName($order->getCustomerName())
123
+ ->setEmail($order->getCustomerEmail())
124
+ ->setId($order->getCustomerId());
125
+
126
+ foreach ($autoresponders as $autoresponder) {
127
+
128
+ if ($autoresponder->getEvent() == 'order_product') {
129
+ $items = $order->getAllItems();
130
+ $ok = false;
131
+ foreach ($items as $item) {
132
+ if ($item->getProductId() == $autoresponder->getProduct()) {
133
+ $ok = true;
134
+ break;
135
+ }
136
+ }
137
+ if ($ok === false) {
138
+ break;
139
+ }
140
+ }
141
+
142
+ $phone = Mage::getModel('fidelitas/egoi')->getPhone($order);
143
+
144
+ if (!$phone) {
145
+ return false;
146
+ }
147
+
148
+
149
+ $this->_insertData($autoresponder, $phone, $order->getStoreId(), $customer, $order->getId());
150
+ }
151
+ }
152
+
153
+ public function calculateSendDate($autoresponder)
154
+ {
155
+ if ($autoresponder->getSendMoment() == 'occurs') {
156
+ $date = Mage::app()->getLocale()->date()
157
+ ->get(self::MYSQL_DATETIME);
158
+ }
159
+
160
+ if ($autoresponder->getSendMoment() == 'after') {
161
+ $date = Mage::app()->getLocale()->date();
162
+
163
+ if ($autoresponder->getAfterHours() > 0) {
164
+ $date->addHour($autoresponder->getAfterHours());
165
+ }
166
+ if ($autoresponder->getAfterDays() > 0) {
167
+ $date->addDay($autoresponder->getAfterDays());
168
+ }
169
+ $date->get(self::MYSQL_DATETIME);
170
+ }
171
+
172
+ return $date;
173
+ }
174
+
175
+ public function send()
176
+ {
177
+ $date = Mage::app()->getLocale()->date()->get(self::MYSQL_DATETIME);
178
+
179
+ $smsCollection = Mage::getModel('fidelitas/events')->getCollection()
180
+ ->addFieldToFilter('sent', 0)
181
+ ->addFieldToFilter('send_at', array('lteq' => $date));
182
+
183
+ foreach ($smsCollection as $cron) {
184
+
185
+ $autoresponder = Mage::getModel('fidelitas/autoresponders')->load($cron->getAutoresponderId());
186
+
187
+ $message = Mage::helper('cms')->getBlockTemplateProcessor()->filter($autoresponder->getMessage());
188
+
189
+ if ($autoresponder->getEvent() == 'new_shipment') {
190
+
191
+ $track = Mage::getModel('sales/order_shipment')
192
+ ->load($cron->getDataObjectId())
193
+ ->getTracksCollection()
194
+ ->getFirstItem();
195
+
196
+ if ($track->getId()) {
197
+ $message = str_replace(
198
+ array('{track_number}', '{track_title}'),
199
+ array($track->getTrackNumber(), $track->getTitle()),
200
+ $message
201
+ );
202
+ }
203
+ }
204
+
205
+ $result = Mage::getModel('fidelitas/egoi')->send($cron->getCellphone(), $message);
206
+
207
+ if ($result === true) {
208
+ $cron->setSent(1)->setMessage($message)->setSentAt($date)->save();
209
+ }
210
+ }
211
+ }
212
+
213
+ protected function _insertData($autoresponder, $number, $storeId, $customer, $dataObjectId = null)
214
+ {
215
+
216
+ $storeIds = explode(',', $autoresponder->getStoreIds());
217
+
218
+ if (!in_array($storeId, $storeIds)) {
219
+ return false;
220
+ }
221
+
222
+ $data = array();
223
+ $data['send_at'] = $this->calculateSendDate($autoresponder);
224
+ $data['autoresponder_id'] = $autoresponder->getId();
225
+ $data['cellphone'] = $number;
226
+ $data['customer_id'] = $customer->getId();
227
+ $data['customer_name'] = $customer->getName();
228
+ $data['customer_email'] = $customer->getEmail();
229
+ $data['event'] = $autoresponder->getEvent();
230
+ $data['created_at'] = new Zend_Db_Expr('NOW()');
231
+ $data['sent'] = 0;
232
+ $data['data_object_id'] = $dataObjectId;
233
+
234
+ Mage::getModel('fidelitas/events')->setData($data)->save();
235
+ $autoresponder->setData('number_subscribers', $autoresponder->getData('number_subscribers') + 1)->save();
236
+ }
237
+
238
+ public function toFormValues()
239
+ {
240
+ $return = array();
241
+ $collection = $this->getCollection()
242
+ ->addFieldToSelect('name')
243
+ ->addFieldToSelect('autoresponder_id')
244
+ ->setOrder('name', 'ASC');
245
+ foreach ($collection as $autoresponder) {
246
+ $return[$autoresponder->getId()] = $autoresponder->getName() . ' (ID:' . $autoresponder->getId() . ')';
247
+ }
248
+
249
+ return $return;
250
+ }
251
+
252
+ protected function _getCollection($storeId)
253
+ {
254
+
255
+ $date = Mage::app()->getLocale()->date()->get(self::MYSQL_DATE);
256
+ //Version Compatability
257
+ $return = $this->getCollection()
258
+ ->addFieldToFilter('active', 1);
259
+
260
+ $return->getSelect()
261
+ ->where(" FIND_IN_SET('0', store_ids) OR FIND_IN_SET(?, store_ids)", $storeId)
262
+ ->where(" from_date <=? or from_date IS NULL ", $date)
263
+ ->where(" to_date >=? or to_date IS NULL ", $date);
264
+
265
+
266
+ return $return;
267
+ }
268
+
269
+ }
app/code/community/Licentia/Fidelitas/Model/Egoi.php ADDED
@@ -0,0 +1,572 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Licentia_Fidelitas_Model_Egoi extends Varien_Object
4
+ {
5
+
6
+ const PLUGIN_KEY = 'e419a126e087bed65ad7fe8342f2f493';
7
+ const API_URL = 'http://api.e-goi.com/v2/soap.php?wsdl';
8
+
9
+
10
+ protected $_client;
11
+
12
+
13
+ public function _construct()
14
+ {
15
+ parent::_construct();
16
+
17
+ ini_set('default_socket_timeout', 120);
18
+
19
+ $this->_client = new Zend_Soap_Client(self::API_URL, array("user_agent" => "Mozilla/5.0 (Windows NT 6.1; rv:12.0) Gecko/20120403211507 Firefox/12.0"));
20
+ }
21
+
22
+
23
+ public function send($number, $message, $storeId = null)
24
+ {
25
+
26
+ if (!$number) {
27
+ return false;
28
+ }
29
+
30
+ $method = Mage::getStoreConfig('fidelitas/config/method', $storeId);
31
+
32
+ if ($method == 'campaign') {
33
+
34
+ $this->setData('subject', 'Sent from Magento');
35
+ $this->setData('fromID', Mage::getStoreConfig('fidelitas/config/sender', $storeId));
36
+ $this->setData('listID', Mage::getModel('fidelitas/lists')->getList()->getData('listnum'));
37
+ $this->setData('message', $message);
38
+ $this->setData('cellphone', $number);
39
+
40
+ $client = new Zend_XmlRpc_Client('http://api.e-goi.com/v2/xmlrpc.php');
41
+ $result = $client->call('sendSMS', array($this->getDataKey()));
42
+
43
+ $this->processServiceResult($this->_client->sendSMS($this->getDataKey()));
44
+
45
+ Mage::log($this->getData(), 2, 'fidelitas-sms-data.log', true);
46
+
47
+ if ($this->getData('id')) {
48
+ return true;
49
+ } else {
50
+ return false;
51
+ }
52
+
53
+ } else {
54
+
55
+ $url = 'https://www51.e-goi.com/api/public/sms/send';
56
+
57
+ $data = array(
58
+ "apikey" => Mage::getStoreConfig('fidelitas/config/api_key', $storeId),
59
+ "mobile" => $number,
60
+ "senderHash" => Mage::getStoreConfig('fidelitas/config/sender', $storeId),
61
+ "message" => $message,
62
+ );
63
+
64
+ $data = Zend_Json::encode($data);
65
+
66
+ $ch = curl_init($url);
67
+ curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
68
+ curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
69
+ curl_setopt($ch, CURLOPT_POST, 1);
70
+ curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
71
+ curl_setopt($ch, CURLOPT_POSTFIELDS, "$data");
72
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
73
+ $output = curl_exec($ch);
74
+ $http_status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
75
+ curl_close($ch);
76
+
77
+ $result = Zend_Json::decode($output);
78
+ if (is_array($result) && is_array($result['errors'])) {
79
+ $result = implode(' ', $result['errors']);
80
+ }
81
+
82
+ return ($http_status == 200) ? true : '. Server Response: ' . $result;
83
+ }
84
+ }
85
+
86
+ public function getPhone($document)
87
+ {
88
+
89
+ if (!is_object($document) && stripos($document, '-') === false) {
90
+ return false;
91
+ }
92
+
93
+ if (!is_object($document) && stripos($document, '-')) {
94
+ return $this->validateNumber($document);
95
+ }
96
+
97
+
98
+ if ($document instanceof Mage_Sales_Model_Order) {
99
+ $billing = $document->getBillingAddress();
100
+ } else if ($document instanceof Mage_Customer_Model_Customer) {
101
+ $billing = $document->getPrimaryBillingAddress();
102
+ } elseif (is_object($document->getOrder())) {
103
+ $billing = $document->getOrder()->getBillingAddress();
104
+ }
105
+
106
+ $prefix = Mage::getModel('fidelitas/subscribers')->getPrefixForCountry($billing->getCountryId());
107
+
108
+ $cellphoneField = Mage::getStoreConfig('fidelitas/config/cellphone');
109
+ $number = preg_replace('/\D/', '', $billing->getData($cellphoneField));
110
+ $number = ltrim($number, $prefix);
111
+ $number = ltrim($number, 0);
112
+
113
+ return $this->validateNumber($prefix . '-' . $number);
114
+ }
115
+
116
+ public function validateNumber($number)
117
+ {
118
+ $url = 'https://www51.e-goi.com/api/public/sms/validatePhone/' . $number;
119
+
120
+ $ch = curl_init($url);
121
+ curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
122
+ curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
123
+ curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
124
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
125
+ $result = curl_exec($ch);
126
+ curl_close($ch);
127
+
128
+ if (!$number) {
129
+ return false;
130
+ }
131
+
132
+ $final = Zend_Json::decode($result);
133
+
134
+ if (array_key_exists('errorCode', $final)) {
135
+ return false;
136
+ }
137
+
138
+ return $number;
139
+ }
140
+
141
+ public function validateEgoiEnvironment()
142
+ {
143
+ $auth = Mage::getSingleton('admin/session')->getUser()->getData('fidelitasAuth');
144
+
145
+ if ($auth === true) {
146
+ return true;
147
+ }
148
+
149
+ $info = $this->getUserData()->getData();
150
+
151
+ if (!isset($info[0]) || !isset($info[0]['user_id']) || (int)$info[0]['user_id'] == 0) {
152
+ return false;
153
+ }
154
+
155
+ $account = Mage::getModel('fidelitas/account')->getAccount();
156
+
157
+ if ((int)$account->getData('cliente_id') == 0) {
158
+
159
+ $n = Mage::getModel('fidelitas/egoi')->getAccountDetails()->getData();
160
+ $account->addData($n[0])->save();
161
+
162
+ $account = Mage::getModel('fidelitas/account')->getAccount();
163
+
164
+ if ((int)$account->getData('cliente_id') == 0) {
165
+ return false;
166
+ }
167
+ }
168
+
169
+ Mage::getSingleton('admin/session')->getUser()->setData('fidelitasAuth', true);
170
+
171
+ return true;
172
+ }
173
+
174
+ public function formatFields($data)
175
+ {
176
+
177
+ if (!is_array($data)) {
178
+ $data = array('RESULT' => $data);
179
+ }
180
+
181
+ if (count($data) == 1 && isset($data['ERROR'])) {
182
+ Mage::log(serialize($data), 2, 'fidelitas-egoi.log');
183
+ $data = array(0 => $data);
184
+ $this->setData($data);
185
+
186
+ return;
187
+ }
188
+
189
+ if (!array_key_exists(0, $data)) {
190
+ $data = array(0 => $data);
191
+ }
192
+
193
+ foreach ($data as $key => $value) {
194
+ $data[$key] = array_change_key_case($value, CASE_LOWER);
195
+ }
196
+
197
+ $this->setData($data);
198
+
199
+ return $this;
200
+ }
201
+
202
+
203
+ public function addSubscriberBulk($generate = false)
204
+ {
205
+ $meta = Mage::getModel('newsletter/subscriber')->getCollection();
206
+
207
+ $list = Mage::getModel('fidelitas/lists')->getList(true);
208
+ $extra = Mage::getModel('fidelitas/extra')->getExtra();
209
+
210
+ $processNumber = 500;
211
+
212
+ if ($generate) {
213
+ $processNumber = 999999999999;
214
+ }
215
+
216
+ $i = 0;
217
+
218
+ try {
219
+ while ($i * $processNumber <= $meta->getSize()) {
220
+
221
+ $i++;
222
+
223
+ $core = Mage::getModel('newsletter/subscriber')
224
+ ->getCollection()
225
+ ->setPageSize($processNumber)
226
+ ->setCurPage($i);
227
+
228
+ $subscribers = array();
229
+ $indexArray = array();
230
+ $subI = 0;
231
+
232
+ /** @var Mage_Newsletter_Model_Subscriber $subscriber */
233
+ foreach ($core as $subscriber) {
234
+ $subI++;
235
+
236
+ try {
237
+ $storeId = $subscriber->getStoreId();
238
+
239
+ $data = array();
240
+
241
+ $data['email'] = $subscriber->getEmail();
242
+ $indexArray[] = 'email';
243
+
244
+ if (!filter_var($data['email'], FILTER_VALIDATE_EMAIL)) {
245
+ $subscriber->delete();
246
+ continue;
247
+ }
248
+
249
+ $locale = Mage::getStoreConfig('general/locale/code', $storeId);
250
+ $language = Locale::getDisplayLanguage($locale);
251
+
252
+ /** @var Licentia_Fidelitas_Model_Subscribers $fidelitas */
253
+ $fidelitas = Mage::getModel('fidelitas/subscribers')->load($subscriber->getEmail(), 'email');
254
+ $customer = $fidelitas->findCustomer($subscriber->getEmail(), 'email');
255
+
256
+ foreach ($extra as $element) {
257
+ if ($element->getData('attribute_code') == 'magento_locale') {
258
+ $data[$element->getData('extra_code')] = $language;
259
+ $indexArray[] = $element->getData('extra_code');
260
+ }
261
+ if ($element->getData('attribute_code') == 'magento_store') {
262
+ $data[$element->getData('extra_code')] = Mage::getModel('adminhtml/system_store')->getStoreNameWithWebsite($storeId);
263
+ $indexArray[] = $element->getData('extra_code');
264
+ }
265
+ if ($element->getData('attribute_code') == 'magento_store_id') {
266
+ $data[$element->getData('extra_code')] = $storeId;
267
+ $indexArray[] = $element->getData('extra_code');
268
+ }
269
+
270
+ if (stripos($element->getData('attribute_code'), 'static_') !== false) {
271
+ $data[$element->getData('extra_code')] = $fidelitas->getData(str_replace('static_', '', $subscriber->getData('attribute_code')));
272
+ $indexArray[] = $element->getData('extra_code');
273
+ }
274
+ }
275
+
276
+
277
+ $data['birth_date'] = '';
278
+ $indexArray[] = 'birth_date';
279
+ $data['first_name'] = '';
280
+ $indexArray[] = 'first_name';
281
+ $data['last_name'] = '';
282
+ $indexArray[] = 'last_name';
283
+ $data['cellphone'] = '';
284
+ $indexArray[] = 'cellphone';
285
+
286
+ if ($customer) {
287
+ $data['birth_date'] = $customer->getData('dob');
288
+ $data['first_name'] = $customer->getData('firstname');
289
+ $data['last_name'] = $customer->getData('lastname');
290
+
291
+ if ($customer->getData('cellphone')) {
292
+ $data['cellphone'] = $customer->getData('cellphone');
293
+ }
294
+
295
+ foreach ($extra as $element) {
296
+
297
+ if (stripos($element->getData('attribute_code'), 'static_') !== false) {
298
+ $data[$element->getData('extra_code')] = $customer->getData(str_replace('static_', '', $element->getData('attribute_code')));
299
+
300
+ $indexArray[] = $element->getData('extra_code');
301
+ continue;
302
+ }
303
+
304
+ $billing = false;
305
+ if (stripos($element->getData('attribute_code'), 'addr_') !== false) {
306
+ $attributeCode = substr($element->getData('attribute_code'), 5);
307
+ $billing = true;
308
+ } else {
309
+ $attributeCode = $element->getData('attribute_code');
310
+ }
311
+
312
+ if (!$customer->getData($attributeCode)) {
313
+ if ($billing) {
314
+ $customer = $this->findCustomer($customer->getId(), 'entity_id', $attributeCode);
315
+ } else {
316
+ $customer = Mage::getModel('customer/customer')->load($customer->getId());
317
+ }
318
+ }
319
+ if ($customer->getData($attributeCode)) {
320
+ $data[$element->getData('extra_code')] = $customer->getData($attributeCode);
321
+
322
+ $indexArray[] = $element->getData('extra_code');
323
+ }
324
+ }
325
+ }
326
+
327
+ $data['status'] = $subscriber->getStatus();
328
+ $indexArray[] = 'status';
329
+ if ($subscriber->getStatus() == 4) {
330
+ $data['status'] = 0;
331
+ }
332
+ if ($subscriber->getStatus() == 3) {
333
+ $data['status'] = 2;
334
+ }
335
+ if ($subscriber->getStatus() == 2) {
336
+ $data['status'] = 4;
337
+ }
338
+
339
+ if ($subI == 1) {
340
+ $subscribers[] = $indexArray;
341
+ }
342
+
343
+ $subscribers[] = $data;
344
+ } catch (Exception $e) {
345
+ }
346
+ }
347
+
348
+ if ($generate === false) {
349
+ return $subscribers;
350
+ }
351
+
352
+ $params = array(
353
+ 'apikey' => Mage::getStoreConfig('fidelitas/config/api_key'),
354
+ 'plugin_key' => self::PLUGIN_KEY,
355
+ 'listID' => $list->getListnum(),
356
+ 'compareField' => 'email',
357
+ 'operation' => 2,
358
+ 'autoresponder' => 0,
359
+ 'subscribers' => $subscribers,
360
+ );
361
+
362
+ $this->processServiceResult($this->_client->addSubscriberBulk($params));
363
+ }
364
+
365
+ } catch (Exception $e) {
366
+ return false;
367
+ }
368
+ return true;
369
+ }
370
+
371
+
372
+ public function getDataKey()
373
+ {
374
+
375
+ $data = $this->getData();
376
+ $data['apikey'] = Mage::getStoreConfig('fidelitas/config/api_key');
377
+ $data['plugin_key'] = self::PLUGIN_KEY;
378
+
379
+ return $data;
380
+ }
381
+
382
+
383
+ public function processServiceResult($result, $index = null)
384
+ {
385
+
386
+ if (!is_array($result)) {
387
+ $result = array('result' => $result);
388
+ }
389
+
390
+ $result = array_change_key_case($result, CASE_LOWER);
391
+
392
+ if ($index && isset($result[$index])) {
393
+ $result = $result[$index];
394
+ $result = array_change_key_case($result, CASE_LOWER);
395
+ }
396
+
397
+ $this->setData($result);
398
+
399
+ $additionalData = serialize(array('request' => $this->_client->getLastRequest(), 'response' => $this->_client->getLastResponse()));
400
+
401
+ if (isset($result['error'])) {
402
+ Mage::log(serialize($additionalData), 2, 'fidelitas-egoi.log', true);
403
+ throw new Mage_Core_Exception(Mage::helper('fidelitas')->__($result['error']));
404
+ }
405
+
406
+ return $this;
407
+ }
408
+
409
+ public function addExtraField()
410
+ {
411
+ $this->setData('type', 'texto');
412
+ return $this->processServiceResult($this->_client->addExtraField($this->getDataKey()));
413
+ }
414
+
415
+ public function getAccountDetails()
416
+ {
417
+ $this->formatFields($this->_client->getClientData($this->getDataKey()));
418
+
419
+ return $this;
420
+ }
421
+
422
+
423
+ public function getUserData()
424
+ {
425
+ $this->formatFields($this->_client->getUserData($this->getDataKey()));
426
+
427
+ return $this;
428
+ }
429
+
430
+
431
+ public function getSenders()
432
+ {
433
+ $this->setData('channel', 'telemovel');
434
+ $this->formatFields($this->_client->getSenders($this->getDataKey()));
435
+
436
+ return $this;
437
+ }
438
+
439
+
440
+ public function getLists($listnum = null)
441
+ {
442
+
443
+ $result = $this->_client->getLists($this->getDataKey());
444
+
445
+ if (is_array($result)) {
446
+ foreach ($result as $key => $value) {
447
+
448
+ if ($listnum && $listnum != $value['listnum']) {
449
+ unset($result[$key]);
450
+ }
451
+
452
+ if (is_array($value) && (isset($value['extra_fields']) && !is_array($value['extra_fields']))) {
453
+ continue;
454
+ }
455
+
456
+ foreach ($value['extra_fields'] as $eKey => $eValue) {
457
+ unset($result[$key]['extra_fields'][$eKey]['listnum']);
458
+ unset($result[$key]['extra_fields'][$eKey]['opcoes']);
459
+ }
460
+ }
461
+ }
462
+
463
+ $this->formatFields($result);
464
+
465
+ return $this;
466
+ }
467
+
468
+
469
+ public function getSubscriberData()
470
+ {
471
+ $this->formatFields($this->_client->subscriberData($this->getDataKey()));
472
+
473
+ return $this;
474
+ }
475
+
476
+
477
+ public function editApiCallback()
478
+ {
479
+ return $this->processServiceResult($this->_client->editApiCallback($this->getDataKey()));
480
+ }
481
+
482
+
483
+ public function createList()
484
+ {
485
+ return $this->processServiceResult($this->_client->createList($this->getDataKey()));
486
+ }
487
+
488
+
489
+ public function updateList()
490
+ {
491
+ return $this->processServiceResult($this->_client->updateList($this->getDataKey()));
492
+ }
493
+
494
+
495
+ public function addSubscriber()
496
+ {
497
+ $this->setData('status', 1);
498
+ return $this->processServiceResult($this->_client->addSubscriber($this->getDataKey()));
499
+ }
500
+
501
+
502
+ public function editSubscriber()
503
+ {
504
+ return $this->processServiceResult($this->_client->editSubscriber($this->getDataKey()));
505
+ }
506
+
507
+
508
+ public function removeSubscriber()
509
+ {
510
+ $result = Mage::getModel('fidelitas/egoi')
511
+ ->setData('listID', $this->getData('listID'))
512
+ ->setData('subscriber', $this->getSubscriber())
513
+ ->getSubscriberData()
514
+ ->getData();
515
+
516
+ if (is_array($result) && $result[0]['subscriber']['STATUS'] != 2) {
517
+ return $this->processServiceResult($this->_client->removeSubscriber($this->getDataKey()));
518
+ }
519
+
520
+ if ($this->getData('inCron')) {
521
+ return;
522
+ }
523
+
524
+ return array('error' => Mage::helper('fidelitas')->__('Subscriber not found or action not allowed'));
525
+ }
526
+
527
+
528
+ public function checkLogin($apiKey = null)
529
+ {
530
+
531
+ $data = $this->getDataKey();
532
+ if ($apiKey) {
533
+ $data['apikey'] = $apiKey;
534
+ }
535
+ $this->processServiceResult($this->_client->checklogin($data));
536
+
537
+ return $this;
538
+ }
539
+
540
+
541
+ public function sync()
542
+ {
543
+ $account = Mage::getModel('fidelitas/account')->getAccount();
544
+ $key = Mage::getStoreConfig('fidelitas/config/api_key');
545
+
546
+ if (!$key) {
547
+ return;
548
+ }
549
+
550
+ $models = array('subscribers', 'account');
551
+ foreach ($models as $sync) {
552
+ Mage::getModel('fidelitas/' . $sync)->cron();
553
+ }
554
+
555
+ $account->setData('cron', 0)->save();
556
+ }
557
+
558
+
559
+ public function syncm()
560
+ {
561
+ $account = Mage::getModel('fidelitas/account')->getAccount();
562
+
563
+ if ($account->getCron() == 3) {
564
+ Mage::registry('fidelitas_first_run', true);
565
+ }
566
+ if ($account->getCron() == 1 || $account->getCron() == 3) {
567
+ $account->setData('cron', 0)->save();
568
+ Mage::getModel('fidelitas/egoi')->sync();
569
+ }
570
+ }
571
+
572
+ }
app/code/community/Licentia/Fidelitas/Model/Events.php ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Licentia Fidelitas - SMS Notifications for E-Goi
5
+ *
6
+ * NOTICE OF LICENSE
7
+ * This source file is subject to the Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International
8
+ * It is available through the world-wide-web at this URL:
9
+ * http://creativecommons.org/licenses/by-nc-nd/4.0/
10
+ *
11
+ * @title SMS Notifications
12
+ * @category Marketing
13
+ * @package Licentia
14
+ * @author Bento Vilas Boas <bento@licentia.pt>
15
+ * @copyright Copyright (c) 2016 E-Goi - http://e-goi.com
16
+ * @license Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International
17
+ */
18
+ class Licentia_Fidelitas_Model_Events extends Mage_Core_Model_Abstract {
19
+
20
+ protected function _construct() {
21
+
22
+ $this->_init('fidelitas/events');
23
+ }
24
+
25
+ }
app/code/community/Licentia/Fidelitas/Model/Extra.php ADDED
@@ -0,0 +1,93 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Licentia_Fidelitas_Model_Extra extends Mage_Core_Model_Abstract
4
+ {
5
+
6
+ protected function _construct()
7
+ {
8
+
9
+ $this->_init('fidelitas/extra');
10
+ }
11
+
12
+ public function addInitialFields($list = false)
13
+ {
14
+ $this->addField('magento_locale', $list);
15
+ $this->addField('magento_store', $list);
16
+ $this->addField('magento_store_id', $list);
17
+ }
18
+
19
+
20
+ public function addField($name, $list = false)
21
+ {
22
+ if (!$list) {
23
+ $list = Mage::getModel('fidelitas/lists')->getList()->getData('listnum');
24
+ }
25
+
26
+ $extra = Mage::getModel('fidelitas/egoi')
27
+ ->setData(array('listID' => $list))
28
+ ->getLists();
29
+
30
+
31
+ foreach ($extra->getData() as $extraField) {
32
+ if (isset($extraField['extra_fields']) && is_array($extraField['extra_fields'])) {
33
+ foreach ($extraField['extra_fields'] as $field) {
34
+ if (isset($field['ref']) && $field['ref'] == $name) {
35
+ return true;
36
+ }
37
+ }
38
+ }
39
+ }
40
+
41
+ $data = array('listID' => $list, 'name' => $name);
42
+ $result = Mage::getModel('fidelitas/egoi')->setData($data)->addExtraField();
43
+
44
+ return $this->setData(array(
45
+ 'extra_code' => 'extra_' . $result->getData('new_id'),
46
+ 'attribute_code' => $name,
47
+ 'system' => 1)
48
+ )
49
+ ->save();
50
+
51
+ }
52
+
53
+
54
+ public function updateExtra($data, $system = 0)
55
+ {
56
+ $collection = $this->getCollection()
57
+ ->addFieldToFilter('attribute_code', array('neq' => 'magento_locale'))
58
+ ->addFieldToFilter('attribute_code', array('neq' => 'magento_store_id'))
59
+ ->addFieldToFilter('attribute_code', array('neq' => 'magento_store'));
60
+
61
+ foreach ($collection as $item) {
62
+ $item->delete();
63
+ }
64
+
65
+ foreach ($data as $key => $value) {
66
+
67
+ if ($value == '0') {
68
+ continue;
69
+ }
70
+
71
+ $new = array();
72
+ $new['attribute_code'] = $value;
73
+ $new['extra_code'] = $key;
74
+ $new['system'] = $system;
75
+
76
+ $this->setData($new)->save();
77
+ }
78
+ }
79
+
80
+ public function getExtra($system = 0)
81
+ {
82
+ $collection = $this->getCollection();
83
+ foreach ($collection as $item) {
84
+
85
+ if (is_numeric($item->getData('extra_code'))) {
86
+ $item->setData('extra_code', 'extra_' . $item->getData('extra_code'));
87
+ }
88
+
89
+ }
90
+ return $collection;
91
+ }
92
+
93
+ }
app/code/community/Licentia/Fidelitas/Model/Lists.php ADDED
@@ -0,0 +1,207 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Licentia_Fidelitas_Model_Lists extends Mage_Core_Model_Abstract
4
+ {
5
+
6
+ protected function _construct()
7
+ {
8
+
9
+ $this->_init('fidelitas/lists');
10
+ }
11
+
12
+
13
+ public function save()
14
+ {
15
+
16
+ $model = Mage::getModel('fidelitas/egoi');
17
+ $data = $this->getData();
18
+
19
+ $this->setData('canal_email', '1');
20
+
21
+ $egoi = Mage::getModel('fidelitas/egoi')->getLists();
22
+ foreach ($egoi->getData() as $list) {
23
+ if (isset($list['extra_fields']) && is_array($list['extra_fields'])) {
24
+ $i = 0;
25
+ foreach ($list['extra_fields'] as $field) {
26
+ if (isset($field['ref']) && $field['ref'] == 'magento_store_id') {
27
+ $i++;
28
+ }
29
+ if (isset($field['ref']) && $field['ref'] == 'magento_store') {
30
+ $i++;
31
+ }
32
+ if (isset($field['ref']) && $field['ref'] == 'magento_locale') {
33
+ $i++;
34
+ }
35
+ if ($i == 2) {
36
+ $this->setData('listnum', $list['listnum']);
37
+ break 2;
38
+ }
39
+ }
40
+ }
41
+ }
42
+
43
+ if (!$this->getData('listID') && $this->getData('listnum')) {
44
+ $this->setData('listID', $this->getData('listnum'));
45
+ $data['listID'] = $this->getData('listnum');
46
+ }
47
+
48
+ $total = $this->getCollection()->getFirstItem();
49
+
50
+ if ($total->getId()) {
51
+ $this->setId($total->getId());
52
+ }
53
+
54
+ if ($this->getData('listnum')) {
55
+
56
+ if (isset($data['nome'])) {
57
+ $data['name'] = $data['nome'];
58
+ }
59
+ $data['title'] = $data['nome'];
60
+ if (isset($data['nome'])) {
61
+ $this->setData('title', $data['nome']);
62
+ }
63
+ $model->addData($data);
64
+ $model->updateList($data);
65
+ } else {
66
+
67
+ $model->setData($data);
68
+ $model->createList();
69
+ $this->setData('listnum', $model->getData('list_id'));
70
+ $this->setData('title', $data['nome']);
71
+ }
72
+
73
+ $parent = parent::save();
74
+
75
+
76
+ return $parent;
77
+ }
78
+
79
+ public function _afterSave()
80
+ {
81
+ $this->updateCallback();
82
+
83
+ return parent::_afterSave();
84
+ }
85
+
86
+ public function updateCallback($id = null)
87
+ {
88
+
89
+ if ($id) {
90
+ $list = $this->load($id);
91
+ } else {
92
+ $list = $this;
93
+ }
94
+
95
+ $store = Mage::app()->getStore();
96
+ $url = $store->getBaseUrl() . 'fidelitas/callback/';
97
+
98
+ $callback = array();
99
+ $callback['listID'] = $list->hasListnum() ? $list->getData('listnum') : $list->getData('listID');
100
+ $callback['callback_url'] = $url;
101
+
102
+ $callback['notif_api_1'] = 1;
103
+ $callback['notif_api_2'] = 1;
104
+ $callback['notif_api_3'] = 1;
105
+ $callback['notif_api_7'] = 1;
106
+ $callback['notif_api_8'] = 1;
107
+ $callback['notif_api_9'] = 1;
108
+ $callback['notif_api_10'] = 1;
109
+ $callback['notif_api_15'] = 1;
110
+
111
+ Mage::getModel('fidelitas/egoi')->setData($callback)->editApiCallback();
112
+ }
113
+
114
+ public function getList($forceFields = false)
115
+ {
116
+ $result = $this->getCollection()->getFirstItem();
117
+
118
+ if (!$result->getId()) {
119
+ $data = array();
120
+ $data['nome'] = 'General';
121
+ $data['title'] = 'General';
122
+ $data['name'] = 'General';
123
+ $data['internal_name'] = '[Magento List]';
124
+ $this->setData($data)->save();
125
+ $result = $this;
126
+ }
127
+
128
+
129
+ if ($forceFields) {
130
+
131
+ $extra = Mage::getModel('fidelitas/egoi')
132
+ ->setData(array('listID' => $result->getData('listnum')))
133
+ ->getLists();
134
+ $addExtra = true;
135
+ $idMagentoStore = 0;
136
+ $idMagentoStoreId = 0;
137
+ $idMagentoLocale = 0;
138
+ foreach ($extra->getData() as $list) {
139
+ if (isset($list['extra_fields']) && is_array($list['extra_fields'])) {
140
+ $i = 0;
141
+ foreach ($list['extra_fields'] as $field) {
142
+ if (isset($field['ref']) && $field['ref'] == 'magento_store_id') {
143
+ $idMagentoStoreId = $field['id'];
144
+ $i++;
145
+ }
146
+ if (isset($field['ref']) && $field['ref'] == 'magento_store') {
147
+ $idMagentoStore = $field['id'];
148
+ $i++;
149
+ }
150
+ if (isset($field['ref']) && $field['ref'] == 'magento_locale') {
151
+ $idMagentoLocale = $field['id'];
152
+ $i++;
153
+ }
154
+ if ($i == 3) {
155
+ $addExtra = false;
156
+ break 2;
157
+ }
158
+ }
159
+ }
160
+ }
161
+
162
+ if ($addExtra) {
163
+ Mage::getModel('fidelitas/extra')->addInitialFields($result->getData('listnum'));
164
+ } else {
165
+
166
+ $existsLocale = Mage::getModel('fidelitas/extra')
167
+ ->getCollection()
168
+ ->addFieldToFilter('attribute_code', 'magento_locale')
169
+ ->getFirstItem();
170
+
171
+ $existsStore = Mage::getModel('fidelitas/extra')
172
+ ->getCollection()
173
+ ->addFieldToFilter('attribute_code', 'magento_store')
174
+ ->getFirstItem();
175
+
176
+
177
+ $existsStoreId = Mage::getModel('fidelitas/extra')
178
+ ->getCollection()
179
+ ->addFieldToFilter('attribute_code', 'magento_store_id')
180
+ ->getFirstItem();
181
+
182
+
183
+ if (!$existsLocale->getId()) {
184
+ Mage::getModel('fidelitas/extra')
185
+ ->setData(array('extra_code' => 'extra_' . $idMagentoLocale, 'attribute_code' => 'magento_locale'))
186
+ ->save();
187
+ }
188
+
189
+ if (!$existsStore->getId()) {
190
+ Mage::getModel('fidelitas/extra')
191
+ ->setData(array('extra_code' => 'extra_' . $idMagentoStore, 'attribute_code' => 'magento_store'))
192
+ ->save();
193
+ }
194
+
195
+ if (!$existsStoreId->getId()) {
196
+ Mage::getModel('fidelitas/extra')
197
+ ->setData(array('extra_code' => 'extra_' . $idMagentoStoreId, 'attribute_code' => 'magento_store_id'))
198
+ ->save();
199
+ }
200
+
201
+ }
202
+
203
+ }
204
+
205
+ return $result;
206
+ }
207
+ }
app/code/community/Licentia/Fidelitas/Model/Mysql4/Account.php ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Licentia Fidelitas - Advanced Email and SMS Marketing Automation for E-Goi
5
+ *
6
+ * NOTICE OF LICENSE
7
+ * This source file is subject to the Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International
8
+ * It is available through the world-wide-web at this URL:
9
+ * http://creativecommons.org/licenses/by-nc-nd/4.0/
10
+ *
11
+ * @title Advanced Email and SMS Marketing Automation
12
+ * @category Marketing
13
+ * @package Licentia
14
+ * @author Bento Vilas Boas <bento@licentia.pt>
15
+ * @copyright Copyright (c) 2016 E-Goi - http://e-goi.com
16
+ * @license Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International
17
+ */
18
+ class Licentia_Fidelitas_Model_Mysql4_Account extends Mage_Core_Model_Mysql4_Abstract
19
+ {
20
+ public function _construct()
21
+ {
22
+ $this->_init('fidelitas/account', 'account_id');
23
+ }
24
+ }
app/code/community/Licentia/Fidelitas/Model/Mysql4/Account/Collection.php ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Licentia Fidelitas - Advanced Email and SMS Marketing Automation for E-Goi
5
+ *
6
+ * NOTICE OF LICENSE
7
+ * This source file is subject to the Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International
8
+ * It is available through the world-wide-web at this URL:
9
+ * http://creativecommons.org/licenses/by-nc-nd/4.0/
10
+ *
11
+ * @title Advanced Email and SMS Marketing Automation
12
+ * @category Marketing
13
+ * @package Licentia
14
+ * @author Bento Vilas Boas <bento@licentia.pt>
15
+ * @copyright Copyright (c) 2016 E-Goi - http://e-goi.com
16
+ * @license Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International
17
+ */
18
+ class Licentia_Fidelitas_Model_Mysql4_Account_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
19
+ {
20
+ public function _construct()
21
+ {
22
+ parent::_construct();
23
+ $this->_init('fidelitas/account');
24
+ }
25
+ }
app/code/community/Licentia/Fidelitas/Model/Mysql4/Autoresponders.php ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Licentia Fidelitas - SMS Notifications for E-Goi
5
+ *
6
+ * NOTICE OF LICENSE
7
+ * This source file is subject to the Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International
8
+ * It is available through the world-wide-web at this URL:
9
+ * http://creativecommons.org/licenses/by-nc-nd/4.0/
10
+ *
11
+ * @title SMS Notifications
12
+ * @category Marketing
13
+ * @package Licentia
14
+ * @author Bento Vilas Boas <bento@licentia.pt>
15
+ * @copyright Copyright (c) 2016 E-Goi - http://e-goi.com
16
+ * @license Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International
17
+ */
18
+ class Licentia_Fidelitas_Model_Mysql4_Autoresponders extends Mage_Core_Model_Mysql4_Abstract {
19
+
20
+ public function _construct() {
21
+ $this->_init('fidelitas/autoresponders', 'autoresponder_id');
22
+ }
23
+
24
+ }
app/code/community/Licentia/Fidelitas/Model/Mysql4/Autoresponders/Collection.php ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Licentia Fidelitas - SMS Notifications for E-Goi
5
+ *
6
+ * NOTICE OF LICENSE
7
+ * This source file is subject to the Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International
8
+ * It is available through the world-wide-web at this URL:
9
+ * http://creativecommons.org/licenses/by-nc-nd/4.0/
10
+ *
11
+ * @title SMS Notifications
12
+ * @category Marketing
13
+ * @package Licentia
14
+ * @author Bento Vilas Boas <bento@licentia.pt>
15
+ * @copyright Copyright (c) 2016 E-Goi - http://e-goi.com
16
+ * @license Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International
17
+ */
18
+ class Licentia_Fidelitas_Model_Mysql4_Autoresponders_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract {
19
+
20
+ public function _construct() {
21
+ parent::_construct();
22
+ $this->_init('fidelitas/autoresponders');
23
+ }
24
+
25
+ }
app/code/community/Licentia/Fidelitas/Model/Mysql4/Events.php ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Licentia Fidelitas - SMS Notifications for E-Goi
5
+ *
6
+ * NOTICE OF LICENSE
7
+ * This source file is subject to the Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International
8
+ * It is available through the world-wide-web at this URL:
9
+ * http://creativecommons.org/licenses/by-nc-nd/4.0/
10
+ *
11
+ * @title SMS Notifications
12
+ * @category Marketing
13
+ * @package Licentia
14
+ * @author Bento Vilas Boas <bento@licentia.pt>
15
+ * @copyright Copyright (c) 2016 E-Goi - http://e-goi.com
16
+ * @license Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International
17
+ */
18
+ class Licentia_Fidelitas_Model_Mysql4_Events extends Mage_Core_Model_Mysql4_Abstract {
19
+
20
+ public function _construct() {
21
+ $this->_init('fidelitas/events', 'event_id');
22
+ }
23
+
24
+ }
app/code/community/Licentia/Fidelitas/Model/Mysql4/Events/Collection.php ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Licentia Fidelitas - SMS Notifications for E-Goi
5
+ *
6
+ * NOTICE OF LICENSE
7
+ * This source file is subject to the Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International
8
+ * It is available through the world-wide-web at this URL:
9
+ * http://creativecommons.org/licenses/by-nc-nd/4.0/
10
+ *
11
+ * @title SMS Notifications
12
+ * @category Marketing
13
+ * @package Licentia
14
+ * @author Bento Vilas Boas <bento@licentia.pt>
15
+ * @copyright Copyright (c) 2016 E-Goi - http://e-goi.com
16
+ * @license Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International
17
+ */
18
+ class Licentia_Fidelitas_Model_Mysql4_Events_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract {
19
+
20
+ public function _construct() {
21
+ parent::_construct();
22
+ $this->_init('fidelitas/events');
23
+ }
24
+
25
+ }
app/code/community/Licentia/Fidelitas/Model/Mysql4/Extra.php ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Licentia_Fidelitas_Model_Mysql4_Extra extends Mage_Core_Model_Mysql4_Abstract
4
+ {
5
+
6
+ public function _construct()
7
+ {
8
+ $this->_init('fidelitas/extra', 'record_id');
9
+ }
10
+
11
+ }
app/code/community/Licentia/Fidelitas/Model/Mysql4/Extra/Collection.php ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Licentia_Fidelitas_Model_Mysql4_Extra_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
4
+ {
5
+
6
+ public function _construct()
7
+ {
8
+ parent::_construct();
9
+ $this->_init('fidelitas/extra');
10
+ }
11
+
12
+
13
+ }
app/code/community/Licentia/Fidelitas/Model/Mysql4/Lists.php ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Licentia Fidelitas - Advanced Email and SMS Marketing Automation for E-Goi
5
+ *
6
+ * NOTICE OF LICENSE
7
+ * This source file is subject to the Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International
8
+ * It is available through the world-wide-web at this URL:
9
+ * http://creativecommons.org/licenses/by-nc-nd/4.0/
10
+ *
11
+ * @title Advanced Email and SMS Marketing Automation
12
+ * @category Marketing
13
+ * @package Licentia
14
+ * @author Bento Vilas Boas <bento@licentia.pt>
15
+ * @copyright Copyright (c) 2016 E-Goi - http://e-goi.com
16
+ * @license Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International
17
+ */
18
+ class Licentia_Fidelitas_Model_Mysql4_Lists extends Mage_Core_Model_Mysql4_Abstract
19
+ {
20
+ public function _construct()
21
+ {
22
+ $this->_init('fidelitas/lists', 'list_id');
23
+ }
24
+ }
app/code/community/Licentia/Fidelitas/Model/Mysql4/Lists/Collection.php ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Licentia Fidelitas - Advanced Email and SMS Marketing Automation for E-Goi
5
+ *
6
+ * NOTICE OF LICENSE
7
+ * This source file is subject to the Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International
8
+ * It is available through the world-wide-web at this URL:
9
+ * http://creativecommons.org/licenses/by-nc-nd/4.0/
10
+ *
11
+ * @title Advanced Email and SMS Marketing Automation
12
+ * @category Marketing
13
+ * @package Licentia
14
+ * @author Bento Vilas Boas <bento@licentia.pt>
15
+ * @copyright Copyright (c) 2016 E-Goi - http://e-goi.com
16
+ * @license Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International
17
+ */
18
+ class Licentia_Fidelitas_Model_Mysql4_Lists_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
19
+ {
20
+ public function _construct()
21
+ {
22
+ parent::_construct();
23
+ $this->_init('fidelitas/lists');
24
+ }
25
+ }
app/code/community/Licentia/Fidelitas/Model/Mysql4/Subscribers.php ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Licentia Fidelitas - Advanced Email and SMS Marketing Automation for E-Goi
5
+ *
6
+ * NOTICE OF LICENSE
7
+ * This source file is subject to the Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International
8
+ * It is available through the world-wide-web at this URL:
9
+ * http://creativecommons.org/licenses/by-nc-nd/4.0/
10
+ *
11
+ * @title Advanced Email and SMS Marketing Automation
12
+ * @category Marketing
13
+ * @package Licentia
14
+ * @author Bento Vilas Boas <bento@licentia.pt>
15
+ * @copyright Copyright (c) 2016 E-Goi - http://e-goi.com
16
+ * @license Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International
17
+ */
18
+ class Licentia_Fidelitas_Model_Mysql4_Subscribers extends Mage_Core_Model_Mysql4_Abstract
19
+ {
20
+ public function _construct()
21
+ {
22
+ $this->_init('fidelitas/subscribers', 'subscriber_id');
23
+ }
24
+ }
app/code/community/Licentia/Fidelitas/Model/Mysql4/Subscribers/Collection.php ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+
4
+ class Licentia_Fidelitas_Model_Mysql4_Subscribers_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
5
+ {
6
+ public function _construct()
7
+ {
8
+ parent::_construct();
9
+ $this->_init('fidelitas/subscribers');
10
+ }
11
+
12
+ public function getAllIds($field = false)
13
+ {
14
+ if (!$field) {
15
+ return parent::getAllIds();
16
+ }
17
+
18
+ $idsSelect = clone $this->getSelect();
19
+ $idsSelect->reset(Zend_Db_Select::ORDER);
20
+ $idsSelect->reset(Zend_Db_Select::LIMIT_COUNT);
21
+ $idsSelect->reset(Zend_Db_Select::LIMIT_OFFSET);
22
+ $idsSelect->reset(Zend_Db_Select::COLUMNS);
23
+ $idsSelect->columns($field, 'main_table');
24
+ return $this->getConnection()->fetchCol($idsSelect);
25
+ }
26
+ }
app/code/community/Licentia/Fidelitas/Model/Observer.php ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Licentia_Fidelitas_Model_Observer
4
+ {
5
+
6
+ /**
7
+ * Add order information into Egoimmerce block to render on checkout success pages
8
+ *
9
+ * @param Varien_Event_Observer $observer
10
+ */
11
+ public function setEgoimmerceOnOrderSuccessPageView(Varien_Event_Observer $observer)
12
+ {
13
+ $orderIds = $observer->getEvent()->getOrderIds();
14
+ if (empty($orderIds) || !is_array($orderIds)) {
15
+ return;
16
+ }
17
+ $block = Mage::app()->getFrontController()->getAction()->getLayout()->getBlock('egoimmerce');
18
+ if ($block) {
19
+ $block->setOrderIds($orderIds);
20
+ }
21
+ }
22
+
23
+
24
+ public function addToAutoList($event)
25
+ {
26
+
27
+ $order = $event->getEvent()->getOrder();
28
+
29
+ try {
30
+
31
+ if (!Mage::getStoreConfig('fidelitas/config/auto')) {
32
+ return false;
33
+ }
34
+
35
+ $email = $order->getCustomerEmail();
36
+ Mage::getModel('newsletter/subscriber')->subscribe($email);
37
+
38
+ } catch (Exception $e) {
39
+ Mage::logException($e);
40
+ }
41
+ }
42
+
43
+ }
app/code/community/Licentia/Fidelitas/Model/Source/Addressattributes.php ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Licentia_Fidelitas_Model_Source_Addressattributes
4
+ {
5
+
6
+ public function toOptionArray()
7
+ {
8
+ $type = Mage::getModel('eav/entity_type')->loadByCode('customer_address');
9
+ $attributes = Mage::getResourceModel('eav/entity_attribute_collection')->setEntityTypeFilter($type);
10
+ $return = array();
11
+
12
+ foreach ($attributes as $attribute) {
13
+ $return[] = array('value' => $attribute['attribute_code'], 'label' => $attribute['frontend_label']);
14
+ }
15
+
16
+ return $return;
17
+ }
18
+
19
+ }
app/code/community/Licentia/Fidelitas/Model/Source/Method.php ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Licentia_Fidelitas_Model_Source_Method
4
+ {
5
+
6
+ public function toOptionArray()
7
+ {
8
+ $return = array();
9
+ $return[] = array('value' => 'transactional', 'label' => 'Transactional API');
10
+ $return[] = array('value' => 'campaign', 'label' => 'Campaign API');
11
+
12
+ return $return;
13
+ }
14
+
15
+ }
app/code/community/Licentia/Fidelitas/Model/Source/Sender.php ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Licentia_Fidelitas_Model_Source_Sender
4
+ {
5
+
6
+ public function toOptionArray()
7
+ {
8
+ $attributes = Mage::getModel('fidelitas/egoi')->getSenders();
9
+ $return = array();
10
+
11
+ foreach ($attributes->getData() as $attribute) {
12
+ $return[] = array('value' => $attribute['fromid'], 'label' => $attribute['sender']);
13
+ }
14
+
15
+ return $return;
16
+ }
17
+
18
+ }
app/code/community/Licentia/Fidelitas/Model/Subscribers.php ADDED
@@ -0,0 +1,611 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Licentia_Fidelitas_Model_Subscribers extends Mage_Core_Model_Abstract
4
+ {
5
+ protected function _construct()
6
+ {
7
+ $this->_init('fidelitas/subscribers');
8
+ }
9
+
10
+ function cron()
11
+ {
12
+
13
+ Mage::log('started', null, 'fidelitas-sync-subs.log', true);
14
+
15
+ $subscribers = $this->getCollection()
16
+ ->addFieldToFilter('cellphone', '')
17
+ ->addFieldToFilter('email', '');
18
+
19
+ foreach ($subscribers as $subscriber) {
20
+ $subscriber->delete();
21
+ }
22
+
23
+ $egoi = Mage::getModel('fidelitas/egoi');
24
+ $list = Mage::getModel('fidelitas/lists')->getList();
25
+
26
+ $limit = 1000;
27
+ $end = false;
28
+ $start = 0;
29
+ do {
30
+ $egoi->addData(array('listID' => $list->getListnum(), 'subscriber' => 'all_subscribers', 'limit' => $limit))
31
+ ->setData('start', $start);
32
+
33
+ try {
34
+ $subscribers = $egoi->getSubscriberData()->getData();
35
+ } catch (Exception $e) {
36
+ Mage::logException($e);
37
+ }
38
+
39
+ if (isset($subscribers[0]['ERROR'])) {
40
+ break;
41
+ }
42
+
43
+ if (count($subscribers[0]['subscriber']) < $limit) {
44
+ $end = true;
45
+ }
46
+
47
+ foreach ($subscribers[0]['subscriber'] as $subscriber) {
48
+
49
+ $subscriberData = array_change_key_case($subscriber, CASE_LOWER);
50
+
51
+ if (!filter_var($subscriberData, FILTER_VALIDATE_EMAIL) && strlen($subscriberData['cellphone']) < 4) {
52
+ continue;
53
+ }
54
+
55
+ $jaExiste = $this->load($subscriberData['email'], 'email');
56
+ if ($jaExiste->getId()) {
57
+ $subscriberData['subscriber_id'] = $jaExiste->getId();
58
+ }
59
+
60
+ if (strlen($subscriberData['birth_date']) > 0) {
61
+ $subscriberData['dob'] = $subscriberData['birth_date'];
62
+ }
63
+
64
+ try {
65
+ Mage::getModel('fidelitas/subscribers')
66
+ ->setData($subscriberData)
67
+ ->setData('inCron', true)
68
+ ->save();
69
+ } catch (Exception $e) {
70
+
71
+ }
72
+ }
73
+
74
+ $start += $limit;
75
+ } while ($end === false);
76
+
77
+ Mage::log('end', null, 'fidelitas-sync-subs.log', true);
78
+
79
+ }
80
+
81
+ public function findCustomer($value, $attribute = 'entity_id', $billing = null)
82
+ {
83
+
84
+ $cellphoneField = Mage::getStoreConfig('fidelitas/config/cellphone');
85
+ $customers = Mage::getModel('customer/customer')
86
+ ->getCollection()
87
+ ->addAttributeToSelect('firstname')
88
+ ->addAttributeToSelect('lastname')
89
+ ->addAttributeToSelect('store_id')
90
+ ->addAttributeToSelect('dob')
91
+ ->addAttributeToFilter($attribute, $value)
92
+ ->joinAttribute('country_id', 'customer_address/country_id', 'default_billing', null, 'left')
93
+ ->joinAttribute($cellphoneField, 'customer_address/' . $cellphoneField, 'default_billing', null, 'left');
94
+
95
+ if ($billing) {
96
+ $customers->joinAttribute($billing, 'customer_address/' . $billing, 'default_billing', null, 'left');
97
+ }
98
+
99
+ if ($customers->count() == 1) {
100
+ $customer = $customers->getFirstItem();
101
+ if (strlen($customer->getData($cellphoneField)) > 5) {
102
+ $customer->setData('cellphone', $this->getPrefixForCountry($customer->getCountryId()) . '-' . preg_replace('/\D/', '', $customer->getData($cellphoneField)));
103
+ }
104
+
105
+ return $customer;
106
+ }
107
+
108
+ return false;
109
+ }
110
+
111
+ public function importCoreNewsletterSubscribers()
112
+ {
113
+
114
+ $news = Mage::getModel('newsletter/subscriber')
115
+ ->getCollection()
116
+ ->addFieldToFilter('subscriber_status', 1);
117
+
118
+
119
+ /** @var Mage_Newsletter_Model_Subscriber $subscriber */
120
+ foreach ($news as $subscriber) {
121
+ if (!$subscriber->getStoreId()) {
122
+ continue;
123
+ }
124
+
125
+ $data = array();
126
+ $list = Mage::getModel('fidelitas/lists')->getList();
127
+
128
+ if ($this->subscriberExists('email', $subscriber->getEmail(), $list->getListnum())) {
129
+ continue;
130
+ }
131
+
132
+ $data['email'] = $subscriber->getEmail();
133
+ $data['status'] = 1;
134
+ $data['customer_id'] = $subscriber->getCustomerId();
135
+ $data['list'] = $list->getListnum();
136
+
137
+ try {
138
+ Mage::getModel('fidelitas/subscribers')->setData($data)->save();
139
+ } catch (Exception $e) {
140
+ Mage::logException($e);
141
+ }
142
+ }
143
+ }
144
+
145
+
146
+ public function subscriberExists($field, $value, $list)
147
+ {
148
+
149
+ $model = Mage::getModel('fidelitas/subscribers')
150
+ ->getCollection()
151
+ ->addFieldToFilter($field, $value)
152
+ ->addFieldToFilter('list', $list);
153
+
154
+ if ($model->count() != 1) {
155
+ return false;
156
+ }
157
+
158
+ return $model->getFirstItem();
159
+ }
160
+
161
+ public function save()
162
+ {
163
+ $data = $this->getData();
164
+
165
+ if (!$this->getEmail() || !filter_var($this->getEmail(), FILTER_VALIDATE_EMAIL)) {
166
+ return false;
167
+ }
168
+
169
+ $this->load($this->getEmail(), 'email');
170
+
171
+ if (!$this->getOrigData() && $this->getId()) {
172
+ $this->load($this->getId());
173
+ }
174
+
175
+ $list = Mage::getModel('fidelitas/lists')->getList()->getData('listnum');;
176
+
177
+ $data['listID'] = $list;
178
+ $data['list'] = $list;
179
+ $data['listnum'] = $list;
180
+
181
+ /** @var Mage_Customer_Model_Customer $customer */
182
+ $customer = $this->findCustomer($data['email'], 'email');
183
+
184
+ $extra = Mage::getModel('fidelitas/extra')->getExtra();
185
+
186
+ $storeId = $this->getStoreId();
187
+
188
+ $locale = Mage::getStoreConfig('general/locale/code', $storeId);
189
+ $language = Locale::getDisplayLanguage($locale);
190
+ foreach ($extra as $element) {
191
+ if ($element->getData('attribute_code') == 'magento_locale') {
192
+ $data[$element->getData('extra_code')] = $language;
193
+ }
194
+ if ($element->getData('attribute_code') == 'magento_store') {
195
+ $data[$element->getData('extra_code')] = Mage::getModel('adminhtml/system_store')->getStoreNameWithWebsite($storeId);
196
+ }
197
+ if ($element->getData('attribute_code') == 'magento_store_id') {
198
+ $data[$element->getData('extra_code')] = $storeId;
199
+ }
200
+
201
+ if (stripos($element->getData('attribute_code'), 'static_') !== false) {
202
+ $old = Mage::getModel('newsletter/subscriber')->loadByEmail($this->getEmail());
203
+ $data[$element->getData('extra_code')] = $this->getData(str_replace('static_', '', $old->getData('attribute_code')));
204
+ }
205
+ }
206
+
207
+ if ($customer) {
208
+ $data['customer_id'] = $customer->getId();
209
+ $data['birth_date'] = $customer->getData('dob');
210
+ $data['first_name'] = $customer->getData('firstname');
211
+ $data['last_name'] = $customer->getData('lastname');
212
+
213
+ if ($customer->getData('cellphone')) {
214
+ $data['cellphone'] = $customer->getData('cellphone');
215
+ }
216
+
217
+ foreach ($extra as $element) {
218
+
219
+ if (stripos($element->getData('attribute_code'), 'static_') !== false) {
220
+ $data[$element->getData('extra_code')] = $customer->getData(str_replace('static_', '', $element->getData('attribute_code')));
221
+ continue;
222
+ }
223
+
224
+ $billing = false;
225
+ if (stripos($element->getData('attribute_code'), 'addr_') !== false) {
226
+ $attributeCode = substr($element->getData('attribute_code'), 5);
227
+ $billing = true;
228
+ } else {
229
+ $attributeCode = $element->getData('attribute_code');
230
+ }
231
+
232
+ if (!$customer->getData($attributeCode)) {
233
+ if ($billing) {
234
+ $customer = $this->findCustomer($customer->getId(), 'entity_id', $attributeCode);
235
+ } else {
236
+ $customer = Mage::getModel('customer/customer')->load($customer->getId());
237
+ }
238
+ }
239
+ if ($customer->getData($attributeCode)) {
240
+ $data[$element->getData('extra_code')] = $customer->getData($attributeCode);
241
+ }
242
+ }
243
+ }
244
+
245
+ if (!$data['first_name'] && !$this->getOrigData('first_name')) {
246
+ $data['first_name'] = 'Customer';
247
+ }
248
+
249
+ $this->addData($data);
250
+
251
+ $info = $this->subscriberExists('email', $this->getEmail(), $this->getData('list'));
252
+
253
+ if ($info && isset($data['inCallback'])) {
254
+ $this->setId($info->getId());
255
+ }
256
+
257
+ if ($this->getData('inCron') === true && !Mage::registry('fidelitas_first_run')) {
258
+ return parent::save();
259
+ }
260
+
261
+ $model = Mage::getModel('fidelitas/egoi');
262
+
263
+ if ($info) {
264
+ $data['subscriber'] = $info->getUid();
265
+ $this->setId($info->getId());
266
+ } elseif ($info = $this->subscriberExists('subscriber_id', $this->getId(), $this->getData('list'))) {
267
+ $data['subscriber'] = $info->getUid();
268
+ $this->setId($info->getId());
269
+ }
270
+
271
+ $model->addData($data);
272
+ $this->addData($data);
273
+
274
+ try {
275
+ if ($this->getId()) {
276
+ if ($model->getData('uid')) {
277
+ $model->setData('subscriber', $model->getData('uid'));
278
+ }
279
+ if ($this->getData('status') == 0) {
280
+ $model->setData('status', 4);
281
+ }
282
+ $model->editSubscriber();
283
+
284
+ } else {
285
+ $result = $model->setData('status', 1)->addSubscriber();
286
+ if (isset($result['uid'])) {
287
+ $this->setData('uid', $result->getData('uid'));
288
+ }
289
+ }
290
+ } catch (Exception $e) {
291
+ Mage::logException($e);
292
+ }
293
+
294
+ return parent::save();
295
+ }
296
+
297
+ public function delete()
298
+ {
299
+ $model = Mage::getModel('fidelitas/egoi');
300
+
301
+ $data = array();
302
+ $data['listID'] = $this->getList();
303
+ $data['subscriber'] = $this->getUid();
304
+
305
+ if (!$this->getData('inCron') && !Mage::registry('fidelitas_clean')) {
306
+ $model->setData($data)->removeSubscriber();
307
+ }
308
+
309
+ Mage::getModel('newsletter/subscriber')->loadByEmail($data['email'])->delete();
310
+
311
+ return parent::delete();
312
+ }
313
+
314
+ public function updateFromNewsletterCore($event)
315
+ {
316
+ $subscriber = $event->getDataObject();
317
+ $email = $subscriber->getSubscriberEmail();
318
+ $subscriber->setImportMode(true);
319
+
320
+ if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
321
+ return false;
322
+ }
323
+
324
+ if (!$subscriber->getIsStatusChanged() && $subscriber->getOrigData('subscriber_status') == $subscriber->getData('subscriber_status')) {
325
+ return;
326
+ }
327
+
328
+ try {
329
+ $list = Mage::getModel('fidelitas/lists')->getList();
330
+
331
+ $listId = $list->getListnum();
332
+ $data = array();
333
+ $data['list'] = $listId;
334
+ $data['email'] = $email;
335
+ $data['status'] = $subscriber->getSubscriberStatus() == 3 ? 0 : 1;
336
+ $data['store_id'] = $subscriber->getStoreId();
337
+
338
+ $this->addData($data)->save();
339
+
340
+ } catch (Exception $e) {
341
+ Mage::logException($e);
342
+ }
343
+
344
+ }
345
+
346
+ public static function getPhonePrefixs()
347
+ {
348
+ $phones = self::phonePrefixsList();
349
+
350
+ $return = array();
351
+ $return[''] = Mage::helper('fidelitas')->__('-- Please Choose --');
352
+ foreach ($phones as $value) {
353
+ $return[$value[2]] = ucwords(strtolower($value[0])) . ' (+' . $value[2] . ')';
354
+ }
355
+
356
+ asort($return);
357
+
358
+ return $return;
359
+ }
360
+
361
+ public function getPrefixForCountry($countryCode)
362
+ {
363
+
364
+ $phones = self::phonePrefixsList();
365
+ foreach ($phones as $phone) {
366
+
367
+ if ($phone[1] == $countryCode) {
368
+ return $phone[2];
369
+ }
370
+ }
371
+
372
+ return '';
373
+ }
374
+
375
+ public static function phonePrefixsList()
376
+ {
377
+
378
+ return array(array('CANADA', 'CA', '1'),
379
+ array('PUERTO RICO', 'PR', '1'),
380
+ array('UNITED STATES', 'US', '1'),
381
+ array('ARMENIA', 'AM', '7'),
382
+ array('KAZAKHSTAN', 'KZ', '7'),
383
+ array('RUSSIAN FEDERATION', 'RU', '7'),
384
+ array('EGYPT', 'EG', '20'),
385
+ array('SOUTH AFRICA (Zuid Afrika)', 'ZA', '27'),
386
+ array('GREECE', 'GR', '30'),
387
+ array('NETHERLANDS', 'NL', '31'),
388
+ array('BELGIUM', 'BE', '32'),
389
+ array('FRANCE', 'FR', '33'),
390
+ array('SPAIN (España)', 'ES', '34'),
391
+ array('HUNGARY', 'HU', '36'),
392
+ array('ITALY', 'IT', '39'),
393
+ array('ROMANIA', 'RO', '40'),
394
+ array('SWITZERLAND (Confederation of Helvetia)', 'CH', '41'),
395
+ array('AUSTRIA', 'AT', '43'),
396
+ array('GREAT BRITAIN (United Kingdom)', 'GB', '44'),
397
+ array('UNITED KINGDOM', 'GB', '44'),
398
+ array('DENMARK', 'DK', '45'),
399
+ array('SWEDEN', 'SE', '46'),
400
+ array('NORWAY', 'NO', '47'),
401
+ array('POLAND', 'PL', '48'),
402
+ array('GERMANY (Deutschland)', 'DE', '49'),
403
+ array('PERU', 'PE', '51'),
404
+ array('MEXICO', 'MX', '52'),
405
+ array('CUBA', 'CU', '53'),
406
+ array('ARGENTINA', 'AR', '54'),
407
+ array('BRAZIL', 'BR', '55'),
408
+ array('CHILE', 'CL', '56'),
409
+ array('COLOMBIA', 'CO', '57'),
410
+ array('VENEZUELA', 'VE', '58'),
411
+ array('MALAYSIA', 'MY', '60'),
412
+ array('AUSTRALIA', 'AU', '61'),
413
+ array('INDONESIA', 'ID', '62'),
414
+ array('PHILIPPINES', 'PH', '63'),
415
+ array('NEW ZEALAND', 'NZ', '64'),
416
+ array('SINGAPORE', 'SG', '65'),
417
+ array('THAILAND', 'TH', '66'),
418
+ array('JAPAN', 'JP', '81'),
419
+ array('KOREA (Republic of [South] Korea)', 'KR', '82'),
420
+ array('VIET NAM', 'VN', '84'),
421
+ array('CHINA', 'CN', '86'),
422
+ array('TURKEY', 'TR', '90'),
423
+ array('INDIA', 'IN', '91'),
424
+ array('PAKISTAN', 'PK', '92'),
425
+ array('AFGHANISTAN', 'AF', '93'),
426
+ array('SRI LANKA (formerly Ceylon)', 'LK', '94'),
427
+ array('MYANMAR (formerly Burma)', 'MM', '95'),
428
+ array('IRAN (Islamic Republic of Iran)', 'IR', '98'),
429
+ array('MOROCCO', 'MA', '212'),
430
+ array('ALGERIA (El Djazaïr)', 'DZ', '213'),
431
+ array('TUNISIA', 'TN', '216'),
432
+ array('LIBYA (Libyan Arab Jamahirya)', 'LY', '218'),
433
+ array('GAMBIA, THE', 'GM', '220'),
434
+ array('SENEGAL', 'SN', '221'),
435
+ array('MAURITANIA', 'MR', '222'),
436
+ array('MALI', 'ML', '223'),
437
+ array('GUINEA', 'GN', '224'),
438
+ array('CÔTE D\'IVOIRE (Ivory Coast)', 'CI', '225'),
439
+ array('BURKINA FASO', 'BF', '226'),
440
+ array('NIGER', 'NE', '227'),
441
+ array('TOGO', 'TG', '228'),
442
+ array('BENIN', 'BJ', '229'),
443
+ array('MAURITIUS', 'MU', '230'),
444
+ array('LIBERIA', 'LR', '231'),
445
+ array('SIERRA LEONE', 'SL', '232'),
446
+ array('GHANA', 'GH', '233'),
447
+ array('NIGERIA', 'NG', '234'),
448
+ array('CHAD (Tchad)', 'TD', '235'),
449
+ array('CENTRAL AFRICAN REPUBLIC', 'CF', '236'),
450
+ array('CAMEROON', 'CM', '237'),
451
+ array('CAPE VERDE', 'CV', '238'),
452
+ array('SAO TOME AND PRINCIPE', 'ST', '239'),
453
+ array('EQUATORIAL GUINEA', 'GQ', '240'),
454
+ array('GABON', 'GA', '241'),
455
+ array('CONGO, REPUBLIC OF', 'CG', '242'),
456
+ array('CONGO, THE DEMOCRATIC REPUBLIC OF THE (formerly Zaire)', 'CD', '243'),
457
+ array('ANGOLA', 'AO', '244'),
458
+ array('GUINEA-BISSAU', 'GW', '245'),
459
+ array('ASCENSION ISLAND', '', '247'),
460
+ array('SEYCHELLES', 'SC', '248'),
461
+ array('SUDAN', 'SD', '249'),
462
+ array('RWANDA', 'RW', '250'),
463
+ array('ETHIOPIA', 'ET', '251'),
464
+ array('SOMALIA', 'SO', '252'),
465
+ array('DJIBOUTI', 'DJ', '253'),
466
+ array('KENYA', 'KE', '254'),
467
+ array('TANZANIA', 'TZ', '255'),
468
+ array('UGANDA', 'UG', '256'),
469
+ array('BURUNDI', 'BI', '257'),
470
+ array('MOZAMBIQUE (Moçambique)', 'MZ', '258'),
471
+ array('ZAMBIA (formerly Northern Rhodesia)', 'ZM', '260'),
472
+ array('MADAGASCAR', 'MG', '261'),
473
+ array('RÉUNION', 'RE', '262'),
474
+ array('ZIMBABWE', 'ZW', '263'),
475
+ array('NAMIBIA', 'NA', '264'),
476
+ array('MALAWI', 'MW', '265'),
477
+ array('LESOTHO', 'LS', '266'),
478
+ array('BOTSWANA', 'BW', '267'),
479
+ array('SWAZILAND', 'SZ', '268'),
480
+ array('COMOROS', 'KM', '269'),
481
+ array('MAYOTTE', 'YT', '269'),
482
+ array('SAINT HELENA', 'SH', '290'),
483
+ array('ERITREA', 'ER', '291'),
484
+ array('ARUBA', 'AW', '297'),
485
+ array('FAEROE ISLANDS', 'FO', '298'),
486
+ array('GREENLAND', 'GL', '299'),
487
+ array('GIBRALTAR', 'GI', '350'),
488
+ array('PORTUGAL', 'PT', '351'),
489
+ array('LUXEMBOURG', 'LU', '352'),
490
+ array('IRELAND', 'IE', '353'),
491
+ array('ICELAND', 'IS', '354'),
492
+ array('ALBANIA', 'AL', '355'),
493
+ array('MALTA', 'MT', '356'),
494
+ array('CYPRUS', 'CY', '357'),
495
+ array('FINLAND', 'FI', '358'),
496
+ array('BULGARIA', 'BG', '359'),
497
+ array('LITHUANIA', 'LT', '370'),
498
+ array('LATVIA', 'LV', '371'),
499
+ array('ESTONIA', 'EE', '372'),
500
+ array('MOLDOVA', 'MD', '373'),
501
+ array('BELARUS', 'BY', '375'),
502
+ array('ANDORRA', 'AD', '376'),
503
+ array('MONACO', 'MC', '377'),
504
+ array('SAN MARINO (Republic of)', 'SM', '378'),
505
+ array('VATICAN CITY (Holy See)', 'VA', '379'),
506
+ array('UKRAINE', 'UA', '380'),
507
+ array('SERBIA (Republic of Serbia)', 'RS', '381'),
508
+ array('MONTENEGRO', 'ME', '382'),
509
+ array('CROATIA (Hrvatska)', 'HR', '385'),
510
+ array('SLOVENIA', 'SI', '386'),
511
+ array('BOSNIA AND HERZEGOVINA', 'BA', '387'),
512
+ array('MACEDONIA (Former Yugoslav Republic of Macedonia)', 'MK', '389'),
513
+ array('CZECH REPUBLIC', 'CZ', '420'),
514
+ array('SLOVAKIA (Slovak Republic)', 'SK', '421'),
515
+ array('LIECHTENSTEIN (Fürstentum Liechtenstein)', 'LI', '423'),
516
+ array('FALKLAND ISLANDS (MALVINAS)', 'FK', '500'),
517
+ array('BELIZE', 'BZ', '501'),
518
+ array('GUATEMALA', 'GT', '502'),
519
+ array('EL SALVADOR', 'SV', '503'),
520
+ array('HONDURAS', 'HN', '504'),
521
+ array('NICARAGUA', 'NI', '505'),
522
+ array('COSTA RICA', 'CR', '506'),
523
+ array('PANAMA', 'PA', '507'),
524
+ array('SAINT PIERRE AND MIQUELON', 'PM', '508'),
525
+ array('HAITI', 'HT', '509'),
526
+ array('GUADELOUPE', 'GP', '590'),
527
+ array('BOLIVIA', 'BO', '591'),
528
+ array('GUYANA', 'GY', '592'),
529
+ array('ECUADOR', 'EC', '593'),
530
+ array('FRENCH GUIANA', 'GF', '594'),
531
+ array('PARAGUAY', 'PY', '595'),
532
+ array('MARTINIQUE', 'MQ', '596'),
533
+ array('SURINAME', 'SR', '597'),
534
+ array('URUGUAY', 'UY', '598'),
535
+ array('BONAIRE, ST. EUSTATIUS, AND SABA', 'BQ', '599'),
536
+ array('CURAÇAO', 'CW', '599'),
537
+ array('NETHERLANDS ANTILLES (obsolete)', 'AN', '599'),
538
+ array('SINT MAARTEN', 'SX', '599'),
539
+ array('TIMOR-LESTE (formerly East Timor)', 'TL', '670'),
540
+ array('BRUNEI DARUSSALAM', 'BN', '673'),
541
+ array('NAURU', 'NR', '674'),
542
+ array('PAPUA NEW GUINEA', 'PG', '675'),
543
+ array('TONGA', 'TO', '676'),
544
+ array('SOLOMON ISLANDS', 'SB', '677'),
545
+ array('VANUATU', 'VU', '678'),
546
+ array('FIJI', 'FJ', '679'),
547
+ array('PALAU', 'PW', '680'),
548
+ array('WALLIS AND FUTUNA', 'WF', '681'),
549
+ array('COOK ISLANDS', 'CK', '682'),
550
+ array('NIUE', 'NU', '683'),
551
+ array('SAMOA (formerly Western Samoa)', 'WS', '685'),
552
+ array('KIRIBATI', 'KI', '686'),
553
+ array('NEW CALEDONIA', 'NC', '687'),
554
+ array('TUVALU', 'TV', '688'),
555
+ array('FRENCH POLYNESIA', 'PF', '689'),
556
+ array('TOKELAU', 'TK', '690'),
557
+ array('MICRONESIA (Federated States of Micronesia)', 'FM', '691'),
558
+ array('MARSHALL ISLANDS', 'MH', '692'),
559
+ array('KOREA (Democratic Peoples Republic of [North] Korea)', 'KP', '850'),
560
+ array('HONG KONG (Special Administrative Region of China)', 'HK', '852'),
561
+ array('MACAO (Special Administrative Region of China)', 'MO', '853'),
562
+ array('CAMBODIA', 'KH', '855'),
563
+ array('LAO PEOPLE\'S DEMOCRATIC REPUBLIC', 'LA', '856'),
564
+ array('BANGLADESH', 'BD', '880'),
565
+ array('TAIWAN (Chinese Taipei for IOC)', 'TW', '886'),
566
+ array('MALDIVES', 'MV', '960'),
567
+ array('LEBANON', 'LB', '961'),
568
+ array('JORDAN (Hashemite Kingdom of Jordan)', 'JO', '962'),
569
+ array('SYRIAN ARAB REPUBLIC', 'SY', '963'),
570
+ array('IRAQ', 'IQ', '964'),
571
+ array('KUWAIT', 'KW', '965'),
572
+ array('SAUDI ARABIA (Kingdom of Saudi Arabia)', 'SA', '966'),
573
+ array('YEMEN (Yemen Arab Republic)', 'YE', '967'),
574
+ array('OMAN', 'OM', '968'),
575
+ array('PALESTINIAN TERRITORIES', 'PS', '970'),
576
+ array('UNITED ARAB EMIRATES', 'AE', '971'),
577
+ array('ISRAEL', 'IL', '972'),
578
+ array('BAHRAIN', 'BH', '973'),
579
+ array('QATAR', 'QA', '974'),
580
+ array('BHUTAN', 'BT', '975'),
581
+ array('MONGOLIA', 'MN', '976'),
582
+ array('NEPAL', 'NP', '977'),
583
+ array('TAJIKISTAN', 'TJ', '992'),
584
+ array('TURKMENISTAN', 'TM', '993'),
585
+ array('AZERBAIJAN', 'AZ', '994'),
586
+ array('KYRGYZSTAN', 'KG', '996'),
587
+ array('UZBEKISTAN', 'UZ', '998'),
588
+ array('BAHAMAS', 'BS', '1242'),
589
+ array('BARBADOS', 'BB', '1246'),
590
+ array('ANGUILLA', 'AI', '1264'),
591
+ array('ANTIGUA AND BARBUDA', 'AG', '1268'),
592
+ array('VIRGIN ISLANDS, BRITISH', 'VG', '1284'),
593
+ array('VIRGIN ISLANDS, U.S.', 'VI', '1340'),
594
+ array('CAYMAN ISLANDS', 'KY', '1345'),
595
+ array('BERMUDA', 'BM', '1441'),
596
+ array('GRENADA', 'GD', '1473'),
597
+ array('TURKS AND CAICOS ISLANDS', 'TC', '1649'),
598
+ array('MONTSERRAT', 'MS', '1664'),
599
+ array('NORTHERN MARIANA ISLANDS', 'MP', '1670'),
600
+ array('GUAM', 'GU', '1671'),
601
+ array('AMERICAN SAMOA', 'AS', '1684'),
602
+ array('SAINT LUCIA', 'LC', '1758'),
603
+ array('DOMINICA', 'DM', '1767'),
604
+ array('SAINT VINCENT AND THE GRENADINES', 'VC', '1784'),
605
+ array('DOMINICAN REPUBLIC', 'DO', '1809'),
606
+ array('TRINIDAD AND TOBAGO', 'TT', '1868'),
607
+ array('SAINT KITTS AND NEVIS', 'KN', '1869'),
608
+ array('JAMAICA', 'JM', '1-876'));
609
+ }
610
+
611
+ }
app/code/community/Licentia/Fidelitas/controllers/Adminhtml/Fidelitas/AccountController.php ADDED
@@ -0,0 +1,290 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Licentia_Fidelitas_Adminhtml_Fidelitas_AccountController extends Mage_Adminhtml_Controller_Action
4
+ {
5
+
6
+ protected function _initAction()
7
+ {
8
+ $this->loadLayout()
9
+ ->_setActiveMenu('fidelitas/account');
10
+ return $this;
11
+ }
12
+
13
+ public function indexAction()
14
+ {
15
+
16
+ $cron = Mage::getModel('cron/schedule')->getCollection()->setOrder('finished_at', 'DESC')->setPageSize(1)->getFirstItem();
17
+ $firstDay = new Zend_Date($cron['finished_at']);
18
+ $lastDay = new Zend_Date(now());
19
+ $diff = $lastDay->sub($firstDay)->toValue('m');
20
+
21
+ if ($diff > 20 || !$cron->getId()) {
22
+ $this->_getSession()->addError($this->__('WARNING: Your cron is not running. Background data sync will not occur.'));
23
+ }
24
+
25
+ $auth = Mage::getModel('fidelitas/egoi')->validateEgoiEnvironment();
26
+ if (!$auth) {
27
+ $this->_redirect('adminhtml/fidelitas_account/new');
28
+ return;
29
+ }
30
+
31
+ Mage::getModel('fidelitas/lists')->getList(true);
32
+
33
+ $this->_initAction();
34
+ $this->_addContent($this->getLayout()->createBlock('fidelitas/adminhtml_account'));
35
+ $this->renderLayout();
36
+ }
37
+
38
+ public function bulkAction()
39
+ {
40
+
41
+ if ($this->getRequest()->getParam('export')) {
42
+
43
+ $subscribers = Mage::getModel('fidelitas/egoi')->addSubscriberBulk(true);
44
+ $file = Mage::getBaseDir('tmp') . '/egoi_export.csv';
45
+ $fp = fopen($file, 'w');
46
+
47
+ foreach ($subscribers as $fields) {
48
+ fputcsv($fp, $fields, ';');
49
+ }
50
+
51
+ fclose($fp);
52
+
53
+ return $this->_prepareDownloadResponse('egoi_export.csv', file_get_contents($file));
54
+
55
+ }
56
+
57
+ $cron = Mage::getModel('cron/schedule');
58
+ $data['status'] = 'pending';
59
+ $data['job_code'] = 'fidelitas_sync_bulk';
60
+ $data['scheduled_at'] = now();
61
+ $data['created_at'] = now();
62
+ $cron->setData($data)->save();
63
+ $this->_getSession()->addSuccess($this->__('Data will be synced next time cron runs'));
64
+
65
+ $this->_redirect('*/*/');
66
+ return;
67
+
68
+ }
69
+
70
+ public function clearAction()
71
+ {
72
+
73
+ $core = Mage::getModel('core/config');
74
+ $core->saveConfig('fidelitas/config/api_key', "0", 'default', 0);
75
+
76
+ $data = array('lists', 'autoresponders', 'events', 'subscribers', 'extra');
77
+
78
+ foreach ($data as $delete) {
79
+ try {
80
+ $model = Mage::getModel('fidelitas/' . $delete);
81
+ if (!$model) {
82
+ continue;
83
+ }
84
+
85
+ $collection = $model->getCollection();
86
+ foreach ($collection as $item) {
87
+ $item->delete();
88
+ }
89
+ } catch (Exception $e) {
90
+
91
+ }
92
+ }
93
+
94
+ Mage::getModel('fidelitas/account')->getAccount()->delete();
95
+
96
+ Mage::getSingleton('admin/session')->getUser()->setData('fidelitasAuth', false);
97
+ Mage::getConfig()->reinit();
98
+ Mage::app()->reinitStores();
99
+
100
+ $this->_redirect('*/*/');
101
+ }
102
+
103
+ public function supportAction()
104
+ {
105
+ $cron = Mage::getModel('cron/schedule')->getCollection()->setOrder('finished_at', 'DESC')->setPageSize(1)->getFirstItem();
106
+
107
+ $firstDay = new Zend_Date($cron['finished_at']);
108
+ $lastDay = new Zend_Date(now());
109
+ $diff = $lastDay->sub($firstDay)->get('m');
110
+
111
+ if ($diff > 20 || !$cron->getId()) {
112
+ $this->_getSession()->addError($this->__('WARNING: Your cron is not running. Background data sync will not occur.'));
113
+ }
114
+
115
+ $info = Mage::getModel('fidelitas/egoi')->getUserData()->getData();
116
+
117
+ Mage::register('current_account', $info[0]);
118
+
119
+ if ($this->getRequest()->isPost()) {
120
+
121
+ $params = array_merge($info[0], $this->getRequest()->getPost());
122
+
123
+ unset($params['form_key']);
124
+ unset($params['usernname']);
125
+ unset($params['credits']);
126
+ unset($params['user_level']);
127
+ unset($params['fax']);
128
+ unset($params['gender']);
129
+ unset($params['api_key']);
130
+
131
+ $email = 'integrations@e-goi.com';
132
+
133
+ $msg = '';
134
+ $params['date'] = now();
135
+
136
+ foreach ($params as $key => $value) {
137
+ $msg .= "$key : $value <br>";
138
+ }
139
+
140
+ $mail = Mage::getModel('core/email');
141
+ $mail->setToName('Support');
142
+ $mail->setToEmail($email);
143
+ $mail->setBody($msg);
144
+ $mail->setSubject('Contacto - Magento Extension');
145
+ $mail->setFromEmail($params['email']);
146
+ $mail->setFromName($params['first_name'] . ' ' . $params['last_name']);
147
+ $mail->setType('html');
148
+
149
+ try {
150
+ $t = $mail->send();
151
+
152
+ if ($t === false) {
153
+ throw new Exception('Unable to send. Please send an email to ' . $email);
154
+ }
155
+
156
+ $this->_getSession()->addSuccess($this->__('Your request has been sent'));
157
+ } catch (Exception $e) {
158
+ Mage::logException($e);
159
+ $this->_getSession()->addError($e->getMessage());
160
+ $this->_redirect('*/*/support');
161
+ }
162
+
163
+ $this->_redirectReferer();
164
+ return;
165
+ }
166
+
167
+ $this->loadLayout();
168
+ $this->_setActiveMenu('fidelitas/account');
169
+
170
+ $this->_addContent($this->getLayout()->createBlock('fidelitas/adminhtml_account_support_edit'))
171
+ ->_addLeft($this->getLayout()->createBlock('fidelitas/adminhtml_account_support_edit_tabs'));
172
+
173
+ $this->renderLayout();
174
+ }
175
+
176
+ public function newAction()
177
+ {
178
+ $this->getRequest()->setParam('op', 'api');
179
+ $op = $this->getRequest()->getParam('op');
180
+
181
+ if ($op == 'api') {
182
+ $this->_getSession()->addNotice($this->__("If you don't have an E-Goi account please %s. If you want to know more about E-Goi %s", '<a target="_blank" href="http://bo.e-goi.com/?action=registo&aff=fadb7a3c20">click here</a>', '<a target="_blank" href="http://www.e-goi.com/index.php?aff=fadb7a3c20">click here</a>'));
183
+ } else {
184
+ $this->_getSession()->addNotice($this->__('If you already have an E-Goi account please %s', '<a href="' . $this->getUrl('*/*/*/op/api') . '">click here</a>'));
185
+ }
186
+
187
+ $model = new Varien_Object();
188
+
189
+ $data = $this->_getSession()->getFormData(true);
190
+ if (!empty($data)) {
191
+ $model->addData($data);
192
+ }
193
+
194
+ Mage::register('current_account', $model);
195
+
196
+ $this->loadLayout();
197
+ $this->_setActiveMenu('fidelitas/account');
198
+
199
+ $this->_addContent($this->getLayout()->createBlock('fidelitas/adminhtml_account_new_edit'))
200
+ ->_addLeft($this->getLayout()->createBlock('fidelitas/adminhtml_account_new_edit_tabs'));
201
+
202
+ $this->renderLayout();
203
+ }
204
+
205
+ public function firstAction()
206
+ {
207
+ $this->_initAction();
208
+ $this->_getSession()->setData('fidelitas_first_run', true);
209
+
210
+ try {
211
+ Mage::getModel('fidelitas/lists')->getList(true);
212
+ Mage::getModel('fidelitas/account')->getAccount();
213
+
214
+ } catch (Exception $e) {
215
+ $this->_getSession()->addError('NO_MORE_LISTS_ALLOWED');
216
+ $this->_redirect('*/*/', array('id' => $this->getRequest()->getParam('id')));
217
+ return;
218
+ }
219
+
220
+ $this->_redirect('*/*/sync');
221
+ return;
222
+ }
223
+
224
+
225
+ public function syncAction()
226
+ {
227
+
228
+ $admin = Mage::getSingleton('admin/session')->getUser();
229
+ $user = $admin->getId();
230
+
231
+ if ($this->_getSession()->getData('fidelitas_first_run') === true) {
232
+ Mage::getModel('fidelitas/account')->getAccount()->setData('cron', 3)->setData('notify_user', $user)->save();
233
+ } else {
234
+ Mage::getModel('fidelitas/account')->getAccount()->setData('cron', 1)->setData('notify_user', $user)->save();
235
+ }
236
+
237
+ $cron = Mage::getModel('cron/schedule')->getCollection()
238
+ ->addFieldToFilter('job_code', 'fidelitas_sync_manually')
239
+ ->addFieldToFilter('status', 'pending');
240
+
241
+ if ($cron->getSize() > 0) {
242
+ $this->_getSession()->addError($this->__('Please wait until previous cron ends'));
243
+ } else {
244
+ $cron = Mage::getModel('cron/schedule');
245
+ $data['status'] = 'pending';
246
+ $data['job_code'] = 'fidelitas_sync_manually';
247
+ $data['scheduled_at'] = now();
248
+ $data['created_at'] = now();
249
+ $cron->setData($data)->save();
250
+ $this->_getSession()->addSuccess($this->__('Data will be synced next time cron runs'));
251
+ }
252
+
253
+ $this->_redirect('*/*/');
254
+ return;
255
+ }
256
+
257
+ public function saveAction()
258
+ {
259
+ if ($this->getRequest()->isPost()) {
260
+ $data = $this->getRequest()->getPost();
261
+
262
+ $model = Mage::getModel('fidelitas/egoi')->setData('api_key', $data['api_key'])->checkLogin($data['api_key']);
263
+ if ($model->getData('user_id')) {
264
+ Mage::getConfig()->saveConfig('fidelitas/config/api_key', $data['api_key']);
265
+ Mage::getConfig()->cleanCache();
266
+
267
+ $lists = Mage::getModel('fidelitas/egoi')->getLists();
268
+ if (count($lists->getData()) == 0) {
269
+ $this->_getSession()->addSuccess($this->__('Success!!! Please wait while we setup the environment. Don\'t close or refresh this page.'));
270
+ } else {
271
+ $this->_getSession()->addSuccess($this->__('Success!!!'));
272
+ }
273
+ $this->_redirect('*/*/first/op/ok');
274
+ return;
275
+ } else {
276
+ $this->_getSession()->addError($this->__('Apikey invalid'));
277
+ $this->_redirect('*/*/new/op/api');
278
+ return;
279
+ }
280
+
281
+ $this->_redirect('*/*/');
282
+ }
283
+ }
284
+
285
+ protected function _isAllowed()
286
+ {
287
+ return Mage::getSingleton('admin/session')->isAllowed('fidelitas/account');
288
+ }
289
+
290
+ }
app/code/community/Licentia/Fidelitas/controllers/Adminhtml/Fidelitas/AutorespondersController.php ADDED
@@ -0,0 +1,208 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Licentia Fidelitas - SMS Notifications for E-Goi
5
+ *
6
+ * NOTICE OF LICENSE
7
+ * This source file is subject to the Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International
8
+ * It is available through the world-wide-web at this URL:
9
+ * http://creativecommons.org/licenses/by-nc-nd/4.0/
10
+ *
11
+ * @title SMS Notifications
12
+ * @category Marketing
13
+ * @package Licentia
14
+ * @author Bento Vilas Boas <bento@licentia.pt>
15
+ * @copyright Copyright (c) 2016 E-Goi - http://e-goi.com
16
+ * @license Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International
17
+ */
18
+ class Licentia_Fidelitas_Adminhtml_Fidelitas_AutorespondersController extends Mage_Adminhtml_Controller_Action
19
+ {
20
+
21
+ protected function _initAction()
22
+ {
23
+ $this->loadLayout()
24
+ ->_setActiveMenu('fidelitas/autoresponders');
25
+
26
+ if (!Mage::getStoreConfig('fidelitas/config/api_key') ||
27
+ !Mage::getStoreConfig('fidelitas/config/sender')
28
+ ) {
29
+ $this->_redirect('*/system_config/edit', array('section' => 'fidelitas'));
30
+ }
31
+
32
+ return $this;
33
+ }
34
+
35
+ public function indexAction()
36
+ {
37
+ $this->_title($this->__('E-Goi'))->_title($this->__('SMS Notifications'));
38
+
39
+ $this->_initAction();
40
+ $this->_addContent($this->getLayout()->createBlock('fidelitas/adminhtml_autoresponders'));
41
+ $this->renderLayout();
42
+ }
43
+
44
+ public function newAction()
45
+ {
46
+ $this->_forward('edit');
47
+ }
48
+
49
+ public function editAction()
50
+ {
51
+ $this->_title($this->__('E-Goi'))->_title($this->__('SMS Notifications'));
52
+
53
+ $id = $this->getRequest()->getParam('id');
54
+ $model = Mage::getModel('fidelitas/autoresponders')->load($id);
55
+ $model->setData('store_ids', explode(',', $model->getStoreIds()));
56
+
57
+ if ($model->getId() || $id == 0) {
58
+
59
+ $data = $this->_getSession()->getFormData();
60
+
61
+ if (!empty($data)) {
62
+ $model->addData($data);
63
+ }
64
+ Mage::register('current_autoresponder', $model);
65
+
66
+
67
+ $this->_title($model->getId() ? $model->getName() : $this->__('New'));
68
+
69
+ $this->loadLayout();
70
+ $this->_setActiveMenu('fidelitas/autoresponders');
71
+
72
+ $this->_addContent($this->getLayout()->createBlock('fidelitas/adminhtml_autoresponders_edit'))
73
+ ->_addLeft($this->getLayout()->createBlock('fidelitas/adminhtml_autoresponders_edit_tabs'));
74
+ $this->renderLayout();
75
+ } else {
76
+ $this->_getSession()->addError($this->__('SMS Notification does not exist'));
77
+ $this->_redirect('*/*/');
78
+ }
79
+ }
80
+
81
+ public function gridAction()
82
+ {
83
+ $this->loadLayout();
84
+ $this->renderLayout();
85
+ }
86
+
87
+ public function saveAction()
88
+ {
89
+
90
+ if ($this->getRequest()->getPost()) {
91
+
92
+ $data = $this->getRequest()->getPost();
93
+ $data = $this->_filterDates($data, array('from_date', 'to_date'));
94
+
95
+ $id = $this->getRequest()->getParam('id');
96
+
97
+ $data['store_ids'] = implode(',', $data['store_ids']);
98
+
99
+ $model = Mage::getModel('fidelitas/autoresponders');
100
+
101
+ try {
102
+ if ($id) {
103
+ $model->setId($id);
104
+ }
105
+
106
+ if (isset($data['product'])) {
107
+ $data['product'] = trim($data['product']);
108
+ }
109
+
110
+ $model->addData($data);
111
+
112
+ if ($model->getData('event') == 'order_product') {
113
+ $product = Mage::getModel('catalog/product')->load($model->getData('product'));
114
+
115
+ if (!$product->getId()) {
116
+ throw new Mage_Core_Exception('Product Not Found');
117
+ }
118
+ }
119
+
120
+ $model->save();
121
+
122
+ $this->_getSession()->setFormData(false);
123
+ $this->_getSession()->addSuccess($this->__('The SMS Notification has been saved.'));
124
+
125
+ // check if 'Save and Continue'
126
+ if ($this->getRequest()->getParam('back')) {
127
+ $this->_redirect('*/*/edit', array('id' => $model->getId()));
128
+ return;
129
+ }
130
+ $this->_redirect('*/*/');
131
+ return;
132
+ } catch (Mage_Core_Exception $e) {
133
+ $this->_getSession()->addError($e->getMessage());
134
+ $this->_getSession()->setFormData($data);
135
+
136
+ if ($this->getRequest()->getParam('id')) {
137
+ $this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id')));
138
+ } else {
139
+ $this->_redirect('*/*/new');
140
+ }
141
+
142
+ return;
143
+ } catch (Exception $e) {
144
+ $this->_getSession()->addError($this->__('An error occurred while saving the SMS Notification data. Please review the log and try again.'));
145
+ Mage::logException($e);
146
+ $this->_getSession()->setFormData($data);
147
+ $this->_redirect('*/*/new', array('id' => $this->getRequest()->getParam('id')));
148
+ return;
149
+ }
150
+ }
151
+ $this->_redirect('*/*/');
152
+ }
153
+
154
+ public function deleteAction()
155
+ {
156
+
157
+
158
+ if ($id = $this->getRequest()->getParam('id')) {
159
+ try {
160
+
161
+ $model = Mage::getModel('fidelitas/autoresponders');
162
+ $model->load($id);
163
+ $model->delete();
164
+
165
+ $this->_getSession()->addSuccess($this->__('The SMS Notification has been deleted.'));
166
+ $this->_redirect('*/*/');
167
+ return;
168
+ } catch (Mage_Core_Exception $e) {
169
+ $this->_getSession()->addError($e->getMessage());
170
+ } catch (Exception $e) {
171
+ $this->_getSession()->addError($this->__('An error occurred while deleting the SMS Notification. Please review the log and try again.'));
172
+ Mage::logException($e);
173
+ $this->_redirect('*/*/edit', array('id' => $id));
174
+ return;
175
+ }
176
+ }
177
+ $this->_getSession()->addError($this->__('Unable to find a SMS Notification to delete.'));
178
+ $this->_redirect('*/*/');
179
+ }
180
+
181
+ public function validateEnvironmentAction()
182
+ {
183
+ $params = $this->getRequest()->getParams();
184
+ $number = $params['number'];
185
+
186
+ if (!Mage::getModel('fidelitas/egoi')->validateNumber($number)) {
187
+ $this->_getSession()->addError($this->__('Please insert a valid Phone Number xxx-xxxxxx'));
188
+ $this->_redirectReferer();
189
+ return;
190
+ }
191
+
192
+ $result = Mage::getModel('fidelitas/egoi')->send($number, 'Test Message from Magento Store');
193
+
194
+ if ($result !== true) {
195
+ $this->_getSession()->addError($this->__('ERROR: Check your settings' . $result));
196
+ } else {
197
+ $this->_getSession()->addSuccess($this->__('Message Sent'));
198
+ }
199
+
200
+ $this->_redirectReferer();
201
+ }
202
+
203
+ protected function _isAllowed()
204
+ {
205
+ return Mage::getSingleton('admin/session')->isAllowed('fidelitas/autoresponders');
206
+ }
207
+
208
+ }
app/code/community/Licentia/Fidelitas/controllers/Adminhtml/Fidelitas/EventsController.php ADDED
@@ -0,0 +1,85 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Licentia Fidelitas - SMS Notifications for E-Goi
5
+ *
6
+ * NOTICE OF LICENSE
7
+ * This source file is subject to the Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International
8
+ * It is available through the world-wide-web at this URL:
9
+ * http://creativecommons.org/licenses/by-nc-nd/4.0/
10
+ *
11
+ * @title SMS Notifications
12
+ * @category Marketing
13
+ * @package Licentia
14
+ * @author Bento Vilas Boas <bento@licentia.pt>
15
+ * @copyright Copyright (c) 2016 E-Goi - http://e-goi.com
16
+ * @license Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International
17
+ */
18
+ class Licentia_Fidelitas_Adminhtml_Fidelitas_EventsController extends Mage_Adminhtml_Controller_Action {
19
+
20
+ protected function _initAction() {
21
+ $this->loadLayout()
22
+ ->_setActiveMenu('fidelitas/events');
23
+
24
+ return $this;
25
+ }
26
+
27
+ public function indexAction() {
28
+
29
+ $this->_title($this->__('E-Goi'))->_title($this->__('Notifications Events'));
30
+
31
+ $this->_initAction();
32
+ $this->_addContent($this->getLayout()->createBlock('fidelitas/adminhtml_events'));
33
+ $this->renderLayout();
34
+ }
35
+
36
+ public function gridAction() {
37
+ $this->loadLayout();
38
+ $this->renderLayout();
39
+ }
40
+
41
+ public function massDeleteAction() {
42
+ $changes = $this->getRequest()->getParam('events');
43
+ if (!is_array($changes)) {
44
+ $this->_getSession()->addError($this->__('Please select event(s).'));
45
+ } else {
46
+ try {
47
+ foreach ($changes as $record) {
48
+ Mage::getModel('fidelitas/events')->load($record)->delete();
49
+ }
50
+ $this->_getSession()->addSuccess($this->__('Total of %d record(s) were deleted.', count($changes)));
51
+ } catch (Exception $e) {
52
+ $this->_getSession()->addError($e->getMessage());
53
+ }
54
+ }
55
+ $this->_redirectReferer();
56
+ }
57
+
58
+ /**
59
+ * Export customer grid to CSV format
60
+ */
61
+ public function exportCsvAction() {
62
+ $fileName = 'events.csv';
63
+ $content = $this->getLayout()->createBlock('fidelitas/adminhtml_events_grid')
64
+ ->getCsvFile();
65
+
66
+ $this->_prepareDownloadResponse($fileName, $content);
67
+ }
68
+
69
+ /**
70
+ * Export customer grid to XML format
71
+ */
72
+ public function exportXmlAction() {
73
+ $fileName = 'events.xml';
74
+ $content = $this->getLayout()->createBlock('fidelitas/adminhtml_events_grid')
75
+ ->getExcelFile();
76
+
77
+ $this->_prepareDownloadResponse($fileName, $content);
78
+ }
79
+
80
+ protected function _isAllowed()
81
+ {
82
+ return Mage::getSingleton('admin/session')->isAllowed('fidelitas/events');
83
+ }
84
+
85
+ }
app/code/community/Licentia/Fidelitas/controllers/Adminhtml/Fidelitas/ListsController.php ADDED
@@ -0,0 +1,121 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Licentia_Fidelitas_Adminhtml_Fidelitas_ListsController extends Mage_Adminhtml_Controller_Action
4
+ {
5
+
6
+ protected function _initAction()
7
+ {
8
+ $this->loadLayout()
9
+ ->_setActiveMenu('fidelitas/lists');
10
+
11
+ $auth = Mage::getModel('fidelitas/egoi')->validateEgoiEnvironment();
12
+ if (!$auth) {
13
+ $this->_redirect('adminhtml/fidelitas_account/new');
14
+ return;
15
+ }
16
+
17
+ return $this;
18
+ }
19
+
20
+ public function indexAction()
21
+ {
22
+
23
+ $this->_title($this->__('E-Goi'))->_title($this->__('Lists'));
24
+ $this->_initAction();
25
+ $this->_addContent($this->getLayout()->createBlock('fidelitas/adminhtml_lists'));
26
+ $this->renderLayout();
27
+ }
28
+
29
+ public function gridAction()
30
+ {
31
+ $this->loadLayout();
32
+ $this->renderLayout();
33
+ }
34
+
35
+ public function editAction()
36
+ {
37
+ $this->_title($this->__('E-Goi'))->_title($this->__('Lists'));
38
+ $id = $this->getRequest()->getParam('id');
39
+ $model = Mage::getModel('fidelitas/lists');
40
+ Mage::register('current_list', $model);
41
+
42
+ $model->load($id);
43
+ if (!$model->getId()) {
44
+ $this->_getSession()->addError($this->__('This list no longer exists.'));
45
+ $this->_redirect('*/*');
46
+ return;
47
+ }
48
+
49
+ if ($model->getId()) {
50
+ $extra = Mage::getModel('fidelitas/extra')->getExtra();
51
+ foreach ($extra as $item) {
52
+ $model->setData($item->getData('extra_code'), $item->getData('attribute_code'));
53
+ }
54
+ }
55
+
56
+ $this->_title($model->getTitle());
57
+
58
+ // set entered data if was error when we do save
59
+ $data = $this->_getSession()->getFormData(true);
60
+ if (!empty($data)) {
61
+ $model->addData($data);
62
+ }
63
+
64
+ $this->_initAction();
65
+
66
+ $this->_addContent($this->getLayout()->createBlock('fidelitas/adminhtml_lists_edit'))
67
+ ->_addLeft($this->getLayout()->createBlock('fidelitas/adminhtml_lists_edit_tabs'));
68
+
69
+ $this->renderLayout();
70
+ }
71
+
72
+
73
+ public function saveAction()
74
+ {
75
+
76
+ if ($data = $this->getRequest()->getPost()) {
77
+
78
+ $model = Mage::getModel('fidelitas/lists')->getList();
79
+
80
+ try {
81
+ $extra = array();
82
+
83
+ foreach ($data as $key => $element) {
84
+ if (stripos($key, 'extra_') !== false) {
85
+ $extra[$key] = $element;
86
+ }
87
+ }
88
+
89
+ $model->addData($data)->save();
90
+
91
+ if ($data['listID']) {
92
+ Mage::getModel('fidelitas/extra')->updateExtra($extra, 1);
93
+ }
94
+
95
+ $this->_getSession()->addSuccess($this->__('List was successfully saved'));
96
+ $this->_getSession()->setFormData(false);
97
+
98
+ // check if 'Save and Continue'
99
+ if ($this->getRequest()->getParam('back')) {
100
+ $this->_redirect('*/*/edit', array('id' => $model->getId()));
101
+ return;
102
+ }
103
+ $this->_redirect('*/*/');
104
+ return;
105
+ } catch (Exception $e) {
106
+ $this->_getSession()->addError($e->getMessage());
107
+ $this->_getSession()->setFormData($data);
108
+ $this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id')));
109
+ return;
110
+ }
111
+ }
112
+ $this->_getSession()->addError($this->__('Unable to find List to save'));
113
+ $this->_redirect('*/*/');
114
+ }
115
+
116
+ protected function _isAllowed()
117
+ {
118
+ return Mage::getSingleton('admin/session')->isAllowed('fidelitas/lists');
119
+ }
120
+
121
+ }
app/code/community/Licentia/Fidelitas/controllers/Adminhtml/Fidelitas/SubscribersController.php ADDED
@@ -0,0 +1,169 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Licentia_Fidelitas_Adminhtml_Fidelitas_SubscribersController extends Mage_Adminhtml_Controller_Action
4
+ {
5
+
6
+ protected function _initAction()
7
+ {
8
+ $this->loadLayout()
9
+ ->_setActiveMenu('fidelitas/subscribers');
10
+
11
+ $auth = Mage::getModel('fidelitas/egoi')->validateEgoiEnvironment();
12
+ if (!$auth) {
13
+ $this->_redirect('adminhtml/fidelitas_account/new');
14
+ return;
15
+ }
16
+ return $this;
17
+ }
18
+
19
+ public function indexAction()
20
+ {
21
+ $this->_initAction();
22
+
23
+ $this->_title($this->__('E-Goi'))->_title($this->__('Subscribers'));
24
+
25
+ $list = Mage::getModel('fidelitas/lists')->getList();
26
+ Mage::register('current_list', $list);
27
+
28
+ $this->_addContent($this->getLayout()->createBlock('fidelitas/adminhtml_subscribers'));
29
+ $this->renderLayout();
30
+ }
31
+
32
+ public function gridAction()
33
+ {
34
+ $list = Mage::getModel('fidelitas/lists')->load($this->getRequest()->getParam('list', 0), 'listnum');
35
+ Mage::register('current_list', $list);
36
+
37
+ $this->loadLayout();
38
+ $this->renderLayout();
39
+ }
40
+
41
+
42
+ public function listAction()
43
+ {
44
+ $this->_title($this->__('E-Goi'))->_title($this->__('Subscribers'));
45
+ $this->_initAction();
46
+ $this->_addContent($this->getLayout()->createBlock('fidelitas/adminhtml_subscribers'));
47
+ $this->renderLayout();
48
+ }
49
+
50
+
51
+ public function editAction()
52
+ {
53
+
54
+ $this->_title($this->__('E-Goi'))->_title($this->__('Subscribers'))->_title($this->__('Edit'));
55
+ $id = $this->getRequest()->getParam('id');
56
+
57
+ $model = Mage::getModel('fidelitas/subscribers')->load($id);
58
+
59
+ $this->_title($model->getId() ? $model->getName() : $this->__('New'));
60
+
61
+ if ($model->getId() || $id == 0) {
62
+ $data = $this->_getSession()->getFormData(true);
63
+ if (!empty($data)) {
64
+ $model->addData($data);
65
+ }
66
+
67
+ $model->setData('list', $model->getData('list') . '-' . $model->getData('store_id'));
68
+ $model->setData('cellphone_prefix', '+' . substr($model->getData('cellphone'), 0, strpos($model->getData('cellphone'), '-')));
69
+ $model->setData('cellphone', substr($model->getData('cellphone'), strpos($model->getData('cellphone'), '-') + 1));
70
+
71
+ Mage::register('current_subscriber', $model);
72
+
73
+ $this->loadLayout();
74
+ $this->_setActiveMenu('fidelitas/subscriber');
75
+
76
+ $this->_addBreadcrumb(Mage::helper('adminhtml')->__('Subscriber Manager'), Mage::helper('adminhtml')->__('Subscriber Manager'));
77
+ $this->_addBreadcrumb(Mage::helper('adminhtml')->__('Subscriber'), Mage::helper('adminhtml')->__('Subscriber'));
78
+
79
+ $this->getLayout()->getBlock('head')->setCanLoadExtJs(true);
80
+
81
+ $this->_addContent($this->getLayout()->createBlock('fidelitas/adminhtml_subscribers_edit'))
82
+ ->_addLeft($this->getLayout()->createBlock('fidelitas/adminhtml_subscribers_edit_tabs'));
83
+
84
+ $this->renderLayout();
85
+ } else {
86
+ $this->_getSession()->addError($this->__('Subscriber does not exist'));
87
+ $this->_redirect('*/*/');
88
+ }
89
+ }
90
+
91
+ public function newAction()
92
+ {
93
+ $this->_forward('edit');
94
+ }
95
+
96
+ public function saveAction()
97
+ {
98
+
99
+ if ($data = $this->getRequest()->getPost()) {
100
+
101
+ if (strlen($data['cellphone']) > 0) {
102
+ $data['cellphone'] = $data['cellphone_prefix'] . '-' . $data['cellphone'];
103
+ }
104
+ $id = $this->getRequest()->getParam('id');
105
+
106
+ $model = Mage::getModel('fidelitas/subscribers');
107
+ $model->setData($data);
108
+
109
+ try {
110
+
111
+ if ($id) {
112
+ $model->setId($id);
113
+ }
114
+
115
+ $model->save();
116
+
117
+ $this->_getSession()->addSuccess($this->__('Subscriber was successfully saved'));
118
+ $this->_getSession()->setFormData(false);
119
+
120
+
121
+ // check if 'Save and Continue'
122
+ if ($this->getRequest()->getParam('back')) {
123
+ $this->_redirect('*/*/edit', array('id' => $model->getId()));
124
+ return;
125
+ }
126
+ $this->_redirect('*/*/index/');
127
+ return;
128
+ } catch (Exception $e) {
129
+ $this->_getSession()->addError($e->getMessage());
130
+ $this->_getSession()->setFormData($data);
131
+ $this->_redirect('*/*/edit/id/' . $id);
132
+ return;
133
+ }
134
+ }
135
+
136
+ $this->_getSession()->addError($this->__('Unable to find subscriber to save'));
137
+ $this->_redirect('*/*/');
138
+ }
139
+
140
+ public function deleteAction()
141
+ {
142
+
143
+ if ($this->getRequest()->getParam('id')) {
144
+
145
+ try {
146
+
147
+ $id = $this->getRequest()->getParam('id');
148
+
149
+ $db = Mage::getModel('fidelitas/subscribers')->load($id);
150
+ $db->delete();
151
+
152
+ $this->_getSession()->addSuccess(Mage::helper('adminhtml')->__('Subscriber was successfully deleted'));
153
+
154
+ $this->_redirect('*/*/');
155
+ } catch (Exception $e) {
156
+ $this->_getSession()->addError($e->getMessage());
157
+ $this->_redirect('*/*/');
158
+ }
159
+ } else {
160
+ $this->_redirect('*/*/');
161
+ }
162
+ }
163
+
164
+ protected function _isAllowed()
165
+ {
166
+ return Mage::getSingleton('admin/session')->isAllowed('fidelitas/subscribers');
167
+ }
168
+
169
+ }
app/code/community/Licentia/Fidelitas/controllers/CallbackController.php ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Licentia_Fidelitas_CallbackController extends Mage_Core_Controller_Front_Action
4
+ {
5
+
6
+ public function indexAction()
7
+ {
8
+
9
+ $remove = $this->getRequest()->getPost('removeSubscriber');
10
+ $add = $this->getRequest()->getPost('addSubscriber');
11
+ $data = isset($remove) ? $remove : $add;
12
+ $data = $this->_object2array(simplexml_load_string($data));
13
+
14
+ if (!is_array($data)) {
15
+ return;
16
+ }
17
+ $data = array_change_key_case($data);
18
+
19
+ foreach ($data as $key => $value) {
20
+ if (is_array($value) && count($value) == 0) {
21
+ unset($data[$key]);
22
+ }
23
+ }
24
+
25
+ $data['inCron'] = true;
26
+ $data['inCallback'] = true;
27
+
28
+ $newletter = Mage::getModel('newsletter/subscriber');
29
+ try {
30
+ if ($add) {
31
+ $newletter->subscribe($data['email']);
32
+ }
33
+
34
+ if ($remove) {
35
+ $newletter->loadByEmail($data['email'])->unsubscribe();
36
+ }
37
+ } catch (Exception $e) {
38
+
39
+ }
40
+
41
+ Mage::log($data, 3, 'egoi-callback.log');
42
+ }
43
+
44
+ protected function _object2array($data)
45
+ {
46
+ if (!is_object($data) && !is_array($data)) {
47
+ return $data;
48
+ }
49
+
50
+ if (is_object($data)) {
51
+ $data = get_object_vars($data);
52
+ }
53
+
54
+ return array_map(array($this, '_object2array'), $data);
55
+ }
56
+
57
+ }
app/code/community/Licentia/Fidelitas/etc/adminhtml.xml ADDED
@@ -0,0 +1,84 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <config>
3
+ <menu>
4
+ <fidelitas>
5
+ <title>E-Goi</title>
6
+ <sort_order>72</sort_order>
7
+ <children>
8
+ <account translate="title" module="fidelitas">
9
+ <title>My Account</title>
10
+ <sort_order>10</sort_order>
11
+ <action>adminhtml/fidelitas_account</action>
12
+ </account>
13
+ <lists translate="title" module="fidelitas">
14
+ <title>List</title>
15
+ <sort_order>10</sort_order>
16
+ <action>adminhtml/fidelitas_lists</action>
17
+ </lists>
18
+ <subscribers>
19
+ <title>Subscribers</title>
20
+ <sort_order>50</sort_order>
21
+ <action>adminhtml/fidelitas_subscribers</action>
22
+ </subscribers>
23
+ <autoresponders>
24
+ <title>SMS Autoresponders</title>
25
+ <sort_order>60</sort_order>
26
+ <action>adminhtml/fidelitas_autoresponders</action>
27
+ </autoresponders>
28
+ <events>
29
+ <title>SMS Autoresponders Log</title>
30
+ <sort_order>70</sort_order>
31
+ <action>adminhtml/fidelitas_events</action>
32
+ </events>
33
+ <support>
34
+ <title>Support</title>
35
+ <sort_order>80</sort_order>
36
+ <action>adminhtml/fidelitas_account/support</action>
37
+ </support>
38
+ <configuration>
39
+ <title>Configuration</title>
40
+ <sort_order>90</sort_order>
41
+ <action>adminhtml/system_config/edit/section/fidelitas</action>
42
+ </configuration>
43
+ </children>
44
+ </fidelitas>
45
+ </menu>
46
+ <acl>
47
+ <resources>
48
+ <admin>
49
+ <children>
50
+ <fidelitas>
51
+ <title>E-goi</title>
52
+ <sort_order>72</sort_order>
53
+ <children>
54
+ <account>
55
+ <title>My Account</title>
56
+ <sort_order>10</sort_order>
57
+ </account>
58
+ <lists>
59
+ <title>List</title>
60
+ <sort_order>10</sort_order>
61
+ </lists>
62
+ <subscribers>
63
+ <title>Subscribers</title>
64
+ <sort_order>50</sort_order>
65
+ </subscribers>
66
+ <autoresponders>
67
+ <title>SMS Autoresponders</title>
68
+ <sort_order>60</sort_order>
69
+ </autoresponders>
70
+ <events>
71
+ <title>SMS Autoresponders Log</title>
72
+ <sort_order>70</sort_order>
73
+ </events>
74
+ <support>
75
+ <title>Support</title>
76
+ <sort_order>80</sort_order>
77
+ </support>
78
+ </children>
79
+ </fidelitas>
80
+ </children>
81
+ </admin>
82
+ </resources>
83
+ </acl>
84
+ </config>
app/code/community/Licentia/Fidelitas/etc/config.xml ADDED
@@ -0,0 +1,241 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?><!--
2
+ -->
3
+ <config>
4
+ <modules>
5
+ <Licentia_Fidelitas>
6
+ <version>2.2.2.0</version>
7
+ </Licentia_Fidelitas>
8
+ </modules>
9
+ <frontend>
10
+ <events>
11
+ <sales_order_place_after>
12
+ <observers>
13
+ <update_subscriber_auto>
14
+ <class>fidelitas/observer</class>
15
+ <method>addToAutoList</method>
16
+ </update_subscriber_auto>
17
+ <fidelitas_update_autoresponders>
18
+ <class>fidelitas/autoresponders</class>
19
+ <method>newOrder</method>
20
+ </fidelitas_update_autoresponders>
21
+ </observers>
22
+ </sales_order_place_after>
23
+ <checkout_onepage_controller_success_action>
24
+ <observers>
25
+ <egoimmerce_order_success>
26
+ <class>fidelitas/observer</class>
27
+ <method>setEgoimmerceOnOrderSuccessPageView</method>
28
+ </egoimmerce_order_success>
29
+ </observers>
30
+ </checkout_onepage_controller_success_action>
31
+ <checkout_multishipping_controller_success_action>
32
+ <observers>
33
+ <egoimmerce_order_success>
34
+ <class>fidelitas/observer</class>
35
+ <method>setEgoimmerceOnOrderSuccessPageView</method>
36
+ </egoimmerce_order_success>
37
+ </observers>
38
+ </checkout_multishipping_controller_success_action>
39
+ </events>
40
+ <routers>
41
+ <fidelitas>
42
+ <use>standard</use>
43
+ <args>
44
+ <module>Licentia_Fidelitas</module>
45
+ <frontName>fidelitas</frontName>
46
+ </args>
47
+ </fidelitas>
48
+ </routers>
49
+ <layout>
50
+ <updates>
51
+ <fidelitas>
52
+ <file>fidelitas.xml</file>
53
+ </fidelitas>
54
+ </updates>
55
+ </layout>
56
+ </frontend>
57
+ <admin>
58
+ <routers>
59
+ <adminhtml>
60
+ <args>
61
+ <modules>
62
+ <fidelitas before="Mage_Adminhtml">Licentia_Fidelitas_Adminhtml</fidelitas>
63
+ </modules>
64
+ </args>
65
+ </adminhtml>
66
+ </routers>
67
+ </admin>
68
+ <adminhtml>
69
+ <events>
70
+ <sales_order_save_commit_after>
71
+ <observers>
72
+ <fidelitas_autoresponders_status>
73
+ <class>fidelitas/autoresponders</class>
74
+ <method>changeStatus</method>
75
+ </fidelitas_autoresponders_status>
76
+ </observers>
77
+ </sales_order_save_commit_after>
78
+ <sales_order_save_commit_after>
79
+ <observers>
80
+ <fidelitas_autoresponders_new_order>
81
+ <class>fidelitas/autoresponders</class>
82
+ <method>newOrder</method>
83
+ </fidelitas_autoresponders_new_order>
84
+ </observers>
85
+ </sales_order_save_commit_after>
86
+ <sales_order_shipment_save_commit_after>
87
+ <observers>
88
+ <fidelitas_autoresponders_shipment>
89
+ <class>fidelitas/autoresponders</class>
90
+ <method>newOrderDocument</method>
91
+ </fidelitas_autoresponders_shipment>
92
+ </observers>
93
+ </sales_order_shipment_save_commit_after>
94
+ <sales_order_invoice_save_commit_after>
95
+ <observers>
96
+ <fidelitas_autoresponders_invoice>
97
+ <class>fidelitas/autoresponders</class>
98
+ <method>newOrderDocument</method>
99
+ </fidelitas_autoresponders_invoice>
100
+ </observers>
101
+ </sales_order_invoice_save_commit_after>
102
+ <sales_order_creditmemo_save_commit_after>
103
+ <observers>
104
+ <fidelitas_autoresponders_creditmemo>
105
+ <class>fidelitas/autoresponders</class>
106
+ <method>newOrderDocument</method>
107
+ </fidelitas_autoresponders_creditmemo>
108
+ </observers>
109
+ </sales_order_creditmemo_save_commit_after>
110
+ </events>
111
+ <acl>
112
+ <resources>
113
+ <admin>
114
+ <children>
115
+ <system>
116
+ <children>
117
+ <config>
118
+ <children>
119
+ <fidelitas>
120
+ <title>E-Goi Section</title>
121
+ </fidelitas>
122
+ </children>
123
+ </config>
124
+ </children>
125
+ </system>
126
+ </children>
127
+ </admin>
128
+ </resources>
129
+ </acl>
130
+ <layout>
131
+ <updates>
132
+ <fidelitas>
133
+ <file>fidelitas.xml</file>
134
+ </fidelitas>
135
+ </updates>
136
+ </layout>
137
+ </adminhtml>
138
+ <global>
139
+ <events>
140
+ <newsletter_subscriber_save_after>
141
+ <observers>
142
+ <fidelitas_update>
143
+ <class>fidelitas/subscribers</class>
144
+ <method>updateFromNewsletterCore</method>
145
+ </fidelitas_update>
146
+ </observers>
147
+ </newsletter_subscriber_save_after>
148
+ </events>
149
+ <models>
150
+ <fidelitas>
151
+ <class>Licentia_Fidelitas_Model</class>
152
+ <resourceModel>fidelitas_mysql4</resourceModel>
153
+ </fidelitas>
154
+ <fidelitas_mysql4>
155
+ <class>Licentia_Fidelitas_Model_Mysql4</class>
156
+ <entities>
157
+ <subscribers>
158
+ <table>fidelitas_subscribers</table>
159
+ </subscribers>
160
+ <lists>
161
+ <table>fidelitas_lists</table>
162
+ </lists>
163
+ <account>
164
+ <table>fidelitas_account</table>
165
+ </account>
166
+ <extra>
167
+ <table>fidelitas_extra</table>
168
+ </extra>
169
+ <autoresponders>
170
+ <table>fidelitas_autoresponders</table>
171
+ </autoresponders>
172
+ <events>
173
+ <table>fidelitas_autoresponders_events</table>
174
+ </events>
175
+ </entities>
176
+ </fidelitas_mysql4>
177
+ </models>
178
+ <resources>
179
+ <fidelitas_setup>
180
+ <setup>
181
+ <module>Licentia_Fidelitas</module>
182
+ <class>Mage_Eav_Model_Entity_Setup</class>
183
+ </setup>
184
+ </fidelitas_setup>
185
+ </resources>
186
+ <blocks>
187
+ <fidelitas>
188
+ <class>Licentia_Fidelitas_Block</class>
189
+ </fidelitas>
190
+ </blocks>
191
+ <helpers>
192
+ <fidelitas>
193
+ <class>Licentia_Fidelitas_Helper</class>
194
+ </fidelitas>
195
+ </helpers>
196
+ </global>
197
+ <crontab>
198
+ <jobs>
199
+ <fidelitas_send_autoresponders>
200
+ <schedule>
201
+ <cron_expr>*/5 * * * *</cron_expr>
202
+ </schedule>
203
+ <run>
204
+ <model>fidelitas/autoresponders::send</model>
205
+ </run>
206
+ </fidelitas_send_autoresponders>
207
+ <fidelitas_sync_manually>
208
+ <schedule>
209
+ <cron_expr>15 0 0 0 *</cron_expr>
210
+ </schedule>
211
+ <run>
212
+ <model>fidelitas/egoi::syncm</model>
213
+ </run>
214
+ </fidelitas_sync_manually>
215
+ <fidelitas_sync_bulk>
216
+ <schedule>
217
+ <cron_expr>15 3 * * 1</cron_expr>
218
+ </schedule>
219
+ <run>
220
+ <model>fidelitas/egoi::addSubscriberBulk</model>
221
+ </run>
222
+ </fidelitas_sync_bulk>
223
+ <fidelitas_sync>
224
+ <schedule>
225
+ <cron_expr>0 3 * * 0</cron_expr>
226
+ </schedule>
227
+ <run>
228
+ <model>fidelitas/egoi::sync</model>
229
+ </run>
230
+ </fidelitas_sync>
231
+ </jobs>
232
+ </crontab>
233
+ <default>
234
+ <fidelitas>
235
+ <config>
236
+ <api_key>0</api_key>
237
+ <cellphone>telephone</cellphone>
238
+ </config>
239
+ </fidelitas>
240
+ </default>
241
+ </config>
app/code/community/Licentia/Fidelitas/etc/system.xml ADDED
@@ -0,0 +1,119 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <sections>
4
+ <fidelitas translate="label" module="fidelitas">
5
+ <label>E-Goi Email Marketing</label>
6
+ <tab>general</tab>
7
+ <frontend_type>text</frontend_type>
8
+ <sort_order>1000</sort_order>
9
+ <show_in_default>1</show_in_default>
10
+ <show_in_website>1</show_in_website>
11
+ <show_in_store>1</show_in_store>
12
+ <groups>
13
+ <config translate="label">
14
+ <label>Configuration</label>
15
+ <frontend_type>text</frontend_type>
16
+ <sort_order>1</sort_order>
17
+ <show_in_default>1</show_in_default>
18
+ <show_in_website>1</show_in_website>
19
+ <show_in_store>0</show_in_store>
20
+ <fields>
21
+ <analytics translate="label">
22
+ <label>E-Goi Track &amp; Engage</label>
23
+ <frontend_type>select</frontend_type>
24
+ <source_model>adminhtml/system_config_source_yesno</source_model>
25
+ <sort_order>10</sort_order>
26
+ <show_in_default>1</show_in_default>
27
+ <show_in_website>1</show_in_website>
28
+ <show_in_store>1</show_in_store>
29
+ </analytics>
30
+ <auto>
31
+ <label>Automatically subscribe customer after order</label>
32
+ <frontend_type>select</frontend_type>
33
+ <source_model>adminhtml/system_config_source_yesno</source_model>
34
+ <sort_order>20</sort_order>
35
+ <show_in_default>1</show_in_default>
36
+ <show_in_website>0</show_in_website>
37
+ <show_in_store>0</show_in_store>
38
+ <required>1</required>
39
+ </auto>
40
+ <cellphone>
41
+ <label>Cellphone Attribute Code</label>
42
+ <frontend_type>select</frontend_type>
43
+ <source_model>fidelitas/source_addressattributes</source_model>
44
+ <sort_order>30</sort_order>
45
+ <show_in_default>1</show_in_default>
46
+ <show_in_website>0</show_in_website>
47
+ <show_in_store>0</show_in_store>
48
+ <required>1</required>
49
+ <comment>Assing the Address Attribute Code to customer's cellphone. Usually "telephone" or "mobile"</comment>
50
+ </cellphone>
51
+ <sender>
52
+ <label>SMS Sender (For autoresponders)</label>
53
+ <frontend_type>select</frontend_type>
54
+ <source_model>fidelitas/source_sender</source_model>
55
+ <sort_order>40</sort_order>
56
+ <comment>Only validated SMS senders are listed here. To add one, please go to your e-goi.com account</comment>
57
+ <sort_order>20</sort_order>
58
+ <show_in_default>1</show_in_default>
59
+ <show_in_website>1</show_in_website>
60
+ <show_in_store>1</show_in_store>
61
+ </sender>
62
+ <method>
63
+ <label>Send SMS using</label>
64
+ <frontend_type>select</frontend_type>
65
+ <source_model>fidelitas/source_method</source_model>
66
+ <sort_order>50</sort_order>
67
+ <comment>If your plan includes SMS's, you should choose the Campaign option</comment>
68
+ <sort_order>20</sort_order>
69
+ <show_in_default>1</show_in_default>
70
+ <show_in_website>1</show_in_website>
71
+ <show_in_store>1</show_in_store>
72
+ </method>
73
+ <merge>
74
+ <label>Merge Subscribers</label>
75
+ <frontend_type>select</frontend_type>
76
+ <source_model>adminhtml/system_config_source_yesno</source_model>
77
+ <sort_order>150</sort_order>
78
+ <comment>Id we should sync back subscribers from E-Goi (only affetcs cron and not callbacks)</comment>
79
+ <sort_order>20</sort_order>
80
+ <show_in_default>1</show_in_default>
81
+ <show_in_website>0</show_in_website>
82
+ <show_in_store>0</show_in_store>
83
+ </merge>
84
+ </fields>
85
+ </config>
86
+ <test translate="label">
87
+ <label>Test SMS Configuration</label>
88
+ <frontend_type>text</frontend_type>
89
+ <sort_order>100</sort_order>
90
+ <show_in_default>1</show_in_default>
91
+ <show_in_website>1</show_in_website>
92
+ <show_in_store>1</show_in_store>
93
+ <expanded>1</expanded>
94
+ <fields>
95
+ <number>
96
+ <label>Mobile Number</label>
97
+ <frontend_type>text</frontend_type>
98
+ <comment>Format: CC-XXXXXXX. Eg: 351-908934778. The above phone number will receive a test Message</comment>
99
+ <sort_order>10</sort_order>
100
+ <show_in_default>1</show_in_default>
101
+ <show_in_website>1</show_in_website>
102
+ <show_in_store>1</show_in_store>
103
+ </number>
104
+ <test translate="label">
105
+ <label></label>
106
+ <frontend_type>label</frontend_type>
107
+ <frontend_model>fidelitas/adminhtml_system_config_form_field_test</frontend_model>
108
+ <comment>Please remember to save any changes prior to testing</comment>
109
+ <sort_order>13</sort_order>
110
+ <show_in_default>1</show_in_default>
111
+ <show_in_website>1</show_in_website>
112
+ <show_in_store>1</show_in_store>
113
+ </test>
114
+ </fields>
115
+ </test>
116
+ </groups>
117
+ </fidelitas>
118
+ </sections>
119
+ </config>
app/code/community/Licentia/Fidelitas/sql/fidelitas_setup/mysql4-install-2.0.0.0.php ADDED
@@ -0,0 +1,157 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+
4
+ $installer = $this;
5
+ $installer->startSetup();
6
+
7
+ $installer->run("DROP TABLE IF EXISTS `{$this->getTable('fidelitas_abandoned')}`;");
8
+ $installer->run("DROP TABLE IF EXISTS `{$this->getTable('fidelitas_abandoned_log')}`;");
9
+ $installer->run("DROP TABLE IF EXISTS `{$this->getTable('fidelitas_account')}`;");
10
+ $installer->run("DROP TABLE IF EXISTS `{$this->getTable('fidelitas_autoresponders')}`;");
11
+ $installer->run("DROP TABLE IF EXISTS `{$this->getTable('fidelitas_autoresponders_events')}`;");
12
+ $installer->run("DROP TABLE IF EXISTS `{$this->getTable('fidelitas_campaigns')}`;");
13
+ $installer->run("DROP TABLE IF EXISTS `{$this->getTable('fidelitas_campaigns_followup')}`;");
14
+ $installer->run("DROP TABLE IF EXISTS `{$this->getTable('fidelitas_campaigns_links')}`;");
15
+ $installer->run("DROP TABLE IF EXISTS `{$this->getTable('fidelitas_campaigns_splits')}`;");
16
+ $installer->run("DROP TABLE IF EXISTS `{$this->getTable('fidelitas_conversions')}`;");
17
+ $installer->run("DROP TABLE IF EXISTS `{$this->getTable('fidelitas_conversions_segments')}`;");
18
+ $installer->run("DROP TABLE IF EXISTS `{$this->getTable('fidelitas_coupons')}`;");
19
+ $installer->run("DROP TABLE IF EXISTS `{$this->getTable('fidelitas_cron_report')}`;");
20
+ $installer->run("DROP TABLE IF EXISTS `{$this->getTable('fidelitas_extra')}`;");
21
+ $installer->run("DROP TABLE IF EXISTS `{$this->getTable('fidelitas_groups')}`;");
22
+ $installer->run("DROP TABLE IF EXISTS `{$this->getTable('fidelitas_history')}`;");
23
+ $installer->run("DROP TABLE IF EXISTS `{$this->getTable('fidelitas_lists')}`;");
24
+ $installer->run("DROP TABLE IF EXISTS `{$this->getTable('fidelitas_lists_stores')}`;");
25
+ $installer->run("DROP TABLE IF EXISTS `{$this->getTable('fidelitas_reports')}`;");
26
+ $installer->run("DROP TABLE IF EXISTS `{$this->getTable('fidelitas_segments_evolutions')}`;");
27
+ $installer->run("DROP TABLE IF EXISTS `{$this->getTable('fidelitas_segments_evolutions_summary')}`;");
28
+ $installer->run("DROP TABLE IF EXISTS `{$this->getTable('fidelitas_segments_subscribers')}`;");
29
+ $installer->run("DROP TABLE IF EXISTS `{$this->getTable('fidelitas_segments_subscribers_list')}`;");
30
+ $installer->run("DROP TABLE IF EXISTS `{$this->getTable('fidelitas_senders')}`;");
31
+ $installer->run("DROP TABLE IF EXISTS `{$this->getTable('fidelitas_stats')}`;");
32
+ $installer->run("DROP TABLE IF EXISTS `{$this->getTable('fidelitas_subscribers')}`;");
33
+ $installer->run("DROP TABLE IF EXISTS `{$this->getTable('fidelitas_templates')}`;");
34
+ $installer->run("DROP TABLE IF EXISTS `{$this->getTable('fidelitas_urls')}`;");
35
+ $installer->run("DROP TABLE IF EXISTS `{$this->getTable('fidelitas_widget_cache')}`;");
36
+
37
+
38
+ $installer->run("
39
+ -- ----------------------------
40
+ -- Table structure for `fidelitas_account`
41
+ -- ----------------------------
42
+ DROP TABLE IF EXISTS `{$this->getTable('fidelitas_account')}`;
43
+ CREATE TABLE `{$this->getTable('fidelitas_account')}`(
44
+ `account_id` int(11) NOT NULL AUTO_INCREMENT,
45
+ `cliente_id` int(11) NOT NULL DEFAULT '0',
46
+ `company_name` varchar(255) DEFAULT NULL,
47
+ `company_legal_name` varchar(255) DEFAULT NULL,
48
+ `company_type` varchar(255) DEFAULT NULL,
49
+ `business_activity_code` varchar(255) DEFAULT NULL,
50
+ `date_registration` date DEFAULT NULL,
51
+ `country` varchar(255) DEFAULT NULL,
52
+ `state` varchar(255) DEFAULT NULL,
53
+ `city` varchar(255) DEFAULT NULL,
54
+ `address` varchar(255) DEFAULT NULL,
55
+ `website` varchar(255) DEFAULT NULL,
56
+ `signup_date` date DEFAULT NULL,
57
+ `credits` float(8,2) DEFAULT NULL,
58
+ `cron` smallint(2) DEFAULT NULL,
59
+ `notify_user` smallint(2) DEFAULT NULL,
60
+ PRIMARY KEY (`account_id`)
61
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='E-Goi - Account Info';
62
+ ");
63
+
64
+
65
+ $installer->run("
66
+ -- ----------------------------
67
+ -- Table structure for `fidelitas_extra`
68
+ -- ----------------------------
69
+ DROP TABLE IF EXISTS `{$this->getTable('fidelitas_extra')}`;
70
+ CREATE TABLE `{$this->getTable('fidelitas_extra')}` (
71
+ `record_id` int(11) NOT NULL AUTO_INCREMENT,
72
+ `extra_code` varchar(50) DEFAULT NULL,
73
+ `attribute_code` varchar(50) DEFAULT NULL,
74
+ `system` smallint(11) DEFAULT NULL,
75
+ PRIMARY KEY (`record_id`)
76
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Fidelitas - List Extra Fields';
77
+
78
+ ");
79
+
80
+
81
+ $installer->run("
82
+ -- ----------------------------
83
+ -- Table structure for `fidelitas_lists`
84
+ -- ----------------------------
85
+ DROP TABLE IF EXISTS `{$this->getTable('fidelitas_lists')}`;
86
+ CREATE TABLE `{$this->getTable('fidelitas_lists')}`(
87
+ `list_id` int(11) NOT NULL AUTO_INCREMENT,
88
+ `listnum` int(12) DEFAULT NULL,
89
+ `title` varchar(255) DEFAULT NULL,
90
+ `internal_name` varchar(255) DEFAULT NULL,
91
+ `subs_activos` int(11) DEFAULT NULL,
92
+ `subs_total` int(11) DEFAULT NULL,
93
+ `canal_email` enum('0','1') NOT NULL DEFAULT '1',
94
+ `canal_sms` enum('0','1') NOT NULL DEFAULT '0',
95
+ `is_active` enum('0','1') DEFAULT '1',
96
+ PRIMARY KEY (`list_id`),
97
+ UNIQUE KEY `unq_listnum` (`listnum`),
98
+ KEY `listnum` (`listnum`)
99
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='E-Goi - List of Lists';
100
+
101
+ ");
102
+
103
+
104
+ $installer->run("
105
+ -- ----------------------------
106
+ -- Table structure for `fidelitas_subscribers`
107
+ -- ----------------------------
108
+ DROP TABLE IF EXISTS `{$this->getTable('fidelitas_subscribers')}`;
109
+ CREATE TABLE `{$this->getTable('fidelitas_subscribers')}`(
110
+ `subscriber_id` int(11) NOT NULL AUTO_INCREMENT,
111
+ `customer_id` int(11) DEFAULT NULL,
112
+ `language` varchar(255) DEFAULT NULL,
113
+ `store_id` varchar(255) DEFAULT NULL,
114
+ `uid` varchar(255) DEFAULT NULL,
115
+ `add_date` date DEFAULT NULL,
116
+ `subscription_method` varchar(255) DEFAULT NULL,
117
+ `list` int(11) DEFAULT NULL,
118
+ `first_name` varchar(255) DEFAULT NULL,
119
+ `last_name` varchar(255) DEFAULT NULL,
120
+ `email` varchar(255) DEFAULT NULL,
121
+ `cellphone` varchar(255) DEFAULT NULL,
122
+ `telephone` varchar(255) DEFAULT NULL,
123
+ `fax` varchar(255) DEFAULT NULL,
124
+ `tax_id` varchar(255) DEFAULT NULL,
125
+ `address` varchar(255) DEFAULT NULL,
126
+ `zip_code` varchar(255) DEFAULT NULL,
127
+ `city` varchar(255) DEFAULT NULL,
128
+ `district` varchar(255) DEFAULT NULL,
129
+ `country` varchar(255) DEFAULT NULL,
130
+ `age` int(11) DEFAULT NULL,
131
+ `gender` varchar(255) DEFAULT NULL,
132
+ `id_card` varchar(255) DEFAULT NULL,
133
+ `company` varchar(255) DEFAULT NULL,
134
+ `birth_date` varchar(255) DEFAULT NULL,
135
+ `status` varchar(255) DEFAULT NULL,
136
+ `bounces` int(11) DEFAULT NULL,
137
+ `email_sent` int(11) DEFAULT NULL,
138
+ `email_views` int(11) DEFAULT NULL,
139
+ `referrals` int(11) DEFAULT NULL,
140
+ `referrals_converted` int(11) DEFAULT NULL,
141
+ `clicks` int(11) DEFAULT NULL,
142
+ `sms_sent` int(11) DEFAULT NULL,
143
+ `sms_delivered` int(11) DEFAULT NULL,
144
+ `remove_method` varchar(255) DEFAULT NULL,
145
+ `remove_date` datetime DEFAULT NULL,
146
+ PRIMARY KEY (`subscriber_id`),
147
+ UNIQUE KEY `unq_uid_list` (`uid`,`list`),
148
+ KEY `email_i` (`email`),
149
+ KEY `list_i` (`list`),
150
+ KEY `uid_i` (`uid`),
151
+ KEY `customer_i` (`customer_id`),
152
+ KEY `status` (`status`)
153
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='E-Goi - List of subscribers';
154
+
155
+ ");
156
+
157
+ $installer->endSetup();
app/code/community/Licentia/Fidelitas/sql/fidelitas_setup/mysql4-upgrade-2.0.0.5-2.1.0.0.php ADDED
@@ -0,0 +1,70 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Licentia Fidelitas - SMS Notifications for E-Goi
5
+ *
6
+ * NOTICE OF LICENSE
7
+ * This source file is subject to the Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International
8
+ * It is available through the world-wide-web at this URL:
9
+ * http://creativecommons.org/licenses/by-nc-nd/4.0/
10
+ *
11
+ * @title SMS Notifications
12
+ * @category Marketing
13
+ * @package Licentia
14
+ * @author Bento Vilas Boas <bento@licentia.pt>
15
+ * @Copyright (c) 2016 E-Goi - http://e-goi.com
16
+ * @license Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International
17
+ */
18
+ $installer = $this;
19
+ $installer->startSetup();
20
+
21
+ $installer->run("
22
+ -- ----------------------------
23
+ -- Table structure for `fidelitas_autoresponders`
24
+ -- ----------------------------
25
+ DROP TABLE IF EXISTS `{$this->getTable('fidelitas_autoresponders')}`;
26
+ CREATE TABLE `{$this->getTable('fidelitas_autoresponders')}` (
27
+ `autoresponder_id` int(11) NOT NULL AUTO_INCREMENT,
28
+ `store_ids` varchar(255) DEFAULT NULL,
29
+ `event` varchar(255) DEFAULT NULL,
30
+ `name` varchar(255) DEFAULT NULL,
31
+ `send_moment` enum('occurs','after') NOT NULL DEFAULT 'occurs',
32
+ `active` enum('0','1') NOT NULL DEFAULT '0',
33
+ `after_days` smallint(2) DEFAULT NULL,
34
+ `after_hours` smallint(1) DEFAULT NULL,
35
+ `product` varchar(255) DEFAULT NULL,
36
+ `message` text,
37
+ `number_subscribers` int(11) DEFAULT NULL,
38
+ `send_once` enum('0','1') DEFAULT '1',
39
+ `search` varchar(255) DEFAULT NULL,
40
+ `search_option` enum('eq','like') DEFAULT 'eq',
41
+ `order_status` varchar(255) DEFAULT NULL,
42
+ `from_date` date DEFAULT NULL,
43
+ `to_date` date DEFAULT NULL,
44
+ PRIMARY KEY (`autoresponder_id`),
45
+ KEY `event` (`event`)
46
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='E-Goi - List of Autoresponders'");
47
+
48
+
49
+ $installer->run("
50
+ -- ----------------------------
51
+ -- Table structure for `fidelitas_autoresponders_events`
52
+ -- ----------------------------
53
+ DROP TABLE IF EXISTS `{$this->getTable('fidelitas_autoresponders_events')}`;
54
+ CREATE TABLE `{$this->getTable('fidelitas_autoresponders_events')}` (
55
+ `event_id` int(11) NOT NULL AUTO_INCREMENT,
56
+ `event` varchar(255) DEFAULT NULL,
57
+ `autoresponder_id` int(11) DEFAULT NULL,
58
+ `customer_id` int(10) DEFAULT NULL,
59
+ `customer_name` varchar(255) DEFAULT NULL,
60
+ `customer_email` varchar(255) DEFAULT NULL,
61
+ `cellphone` varchar(255) DEFAULT NULL,
62
+ `send_at` datetime DEFAULT NULL,
63
+ `created_at` datetime DEFAULT NULL,
64
+ `sent` enum('0','1') NOT NULL DEFAULT '0',
65
+ `sent_at` datetime DEFAULT NULL,
66
+ PRIMARY KEY (`event_id`),
67
+ KEY `autoresponder_id` (`autoresponder_id`)
68
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='E-Goi - List of events in queue for autoresponder'");
69
+
70
+ $installer->endSetup();
app/code/community/Licentia/Fidelitas/sql/fidelitas_setup/mysql4-upgrade-2.1.0.4-2.1.0.5.php ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Licentia Fidelitas - SMS Notifications for E-Goi
5
+ *
6
+ * NOTICE OF LICENSE
7
+ * This source file is subject to the Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International
8
+ * It is available through the world-wide-web at this URL:
9
+ * http://creativecommons.org/licenses/by-nc-nd/4.0/
10
+ *
11
+ * @title SMS Notifications
12
+ * @category Marketing
13
+ * @package Licentia
14
+ * @author Bento Vilas Boas <bento@licentia.pt>
15
+ * @Copyright (c) 2016 E-Goi - http://e-goi.com
16
+ * @license Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International
17
+ */
18
+ $installer = $this;
19
+ $installer->startSetup();
20
+
21
+ $installer->run("ALTER TABLE `{$this->getTable('fidelitas_autoresponders_events')}` ADD COLUMN `data_object_id` int");
22
+ $installer->run("ALTER TABLE `{$this->getTable('fidelitas_autoresponders_events')}` ADD COLUMN `message` VARCHAR (100)");
23
+
24
+ $installer->endSetup();
app/code/community/Licentia/Fidelitas/sql/fidelitas_setup/mysql4-upgrade-2.2.0.4-2.2.0.5.php ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Licentia Fidelitas - SMS Notifications for E-Goi
5
+ *
6
+ * NOTICE OF LICENSE
7
+ * This source file is subject to the Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International
8
+ * It is available through the world-wide-web at this URL:
9
+ * http://creativecommons.org/licenses/by-nc-nd/4.0/
10
+ *
11
+ * @title SMS Notifications
12
+ * @category Marketing
13
+ * @package Licentia
14
+ * @author Bento Vilas Boas <bento@licentia.pt>
15
+ * @Copyright (c) 2016 E-Goi - http://e-goi.com
16
+ * @license Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International
17
+ */
18
+ $installer = $this;
19
+ $installer->startSetup();
20
+
21
+ $installer->run("DELETE FROM `{$this->getTable('fidelitas_subscribers')}` WHERE email IS NULL OR LENGTH(email)<5");
22
+ $installer->run("DELETE FROM `{$this->getTable('newsletter_subscriber')}` WHERE subscriber_email IS NULL OR LENGTH(subscriber_email)<5");
23
+
24
+ $installer->endSetup();
app/design/adminhtml/default/default/layout/fidelitas.xml ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <layout>
3
+ <adminhtml_fidelitas_subscribers_grid>
4
+ <block type="core/text_list" name="root" output="toHtml">
5
+ <block type="fidelitas/adminhtml_subscribers_grid" name="admin.subscribers.grid"/>
6
+ </block>
7
+ </adminhtml_fidelitas_subscribers_grid>
8
+ </layout>
app/design/adminhtml/default/default/template/fidelitas/account/account.phtml ADDED
@@ -0,0 +1,128 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ $data = $this->getCompany();
3
+ ?>
4
+ <style type="text/css">
5
+ th span {
6
+ padding: 4px;
7
+ }
8
+
9
+ .grid td {
10
+ padding: 10px;
11
+ }
12
+ </style>
13
+ <div class="content-header">
14
+ <h3 class="icon-head head-customer"><?php echo $this->getTitle() ?></h3>
15
+ </div>
16
+ <div class="grid" style="width:40%; float:left;">
17
+ <table cellspacing="0" id="storeGrid_table" class="data">
18
+ <thead>
19
+ <tr class="headings">
20
+ <th class=" no-link last" colspan="2"><span class="nobr"><?php echo $this->__('Account Data') ?></span></th>
21
+ </tr>
22
+ </thead>
23
+ <tbody id="">
24
+ <?php
25
+ $i = 0;
26
+ foreach ($data->getData() as $key => $info):
27
+
28
+ if ($key == 'credits' || $key == 'account_id' || $key == 'cron' || $key == 'notify_user') {
29
+ continue;
30
+ }
31
+ ?>
32
+ <tr class="<?php echo $i % 2 ? 'even' : '' ?>">
33
+ <td class="last"><?php echo ucwords(str_replace('_', ' ', $key)); ?></td>
34
+ <td class="last"><?php echo $info; ?></td>
35
+ </tr>
36
+ <?php $i++; ?>
37
+ <?php endforeach; ?>
38
+ </tbody>
39
+ </table>
40
+ </div>
41
+
42
+
43
+ <div class="grid " style="width:23%; margin-left: 1%; float: right">
44
+
45
+
46
+ <table cellspacing="0" style="margin-top:10px;" id="storeGrid_table" class="data">
47
+ <tbody>
48
+ <thead>
49
+ <tr class="headings">
50
+ <th class=" no-link last" colspan="2"><span class="nobr"><?php echo $this->__('Extension Version') ?></span>
51
+ </th>
52
+ </tr>
53
+ </thead>
54
+ <tr>
55
+ <td><?php echo (string)Mage::getConfig()->getNode()->modules->Licentia_Fidelitas->version; ?></td>
56
+ </tr>
57
+ </tbody>
58
+ </table>
59
+
60
+
61
+ <table cellspacing="0" style="margin-top:10px;" id="storeGrid_table" class="data">
62
+ <tbody>
63
+ <thead>
64
+ <tr class="headings">
65
+ <th class=" no-link last" colspan="2"><span class="nobr"><?php echo $this->__('Extension Manual') ?></span>
66
+ </th>
67
+ </tr>
68
+ </thead>
69
+ <tr>
70
+ <td style="background-color:#556B2F; color: white; "><?php echo $this->__('Click to download the extension manual [<a target="_blank" href="%s">EN</a>] / [<a target="_blank" href="%s">PT</a>]', 'http://licentia.pt/download/Fidelitas_Manual-EN.pdf', 'http://licentia.pt/download/Fidelitas_Manual-PT.pdf') ?></td>
71
+ </tr>
72
+ </tbody>
73
+ </table>
74
+
75
+
76
+ <table cellspacing="0" style="margin-top:10px;" id="storeGrid_table" class="data">
77
+ <tbody>
78
+ <thead>
79
+ <tr class="headings">
80
+ <th class=" no-link last" colspan="2"><span class="nobr"><?php echo $this->__('Push Magento Subscribers') ?></span>
81
+ </th>
82
+ </tr>
83
+ </thead>
84
+ <tr class="even">
85
+ <td>
86
+ <a href="<?php echo $this->getUrl('*/*/bulk',array('export'=>1)); ?>"><?php echo $this->__('Click here to EXPORT Magento Subscribers.') ?> </a><br><em><?php echo $this->__('This process may take a few minutes') ?></em>
87
+ </td>
88
+ </tr> <tr class="odd">
89
+ <td>
90
+ <a href="<?php echo $this->getUrl('*/*/bulk'); ?>"><?php echo $this->__('Click here to SYNC Magento Subscribers.') ?> </a><br><em><?php echo $this->__('This process may take a few minutes') ?></em>
91
+ </td>
92
+ </tr>
93
+ </tbody>
94
+ </table>
95
+
96
+
97
+ <table cellspacing="0" style="margin-top:10px;" id="storeGrid_table" class="data">
98
+ <tbody>
99
+ <thead>
100
+ <tr class="headings">
101
+ <th class=" no-link last" colspan="2"><span class="nobr"><?php echo $this->__('Sync Data') ?></span></th>
102
+ </tr>
103
+ </thead>
104
+ <tr class="even">
105
+ <td>
106
+ <a href="<?php echo $this->getUrl('*/*/sync'); ?>"><?php echo $this->__('Click here to sync Mage/E-Goi data now.') ?> </a><br><em><?php echo $this->__('This process will run in background and may take a few minutes') ?></em>
107
+ </td>
108
+ </tr>
109
+ </tbody>
110
+ </table>
111
+
112
+
113
+ <table cellspacing="0" style="margin-top:10px;" id="storeGrid_table" class="data">
114
+ <tbody>
115
+ <thead>
116
+ <tr class="headings">
117
+ <th class=" no-link last" colspan="2"><span class="nobr"><?php echo $this->__('Clear Data') ?></span></th>
118
+ </tr>
119
+ </thead>
120
+ <tr class="even">
121
+ <td>
122
+ <a onclick="if(!confirm('Are you sure?')){return false;}"
123
+ href="<?php echo $this->getUrl('*/*/clear'); ?>"><?php echo $this->__('Click here to clear all your data and disconnect from E-Goi') ?>
124
+ </td>
125
+ </tr>
126
+ </tbody>
127
+ </table>
128
+ </div>
app/design/adminhtml/default/default/template/fidelitas/account/new.phtml ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <div id="messages">
2
+ <ul class="messages">
3
+ <li class="notice-msg">
4
+ <ul>
5
+ <li>
6
+ <span><?php echo Mage::helper('fidelitas')->__('If you already have an E-Goi account please ') ?></span>
7
+ </li>
8
+ </ul>
9
+ </li>
10
+ </ul>
11
+ </div>
12
+
13
+ <form action="<?php echo $this->getLoadUrl() ?>" method="post" id="email_template_load_form">
14
+ <?php echo $this->getBlockHtml('formkey') ?>
15
+ <div class="entry-edit">
16
+ <div class="entry-edit-head">
17
+ <h4 class="icon-head head-edit-form fieldset-legend">
18
+ <?php echo Mage::helper('fidelitas')->__('Existing E-Goi Customers') ?>
19
+ </h4>
20
+ <div class="form-buttons"></div>
21
+ </div>
22
+ <div class="fieldset">
23
+ <table class="form-list" cellspacing="0">
24
+ <tbody>
25
+ <tr>
26
+ <td class="label"><label for="telephone">API Key
27
+ <span class="required">*</span></label></td>
28
+ <td class="value">
29
+ <input type="text" class="input-text" value="" name="telephone" id="telephone">
30
+ <p id="note_telephone" class="note"><span>To get your API Key, login in your E-Goi.com panel and under "LISTS/OPTIONS/API" you will find your "API access key" </span>
31
+ </p>
32
+ </td>
33
+ </tr>
34
+ </tbody>
35
+ </table>
36
+ </div>
37
+ </div>
38
+ </form>
39
+ <?php
40
+ echo $this->getFormHtml();
app/design/frontend/base/default/layout/fidelitas.xml ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <layout version="0.1.0">
3
+ <default>
4
+ <reference name="before_body_end">
5
+ <block type="fidelitas/egoimmerce" name="egoimmerce" as="egoimmerce" template="fidelitas/egoimmerce.phtml"/>
6
+ </reference>
7
+ </default>
8
+ </layout>
app/design/frontend/base/default/template/fidelitas/egoimmerce.phtml ADDED
@@ -0,0 +1,80 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ $installPath = 'egoimmerce.e-goi.com';
4
+
5
+ $account = Mage::getModel('fidelitas/account')->getAccount();
6
+
7
+ if ($account->getClienteId()) {
8
+ if (strpos($installPath, "https://") !== false) {
9
+ $secureinstallPath = $installPath;
10
+ $installPath = str_replace("https://", "http://", $installPath);
11
+ }
12
+ if (strpos($installPath, "http://") === false) {
13
+ $installPath = "http://" . $installPath;
14
+ }
15
+
16
+ $secureinstallPath = str_replace("http://", "https://", $installPath);
17
+ $last = $installPath[strlen($installPath) - 1];
18
+
19
+ if ($last != "/") {
20
+ $installPath .= "/";
21
+ $secureinstallPath .= "/";
22
+ }
23
+ $_customerId = Mage::getSingleton('customer/session')->getCustomer()->getId();
24
+ $listId = '';
25
+ $subscriberId = '';
26
+ if ($_customerId) {
27
+ $sub = Mage::helper('fidelitas')->isCustomerSubscribed($_customerId);
28
+ if ($sub) {
29
+ $listId = $sub->getList();
30
+ $subscriberId = $sub->getUid();
31
+ }
32
+ }
33
+
34
+ //0 Search Results
35
+ if ($this->getRequest()->getControllerName() == 'result') {
36
+ $nores = Mage::helper('catalogsearch')->getEngine()->getResultCollection()->addSearchFilter(Mage::helper('catalogsearch')->getQuery()->getQueryText())->getSize();
37
+ }
38
+ ?>
39
+
40
+ <!-- EGOIMMERCE TRACKING CODE -->
41
+ <script type="text/javascript">
42
+ //<![CDATA[
43
+ var _egoiaq = _egoiaq || [];
44
+ (function () {
45
+ var u = (("https:" == document.location.protocol) ? "<?php echo $secureinstallPath ?>" : "<?php echo $installPath ?>");
46
+ _egoiaq.push(['setClientId', "<?php echo $account->getClienteId() ?>"]);
47
+ _egoiaq.push(['setSubscriber', "<?php echo $subscriberId; ?>"]);
48
+ _egoiaq.push(['setListId', "<?php echo $listId; ?>"]);
49
+ _egoiaq.push(['setTrackerUrl', u + 'collect']);
50
+ <?php echo $this->_getEcommerceCartUpdate() ?>
51
+ <?php echo $this->_getOrdersTrackingCode() ?>
52
+ <?php echo $this->_getProductPageview() ?>
53
+ <?php echo $this->_getCategoryPageview() ?>
54
+ <?php if (isset($nores)) {
55
+ ?>
56
+ var searchCount = <?php echo $nores; ?>;
57
+ _egoiaq.push(['setCustomUrl', document.URL + '&search_count=' + searchCount]);
58
+ <?php } ?>
59
+ <?php
60
+ //404 tracking
61
+ $action = Mage::app()->getRequest()->getActionName();
62
+ if ($action == 'noRoute') {
63
+ ?>
64
+ _egoiaq.push(['setDocumentTitle', '404/URL = ' + String(document.location.pathname + document.location.search).replace(/\//g, "%2f") + '/From = ' + String(document.referrer).replace(/\//g, "%2f")]);
65
+ <?php } ?>
66
+ <?php echo "\n"; ?>
67
+ _egoiaq.push(['trackPageView']);
68
+ _egoiaq.push(['enableLinkTracking']);
69
+ var d = document, g = d.createElement('script'), s = d.getElementsByTagName('script')[0];
70
+ g.type = 'text/javascript';
71
+ g.defer = true;
72
+ g.async = true;
73
+ g.src = u + 'egoimmerce.js';
74
+ s.parentNode.insertBefore(g, s);
75
+ })();
76
+ //]]>
77
+ </script>
78
+ <!-- END EGOIMMERCE TRACKING CODE -->
79
+ <?php
80
+ }
app/etc/modules/Licentia_Fidelitas.xml ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Licentia_Fidelitas>
5
+ <active>true</active>
6
+ <codePool>community</codePool>
7
+ <version>2.0.0.3</version>
8
+ </Licentia_Fidelitas>
9
+ </modules>
10
+ </config>
package.xml ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>Licentia_Fidelitas</name>
4
+ <version>2.2.2.0</version>
5
+ <stability>stable</stability>
6
+ <license uri="http://creativecommons.org/licenses/by-nc/4.0/">Creative Commons - Attribution-NonCommercial 4.0 International </license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>Email marketing</summary>
10
+ <description>Email marketing</description>
11
+ <notes>Email marketing</notes>
12
+ <authors><author><name>bento</name><user>licentia</user><email>bento@licentia.pt</email></author></authors>
13
+ <date>2017-01-22</date>
14
+ <time>22:31:05</time>
15
+ <contents><target name="magecommunity"><dir name="Licentia"><dir name="Fidelitas"><dir name="Block"><dir name="Adminhtml"><dir name="Account"><dir name="New"><dir name="Edit"><file name="Form.php" hash="6802d636f325a1c1e91515d906c35352"/><dir name="Tab"><file name="Api.php" hash="320ffbcc93452ab7c2ffd0a83aa96020"/><file name="Form.php" hash="d58c80db9a08fb05ae059e18215cb378"/></dir><file name="Tabs.php" hash="8add5cc4a3edbd6ef92c6f0a00db0e2e"/></dir><file name="Edit.php" hash="b86f3f3b32c38ba80c5e74bd0c858e08"/></dir><file name="New.php" hash="d5fc7f250b2d2cd816e4b5cc91242272"/><dir name="Support"><dir name="Edit"><file name="Form.php" hash="0eacee9a220ba52968442575c9f9a406"/><dir name="Tab"><file name="Form.php" hash="5cecbf817777f9322a8a4066805c6dd4"/></dir><file name="Tabs.php" hash="3de3e6aa7541058be94a4cdad5f479ae"/></dir><file name="Edit.php" hash="9dbc6988f63239978405ca3703ed2ce6"/></dir><file name="Support.php" hash="8a8ca7ba9dd695f10fca5e6f2fe7b55a"/><dir name="Sync"><dir name="Edit"><file name="Form.php" hash="f0283c4d94ded6843b5d807cd8ef1a29"/><dir name="Tab"><file name="Form.php" hash="62aa790142e7c7d5f7c1efd403bc8caf"/></dir><file name="Tabs.php" hash="69846a0c99c896a88e9ab56766d7e53f"/></dir><file name="Edit.php" hash="564693d4f8dfb59b9ff0efd47a1119cd"/></dir><file name="Sync.php" hash="2c1d8b495043e8f07dcd9e360bb188d3"/></dir><file name="Account.php" hash="7852371d0a9d7be6df7a2d06e2ee631c"/><dir name="Autoresponders"><dir name="Edit"><file name="Form.php" hash="356ca946f042ef4707f4c2d87d449852"/><dir name="Tab"><file name="Data.php" hash="bbacf805657b8f029d6b91b36d28bb77"/><file name="Main.php" hash="37bdc3f0d2b704bc1fb208a7f5515a6a"/></dir><file name="Tabs.php" hash="ea583251e1c289ef5bcb883140966474"/></dir><file name="Edit.php" hash="814a0172d583f9678cf6fa67972e0198"/><file name="Grid.php" hash="44ce976d0426680e89d84fd0327e6ae2"/></dir><file name="Autoresponders.php" hash="7e2d11c1b3bb81a3bd2e1e347c1dcf0f"/><dir name="Events"><file name="Grid.php" hash="fb96492b69dec4628b42a25c8bbfd284"/></dir><file name="Events.php" hash="d5e7420ab36d092fb36f0c800dd55a1d"/><dir name="Lists"><dir name="Edit"><file name="Form.php" hash="1887d528edc782f9c918894238e3e5a4"/><dir name="Tab"><file name="Main.php" hash="5bd978fd01c24854f590288a57081cae"/></dir><file name="Tabs.php" hash="b0687d00f6c93ea0955ad5432c2dc1ab"/></dir><file name="Edit.php" hash="f9e149d2b0922c33ffb89a99e256c4b3"/><file name="Grid.php" hash="c2684f64f5dac5e6e83a74a6d9cd0664"/></dir><file name="Lists.php" hash="cc3df10e61a0a0cef65deb0e7bd029bb"/><dir name="Subscribers"><dir name="Edit"><file name="Form.php" hash="aadce50da358d664c99fc2c27d519b2e"/><dir name="Tab"><file name="Form.php" hash="56f4c6b69545e15b3e4bfad1228c2d57"/></dir><file name="Tabs.php" hash="62462849bc5bd297fb764a075abb6b69"/></dir><file name="Edit.php" hash="c86c116e9b7894b653713db6c1f5b405"/><file name="Grid.php" hash="b6307e585a5e6feb8af3801db5b5019f"/></dir><file name="Subscribers.php" hash="5880102fd07c90d645fee6c9f90f5662"/><dir name="System"><dir name="Config"><dir name="Form"><dir name="Field"><file name="Test.php" hash="55c625dced6d7e265c28377eed3fea21"/></dir></dir></dir></dir></dir><file name="Egoimmerce.php" hash="66ea73ddc94914d705ab22ee90da0c08"/></dir><dir name="Helper"><file name="Data.php" hash="d9c90d95319fab4b6431b2d30fbfae6f"/></dir><dir name="Model"><file name="Account.php" hash="ac6a858eebdf9335b22e7cced2145fa8"/><file name="Autoresponders.php" hash="3f6808a6b9c7e356002c31cc00597317"/><file name="Egoi.php" hash="b77f8dd6c6f20fb4eb1195d475008f85"/><file name="Events.php" hash="190cf15070bd6f799f8b10c0921133f5"/><file name="Extra.php" hash="e8b6d2da034b77b143db81cf649ead1c"/><file name="Lists.php" hash="aca7a218c9f81b2fdbe0d79c13e489c4"/><dir name="Mysql4"><dir name="Account"><file name="Collection.php" hash="2d668e62a13f4ef5e384aeec0e514c1a"/></dir><file name="Account.php" hash="7c9967d6a86f49378f1e513acfc07078"/><dir name="Autoresponders"><file name="Collection.php" hash="bb924ad5979b3b27b312f46d84fe44c6"/></dir><file name="Autoresponders.php" hash="84fe50177e1c3cf4b8773b6133017ab4"/><dir name="Events"><file name="Collection.php" hash="3eb76ae733c4d76f27dae40cda7f9f4c"/></dir><file name="Events.php" hash="c68be7cbd8bcb077729de120a4af2cb3"/><dir name="Extra"><file name="Collection.php" hash="3378a705bbc8fd647c87d50c729b6715"/></dir><file name="Extra.php" hash="2e7c8ae5c07f92a22b04b5080f0712b4"/><dir name="Lists"><file name="Collection.php" hash="bb48b44e845ee9c28a8ce8fdbc42674d"/></dir><file name="Lists.php" hash="eb23516e199ed10234c7df1a6922a313"/><dir name="Subscribers"><file name="Collection.php" hash="fc44d78d088c11aab5345aacd12b80b6"/></dir><file name="Subscribers.php" hash="4478e53edda9027e02fb62163164ce97"/></dir><file name="Observer.php" hash="f575478e27bd583931acfbb2c8731503"/><dir name="Source"><file name="Addressattributes.php" hash="c8cf64629c92f54859c3335832b43ee6"/><file name="Method.php" hash="151497a995e79e0a6e226ec1aae3eaec"/><file name="Sender.php" hash="2c054ca6a46b43545a0cec4eef381b8a"/></dir><file name="Subscribers.php" hash="cba8c3ad04801303bd89fb51332d8afd"/></dir><dir name="controllers"><dir name="Adminhtml"><dir name="Fidelitas"><file name="AccountController.php" hash="73bb608f82fd1be3325fe5a7ba1d6fac"/><file name="AutorespondersController.php" hash="000336c4a0bbe237404ea8de5a399e66"/><file name="EventsController.php" hash="37252a1a492bb4a90d2badae5c92e472"/><file name="ListsController.php" hash="5915bf0646216756b91b1636b38c52ca"/><file name="SubscribersController.php" hash="c3c0393809c664891b02f07a89ca3f7b"/></dir></dir><file name="CallbackController.php" hash="a5c1e7ef880f3faeaa32287791737669"/></dir><dir name="etc"><file name="adminhtml.xml" hash="f7e2021f617fe0d719cc71641927c6c9"/><file name="config.xml" hash="5413eb890a07615cb1580f3725117abe"/><file name="system.xml" hash="bfbfc6ba8827e6ba20f1cd88b2f25105"/></dir><dir name="sql"><dir name="fidelitas_setup"><file name="mysql4-install-2.0.0.0.php" hash="665ca2dfe422a474f4faad8ae1985e6c"/><file name="mysql4-upgrade-2.0.0.5-2.1.0.0.php" hash="628f9f7253d152847971708552849b90"/><file name="mysql4-upgrade-2.1.0.4-2.1.0.5.php" hash="5fe08f874391f6d174be2c33e2f81cfd"/><file name="mysql4-upgrade-2.2.0.4-2.2.0.5.php" hash="ed2e1a7d5e7cd959277823d7a03bff5a"/></dir></dir><file name=".DS_Store" hash="9973f2ca1f500fa6ee3b1d567898c291"/></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Licentia_Fidelitas.xml" hash="fb5bebd3e734d581867a362a1046df7c"/></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="fidelitas.xml" hash="78efe5b2c2cbf4650e4d3d5acea8df12"/></dir><dir name="template"><dir name="fidelitas"><file name="egoimmerce.phtml" hash="8402f2defee218269dad4989ce80651f"/></dir></dir></dir></dir></dir><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="fidelitas.xml" hash="fbf163f93a515a6b834468bbbddd49da"/></dir><dir name="template"><dir name="fidelitas"><dir name="account"><file name="account.phtml" hash="502fd3aa14466f51b760e54d3754728a"/><file name="new.phtml" hash="b77874642f2fe60d966ba52ba808ff87"/></dir></dir></dir></dir></dir></dir></target></contents>
16
+ <compatible/>
17
+ <dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php><extension><name>soap</name><min/><max/></extension></required></dependencies>
18
+ </package>