|
|
@@ -1161,8 +1161,10 @@ class common {
|
|
|
"date_end"=>$ctnr_date_end_two,"date_end_two"=>$ctnr_date_end);
|
|
|
|
|
|
//RevenueDefaultData
|
|
|
- //$dashboard_filter['RevenueDefaultData'] = array("transportation" =>array('All'),"date_type"=>"Invoice Issue Date","date_start"=>$ctnr_date_start_two,"date_start_two"=>$ctnr_date_start,
|
|
|
- // "date_end"=>$ctnr_date_end_two,"date_end_two"=>$ctnr_date_end);
|
|
|
+ if(_isRevenueDisplay()){
|
|
|
+ $dashboard_filter['RevenueDefaultData'] = array("transportation" =>array('All'),"date_type"=>"Invoice Issue Date","date_start"=>$ctnr_date_start_two,"date_start_two"=>$ctnr_date_start,
|
|
|
+ "date_end"=>$ctnr_date_end_two,"date_end_two"=>$ctnr_date_end);
|
|
|
+ }
|
|
|
|
|
|
//Top10faultData
|
|
|
$dashboard_filter['Top10faultData'] = array("transportation" =>array('All'),"date_type"=>"ETA","date_start"=>$top_date_start_two,"date_start_two"=>$top_date_start,
|
|
|
@@ -1546,20 +1548,69 @@ class common {
|
|
|
|
|
|
public static function getRevenue(){
|
|
|
$data = '{"bar_title":"Total: 0","barList":["DEC,23","JAN,24","FEB,24","MAR,24","APR,24","MAY,24","JUN,24","JUL,24","AUG,24","SEP,24","OCT,24","NOV,24"],"barSeries":[{"name":"USD","type":"bar","data":[1,1,1,1,1,1,1,1,1,1,1,1],"emphasis":{"disabled":true,"focus":"none"},"itemStyle":{"color":"#FF7500","borderRadius":6},"label":{"show":false,"color":"#646A73","position":"top","fontFamily":"Lato-Light","hideWhenMouseLeave":false}},{"name":"THB","type":"bar","data":[2,2,2,2,2,2,2,2,2,2,2,2],"emphasis":{"disabled":true,"focus":"none"},"itemStyle":{"color":"#FFAC66","borderRadius":6},"label":{"show":false,"color":"#646A73","position":"top","fontFamily":"Lato-Light","hideWhenMouseLeave":false}},{"name":"SGD","type":"bar","data":[3,3,3,3,3,3,3,3,3,3,3,3],"emphasis":{"disabled":true,"focus":"none"},"itemStyle":{"color":"#FFE3CC","borderRadius":6},"label":{"show":false,"color":"#646A73","position":"top","fontFamily":"Lato-Light","hideWhenMouseLeave":false}}],"Max":5,"interval":1,"download_name":"Rvenue","isShowTooltips":true}';
|
|
|
- // $date_from = null;
|
|
|
- // $date_to = null;
|
|
|
- // if (isset($_REQUEST['date_start']) && !empty($_REQUEST['date_start'])){
|
|
|
- // $date_start = common::dateFormatToYM($_REQUEST['date_start']);
|
|
|
- // $date_from = $date_start."-01";
|
|
|
- // }
|
|
|
- // if (isset($_REQUEST['date_end']) && !empty($_REQUEST['date_end'])){
|
|
|
- // $date_end = common::dateFormatToYM($_REQUEST['date_end']);
|
|
|
- // $date_to = date('Y-m-t', strtotime("$date_end-01"));
|
|
|
- // }
|
|
|
- // $param = '{"user_login":"'._getLoginName().'","report_type":"ALL","date_from":"2024-01-01","date_to":"2024-12-31"}';
|
|
|
- // $sql = "SELECT * FROM get_customer_revenue_report('$param');FETCH ALL FROM r2;";
|
|
|
- // common::excuteListSql($sql);
|
|
|
- return json_decode($data,true);
|
|
|
+ //return json_decode($data,true);
|
|
|
+ $date_from = null;
|
|
|
+ $date_to = null;
|
|
|
+ if (isset($_REQUEST['date_start']) && !empty($_REQUEST['date_start'])){
|
|
|
+ $date_start = common::dateFormatToYM($_REQUEST['date_start']);
|
|
|
+ $date_from = $date_start."-01";
|
|
|
+ }
|
|
|
+ if (isset($_REQUEST['date_end']) && !empty($_REQUEST['date_end'])){
|
|
|
+ $date_end = common::dateFormatToYM($_REQUEST['date_end']);
|
|
|
+ $date_to = date('Y-m-t', strtotime("$date_end-01"));
|
|
|
+ }
|
|
|
+ $param = '{"user_login":"'._getLoginName().'","report_type":"ALL","date_from":"'.$date_from.'","date_to":"'.$date_to.'"}';
|
|
|
+ $sql = "SELECT * FROM get_customer_revenue_report('$param');FETCH ALL FROM r2;";
|
|
|
+ $r2_data = common::excuteListSql($sql);
|
|
|
+
|
|
|
+ $barList = array();
|
|
|
+ $groupedItems = array();
|
|
|
+ foreach ($r2_data as $item) {
|
|
|
+ if(!in_array($item['month'],$barList)){
|
|
|
+ $barList[] = $item['month'];
|
|
|
+ }
|
|
|
+ $groupedItems[$item['currency']][] = $item;
|
|
|
+ }
|
|
|
+
|
|
|
+ //处理barSeries
|
|
|
+ $barSeries = array();
|
|
|
+ //先准备4种颜色
|
|
|
+ $color = array("#FF7500","#FFAC66","#FFE3CC");
|
|
|
+ $index = 0;
|
|
|
+ $max = 0;
|
|
|
+ foreach($groupedItems as $currency => $series){
|
|
|
+ $num = $index % 3;
|
|
|
+ $index = $index +1;
|
|
|
+ $tem_series = array();
|
|
|
+ $tem_series["name"] = $currency;
|
|
|
+ $tem_series["type"] = "bar";
|
|
|
+ $tem_series["emphasis"] = array("disabled"=>true,"focus"=>"none");
|
|
|
+ $tem_series["itemStyle"] = array("color"=>$color[$num],"borderRadius"=>6);
|
|
|
+ $tem_series["label"] = array("show"=>false,"color"=>"#646A73","position"=>"top","fontFamily"=>"Lato-Light","hideWhenMouseLeave"=>false);
|
|
|
+ //准备series data
|
|
|
+ $data = array();
|
|
|
+ $total = 0;
|
|
|
+ foreach($series as $_series){
|
|
|
+ $data[]=$_series['total_amount'];
|
|
|
+ $total = $total + $_series['total_amount'];
|
|
|
+ $max = $max<$_series['total_amount'] ? $_series['total_amount'] : $max;
|
|
|
+ }
|
|
|
+ $tem_series["label"] = $data;
|
|
|
+ $tem_series["total"] = $total;
|
|
|
+ $barSeries[] = $tem_series;
|
|
|
+ }
|
|
|
+
|
|
|
+ //计算Y坐标的间隔
|
|
|
+ $interval = utils::calculateTicks(0,$max,5);
|
|
|
+ if($interval == 0){
|
|
|
+ //处理返回默认值
|
|
|
+ $interval = 2;
|
|
|
+ }
|
|
|
+
|
|
|
+ $revenueBarData = array("bar_title" =>"Total: 0","barList" => $barList,
|
|
|
+ "barSeries" =>$barSeries,"download_name"=>"Rvenue","isShowTooltips"=>true,"Max" =>$interval*5,"interval" =>$interval);
|
|
|
+
|
|
|
+ return $revenueBarData;
|
|
|
}
|
|
|
|
|
|
public static function getdefaultManagement(){
|
|
|
@@ -1580,10 +1631,12 @@ class common {
|
|
|
"title"=>"Container Count",
|
|
|
"switchValue"=>true,
|
|
|
"text"=>"Pie chart showing figures of shipments which are soon to depart/arrive (Calculated from ETD/ETA).");
|
|
|
- // $Management[] = array("id"=>5 ,
|
|
|
- // "title"=>"Revenue Spent",
|
|
|
- // "switchValue"=>true,
|
|
|
- // "text"=>"Revenue data for the past 12 months.");
|
|
|
+ if(_isRevenueDisplay()){
|
|
|
+ $Management[] = array("id"=>5 ,
|
|
|
+ "title"=>"Revenue Spent",
|
|
|
+ "switchValue"=>true,
|
|
|
+ "text"=>"Revenue data for the past 12 months.");
|
|
|
+ }
|
|
|
$Management[] = array("id"=>6 ,
|
|
|
"title"=>"Top 10 Origin/Destination",
|
|
|
"switchValue"=>true,
|