0) { $sql = "select * from public.kln_report_template"; $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(); } } if ($operate == "add"){ $id = common::deCode($_REQUEST['id'], 'D'); if(!empty($id)){ //代表编辑 $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); }else{ $data = array("reportMain" =>array(),"reportField" =>array()); } common::echo_json_encode(200,$data); exit(); } 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"); } 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']); $access_type = common::check_input($_POST['access_type']); $party_ids = $_POST['party_ids']; $group_names = $_POST['group_names']; $sql = ""; if (!empty($serial_no)){ $updateSqlSet = " modify_by = '"._getLoginName()."',update_time = now()"; if (!empty($name)) { $updateSqlSet.= ", name = '$name' "; } if (!empty($description)) { $updateSqlSet.= ", description = '$description' "; } if (!empty($level)) { $updateSqlSet.= ", level = '$level' "; } if (!empty($access_type)) { $updateSqlSet.= ", access_type = '$access_type' "; } if (!empty($party_ids)) { $pgsql_array = '"' . implode('","', array_map(fn($v) => str_replace("'", "''", $v), $party_ids)) . '"'; $updateSqlSet.= ", party_ids = '{".$pgsql_array."}'::text[]"; } if (!empty($group_names)) { $pgsql_array = '"' . implode('","', array_map(fn($v) => str_replace("'", "''", $v), $group_names)) . '"'; $updateSqlSet.= ", group_names = '{".$pgsql_array."}'::text[]"; } //代表update $sql .= "update public.kln_report_config set ".$updateSqlSet." where serial_no = '$serial_no';"; } else { //检查配置的站点是否于以前的配置的,是否重合 } $errmsg = ""; //柜子是先删除,后添加 $sql .= "delete from public.kln_report_rule where recommended_delivery_serial_no = '';"; if (empty($errmsg) && !empty($sql)){ common::excuteUpdateSql($sql); $data = array("msg" =>"success"); } else { $data = array("msg" =>$errmsg); } common::echo_json_encode(200,$data); exit(); } if ($operate == "delete"){ $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); common::excuteUpdateSql($sql); $data = array("msg" =>"success"); common::echo_json_encode(200,$data); exit(); } } /** * shipment_status_report */ public function shipment_status_report(){ $operate = utils::_get('operate'); $operate = strtolower($operate); 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(); } } /** * 关于report 页面的所有的静态加载数据查询 */ public function report_load(){ $operate = utils::_get('operate'); $operate = strtolower($operate); /** * 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']); } } common::echo_json_encode(200,$retData); exit(); } } } ?>