$_STATE->records = DB_tables($_DB->prefix); $_STATE->msgGreet = "Enter the new date"; $_STATE->status = STATE::SELECT; //prepare a 'goback' // break 1; //do a re-switch //prepare a 'goback' // break 1; //do a re-switch case STATE::SELECT: $_STATE->old_date = ""; $new_date = new DATE_FIELD("txtNew", "", TRUE, TRUE, TRUE, 0, FALSE, "now"); old_date(); $_STATE->status = STATE::UPDATE; break 2; case STATE::UPDATE: $_STATE->msgGreet = ""; $new_date = new DATE_FIELD("txtNew", "", TRUE, TRUE, TRUE, 0, FALSE, "now"); $msg = $new_date->audit(); if ($msg === true) { upgrade($new_date); } else { $_STATE->msgStatus = $msg; $_STATE->status = STATE::INIT; break; } $_STATE->status = STATE::DONE; break 2; default: throw_the_bum_out(NULL, "Evicted(" . __LINE__ . "): invalid state=" . $_STATE->status); } } //while & switch
function POST($chkrecent = 3) { //1=to,2=from,3=logical OR global $_STATE; if (!isset($_POST["radRange"])) { return false; } //can happen on a goback if ($this->uses & DATE_SELECT::FROM) { //From date //pagename,DBname,load from DB?,write to DB?,required?,maxlength,disabled,value $from = new DATE_FIELD("txtFrom", "", FALSE, FALSE, FALSE, 0, FALSE, $this->from); $chk = $chkrecent & DATE_SELECT::FROM; if (($msg = $from->audit($chk)) !== true) { $_STATE->msgStatus = "From Date error: " . $msg; return false; } } if ($this->uses & DATE_SELECT::TO) { //To date $to = new DATE_FIELD("txtTo", "", FALSE, FALSE, FALSE, 0, FALSE, $this->to); $chk = $chkrecent & DATE_SELECT::TO; if (($msg = $to->audit($chk)) !== true) { $_STATE->msgStatus = "To Date error: " . $msg; return false; } } $this->checked = $_POST["radRange"]; switch ($this->checked) { case "a": break; case "b": break; case "m": $from->value->modify("first day of this month"); $to->value = clone $from->value; $to->value->modify("last day of this month"); break; case "p": break; case "s": break; case "w": if ($from->format("w") != 0 && $from->format("N") != 1) { $from->value->modify("last monday"); } $to->value = clone $from->value; $to->value->add(new DateInterval('P6D')); //P=period, 6=number, D=days } if ($this->uses & 3 && $from->value > $to->value) { $_STATE->msgStatus = "Error: From Date must be less than To Date"; return false; } if ($this->uses & DATE_SELECT::TO) { $now = COM_NOW(); $diff = date_diff($to->value, $now, true); if ($diff->m > 2) { if ($_STATE->msgStatus != "") { $_STATE->msgStatus .= "<br>"; } $_STATE->msgStatus .= "These dates are suspect - proceeding anyway"; } } $this->from = clone $from->value; $this->to = clone $to->value; return true; }