Просмотр исходного кода

ADD VGM / tracking / other submit

ShuanghongS 1 год назад
Родитель
Сommit
937f4fd4a1

+ 1 - 0
login.php

@@ -2,6 +2,7 @@
 header("Cache-Control: no-cache");
 include_once "include.ini.php";
 include_once 'service/login.class.php';
+include 'service/column.class.php';
 //Operation log 日志记录
 utils::operation_log_records();
 

+ 6 - 2
main_new_version.php

@@ -17,11 +17,12 @@ include 'service/search.class.php';
 include 'service/column.class.php';
 include 'service/ajax.class.php';
 include 'service/login.class.php';
+include 'service/tools.class.php';
 
 //为了调用,临时做一个登录动作
 $_POST['uname'] = "ra.admin";
 $_POST['psw'] = "abc123456789";
-login::getInstance()->do_login_auto();
+//login::getInstance()->do_login_auto();
 //验证路由权限
 common::securityCheckHandNew($action);
 if (_is_only_vgm()) {
@@ -518,7 +519,10 @@ switch ($action) {
         $returnData = array("msg" => "success");
         common::echo_json_encode(200, $returnData);
         exit();
-        break;     
+        break; 
+    case 'password':
+        tools::getInstance()->updatePassword();
+        break;        
     default:
         $data = array(
             'msg' => 'Page not found',

+ 187 - 0
service/login.class.php

@@ -1116,6 +1116,193 @@ class login {
         exit();
     }
 
+    public function tracking_checked(){
+        $reference_number = common::check_input($_POST['reference_number']);
+        $is_verify = common::check_input($_POST['verifcation_code']);
+        if($this->signUpAndTrackingChecked($is_verify)){
+            $data = array("msg" =>"visit limit");
+            common::echo_json_encode(200, $data);
+            exit();
+        }else{
+            $data =  $this->getTrackingInfo($reference_number);
+            common::echo_json_encode(200, $data);
+            exit();
+        }
+    }
+
+    private function  signUpAndTrackingChecked($is_verify){
+        $Tracking_Search_Count = common::excuteOneSql("select ra_value from ra_online_config where ra_name='Tracking_Search_Count'");
+        $ip = common::ip();
+        global $db;
+        $db->StartTrans();
+        $db->Execute("update tracking_login_record set visit_count = 1, visit_time=now() "
+                        . " where ip = '$ip' and type ilike '".common::check_input($_POST['type'])."' and visit_time + '5 min' < NOW()::timestamp ") or ( (!$db->ErrorMsg()) or error_log($db->ErrorMsg(), 0));
+        $ipInfo = $db->GetRow("select ip, visit_count from tracking_login_record where ip = '$ip' and type ilike '".common::check_input($_POST['type'])."' and visit_time + '5 min' > NOW()::timestamp");
+        if(empty($ipInfo)){
+            $db->Execute("INSERT INTO public.tracking_login_record(ip, visit_count,visit_time,type)VALUES ('$ip', '1', now(),'".common::check_input($_POST['type'])."');") or ( (!$db->ErrorMsg()) or error_log($db->ErrorMsg(), 0));
+        }else{
+            if ($ipInfo['visit_count'] > $Tracking_Search_Count){
+                if(strtolower($_SESSION['captcha']) == strtolower($is_verify) || true ){
+                    //归零验证次数
+                    $db->Execute("update tracking_login_record set visit_count = 1 "
+                        . " where ip = '$ip' and type ilike '".common::check_input($_POST['type'])."' and visit_time + '5 min' > NOW()::timestamp ") or ( (!$db->ErrorMsg()) or error_log($db->ErrorMsg(), 0));
+                }else{
+                    return TRUE;
+                }
+            }else{
+                $db->Execute("update tracking_login_record set visit_count = visit_count::integer + 1 "
+                        . " where ip = '$ip' and type ilike '".common::check_input($_POST['type'])."' and visit_time + '5 min' > NOW()::timestamp ") or ( (!$db->ErrorMsg()) or error_log($db->ErrorMsg(), 0));
+            }
+        }
+        if ($db->CompleteTrans() === FALSE) {
+            //出错拦截
+            return TRUE;
+        } else {
+            return FALSE;
+        }
+    }
+
+    private function getTrackingInfo($reference_number){
+        $sql = "SELECT o.* ,sh.*, cn.* ,aa.*,dd.* ,cc.status
+                from ocean o 
+                left join LATERAL (select case when a.description='Booking Confirmation' then 'Booked'
+							when a.description='Cargo Pickup' then 'Cargo Received'
+							when a.description='Cargo Arrived at Origin' then 'Cargo Received'
+							when a.description='Departure' then 'Departed'
+							when a.description='Arrived at Final Destination Port Arrived' then 'Arrived'
+							when a.description='Arrived at Final Destination' then 'Completed'
+							else 'Booked' END as status
+			            from  ocean_milestone a 
+					        where a.serial_no=o.serial_no 
+					        and a.description in (
+						        select regexp_split_to_table('Booking Confirmation,Cargo Pickup,Cargo Arrived at Origin,Departure,Arrived at Final Destination Port,Arrived at Final Destination', ','))
+				        order by id desc limit 1) cc on true
+                LEFT JOIN LATERAL ( SELECT company as cn_company,
+                    address_1 as cn_address_1,
+                    address_2 as cn_address_2,
+                    address_3 as cn_address_3,
+                    address_4 as cn_address_4,
+                    city as cn_city, state as cn_state, zipcode as cn_zipcode, country as cn_country,
+                    phone_1 as cn_phone
+                FROM contacts c WHERE o.consignee::text = c.contact_id::text) cn ON true
+                LEFT JOIN LATERAL ( SELECT company as sh_company,
+                    address_1 as sh_address_1,
+                    address_2 as sh_address_2,
+                    address_3 as sh_address_3,
+                    address_4 as sh_address_4,
+                    city as sh_city, state as sh_state, zipcode as sh_zipcode, country as sh_country,
+                    phone_1 as sh_phone
+                FROM contacts c WHERE o.shipper::text = c.contact_id::text) sh ON true
+                LEFT JOIN LATERAL ( SELECT company as aa_company,
+                    address_1 as aa_address_1,
+                    address_2 as aa_address_2,
+                    address_3 as aa_address_3,
+                    address_4 as aa_address_4,
+                    city as aa_city, state as aa_state, zipcode as aa_zipcode, country as aa_country,
+                    phone_1 as aa_phone
+                FROM contacts c WHERE o.origin_station::text = c.contact_id::text) aa ON true
+                LEFT JOIN LATERAL ( SELECT company as dd_company,
+                    address_1 as dd_address_1,
+                    address_2 as dd_address_2,
+                    address_3 as dd_address_3,
+                    address_4 as dd_address_4,
+                    city as dd_city, state as dd_state, zipcode as dd_zipcode, country as dd_country,
+                    phone_1 as dd_phone
+                FROM contacts c WHERE o.destination_station::text = c.contact_id::text) dd ON true
+            where (lower(tracking_no) = '" . strtolower($reference_number) . "' 
+                or lower(booking_no) = '" . strtolower($reference_number) . "'
+                or lower(h_bol) = '" . strtolower($reference_number) . "'
+                or lower(m_bol) = '" . strtolower($reference_number) . "'
+                or lower(po_no) = '" . strtolower($reference_number) . "'
+                or lower(quote_no) = '" . strtolower($reference_number) . "'
+                or lower(invoice_no) = '" . strtolower($reference_number) . "'
+                or exists (select 1 from oc_container oc where o.serial_no = oc.serial_no and oc.ctnr = '$reference_number'))";
+        $ocean_arr = common::excuteListSql($sql);
+        if(empty($ocean_arr)){
+            $data = array("msg" =>"No matches");
+            return $data;
+        }
+        if(!empty($ocean_arr) && count($ocean_arr) > 1){
+            $data = array("msg" =>"Multiple results");
+            return $data;
+        }
+
+        $ocean = $ocean_arr[0];
+        //处理transportInfo信息数据
+        $transportInfo = array("Tracking No." =>$ocean['tracking_no'],"status"=>$ocean['status'],"mode" => "Ocean Frieght",
+            "origin" =>$ocean['origin_station'],"destination" =>$ocean['destination_station'],
+            "etd" =>$ocean['f_etd'],"atd" =>"","eta" =>$ocean['m_eta'],"ata" =>"");
+
+        //处理basicInfo信息数据
+        $vessel = utils::outDisplayForMerge($ocean['f_vessel'],$ocean['m_vessel']);
+        $voyage = utils::outDisplayForMerge($ocean['f_voyage'],$ocean['m_voyage']);
+        $basicInfo = array("MAWB/MBL No." =>$ocean['m_bol'],"HAWB/HBOL" => $ocean['h_bol'],"Carrier_Booking_No" =>$ocean['carrier_booking'],
+            "PO_NO" =>$ocean['po_no'],"Vessel/Airline" =>$vessel,"Voyage/Filght" =>$voyage,
+            "Incoterm" =>$ocean['terms'],"Service_Type" =>$ocean['service']);
+
+        //处理 拼接地址 ocean表单exp 字段无法精准分割电话和地址信息,只能从contacts表里查询
+        $shipper_address = common::retStationInfo($ocean['sh_address_1'], $ocean['sh_address_2'], $ocean['sh_address_3'], $ocean['sh_address_4'], 
+            $ocean['sh_city'], $ocean['sh_state'], $ocean['sh_zipcode'], $ocean['sh_country']);
+        $consignee_address = common::retStationInfo($ocean['cn_address_1'], $ocean['cn_address_2'], $ocean['cn_address_3'], $ocean['cn_address_4'], 
+            $ocean['cn_city'], $ocean['cn_state'], $ocean['cn_zipcode'], $ocean['cn_country']);
+        $origin_address = common::retStationInfo($ocean['aa_address_1'], $ocean['aa_address_2'], $ocean['aa_address_3'], $ocean['aa_address_4'], 
+            $ocean['aa_city'], $ocean['aa_state'], $ocean['aa_zipcode'], $ocean['aa_country']); 
+        $destination_address = common::retStationInfo($ocean['dd_address_1'], $ocean['dd_address_2'], $ocean['dd_address_3'], $ocean['dd_address_4'], 
+            $ocean['dd_city'], $ocean['dd_state'], $ocean['dd_zipcode'], $ocean['dd_country']);    
+
+        $shipperPartners = array("company" =>$ocean['sh_company'],"address"=>$shipper_address,"phone"=>$ocean['sh_phone']);
+        $consigneePartners = array("company" =>$ocean['cn_company'],"address"=>$consignee_address,"phone"=>$ocean['cn_phone']);
+        $originPartners = array("company" =>$ocean['aa_company'],"address"=>$origin_address,"phone"=>$ocean['aa_phone']);
+        $destinationPartners = array("company" =>$ocean['dd_company'],"address"=>$destination_address,"phone"=>$ocean['dd_phone']);
+        $businessPartners = array("shipper"=>$shipperPartners,"consignee" => $consigneePartners,"origin" => $originPartners,"destination" => $destinationPartners);
+            
+        //处理marksAndDescription
+        $marksAndDescription = array("marks"=>$ocean['marks'],"description"=>$ocean['description']);
+        
+        $sql = "SELECT " . column::getInstance()->getSearchSql('Ocean_Container') . " from oc_container where lower(serial_no) = '" . strtolower($serial_no) . "'";
+        $rss = common::excuteListSql($sql);
+        $quantity_tolal = 0;
+        $packages = "CTN";
+        $g_weight_tolal = 0;
+        $ch_weight_tolal = 0;
+        $cbm_tolal = 0;
+        foreach ($rss as $key => $rs) {
+            $quantity_tolal += $rs['qty'];
+            $g_weight_tolal += $rs['grs_kgs'];
+            $ch_weight_tolal += $rs['grs_lbs'];
+            $cbm_tolal += $rs['cbm'];
+            $packages = " ".$rs['unit'];
+        }
+        //Packing 不确定信息
+        $packing = array("Quantity/Unit"=>$quantity_tolal.$packages,"G. Weight" => $g_weight_tolal." KGS","Ch. Weight" => $ch_weight_tolal." LBS","Volume" => $cbm_tolal." CBM");
+       
+        //Milestones info  列名固定
+        $Milestones_column = array();
+        $Milestones_column[] = array("title" =>"Milestones","field" =>"milestones","formatter" =>"","type" =>"normal");
+        $Milestones_column[] = array("title" =>"Date Time","field" =>"date_time","formatter" =>"","type" =>"normal");
+        $Milestones_column[] = array("title" =>"Locations","field" =>"locations","formatter" =>"","type" =>"normal");
+        $Milestones_column[] = array("title" =>"Remarks","field" =>"remarks","formatter" =>"","type" =>"normal");
+
+        //Milestones 数据信息待定
+        $Milestones_data = array();
+        $Milestones_data_arr = common::excuteListSql("select description,act_date||act_time as date_time, remark from  ocean_milestone a 
+		 			where a.serial_no='".$ocean['serial_no']."' order by id");           
+        foreach($Milestones_data_arr as $mda){
+            $Milestones_data[] = array("milestones"=>$mda['description'],"date_time"=>$mda['date_time'],"locations" => "", "remarks" =>$mda['remark']);
+        }            
+        $Milestones = array("Milestones_column"=>$Milestones_column,"Milestones_data" =>$Milestones_data);
+
+        global $_COPYRIGHT;
+        $data = array('transportInfo' => $transportInfo, 
+                        'basicInfo' => $basicInfo,
+                        'businessPartners' => $businessPartners,
+                        'packing' => $packing,
+                        'marksAndDescription' => $marksAndDescription,
+                        'Milestones' => $Milestones,
+                        'copyright' =>$_COPYRIGHT);
+        return array("msg" =>"success","data" =>$data);
+    }
+
 }
 
 ?>

+ 4 - 4
service/ocean_booking.class.php

@@ -327,13 +327,13 @@ class ocean_booking {
             "Incoterm" =>$ocean['terms'],"Service_Type" =>$ocean['service']);
 
         //处理 拼接地址 ocean表单exp 字段无法精准分割电话和地址信息,只能从contacts表里查询
-        $shipper_address = $this->retStationInfo($ocean['sh_address_1'], $ocean['sh_address_2'], $ocean['sh_address_3'], $ocean['sh_address_4'], 
+        $shipper_address = common::retStationInfo($ocean['sh_address_1'], $ocean['sh_address_2'], $ocean['sh_address_3'], $ocean['sh_address_4'], 
             $ocean['sh_city'], $ocean['sh_state'], $ocean['sh_zipcode'], $ocean['sh_country']);
-        $consignee_address = $this->retStationInfo($ocean['cn_address_1'], $ocean['cn_address_2'], $ocean['cn_address_3'], $ocean['cn_address_4'], 
+        $consignee_address = common::retStationInfo($ocean['cn_address_1'], $ocean['cn_address_2'], $ocean['cn_address_3'], $ocean['cn_address_4'], 
             $ocean['cn_city'], $ocean['cn_state'], $ocean['cn_zipcode'], $ocean['cn_country']);
-        $origin_address = $this->retStationInfo($ocean['aa_address_1'], $ocean['aa_address_2'], $ocean['aa_address_3'], $ocean['aa_address_4'], 
+        $origin_address = common::retStationInfo($ocean['aa_address_1'], $ocean['aa_address_2'], $ocean['aa_address_3'], $ocean['aa_address_4'], 
             $ocean['aa_city'], $ocean['aa_state'], $ocean['aa_zipcode'], $ocean['aa_country']); 
-        $destination_address = $this->retStationInfo($ocean['dd_address_1'], $ocean['dd_address_2'], $ocean['dd_address_3'], $ocean['dd_address_4'], 
+        $destination_address = common::retStationInfo($ocean['dd_address_1'], $ocean['dd_address_2'], $ocean['dd_address_3'], $ocean['dd_address_4'], 
             $ocean['dd_city'], $ocean['dd_state'], $ocean['dd_zipcode'], $ocean['dd_country']);    
 
         $shipperPartners = array("company" =>$ocean['sh_company'],"address"=>$shipper_address,"phone"=>$ocean['sh_phone']);

+ 221 - 40
service/ocean_order.class.php

@@ -42,7 +42,6 @@ class ocean_order {
             $data['TrackingTableColumns'] = $BookingTableColumns;
             common::echo_json_encode(200,$data);
             exit();
-
         }
         /*
          * ocean order search
@@ -136,6 +135,124 @@ class ocean_order {
                 exit();
             }
         }
+
+        if ($operate == "ocean_vgm") {
+            if (!_canEdiVgm()) {
+                $data = array("msg" =>"Vgm Permission Error");
+                common::echo_json_encode(200, $data);
+                exit();
+            }
+            $serial_no = common::deCode(($_GET["a"]), 'D');
+            $sqlWhere = " and o.serial_no='" . $serial_no . "'";
+            $column = "*";
+            $schemas = $_GET["_schemas"];
+            if (empty($schemas)) {
+                $schemas = "public";
+            }
+            $ocean_info_sql = "select o.from_station as o_from_station, o.h_bol as o_h_bol, o.carrier_booking, o.m_vessel, o.m_voyage, to_char(o.f_etd, 'MM/DD/YYYY') as f_etd, to_char(o.m_eta, 'MM/DD/YYYY') as m_eta, v.*, o.master_base_number from "
+                    . "$schemas.ocean o left join $schemas.ocean_vgm v on o.serial_no=v.serial_no or o.master_base_number=v.master_base_number where 1=1  and o.status::text <> 'Cancelled'::text AND o.bol_type::text <> 'BOOKING'::text AND o.bol_type::text <> 'QUOTE'::text" . $sqlWhere;
+            $ocean_info = common::excuteObjectSql($ocean_info_sql);
+
+            $rs_sql = "select o.service, o.ctnr, v.carrier_booking_no, o.ctnr, o.size, v.vgm_weight, v.unit, v.vgm_time, v.vgm_method, o.grs_kgs, o.grs_lbs, ov.id as ocean_vgm_id, v.id as ocean_vgm_container_id from "
+                    . "$schemas.oc_container o left join $schemas.ocean oc on o.serial_no=oc.serial_no "
+                    . " left join $schemas.ocean_vgm ov on oc.serial_no=ov.serial_no or oc.master_base_number=ov.master_base_number "
+                    . " left join $schemas.ocean_vgm_container v on ov.serial_no=v.serial_no and o.ctnr=v.ctnr "
+                    . " where 1=1 and oc.status::text <> 'Cancelled'::text AND oc.bol_type::text <> 'BOOKING'::text AND oc.bol_type::text <> 'QUOTE'::text and oc.master_base_number='" . $ocean_info["master_base_number"] . "' and oc.from_station='" . $ocean_info["o_from_station"] . "'";
+            $rs = common::excuteListSql($rs_sql);
+            $ocean_info["is_send"] = (empty($ocean_info["is_send"]) ? "f" : $ocean_info["is_send"]);
+            if (empty($ocean_info["id"])) {
+                $ocean_info["is_send"] = "t";
+            }
+            $err_msg = "";
+            if (empty($ocean_info["carrier_booking"])) {
+                $err_msg = "Carrier Booking is empty.";
+            }
+            if ($schemas <> "public") {
+                $err_msg .= "This hbol do not support.";
+            }
+            foreach ($rs as $cv) {
+                if (empty($cv["ctnr"])) {
+                    $err_msg .= "Container# is empty.";
+                }
+                if (substr($cv["service"], 0, 3) == "CFS") {
+                    $err_msg .= "CFS cannot support update.";
+                }
+            }
+            if (!empty($err_msg)) {
+                $err_msg = "You cant't add this VGM, (" . $err_msg . ")";
+            }
+            $serial_no = common::deCode($serial_no, "E");
+
+            //default
+            if (empty($rs["id"])) {
+                $default = common::excuteObjectSql("select * from ocean_vgm_setting where login_name ilike '" . _getLoginName() . "'");
+            }
+
+            $log = common::excuteListSql("select * from ocean_vermas where from_serial_no ilike '" . $ocean_info["master_base_number"] . "'");
+
+            //detail  information 
+            $detail_information_column = array();
+            $detail_information_column[] = array("title" =>"SN","field" =>"sn","formatter" =>"","type" =>"normal");
+            $detail_information_column[] = array("title" =>"Carrier Booking No.","field" =>"carrier_booking_no","formatter" =>"","type" =>"normal");
+            $detail_information_column[] = array("title" =>"Container No","field" =>"ctnr","formatter" =>"","type" =>"normal");
+            $detail_information_column[] = array("title" =>"VGM Weight","field" =>"vgm_weight","formatter" =>"","type" =>"normal");
+            $detail_information_column[] = array("title" =>"VGM Unit","field" =>"unit","formatter" =>"","type" =>"normal");
+            $detail_information_column[] = array("title" =>"VGM Time","field" =>"vgm_time","formatter" =>"","type" =>"normal");
+            $detail_information_column[] = array("title" =>"VGM Method","field" =>"vgm_method","formatter" =>"","type" =>"normal");
+            foreach($rs as $rk => $rv){
+                $log[$rk]['sn'] = $rk +1;
+            }
+            $detail_information =array("detail_information_column" =>$detail_information_column,
+                "detail_information_data" =>$rs);
+
+            $data = array("msg" =>$err_msg);
+
+            $Submitter = $ocean_info["authorized_company"];
+            if(empty($ocean_info["id"])){
+                $Submitter = $default["submitter"];
+            }
+
+            $signature = $ocean_info["signature"];
+            if(empty($ocean_info["id"])){
+                $signature = $default["signature"];
+            }
+
+            $authorized_email = $ocean_info["authorized_email"];
+            if(empty($ocean_info["id"])){
+                $authorized_email = $default["authorized_email"];
+            }
+
+            $authorized_tel = $ocean_info["authorized_tel"];
+            if(empty($ocean_info["id"])){
+                $authorized_tel = $default["authorized_tel"];
+            }
+            
+            $data["general_information"] = array("HBL No."=>$ocean_info["o_h_bol"],
+                "Carrier Booking No."=>$ocean_info["carrier_booking"],
+                "Vessel"=>$ocean_info["m_vessel"],"Voyage"=>$ocean_info["m_voyage"],
+                "ETD"=>$ocean_info["f_etd"],"ETA"=>$ocean_info["m_eta"],
+                "Last updated User"=>$ocean_info["modify_user"],"Last updated Time"=>$ocean_info["modify_time"],
+                "Submitter" =>$Submitter,"$signature" =>$signature,"authorized_email" =>$authorized_email,"authorized_tel" =>$authorized_tel,"is_send" =>$ocean_info['is_send']);
+
+            $data["detail_information"] = $detail_information;
+            $data["schemas"] = $schemas;
+            $data["serial_no"] = $serial_no;
+
+            common::echo_json_encode(200, $data);
+            exit();
+        }
+
+        if ($operate == "save_ocean_vgm") {
+            if (!_canEdiVgm()) {
+                $data = array("msg" =>"Vgm Permission Error");
+                common::echo_json_encode(200, $data);
+                exit();
+            }
+            $msg = $this->save_vgm();
+            $data = array("msg" =>$msg);
+            common::echo_json_encode(200, $data);
+            exit();
+        }
     }
 
     /*
@@ -296,6 +413,7 @@ class ocean_order {
                'tagsList' => array(),
                'TransportList' => $TransportList,
                'allColums' => $allBookingColumns,
+               'canEdiVgm' => _canEdiVgm(),
                'rc' => $rc,
                'ps' => $ps,
                'cp' => $cp,
@@ -307,6 +425,7 @@ class ocean_order {
                 'tagsList' => array(),
                 'TransportList' => $TransportList,
                 'allColums' => $allBookingColumns,
+                'allColcanEdiVgmums' => _canEdiVgm(),
                 'rc' => $rc,
                 'ps' => $ps,
                 'cp' => $cp,
@@ -429,13 +548,13 @@ class ocean_order {
             "Incoterm" =>$ocean['terms'],"Service_Type" =>$ocean['service']);
 
         //处理 拼接地址 ocean表单exp 字段无法精准分割电话和地址信息,只能从contacts表里查询
-        $shipper_address = $this->retStationInfo($ocean['sh_address_1'], $ocean['sh_address_2'], $ocean['sh_address_3'], $ocean['sh_address_4'], 
+        $shipper_address = common::retStationInfo($ocean['sh_address_1'], $ocean['sh_address_2'], $ocean['sh_address_3'], $ocean['sh_address_4'], 
             $ocean['sh_city'], $ocean['sh_state'], $ocean['sh_zipcode'], $ocean['sh_country']);
-        $consignee_address = $this->retStationInfo($ocean['cn_address_1'], $ocean['cn_address_2'], $ocean['cn_address_3'], $ocean['cn_address_4'], 
+        $consignee_address = common::retStationInfo($ocean['cn_address_1'], $ocean['cn_address_2'], $ocean['cn_address_3'], $ocean['cn_address_4'], 
             $ocean['cn_city'], $ocean['cn_state'], $ocean['cn_zipcode'], $ocean['cn_country']);
-        $origin_address = $this->retStationInfo($ocean['aa_address_1'], $ocean['aa_address_2'], $ocean['aa_address_3'], $ocean['aa_address_4'], 
+        $origin_address = common::retStationInfo($ocean['aa_address_1'], $ocean['aa_address_2'], $ocean['aa_address_3'], $ocean['aa_address_4'], 
             $ocean['aa_city'], $ocean['aa_state'], $ocean['aa_zipcode'], $ocean['aa_country']); 
-        $destination_address = $this->retStationInfo($ocean['dd_address_1'], $ocean['dd_address_2'], $ocean['dd_address_3'], $ocean['dd_address_4'], 
+        $destination_address = common::retStationInfo($ocean['dd_address_1'], $ocean['dd_address_2'], $ocean['dd_address_3'], $ocean['dd_address_4'], 
             $ocean['dd_city'], $ocean['dd_state'], $ocean['dd_zipcode'], $ocean['dd_country']);    
 
         $shipperPartners = array("company" =>$ocean['sh_company'],"address"=>$shipper_address,"phone"=>$ocean['sh_phone']);
@@ -524,8 +643,14 @@ class ocean_order {
         $Milestones_column[] = array("title" =>"Date Time","field" =>"date_time","formatter" =>"","type" =>"normal");
         $Milestones_column[] = array("title" =>"Locations","field" =>"locations","formatter" =>"","type" =>"normal");
         $Milestones_column[] = array("title" =>"Remarks","field" =>"remarks","formatter" =>"","type" =>"normal");
-        //假数据
-        $Milestones_data = array(array("milestones"=>"booking submit","date_time"=>"2024-02-21","locations" => "china", "remarks" =>""));
+
+        //Milestones 数据信息待定
+        $Milestones_data = array();
+        $Milestones_data_arr = common::excuteListSql("select description,act_date||act_time as date_time, remark from  ocean_milestone a 
+		 			where a.serial_no='".$ocean["serial_no"]."' order by id");           
+        foreach($Milestones_data_arr as $mda){
+            $Milestones_data[] = array("milestones"=>$mda['description'],"date_time"=>$mda['date_time'],"locations" => "", "remarks" =>$mda['remark']);
+        }  
         $Milestones = array("Milestones_column"=>$Milestones_column,"Milestones_data" =>$Milestones_data);
 
         //页面固定写死的信息
@@ -753,39 +878,6 @@ class ocean_order {
         return $emialRecords;
     }
 
-    private function retStationInfo($address_1,$address_2,$address_3,$address_4,$city,$state,$country,$zipcode){
-        $stationInfo = "";
-        if(!empty($address_1)){
-            $stationInfo .= $address_1;
-        }
-        if(!empty($address_2)){
-            $stationInfo .= " ".$address_2;
-        }
-        if(!empty($address_3)){
-            $stationInfo .= " ".$address_3;
-        }
-        if(!empty($address_4)){
-            $stationInfo .= " ".$address_4;
-        }
-        $temp_str  = "";
-        if(!empty($city)){
-            $temp_str .= $city." ";
-        }
-        if(!empty($state)){
-            $temp_str .= $state." ";
-        }
-        if(!empty($zipcode)){
-            $temp_str .= $zipcode." ";
-        }
-        if(!empty($country)){
-            $temp_str .= $country." ";
-        }
-        if(!empty($temp_str)){
-            return $stationInfo." ".trim($temp_str);
-        }
-        return $stationInfo;
-    }
-
     /*
      * get file by hbol/destination
      * H:HBL
@@ -920,6 +1012,95 @@ class ocean_order {
 				 order by id desc limit 1) dd on true" . $sqlWhere.$Completed_sqlWhere;
         }
     }
+
+    private function save_vgm() {
+        $schemas = $_POST["schemas"];
+        $serial_no = common::deCode($_POST["serial_no"], 'D');
+        $ocean = common::excuteObjectSql("select m_bol, master_base_number, from_station, h_bol from $schemas.ocean where serial_no='" . common::check_input($serial_no) . "'");
+        $contact = common::excuteObjectSql("select company, city, state, zipcode, phone_1, fax, email_1, contactname_1, address_1, address_2, address_3, address_4 from ocean.contacts where contact_id='" . $ocean["from_station"] . "'");
+        $address = $contact["address_1"];
+        if (!empty($address)) {
+            $address .= "\r\n";
+        }
+        $address .= $contact["address_2"];
+        if (!empty($address)) {
+            $address .= "\r\n";
+        }
+        $address .= $contact["address_3"];
+        if (!empty($address)) {
+            $address .= "\r\n";
+        }
+        $address .= $contact["address_4"];
+
+        $exists = common::excuteOneSql("select serial_no from $schemas.ocean_vgm_masterbasenumber where master_base_number ilike '" . $ocean["master_base_number"] . "'");
+
+        global $db;
+        $db->StartTrans();
+        if (empty($_POST["is_send"])) {
+            $_POST["is_send"] = 'f';
+        }
+        if (empty($exists)) {
+            $db->Execute("insert into ocean_vgm_masterbasenumber (master_base_number, serial_no) values ('" . $ocean["master_base_number"] . "', '$serial_no');");
+            $value["serial_no"] = $serial_no;
+            $value["carrier_booking_no"] = $_POST["all_carrier_booking"];
+            $value["modify_user"] = _getLoginName();
+            $value["modify_time"] = "now()";
+            $value["authorized_email"] = !empty($_POST["authorized_email"]) ? $_POST["authorized_email"] : "";
+            $value["authorized_tel"] = !empty($_POST["authorized_tel"]) ? $_POST["authorized_tel"] : "";
+            $value["authorized_company"] = !empty($_POST["submitter"]) ? $_POST["submitter"] : "";
+            $value["signature"] = !empty($_POST["signature"]) ? $_POST["signature"] : "";
+            $value["is_send"] = $_POST["is_send"];
+            $value["action"] = "New";
+            $value["type"] = "Shipper";
+
+            $value["m_bol"] = $ocean["m_bol"];
+            $value["master_base_number"] = $ocean["master_base_number"];
+            $value["shipper_id"] = $ocean["from_station"];
+            $value["shipper"] = $contact["company"];
+            $value["shipper_address"] = $address;
+            $value["shipper_contactname"] = $contact["contactname_1"];
+            $value["shipper_email"] = $contact["email_1"];
+            $value["shipper_fax"] = $contact["fax"];
+            $value["shipper_telephone"] = $contact["phone_1"];
+            $value["update_uuid"] = utils::uuid();
+            $value["h_bol"] = $ocean["h_bol"];
+            $value["from_station"] = $ocean["from_station"];
+
+            $sql = common::getInsertSqlNull("$schemas .ocean_vgm", $value);
+            $db->Execute($sql);
+        } else {
+            $serial_no = $exists;
+            $db->Execute("update ocean_vgm_masterbasenumber set id=id where master_base_number ilike '" . $ocean["master_base_number"] . "';");
+
+            $db->Execute("update $schemas.ocean_vgm set is_send='" . $_POST["is_send"] . "', carrier_booking_no='" . $_POST["all_carrier_booking"] . "', modify_user='" . _getLoginName() . "', modify_time=now(),"
+                    . "authorized_email='" . $_POST["authorized_email"] . "', authorized_tel='" . $_POST["authorized_tel"] . "', authorized_company='" . $_POST["submitter"] . "', signature='" . $_POST["signature"] . "', send_time=null "
+                    . ", update_uuid='" . utils::uuid() . "' where master_base_number ilike '" . $ocean["master_base_number"] . "';");
+        }
+        $db->Execute("delete from ocean_vgm_container where serial_no ilike '" . $serial_no . "';");
+
+        foreach ($_POST["container_no"] as $i => $cv) {
+            $value1["serial_no"] = $serial_no;
+            $value1["carrier_booking_no"] = !empty($_POST["carrier_booking_no"][$i]) ? $_POST["carrier_booking_no"][$i] : "";
+            $value1["ctnr"] = !empty($_POST["container_no"][$i]) ? $_POST["container_no"][$i] : "";
+            $value1["size"] = !empty($_POST["size"][$i]) ? $_POST["size"][$i] : "";
+            $value1["vgm_weight"] = !empty($_POST["vgm_weight"][$i]) ? $_POST["vgm_weight"][$i] : "";
+            $value1["unit"] = !empty($_POST["vgm_kg_lg"][$i]) ? $_POST["vgm_kg_lg"][$i] : "";
+            $value1["vgm_time"] = !empty($_POST["vgm_date"][$i]) ? $_POST["vgm_date"][$i] : "";
+            $value1["cargo_weight_kgs"] = !empty($_POST["cargo_weight_kg"][$i]) ? $_POST["cargo_weight_kg"][$i] : "";
+            $value1["cargo_weight_lbs"] = !empty($_POST["cargo_weight_lb"][$i]) ? $_POST["cargo_weight_lb"][$i] : "";
+            $value1["vgm_method"] = !empty($_POST["vgm_method"][$i]) ? $_POST["vgm_method"][$i] : "";
+            $value1["master_base_number"] = $ocean["master_base_number"];
+
+            $sql = common::getInsertSqlNull("$schemas.ocean_vgm_container", $value1);
+            $db->Execute($sql);
+        }
+
+        if ($db->CompleteTrans() === FALSE) {
+            return "error";
+        } else {
+            return "success";
+        }
+    }
 }
 
 ?>

+ 64 - 0
service/tools.class.php

@@ -0,0 +1,64 @@
+<?php
+
+if (!defined('IN_ONLINE')) {
+    exit('Access Denied');
+}
+
+/**
+ * Description of operation_log
+ *
+ * @author Administrator
+ */
+class tools {
+
+    private static $_tools;
+
+    public static function getInstance() {
+        if (!self::$_tools) {
+            $c = __CLASS__;
+            self::$_tools = new $c;
+        }
+        return self::$_tools;
+    }
+
+    /*
+     * update password when login success
+    */
+     public function updatePassword() {
+        if ($_SESSION['ONLINE_USER']['is_demo'] == "t") {
+            $str = "DEMO cannot update password.";
+        } else {
+            $opsw = common::check_input($_POST ['opsw']);
+            $npsw = common::check_input($_POST ['npsw']);
+            if (empty(utils::checkPassword($npsw))) {
+                $username = _getLoginName();
+                $sql = "select ra_password as password from ra_online_user where lower(user_login) = '" . strtolower($username) . "'";
+                $rs = common::excuteObjectSql($sql);
+                $str = '';
+                if (!empty($rs)) {
+                    if ($rs['password'] == $opsw) {
+                        $sql = "UPDATE ra_online_user SET ra_password = '" . $npsw . "', last_pwd_change = now() WHERE lower(user_login) = '" . strtolower($username) . "'";
+                        $rls = common::excuteUpdateSql($sql);
+                        if (!$rls) {
+                            $str = "Password modification failed!";
+                        } else {
+                            $str = " Your password has been modified!";
+                        }
+                    } else {
+                        $str = "Old password is incorrect!";
+                    }
+                } else {
+                    $str = "Old password is incorrect!";
+                }
+            } else {
+                $str = "The new password is too simple(must include numbers and letters)";
+            }
+        }
+        $returnData = array("msg" => $str);
+        common::echo_json_encode(200, $returnData);
+        exit();
+    }
+    
+}
+
+?>

+ 70 - 0
utils/common.class.php

@@ -1292,5 +1292,75 @@ class common {
         setcookie(session_name(), '', time() - 3600);
         $_SESSION = array();
     }
+
+    public static function retStationInfo($address_1,$address_2,$address_3,$address_4,$city,$state,$country,$zipcode){
+        $stationInfo = "";
+        if(!empty($address_1)){
+            $stationInfo .= $address_1;
+        }
+        if(!empty($address_2)){
+            $stationInfo .= " ".$address_2;
+        }
+        if(!empty($address_3)){
+            $stationInfo .= " ".$address_3;
+        }
+        if(!empty($address_4)){
+            $stationInfo .= " ".$address_4;
+        }
+        $temp_str  = "";
+        if(!empty($city)){
+            $temp_str .= $city." ";
+        }
+        if(!empty($state)){
+            $temp_str .= $state." ";
+        }
+        if(!empty($zipcode)){
+            $temp_str .= $zipcode." ";
+        }
+        if(!empty($country)){
+            $temp_str .= $country." ";
+        }
+        if(!empty($temp_str)){
+            return $stationInfo." ".trim($temp_str);
+        }
+        return $stationInfo;
+    }
+
+    public static function getInsertSqlNull($table_name, $values) {
+        $field = "";
+        $value = "";
+        foreach ($values as $k => $v) {
+            if ($k == 'tmp' || $k == 'action' || $k == 'operate' || $k == 'x' || $k == 'y') {
+                continue;
+            }
+            if (is_array($v)) {
+                $v = implode(",", $v);
+            }
+            if (empty($field)) {
+                $field = $k;
+                if (utils::checkExist($v, 'now()')) {
+                    $value = $v;
+                } elseif ($v == null) {
+                    $value .= 'null';
+                } elseif ($v == 'TRUE' || $v == 'FALSE') {
+                    $value .= $v;
+                } else {
+                    $value = '\'' . common::check_input($v) . '\'';
+                }
+            } else {
+                $field .= ',' . $k;
+                if (utils::checkExist($v, 'now()'))
+                    $value .= ', now()';
+                elseif ($v == null) {
+                    $value .= ',null';
+                } else if ($v == 'TRUE' || $v == 'FALSE') {
+                    $value .= ',' . $v;
+                } else {
+                    $value .= ', \'' . common::check_input($v) . '\'';
+                }
+            }
+        }
+        return 'insert into ' . $table_name . '(' . $field . ') values (' . $value . ')';
+    }
 }
 ?>

+ 4 - 1
utils/utils.class.php

@@ -383,6 +383,9 @@ class utils {
         }
         return $interval;
     }
-}
 
+    public static function uuid() {
+        return strtoupper(md5(uniqid("", TRUE) . mt_rand()));
+    }
+}
 ?>