コード例 #1
0
 function prepare_set_defaults()
 {
     log_debug("invoice", "Executing prepare_set_defaults");
     if (empty($this->data["code_invoice"])) {
         $this->prepare_code_invoice();
     }
     if (empty($this->data["date_trans"])) {
         $this->data["date_trans"] = date("Y-m-d");
     }
     if (empty($this->data["date_due"])) {
         $this->data["date_due"] = invoice_calc_duedate($this->data["date_trans"]);
     }
     return 1;
 }
コード例 #2
0
 function execute()
 {
     log_debug("invoice_form_details", "Executing execute()");
     if ($this->invoiceid) {
         $this->mode = "edit";
     } else {
         $this->mode = "add";
     }
     /*
     	Make sure invoice does exist and fetch locked status
     */
     if ($this->mode == "edit") {
         $sql_invoice_obj = new sql_query();
         $sql_invoice_obj->string = "SELECT id, locked FROM account_" . $this->type . " WHERE id='" . $this->invoiceid . "' LIMIT 1";
         $sql_invoice_obj->execute();
         if (!$sql_invoice_obj->num_rows()) {
             print "<p><b>Error: The requested invoice does not exist. <a href=\"index.php?page=accounts/" . $this->type . "/" . $this->type . ".php\">Try looking on the invoice/invoice list page.</a></b></p>";
             return 0;
         } else {
             $sql_invoice_obj->fetch_array();
             $this->locked = $sql_invoice_obj->data[0]["locked"];
         }
     }
     /*
     	Start Form
     */
     $this->obj_form = new form_input();
     $this->obj_form->formname = $this->type . "_invoice_" . $this->mode;
     $this->obj_form->language = $_SESSION["user"]["lang"];
     $this->obj_form->action = $this->processpage;
     $this->obj_form->method = "POST";
     /*
     	Define form structure
     */
     // basic details
     if ($this->type == "ap") {
         $sql_struct_obj = new sql_query();
         $sql_struct_obj->prepare_sql_settable("vendors");
         $sql_struct_obj->prepare_sql_addfield("id", "vendors.id");
         $sql_struct_obj->prepare_sql_addfield("label", "vendors.code_vendor");
         $sql_struct_obj->prepare_sql_addfield("label1", "vendors.name_vendor");
         $sql_struct_obj->prepare_sql_addorderby("code_vendor");
         $sql_struct_obj->prepare_sql_addwhere("id = 'CURRENTID' OR date_end = '0000-00-00'");
         $structure = form_helper_prepare_dropdownfromobj("vendorid", $sql_struct_obj);
         $structure["options"]["req"] = "yes";
         $structure["options"]["width"] = "600";
         $structure["options"]["search_filter"] = "enabled";
         $structure["defaultvalue"] = $this->vendor_id;
         $this->obj_form->add_input($structure);
     } else {
         // load customer dropdown
         $sql_struct_obj = new sql_query();
         $sql_struct_obj->prepare_sql_settable("customers");
         $sql_struct_obj->prepare_sql_addfield("id", "customers.id");
         $sql_struct_obj->prepare_sql_addfield("label", "customers.code_customer");
         $sql_struct_obj->prepare_sql_addfield("label1", "customers.name_customer");
         $sql_struct_obj->prepare_sql_addorderby("code_customer");
         $sql_struct_obj->prepare_sql_addwhere("id = 'CURRENTID' OR date_end = '0000-00-00'");
         $structure = form_helper_prepare_dropdownfromobj("customerid", $sql_struct_obj);
         $structure["options"]["req"] = "yes";
         $structure["options"]["width"] = "600";
         $structure["options"]["search_filter"] = "enabled";
         $structure["defaultvalue"] = $this->customer_id;
         $this->obj_form->add_input($structure);
     }
     $sql_struct_obj = new sql_query();
     $sql_struct_obj->prepare_sql_settable("staff");
     $sql_struct_obj->prepare_sql_addfield("id", "staff.id");
     $sql_struct_obj->prepare_sql_addfield("label", "staff.staff_code");
     $sql_struct_obj->prepare_sql_addfield("label1", "staff.name_staff");
     $sql_struct_obj->prepare_sql_addorderby("staff_code");
     $sql_struct_obj->prepare_sql_addwhere("id = 'CURRENTID' OR date_end = '0000-00-00'");
     $structure = form_helper_prepare_dropdownfromobj("employeeid", $sql_struct_obj);
     $structure["options"]["req"] = "yes";
     $structure["options"]["autoselect"] = "yes";
     $structure["options"]["width"] = "600";
     $structure["options"]["search_filter"] = "enabled";
     $structure["defaultvalue"] = @$_SESSION["user"]["default_employeeid"];
     $this->obj_form->add_input($structure);
     $structure = NULL;
     $structure["fieldname"] = "code_invoice";
     $structure["type"] = "input";
     if ($this->mode == "edit") {
         $structure["options"]["req"] = "yes";
     }
     $this->obj_form->add_input($structure);
     $structure = NULL;
     $structure["fieldname"] = "code_ordernumber";
     $structure["type"] = "input";
     $this->obj_form->add_input($structure);
     $structure = NULL;
     $structure["fieldname"] = "code_ponumber";
     $structure["type"] = "input";
     $this->obj_form->add_input($structure);
     $structure = NULL;
     $structure["fieldname"] = "notes";
     $structure["type"] = "textarea";
     $structure["options"]["height"] = "100";
     $structure["options"]["width"] = 500;
     $this->obj_form->add_input($structure);
     // dates
     $structure = NULL;
     $structure["fieldname"] = "date_trans";
     $structure["type"] = "date";
     $structure["defaultvalue"] = date("Y-m-d");
     $this->obj_form->add_input($structure);
     $structure = NULL;
     $structure["fieldname"] = "date_due";
     $structure["type"] = "date";
     $structure["defaultvalue"] = invoice_calc_duedate(date("Y-m-d"));
     $this->obj_form->add_input($structure);
     // destination account
     if ($this->type == "ap") {
         $structure = charts_form_prepare_acccountdropdown("dest_account", "ap_summary_account");
     } else {
         $structure = charts_form_prepare_acccountdropdown("dest_account", "ar_summary_account");
     }
     $structure["options"]["req"] = "yes";
     $structure["options"]["autoselect"] = "yes";
     $structure["options"]["search_filter"] = "enabled";
     $structure["options"]["width"] = "600";
     $this->obj_form->add_input($structure);
     // ID
     $structure = NULL;
     $structure["fieldname"] = "id_invoice";
     $structure["type"] = "hidden";
     $structure["defaultvalue"] = $this->invoiceid;
     $this->obj_form->add_input($structure);
     // submit
     $structure = NULL;
     $structure["fieldname"] = "submit";
     $structure["type"] = "submit";
     $structure["defaultvalue"] = "Save Changes";
     $this->obj_form->add_input($structure);
     // load data
     if ($this->type == "ap") {
         $this->obj_form->sql_query = "SELECT vendorid, employeeid, code_invoice, code_ordernumber, code_ponumber, notes, date_trans, date_due, dest_account FROM account_" . $this->type . " WHERE id='" . $this->invoiceid . "'";
     } else {
         $this->obj_form->sql_query = "SELECT customerid, employeeid, code_invoice, code_ordernumber, code_ponumber, notes, date_trans, date_due, dest_account FROM account_" . $this->type . " WHERE id='" . $this->invoiceid . "'";
     }
     $this->obj_form->load_data();
     /*
     	Fetch any provided values from $_GET if adding a new invoice and no error data provided
     */
     if ($this->mode == "add" && error_check()) {
         $this->obj_form->structure["customerid"]["defaultvalue"] = @security_script_input('/^[0-9]*$/', $_GET["customerid"]);
         $this->obj_form->structure["vendorid"]["defaultvalue"] = @security_script_input('/^[0-9]*$/', $_GET["vendorid"]);
     }
     // define subforms
     if ($this->type == "ap") {
         $this->obj_form->subforms[$this->type . "_invoice_details"] = array("vendorid", "employeeid", "code_invoice", "code_ordernumber", "code_ponumber", "date_trans", "date_due");
     } else {
         $this->obj_form->subforms[$this->type . "_invoice_details"] = array("customerid", "employeeid", "code_invoice", "code_ordernumber", "code_ponumber", "date_trans", "date_due");
     }
     $this->obj_form->subforms[$this->type . "_invoice_financials"] = array("dest_account");
     $this->obj_form->subforms[$this->type . "_invoice_other"] = array("notes");
     $this->obj_form->subforms["hidden"] = array("id_invoice");
     if ($this->locked) {
         $this->obj_form->subforms["submit"] = array();
     } else {
         $this->obj_form->subforms["submit"] = array("submit");
     }
     return 1;
 }
コード例 #3
0
 function execute()
 {
     log_debug("quote_form_delete", "Executing execute()");
     /*
     	Start Form
     */
     $this->obj_form = new form_input();
     $this->obj_form->formname = "_quote_convert";
     $this->obj_form->language = $_SESSION["user"]["lang"];
     $this->obj_form->action = $this->processpage;
     $this->obj_form->method = "POST";
     /*
     	Define form structure
     */
     // basic details
     $structure = NULL;
     $structure["fieldname"] = "code_quote";
     $structure["type"] = "text";
     $this->obj_form->add_input($structure);
     $structure = NULL;
     $structure["fieldname"] = "code_invoice";
     $structure["type"] = "input";
     $this->obj_form->add_input($structure);
     $structure = NULL;
     $structure["fieldname"] = "code_ordernumber";
     $structure["type"] = "input";
     $this->obj_form->add_input($structure);
     $structure = NULL;
     $structure["fieldname"] = "code_ponumber";
     $structure["type"] = "input";
     $this->obj_form->add_input($structure);
     // dates
     $structure = NULL;
     $structure["fieldname"] = "date_trans";
     $structure["type"] = "date";
     $structure["defaultvalue"] = date("Y-m-d");
     $this->obj_form->add_input($structure);
     $structure = NULL;
     $structure["fieldname"] = "date_due";
     $structure["type"] = "date";
     $structure["defaultvalue"] = invoice_calc_duedate(date("Y-m-d"));
     $this->obj_form->add_input($structure);
     // destination account
     $structure = charts_form_prepare_acccountdropdown("dest_account", "ar_summary_account");
     $structure["options"]["req"] = "yes";
     $structure["options"]["autoselect"] = "yes";
     $this->obj_form->add_input($structure);
     // ID
     $structure = NULL;
     $structure["fieldname"] = "id_quote";
     $structure["type"] = "hidden";
     $structure["defaultvalue"] = $this->quoteid;
     $this->obj_form->add_input($structure);
     // submit
     $structure = NULL;
     $structure["fieldname"] = "submit";
     $structure["type"] = "submit";
     $structure["defaultvalue"] = "Convert to Invoice";
     $this->obj_form->add_input($structure);
     // load data
     $this->obj_form->sql_query = "SELECT date_create, code_quote FROM account_quotes WHERE id='" . $this->quoteid . "'";
     $this->obj_form->load_data();
     // define subforms
     $this->obj_form->subforms["quote_convert_details"] = array("code_quote", "code_invoice", "code_ordernumber", "code_ponumber", "date_trans", "date_due");
     $this->obj_form->subforms["quote_convert_financials"] = array("dest_account");
     $this->obj_form->subforms["hidden"] = array("id_quote");
     $this->obj_form->subforms["submit"] = array("submit");
 }