Mage_Adminhtml_Tax_Class_CustomerController Class Reference

Inheritance diagram for Mage_Adminhtml_Tax_Class_CustomerController:

Mage_Adminhtml_Controller_Action Mage_Core_Controller_Varien_Action

List of all members.

Public Member Functions

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

Protected Member Functions

 _initAction ()
 _isAllowed ()


Detailed Description

Definition at line 35 of file CustomerController.php.


Member Function Documentation

_initAction (  )  [protected]

Initialize action

Returns:
Mage_Adminhtml_Controller_Action

Definition at line 146 of file CustomerController.php.

00147     {
00148         $this->loadLayout()
00149             ->_setActiveMenu('sales/tax/tax_class_customer')
00150             ->_addBreadcrumb(Mage::helper('tax')->__('Sales'), Mage::helper('tax')->__('Sales'))
00151             ->_addBreadcrumb(Mage::helper('tax')->__('Tax'), Mage::helper('tax')->__('Tax'))
00152             ->_addBreadcrumb(Mage::helper('tax')->__('Manage Customer Tax Classes'), Mage::helper('tax')->__('Manage Customer Tax Classes'))
00153         ;
00154         return $this;
00155     }

_isAllowed (  )  [protected]

Check current user permission on resource and privilege

Returns:
bool

Reimplemented from Mage_Adminhtml_Controller_Action.

Definition at line 162 of file CustomerController.php.

00163     {
00164         return Mage::getSingleton('admin/session')->isAllowed('sales/tax/classes_customer');
00165     }

deleteAction (  ) 

delete class action

Definition at line 91 of file CustomerController.php.

00092     {
00093         $classId    = $this->getRequest()->getParam('id');
00094         $classModel = Mage::getModel('tax/class')
00095             ->load($classId);
00096 
00097         if (!$classModel->getId() || $classModel->getClassType() != 'CUSTOMER') {
00098             Mage::getSingleton('adminhtml/session')->addError(Mage::helper('tax')->__('This class no longer exists'));
00099             $this->_redirect('*/*/');
00100             return;
00101         }
00102 
00103         $ruleCollection = Mage::getModel('tax/calculation_rule')
00104             ->getCollection()
00105             ->setClassTypeFilter('CUSTOMER', $classId);
00106 
00107         if ($ruleCollection->getSize() > 0) {
00108             Mage::getSingleton('adminhtml/session')->addError(Mage::helper('tax')->__('You cannot delete this tax class as it is used in Tax Rules. You have to delete the rules it is used in first.'));
00109             $this->_redirectReferer();
00110             return;
00111         }
00112 
00113         $customerGroupCollection = Mage::getModel('customer/group')
00114             ->getCollection()
00115             ->addFieldToFilter('tax_class_id', $classId);
00116         $groupCount = $customerGroupCollection->getSize();
00117 
00118         if ($groupCount > 0) {
00119             Mage::getSingleton('adminhtml/session')->addError(Mage::helper('tax')->__('You cannot delete this tax class as it is used for %d customer groups.', $groupCount));
00120             $this->_redirectReferer();
00121             return;
00122         }
00123 
00124         try {
00125             $classModel->delete();
00126 
00127             Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('tax')->__('Tax class was successfully deleted'));
00128             $this->getResponse()->setRedirect($this->getUrl("*/*/"));
00129             return ;
00130         }
00131         catch (Mage_Core_Exception $e) {
00132             Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
00133         }
00134         catch (Exception $e) {
00135             Mage::getSingleton('adminhtml/session')->addError(Mage::helper('tax')->__('Error while deleting this class. Please try again later.'));
00136         }
00137 
00138         $this->_redirectReferer();
00139     }

editAction (  ) 

edit class action

Definition at line 61 of file CustomerController.php.

00062     {
00063         $classId    = $this->getRequest()->getParam('id');
00064         $model      = Mage::getModel('tax/class');
00065         if ($classId) {
00066             $model->load($classId);
00067             if (!$model->getId() || $model->getClassType() != 'CUSTOMER') {
00068                 Mage::getSingleton('adminhtml/session')->addError(Mage::helper('tax')->__('This class no longer exists'));
00069                 $this->_redirect('*/*/');
00070                 return;
00071             }
00072         }
00073 
00074         $data = Mage::getSingleton('adminhtml/session')->getClassData(true);
00075         if (!empty($data)) {
00076             $model->setData($data);
00077         }
00078 
00079         Mage::register('tax_class', $model);
00080 
00081         $this->_initAction()
00082             ->_addBreadcrumb($classId ? Mage::helper('tax')->__('Edit Class') :  Mage::helper('tax')->__('New Class'), $classId ?  Mage::helper('tax')->__('Edit Class') :  Mage::helper('tax')->__('New Class'))
00083             ->_addContent($this->getLayout()->createBlock('adminhtml/tax_class_edit')->setData('action', $this->getUrl('*/tax_class/save'))->setClassType('CUSTOMER'))
00084             ->renderLayout();
00085     }

indexAction (  ) 

grid view

Definition at line 41 of file CustomerController.php.

00042     {
00043         $this->_initAction()
00044             ->_addContent($this->getLayout()->createBlock('adminhtml/tax_class')->setClassType('CUSTOMER'))
00045             ->renderLayout();
00046     }

newAction (  ) 

new class action

Definition at line 52 of file CustomerController.php.

00053     {
00054         $this->_forward('edit');
00055     }


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