function validate() { $this->get_value("productID") or $err[] = "Missing a Product."; $this->get_value("tfID") or $err[] = "Missing a Destination TF."; $this->get_value("amount") or $err[] = "Missing an amount."; return parent::validate($err); }
function delete() { $q = prepare("DELETE FROM reminderRecipient WHERE reminderID = %d", $this->get_id()); $db = new db_alloc(); $db->query($q); return parent::delete(); }
function delete() { $q = prepare("DELETE from projectPerson WHERE projectID = %d", $this->get_id()); $db = new db_alloc(); $db->query($q); return parent::delete(); }
function delete() { $db = new db_alloc(); $q = prepare("DELETE FROM invoiceEntity WHERE invoiceID = %d", $this->get_id()); $db->query($q); return parent::delete(); }
function validate() { $this->get_value("productID") or $err[] = "Please select a Product."; $this->get_value("productSaleID") or $err[] = "Please select a Product Sale."; $this->get_value("sellPrice") or $err[] = "Please enter a Sell Price."; $this->get_value("quantity") or $err[] = "Please enter a Quantity."; return parent::validate($err); }
function save() { if (!imp($this->get_value("iiAmount"))) { $this->set_value("iiAmount", $this->get_value("iiQuantity") * $this->get_value("iiUnitPrice")); } $status = parent::save(); $status2 = invoice::update_invoice_dates($this->get_value("invoiceID")); return $status && $status2; }
function set_values($prefix) { global $TPL; $db = new db_alloc(); $db->query("SELECT * FROM invoiceRepeatDate WHERE invoiceRepeatID = %d", $this->get_id()); while ($row = $db->row()) { $rows[] = $row["invoiceDate"]; } $TPL[$prefix . "frequency"] = implode(" ", (array) $rows); return parent::set_values($prefix); }
function delete() { $db = new db_alloc(); $query = prepare("SELECT * \n FROM productSaleItem \n WHERE productSaleID = %d", $this->get_id()); $db->query($query); while ($db->next_record()) { $productSaleItem = new productSaleItem(); $productSaleItem->read_db_record($db); $productSaleItem->delete(); } $this->delete_transactions(); return parent::delete(); }
function save() { // Just ensure multiple 0 entries cannot be saved. if ($this->get_value("commissionPercent") == 0) { $q = prepare("SELECT * FROM projectCommissionPerson WHERE projectID = %d AND commissionPercent = 0 AND projectCommissionPersonID != %d", $this->get_value("projectID"), $this->get_id()); $db = new db_alloc(); $db->query($q); if ($db->next_record()) { $fail = true; alloc_error("Only one Time Sheet Commission is allowed to be set to 0%"); } } if (!$fail) { parent::save(); } }
function validate() { $current_user =& singleton("current_user"); $this->get_value("fromTfID") or $err[] = "Unable to save transaction without a Source TF."; $this->get_value("fromTfID") && $this->get_value("fromTfID") == $this->get_value("tfID") and $err[] = "Unable to save transaction with Source TF (" . tf::get_name($this->get_value("fromTfID")) . ") being the same as the Destination TF (" . tf::get_name($this->get_value("tfID")) . ") \"" . $this->get_value("product") . "\""; $this->get_value("quantity") or $this->set_value("quantity", 1); $this->get_value("transactionDate") or $this->set_value("transactionDate", date("Y-m-d")); $old = $this->all_row_fields; $status = $old["status"] or $status = $this->get_value("status"); if ($status != "pending" && !$current_user->have_role("admin")) { $err[] = "Unable to save transaction unless status is pending."; } if ($old["status"] == "pending" && $old["status"] != $this->get_value("status") && !$current_user->have_role("admin")) { $err[] = "Unable to change transaction status unless you have admin perm."; } return parent::validate($err); }
function delete() { if ($this->get_id()) { $dir = ATTACHMENTS_DIR . "comment" . DIRECTORY_SEPARATOR . $this->get_id(); if (is_dir($dir)) { $handle = opendir($dir); clearstatcache(); while (false !== ($file = readdir($handle))) { if ($file != "." && $file != ".." && file_exists($dir . DIRECTORY_SEPARATOR . $file)) { unlink($dir . DIRECTORY_SEPARATOR . $file); clearstatcache(); } } is_dir($dir) && rmdir($dir); } } parent::delete(); }
function delete() { // delete all contacts and comments linked with this client as well $db = new db_alloc(); $query = prepare("SELECT * FROM clientContact WHERE clientID=%d", $this->get_id()); $db->query($query); while ($db->next_record()) { $clientContact = new clientContact(); $clientContact->read_db_record($db); $clientContact->delete(); } $query = prepare("SELECT * FROM comment WHERE commentType = 'client' and commentLinkID=%d", $this->get_id()); $db->query($query); while ($db->next_record()) { $comment = new comment(); $comment->read_db_record($db); $comment->delete(); } return parent::delete(); }
function validate() { // Validate/coerce the fields $coerce = array("inprogress" => "open_inprogress", "notstarted" => "open_notstarted", "info" => "pending_info", "client" => "pending_client", "manager" => "pending_manager", "tasks" => "pending_tasks", "invalid" => "closed_invalid", "duplicate" => "closed_duplicate", "incomplete" => "closed_incomplete", "complete" => "closed_complete", "archived" => "closed_archived", "open" => "open_inprogress", "pending" => "pending_info", "close" => "closed_complete", "closed" => "closed_complete"); if ($this->get_value("taskStatus") && !in_array($this->get_value("taskStatus"), $coerce)) { $orig = $this->get_value("taskStatus"); $cleaned = str_replace("-", "_", strtolower($orig)); if (in_array($cleaned, $coerce)) { $this->set_value("taskStatus", $cleaned); } else { if ($coerce[$cleaned]) { $this->set_value("taskStatus", $coerce[$cleaned]); } } if (!in_array($this->get_value("taskStatus"), $coerce)) { $err[] = "Unrecognised task status: " . $orig; } } in_array($this->get_value("priority"), array(1, 2, 3, 4, 5)) or $err[] = "Invalid priority."; in_array(ucwords($this->get_value("taskTypeID")), array("Task", "Fault", "Message", "Milestone", "Parent")) or $err[] = "Invalid Task Type."; $this->get_value("taskName") or $err[] = "Please enter a name for the Task."; $this->get_value("taskDescription") and $this->set_value("taskDescription", rtrim($this->get_value("taskDescription"))); return parent::validate($err); }
function save() { $this->set_value("emailAddress", str_replace(array("<", ">"), "", $this->get_value("emailAddress"))); return parent::save(); }
function delete() { // have to null out any records that point to this clientContact first to satisfy the referential integrity constraints if ($this->get_id()) { $db = new db_alloc(); $q = prepare("UPDATE interestedParty SET clientContactID = NULL where clientContactID = %d", $this->get_id()); $db->query($q); $q = prepare("UPDATE comment SET commentCreatedUserClientContactID = NULL where commentCreatedUserClientContactID = %d", $this->get_id()); $db->query($q); $q = prepare("UPDATE project SET clientContactID = NULL where clientContactID = %d", $this->get_id()); $db->query($q); } return parent::delete(); }
function delete() { $timeSheetID = $this->get_value("timeSheetID"); $db = new db_alloc(); $q = prepare("SELECT invoiceItem.*\n FROM invoiceItem\n LEFT JOIN invoice ON invoiceItem.invoiceID = invoice.invoiceID\n WHERE timeSheetID = %d\n AND invoiceStatus != 'finished'", $timeSheetID); $db->query($q); while ($row = $db->row()) { $ii = new invoiceItem(); $ii->set_id($row["invoiceItemID"]); $ii->select(); if ($ii->get_value("timeSheetItemID") == $this->get_id()) { $ii->delete(); } else { if (!$ii->get_value("timeSheetItemID")) { invoiceEntity::save_invoice_timeSheet($row["invoiceID"], $timeSheetID); // will update the existing invoice item } } } return parent::delete(); }
function validate() { $this->get_id() or $err[] = "Please enter a Value/ID for the " . $this->get_label(); $this->get_value($this->t . "Seq") or $err[] = "Please enter a Sequence Number for the " . $this->get_label(); return parent::validate($err); }
function save() { $rtn = parent::save(); $this->update_related_invoices(); return $rtn; }