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;
 }
 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;
 }
 public function travelcornerAction()
 {
     $getuser = $this->forward()->dispatch('Admin\\Controller\\Index', array('action' => 'getuser'));
     // var_dump($getuser);
     $this->layout()->getuser = $getuser;
     $unity = new Utility();
     $domain = WEBPATH;
     $newsTable = $this->getServiceLocator()->get('NewsTable');
     $all_new = $newsTable->fetchAll();
     $ajax = "<script type=\"text/javascript\">\n    \t\t\twindow.travel_news = new Array();";
     foreach ($all_new as $key => $value) {
         $dateview = $value->date_creat;
         $_title = $unity->_substr_co_nghia($value->news_name, 30);
         $array_time = explode('-', $dateview);
         if (!empty($array_time)) {
             $number_moth = (int) $array_time[1];
             $_month = $unity->_name_moth($array_time[1]);
             $_today = $array_time[2];
             $_year = $array_time[0];
             $_string = $_month . ' ' . $_today . ' ' . $_year;
         } else {
             $number_moth = '';
             $_month = '';
             $_today = '';
             $_year = '';
             $_string = '';
         }
         if ($value->travel_corner == 1 and $value->status == 1) {
             $ajax .= "travel_news.push({\n\t\t\t\t\t\tthumbnail: '" . $domain . "/uploads/" . $value->news_thumbnail . "',\n\t\t\t\t\t\ttitle: '" . $_title . "',\n\t\t\t\t\t\ttime: '" . $_string . "',\n\t\t\t\t\t\tlink: '" . $domain . "/newsview/" . $value->url_static . "'\n\t\t\t\t\t});";
         }
     }
     // end for
     $ajax .= "</script>";
     echo $ajax;
     die;
 }
 public function deleteAction()
 {
     $id = (int) $this->params()->fromRoute('id', 0);
     $fetch_row = $this->getSlideTable()->fetch_row($id);
     $img_older = $fetch_row->img;
     $this->layout()->show_img = $fetch_row->img;
     //=======check login
     $utility = new Utility();
     $this->layout('layout/bags');
     $getuser = $this->forward()->dispatch('Admin\\Controller\\Index', array('action' => 'getuser'));
     $this->layout()->getuser = $getuser;
     // notlogin
     if (!$getuser) {
         $this->redirect()->toUrl(WEBPATH);
     }
     $post = $_POST;
     if ($post['del'] == 'Yes') {
         // delete img older
         $dir = ROOT_PATH . '/public/imgslideshow';
         $utility->deleteSlideshow($img_older, $dir);
         // delete img older thumb_slideshow
         $dir = ROOT_PATH . '/public/imgslideshow/thumb_slideshow';
         $utility->deleteSlideshow($img_older, $dir);
         // delete img older thumb_slideshow2
         $dir = ROOT_PATH . '/public/imgslideshow/thumb_slideshow2';
         $utility->deleteSlideshow($img_older, $dir);
         //======upload and resize images
         $_array_img = $this->params()->fromFiles('img');
         //die;
         $img_src = $utility->uploadImageSlideshow($_array_img);
         $checkupdate = $this->getSlideTable()->delete($id);
         $url = WEBPATH . '/slideshow/index';
         return $this->redirect()->toUrl($url);
     }
     if ($post['del'] == 'No') {
         $url = WEBPATH . '/slideshow/index';
         return $this->redirect()->toUrl($url);
     }
 }