本文整理汇总了PHP中sql_query::prepare_sql_addwhere方法的典型用法代码示例。如果您正苦于以下问题:PHP sql_query::prepare_sql_addwhere方法的具体用法?PHP sql_query::prepare_sql_addwhere怎么用?PHP sql_query::prepare_sql_addwhere使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sql_query
的用法示例。
在下文中一共展示了sql_query::prepare_sql_addwhere方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: execute
function execute()
{
$this->obj_form = new form_input();
$this->obj_form->formname = "bankstatementimport";
$this->obj_form->language = $_SESSION["user"]["lang"];
$this->obj_form->action = "accounts/import/bankstatement-process.php";
$this->obj_form->method = "post";
$structure = NULL;
$structure["fieldname"] = "BANK_STATEMENT";
$structure["type"] = "file";
$this->obj_form->add_input($structure);
$structure = charts_form_prepare_acccountdropdown("dest_account", "ar_payment");
$structure["options"]["req"] = "yes";
$structure["options"]["autoselect"] = "yes";
$structure["options"]["search_filter"] = "enabled";
$structure["options"]["width"] = "600";
$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"]["width"] = "600";
$structure["options"]["search_filter"] = "enabled";
$structure["defaultvalue"] = @$_SESSION["user"]["default_employeeid"];
$this->obj_form->add_input($structure);
$structure = NULL;
$structure["fieldname"] = "submit";
$structure["type"] = "submit";
$structure["defaultvalue"] = "Import";
$this->obj_form->add_input($structure);
$this->obj_form->subforms["upload_bank_statement"] = array("BANK_STATEMENT", "dest_account", "employeeid");
$this->obj_form->subforms["import"] = array("submit");
}
示例2: execute
function execute()
{
/*
Create an array of all unbilled time records. We need to do the following to create this list:
1. Exclude any internal_only projects.
2. Include time which belongs to a time_group, but ONLY if the time group has not been added to an invoice.
*/
$unbilled_ids = array();
// select non-internal projects
$sql_projects_obj = new sql_query();
$sql_projects_obj->string = "SELECT projects.id as projectid, project_phases.id as phaseid FROM project_phases LEFT JOIN projects ON projects.id = project_phases.projectid WHERE projects.internal_only='0'";
$sql_projects_obj->execute();
if ($sql_projects_obj->num_rows()) {
$sql_projects_obj->fetch_array();
foreach ($sql_projects_obj->data as $project_data) {
// select non-group time records
$sql_obj = new sql_query();
$sql_obj->string = "SELECT id FROM timereg WHERE groupid='0' AND phaseid='" . $project_data["phaseid"] . "'";
$sql_obj->execute();
if ($sql_obj->num_rows()) {
$sql_obj->fetch_array();
foreach ($sql_obj->data as $data_tmp) {
// we store the ID inside an array key, since they are unique
// and this will prevent us needed to check for the existance of
// the ID already.
$unbilled_ids[$data_tmp["id"]] = "on";
}
}
unset($sql_obj);
// select unpaid group IDs
$sql_obj = new sql_query();
$sql_obj->string = "SELECT id FROM time_groups WHERE projectid='" . $project_data["projectid"] . "' AND invoiceid='0'";
$sql_obj->execute();
if ($sql_obj->num_rows()) {
$sql_obj->fetch_array();
foreach ($sql_obj->data as $data_group) {
// fetch all the time reg IDs belonging this group, but only select time entries marked as billable - we
// don't want to report a timegroup with unbillable time as being billed!
$sql_reg_obj = new sql_query();
$sql_reg_obj->string = "SELECT id FROM timereg WHERE groupid='" . $data_group["id"] . "' AND billable='1'";
$sql_reg_obj->execute();
if ($sql_reg_obj->num_rows()) {
$sql_reg_obj->fetch_array();
foreach ($sql_reg_obj->data as $data_tmp) {
// we store the ID inside an array key, since they are unique
// and this will prevent us needed to check for the existance of
// the ID already.
$unbilled_ids[$data_tmp["id"]] = "on";
}
}
unset($sql_reg_obj);
}
}
unset($sql_obj);
}
}
/*
Define table
*/
// establish a new table object
$this->obj_table = new table();
$this->obj_table->language = $_SESSION["user"]["lang"];
$this->obj_table->tablename = "timereg_unbilled";
// define all the columns and structure
$this->obj_table->add_column("date", "date", "timereg.date");
$this->obj_table->add_column("standard", "name_phase", "CONCAT_WS(' -- ', projects.code_project, projects.name_project, project_phases.name_phase)");
$this->obj_table->add_column("standard", "name_staff", "CONCAT_WS(' -- ', staff.staff_code, staff.name_staff)");
$this->obj_table->add_column("standard", "time_group", "time_groups.name_group");
$this->obj_table->add_column("standard", "description", "timereg.description");
$this->obj_table->add_column("hourmins", "time_booked", "timereg.time_booked");
// defaults
$this->obj_table->columns = array("date", "name_phase", "name_staff", "time_group", "description", "time_booked");
$this->obj_table->columns_order = array("date", "name_phase");
$this->obj_table->columns_order_options = array("date", "name_phase", "name_staff", "time_group", "description");
// define SQL structure
$this->obj_table->sql_obj->prepare_sql_settable("timereg");
$this->obj_table->sql_obj->prepare_sql_addfield("id", "timereg.id");
$this->obj_table->sql_obj->prepare_sql_addfield("projectid", "projects.id");
$this->obj_table->sql_obj->prepare_sql_addfield("employeeid", "timereg.employeeid");
$this->obj_table->sql_obj->prepare_sql_addfield("timegroupid", "time_groups.id");
$this->obj_table->sql_obj->prepare_sql_addfield("timegroupinvoiceid", "time_groups.invoiceid");
$this->obj_table->sql_obj->prepare_sql_addjoin("LEFT JOIN staff ON timereg.employeeid = staff.id");
$this->obj_table->sql_obj->prepare_sql_addjoin("LEFT JOIN time_groups ON timereg.groupid = time_groups.id");
$this->obj_table->sql_obj->prepare_sql_addjoin("LEFT JOIN project_phases ON timereg.phaseid = project_phases.id");
$this->obj_table->sql_obj->prepare_sql_addjoin("LEFT JOIN projects ON project_phases.projectid = projects.id");
// provide list of valid IDs
$unbilled_ids_keys = array_keys($unbilled_ids);
$unbilled_ids_count = count($unbilled_ids_keys);
$unbilled_ids_sql = "";
if ($unbilled_ids_count) {
$this->obj_table->sql_obj->prepare_sql_addwhere("timereg.id IN (" . format_arraytocommastring($unbilled_ids_keys) . ")");
}
// if the user only has access to specific staff, filter to these staff members
if ($this->access_staff_ids) {
$this->obj_table->sql_obj->prepare_sql_addwhere("timereg.employeeid IN (" . format_arraytocommastring($this->access_staff_ids) . ")");
}
/// Filtering/Display Options
// fixed options
$this->obj_table->add_fixed_option("id", $this->id);
// acceptable filter options
//.........这里部分代码省略.........
示例3: credit_render_invoiceselect
function credit_render_invoiceselect($type, $id, $processpage)
{
log_debug("inc_credits", "credit_render_summarybox({$type}, {$id})");
// fetch credit information
$sql_obj = new sql_query();
$sql_obj->prepare_sql_settable("account_{$type}");
if ($type == "ar_credit") {
$sql_obj->prepare_sql_addfield("date_sent");
$sql_obj->prepare_sql_addfield("sentmethod");
}
$sql_obj->prepare_sql_addfield("code_credit");
$sql_obj->prepare_sql_addfield("amount_total");
$sql_obj->prepare_sql_addfield("invoiceid");
$sql_obj->prepare_sql_addfield("locked");
$sql_obj->prepare_sql_addwhere("id='{$id}'");
$sql_obj->prepare_sql_setlimit("1");
$sql_obj->generate_sql();
$sql_obj->execute();
if ($sql_obj->num_rows()) {
$sql_obj->fetch_array();
if ($sql_obj->data[0]["locked"]) {
// credit note is locked, nothing todo
return 1;
}
/*
Select Invoice Items
*/
$invoice_type = "unknown";
if ($type == "ar_credit") {
$invoice_type = "ar";
} elseif ($type == "ap_credit") {
$invoice_type = "ap";
}
$sql_invoice_obj = new sql_query();
$sql_invoice_obj->string = "SELECT id as itemid, type, customid, chartid, quantity, units, price, amount, description FROM account_items WHERE invoiceid='" . $sql_obj->data[0]["invoiceid"] . "' AND invoicetype='" . $invoice_type . "' AND type!='payment' AND type!='tax'";
$sql_invoice_obj->execute();
if ($sql_invoice_obj->num_rows()) {
$sql_invoice_obj->fetch_array();
}
/*
Create Form
*/
$obj_invoice_form = new form_input();
$obj_invoice_form->formname = $type . "_invoiceselect";
$obj_invoice_form->language = $_SESSION["user"]["lang"];
$obj_invoice_form->action = "index.php";
$obj_invoice_form->method = "GET";
// ID
$structure = NULL;
$structure["fieldname"] = "id";
$structure["type"] = "hidden";
$structure["defaultvalue"] = $id;
$obj_invoice_form->add_input($structure);
$structure = NULL;
$structure["fieldname"] = "page";
$structure["type"] = "hidden";
$structure["defaultvalue"] = $processpage;
$obj_invoice_form->add_input($structure);
// submit
$structure = NULL;
$structure["fieldname"] = "submit";
$structure["type"] = "submit";
$structure["defaultvalue"] = "submit_add_credit_item";
$obj_invoice_form->add_input($structure);
/*
Generate Items Radio Array
*/
if ($sql_invoice_obj->num_rows()) {
$structure = NULL;
$structure["fieldname"] = "invoice_item";
$structure["type"] = "radio";
foreach ($sql_invoice_obj->data as $data_invoice) {
$description = $data_invoice["description"];
switch ($data_invoice["type"]) {
case "standard":
$description = sql_get_singlevalue("SELECT CONCAT_WS('--', code_chart, description) as value FROM account_charts WHERE id='" . $data_invoice["chartid"] . "' LIMIT 1");
break;
case "product":
$description = sql_get_singlevalue("SELECT CONCAT_WS('--', code_product, name_product) as value FROM products WHERE id='" . $data_invoice["customid"] . "' LIMIT 1");
break;
case "service":
case "service_usage":
$description = sql_get_singlevalue("SELECT name_service as value FROM services WHERE id='" . $data_invoice["customid"] . "' LIMIT 1");
break;
default:
$description = "unknown item";
break;
}
$description .= " <i>" . $data_invoice["description"] . "</i>";
$description .= " [" . format_money($data_invoice["amount"]) . " exc tax]";
$structure["values"][] = $data_invoice["itemid"];
$structure["translations"][$data_invoice["itemid"]] = $description;
}
$obj_invoice_form->add_input($structure);
}
/*
Render Form
*/
if ($sql_invoice_obj->num_rows()) {
print "<table width=\"100%\" class=\"table_highlight_info\">";
//.........这里部分代码省略.........
示例4: execute
function execute()
{
/*
Filter selection form
*/
// fetch existing values
$this->date_end = @security_script_input("/^[0-9]*-[0-9]*-[0-9]*\$/", $_GET["date_as_of_yyyy"] . "-" . $_GET["date_as_of_mm"] . "-" . $_GET["date_as_of_dd"]);
$this->mode = @security_script_input("/^\\S*\$/", $_GET["mode"]);
if (!$this->mode) {
if ($_SESSION["account_reports"]["mode"]) {
$this->mode = $_SESSION["account_reports"]["mode"];
} else {
$this->mode = "Accrual/Invoice";
}
}
if (!$this->date_end || $this->date_end == "--") {
if ($_SESSION["account_reports"]["date_end"]) {
$this->date_end = $_SESSION["account_reports"]["date_end"];
} else {
$this->date_end = date("Y-m-d");
}
}
// save to session vars
$_SESSION["account_reports"]["date_end"] = $this->date_end;
$_SESSION["account_reports"]["mode"] = $this->mode;
// define form
$this->obj_form = new form_input();
$this->obj_form->method = "get";
$this->obj_form->action = "index.php";
$this->obj_form->formname = "accounts_report_incomestatement";
$this->obj_form->language = $_SESSION["user"]["lang"];
// hidden values
$structure = NULL;
$structure["fieldname"] = "page";
$structure["type"] = "hidden";
$structure["defaultvalue"] = $_GET["page"];
$this->obj_form->add_input($structure);
// date selection
$structure = NULL;
$structure["fieldname"] = "date_as_of";
$structure["type"] = "date";
$structure["defaultvalue"] = $this->date_end;
$this->obj_form->add_input($structure);
// mode selection
$structure = NULL;
$structure["fieldname"] = "mode";
$structure["type"] = "radio";
$structure["values"] = array("Accrual/Invoice", "Cash");
$structure["defaultvalue"] = $this->mode;
$this->obj_form->add_input($structure);
// submit
$structure = NULL;
$structure["fieldname"] = "submit";
$structure["type"] = "submit";
$structure["defaultvalue"] = "Apply Filter Options";
$this->obj_form->add_input($structure);
/*
Asset Accounts
*/
// chart details
$sql_obj = new sql_query();
$sql_obj->prepare_sql_settable("account_charts");
$sql_obj->prepare_sql_addfield("id");
$sql_obj->prepare_sql_addfield("code_chart");
$sql_obj->prepare_sql_addfield("description");
$sql_obj->prepare_sql_addwhere("chart_type='2'");
$sql_obj->generate_sql();
$sql_obj->execute();
$sql_obj->fetch_array();
$this->data_assets = $sql_obj->data;
unset($sql_obj);
/*
Liability Accounts
*/
// chart details
$sql_obj = new sql_query();
$sql_obj->prepare_sql_settable("account_charts");
$sql_obj->prepare_sql_addfield("id");
$sql_obj->prepare_sql_addfield("code_chart");
$sql_obj->prepare_sql_addfield("description");
$sql_obj->prepare_sql_addwhere("chart_type='3'");
$sql_obj->generate_sql();
$sql_obj->execute();
$sql_obj->fetch_array();
$this->data_liabilities = $sql_obj->data;
unset($sql_obj);
/*
Equitity Accounts
*/
// chart details
$sql_obj = new sql_query();
$sql_obj->prepare_sql_settable("account_charts");
$sql_obj->prepare_sql_addfield("id");
$sql_obj->prepare_sql_addfield("code_chart");
$sql_obj->prepare_sql_addfield("description");
$sql_obj->prepare_sql_addwhere("chart_type='4'");
$sql_obj->generate_sql();
$sql_obj->execute();
$sql_obj->fetch_array();
$this->data_equity = $sql_obj->data;
//.........这里部分代码省略.........
示例5: execute
function execute()
{
log_debug("quote_form_details", "Executing execute()");
if ($this->quoteid) {
$this->mode = "edit";
} else {
$this->mode = "add";
}
/*
Start Form
*/
$this->obj_form = new form_input();
$this->obj_form->formname = "quote_" . $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
$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";
$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["defaultvalue"] = $_SESSION["user"]["default_employeeid"];
$this->obj_form->add_input($structure);
$structure = NULL;
$structure["fieldname"] = "code_quote";
$structure["type"] = "input";
if ($this->mode == "edit") {
$structure["options"]["req"] = "yes";
}
$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_validtill";
$structure["type"] = "date";
$structure["defaultvalue"] = quotes_calc_duedate(date("Y-m-d"));
$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"] = "Save Changes";
$this->obj_form->add_input($structure);
// load data
$this->obj_form->sql_query = "SELECT customerid, employeeid, code_quote, notes, date_trans, date_validtill FROM account_quotes WHERE id='" . $this->quoteid . "'";
$this->obj_form->load_data();
// define subforms
$this->obj_form->subforms["quote_details"] = array("customerid", "employeeid", "code_quote", "date_trans", "date_validtill");
$this->obj_form->subforms["quote_other"] = array("notes");
$this->obj_form->subforms["hidden"] = array("id_quote");
$this->obj_form->subforms["submit"] = array("submit");
}
示例6: execute
function execute()
{
/*
Define form structure
*/
$this->obj_form = new form_input();
$this->obj_form->formname = "timebilled_view";
$this->obj_form->language = $_SESSION["user"]["lang"];
$this->obj_form->action = "projects/timebilled-edit-process.php";
$this->obj_form->method = "post";
// general
$structure = NULL;
$structure["fieldname"] = "name_group";
$structure["type"] = "input";
$structure["options"]["req"] = "yes";
$structure["defaultvalue"] = date("Y-m");
$this->obj_form->add_input($structure);
$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 = form_helper_prepare_dropdownfromdb("customerid", "SELECT id, code_customer as label, name_customer as label1 FROM customers ORDER BY name_customer");
$structure["options"]["req"] = "yes";
$structure["options"]["width"] = "600";
$this->obj_form->add_input($structure);
if ($this->groupid) {
$structure = NULL;
$structure["fieldname"] = "code_invoice";
$structure["type"] = "text";
$this->obj_form->add_input($structure);
}
$structure = NULL;
$structure["fieldname"] = "description";
$structure["type"] = "textarea";
$structure["options"]["width"] = "600";
$structure["options"]["height"] = "60";
$this->obj_form->add_input($structure);
// hidden values
$structure = NULL;
$structure["fieldname"] = "projectid";
$structure["type"] = "hidden";
$structure["defaultvalue"] = $this->id;
$this->obj_form->add_input($structure);
$structure = null;
$structure["fieldname"] = "groupid";
$structure["type"] = "hidden";
$structure["defaultvalue"] = $this->groupid;
$this->obj_form->add_input($structure);
/*
Define checkboxes for all unassigned time entries
*/
$this->obj_sql_entries = new sql_query();
$this->obj_sql_entries->prepare_sql_settable("timereg");
$this->obj_sql_entries->prepare_sql_addfield("id", "timereg.id");
$this->obj_sql_entries->prepare_sql_addfield("date", "timereg.date");
$this->obj_sql_entries->prepare_sql_addfield("name_phase", "project_phases.name_phase");
$this->obj_sql_entries->prepare_sql_addfield("name_staff", "CONCAT_WS(' -- ', staff.staff_code, staff.name_staff)");
$this->obj_sql_entries->prepare_sql_addfield("description", "timereg.description");
$this->obj_sql_entries->prepare_sql_addfield("time_booked", "timereg.time_booked");
$this->obj_sql_entries->prepare_sql_addfield("groupid", "timereg.groupid");
$this->obj_sql_entries->prepare_sql_addfield("billable", "timereg.billable");
$this->obj_sql_entries->prepare_sql_addjoin("LEFT JOIN staff ON timereg.employeeid = staff.id");
$this->obj_sql_entries->prepare_sql_addjoin("LEFT JOIN project_phases ON timereg.phaseid = project_phases.id");
$this->obj_sql_entries->prepare_sql_addwhere("project_phases.projectid='" . $this->id . "'");
if ($this->groupid) {
$this->obj_sql_entries->prepare_sql_addwhere("(groupid='" . $this->groupid . "' OR !groupid)");
} else {
$this->obj_sql_entries->prepare_sql_addwhere("!groupid");
}
if ($this->access_staff_ids) {
$this->obj_sql_entries->prepare_sql_addwhere("timereg.employeeid IN (" . format_arraytocommastring($this->access_staff_ids) . ")");
}
$this->obj_sql_entries->generate_sql();
$this->obj_sql_entries->execute();
if ($this->obj_sql_entries->num_rows()) {
$this->obj_sql_entries->fetch_array();
foreach ($this->obj_sql_entries->data as $data) {
// define the billable check box
$structure = NULL;
$structure["fieldname"] = "time_" . $data["id"] . "_bill";
$structure["type"] = "checkbox";
$structure["options"]["label"] = " ";
if ($data["groupid"] == $this->groupid && $data["billable"] == "1") {
$structure["defaultvalue"] = "on";
}
$this->obj_form->add_input($structure);
// define the nobill check box
$structure = NULL;
$structure["fieldname"] = "time_" . $data["id"] . "_nobill";
$structure["type"] = "checkbox";
$structure["options"]["label"] = " ";
if ($data["groupid"] == $this->groupid && $data["billable"] == "0") {
$structure["defaultvalue"] = "on";
}
$this->obj_form->add_input($structure);
}
//.........这里部分代码省略.........
示例7: execute
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);
//.........这里部分代码省略.........
示例8: invoice_render_summarybox
function invoice_render_summarybox($type, $id)
{
log_debug("inc_invoices", "invoice_render_summarybox({$type}, {$id})");
// fetch invoice information
$sql_obj = new sql_query();
$sql_obj->prepare_sql_settable("account_{$type}");
if ($type == "ar") {
$sql_obj->prepare_sql_addfield("date_sent");
$sql_obj->prepare_sql_addfield("sentmethod");
}
$sql_obj->prepare_sql_addfield("code_invoice");
$sql_obj->prepare_sql_addfield("amount_total");
$sql_obj->prepare_sql_addfield("amount_paid");
$sql_obj->prepare_sql_addwhere("id='{$id}'");
$sql_obj->prepare_sql_setlimit("1");
$sql_obj->generate_sql();
$sql_obj->execute();
if ($sql_obj->num_rows()) {
$sql_obj->fetch_array();
// check for presence of invoice items
$sql_item_obj = new sql_query();
$sql_item_obj->string = "SELECT id FROM account_items WHERE invoicetype='{$type}' AND invoiceid='{$id}' LIMIT 1";
$sql_item_obj->execute();
if (!$sql_item_obj->num_rows()) {
print "<table width=\"100%\" class=\"table_highlight_important\">";
print "<tr>";
print "<td>";
print "<b>Invoice " . $sql_obj->data[0]["code_invoice"] . " has no items on it</b>";
print "<p>This invoice is currently empty, add some items to it using the Invoice Items page.</p>";
print "</td>";
print "</tr>";
print "</table>";
} else {
if ($sql_obj->data[0]["amount_paid"] == $sql_obj->data[0]["amount_total"]) {
print "<table width=\"100%\" class=\"table_highlight_open\">";
print "<tr>";
print "<td>";
print "<b>Invoice " . $sql_obj->data[0]["code_invoice"] . " is closed (fully paid).</b>";
print "<p>This invoice has been fully paid and no further action is required.</p>";
print "</td>";
print "</tr>";
print "</table>";
} else {
print "<table width=\"100%\" class=\"table_highlight_important\">";
print "<tr>";
print "<td>";
print "<b>Invoice " . $sql_obj->data[0]["code_invoice"] . " is open (unpaid).</b>";
print "<table cellpadding=\"4\">";
print "<tr>";
print "<td>Total Due:</td>";
print "<td>" . format_money($sql_obj->data[0]["amount_total"]) . "</td>";
print "</tr>";
print "<tr>";
print "<td>Total Paid:</td>";
print "<td>" . format_money($sql_obj->data[0]["amount_paid"]) . "</td>";
print "</tr>";
$amount_due = $sql_obj->data[0]["amount_total"] - $sql_obj->data[0]["amount_paid"];
print "<tr>";
print "<td>Amount Due:</td>";
print "<td>" . format_money($amount_due) . "</td>";
print "</tr>";
if ($type == "ar") {
print "<tr>";
print "<td>Date Sent:</td>";
if ($sql_obj->data[0]["sentmethod"] == "") {
print "<td><i>Has not been sent to customer</i></td>";
} else {
print "<td>" . $sql_obj->data[0]["date_sent"] . " (" . $sql_obj->data[0]["sentmethod"] . ")</td>";
}
print "</tr>";
}
print "</tr></table>";
print "</td>";
print "</tr>";
print "</table>";
}
}
print "<br>";
}
}
示例9: IN
} else {
$mode = "add";
}
}
/*
Fetch all the information for the time entries.
*/
$sql_entries_obj = new sql_query();
$sql_entries_obj->prepare_sql_settable("timereg");
$sql_entries_obj->prepare_sql_addfield("id", "");
$sql_entries_obj->prepare_sql_addfield("locked", "");
$sql_entries_obj->prepare_sql_addfield("groupid", "");
$sql_entries_obj->prepare_sql_addfield("billable", "");
$sql_entries_obj->prepare_sql_addfield("time_booked", "");
if ($groupid) {
$sql_entries_obj->prepare_sql_addwhere("(groupid='{$groupid}' OR !groupid)");
} else {
$sql_entries_obj->prepare_sql_addwhere("!groupid");
}
// if user has limited employee access, only process time records for those employees
if ($access_staff_ids) {
$sql_entries_obj->prepare_sql_addwhere("employeeid IN (" . format_arraytocommastring($access_staff_ids) . ")");
}
$sql_entries_obj->generate_sql();
$sql_entries_obj->execute();
if ($sql_entries_obj->num_rows()) {
$sql_entries_obj->fetch_array();
foreach ($sql_entries_obj->data as $entries_data) {
// only get the data for selected time entries
if ($_POST["time_" . $entries_data["id"] . "_bill"] == "on") {
$data["time_entries"][$entries_data["id"]]["billable"] = 1;
示例10: execute
function execute()
{
/*
Define form structure
*/
$this->obj_form = new form_input();
$this->obj_form->formname = "orders_view";
$this->obj_form->language = $_SESSION["user"]["lang"];
$this->obj_form->action = "customers/orders-edit-process.php";
$this->obj_form->method = "post";
/*
Define Orders (products-style)
*/
// basic details
$structure = NULL;
$structure["fieldname"] = "date_ordered";
$structure["type"] = "date";
$structure["defaultvalue"] = date("Y-m-d");
$this->obj_form->add_input($structure);
$structure = NULL;
$structure["fieldname"] = "type";
$structure["type"] = "text";
$structure["defaultvalue"] = $this->obj_customer->data_orders["type"];
$this->obj_form->add_input($structure);
$this->obj_form->subforms["order_basic"] = array("date_ordered", "type");
/*
Item Specifics
*/
switch ($this->obj_customer->data_orders["type"]) {
case "product":
// price
$structure = null;
$structure["fieldname"] = "price";
$structure["type"] = "money";
$this->obj_form->add_input($structure);
// quantity
$structure = null;
$structure["fieldname"] = "quantity";
$structure["type"] = "input";
$structure["options"]["width"] = 50;
$this->obj_form->add_input($structure);
// units
$structure = null;
$structure["fieldname"] = "units";
$structure["type"] = "input";
$structure["options"]["width"] = 50;
$structure["options"]["max_length"] = 10;
$this->obj_form->add_input($structure);
// product id
$sql_struct_obj = new sql_query();
$sql_struct_obj->prepare_sql_settable("products");
$sql_struct_obj->prepare_sql_addfield("id", "products.id");
$sql_struct_obj->prepare_sql_addfield("label", "products.code_product");
$sql_struct_obj->prepare_sql_addfield("label1", "products.name_product");
$sql_struct_obj->prepare_sql_addorderby("code_product");
$sql_struct_obj->prepare_sql_addwhere("id = 'currentid' or date_end = '0000-00-00'");
$structure = form_helper_prepare_dropdownfromobj("productid", $sql_struct_obj);
$structure["options"]["search_filter"] = "enabled";
$structure["options"]["width"] = "600";
$this->obj_form->add_input($structure);
// description
$structure = null;
$structure["fieldname"] = "description";
$structure["type"] = "textarea";
$structure["options"]["height"] = "50";
$structure["options"]["width"] = 500;
$this->obj_form->add_input($structure);
// discount
$structure = null;
$structure["fieldname"] = "discount";
$structure["type"] = "input";
$structure["options"]["width"] = 50;
$structure["options"]["label"] = " %";
$structure["options"]["max_length"] = "2";
$this->obj_form->add_input($structure);
// subform
$this->obj_form->subforms["order_product"] = array("productid", "price", "quantity", "units", "description", "discount");
break;
case "service":
// price
$structure = null;
$structure["fieldname"] = "price";
$structure["type"] = "money";
$this->obj_form->add_input($structure);
// discount
$structure = null;
$structure["fieldname"] = "discount";
$structure["type"] = "input";
$structure["options"]["width"] = 50;
$structure["options"]["label"] = " %";
$structure["options"]["max_length"] = "2";
$this->obj_form->add_input($structure);
// service id
$sql_struct_obj = new sql_query();
$sql_struct_obj->prepare_sql_settable("services");
$sql_struct_obj->prepare_sql_addfield("id", "services.id");
$sql_struct_obj->prepare_sql_addfield("label", "services.name_service");
$sql_struct_obj->prepare_sql_addorderby("name_service");
$structure = form_helper_prepare_dropdownfromobj("serviceid", $sql_struct_obj);
$structure["options"]["search_filter"] = "enabled";
//.........这里部分代码省略.........
示例11: execute
//.........这里部分代码省略.........
Product item - selection of a product from the DB, and specify quantity, unit and amount.
*/
/*
PRODUCT
Product item - selection of a product from the DB, and specify quantity, unit and amount.
*/
case "product":
// basic details
$structure = NULL;
$structure["fieldname"] = "price";
$structure["type"] = "money";
$this->obj_form->add_input($structure);
// quantity
$structure = NULL;
$structure["fieldname"] = "quantity";
$structure["type"] = "input";
$structure["options"]["width"] = 50;
$this->obj_form->add_input($structure);
// units
$structure = NULL;
$structure["fieldname"] = "units";
$structure["type"] = "input";
$structure["options"]["width"] = 50;
$structure["options"]["max_length"] = 10;
$this->obj_form->add_input($structure);
// product id
$sql_struct_obj = new sql_query();
$sql_struct_obj->prepare_sql_settable("products");
$sql_struct_obj->prepare_sql_addfield("id", "products.id");
$sql_struct_obj->prepare_sql_addfield("label", "products.code_product");
$sql_struct_obj->prepare_sql_addfield("label1", "products.name_product");
$sql_struct_obj->prepare_sql_addorderby("code_product");
$sql_struct_obj->prepare_sql_addwhere("id = 'CURRENTID' OR date_end = '0000-00-00'");
$structure = form_helper_prepare_dropdownfromobj("productid", $sql_struct_obj);
$structure["options"]["search_filter"] = "enabled";
$structure["options"]["width"] = "600";
$this->obj_form->add_input($structure);
// description
$structure = NULL;
$structure["fieldname"] = "description";
$structure["type"] = "textarea";
$structure["options"]["height"] = "50";
$structure["options"]["width"] = 500;
$this->obj_form->add_input($structure);
// discount
$structure = NULL;
$structure["fieldname"] = "discount";
$structure["type"] = "input";
$structure["options"]["width"] = 50;
$structure["options"]["label"] = " %";
$structure["options"]["max_length"] = "2";
$this->obj_form->add_input($structure);
// define form layout
$this->obj_form->subforms[$this->type . "_invoice_item"] = array("productid", "price", "quantity", "units", "description", "discount");
// fetch data
//
// if the item is new, use the this->item field to fetch the default product details, otherwise
// fetch the details for the existing item
//
if ($this->itemid) {
$this->obj_form->sql_query = "SELECT price, description, customid as productid, quantity, units FROM account_items WHERE id='" . $this->itemid . "'";
} else {
if ($this->type == "ar" || $this->type == "quotes") {
$this->obj_form->sql_query = "SELECT id as productid, price_sale as price, units, details as description FROM products WHERE id='" . $this->productid . "'";
} else {
示例12: execute
function execute()
{
/*
Define form structure
*/
$this->obj_form = new form_input();
$this->obj_form->formname = "credit_refund";
$this->obj_form->language = $_SESSION["user"]["lang"];
$this->obj_form->action = "customers/credit-refund-edit-process.php";
$this->obj_form->method = "post";
// basic details
$structure = NULL;
$structure["fieldname"] = "date_trans";
$structure["type"] = "date";
$structure["defaultvalue"] = date("Y-m-d");
$structure["options"]["req"] = "yes";
$this->obj_form->add_input($structure);
$structure = NULL;
$structure["fieldname"] = "type";
$structure["type"] = "text";
$structure["defaultvalue"] = "refund";
$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("id_employee", $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"] = "description";
$structure["type"] = "textarea";
$structure["defaultvalue"] = "";
$structure["options"]["req"] = "yes";
$structure["options"]["width"] = "600";
$this->obj_form->add_input($structure);
// amount
$structure = NULL;
$structure["fieldname"] = "amount";
$structure["type"] = "money";
$structure["options"]["req"] = "yes";
$this->obj_form->add_input($structure);
$structure = NULL;
$structure = charts_form_prepare_acccountdropdown("account_asset", "ap_payment");
$structure["options"]["search_filter"] = "enabled";
$structure["options"]["autoselect"] = "enabled";
$structure["options"]["width"] = "600";
$structure["options"]["req"] = "yes";
$this->obj_form->add_input($structure);
$structure = NULL;
$structure = charts_form_prepare_acccountdropdown("account_dest", "ar_summary_account");
$structure["options"]["search_filter"] = "enabled";
$structure["options"]["autoselect"] = "enabled";
$structure["options"]["width"] = "600";
$structure["options"]["req"] = "yes";
$this->obj_form->add_input($structure);
// hidden values
$structure = NULL;
$structure["fieldname"] = "id_customer";
$structure["type"] = "hidden";
$structure["defaultvalue"] = $this->obj_customer->id;
$this->obj_form->add_input($structure);
$structure = NULL;
$structure["fieldname"] = "id_refund";
$structure["type"] = "hidden";
$structure["defaultvalue"] = $this->obj_refund->id;
$this->obj_form->add_input($structure);
// submit button
$structure = NULL;
$structure["fieldname"] = "submit";
$structure["type"] = "submit";
$structure["defaultvalue"] = "Save Changes";
$this->obj_form->add_input($structure);
// define base subforms
$this->obj_form->subforms["credit_refund_details"] = array("date_trans", "type", "id_employee", "description");
$this->obj_form->subforms["credit_refund_amount"] = array("amount", "account_asset", "account_dest");
$this->obj_form->subforms["hidden"] = array("id_customer", "id_refund");
$this->obj_form->subforms["submit"] = array("submit");
// fetch the form data if editing
if ($this->obj_refund->id) {
// load existing information
$this->obj_refund->load_data();
$this->obj_form->structure["date_trans"]["defaultvalue"] = $this->obj_refund->data["date_trans"];
$this->obj_form->structure["amount"]["defaultvalue"] = $this->obj_refund->data["amount_total"];
$this->obj_form->structure["id_employee"]["defaultvalue"] = $this->obj_refund->data["id_employee"];
$this->obj_form->structure["description"]["defaultvalue"] = $this->obj_refund->data["description"];
} else {
// set defaults
$this->obj_form->structure["date_trans"]["defaultvalue"] = date("Y-m-d");
$this->obj_form->structure["amount"]["defaultvalue"] = sql_get_singlevalue("SELECT SUM(amount_total) as value FROM customers_credits WHERE id_customer='" . $this->obj_customer->id . "' AND id!='" . $this->obj_refund->id . "'");
}
if (error_check()) {
// load any data returned due to errors
//.........这里部分代码省略.........
示例13: execute
//.........这里部分代码省略.........
if ($sql_tax_obj->num_rows()) {
// user note
$structure = NULL;
$structure["fieldname"] = "tax_message";
$structure["type"] = "message";
$structure["defaultvalue"] = "<p>Check all taxes that apply to this product below.</p>";
$this->obj_form->add_input($structure);
$this->obj_form->subforms["product_tax"][] = "tax_message";
// run through all the taxes
$sql_tax_obj->fetch_array();
foreach ($sql_tax_obj->data as $data_tax) {
// define tax checkbox
$structure = NULL;
$structure["fieldname"] = "tax_" . $data_tax["id"];
$structure["type"] = "checkbox";
$structure["options"]["label"] = $data_tax["name_tax"] . " -- " . $data_tax["description"];
$structure["options"]["no_fieldname"] = "enable";
// see if this tax is currently enabled for this product
if ($this->productid) {
$sql_obj = new sql_query();
$sql_obj->string = "SELECT id FROM products_taxes WHERE productid='" . $this->productid . "' AND taxid='" . $data_tax["id"] . "' LIMIT 1";
$sql_obj->execute();
if ($sql_obj->num_rows()) {
$structure["defaultvalue"] = "on";
}
} else {
if ($data_tax["default_products"]) {
$structure["defaultvalue"] = "on";
}
}
// add to form
$this->obj_form->add_input($structure);
$this->obj_form->subforms["product_tax"][] = "tax_" . $data_tax["id"];
}
}
// quantity
$structure = NULL;
$structure["fieldname"] = "quantity_instock";
$structure["type"] = "input";
$this->obj_form->add_input($structure);
$structure = NULL;
$structure["fieldname"] = "quantity_vendor";
$structure["type"] = "input";
$this->obj_form->add_input($structure);
$this->obj_form->subforms["product_quantity"] = array("quantity_instock", "quantity_vendor");
// supplier details
$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.name_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"]["search_filter"] = "yes";
$this->obj_form->add_input($structure);
$structure = NULL;
$structure["fieldname"] = "code_product_vendor";
$structure["type"] = "input";
$this->obj_form->add_input($structure);
$this->obj_form->subforms["product_supplier"] = array("vendorid", "code_product_vendor");
// define remaining subforms
if (user_permissions_get("products_write")) {
$this->obj_form->subforms["submit"] = array("submit");
} else {
$this->obj_form->subforms["submit"] = array();
}
/*
Mode dependent options
*/
if ($this->mode == "add") {
// submit button
$structure = NULL;
$structure["fieldname"] = "submit";
$structure["type"] = "submit";
$structure["defaultvalue"] = "Create Product";
$this->obj_form->add_input($structure);
} else {
// submit button
$structure = NULL;
$structure["fieldname"] = "submit";
$structure["type"] = "submit";
$structure["defaultvalue"] = "Save Changes";
$this->obj_form->add_input($structure);
// hidden data
$structure = NULL;
$structure["fieldname"] = "id_product";
$structure["type"] = "hidden";
$structure["defaultvalue"] = $this->productid;
$this->obj_form->add_input($structure);
$this->obj_form->subforms["hidden"] = array("id_product");
}
/*
Load Data
*/
if ($this->mode == "add") {
$this->obj_form->load_data_error();
} else {
$this->obj_form->sql_query = "SELECT * FROM `products` WHERE id='" . $this->productid . "' LIMIT 1";
$this->obj_form->load_data();
}
}
示例14: execute
function execute()
{
/*
Check if time entry can be adjusted
*/
if ($this->id) {
$sql_obj = new sql_query();
$sql_obj->string = "SELECT locked, groupid FROM `timereg` WHERE id='" . $this->id . "' LIMIT 1";
$sql_obj->execute();
if ($sql_obj->num_rows()) {
$sql_obj->fetch_array();
$this->locked = $sql_obj->data[0]["locked"];
// so we can tell if the time is locked
$this->groupid = $sql_obj->data[0]["groupid"];
// tells us what group id the time belongs to
}
unset($sql_obj);
}
/*
Input Form
Allows the creation of a new entry for the day, or the adjustment of an existing one.
*/
$this->obj_form = new form_input();
$this->obj_form->formname = "timereg_day";
$this->obj_form->language = $_SESSION["user"]["lang"];
$this->obj_form->action = "timekeeping/timereg-day-edit-process.php";
$this->obj_form->method = "post";
// hidden stuff
$structure = NULL;
$structure["fieldname"] = "id_timereg";
$structure["type"] = "hidden";
$structure["defaultvalue"] = $this->id;
$this->obj_form->add_input($structure);
// employee selection box
$sql_obj = new sql_query();
$sql_obj->prepare_sql_settable("staff");
$sql_obj->prepare_sql_addfield("id", "id");
$sql_obj->prepare_sql_addfield("label", "staff_code");
$sql_obj->prepare_sql_addfield("label1", "name_staff");
if ($this->access_staff_ids_write) {
$sql_obj->prepare_sql_addwhere("id IN (" . format_arraytocommastring($this->access_staff_ids_write) . ")");
}
$sql_obj->generate_sql();
$structure = form_helper_prepare_dropdownfromdb("employeeid", $sql_obj->string);
// if there is currently no employee set, and there is only one
// employee in the selection box, automatically select it and update
// the session variables.
if (!$this->employeeid && count($structure["values"]) == 1) {
$this->employeeid = $structure["values"][0];
$_SESSION["form"]["timereg"]["employeeid"] = $structure["values"][0];
}
$structure["options"]["autoselect"] = "on";
$structure["options"]["width"] = "600";
$structure["options"]["search_filter"] = "yes";
$structure["defaultvalue"] = $this->employeeid;
$this->obj_form->add_input($structure);
// general
$structure = NULL;
$structure["fieldname"] = "date";
$structure["type"] = "date";
$structure["defaultvalue"] = $this->date;
$structure["options"]["req"] = "yes";
$this->obj_form->add_input($structure);
$structure = NULL;
$structure["fieldname"] = "time_booked";
$structure["type"] = "hourmins";
$structure["options"]["req"] = "yes";
$this->obj_form->add_input($structure);
$structure = NULL;
$structure["fieldname"] = "description";
$structure["type"] = "textarea";
$structure["options"]["req"] = "yes";
$structure["options"]["width"] = "600";
$structure["options"]["height"] = "60";
$this->obj_form->add_input($structure);
//project dropdown
$sql_struct_obj = new sql_query();
$sql_struct_obj->prepare_sql_settable("projects");
$sql_struct_obj->prepare_sql_addfield("id", "projects.id");
$sql_struct_obj->prepare_sql_addfield("label", "projects.code_project");
$sql_struct_obj->prepare_sql_addfield("label1", "projects.name_project");
$sql_struct_obj->prepare_sql_addorderby("code_project");
$sql_struct_obj->prepare_sql_addwhere("id = 'CURRENTID' OR date_end = '0000-00-00'");
$structure = form_helper_prepare_dropdownfromobj("projectid", $sql_struct_obj);
$structure["options"]["autoselect"] = "on";
$structure["options"]["width"] = "600";
$structure["options"]["search_filter"] = "yes";
if (count($structure["values"]) == 0) {
$structure["defaultvalue"] = "You need to create a project and add a phase to it in order to be able to book time.";
$_SESSION["error"]["phaseid-error"] = 1;
}
$this->obj_form->add_input($structure);
//phase dropdown
$structure = NULL;
$structure["fieldname"] = "phaseid";
$structure["type"] = "dropdown";
$structure["values"] = array("");
$structure["options"]["width"] = "600";
$structure["options"]["disabled"] = "yes";
//.........这里部分代码省略.........
示例15: execute
function execute()
{
// establish a new table object
$this->obj_table = new table();
$this->obj_table->language = $_SESSION["user"]["lang"];
$this->obj_table->tablename = "timereg_table";
// define all the columns and structure
$this->obj_table->add_column("date", "date", "timereg.date");
$this->obj_table->add_column("standard", "name_phase", "project_phases.name_phase");
$this->obj_table->add_column("standard", "name_staff", "CONCAT_WS(' -- ', staff.staff_code, staff.name_staff)");
$this->obj_table->add_column("standard", "time_group", "time_groups.name_group");
$this->obj_table->add_column("standard", "description", "timereg.description");
$this->obj_table->add_column("hourmins", "time_booked", "timereg.time_booked");
// defaults
$this->obj_table->columns = array("date", "name_phase", "name_staff", "time_group", "description", "time_booked");
$this->obj_table->columns_order = array("date", "name_phase");
$this->obj_table->columns_order_options = array("date", "name_phase", "name_staff", "time_group", "description", "time_booked");
// define SQL structure
$this->obj_table->sql_obj->prepare_sql_settable("timereg");
$this->obj_table->sql_obj->prepare_sql_addfield("id", "timereg.id");
$this->obj_table->sql_obj->prepare_sql_addfield("employeeid", "timereg.employeeid");
$this->obj_table->sql_obj->prepare_sql_addjoin("LEFT JOIN staff ON timereg.employeeid = staff.id");
$this->obj_table->sql_obj->prepare_sql_addjoin("LEFT JOIN time_groups ON timereg.groupid = time_groups.id");
$this->obj_table->sql_obj->prepare_sql_addjoin("LEFT JOIN project_phases ON timereg.phaseid = project_phases.id");
$this->obj_table->sql_obj->prepare_sql_addjoin("LEFT JOIN projects ON project_phases.projectid = projects.id");
$this->obj_table->sql_obj->prepare_sql_addwhere("projects.id = '" . $this->id . "'");
if ($this->access_staff_ids) {
$this->obj_table->sql_obj->prepare_sql_addwhere("timereg.employeeid IN (" . format_arraytocommastring($this->access_staff_ids) . ")");
}
/// Filtering/Display Options
// fixed options
$this->obj_table->add_fixed_option("id", $this->id);
// acceptable filter options
$structure = NULL;
$structure["fieldname"] = "date_start";
$structure["type"] = "date";
$structure["sql"] = "date >= 'value'";
$this->obj_table->add_filter($structure);
$structure = NULL;
$structure["fieldname"] = "date_end";
$structure["type"] = "date";
$structure["sql"] = "date <= 'value'";
$this->obj_table->add_filter($structure);
$structure = form_helper_prepare_dropdownfromdb("phaseid", "SELECT id, name_phase as label FROM project_phases WHERE projectid='" . $this->id . "' ORDER BY name_phase ASC");
$structure["sql"] = "project_phases.id='value'";
$structure["options"]["search_filter"] = "yes";
$this->obj_table->add_filter($structure);
$sql_obj = new sql_query();
$sql_obj->prepare_sql_settable("staff");
$sql_obj->prepare_sql_addfield("id", "id");
$sql_obj->prepare_sql_addfield("label", "staff_code");
$sql_obj->prepare_sql_addfield("label1", "name_staff");
if ($this->access_staff_ids) {
$sql_obj->prepare_sql_addwhere("id IN (" . format_arraytocommastring($this->access_staff_ids) . ")");
}
$sql_obj->generate_sql();
$structure = form_helper_prepare_dropdownfromdb("employeeid", $sql_obj->string);
$structure["sql"] = "timereg.employeeid='value'";
$structure["options"]["search_filter"] = "yes";
$this->obj_table->add_filter($structure);
$structure = NULL;
$structure["fieldname"] = "no_group";
$structure["type"] = "checkbox";
$structure["sql"] = "groupid='0'";
$structure["options"]["label"] = "Only show unprocessed time";
$this->obj_table->add_filter($structure);
$structure = NULL;
$structure["fieldname"] = "searchbox";
$structure["type"] = "input";
$structure["sql"] = "(timereg.description LIKE '%value%' OR project_phases.name_phase LIKE '%value%' OR staff.name_staff LIKE '%value%')";
$this->obj_table->add_filter($structure);
// create totals
$this->obj_table->total_columns = array("time_booked");
// load options form
$this->obj_table->load_options_form();
// generate & execute SQL query
$this->obj_table->generate_sql();
$this->obj_table->load_data_sql();
}