public function actionGeneratePdf()
 {
     $model = new Printers('search');
     if (isset($_GET['Printers'])) {
         $model->attributes = $_GET['Printers'];
     }
     // to execute the filters (if is the case)
     $dataProvider = $model->search();
     $dataProvider->pagination = false;
     $mPDF1 = Yii::app()->ePdf->mpdf();
     # You can easily override default constructor's params
     $mPDF1 = Yii::app()->ePdf->mpdf('', 'A5');
     # renderPartial (only 'view' of current controller)
     $mPDF1->WriteHTML($this->renderPartial('admin', array('model' => $model), true));
     # Outputs ready PDF
     $mPDF1->Output();
 }
Пример #2
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');
 }
Пример #3
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!']);
     }
 }
Пример #4
0
 public function update_printer()
 {
     try {
         $_arData = 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->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, 'eventPicturesContent' => $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, 'eventPictures' => $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, 'eventPictures' => $filename_Banner, 'eventPicturesContent' => $total_files);
                     }
                 }
             }
         }
         $_page_update = Printers::where('detailId', Input::get("detailId"))->update($_arData);
     } catch (Exception $_ex) {
         Session::flash('error', '$$$ --- Error (' . $_ex->getMessage() . ') --- $$$');
     }
     Session::flash('success', '$$$ --- Update Printer Successfully  --- $$$');
     return Redirect::to('qlm-admin/printers/' . Input::get("detailId"));
 }
 public function getInfo()
 {
     /* Items allocated*/
     $commodity['consumable'] = Consumable::model()->findAll();
     $commodity['monitor'] = Monitor::model()->findAll();
     $commodity['printers'] = Printers::model()->findAll();
     $commodity['devices'] = Devices::model()->findAll();
     $dup = $commodity;
     /* Items available on Loan*/
     $availableOnLoan = 0;
     $thresholdItems = 0;
     $content = '';
     foreach ($commodity as $key => $commo) {
         foreach ($commo as $item) {
             if ($item['available_on_loan'] == 1 || $item['available_on_loan'] == 'Yes') {
                 ++$availableOnLoan;
             }
             if ($key == 'consumable') {
                 $commodity = Commodity::model()->findByAttributes(array('name' => $key));
                 $allocates = Allocate::model()->findAllByAttributes(array('commodity_id' => $commodity['id'], 'cons_id' => $item['id']));
                 if (count($allocates) < $item['threshold']) {
                     ++$thresholdItems;
                 }
             }
         }
     }
     /** Allocated and unallocated **/
     $countAllocated = 0;
     $countUnAllocated = 0;
     $commodity = $dup;
     $unAllocated = Allocate::model()->findAllByAttributes(array('date_out' => NULL));
     $allocated = Allocate::model()->findAll('date_out IS NOT NULL');
     $countAllocated += count($allocated);
     $countUnAllocated += count($unAllocated);
     $content .= '<b style="color:red">' . $availableOnLoan . '</b> item available on loan<br/>';
     $content .= '<b style="color:red">' . $thresholdItems . '</b> item below threshold<br/>';
     $content .= '<b style="color:red">' . $countAllocated . '</b> item allocated<br/>';
     $content .= '<b style="color:red">' . $countUnAllocated . '</b> item unallocated<br/>';
     /* Items below threshold*/
     return $content;
 }