ShuanghongS 1 year ago
parent
commit
9b658b9c84
1 changed files with 6 additions and 7 deletions
  1. 6 7
      service/login.class.php

+ 6 - 7
service/login.class.php

@@ -1200,12 +1200,12 @@ class login {
     }
 
     private function getTrackingInfo($reference_number){
-        $reference_number = strtolower($reference_number);
+        $reference_number_lower = strtolower($reference_number);
         $sql = "with o as(
             SELECT  o.* 
                 from public.ocean o 
                 where o.status::text <> 'Cancelled'::text AND o.bol_type::text <> 'BOOKING'::text AND o.bol_type::text <> 'QUOTE'::text AND o.iscts = true 
-                    AND o.iscts IS NOT NULL and ARRAY['$reference_number'] && array_append(array[lower(tracking_no)::text,lower(booking_no)::text,lower(h_bol)::text,lower(m_bol)::text, lower(po_no),lower(quote_no)::text,lower(invoice_no)],'')
+                    AND o.iscts IS NOT NULL and ARRAY['$reference_number_lower'] && array_append(array[lower(tracking_no)::text,lower(booking_no)::text,lower(h_bol)::text,lower(m_bol)::text, lower(po_no),lower(quote_no)::text,lower(invoice_no)],'')
             union       
             SELECT  o.* 
                 from public.ocean o 
@@ -1231,7 +1231,6 @@ class login {
                     (select uncity from public.ports where uncode = oo.place_of_receipt_un limit 1) as por_uncity,
                     (select time_zone from public.city_timezone where uncode = oo.place_of_delivery_un limit 1) as pod_timezone,
                     (select uncity from public.ports where uncode = oo.place_of_delivery_un limit 1) as pod_uncity,
-                    po_no as _po_no,
                     CASE
                         WHEN ((m_iffbcf is not null or m_iffbcf is null) and m_iffcpu is null and m_iffrec is null and m_iffdep is null and m_iffarr is null and m_iffdel is null) THEN 'Created'::text
                         WHEN ((m_iffcpu is not null or m_iffrec is not null) and m_iffdep is null and m_iffarr is null and m_iffdel is null) THEN 'Cargo Received'::text
@@ -1432,21 +1431,22 @@ class login {
     }
 
     private function trackingSfsSql($reference_number){
+        $reference_number_lower = strtolower($reference_number);
         $sql = "with o as(
             SELECT  o.* 
                 from sfs.ocean o 
                 where o.status::text <> 'Cancelled'::text AND o.bol_type::text <> 'BOOKING'::text AND o.bol_type::text <> 'QUOTE'::text AND o.iscts = true 
-                    AND o.iscts IS NOT NULL and ARRAY['$reference_number'] && array_append(array[lower(tracking_no)::text,lower(booking_no)::text,lower(h_bol)::text,lower(m_bol)::text, lower(po_no),lower(quote_no)::text,lower(invoice_no)],'')
+                    AND o.iscts IS NOT NULL and ARRAY['$reference_number_lower'] && array_append(array[lower(tracking_no)::text,lower(booking_no)::text,lower(h_bol)::text,lower(m_bol)::text, lower(po_no),lower(quote_no)::text,lower(invoice_no)],'')
             union       
             SELECT  o.* 
                 from sfs.ocean o 
                 where o.status::text <> 'Cancelled'::text AND o.bol_type::text <> 'BOOKING'::text AND o.bol_type::text <> 'QUOTE'::text AND o.iscts = true 
-                    AND o.iscts IS NOT NULL and exists (select 1 from oc_container oc where o.serial_no = oc.serial_no and oc.ctnr = '$reference_number')
+                    AND o.iscts IS NOT NULL and exists (select 1 from sfs.oc_container oc where o.serial_no = oc.serial_no and oc.ctnr = '$reference_number')
         )
         SELECT m_eta as _m_eta,  h_bol as _h_bol, m_bol as _m_bol,job_no as _job_bol,
                 o.* ,sh.*, cn.* ,aa.*,dd.*,fd.*,oo.*,
                 (select uncode from ports where  code = o.port_of_transshipment) as port_of_transshipment_un
-            from sfs.ocean o 
+            from o
             LEFT JOIN LATERAL ( SELECT tracking_no as _tracking_no,shippr_uncode,shipper_city,
                     consignee_uncode,consignee_city,incoterms,
                     fport_of_loading_un,
@@ -1461,7 +1461,6 @@ class login {
                     (select uncity from public.ports where uncode = oo.place_of_receipt_un limit 1) as por_uncity,
                     (select time_zone from public.city_timezone where uncode = oo.place_of_delivery_un limit 1) as pod_timezone,
                     (select uncity from public.ports where uncode = oo.place_of_delivery_un limit 1) as pod_uncity,
-                    po_no as _po_no,
                     CASE
                         WHEN ((m_iffbcf is not null or m_iffbcf is null) and m_iffcpu is null and m_iffrec is null and m_iffdep is null and m_iffarr is null and m_iffdel is null) THEN 'Created'::text
                         WHEN ((m_iffcpu is not null or m_iffrec is not null) and m_iffdep is null and m_iffarr is null and m_iffdel is null) THEN 'Cargo Received'::text