ShuanghongS 1 tháng trước cách đây
mục cha
commit
c7e698f75d
1 tập tin đã thay đổi với 27 bổ sung26 xóa
  1. 27 26
      service/report.class.php

+ 27 - 26
service/report.class.php

@@ -91,7 +91,6 @@ class report {
 
             $sqlWhere_party_id = '';
             $sqlWhere_group_name = '';
-            $systemAccountsqlWhere = " OR system_account IS NULL  OR array_length(system_account, 1) = 0  OR '".common::check_input(_getLoginName())."' = any(system_account)";
             if(_isCustomerLogin()){
                 $ocean_contact_id = _getCompanyContactHandNew($_SESSION["ONLINE_USER"]);
                 $air_contact_id = _getAirContactID('public');
@@ -125,22 +124,23 @@ class report {
                 $company = strtolower($company);
                 $aa = explode(";", $company);
 
-                if(!empty($aa)){
-                    $escaped_company = array();
-                    foreach ($aa as $value) {
-                        $value = trim($value);
-                        if (empty($value))
-                            continue;
-                        $escaped_company[] = "'" . common::check_input($value) . "'";
-                    }
-                    if(empty($escaped_company)){
+                $escaped_company = array();
+                foreach ($aa as $value) {
+                    $value = trim($value);
+                    if (empty($value))
+                        continue;
+                    $escaped_company[] = "'" . common::check_input($value) . "'";
+                }
+                if(empty($escaped_company)){
                         $escaped_company[] = "'" . common::check_input('default_value_that_does_not_exist') . "'";
-                    }
-                    $array_str = 'ARRAY[' . implode(',', $escaped_company) . ']';
-                    $sqlWhere_group_name = "  OR group_names && $array_str";
                 }
+                $array_str = 'ARRAY[' . implode(',', $escaped_company) . ']';
+                $sqlWhere_group_name = "  OR group_names && $array_str";
+                
+                $systemAccountsqlWhere = " OR '".common::check_input(_getLoginName())."' = any(system_account)";
                 $sqlWhere .= " and ( access_type = 'All Users' ".$sqlWhere_party_id . " ".$sqlWhere_group_name ." ".$systemAccountsqlWhere .")";
             } else {
+                $systemAccountsqlWhere = " OR system_account IS NULL  OR array_length(system_account, 1) = 0  OR '".common::check_input(_getLoginName())."' = any(system_account)";
                 $sqlWhere .= " and ( 1<>1 ".$systemAccountsqlWhere .")";
             }
 
@@ -388,7 +388,6 @@ class report {
             
             $sqlWhere_party_id = '';
             $sqlWhere_group_name = '';
-            $systemAccountsqlWhere = " OR system_account IS NULL  OR array_length(system_account, 1) = 0  OR '".common::check_input(_getLoginName())."' = any(system_account)";
             if(_isCustomerLogin()){
                 $ocean_contact_id = _getCompanyContactHandNew($_SESSION["ONLINE_USER"]);
                 $air_contact_id = _getAirContactID('public');
@@ -422,22 +421,23 @@ class report {
                 $company = strtolower($company);
                 $aa = explode(";", $company);
 
-                if(!empty($aa)){
-                    $escaped_company = array();
-                    foreach ($aa as $value) {
-                        $value = trim($value);
-                        if (empty($value))
-                            continue;
-                        $escaped_company[] = "'" . common::check_input($value) . "'";
-                    }
-                    if(empty($escaped_company)){
+                $escaped_company = array();
+                foreach ($aa as $value) {
+                    $value = trim($value);
+                    if (empty($value))
+                        continue;
+                    $escaped_company[] = "'" . common::check_input($value) . "'";
+                }
+                if(empty($escaped_company)){
                         $escaped_company[] = "'" . common::check_input('default_value_that_does_not_exist') . "'";
-                    }
-                    $array_str = 'ARRAY[' . implode(',', $escaped_company) . ']';
-                    $sqlWhere_group_name = "  OR group_names && $array_str";
                 }
+                $array_str = 'ARRAY[' . implode(',', $escaped_company) . ']';
+                $sqlWhere_group_name = "  OR group_names && $array_str";
+
+                $systemAccountsqlWhere = " OR '".common::check_input(_getLoginName())."' = any(system_account)";
                 $sqlWhere .= " and ( access_type = 'All Users' ".$sqlWhere_party_id . " ".$sqlWhere_group_name ." ".$systemAccountsqlWhere .")";
             } else {
+                $systemAccountsqlWhere = " OR system_account IS NULL  OR array_length(system_account, 1) = 0  OR '".common::check_input(_getLoginName())."' = any(system_account)";
                 $sqlWhere .= " and ( 1<>1 ".$systemAccountsqlWhere .")";
             }
 
@@ -446,6 +446,7 @@ class report {
             if ($rc == - 1) {
                 $sql = "select count(*) from public.kln_report_template where " .$sqlWhere;
                 $rc = common::excuteOneSql($sql);
+                error_log($sql);
             }
             $tp = ceil($rc / $ps);
             if ($rc > 0) {