ShuanghongS 1 vuosi sitten
vanhempi
commit
f45979d392
5 muutettua tiedostoa jossa 127 lisäystä ja 37 poistoa
  1. 4 0
      include.ini.php
  2. 19 16
      main_new_version.php
  3. 1 1
      service/login.class.php
  4. 30 0
      service/ocean_order.class.php
  5. 73 20
      utils/common.class.php

+ 4 - 0
include.ini.php

@@ -51,6 +51,10 @@ function _isAdmin() {
     return $_SESSION['ONLINE_USER']['is_super'] == 't';
 }
 
+function _isRevenueDisplay() {
+    return $_SESSION['ONLINE_USER']['revenue_active'] == 't';
+}
+
 function _isNewUser() {
     return _isCustomerLogin() && empty($_SESSION['ONLINE_USER']['permission']);
 }

+ 19 - 16
main_new_version.php

@@ -587,7 +587,7 @@ switch ($action) {
         exit();
         break;
     case 'main_map_new':
-        //include ONLINE_ROOT . 'libs' . DS . 'map_config.ini.php';
+        include ONLINE_ROOT . 'libs' . DS . 'map_config.ini.php';
         //修改添加port_of_transshipment 和port_of_transshipment_name的坐标获取(有为空的可能)
         $serial_no = $_REQUEST["serial_no"];
         //$serial_no = "F41E6016-1A97-4C93-8198-53D8B3B26220";
@@ -620,21 +620,24 @@ switch ($action) {
         //           {"lng":"100.88333333","lat":"13.08333333","label":"Destination","infor":"LAEM CHABANG PORT,THAILAND","sort":"1","stime":null,"ptype":"pol"},
         //           {"lng":"-122.28640000","lat":"37.79784000","label":"Transfer","infor":"OAKLAND, CA, USA","sort":"2","stime":null,"ptype":"pod"}]';
         //$rss = json_decode($json,true);
-        // global $mapdb;
-        // //查询线(包含所有的线)
-        // $Line = $mapdb->GetAll("select * from get_track_data('$serial_no',true)");
-        // $solidLine = array();
-        // $dottedLine = array();
-        // foreach($Line as $line){
-        //     if($line['tp'] == "1"){
-        //         $solidLine[] = $line;
-        //     }else{
-        //         $dottedLine[] = $line;
-        //     }
-        // }
-        // $data = array("point"=>$rss,"solidLine"=>$solidLine,"dottedLine"=>$dottedLine);
-        // common::echo_json_encode(200, $data);
-        common::echo_json_encode(200, $rss);
+        global $mapdb;
+        //查询线(包含所有的线)
+        $Line = $mapdb->GetAll("select * from get_track_data('$serial_no',true)");
+        $solidLine = array();
+        $dottedLine = array();
+        $rangePoint = array();
+        foreach($Line as $line){
+            if($line['tp'] == "1"){
+                $solidLine[] = $line;
+            }elseif($line['tp'] == "0"){
+                $dottedLine[] = $line;
+            }else{
+                $rangePoint[] = $line;
+            }
+        }
+        $data = array("point"=>$rss,"solidLine"=>$solidLine,"dottedLine"=>$dottedLine,"rangePoint"=>$rangePoint);
+        common::echo_json_encode(200, $data);
+        //common::echo_json_encode(200, $rss);
         exit();
         break;
     case 'main_welcome':

+ 1 - 1
service/login.class.php

@@ -26,7 +26,7 @@ class login {
         customer_search_type, customer_destination, can_add_ams, can_add_isf, air_station, air_sales, ocean_station, ocean_sales,ocean_following_sales,ocean_following_sales_or,air_following_sales,air_following_sales_or, trucking_station, ocean_dest_op, can_see_password, can_add_opsales_code, ocean_station_or, ocean_agent_or, ocean_sales_or, ocean_dest_op_or, air_station_or, air_sales_or, trucking_station_or, 
         can_add_user, can_add_employee, can_add_contact, company_name, ams_email, isf_email, customer_discharge, online_active, is_super, ocean_agent,active, can_send_email, view_file_format as docdownload, container_status, consolidated_cbsa_code, can_add_aci, 
         air_customers, air_customer_search_type,trucking_customers,trucking_customer_search_type, upload_document, view_file_format, event_type, belong_schemas, main_schemas, error_login_count, EXTRACT(EPOCH FROM (now()-COALESCE(error_login_time, now()))) as second, po_status, view_air_file_format, 
-        special_customer_event, can_edi_vgm, isf_aci_ams_station,login_version,is_kerry_shipment,can_visit_delivery,currency_group from public.ra_online_user u where lower(user_login) = '" . strtolower($uname) . "'";
+        special_customer_event, can_edi_vgm, isf_aci_ams_station,login_version,is_kerry_shipment,can_visit_delivery,currency_group,revenue_active from public.ra_online_user u where lower(user_login) = '" . strtolower($uname) . "'";
     }
 
     public function do_login() {

+ 30 - 0
service/ocean_order.class.php

@@ -60,6 +60,13 @@ class ocean_order {
         if ($operate == "excel") {
             $this->_ocean_excel();
         }
+
+        /*
+         * download Revenue
+        */
+        if ($operate == "revenue") {
+            $this->_revenue_download();
+        }
        
         if ($operate == 'setting_ocean_order_display') {
             column::getInstance()->settingDisplay('Ocean_Search', 'main_new_version.php?action=ocean_order');
@@ -866,6 +873,29 @@ class ocean_order {
         common::echo_json_encode(200,array("msg"=>"success","Data" => $rs));
         exit;
     }
+
+    private function _revenue_download(){
+        $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);
+
+        $sql = "SELECT * FROM get_customer_revenue_report('$param');FETCH ALL FROM r3;";
+        $r3_data = common::excuteListSql($sql);
+       
+        common::echo_json_encode(200,array("msg"=>"success","r2" => $r2_data,"r3"=>$r3_data));
+        exit;
+    }
     
     private function _ams_isf_log(){
         global $cbpdb;

+ 73 - 20
utils/common.class.php

@@ -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,