Mage_Adminhtml_Tax_RuleController Class Reference

Inheritance diagram for Mage_Adminhtml_Tax_RuleController:

Mage_Adminhtml_Controller_Action Mage_Core_Controller_Varien_Action

List of all members.

Public Member Functions

 indexAction ()
 newAction ()
 editAction ()
 saveAction ()
 deleteAction ()

Protected Member Functions

 _initAction ()
 _isAllowed ()


Detailed Description

Definition at line 34 of file RuleController.php.


Member Function Documentation

_initAction (  )  [protected]

Initialize action

Returns:
Mage_Adminhtml_Controller_Action

Definition at line 135 of file RuleController.php.

00136     {
00137         $this->loadLayout()
00138             ->_setActiveMenu('sales/tax/rule')
00139             ->_addBreadcrumb(Mage::helper('tax')->__('Tax'), Mage::helper('tax')->__('Tax'))
00140             ->_addBreadcrumb(Mage::helper('tax')->__('Tax Rules'), Mage::helper('tax')->__('Tax Rules'))
00141         ;
00142         return $this;
00143     }

_isAllowed (  )  [protected]

Reimplemented from Mage_Adminhtml_Controller_Action.

Definition at line 145 of file RuleController.php.

00146     {
00147         return Mage::getSingleton('admin/session')->isAllowed('sales/tax/rules');
00148     }

deleteAction (  ) 

Definition at line 101 of file RuleController.php.

00102     {
00103         $ruleId = (int)$this->getRequest()->getParam('rule');
00104         $ruleModel = Mage::getSingleton('tax/calculation_rule')
00105             ->load($ruleId);
00106         if (!$ruleModel->getId()) {
00107             Mage::getSingleton('adminhtml/session')->addError(Mage::helper('tax')->__('This rule no longer exists'));
00108             $this->_redirect('*/*/');
00109             return;
00110         }
00111 
00112         try {
00113             $ruleModel->delete();
00114 
00115             Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('tax')->__('Tax rule was successfully deleted'));
00116             $this->_redirect('*/*/');
00117 
00118             return;
00119         }
00120         catch (Mage_Core_Exception $e) {
00121             Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
00122         }
00123         catch (Exception $e) {
00124             Mage::getSingleton('adminhtml/session')->addError(Mage::helper('tax')->__('Error while deleting this tax rule. Please try again later.'));
00125         }
00126 
00127         $this->_redirectReferer();
00128     }

editAction (  ) 

Definition at line 49 of file RuleController.php.

00050     {
00051         $taxRuleId  = $this->getRequest()->getParam('rule');
00052         $ruleModel  = Mage::getModel('tax/calculation_rule');
00053         if ($taxRuleId) {
00054             $ruleModel->load($taxRuleId);
00055             if (!$ruleModel->getId()) {
00056                 Mage::getSingleton('adminhtml/session')->addError(Mage::helper('tax')->__('This rule no longer exists'));
00057                 $this->_redirect('*/*/');
00058                 return;
00059             }
00060         }
00061 
00062         $data = Mage::getSingleton('adminhtml/session')->getRuleData(true);
00063         if (!empty($data)) {
00064             $ruleModel->setData($data);
00065         }
00066 
00067         Mage::register('tax_rule', $ruleModel);
00068 
00069         $this->_initAction()
00070             ->_addBreadcrumb($taxRuleId ? Mage::helper('tax')->__('Edit Rule') :  Mage::helper('tax')->__('New Rule'), $taxRuleId ?  Mage::helper('tax')->__('Edit Rule') :  Mage::helper('tax')->__('New Rule'))
00071             ->_addContent($this->getLayout()->createBlock('adminhtml/tax_rule_edit')->setData('action', $this->getUrl('*/tax_rule/save')))
00072             ->renderLayout();
00073     }

indexAction (  ) 

Definition at line 36 of file RuleController.php.

00037     {
00038         $this->_initAction()
00039             ->_addContent($this->getLayout()->createBlock('adminhtml/tax_rule'))
00040             ->renderLayout();
00041         return $this;
00042     }

newAction (  ) 

Definition at line 44 of file RuleController.php.

00045     {
00046         $this->_forward('edit');
00047     }

saveAction (  ) 

Definition at line 75 of file RuleController.php.

00076     {
00077         if ($postData = $this->getRequest()->getPost()) {
00078             $ruleModel = Mage::getSingleton('tax/calculation_rule');
00079             $ruleModel->setData($postData);
00080 
00081             try {
00082                 $ruleModel->save();
00083 
00084                 Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('tax')->__('Tax rule was successfully saved'));
00085                 $this->_redirect('*/*/');
00086 
00087                 return;
00088             }
00089             catch (Mage_Core_Exception $e) {
00090                 Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
00091             }
00092             catch (Exception $e) {
00093                 Mage::getSingleton('adminhtml/session')->addError(Mage::helper('tax')->__('Error while saving this tax rule. Please try again later.'));
00094             }
00095 
00096             Mage::getSingleton('adminhtml/session')->setRuleData($postData);
00097             $this->_redirectReferer();
00098         }
00099     }


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

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