d4u_dealoffer - Version 1.0.0

Version Notes

Deal offer for Magento

Download this release

Release Info

Developer Gayatri
Extension d4u_dealoffer
Version 1.0.0
Comparing to
See all releases


Version 1.0.0

Files changed (60) hide show
  1. app/code/local/D4U/Dealoffer/Block/Adminhtml/Catalog/Product/Edit/Tab/Offers.php +190 -0
  2. app/code/local/D4U/Dealoffer/Block/Adminhtml/Offers.php +38 -0
  3. app/code/local/D4U/Dealoffer/Block/Adminhtml/Offers/Edit.php +166 -0
  4. app/code/local/D4U/Dealoffer/Block/Adminhtml/Offers/Edit/Form.php +43 -0
  5. app/code/local/D4U/Dealoffer/Block/Adminhtml/Offers/Edit/Tab/Form.php +185 -0
  6. app/code/local/D4U/Dealoffer/Block/Adminhtml/Offers/Edit/Tab/Meta.php +51 -0
  7. app/code/local/D4U/Dealoffer/Block/Adminhtml/Offers/Edit/Tab/Product.php +228 -0
  8. app/code/local/D4U/Dealoffer/Block/Adminhtml/Offers/Edit/Tab/Stores.php +48 -0
  9. app/code/local/D4U/Dealoffer/Block/Adminhtml/Offers/Edit/Tabs.php +69 -0
  10. app/code/local/D4U/Dealoffer/Block/Adminhtml/Offers/Grid.php +243 -0
  11. app/code/local/D4U/Dealoffer/Block/Adminhtml/Offers/Helper/File.php +101 -0
  12. app/code/local/D4U/Dealoffer/Block/Adminhtml/Offers/Helper/Image.php +39 -0
  13. app/code/local/D4U/Dealoffer/Block/Adminhtml/Offers/Widget/Chooser.php +156 -0
  14. app/code/local/D4U/Dealoffer/Block/Offers/Catalog/Product/List.php +49 -0
  15. app/code/local/D4U/Dealoffer/Block/Offers/List.php +67 -0
  16. app/code/local/D4U/Dealoffer/Block/Offers/Rss.php +80 -0
  17. app/code/local/D4U/Dealoffer/Block/Offers/View.php +34 -0
  18. app/code/local/D4U/Dealoffer/Block/Offers/Widget/Link.php +26 -0
  19. app/code/local/D4U/Dealoffer/Block/Offers/Widget/View.php +46 -0
  20. app/code/local/D4U/Dealoffer/Block/Rss.php +52 -0
  21. app/code/local/D4U/Dealoffer/Controller/Adminhtml/Dealoffer.php +60 -0
  22. app/code/local/D4U/Dealoffer/Controller/Router.php +76 -0
  23. app/code/local/D4U/Dealoffer/Helper/Data.php +34 -0
  24. app/code/local/D4U/Dealoffer/Helper/Image/Abstract.php +461 -0
  25. app/code/local/D4U/Dealoffer/Helper/Offers.php +70 -0
  26. app/code/local/D4U/Dealoffer/Helper/Offers/Image.php +35 -0
  27. app/code/local/D4U/Dealoffer/Helper/Product.php +53 -0
  28. app/code/local/D4U/Dealoffer/Model/Adminhtml/Observer.php +81 -0
  29. app/code/local/D4U/Dealoffer/Model/Adminhtml/Search/Offers.php +54 -0
  30. app/code/local/D4U/Dealoffer/Model/Offers.php +139 -0
  31. app/code/local/D4U/Dealoffer/Model/Offers/Product.php +60 -0
  32. app/code/local/D4U/Dealoffer/Model/Resource/Offers.php +221 -0
  33. app/code/local/D4U/Dealoffer/Model/Resource/Offers/Collection.php +166 -0
  34. app/code/local/D4U/Dealoffer/Model/Resource/Offers/Product.php +83 -0
  35. app/code/local/D4U/Dealoffer/Model/Resource/Offers/Product/Collection.php +64 -0
  36. app/code/local/D4U/Dealoffer/Model/Resource/Setup.php +26 -0
  37. app/code/local/D4U/Dealoffer/controllers/Adminhtml/Dealoffer/Offers/Catalog/ProductController.php +62 -0
  38. app/code/local/D4U/Dealoffer/controllers/Adminhtml/Dealoffer/Offers/WidgetController.php +38 -0
  39. app/code/local/D4U/Dealoffer/controllers/Adminhtml/Dealoffer/OffersController.php +361 -0
  40. app/code/local/D4U/Dealoffer/controllers/OffersController.php +192 -0
  41. app/code/local/D4U/Dealoffer/etc/adminhtml.xml +63 -0
  42. app/code/local/D4U/Dealoffer/etc/config.xml +166 -0
  43. app/code/local/D4U/Dealoffer/etc/system.xml +93 -0
  44. app/code/local/D4U/Dealoffer/etc/widget.xml +64 -0
  45. app/code/local/D4U/Dealoffer/sql/d4u_dealoffer_setup/install-0.0.1.php +123 -0
  46. app/design/adminhtml/default/default/layout/d4u_dealoffer.xml +97 -0
  47. app/design/frontend/default/default/layout/d4u_dealoffer.xml +82 -0
  48. app/design/frontend/default/default/template/d4u_dealoffer/getdailydeal.phtml +101 -0
  49. app/design/frontend/default/default/template/d4u_dealoffer/offers/catalog/product/list.phtml +137 -0
  50. app/design/frontend/default/default/template/d4u_dealoffer/offers/categoryview.phtml +74 -0
  51. app/design/frontend/default/default/template/d4u_dealoffer/offers/list.phtml +97 -0
  52. app/design/frontend/default/default/template/d4u_dealoffer/offers/view.phtml +47 -0
  53. app/design/frontend/default/default/template/d4u_dealoffer/offers/widget/link.phtml +30 -0
  54. app/design/frontend/default/default/template/d4u_dealoffer/offers/widget/view.phtml +45 -0
  55. app/design/frontend/default/default/template/d4u_dealoffer/rss.phtml +43 -0
  56. app/etc/modules/D4U_Dealoffer.xml +29 -0
  57. app/locale/en_US/D4U_Dealoffer.csv +60 -0
  58. js/d4u_dealoffer/countdown.js +45 -0
  59. package.xml +18 -0
  60. skin/frontend/base/default/d4u_dealoffer/deal.css +110 -0
app/code/local/D4U/Dealoffer/Block/Adminhtml/Catalog/Product/Edit/Tab/Offers.php ADDED
@@ -0,0 +1,190 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * D4U_Dealoffer extension
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the MIT License
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/mit-license.php
11
+ *
12
+ * @category D4U
13
+ * @package D4U_Dealoffer
14
+ * @copyright Copyright (c) 2013
15
+ * @license http://opensource.org/licenses/mit-license.php MIT License
16
+ */
17
+ /**
18
+ * Offers tab on product edit form
19
+ *
20
+ * @category D4U
21
+ * @package D4U_Dealoffer
22
+ * @author Ultimate Module Creator
23
+ */
24
+ class D4U_Dealoffer_Block_Adminhtml_Catalog_Product_Edit_Tab_Offers extends Mage_Adminhtml_Block_Widget_Grid{
25
+ /**
26
+ * Set grid params
27
+ * @access protected
28
+ * @return void
29
+ * @author Ultimate Module Creator
30
+ */
31
+ public function __construct(){
32
+ parent::__construct();
33
+ $this->setId('offers_grid');
34
+ $this->setDefaultSort('position');
35
+ $this->setDefaultDir('ASC');
36
+ $this->setUseAjax(true);
37
+ if ($this->getProduct()->getId()) {
38
+ $this->setDefaultFilter(array('in_offerss'=>1));
39
+ }
40
+ }
41
+ /**
42
+ * prepare the offers collection
43
+ * @access protected
44
+ * @return D4U_Dealoffer_Block_Adminhtml_Catalog_Product_Edit_Tab_Offers
45
+ * @author Ultimate Module Creator
46
+ */
47
+ protected function _prepareCollection() {
48
+ $collection = Mage::getResourceModel('dealoffer/offers_collection');
49
+ if ($this->getProduct()->getId()){
50
+ $constraint = 'related.product_id='.$this->getProduct()->getId();
51
+ }
52
+ else{
53
+ $constraint = 'related.product_id=0';
54
+ }
55
+ $collection->getSelect()->joinLeft(
56
+ array('related'=>$collection->getTable('dealoffer/offers_product')),
57
+ 'related.offers_id=main_table.entity_id AND '.$constraint,
58
+ array('position')
59
+ );
60
+ $this->setCollection($collection);
61
+ parent::_prepareCollection();
62
+ return $this;
63
+ }
64
+ /**
65
+ * prepare mass action grid
66
+ * @access protected
67
+ * @return D4U_Dealoffer_Block_Adminhtml_Catalog_Product_Edit_Tab_Offers
68
+ * @author Ultimate Module Creator
69
+ */
70
+ protected function _prepareMassaction(){
71
+ return $this;
72
+ }
73
+ /**
74
+ * prepare the grid columns
75
+ * @access protected
76
+ * @return D4U_Dealoffer_Block_Adminhtml_Catalog_Product_Edit_Tab_Offers
77
+ * @author Ultimate Module Creator
78
+ */
79
+ protected function _prepareColumns(){
80
+ $this->addColumn('in_offerss', array(
81
+ 'header_css_class' => 'a-center',
82
+ 'type' => 'checkbox',
83
+ 'name' => 'in_offerss',
84
+ 'values'=> $this->_getSelectedOfferss(),
85
+ 'align' => 'center',
86
+ 'index' => 'entity_id'
87
+ ));
88
+ $this->addColumn('name', array(
89
+ 'header'=> Mage::helper('dealoffer')->__('Name'),
90
+ 'align' => 'left',
91
+ 'index' => 'name',
92
+ ));
93
+ $this->addColumn('position', array(
94
+ 'header' => Mage::helper('dealoffer')->__('Position'),
95
+ 'name' => 'position',
96
+ 'width' => 60,
97
+ 'type' => 'number',
98
+ 'validate_class'=> 'validate-number',
99
+ 'index' => 'position',
100
+ 'editable' => true,
101
+ ));
102
+ }
103
+ /**
104
+ * Retrieve selected offerss
105
+ * @access protected
106
+ * @return array
107
+ * @author Ultimate Module Creator
108
+ */
109
+ protected function _getSelectedOfferss(){
110
+ $offerss = $this->getProductOfferss();
111
+ if (!is_array($offerss)) {
112
+ $offerss = array_keys($this->getSelectedOfferss());
113
+ }
114
+ return $offerss;
115
+ }
116
+ /**
117
+ * Retrieve selected offerss
118
+ * @access protected
119
+ * @return array
120
+ * @author Ultimate Module Creator
121
+ */
122
+ public function getSelectedOfferss() {
123
+ $offerss = array();
124
+ //used helper here in order not to override the product model
125
+ $selected = Mage::helper('dealoffer/product')->getSelectedOfferss(Mage::registry('current_product'));
126
+ if (!is_array($selected)){
127
+ $selected = array();
128
+ }
129
+ foreach ($selected as $offers) {
130
+ $offerss[$offers->getId()] = array('position' => $offers->getPosition());
131
+ }
132
+ return $offerss;
133
+ }
134
+ /**
135
+ * get row url
136
+ * @access public
137
+ * @return string
138
+ * @author Ultimate Module Creator
139
+ */
140
+ public function getRowUrl($item){
141
+ return '#';
142
+ }
143
+ /**
144
+ * get grid url
145
+ * @access public
146
+ * @return string
147
+ * @author Ultimate Module Creator
148
+ */
149
+ public function getGridUrl(){
150
+ return $this->getUrl('*/*/offerssGrid', array(
151
+ 'id'=>$this->getProduct()->getId()
152
+ ));
153
+ }
154
+ /**
155
+ * get the current product
156
+ * @access public
157
+ * @return Mage_Catalog_Model_Product
158
+ * @author Ultimate Module Creator
159
+ */
160
+ public function getProduct(){
161
+ return Mage::registry('current_product');
162
+ }
163
+ /**
164
+ * Add filter
165
+ * @access protected
166
+ * @param object $column
167
+ * @return D4U_Dealoffer_Block_Adminhtml_Catalog_Product_Edit_Tab_Offers
168
+ * @author Ultimate Module Creator
169
+ */
170
+ protected function _addColumnFilterToCollection($column){
171
+ if ($column->getId() == 'in_offerss') {
172
+ $offersIds = $this->_getSelectedOfferss();
173
+ if (empty($offersIds)) {
174
+ $offersIds = 0;
175
+ }
176
+ if ($column->getFilter()->getValue()) {
177
+ $this->getCollection()->addFieldToFilter('entity_id', array('in'=>$offersIds));
178
+ }
179
+ else {
180
+ if($offersIds) {
181
+ $this->getCollection()->addFieldToFilter('entity_id', array('nin'=>$offersIds));
182
+ }
183
+ }
184
+ }
185
+ else {
186
+ parent::_addColumnFilterToCollection($column);
187
+ }
188
+ return $this;
189
+ }
190
+ }
app/code/local/D4U/Dealoffer/Block/Adminhtml/Offers.php ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * D4U_Dealoffer extension
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the MIT License
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/mit-license.php
11
+ *
12
+ * @category D4U
13
+ * @package D4U_Dealoffer
14
+ * @copyright Copyright (c) 2013
15
+ * @license http://opensource.org/licenses/mit-license.php MIT License
16
+ */
17
+ /**
18
+ * Offers admin block
19
+ *
20
+ * @category D4U
21
+ * @package D4U_Dealoffer
22
+ * @author Ultimate Module Creator
23
+ */
24
+ class D4U_Dealoffer_Block_Adminhtml_Offers extends Mage_Adminhtml_Block_Widget_Grid_Container{
25
+ /**
26
+ * constructor
27
+ * @access public
28
+ * @return void
29
+ * @author Ultimate Module Creator
30
+ */
31
+ public function __construct(){
32
+ $this->_controller = 'adminhtml_offers';
33
+ $this->_blockGroup = 'dealoffer';
34
+ $this->_headerText = Mage::helper('dealoffer')->__('Manage Offers');
35
+ $this->_addButtonLabel = Mage::helper('dealoffer')->__('Add Offer');
36
+ parent::__construct();
37
+ }
38
+ }
app/code/local/D4U/Dealoffer/Block/Adminhtml/Offers/Edit.php ADDED
@@ -0,0 +1,166 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * D4U_Dealoffer extension
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the MIT License
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/mit-license.php
11
+ *
12
+ * @category D4U
13
+ * @package D4U_Dealoffer
14
+ * @copyright Copyright (c) 2013
15
+ * @license http://opensource.org/licenses/mit-license.php MIT License
16
+ */
17
+ /**
18
+ * Offers admin edit block
19
+ *
20
+ * @category D4U
21
+ * @package D4U_Dealoffer
22
+ * @author Ultimate Module Creator
23
+ */
24
+ class D4U_Dealoffer_Block_Adminhtml_Offers_Edit extends Mage_Adminhtml_Block_Widget_Form_Container{
25
+ /**
26
+ * constuctor
27
+ * @access public
28
+ * @return void
29
+ * @author Ultimate Module Creator
30
+ */
31
+ public function __construct(){
32
+ parent::__construct();
33
+ $this->_blockGroup = 'dealoffer';
34
+ $this->_controller = 'adminhtml_offers';
35
+ $this->_updateButton('delete', 'label', Mage::helper('dealoffer')->__('Delete Offers'));
36
+ $this->_removeButton('save');
37
+ $this->_addButton('save', array(
38
+ 'label' => Mage::helper('dealoffer')->__('Save'),
39
+ 'onclick' => 'saveEdit()',
40
+ 'class' => 'save',
41
+ ), -50);
42
+ $this->_addButton('saveandcontinue', array(
43
+ 'label' => Mage::helper('dealoffer')->__('Save And Continue Edit'),
44
+ 'onclick' => 'saveAndContinueEdit()',
45
+ 'class' => 'save',
46
+ ), -100);
47
+ /*$this->_formScripts[] = "
48
+ function saveAndContinueEdit(){
49
+ editForm.submit($('edit_form').action+'back/edit/');
50
+ }
51
+ ";*/
52
+ $this->_formScripts[] = "function endAfterStart_offer(start,end){
53
+ return new Date(start.split('/').reverse().join('/')) <=
54
+ new Date(end.split('/').reverse().join('/'));
55
+ }
56
+ function Checkdate_offer(start,end){
57
+ if(start != '' && end != '') {
58
+ var parContainer = document.getElementById('note_end_date');
59
+ var msgContainer1 = document.getElementById('datevalidation');
60
+ if(msgContainer1)
61
+ {
62
+ parContainer.removeChild(msgContainer1);
63
+ }
64
+ if(endAfterStart_offer(start,end) == true)
65
+ {
66
+ }
67
+ else{
68
+ var msgContainer = document.createElement('div');
69
+ msgContainer.setAttribute('id', 'datevalidation'); //set id
70
+ msgContainer.setAttribute('class', 'validation-advice'); //set id
71
+ msgContainer.style.color='#D40707';
72
+ msgContainer.style.fontWeight='bold';
73
+ msgContainer.style.fontSize ='11.4px';
74
+ msgContainer.style.marginLeft ='-5px';
75
+ msgContainer.innerHTML = 'End Date Must be greater than Start Date';
76
+ document.getElementById('offers_end_date').value='';
77
+ parContainer.insertBefore(msgContainer,parContainer.childNodes[0]);
78
+ }
79
+ }
80
+ }
81
+
82
+ function showproductmsg_offer()
83
+ {
84
+ var parContainer = document.getElementById('offers_tabs_products_content');
85
+ var msgContainer1 = document.getElementById('xyz');
86
+ if(msgContainer1)
87
+ {
88
+ parContainer.removeChild(msgContainer1);
89
+ }
90
+ var msgContainer = document.createElement('div');
91
+ msgContainer.setAttribute('id', 'xyz'); //set id
92
+ msgContainer.style.color='red';
93
+ msgContainer.innerHTML = 'Please Select At least One Product';
94
+ parContainer.insertBefore(msgContainer,parContainer.childNodes[0]);
95
+
96
+ document.getElementById('offers_tabs_form_offers').className = 'tab-item-link';
97
+ document.getElementById('offers_tabs_form_store_offers').className = 'tab-item-link';
98
+ document.getElementById('offers_tabs_products').className = 'tab-item-link error active';
99
+
100
+ document.getElementById('offers_tabs_form_offers_content').style.display = 'none';
101
+ document.getElementById('offers_tabs_form_store_offers_content').style.display = 'none';
102
+ document.getElementById('offers_tabs_products_content').style.display = 'block';
103
+ return false;
104
+ }
105
+
106
+ function showProductsTab_offer(method) {
107
+
108
+ var cboxes = document.getElementsByName('items[]');
109
+ var len = cboxes.length;
110
+ for (var i=0; i<len; i++)
111
+ {
112
+ if(cboxes[i].checked)
113
+ {
114
+ if(method == 1)
115
+ {
116
+ editForm.submit($('edit_form').action+'back/edit/');
117
+ return true;
118
+ }
119
+ else
120
+ {
121
+ editForm.submit($('edit_form').action);
122
+ return true;
123
+
124
+ }
125
+ }
126
+ }
127
+ setTimeout(showproductmsg_offer, 1000);
128
+ return false;
129
+ }
130
+ function saveAndContinueEdit(){
131
+ if(document.getElementById('offers_deal_image_image')){
132
+
133
+ }
134
+ else{
135
+ document.getElementById('offers_deal_image').className = '';
136
+ document.getElementById('offers_deal_image').className = 'required-entry';
137
+ }
138
+ showProductsTab_offer(1);
139
+ }
140
+ function saveEdit(){
141
+ if(document.getElementById('offers_deal_image_image')){
142
+
143
+ }
144
+ else{
145
+ document.getElementById('offers_deal_image').className = '';
146
+ document.getElementById('offers_deal_image').className = 'required-entry';
147
+ }
148
+ showProductsTab_offer(0);
149
+ }
150
+ ";
151
+ }
152
+ /**
153
+ * get the edit form header
154
+ * @access public
155
+ * @return string
156
+ * @author Ultimate Module Creator
157
+ */
158
+ public function getHeaderText(){
159
+ if( Mage::registry('offers_data') && Mage::registry('offers_data')->getId() ) {
160
+ return Mage::helper('dealoffer')->__("Edit Offers '%s'", $this->htmlEscape(Mage::registry('offers_data')->getName()));
161
+ }
162
+ else {
163
+ return Mage::helper('dealoffer')->__('Add Offer');
164
+ }
165
+ }
166
+ }
app/code/local/D4U/Dealoffer/Block/Adminhtml/Offers/Edit/Form.php ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * D4U_Dealoffer extension
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the MIT License
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/mit-license.php
11
+ *
12
+ * @category D4U
13
+ * @package D4U_Dealoffer
14
+ * @copyright Copyright (c) 2013
15
+ * @license http://opensource.org/licenses/mit-license.php MIT License
16
+ */
17
+ /**
18
+ * Offers edit form
19
+ *
20
+ * @category D4U
21
+ * @package D4U_Dealoffer
22
+ * @author Ultimate Module Creator
23
+ */
24
+ class D4U_Dealoffer_Block_Adminhtml_Offers_Edit_Form extends Mage_Adminhtml_Block_Widget_Form{
25
+ /**
26
+ * prepare form
27
+ * @access protected
28
+ * @return D4U_Dealoffer_Block_Adminhtml_Offers_Edit_Form
29
+ * @author Ultimate Module Creator
30
+ */
31
+ protected function _prepareForm(){
32
+ $form = new Varien_Data_Form(array(
33
+ 'id' => 'edit_form',
34
+ 'action' => $this->getUrl('*/*/save', array('id' => $this->getRequest()->getParam('id'))),
35
+ 'method' => 'post',
36
+ 'enctype' => 'multipart/form-data'
37
+ )
38
+ );
39
+ $form->setUseContainer(true);
40
+ $this->setForm($form);
41
+ return parent::_prepareForm();
42
+ }
43
+ }
app/code/local/D4U/Dealoffer/Block/Adminhtml/Offers/Edit/Tab/Form.php ADDED
@@ -0,0 +1,185 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * D4U_Dealoffer extension
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the MIT License
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/mit-license.php
11
+ *
12
+ * @category D4U
13
+ * @package D4U_Dealoffer
14
+ * @copyright Copyright (c) 2013
15
+ * @license http://opensource.org/licenses/mit-license.php MIT License
16
+ */
17
+ /**
18
+ * Offers edit form tab
19
+ *
20
+ * @category D4U
21
+ * @package D4U_Dealoffer
22
+ * @author Ultimate Module Creator
23
+ */
24
+ class D4U_Dealoffer_Block_Adminhtml_Offers_Edit_Tab_Form extends Mage_Adminhtml_Block_Widget_Form{
25
+ /**
26
+ * prepare the form
27
+ * @access protected
28
+ * @return Dealoffer_Offers_Block_Adminhtml_Offers_Edit_Tab_Form
29
+ * @author Ultimate Module Creator
30
+ */
31
+ protected function _prepareForm(){
32
+ $form = new Varien_Data_Form();
33
+ $form->setHtmlIdPrefix('offers_');
34
+ $form->setFieldNameSuffix('offers');
35
+ $this->setForm($form);
36
+ $fieldset = $form->addFieldset('offers_form', array('legend'=>Mage::helper('dealoffer')->__('Deal Offer Informations')));
37
+ $fieldset->addType('image', Mage::getConfig()->getBlockClassName('dealoffer/adminhtml_offers_helper_image'));
38
+
39
+
40
+
41
+ //for all category
42
+ //$arr = $this->get_categories();
43
+ //var_dump($arr);
44
+
45
+ $categories = Mage::getModel('catalog/category')->getCollection()
46
+ ->addAttributeToSelect('name')
47
+ ->addAttributeToSelect('url_key')
48
+ ->addAttributeToSelect('my_attribute')
49
+ ->setLoadProductCount(true)
50
+ ->addAttributeToFilter('is_active',array('eq'=>true))
51
+ ->addAttributeToFilter('level',2)
52
+ ->setOrder('position', Varien_Db_Select::SQL_ASC)
53
+ ->load();
54
+ $main_category_arr = array();
55
+ foreach ($categories as $cat):
56
+ $data_arr =$cat->getData();
57
+ $main_category_arr[] = array('value'=>$data_arr['entity_id'],'label' => $cat->getName());
58
+ endforeach;
59
+
60
+ $fieldset->addField('name', 'text', array(
61
+ 'label' => Mage::helper('dealoffer')->__('Name'),
62
+ 'name' => 'name',
63
+ 'note' => $this->__('Enter Unique Deal Offer Name'),
64
+ 'required' => true,
65
+ 'class' => 'required-entry',
66
+ 'onchange' => "document.getElementById('offers_url_key').value = (document.getElementById('offers_name').value).replace(/[^a-z0-9\s]/gi, '').replace(/[_\s]/g, '').toLowerCase();",
67
+ ));
68
+
69
+ $fieldset->addField('category_id', 'select', array(
70
+ 'label' => Mage::helper('dealoffer')->__('Category'),
71
+ 'name' => 'category_id',
72
+ 'values'=> $main_category_arr,
73
+ ));
74
+
75
+
76
+ $dateFormatIso = Mage::app()->getLocale()->getDateFormat(
77
+ Mage_Core_Model_Locale::FORMAT_TYPE_SHORT
78
+ );
79
+
80
+ $fieldset->addField('start_date', 'date', array(
81
+ 'label' => Mage::helper('dealoffer')->__('Start Date'),
82
+ 'name' => 'start_date',
83
+ 'note' => $this->__('Deal Offer Start Date'),
84
+ 'required' => true,
85
+ 'class' => 'required-entry',
86
+ 'image' => $this->getSkinUrl('images/grid-cal.gif'),
87
+ 'format' => $dateFormatIso,
88
+ 'onchange' => "Checkdate_offer(document.getElementById('offers_start_date').value,document.getElementById('offers_end_date').value)"
89
+ ));
90
+ $dateFormatIso = Mage::app()->getLocale()->getDateFormat(
91
+ Mage_Core_Model_Locale::FORMAT_TYPE_SHORT
92
+ );
93
+
94
+ $fieldset->addField('end_date', 'date', array(
95
+ 'label' => Mage::helper('dealoffer')->__('End Date'),
96
+ 'name' => 'end_date',
97
+ 'note' => $this->__('Deal Offer Expiry Date'),
98
+ 'required' => true,
99
+ 'class' => 'required-entry',
100
+ 'image' => $this->getSkinUrl('images/grid-cal.gif'),
101
+ 'format' => $dateFormatIso,
102
+ 'onchange' => "Checkdate_offer(document.getElementById('offers_start_date').value,document.getElementById('offers_end_date').value)"
103
+ ));
104
+
105
+ $fieldset->addField('deal_image', 'image', array(
106
+ 'name' => 'deal_image',
107
+ 'class' => 'required-entry required-file',
108
+ 'label' => Mage::helper('dealoffer')->__('Offer Image'),
109
+ 'title' => Mage::helper('dealoffer')->__('Offer Image'),
110
+ 'required' => true,
111
+
112
+ ));
113
+
114
+ $fieldset->addField('url_key', 'text', array(
115
+ 'label' => Mage::helper('dealoffer')->__('Url key'),
116
+ 'name' => 'url_key',
117
+ 'required' => true,
118
+ 'class' => 'required-entry',
119
+ 'note' => Mage::helper('dealoffer')->__('Relative to Website Base URL')
120
+ ));
121
+ $fieldset->addField('status', 'select', array(
122
+ 'label' => Mage::helper('dealoffer')->__('Status'),
123
+ 'name' => 'status',
124
+ 'values'=> array(
125
+ array(
126
+ 'value' => '1',
127
+ 'label' => Mage::helper('dealoffer')->__('Enabled'),
128
+ ),
129
+ array(
130
+ 'value' => '0',
131
+ 'label' => Mage::helper('dealoffer')->__('Disabled'),
132
+ ),
133
+ ),
134
+ 'value' => 1 //Default value
135
+ ));
136
+ $fieldset->addField('in_rss', 'select', array(
137
+ 'label' => Mage::helper('dealoffer')->__('Show in rss'),
138
+ 'name' => 'in_rss',
139
+ 'values'=> array(
140
+ array(
141
+ 'value' => 1,
142
+ 'label' => Mage::helper('dealoffer')->__('Yes'),
143
+ ),
144
+ array(
145
+ 'value' => 0,
146
+ 'label' => Mage::helper('dealoffer')->__('No'),
147
+ ),
148
+ ),
149
+ ));
150
+ if (Mage::app()->isSingleStoreMode()){
151
+ $fieldset->addField('store_id', 'hidden', array(
152
+ 'name' => 'stores[]',
153
+ 'value' => Mage::app()->getStore(true)->getId()
154
+ ));
155
+ Mage::registry('current_offers')->setStoreId(Mage::app()->getStore(true)->getId());
156
+ }
157
+ if (Mage::getSingleton('adminhtml/session')->getOffersData()){
158
+ $form->setValues(Mage::getSingleton('adminhtml/session')->getOffersData());
159
+ Mage::getSingleton('adminhtml/session')->setOffersData(null);
160
+ }
161
+ elseif (Mage::registry('current_offers')){
162
+ $form->setValues(Mage::registry('current_offers')->getData());
163
+ }
164
+ return parent::_prepareForm();
165
+ }
166
+
167
+ function get_categories(){
168
+
169
+ $category = Mage::getModel('catalog/category');
170
+ $tree = $category->getTreeModel();
171
+ $tree->load();
172
+ $ids = $tree->getCollection()->getAllIds();
173
+ $arr = array();
174
+ if ($ids){
175
+ foreach ($ids as $id){
176
+ $cat = Mage::getModel('catalog/category');
177
+ $cat->load($id);
178
+ $arr[$id] = $cat->getName();
179
+ }
180
+ }
181
+
182
+ return $arr;
183
+
184
+ }
185
+ }
app/code/local/D4U/Dealoffer/Block/Adminhtml/Offers/Edit/Tab/Meta.php ADDED
@@ -0,0 +1,51 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * D4U_Dealoffer extension
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the MIT License
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/mit-license.php
11
+ *
12
+ * @category D4U
13
+ * @package D4U_Dealoffer
14
+ * @copyright Copyright (c) 2013
15
+ * @license http://opensource.org/licenses/mit-license.php MIT License
16
+ */
17
+ /**
18
+ * meta information tab
19
+ *
20
+ * @category D4U
21
+ * @package D4U_Dealoffer
22
+ * @author Ultimate Module Creator
23
+ */
24
+ class D4U_Dealoffer_Block_Adminhtml_Offers_Edit_Tab_Meta extends Mage_Adminhtml_Block_Widget_Form{
25
+ /**
26
+ * prepare the form
27
+ * @access protected
28
+ * @return D4U_Dealoffer_Block_Adminhtml_Offers_Edit_Tab_Meta
29
+ * @author Ultimate Module Creator
30
+ */
31
+ protected function _prepareForm(){
32
+ $form = new Varien_Data_Form();
33
+ $form->setFieldNameSuffix('offers');
34
+ $this->setForm($form);
35
+ $fieldset = $form->addFieldset('offers_meta_form', array('legend'=>Mage::helper('dealoffer')->__('Meta information')));
36
+ $fieldset->addField('meta_title', 'text', array(
37
+ 'label' => Mage::helper('dealoffer')->__('Meta-title'),
38
+ 'name' => 'meta_title',
39
+ ));
40
+ $fieldset->addField('meta_description', 'textarea', array(
41
+ 'name' => 'meta_description',
42
+ 'label' => Mage::helper('dealoffer')->__('Meta-description'),
43
+ ));
44
+ $fieldset->addField('meta_keywords', 'textarea', array(
45
+ 'name' => 'meta_keywords',
46
+ 'label' => Mage::helper('dealoffer')->__('Meta-keywords'),
47
+ ));
48
+ $form->addValues(Mage::registry('current_offers')->getData());
49
+ return parent::_prepareForm();
50
+ }
51
+ }
app/code/local/D4U/Dealoffer/Block/Adminhtml/Offers/Edit/Tab/Product.php ADDED
@@ -0,0 +1,228 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * D4U_Dealoffer extension
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the MIT License
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/mit-license.php
11
+ *
12
+ * @category D4U
13
+ * @package D4U_Dealoffer
14
+ * @copyright Copyright (c) 2013
15
+ * @license http://opensource.org/licenses/mit-license.php MIT License
16
+ */
17
+ /**
18
+ * Offers - product relation edit block
19
+ *
20
+ * @category D4U
21
+ * @package D4U_Dealoffer
22
+ * @author Ultimate Module Creator
23
+ */
24
+ class D4U_Dealoffer_Block_Adminhtml_Offers_Edit_Tab_Product extends Mage_Adminhtml_Block_Widget_Grid{
25
+ /**
26
+ * Set grid params
27
+ * @access protected
28
+ * @return void
29
+ * @author Ultimate Module Creator
30
+ */
31
+ public function __construct(){
32
+ parent::__construct();
33
+ $this->setId('product_grid');
34
+ $this->setDefaultSort('position');
35
+ $this->setDefaultDir('ASC');
36
+ $this->setUseAjax(true);
37
+ if ($this->getOffers()->getId()) {
38
+ $this->setDefaultFilter(array('in_products'=>1));
39
+ }
40
+ }
41
+ /**
42
+ * prepare the product collection
43
+ * @access protected
44
+ * @return D4U_Dealoffer_Block_Adminhtml_Offers_Edit_Tab_Product
45
+ * @author Ultimate Module Creator
46
+ */
47
+ protected function _prepareCollection() {
48
+ $collection = Mage::getResourceModel('catalog/product_collection')->joinField('category_id', 'catalog/category_product', 'category_id', 'product_id = entity_id', null, 'right');
49
+ $collection->addAttributeToFilter('status',1);
50
+ $collection->addAttributeToFilter('visibility',array("neq"=>1));
51
+ $collection->addAttributeToSelect('price');
52
+ $adminStore = Mage_Core_Model_App::ADMIN_STORE_ID;
53
+ $collection->joinAttribute('product_name', 'catalog_product/name', 'entity_id', null, 'left', $adminStore);
54
+ if ($this->getOffers()->getId()){
55
+ $constraint = '{{table}}.offers_id='.$this->getOffers()->getId();
56
+ }
57
+ else{
58
+ $constraint = '{{table}}.offers_id=0';
59
+ }
60
+ $collection->joinField('position',
61
+ 'dealoffer/offers_product',
62
+ 'position',
63
+ 'product_id=entity_id',
64
+ $constraint,
65
+ 'left');
66
+
67
+ $this->setCollection($collection);
68
+ parent::_prepareCollection();
69
+ return $this;
70
+ }
71
+ /**
72
+ * prepare mass action grid
73
+ * @access protected
74
+ * @return D4U_Dealoffer_Block_Adminhtml_Offers_Edit_Tab_Product
75
+ * @author Ultimate Module Creator
76
+ */
77
+ protected function _prepareMassaction(){
78
+ return $this;
79
+ }
80
+ /**
81
+ * prepare the grid columns
82
+ * @access protected
83
+ * @return D4U_Dealoffer_Block_Adminhtml_Offers_Edit_Tab_Product
84
+ * @author Ultimate Module Creator
85
+ */
86
+ protected function _prepareColumns(){
87
+
88
+ $collection = Mage::getModel('catalog/category')->getCollection()->setLoadProductCount(true)->addAttributeToSelect('name');
89
+ $options = array();
90
+ foreach ($collection as $item){
91
+ if($item->getId() != '' ){
92
+ $options[$item->getId()] = $item->getName();
93
+ }
94
+ }
95
+
96
+ $this->addColumn('in_products', array(
97
+ 'header_css_class' => 'a-center',
98
+ 'type' => 'checkbox',
99
+ 'name' => 'in_products',
100
+ 'field_name' =>'items[]',
101
+ 'values'=> $this->_getSelectedProducts(),
102
+ 'align' => 'center',
103
+ 'index' => 'entity_id'
104
+ ));
105
+ $this->addColumn('product_name', array(
106
+ 'header'=> Mage::helper('catalog')->__('Name'),
107
+ 'align' => 'left',
108
+ 'index' => 'product_name',
109
+ ));
110
+ $this->addColumn('category_id', array(
111
+ 'header'=> Mage::helper('catalog')->__('Category Name'),
112
+ 'align' => 'left',
113
+ 'index' => 'category_id',
114
+ 'type' => 'options',
115
+ 'options' =>$options
116
+
117
+ ));
118
+ $this->addColumn('sku', array(
119
+ 'header'=> Mage::helper('catalog')->__('SKU'),
120
+ 'align' => 'left',
121
+ 'index' => 'sku',
122
+ ));
123
+ $this->addColumn('price', array(
124
+ 'header'=> Mage::helper('catalog')->__('Price'),
125
+ 'type' => 'currency',
126
+ 'width' => '1',
127
+ 'currency_code' => (string) Mage::getStoreConfig(Mage_Directory_Model_Currency::XML_PATH_CURRENCY_BASE),
128
+ 'index' => 'price'
129
+ ));
130
+ $this->addColumn('position', array(
131
+ 'header'=> Mage::helper('catalog')->__('Position'),
132
+ 'name' => 'position',
133
+ 'width' => 60,
134
+ 'type' => 'number',
135
+ 'validate_class'=> 'validate-number',
136
+ 'index' => 'position',
137
+ 'editable' => true,
138
+ ));
139
+ }
140
+ /**
141
+ * Retrieve selected products
142
+ * @access protected
143
+ * @return array
144
+ * @author Ultimate Module Creator
145
+ */
146
+ protected function _getSelectedProducts(){
147
+ $products = $this->getOffersProducts();
148
+ if (!is_array($products)) {
149
+ $products = array_keys($this->getSelectedProducts());
150
+ }
151
+ return $products;
152
+ }
153
+
154
+ /**
155
+ * Retrieve selected products
156
+ * @access protected
157
+ * @return array
158
+ * @author Ultimate Module Creator
159
+ */
160
+ public function getSelectedProducts() {
161
+ $products = array();
162
+ $selected = Mage::registry('current_offers')->getSelectedProducts();
163
+ if (!is_array($selected)){
164
+ $selected = array();
165
+ }
166
+ foreach ($selected as $product) {
167
+ $products[$product->getId()] = array('position' => $product->getPosition());
168
+ }
169
+ return $products;
170
+ }
171
+ /**
172
+ * get row url
173
+ * @access public
174
+ * @return string
175
+ * @author Ultimate Module Creator
176
+ */
177
+ public function getRowUrl($item){
178
+ return '#';
179
+ }
180
+ /**
181
+ * get grid url
182
+ * @access public
183
+ * @return string
184
+ * @author Ultimate Module Creator
185
+ */
186
+ public function getGridUrl(){
187
+ return $this->getUrl('*/*/productsGrid', array(
188
+ 'id'=>$this->getOffers()->getId()
189
+ ));
190
+ }
191
+ /**
192
+ * get the current offers
193
+ * @access public
194
+ * @return D4U_Dealoffer_Model_Offers
195
+ * @author Ultimate Module Creator
196
+ */
197
+ public function getOffers(){
198
+ return Mage::registry('current_offers');
199
+ }
200
+ /**
201
+ * Add filter
202
+ * @access protected
203
+ * @param object $column
204
+ * @return D4U_Dealoffer_Block_Adminhtml_Offers_Edit_Tab_Product
205
+ * @author Ultimate Module Creator
206
+ */
207
+ protected function _addColumnFilterToCollection($column){
208
+ // Set custom filter for in product flag
209
+ if ($column->getId() == 'in_products') {
210
+ $productIds = $this->_getSelectedProducts();
211
+ if (empty($productIds)) {
212
+ $productIds = 0;
213
+ }
214
+ if ($column->getFilter()->getValue()) {
215
+ $this->getCollection()->addFieldToFilter('entity_id', array('in'=>$productIds));
216
+ }
217
+ else {
218
+ if($productIds) {
219
+ $this->getCollection()->addFieldToFilter('entity_id', array('nin'=>$productIds));
220
+ }
221
+ }
222
+ }
223
+ else {
224
+ parent::_addColumnFilterToCollection($column);
225
+ }
226
+ return $this;
227
+ }
228
+ }
app/code/local/D4U/Dealoffer/Block/Adminhtml/Offers/Edit/Tab/Stores.php ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * D4U_Dealoffer extension
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the MIT License
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/mit-license.php
11
+ *
12
+ * @category D4U
13
+ * @package D4U_Dealoffer
14
+ * @copyright Copyright (c) 2013
15
+ * @license http://opensource.org/licenses/mit-license.php MIT License
16
+ */
17
+ /**
18
+ * store selection tab
19
+ *
20
+ * @category D4U
21
+ * @package D4U_Dealoffer
22
+ * @author Ultimate Module Creator
23
+ */
24
+ class D4U_Dealoffer_Block_Adminhtml_Offers_Edit_Tab_Stores extends Mage_Adminhtml_Block_Widget_Form{
25
+ /**
26
+ * prepare the form
27
+ * @access protected
28
+ * @return D4U_Dealoffer_Block_Adminhtml_Offers_Edit_Tab_Stores
29
+ * @author Ultimate Module Creator
30
+ */
31
+ protected function _prepareForm(){
32
+ $form = new Varien_Data_Form();
33
+ $form->setFieldNameSuffix('offers');
34
+ $this->setForm($form);
35
+ $fieldset = $form->addFieldset('offers_stores_form', array('legend'=>Mage::helper('dealoffer')->__('Store views')));
36
+ $field = $fieldset->addField('store_id', 'multiselect', array(
37
+ 'name' => 'stores[]',
38
+ 'label' => Mage::helper('dealoffer')->__('Store Views'),
39
+ 'title' => Mage::helper('dealoffer')->__('Store Views'),
40
+ 'required' => true,
41
+ 'values'=> Mage::getSingleton('adminhtml/system_store')->getStoreValuesForForm(false, true),
42
+ ));
43
+ $renderer = $this->getLayout()->createBlock('adminhtml/store_switcher_form_renderer_fieldset_element');
44
+ $field->setRenderer($renderer);
45
+ $form->addValues(Mage::registry('current_offers')->getData());
46
+ return parent::_prepareForm();
47
+ }
48
+ }
app/code/local/D4U/Dealoffer/Block/Adminhtml/Offers/Edit/Tabs.php ADDED
@@ -0,0 +1,69 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * D4U_Dealoffer extension
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the MIT License
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/mit-license.php
11
+ *
12
+ * @category D4U
13
+ * @package D4U_Dealoffer
14
+ * @copyright Copyright (c) 2013
15
+ * @license http://opensource.org/licenses/mit-license.php MIT License
16
+ */
17
+ /**
18
+ * Offers admin edit tabs
19
+ *
20
+ * @category D4U
21
+ * @package D4U_Dealoffer
22
+ * @author Ultimate Module Creator
23
+ */
24
+ class D4U_Dealoffer_Block_Adminhtml_Offers_Edit_Tabs extends Mage_Adminhtml_Block_Widget_Tabs{
25
+ /**
26
+ * constructor
27
+ * @access public
28
+ * @return void
29
+ * @author Ultimate Module Creator
30
+ */
31
+ public function __construct(){
32
+ parent::__construct();
33
+ $this->setId('offers_tabs');
34
+ $this->setDestElementId('edit_form');
35
+ $this->setTitle(Mage::helper('dealoffer')->__('Offer Information'));
36
+ }
37
+ /**
38
+ * before render html
39
+ * @access protected
40
+ * @return D4U_Dealoffer_Block_Adminhtml_Offers_Edit_Tabs
41
+ * @author Ultimate Module Creator
42
+ */
43
+ protected function _beforeToHtml(){
44
+ $this->addTab('products', array(
45
+ 'label' => Mage::helper('dealoffer')->__('Associated products'),
46
+ 'url' => $this->getUrl('*/*/products', array('_current' => true)),
47
+ 'class' => 'ajax'
48
+ ));
49
+ $this->addTab('form_offers', array(
50
+ 'label' => Mage::helper('dealoffer')->__('Offer Settings'),
51
+ 'title' => Mage::helper('dealoffer')->__('Offer Settings'),
52
+ 'content' => $this->getLayout()->createBlock('dealoffer/adminhtml_offers_edit_tab_form')->toHtml(),
53
+ ));
54
+ $this->addTab('form_meta_offers', array(
55
+ 'label' => Mage::helper('dealoffer')->__('Meta Information'),
56
+ 'title' => Mage::helper('dealoffer')->__('Meta Information'),
57
+ 'content' => $this->getLayout()->createBlock('dealoffer/adminhtml_offers_edit_tab_meta')->toHtml(),
58
+ ));
59
+ if (!Mage::app()->isSingleStoreMode()){
60
+ $this->addTab('form_store_offers', array(
61
+ 'label' => Mage::helper('dealoffer')->__('Store views'),
62
+ 'title' => Mage::helper('dealoffer')->__('Store views'),
63
+ 'content' => $this->getLayout()->createBlock('dealoffer/adminhtml_offers_edit_tab_stores')->toHtml(),
64
+ ));
65
+ }
66
+
67
+ return parent::_beforeToHtml();
68
+ }
69
+ }
app/code/local/D4U/Dealoffer/Block/Adminhtml/Offers/Grid.php ADDED
@@ -0,0 +1,243 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * D4U_Dealoffer extension
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the MIT License
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/mit-license.php
11
+ *
12
+ * @category D4U
13
+ * @package D4U_Dealoffer
14
+ * @copyright Copyright (c) 2013
15
+ * @license http://opensource.org/licenses/mit-license.php MIT License
16
+ */
17
+ /**
18
+ * Offers admin grid block
19
+ *
20
+ * @category D4U
21
+ * @package D4U_Dealoffer
22
+ * @author Ultimate Module Creator
23
+ */
24
+ class D4U_Dealoffer_Block_Adminhtml_Offers_Grid extends Mage_Adminhtml_Block_Widget_Grid{
25
+ /**
26
+ * constructor
27
+ * @access public
28
+ * @return void
29
+ * @author Ultimate Module Creator
30
+ */
31
+ public function __construct(){
32
+ parent::__construct();
33
+ $this->setId('offersGrid');
34
+ $this->setDefaultSort('entity_id');
35
+ $this->setDefaultDir('ASC');
36
+ $this->setSaveParametersInSession(true);
37
+ $this->setUseAjax(true);
38
+ }
39
+ /**
40
+ * prepare collection
41
+ * @access protected
42
+ * @return D4U_Dealoffer_Block_Adminhtml_Offers_Grid
43
+ * @author Ultimate Module Creator
44
+ */
45
+ protected function _prepareCollection(){
46
+ $collection = Mage::getModel('dealoffer/offers')->getCollection();
47
+
48
+ $this->setCollection($collection);
49
+ return parent::_prepareCollection();
50
+ }
51
+ /**
52
+ * prepare grid collection
53
+ * @access protected
54
+ * @return D4U_Dealoffer_Block_Adminhtml_Offers_Grid
55
+ * @author Ultimate Module Creator
56
+ */
57
+ protected function _prepareColumns(){
58
+ $collection = Mage::getModel('catalog/category')->getCollection()->addAttributeToFilter('level',2)->addAttributeToSelect('name');
59
+ $options = array();
60
+ foreach ($collection as $item){
61
+ if($item->getId() != ''){
62
+ $options[$item->getId()] = $item->getName();
63
+ }
64
+ }
65
+
66
+ $this->addColumn('entity_id', array(
67
+ 'header' => Mage::helper('dealoffer')->__('Id'),
68
+ 'index' => 'entity_id',
69
+ 'type' => 'number'
70
+ ));
71
+ $this->addColumn('name', array(
72
+ 'header'=> Mage::helper('dealoffer')->__('Name'),
73
+ 'index' => 'name',
74
+ 'type' => 'text',
75
+
76
+ ));
77
+ $this->addColumn('category_id', array(
78
+ 'header'=> Mage::helper('dealoffer')->__('Category'),
79
+ 'index' => 'category_id',
80
+ 'type' => 'options',
81
+ 'options' =>$options
82
+
83
+ ));
84
+ $this->addColumn('start_date', array(
85
+ 'header'=> Mage::helper('dealoffer')->__('Start Date'),
86
+ 'index' => 'start_date',
87
+ 'type' => 'date',
88
+
89
+ ));
90
+ $this->addColumn('end_date', array(
91
+ 'header'=> Mage::helper('dealoffer')->__('End Date'),
92
+ 'index' => 'end_date',
93
+ 'type' => 'date',
94
+
95
+ ));
96
+ $this->addColumn('offer_image', array(
97
+ 'header' => Mage::helper('dealoffer')->__('Today Offer'),
98
+ 'index' => 'offer_image',
99
+ 'type' => 'options',
100
+ 'options' => array(
101
+ '1' => Mage::helper('dealoffer')->__('Yes'),
102
+ '0' => Mage::helper('dealoffer')->__('No'),
103
+ )
104
+ ));
105
+ $this->addColumn('status', array(
106
+ 'header' => Mage::helper('dealoffer')->__('Status'),
107
+ 'index' => 'status',
108
+ 'type' => 'options',
109
+ 'options' => array(
110
+ '1' => Mage::helper('dealoffer')->__('Enabled'),
111
+ '0' => Mage::helper('dealoffer')->__('Disabled'),
112
+ )
113
+ ));
114
+ if (!Mage::app()->isSingleStoreMode()) {
115
+ $this->addColumn('store_id', array(
116
+ 'header'=> Mage::helper('dealoffer')->__('Store Views'),
117
+ 'index' => 'store_id',
118
+ 'type' => 'store',
119
+ 'store_all' => true,
120
+ 'store_view'=> true,
121
+ 'sortable' => false,
122
+ 'filter_condition_callback'=> array($this, '_filterStoreCondition'),
123
+ ));
124
+ }
125
+
126
+
127
+ /*$this->addColumn('created_at', array(
128
+ 'header' => Mage::helper('dealoffer')->__('Created at'),
129
+ 'index' => 'created_at',
130
+ 'width' => '120px',
131
+ 'type' => 'datetime',
132
+ ));
133
+ $this->addColumn('updated_at', array(
134
+ 'header' => Mage::helper('dealoffer')->__('Updated at'),
135
+ 'index' => 'updated_at',
136
+ 'width' => '120px',
137
+ 'type' => 'datetime',
138
+ ));*/
139
+ $this->addColumn('action',
140
+ array(
141
+ 'header'=> Mage::helper('dealoffer')->__('Action'),
142
+ 'width' => '100',
143
+ 'type' => 'action',
144
+ 'getter'=> 'getId',
145
+ 'actions' => array(
146
+ array(
147
+ 'caption' => Mage::helper('dealoffer')->__('Edit'),
148
+ 'url' => array('base'=> '*/*/edit'),
149
+ 'field' => 'id'
150
+ )
151
+ ),
152
+ 'filter'=> false,
153
+ 'is_system' => true,
154
+ 'sortable' => false,
155
+ ));
156
+ $this->addExportType('*/*/exportCsv', Mage::helper('dealoffer')->__('CSV'));
157
+ $this->addExportType('*/*/exportExcel', Mage::helper('dealoffer')->__('Excel'));
158
+ $this->addExportType('*/*/exportXml', Mage::helper('dealoffer')->__('XML'));
159
+ return parent::_prepareColumns();
160
+ }
161
+ /**
162
+ * prepare mass action
163
+ * @access protected
164
+ * @return D4U_Dealoffer_Block_Adminhtml_Offers_Grid
165
+ * @author Ultimate Module Creator
166
+ */
167
+ protected function _prepareMassaction(){
168
+ $this->setMassactionIdField('entity_id');
169
+ $this->getMassactionBlock()->setFormFieldName('offers');
170
+ $this->getMassactionBlock()->addItem('delete', array(
171
+ 'label'=> Mage::helper('dealoffer')->__('Delete'),
172
+ 'url' => $this->getUrl('*/*/massDelete'),
173
+ 'confirm' => Mage::helper('dealoffer')->__('Are you sure?')
174
+ ));
175
+ $this->getMassactionBlock()->addItem('TodayDeal', array(
176
+ 'label'=> Mage::helper('dealoffer')->__('Set TodayDeal'),
177
+ 'url' => $this->getUrl('*/*/massTodayDeal'),
178
+ ));
179
+ $this->getMassactionBlock()->addItem('status', array(
180
+ 'label'=> Mage::helper('dealoffer')->__('Change status'),
181
+ 'url' => $this->getUrl('*/*/massStatus', array('_current'=>true)),
182
+ 'additional' => array(
183
+ 'status' => array(
184
+ 'name' => 'status',
185
+ 'type' => 'select',
186
+ 'class' => 'required-entry',
187
+ 'label' => Mage::helper('dealoffer')->__('Status'),
188
+ 'values' => array(
189
+ '1' => Mage::helper('dealoffer')->__('Enabled'),
190
+ '0' => Mage::helper('dealoffer')->__('Disabled'),
191
+ )
192
+ )
193
+ )
194
+ ));
195
+ return $this;
196
+ }
197
+ /**
198
+ * get the row url
199
+ * @access public
200
+ * @param D4U_Dealoffer_Model_Offers
201
+ * @return string
202
+ * @author Ultimate Module Creator
203
+ */
204
+ public function getRowUrl($row){
205
+ return $this->getUrl('*/*/edit', array('id' => $row->getId()));
206
+ }
207
+ /**
208
+ * get the grid url
209
+ * @access public
210
+ * @return string
211
+ * @author Ultimate Module Creator
212
+ */
213
+ public function getGridUrl(){
214
+ return $this->getUrl('*/*/grid', array('_current'=>true));
215
+ }
216
+ /**
217
+ * after collection load
218
+ * @access protected
219
+ * @return D4U_Dealoffer_Block_Adminhtml_Offers_Grid
220
+ * @author Ultimate Module Creator
221
+ */
222
+ protected function _afterLoadCollection(){
223
+ $this->getCollection()->walk('afterLoad');
224
+ parent::_afterLoadCollection();
225
+ }
226
+ /**
227
+ * filter store column
228
+ * @access protected
229
+ * @param D4U_Dealoffer_Model_Resource_Offers_Collection $collection
230
+ * @param Mage_Adminhtml_Block_Widget_Grid_Column $column
231
+ * @return D4U_Dealoffer_Block_Adminhtml_Offers_Grid
232
+ * @author Ultimate Module Creator
233
+ */
234
+ protected function _filterStoreCondition($collection, $column){
235
+ if (!$value = $column->getFilter()->getValue()) {
236
+ return;
237
+ }
238
+ $collection->addStoreFilter($value);
239
+ return $this;
240
+ }
241
+
242
+
243
+ }
app/code/local/D4U/Dealoffer/Block/Adminhtml/Offers/Helper/File.php ADDED
@@ -0,0 +1,101 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * D4U_Dealoffer extension
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the MIT License
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/mit-license.php
11
+ *
12
+ * @category D4U
13
+ * @package D4U_Dealoffer
14
+ * @copyright Copyright (c) 2013
15
+ * @license http://opensource.org/licenses/mit-license.php MIT License
16
+ */
17
+ /**
18
+ * Offers file field renderer helper
19
+ *
20
+ * @category D4U
21
+ * @package D4U_Dealoffer
22
+ * @author Ultimate Module Creator
23
+ */
24
+ class D4U_Dealoffer_Block_Adminhtml_Offers_Helper_File extends Varien_Data_Form_Element_Abstract{
25
+ /**
26
+ * constructor
27
+ * @access public
28
+ * @param array $data
29
+ * @return void
30
+ * @author Ultimate Module Creator
31
+ */
32
+ public function __construct($data){
33
+ parent::__construct($data);
34
+ $this->setType('file');
35
+ }
36
+ /**
37
+ * get element html
38
+ * @access public
39
+ * @return string
40
+ * @author Ultimate Module Creator
41
+ */
42
+ public function getElementHtml(){
43
+ $html = '';
44
+ $this->addClass('input-file');
45
+ $html.= parent::getElementHtml();
46
+ if ($this->getValue()) {
47
+ $url = $this->_getUrl();
48
+ if( !preg_match("/^http\:\/\/|https\:\/\//", $url) ) {
49
+ $url = Mage::helper('dealoffer/offers')->getFileBaseUrl() . $url;
50
+ }
51
+ $html .= '<br /><a href="'.$url.'">'.$this->_getUrl().'</a> ';
52
+ }
53
+ $html.= $this->_getDeleteCheckbox();
54
+ return $html;
55
+ }
56
+ /**
57
+ * get the delete checkbox HTML
58
+ * @access protected
59
+ * @return string
60
+ * @author Ultimate Module Creator
61
+ */
62
+ protected function _getDeleteCheckbox(){
63
+ $html = '';
64
+ if ($this->getValue()) {
65
+ $label = Mage::helper('dealoffer')->__('Delete File');
66
+ $html .= '<span class="delete-image">';
67
+ $html .= '<input type="checkbox" name="'.parent::getName().'[delete]" value="1" class="checkbox" id="'.$this->getHtmlId().'_delete"'.($this->getDisabled() ? ' disabled="disabled"': '').'/>';
68
+ $html .= '<label for="'.$this->getHtmlId().'_delete"'.($this->getDisabled() ? ' class="disabled"' : '').'> '.$label.'</label>';
69
+ $html .= $this->_getHiddenInput();
70
+ $html .= '</span>';
71
+ }
72
+ return $html;
73
+ }
74
+ /**
75
+ * get the hidden input
76
+ * @access protected
77
+ * @return string
78
+ * @author Ultimate Module Creator
79
+ */
80
+ protected function _getHiddenInput(){
81
+ return '<input type="hidden" name="'.parent::getName().'[value]" value="'.$this->getValue().'" />';
82
+ }
83
+ /**
84
+ * get the file url
85
+ * @access protected
86
+ * @return string
87
+ * @author Ultimate Module Creator
88
+ */
89
+ protected function _getUrl(){
90
+ return $this->getValue();
91
+ }
92
+ /**
93
+ * get the name
94
+ * @access public
95
+ * @return string
96
+ * @author Ultimate Module Creator
97
+ */
98
+ public function getName(){
99
+ return $this->getData('name');
100
+ }
101
+ }
app/code/local/D4U/Dealoffer/Block/Adminhtml/Offers/Helper/Image.php ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * D4U_Dealoffer extension
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the MIT License
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/mit-license.php
11
+ *
12
+ * @category D4U
13
+ * @package D4U_Dealoffer
14
+ * @copyright Copyright (c) 2013
15
+ * @license http://opensource.org/licenses/mit-license.php MIT License
16
+ */
17
+ /**
18
+ * Offers image field renderer helper
19
+ *
20
+ * @category D4U
21
+ * @package D4U_Dealoffer
22
+ * @author Ultimate Module Creator
23
+ */
24
+ class D4U_Dealoffer_Block_Adminhtml_Offers_Helper_Image extends Varien_Data_Form_Element_Image{
25
+ /**
26
+ * get the url of the image
27
+ * @access protected
28
+ * @return string
29
+ * @author Ultimate Module Creator
30
+ */
31
+ protected function _getUrl(){
32
+ $url = false;
33
+ if ($this->getValue()) {
34
+ $url = Mage::helper('dealoffer/offers_image')->getImageBaseUrl().$this->getValue();
35
+ }
36
+ return $url;
37
+ }
38
+ }
39
+
app/code/local/D4U/Dealoffer/Block/Adminhtml/Offers/Widget/Chooser.php ADDED
@@ -0,0 +1,156 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * D4U_Dealoffer extension
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the MIT License
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/mit-license.php
11
+ *
12
+ * @category D4U
13
+ * @package D4U_Dealoffer
14
+ * @copyright Copyright (c) 2013
15
+ * @license http://opensource.org/licenses/mit-license.php MIT License
16
+ */
17
+ /**
18
+ * Offers admin widget chooser
19
+ *
20
+ * @category D4U
21
+ * @package D4U_Dealoffer
22
+ * @author Ultimate Module Creator
23
+ */
24
+ class D4U_Dealoffer_Block_Adminhtml_Offers_Widget_Chooser extends Mage_Adminhtml_Block_Widget_Grid{
25
+ /**
26
+ * Block construction, prepare grid params
27
+ * @access public
28
+ * @param array $arguments Object data
29
+ * @return void
30
+ * @author Ultimate Module Creator
31
+ */
32
+ public function __construct($arguments=array()){
33
+ parent::__construct($arguments);
34
+ $this->setDefaultSort('entity_id');
35
+ $this->setDefaultDir('ASC');
36
+ $this->setUseAjax(true);
37
+ $this->setDefaultFilter(array('chooser_status' => '1'));
38
+ }
39
+ /**
40
+ * Prepare chooser element HTML
41
+ * @access public
42
+ * @param Varien_Data_Form_Element_Abstract $element Form Element
43
+ * @return Varien_Data_Form_Element_Abstract
44
+ * @author Ultimate Module Creator
45
+ */
46
+ public function prepareElementHtml(Varien_Data_Form_Element_Abstract $element){
47
+ $uniqId = Mage::helper('core')->uniqHash($element->getId());
48
+ $sourceUrl = $this->getUrl('dealoffer/adminhtml_dealoffer_offers_widget/chooser', array('uniq_id' => $uniqId));
49
+ $chooser = $this->getLayout()->createBlock('widget/adminhtml_widget_chooser')
50
+ ->setElement($element)
51
+ ->setTranslationHelper($this->getTranslationHelper())
52
+ ->setConfig($this->getConfig())
53
+ ->setFieldsetId($this->getFieldsetId())
54
+ ->setSourceUrl($sourceUrl)
55
+ ->setUniqId($uniqId);
56
+ if ($element->getValue()) {
57
+ $offers = Mage::getModel('dealoffer/offers')->load($element->getValue());
58
+ if ($offers->getId()) {
59
+ $chooser->setLabel($offers->getName());
60
+ }
61
+ }
62
+ $element->setData('after_element_html', $chooser->toHtml());
63
+ return $element;
64
+ }
65
+ /**
66
+ * Grid Row JS Callback
67
+ * @access public
68
+ * @return string
69
+ * @author Ultimate Module Creator
70
+ */
71
+ public function getRowClickCallback(){
72
+ $chooserJsObject = $this->getId();
73
+ $js = '
74
+ function (grid, event) {
75
+ var trElement = Event.findElement(event, "tr");
76
+ var offersId = trElement.down("td").innerHTML.replace(/^\s+|\s+$/g,"");
77
+ var offersTitle = trElement.down("td").next().innerHTML;
78
+ '.$chooserJsObject.'.setElementValue(offersId);
79
+ '.$chooserJsObject.'.setElementLabel(offersTitle);
80
+ '.$chooserJsObject.'.close();
81
+ }
82
+ ';
83
+ return $js;
84
+ }
85
+ /**
86
+ * Prepare a static blocks collection
87
+ * @access protected
88
+ * @return D4U_Dealoffer_Block_Adminhtml_Offers_Widget_Chooser
89
+ * @author Ultimate Module Creator
90
+ */
91
+ protected function _prepareCollection(){
92
+ $collection = Mage::getModel('dealoffer/offers')->getCollection();
93
+ $this->setCollection($collection);
94
+ return parent::_prepareCollection();
95
+ }
96
+ /**
97
+ * Prepare columns for the a grid
98
+ * @access protected
99
+ * @return D4U_Dealoffer_Block_Adminhtml_Offers_Widget_Chooser
100
+ * @author Ultimate Module Creator
101
+ */
102
+ protected function _prepareColumns(){
103
+ $this->addColumn('chooser_id', array(
104
+ 'header' => Mage::helper('dealoffer')->__('Id'),
105
+ 'align' => 'right',
106
+ 'index' => 'entity_id',
107
+ 'type' => 'number',
108
+ 'width' => 50
109
+ ));
110
+
111
+ $this->addColumn('chooser_name', array(
112
+ 'header'=> Mage::helper('dealoffer')->__('Name'),
113
+ 'align' => 'left',
114
+ 'index' => 'name',
115
+ ));
116
+ if (!Mage::app()->isSingleStoreMode()) {
117
+ $this->addColumn('store_id', array(
118
+ 'header'=> Mage::helper('dealoffer')->__('Store Views'),
119
+ 'index' => 'store_id',
120
+ 'type' => 'store',
121
+ 'store_all' => true,
122
+ 'store_view'=> true,
123
+ 'sortable' => false,
124
+ ));
125
+ }
126
+ $this->addColumn('chooser_status', array(
127
+ 'header'=> Mage::helper('dealoffer')->__('Status'),
128
+ 'index' => 'status',
129
+ 'type' => 'options',
130
+ 'options' => array(
131
+ 0 => Mage::helper('dealoffer')->__('Disabled'),
132
+ 1 => Mage::helper('dealoffer')->__('Enabled')
133
+ ),
134
+ ));
135
+ return parent::_prepareColumns();
136
+ }
137
+ /**
138
+ * get url for grid
139
+ * @access public
140
+ * @return string
141
+ * @author Ultimate Module Creator
142
+ */
143
+ public function getGridUrl(){
144
+ return $this->getUrl('adminhtml/dealoffer_offers_widget/chooser', array('_current' => true));
145
+ }
146
+ /**
147
+ * after collection load
148
+ * @access protected
149
+ * @return D4U_Dealoffer_Block_Adminhtml_Offers_Widget_Chooser
150
+ * @author Ultimate Module Creator
151
+ */
152
+ protected function _afterLoadCollection(){
153
+ $this->getCollection()->walk('afterLoad');
154
+ parent::_afterLoadCollection();
155
+ }
156
+ }
app/code/local/D4U/Dealoffer/Block/Offers/Catalog/Product/List.php ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * D4U_Dealoffer extension
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the MIT License
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/mit-license.php
11
+ *
12
+ * @category D4U
13
+ * @package D4U_Dealoffer
14
+ * @copyright Copyright (c) 2013
15
+ * @license http://opensource.org/licenses/mit-license.php MIT License
16
+ */
17
+ /**
18
+ * Offers product list
19
+ *
20
+ * @category D4U
21
+ * @package D4U_Dealoffer
22
+ * @author Ultimate Module Creator
23
+ */
24
+ class D4U_Dealoffer_Block_Offers_Catalog_Product_List extends Mage_Core_Block_Template{
25
+ /**
26
+ * get the list of products
27
+ * @access public
28
+ * @return Mage_Catalog_Model_Resource_Product_Collection
29
+ * @author Ultimate Module Creator
30
+ */
31
+ public function getProductCollection(){
32
+ $collection = $this->getOffers()->getSelectedProductsCollection();
33
+ $collection->addAttributeToSelect('name');
34
+ $collection->addUrlRewrite();
35
+ $collection->getSelect()->order('related.position');
36
+ Mage::getSingleton('catalog/product_status')->addVisibleFilterToCollection($collection);
37
+ Mage::getSingleton('catalog/product_visibility')->addVisibleInCatalogFilterToCollection($collection);
38
+ return $collection;
39
+ }
40
+ /**
41
+ * get current offers
42
+ * @access public
43
+ * @return D4U_Dealoffer_Model_Offers
44
+ * @author Ultimate Module Creator
45
+ */
46
+ public function getOffers(){
47
+ return Mage::registry('current_dealoffer_offers');
48
+ }
49
+ }
app/code/local/D4U/Dealoffer/Block/Offers/List.php ADDED
@@ -0,0 +1,67 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * D4U_Dealoffer extension
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the MIT License
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/mit-license.php
11
+ *
12
+ * @category D4U
13
+ * @package D4U_Dealoffer
14
+ * @copyright Copyright (c) 2013
15
+ * @license http://opensource.org/licenses/mit-license.php MIT License
16
+ */
17
+ /**
18
+ * Offers list block
19
+ *
20
+ * @category D4U
21
+ * @package D4U_Dealoffer
22
+ * @author Ultimate Module Creator
23
+ */
24
+ class D4U_Dealoffer_Block_Offers_List extends Mage_Core_Block_Template{
25
+ /**
26
+ * initialize
27
+ * @access public
28
+ * @return void
29
+ * @author Ultimate Module Creator
30
+ */
31
+ public function __construct(){
32
+ parent::__construct();
33
+ $todayDate = Mage::app()->getLocale()->date()->toString(Varien_Date::DATE_INTERNAL_FORMAT);
34
+ $offerss = Mage::getResourceModel('dealoffer/offers_collection')
35
+ ->addStoreFilter(Mage::app()->getStore())
36
+ ->addFilter('status', 1)
37
+ ->customaddFilter('end_date', $todayDate ,">=")
38
+ ;
39
+
40
+ //$offerss->setOrder('name', 'asc');
41
+ $offerss->GroupbyAdd('category_id');
42
+ $this->setOfferss($offerss);
43
+ }
44
+ /**
45
+ * prepare the layout
46
+ * @access protected
47
+ * @return D4U_Dealoffer_Block_Offers_List
48
+ * @author Ultimate Module Creator
49
+ */
50
+ protected function _prepareLayout(){
51
+ parent::_prepareLayout();
52
+ $pager = $this->getLayout()->createBlock('page/html_pager', 'dealoffer.offers.html.pager')
53
+ ->setCollection($this->getOfferss());
54
+ $this->setChild('pager', $pager);
55
+ $this->getOfferss()->load();
56
+ return $this;
57
+ }
58
+ /**
59
+ * get the pager html
60
+ * @access public
61
+ * @return string
62
+ * @author Ultimate Module Creator
63
+ */
64
+ public function getPagerHtml(){
65
+ return $this->getChildHtml('pager');
66
+ }
67
+ }
app/code/local/D4U/Dealoffer/Block/Offers/Rss.php ADDED
@@ -0,0 +1,80 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * D4U_Dealoffer extension
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the MIT License
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/mit-license.php
11
+ *
12
+ * @category D4U
13
+ * @package D4U_Dealoffer
14
+ * @copyright Copyright (c) 2013
15
+ * @license http://opensource.org/licenses/mit-license.php MIT License
16
+ */
17
+ /**
18
+ * Offers RSS block
19
+ *
20
+ * @category D4U
21
+ * @package D4U_Dealoffer
22
+ * @author Ultimate Module Creator
23
+ */
24
+ class D4U_Dealoffer_Block_Offers_Rss extends Mage_Rss_Block_Abstract{
25
+ /**
26
+ * Cache tag constant for feed reviews
27
+ * @var string
28
+ */
29
+ const CACHE_TAG = 'block_html_dealoffer_offers_rss';
30
+ /**
31
+ * constructor
32
+ * @access protected
33
+ * @return void
34
+ * @author Ultimate Module Creator
35
+ */
36
+ protected function _construct(){
37
+ $this->setCacheTags(array(self::CACHE_TAG));
38
+ /*
39
+ * setting cache to save the rss for 10 minutes
40
+ */
41
+ $this->setCacheKey('dealoffer_offers_rss');
42
+ $this->setCacheLifetime(600);
43
+ }
44
+ /**
45
+ * toHtml method
46
+ * @access protected
47
+ * @return string
48
+ * @author Ultimate Module Creator
49
+ */
50
+ protected function _toHtml(){
51
+ $url = Mage::helper('dealoffer')->getOfferssUrl();
52
+ $title = Mage::helper('dealoffer')->__('Offers');
53
+ $rssObj = Mage::getModel('rss/rss');
54
+ $data = array(
55
+ 'title' => $title,
56
+ 'description' => $title,
57
+ 'link'=> $url,
58
+ 'charset' => 'UTF-8',
59
+ );
60
+ $rssObj->_addHeader($data);
61
+ $collection = Mage::getModel('dealoffer/offers')->getCollection()
62
+ ->addStoreFilter(Mage::app()->getStore())
63
+
64
+ ->addFilter('status', 1)
65
+ ->addFilter('in_rss', 1)
66
+ ->setOrder('created_at');
67
+ $collection->load();
68
+ foreach ($collection as $item){
69
+ $description = '<p>';
70
+ $description .= '</p>';
71
+ $data = array(
72
+ 'title'=>$item->getName(),
73
+ 'link'=>$item->getOffersUrl(),
74
+ 'description' => $description
75
+ );
76
+ $rssObj->_addEntry($data);
77
+ }
78
+ return $rssObj->createRssXml();
79
+ }
80
+ }
app/code/local/D4U/Dealoffer/Block/Offers/View.php ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * D4U_Dealoffer extension
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the MIT License
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/mit-license.php
11
+ *
12
+ * @category D4U
13
+ * @package D4U_Dealoffer
14
+ * @copyright Copyright (c) 2013
15
+ * @license http://opensource.org/licenses/mit-license.php MIT License
16
+ */
17
+ /**
18
+ * Offers view block
19
+ *
20
+ * @category D4U
21
+ * @package D4U_Dealoffer
22
+ * @author Ultimate Module Creator
23
+ */
24
+ class D4U_Dealoffer_Block_Offers_View extends Mage_Core_Block_Template{
25
+ /**
26
+ * get the current offers
27
+ * @access public
28
+ * @return mixed (D4U_Dealoffer_Model_Offers|null)
29
+ * @author Ultimate Module Creator
30
+ */
31
+ public function getCurrentOffers(){
32
+ return Mage::registry('current_dealoffer_offers');
33
+ }
34
+ }
app/code/local/D4U/Dealoffer/Block/Offers/Widget/Link.php ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * D4U_Dealoffer extension
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the MIT License
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/mit-license.php
11
+ *
12
+ * @category D4U
13
+ * @package D4U_Dealoffer
14
+ * @copyright Copyright (c) 2013
15
+ * @license http://opensource.org/licenses/mit-license.php MIT License
16
+ */
17
+ /**
18
+ * Offers link widget block
19
+ *
20
+ * @category D4U
21
+ * @package D4U_Dealoffer
22
+ * @author Ultimate Module Creator
23
+ */
24
+ class D4U_Dealoffer_Block_Offers_Widget_Link extends D4U_Dealoffer_Block_Offers_Widget_View{
25
+ protected $_htmlTemplate = 'd4u_dealoffer/offers/widget/link.phtml';
26
+ }
app/code/local/D4U/Dealoffer/Block/Offers/Widget/View.php ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * D4U_Dealoffer extension
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the MIT License
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/mit-license.php
11
+ *
12
+ * @category D4U
13
+ * @package D4U_Dealoffer
14
+ * @copyright Copyright (c) 2013
15
+ * @license http://opensource.org/licenses/mit-license.php MIT License
16
+ */
17
+ /**
18
+ * Offers widget block
19
+ *
20
+ * @category D4U
21
+ * @package D4U_Dealoffer
22
+ * @author Ultimate Module Creator
23
+ */
24
+ class D4U_Dealoffer_Block_Offers_Widget_View extends Mage_Core_Block_Template implements Mage_Widget_Block_Interface{
25
+ protected $_htmlTemplate = 'd4u_dealoffer/offers/widget/view.phtml';
26
+ /**
27
+ * Prepare a for widget
28
+ * @access protected
29
+ * @return D4U_Dealoffer_Block_Offers_Widget_View
30
+ * @author Ultimate Module Creator
31
+ */
32
+ protected function _beforeToHtml() {
33
+ parent::_beforeToHtml();
34
+ $offersId = $this->getData('offers_id');
35
+ if ($offersId) {
36
+ $offers = Mage::getModel('dealoffer/offers')
37
+ ->setStoreId(Mage::app()->getStore()->getId())
38
+ ->load($offersId);
39
+ if ($offers->getStatus()) {
40
+ $this->setCurrentOffers($offers);
41
+ $this->setTemplate($this->_htmlTemplate);
42
+ }
43
+ }
44
+ return $this;
45
+ }
46
+ }
app/code/local/D4U/Dealoffer/Block/Rss.php ADDED
@@ -0,0 +1,52 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * D4U_Dealoffer extension
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the MIT License
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/mit-license.php
11
+ *
12
+ * @category D4U
13
+ * @package D4U_Dealoffer
14
+ * @copyright Copyright (c) 2013
15
+ * @license http://opensource.org/licenses/mit-license.php MIT License
16
+ */
17
+ /**
18
+ * Dealoffer RSS block
19
+ *
20
+ * @category D4U
21
+ * @package D4U_Dealoffer
22
+ * @author Ultimate Module Creator
23
+ */
24
+ class D4U_Dealoffer_Block_Rss extends Mage_Core_Block_Template{
25
+ protected $_feeds = array();
26
+ /**
27
+ * add a new feed
28
+ * @access public
29
+ * @param string $label
30
+ * @param string $url
31
+ * @param bool $prepare
32
+ * @return D4U_Dealoffer_Block_Rss
33
+ * @author Ultimate Module Creator
34
+ */
35
+ public function addFeed($label, $url, $prepare = false){
36
+ $link = ($prepare ? $this->getUrl($url) : $url);
37
+ $feed = new Varien_Object();
38
+ $feed->setLabel($label);
39
+ $feed->setUrl($link);
40
+ $this->_feeds[$link] = $feed;
41
+ return $this;
42
+ }
43
+ /**
44
+ * get the current feeds
45
+ * @access public
46
+ * @return array()
47
+ * @author Ultimate Module Creator
48
+ */
49
+ public function getFeeds(){
50
+ return $this->_feeds;
51
+ }
52
+ }
app/code/local/D4U/Dealoffer/Controller/Adminhtml/Dealoffer.php ADDED
@@ -0,0 +1,60 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * D4U_Dealoffer extension
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the MIT License
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/mit-license.php
11
+ *
12
+ * @category D4U
13
+ * @package D4U_Dealoffer
14
+ * @copyright Copyright (c) 2013
15
+ * @license http://opensource.org/licenses/mit-license.php MIT License
16
+ */
17
+ /**
18
+ * module base admin controller
19
+ *
20
+ * @category D4U
21
+ * @package D4U_Dealoffer
22
+ * @author Ultimate Module Creator
23
+ */
24
+ class D4U_Dealoffer_Controller_Adminhtml_Dealoffer extends Mage_Adminhtml_Controller_Action{
25
+ /**
26
+ * upload file and get the uploaded name
27
+ * @access public
28
+ * @param string $input
29
+ * @param string $destinationFolder
30
+ * @param array $data
31
+ * @return string
32
+ * @author Ultimate Module Creator
33
+ */
34
+ protected function _uploadAndGetName($input, $destinationFolder, $data){
35
+ try{
36
+ if (isset($data[$input]['delete'])){
37
+ return '';
38
+ }
39
+ else{
40
+ $uploader = new Varien_File_Uploader($input);
41
+ $uploader->setAllowRenameFiles(true);
42
+ $uploader->setFilesDispersion(true);
43
+ $uploader->setAllowCreateFolders(true);
44
+ $result = $uploader->save($destinationFolder);
45
+ return $result['file'];
46
+ }
47
+ }
48
+ catch (Exception $e){
49
+ if ($e->getCode() != Varien_File_Uploader::TMP_NAME_EMPTY){
50
+ throw $e;
51
+ }
52
+ else{
53
+ if (isset($data[$input]['value'])){
54
+ return $data[$input]['value'];
55
+ }
56
+ }
57
+ }
58
+ return '';
59
+ }
60
+ }
app/code/local/D4U/Dealoffer/Controller/Router.php ADDED
@@ -0,0 +1,76 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * D4U_Dealoffer extension
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the MIT License
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/mit-license.php
11
+ *
12
+ * @category D4U
13
+ * @package D4U_Dealoffer
14
+ * @copyright Copyright (c) 2013
15
+ * @license http://opensource.org/licenses/mit-license.php MIT License
16
+ */
17
+ /**
18
+ * Router
19
+ *
20
+ * @category D4U
21
+ * @package D4U_Dealoffer
22
+ * @author Ultimate Module Creator
23
+ */
24
+ class D4U_Dealoffer_Controller_Router extends Mage_Core_Controller_Varien_Router_Abstract{
25
+ /**
26
+ * init routes
27
+ * @access public
28
+ * @param Varien_Event_Observer $observer
29
+ * @return D4U_Dealoffer_Controller_Router
30
+ * @author Ultimate Module Creator
31
+ */
32
+ public function initControllerRouters($observer){
33
+ $front = $observer->getEvent()->getFront();
34
+ $front->addRouter('dealoffer', $this);
35
+ return $this;
36
+ }
37
+ /**
38
+ * Validate and match entities and modify request
39
+ * @access public
40
+ * @param Zend_Controller_Request_Http $request
41
+ * @return bool
42
+ * @author Ultimate Module Creator
43
+ */
44
+ public function match(Zend_Controller_Request_Http $request){
45
+ if (!Mage::isInstalled()) {
46
+ Mage::app()->getFrontController()->getResponse()
47
+ ->setRedirect(Mage::getUrl('install'))
48
+ ->sendResponse();
49
+ exit;
50
+ }
51
+ $urlKey = trim($request->getPathInfo(), '/');
52
+ $check = array();
53
+ $check['offers'] = new Varien_Object(array(
54
+ 'model' =>'dealoffer/offers',
55
+ 'controller' => 'offers',
56
+ 'action' => 'view',
57
+ 'param' => 'id',
58
+ ));
59
+ foreach ($check as $key=>$settings){
60
+ $model = Mage::getModel($settings->getModel());
61
+ $id = $model->checkUrlKey($urlKey, Mage::app()->getStore()->getId());
62
+ if ($id){
63
+ $request->setModuleName('dealoffer')
64
+ ->setControllerName($settings->getController())
65
+ ->setActionName($settings->getAction())
66
+ ->setParam($settings->getParam(), $id);
67
+ $request->setAlias(
68
+ Mage_Core_Model_Url_Rewrite::REWRITE_REQUEST_PATH_ALIAS,
69
+ $urlKey
70
+ );
71
+ return true;
72
+ }
73
+ }
74
+ return false;
75
+ }
76
+ }
app/code/local/D4U/Dealoffer/Helper/Data.php ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * D4U_Dealoffer extension
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the MIT License
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/mit-license.php
11
+ *
12
+ * @category D4U
13
+ * @package D4U_Dealoffer
14
+ * @copyright Copyright (c) 2013
15
+ * @license http://opensource.org/licenses/mit-license.php MIT License
16
+ */
17
+ /**
18
+ * Dealoffer default helper
19
+ *
20
+ * @category D4U
21
+ * @package D4U_Dealoffer
22
+ * @author Ultimate Module Creator
23
+ */
24
+ class D4U_Dealoffer_Helper_Data extends Mage_Core_Helper_Abstract{
25
+ /**
26
+ * get the url to the offers list page
27
+ * @access public
28
+ * @return string
29
+ * @author Ultimate Module Creator
30
+ */
31
+ public function getOfferssUrl(){
32
+ return Mage::getUrl('dealoffer/offers/index');
33
+ }
34
+ }
app/code/local/D4U/Dealoffer/Helper/Image/Abstract.php ADDED
@@ -0,0 +1,461 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * D4U_Dealoffer extension
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the MIT License
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/mit-license.php
11
+ *
12
+ * @category D4U
13
+ * @package D4U_Dealoffer
14
+ * @copyright Copyright (c) 2013
15
+ * @license http://opensource.org/licenses/mit-license.php MIT License
16
+ */
17
+ /**
18
+ * abstract image helper
19
+ *
20
+ * @category D4U
21
+ * @package D4U_Dealoffer
22
+ * @author Ultimate Module Creator
23
+ */
24
+ abstract class D4U_Dealoffer_Helper_Image_Abstract extends Mage_Core_Helper_Data{
25
+ /**
26
+ * path to image placeholder
27
+ * override in child
28
+ * @var string
29
+ */
30
+ protected $_placeholder = '';
31
+ /**
32
+ * subdirectory to save imaves
33
+ * override in child
34
+ * @var string
35
+ */
36
+ protected $_subdir = '';
37
+ /**
38
+ * image processor
39
+ * @var null|Varien_Image_Adapter_Gd2
40
+ */
41
+ protected $_imageProcessor = null;
42
+ /**
43
+ * image to process
44
+ * @var unknown_type
45
+ */
46
+ protected $_image = null;
47
+ /**
48
+ * error message
49
+ * @var string
50
+ */
51
+ protected $_openError = "";
52
+ /**
53
+ * keep image frame
54
+ * @var bool
55
+ */
56
+ protected $_keepFrame = false;
57
+ /**
58
+ * keep image aspect ratio
59
+ * @var bool
60
+ */
61
+ protected $_keepAspectRatio = true;
62
+ /**
63
+ * constrain image
64
+ * @var bool
65
+ */
66
+ protected $_constrainOnly = true;
67
+ /**
68
+ * addaptive resize - crop
69
+ * https://github.com/wearefarm/magento-adaptive-resize/blob/master/README.md
70
+ * @var bool
71
+ */
72
+ protected $_adaptiveResize = 'center'; // false|center|top|bottom
73
+ /**
74
+ * image width
75
+ * @var mixed(null|int)
76
+ */
77
+ protected $_width = null;
78
+ /**
79
+ * image height
80
+ * @var mixed(null|int)
81
+ */
82
+ protected $_height = null;
83
+ /**
84
+ * image resize needed
85
+ * @var mixed (null|array)
86
+ */
87
+ protected $_scheduledResize = null;
88
+ /**
89
+ * image is resized
90
+ * @var bool
91
+ */
92
+ protected $_resized = false;
93
+ /**
94
+ * addaptive resize positions
95
+ * https://github.com/wearefarm/magento-adaptive-resize/blob/master/README.md
96
+ * @var array
97
+ */
98
+ protected $_adaptiveResizePositions = array(
99
+ 'center'=>array(0.5,0.5),
100
+ 'top' =>array(1,0),
101
+ 'bottom'=>array(0,1)
102
+ );
103
+ /**
104
+ * resized image folder name
105
+ * @var string
106
+ */
107
+ protected $_resizeFolderName = 'cache';
108
+ /**
109
+ * get the image base dir
110
+ * @access public
111
+ * @return string
112
+ * @author Ultimate Module Creator
113
+ */
114
+ public function getImageBaseDir(){
115
+ return Mage::getBaseDir('media').DS.$this->_subdir.DS.'image';
116
+ }
117
+ /**
118
+ * get the image url for object
119
+ * @access public
120
+ * @return string
121
+ * @author Ultimate Module Creator
122
+ */
123
+ public function getImageBaseUrl(){
124
+ return Mage::getBaseUrl('media').$this->_subdir.'/'.'image';
125
+ }
126
+
127
+ /**
128
+ * init image
129
+ * @access public
130
+ * @param Varien_Object $object
131
+ * @param string $imageField
132
+ * @return D4U_Dealoffer_Helper_Image_Abstract
133
+ * @author Ultimate Module Creator
134
+ */
135
+ public function init(Varien_Object $object, $imageField = 'image'){
136
+ $this->_imageProcessor = null;
137
+ $this->_image = $object->getDataUsingMethod($imageField);
138
+ if(!$this->_image) {
139
+ $this->_image = '/'.$this->_placeholder;
140
+ }
141
+ $this->_widht = null;
142
+ $this->_height = null;
143
+ $this->_scheduledResize = false;
144
+ $this->_resized = false;
145
+ $this->_adaptiveResize = 'center';
146
+
147
+ try{
148
+ $this->_getImageProcessor()->open($this->getImageBaseDir().$this->_image);
149
+ }
150
+ catch (Exception $e){
151
+ $this->_openError = $e->getMessage();
152
+ try{
153
+ $this->_getImageProcessor()->open(Mage::getDesign()->getSkinUrl($this->_placeholder));
154
+ $this->_image = '/'.$this->_placeholder;
155
+ }
156
+ catch(Exception $e) {
157
+ $this->_openError .= "\n".$e->getMessage();
158
+ $this->_image = null;
159
+ }
160
+ }
161
+ return $this;
162
+ }
163
+ /**
164
+ * get the image processor
165
+ * @access protected
166
+ * @return Varien_Image_Adapter_Gd2
167
+ * @author Ultimate Module Creator
168
+ */
169
+ protected function _getImageProcessor() {
170
+ if (is_null($this->_imageProcessor)) {
171
+ $this->_imageProcessor = Varien_Image_Adapter::factory('GD2');
172
+ $this->_imageProcessor->keepFrame($this->_keepFrame);
173
+ $this->_imageProcessor->keepAspectRatio($this->_keepAspectRatio);
174
+ $this->_imageProcessor->constrainOnly($this->_constrainOnly);
175
+ }
176
+ return $this->_imageProcessor;
177
+ }
178
+ /**
179
+ * Get/set keepAspectRatio
180
+ * @access public
181
+ * @param bool $value
182
+ * @return mixed(bool|D4U_Dealoffer_Helper_Image_Abstract)
183
+ * @author Ultimate Module Creator
184
+ */
185
+ public function keepAspectRatio($value = null){
186
+ if (null !== $value) {
187
+ $this->_getImageProcessor()->keepAspectRatio($value);
188
+ return $this;
189
+ }
190
+ else {
191
+ return $this->_getImageProcessor()->keepAspectRatio();
192
+ }
193
+ }
194
+
195
+ /**
196
+ * Get/set keepFrame
197
+ * @access public
198
+ * @param bool $value
199
+ * @return mixed(bool|D4U_Dealoffer_Helper_Image_Abstract)
200
+ * @author Ultimate Module Creator
201
+ */
202
+ public function keepFrame($value = null){
203
+ if (null !== $value) {
204
+ $this->_getImageProcessor()->keepFrame($value);
205
+ return $this;
206
+ }
207
+ else {
208
+ return $this->_getImageProcessor()->keepFrame();
209
+ }
210
+ }
211
+ /**
212
+ * Get/set keepTransparency
213
+ * @access public
214
+ * @param bool $value
215
+ * @return mixed(bool|D4U_Dealoffer_Helper_Image_Abstract)
216
+ * @author Ultimate Module Creator
217
+ */
218
+ public function keepTransparency($value = null){
219
+ if (null !== $value) {
220
+ $this->_getImageProcessor()->keepTransparency($value);
221
+ return $this;
222
+ }
223
+ else {
224
+ return $this->_getImageProcessor()->keepTransparency();
225
+ }
226
+ }
227
+ /**
228
+ * Get/set adaptiveResize
229
+ * @access public
230
+ * @param bool|string $value
231
+ * @return mixed(bool|D4U_Dealoffer_Helper_Image_Abstract)
232
+ * https://github.com/wearefarm/magento-adaptive-resize/blob/master/README.md
233
+ * @author Ultimate Module Creator
234
+ */
235
+ public function adaptiveResize($value = null){
236
+ if (null !== $value) {
237
+ $this->_adaptiveResize = $value;
238
+ if($value) {
239
+ $this->keepFrame(false);
240
+ }
241
+ return $this;
242
+ }
243
+ else {
244
+ return $this->_adaptiveResize;
245
+ }
246
+ }
247
+ /**
248
+ * Get/set constrainOnly
249
+ * @access public
250
+ * @param bool $value
251
+ * @return mixed(bool|D4U_Dealoffer_Helper_Image_Abstract)
252
+ * @author Ultimate Module Creator
253
+ */
254
+ public function constrainOnly($value = null){
255
+ if (null !== $value) {
256
+ $this->_getImageProcessor()->constrainOnly($value);
257
+ return $this;
258
+ }
259
+ else {
260
+ return $this->_getImageProcessor()->constrainOnly();
261
+ }
262
+ }
263
+ /**
264
+ * Get/set quality, values in percentage from 0 to 100
265
+ * @access public
266
+ * @param int $value
267
+ * @return mixed(bool|D4U_Dealoffer_Helper_Image_Abstract)
268
+ * @author Ultimate Module Creator
269
+ */
270
+ public function quality($value = null){
271
+ if (null !== $value) {
272
+ $this->_getImageProcessor()->quality($value);
273
+ return $this;
274
+ }
275
+ else {
276
+ return $this->_getImageProcessor()->quality();
277
+ }
278
+ }
279
+ /**
280
+ * Get/set keepBackgroundColor
281
+ * @access public
282
+ * @param array $value
283
+ * @return mixed(bool|D4U_Dealoffer_Helper_Image_Abstract)
284
+ * @author Ultimate Module Creator
285
+ */
286
+ public function backgroundColor($value = null){
287
+ if (null !== $value) {
288
+ $this->_getImageProcessor()-> backgroundColor($value);
289
+ return $this;
290
+ }
291
+ else {
292
+ return $this->_getImageProcessor()-> backgroundColor();
293
+ }
294
+ }
295
+ /**
296
+ * resize image
297
+ * @access public
298
+ * @param int $width - defaults to null
299
+ * @param int $height - defaults to null
300
+ * @return D4U_Dealoffer_Helper_Image_Abstract
301
+ * @author Ultimate Module Creator
302
+ */
303
+ public function resize($width = null, $height = null) {
304
+ $this->_scheduledResize = true;
305
+ $this->_width = $width;
306
+ $this->_height = $height;
307
+ return $this;
308
+ }
309
+ /**
310
+ * get destination image prefix
311
+ * @access protected
312
+ * @return D4U_Dealoffer_Helper_Image_Abstract
313
+ * @author Ultimate Module Creator
314
+ */
315
+ protected function _getDestinationImagePrefix() {
316
+ if(!$this->_image) {
317
+ return $this;
318
+ }
319
+ $imageRealPath = "";
320
+ if($this->_scheduledResize) {
321
+ $width = $this->_width;
322
+ $height = $this->_height;
323
+ $adaptive = $this->adaptiveResize();
324
+ $keepFrame = $this->keepFrame();
325
+ $keepAspectRatio= $this->keepAspectRatio();
326
+ $constrainOnly = $this->constrainOnly();
327
+ $imageRealPath = $width.'x'.$height;
328
+ $options = "";
329
+
330
+ if(!$keepAspectRatio) {
331
+ $imageRealPath .= '-exact';
332
+ }
333
+ else {
334
+ if(!$keepFrame && $width && $height && ($adaptive !== false)) {
335
+ $adaptive = strtolower(trim($adaptive));
336
+ if(isset($this->_adaptiveResizePositions[$adaptive])) {
337
+ $imageRealPath .= '-'.$adaptive;
338
+ }
339
+ }
340
+ }
341
+ if($keepFrame) {
342
+ $imageRealPath .= '-frame';
343
+ $_backgroundColor = $this->backgroundColor();
344
+ if($_backgroundColor) {
345
+ $imageRealPath .= '-'.implode('-',$_backgroundColor);
346
+ }
347
+ }
348
+ if(!$constrainOnly) {
349
+ $imageRealPath .= '-zoom';
350
+ }
351
+ }
352
+ return $imageRealPath;
353
+ }
354
+ /**
355
+ * get image destination path
356
+ * @access protected
357
+ * @return string
358
+ * @author Ultimate Module Creator
359
+ */
360
+ protected function _getDestinationPath() {
361
+ if(!$this->_image) {
362
+ return $this;
363
+ }
364
+ if($this->_scheduledResize) {
365
+ return $this->getImageBaseDir().DS.$this->_resizeFolderName.DS.$this->_getDestinationImagePrefix().DS.$this->_image;
366
+ } else {
367
+ return $this->getImageBaseDir().DS.$this->_image;
368
+ }
369
+ }
370
+ /**
371
+ * get image url
372
+ * @access protected
373
+ * @return mixed (string|bool)
374
+ * @author Ultimate Module Creator
375
+ */
376
+ protected function _getImageUrl() {
377
+ if(!$this->_image) {
378
+ return false;
379
+ }
380
+ if($this->_scheduledResize) {
381
+ return $this->getImageBaseUrl().'/'.$this->_resizeFolderName.'/'.$this->_getDestinationImagePrefix().$this->_image;
382
+ }
383
+ else {
384
+ return $this->getImageBaseUrl().$this->_image;
385
+ }
386
+ }
387
+ /**
388
+ * resize image
389
+ * @access protected
390
+ * @return D4U_Dealoffer_Helper_Image_Abstract
391
+ * @author Ultimate Module Creator
392
+ */
393
+ protected function _doResize() {
394
+ if(!$this->_image || !$this->_scheduledResize || $this->_resized) {
395
+ return $this;
396
+ }
397
+ $this->_resized = true; //mark as resized
398
+ $width = $this->_width;
399
+ $height = $this->_height;
400
+ $adaptive = $width && $height &&
401
+ $this->keepAspectRatio() && !$this->keepFrame() &&
402
+ ($this->adaptiveResize() !== false);
403
+ $adaptivePosition = false;
404
+ if($adaptive) {
405
+ $adaptive = strtolower(trim($this->adaptiveResize()));
406
+ if(isset($this->_adaptiveResizePositions[$adaptive])) {
407
+ $adaptivePosition = $this->_adaptiveResizePositions[$adaptive];
408
+ }
409
+ }
410
+ $processor = $this->_getImageProcessor();
411
+
412
+ if(!$adaptivePosition) {
413
+ $processor->resize($width, $height);
414
+ return $this;
415
+ }
416
+ //make adaptive resize
417
+ //https://github.com/wearefarm/magento-adaptive-resize/blob/master/README.md
418
+ $currentRatio = $processor->getOriginalWidth() / $processor->getOriginalHeight();
419
+ $targetRatio = $width / $height;
420
+ if ($targetRatio > $currentRatio) {
421
+ $processor->resize($width, null);
422
+ }
423
+ else {
424
+ $processor->resize(null, $height);
425
+ }
426
+ $diffWidth = $processor->getOriginalWidth() - $width;
427
+ $diffHeight = $processor->getOriginalHeight() - $height;
428
+ if($diffWidth || $diffHeight) {
429
+ $processor->crop(
430
+ floor($diffHeight * $adaptivePosition[0]), //top rate
431
+ floor($diffWidth / 2),
432
+ ceil($diffWidth / 2),
433
+ ceil($diffHeight * $adaptivePosition[1]) //bottom rate
434
+ );
435
+ }
436
+ return $this;
437
+ }
438
+ /**
439
+ * to string - no need for cache expire because the image names will be different
440
+ * @access public
441
+ * @return string
442
+ * @author Ultimate Module Creator
443
+ */
444
+ public function __toString(){
445
+ try{
446
+ if(!$this->_image) {
447
+ throw new Exception($this->_openError);
448
+ }
449
+ $imageRealPath = $this->_getDestinationPath();
450
+ if (!file_exists($imageRealPath)) {
451
+ $this->_doResize();
452
+ $this->_getImageProcessor()->save($imageRealPath);
453
+ }
454
+ return $this->_getImageUrl();
455
+ }
456
+ catch (Exception $e){
457
+ Mage::logException($e);
458
+ return 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAFr0lEQVR42rWXaUxUZxSGZVOKpWBRCGrSijBgDG1dagaxVgNSUqhAqq1CqzVVksb+sdZU0hgbfhQ1riEoiHFns4qVEYWglEWgVaBQLXRYJKzCzCA7KCpvz7njHbgz4AXSkryZYea73/Oe5Tv3zhQABtGfGcmCZPk/yYIZEuYIuDnJgeRKcn8pj/9Q7rw3M5g1moFpJGVnVxe0Wi20Oh107e1of/wYj1kdHejo7AR/z+oS1d0tqLunx6AeVm+vifoHBsAMZo1lYKVWq0NzyyO0PGrFo9Y2tLZp0KYRDA2bMjamN6c3OGzSxGwvmWDGWAasSR9qde0EbiVwG4E10AxnQw/XQ1nDUAYZZ2QU9fX1gRnMGtMAASTwMUvBGoYyQFoClmkJ5A0QhOHSlEtTbQoeAewVRdGy+kZoYDwGCGSacmOwKVQK6+9H/yh68uSJvAGGCGBTuACur6pCXUICssPDcXfHDvy5dy8KIyLQdOkSmh8+FNI8YCwCs54+fSpvgCNkOJeiwwieHROD3KBP8CDyJ9QePYLq/fuhjoqCml7L9/yI236+yI+L40hZDJRocHBwXAZGjTztq00o+mYbKiIj8cf2cGT6rIJKqUTakiW44a1EwdYtKNm1C/lfboBq0xcMM9GzZ8/kDRDMBJ5FkWeHrkPJD7uQvsYb177egr/LyzndQhPmpqYi2c0Fv23aiPxt25AZHIi8kycnZ4CaS1rz2lpcXbEUhd9ux7VVSmSfO8d1NaSY36cGBSJzrT9uhYYia+PnyFy/Dul+K6FpbmaoQc+fP5c3wF0twtnM5d27cfPTAEFJYRskcH69vjkMBaEh1BtBuEX9kbJIgav+q5EW6Iu0PXsYatCLFy/kDfCR4j7g1PIxSwwm+PogJCo98c/9+1L41s24FxaCIh8f5K3xwdVlC3CeTkTCewqkBvjhSthnkzMgwvn9WS9PpH7kh3Pve4yE0+brURLsixJqxOIPvKHyWoicM2eEWscrZuPI3Dk4tciNoRLJGuCB0q0fMMJQOb5YgQMz7BHj5mQYJvE+3shdqkDpvHkonz8PqmUKZJ8+zQAh0ti3HbDPbAriFusNDA0NscZngKFC9C8n2sm1foh6wwqHZ9vgdnIyYlZ5QeVojd/p0r+szHHZxR5Z8fGGCCtKSxHnZI1ouuZsyMcMlkjWAEN79dELEV/4ficOzZmOE7TpPlcnpDrb4A5d9oDgv7ja42ZcrAHOgLggfyTMskbsXBukROyeeAkYKkbPHd9UX48DHjMRa0lAgmfQJXenmiPFfQauH4+RwH89fBgXXGyRTOaOLpiFlsbGic8BHi5i9GyAm+7yoYOIUdghiZbfmmqBC++8iWiaCyJcXVaG6ABfpNCaLDJ32s0OV+ga2oP3Eu+QvJ/8A8mA3oDkvLP7Q8H+OOVB9ba2QKHja8icb4vEBTNx0cMB11xex10q071pFjhPa47QWuojPs58P+H7Cov/HyLGcjkD7Fw0IElf0oH9OOjpiBvudihztEG1uRnqSGoylE3RH/N0wsWon4WHFY1Gg5aWFjQ1NaGhoRH19Q1QqVR3iPEWyVzOgJh+iQFWQ10dTuz8DvsCVuOY0gXRXvNxNMQfsfRZjVotwGtpfBcWFqKoqAjldM+oqKhguJr2X0iayjw5Axy9sYGRE01yvvk7vo4HGEeel5fHnwt1r6qqYngj7b1IbD45Ayb1Z4DUgHS48BqGcb055Tk5uUIfVVdXIyMjQ2tra7uC9p7OHHkDBB7bgGn0/Bmv5ej5QaaOSlRcXIyamhoB7uzs7Ef72jJjogaM6//K9HPH63Q6qKkPKisrkZ6e3kiRL2c4yUzWgPjDZCIGAEgM0C8qNsBwbrh3STZSoLyB5QR8Ve1HKwGv5x7gsz5E8AL+HSie9YkYsHx5Rr25FJOUF2kuyUoCkjUgNcGZsJ6kpolDZrz6F2ZUsalEFcbPAAAAAElFTkSuQmCC';
459
+ }
460
+ }
461
+ }
app/code/local/D4U/Dealoffer/Helper/Offers.php ADDED
@@ -0,0 +1,70 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * D4U_Dealoffer extension
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the MIT License
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/mit-license.php
11
+ *
12
+ * @category D4U
13
+ * @package D4U_Dealoffer
14
+ * @copyright Copyright (c) 2013
15
+ * @license http://opensource.org/licenses/mit-license.php MIT License
16
+ */
17
+ /**
18
+ * Offers helper
19
+ *
20
+ * @category D4U
21
+ * @package D4U_Dealoffer
22
+ * @author Ultimate Module Creator
23
+ */
24
+ class D4U_Dealoffer_Helper_Offers extends Mage_Core_Helper_Abstract{
25
+ /**
26
+ * check if the rss for offers is enabled
27
+ * @access public
28
+ * @return bool
29
+ * @author Ultimate Module Creator
30
+ */
31
+ public function isRssEnabled(){
32
+ return Mage::getStoreConfigFlag('rss/config/active') && Mage::getStoreConfigFlag('dealoffer/offers/rss');
33
+ }
34
+ /**
35
+ * get the link to the offers rss list
36
+ * @access public
37
+ * @return string
38
+ * @author Ultimate Module Creator
39
+ */
40
+ public function getRssUrl(){
41
+ return Mage::getUrl('dealoffer/offers/rss');
42
+ }
43
+ /**
44
+ * get base files dir
45
+ * @access public
46
+ * @return string
47
+ * @author Ultimate Module Creator
48
+ */
49
+ public function getFileBaseDir(){
50
+ return Mage::getBaseDir('media').DS.'offers'.DS.'file';
51
+ }
52
+ /**
53
+ * get base file url
54
+ * @access public
55
+ * @return string
56
+ * @author Ultimate Module Creator
57
+ */
58
+ public function getFileBaseUrl(){
59
+ return Mage::getBaseUrl('media').'offers'.'/'.'file';
60
+ }
61
+ /**
62
+ * check if breadcrumbs can be used
63
+ * @access public
64
+ * @return bool
65
+ * @author Ultimate Module Creator
66
+ */
67
+ public function getUseBreadcrumbs(){
68
+ return Mage::getStoreConfigFlag('dealoffer/offers/breadcrumbs');
69
+ }
70
+ }
app/code/local/D4U/Dealoffer/Helper/Offers/Image.php ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * D4U_Dealoffer extension
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the MIT License
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/mit-license.php
11
+ *
12
+ * @category D4U
13
+ * @package D4U_Dealoffer
14
+ * @copyright Copyright (c) 2013
15
+ * @license http://opensource.org/licenses/mit-license.php MIT License
16
+ */
17
+ /**
18
+ * Offers image helper
19
+ *
20
+ * @category D4U
21
+ * @package D4U_Dealoffer
22
+ * @author Ultimate Module Creator
23
+ */
24
+ class D4U_Dealoffer_Helper_Offers_Image extends D4U_Dealoffer_Helper_Image_Abstract{
25
+ /**
26
+ * image placeholder
27
+ * @var string
28
+ */
29
+ protected $_placeholder = 'images/placeholder/offers.jpg';
30
+ /**
31
+ * image subdir
32
+ * @var string
33
+ */
34
+ protected $_subdir = 'offers';
35
+ }
app/code/local/D4U/Dealoffer/Helper/Product.php ADDED
@@ -0,0 +1,53 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * D4U_Dealoffer extension
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the MIT License
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/mit-license.php
11
+ *
12
+ * @category D4U
13
+ * @package D4U_Dealoffer
14
+ * @copyright Copyright (c) 2013
15
+ * @license http://opensource.org/licenses/mit-license.php MIT License
16
+ */
17
+ /**
18
+ * Product helper
19
+ *
20
+ * @category D4U
21
+ * @package D4U_Dealoffer
22
+ * @author Ultimate Module Creator
23
+ */
24
+ class D4U_Dealoffer_Helper_Product extends D4U_Dealoffer_Helper_Data{
25
+ /**
26
+ * get the selected offerss for a product
27
+ * @access public
28
+ * @param Mage_Catalog_Model_Product $product
29
+ * @return array()
30
+ * @author Ultimate Module Creator
31
+ */
32
+ public function getSelectedOfferss(Mage_Catalog_Model_Product $product){
33
+ if (!$product->hasSelectedOfferss()) {
34
+ $offerss = array();
35
+ foreach ($this->getSelectedOfferssCollection($product) as $offers) {
36
+ $offerss[] = $offers;
37
+ }
38
+ $product->setSelectedOfferss($offerss);
39
+ }
40
+ return $product->getData('selected_offerss');
41
+ }
42
+ /**
43
+ * get offers collection for a product
44
+ * @access public
45
+ * @param Mage_Catalog_Model_Product $product
46
+ * @return D4U_Dealoffer_Model_Resource_Offers_Collection
47
+ */
48
+ public function getSelectedOfferssCollection(Mage_Catalog_Model_Product $product){
49
+ $collection = Mage::getResourceSingleton('dealoffer/offers_collection')
50
+ ->addProductFilter($product);
51
+ return $collection;
52
+ }
53
+ }
app/code/local/D4U/Dealoffer/Model/Adminhtml/Observer.php ADDED
@@ -0,0 +1,81 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * D4U_Dealoffer extension
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the MIT License
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/mit-license.php
11
+ *
12
+ * @category D4U
13
+ * @package D4U_Dealoffer
14
+ * @copyright Copyright (c) 2013
15
+ * @license http://opensource.org/licenses/mit-license.php MIT License
16
+ */
17
+ /**
18
+ * Adminhtml observer
19
+ *
20
+ * @category D4U
21
+ * @package D4U_Dealoffer
22
+ * @author Ultimate Module Creator
23
+ */
24
+ class D4U_Dealoffer_Model_Adminhtml_Observer{
25
+ /**
26
+ * check if tab can be added
27
+ * @access protected
28
+ * @param Mage_Catalog_Model_Product $product
29
+ * @return bool
30
+ * @author Ultimate Module Creator
31
+ */
32
+ protected function _canAddTab($product){
33
+ if ($product->getId()){
34
+ return true;
35
+ }
36
+ if (!$product->getAttributeSetId()){
37
+ return false;
38
+ }
39
+ $request = Mage::app()->getRequest();
40
+ if ($request->getParam('type') == 'configurable'){
41
+ if ($request->getParam('attribtues')){
42
+ return true;
43
+ }
44
+ }
45
+ return false;
46
+ }
47
+ /**
48
+ * add the offers tab to products
49
+ * @access public
50
+ * @param Varien_Event_Observer $observer
51
+ * @return D4U_Dealoffer_Model_Adminhtml_Observer
52
+ * @author Ultimate Module Creator
53
+ */
54
+ public function addOffersBlock($observer){
55
+ $block = $observer->getEvent()->getBlock();
56
+ $product = Mage::registry('product');
57
+ if ($block instanceof Mage_Adminhtml_Block_Catalog_Product_Edit_Tabs && $this->_canAddTab($product)){
58
+ $block->addTab('offerss', array(
59
+ 'label' => Mage::helper('dealoffer')->__('Offerss'),
60
+ 'url' => Mage::helper('adminhtml')->getUrl('adminhtml/dealoffer_offers_catalog_product/offerss', array('_current' => true)),
61
+ 'class' => 'ajax',
62
+ ));
63
+ }
64
+ return $this;
65
+ }
66
+ /**
67
+ * save offers - product relation
68
+ * @access public
69
+ * @param Varien_Event_Observer $observer
70
+ * @return D4U_Dealoffer_Model_Adminhtml_Observer
71
+ * @author Ultimate Module Creator
72
+ */
73
+ public function saveOffersData($observer){
74
+ $post = Mage::app()->getRequest()->getPost('offerss', -1);
75
+ if ($post != '-1') {
76
+ $post = Mage::helper('adminhtml/js')->decodeGridSerializedInput($post);
77
+ $product = Mage::registry('product');
78
+ $offersProduct = Mage::getResourceSingleton('dealoffer/offers_product')->saveProductRelation($product, $post);
79
+ }
80
+ return $this;
81
+ }}
app/code/local/D4U/Dealoffer/Model/Adminhtml/Search/Offers.php ADDED
@@ -0,0 +1,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * D4U_Dealoffer extension
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the MIT License
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/mit-license.php
11
+ *
12
+ * @category D4U
13
+ * @package D4U_Dealoffer
14
+ * @copyright Copyright (c) 2013
15
+ * @license http://opensource.org/licenses/mit-license.php MIT License
16
+ */
17
+ /**
18
+ * Admin search model
19
+ *
20
+ * @category D4U
21
+ * @package D4U_Dealoffer
22
+ * @author Ultimate Module Creator
23
+ */
24
+ class D4U_Dealoffer_Model_Adminhtml_Search_Offers extends Varien_Object{
25
+ /**
26
+ * Load search results
27
+ * @access public
28
+ * @return D4U_Dealoffer_Model_Adminhtml_Search_Offers
29
+ * @author Ultimate Module Creator
30
+ */
31
+ public function load(){
32
+ $arr = array();
33
+ if (!$this->hasStart() || !$this->hasLimit() || !$this->hasQuery()) {
34
+ $this->setResults($arr);
35
+ return $this;
36
+ }
37
+ $collection = Mage::getResourceModel('dealoffer/offers_collection')
38
+ ->addFieldToFilter('name', array('like' => $this->getQuery().'%'))
39
+ ->setCurPage($this->getStart())
40
+ ->setPageSize($this->getLimit())
41
+ ->load();
42
+ foreach ($collection->getItems() as $offers) {
43
+ $arr[] = array(
44
+ 'id'=> 'offers/1/'.$offers->getId(),
45
+ 'type' => Mage::helper('dealoffer')->__('Offers'),
46
+ 'name' => $offers->getName(),
47
+ 'description' => $offers->getName(),
48
+ 'url' => Mage::helper('adminhtml')->getUrl('*/dealoffer_offers/edit', array('id'=>$offers->getId())),
49
+ );
50
+ }
51
+ $this->setResults($arr);
52
+ return $this;
53
+ }
54
+ }
app/code/local/D4U/Dealoffer/Model/Offers.php ADDED
@@ -0,0 +1,139 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * D4U_Dealoffer extension
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the MIT License
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/mit-license.php
11
+ *
12
+ * @category D4U
13
+ * @package D4U_Dealoffer
14
+ * @copyright Copyright (c) 2013
15
+ * @license http://opensource.org/licenses/mit-license.php MIT License
16
+ */
17
+ /**
18
+ * Offers model
19
+ *
20
+ * @category D4U
21
+ * @package D4U_Dealoffer
22
+ * @author Ultimate Module Creator
23
+ */
24
+ class D4U_Dealoffer_Model_Offers extends Mage_Core_Model_Abstract{
25
+ /**
26
+ * Entity code.
27
+ * Can be used as part of method name for entity processing
28
+ */
29
+ const ENTITY= 'dealoffer_offers';
30
+ const CACHE_TAG = 'dealoffer_offers';
31
+ /**
32
+ * Prefix of model events names
33
+ * @var string
34
+ */
35
+ protected $_eventPrefix = 'dealoffer_offers';
36
+
37
+ /**
38
+ * Parameter name in event
39
+ * @var string
40
+ */
41
+ protected $_eventObject = 'offers';
42
+ protected $_productInstance = null;
43
+ /**
44
+ * constructor
45
+ * @access public
46
+ * @return void
47
+ * @author Ultimate Module Creator
48
+ */
49
+ public function _construct(){
50
+ parent::_construct();
51
+ $this->_init('dealoffer/offers');
52
+ }
53
+ /**
54
+ * before save offers
55
+ * @access protected
56
+ * @return D4U_Dealoffer_Model_Offers
57
+ * @author Ultimate Module Creator
58
+ */
59
+ protected function _beforeSave(){
60
+ parent::_beforeSave();
61
+ $now = Mage::getSingleton('core/date')->gmtDate();
62
+ if ($this->isObjectNew()){
63
+ $this->setCreatedAt($now);
64
+ }
65
+ $this->setUpdatedAt($now);
66
+ return $this;
67
+ }
68
+ /**
69
+ * get the url to the offers details page
70
+ * @access public
71
+ * @return string
72
+ * @author Ultimate Module Creator
73
+ */
74
+ public function getOffersUrl(){
75
+ if ($this->getUrlKey()){
76
+ return Mage::getUrl('', array('_direct'=>$this->getUrlKey()));
77
+ }
78
+ return Mage::getUrl('dealoffer/offers/view', array('id'=>$this->getId()));
79
+ }
80
+ /**
81
+ * check URL key
82
+ * @access public
83
+ * @param string $urlKey
84
+ * @param bool $active
85
+ * @return mixed
86
+ * @author Ultimate Module Creator
87
+ */
88
+ public function checkUrlKey($urlKey, $active = true){
89
+ return $this->_getResource()->checkUrlKey($urlKey, $active);
90
+ }
91
+ /**
92
+ * save offers relation
93
+ * @access public
94
+ * @return D4U_Dealoffer_Model_Offers
95
+ * @author Ultimate Module Creator
96
+ */
97
+ protected function _afterSave() {
98
+ $this->getProductInstance()->saveOffersRelation($this);
99
+ return parent::_afterSave();
100
+ }
101
+ /**
102
+ * get product relation model
103
+ * @access public
104
+ * @return D4U_Dealoffer_Model_Offers_Product
105
+ * @author Ultimate Module Creator
106
+ */
107
+ public function getProductInstance(){
108
+ if (!$this->_productInstance) {
109
+ $this->_productInstance = Mage::getSingleton('dealoffer/offers_product');
110
+ }
111
+ return $this->_productInstance;
112
+ }
113
+ /**
114
+ * get selected products array
115
+ * @access public
116
+ * @return array
117
+ * @author Ultimate Module Creator
118
+ */
119
+ public function getSelectedProducts(){
120
+ if (!$this->hasSelectedProducts()) {
121
+ $products = array();
122
+ foreach ($this->getSelectedProductsCollection() as $product) {
123
+ $products[] = $product;
124
+ }
125
+ $this->setSelectedProducts($products);
126
+ }
127
+ return $this->getData('selected_products');
128
+ }
129
+ /**
130
+ * Retrieve collection selected products
131
+ * @access public
132
+ * @return D4U_Dealoffer_Resource_Offers_Product_Collection
133
+ * @author Ultimate Module Creator
134
+ */
135
+ public function getSelectedProductsCollection(){
136
+ $collection = $this->getProductInstance()->getProductCollection($this);
137
+ return $collection;
138
+ }
139
+ }
app/code/local/D4U/Dealoffer/Model/Offers/Product.php ADDED
@@ -0,0 +1,60 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * D4U_Dealoffer extension
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the MIT License
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/mit-license.php
11
+ *
12
+ * @category D4U
13
+ * @package D4U_Dealoffer
14
+ * @copyright Copyright (c) 2013
15
+ * @license http://opensource.org/licenses/mit-license.php MIT License
16
+ */
17
+ /**
18
+ * Offers product model
19
+ *
20
+ * @category D4U
21
+ * @package D4U_Dealoffer
22
+ * @author Ultimate Module Creator
23
+ */
24
+ class D4U_Dealoffer_Model_Offers_Product extends Mage_Core_Model_Abstract{
25
+ /**
26
+ * Initialize resource
27
+ * @access protected
28
+ * @return void
29
+ * @author Ultimate Module Creator
30
+ */
31
+ protected function _construct(){
32
+ $this->_init('dealoffer/offers_product');
33
+ }
34
+ /**
35
+ * Save data for offers-product relation
36
+ * @access public
37
+ * @param D4U_Dealoffer_Model_Offers $offers
38
+ * @return D4U_Dealoffer_Model_Offers_Product
39
+ * @author Ultimate Module Creator
40
+ */
41
+ public function saveOffersRelation($offers){
42
+ $data = $offers->getProductsData();
43
+ if (!is_null($data)) {
44
+ $this->_getResource()->saveOffersRelation($offers, $data);
45
+ }
46
+ return $this;
47
+ }
48
+ /**
49
+ * get products for offers
50
+ * @access public
51
+ * @param D4U_Dealoffer_Model_Offers $offers
52
+ * @return D4U_Dealoffer_Model_Resource_Offers_Product_Collection
53
+ * @author Ultimate Module Creator
54
+ */
55
+ public function getProductCollection($offers){
56
+ $collection = Mage::getResourceModel('dealoffer/offers_product_collection')
57
+ ->addOffersFilter($offers);
58
+ return $collection;
59
+ }
60
+ }
app/code/local/D4U/Dealoffer/Model/Resource/Offers.php ADDED
@@ -0,0 +1,221 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * D4U_Dealoffer extension
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the MIT License
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/mit-license.php
11
+ *
12
+ * @category D4U
13
+ * @package D4U_Dealoffer
14
+ * @copyright Copyright (c) 2013
15
+ * @license http://opensource.org/licenses/mit-license.php MIT License
16
+ */
17
+ /**
18
+ * Offers resource model
19
+ *
20
+ * @category D4U
21
+ * @package D4U_Dealoffer
22
+ * @author Ultimate Module Creator
23
+ */
24
+ class D4U_Dealoffer_Model_Resource_Offers extends Mage_Core_Model_Resource_Db_Abstract{
25
+ /**
26
+ * constructor
27
+ * @access public
28
+ * @return void
29
+ * @author Ultimate Module Creator
30
+ */
31
+ public function _construct(){
32
+ $this->_init('dealoffer/offers', 'entity_id');
33
+ }
34
+
35
+ /**
36
+ * Get store ids to which specified item is assigned
37
+ * @access public
38
+ * @param int $offersId
39
+ * @return array
40
+ * @author Ultimate Module Creator
41
+ */
42
+ public function lookupStoreIds($offersId){
43
+ $adapter = $this->_getReadAdapter();
44
+ $select = $adapter->select()
45
+ ->from($this->getTable('dealoffer/offers_store'), 'store_id')
46
+ ->where('offers_id = ?',(int)$offersId);
47
+ return $adapter->fetchCol($select);
48
+ }
49
+ /**
50
+ * Perform operations after object load
51
+ * @access public
52
+ * @param Mage_Core_Model_Abstract $object
53
+ * @return D4U_Dealoffer_Model_Resource_Offers
54
+ * @author Ultimate Module Creator
55
+ */
56
+ protected function _afterLoad(Mage_Core_Model_Abstract $object){
57
+ if ($object->getId()) {
58
+ $stores = $this->lookupStoreIds($object->getId());
59
+ $object->setData('store_id', $stores);
60
+ }
61
+ return parent::_afterLoad($object);
62
+ }
63
+
64
+ /**
65
+ * Retrieve select object for load object data
66
+ *
67
+ * @param string $field
68
+ * @param mixed $value
69
+ * @param D4U_Dealoffer_Model_Offers $object
70
+ * @return Zend_Db_Select
71
+ */
72
+ protected function _getLoadSelect($field, $value, $object){
73
+ $select = parent::_getLoadSelect($field, $value, $object);
74
+ if ($object->getStoreId()) {
75
+ $storeIds = array(Mage_Core_Model_App::ADMIN_STORE_ID, (int)$object->getStoreId());
76
+ $select->join(
77
+ array('dealoffer_offers_store' => $this->getTable('dealoffer/offers_store')),
78
+ $this->getMainTable() . '.entity_id = dealoffer_offers_store.offers_id',
79
+ array()
80
+ )
81
+ ->where('dealoffer_offers_store.store_id IN (?)', $storeIds)
82
+ ->order('dealoffer_offers_store.store_id DESC')
83
+ ->limit(1);
84
+ }
85
+ return $select;
86
+ }
87
+ /**
88
+ * Assign offers to store views
89
+ * @access protected
90
+ * @param Mage_Core_Model_Abstract $object
91
+ * @return D4U_Dealoffer_Model_Resource_Offers
92
+ * @author Ultimate Module Creator
93
+ */
94
+ protected function _afterSave(Mage_Core_Model_Abstract $object){
95
+ $oldStores = $this->lookupStoreIds($object->getId());
96
+ $newStores = (array)$object->getStores();
97
+ if (empty($newStores)) {
98
+ $newStores = (array)$object->getStoreId();
99
+ }
100
+ $table = $this->getTable('dealoffer/offers_store');
101
+ $insert = array_diff($newStores, $oldStores);
102
+ $delete = array_diff($oldStores, $newStores);
103
+ if ($delete) {
104
+ $where = array(
105
+ 'offers_id = ?' => (int) $object->getId(),
106
+ 'store_id IN (?)' => $delete
107
+ );
108
+ $this->_getWriteAdapter()->delete($table, $where);
109
+ }
110
+ if ($insert) {
111
+ $data = array();
112
+ foreach ($insert as $storeId) {
113
+ $data[] = array(
114
+ 'offers_id' => (int) $object->getId(),
115
+ 'store_id' => (int) $storeId
116
+ );
117
+ }
118
+ $this->_getWriteAdapter()->insertMultiple($table, $data);
119
+ }
120
+ return parent::_afterSave($object);
121
+ } /**
122
+ * check url key
123
+ * @access public
124
+ * @param string $urlKey
125
+ * @param bool $active
126
+ * @return mixed
127
+ * @author Ultimate Module Creator
128
+ */
129
+ public function checkUrlKey($urlKey, $storeId, $active = true){
130
+ $stores = array(Mage_Core_Model_App::ADMIN_STORE_ID, $storeId);
131
+ $select = $this->_initCheckUrlKeySelect($urlKey, $stores);
132
+ if (!is_null($active)) {
133
+ $select->where('e.status = ?', $active);
134
+ }
135
+ $select->reset(Zend_Db_Select::COLUMNS)
136
+ ->columns('e.entity_id')
137
+ ->limit(1);
138
+
139
+ return $this->_getReadAdapter()->fetchOne($select);
140
+ }
141
+ /**
142
+ * init the check select
143
+ * @access protected
144
+ * @param string $urlKey
145
+ * @param array $store
146
+ * @return Zend_Db_Select
147
+ * @author Ultimate Module Creator
148
+ */
149
+ protected function _initCheckUrlKeySelect($urlKey, $store){
150
+ $select = $this->_getReadAdapter()->select()
151
+ ->from(array('e' => $this->getMainTable()))
152
+ ->join(
153
+ array('es' => $this->getTable('dealoffer/offers_store')),
154
+ 'e.entity_id = es.offers_id',
155
+ array())
156
+ ->where('e.url_key = ?', $urlKey)
157
+ ->where('es.store_id IN (?)', $store);
158
+ return $select;
159
+ }
160
+ /**
161
+ * Check for unique URL key
162
+ * @access public
163
+ * @param Mage_Core_Model_Abstract $object
164
+ * @return bool
165
+ * @author Ultimate Module Creator
166
+ */
167
+ public function getIsUniqueUrlKey(Mage_Core_Model_Abstract $object){
168
+ if (Mage::app()->isSingleStoreMode() || !$object->hasStores()) {
169
+ $stores = array(Mage_Core_Model_App::ADMIN_STORE_ID);
170
+ }
171
+ else {
172
+ $stores = (array)$object->getData('stores');
173
+ }
174
+ $select = $this->_initCheckUrlKeySelect($object->getData('url_key'), $stores);
175
+ if ($object->getId()) {
176
+ $select->where('e.entity_id <> ?', $object->getId());
177
+ }
178
+ if ($this->_getWriteAdapter()->fetchRow($select)) {
179
+ return false;
180
+ }
181
+ return true;
182
+ }
183
+ /**
184
+ * Check if the URL key is numeric
185
+ * @access public
186
+ * @param Mage_Core_Model_Abstract $object
187
+ * @return bool
188
+ * @author Ultimate Module Creator
189
+ */
190
+ protected function isNumericUrlKey(Mage_Core_Model_Abstract $object){
191
+ return preg_match('/^[0-9]+$/', $object->getData('url_key'));
192
+ }
193
+ /**
194
+ * Checkif the URL key is valid
195
+ * @access public
196
+ * @param Mage_Core_Model_Abstract $object
197
+ * @return bool
198
+ * @author Ultimate Module Creator
199
+ */
200
+ protected function isValidUrlKey(Mage_Core_Model_Abstract $object){
201
+ return preg_match('/^[a-z0-9][a-z0-9_\/-]+(\.[a-z0-9_-]+)?$/', $object->getData('url_key'));
202
+ }
203
+ /**
204
+ * validate before saving
205
+ * @access protected
206
+ * @param $object
207
+ * @return D4U_Dealoffer_Model_Resource_Offers
208
+ * @author Ultimate Module Creator
209
+ */
210
+ protected function _beforeSave(Mage_Core_Model_Abstract $object){
211
+ if (!$this->getIsUniqueUrlKey($object)) {
212
+ Mage::throwException(Mage::helper('dealoffer')->__('URL key already exists.'));
213
+ }
214
+ if (!$this->isValidUrlKey($object)) {
215
+ Mage::throwException(Mage::helper('dealoffer')->__('The URL key contains capital letters or disallowed symbols.'));
216
+ }
217
+ if ($this->isNumericUrlKey($object)) {
218
+ Mage::throwException(Mage::helper('dealoffer')->__('The URL key cannot consist only of numbers.'));
219
+ }
220
+ return parent::_beforeSave($object);
221
+ }}
app/code/local/D4U/Dealoffer/Model/Resource/Offers/Collection.php ADDED
@@ -0,0 +1,166 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * D4U_Dealoffer extension
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the MIT License
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/mit-license.php
11
+ *
12
+ * @category D4U
13
+ * @package D4U_Dealoffer
14
+ * @copyright Copyright (c) 2013
15
+ * @license http://opensource.org/licenses/mit-license.php MIT License
16
+ */
17
+ /**
18
+ * Offers collection resource model
19
+ *
20
+ * @category D4U
21
+ * @package D4U_Dealoffer
22
+ * @author Ultimate Module Creator
23
+ */
24
+ class D4U_Dealoffer_Model_Resource_Offers_Collection extends Mage_Core_Model_Resource_Db_Collection_Abstract{
25
+ protected $_joinedFields = array();
26
+ /**
27
+ * constructor
28
+ * @access public
29
+ * @return void
30
+ * @author Ultimate Module Creator
31
+ */
32
+ public function _construct(){
33
+ parent::_construct();
34
+ $this->_init('dealoffer/offers');
35
+ $this->_map['fields']['store'] = 'store_table.store_id';
36
+
37
+ }
38
+ /**
39
+ * get offerss as array
40
+ * @access protected
41
+ * @param string $valueField
42
+ * @param string $labelField
43
+ * @param array $additional
44
+ * @return array
45
+ * @author Ultimate Module Creator
46
+ */
47
+ protected function _toOptionArray($valueField='entity_id', $labelField='name', $additional=array()){
48
+ return parent::_toOptionArray($valueField, $labelField, $additional);
49
+ }
50
+ /**
51
+ * get options hash
52
+ * @access protected
53
+ * @param string $valueField
54
+ * @param string $labelField
55
+ * @return array
56
+ * @author Ultimate Module Creator
57
+ */
58
+ protected function _toOptionHash($valueField='entity_id', $labelField='name'){
59
+ return parent::_toOptionHash($valueField, $labelField);
60
+ }
61
+ /**
62
+ * Add filter by store
63
+ * @access public
64
+ * @param int|Mage_Core_Model_Store $store
65
+ * @param bool $withAdmin
66
+ * @return D4U_Dealoffer_Model_Resource_Offers_Collection
67
+ * @author Ultimate Module Creator
68
+ */
69
+ public function addStoreFilter($store, $withAdmin = true){
70
+ if (!isset($this->_joinedFields['store'])){
71
+ if ($store instanceof Mage_Core_Model_Store) {
72
+ $store = array($store->getId());
73
+ }
74
+ if (!is_array($store)) {
75
+ $store = array($store);
76
+ }
77
+ if ($withAdmin) {
78
+ $store[] = Mage_Core_Model_App::ADMIN_STORE_ID;
79
+ }
80
+ $this->addFilter('store', array('in' => $store), 'public');
81
+ $this->_joinedFields['store'] = true;
82
+ }
83
+
84
+ return $this;
85
+ }
86
+ /**
87
+ * Join store relation table if there is store filter
88
+ * @access protected
89
+ * @return D4U_Dealoffer_Model_Resource_Offers_Collection
90
+ * @author Ultimate Module Creator
91
+ */
92
+ protected function _renderFiltersBefore(){
93
+ if ($this->getFilter('store')) {
94
+ $this->getSelect()->join(
95
+ array('store_table' => $this->getTable('dealoffer/offers_store')),
96
+ 'main_table.entity_id = store_table.offers_id',
97
+ array('count(category_id) as category_count')
98
+ );//->group('main_table.entity_id');
99
+ /*
100
+ * Allow analytic functions usage because of one field grouping
101
+ */
102
+ $this->_useAnalyticFunction = true;
103
+ }
104
+ return parent::_renderFiltersBefore();
105
+ }
106
+ public function customaddFilter($filterName,$filtervalue,$condition='='){
107
+ $this->getSelect()->where('main_table.'.$filterName.' '.$condition.' ?', $filtervalue);
108
+ return $this;
109
+ }
110
+ /**
111
+ * Get SQL for get record count.
112
+ * Extra GROUP BY strip added.
113
+ * @access public
114
+ * @return Varien_Db_Select
115
+ * @author Ultimate Module Creator
116
+ */
117
+ public function getSelectCountSql(){
118
+ /*$countSelect = parent::getSelectCountSql();
119
+ $countSelect->reset(Zend_Db_Select::GROUP);
120
+ return $countSelect;*/
121
+ $this->_renderFilters();
122
+ $countSelect = clone $this->getSelect();
123
+ $countSelect->reset(Zend_Db_Select::ORDER);
124
+ $countSelect->reset(Zend_Db_Select::LIMIT_COUNT);
125
+ $countSelect->reset(Zend_Db_Select::LIMIT_OFFSET);
126
+ $countSelect->reset(Zend_Db_Select::COLUMNS);
127
+
128
+ // Count doesn't work with group by columns keep the group by
129
+ if(count($this->getSelect()->getPart(Zend_Db_Select::GROUP)) > 0) {
130
+ $countSelect->reset(Zend_Db_Select::GROUP);
131
+ $countSelect->distinct(true);
132
+ $group = $this->getSelect()->getPart(Zend_Db_Select::GROUP);
133
+ $countSelect->columns("COUNT(DISTINCT ".implode(", ", $group).")");
134
+ } else {
135
+ $countSelect->columns('COUNT(*)');
136
+ }
137
+ return $countSelect;
138
+ }
139
+ /**
140
+ * add the product filter to collection
141
+ * @access public
142
+ * @param mixed (Mage_Catalog_Model_Product|int) $product
143
+ * @return D4U_Dealoffer_Model_Resource_Offers_Collection
144
+ * @author Ultimate Module Creator
145
+ */
146
+ public function addProductFilter($product){
147
+ if ($product instanceof Mage_Catalog_Model_Product){
148
+ $product = $product->getId();
149
+ }
150
+ if (!isset($this->_joinedFields['product'])){
151
+ $this->getSelect()->join(
152
+ array('related_product' => $this->getTable('dealoffer/offers_product')),
153
+ 'related_product.offers_id = main_table.entity_id',
154
+ array('position')
155
+ );
156
+ $this->getSelect()->where('related_product.product_id = ?', $product);
157
+ $this->_joinedFields['product'] = true;
158
+ }
159
+ return $this;
160
+ }
161
+ public function GroupbyAdd($filedname){
162
+
163
+ $this->getSelect()->group('main_table.'.$filedname);
164
+ return $this;
165
+ }
166
+ }
app/code/local/D4U/Dealoffer/Model/Resource/Offers/Product.php ADDED
@@ -0,0 +1,83 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * D4U_Dealoffer extension
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the MIT License
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/mit-license.php
11
+ *
12
+ * @category D4U
13
+ * @package D4U_Dealoffer
14
+ * @copyright Copyright (c) 2013
15
+ * @license http://opensource.org/licenses/mit-license.php MIT License
16
+ */
17
+ /**
18
+ * Offers - product relation model
19
+ *
20
+ * @category D4U
21
+ * @package D4U_Dealoffer
22
+ * @author Ultimate Module Creator
23
+ */
24
+ class D4U_Dealoffer_Model_Resource_Offers_Product extends Mage_Core_Model_Resource_Db_Abstract{
25
+ /**
26
+ * initialize resource model
27
+ * @access protected
28
+ * @return void
29
+ * @see Mage_Core_Model_Resource_Abstract::_construct()
30
+ * @author Ultimate Module Creator
31
+ */
32
+ protected function _construct(){
33
+ $this->_init('dealoffer/offers_product', 'rel_id');
34
+ }
35
+ /**
36
+ * Save offers - product relations
37
+ * @access public
38
+ * @param D4U_Dealoffer_Model_Offers $offers
39
+ * @param array $data
40
+ * @return D4U_Dealoffer_Model_Resource_Offers_Product
41
+ * @author Ultimate Module Creator
42
+ */
43
+ public function saveOffersRelation($offers, $data){
44
+ if (!is_array($data)) {
45
+ $data = array();
46
+ }
47
+ $deleteCondition = $this->_getWriteAdapter()->quoteInto('offers_id=?', $offers->getId());
48
+ $this->_getWriteAdapter()->delete($this->getMainTable(), $deleteCondition);
49
+
50
+ foreach ($data as $productId => $info) {
51
+ $this->_getWriteAdapter()->insert($this->getMainTable(), array(
52
+ 'offers_id' => $offers->getId(),
53
+ 'product_id' => $productId,
54
+ 'position' => @$info['position']
55
+ ));
56
+ }
57
+ return $this;
58
+ }
59
+ /**
60
+ * Save product - offers relations
61
+ * @access public
62
+ * @param Mage_Catalog_Model_Product $prooduct
63
+ * @param array $data
64
+ * @return D4U_Dealoffer_Model_Resource_Offers_Product
65
+ * @@author Ultimate Module Creator
66
+ */
67
+ public function saveProductRelation($product, $data){
68
+ if (!is_array($data)) {
69
+ $data = array();
70
+ }
71
+ $deleteCondition = $this->_getWriteAdapter()->quoteInto('product_id=?', $product->getId());
72
+ $this->_getWriteAdapter()->delete($this->getMainTable(), $deleteCondition);
73
+
74
+ foreach ($data as $offersId => $info) {
75
+ $this->_getWriteAdapter()->insert($this->getMainTable(), array(
76
+ 'offers_id' => $offersId,
77
+ 'product_id' => $product->getId(),
78
+ 'position' => @$info['position']
79
+ ));
80
+ }
81
+ return $this;
82
+ }
83
+ }
app/code/local/D4U/Dealoffer/Model/Resource/Offers/Product/Collection.php ADDED
@@ -0,0 +1,64 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * D4U_Dealoffer extension
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the MIT License
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/mit-license.php
11
+ *
12
+ * @category D4U
13
+ * @package D4U_Dealoffer
14
+ * @copyright Copyright (c) 2013
15
+ * @license http://opensource.org/licenses/mit-license.php MIT License
16
+ */
17
+ /**
18
+ * Offers - product relation resource model collection
19
+ *
20
+ * @category D4U
21
+ * @package D4U_Dealoffer
22
+ * @author Ultimate Module Creator
23
+ */
24
+ class D4U_Dealoffer_Model_Resource_Offers_Product_Collection extends Mage_Catalog_Model_Resource_Product_Collection{
25
+ /**
26
+ * remember if fields have been joined
27
+ * @var bool
28
+ */
29
+ protected $_joinedFields = false;
30
+ /**
31
+ * join the link table
32
+ * @access public
33
+ * @return D4U_Dealoffer_Model_Resource_Offers_Product_Collection
34
+ * @author Ultimate Module Creator
35
+ */
36
+ public function joinFields(){
37
+ if (!$this->_joinedFields){
38
+ $this->getSelect()->join(
39
+ array('related' => $this->getTable('dealoffer/offers_product')),
40
+ 'related.product_id = e.entity_id',
41
+ array('position')
42
+ );
43
+ $this->_joinedFields = true;
44
+ }
45
+ return $this;
46
+ }
47
+ /**
48
+ * add offers filter
49
+ * @access public
50
+ * @param D4U_Dealoffer_Model_Offers | int $offers
51
+ * @return D4U_Dealoffer_Model_Resource_Offers_Product_Collection
52
+ * @author Ultimate Module Creator
53
+ */
54
+ public function addOffersFilter($offers){
55
+ if ($offers instanceof D4U_Dealoffer_Model_Offers){
56
+ $offers = $offers->getId();
57
+ }
58
+ if (!$this->_joinedFields){
59
+ $this->joinFields();
60
+ }
61
+ $this->getSelect()->where('related.offers_id = ?', $offers);
62
+ return $this;
63
+ }
64
+ }
app/code/local/D4U/Dealoffer/Model/Resource/Setup.php ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * D4U_Dealoffer extension
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the MIT License
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/mit-license.php
11
+ *
12
+ * @category D4U
13
+ * @package D4U_Dealoffer
14
+ * @copyright Copyright (c) 2013
15
+ * @license http://opensource.org/licenses/mit-license.php MIT License
16
+ */
17
+ /**
18
+ * Dealoffer setup
19
+ *
20
+ * @category D4U
21
+ * @package D4U_Dealoffer
22
+ * @author Ultimate Module Creator
23
+ */
24
+ class D4U_Dealoffer_Model_Resource_Setup extends Mage_Core_Model_Resource_Setup{
25
+
26
+ }
app/code/local/D4U/Dealoffer/controllers/Adminhtml/Dealoffer/Offers/Catalog/ProductController.php ADDED
@@ -0,0 +1,62 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * D4U_Dealoffer extension
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the MIT License
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/mit-license.php
11
+ *
12
+ * @category D4U
13
+ * @package D4U_Dealoffer
14
+ * @copyright Copyright (c) 2013
15
+ * @license http://opensource.org/licenses/mit-license.php MIT License
16
+ */
17
+ /**
18
+ * Offers product admin controller
19
+ *
20
+ * @category D4U
21
+ * @package D4U_Dealoffer
22
+ * @author Ultimate Module Creator
23
+ */
24
+ require_once ("Mage/Adminhtml/controllers/Catalog/ProductController.php");
25
+ class D4U_Dealoffer_Adminhtml_Dealoffer_Offers_Catalog_ProductController extends Mage_Adminhtml_Catalog_ProductController{
26
+ /**
27
+ * construct
28
+ * @access protected
29
+ * @return void
30
+ * @author Ultimate Module Creator
31
+ */
32
+ protected function _construct(){
33
+ // Define module dependent translate
34
+ $this->setUsedModuleName('D4U_Dealoffer');
35
+ }
36
+ /**
37
+ * offerss in the catalog page
38
+ * @access public
39
+ * @return void
40
+ * @author Ultimate Module Creator
41
+ */
42
+ public function offerssAction(){
43
+ $this->_initProduct();
44
+ $this->loadLayout();
45
+ $this->getLayout()->getBlock('product.edit.tab.offers')
46
+ ->setProductOfferss($this->getRequest()->getPost('product_offerss', null));
47
+ $this->renderLayout();
48
+ }
49
+ /**
50
+ * offerss grid in the catalog page
51
+ * @access public
52
+ * @return void
53
+ * @author Ultimate Module Creator
54
+ */
55
+ public function offerssGridAction(){
56
+ $this->_initProduct();
57
+ $this->loadLayout();
58
+ $this->getLayout()->getBlock('product.edit.tab.offers')
59
+ ->setProductOfferss($this->getRequest()->getPost('product_offerss', null));
60
+ $this->renderLayout();
61
+ }
62
+ }
app/code/local/D4U/Dealoffer/controllers/Adminhtml/Dealoffer/Offers/WidgetController.php ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * D4U_Dealoffer extension
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the MIT License
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/mit-license.php
11
+ *
12
+ * @category D4U
13
+ * @package D4U_Dealoffer
14
+ * @copyright Copyright (c) 2013
15
+ * @license http://opensource.org/licenses/mit-license.php MIT License
16
+ */
17
+ /**
18
+ * Offers admin widget controller
19
+ *
20
+ * @category D4U
21
+ * @package D4U_Dealoffer
22
+ * @author Ultimate Module Creator
23
+ */
24
+ class D4U_Dealoffer_Adminhtml_Dealoffer_Offers_WidgetController extends Mage_Adminhtml_Controller_Action{
25
+ /**
26
+ * Chooser Source action
27
+ * @access public
28
+ * @return void
29
+ * @author Ultimate Module Creator
30
+ */
31
+ public function chooserAction(){
32
+ $uniqId = $this->getRequest()->getParam('uniq_id');
33
+ $grid = $this->getLayout()->createBlock('dealoffer/adminhtml_offers_widget_chooser', '', array(
34
+ 'id' => $uniqId,
35
+ ));
36
+ $this->getResponse()->setBody($grid->toHtml());
37
+ }
38
+ }
app/code/local/D4U/Dealoffer/controllers/Adminhtml/Dealoffer/OffersController.php ADDED
@@ -0,0 +1,361 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * D4U_Dealoffer extension
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the MIT License
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/mit-license.php
11
+ *
12
+ * @category D4U
13
+ * @package D4U_Dealoffer
14
+ * @copyright Copyright (c) 2013
15
+ * @license http://opensource.org/licenses/mit-license.php MIT License
16
+ */
17
+ /**
18
+ * Offers admin controller
19
+ *
20
+ * @category D4U
21
+ * @package D4U_Dealoffer
22
+ * @author Ultimate Module Creator
23
+ */
24
+ class D4U_Dealoffer_Adminhtml_Dealoffer_OffersController extends D4U_Dealoffer_Controller_Adminhtml_Dealoffer{
25
+ /**
26
+ * init the offers
27
+ * @access protected
28
+ * @return D4U_Dealoffer_Model_Offers
29
+ */
30
+ protected function _initOffers(){
31
+ $offersId = (int) $this->getRequest()->getParam('id');
32
+ $offers = Mage::getModel('dealoffer/offers');
33
+ if ($offersId) {
34
+ $offers->load($offersId);
35
+ }
36
+ Mage::register('current_offers', $offers);
37
+ return $offers;
38
+ }
39
+ /**
40
+ * default action
41
+ * @access public
42
+ * @return void
43
+ * @author Ultimate Module Creator
44
+ */
45
+ public function indexAction() {
46
+ $this->loadLayout();
47
+ $this->_title(Mage::helper('dealoffer')->__('Dealoffer'))
48
+ ->_title(Mage::helper('dealoffer')->__('Offers'));
49
+ $this->renderLayout();
50
+ }
51
+ /**
52
+ * grid action
53
+ * @access public
54
+ * @return void
55
+ * @author Ultimate Module Creator
56
+ */
57
+ public function gridAction() {
58
+ $this->loadLayout()->renderLayout();
59
+ }
60
+ /**
61
+ * edit offers - action
62
+ * @access public
63
+ * @return void
64
+ * @author Ultimate Module Creator
65
+ */
66
+ public function editAction() {
67
+ $offersId = $this->getRequest()->getParam('id');
68
+ $offers = $this->_initOffers();
69
+ if ($offersId && !$offers->getId()) {
70
+ $this->_getSession()->addError(Mage::helper('dealoffer')->__('This offers no longer exists.'));
71
+ $this->_redirect('*/*/');
72
+ return;
73
+ }
74
+ $data = Mage::getSingleton('adminhtml/session')->getFormData(true);
75
+ if (!empty($data)) {
76
+ $offers->setData($data);
77
+ }
78
+ Mage::register('offers_data', $offers);
79
+ $this->loadLayout();
80
+ $this->_title(Mage::helper('dealoffer')->__('Dealoffer'))
81
+ ->_title(Mage::helper('dealoffer')->__('Offers'));
82
+ if ($offers->getId()){
83
+ $this->_title($offers->getName());
84
+ }
85
+ else{
86
+ $this->_title(Mage::helper('dealoffer')->__('Add offers'));
87
+ }
88
+ if (Mage::getSingleton('cms/wysiwyg_config')->isEnabled()) {
89
+ $this->getLayout()->getBlock('head')->setCanLoadTinyMce(true);
90
+ }
91
+ $this->renderLayout();
92
+ }
93
+ /**
94
+ * new offers action
95
+ * @access public
96
+ * @return void
97
+ * @author Ultimate Module Creator
98
+ */
99
+ public function newAction() {
100
+ $this->_forward('edit');
101
+ }
102
+ /**
103
+ * save offers - action
104
+ * @access public
105
+ * @return void
106
+ * @author Ultimate Module Creator
107
+ */
108
+ public function saveAction() {
109
+ if ($data = $this->getRequest()->getPost('offers')) {
110
+ try {
111
+ $offers = $this->_initOffers();
112
+ $offers->addData($data);
113
+ $deal_imageName = $this->_uploadAndGetName('deal_image', Mage::helper('dealoffer/offers_image')->getImageBaseDir(), $data);
114
+ $offers->setData('deal_image', $deal_imageName);
115
+ // $offer_imageName = $this->_uploadAndGetName('offer_image', Mage::helper('dealoffer/offers')->getFileBaseDir(), $data);
116
+ // $offers->setData('offer_image', $offer_imageName);
117
+ $offers->setData('offer_image', 0);
118
+ $products = $this->getRequest()->getPost('products', -1);
119
+ if ($products != -1) {
120
+ $offers->setProductsData(Mage::helper('adminhtml/js')->decodeGridSerializedInput($products));
121
+ }
122
+ $offers->save();
123
+ Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('dealoffer')->__('Offers was successfully saved'));
124
+ Mage::getSingleton('adminhtml/session')->setFormData(false);
125
+ if ($this->getRequest()->getParam('back')) {
126
+ $this->_redirect('*/*/edit', array('id' => $offers->getId()));
127
+ return;
128
+ }
129
+ $this->_redirect('*/*/');
130
+ return;
131
+ }
132
+ catch (Mage_Core_Exception $e){
133
+ if (isset($data['deal_image']['value'])){
134
+ $data['deal_image'] = $data['deal_image']['value'];
135
+ }
136
+ if (isset($data['offer_image']['value'])){
137
+ $data['offer_image'] = $data['offer_image']['value'];
138
+ }
139
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
140
+ Mage::getSingleton('adminhtml/session')->setFormData($data);
141
+ $this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id')));
142
+ return;
143
+ }
144
+ catch (Exception $e) {
145
+ Mage::logException($e);
146
+ if (isset($data['deal_image']['value'])){
147
+ $data['deal_image'] = $data['deal_image']['value'];
148
+ }
149
+ if (isset($data['offer_image']['value'])){
150
+ $data['offer_image'] = $data['offer_image']['value'];
151
+ }
152
+ Mage::getSingleton('adminhtml/session')->addError(Mage::helper('dealoffer')->__('There was a problem saving the offers.'));
153
+ Mage::getSingleton('adminhtml/session')->setFormData($data);
154
+ $this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id')));
155
+ return;
156
+ }
157
+ }
158
+ Mage::getSingleton('adminhtml/session')->addError(Mage::helper('dealoffer')->__('Unable to find offers to save.'));
159
+ $this->_redirect('*/*/');
160
+ }
161
+ /**
162
+ * delete offers - action
163
+ * @access public
164
+ * @return void
165
+ * @author Ultimate Module Creator
166
+ */
167
+ public function deleteAction() {
168
+ if( $this->getRequest()->getParam('id') > 0) {
169
+ try {
170
+ $offers = Mage::getModel('dealoffer/offers');
171
+ $offers->setId($this->getRequest()->getParam('id'))->delete();
172
+ Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('dealoffer')->__('Offers was successfully deleted.'));
173
+ $this->_redirect('*/*/');
174
+ return;
175
+ }
176
+ catch (Mage_Core_Exception $e){
177
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
178
+ $this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id')));
179
+ }
180
+ catch (Exception $e) {
181
+ Mage::getSingleton('adminhtml/session')->addError(Mage::helper('dealoffer')->__('There was an error deleteing offers.'));
182
+ $this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id')));
183
+ Mage::logException($e);
184
+ return;
185
+ }
186
+ }
187
+ Mage::getSingleton('adminhtml/session')->addError(Mage::helper('dealoffer')->__('Could not find offers to delete.'));
188
+ $this->_redirect('*/*/');
189
+ }
190
+ public function massTodayDealAction(){
191
+
192
+ $offersIds = $this->getRequest()->getParam('offers');
193
+ if(!is_array($offersIds)) {
194
+ Mage::getSingleton('adminhtml/session')->addError(Mage::helper('dealoffer')->__('Please select offers.'));
195
+ }
196
+ elseif(count($offersIds) > 1)
197
+ {
198
+ Mage::getSingleton('adminhtml/session')->addError(Mage::helper('dealoffer')->__('Select Single offers only and End Date is grater then today date'));
199
+ }
200
+ else{
201
+
202
+
203
+ $offerss = Mage::getResourceModel('dealoffer/offers_collection');
204
+ foreach($offerss as $_offers)
205
+ {
206
+ if($_offers->getEntityId() == $offersIds[0]){
207
+ $end_date=date("d-m-Y", strtotime($_offers->getEndDate()));
208
+ }
209
+
210
+ if($_offers->getOfferImage() != 0){
211
+ $offersset="";
212
+ $offersset = Mage::getSingleton('dealoffer/offers')->load($_offers->getEntityId())
213
+ ->setOfferImage(0)
214
+ ->setIsMassupdate(true)
215
+ ->save();
216
+ }
217
+ }
218
+
219
+ $today = date("d-m-Y");
220
+ if(!empty($end_date) && strtotime($end_date) >= strtotime($today))
221
+ {
222
+ $offers1="";
223
+ $offers1 = Mage::getSingleton('dealoffer/offers')->load($offersIds[0])
224
+ ->setOfferImage(1)
225
+ ->setIsMassupdate(true)
226
+ ->save();
227
+ // print_r($offers1);exit;
228
+ $this->_getSession()->addSuccess($this->__('Set today display offer successfully.'));
229
+ }
230
+ else{
231
+ Mage::getSingleton('adminhtml/session')->addError(Mage::helper('dealoffer')->__('End Date must grater then or equal to today date'));
232
+
233
+ }
234
+
235
+
236
+
237
+
238
+ }
239
+
240
+ $this->_redirect('*/*/index');
241
+ }
242
+ /**
243
+ * mass delete offers - action
244
+ * @access public
245
+ * @return void
246
+ * @author Ultimate Module Creator
247
+ */
248
+ public function massDeleteAction() {
249
+ $offersIds = $this->getRequest()->getParam('offers');
250
+ if(!is_array($offersIds)) {
251
+ Mage::getSingleton('adminhtml/session')->addError(Mage::helper('dealoffer')->__('Please select offers to delete.'));
252
+ }
253
+ else {
254
+ try {
255
+ foreach ($offersIds as $offersId) {
256
+ $offers = Mage::getModel('dealoffer/offers');
257
+ $offers->setId($offersId)->delete();
258
+ }
259
+ Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('dealoffer')->__('Total of %d offers were successfully deleted.', count($offersIds)));
260
+ }
261
+ catch (Mage_Core_Exception $e){
262
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
263
+ }
264
+ catch (Exception $e) {
265
+ Mage::getSingleton('adminhtml/session')->addError(Mage::helper('dealoffer')->__('There was an error deleteing offers.'));
266
+ Mage::logException($e);
267
+ }
268
+ }
269
+ $this->_redirect('*/*/index');
270
+ }
271
+ /**
272
+ * mass status change - action
273
+ * @access public
274
+ * @return void
275
+ * @author Ultimate Module Creator
276
+ */
277
+ public function massStatusAction(){
278
+ $offersIds = $this->getRequest()->getParam('offers');
279
+ if(!is_array($offersIds)) {
280
+ Mage::getSingleton('adminhtml/session')->addError(Mage::helper('dealoffer')->__('Please select offers.'));
281
+ }
282
+ else {
283
+ try {
284
+ foreach ($offersIds as $offersId) {
285
+ $offers = Mage::getSingleton('dealoffer/offers')->load($offersId)
286
+ ->setStatus($this->getRequest()->getParam('status'))
287
+ ->setIsMassupdate(true)
288
+ ->save();
289
+ }
290
+ $this->_getSession()->addSuccess($this->__('Total of %d offers were successfully updated.', count($offersIds)));
291
+ }
292
+ catch (Mage_Core_Exception $e){
293
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
294
+ }
295
+ catch (Exception $e) {
296
+ Mage::getSingleton('adminhtml/session')->addError(Mage::helper('dealoffer')->__('There was an error updating offers.'));
297
+ Mage::logException($e);
298
+ }
299
+ }
300
+ $this->_redirect('*/*/index');
301
+ }
302
+ /**
303
+ * get grid of products action
304
+ * @access public
305
+ * @return void
306
+ * @author Ultimate Module Creator
307
+ */
308
+ public function productsAction(){
309
+ $this->_initOffers();
310
+ $this->loadLayout();
311
+ $this->getLayout()->getBlock('offers.edit.tab.product')
312
+ ->setOffersProducts($this->getRequest()->getPost('offers_products', null));
313
+ $this->renderLayout();
314
+ }
315
+ /**
316
+ * get grid of products action
317
+ * @access public
318
+ * @return void
319
+ * @author Ultimate Module Creator
320
+ */
321
+ public function productsgridAction(){
322
+ $this->_initOffers();
323
+ $this->loadLayout();
324
+ $this->getLayout()->getBlock('offers.edit.tab.product')
325
+ ->setOffersProducts($this->getRequest()->getPost('offers_products', null));
326
+ $this->renderLayout();
327
+ }
328
+ /**
329
+ * export as csv - action
330
+ * @access public
331
+ * @return void
332
+ * @author Ultimate Module Creator
333
+ */
334
+ public function exportCsvAction(){
335
+ $fileName = 'offers.csv';
336
+ $content = $this->getLayout()->createBlock('dealoffer/adminhtml_offers_grid')->getCsv();
337
+ $this->_prepareDownloadResponse($fileName, $content);
338
+ }
339
+ /**
340
+ * export as MsExcel - action
341
+ * @access public
342
+ * @return void
343
+ * @author Ultimate Module Creator
344
+ */
345
+ public function exportExcelAction(){
346
+ $fileName = 'offers.xls';
347
+ $content = $this->getLayout()->createBlock('dealoffer/adminhtml_offers_grid')->getExcelFile();
348
+ $this->_prepareDownloadResponse($fileName, $content);
349
+ }
350
+ /**
351
+ * export as xml - action
352
+ * @access public
353
+ * @return void
354
+ * @author Ultimate Module Creator
355
+ */
356
+ public function exportXmlAction(){
357
+ $fileName = 'offers.xml';
358
+ $content = $this->getLayout()->createBlock('dealoffer/adminhtml_offers_grid')->getXml();
359
+ $this->_prepareDownloadResponse($fileName, $content);
360
+ }
361
+ }
app/code/local/D4U/Dealoffer/controllers/OffersController.php ADDED
@@ -0,0 +1,192 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * D4U_Dealoffer extension
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the MIT License
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/mit-license.php
11
+ *
12
+ * @category D4U
13
+ * @package D4U_Dealoffer
14
+ * @copyright Copyright (c) 2013
15
+ * @license http://opensource.org/licenses/mit-license.php MIT License
16
+ */
17
+ /**
18
+ * Offers front contrller
19
+ *
20
+ * @category D4U
21
+ * @package D4U_Dealoffer
22
+ * @author Ultimate Module Creator
23
+ */
24
+ class D4U_Dealoffer_OffersController extends Mage_Core_Controller_Front_Action{
25
+ /**
26
+ * default action
27
+ * @access public
28
+ * @return void
29
+ * @author Ultimate Module Creator
30
+ */
31
+ public function indexAction(){
32
+ $this->loadLayout();
33
+ if (Mage::helper('dealoffer/offers')->getUseBreadcrumbs()){
34
+ if ($breadcrumbBlock = $this->getLayout()->getBlock('breadcrumbs')){
35
+ $breadcrumbBlock->addCrumb('home', array(
36
+ 'label' => Mage::helper('dealoffer')->__('Home'),
37
+ 'link' => Mage::getUrl(),
38
+ )
39
+ );
40
+ $breadcrumbBlock->addCrumb('offerss', array(
41
+ 'label' => Mage::helper('dealoffer')->__('Offers'),
42
+ 'link' => '',
43
+ )
44
+ );
45
+ }
46
+ }
47
+ $headBlock = $this->getLayout()->getBlock('head');
48
+ if ($headBlock) {
49
+ $headBlock->setTitle(Mage::getStoreConfig('dealoffer/offers/meta_title'));
50
+ $headBlock->setKeywords(Mage::getStoreConfig('dealoffer/offers/meta_keywords'));
51
+ $headBlock->setDescription(Mage::getStoreConfig('dealoffer/offers/meta_description'));
52
+ }
53
+ $this->renderLayout();
54
+ }
55
+ /**
56
+ * view offers action
57
+ * @access public
58
+ * @return void
59
+ * @author Ultimate Module Creator
60
+ */
61
+ public function viewAction(){
62
+ $offersId = $this->getRequest()->getParam('id', 0);
63
+ $offers = Mage::getModel('dealoffer/offers')
64
+ ->setStoreId(Mage::app()->getStore()->getId())
65
+ ->load($offersId);
66
+
67
+ $category = Mage::getModel('catalog/category')->load($offers->getCategoryId());
68
+ if (!$offers->getId()){
69
+ $this->_forward('no-route');
70
+ }
71
+ elseif (!$offers->getStatus()){
72
+ $this->_forward('no-route');
73
+ }
74
+ else{
75
+ Mage::register('current_dealoffer_offers', $offers);
76
+ $this->loadLayout();
77
+ if ($root = $this->getLayout()->getBlock('root')) {
78
+ $root->addBodyClass('dealoffer-offers dealoffer-offers' . $offers->getId());
79
+ }
80
+ if (Mage::helper('dealoffer/offers')->getUseBreadcrumbs()){
81
+ if ($breadcrumbBlock = $this->getLayout()->getBlock('breadcrumbs')){
82
+ $breadcrumbBlock->addCrumb('home', array(
83
+ 'label' => Mage::helper('dealoffer')->__('Home'),
84
+ 'link' => Mage::getUrl(),
85
+ )
86
+ );
87
+ $breadcrumbBlock->addCrumb('offerss', array(
88
+ 'label' => Mage::helper('dealoffer')->__('Offers'),
89
+ 'link' => Mage::helper('dealoffer')->getOfferssUrl(),
90
+ )
91
+ );
92
+ $breadcrumbBlock->addCrumb('category', array(
93
+ 'label' => Mage::helper('dealoffer')->__($category->getName()),
94
+ 'link' => Mage::getUrl('dealoffer/offers/categoryview/',array('id'=>$offers->getCategoryId())),
95
+ )
96
+ );
97
+ $breadcrumbBlock->addCrumb('offers', array(
98
+ 'label' => $offers->getName(),
99
+ 'link' => '',
100
+ )
101
+ );
102
+ }
103
+ }
104
+ $headBlock = $this->getLayout()->getBlock('head');
105
+ if ($headBlock) {
106
+ if ($offers->getMetaTitle()){
107
+ $headBlock->setTitle($offers->getMetaTitle());
108
+ }
109
+ else{
110
+ $headBlock->setTitle($offers->getName());
111
+ }
112
+ $headBlock->setKeywords($offers->getMetaKeywords());
113
+ $headBlock->setDescription($offers->getMetaDescription());
114
+ }
115
+ $this->renderLayout();
116
+ }
117
+ }
118
+ /**
119
+ * offers rss list action
120
+ * @access public
121
+ * @return void
122
+ * @author Ultimate Module Creator
123
+ */
124
+ public function rssAction(){
125
+ if (Mage::helper('dealoffer/offers')->isRssEnabled()) {
126
+ $this->getResponse()->setHeader('Content-type', 'text/xml; charset=UTF-8');
127
+ $this->loadLayout(false);
128
+ $this->renderLayout();
129
+ }
130
+ else {
131
+ $this->getResponse()->setHeader('HTTP/1.1','404 Not Found');
132
+ $this->getResponse()->setHeader('Status','404 File not found');
133
+ $this->_forward('nofeed','index','rss');
134
+ }
135
+ }
136
+
137
+ public function categoryviewAction()
138
+ {
139
+ /*echo $this->getLayout()
140
+ ->createBlock('Mage_Core_Block_Template')
141
+ ->setTemplate('d4u_dealoffer/offers/categoryview.phtml')
142
+ ->toHtml();*/
143
+ $this->loadLayout();
144
+ $this->getLayout()->getBlock('root')->setTemplate('page/1column.phtml');
145
+
146
+ $params = $this->getRequest()->getParams();
147
+ $category = Mage::getModel('catalog/category')->load($params['id']);
148
+
149
+ if (Mage::helper('dealoffer/offers')->getUseBreadcrumbs()){
150
+ if ($breadcrumbBlock = $this->getLayout()->getBlock('breadcrumbs')){
151
+ $breadcrumbBlock->addCrumb('home', array(
152
+ 'label' => Mage::helper('dealoffer')->__('Home'),
153
+ 'link' => Mage::getUrl(),
154
+ )
155
+ );
156
+ $breadcrumbBlock->addCrumb('offerss', array(
157
+ 'label' => Mage::helper('dealoffer')->__('Offers'),
158
+ 'link' => Mage::getUrl('dealoffer/offers'),
159
+ )
160
+ );
161
+ $breadcrumbBlock->addCrumb('category', array(
162
+ 'label' => Mage::helper('dealoffer')->__($category->getName()),
163
+ 'link' => '',
164
+ )
165
+ );
166
+ }
167
+ }
168
+ $headBlock = $this->getLayout()->getBlock('head');
169
+ if ($headBlock) {
170
+ $headBlock->setTitle(Mage::getStoreConfig('dealoffer/offers/meta_title'));
171
+ $headBlock->setKeywords(Mage::getStoreConfig('dealoffer/offers/meta_keywords'));
172
+ $headBlock->setDescription(Mage::getStoreConfig('dealoffer/offers/meta_description'));
173
+ }
174
+ $block = $this->getLayout()->createBlock(
175
+ 'Mage_Core_Block_Template',
176
+ 'categoryview',
177
+ array('template' => 'd4u_dealoffer/offers/categoryview.phtml')
178
+ );
179
+ $this->getLayout()->getBlock('content')->append($block);
180
+
181
+ $this->renderLayout();
182
+
183
+
184
+ }
185
+ public function getdailydealAction()
186
+ {
187
+ echo $this->getLayout()
188
+ ->createBlock('Mage_Core_Block_Template')
189
+ ->setTemplate('d4u_dealoffer/getdailydeal.phtml')
190
+ ->toHtml();
191
+ }
192
+ }
app/code/local/D4U/Dealoffer/etc/adminhtml.xml ADDED
@@ -0,0 +1,63 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * D4U_Dealoffer extension
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the MIT License
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/mit-license.php
12
+ *
13
+ * @category D4U
14
+ * @package D4U_Dealoffer
15
+ * @copyright Copyright (c) 2013
16
+ * @license http://opensource.org/licenses/mit-license.php MIT License
17
+ */
18
+ -->
19
+ <config>
20
+ <acl>
21
+ <resources>
22
+ <admin>
23
+ <children>
24
+ <system>
25
+ <children>
26
+ <config>
27
+ <children>
28
+ <dealoffer translate="title" module="dealoffer">
29
+ <title>Dealoffer</title>
30
+ </dealoffer>
31
+ </children>
32
+ </config>
33
+ </children>
34
+ </system>
35
+ <dealoffer translate="title" module="dealoffer">
36
+ <title>Dealoffer</title>
37
+ <children>
38
+ <offers translate="title" module="dealoffer">
39
+ <title>Offers</title>
40
+ </offers>
41
+ </children>
42
+ </dealoffer>
43
+ </children>
44
+ </admin>
45
+ </resources>
46
+ </acl>
47
+ <menu>
48
+ <dealoffer translate="title" module="dealoffer">
49
+ <title>Deal Offer</title>
50
+ <sort_order>81</sort_order>
51
+ <depends>
52
+ <module>D4U_Dealoffer</module>
53
+ </depends>
54
+ <children>
55
+ <offers translate="title" module="dealoffer">
56
+ <title>Manage Offers</title>
57
+ <action>adminhtml/dealoffer_offers</action>
58
+ <sort_order>0</sort_order>
59
+ </offers>
60
+ </children>
61
+ </dealoffer>
62
+ </menu>
63
+ </config>
app/code/local/D4U/Dealoffer/etc/config.xml ADDED
@@ -0,0 +1,166 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * D4U_Dealoffer extension
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the MIT License
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/mit-license.php
12
+ *
13
+ * @category D4U
14
+ * @package D4U_Dealoffer
15
+ * @copyright Copyright (c) 2013
16
+ * @license http://opensource.org/licenses/mit-license.php MIT License
17
+ */
18
+ -->
19
+ <config>
20
+ <modules>
21
+ <D4U_Dealoffer>
22
+ <version>0.0.1</version>
23
+ </D4U_Dealoffer>
24
+ </modules>
25
+ <global>
26
+ <resources>
27
+ <d4u_dealoffer_setup>
28
+ <setup>
29
+ <module>D4U_Dealoffer</module>
30
+ <class>D4U_Dealoffer_Model_Resource_Setup</class>
31
+ </setup>
32
+ </d4u_dealoffer_setup>
33
+ </resources>
34
+ <blocks>
35
+ <dealoffer>
36
+ <class>D4U_Dealoffer_Block</class>
37
+ </dealoffer>
38
+ </blocks>
39
+ <helpers>
40
+ <dealoffer>
41
+ <class>D4U_Dealoffer_Helper</class>
42
+ </dealoffer>
43
+ </helpers>
44
+ <models>
45
+ <dealoffer>
46
+ <class>D4U_Dealoffer_Model</class>
47
+ <resourceModel>dealoffer_resource</resourceModel>
48
+ </dealoffer>
49
+ <dealoffer_resource>
50
+ <class>D4U_Dealoffer_Model_Resource</class>
51
+ <entities>
52
+ <offers>
53
+ <table>dealoffer_offers</table>
54
+ </offers>
55
+ <offers_store>
56
+ <table>dealoffer_offers_store</table>
57
+ </offers_store>
58
+ <offers_product>
59
+ <table>dealoffer_offers_product</table>
60
+ </offers_product>
61
+ </entities>
62
+ </dealoffer_resource>
63
+ </models>
64
+ <events>
65
+ <controller_front_init_routers>
66
+ <observers>
67
+ <d4u_dealoffer>
68
+ <class>D4U_Dealoffer_Controller_Router</class>
69
+ <method>initControllerRouters</method>
70
+ </d4u_dealoffer>
71
+ </observers>
72
+ </controller_front_init_routers>
73
+ </events>
74
+ </global>
75
+ <adminhtml>
76
+ <layout>
77
+ <updates>
78
+ <d4u_dealoffer>
79
+ <file>d4u_dealoffer.xml</file>
80
+ </d4u_dealoffer>
81
+ </updates>
82
+ </layout>
83
+ <translate>
84
+ <modules>
85
+ <D4U_Dealoffer>
86
+ <files>
87
+ <default>D4U_Dealoffer.csv</default>
88
+ </files>
89
+ </D4U_Dealoffer>
90
+ </modules>
91
+ </translate>
92
+ <events>
93
+ <core_block_abstract_prepare_layout_after>
94
+ <observers>
95
+ <offers>
96
+ <type>singleton</type>
97
+ <class>dealoffer/adminhtml_observer</class>
98
+ <method>addOffersBlock</method>
99
+ </offers>
100
+ </observers>
101
+ </core_block_abstract_prepare_layout_after>
102
+ <catalog_product_save_after>
103
+ <observers>
104
+ <offers>
105
+ <type>singleton</type>
106
+ <class>dealoffer/adminhtml_observer</class>
107
+ <method>saveOffersData</method>
108
+ </offers>
109
+ </observers>
110
+ </catalog_product_save_after>
111
+ </events>
112
+ <global_search>
113
+ <offers>
114
+ <class>dealoffer/adminhtml_search_offers</class>
115
+ <acl>dealoffer</acl>
116
+ </offers>
117
+ </global_search>
118
+ </adminhtml>
119
+ <admin>
120
+ <routers>
121
+ <adminhtml>
122
+ <args>
123
+ <modules>
124
+ <D4U_Dealoffer before="Mage_Adminhtml">D4U_Dealoffer_Adminhtml</D4U_Dealoffer>
125
+ </modules>
126
+ </args>
127
+ </adminhtml>
128
+ </routers>
129
+ </admin>
130
+ <frontend>
131
+ <routers>
132
+ <dealoffer>
133
+ <use>standard</use>
134
+ <args>
135
+ <module>D4U_Dealoffer</module>
136
+ <frontName>dealoffer</frontName>
137
+ </args>
138
+ </dealoffer>
139
+ </routers>
140
+ <layout>
141
+ <updates>
142
+ <d4u_dealoffer>
143
+ <file>d4u_dealoffer.xml</file>
144
+ </d4u_dealoffer>
145
+ </updates>
146
+ </layout>
147
+ <translate>
148
+ <modules>
149
+ <D4U_Dealoffer>
150
+ <files>
151
+ <default>D4U_Dealoffer.csv</default>
152
+ </files>
153
+ </D4U_Dealoffer>
154
+ </modules>
155
+ </translate>
156
+ </frontend>
157
+ <default>
158
+ <dealoffer>
159
+ <offers>
160
+ <breadcrumbs>1</breadcrumbs>
161
+ <rss>1</rss>
162
+ <meta_title>Offers</meta_title>
163
+ </offers>
164
+ </dealoffer>
165
+ </default>
166
+ </config>
app/code/local/D4U/Dealoffer/etc/system.xml ADDED
@@ -0,0 +1,93 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * D4U_Dealoffer extension
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the MIT License
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/mit-license.php
12
+ *
13
+ * @category D4U
14
+ * @package D4U_Dealoffer
15
+ * @copyright Copyright (c) 2013
16
+ * @license http://opensource.org/licenses/mit-license.php MIT License
17
+ */
18
+ -->
19
+ <config>
20
+ <tabs>
21
+ <d4u translate="label" module="dealoffer">
22
+ <label>D4U</label>
23
+ <sort_order>2000</sort_order>
24
+ </d4u>
25
+ </tabs>
26
+ <sections>
27
+ <dealoffer translate="label" module="dealoffer">
28
+ <class>separator-top</class>
29
+ <label>Deal Offer</label>
30
+ <tab>d4u</tab>
31
+ <frontend_type>text</frontend_type>
32
+ <sort_order>100</sort_order>
33
+ <show_in_default>1</show_in_default>
34
+ <show_in_website>1</show_in_website>
35
+ <show_in_store>1</show_in_store>
36
+ <groups>
37
+ <offers translate="label" module="dealoffer">
38
+ <label>Deal Offer Settings</label>
39
+ <frontend_type>text</frontend_type>
40
+ <sort_order>10</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
+ <fields>
45
+ <breadcrumbs translate="label" module="dealoffer">
46
+ <label>Use Breadcrumbs For Offers Pages</label>
47
+ <frontend_type>select</frontend_type>
48
+ <source_model>adminhtml/system_config_source_yesno</source_model>
49
+ <sort_order>10</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
+ </breadcrumbs>
54
+ <rss translate="label" module="dealoffer">
55
+ <label>Enable rss</label>
56
+ <frontend_type>select</frontend_type>
57
+ <source_model>adminhtml/system_config_source_yesno</source_model>
58
+ <sort_order>20</sort_order>
59
+ <show_in_default>1</show_in_default>
60
+ <show_in_website>1</show_in_website>
61
+ <show_in_store>1</show_in_store>
62
+ </rss>
63
+ <meta_title translate="label" module="dealoffer">
64
+ <label>Meta title for offers list page</label>
65
+ <frontend_type>text</frontend_type>
66
+ <sort_order>30</sort_order>
67
+ <show_in_default>1</show_in_default>
68
+ <show_in_website>1</show_in_website>
69
+ <show_in_store>1</show_in_store>
70
+ </meta_title>
71
+ <meta_description translate="label" module="dealoffer">
72
+ <label>Meta description for offers list page</label>
73
+ <frontend_type>textarea</frontend_type>
74
+ <sort_order>40</sort_order>
75
+ <show_in_default>1</show_in_default>
76
+ <show_in_website>1</show_in_website>
77
+ <show_in_store>1</show_in_store>
78
+ </meta_description>
79
+ <meta_keywords translate="label" module="dealoffer">
80
+ <label>Meta keywords for offers list page</label>
81
+ <frontend_type>textarea</frontend_type>
82
+ <sort_order>50</sort_order>
83
+ <show_in_default>1</show_in_default>
84
+ <show_in_website>1</show_in_website>
85
+ <show_in_store>1</show_in_store>
86
+ </meta_keywords>
87
+
88
+ </fields>
89
+ </offers>
90
+ </groups>
91
+ </dealoffer>
92
+ </sections>
93
+ </config>
app/code/local/D4U/Dealoffer/etc/widget.xml ADDED
@@ -0,0 +1,64 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * D4U_Dealoffer extension
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the MIT License
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/mit-license.php
12
+ *
13
+ * @category D4U
14
+ * @package D4U_Dealoffer
15
+ * @copyright Copyright (c) 2013
16
+ * @license http://opensource.org/licenses/mit-license.php MIT License
17
+ */
18
+ -->
19
+ <widgets>
20
+ <dealoffer_offers_view type="dealoffer/offers_widget_view" translate="name description" module="dealoffer">
21
+ <name>Offers view</name>
22
+ <description>Offers view widget</description>
23
+ <is_email_compatible>0</is_email_compatible>
24
+ <parameters>
25
+ <offers_id type="complex" translate="label">
26
+ <visible>1</visible>
27
+ <required>1</required>
28
+ <label>Offers</label>
29
+ <type>label</type>
30
+ <helper_block>
31
+ <type>dealoffer/adminhtml_offers_widget_chooser</type>
32
+ <data>
33
+ <button translate="open">
34
+ <open>Select Offers</open>
35
+ </button>
36
+ </data>
37
+ </helper_block>
38
+ <sort_order>120</sort_order>
39
+ </offers_id>
40
+ </parameters>
41
+ </dealoffer_offers_view>
42
+ <dealoffer_offers_link type="dealoffer/offers_widget_link" translate="name description" module="dealoffer">
43
+ <name>Offers link</name>
44
+ <description>Offers link widget</description>
45
+ <is_email_compatible>0</is_email_compatible>
46
+ <parameters>
47
+ <offers_id type="complex" translate="label">
48
+ <visible>1</visible>
49
+ <required>1</required>
50
+ <label>Offers</label>
51
+ <type>label</type>
52
+ <helper_block>
53
+ <type>dealoffer/adminhtml_offers_widget_chooser</type>
54
+ <data>
55
+ <button translate="open">
56
+ <open>Select Offers</open>
57
+ </button>
58
+ </data>
59
+ </helper_block>
60
+ <sort_order>130</sort_order>
61
+ </offers_id>
62
+ </parameters>
63
+ </dealoffer_offers_link>
64
+ </widgets>
app/code/local/D4U/Dealoffer/sql/d4u_dealoffer_setup/install-0.0.1.php ADDED
@@ -0,0 +1,123 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * D4U_Dealoffer extension
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the MIT License
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/mit-license.php
11
+ *
12
+ * @category D4U
13
+ * @package D4U_Dealoffer
14
+ * @copyright Copyright (c) 2013
15
+ * @license http://opensource.org/licenses/mit-license.php MIT License
16
+ */
17
+ /**
18
+ * Dealoffer module install script
19
+ *
20
+ * @category D4U
21
+ * @package D4U_Dealoffer
22
+ * @author Ultimate Module Creator
23
+ */
24
+ $this->startSetup();
25
+ $table = $this->getConnection()
26
+ ->newTable($this->getTable('dealoffer/offers'))
27
+ ->addColumn('entity_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
28
+ 'identity' => true,
29
+ 'nullable' => false,
30
+ 'primary' => true,
31
+ ), 'Offers ID')
32
+ ->addColumn('name', Varien_Db_Ddl_Table::TYPE_TEXT, 255, array(
33
+ 'nullable' => false,
34
+ ), 'Name')
35
+
36
+ ->addColumn('category_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
37
+ 'nullable' => false,
38
+ 'unsigned' => true,
39
+ ), 'Category')
40
+
41
+ ->addColumn('start_date', Varien_Db_Ddl_Table::TYPE_DATETIME, 255, array(
42
+ 'nullable' => false,
43
+ ), 'Start Date')
44
+
45
+ ->addColumn('end_date', Varien_Db_Ddl_Table::TYPE_DATETIME, 255, array(
46
+ 'nullable' => false,
47
+ ), 'End Date')
48
+
49
+ ->addColumn('deal_image', Varien_Db_Ddl_Table::TYPE_TEXT, 255, array(
50
+ ), 'Deal Image')
51
+
52
+ ->addColumn('offer_image', Varien_Db_Ddl_Table::TYPE_TEXT, 255, array(
53
+ ), 'Deal Image Upload')
54
+
55
+ ->addColumn('url_key', Varien_Db_Ddl_Table::TYPE_TEXT, 255, array(
56
+ ), 'URL key')
57
+
58
+ ->addColumn('status', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
59
+ ), 'Status')
60
+
61
+ ->addColumn('in_rss', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
62
+ ), 'In RSS')
63
+
64
+ ->addColumn('meta_title', Varien_Db_Ddl_Table::TYPE_TEXT, 255, array(
65
+ ), 'Meta title')
66
+
67
+ ->addColumn('meta_keywords', Varien_Db_Ddl_Table::TYPE_TEXT, '64k', array(
68
+ ), 'Meta keywords')
69
+
70
+ ->addColumn('meta_description', Varien_Db_Ddl_Table::TYPE_TEXT, '64k', array(
71
+ ), 'Meta description')
72
+
73
+ ->addColumn('created_at', Varien_Db_Ddl_Table::TYPE_TIMESTAMP, null, array(
74
+ ), 'Offers Creation Time')
75
+ ->addColumn('updated_at', Varien_Db_Ddl_Table::TYPE_TIMESTAMP, null, array(
76
+ ), 'Offers Modification Time')
77
+ ->setComment('Offers Table');
78
+ $this->getConnection()->createTable($table);
79
+
80
+ $table = $this->getConnection()
81
+ ->newTable($this->getTable('dealoffer/offers_store'))
82
+ ->addColumn('offers_id', Varien_Db_Ddl_Table::TYPE_SMALLINT, null, array(
83
+ 'nullable' => false,
84
+ 'primary' => true,
85
+ ), 'Offers ID')
86
+ ->addColumn('store_id', Varien_Db_Ddl_Table::TYPE_SMALLINT, null, array(
87
+ 'unsigned' => true,
88
+ 'nullable' => false,
89
+ 'primary' => true,
90
+ ), 'Store ID')
91
+ ->addIndex($this->getIdxName('dealoffer/offers_store', array('store_id')), array('store_id'))
92
+ ->addForeignKey($this->getFkName('dealoffer/offers_store', 'offers_id', 'dealoffer/offers', 'entity_id'), 'offers_id', $this->getTable('dealoffer/offers'), 'entity_id', Varien_Db_Ddl_Table::ACTION_CASCADE, Varien_Db_Ddl_Table::ACTION_CASCADE)
93
+ ->addForeignKey($this->getFkName('dealoffer/offers_store', 'store_id', 'core/store', 'store_id'), 'store_id', $this->getTable('core/store'), 'store_id', Varien_Db_Ddl_Table::ACTION_CASCADE, Varien_Db_Ddl_Table::ACTION_CASCADE)
94
+ ->setComment('Offers To Store Linkage Table');
95
+ $this->getConnection()->createTable($table);
96
+ $table = $this->getConnection()
97
+ ->newTable($this->getTable('dealoffer/offers_product'))
98
+ ->addColumn('rel_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
99
+ 'unsigned' => true,
100
+ 'identity' => true,
101
+ 'nullable' => false,
102
+ 'primary' => true,
103
+ ), 'Category ID')
104
+ ->addColumn('offers_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
105
+ 'unsigned' => true,
106
+ 'nullable' => false,
107
+ 'default' => '0',
108
+ ), 'Offers ID')
109
+ ->addColumn('product_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
110
+ 'unsigned' => true,
111
+ 'nullable' => false,
112
+ 'default' => '0',
113
+ ), 'Product ID')
114
+ ->addColumn('position', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
115
+ 'nullable' => false,
116
+ 'default' => '0',
117
+ ), 'Position')
118
+ ->addIndex($this->getIdxName('dealoffer/offers_product', array('product_id')), array('product_id'))
119
+ ->addForeignKey($this->getFkName('dealoffer/offers_product', 'offers_id', 'dealoffer/offers', 'entity_id'), 'offers_id', $this->getTable('dealoffer/offers'), 'entity_id', Varien_Db_Ddl_Table::ACTION_CASCADE, Varien_Db_Ddl_Table::ACTION_CASCADE)
120
+ ->addForeignKey($this->getFkName('dealoffer/offers_product', 'product_id', 'catalog/product', 'entity_id'), 'product_id', $this->getTable('catalog/product'), 'entity_id', Varien_Db_Ddl_Table::ACTION_CASCADE, Varien_Db_Ddl_Table::ACTION_CASCADE)
121
+ ->setComment('Offers to Product Linkage Table');
122
+ $this->getConnection()->createTable($table);
123
+ $this->endSetup();
app/design/adminhtml/default/default/layout/d4u_dealoffer.xml ADDED
@@ -0,0 +1,97 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * D4U_Dealoffer extension
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the MIT License
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/mit-license.php
12
+ *
13
+ * @category D4U
14
+ * @package D4U_Dealoffer
15
+ * @copyright Copyright (c) 2013
16
+ * @license http://opensource.org/licenses/mit-license.php MIT License
17
+ */
18
+ -->
19
+ <layout>
20
+ <!-- Offers grid action -->
21
+ <adminhtml_dealoffer_offers_index>
22
+ <reference name="menu">
23
+ <action method="setActive">
24
+ <menupath>dealoffer/offers</menupath>
25
+ </action>
26
+ </reference>
27
+ <reference name="content">
28
+ <block type="dealoffer/adminhtml_offers" name="offers" />
29
+ </reference>
30
+ </adminhtml_dealoffer_offers_index>
31
+ <adminhtml_dealoffer_offers_grid>
32
+ <block type="core/text_list" name="root" output="toHtml">
33
+ <block type="dealoffer/adminhtml_offers_grid" name="offers_grid"/>
34
+ </block>
35
+ </adminhtml_dealoffer_offers_grid>
36
+ <!-- Offers add/edit action -->
37
+ <adminhtml_dealoffer_offers_edit>
38
+ <update handle="editor"/>
39
+ <reference name="menu">
40
+ <action method="setActive">
41
+ <menupath>dealoffer/offers</menupath>
42
+ </action>
43
+ </reference>
44
+ <reference name="content">
45
+ <block type="dealoffer/adminhtml_offers_edit" name="offers_edit"></block>
46
+ </reference>
47
+ <reference name="left">
48
+ <block type="dealoffer/adminhtml_offers_edit_tabs" name="offers_tabs"></block>
49
+ </reference>
50
+ </adminhtml_dealoffer_offers_edit>
51
+ <adminhtml_dealoffer_offers_catalog_product_offerss>
52
+ <block type="core/text_list" name="root" output="toHtml">
53
+ <block type="dealoffer/adminhtml_catalog_product_edit_tab_offers" name="product.edit.tab.offers"/>
54
+ <block type="adminhtml/widget_grid_serializer" name="offers_grid_serializer">
55
+ <reference name="offers_grid_serializer">
56
+ <action method="initSerializerBlock">
57
+ <grid_block_name>product.edit.tab.offers</grid_block_name>
58
+ <data_callback>getSelectedOfferss</data_callback>
59
+ <hidden_input_name>offerss</hidden_input_name>
60
+ <reload_param_name>product_offerss</reload_param_name>
61
+ </action>
62
+ <action method="addColumnInputName">
63
+ <input_name>position</input_name>
64
+ </action>
65
+ </reference>
66
+ </block>
67
+ </block>
68
+ </adminhtml_dealoffer_offers_catalog_product_offerss>
69
+ <adminhtml_dealoffer_offers_catalog_product_offerssgrid>
70
+ <block type="core/text_list" name="root" output="toHtml">
71
+ <block type="dealoffer/adminhtml_catalog_product_edit_tab_offers" name="product.edit.tab.offers"/>
72
+ </block>
73
+ </adminhtml_dealoffer_offers_catalog_product_offerssgrid>
74
+ <adminhtml_dealoffer_offers_products>
75
+ <block type="core/text_list" name="root" output="toHtml">
76
+ <block type="dealoffer/adminhtml_offers_edit_tab_product" name="offers.edit.tab.product"/>
77
+ <block type="adminhtml/widget_grid_serializer" name="product_grid_serializer">
78
+ <reference name="product_grid_serializer">
79
+ <action method="initSerializerBlock">
80
+ <grid_block_name>offers.edit.tab.product</grid_block_name>
81
+ <data_callback>getSelectedProducts</data_callback>
82
+ <hidden_input_name>products</hidden_input_name>
83
+ <reload_param_name>offers_products</reload_param_name>
84
+ </action>
85
+ <action method="addColumnInputName">
86
+ <input_name>position</input_name>
87
+ </action>
88
+ </reference>
89
+ </block>
90
+ </block>
91
+ </adminhtml_dealoffer_offers_products>
92
+ <adminhtml_dealoffer_offers_productsgrid>
93
+ <block type="core/text_list" name="root" output="toHtml">
94
+ <block type="dealoffer/adminhtml_offers_edit_tab_product" name="offers.edit.tab.product"/>
95
+ </block>
96
+ </adminhtml_dealoffer_offers_productsgrid>
97
+ </layout>
app/design/frontend/default/default/layout/d4u_dealoffer.xml ADDED
@@ -0,0 +1,82 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * D4U_Dealoffer extension
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the MIT License
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/mit-license.php
12
+ *
13
+ * @category D4U
14
+ * @package D4U_Dealoffer
15
+ * @copyright Copyright (c) 2013
16
+ * @license http://opensource.org/licenses/mit-license.php MIT License
17
+ */
18
+ -->
19
+ <layout>
20
+ <default>
21
+ <reference name="footer_links">
22
+ <action method="addLink" translate="label title" module="dealoffer">
23
+ <label>Deal Offers</label>
24
+ <url helper="dealoffer/getOfferssUrl" />
25
+ <title>Deal Offers</title>
26
+ <prepare />
27
+ <urlParams/>
28
+ <position>120</position>
29
+ </action>
30
+ </reference>
31
+ <reference name="top.links">
32
+ <action method="addLink" translate="label title" module="dealoffer">
33
+ <label>Deal Offers</label>
34
+ <url helper="dealoffer/getOfferssUrl" />
35
+ <title>Deal Offers</title>
36
+ <prepare />
37
+ <urlParams/>
38
+ <position>5</position>
39
+ </action>
40
+ </reference>
41
+ <reference name="right">
42
+ <block type="dealoffer/Offers_List" name="daily deal" before="cart_sidebar" template="d4u_dealoffer/getdailydeal.phtml" >
43
+ </block>
44
+ </reference>
45
+
46
+
47
+ </default>
48
+ <dealoffer_offers_index translate="label" module="dealoffer">
49
+ <label>Offers list</label>
50
+ <reference name="root">
51
+ <action method="setTemplate"><template>page/1column.phtml</template></action>
52
+ </reference>
53
+ <reference name="content">
54
+ <block type="dealoffer/offers_list" name="offers_list" template="d4u_dealoffer/offers/list.phtml" />
55
+ </reference>
56
+ </dealoffer_offers_index>
57
+ <dealoffer_offers_view translate="label" module="dealoffer">
58
+ <label>Offers view page</label>
59
+ <reference name="root">
60
+ <action method="setTemplate"><template>page/2columns-left.phtml</template></action>
61
+ </reference>
62
+ <reference name="content">
63
+ <block type="dealoffer/offers_view" name="offers_view" template="d4u_dealoffer/offers/view.phtml" />
64
+ <block type="dealoffer/offers_catalog_product_list" name="offers.info.products" as="offers_products" template="d4u_dealoffer/offers/catalog/product/list.phtml" />
65
+ </reference>
66
+ </dealoffer_offers_view>
67
+ <dealoffer_offers_rss translate="label" module="dealoffer">
68
+ <label>Offers rss feed</label>
69
+ <block type="dealoffer/offers_rss" output="toHtml" name="dealoffer.offers.rss" />
70
+ </dealoffer_offers_rss>
71
+ <rss_index_index>
72
+ <reference name="content">
73
+ <block type="dealoffer/rss" name="dealoffer.rss" template="d4u_dealoffer/rss.phtml">
74
+ <action method="addFeed" ifconfig="dealoffer/offers/rss" translate="label" module="dealoffer">
75
+ <label>Offers</label>
76
+ <url helper="dealoffer/offers/getRssUrl" />
77
+ </action>
78
+ </block>
79
+ </reference>
80
+ </rss_index_index>
81
+
82
+ </layout>
app/design/frontend/default/default/template/d4u_dealoffer/getdailydeal.phtml ADDED
@@ -0,0 +1,101 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ $todayDate = Mage::app()->getLocale()->date()->toString(Varien_Date::DATE_INTERNAL_FORMAT);
3
+ $leftofferss = Mage::getResourceModel('dealoffer/offers_collection')
4
+ ->addStoreFilter(Mage::app()->getStore())
5
+ ->addFilter('status', 1)
6
+ ->customaddFilter('end_date', $todayDate ,">=")
7
+ ->customaddFilter('offer_image', 1 ,"=")
8
+ ;
9
+
10
+ $leftofferss->GroupbyAdd('entity_id');
11
+ if($leftofferss->getSize() != 0) {
12
+ ?>
13
+ <script src="<?php echo $this->getJsUrl(); ?>d4u_dealoffer/countdown.js" type="text/javascript"></script>
14
+ <style>
15
+ .time{
16
+ background :none repeat scroll 0 0 #FAE683;
17
+ border:1px solid #FAC903;
18
+ color:#333333;
19
+ font-size:15px;
20
+ padding:0px 5px 0px 5px;
21
+ }
22
+ li.item { list-style: none outside none;}
23
+ .block-deal {
24
+ border :5px solid #000000;
25
+ border-radius :8px;
26
+ font-size:13px;
27
+ line-height:1.25;
28
+
29
+ }
30
+ .block-deal-title {
31
+ background:#000;
32
+ color:#FFFFFF;
33
+ font-size:14px;
34
+ padding:5px;
35
+ text-align:center;
36
+ }
37
+ .deal-product-image{ border:1px solid #ccc;vertical-align:middle;max-height:160px;}
38
+ </style>
39
+ <?php
40
+ foreach ($leftofferss as $leftoffers) {
41
+ $leftdata = $leftoffers->getData();
42
+
43
+ ?>
44
+ <div class="block block-deal">
45
+ <div class="block-deal-title">
46
+ <strong><?php echo $this->__("Today's Deal") ?></strong>
47
+ </div>
48
+ <div class="block-content">
49
+
50
+ <ol id="best-sidebar" class="mini-products-list">
51
+ <li class="item">
52
+ <div>
53
+ <p class="product-name">
54
+ <a href="<?php echo $leftoffers->getOffersUrl() ?>"><?php echo $leftoffers->getName();?></a>
55
+ </p>
56
+ </div>
57
+ <div>
58
+ <br/>
59
+ <a href="<?php echo $leftoffers->getOffersUrl();?>" title="<?php echo $this->htmlEscape($leftoffers->getName()) ?>" ><img src="<?php echo Mage::helper('dealoffer/offers_image')->init($leftoffers, 'deal_image')->resize(166);?>" alt="<?php echo $this->htmlEscape($leftoffers->getName());?>" class='deal-product-image'/></a>
60
+ <br/>
61
+ </div>
62
+
63
+ </li>
64
+ <li class="item">
65
+
66
+ <div >
67
+ <div class="time" id="countboxofferleft" style="float:right"></div>
68
+ <script>
69
+ leftdivlist.push('countboxofferleft<?php echo "&&||&&".date("Y/m/d", strtotime($leftdata['end_date']));?>') ;
70
+ </script>
71
+ </div>
72
+ </li>
73
+ </ol>
74
+ <div class="actions" style="margin-top:8px;">
75
+ <button onclick="setLocation('<?php echo $this->getUrl('dealoffer/offers');?>')" class="button" title="<?php echo $this->__('View All Offers') ?>" type="button"><span><span><?php echo $this->__('View All Offers') ?></span></span></button>
76
+ </div>
77
+ </div>
78
+ <?php
79
+
80
+ }
81
+
82
+ ?>
83
+ <script>
84
+ window.onload=function(){
85
+
86
+ if(leftdivlist.length > 0)
87
+ {
88
+ for(i=0;i<leftdivlist.length;i++)
89
+ {
90
+ var arr = leftdivlist[i].split("&&||&&");
91
+ //alert(arr[1]);
92
+ var dateFuture1 = new Date(arr[1]);
93
+ GetCount_offer(dateFuture1, arr[0]);
94
+ }
95
+
96
+ }
97
+ //you can add additional countdowns here (just make sure you create dateFuture2 and countbox2 etc for each)
98
+ }
99
+ </script>
100
+ </div>
101
+ <?php } ?>
app/design/frontend/default/default/template/d4u_dealoffer/offers/catalog/product/list.phtml ADDED
@@ -0,0 +1,137 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * D4U_Dealoffer extension
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the MIT License
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/mit-license.php
11
+ *
12
+ * @category D4U
13
+ * @package D4U_Dealoffer
14
+ * @copyright Copyright (c) 2013
15
+ * @license http://opensource.org/licenses/mit-license.php MIT License
16
+ */
17
+ /**
18
+ * Offers product list template
19
+ *
20
+ * @category D4U
21
+ * @package D4U_Dealoffer
22
+ * @author Ultimate Module Creator
23
+ */
24
+ $get_parm_list = $this->getRequest()->getParams();
25
+ if(!isset($get_parm_list['mode'])){
26
+ $get_parm_list['mode'] ="grid";
27
+ }
28
+ $_productCollection = $this->getProductCollection();
29
+ if($_productCollection->count() > 0 ) {
30
+ ?>
31
+ <?php // Grid Mode ?>
32
+ <div class="pager">
33
+ <p class="amount">
34
+ <strong><?php echo $_productCollection->count();?> Item(s)</strong>
35
+ </p>
36
+ </div>
37
+ <?php if($get_parm_list['mode'] == 'list') {?>
38
+ <div class="listing-type-list catalog-listing">
39
+ <ol class="products-list" id="products-list">
40
+ <?php foreach ($_productCollection as $_product): ?>
41
+
42
+ <?php $_product = Mage::getModel('catalog/product')->load($_product->getEntityId());
43
+ $block = Mage::app()->getLayout()->createBlock('catalog/product_list');
44
+ ?>
45
+ <li class="item<?php if( ++$_iterator == sizeof($_productCollection) ): ?> last<?php endif; ?>">
46
+ <?php // Product Image ?>
47
+
48
+ <a class="product-image" href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->htmlEscape($_product->getSmallImageLabel()) ?>">
49
+ <img src="<?php echo $this->helper('catalog/image')->init($_product, 'small_image')->resize(135, 135); ?>" width="135" height="135" alt="<?php echo $this->htmlEscape($this->getImageLabel($_product, 'small_image')) ?>" title="<?php echo $this->htmlEscape($this->getImageLabel($_product, 'small_image')) ?>" />
50
+ </a>
51
+
52
+
53
+ <?php // Product description ?>
54
+ <div class="product-shop">
55
+ <div class="f-fix">
56
+ <h2 class="product-name"><a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->htmlEscape($_product->getName()) ?>"><?php echo $this->htmlEscape($_product->getName())?></a></h2>
57
+ <?php echo $block->getReviewsSummaryHtml($_product) ?>
58
+ <?php echo $block->getPriceHtml($_product, true) ?>
59
+ <p>
60
+ <?php if($_product->getIsSalable()): ?>
61
+ <button class="button btn-cart" onclick="setLocation('<?php echo $this->getAddToCartUrl($_product) ?>')"><span><?php echo $this->__('Add to Cart') ?></span></button>
62
+ <?php else: ?>
63
+ <div class="out-of-stock"><?php echo $this->__('Out of stock') ?></div>
64
+ <?php endif; ?>
65
+ </p>
66
+ <div class="clear"></div>
67
+ <div class="desc std">
68
+ <?php echo nl2br($_product->getShortDescription()) ?>
69
+ <a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->htmlEscape($_product->getName()) ?>"><small><?php echo $this->__('Learn More') ?></small></a>
70
+ </div>
71
+ <ul class="add-to-links">
72
+ <?php if ($this->helper('wishlist')->isAllow()) : ?>
73
+ <li>
74
+ <a href="<?php echo $this->helper('wishlist')->getAddUrl($_product) ?>" class="link-cart"><?php echo $this->__('Add to Wishlist') ?></a>
75
+ </li>
76
+ <?php endif; ?>
77
+ <?php if($_compareUrl=$block->getAddToCompareUrl($_product)): ?>
78
+ <span class="pipe">|</span>
79
+ <li><a href="<?php echo $_compareUrl ?>"><?php echo $this->__('Add to Compare') ?></a></li>
80
+ <?php endif; ?>
81
+ </ul>
82
+ <div>
83
+ </div>
84
+ </li>
85
+ <?php endforeach; ?>
86
+ </ol>
87
+ </div>
88
+ <script type="text/javascript">decorateList('products-list', 'none-recursive')</script>
89
+ <?php }else {?>
90
+ <div class="listing-type-grid catalog-listing">
91
+ <?php $_collectionSize = $_productCollection->count() ?>
92
+ <?php $_columnCount = 4 ?>
93
+ <?php $i=0; foreach ($_productCollection as $_product): ?>
94
+
95
+ <?php $_product = Mage::getModel('catalog/product')->load($_product->getEntityId());
96
+ $block = Mage::app()->getLayout()->createBlock('catalog/product_list');
97
+ ?>
98
+
99
+ <?php if($i++%$_columnCount==0): ?>
100
+ <ul class="products-grid" style="padding:0px;margin:0px">
101
+ <?php endif; ?>
102
+ <li class="item" style="list-style:none">
103
+
104
+ <a class='product-image' href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->htmlEscape($this->getImageLabel($_product, 'small_image')) ?>">
105
+ <img src="<?php echo $this->helper('catalog/image')->init($_product, 'small_image')->resize(135, 135); ?>" width="135" height="135" alt="<?php echo $this->htmlEscape($this->getImageLabel($_product, 'small_image')) ?>" title="<?php echo $this->htmlEscape($this->getImageLabel($_product, 'small_image')) ?>" />
106
+ </a>
107
+
108
+ <h2><a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->htmlEscape($_product->getName()) ?>"><?php echo $this->htmlEscape($_product->getName()) ?></a></h2>
109
+ <?php echo $block->getReviewsSummaryHtml($_product, 'short') ?>
110
+ <?php echo $block->getPriceHtml($_product, true) ?>
111
+ <?php if($_product->getIsSalable()): ?>
112
+ <button type="button" class="button btn-cart" onclick="setLocation('<?php echo Mage::helper('checkout/cart')->getAddUrl($_product) //echo $this->getAddToCartUrl($_product) ?>')"><span><?php echo $this->__('Add to Cart') ?></span></button>
113
+ <?php else: ?>
114
+ <div class="out-of-stock"><?php echo $this->__('Out of stock') ?></div>
115
+ <?php endif; ?>
116
+ <p class="add-to">
117
+ <?php if ($this->helper('wishlist')->isAllow()) : ?>
118
+ <a href="<?php echo $this->helper('wishlist')->getAddUrl($_product) ?>" class="link-cart"><?php echo $this->__('Add to Wishlist') ?></a>
119
+ <?php endif; ?>
120
+ <?php if($_compareUrl=$block->getAddToCompareUrl($_product)): ?><br/>
121
+ <a href="<?php echo $_compareUrl ?>"><?php echo $this->__('Add to Compare') ?></a>
122
+ <?php endif; ?>
123
+ </p>
124
+ </li>
125
+ <?php if($i%$_columnCount==0 || $i==$_collectionSize): ?>
126
+ </ul>
127
+ <?php endif; ?>
128
+ <?php endforeach ?>
129
+ <script type="text/javascript">decorateGeneric($$('ul.products-grid'), ['odd','even','first','last'])</script>
130
+ </div>
131
+ <?php } ?>
132
+ <div class="pager">
133
+ <p class="amount">
134
+ <strong><?php echo $_productCollection->count();?> Item(s)</strong>
135
+ </p>
136
+ </div>
137
+ <?php } ?>
app/design/frontend/default/default/template/d4u_dealoffer/offers/categoryview.phtml ADDED
@@ -0,0 +1,74 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ $get_parm = $this->getRequest()->getParams();
3
+ $todayDate = Mage::app()->getLocale()->date()->toString(Varien_Date::DATE_INTERNAL_FORMAT);
4
+ $offerss = Mage::getResourceModel('dealoffer/offers_collection')
5
+ ->addStoreFilter(Mage::app()->getStore())
6
+ ->addFilter('status', 1)
7
+ ->customaddFilter('end_date', $todayDate ,">=")
8
+ ->customaddFilter('category_id', $get_parm['id'] ,"=")
9
+ ;
10
+
11
+ //$offerss->setOrder('name', 'asc');
12
+ $offerss->GroupbyAdd('entity_id');
13
+ $category = Mage::getModel('catalog/category')->load($get_parm['id']);
14
+ ?>
15
+ <script src="<?php echo $this->getJsUrl(); ?>d4u_dealoffer/countdown.js" type="text/javascript"></script>
16
+ <link rel='stylesheet' id='camera-css' href="<?php echo $this->getSkinUrl('d4u_dealoffer/deal.css');?>" type='text/css' media='all'>
17
+ <?php echo $this->getMessagesBlock()->getGroupedHtml() ?>
18
+ <?php $_offerss = $offerss; ?>
19
+ <div class="page-title offers-title">
20
+ <h1><?php echo Mage::helper('dealoffer')->__($category->getName(). ' Deals') ?></h1>
21
+ </div>
22
+ <?php
23
+ if (!empty($_offerss)) :?>
24
+ <div class="dela_offer">
25
+ <?php
26
+ $j=0;
27
+ foreach ($_offerss as $_offers) :
28
+ $data = $_offers->getData();
29
+ $current_cat = $data['category_id'];
30
+ ?>
31
+ <div class="itemcategory">
32
+ <div style="height:45px;">
33
+ <div class="time" id="countboxoffer1_<?php echo $j?>" style="float:right"></div>
34
+ <script>
35
+ divlists.push('countboxoffer1_<?php echo $j."&&||&&".date("Y/m/d", strtotime($data['end_date']));?>') ;
36
+ </script>
37
+
38
+ </div>
39
+
40
+ <?php if ($_offers->getDealImage()) :?>
41
+ <div class="itemcategory_center_image">
42
+ <a href="<?php echo $_offers->getOffersUrl();?>" title="<?php echo $this->htmlEscape($_offers->getName()) ?>" class='product-image'>
43
+ <img src="<?php echo Mage::helper('dealoffer/offers_image')->init($_offers, 'deal_image')->resize(200);?>" alt="<?php echo $this->htmlEscape($_offers->getName());?>" style="vertical-align:middle;max-height:150px;" />
44
+ </a>
45
+ </div>
46
+ <?php endif;?>
47
+ <div class="bordder_bottom">&nbsp;</div>
48
+ <div class="title"><?php echo $_offers->getName();?></div>
49
+ </div>
50
+ <?php
51
+ $j++;
52
+ endforeach;?>
53
+ </div>
54
+ <script>
55
+ window.onload=function(){
56
+
57
+ if(divlists.length > 0)
58
+ {
59
+ for(i=0;i<divlists.length;i++)
60
+ {
61
+ var arr = divlists[i].split("&&||&&");
62
+ //alert(arr[1]);
63
+ var dateFuture1 = new Date(arr[1]);
64
+ GetCount_offer(dateFuture1, arr[0]);
65
+ }
66
+
67
+ }
68
+ //you can add additional countdowns here (just make sure you create dateFuture2 and countbox2 etc for each)
69
+ }
70
+ </script>
71
+ <?php else : ?>
72
+ <?php echo Mage::helper('dealoffer')->__('There are no offers at this moment');?>
73
+ <?php endif;?>
74
+
app/design/frontend/default/default/template/d4u_dealoffer/offers/list.phtml ADDED
@@ -0,0 +1,97 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * D4U_Dealoffer extension
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the MIT License
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/mit-license.php
11
+ *
12
+ * @category D4U
13
+ * @package D4U_Dealoffer
14
+ * @copyright Copyright (c) 2013
15
+ * @license http://opensource.org/licenses/mit-license.php MIT License
16
+ */
17
+ /**
18
+ * Offers list template
19
+ *
20
+ * @category D4U
21
+ * @package D4U_Dealoffer
22
+ * @author Ultimate Module Creator
23
+ */
24
+ $division_cat =0;
25
+ ?>
26
+ <script src="<?php echo $this->getJsUrl(); ?>d4u_dealoffer/countdown.js" type="text/javascript"></script>
27
+ <link rel='stylesheet' id='camera-css' href="<?php echo $this->getSkinUrl('d4u_dealoffer/deal.css');?>" type='text/css' media='all'>
28
+ <?php echo $this->getMessagesBlock()->getGroupedHtml() ?>
29
+ <?php $_offerss = $this->getOfferss(); ?>
30
+ <div class="page-title offers-title">
31
+ <?php if(Mage::helper('dealoffer/offers')->isRssEnabled()) : ?>
32
+ <a href="<?php echo Mage::helper('dealoffer/offers')->getRssUrl();?>" class="link-rss"><?php echo Mage::helper('dealoffer')->__('Subscribe to RSS Feed')?></a>
33
+ <?php endif;?>
34
+ <h1><?php echo Mage::helper('dealoffer')->__('Offers') ?></h1>
35
+ </div>
36
+ <?php
37
+ if ($_offerss->getSize() > 0) :?>
38
+ <?php echo $this->getPagerHtml(); ?>
39
+ <div class="dela_offer"><br/><br/>
40
+ <?php
41
+ $j=0;
42
+ foreach ($_offerss as $_offers) :
43
+ $data = $_offers->getData();
44
+ $current_cat = $data['category_id'];
45
+ ?>
46
+ <div class="item">
47
+ <?php
48
+ $category = Mage::getModel('catalog/category')->load($current_cat);
49
+ ?>
50
+
51
+ <div style="height:45px;"><h3 class="top_category" style="float:left">&nbsp;&nbsp;<?php echo $category->getName();?></h3>
52
+ <div class="time" id="countboxoffer1_<?php echo $j?>" style="float:right"></div>
53
+ <script>
54
+ divlists.push('countboxoffer1_<?php echo $j."&&||&&".date("Y/m/d", strtotime($data['end_date']));?>') ;
55
+ </script>
56
+
57
+ </div>
58
+
59
+ <?php if ($_offers->getDealImage()) :?>
60
+ <div class="item_center_image">
61
+ <a href="<?php echo $_offers->getOffersUrl();?>" title="<?php echo $this->htmlEscape($_offers->getName()) ?>" class='product-image'>
62
+ <img src="<?php echo Mage::helper('dealoffer/offers_image')->init($_offers, 'deal_image')->resize(250);?>" alt="<?php echo $this->htmlEscape($_offers->getName());?>" id="imgck" style="max-height:200px;" />
63
+ </a>
64
+ </div>
65
+ <?php endif;?>
66
+ <div class="bordder_bottom">&nbsp;</div>
67
+ <div class="title"><?php echo $_offers->getName();?></div>
68
+ <?php if($data['category_count'] > 1) {?>
69
+ <div class="button"><a href="<?php echo $this->getUrl('dealoffer/offers/categoryview/',array('id'=>$current_cat)); ?>" class="btn-orange">View all offers</a></div>
70
+ <?php } ?>
71
+ </div>
72
+ <?php
73
+ $j++;
74
+ endforeach;?>
75
+ </div>
76
+ <script>
77
+ window.onload=function(){
78
+
79
+ if(divlists.length > 0)
80
+ {
81
+ for(i=0;i<divlists.length;i++)
82
+ {
83
+ var arr = divlists[i].split("&&||&&");
84
+ //alert(arr[1]);
85
+ var dateFuture1 = new Date(arr[1]);
86
+ GetCount_offer(dateFuture1, arr[0]);
87
+ }
88
+
89
+ }
90
+ //you can add additional countdowns here (just make sure you create dateFuture2 and countbox2 etc for each)
91
+ }
92
+ </script>
93
+ <?php echo $this->getPagerHtml(); ?>
94
+ <?php else : ?>
95
+ <?php echo Mage::helper('dealoffer')->__('There are no offers at this moment');?>
96
+ <?php endif;?>
97
+
app/design/frontend/default/default/template/d4u_dealoffer/offers/view.phtml ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * D4U_Dealoffer extension
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the MIT License
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/mit-license.php
11
+ *
12
+ * @category D4U
13
+ * @package D4U_Dealoffer
14
+ * @copyright Copyright (c) 2013
15
+ * @license http://opensource.org/licenses/mit-license.php MIT License
16
+ */
17
+ /**
18
+ * Offers view template
19
+ *
20
+ * @category D4U
21
+ * @package D4U_Dealoffer
22
+ * @author Ultimate Module Creator
23
+ */
24
+ $get_parm = $this->getRequest()->getParams();
25
+ if(!isset($get_parm['mode'])){
26
+ $get_parm['mode'] ="grid";
27
+ }
28
+ ?>
29
+ <?php $_offers = $this->getCurrentOffers();?>
30
+ <?php echo $this->getMessagesBlock()->getGroupedHtml() ?>
31
+ <div class="page-title category-title">
32
+ <h1><?php echo $_offers->getName(); ?></h1>
33
+ </div>
34
+ <div class="pager" style="text-align:right">
35
+ <label>View as:</label>
36
+ <?php if(isset($get_parm['mode']) && $get_parm['mode'] == 'grid') {?>
37
+ <strong class="grid" title="Grid" >Grid</strong>
38
+ <?php }else{ ?>
39
+ <a class="grid" title="Grid" href="<?php echo $_offers->getOffersUrl();?>?mode=grid">Grid</a>
40
+ <?php } ?>
41
+
42
+ <?php if(isset($get_parm['mode']) && $get_parm['mode'] == 'list') {?>
43
+ <strong class="list" title="List" >List</strong>
44
+ <?php }else{ ?>
45
+ <a class="list" title="List" href="<?php echo $_offers->getOffersUrl();?>?mode=list">List</a>
46
+ <?php } ?>
47
+ </div>
app/design/frontend/default/default/template/d4u_dealoffer/offers/widget/link.phtml ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * D4U_Dealoffer extension
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the MIT License
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/mit-license.php
11
+ *
12
+ * @category D4U
13
+ * @package D4U_Dealoffer
14
+ * @copyright Copyright (c) 2013
15
+ * @license http://opensource.org/licenses/mit-license.php MIT License
16
+ */
17
+ /**
18
+ * Offers link widget template
19
+ *
20
+ * @category D4U
21
+ * @package D4U_Dealoffer
22
+ * @author Ultimate Module Creator
23
+ */
24
+ ?>
25
+ <?php $_offers = $this->getCurrentOffers();?>
26
+ <?php if ($_offers) :?>
27
+ <div class="offers-widget-link">
28
+ <a href="<?php echo $_offers->getOffersUrl()?>"><?php echo $_offers->getName()?></a>
29
+ </div>
30
+ <?php endif;?>
app/design/frontend/default/default/template/d4u_dealoffer/offers/widget/view.phtml ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * D4U_Dealoffer extension
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the MIT License
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/mit-license.php
11
+ *
12
+ * @category D4U
13
+ * @package D4U_Dealoffer
14
+ * @copyright Copyright (c) 2013
15
+ * @license http://opensource.org/licenses/mit-license.php MIT License
16
+ */
17
+ /**
18
+ * Offers view widget template
19
+ *
20
+ * @category D4U
21
+ * @package D4U_Dealoffer
22
+ * @author Ultimate Module Creator
23
+ */
24
+ ?>
25
+ <?php $_offers = $this->getCurrentOffers();?>
26
+ <?php if ($_offers) :?>
27
+ <div class="offers-widget-view">
28
+ <h3><?php echo $_offers->getName()?></h3>
29
+ <div>
30
+ <?php echo Mage::helper('dealoffer')->__('Name');?>:<?php echo $_offers->getName();?>
31
+ <?php echo Mage::helper('dealoffer')->__('Category');?>:<?php echo $_offers->getCategoryId();?>
32
+ <?php echo Mage::helper('dealoffer')->__('Start Date');?>:<?php echo $_offers->getStartDate();?>
33
+ <?php echo Mage::helper('dealoffer')->__('End Date');?>:<?php echo $_offers->getEndDate();?>
34
+ <?php if ($_offers->getDealImage()) :?>
35
+ <img src="<?php echo Mage::helper('dealoffer/offers_image')->init($_offers, 'deal_image')->resize(75);?>" alt="<?php echo $this->htmlEscape($_offers->getName());?>" />
36
+ <?php endif;?>
37
+ <?php if ($_offers->getOfferImage()) :?>
38
+ <a href="<?php echo Mage::helper('dealoffer/offers')->getFileBaseUrl().$_offers->getOfferImage();?>">
39
+ <span><?php echo basename($_offers->getOfferImage())?></span>
40
+ </a>
41
+ <?php endif;?>
42
+
43
+ </div>
44
+ </div>
45
+ <?php endif;?>
app/design/frontend/default/default/template/d4u_dealoffer/rss.phtml ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * D4U_Dealoffer extension
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the MIT License
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/mit-license.php
11
+ *
12
+ * @category D4U
13
+ * @package D4U_Dealoffer
14
+ * @copyright Copyright (c) 2013
15
+ * @license http://opensource.org/licenses/mit-license.php MIT License
16
+ */
17
+ /**
18
+ * dealoffer rss feeds block
19
+ * @category D4U
20
+ * @package D4U_Dealoffer
21
+ * @author Ultimate Module Creator
22
+ */
23
+ ?>
24
+ <?php $_feeds = $this->getFeeds();?>
25
+ <?php if ($_feeds): ?>
26
+ <table class="data-table rss-table" id="rss-table-dealoffer" style="margin-top:20px">
27
+ <col />
28
+ <col width="1" />
29
+ <thead>
30
+ <tr>
31
+ <th colspan="2"><?php echo Mage::helper('dealoffer')->__('Dealoffer Feeds') ?></th>
32
+ </tr>
33
+ </thead>
34
+ <tbody>
35
+ <?php foreach ($_feeds as $_feed): ?>
36
+ <tr>
37
+ <td><?php echo $_feed->getLabel() ?></td>
38
+ <td><a href="<?php echo $_feed->getUrl() ?>" class="link-rss"><?php echo Mage::helper('dealoffer')->__('Get Feed'); ?></a></td>
39
+ </tr>
40
+ <?php endforeach; ?>
41
+ </tbody>
42
+ </table>
43
+ <?php endif; ?>
app/etc/modules/D4U_Dealoffer.xml ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * D4U_Dealoffer extension
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the MIT License
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/mit-license.php
12
+ *
13
+ * @category D4U
14
+ * @package D4U_Dealoffer
15
+ * @copyright Copyright (c) 2013
16
+ * @license http://opensource.org/licenses/mit-license.php MIT License
17
+ */
18
+ -->
19
+ <config>
20
+ <modules>
21
+ <D4U_Dealoffer>
22
+ <active>true</active>
23
+ <codePool>local</codePool>
24
+ <depends>
25
+ <Mage_Core />
26
+ </depends>
27
+ </D4U_Dealoffer>
28
+ </modules>
29
+ </config>
app/locale/en_US/D4U_Dealoffer.csv ADDED
@@ -0,0 +1,60 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ "Action","Action"
2
+ "Add Offers","Add Offers"
3
+ "Are you sure?","Are you sure?"
4
+ "Associated products","Associated products"
5
+ "CSV","CSV"
6
+ "Category","Category"
7
+ "Change status","Change status"
8
+ "Could not find offers to delete.","Could not find offers to delete."
9
+ "Deal Expiry Time","Deal Expiry Time"
10
+ "Deal Image Upload","Deal Image Upload"
11
+ "Deal Image","Deal Image"
12
+ "Deal Start Date","Deal Start Date"
13
+ "Delete File","Delete File"
14
+ "Delete Offers","Delete Offers"
15
+ "Delete","Delete"
16
+ "Disabled","Disabled"
17
+ "Edit Offers '%s'","Edit Offers '%s'"
18
+ "Edit","Edit"
19
+ "Enabled","Enabled"
20
+ "End Date","End Date"
21
+ "Enter deal/offer Name","Enter deal/offer Name"
22
+ "Excel","Excel"
23
+ "Home","Home"
24
+ "Id","Id"
25
+ "Image","Image"
26
+ "Meta information","Meta information"
27
+ "Meta","Meta"
28
+ "Meta-description","Meta-description"
29
+ "Meta-keywords","Meta-keywords"
30
+ "Name","Name"
31
+ "No","No"
32
+ "None","None"
33
+ "Offers was successfully deleted.","Offers was successfully deleted."
34
+ "Offers was successfully saved","Offers was successfully saved"
35
+ "Offers","Offers"
36
+ "Please select offers to delete.","Please select offers to delete."
37
+ "Please select offers.","Please select offers."
38
+ "Position","Position"
39
+ "Relative to Website Base URL","Relative to Website Base URL"
40
+ "Save And Continue Edit","Save And Continue Edit"
41
+ "Save Offers","Save Offers"
42
+ "Select Product Category","Select Product Category"
43
+ "Show in rss","Show in rss"
44
+ "Meta-title","Meta-title"
45
+ "Start Date","Start Date"
46
+ "Status","Status"
47
+ "Store views","Store views"
48
+ "The URL key cannot consist only of numbers.","The URL key cannot consist only of numbers."
49
+ "The URL key contains capital letters or disallowed symbols.","The URL key contains capital letters or disallowed symbols."
50
+ "There was a problem saving the offers.","There was a problem saving the offers."
51
+ "There was an error deleteing offers.","There was an error deleteing offers."
52
+ "There was an error updating offers.","There was an error updating offers."
53
+ "This offers no longer exists.","This offers no longer exists."
54
+ "Total of %d offers were successfully deleted.","Total of %d offers were successfully deleted."
55
+ "Total of %d offers were successfully updated.","Total of %d offers were successfully updated."
56
+ "URL key already exists.","URL key already exists."
57
+ "URL key","URL key"
58
+ "Unable to find offers to save.","Unable to find offers to save."
59
+ "XML","XML"
60
+ "Yes","Yes"
js/d4u_dealoffer/countdown.js ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ dateFuture1 = new Date(2013,10,26,12,00,00);
2
+ var divlists = [];
3
+ var leftdivlist = [];
4
+ function GetCount_offer(ddate,iid){
5
+
6
+ dateNow = new Date(); //grab current date
7
+ amount = ddate.getTime() - dateNow.getTime(); //calc milliseconds between dates
8
+ delete dateNow;
9
+
10
+ // if time is already past
11
+ if(amount < 0){
12
+ document.getElementById(iid).innerHTML="Now!";
13
+ }
14
+ // else date is still good
15
+ else{
16
+ days=0;hours=0;mins=0;secs=0;out="";
17
+
18
+ amount = Math.floor(amount/1000);//kill the "milliseconds" so just secs
19
+
20
+ days=Math.floor(amount/86400);//days
21
+ amount=amount%86400;
22
+
23
+ hours=Math.floor(amount/3600);//hours
24
+ amount=amount%3600;
25
+
26
+ mins=Math.floor(amount/60);//minutes
27
+ amount=amount%60;
28
+
29
+ secs=Math.floor(amount);//seconds
30
+
31
+ /*if(days != 0){out += days +" "+((days==1)?"day":"days")+", ";}
32
+ if(hours != 0){out += hours +" "+((hours==1)?"hour":"hours")+", ";}
33
+ out += mins +" "+((mins==1)?"min":"mins")+", ";
34
+ out += secs +" "+((secs==1)?"sec":"secs")+", ";
35
+ out = out.substr(0,out.length-2);*/
36
+ if(days != 0){out += days +" "+((days==1)?"day":"days")+" &hearts; ";} else { out += " &hearts; ";}//&hearts;&#9685;
37
+ if(hours != 0){out += hours +" "+((hours==1)?"":"")+" : ";}
38
+ out += mins +" "+((mins==1)?"":"")+": ";
39
+ out += secs +" "+((secs==1)?"":"")+": ";
40
+ out = out.substr(0,out.length-2);
41
+ document.getElementById(iid).innerHTML=out;
42
+
43
+ setTimeout(function(){GetCount_offer(ddate,iid)}, 1000);
44
+ }
45
+ }
package.xml ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>d4u_dealoffer</name>
4
+ <version>1.0.0</version>
5
+ <stability>stable</stability>
6
+ <license uri="http://opensource.org/licenses/osl-3.0.php">OSL v3.0</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>Deal offer for Magento</summary>
10
+ <description>Deal offer for Magento</description>
11
+ <notes>Deal offer for Magento</notes>
12
+ <authors><author><name>Gayatri</name><user>Gayatri</user><email>gayatri.patel@einfochips.com</email></author></authors>
13
+ <date>2013-12-30</date>
14
+ <time>07:00:38</time>
15
+ <contents><target name="magelocal"><dir name="D4U"><dir name="Dealoffer"><dir name="Block"><dir name="Adminhtml"><dir name="Catalog"><dir name="Product"><dir name="Edit"><dir name="Tab"><file name="Offers.php" hash="58e7fbdf404c69746ca8d9c78e4ff615"/></dir></dir></dir></dir><dir name="Offers"><dir name="Edit"><file name="Form.php" hash="069879bd7188975f23ab7c60f7e9fb1e"/><dir name="Tab"><file name="Form.php" hash="e97fa5870191a1cfde4e0b22847de1dd"/><file name="Meta.php" hash="5a918b5f8a9932b18436464df73bfcf7"/><file name="Product.php" hash="3e66dbe72d746aae36744261592bdbec"/><file name="Stores.php" hash="d830ab0600747dd9e0fb3a60c58ca515"/></dir><file name="Tabs.php" hash="ce201338f8314aa976f0d1d6e6128d07"/></dir><file name="Edit.php" hash="9f23ee9c9ddaf6deae6ec5934fc0e8f0"/><file name="Grid.php" hash="84d1b1318a32d2e0620ef1406226c6c7"/><dir name="Helper"><file name="File.php" hash="a24b7b6d31c5ac5a3f65625f843a9067"/><file name="Image.php" hash="709d8d086a8da55cbcbc40ec7e8310dd"/></dir><dir name="Widget"><file name="Chooser.php" hash="763752c923f15df2747eb15e72b3c5be"/></dir></dir><file name="Offers.php" hash="c1beacffead26d89fbcacb8f32a34d70"/></dir><dir name="Offers"><dir name="Catalog"><dir name="Product"><file name="List.php" hash="946c74c1aa395907fa29b8fa62b94d89"/></dir></dir><file name="List.php" hash="c9dc3b813e5a0abb38909dfd9dafd580"/><file name="Rss.php" hash="7da194cea15714d0c6ff3a966d9df851"/><file name="View.php" hash="66bc03f32a47a86fbe568ce6c6008b46"/><dir name="Widget"><file name="Link.php" hash="d7c21bf44e303a0a237c7a2a5bcf0c01"/><file name="View.php" hash="61f9cca6dc4ea4b483d10e0c608baa36"/></dir></dir><file name="Rss.php" hash="20f8da38442f262617c97efd00856952"/></dir><dir name="Controller"><dir name="Adminhtml"><file name="Dealoffer.php" hash="d4e8cadfef07cd08b969d60562aeedd2"/></dir><file name="Router.php" hash="40706188a5d5fb6ffb267d90b06594de"/></dir><dir name="Helper"><file name="Data.php" hash="7744b14face0aa30347295ddcb8eaf92"/><dir name="Image"><file name="Abstract.php" hash="c74297849521e7d3d46f3094e36ed41f"/></dir><dir name="Offers"><file name="Image.php" hash="5a1d310769ce1696e2518f0cd34f610d"/></dir><file name="Offers.php" hash="9ab54a3383e738b47e2f381d312676fc"/><file name="Product.php" hash="1c27ca29ed6a98f9660c2d8ad80645e9"/></dir><dir name="Model"><dir name="Adminhtml"><file name="Observer.php" hash="d53e94d7842825dc32c0853f3e0c4ddc"/><dir name="Search"><file name="Offers.php" hash="f16557d702929c3665fedcba449928ea"/></dir></dir><dir name="Offers"><file name="Product.php" hash="edc9aedef4b1ef50974107899531f829"/></dir><file name="Offers.php" hash="8fc8e0b1ca6243fcf5301859b10c6195"/><dir name="Resource"><dir name="Offers"><file name="Collection.php" hash="7738655ef48c04006b42023d59188b9c"/><dir name="Product"><file name="Collection.php" hash="2412c3fcef83ab8009e5c0077c66b8d5"/></dir><file name="Product.php" hash="1ef2c097b643587793d6e5b2d156874c"/></dir><file name="Offers.php" hash="5cd80a77ef0dbd6f2f1bc1217b423af8"/><file name="Setup.php" hash="3ab50d704d95088bdcd0e4682c94efdd"/></dir></dir><dir name="controllers"><dir name="Adminhtml"><dir name="Dealoffer"><dir name="Offers"><dir name="Catalog"><file name="ProductController.php" hash="f1758bd9e20c5cfe419a7e43af7d72ed"/></dir><file name="WidgetController.php" hash="12fafde177acd013e5958933755b41c7"/></dir><file name="OffersController.php" hash="c9fe28d6138086efb4cb0a6b5f16fad9"/></dir></dir><file name="OffersController.php" hash="0b2bde0c75415c4e5427fc1e96293c64"/></dir><dir name="etc"><file name="adminhtml.xml" hash="fa44388738f2dad8a3ae82e838821ec8"/><file name="config.xml" hash="2cbf0c19cd2505449ae6b201c4d3a3f4"/><file name="system.xml" hash="c245517532a7fc443563242259e6c728"/><file name="widget.xml" hash="ef981d63ad91a6570962eaf32e3f7952"/></dir><dir name="sql"><dir name="d4u_dealoffer_setup"><file name="install-0.0.1.php" hash="90abfb8c0ff36a170f344beb767b4f85"/></dir></dir></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="d4u_dealoffer.xml" hash="e256e4d4ca94ac6a9accd4cfd34b883b"/></dir></dir></dir></dir><dir name="frontend"><dir name="default"><dir name="default"><dir name="layout"><file name="d4u_dealoffer.xml" hash="e61029c3d6c6faf1800af2d865e2b0c8"/></dir><dir name="template"><dir name="d4u_dealoffer"><file name="getdailydeal.phtml" hash="a007e666e9e50cf2175471cdceab5a12"/><dir name="offers"><dir name="catalog"><dir name="product"><file name="list.phtml" hash="bebeaa63523252c51b1051d42226c324"/></dir></dir><file name="categoryview.phtml" hash="802c61c79fbaa42c35040a344f3d3de3"/><file name="list.phtml" hash="76a0c908e5350d955b6677c36bca3edd"/><file name="view.phtml" hash="6643e5355500a346c9a95508a7a7caf4"/><dir name="widget"><file name="link.phtml" hash="1ef849109fa867fa73fab3ecf5defd82"/><file name="view.phtml" hash="aacdddb2ac753581dc600e2fb4ad1aee"/></dir></dir><file name="rss.phtml" hash="b9902e5a3ec3fe5d70aefd9f76ab8de4"/></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="D4U_Dealoffer.xml" hash="9c1b8bebeda576eb7289e75e2632fe2b"/></dir></target><target name="magelocale"><dir><dir name="en_US"><file name="D4U_Dealoffer.csv" hash="0b11463e53fd6f3fad412915b38f6f6b"/></dir></dir></target><target name="mageskin"><dir name="frontend"><dir name="base"><dir name="default"><dir name="d4u_dealoffer"><file name="deal.css" hash="4bc80104fe3364fef56306e967182f2a"/></dir></dir></dir></dir></target><target name="mageweb"><dir name="js"><dir name="d4u_dealoffer"><file name="countdown.js" hash="014e66008cb449218647aee330362b59"/></dir></dir></target></contents>
16
+ <compatible/>
17
+ <dependencies><required><php><min>5.1.0</min><max>6.0.0</max></php><package><name>Mage_Core_Modules</name><channel>community</channel><min>1.6.0</min><max>1.7</max></package><extension><name>gd</name><min>2.0</min><max>3.0</max></extension></required></dependencies>
18
+ </package>
skin/frontend/base/default/d4u_dealoffer/deal.css ADDED
@@ -0,0 +1,110 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ .dela_offer{
2
+ float:left;
3
+ width:100%;
4
+ min-height:100%
5
+ }
6
+ div.itemcategory{
7
+ background: none repeat scroll 0 0 #FFFFFF;
8
+ border: 1px solid #ccc;
9
+ border-radius: 3px;
10
+ float: left;
11
+ margin: 0 15px 30px;
12
+ padding: 5px;
13
+ position: relative;
14
+ width: 250px;
15
+ height:310px;
16
+ }
17
+ div.itemcategory:hover {
18
+ background: none repeat scroll 0 0 #f1f1f1;
19
+ border: 1px solid #ccc;
20
+ border-radius: 3px;
21
+ float: left;
22
+ margin: 0 15px 30px;
23
+ padding: 5px;
24
+ position: relative;
25
+ width: 250px;
26
+ height:310px;
27
+ }
28
+ div.item {
29
+ background: none repeat scroll 0 0 #FFFFFF;
30
+ border: 1px solid #ccc;
31
+ border-radius: 3px;
32
+ float: left;
33
+ margin: 0 15px 30px;
34
+ padding: 5px;
35
+ position: relative;
36
+ width: 398px;
37
+ height:385px;
38
+ }
39
+ div.item:hover {
40
+ background: none repeat scroll 0 0 #f1f1f1;
41
+ border: 1px solid #ccc;
42
+ border-radius: 3px;
43
+ float: left;
44
+ margin: 0 15px 30px;
45
+ padding: 5px;
46
+ position: relative;
47
+ width: 398px;
48
+ height:385px;
49
+ }
50
+ .item_center_image{
51
+ height: 250px;
52
+ width: 350px;
53
+ vertical-align: middle;
54
+ display: table-cell;
55
+ margin: auto;
56
+ text-align: center;overflow:hidden;
57
+ }
58
+ .itemcategory_center_image{
59
+ height: 200px;
60
+ width: 200px;
61
+ vertical-align: middle;
62
+ display: table-cell;
63
+ margin: auto;
64
+ text-align: center;overflow:hidden;
65
+ /*height:200px;width:200px;line-height:200px;text-align:center;overflow;hidden;*/
66
+ }
67
+ .bordder_bottom{
68
+ border-bottom: 1px solid #CCCCCC;
69
+ margin: auto;
70
+ width: 85%;
71
+ }
72
+ .title{
73
+ padding-top:5px;
74
+ text-align:center;
75
+ color: #3C3C3C;
76
+ font-size: 16px;
77
+ }
78
+ div.item .product-image {
79
+ display: block;
80
+ margin: 0 0 0px 56px;
81
+ position: relative;
82
+ z-index: 1;
83
+
84
+ }
85
+ div.itemcategory .product-image {
86
+ display: block;
87
+ margin: 0 0 12px 25px;
88
+ position: relative;
89
+ z-index: 1;
90
+
91
+ }
92
+ .button{
93
+ width:24%;
94
+ margin:auto;
95
+ padding-top:10px;}
96
+ .btn-orange{
97
+ background: #FF6600;
98
+ border: 2px solid #EC6723;
99
+ color: #FFFFFF;
100
+ padding: 6px;
101
+ text-decoration: none;
102
+ }
103
+ .time{
104
+ background :none repeat scroll 0 0 #FAE683;
105
+ border:1px solid #FAC903;
106
+ color:#333333;
107
+ font-size:15px;
108
+ padding:0px 5px 0px 5px;
109
+ }
110
+