PMCORE-2369 Kpi Report by process and Report by user does not work and the error is displayed on the taskscheduler log

This commit is contained in:
Roly Rudy Gutierrez Pinto
2021-07-01 14:24:09 -04:00
parent 4d77676d0c
commit f647b1ffa2
4 changed files with 38 additions and 7 deletions

View File

@@ -332,11 +332,18 @@ class G
$ip = getenv('HTTP_CLIENT_IP'); $ip = getenv('HTTP_CLIENT_IP');
} elseif (getenv('HTTP_X_FORWARDED_FOR')) { } elseif (getenv('HTTP_X_FORWARDED_FOR')) {
$ip = getenv('HTTP_X_FORWARDED_FOR'); $ip = getenv('HTTP_X_FORWARDED_FOR');
} else { } elseif (getenv('HTTP_X_FORWARDED')) {
$ip = getenv('HTTP_X_FORWARDED');
} elseif (getenv('HTTP_FORWARDED_FOR')) {
$ip = getenv('HTTP_FORWARDED_FOR');
} elseif (getenv('HTTP_FORWARDED')) {
$ip = getenv('HTTP_FORWARDED');
} elseif (getenv('REMOTE_ADDR')) {
$ip = getenv('REMOTE_ADDR'); $ip = getenv('REMOTE_ADDR');
} } elseif (class_exists('Request')) {
if ($ip === false) {
$ip = Request::ip(); $ip = Request::ip();
} else {
$ip = gethostbyname(gethostname());
} }
return $ip; return $ip;
} }

View File

@@ -1,5 +1,7 @@
<?php <?php
use ProcessMaker\Core\System;
// Auto loader // Auto loader
require_once __DIR__ . '/../../../bootstrap/autoload.php'; require_once __DIR__ . '/../../../bootstrap/autoload.php';

View File

@@ -1,4 +1,7 @@
<?php <?php
use ProcessMaker\Core\System;
try { try {
global $G_PUBLISH; global $G_PUBLISH;
$G_PUBLISH = new Publisher(); $G_PUBLISH = new Publisher();

View File

@@ -172,7 +172,9 @@ class TaskSchedulerBM
"everyOn" => "1", "everyOn" => "1",
"interval" => "week", "interval" => "week",
"expression" => "*/10 * * * 0,1,2,3,4,5,6", "expression" => "*/10 * * * 0,1,2,3,4,5,6",
"description" => "ID_TASK_SCHEDULER_REPORT_USERS_DESC" "description" => "ID_TASK_SCHEDULER_REPORT_USERS_DESC",
"initDate" => "+init-date",
"finishDate" => "+finish-date"
], ],
[ [
"title" => "ID_TASK_SCHEDULER_REPORT_PROCESS", "title" => "ID_TASK_SCHEDULER_REPORT_PROCESS",
@@ -189,7 +191,9 @@ class TaskSchedulerBM
"everyOn" => "1", "everyOn" => "1",
"interval" => "week", "interval" => "week",
"expression" => "*/10 * * * 0,1,2,3,4,5,6", "expression" => "*/10 * * * 0,1,2,3,4,5,6",
"description" => "ID_TASK_SCHEDULER_CALCULATE_APP_DESC" "description" => "ID_TASK_SCHEDULER_CALCULATE_APP_DESC",
"initDate" => "+init-date",
"finishDate" => "+finish-date"
], ],
[ [
"title" => "ID_TASK_SCHEDULER_LDAP", "title" => "ID_TASK_SCHEDULER_LDAP",
@@ -279,10 +283,25 @@ class TaskSchedulerBM
$task->description = $service["description"]; $task->description = $service["description"];
$task->startingTime = $service["startingTime"]; $task->startingTime = $service["startingTime"];
$task->endingTime = $service["endingTime"]; $task->endingTime = $service["endingTime"];
$activity = $service["service"];
//for init date and finish date parameters
$currentDate = date("Y-m-d H:i:s");
$setOfActivities = ["report_by_user", "report_by_process"];
if (!empty($service["initDate"]) && in_array($activity, $setOfActivities)) {
$oneMonthAgo = $currentDate . " -1 month";
$timestamp = strtotime($oneMonthAgo);
$oneMonthAgo = date("Y-m-d H:i:s", $timestamp);
$activity = $activity . ' ' . $service["initDate"] . '"' . $oneMonthAgo . '"';
}
if (!empty($service["finishDate"]) && in_array($activity, $setOfActivities)) {
$activity = $activity . ' ' . $service["initDate"] . '"' . $currentDate . '"';
}
if ($win) { if ($win) {
$task->body = 'php "' . PATH_TRUNK . $service["filew"] . '" ' . $service["service"] . ' +w' . config("system.workspace") . ' +force +async'; $task->body = 'php "' . PATH_TRUNK . $service["filew"] . '" ' . $activity . ' +w' . config("system.workspace") . ' +force +async';
} else { } else {
$task->body = 'su -s /bin/sh -c "php ' . PATH_TRUNK . $service["file"] . " " . $service["service"] . ' +w' . config("system.workspace") . ' +force +async"'; $task->body = 'su -s /bin/sh -c "php ' . PATH_TRUNK . $service["file"] . " " . $activity . ' +w' . config("system.workspace") . ' +force +async"';
} }
$task->expression = $service["expression"]; $task->expression = $service["expression"];
$task->type = "shell"; $task->type = "shell";