Exemplo n.º 1
0
 public function deleteAction()
 {
     $product_id = (int) $this->params()->fromRoute('id', 0);
     if ($product_id == 0) {
         return $this->redirect()->toRoute('Masterialproduct');
     }
     $view = new ViewModel();
     $utility = new Utility();
     $this->layout('layout/apotravinyadmin');
     $getuser = $this->forward()->dispatch('Admin\\Controller\\Index', array('action' => 'getuser'));
     $this->layout()->getuser = $getuser;
     $request = $this->getRequest();
     if ($request->isPost()) {
         $del = $request->getPost()->get('del', 'No');
         if ($del == 'Yes') {
             $id = (int) $request->getPost()->get('id');
             if ($id != 0) {
                 $getcata = $this->getServiceLocator()->get('MasterialproductTable')->get($id);
                 if ($getcata) {
                     $get_img_older = $getcata->img;
                     $_dir = UPLOAD_PATH_IMG;
                     if ($get_img_older) {
                         $utility->deleteImage($get_img_older, $_dir);
                     }
                 }
                 $view->check = $this->getServiceLocator()->get('MasterialproductTable')->delete($product_id);
                 return $view;
             } else {
                 $view->check = 0;
                 return $view;
             }
         }
     }
     $view->setVariable('id', $product_id);
     $view->setVariable('product', $this->getServiceLocator()->get('MasterialproductTable')->get($product_id));
     return $view;
 }
Exemplo n.º 2
0
 public function masterdeleteAction()
 {
     $Slider_id = (int) $this->params()->fromRoute('id', 0);
     if ($Slider_id == 0) {
         return $this->redirect()->toRoute('Slider');
     }
     $view = new ViewModel();
     $utility = new Utility();
     $this->layout('layout/apotravinyadmin');
     $getuser = $this->forward()->dispatch('Admin\\Controller\\Index', array('action' => 'getuser'));
     $this->layout()->getuser = $getuser;
     //$id = (int) $request->getPost()->get('id');
     if ($Slider_id != 0) {
         $getcata = $this->getSliderTable()->getSlider($Slider_id);
         if ($getcata) {
             $get_img_older = $getcata->img;
             $_dir = UPLOAD_PATH_IMG;
             if ($get_img_older) {
                 $utility->deleteImage($get_img_older, $_dir);
             }
         }
         $this->getSliderTable()->delete($Slider_id);
         $this->redirect()->toUrl(WEBPATH . '/tags/masterindex');
     }
     //
     //        $request = $this->getRequest();
     //        if ($request->isPost()) {
     //            $del = $request->getPost()->get('del', 'No');
     //            if ($del == 'Yes') {
     //                $id = (int) $request->getPost()->get('id');
     //
     //                if ($id != 0) {
     //                    $getcata = $this->getSliderTable()->getSlider($id);
     //                    if ($getcata) {
     //                        $get_img_older = $getcata->img;
     //                        $_dir = UPLOAD_PATH_IMG;
     //                        if ($get_img_older) {
     //                            $utility->deleteImage($get_img_older, $_dir);
     //                        }
     //                    }
     //
     //                    $view->check = $this->getSliderTable()->delete($Slider_id);
     //                    return $view;
     //                } else {
     //                    $view->check = 0;
     //                    return $view;
     //                }
     //            }
     //        }
     //
     //        $view->setVariable('id', $Slider_id);
     //        $view->setVariable('tags', $this->getSliderTable()->getSlider($Slider_id));
     //
     //        return $view;
 }