public function editAction()
 {
     if ($this->_request->isPost()) {
         if (Digitalus_Filesystem_File::isUploaded('field_image')) {
             // Xu ly upload file
             $upload = new Digitalus_Resource_Image();
             $ext = Digitalus_Filesystem_File::getFileExtension($_FILES['field_image']['name']);
             $file_name = 'manu_' . time() . ".{$ext}";
             $upload->uploadImage('field_image', $file_name, DIR_VM_MANUFACTURER_IMAGE, false, false);
             $_POST['image'] = DIR_VM_MANUFACTURER_IMAGE . "/{$file_name}";
         }
         if ($this->_objManus->updateFromPost()) {
             $this->_redirect($this->_currentControllerUrl);
             return;
         }
         $rowManu = $this->_objManus->createRow($this->_request->getParams());
     } else {
         $id = $this->_request->getParam('id');
         $rowManu = $this->_objManus->find($id)->current();
         if (!$rowManu) {
             $this->_redirect($this->_currentControllerUrl);
         }
     }
     $this->view->rowManu = $rowManu;
     $this->view->title_action = $this->view->getTranslation('Edit');
 }
 public function editAction()
 {
     $this->loadLeftPage();
     if ($this->_request->isPost()) {
         if (Digitalus_Filesystem_File::isUploaded('field_default_image')) {
             // Xu ly upload file
             $upload = new Digitalus_Resource_Image();
             $ext = Digitalus_Filesystem_File::getFileExtension($_FILES['field_default_image']['name']);
             $file_name = 'type_' . time() . ".{$ext}";
             $upload->uploadImage('field_default_image', $file_name, DIR_VM_PRODUCT_TYPE_IMAGE, false, false);
             $_POST['default_image'] = DIR_VM_PRODUCT_TYPE_IMAGE . "/{$file_name}";
         }
         if ($this->_objProTypes->updateFromPost()) {
             // Xoa toan bo cache trong trong troller nay
             $this->_redirect($this->_currentControllerUrl);
             return;
         }
         $rowType = $this->_objProTypes->createRow($this->_request->getParams());
     } else {
         $id = $this->_request->getParam('id');
         $rowType = $this->_objProTypes->find($id)->current();
         if (!$rowType) {
             $this->_redirect($this->_currentControllerUrl);
         }
     }
     $this->view->rowType = $rowType;
     $this->view->title_action = "Edit";
 }
Esempio n. 3
0
 public function addAction()
 {
     $cId = $this->_request->getParam('cId', 0);
     $cPath = $this->_request->getParam('cPath', null);
     $type_id = $this->_request->getParam('type_id', null);
     // Neu khong ton tai category hay product thi chuyen den trang chu
     if ($cId != 0 && !$this->_objCats->find($cId)->current()) {
         $this->_redirect($this->_currentModuleUrl);
     }
     $val = array('tax_rates_id' => 0, 'quantity' => 0, 'price' => 0, 'discount' => 0, 'weight' => 0, 'in_stock' => 0, 'quantity_order_min' => 0, 'quantity_order_max' => 0, 'quantity_order_units' => 0, 'is_virtual' => 0, 'is_free' => 0, 'is_call' => 0, 'is_always_free_shipping' => 0, 'order' => 0, 'active' => 0);
     //you must validate that the session ids match
     if ($this->_request->isPost()) {
         if (Digitalus_Filesystem_File::isUploaded('field_image')) {
             // Xu ly upload file
             $upload = new Digitalus_Resource_Image();
             $ext = Digitalus_Filesystem_File::getFileExtension($_FILES['field_image']['name']);
             $file_name = 'cat_' . time() . ".{$ext}";
             $upload->uploadImage('field_image', $file_name, DIR_VM_CATALOG_IMAGE, false, false);
             $_POST['image'] = DIR_VM_CATALOG_IMAGE . "/{$file_name}";
         }
         if ($this->_objCats->insertFromPost()) {
             $this->_redirect($this->_currentControllerUrl);
             return;
         }
         $val = $this->_request->getParams();
     }
     $this->view->breadCrumbs = $this->view->partial('category-product/_bread_crumbs.phtml', array('view' => $this->view, 'arrPath' => $this->view->getBreadCrumbsData($cId)));
     $rowProduct = $this->_objProducts->createRow($val);
     $this->view->rowProduct = $rowProduct;
     $this->view->cId = $cId;
     $this->view->cPath = $cPath;
     $this->view->type_id = $type_id;
     $this->view->title_action = $this->view->getTranslation('Add');
 }
Esempio n. 4
0
 public function editAction()
 {
     $cId = $this->_request->getParam('cId');
     $cPath = $this->_request->getParam('cPath');
     if ($this->_request->isPost()) {
         if (Digitalus_Filesystem_File::isUploaded('field_image')) {
             // Xu ly upload file
             $upload = new Digitalus_Resource_Image();
             $ext = Digitalus_Filesystem_File::getFileExtension($_FILES['field_image']['name']);
             $file_name = 'cat_' . time() . ".{$ext}";
             $upload->uploadImage('field_image', $file_name, DIR_VM_CATALOG_IMAGE, false, false);
             $_POST['image'] = DIR_VM_CATALOG_IMAGE . "/{$file_name}";
         }
         if ($this->_objCats->updateFromPost()) {
             $this->_redirect($this->_currentControllerUrl);
             return;
         }
         $rowManu = $this->_objCats->createRow($this->_request->getParams());
     } else {
         $rowCat = $this->_objCats->find($cId)->current();
         if (!$rowCat) {
             $this->_redirect($this->_currentControllerUrl);
         }
     }
     $this->view->breadCrumbs = $this->view->partial('category-product/_bread_crumbs.phtml', array('view' => $this->view, 'arrPath' => $this->view->getBreadCrumbsData($cId)));
     $this->view->rowCat = $rowCat;
     $this->view->cId = $cId;
     $this->view->cPath = $cPath;
     $this->view->title_action = $this->view->getTranslation('Edit');
 }