|
|
@@ -651,7 +651,7 @@ class report {
|
|
|
quarterly_month,quarterly_day,TO_CHAR(quarterly_time, 'HH24:MI') as quarterly_time,
|
|
|
array_to_json(yearly_month) as yearly_month_json,yearly_day, TO_CHAR(yearly_time, 'HH24:MI') as yearly_time,
|
|
|
timezone,email_recipients
|
|
|
- from public.kln_report_template where serial_no = '$serial_no'");
|
|
|
+ from public.kln_report_schedule where serial_no = '$serial_no' and lower(create_by) = '".strtolower(_getLoginName())."'");
|
|
|
|
|
|
$schedule["weekly_days"] = json_decode($schedule["weekly_days"],true);
|
|
|
$schedule["monthly_day"] = json_decode($schedule["monthly_day"],true);
|
|
|
@@ -738,11 +738,13 @@ class report {
|
|
|
|
|
|
|
|
|
//形成sql
|
|
|
- $schedule_search = common::excuteObjectSql("select name,level,schedule_order_field,data_reference_field,data_range_type,
|
|
|
- dynamic_start_offset,dynamic_end_offset,
|
|
|
- fixed_start_date,fixed_end_date,
|
|
|
- report_sql,count_sql
|
|
|
- from public.kln_report_template where serial_no = '$serial_no'");
|
|
|
+ $schedule_search = common::excuteObjectSql("select t.name,t.level,s.schedule_order_field,s.data_reference_field,s.data_range_type,
|
|
|
+ s.dynamic_start_offset,s.dynamic_end_offset,
|
|
|
+ s.fixed_start_date,s.fixed_end_date,
|
|
|
+ t.report_sql,t.count_sql
|
|
|
+ from public.kln_report_schedule s
|
|
|
+ left join kln_report_template t on s.serial_no = t.serial_no
|
|
|
+ where s.serial_no = '$serial_no' and lower(s.create_by) = '".strtolower(_getLoginName())."'");
|
|
|
|
|
|
$report_sql = $schedule_search["report_sql"];
|
|
|
//$count_sql = $schedule_search["count_sql"];
|
|
|
@@ -903,43 +905,63 @@ class report {
|
|
|
$yearly_day = "'".common::check_input($_POST ['day'])."'";
|
|
|
$yearly_time = "'".common::check_input($_POST ['time'])."'";
|
|
|
}
|
|
|
+
|
|
|
$sql = "";
|
|
|
$klnOceanSearchKLN = ' where ' . common::searchExtendHand_KLN("ocean", $_SESSION["ONLINE_USER"]);
|
|
|
if (!empty($serial_no)){
|
|
|
- $updateSqlSet = " schedule_order_field = '".$schedule_order_field."',
|
|
|
- validity_type = '".$validity_type."',
|
|
|
- valid_from = ".$valid_from.",
|
|
|
- valid_to = ".$valid_to.",
|
|
|
-
|
|
|
- data_reference_field = '".$data_reference_field."',
|
|
|
- data_range_type = '".$data_range_type."',
|
|
|
- dynamic_start_offset = ".$dynamic_start_offset.",
|
|
|
- dynamic_end_offset = ".$dynamic_end_offset.",
|
|
|
- fixed_start_date = ".$fixed_start_date.",
|
|
|
- fixed_end_date = ".$fixed_end_date.",
|
|
|
-
|
|
|
- delivery_frequency = '".$delivery_frequency."',
|
|
|
- daily_time = ".$daily_time.",
|
|
|
- weekly_day = ".$weekly_day.",
|
|
|
- weekly_time = ".$weekly_time.",
|
|
|
- monthly_day = ".$monthly_day.",
|
|
|
- monthly_time = ".$monthly_time.",
|
|
|
- quarterly_month = ".$quarterly_month.",
|
|
|
- quarterly_day = ".$quarterly_day.",
|
|
|
- quarterly_time = ".$quarterly_time.",
|
|
|
- yearly_month = ".$yearly_month.",
|
|
|
- yearly_day = ".$yearly_day.",
|
|
|
- yearly_time = ".$yearly_time.",
|
|
|
- timezone = '".$timezone."',
|
|
|
- email_recipients = '".$email_recipients."',
|
|
|
- next_run_time = null,
|
|
|
- search_extend_hand = '".common::check_input($klnOceanSearchKLN)."',
|
|
|
- modify_by = '"._getLoginName()."',
|
|
|
- update_time = now()";
|
|
|
- //代表update
|
|
|
- $sql .= "update public.kln_report_template set ".$updateSqlSet."
|
|
|
- where serial_no = '$serial_no';";
|
|
|
- }
|
|
|
+ $exist = common::excuteObjectSql("select serial_no from public.kln_report_schedule where serial_no = '$serial_no' and lower(create_by) = '".strtolower(_getLoginName())."'");
|
|
|
+ if (!empty($exist['serial_no'])) {
|
|
|
+ $updateSqlSet = " schedule_order_field = '".$schedule_order_field."',
|
|
|
+ validity_type = '".$validity_type."',
|
|
|
+ valid_from = ".$valid_from.",
|
|
|
+ valid_to = ".$valid_to.",
|
|
|
+
|
|
|
+ data_reference_field = '".$data_reference_field."',
|
|
|
+ data_range_type = '".$data_range_type."',
|
|
|
+ dynamic_start_offset = ".$dynamic_start_offset.",
|
|
|
+ dynamic_end_offset = ".$dynamic_end_offset.",
|
|
|
+ fixed_start_date = ".$fixed_start_date.",
|
|
|
+ fixed_end_date = ".$fixed_end_date.",
|
|
|
+
|
|
|
+ delivery_frequency = '".$delivery_frequency."',
|
|
|
+ daily_time = ".$daily_time.",
|
|
|
+ weekly_day = ".$weekly_day.",
|
|
|
+ weekly_time = ".$weekly_time.",
|
|
|
+ monthly_day = ".$monthly_day.",
|
|
|
+ monthly_time = ".$monthly_time.",
|
|
|
+ quarterly_month = ".$quarterly_month.",
|
|
|
+ quarterly_day = ".$quarterly_day.",
|
|
|
+ quarterly_time = ".$quarterly_time.",
|
|
|
+ yearly_month = ".$yearly_month.",
|
|
|
+ yearly_day = ".$yearly_day.",
|
|
|
+ yearly_time = ".$yearly_time.",
|
|
|
+ timezone = '".$timezone."',
|
|
|
+ email_recipients = '".$email_recipients."',
|
|
|
+ next_run_time = null,
|
|
|
+ search_extend_hand = '".common::check_input($klnOceanSearchKLN)."',
|
|
|
+ create_by = '"._getLoginName()."',
|
|
|
+ created_time = now()";
|
|
|
+ //代表update
|
|
|
+ $sql .= "update public.kln_report_schedule set ".$updateSqlSet."
|
|
|
+ where serial_no = '$serial_no' and lower(create_by) = '".strtolower(_getLoginName())."';";
|
|
|
+ } else {
|
|
|
+ $sql .= "INSERT INTO public.kln_report_schedule(
|
|
|
+ serial_no, search_extend_hand, schedule_order_field,
|
|
|
+ validity_type, valid_from, valid_to, data_reference_field, data_range_type,
|
|
|
+ dynamic_start_offset, dynamic_end_offset, fixed_start_date, fixed_end_date,
|
|
|
+ delivery_frequency, daily_time, weekly_day, weekly_time, monthly_day,
|
|
|
+ monthly_time, quarterly_month, quarterly_day, quarterly_time,
|
|
|
+ yearly_month, yearly_day, yearly_time, timezone, email_recipients,
|
|
|
+ next_run_time, create_by, created_time)
|
|
|
+ VALUES ('$serial_no', '".common::check_input($klnOceanSearchKLN)."', '".$schedule_order_field."',
|
|
|
+ '".$validity_type."', ".$valid_from.", ".$valid_to.", '".$data_reference_field."', '".$data_range_type."',
|
|
|
+ ".$dynamic_start_offset.", ".$dynamic_end_offset.", ".$fixed_start_date.", ".$fixed_end_date.",
|
|
|
+ '".$delivery_frequency."', ".$daily_time.", ".$weekly_day.", ".$weekly_time.", ".$monthly_day.",
|
|
|
+ ".$monthly_time.", ".$quarterly_month.", ".$quarterly_day.", ".$quarterly_time.",
|
|
|
+ ".$yearly_month.", ".$yearly_day.", ".$yearly_time.", '".$timezone."', '".$email_recipients."',
|
|
|
+ null, '"._getLoginName()."',now());";
|
|
|
+ }
|
|
|
+ }
|
|
|
if (!empty($sql)){
|
|
|
common::excuteUpdateSql($sql);
|
|
|
//执行成功后,处理next_run_time
|
|
|
@@ -948,14 +970,14 @@ class report {
|
|
|
array_to_json(monthly_day) as monthly_day_json,monthly_time,
|
|
|
quarterly_month,quarterly_day,quarterly_time,
|
|
|
array_to_json(yearly_month) as yearly_month_json,yearly_day,yearly_time,timezone
|
|
|
- from public.kln_report_template where serial_no = '$serial_no';");
|
|
|
+ from public.kln_report_schedule where serial_no = '$serial_no' and lower(create_by) = '".strtolower(_getLoginName())."';");
|
|
|
|
|
|
$config["weekly_day"] = json_decode($config["weekly_day_json"],true);
|
|
|
$config["monthly_day"] = json_decode($config["monthly_day_json"],true);
|
|
|
$config["yearly_month"] = json_decode($config["yearly_month_json"],true);
|
|
|
$next = common::calculateNextRunTime($config);
|
|
|
$next_run_time = $next->format('Y-m-d H:i:s');
|
|
|
- common::excuteUpdateSql("update public.kln_report_template set next_run_time = '$next_run_time' where serial_no = '$serial_no';");
|
|
|
+ common::excuteUpdateSql("update public.kln_report_schedule set next_run_time = '$next_run_time' where serial_no = '$serial_no' and lower(create_by) = '".strtolower(_getLoginName())."';");
|
|
|
|
|
|
$data = array("msg" =>"success");
|
|
|
}
|