Beispiel #1
0
 public function update_printer()
 {
     try {
         $_arData = array();
         $_arData2 = array();
         $total_files = null;
         $detailName = Input::get("detailName");
         $detailType = Input::get("detailType");
         $detailPDF = Input::get("detailPDF");
         $detailVideo = Input::get("detailVideo");
         $detailDescription = Input::get("detailDescription");
         $detailOldPrice = Input::get("detailOldPrice");
         $detailNewPrice = Input::get("detailNewPrice");
         $detailVisible = Input::get("detailVisible");
         if ($detailVisible == '1') {
             $detailVisible = '1';
         } else {
             $detailVisible = '0';
         }
         $destinationPath_Printer = 'asserts/images/Products/Printers';
         $_countFiles = count(Input::file("filedetailTImage"));
         $_number = 1;
         if (Input::hasfile('filedetailTImage')) {
             foreach (Input::file("filedetailTImage") as $file) {
                 $filename = $file->getClientOriginalName();
                 if ($_number == $_countFiles) {
                     $total_files .= $filename;
                 } else {
                     $total_files .= $filename . ';';
                 }
                 $upload_success = $file->move($destinationPath_Printer, $filename);
                 $_number++;
             }
         }
         $filename_Banner = null;
         if (Input::hasfile('filedetailBImage')) {
             $file_Banner = Input::file("filedetailBImage");
             $filename_Banner = $file_Banner->getClientOriginalName();
             $upload_success_banner = $file_Banner->move($destinationPath_Printer, $filename_Banner);
         }
         if ($filename_Banner == null && $total_files == null) {
             $_arData = array('detailName' => $detailName, 'detailType' => $detailType, 'detailPDF' => $detailPDF, 'detailVideo' => $detailVideo, 'detailDescription' => $detailDescription, 'detailOldPrice' => $detailOldPrice, 'detailNewPrice' => $detailNewPrice, 'detailVisible' => $detailVisible);
         } else {
             if ($filename_Banner == null && $total_files != null) {
                 $_arData = array('detailName' => $detailName, 'detailType' => $detailType, 'detailPDF' => $detailPDF, 'detailVideo' => $detailVideo, 'detailDescription' => $detailDescription, 'detailOldPrice' => $detailOldPrice, 'detailNewPrice' => $detailNewPrice, 'detailVisible' => $detailVisible, 'detailTImage' => $total_files);
             } else {
                 if ($filename_Banner != null && $total_files == null) {
                     $_arData = array('detailName' => $detailName, 'detailType' => $detailType, 'detailPDF' => $detailPDF, 'detailVideo' => $detailVideo, 'detailDescription' => $detailDescription, 'detailOldPrice' => $detailOldPrice, 'detailNewPrice' => $detailNewPrice, 'detailVisible' => $detailVisible, 'detailBImage' => $filename_Banner);
                 } else {
                     if ($filename_Banner != null && $total_files != null) {
                         $_arData = array('detailName' => $detailName, 'detailType' => $detailType, 'detailPDF' => $detailPDF, 'detailVideo' => $detailVideo, 'detailDescription' => $detailDescription, 'detailOldPrice' => $detailOldPrice, 'detailNewPrice' => $detailNewPrice, 'detailVisible' => $detailVisible, 'detailBImage' => $filename_Banner, 'detailTImage' => $total_files);
                     }
                 }
             }
         }
         $_page_update = Printers::where('detailId', Input::get("detailId"))->update($_arData);
         $printerId = Input::get("printerId");
         $_arData2 = array('printerId' => $printerId, 'detailId' => Input::get("detailId"));
         $oldprinterId = Input::get("oldprinterId");
         $_page_update1 = PrinterAlias::where('printerId', $oldprinterId)->where('detailId', Input::get("detailId"))->update($_arData2);
     } catch (Exception $_ex) {
         Session::flash('error', '$$$ --- Error (' . $_ex->getMessage() . ') --- $$$');
     }
     Session::flash('success', '$$$ --- Update Printer Successfully  --- $$$');
     return Redirect::to('qlm-admin/printers/' . Input::get("detailId"));
 }
Beispiel #2
0
 public function delete_printer_image()
 {
     try {
         $sequence = 0;
         $id = Input::get('id');
         $_arrayImages = explode(";", Input::get('images'));
         $images = $_arrayImages;
         $image = Input::get('image');
         $new_image = '';
         foreach ($images as $_image) {
             if ($_image != $image) {
                 if ($sequence == count($images) - 1) {
                     $new_image .= $_image;
                 } else {
                     $new_image .= $_image . ';';
                 }
             }
             $sequence++;
         }
         if (ends_with($new_image, ';')) {
             $_arrayImages = '';
             $_arrayImages = explode(";", $new_image);
             $new_image = '';
             $sequence = 0;
             foreach ($_arrayImages as $_image) {
                 $sequence++;
                 if ($sequence < count($images) - 1) {
                     $new_image .= $_image . ';';
                 } else {
                     if ($sequence == count($images) - 1) {
                         $new_image .= $_image;
                     }
                 }
             }
         }
         $isUpdate = Printers::where('detailId', $id)->update(array('detailTImage' => $new_image));
         return Response::json(['status' => 'success', 'msg' => 'Đăng nhập thành công!']);
     } catch (Exception $_ex) {
         Log::error('Error: ' . $_ex);
         return Response::json(['status' => 'error', 'msg' => 'Đăng nhập thành công!']);
     }
 }