Version Notes
First Release
Download this release
Release Info
Developer | Manthan |
Extension | Service_Checker |
Version | 1.0.0 |
Comparing to | |
See all releases |
Version 1.0.0
- app/code/local/Sitegurus/Rules/Block/Adminhtml/Rules.php +12 -0
- app/code/local/Sitegurus/Rules/Block/Adminhtml/Rules/Edit.php +45 -0
- app/code/local/Sitegurus/Rules/Block/Adminhtml/Rules/Edit/Form.php +19 -0
- app/code/local/Sitegurus/Rules/Block/Adminhtml/Rules/Edit/Tab/Form.php +185 -0
- app/code/local/Sitegurus/Rules/Block/Adminhtml/Rules/Edit/Tabs.php +24 -0
- app/code/local/Sitegurus/Rules/Block/Adminhtml/Rules/Grid.php +140 -0
- app/code/local/Sitegurus/Rules/Block/Rules.php +17 -0
- app/code/local/Sitegurus/Rules/Helper/Data.php +6 -0
- app/code/local/Sitegurus/Rules/Model/Mysql4/Rules.php +10 -0
- app/code/local/Sitegurus/Rules/Model/Mysql4/Rules/Collection.php +10 -0
- app/code/local/Sitegurus/Rules/Model/Rules.php +10 -0
- app/code/local/Sitegurus/Rules/Model/Status.php +15 -0
- app/code/local/Sitegurus/Rules/controllers/Adminhtml/RulesController.php +180 -0
- app/code/local/Sitegurus/Rules/controllers/IndexController.php +9 -0
- app/code/local/Sitegurus/Rules/etc/config.xml +120 -0
- app/code/local/Sitegurus/Rules/sql/rules_setup/mysql4-install-0.1.0.php +26 -0
- app/design/adminhtml/default/default/layout/rules.xml +8 -0
- app/design/frontend/default/default/layout/rules.xml +13 -0
- app/design/frontend/default/default/template/rules/rules.phtml +46 -0
- app/etc/modules/Sitegurus_Rules.xml +9 -0
- package.xml +21 -0
- skin/frontend/default/default/css/available.css +13 -0
- skin/frontend/default/default/images/free_shipping.png +0 -0
- skin/frontend/default/default/images/no_return.png +0 -0
- skin/frontend/default/default/images/paid_shipping.png +0 -0
- skin/frontend/default/default/images/post_pre_payment.png +0 -0
- skin/frontend/default/default/images/pre_payment.png +0 -0
- skin/frontend/default/default/images/return.png +0 -0
app/code/local/Sitegurus/Rules/Block/Adminhtml/Rules.php
ADDED
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Sitegurus_Rules_Block_Adminhtml_Rules extends Mage_Adminhtml_Block_Widget_Grid_Container
|
3 |
+
{
|
4 |
+
public function __construct()
|
5 |
+
{
|
6 |
+
$this->_controller = 'adminhtml_rules';
|
7 |
+
$this->_blockGroup = 'rules';
|
8 |
+
$this->_headerText = Mage::helper('rules')->__('Rule Manager');
|
9 |
+
$this->_addButtonLabel = Mage::helper('rules')->__('Add Rule');
|
10 |
+
parent::__construct();
|
11 |
+
}
|
12 |
+
}
|
app/code/local/Sitegurus/Rules/Block/Adminhtml/Rules/Edit.php
ADDED
@@ -0,0 +1,45 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Sitegurus_Rules_Block_Adminhtml_Rules_Edit extends Mage_Adminhtml_Block_Widget_Form_Container
|
4 |
+
{
|
5 |
+
public function __construct()
|
6 |
+
{
|
7 |
+
parent::__construct();
|
8 |
+
|
9 |
+
$this->_objectId = 'id';
|
10 |
+
$this->_blockGroup = 'rules';
|
11 |
+
$this->_controller = 'adminhtml_rules';
|
12 |
+
|
13 |
+
$this->_updateButton('save', 'label', Mage::helper('rules')->__('Save Rule'));
|
14 |
+
$this->_updateButton('delete', 'label', Mage::helper('rules')->__('Delete Rule'));
|
15 |
+
|
16 |
+
$this->_addButton('saveandcontinue', array(
|
17 |
+
'label' => Mage::helper('adminhtml')->__('Save And Continue Edit'),
|
18 |
+
'onclick' => 'saveAndContinueEdit()',
|
19 |
+
'class' => 'save',
|
20 |
+
), -100);
|
21 |
+
|
22 |
+
$this->_formScripts[] = "
|
23 |
+
function toggleEditor() {
|
24 |
+
if (tinyMCE.getInstanceById('rules_content') == null) {
|
25 |
+
tinyMCE.execCommand('mceAddControl', false, 'rules_content');
|
26 |
+
} else {
|
27 |
+
tinyMCE.execCommand('mceRemoveControl', false, 'rules_content');
|
28 |
+
}
|
29 |
+
}
|
30 |
+
|
31 |
+
function saveAndContinueEdit(){
|
32 |
+
editForm.submit($('edit_form').action+'back/edit/');
|
33 |
+
}
|
34 |
+
";
|
35 |
+
}
|
36 |
+
|
37 |
+
public function getHeaderText()
|
38 |
+
{
|
39 |
+
if( Mage::registry('rules_data') && Mage::registry('rules_data')->getId() ) {
|
40 |
+
return Mage::helper('rules')->__("Edit Rule '%s'", $this->htmlEscape(Mage::registry('rules_data')->getTitle()));
|
41 |
+
} else {
|
42 |
+
return Mage::helper('rules')->__('Add Rule');
|
43 |
+
}
|
44 |
+
}
|
45 |
+
}
|
app/code/local/Sitegurus/Rules/Block/Adminhtml/Rules/Edit/Form.php
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Sitegurus_Rules_Block_Adminhtml_Rules_Edit_Form extends Mage_Adminhtml_Block_Widget_Form
|
4 |
+
{
|
5 |
+
protected function _prepareForm()
|
6 |
+
{
|
7 |
+
$form = new Varien_Data_Form(array(
|
8 |
+
'id' => 'edit_form',
|
9 |
+
'action' => $this->getUrl('*/*/save', array('id' => $this->getRequest()->getParam('id'))),
|
10 |
+
'method' => 'post',
|
11 |
+
'enctype' => 'multipart/form-data'
|
12 |
+
)
|
13 |
+
);
|
14 |
+
|
15 |
+
$form->setUseContainer(true);
|
16 |
+
$this->setForm($form);
|
17 |
+
return parent::_prepareForm();
|
18 |
+
}
|
19 |
+
}
|
app/code/local/Sitegurus/Rules/Block/Adminhtml/Rules/Edit/Tab/Form.php
ADDED
@@ -0,0 +1,185 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Sitegurus_Rules_Block_Adminhtml_Rules_Edit_Tab_Form extends Mage_Adminhtml_Block_Widget_Form
|
3 |
+
{
|
4 |
+
protected function _prepareForm()
|
5 |
+
{
|
6 |
+
$form = new Varien_Data_Form();
|
7 |
+
$this->setForm($form);
|
8 |
+
$fieldset = $form->addFieldset('rules_form', array('legend'=>Mage::helper('rules')->__('Rules information')));
|
9 |
+
|
10 |
+
//$categories = Mage::getModel('catalog/category')->getCollection()->addAttributeToSelect('*');
|
11 |
+
|
12 |
+
$fieldset->addField('title', 'text', array(
|
13 |
+
'label' => Mage::helper('rules')->__('Title of Rule'),
|
14 |
+
'class' => 'required-entry',
|
15 |
+
'required' => true,
|
16 |
+
'name' => 'title',
|
17 |
+
));
|
18 |
+
|
19 |
+
$cats=Mage::getModel('catalog/category')->load(2)->getChildren();
|
20 |
+
$catIds=explode(',',$cats);
|
21 |
+
foreach($catIds as $id)
|
22 |
+
{
|
23 |
+
$category=Mage::getModel('catalog/category')->load($id);
|
24 |
+
$tmp1[]=array(
|
25 |
+
'value' => $category->getId(),
|
26 |
+
'label' => $category->getName(),
|
27 |
+
);
|
28 |
+
if($category->hasChildren())
|
29 |
+
{
|
30 |
+
$cats1=$category->getChildren();
|
31 |
+
$catIds1=explode(',',$cats1);
|
32 |
+
foreach($catIds1 as $id1)
|
33 |
+
{
|
34 |
+
$category1=Mage::getModel('catalog/category')->load($id1);
|
35 |
+
$tmp1[]=array(
|
36 |
+
'value' => $category1->getId(),
|
37 |
+
'label' => '-----'.$category1->getName(),
|
38 |
+
);
|
39 |
+
|
40 |
+
if($category1->hasChildren())
|
41 |
+
{
|
42 |
+
$cats2=$category1->getChildren();
|
43 |
+
$catIds2=explode(',',$cats2);
|
44 |
+
foreach($catIds2 as $id2)
|
45 |
+
{
|
46 |
+
$category2=Mage::getModel('catalog/category')->load($id2);
|
47 |
+
$tmp1[]=array(
|
48 |
+
'value' => $category2->getId(),
|
49 |
+
'label' => '-----------'.$category2->getName(),
|
50 |
+
);
|
51 |
+
|
52 |
+
}
|
53 |
+
}
|
54 |
+
}
|
55 |
+
}
|
56 |
+
}
|
57 |
+
|
58 |
+
foreach($categories as $v){
|
59 |
+
$tmp[]=array(
|
60 |
+
'value' => $v->getId(),
|
61 |
+
'label' => $v->getName(),
|
62 |
+
);
|
63 |
+
}
|
64 |
+
|
65 |
+
$categoryId=$this->getRequest()->getParam('categories');
|
66 |
+
|
67 |
+
$fieldset->addField('category_name', 'select', array(
|
68 |
+
'label' => Mage::helper('rules')->__('Category Name'),
|
69 |
+
'name' => 'category_name',
|
70 |
+
'values' => $tmp1,
|
71 |
+
'value' =>($categoryId)?$categoryId:'',
|
72 |
+
'required' => true,
|
73 |
+
));
|
74 |
+
|
75 |
+
|
76 |
+
$fieldset->addField('shipping_method', 'select', array(
|
77 |
+
'label' => Mage::helper('rules')->__('Shipping Method'),
|
78 |
+
'name' => 'shipping_method',
|
79 |
+
'required' => true,
|
80 |
+
'values' => array(
|
81 |
+
|
82 |
+
array(
|
83 |
+
'value' => 0,
|
84 |
+
'label' => Mage::helper('rules')->__(''),
|
85 |
+
),
|
86 |
+
array(
|
87 |
+
'value' => "Free Shipping",
|
88 |
+
'label' => Mage::helper('rules')->__('Free Shipping'),
|
89 |
+
),
|
90 |
+
|
91 |
+
array(
|
92 |
+
'value' => "Paid Shipping",
|
93 |
+
'label' => Mage::helper('rules')->__('Paid Shipping'),
|
94 |
+
),
|
95 |
+
),
|
96 |
+
));
|
97 |
+
|
98 |
+
|
99 |
+
$fieldset->addField('payment_method', 'select', array(
|
100 |
+
'label' => Mage::helper('rules')->__('Payment Method'),
|
101 |
+
'name' => 'payment_method',
|
102 |
+
'required' => true,
|
103 |
+
'values' => array(
|
104 |
+
array(
|
105 |
+
'value' => 0,
|
106 |
+
'label' => Mage::helper('rules')->__(''),
|
107 |
+
),
|
108 |
+
array(
|
109 |
+
'value' => "Only Pre Payment",
|
110 |
+
'label' => Mage::helper('rules')->__('Only Pre Payment'),
|
111 |
+
),
|
112 |
+
|
113 |
+
array(
|
114 |
+
'value' => "Pre/Post Payment",
|
115 |
+
'label' => Mage::helper('rules')->__('Pre/Post Payment'),
|
116 |
+
),
|
117 |
+
),
|
118 |
+
));
|
119 |
+
|
120 |
+
|
121 |
+
$fieldset->addField('return_method', 'select', array(
|
122 |
+
'label' => Mage::helper('rules')->__('Return Method'),
|
123 |
+
'name' => 'return_method',
|
124 |
+
'required' => true,
|
125 |
+
'values' => array(
|
126 |
+
array(
|
127 |
+
'value' => 0,
|
128 |
+
'label' => Mage::helper('rules')->__(''),
|
129 |
+
),
|
130 |
+
array(
|
131 |
+
'value' => "Not Available",
|
132 |
+
'label' => Mage::helper('rules')->__('Not Available'),
|
133 |
+
),
|
134 |
+
|
135 |
+
array(
|
136 |
+
'value' => "Free Return",
|
137 |
+
'label' => Mage::helper('rules')->__('Free Return'),
|
138 |
+
),
|
139 |
+
array(
|
140 |
+
'value' => "Paid Return",
|
141 |
+
'label' => Mage::helper('rules')->__('Paid Return'),
|
142 |
+
),
|
143 |
+
|
144 |
+
),
|
145 |
+
));
|
146 |
+
|
147 |
+
|
148 |
+
$fieldset->addField('status', 'select', array(
|
149 |
+
'label' => Mage::helper('rules')->__('Status'),
|
150 |
+
'name' => 'status',
|
151 |
+
'values' => array(
|
152 |
+
array(
|
153 |
+
'value' => 0,
|
154 |
+
'label' => Mage::helper('rules')->__(''),
|
155 |
+
),
|
156 |
+
array(
|
157 |
+
'value' => 1,
|
158 |
+
'label' => Mage::helper('rules')->__('Enabled'),
|
159 |
+
),
|
160 |
+
|
161 |
+
array(
|
162 |
+
'value' => 2,
|
163 |
+
'label' => Mage::helper('rules')->__('Disabled'),
|
164 |
+
),
|
165 |
+
),
|
166 |
+
));
|
167 |
+
|
168 |
+
$fieldset->addField('description', 'editor', array(
|
169 |
+
'name' => 'description',
|
170 |
+
'label' => Mage::helper('rules')->__('Description'),
|
171 |
+
'title' => Mage::helper('rules')->__('Description'),
|
172 |
+
'style' => 'width:700px; height:200px;',
|
173 |
+
'wysiwyg' => false,
|
174 |
+
));
|
175 |
+
|
176 |
+
if ( Mage::getSingleton('adminhtml/session')->getRulesData() )
|
177 |
+
{
|
178 |
+
$form->setValues(Mage::getSingleton('adminhtml/session')->getRulesData());
|
179 |
+
Mage::getSingleton('adminhtml/session')->setRulesData(null);
|
180 |
+
} elseif ( Mage::registry('rules_data') ) {
|
181 |
+
$form->setValues(Mage::registry('rules_data')->getData());
|
182 |
+
}
|
183 |
+
return parent::_prepareForm();
|
184 |
+
}
|
185 |
+
}
|
app/code/local/Sitegurus/Rules/Block/Adminhtml/Rules/Edit/Tabs.php
ADDED
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Sitegurus_Rules_Block_Adminhtml_Rules_Edit_Tabs extends Mage_Adminhtml_Block_Widget_Tabs
|
4 |
+
{
|
5 |
+
|
6 |
+
public function __construct()
|
7 |
+
{
|
8 |
+
parent::__construct();
|
9 |
+
$this->setId('rules_tabs');
|
10 |
+
$this->setDestElementId('edit_form');
|
11 |
+
$this->setTitle(Mage::helper('rules')->__('Rule Information'));
|
12 |
+
}
|
13 |
+
|
14 |
+
protected function _beforeToHtml()
|
15 |
+
{
|
16 |
+
$this->addTab('form_section', array(
|
17 |
+
'label' => Mage::helper('rules')->__('Rule Information'),
|
18 |
+
'title' => Mage::helper('rules')->__('Rule Information'),
|
19 |
+
'content' => $this->getLayout()->createBlock('rules/adminhtml_rules_edit_tab_form')->toHtml(),
|
20 |
+
));
|
21 |
+
|
22 |
+
return parent::_beforeToHtml();
|
23 |
+
}
|
24 |
+
}
|
app/code/local/Sitegurus/Rules/Block/Adminhtml/Rules/Grid.php
ADDED
@@ -0,0 +1,140 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Sitegurus_Rules_Block_Adminhtml_Rules_Grid extends Mage_Adminhtml_Block_Widget_Grid
|
4 |
+
{
|
5 |
+
public function __construct()
|
6 |
+
{
|
7 |
+
parent::__construct();
|
8 |
+
$this->setId('rulesGrid');
|
9 |
+
$this->setDefaultSort('rules_id');
|
10 |
+
$this->setDefaultDir('ASC');
|
11 |
+
$this->setSaveParametersInSession(true);
|
12 |
+
}
|
13 |
+
|
14 |
+
protected function _prepareCollection()
|
15 |
+
{
|
16 |
+
$collection = Mage::getModel('rules/rules')->getCollection();
|
17 |
+
$this->setCollection($collection);
|
18 |
+
return parent::_prepareCollection();
|
19 |
+
}
|
20 |
+
|
21 |
+
protected function _prepareColumns()
|
22 |
+
{
|
23 |
+
$this->addColumn('rules_id', array(
|
24 |
+
'header' => Mage::helper('rules')->__('ID'),
|
25 |
+
'align' =>'right',
|
26 |
+
'width' => '50px',
|
27 |
+
'index' => 'rules_id',
|
28 |
+
));
|
29 |
+
|
30 |
+
$this->addColumn('title', array(
|
31 |
+
'header' => Mage::helper('rules')->__('Title'),
|
32 |
+
'align' =>'left',
|
33 |
+
'index' => 'title',
|
34 |
+
));
|
35 |
+
|
36 |
+
$this->addColumn('category_name', array(
|
37 |
+
'header' => Mage::helper('rules')->__('Category ID'),
|
38 |
+
'align' =>'left',
|
39 |
+
'index' => 'category_name',
|
40 |
+
));
|
41 |
+
|
42 |
+
$this->addColumn('shipping_method', array(
|
43 |
+
'header' => Mage::helper('rules')->__('Shipping'),
|
44 |
+
'align' =>'left',
|
45 |
+
'index' => 'shipping_method',
|
46 |
+
));
|
47 |
+
|
48 |
+
$this->addColumn('payment_method', array(
|
49 |
+
'header' => Mage::helper('rules')->__('Payment'),
|
50 |
+
'align' =>'left',
|
51 |
+
'index' => 'payment_method',
|
52 |
+
));
|
53 |
+
|
54 |
+
$this->addColumn('return_method', array(
|
55 |
+
'header' => Mage::helper('rules')->__('Return'),
|
56 |
+
'align' =>'left',
|
57 |
+
'index' => 'return_method',
|
58 |
+
));
|
59 |
+
|
60 |
+
/*
|
61 |
+
$this->addColumn('content', array(
|
62 |
+
'header' => Mage::helper('rules')->__('Item Content'),
|
63 |
+
'width' => '150px',
|
64 |
+
'index' => 'content',
|
65 |
+
));
|
66 |
+
*/
|
67 |
+
|
68 |
+
$this->addColumn('status', array(
|
69 |
+
'header' => Mage::helper('rules')->__('Status'),
|
70 |
+
'align' => 'left',
|
71 |
+
'width' => '80px',
|
72 |
+
'index' => 'status',
|
73 |
+
'type' => 'options',
|
74 |
+
'options' => array(
|
75 |
+
1 => 'Enabled',
|
76 |
+
2 => 'Disabled',
|
77 |
+
),
|
78 |
+
));
|
79 |
+
|
80 |
+
$this->addColumn('action',
|
81 |
+
array(
|
82 |
+
'header' => Mage::helper('rules')->__('Action'),
|
83 |
+
'width' => '100',
|
84 |
+
'type' => 'action',
|
85 |
+
'getter' => 'getId',
|
86 |
+
'actions' => array(
|
87 |
+
array(
|
88 |
+
'caption' => Mage::helper('rules')->__('Edit'),
|
89 |
+
'url' => array('base'=> '*/*/edit'),
|
90 |
+
'field' => 'id'
|
91 |
+
)
|
92 |
+
),
|
93 |
+
'filter' => false,
|
94 |
+
'sortable' => false,
|
95 |
+
'index' => 'stores',
|
96 |
+
'is_system' => true,
|
97 |
+
));
|
98 |
+
|
99 |
+
$this->addExportType('*/*/exportCsv', Mage::helper('rules')->__('CSV'));
|
100 |
+
$this->addExportType('*/*/exportXml', Mage::helper('rules')->__('XML'));
|
101 |
+
|
102 |
+
return parent::_prepareColumns();
|
103 |
+
}
|
104 |
+
|
105 |
+
protected function _prepareMassaction()
|
106 |
+
{
|
107 |
+
$this->setMassactionIdField('rules_id');
|
108 |
+
$this->getMassactionBlock()->setFormFieldName('rules');
|
109 |
+
|
110 |
+
$this->getMassactionBlock()->addItem('delete', array(
|
111 |
+
'label' => Mage::helper('rules')->__('Delete'),
|
112 |
+
'url' => $this->getUrl('*/*/massDelete'),
|
113 |
+
'confirm' => Mage::helper('rules')->__('Are you sure?')
|
114 |
+
));
|
115 |
+
|
116 |
+
$statuses = Mage::getSingleton('rules/status')->getOptionArray();
|
117 |
+
|
118 |
+
array_unshift($statuses, array('label'=>'', 'value'=>''));
|
119 |
+
$this->getMassactionBlock()->addItem('status', array(
|
120 |
+
'label'=> Mage::helper('rules')->__('Change status'),
|
121 |
+
'url' => $this->getUrl('*/*/massStatus', array('_current'=>true)),
|
122 |
+
'additional' => array(
|
123 |
+
'visibility' => array(
|
124 |
+
'name' => 'status',
|
125 |
+
'type' => 'select',
|
126 |
+
'class' => 'required-entry',
|
127 |
+
'label' => Mage::helper('rules')->__('Status'),
|
128 |
+
'values' => $statuses
|
129 |
+
)
|
130 |
+
)
|
131 |
+
));
|
132 |
+
return $this;
|
133 |
+
}
|
134 |
+
|
135 |
+
public function getRowUrl($row)
|
136 |
+
{
|
137 |
+
return $this->getUrl('*/*/edit', array('id' => $row->getId()));
|
138 |
+
}
|
139 |
+
|
140 |
+
}
|
app/code/local/Sitegurus/Rules/Block/Rules.php
ADDED
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Sitegurus_Rules_Block_Rules extends Mage_Core_Block_Template
|
3 |
+
{
|
4 |
+
public function _prepareLayout()
|
5 |
+
{
|
6 |
+
return parent::_prepareLayout();
|
7 |
+
}
|
8 |
+
|
9 |
+
public function getRules()
|
10 |
+
{
|
11 |
+
if (!$this->hasData('rules')) {
|
12 |
+
$this->setData('rules', Mage::registry('rules'));
|
13 |
+
}
|
14 |
+
return $this->getData('rules');
|
15 |
+
|
16 |
+
}
|
17 |
+
}
|
app/code/local/Sitegurus/Rules/Helper/Data.php
ADDED
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Sitegurus_Rules_Helper_Data extends Mage_Core_Helper_Abstract
|
4 |
+
{
|
5 |
+
|
6 |
+
}
|
app/code/local/Sitegurus/Rules/Model/Mysql4/Rules.php
ADDED
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Sitegurus_Rules_Model_Mysql4_Rules extends Mage_Core_Model_Mysql4_Abstract
|
4 |
+
{
|
5 |
+
public function _construct()
|
6 |
+
{
|
7 |
+
// Note that the rules_id refers to the key field in your database table.
|
8 |
+
$this->_init('rules/rules', 'rules_id');
|
9 |
+
}
|
10 |
+
}
|
app/code/local/Sitegurus/Rules/Model/Mysql4/Rules/Collection.php
ADDED
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Sitegurus_Rules_Model_Mysql4_Rules_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
|
4 |
+
{
|
5 |
+
public function _construct()
|
6 |
+
{
|
7 |
+
parent::_construct();
|
8 |
+
$this->_init('rules/rules');
|
9 |
+
}
|
10 |
+
}
|
app/code/local/Sitegurus/Rules/Model/Rules.php
ADDED
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Sitegurus_Rules_Model_Rules extends Mage_Core_Model_Abstract
|
4 |
+
{
|
5 |
+
public function _construct()
|
6 |
+
{
|
7 |
+
parent::_construct();
|
8 |
+
$this->_init('rules/rules');
|
9 |
+
}
|
10 |
+
}
|
app/code/local/Sitegurus/Rules/Model/Status.php
ADDED
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Sitegurus_Rules_Model_Status extends Varien_Object
|
4 |
+
{
|
5 |
+
const STATUS_ENABLED = 1;
|
6 |
+
const STATUS_DISABLED = 2;
|
7 |
+
|
8 |
+
static public function getOptionArray()
|
9 |
+
{
|
10 |
+
return array(
|
11 |
+
self::STATUS_ENABLED => Mage::helper('rules')->__('Enabled'),
|
12 |
+
self::STATUS_DISABLED => Mage::helper('rules')->__('Disabled')
|
13 |
+
);
|
14 |
+
}
|
15 |
+
}
|
app/code/local/Sitegurus/Rules/controllers/Adminhtml/RulesController.php
ADDED
@@ -0,0 +1,180 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Sitegurus_Rules_Adminhtml_RulesController extends Mage_Adminhtml_Controller_action
|
4 |
+
{
|
5 |
+
|
6 |
+
protected function _initAction() {
|
7 |
+
$this->loadLayout()
|
8 |
+
->_setActiveMenu('rules/items')
|
9 |
+
->_addBreadcrumb(Mage::helper('adminhtml')->__('Items Manager'), Mage::helper('adminhtml')->__('Rule Manager'));
|
10 |
+
|
11 |
+
return $this;
|
12 |
+
}
|
13 |
+
|
14 |
+
public function indexAction() {
|
15 |
+
$this->_initAction()
|
16 |
+
->renderLayout();
|
17 |
+
}
|
18 |
+
|
19 |
+
public function editAction() {
|
20 |
+
$id = $this->getRequest()->getParam('id');
|
21 |
+
$model = Mage::getModel('rules/rules')->load($id);
|
22 |
+
|
23 |
+
if ($model->getId() || $id == 0) {
|
24 |
+
$data = Mage::getSingleton('adminhtml/session')->getFormData(true);
|
25 |
+
if (!empty($data)) {
|
26 |
+
$model->setData($data);
|
27 |
+
}
|
28 |
+
|
29 |
+
Mage::register('rules_data', $model);
|
30 |
+
|
31 |
+
$this->loadLayout();
|
32 |
+
$this->_setActiveMenu('rules/items');
|
33 |
+
|
34 |
+
$this->_addBreadcrumb(Mage::helper('adminhtml')->__('Rule Manager'), Mage::helper('adminhtml')->__('Rule Manager'));
|
35 |
+
$this->_addBreadcrumb(Mage::helper('adminhtml')->__('Rule News'), Mage::helper('adminhtml')->__('Rule News'));
|
36 |
+
|
37 |
+
$this->getLayout()->getBlock('head')->setCanLoadExtJs(true);
|
38 |
+
|
39 |
+
$this->_addContent($this->getLayout()->createBlock('rules/adminhtml_rules_edit'))
|
40 |
+
->_addLeft($this->getLayout()->createBlock('rules/adminhtml_rules_edit_tabs'));
|
41 |
+
|
42 |
+
$this->renderLayout();
|
43 |
+
} else {
|
44 |
+
Mage::getSingleton('adminhtml/session')->addError(Mage::helper('rules')->__('Rule does not exist'));
|
45 |
+
$this->_redirect('*/*/');
|
46 |
+
}
|
47 |
+
}
|
48 |
+
|
49 |
+
public function newAction() {
|
50 |
+
$this->_forward('edit');
|
51 |
+
}
|
52 |
+
|
53 |
+
public function saveAction() {
|
54 |
+
if ($data = $this->getRequest()->getPost()) {
|
55 |
+
|
56 |
+
if(isset($_FILES['filename']['name']) && $_FILES['filename']['name'] != '') {
|
57 |
+
try {
|
58 |
+
/* Starting upload */
|
59 |
+
$uploader = new Varien_File_Uploader('filename');
|
60 |
+
|
61 |
+
// Any extention would work
|
62 |
+
$uploader->setAllowedExtensions(array('jpg','jpeg','gif','png'));
|
63 |
+
$uploader->setAllowRenameFiles(false);
|
64 |
+
|
65 |
+
// Set the file upload mode
|
66 |
+
// false -> get the file directly in the specified folder
|
67 |
+
// true -> get the file in the product like folders
|
68 |
+
// (file.jpg will go in something like /media/f/i/file.jpg)
|
69 |
+
$uploader->setFilesDispersion(false);
|
70 |
+
|
71 |
+
// We set media as the upload dir
|
72 |
+
$path = Mage::getBaseDir('media') . DS ;
|
73 |
+
$uploader->save($path, $_FILES['filename']['name'] );
|
74 |
+
|
75 |
+
} catch (Exception $e) {
|
76 |
+
|
77 |
+
}
|
78 |
+
|
79 |
+
//this way the name is saved in DB
|
80 |
+
$data['filename'] = $_FILES['filename']['name'];
|
81 |
+
}
|
82 |
+
|
83 |
+
//$data['category_name'] = implode(",", $data['category_name']);
|
84 |
+
$model = Mage::getModel('rules/rules');
|
85 |
+
$model->setData($data)
|
86 |
+
->setId($this->getRequest()->getParam('id'));
|
87 |
+
|
88 |
+
try {
|
89 |
+
if ($model->getCreatedTime == NULL || $model->getUpdateTime() == NULL) {
|
90 |
+
$model->setCreatedTime(now())
|
91 |
+
->setUpdateTime(now());
|
92 |
+
} else {
|
93 |
+
$model->setUpdateTime(now());
|
94 |
+
}
|
95 |
+
|
96 |
+
$model->save();
|
97 |
+
Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('rules')->__('Rule was successfully saved'));
|
98 |
+
Mage::getSingleton('adminhtml/session')->setFormData(false);
|
99 |
+
|
100 |
+
if ($this->getRequest()->getParam('back')) {
|
101 |
+
$this->_redirect('*/*/edit', array('id' => $model->getId()));
|
102 |
+
return;
|
103 |
+
}
|
104 |
+
$this->_redirect('*/*/');
|
105 |
+
return;
|
106 |
+
} catch (Exception $e) {
|
107 |
+
Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
|
108 |
+
Mage::getSingleton('adminhtml/session')->setFormData($data);
|
109 |
+
$this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id')));
|
110 |
+
return;
|
111 |
+
}
|
112 |
+
}
|
113 |
+
Mage::getSingleton('adminhtml/session')->addError(Mage::helper('rules')->__('Unable to find Rule to save'));
|
114 |
+
$this->_redirect('*/*/');
|
115 |
+
}
|
116 |
+
|
117 |
+
public function deleteAction() {
|
118 |
+
if( $this->getRequest()->getParam('id') > 0 ) {
|
119 |
+
try {
|
120 |
+
$model = Mage::getModel('rules/rules');
|
121 |
+
|
122 |
+
$model->setId($this->getRequest()->getParam('id'))
|
123 |
+
->delete();
|
124 |
+
|
125 |
+
Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('adminhtml')->__('Rule was successfully deleted'));
|
126 |
+
$this->_redirect('*/*/');
|
127 |
+
} catch (Exception $e) {
|
128 |
+
Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
|
129 |
+
$this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id')));
|
130 |
+
}
|
131 |
+
}
|
132 |
+
$this->_redirect('*/*/');
|
133 |
+
}
|
134 |
+
|
135 |
+
public function massDeleteAction() {
|
136 |
+
$rulesIds = $this->getRequest()->getParam('rules');
|
137 |
+
if(!is_array($rulesIds)) {
|
138 |
+
Mage::getSingleton('adminhtml/session')->addError(Mage::helper('adminhtml')->__('Please select Rule(s)'));
|
139 |
+
} else {
|
140 |
+
try {
|
141 |
+
foreach ($rulesIds as $rulesId) {
|
142 |
+
$rules = Mage::getModel('rules/rules')->load($rulesId);
|
143 |
+
$rules->delete();
|
144 |
+
}
|
145 |
+
Mage::getSingleton('adminhtml/session')->addSuccess(
|
146 |
+
Mage::helper('adminhtml')->__(
|
147 |
+
'Total of %d record(s) were successfully deleted', count($rulesIds)
|
148 |
+
)
|
149 |
+
);
|
150 |
+
} catch (Exception $e) {
|
151 |
+
Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
|
152 |
+
}
|
153 |
+
}
|
154 |
+
$this->_redirect('*/*/index');
|
155 |
+
}
|
156 |
+
|
157 |
+
public function massStatusAction()
|
158 |
+
{
|
159 |
+
$rulesIds = $this->getRequest()->getParam('rules');
|
160 |
+
if(!is_array($rulesIds)) {
|
161 |
+
Mage::getSingleton('adminhtml/session')->addError($this->__('Please select Rule(s)'));
|
162 |
+
} else {
|
163 |
+
try {
|
164 |
+
foreach ($rulesIds as $rulesId) {
|
165 |
+
$rules = Mage::getSingleton('rules/rules')
|
166 |
+
->load($rulesId)
|
167 |
+
->setStatus($this->getRequest()->getParam('status'))
|
168 |
+
->setIsMassupdate(true)
|
169 |
+
->save();
|
170 |
+
}
|
171 |
+
$this->_getSession()->addSuccess(
|
172 |
+
$this->__('Total of %d record(s) were successfully updated', count($rulesIds))
|
173 |
+
);
|
174 |
+
} catch (Exception $e) {
|
175 |
+
$this->_getSession()->addError($e->getMessage());
|
176 |
+
}
|
177 |
+
}
|
178 |
+
$this->_redirect('*/*/index');
|
179 |
+
}
|
180 |
+
}
|
app/code/local/Sitegurus/Rules/controllers/IndexController.php
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Sitegurus_Rules_IndexController extends Mage_Core_Controller_Front_Action
|
3 |
+
{
|
4 |
+
public function indexAction()
|
5 |
+
{
|
6 |
+
$this->loadLayout();
|
7 |
+
$this->renderLayout();
|
8 |
+
}
|
9 |
+
}
|
app/code/local/Sitegurus/Rules/etc/config.xml
ADDED
@@ -0,0 +1,120 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<modules>
|
4 |
+
<Sitegurus_Rules>
|
5 |
+
<version>0.1.0</version>
|
6 |
+
</Sitegurus_Rules>
|
7 |
+
</modules>
|
8 |
+
<frontend>
|
9 |
+
<routers>
|
10 |
+
<rules>
|
11 |
+
<use>standard</use>
|
12 |
+
<args>
|
13 |
+
<module>Sitegurus_Rules</module>
|
14 |
+
<frontName>rules</frontName>
|
15 |
+
</args>
|
16 |
+
</rules>
|
17 |
+
</routers>
|
18 |
+
<layout>
|
19 |
+
<updates>
|
20 |
+
<rules>
|
21 |
+
<file>rules.xml</file>
|
22 |
+
</rules>
|
23 |
+
</updates>
|
24 |
+
</layout>
|
25 |
+
</frontend>
|
26 |
+
<admin>
|
27 |
+
<routers>
|
28 |
+
<rules>
|
29 |
+
<use>admin</use>
|
30 |
+
<args>
|
31 |
+
<module>Sitegurus_Rules</module>
|
32 |
+
<frontName>rules</frontName>
|
33 |
+
</args>
|
34 |
+
</rules>
|
35 |
+
</routers>
|
36 |
+
</admin>
|
37 |
+
<adminhtml>
|
38 |
+
<menu>
|
39 |
+
<rules module="rules">
|
40 |
+
<title>Rules</title>
|
41 |
+
<sort_order>71</sort_order>
|
42 |
+
<children>
|
43 |
+
<items module="rules">
|
44 |
+
<title>Manage Rules</title>
|
45 |
+
<sort_order>0</sort_order>
|
46 |
+
<action>rules/adminhtml_rules</action>
|
47 |
+
</items>
|
48 |
+
</children>
|
49 |
+
</rules>
|
50 |
+
</menu>
|
51 |
+
<acl>
|
52 |
+
<resources>
|
53 |
+
<all>
|
54 |
+
<title>Allow Everything</title>
|
55 |
+
</all>
|
56 |
+
<admin>
|
57 |
+
<children>
|
58 |
+
<Sitegurus_Rules>
|
59 |
+
<title>Rules Module</title>
|
60 |
+
<sort_order>10</sort_order>
|
61 |
+
</Sitegurus_Rules>
|
62 |
+
</children>
|
63 |
+
</admin>
|
64 |
+
</resources>
|
65 |
+
</acl>
|
66 |
+
<layout>
|
67 |
+
<updates>
|
68 |
+
<rules>
|
69 |
+
<file>rules.xml</file>
|
70 |
+
</rules>
|
71 |
+
</updates>
|
72 |
+
</layout>
|
73 |
+
</adminhtml>
|
74 |
+
<global>
|
75 |
+
<models>
|
76 |
+
<rules>
|
77 |
+
<class>Sitegurus_Rules_Model</class>
|
78 |
+
<resourceModel>rules_mysql4</resourceModel>
|
79 |
+
</rules>
|
80 |
+
<rules_mysql4>
|
81 |
+
<class>Sitegurus_Rules_Model_Mysql4</class>
|
82 |
+
<entities>
|
83 |
+
<rules>
|
84 |
+
<table>rules</table>
|
85 |
+
</rules>
|
86 |
+
</entities>
|
87 |
+
</rules_mysql4>
|
88 |
+
</models>
|
89 |
+
<resources>
|
90 |
+
<rules_setup>
|
91 |
+
<setup>
|
92 |
+
<module>Sitegurus_Rules</module>
|
93 |
+
</setup>
|
94 |
+
<connection>
|
95 |
+
<use>core_setup</use>
|
96 |
+
</connection>
|
97 |
+
</rules_setup>
|
98 |
+
<rules_write>
|
99 |
+
<connection>
|
100 |
+
<use>core_write</use>
|
101 |
+
</connection>
|
102 |
+
</rules_write>
|
103 |
+
<rules_read>
|
104 |
+
<connection>
|
105 |
+
<use>core_read</use>
|
106 |
+
</connection>
|
107 |
+
</rules_read>
|
108 |
+
</resources>
|
109 |
+
<blocks>
|
110 |
+
<rules>
|
111 |
+
<class>Sitegurus_Rules_Block</class>
|
112 |
+
</rules>
|
113 |
+
</blocks>
|
114 |
+
<helpers>
|
115 |
+
<rules>
|
116 |
+
<class>Sitegurus_Rules_Helper</class>
|
117 |
+
</rules>
|
118 |
+
</helpers>
|
119 |
+
</global>
|
120 |
+
</config>
|
app/code/local/Sitegurus/Rules/sql/rules_setup/mysql4-install-0.1.0.php
ADDED
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
$installer = $this;
|
4 |
+
|
5 |
+
$installer->startSetup();
|
6 |
+
|
7 |
+
$installer->run("
|
8 |
+
|
9 |
+
-- DROP TABLE IF EXISTS {$this->getTable('rules')};
|
10 |
+
CREATE TABLE {$this->getTable('rules')} (
|
11 |
+
`rules_id` int(11) unsigned NOT NULL auto_increment,
|
12 |
+
`title` varchar(255) NOT NULL default '',
|
13 |
+
`category_name` varchar(255) NOT NULL default '',
|
14 |
+
`shipping_method` varchar(255) NOT NULL default '',
|
15 |
+
`payment_method` varchar(255) NOT NULL default '',
|
16 |
+
`return_method` varchar(255) NOT NULL default '',
|
17 |
+
`description` text NOT NULL default '',
|
18 |
+
`status` smallint(6) NOT NULL default '0',
|
19 |
+
`created_time` datetime NULL,
|
20 |
+
`update_time` datetime NULL,
|
21 |
+
PRIMARY KEY (`rules_id`)
|
22 |
+
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
23 |
+
|
24 |
+
");
|
25 |
+
|
26 |
+
$installer->endSetup();
|
app/design/adminhtml/default/default/layout/rules.xml
ADDED
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<layout version="0.1.0">
|
3 |
+
<rules_adminhtml_rules_index>
|
4 |
+
<reference name="content">
|
5 |
+
<block type="rules/adminhtml_rules" name="rules" />
|
6 |
+
</reference>
|
7 |
+
</rules_adminhtml_rules_index>
|
8 |
+
</layout>
|
app/design/frontend/default/default/layout/rules.xml
ADDED
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<layout version="0.1.0">
|
3 |
+
<default>
|
4 |
+
</default>
|
5 |
+
<catalog_product_view translate="label">
|
6 |
+
<reference name="head">
|
7 |
+
<action method="addItem"><type>skin_css</type><file>css/available.css</file></action>
|
8 |
+
</reference>
|
9 |
+
<reference name="right">
|
10 |
+
<block type="rules/rules" name="rules" template="rules/rules.phtml" />
|
11 |
+
</reference>
|
12 |
+
</catalog_product_view>
|
13 |
+
</layout>
|
app/design/frontend/default/default/template/rules/rules.phtml
ADDED
@@ -0,0 +1,46 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
Developed by Sitegurus
|
4 |
+
Manthan Vora<manthan18121989@gmail.com>*/
|
5 |
+
$rules = Mage::getModel('rules/rules')->getCollection();
|
6 |
+
$current_product = Mage::registry('current_product');
|
7 |
+
$procut_ids = Mage::registry('current_product')->getCategoryIds();
|
8 |
+
foreach($rules as $rule){
|
9 |
+
$rule_category = $rule->getData('category_name');
|
10 |
+
if(in_array($rule_category,$procut_ids)){
|
11 |
+
?>
|
12 |
+
<div class="block block-category">
|
13 |
+
<div class="block-title">
|
14 |
+
<strong>
|
15 |
+
<span>Product's Features</span>
|
16 |
+
</strong>
|
17 |
+
</div>
|
18 |
+
<div class="block-content block-category-content">
|
19 |
+
<div class="shipping-block">
|
20 |
+
<?php if($rule->getData('shipping_method') == "Free Shipping"){?>
|
21 |
+
<div class="free-shipping"><?php echo $rule->getData('shipping_method')." is available" ?></div>
|
22 |
+
<?php } else{ ?>
|
23 |
+
<div class="paid-shipping"><?php echo "Only ".$rule->getData('shipping_method')." is available" ?></div>
|
24 |
+
<?php }?>
|
25 |
+
</div>
|
26 |
+
<div class="payment-block">
|
27 |
+
<?php if($rule->getData('payment_method') == "Pre/Post Payment"){?>
|
28 |
+
<div class="pre-post-payment"><?php echo $rule->getData('payment_method')." Methods are available"?></div>
|
29 |
+
<?php } else{ ?>
|
30 |
+
<div class="pre-payment"><?php echo $rule->getData('payment_method')." Method is available"?></div>
|
31 |
+
<?php } ?>
|
32 |
+
</div>
|
33 |
+
<div class="return-block">
|
34 |
+
<?php if($rule->getData('return_method') == "Not Available"){?>
|
35 |
+
<div class="no-return"><?php echo "Return is ".$rule->getData('return_method') ?></div>
|
36 |
+
<?php } else if($rule->getData('return_method') == "Paid Return"){?>
|
37 |
+
<div class="paid-return"><?php echo $rule->getData('return_method')." is available" ?></div>
|
38 |
+
<?php } else {?>
|
39 |
+
<div class="free-return"><?php echo $rule->getData('return_method')." is available" ?></div>
|
40 |
+
<?php } ?>
|
41 |
+
</div>
|
42 |
+
</div>
|
43 |
+
</div>
|
44 |
+
<?php break; }
|
45 |
+
}
|
46 |
+
?>
|
app/etc/modules/Sitegurus_Rules.xml
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<modules>
|
4 |
+
<Sitegurus_Rules>
|
5 |
+
<active>true</active>
|
6 |
+
<codePool>local</codePool>
|
7 |
+
</Sitegurus_Rules>
|
8 |
+
</modules>
|
9 |
+
</config>
|
package.xml
ADDED
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<package>
|
3 |
+
<name>Service_Checker</name>
|
4 |
+
<version>1.0.0</version>
|
5 |
+
<stability>stable</stability>
|
6 |
+
<license>Open Software License (OSL)</license>
|
7 |
+
<channel>community</channel>
|
8 |
+
<extends/>
|
9 |
+
<summary>This extension allows admin to add Shipping, Payment & Return Methods for particular Category Products for user information.
|
10 |
+
</summary>
|
11 |
+
<description>Shipping/Payment and Return Services Checker of Product allows admin to add Shipping, Payment and Return Method for particular Category Product which can be displayed on particular product page on front end.
|
12 |
+
It can help your customers to check the availability of services provided by the store with particular products.
|
13 |
+
It is the stable version of Shipping/Payment and Return Services Checker of Product and it is completely free to download. And as it is an open source, one can easily modify it as per the requirements.</description>
|
14 |
+
<notes>First Release</notes>
|
15 |
+
<authors><author><name>Manthan</name><user>manthanext</user><email>manthan18121989@gmail.com</email></author></authors>
|
16 |
+
<date>2013-12-17</date>
|
17 |
+
<time>11:11:39</time>
|
18 |
+
<contents><target name="magelocal"><dir name="Sitegurus"><dir name="Rules"><dir name="Block"><dir name="Adminhtml"><dir name="Rules"><dir name="Edit"><file name="Form.php" hash="cea86a3b2a64ff77ab1ccb25afa77892"/><dir name="Tab"><file name="Form.php" hash="525a0983acca4216f4e0e33ec7d938ac"/></dir><file name="Tabs.php" hash="482d4038890a49dec0cf75e348305ae9"/></dir><file name="Edit.php" hash="bacbe31c8c9e0cc1121fac7bb8159183"/><file name="Grid.php" hash="04100bb6841de6afe01b1a6d70893660"/></dir><file name="Rules.php" hash="72ac2e31387a4e0a8be49790241c0739"/></dir><file name="Rules.php" hash="8354e6e1f17cd65d78501f08fc04dfaa"/></dir><dir name="Helper"><file name="Data.php" hash="96a1aa41cc4e052bdcc1221e0776c747"/></dir><dir name="Model"><dir name="Mysql4"><dir name="Rules"><file name="Collection.php" hash="1be2df25dc55f1199c231460adebe3f4"/></dir><file name="Rules.php" hash="629d2e01834cdb4f1e9e68b0826279ca"/></dir><file name="Rules.php" hash="05cf70eea26afb5ab4bb760f9f468ed1"/><file name="Status.php" hash="f366805c100700f57184d407e203c62a"/></dir><dir name="controllers"><dir name="Adminhtml"><file name="RulesController.php" hash="c1e2ca4ca2470d4444e8be1726c983fa"/></dir><file name="IndexController.php" hash="b39f2fd8ce6949bde3982b5911551ba1"/></dir><dir name="etc"><file name="config.xml" hash="1f9af14b7a65bf4cf51bbef8fee5e1f1"/></dir><dir name="sql"><dir name="rules_setup"><file name="mysql4-install-0.1.0.php" hash="447d1349e484b0674ed668363b3d239c"/></dir></dir></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="rules.xml" hash="502973dffc67acbf2a9eca9926db8528"/></dir></dir></dir></dir><dir name="frontend"><dir name="default"><dir name="default"><dir name="layout"><file name="rules.xml" hash="e9bdb2dce6d0153fd8c0df18bfa01a42"/></dir><dir name="template"><dir name="rules"><file name="rules.phtml" hash="ec7f2a9a7f9525ba0a38947594f51081"/></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Sitegurus_Rules.xml" hash="fc2150b058a284ac5ab8fdd49a36f7da"/></dir></target><target name="mageskin"><dir name="frontend"><dir name="default"><dir name="default"><dir name="css"><file name="available.css" hash="b28435824dffd1dc1140d4b7c2a7c7bf"/></dir><dir name="images"><file name="no_return.png" hash="c9f6787b5720911c69c31a55dd3db879"/><file name="return.png" hash="6c2a005dd5f5a983e99e4bdce0c285f3"/><file name="post_pre_payment.png" hash="25a49ff2221147a203ccadcb6fe6bd96"/><file name="pre_payment.png" hash="00165feba9995809df88222f6405b6f9"/><file name="paid_shipping.png" hash="29d59f0e0c3a10a048198cb61bc9e9c1"/><file name="free_shipping.png" hash="7c7a34af358a767b0f7cd4023de7463a"/></dir></dir></dir></dir></target></contents>
|
19 |
+
<compatible/>
|
20 |
+
<dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
|
21 |
+
</package>
|
skin/frontend/default/default/css/available.css
ADDED
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/*Sitegurus
|
2 |
+
* Manthan Vora <manthan18121989@gmail.com>
|
3 |
+
*/
|
4 |
+
.block-category-content{padding: 5px 10px; font-size: 12px; color: #2f2f2f;font-weight: bold;}
|
5 |
+
.shipping-block, .payment-block, .return-block{padding: 5px 0;}
|
6 |
+
.free-shipping{background: url("../images/free_shipping.png") no-repeat scroll 0 0 rgba(0, 0, 0, 0);color: #008000;padding-left: 40px;}
|
7 |
+
.paid-shipping{background: url("../images/paid_shipping.png") no-repeat scroll 0% 0% transparent;color: #9B5222;padding-left: 40px;}
|
8 |
+
.pre-post-payment{background: url("../images/post_pre_payment.png") no-repeat scroll 0 0 rgba(0, 0, 0, 0);padding-left: 40px;color: #618499;}
|
9 |
+
.pre-payment{background: url("../images/pre_payment.png") no-repeat scroll 0 0 rgba(0, 0, 0, 0);padding-left: 40px;color: #003366;}
|
10 |
+
.paid-return, .free-return{background: url("../images/return.png") no-repeat scroll 0 0 rgba(0, 0, 0, 0);padding-left: 40px; height: 35px;line-height: 35px;}
|
11 |
+
.free-return{color: #075FB7;}
|
12 |
+
.paid-return{color: #505052;}
|
13 |
+
.no-return{background: url("../images/no_return.png") no-repeat scroll 0 0 rgba(0, 0, 0, 0);color: #FF3300;height: 35px;line-height: 35px;padding-left: 40px;}
|
skin/frontend/default/default/images/free_shipping.png
ADDED
Binary file
|
skin/frontend/default/default/images/no_return.png
ADDED
Binary file
|
skin/frontend/default/default/images/paid_shipping.png
ADDED
Binary file
|
skin/frontend/default/default/images/post_pre_payment.png
ADDED
Binary file
|
skin/frontend/default/default/images/pre_payment.png
ADDED
Binary file
|
skin/frontend/default/default/images/return.png
ADDED
Binary file
|