Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /**
- *
- * @ IonCube v7 Decoder By DoraemonPT
- *
- * @ Version : 1,0,0,0
- * @ Author : DoraemonPT
- * @ Release on : 19-08-2013
- * @ Website : http://easytoyou.eu
- *
- **/
- class Websoft_Dpd_Adminhtml_PricelistController extends Mage_Adminhtml_Controller_Action
- {
- function indexAction()
- {
- $this->loadLayout();
- $this->_addContent($this->getLayout()->createBlock('dpd/adminhtml_pricelist'));
- $this->renderLayout();
- }
- function newAction()
- {
- $this->_forward('edit');
- }
- function editAction()
- {
- $id = $this->getRequest()->getParam('id', null);
- $model = Mage::getModel('dpd/pricelist');
- if ($id) {
- $model->load((int)$id);
- if ($model->getId()) {
- $data = Mage::getSingleton('adminhtml/session')->getFormData(true);
- if ($data) {
- $model->setData($data)->setId($id);
- }
- } else {
- Mage::getSingleton('adminhtml/session')->addError(Mage::helper('awesome')->__('Reguła nie istnieje'));
- $this->_redirect('*/*/');
- }
- }
- Mage::register('pricelist_data', $model);
- $this->loadLayout();
- $this->getLayout()->getBlock('head')->setCanLoadExtJs(true);
- $this->_addContent($this->getLayout()->createBlock('dpd/adminhtml_pricelist_edit'));
- $this->renderLayout();
- }
- function saveAction()
- {
- if ($data = $this->getRequest()->getPost()) {
- try {
- $model = Mage::getModel('dpd/pricelist');
- $data_country = implode(',', array_filter($data['country']));
- $data['country'] = $data_country;
- $id = $this->getRequest()->getParam('id');
- if ($id) {
- $model->load($id);
- }
- $model->setData($data);
- Mage::getSingleton('adminhtml/session')->setFormData($data);
- if ($id) {
- $model->setId($id);
- }
- $model->save();
- if (!$model->getId()) {
- Mage::throwException(Mage::helper('dpd')->__('Błąd zapisu.'));
- }
- Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('dpd')->__('Reguła została pomyślnie zapisana.'));
- Mage::getSingleton('adminhtml/session')->setFormData(false);
- $this->_redirect('*/*/');
- return null;
- } catch (Exception $e) {
- Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
- if (( $model && $model->getId() )) {
- $this->_redirect('*/*/edit', array( 'id' => $model->getId() ));
- return null;
- }
- $this->_redirect('*/*/');
- return null;
- }
- }
- Mage::getSingleton('adminhtml/session')->addError(Mage::helper('dpd')->__('Brak danych do zapisu.'));
- $this->_redirect('*/*/');
- }
- function deleteAction()
- {
- if ($id = $this->getRequest()->getParam('id')) {
- try {
- $model = Mage::getModel('dpd/pricelist');
- $model->setId($id);
- $model->delete();
- Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('dpd')->__('Reguła ceny została usunięta.'));
- $this->_redirect('*/*/');
- return null;
- } catch (Exception $e) {
- Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
- $this->_redirect('*/*/edit', array( 'id' => $this->getRequest()->getParam('id') ));
- return null;
- }
- }
- Mage::getSingleton('adminhtml/session')->addError(Mage::helper('adminhtml')->__('Nie odnaleziono reguły do usunięcia.'));
- $this->_redirect('*/*/');
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement