Add php files
This commit is contained in:
46
modules/Home/Dashlets/MyEcmReportDashlets/MyEcmReportDashlets.en_us.lang.php
Executable file
46
modules/Home/Dashlets/MyEcmReportDashlets/MyEcmReportDashlets.en_us.lang.php
Executable file
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
|
||||
/**
|
||||
* SugarCRM is a customer relationship management program developed by
|
||||
* SugarCRM, Inc. Copyright (C) 2004 - 2007 SugarCRM Inc.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License version 3 as published by the
|
||||
* Free Software Foundation with the addition of the following permission added
|
||||
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
|
||||
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
|
||||
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program; if not, see http://www.gnu.org/licenses or write to the Free
|
||||
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
* 02110-1301 USA.
|
||||
*
|
||||
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
|
||||
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of this program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU General Public License version 3.
|
||||
*
|
||||
* In accordance with Section 7(b) of the GNU General Public License version 3,
|
||||
* these Appropriate Legal Notices must retain the display of the "Powered by
|
||||
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
|
||||
* technical reasons, the Appropriate Legal Notices must display the words
|
||||
* "Powered by SugarCRM".
|
||||
*/
|
||||
|
||||
$dashletStrings['MyEcmReportDashlets'] = array('LBL_TITLE' => 'Reports summary',
|
||||
'LBL_DESCRIPTION' => 'A reports summary dashlet',
|
||||
'LBL_SAVING' => 'Saving calls summary ...',
|
||||
'LBL_SAVED' => 'Saved',
|
||||
'LBL_CONFIGURE_TITLE' => 'Title',
|
||||
'LBL_CONFIGURE_SAVE' => 'Save',
|
||||
'LBL_DEFAULT_TEXT' => '',
|
||||
);
|
||||
?>
|
||||
46
modules/Home/Dashlets/MyEcmReportDashlets/MyEcmReportDashlets.meta.php
Executable file
46
modules/Home/Dashlets/MyEcmReportDashlets/MyEcmReportDashlets.meta.php
Executable file
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
|
||||
/**
|
||||
* SugarCRM is a customer relationship management program developed by
|
||||
* SugarCRM, Inc. Copyright (C) 2004 - 2007 SugarCRM Inc.
|
||||
*
|
||||
* This program is fre e software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License version 3 as published by the
|
||||
* Free Software Foundation with the addition of the following permission added
|
||||
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
|
||||
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
|
||||
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program; if not, see http://www.gnu.org/licenses or write to the Free
|
||||
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
* 02110-1301 USA.
|
||||
*
|
||||
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
|
||||
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of this program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU General Public License version 3.
|
||||
*
|
||||
* In accordance with Section 7(b) of the GNU General Public License version 3,
|
||||
* these Appropriate Legal Notices must retain the display of the "Powered by
|
||||
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
|
||||
* technical reasons, the Appropriate Legal Notices must display the words
|
||||
* "Powered by SugarCRM".
|
||||
*/
|
||||
|
||||
|
||||
|
||||
global $app_strings, $current_language;
|
||||
|
||||
$dashletMeta['MyEcmReportDashlets'] = array('title' => 'LBL_TITLE', // array index in language pack
|
||||
'description' => 'LBL_DESCRIPTION', // array index in language pack
|
||||
'icon' => 'themes/default/images/EcmReport.gif',
|
||||
'category' => 'Tools');
|
||||
?>
|
||||
1041
modules/Home/Dashlets/MyEcmReportDashlets/MyEcmReportDashlets.php
Executable file
1041
modules/Home/Dashlets/MyEcmReportDashlets/MyEcmReportDashlets.php
Executable file
File diff suppressed because it is too large
Load Diff
154
modules/Home/Dashlets/MyEcmReportDashlets/salesChart.php
Executable file
154
modules/Home/Dashlets/MyEcmReportDashlets/salesChart.php
Executable file
@@ -0,0 +1,154 @@
|
||||
<?php
|
||||
if(!defined('sugarEntry'))define('sugarEntry', true);
|
||||
$startTime = microtime(true);
|
||||
|
||||
require_once('/var/www/html/e5crm/include/entryPoint.php');
|
||||
ob_start();
|
||||
require_once("/var/www/html/e5crm/config.php");
|
||||
require_once('/var/www/html/e5crm/include/MVC/SugarApplication.php');
|
||||
$mm = new MysqlManager();
|
||||
$mm->connect();
|
||||
/*$app = new SugarApplication();
|
||||
$app->startSession();
|
||||
$app->execute();
|
||||
*/
|
||||
include_once( '/var/www/html/e5crm/include/ECM/open_flash_chart/ofc-library/open-flash-chart.php' );
|
||||
include_once("/var/www/html/e5crm/modules/EcmReports/cache.php");
|
||||
include_once("/var/www/html/e5crm/modules/EcmReports/class.sales.php");
|
||||
|
||||
|
||||
$mmm=(int)date("m")-1;
|
||||
if($mmm==0)$mmm=12;
|
||||
|
||||
$year_month=$_SESSION['EcmReports_Dashlet_sales'];
|
||||
$e=explode("-",$_SESSION['EcmReports_Dashlet_sales']);
|
||||
$year=$e[0];
|
||||
$month=$e[1];
|
||||
|
||||
$s=new Sales();
|
||||
$s->date_from=$year."-".$month."-01";
|
||||
$s->date_to=$year."-".$month."-31";
|
||||
$sdata=$s->getSalesByCategory();
|
||||
|
||||
$pred=new Sales();
|
||||
$pred->date_from=$year."-01-01";
|
||||
$pred->date_to=$year."-12-31";
|
||||
$pred=$pred->getSalesByCategory();
|
||||
|
||||
function repl($t){
|
||||
$a1=array("ą","ś","ę","ż","ź","ć","ń","ó","ł","Ą","Ś","Ę","Ż","Ź","Ć","Ń","Ó","Ł");
|
||||
$a2=array("a","s","e","z","z","c","n","o","l","A","S","E","Z","Z","C","N","O","L");
|
||||
return str_replace($a1,$a2,$t);
|
||||
}
|
||||
function salesPercent($category_id,$date){
|
||||
$w=$GLOBALS['db']->query("select value_wz as swz,value_sale as ssale from ecmproductcategories_realisation where product_category_id='".$category_id."' and date='".$date."'");
|
||||
$r=$GLOBALS['db']->fetchByAssoc($w);
|
||||
return @100*$r['swz']/$r['ssale'];
|
||||
}
|
||||
|
||||
$year_month=$_SESSION['EcmReports_Dashlet_sales'];
|
||||
$e=explode("-",$_SESSION['EcmReports_Dashlet_sales']);
|
||||
$year=$e[0];
|
||||
$month=$e[1];
|
||||
|
||||
$s=sum($year_month,"","","","");
|
||||
$sy=sum($year,"","","","");
|
||||
|
||||
$w=$GLOBALS['db']->query("select id,name from ecmproductcategories where deleted='0' and name!='' order by name asc");
|
||||
while($r=$GLOBALS['db']->fetchByAssoc($w)){
|
||||
$ss=$sdata[$month][$r['id']];
|
||||
$pp=$pred[$month][$r['id']];
|
||||
|
||||
$v_s=$ss['sales'];
|
||||
if($v_s>$temp)$temp=$v_s;
|
||||
$sum_s+=$v_s;
|
||||
|
||||
$v_p=$ss['purchase'];
|
||||
if($v_p>$temp)$temp=$v_p;
|
||||
$sum_p+=$v_p;
|
||||
|
||||
$v_l=$pp['sales']/$mmm;
|
||||
if($v_l>$temp)$temp=$v_l;
|
||||
$sum_l+=$v_l;
|
||||
|
||||
$v_r=salesPercent($r['id'],$year_month);
|
||||
|
||||
$arr_s[]=array(
|
||||
"name"=>repl($r['name']),
|
||||
"value"=>$v_s,
|
||||
);
|
||||
$arr_p[]=array(
|
||||
"value"=>$v_p,
|
||||
);
|
||||
$arr_l[]=array(
|
||||
"value"=>$v_l,
|
||||
);
|
||||
$arr_r[]=array(
|
||||
"value"=>$v_r,
|
||||
);
|
||||
}
|
||||
//$arr_s=multisort($arr_s,array(array('key'=>'value','sort'=>'desc')));
|
||||
for($i=0;$i<count($arr_s);$i++){
|
||||
$data_1[]=$arr_l[$i]['value'];
|
||||
$data_2[]=$arr_s[$i]['value'];
|
||||
$data_3[]=$arr_p[$i]['value'];
|
||||
$data_4[]=$arr_r[$i]['value'];
|
||||
$cats[]=$arr_s[$i]['name'];
|
||||
}
|
||||
|
||||
$g = new graph();
|
||||
|
||||
//$g->title( 'Sales: '.$year_month, '{font-size:20px; color: #000000; margin: 5px; background-color: #ffffff; padding:5px; padding-left: 20px; padding-right: 20px;}' );
|
||||
|
||||
$g->bg_colour = '#ffffff';
|
||||
|
||||
$d1 = new bar( 75, '#999999' );
|
||||
$d2 = new bar( 75, '#D54C78' );
|
||||
$d3 = new bar( 75, '#3334AD' );
|
||||
$d1->key( 'Forecast', 10 );
|
||||
$d2->key( 'Sales', 10 );
|
||||
$d3->key( 'Margin', 10 );
|
||||
for($i=0;$i<count($data_1);$i++){
|
||||
$d1->add_data_tip($data_1[$i],"Margin: ".round($data_3[$i],2)."\nSales: ".round($data_2[$i],2)."\nForecast: ".round($data_1[$i],2)."\nFullfillment: ".round($data_4[$i],2)."%");
|
||||
$d2->add_data_tip($data_2[$i],"Margin: ".round($data_3[$i],2)."\nSales: ".round($data_2[$i],2)."\nForecast: ".round($data_1[$i],2)."\nFullfillment: ".round($data_4[$i],2)."%");
|
||||
$d3->add_data_tip($data_3[$i],"Margin: ".round($data_3[$i],2)."\nSales: ".round($data_2[$i],2)."\nForecast: ".round($data_1[$i],2)."\nFullfillment: ".round($data_4[$i],2)."%");
|
||||
}
|
||||
$g->data_sets[]=$d1;
|
||||
$g->data_sets[]=$d2;
|
||||
$g->data_sets[]=$d3;
|
||||
|
||||
$g->set_tool_tip( '#x_label#<br>#tip#<br>' );
|
||||
|
||||
//$g->set_data($data_1);
|
||||
//$g->bar( 75, '#D54C78', '', 10 );
|
||||
//$g->set_data($data_2);
|
||||
//$g->bar( 75, '#3334AD', '', 10 );
|
||||
|
||||
//$g->attach_to_y_right_axis(2);
|
||||
|
||||
$g->x_axis_colour( '#909090', '#ADB5C7' );
|
||||
$g->y_axis_colour( '#909090', '#ADB5C7' );
|
||||
$g->y_right_axis_colour( '#909090' );
|
||||
|
||||
$g->set_x_labels( $cats );
|
||||
$g->set_x_label_style( 10, '#000000', 2 );
|
||||
|
||||
$g->set_y_max( $temp );
|
||||
$g->set_y_right_max( $temp);
|
||||
|
||||
$g->y_label_steps( 20 );
|
||||
//$g->y_right_label_steps( 5 );
|
||||
|
||||
$g->set_y_legend( '', 12, '#736AFF' );
|
||||
$g->set_y_right_legend( 'Free Ram (MB)' ,12 , '#164166' );
|
||||
|
||||
echo $g->render();
|
||||
|
||||
$exit_on_cleanup = true;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
sugar_cleanup($exit_on_cleanup);
|
||||
?>
|
||||
106
modules/Home/Dashlets/MyEcmReportDashlets/salesYearChart.php
Executable file
106
modules/Home/Dashlets/MyEcmReportDashlets/salesYearChart.php
Executable file
@@ -0,0 +1,106 @@
|
||||
<?php
|
||||
session_start();
|
||||
//error_reporting(0);
|
||||
include_once( '/var/www/html/e5crm/config.php');
|
||||
$sql=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/EcmReports/cache.php");
|
||||
function repl($t){
|
||||
$a1=array("ą","ś","ę","ż","ź","ć","ń","ó","ł","Ą","Ś","Ę","Ż","Ź","Ć","Ń","Ó","Ł");
|
||||
$a2=array("a","s","e","z","z","c","n","o","l","A","S","E","Z","Z","C","N","O","L");
|
||||
return str_replace($a1,$a2,$t);
|
||||
}
|
||||
function getSalesYear($year){
|
||||
for($i=1;$i<=12;$i++){
|
||||
if($i<10)$n="0".$i;
|
||||
else $n=$i;
|
||||
$r=mysql_fetch_array(mysql_query("select if(e.currency_value>0 and e.currency_value is not null,sum(i.quantity*i.price*e.currency_value),sum(i.quantity*i.price)) as s,sum(i.quantity*i.purchase_price) as p from ecminvoiceouts as e inner join ecminvoiceoutitems as i on e.id=i.ecminvoiceout_id inner join ecmproducts as p on p.id=i.ecmproduct_id inner join ecmstockdocouts as w on w.id=e.wz_id inner join ecmproductcategories as pc on pc.id=p.product_category_id where e.register_date like '".$year."-".$n."%' and e.type!='correct' and e.status='accepted' and i.deleted='0' and e.deleted='0'"));
|
||||
$arr[$i]=$r;
|
||||
|
||||
$w=mysql_query("select i.price,i.quantity,i.ecminvoiceoutitem_id,e.currency_value from ecminvoiceouts as e inner join ecminvoiceoutitems as i on e.id=i.ecminvoiceout_id inner join ecmproducts as p on p.id=i.ecmproduct_id inner join ecmproductcategories as pc on pc.id=p.product_category_id where e.register_date like '".$year."-".$n."%' and e.type='correct' and e.status='accepted' and i.deleted='0' and e.deleted='0'");
|
||||
while($r=mysql_fetch_array($w)){
|
||||
if(!$r['currency_value'])$r['currency_value']=1;
|
||||
$arr[$i]['s']+=$r['currency_value']*$r['price']*$r['quantity'];
|
||||
$rr=mysql_fetch_array(mysql_query("select price,quantity,purchase_price from ecminvoiceoutitems where id='".$r['ecminvoiceoutitem_id']."'"));
|
||||
$arr[$i]['s']-=$rr['price']*$rr['quantity'];
|
||||
$arr[$i]['p']+=$rr['purchase_price']*$r['quantity'];
|
||||
$arr[$i]['p']-=$rr['purchase_price']*$rr['quantity'];
|
||||
}
|
||||
}
|
||||
|
||||
return $arr;;
|
||||
}
|
||||
|
||||
$year_month=$_SESSION['EcmReports_Dashlet_sales_year'];
|
||||
$e=explode("-",$_SESSION['EcmReports_Dashlet_sales_year']);
|
||||
$year=$e[0];
|
||||
$month=$e[1];
|
||||
|
||||
$months=array("January","February","March","April","May","June","July","August","September","October","November","Dezember");
|
||||
|
||||
for($i=1;$i<=12;$i++){
|
||||
$s=getSalesYear($year);
|
||||
if($temp<$s[$i]['s'])$temp=$s[$i]['s'];
|
||||
$arr_s[]=array(
|
||||
"name"=>repl($months[$i-1]),
|
||||
"value"=>$s[$i]['s'],
|
||||
);
|
||||
$arr_p[]=array(
|
||||
"name"=>repl($months[$i-1]),
|
||||
"value"=>$s[$i]['p'],
|
||||
);
|
||||
}
|
||||
for($i=0;$i<count($arr_s);$i++){
|
||||
$data_1[]=$arr_s[$i]['value'];
|
||||
$data_2[]=$arr_s[$i]['value']-$arr_p[$i]['value'];
|
||||
$cats[]=$arr_s[$i]['name']." ".$year;
|
||||
}
|
||||
|
||||
$g = new graph();
|
||||
|
||||
//$g->title( 'Sales: '.$year_month, '{font-size:20px; color: #000000; margin: 5px; background-color: #ffffff; padding:5px; padding-left: 20px; padding-right: 20px;}' );
|
||||
|
||||
$g->bg_colour = '#ffffff';
|
||||
//$g->bg_colour = '#000000';
|
||||
|
||||
$d1 = new bar( 75, '#D54C78' );
|
||||
$d2 = new bar( 75, '#3334AD' );
|
||||
$d1->key( 'Sales', 10 );
|
||||
$d2->key( 'PLN Margin', 10 );
|
||||
for($i=0;$i<count($data_1);$i++){
|
||||
$d1->add_data_tip($data_1[$i],"Sales: ".round($data_1[$i],2)."\nPLN Margin: ".round($data_2[$i],2)."\nMargin: ".@round(100*($data_2[$i])/$data_1[$i],2)."%");
|
||||
$d2->add_data_tip($data_2[$i],"Sales: ".round($data_1[$i],2)."\nPLN Margin: ".round($data_2[$i],2)."\nMargin: ".@round(100*($data_2[$i])/$data_1[$i],2)."%");
|
||||
}
|
||||
$g->data_sets[]=$d1;
|
||||
$g->data_sets[]=$d2;
|
||||
|
||||
$g->set_tool_tip( '#x_label#<br>#tip#<br>' );
|
||||
|
||||
//$g->set_data($data_1);
|
||||
//$g->bar( 75, '#D54C78', '', 10 );
|
||||
//$g->set_data($data_2);
|
||||
//$g->bar( 75, '#3334AD', '', 10 );
|
||||
|
||||
//$g->attach_to_y_right_axis(2);
|
||||
|
||||
$g->x_axis_colour( '#909090', '#ADB5C7' );
|
||||
$g->y_axis_colour( '#909090', '#ADB5C7' );
|
||||
$g->y_right_axis_colour( '#909090' );
|
||||
|
||||
$g->set_x_labels( $cats );
|
||||
$g->set_x_label_style( 10, '#000000', 2 );
|
||||
|
||||
$g->set_y_max( $temp );
|
||||
$g->set_y_right_max( $temp);
|
||||
|
||||
$g->y_label_steps( 20 );
|
||||
//$g->y_right_label_steps( 5 );
|
||||
|
||||
$g->set_y_legend( '', 12, '#736AFF' );
|
||||
$g->set_y_right_legend( '' ,12 , '#164166' );
|
||||
|
||||
echo $g->render();
|
||||
mysql_close($sql);
|
||||
?>
|
||||
106
modules/Home/Dashlets/MyEcmReportDashlets/stocksChart.php
Executable file
106
modules/Home/Dashlets/MyEcmReportDashlets/stocksChart.php
Executable file
@@ -0,0 +1,106 @@
|
||||
<?php
|
||||
session_start();
|
||||
include_once( '/var/www/html/e5crm/config.php');
|
||||
$sql=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');
|
||||
include_once("/var/www/html/e5crm/modules/EcmReports/cache.php");
|
||||
function repl($t){
|
||||
$a1=array("ą","ś","ę","ż","ź","ć","ń","ó","ł","Ą","Ś","Ę","Ż","Ź","Ć","Ń","Ó","Ł");
|
||||
$a2=array("a","s","e","z","z","c","n","o","l","A","S","E","Z","Z","C","N","O","L");
|
||||
return str_replace($a1,$a2,$t);
|
||||
}
|
||||
|
||||
function getStock($category_id){
|
||||
$ww=mysql_query("select sum(h.value) as sum from ecmproducts_history_states as h inner join ecmproducts as p on p.id=h.ecmproduct_id where p.product_category_id='".$category_id."' and p.deleted='0' and h.ecmstock_id='c7afd71a-4c3a-bde4-138d-4acaee1644e4' and p.product_active='1'");
|
||||
$rr=mysql_fetch_array($ww);
|
||||
|
||||
$i=mysql_num_rows(mysql_query("select distinct date from ecmproducts_history_states"));
|
||||
$v=$rr['sum'];
|
||||
|
||||
return $v/$i;
|
||||
}
|
||||
if((int)date("m")==1){
|
||||
$mmm=12;
|
||||
$year=date("Y")-1;
|
||||
}
|
||||
else{
|
||||
$mmm=(int)date("m")-1;
|
||||
$year=date("Y");
|
||||
}
|
||||
$s=sum($year,"","","","");
|
||||
|
||||
//$w=mysql_query("select id,name from ecmproductcategories where deleted='0' and name!=''");
|
||||
//while($r=mysql_fetch_array($w)){
|
||||
//$ss=getSum($s,$year,"",$r['id']);
|
||||
//@$rot[$r['id']]=12*($ss['total_purchase']/$mmm)/getStock($r['id']);
|
||||
//if($tempr<$rot[$r['id']])$tempr=$rot[$r['id']];
|
||||
//}
|
||||
//echo '<pre>';
|
||||
//print_r($rot);
|
||||
//echo '</pre>';m
|
||||
$w=mysql_query("select p.id,p.product_category_id from ecmproducts as p inner join ecmproductcategories as c on c.id=p.product_category_id where p.deleted='0' order by c.name asc");
|
||||
while($r=mysql_fetch_array($w)){
|
||||
$qty=0;
|
||||
$ww=mysql_query("select quantity,price from ecmstockstates where deleted='0' and product_id='".$r['id']."'");
|
||||
while($rrr=mysql_fetch_array($ww)){
|
||||
$qty+=$rrr['quantity']*$rrr['price'];
|
||||
}
|
||||
$cats[$r['product_category_id']]+=$qty;
|
||||
if($cats[$r['product_category_id']]>$temp)$temp=$cats[$r['product_category_id']];
|
||||
}
|
||||
//$arr_s=multisort($arr_s,array(array('key'=>'value','sort'=>'desc')));
|
||||
$i=0;
|
||||
foreach($cats as $k=>$v){
|
||||
$r=mysql_fetch_array(mysql_query("select name from ecmproductcategories where id='".$k."' and deleted='0'"));
|
||||
if($r['name']){
|
||||
$data_1[$i]=$v;
|
||||
if($v)$data_2[$i]=$rot[$k];
|
||||
else $data_2[$i]=0;
|
||||
$cn[$i]=repl($r['name']);
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
|
||||
$g = new graph();
|
||||
|
||||
//$g->title( 'Stocks', '{font-size:20px; color: #000000; margin: 5px; background-color: #ffffff; padding:5px; padding-left: 20px; padding-right: 20px;}' );
|
||||
|
||||
$g->bg_colour = '#ffffff';
|
||||
|
||||
$d1 = new bar( 75, '#D54C78' );
|
||||
$d2 = new bar( 75, '#3334AD' );
|
||||
$d1->key( 'Inventory valueee', 10 );
|
||||
$d2->key( 'Rotation', 10 );
|
||||
for($i=0;$i<count($data_1);$i++){
|
||||
$d1->add_data_tip($data_1[$i],"Value: ".$data_1[$i]."\nRotation: ".round($data_2[$i],2));
|
||||
//$d2->add_data_tip($data_2[$i],"Value: ".$data_1[$i]."\nRotation: ".round($data_2[$i],2));
|
||||
}
|
||||
$g->data_sets[]=$d1;
|
||||
//$g->data_sets[]=$d2;
|
||||
|
||||
$g->set_tool_tip( '#x_label#<br>#tip#<br>' );
|
||||
|
||||
$g->attach_to_y_right_axis(2);
|
||||
|
||||
$g->x_axis_colour( '#909090', '#ADB5C7' );
|
||||
$g->y_axis_colour( '#909090', '#ADB5C7' );
|
||||
$g->y_right_axis_colour( '#909090' );
|
||||
|
||||
$g->set_x_labels( $cn );
|
||||
$g->set_x_label_style( 10, '#000000', 2 );
|
||||
|
||||
$g->set_y_max( $temp );
|
||||
$g->set_y_right_max( $tempr);
|
||||
|
||||
$g->y_label_steps( 20 );
|
||||
//$g->y_right_label_steps( 5 );
|
||||
|
||||
$g->set_y_legend( 'Inventory value', 12, '#D54C78' );
|
||||
$g->set_y_right_legend( 'Rotation' ,12 , '#3334AD' );
|
||||
|
||||
echo $g->render();
|
||||
mysql_close($sql);
|
||||
?>
|
||||
35
modules/Home/Dashlets/MyEcmReportDashlets/updateHistoryStates.php
Executable file
35
modules/Home/Dashlets/MyEcmReportDashlets/updateHistoryStates.php
Executable file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
session_start();
|
||||
include_once( '/var/www/html/e5crm/vserver/e5crm.more7.com/www/config.php');
|
||||
include_once( '/var/www/html/e5crm/vserver/e5crm.more7.com/www/guid.php');
|
||||
$sql=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");
|
||||
//mysql_query("truncate table ecmproducts_history_states");
|
||||
$date="2010-08-02";
|
||||
$www=mysql_query("select id,name from ecmstocks where deleted='0' and no='1'");
|
||||
while($rrr=mysql_fetch_array($www)){
|
||||
$stock_id=$rrr['id'];
|
||||
$ww=mysql_query("select id,code from ecmproducts where deleted='0' and code!='' order by code");
|
||||
while($rr=mysql_fetch_array($ww)){
|
||||
$v=0;
|
||||
$product_id=$rr['id'];
|
||||
$w=mysql_query("select type,quantity,price from ecmstockoperations where stock_id='".$stock_id."' and product_id='".$product_id."' and deleted='0'");
|
||||
while($r=mysql_fetch_array($w)){
|
||||
if($r['type']==0)$v+=$r['price']*$r['quantity'];
|
||||
else $v-=$r['price']*$r['quantity'];
|
||||
}
|
||||
if($v<0)$v=0;
|
||||
$set="date='".$date."',ecmproduct_id='".$product_id."',ecmstock_id='".$stock_id."',value='".$v."'";
|
||||
if(mysql_num_rows(mysql_query("select id from ecmproducts_history_states where ecmstock_id='".$stock_id."' and ecmproduct_id='".$product_id."' and date='".$date."'"))==0){
|
||||
mysql_query("insert into ecmproducts_history_states set id='".create_guid()."',".$set);
|
||||
}
|
||||
else{
|
||||
mysql_query("update ecmproducts_history_states set value='".$v."' where ecmstock_id='".$stock_id."' and ecmproduct_id='".$product_id."' and date='".$date."'");
|
||||
}
|
||||
echo $rr['code']." ".$v."\n";
|
||||
|
||||
}
|
||||
}
|
||||
mysql_close($sql);
|
||||
?>
|
||||
86
modules/Home/Dashlets/MyEcmReportDashlets/updateRealisation.php
Executable file
86
modules/Home/Dashlets/MyEcmReportDashlets/updateRealisation.php
Executable file
@@ -0,0 +1,86 @@
|
||||
<?php
|
||||
session_start();
|
||||
include_once( '/var/www/html/e5crm/config.php');
|
||||
include_once( '/var/www/html/e5crm/guid.php');
|
||||
$sql=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");
|
||||
//mysql_query("truncate table ecmproductcategories_realisation");
|
||||
$mdate=date("Y-m");
|
||||
|
||||
//$w=mysql_query("select * from ecmsales where delivery_date like '".$mdate."%' and deleted='0' and status='s30' and type='sales_order'");
|
||||
$w=mysql_query("select e.* from ecmsales as e inner join ecmstockdocouts as w on w.so_id=e.id inner join ecminvoiceouts as inv on inv.wz_id=w.id where e.deleted='0' and inv.register_date like '".$mdate."%' and e.type='sales_order' and e.status!='s10'");
|
||||
while($r=mysql_fetch_array($w)){
|
||||
$rsale=mysql_fetch_array(mysql_query("select sum(quantity*price) as qty from ecmsaleitems where ecmsale_id='".$r['id']."'"));
|
||||
$rwz=mysql_fetch_array(mysql_query("select id from ecmstockdocouts where so_id='".$r['id']."'"));
|
||||
$rwzi=mysql_fetch_array(mysql_query("select sum(quantity*selling_price) as qty from ecmstockdocoutitems where ecmstockdocout_id='".$rwz['id']."'"));
|
||||
$ecmstockdocout_id=$rwz['id'];
|
||||
if(mysql_num_rows(mysql_query("select id from ecminvoiceouts where wz_id='".$ecmstockdocout_id."' and deleted='0'"))==0)continue;
|
||||
if($ecmstockdocout_id){
|
||||
$sum_wz_qty+=$rwzi['qty'];
|
||||
$sum_sale_qty+=$rsale['qty'];
|
||||
}
|
||||
$qty_diff=$rwzi['qty']-$rsale['qty'];
|
||||
$diff_minus=$diff_plus=0;
|
||||
$rst=$rsale['qty'];
|
||||
$rwt=$rwzi['qty'];
|
||||
|
||||
if($ecmstockdocout_id){
|
||||
$wsale=mysql_query("select quantity,price,code,ecmproduct_id from ecmsaleitems where deleted='0' and ecmsale_id='".$r['id']."' order by code");
|
||||
while($rsale=mysql_fetch_array($wsale)){
|
||||
$qty=0;
|
||||
$wwz=mysql_query("select quantity,selling_price from ecmstockdocoutitems where deleted='0' and ecmproduct_id='".$rsale['ecmproduct_id']."' and ecmstockdocout_id='".$ecmstockdocout_id."'");
|
||||
while($rwz=mysql_fetch_array($wwz)){
|
||||
$qty+=$rwz['quantity']*$rwz['selling_price'];
|
||||
}
|
||||
|
||||
if($rsale['quantity']*$rsale['price']>$qty)$diff_minus+=$qty-$rsale['quantity']*$rsale['price'];
|
||||
if($rsale['quantity']*$rsale['price']<$qty)$diff_plus+=$qty-$rsale['quantity']*$rsale['price'];
|
||||
|
||||
$sum[$rsale['ecmproduct_id']]['wz']+=$qty;
|
||||
$sum[$rsale['ecmproduct_id']]['sale']+=$rsale['quantity']*$rsale['price'];
|
||||
}
|
||||
}
|
||||
}
|
||||
$percent=number_format((100*$sum_wz_qty/$sum_sale_qty),2,",",".")."%";
|
||||
|
||||
$rst=0;
|
||||
$rwt=0;
|
||||
$diff_plus=$diff_minus=0;
|
||||
$ww=mysql_query("select id,product_category_id from ecmproducts where deleted='0' order by code asc");
|
||||
while($rr=mysql_fetch_array($ww)){
|
||||
$k=$rr['id'];
|
||||
if(!$sum[$k])continue;
|
||||
$rst+=$sum[$k]['sale'];
|
||||
$rwt+=$sum[$k]['wz'];
|
||||
$cst[$rr['product_category_id']]+=$sum[$k]['sale'];
|
||||
$cwt[$rr['product_category_id']]+=$sum[$k]['wz'];
|
||||
if($sum[$k]['sale']>$sum[$k]['wz'])$diff_minus+=$sum[$k]['wz']-$sum[$k]['sale'];
|
||||
if($sum[$k]['sale']<$sum[$k]['wz'])$diff_plus+=$sum[$k]['wz']-$sum[$k]['sale'];
|
||||
}
|
||||
|
||||
$ww=mysql_query("select id,name from ecmproductcategories where deleted='0' order by name asc");
|
||||
while($rr=mysql_fetch_array($ww)){
|
||||
$k=$rr['id'];
|
||||
if($cwt[$k]<$cst[$k])$color="red";
|
||||
elseif($cwt[$k]>$cst[$k])$color="green";
|
||||
else $color="black";
|
||||
$set="date='".$mdate."',product_category_id='".$rr['id']."',value_sale='".$cst[$k]."',value_wz='".$cwt[$k]."'";
|
||||
if(mysql_num_rows(mysql_query("select id from ecmproductcategories_realisation where product_category_id='".$rr['id']."' and date like '".$mdate."%'"))==0){
|
||||
mysql_query("insert into ecmproductcategories_realisation set id='".create_guid()."',".$set);
|
||||
}
|
||||
else mysql_query("update ecmproductcategories_realisation set ".$set." where product_category_id='".$rr['id']."' and date like '".$mdate."%'");
|
||||
echo $rr['name']."\n";
|
||||
}
|
||||
$set="date='".$mdate."',product_category_id='diff_minus',value_sale='".$diff_minus."'";
|
||||
if(mysql_num_rows(mysql_query("select id from ecmproductcategories_realisation where product_category_id='diff_minus' and date like '".$mdate."%'"))==0){
|
||||
mysql_query("insert into ecmproductcategories_realisation set id='".create_guid()."',".$set);
|
||||
}
|
||||
else mysql_query("update ecmproductcategories_realisation set ".$set." where product_category_id='diff_minus' and date like '".$mdate."%'");
|
||||
$set="date='".$mdate."',product_category_id='diff_plus',value_sale='".$diff_plus."'";
|
||||
if(mysql_num_rows(mysql_query("select id from ecmproductcategories_realisation where product_category_id='diff_plus' and date like '".$mdate."%'"))==0){
|
||||
mysql_query("insert into ecmproductcategories_realisation set id='".create_guid()."',".$set);
|
||||
}
|
||||
else mysql_query("update ecmproductcategories_realisation set ".$set." where product_category_id='diff_plus' and date like '".$mdate."%'");
|
||||
mysql_close($sql);
|
||||
?>
|
||||
Reference in New Issue
Block a user