Merge branch 'ent-8934-Macros-para-fechas-en-custom-SQL' into 'develop'
Added new macros See merge request artica/pandorafms!5103
This commit is contained in:
commit
30edbc81ad
|
@ -2335,7 +2335,7 @@ $class = 'databox filters';
|
|||
<td class="bolder">
|
||||
<?php
|
||||
echo __('SQL query').ui_print_help_tip(
|
||||
__('The entities of the fields that contain them must be included.'),
|
||||
__('The entities of the fields that contain them must be included. Also is possible use macros like `_start_date_` or `_end_date_`.'),
|
||||
true
|
||||
);
|
||||
?>
|
||||
|
|
|
@ -7213,7 +7213,7 @@ function reporting_sql($report, $content)
|
|||
$sql = $content['external_source'];
|
||||
}
|
||||
|
||||
// Check if exist sql macro
|
||||
// Check if exist sql macro.
|
||||
$sql = reporting_sql_macro($report, $sql);
|
||||
|
||||
// Do a security check on SQL coming from the user.
|
||||
|
@ -14718,6 +14718,25 @@ function reporting_sql_macro(array $report, string $sql): string
|
|||
);
|
||||
}
|
||||
|
||||
if (preg_match('/_start_date_/', $sql)) {
|
||||
$date_init = get_parameter('date_init', date(DATE_FORMAT, (strtotime(date('Y-m-j')) - SECONDS_1DAY)));
|
||||
$time_init = get_parameter('time_init', date(TIME_FORMAT, (strtotime(date('Y-m-j')) - SECONDS_1DAY)));
|
||||
$datetime_init = strtotime($date_init.' '.$time_init);
|
||||
$sql = str_replace(
|
||||
'_start_date_',
|
||||
$datetime_init,
|
||||
$sql
|
||||
);
|
||||
}
|
||||
|
||||
if (preg_match('/_end_date_/', $sql)) {
|
||||
$sql = str_replace(
|
||||
'_end_date_',
|
||||
$report['datetime'],
|
||||
$sql
|
||||
);
|
||||
}
|
||||
|
||||
return $sql;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue