Esempio n. 1
0
 public function add_printer()
 {
     try {
         $_arData = array();
         $total_files = null;
         $detailId = Input::get("detailId");
         $detailName = Input::get("detailName");
         $detailType = Input::get("detailType");
         $detailPDF = Input::get("detailPDF", null);
         $detailVideo = Input::get("detailVideo", null);
         $detailDescription = Input::get("detailDescription", null);
         $detailNewPrice = Input::get("detailNewPrice", null);
         $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);
         }
         $newPrinter = new Printers();
         $newPrinter->detailId = $detailId;
         $newPrinter->detailName = $detailName;
         $newPrinter->detailType = $detailType;
         $newPrinter->detailPDF = $detailPDF;
         $newPrinter->detailVideo = $detailVideo;
         $newPrinter->detailDescription = $detailDescription;
         $newPrinter->detailNewPrice = $detailNewPrice;
         $newPrinter->detailVisible = $detailVisible;
         $newPrinter->detailBImage = $filename_Banner;
         $newPrinter->detailTImage = $total_files;
         $newPrinter->save();
         $printerId = Input::get("printerId", null);
         $newalias = new PrinterAlias();
         $newalias->printerId = $printerId;
         $newalias->detailId = $detailId;
         $newalias->save();
     } catch (Exception $_ex) {
         Session::flash('error', '$$$ --- Error (' . $_ex->getMessage() . ') --- $$$');
     }
     Session::flash('success', '$$$ --- Update Printer Successfully  --- $$$');
     return Redirect::to('qlm-admin/add-new-printer');
 }
Esempio n. 2
0
 public function add_printer()
 {
     try {
         $total_files = null;
         $destinationPath_Printer = 'asserts/images/Products/Printers';
         $destinationPath_PDF = 'asserts/Files/Catalogue';
         $new_printer = new Printers();
         if (!empty(Input::get("detailName"))) {
             $new_printer->detailName = Input::get("detailName");
         }
         if (!empty(Input::get("detailType"))) {
             $new_printer->detailType = Input::get("detailType");
         }
         if (!empty(Input::get("detailVideo"))) {
             $new_printer->detailVideo = Input::get("detailVideo");
         }
         if (!empty(Input::get("detailDescription"))) {
             $new_printer->detailDescription = Input::get("detailDescription");
         }
         if (!empty(Input::get("detailNewPrice"))) {
             $new_printer->detailNewPrice = Input::get("detailNewPrice");
         }
         if (!empty(Input::get("detailVisible"))) {
             $new_printer->detailVisible = Input::get("detailVisible");
         }
         $filename_PDF = null;
         if (Input::hasfile('file_detailPDF')) {
             $file_PDF = Input::file("file_detailPDF");
             $filename_PDF = $file_PDF->getClientOriginalName();
             $upload_success_banner = $file_PDF->move($destinationPath_PDF, $filename_PDF);
             $new_printer->detailPDF = $filename_PDF;
         }
         $_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++;
             }
             $new_printer->detailTImage = $total_files;
         }
         $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);
             $new_printer->detailBImage = $filename_Banner;
         }
         $printerId = $this->generate_printerid();
         $new_printer->detailId = $printerId;
         $new_printer->save();
         /*==============================
           == Phan update Alias
           ==============================*/
         $is_deleted = PrinterAlias::where('detailId', $printerId)->delete();
         foreach (Input::get("type_printer") as $type_prin) {
             $alias_new = new PrinterAlias();
             $alias_new->printerId = $type_prin;
             $alias_new->detailId = $printerId;
             $alias_new->save();
         }
     } catch (Exception $_ex) {
         Session::flash('error', '$$$ --- Error (' . $_ex->getMessage() . ') --- $$$');
     }
     Session::flash('success', '$$$ --- Add Printer Successfully  --- $$$');
     return Redirect::to('qlm-admin/add-new-printer/' . $printerId);
 }