Version Notes
Fixed minor bugs
Download this release
Release Info
| Developer | Mamta |
| Extension | Grazitti_Discount |
| Version | 1.0.3 |
| Comparing to | |
| See all releases | |
Code changes from version 1.0.1 to 1.0.3
- app/code/local/Grazitti/Discount/Block/Adminhtml/Discount.php +12 -0
- app/code/local/Grazitti/Discount/Block/Adminhtml/Discount/Edit.php +45 -0
- app/code/local/Grazitti/Discount/Block/Adminhtml/Discount/Edit/Form.php +19 -0
- app/code/local/Grazitti/Discount/Block/Adminhtml/Discount/Edit/Tab/Form.php +58 -0
- app/code/local/Grazitti/Discount/Block/Adminhtml/Discount/Edit/Tabs.php +30 -0
- app/code/local/Grazitti/Discount/Block/Adminhtml/Discount/Grid.php +116 -0
- app/code/local/Grazitti/Discount/Block/Adminhtml/Promo/Quote/Edit/Tab/Custom - Copy.php +73 -0
- app/code/local/Grazitti/Discount/Block/Adminhtml/Promo/Quote/Edit/Tab/Custom 23-3-16.php +174 -0
- app/code/local/Grazitti/Discount/Block/Adminhtml/Promo/Quote/Edit/Tab/Custom.php +137 -0
- app/code/local/Grazitti/Discount/Block/Adminhtml/Promo/Quote/Edit/Tab/Main.php123456 +282 -0
- app/code/local/Grazitti/Discount/Block/Discount.php +17 -0
- app/code/local/Grazitti/Discount/Helper/Data.php +6 -0
- app/code/local/Grazitti/Discount/Model/Discount.php +10 -0
- app/code/local/Grazitti/Discount/Model/Mysql4/Discount.php +17 -0
- app/code/local/Grazitti/Discount/Model/Mysql4/Discount/Collection.php +10 -0
- app/code/local/Grazitti/Discount/Model/Observer.php +89 -0
- app/code/local/Grazitti/Discount/Model/Status.php +15 -0
- app/code/local/Grazitti/Discount/Model/Validator.php +75 -0
- app/code/local/Grazitti/Discount/controllers/Adminhtml/DiscountController.php +214 -0
- app/code/local/Grazitti/Discount/controllers/Adminhtml/Promo/QuoteController.php +223 -0
- app/code/local/Grazitti/Discount/controllers/IndexController.php +9 -0
- app/code/local/Grazitti/Discount/etc/config.xml +149 -0
- app/code/local/Grazitti/Discount/sql/discount_setup/mysql4-install-0.1.0.php +20 -0
- app/design/adminhtml/default/default/layout/discount.xml +40 -0
- app/etc/modules/Grazitti_Discount.xml +17 -0
- package.xml +7 -7
app/code/local/Grazitti/Discount/Block/Adminhtml/Discount.php
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
class Grazitti_Discount_Block_Adminhtml_Discount extends Mage_Adminhtml_Block_Widget_Grid_Container
|
| 3 |
+
{
|
| 4 |
+
public function __construct()
|
| 5 |
+
{
|
| 6 |
+
$this->_controller = 'adminhtml_discount';
|
| 7 |
+
$this->_blockGroup = 'discount';
|
| 8 |
+
$this->_headerText = Mage::helper('discount')->__('Item Manager');
|
| 9 |
+
$this->_addButtonLabel = Mage::helper('discount')->__('Add Item');
|
| 10 |
+
parent::__construct();
|
| 11 |
+
}
|
| 12 |
+
}
|
app/code/local/Grazitti/Discount/Block/Adminhtml/Discount/Edit.php
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
class Grazitti_Discount_Block_Adminhtml_Discount_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 = 'discount';
|
| 11 |
+
$this->_controller = 'adminhtml_discount';
|
| 12 |
+
|
| 13 |
+
$this->_updateButton('save', 'label', Mage::helper('discount')->__('Save Item'));
|
| 14 |
+
$this->_updateButton('delete', 'label', Mage::helper('discount')->__('Delete Item'));
|
| 15 |
+
|
| 16 |
+
$this->_addButton('saveandcontinue', array(
|
| 17 |
+
'label' => Mage::helper('adminhtml')->__('Save And Continue Edit'),
|
| 18 |
+
'onclick' => 'saveAndContinueEdit()',
|
| 19 |
+
'class' => 'save',
|
| 20 |
+
), -100);
|
| 21 |
+
|
| 22 |
+
$this->_formScripts[] = "
|
| 23 |
+
function toggleEditor() {
|
| 24 |
+
if (tinyMCE.getInstanceById('discount_content') == null) {
|
| 25 |
+
tinyMCE.execCommand('mceAddControl', false, 'discount_content');
|
| 26 |
+
} else {
|
| 27 |
+
tinyMCE.execCommand('mceRemoveControl', false, 'discount_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('discount_data') && Mage::registry('discount_data')->getId() ) {
|
| 40 |
+
return Mage::helper('discount')->__("Edit Item '%s'", $this->htmlEscape(Mage::registry('discount_data')->getTitle()));
|
| 41 |
+
} else {
|
| 42 |
+
return Mage::helper('discount')->__('Add Item');
|
| 43 |
+
}
|
| 44 |
+
}
|
| 45 |
+
}
|
app/code/local/Grazitti/Discount/Block/Adminhtml/Discount/Edit/Form.php
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
class Grazitti_Discount_Block_Adminhtml_Discount_Edit_Form extends Mage_Adminhtml_Block_Widget_Form
|
| 4 |
+
{
|
| 5 |
+
protected function _prepareForm()
|
| 6 |
+
{
|
| 7 |
+
$form = new Varien_Data_Form(array(
|
| 8 |
+
'id' => 'edit_form',
|
| 9 |
+
'action' => $this->getUrl('*/*/save', array('id' => $this->getRequest()->getParam('id'))),
|
| 10 |
+
'method' => 'post',
|
| 11 |
+
'enctype' => 'multipart/form-data'
|
| 12 |
+
)
|
| 13 |
+
);
|
| 14 |
+
|
| 15 |
+
$form->setUseContainer(true);
|
| 16 |
+
$this->setForm($form);
|
| 17 |
+
return parent::_prepareForm();
|
| 18 |
+
}
|
| 19 |
+
}
|
app/code/local/Grazitti/Discount/Block/Adminhtml/Discount/Edit/Tab/Form.php
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
class Grazitti_Discount_Block_Adminhtml_Discount_Edit_Tab_Form extends Mage_Adminhtml_Block_Widget_Form
|
| 4 |
+
{
|
| 5 |
+
protected function _prepareForm()
|
| 6 |
+
{
|
| 7 |
+
$form = new Varien_Data_Form();
|
| 8 |
+
$this->setForm($form);
|
| 9 |
+
$fieldset = $form->addFieldset('discount_form', array('legend'=>Mage::helper('discount')->__('Item information')));
|
| 10 |
+
|
| 11 |
+
$fieldset->addField('title', 'text', array(
|
| 12 |
+
'label' => Mage::helper('discount')->__('Title'),
|
| 13 |
+
'class' => 'required-entry',
|
| 14 |
+
'required' => true,
|
| 15 |
+
'name' => 'title',
|
| 16 |
+
));
|
| 17 |
+
|
| 18 |
+
$fieldset->addField('filename', 'file', array(
|
| 19 |
+
'label' => Mage::helper('discount')->__('File'),
|
| 20 |
+
'required' => false,
|
| 21 |
+
'name' => 'filename',
|
| 22 |
+
));
|
| 23 |
+
|
| 24 |
+
$fieldset->addField('status', 'select', array(
|
| 25 |
+
'label' => Mage::helper('discount')->__('Status'),
|
| 26 |
+
'name' => 'status',
|
| 27 |
+
'values' => array(
|
| 28 |
+
array(
|
| 29 |
+
'value' => 1,
|
| 30 |
+
'label' => Mage::helper('discount')->__('Enabled'),
|
| 31 |
+
),
|
| 32 |
+
|
| 33 |
+
array(
|
| 34 |
+
'value' => 2,
|
| 35 |
+
'label' => Mage::helper('discount')->__('Disabled'),
|
| 36 |
+
),
|
| 37 |
+
),
|
| 38 |
+
));
|
| 39 |
+
|
| 40 |
+
$fieldset->addField('content', 'editor', array(
|
| 41 |
+
'name' => 'content',
|
| 42 |
+
'label' => Mage::helper('discount')->__('Content'),
|
| 43 |
+
'title' => Mage::helper('discount')->__('Content'),
|
| 44 |
+
'style' => 'width:700px; height:500px;',
|
| 45 |
+
'wysiwyg' => false,
|
| 46 |
+
'required' => true,
|
| 47 |
+
));
|
| 48 |
+
|
| 49 |
+
if ( Mage::getSingleton('adminhtml/session')->getDiscountData() )
|
| 50 |
+
{
|
| 51 |
+
$form->setValues(Mage::getSingleton('adminhtml/session')->getDiscountData());
|
| 52 |
+
Mage::getSingleton('adminhtml/session')->setDiscountData(null);
|
| 53 |
+
} elseif ( Mage::registry('discount_data') ) {
|
| 54 |
+
$form->setValues(Mage::registry('discount_data')->getData());
|
| 55 |
+
}
|
| 56 |
+
return parent::_prepareForm();
|
| 57 |
+
}
|
| 58 |
+
}
|
app/code/local/Grazitti/Discount/Block/Adminhtml/Discount/Edit/Tabs.php
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
class Grazitti_Discount_Block_Adminhtml_Discount_Edit_Tabs extends Mage_Adminhtml_Block_Widget_Tabs
|
| 4 |
+
{
|
| 5 |
+
|
| 6 |
+
public function __construct()
|
| 7 |
+
{
|
| 8 |
+
parent::__construct();
|
| 9 |
+
$this->setId('discount_tabs');
|
| 10 |
+
$this->setDestElementId('edit_form');
|
| 11 |
+
$this->setTitle(Mage::helper('discount')->__('Item Information'));
|
| 12 |
+
}
|
| 13 |
+
|
| 14 |
+
protected function _beforeToHtml()
|
| 15 |
+
{
|
| 16 |
+
/* $this->addTab('form_section', array(
|
| 17 |
+
'label' => Mage::helper('discount')->__('Item Information'),
|
| 18 |
+
'title' => Mage::helper('discount')->__('Item Information'),
|
| 19 |
+
'content' => $this->getLayout()->createBlock('discount/adminhtml_discount_edit_tab_form')->toHtml(),
|
| 20 |
+
)); */
|
| 21 |
+
$this->addTab('grid_section', array(
|
| 22 |
+
'label' => Mage::helper('salesrule')->__('Customer List'),
|
| 23 |
+
'title' => Mage::helper('salesrule')->__('Customer List'),
|
| 24 |
+
'content' => $this->getLayout()->createBlock('discount/adminhtml_promo_quote_edit_tab_custom')->toHtml(),
|
| 25 |
+
));
|
| 26 |
+
|
| 27 |
+
|
| 28 |
+
return parent::_beforeToHtml();
|
| 29 |
+
}
|
| 30 |
+
}
|
app/code/local/Grazitti/Discount/Block/Adminhtml/Discount/Grid.php
ADDED
|
@@ -0,0 +1,116 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
class Grazitti_Discount_Block_Adminhtml_Discount_Grid extends Mage_Adminhtml_Block_Widget_Grid
|
| 4 |
+
{
|
| 5 |
+
public function __construct()
|
| 6 |
+
{
|
| 7 |
+
parent::__construct();
|
| 8 |
+
$this->setId('discountGrid');
|
| 9 |
+
$this->setDefaultSort('discount_id');
|
| 10 |
+
$this->setDefaultDir('ASC');
|
| 11 |
+
$this->setSaveParametersInSession(true);
|
| 12 |
+
}
|
| 13 |
+
|
| 14 |
+
protected function _prepareCollection()
|
| 15 |
+
{
|
| 16 |
+
$collection = Mage::getModel('discount/discount')->getCollection();
|
| 17 |
+
$this->setCollection($collection);
|
| 18 |
+
return parent::_prepareCollection();
|
| 19 |
+
}
|
| 20 |
+
|
| 21 |
+
protected function _prepareColumns()
|
| 22 |
+
{
|
| 23 |
+
$this->addColumn('discount_id', array(
|
| 24 |
+
'header' => Mage::helper('discount')->__('ID'),
|
| 25 |
+
'align' =>'right',
|
| 26 |
+
'width' => '50px',
|
| 27 |
+
'index' => 'discount_id',
|
| 28 |
+
));
|
| 29 |
+
|
| 30 |
+
$this->addColumn('title', array(
|
| 31 |
+
'header' => Mage::helper('discount')->__('Title'),
|
| 32 |
+
'align' =>'left',
|
| 33 |
+
'index' => 'title',
|
| 34 |
+
));
|
| 35 |
+
|
| 36 |
+
/*
|
| 37 |
+
$this->addColumn('content', array(
|
| 38 |
+
'header' => Mage::helper('discount')->__('Item Content'),
|
| 39 |
+
'width' => '150px',
|
| 40 |
+
'index' => 'content',
|
| 41 |
+
));
|
| 42 |
+
*/
|
| 43 |
+
|
| 44 |
+
$this->addColumn('status', array(
|
| 45 |
+
'header' => Mage::helper('discount')->__('Status'),
|
| 46 |
+
'align' => 'left',
|
| 47 |
+
'width' => '80px',
|
| 48 |
+
'index' => 'status',
|
| 49 |
+
'type' => 'options',
|
| 50 |
+
'options' => array(
|
| 51 |
+
1 => 'Enabled',
|
| 52 |
+
2 => 'Disabled',
|
| 53 |
+
),
|
| 54 |
+
));
|
| 55 |
+
|
| 56 |
+
$this->addColumn('action',
|
| 57 |
+
array(
|
| 58 |
+
'header' => Mage::helper('discount')->__('Action'),
|
| 59 |
+
'width' => '100',
|
| 60 |
+
'type' => 'action',
|
| 61 |
+
'getter' => 'getId',
|
| 62 |
+
'actions' => array(
|
| 63 |
+
array(
|
| 64 |
+
'caption' => Mage::helper('discount')->__('Edit'),
|
| 65 |
+
'url' => array('base'=> '*/*/edit'),
|
| 66 |
+
'field' => 'id'
|
| 67 |
+
)
|
| 68 |
+
),
|
| 69 |
+
'filter' => false,
|
| 70 |
+
'sortable' => false,
|
| 71 |
+
'index' => 'stores',
|
| 72 |
+
'is_system' => true,
|
| 73 |
+
));
|
| 74 |
+
|
| 75 |
+
$this->addExportType('*/*/exportCsv', Mage::helper('discount')->__('CSV'));
|
| 76 |
+
$this->addExportType('*/*/exportXml', Mage::helper('discount')->__('XML'));
|
| 77 |
+
|
| 78 |
+
return parent::_prepareColumns();
|
| 79 |
+
}
|
| 80 |
+
|
| 81 |
+
protected function _prepareMassaction()
|
| 82 |
+
{
|
| 83 |
+
$this->setMassactionIdField('discount_id');
|
| 84 |
+
$this->getMassactionBlock()->setFormFieldName('discount');
|
| 85 |
+
|
| 86 |
+
$this->getMassactionBlock()->addItem('delete', array(
|
| 87 |
+
'label' => Mage::helper('discount')->__('Delete'),
|
| 88 |
+
'url' => $this->getUrl('*/*/massDelete'),
|
| 89 |
+
'confirm' => Mage::helper('discount')->__('Are you sure?')
|
| 90 |
+
));
|
| 91 |
+
|
| 92 |
+
$statuses = Mage::getSingleton('discount/status')->getOptionArray();
|
| 93 |
+
|
| 94 |
+
array_unshift($statuses, array('label'=>'', 'value'=>''));
|
| 95 |
+
$this->getMassactionBlock()->addItem('status', array(
|
| 96 |
+
'label'=> Mage::helper('discount')->__('Change status'),
|
| 97 |
+
'url' => $this->getUrl('*/*/massStatus', array('_current'=>true)),
|
| 98 |
+
'additional' => array(
|
| 99 |
+
'visibility' => array(
|
| 100 |
+
'name' => 'status',
|
| 101 |
+
'type' => 'select',
|
| 102 |
+
'class' => 'required-entry',
|
| 103 |
+
'label' => Mage::helper('discount')->__('Status'),
|
| 104 |
+
'values' => $statuses
|
| 105 |
+
)
|
| 106 |
+
)
|
| 107 |
+
));
|
| 108 |
+
return $this;
|
| 109 |
+
}
|
| 110 |
+
|
| 111 |
+
public function getRowUrl($row)
|
| 112 |
+
{
|
| 113 |
+
return $this->getUrl('*/*/edit', array('id' => $row->getId()));
|
| 114 |
+
}
|
| 115 |
+
|
| 116 |
+
}
|
app/code/local/Grazitti/Discount/Block/Adminhtml/Promo/Quote/Edit/Tab/Custom - Copy.php
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
class Fishpig_Customtabs_Block_Adminhtml_Promo_Quote_Edit_Tab_Custom
|
| 3 |
+
extends Mage_Adminhtml_Block_Widget_Grid
|
| 4 |
+
implements Mage_Adminhtml_Block_Widget_Tab_Interface
|
| 5 |
+
{ /* /**
|
| 6 |
+
* Mandatory to override as we are implementing Widget Tab interface
|
| 7 |
+
* Return Tab Title
|
| 8 |
+
*
|
| 9 |
+
* @return string
|
| 10 |
+
*/
|
| 11 |
+
public function getTabTitle(){
|
| 12 |
+
return Mage::helper('salesrule')->__('Custom Tab');
|
| 13 |
+
}
|
| 14 |
+
|
| 15 |
+
/**
|
| 16 |
+
* Mandatory to override as we are implementing Widget Tab interface
|
| 17 |
+
* Return Tab Label
|
| 18 |
+
*
|
| 19 |
+
* @return string
|
| 20 |
+
*/
|
| 21 |
+
public function getTabLabel(){
|
| 22 |
+
return Mage::helper('salesrule')->__('Custom Tab');
|
| 23 |
+
}
|
| 24 |
+
|
| 25 |
+
/**
|
| 26 |
+
* Mandatory to override as we are implementing Widget Tab interface
|
| 27 |
+
* Can show tab in tabs
|
| 28 |
+
* Here you can write condition when the tab should we shown or not. Like you see when we create shopping cart rule
|
| 29 |
+
* Manage coupon tab doesn't come. If you want that then just make a function and check whether you have information
|
| 30 |
+
* in registry or not
|
| 31 |
+
*
|
| 32 |
+
* @return boolean
|
| 33 |
+
*/
|
| 34 |
+
public function canShowTab(){
|
| 35 |
+
return true;
|
| 36 |
+
}
|
| 37 |
+
|
| 38 |
+
|
| 39 |
+
public function isHidden(){
|
| 40 |
+
return false;
|
| 41 |
+
}
|
| 42 |
+
|
| 43 |
+
|
| 44 |
+
public function getAfter(){
|
| 45 |
+
return 'coupons_section';
|
| 46 |
+
}
|
| 47 |
+
|
| 48 |
+
protected function _prepareCollection()
|
| 49 |
+
{
|
| 50 |
+
$collection = Mage::getResourceModel('customer/customer_collection')
|
| 51 |
+
->addNameToSelect();
|
| 52 |
+
|
| 53 |
+
$this->setCollection($collection);
|
| 54 |
+
return parent::_prepareCollection();
|
| 55 |
+
}
|
| 56 |
+
protected function _prepareColumns()
|
| 57 |
+
{
|
| 58 |
+
$this->addColumn('selected_customers', array(
|
| 59 |
+
'header' => $this->__('Popular'),
|
| 60 |
+
'type' => 'checkbox',
|
| 61 |
+
'index' => 'entity_id',
|
| 62 |
+
'align' => 'center',
|
| 63 |
+
'field_name'=> 'selected_customers',
|
| 64 |
+
'values' => $this->getSelectedCustomers(),
|
| 65 |
+
));
|
| 66 |
+
|
| 67 |
+
return parent::_prepareColumns();
|
| 68 |
+
}
|
| 69 |
+
public function getGridUrl()
|
| 70 |
+
{
|
| 71 |
+
return $this->getUrl('*/*/customersGrid', array('_current' => true));
|
| 72 |
+
} */
|
| 73 |
+
}
|
app/code/local/Grazitti/Discount/Block/Adminhtml/Promo/Quote/Edit/Tab/Custom 23-3-16.php
ADDED
|
@@ -0,0 +1,174 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
class Fishpig_Customtabs_Block_Adminhtml_Promo_Quote_Edit_Tab_Custom
|
| 3 |
+
extends Mage_Adminhtml_Block_Widget_Grid
|
| 4 |
+
|
| 5 |
+
{ /**
|
| 6 |
+
* Mandatory to override as we are implementing Widget Tab interface
|
| 7 |
+
* Return Tab Title
|
| 8 |
+
*
|
| 9 |
+
* @return string
|
| 10 |
+
*/
|
| 11 |
+
public function __construct()
|
| 12 |
+
{
|
| 13 |
+
parent::__construct();
|
| 14 |
+
$this->setId('customerGrid');
|
| 15 |
+
$this->setUseAjax(true); // Using ajax grid is important
|
| 16 |
+
$this->setDefaultSort('entity_id');
|
| 17 |
+
//$this->setTitle(Mage::helper('catalogrule')->__('Catalog Price Rule'));
|
| 18 |
+
$this->setSaveParametersInSession(false);
|
| 19 |
+
}
|
| 20 |
+
|
| 21 |
+
|
| 22 |
+
protected function _prepareCollection()
|
| 23 |
+
{
|
| 24 |
+
|
| 25 |
+
$collection = Mage::getResourceModel('customer/customer_collection')
|
| 26 |
+
->addNameToSelect()
|
| 27 |
+
->addAttributeToSelect('email')
|
| 28 |
+
->addAttributeToSelect('created_at')
|
| 29 |
+
->addAttributeToSelect('group_id')
|
| 30 |
+
->joinAttribute('billing_postcode', 'customer_address/postcode', 'default_billing', null, 'left')
|
| 31 |
+
->joinAttribute('billing_city', 'customer_address/city', 'default_billing', null, 'left')
|
| 32 |
+
->joinAttribute('billing_telephone', 'customer_address/telephone', 'default_billing', null, 'left')
|
| 33 |
+
->joinAttribute('billing_region', 'customer_address/region', 'default_billing', null, 'left')
|
| 34 |
+
->joinAttribute('billing_country_id', 'customer_address/country_id', 'default_billing', null, 'left')
|
| 35 |
+
;
|
| 36 |
+
|
| 37 |
+
|
| 38 |
+
$tm_id = $this->getRequest()->getParam('id');
|
| 39 |
+
if(!isset($tm_id)) {
|
| 40 |
+
$tm_id = 0;
|
| 41 |
+
}
|
| 42 |
+
Mage::getResourceModel('customtabs/customtabs')->addGridPosition($collection,$tm_id);
|
| 43 |
+
//echo'<pre>';print_r($test);
|
| 44 |
+
$this->setCollection($collection);
|
| 45 |
+
return parent::_prepareCollection();
|
| 46 |
+
}
|
| 47 |
+
protected function _addColumnFilterToCollection($column)
|
| 48 |
+
{
|
| 49 |
+
// Set custom filter for in product flag
|
| 50 |
+
//echo'test';
|
| 51 |
+
if ($column->getId() == 'selected_customers') {
|
| 52 |
+
$ids = $this->_getSelectedCustomers();
|
| 53 |
+
if (empty($ids)) {
|
| 54 |
+
$ids = 0;
|
| 55 |
+
}
|
| 56 |
+
if ($column->getFilter()->getValue()) {
|
| 57 |
+
$this->getCollection()->addFieldToFilter('entity_id', array('in'=>$ids));
|
| 58 |
+
} else {
|
| 59 |
+
if($productIds) {
|
| 60 |
+
$this->getCollection()->addFieldToFilter('entity_id', array('nin'=>$ids));
|
| 61 |
+
}
|
| 62 |
+
}
|
| 63 |
+
} else {
|
| 64 |
+
parent::_addColumnFilterToCollection($column);
|
| 65 |
+
}
|
| 66 |
+
return $this;
|
| 67 |
+
}
|
| 68 |
+
protected function _prepareColumns()
|
| 69 |
+
{
|
| 70 |
+
|
| 71 |
+
$this->addColumn('selected_customers', array(
|
| 72 |
+
'header' => $this->__('Popular'),
|
| 73 |
+
'type' => 'checkbox',
|
| 74 |
+
'index' => 'entity_id',
|
| 75 |
+
'align' => 'center',
|
| 76 |
+
'field_name'=> 'selected_customers[]',
|
| 77 |
+
'values' => $this->_getSelectedCustomers(),
|
| 78 |
+
));
|
| 79 |
+
|
| 80 |
+
$this->addColumn('entity_id', array(
|
| 81 |
+
'header' => Mage::helper('customer')->__('ID'),
|
| 82 |
+
'width' => '50px',
|
| 83 |
+
'index' => 'entity_id',
|
| 84 |
+
'type' => 'number',
|
| 85 |
+
));
|
| 86 |
+
$this->addColumn('customer_name', array(
|
| 87 |
+
'header' => Mage::helper('customer')->__('Name'),
|
| 88 |
+
'index' => 'name'
|
| 89 |
+
));
|
| 90 |
+
$this->addColumn('customer_email', array(
|
| 91 |
+
'header' => Mage::helper('customer')->__('Email'),
|
| 92 |
+
'width' => '150',
|
| 93 |
+
'index' => 'email'
|
| 94 |
+
));
|
| 95 |
+
|
| 96 |
+
$groups = Mage::getResourceModel('customer/group_collection')
|
| 97 |
+
->addFieldToFilter('customer_group_id', array('gt'=> 0))
|
| 98 |
+
->load()
|
| 99 |
+
->toOptionHash();
|
| 100 |
+
|
| 101 |
+
$this->addColumn('group', array(
|
| 102 |
+
'header' => Mage::helper('customer')->__('Group'),
|
| 103 |
+
'width' => '100',
|
| 104 |
+
'index' => 'group_id',
|
| 105 |
+
'type' => 'options',
|
| 106 |
+
'options' => $groups,
|
| 107 |
+
));
|
| 108 |
+
$this->addColumn('customer_since', array(
|
| 109 |
+
'header' => Mage::helper('customer')->__('Customer Since'),
|
| 110 |
+
'type' => 'datetime',
|
| 111 |
+
'align' => 'center',
|
| 112 |
+
'index' => 'created_at',
|
| 113 |
+
'gmtoffset' => true
|
| 114 |
+
));
|
| 115 |
+
$this->addColumn('position', array(
|
| 116 |
+
'header' => Mage::helper('catalog')->__('Position'),
|
| 117 |
+
'name' => 'position',
|
| 118 |
+
'width' => 60,
|
| 119 |
+
'type' => 'number',
|
| 120 |
+
'validate_class' => 'validate-number',
|
| 121 |
+
'index' => 'position',
|
| 122 |
+
'editable' => true,
|
| 123 |
+
'edit_only' => true
|
| 124 |
+
));
|
| 125 |
+
|
| 126 |
+
return parent::_prepareColumns();
|
| 127 |
+
}
|
| 128 |
+
protected function _getSelectedCustomers() // Used in grid to return selected customers values.
|
| 129 |
+
{
|
| 130 |
+
$customers = array_keys($this->getSelectedCustomers());
|
| 131 |
+
|
| 132 |
+
return $customers;
|
| 133 |
+
}
|
| 134 |
+
public function getGridUrl()
|
| 135 |
+
{
|
| 136 |
+
return $this->_getData('grid_url') ? $this->_getData('grid_url') : $this->getUrl('*/*/customergrid', array('_current'=>true));
|
| 137 |
+
}
|
| 138 |
+
protected function getSelectedCustomers()
|
| 139 |
+
{
|
| 140 |
+
/* $tm_id = $this->getRequest()->getParam('id');
|
| 141 |
+
//print_r($this->getRequest()->getParam('rule_id')); die;
|
| 142 |
+
if(!isset($tm_id)) {
|
| 143 |
+
$tm_id = 0;
|
| 144 |
+
}
|
| 145 |
+
$collection = Mage::getModel('customtabs/customtabs')->getCollection();
|
| 146 |
+
$collection->addFieldToFilter('rule_id',$tm_id);
|
| 147 |
+
|
| 148 |
+
//echo'<pre>';print_r($collection);die;
|
| 149 |
+
$custIds = array();
|
| 150 |
+
|
| 151 |
+
foreach($collection as $obj){
|
| 152 |
+
$custIds[$obj->getCustomerId()] = array('position'=>$obj->getPosition());
|
| 153 |
+
//print_r($custIds); die;
|
| 154 |
+
}
|
| 155 |
+
return $custIds;
|
| 156 |
+
} */
|
| 157 |
+
$tm_id = $this->getRequest()->getParam('id');
|
| 158 |
+
//print_r($this->getRequest()->getParam('rule_id')); die;
|
| 159 |
+
if(!isset($tm_id)) {
|
| 160 |
+
$tm_id = 0;
|
| 161 |
+
}
|
| 162 |
+
$collection = Mage::getModel('customtabs/customtabs')->getCollection();
|
| 163 |
+
$collection = $collection->addFieldToFilter('rule_id',$tm_id)->getFirstItem();
|
| 164 |
+
$customer_ids = explode(",",$collection['customer_id']);
|
| 165 |
+
//echo'<pre>';print_r($customer_ids); die;
|
| 166 |
+
$custIds = array();
|
| 167 |
+
|
| 168 |
+
foreach($customer_ids as $obj){
|
| 169 |
+
$custIds[$obj] = array('position'=>'0');
|
| 170 |
+
|
| 171 |
+
}
|
| 172 |
+
return $custIds;
|
| 173 |
+
}
|
| 174 |
+
}
|
app/code/local/Grazitti/Discount/Block/Adminhtml/Promo/Quote/Edit/Tab/Custom.php
ADDED
|
@@ -0,0 +1,137 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
class Grazitti_Discount_Block_Adminhtml_Promo_Quote_Edit_Tab_Custom
|
| 3 |
+
extends Mage_Adminhtml_Block_Widget_Grid
|
| 4 |
+
|
| 5 |
+
{ /**
|
| 6 |
+
* Mandatory to override as we are implementing Widget Tab interface
|
| 7 |
+
* Return Tab Title
|
| 8 |
+
*
|
| 9 |
+
* @return string
|
| 10 |
+
*/
|
| 11 |
+
public function __construct()
|
| 12 |
+
{
|
| 13 |
+
parent::__construct();
|
| 14 |
+
$this->setId('customerGrid');
|
| 15 |
+
$this->setUseAjax(true);
|
| 16 |
+
$this->setDefaultSort('entity_id');
|
| 17 |
+
$this->setSaveParametersInSession(false);
|
| 18 |
+
}
|
| 19 |
+
|
| 20 |
+
|
| 21 |
+
protected function _prepareCollection()
|
| 22 |
+
{
|
| 23 |
+
|
| 24 |
+
$collection = Mage::getResourceModel('customer/customer_collection')->addNameToSelect()->addAttributeToSelect('email')->addAttributeToSelect('created_at')->addAttributeToSelect('group_id')
|
| 25 |
+
;
|
| 26 |
+
$this->setCollection($collection);
|
| 27 |
+
return parent::_prepareCollection();
|
| 28 |
+
}
|
| 29 |
+
protected function _addColumnFilterToCollection($column)
|
| 30 |
+
{
|
| 31 |
+
|
| 32 |
+
if ($column->getId() == 'selected_customers') {
|
| 33 |
+
$ids = $this->_getSelectedCustomers();
|
| 34 |
+
if (empty($ids)) {$ids = 0;}
|
| 35 |
+
if ($column->getFilter()->getValue()) {
|
| 36 |
+
$this->getCollection()->addFieldToFilter('entity_id', array('in'=>$ids));
|
| 37 |
+
} else {
|
| 38 |
+
if($productIds) {
|
| 39 |
+
$this->getCollection()->addFieldToFilter('entity_id', array('nin'=>$ids));
|
| 40 |
+
}
|
| 41 |
+
}
|
| 42 |
+
} else {
|
| 43 |
+
parent::_addColumnFilterToCollection($column);
|
| 44 |
+
}
|
| 45 |
+
return $this;
|
| 46 |
+
}
|
| 47 |
+
protected function _prepareColumns()
|
| 48 |
+
{
|
| 49 |
+
|
| 50 |
+
$this->addColumn('selected_customers', array(
|
| 51 |
+
'header' => $this->__('Popular'),
|
| 52 |
+
'type' => 'checkbox',
|
| 53 |
+
'index' => 'entity_id',
|
| 54 |
+
'align' => 'center',
|
| 55 |
+
'field_name'=> 'selected_customers[]',
|
| 56 |
+
'values' => $this->_getSelectedCustomers(),
|
| 57 |
+
));
|
| 58 |
+
|
| 59 |
+
$this->addColumn('entity_id', array(
|
| 60 |
+
'header' => Mage::helper('customer')->__('ID'),
|
| 61 |
+
'width' => '50px',
|
| 62 |
+
'index' => 'entity_id',
|
| 63 |
+
'type' => 'number',
|
| 64 |
+
));
|
| 65 |
+
$this->addColumn('customer_name', array(
|
| 66 |
+
'header' => Mage::helper('customer')->__('Name'),
|
| 67 |
+
'index' => 'name'
|
| 68 |
+
));
|
| 69 |
+
$this->addColumn('customer_email', array(
|
| 70 |
+
'header' => Mage::helper('customer')->__('Email'),
|
| 71 |
+
'width' => '150',
|
| 72 |
+
'index' => 'email'
|
| 73 |
+
));
|
| 74 |
+
|
| 75 |
+
$groups = Mage::getResourceModel('customer/group_collection')
|
| 76 |
+
->addFieldToFilter('customer_group_id', array('gt'=> 0))
|
| 77 |
+
->load()
|
| 78 |
+
->toOptionHash();
|
| 79 |
+
|
| 80 |
+
$this->addColumn('group', array(
|
| 81 |
+
'header' => Mage::helper('customer')->__('Group'),
|
| 82 |
+
'width' => '100',
|
| 83 |
+
'index' => 'group_id',
|
| 84 |
+
'type' => 'options',
|
| 85 |
+
'options' => $groups,
|
| 86 |
+
));
|
| 87 |
+
$this->addColumn('customer_since', array(
|
| 88 |
+
'header' => Mage::helper('customer')->__('Customer Since'),
|
| 89 |
+
'type' => 'datetime',
|
| 90 |
+
'align' => 'center',
|
| 91 |
+
'index' => 'created_at',
|
| 92 |
+
'gmtoffset' => true
|
| 93 |
+
));
|
| 94 |
+
$this->addColumn('position', array(
|
| 95 |
+
'header' => Mage::helper('catalog')->__('Position'),
|
| 96 |
+
'name' => 'position',
|
| 97 |
+
'width' => 60,
|
| 98 |
+
'type' => 'number',
|
| 99 |
+
'validate_class' => 'validate-number',
|
| 100 |
+
'index' => 'position',
|
| 101 |
+
'editable' => true,
|
| 102 |
+
'edit_only' => true
|
| 103 |
+
));
|
| 104 |
+
|
| 105 |
+
return parent::_prepareColumns();
|
| 106 |
+
}
|
| 107 |
+
protected function _getSelectedCustomers() // Used in grid to return selected customers values.
|
| 108 |
+
{
|
| 109 |
+
$customers = array_keys($this->getSelectedCustomers());
|
| 110 |
+
|
| 111 |
+
return $customers;
|
| 112 |
+
}
|
| 113 |
+
public function getGridUrl()
|
| 114 |
+
{
|
| 115 |
+
return $this->_getData('grid_url') ? $this->_getData('grid_url') : $this->getUrl('*/*/customergrid', array('_current'=>true));
|
| 116 |
+
}
|
| 117 |
+
protected function getSelectedCustomers()
|
| 118 |
+
{
|
| 119 |
+
|
| 120 |
+
$tm_id = $this->getRequest()->getParam('id');
|
| 121 |
+
//print_r($this->getRequest()->getParam('rule_id')); die;
|
| 122 |
+
if(!isset($tm_id)) {
|
| 123 |
+
$tm_id = 0;
|
| 124 |
+
}
|
| 125 |
+
$collection = Mage::getModel('discount/discount')->getCollection();
|
| 126 |
+
$collection = $collection->addFieldToFilter('rule_id',$tm_id)->getFirstItem();
|
| 127 |
+
$customer_ids = explode(",",$collection['customer_id']);
|
| 128 |
+
//echo'<pre>';print_r($customer_ids); die;
|
| 129 |
+
$custIds = array();
|
| 130 |
+
|
| 131 |
+
foreach($customer_ids as $obj){
|
| 132 |
+
$custIds[$obj] = array('position'=>'0');
|
| 133 |
+
|
| 134 |
+
}
|
| 135 |
+
return $custIds;
|
| 136 |
+
}
|
| 137 |
+
}
|
app/code/local/Grazitti/Discount/Block/Adminhtml/Promo/Quote/Edit/Tab/Main.php123456
ADDED
|
@@ -0,0 +1,282 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* Magento
|
| 4 |
+
*
|
| 5 |
+
* NOTICE OF LICENSE
|
| 6 |
+
*
|
| 7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
| 8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
| 9 |
+
* It is also available through the world-wide-web at this URL:
|
| 10 |
+
* http://opensource.org/licenses/osl-3.0.php
|
| 11 |
+
* If you did not receive a copy of the license and are unable to
|
| 12 |
+
* obtain it through the world-wide-web, please send an email
|
| 13 |
+
* to license@magento.com so we can send you a copy immediately.
|
| 14 |
+
*
|
| 15 |
+
* DISCLAIMER
|
| 16 |
+
*
|
| 17 |
+
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
| 18 |
+
* versions in the future. If you wish to customize Magento for your
|
| 19 |
+
* needs please refer to http://www.magento.com for more information.
|
| 20 |
+
*
|
| 21 |
+
* @category Mage
|
| 22 |
+
* @package Mage_Adminhtml
|
| 23 |
+
* @copyright Copyright (c) 2006-2015 X.commerce, Inc. (http://www.magento.com)
|
| 24 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
| 25 |
+
*/
|
| 26 |
+
|
| 27 |
+
/**
|
| 28 |
+
* Shopping Cart Price Rule General Information Tab
|
| 29 |
+
*
|
| 30 |
+
* @category Mage
|
| 31 |
+
* @package Mage_Adminhtml
|
| 32 |
+
* @author Magento Core Team <core@magentocommerce.com>
|
| 33 |
+
*/
|
| 34 |
+
class Mage_Adminhtml_Block_Promo_Quote_Edit_Tab_Main
|
| 35 |
+
extends Mage_Adminhtml_Block_Widget_Form
|
| 36 |
+
implements Mage_Adminhtml_Block_Widget_Tab_Interface
|
| 37 |
+
{
|
| 38 |
+
/**
|
| 39 |
+
* Prepare content for tab
|
| 40 |
+
*
|
| 41 |
+
* @return string
|
| 42 |
+
*/
|
| 43 |
+
public function getTabLabel()
|
| 44 |
+
{
|
| 45 |
+
return Mage::helper('salesrule')->__('Rule Information');
|
| 46 |
+
}
|
| 47 |
+
|
| 48 |
+
/**
|
| 49 |
+
* Prepare title for tab
|
| 50 |
+
*
|
| 51 |
+
* @return string
|
| 52 |
+
*/
|
| 53 |
+
public function getTabTitle()
|
| 54 |
+
{
|
| 55 |
+
return Mage::helper('salesrule')->__('Rule Information');
|
| 56 |
+
}
|
| 57 |
+
|
| 58 |
+
/**
|
| 59 |
+
* Returns status flag about this tab can be showed or not
|
| 60 |
+
*
|
| 61 |
+
* @return true
|
| 62 |
+
*/
|
| 63 |
+
public function canShowTab()
|
| 64 |
+
{
|
| 65 |
+
return true;
|
| 66 |
+
}
|
| 67 |
+
|
| 68 |
+
/**
|
| 69 |
+
* Returns status flag about this tab hidden or not
|
| 70 |
+
*
|
| 71 |
+
* @return true
|
| 72 |
+
*/
|
| 73 |
+
public function isHidden()
|
| 74 |
+
{
|
| 75 |
+
return false;
|
| 76 |
+
}
|
| 77 |
+
|
| 78 |
+
protected function _prepareForm()
|
| 79 |
+
{
|
| 80 |
+
$model = Mage::registry('current_promo_quote_rule');
|
| 81 |
+
|
| 82 |
+
$form = new Varien_Data_Form();
|
| 83 |
+
$form->setHtmlIdPrefix('rule_');
|
| 84 |
+
|
| 85 |
+
$fieldset = $form->addFieldset('base_fieldset',
|
| 86 |
+
array('legend' => Mage::helper('salesrule')->__('General Information'))
|
| 87 |
+
);
|
| 88 |
+
|
| 89 |
+
if ($model->getId()) {
|
| 90 |
+
$fieldset->addField('rule_id', 'hidden', array(
|
| 91 |
+
'name' => 'rule_id',
|
| 92 |
+
));
|
| 93 |
+
}
|
| 94 |
+
|
| 95 |
+
$fieldset->addField('product_ids', 'hidden', array(
|
| 96 |
+
'name' => 'product_ids',
|
| 97 |
+
));
|
| 98 |
+
|
| 99 |
+
$fieldset->addField('name', 'text', array(
|
| 100 |
+
'name' => 'name',
|
| 101 |
+
'label' => Mage::helper('salesrule')->__('Rule Name'),
|
| 102 |
+
'title' => Mage::helper('salesrule')->__('Rule Name'),
|
| 103 |
+
'required' => true,
|
| 104 |
+
));
|
| 105 |
+
|
| 106 |
+
$fieldset->addField('description', 'textarea', array(
|
| 107 |
+
'name' => 'description',
|
| 108 |
+
'label' => Mage::helper('salesrule')->__('Description'),
|
| 109 |
+
'title' => Mage::helper('salesrule')->__('Description'),
|
| 110 |
+
'style' => 'height: 100px;',
|
| 111 |
+
));
|
| 112 |
+
|
| 113 |
+
$fieldset->addField('is_active', 'select', array(
|
| 114 |
+
'label' => Mage::helper('salesrule')->__('Status'),
|
| 115 |
+
'title' => Mage::helper('salesrule')->__('Status'),
|
| 116 |
+
'name' => 'is_active',
|
| 117 |
+
'required' => true,
|
| 118 |
+
'options' => array(
|
| 119 |
+
'1' => Mage::helper('salesrule')->__('Active'),
|
| 120 |
+
'0' => Mage::helper('salesrule')->__('Inactive'),
|
| 121 |
+
),
|
| 122 |
+
));
|
| 123 |
+
|
| 124 |
+
if (!$model->getId()) {
|
| 125 |
+
$model->setData('is_active', '1');
|
| 126 |
+
}
|
| 127 |
+
|
| 128 |
+
if (Mage::app()->isSingleStoreMode()) {
|
| 129 |
+
$websiteId = Mage::app()->getStore(true)->getWebsiteId();
|
| 130 |
+
$fieldset->addField('website_ids', 'hidden', array(
|
| 131 |
+
'name' => 'website_ids[]',
|
| 132 |
+
'value' => $websiteId
|
| 133 |
+
));
|
| 134 |
+
$model->setWebsiteIds($websiteId);
|
| 135 |
+
} else {
|
| 136 |
+
$field = $fieldset->addField('website_ids', 'multiselect', array(
|
| 137 |
+
'name' => 'website_ids[]',
|
| 138 |
+
'label' => Mage::helper('salesrule')->__('Websites'),
|
| 139 |
+
'title' => Mage::helper('salesrule')->__('Websites'),
|
| 140 |
+
'required' => true,
|
| 141 |
+
'values' => Mage::getSingleton('adminhtml/system_store')->getWebsiteValuesForForm()
|
| 142 |
+
));
|
| 143 |
+
$renderer = $this->getLayout()->createBlock('adminhtml/store_switcher_form_renderer_fieldset_element');
|
| 144 |
+
$field->setRenderer($renderer);
|
| 145 |
+
}
|
| 146 |
+
|
| 147 |
+
$customerGroups = Mage::getResourceModel('customer/group_collection')->load()->toOptionArray();
|
| 148 |
+
$found = false;
|
| 149 |
+
|
| 150 |
+
foreach ($customerGroups as $group) {
|
| 151 |
+
if ($group['value']==0) {
|
| 152 |
+
$found = true;
|
| 153 |
+
}
|
| 154 |
+
}
|
| 155 |
+
if (!$found) {
|
| 156 |
+
array_unshift($customerGroups, array(
|
| 157 |
+
'value' => 0,
|
| 158 |
+
'label' => Mage::helper('salesrule')->__('NOT LOGGED IN'))
|
| 159 |
+
);
|
| 160 |
+
}
|
| 161 |
+
|
| 162 |
+
$fieldset->addField('customer_group_ids', 'multiselect', array(
|
| 163 |
+
'name' => 'customer_group_ids[]',
|
| 164 |
+
'label' => Mage::helper('salesrule')->__('Customer Groups'),
|
| 165 |
+
'title' => Mage::helper('salesrule')->__('Customer Groups'),
|
| 166 |
+
'required' => true,
|
| 167 |
+
'values' => Mage::getResourceModel('customer/group_collection')->toOptionArray(),
|
| 168 |
+
));
|
| 169 |
+
|
| 170 |
+
$couponTypeFiled = $fieldset->addField('coupon_type', 'select', array(
|
| 171 |
+
'name' => 'coupon_type',
|
| 172 |
+
'label' => Mage::helper('salesrule')->__('Coupon'),
|
| 173 |
+
'required' => true,
|
| 174 |
+
'options' => Mage::getModel('salesrule/rule')->getCouponTypes(),
|
| 175 |
+
));
|
| 176 |
+
|
| 177 |
+
$couponCodeFiled = $fieldset->addField('coupon_code', 'text', array(
|
| 178 |
+
'name' => 'coupon_code',
|
| 179 |
+
'label' => Mage::helper('salesrule')->__('Coupon Code'),
|
| 180 |
+
'required' => true,
|
| 181 |
+
));
|
| 182 |
+
|
| 183 |
+
$autoGenerationCheckbox = $fieldset->addField('use_auto_generation', 'checkbox', array(
|
| 184 |
+
'name' => 'use_auto_generation',
|
| 185 |
+
'label' => Mage::helper('salesrule')->__('Use Auto Generation'),
|
| 186 |
+
'note' => Mage::helper('salesrule')->__('If you select and save the rule you will be able to generate multiple coupon codes.'),
|
| 187 |
+
'onclick' => 'handleCouponsTabContentActivity()',
|
| 188 |
+
'checked' => (int)$model->getUseAutoGeneration() > 0 ? 'checked' : ''
|
| 189 |
+
));
|
| 190 |
+
|
| 191 |
+
$autoGenerationCheckbox->setRenderer(
|
| 192 |
+
$this->getLayout()->createBlock('adminhtml/promo_quote_edit_tab_main_renderer_checkbox')
|
| 193 |
+
);
|
| 194 |
+
|
| 195 |
+
$usesPerCouponFiled = $fieldset->addField('uses_per_coupon', 'text', array(
|
| 196 |
+
'name' => 'uses_per_coupon',
|
| 197 |
+
'label' => Mage::helper('salesrule')->__('Uses per Coupon'),
|
| 198 |
+
));
|
| 199 |
+
|
| 200 |
+
$fieldset->addField('uses_per_customer', 'text', array(
|
| 201 |
+
'name' => 'uses_per_customer',
|
| 202 |
+
'label' => Mage::helper('salesrule')->__('Uses per Customer'),
|
| 203 |
+
'note' => Mage::helper('salesrule')->__('Usage limit enforced for logged in customers only'),
|
| 204 |
+
));
|
| 205 |
+
|
| 206 |
+
$dateFormatIso = Mage::app()->getLocale()->getDateFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT);
|
| 207 |
+
$fieldset->addField('from_date', 'date', array(
|
| 208 |
+
'name' => 'from_date',
|
| 209 |
+
'label' => Mage::helper('salesrule')->__('From Date'),
|
| 210 |
+
'title' => Mage::helper('salesrule')->__('From Date'),
|
| 211 |
+
'image' => $this->getSkinUrl('images/grid-cal.gif'),
|
| 212 |
+
'input_format' => Varien_Date::DATE_INTERNAL_FORMAT,
|
| 213 |
+
'format' => $dateFormatIso
|
| 214 |
+
));
|
| 215 |
+
$fieldset->addField('to_date', 'date', array(
|
| 216 |
+
'name' => 'to_date',
|
| 217 |
+
'label' => Mage::helper('salesrule')->__('To Date'),
|
| 218 |
+
'title' => Mage::helper('salesrule')->__('To Date'),
|
| 219 |
+
'image' => $this->getSkinUrl('images/grid-cal.gif'),
|
| 220 |
+
'input_format' => Varien_Date::DATE_INTERNAL_FORMAT,
|
| 221 |
+
'format' => $dateFormatIso
|
| 222 |
+
));
|
| 223 |
+
|
| 224 |
+
$fieldset->addField('sort_order', 'text', array(
|
| 225 |
+
'name' => 'sort_order',
|
| 226 |
+
'label' => Mage::helper('salesrule')->__('Priority'),
|
| 227 |
+
));
|
| 228 |
+
|
| 229 |
+
$fieldset->addField('is_rss', 'select', array(
|
| 230 |
+
'label' => Mage::helper('salesrule')->__('Public In RSS Feed'),
|
| 231 |
+
'title' => Mage::helper('salesrule')->__('Public In RSS Feed'),
|
| 232 |
+
'name' => 'is_rss',
|
| 233 |
+
'options' => array(
|
| 234 |
+
'1' => Mage::helper('salesrule')->__('Yes'),
|
| 235 |
+
'0' => Mage::helper('salesrule')->__('No'),
|
| 236 |
+
),
|
| 237 |
+
));
|
| 238 |
+
|
| 239 |
+
if(!$model->getId()){
|
| 240 |
+
//set the default value for is_rss feed to yes for new promotion
|
| 241 |
+
$model->setIsRss(1);
|
| 242 |
+
}
|
| 243 |
+
|
| 244 |
+
$form->setValues($model->getData());
|
| 245 |
+
|
| 246 |
+
$autoGenerationCheckbox->setValue(1);
|
| 247 |
+
|
| 248 |
+
if ($model->isReadonly()) {
|
| 249 |
+
foreach ($fieldset->getElements() as $element) {
|
| 250 |
+
$element->setReadonly(true, true);
|
| 251 |
+
}
|
| 252 |
+
}
|
| 253 |
+
|
| 254 |
+
//$form->setUseContainer(true);
|
| 255 |
+
|
| 256 |
+
$this->setForm($form);
|
| 257 |
+
|
| 258 |
+
// field dependencies
|
| 259 |
+
$this->setChild('form_after', $this->getLayout()->createBlock('adminhtml/widget_form_element_dependence')
|
| 260 |
+
->addFieldMap($couponTypeFiled->getHtmlId(), $couponTypeFiled->getName())
|
| 261 |
+
->addFieldMap($couponCodeFiled->getHtmlId(), $couponCodeFiled->getName())
|
| 262 |
+
->addFieldMap($autoGenerationCheckbox->getHtmlId(), $autoGenerationCheckbox->getName())
|
| 263 |
+
->addFieldMap($usesPerCouponFiled->getHtmlId(), $usesPerCouponFiled->getName())
|
| 264 |
+
->addFieldDependence(
|
| 265 |
+
$couponCodeFiled->getName(),
|
| 266 |
+
$couponTypeFiled->getName(),
|
| 267 |
+
Mage_SalesRule_Model_Rule::COUPON_TYPE_SPECIFIC)
|
| 268 |
+
->addFieldDependence(
|
| 269 |
+
$autoGenerationCheckbox->getName(),
|
| 270 |
+
$couponTypeFiled->getName(),
|
| 271 |
+
Mage_SalesRule_Model_Rule::COUPON_TYPE_SPECIFIC)
|
| 272 |
+
->addFieldDependence(
|
| 273 |
+
$usesPerCouponFiled->getName(),
|
| 274 |
+
$couponTypeFiled->getName(),
|
| 275 |
+
Mage_SalesRule_Model_Rule::COUPON_TYPE_SPECIFIC)
|
| 276 |
+
);
|
| 277 |
+
|
| 278 |
+
Mage::dispatchEvent('adminhtml_promo_quote_edit_tab_main_prepare_form', array('form' => $form));
|
| 279 |
+
|
| 280 |
+
return parent::_prepareForm();
|
| 281 |
+
}
|
| 282 |
+
}
|
app/code/local/Grazitti/Discount/Block/Discount.php
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
class Grazitti_Discount_Block_Discount extends Mage_Core_Block_Template
|
| 3 |
+
{
|
| 4 |
+
public function _prepareLayout()
|
| 5 |
+
{
|
| 6 |
+
return parent::_prepareLayout();
|
| 7 |
+
}
|
| 8 |
+
|
| 9 |
+
public function getDiscount()
|
| 10 |
+
{
|
| 11 |
+
if (!$this->hasData('discount')) {
|
| 12 |
+
$this->setData('discount', Mage::registry('discount'));
|
| 13 |
+
}
|
| 14 |
+
return $this->getData('discount');
|
| 15 |
+
|
| 16 |
+
}
|
| 17 |
+
}
|
app/code/local/Grazitti/Discount/Helper/Data.php
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
class Grazitti_Discount_Helper_Data extends Mage_Core_Helper_Abstract
|
| 4 |
+
{
|
| 5 |
+
|
| 6 |
+
}
|
app/code/local/Grazitti/Discount/Model/Discount.php
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
class Grazitti_Discount_Model_Discount extends Mage_Core_Model_Abstract
|
| 4 |
+
{
|
| 5 |
+
public function _construct()
|
| 6 |
+
{
|
| 7 |
+
parent::_construct();
|
| 8 |
+
$this->_init('discount/discount');
|
| 9 |
+
}
|
| 10 |
+
}
|
app/code/local/Grazitti/Discount/Model/Mysql4/Discount.php
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
class Grazitti_Discount_Model_Mysql4_Discount extends Mage_Core_Model_Mysql4_Abstract
|
| 4 |
+
{
|
| 5 |
+
public function _construct()
|
| 6 |
+
{
|
| 7 |
+
// Note that the discount_id refers to the key field in your database table.
|
| 8 |
+
$this->_init('discount/discount', 'discount_id');
|
| 9 |
+
}
|
| 10 |
+
public function addGridPosition($collection,$rule_id){
|
| 11 |
+
$table2 = $this->getMainTable();
|
| 12 |
+
$cond = $this->_getWriteAdapter()->quoteInto('e.entity_id = t2.customer_id','');
|
| 13 |
+
$collection->getSelect()->joinLeft(array('t2'=>$table2), $cond);
|
| 14 |
+
$collection->getSelect()->group('e.entity_id');
|
| 15 |
+
//echo $collection->getSelect(); die;
|
| 16 |
+
}
|
| 17 |
+
}
|
app/code/local/Grazitti/Discount/Model/Mysql4/Discount/Collection.php
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
class Grazitti_Discount_Model_Mysql4_Discount_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
|
| 4 |
+
{
|
| 5 |
+
public function _construct()
|
| 6 |
+
{
|
| 7 |
+
parent::_construct();
|
| 8 |
+
$this->_init('discount/discount');
|
| 9 |
+
}
|
| 10 |
+
}
|
app/code/local/Grazitti/Discount/Model/Observer.php
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
class Grazitti_Discount_Model_Observer
|
| 4 |
+
{
|
| 5 |
+
/**
|
| 6 |
+
* Flag to stop observer executing more than once
|
| 7 |
+
*
|
| 8 |
+
* @var static bool
|
| 9 |
+
*/
|
| 10 |
+
static protected $_singletonFlag = false;
|
| 11 |
+
|
| 12 |
+
/**
|
| 13 |
+
* This method will run when the product is saved from the Magento Admin
|
| 14 |
+
* Use this function to update the product model, process the
|
| 15 |
+
* data or anything you like
|
| 16 |
+
*
|
| 17 |
+
* @param Varien_Event_Observer $observer
|
| 18 |
+
*/
|
| 19 |
+
public function saveProductTabData1(Varien_Event_Observer $observer)
|
| 20 |
+
{
|
| 21 |
+
// Mage::getModel('customtabs/customtabs')->load(5)
|
| 22 |
+
// $rule_id=Mage::app()->getRequest()->getParam('rule_id');
|
| 23 |
+
// $selected_customers=Mage::app()->getRequest()->getParam('selected_customers');
|
| 24 |
+
// $selected_customers=implode(",",$selected_customers);
|
| 25 |
+
|
| 26 |
+
// $customTabModule=Mage::getModel('customtabs/customtabs');
|
| 27 |
+
// $customTabModule=$customTabModule->setRuleId($rule_id);
|
| 28 |
+
// $customTabModule=$customTabModule->setCustomerId($selected_customers);
|
| 29 |
+
// $customTabModule=$customTabModule->save();
|
| 30 |
+
// echo "<pre>";
|
| 31 |
+
// print_r($customTabModule->getData());
|
| 32 |
+
// echo "<pre>asdsa";
|
| 33 |
+
// print_r(Mage::app()->getRequest()->getParam('selected_customers'));
|
| 34 |
+
// print_r(Mage::app()->getRequest()->getParams());die;
|
| 35 |
+
// print_r($observer->getEvent()->getRule()->getData());
|
| 36 |
+
$customFieldValue = $this->_getRequest()->getPost('custom_field');
|
| 37 |
+
// echo "<pre>";
|
| 38 |
+
// print_r($customFieldValue);
|
| 39 |
+
// die;
|
| 40 |
+
}
|
| 41 |
+
public function saveProductTabData(Varien_Event_Observer $observer)
|
| 42 |
+
{
|
| 43 |
+
// echo "<pre>";
|
| 44 |
+
// print_r($observer->getEvent());die;
|
| 45 |
+
if (!self::$_singletonFlag) {
|
| 46 |
+
self::$_singletonFlag = true;
|
| 47 |
+
|
| 48 |
+
$product = $observer->getEvent()->getProduct();
|
| 49 |
+
|
| 50 |
+
try {
|
| 51 |
+
/**
|
| 52 |
+
* Perform any actions you want here
|
| 53 |
+
*
|
| 54 |
+
*/
|
| 55 |
+
$customFieldValue = $this->_getRequest()->getPost('custom_field');
|
| 56 |
+
//echo "<pre>";
|
| 57 |
+
//print_r($customFieldValue);die;
|
| 58 |
+
|
| 59 |
+
/**
|
| 60 |
+
* Uncomment the line below to save the product
|
| 61 |
+
*
|
| 62 |
+
*/
|
| 63 |
+
//$product->save();
|
| 64 |
+
}
|
| 65 |
+
catch (Exception $e) {
|
| 66 |
+
Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
|
| 67 |
+
}
|
| 68 |
+
}
|
| 69 |
+
}
|
| 70 |
+
|
| 71 |
+
/**
|
| 72 |
+
* Retrieve the product model
|
| 73 |
+
*
|
| 74 |
+
* @return Mage_Catalog_Model_Product $product
|
| 75 |
+
*/
|
| 76 |
+
public function getProduct()
|
| 77 |
+
{
|
| 78 |
+
return Mage::registry('product');
|
| 79 |
+
}
|
| 80 |
+
|
| 81 |
+
/**
|
| 82 |
+
* Shortcut to getRequest
|
| 83 |
+
*
|
| 84 |
+
*/
|
| 85 |
+
protected function _getRequest()
|
| 86 |
+
{
|
| 87 |
+
return Mage::app()->getRequest();
|
| 88 |
+
}
|
| 89 |
+
}
|
app/code/local/Grazitti/Discount/Model/Status.php
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
class Grazitti_Discount_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('discount')->__('Enabled'),
|
| 12 |
+
self::STATUS_DISABLED => Mage::helper('discount')->__('Disabled')
|
| 13 |
+
);
|
| 14 |
+
}
|
| 15 |
+
}
|
app/code/local/Grazitti/Discount/Model/Validator.php
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* Magento
|
| 4 |
+
*
|
| 5 |
+
* NOTICE OF LICENSE
|
| 6 |
+
*
|
| 7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
| 8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
| 9 |
+
* It is also available through the world-wide-web at this URL:
|
| 10 |
+
* http://opensource.org/licenses/osl-3.0.php
|
| 11 |
+
* If you did not receive a copy of the license and are unable to
|
| 12 |
+
* obtain it through the world-wide-web, please send an email
|
| 13 |
+
* to license@magento.com so we can send you a copy immediately.
|
| 14 |
+
*
|
| 15 |
+
* DISCLAIMER
|
| 16 |
+
*
|
| 17 |
+
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
| 18 |
+
* versions in the future. If you wish to customize Magento for your
|
| 19 |
+
* needs please refer to http://www.magento.com for more information.
|
| 20 |
+
*
|
| 21 |
+
* @category Mage
|
| 22 |
+
* @package Mage_SalesRule
|
| 23 |
+
* @copyright Copyright (c) 2006-2015 X.commerce, Inc. (http://www.magento.com)
|
| 24 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
| 25 |
+
*/
|
| 26 |
+
|
| 27 |
+
|
| 28 |
+
/**
|
| 29 |
+
* SalesRule Validator Model
|
| 30 |
+
*
|
| 31 |
+
* Allows dispatching before and after events for each controller action
|
| 32 |
+
*
|
| 33 |
+
* @category Mage
|
| 34 |
+
* @package Mage_SalesRule
|
| 35 |
+
* @author Magento Core Team <core@magentocommerce.com>
|
| 36 |
+
*/
|
| 37 |
+
class Grazitti_Discount_Model_Validator extends Mage_SalesRule_Model_Validator
|
| 38 |
+
{
|
| 39 |
+
|
| 40 |
+
public function init($websiteId, $customerGroupId, $couponCode)
|
| 41 |
+
{
|
| 42 |
+
$customerID = Mage::getSingleton('customer/session')->getCustomer()->getID();
|
| 43 |
+
$currentcustomercroupId = Mage::getSingleton('customer/session')->getCustomerGroupId();
|
| 44 |
+
$oCoupon = Mage::getModel('salesrule/coupon')->load($couponCode, 'code');
|
| 45 |
+
$oRule = Mage::getModel('salesrule/rule')->load($oCoupon->getRuleId());
|
| 46 |
+
$ruleId = $oRule->getRuleId();
|
| 47 |
+
$rule_customergroup_ids = Mage::getModel('salesrule/rule')->load($ruleId)
|
| 48 |
+
->getData('customer_group_ids');
|
| 49 |
+
|
| 50 |
+
$collection = Mage::getModel('discount/discount')
|
| 51 |
+
->getCollection()
|
| 52 |
+
->addFieldToFilter('customer_id', array('finset' => $customerID))
|
| 53 |
+
->addFieldToFilter('rule_id' , $ruleId)
|
| 54 |
+
->getData();
|
| 55 |
+
if(in_array($currentcustomercroupId, $rule_customergroup_ids)){
|
| 56 |
+
$customerGroupId=$customerGroupId;
|
| 57 |
+
} else if($collection){
|
| 58 |
+
$customerGroupId=$rule_customergroup_ids[0];
|
| 59 |
+
}else{
|
| 60 |
+
$customerGroupId=$customerGroupId;
|
| 61 |
+
}
|
| 62 |
+
|
| 63 |
+
$this->setWebsiteId($websiteId)
|
| 64 |
+
->setCustomerGroupId($customerGroupId)
|
| 65 |
+
->setCouponCode($couponCode);
|
| 66 |
+
|
| 67 |
+
$key = $websiteId . '_' . $customerGroupId . '_' . $couponCode;
|
| 68 |
+
if (!isset($this->_rules[$key])) {
|
| 69 |
+
$this->_rules[$key] = Mage::getResourceModel('salesrule/rule_collection')
|
| 70 |
+
->setValidationFilter($websiteId, $customerGroupId, $couponCode)
|
| 71 |
+
->load();
|
| 72 |
+
}
|
| 73 |
+
return $this;
|
| 74 |
+
}
|
| 75 |
+
}
|
app/code/local/Grazitti/Discount/controllers/Adminhtml/DiscountController.php
ADDED
|
@@ -0,0 +1,214 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
class Grazitti_Discount_Adminhtml_DiscountController extends Mage_Adminhtml_Controller_action
|
| 4 |
+
{
|
| 5 |
+
|
| 6 |
+
protected function _initAction() {
|
| 7 |
+
$this->loadLayout()
|
| 8 |
+
->_setActiveMenu('discount/items')
|
| 9 |
+
->_addBreadcrumb(Mage::helper('adminhtml')->__('Items Manager'), Mage::helper('adminhtml')->__('Item Manager'));
|
| 10 |
+
|
| 11 |
+
return $this;
|
| 12 |
+
}
|
| 13 |
+
|
| 14 |
+
public function indexAction() {
|
| 15 |
+
$this->_initAction()
|
| 16 |
+
->renderLayout();
|
| 17 |
+
}
|
| 18 |
+
|
| 19 |
+
public function editAction() {
|
| 20 |
+
$id = $this->getRequest()->getParam('id');
|
| 21 |
+
$model = Mage::getModel('discount/discount')->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('discount_data', $model);
|
| 30 |
+
|
| 31 |
+
$this->loadLayout();
|
| 32 |
+
$this->_setActiveMenu('discount/items');
|
| 33 |
+
|
| 34 |
+
$this->_addBreadcrumb(Mage::helper('adminhtml')->__('Item Manager'), Mage::helper('adminhtml')->__('Item Manager'));
|
| 35 |
+
$this->_addBreadcrumb(Mage::helper('adminhtml')->__('Item News'), Mage::helper('adminhtml')->__('Item News'));
|
| 36 |
+
|
| 37 |
+
$this->getLayout()->getBlock('head')->setCanLoadExtJs(true);
|
| 38 |
+
|
| 39 |
+
$this->_addContent($this->getLayout()->createBlock('discount/adminhtml_discount_edit'))
|
| 40 |
+
->_addLeft($this->getLayout()->createBlock('discount/adminhtml_discount_edit_tabs'));
|
| 41 |
+
|
| 42 |
+
$this->renderLayout();
|
| 43 |
+
} else {
|
| 44 |
+
Mage::getSingleton('adminhtml/session')->addError(Mage::helper('discount')->__('Item 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 |
+
|
| 84 |
+
$model = Mage::getModel('discount/discount');
|
| 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('discount')->__('Item 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('discount')->__('Unable to find item to save'));
|
| 114 |
+
$this->_redirect('*/*/');
|
| 115 |
+
}
|
| 116 |
+
|
| 117 |
+
public function deleteAction() {
|
| 118 |
+
if( $this->getRequest()->getParam('id') > 0 ) {
|
| 119 |
+
try {
|
| 120 |
+
$model = Mage::getModel('discount/discount');
|
| 121 |
+
|
| 122 |
+
$model->setId($this->getRequest()->getParam('id'))
|
| 123 |
+
->delete();
|
| 124 |
+
|
| 125 |
+
Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('adminhtml')->__('Item 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 |
+
$discountIds = $this->getRequest()->getParam('discount');
|
| 137 |
+
if(!is_array($discountIds)) {
|
| 138 |
+
Mage::getSingleton('adminhtml/session')->addError(Mage::helper('adminhtml')->__('Please select item(s)'));
|
| 139 |
+
} else {
|
| 140 |
+
try {
|
| 141 |
+
foreach ($discountIds as $discountId) {
|
| 142 |
+
$discount = Mage::getModel('discount/discount')->load($discountId);
|
| 143 |
+
$discount->delete();
|
| 144 |
+
}
|
| 145 |
+
Mage::getSingleton('adminhtml/session')->addSuccess(
|
| 146 |
+
Mage::helper('adminhtml')->__(
|
| 147 |
+
'Total of %d record(s) were successfully deleted', count($discountIds)
|
| 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 |
+
$discountIds = $this->getRequest()->getParam('discount');
|
| 160 |
+
if(!is_array($discountIds)) {
|
| 161 |
+
Mage::getSingleton('adminhtml/session')->addError($this->__('Please select item(s)'));
|
| 162 |
+
} else {
|
| 163 |
+
try {
|
| 164 |
+
foreach ($discountIds as $discountId) {
|
| 165 |
+
$discount = Mage::getSingleton('discount/discount')
|
| 166 |
+
->load($discountId)
|
| 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($discountIds))
|
| 173 |
+
);
|
| 174 |
+
} catch (Exception $e) {
|
| 175 |
+
$this->_getSession()->addError($e->getMessage());
|
| 176 |
+
}
|
| 177 |
+
}
|
| 178 |
+
$this->_redirect('*/*/index');
|
| 179 |
+
}
|
| 180 |
+
|
| 181 |
+
public function exportCsvAction()
|
| 182 |
+
{
|
| 183 |
+
$fileName = 'discount.csv';
|
| 184 |
+
$content = $this->getLayout()->createBlock('discount/adminhtml_discount_grid')
|
| 185 |
+
->getCsv();
|
| 186 |
+
|
| 187 |
+
$this->_sendUploadResponse($fileName, $content);
|
| 188 |
+
}
|
| 189 |
+
|
| 190 |
+
public function exportXmlAction()
|
| 191 |
+
{
|
| 192 |
+
$fileName = 'discount.xml';
|
| 193 |
+
$content = $this->getLayout()->createBlock('discount/adminhtml_discount_grid')
|
| 194 |
+
->getXml();
|
| 195 |
+
|
| 196 |
+
$this->_sendUploadResponse($fileName, $content);
|
| 197 |
+
}
|
| 198 |
+
|
| 199 |
+
protected function _sendUploadResponse($fileName, $content, $contentType='application/octet-stream')
|
| 200 |
+
{
|
| 201 |
+
$response = $this->getResponse();
|
| 202 |
+
$response->setHeader('HTTP/1.1 200 OK','');
|
| 203 |
+
$response->setHeader('Pragma', 'public', true);
|
| 204 |
+
$response->setHeader('Cache-Control', 'must-revalidate, post-check=0, pre-check=0', true);
|
| 205 |
+
$response->setHeader('Content-Disposition', 'attachment; filename='.$fileName);
|
| 206 |
+
$response->setHeader('Last-Modified', date('r'));
|
| 207 |
+
$response->setHeader('Accept-Ranges', 'bytes');
|
| 208 |
+
$response->setHeader('Content-Length', strlen($content));
|
| 209 |
+
$response->setHeader('Content-type', $contentType);
|
| 210 |
+
$response->setBody($content);
|
| 211 |
+
$response->sendResponse();
|
| 212 |
+
die;
|
| 213 |
+
}
|
| 214 |
+
}
|
app/code/local/Grazitti/Discount/controllers/Adminhtml/Promo/QuoteController.php
ADDED
|
@@ -0,0 +1,223 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* Magento
|
| 4 |
+
*
|
| 5 |
+
* NOTICE OF LICENSE
|
| 6 |
+
*
|
| 7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
| 8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
| 9 |
+
* It is also available through the world-wide-web at this URL:
|
| 10 |
+
* http://opensource.org/licenses/osl-3.0.php
|
| 11 |
+
* If you did not receive a copy of the license and are unable to
|
| 12 |
+
* obtain it through the world-wide-web, please send an email
|
| 13 |
+
* to license@magento.com so we can send you a copy immediately.
|
| 14 |
+
*
|
| 15 |
+
* DISCLAIMER
|
| 16 |
+
*
|
| 17 |
+
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
| 18 |
+
* versions in the future. If you wish to customize Magento for your
|
| 19 |
+
* needs please refer to http://www.magento.com for more information.
|
| 20 |
+
*
|
| 21 |
+
* @category Mage
|
| 22 |
+
* @package Mage_Adminhtml
|
| 23 |
+
* @copyright Copyright (c) 2006-2015 X.commerce, Inc. (http://www.magento.com)
|
| 24 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
| 25 |
+
*/
|
| 26 |
+
|
| 27 |
+
require_once 'Mage/Adminhtml/controllers/Promo/QuoteController.php';
|
| 28 |
+
class Grazitti_Discount_Adminhtml_Promo_QuoteController extends Mage_Adminhtml_Promo_QuoteController
|
| 29 |
+
{
|
| 30 |
+
|
| 31 |
+
public function customerAction(){
|
| 32 |
+
$this->loadLayout();
|
| 33 |
+
$this->getLayout()->getBlock('customer.grid')
|
| 34 |
+
->setCustomers($this->getRequest()->getPost('customers', null));
|
| 35 |
+
$this->renderLayout();
|
| 36 |
+
}
|
| 37 |
+
public function customergridAction(){
|
| 38 |
+
$this->loadLayout();
|
| 39 |
+
$this->getLayout()->getBlock('customer.grid')
|
| 40 |
+
->setCustomers($this->getRequest()->getPost('customers', null));
|
| 41 |
+
$this->renderLayout();
|
| 42 |
+
}
|
| 43 |
+
public function editAction()
|
| 44 |
+
{
|
| 45 |
+
$id = $this->getRequest()->getParam('id');
|
| 46 |
+
$model = Mage::getModel('salesrule/rule');
|
| 47 |
+
|
| 48 |
+
if ($id) {
|
| 49 |
+
$model->load($id);
|
| 50 |
+
if (! $model->getRuleId()) {
|
| 51 |
+
Mage::getSingleton('adminhtml/session')->addError(
|
| 52 |
+
Mage::helper('salesrule')->__('This rule no longer exists.'));
|
| 53 |
+
$this->_redirect('*/*');
|
| 54 |
+
return;
|
| 55 |
+
}
|
| 56 |
+
}
|
| 57 |
+
|
| 58 |
+
$this->_title($model->getRuleId() ? $model->getName() : $this->__('New Rule'));
|
| 59 |
+
|
| 60 |
+
// set entered data if was error when we do save
|
| 61 |
+
$data = Mage::getSingleton('adminhtml/session')->getPageData(true);
|
| 62 |
+
if (!empty($data)) {
|
| 63 |
+
$model->addData($data);
|
| 64 |
+
}
|
| 65 |
+
|
| 66 |
+
$model->getConditions()->setJsFormObject('rule_conditions_fieldset');
|
| 67 |
+
$model->getActions()->setJsFormObject('rule_actions_fieldset');
|
| 68 |
+
|
| 69 |
+
Mage::register('current_promo_quote_rule', $model);
|
| 70 |
+
|
| 71 |
+
$this->_initAction()->getLayout()->getBlock('promo_quote_edit')
|
| 72 |
+
->setData('action', $this->getUrl('*/*/save'));
|
| 73 |
+
|
| 74 |
+
$this
|
| 75 |
+
->_addBreadcrumb(
|
| 76 |
+
$id ? Mage::helper('salesrule')->__('Edit Rule')
|
| 77 |
+
: Mage::helper('salesrule')->__('New Rule'),
|
| 78 |
+
$id ? Mage::helper('salesrule')->__('Edit Rule')
|
| 79 |
+
: Mage::helper('salesrule')->__('New Rule'))
|
| 80 |
+
->renderLayout();
|
| 81 |
+
|
| 82 |
+
}
|
| 83 |
+
|
| 84 |
+
/**
|
| 85 |
+
* Promo quote save action
|
| 86 |
+
*
|
| 87 |
+
*/
|
| 88 |
+
public function saveAction()
|
| 89 |
+
{
|
| 90 |
+
|
| 91 |
+
if ($this->getRequest()->getPost()) {
|
| 92 |
+
try {
|
| 93 |
+
/** @var $model Mage_SalesRule_Model_Rule */
|
| 94 |
+
|
| 95 |
+
|
| 96 |
+
$model = Mage::getModel('salesrule/rule');
|
| 97 |
+
Mage::dispatchEvent(
|
| 98 |
+
'adminhtml_controller_salesrule_prepare_save',
|
| 99 |
+
array('request' => $this->getRequest()));
|
| 100 |
+
$data = $this->getRequest()->getPost();
|
| 101 |
+
//echo'<pre>'; print_r($data); die;
|
| 102 |
+
$data = $this->_filterDates($data, array('from_date', 'to_date'));
|
| 103 |
+
$id = $this->getRequest()->getParam('rule_id');
|
| 104 |
+
if ($id) {
|
| 105 |
+
$model->load($id);
|
| 106 |
+
if ($id != $model->getId()) {
|
| 107 |
+
Mage::throwException(Mage::helper('salesrule')->__('Wrong rule specified.'));
|
| 108 |
+
}
|
| 109 |
+
}
|
| 110 |
+
|
| 111 |
+
$session = Mage::getSingleton('adminhtml/session');
|
| 112 |
+
|
| 113 |
+
$validateResult = $model->validateData(new Varien_Object($data));
|
| 114 |
+
if ($validateResult !== true) {
|
| 115 |
+
foreach($validateResult as $errorMessage) {
|
| 116 |
+
$session->addError($errorMessage);
|
| 117 |
+
}
|
| 118 |
+
$session->setPageData($data);
|
| 119 |
+
$this->_redirect('*/*/edit', array('id'=>$model->getId()));
|
| 120 |
+
return;
|
| 121 |
+
}
|
| 122 |
+
|
| 123 |
+
if (isset($data['simple_action']) && $data['simple_action'] == 'by_percent'
|
| 124 |
+
&& isset($data['discount_amount'])) {
|
| 125 |
+
$data['discount_amount'] = min(100,$data['discount_amount']);
|
| 126 |
+
}
|
| 127 |
+
if (isset($data['rule']['conditions'])) {
|
| 128 |
+
$data['conditions'] = $data['rule']['conditions'];
|
| 129 |
+
}
|
| 130 |
+
if (isset($data['rule']['actions'])) {
|
| 131 |
+
$data['actions'] = $data['rule']['actions'];
|
| 132 |
+
}
|
| 133 |
+
unset($data['rule']);
|
| 134 |
+
$model->loadPost($data);
|
| 135 |
+
|
| 136 |
+
$useAutoGeneration = (int)!empty($data['use_auto_generation']);
|
| 137 |
+
$model->setUseAutoGeneration($useAutoGeneration);
|
| 138 |
+
|
| 139 |
+
$session->setPageData($model->getData());
|
| 140 |
+
|
| 141 |
+
$model->save();
|
| 142 |
+
/* Save Customer list data in Custom tab table database */
|
| 143 |
+
$rule_id=Mage::app()->getRequest()->getParam('rule_id');
|
| 144 |
+
$selected_customers = Mage::app()->getRequest()->getParam('selected_customers');
|
| 145 |
+
$selected_customers = implode(",",$selected_customers);
|
| 146 |
+
//echo "<pre>";
|
| 147 |
+
/* echo "<pre>";
|
| 148 |
+
print_r($selected_customers);die; */
|
| 149 |
+
$customModel = Mage::getModel('discount/discount');
|
| 150 |
+
$customTabModule = Mage::getModel('discount/discount')
|
| 151 |
+
->getCollection()
|
| 152 |
+
->addFieldToFilter('rule_id',$rule_id)
|
| 153 |
+
->addFieldToSelect('discount_id')
|
| 154 |
+
->getFirstItem()->getData();
|
| 155 |
+
//print_r($customTabModule); die;
|
| 156 |
+
if($customTabModule)
|
| 157 |
+
{
|
| 158 |
+
$customModel=$customModel->setDiscountId($customTabModule['discount_id']);
|
| 159 |
+
$customModel=$customModel->setRuleId($rule_id);
|
| 160 |
+
if($selected_customers)
|
| 161 |
+
{
|
| 162 |
+
$customModel=$customModel->setCustomerId($selected_customers);
|
| 163 |
+
}
|
| 164 |
+
else
|
| 165 |
+
{
|
| 166 |
+
$customModel=$customModel->setCustomerId('');
|
| 167 |
+
}
|
| 168 |
+
$customModel=$customModel->setPosition($value['position']);
|
| 169 |
+
}
|
| 170 |
+
else
|
| 171 |
+
{
|
| 172 |
+
$customModel=$customModel->setRuleId($rule_id);
|
| 173 |
+
if($selected_customers){
|
| 174 |
+
$customModel=$customModel->setCustomerId($selected_customers);
|
| 175 |
+
}else{
|
| 176 |
+
$customModel=$customModel->setCustomerId('');
|
| 177 |
+
}
|
| 178 |
+
$customModel=$customModel->setPosition($value['position']);
|
| 179 |
+
}
|
| 180 |
+
$customModel = $customModel->save();
|
| 181 |
+
/* Save Customer list data in Custom tab table database */
|
| 182 |
+
|
| 183 |
+
$session->addSuccess(Mage::helper('salesrule')->__('The rule has been saved.'));
|
| 184 |
+
$session->setPageData(false);
|
| 185 |
+
if ($this->getRequest()->getParam('back')) {
|
| 186 |
+
$this->_redirect('*/*/edit', array('id' => $model->getId()));
|
| 187 |
+
return;
|
| 188 |
+
}
|
| 189 |
+
$this->_redirect('*/*/');
|
| 190 |
+
return;
|
| 191 |
+
} catch (Mage_Core_Exception $e) {
|
| 192 |
+
$this->_getSession()->addError($e->getMessage());
|
| 193 |
+
$id = (int)$this->getRequest()->getParam('rule_id');
|
| 194 |
+
if (!empty($id)) {
|
| 195 |
+
$this->_redirect('*/*/edit', array('id' => $id));
|
| 196 |
+
} else {
|
| 197 |
+
$this->_redirect('*/*/new');
|
| 198 |
+
}
|
| 199 |
+
return;
|
| 200 |
+
|
| 201 |
+
} catch (Exception $e) {
|
| 202 |
+
$this->_getSession()->addError(
|
| 203 |
+
Mage::helper('catalogrule')->__('An error occurred while saving the rule data. Please review the log and try again.'));
|
| 204 |
+
Mage::logException($e);
|
| 205 |
+
Mage::getSingleton('adminhtml/session')->setPageData($data);
|
| 206 |
+
$this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('rule_id')));
|
| 207 |
+
return;
|
| 208 |
+
}
|
| 209 |
+
}
|
| 210 |
+
$this->_redirect('*/*/');
|
| 211 |
+
}
|
| 212 |
+
public function gridAction()
|
| 213 |
+
{
|
| 214 |
+
|
| 215 |
+
$this->loadLayout();
|
| 216 |
+
$this->getResponse()->setBody(
|
| 217 |
+
$this->getLayout()->createBlock('discount/adminhtml_promo_quote_edit_tab_custom')->toHtml()
|
| 218 |
+
);
|
| 219 |
+
|
| 220 |
+
|
| 221 |
+
}
|
| 222 |
+
|
| 223 |
+
}
|
app/code/local/Grazitti/Discount/controllers/IndexController.php
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
class Grazitti_Discount_IndexController extends Mage_Core_Controller_Front_Action
|
| 3 |
+
{
|
| 4 |
+
public function indexAction()
|
| 5 |
+
{
|
| 6 |
+
$this->loadLayout();
|
| 7 |
+
$this->renderLayout();
|
| 8 |
+
}
|
| 9 |
+
}
|
app/code/local/Grazitti/Discount/etc/config.xml
ADDED
|
@@ -0,0 +1,149 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0"?>
|
| 2 |
+
<!--
|
| 3 |
+
/**
|
| 4 |
+
* @category Individual Discount
|
| 5 |
+
* @package Grazitti_Discount
|
| 6 |
+
* @author Grazitti
|
| 7 |
+
*/
|
| 8 |
+
-->
|
| 9 |
+
<config>
|
| 10 |
+
<modules>
|
| 11 |
+
<Grazitti_Discount>
|
| 12 |
+
<version>0.1.0</version>
|
| 13 |
+
</Grazitti_Discount>
|
| 14 |
+
</modules>
|
| 15 |
+
<frontend>
|
| 16 |
+
<routers>
|
| 17 |
+
<discount>
|
| 18 |
+
<use>standard</use>
|
| 19 |
+
<args>
|
| 20 |
+
<module>Grazitti_Discount</module>
|
| 21 |
+
<frontName>discount</frontName>
|
| 22 |
+
</args>
|
| 23 |
+
</discount>
|
| 24 |
+
</routers>
|
| 25 |
+
<layout>
|
| 26 |
+
<updates>
|
| 27 |
+
<discount>
|
| 28 |
+
<file>discount.xml</file>
|
| 29 |
+
</discount>
|
| 30 |
+
</updates>
|
| 31 |
+
</layout>
|
| 32 |
+
</frontend>
|
| 33 |
+
<admin>
|
| 34 |
+
<routers>
|
| 35 |
+
<adminhtml>
|
| 36 |
+
<args>
|
| 37 |
+
<modules>
|
| 38 |
+
<Grazitti_Discount before="Mage_Adminhtml">Grazitti_Discount_Adminhtml</Grazitti_Discount>
|
| 39 |
+
</modules>
|
| 40 |
+
</args>
|
| 41 |
+
</adminhtml>
|
| 42 |
+
|
| 43 |
+
</routers>
|
| 44 |
+
</admin>
|
| 45 |
+
<adminhtml>
|
| 46 |
+
<menu>
|
| 47 |
+
<discount module="discount">
|
| 48 |
+
<title>Discount</title>
|
| 49 |
+
<sort_order>71</sort_order>
|
| 50 |
+
<children>
|
| 51 |
+
<items module="discount">
|
| 52 |
+
<title>Manage Items</title>
|
| 53 |
+
<sort_order>0</sort_order>
|
| 54 |
+
<action>discount/adminhtml_discount</action>
|
| 55 |
+
</items>
|
| 56 |
+
</children>
|
| 57 |
+
</discount>
|
| 58 |
+
</menu>
|
| 59 |
+
<acl>
|
| 60 |
+
<resources>
|
| 61 |
+
<all>
|
| 62 |
+
<title>Allow Everything</title>
|
| 63 |
+
</all>
|
| 64 |
+
<admin>
|
| 65 |
+
<children>
|
| 66 |
+
<Grazitti_Discount>
|
| 67 |
+
<title>Discount Module</title>
|
| 68 |
+
<sort_order>10</sort_order>
|
| 69 |
+
</Grazitti_Discount>
|
| 70 |
+
</children>
|
| 71 |
+
</admin>
|
| 72 |
+
</resources>
|
| 73 |
+
</acl>
|
| 74 |
+
<layout>
|
| 75 |
+
<updates>
|
| 76 |
+
<discount>
|
| 77 |
+
<file>discount.xml</file>
|
| 78 |
+
</discount>
|
| 79 |
+
</updates>
|
| 80 |
+
</layout>
|
| 81 |
+
<events>
|
| 82 |
+
<salesrule_rule_save_before>
|
| 83 |
+
<observers>
|
| 84 |
+
<grazitti_save_product_data>
|
| 85 |
+
<type>singleton</type>
|
| 86 |
+
<class>discount/observer</class>
|
| 87 |
+
<method>saveProductTabData1</method>
|
| 88 |
+
</grazitti_save_product_data>
|
| 89 |
+
</observers>
|
| 90 |
+
</salesrule_rule_save_before>
|
| 91 |
+
</events>
|
| 92 |
+
</adminhtml>
|
| 93 |
+
<global>
|
| 94 |
+
<models>
|
| 95 |
+
<discount>
|
| 96 |
+
<class>Grazitti_Discount_Model</class>
|
| 97 |
+
<resourceModel>discount_mysql4</resourceModel>
|
| 98 |
+
</discount>
|
| 99 |
+
<discount_mysql4>
|
| 100 |
+
<class>Grazitti_Discount_Model_Mysql4</class>
|
| 101 |
+
<entities>
|
| 102 |
+
<discount>
|
| 103 |
+
<table>discount</table>
|
| 104 |
+
</discount>
|
| 105 |
+
</entities>
|
| 106 |
+
</discount_mysql4>
|
| 107 |
+
<salesrule>
|
| 108 |
+
<rewrite>
|
| 109 |
+
<validator>Grazitti_Discount_Model_Validator</validator>
|
| 110 |
+
</rewrite>
|
| 111 |
+
</salesrule>
|
| 112 |
+
</models>
|
| 113 |
+
<resources>
|
| 114 |
+
<discount_setup>
|
| 115 |
+
<setup>
|
| 116 |
+
<module>Grazitti_Discount</module>
|
| 117 |
+
</setup>
|
| 118 |
+
<connection>
|
| 119 |
+
<use>core_setup</use>
|
| 120 |
+
</connection>
|
| 121 |
+
</discount_setup>
|
| 122 |
+
<discount_write>
|
| 123 |
+
<connection>
|
| 124 |
+
<use>core_write</use>
|
| 125 |
+
</connection>
|
| 126 |
+
</discount_write>
|
| 127 |
+
<discount_read>
|
| 128 |
+
<connection>
|
| 129 |
+
<use>core_read</use>
|
| 130 |
+
</connection>
|
| 131 |
+
</discount_read>
|
| 132 |
+
</resources>
|
| 133 |
+
<blocks>
|
| 134 |
+
<discount>
|
| 135 |
+
<class>Grazitti_Discount_Block</class>
|
| 136 |
+
</discount>
|
| 137 |
+
<adminhtml>
|
| 138 |
+
<rewrite>
|
| 139 |
+
<promo_quote_edit_tabs>Grazitti_Discount_Block_Adminhtml_Discount_Edit_Tabs</promo_quote_edit_tabs>
|
| 140 |
+
</rewrite>
|
| 141 |
+
</adminhtml>
|
| 142 |
+
</blocks>
|
| 143 |
+
<helpers>
|
| 144 |
+
<discount>
|
| 145 |
+
<class>Grazitti_Discount_Helper</class>
|
| 146 |
+
</discount>
|
| 147 |
+
</helpers>
|
| 148 |
+
</global>
|
| 149 |
+
</config>
|
app/code/local/Grazitti/Discount/sql/discount_setup/mysql4-install-0.1.0.php
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
$installer = $this;
|
| 4 |
+
|
| 5 |
+
$installer->startSetup();
|
| 6 |
+
|
| 7 |
+
$installer->run("
|
| 8 |
+
|
| 9 |
+
-- DROP TABLE IF EXISTS {$this->getTable('discount')};
|
| 10 |
+
CREATE TABLE {$this->getTable('discount')} (
|
| 11 |
+
`discount_id` int(11) unsigned NOT NULL auto_increment,
|
| 12 |
+
`rule_id` varchar(255) NOT NULL default '',
|
| 13 |
+
`customer_id` varchar(255) NOT NULL default '',
|
| 14 |
+
`update_time` datetime NULL,
|
| 15 |
+
PRIMARY KEY (`discount_id`)
|
| 16 |
+
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
| 17 |
+
|
| 18 |
+
");
|
| 19 |
+
|
| 20 |
+
$installer->endSetup();
|
app/design/adminhtml/default/default/layout/discount.xml
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0"?>
|
| 2 |
+
<layout version="0.1.0">
|
| 3 |
+
<discount_adminhtml_discount_index>
|
| 4 |
+
<reference name="content">
|
| 5 |
+
<block type="discount/adminhtml_discount" name="discount" />
|
| 6 |
+
</reference>
|
| 7 |
+
</discount_adminhtml_discount_index>
|
| 8 |
+
<!-- <adminhtml_promo_quote_edit>
|
| 9 |
+
<reference name="promo_quote_edit_tabs">
|
| 10 |
+
<action method="addTab">
|
| 11 |
+
<name>promo_quote_edit_tab_custom</name>
|
| 12 |
+
<block>discount/adminhtml_promo_quote_edit_tab_custom</block>
|
| 13 |
+
</action>
|
| 14 |
+
</reference>
|
| 15 |
+
</adminhtml_promo_quote_edit> -->
|
| 16 |
+
|
| 17 |
+
<adminhtml_promo_quote_grid>
|
| 18 |
+
<block type="core/text_list" name="root" output="toHtml">
|
| 19 |
+
<block type="discount/adminhtml_promo_quote_edit_tab_custom" name="customer.grid"/>
|
| 20 |
+
<block type="adminhtml/widget_grid_serializer" name="grid_serializer">
|
| 21 |
+
<reference name="grid_serializer">
|
| 22 |
+
<action method="initSerializerBlock">
|
| 23 |
+
<grid_block_name>customer.grid</grid_block_name>
|
| 24 |
+
<data_callback>getSelectedCustomers</data_callback>
|
| 25 |
+
<hidden_input_name>links[customers]</hidden_input_name>
|
| 26 |
+
<reload_param_name>customers</reload_param_name>
|
| 27 |
+
</action>
|
| 28 |
+
<action method="addColumnInputName">
|
| 29 |
+
<input_name>position</input_name>
|
| 30 |
+
</action>
|
| 31 |
+
</reference>
|
| 32 |
+
</block>
|
| 33 |
+
</block>
|
| 34 |
+
</adminhtml_promo_quote_grid>
|
| 35 |
+
<adminhtml_promo_quote_customergrid>
|
| 36 |
+
<block type="core/text_list" name="root" output="toHtml">
|
| 37 |
+
<block type="discount/adminhtml_promo_quote_edit_tab_custom" name="customer.grid"/>
|
| 38 |
+
</block>
|
| 39 |
+
</adminhtml_promo_quote_customergrid>
|
| 40 |
+
</layout>
|
app/etc/modules/Grazitti_Discount.xml
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0"?>
|
| 2 |
+
<!--
|
| 3 |
+
/**
|
| 4 |
+
* @category Grazitti
|
| 5 |
+
* @package Grazitti_Discount
|
| 6 |
+
* @author ModuleCreator
|
| 7 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
| 8 |
+
*/
|
| 9 |
+
-->
|
| 10 |
+
<config>
|
| 11 |
+
<modules>
|
| 12 |
+
<Grazitti_Discount>
|
| 13 |
+
<active>true</active>
|
| 14 |
+
<codePool>local</codePool>
|
| 15 |
+
</Grazitti_Discount>
|
| 16 |
+
</modules>
|
| 17 |
+
</config>
|
package.xml
CHANGED
|
@@ -1,18 +1,18 @@
|
|
| 1 |
<?xml version="1.0"?>
|
| 2 |
<package>
|
| 3 |
<name>Grazitti_Discount</name>
|
| 4 |
-
<version>1.0.
|
| 5 |
<stability>stable</stability>
|
| 6 |
<license>OSL</license>
|
| 7 |
<channel>community</channel>
|
| 8 |
<extends/>
|
| 9 |
<summary>Individual Promotions</summary>
|
| 10 |
<description>Empowers you to provide some special favors to specific customers. With Individual Promotions module you can create coupons and shopping cart price rules for individual customers.</description>
|
| 11 |
-
<notes>
|
| 12 |
-
<authors><author><name>Mamta</name><user>
|
| 13 |
-
<date>2016-
|
| 14 |
-
<time>
|
| 15 |
-
<contents><target name="magelocal"><dir><dir name="
|
| 16 |
<compatible/>
|
| 17 |
-
<dependencies><required><php><min>5.
|
| 18 |
</package>
|
| 1 |
<?xml version="1.0"?>
|
| 2 |
<package>
|
| 3 |
<name>Grazitti_Discount</name>
|
| 4 |
+
<version>1.0.3</version>
|
| 5 |
<stability>stable</stability>
|
| 6 |
<license>OSL</license>
|
| 7 |
<channel>community</channel>
|
| 8 |
<extends/>
|
| 9 |
<summary>Individual Promotions</summary>
|
| 10 |
<description>Empowers you to provide some special favors to specific customers. With Individual Promotions module you can create coupons and shopping cart price rules for individual customers.</description>
|
| 11 |
+
<notes>Fixed minor bugs</notes>
|
| 12 |
+
<authors><author><name>Mamta</name><user>grazitti</user><email>mamtas@grazitti.com</email></author></authors>
|
| 13 |
+
<date>2016-05-11</date>
|
| 14 |
+
<time>11:32:03</time>
|
| 15 |
+
<contents><target name="magelocal"><dir name="Grazitti"><dir name="Discount"><dir name="Block"><dir name="Adminhtml"><dir name="Discount"><dir name="Edit"><file name="Form.php" hash="f6c993ef81e70a33c8d36acb6e4f3071"/><dir name="Tab"><file name="Form.php" hash="95ac6ab00b83d2d62a1012e1f740d714"/></dir><file name="Tabs.php" hash="d427d7ee0a2021dbc4ccd2ae7d3692a0"/></dir><file name="Edit.php" hash="c2daa06cedacd38b880369bbdb8eae15"/><file name="Grid.php" hash="c7f4f36fdf4d5e6f609c3ab6539503bf"/></dir><file name="Discount.php" hash="1159d6a3221955b3d8ddcc0c4b78eb9b"/><dir name="Promo"><dir name="Quote"><dir name="Edit"><dir name="Tab"><file name="Custom - Copy.php" hash="96bfd009590d1edd0f8a7a2e11ccd431"/><file name="Custom 23-3-16.php" hash="a4002466b9ffb484615da1314e865527"/><file name="Custom.php" hash="bc674a3f68c3506af6edb0550f756d5a"/><file name="Main.php123456" hash="47cde0a6d834a0bd6217ae95137b7e22"/></dir></dir></dir></dir></dir><file name="Discount.php" hash="e57fa7765e026a25f9db740a8e56a82e"/></dir><dir name="Helper"><file name="Data.php" hash="f998a3e1f83e148da9821b4ec7bb0713"/></dir><dir name="Model"><file name="Discount.php" hash="d4cc830b0ecfe0a27ece9a94bf2651c2"/><dir name="Mysql4"><dir name="Discount"><file name="Collection.php" hash="53af169a87f3398be770512bd79faf88"/></dir><file name="Discount.php" hash="46fe6a3b294a464221d12873455651ab"/></dir><file name="Observer.php" hash="bbb81b3434e59029e9640906f6bc6820"/><file name="Status.php" hash="05604fcfb07f1cef8fbf3def208a50c9"/><file name="Validator.php" hash="844bd41c0011edc7aacb8153753b56ee"/></dir><dir name="controllers"><dir name="Adminhtml"><file name="DiscountController.php" hash="30517d50cbe89ba6c12a1002f88e722a"/><dir name="Promo"><file name="QuoteController.php" hash="197b7116d6b25bd656a24b8bed03fa2c"/></dir></dir><file name="IndexController.php" hash="d9ee8b0884924dcb1dd644815d49daf4"/></dir><dir name="etc"><file name="config.xml" hash="e24534b50a0568e5a40597f984ad6c50"/></dir><dir name="sql"><dir name="discount_setup"><file name="mysql4-install-0.1.0.php" hash="6bf72c8a2441fc7b132cf80cb9962fab"/></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Grazitti_Discount.xml" hash="d5979ea75b3e7baf96035801514526f9"/></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="discount.xml" hash="17afe38539e5525c964eacafed0a6c0b"/></dir></dir></dir></dir></target></contents>
|
| 16 |
<compatible/>
|
| 17 |
+
<dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
|
| 18 |
</package>
|
