function upgrade(&$new_date) { global $_DB, $_STATE; // $diff = date_diff($_STATE->fields["Close Date"]->value, COM_NOW(), true); // if ($diff->m > 2) { $sql = "SELECT MAX(logdate) AS max_date FROM " . $_DB->prefix . "b00_timelog;"; $stmt = $_DB->query($sql); $row = $stmt->fetchObject(); $max_date = new DateTime($row->max_date); $stmt->closeCursor(); $diff = date_diff($max_date, $new_date->value, true); $interval = new DateInterval("P" . $diff->days . "D"); $diff = 1; if ($max_date > $new_date->value) { $diff = -1; } $_STATE->records = DB_tables($_DB->prefix); foreach ($_POST["chkDate"] as $chkDate) { up_date($chkDate, $interval, $diff); } echo "<br>Done!"; exit; }
<?php //copyright 2015-2016 C.D.Price. Licensed under Apache License, Version 2.0 //See license text at http://www.apache.org/licenses/LICENSE-2.0 if ($_SESSION["_SITE_CONF"]["RUNLEVEL"] < 1 || !$_PERMITS->can_pass(PERMITS::_SUPERUSER)) { throw_the_bum_out(NULL, "Evicted(" . __LINE__ . "): no permit"); } require_once "lib/tables_list.php"; $_STATE->records = DB_tables($_DB->prefix); $REFRESH_PATH = $_SESSION["_SITE_CONF"]["_STASH"] . "/refresh/"; //Main State Gate: (the while (1==1) allows a loop back through the switch using a 'break 1') while (1 == 1) { switch ($_STATE->status) { case STATE::INIT: $_STATE->msgGreet = "Check the tables to save"; $_STATE->status = STATE::UPDATE; break 2; case STATE::UPDATE: $_STATE->msgStatus = "Tables saved:"; entry_audit(); $_STATE->msgGreet = "Check more to save"; break 2; default: throw_the_bum_out(NULL, "Evicted(" . __LINE__ . "): invalid state=" . $_STATE->status); } } //while & switch //End Main State Gate function save(&$table) { global $_DB, $REFRESH_PATH;