function getInvoicesToRepeat($dateToCheck = NULL) { if ($dateToCheck == NULL) { $dateToCheck = mktime(0, 0, 0); } $invoiceList = array(); $querystatement = "\n\t\t\tSELECT\n\t\t\t\t`invoiceid`,\n\t\t\t\t`invoices`.`invoicedate`,\n\t\t\t\t`firstrepeat`,\n\t\t\t\t`lastrepeat`,\n\t\t\t\t`recurringinvoices`.`type`,\n\t\t\t\t`eachlist`,`every`,\n\t\t\t\t`ontheday`,`ontheweek`\n\t\t\tFROM\n\t\t\t\t`recurringinvoices` INNER JOIN `invoices` ON `recurringinvoices`.`invoiceid` = `invoices`.`uuid`\n\t\t\tWHERE\n\t\t\t\t`invoices`.`invoicedate` <= '" . dateToString($dateToCheck, "SQL") . "'\n\t\t\t\tAND\n\t\t\t\t(`recurringinvoices`.`until` IS NULL OR `recurringinvoices`.`until` >= '" . dateToString($dateToCheck, "SQL") . "')\n\t\t\t\tAND\n\t\t\t\t(`recurringinvoices`.`times` IS NULL OR `recurringinvoices`.`times` > `recurringinvoices`.`timesrepeated`)"; $queryresult = $this->db->query($querystatement); while ($therecord = $this->db->fetchArray($queryresult)) { if ($therecord["lastrepeat"]) { $startDate = stringToDate($therecord["lastrepeat"], "SQL"); } else { $startDate = stringToDate($therecord["invoicedate"], "SQL"); } $dateArray = $this->getValidInRange($startDate, $dateToCheck, $therecord); if (in_array($dateToCheck, $dateArray)) { $invoiceList[] = $therecord["invoiceid"]; } } //end while return $invoiceList; }
$theinput = new inputDatePicker("completeddate", $therecord["completeddate"], "completed date", false, 11, 15, false); $theinput->setAttribute("readonly", "readonly"); $theform->addField($theinput); $theinput = new inputChoiceList($db, "status", $therecord["status"], "notestatus"); $theform->addField($theinput); $theinput = new inputSmartSearch($db, "assignedtoid", "Pick Active User", $therecord["assignedtoid"], "assigned to", false, 18, 255, false); $theform->addField($theinput); $theinput = new inputDatePicker("assignedtodate", $therecord["assignedtodate"], "follow up date"); $theform->addField($theinput); $theinput = new inputTimePicker("assignedtotime", $therecord["assignedtotime"], "follow up time", false, 11, 15, false); $theform->addField($theinput); $theinput = new inputChoiceList($db, "category", $therecord["category"], "notecategories"); $theform->addField($theinput); //repeat fields if ($therecord["startdate"]) { $repeatBase = stringToDate($therecord["startdate"], "SQL"); } else { $repeatBase = mktime(); } $theinput = new inputCheckbox("repeating", $therecord["repeating"], "repeat"); $theinput->setAttribute("onchange", "checkRepeat();"); $theform->addField($theinput); $temparray = array("Daily" => "Daily", "Weekly" => "Weekly", "Monthly" => "Monthly", "Yearly" => "Yearly"); $theinput = new inputBasiclist("repeattype", $therecord["repeattype"], $temparray, "frequency"); $theinput->setAttribute("onchange", "changeRepeatType();"); $theform->addField($theinput); $theinput = new inputField("repeatevery", $therecord["repeatevery"], "frequency of repeating", false, "integer", 2, 4, false); $theform->addField($theinput); $theinput = new inputBasiclist("monthlyontheweek", $therecord["repeatontheweek"], $thetable->weekArray, "on the week of", false); $theinput2 = new inputBasiclist("yearlyontheweek", $therecord["repeatontheweek"], $thetable->weekArray, "on the week of", false); if (!$therecord["repeatontheday"]) {
$querystatement .= "\n\t\t\t,\n\t\t\t`tabledefs`.`maintable`,\n\t\t\t`modules`.`name` AS `modulename`\n\t\tFROM\n\t\t"; $querystatement .= "\n\t\t\t(((scheduler LEFT JOIN `pushrecords` ON `scheduler`.`pushrecordid` = `pushrecords`.`uuid`) LEFT JOIN `tabledefs` ON `pushrecords`.`originuuid` = `tabledefs`.`uuid`) LEFT JOIN `modules` ON `tabledefs`.`moduleid` = `modules`.`uuid`)\n\t\t"; } else { $querystatement .= "\n\t\tFROM\n\t\t"; $querystatement .= "\n\t\t\t`scheduler`\n\t\t"; } //end if $querystatement .= " WHERE\n\t\t\t`scheduler`.inactive = '0'\n\t\t\tAND `scheduler`.startdatetime < NOW()\n\t\t\tAND (`scheduler`.enddatetime > NOW() OR `scheduler`.enddatetime IS NULL)\n\t"; $queryresult = $db->query($querystatement); while ($schedule_record = $db->fetchArray($queryresult)) { $datetimearray = explode(" ", $schedule_record["startdatetime"]); $schedule_record["startdate"] = stringToDate($datetimearray[0], "SQL"); $schedule_record["starttime"] = stringToTime($datetimearray[1], "24 Hour"); if ($schedule_record["enddatetime"]) { $datetimearray = explode(" ", $schedule_record["enddatetime"]); $schedule_record["enddate"] = stringToDate($datetimearray[0], "SQL"); $schedule_record["endtime"] = stringToTime($datetimearray[1], "24 Hour"); } //endif enddateiem $validTimes = getTimes($schedule_record); if (is_array($validTimes) && in_array($now, $validTimes)) { switch ($schedule_record["type"]) { case "job": $success = @(include $schedule_record["job"]); break; case "pushrecord": include_once "../../modules/api/include/push.php"; //try to include table specific functions $tableFile = "../../modules/" . $schedule_record["modulename"] . "/include/" . $schedule_record["maintable"] . ".php"; if (file_exists($tableFile)) { include_once $tableFile;
function showTasks($type) { $querystatement = "\n\t\t\tSELECT\n\t\t\t\tid,\n\t\t\t\ttype,\n\t\t\t\tsubject,\n\t\t\t\tcompleted,\n\t\t\t\tif(enddate < CURDATE(),1,0) AS ispastdue,\n\t\t\t\tif(assignedtodate < CURDATE(),1,0) AS ispastassigneddate,\n\t\t\t\tstartdate,\n\t\t\t\tenddate,\n\t\t\t\tassignedtodate,\n\t\t\t\tprivate,\n\t\t\t\tassignedbyid,\n\t\t\t\tassignedtoid,\n\t\t\t\tIF(assignedtodate IS NOT NULL, assignedtodate, IF((enddate IS NOT NULL && type = 'TS'), enddate, IF((startdate IS NOT NULL && type = 'EV'), startdate, CURDATE()))) AS xdate\n\t\t\tFROM\n\t\t\t\tnotes\n\t\t\tWHERE"; switch ($type) { case "ReceivedAssignments": $querystatement .= "\n\t\t\t\t\t((\n\t\t\t\t\t\tassignedtoid = '" . $this->useruuid . "'\n\t\t\t\t\t\tOR \t(\n\t\t\t\t\t\t\ttype = 'TS'\n\t\t\t\t\t\t\tAND (assignedtoid = '' OR assignedtoid IS NULL)\n\t\t\t\t\t\t\tAND createdby = " . $this->userid . "\n\t\t\t\t\t\t\t)\n\t\t\t\t\t)\n\t\t\t\t\t\tAND \t(\n\t\t\t\t\t\t\tcompleted = 0\n\t\t\t\t\t\t\tOR \t(\n\t\t\t\t\t\t\t\tcompleted = 1\n\t\t\t\t\t\t\t\tAND completeddate >= CURDATE()\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t)\n\t\t\t\t\t)"; $title = "Assignments"; $id = "AS"; break; case "GivenAssignments": $querystatement .= "\n\t\t\t\t\t(assignedbyid = '" . $this->useruuid . "'\n\t\t\t\t\tAND (completed = 0\n\t\t\t\t\t\tOR (completed = 1 AND completeddate >= CURDATE())\n\t\t\t\t\t))"; $title = "Delegations"; $id = "DG"; break; } //endswitch $querystatement .= "AND (\n\t\t\t\t\t(startdate IS NULL AND enddate IS NULL AND assignedtodate IS NULL)\n\t\t\t\t\tOR (startdate IS NOT NULL AND startdate <= DATE_ADD(CURDATE(),INTERVAL 30 DAY) AND enddate IS NULL AND assignedtodate IS NULL)\n\t\t\t\t\tOR (enddate IS NOT NULL AND enddate <= DATE_ADD(CURDATE(),INTERVAL 30 DAY))\n\t\t\t\t\tOR (assignedtodate IS NOT NULL AND assignedtodate <= DATE_ADD(CURDATE(),INTERVAL 30 DAY))\n\t\t\t\t )"; $querystatement .= " ORDER BY\n\t\t\t\timportance DESC,\n\t\t\t\txdate,\n\t\t\t\tsubject"; $queryresult = $this->db->query($querystatement); $numRows = $this->db->numRows($queryresult); ?> <h3 class="tasksLinks"><?php echo $title; if ($numRows) { ?> <span class="small">(<?php echo $numRows; ?> )</span><?php } ?> </h3> <div class="tasksDivs"> <div> <?php if ($numRows) { $linkStart = getAddEditFile($this->db, "tbld:a4cdd991-cf0a-916f-1240-49428ea1bdd1"); $section["title"] = "Today"; $section["date"] = mktime(0, 0, 0, date("m"), date("d"), date("Y")); while ($therecord = $this->db->fetchArray($queryresult)) { $className = "tasks"; if ($therecord["completed"]) { $className .= " complete"; } else { if ($therecord["ispastdue"] || $therecord["ispastassigneddate"]) { $className .= " pastDue"; } } if ($therecord["private"]) { $className .= " private"; } $className .= " " . $therecord["type"]; $checkBoxID = $id . $therecord["type"] . "C" . $therecord["id"]; $link = $linkStart . "?id=" . $therecord["id"] . "&backurl=" . APP_PATH . "modules/base/snapshot.php"; $rightSide = ""; if ($therecord["assignedtodate"]) { $rightSide .= "FUP: " . formatFromSQLDate($therecord["assignedtodate"]) . "<br />"; } switch ($therecord["type"]) { case "TS": if ($therecord["enddate"]) { $rightSide .= "Due: " . formatFromSQLDate($therecord["enddate"]) . "<br />"; } break; case "EV": $rightSide .= "Start: " . formatFromSQLDate($therecord["startdate"]) . "<br />"; $rightSide .= "End: " . formatFromSQLDate($therecord["enddate"]) . "<br />"; break; } //endswitch if (!$rightSide) { $rightSide = " "; } $bottomInfo = ""; switch ($type) { case "ReceivedAssignments": if ($therecord["assignedbyid"]) { $bottomInfo = "Assigned By: " . htmlQuotes($this->phpbms->getUserName($therecord["assignedbyid"], true)); } break; case "GivenAssignments": $bottomInfo = "Assigned To: " . htmlQuotes($this->phpbms->getUserName($therecord["assignedtoid"], true)); break; } //endswitch // Looking for grouping changes in headers (3 days, 4-7 days, > 7 days) $xdate = stringToDate($therecord["xdate"], "SQL"); if ($xdate > $section["date"]) { while ($xdate > $section["date"]) { switch ($section["title"]) { case "Today": $section["title"] = "Soon"; $section["date"] = mktime(0, 0, 0, date("m"), date("d") + 7, date("Y")); break; case "Soon": $section["title"] = "Later"; $section["date"] = mktime(0, 0, 0, 1, 1, 2038); break; case "Later": //should never be here $section["date"] = $xdate; } //end switch } //endwhile ?> <div class="taskSection"><?php echo $section["title"]; ?> </div><?php } //end if ?> <div id="<?php echo $id . $therecord["id"]; ?> " class="<?php echo $className; ?> "> <span class="taskRight"><?php echo $rightSide; ?> </span> <input class="radiochecks taskChecks" id="<?php echo $checkBoxID; ?> " name="<?php echo $checkBoxID; ?> " type="checkbox" value="1" <?php if ($therecord["completed"]) { echo 'checked="checked"'; } ?> align="middle" /> <a href="<?php echo $link; ?> "><?php echo htmlQuotes($therecord["subject"]); ?> </a> <?php if ($bottomInfo) { ?> <p><?php echo $bottomInfo; ?> </p> <?php } //endif ?> </div> <?php } //endwhile } else { ?> <p class="small disabledtext">no <?php echo strtolower($title); ?> </p><?php } ?> </div> </div> <?php }
function prepareVariables($variables, $userid = NULL) { if ($userid == NULL) { if (isset($_SESSION["userinfo"]["id"])) { $userid = $_SESSION["userinfo"]["id"]; } } if ($variables["id"]) { //i.e. only on update unset($this->fields["type"]); if ($variables["typeCheck"] == "TS" && isset($variables["repeating"]) && $variables["lastrepeat"]) { $variables["lastrepeat"] = NULL; $variables["firstrepeat"] = NULL; $variables["timesrepeated"] = NULL; if (isset($variables["completed"])) { $variables["completedChange"] = 0; } $this->resetRepeating($variables["id"]); } //end if } //end if if (isset($variables["thetype"])) { $variables["type"] = $variables["thetype"]; } if (!isset($variables["completed"])) { $variables["completeddate"] = NULL; } if ($variables["enddate"] == "") { $variables["enddate"] = NULL; $variables["endtime"] = NULL; } if ($variables["startdate"] == "") { $variables["startdate"] = NULL; $variables["starttime"] = NULL; } if (isset($variables["repeating"])) { $thename = "Every "; switch ($variables["repeattype"]) { case "Daily": if ($variables["repeatevery"] != 1) { $thename .= $variables["repeatevery"] . " days"; } else { $thename .= " day "; } $variables["repeatechlist"] = NULL; $variables["repeatontheday"] = NULL; $variables["repeatontheweek"] = NULL; break; case "Weekly": if ($variables["repeatevery"] != 1) { $thename .= $variables["repeatevery"] . " weeks on"; } else { $thename .= "week on"; } foreach (explode("::", $variables["eachlist"]) as $dayNum) { $tempday = $dayNum != 7 ? $dayNum + 1 : 1; $thename .= " " . nl_langinfo(constant("ABDAY_" . $tempday)) . ", "; } $thename = substr($thename, 0, strlen($thename) - 2); if (strpos($thename, ",") != false) { $thename = strrev(preg_replace("/,/", "dna ", strrev($thename), 1)); } $variables["repeateachlist"] = $variables["eachlist"]; $variables["repeatontheday"] = NULL; $variables["repeatontheweek"] = NULL; break; case "Monthly": if ($variables["repeatevery"] != 1) { $thename .= $variables["repeatevery"] . " months"; } else { $thename .= "month"; } $thename .= " on the"; if ($variables["monthlyWhat"] == 1) { foreach (explode("::", $variables["eachlist"]) as $dayNum) { $thename .= " " . ordinal($dayNum) . ", "; } $thename = substr($thename, 0, strlen($thename) - 2); if (strpos($thename, ",") != false) { $thename = strrev(preg_replace("/,/", "dna ", strrev($thename), 1)); } $variables["repeateachlist"] = $variables["eachlist"]; $variables["repeatontheday"] = NULL; $variables["repeatontheweek"] = NULL; } else { foreach ($this->weekArray as $key => $value) { if ($value == $variables["monthlyontheweek"]) { $thename .= " " . strtolower($key); } } foreach ($this->dayOfWeekArray as $key => $value) { if ($value == $variables["monthlyontheday"]) { $thename .= " " . $key; } } $variables["repeateachlist"] = NULL; $variables["repeatontheday"] = $variables["monthlyontheday"]; $variables["repeatontheweek"] = $variables["monthlyontheweek"]; } break; case "Yearly": if ($variables["repeatevery"] > 1) { $thename .= $variables["repeatevery"] . " years"; } else { $thename .= "year"; } $thename .= " in"; foreach (explode("::", $variables["eachlist"]) as $monthNum) { $thename .= " " . nl_langinfo(constant("MON_" . $monthNum)) . ", "; } $thename = substr($thename, 0, strlen($thename) - 2); if (strpos($thename, ",") != false) { $thename = strrev(preg_replace("/,/", "dna ", strrev($thename), 1)); } $variables["repeateachlist"] = $variables["eachlist"]; if (isset($variables["yearlyOnThe"])) { $thename .= " on the"; foreach ($this->weekArray as $key => $value) { if ($value == $variables["yearlyontheweek"]) { $thename .= " " . strtolower($key); } } foreach ($this->dayOfWeekArray as $key => $value) { if ($value == $variables["yearlyontheday"]) { $thename .= " " . $key; } } $variables["repeatontheday"] = $variables["yearlyontheday"]; $variables["repeatontheweek"] = $variables["yearlyontheweek"]; } else { $variables["repeatontheday"] = NULL; $variables["repeatontheweek"] = NULL; } //end if break; } switch ($variables["repeatend"]) { case "never": $variables["repeatuntil"] = NULL; $variables["repeattimes"] = NULL; break; case "after": $thename .= " for " . $variables["repeattimes"]; $variables["repeatuntil"] = NULL; break; case "on date": $thename .= " until " . $variables["repeatuntil"]; $variables["repeattimes"] = NULL; break; } $thename = trim($thename) . "."; $variables["repeatname"] = $thename; $variables["firstrepeat"] = dateToString(stringToDate($variables["firstrepeat"], "SQL")); $variables["lastrepeat"] = dateToString(stringToDate($variables["lastrepeat"], "SQL")); $variables["timesrepeated"] = NULL; } else { $variables["repeat"] = 0; $variables["repeatechlist"] = NULL; $variables["repeatontheday"] = NULL; $variables["repeatontheweek"] = NULL; $variables["repeatname"] = NULL; $variables["repeatuntil"] = NULL; $variables["repeattimes"] = NULL; $variables["firstrepeat"] = NULL; $variables["lastrepeat"] = NULL; $variables["timesrepeated"] = NULL; } //endif repeat if ($variables["assignedtoid"] != $variables["assignedtochange"]) { if ($variables["assignedtoid"] != "") { $variables["assignedbyid"] = getUuid($this->db, "tbld:afe6d297-b484-4f0b-57d4-1c39412e9dfb", $userid); } else { $variables["assignedbyid"] = ''; } } //endif return $variables; }
function post($whereclause = NULL, $postsessionid = NULL) { if ($whereclause) { $this->prepareWhere($whereclause); } if (!$postsessionid) { $postsessionid = $this->generatePostingSession("search"); } $querystatement = "\n\t\t\t\tSELECT\n\t\t\t\t\tinvoices.id,\n\t\t\t\t\tinvoices.uuid,\n\t\t\t\t\tinvoices.clientid,\n\t\t\t\t\tinvoices.totalti,\n\t\t\t\t\tinvoices.invoicedate,\n\t\t\t\t\tpaymentmethods.type,"; if (ENCRYPT_PAYMENT_FIELDS) { $paymentfields = "\n\t\t\t\t\t" . $this->db->decrypt("`invoices`.`ccnumber`") . " AS `ccnumber`,\n\t\t\t\t\t" . $this->db->decrypt("`invoices`.`ccexpiration`") . " AS `ccexpiration`,\n\t\t\t\t\t" . $this->db->decrypt("`invoices`.`ccverification`") . " AS `ccverification`,\n\t\t\t\t\t" . $this->db->decrypt("`invoices`.`routingnumber`") . " AS `routingnumber`,\n\t\t\t\t\t" . $this->db->decrypt("`invoices`.`accountnumber`") . " AS `accountnumber`"; } else { $paymentfields = "\n\t\t\t\t\tinvoices.ccnumber,\n\t\t\t\t\tinvoices.ccexpiration,\n\t\t\t\t\tinvoices.ccverification,\n\t\t\t\t\tinvoices.routingnumber,\n\t\t\t\t\tinvoices.accountnumber\n\t\t\t\t"; } //end if $querystatement .= $paymentfields . " FROM\n\t\t\t\t\tinvoices LEFT JOIN paymentmethods ON invoices.paymentmethodid = paymentmethods.uuid\n\t\t\t\tWHERE\n\t\t\t\t\t" . $this->whereclause; $queryresult = $this->db->query($querystatement); $count = 0; while ($therecord = $this->db->fetchArray($queryresult)) { $updatestatement = "\n\t\t\t\t\tUPDATE\n\t\t\t\t\t\t`invoices`\n\t\t\t\t\tSET\n\t\t\t\t\t\t`type` = 'Invoice',\n\t\t\t\t\t\t`postingsessionid` = " . $postsessionid . ","; if (ENCRYPT_PAYMENT_FIELDS) { $therecord = obfuscatePayment($therecord); if ($therecord["ccnumber"]) { $updatestatement .= "ccnumber = '" . $therecord["ccnumber"] . "', "; } if ($therecord["ccexpiration"]) { $updatestatement .= "ccexpiration = '" . $therecord["ccexpiration"] . "', "; } if ($therecord["ccverification"]) { $updatestatement .= "ccverification = '" . $therecord["ccverification"] . "', "; } if ($therecord["routingnumber"]) { $updatestatement .= "routingnumber = NULL, "; } if ($therecord["accountnumber"]) { $updatestatement .= "accountnumber = NULL, "; } } //endif - ENCRYPT_PAYMENT_FIELDS if (!$therecord["invoicedate"] || $therecord["invoicedate"] == "0000-00-00") { $therecord["invoicedate"] = dateToString(mktime(0, 0, 0), "SQL"); $updatestatement .= "\n\t\t\t\t\t\t`invoicedate` = NOW(), "; } //end if $updatestatement .= "\n\t\t\t\t\t\t`modifiedby` = " . $this->modifiedby . ",\n\t\t\t\t\t\t`modifieddate` = NOW()\n\t\t\t\t\tWHERE\n\t\t\t\t\t\t`id` = " . $therecord["id"]; $updateresult = $this->db->query($updatestatement); if ($therecord["type"] == "receivable") { // if type = AR, create AR item $arrecord["type"] = "invoice"; $arrecord["status"] = "open"; $arrecord["posted"] = 1; $arrecord["amount"] = $therecord["totalti"]; $arrecord["itemdate"] = dateToString(stringToDate($therecord["invoicedate"], "SQL")); $arrecord["clientid"] = $therecord["clientid"]; $arrecord["relatedid"] = $therecord["uuid"]; $arrecord["uuid"] = ""; if (!class_exists("phpbmsTable")) { include "include/tables.php"; } $aritems = new phpbmsTable($this->db, "tbld:c595dbe7-6c77-1e02-5e81-c2e215736e9c"); $arrecord = $aritems->prepareVariables($arrecord); $aritems->insertRecord($arrecord, $this->modifiedby); } //endif $count++; } //endwhile $this->updatePostingSession($postsessionid, $count); return $count; }
| (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | | | +-------------------------------------------------------------------------+ */ require_once "../../include/session.php"; require_once "include/fields.php"; require_once "include/post.php"; require_once "include/post_class.php"; if (!isset($_POST["startdate"])) { $_POST["startdate"] = dateToString(mktime(0, 0, 0, date("m"), 1, date("y"))); } if (!isset($_POST["enddate"])) { $_POST["enddate"] = dateToString(mktime(0, 0, 0)); } $poster = new poster($db, stringToDate($_POST["startdate"]), stringToDate($_POST["enddate"])); $poster->getSections(); if (isset($_POST["cmd"])) { $statusmessage = $poster->process($_POST); } $pageTitle = "Post Records"; $phpbms->cssIncludes[] = "pages/bms/post.css"; $phpbms->jsIncludes[] = "modules/bms/javascript/post.js"; //Form Elements //============================================================== $theform = new phpbmsForm(); $theinput = new inputDatePicker("startdate", dateToString($poster->startdate, "SQL"), "start date"); $theform->addField($theinput); $theinput = new inputDatePicker("enddate", dateToString($poster->enddate, "SQL"), "end date"); $theform->addField($theinput); $theform->jsMerge();
function processDialog($variables) { if (isset($variables["statementdate"])) { $this->statementDate = stringToDate($variables["statementdate"]); } $this->showClosed = isset($variables["showclosed"]); if (isset($variables["showpayments"])) { $this->showPayments = $variables["showpayments"]; } if (!isset($variables["selrecords"])) { $variables["selrecords"] = "allOpen"; } switch ($variables["selrecords"]) { case "allOpen": $this->generate(); break; case "allClients": $this->generate("clients.hascredit = 1"); break; case "fromPrint": $this->setupFromPrintScreen(); $this->generate(); break; } //endswitch $this->output(); }
function _showNeedingAgingTotals() { $totals = array("term1" => 0, "term2" => 0, "term3" => 0); $querystatement = "\n\t\t\tSELECT\n\t\t\t\titemdate,\n\t\t\t\taged1,\n\t\t\t\taged2,\n\t\t\t\taged3\n\t\t\tFROM\n\t\t\t\taritems\n\t\t\tWHERE\n\t\t\t\t`status` = 'open'\n\t\t\t\tAND posted = 1\n\t\t\t\tAND `type` = 'invoice'"; $queryresult = $this->db->query($querystatement); while ($therecord = $this->db->fetchArray($queryresult)) { $itemdate = stringToDate($therecord["itemdate"], "SQL"); $term1Date = strtotime(TERM1_DAYS . " days", $itemdate); $term2Date = strtotime(TERM2_DAYS . " days", $itemdate); $term3Date = strtotime(TERM3_DAYS . " days", $itemdate); $today = mktime(0, 0, 0); if ($today > $term1Date && $therecord["aged1"] == 0) { $totals["term1"]++; } elseif ($today > $term2Date && $therecord["aged2"] == 0) { $totals["term2"]++; } elseif ($today > $term2Date && $therecord["aged2"] == 0) { $totals["term3"]++; } } //endwhile ?> <p> <label for="term1"><?php echo TERM1_DAYS + 1 . " - " . TERM2_DAYS . " days"; ?> </label><br /> <input id="term1" class="uneditable" readonly="readonly" value="<?php echo $totals["term1"]; ?> "/> </p> <p> <label for="term2"><?php echo TERM2_DAYS + 1 . " - " . TERM3_DAYS . " days"; ?> </label><br /> <input id="term2" class="uneditable" readonly="readonly" value="<?php echo $totals["term2"]; ?> "/> </p> <p> <label for="term3"><?php echo TERM3_DAYS + 1 . "+ days"; ?> </label><br /> <input id="term3" class="uneditable" readonly="readonly" value="<?php echo $totals["term3"]; ?> "/> </p> <?php }
function show($itemslist, $receiptPosted, $receiptid) { $count = 1; foreach ($itemslist as $therecord) { $recID = "i" . $count; if ($therecord["type"] == "invoice") { $tempDate = stringToDate($therecord["itemdate"], "SQL"); $dueDate = dateToString(strtotime(TERM1_DAYS . " days", $tempDate)); } else { $dueDate = " "; } if ($therecord["type"] == "credit" && $therecord["relatedid"] == $receiptid) { $therecord["relatedid"] = ""; $therecord["amount"] = 0; $therecord["aritemid"] = ""; $therecord["invoiceid"] = ""; } if ($receiptPosted) { $docDue = $therecord["amount"] - $therecord["paid"]; } elseif ($therecord["relatedid"]) { $docDue = $therecord["amount"] - $therecord["paid"] - $therecord["applied"] - $therecord["discount"] - $therecord["taxadjustment"]; } else { $docDue = 0; } ?> <tr id="<?php echo $recID; ?> " class="receiptTR"> <td> <input type="hidden" id="<?php echo $recID; ?> ARID" value="<?php echo $therecord["aritemid"]; ?> " /> <input type="hidden" id="<?php echo $recID; ?> RecID" value="<?php echo $therecord["relatedid"]; ?> " /> <input id="<?php echo $recID; ?> DocRef" class="invisibleTextField" readonly="readonly" value="<?php echo $therecord["invoiceid"]; ?> " size="4"/> </td> <td><input id="<?php echo $recID; ?> Type" class="invisibleTextField" readonly="readonly" value="<?php echo $therecord["type"]; ?> " size="12" /></td> <td><input id="<?php echo $recID; ?> DocDate" class="invisibleTextField" readonly="readonly" value="<?php echo formatFromSQLDate($therecord["itemdate"]); ?> " size="9" /></td> <td><input id="<?php echo $recID; ?> DueDate" class="invisibleTextField" readonly="readonly" value="<?php echo $dueDate; ?> " size="9" /></td> <td align="right"> <input type="hidden" id="<?php echo $recID; ?> DocPaid" value="<?php echo $therecord["paid"]; ?> " /> <input id="<?php echo $recID; ?> DocAmount" class="invisibleTextField currency" readonly="readonly" value="<?php echo formatVariable($therecord["amount"], "currency"); ?> " size="10" maxlength="12"/> </td> <td><input id="<?php echo $recID; ?> DocDue" class="invisibleTextField currency dueFields" readonly="readonly" value="<?php echo formatVariable($docDue, "currency"); ?> " size="10" maxlength="12"/></td> <td><input id="<?php echo $recID; ?> Applied" class="currency appliedFields" value="<?php echo formatVariable($therecord["applied"], "currency"); ?> " size="10" maxlength="12"/></td> <td><input id="<?php echo $recID; ?> Discount" class="currency" value="<?php echo formatVariable($therecord["discount"], "currency"); ?> " size="10" maxlength="12"/></td> <td><input id="<?php echo $recID; ?> TaxAdj" class="currency" value="<?php echo formatVariable($therecord["taxadjustment"], "currency"); ?> " size="10" maxlength="12"/></td> <td><button type="button" id="<?php echo $recID; ?> RemoveARItemButton" class="graphicButtons buttonMinus" title="remove item"><span>-</span></button></td> </tr> <?php $count++; } //end foreach }
function showHistory($clientid) { $querystatement = "\n\t\t\t\tSELECT \n\t\t\t\t\tid, \n\t\t\t\t\tuuid\n\t\t\t\tFROM\n\t\t\t\t\tclients\n\t\t\t\tWHERE\n\t\t\t\t\tid=" . (int) $clientid; $queryresult = $this->db->query($querystatement); $therecord = $this->db->fetchArray($queryresult); $querystatement = "\n\t\t\t\tSELECT\n\t\t\t\t\trelatedid,\n\t\t\t\t\tamount,\n\t\t\t\t\t`type`,\n\t\t\t\t\tpaid,\n\t\t\t\t\titemdate,\n\t\t\t\t\tposted\n\t\t\t\tFROM\n\t\t\t\t\taritems\n\t\t\t\tWHERE\n\t\t\t\t\tclientid = '" . $therecord["uuid"] . "'\n\t\t\t\t\tAND `status` = 'open'\n\t\t\t\tORDER BY\n\t\t\t\t\tposted"; $queryresult = $this->db->query($querystatement); $querystatement = "\n\t\t\t\tSELECT\n\t\t\t\t\tSUM(amount) AS theamount,\n\t\t\t\t\tSUM(amount - paid) AS thedue\n\t\t\t\tFROM\n\t\t\t\t\taritems\n\t\t\t\tWHERE\n\t\t\t\t\tclientid = '" . $therecord["uuid"] . "'\n\t\t\t\t\tAND `status` = 'open'\n\t\t\t\tORDER BY\n\t\t\t\t\tposted"; $sumresult = $this->db->query($querystatement); $sumrecord = $this->db->fetchArray($sumresult); ?> <table border="0" cellpadding="0" cellspacing="0" class="querytable" id="openItems"> <thead> <tr> <th align="left" width="35%" nowrap="nowrap">doc ref</th> <th align="left" nowrap="nowrap">type</th> <th align="left" nowrap="nowrap">doc date</th> <th align="left" nowrap="nowrap">due date</th> <th align="right" width="65%" nowrap="nowrap">amount</th> <th align="right">due</th> </tr> </thead> <tfoot> <tr class="queryfooter"> <td colspan="5" align="right"><?php echo formatVariable($sumrecord["theamount"], "currency"); ?> </td> <td align="right"><?php echo formatVariable($sumrecord["thedue"], "currency"); ?> </td> </tr> </tfoot> <tbody> <?php if ($this->db->numRows($queryresult)) { $postedGroup = ""; $row = 1; while ($therecord = $this->db->fetchArray($queryresult)) { $row = $row == 1 ? 2 : 1; if ($postedGroup != $therecord["posted"]) { $postedGroup = $therecord["posted"]; $title = $therecord["posted"] == 1 ? "Current" : "Pending (non-posted)"; ?> <tr class="queryGroup"> <td colspan="6"><?php echo $title; ?> </td> </tr><?php } //end if $dueDate = strtotime(TERM1_DAYS . " days", stringToDate($therecord["itemdate"], "SQL")); ?> <tr class="row<?php echo $row; ?> "> <td><?php echo $therecord["relatedid"]; ?> </td> <td nowrap="nowrap"><?php echo $therecord["type"]; ?> </td> <td><?php echo formatFromSQLDate($therecord["itemdate"]); ?> </td> <td <?php if ($dueDate < mktime(0, 0, 0)) { echo 'class="important"'; } ?> ><?php if ($therecord["type"] == "invoice") { echo dateToString($dueDate); } else { echo " "; } ?> </td> <td align="right"><?php echo formatVariable($therecord["amount"], "currency"); ?> </td> <td align="right"><?php echo formatVariable($therecord["amount"] - $therecord["paid"], "currency"); ?> </td> </tr><?php } //end while } else { ?> <tr class="norecords"><td colspan="6" >No open items</td></tr><?php } //endif ?> </tbody> </table><?php }
/** * Check to see if the scheduler has ever run */ function checkForSchedulerRunning() { //first, if this is within the first day of the installation, we skip the check $querystatement = "SELECT creationdate FROM users WHERE id = 1"; $queryresult = $this->db->query($querystatement); $therecord = $this->db->fetchArray($queryresult); if (stringToDate($therecord["creationdate"], "SQL") < strtotime("yesterday")) { $querystatement = "\n\t\t\t\tSELECT\n\t\t\t\t\tMAX(lastrun) AS lastrun\n\t\t\t\tFROM\n\t\t\t\t\tscheduler"; $queryresult = $this->db->query($querystatement); $therecord = $this->db->fetchArray($queryresult); if (!$therecord["lastrun"]) { return false; } } //endif return true; }
function sqlDateFromString($datestring, $format = DATE_FORMAT) { $sqldate = "0000-00-00"; if ($datestring) { if ($format == "SQL") { $sqldate = $datestring; } else { $sqldate = dateToString(stringToDate($datestring, $format), "SQL"); } } return $sqldate; }
function displayBox($month, $year, $selectedDate, $db) { $thedate = mktime(0, 0, 0, $month, 1, $year); $today = mktime(0, 0, 0); $todayArray = getdate($today); if ($selectedDate != "0000-00-00") { $selDate = stringToDate($selectedDate, "SQL"); $tempDate = getdate($selDate); $displayLongDate = $tempDate["month"] . " " . $tempDate["mday"] . ", " . $tempDate["year"]; } else { $selDate = NULL; $displayLongDate = "Click a Date"; } ?> <script language="JavaScript" type="text/javascript">displayLongDate="<?php echo $displayLongDate; ?> ";</script> <?php ?> <table class="dp" cellspacing="0" cellpadding="0" border="0"> <tr> <td colspan=6 class="dpHead"><?php echo date("F, Y", $thedate); ?> </td> <td class="dpHead"><button type="button" class="graphicButtons buttonX" id="DPCancel" onclick="closeDPBox();"><span>x</span></button></td> </tr> <tr> <td class="dpButtons" onclick="loadMonth('<?php echo APP_PATH; ?> ','<?php echo $month; ?> ','<?php echo $year - 1; ?> '<?php if ($selDate) { echo ",'" . date("m/d/Y", $selDate) . "'"; } ?> )"><<</td> <td class="dpButtons" onclick="loadMonth('<?php echo APP_PATH; ?> ','<?php if ($month == 1) { echo "12"; } else { echo $month - 1; } ?> ','<?php if ($month == 1) { echo $year - 1; } else { echo $year; } ?> '<?php if ($selDate) { echo ",'" . date("m/d/Y", $selDate) . "'"; } ?> )"><</td> <td colspan=3 class="dpButtons" onclick="loadMonth('<?php echo APP_PATH; ?> ','<?php echo date('m', $today); ?> ','<?php echo $todayArray["year"]; ?> '<?php if ($selDate) { echo ",'" . date("m/d/Y", $selDate) . "'"; } ?> )">Today</td> <td class="dpButtons" onclick="loadMonth('<?php echo APP_PATH; ?> ','<?php if ($month == 12) { echo "1"; } else { echo $month + 1; } ?> ','<?php if ($month == 12) { echo $year + 1; } else { echo $year; } ?> '<?php if ($selDate) { echo ",'" . date("m/d/Y", $selDate) . "'"; } ?> )">></td> <td class="dpButtons" onclick="loadMonth('<?php echo APP_PATH; ?> ','<?php echo $month; ?> ','<?php echo $year + 1; ?> '<?php if ($selDate) { echo ",'" . date("m/d/Y", $selDate) . "'"; } ?> )">>></td> </tr> <tr class="dpDayNames"> <td width="14.286%">S</td> <td width="14.286%">M</td> <td width="14.286%">T</td> <td width="14.286%">W</td> <td width="14.286%">R</td> <td width="14.286%">F</td> <td width="14.286%">S</td> </tr> <?php $firstdate = getdate($thedate); $mydate = $firstdate; while ($firstdate["month"] == $mydate["month"]) { if ($mydate["wday"] == 0) { echo "<TR class=\"dpWeek\">"; } if ($firstdate == $mydate) { // firstdate, so we may have to put in blanks echo "<TR class=\"dpWeek\">"; for ($i = 0; $i < $mydate["wday"]; $i++) { echo "<TD> </TD>"; } } $dayclass = "dpReg"; if ($thedate == $selDate) { $dayclass = "dpSelected"; } elseif ($thedate == $today) { $dayclass = "dpToday"; } echo "<TD class=\"" . $dayclass . "\" onMouseOut=\"dpUnhighlightDay();\" onMouseOver=\"dpHighlightDay(" . $mydate["year"] . "," . date("n", $thedate) . "," . $mydate["mday"] . ")\" onclick=\"dpClickDay(" . $mydate["year"] . "," . date("n", $thedate) . "," . $mydate["mday"] . ")\">" . $mydate["mday"] . "</TD>"; if ($mydate["wday"] == 6) { echo "</tr>"; } $thedate = strtotime("tomorrow", $thedate); $mydate = getdate($thedate); } if ($mydate["wday"] != 0) { for ($i = 6; $i >= $mydate["wday"]; $i--) { echo "<TD> </TD>"; } echo "</TR"; } ?> <tr><td id="dpExp" class="dpExplanation" colspan="7"><?php echo $displayLongDate; ?> </td></tr> </table> <?php }
function search_events($name, $location, $date, $desc, $postcode, $maxdist, $id) { //Connect to the database $con = connect(); //Import geoIP to find distance to events require_once "geoIP.php"; //Allows for easy SQL generation $sql = "SELECT * FROM Events WHERE 1=1 "; //For each argument, append to the SQL if it is set (black magic, but it works) // --HACKY-- // if (!no_val($name)) { $sql .= " AND `name` LIKE '%" . mysqli_real_escape_string($con, $name) . "%'"; } if (!no_val($location)) { $sql .= " AND `location`LIKE '%" . mysqli_real_escape_string($con, $location) . "%'"; } if (!no_val($date)) { $sDate = stringToDate($date); $sql .= " AND `startDate` <=" . $sDate[0] . " AND `endDate` >=" . $sDate[1]; } if (!no_val($desc)) { $sql .= " AND (`description` LIKE '" . getTerms($desc) . ")"; } if (!no_val($postcode)) { $sql .= " AND `postcode`LIKE '%" . mysqli_real_escape_string($con, $postcode) . "%'"; } if (!no_val($id)) { $sql .= " AND `createdBy` = " . $id; } //prepare the statement to be run //If this fails, either you have made a mistake editing this glorious code //Or there's malicious input if (!($stmt = $con->prepare($sql))) { echo "SQL incorrect or injection attempt."; die; } //Run the query. Stop all PHP if we can't for any reason if (!$stmt->execute()) { echo "Query Failed"; die; } //Retrieve the results $result = $stmt->get_result(); $results = array(); //Postcode regular expression //Provided by the government, so should work 100% of the time $regex = '#^(GIR ?0AA|[A-PR-UWYZ]([0-9]{1,2}|([A-HK-Y][0-9]'; $regex .= '([0-9ABEHMNPRV-Y])?)|[0-9][A-HJKPS-UW]) ?[0-9]'; $regex .= '[ABD-HJLNP-UW-Z]{2})$#'; //Get thbe user's location for distance calculations $postcode1 = urlencode(getLocation()['zipCode']); //Prepare the google maps API $url = "https://maps.googleapis.com/maps/api/distancematrix/json?origins="; $url .= urlencode($postcode1) . "&destinations="; //Go through all results from the query $distances = array(); $num = 0; while ($row = $result->fetch_assoc()) { $url .= urlencode("|" . $row['location']); $num += 1; if (strlen($url) >= 1500) { $url .= "&units=imperial"; $google = curl_init($url); curl_setopt($google, CURLOPT_RETURNTRANSFER, true); $data = curl_exec($google); curl_close($google); if ($data) { $data = json_decode($data); if ($data->status == "OK") { foreach ($data->rows[0]->elements as $dist) { if ($dist->status == "OK") { array_push($distances, $dist->distance->text); } else { array_push($distances, "---"); } } } if (@sizeof($data->rows[0]->elements < $num)) { for ($i = 0; $i < $num; $i++) { array_push($distances, "---"); } } $url = "https://maps.googleapis.com/maps/api/distancematrix/json?origins="; $url .= urlencode($postcode1) . "&destinations="; } else { $url = "https://maps.googleapis.com/maps/api/distancematrix/json?origins="; $url .= urlencode($postcode1) . "&destinations="; for ($i = 0; $i < $num; $i++) { array_push($distances, "---"); } } $num = 0; } //Placeholder for distance values array_push($row, "---"); //Add row to our results array_push($results, $row); } //Set the units to miles. //There's no real reason, most people just use miles $url .= "&units=imperial"; $returnValues = array(); foreach ($result as $row) { @array_push($row, $distances[0]); if (!no_val($maxdist)) { if ($row[0] <= $maxdist) { @array_push($returnValues, $row); } } else { @array_push($returnValues, $row); } //Delete the first element from google results $distances = array_slice($distances, 1); } //Throw back the array of all results return $returnValues; }
function _toCalDate($sqldate) { $phpDate = stringToDate($sqldate, "SQL"); return date("Ymd", $phpDate); }
include "include/fields.php"; include "modules/recurringinvoices/include/recurringinvoices.php"; if (!isset($_GET["id"])) { $_GET["id"] = 0; } $_GET["id"] = (int) $_GET["id"]; if (isset($_POST["referrer"])) { $_SERVER['HTTP_REFERER'] = $_POST["referrer"]; } $thetable = new recurringinvoice($db, $_GET["id"]); $therecord = $thetable->process(); //set the page title $refquery = "\n\t\tSELECT\n\t\t\t`invoices`.`id`,\n\t\t\tif(clients.lastname!=\"\",concat(clients.lastname,\", \",clients.firstname,if(clients.company!=\"\",concat(\" (\",clients.company,\")\"),\"\")),clients.company) as name,\n\t\t\t`invoices`.`type`,\n\t\t\t`invoices`.`invoicedate`\n\t\tFROM\n\t\t\t`invoices` INNER JOIN `clients` ON `invoices`.`clientid`=clients.uuid\n\t\tWHERE\n\t\t\t`invoices`.`id`=" . $_GET["id"]; $refquery = $db->query($refquery); $refrecord = $db->fetchArray($refquery); $invoiceDate = stringToDate($refrecord["invoicedate"], "SQL"); $pageTitle = "Invoice Recurrence: " . $refrecord["id"] . ": " . $refrecord["name"]; $phpbms->cssIncludes[] = "pages/recurringinvoices.css"; $phpbms->jsIncludes[] = "modules/recurringinvoices/javascript/recurringinvoices.js"; //Form Elements //============================================================== $theform = new phpbmsForm(); $theinput = new inputCheckbox("recurr", "", "recurr invoice", $invoiceDate == NULL); $theform->addField($theinput); $temparray = array("Daily" => "Daily", "Weekly" => "Weekly", "Monthly" => "Monthly", "Yearly" => "Yearly"); $theinput = new inputBasiclist("type", $therecord["type"], $temparray, "frequency"); $theinput->setAttribute("onchange", "changeType();"); $theform->addField($theinput); $theinput = new inputField("every", $therecord["every"], "frequency of repeating", false, "integer", 2, 4, false); $theform->addField($theinput); $theinput = new inputBasiclist("monthlyontheweek", $therecord["ontheweek"], $thetable->weekArray, "on the week of", false);
function displayWeek($userid, $dayInWeek = null) { // Creates a week view calendar for the widget if (!$dayInWeek) { $dayInWeek = mktime(0, 0, 0); } $firstDay = $dayInWeek; $dayArray = localtime($firstDay, true); while ($dayArray["tm_wday"] != 0) { $firstDay = strtotime("yesterday", $firstDay); $dayArray = localtime($firstDay, true); } //endwhile //build the initial array $events = array(); $lastDay = strtotime("6 days", $firstDay); $tempDay = $firstDay; for ($i = 0; $i < 7; $i++) { $events["d" . $tempDay] = array(); $tempDay = strtotime("tomorrow", $tempDay); } //endfor //first lets get the regular events in the timeframe; $querystatement = "\n SELECT\n notes.id,\n notes.startdate,\n notes.starttime,\n notes.enddate,\n notes.endtime,\n notes.subject\n FROM\n notes\n WHERE\n (\n notes.private = 0\n OR notes.createdby=" . $userid . "\n )\n AND notes.type='EV'\n AND notes.repeating = 0\n AND notes.startdate >= '" . dateToString($firstDay, "SQL") . "'\n AND notes.startdate <= '" . dateToString($lastDay, "SQL") . "'"; $queryresult = $this->db->query($querystatement); while ($therecord = $this->db->fetchArray($queryresult)) { $events["d" . stringToDate($therecord["startdate"], "SQL")]["t" . stringToTime($therecord["starttime"], "24 Hour")][] = $therecord; } //next we do recurring events $querystatement = "\n SELECT\n notes.id,\n notes.startdate,\n notes.starttime,\n notes.enddate,\n notes.endtime,\n notes.subject,\n notes.repeattype,\n notes.repeatevery,\n notes.firstrepeat,\n notes.lastrepeat,\n notes.timesrepeated,\n notes.repeatontheday,\n notes.repeatontheweek,\n notes.repeateachlist,\n notes.repeatuntil,\n notes.repeattimes\n FROM\n notes\n WHERE\n repeating =1\n AND (\n notes.private = 0\n OR notes.createdby=" . $userid . "\n ) AND notes.type='EV'\n AND (\n notes.repeatuntil IS NULL\n OR notes.repeatuntil >= '" . dateToString($firstDay, "SQL") . "'\n )\n AND (\n notes.repeattimes IS NULL\n OR notes.repeattimes > notes.timesrepeated\n )"; $queryresult = $this->db->query($querystatement); $thetable = new notes($this->db, "tbld:a4cdd991-cf0a-916f-1240-49428ea1bdd1"); while ($therecord = $this->db->fetchArray($queryresult)) { $dateArray = $thetable->getValidInRange(stringToDate($therecord["startdate"], "SQL"), $lastDay, $therecord); foreach ($dateArray as $date) { if ($date >= $firstDay && $date <= $lastDay) { if ($therecord["enddate"]) { $therecord["enddate"] = dateToString($date + (stringToDate($therecord["enddate"], "SQL") - stringToDate($therecord["startdate"], "SQL")), "SQL"); } $therecord["startdate"] = dateToString($date, "SQL"); $events["d" . $date]["t" . stringToTime($therecord["starttime"], "24 Hour")][] = $therecord; } //endif } //endforeach } //endwhile $querystatement = "\n SELECT\n DECODE(password,'" . ENCRYPTION_SEED . "') AS decpass\n FROM\n users\n WHERE\n id=" . $_SESSION["userinfo"]["id"]; $queryresult = $this->db->query($querystatement); $passrec = $this->db->fetchArray($queryresult); $icallink = "?u=" . $_SESSION["userinfo"]["id"] . "&h=" . md5("phpBMS" . $_SESSION["userinfo"]["firstname"] . $_SESSION["userinfo"]["lastname"] . $_SESSION["userinfo"]["id"] . $passrec["decpass"]); ?> <input type="hidden" id="eventDateLast" value="<?php echo strtotime("-7 days", $firstDay); ?> " /> <input type="hidden" id="eventDateToday" value="<?php echo mktime(0, 0, 0); ?> " /> <input type="hidden" id="eventDateNext" value="<?php echo strtotime("tomorrow", $lastDay); ?> " /> <ul id="eventButtons"> <li id="icalLi"><a href="ical.php<?php echo $icallink; ?> " title="ical subscription link" id="icalA"><span>ical</span></a> </li> <li><button id="eventLastWeek" type="button" title="previous week" class="smallButtons"><span><<</span></button></li> <li><button id="eventToday" type="button" title="today" class="smallButtons"><span>today</span></button></li> <li><button id="eventNextWeek" type="button" title="next week" class="smallButtons"><span>>></span></button></li> </ul> <table border="0" cellspacing="0" cellpadding="0" width="100%" id="eventsList"><?php foreach ($events as $date => $times) { ?> <tr class="eventDayName" <?php if (mktime(0, 0, 0) === (int) str_replace("d", "", $date)) { echo 'id="today"'; } ?> > <td nowrap="nowrap"><?php echo @strftime("%A", (int) str_replace("d", "", $date)); ?> </td> <td width="100%" align="right"><?php echo @strftime("%b %e %Y", (int) str_replace("d", "", $date)); ?> </td> </tr><?php if (count($times)) { ksort($times); foreach ($times as $time => $timeevents) { foreach ($timeevents as $event) { ?> <tr> <td nowrap="nowrap" valign="top" align="right"><?php echo formatFromSQLTime($event["starttime"]); ?> </td> <td valign="top" ><a href="<?php echo getAddEditFile($this->db, "tbld:a4cdd991-cf0a-916f-1240-49428ea1bdd1") . "?id=" . $event["id"]; ?> &backurl=snapshot.php"><?php echo htmlQuotes($event["subject"]); ?> </a></td> </tr><?php } //endforeach events } //endforeach time } else { ?> <tr> <td class="disabledtext" align="right">no events</td> <td> </td> </tr><?php } // endif } //endforeach day ?> </table><?php }
function _addLineItems($coords) { $pdf =& $this->pdf; $lineitemresult = $this->_getLineItems(); $pdf->setStyle("normal"); $pdf->SetY($pdf->GetY() + 0.18 + 0.0625); while ($line = $this->db->fetchArray($lineitemresult)) { if ($pdf->GetY() + 0.17 * 3 > $coords["y"] + $this->lineitemBoxHeight) { $pdf->SetLineWidth(0.02); $pdf->Rect($coords["x"], $coords["y"], $pdf->paperwidth - $pdf->leftmargin - $pdf->rightmargin, $this->lineitemBoxHeight); $pdf->SetLineWidth(0.01); $this->_addPage(); } //end if if ($line["type"] == "invoice") { $tempDate = stringToDate($line["itemdate"], "SQL"); $line["duedate"] = dateToString(strtotime(TERM1_DAYS . " days", $tempDate), "SQL"); } else { $line["duedate"] = ""; } if ($line["type"] == "credit" && $line["relatedid"] == $this->receiptrecord["id"]) { $line["relatedid"] = ""; $line["amount"] = 0; $line["aritemid"] = 0; } if ($this->receiptrecord["posted"]) { $line["docdue"] = $line["amount"] - $line["paid"]; } elseif ($line["relatedid"]) { $line["docdue"] = $line["amount"] - $line["paid"] - $line["applied"] - $line["discount"] - $line["taxadjustment"]; } else { $line["docDue"] = 0; } foreach ($this->lineitems as $column) { $ln = 0; switch ($column->fieldname) { case "parts": $pdf->SetFont("Arial", "B", 8); $pdf->Write(0.17, $line["partname"]); $pdf->setStyle("normal"); $pdf->SetX($pdf->leftmargin + $column->size); break; default: if ($column->format != "") { $value = formatVariable($line[$column->fieldname], $column->format); } else { $value = $line[$column->fieldname]; } if ($value == "·") { $value = " "; } if ($column->fieldname == $this->lineitems[count($this->lineitems) - 1]->fieldname) { $ln = 2; } $pdf->Cell($column->size, 0.17, $value, $pdf->borderDebug, $ln, $column->align); break; } //end switch } //end foreach $pdf->SetXY($pdf->leftmargin, $pdf->GetY() + 0.0625); $pdf->SetLineWidth(0.01); $pdf->SetDrawColor(180, 180, 180); $pdf->Line($pdf->leftmargin, $pdf->GetY(), $pdf->paperwidth - $pdf->rightmargin, $pdf->GetY()); $pdf->SetDrawColor(0, 0, 0); $pdf->SetLineWidth(0.02); $pdf->SetXY($pdf->leftmargin, $pdf->GetY() + 0.0625); } //end while $pdf->SetLineWidth(0.02); $pdf->Rect($coords["x"], $coords["y"], $pdf->paperwidth - $pdf->leftmargin - $pdf->rightmargin, $this->lineitemBoxHeight); }