public function statusAction() { $view = new ViewModel(); $this->layout('layout/apotravinyadmin'); $id = $this->params()->fromRoute('id', 0); $status = $this->params()->fromRoute('status', 0); $CrowlerTable = $this->getServiceLocator()->get('CrowlerTable'); if ($id == 0) { return $this->redirect()->toRoute('Crowler', array('controller' => 'product', 'action' => 'list-news')); } else { $exchange_data = array(); $exchange_data['id'] = $id; $exchange_data['status'] = $status; $Crowler = new Crowler(); $Crowler->exchangeArray($exchange_data); $checkupdate = $CrowlerTable->savestatus($Crowler); $view->id = $id; $view->check = $checkupdate; return $view; } }
public function dragdropAction() { $getuser = $this->forward()->dispatch('Admin\\Controller\\Index', array('action' => 'getuser')); $this->layout()->getuser = $getuser; //not login if (!$getuser) { $this->redirect()->toUrl(WEBPATH); } $this->layout('layout/dragdrop'); $product_id = (int) $this->params()->fromRoute('id', 0); if ($product_id == 0) { die("Error ! try agian!"); } $img = (int) $this->params()->fromPost('img', 0); if ($img == 1) { // update array_img = null die("Error none"); } //---------------------------------- Upload product ------------------------------------------------------- $utility = new Utility(); $output_dir = UPLOAD_PATH_IMG . '/'; //"uploads/"; $output_dir_thumb = UPLOAD_PATH_IMG_THUNB_ . '/'; //"uploads/"; $_ProductTable = $this->getServiceLocator()->get('ProductTable'); if (isset($_FILES["myfile"])) { $ret = array(); $tmp_Crowler_all = ''; // $error = $_FILES["myfile"]["error"]; if (!@is_array($_FILES["myfile"]['name'])) { // single file $RandomNum = time(); $ImageName = @str_replace(' ', '-', @strtolower($_FILES['myfile']['name'])); $ImageType = $_FILES['myfile']['type']; // "image/png", image/jpeg etc. $ImageExt = @substr($ImageName, @strrpos($ImageName, '.')); $ImageExt = @str_replace('.', '', $ImageExt); $ImageName = @preg_replace("/\\.[^.\\s]{3,4}\$/", "", $ImageName); $NewImageName = $ImageName . '-' . $RandomNum . '.' . $ImageExt; $check = @move_uploaded_file($_FILES["myfile"]["tmp_name"], $output_dir . $NewImageName); //tao kich co anh va di chuyen vao thumbnail $dir = UPLOAD_PATH_IMG; $dirFileName = $dir . '/' . $NewImageName; $options = array('max_width' => 102, 'max_height' => 102, 'jpeg_quality' => 100); $utility->createImageThumbnail($dirFileName, $dir . '/thumb_', $options); if ($product_id != 0) { $_Crowler_all = $_ProductTable->get($product_id); if ($_Crowler_all->array_img != '' || $_Crowler_all->array_img === null || $_Crowler_all->array_img === NULL || $_Crowler_all->array_img === '(NULL)') { if ($_Crowler_all->array_img === null) { $tmp_Crowler_all = $NewImageName; } else { $tmp_Crowler_all = $_Crowler_all->array_img . ',' . $NewImageName; } } //update array_img $data_update_img = array('id' => $product_id, 'array_img' => $tmp_Crowler_all); $Crowler = new Crowler(); $Crowler->exchangeArray($data_update_img); $_check = $_ProductTable->update_array_img_insert($Crowler); } // echo "<br> Error: ".$_FILES["myfile"]["error"]; //echo "testupload : "; $ret[$NewImageName] = $output_dir . $NewImageName; echo "update_array_img_insert : "; var_dump($_check); echo @json_encode($ret); die; } } }