Files
crm.clientright.ru/Send2Court.stable

54 lines
2.3 KiB
Plaintext
Executable File
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
file_put_contents('send2court.log', date('Y-m-d H:i:s').' - старт корневой процедуры отправки исковых'.PHP_EOL, FILE_APPEND);
set_time_limit(0); //Снимаем ограничение по времени работы скрипта
error_reporting(E_ALL);
ini_set('display_errors', '1');
$id = $_REQUEST['id'];
$version = $_REQUEST['version'];
require_once 'include/utils/Debexpert-guzzle.php';
require_once 'include/utils/utils.php';
if (isset($id) and !empty($id) and $id > 0) {
// Задан ID конкретного Проекта - его и отправим
$result = Send2Court($id, $version);
if (is_array($result)) {
// Завершилось относительно ровно, в том плане, что логических ошибок не найдено, которые прервали бы процесс
$result = json_encode($result);
}
file_put_contents('send2court.log', date('Y-m-d H:i:s').' - в WD возвращаем ответ: '.$result.PHP_EOL, FILE_APPEND);
echo $result;
} else {
// Конкретный Проект не задан - значит отправим все
global $adb;
$query = 'select p.projectid
from vtiger_project p
left join vtiger_crmentity e on e.crmid = p.projectid
left join vtiger_projectcf cf on cf.projectid = p.projectid
where e.deleted = 0 and p.projectstatus = "готово для подачи" and cf.cf_1501 not like "%Москва%" and cf.cf_1501 not like "%москва%"';
$result = $adb->pquery($query);
$count = $adb->num_rows($result);
if ($count > 0) {
file_put_contents('send2court.log', date('Y-m-d H:i:s').' - найдено '.$count.' Проектов на отправку в суд'.PHP_EOL, FILE_APPEND);
// Есть Проекты на отправку
for ($i=0; $i<$count; $i++) {
$id = $adb->query_result($result, $i, 'projectid');
if ($i > 0) {
// Пауза между отправками
sleep(10);
}
$out = Send2Court($id, $version);
}
file_put_contents('send2court.log', date('Y-m-d H:i:s').' - закончили отправку всех исковых'.PHP_EOL, FILE_APPEND);
} else {
file_put_contents('send2court.log', date('Y-m-d H:i:s').' - Проектов на отправку в суд не обнаружено'.PHP_EOL, FILE_APPEND);
}
}
?>