load->model('catalog/product'); $this->load->model('tool/image'); $this->load->model('catalog/manufacturer'); $product_info = $this->model_catalog_product->getProduct($product_id); if(empty($product_info))exit('not found!'); $product_info['url'] = $this->url->link('product/product', '&product_id=' . $product_id); $product_info['description'] = html_entity_decode($product_info['description'], ENT_QUOTES, 'UTF-8'); $product_info['attribute_groups'] = $this->model_catalog_product->getProductAttributes($product_id); $product_info['kol'] = $kol; if ($this->customer->isLogged() || !$this->config->get('config_customer_price')) { $product_info['price'] = $this->currency->format($this->tax->calculate($product_info['price'], $product_info['tax_class_id'], $this->config->get('config_tax')), $this->session->data['currency']); $product_info['total'] = $this->currency->format($this->tax->calculate($kol* (int) str_replace(' ', '', $product_info['price']), 1, $this->config->get('config_tax')), $this->session->data['currency']); if( $fix_price != null ) { $product_info['price'] = $this->currency->format($this->tax->calculate($fix_price, $product_info['tax_class_id'], $this->config->get('config_tax')), $this->session->data['currency']); } if( $fix_price != null ) { $product_info['total'] = $this->currency->format($this->tax->calculate($fix_total, $product_info['tax_class_id'], $this->config->get('config_tax')), $this->session->data['currency']); } } else { $product_info['price'] = false; } if ((float)$product_info['special']) { $product_info['special'] = $this->currency->format($this->tax->calculate($product_info['special'], $product_info['tax_class_id'], $this->config->get('config_tax')), $this->session->data['currency']); } else { $product_info['special'] = false; } if ($this->config->get('config_tax')) { $product_info['tax'] = $this->currency->format((float)$product_info['special'] ? $product_info['special'] : $product_info['price'], $this->session->data['currency']); } else { $product_info['tax'] = false; } $discounts = $this->model_catalog_product->getProductDiscounts($product_id); $product_info['discounts'] = array(); foreach ($discounts as $discount) { $product_info['discounts'][] = array( 'quantity' => $discount['quantity'], 'price' => $this->currency->format($this->tax->calculate($discount['price'], $product_info['tax_class_id'], $this->config->get('config_tax')), $this->session->data['currency']) ); } $product_info['thumb'] = $this->model_tool_image->resize($product_info['image'], 450, 450); if ($product_info['image']) { $product_info['thumb'] = $this->model_tool_image->resize($product_info['image'], 450, 450); } else { $product_info['thumb'] = ''; } $images = $this->model_catalog_product->getProductImages($product_id); $w = 250; foreach ($images as $result) { $product_info['images'][] = $this->model_tool_image->resize($result['image'],$w,$w); } if(count($images) > 2) $product_info['images'] = array_slice( $product_info['images'] , 0, 2); return $this->load->view('/kom/ru_view_kp', $product_info); //return "

32424

"; } public function mono_tableEXCEL($product_id, $quantity, $price, $total) { $this->load->model('catalog/product'); $this->load->model('tool/image'); $this->load->model('catalog/manufacturer'); $product_info = $this->model_catalog_product->getProduct($product_id); if(!empty($product_info)) { $product_info['url'] = $this->url->link('product/product', '&product_id=' . $product_id); $product_info['thumb'] = $this->model_tool_image->resize($product_info['image'], 140, 140); $product_info['thumb'] = str_replace('/webp', '', $product_info['thumb']); $product_info['thumb'] = str_replace('.webp', '.jpg', $product_info['thumb']); $is_jpg = file_get_contents($product_info['thumb']); if(empty($is_jpg)) { $product_info['thumb'] = str_replace('.jpg', '.png', $product_info['thumb']); } $url = $this->url->link('product/product', '&product_id=' . $product_id); return [ 'thumb' => $product_info['image'], 'model' => $product_info['model'], 'name' => $product_info['name'], 'url' => $url, 'quantity' => $quantity, 'total' => round($total,0), 'price' => round($price,0) ]; } return $table; } public function mono_table($product_id, $quantity, $price, $total) { $table = ""; $this->load->model('catalog/product'); $this->load->model('tool/image'); $this->load->model('catalog/manufacturer'); $product_info = $this->model_catalog_product->getProduct($product_id); if(!empty($product_info)) { $product_info['url'] = $this->url->link('product/product', '&product_id=' . $product_id); $product_info['thumb'] = $this->model_tool_image->resize($product_info['image'], 140, 140); $product_info['thumb'] = str_replace('/webp', '', $product_info['thumb']); $product_info['thumb'] = str_replace('.webp', '.jpg', $product_info['thumb']); $is_jpg = file_get_contents($product_info['thumb']); if(empty($is_jpg)) { $product_info['thumb'] = str_replace('.jpg', '.png', $product_info['thumb']); } $url = $this->url->link('product/product', '&product_id=' . $product_id); $table .= ' '. $product_info['model'].' '. $product_info['name'].' '.$quantity.' '.round($price,0).' '.round($total,0).' '.$html.''; } return $table; } public function OrderCP() { $this->load->model('checkout/order'); $id_order = (int)$_GET['order_id']; $data = $this->model_checkout_order->getOrder($id_order); $products = $this->db->query("SELECT * FROM " . DB_PREFIX . "order_product WHERE order_id = '" . (int)$id_order . "'")->rows; $html = ""; $full_totol = 0; foreach ($products as $key => $prd) { $html .= $this->mono_table($prd['product_id'], $prd['quantity'], $prd['price'], $prd['total']); $full_totol += $prd['total']; } $this->Smpdf(''.$html.'
Фото Код товара Название Кол. Цена Сумма
Итого: '.$full_totol.'
', $id_order); } public function CartCP() { $listing = $this->cart->getProducts(); $html = ""; $htmlS = ""; foreach ($listing as $key => $prd) { $html .= $this->mono_table($prd['product_id'], $prd['quantity'], $prd['price'], $prd['total']); $htmlS .= $this->print_mono($prd['product_id'], $prd['quantity'], $prd['price'], $prd['total']); } $render_table = ''.$html.'
Фото Код товара Название Кол. Цена Сумма
Итого: '.$this->currency->format($this->tax->calculate($this->cart->getTotal(), 1, $this->config->get('config_tax')), $this->session->data['currency']).'
'; if($_GET['formaat'] == "PDF") $this->Smpdf( $htmlS .'

Комерческое предложение

№ '.rand(99,999).' от '.date('d.m.Y').'

'.$render_table.'

Цена указана без учета доставки

'); if($_GET['formaat'] == "EXEL")$this->SmpdfEXEL( $render_table); } public function cp() { if(!empty($this->request->get['pr_id'])) { $product_id = (int) $this->request->get['pr_id']; $html = $this->print_mono($product_id); $this->Smpdf($html, rand(100,999)); } else exit('not product!'); } public function SmpdfEXEL($html, $num = null) { require_once DIR_SYSTEM . '/library/KOM-EXCEL/PHPExcel.php'; require_once DIR_SYSTEM . '/library/KOM-EXCEL/PHPExcel/Writer/Excel2007.php'; $xls = new PHPExcel(); $xls->getProperties()->setTitle("".$_SERVER['HTTP_HOST']); $xls->getProperties()->setSubject("КП"); $xls->getProperties()->setCreator("".$_SERVER['HTTP_HOST']); $xls->getProperties()->setManager("".$_SERVER['HTTP_HOST']); $xls->getProperties()->setCompany("".$_SERVER['HTTP_HOST']); $xls->getProperties()->setCategory("".$_SERVER['HTTP_HOST']); $xls->getProperties()->setKeywords("".$_SERVER['HTTP_HOST']); $xls->getProperties()->setDescription("".$_SERVER['HTTP_HOST']); $xls->getProperties()->setLastModifiedBy("".$_SERVER['HTTP_HOST']); $xls->getProperties()->setCreated(date("d.m.Y")); $sheet = $xls->getActiveSheet(); $sheet->setTitle('КП'); $objDrawing = new PHPExcel_Worksheet_Drawing(); $objDrawing->setResizeProportional(false); $objDrawing->setName("".$_SERVER['HTTP_HOST']); $objDrawing->setDescription("".$_SERVER['HTTP_HOST']); $objDrawing->setPath(DIR_IMAGE.''.$this->config->get('config_logo')); $objDrawing->setCoordinates('B2'); $objDrawing->setOffsetX(10); $objDrawing->setOffsetY(10); $objDrawing->setWidth(170); $objDrawing->setHeight(70); $objDrawing->setWorksheet($sheet); $style_border = array( 'font' => array( 'name' => 'Times New Roman', 'size' => 14, 'color' => array('rgb' => '666666'), ) ); $sheet->getStyle("E2:E4")->applyFromArray($style_border); $style_border = array( 'font' => array( 'name' => 'Times New Roman', 'size' => 16, 'color' => array('rgb' => 'ff7700'), 'bold' => true, ) ); $sheet->getStyle("F2:F4")->applyFromArray($style_border); $sheet->setCellValue("F2", "".$_SERVER['HTTP_HOST']); $sheet->setCellValue("F3", "".$this->config->get('config_email')); $sheet->setCellValue("F4", "".$this->config->get('config_telephone')); $sheet->setCellValue("E2", "Сайт:"); $sheet->setCellValue("E3", "Email:"); $sheet->setCellValue("E4", "Телефон:"); $sheet->mergeCells("B6:G6"); $sheet->mergeCells("B7:G7"); $style_border = array( 'font' => array( 'name' => 'Times New Roman', 'size' => 18, 'color' => array('rgb' => '666666'), 'bold' => true, ) ); $sheet->getStyle("B6")->applyFromArray($style_border); $sheet->setCellValue("B6", "Коммерческое предложение"); $style_border = array( 'font' => array( 'name' => 'Times New Roman', 'size' => 14, 'color' => array('rgb' => '666666'), 'bold' => true, ) ); $sheet->getStyle("B7")->applyFromArray($style_border); $sheet->setCellValue("B7", "№ ".rand(99,1500)." от ".date('d.m.Y')); $sheet->getStyle("B6")->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER); $sheet->getStyle("B6")->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER); $sheet->getStyle("B7")->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER); $sheet->getStyle("B7")->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER); $border = array( 'borders'=>array( 'allborders' => array( 'style' => PHPExcel_Style_Border::BORDER_THIN, 'color' => array('rgb' => '000000') ) ) ); $listing = $this->cart->getProducts(); $style_border = array( 'font' => array( 'name' => 'Times New Roman', 'size' => 14, 'color' => array('rgb' => '666666'), 'bold' => true, ) ); $sheet->setCellValue("B9", "Фото"); $sheet->getStyle("B9")->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER); $sheet->getStyle("B9")->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER); $sheet->setCellValue("C9", "Код товара"); $sheet->getStyle("C9")->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER); $sheet->getStyle("C9")->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER); $sheet->setCellValue("D9", "Название "); $sheet->getStyle("D9")->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER); $sheet->getStyle("D9")->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER); $sheet->setCellValue("E9", "Кол."); $sheet->getStyle("E9")->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER); $sheet->getStyle("E9")->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER); $sheet->setCellValue("F9", "Цена"); $sheet->getStyle("F9")->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER); $sheet->getStyle("F9")->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER); $sheet->setCellValue("G9", "Сумма"); $sheet->getStyle("G9")->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER); $sheet->getStyle("G9")->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER); $sheet->getStyle("B9:G9")->applyFromArray($border); $sheet->getColumnDimension('D')->setWidth(50); $sheet->getStyle('B9')->applyFromArray($style_border); $sheet->getStyle('C9')->applyFromArray($style_border); $sheet->getStyle('D9')->applyFromArray($style_border); $sheet->getStyle('E9')->applyFromArray($style_border); $sheet->getStyle('F9')->applyFromArray($style_border); $sheet->getStyle('G9')->applyFromArray($style_border); $full_totol = 0; foreach ($listing as $key => $prd) { /* 'thumb' => $product_info['image'], 'model' => $product_info['model'], 'name' => $product_info['name'], 'url' => $url, 'quantity' => $quantity, 'total' => round($total,0), 'price' => round($price,0) */ $l = $key +10; $i = $this->mono_tableEXCEL($prd['product_id'], $prd['quantity'], $prd['price'], $prd['total']); $objDrawing = new PHPExcel_Worksheet_Drawing(); $objDrawing->setResizeProportional(false); $objDrawing->setName('Название картинки'); $objDrawing->setDescription('Описание картинки'); $objDrawing->setPath(DIR_IMAGE . $i['thumb']); $objDrawing->setCoordinates('B'.$l); $objDrawing->setOffsetX(10); $objDrawing->setOffsetY(10); $objDrawing->setWidth(163); $objDrawing->setHeight(160); $objDrawing->setWorksheet($sheet); $sheet->getColumnDimension('B')->setWidth(28); $sheet->getRowDimension( $l)->setRowHeight(140); $sheet->setCellValue("C".$l, $i['model']); $sheet->getColumnDimension('C')->setWidth(15); $sheet->getStyle("C".$l)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER); $sheet->getStyle("C".$l)->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER); $sheet->setCellValue("D".$l, $i['name']); $sheet->getStyle("D".$l)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER); $sheet->getStyle("D".$l)->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER); $sheet->getCell("D".$l)->getHyperlink()->setUrl($i['url']); $sheet->getCell("D".$l)->getHyperlink()->setTooltip('Открыть товар на сайте'); // У текста нужно сделать синий цвет и подчеркивание $sheet->getStyle("D".$l)->applyFromArray( array( 'font' => array( 'color' => array( 'rgb' => '0000FF' ), 'underline' => 'single' ) ) ); $sheet->getStyle("D".$l)->getAlignment()->setWrapText(true); $sheet->setCellValue("E".$l, $i['quantity']); $sheet->getStyle("E".$l)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER); $sheet->getStyle("E".$l)->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER); $sheet->setCellValue("F".$l, $i['price']); $sheet->getStyle("F".$l)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER); $sheet->getStyle("F".$l)->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER); $sheet->setCellValue("G".$l, $i['total']); $sheet->getStyle("G".$l)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER); $sheet->getStyle("G".$l)->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER); $full_totol += $i['total']; $sheet->getStyle("B".$l.":G".$l."")->applyFromArray($border); } $sheet->setCellValue("E".($l+1), 'Итого: '.$full_totol.' грн.'); $style_border = array( 'font' => array( 'name' => 'Times New Roman', 'size' => 16, 'color' => array('rgb' => 'ff7700'), 'bold' => true, ) ); $sheet->getStyle("E".($l+1))->applyFromArray($style_border); $sheet->setCellValue("E".($l+2), "Цена без учета доставки"); $style_border = array( 'font' => array( 'name' => 'Times New Roman', 'size' => 9, 'color' => array('rgb' => '666666'), ) ); $sheet->getStyle("E".($l+2))->applyFromArray($style_border); header("Expires: Mon, 1 Apr 1974 05:00:00 GMT"); header("Last-Modified: " . gmdate("D,d M YH:i:s") . " GMT"); header("Cache-Control: no-cache, must-revalidate"); header("Pragma: no-cache"); header("Content-type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"); header("Content-Disposition: attachment; filename=file.xlsx"); $objWriter = new PHPExcel_Writer_Excel2007($xls); $objWriter->save('php://output'); exit(); exit(); header('Content-Type: application/vnd.ms-excel; charset=utf-8'); header("Content-Disposition: attachment;filename=".date("d.m.Y").rand(2,100000)."-export.xls"); header("Content-Transfer-Encoding: binary "); echo $data = ' '; } public function Smpdf( $html, $num = null) { if ($num == null) $num = rand(100,999); require_once DIR_SYSTEM . '/library/mpdf2/vendor/autoload.php'; $this->load->model('tool/image'); $headerHTML = '
'.$this->config->get('config_langdata')[1]['open'].'
Сайт:
Email:
Телефон:
'.$_SERVER['HTTP_HOST'].'
'.$this->config->get('config_email').'
'.$this->config->get('config_telephone').'

'; $config = [ 'mode' => 'fullwidth', 'format' => 'A4', 'default_font_size' => 7, 'default_font' => 'Helvetica', 'margin_left' => 15, 'margin_right' => 15, 'margin_top' => 45, 'margin_bottom' => 16, 'margin_header' => 9, 'margin_footer' => 9, 'orientation' => 'P' ]; $mpdf = new \Mpdf\Mpdf($config); $mpdf->use_kwt = true; $mpdf->setFooter('Страница {PAGENO} из {nbpg}'); $mpdf->SetHTMLHeader($headerHTML); $mpdf->WriteHTML($html); $mpdf->Output(time().'kp.pdf', 'D'); } } ?>