function copyInvoice($invoiceid) { $querystatement = "\n\t\t\tSELECT\n\t\t\t\tinvoices.*,\n\t\t\t\tfirstrepeat,\n\t\t\t\tincludepaymenttype,\n\t\t\t\trecurringinvoices.id AS recurrid,\n\t\t\t\trecurringinvoices.statusid AS newstatusid,\n\t\t\t\trecurringinvoices.assignedtoid AS newassignedtoid,\n\t\t\t\tnotificationroleid\n\t\t\tFROM\n\t\t\t\tinvoices INNER JOIN recurringinvoices ON invoices.uuid = recurringinvoices.invoiceid\n\t\t\tWHERE\n\t\t\t\tinvoices.uuid = '" . $invoiceid . "'\n\t\t"; $queryresult = $this->db->query($querystatement); $therecord = $this->db->fetchArray($queryresult); $fieldList = array(); foreach ($therecord as $name => $value) { switch ($name) { case "id": case "notificationroleid": case "includepaymenttype": case "modifiedby": case "modifieddate": case "createdby": case "creationdate": case "newstatusid": case "newassignedtoid": case "firstrepeat": case "recurrid": case "bankname": case "ccnumber": case "routingnumber": case "ccexpiration": case "ccverification": case "accountnumber": break; case "uuid": $fieldlist[] = "uuid"; $therecord["uuid"] = uuid(getUuidPrefix($this->db, "tbld:62fe599d-c18f-3674-9e54-b62c2d6b1883") . ":"); break; case "checkno": case "webconfirmationno": case "trackingno": case "weborder": case "transactionid": case "invoicedate": $fieldlist[] = $name; $therecord[$name] = NULL; break; case "statusdate": case "orderdate": $fieldlist[] = $name; $therecord[$name] = dateToString(mktime(), "SQL"); break; case "paymenttypeid": $fieldlist[] = $name; if (!$therecord["includepaymenttype"]) { $therecord[$name] = NULL; } break; case "statusid": $fieldlist[] = $name; $therecord[$name] = $therecord["newstatusid"]; break; case "assignedtoid": $fieldlist[] = $name; $therecord[$name] = $therecord["newassignedtoid"]; break; case "amountpaid": $fieldlist[] = $name; $therecord[$name] = 0; break; case "type": $fieldlist[] = $name; $therecord[$name] = "Order"; break; case "readytopost": $fieldlist[] = $name; $therecord[$name] = 0; break; default: $fieldlist[] = $name; } //endswitch } //endforeach $insertstatement = $this->prepareInsert("invoices", $fieldlist, $therecord); $this->db->query($insertstatement); $theid = $this->db->insertId(); $this->copyLineItems($therecord["id"], $theid); $this->insertHistory($therecord["uuid"], $therecord["statusid"], $therecord["statusdate"], $therecord["assignedtoid"]); $this->updateReccurence($therecord["recurrid"], $therecord["firstrepeat"]); if ($therecord["notificationroleid"]) { $this->sendNotification($therecord["notificationroleid"], $theid); } }
function createChildTask($parentid, $newdate, $startdate, $enddate = NULL) { //let's check to see if the new task already exists $querystatement = "\n SELECT\n id\n FROM\n notes\n WHERE\n parentid='" . $parentid . "'\n AND startdate='" . dateToString($newdate, "SQL") . "'"; $queryresult = $this->db->query($querystatement); if ($this->db->numRows($queryresult)) { return false; } $newenddate = "NULL"; if ($enddate) { $newenddate = "\"" . dateToString($newdate + ($enddate - $startdate), "SQL") . "\""; } $querystatement = "\n SELECT\n id,\n uuid,\n type,\n subject,\n content,\n status,\n starttime,\n private,\n modifiedby,\n location,\n importance,\n endtime,\n CURDATE() as creationdate,\n createdby,\n category,\n attachedtabledefid,\n attachedid,\n assignedtoid,\n assignedtodate,\n assignedtotime,\n assignedbyid\n\t\t\t FROM\n notes\n WHERE\n uuid='" . $parentid . "'"; $queryresult = $this->db->query($querystatement); $therecord = $this->db->fetchArray($queryresult); $querystatement = "\n SELECT\n id\n FROM\n notes\n WHERE\n parentid = '" . $parentid . "'\n AND completed = 0 AND startdate ='" . dateToString($newdate, "SQL") . "'"; $queryresult = $this->db->query($querystatement); if ($this->db->numRows($queryresult)) { return false; } if (!$therecord["assignedtoid"]) { $therecord["assignedtoid"] = "NULL"; } $querystatement = "\n INSERT INTO\n notes\n (\n uuid,\n parentid,\n startdate,\n enddate,\n completed,\n completeddate,\n type,\n subject,\n content,\n status,\n starttime,\n private,\n modifiedby,\n location,\n importance,\n endtime,\n creationdate,\n createdby,\n category,\n attachedtabledefid,\n attachedid,\n assignedtoid,\n assignedtodate,\n assignedtotime,\n assignedbyid)\n VALUES (\n '" . uuid(getUuidPrefix($this->db, "tbld:a4cdd991-cf0a-916f-1240-49428ea1bdd1") . ":") . "',\n\t\t\t\t'" . $therecord["uuid"] . "',\n '" . dateToString($newdate, "SQL") . "',\n " . $newenddate . ",\n 0,\n NULL,"; $querystatement .= "'" . $therecord["type"] . "', "; $querystatement .= "'" . $therecord["subject"] . "', "; $querystatement .= "'" . $therecord["content"] . "', "; $querystatement .= "'" . $therecord["status"] . "', "; if ($therecord["starttime"]) { $querystatement .= "'" . $therecord["starttime"] . "', "; } else { $querystatement .= "NULL, "; } $querystatement .= $therecord["private"] . ", "; $querystatement .= $therecord["modifiedby"] . ", "; $querystatement .= "'" . $therecord["location"] . "', "; $querystatement .= "'" . $therecord["importance"] . "', "; if ($therecord["endtime"]) { $querystatement .= "'" . $therecord["endtime"] . "', "; } else { $querystatement .= "NULL, "; } $querystatement .= "'" . $therecord["creationdate"] . "', "; $querystatement .= $therecord["createdby"] . ", "; $querystatement .= "'" . $therecord["category"] . "', "; $querystatement .= "'" . $therecord["attachedtabledefid"] . "', "; $querystatement .= "'" . $therecord["attachedid"] . "', "; $querystatement .= "'" . $therecord["assignedtoid"] . "', "; if ($therecord["assignedtodate"]) { $querystatement .= "'" . $therecord["assignedtodate"] . "', "; } else { $querystatement .= "NULL, "; } if ($therecord["assignedtotime"]) { $querystatement .= "'" . $therecord["assignedtotime"] . "', "; } else { $querystatement .= "NULL, "; } $querystatement .= "'" . $therecord["assignedbyid"] . "') "; $queryresult = $this->db->query($querystatement); return true; }
function _storeTempCSV($fileName) { $querystatement = "\n\t\t\t\tINSERT INTO\n\t\t\t\t\t`files`\n\t\t\t\t\t(\n\t\t\t\t\t\t`uuid`,\n\t\t\t\t\t\t`name`,\n\t\t\t\t\t\t`description`,\n\t\t\t\t\t\t`file`,\n\t\t\t\t\t\t`type`,\n\t\t\t\t\t\t`roleid`,\n\t\t\t\t\t\t`creationdate`,\n\t\t\t\t\t\t`createdby`,\n\t\t\t\t\t\t`modifiedby`\n\t\t\t\t\t)\n\t\t\t\t\tVALUES\n\t\t\t\t\t(\n\t\t\t\t\t\t'" . uuid(getUuidPrefix($this->table->db, "tbld:80b4f38d-b957-bced-c0a0-ed08a0db6475")) . "',\n\t\t\t\t\t\t'temporary',\n\t\t\t\t\t\t'This is a temporary import file',\n\t\t\t\t\t\t'" . $this->_getFile($fileName) . "',\n\t\t\t\t\t\t'phpbms/temp',\n\t\t\t\t\t\t'Admin',\n\t\t\t\t\t\tNOW(),\n\t\t\t\t\t\t'" . $_SESSION["userinfo"]["id"] . "',\n\t\t\t\t\t\t'" . $_SESSION["userinfo"]["id"] . "'\n\n\t\t\t\t\t)\n\t\t\t\t"; $this->table->db->query($querystatement); $id = $this->table->db->insertId(); if ($id) { $this->tempFileID = (int) $id; } else { $this->error .= '<li> inserting temporary file failure </li>'; } }