124 lines
3.9 KiB
PHP
Executable File
124 lines
3.9 KiB
PHP
Executable File
<?php
|
|
session_start();
|
|
include_once( '/var/www/html/e5crm/config.php');
|
|
mysql_connect($sugar_config['dbconfig']['db_host_name'],$sugar_config['dbconfig']['db_user_name'],$sugar_config['dbconfig']['db_password']);
|
|
mysql_select_db($sugar_config['dbconfig']['db_name']);
|
|
mysql_query("set names utf8");
|
|
include_once( '/var/www/html/e5crm/include/ECM/open_flash_chart/ofc-library/open-flash-chart.php' );
|
|
include_once('/var/www/html/e5crm/modules/EcmCharts/chartHelper.php');
|
|
|
|
$s=sum($_SESSION['EcmCharts_4_year']);
|
|
$temp=0;
|
|
|
|
$sh=$_SESSION['EcmCharts_4_show'];
|
|
$ye=$_SESSION['EcmCharts_4_year'];
|
|
$no=$_SESSION['EcmCharts_4_no'];
|
|
|
|
$w=mysql_query("select id,code,name from ecmproducts where deleted='0' and product_active='1'");
|
|
while($r=mysql_fetch_array($w)){
|
|
$ss=$s[$_SESSION['EcmCharts_4_year']];
|
|
if($sh=="sales"){
|
|
if($ss['product_sum_'.$r['id']]>$temp)$temp=$ss['product_sum_'.$r['id']];
|
|
if(!$ss['product_sum_'.$r['id']])$value=0;
|
|
else $value=$ss['product_sum_'.$r['id']];
|
|
$sum+=$value;
|
|
}
|
|
if($sh=="quantity"){
|
|
if($ss['product_qty_sum_'.$r['id']]>$temp)$temp=$ss['product_qty_sum_'.$r['id']];
|
|
if(!$ss['product_qty_sum_'.$r['id']])$value=0;
|
|
else $value=$ss['product_qty_sum_'.$r['id']];
|
|
$sum+=$value;
|
|
}
|
|
if($sh=="pln_margin"){
|
|
$pln_margin=$ss['product_sum_'.$r['id']]-$ss['product_pur_sum_'.$r['id']];
|
|
if($pln_margin>$temp)$temp=$pln_margin;
|
|
if(!$pln_margin)$value=0;
|
|
$value=$pln_margin;
|
|
$sum+=$value;
|
|
}
|
|
if($sh=="margin"){
|
|
if($ss['product_sum_'.$r['id']]>0)$margin=100*($ss['product_sum_'.$r['id']]-$ss['product_pur_sum_'.$r['id']])/$ss['product_sum_'.$r['id']];
|
|
else $margin=0;
|
|
if($margin>$temp)$temp=$margin;
|
|
if(!$margin)$value=0;
|
|
$value=$margin;
|
|
$sum+=$value;
|
|
}
|
|
$arr[]=array(
|
|
"name"=>$r['code'],
|
|
"name1"=>$r['name'],
|
|
"value"=>$value,
|
|
);
|
|
}
|
|
$arr=multisort($arr,array(array('key'=>'value','sort'=>'desc')));
|
|
$m=0;
|
|
foreach($arr as $a){
|
|
$m++;
|
|
if($m>$_SESSION['EcmCharts_4_no'])continue;
|
|
$data[]=$a['value'];
|
|
$products[]=repl($a['name']);
|
|
$names[]=repl($a['name1']);
|
|
}
|
|
// tworzymy nowy objekt
|
|
$g = new graph();
|
|
|
|
//Tytul wykresu
|
|
|
|
$g->title( 'Top Products', '{font-size:20px; color: #000000; margin: 5px; background-color: #ffffff; padding:5px; padding-left: 20px; padding-right: 20px;}' );
|
|
|
|
//kolor tla
|
|
$g->bg_colour = '#ffffff';
|
|
|
|
//if($_SESSION['EcmCharts_4_no']==10){
|
|
if($sh=="sales")$data_1 = new bar( 75, '#D54C78', '', 10 );
|
|
if($sh=="quantity")$data_1 = new bar( 75, '#333333', '', 10 );
|
|
if($sh=="pln_margin")$data_1 = new bar( 75, '#3334AD', '', 10 );
|
|
if($sh=="margin")$data_1 = new bar( 75, '#00CC00', '', 10 );
|
|
//$data_2 = new line( 2, '#ffffff');
|
|
$data_1->key( '', 10 );
|
|
//$data_2->key( '', 10 );
|
|
for($i=0;$i<count($data);$i++){
|
|
$data_1->add_data_tip( $data[$i], $names[$i] );
|
|
//$data_2->add_data_tip( $data[$i], '<img src="custom/themes/Sugar/images/company_logo.png">' );
|
|
}
|
|
$g->data_sets[]=$data_1;
|
|
//$g->data_sets[]=$data_2;
|
|
$g->set_tool_tip( '#x_label#<br>#tip#<br>#val#<br>' );
|
|
/*}
|
|
else{
|
|
$g->set_data( $data );
|
|
if($sh=="sales")$g->bar_3D( 75, '#D54C78', '', 10 );
|
|
if($sh=="quantity")$g->bar_3D( 75, '#333333', '', 10 );
|
|
if($sh=="pln_margin")$g->bar_3D( 75, '#3334AD', '', 10 );
|
|
if($sh=="margin")$g->bar_3D( 75, '#00CC00', '', 10 );
|
|
}*/
|
|
/*$as=$sum/$no;
|
|
$li=array();
|
|
for($i=0;$i<$no;$i++)$li[]=$as;
|
|
$g->set_data($li);
|
|
$g->line( 2,'0x9933CC', '', 18 );
|
|
*/
|
|
//wysokosc spodu
|
|
//$g->set_x_axis_3d(12);
|
|
|
|
//kolor lini wewnetrzynych i tla
|
|
$g->x_axis_colour( '#909090', '#ADB5C7' );
|
|
$g->y_axis_colour( '#909090', '#ADB5C7' );
|
|
|
|
//wartosci osi X
|
|
$g->set_x_labels( $products );
|
|
//styl osi x,: rozmiar tekstu, kolor, kad nacylenia 2- 45 stopni
|
|
$g->set_x_label_style( 10, '#000000', 2 );
|
|
|
|
//maksymalna wartosc dla osi Y
|
|
$g->set_y_max( round($temp,-3) );
|
|
|
|
//na ile czesci podzielic os Y
|
|
$g->y_label_steps( 20 );
|
|
|
|
//legenda osi Y
|
|
$g->set_y_legend( '', 12, '#736AFF' );
|
|
//$g->area_hollow( 2, 3, 25, '#C11B01', 'Squared', 12, '#8E560F' );
|
|
echo $g->render();
|
|
mysql_close($sql);
|
|
?>
|