|
@@ -25,41 +25,6 @@ class report {
|
|
|
* report 配置
|
|
* report 配置
|
|
|
*/
|
|
*/
|
|
|
public function report_config(){
|
|
public function report_config(){
|
|
|
- // $config = [
|
|
|
|
|
- // 'delivery_frequency' => 'monthly',
|
|
|
|
|
- // 'timezone' => 'UTC+05',
|
|
|
|
|
- // 'monthly_day' => [2,3,4],
|
|
|
|
|
- // 'monthly_time' => '09:00:00',
|
|
|
|
|
- // ];
|
|
|
|
|
- // $config = [
|
|
|
|
|
- // 'delivery_frequency' => 'daily',
|
|
|
|
|
- // 'timezone' => 'UTC+05',
|
|
|
|
|
- // 'daily_time' => '09:00:00',
|
|
|
|
|
- // ];
|
|
|
|
|
- // $config = [
|
|
|
|
|
- // 'delivery_frequency' => 'weekly',
|
|
|
|
|
- // 'timezone' => 'UTC+05',
|
|
|
|
|
- // 'weekly_day' => [1],
|
|
|
|
|
- // 'weekly_time' => '09:00:00',
|
|
|
|
|
- // ];
|
|
|
|
|
- // $config = [
|
|
|
|
|
- // 'delivery_frequency' => 'quarterly',
|
|
|
|
|
- // 'timezone' => 'UTC+05',
|
|
|
|
|
- // 'quarterly_month' =>'1',
|
|
|
|
|
- // 'quarterly_day' =>'1',
|
|
|
|
|
- // 'quarterly_time' => '09:00:00',
|
|
|
|
|
- // ];
|
|
|
|
|
- // $config = [
|
|
|
|
|
- // 'delivery_frequency' => 'yearly',
|
|
|
|
|
- // 'timezone' => 'UTC+05',
|
|
|
|
|
- // 'yearly_month' =>[1,2],
|
|
|
|
|
- // 'yearly_day' =>'1',
|
|
|
|
|
- // 'yearly_time' => '09:00:00',
|
|
|
|
|
- // ];
|
|
|
|
|
-
|
|
|
|
|
- // $next = common::calculateNextRunTime($config);
|
|
|
|
|
- //echo $next->format('Y-m-d H:i:s');
|
|
|
|
|
-
|
|
|
|
|
$operate = utils::_get('operate');
|
|
$operate = utils::_get('operate');
|
|
|
$operate = strtolower($operate);
|
|
$operate = strtolower($operate);
|
|
|
|
|
|
|
@@ -111,7 +76,7 @@ class report {
|
|
|
$sqlWhere .= " and access_type ='". common::check_input($pplication_scope)."'";
|
|
$sqlWhere .= " and access_type ='". common::check_input($pplication_scope)."'";
|
|
|
}
|
|
}
|
|
|
if(!empty($_POST['is_active'])){
|
|
if(!empty($_POST['is_active'])){
|
|
|
- if($_POST['is_active'] == 't'){
|
|
|
|
|
|
|
+ if($_POST['is_active'] == 'true'){
|
|
|
$sqlWhere .= " and is_active = true";
|
|
$sqlWhere .= " and is_active = true";
|
|
|
}else{
|
|
}else{
|
|
|
$sqlWhere .= " and is_active = false";
|
|
$sqlWhere .= " and is_active = false";
|
|
@@ -124,6 +89,9 @@ 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()){
|
|
if(_isCustomerLogin()){
|
|
|
$ocean_contact_id = _getCompanyContactHandNew($_SESSION["ONLINE_USER"]);
|
|
$ocean_contact_id = _getCompanyContactHandNew($_SESSION["ONLINE_USER"]);
|
|
|
$air_contact_id = _getAirContactID('public');
|
|
$air_contact_id = _getAirContactID('public');
|
|
@@ -137,7 +105,6 @@ class report {
|
|
|
$all_id = strtolower($all_id);
|
|
$all_id = strtolower($all_id);
|
|
|
$unique_arr = explode(';', $all_id);
|
|
$unique_arr = explode(';', $all_id);
|
|
|
//构建安全的数组字面量用于 PostgreSQL 的 && 交集判断
|
|
//构建安全的数组字面量用于 PostgreSQL 的 && 交集判断
|
|
|
- $sqlWhere_party_id = '';
|
|
|
|
|
if (!empty($unique_arr)) {
|
|
if (!empty($unique_arr)) {
|
|
|
// 转义每个 ID 防注入
|
|
// 转义每个 ID 防注入
|
|
|
$escaped_ids = array();
|
|
$escaped_ids = array();
|
|
@@ -149,7 +116,7 @@ class report {
|
|
|
}
|
|
}
|
|
|
if(!empty($escaped_ids)){
|
|
if(!empty($escaped_ids)){
|
|
|
$array_str = 'ARRAY[' . implode(',', $escaped_ids) . ']';
|
|
$array_str = 'ARRAY[' . implode(',', $escaped_ids) . ']';
|
|
|
- $sqlWhere_party_id = " or party_ids && $array_str ";
|
|
|
|
|
|
|
+ $sqlWhere_party_id = " OR party_ids && $array_str ";
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
//Group Name 判断
|
|
//Group Name 判断
|
|
@@ -157,7 +124,6 @@ class report {
|
|
|
$company = strtolower($company);
|
|
$company = strtolower($company);
|
|
|
$aa = explode(";", $company);
|
|
$aa = explode(";", $company);
|
|
|
|
|
|
|
|
- $sqlWhere_group_name = '';
|
|
|
|
|
if(!empty($aa)){
|
|
if(!empty($aa)){
|
|
|
$escaped_company = array();
|
|
$escaped_company = array();
|
|
|
foreach ($aa as $value) {
|
|
foreach ($aa as $value) {
|
|
@@ -168,14 +134,11 @@ class report {
|
|
|
}
|
|
}
|
|
|
if(!empty($escaped_company)){
|
|
if(!empty($escaped_company)){
|
|
|
$array_str = 'ARRAY[' . implode(',', $escaped_company) . ']';
|
|
$array_str = 'ARRAY[' . implode(',', $escaped_company) . ']';
|
|
|
- $sqlWhere_group_name = " or group_names && $array_str";
|
|
|
|
|
|
|
+ $sqlWhere_group_name = " OR group_names && $array_str";
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
- $sqlWhere .= " and ( access_type = 'All Users' ".$sqlWhere_party_id . " ".$sqlWhere_group_name .")";
|
|
|
|
|
- }
|
|
|
|
|
- $sqlWhere .= " and (system_account IS NULL OR array_length(system_account, 1) = 0 OR '".common::check_input(_getLoginName())."' = any(system_account))";
|
|
|
|
|
-
|
|
|
|
|
|
|
+ $sqlWhere .= " and ( access_type = 'All Users' ".$sqlWhere_party_id . " ".$sqlWhere_group_name ." ".$systemAccountsqlWhere .")";
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
$rc = $_POST ['rc'];
|
|
$rc = $_POST ['rc'];
|
|
|
if ($rc == -1) {
|
|
if ($rc == -1) {
|
|
@@ -187,7 +150,8 @@ class report {
|
|
|
$sql = "select * from public.kln_report_template where " .$sqlWhere;
|
|
$sql = "select * from public.kln_report_template where " .$sqlWhere;
|
|
|
$sql .= " order by id desc limit " . $ps . " offset " . ($cp - 1) * $ps;
|
|
$sql .= " order by id desc limit " . $ps . " offset " . ($cp - 1) * $ps;
|
|
|
$rs = common::excuteListSql($sql);
|
|
$rs = common::excuteListSql($sql);
|
|
|
- $arrTmp = array('searchData' => $rs,
|
|
|
|
|
|
|
+ $arrTmp = array('searchData' => $rs,
|
|
|
|
|
+ 'isDelete' =>_isVipReportAdmin(_getLoginName()),
|
|
|
'rc' => intval($rc),
|
|
'rc' => intval($rc),
|
|
|
'ps' => intval($ps),
|
|
'ps' => intval($ps),
|
|
|
'cp' => intval($cp),
|
|
'cp' => intval($cp),
|
|
@@ -195,7 +159,12 @@ class report {
|
|
|
common::echo_json_encode(200,$arrTmp);
|
|
common::echo_json_encode(200,$arrTmp);
|
|
|
exit();
|
|
exit();
|
|
|
}else{
|
|
}else{
|
|
|
- $arrTmp = array('searchData' => array());
|
|
|
|
|
|
|
+ $arrTmp = array('searchData' =>array(),
|
|
|
|
|
+ 'isDelete' =>_isVipReportAdmin(_getLoginName()),
|
|
|
|
|
+ 'rc' => intval($rc),
|
|
|
|
|
+ 'ps' => intval($ps),
|
|
|
|
|
+ 'cp' => intval($cp),
|
|
|
|
|
+ 'tp' => intval($tp));
|
|
|
common::echo_json_encode(200, $arrTmp);
|
|
common::echo_json_encode(200, $arrTmp);
|
|
|
exit();
|
|
exit();
|
|
|
}
|
|
}
|
|
@@ -207,7 +176,8 @@ class report {
|
|
|
//代表编辑
|
|
//代表编辑
|
|
|
$reportMain = common::excuteObjectSql("select *,
|
|
$reportMain = common::excuteObjectSql("select *,
|
|
|
array_to_json(party_ids) as party_ids_json,
|
|
array_to_json(party_ids) as party_ids_json,
|
|
|
- array_to_json(group_names) as group_names_json
|
|
|
|
|
|
|
+ array_to_json(group_names) as group_names_json,
|
|
|
|
|
+ array_to_json(system_account) as system_account_json
|
|
|
from kln_report_template where serial_no = '$serial_no'");
|
|
from kln_report_template where serial_no = '$serial_no'");
|
|
|
|
|
|
|
|
$reportFields = array();
|
|
$reportFields = array();
|
|
@@ -232,7 +202,8 @@ class report {
|
|
|
|
|
|
|
|
$reportAccess = array("type"=>$reportMain['access_type'],
|
|
$reportAccess = array("type"=>$reportMain['access_type'],
|
|
|
"partyId"=>json_decode($reportMain['party_ids_json'],true),
|
|
"partyId"=>json_decode($reportMain['party_ids_json'],true),
|
|
|
- "groupName"=>json_decode($reportMain['group_names_json'],true));
|
|
|
|
|
|
|
+ "groupName"=>json_decode($reportMain['group_names_json'],true),
|
|
|
|
|
+ "systemAccount"=>json_decode($reportMain['system_account_json'],true));
|
|
|
$data = array("reportName"=>$reportMain['name'],"reportLevel"=>$reportMain['level'],"reportDescription"=>$reportMain['description'],
|
|
$data = array("reportName"=>$reportMain['name'],"reportLevel"=>$reportMain['level'],"reportDescription"=>$reportMain['description'],
|
|
|
"reportFields"=>$reportFields,"reportAccess"=>$reportAccess);
|
|
"reportFields"=>$reportFields,"reportAccess"=>$reportAccess);
|
|
|
}else{
|
|
}else{
|
|
@@ -378,6 +349,16 @@ class report {
|
|
|
exit();
|
|
exit();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ if ($operate == "delete"){
|
|
|
|
|
+ $serial_no =$_POST['serial_no'];
|
|
|
|
|
+ $sql = "delete from public.kln_report_template where serial_no = '$serial_no';";
|
|
|
|
|
+ $sql .= "delete from public.kln_report_field_config where template_serial_no = '$serial_no';";
|
|
|
|
|
+ common::excuteUpdateSql($sql);
|
|
|
|
|
+ $data = array("msg" =>"success");
|
|
|
|
|
+ common::echo_json_encode(200,$data);
|
|
|
|
|
+ exit();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -400,6 +381,58 @@ class report {
|
|
|
if (!empty($text_search)){
|
|
if (!empty($text_search)){
|
|
|
$sqlWhere .= " and (lower(name) like '%".strtolower($text_search)."%')";
|
|
$sqlWhere .= " and (lower(name) like '%".strtolower($text_search)."%')";
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ $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');
|
|
|
|
|
+
|
|
|
|
|
+ $all_id = $ocean_contact_id;
|
|
|
|
|
+ if (utils::endWith($ocean_contact_id,";")){
|
|
|
|
|
+ $all_id .=$air_contact_id;
|
|
|
|
|
+ } else {
|
|
|
|
|
+ $all_id .=";".$air_contact_id;
|
|
|
|
|
+ }
|
|
|
|
|
+ $all_id = strtolower($all_id);
|
|
|
|
|
+ $unique_arr = explode(';', $all_id);
|
|
|
|
|
+ //构建安全的数组字面量用于 PostgreSQL 的 && 交集判断
|
|
|
|
|
+ if (!empty($unique_arr)) {
|
|
|
|
|
+ // 转义每个 ID 防注入
|
|
|
|
|
+ $escaped_ids = array();
|
|
|
|
|
+ foreach($unique_arr as $id){
|
|
|
|
|
+ $id = trim($id);
|
|
|
|
|
+ if (empty($id))
|
|
|
|
|
+ continue;
|
|
|
|
|
+ $escaped_ids[] = "'" .common::check_input($id) . "'";
|
|
|
|
|
+ }
|
|
|
|
|
+ if(!empty($escaped_ids)){
|
|
|
|
|
+ $array_str = 'ARRAY[' . implode(',', $escaped_ids) . ']';
|
|
|
|
|
+ $sqlWhere_party_id = " OR party_ids && $array_str ";
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ //Group Name 判断
|
|
|
|
|
+ $company = _getCompanyHandNew($_SESSION["ONLINE_USER"],'public');
|
|
|
|
|
+ $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)){
|
|
|
|
|
+ $array_str = 'ARRAY[' . implode(',', $escaped_company) . ']';
|
|
|
|
|
+ $sqlWhere_group_name = " OR group_names && $array_str";
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ $sqlWhere .= " and ( access_type = 'All Users' ".$sqlWhere_party_id . " ".$sqlWhere_group_name ." ".$systemAccountsqlWhere .")";
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
|
|
|
$rc = $_POST ['rc'];
|
|
$rc = $_POST ['rc'];
|
|
|
if ($rc == - 1) {
|
|
if ($rc == - 1) {
|
|
@@ -411,7 +444,7 @@ class report {
|
|
|
$sql = "select serial_no,name,description from public.kln_report_template where " .$sqlWhere;
|
|
$sql = "select serial_no,name,description from public.kln_report_template where " .$sqlWhere;
|
|
|
$sql .= " order by id desc limit " . $ps . " offset " . ($cp - 1) * $ps;
|
|
$sql .= " order by id desc limit " . $ps . " offset " . ($cp - 1) * $ps;
|
|
|
$rs = common::excuteListSql($sql);
|
|
$rs = common::excuteListSql($sql);
|
|
|
- $arrTmp = array('searchData' => $rs,
|
|
|
|
|
|
|
+ $arrTmp = array('searchData' => $rs,
|
|
|
'rc' => intval($rc),
|
|
'rc' => intval($rc),
|
|
|
'ps' => intval($ps),
|
|
'ps' => intval($ps),
|
|
|
'cp' => intval($cp),
|
|
'cp' => intval($cp),
|
|
@@ -419,12 +452,16 @@ class report {
|
|
|
common::echo_json_encode(200,$arrTmp);
|
|
common::echo_json_encode(200,$arrTmp);
|
|
|
exit();
|
|
exit();
|
|
|
}else{
|
|
}else{
|
|
|
- $arrTmp = array('searchData' => array());
|
|
|
|
|
|
|
+ $arrTmp = array('searchData' => array(),
|
|
|
|
|
+ 'rc' => intval($rc),
|
|
|
|
|
+ 'ps' => intval($ps),
|
|
|
|
|
+ 'cp' => intval($cp),
|
|
|
|
|
+ 'tp' => intval($tp));
|
|
|
common::echo_json_encode(200, $arrTmp);
|
|
common::echo_json_encode(200, $arrTmp);
|
|
|
exit();
|
|
exit();
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
if ($operate == "report_detail") {
|
|
if ($operate == "report_detail") {
|
|
|
$serial_no = common::check_input($_POST ['serial_no']);
|
|
$serial_no = common::check_input($_POST ['serial_no']);
|
|
|
$dataReturn = array();
|
|
$dataReturn = array();
|
|
@@ -523,6 +560,7 @@ class report {
|
|
|
}
|
|
}
|
|
|
$dataReturn['tableData'] = $arrTmp;
|
|
$dataReturn['tableData'] = $arrTmp;
|
|
|
$dataReturn['tmp_search'] = common::deCode($tmp_search_without_limit, 'E');
|
|
$dataReturn['tmp_search'] = common::deCode($tmp_search_without_limit, 'E');
|
|
|
|
|
+ $dataReturn['reportName'] = $reportFiled['name'];
|
|
|
common::echo_json_encode(200, $dataReturn);
|
|
common::echo_json_encode(200, $dataReturn);
|
|
|
exit();
|
|
exit();
|
|
|
}
|
|
}
|