ShuanghongS 7 месяцев назад
Родитель
Сommit
413dfee32b
4 измененных файлов с 203 добавлено и 11 удалено
  1. 1 1
      main_new_version.php
  2. 13 8
      service/login.class.php
  3. 4 2
      service/ocean_order.class.php
  4. 185 0
      utils/common.class.php

+ 1 - 1
main_new_version.php

@@ -383,7 +383,7 @@ switch ($action) {
         exit();
         break;   
     case 'main_report_top10_bar':
-        $returnData = common::getTopBar();
+        $returnData = common::getTopBarNew();
         common::echo_json_encode(200, $returnData);
         exit();
         break;

+ 13 - 8
service/login.class.php

@@ -21,12 +21,12 @@ class login {
         return self::$_login;
     }
 
-    private function getLoginSql($uname) {
+    private function getLoginSql() {
         return "select first_name,last_name,user_login,(select active from public.employee ee where ee.employee_id=u.employee_id) as employee_id_active, can_visit_vgm,can_add_booking, can_add_tk_status,truck_driver,po_booking,o_final_delivery_u,ipad_view_po,can_view_doc,can_upload_doc,can_add_catalog,can_add_po,packing_list_company,is_only_vgm,contact_id_user,is_demo, ra_password as password,employee_id, contact_id, user_type, last_pwd_change, EXTRACT(DAY from (now() - last_pwd_change)) as last_pwd_change_date, email, user_webtype_id, active, is_online, station, allow_login_remote, can_see_amslog,can_view_eccn, can_see_isflog, can_see_isflog_withaddress, 
         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,revenue_active 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) = ?";
     }
 
     public function do_login() {
@@ -57,8 +57,13 @@ class login {
                 }
             }
 
-            $sql = $this->getLoginSql($uname);
-            $rs = common::excuteObjectSql($sql);
+
+            //检查长度,大于50,返回 no_exist
+            common::checkUserNameLength($uname);
+
+            $sql = $this->getLoginSql();
+            $rs = common::excuteObjectPrepareSql($sql,[strtolower($uname)]);
+
             if (!empty($rs)) {
                 if (empty($rs['belong_schemas'])) {
                     $rs['belong_schemas'] = "public";
@@ -496,8 +501,8 @@ class login {
 
     public function check_uname(){
         $uname = common::check_input($_POST['uname']);
-        $sql = $this->getLoginSql($uname);
-        $rs = common::excuteObjectSql($sql);
+        $sql = $this->getLoginSql();
+        $rs = common::excuteObjectPrepareSql($sql,[strtolower($uname)]);
         if (!empty($rs)) {
             //只是验证用户是否存在,是否激活
             //验证employee是否active
@@ -664,8 +669,8 @@ class login {
            
         } else {
             $uname = common::check_input($_POST['uname']);
-            $sql = $this->getLoginSql($uname);
-            $rs = common::excuteObjectSql($sql);
+            $sql = $this->getLoginSql();
+            $rs = common::excuteObjectPrepareSql($sql,[strtolower($uname)]);
             if (empty($rs['belong_schemas'])) {
                 $rs['belong_schemas'] = "public";
             }

+ 4 - 2
service/ocean_order.class.php

@@ -1296,7 +1296,8 @@ class ocean_order {
                         'canEdiVgm' => _canEdiVgm(),
                         'canViewAMSLog'=>_canViewAMSLog(),
                         'canViewISFLog'=>_canViewISFLog(),
-                        'copyright' =>$_COPYRIGHT);
+                        'copyright' =>$_COPYRIGHT,
+                        'website' =>common::getWebiste($ocean['m_carrier']));
         common::echo_json_encode(200,$data);                
         exit(); 
     }
@@ -1455,7 +1456,8 @@ class ocean_order {
                         'canEdiVgm' => _canEdiVgm(),
                         'canViewAMSLog'=>_canViewAMSLog(),
                         'canViewISFLog'=>_canViewISFLog(),
-                        'copyright' =>$_COPYRIGHT);
+                        'copyright' =>$_COPYRIGHT,
+                        'website' =>"");
         common::echo_json_encode(200,$data);                
         exit(); 
     }

+ 185 - 0
utils/common.class.php

@@ -1457,6 +1457,147 @@ class common {
         return $returnData;
     }
 
+
+    public static function getTopBarNew(){
+        //分担查询
+        include ONLINE_ROOT . 'libs' . DS . 'map_config.ini.php';
+
+        $sqlWhere = ' and ' . common::searchExtendHand_KLN("ocean", $_SESSION["ONLINE_USER"]);
+        $sqlWhere = " " . $sqlWhere;
+
+        $date_type = strtolower($_REQUEST["date_type"]);
+        if (isset($_REQUEST['date_start']) && !empty($_REQUEST['date_start']))
+            $sqlWhere .= " and $date_type >= '" . common::usDate2sqlDate($_REQUEST['date_start']) . " 00:00:00'";
+        if (isset($_REQUEST['date_end']) && !empty($_REQUEST['date_end']))
+            $sqlWhere .= " and $date_type <= '" . common::usDate2sqlDate($_REQUEST['date_end']) . " 23:59:59'";
+
+        $transportation = $_REQUEST["transportation"];
+        if(!is_array($transportation)){
+            $transportation = array($transportation);
+        }
+        $mode_param = "";
+        if(utils::count($transportation) == 1 && strtolower($transportation[0]) == 'all' ){
+            $mode_param = "'sea','air','road'";         
+        }else{
+            $transport_mode = utils::implode(';', $transportation);
+            $mode_param = common::getInNotInSqlForSearch($transport_mode);
+        }
+        $sqlWhere .= " and transport_mode in ($mode_param)";    
+         
+        $toporiginType = "shippr_uncode";
+        $shippr_uncode_10_sql ="with aa as  (select count(shippr_uncode) as num,shippr_uncode,
+                                (array_agg(shipper_city))[1] AS shipper_city from public.kln_ocean  
+                        where 1=1 and COALESCE(shippr_uncode,'')<>'' $sqlWhere group by shippr_uncode order by num desc limit 10)
+            select   aa.* from  aa ";
+   
+        $shippr_uncode_10 = $mapdb->GetAll($shippr_uncode_10_sql) or ( (!$mapdb->ErrorMsg()) or error_log(common::dbLog($mapdb, $shippr_uncode_10_sql), 0));
+        //如果值没有:客户地址-->站点地址-->Port地址(POL/POD) 
+        if(utils::count($shippr_uncode_10) == 1 && empty($shippr_uncode_10[0]["shippr_uncode"])){
+            $toporiginType = "fport_of_loading_un";
+            $shippr_uncode_10_sql = "with aa as  (select count(fport_of_loading_un) as num,fport_of_loading_un as shippr_uncode 
+                    from public.kln_ocean where 1=1 and COALESCE(fport_of_loading_un,'')<>'' $sqlWhere group by fport_of_loading_un order by num desc limit 10)
+                    select   aa.* from  aa ";
+            $shippr_uncode_10 = $mapdb->GetAll($shippr_uncode_10_sql) or ( (!$mapdb->ErrorMsg()) or error_log(common::dbLog($mapdb, $shippr_uncode_10_sql), 0));
+        }
+       
+        $topdestinationinType = "consignee_uncode";
+        $consignee_uncode_10_sql = "with aa as  (select count(consignee_uncode) as num,consignee_uncode,
+                    (array_agg(consignee_city))[1] AS consignee_city 
+                from public.kln_ocean  where 1=1  and COALESCE(consignee_uncode,'')<>''  $sqlWhere group by consignee_uncode order by num desc limit 10)
+        select   aa.* from  aa";
+
+        $consignee_uncode_10 = $mapdb->GetAll($consignee_uncode_10_sql) or ( (!$mapdb->ErrorMsg()) or error_log(common::dbLog($mapdb, $consignee_uncode_10_sql), 0));
+        //如果值没有:客户地址-->站点地址-->Port地址(POL/POD) 
+        if(utils::count($consignee_uncode_10) == 1 && empty($consignee_uncode_10[0]["consignee_uncode"])){
+            $topdestinationinType = "mport_of_discharge_un";
+            $consignee_uncode_10_sql = "with aa as  (select count(mport_of_discharge_un) as num,mport_of_discharge_un as consignee_uncode from public.kln_ocean where 1=1 and COALESCE(mport_of_discharge_un,'')<>'' $sqlWhere group by mport_of_discharge_un order by num desc limit 10)
+                select   aa.* from  aa";
+            $consignee_uncode_10 = $mapdb->GetAll($consignee_uncode_10_sql) or ( (!$mapdb->ErrorMsg()) or error_log(common::dbLog($mapdb, $consignee_uncode_10_sql), 0));
+        }
+
+        $toporigin = array();
+        $toporiginMap = array();
+        $i = 0;
+        $origiNunMax = 0;
+        foreach($shippr_uncode_10 as $orgin){
+            $i = $i + 1;
+            $map =common::excuteObjectSql("select lon as lng, lat as lat,
+                    '' as label, '' as infor, 3 as sort,
+                    null::timestamp without time zone as stime,''::text as ptype 
+                from vessel.vt_unlocode where (lat<=90 and lat>=-90) and (lon<=180 and lon>=-180) and lon is not null and lat is not null and uncode='".$orgin['shippr_uncode']."'");
+            
+            //$json = '{"lng":121.8525,"lat":29.926545,"label":"'.$orgin['origin'].'","infor":"LAT KRABANG, THAILAND","sort":"0","stime":null,"ptype":"por"}';
+            //$map = json_decode($json,true);
+            if(!empty($map)){
+                $toporiginMap[] = array("qandl"=>array(floatval($map['lat']),floatval($map['lng'])),
+                    "divIcon" => array("iconSize"=>0),
+                    "name" =>$orgin['shippr_uncode'],
+                    "color" =>common::getItemStyle("top",$i),
+                    "value" =>$orgin['num'],
+                    "textcolor" =>"#FFF");
+            }
+            //查询uncode,对应的city
+            $city = "";
+            if($toporiginType == "shippr_uncode"){
+                $city = $orgin['shipper_city'];
+            }
+            //$city 做假数据
+            $toporigin[] = array("name"=>$orgin['shippr_uncode'],"city_name"=>$city,"value"=>$orgin['num'],"color"=>common::getItemStyle("top",$i));
+            $origiNunMax = $origiNunMax < $orgin['num'] ? $orgin['num'] : $origiNunMax;
+        }
+
+        $topdestination = array();
+        $topdestinationinMap = array();
+        $i = 0;
+        $agentiNunMax = 0;
+        foreach($consignee_uncode_10 as $agent){
+            $i = $i + 1;
+            $map =common::excuteObjectSql("select lon as lng, lat as lat,
+                    '' as label, '' as infor, 3 as sort,
+                    null::timestamp without time zone as stime,''::text as ptype 
+                from vessel.vt_unlocode where (lat<=90 and lat>=-90) and (lon<=180 and lon>=-180) and lon is not null and lat is not null and uncode='".$agent['consignee_uncode']."' ");
+            
+            // $json = '{"lng":"100.78594000","lat":"13.68521000","label":"'.$agent['agent'].'","infor":"LAT KRABANG, THAILAND","sort":"0","stime":null,"ptype":"por"}';
+            // $map = json_decode($json,true);
+            if(!empty($map)){
+                $topdestinationinMap[] = array("qandl"=>array(floatval($map['lat']),floatval($map['lng'])),
+                    "divIcon" => array("iconSize"=>0),
+                    "name" =>$agent['consignee_uncode'],
+                    "color" =>common::getItemStyle("top",$i),
+                    "value" =>$agent['num'],
+                    "textcolor" =>"#FFF");
+            }
+
+            //查询uncode,对应的city
+            $city = "";
+            if($topdestinationinType == "consignee_uncode"){
+                $city = $agent['consignee_city'];
+            }
+            //$city 做假数据
+            $topdestination[] = array("name"=>$agent['consignee_uncode'],"city_name"=>$city,"value"=>$agent['num'],"color"=>common::getItemStyle("top",$i));
+            $agentiNunMax = $agentiNunMax < $agent['num'] ? $agent['num'] : $agentiNunMax;
+        }
+
+        //处理返回原表数据格式
+        $interval = utils::calculateTicks(0,$origiNunMax,10);
+        if($interval == 0){
+            //处理返回默认值
+            $interval = 1;
+        }
+
+        $dest_interval = utils::calculateTicks(0,$agentiNunMax,10);
+        if($dest_interval == 0){
+            //处理返回默认值
+            $dest_interval = 1;
+        }
+
+        $returnData = array("seller_data_list_origin"=>$toporigin,"toporiginMap"=>array_reverse($toporiginMap),"toporiginType"=>$toporiginType,
+            "seller_data_list_destination"=>$topdestination,"topdestinationinMap"=>array_reverse($topdestinationinMap),"topdestinationinType"=>$topdestinationinType,
+            "min" => 0,"Max" =>$interval*10,"interval" =>$interval,
+            "dest_min" => 0,"dest_Max" =>$dest_interval*10,"dest_interval" =>$dest_interval);
+        return $returnData;
+    }
+
     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}';   
         //return json_decode($data,true);
@@ -2204,6 +2345,23 @@ class common {
         return $is_subscribe;
     }
 
+    /**
+     * get webiste
+    */
+    public static function getWebiste($carrier) {
+        $website = "";
+        if (!empty($carrier)){
+            $website = common::excuteOneSql("select website from vessel_company where scac = '$carrier'");
+        }
+        if (strpos($website, ";") === FALSE){
+            
+        }else{
+            $site = explode(";", $website);
+            $website = $site[0];
+        } 
+        return  $website; 
+    }
+
     public static  function getWeek($week){
         if ($week == "0"){
             $week = "Sunday";
@@ -2297,5 +2455,32 @@ class common {
         }
         return !empty($num) ? intval($num): $num;
     }
+
+    //检查user name length
+    public static function checkUserNameLength($input) {
+        if(!empty($input) && strlen($input) > 50){
+            $data = array(
+                'code' => 'no_exist',
+                'login_version' => '',
+                'msg' => 'The username or password you entered is incorrect'
+            );
+            common::echo_json_encode(500, $data);
+            exit();
+        }
+    }
+
+    //预加载写法
+    public static function excuteObjectPrepareSql($sql,$param) {
+        if (empty($sql))
+            exit(json_encode("Program encountered an error."));
+        global $db;
+        $stmt = $db->Prepare($sql);
+        $result = $db->Execute($stmt, $param);
+        if ($result && $result->RecordCount() > 0) { 
+            $row = $result->fields;
+            return $row;
+        }
+        return  null;
+    }
 }
 ?>