62 lines
2.3 KiB
PHP
Executable File
62 lines
2.3 KiB
PHP
Executable File
<?php
|
|
set_time_limit(99999);
|
|
error_reporting(0);
|
|
include_once("include/pChart/pChart/pData.class");
|
|
include_once("include/pChart/pChart/pChart.class");
|
|
include_once('modules/EcmCharts/helperChart.php');
|
|
|
|
$year=$_REQUEST['year'];
|
|
$category=$_REQUEST['category'];
|
|
if(count($category)==0)$category=array("cat");
|
|
$account=$_REQUEST['account'];
|
|
$sh=$_REQUEST['show'];
|
|
$ar=array();
|
|
foreach($category as $cat){
|
|
if(in_array("margin",$sh))$ar[]=generateImgChart($cat,$year,$account,array("margin"));
|
|
foreach($sh as $ssh){
|
|
if($ssh!="margin")$shh[]=$ssh;
|
|
}
|
|
$ar[]=generateImgChart($cat,$year,$account,$shh);
|
|
$ars[]=getSalesByProduct1($cat,$year."-01-01",$year."-12-31","",$account);
|
|
}
|
|
|
|
include_once("include/html2fpdf/html2fpdf.php");
|
|
$p=new HTML2FPDF();
|
|
$p->SetLeftMargin(10);
|
|
$p->SetRightMargin(10);
|
|
$p->SetTopMargin(10);
|
|
$p->SetAutoPageBreak(true,10);
|
|
$p->AddPage();
|
|
$p->SetFont('arialpl','B',16);
|
|
$x=0;
|
|
$y=0;
|
|
for($i=0;$i<count($ar);$i++){
|
|
$p->Image('modules/EcmCharts/files/'.$ar[$i].'.png',$x,$y,190);$p->Ln();
|
|
$p->SetFont('arialpl','B',8);
|
|
$p->Cell(25,4,"Index",0,0,"L",1);
|
|
$p->Cell(75,4,"Name",0,0,"L",1);
|
|
$p->Cell(20,4,"Sales",0,0,"L",1);
|
|
$p->Cell(15,4,"Quantity",0,0,"L",1);
|
|
$p->Cell(20,4,"Margin PLN",0,0,"L",1);
|
|
$p->Cell(15,4,"Margin %",0,0,"L",1);
|
|
//$p->Cell(20,4,"Price",0,0,"L",1);
|
|
$p->Ln();
|
|
$ars[$i]=multisort($ars[$i],array(array('key'=>'sales','sort'=>'desc')));
|
|
foreach($ars[$i] as $k=>$s){
|
|
$r=mysql_fetch_array(mysql_query("select code,name from ecmproducts where id='".$k."'"));
|
|
$rp=mysql_fetch_array(mysql_query("select i.price from ecmpricebooks_ecmproducts as i inner join ecmpricebooks as e on e.id=i.ecmpricebook_id where where i.ecmproduct_id='".$k."' and e.account_id='".$account."' and e.name='Carrefour' and deleted='0'"));
|
|
$p->SetFont('arialpl','',8);
|
|
$p->Cell(25,4,$r['code'],0,0,"L",1);
|
|
$p->Cell(75,4,iconv("UTF-8","ISO-8859-2",$r['name']),0,0,"L",1);
|
|
$p->Cell(20,4,number_format($s['sales'],2,",","."),0,0,"L",1);
|
|
$p->Cell(15,4,number_format($s['quantity'],0,",","."),0,0,"L",1);
|
|
$p->Cell(20,4,number_format(($s['sales']-$s['purchase']),2,",","."),0,0,"L",1);
|
|
$p->Cell(15,4,number_format((100*($s['sales']-$s['purchase'])/$s['sales']),2,",",".")."%",0,0,"L",1);
|
|
//$p->Cell(20,4,$rp['price'],0,0,"L",1);
|
|
$p->Ln();
|
|
}
|
|
$x=$p->GetX();
|
|
$y=$p->GetY();
|
|
}
|
|
$p->Output("Chart.pdf","I");
|
|
?>
|