Advertisement
Guest User

New fixed

a guest
Feb 7th, 2016
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 4.00 KB | None | 0 0
  1. <?php
  2. /**
  3.  *
  4.  * @ IonCube v7 Decoder By DoraemonPT
  5.  *
  6.  * @ Version  : 1,0,0,0
  7.  * @ Author   : DoraemonPT
  8.  * @ Release on : 19-08-2013
  9.  * @ Website  : http://easytoyou.eu
  10.  *
  11.  **/
  12.  
  13. class Websoft_Dpd_Adminhtml_PricelistController extends Mage_Adminhtml_Controller_Action
  14. {
  15.     function indexAction()
  16.     {
  17.         $this->loadLayout();
  18.         $this->_addContent($this->getLayout()->createBlock('dpd/adminhtml_pricelist'));
  19.         $this->renderLayout();
  20.     }
  21.  
  22.     function newAction()
  23.     {
  24.         $this->_forward('edit');
  25.     }
  26.  
  27.     function editAction()
  28.     {
  29.         $id = $this->getRequest()->getParam('id', null);
  30.         $model = Mage::getModel('dpd/pricelist');
  31.  
  32.         if ($id) {
  33.             $model->load((int)$id);
  34.  
  35.             if ($model->getId()) {
  36.                 $data = Mage::getSingleton('adminhtml/session')->getFormData(true);
  37.  
  38.                 if ($data) {
  39.                     $model->setData($data)->setId($id);
  40.                 }
  41.             } else {
  42.                 Mage::getSingleton('adminhtml/session')->addError(Mage::helper('awesome')->__('Reguła nie istnieje'));
  43.                 $this->_redirect('*/*/');
  44.             }
  45.         }
  46.  
  47.         Mage::register('pricelist_data', $model);
  48.         $this->loadLayout();
  49.         $this->getLayout()->getBlock('head')->setCanLoadExtJs(true);
  50.         $this->_addContent($this->getLayout()->createBlock('dpd/adminhtml_pricelist_edit'));
  51.         $this->renderLayout();
  52.     }
  53.  
  54.     function saveAction()
  55.     {
  56.         if ($data = $this->getRequest()->getPost()) {
  57.             try {
  58.                 $model = Mage::getModel('dpd/pricelist');
  59.                 $data_country = implode(',', array_filter($data['country']));
  60.                 $data['country'] = $data_country;
  61.                 $id = $this->getRequest()->getParam('id');
  62.  
  63.                 if ($id) {
  64.                     $model->load($id);
  65.                 }
  66.  
  67.                 $model->setData($data);
  68.                 Mage::getSingleton('adminhtml/session')->setFormData($data);
  69.  
  70.                 if ($id) {
  71.                     $model->setId($id);
  72.                 }
  73.  
  74.                 $model->save();
  75.  
  76.                 if (!$model->getId()) {
  77.                     Mage::throwException(Mage::helper('dpd')->__('Błąd zapisu.'));
  78.                 }
  79.  
  80.                 Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('dpd')->__('Reguła została pomyślnie zapisana.'));
  81.                 Mage::getSingleton('adminhtml/session')->setFormData(false);
  82.                 $this->_redirect('*/*/');
  83.                 return null;
  84.             } catch (Exception $e) {
  85.                 Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
  86.  
  87.                 if (( $model && $model->getId() )) {
  88.                     $this->_redirect('*/*/edit', array( 'id' => $model->getId() ));
  89.                     return null;
  90.                 }
  91.  
  92.                 $this->_redirect('*/*/');
  93.                 return null;
  94.             }
  95.         }
  96.  
  97.         Mage::getSingleton('adminhtml/session')->addError(Mage::helper('dpd')->__('Brak danych do zapisu.'));
  98.         $this->_redirect('*/*/');
  99.     }
  100.  
  101.     function deleteAction()
  102.     {
  103.         if ($id = $this->getRequest()->getParam('id')) {
  104.             try {
  105.                 $model = Mage::getModel('dpd/pricelist');
  106.                 $model->setId($id);
  107.                 $model->delete();
  108.                 Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('dpd')->__('Reguła ceny została usunięta.'));
  109.                 $this->_redirect('*/*/');
  110.                 return null;
  111.             } catch (Exception $e) {
  112.                 Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
  113.                 $this->_redirect('*/*/edit', array( 'id' => $this->getRequest()->getParam('id') ));
  114.                 return null;
  115.             }
  116.         }
  117.  
  118.         Mage::getSingleton('adminhtml/session')->addError(Mage::helper('adminhtml')->__('Nie odnaleziono reguły do usunięcia.'));
  119.         $this->_redirect('*/*/');
  120.     }
  121. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement