Grazitti_Promotions - Version 1.0.1

Version Notes

First Release

Download this release

Release Info

Developer Mamta
Extension Grazitti_Promotions
Version 1.0.1
Comparing to
See all releases


Version 1.0.1

Files changed (37) hide show
  1. app/code/local/Grazitti/Promotions/Block/Adminhtml/Promo/Quote/Edit/Tab/Grid.php +259 -0
  2. app/code/local/Grazitti/Promotions/Block/Adminhtml/Promotion.php +12 -0
  3. app/code/local/Grazitti/Promotions/Block/Adminhtml/Promotion/Edit.php +45 -0
  4. app/code/local/Grazitti/Promotions/Block/Adminhtml/Promotion/Edit/Form.php +19 -0
  5. app/code/local/Grazitti/Promotions/Block/Adminhtml/Promotion/Edit/Tab/Form.php +58 -0
  6. app/code/local/Grazitti/Promotions/Block/Adminhtml/Promotion/Edit/Tabs.php +29 -0
  7. app/code/local/Grazitti/Promotions/Block/Adminhtml/Promotion/Grid.php +116 -0
  8. app/code/local/Grazitti/Promotions/Block/Adminhtml/Promotions.php +12 -0
  9. app/code/local/Grazitti/Promotions/Block/Adminhtml/Promotions/Edit.php +45 -0
  10. app/code/local/Grazitti/Promotions/Block/Adminhtml/Promotions/Edit/Form.php +19 -0
  11. app/code/local/Grazitti/Promotions/Block/Adminhtml/Promotions/Edit/Tab/Form.php +58 -0
  12. app/code/local/Grazitti/Promotions/Block/Adminhtml/Promotions/Edit/Tab/Grid.php +44 -0
  13. app/code/local/Grazitti/Promotions/Block/Adminhtml/Promotions/Edit/Tabs.php +30 -0
  14. app/code/local/Grazitti/Promotions/Block/Adminhtml/Promotions/Grid.php +117 -0
  15. app/code/local/Grazitti/Promotions/Block/Promotion.php +17 -0
  16. app/code/local/Grazitti/Promotions/Block/Promotions.php +17 -0
  17. app/code/local/Grazitti/Promotions/Helper/Data.php +6 -0
  18. app/code/local/Grazitti/Promotions/Model/Massgenerator.php +99 -0
  19. app/code/local/Grazitti/Promotions/Model/Mysql4/Promotion.php +10 -0
  20. app/code/local/Grazitti/Promotions/Model/Mysql4/Promotion/Collection.php +10 -0
  21. app/code/local/Grazitti/Promotions/Model/Mysql4/Promotions.php +10 -0
  22. app/code/local/Grazitti/Promotions/Model/Mysql4/Promotions/Collection.php +10 -0
  23. app/code/local/Grazitti/Promotions/Model/Observer.php +96 -0
  24. app/code/local/Grazitti/Promotions/Model/Promotion.php +10 -0
  25. app/code/local/Grazitti/Promotions/Model/Promotions.php +10 -0
  26. app/code/local/Grazitti/Promotions/Model/Status.php +15 -0
  27. app/code/local/Grazitti/Promotions/Model/System/Config/Source/salerules.php +81 -0
  28. app/code/local/Grazitti/Promotions/controllers/Adminhtml/PromotionController.php +234 -0
  29. app/code/local/Grazitti/Promotions/controllers/Adminhtml/PromotionsController.php +228 -0
  30. app/code/local/Grazitti/Promotions/controllers/IndexController.php +47 -0
  31. app/code/local/Grazitti/Promotions/etc/config.xml +156 -0
  32. app/code/local/Grazitti/Promotions/etc/system.xml +87 -0
  33. app/code/local/Grazitti/Promotions/sql/promotion_setup/mysql4-install-0.1.0.php +23 -0
  34. app/code/local/Grazitti/Promotions/sql/promotions_setup/mysql4-install-0.1.0.php +23 -0
  35. app/design/adminhtml/default/default/layout/promotions.xml +32 -0
  36. app/etc/modules/Grazitti_Promotions.xml +17 -0
  37. package.xml +18 -0
app/code/local/Grazitti/Promotions/Block/Adminhtml/Promo/Quote/Edit/Tab/Grid.php ADDED
@@ -0,0 +1,259 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magento.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magento.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2006-2015 X.commerce, Inc. (http://www.magento.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Shopping Cart Price Rule General Information Tab
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Adminhtml
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+ class Grazitti_Promotion_Block_Adminhtml_Promo_Quote_Edit_Tab_Grid
35
+ extends Mage_Adminhtml_Block_Widget_Grid
36
+ implements Mage_Adminhtml_Block_Widget_Tab_Interface
37
+ {
38
+ /**
39
+ * Prepare content for tab
40
+ *
41
+ * @return string
42
+ */
43
+ public function getTabLabel()
44
+ {
45
+ return Mage::helper('salesrule')->__('Individual Discount');
46
+ }
47
+
48
+ /**
49
+ * Prepare title for tab
50
+ *
51
+ * @return string
52
+ */
53
+ public function getTabTitle()
54
+ {
55
+ return Mage::helper('salesrule')->__('Rule Information');
56
+ }
57
+
58
+ /**
59
+ * Returns status flag about this tab can be showed or not
60
+ *
61
+ * @return true
62
+ */
63
+ public function canShowTab()
64
+ {
65
+ return true;
66
+ }
67
+
68
+ /**
69
+ * Returns status flag about this tab hidden or not
70
+ *
71
+ * @return true
72
+ */
73
+ public function isHidden()
74
+ {
75
+ return false;
76
+ }
77
+
78
+ public function __construct()
79
+ {
80
+ parent::__construct();
81
+ $this->setId('customer_Grid');
82
+ $this->setUseAjax(true);
83
+ $this->setDefaultSort('entity_id');
84
+ $this->setSaveParametersInSession(false);
85
+ }
86
+
87
+ protected function _prepareCollection()
88
+ {
89
+ $collection = Mage::getResourceModel('customer/customer_collection')
90
+ ->addNameToSelect()
91
+ ->addAttributeToSelect('email')
92
+ ->addAttributeToSelect('created_at')
93
+ ->addAttributeToSelect('group_id')
94
+ ->addAttributeToSelect('customer_id')
95
+ ->joinAttribute('billing_postcode', 'customer_address/postcode', 'default_billing', null, 'left')
96
+ ->joinAttribute('billing_city', 'customer_address/city', 'default_billing', null, 'left')
97
+ ->joinAttribute('billing_telephone', 'customer_address/telephone', 'default_billing', null, 'left')
98
+ ->joinAttribute('billing_region', 'customer_address/region', 'default_billing', null, 'left')
99
+ ->joinAttribute('billing_country_id', 'customer_address/country_id', 'default_billing', null, 'left');
100
+
101
+ $this->setCollection($collection);
102
+ //echo '<pre>';print_r($collection);
103
+ return Mage_Adminhtml_Block_Widget_Grid::_prepareCollection();
104
+ }
105
+ protected function _prepareColumns()
106
+ {
107
+ $this->addColumn('in_products', array(
108
+ 'header_css_class' => 'a-center',
109
+ 'type' => 'checkbox',
110
+ 'name' => 'customer',
111
+ 'values' => $this->_getSelectedCustomers(),
112
+ 'align' => 'center',
113
+ 'index' => 'entity_id'
114
+ ));
115
+ $this->addColumn('entity_id', array(
116
+ 'header' => Mage::helper('customer')->__('ID'),
117
+ 'width' => '50px',
118
+ 'index' => 'entity_id',
119
+ 'type' => 'number',
120
+ ));
121
+
122
+ $this->addColumn('name', array(
123
+ 'header' => Mage::helper('customer')->__('Name'),
124
+ 'index' => 'name'
125
+ ));
126
+ $this->addColumn('email', array(
127
+ 'header' => Mage::helper('customer')->__('Email'),
128
+ 'width' => '150',
129
+ 'index' => 'email'
130
+ ));
131
+
132
+ $groups = Mage::getResourceModel('customer/group_collection')
133
+ ->addFieldToFilter('customer_group_id', array('gt'=> 0))
134
+ ->load()
135
+ ->toOptionHash();
136
+
137
+ $this->addColumn('group', array(
138
+ 'header' => Mage::helper('customer')->__('Group'),
139
+ 'width' => '100',
140
+ 'index' => 'group_id',
141
+ 'type' => 'options',
142
+ 'options' => $groups,
143
+ ));
144
+
145
+ $this->addColumn('Telephone', array(
146
+ 'header' => Mage::helper('customer')->__('Telephone'),
147
+ 'width' => '100',
148
+ 'index' => 'billing_telephone'
149
+ ));
150
+
151
+ $this->addColumn('billing_postcode', array(
152
+ 'header' => Mage::helper('customer')->__('ZIP'),
153
+ 'width' => '90',
154
+ 'index' => 'billing_postcode',
155
+ ));
156
+
157
+ $this->addColumn('billing_country_id', array(
158
+ 'header' => Mage::helper('customer')->__('Country'),
159
+ 'width' => '100',
160
+ 'type' => 'country',
161
+ 'index' => 'billing_country_id',
162
+ ));
163
+
164
+ $this->addColumn('billing_region', array(
165
+ 'header' => Mage::helper('customer')->__('State/Province'),
166
+ 'width' => '100',
167
+ 'index' => 'billing_region',
168
+ ));
169
+
170
+ $this->addColumn('customer_since', array(
171
+ 'header' => Mage::helper('customer')->__('Customer Since'),
172
+ 'type' => 'datetime',
173
+ 'align' => 'center',
174
+ 'index' => 'created_at',
175
+ 'gmtoffset' => true
176
+ ));
177
+
178
+ if (!Mage::app()->isSingleStoreMode()) {
179
+ $this->addColumn('website_id', array(
180
+ 'header' => Mage::helper('customer')->__('Website'),
181
+ 'align' => 'center',
182
+ 'width' => '80px',
183
+ 'type' => 'options',
184
+ 'options' => Mage::getSingleton('adminhtml/system_store')->getWebsiteOptionHash(true),
185
+ 'index' => 'website_id',
186
+ ));
187
+ }
188
+ return parent::_prepareColumns();
189
+ }
190
+ // protected function _prepareMassaction()
191
+ // {
192
+ // $this->setMassactionIdField('entity_id');
193
+ // $this->getMassactionBlock()->setFormFieldName('customer');
194
+
195
+ // $this->getMassactionBlock()->addItem('delete', array(
196
+ // 'label' => Mage::helper('customer')->__('Delete'),
197
+ // 'url' => $this->getUrl('*/*/massDelete'),
198
+ // 'confirm' => Mage::helper('customer')->__('Are you sure?')
199
+ // ));
200
+
201
+
202
+
203
+
204
+ // return $this;
205
+ //}
206
+ protected function _addColumnFilterToCollection($column)
207
+ {
208
+ // Set custom filter for in product flag
209
+ if ($column->getId() == 'in_products') {
210
+ $productIds = $this->_getSelectedCustomers();
211
+ if (empty($productIds)) {
212
+ $productIds = 0;
213
+ }
214
+ if ($column->getFilter()->getValue()) {
215
+ $this->getCollection()->addFieldToFilter('entity_id', array('in'=>$productIds));
216
+ } else {
217
+ if($productIds) {
218
+ $this->getCollection()->addFieldToFilter('entity_id', array('nin'=>$productIds));
219
+ }
220
+ }
221
+ } else {
222
+ parent::_addColumnFilterToCollection($column);
223
+ }
224
+ return $this;
225
+ }
226
+
227
+ protected function _getSelectedCustomers() // Used in grid to return selected customers values.
228
+ {
229
+ $customers = array_keys($this->getSelectedCustomers());
230
+ return $customers;
231
+ }
232
+
233
+ public function getSelectedCustomers()
234
+ {
235
+ // Customer Data
236
+ $tm_id = $this->getRequest()->getParam('id');
237
+ if(!isset($tm_id)) {
238
+ $tm_id = 0;
239
+ }
240
+ $customers = array(1,2); // This is hard-coded right now, but should actually get values from database.
241
+ $custIds = array();
242
+
243
+ foreach($customers as $customer) {
244
+ foreach($customer as $cust) {
245
+ $custIds[$cust] = array('position'=>$cust);
246
+ }
247
+ }
248
+ return $custIds;
249
+ }
250
+
251
+ public function getGridUrl()
252
+ {
253
+
254
+ return $this->getUrl('adminhtml/indpromotions/grid', array('_current'=> true));
255
+
256
+ }
257
+
258
+
259
+ }
app/code/local/Grazitti/Promotions/Block/Adminhtml/Promotion.php ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Grazitti_Promotion_Block_Adminhtml_Promotion extends Mage_Adminhtml_Block_Widget_Grid_Container
3
+ {
4
+ public function __construct()
5
+ {
6
+ $this->_controller = 'adminhtml_promotion';
7
+ $this->_blockGroup = 'promotion';
8
+ $this->_headerText = Mage::helper('promotion')->__('Item Manager');
9
+ $this->_addButtonLabel = Mage::helper('promotion')->__('Add Item');
10
+ parent::__construct();
11
+ }
12
+ }
app/code/local/Grazitti/Promotions/Block/Adminhtml/Promotion/Edit.php ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Grazitti_Promotion_Block_Adminhtml_Promotion_Edit extends Mage_Adminhtml_Block_Widget_Form_Container
4
+ {
5
+ public function __construct()
6
+ {
7
+ parent::__construct();
8
+
9
+ $this->_objectId = 'id';
10
+ $this->_blockGroup = 'promotion';
11
+ $this->_controller = 'adminhtml_promotion';
12
+
13
+ $this->_updateButton('save', 'label', Mage::helper('promotion')->__('Save Item'));
14
+ $this->_updateButton('delete', 'label', Mage::helper('promotion')->__('Delete Item'));
15
+
16
+ $this->_addButton('saveandcontinue', array(
17
+ 'label' => Mage::helper('adminhtml')->__('Save And Continue Edit'),
18
+ 'onclick' => 'saveAndContinueEdit()',
19
+ 'class' => 'save',
20
+ ), -100);
21
+
22
+ $this->_formScripts[] = "
23
+ function toggleEditor() {
24
+ if (tinyMCE.getInstanceById('promotion_content') == null) {
25
+ tinyMCE.execCommand('mceAddControl', false, 'promotion_content');
26
+ } else {
27
+ tinyMCE.execCommand('mceRemoveControl', false, 'promotion_content');
28
+ }
29
+ }
30
+
31
+ function saveAndContinueEdit(){
32
+ editForm.submit($('edit_form').action+'back/edit/');
33
+ }
34
+ ";
35
+ }
36
+
37
+ public function getHeaderText()
38
+ {
39
+ if( Mage::registry('promotion_data') && Mage::registry('promotion_data')->getId() ) {
40
+ return Mage::helper('promotion')->__("Edit Item '%s'", $this->htmlEscape(Mage::registry('promotion_data')->getTitle()));
41
+ } else {
42
+ return Mage::helper('promotion')->__('Add Item');
43
+ }
44
+ }
45
+ }
app/code/local/Grazitti/Promotions/Block/Adminhtml/Promotion/Edit/Form.php ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Grazitti_Promotion_Block_Adminhtml_Promotion_Edit_Form extends Mage_Adminhtml_Block_Widget_Form
4
+ {
5
+ protected function _prepareForm()
6
+ {
7
+ $form = new Varien_Data_Form(array(
8
+ 'id' => 'edit_form',
9
+ 'action' => $this->getUrl('*/*/save', array('id' => $this->getRequest()->getParam('id'))),
10
+ 'method' => 'post',
11
+ 'enctype' => 'multipart/form-data'
12
+ )
13
+ );
14
+
15
+ $form->setUseContainer(true);
16
+ $this->setForm($form);
17
+ return parent::_prepareForm();
18
+ }
19
+ }
app/code/local/Grazitti/Promotions/Block/Adminhtml/Promotion/Edit/Tab/Form.php ADDED
@@ -0,0 +1,58 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Grazitti_Promotion_Block_Adminhtml_Promotion_Edit_Tab_Form extends Mage_Adminhtml_Block_Widget_Form
4
+ {
5
+ protected function _prepareForm()
6
+ {
7
+ $form = new Varien_Data_Form();
8
+ $this->setForm($form);
9
+ $fieldset = $form->addFieldset('promotion_form', array('legend'=>Mage::helper('promotion')->__('Item information')));
10
+
11
+ $fieldset->addField('title', 'text', array(
12
+ 'label' => Mage::helper('promotion')->__('Title'),
13
+ 'class' => 'required-entry',
14
+ 'required' => true,
15
+ 'name' => 'title',
16
+ ));
17
+
18
+ $fieldset->addField('filename', 'file', array(
19
+ 'label' => Mage::helper('promotion')->__('File'),
20
+ 'required' => false,
21
+ 'name' => 'filename',
22
+ ));
23
+
24
+ $fieldset->addField('status', 'select', array(
25
+ 'label' => Mage::helper('promotion')->__('Status'),
26
+ 'name' => 'status',
27
+ 'values' => array(
28
+ array(
29
+ 'value' => 1,
30
+ 'label' => Mage::helper('promotion')->__('Enabled'),
31
+ ),
32
+
33
+ array(
34
+ 'value' => 2,
35
+ 'label' => Mage::helper('promotion')->__('Disabled'),
36
+ ),
37
+ ),
38
+ ));
39
+
40
+ $fieldset->addField('content', 'editor', array(
41
+ 'name' => 'content',
42
+ 'label' => Mage::helper('promotion')->__('Content'),
43
+ 'title' => Mage::helper('promotion')->__('Content'),
44
+ 'style' => 'width:700px; height:500px;',
45
+ 'wysiwyg' => false,
46
+ 'required' => true,
47
+ ));
48
+
49
+ if ( Mage::getSingleton('adminhtml/session')->getPromotionData() )
50
+ {
51
+ $form->setValues(Mage::getSingleton('adminhtml/session')->getPromotionData());
52
+ Mage::getSingleton('adminhtml/session')->setPromotionData(null);
53
+ } elseif ( Mage::registry('promotion_data') ) {
54
+ $form->setValues(Mage::registry('promotion_data')->getData());
55
+ }
56
+ return parent::_prepareForm();
57
+ }
58
+ }
app/code/local/Grazitti/Promotions/Block/Adminhtml/Promotion/Edit/Tabs.php ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Grazitti_Promotion_Block_Adminhtml_Promotion_Edit_Tabs extends Mage_Adminhtml_Block_Widget_Tabs
4
+ {
5
+
6
+ public function __construct()
7
+ {
8
+ parent::__construct();
9
+ $this->setId('promotion_tabs');
10
+ $this->setDestElementId('edit_form');
11
+ $this->setTitle(Mage::helper('promotion')->__('Item Information'));
12
+ }
13
+
14
+ protected function _beforeToHtml()
15
+ {
16
+ $this->addTab('form_section', array(
17
+ 'label' => Mage::helper('promotion')->__('Item Information'),
18
+ 'title' => Mage::helper('promotion')->__('Item Information'),
19
+ 'content' => $this->getLayout()->createBlock('promotion/adminhtml_promotion_edit_tab_form')->toHtml(),
20
+ ));
21
+
22
+
23
+
24
+
25
+ return parent::_beforeToHtml();
26
+
27
+
28
+ }
29
+ }
app/code/local/Grazitti/Promotions/Block/Adminhtml/Promotion/Grid.php ADDED
@@ -0,0 +1,116 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Grazitti_Promotion_Block_Adminhtml_Promotion_Grid extends Mage_Adminhtml_Block_Widget_Grid
4
+ {
5
+ public function __construct()
6
+ {
7
+ parent::__construct();
8
+ $this->setId('promotionGrid');
9
+ $this->setDefaultSort('promotion_id');
10
+ $this->setDefaultDir('ASC');
11
+ $this->setSaveParametersInSession(true);
12
+ }
13
+
14
+ protected function _prepareCollection()
15
+ {
16
+ $collection = Mage::getModel('promotion/promotion')->getCollection();
17
+ $this->setCollection($collection);
18
+ return parent::_prepareCollection();
19
+ }
20
+
21
+ protected function _prepareColumns()
22
+ {
23
+ $this->addColumn('promotion_id', array(
24
+ 'header' => Mage::helper('promotion')->__('ID'),
25
+ 'align' =>'right',
26
+ 'width' => '50px',
27
+ 'index' => 'promotion_id',
28
+ ));
29
+
30
+ $this->addColumn('title', array(
31
+ 'header' => Mage::helper('promotion')->__('Title'),
32
+ 'align' =>'left',
33
+ 'index' => 'title',
34
+ ));
35
+
36
+ /*
37
+ $this->addColumn('content', array(
38
+ 'header' => Mage::helper('promotion')->__('Item Content'),
39
+ 'width' => '150px',
40
+ 'index' => 'content',
41
+ ));
42
+ */
43
+
44
+ $this->addColumn('status', array(
45
+ 'header' => Mage::helper('promotion')->__('Status'),
46
+ 'align' => 'left',
47
+ 'width' => '80px',
48
+ 'index' => 'status',
49
+ 'type' => 'options',
50
+ 'options' => array(
51
+ 1 => 'Enabled',
52
+ 2 => 'Disabled',
53
+ ),
54
+ ));
55
+
56
+ $this->addColumn('action',
57
+ array(
58
+ 'header' => Mage::helper('promotion')->__('Action'),
59
+ 'width' => '100',
60
+ 'type' => 'action',
61
+ 'getter' => 'getId',
62
+ 'actions' => array(
63
+ array(
64
+ 'caption' => Mage::helper('promotion')->__('Edit'),
65
+ 'url' => array('base'=> '*/*/edit'),
66
+ 'field' => 'id'
67
+ )
68
+ ),
69
+ 'filter' => false,
70
+ 'sortable' => false,
71
+ 'index' => 'stores',
72
+ 'is_system' => true,
73
+ ));
74
+
75
+ $this->addExportType('*/*/exportCsv', Mage::helper('promotion')->__('CSV'));
76
+ $this->addExportType('*/*/exportXml', Mage::helper('promotion')->__('XML'));
77
+
78
+ return parent::_prepareColumns();
79
+ }
80
+
81
+ protected function _prepareMassaction()
82
+ {
83
+ $this->setMassactionIdField('promotion_id');
84
+ $this->getMassactionBlock()->setFormFieldName('promotion');
85
+
86
+ $this->getMassactionBlock()->addItem('delete', array(
87
+ 'label' => Mage::helper('promotion')->__('Delete'),
88
+ 'url' => $this->getUrl('*/*/massDelete'),
89
+ 'confirm' => Mage::helper('promotion')->__('Are you sure?')
90
+ ));
91
+
92
+ $statuses = Mage::getSingleton('promotion/status')->getOptionArray();
93
+
94
+ array_unshift($statuses, array('label'=>'', 'value'=>''));
95
+ $this->getMassactionBlock()->addItem('status', array(
96
+ 'label'=> Mage::helper('promotion')->__('Change status'),
97
+ 'url' => $this->getUrl('*/*/massStatus', array('_current'=>true)),
98
+ 'additional' => array(
99
+ 'visibility' => array(
100
+ 'name' => 'status',
101
+ 'type' => 'select',
102
+ 'class' => 'required-entry',
103
+ 'label' => Mage::helper('promotion')->__('Status'),
104
+ 'values' => $statuses
105
+ )
106
+ )
107
+ ));
108
+ return $this;
109
+ }
110
+
111
+ public function getRowUrl($row)
112
+ {
113
+ return $this->getUrl('*/*/edit', array('id' => $row->getId()));
114
+ }
115
+
116
+ }
app/code/local/Grazitti/Promotions/Block/Adminhtml/Promotions.php ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Grazitti_Promotions_Block_Adminhtml_Promotions extends Mage_Adminhtml_Block_Widget_Grid_Container
3
+ {
4
+ public function __construct()
5
+ {
6
+ $this->_controller = 'adminhtml_promotions';
7
+ $this->_blockGroup = 'promotions';
8
+ $this->_headerText = Mage::helper('promotions')->__('Item Manager');
9
+ $this->_addButtonLabel = Mage::helper('promotions')->__('Add Item');
10
+ parent::__construct();
11
+ }
12
+ }
app/code/local/Grazitti/Promotions/Block/Adminhtml/Promotions/Edit.php ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Grazitti_Promotions_Block_Adminhtml_Promotions_Edit extends Mage_Adminhtml_Block_Widget_Form_Container
4
+ {
5
+ public function __construct()
6
+ {
7
+ parent::__construct();
8
+
9
+ $this->_objectId = 'id';
10
+ $this->_blockGroup = 'promotions';
11
+ $this->_controller = 'adminhtml_promotions';
12
+
13
+ $this->_updateButton('save', 'label', Mage::helper('promotions')->__('Save Item'));
14
+ $this->_updateButton('delete', 'label', Mage::helper('promotions')->__('Delete Item'));
15
+
16
+ $this->_addButton('saveandcontinue', array(
17
+ 'label' => Mage::helper('adminhtml')->__('Save And Continue Edit'),
18
+ 'onclick' => 'saveAndContinueEdit()',
19
+ 'class' => 'save',
20
+ ), -100);
21
+
22
+ $this->_formScripts[] = "
23
+ function toggleEditor() {
24
+ if (tinyMCE.getInstanceById('promotions_content') == null) {
25
+ tinyMCE.execCommand('mceAddControl', false, 'promotions_content');
26
+ } else {
27
+ tinyMCE.execCommand('mceRemoveControl', false, 'promotions_content');
28
+ }
29
+ }
30
+
31
+ function saveAndContinueEdit(){
32
+ editForm.submit($('edit_form').action+'back/edit/');
33
+ }
34
+ ";
35
+ }
36
+
37
+ public function getHeaderText()
38
+ {
39
+ if( Mage::registry('promotions_data') && Mage::registry('promotions_data')->getId() ) {
40
+ return Mage::helper('promotions')->__("Edit Item '%s'", $this->htmlEscape(Mage::registry('promotions_data')->getTitle()));
41
+ } else {
42
+ return Mage::helper('promotions')->__('Add Item');
43
+ }
44
+ }
45
+ }
app/code/local/Grazitti/Promotions/Block/Adminhtml/Promotions/Edit/Form.php ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Grazitti_Promotions_Block_Adminhtml_Promotions_Edit_Form extends Mage_Adminhtml_Block_Widget_Form
4
+ {
5
+ protected function _prepareForm()
6
+ {
7
+ $form = new Varien_Data_Form(array(
8
+ 'id' => 'edit_form',
9
+ 'action' => $this->getUrl('*/*/save', array('id' => $this->getRequest()->getParam('id'))),
10
+ 'method' => 'post',
11
+ 'enctype' => 'multipart/form-data'
12
+ )
13
+ );
14
+
15
+ $form->setUseContainer(true);
16
+ $this->setForm($form);
17
+ return parent::_prepareForm();
18
+ }
19
+ }
app/code/local/Grazitti/Promotions/Block/Adminhtml/Promotions/Edit/Tab/Form.php ADDED
@@ -0,0 +1,58 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Grazitti_Promotions_Block_Adminhtml_Promotions_Edit_Tab_Form extends Mage_Adminhtml_Block_Widget_Form
4
+ {
5
+ protected function _prepareForm()
6
+ {
7
+ $form = new Varien_Data_Form();
8
+ $this->setForm($form);
9
+ $fieldset = $form->addFieldset('promotions_form', array('legend'=>Mage::helper('promotions')->__('Item information')));
10
+
11
+ $fieldset->addField('title', 'text', array(
12
+ 'label' => Mage::helper('promotions')->__('Title'),
13
+ 'class' => 'required-entry',
14
+ 'required' => true,
15
+ 'name' => 'title',
16
+ ));
17
+
18
+ $fieldset->addField('filename', 'file', array(
19
+ 'label' => Mage::helper('promotions')->__('File'),
20
+ 'required' => false,
21
+ 'name' => 'filename',
22
+ ));
23
+
24
+ $fieldset->addField('status', 'select', array(
25
+ 'label' => Mage::helper('promotions')->__('Status'),
26
+ 'name' => 'status',
27
+ 'values' => array(
28
+ array(
29
+ 'value' => 1,
30
+ 'label' => Mage::helper('promotions')->__('Enabled'),
31
+ ),
32
+
33
+ array(
34
+ 'value' => 2,
35
+ 'label' => Mage::helper('promotions')->__('Disabled'),
36
+ ),
37
+ ),
38
+ ));
39
+
40
+ $fieldset->addField('content', 'editor', array(
41
+ 'name' => 'content',
42
+ 'label' => Mage::helper('promotions')->__('Content'),
43
+ 'title' => Mage::helper('promotions')->__('Content'),
44
+ 'style' => 'width:700px; height:500px;',
45
+ 'wysiwyg' => false,
46
+ 'required' => true,
47
+ ));
48
+
49
+ if ( Mage::getSingleton('adminhtml/session')->getPromotionsData() )
50
+ {
51
+ $form->setValues(Mage::getSingleton('adminhtml/session')->getPromotionsData());
52
+ Mage::getSingleton('adminhtml/session')->setPromotionsData(null);
53
+ } elseif ( Mage::registry('promotions_data') ) {
54
+ $form->setValues(Mage::registry('promotions_data')->getData());
55
+ }
56
+ return parent::_prepareForm();
57
+ }
58
+ }
app/code/local/Grazitti/Promotions/Block/Adminhtml/Promotions/Edit/Tab/Grid.php ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Grazitti_Promotions_Block_Adminhtml_Promotions_Edit_Tab_Grid
3
+ extends Mage_Adminhtml_Block_Widget_Grid
4
+ implements Mage_Adminhtml_Block_Widget_Tab_Interface
5
+ {
6
+ public function __construct()
7
+ {
8
+ parent::__construct();
9
+ $this->setId('indpromotionsGrid');
10
+ $this->setUseAjax(true);
11
+ //$this->setDefaultSort('entity_id');
12
+ $this->setSaveParametersInSession(true);
13
+ }
14
+ protected function _prepareCollection()
15
+ {
16
+ /*Prepare collection that you want to show on the grid. I have commented it because I don't have
17
+ any table or collection. You will be uncommenting it to set collection on your grid.
18
+ */
19
+ $collection = Mage::getResourceModel('customer/customer_collection');
20
+
21
+ $this->setCollection($collection);
22
+
23
+ return parent::_prepareCollection();
24
+ }
25
+
26
+ /**
27
+ * This method will create columns
28
+ */
29
+ protected function _prepareColumns()
30
+ {
31
+ // Code for your grid here.
32
+ $this->addColumn('created_at', array(
33
+ 'header' => Mage::helper('salesrule')->__('Created On'),
34
+ 'index' => 'created_at',
35
+ 'type' => 'datetime',
36
+ 'align' => 'center',
37
+ 'width' => '160'
38
+ ));
39
+
40
+ return parent::_prepareColumns();
41
+ }
42
+
43
+ }
44
+ ?>
app/code/local/Grazitti/Promotions/Block/Adminhtml/Promotions/Edit/Tabs.php ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Grazitti_Promotions_Block_Adminhtml_Promotions_Edit_Tabs extends Mage_Adminhtml_Block_Widget_Tabs
4
+ {
5
+
6
+ public function __construct()
7
+ {
8
+ parent::__construct();
9
+ $this->setId('promotions_tabs');
10
+ $this->setDestElementId('edit_form');
11
+ $this->setTitle(Mage::helper('promotions')->__('Item Information'));
12
+ }
13
+
14
+ protected function _beforeToHtml()
15
+ {
16
+ $this->addTab('form_section', array(
17
+ 'label' => Mage::helper('promotions')->__('Item Information'),
18
+ 'title' => Mage::helper('promotions')->__('Item Information'),
19
+ 'content' => $this->getLayout()->createBlock('promotions/adminhtml_promotions_edit_tab_form')->toHtml(),
20
+ ));
21
+ $this->addTab('form_section1', array(
22
+ 'label' => Mage::helper('promotions')->__('Customers'),
23
+ 'title' => Mage::helper('promotions')->__('Customers'),
24
+ 'url' => $this->getUrl('*/*/customer', array('_current' => true)),
25
+ 'class' => 'ajax',
26
+ ));
27
+
28
+ return parent::_beforeToHtml();
29
+ }
30
+ }
app/code/local/Grazitti/Promotions/Block/Adminhtml/Promotions/Grid.php ADDED
@@ -0,0 +1,117 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Grazitti_Promotions_Block_Adminhtml_Promotions_Grid extends Mage_Adminhtml_Block_Widget_Grid
4
+ {
5
+ public function __construct()
6
+ {
7
+ parent::__construct();
8
+ $this->setId('promotionsGrid');
9
+ $this->setDefaultSort('promotions_id');
10
+ $this->setDefaultDir('ASC');
11
+ $this->setSaveParametersInSession(true);
12
+ }
13
+
14
+ protected function _prepareCollection()
15
+ {
16
+ $collection = Mage::getModel('promotions/promotions')->getCollection();
17
+ $this->setCollection($collection);
18
+ return parent::_prepareCollection();
19
+ }
20
+
21
+ protected function _prepareColumns()
22
+ {
23
+
24
+ $this->addColumn('promotions_id', array(
25
+ 'header' => Mage::helper('promotions')->__('ID'),
26
+ 'align' =>'right',
27
+ 'width' => '50px',
28
+ 'index' => 'promotions_id',
29
+ ));
30
+
31
+ $this->addColumn('title', array(
32
+ 'header' => Mage::helper('promotions')->__('Title'),
33
+ 'align' =>'left',
34
+ 'index' => 'title',
35
+ ));
36
+
37
+ /*
38
+ $this->addColumn('content', array(
39
+ 'header' => Mage::helper('promotions')->__('Item Content'),
40
+ 'width' => '150px',
41
+ 'index' => 'content',
42
+ ));
43
+ */
44
+
45
+ $this->addColumn('status', array(
46
+ 'header' => Mage::helper('promotions')->__('Status'),
47
+ 'align' => 'left',
48
+ 'width' => '80px',
49
+ 'index' => 'status',
50
+ 'type' => 'options',
51
+ 'options' => array(
52
+ 1 => 'Enabled',
53
+ 2 => 'Disabled',
54
+ ),
55
+ ));
56
+
57
+ $this->addColumn('action',
58
+ array(
59
+ 'header' => Mage::helper('promotions')->__('Action'),
60
+ 'width' => '100',
61
+ 'type' => 'action',
62
+ 'getter' => 'getId',
63
+ 'actions' => array(
64
+ array(
65
+ 'caption' => Mage::helper('promotions')->__('Edit'),
66
+ 'url' => array('base'=> '*/*/edit'),
67
+ 'field' => 'id'
68
+ )
69
+ ),
70
+ 'filter' => false,
71
+ 'sortable' => false,
72
+ 'index' => 'stores',
73
+ 'is_system' => true,
74
+ ));
75
+
76
+ $this->addExportType('*/*/exportCsv', Mage::helper('promotions')->__('CSV'));
77
+ $this->addExportType('*/*/exportXml', Mage::helper('promotions')->__('XML'));
78
+
79
+ return parent::_prepareColumns();
80
+ }
81
+
82
+ protected function _prepareMassaction()
83
+ {
84
+ $this->setMassactionIdField('promotions_id');
85
+ $this->getMassactionBlock()->setFormFieldName('promotions');
86
+
87
+ $this->getMassactionBlock()->addItem('delete', array(
88
+ 'label' => Mage::helper('promotions')->__('Delete'),
89
+ 'url' => $this->getUrl('*/*/massDelete'),
90
+ 'confirm' => Mage::helper('promotions')->__('Are you sure?')
91
+ ));
92
+
93
+ $statuses = Mage::getSingleton('promotions/status')->getOptionArray();
94
+
95
+ array_unshift($statuses, array('label'=>'', 'value'=>''));
96
+ $this->getMassactionBlock()->addItem('status', array(
97
+ 'label'=> Mage::helper('promotions')->__('Change status'),
98
+ 'url' => $this->getUrl('*/*/massStatus', array('_current'=>true)),
99
+ 'additional' => array(
100
+ 'visibility' => array(
101
+ 'name' => 'status',
102
+ 'type' => 'select',
103
+ 'class' => 'required-entry',
104
+ 'label' => Mage::helper('promotions')->__('Status'),
105
+ 'values' => $statuses
106
+ )
107
+ )
108
+ ));
109
+ return $this;
110
+ }
111
+
112
+ public function getRowUrl($row)
113
+ {
114
+ return $this->getUrl('*/*/edit', array('id' => $row->getId()));
115
+ }
116
+
117
+ }
app/code/local/Grazitti/Promotions/Block/Promotion.php ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Grazitti_Promotion_Block_Promotion extends Mage_Core_Block_Template
3
+ {
4
+ public function _prepareLayout()
5
+ {
6
+ return parent::_prepareLayout();
7
+ }
8
+
9
+ public function getPromotion()
10
+ {
11
+ if (!$this->hasData('promotion')) {
12
+ $this->setData('promotion', Mage::registry('promotion'));
13
+ }
14
+ return $this->getData('promotion');
15
+
16
+ }
17
+ }
app/code/local/Grazitti/Promotions/Block/Promotions.php ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Grazitti_Promotions_Block_Promotions extends Mage_Core_Block_Template
3
+ {
4
+ public function _prepareLayout()
5
+ {
6
+ return parent::_prepareLayout();
7
+ }
8
+
9
+ public function getPromotions()
10
+ {
11
+ if (!$this->hasData('promotions')) {
12
+ $this->setData('promotions', Mage::registry('promotions'));
13
+ }
14
+ return $this->getData('promotions');
15
+
16
+ }
17
+ }
app/code/local/Grazitti/Promotions/Helper/Data.php ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Grazitti_Promotions_Helper_Data extends Mage_Core_Helper_Abstract
4
+ {
5
+
6
+ }
app/code/local/Grazitti/Promotions/Model/Massgenerator.php ADDED
@@ -0,0 +1,99 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magento.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magento.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_SalesRule
23
+ * @copyright Copyright (c) 2006-2015 X.commerce, Inc. (http://www.magento.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+
28
+ /**
29
+ * SalesRule Mass Coupon Generator
30
+ *
31
+ * @method Mage_SalesRule_Model_Resource_Coupon getResource()
32
+ *
33
+ * @category Mage
34
+ * @package Mage_SalesRule
35
+ * @author Magento Core Team <core@magentocommerce.com>
36
+ */
37
+ class Grazitti_Promotions_Model_Massgenerator extends Mage_SalesRule_Model_Coupon_Massgenerator
38
+ implements Mage_SalesRule_Model_Coupon_CodegeneratorInterface
39
+ {
40
+ public function generatePool()
41
+ {
42
+ $this->_generatedCount = 0;
43
+ $size = $this->getQty();
44
+
45
+ $maxProbability = $this->getMaxProbability() ? $this->getMaxProbability() : self::MAX_PROBABILITY_OF_GUESSING;
46
+ $maxAttempts = $this->getMaxAttempts() ? $this->getMaxAttempts() : self::MAX_GENERATE_ATTEMPTS;
47
+
48
+ /** @var $coupon Mage_SalesRule_Model_Coupon */
49
+ $coupon = Mage::getModel('salesrule/coupon');
50
+
51
+ $chars = count(Mage::helper('salesrule/coupon')->getCharset($this->getFormat()));
52
+ $length = (int) $this->getLength();
53
+ $maxCodes = pow($chars, $length);
54
+ $probability = $size / $maxCodes;
55
+ //increase the length of Code if probability is low
56
+ if ($probability > $maxProbability) {
57
+ do {
58
+ $length++;
59
+ $maxCodes = pow($chars, $length);
60
+ $probability = $size / $maxCodes;
61
+ } while ($probability > $maxProbability);
62
+ $this->setLength($length);
63
+ }
64
+
65
+ $now = $this->getResource()->formatDate(
66
+ Mage::getSingleton('core/date')->gmtTimestamp()
67
+ );
68
+
69
+ for ($i = 0; $i < $size; $i++) {
70
+ $attempt = 0;
71
+ do {
72
+ if ($attempt >= $maxAttempts) {
73
+ Mage::throwException(Mage::helper('salesrule')->__('Unable to create requested Coupon Qty. Please check settings and try again.'));
74
+ }
75
+ $code = $this->generateCode();
76
+ $attempt++;
77
+ } while ($this->getResource()->exists($code));
78
+
79
+ $expirationDate = $this->getToDate();
80
+ if ($expirationDate instanceof Zend_Date) {
81
+ $expirationDate = $expirationDate->toString(Varien_Date::DATETIME_INTERNAL_FORMAT);
82
+ }
83
+
84
+ $coupon->setId(null)
85
+ ->setRuleId($this->getRuleId())
86
+ ->setUsageLimit($this->getUsesPerCoupon())
87
+ ->setUsagePerCustomer($this->getUsesPerCustomer())
88
+ ->setExpirationDate($expirationDate)
89
+ ->setCreatedAt($now)
90
+ ->setType(Mage_SalesRule_Helper_Coupon::COUPON_TYPE_SPECIFIC_AUTOGENERATED)
91
+ ->setCode($code)
92
+ ->save();
93
+
94
+ $this->_generatedCount++;
95
+ }
96
+ return $code;
97
+ }
98
+
99
+ }
app/code/local/Grazitti/Promotions/Model/Mysql4/Promotion.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Grazitti_Promotion_Model_Mysql4_Promotion extends Mage_Core_Model_Mysql4_Abstract
4
+ {
5
+ public function _construct()
6
+ {
7
+ // Note that the promotion_id refers to the key field in your database table.
8
+ $this->_init('promotion/promotion', 'promotion_id');
9
+ }
10
+ }
app/code/local/Grazitti/Promotions/Model/Mysql4/Promotion/Collection.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Grazitti_Promotion_Model_Mysql4_Promotion_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
4
+ {
5
+ public function _construct()
6
+ {
7
+ parent::_construct();
8
+ $this->_init('promotion/promotion');
9
+ }
10
+ }
app/code/local/Grazitti/Promotions/Model/Mysql4/Promotions.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Grazitti_Promotions_Model_Mysql4_Promotions extends Mage_Core_Model_Mysql4_Abstract
4
+ {
5
+ public function _construct()
6
+ {
7
+ // Note that the promotions_id refers to the key field in your database table.
8
+ $this->_init('promotions/promotions', 'promotions_id');
9
+ }
10
+ }
app/code/local/Grazitti/Promotions/Model/Mysql4/Promotions/Collection.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Grazitti_Promotions_Model_Mysql4_Promotions_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
4
+ {
5
+ public function _construct()
6
+ {
7
+ parent::_construct();
8
+ $this->_init('promotions/promotions');
9
+ }
10
+ }
app/code/local/Grazitti/Promotions/Model/Observer.php ADDED
@@ -0,0 +1,96 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Grazitti_Promotions_Model_Observer {
4
+
5
+ public function customerRegisterSuccess(Varien_Event_Observer $observer)
6
+ {
7
+ $enable = Mage::getStoreConfig('grazitti/general/enable');
8
+ $confirmation = Mage::getStoreConfig('customer/create_account/confirm');
9
+ /* check module is enable and confirmation is not required */
10
+ if($enable && !$confirmation)
11
+ {
12
+ $customer = $observer->getEvent()->getCustomer();
13
+ $customerName = $customer->getname();
14
+ $customerEmail = $customer->getEmail();
15
+ $PromotionCode= $this->generateCode();
16
+ $this->sendTransactionalEmail($customerEmail,$customerName,$PromotionCode);
17
+
18
+ }
19
+ }
20
+ public function customerSaveAfter(Varien_Event_Observer $observer)
21
+ {
22
+ $enable = Mage::getStoreConfig('grazitti/general/enable');
23
+ $confirmation = Mage::getStoreConfig('customer/create_account/confirm');
24
+
25
+ if($enable && $confirmation)
26
+ {
27
+ $customerData = $observer->getEvent()->getCustomer();
28
+ $customerName = $customerData->getname();
29
+ $customerEmail = $customerData->getEmail();
30
+ $PromotionCode= $this->generateCode();
31
+ $this->sendTransactionalEmail($customerEmail,$customerName,$PromotionCode);
32
+
33
+ }
34
+ }
35
+ Public function generateCode()
36
+ {
37
+ /* Coupon Generate Code */
38
+ $generator = new Grazitti_Promotions_Model_Massgenerator();
39
+ $days = Mage::getStoreConfig('grazitti/general/days');
40
+ $currentdate = new Zend_Date(Mage::getModel('core/date')->timestamp());
41
+ $currentdate->addDay($days);
42
+ $currentdate->toString('Y-m-d H:i:s'); //Returns representation of date
43
+ $ruleId = Mage::getStoreConfig('grazitti/general/rules');
44
+
45
+ $data = array(
46
+ 'max_probability' => .25,
47
+ 'max_attempts' => 10,
48
+ 'uses_per_customer' => 1,
49
+ 'uses_per_coupon' => 1,
50
+ 'qty' => 1, //number of coupons to generate
51
+ 'length' => 14, //length of coupon string
52
+ 'to_date' => $currentdate, //ending date of generated promo
53
+ 'format' => Mage_SalesRule_Helper_Coupon::COUPON_FORMAT_ALPHANUMERIC,
54
+ 'rule_id' => $ruleId //the id of the rule you will use as a template
55
+ );
56
+ $generator->validateData($data);
57
+ $generator->setData($data);
58
+ $couponCode = $generator->generatePool();
59
+ return $couponCode;
60
+ }
61
+ public function sendTransactionalEmail($customerEmail,$customerName,$PromotionCode)
62
+ {
63
+ // set the Transactional Email Template's ID that you've created...
64
+ $emailtemplate = Mage::getStoreConfig('grazitti/general/template');
65
+ /*check test and live mode */
66
+ $modevalue = Mage::getStoreConfig('grazitti/general/mode');
67
+ $testemail = Mage::getStoreConfig('grazitti/general/email');
68
+
69
+ if($modevalue)
70
+ {
71
+ $recepientEmail = $testemail;
72
+ }else{
73
+ $recepientEmail = $customerEmail;
74
+ }
75
+
76
+ $templateId = $emailtemplate;
77
+ // Set sender information
78
+ $senderName = Mage::getStoreConfig('trans_email/ident_support/name');
79
+ $senderEmail = Mage::getStoreConfig('trans_email/ident_support/email');
80
+ $sender = array('name' => $senderName,
81
+ 'email' => $senderEmail);
82
+ // Set recepient information
83
+ $recepientName = $customerName;
84
+
85
+ // Set variables that can be used in email template. To get this variable write like {{var customerEmail}} in transactional Email.
86
+ $vars = array('coupon code' => $PromotionCode);
87
+ $translate = Mage::getSingleton('core/translate');
88
+ // Send Transactional Email
89
+ Mage::getModel('core/email_template')->sendTransactional($templateId, $sender, $recepientEmail, $recepientName, $vars);
90
+
91
+ $translate->setTranslateInline(true);
92
+
93
+
94
+ }
95
+ }
96
+
app/code/local/Grazitti/Promotions/Model/Promotion.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Grazitti_Promotion_Model_Promotion extends Mage_Core_Model_Abstract
4
+ {
5
+ public function _construct()
6
+ {
7
+ parent::_construct();
8
+ $this->_init('promotion/promotion');
9
+ }
10
+ }
app/code/local/Grazitti/Promotions/Model/Promotions.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Grazitti_Promotions_Model_Promotions extends Mage_Core_Model_Abstract
4
+ {
5
+ public function _construct()
6
+ {
7
+ parent::_construct();
8
+ $this->_init('promotions/promotions');
9
+ }
10
+ }
app/code/local/Grazitti/Promotions/Model/Status.php ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Grazitti_Promotions_Model_Status extends Varien_Object
4
+ {
5
+ const STATUS_ENABLED = 1;
6
+ const STATUS_DISABLED = 2;
7
+
8
+ static public function getOptionArray()
9
+ {
10
+ return array(
11
+ self::STATUS_ENABLED => Mage::helper('promotions')->__('Enabled'),
12
+ self::STATUS_DISABLED => Mage::helper('promotions')->__('Disabled')
13
+ );
14
+ }
15
+ }
app/code/local/Grazitti/Promotions/Model/System/Config/Source/salerules.php ADDED
@@ -0,0 +1,81 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magento.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magento.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2006-2015 X.commerce, Inc. (http://www.magento.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Used in creating options for Yes|No config value selection
29
+ *
30
+ */
31
+ class Grazitti_Promotions_Model_System_Config_Source_salerules
32
+ {
33
+
34
+ /**
35
+ * Options getter
36
+ *
37
+ * @return array
38
+ */
39
+ /* public function toOptionArray()
40
+ {
41
+
42
+ $rulesCollection = Mage::getModel('salesrule/rule')->getCollection();
43
+ foreach($rulesCollection as $rule)
44
+ {
45
+ $name = $rule->getname();
46
+ }
47
+
48
+ return array(
49
+ array('value' => 1, 'label'=>Mage::helper('adminhtml')->__('Yes23')),
50
+ array('value' => 0, 'label'=>Mage::helper('adminhtml')->__('No')),
51
+ );
52
+ }
53
+ */
54
+ public function toOptionArray()
55
+ {
56
+ $rulesCollection = Mage::getModel('salesrule/rule')->getCollection()
57
+ ->addFieldToSelect('name')
58
+ ->addFieldToSelect('rule_id')
59
+ ->addFieldToFilter('is_active',1)
60
+ ->getData();
61
+ //echo'<pre>'; print_r($rulesCollection); die;
62
+ $salesrule = array();
63
+ if(!$rulesCollection){
64
+ $salesrule[] = array(
65
+ 'label' => 'Please create shopping cart price rule',
66
+ 'value' => '-1'
67
+ );
68
+ }else{
69
+ foreach($rulesCollection as $rule)
70
+ {
71
+ $salesrule[] = array(
72
+ 'label' => $rule['name'],
73
+ 'value' => $rule['rule_id']
74
+ );
75
+ }
76
+ }
77
+ return $salesrule;
78
+
79
+
80
+ }
81
+ }
app/code/local/Grazitti/Promotions/controllers/Adminhtml/PromotionController.php ADDED
@@ -0,0 +1,234 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Grazitti_Promotion_Adminhtml_PromotionController extends Mage_Adminhtml_Controller_action
4
+ {
5
+
6
+ protected function _initAction() {
7
+ $this->loadLayout()
8
+ ->_setActiveMenu('promotion/items')
9
+ ->_addBreadcrumb(Mage::helper('adminhtml')->__('Items Manager'), Mage::helper('adminhtml')->__('Item Manager'));
10
+
11
+ return $this;
12
+ }
13
+
14
+ public function indexAction() {
15
+ $this->_initAction()
16
+ ->renderLayout();
17
+ }
18
+ public function customergridAction(){
19
+ $this->loadLayout();
20
+ $this->getLayout()->getBlock('customer.grid')
21
+ ->setCustomers($this->getRequest()->getPost('customers', null));
22
+ $this->renderLayout();
23
+ }
24
+ public function editAction() {
25
+ $id = $this->getRequest()->getParam('id');
26
+ $model = Mage::getModel('promotion/promotion')->load($id);
27
+
28
+ if ($model->getId() || $id == 0) {
29
+ $data = Mage::getSingleton('adminhtml/session')->getFormData(true);
30
+ if (!empty($data)) {
31
+ $model->setData($data);
32
+ }
33
+
34
+ Mage::register('promotion_data', $model);
35
+
36
+ $this->loadLayout();
37
+ $this->_setActiveMenu('promotion/items');
38
+
39
+ $this->_addBreadcrumb(Mage::helper('adminhtml')->__('Item Manager'), Mage::helper('adminhtml')->__('Item Manager'));
40
+ $this->_addBreadcrumb(Mage::helper('adminhtml')->__('Item News'), Mage::helper('adminhtml')->__('Item News'));
41
+
42
+ $this->getLayout()->getBlock('head')->setCanLoadExtJs(true);
43
+
44
+ $this->_addContent($this->getLayout()->createBlock('promotion/adminhtml_promotion_edit'))
45
+ ->_addLeft($this->getLayout()->createBlock('promotion/adminhtml_promotion_edit_tabs'));
46
+
47
+ $this->renderLayout();
48
+ } else {
49
+ Mage::getSingleton('adminhtml/session')->addError(Mage::helper('promotion')->__('Item does not exist'));
50
+ $this->_redirect('*/*/');
51
+ }
52
+ }
53
+
54
+ public function newAction() {
55
+ $this->_forward('edit');
56
+ }
57
+
58
+ public function saveAction() {
59
+
60
+ // if(isset($data['links'])){
61
+ // $customers = Mage::helper('adminhtml/js')->decodeGridSerializedInput($data['links']['customers']); //Save the array to your database
62
+
63
+ // }
64
+
65
+ if ($data = $this->getRequest()->getPost()) {
66
+
67
+ if(isset($_FILES['filename']['name']) && $_FILES['filename']['name'] != '') {
68
+ try {
69
+ /* Starting upload */
70
+ $uploader = new Varien_File_Uploader('filename');
71
+
72
+ // Any extention would work
73
+ $uploader->setAllowedExtensions(array('jpg','jpeg','gif','png'));
74
+ $uploader->setAllowRenameFiles(false);
75
+
76
+ // Set the file upload mode
77
+ // false -> get the file directly in the specified folder
78
+ // true -> get the file in the product like folders
79
+ // (file.jpg will go in something like /media/f/i/file.jpg)
80
+ $uploader->setFilesDispersion(false);
81
+
82
+ // We set media as the upload dir
83
+ $path = Mage::getBaseDir('media') . DS ;
84
+ $uploader->save($path, $_FILES['filename']['name'] );
85
+
86
+ } catch (Exception $e) {
87
+
88
+ }
89
+
90
+ //this way the name is saved in DB
91
+ $data['filename'] = $_FILES['filename']['name'];
92
+ }
93
+
94
+
95
+ $model = Mage::getModel('promotion/promotion');
96
+ $model->setData($data)
97
+ ->setId($this->getRequest()->getParam('id'));
98
+
99
+ try {
100
+ if ($model->getCreatedTime == NULL || $model->getUpdateTime() == NULL) {
101
+ $model->setCreatedTime(now())
102
+ ->setUpdateTime(now());
103
+ } else {
104
+ $model->setUpdateTime(now());
105
+ }
106
+ if(isset($data['links'])){
107
+ $customers = Mage::helper('adminhtml/js')->decodeGridSerializedInput($data['links']['customers']); //Save the array to your database
108
+
109
+ }
110
+
111
+ $model->save();
112
+ echo '<pre>';print_r($model); die;
113
+
114
+ Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('promotion')->__('Item was successfully saved'));
115
+
116
+ Mage::getSingleton('adminhtml/session')->setFormData(false);
117
+
118
+ if ($this->getRequest()->getParam('back')) {
119
+ $this->_redirect('*/*/edit', array('id' => $model->getId()));
120
+ return;
121
+ }
122
+ $this->_redirect('*/*/');
123
+ return;
124
+ } catch (Exception $e) {
125
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
126
+ Mage::getSingleton('adminhtml/session')->setFormData($data);
127
+ $this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id')));
128
+ return;
129
+ }
130
+ }
131
+ Mage::getSingleton('adminhtml/session')->addError(Mage::helper('promotion')->__('Unable to find item to save'));
132
+ $this->_redirect('*/*/');
133
+ }
134
+
135
+ public function deleteAction() {
136
+ if( $this->getRequest()->getParam('id') > 0 ) {
137
+ try {
138
+ $model = Mage::getModel('promotion/promotion');
139
+
140
+ $model->setId($this->getRequest()->getParam('id'))
141
+ ->delete();
142
+
143
+ Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('adminhtml')->__('Item was successfully deleted'));
144
+ $this->_redirect('*/*/');
145
+ } catch (Exception $e) {
146
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
147
+ $this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id')));
148
+ }
149
+ }
150
+ $this->_redirect('*/*/');
151
+ }
152
+
153
+ public function massDeleteAction() {
154
+ $promotionIds = $this->getRequest()->getParam('promotion');
155
+ if(!is_array($promotionIds)) {
156
+ Mage::getSingleton('adminhtml/session')->addError(Mage::helper('adminhtml')->__('Please select item(s)'));
157
+ } else {
158
+ try {
159
+ foreach ($promotionIds as $promotionId) {
160
+ $promotion = Mage::getModel('promotion/promotion')->load($promotionId);
161
+ $promotion->delete();
162
+ }
163
+ Mage::getSingleton('adminhtml/session')->addSuccess(
164
+ Mage::helper('adminhtml')->__(
165
+ 'Total of %d record(s) were successfully deleted', count($promotionIds)
166
+ )
167
+ );
168
+ } catch (Exception $e) {
169
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
170
+ }
171
+ }
172
+ $this->_redirect('*/*/index');
173
+ }
174
+
175
+ public function massStatusAction()
176
+ {
177
+ $promotionIds = $this->getRequest()->getParam('promotion');
178
+ if(!is_array($promotionIds)) {
179
+ Mage::getSingleton('adminhtml/session')->addError($this->__('Please select item(s)'));
180
+ } else {
181
+ try {
182
+ foreach ($promotionIds as $promotionId) {
183
+ $promotion = Mage::getSingleton('promotion/promotion')
184
+ ->load($promotionId)
185
+ ->setStatus($this->getRequest()->getParam('status'))
186
+ ->setIsMassupdate(true)
187
+ ->save();
188
+ }
189
+ $this->_getSession()->addSuccess(
190
+ $this->__('Total of %d record(s) were successfully updated', count($promotionIds))
191
+ );
192
+ } catch (Exception $e) {
193
+ $this->_getSession()->addError($e->getMessage());
194
+ }
195
+ }
196
+ $this->_redirect('*/*/index');
197
+ }
198
+
199
+ public function exportCsvAction()
200
+ {
201
+ $fileName = 'promotion.csv';
202
+ $content = $this->getLayout()->createBlock('promotion/adminhtml_promotion_grid')
203
+ ->getCsv();
204
+
205
+ $this->_sendUploadResponse($fileName, $content);
206
+ }
207
+
208
+ public function exportXmlAction()
209
+ {
210
+ $fileName = 'promotion.xml';
211
+ $content = $this->getLayout()->createBlock('promotion/adminhtml_promotion_grid')
212
+ ->getXml();
213
+
214
+ $this->_sendUploadResponse($fileName, $content);
215
+ }
216
+
217
+ protected function _sendUploadResponse($fileName, $content, $contentType='application/octet-stream')
218
+ {
219
+ $response = $this->getResponse();
220
+ $response->setHeader('HTTP/1.1 200 OK','');
221
+ $response->setHeader('Pragma', 'public', true);
222
+ $response->setHeader('Cache-Control', 'must-revalidate, post-check=0, pre-check=0', true);
223
+ $response->setHeader('Content-Disposition', 'attachment; filename='.$fileName);
224
+ $response->setHeader('Last-Modified', date('r'));
225
+ $response->setHeader('Accept-Ranges', 'bytes');
226
+ $response->setHeader('Content-Length', strlen($content));
227
+ $response->setHeader('Content-type', $contentType);
228
+ $response->setBody($content);
229
+ $response->sendResponse();
230
+ die;
231
+ }
232
+
233
+
234
+ }
app/code/local/Grazitti/Promotions/controllers/Adminhtml/PromotionsController.php ADDED
@@ -0,0 +1,228 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Grazitti_Promotions_Adminhtml_PromotionsController extends Mage_Adminhtml_Controller_action
4
+ {
5
+
6
+ protected function _initAction() {
7
+ $this->loadLayout()
8
+ ->_setActiveMenu('promotions/items')
9
+ ->_addBreadcrumb(Mage::helper('adminhtml')->__('Items Manager'), Mage::helper('adminhtml')->__('Item Manager'));
10
+
11
+ return $this;
12
+ }
13
+ public function customerAction(){
14
+ $this->loadLayout();
15
+ $this->getLayout()->getBlock('customer.grid')
16
+ ->setCustomers($this->getRequest()->getPost('customers', null));
17
+ $this->renderLayout();
18
+ }
19
+ public function customergridAction(){
20
+ $this->loadLayout();
21
+ $this->getLayout()->getBlock('customer.grid')
22
+ ->setCustomers($this->getRequest()->getPost('customers', null));
23
+ $this->renderLayout();
24
+ }
25
+
26
+ public function indexAction() {
27
+ $this->_initAction()
28
+ ->renderLayout();
29
+ }
30
+
31
+ public function editAction() {
32
+ $id = $this->getRequest()->getParam('id');
33
+ $model = Mage::getModel('promotions/promotions')->load($id);
34
+
35
+ if ($model->getId() || $id == 0) {
36
+ $data = Mage::getSingleton('adminhtml/session')->getFormData(true);
37
+ if (!empty($data)) {
38
+ $model->setData($data);
39
+ }
40
+
41
+ Mage::register('promotions_data', $model);
42
+
43
+ $this->loadLayout();
44
+ $this->_setActiveMenu('promotions/items');
45
+
46
+ $this->_addBreadcrumb(Mage::helper('adminhtml')->__('Item Manager'), Mage::helper('adminhtml')->__('Item Manager'));
47
+ $this->_addBreadcrumb(Mage::helper('adminhtml')->__('Item News'), Mage::helper('adminhtml')->__('Item News'));
48
+
49
+ $this->getLayout()->getBlock('head')->setCanLoadExtJs(true);
50
+
51
+ $this->_addContent($this->getLayout()->createBlock('promotions/adminhtml_promotions_edit'))
52
+ ->_addLeft($this->getLayout()->createBlock('promotions/adminhtml_promotions_edit_tabs'));
53
+
54
+ $this->renderLayout();
55
+ } else {
56
+ Mage::getSingleton('adminhtml/session')->addError(Mage::helper('promotions')->__('Item does not exist'));
57
+ $this->_redirect('*/*/');
58
+ }
59
+ }
60
+
61
+ public function newAction() {
62
+ $this->_forward('edit');
63
+ }
64
+
65
+ public function saveAction() {
66
+ if ($data = $this->getRequest()->getPost()) {
67
+
68
+ if(isset($_FILES['filename']['name']) && $_FILES['filename']['name'] != '') {
69
+ try {
70
+ /* Starting upload */
71
+ $uploader = new Varien_File_Uploader('filename');
72
+
73
+ // Any extention would work
74
+ $uploader->setAllowedExtensions(array('jpg','jpeg','gif','png'));
75
+ $uploader->setAllowRenameFiles(false);
76
+
77
+ // Set the file upload mode
78
+ // false -> get the file directly in the specified folder
79
+ // true -> get the file in the product like folders
80
+ // (file.jpg will go in something like /media/f/i/file.jpg)
81
+ $uploader->setFilesDispersion(false);
82
+
83
+ // We set media as the upload dir
84
+ $path = Mage::getBaseDir('media') . DS ;
85
+ $uploader->save($path, $_FILES['filename']['name'] );
86
+
87
+ } catch (Exception $e) {
88
+
89
+ }
90
+
91
+ //this way the name is saved in DB
92
+ $data['filename'] = $_FILES['filename']['name'];
93
+ }
94
+
95
+
96
+ $model = Mage::getModel('promotions/promotions');
97
+ $model->setData($data)
98
+ ->setId($this->getRequest()->getParam('id'));
99
+
100
+ try {
101
+ if ($model->getCreatedTime == NULL || $model->getUpdateTime() == NULL) {
102
+ $model->setCreatedTime(now())
103
+ ->setUpdateTime(now());
104
+ } else {
105
+ $model->setUpdateTime(now());
106
+ }
107
+
108
+ $model->save();
109
+ Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('promotions')->__('Item was successfully saved'));
110
+ Mage::getSingleton('adminhtml/session')->setFormData(false);
111
+
112
+ if ($this->getRequest()->getParam('back')) {
113
+ $this->_redirect('*/*/edit', array('id' => $model->getId()));
114
+ return;
115
+ }
116
+ $this->_redirect('*/*/');
117
+ return;
118
+ } catch (Exception $e) {
119
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
120
+ Mage::getSingleton('adminhtml/session')->setFormData($data);
121
+ $this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id')));
122
+ return;
123
+ }
124
+ }
125
+ Mage::getSingleton('adminhtml/session')->addError(Mage::helper('promotions')->__('Unable to find item to save'));
126
+ $this->_redirect('*/*/');
127
+ }
128
+
129
+ public function deleteAction() {
130
+ if( $this->getRequest()->getParam('id') > 0 ) {
131
+ try {
132
+ $model = Mage::getModel('promotions/promotions');
133
+
134
+ $model->setId($this->getRequest()->getParam('id'))
135
+ ->delete();
136
+
137
+ Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('adminhtml')->__('Item was successfully deleted'));
138
+ $this->_redirect('*/*/');
139
+ } catch (Exception $e) {
140
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
141
+ $this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id')));
142
+ }
143
+ }
144
+ $this->_redirect('*/*/');
145
+ }
146
+
147
+ public function massDeleteAction() {
148
+ $promotionsIds = $this->getRequest()->getParam('promotions');
149
+ if(!is_array($promotionsIds)) {
150
+ Mage::getSingleton('adminhtml/session')->addError(Mage::helper('adminhtml')->__('Please select item(s)'));
151
+ } else {
152
+ try {
153
+ foreach ($promotionsIds as $promotionsId) {
154
+ $promotions = Mage::getModel('promotions/promotions')->load($promotionsId);
155
+ $promotions->delete();
156
+ }
157
+ Mage::getSingleton('adminhtml/session')->addSuccess(
158
+ Mage::helper('adminhtml')->__(
159
+ 'Total of %d record(s) were successfully deleted', count($promotionsIds)
160
+ )
161
+ );
162
+ } catch (Exception $e) {
163
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
164
+ }
165
+ }
166
+ $this->_redirect('*/*/index');
167
+ }
168
+
169
+ public function massStatusAction()
170
+ {
171
+ $promotionsIds = $this->getRequest()->getParam('promotions');
172
+ if(!is_array($promotionsIds)) {
173
+ Mage::getSingleton('adminhtml/session')->addError($this->__('Please select item(s)'));
174
+ } else {
175
+ try {
176
+ foreach ($promotionsIds as $promotionsId) {
177
+ $promotions = Mage::getSingleton('promotions/promotions')
178
+ ->load($promotionsId)
179
+ ->setStatus($this->getRequest()->getParam('status'))
180
+ ->setIsMassupdate(true)
181
+ ->save();
182
+ }
183
+ $this->_getSession()->addSuccess(
184
+ $this->__('Total of %d record(s) were successfully updated', count($promotionsIds))
185
+ );
186
+ } catch (Exception $e) {
187
+ $this->_getSession()->addError($e->getMessage());
188
+ }
189
+ }
190
+ $this->_redirect('*/*/index');
191
+ }
192
+
193
+ public function exportCsvAction()
194
+ {
195
+ $fileName = 'promotions.csv';
196
+ $content = $this->getLayout()->createBlock('promotions/adminhtml_promotions_grid')
197
+ ->getCsv();
198
+
199
+ $this->_sendUploadResponse($fileName, $content);
200
+ }
201
+
202
+ public function exportXmlAction()
203
+ {
204
+ $fileName = 'promotions.xml';
205
+ $content = $this->getLayout()->createBlock('promotions/adminhtml_promotions_grid')
206
+ ->getXml();
207
+
208
+ $this->_sendUploadResponse($fileName, $content);
209
+ }
210
+
211
+ protected function _sendUploadResponse($fileName, $content, $contentType='application/octet-stream')
212
+ {
213
+ $response = $this->getResponse();
214
+ $response->setHeader('HTTP/1.1 200 OK','');
215
+ $response->setHeader('Pragma', 'public', true);
216
+ $response->setHeader('Cache-Control', 'must-revalidate, post-check=0, pre-check=0', true);
217
+ $response->setHeader('Content-Disposition', 'attachment; filename='.$fileName);
218
+ $response->setHeader('Last-Modified', date('r'));
219
+ $response->setHeader('Accept-Ranges', 'bytes');
220
+ $response->setHeader('Content-Length', strlen($content));
221
+ $response->setHeader('Content-type', $contentType);
222
+ $response->setBody($content);
223
+ $response->sendResponse();
224
+ die;
225
+ }
226
+
227
+
228
+ }
app/code/local/Grazitti/Promotions/controllers/IndexController.php ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Grazitti_Promotions_IndexController extends Mage_Core_Controller_Front_Action
3
+ {
4
+ public function indexAction()
5
+ {
6
+
7
+ /*
8
+ * Load an object by id
9
+ * Request looking like:
10
+ * http://site.com/promotions?id=15
11
+ * or
12
+ * http://site.com/promotions/id/15
13
+ */
14
+ /*
15
+ $promotions_id = $this->getRequest()->getParam('id');
16
+
17
+ if($promotions_id != null && $promotions_id != '') {
18
+ $promotions = Mage::getModel('promotions/promotions')->load($promotions_id)->getData();
19
+ } else {
20
+ $promotions = null;
21
+ }
22
+ */
23
+
24
+ /*
25
+ * If no param we load a the last created item
26
+ */
27
+ /*
28
+ if($promotions == null) {
29
+ $resource = Mage::getSingleton('core/resource');
30
+ $read= $resource->getConnection('core_read');
31
+ $promotionsTable = $resource->getTableName('promotions');
32
+
33
+ $select = $read->select()
34
+ ->from($promotionsTable,array('promotions_id','title','content','status'))
35
+ ->where('status',1)
36
+ ->order('created_time DESC') ;
37
+
38
+ $promotions = $read->fetchRow($select);
39
+ }
40
+ Mage::register('promotions', $promotions);
41
+ */
42
+
43
+
44
+ $this->loadLayout();
45
+ $this->renderLayout();
46
+ }
47
+ }
app/code/local/Grazitti/Promotions/etc/config.xml ADDED
@@ -0,0 +1,156 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * @category Grazitti
5
+ * @package Grazitti_Promotions
6
+ * @author ModuleCreator
7
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
8
+ */
9
+ -->
10
+ <config>
11
+ <modules>
12
+ <Grazitti_Promotions>
13
+ <version>0.1.0</version>
14
+ <active>true</active>
15
+ <codePool>local</codePool>
16
+ </Grazitti_Promotions>
17
+ </modules>
18
+ <frontend>
19
+ <routers>
20
+ <promotions>
21
+ <use>standard</use>
22
+ <args>
23
+ <module>Grazitti_Promotions</module>
24
+ <frontName>promotions</frontName>
25
+ </args>
26
+ </promotions>
27
+ </routers>
28
+ <layout>
29
+ <updates>
30
+ <promotions>
31
+ <file>promotions.xml</file>
32
+ </promotions>
33
+ </updates>
34
+ </layout>
35
+ </frontend>
36
+ <admin>
37
+ <routers>
38
+ <promotions>
39
+ <use>admin</use>
40
+ <args>
41
+ <module>Grazitti_Promotions</module>
42
+ <frontName>promotions</frontName>
43
+ </args>
44
+ </promotions>
45
+ </routers>
46
+ </admin>
47
+ <adminhtml>
48
+ <menu>
49
+ <promotions module="promotions">
50
+ <title>Promotions</title>
51
+ <sort_order>71</sort_order>
52
+ <children>
53
+ <items module="promotions">
54
+ <title>Manage Items</title>
55
+ <sort_order>0</sort_order>
56
+ <action>promotions/adminhtml_promotions</action>
57
+ </items>
58
+ </children>
59
+ </promotions>
60
+ </menu>
61
+ <acl>
62
+ <resources>
63
+ <admin> <!--This is acl based on URL. If you see URL it would be /admin/system_config/ -->
64
+ <children>
65
+ <system>
66
+ <children>
67
+ <config>
68
+ <children>
69
+ <grazitti translate="title" module="promotions"> <!-- This is name of the section created by us -->
70
+ <title>Test Section ACL</title> <!-- Title as shown in User->Roles->Permissions Window -->
71
+ <sort_order>99</sort_order>
72
+ </grazitti>
73
+ </children>
74
+ </config>
75
+ </children>
76
+ </system>
77
+ </children>
78
+ </admin>
79
+ </resources>
80
+ </acl>
81
+ <layout>
82
+ <updates>
83
+ <promotions>
84
+ <file>promotions.xml</file>
85
+ </promotions>
86
+ </updates>
87
+ </layout>
88
+ </adminhtml>
89
+
90
+ <global>
91
+ <models>
92
+ <promotions>
93
+ <class>Grazitti_Promotions_Model</class>
94
+ <resourceModel>promotions_mysql4</resourceModel>
95
+ </promotions>
96
+ <promotions_mysql4>
97
+ <class>Grazitti_Promotions_Model_Mysql4</class>
98
+ <entities>
99
+ <promotions>
100
+ <table>promotions</table>
101
+ </promotions>
102
+ </entities>
103
+ </promotions_mysql4>
104
+ </models>
105
+ <events>
106
+ <customer_register_success>
107
+ <observers>
108
+ <Grazitti_Promotions_Model_Observer>
109
+ <type>singleton</type>
110
+ <class>Grazitti_Promotions_Model_Observer</class>
111
+ <method>customerRegisterSuccess</method>
112
+ </Grazitti_Promotions_Model_Observer>
113
+ </observers>
114
+ </customer_register_success>
115
+ <customer_save_after>
116
+ <observers>
117
+ <Grazitti_Promotions_Model_Observer>
118
+ <type>singleton</type>
119
+ <class>Grazitti_Promotions_Model_Observer</class>
120
+ <method>customerSaveAfter</method>
121
+ </Grazitti_Promotions_Model_Observer>
122
+ </observers>
123
+ </customer_save_after>
124
+ </events>
125
+ <resources>
126
+ <promotions_setup>
127
+ <setup>
128
+ <module>Grazitti_Promotions</module>
129
+ </setup>
130
+ <connection>
131
+ <use>core_setup</use>
132
+ </connection>
133
+ </promotions_setup>
134
+ <promotions_write>
135
+ <connection>
136
+ <use>core_write</use>
137
+ </connection>
138
+ </promotions_write>
139
+ <promotions_read>
140
+ <connection>
141
+ <use>core_read</use>
142
+ </connection>
143
+ </promotions_read>
144
+ </resources>
145
+ <blocks>
146
+ <promotions>
147
+ <class>Grazitti_Promotions_Block</class>
148
+ </promotions>
149
+ </blocks>
150
+ <helpers>
151
+ <promotions>
152
+ <class>Grazitti_Promotions_Helper</class>
153
+ </promotions>
154
+ </helpers>
155
+ </global>
156
+ </config>
app/code/local/Grazitti/Promotions/etc/system.xml ADDED
@@ -0,0 +1,87 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" ?>
2
+ <config>
3
+ <tabs>
4
+ <news translate="label" module="promotions">
5
+ <label>Grazitti Interactive</label>
6
+ <sort_order>10</sort_order>
7
+ </news>
8
+ </tabs>
9
+ <sections>
10
+ <grazitti translate="label" module="promotions">
11
+ <label>Sign UP Promotions</label>
12
+ <tab>news</tab>
13
+ <frontend_type>text</frontend_type>
14
+ <sort_order>120</sort_order>
15
+ <show_in_default>1</show_in_default>
16
+ <show_in_website>1</show_in_website>
17
+ <show_in_store>1</show_in_store>
18
+ <groups>
19
+ <general>
20
+ <label>General Settings</label>
21
+ <frontend_type>text</frontend_type>
22
+ <sort_order>10</sort_order>
23
+ <show_in_default>1</show_in_default>
24
+ <show_in_website>1</show_in_website>
25
+ <show_in_store>1</show_in_store>
26
+ <fields>
27
+ <days translate="label">
28
+ <label>Days</label>
29
+ <comment></comment>
30
+ <frontend_type>text</frontend_type>
31
+ <sort_order>10</sort_order>
32
+ <show_in_default>1</show_in_default>
33
+ <show_in_website>1</show_in_website>
34
+ <show_in_store>1</show_in_store>
35
+ </days>
36
+ <rules translate="label">
37
+ <label>Shopping cart price rules</label>
38
+ <frontend_type>select</frontend_type>
39
+ <source_model>Grazitti_Promotions_Model_System_Config_Source_salerules</source_model>
40
+ <sort_order>1</sort_order>
41
+ <show_in_default>1</show_in_default>
42
+ <show_in_website>1</show_in_website>
43
+ <show_in_store>1</show_in_store>
44
+ </rules>
45
+ <template translate="label">
46
+ <label>Template</label>
47
+ <frontend_type>select</frontend_type>
48
+ <source_model>adminhtml/system_config_source_email_template</source_model>
49
+ <sort_order>11</sort_order>
50
+ <show_in_default>1</show_in_default>
51
+ <show_in_website>1</show_in_website>
52
+ <show_in_store>1</show_in_store>
53
+ </template>
54
+ <mode translate="label">
55
+ <label>Test Mode</label>
56
+ <comment>For Test/Live Mode</comment>
57
+ <frontend_type>select</frontend_type>
58
+ <source_model>adminhtml/system_config_source_YesNo</source_model>
59
+ <sort_order>12</sort_order>
60
+ <show_in_default>1</show_in_default>
61
+ <show_in_website>1</show_in_website>
62
+ <show_in_store>1</show_in_store>
63
+ </mode>
64
+ <email translate="label">
65
+ <label>Email</label>
66
+ <comment></comment>
67
+ <frontend_type>text</frontend_type>
68
+ <sort_order>13</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
+ </email>
73
+ <enable translate="label">
74
+ <label>Enable</label>
75
+ <frontend_type>select</frontend_type>
76
+ <source_model>adminhtml/system_config_source_YesNo</source_model>
77
+ <sort_order>1</sort_order>
78
+ <show_in_default>1</show_in_default>
79
+ <show_in_website>1</show_in_website>
80
+ <show_in_store>1</show_in_store>
81
+ </enable>
82
+ </fields>
83
+ </general>
84
+ </groups>
85
+ </grazitti>
86
+ </sections>
87
+ </config>
app/code/local/Grazitti/Promotions/sql/promotion_setup/mysql4-install-0.1.0.php ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ $installer = $this;
4
+
5
+ $installer->startSetup();
6
+
7
+ $installer->run("
8
+
9
+ -- DROP TABLE IF EXISTS {$this->getTable('promotion')};
10
+ CREATE TABLE {$this->getTable('promotion')} (
11
+ `promotion_id` int(11) unsigned NOT NULL auto_increment,
12
+ `title` varchar(255) NOT NULL default '',
13
+ `filename` varchar(255) NOT NULL default '',
14
+ `content` text NOT NULL default '',
15
+ `status` smallint(6) NOT NULL default '0',
16
+ `created_time` datetime NULL,
17
+ `update_time` datetime NULL,
18
+ PRIMARY KEY (`promotion_id`)
19
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
20
+
21
+ ");
22
+
23
+ $installer->endSetup();
app/code/local/Grazitti/Promotions/sql/promotions_setup/mysql4-install-0.1.0.php ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ $installer = $this;
4
+
5
+ $installer->startSetup();
6
+
7
+ $installer->run("
8
+
9
+ -- DROP TABLE IF EXISTS {$this->getTable('promotions')};
10
+ CREATE TABLE {$this->getTable('promotions')} (
11
+ `promotions_id` int(11) unsigned NOT NULL auto_increment,
12
+ `title` varchar(255) NOT NULL default '',
13
+ `filename` varchar(255) NOT NULL default '',
14
+ `content` text NOT NULL default '',
15
+ `status` smallint(6) NOT NULL default '0',
16
+ `created_time` datetime NULL,
17
+ `update_time` datetime NULL,
18
+ PRIMARY KEY (`promotions_id`)
19
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
20
+
21
+ ");
22
+
23
+ $installer->endSetup();
app/design/adminhtml/default/default/layout/promotions.xml ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <layout version="0.1.0">
3
+ <promotions_adminhtml_promotions_index>
4
+ <reference name="content">
5
+ <block type="promotions/adminhtml_promotions" name="promotions" />
6
+ </reference>
7
+ </promotions_adminhtml_promotions_index>
8
+ <promotions_adminhtml_promotions_customer>
9
+ <block type="core/text_list" name="root" output="toHtml">
10
+ <block type="promotions/adminhtml_promotions_edit_tab_grid" name="customer.grid"/>
11
+ <block type="adminhtml/widget_grid_serializer" name="grid_serializer">
12
+ <reference name="grid_serializer">
13
+ <action method="initSerializerBlock">
14
+ <grid_block_name>customer.grid</grid_block_name>
15
+ <data_callback>getSelectedCustomers</data_callback>
16
+ <hidden_input_name>links[customers]</hidden_input_name>
17
+ <reload_param_name>customers</reload_param_name>
18
+ </action>
19
+ <action method="addColumnInputName">
20
+ <input_name>position</input_name>
21
+ </action>
22
+ </reference>
23
+ </block>
24
+ </block>
25
+ </promotions_adminhtml_promotions_customer>
26
+ <promotions_adminhtml_promotions_customergrid>
27
+ <block type="core/text_list" name="root" output="toHtml">
28
+ <block type="promotions/adminhtml_promotions_edit_tab_grid" name="customer.grid"/>
29
+ </block>
30
+ </promotions_adminhtml_promotions_customergrid>
31
+
32
+ </layout>
app/etc/modules/Grazitti_Promotions.xml ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * @category Grazitti
5
+ * @package Grazitti_Promotions
6
+ * @author ModuleCreator
7
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
8
+ */
9
+ -->
10
+ <config>
11
+ <modules>
12
+ <Grazitti_Promotions>
13
+ <active>true</active>
14
+ <codePool>local</codePool>
15
+ </Grazitti_Promotions>
16
+ </modules>
17
+ </config>
package.xml ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>Grazitti_Promotions</name>
4
+ <version>1.0.1</version>
5
+ <stability>stable</stability>
6
+ <license>OSL</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>Sign-up Promotion</summary>
10
+ <description>The Sign-up Promotion Plug-in offers discount functionality by providing random coupon codes for new sign-up customers.</description>
11
+ <notes>First Release</notes>
12
+ <authors><author><name>Mamta</name><user>grazitti</user><email>mamtas@grazitti.com</email></author></authors>
13
+ <date>2016-06-21</date>
14
+ <time>07:25:03</time>
15
+ <contents><target name="magelocal"><dir name="Grazitti"><dir name="Promotions"><dir name="Block"><dir name="Adminhtml"><dir name="Promo"><dir name="Quote"><dir name="Edit"><dir name="Tab"><file name="Grid.php" hash="edec62a62158ad55fcb72bb3f925eb60"/></dir></dir></dir></dir><dir name="Promotion"><dir name="Edit"><file name="Form.php" hash="6c25bc3a392c1b43f585d47ddeeeccbd"/><dir name="Tab"><file name="Form.php" hash="2d572f6922f6555facf242a7ec0860f3"/></dir><file name="Tabs.php" hash="ed2ca198c1b457f5c712079d6709c5b5"/></dir><file name="Edit.php" hash="2a3d09450e1aa37988e27ba050ea7fc1"/><file name="Grid.php" hash="455c7adb4618646fc2e6c5ebbe81b2b5"/></dir><file name="Promotion.php" hash="bca67b9f7ab94d6a9895a2e611c4ecaa"/><dir name="Promotions"><dir name="Edit"><file name="Form.php" hash="df75e41c29ecc694614798f18f15ef43"/><dir name="Tab"><file name="Form.php" hash="bf1af1f8d3f595824797226078be3ef2"/><file name="Grid.php" hash="d8f607bc24254c686a0bc5028f41b7a0"/></dir><file name="Tabs.php" hash="56247e23daffe796450c9c80e6f28f9b"/></dir><file name="Edit.php" hash="5e2c6124d2ccaef5bed70089fb330848"/><file name="Grid.php" hash="aa8f61900cdafaa22e8fca9a0ce72f38"/></dir><file name="Promotions.php" hash="14a225688b3806318764ac3d02073132"/></dir><file name="Promotion.php" hash="682af36b3e1d5360c9585c17a5b2c6c4"/><file name="Promotions.php" hash="10c8ed1f379ec2e115e1f99cb46aa95d"/></dir><dir name="Helper"><file name="Data.php" hash="47d05081d1c5736276cf1f8cd04e7e5e"/></dir><dir name="Model"><file name="Massgenerator.php" hash="5644d7e34e64e32a625220e265f91107"/><dir name="Mysql4"><dir name="Promotion"><file name="Collection.php" hash="896cd729eba97c037910fc402e8d6b89"/></dir><file name="Promotion.php" hash="bac247b3a5636ee3c23fc43e699ef567"/><dir name="Promotions"><file name="Collection.php" hash="7bfdc803707362c915dbe6993af5c202"/></dir><file name="Promotions.php" hash="5e1b59bd648ac820469b294be7a0ff8c"/></dir><file name="Observer.php" hash="88875e01042eff6bb0efd32bcc098d8f"/><file name="Promotion.php" hash="04dc485b396afb3e5af185bfca48e3b6"/><file name="Promotions.php" hash="1e11230f7526cd9cad21e1238f1d37ae"/><file name="Status.php" hash="8c125b4634cc9fb7900cf8eb8f6c6cf8"/><dir name="System"><dir name="Config"><dir name="Source"><file name="salerules.php" hash="76f897e441dfd98ac1a16268ede5e200"/></dir></dir></dir></dir><dir name="controllers"><dir name="Adminhtml"><file name="PromotionController.php" hash="5534dd811268a2756857d471485c78c5"/><file name="PromotionsController.php" hash="17803e5aaaff056d01c1a89b5f5dfcbb"/></dir><file name="IndexController.php" hash="224656dce770fb262aa8919ea8eac96e"/></dir><dir name="etc"><file name="config.xml" hash="6d3acb8a6fafc4ccc7eddcc6c6cddf1b"/><file name="system.xml" hash="9a25270ddc0ef5cdbacb8955b172a0eb"/></dir><dir name="sql"><dir name="promotion_setup"><file name="mysql4-install-0.1.0.php" hash="03920a323ea4849644b8dd5ea9dd62ce"/></dir><dir name="promotions_setup"><file name="mysql4-install-0.1.0.php" hash="00c7a069109034c5b37f3b23204fea20"/></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Grazitti_Promotions.xml" hash="1282a810edf0e953c608b2b44553399c"/></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="promotions.xml" hash="6d3b7facc16e5cb86652ef5341d11417"/></dir></dir></dir></dir></target></contents>
16
+ <compatible/>
17
+ <dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
18
+ </package>