$locationid, 'act' => $action )); } private static function calcNextexec($action, $openingTimes) { //TODO: Calculate nextExec based on openingTimes. Needs action to know if openTimes or closingTimes are used. return 0; } private static function upsert($locationid, $action, $nextexec, $options) { $schedule = Database::queryFirst("SELECT locationid, action FROM `reboot_scheduler` WHERE locationid = :lid AND action = :act", array( 'lid' => $locationid, 'act' => $action )); if ($schedule === false) { Database::exec("INSERT INTO `reboot_scheduler` (locationid, action, nextexecution, options) VALUES (:lid, :act, :next, :opt)", array( 'lid' => $locationid, 'act' => $action, 'next' => $nextexec, 'opt' => $options )); } else { Database::exec("UPDATE `reboot_scheduler` SET nextexecution = :next, options = :opt WHERE locationid = :lid AND action = :act", array( 'next' => $nextexec, 'opt' => $options, 'lid' => $locationid, 'act' => $action )); } return true; } }