ShuanghongS 3 сар өмнө
parent
commit
6915b3151f

+ 8 - 2
service/destination_delivery.class.php

@@ -1002,10 +1002,16 @@ class destination_delivery {
             $sql = "";
             //审核通过时,才取下放当时应用修改的地址
             if ($status == "Approve") {
-                $address_country = common::excuteOneSql("select array_to_json(address_country) as address_country from public.kln_destination_delivery where serial_no = '$serial_no'");
+                $delivery_booking = common::excuteObjectSql("select *,array_to_json(address_country) as address_country,
+                    array_to_json(h_serial_no) as h_serial_no_json from public.kln_destination_delivery where serial_no = '$serial_no'");
                 $onine_address = common::excuteListSql("select * from public.contacts_address_online where delivery_serial_no = '$serial_no'");
                 $sql .= "delete from public.contacts_address_online where delivery_serial_no = '$serial_no';";
-                $sql .=common::returnDAddressRecord($address_country,$onine_address);
+                $sql .=common::returnDAddressRecord($delivery_booking["address_country"],$onine_address);
+
+                //Booking自動同步到Ksmart WO 的逻辑   保存在do_header和do_details表里
+                $sql .=common::saveWorkOrder($delivery_booking);
+
+
             }
             if ($status == "Reject" || $status == "Cancel") {
                 //这种情况,清除当前用户对这一票的修改和添加的信息

+ 8 - 7
service/login.class.php

@@ -144,7 +144,7 @@ class login {
                     //如是是token登录,则不用验证密码
                     if(isset($_POST['token']) && !empty($_POST['token'])){
                         $is_verify = $_POST['token'];
-                        $AES_encrypted = utils::AES_encrypted($is_verify);
+                        $AES_encrypted = utils::AES_encrypted($is_verify,true,"USAIandy20244Q9X","0123456123456789");
                         $secret_key = common::excuteOneSql("select secret_key from customer_service_secret_key 
                             where secret_key = '$is_verify' 
                             and create_time >= current_date - INTERVAL '3 months' limit 1");
@@ -634,15 +634,15 @@ class login {
 
         $msg = "";
         if (!empty($email) || !empty($login)) {
-            $sql_p = "select User_Login, ra_password as password,user_type,
+            $sql_p = "select user_login, ra_password as password,user_type,
                     to_char(now(), 'Mon-DD-YYYY') as current_date,to_char(now(), 'Mon-DD-YYYY HH:mm:ss') as current_time
                 from public.ra_online_user where md5(lower(user_login)) = ? and md5(lower(email)) = ?";
             //$rs = common::excuteObjectSql($sql_p);
             $rs = common::excuteObjectPrepareSql($sql_p,[md5(strtolower($login)),md5(strtolower($email))]);
 
             if (!empty($rs)) {
-                $r = utils::sendEmailByPassword($login, $rs['password'], $email);
-                //$r = utils::sendEmailByResetPassword($rs, $email);
+                //$r = utils::sendEmailByPassword($login, $rs['password'], $email);
+                $r = utils::sendEmailByResetPassword($rs, $email);
                 if ($r == 'success') {
                     $msg = "success";
                 } else {
@@ -709,7 +709,7 @@ class login {
                         }
                     }
                     if (strtolower(Soure) =='apex'){
-                        $data = "<a href='mailto:maria.wang@apexshipping.com.cn'>maria.wang@apexshipping.com.cn</a>";
+                        $data = "<a href='mailto:maria.jj.wang@kln.com'>maria.jj.wang@kln.com</a>";
                     }
                     
                     $data = array(
@@ -1543,10 +1543,11 @@ class login {
         return $sql;
     }
 
-    private function resetAndActivateUpdate(){
+    public function resetAndActivateUpdate(){
         $verifcation_code = $_REQUEST['verifcation_code'];
-        $AES_encrypted = utils::AES_encrypted($verifcation_code);
+        $AES_encrypted = utils::AES_encrypted($verifcation_code,true,"USAIandy20244Q9X","0123456123456789");
 
+        //七天内有效
         $secret_key = common::excuteOneSql("select secret_key from customer_service_secret_key 
                         where secret_key = '$verifcation_code' 
                         and create_time >= current_date - INTERVAL '7 days' limit 1");

+ 4 - 0
service/tools.class.php

@@ -46,6 +46,10 @@ class tools {
                             $str = "Password modification failed!";
                         } else {
                             $str = " Your password has been modified!";
+                            //发送更新成功的邮件
+                            $user_type = $_SESSION['ONLINE_USER']['user_type'];
+                            $user_login = _getLoginName();
+                            utils::sendEmailWithPasswordUpdate($user_login,$user_type);
                         }
                     } else {
                         $str = "Old password is incorrect!";

+ 26 - 0
utils/common.class.php

@@ -3867,6 +3867,9 @@ class common {
         return $_sync_key_add;
     }
 
+    /**
+     * 审核通过时,才取下放当时应用修改的地址
+     */
     public static function returnDAddressRecord($address_country,$onine_address){
         //deliver address is new
         $addressSql = "";
@@ -3956,6 +3959,9 @@ class common {
     }
 
 
+    /**
+     * 当前save的地址信息
+     */
     public static function returnDAddress($_sync_key_add=""){
         //deliver address is new
         $$delivery_address = "";
@@ -3998,5 +4004,25 @@ class common {
         }
         return $delivery_address;
     }
+
+    /**
+     * Booking自動同步到Ksmart WO 的逻辑   保存在do_header和do_details表里
+     */
+    public static function saveWorkOrder($delivery_booking){
+        $h_serial_no_json  = $delivery_booking['h_serial_no_json'];
+        $h_serial_no_arr  =json_decode($h_serial_no_json,true);
+
+        $ctnr  = $delivery_booking['ctnr'];
+         
+        //从UI 设计的case来讲,一个hbol就生成成一个wo ID 
+        foreach($h_serial_no_arr as $serial_no){
+            $oceanInfo = common::excuteObjectSql("select (select manifest_type from public.ocean o where o.serial_no = ooc.serial_no  limit 1) as manifest_type
+                from public.kln_ocean oo where o.serial_no ='".$serial_no."'" );
+            $ctnr = common::excuteObjectSql("select ctnr,seal_no,size,qty,unit, FROM oc_container oc where oc.serial_no::text = '".$serial_no."' 
+                    and oc.ctnr in (select regexp_split_to_table('".$ctnr."', ','))" );
+
+
+        }
+    }
 }
 ?>

+ 60 - 21
utils/utils.class.php

@@ -353,18 +353,53 @@ class utils {
      * reset password link email   sendEmailByResetPassword
     */
     public static function sendEmailByResetPassword($data, $email) {
-        $sql = "select subject, ra_content as content from ra_online_email_tpl where lower(ra_type) = 'forgotpw'";
+        $sql = "select subject, ra_content as content from ra_online_email_tpl where lower(ra_type) = 'kln_reset'";
         $rs = common::excuteObjectSql($sql);
         if (!empty($rs)) {
             $subject = $rs['subject'];
             $content = $rs['content'];
         }
         if (!empty($subject) && !empty($content)) {
-        
-            $verifcation_code = utils::AES_128_CBC_Encrypt($data['User_Login']);
-            $link = SERVER_Vue_PAHT."login.php?action=login&operate=resetAndActivateInit&verifcation_code=".$verifcation_code;
+            $verifcation_code = utils::AES_128_CBC_Encrypt($data['user_login'],"USAIandy20244Q9X","0123456123456789");
+            //http://localhost:8080/k_new_online/login?state=reset&verifcation_code=XXX
+            $encoded = rawurlencode($verifcation_code);
+            $link = SERVER_Vue_PAHT."login?state=reset&name=".$data['user_login']."&verifcation_code=".$encoded;
+
+            $tplData = array("username"=>$data['user_login'],
+                "creation_date"=>$data['current_time'],
+                "link" =>$link);
+
+            // 动态构建替换数组(格式:[key] => value)
+            $replacements = [];
+            foreach ($tplData as $key => $value) {
+                $replacements["{{$key}}"] = $value; 
+                $replacements["{{{$key}}}"] = $value; 
+            }
+            $content = strtr($content, $replacements);
+            $content = common::check_input($content);
+
+            common::excuteUpdateSql("INSERT INTO public.email_record_forgotpassword(type, title, from_email, to_email, content, insert_date, 
+            cc_email) VALUES ('forgot_password', '" . common::check_input($subject) . "', 'US.KApex.Online@kerryapex.com', '" .
+                    common::check_input($email) . "', '" . $content . "', now(), '');
+                    INSERT INTO public.customer_service_secret_key(secret_key, create_time) VALUES('".$verifcation_code."',now())");
+            return "success";
+            //return Mail::sendMail($email, $subject, $content);
+        } else
+            return null;
+    }
 
-            if(strtolower($data['user_type']) == "employee"){
+    /**
+     * reset password link email   sendEmailByResetPassword
+    */
+    public static function sendEmailWithPasswordUpdate($user_login, $user_type) {
+        $sql = "select subject, ra_content as content from ra_online_email_tpl where lower(ra_type) = 'kln_passwordchange'";
+        $rs = common::excuteObjectSql($sql);
+        if (!empty($rs)) {
+            $subject = $rs['subject'];
+            $content = $rs['content'];
+        }
+        if (!empty($subject) && !empty($content)) {
+            if(strtolower($user_type) == "employee"){
                 $sql = "SELECT lower(ra_name) as ra_name, ra_value from ra_online_config where lower(ra_name) in ('employee_password_change_cycle')";
             } else {
                 $sql = "SELECT lower(ra_name) as ra_name, ra_value from ra_online_config where lower(ra_name) in ('customer_password_change_cycle')";
@@ -374,12 +409,15 @@ class utils {
             foreach ($rs1s as $rs1) {
                 $PASSWORD_CHANGE_CYCLE = $rs1['ra_value'];
             }
-            $expiry_date = common::excuteOneSql("select to_char((current_date + INTERVAL '".$PASSWORD_CHANGE_CYCLE." days'),'Mon-DD-YYYY');");
+            $dateInfo = common::excuteObjectSql("select 
+                to_char(now(), 'Mon-DD-YYYY') as current_date,
+                to_char(now(), 'Mon-DD-YYYY HH:mm:ss') as current_time,
+                to_char((current_date + INTERVAL '".$PASSWORD_CHANGE_CYCLE." days'),'Mon-DD-YYYY') as expiry_date ;");
 
-            $tplData = array("username"=>$data['User_Login'],
-                "creation_date"=>$data['current_time'],
-                "expiry_date"=>$expiry_date,
-                "link" =>$link);
+            $tplData = array("username"=>$user_login,
+                "creation_date"=>$dateInfo['current_time'],
+                "update_date"=>$dateInfo['current_date'],
+                "expiry_date"=>$dateInfo['expiry_date']);
 
             // 动态构建替换数组(格式:[key] => value)
             $replacements = [];
@@ -390,12 +428,13 @@ class utils {
             $content = strtr($content, $replacements);
             $content = common::check_input($content);
 
-            common::excuteUpdateSql("INSERT INTO public.email_record_forgotpassword(type, title, from_email, to_email, content, insert_date, 
-            cc_email) VALUES ('forgot_password', '" . common::check_input($subject) . "', 'US.KApex.Online@kerryapex.com', '" .
-                    common::check_input($email) . "', '" . common::check_input($content) . "', now(), '');
-                    insert customer_service_secret_key(secret_key,create_time) value('".$verifcation_code."',now())");
+            $email = _getLoginEamil();
+            $sql = "INSERT INTO email_record(type, title, from_email, to_email, content, insert_date, cc_email, attachment_path)
+                VALUES ('kln_passwordChange', '" . common::check_input($subject) . "', 'US.KApex.Online@kerryapex.com', '" .
+               common::check_input($email) . "', '" . common::check_input($content) . "', now(), '', '');";
+
+            common::excuteUpdateSql($sql);
             return "success";
-            //return Mail::sendMail($email, $subject, $content);
         } else
             return null;
     }
@@ -1646,10 +1685,10 @@ class utils {
     }
 
     //AES 加密
-    public static function AES_128_CBC_Encrypt($data){
-        $key = 'fT5!R1k$7Mv@4Q9X'; // 密钥应该是16字节(128位),24字节(192位)或32字节(256位)
+    public static function AES_128_CBC_Encrypt($data,$key = "fT5!R1k$7Mv@4Q9X",$iv = '1234567890123456'){
+        //$key = 'fT5!R1k$7Mv@4Q9X'; // 密钥应该是16字节(128位),24字节(192位)或32字节(256位)
         $method = 'AES-128-CBC';
-        $iv = '1234567890123456'; 
+        //$iv = '1234567890123456'; 
         // 加密
         $encrypted = openssl_encrypt($data, $method, $key, OPENSSL_RAW_DATA, $iv);
         // 编码为可打印的字符串,如Base64
@@ -1660,9 +1699,9 @@ class utils {
     /**
      * 解密decrypt
     */
-    public static function AES_encrypted($encrypted_string,$isbase64_encode = true){
-        $key = 'fT5!R1k$7Mv@4Q9X'; // 16 bytes key
-        $iv = '1234567890123456'; // 16 bytes IV
+    public static function AES_encrypted($encrypted_string,$isbase64_encode = true,$key = "fT5!R1k$7Mv@4Q9X",$iv = '1234567890123456'){
+        //$key = 'fT5!R1k$7Mv@4Q9X'; // 16 bytes key
+        //$iv = '1234567890123456'; // 16 bytes IV
         if($isbase64_encode){
             $decrypted = openssl_decrypt(base64_decode($encrypted_string), 'AES-128-CBC', $key, OPENSSL_RAW_DATA, $iv);
         }else{