Ejemplo n.º 1
0
 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);
 }
Ejemplo n.º 2
0
 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);
 }
Ejemplo n.º 3
0
 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);
 }
Ejemplo n.º 4
0
 function validate()
 {
     if ($this->get_value("status") == "admin" || $this->get_value("status") == "finished") {
         $orig = new $this->classname();
         $orig->set_id($this->get_id());
         $orig->select();
         $orig_status = $orig->get_value("status");
         if ($orig_status == "allocate" && $this->get_value("status") == "admin") {
         } else {
             if (!$this->have_perm(PERM_APPROVE_PRODUCT_TRANSACTIONS)) {
                 $rtn[] = "Unable to save Product Sale, user does not have correct permissions.";
             }
         }
     }
     if ($this->get_value("extRef")) {
         $q = prepare("SELECT productSaleID FROM productSale WHERE productSaleID != %d AND extRef = '%s'", $this->get_id(), $this->get_value("extRef"));
         $db = new db_alloc();
         if ($r = $db->qr($q)) {
             $rtn[] = "Unable to save Product Sale, this external reference number is used in Sale " . $r["productSaleID"];
         }
     }
     return parent::validate($rtn);
 }
Ejemplo n.º 5
0
 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);
 }
Ejemplo n.º 6
0
 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);
 }