ShuanghongS пре 2 недеља
родитељ
комит
97ae41b0dc
2 измењених фајлова са 375 додато и 76 уклоњено
  1. 367 73
      service/multilingual.class.php
  2. 8 3
      service/ocean_order.class.php

+ 367 - 73
service/multilingual.class.php

@@ -30,6 +30,50 @@ class multilingual{
     public function multilingual_config() {
     public function multilingual_config() {
         $operate = utils::_get('operate');
         $operate = utils::_get('operate');
         $operate = strtolower($operate);
         $operate = strtolower($operate);
+        /*
+         * multilingual_page_load
+        */
+        if ($operate == "multilingual_page") {
+            //查询指定语言
+            $langIds = [];
+            $langkey = $_POST['langkey'];
+
+            // 1. 统一处理 $langs 数组
+            if (empty($langkey) || strtoupper($langkey) == "ALL") {
+                // 如果没传或传 ALL,直接查询所有激活语言的 ID
+                // 优化点:直接查 id,不需要先查 key 再查 id
+                $langSql = "SELECT id FROM kln_i18n_languages"; 
+                $langRows = common::excuteListSql($langSql);
+                if ($langRows) {
+                    $langIds = array_column($langRows, 'id');
+                }
+            } else {
+                // 2. 如果指定了语言,使用 IN 查询一次性获取
+                $langs = explode(',', $langkey);
+                // 安全过滤:防止 SQL 注入,并确保只处理非空字符串
+                $safeLangs = array();
+                foreach ($langs as $l) {
+                    $l = trim($l);
+                    if (!empty($l)) {
+                        $safeLangs[] = "'" . common::check_input($l) . "'";
+                    }
+                }
+                if (!empty($safeLangs)) {
+                    // 拼接 IN 条件:('english', 'french')
+                    $inClause = implode(',', $safeLangs);
+                    $langSql = "SELECT id FROM kln_i18n_languages WHERE lang_key IN ($inClause)";
+                    $langRows = common::excuteListSql($langSql);
+                    if ($langRows) {
+                        $langIds = array_column($langRows, 'id');
+                    }
+                }
+            }
+
+            $pageData =  $this->_loadPageInfo($langIds);
+            $langData =  $this->_loadLangInfo($langIds);
+
+            common::echo_json_encode(200,array("pageData" =>$pageData,"langData" =>$langData));
+        }
 
 
         /*
         /*
          * multilingual_load
          * multilingual_load
@@ -39,39 +83,39 @@ class multilingual{
         }
         }
 
 
         if ($operate == "multilingual_search") {
         if ($operate == "multilingual_search") {
-            $this->_multilingual_search();
+            $result = $this->_multilingual_search();
+            common::echo_json_encode(200,$result);
         }
         }
 
 
         /*
         /*
          * multilingual_save
          * multilingual_save
          */
          */
         if ($operate == "multilingual_save") {
         if ($operate == "multilingual_save") {
-            $multilingual = $_POST['multilingual_param'];
-
-            $unverifiedNumber = $multilingual['unverifiedNumber'];
-            $page = $multilingual['page'];
-            $data = $multilingual['data'];
+            $multilingual_param = $_POST['multilingual_param'];
+            $this->_multilingual_save($multilingual_param);
         }
         }
     }
     }
 
 
-        private function _multilingual_init() {
+    private function _multilingual_init() {
         // 1. 获取并解析 JSON 数据
         // 1. 获取并解析 JSON 数据
-        $rawData = $_POST['josn_input'];
-        $mode = $_POST['mode'];
-        $json = json_decode($rawData, true);
+        $sql = "select * from public.kln_i18n_pages_init where page = 'login'";
+        $data = common::excuteObjectSql($sql);
+        $rawData = $data['data'];
+        $mode = "update";
 
 
+        $json = json_decode($rawData, true);
         if (!$json) {
         if (!$json) {
             common::echo_json_encode(500, "Invalid JSON format");
             common::echo_json_encode(500, "Invalid JSON format");
             exit();
             exit();
         }
         }
 
 
         // 获取控制模式,默认为 'update'
         // 获取控制模式,默认为 'update'
-        $mode = empty($mode) ? 'update' : 'replace';
+        $mode = $mode == 'replace' ? 'replace' : 'update';
 
 
-        $pageKey = isset($json['page']) ? $json['page'] : '';
+        $pageKey = isset($json['page']) ? common::check_input($json['page']) : '';
         $unverifiedNumber = isset($json['unverifiedNumber']) ? intval($json['unverifiedNumber']) : 0;
         $unverifiedNumber = isset($json['unverifiedNumber']) ? intval($json['unverifiedNumber']) : 0;
         $dataList = isset($json['data']) ? $json['data'] : [];
         $dataList = isset($json['data']) ? $json['data'] : [];
-
+        //tracking   report  booking    destinationDelivery
         if (empty($pageKey)) {
         if (empty($pageKey)) {
             common::echo_json_encode(500, "Missing page key");
             common::echo_json_encode(500, "Missing page key");
             exit();
             exit();
@@ -87,47 +131,44 @@ class multilingual{
             'portuguese'         => ['name' => '葡萄牙语', 'code' => 'pt-BR']
             'portuguese'         => ['name' => '葡萄牙语', 'code' => 'pt-BR']
         ];
         ];
 
 
-        // 开启事务
-        global $db;
+        global $db; 
         $db->StartTrans();
         $db->StartTrans();
-
         try {
         try {
-            // ==========================================
             // 第一步:处理页面表 (kln_i18n_pages)
             // 第一步:处理页面表 (kln_i18n_pages)
-            // ==========================================
             $pageId = null;
             $pageId = null;
 
 
-            // 如果是覆盖模式,先删除旧页面及关联数据
+            // --- 模式判断:如果是覆盖模式,先删除旧数据 ---
             if ($mode === 'replace') {
             if ($mode === 'replace') {
-                // 1. 先删子表 (kln_i18n_keys),防止外键报错
+                // 1. 先删子表 (kln_i18n_keys)
                 $kikSqlDelete = "DELETE FROM kln_i18n_keys WHERE page_id IN (SELECT id FROM kln_i18n_pages WHERE page_key = '$pageKey')";
                 $kikSqlDelete = "DELETE FROM kln_i18n_keys WHERE page_id IN (SELECT id FROM kln_i18n_pages WHERE page_key = '$pageKey')";
-                $db->GetRow($kikSqlDelete) or ( (!$db->ErrorMsg()) or error_log(common::dbLog($db, $kikSqlDelete), 0));
-                // 2. 再删主表
-                $kipSqlDelete = "DELETE FROM kln_i18n_pages WHERE page_key = '$pageKey'";
-                $db->GetRow($kipSqlDelete) or ( (!$db->ErrorMsg()) or error_log(common::dbLog($db, $kipSqlDelete), 0));
+                $db->Execute($kikSqlDelete) or ( (!$db->ErrorMsg()) or error_log(common::dbLog($db, $kikSqlDelete), 0));
+
+                // 2. 再删主表 (kln_i18n_pages) - 虽然上面删了子表,这里为了保险或者重置页面信息也可以删,
+                $delPageSql = "DELETE FROM kln_i18n_pages WHERE page_key = '$pageKey'";
+                $db->Execute($delPageSql) or ( (!$db->ErrorMsg()) or error_log(common::dbLog($db, $delPageSql), 0));
             }
             }
 
 
-            // 查询页面是否存在
+            // --- 查询页面是否存在 ---
             $checkPageSql = "SELECT id FROM kln_i18n_pages WHERE page_key = '$pageKey'";
             $checkPageSql = "SELECT id FROM kln_i18n_pages WHERE page_key = '$pageKey'";
-            $checkPageRes = common::excuteObjectSql($checkPageSql);
+            $checkPageRes =  $db->GetRow($checkPageSql) or ( (!$db->ErrorMsg()) or error_log(common::dbLog($db, $checkPageSql), 0));
             
             
             if (!empty($checkPageRes)) {
             if (!empty($checkPageRes)) {
                 // 存在 -> 更新
                 // 存在 -> 更新
-                $pageId = $checkPageRes[0]['id'];
+                $pageId = $checkPageRes['id'];
                 $updatePageSql = "UPDATE kln_i18n_pages SET unverified_number = $unverifiedNumber WHERE id = $pageId";
                 $updatePageSql = "UPDATE kln_i18n_pages SET unverified_number = $unverifiedNumber WHERE id = $pageId";
-                common::excuteObjectSql($updatePageSql);
+                $db->Execute($updatePageSql) or ( (!$db->ErrorMsg()) or error_log(common::dbLog($db, $updatePageSql), 0));
             } else {
             } else {
                 // 不存在 -> 插入
                 // 不存在 -> 插入
                 $insertPageSql = "INSERT INTO kln_i18n_pages (page_key, unverified_number, description) VALUES ('$pageKey', $unverifiedNumber, '')";
                 $insertPageSql = "INSERT INTO kln_i18n_pages (page_key, unverified_number, description) VALUES ('$pageKey', $unverifiedNumber, '')";
-                common::excuteObjectSql($insertPageSql);
-                // 获取新生成的 ID (PostgreSQL 语法)
-                $pageIdRow = common::excuteObjectSql("SELECT currval('kln_i18n_pages_id_seq')");
-                $pageId = $pageIdRow[0]['currval'];
+                $db->Execute($insertPageSql) or ( (!$db->ErrorMsg()) or error_log(common::dbLog($db, $insertPageSql), 0));
+                
+                // 获取新生成的 ID (PostgreSQL)
+                $seqSql = "SELECT currval('kln_i18n_pages_id_seq')";
+                $pageIdRow = $db->GetRow($seqSql) or ( (!$db->ErrorMsg()) or error_log(common::dbLog($db, $seqSql), 0));
+                $pageId = $pageIdRow['currval'];
             }
             }
 
 
-            // ==========================================
             // 第二步:循环处理数据
             // 第二步:循环处理数据
-            // ==========================================
             foreach ($dataList as $item) {
             foreach ($dataList as $item) {
                 $transKey = $item['key'];
                 $transKey = $item['key'];
                 $originValue = isset($item['orginEnglish']) ? $item['orginEnglish'] : '';
                 $originValue = isset($item['orginEnglish']) ? $item['orginEnglish'] : '';
@@ -135,84 +176,337 @@ class multilingual{
                 foreach ($langMap as $jsonKey => $langInfo) {
                 foreach ($langMap as $jsonKey => $langInfo) {
                     // 只处理 JSON 中存在的数据
                     // 只处理 JSON 中存在的数据
                     if (isset($item[$jsonKey])) {
                     if (isset($item[$jsonKey])) {
-                        $transValue = $item[$jsonKey];
+                        $transValue = common::check_input($item[$jsonKey]);
                         $statusKey = $jsonKey . 'Status';
                         $statusKey = $jsonKey . 'Status';
                         $status = isset($item[$statusKey]) ? intval($item[$statusKey]) : 0;
                         $status = isset($item[$statusKey]) ? intval($item[$statusKey]) : 0;
 
 
                         // --- 1. 处理语言表 (kln_i18n_languages) ---
                         // --- 1. 处理语言表 (kln_i18n_languages) ---
-                        $langKey = $jsonKey; 
-                        $langName = $langInfo['name'];
-                        $localeCode = $langInfo['code'];
+                        $langKey = common::check_input($jsonKey); 
+                        $langName = common::check_input($langInfo['name']);
+                        $localeCode = common::check_input($langInfo['code']);
 
 
                         // 查询语言是否存在
                         // 查询语言是否存在
                         $checkLangSql = "SELECT id FROM kln_i18n_languages WHERE lang_key = '$langKey'";
                         $checkLangSql = "SELECT id FROM kln_i18n_languages WHERE lang_key = '$langKey'";
-                        $checkLangRes = common::excuteObjectSql($checkLangSql);
+                        $checkLangRes = $db->GetRow($checkLangSql) or ( (!$db->ErrorMsg()) or error_log(common::dbLog($db, $checkLangSql), 0));
 
 
                         if (!empty($checkLangRes)) {
                         if (!empty($checkLangRes)) {
                             // 存在 -> 更新
                             // 存在 -> 更新
-                            $langId = $checkLangRes[0]['id'];
+                            $langId = $checkLangRes['id'];
                             $updateLangSql = "UPDATE kln_i18n_languages SET lang_name = '$langName', locale_code = '$localeCode' WHERE id = $langId";
                             $updateLangSql = "UPDATE kln_i18n_languages SET lang_name = '$langName', locale_code = '$localeCode' WHERE id = $langId";
-                            common::excuteObjectSql($updateLangSql);
+                            $db->Execute($updateLangSql) or ( (!$db->ErrorMsg()) or error_log(common::dbLog($db, $updateLangSql), 0));
                         } else {
                         } else {
                             // 不存在 -> 插入
                             // 不存在 -> 插入
-                            $insertLangSql = "INSERT INTO kln_i18n_languages (lang_key, lang_name, locale_code, is_active) VALUES ('$langKey', '$langName', '$localeCode', 1)";
-                            common::excuteObjectSql($insertLangSql);
+                            $insertLangSql = "INSERT INTO kln_i18n_languages (lang_key, lang_name, locale_code, is_active) VALUES ('$langKey', '$langName', '$localeCode', true)";
+                            $db->Execute($insertLangSql) or ( (!$db->ErrorMsg()) or error_log(common::dbLog($db, $updateLangSql), 0));
+                            
                             // 获取 ID
                             // 获取 ID
-                            $langIdRow = common::excuteObjectSql("SELECT currval('kln_i18n_languages_id_seq')");
-                            $langId = $langIdRow[0]['currval'];
+                            $seqLangSql = "SELECT currval('kln_i18n_languages_id_seq')";
+                            $langIdRow = $db->GetRow($seqLangSql) or ( (!$db->ErrorMsg()) or error_log(common::dbLog($db, $seqLangSql), 0));
+                            $langId = $langIdRow['currval'];
                         }
                         }
 
 
                         // --- 2. 处理词条表 (kln_i18n_keys) ---
                         // --- 2. 处理词条表 (kln_i18n_keys) ---
-                        // 查询词条是否存在 (根据 page_id, lang_id, trans_key 唯一性)
+                        // 查询词条是否存在
                         $checkKeySql = "SELECT id FROM kln_i18n_keys WHERE page_id = $pageId AND lang_id = $langId AND trans_key = '$transKey'";
                         $checkKeySql = "SELECT id FROM kln_i18n_keys WHERE page_id = $pageId AND lang_id = $langId AND trans_key = '$transKey'";
-                        $checkKeyRes = common::excuteObjectSql($checkKeySql);
+                        $checkKeyRes = $db->GetRow($checkKeySql) or ( (!$db->ErrorMsg()) or error_log(common::dbLog($db, $checkKeySql), 0));
 
 
                         if (!empty($checkKeyRes)) {
                         if (!empty($checkKeyRes)) {
                             // 存在 -> 更新
                             // 存在 -> 更新
-                            $updateKeySql = "UPDATE kln_i18n_keys SET trans_value = '$transValue', orgin_value = '$originValue', status = $status WHERE id = " . $checkKeyRes[0]['id'];
-                            common::excuteObjectSql($updateKeySql);
+                            $updateKeySql = "UPDATE kln_i18n_keys SET trans_value = '$transValue', orgin_value = '$originValue', status = $status WHERE id = " . $checkKeyRes['id'];
+                            $db->Execute($updateKeySql) or ( (!$db->ErrorMsg()) or error_log(common::dbLog($db, $updateKeySql), 0));
                         } else {
                         } else {
                             // 不存在 -> 插入
                             // 不存在 -> 插入
                             $insertKeySql = "INSERT INTO kln_i18n_keys (page_id, lang_id, trans_key, trans_value, orgin_value, status) VALUES ($pageId, $langId, '$transKey', '$transValue', '$originValue', $status)";
                             $insertKeySql = "INSERT INTO kln_i18n_keys (page_id, lang_id, trans_key, trans_value, orgin_value, status) VALUES ($pageId, $langId, '$transKey', '$transValue', '$originValue', $status)";
-                            common::excuteObjectSql($insertKeySql);
+                            $db->Execute($insertKeySql) or ( (!$db->ErrorMsg()) or error_log(common::dbLog($db, $insertKeySql), 0));
                         }
                         }
                     }
                     }
                 }
                 }
             }
             }
 
 
-            // 提交事务
-            common::excuteObjectSql("COMMIT");
-            common::echo_json_encode(200, "Initialization successful (Mode: $mode)");
-
         } catch (Exception $e) {
         } catch (Exception $e) {
-            // 发生错误回滚
-            common::excuteObjectSql("ROLLBACK");
-            common::echo_json_encode(500, "Database Error: " . $e->getMessage());
+            // 捕获异常,标记错误,以便回滚
+            error_log("Exception in multilingual_init: " . $e->getMessage());
         }
         }
-        
+        // 结束事务
+        if ($db->CompleteTrans() === FALSE) {
+            $msg = 'Save Error';
+        } else {
+            $msg = 'Save Success';
+        }
+        common::echo_json_encode(200, $msg);
         exit();
         exit();
     }
     }
         
         
+    /**
+     * 根据传入的 page_key 查询多语言信息并组装成 JSON 格式
+     * 支持多个页面查询,将所有数据整合到一个 data 数组中
+     *
+     * @param string|array $pageKey 页面标识 (例如 'login' 或 ['login', 'register'])
+     * @return array 返回组装好的数组 (通常最后会 json_encode 输出)
+    */
+    public function _multilingual_search() {
+
+        $pageKey = $_POST['pagekey'];
+        $pageIds = [];
+        // 1. 统一处理 $pageIds 数组
+        if (empty($pageKey) || strtoupper($pageKey) == "ALL") {
+            // 如果没传或传 ALL,直接查询所有页面的 ID
+            $pageSql = "SELECT id FROM kln_i18n_pages";
+            $pageRows = common::excuteListSql($pageSql);
+            
+            if ($pageRows) {
+                $pageIds = array_column($pageRows, 'id');
+            }
+        } else {
+            // 2. 如果指定了页面,使用 IN 查询一次性获取
+            $pages = explode(',', $pageKey);
+            // 安全过滤:防止 SQL 注入,并确保只处理非空字符串
+            $safePages = array();
+            foreach ($pages as $p) {
+                $p = trim($p);
+                if (!empty($p)) {
+                    $safePages[] = "'" . common::check_input($p) . "'";
+                }
+            }
+            if (!empty($safePages)) {
+                $inClause = implode(',', $safePages);
+                // 优化点:一次查询获取所有匹配的 ID 和 unverified_number
+                $pageSql = "SELECT id, unverified_number FROM kln_i18n_pages WHERE page_key IN ($inClause)";
+                $pageRows = common::excuteListSql($pageSql);
+                
+                if ($pageRows) {
+                    $pageIds = array_column($pageRows, 'id');
+                }
+            }
+        }
+        // 3. 如果没有找到任何页面,返回空数组
+        if (empty($pageIds)) {
+            return array();
+        }
 
 
+        //查询指定语言
+        $langIds = [];
+        $langkey = $_POST['langKey'];
+        // 1. 统一处理 $langs 数组
+        if (empty($langkey) || strtoupper($langkey) == "ALL") {
+            // 如果没传或传 ALL,直接查询所有激活语言的 ID
+            // 优化点:直接查 id,不需要先查 key 再查 id
+            $langSql = "SELECT id FROM kln_i18n_languages"; 
+            $langRows = common::excuteListSql($langSql);
+                
+            if ($langRows) {
+                $langIds = array_column($langRows, 'id');
+            }
+        } else {
+            // 2. 如果指定了语言,使用 IN 查询一次性获取
+            $langs = explode(',', $langkey);
+            // 安全过滤:防止 SQL 注入,并确保只处理非空字符串
+            $safeLangs = array();
+            foreach ($langs as $l) {
+                $l = trim($l);
+                if (!empty($l)) {
+                    $safeLangs[] = "'" . common::check_input($l) . "'";
+                }
+            }
+            if (!empty($safeLangs)) {
+                // 拼接 IN 条件:('english', 'french')
+                $inClause = implode(',', $safeLangs);
+                $langSql = "SELECT id FROM kln_i18n_languages WHERE lang_key IN ($inClause)";
+                $langRows = common::excuteListSql($langSql);
+                if ($langRows) {
+                    $langIds = array_column($langRows, 'id');
+                }
+            }
+        }
 
 
-    private function _multilingual_search() {
-        $page = common::check_input($_POST ['page']); 
-        $sql = "SELECT *  from public.i18n_content where page = '$page'";
-        $content = common::excuteObjectSql($sql);
-
-        if(empty($content)){
-            common::echo_json_encode(500,"Page not exist");
-            exit();
+        // 4. 查询所有指定页面的翻译词条(一次查询获取所有数据)
+        $sql = "SELECT 
+                    k.trans_key, 
+                    k.trans_value, 
+                    k.status, 
+                    k.orgin_value,
+                    l.lang_key,
+                    p.page_key AS key_page
+                FROM kln_i18n_keys k
+                JOIN kln_i18n_languages l ON k.lang_id = l.id
+                JOIN kln_i18n_pages p ON k.page_id = p.id
+                WHERE k.page_id IN (" . implode(',', $pageIds) . ")
+                AND k.lang_id IN (" . implode(',', $langIds) . ")
+                ORDER BY k.trans_key, p.page_key";
+        
+        $rows = common::excuteListSql($sql);
+        
+        if ($rows === FALSE) {
+            return array();
         }
         }
         
         
-        $multilingual = array();
-        $multilingual["unverifiedNumber"] = $content['unverifinumber'];
-        $multilingual["page"] = $page;
-        $multilingual["data"] = json_decode($content['content_data'],true);
-       
-        common::echo_json_encode(200,$multilingual);
+        // 5. 数据重组(核心逻辑)
+        $dataMap = array();
+        
+        foreach ($rows as $row) {
+            $key = $row['trans_key'];
+            $langKey = $row['lang_key'];
+            
+            // 如果这个 key 还没初始化,先初始化
+            if (!isset($dataMap[$key])) {
+                $dataMap[$key] = array(
+                    'key' => $key,
+                    'key_page' => $row['key_page']  // 记录所属页面
+                );
+            }
+            
+            // 动态填充语言字段
+            $dataMap[$key][$langKey] = $row['trans_value'];
+            
+            // 填充状态字段
+            $dataMap[$key][$langKey . 'Status'] = intval($row['status']);
+            
+            // 填充原始值(如果有)
+            //if (!empty($row['orgin_value'])) {
+            $dataMap[$key]['orginEnglish'] = $row['orgin_value'];
+            //}
+        }
+        
+        // 6. 将 Map 转换为数组列表
+        $dataList = array_values($dataMap);
+        
+        // 7. 组装最终结果
+        $result = array(
+            'page'             => $pageKey,  
+            'data'             => $dataList
+        );
+
+        //重新查询一下page load
+        $pageData =  $this->_loadPageInfo($langIds);
+        $result['pageData'] = $pageData;
+
+        $langData =  $this->_loadLangInfo($langIds,$pageIds);
+        $result['langData'] = $langData;
+        return $result;
+    }
+
+    /**
+     * 保存多语言数据
+     * 
+     * @param array $multilingual_param 页面未审核数量参数,格式:[{unverifiedNumber: 3, page: 'login'}, ...]
+     * @param array $multilingual_trans_param 翻译状态参数,格式:[{page: 'login', lang: 'traditionalChinese', trans_key: 'username', status: 1}, ...]
+     * @return bool 是否保存成功
+     */
+    public function _multilingual_save($multilingual_param) {
+        global $db;
+        try {
+            // 开启事务确保数据一致性
+            $db->StartTrans();
+            //2. 处理翻译词条状态更新
+            foreach ($multilingual_param as $param) {
+                $pageKey = common::check_input($param['page']);
+                $langKey = common::check_input($param['lang']);
+                $transKey = common::check_input($param['trans_key']);
+                $trans_value = common::check_input($param['trans_value']);
+                $status = $param['status'];
+                
+                // 查询页面ID
+                $pageSql = "SELECT id FROM kln_i18n_pages WHERE page_key = '".$pageKey."'";
+                $pageId = $db->GetOne($pageSql);
+                if (!$pageId) {
+                    throw new Exception("Page not found: " . $pageKey);
+                }
+                
+                // 查询语言ID
+                $langSql = "SELECT id FROM kln_i18n_languages WHERE lang_key = '".$langKey."'";
+                $langId = $db->GetOne($langSql);
+                if (!$langId) {
+                    throw new Exception("Language not found: " . $langKey);
+                }
+                // 更新翻译状态
+                $updateTransSql = "UPDATE kln_i18n_keys SET status = $status, trans_value = '$trans_value' ".
+                                " WHERE page_id = " . $pageId . 
+                                " AND lang_id = " . $langId . 
+                                " AND trans_key = '".$transKey."'";
+                $db->Execute($updateTransSql);
+            }
+        } catch (Exception $e) {
+            // 捕获异常,标记错误,以便回滚
+            error_log("Exception in multilingual_save: " . $e->getMessage());
+        }
+        // 结束事务
+        if ($db->CompleteTrans() === FALSE) {
+            $msg = 'Save Error';
+        } else {
+            $msg = 'Save Success';
+        }
+        common::echo_json_encode(200, $msg);
         exit();
         exit();
-    }  
+    }
+
+
+    /**
+     *  load page info
+    */
+    public function _loadPageInfo($langIds){
+        $pageSql = "SELECT 
+                (select page_key from public.kln_i18n_pages where id = page_id) as page_key,
+                COUNT(*) AS unverified_count
+            FROM (
+                    SELECT 
+                        page_id,
+                        trans_key,
+                        BOOL_OR(status = 0) AS all_unverified
+                    FROM kln_i18n_keys
+                    WHERE lang_id IN (" . implode(',', $langIds) . ")
+                    GROUP BY page_id, trans_key
+                ) AS subquery
+            WHERE all_unverified = TRUE GROUP BY page_id;";
+
+        $pageData = common::excuteListSql($pageSql);
+        $unverified_count = 0;
+        foreach($pageData as $_pageData){
+            $unverified_count += $_pageData['unverified_count'];
+        }
+        $newItem = [
+            'page_key' => 'all', 
+            'unverified_count' =>$unverified_count
+        ];
+        // 将新数组插入到 $pageDate 的开头
+        array_unshift($pageData, $newItem);
+
+        return $pageData;
+    }
+
+    /**
+     *  load lang info
+    */
+    public function _loadLangInfo($langIds,$pageIds = array()){
+
+        $page_id_sql = "";
+        if(!empty($pageIds)){
+            $page_id_sql = "AND k.page_id IN (" . implode(',', $pageIds) . ")";
+        }
+
+        $langSql = "SELECT 
+            l.lang_key, 
+            COUNT(k.id) AS unverified_count
+        FROM kln_i18n_languages l
+        LEFT JOIN kln_i18n_keys k ON l.id = k.lang_id 
+            $page_id_sql  
+            AND k.status = 0    
+        WHERE 
+            l.is_active = TRUE
+            AND l.id IN (" . implode(',', $langIds) . ")
+        GROUP BY 
+            l.id, l.lang_key, l.lang_name;";
+
+        $langData = common::excuteListSql($langSql);
+
+        $unverified_count = 0;
+        $retLangData = array('all'=>0);
+        foreach($langData as $_langData){
+            $unverified_count += $_langData['unverified_count'];
+            $retLangData[$_langData['lang_key']] = intval($_langData['unverified_count']);
+        }
+        $retLangData['all'] =$unverified_count; 
+        return $retLangData;
+    }
 }
 }
 
 
 ?>
 ?>

+ 8 - 3
service/ocean_order.class.php

@@ -2322,6 +2322,8 @@ class ocean_order {
                     (select uncity from $order_from.ports where uncode = oo.final_desination_uncode limit 1) as _pd_uncity,
                     (select uncity from $order_from.ports where uncode = oo.final_desination_uncode limit 1) as _pd_uncity,
                     invoice_no as _invoice_no,
                     invoice_no as _invoice_no,
                     oo.po_no,
                     oo.po_no,
+                    oo.voyage as oo_voyage,
+                    oo.vessel as oo_vessel,
                     CASE
                     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_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
                         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
@@ -2646,9 +2648,12 @@ class ocean_order {
             "ata_timezone" =>$ocean['mpod_timezone']);
             "ata_timezone" =>$ocean['mpod_timezone']);
         $data['transportInfo'] = $transportInfo;
         $data['transportInfo'] = $transportInfo;
 
 
-        //处理basicInfo信息数据
-        $vessel = utils::outDisplayForMerge($ocean['f_vessel'],$ocean['m_vessel']);
-        $voyage = utils::outDisplayForMerge($ocean['f_voyage'],$ocean['m_voyage']);
+        //处理basicInfo信息数据 --改为前端一样 同步 KLN_ocean
+        //$vessel = utils::outDisplayForMerge($ocean['f_vessel'],$ocean['m_vessel']);
+        //$voyage = utils::outDisplayForMerge($ocean['f_voyage'],$ocean['m_voyage']);
+        $$vessel = utils::outDisplayForMerge($val['f_vessel'],$val['oo_vessel']);
+        $$voyage = utils::outDisplayForMerge($val['f_voyage'],$val['oo_voyage']);
+
         $basicInfo = array("MAWB/MBL No." =>$ocean['m_bol'],"HAWB/HBOL" => $ocean['h_bol'],"Carrier_Booking_No" =>$ocean['booking_no'],
         $basicInfo = array("MAWB/MBL No." =>$ocean['m_bol'],"HAWB/HBOL" => $ocean['h_bol'],"Carrier_Booking_No" =>$ocean['booking_no'],
             "PO_NO" =>$ocean['_po_no'],"Vessel/Airline" =>$vessel,"Voyage/Filght" =>$voyage,
             "PO_NO" =>$ocean['_po_no'],"Vessel/Airline" =>$vessel,"Voyage/Filght" =>$voyage,
             "Incoterm" =>$ocean['incoterms'],"Service_Type" =>$ocean['service'],
             "Incoterm" =>$ocean['incoterms'],"Service_Type" =>$ocean['service'],