59 lines
2.3 KiB
PHP
59 lines
2.3 KiB
PHP
<?php
|
|
/** \file scripts/other/tasks/release_check.php
|
|
* \brief DI webinterface task manager script, release check
|
|
* \author Rob Schalken, Core|Vision
|
|
* \version $Revision: 1.2 $
|
|
* \date $Date: 2013/03/13 17:11:35 $
|
|
*
|
|
* Release check
|
|
*/
|
|
|
|
/************************************/
|
|
/* Release check */
|
|
/************************************/
|
|
|
|
// Get all rc projects with the sstatus = "request for release"
|
|
$projects = db_fetch("project","*","parent IS NULL AND status!='afgesloten' AND sstatus='verzoek tot vrijgeven' AND type='rc' ORDER BY NAAM");
|
|
|
|
if (is_array($projects)) {
|
|
foreach($projects as $project) {
|
|
// Detect last request
|
|
$log_user_project = db_fetch("log_gebruiker_project", "id", "FIND_IN_SET('sstatus',wijzigingen) > 0 and sstatus='verzoek tot vrijgeven' and project=" . $project['id'] . " order by id desc limit 1");
|
|
|
|
if (is_array($log_user_project)) {
|
|
// Detect timestamp last request
|
|
$log_user = db_fetch("log_gebruiker", "tijd", "id=" . $log_user_project[0]['id']);
|
|
if (is_array($log_user)) {
|
|
// Time exceeds 3 times the Power management timeout? => sstatus becomes "not released" => The devices can rest
|
|
if ((convert_datetime(date("Y-m-d H:i:s")) - convert_datetime($log_user[0]['tijd'])) > (3 * PM_TIMEOUT)) {
|
|
// Update project sstatus
|
|
$project['sstatus'] = "niet vrijgegeven";
|
|
|
|
// Update project (only sstatus of parent (and equipment), no users/equipment, no mail)
|
|
db_update_project($project, 0, array("sstatus"), "", $dummy, FALSE);
|
|
|
|
// Debug info
|
|
DBG("Release check: sstatus project: " . $project['naam'] . " (id: " . $project['id'] . ") => \"not released\"");
|
|
|
|
// Retrieve switching equipment active (on all periods)?
|
|
$equipment = db_fetch_project_lances($project['id'], "", array("kortsluiting schakelen"));
|
|
|
|
if (is_array($equipment)) {
|
|
foreach($equipment as $item) {
|
|
// Be sure the power management state is enabled => sync => release
|
|
tcpclient_sync($item['id'], FALSE, "release");
|
|
|
|
// Debug info
|
|
DBG("Release check: sync equipment: " . $item['idcode'] . "");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
// Set handled flag
|
|
$handled = 1;
|
|
|
|
?>
|