| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213 |
- <?php
- if (!defined('IN_ONLINE')) {
- exit('Access Denied');
- }
- /**
- * Description of operation_log
- *
- * @author Administrator
- */
- class report {
- private static $_report;
- public static function getInstance() {
- if (!self::$_report) {
- $c = __CLASS__;
- self::$_report = new $c;
- }
- return self::$_report;
- }
- /**
- * report 配置
- */
- public function report_config(){
- $operate = utils::_get('operate');
- $operate = strtolower($operate);
- /**
- * report的配置查询,
- */
- if ($operate == "search"){
- $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;
- $rc = $_POST ['rc'];
- if ($rc == - 1) {
- $sql = "select count(*) from public.kln_report_template";
- $rc = common::excuteOneSql($sql);
- }
- $tp = ceil($rc / $ps);
- if ($rc > 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();
- }
- }
- }
- ?>
|