|
@@ -39,14 +39,31 @@ class report {
|
|
|
if (empty($cp))
|
|
if (empty($cp))
|
|
|
$cp = 1;
|
|
$cp = 1;
|
|
|
|
|
|
|
|
|
|
+ $sqlWhere = "1=1";
|
|
|
|
|
+ $text_search = $_POST['text_search'];
|
|
|
|
|
+ if (!empty($text_search)){
|
|
|
|
|
+ $sqlWhere .= " and (lower(name) like '%".strtolower($text_search)."%')";
|
|
|
|
|
+ }
|
|
|
|
|
+ if(!empty($_POST['application_scope'])){
|
|
|
|
|
+ $pplication_scope = $_POST['application_scope'] =='all' ? "All Users" : "Specific Users";
|
|
|
|
|
+ $sqlWhere .= " and access_type ='". common::check_input($pplication_scope)."'";
|
|
|
|
|
+ }
|
|
|
|
|
+ if(!empty($_POST['is_active'])){
|
|
|
|
|
+ if($_POST['is_active'] == 't'){
|
|
|
|
|
+ $sqlWhere .= " and is_active = true";
|
|
|
|
|
+ }else{
|
|
|
|
|
+ $sqlWhere .= " and is_active = false";
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
$rc = $_POST ['rc'];
|
|
$rc = $_POST ['rc'];
|
|
|
if ($rc == - 1) {
|
|
if ($rc == - 1) {
|
|
|
- $sql = "select count(*) from public.kln_report_template";
|
|
|
|
|
|
|
+ $sql = "select count(*) from public.kln_report_template where " .$sqlWhere;
|
|
|
$rc = common::excuteOneSql($sql);
|
|
$rc = common::excuteOneSql($sql);
|
|
|
}
|
|
}
|
|
|
$tp = ceil($rc / $ps);
|
|
$tp = ceil($rc / $ps);
|
|
|
if ($rc > 0) {
|
|
if ($rc > 0) {
|
|
|
- $sql = "select * from public.kln_report_template";
|
|
|
|
|
|
|
+ $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,
|
|
@@ -64,45 +81,67 @@ class report {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
if ($operate == "add"){
|
|
if ($operate == "add"){
|
|
|
- $id = common::deCode($_REQUEST['id'], 'D');
|
|
|
|
|
- if(!empty($id)){
|
|
|
|
|
|
|
+ $serial_no = common::deCode($_REQUEST['serial_no'], 'D');
|
|
|
|
|
+ if(!empty($serial_no)){
|
|
|
//代表编辑
|
|
//代表编辑
|
|
|
- $reportMain = common::excuteObjectSql("select * from kln_report_template where id = $id");
|
|
|
|
|
- $reportField = common::excuteListSql("select * from kln_report_field_config where template_id = $id order by order_index");
|
|
|
|
|
- $data = array("reportMain" => $reportMain,"reportField" =>$reportField);
|
|
|
|
|
|
|
+ $reportMain = common::excuteObjectSql("select *,
|
|
|
|
|
+ array_to_json(party_ids) as party_ids_json,
|
|
|
|
|
+ array_to_json(group_names) as group_names_json
|
|
|
|
|
+ from kln_report_template where serial_no = '$serial_no'");
|
|
|
|
|
+
|
|
|
|
|
+ $reportFields = array();
|
|
|
|
|
+ $reportField = common::excuteListSql("select field_id,field_level,field_type,field_db,field_display_name,
|
|
|
|
|
+ field_display_name_user,data_type,custom_value_type,
|
|
|
|
|
+ custom_fixed_value,is_filter_enabled,is_sort_enabled
|
|
|
|
|
+ from kln_report_field_config where template_serial_no = '$serial_no' order by order_index");
|
|
|
|
|
+ foreach($reportField as $_reportField){
|
|
|
|
|
+ $_reportField['is_filter_enabled'] = $_reportField['is_filter_enabled'] == 't' ? true : false;
|
|
|
|
|
+ $_reportField['is_sort_enabled'] = $_reportField['is_sort_enabled'] == 't' ? true : false;
|
|
|
|
|
+ $reportFields[] = $_reportField;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ $reportAccess = array("type"=>$reportMain['access_type'],
|
|
|
|
|
+ "partyId"=>json_decode($reportMain['party_ids_json'],true),
|
|
|
|
|
+ "groupName"=>json_decode($reportMain['group_names_json'],true));
|
|
|
|
|
+ $data = array("reportName"=>$reportMain['name'],"reportLevel"=>$reportMain['level'],"reportDescription"=>$reportMain['description'],
|
|
|
|
|
+ "reportFields"=>$reportFields,"reportAccess"=>$reportAccess);
|
|
|
}else{
|
|
}else{
|
|
|
- $data = array("reportMain" =>array(),"reportField" =>array());
|
|
|
|
|
|
|
+ $data = array();
|
|
|
}
|
|
}
|
|
|
common::echo_json_encode(200,$data);
|
|
common::echo_json_encode(200,$data);
|
|
|
exit();
|
|
exit();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
if ($operate == "report_field_load"){
|
|
if ($operate == "report_field_load"){
|
|
|
- $level = common::check_input($_POST['level']);
|
|
|
|
|
- $template_id = common::check_input($_POST['template_id']);
|
|
|
|
|
-
|
|
|
|
|
- $all_field = common::excuteListSql("select * from public.kln_report_field where level = '$level' order by id");
|
|
|
|
|
-
|
|
|
|
|
- $right_field = common::excuteListSql("select * from public.kln_report_field_config where template_id = '$template_id' order by id");
|
|
|
|
|
-
|
|
|
|
|
- $left_field = common::excuteListSql("select * from public.kln_report_field where level = '$level'
|
|
|
|
|
- and id != ALL(select field_ids from public.kln_report_template where id = '$template_id') order by id");
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
|
|
+ column::getInstance()->settingDisplayForVIPReport();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
if ($operate == "save"){
|
|
if ($operate == "save"){
|
|
|
- $template_id = common::deCode($_POST['template_id'], 'D');
|
|
|
|
|
- $name = common::check_input($_POST['name']);
|
|
|
|
|
- $description = common::check_input($_POST['description']);
|
|
|
|
|
- $level = common::check_input($_POST['level']);
|
|
|
|
|
|
|
+ $serial_no = common::deCode($_POST['serial_no'], 'D');
|
|
|
|
|
+ $name = common::check_input($_POST['report_name']);
|
|
|
|
|
+ $description = common::check_input($_POST['report_description']);
|
|
|
|
|
+ $level = common::check_input($_POST['report_level']);
|
|
|
$access_type = common::check_input($_POST['access_type']);
|
|
$access_type = common::check_input($_POST['access_type']);
|
|
|
$party_ids = $_POST['party_ids'];
|
|
$party_ids = $_POST['party_ids'];
|
|
|
$group_names = $_POST['group_names'];
|
|
$group_names = $_POST['group_names'];
|
|
|
|
|
|
|
|
|
|
+ //字段配置信息
|
|
|
|
|
+ $field_ids = $_POST['field_id'];
|
|
|
|
|
+ $field_level = $_POST['field_level'];
|
|
|
|
|
+ $field_type = $_POST['field_type'];
|
|
|
|
|
+ $field_db = $_POST['field_db'];
|
|
|
|
|
+ $field_code = $_POST['field_code'];
|
|
|
|
|
+ $display_name = $_POST['display_name'];
|
|
|
|
|
+ $data_type = $_POST['data_type'];
|
|
|
|
|
+ $value_type = $_POST['value_type'];
|
|
|
|
|
+ $fixed_value = $_POST['fixed_value'];
|
|
|
|
|
+ $is_filter_enabled = $_POST['is_filter_enabled'];
|
|
|
|
|
+ $is_sort_enabled = $_POST['is_sort_enabled'];
|
|
|
|
|
+
|
|
|
|
|
+ $report_sql = common::excuteOneSql("select sql from public.kln_report_sql_manage where level = '$level'");
|
|
|
$sql = "";
|
|
$sql = "";
|
|
|
if (!empty($serial_no)){
|
|
if (!empty($serial_no)){
|
|
|
- $updateSqlSet = " modify_by = '"._getLoginName()."',update_time = now()";
|
|
|
|
|
|
|
+ $updateSqlSet = " report_sql = '$report_sql', modify_by = '"._getLoginName()."',update_time = now()";
|
|
|
if (!empty($name)) {
|
|
if (!empty($name)) {
|
|
|
$updateSqlSet.= ", name = '$name' ";
|
|
$updateSqlSet.= ", name = '$name' ";
|
|
|
}
|
|
}
|
|
@@ -123,19 +162,63 @@ class report {
|
|
|
$pgsql_array = '"' . implode('","', array_map(fn($v) => str_replace("'", "''", $v), $group_names)) . '"';
|
|
$pgsql_array = '"' . implode('","', array_map(fn($v) => str_replace("'", "''", $v), $group_names)) . '"';
|
|
|
$updateSqlSet.= ", group_names = '{".$pgsql_array."}'::text[]";
|
|
$updateSqlSet.= ", group_names = '{".$pgsql_array."}'::text[]";
|
|
|
}
|
|
}
|
|
|
|
|
+ if (!empty($field_ids)) {
|
|
|
|
|
+ $pgsql_array = '"' . implode('","', array_map(fn($v) => str_replace("'", "''", $v), $field_ids)) . '"';
|
|
|
|
|
+ $updateSqlSet.= ", field_ids = '{".$pgsql_array."}'::INTEGER[]";
|
|
|
|
|
+ }
|
|
|
//代表update
|
|
//代表update
|
|
|
- $sql .= "update public.kln_report_config set ".$updateSqlSet."
|
|
|
|
|
|
|
+ $sql .= "update public.kln_report_template set ".$updateSqlSet."
|
|
|
where serial_no = '$serial_no';";
|
|
where serial_no = '$serial_no';";
|
|
|
} else {
|
|
} else {
|
|
|
- //检查配置的站点是否于以前的配置的,是否重合
|
|
|
|
|
-
|
|
|
|
|
|
|
+ $party_ids_filed = null;
|
|
|
|
|
+ if (!empty($party_ids)) {
|
|
|
|
|
+ $pgsql_array = '"' . implode('","', array_map(fn($v) => str_replace("'", "''", $v), $party_ids)) . '"';
|
|
|
|
|
+ $party_ids_filed= "'{".$pgsql_array."}'::text[]";
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ $group_names_filed = null;
|
|
|
|
|
+ if (!empty($group_names)) {
|
|
|
|
|
+ $pgsql_array = '"' . implode('","', array_map(fn($v) => str_replace("'", "''", $v), $group_names)) . '"';
|
|
|
|
|
+ $group_names_filed = "'{".$pgsql_array."}'::text[]";
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ $ids_filed = null;
|
|
|
|
|
+ if (!empty($field_ids)) {
|
|
|
|
|
+ $pgsql_array = '"' . implode('","', array_map(fn($v) => str_replace("'", "''", $v), $field_ids)) . '"';
|
|
|
|
|
+ $ids_filed = "'{".$pgsql_array."}'::INTEGER[]";
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ $serial_no = common::uuid();
|
|
|
|
|
+ $sql .= "INSERT INTO public.kln_report_template(
|
|
|
|
|
+ serial_no,name, description, level, field_ids, access_type, report_sql,
|
|
|
|
|
+ party_ids, group_names, create_by, created_time, modify_by, update_time )
|
|
|
|
|
+ VALUES ('$serial_no','$name', '$description', '$level', $ids_filed, '$access_type', '$report_sql'
|
|
|
|
|
+ $party_ids_filed, $group_names_filed , '"._getLoginName()."', now(), '"._getLoginName()."', now());";
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
$errmsg = "";
|
|
$errmsg = "";
|
|
|
//柜子是先删除,后添加
|
|
//柜子是先删除,后添加
|
|
|
- $sql .= "delete from public.kln_report_rule where recommended_delivery_serial_no = '';";
|
|
|
|
|
-
|
|
|
|
|
|
|
+ $sql .= "delete from public.kln_report_field_config where template_serial_no = '$serial_no';";
|
|
|
|
|
+ foreach($field_ids as $key =>$_field_id){
|
|
|
|
|
+ $_field_level = $field_level[$key];
|
|
|
|
|
+ $_ield_type = $field_type[$key];
|
|
|
|
|
+ $_field_db = $field_db[$key];
|
|
|
|
|
+ $_field_code = $field_code[$key];
|
|
|
|
|
+ $_display_name = $display_name[$key];
|
|
|
|
|
+ $_data_type = $data_type[$key];
|
|
|
|
|
+ $_value_type = $value_type[$key];
|
|
|
|
|
+ $_fixed_value = $fixed_value[$key];
|
|
|
|
|
+ $_is_filter_enabled = $is_filter_enabled[$key];
|
|
|
|
|
+ $_is_sort_enabled = $is_sort_enabled[$key];
|
|
|
|
|
+ $sql .= "INSERT INTO public.kln_report_field_config(
|
|
|
|
|
+ template_serial_no, field_id, field_level, field_type, field_db,
|
|
|
|
|
+ field_display_name, field_display_name_user, data_type, custom_value_type,
|
|
|
|
|
+ custom_fixed_value, is_filter_enabled, is_sort_enabled, created_time)
|
|
|
|
|
+ VALUES ('$serial_no', '$_field_id', '$_field_level', '$_ield_type', '$_field_db',
|
|
|
|
|
+ '$_field_code', '$_display_name', '$_data_type', '$_value_type',
|
|
|
|
|
+ '$_fixed_value', '$_is_filter_enabled', '$_is_sort_enabled',now());";
|
|
|
|
|
|
|
|
|
|
+ }
|
|
|
if (empty($errmsg) && !empty($sql)){
|
|
if (empty($errmsg) && !empty($sql)){
|
|
|
common::excuteUpdateSql($sql);
|
|
common::excuteUpdateSql($sql);
|
|
|
$data = array("msg" =>"success");
|
|
$data = array("msg" =>"success");
|
|
@@ -148,9 +231,8 @@ class report {
|
|
|
|
|
|
|
|
if ($operate == "delete"){
|
|
if ($operate == "delete"){
|
|
|
$serial_no = common::deCode($_POST['a'], 'D');
|
|
$serial_no = common::deCode($_POST['a'], 'D');
|
|
|
- $sql = "delete from public.kln_report_config where serial_no = '$serial_no';";
|
|
|
|
|
- $sql .= "delete from public.kln_report_rule where recommended_delivery_serial_no = '$serial_no';";
|
|
|
|
|
- error_log($sql);
|
|
|
|
|
|
|
+ $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);
|
|
common::excuteUpdateSql($sql);
|
|
|
$data = array("msg" =>"success");
|
|
$data = array("msg" =>"success");
|
|
|
common::echo_json_encode(200,$data);
|
|
common::echo_json_encode(200,$data);
|
|
@@ -167,45 +249,74 @@ class report {
|
|
|
$operate = strtolower($operate);
|
|
$operate = strtolower($operate);
|
|
|
|
|
|
|
|
if ($operate == "report_search") {
|
|
if ($operate == "report_search") {
|
|
|
- //search
|
|
|
|
|
- //栏位信息
|
|
|
|
|
- $column = column::getInstance()->getDisplayColumn('report_Search');
|
|
|
|
|
- $BookingTableColumns = column::getInstance()->tableColumns('report_Search',$column);
|
|
|
|
|
- $data['TrackingTableColumns'] = $BookingTableColumns;
|
|
|
|
|
- common::echo_json_encode(200,$data);
|
|
|
|
|
- exit();
|
|
|
|
|
|
|
+ $cp = common::check_input($_POST ['cp']); //current_page
|
|
|
|
|
+ $ps = common::check_input($_POST ['ps']); //ps
|
|
|
|
|
+ if (empty($ps))
|
|
|
|
|
+ $ps = 100;
|
|
|
|
|
+ if (empty($cp))
|
|
|
|
|
+ $cp = 1;
|
|
|
|
|
+
|
|
|
|
|
+ $sqlWhere = "1=1 and is_active = true";
|
|
|
|
|
+ $text_search = $_POST['text_search'];
|
|
|
|
|
+ if (!empty($text_search)){
|
|
|
|
|
+ $sqlWhere .= " and (lower(name) like '%".strtolower($text_search)."%')";
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ $rc = $_POST ['rc'];
|
|
|
|
|
+ if ($rc == - 1) {
|
|
|
|
|
+ $sql = "select count(*) from public.kln_report_template where " .$sqlWhere;
|
|
|
|
|
+ $rc = common::excuteOneSql($sql);
|
|
|
|
|
+ }
|
|
|
|
|
+ $tp = ceil($rc / $ps);
|
|
|
|
|
+ if ($rc > 0) {
|
|
|
|
|
+ $sql = "select name,description from public.kln_report_template where " .$sqlWhere;
|
|
|
|
|
+ $sql .= " order by id desc limit " . $ps . " offset " . ($cp - 1) * $ps;
|
|
|
|
|
+ $rs = common::excuteListSql($sql);
|
|
|
|
|
+ $arrTmp = array('searchData' => $rs,
|
|
|
|
|
+ 'rc' => intval($rc),
|
|
|
|
|
+ 'ps' => intval($ps),
|
|
|
|
|
+ 'cp' => intval($cp),
|
|
|
|
|
+ 'tp' => intval($tp));
|
|
|
|
|
+ common::echo_json_encode(200,$arrTmp);
|
|
|
|
|
+ exit();
|
|
|
|
|
+ }else{
|
|
|
|
|
+ $arrTmp = array('searchData' => array());
|
|
|
|
|
+ common::echo_json_encode(200, $arrTmp);
|
|
|
|
|
+ exit();
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
- }
|
|
|
|
|
|
|
|
|
|
- /**
|
|
|
|
|
- * 关于report 页面的所有的静态加载数据查询
|
|
|
|
|
- */
|
|
|
|
|
- public function report_load(){
|
|
|
|
|
- $operate = utils::_get('operate');
|
|
|
|
|
- $operate = strtolower($operate);
|
|
|
|
|
|
|
+ if ($operate == "report_detail") {
|
|
|
|
|
+ $serial_no = common::check_input($_POST ['serial_no']);
|
|
|
|
|
+
|
|
|
|
|
+ common::excuteListSql("select * from kln_report_field_config where template_serial_no = '".$serial_no."' and field_type = 'System' order by id ");
|
|
|
|
|
+
|
|
|
|
|
|
|
|
- /**
|
|
|
|
|
- * select country
|
|
|
|
|
- */
|
|
|
|
|
- if ($operate == "country") {
|
|
|
|
|
- $term = $_POST['term'];
|
|
|
|
|
- $term = trim($term);
|
|
|
|
|
- $sql = "select DISTINCT category AS country_code from public.kerry_system_code
|
|
|
|
|
- where description='COUNTRY-STATION'
|
|
|
|
|
- and category ilike '" . common::check_input($term) . "%'";
|
|
|
|
|
- $sql .= " order by category";
|
|
|
|
|
-
|
|
|
|
|
- $rs = common::excuteListSql($sql);
|
|
|
|
|
- //前端要加上id 从1开始
|
|
|
|
|
- $retData = array();
|
|
|
|
|
- foreach($rs as $key => $val){
|
|
|
|
|
- if(!empty($val['country_code'])){
|
|
|
|
|
- $retData[] = array("value" =>$val['country_code'] ,"label"=>$val['country_code']);
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ //第一次进来,把查询放到一起了
|
|
|
|
|
+ $cp = 10;
|
|
|
|
|
+ $ps = 1;
|
|
|
|
|
+ $rc = $_POST ['rc'];
|
|
|
|
|
+ if ($rc == - 1) {
|
|
|
|
|
+ $sql = "select count(*) from public.kln_report_template where " ;
|
|
|
|
|
+ $rc = common::excuteOneSql($sql);
|
|
|
|
|
+ }
|
|
|
|
|
+ $tp = ceil($rc / $ps);
|
|
|
|
|
+ if ($rc > 0) {
|
|
|
|
|
+ $sql = "select name,description from public.kln_report_template where " ;
|
|
|
|
|
+ $sql .= " order by id desc limit " . $ps . " offset " . ($cp - 1) * $ps;
|
|
|
|
|
+ $rs = common::excuteListSql($sql);
|
|
|
|
|
+ $arrTmp = array('searchData' => $rs,
|
|
|
|
|
+ 'rc' => intval($rc),
|
|
|
|
|
+ 'ps' => intval($ps),
|
|
|
|
|
+ 'cp' => intval($cp),
|
|
|
|
|
+ 'tp' => intval($tp));
|
|
|
|
|
+ common::echo_json_encode(200,$arrTmp);
|
|
|
|
|
+ exit();
|
|
|
|
|
+ }else{
|
|
|
|
|
+ $arrTmp = array('searchData' => array());
|
|
|
|
|
+ common::echo_json_encode(200, $arrTmp);
|
|
|
|
|
+ exit();
|
|
|
}
|
|
}
|
|
|
- common::echo_json_encode(200,$retData);
|
|
|
|
|
- exit();
|
|
|
|
|
-
|
|
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|