Ad_Manager - Version 1.0.0

Version Notes

This is fully tested on our servers and works well

Download this release

Release Info

Developer Rohit Goel
Extension Ad_Manager
Version 1.0.0
Comparing to
See all releases


Version 1.0.0

Files changed (51) hide show
  1. app/code/local/Ghrix/Bannercampaign/Block/Adminhtml/Bannercampaign.php +17 -0
  2. app/code/local/Ghrix/Bannercampaign/Block/Adminhtml/Bannercampaign/Edit.php +44 -0
  3. app/code/local/Ghrix/Bannercampaign/Block/Adminhtml/Bannercampaign/Edit/Form.php +17 -0
  4. app/code/local/Ghrix/Bannercampaign/Block/Adminhtml/Bannercampaign/Edit/Tab/Form.php +97 -0
  5. app/code/local/Ghrix/Bannercampaign/Block/Adminhtml/Bannercampaign/Edit/Tabs.php +21 -0
  6. app/code/local/Ghrix/Bannercampaign/Block/Adminhtml/Bannercampaign/Grid.php +140 -0
  7. app/code/local/Ghrix/Bannercampaign/Block/Adminhtml/Bannercampaignbackend.php +5 -0
  8. app/code/local/Ghrix/Bannercampaign/Block/Index.php +8 -0
  9. app/code/local/Ghrix/Bannercampaign/Helper/Data.php +5 -0
  10. app/code/local/Ghrix/Bannercampaign/Model/Bannercampaign.php +12 -0
  11. app/code/local/Ghrix/Bannercampaign/Model/Mysql4/Bannercampaign.php +8 -0
  12. app/code/local/Ghrix/Bannercampaign/Model/Mysql4/Bannercampaign/Collection.php +12 -0
  13. app/code/local/Ghrix/Bannercampaign/controllers/Adminhtml/BannercampaignController.php +210 -0
  14. app/code/local/Ghrix/Bannercampaign/controllers/Adminhtml/BannercampaignbackendController.php +10 -0
  15. app/code/local/Ghrix/Bannercampaign/controllers/IndexController.php +22 -0
  16. app/code/local/Ghrix/Bannercampaign/etc/config.xml +134 -0
  17. app/code/local/Ghrix/Bannercampaign/sql/bannercampaign_setup/mysql4-install-0.1.0.php +26 -0
  18. app/code/local/Ghrix/Campaign/Block/Adminhtml/Campaign.php +17 -0
  19. app/code/local/Ghrix/Campaign/Block/Adminhtml/Campaign/Edit.php +44 -0
  20. app/code/local/Ghrix/Campaign/Block/Adminhtml/Campaign/Edit/Form.php +17 -0
  21. app/code/local/Ghrix/Campaign/Block/Adminhtml/Campaign/Edit/Tab/Form.php +100 -0
  22. app/code/local/Ghrix/Campaign/Block/Adminhtml/Campaign/Edit/Tabs.php +21 -0
  23. app/code/local/Ghrix/Campaign/Block/Adminhtml/Campaign/Grid.php +155 -0
  24. app/code/local/Ghrix/Campaign/Block/Adminhtml/Campaign/Grid/Column/Renderer/Image.php +57 -0
  25. app/code/local/Ghrix/Campaign/Block/Index.php +8 -0
  26. app/code/local/Ghrix/Campaign/Helper/Data.php +89 -0
  27. app/code/local/Ghrix/Campaign/Model/Campaign.php +12 -0
  28. app/code/local/Ghrix/Campaign/Model/Mysql4/Campaign.php +8 -0
  29. app/code/local/Ghrix/Campaign/Model/Mysql4/Campaign/Collection.php +12 -0
  30. app/code/local/Ghrix/Campaign/controllers/Adminhtml/CampaignController.php +211 -0
  31. app/code/local/Ghrix/Campaign/controllers/IndexController.php +76 -0
  32. app/code/local/Ghrix/Campaign/etc/config.xml +126 -0
  33. app/code/local/Ghrix/Campaign/sql/campaign_setup/mysql4-install-0.1.0.php +27 -0
  34. app/code/local/Ghrix/Campaignmanager/Block/Adminhtml/Campaignmanager.php +17 -0
  35. app/code/local/Ghrix/Campaignmanager/Block/Adminhtml/Campaignmanager/Edit.php +44 -0
  36. app/code/local/Ghrix/Campaignmanager/Block/Adminhtml/Campaignmanager/Edit/Form.php +17 -0
  37. app/code/local/Ghrix/Campaignmanager/Block/Adminhtml/Campaignmanager/Edit/Tab/Form.php +97 -0
  38. app/code/local/Ghrix/Campaignmanager/Block/Adminhtml/Campaignmanager/Edit/Tabs.php +21 -0
  39. app/code/local/Ghrix/Campaignmanager/Block/Adminhtml/Campaignmanager/Grid.php +140 -0
  40. app/code/local/Ghrix/Campaignmanager/Block/Adminhtml/Campaignmanagerbackend.php +5 -0
  41. app/code/local/Ghrix/Campaignmanager/Block/Index.php +8 -0
  42. app/code/local/Ghrix/Campaignmanager/Helper/Data.php +5 -0
  43. app/code/local/Ghrix/Campaignmanager/Model/Campaignmanager.php +12 -0
  44. app/code/local/Ghrix/Campaignmanager/Model/Mysql4/Campaignmanager.php +8 -0
  45. app/code/local/Ghrix/Campaignmanager/Model/Mysql4/Campaignmanager/Collection.php +12 -0
  46. app/code/local/Ghrix/Campaignmanager/controllers/Adminhtml/CampaignmanagerController.php +210 -0
  47. app/code/local/Ghrix/Campaignmanager/controllers/Adminhtml/CampaignmanagerbackendController.php +10 -0
  48. app/code/local/Ghrix/Campaignmanager/controllers/IndexController.php +22 -0
  49. app/code/local/Ghrix/Campaignmanager/etc/config.xml +134 -0
  50. app/design/frontend/base/default/layout/campaign.xml +12 -0
  51. package.xml +27 -0
app/code/local/Ghrix/Bannercampaign/Block/Adminhtml/Bannercampaign.php ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+
4
+ class Ghrix_Bannercampaign_Block_Adminhtml_Bannercampaign extends Mage_Adminhtml_Block_Widget_Grid_Container{
5
+
6
+ public function __construct()
7
+ {
8
+
9
+ $this->_controller = "adminhtml_bannercampaign";
10
+ $this->_blockGroup = "bannercampaign";
11
+ $this->_headerText = Mage::helper("bannercampaign")->__("Bannercampaign Manager");
12
+ $this->_addButtonLabel = Mage::helper("bannercampaign")->__("Add New Item");
13
+ parent::__construct();
14
+
15
+ }
16
+
17
+ }
app/code/local/Ghrix/Bannercampaign/Block/Adminhtml/Bannercampaign/Edit.php ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Ghrix_Bannercampaign_Block_Adminhtml_Bannercampaign_Edit extends Mage_Adminhtml_Block_Widget_Form_Container
4
+ {
5
+ public function __construct()
6
+ {
7
+
8
+ parent::__construct();
9
+ $this->_objectId = "id";
10
+ $this->_blockGroup = "bannercampaign";
11
+ $this->_controller = "adminhtml_bannercampaign";
12
+ $this->_updateButton("save", "label", Mage::helper("bannercampaign")->__("Save Item"));
13
+ $this->_updateButton("delete", "label", Mage::helper("bannercampaign")->__("Delete Item"));
14
+
15
+ $this->_addButton("saveandcontinue", array(
16
+ "label" => Mage::helper("bannercampaign")->__("Save And Continue Edit"),
17
+ "onclick" => "saveAndContinueEdit()",
18
+ "class" => "save",
19
+ ), -100);
20
+
21
+
22
+
23
+ $this->_formScripts[] = "
24
+
25
+ function saveAndContinueEdit(){
26
+ editForm.submit($('edit_form').action+'back/edit/');
27
+ }
28
+ ";
29
+ }
30
+
31
+ public function getHeaderText()
32
+ {
33
+ if( Mage::registry("bannercampaign_data") && Mage::registry("bannercampaign_data")->getId() ){
34
+
35
+ return Mage::helper("bannercampaign")->__("Edit Item '%s'", $this->htmlEscape(Mage::registry("bannercampaign_data")->getId()));
36
+
37
+ }
38
+ else{
39
+
40
+ return Mage::helper("bannercampaign")->__("Add Item");
41
+
42
+ }
43
+ }
44
+ }
app/code/local/Ghrix/Bannercampaign/Block/Adminhtml/Bannercampaign/Edit/Form.php ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Ghrix_Bannercampaign_Block_Adminhtml_Bannercampaign_Edit_Form extends Mage_Adminhtml_Block_Widget_Form
3
+ {
4
+ protected function _prepareForm()
5
+ {
6
+ $form = new Varien_Data_Form(array(
7
+ "id" => "edit_form",
8
+ "action" => $this->getUrl("*/*/save", array("id" => $this->getRequest()->getParam("id"))),
9
+ "method" => "post",
10
+ "enctype" =>"multipart/form-data",
11
+ )
12
+ );
13
+ $form->setUseContainer(true);
14
+ $this->setForm($form);
15
+ return parent::_prepareForm();
16
+ }
17
+ }
app/code/local/Ghrix/Bannercampaign/Block/Adminhtml/Bannercampaign/Edit/Tab/Form.php ADDED
@@ -0,0 +1,97 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Ghrix_Bannercampaign_Block_Adminhtml_Bannercampaign_Edit_Tab_Form extends Mage_Adminhtml_Block_Widget_Form
3
+ {
4
+ protected function _prepareForm()
5
+ {
6
+
7
+ $form = new Varien_Data_Form();
8
+ $this->setForm($form);
9
+ $fieldset = $form->addFieldset("bannercampaign_form", array("legend"=>Mage::helper("bannercampaign")->__("Item information")));
10
+
11
+
12
+ $fieldset->addField("id", "text", array(
13
+ "label" => Mage::helper("bannercampaign")->__("id"),
14
+ "class" => "required-entry",
15
+ "required" => true,
16
+ "name" => "id",
17
+ ));
18
+
19
+ $fieldset->addField("title", "text", array(
20
+ "label" => Mage::helper("bannercampaign")->__("title"),
21
+ "name" => "title",
22
+ ));
23
+
24
+ $fieldset->addField("content", "text", array(
25
+ "label" => Mage::helper("bannercampaign")->__("content"),
26
+ "name" => "content",
27
+ ));
28
+
29
+ $fieldset->addField("positon", "text", array(
30
+ "label" => Mage::helper("bannercampaign")->__("positon"),
31
+ "name" => "positon",
32
+ ));
33
+
34
+ $fieldset->addField('photo', 'image', array(
35
+ 'label' => Mage::helper('bannercampaign')->__('photo'),
36
+ 'name' => 'photo',
37
+ 'note' => '(*.jpg, *.png, *.gif)',
38
+ ));
39
+ $fieldset->addField("width", "text", array(
40
+ "label" => Mage::helper("bannercampaign")->__("width"),
41
+ "name" => "width",
42
+ ));
43
+
44
+ $fieldset->addField("height", "text", array(
45
+ "label" => Mage::helper("bannercampaign")->__("height"),
46
+ "name" => "height",
47
+ ));
48
+
49
+ $fieldset->addField('country', 'select', array(
50
+ 'label' => Mage::helper('bannercampaign')->__('country'),
51
+ 'values' => Ghrix_Bannercampaign_Block_Adminhtml_Bannercampaign_Grid::getValueArray7(),
52
+ 'name' => 'country',
53
+ ));
54
+ $dateFormatIso = Mage::app()->getLocale()->getDateTimeFormat(
55
+ Mage_Core_Model_Locale::FORMAT_TYPE_SHORT
56
+ );
57
+
58
+ $fieldset->addField('startfrom', 'date', array(
59
+ 'label' => Mage::helper('bannercampaign')->__('startfrom'),
60
+ 'name' => 'startfrom',
61
+ 'time' => true,
62
+ 'image' => $this->getSkinUrl('images/grid-cal.gif'),
63
+ 'format' => $dateFormatIso
64
+ ));
65
+ $dateFormatIso = Mage::app()->getLocale()->getDateTimeFormat(
66
+ Mage_Core_Model_Locale::FORMAT_TYPE_SHORT
67
+ );
68
+
69
+ $fieldset->addField('startto', 'date', array(
70
+ 'label' => Mage::helper('bannercampaign')->__('startto'),
71
+ 'name' => 'startto',
72
+ 'time' => true,
73
+ 'image' => $this->getSkinUrl('images/grid-cal.gif'),
74
+ 'format' => $dateFormatIso
75
+ ));
76
+ $fieldset->addField('whichday', 'multiselect', array(
77
+ 'label' => Mage::helper('bannercampaign')->__('whichday'),
78
+ 'values' => Ghrix_Bannercampaign_Block_Adminhtml_Bannercampaign_Grid::getValueArray10(),
79
+ 'name' => 'whichday',
80
+ ));
81
+ $fieldset->addField("enable", "text", array(
82
+ "label" => Mage::helper("bannercampaign")->__("enable"),
83
+ "name" => "enable",
84
+ ));
85
+
86
+
87
+ if (Mage::getSingleton("adminhtml/session")->getBannercampaignData())
88
+ {
89
+ $form->setValues(Mage::getSingleton("adminhtml/session")->getBannercampaignData());
90
+ Mage::getSingleton("adminhtml/session")->setBannercampaignData(null);
91
+ }
92
+ elseif(Mage::registry("bannercampaign_data")) {
93
+ $form->setValues(Mage::registry("bannercampaign_data")->getData());
94
+ }
95
+ return parent::_prepareForm();
96
+ }
97
+ }
app/code/local/Ghrix/Bannercampaign/Block/Adminhtml/Bannercampaign/Edit/Tabs.php ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Ghrix_Bannercampaign_Block_Adminhtml_Bannercampaign_Edit_Tabs extends Mage_Adminhtml_Block_Widget_Tabs
3
+ {
4
+ public function __construct()
5
+ {
6
+ parent::__construct();
7
+ $this->setId("bannercampaign_tabs");
8
+ $this->setDestElementId("edit_form");
9
+ $this->setTitle(Mage::helper("bannercampaign")->__("Item Information"));
10
+ }
11
+ protected function _beforeToHtml()
12
+ {
13
+ $this->addTab("form_section", array(
14
+ "label" => Mage::helper("bannercampaign")->__("Item Information"),
15
+ "title" => Mage::helper("bannercampaign")->__("Item Information"),
16
+ "content" => $this->getLayout()->createBlock("bannercampaign/adminhtml_bannercampaign_edit_tab_form")->toHtml(),
17
+ ));
18
+ return parent::_beforeToHtml();
19
+ }
20
+
21
+ }
app/code/local/Ghrix/Bannercampaign/Block/Adminhtml/Bannercampaign/Grid.php ADDED
@@ -0,0 +1,140 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Ghrix_Bannercampaign_Block_Adminhtml_Bannercampaign_Grid extends Mage_Adminhtml_Block_Widget_Grid
4
+ {
5
+
6
+ public function __construct()
7
+ {
8
+ parent::__construct();
9
+ $this->setId("bannercampaignGrid");
10
+ $this->setDefaultSort("id");
11
+ $this->setDefaultDir("DESC");
12
+ $this->setSaveParametersInSession(true);
13
+ }
14
+
15
+ protected function _prepareCollection()
16
+ {
17
+ $collection = Mage::getModel("bannercampaign/bannercampaign")->getCollection();
18
+ $this->setCollection($collection);
19
+ return parent::_prepareCollection();
20
+ }
21
+ protected function _prepareColumns()
22
+ {
23
+ $this->addColumn("id", array(
24
+ "header" => Mage::helper("bannercampaign")->__("ID"),
25
+ "align" =>"right",
26
+ "width" => "50px",
27
+ "type" => "number",
28
+ "index" => "id",
29
+ ));
30
+
31
+ $this->addColumn("title", array(
32
+ "header" => Mage::helper("bannercampaign")->__("title"),
33
+ "index" => "title",
34
+ ));
35
+ $this->addColumn("content", array(
36
+ "header" => Mage::helper("bannercampaign")->__("content"),
37
+ "index" => "content",
38
+ ));
39
+ $this->addColumn("positon", array(
40
+ "header" => Mage::helper("bannercampaign")->__("positon"),
41
+ "index" => "positon",
42
+ ));
43
+ $this->addColumn("width", array(
44
+ "header" => Mage::helper("bannercampaign")->__("width"),
45
+ "index" => "width",
46
+ ));
47
+ $this->addColumn("height", array(
48
+ "header" => Mage::helper("bannercampaign")->__("height"),
49
+ "index" => "height",
50
+ ));
51
+ $this->addColumn('country', array(
52
+ 'header' => Mage::helper('bannercampaign')->__('country'),
53
+ 'index' => 'country',
54
+ 'type' => 'options',
55
+ 'options'=>Ghrix_Bannercampaign_Block_Adminhtml_Bannercampaign_Grid::getOptionArray7(),
56
+ ));
57
+
58
+ $this->addColumn('startfrom', array(
59
+ 'header' => Mage::helper('bannercampaign')->__('startfrom'),
60
+ 'index' => 'startfrom',
61
+ 'type' => 'datetime',
62
+ ));
63
+ $this->addColumn('startto', array(
64
+ 'header' => Mage::helper('bannercampaign')->__('startto'),
65
+ 'index' => 'startto',
66
+ 'type' => 'datetime',
67
+ ));
68
+ $this->addColumn("enable", array(
69
+ "header" => Mage::helper("bannercampaign")->__("enable"),
70
+ "index" => "enable",
71
+ ));
72
+ $this->addExportType('*/*/exportCsv', Mage::helper('sales')->__('CSV'));
73
+ $this->addExportType('*/*/exportExcel', Mage::helper('sales')->__('Excel'));
74
+
75
+ return parent::_prepareColumns();
76
+ }
77
+
78
+ public function getRowUrl($row)
79
+ {
80
+ return $this->getUrl("*/*/edit", array("id" => $row->getId()));
81
+ }
82
+
83
+
84
+
85
+ protected function _prepareMassaction()
86
+ {
87
+ $this->setMassactionIdField('id');
88
+ $this->getMassactionBlock()->setFormFieldName('ids');
89
+ $this->getMassactionBlock()->setUseSelectAll(true);
90
+ $this->getMassactionBlock()->addItem('remove_bannercampaign', array(
91
+ 'label'=> Mage::helper('bannercampaign')->__('Remove Bannercampaign'),
92
+ 'url' => $this->getUrl('*/adminhtml_bannercampaign/massRemove'),
93
+ 'confirm' => Mage::helper('bannercampaign')->__('Are you sure?')
94
+ ));
95
+ return $this;
96
+ }
97
+
98
+ static public function getOptionArray7()
99
+ {
100
+ $data_array=array();
101
+ $data_array[0]='india';
102
+ $data_array[1]='us';
103
+ return($data_array);
104
+ }
105
+ static public function getValueArray7()
106
+ {
107
+ $data_array=array();
108
+ foreach(Ghrix_Bannercampaign_Block_Adminhtml_Bannercampaign_Grid::getOptionArray7() as $k=>$v){
109
+ $data_array[]=array('value'=>$k,'label'=>$v);
110
+ }
111
+ return($data_array);
112
+
113
+ }
114
+
115
+ static public function getOptionArray10()
116
+ {
117
+ $data_array=array();
118
+ $data_array[0]='weekday';
119
+ $data_array[1]='weekend';
120
+ $data_array[2]='monday';
121
+ $data_array[3]='tuesday';
122
+ $data_array[4]='wednesday';
123
+ $data_array[5]='thursday';
124
+ $data_array[6]='friday';
125
+ $data_array[7]='saturday';
126
+ $data_array[8]='sunday';
127
+ return($data_array);
128
+ }
129
+ static public function getValueArray10()
130
+ {
131
+ $data_array=array();
132
+ foreach(Ghrix_Bannercampaign_Block_Adminhtml_Bannercampaign_Grid::getOptionArray10() as $k=>$v){
133
+ $data_array[]=array('value'=>$k,'label'=>$v);
134
+ }
135
+ return($data_array);
136
+
137
+ }
138
+
139
+
140
+ }
app/code/local/Ghrix/Bannercampaign/Block/Adminhtml/Bannercampaignbackend.php ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
1
+ <?php
2
+
3
+ class Ghrix_Bannercampaign_Block_Adminhtml_Bannercampaignbackend extends Mage_Adminhtml_Block_Template {
4
+
5
+ }
app/code/local/Ghrix/Bannercampaign/Block/Index.php ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Ghrix_Bannercampaign_Block_Index extends Mage_Core_Block_Template{
3
+
4
+
5
+
6
+
7
+
8
+ }
app/code/local/Ghrix/Bannercampaign/Helper/Data.php ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
1
+ <?php
2
+ class Ghrix_Bannercampaign_Helper_Data extends Mage_Core_Helper_Abstract
3
+ {
4
+ }
5
+
app/code/local/Ghrix/Bannercampaign/Model/Bannercampaign.php ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Ghrix_Bannercampaign_Model_Bannercampaign extends Mage_Core_Model_Abstract
4
+ {
5
+ protected function _construct(){
6
+
7
+ $this->_init("bannercampaign/bannercampaign");
8
+
9
+ }
10
+
11
+ }
12
+
app/code/local/Ghrix/Bannercampaign/Model/Mysql4/Bannercampaign.php ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Ghrix_Bannercampaign_Model_Mysql4_Bannercampaign extends Mage_Core_Model_Mysql4_Abstract
3
+ {
4
+ protected function _construct()
5
+ {
6
+ $this->_init("bannercampaign/bannercampaign", "id");
7
+ }
8
+ }
app/code/local/Ghrix/Bannercampaign/Model/Mysql4/Bannercampaign/Collection.php ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Ghrix_Bannercampaign_Model_Mysql4_Bannercampaign_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
3
+ {
4
+
5
+ public function _construct(){
6
+ $this->_init("bannercampaign/bannercampaign");
7
+ }
8
+
9
+
10
+
11
+ }
12
+
app/code/local/Ghrix/Bannercampaign/controllers/Adminhtml/BannercampaignController.php ADDED
@@ -0,0 +1,210 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Ghrix_Bannercampaign_Adminhtml_BannercampaignController extends Mage_Adminhtml_Controller_Action
4
+ {
5
+ protected function _initAction()
6
+ {
7
+ $this->loadLayout()->_setActiveMenu("bannercampaign/bannercampaign")->_addBreadcrumb(Mage::helper("adminhtml")->__("Bannercampaign Manager"),Mage::helper("adminhtml")->__("Bannercampaign Manager"));
8
+ return $this;
9
+ }
10
+ public function indexAction()
11
+ {
12
+ $this->_title($this->__("Bannercampaign"));
13
+ $this->_title($this->__("Manager Bannercampaign"));
14
+
15
+ $this->_initAction();
16
+ $this->renderLayout();
17
+ }
18
+ public function editAction()
19
+ {
20
+ $this->_title($this->__("Bannercampaign"));
21
+ $this->_title($this->__("Bannercampaign"));
22
+ $this->_title($this->__("Edit Item"));
23
+
24
+ $id = $this->getRequest()->getParam("id");
25
+ $model = Mage::getModel("bannercampaign/bannercampaign")->load($id);
26
+ if ($model->getId()) {
27
+ Mage::register("bannercampaign_data", $model);
28
+ $this->loadLayout();
29
+ $this->_setActiveMenu("bannercampaign/bannercampaign");
30
+ $this->_addBreadcrumb(Mage::helper("adminhtml")->__("Bannercampaign Manager"), Mage::helper("adminhtml")->__("Bannercampaign Manager"));
31
+ $this->_addBreadcrumb(Mage::helper("adminhtml")->__("Bannercampaign Description"), Mage::helper("adminhtml")->__("Bannercampaign Description"));
32
+ $this->getLayout()->getBlock("head")->setCanLoadExtJs(true);
33
+ $this->_addContent($this->getLayout()->createBlock("bannercampaign/adminhtml_bannercampaign_edit"))->_addLeft($this->getLayout()->createBlock("bannercampaign/adminhtml_bannercampaign_edit_tabs"));
34
+ $this->renderLayout();
35
+ }
36
+ else {
37
+ Mage::getSingleton("adminhtml/session")->addError(Mage::helper("bannercampaign")->__("Item does not exist."));
38
+ $this->_redirect("*/*/");
39
+ }
40
+ }
41
+
42
+ public function newAction()
43
+ {
44
+
45
+ $this->_title($this->__("Bannercampaign"));
46
+ $this->_title($this->__("Bannercampaign"));
47
+ $this->_title($this->__("New Item"));
48
+
49
+ $id = $this->getRequest()->getParam("id");
50
+ $model = Mage::getModel("bannercampaign/bannercampaign")->load($id);
51
+
52
+ $data = Mage::getSingleton("adminhtml/session")->getFormData(true);
53
+ if (!empty($data)) {
54
+ $model->setData($data);
55
+ }
56
+
57
+ Mage::register("bannercampaign_data", $model);
58
+
59
+ $this->loadLayout();
60
+ $this->_setActiveMenu("bannercampaign/bannercampaign");
61
+
62
+ $this->getLayout()->getBlock("head")->setCanLoadExtJs(true);
63
+
64
+ $this->_addBreadcrumb(Mage::helper("adminhtml")->__("Bannercampaign Manager"), Mage::helper("adminhtml")->__("Bannercampaign Manager"));
65
+ $this->_addBreadcrumb(Mage::helper("adminhtml")->__("Bannercampaign Description"), Mage::helper("adminhtml")->__("Bannercampaign Description"));
66
+
67
+
68
+ $this->_addContent($this->getLayout()->createBlock("bannercampaign/adminhtml_bannercampaign_edit"))->_addLeft($this->getLayout()->createBlock("bannercampaign/adminhtml_bannercampaign_edit_tabs"));
69
+
70
+ $this->renderLayout();
71
+
72
+ }
73
+ public function saveAction()
74
+ {
75
+
76
+ $post_data=$this->getRequest()->getPost();
77
+
78
+
79
+ if ($post_data) {
80
+
81
+ try {
82
+
83
+
84
+ $post_data['whichday']=implode(',',$post_data['whichday']);
85
+ //save image
86
+ try{
87
+
88
+ if((bool)$post_data['photo']['delete']==1) {
89
+
90
+ $post_data['photo']='';
91
+
92
+ }
93
+ else {
94
+
95
+ unset($post_data['photo']);
96
+
97
+ if (isset($_FILES)){
98
+
99
+ if ($_FILES['photo']['name']) {
100
+
101
+ if($this->getRequest()->getParam("id")){
102
+ $model = Mage::getModel("bannercampaign/bannercampaign")->load($this->getRequest()->getParam("id"));
103
+ if($model->getData('photo')){
104
+ $io = new Varien_Io_File();
105
+ $io->rm(Mage::getBaseDir('media').DS.implode(DS,explode('/',$model->getData('photo'))));
106
+ }
107
+ }
108
+ $path = Mage::getBaseDir('media') . DS . 'bannercampaign' . DS .'bannercampaign'.DS;
109
+ $uploader = new Varien_File_Uploader('photo');
110
+ $uploader->setAllowedExtensions(array('jpg','png','gif'));
111
+ $uploader->setAllowRenameFiles(false);
112
+ $uploader->setFilesDispersion(false);
113
+ $destFile = $path.$_FILES['photo']['name'];
114
+ $filename = $uploader->getNewFileName($destFile);
115
+ $uploader->save($path, $filename);
116
+
117
+ $post_data['photo']='bannercampaign/bannercampaign/'.$filename;
118
+ }
119
+ }
120
+ }
121
+
122
+ } catch (Exception $e) {
123
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
124
+ $this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id')));
125
+ return;
126
+ }
127
+ //save image
128
+
129
+
130
+ $model = Mage::getModel("bannercampaign/bannercampaign")
131
+ ->addData($post_data)
132
+ ->setId($this->getRequest()->getParam("id"))
133
+ ->save();
134
+
135
+ Mage::getSingleton("adminhtml/session")->addSuccess(Mage::helper("adminhtml")->__("Bannercampaign was successfully saved"));
136
+ Mage::getSingleton("adminhtml/session")->setBannercampaignData(false);
137
+
138
+ if ($this->getRequest()->getParam("back")) {
139
+ $this->_redirect("*/*/edit", array("id" => $model->getId()));
140
+ return;
141
+ }
142
+ $this->_redirect("*/*/");
143
+ return;
144
+ }
145
+ catch (Exception $e) {
146
+ Mage::getSingleton("adminhtml/session")->addError($e->getMessage());
147
+ Mage::getSingleton("adminhtml/session")->setBannercampaignData($this->getRequest()->getPost());
148
+ $this->_redirect("*/*/edit", array("id" => $this->getRequest()->getParam("id")));
149
+ return;
150
+ }
151
+
152
+ }
153
+ $this->_redirect("*/*/");
154
+ }
155
+
156
+
157
+
158
+ public function deleteAction()
159
+ {
160
+ if( $this->getRequest()->getParam("id") > 0 ) {
161
+ try {
162
+ $model = Mage::getModel("bannercampaign/bannercampaign");
163
+ $model->setId($this->getRequest()->getParam("id"))->delete();
164
+ Mage::getSingleton("adminhtml/session")->addSuccess(Mage::helper("adminhtml")->__("Item was successfully deleted"));
165
+ $this->_redirect("*/*/");
166
+ }
167
+ catch (Exception $e) {
168
+ Mage::getSingleton("adminhtml/session")->addError($e->getMessage());
169
+ $this->_redirect("*/*/edit", array("id" => $this->getRequest()->getParam("id")));
170
+ }
171
+ }
172
+ $this->_redirect("*/*/");
173
+ }
174
+
175
+
176
+ public function massRemoveAction()
177
+ {
178
+ try {
179
+ $ids = $this->getRequest()->getPost('ids', array());
180
+ foreach ($ids as $id) {
181
+ $model = Mage::getModel("bannercampaign/bannercampaign");
182
+ $model->setId($id)->delete();
183
+ }
184
+ Mage::getSingleton("adminhtml/session")->addSuccess(Mage::helper("adminhtml")->__("Item(s) was successfully removed"));
185
+ }
186
+ catch (Exception $e) {
187
+ Mage::getSingleton("adminhtml/session")->addError($e->getMessage());
188
+ }
189
+ $this->_redirect('*/*/');
190
+ }
191
+
192
+ /**
193
+ * Export order grid to CSV format
194
+ */
195
+ public function exportCsvAction()
196
+ {
197
+ $fileName = 'bannercampaign.csv';
198
+ $grid = $this->getLayout()->createBlock('bannercampaign/adminhtml_bannercampaign_grid');
199
+ $this->_prepareDownloadResponse($fileName, $grid->getCsvFile());
200
+ }
201
+ /**
202
+ * Export order grid to Excel XML format
203
+ */
204
+ public function exportExcelAction()
205
+ {
206
+ $fileName = 'bannercampaign.xml';
207
+ $grid = $this->getLayout()->createBlock('bannercampaign/adminhtml_bannercampaign_grid');
208
+ $this->_prepareDownloadResponse($fileName, $grid->getExcelFile($fileName));
209
+ }
210
+ }
app/code/local/Ghrix/Bannercampaign/controllers/Adminhtml/BannercampaignbackendController.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Ghrix_Bannercampaign_Adminhtml_BannercampaignbackendController extends Mage_Adminhtml_Controller_Action
3
+ {
4
+ public function indexAction()
5
+ {
6
+ $this->loadLayout();
7
+ $this->_title($this->__("bannercampaign"));
8
+ $this->renderLayout();
9
+ }
10
+ }
app/code/local/Ghrix/Bannercampaign/controllers/IndexController.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Ghrix_Bannercampaign_IndexController extends Mage_Core_Controller_Front_Action{
3
+ public function IndexAction() {
4
+
5
+ $this->loadLayout();
6
+ $this->getLayout()->getBlock("head")->setTitle($this->__("Titlename"));
7
+ $breadcrumbs = $this->getLayout()->getBlock("breadcrumbs");
8
+ $breadcrumbs->addCrumb("home", array(
9
+ "label" => $this->__("Home Page"),
10
+ "title" => $this->__("Home Page"),
11
+ "link" => Mage::getBaseUrl()
12
+ ));
13
+
14
+ $breadcrumbs->addCrumb("titlename", array(
15
+ "label" => $this->__("Titlename"),
16
+ "title" => $this->__("Titlename")
17
+ ));
18
+
19
+ $this->renderLayout();
20
+
21
+ }
22
+ }
app/code/local/Ghrix/Bannercampaign/etc/config.xml ADDED
@@ -0,0 +1,134 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Ghrix_Bannercampaign>
5
+ <version>0.1.0</version>
6
+ </Ghrix_Bannercampaign>
7
+ </modules>
8
+ <frontend>
9
+ <routers>
10
+ <bannercampaign>
11
+ <use>standard</use>
12
+ <args>
13
+ <module>Ghrix_Bannercampaign</module>
14
+ <frontName>bannercampaign</frontName>
15
+ </args>
16
+ </bannercampaign>
17
+ </routers>
18
+ <layout>
19
+ <updates>
20
+ <bannercampaign>
21
+ <file>bannercampaign.xml</file>
22
+ </bannercampaign>
23
+ </updates>
24
+ </layout>
25
+ </frontend>
26
+ <global>
27
+ <helpers>
28
+ <bannercampaign>
29
+ <class>Ghrix_Bannercampaign_Helper</class>
30
+ </bannercampaign>
31
+ </helpers>
32
+ <blocks>
33
+ <bannercampaign>
34
+ <class>Ghrix_Bannercampaign_Block</class>
35
+ </bannercampaign>
36
+ </blocks>
37
+ <models>
38
+ <bannercampaign>
39
+ <class>Ghrix_Bannercampaign_Model</class>
40
+ <resourceModel>bannercampaign_mysql4</resourceModel>
41
+ </bannercampaign>
42
+ <bannercampaign_mysql4>
43
+ <class>Ghrix_Bannercampaign_Model_Mysql4</class>
44
+ <entities>
45
+ <bannercampaign>
46
+ <table>bannercampaign</table>
47
+ </bannercampaign>
48
+ </entities>
49
+ </bannercampaign_mysql4>
50
+ </models>
51
+ <resources>
52
+ <bannercampaign_setup>
53
+ <setup>
54
+ <module>Ghrix_Bannercampaign</module>
55
+ </setup>
56
+ <connection>
57
+ <use>core_setup</use>
58
+ </connection>
59
+ </bannercampaign_setup>
60
+ <bannercampaign_write>
61
+ <connection>
62
+ <use>core_write</use>
63
+ </connection>
64
+ </bannercampaign_write>
65
+ <bannercampaign_read>
66
+ <connection>
67
+ <use>core_read</use>
68
+ </connection>
69
+ </bannercampaign_read>
70
+ </resources>
71
+ </global>
72
+ <admin>
73
+ <routers>
74
+ <bannercampaign>
75
+ <use>admin</use>
76
+ <args>
77
+ <module>Ghrix_Bannercampaign</module>
78
+ <frontName>admin_bannercampaign</frontName>
79
+ </args>
80
+ </bannercampaign>
81
+ </routers>
82
+ </admin>
83
+ <adminhtml>
84
+ <menu>
85
+ <bannercampaign module="bannercampaign">
86
+ <title>Bannercampaign</title>
87
+ <sort_order>100</sort_order>
88
+ <children>
89
+ <bannercampaignbackend module="bannercampaign">
90
+ <title>bannercampaign</title>
91
+ <sort_order>0</sort_order>
92
+ <action>admin_bannercampaign/adminhtml_bannercampaignbackend</action>
93
+ </bannercampaignbackend>
94
+ <bannercampaign module="bannercampaign">
95
+ <title>Manage Bannercampaign</title>
96
+ <sort_order>0</sort_order>
97
+ <action>admin_bannercampaign/adminhtml_bannercampaign</action>
98
+ </bannercampaign>
99
+ </children>
100
+ </bannercampaign>
101
+ </menu>
102
+ <acl>
103
+ <resources>
104
+ <all>
105
+ <title>Allow Everything</title>
106
+ </all>
107
+ <admin>
108
+ <children>
109
+ <bannercampaign translate="title" module="bannercampaign">
110
+ <title>Bannercampaign</title>
111
+ <sort_order>1000</sort_order>
112
+ <children>
113
+ <bannercampaignbackend translate="title">
114
+ <title>bannercampaign</title>
115
+ </bannercampaignbackend>
116
+ <bannercampaign translate="title">
117
+ <title>Manage Bannercampaign</title>
118
+ <sort_order>0</sort_order>
119
+ </bannercampaign>
120
+ </children>
121
+ </bannercampaign>
122
+ </children>
123
+ </admin>
124
+ </resources>
125
+ </acl>
126
+ <layout>
127
+ <updates>
128
+ <bannercampaign>
129
+ <file>bannercampaign.xml</file>
130
+ </bannercampaign>
131
+ </updates>
132
+ </layout>
133
+ </adminhtml>
134
+ </config>
app/code/local/Ghrix/Bannercampaign/sql/bannercampaign_setup/mysql4-install-0.1.0.php ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ $installer = $this;
3
+ $installer->startSetup();
4
+ $sql=<<<SQLTEXT
5
+ create table bannercampaign(id int not null auto_increment,
6
+ title varchar(100),
7
+ positon varchar(100),
8
+ content varchar(100),
9
+ photo varchar(100),
10
+ width varchar(100),
11
+ height varchar(100),
12
+ country varchar(100),
13
+ startfrom varchar(100),
14
+ startto varchar(100),
15
+ whichday varchar(100),
16
+ enable varchar(100),
17
+ primary key(id));
18
+
19
+ SQLTEXT;
20
+
21
+ $installer->run($sql);
22
+ //demo
23
+ //Mage::getModel('core/url_rewrite')->setId(null);
24
+ //demo
25
+ $installer->endSetup();
26
+
app/code/local/Ghrix/Campaign/Block/Adminhtml/Campaign.php ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+
4
+ class Ghrix_Campaign_Block_Adminhtml_Campaign extends Mage_Adminhtml_Block_Widget_Grid_Container{
5
+
6
+ public function __construct()
7
+ {
8
+
9
+ $this->_controller = "adminhtml_campaign";
10
+ $this->_blockGroup = "campaign";
11
+ $this->_headerText = Mage::helper("campaign")->__("Campaign Manager");
12
+ $this->_addButtonLabel = Mage::helper("campaign")->__("Add New Item");
13
+ parent::__construct();
14
+
15
+ }
16
+
17
+ }
app/code/local/Ghrix/Campaign/Block/Adminhtml/Campaign/Edit.php ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Ghrix_Campaign_Block_Adminhtml_Campaign_Edit extends Mage_Adminhtml_Block_Widget_Form_Container
4
+ {
5
+ public function __construct()
6
+ {
7
+
8
+ parent::__construct();
9
+ $this->_objectId = "id";
10
+ $this->_blockGroup = "campaign";
11
+ $this->_controller = "adminhtml_campaign";
12
+ $this->_updateButton("save", "label", Mage::helper("campaign")->__("Save Item"));
13
+ $this->_updateButton("delete", "label", Mage::helper("campaign")->__("Delete Item"));
14
+
15
+ $this->_addButton("saveandcontinue", array(
16
+ "label" => Mage::helper("campaign")->__("Save And Continue Edit"),
17
+ "onclick" => "saveAndContinueEdit()",
18
+ "class" => "save",
19
+ ), -100);
20
+
21
+
22
+
23
+ $this->_formScripts[] = "
24
+
25
+ function saveAndContinueEdit(){
26
+ editForm.submit($('edit_form').action+'back/edit/');
27
+ }
28
+ ";
29
+ }
30
+
31
+ public function getHeaderText()
32
+ {
33
+ if( Mage::registry("campaign_data") && Mage::registry("campaign_data")->getId() ){
34
+
35
+ return Mage::helper("campaign")->__("Edit Item '%s'", $this->htmlEscape(Mage::registry("campaign_data")->getId()));
36
+
37
+ }
38
+ else{
39
+
40
+ return Mage::helper("campaign")->__("Add Item");
41
+
42
+ }
43
+ }
44
+ }
app/code/local/Ghrix/Campaign/Block/Adminhtml/Campaign/Edit/Form.php ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Ghrix_Campaign_Block_Adminhtml_Campaign_Edit_Form extends Mage_Adminhtml_Block_Widget_Form
3
+ {
4
+ protected function _prepareForm()
5
+ {
6
+ $form = new Varien_Data_Form(array(
7
+ "id" => "edit_form",
8
+ "action" => $this->getUrl("*/*/save", array("id" => $this->getRequest()->getParam("id"))),
9
+ "method" => "post",
10
+ "enctype" =>"multipart/form-data",
11
+ )
12
+ );
13
+ $form->setUseContainer(true);
14
+ $this->setForm($form);
15
+ return parent::_prepareForm();
16
+ }
17
+ }
app/code/local/Ghrix/Campaign/Block/Adminhtml/Campaign/Edit/Tab/Form.php ADDED
@@ -0,0 +1,100 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Ghrix_Campaign_Block_Adminhtml_Campaign_Edit_Tab_Form extends Mage_Adminhtml_Block_Widget_Form
3
+ {
4
+ protected function _prepareForm()
5
+ {
6
+
7
+ $form = new Varien_Data_Form();
8
+ $this->setForm($form);
9
+ $fieldset = $form->addFieldset("campaign_form", array("legend"=>Mage::helper("campaign")->__("Item information")));
10
+
11
+
12
+ $fieldset->addField("title", "text", array(
13
+ "label" => Mage::helper("campaign")->__("title"),
14
+ "name" => "title",
15
+ 'class' => 'required-entry',
16
+ ));
17
+
18
+ $fieldset->addField("content", "textarea", array(
19
+ "label" => Mage::helper("campaign")->__("content"),
20
+ "name" => "content",
21
+ ));
22
+
23
+ $fieldset->addField("positon", "text", array(
24
+ "label" => Mage::helper("campaign")->__("positon"),
25
+ "name" => "positon",
26
+ 'class' => 'required-entry',
27
+ ));
28
+
29
+ $fieldset->addField('photo', 'image', array(
30
+ 'label' => Mage::helper('campaign')->__('photo'),
31
+ 'name' => 'photo',
32
+ 'class' => 'required-entry',
33
+ 'note' => '(*.jpg, *.png, *.gif)',
34
+ ));
35
+ $fieldset->addField("width", "text", array(
36
+ "label" => Mage::helper("campaign")->__("width"),
37
+ "name" => "width",
38
+ ));
39
+
40
+ $fieldset->addField("height", "text", array(
41
+ "label" => Mage::helper("campaign")->__("height"),
42
+ "name" => "height",
43
+ ));
44
+
45
+ $fieldset->addField('country', 'multiselect', array(
46
+ 'label' => Mage::helper('campaign')->__('country'),
47
+ 'values' => Mage::getModel('directory/country')->getResourceCollection()->loadByStore()->toOptionArray(),
48
+ 'name' => 'country',
49
+ ));
50
+ $dateFormatIso = Mage::app()->getLocale()->getDateTimeFormat(
51
+ Mage_Core_Model_Locale::FORMAT_TYPE_SHORT
52
+ );
53
+
54
+ $fieldset->addField('startfrom', 'date', array(
55
+ 'label' => Mage::helper('campaign')->__('startfrom'),
56
+ 'class' => 'required-entry',
57
+ 'name' => 'startfrom',
58
+ 'time' => true,
59
+ 'image' => $this->getSkinUrl('images/grid-cal.gif'),
60
+ 'format' => 'yyyy-M-d h:mm a'
61
+ ));
62
+
63
+
64
+ $fieldset->addField('startto', 'date', array(
65
+ 'label' => Mage::helper('campaign')->__('startto'),
66
+ 'class' => 'required-entry',
67
+ 'name' => 'startto',
68
+ 'time' => true,
69
+ 'image' => $this->getSkinUrl('images/grid-cal.gif'),
70
+ 'format' => 'yyyy-M-d h:mm a'
71
+ ));
72
+ $fieldset->addField('whichday', 'multiselect', array(
73
+ 'label' => Mage::helper('campaign')->__('whichday'),
74
+ 'values' => Ghrix_Campaign_Block_Adminhtml_Campaign_Grid::getValueArray10(),
75
+ 'name' => 'whichday',
76
+ ));
77
+
78
+ $fieldset->addField("pos", "text", array(
79
+ "label" => Mage::helper("campaign")->__("sort order"),
80
+ "name" => "pos",
81
+ ));
82
+
83
+
84
+ $fieldset->addField("enable", "select", array(
85
+ "label" => Mage::helper("campaign")->__("enable"),
86
+ "name" => "enable",
87
+ "values"=> Mage::getModel('adminhtml/system_config_source_yesno')->toOptionArray(),
88
+ ));
89
+
90
+ if (Mage::getSingleton("adminhtml/session")->getCampaignData())
91
+ {
92
+ $form->setValues(Mage::getSingleton("adminhtml/session")->getCampaignData());
93
+ Mage::getSingleton("adminhtml/session")->setCampaignData(null);
94
+ }
95
+ elseif(Mage::registry("campaign_data")) {
96
+ $form->setValues(Mage::registry("campaign_data")->getData());
97
+ }
98
+ return parent::_prepareForm();
99
+ }
100
+ }
app/code/local/Ghrix/Campaign/Block/Adminhtml/Campaign/Edit/Tabs.php ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Ghrix_Campaign_Block_Adminhtml_Campaign_Edit_Tabs extends Mage_Adminhtml_Block_Widget_Tabs
3
+ {
4
+ public function __construct()
5
+ {
6
+ parent::__construct();
7
+ $this->setId("campaign_tabs");
8
+ $this->setDestElementId("edit_form");
9
+ $this->setTitle(Mage::helper("campaign")->__("Item Information"));
10
+ }
11
+ protected function _beforeToHtml()
12
+ {
13
+ $this->addTab("form_section", array(
14
+ "label" => Mage::helper("campaign")->__("Item Information"),
15
+ "title" => Mage::helper("campaign")->__("Item Information"),
16
+ "content" => $this->getLayout()->createBlock("campaign/adminhtml_campaign_edit_tab_form")->toHtml(),
17
+ ));
18
+ return parent::_beforeToHtml();
19
+ }
20
+
21
+ }
app/code/local/Ghrix/Campaign/Block/Adminhtml/Campaign/Grid.php ADDED
@@ -0,0 +1,155 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Ghrix_Campaign_Block_Adminhtml_Campaign_Grid extends Mage_Adminhtml_Block_Widget_Grid
4
+ {
5
+
6
+ public function __construct()
7
+ {
8
+ parent::__construct();
9
+ $this->setId("campaignGrid");
10
+ $this->setDefaultSort("id");
11
+ $this->setDefaultDir("DESC");
12
+ $this->setSaveParametersInSession(true);
13
+ }
14
+
15
+ protected function _prepareCollection()
16
+ {
17
+ $collection = Mage::getModel("campaign/campaign")->getCollection();
18
+ $this->setCollection($collection);
19
+ return parent::_prepareCollection();
20
+ }
21
+ protected function _prepareColumns()
22
+ {
23
+ $this->addColumn("id", array(
24
+ "header" => Mage::helper("campaign")->__("ID"),
25
+ "align" =>"right",
26
+ "width" => "50px",
27
+ "type" => "number",
28
+ "index" => "id",
29
+ ));
30
+
31
+ $this->addColumn("title", array(
32
+ "header" => Mage::helper("campaign")->__("title"),
33
+ "index" => "title",
34
+ ));
35
+ $this->addColumn("content", array(
36
+ "header" => Mage::helper("campaign")->__("content"),
37
+ "index" => "content",
38
+ ));
39
+ $this->addColumn("positon", array(
40
+ "header" => Mage::helper("campaign")->__("positon"),
41
+ "index" => "positon",
42
+ ));
43
+ $this->addColumn("width", array(
44
+ "header" => Mage::helper("campaign")->__("width"),
45
+ "index" => "width",
46
+ ));
47
+ $this->addColumn("height", array(
48
+ "header" => Mage::helper("campaign")->__("height"),
49
+ "index" => "height",
50
+ ));
51
+ $this->addColumn('country', array(
52
+ 'header' => Mage::helper('campaign')->__('country'),
53
+ 'index' => 'country',
54
+ 'type' => 'options',
55
+ 'options'=> Ghrix_Campaign_Block_Adminhtml_Campaign_Grid::getOptionArray7(),
56
+ ));
57
+
58
+ $this->addColumn('startfrom', array(
59
+ 'header' => Mage::helper('campaign')->__('startfrom'),
60
+ 'index' => 'startfrom',
61
+ 'type' => 'datetime',
62
+ ));
63
+ $this->addColumn('startto', array(
64
+ 'header' => Mage::helper('campaign')->__('startto'),
65
+ 'index' => 'startto',
66
+ 'type' => 'datetime',
67
+ ));
68
+
69
+ $this->addColumn('photo', array(
70
+ 'header' => Mage::helper('salesrule')->__('photo'),
71
+ 'index' => 'id',
72
+ 'align' => 'center',
73
+ 'width' => '160',
74
+ 'renderer' => 'ghrix_campaign_block_adminhtml_campaign_grid_column_renderer_image'
75
+ ));
76
+
77
+
78
+
79
+
80
+
81
+
82
+
83
+ $this->addColumn("enable", array(
84
+ "header" => Mage::helper("campaign")->__("enable"),
85
+ "index" => "enable",
86
+ ));
87
+ $this->addExportType('*/*/exportCsv', Mage::helper('sales')->__('CSV'));
88
+ $this->addExportType('*/*/exportExcel', Mage::helper('sales')->__('Excel'));
89
+
90
+ return parent::_prepareColumns();
91
+ }
92
+
93
+ public function getRowUrl($row)
94
+ {
95
+ return $this->getUrl("*/*/edit", array("id" => $row->getId()));
96
+ }
97
+
98
+
99
+
100
+ protected function _prepareMassaction()
101
+ {
102
+ $this->setMassactionIdField('id');
103
+ $this->getMassactionBlock()->setFormFieldName('ids');
104
+ $this->getMassactionBlock()->setUseSelectAll(true);
105
+ $this->getMassactionBlock()->addItem('remove_campaign', array(
106
+ 'label'=> Mage::helper('campaign')->__('Remove Campaign'),
107
+ 'url' => $this->getUrl('*/adminhtml_campaign/massRemove'),
108
+ 'confirm' => Mage::helper('campaign')->__('Are you sure?')
109
+ ));
110
+ return $this;
111
+ }
112
+
113
+ static public function getOptionArray7()
114
+ {
115
+ $data_array=array();
116
+ $data_array[0]='india';
117
+ $data_array[1]='us';
118
+ return($data_array);
119
+ }
120
+ static public function getValueArray7()
121
+ {
122
+ $data_array=array();
123
+ foreach(Ghrix_Campaign_Block_Adminhtml_Campaign_Grid::getOptionArray7() as $k=>$v){
124
+ $data_array[]=array('value'=>$k,'label'=>$v);
125
+ }
126
+ return($data_array);
127
+
128
+ }
129
+
130
+ static public function getOptionArray10()
131
+ {
132
+ $data_array=array();
133
+ $data_array[0]='weekday';
134
+ $data_array[1]='weekend';
135
+ $data_array[2]='monday';
136
+ $data_array[3]='tuesday';
137
+ $data_array[4]='wednesday';
138
+ $data_array[5]='thursday';
139
+ $data_array[6]='friday';
140
+ $data_array[7]='saturday';
141
+ $data_array[8]='sunday';
142
+ return($data_array);
143
+ }
144
+ static public function getValueArray10()
145
+ {
146
+ $data_array=array();
147
+ foreach(Ghrix_Campaign_Block_Adminhtml_Campaign_Grid::getOptionArray10() as $k=>$v){
148
+ $data_array[]=array('value'=>$k,'label'=>$v);
149
+ }
150
+ return($data_array);
151
+
152
+ }
153
+
154
+
155
+ }
app/code/local/Ghrix/Campaign/Block/Adminhtml/Campaign/Grid/Column/Renderer/Image.php ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2014 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Coupon codes grid "Used" column renderer
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Adminhtml
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+ class Ghrix_Campaign_Block_Adminhtml_Campaign_Grid_Column_Renderer_Image
35
+ extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Text
36
+ {
37
+ public function render(Varien_Object $row)
38
+ {
39
+ $currentruleid = $this->getRequest()->getParam('id');
40
+ $value = (int)$row->getData('id');
41
+ $read = Mage::getSingleton('core/resource')->getConnection('core_read');
42
+ $write = Mage::getSingleton("core/resource")->getConnection("core_write");
43
+ $query = "SELECT * FROM campaign
44
+ WHERE id ='$value' ";
45
+ $result = $read->query($query);
46
+ $affected_rows = $result->rowCount();
47
+ $getstartdate= '';
48
+ if($affected_rows > 0){
49
+ $e = 1;
50
+ $getstartdate1 = $result->fetchAll();
51
+ $getstartdate = $getstartdate1[0]['photo'];
52
+ }
53
+ //return print_r(Mage::getModel('adminhtml/system_config_source_country')->toOptionArray());
54
+ return "<img width ='50' height ='50'src = '".Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA).$getstartdate."'>"
55
+ ;
56
+ }
57
+ }
app/code/local/Ghrix/Campaign/Block/Index.php ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Ghrix_Campaign_Block_Index extends Mage_Core_Block_Template{
3
+
4
+
5
+
6
+
7
+
8
+ }
app/code/local/Ghrix/Campaign/Helper/Data.php ADDED
@@ -0,0 +1,89 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Ghrix_Campaign_Helper_Data extends Mage_Core_Helper_Abstract
3
+ {
4
+
5
+ public function showbanner($position){
6
+
7
+ $usercurrent_country = $this->getLocationInfoByIp();
8
+ $weekend = array('saturday','sunday');
9
+
10
+ $collection = Mage::getModel("campaign/campaign")->getCollection()->addFieldToFilter("positon", $position)
11
+ ->addFieldToFilter("enable", "1")
12
+ ->addOrder('pos','DES');
13
+ foreach ($collection as $collectiondta)
14
+ {
15
+ $getcountry = explode(',' , $collectiondta->getData('country'));
16
+ if(is_array($getcountry)){
17
+ $country = explode(',' , $collectiondta->getData('country')) ;
18
+ }else{
19
+ $country['0'] = $collectiondta->getData('country') ;
20
+ }
21
+ $collectiondta->getData('id');
22
+ // echo "<br/>";
23
+
24
+ $imagestartfrom = strtotime($collectiondta->getData('startfrom'));
25
+ //echo "<br/>";
26
+
27
+ $imagestartto = strtotime($collectiondta->getData('startto'));
28
+ //echo "<br/>";
29
+ $today_day = strtolower(date( "l")); // get current day
30
+ $today_date = time();
31
+ //echo "<br/>";
32
+ //echo $usercurrent_country;
33
+ //echo "<br/>";
34
+
35
+ // to get days from the ids storre in the db
36
+ $imagewhichday = explode(',' , $collectiondta->getData('whichday'));
37
+ $dayasarray = Ghrix_Campaign_Block_Adminhtml_Campaign_Grid::getOptionArray10(); // get defined whichdays arrays
38
+ $array_new = [];
39
+ foreach($imagewhichday as $key)
40
+ {
41
+ if(array_key_exists($key, $dayasarray))
42
+ {
43
+ $array_new[$key] = $dayasarray[$key];
44
+ }
45
+ }
46
+
47
+ if(in_array('weekday',$array_new)){
48
+ $array_new = array('monday','tuesday','wednesday','thursday','friday');
49
+ }
50
+ elseif(in_array('weekend',$array_new)){
51
+ $array_new = array('saturday','sunday');
52
+ }
53
+ // print_r($country)
54
+ if(in_array($today_day ,$array_new)){
55
+ if($today_date >= $imagestartfrom && $today_date <= $imagestartto)
56
+ {
57
+ if(in_array($usercurrent_country , $country)) {
58
+ echo $collectiondta->getData('title')."<br><img height =".$collectiondta->getData('height')." width = ".$collectiondta->getData('width')." src = ".Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA).$collectiondta->getData('photo')."><br/>".$collectiondta->getData('content')."<br/> ";
59
+ echo "<hr>";
60
+
61
+ }
62
+ }
63
+
64
+ }
65
+ }
66
+ }
67
+
68
+ public function getLocationInfoByIp(){
69
+ $client = @$_SERVER['HTTP_CLIENT_IP'];
70
+ $forward = @$_SERVER['HTTP_X_FORWARDED_FOR'];
71
+ $remote = @$_SERVER['REMOTE_ADDR'];
72
+ $result = array('country'=>'', 'city'=>'');
73
+ if(filter_var($client, FILTER_VALIDATE_IP)){
74
+ $ip = $client;
75
+ }elseif(filter_var($forward, FILTER_VALIDATE_IP)){
76
+ $ip = $forward;
77
+ }else{
78
+ $ip = $remote;
79
+ }
80
+ $ip_data = @json_decode(file_get_contents("http://www.geoplugin.net/json.gp?ip=".$ip));
81
+ if($ip_data && $ip_data->geoplugin_countryName != null){
82
+ $result['country'] = $ip_data->geoplugin_countryCode;
83
+ $result['city'] = $ip_data->geoplugin_city;
84
+ }
85
+ return $result['country'];
86
+ }
87
+
88
+
89
+ }
app/code/local/Ghrix/Campaign/Model/Campaign.php ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Ghrix_Campaign_Model_Campaign extends Mage_Core_Model_Abstract
4
+ {
5
+ protected function _construct(){
6
+
7
+ $this->_init("campaign/campaign");
8
+
9
+ }
10
+
11
+ }
12
+
app/code/local/Ghrix/Campaign/Model/Mysql4/Campaign.php ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Ghrix_Campaign_Model_Mysql4_Campaign extends Mage_Core_Model_Mysql4_Abstract
3
+ {
4
+ protected function _construct()
5
+ {
6
+ $this->_init("campaign/campaign", "id");
7
+ }
8
+ }
app/code/local/Ghrix/Campaign/Model/Mysql4/Campaign/Collection.php ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Ghrix_Campaign_Model_Mysql4_Campaign_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
3
+ {
4
+
5
+ public function _construct(){
6
+ $this->_init("campaign/campaign");
7
+ }
8
+
9
+
10
+
11
+ }
12
+
app/code/local/Ghrix/Campaign/controllers/Adminhtml/CampaignController.php ADDED
@@ -0,0 +1,211 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Ghrix_Campaign_Adminhtml_CampaignController extends Mage_Adminhtml_Controller_Action
4
+ {
5
+ protected function _initAction()
6
+ {
7
+ $this->loadLayout()->_setActiveMenu("campaign/campaign")->_addBreadcrumb(Mage::helper("adminhtml")->__("Campaign Manager"),Mage::helper("adminhtml")->__("Campaign Manager"));
8
+ return $this;
9
+ }
10
+ public function indexAction()
11
+ {
12
+ $this->_title($this->__("Campaign"));
13
+ $this->_title($this->__("Manager Campaign"));
14
+
15
+ $this->_initAction();
16
+ $this->renderLayout();
17
+ }
18
+ public function editAction()
19
+ {
20
+ $this->_title($this->__("Campaign"));
21
+ $this->_title($this->__("Campaign"));
22
+ $this->_title($this->__("Edit Item"));
23
+
24
+ $id = $this->getRequest()->getParam("id");
25
+ $model = Mage::getModel("campaign/campaign")->load($id);
26
+ if ($model->getId()) {
27
+ Mage::register("campaign_data", $model);
28
+ $this->loadLayout();
29
+ $this->_setActiveMenu("campaign/campaign");
30
+ $this->_addBreadcrumb(Mage::helper("adminhtml")->__("Campaign Manager"), Mage::helper("adminhtml")->__("Campaign Manager"));
31
+ $this->_addBreadcrumb(Mage::helper("adminhtml")->__("Campaign Description"), Mage::helper("adminhtml")->__("Campaign Description"));
32
+ $this->getLayout()->getBlock("head")->setCanLoadExtJs(true);
33
+ $this->_addContent($this->getLayout()->createBlock("campaign/adminhtml_campaign_edit"))->_addLeft($this->getLayout()->createBlock("campaign/adminhtml_campaign_edit_tabs"));
34
+ $this->renderLayout();
35
+ }
36
+ else {
37
+ Mage::getSingleton("adminhtml/session")->addError(Mage::helper("campaign")->__("Item does not exist."));
38
+ $this->_redirect("*/*/");
39
+ }
40
+ }
41
+
42
+ public function newAction()
43
+ {
44
+
45
+ $this->_title($this->__("Campaign"));
46
+ $this->_title($this->__("Campaign"));
47
+ $this->_title($this->__("New Item"));
48
+
49
+ $id = $this->getRequest()->getParam("id");
50
+ $model = Mage::getModel("campaign/campaign")->load($id);
51
+
52
+ $data = Mage::getSingleton("adminhtml/session")->getFormData(true);
53
+ if (!empty($data)) {
54
+ $model->setData($data);
55
+ }
56
+
57
+ Mage::register("campaign_data", $model);
58
+
59
+ $this->loadLayout();
60
+ $this->_setActiveMenu("campaign/campaign");
61
+
62
+ $this->getLayout()->getBlock("head")->setCanLoadExtJs(true);
63
+
64
+ $this->_addBreadcrumb(Mage::helper("adminhtml")->__("Campaign Manager"), Mage::helper("adminhtml")->__("Campaign Manager"));
65
+ $this->_addBreadcrumb(Mage::helper("adminhtml")->__("Campaign Description"), Mage::helper("adminhtml")->__("Campaign Description"));
66
+
67
+
68
+ $this->_addContent($this->getLayout()->createBlock("campaign/adminhtml_campaign_edit"))->_addLeft($this->getLayout()->createBlock("campaign/adminhtml_campaign_edit_tabs"));
69
+
70
+ $this->renderLayout();
71
+
72
+ }
73
+ public function saveAction()
74
+ {
75
+
76
+ $post_data=$this->getRequest()->getPost();
77
+
78
+
79
+ if ($post_data) {
80
+
81
+ try {
82
+
83
+
84
+ $post_data['whichday']=implode(',',$post_data['whichday']);
85
+ $post_data['country']=implode(',',$post_data['country']);
86
+ //save image
87
+ try{
88
+
89
+ if((bool)$post_data['photo']['delete']==1) {
90
+
91
+ $post_data['photo']='';
92
+
93
+ }
94
+ else {
95
+
96
+ unset($post_data['photo']);
97
+
98
+ if (isset($_FILES)){
99
+
100
+ if ($_FILES['photo']['name']) {
101
+
102
+ if($this->getRequest()->getParam("id")){
103
+ $model = Mage::getModel("campaign/campaign")->load($this->getRequest()->getParam("id"));
104
+ if($model->getData('photo')){
105
+ $io = new Varien_Io_File();
106
+ $io->rm(Mage::getBaseDir('media').DS.implode(DS,explode('/',$model->getData('photo'))));
107
+ }
108
+ }
109
+ $path = Mage::getBaseDir('media') . DS . 'campaign' . DS .'campaign'.DS;
110
+ $uploader = new Varien_File_Uploader('photo');
111
+ $uploader->setAllowedExtensions(array('jpg','png','gif'));
112
+ $uploader->setAllowRenameFiles(false);
113
+ $uploader->setFilesDispersion(false);
114
+ $destFile = $path.$_FILES['photo']['name'];
115
+ $filename = $uploader->getNewFileName($destFile);
116
+ $uploader->save($path, $filename);
117
+
118
+ $post_data['photo']='campaign/campaign/'.$filename;
119
+ }
120
+ }
121
+ }
122
+
123
+ } catch (Exception $e) {
124
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
125
+ $this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id')));
126
+ return;
127
+ }
128
+ //save image
129
+
130
+
131
+ $model = Mage::getModel("campaign/campaign")
132
+ ->addData($post_data)
133
+ ->setId($this->getRequest()->getParam("id"))
134
+ ->save();
135
+
136
+ Mage::getSingleton("adminhtml/session")->addSuccess(Mage::helper("adminhtml")->__("Campaign was successfully saved"));
137
+ Mage::getSingleton("adminhtml/session")->setCampaignData(false);
138
+
139
+ if ($this->getRequest()->getParam("back")) {
140
+ $this->_redirect("*/*/edit", array("id" => $model->getId()));
141
+ return;
142
+ }
143
+ $this->_redirect("*/*/");
144
+ return;
145
+ }
146
+ catch (Exception $e) {
147
+ Mage::getSingleton("adminhtml/session")->addError($e->getMessage());
148
+ Mage::getSingleton("adminhtml/session")->setCampaignData($this->getRequest()->getPost());
149
+ $this->_redirect("*/*/edit", array("id" => $this->getRequest()->getParam("id")));
150
+ return;
151
+ }
152
+
153
+ }
154
+ $this->_redirect("*/*/");
155
+ }
156
+
157
+
158
+
159
+ public function deleteAction()
160
+ {
161
+ if( $this->getRequest()->getParam("id") > 0 ) {
162
+ try {
163
+ $model = Mage::getModel("campaign/campaign");
164
+ $model->setId($this->getRequest()->getParam("id"))->delete();
165
+ Mage::getSingleton("adminhtml/session")->addSuccess(Mage::helper("adminhtml")->__("Item was successfully deleted"));
166
+ $this->_redirect("*/*/");
167
+ }
168
+ catch (Exception $e) {
169
+ Mage::getSingleton("adminhtml/session")->addError($e->getMessage());
170
+ $this->_redirect("*/*/edit", array("id" => $this->getRequest()->getParam("id")));
171
+ }
172
+ }
173
+ $this->_redirect("*/*/");
174
+ }
175
+
176
+
177
+ public function massRemoveAction()
178
+ {
179
+ try {
180
+ $ids = $this->getRequest()->getPost('ids', array());
181
+ foreach ($ids as $id) {
182
+ $model = Mage::getModel("campaign/campaign");
183
+ $model->setId($id)->delete();
184
+ }
185
+ Mage::getSingleton("adminhtml/session")->addSuccess(Mage::helper("adminhtml")->__("Item(s) was successfully removed"));
186
+ }
187
+ catch (Exception $e) {
188
+ Mage::getSingleton("adminhtml/session")->addError($e->getMessage());
189
+ }
190
+ $this->_redirect('*/*/');
191
+ }
192
+
193
+ /**
194
+ * Export order grid to CSV format
195
+ */
196
+ public function exportCsvAction()
197
+ {
198
+ $fileName = 'campaign.csv';
199
+ $grid = $this->getLayout()->createBlock('campaign/adminhtml_campaign_grid');
200
+ $this->_prepareDownloadResponse($fileName, $grid->getCsvFile());
201
+ }
202
+ /**
203
+ * Export order grid to Excel XML format
204
+ */
205
+ public function exportExcelAction()
206
+ {
207
+ $fileName = 'campaign.xml';
208
+ $grid = $this->getLayout()->createBlock('campaign/adminhtml_campaign_grid');
209
+ $this->_prepareDownloadResponse($fileName, $grid->getExcelFile($fileName));
210
+ }
211
+ }
app/code/local/Ghrix/Campaign/controllers/IndexController.php ADDED
@@ -0,0 +1,76 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Ghrix_Campaign_IndexController extends Mage_Core_Controller_Front_Action{
3
+ public function IndexAction() {
4
+ $usercurrent_country = $this->getLocationInfoByIp();
5
+
6
+ $collection = Mage::getModel("campaign/campaign")->getCollection()->addFieldToFilter("positon", 'content')
7
+ ->addFieldToFilter("enable", "1")
8
+ // ->addFieldToFilter("id", "2")
9
+
10
+ ->addOrder('pos','DES');
11
+
12
+ foreach ($collection as $collectiondta)
13
+ {
14
+
15
+ $getcountry = explode(',' , $collectiondta->getData('country'));
16
+
17
+ if(is_array($getcountry)){
18
+ $country = explode(',' , $collectiondta->getData('country')) ;
19
+ }else{
20
+ $country['0'] = $collectiondta->getData('country') ;
21
+ }
22
+ $imagestartfrom = strtotime($collectiondta->getData('startfrom'));
23
+ $imagestartto = strtotime($collectiondta->getData('startto'));
24
+ echo "<br/>";
25
+ $today_day = strtolower(date( "l")); // get current day
26
+ $today_date = time();
27
+ //echo "<br/>";
28
+
29
+ // to get days from the ids storre in the db
30
+ $imagewhichday = explode(',' , $collectiondta->getData('whichday'));
31
+ $dayasarray = Ghrix_Campaign_Block_Adminhtml_Campaign_Grid::getOptionArray10(); // get defined whichdays arrays
32
+ $array_new = [];
33
+ foreach($imagewhichday as $key)
34
+ {
35
+ if(array_key_exists($key, $dayasarray))
36
+ {
37
+ $array_new[$key] = $dayasarray[$key];
38
+ }
39
+ }
40
+ // end to get days from the ids storre in the db
41
+ print_r($usercurrent_country);
42
+ if(in_array($today_day ,$array_new)){
43
+ if($today_date >= $imagestartfrom && $today_date <= $imagestartto)
44
+ {
45
+ if(in_array($usercurrent_country , $country)) {
46
+ print_r($usercurrent_country);
47
+
48
+ echo $collectiondta->getData('title')."<br><img height =".$collectiondta->getData('height')." width = ".$collectiondta->getData('width')." src = ".Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA).$collectiondta->getData('photo')."><br/>".$collectiondta->getData('content')."<br/> ";
49
+ }
50
+ }
51
+ }
52
+ }
53
+ }
54
+
55
+ public function getLocationInfoByIp(){
56
+ $client = @$_SERVER['HTTP_CLIENT_IP'];
57
+ $forward = @$_SERVER['HTTP_X_FORWARDED_FOR'];
58
+ $remote = @$_SERVER['REMOTE_ADDR'];
59
+ $result = array('country'=>'', 'city'=>'');
60
+ if(filter_var($client, FILTER_VALIDATE_IP)){
61
+ $ip = $client;
62
+ }elseif(filter_var($forward, FILTER_VALIDATE_IP)){
63
+ $ip = $forward;
64
+ }else{
65
+ $ip = $remote;
66
+ }
67
+ $ip_data = @json_decode(file_get_contents("http://www.geoplugin.net/json.gp?ip=".$ip));
68
+ if($ip_data && $ip_data->geoplugin_countryName != null){
69
+ $result['country'] = $ip_data->geoplugin_countryCode;
70
+ $result['city'] = $ip_data->geoplugin_city;
71
+ }
72
+ return $result['country'];
73
+ }
74
+
75
+
76
+ }
app/code/local/Ghrix/Campaign/etc/config.xml ADDED
@@ -0,0 +1,126 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Ghrix_Campaign>
5
+ <version>0.1.0</version>
6
+ </Ghrix_Campaign>
7
+ </modules>
8
+ <frontend>
9
+ <routers>
10
+ <campaign>
11
+ <use>standard</use>
12
+ <args>
13
+ <module>Ghrix_Campaign</module>
14
+ <frontName>campaign</frontName>
15
+ </args>
16
+ </campaign>
17
+ </routers>
18
+ <layout>
19
+ <updates>
20
+ <campaign>
21
+ <file>campaign.xml</file>
22
+ </campaign>
23
+ </updates>
24
+ </layout>
25
+ </frontend>
26
+ <global>
27
+ <helpers>
28
+ <campaign>
29
+ <class>Ghrix_Campaign_Helper</class>
30
+ </campaign>
31
+ </helpers>
32
+ <blocks>
33
+ <campaign>
34
+ <class>Ghrix_Campaign_Block</class>
35
+ </campaign>
36
+ </blocks>
37
+ <models>
38
+ <campaign>
39
+ <class>Ghrix_Campaign_Model</class>
40
+ <resourceModel>campaign_mysql4</resourceModel>
41
+ </campaign>
42
+ <campaign_mysql4>
43
+ <class>Ghrix_Campaign_Model_Mysql4</class>
44
+ <entities>
45
+ <campaign>
46
+ <table>campaign</table>
47
+ </campaign>
48
+ </entities>
49
+ </campaign_mysql4>
50
+ </models>
51
+ <resources>
52
+ <campaign_setup>
53
+ <setup>
54
+ <module>Ghrix_Campaign</module>
55
+ </setup>
56
+ <connection>
57
+ <use>core_setup</use>
58
+ </connection>
59
+ </campaign_setup>
60
+ <campaign_write>
61
+ <connection>
62
+ <use>core_write</use>
63
+ </connection>
64
+ </campaign_write>
65
+ <campaign_read>
66
+ <connection>
67
+ <use>core_read</use>
68
+ </connection>
69
+ </campaign_read>
70
+ </resources>
71
+ </global>
72
+ <admin>
73
+ <routers>
74
+ <campaign>
75
+ <use>admin</use>
76
+ <args>
77
+ <module>Ghrix_Campaign</module>
78
+ <frontName>admin_campaign</frontName>
79
+ </args>
80
+ </campaign>
81
+ </routers>
82
+ </admin>
83
+ <adminhtml>
84
+ <menu>
85
+ <campaign module="campaign">
86
+ <title>Campaign</title>
87
+ <sort_order>100</sort_order>
88
+ <children>
89
+ <campaign module="campaign">
90
+ <title>Manage Campaign</title>
91
+ <sort_order>0</sort_order>
92
+ <action>admin_campaign/adminhtml_campaign</action>
93
+ </campaign>
94
+ </children>
95
+ </campaign>
96
+ </menu>
97
+ <acl>
98
+ <resources>
99
+ <all>
100
+ <title>Allow Everything</title>
101
+ </all>
102
+ <admin>
103
+ <children>
104
+ <campaign translate="title" module="campaign">
105
+ <title>Campaign</title>
106
+ <sort_order>1000</sort_order>
107
+ <children>
108
+ <campaign translate="title">
109
+ <title>Manage Campaign</title>
110
+ <sort_order>0</sort_order>
111
+ </campaign>
112
+ </children>
113
+ </campaign>
114
+ </children>
115
+ </admin>
116
+ </resources>
117
+ </acl>
118
+ <layout>
119
+ <updates>
120
+ <campaign>
121
+ <file>campaign.xml</file>
122
+ </campaign>
123
+ </updates>
124
+ </layout>
125
+ </adminhtml>
126
+ </config>
app/code/local/Ghrix/Campaign/sql/campaign_setup/mysql4-install-0.1.0.php ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ $installer = $this;
3
+ $installer->startSetup();
4
+ $sql=<<<SQLTEXT
5
+ create table campaign(id int not null auto_increment,
6
+ title varchar(255),
7
+ positon varchar(255),
8
+ content varchar(9999),
9
+ photo varchar(255),
10
+ width varchar(255),
11
+ height varchar(255),
12
+ country varchar(255),
13
+ startfrom varchar(255),
14
+ startto varchar(255),
15
+ whichday varchar(255),
16
+ enable int(1),
17
+ pos varchar(255),
18
+ primary key(id));
19
+
20
+ SQLTEXT;
21
+
22
+ $installer->run($sql);
23
+ //demo
24
+ //Mage::getModel('core/url_rewrite')->setId(null);
25
+ //demo
26
+ $installer->endSetup();
27
+
app/code/local/Ghrix/Campaignmanager/Block/Adminhtml/Campaignmanager.php ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+
4
+ class Ghrix_Campaignmanager_Block_Adminhtml_Campaignmanager extends Mage_Adminhtml_Block_Widget_Grid_Container{
5
+
6
+ public function __construct()
7
+ {
8
+
9
+ $this->_controller = "adminhtml_campaignmanager";
10
+ $this->_blockGroup = "campaignmanager";
11
+ $this->_headerText = Mage::helper("campaignmanager")->__("Campaignmanager Manager");
12
+ $this->_addButtonLabel = Mage::helper("campaignmanager")->__("Add New Item");
13
+ parent::__construct();
14
+
15
+ }
16
+
17
+ }
app/code/local/Ghrix/Campaignmanager/Block/Adminhtml/Campaignmanager/Edit.php ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Ghrix_Campaignmanager_Block_Adminhtml_Campaignmanager_Edit extends Mage_Adminhtml_Block_Widget_Form_Container
4
+ {
5
+ public function __construct()
6
+ {
7
+
8
+ parent::__construct();
9
+ $this->_objectId = "id";
10
+ $this->_blockGroup = "campaignmanager";
11
+ $this->_controller = "adminhtml_campaignmanager";
12
+ $this->_updateButton("save", "label", Mage::helper("campaignmanager")->__("Save Item"));
13
+ $this->_updateButton("delete", "label", Mage::helper("campaignmanager")->__("Delete Item"));
14
+
15
+ $this->_addButton("saveandcontinue", array(
16
+ "label" => Mage::helper("campaignmanager")->__("Save And Continue Edit"),
17
+ "onclick" => "saveAndContinueEdit()",
18
+ "class" => "save",
19
+ ), -100);
20
+
21
+
22
+
23
+ $this->_formScripts[] = "
24
+
25
+ function saveAndContinueEdit(){
26
+ editForm.submit($('edit_form').action+'back/edit/');
27
+ }
28
+ ";
29
+ }
30
+
31
+ public function getHeaderText()
32
+ {
33
+ if( Mage::registry("campaignmanager_data") && Mage::registry("campaignmanager_data")->getId() ){
34
+
35
+ return Mage::helper("campaignmanager")->__("Edit Item '%s'", $this->htmlEscape(Mage::registry("campaignmanager_data")->getId()));
36
+
37
+ }
38
+ else{
39
+
40
+ return Mage::helper("campaignmanager")->__("Add Item");
41
+
42
+ }
43
+ }
44
+ }
app/code/local/Ghrix/Campaignmanager/Block/Adminhtml/Campaignmanager/Edit/Form.php ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Ghrix_Campaignmanager_Block_Adminhtml_Campaignmanager_Edit_Form extends Mage_Adminhtml_Block_Widget_Form
3
+ {
4
+ protected function _prepareForm()
5
+ {
6
+ $form = new Varien_Data_Form(array(
7
+ "id" => "edit_form",
8
+ "action" => $this->getUrl("*/*/save", array("id" => $this->getRequest()->getParam("id"))),
9
+ "method" => "post",
10
+ "enctype" =>"multipart/form-data",
11
+ )
12
+ );
13
+ $form->setUseContainer(true);
14
+ $this->setForm($form);
15
+ return parent::_prepareForm();
16
+ }
17
+ }
app/code/local/Ghrix/Campaignmanager/Block/Adminhtml/Campaignmanager/Edit/Tab/Form.php ADDED
@@ -0,0 +1,97 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Ghrix_Campaignmanager_Block_Adminhtml_Campaignmanager_Edit_Tab_Form extends Mage_Adminhtml_Block_Widget_Form
3
+ {
4
+ protected function _prepareForm()
5
+ {
6
+
7
+ $form = new Varien_Data_Form();
8
+ $this->setForm($form);
9
+ $fieldset = $form->addFieldset("campaignmanager_form", array("legend"=>Mage::helper("campaignmanager")->__("Item information")));
10
+
11
+
12
+ $fieldset->addField("id", "text", array(
13
+ "label" => Mage::helper("campaignmanager")->__("id"),
14
+ "class" => "required-entry",
15
+ "required" => true,
16
+ "name" => "id",
17
+ ));
18
+
19
+ $fieldset->addField("title", "text", array(
20
+ "label" => Mage::helper("campaignmanager")->__("title"),
21
+ "name" => "title",
22
+ ));
23
+
24
+ $fieldset->addField("content", "text", array(
25
+ "label" => Mage::helper("campaignmanager")->__("content"),
26
+ "name" => "content",
27
+ ));
28
+
29
+ $fieldset->addField("positon", "text", array(
30
+ "label" => Mage::helper("campaignmanager")->__("positon"),
31
+ "name" => "positon",
32
+ ));
33
+
34
+ $fieldset->addField('photo', 'image', array(
35
+ 'label' => Mage::helper('campaignmanager')->__('photo'),
36
+ 'name' => 'photo',
37
+ 'note' => '(*.jpg, *.png, *.gif)',
38
+ ));
39
+ $fieldset->addField("width", "text", array(
40
+ "label" => Mage::helper("campaignmanager")->__("width"),
41
+ "name" => "width",
42
+ ));
43
+
44
+ $fieldset->addField("height", "text", array(
45
+ "label" => Mage::helper("campaignmanager")->__("height"),
46
+ "name" => "height",
47
+ ));
48
+
49
+ $fieldset->addField('country', 'select', array(
50
+ 'label' => Mage::helper('campaignmanager')->__('country'),
51
+ 'values' => Ghrix_Campaignmanager_Block_Adminhtml_Campaignmanager_Grid::getValueArray7(),
52
+ 'name' => 'country',
53
+ ));
54
+ $dateFormatIso = Mage::app()->getLocale()->getDateTimeFormat(
55
+ Mage_Core_Model_Locale::FORMAT_TYPE_SHORT
56
+ );
57
+
58
+ $fieldset->addField('startfrom', 'date', array(
59
+ 'label' => Mage::helper('campaignmanager')->__('startfrom'),
60
+ 'name' => 'startfrom',
61
+ 'time' => true,
62
+ 'image' => $this->getSkinUrl('images/grid-cal.gif'),
63
+ 'format' => $dateFormatIso
64
+ ));
65
+ $dateFormatIso = Mage::app()->getLocale()->getDateTimeFormat(
66
+ Mage_Core_Model_Locale::FORMAT_TYPE_SHORT
67
+ );
68
+
69
+ $fieldset->addField('startto', 'date', array(
70
+ 'label' => Mage::helper('campaignmanager')->__('startto'),
71
+ 'name' => 'startto',
72
+ 'time' => true,
73
+ 'image' => $this->getSkinUrl('images/grid-cal.gif'),
74
+ 'format' => $dateFormatIso
75
+ ));
76
+ $fieldset->addField('whichday', 'multiselect', array(
77
+ 'label' => Mage::helper('campaignmanager')->__('whichday'),
78
+ 'values' => Ghrix_Campaignmanager_Block_Adminhtml_Campaignmanager_Grid::getValueArray10(),
79
+ 'name' => 'whichday',
80
+ ));
81
+ $fieldset->addField("enable", "text", array(
82
+ "label" => Mage::helper("campaignmanager")->__("enable"),
83
+ "name" => "enable",
84
+ ));
85
+
86
+
87
+ if (Mage::getSingleton("adminhtml/session")->getCampaignmanagerData())
88
+ {
89
+ $form->setValues(Mage::getSingleton("adminhtml/session")->getCampaignmanagerData());
90
+ Mage::getSingleton("adminhtml/session")->setCampaignmanagerData(null);
91
+ }
92
+ elseif(Mage::registry("campaignmanager_data")) {
93
+ $form->setValues(Mage::registry("campaignmanager_data")->getData());
94
+ }
95
+ return parent::_prepareForm();
96
+ }
97
+ }
app/code/local/Ghrix/Campaignmanager/Block/Adminhtml/Campaignmanager/Edit/Tabs.php ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Ghrix_Campaignmanager_Block_Adminhtml_Campaignmanager_Edit_Tabs extends Mage_Adminhtml_Block_Widget_Tabs
3
+ {
4
+ public function __construct()
5
+ {
6
+ parent::__construct();
7
+ $this->setId("campaignmanager_tabs");
8
+ $this->setDestElementId("edit_form");
9
+ $this->setTitle(Mage::helper("campaignmanager")->__("Item Information"));
10
+ }
11
+ protected function _beforeToHtml()
12
+ {
13
+ $this->addTab("form_section", array(
14
+ "label" => Mage::helper("campaignmanager")->__("Item Information"),
15
+ "title" => Mage::helper("campaignmanager")->__("Item Information"),
16
+ "content" => $this->getLayout()->createBlock("campaignmanager/adminhtml_campaignmanager_edit_tab_form")->toHtml(),
17
+ ));
18
+ return parent::_beforeToHtml();
19
+ }
20
+
21
+ }
app/code/local/Ghrix/Campaignmanager/Block/Adminhtml/Campaignmanager/Grid.php ADDED
@@ -0,0 +1,140 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Ghrix_Campaignmanager_Block_Adminhtml_Campaignmanager_Grid extends Mage_Adminhtml_Block_Widget_Grid
4
+ {
5
+
6
+ public function __construct()
7
+ {
8
+ parent::__construct();
9
+ $this->setId("campaignmanagerGrid");
10
+ $this->setDefaultSort("id");
11
+ $this->setDefaultDir("DESC");
12
+ $this->setSaveParametersInSession(true);
13
+ }
14
+
15
+ protected function _prepareCollection()
16
+ {
17
+ $collection = Mage::getModel("campaignmanager/campaignmanager")->getCollection();
18
+ $this->setCollection($collection);
19
+ return parent::_prepareCollection();
20
+ }
21
+ protected function _prepareColumns()
22
+ {
23
+ $this->addColumn("id", array(
24
+ "header" => Mage::helper("campaignmanager")->__("ID"),
25
+ "align" =>"right",
26
+ "width" => "50px",
27
+ "type" => "number",
28
+ "index" => "id",
29
+ ));
30
+
31
+ $this->addColumn("title", array(
32
+ "header" => Mage::helper("campaignmanager")->__("title"),
33
+ "index" => "title",
34
+ ));
35
+ $this->addColumn("content", array(
36
+ "header" => Mage::helper("campaignmanager")->__("content"),
37
+ "index" => "content",
38
+ ));
39
+ $this->addColumn("positon", array(
40
+ "header" => Mage::helper("campaignmanager")->__("positon"),
41
+ "index" => "positon",
42
+ ));
43
+ $this->addColumn("width", array(
44
+ "header" => Mage::helper("campaignmanager")->__("width"),
45
+ "index" => "width",
46
+ ));
47
+ $this->addColumn("height", array(
48
+ "header" => Mage::helper("campaignmanager")->__("height"),
49
+ "index" => "height",
50
+ ));
51
+ $this->addColumn('country', array(
52
+ 'header' => Mage::helper('campaignmanager')->__('country'),
53
+ 'index' => 'country',
54
+ 'type' => 'options',
55
+ 'options'=>Ghrix_Campaignmanager_Block_Adminhtml_Campaignmanager_Grid::getOptionArray7(),
56
+ ));
57
+
58
+ $this->addColumn('startfrom', array(
59
+ 'header' => Mage::helper('campaignmanager')->__('startfrom'),
60
+ 'index' => 'startfrom',
61
+ 'type' => 'datetime',
62
+ ));
63
+ $this->addColumn('startto', array(
64
+ 'header' => Mage::helper('campaignmanager')->__('startto'),
65
+ 'index' => 'startto',
66
+ 'type' => 'datetime',
67
+ ));
68
+ $this->addColumn("enable", array(
69
+ "header" => Mage::helper("campaignmanager")->__("enable"),
70
+ "index" => "enable",
71
+ ));
72
+ $this->addExportType('*/*/exportCsv', Mage::helper('sales')->__('CSV'));
73
+ $this->addExportType('*/*/exportExcel', Mage::helper('sales')->__('Excel'));
74
+
75
+ return parent::_prepareColumns();
76
+ }
77
+
78
+ public function getRowUrl($row)
79
+ {
80
+ return $this->getUrl("*/*/edit", array("id" => $row->getId()));
81
+ }
82
+
83
+
84
+
85
+ protected function _prepareMassaction()
86
+ {
87
+ $this->setMassactionIdField('id');
88
+ $this->getMassactionBlock()->setFormFieldName('ids');
89
+ $this->getMassactionBlock()->setUseSelectAll(true);
90
+ $this->getMassactionBlock()->addItem('remove_campaignmanager', array(
91
+ 'label'=> Mage::helper('campaignmanager')->__('Remove Campaignmanager'),
92
+ 'url' => $this->getUrl('*/adminhtml_campaignmanager/massRemove'),
93
+ 'confirm' => Mage::helper('campaignmanager')->__('Are you sure?')
94
+ ));
95
+ return $this;
96
+ }
97
+
98
+ static public function getOptionArray7()
99
+ {
100
+ $data_array=array();
101
+ $data_array[0]='india';
102
+ $data_array[1]='us';
103
+ return($data_array);
104
+ }
105
+ static public function getValueArray7()
106
+ {
107
+ $data_array=array();
108
+ foreach(Ghrix_Campaignmanager_Block_Adminhtml_Campaignmanager_Grid::getOptionArray7() as $k=>$v){
109
+ $data_array[]=array('value'=>$k,'label'=>$v);
110
+ }
111
+ return($data_array);
112
+
113
+ }
114
+
115
+ static public function getOptionArray10()
116
+ {
117
+ $data_array=array();
118
+ $data_array[0]='weekday';
119
+ $data_array[1]='weekend';
120
+ $data_array[2]='monday';
121
+ $data_array[3]='tuesday';
122
+ $data_array[4]='wednesday';
123
+ $data_array[5]='thursday';
124
+ $data_array[6]='friday';
125
+ $data_array[7]='saturday';
126
+ $data_array[8]='sunday';
127
+ return($data_array);
128
+ }
129
+ static public function getValueArray10()
130
+ {
131
+ $data_array=array();
132
+ foreach(Ghrix_Campaignmanager_Block_Adminhtml_Campaignmanager_Grid::getOptionArray10() as $k=>$v){
133
+ $data_array[]=array('value'=>$k,'label'=>$v);
134
+ }
135
+ return($data_array);
136
+
137
+ }
138
+
139
+
140
+ }
app/code/local/Ghrix/Campaignmanager/Block/Adminhtml/Campaignmanagerbackend.php ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
1
+ <?php
2
+
3
+ class Ghrix_Campaignmanager_Block_Adminhtml_Campaignmanagerbackend extends Mage_Adminhtml_Block_Template {
4
+
5
+ }
app/code/local/Ghrix/Campaignmanager/Block/Index.php ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Ghrix_Campaignmanager_Block_Index extends Mage_Core_Block_Template{
3
+
4
+
5
+
6
+
7
+
8
+ }
app/code/local/Ghrix/Campaignmanager/Helper/Data.php ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
1
+ <?php
2
+ class Ghrix_Campaignmanager_Helper_Data extends Mage_Core_Helper_Abstract
3
+ {
4
+ }
5
+
app/code/local/Ghrix/Campaignmanager/Model/Campaignmanager.php ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Ghrix_Campaignmanager_Model_Campaignmanager extends Mage_Core_Model_Abstract
4
+ {
5
+ protected function _construct(){
6
+
7
+ $this->_init("campaignmanager/campaignmanager");
8
+
9
+ }
10
+
11
+ }
12
+
app/code/local/Ghrix/Campaignmanager/Model/Mysql4/Campaignmanager.php ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Ghrix_Campaignmanager_Model_Mysql4_Campaignmanager extends Mage_Core_Model_Mysql4_Abstract
3
+ {
4
+ protected function _construct()
5
+ {
6
+ $this->_init("campaignmanager/campaignmanager", "id");
7
+ }
8
+ }
app/code/local/Ghrix/Campaignmanager/Model/Mysql4/Campaignmanager/Collection.php ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Ghrix_Campaignmanager_Model_Mysql4_Campaignmanager_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
3
+ {
4
+
5
+ public function _construct(){
6
+ $this->_init("campaignmanager/campaignmanager");
7
+ }
8
+
9
+
10
+
11
+ }
12
+
app/code/local/Ghrix/Campaignmanager/controllers/Adminhtml/CampaignmanagerController.php ADDED
@@ -0,0 +1,210 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Ghrix_Campaignmanager_Adminhtml_CampaignmanagerController extends Mage_Adminhtml_Controller_Action
4
+ {
5
+ protected function _initAction()
6
+ {
7
+ $this->loadLayout()->_setActiveMenu("campaignmanager/campaignmanager")->_addBreadcrumb(Mage::helper("adminhtml")->__("Campaignmanager Manager"),Mage::helper("adminhtml")->__("Campaignmanager Manager"));
8
+ return $this;
9
+ }
10
+ public function indexAction()
11
+ {
12
+ $this->_title($this->__("Campaignmanager"));
13
+ $this->_title($this->__("Manager Campaignmanager"));
14
+
15
+ $this->_initAction();
16
+ $this->renderLayout();
17
+ }
18
+ public function editAction()
19
+ {
20
+ $this->_title($this->__("Campaignmanager"));
21
+ $this->_title($this->__("Campaignmanager"));
22
+ $this->_title($this->__("Edit Item"));
23
+
24
+ $id = $this->getRequest()->getParam("id");
25
+ $model = Mage::getModel("campaignmanager/campaignmanager")->load($id);
26
+ if ($model->getId()) {
27
+ Mage::register("campaignmanager_data", $model);
28
+ $this->loadLayout();
29
+ $this->_setActiveMenu("campaignmanager/campaignmanager");
30
+ $this->_addBreadcrumb(Mage::helper("adminhtml")->__("Campaignmanager Manager"), Mage::helper("adminhtml")->__("Campaignmanager Manager"));
31
+ $this->_addBreadcrumb(Mage::helper("adminhtml")->__("Campaignmanager Description"), Mage::helper("adminhtml")->__("Campaignmanager Description"));
32
+ $this->getLayout()->getBlock("head")->setCanLoadExtJs(true);
33
+ $this->_addContent($this->getLayout()->createBlock("campaignmanager/adminhtml_campaignmanager_edit"))->_addLeft($this->getLayout()->createBlock("campaignmanager/adminhtml_campaignmanager_edit_tabs"));
34
+ $this->renderLayout();
35
+ }
36
+ else {
37
+ Mage::getSingleton("adminhtml/session")->addError(Mage::helper("campaignmanager")->__("Item does not exist."));
38
+ $this->_redirect("*/*/");
39
+ }
40
+ }
41
+
42
+ public function newAction()
43
+ {
44
+
45
+ $this->_title($this->__("Campaignmanager"));
46
+ $this->_title($this->__("Campaignmanager"));
47
+ $this->_title($this->__("New Item"));
48
+
49
+ $id = $this->getRequest()->getParam("id");
50
+ $model = Mage::getModel("campaignmanager/campaignmanager")->load($id);
51
+
52
+ $data = Mage::getSingleton("adminhtml/session")->getFormData(true);
53
+ if (!empty($data)) {
54
+ $model->setData($data);
55
+ }
56
+
57
+ Mage::register("campaignmanager_data", $model);
58
+
59
+ $this->loadLayout();
60
+ $this->_setActiveMenu("campaignmanager/campaignmanager");
61
+
62
+ $this->getLayout()->getBlock("head")->setCanLoadExtJs(true);
63
+
64
+ $this->_addBreadcrumb(Mage::helper("adminhtml")->__("Campaignmanager Manager"), Mage::helper("adminhtml")->__("Campaignmanager Manager"));
65
+ $this->_addBreadcrumb(Mage::helper("adminhtml")->__("Campaignmanager Description"), Mage::helper("adminhtml")->__("Campaignmanager Description"));
66
+
67
+
68
+ $this->_addContent($this->getLayout()->createBlock("campaignmanager/adminhtml_campaignmanager_edit"))->_addLeft($this->getLayout()->createBlock("campaignmanager/adminhtml_campaignmanager_edit_tabs"));
69
+
70
+ $this->renderLayout();
71
+
72
+ }
73
+ public function saveAction()
74
+ {
75
+
76
+ $post_data=$this->getRequest()->getPost();
77
+
78
+
79
+ if ($post_data) {
80
+
81
+ try {
82
+
83
+
84
+ $post_data['whichday']=implode(',',$post_data['whichday']);
85
+ //save image
86
+ try{
87
+
88
+ if((bool)$post_data['photo']['delete']==1) {
89
+
90
+ $post_data['photo']='';
91
+
92
+ }
93
+ else {
94
+
95
+ unset($post_data['photo']);
96
+
97
+ if (isset($_FILES)){
98
+
99
+ if ($_FILES['photo']['name']) {
100
+
101
+ if($this->getRequest()->getParam("id")){
102
+ $model = Mage::getModel("campaignmanager/campaignmanager")->load($this->getRequest()->getParam("id"));
103
+ if($model->getData('photo')){
104
+ $io = new Varien_Io_File();
105
+ $io->rm(Mage::getBaseDir('media').DS.implode(DS,explode('/',$model->getData('photo'))));
106
+ }
107
+ }
108
+ $path = Mage::getBaseDir('media') . DS . 'campaignmanager' . DS .'campaignmanager'.DS;
109
+ $uploader = new Varien_File_Uploader('photo');
110
+ $uploader->setAllowedExtensions(array('jpg','png','gif'));
111
+ $uploader->setAllowRenameFiles(false);
112
+ $uploader->setFilesDispersion(false);
113
+ $destFile = $path.$_FILES['photo']['name'];
114
+ $filename = $uploader->getNewFileName($destFile);
115
+ $uploader->save($path, $filename);
116
+
117
+ $post_data['photo']='campaignmanager/campaignmanager/'.$filename;
118
+ }
119
+ }
120
+ }
121
+
122
+ } catch (Exception $e) {
123
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
124
+ $this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id')));
125
+ return;
126
+ }
127
+ //save image
128
+
129
+
130
+ $model = Mage::getModel("campaignmanager/campaignmanager")
131
+ ->addData($post_data)
132
+ ->setId($this->getRequest()->getParam("id"))
133
+ ->save();
134
+
135
+ Mage::getSingleton("adminhtml/session")->addSuccess(Mage::helper("adminhtml")->__("Campaignmanager was successfully saved"));
136
+ Mage::getSingleton("adminhtml/session")->setCampaignmanagerData(false);
137
+
138
+ if ($this->getRequest()->getParam("back")) {
139
+ $this->_redirect("*/*/edit", array("id" => $model->getId()));
140
+ return;
141
+ }
142
+ $this->_redirect("*/*/");
143
+ return;
144
+ }
145
+ catch (Exception $e) {
146
+ Mage::getSingleton("adminhtml/session")->addError($e->getMessage());
147
+ Mage::getSingleton("adminhtml/session")->setCampaignmanagerData($this->getRequest()->getPost());
148
+ $this->_redirect("*/*/edit", array("id" => $this->getRequest()->getParam("id")));
149
+ return;
150
+ }
151
+
152
+ }
153
+ $this->_redirect("*/*/");
154
+ }
155
+
156
+
157
+
158
+ public function deleteAction()
159
+ {
160
+ if( $this->getRequest()->getParam("id") > 0 ) {
161
+ try {
162
+ $model = Mage::getModel("campaignmanager/campaignmanager");
163
+ $model->setId($this->getRequest()->getParam("id"))->delete();
164
+ Mage::getSingleton("adminhtml/session")->addSuccess(Mage::helper("adminhtml")->__("Item was successfully deleted"));
165
+ $this->_redirect("*/*/");
166
+ }
167
+ catch (Exception $e) {
168
+ Mage::getSingleton("adminhtml/session")->addError($e->getMessage());
169
+ $this->_redirect("*/*/edit", array("id" => $this->getRequest()->getParam("id")));
170
+ }
171
+ }
172
+ $this->_redirect("*/*/");
173
+ }
174
+
175
+
176
+ public function massRemoveAction()
177
+ {
178
+ try {
179
+ $ids = $this->getRequest()->getPost('ids', array());
180
+ foreach ($ids as $id) {
181
+ $model = Mage::getModel("campaignmanager/campaignmanager");
182
+ $model->setId($id)->delete();
183
+ }
184
+ Mage::getSingleton("adminhtml/session")->addSuccess(Mage::helper("adminhtml")->__("Item(s) was successfully removed"));
185
+ }
186
+ catch (Exception $e) {
187
+ Mage::getSingleton("adminhtml/session")->addError($e->getMessage());
188
+ }
189
+ $this->_redirect('*/*/');
190
+ }
191
+
192
+ /**
193
+ * Export order grid to CSV format
194
+ */
195
+ public function exportCsvAction()
196
+ {
197
+ $fileName = 'campaignmanager.csv';
198
+ $grid = $this->getLayout()->createBlock('campaignmanager/adminhtml_campaignmanager_grid');
199
+ $this->_prepareDownloadResponse($fileName, $grid->getCsvFile());
200
+ }
201
+ /**
202
+ * Export order grid to Excel XML format
203
+ */
204
+ public function exportExcelAction()
205
+ {
206
+ $fileName = 'campaignmanager.xml';
207
+ $grid = $this->getLayout()->createBlock('campaignmanager/adminhtml_campaignmanager_grid');
208
+ $this->_prepareDownloadResponse($fileName, $grid->getExcelFile($fileName));
209
+ }
210
+ }
app/code/local/Ghrix/Campaignmanager/controllers/Adminhtml/CampaignmanagerbackendController.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Ghrix_Campaignmanager_Adminhtml_CampaignmanagerbackendController extends Mage_Adminhtml_Controller_Action
3
+ {
4
+ public function indexAction()
5
+ {
6
+ $this->loadLayout();
7
+ $this->_title($this->__("Campaignmanager"));
8
+ $this->renderLayout();
9
+ }
10
+ }
app/code/local/Ghrix/Campaignmanager/controllers/IndexController.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Ghrix_Campaignmanager_IndexController extends Mage_Core_Controller_Front_Action{
3
+ public function IndexAction() {
4
+
5
+ $this->loadLayout();
6
+ $this->getLayout()->getBlock("head")->setTitle($this->__("Titlename"));
7
+ $breadcrumbs = $this->getLayout()->getBlock("breadcrumbs");
8
+ $breadcrumbs->addCrumb("home", array(
9
+ "label" => $this->__("Home Page"),
10
+ "title" => $this->__("Home Page"),
11
+ "link" => Mage::getBaseUrl()
12
+ ));
13
+
14
+ $breadcrumbs->addCrumb("titlename", array(
15
+ "label" => $this->__("Titlename"),
16
+ "title" => $this->__("Titlename")
17
+ ));
18
+
19
+ $this->renderLayout();
20
+
21
+ }
22
+ }
app/code/local/Ghrix/Campaignmanager/etc/config.xml ADDED
@@ -0,0 +1,134 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Ghrix_Campaignmanager>
5
+ <version>0.1.0</version>
6
+ </Ghrix_Campaignmanager>
7
+ </modules>
8
+ <frontend>
9
+ <routers>
10
+ <campaignmanager>
11
+ <use>standard</use>
12
+ <args>
13
+ <module>Ghrix_Campaignmanager</module>
14
+ <frontName>campaignmanager</frontName>
15
+ </args>
16
+ </campaignmanager>
17
+ </routers>
18
+ <layout>
19
+ <updates>
20
+ <campaignmanager>
21
+ <file>campaignmanager.xml</file>
22
+ </campaignmanager>
23
+ </updates>
24
+ </layout>
25
+ </frontend>
26
+ <global>
27
+ <helpers>
28
+ <campaignmanager>
29
+ <class>Ghrix_Campaignmanager_Helper</class>
30
+ </campaignmanager>
31
+ </helpers>
32
+ <blocks>
33
+ <campaignmanager>
34
+ <class>Ghrix_Campaignmanager_Block</class>
35
+ </campaignmanager>
36
+ </blocks>
37
+ <models>
38
+ <campaignmanager>
39
+ <class>Ghrix_Campaignmanager_Model</class>
40
+ <resourceModel>campaignmanager_mysql4</resourceModel>
41
+ </campaignmanager>
42
+ <campaignmanager_mysql4>
43
+ <class>Ghrix_Campaignmanager_Model_Mysql4</class>
44
+ <entities>
45
+ <campaignmanager>
46
+ <table>campaignmanager</table>
47
+ </campaignmanager>
48
+ </entities>
49
+ </campaignmanager_mysql4>
50
+ </models>
51
+ <resources>
52
+ <campaignmanager_setup>
53
+ <setup>
54
+ <module>Ghrix_Campaignmanager</module>
55
+ </setup>
56
+ <connection>
57
+ <use>core_setup</use>
58
+ </connection>
59
+ </campaignmanager_setup>
60
+ <campaignmanager_write>
61
+ <connection>
62
+ <use>core_write</use>
63
+ </connection>
64
+ </campaignmanager_write>
65
+ <campaignmanager_read>
66
+ <connection>
67
+ <use>core_read</use>
68
+ </connection>
69
+ </campaignmanager_read>
70
+ </resources>
71
+ </global>
72
+ <admin>
73
+ <routers>
74
+ <campaignmanager>
75
+ <use>admin</use>
76
+ <args>
77
+ <module>Ghrix_Campaignmanager</module>
78
+ <frontName>admin_campaignmanager</frontName>
79
+ </args>
80
+ </campaignmanager>
81
+ </routers>
82
+ </admin>
83
+ <adminhtml>
84
+ <menu>
85
+ <campaignmanager module="campaignmanager">
86
+ <title>Campaignmanager</title>
87
+ <sort_order>100</sort_order>
88
+ <children>
89
+ <campaignmanagerbackend module="campaignmanager">
90
+ <title>Campaignmanager</title>
91
+ <sort_order>0</sort_order>
92
+ <action>admin_campaignmanager/adminhtml_campaignmanagerbackend</action>
93
+ </campaignmanagerbackend>
94
+ <campaignmanager module="campaignmanager">
95
+ <title>Manage Campaignmanager</title>
96
+ <sort_order>0</sort_order>
97
+ <action>admin_campaignmanager/adminhtml_campaignmanager</action>
98
+ </campaignmanager>
99
+ </children>
100
+ </campaignmanager>
101
+ </menu>
102
+ <acl>
103
+ <resources>
104
+ <all>
105
+ <title>Allow Everything</title>
106
+ </all>
107
+ <admin>
108
+ <children>
109
+ <campaignmanager translate="title" module="campaignmanager">
110
+ <title>Campaignmanager</title>
111
+ <sort_order>1000</sort_order>
112
+ <children>
113
+ <campaignmanagerbackend translate="title">
114
+ <title>Campaignmanager</title>
115
+ </campaignmanagerbackend>
116
+ <campaignmanager translate="title">
117
+ <title>Manage Campaignmanager</title>
118
+ <sort_order>0</sort_order>
119
+ </campaignmanager>
120
+ </children>
121
+ </campaignmanager>
122
+ </children>
123
+ </admin>
124
+ </resources>
125
+ </acl>
126
+ <layout>
127
+ <updates>
128
+ <campaignmanager>
129
+ <file>campaignmanager.xml</file>
130
+ </campaignmanager>
131
+ </updates>
132
+ </layout>
133
+ </adminhtml>
134
+ </config>
app/design/frontend/base/default/layout/campaign.xml ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <layout version="0.1.0">
3
+ <campaign_index_index>
4
+ <reference name="root">
5
+ <action method="setTemplate"><template>page/1column.phtml</template></action>
6
+ </reference>
7
+ <reference name="content">
8
+ <block type="campaign/index" name="campaign_index" template="campaign/index.phtml"/>
9
+ </reference>
10
+ </campaign_index_index>
11
+ </layout>
12
+
package.xml ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>Ad_Manager</name>
4
+ <version>1.0.0</version>
5
+ <stability>stable</stability>
6
+ <license uri="http://opensource.org/licenses/osl-3.0.php">Open Software License (OSL)</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>Ad Manager for displaying custom ads in any place of magento </summary>
10
+ <description>Ad Manager for displaying custom ads in any place of magento .With this a merchant can easily all there ads from admin.&#xD;
11
+ &#xD;
12
+ Key Features&#xD;
13
+ &#xD;
14
+ 1 Add ads from magento admin&#xD;
15
+ 2 Assign time for the ads to be displayed&#xD;
16
+ 3 assign default days to be ads showing on the site&#xD;
17
+ 4 can group ads&#xD;
18
+ 5 easily manageable from admin&#xD;
19
+ </description>
20
+ <notes>This is fully tested on our servers and works well</notes>
21
+ <authors><author><name>Rohit Goel</name><user>rohit_goel</user><email>rhtgoel7@gmail.com</email></author></authors>
22
+ <date>2016-01-15</date>
23
+ <time>06:29:18</time>
24
+ <contents><target name="mageetc"><dir name="."><file name="Ghrix_Campaign.xml" hash=""/></dir></target><target name="magelocal"><dir name="Ghrix"><dir name="Bannercampaign"><dir name="Block"><dir name="Adminhtml"><dir name="Bannercampaign"><dir name="Edit"><file name="Form.php" hash="f1caee3878363b74ef2cc56520979894"/><dir name="Tab"><file name="Form.php" hash="98e92f8b95301a62fc8946c558c0f5a6"/></dir><file name="Tabs.php" hash="7461ac7737eec70a266ec6bbfca85628"/></dir><file name="Edit.php" hash="1ef092b75d4f089c7fa4088e1b0d2f2d"/><file name="Grid.php" hash="b75fd19dd97ca938d61b263312d17733"/></dir><file name="Bannercampaign.php" hash="cbc42fee605e2c4d5af3e82c0c85b83d"/><file name="Bannercampaignbackend.php" hash="2beb9a8f054bebb68380989b6d4a59af"/></dir><file name="Index.php" hash="e77b67a2edeb108f6031e926b573935a"/></dir><dir name="Helper"><file name="Data.php" hash="07482abcd680d3285f53014d9acbecb6"/></dir><dir name="Model"><file name="Bannercampaign.php" hash="b4a04d6d4cd3ef02236b0d11198510dd"/><dir name="Mysql4"><dir name="Bannercampaign"><file name="Collection.php" hash="f922ec0ca148d1d944d5a9c426707ce2"/></dir><file name="Bannercampaign.php" hash="8e08613a15a6505bae4852fbd925cb11"/></dir></dir><dir name="controllers"><dir name="Adminhtml"><file name="BannercampaignController.php" hash="3e345c153e3ab18b8f38169fc215b0b1"/><file name="BannercampaignbackendController.php" hash="2379c196387e1013fb100bf0c1d9566b"/></dir><file name="IndexController.php" hash="165d3d4a63cfb351cb31870ce2670562"/></dir><dir name="etc"><file name="config.xml" hash="46747b4354eb2e4e5b1c2a097fb2ea67"/></dir><dir name="sql"><dir name="bannercampaign_setup"><file name="mysql4-install-0.1.0.php" hash="0f11698aa7446670aeb50854b0b1d4e6"/></dir></dir></dir><dir name="Campaign"><dir name="Block"><dir name="Adminhtml"><dir name="Campaign"><dir name="Edit"><file name="Form.php" hash="2960b11acabf49bb3f78ce3f443abf55"/><dir name="Tab"><file name="Form.php" hash="d3ab2f48a88d1509cbc49d2ffde07c3f"/></dir><file name="Tabs.php" hash="dec5f736e0790de1bce4cc71295abb2b"/></dir><file name="Edit.php" hash="832be537f03fb8d14e4bbceedff52a5d"/><dir name="Grid"><dir name="Column"><dir name="Renderer"><file name="Image.php" hash="aba1bc04a3831dfbb27ae995b59cff43"/></dir></dir></dir><file name="Grid.php" hash="b8e082c4259fd1f447f6fcc70e6ab36d"/></dir><file name="Campaign.php" hash="8ad218792378e123dd3d30c0b9c0daa6"/></dir><file name="Index.php" hash="204852c2117c36117021f621494ae682"/></dir><dir name="Helper"><file name="Data.php" hash="14398e5ef48fd2f5825773753bb5c110"/></dir><dir name="Model"><file name="Campaign.php" hash="c88d2e47f03a66f21989936c91764682"/><dir name="Mysql4"><dir name="Campaign"><file name="Collection.php" hash="7aaa44a0c14efc1a9bdba8aff398fac9"/></dir><file name="Campaign.php" hash="fdf6f622849228f36e1c5181ea1428f3"/></dir></dir><dir name="controllers"><dir name="Adminhtml"><file name="CampaignController.php" hash="c563860c9320d00c793ab609a310c3eb"/></dir><file name="IndexController.php" hash="db1ef3136a4ca46fc4c37d960e1dc8e4"/></dir><dir name="etc"><file name="config.xml" hash="77e055c312e1102ea5cbeca4820a5b9a"/></dir><dir name="sql"><dir name="campaign_setup"><file name="mysql4-install-0.1.0.php" hash="ed378f971f9196c87a08a4bd0eeb5c11"/></dir></dir></dir><dir name="Campaignmanager"><dir name="Block"><dir name="Adminhtml"><dir name="Campaignmanager"><dir name="Edit"><file name="Form.php" hash="ea771df128eb5c2c2cbb3d56029261f7"/><dir name="Tab"><file name="Form.php" hash="5369de8db60cf48b7b8dd00257555cfb"/></dir><file name="Tabs.php" hash="601999e06020f1b944b193610280ee3b"/></dir><file name="Edit.php" hash="d133f1e5ebdcf3622a9a2b469f35bfb0"/><file name="Grid.php" hash="383f0d15f505e9ff91061799b27184e1"/></dir><file name="Campaignmanager.php" hash="8698f8d7f321c79f05c6a1cae2d285fe"/><file name="Campaignmanagerbackend.php" hash="4604702b15f2bcca76195835742bc132"/></dir><file name="Index.php" hash="d151e4925a7fc082dea67e45eef32cdf"/></dir><dir name="Helper"><file name="Data.php" hash="6a4c5519aa20a588a328b38f2202f63b"/></dir><dir name="Model"><file name="Campaignmanager.php" hash="4528899cf5aa06daa4bb3e67947edabe"/><dir name="Mysql4"><dir name="Campaignmanager"><file name="Collection.php" hash="5b9b35e389118292428dcab34b41094b"/></dir><file name="Campaignmanager.php" hash="44d44d4279b35e8889c1d8e7aca2865c"/></dir></dir><dir name="controllers"><dir name="Adminhtml"><file name="CampaignmanagerController.php" hash="36b4b28adc65663def77b8be20f02f99"/><file name="CampaignmanagerbackendController.php" hash="5258f7c3c89390835e3df539cf6a7bf1"/></dir><file name="IndexController.php" hash="4b65fb50f6fe5bd5b3b7e28e1c1949a5"/></dir><dir name="etc"><file name="config.xml" hash="5d5bd2fe1ddb11b1e5187338bbfcb559"/></dir></dir></dir><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="campaign.xml" hash=""/></dir></dir></dir></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="campaign.xml" hash="3aa88733ca4314497c6cccf6c323aea3"/></dir></dir></dir></dir></target></contents>
25
+ <compatible/>
26
+ <dependencies><required><php><min>5.1.0</min><max>6.0.0</max></php></required></dependencies>
27
+ </package>