Mage_Adminhtml_Promo_QuoteController Class Reference

Inheritance diagram for Mage_Adminhtml_Promo_QuoteController:

Mage_Adminhtml_Controller_Action Mage_Core_Controller_Varien_Action

List of all members.

Public Member Functions

 indexAction ()
 newAction ()
 editAction ()
 saveAction ()
 deleteAction ()
 newConditionHtmlAction ()
 newActionHtmlAction ()
 applyRulesAction ()
 gridAction ()

Protected Member Functions

 _initRule ()
 _initAction ()
 _isAllowed ()


Detailed Description

Definition at line 28 of file QuoteController.php.


Member Function Documentation

_initAction (  )  [protected]

Definition at line 39 of file QuoteController.php.

00040     {
00041         $this->loadLayout()
00042             ->_setActiveMenu('promo/quote')
00043             ->_addBreadcrumb(Mage::helper('salesrule')->__('Promotions'), Mage::helper('salesrule')->__('Promotions'))
00044         ;
00045         return $this;
00046     }

_initRule (  )  [protected]

Definition at line 30 of file QuoteController.php.

00031     {
00032         Mage::register('current_promo_quote_rule', Mage::getModel('salesrule/rule'));
00033         if ($id = (int) $this->getRequest()->getParam('id')) {
00034             Mage::registry('current_promo_quote_rule')
00035                 ->load($id);
00036         }
00037     }

_isAllowed (  )  [protected]

Reimplemented from Mage_Adminhtml_Controller_Action.

Definition at line 228 of file QuoteController.php.

00229     {
00230         return Mage::getSingleton('admin/session')->isAllowed('promo/quote');
00231     }

applyRulesAction (  ) 

Definition at line 213 of file QuoteController.php.

00214     {
00215         $this->_initAction();
00216 
00217         $this->renderLayout();
00218     }

deleteAction (  ) 

Definition at line 144 of file QuoteController.php.

00145     {
00146         if ($id = $this->getRequest()->getParam('id')) {
00147             try {
00148                 $model = Mage::getModel('salesrule/rule');
00149                 $model->load($id);
00150                 $model->delete();
00151                 Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('salesrule')->__('Rule was successfully deleted'));
00152                 $this->_redirect('*/*/');
00153                 return;
00154             }
00155             catch (Exception $e) {
00156                 Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
00157                 $this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id')));
00158                 return;
00159             }
00160         }
00161         Mage::getSingleton('adminhtml/session')->addError(Mage::helper('salesrule')->__('Unable to find a page to delete'));
00162         $this->_redirect('*/*/');
00163     }

editAction (  ) 

Definition at line 61 of file QuoteController.php.

00062     {
00063         $id = $this->getRequest()->getParam('id');
00064         $model = Mage::getModel('salesrule/rule');
00065 
00066         if ($id) {
00067             $model->load($id);
00068             if (! $model->getRuleId()) {
00069                 Mage::getSingleton('adminhtml/session')->addError(Mage::helper('salesrule')->__('This rule no longer exists'));
00070                 $this->_redirect('*/*');
00071                 return;
00072             }
00073         }
00074 
00075         // set entered data if was error when we do save
00076         $data = Mage::getSingleton('adminhtml/session')->getPageData(true);
00077         if (!empty($data)) {
00078             $model->addData($data);
00079         }
00080 
00081         $model->getConditions()->setJsFormObject('rule_conditions_fieldset');
00082         $model->getActions()->setJsFormObject('rule_actions_fieldset');
00083 
00084         Mage::register('current_promo_quote_rule', $model);
00085 
00086         $block = $this->getLayout()->createBlock('adminhtml/promo_quote_edit')
00087             ->setData('action', $this->getUrl('*/*/save'));
00088 
00089         $this->_initAction();
00090         $this->getLayout()->getBlock('head')
00091             ->setCanLoadExtJs(true)
00092             ->setCanLoadRulesJs(true);
00093 
00094         $this
00095             ->_addBreadcrumb($id ? Mage::helper('salesrule')->__('Edit Rule') : Mage::helper('salesrule')->__('New Rule'), $id ? Mage::helper('salesrule')->__('Edit Rule') : Mage::helper('salesrule')->__('New Rule'))
00096             ->_addContent($block)
00097             ->_addLeft($this->getLayout()->createBlock('adminhtml/promo_quote_edit_tabs'))
00098             ->renderLayout();
00099 
00100     }

gridAction (  ) 

Definition at line 220 of file QuoteController.php.

00221     {
00222         $this->_initRule();
00223         $this->getResponse()->setBody(
00224             $this->getLayout()->createBlock('adminhtml/promo_quote_edit_tab_product')->toHtml()
00225         );
00226     }

indexAction (  ) 

Definition at line 48 of file QuoteController.php.

00049     {
00050         $this->_initAction()
00051             ->_addBreadcrumb(Mage::helper('salesrule')->__('Catalog'), Mage::helper('salesrule')->__('Catalog'))
00052             ->_addContent($this->getLayout()->createBlock('adminhtml/promo_quote'))
00053             ->renderLayout();
00054     }

newAction (  ) 

Definition at line 56 of file QuoteController.php.

00057     {
00058         $this->_forward('edit');
00059     }

newActionHtmlAction (  ) 

Definition at line 189 of file QuoteController.php.

00190     {
00191         $id = $this->getRequest()->getParam('id');
00192         $typeArr = explode('|', str_replace('-', '/', $this->getRequest()->getParam('type')));
00193         $type = $typeArr[0];
00194 
00195         $model = Mage::getModel($type)
00196             ->setId($id)
00197             ->setType($type)
00198             ->setRule(Mage::getModel('salesrule/rule'))
00199             ->setPrefix('actions');
00200         if (!empty($typeArr[1])) {
00201             $model->setAttribute($typeArr[1]);
00202         }
00203 
00204         if ($model instanceof Mage_Rule_Model_Condition_Abstract) {
00205             $model->setJsFormObject($this->getRequest()->getParam('form'));
00206             $html = $model->asHtmlRecursive();
00207         } else {
00208             $html = '';
00209         }
00210         $this->getResponse()->setBody($html);
00211     }

newConditionHtmlAction (  ) 

Definition at line 165 of file QuoteController.php.

00166     {
00167         $id = $this->getRequest()->getParam('id');
00168         $typeArr = explode('|', str_replace('-', '/', $this->getRequest()->getParam('type')));
00169         $type = $typeArr[0];
00170 
00171         $model = Mage::getModel($type)
00172             ->setId($id)
00173             ->setType($type)
00174             ->setRule(Mage::getModel('salesrule/rule'))
00175             ->setPrefix('conditions');
00176         if (!empty($typeArr[1])) {
00177             $model->setAttribute($typeArr[1]);
00178         }
00179 
00180         if ($model instanceof Mage_Rule_Model_Condition_Abstract) {
00181             $model->setJsFormObject($this->getRequest()->getParam('form'));
00182             $html = $model->asHtmlRecursive();
00183         } else {
00184             $html = '';
00185         }
00186         $this->getResponse()->setBody($html);
00187     }

saveAction (  ) 

Definition at line 102 of file QuoteController.php.

00103     {
00104         if ($data = $this->getRequest()->getPost()) {
00105             try {
00106                 $model = Mage::getModel('salesrule/rule');
00107 
00108                 if ($id = $this->getRequest()->getParam('rule_id')) {
00109                     $model->load($id);
00110                     if ($id != $model->getId()) {
00111                         Mage::throwException(Mage::helper('salesrule')->__('Wrong rule specified.'));
00112                     }
00113                 }
00114                 if (isset($data['simple_action']) && $data['simple_action'] == 'by_percent' && isset($data['discount_amount'])) {
00115                     $data['discount_amount'] = min(100,$data['discount_amount']);
00116                 }
00117                 if (isset($data['rule']['conditions'])) {
00118                     $data['conditions'] = $data['rule']['conditions'];
00119                 }
00120                 if (isset($data['rule']['actions'])) {
00121                     $data['actions'] = $data['rule']['actions'];
00122                 }
00123                 unset($data['rule']);
00124 
00125                 $model->loadPost($data);
00126 
00127                 Mage::getSingleton('adminhtml/session')->setPageData($model->getData());
00128 
00129                 $model->save();
00130                 Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('salesrule')->__('Rule was successfully saved'));
00131                 Mage::getSingleton('adminhtml/session')->setPageData(false);
00132                 $this->_redirect('*/*/');
00133                 return;
00134             } catch (Exception $e) {
00135                 Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
00136                 Mage::getSingleton('adminhtml/session')->setPageData($data);
00137                 $this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('rule_id')));
00138                 return;
00139             }
00140         }
00141         $this->_redirect('*/*/');
00142     }


The documentation for this class was generated from the following file:

Generated on Sat Jul 4 17:23:28 2009 for Magento by  doxygen 1.5.8