leonambernini_timerbanner - Version 1.0.1

Version Notes

The first version stable

Download this release

Release Info

Developer Leonam Bernini
Extension leonambernini_timerbanner
Version 1.0.1
Comparing to
See all releases


Version 1.0.1

Files changed (34) hide show
  1. app/code/community/LeonamBernini/TimerBanner/Block/Adminhtml/Grid/Renderer/Image.php +22 -0
  2. app/code/community/LeonamBernini/TimerBanner/Block/Adminhtml/Reports.php +12 -0
  3. app/code/community/LeonamBernini/TimerBanner/Block/Adminhtml/Reports/Banner/Grid.php +73 -0
  4. app/code/community/LeonamBernini/TimerBanner/Block/Adminhtml/Reports/Grid.php +73 -0
  5. app/code/community/LeonamBernini/TimerBanner/Block/Adminhtml/Reportsbanner.php +12 -0
  6. app/code/community/LeonamBernini/TimerBanner/Block/Adminhtml/Timerbanner.php +12 -0
  7. app/code/community/LeonamBernini/TimerBanner/Block/Adminhtml/Timerbanner/Edit.php +25 -0
  8. app/code/community/LeonamBernini/TimerBanner/Block/Adminhtml/Timerbanner/Edit/Form.php +17 -0
  9. app/code/community/LeonamBernini/TimerBanner/Block/Adminhtml/Timerbanner/Edit/Tab/Form.php +182 -0
  10. app/code/community/LeonamBernini/TimerBanner/Block/Adminhtml/Timerbanner/Edit/Tabs.php +24 -0
  11. app/code/community/LeonamBernini/TimerBanner/Block/Adminhtml/Timerbanner/Grid.php +123 -0
  12. app/code/community/LeonamBernini/TimerBanner/Block/Timerbanner.php +65 -0
  13. app/code/community/LeonamBernini/TimerBanner/Helper/Data.php +72 -0
  14. app/code/community/LeonamBernini/TimerBanner/Model/Mysql4/Reports.php +9 -0
  15. app/code/community/LeonamBernini/TimerBanner/Model/Mysql4/Reports/Collection.php +10 -0
  16. app/code/community/LeonamBernini/TimerBanner/Model/Mysql4/Timerbanner.php +9 -0
  17. app/code/community/LeonamBernini/TimerBanner/Model/Mysql4/Timerbanner/Collection.php +10 -0
  18. app/code/community/LeonamBernini/TimerBanner/Model/Reports.php +10 -0
  19. app/code/community/LeonamBernini/TimerBanner/Model/Timerbanner.php +10 -0
  20. app/code/community/LeonamBernini/TimerBanner/controllers/Adminhtml/IndexController.php +236 -0
  21. app/code/community/LeonamBernini/TimerBanner/controllers/Adminhtml/ReportsController.php +40 -0
  22. app/code/community/LeonamBernini/TimerBanner/controllers/IndexController.php +53 -0
  23. app/code/community/LeonamBernini/TimerBanner/etc/adminhtml.xml +51 -0
  24. app/code/community/LeonamBernini/TimerBanner/etc/config.xml +148 -0
  25. app/code/community/LeonamBernini/TimerBanner/etc/system.xml +42 -0
  26. app/code/community/LeonamBernini/TimerBanner/sql/timerbanner_setup/mysql4-install-1.0.1.php +45 -0
  27. app/design/frontend/base/default/layout/leonambernini/timerbanner.xml +17 -0
  28. app/design/frontend/base/default/template/leonambernini/timerbanner/timerbanner.phtml +101 -0
  29. app/etc/modules/LeonamBernini_TimerBanner.xml +15 -0
  30. js/leonam_bernini/timerbanner/timerbanner.js +19 -0
  31. package.xml +18 -0
  32. skin/frontend/base/default/leonam_bernini/timerbanner/css/timerbanner.css +51 -0
  33. skin/frontend/base/default/leonam_bernini/timerbanner/images/Thumbs.db +0 -0
  34. skin/frontend/base/default/leonam_bernini/timerbanner/images/models.jpg +0 -0
app/code/community/LeonamBernini/TimerBanner/Block/Adminhtml/Grid/Renderer/Image.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class LeonamBernini_TimerBanner_Block_Adminhtml_Grid_Renderer_Image extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract
3
+ {
4
+ public function render(Varien_Object $row)
5
+ {
6
+ if($row->getData($this->getColumn()->getIndex())==""){
7
+ return "";
8
+ }
9
+ else{
10
+ $html = '<img ';
11
+ $html .= 'id="img-' . $this->getColumn()->getId() . '" ';
12
+ $html .= 'alt="' . $this->getColumn()->getTitle() . '" ';
13
+ $html .= 'title="' . $this->getColumn()->getTitle() . '" ';
14
+ $html .= 'width="170" ';
15
+ $html .= 'height="50" ';
16
+ $html .= 'src="' . Mage::getBaseUrl("media") . Mage::helper('timerbanner')->getThumbsPath( $row->getData( $this->getColumn()->getIndex() ) ) . '"';
17
+ $html .= 'class="grid-image ' . $this->getColumn()->getInlineCss() . '"/>';
18
+
19
+ return $html;
20
+ }
21
+ }
22
+ }
app/code/community/LeonamBernini/TimerBanner/Block/Adminhtml/Reports.php ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class LeonamBernini_TimerBanner_Block_Adminhtml_Reports extends Mage_Adminhtml_Block_Widget_Grid_Container
3
+ {
4
+ public function __construct()
5
+ {
6
+ $this->_controller = 'adminhtml_reports';
7
+ $this->_blockGroup = 'timerbanner';
8
+ $this->_headerText = Mage::helper('timerbanner')->__('Report');
9
+ parent::__construct();
10
+ $this->removeButton('add');
11
+ }
12
+ }
app/code/community/LeonamBernini/TimerBanner/Block/Adminhtml/Reports/Banner/Grid.php ADDED
@@ -0,0 +1,73 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class LeonamBernini_TimerBanner_Block_Adminhtml_Reports_Banner_Grid extends Mage_Adminhtml_Block_Widget_Grid
4
+ {
5
+ public function __construct()
6
+ {
7
+ parent::__construct();
8
+ $this->setId('reportBannerGrid');
9
+ // This is the primary key of the database
10
+ $this->setDefaultSort('id');
11
+ $this->setDefaultDir('ASC');
12
+ $this->setSaveParametersInSession(true);
13
+ }
14
+
15
+ protected function _prepareCollection()
16
+ {
17
+ $collection = Mage::getModel('timerbanner/reports')->getCollection();
18
+ $collection->getSelect()
19
+ ->reset(Zend_Db_Select::COLUMNS)
20
+ ->joinLeft(array('table_timerbanner' => $collection->getTable('timerbanner/timerbanner')), 'main_table.timerbanner_id = table_timerbanner.id', array('title' => 'table_timerbanner.title', 'url' => 'table_timerbanner.url', 'filename' => 'table_timerbanner.filename'))
21
+ ->columns('table_timerbanner.title AS title')
22
+ ->columns('COUNT(main_table.timerbanner_id) AS total')
23
+ ->group('table_timerbanner.title')
24
+ ->group('table_timerbanner.url')
25
+ ->group('table_timerbanner.filename');
26
+ $this->setCollection($collection);
27
+ return parent::_prepareCollection();
28
+ }
29
+
30
+ protected function _prepareColumns()
31
+ {
32
+ $this->addColumn('filename', array(
33
+ 'header' => Mage::helper('timerbanner')->__('Banner Image'),
34
+ 'align' => 'left',
35
+ 'index' => 'filename',
36
+ 'renderer' => 'timerbanner/adminhtml_grid_renderer_image',
37
+ 'width' => '170px',
38
+ 'align' => 'center',
39
+ 'escape' => true,
40
+ 'sortable' => false,
41
+ 'filter' => false,
42
+ ));
43
+
44
+ $this->addColumn('title', array(
45
+ 'header' => Mage::helper('timerbanner')->__('Title'),
46
+ 'align' =>'left',
47
+ 'index' => 'title',
48
+ 'filter_index' => 'table_timerbanner.title',
49
+ ));
50
+
51
+ $this->addColumn('url', array(
52
+ 'header' => Mage::helper('timerbanner')->__('URL to click'),
53
+ 'align' =>'left',
54
+ 'index' => 'url',
55
+ 'filter_index' => 'table_timerbanner.url',
56
+ ));
57
+
58
+ $this->addColumn('total', array(
59
+ 'header' => Mage::helper('timerbanner')->__('Total of Clicks'),
60
+ 'align' =>'center',
61
+ 'index' => 'total',
62
+ 'filter' => false,
63
+ ));
64
+
65
+ return parent::_prepareColumns();
66
+ }
67
+
68
+ public function getRowUrl($row)
69
+ {
70
+ return '';
71
+ }
72
+
73
+ }
app/code/community/LeonamBernini/TimerBanner/Block/Adminhtml/Reports/Grid.php ADDED
@@ -0,0 +1,73 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class LeonamBernini_TimerBanner_Block_Adminhtml_Reports_Grid extends Mage_Adminhtml_Block_Widget_Grid
4
+ {
5
+ public function __construct()
6
+ {
7
+ parent::__construct();
8
+ $this->setId('reportGrid');
9
+ // This is the primary key of the database
10
+ $this->setDefaultSort('id');
11
+ $this->setDefaultDir('ASC');
12
+ $this->setSaveParametersInSession(true);
13
+ }
14
+
15
+ protected function _prepareCollection()
16
+ {
17
+ $collection = Mage::getModel('timerbanner/reports')->getCollection();
18
+ $collection->getSelect()->joinLeft(array('table_timerbanner' => $collection->getTable('timerbanner/timerbanner')), 'main_table.timerbanner_id = table_timerbanner.id', array('title' => 'table_timerbanner.title', 'filename' => 'table_timerbanner.filename'));
19
+ $this->setCollection($collection);
20
+ return parent::_prepareCollection();
21
+ }
22
+
23
+ protected function _prepareColumns()
24
+ {
25
+ $this->addColumn('id', array(
26
+ 'header' => Mage::helper('timerbanner')->__('ID'),
27
+ 'align' =>'right',
28
+ 'width' => '50px',
29
+ 'index' => 'id',
30
+ 'filter_index' => 'main_table.id',
31
+ ));
32
+
33
+ $this->addColumn('filename', array(
34
+ 'header' => Mage::helper('timerbanner')->__('Banner Image'),
35
+ 'align' => 'left',
36
+ 'index' => 'filename',
37
+ 'renderer' => 'timerbanner/adminhtml_grid_renderer_image',
38
+ 'align' => 'center',
39
+ 'escape' => true,
40
+ 'sortable' => false,
41
+ 'filter' => false,
42
+ ));
43
+
44
+ $this->addColumn('title', array(
45
+ 'header' => Mage::helper('timerbanner')->__('Title'),
46
+ 'align' =>'left',
47
+ 'filter_index' => 'table_timerbanner.title',
48
+ 'index' => 'title',
49
+ ));
50
+
51
+ $this->addColumn('ip', array(
52
+ 'header' => Mage::helper('timerbanner')->__('IP'),
53
+ 'align' =>'left',
54
+ 'filter_index' => 'table_timerbanner.ip',
55
+ 'index' => 'ip',
56
+ ));
57
+
58
+ $this->addColumn('date', array(
59
+ 'header' => Mage::helper('timerbanner')->__('Date of click'),
60
+ 'align' => 'center',
61
+ 'width' => '80px',
62
+ 'index' => 'date',
63
+ 'filter_index' => 'main_table.date',
64
+ ));
65
+
66
+ return parent::_prepareColumns();
67
+ }
68
+
69
+ public function getRowUrl($row) {
70
+ return '';
71
+ }
72
+
73
+ }
app/code/community/LeonamBernini/TimerBanner/Block/Adminhtml/Reportsbanner.php ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class LeonamBernini_TimerBanner_Block_Adminhtml_Reportsbanner extends Mage_Adminhtml_Block_Widget_Grid_Container
3
+ {
4
+ public function __construct()
5
+ {
6
+ $this->_controller = 'adminhtml_reports_banner';
7
+ $this->_blockGroup = 'timerbanner';
8
+ $this->_headerText = Mage::helper('timerbanner')->__('Report - Totals');
9
+ parent::__construct();
10
+ $this->removeButton('add');
11
+ }
12
+ }
app/code/community/LeonamBernini/TimerBanner/Block/Adminhtml/Timerbanner.php ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class LeonamBernini_TimerBanner_Block_Adminhtml_Timerbanner extends Mage_Adminhtml_Block_Widget_Grid_Container
3
+ {
4
+ public function __construct()
5
+ {
6
+ $this->_controller = 'adminhtml_timerbanner';
7
+ $this->_blockGroup = 'timerbanner';
8
+ $this->_headerText = Mage::helper('timerbanner')->__('Item Manager');
9
+ $this->_addButtonLabel = Mage::helper('timerbanner')->__('Add Item');
10
+ parent::__construct();
11
+ }
12
+ }
app/code/community/LeonamBernini/TimerBanner/Block/Adminhtml/Timerbanner/Edit.php ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class LeonamBernini_TimerBanner_Block_Adminhtml_Timerbanner_Edit extends Mage_Adminhtml_Block_Widget_Form_Container
4
+ {
5
+ public function __construct()
6
+ {
7
+ parent::__construct();
8
+
9
+ $this->_objectId = 'id';
10
+ $this->_blockGroup = 'timerbanner';
11
+ $this->_controller = 'adminhtml_timerbanner';
12
+
13
+ $this->_updateButton('save', 'label', Mage::helper('timerbanner')->__('Save Item'));
14
+ $this->_updateButton('delete', 'label', Mage::helper('timerbanner')->__('Delete Item'));
15
+ }
16
+
17
+ public function getHeaderText()
18
+ {
19
+ if( Mage::registry('timerbanner_data') && Mage::registry('timerbanner_data')->getId() ) {
20
+ return Mage::helper('timerbanner')->__("Edit Item '%s'", $this->htmlEscape(Mage::registry('timerbanner_data')->getTitle()));
21
+ } else {
22
+ return Mage::helper('timerbanner')->__('Add Item');
23
+ }
24
+ }
25
+ }
app/code/community/LeonamBernini/TimerBanner/Block/Adminhtml/Timerbanner/Edit/Form.php ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class LeonamBernini_TimerBanner_Block_Adminhtml_Timerbanner_Edit_Form extends Mage_Adminhtml_Block_Widget_Form
4
+ {
5
+ protected function _prepareForm()
6
+ {
7
+ $form = new Varien_Data_Form(array(
8
+ 'id' => 'edit_form',
9
+ 'action' => $this->getUrl('*/*/save', array('id' => $this->getRequest()->getParam('id'))),
10
+ 'method' => 'post',
11
+ 'enctype' => 'multipart/form-data'
12
+ ));
13
+ $form->setUseContainer(true);
14
+ $this->setForm($form);
15
+ return parent::_prepareForm();
16
+ }
17
+ }
app/code/community/LeonamBernini/TimerBanner/Block/Adminhtml/Timerbanner/Edit/Tab/Form.php ADDED
@@ -0,0 +1,182 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class LeonamBernini_TimerBanner_Block_Adminhtml_Timerbanner_Edit_Tab_Form extends Mage_Adminhtml_Block_Widget_Form
4
+ {
5
+ protected function _prepareForm()
6
+ {
7
+ $form = new Varien_Data_Form();
8
+ $this->setForm($form);
9
+ $fieldset = $form->addFieldset('timerbanner_form', array('legend'=>Mage::helper('timerbanner')->__('Item information')));
10
+
11
+ $fieldset->addField('id_show', 'text', array(
12
+ 'label' => Mage::helper('timerbanner')->__('ID Show'),
13
+ 'class' => 'validate-code required-entry',
14
+ 'maxlength' => '20',
15
+ 'required' => true,
16
+ 'name' => 'id_show',
17
+ ));
18
+
19
+ $fieldset->addField('title', 'text', array(
20
+ 'label' => Mage::helper('timerbanner')->__('Title'),
21
+ 'class' => 'required-entry',
22
+ 'required' => true,
23
+ 'name' => 'title',
24
+ ));
25
+
26
+ if (!Mage::app()->isSingleStoreMode()) {
27
+ $fieldset->addField('stores', 'multiselect', array(
28
+ 'name' => 'stores[]',
29
+ 'label' => Mage::helper('timerbanner')->__('Select Store'),
30
+ 'title' => Mage::helper('timerbanner')->__('Select Store'),
31
+ 'required' => true,
32
+ 'values' => Mage::getSingleton('adminhtml/system_store')->getStoreValuesForForm(false, true),
33
+ ));
34
+ }
35
+ else {
36
+ $fieldset->addField('stores', 'hidden', array(
37
+ 'name' => 'stores[]',
38
+ 'value' => Mage::app()->getStore(true)->getId()
39
+ ));
40
+ }
41
+
42
+ $fieldset->addField('filename', 'image', array(
43
+ 'label' => Mage::helper('timerbanner')->__('Image File'),
44
+ 'name' => 'filename',
45
+ ));
46
+
47
+ $fieldset->addField('background_image', 'image', array(
48
+ 'label' => Mage::helper('timerbanner')->__('Background Imagem'),
49
+ 'name' => 'background_image',
50
+ ));
51
+
52
+ $fieldset->addField('background_color', 'text', array(
53
+ 'label' => Mage::helper('timerbanner')->__('Background Color'),
54
+ 'name' => 'background_color',
55
+ ));
56
+
57
+ $fieldset->addField('product_id', 'text', array(
58
+ 'label' => Mage::helper('timerbanner')->__('Product ID'),
59
+ 'required' => true,
60
+ 'name' => 'product_id',
61
+ ));
62
+
63
+ $fieldset->addField('product_name', 'text', array(
64
+ 'label' => Mage::helper('timerbanner')->__('Product Name'),
65
+ 'title' => Mage::helper('timerbanner')->__('If not given, will be shown the name of the registered product'),
66
+ 'name' => 'product_name',
67
+ ));
68
+
69
+ $fieldset->addField('template', 'select', array(
70
+ 'name' => 'template',
71
+ 'label' => Mage::helper('timerbanner')->__('Template'),
72
+ 'required' => true,
73
+ 'note' => Mage::helper('timerbanner')->getExemplesTemplates(),
74
+ 'values' => Mage::helper('timerbanner')->getTemplates(),
75
+ ));
76
+
77
+ $fieldset->addField('width', 'text', array(
78
+ 'label' => Mage::helper('timerbanner')->__('Width'),
79
+ 'required' => true,
80
+ 'name' => 'width',
81
+ ));
82
+
83
+ $fieldset->addField('height', 'text', array(
84
+ 'label' => Mage::helper('timerbanner')->__('Height'),
85
+ 'required' => true,
86
+ 'name' => 'height',
87
+ ));
88
+
89
+ $image_calendar = Mage::getBaseUrl('skin') . 'adminhtml/default/default/images/grid-cal.gif';
90
+
91
+ $fieldset->addField('end_time_promotion', 'date', array(
92
+ 'label' => Mage::helper('timerbanner')->__('End date promotion'),
93
+ 'format' => 'yyyy-MM-dd',
94
+ 'required' => true,
95
+ 'image' => $image_calendar,
96
+ 'name' => 'end_time_promotion',
97
+ 'time' => true
98
+ ));
99
+
100
+ $fieldset->addField('text_time_end', 'text', array(
101
+ 'label' => Mage::helper('timerbanner')->__('Text time end'),
102
+ 'required' => false,
103
+ 'name' => 'text_time_end',
104
+ ));
105
+
106
+ $fieldset->addField('url', 'text', array(
107
+ 'label' => Mage::helper('timerbanner')->__('Url'),
108
+ 'required' => false,
109
+ 'name' => 'url',
110
+ ));
111
+
112
+ $fieldset->addField('target', 'select', array(
113
+ 'label' => Mage::helper('timerbanner')->__('Target'),
114
+ 'name' => 'target',
115
+ 'values' => array(
116
+ array(
117
+ 'value' => '_blank',
118
+ 'label' => Mage::helper('timerbanner')->__('Blank'),
119
+ ),
120
+ array(
121
+ 'value' => '_new',
122
+ 'label' => Mage::helper('timerbanner')->__('New'),
123
+ ),
124
+ array(
125
+ 'value' => '_parent',
126
+ 'label' => Mage::helper('timerbanner')->__('Parent'),
127
+ ),
128
+ array(
129
+ 'value' => '_self',
130
+ 'label' => Mage::helper('timerbanner')->__('Self'),
131
+ ),
132
+ array(
133
+ 'value' => '_top',
134
+ 'label' => Mage::helper('timerbanner')->__('Top'),
135
+ ),
136
+ ),
137
+ ));
138
+
139
+ $fieldset->addField('status', 'select', array(
140
+ 'label' => Mage::helper('timerbanner')->__('Status'),
141
+ 'name' => 'status',
142
+ 'values' => array(
143
+ array(
144
+ 'value' => 1,
145
+ 'label' => Mage::helper('timerbanner')->__('Active'),
146
+ ),
147
+
148
+ array(
149
+ 'value' => 0,
150
+ 'label' => Mage::helper('timerbanner')->__('Inactive'),
151
+ ),
152
+ ),
153
+ ));
154
+
155
+ $fieldset->addField('start_time', 'date', array(
156
+ 'label' => Mage::helper('timerbanner')->__('Start date'),
157
+ 'format' => 'yyyy-MM-dd',
158
+ 'required' => false,
159
+ 'image' => $image_calendar,
160
+ 'name' => 'start_time',
161
+ 'time' => true
162
+ ));
163
+
164
+ $fieldset->addField('end_time', 'date', array(
165
+ 'label' => Mage::helper('timerbanner')->__('End date'),
166
+ 'format' =>'yyyy-MM-dd',
167
+ 'required' => false,
168
+ 'image' => $image_calendar,
169
+ 'name' => 'end_time',
170
+ 'time' => true
171
+ ));
172
+
173
+ if ( Mage::getSingleton('adminhtml/session')->getSlideshowData() )
174
+ {
175
+ $form->setValues(Mage::getSingleton('adminhtml/session')->getTimerbannerData());
176
+ Mage::getSingleton('adminhtml/session')->setTimerbannerData(null);
177
+ } elseif ( Mage::registry('timerbanner_data') ) {
178
+ $form->setValues(Mage::registry('timerbanner_data')->getData());
179
+ }
180
+ return parent::_prepareForm();
181
+ }
182
+ }
app/code/community/LeonamBernini/TimerBanner/Block/Adminhtml/Timerbanner/Edit/Tabs.php ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class LeonamBernini_TimerBanner_Block_Adminhtml_Timerbanner_Edit_Tabs extends Mage_Adminhtml_Block_Widget_Tabs
4
+ {
5
+
6
+ public function __construct()
7
+ {
8
+ parent::__construct();
9
+ $this->setId('timerbanner_tabs');
10
+ $this->setDestElementId('edit_form');
11
+ $this->setTitle(Mage::helper('timerbanner')->__('Banner Information'));
12
+ }
13
+
14
+ protected function _beforeToHtml()
15
+ {
16
+ $this->addTab('form_section', array(
17
+ 'label' => Mage::helper('timerbanner')->__('Item Information'),
18
+ 'title' => Mage::helper('timerbanner')->__('Item Information'),
19
+ 'content' => $this->getLayout()->createBlock('timerbanner/adminhtml_timerbanner_edit_tab_form')->toHtml(),
20
+ ));
21
+
22
+ return parent::_beforeToHtml();
23
+ }
24
+ }
app/code/community/LeonamBernini/TimerBanner/Block/Adminhtml/Timerbanner/Grid.php ADDED
@@ -0,0 +1,123 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class LeonamBernini_TimerBanner_Block_Adminhtml_Timerbanner_Grid extends Mage_Adminhtml_Block_Widget_Grid
4
+ {
5
+ public function __construct()
6
+ {
7
+ parent::__construct();
8
+ $this->setId('TimerBannerGrid');
9
+ // This is the primary key of the database
10
+ $this->setDefaultSort('id');
11
+ $this->setDefaultDir('ASC');
12
+ $this->setSaveParametersInSession(true);
13
+ $this->setUseAjax(true);
14
+ }
15
+
16
+ protected function _prepareCollection()
17
+ {
18
+ $collection = Mage::getModel('timerbanner/timerbanner')->getCollection();
19
+ foreach($collection as $link){
20
+ if($link->getStores() && $link->getStores() != 0 ){
21
+ $link->setStores(explode(',',$link->getStores()));
22
+ }
23
+ else{
24
+ $link->setStores(array('0'));
25
+ }
26
+ }
27
+ $this->setCollection($collection);
28
+ return parent::_prepareCollection();
29
+ }
30
+
31
+ protected function _prepareColumns()
32
+ {
33
+ $this->addColumn('id', array(
34
+ 'header' => Mage::helper('timerbanner')->__('ID'),
35
+ 'align' =>'right',
36
+ 'width' => '50px',
37
+ 'index' => 'id',
38
+ ));
39
+
40
+ $this->addColumn('id_show', array(
41
+ 'header' => Mage::helper('timerbanner')->__('ID Show'),
42
+ 'align' =>'center',
43
+ 'width' => '100px',
44
+ 'index' => 'id_show',
45
+ ));
46
+
47
+ $this->addColumn('filename', array(
48
+ 'header' => Mage::helper('timerbanner')->__('Image'),
49
+ 'align' => 'left',
50
+ 'index' => 'filename',
51
+ 'renderer' => 'timerbanner/adminhtml_grid_renderer_image',
52
+ 'width' => '130px',
53
+ 'align' => 'center',
54
+ 'escape' => true,
55
+ 'sortable' => false,
56
+ 'filter' => false,
57
+ ));
58
+
59
+ $this->addColumn('title', array(
60
+ 'header' => Mage::helper('timerbanner')->__('Title'),
61
+ 'align' =>'left',
62
+ 'index' => 'title',
63
+ ));
64
+
65
+ $this->addColumn('name', array(
66
+ 'header' => Mage::helper('timerbanner')->__('Name'),
67
+ 'align' =>'left',
68
+ 'index' => 'name',
69
+ ));
70
+
71
+ if (!Mage::app()->isSingleStoreMode()) {
72
+ $this->addColumn('stores', array(
73
+ 'header' => Mage::helper('timerbanner')->__('Store'),
74
+ 'index' => 'stores',
75
+ 'type' => 'store',
76
+ 'store_all' => true,
77
+ 'store_view' => true,
78
+ 'sortable' => false,
79
+ 'filter_condition_callback'
80
+ => array($this, '_filterStoreCondition'),
81
+ ));
82
+ }
83
+
84
+ $this->addColumn('start_time', array(
85
+ 'header' => Mage::helper('timerbanner')->__('Start Time'),
86
+ 'align' => 'center',
87
+ 'width' => '80px',
88
+ 'index' => 'start_time',
89
+ ));
90
+
91
+ $this->addColumn('end_time', array(
92
+ 'header' => Mage::helper('timerbanner')->__('End Time'),
93
+ 'align' => 'center',
94
+ 'width' => '80px',
95
+ 'index' => 'end_time',
96
+ ));
97
+
98
+ $this->addColumn('status', array(
99
+ 'header' => Mage::helper('timerbanner')->__('Status'),
100
+ 'align' => 'left',
101
+ 'width' => '80px',
102
+ 'index' => 'status',
103
+ 'type' => 'options',
104
+ 'options' => array(
105
+ 1 => Mage::helper('timerbanner')->__('Active'),
106
+ 0 => Mage::helper('timerbanner')->__('Inactive'),
107
+ ),
108
+ ));
109
+
110
+ return parent::_prepareColumns();
111
+ }
112
+
113
+ public function getRowUrl($row)
114
+ {
115
+ return $this->getUrl('*/*/edit', array('id' => $row->getId()));
116
+ }
117
+
118
+ public function getGridUrl()
119
+ {
120
+ return $this->getUrl('*/*/grid', array('_current'=>true));
121
+ }
122
+
123
+ }
app/code/community/LeonamBernini/TimerBanner/Block/Timerbanner.php ADDED
@@ -0,0 +1,65 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class LeonamBernini_TimerBanner_Block_Timerbanner extends Mage_Core_Block_Template
3
+ {
4
+ public function __construct()
5
+ {
6
+ parent::__construct();
7
+ $this->setTemplate('leonambernini/timerbanner/timerbanner.phtml');
8
+ }
9
+
10
+ public function getDataBanner()
11
+ {
12
+ try{
13
+ $today = date("Y-m-d");
14
+ $banners = Mage::getModel('timerbanner/timerbanner')
15
+ ->getCollection()
16
+ ->addFieldToFilter(
17
+ array('stores', 'stores'),
18
+ array(
19
+ array('finset'=>Mage::app()->getStore()->getId()),
20
+ array('eq'=>'0'))
21
+ )
22
+ ->addFieldToFilter('start_time', array( array('lteq' => $today), array('null' => true)))
23
+ ->addFieldToFilter('end_time', array(array('gteq' => $today), array('null' => true)))
24
+ ->addFieldToFilter('status', array('eq' => '1'))
25
+ ->addFieldToFilter('id_show', array('eq' => $this->getTimerId()) )
26
+ ->setOrder("id","ASC");
27
+
28
+ foreach ( $banners as $banner ){
29
+ $product = Mage::getModel('catalog/product')->load( $banner->getProductId() );
30
+
31
+ if( $product ){
32
+ $res = array(
33
+ 'id' => $banner->getId(),
34
+ 'title' => $banner->getTitle(),
35
+ 'time' => $banner->getEndTimePromotion(),
36
+ 'textTime' => ( ( $banner->getTextTimeEnd() != '' ) ? $banner->getTextTimeEnd() : Mage::helper('timerbanner')->__('FINISHED')),
37
+ 'target' => $product->getTarget(),
38
+ 'product' => array(
39
+ 'id' => $product->getId(),
40
+ 'name' => ( ( $banner->getProductName() != null && $banner->getProductName() != '' ) ? $banner->getProductName() : $product->getName() ),
41
+ 'price' => Mage::helper('core')->currency( $product->getPrice(), true, false ),
42
+ 'sPrice'=> Mage::helper('core')->currency( $product->getFinalPrice(), true, false),
43
+ 'image' => ( ( $banner->getFilename() != '' ) ? Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA) . $banner->getFilename() : Mage::helper('catalog/image')->init($product, 'image') ),
44
+ 'url' => ( ( strpos( $product->getProductUrl(), 'http://' ) > -1 || strpos( $product->getProductUrl(), 'https://' ) > -1 ) ? $product->getProductUrl() : 'http://' . $product->getProductUrl() ),
45
+ ),
46
+ 'layout' => array(
47
+ 'template' => $banner->getTemplate(),
48
+ 'backgroundImage' => ( ( $banner->getBackgroundImage() != '' ) ? "background-image: url('" . Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA) . $banner->getBackgroundImage() . "');" : '' ),
49
+ 'backgroundColor' => ( ( $banner->getBackgroundColor() != '' ) ? 'background-color: ' . $banner->getBackgroundColor() . ';' : '' ),
50
+ 'width' => ( ( $banner->getWidth() > 0 ) ? 'width: ' . $banner->getWidth() .'px;' : '' ),
51
+ 'height' => ( ( $banner->getHeight() > 0 ) ? 'height: ' . $banner->getHeight() .'px;' : '' ),
52
+ ),
53
+ );
54
+ break;
55
+ }else{
56
+ $res = Mage::helper('timerbanner')->__('Product not found');
57
+ }
58
+ }
59
+ return $res;
60
+
61
+ } catch (Exception $ex) {
62
+ return Mage::helper('timerbanner')->__('The TimerBanner not configured.');
63
+ }
64
+ }
65
+ }
app/code/community/LeonamBernini/TimerBanner/Helper/Data.php ADDED
@@ -0,0 +1,72 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class LeonamBernini_TimerBanner_Helper_Data extends Mage_Core_Helper_Abstract
4
+ {
5
+
6
+ private $bannerPath;
7
+ private $bannerThumbsPath;
8
+
9
+ public function __construct() {
10
+ $this->bannerPath = '/leonam_bernini/timerbanner/';
11
+ $this->bannerThumbsPath = '/leonam_bernini/timerbanner/thumbs/';
12
+ }
13
+
14
+ public function getBannerPath()
15
+ {
16
+ return $this->bannerPath;
17
+ }
18
+ public function getThumbsPath($path = null)
19
+ {
20
+ if( $path == null ){
21
+ return $this->bannerThumbsPath;
22
+ }else{
23
+ return str_replace( '/timerbanner/', '/timerbanner/thumbs/', $path);
24
+ }
25
+ }
26
+
27
+ public function resizeImg($fileName, $width, $height = '')
28
+ {
29
+ //$fileName = "slideshow\slides\\".$fileName;
30
+ $folderURL = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA);
31
+ $imageURL = $folderURL . $fileName;
32
+
33
+ $basePath = Mage::getBaseDir(Mage_Core_Model_Store::URL_TYPE_MEDIA) . $this->bannerPath. $fileName;
34
+
35
+ $newPath = Mage::getBaseDir(Mage_Core_Model_Store::URL_TYPE_MEDIA) . $this->bannerThumbsPath . $fileName;
36
+ //if width empty then return original size image's URL
37
+ if ($width != '') {
38
+ //if image has already resized then just return URL
39
+ if (file_exists($basePath) && is_file($basePath) && !file_exists($newPath)) {
40
+ $imageObj = new Varien_Image($basePath);
41
+ $imageObj->constrainOnly(TRUE);
42
+ $imageObj->keepAspectRatio(FALSE);
43
+ $imageObj->keepFrame(FALSE);
44
+ $imageObj->resize($width, $height);
45
+ $imageObj->save($newPath);
46
+ }
47
+ $resizedURL = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA) . "resized" . DS . $fileName;
48
+ } else {
49
+ $resizedURL = $imageURL;
50
+ }
51
+ return $resizedURL;
52
+ }
53
+
54
+
55
+ public function getTemplates()
56
+ {
57
+ return array(
58
+ '1' => $this->__('model') . ' 1',
59
+ '2' => $this->__('model') . ' 2',
60
+ '3' => $this->__('model') . ' 3',
61
+ '4' => $this->__('model') . ' 4',
62
+ '5' => $this->__('model') . ' 5',
63
+ );
64
+ }
65
+
66
+ public function getExemplesTemplates()
67
+ {
68
+ $exemples = '<img src="' . Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_SKIN) . 'frontend/base/default/leonam_bernini/timerbanner/images/models.jpg' . '" title="' . $this->__('models exemples') . '" alt="' . $this->__('models exemples') . '" style="margin-top: 10px;">';
69
+ return $exemples;
70
+ }
71
+
72
+ }
app/code/community/LeonamBernini/TimerBanner/Model/Mysql4/Reports.php ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class LeonamBernini_TimerBanner_Model_Mysql4_Reports extends Mage_Core_Model_Mysql4_Abstract
4
+ {
5
+ public function _construct()
6
+ {
7
+ $this->_init('timerbanner/reports', 'id');
8
+ }
9
+ }
app/code/community/LeonamBernini/TimerBanner/Model/Mysql4/Reports/Collection.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class LeonamBernini_TimerBanner_Model_Mysql4_Reports_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
4
+ {
5
+ public function _construct()
6
+ {
7
+ //parent::_construct();
8
+ $this->_init('timerbanner/reports');
9
+ }
10
+ }
app/code/community/LeonamBernini/TimerBanner/Model/Mysql4/Timerbanner.php ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class LeonamBernini_TimerBanner_Model_Mysql4_Timerbanner extends Mage_Core_Model_Mysql4_Abstract
4
+ {
5
+ public function _construct()
6
+ {
7
+ $this->_init('timerbanner/timerbanner', 'id');
8
+ }
9
+ }
app/code/community/LeonamBernini/TimerBanner/Model/Mysql4/Timerbanner/Collection.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class LeonamBernini_TimerBanner_Model_Mysql4_Timerbanner_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
4
+ {
5
+ public function _construct()
6
+ {
7
+ //parent::_construct();
8
+ $this->_init('timerbanner/timerbanner');
9
+ }
10
+ }
app/code/community/LeonamBernini/TimerBanner/Model/Reports.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class LeonamBernini_TimerBanner_Model_Reports extends Mage_Core_Model_Abstract
4
+ {
5
+ public function _construct()
6
+ {
7
+ parent::_construct();
8
+ $this->_init('timerbanner/reports');
9
+ }
10
+ }
app/code/community/LeonamBernini/TimerBanner/Model/Timerbanner.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class LeonamBernini_TimerBanner_Model_Timerbanner extends Mage_Core_Model_Abstract
4
+ {
5
+ public function _construct()
6
+ {
7
+ parent::_construct();
8
+ $this->_init('timerbanner/timerbanner');
9
+ }
10
+ }
app/code/community/LeonamBernini/TimerBanner/controllers/Adminhtml/IndexController.php ADDED
@@ -0,0 +1,236 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class LeonamBernini_TimerBanner_Adminhtml_IndexController extends Mage_Adminhtml_Controller_Action
4
+ {
5
+ protected function _initAction()
6
+ {
7
+ $this->loadLayout()
8
+ ->_setActiveMenu('timerbanner/manage_timerbanner')
9
+ ->_addBreadcrumb(Mage::helper('adminhtml')->__('Items Manager'), Mage::helper('adminhtml')->__('Item Manager'));
10
+ return $this;
11
+ }
12
+
13
+ public function indexAction() {
14
+ $this->_initAction();
15
+ $this->_addContent($this->getLayout()->createBlock('timerbanner/adminhtml_timerbanner'));
16
+ $this->renderLayout();
17
+ }
18
+
19
+ public function newAction(){
20
+ $this->_forward('edit');
21
+ }
22
+
23
+ public function editAction(){
24
+ $id = $this->getRequest()->getParam('id');
25
+ $model = Mage::getModel('timerbanner/timerbanner')->load($id);
26
+
27
+ if ( $model->getId() || $id == 0 ) {
28
+
29
+ Mage::register('timerbanner_data', $model);
30
+
31
+ $this->loadLayout();
32
+ $this->_setActiveMenu('timerbanner/manage_timerbanner');
33
+
34
+ $this->_addBreadcrumb(Mage::helper('adminhtml')->__('Item Manager'), Mage::helper('adminhtml')->__('Item Manager'));
35
+ $this->_addBreadcrumb(Mage::helper('adminhtml')->__('Item News'), Mage::helper('adminhtml')->__('Item News'));
36
+
37
+ $this->getLayout()->getBlock('head')->setCanLoadExtJs(true);
38
+
39
+ $this->_addContent($this->getLayout()->createBlock('timerbanner/adminhtml_timerbanner_edit'))
40
+ ->_addLeft($this->getLayout()->createBlock('timerbanner/adminhtml_timerbanner_edit_tabs'));
41
+
42
+ $this->renderLayout();
43
+ } else {
44
+ Mage::getSingleton('adminhtml/session')->addError(Mage::helper('timerbanner')->__('Item does not exist'));
45
+ $this->_redirect('*/*/');
46
+ }
47
+ }
48
+
49
+ public function uploadImage($file, $name)
50
+ {
51
+ try {
52
+ $bannerPath = Mage::helper('timerbanner')->getBannerPath();
53
+
54
+ /* Starting upload */
55
+ $uploader = new Varien_File_Uploader($name);
56
+
57
+ // Any extention would work
58
+ $uploader->setAllowedExtensions(array('jpg','jpeg','gif','png'));
59
+ $uploader->setAllowRenameFiles(true);
60
+
61
+ // Set the file upload mode
62
+ // false -> get the file directly in the specified folder
63
+ // true -> get the file in the product like folders
64
+ // (file.jpg will go in something like /media/f/i/file.jpg)
65
+ $uploader->setFilesDispersion(false);
66
+
67
+ // We set media as the upload dir
68
+ $path = Mage::getBaseDir('media') . DS . $bannerPath ;
69
+
70
+ $extension = pathinfo($file['name'], PATHINFO_EXTENSION);
71
+ $result = $uploader->save($path, md5( $imageName . date('d.m.Y_H.m.i') ) . '.' . $extension );
72
+
73
+ //For thumb
74
+ Mage::helper('timerbanner')->resizeImg($result['file'], 100, 75);
75
+ //For thumb ends
76
+
77
+ $test = $bannerPath.$result['file'];
78
+
79
+
80
+ return $test;
81
+
82
+ } catch (Exception $e) {
83
+ return $file['name'];
84
+ }
85
+ }
86
+
87
+ public function saveAction()
88
+ {
89
+ if ( $this->getRequest()->getPost() ) {
90
+ try {
91
+ $postData = $this->getRequest()->getPost();
92
+ $timerbannerModel = Mage::getModel('timerbanner/timerbanner');
93
+
94
+ if(isset($_FILES['filename']['name']) && $_FILES['filename']['name'] != '') {
95
+ $postData['filename'] = $this->uploadImage($_FILES['filename'], 'filename');
96
+ if(isset($postData['filename']['delete']) && $postData['filename']['delete'] == 1)
97
+ {
98
+ unlink(Mage_Core_Model_Store::URL_TYPE_MEDIA. DS .$postData['filename']['value']);
99
+ unlink(Mage_Core_Model_Store::URL_TYPE_MEDIA. DS . Mage::helper('timerbanner')->getThumbsPath($postData['filename']['value']));
100
+ }
101
+ }else {
102
+ if(isset($postData['filename']['delete']) && $postData['filename']['delete'] == 1){
103
+ unlink(Mage_Core_Model_Store::URL_TYPE_MEDIA. DS .$postData['filename']['value']);
104
+ unlink(Mage_Core_Model_Store::URL_TYPE_MEDIA. DS .Mage::helper('timerbanner')->getThumbsPath($postData['filename']['value']));
105
+ $postData['filename'] = '';
106
+ }else{
107
+ unset($postData['filename']);
108
+ }
109
+ }
110
+
111
+ if(isset($_FILES['background_image']['name']) && $_FILES['background_image']['name'] != '') {
112
+ $postData['background_image'] = $this->uploadImage($_FILES['background_image'], 'background_image');
113
+ if(isset($postData['background_image']['delete']) && $postData['background_image']['delete'] == 1)
114
+ {
115
+ unlink(Mage_Core_Model_Store::URL_TYPE_MEDIA. DS .$postData['background_image']['value']);
116
+ unlink(Mage_Core_Model_Store::URL_TYPE_MEDIA. DS . Mage::helper('timerbanner')->getThumbsPath($postData['background_image']['value']));
117
+ }
118
+ }else {
119
+ if(isset($postData['background_image']['delete']) && $postData['background_image']['delete'] == 1){
120
+ unlink(Mage_Core_Model_Store::URL_TYPE_MEDIA. DS .$postData['background_image']['value']);
121
+ unlink(Mage_Core_Model_Store::URL_TYPE_MEDIA. DS .Mage::helper('timerbanner')->getThumbsPath($postData['background_image']['value']));
122
+ $postData['background_image'] = '';
123
+ }else{
124
+ unset($postData['background_image']);
125
+ }
126
+ }
127
+
128
+ if(isset($postData['stores'])) {
129
+ if(in_array('0',$postData['stores'])){
130
+ $postData['stores'] = '0';
131
+ }else{
132
+ $postData['stores'] = implode(",", $postData['stores']);
133
+ }
134
+ }
135
+
136
+ if($postData['stores'] == "")
137
+ {
138
+ $postData['stores'] = '0';
139
+ }
140
+
141
+ $times = explode(" ", now());
142
+ if ( $postData['start_time'] ) {
143
+ $postData['start_time'] = $postData['start_time']. " " . $times[1];
144
+ }else{
145
+ $postData['start_time'] = null;
146
+ }
147
+ if ( $postData['end_time'] ) {
148
+ $postData['end_time'] = $postData['end_time'] . " " . $times[1];
149
+ }else{
150
+ $postData['end_time'] = null;
151
+ }
152
+
153
+ $timerbannerModel->setId($this->getRequest()->getParam('id'))
154
+ ->setIdShow($postData['id_show'])
155
+ ->setTitle($postData['title'])
156
+ ->setFilename($postData['filename'])
157
+ ->setBackgroundImage($postData['background_image'])
158
+ ->setBackgroundColor($postData['background_color'])
159
+ ->setProductId($postData['product_id'])
160
+ ->setProductName($postData['product_name'])
161
+ ->setTemplate($postData['template'])
162
+ ->setWidth($postData['width'])
163
+ ->setHeight($postData['height'])
164
+ ->setEndTimePromotion($postData['end_time_promotion'])
165
+ ->setTextTimeEnd($postData['text_time_end'])
166
+ ->setUrl($postData['url'])
167
+ ->setTarget($postData['target'])
168
+ ->setStatus($postData['status'])
169
+ ->setStores($postData['stores'])
170
+ ->setStartTime($postData['start_time'])
171
+ ->setEndTime($postData['end_time'])
172
+ ->save();
173
+
174
+ Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('adminhtml')->__('Item was successfully saved'));
175
+ Mage::getSingleton('adminhtml/session')->setSlideshowData(false);
176
+
177
+ $this->_redirect('*/*/');
178
+ return;
179
+ } catch (Exception $e) {
180
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
181
+ Mage::getSingleton('adminhtml/session')->setSlideshowData($this->getRequest()->getPost());
182
+ $this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id')));
183
+ return;
184
+ }
185
+ }
186
+ $this->_redirect('*/*/');
187
+ }
188
+
189
+ public function deleteAction()
190
+ {
191
+ $id = $this->getRequest()->getParam('id');
192
+ if( $id > 0 ) {
193
+ try {
194
+ $model = Mage::getModel('timerbanner/timerbanner')->load($id);
195
+ $image = $model->getFilename();
196
+ $background = $model->getBackgroundImage();
197
+ $model->delete();
198
+
199
+ if( $image != '' && $image != null && file_exists( Mage_Core_Model_Store::URL_TYPE_MEDIA .$image ) ){
200
+ unlink( Mage_Core_Model_Store::URL_TYPE_MEDIA .$image );
201
+
202
+ if( file_exists( Mage_Core_Model_Store::URL_TYPE_MEDIA . Mage::helper('timerbanner')->getThumbsPath( $image ) ) ){
203
+ unlink( Mage_Core_Model_Store::URL_TYPE_MEDIA . Mage::helper('timerbanner')->getThumbsPath( $image ) );
204
+ }
205
+ }
206
+ if( $background != '' && $background != null && file_exists( Mage_Core_Model_Store::URL_TYPE_MEDIA .$background ) ){
207
+ unlink( Mage_Core_Model_Store::URL_TYPE_MEDIA .$background );
208
+
209
+ if( file_exists( Mage_Core_Model_Store::URL_TYPE_MEDIA . Mage::helper('timerbanner')->getThumbsPath( $background ) ) ){
210
+ unlink( Mage_Core_Model_Store::URL_TYPE_MEDIA . Mage::helper('timerbanner')->getThumbsPath( $background ) );
211
+ }
212
+ }
213
+
214
+ Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('adminhtml')->__('Item was successfully deleted'));
215
+ $this->_redirect('*/*/');
216
+ } catch (Exception $e) {
217
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
218
+ $this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id')));
219
+ }
220
+ }
221
+ $this->_redirect('*/*/');
222
+ }
223
+
224
+ /**
225
+ * Product grid for AJAX request.
226
+ * Sort and filter result for example.
227
+ */
228
+ public function gridAction()
229
+ {
230
+ $this->loadLayout();
231
+ $this->getResponse()->setBody(
232
+ $this->getLayout()->createBlock('timerbanner/adminhtml_timerbanner_grid')->toHtml()
233
+ );
234
+ }
235
+ }
236
+ ?>
app/code/community/LeonamBernini/TimerBanner/controllers/Adminhtml/ReportsController.php ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class LeonamBernini_TimerBanner_Adminhtml_ReportsController extends Mage_Adminhtml_Controller_Action
4
+ {
5
+ protected function _initAction()
6
+ {
7
+ $this->loadLayout()
8
+ ->_setActiveMenu('timerbanner/manage_timerbanner')
9
+ ->_addBreadcrumb(Mage::helper('adminhtml')->__('Items Manager'), Mage::helper('adminhtml')->__('Item Manager'));
10
+ return $this;
11
+ }
12
+
13
+ public function indexAction() {
14
+ $this->_initAction();
15
+ $this->_addContent($this->getLayout()->createBlock('timerbanner/adminhtml_reports'));
16
+ $this->renderLayout();
17
+ }
18
+
19
+ public function bannerAction() {
20
+ $this->_initAction();
21
+ $block = $this->getLayout()->createBlock('timerbanner/adminhtml_reportsbanner','reports_banner');
22
+ $block->append( $this->getLayout()->createBlock('timerbanner/adminhtml_reports_banner_grid') );
23
+ $this->_addContent( $block );
24
+ $this->renderLayout();
25
+ }
26
+
27
+
28
+ /**
29
+ * Product grid for AJAX request.
30
+ * Sort and filter result for example.
31
+ */
32
+ public function gridAction()
33
+ {
34
+ $this->loadLayout();
35
+ $this->getResponse()->setBody(
36
+ $this->getLayout()->createBlock('timerbanner/adminhtml_reports_grid')->toHtml()
37
+ );
38
+ }
39
+ }
40
+ ?>
app/code/community/LeonamBernini/TimerBanner/controllers/IndexController.php ADDED
@@ -0,0 +1,53 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class LeonamBernini_TimerBanner_IndexController extends Mage_Adminhtml_Controller_Action
4
+ {
5
+ protected function _initAction()
6
+ {
7
+ $this->loadLayout()
8
+ ->_setActiveMenu('timerbanner/manage_timerbanner')
9
+ ->_addBreadcrumb(Mage::helper('adminhtml')->__('Items Manager'), Mage::helper('adminhtml')->__('Item Manager'));
10
+ return $this;
11
+ }
12
+
13
+ public function preDispatch() {}
14
+
15
+ public function clickAction() {
16
+ $cookie = Mage::getSingleton('core/cookie');
17
+ $id = $this->getRequest()->getParam('id_banner');
18
+ $userCode = $this->getUserCode($id);
19
+ $date_click = now();
20
+ $report = Mage::getModel('timerbanner/reports');
21
+ if ( $id ) {
22
+ if ( !$cookie->get('timerbanner_user_code_click' . $id ) ) {
23
+ $cookie->set( 'timerbanner_user_code_click' . $id, $userCode );
24
+ $report->setData( 'timerbanner_id', $id )
25
+ ->setData( 'ip', $this->getIP() )
26
+ ->setData( 'date', $date_click );
27
+ try {
28
+ $report->save();
29
+ } catch (Exception $e) { }
30
+ }
31
+ }
32
+ }
33
+
34
+ private function getIP(){
35
+ $ipAddress = null;
36
+ if (isset($_SERVER["HTTP_X_FORWARDED_FOR"])) {
37
+ $ipAddress = $_SERVER["HTTP_X_FORWARDED_FOR"];
38
+ } elseif (isset($_SERVER["HTTP_CLIENT_IP"])) {
39
+ $ipAddress = $_SERVER["HTTP_CLIENT_IP"];
40
+ } elseif (isset($_SERVER["REMOTE_ADDR"])) {
41
+ $ipAddress = $_SERVER["REMOTE_ADDR"];
42
+ }
43
+ return $ipAddress;
44
+ }
45
+
46
+
47
+ private function getUserCode($id) {
48
+ $cookiefrontend = $_COOKIE['frontend'];
49
+ $usercode = $this->getIP() . $cookiefrontend . $id;
50
+ return md5($usercode);
51
+ }
52
+ }
53
+ ?>
app/code/community/LeonamBernini/TimerBanner/etc/adminhtml.xml ADDED
@@ -0,0 +1,51 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <config>
3
+ <acl>
4
+ <resources>
5
+ <admin>
6
+ <children>
7
+ <system>
8
+ <children>
9
+ <config>
10
+ <children>
11
+ <timerbanner translate="title" module="timerbanner">
12
+ <title>TimerBanner Setting - NEX</title>
13
+ </timerbanner>
14
+ </children>
15
+ </config>
16
+ </children>
17
+ </system>
18
+ </children>
19
+ </admin>
20
+ </resources>
21
+ </acl>
22
+ <menu>
23
+ <timerbanner module="timerbanner" translate="title">
24
+ <title>TimerBanner (nex)</title>
25
+ <sort_order>99</sort_order>
26
+ <children>
27
+ <items module="timerbanner">
28
+ <title>Manage Items</title>
29
+ <sort_order>0</sort_order>
30
+ <action>timerbanner/adminhtml_index</action>
31
+ </items>
32
+ <reports module="timerbanner" translate="title">
33
+ <title>reports</title>
34
+ <sort_order>1</sort_order>
35
+ <children>
36
+ <reposts_all module="timerbanner" translate="title">
37
+ <title>All Banners</title>
38
+ <sort_order>0</sort_order>
39
+ <action>timerbanner/adminhtml_reports</action>
40
+ </reposts_all>
41
+ <reposts_banner module="timerbanner" translate="title">
42
+ <title>Per Banner</title>
43
+ <sort_order>1</sort_order>
44
+ <action>timerbanner/adminhtml_reports/banner</action>
45
+ </reposts_banner>
46
+ </children>
47
+ </reports>
48
+ </children>
49
+ </timerbanner>
50
+ </menu>
51
+ </config>
app/code/community/LeonamBernini/TimerBanner/etc/config.xml ADDED
@@ -0,0 +1,148 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <LeonamBernini_TimerBanner>
5
+ <version>1.0.1</version>
6
+ </LeonamBernini_TimerBanner>
7
+ </modules>
8
+
9
+ <frontend>
10
+ <routers>
11
+ <timerbanner>
12
+ <use>standard</use>
13
+ <args>
14
+ <module>LeonamBernini_TimerBanner</module>
15
+ <frontName>timerbanner</frontName>
16
+ </args>
17
+ </timerbanner>
18
+ </routers>
19
+ <translate>
20
+ <modules>
21
+ <LeonamBernini_TimerBanner>
22
+ <files>
23
+ <default>LeonamBernini_TimerBanner.csv</default>
24
+ </files>
25
+ </LeonamBernini_TimerBanner>
26
+ </modules>
27
+ </translate>
28
+ <layout>
29
+ <updates>
30
+ <timerbanner>
31
+ <file>leonambernini/timerbanner.xml</file>
32
+ </timerbanner>
33
+ </updates>
34
+ </layout>
35
+ </frontend>
36
+
37
+ <adminhtml>
38
+ <layout>
39
+ <updates>
40
+ <leonambernini>
41
+ <file>timerbanner/timerbanner.xml</file>
42
+ </leonambernini>
43
+ </updates>
44
+ </layout>
45
+
46
+ <translate>
47
+ <modules>
48
+ <LeonamBernini_TimerBanner>
49
+ <files>
50
+ <default>LeonamBernini_TimerBanner.csv</default>
51
+ </files>
52
+ </LeonamBernini_TimerBanner>
53
+ </modules>
54
+ </translate>
55
+
56
+ <acl>
57
+ <resources>
58
+ <admin>
59
+ <children>
60
+ <system>
61
+ <children>
62
+ <config>
63
+ <children>
64
+ <timerbanner>
65
+ <title>TimerBanner Settings - NEX</title>
66
+ </timerbanner>
67
+ </children>
68
+ </config>
69
+ </children>
70
+ </system>
71
+ </children>
72
+ </admin>
73
+ </resources>
74
+ </acl>
75
+
76
+ </adminhtml>
77
+
78
+ <global>
79
+ <models>
80
+ <timerbanner>
81
+ <class>LeonamBernini_TimerBanner_Model</class>
82
+ <resourceModel>timerbanner_mysql4</resourceModel>
83
+ </timerbanner>
84
+ <timerbanner_mysql4>
85
+ <class>LeonamBernini_TimerBanner_Model_Mysql4</class>
86
+ <entities>
87
+ <timerbanner>
88
+ <table>lb_timerbanner</table>
89
+ </timerbanner>
90
+ <reports>
91
+ <table>lb_timerbanner_report</table>
92
+ </reports>
93
+ </entities>
94
+ </timerbanner_mysql4>
95
+ </models>
96
+ <resources>
97
+ <timerbanner_setup>
98
+ <setup>
99
+ <module>LeonamBernini_TimerBanner</module>
100
+ </setup>
101
+ <connection>
102
+ <use>core_setup</use>
103
+ </connection>
104
+ </timerbanner_setup>
105
+ <timerbanner_write>
106
+ <connection>
107
+ <use>core_write</use>
108
+ </connection>
109
+ </timerbanner_write>
110
+ <timerbanner_read>
111
+ <connection>
112
+ <use>core_read</use>
113
+ </connection>
114
+ </timerbanner_read>
115
+ </resources>
116
+ <blocks>
117
+ <timerbanner>
118
+ <class>LeonamBernini_TimerBanner_Block</class>
119
+ </timerbanner>
120
+ </blocks>
121
+ <helpers>
122
+ <timerbanner>
123
+ <class>LeonamBernini_TimerBanner_Helper</class>
124
+ </timerbanner>
125
+ </helpers>
126
+ </global>
127
+
128
+ <default>
129
+ <timerbanner>
130
+ <general>
131
+ <enable>0</enable>
132
+ </general>
133
+ </timerbanner>
134
+ </default>
135
+
136
+ <admin>
137
+ <routers>
138
+ <timerbanner>
139
+ <use>admin</use>
140
+ <args>
141
+ <module>LeonamBernini_TimerBanner</module>
142
+ <frontName>timerbanner</frontName>
143
+ </args>
144
+ </timerbanner>
145
+ </routers>
146
+ </admin>
147
+
148
+ </config>
app/code/community/LeonamBernini/TimerBanner/etc/system.xml ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <config>
3
+ <tabs>
4
+ <leonambernini translate="label">
5
+ <label>Leonam Bernini</label>
6
+ <sort_order>100</sort_order>
7
+ </leonambernini>
8
+ </tabs>
9
+ <sections>
10
+ <timerbanner translate="label" module="timerbanner">
11
+ <label>Timer Banner</label>
12
+ <class>timerbanner-section</class>
13
+ <tab>leonambernini</tab>
14
+ <frontend_type>text</frontend_type>
15
+ <sort_order>9999</sort_order>
16
+ <show_in_default>1</show_in_default>
17
+ <show_in_website>1</show_in_website>
18
+ <show_in_store>1</show_in_store>
19
+ <groups>
20
+ <general translate="label">
21
+ <label>General</label>
22
+ <frontend_type>text</frontend_type>
23
+ <sort_order>1</sort_order>
24
+ <show_in_default>1</show_in_default>
25
+ <show_in_website>1</show_in_website>
26
+ <show_in_store>1</show_in_store>
27
+ <fields>
28
+ <enable translate="label comment">
29
+ <label>Enable</label>
30
+ <frontend_type>select</frontend_type>
31
+ <source_model>adminhtml/system_config_source_yesno</source_model>
32
+ <sort_order>1</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
+ </enable>
37
+ </fields>
38
+ </general>
39
+ </groups>
40
+ </timerbanner>
41
+ </sections>
42
+ </config>
app/code/community/LeonamBernini/TimerBanner/sql/timerbanner_setup/mysql4-install-1.0.1.php ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ $installer = $this;
4
+
5
+ $installer->startSetup();
6
+
7
+ $installer->run("
8
+
9
+ -- DROP TABLE IF EXISTS {$this->getTable('lb_timerbanner')};
10
+ CREATE TABLE {$this->getTable('lb_timerbanner')} (
11
+ `id` int(11) unsigned NOT NULL auto_increment,
12
+ `id_show` varchar(20) NOT NULL,
13
+ `title` varchar(255) NOT NULL default '',
14
+ `filename` varchar(255) NOT NULL default '',
15
+ `background_image` varchar(255) NOT NULL default '',
16
+ `background_color` varchar(10) NULL,
17
+ `product_id` int(11) unsigned NOT NULL,
18
+ `product_name` varchar(255) NULL default NULL,
19
+ `template` int(11) unsigned NOT NULL default '1',
20
+ `width` int(11) unsigned NOT NULL default '0',
21
+ `height` int(11) unsigned NOT NULL default '0',
22
+ `end_time_promotion` datetime NULL default NULL,
23
+ `text_time_end` varchar(30) NULL default NULL,
24
+ `url` varchar(500) NOT NULL default '',
25
+ `target` varchar(255) NOT NULL default '',
26
+ `status` smallint(6) NOT NULL default '0',
27
+ `stores` VARCHAR( 255 ) NOT NULL DEFAULT '0',
28
+ `start_time` datetime NULL default NULL,
29
+ `end_time` datetime NULL default NULL,
30
+ PRIMARY KEY (`id`)
31
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
32
+
33
+ -- DROP TABLE IF EXISTS {$this->getTable('lb_timerbanner_report')};
34
+ CREATE TABLE {$this->getTable('lb_timerbanner_report')} (
35
+ `id` int(11) unsigned NOT NULL auto_increment,
36
+ `timerbanner_id` int(11) unsigned NOT NULL,
37
+ `ip` varchar(20) NULL default NULL,
38
+ `date` datetime NULL default NULL,
39
+ FOREIGN KEY (`timerbanner_id`) REFERENCES {$this->getTable('lb_timerbanner')} (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
40
+ PRIMARY KEY (`id`)
41
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
42
+
43
+ ");
44
+
45
+ $installer->endSetup();
app/design/frontend/base/default/layout/leonambernini/timerbanner.xml ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <layout version="0.1.0">
3
+ <default>
4
+ <reference name="head">
5
+ <action method="addCss"><stylesheet>leonam_bernini/timerbanner/css/timerbanner.css</stylesheet></action>
6
+ </reference>
7
+ <reference name="header">
8
+ <block type="timerbanner/timerbanner" name="leonambernini.timerbanner" as="leonambernini.timerbanner" />
9
+ </reference>
10
+ <reference name="catalog.topnav">
11
+ <block type="timerbanner/timerbanner" name="leonambernini.timerbanner" as="leonambernini.timerbanner" />
12
+ </reference>
13
+ <reference name="page">
14
+ <block type="timerbanner/timerbanner" name="leonambernini.timerbanner" as="leonambernini.timerbanner" />
15
+ </reference>
16
+ </default>
17
+ </layout>
app/design/frontend/base/default/template/leonambernini/timerbanner/timerbanner.phtml ADDED
@@ -0,0 +1,101 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php if( Mage::getStoreConfig("timerbanner/general/enable") ): ?>
2
+
3
+ <script src="<?php echo $this->getJsUrl('leonam_bernini/timerbanner/timerbanner.js'); ?>" type="text/javascript"></script>
4
+
5
+ <?php $data = $this->getDataBanner(); ?>
6
+ <?php
7
+ $title = '<h2 class="timer-banner-title">' . $data['title'] . '</h2>';
8
+ $image = '<span class="timer-banner-image"><img src="' . $data['product']['image'] . '" alt="' . $data['product']['name'] . '" title="' . $data['product']['name'] . '"></span>';
9
+ $name = '<b class="timer-banner-name">' . $data['product']['name'] . '</b>';
10
+ $prices = '<span class="timer-banner-value">'.
11
+ ' <span class="tbv-price">' . $this->__('of:') . ' <b>' . $data['product']['price'] . '</b></span>' .
12
+ ' <span class="tbv-final-price">' . $this->__('for:') . ' <b>' . $data['product']['sPrice'] . '</b></span>' .
13
+ '</span>';
14
+ $timer = '<span class="timer-banner-box-time">'
15
+ . ' <span id="timer-banner-time-' . $data['product']['id'] . '" class="timer-banner-time">' .
16
+ ' <span id="timer-banner-days-' . $data['product']['id'] . '"></span>' .
17
+ ' <span id="timer-banner-hours-' . $data['product']['id'] . '" class="separator"></span>' .
18
+ ' <span id="timer-banner-minute-' . $data['product']['id'] . '" class="separator"></span>' .
19
+ ' <span id="timer-banner-seconds-' . $data['product']['id'] . '" class="separator"></span>' .
20
+ ' </span>' .
21
+ ' <span class="timer-banner-legend">' . $this->__('D : H : M : S') . '</span>' .
22
+ '</span>';
23
+ $button = '<a href="' . $data['product']['url'] . '" title="' . $data['product']['name'] . '" class="timer-banner-url transition" data-id="' . $data['product']['id'] . '" onclick="saveTimerBannerClick(this)">' . $this->__("BUY") . '</a>';
24
+ ?>
25
+
26
+ <span id="timer-banner-<?php echo $data['product']['id'] ?>" class="timer-banner" style="<?php echo $data['layout']['backgroundColor'] . $data['layout']['backgroundImage'] . $data['layout']['width'] . $data['layout']['height']; ?>">
27
+ <span class="border timer-banner-template-<?php echo $data['layout']['template'] ?>">
28
+
29
+ <?php
30
+ if( $data['layout']['template'] == 1 ):
31
+ echo $title . $image . $name . $prices . $timer . $button;
32
+ elseif( $data['layout']['template'] == 2 ):
33
+ echo $title . $name . $image . $prices . $timer . $button;
34
+ elseif( $data['layout']['template'] == 3 ):
35
+ echo $title . $name . '<span class="timer-banner-box-image-value">' . $image . $prices . '</span>' . $timer . $button;
36
+ elseif( $data['layout']['template'] == 4 ):
37
+ echo $title . $image . '<span class="timer-banner-box-name-timer">' . $name . $timer . '</span>' . '<span class="timer-banner-box-prices-button">' . $prices . $button . '</span>';
38
+ elseif( $data['layout']['template'] == 5 ):
39
+ echo $title . $image . '<span class="timer-banner-box-name-prices">' . $name . $prices . '</span>' . $timer . $button;
40
+ endif;
41
+ ?>
42
+
43
+ </span>
44
+ </span>
45
+ <?php
46
+ $dateTime = explode( ' ', $data['time'] );
47
+ $date = explode( '-', $dateTime[0] );
48
+ $time = explode( ':', $dateTime[1] );
49
+ $day = $date[2];
50
+ $month = $date[1];
51
+ $year = $date[0];
52
+
53
+ $hours = $time[0];
54
+ $minute = $time[1];
55
+ $second = $time[2];
56
+ ?>
57
+ <script language="Javascript">
58
+
59
+ var URL_TIMER_BANNER = '<?php echo $this->getUrl('timerbanner/index/click'); ?>';
60
+
61
+ function atualizaContador<?php echo $data['product']['id'] ?>()
62
+ {
63
+ var YY = <?php echo $year; ?>;
64
+ var MM = <?php echo $month; ?>;
65
+ var DD = <?php echo $day; ?>;
66
+ var HH = <?php echo $hours; ?>;
67
+ var MI = <?php echo $minute; ?>;
68
+ var SS = <?php echo $second; ?>;
69
+
70
+ var hoje = new Date();
71
+ var futuro = new Date(YY,MM-1,DD,HH,MI,SS);
72
+ var ss = parseInt((futuro - hoje) / 1000);
73
+ var mm = parseInt(ss / 60);
74
+ var hh = parseInt(mm / 60);
75
+ var dd = parseInt(hh / 24);
76
+
77
+ ss = ss - (mm * 60);
78
+ mm = mm - (hh * 60);
79
+ hh = hh - (dd * 24);
80
+
81
+ dd = (dd && dd > 1) ? dd : (dd==1 ? '01' : '00');
82
+ hh = ((hh.toString()).length) ? ((hh.toString()).length == 2) ? hh : '0'+hh : '00';
83
+ mm = ((mm.toString()).length) ? ((mm.toString()).length == 2) ? mm : '0'+mm : '00';
84
+ ss = ((ss.toString()).length) ? ((ss.toString()).length == 2) ? ss: '0'+ss : '00';
85
+
86
+ if (dd+hh+mm+ss > 0)
87
+ {
88
+ document.getElementById('timer-banner-days-<?php echo $data['product']['id'] ?>').innerHTML = dd;
89
+ document.getElementById('timer-banner-hours-<?php echo $data['product']['id'] ?>').innerHTML = hh;
90
+ document.getElementById('timer-banner-minute-<?php echo $data['product']['id'] ?>').innerHTML = mm;
91
+ document.getElementById('timer-banner-seconds-<?php echo $data['product']['id'] ?>').innerHTML = ss;
92
+ setTimeout(atualizaContador<?php echo $data['product']['id'] ?>,1000);
93
+ }else{
94
+ document.getElementById('timer-banner-time-<?php echo $data['product']['id'] ?>').innerHTML = '<?php echo $data['textTime'] ?>';
95
+ setTimeout(atualizaContador<?php echo $data['product']['id'] ?>,1000);
96
+ }
97
+ }
98
+ setTimeout("atualizaContador<?php echo $data['product']['id'] ?>()",1000);
99
+ </script>
100
+
101
+ <?php endif; ?>
app/etc/modules/LeonamBernini_TimerBanner.xml ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ * @category LeonamBernini
4
+ * @package LeonamBernini_TimerBanner
5
+ * @copyright Copyright (c) 2014 Leonam Bernini. (http://www.agencianex.com.br)
6
+ */
7
+ -->
8
+ <config>
9
+ <modules>
10
+ <LeonamBernini_TimerBanner>
11
+ <active>true</active>
12
+ <codePool>community</codePool>
13
+ </LeonamBernini_TimerBanner>
14
+ </modules>
15
+ </config>
js/leonam_bernini/timerbanner/timerbanner.js ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ function saveTimerBannerClick(obj){
2
+ var bannerId = obj.getAttribute('data-id');
3
+ var data = "id_banner=" + bannerId;
4
+ var xmlhttp;
5
+ try{
6
+ xmlhttp = new XMLHttpRequest();
7
+ }catch (e){
8
+ try{
9
+ xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
10
+ }catch (e) {
11
+ try{
12
+ xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
13
+ }catch (e){}
14
+ }
15
+ }
16
+ xmlhttp.open("POST", URL_TIMER_BANNER, true);
17
+ xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
18
+ xmlhttp.send(data);
19
+ }
package.xml ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>leonambernini_timerbanner</name>
4
+ <version>1.0.1</version>
5
+ <stability>stable</stability>
6
+ <license uri="http://opensource.org/licenses/academic.php">Academic Free License 3.0</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>Timer Banner extension for magento</summary>
10
+ <description>Banner timer, the best way to create promotions in style "collective sale"</description>
11
+ <notes>The first version stable</notes>
12
+ <authors><author><name>Leonam Bernini</name><user>leonambernini</user><email>leonam.b@hotmail.com</email></author></authors>
13
+ <date>2014-11-03</date>
14
+ <time>22:12:20</time>
15
+ <contents><target name="magecommunity"><dir name="LeonamBernini"><dir name="TimerBanner"><dir name="Block"><dir name="Adminhtml"><dir name="Grid"><dir name="Renderer"><file name="Image.php" hash="612973c83674c68826e7317f758eac36"/></dir></dir><dir name="Reports"><dir name="Banner"><file name="Grid.php" hash="d4dd846cbb6da659b249eb1164fc3242"/></dir><file name="Grid.php" hash="1f115fdc4eff6555f30a1350a599b5e2"/></dir><file name="Reports.php" hash="f4720010f46da27312e1d9bbeb168f9b"/><file name="Reportsbanner.php" hash="497dc089d893c2c817329657ff18f7d5"/><dir name="Timerbanner"><dir name="Edit"><file name="Form.php" hash="657e1759d1efae789033cdce0f10e5fc"/><dir name="Tab"><file name="Form.php" hash="222d3a1c11bd99903bc9326cf12be22a"/></dir><file name="Tabs.php" hash="dc7e47e5fe404edd9e7f243dc0e91cb2"/></dir><file name="Edit.php" hash="2882a10c7930ce7d19b960e3e92a5bfb"/><file name="Grid.php" hash="fcc681128264df97b5e21ab34ec64a7a"/></dir><file name="Timerbanner.php" hash="a685c3da0b57e0899f48e0c327e0bf35"/></dir><file name="Timerbanner.php" hash="68337c420ce56148d531c2e0aad2dcff"/></dir><dir name="Helper"><file name="Data.php" hash="77f8ba443fdff0d1e68ef577f188582e"/></dir><dir name="Model"><dir name="Mysql4"><dir name="Reports"><file name="Collection.php" hash="4da08e88c6b7cead57cecf5251b12666"/></dir><file name="Reports.php" hash="f68861614f51ffc94aae7eed8a915606"/><dir name="Timerbanner"><file name="Collection.php" hash="9cb587d066135ed0926fe962ff7b8c9e"/></dir><file name="Timerbanner.php" hash="f6ae79832282aa3de8f5b02d18c0cda5"/></dir><file name="Reports.php" hash="93aa3262b07c94941ea71fe29378ae82"/><file name="Timerbanner.php" hash="c0463128785838fb43cac087c767c73f"/></dir><dir name="controllers"><dir name="Adminhtml"><file name="IndexController.php" hash="eec1db266890a526de72551642b99fe6"/><file name="ReportsController.php" hash="2e603c2e03a30a5e4a26948b5d6a98a3"/></dir><file name="IndexController.php" hash="e8c493de04c43c293d1730bc7c3b7aee"/></dir><dir name="etc"><file name="adminhtml.xml" hash="aab2914f2fd9c18dcfeef3e94b66afc6"/><file name="config.xml" hash="5e4a61fd3f1511779589a93a791ad75c"/><file name="system.xml" hash="c56de37aee478fdce41885f09a7a9c06"/></dir><dir name="sql"><dir name="timerbanner_setup"><file name="mysql4-install-1.0.1.php" hash="0a21e4f826c6bf67a4bc612b47ad60c2"/></dir></dir></dir></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><dir name="leonambernini"><file name="timerbanner.xml" hash="db036821f7e6876e4f8505df43327b93"/></dir></dir><dir name="template"><dir name="leonambernini"><dir name="timerbanner"><file name="timerbanner.phtml" hash="919f95c66ea965a21c6cf245d7c9437b"/></dir></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="LeonamBernini_TimerBanner.xml" hash="6a6b1abd6ede1c3b67ec58ff044b99ab"/></dir></target><target name="mageskin"><dir name="frontend"><dir name="base"><dir name="default"><dir name="leonam_bernini"><dir name="timerbanner"><dir name="css"><file name="timerbanner.css" hash="8fc1d9b42d2d459ffe15cfe4f584d6ef"/></dir><dir name="images"><file name="Thumbs.db" hash="7247497b51a39932756b9de76d69134c"/><file name="models.jpg" hash="52dcc2540d89836cd1a9ff731e8cd012"/></dir></dir></dir></dir></dir></dir></target><target name="mage"><dir name="js"><dir name="leonam_bernini"><dir name="timerbanner"><file name="timerbanner.js" hash="17a6bbdab52ba8bdba121d7135333abb"/></dir></dir></dir></target></contents>
16
+ <compatible/>
17
+ <dependencies><required><php><min>5.1.0</min><max>6.0.0</max></php></required></dependencies>
18
+ </package>
skin/frontend/base/default/leonam_bernini/timerbanner/css/timerbanner.css ADDED
@@ -0,0 +1,51 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ To change this license header, choose License Headers in Project Properties.
3
+ To change this template file, choose Tools | Templates
4
+ and open the template in the editor.
5
+ */
6
+ /*
7
+ Created on : 24/10/2014, 21:35:27
8
+ Author : Leonam
9
+ */
10
+ .transition{ -webkit-transition: 150ms all linear 0s; -moz-transition: 150ms all linear 0s; -o-transition: 150ms all linear 0s; transition: 150ms all linear 0s; }
11
+ .inline-block,
12
+ .inline-block li{ display: inline-block; vertical-align: top; /* Setting a common base */ margin: 0; padding: 0; /* For IE 7 */ zoom: 1; *display: inline; }
13
+
14
+ .timer-banner{ background-position: center; background-repeat: no-repeat; box-shadow: 0 0 15px 0 #000; border-radius: 4px; display: block; margin: 10px auto; }
15
+ .timer-banner .border{ display: block; padding: 10px; position: relative; text-align: left; }
16
+ .timer-banner-title{ color: #060606; display: block; font: 700 16px/20px 'Tahoma', sans-serif; padding: 10px 0; }
17
+ .timer-banner-image img{ display: block; margin: 0 auto; max-width: 100%; }
18
+ .timer-banner-name{ color: #006AA9; display: block; font: 700 14px/18px 'Tahoma', sans-serif; padding: 10px 0; text-align: center; }
19
+ .timer-banner-value .tbv-price{ color: #060606; display: block; font: 400 12px/15px 'Tahoma', sans-serif; }
20
+ .timer-banner-value .tbv-price b{ color: #060606; font-weight: 700; text-decoration: line-through; }
21
+ .timer-banner-value .tbv-final-price{ color: #060606; display: block; font: 400 15px/22px 'Tahoma', sans-serif; }
22
+ .timer-banner-value .tbv-final-price b{ color: #006AA9; font-size: 20px; font-weight: 700; }
23
+ .timer-banner-box-time{ display: block; padding: 5px; }
24
+ .timer-banner-time{ background-color: rgb(255,255,255); background-color: rgba(255,255,255,.5); border-radius: 5px; color: #006AA9; display: block; font: 400 24px/21px 'Tahoma', sans-serif; padding: 20px 10px; text-align: center; }
25
+ .timer-banner-time > span.separator:before{ content: ":"; margin-right: 5px; }
26
+ .timer-banner-legend{ color: #060606; display: block; font: 300 11px/15px 'Tahoma', sans-serif; text-align: center; text-transform: uppercase; }
27
+ .timer-banner-url{ background-color: #006AA9; border-radius: 4px; color: #fff; display: block; font: 400 15px/18px 'Tahoma', sans-serif; margin: 15px auto; max-width: 200px; padding: 6px; text-align: center; text-decoration: none; }
28
+ .timer-banner-url:hover{ background-color: #fff; color: #006AA9; text-decoration: none; }
29
+
30
+
31
+ .timer-banner-template-1 .timer-banner-image,
32
+ .timer-banner-template-2 .timer-banner-image{ display: block; margin-bottom: 15px; }
33
+ .timer-banner-template-1 .timer-banner-value,
34
+ .timer-banner-template-2 .timer-banner-value{ display: block; padding: 10px 0; text-align: right; }
35
+
36
+ .timer-banner-template-3 .timer-banner-box-image-value{ display: block; padding: 10px 0; }
37
+ .timer-banner-template-3 .timer-banner-image{ display: inline-block; vertical-align: top; /* Setting a common base */ margin: 0; padding: 0; /* For IE 7 */ zoom: 1; *display: inline; padding-right: 1%; width: 60%; }
38
+ .timer-banner-template-3 .timer-banner-value{ display: inline-block; vertical-align: top; /* Setting a common base */ margin: 0; padding: 0; /* For IE 7 */ zoom: 1; *display: inline; padding-top: 20%; text-align: right; width: 38%; }
39
+
40
+ .timer-banner-template-4 .timer-banner-box-name-timer{ display: inline-block; vertical-align: top; /* Setting a common base */ margin: 0; padding: 0; /* For IE 7 */ zoom: 1; *display: inline; padding-left: 2%; width: 40%; }
41
+ .timer-banner-template-4 .timer-banner-box-prices-button{ bottom: 10px; position: absolute; right: 15px; }
42
+ .timer-banner-template-4 .timer-banner-image{ display: inline-block; vertical-align: top; /* Setting a common base */ margin: 0; padding: 0; /* For IE 7 */ zoom: 1; *display: inline; width: 25%; }
43
+ .timer-banner-template-4 .timer-banner-value{ text-align: right; }
44
+ .timer-banner-template-4 .timer-banner-name{ padding-top: 0; text-align: left; }
45
+
46
+ .timer-banner-template-5 .timer-banner-box-name-prices{ display: inline-block; vertical-align: top; /* Setting a common base */ margin: 0; padding: 0; /* For IE 7 */ zoom: 1; *display: inline; padding-left: 2%; width: 40%; }
47
+ .timer-banner-template-5 .timer-banner-image{ display: inline-block; vertical-align: top; /* Setting a common base */ margin: 0; padding: 0; /* For IE 7 */ zoom: 1; *display: inline; width: 25%; }
48
+ .timer-banner-template-5 .timer-banner-name{ padding-top: 0; text-align: left; }
49
+ .timer-banner-template-5 .timer-banner-box-time{ position: absolute; right: 15px; top: 15px; }
50
+ .timer-banner-template-5 .timer-banner-url{ bottom: 10px; position: absolute; right: 15px; }
51
+
skin/frontend/base/default/leonam_bernini/timerbanner/images/Thumbs.db ADDED
Binary file
skin/frontend/base/default/leonam_bernini/timerbanner/images/models.jpg ADDED
Binary file