2012-09-24 11:51:45 -04:00
|
|
|
<?php
|
2012-10-17 15:40:37 -04:00
|
|
|
|
2018-08-20 14:40:30 -04:00
|
|
|
use ProcessMaker\BusinessModel\Files\Cron;
|
2012-10-17 15:40:37 -04:00
|
|
|
|
2018-08-20 14:40:30 -04:00
|
|
|
$option = isset($_REQUEST["option"]) ? $_REQUEST["option"] : null;
|
2012-09-24 11:51:45 -04:00
|
|
|
|
2018-08-20 14:40:30 -04:00
|
|
|
$response = [];
|
2012-09-24 11:51:45 -04:00
|
|
|
|
|
|
|
|
switch ($option) {
|
|
|
|
|
case "LST":
|
2012-10-17 15:40:37 -04:00
|
|
|
$pageSize = $_REQUEST["pageSize"];
|
2017-10-10 12:33:25 -04:00
|
|
|
$workspace = config("system.workspace");
|
2012-10-17 15:40:37 -04:00
|
|
|
$status = $_REQUEST["status"];
|
|
|
|
|
$dateFrom = $_REQUEST["dateFrom"];
|
|
|
|
|
$dateTo = $_REQUEST["dateTo"];
|
|
|
|
|
|
2018-08-20 14:40:30 -04:00
|
|
|
$filter = [
|
|
|
|
|
"workspace" => $workspace,
|
|
|
|
|
"status" => $status,
|
|
|
|
|
"dateFrom" => str_replace("T00:00:00", null, $dateFrom),
|
|
|
|
|
"dateTo" => str_replace("T00:00:00", null, $dateTo)
|
|
|
|
|
];
|
2012-09-24 11:51:45 -04:00
|
|
|
|
2018-08-20 14:40:30 -04:00
|
|
|
$start = (int) isset($_REQUEST["start"]) ? $_REQUEST["start"] : 0;
|
|
|
|
|
$limit = (int) isset($_REQUEST["limit"]) ? $_REQUEST["limit"] : $pageSize;
|
2012-09-24 11:51:45 -04:00
|
|
|
|
2018-08-20 14:40:30 -04:00
|
|
|
$cron = new Cron();
|
|
|
|
|
list ($count, $data) = $cron->getData($filter, $start, $limit);
|
2012-09-24 11:51:45 -04:00
|
|
|
|
2018-08-20 14:40:30 -04:00
|
|
|
$response = [
|
|
|
|
|
"success" => true,
|
|
|
|
|
"resultTotal" => $count,
|
|
|
|
|
"resultRoot" => $data
|
|
|
|
|
];
|
2012-09-24 11:51:45 -04:00
|
|
|
break;
|
|
|
|
|
case "EMPTY":
|
|
|
|
|
$status = 1;
|
|
|
|
|
try {
|
|
|
|
|
$file = PATH_DATA . "log" . PATH_SEP . "cron.log";
|
2018-08-20 14:40:30 -04:00
|
|
|
if (file_exists($file)) {
|
|
|
|
|
unlink($file);
|
2012-09-24 11:51:45 -04:00
|
|
|
}
|
|
|
|
|
$response["status"] = "OK";
|
2014-10-10 12:19:34 -04:00
|
|
|
G::auditLog("ClearCron");
|
2012-09-24 11:51:45 -04:00
|
|
|
} catch (Exception $e) {
|
|
|
|
|
$response["message"] = $e->getMessage();
|
|
|
|
|
$status = 0;
|
|
|
|
|
}
|
|
|
|
|
if ($status == 0) {
|
|
|
|
|
$response["status"] = "ERROR";
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2018-08-20 14:40:30 -04:00
|
|
|
echo G::json_encode($response);
|