134 lines
4.5 KiB
PHP
Executable File
134 lines
4.5 KiB
PHP
Executable File
<?php
|
|
include_once("modules/EcmProductReports/vtigerConnector.php");
|
|
include_once('modules/EcmCharts/chartHelper.php');
|
|
|
|
$vc=new vtigerConnector();
|
|
$vc->start=1;
|
|
$wc[]="1=1";
|
|
$wc[]="purchaseordercf.cf_528='0'";
|
|
$wc[]="purchaseorder.tracking_no!=''";
|
|
$vc->order_by="purchaseordercf.cf_532";
|
|
$vc->sorder="asc";
|
|
$vc->where=@implode(" and ",$wc);
|
|
$vc->getData();
|
|
$cnt=$vc->getCount();
|
|
$data=$vc->data;
|
|
|
|
if(count($data)>0){
|
|
foreach($data as $d){
|
|
if(in_array(trim($d['tracking_no']),$_REQUEST['check'])){
|
|
$r=mysql_fetch_array(mysql_query("select product_category_name from ecmproducts where code like '".$d['productcode']."' and deleted='0'"));
|
|
$d['category']=$r['product_category_name'];
|
|
$dd[]=$d;
|
|
}
|
|
}
|
|
}
|
|
$dd=multisort($dd,array(array('key'=>"deliverydate",'sort'=>"asc"),array('key'=>"tracking_no",'sort'=>"asc"),array('key'=>"category",'sort'=>"asc"),array('key'=>"productcode",'sort'=>"asc")));
|
|
$data=$dd;
|
|
|
|
|
|
set_include_path('include/PHPExcel/');
|
|
|
|
include 'PHPExcel.php';
|
|
include 'PHPExcel/Writer/Excel2007.php';
|
|
include 'PHPExcel/IOFactory.php';
|
|
|
|
$objPHPExcel = new PHPExcel();
|
|
$objPHPExcel->getProperties()->setCreator("E5 CRM");
|
|
$objPHPExcel->getProperties()->setLastModifiedBy("E5 CRM");
|
|
$objPHPExcel->getProperties()->setTitle("Office 2007 PRICEBOOK");
|
|
$objPHPExcel->getProperties()->setSubject("Office 2007 PRICEBOOK");
|
|
$objPHPExcel->getProperties()->setDescription("PRICEBOOK");
|
|
|
|
$objPHPExcel->getActiveSheet()->duplicateStyleArray(
|
|
array(
|
|
'fill' => array(
|
|
'type' => PHPExcel_Style_Fill::FILL_SOLID,
|
|
'color' => array('argb' => 'FFCCFFCC')
|
|
),
|
|
'borders' => array(
|
|
'bottom' => array('style' => PHPExcel_Style_Border::BORDER_THIN),
|
|
'right' => array('style' => PHPExcel_Style_Border::BORDER_MEDIUM)
|
|
)
|
|
),
|
|
"A1:E1"
|
|
);
|
|
|
|
$alf="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
|
|
|
$objPHPExcel->getActiveSheet()->getColumnDimension('A')->setWidth(20);
|
|
$objPHPExcel->getActiveSheet()->getColumnDimension('B')->setWidth(20);
|
|
$objPHPExcel->getActiveSheet()->getColumnDimension('C')->setWidth(20);
|
|
$objPHPExcel->getActiveSheet()->getColumnDimension('D')->setWidth(20);
|
|
$objPHPExcel->getActiveSheet()->getColumnDimension('E')->setWidth(20);
|
|
|
|
|
|
$objPHPExcel->getActiveSheet()->SetCellValue('A1','Index');
|
|
$objPHPExcel->getActiveSheet()->SetCellValue('B1','Name');
|
|
$objPHPExcel->getActiveSheet()->SetCellValue('C1','Quantity');
|
|
$objPHPExcel->getActiveSheet()->SetCellValue('D1','Cartons');
|
|
$objPHPExcel->getActiveSheet()->SetCellValue('E1','CBM');
|
|
|
|
$j=0;
|
|
for($i=0;$i<count($data);$i++){
|
|
if($pom!=$data[$i]['tracking_no']){
|
|
$objPHPExcel->getActiveSheet()->SetCellValue('A'.($j+2),$data[$i]['tracking_no']." ".$GLOBALS['timedate']->to_display_date($data[$i]['deliverydate']));
|
|
$arr_y[]=$j+2;
|
|
$j++;
|
|
}
|
|
$pom=$data[$i]['tracking_no'];
|
|
$id=$vc->getIdByCode($data[$i]['productcode']);
|
|
$r=mysql_fetch_array(mysql_query("select pieces_per_carton as ppc,carton_volume_meter as cvm from ecmproducts where id='".$id."'"));
|
|
@$cartons=$data[$i]['quantity']/$r['ppc'];
|
|
@$cbm=$data[$i]['quantity']*$r['cvm']/$r['ppc'];
|
|
$qty_sum+=$data[$i]['quantity'];
|
|
$cartons_sum+=$cartons;
|
|
$cbm_sum+=$cbm;
|
|
|
|
$objPHPExcel->getActiveSheet()->SetCellValue('A'.($j+2),$data[$i]['productcode']);
|
|
$objPHPExcel->getActiveSheet()->SetCellValue('B'.($j+2),$data[$i]['productname']);
|
|
$objPHPExcel->getActiveSheet()->SetCellValue('C'.($j+2),$data[$i]['quantity']);
|
|
$objPHPExcel->getActiveSheet()->SetCellValue('D'.($j+2),$cartons);
|
|
$objPHPExcel->getActiveSheet()->SetCellValue('E'.($j+2),$cbm);
|
|
|
|
$j++;
|
|
}
|
|
foreach($arr_y as $ay){
|
|
$objPHPExcel->getActiveSheet()->duplicateStyleArray(
|
|
array(
|
|
'fill' => array(
|
|
'type' => PHPExcel_Style_Fill::FILL_SOLID,
|
|
'color' => array('argb' => 'FFFF33')
|
|
),
|
|
),
|
|
"A".$ay.":E".$ay
|
|
);
|
|
}
|
|
$objPHPExcel->getActiveSheet()->duplicateStyleArray(
|
|
array(
|
|
'fill' => array(
|
|
'type' => PHPExcel_Style_Fill::FILL_SOLID,
|
|
'color' => array('argb' => 'E6E6E6')
|
|
),
|
|
),
|
|
"A".($j+2).":E".($j+2)
|
|
);
|
|
|
|
$cnt=count($data);
|
|
|
|
$objPHPExcel->getActiveSheet()->SetCellValue('C'.($j+2),number_format($qty_sum,0,"",""));
|
|
$objPHPExcel->getActiveSheet()->SetCellValue('D'.($j+2),number_format($cartons_sum,0,"",""));
|
|
$objPHPExcel->getActiveSheet()->SetCellValue('E'.($j+2),number_format($cbm_sum,0,"",""));
|
|
|
|
$objPHPExcel->getActiveSheet()->setTitle('Simple');
|
|
$objPHPExcel->setActiveSheetIndex(0);
|
|
|
|
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
|
|
chmod("cache/upload",0777);
|
|
$microtime=str_replace(".","",str_replace(" ","",microtime()));
|
|
$name="cache/upload/Containers".$microtime.".xlsx";
|
|
$objWriter->save($name);
|
|
chmod($name,0777);
|
|
|
|
header("Location: ".$name);
|
|
?>
|