|
|
@@ -350,46 +350,162 @@ class utils {
|
|
|
//排除opreation_log操作
|
|
|
if($_REQUEST["action"] == "opreation_log"
|
|
|
|| empty($_REQUEST["operate"])
|
|
|
- || ($_REQUEST["action"] == "login" && $_REQUEST["operate"] == "verifcation_code")){
|
|
|
+ || ($_REQUEST["action"] == "login" && $_REQUEST["operate"] == "verifcation_code")
|
|
|
+ || ($_REQUEST["action"] == "login" && $_REQUEST["operate"] == "check_uname")
|
|
|
+ || ($_REQUEST["action"] == "ocean_order" && $_REQUEST["operate"] == "setting_ocean_order_display")
|
|
|
+ || ($_REQUEST["action"] == "ocean_booking" && $_REQUEST["operate"] == "setting_display")){
|
|
|
return;
|
|
|
}
|
|
|
$user_type = _isCustomerLogin() ? "Customer" : "Employee";
|
|
|
- $user_name = _getLoginName();
|
|
|
+ if($_REQUEST["action"] == "login" && $_REQUEST["operate"] == "tracking_checked"){
|
|
|
+ //public tracking_checked 的user name 记录对应IP 地址
|
|
|
+ $user_name = common::ip();
|
|
|
+ } elseif($_REQUEST["action"] == "login" && $_REQUEST["operate"] == "do_login"){
|
|
|
+ $user_name = $_REQUEST["uname"];
|
|
|
+ } else{
|
|
|
+ $user_name = _getLoginName();
|
|
|
+ }
|
|
|
|
|
|
- $operateInfo = utils::getPageByAction($_REQUEST["action"],$_REQUEST["operate"]);
|
|
|
+ $operateInfo = utils::getPageByAction($_REQUEST["action"],$_REQUEST["operate"],$_REQUEST["model_name"]);
|
|
|
$page = $operateInfo["page"];
|
|
|
$operation = $operateInfo["operate"];
|
|
|
- $operation_detail = common::check_input(utils::jsonFiltration("null", "\"\"", json_encode($_REQUEST)));
|
|
|
- $sql = "INSERT INTO public.customer_service_operation_log(user_type, user_name, page, operation, operation_detail,
|
|
|
- operation_time)
|
|
|
- VALUES ('$user_type', '$user_name', '$page', '$operation', '$operation_detail', now())";
|
|
|
- common::excuteUpdateSql($sql);
|
|
|
+ $operation_detail = utils::analyzeOperationDetail($_REQUEST["action"],$_REQUEST["operate"]);
|
|
|
+ if(empty($operation_detail)){
|
|
|
+ $operation_detail = common::check_input(utils::jsonFiltration("null", "\"\"", json_encode($_REQUEST)));
|
|
|
+ }
|
|
|
+ //过滤一分钟以内,相同用户的重复请求
|
|
|
+ $exist_sql = "select count(1) from public.customer_service_operation_log
|
|
|
+ where user_name = '$user_name'
|
|
|
+ and page = '$page' and operation = '$operation' and operation_detail = '$operation_detail'
|
|
|
+ and operation_time > NOW() - INTERVAL '1 minute' limit 1;";
|
|
|
+ $exist_obj = common::excuteOneSql($exist_sql);
|
|
|
+ if(empty($exist_obj)){
|
|
|
+ $sql = "INSERT INTO public.customer_service_operation_log(user_type, user_name, page, operation, operation_detail,
|
|
|
+ operation_time)
|
|
|
+ VALUES ('$user_type', '$user_name', '$page', '$operation', '$operation_detail', now())";
|
|
|
+ common::excuteUpdateSql($sql);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
- public static function getPageByAction($action,$operate){
|
|
|
+ public static function getPageByAction($action,$operate,$model_name){
|
|
|
//取消
|
|
|
$operationConvertName = array(
|
|
|
"login=do_login" => array("page" =>"Login","operate"=>"Login"),
|
|
|
"login=logout" => array("page" =>"logout","operate"=>"logout"),
|
|
|
"login=update_pwd_expires" => array("page" =>"Login","operate"=>"Reset password"),
|
|
|
"ocean_booking=search" => array("page" =>"Booking","operate"=>"Search"),
|
|
|
- "ocean_booking=setting_display" => array("page" =>"Booking","operate"=>"Customize Coulumns"),
|
|
|
+ "Booking_Search=save_setting_display" => array("page" =>"Booking","operate"=>"Customize Coulumns"),
|
|
|
"ocean_booking=detail" => array("page" =>"Booking","operate"=>"Open Detailed Page"),
|
|
|
"ocean_booking=excel" => array("page" =>"Booking","operate"=>"Download"),
|
|
|
"ocean_booking=save_communication" => array("page" =>"Booking","operate"=>"Send Email"),
|
|
|
|
|
|
"login=tracking_checked" => array("page" =>"Tracking","operate"=>"Public tracking"),
|
|
|
"ocean_order=search" => array("page" =>"Tracking","operate"=>"Search"),
|
|
|
- "ocean_order=setting_display" => array("page" =>"Tracking","operate"=>"Customize Coulumns"),
|
|
|
+ "Ocean_Search=save_setting_display" => array("page" =>"Tracking","operate"=>"Customize Coulumns"),
|
|
|
"ocean_order=detail" => array("page" =>"Tracking","operate"=>"Open Detailed Page"),
|
|
|
"ocean_order=excel" => array("page" =>"Tracking","operate"=>"Download"),
|
|
|
"ocean_booking=save_communication" => array("page" =>"Tracking","operate"=>"Send Email"),
|
|
|
+ "ocean_booking=ams_isf_log" => array("page" =>"Tracking","operate"=>"AMS/ISF"),
|
|
|
|
|
|
"password=" => array("page" =>"Profile","operate"=>"Change password"));
|
|
|
-
|
|
|
+ if($action == "ajax" && $operate == "save_setting_display"){
|
|
|
+ return $operationConvertName[$model_name."=".$operate];
|
|
|
+ }
|
|
|
return $operationConvertName[$action."=".$operate];
|
|
|
}
|
|
|
|
|
|
+ public static function analyzeOperationDetail($action,$operate){
|
|
|
+ if($action == "login" && $operate == "do_login"){
|
|
|
+ $detail = 'System account';
|
|
|
+ }
|
|
|
+ if($action == "login" && $operate == "logout"){
|
|
|
+ $detail = 'User Logout';
|
|
|
+ }
|
|
|
+ if($action == "login" && $operate == "tracking_checked"){
|
|
|
+ $detail = 'Join public tracking action';
|
|
|
+ }
|
|
|
+ if($action == "password"){
|
|
|
+ $detail = 'User Change password';
|
|
|
+ }
|
|
|
+ if(($action == "ocean_booking" || $action == "ocean_order") && $operate == "search"){
|
|
|
+ $detail = "";
|
|
|
+ //还有一个同以分钟内,不记录相同的查询 这个需要建表查询
|
|
|
+ //{"action":"ocean_booking","operate":"search","_ntype":"ocean_booking","cp":"1","ps":"100","rc":"-1","other_filed":"","uname":"ra.admin","psw":"abc123456789"}
|
|
|
+ $filter_common_field = array("action","operate","_ntype","cp","ps","rc","other_filed","uname","psw");
|
|
|
+ foreach($_REQUEST as $selected_key => $selected){
|
|
|
+ if(!utils::in_array($selected_key, $filter_common_field)){
|
|
|
+ if(is_array($selected)){
|
|
|
+ $selected = utils::implode(",",$selected);
|
|
|
+ }
|
|
|
+ $detail .="$selected_key:".$selected."; ";
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(empty($detail)){
|
|
|
+ $detail .="No search condition";
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if($action == "ajax" && $operate == "save_setting_display"){
|
|
|
+ $detail = "";
|
|
|
+ $type = $_REQUEST['model_name'] == "Booking_Search" ? "Booking_Search" : "Ocean_Search";
|
|
|
+ //记录最终save 和 default 字段相比的结果
|
|
|
+ $default_ids = common::excuteListSql("select id,display_name from public.ra_online_search_display_cso where model_name = '$type'
|
|
|
+ and display_name in('Booking No.','MBL No.','HBL No.','Transportation Mode','Status',
|
|
|
+ 'Shipper','Consignee','Origin Agent','Destination Agent','Creation Time','ETD','ETA',
|
|
|
+ 'Voyage','Vessel','Week','Created by') order by default_order");
|
|
|
+
|
|
|
+ $ids = utils::implode(";", $_POST['ids']);
|
|
|
+ $save_ids = common::excuteListSql("select id,display_name from public.ra_online_search_display_cso where model_name = '$type'
|
|
|
+ and id::text = any(regexp_split_to_array('$ids', ';')) order by default_order");
|
|
|
+
|
|
|
+ $detele_detail = "";
|
|
|
+ foreach($default_ids as $did){
|
|
|
+ if(!utils::exist_array($did['id'],$save_ids)){
|
|
|
+ $detele_detail .=$did['display_name']."/";
|
|
|
+ }
|
|
|
+ }
|
|
|
+ $add_detail = "";
|
|
|
+ foreach($save_ids as $sid){
|
|
|
+ if(!utils::exist_array($sid['id'],$default_ids)){
|
|
|
+ $add_detail .=$sid['display_name']."/";
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(!empty($detele_detail)){
|
|
|
+ $detail.="Detele fields: (".$detele_detail."). ";
|
|
|
+ }
|
|
|
+ if(!empty($add_detail)){
|
|
|
+ $detail.="Add fields: (".$add_detail."). ";
|
|
|
+ }
|
|
|
+ if(empty($detail)){
|
|
|
+ $detail = "The default field has not changed";
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if(($action == "ocean_booking" || $action == "ocean_order") && $operate == "detail"){
|
|
|
+ $tabel = $action == "ocean_booking" ? "online_booking" : "online_ocean";
|
|
|
+ $serial_no = common::deCode($_GET['a'], 'D');
|
|
|
+ $sql = "SELECT booking_no,h_bol from public.$tabel where serial_no = '$serial_no' limit 1";
|
|
|
+ $data = common::excuteObjectSql($sql);
|
|
|
+ if(!empty($data['booking_no'])){
|
|
|
+ $detail = 'Booking No.: '.$data['booking_no'];
|
|
|
+ }else{
|
|
|
+ $detail = 'HBOL: '.$data['h_bol'];
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if(($action == "ocean_booking" || $action == "ocean_order") && $operate == "save_communication"){
|
|
|
+ $text = $_POST["text"];
|
|
|
+ $detail = urldecode($text);
|
|
|
+ }
|
|
|
+ if(($action == "ocean_order") && $operate == "ams_isf_log"){
|
|
|
+ $detail = "AMS/ISF";
|
|
|
+ }
|
|
|
+ if(($action == "ocean_booking" || $action == "ocean_order") && $operate == "excel"){
|
|
|
+ $detail = "Filter_condition:" . $_REQUEST['excel_filter_condition']." Selected Fields:". $_REQUEST['selected fields'];
|
|
|
+ }
|
|
|
+ return $detail;
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
public static function calculateTicks($minValue, $maxValue, $targetTickCount = 10) {
|
|
|
$tickSpacing = ($maxValue - $minValue);
|
|
|
$tickSpacing = intval($tickSpacing);
|
|
|
@@ -401,6 +517,19 @@ class utils {
|
|
|
return $interval;
|
|
|
}
|
|
|
|
|
|
+ public static function single_operation_log_save($page,$operation,$operation_detail){
|
|
|
+ $user_type = _isCustomerLogin() ? "Customer" : "Employee";
|
|
|
+ $user_name = _getLoginName();
|
|
|
+ if(!isset($_SESSION['ONLINE_USER'])){
|
|
|
+ $user_type = "";
|
|
|
+ $user_name = "No Login Record";
|
|
|
+ }
|
|
|
+ $sql = "INSERT INTO public.customer_service_operation_log(user_type, user_name, page, operation, operation_detail,
|
|
|
+ operation_time)
|
|
|
+ VALUES ('$user_type', '$user_name', '$page', '$operation', '$operation_detail', now())";
|
|
|
+ common::excuteUpdateSql($sql);
|
|
|
+ }
|
|
|
+
|
|
|
public static function uuid() {
|
|
|
return strtoupper(md5(uniqid("", TRUE) . mt_rand()));
|
|
|
}
|
|
|
@@ -427,6 +556,16 @@ class utils {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ public static function exist_array($key,$arr){
|
|
|
+ $flag = false;
|
|
|
+ foreach($arr as $v){
|
|
|
+ if($v['id'] == $key ){
|
|
|
+ $flag = true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return $flag;
|
|
|
+ }
|
|
|
+
|
|
|
public static function _getSql($ids, $type,$shipment_mode) {
|
|
|
$ids_arr = explode(',', $ids);
|
|
|
$sql = "";
|