示例#1
0
 function updateRecord($variables, $modifiedby = NULL, $useUuid = false)
 {
     if (isset($variables["invoicedefault"])) {
         $this->updateInvoiceDefault();
     }
     parent::updateRecord($variables, $modifiedby, $useUuid);
 }
示例#2
0
 function insertRecord($variables, $createdby = NULL, $overrideID = false, $replace = false, $useUuid = false)
 {
     $theid = parent::insertRecord($variables, $createdby, $overrideID, $replace, $useUuid);
     if (isset($variables["userschanged"])) {
         if ($variables["userschanged"] == 1) {
             $this->assignUsers($theid, $variables["newusers"]);
         }
     }
     return $theid;
 }
示例#3
0
 function getRecord($id, $useUuid = false)
 {
     $therecord = parent::getRecord($id, $useUuid);
     /**
      *   If type is credit, get the receipt id
      *   else get the invoice id
      */
     if ($therecord["type"] == "credit") {
         $therecord["editrelatedid"] = getId($this->db, "tbld:43678406-be25-909b-c715-7e2afc7db601", $therecord["relatedid"]);
     } else {
         $therecord["editrelatedid"] = getId($this->db, "tbld:62fe599d-c18f-3674-9e54-b62c2d6b1883", $therecord["relatedid"]);
     }
     return $therecord;
 }
示例#4
0
 function verifyVariables($variables)
 {
     //table's default is fine
     if (isset($variables["type"])) {
         switch ($variables["type"]) {
             case "percent":
             case "amount":
                 break;
             default:
                 $this->verifyErrors[] = "The value of the `type` field is invalid.\n\t\t\t\t\t\t\tIt must be either 'percent' or 'amount'.";
                 break;
         }
         //end switch
     }
     //end if
     return parent::verifyVariables($variables);
 }
示例#5
0
 function verifyVariables($variables)
 {
     //check booleans
     if (isset($variables["webenabled"])) {
         if ($variables["webenabled"] && $variables["webenabled"] != 1) {
             $this->verifyErrors[] = "The `webenabled` field must be a boolean (equivalent to 0 or exactly 1).";
         }
     }
     if (isset($variables["parentid"])) {
         $tempParentId = $variables["parentid"];
         $tempUUID = "";
         if (isset($variables["uuid"])) {
             $tempUUID = $variables["uuid"];
         }
         if (!$this->checkForValidParentid($tempUUID, $tempParentId)) {
             $this->verifyErrors[] = "The `parentid` field does not give a valid parent id.";
         }
     }
     //end if
     return parent::verifyVariables($variables);
 }
示例#6
0
 function insertRecord($variables, $createdby = NULL, $overrideID = false, $replace = false, $useUuid = false)
 {
     $newid = parent::insertRecord($variables, $createdby, $overrideID, $replace, $useUuid);
     //restore the fields
     $this->getTableInfo();
     return $newid;
 }
示例#7
0
 function insertRecord($variables, $createdby = NULL, $overrideID = false, $replace = false, $useUuid = false)
 {
     $newid = parent::insertRecord($variables, $createdby, $overrideID, $replace, $useUuid);
     if (isset($variables["completed"]) && isset($variables["repeating"])) {
         $this->repeatTask($newid);
     }
     return $newid;
 }
示例#8
0
 /**
  * Overriden phpbmstable function
  */
 function insertRecord($variables, $createdby = NULL, $overrideID = false, $replace = false, $useUuid = false)
 {
     if ($createdby === NULL) {
         $createdby = $_SESSION["userinfo"]["id"];
     }
     $newid = parent::insertRecord($variables, $createdby, $overrideID, $replace, $useUuid);
     if (is_array($newid)) {
         $uuid = $newid["uuid"];
     } else {
         $uuid = $variables["uuid"];
     }
     if ($variables["catschanged"]) {
         $this->updateCategories($uuid, $variables["addcats"]);
     }
     return $newid;
 }
示例#9
0
 function insertRecord($variables, $createdby = NULL, $overrideID = false, $replace = false, $useUuid = false)
 {
     $newid = parent::insertRecord($variables, $createdby, $overrideID, $replace, $useUuid);
     if (is_array($newid)) {
         $newUuid = $newid["uuid"];
     } else {
         $newUuid = $variables["uuid"];
     }
     //need to create the address and addresstorecord id
     // make sure we are not setting extra info
     unset($this->address->fields["email"]);
     unset($this->address->fields["phone"]);
     unset($this->address->fields["notes"]);
     unset($variables["id"]);
     // This breaks the import otherwise...needs further testing and possibly a better solution
     $variables["title"] = "Main Address";
     $variables["tabledefid"] = "tbld:6d290174-8b73-e199-fe6c-bcf3d4b61083";
     $variables["recordid"] = $newUuid;
     $variables["uuid"] = "";
     $variables["defaultshipto"] = 1;
     $variables["primary"] = 1;
     if ($newUuid) {
         // temporary fix... may need to verify client id before hand... dunno
         $variables = $this->address->prepareVariables($variables);
         $errorArray = $this->address->verifyVariables($variables);
         if (!count($errorArray)) {
             /**
              *  If we are replacing the record, we need to cut the links
              *  from the client to the old address record.
              */
             if ($replace) {
                 $querystatement = "\n\t\t\t\t\t\t\tDELETE FROM\n\t\t\t\t\t\t\t\t`addresstorecord`\n\t\t\t\t\t\t\tWHERE\n\t\t\t\t\t\t\t\t`recordid` = '" . $newUuid . "'\n\t\t\t\t\t\t";
                 $queryresult = $this->db->query($querystatement);
             }
             //end if
             $this->address->insertRecord($variables, $createdby);
         } else {
             foreach ($errorArray as $error) {
                 $logError = new appError(-910, $error, "Address Verification Error");
             }
         }
         //end if
     }
     //end if
     //restore the fields
     $this->address->getTableInfo();
     return $newid;
 }
示例#10
0
 function insertRecord($variables, $createdby = NULL, $overrideID = false, $replace = false, $useUuid = false)
 {
     $variables = $this->prepareVariables($variables);
     return parent::insertRecord($variables, $createdby, $overrideID, $replace, $useUuid);
 }
示例#11
0
 function insertRecord($variables, $createdby = NULL, $overrideID = false, $replace = false, $useUuid = false)
 {
     $newid = parent::insertRecord($variables, $createdby, $overrideID, $replace, $useUuid);
     if (ENCRYPT_PAYMENT_FIELDS && (isset($variables["ccnumber"]) || isset($variables["ccexpiration"]) || isset($variables["ccverification"]) || isset($variables["accountnumber"]) || isset($variables["routingnumber"]))) {
         if ($useUuid) {
             $whereclause = "`uuid` = '" . $newid["uuid"] . "'";
             $variables["uuid"] = $newid["uuid"];
         } else {
             $whereclause = "`id` = '" . $newid . "'";
         }
         $querystatement = "\n\t\t\t\t\tUPDATE\n\t\t\t\t\t\t`receipts`\n\t\t\t\t\tSET ";
         $fieldlist = "";
         if (isset($variables["ccnumber"])) {
             $variables["ccnumber"] = mysql_real_escape_string($variables["ccnumber"]);
             $fieldlist .= ", `ccnumber` = " . $this->db->encrypt("'" . $variables["ccnumber"] . "'");
         }
         //end if
         if (isset($variables["ccexpiration"])) {
             $variables["ccexpiration"] = mysql_real_escape_string($variables["ccexpiration"]);
             $fieldlist .= ", `ccexpiration` = " . $this->db->encrypt("'" . $variables["ccexpiration"] . "'");
         }
         //end if
         if (isset($variables["ccverification"])) {
             $variables["ccverification"] = mysql_real_escape_string($variables["ccverification"]);
             $fieldlist .= ", `ccverification` = " . $this->db->encrypt("'" . $variables["ccverification"] . "'");
         }
         //end if
         if (isset($variables["accountnumber"])) {
             $variables["accountnumber"] = mysql_real_escape_string($variables["accountnumber"]);
             $fieldlist .= ", `accountnumber` = " . $this->db->encrypt("'" . $variables["accountnumber"] . "'");
         }
         //end if
         if (isset($variables["routingnumber"])) {
             $variables["routingnumber"] = mysql_real_escape_string($variables["routingnumber"]);
             $fieldlist .= ", `routingnumber` = " . $this->db->encrypt("'" . $variables["routingnumber"] . "'");
         }
         //end if
         $fieldlist = substr($fieldlist, 1);
         $querystatement .= $fieldlist . " WHERE `posted` = '0' AND " . $whereclause;
         $this->db->query($querystatement);
     }
     //end if
     if ($variables["itemschanged"] == 1) {
         if ($this->receiptitems === NULL) {
             $this->receiptitems = new receiptitems($this->db);
         }
         $this->receiptitems->set($variables["itemslist"], $variables["uuid"], $variables["clientid"], $createdby);
     }
     //end if
     return $newid;
 }
示例#12
0
 /**
  * function process
  * Process request array posted to api
  *
  * The method process() loops through the request array, and attempts to
  * find a corresponding function to run for the request. It first looks for
  * a corresponding api class to load. If it does not find it, it next to
  * see if there is an overriden table class file, and finally if none of
  * these are present, it uses the standard table class.
  *
  */
 function process()
 {
     $i = 1;
     $tabledefid = null;
     if (!is_array($this->data)) {
         $this->sendError("Passed data malformed.  Was expecting an array.", $this->data, true);
     }
     foreach ($this->data as $request) {
         if (!is_array($request)) {
             $this->sendError("Malformed request number " . $i, $request);
         }
         if (!isset($request["tabledefid"]) || !isset($request["command"]) || !isset($request["data"])) {
             $this->sendError("Malformed request number " . $i, $request);
         }
         /**
          *  Process the options and populate the options object.
          */
         if (!isset($request["options"])) {
             $request["options"] = NULL;
         }
         $this->processOptions($request["options"]);
         if ((int) $request["tabledefid"] !== $tabledefid) {
             $tabledefid = mysql_real_escape_string($request["tabledefid"]);
             //First let's get the table information from the tabledef
             $querystatement = "\n                    SELECT\n                        `maintable`,\n                        `deletebutton`,\n                        `querytable`,\n                        `modules`.`name`,\n                        `apiaccessible`\n                    FROM\n                        `tabledefs` INNER JOIN `modules` ON tabledefs.moduleid = modules.uuid\n                    WHERE\n                        tabledefs.uuid = '" . $tabledefid . "'\n                ";
             $queryresult = $this->db->query($querystatement);
             if ($this->db->numRows($queryresult) == 0) {
                 if (!in_array($request["command"], array("procedure", "getsetting"))) {
                     $this->sendError("Invalid tabledefid (" . $tabledefid . ") from request number " . $i);
                     continue;
                 } else {
                     $deletebutton = "delete";
                     $maintable = "settings";
                     $modulename = "base";
                     $hasAPIOveride = false;
                     $hasTableClassOveride = false;
                 }
                 //endif
             } else {
                 $therecord = $this->db->fetchArray($queryresult);
                 if (!$therecord["apiaccessible"]) {
                     $this->sendError("Invalid tabledefid (" . $tabledefid . ") from request number " . $i . ": This table definition is inaccessible via api.");
                     continue;
                 }
                 //endif
                 $deletebutton = $therecord["deletebutton"];
                 $maintable = $therecord["maintable"];
                 $modulename = $therecord["name"];
                 //check for ovridding classes only once.
                 $hasAPIOveride = file_exists("../extendedapi/" . $maintable . ".php");
                 $hasTableClassOveride = file_exists("../" . $modulename . "/include/" . $maintable . ".php");
             }
             //endif
         }
         //endif
         /* Order in which to check for processors is as follows:
         
                        If the extendedAPI module is present, look for a file matching the main
                        table name of the table def.
                        Example: modules/extendedapi/clients.php
         
                        If a table class file exists in the module's include folder
                        use that.
                        Example: modules/bms/include/clients.php
         
                        Use the standard class module.
         
                     */
         $methodName = "";
         if ($hasAPIOveride) {
             // Found an API module table php
             @(include_once "modules/extendedapi/" . $maintable . ".php");
             $className = $className . "Api";
             if (class_exists($className)) {
                 $processor = new $className($this->db);
                 $processor->dateFormat = $this->options->dateFormat;
                 $processor->timeFormat = $this->options->timeFormat;
                 if (!method_exists($processor, $request["command"])) {
                     $methodName = $request["command"];
                     $this->response[] = $processor->{$methodName}($request["data"], $this->options->useUuid);
                 }
                 //endif
             }
             //end if
         }
         //endif
         /* If the command starts with api_, and there is a request overload, let's assume they
               are trying to call a homeade function in the ovveriden phpBMS table that they created.
            */
         if (!$methodName && substr($request["command"], 0, 4) == "api_" && $hasTableClassOveride) {
             include_once "include/tables.php";
             @(include_once "modules/" . $modulename . "/include/" . $maintable . ".php");
             if (class_exists($maintable)) {
                 $processor = new $maintable($this->db, $tabledefid);
                 $processor->dateFormat = $this->options->dateFormat;
                 $processor->timeFormat = $this->options->timeFormat;
             } else {
                 $processor = new phpbmsTable($this->db, $tabledefid);
                 $processor->dateFormat = $this->options->dateFormat;
                 $processor->timeFormat = $this->options->timeFormat;
             }
             if (method_exists($processor, $request["command"])) {
                 $methodName = $request["command"];
                 $this->response[] = $processor->{$methodName}($request["data"], $this->options->useUuid);
             }
             //endif
         }
         //endif
         if (!$methodName) {
             /* Either using the modules overriden table class or search
                                functions class or the standard one There are several
                                standard commands that can be passed:
             
                                * insert - calls the tabledefs insertRecord command, the
                                             same command that is called on standard
                                             phpBMS forms. a variable array should be
                                             passed in the request data.
             
                                * update - calls the tabledefs iupdateRecord command, the
                                             same command that is called on standard
                                             phpBMS forms. a variable array should be
                                             passed in the request data
             
                                * delete (or the corresponding delete button command)
                                         - calls the deleteRecord searchFunctions command
                                         data should be an array of ids
             
                                * procedure - This calls a stored MySQL stored procedure
                                              request data should pass an object with the
                                              (name) and optionally an array of any
                                              (parameters)
             
                                 In addition, you can pass a command that corresponds to
                                 any additional commands as defined in the table definition
                                 the request data passed should contain an array of ids
                             */
             switch ($request["command"]) {
                 case "ping":
                     //======================================================
                     $this->_addToResponse("message", "Everything is phpBMSy!");
                     break;
                 case "getDefaults":
                     include_once "include/tables.php";
                     if ($hasTableClassOveride) {
                         @(include_once "modules/" . $modulename . "/include/" . $maintable . ".php");
                         if (class_exists($maintable)) {
                             $processor = new $maintable($this->db, $tabledefid);
                             $processor->dateFormat = $this->options->dateFormat;
                             $processor->timeFormat = $this->options->timeFormat;
                         } else {
                             $processor = new phpbmsTable($this->db, $tabledefid);
                             $processor->dateFormat = $this->options->dateFormat;
                             $processor->timeFormat = $this->options->timeFormat;
                         }
                         //end if
                     } else {
                         $processor = new phpbmsTable($this->db, $tabledefid);
                         $processor->dateFormat = $this->options->dateFormat;
                         $processor->timeFormat = $this->options->timeFormat;
                     }
                     //end if
                     $therecord = $processor->getDefaults();
                     $this->_addToResponse("retrieved", "defaults retrieved in tabledef " . $tabledefid, $therecord);
                     break;
                 case "insert":
                     //======================================================
                     include_once "include/tables.php";
                     if ($hasTableClassOveride) {
                         @(include_once "modules/" . $modulename . "/include/" . $maintable . ".php");
                         if (class_exists($maintable)) {
                             $processor = new $maintable($this->db, $tabledefid);
                             $processor->dateFormat = $this->options->dateFormat;
                             $processor->timeFormat = $this->options->timeFormat;
                         } else {
                             $processor = new phpbmsTable($this->db, $tabledefid);
                             $processor->dateFormat = $this->options->dateFormat;
                             $processor->timeFormat = $this->options->timeFormat;
                         }
                         //end if
                     } else {
                         $processor = new phpbmsTable($this->db, $tabledefid);
                         $processor->dateFormat = $this->options->dateFormat;
                         $processor->timeFormat = $this->options->timeFormat;
                     }
                     //end if
                     $errorArray = $processor->verifyVariables((array) $request["data"]);
                     if (count($errorArray)) {
                         $this->sendError("Insert failed from request number " . $i, $errorArray);
                     } else {
                         $overrideID = false;
                         if (is_array($request["data"])) {
                             if (isset($request["data"]["id"])) {
                                 if ((int) $request["data"]["id"] !== 0) {
                                     $overrideID = true;
                                 }
                                 if ($this->options->keepDestId && isset($request["data"]["uuid"]) && $this->options->useUuid) {
                                     $request["data"]["id"] = getId($this->db, $processor->uuid, $request["data"]["uuid"]);
                                 }
                             } elseif ($this->options->keepDestId && isset($request["data"]["uuid"]) && $this->options->useUuid) {
                                 $request["data"]["id"] = getId($this->db, $processor->uuid, $request["data"]["uuid"]);
                             }
                         }
                         $createUuid = true;
                         if (is_array($request["data"])) {
                             if (isset($request["data"]["uuid"])) {
                                 if ((string) $request["data"]["uuid"] !== "") {
                                     $overrideID = true;
                                     $createUuid = false;
                                 }
                             }
                         }
                         //end if
                         if (!isset($processor->fields["uuid"])) {
                             $createUuid = false;
                         }
                         $newid = $processor->insertRecord($request["data"], NULL, $overrideID, true, $createUuid);
                         if ($newid) {
                             if ($createUuid) {
                                 $this->_addToResponse("added", "record added to tabledef " . $tabledefid, $newid["uuid"]);
                             } elseif (isset($processor->fields["uuid"])) {
                                 $this->_addToResponse("added", "record added to tabledef " . $tabledefid, $request["data"]["uuid"]);
                             } else {
                                 $this->_addToResponse("added", "record added to tabledef " . $tabledefid, $newid);
                             }
                             //end if
                         } else {
                             $this->sendError("Insert failed from request number " . $i);
                         }
                     }
                     //endif
                     break;
                 case "update":
                     //======================================================
                     include_once "include/tables.php";
                     if ($hasTableClassOveride) {
                         @(include_once "modules/" . $modulename . "/include/" . $maintable . ".php");
                         if (class_exists($maintable)) {
                             $processor = new $maintable($this->db, $tabledefid);
                             $processor->dateFormat = $this->options->dateFormat;
                             $processor->timeFormat = $this->options->timeFormat;
                         } else {
                             $processor = new phpbmsTable($this->db, $tabledefid);
                             $processor->dateFormat = $this->options->dateFormat;
                             $processor->timeFormat = $this->options->timeFormat;
                         }
                         //end if
                     } else {
                         $processor = new phpbmsTable($this->db, $tabledefid);
                         $processor->dateFormat = $this->options->dateFormat;
                         $processor->timeFormat = $this->options->timeFormat;
                     }
                     //end if
                     $errorArray = $processor->verifyVariables($request["data"]);
                     if ($this->options->useUuid) {
                         if (!isset($request["data"]["uuid"])) {
                             $errorArray[] = "The `uuid` field must be set.";
                         }
                     } else {
                         if (!isset($request["data"]["id"])) {
                             $errorArray[] = "The `id` field must be set.";
                         }
                     }
                     //end if
                     if (count($errorArray)) {
                         $this->sendError("Update failed from request number " . $i, $errorArray);
                     } else {
                         $processor->updateRecord($request["data"], NULL, (bool) $this->options->useUuid);
                         $this->_addToResponse("updated", "record updated in tabledef " . $tabledefid);
                     }
                     //endif
                     break;
                 case "get":
                     //======================================================
                     include_once "include/tables.php";
                     if ($hasTableClassOveride) {
                         @(include_once "modules/" . $modulename . "/include/" . $maintable . ".php");
                         if (class_exists($maintable)) {
                             $processor = new $maintable($this->db, $tabledefid);
                             $processor->dateFormat = $this->options->dateFormat;
                             $processor->timeFormat = $this->options->timeFormat;
                         } else {
                             $processor = new phpbmsTable($this->db, $tabledefid);
                             $processor->dateFormat = $this->options->dateFormat;
                             $processor->timeFormat = $this->options->timeFormat;
                         }
                         //end if
                     } else {
                         $processor = new phpbmsTable($this->db, $tabledefid);
                         $processor->dateFormat = $this->options->dateFormat;
                         $processor->timeFormat = $this->options->timeFormat;
                     }
                     //end if
                     $errorMessage = "";
                     if ($this->options->useUuid) {
                         if (!isset($request["data"]["uuid"])) {
                             $errorMessage = "The `uuid` field must be set.";
                         }
                     } else {
                         if (!isset($request["data"]["id"])) {
                             $errorMessage = "The `id` field must be set.";
                         }
                     }
                     //end if
                     if ($errorMessage) {
                         $this->sendError("Get failed from request number " . $i, $errorMessage);
                     } elseif (!$this->options->useUuid) {
                         $therecord = $processor->getRecord((int) $request["data"]["id"], $this->options->useUuid);
                         $thereturn = $therecord["id"];
                         $thevalue = (int) $request["data"]["id"];
                     } else {
                         $therecord = $processor->getRecord(mysql_real_escape_string($request["data"]["uuid"]), $this->options->useUuid);
                         $thereturn = $therecord["uuid"];
                         $thevalue = $request["data"]["uuid"];
                     }
                     if ($thereturn == $thevalue) {
                         $this->_addToResponse("retrieved", "record (" . htmlQuotes($thevalue) . ") retrieved in tabledef " . $tabledefid, $therecord);
                     } else {
                         $this->_addToResponse("retrieved", "no record found (" . htmlQuotes($thevalue) . ") in tabledef " . $tabledefid);
                     }
                     break;
                 case "delete":
                 case $deletebutton:
                     //======================================================
                     if (!is_array($request["data"])) {
                         $this->sendError("Passed data is not array in request number " . $i, $request["data"]);
                     } else {
                         include_once "include/search_class.php";
                         if ($hasTableClassOveride) {
                             @(include_once "modules/" . $modulename . "/include/" . $maintable . ".php");
                             $className = $maintable . "SearchFunctions";
                             if (class_exists($className)) {
                                 $processor = new $className($this->db, $tabledefid, $request["data"]);
                             } else {
                                 $processor = new searchFunctions($this->db, $tabledefid, $request["data"]);
                             }
                         } else {
                             $processor = new searchFunctions($this->db, $tabledefid, $request["data"]);
                         }
                         $result = $processor->delete_record($this->options->useUuid);
                         $this->_addToResponse($request["command"], $result);
                     }
                     //endif
                     break;
                 case "procedure":
                     //======================================================
                     if (!is_array($request["data"])) {
                         $this->sendError("Wrong passed procedure format, expected object in request number " . $i, $request["data"]);
                     } else {
                         if (!isset($request["data"]["name"])) {
                             $this->sendError("Wrong passed procedure format, name missing in request number " . $i, $request["data"]);
                         } else {
                             //check to see if stored procedure exists
                             $querystatement = "\n                                    SHOW PROCEDURE STATUS LIKE '" . mysql_real_escape_string($request["data"]["name"]) . "'\n                                ";
                             $queryresult = $this->db->query($querystatement);
                             if ($this->db->numRows($queryresult) === 0) {
                                 $this->sendError("Procedure '" . $request["data"]["name"] . "' does not exist in request number " . $i, $request["data"]);
                             } else {
                                 $parameterList = "";
                                 if (isset($request["data"]["parameters"])) {
                                     foreach ($request["data"]["parameters"] as $parameter) {
                                         $parameterList .= ", '" . mysql_real_escape_string($parameter) . "'";
                                     }
                                 }
                                 if ($parameterList) {
                                     $parameterList = substr(1, $parameterList);
                                 }
                                 $procedurestatement = "\n                                        CALL " . $request["data"]["name"] . "(" . $parameterList . ")";
                                 $queryresult = $this->db->query($procedurestatement);
                                 $result = array();
                                 while ($therecord = $this->db->fetchArray($queryresult)) {
                                     $result[] = $therecord;
                                 }
                                 $this->_addToResponse("result", "Procedure '" . $request["data"]["name"] . "' returned (" . $this->db->numRows($queryresult) . ") in request number " . $i, $result);
                             }
                             //endif
                         }
                         //endif
                     }
                     //endif
                     break;
                 case "getsetting":
                     //======================================================
                     if (!is_array($request["data"])) {
                         $this->sendError("Wrong passed data format, expected array in request number " . $i, $request["data"]);
                     } else {
                         $whereclause = "";
                         foreach ($request["data"] as $settingName) {
                             $whereclause = "OR `name` = '" . mysql_real_escape_string($settingName) . "' ";
                         }
                         if ($whereclause) {
                             $whereclause = "WHERE " . substr($whereclause, 2);
                         }
                         $querystatement = "\n                                SELECT\n                                    `name`,\n                                    `value`\n                                FROM\n                                    `settings`\n                                " . $whereclause;
                         $queryresult = $this->db->query($querystatement);
                         $settings = array();
                         while ($therecord = $this->db->fetchArray($queryresult)) {
                             $settings[$therecord["name"]] = $therecord["value"];
                         }
                         $this->_addToResponse("result", "GetSettings returned (" . count($settings) . ") in request number " . $i, $settings);
                     }
                     //endif
                     break;
                 default:
                     //======================================================
                     // a catch all for other requests.  This should correspond
                     // to an ovrriden search class function only. Calling
                     // some commands can cause response errors so be careful
                     if (!is_array($request["data"]) && !$hasTableClassOveride) {
                         $this->sendError("Passaed data is not array or function (" . $request["command"] . ") does not exist in request number " . $i, $request["data"]);
                     } else {
                         @(include_once "modules/" . $modulename . "/include/" . $maintable . ".php");
                         $className = $maintable . "SearchFunctions";
                         if (!class_exists($className)) {
                             $this->sendError("Function (" . $request["command"] . ") does not exist in request number " . $i, $request["data"]);
                         } else {
                             $processor = new $className($this->db, $tabledefid, $request["data"]);
                             $processor->dateFormat = $this->options->dateFormat;
                             $processor->timeFormat = $this->options->timeFormat;
                             $methodName = $request["command"];
                             if (!method_exists($processor, $methodName)) {
                                 $this->sendError("Function (" . $request["command"] . ") does not exist in request number " . $i, $request["data"]);
                             } else {
                                 $result = $processor->{$methodName}();
                                 $this->_addToResponse($request["command"], $result);
                             }
                             //endif method_exists
                         }
                         //endif $className
                     }
                     //endif
                     break;
             }
             //endswitch $request["command"]
         }
         //endif $modulename
         $i++;
     }
     //endforeach
     $this->displayResult();
 }
示例#13
0
 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A |
 | PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT      |
 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,   |
 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT        |
 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,   |
 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY   |
 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT     |
 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE   |
 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.    |
 |                                                                         |
 +-------------------------------------------------------------------------+
*/
include "../../include/session.php";
include "include/fields.php";
include "include/tables.php";
$thetable = new phpbmsTable($db, "tbld:ea159d67-5e89-5b7f-f5a0-c740e147cd73");
$therecord = $thetable->processAddEditPage();
if (isset($therecord["phpbmsStatus"])) {
    $statusmessage = $therecord["phpbmsStatus"];
}
$pageTitle = "Installed Modules";
$phpbms->cssIncludes[] = "pages/base/modules.css";
//Form Elements
//==============================================================
$theform = new phpbmsForm();
$theform->jsMerge();
//==============================================================
//End Form Elements
include "header.php";
?>
示例#14
0
 function verifyVariables($variables)
 {
     if (isset($variables["title"])) {
         if ($variables["title"] === "" || $variables["title"] === NULL) {
             $this->verifyErrors[] = "The `title` field must not be blank.";
         }
     } else {
         $this->verifyErrors[] = "The `title` field must be set.";
     }
     if (isset($variables["file"])) {
         if ($variables["file"] === "" || $variables["file"] === NULL) {
             $this->verifyErrors[] = "The `file` field must not be blank.";
         }
     } else {
         $this->verifyErrors[] = "The `file` field must be set.";
     }
     //table default of '' is sufficient
     if (isset($variables["roleid"])) {
         if ($this->_availableRoleUUIDs === NULL) {
             $this->_availableRoleUUIDs = $this->_loadUUIDList("roles");
             $this->_availableRoleUUIDs[] = "";
             // no restrictions
             $this->_availableRoleUUIDs[] = "Admin";
             // admin restriction
         }
         //end if
         if (!in_array((string) $variables["roleid"], $this->_availableRoleUUIDs)) {
             $this->verifyErrors[] = "The `roleid` field does not give an existing/acceptable role id number.";
         }
     }
     //end if
     //table default insufficient
     if (isset($variables["moduleid"])) {
         if ($this->_availableModuleUUIDs === NULL) {
             $this->_availableModuleUUIDs = $this->_loadUUIDList("modules");
         }
         if (!in_array((string) $variables["moduleid"], $this->_availableModuleUUIDs)) {
             $this->verifyErrors[] = "The `moduleid` field does not give an existing/acceptable module id number.";
         }
     } else {
         $this->verifyErrors[] = "The `moduleid` field must be set.";
     }
     if (isset($variables["default"])) {
         if ($variables["default"] && $variables["default"] != 1) {
             $this->verifyErrors[] = "The `revoked` field must be a boolean (equivalent to 0 or exactly 1).";
         }
     }
     if (isset($variables["type"])) {
         switch ($variables["type"]) {
             case "big":
             case "little":
                 break;
             default:
                 $this->verifyErrors[] = "The `type` field's value must be one of the following: 'big' or 'little'";
                 break;
         }
         //end switch
     } else {
         $this->verifyErrors[] = "The `type` field must be set.";
     }
     if (isset($variables["uuid"])) {
         if ($variables["uuid"] !== "" && $variables !== NULL) {
             if ($this->_availableUUIDs === NULL) {
                 $this->_populateUuidArray();
             }
             if (!isset($variables["id"])) {
                 $tempid = 0;
             } else {
                 $tempid = $variables["id"];
             }
             $tempuuid = $variables["uuid"];
             // using this because it looks ugly to but the brackets within brackets
             if (array_key_exists((string) $variables["uuid"], $this->_availableUUIDs)) {
                 if ($this->_availableUUIDs[$tempuuid]["id"] !== $tempid) {
                     $this->verifyErrors = "The `uuid` field must give an unique uuid.";
                 }
             }
             //end if
         } else {
             $this->verifyErrors[] = "The `uuid` field must not be blank.";
         }
     } else {
         $this->verifyErrors[] = "The `uuid` field must be set.";
     }
     return parent::verifyVariables($variables);
 }
示例#15
0
文件: menu.php 项目: Jacquesvw/phpBMS
 function verifyVariables($variables)
 {
     if (isset($variables["uuid"])) {
         if ($variables["uuid"] === "" && $variables["uuid"] === NULL) {
             $this->verifyErrors[] = "The `uuid` field cannot be blank.";
         }
     } else {
         $this->verifyErrors[] = "The `uuid` field must be set.";
     }
     //table default ('') for `roleid` is ok (i.e. doesn't have to be set)
     if (isset($variables["roleid"])) {
         //check for populated role id array
         if ($this->_availableRoleUUIDs === NULL) {
             $this->_availableRoleUUIDs = $this->_loadUUIDList("roles");
             $this->_availableRoleUUIDs[] = "";
             //for no restrictions
             $this->_availableRoleUUIDs[] = "Admin";
             //for admin restriction
         }
         //end if
         //check to see if the int typecast role id is in one of the available ones
         if (!in_array((string) $variables["roleid"], $this->_availableRoleUUIDs)) {
             $this->verifyErrors[] = "The `roleid` field does not give an existing/acceptable role id number.";
         }
     }
     //end if
     //check parent ids under certain circumstances
     //not set is acceptable
     if (isset($variables["parentid"])) {
         $uuid = "";
         // can still check for an invalid parentid even though the current uuid is bad
         //use the current id if it exists (A menu record cannot be its own parent)
         if (isset($variables["uuid"])) {
             if ($variables["uuid"] !== "" && $variables["uuid"] !== NULL) {
                 $uuid = $variables["uuid"];
             }
         }
         //Select run every time because `id` can be different
         if (!$this->checkParentMenuUUIDs($uuid, (string) $variables["parentid"])) {
             $this->verifyErrors[] = "The `parentid` field does not give an existing/acceptable parentid uuid.";
         }
     }
     //end if
     return parent::verifyVariables($variables);
 }
示例#16
0
 /**
  *  function verifyVariables
  *  @param array $variables
  */
 function verifyVariables($variables)
 {
     /**
      *  originuuid 
      */
     if (isset($variables["originuuid"])) {
         if ($this->_availableTabledefUuids === NULL) {
             $this->_availableTabledefUuids = $this->_loadUUIDList("tabledefs");
         }
         if (!in_array((string) $variables["originuuid"], $this->_availableTabledefUuids)) {
             $this->verifyErrors[] = "The `originuuid` field does not give an existing/acceptable tabledefinition uuid.";
         }
     } else {
         $this->verifyErrors[] = "The `originuuid` field must be set.";
     }
     /**
      *  whereclause 
      */
     if (isset($variables["whereclause"])) {
         switch ($variables["whereclause"]) {
             case "all":
             case "select":
                 break;
             default:
                 if ($this->_availableUserSearchesUuids === NULL) {
                     $this->_availableUserSearchesUuids = $this->_loadUUIDList("usersearches");
                 }
                 if (!in_array((string) $variables["whereclause"], $this->_availableUserSearchesUuids)) {
                     $this->verifyErrors[] = "The `usersearches` field does not give an existing/acceptable user search uuid or be of value 'all' or 'select'.";
                 }
                 break;
         }
         //end switch
     } else {
         $this->verifyErrors[] = "The `whereclause` field must be set.";
     }
     /**
      *  apicommand
      */
     if (isset($variables["apicommand"])) {
         if ($variables["apicommand"] === "" || $variables["apicommand"] === NULL) {
             $this->verifyErrors[] = "The `apicommand` field must not be blank.";
         }
     } else {
         $this->verifyErrors[] = "The `apicommand` field must be set.";
     }
     /**
      *  dateformat 
      */
     if (isset($variables["dateformat"])) {
         switch ($variables["dateformat"]) {
             case "SQL":
             case "English, UK":
             case "English, US":
             case "Dutch, NL":
                 break;
             default:
                 $this->verifyErrors[] = "The `dateformat` field's value must be one of the following:\n                        'SQL', 'English, UK', 'English, US', or 'Dutch, NL'.";
                 break;
         }
         //end switch
     } else {
         $this->verifyErrors[] = "The `dateformat` field must be set.";
     }
     /**
      *  timeformat 
      */
     if (isset($variables["timeformat"])) {
         switch ($variables["timeformat"]) {
             case "24 Hour":
             case "12 Hour":
                 break;
             default:
                 $this->verifyErrors[] = "The `timeformat` field's value\n                        must be one of the following: '24 Hour' or '12 Hour'.";
                 break;
         }
         //end switch
     } else {
         $this->verifyErrors[] = "The `timeformat` field must be set.";
     }
     /**
      *  http format 
      */
     if (isset($variables["httpformat"])) {
         switch ($variables["httpformat"]) {
             case "POST":
             case "GET":
                 break;
             default:
                 $this->verifyErrors[] = "The `httpformat` field's value must either be 'POST' or 'GET'.";
                 break;
         }
         //end switch
     } else {
         $this->verifyErrors[] = "The `httpformat` field must be set.";
     }
     /**
      *  data format 
      */
     if (isset($variables["dataformat"])) {
         switch ($variables["dataformat"]) {
             case "json":
                 break;
             default:
                 $this->verifyErrors[] = "The `dataformat` field's value must be 'json'.";
                 break;
         }
         //end switch
     } else {
         $this->verifyErrors[] = "The `dataformat` field must be set.";
     }
     /**
      *  Booleans 
      */
     if (isset($variables["useuuid"])) {
         if ($variables["useuuid"] && $variables["useuuid"] != 1) {
             $this->verifyErrors[] = "The `useuuid` field must be a boolean (equivalent to 0 or exactly 1).";
         }
     }
     if (isset($variables["keepdestid"])) {
         if ($variables["keepdestid"] && $variables["keepdestid"] != 1) {
             $this->verifyErrors[] = "The `keepdestid` field must be a boolean (equivalent to 0 or exactly 1).";
         }
     }
     if (isset($variables["ssl"])) {
         if ($variables["ssl"] && $variables["ssl"] != 1) {
             $this->verifyErrors[] = "The `ssl` field must be a boolean (equivalent to 0 or exactly 1).";
         }
     }
     return parent::verifyVariables($variables);
 }
示例#17
0
 function updateRecord($variables, $modifiedby = NULL, $useUuid = false)
 {
     parent::updateRecord($variables, $modifiedby, $useUuid);
     $reportSettings = new reportSettings($this->db, $variables["uuid"]);
     $reportSettings->save($variables["rsDelList"], $variables["rsUpdates"], $variables["rsAdds"]);
 }
示例#18
0
 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A |
 | PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT      |
 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,   |
 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT        |
 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,   |
 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY   |
 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT     |
 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE   |
 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.    |
 |                                                                         |
 +-------------------------------------------------------------------------+
*/
include "../../include/session.php";
include "include/tables.php";
include "include/fields.php";
$thetable = new phpbmsTable($db, "tbld:7e75af48-6f70-d157-f440-69a8e7f59d38");
$therecord = $thetable->processAddEditPage();
if (isset($therecord["phpbmsStatus"])) {
    $statusmessage = $therecord["phpbmsStatus"];
}
$pageTitle = "Tab";
$phpbms->cssIncludes[] = "pages/tabs.css";
//Form Elements
//==============================================================
$theform = new phpbmsForm();
$theinput = new inputField("name", $therecord["name"], NULL, true, NULL, 32, 64);
$theinput->setAttribute("class", "important");
$theform->addField($theinput);
$theinput = new inputField("displayorder", $therecord["displayorder"], "display order", true, NULL, 10, 10);
$theform->addField($theinput);
$theinput = new inputRolesList($db, "roleid", $therecord["roleid"], "access (role)");
示例#19
0
 function insertRecord($variables, $createdby = NULL, $overrideID = false, $replace = false, $useUuid = false)
 {
     $this->fields["password"]["type"] = "password";
     unset($this->fields["lastlogin"]);
     $theid = parent::insertRecord($variables, $createdby, $overrideID, $replace, $useUuid);
     //reset field information
     $this->fields = $this->db->tableInfo($this->maintable);
     return $theid;
 }
示例#20
0
 function verifyVariables($variables)
 {
     //cannot be table default ("")
     if (isset($variables["tofield"])) {
         if ($variables["tofield"] === "" || $variables["tofield"] === NULL) {
             $this->verifyErrors[] = "The `tofield` field cannot be blank.";
         }
     } else {
         $this->verifyErrors[] = "The `tofield` field must be set.";
     }
     //cannot be table default ("")
     if (isset($variables["fromfield"])) {
         if ($variables["fromfield"] === "" || $variables["fromfield"] === NULL) {
             $this->verifyErrors[] = "The `from` field cannot be blank.";
         }
     } else {
         $this->verifyErrors[] = "The `fromfield` field must be set.";
     }
     //cannot be table default
     if (isset($variables["fromtableid"])) {
         if ($this->_availableTabledefUUIDs === NULL || $this->_availableTabledefNames === NULL) {
             $this->populateTableDefArrays();
         }
         if (!in_array($variables["fromtableid"], $this->_availableTabledefUUIDs)) {
             $this->verifyErrors[] = "The `fromtableid` field does not give an existing/acceptable parent id number.";
         }
     } else {
         $this->verifyErrors[] = "The `fromtableid` field must be set.";
     }
     //cannot be table default
     if (isset($variables["totableid"])) {
         if ($this->_availableTabledefUUIDs === NULL || $this->_availableTabledefNames === NULL) {
             $this->populateTableDefArrays();
         }
         if (!in_array($variables["totableid"], $this->_availableTabledefUUIDs)) {
             $this->verifyErrors[] = "The `totableid` field does not give an existing/acceptable to table id number.";
         }
     } else {
         $this->verifyErrors[] = "The `totableid` field must be set.";
     }
     //check boolean
     if (isset($variables["inherit"])) {
         if ($variables["inherit"] && $variables["inherit"] != 1) {
             $this->verifyErrors[] = "The `inherit` field must be a boolean (equivalent to 0 or exactly 1).";
         }
     }
     return parent::verifyVariables($variables);
 }
示例#21
0
 /**
  *  function create_credit_memo
  *
  *
  *  @param bool $useUuid Whether the ids in $this->idsArray are
  *  uuids or ids.
  */
 function create_credit_memo($useUuid = false)
 {
     if (!$useUuid) {
         $whereclause = $this->buildWhereClause();
     } else {
         $whereclause = $this->buildWhereClause($this->maintable . ".uuid");
     }
     if (isset($_SESSION["userinfo"]["id"])) {
         $createdby = $_SESSION["userinfo"]["id"];
     } else {
         $error = new appError(-841, "Session Timed Out.", "Creating New Record");
     }
     $invoicestatusQuery = "\n\t\t\t\tSELECT\n\t\t\t\t\t`uuid`\n\t\t\t\tFROM\n\t\t\t\t\t`invoicestatuses`\n\t\t\t\tWHERE\n\t\t\t\t\t`invoicedefault` != '0'\n\t\t\t";
     $queryresult = $this->db->query($invoicestatusQuery);
     $statusRecord = $this->db->fetchArray($queryresult);
     if (!class_exists("phpbmsTable")) {
         include_once "include/tables.php";
     }
     $invoices = new phpbmsTable($this->db, "tbld:62fe599d-c18f-3674-9e54-b62c2d6b1883");
     $count = 0;
     if (count($this->idsArray)) {
         foreach ($this->idsArray as $id) {
             $invoiceRecord = $invoices->getRecord($id, $useUuid);
             if ($invoiceRecord["type"] == "Invoice" && !$invoiceRecord["iscreditmemo"]) {
                 $count++;
                 $fieldsList = "";
                 $insertValues = "";
                 foreach ($invoiceRecord as $name => $value) {
                     switch ($name) {
                         case "id":
                         case "ccexpiration":
                         case "bankname":
                         case "checkno":
                         case "routingnumber":
                         case "accountnumber":
                         case "transactionid":
                         case "postingsessionid":
                         case "readytopost":
                         case "assignedtoid":
                         case "invoicedate":
                         case "requireddate":
                         case "amountpaid":
                         case "cmuuid":
                             break;
                         case "type":
                             $fieldsList .= ",`" . $name . "`";
                             $insertValues .= ",'Order'";
                             break;
                         case "iscreditmemo":
                             $fieldsList .= ",`" . $name . "`";
                             $insertValues .= ",'1'";
                             break;
                         case "createdby":
                         case "modifiedby":
                             $fieldsList .= ",`" . $name . "`";
                             $insertValues .= ",'" . (int) $createdby . "'";
                             break;
                         case "uuid":
                             $fieldsList .= ",`cmuuid`";
                             $insertValues .= ",'" . $value . "'";
                             $fieldsList .= ",`uuid`";
                             $newUuid = uuid($invoices->prefix . ":");
                             $insertValues .= ",'" . $newUuid . "'";
                             break;
                         case "creationdate":
                         case "modifieddate":
                         case "statusdate":
                         case "orderdate":
                             $fieldsList .= ",`" . $name . "`";
                             $insertValues .= ",NOW()";
                             break;
                         case "statusid":
                             $fieldsList .= ",`" . $name . "`";
                             $insertValues .= ",'" . $statusRecord["uuid"] . "'";
                             break;
                         case "discountamount":
                         case "totaltni":
                         case "totaltaxable":
                         case "tax":
                         case "shipping":
                         case "totalcost":
                         case "totalti":
                             $fieldsList .= ",`" . $name . "`";
                             $insertValues .= ",'" . -(double) $value . "'";
                             break;
                         default:
                             $fieldsList .= ",`" . $name . "`";
                             $insertValues .= ",'" . $value . "'";
                             break;
                     }
                     //end switch
                 }
                 //end foreach
                 $fieldsList = substr($fieldsList, 1);
                 $insertValues = substr($insertValues, 1);
                 $insertstatement = "\n\t\t\t\t\t\t\tINSERT INTO\n\t\t\t\t\t\t\t\t`invoices`\n\t\t\t\t\t\t\t(" . $fieldsList . ")\n\t\t\t\t\t\t\tVALUES\n\t\t\t\t\t\t\t(" . $insertValues . ")\n\t\t\t\t\t\t";
                 $queryresult = $this->db->query($insertstatement);
                 $newid = $this->db->insertId();
                 //invoice status history
                 $statushistoryquery = "\n\t\t\t\t\t\t\tINSERT INTO\n\t\t\t\t\t\t\t\t`invoicestatushistory`\n\t\t\t\t\t\t\t\t(\n\t\t\t\t\t\t\t\t\tinvoiceid,\n\t\t\t\t\t\t\t\t\tinvoicestatusid,\n\t\t\t\t\t\t\t\t\tstatusdate,\n\t\t\t\t\t\t\t\t\tassignedtoid\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\tVALUES\n\t\t\t\t\t\t\t\t(\n\t\t\t\t\t\t\t\t\t'" . mysql_real_escape_string($newUuid) . "',\n\t\t\t\t\t\t\t\t\t'" . $statusRecord["uuid"] . "',\n\t\t\t\t\t\t\t\t\tNOW(),\n\t\t\t\t\t\t\t\t\t''\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t";
                 $this->db->query($statushistoryquery);
                 // Line items
                 $lineitemstatement = "\n\t\t\t\t\t\t\tSELECT\n\t\t\t\t\t\t\t\tlineitems.productid,\n\t\t\t\t\t\t\t\tlineitems.taxable,\n\t\t\t\t\t\t\t\t-(`lineitems`.`quantity`) AS `quantity`,\n\t\t\t\t\t\t\t\tlineitems.unitprice,\n\t\t\t\t\t\t\t\tlineitems.unitcost,\n\t\t\t\t\t\t\t\tlineitems.unitweight,\n\t\t\t\t\t\t\t\tlineitems.memo,\n\t\t\t\t\t\t\t\tlineitems.displayorder,\n\t\t\t\t\t\t\t\tlineitems.custom1,\n\t\t\t\t\t\t\t\tlineitems.custom2,\n\t\t\t\t\t\t\t\tlineitems.custom3,\n\t\t\t\t\t\t\t\tlineitems.custom4,\n\t\t\t\t\t\t\t\tlineitems.custom5,\n\t\t\t\t\t\t\t\tlineitems.custom6,\n\t\t\t\t\t\t\t\tlineitems.custom7,\n\t\t\t\t\t\t\t\tlineitems.custom8,\n\t\t\t\t\t\t\t\tlineitems.createdby,\n\t\t\t\t\t\t\t\tlineitems.modifiedby,\n\t\t\t\t\t\t\t\tlineitems.creationdate,\n\t\t\t\t\t\t\t\tlineitems.modifieddate\n\t\t\t\t\t\t\tFROM\n\t\t\t\t\t\t\t\tlineitems\n\t\t\t\t\t\t\tWHERE\n\t\t\t\t\t\t\t\tinvoiceid = '" . $id . "'";
                 $lineitemresult = $this->db->query($lineitemstatement);
                 while ($lineitemrecord = $this->db->fetchArray($lineitemresult)) {
                     $fieldsList = "";
                     $insertValues = "";
                     $fieldsList .= "`invoiceid`";
                     $insertValues .= "'" . $newid . "'";
                     foreach ($lineitemrecord as $name => $value) {
                         switch ($name) {
                             case "createdby":
                             case "modifiedby":
                                 $fieldsList .= ",`" . $name . "`";
                                 $insertValues .= ",'" . (int) $createdby . "'";
                                 break;
                             case "creationdate":
                             case "modifieddate":
                                 $fieldsList .= ",`" . $name . "`";
                                 $insertValues .= ",NOW()";
                                 break;
                             default:
                                 $fieldsList .= ",`" . $name . "`";
                                 $insertValues .= ",'" . $value . "'";
                                 break;
                         }
                         //end switch
                     }
                     //end foreach
                     $lineinsertstatement = "\n\t\t\t\t\t\t\t\tINSERT INTO\n\t\t\t\t\t\t\t\t\t`lineitems`\n\t\t\t\t\t\t\t\t(" . $fieldsList . ")\n\t\t\t\t\t\t\t\tVALUES\n\t\t\t\t\t\t\t\t(" . $insertValues . ")\n\t\t\t\t\t\t\t";
                     $this->db->query($lineinsertstatement);
                 }
                 //end while
             }
             //end if
         }
     }
     //end foreach
     if ($count == count($this->idsArray)) {
         $message = $count . " related credit memo(s) have been created.";
     } else {
         $message = $count . " related credit memo(s) (of " . count($this->idsArray) . " selected) have been created.";
     }
     return $message;
 }
示例#22
0
 function insertRecord($variables, $createdby = NULL, $overrideID = false, $replace = false, $useUuid = false)
 {
     $newid = parent::insertRecord($variables, $createdby, $overrideID, $replace, $useUuid);
     //we need to create the some default supporting records
     //first a single column.
     $querystatement = "INSERT INTO `tablecolumns`\n\t\t\t(`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`)\n\t\t\tVALUES ('" . $variables["uuid"] . "','id','" . $variables["maintable"] . ".id','left','',0,'',0,'',NULL, '');";
     $this->db->query($querystatement);
     //next default button options
     $querystatement = "INSERT INTO `tableoptions` (`tabledefid`, `name`, `option`, `needselect`, `othercommand`, `roleid`)\n\t\t\tVALUES ('" . $variables["uuid"] . "','new','1',0,0, '');";
     $this->db->query($querystatement);
     $querystatement = "INSERT INTO `tableoptions` (`tabledefid`, `name`, `option`, `needselect`, `othercommand`, `roleid`)\n\t\t\tVALUES ('" . $variables["uuid"] . "','edit','1','1',0, '');";
     $this->db->query($querystatement);
     $querystatement = "INSERT INTO `tableoptions` (`tabledefid`, `name`, `option`, `needselect`, `othercommand`, `roleid`)\n\t\t\tVALUES ('" . $variables["uuid"] . "','printex','1',0,0, '');";
     $this->db->query($querystatement);
     $querystatement = "INSERT INTO `tableoptions` (`tabledefid`, `name`, `option`, `needselect`, `othercommand`, `roleid`)\n\t\t\tVALUES ('" . $variables["uuid"] . "','select','1',0,0,'');";
     $this->db->query($querystatement);
     $querystatement = "INSERT INTO `tableoptions` (`tabledefid`, `name`, `option`, `needselect`, `othercommand`, `roleid`)\n\t\t\tVALUES ('" . $variables["uuid"] . "','import','0',0,0,'Admin');";
     $this->db->query($querystatement);
     //next quicksearch
     $querystatement = "INSERT INTO `tablefindoptions` (`tabledefid`, `name`, `search`, `displayorder`, `roleid`)\n\t\t\tVALUES ('" . $variables["uuid"] . "','All Records','" . $variables["maintable"] . ".id!=-1',0, '');";
     $this->db->query($querystatement);
     //and last findfields
     $querystatement = "INSERT INTO `tablesearchablefields` (`tabledefid`, `field`, `name`, `displayorder`, `type`)\n\t\t\tVALUES ('" . $variables["uuid"] . "','" . $variables["maintable"] . ".id','id',1,'field');";
     $this->db->query($querystatement);
     return $newid;
 }
示例#23
0
 function verifyVariables($variables)
 {
     $validJob = true;
     if (isset($variables["job"])) {
         if ($variables["job"] === "" || $variables["job"] === NULL) {
             $validJob = false;
         }
     } else {
         $validJob = false;
     }
     $validPush = true;
     if (isset($variables["pushrecordid"])) {
         if ($variables["pushrecordid"] === "" || $variables["pushrecordid"] === NULL) {
             $validPush = false;
         }
     } else {
         $validPush = false;
     }
     if (!$validPush && !$validJob) {
         $this->verifyErrors[] = "The `job` or the `pushrecordid` must be set and not blank.";
     }
     //checks to see if crontab is in the (somewhat) right format
     if (isset($variables["crontab"])) {
         $explode = explode("::", $variables["crontab"]);
         if (count($explode) != 5) {
             $this->verifyErrors[] = "The `crontab` field is not of the proper form.  There must be four pairs of '::' in the field's value.";
         }
     }
     //end if
     return parent::verifyVariables($variables);
 }
示例#24
0
 function updateRecord($variables, $modifiedby = NULL, $useUuid = false)
 {
     if (isset($variables["makeglobal"])) {
         $variables["userid"] = '';
     }
     parent::updateRecord($variables, $modifiedby, $useUuid);
 }
示例#25
0
 function _createServiceCharge($arrecord, $percentage)
 {
     if ($arrecord["amount"] - $arrecord["paid"] <= 0) {
         return false;
     }
     $newAmount = round(($arrecord["amount"] - $arrecord["paid"]) * ($percentage / 100), CURRENCY_ACCURACY);
     if ($newAmount <= 0) {
         return false;
     }
     if (!class_exists("phpbmsTable")) {
         include "include/tables.php";
     }
     $aritems = new phpbmsTable($this->db, "tbld:c595dbe7-6c77-1e02-5e81-c2e215736e9c");
     $newarrecord = array();
     $newarrecord["uuid"] = uuid($aritems->prefix . ":");
     $newarrecord["type"] = "service charge";
     $newarrecord["status"] = "open";
     $newarrecord["posted"] = 1;
     $newarrecord["amount"] = $newAmount;
     $newarrecord["itemdate"] = dateToString($this->agingDate);
     $newarrecord["clientid"] = $arrecord["clientid"];
     $newarrecord["relatedid"] = $arrecord["relatedid"];
     $aritems->insertRecord($newarrecord, $this->userid);
     return true;
 }