/** * function prepareVariables * @param $variables */ function prepareVariables($variables) { $variables = parent::prepareVariables($variables); if (!isset($variables["usecustomdestuuid"])) { $variables["usecustomdestuuid"] = 0; } if ($variables["usecustomdestuuid"]) { $variables["destuuid"] = $variables["customdestuuid"]; } switch ($variables["whereselection"]) { case "all": case "select": $variables["whereclause"] = $variables["whereselection"]; break; default: $variables["whereclause"] = $variables["customwhere"]; break; } //end switch switch ($variables["apicommand"]) { case "insert": case "update": break; case "custom": $variables["apicommand"] = $variables["customcommand"]; break; } //end switch return $variables; }
function prepareVariables($variables) { if (isset($_FILES['upload'])) { if ($_FILES['upload']["name"]) { $variables["name"] = $_FILES['upload']["name"]; $variables["type"] = $_FILES['upload']['type']; $variables["file"] = $this->getPicture("upload"); } else { unset($this->fields["type"]); unset($this->fields["file"]); } } //end if return parent::prepareVariables($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; }