function check_requirements() { // verify that the service exists $sql_obj = new sql_query(); $sql_obj->string = "SELECT id, id_rate_table FROM services WHERE id='" . $this->id . "' LIMIT 1"; $sql_obj->execute(); if ($sql_obj->num_rows()) { $sql_obj->fetch_array(); // verify the rate is valid if ($sql_obj->data[0]["id_rate_table"]) { $this->obj_cdr_rate_table->id = $sql_obj->data[0]["id_rate_table"]; if (!$this->obj_cdr_rate_table->verify_id()) { log_write("error", "page_output", "The requested CDR rate table is invalid, there may be some problems with the information in the database."); return 0; } } else { log_write("error", "page_output", "You have yet to set a CDR Rate Table for this service to use - please do so using the plan page before attempting to override the rates"); return 0; } } else { log_write("error", "page_output", "The requested service (" . $this->id . ") does not exist - possibly the service has been deleted."); return 0; } unset($sql_obj); // verify that this is a phone service if ($this->service_type != ("phone_single" || "phone_trunk" || "phone_tollfree")) { log_write("error", "page_output", "The requested service is not a phone service."); return 0; } return 1; }
function check_requirements() { // verify that the invoice exists $sql_obj = new sql_query(); $sql_obj->string = "SELECT id FROM account_ar WHERE id='" . $this->id . "' LIMIT 1"; $sql_obj->execute(); if (!$sql_obj->num_rows()) { log_write("error", "page_output", "The requested invoice (" . $this->id . ") does not exist - possibly the invoice has been deleted."); return 0; } unset($sql_obj); // verify that the item id supplied exists and fetch required information if ($this->itemid) { $sql_obj = new sql_query(); $sql_obj->string = "SELECT id, type FROM account_items WHERE id='" . $this->itemid . "' AND invoiceid='" . $this->id . "' LIMIT 1"; $sql_obj->execute(); if (!$sql_obj->num_rows()) { log_write("error", "page_output", "The requested payment/invoice combination does not exist. Are you trying to use a link to a deleted payment?"); return 0; } else { $sql_obj->fetch_array(); $this->item_type = $sql_obj->data[0]["type"]; } } return 1; }
function list_taxes() { log_debug("accounts_taxes_manage_soap", "Executing list_taxes()"); if (user_permissions_get("accounts_taxes_view")) { // fetch taxes $sql_obj = new sql_query(); $sql_obj->string = "SELECT id, name_tax, taxrate, chartid, taxnumber, description FROM account_taxes"; $sql_obj->execute(); $return = NULL; if ($sql_obj->num_rows()) { $sql_obj->fetch_array(); // package data into array for passing back to SOAP client foreach ($sql_obj->data as $data) { $return_tmp = NULL; $return_tmp["id"] = $data["id"]; $return_tmp["name_tax"] = $data["name_tax"]; $return_tmp["taxrate"] = $data["taxrate"]; $return_tmp["chartid"] = $data["chartid"]; $return_tmp["chartid_label"] = sql_get_singlevalue("SELECT CONCAT_WS('--', code_chart, description) as value FROM account_charts WHERE id='" . $data["chartid"] . "'"); $return_tmp["taxnumber"] = $data["taxnumber"]; $return_tmp["description"] = $data["description"]; $return[] = $return_tmp; } } return $return; } else { throw new SoapFault("Sender", "ACCESS_DENIED"); } }
function check_requirements() { // verify that project exists $sql_obj = new sql_query(); $sql_obj->string = "SELECT id FROM projects WHERE id='" . $this->id . "' LIMIT 1"; $sql_obj->execute(); if (!$sql_obj->num_rows()) { log_write("error", "page_output", "The requested project (" . $this->id . ") does not exist - possibly the project has been deleted."); return 0; } unset($sql_obj); // verify that the time group exists and belongs to this project if ($this->groupid) { $sql_obj = new sql_query(); $sql_obj->string = "SELECT projectid, locked FROM time_groups WHERE id='" . $this->groupid . "' LIMIT 1"; $sql_obj->execute(); if (!$sql_obj->num_rows()) { log_write("error", "page_output", "The requested time group (" . $this->groupid . ") does not exist - possibly the time group has been deleted."); return 0; } else { $sql_obj->fetch_array(); $this->locked = $sql_obj->data[0]["locked"]; if ($sql_obj->data[0]["projectid"] != $this->id) { log_write("error", "page_output", "The requested time group (" . $this->groupid . ") does not belong to the selected project (" . $this->id . ")"); return 0; } } unset($sql_obj); } return 1; }
function execute() { /* Define form structure */ $this->obj_form = new form_input(); $this->obj_form->formname = "users_permissions_staff"; $this->obj_form->language = $_SESSION["user"]["lang"]; $this->obj_form->action = "user/user-staffaccess-edit-process.php"; $this->obj_form->method = "post"; // run through all the avaliable permissions $sql_perms_obj = new sql_query(); $sql_perms_obj->string = "SELECT * FROM `permissions_staff`"; $sql_perms_obj->execute(); if ($sql_perms_obj->num_rows()) { $sql_perms_obj->fetch_array(); foreach ($sql_perms_obj->data as $data_perms) { // define the checkbox $structure = NULL; $structure["fieldname"] = $data_perms["value"]; $structure["type"] = "checkbox"; $structure["options"]["label"] = $data_perms["description"]; // check the database to see if this checkbox is selected $sql_obj = new sql_query(); $sql_obj->string = "SELECT " . "id " . "FROM `users_permissions_staff` " . "WHERE " . "userid='" . $this->id . "' " . "AND permid='" . $data_perms["id"] . "' " . "AND staffid='" . $this->staffid . "'"; $sql_obj->execute(); if ($sql_obj->num_rows()) { $structure["defaultvalue"] = "on"; } // add checkbox $this->obj_form->add_input($structure); // add checkbox to subforms $this->obj_form->subforms["user_permissions_staff"][] = $data_perms["value"]; } } // hidden fields $structure = NULL; $structure["fieldname"] = "id_user"; $structure["type"] = "hidden"; $structure["defaultvalue"] = $this->id; $this->obj_form->add_input($structure); $structure = NULL; $structure["fieldname"] = "id_staff"; $structure["type"] = "hidden"; $structure["defaultvalue"] = $this->staffid; $this->obj_form->add_input($structure); // submit section $structure = NULL; $structure["fieldname"] = "submit"; $structure["type"] = "submit"; $structure["defaultvalue"] = "Save Changes"; $this->obj_form->add_input($structure); // define subforms $this->obj_form->subforms["hidden"] = array("id_user", "id_staff"); $this->obj_form->subforms["submit"] = array("submit"); /* Note: We don't load from error data, since there should never be any errors when using this form. */ }
function quotes_render_summarybox($id) { log_debug("inc_quotes", "quotes_render_summarybox({$id})"); // fetch quote information $sql_obj = new sql_query(); $sql_obj->string = "SELECT code_quote, amount_total, date_validtill, date_sent, sentmethod FROM account_quotes WHERE id='{$id}' LIMIT 1"; $sql_obj->execute(); if ($sql_obj->num_rows()) { $sql_obj->fetch_array(); if ($sql_obj->data[0]["amount_total"] == 0) { print "<table width=\"100%\" class=\"table_highlight_important\">"; print "<tr>"; print "<td>"; print "<b>Quote " . $sql_obj->data[0]["code_quote"] . " has no items on it</b>"; print "<p>This quote needs to have some items added to it using the links in the nav menu above.</p>"; print "</td>"; print "</tr>"; print "</table>"; } else { if (time_date_to_timestamp($sql_obj->data[0]["date_validtill"]) <= time()) { print "<table width=\"100%\" class=\"table_highlight_important\">"; print "<tr>"; print "<td>"; print "<p><b>Quote " . $sql_obj->data[0]["code_quote"] . " has now expired and is no longer valid.</b></p>"; print "</td>"; print "</tr>"; print "</table>"; } else { print "<table width=\"100%\" class=\"table_highlight_important\">"; print "<tr>"; print "<td>"; print "<b>Quote " . $sql_obj->data[0]["code_quote"] . " is currently valid.</b>"; print "<table cellpadding=\"4\">"; print "<tr>"; print "<td>Quote Total:</td>"; print "<td>" . format_money($sql_obj->data[0]["amount_total"]) . "</td>"; print "</tr>"; print "<tr>"; print "<td>Valid Until:</td>"; print "<td>" . $sql_obj->data[0]["date_validtill"] . "</td>"; print "</tr>"; 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>"; } }
function execute() { /* Define form structure */ $this->obj_form = new form_input(); $this->obj_form->formname = "users_permissions_staff"; $this->obj_form->language = $_SESSION["user"]["lang"]; $this->obj_form->action = "user/user-staffaccess-edit-process.php"; $this->obj_form->method = "post"; // staff member dropdown $structure = form_helper_prepare_dropdownfromdb("id_staff", "SELECT id, staff_code as label, name_staff as label1 FROM `staff` ORDER BY name_staff"); $this->obj_form->add_input($structure); $this->obj_form->subforms["user_permissions_selectstaff"] = array("id_staff"); /* Permissions sub-form */ // run through all the avaliable permissions $sql_perms_obj = new sql_query(); $sql_perms_obj->string = "SELECT * FROM `permissions_staff`"; $sql_perms_obj->execute(); if ($sql_perms_obj->num_rows()) { $sql_perms_obj->fetch_array(); foreach ($sql_perms_obj->data as $data_perms) { // define the checkbox $structure = NULL; $structure["fieldname"] = $data_perms["value"]; $structure["type"] = "checkbox"; $structure["options"]["label"] = $data_perms["description"]; // add checkbox $this->obj_form->add_input($structure); // add checkbox to subforms $this->obj_form->subforms["user_permissions_staff"][] = $data_perms["value"]; } } // hidden fields $structure = NULL; $structure["fieldname"] = "id_user"; $structure["type"] = "hidden"; $structure["defaultvalue"] = $this->id; $this->obj_form->add_input($structure); // submit section $structure = NULL; $structure["fieldname"] = "submit"; $structure["type"] = "submit"; $structure["defaultvalue"] = "Save Changes"; $this->obj_form->add_input($structure); // define subforms $this->obj_form->subforms["hidden"] = array("id_user"); $this->obj_form->subforms["submit"] = array("submit"); /* Note: We don't load from error data, since there should never be any errors when using this form. */ }
function execute() { /* Define form structure */ $this->obj_form = new form_input(); $this->obj_form->formname = "user_permissions"; $this->obj_form->language = $_SESSION["user"]["lang"]; $this->obj_form->action = "user/user-permissions-process.php"; $this->obj_form->method = "post"; $sql_perms_obj = new sql_query(); $sql_perms_obj->string = "SELECT * FROM `permissions` ORDER BY value='disabled' DESC, value='admin' DESC, value"; $sql_perms_obj->execute(); $sql_perms_obj->fetch_array(); foreach ($sql_perms_obj->data as $data_perms) { // define the checkbox $structure = NULL; $structure["fieldname"] = $data_perms["value"]; $structure["type"] = "checkbox"; $structure["options"]["label"] = $data_perms["description"]; $structure["options"]["no_translate_fieldname"] = "yes"; // check if the user has this permission $sql_obj = new sql_query(); $sql_obj->string = "SELECT id FROM `users_permissions` WHERE userid='" . $this->id . "' AND permid='" . $data_perms["id"] . "'"; $sql_obj->execute(); if ($sql_obj->num_rows()) { $structure["defaultvalue"] = "on"; } // add checkbox $this->obj_form->add_input($structure); // add checkbox to subforms $this->obj_form->subforms["user_permissions"][] = $data_perms["value"]; } // user ID (hidden field) $structure = NULL; $structure["fieldname"] = "id_user"; $structure["type"] = "hidden"; $structure["defaultvalue"] = $this->id; $this->obj_form->add_input($structure); // submit section $structure = NULL; $structure["fieldname"] = "submit"; $structure["type"] = "submit"; $structure["defaultvalue"] = "Save Changes"; $this->obj_form->add_input($structure); // define subforms $this->obj_form->subforms["hidden"] = array("id_user"); $this->obj_form->subforms["submit"] = array("submit"); /* Note: We don't load from error data, since there should never be any errors when using this form. */ }
function execute() { // make sure tax does not belong to any invoices $sql_obj = new sql_query(); $sql_obj->string = "SELECT id FROM account_items WHERE type='tax' AND customid='" . $this->id . "'"; $sql_obj->execute(); if ($sql_obj->num_rows()) { $this->locked = 1; } /* Define form structure */ $this->obj_form = new form_input(); $this->obj_form->formname = "tax_delete"; $this->obj_form->language = $_SESSION["user"]["lang"]; $this->obj_form->action = "accounts/taxes/delete-process.php"; $this->obj_form->method = "post"; // general $structure = NULL; $structure["fieldname"] = "name_tax"; $structure["type"] = "text"; $this->obj_form->add_input($structure); // hidden $structure = NULL; $structure["fieldname"] = "id_tax"; $structure["type"] = "hidden"; $structure["defaultvalue"] = $this->id; $this->obj_form->add_input($structure); // confirm delete $structure = NULL; $structure["fieldname"] = "delete_confirm"; $structure["type"] = "checkbox"; $structure["options"]["label"] = "Yes, I wish to delete this tax and realise that once deleted the data can not be recovered."; $this->obj_form->add_input($structure); // define submit field $structure = NULL; $structure["fieldname"] = "submit"; $structure["type"] = "submit"; $structure["defaultvalue"] = "delete"; $this->obj_form->add_input($structure); // define subforms $this->obj_form->subforms["tax_delete"] = array("name_tax"); $this->obj_form->subforms["hidden"] = array("id_tax"); if ($this->locked) { $this->obj_form->subforms["submit"] = array(); } else { $this->obj_form->subforms["submit"] = array("delete_confirm", "submit"); } // fetch the form data $this->obj_form->sql_query = "SELECT name_tax FROM `account_taxes` WHERE id='" . $this->id . "' LIMIT 1"; $this->obj_form->load_data(); }
function check_requirements() { // verify that the quote exists $sql_obj = new sql_query(); $sql_obj->string = "SELECT id FROM account_quotes WHERE id='" . $this->id . "' LIMIT 1"; $sql_obj->execute(); if (!$sql_obj->num_rows()) { log_write("error", "page_output", "The requested quote (" . $this->id . ") does not exist - possibly the quote has been deleted or converted into an invoice."); return 0; } unset($sql_obj); return 1; }
function check_requirements() { // verify that the product exists $sql_obj = new sql_query(); $sql_obj->string = "SELECT id FROM products WHERE id='" . $this->id . "' LIMIT 1"; $sql_obj->execute(); if (!$sql_obj->num_rows()) { log_write("error", "page_output", "The requested product (" . $this->id . ") does not exist - possibly the product has been deleted."); return 0; } unset($sql_obj); return 1; }
function execute() { /* Fetch period data */ $sql_period_obj = new sql_query(); $sql_period_obj->string = "SELECT date_start, date_end FROM services_customers_periods WHERE id='" . $this->id_service_period . "' LIMIT 1"; $sql_period_obj->execute(); $sql_period_obj->fetch_array(); /* Fetch call charges for this period into table. */ // establish a new table object $this->obj_table = new table(); $this->obj_table->language = $_SESSION["user"]["lang"]; $this->obj_table->tablename = "service_history_cdr"; // define all the columns and structure $this->obj_table->add_column("date", "date", ""); $this->obj_table->add_column("standard", "rate_billgroup", "cdr_rate_billgroups.billgroup_name"); $this->obj_table->add_column("standard", "number_src", "usage1"); $this->obj_table->add_column("standard", "number_dst", "usage2"); $this->obj_table->add_column("standard", "billable_seconds", "usage3"); $this->obj_table->add_column("money_float", "price", ""); // defaults $this->obj_table->columns = array("date", "rate_billgroup", "number_src", "number_dst", "billable_seconds", "price"); $this->obj_table->columns_order = array("date", "rate_billgroup", "number_src", "number_dst"); // totals $this->obj_table->total_columns = array("billable_seconds", "price"); // define SQL structure $this->obj_table->sql_obj->prepare_sql_settable("service_usage_records"); $this->obj_table->sql_obj->prepare_sql_addjoin("LEFT JOIN cdr_rate_billgroups ON cdr_rate_billgroups.id = service_usage_records.billgroup"); $this->obj_table->sql_obj->prepare_sql_addfield("id", "service_usage_records.id"); $this->obj_table->sql_obj->prepare_sql_addwhere("id_service_customer = '" . $this->obj_customer->id_service_customer . "'"); $this->obj_table->sql_obj->prepare_sql_addwhere("date >= '" . $sql_period_obj->data[0]["date_start"] . "'"); $this->obj_table->sql_obj->prepare_sql_addwhere("date <= '" . $sql_period_obj->data[0]["date_end"] . "'"); // acceptable filter options $structure = NULL; $structure["fieldname"] = "searchbox"; $structure["type"] = "input"; $structure["sql"] = "(number_src LIKE '%value%' OR number_dst LIKE '%value%')"; $this->obj_table->add_filter($structure); $this->obj_table->add_fixed_option("id_customer", $this->obj_customer->id); $this->obj_table->add_fixed_option("id_service_customer", $this->obj_customer->id_service_customer); $this->obj_table->add_fixed_option("id_service_period", $this->id_service_period); // load settings from options form $this->obj_table->load_options_form(); // run SQL query $this->obj_table->generate_sql(); $this->obj_table->load_data_sql(); }
function check_requirements() { // verify that the account exists $sql_obj = new sql_query(); $sql_obj->string = "SELECT id, locked FROM account_gl WHERE id='" . $this->id . "' LIMIT 1"; $sql_obj->execute(); if (!$sql_obj->num_rows()) { log_write("error", "page_output", "The requested transaction (" . $this->id . ") does not exist - possibly the transaction has been deleted."); return 0; } else { $sql_obj->fetch_array(); $this->locked = $sql_obj->data[0]["locked"]; } unset($sql_obj); return 1; }
function check_requirements() { // verify that the service exists $sql_obj = new sql_query(); $sql_obj->string = "SELECT id FROM services WHERE id='" . $this->id . "' LIMIT 1"; $sql_obj->execute(); if (!$sql_obj->num_rows()) { log_write("error", "page_output", "The requested service (" . $this->id . ") does not exist - possibly the service has been deleted."); return 0; } unset($sql_obj); // verify that this is a bundle service if ($this->service_type != "bundle") { log_write("error", "page_output", "The requested service is not a bundle service."); return 0; } return 1; }
function config_generate_uniqueid($config_name, $check_sql) { log_debug("inc_misc", "Executing config_generate_uniqueid({$config_name})"); $config_name = strtoupper($config_name); $returnvalue = 0; $uniqueid = 0; // fetch the starting ID from the config DB $uniqueid = sql_get_singlevalue("SELECT value FROM config WHERE name='{$config_name}'"); if (!$uniqueid) { die("Unable to fetch {$config_name} value from config database"); } // first set the uniqueid prefix to an empty string, in case the following tests fail $uniqueid_prefix = ''; if (!is_numeric($uniqueid)) { preg_match("/^(\\S*?)([0-9]*)\$/", $uniqueid, $matches); $uniqueid_prefix = $matches[1]; $uniqueid = (int) $matches[2]; } if ($check_sql) { // we will use the supplied SQL query to make sure this value is not currently used while ($returnvalue == 0) { $sql_obj = new sql_query(); $sql_obj->string = str_replace("VALUE", $uniqueid_prefix . $uniqueid, $check_sql); $sql_obj->execute(); if ($sql_obj->num_rows()) { // the ID has already been used, try incrementing $uniqueid++; } else { // found an avaliable ID $returnvalue = $uniqueid; } } $returnvalue = $uniqueid_prefix . $returnvalue; } else { // conducting no DB checks. $returnvalue = $uniqueid_prefix . $uniqueid; } // update the DB with the new value + 1 $uniqueid++; $sql_obj = new sql_query(); $sql_obj->string = "UPDATE config SET value='{$uniqueid_prefix}{$uniqueid}' WHERE name='{$config_name}'"; $sql_obj->execute(); return $returnvalue; }
function set_usage_record($collector, $id_service_customer, $date, $usage1, $usage2 = NULL) { log_debug("services_usage", "Executing set_usage_record"); if (user_permissions_get("services_write_usage")) { // sanitise input $data["collector"] = @security_script_input_predefined("any", $collector); $data["id_service_customer"] = @security_script_input_predefined("int", $id_service_customer); $data["date"] = @security_script_input_predefined("date", $date); $data["usage1"] = @security_script_input_predefined("int", $usage1); $data["usage2"] = @security_script_input_predefined("int", $usage2); foreach (array_keys($data) as $key) { if ($data[$key] == "error") { throw new SoapFault("Sender", "INVALID_INPUT"); } } /* Verify that id_service_customer exists - this may seem unnessacary, but should be done to prevent data being inserted to IDs that don't yet belong - but may do in future. Would be nasty to have a lot of data sitting in the table waiting for a new customer to appear whom the ID matches too. Of course, this check does nothing to prevent data for one customer being accidently filed against another customer due to an incorrect ID. */ $sql_obj = new sql_query(); $sql_obj->string = "SELECT id FROM services_customers WHERE id='" . $data["id_service_customer"] . "' LIMIT 1"; $sql_obj->execute(); if (!$sql_obj->num_rows()) { throw new SoapFault("Sender", "INVALID_SERVICES_CUSTOMERS_ID"); } unset($sql_obj); // add new row to DB $sql_obj = new sql_query(); $sql_obj->string = "INSERT INTO service_usage_records (" . "id_service_customer, " . "date, " . "usage1, " . "usage2" . ") VALUES (" . "'" . $data["id_service_customer"] . "', " . "'" . $data["date"] . "', " . "'" . $data["usage1"] . "', " . "'" . $data["usage2"] . "'" . ")"; if (!$sql_obj->execute()) { throw new SoapFault("Sender", "UNEXPECTED_DB_ERROR"); } return 1; } else { throw new SoapFault("Sender", "ACCESS_DENIED"); } }
function execute() { /* Fetch period data */ $sql_period_obj = new sql_query(); $sql_period_obj->string = "SELECT date_start, date_end FROM services_customers_periods WHERE id='" . $this->id_service_period . "' LIMIT 1"; $sql_period_obj->execute(); $sql_period_obj->fetch_array(); /* Generate CSV CDR Output */ $options = array('id_customer' => $this->obj_customer->id, 'id_service_customer' => $this->obj_customer->id_service_customer, 'period_start' => $sql_period_obj->data[0]["date_start"], 'period_end' => $sql_period_obj->data[0]["date_end"]); $csv = new cdr_csv($options); if (!($this->output = $csv->getCSV())) { log_write("error", "page_output", "Unable to generate CSV ouput for the configured range"); return 0; } return 1; }
function execute() { /* Define form structure */ $this->obj_form = new form_input(); $this->obj_form->formname = "config_integration"; $this->obj_form->language = $_SESSION["user"]["lang"]; $this->obj_form->action = "admin/config_integration-process.php"; $this->obj_form->method = "post"; // customer portal stuff $structure = NULL; $structure["fieldname"] = "MODULE_CUSTOMER_PORTAL"; $structure["type"] = "checkbox"; $structure["options"]["no_translate_fieldname"] = "yes"; $structure["options"]["label"] = "Enable/disable the customer portal integration."; $this->obj_form->add_input($structure); // submit section $structure = NULL; $structure["fieldname"] = "submit"; $structure["type"] = "submit"; $structure["defaultvalue"] = "Save Changes"; $this->obj_form->add_input($structure); // define subforms $this->obj_form->subforms["config_integration"] = array("MODULE_CUSTOMER_PORTAL"); $this->obj_form->subforms["submit"] = array("submit"); if (error_check()) { // load error datas $this->obj_form->load_data_error(); } else { // fetch all the values from the database $sql_config_obj = new sql_query(); $sql_config_obj->string = "SELECT name, value FROM config ORDER BY name"; $sql_config_obj->execute(); $sql_config_obj->fetch_array(); foreach ($sql_config_obj->data as $data_config) { $this->obj_form->structure[$data_config["name"]]["defaultvalue"] = $data_config["value"]; } unset($sql_config_obj); } }
function render_html() { // Title + Summary print "<h3>DATABASE BACKUP</h3><br>"; print "<p>This page allows an administrator to perform an export of the entire MySQL database and download it as a file. This feature\n\t\t\tensures that no matter who runs your instance of the Amberdms Billing System, your data can always be retrieved.</p>"; print "<p>The file generated is a standard SQL file compressed with gzip, it can be easily restored using the MySQL command line or\n\t\t\tvia a utility such as phpmyadmin.</p>"; // report on usage $sql_obj = new sql_query(); $usage = $sql_obj->stats_diskusage(); format_msgbox("info", "<p>Estimated download size: " . format_size_human($usage) . " (before compression)</p>"); // run check for file-system based journal files $sql_obj = new sql_query(); $sql_obj->string = "SELECT id FROM file_uploads WHERE file_location != 'db' LIMIT 1"; $sql_obj->execute(); if ($sql_obj->num_rows()) { format_msgbox("important", "<p>Some of the files stored in the journal have been saved to the filesystem rather than the MySQL database. This backup will provide a copy of the database, but you will also need to download the contents of the data/ directory.</p>"); } // export link print "<br>"; print "<a class=\"button\" href=\"admin/db_backup-process.php\">Export Database</a>"; }
function get_gl_trans($id) { log_debug("gl_manage_soap", "Executing get_gl_trans()"); if (user_permissions_get("accounts_gl_view")) { $obj_gl = new gl_transaction(); // sanitise input $obj_gl->id = @security_script_input_predefined("int", $id); if (!$obj_gl->id || $obj_gl->id == "error") { throw new SoapFault("Sender", "INVALID_INPUT"); } // verify that the ID is valid if (!$obj_gl->verify_id()) { throw new SoapFault("Sender", "INVALID_ID"); } // fetch list of all transactions $sql_obj = new sql_query(); $sql_obj->string = "SELECT id, amount_debit, amount_credit, chartid, source, memo FROM `account_trans` WHERE type='gl' AND customid='" . $obj_gl->id . "'"; $sql_obj->execute(); // package up for sending to the client $return = NULL; if ($sql_obj->num_rows()) { $sql_obj->fetch_array(); foreach ($sql_obj->data as $data) { $return_tmp = NULL; $return_tmp["id"] = $data["id"]; $return_tmp["chartid"] = $data["chartid"]; $return_tmp["chartid_label"] = sql_get_singlevalue("SELECT CONCAT_WS('--', code_chart, description) as value FROM account_charts WHERE id='" . $data["chartid"] . "'"); $return_tmp["debit"] = $data["amount_debit"]; $return_tmp["credit"] = $data["amount_credit"]; $return_tmp["source"] = $data["source"]; $return_tmp["description"] = $data["memo"]; $return[] = $return_tmp; } } return $return; } else { throw new SoapFault("Sender", "ACCESS_DENIED"); } }
*/ // includes require "../../include/config.php"; require "../../include/amberphplib/main.php"; if (user_permissions_get('accounts_quotes_write')) { ///////////////////////// // start the journal processing $journal = new journal_process(); $journal->prepare_set_journalname("account_quotes"); // import form data $journal->process_form_input(); //// ERROR CHECKING /////////////////////// // make sure the quote ID submitted really exists $sql_obj = new sql_query(); $sql_obj->string = "SELECT id FROM account_quotes WHERE id='" . $journal->structure["customid"] . "'"; $sql_obj->execute(); if (!$sql_obj->num_rows()) { $_SESSION["error"]["message"][] = "Unable to find requested quote/transaction to modify journal for."; } /// if there was an error, go back to the entry page if ($_SESSION["error"]["message"]) { $_SESSION["error"]["form"]["journal_edit"] = "failed"; header("Location: ../../index.php?page=accounts/quotes/journal.php&id=" . $journal->structure["customid"] . "&journalid=" . $journal->structure["id"] . "&action=" . $journal->structure["action"] . ""); exit(0); } else { if ($journal->structure["action"] == "delete") { $journal->action_delete(); } else { // update or create $journal->action_update(); }
function execute() { /* Check if the project can be deleted or not */ // see if any time has been booked to any of the phases $sql_obj = new sql_query(); $sql_obj->string = "SELECT id FROM project_phases WHERE projectid='" . $this->id . "'"; $sql_obj->execute(); if ($sql_obj->num_rows()) { $sql_obj->fetch_array(); foreach ($sql_obj->data as $phase_data) { $sql_phase_obj = new sql_query(); $sql_phase_obj->string = "SELECT id FROM timereg WHERE phaseid='" . $phase_data["id"] . "' LIMIT 1"; $sql_phase_obj->execute(); if ($sql_phase_obj->num_rows()) { $this->locked = 1; } } } /* Define form structure */ $this->obj_form = new form_input(); $this->obj_form->formname = "project_delete"; $this->obj_form->language = $_SESSION["user"]["lang"]; $this->obj_form->action = "projects/delete-process.php"; $this->obj_form->method = "post"; // general $structure = NULL; $structure["fieldname"] = "name_project"; $structure["type"] = "text"; $this->obj_form->add_input($structure); $structure = NULL; $structure["fieldname"] = "code_project"; $structure["type"] = "text"; $this->obj_form->add_input($structure); // hidden $structure = NULL; $structure["fieldname"] = "id_project"; $structure["type"] = "hidden"; $structure["defaultvalue"] = $this->id; $this->obj_form->add_input($structure); // confirm delete $structure = NULL; $structure["fieldname"] = "delete_confirm"; $structure["type"] = "checkbox"; $structure["options"]["label"] = "Yes, I wish to delete this project and realise that once deleted the data can not be recovered."; $this->obj_form->add_input($structure); // submit button $structure = NULL; $structure["fieldname"] = "submit"; $structure["type"] = "submit"; $structure["defaultvalue"] = "delete"; $this->obj_form->add_input($structure); // define subforms $this->obj_form->subforms["project_delete"] = array("code_project", "name_project"); $this->obj_form->subforms["hidden"] = array("id_project"); if ($this->locked) { $this->obj_form->subforms["submit"] = array(); } else { $this->obj_form->subforms["submit"] = array("delete_confirm", "submit"); } // fetch the form data $this->obj_form->sql_query = "SELECT * FROM `projects` WHERE id='" . $this->id . "' LIMIT 1"; $this->obj_form->load_data(); }
} else { $_SESSION["error"] = array(); // start SQL transaction $sql_obj = new sql_query(); $sql_obj->trans_begin(); /* Generate new password */ if ($data["password"]) { user_changepwd($id, $data["password"]); } /* Update user account details */ $sql_obj->string = "UPDATE `users` SET " . "realname='" . $data["realname"] . "', " . "contact_email='" . $data["contact_email"] . "' " . "WHERE id='{$id}'"; if (!$sql_obj->execute()) { $_SESSION["error"]["message"][] = "A fatal SQL error occured whilst trying to update user account details."; } /* Update user options */ // remove old user options $sql_obj->string = "DELETE FROM users_options WHERE userid='{$id}'"; $sql_obj->execute(); // language $sql_obj->string = "INSERT INTO users_options (userid, name, value) VALUES ({$id}, 'lang', '" . $data["option_lang"] . "')"; $sql_obj->execute(); // timezone $sql_obj->string = "INSERT INTO users_options (userid, name, value) VALUES ({$id}, 'timezone', '" . $data["option_timezone"] . "')"; $sql_obj->execute(); // dateformat
function action_delete_domain() { log_write("debug", "inc_cloud_route53", "Executing action_delete_domain()"); /* Delete Record Sets Amazon won't delete a domain if there are any records other than the base SOA and NS records assigned to it. We need to submit a delete request for all the records first. We do this by setting the local object to empty records, then do a sync record action against Route53. This generates a batch change to delete all the records. */ $this->obj_domain->data["records"] = array(); if (!$this->fetch_records_remote()) { return 0; } if (!$this->action_sync_records()) { return 0; } /* Delete Domain Now we can delete the domain itself. */ try { $change = NULL; $change["Id"] = $this->aws_zone_id; $query = $this->obj_route53->deleteHostedZone($change); if (!$query["ChangeInfo"]["Id"]) { log_write("error", "cloud_route53", "Invalid delete response returned from Route53"); return 0; } else { log_write("debug", "cloud_route53", "Route53 delete request submitted"); $this->changelog->log_post('server', "Domain \"" . $this->obj_domain->data["domain_name"] . "\" deleted from Route53"); $obj_sql = new sql_query(); $obj_sql->string = "DELETE FROM cloud_zone_map WHERE id_name_server='" . $this->obj_name_server->id . "' AND id_domain='" . $this->obj_domain->id . "' LIMIT 1"; $obj_sql->execute(); } } catch (Route53Exception $e) { log_write("error", "process", "A failure occured whilst trying to delete hosted zone."); log_write("error", "process", "Failure returned: " . $e->getExceptionCode() . ""); $this->changelog->log_post('server', "An error occured attempting to delete domain \"" . $this->obj_domain->data["domain_name"] . "\" from Route53"); return 0; } // success return 1; }
$send_reminder = @security_form_input_predefined("checkbox", "send_reminder_{$i}", 0, ""); //send reminder if ($send_reminder) { //fetch invoice id $invoice_id = @security_form_input_predefined("int", "invoice_id_{$i}", 1, "A problem occurred - no id seems to exist for this invoice"); //fetch days overdue $days_overdue = @security_form_input_predefined("int", "days_overdue_{$i}", 0, ""); //fetch basic invoice details $obj_sql_invoice = new sql_query(); $obj_sql_invoice->string = "SELECT code_invoice, customerid FROM account_ar WHERE id='" . $invoice_id . "' LIMIT 1"; $obj_sql_invoice->execute(); $obj_sql_invoice->fetch_array(); //fetch basic customer details $obj_sql_contact = new sql_query(); $obj_sql_contact->string = "SELECT id, contact FROM customer_contacts WHERE customer_id = '" . $obj_sql_invoice->data[0]["customerid"] . "' AND role = 'accounts'"; $obj_sql_contact->execute(); $obj_sql_contact->fetch_array(); //fetch email to address, set error if no address is set $to = sql_get_singlevalue("SELECT detail AS value FROM customer_contact_records WHERE contact_id = '" . $obj_sql_contact->data[0]["id"] . "' AND type = 'email' LIMIT 1"); if (!$to) { $error_array[] = $obj_sql_invoice->data[0]["code_invoice"]; continue; } //create invoice $obj_invoice = new invoice(); $obj_invoice->type = "ar"; $obj_invoice->id = $invoice_id; $obj_invoice->load_data(); $obj_invoice->load_data_export(); //get templating keys and values $invoice_data = $obj_invoice->invoice_fields;
function execute() { if ($this->mode == 1) { /* MODE 1: INITAL FILE UPLOAD */ $this->obj_form = new form_input(); $this->obj_form->formname = "domain_import"; $this->obj_form->language = $_SESSION["user"]["lang"]; $this->obj_form->action = "domains/import-process.php"; $this->obj_form->method = "post"; // import type $structure = NULL; $structure["fieldname"] = "import_upload_type"; $structure["type"] = "radio"; $structure["values"] = array("file_bind_8"); $structure["defaultvalue"] = "file_bind_8"; $this->obj_form->add_input($structure); // file upload $structure = NULL; $structure["fieldname"] = "import_upload_file"; $structure["type"] = "file"; $this->obj_form->add_input($structure); // submit section $structure = NULL; $structure["fieldname"] = "submit"; $structure["type"] = "submit"; $structure["defaultvalue"] = "Save Changes"; $this->obj_form->add_input($structure); $structure = NULL; $structure["fieldname"] = "mode"; $structure["type"] = "hidden"; $structure["defaultvalue"] = $this->mode; $this->obj_form->add_input($structure); // define subforms $this->obj_form->subforms["upload"] = array("import_upload_type", "import_upload_file"); $this->obj_form->subforms["hidden"] = array("mode"); $this->obj_form->subforms["submit"] = array("submit"); // import data if (error_check()) { $this->obj_form->load_data_error(); } } elseif ($this->mode == 2) { /* MODE 2: DOMAIN RECORD ASSIGNMENT Information from the imported zone file under mode 1 has been converted and loaded into the session variables, from here we can now enter all that information into a form and the user can correct/complete before we push through to the database. We also need to address issues like over-writing of existing domains here. */ /* Define form structure */ $this->obj_form = new form_input(); $this->obj_form->formname = "domain_import"; $this->obj_form->language = $_SESSION["user"]["lang"]; $this->obj_form->action = "domains/import-process.php"; $this->obj_form->method = "post"; /* General domain & SOA information */ $structure = NULL; $structure["fieldname"] = "domain_type"; $structure["type"] = "radio"; $structure["values"] = array("domain_standard", "domain_reverse_ipv4", "domain_reverse_ipv6"); $structure["options"]["req"] = "yes"; $structure["defaultvalue"] = "domain_standard"; $this->obj_form->add_input($structure); $structure = NULL; $structure["fieldname"] = "domain_name"; $structure["type"] = "input"; $structure["options"]["req"] = "yes"; $this->obj_form->add_input($structure); $structure = NULL; $structure["fieldname"] = "ipv4_help"; $structure["type"] = "text"; $structure["options"]["req"] = "yes"; $structure["defaultvalue"] = "help_ipv4_help"; $this->obj_form->add_input($structure); $structure = NULL; $structure["fieldname"] = "ipv6_help"; $structure["type"] = "text"; $structure["options"]["req"] = "yes"; $structure["defaultvalue"] = "help_ipv6_help"; $this->obj_form->add_input($structure); $structure = NULL; $structure["fieldname"] = "ipv4_network"; $structure["type"] = "input"; $structure["options"]["help"] = "eg: 192.168.0.0"; $structure["options"]["label"] = " /24"; $structure["options"]["req"] = "yes"; $this->obj_form->add_input($structure); /* $structure = NULL; $structure["fieldname"] = "ipv4_subnet"; $structure["type"] = "radio"; $structure["values"] = array("24", "16", "8"); $structure["options"]["req"] = "yes"; $this->obj_form->add_input($structure); $structure = NULL; $structure["fieldname"] = "ipv4_autofill"; $structure["type"] = "checkbox"; $structure["options"]["label"] = lang_trans("help_ipv4_autofill"); $structure["options"]["req"] = "yes"; $this->obj_form->add_input($structure); $structure = NULL; $structure["fieldname"] = "ipv4_autofill_domain"; $structure["type"] = "input"; $structure["options"]["help"] = "eg: static.example.com"; $structure["options"]["req"] = "yes"; $this->obj_form->add_input($structure); */ $structure = NULL; $structure["fieldname"] = "ipv6_network"; $structure["type"] = "input"; $structure["options"]["help"] = "eg: 2001:db8::/48"; $structure["options"]["label"] = " always include a /cidr value (/1 though to /64)"; $structure["options"]["req"] = "yes"; $this->obj_form->add_input($structure); /* $structure = NULL; $structure["fieldname"] = "ipv6_autofill"; $structure["type"] = "checkbox"; $structure["options"]["label"] = lang_trans("help_ipv6_autofill"); $structure["options"]["req"] = "yes"; $this->obj_form->add_input($structure); $structure = NULL; $structure["fieldname"] = "ipv6_autofill_forward"; $structure["type"] = "checkbox"; $structure["options"]["label"] = lang_trans("help_ipv6_autofill_forward"); $structure["options"]["req"] = "yes"; $this->obj_form->add_input($structure); $structure = NULL; $structure["fieldname"] = "ipv6_autofill_reverse_from_forward"; $structure["type"] = "checkbox"; $structure["options"]["label"] = lang_trans("help_ipv6_autofill_reverse_from_forward"); $structure["options"]["req"] = "yes"; $this->obj_form->add_input($structure); $structure = NULL; $structure["fieldname"] = "ipv6_autofill_domain"; $structure["type"] = "input"; $structure["options"]["help"] = "eg: static.example.com"; $structure["options"]["req"] = "yes"; $this->obj_form->add_input($structure); */ $this->obj_form->add_action("domain_type", "default", "domain_name", "show"); $this->obj_form->add_action("domain_type", "default", "ipv4_help", "hide"); $this->obj_form->add_action("domain_type", "default", "ipv4_network", "hide"); // $this->obj_form->add_action("domain_type", "default", "ipv4_subnet", "hide"); // $this->obj_form->add_action("domain_type", "default", "ipv4_autofill", "hide"); $this->obj_form->add_action("domain_type", "default", "ipv6_help", "hide"); $this->obj_form->add_action("domain_type", "default", "ipv6_network", "hide"); // $this->obj_form->add_action("domain_type", "default", "ipv4_subnet", "hide"); // $this->obj_form->add_action("domain_type", "default", "ipv4_autofill", "hide"); $this->obj_form->add_action("domain_type", "domain_standard", "domain_name", "show"); $this->obj_form->add_action("domain_type", "domain_reverse_ipv4", "domain_name", "hide"); $this->obj_form->add_action("domain_type", "domain_reverse_ipv4", "ipv4_help", "show"); $this->obj_form->add_action("domain_type", "domain_reverse_ipv4", "ipv4_network", "show"); // $this->obj_form->add_action("domain_type", "domain_reverse_ipv4", "ipv4_subnet", "show"); // $this->obj_form->add_action("domain_type", "domain_reverse_ipv4", "ipv4_autofill", "show"); $this->obj_form->add_action("domain_type", "domain_reverse_ipv4", "ipv6_help", "hide"); $this->obj_form->add_action("domain_type", "domain_reverse_ipv4", "ipv6_network", "hide"); // $this->obj_form->add_action("domain_type", "domain_reverse_ipv4", "ipv6_subnet", "hide"); // $this->obj_form->add_action("domain_type", "domain_reverse_ipv4", "ipv6_autofill", "hide"); $this->obj_form->add_action("domain_type", "domain_reverse_ipv6", "domain_name", "hide"); $this->obj_form->add_action("domain_type", "domain_reverse_ipv6", "ipv4_help", "hide"); $this->obj_form->add_action("domain_type", "domain_reverse_ipv6", "ipv4_network", "hide"); // $this->obj_form->add_action("domain_type", "domain_reverse_ipv6", "ipv4_subnet", "hide"); // $this->obj_form->add_action("domain_type", "domain_reverse_ipv6", "ipv4_autofill", "hide"); $this->obj_form->add_action("domain_type", "domain_reverse_ipv6", "ipv6_help", "show"); $this->obj_form->add_action("domain_type", "domain_reverse_ipv6", "ipv6_network", "show"); // $this->obj_form->add_action("domain_type", "domain_reverse_ipv6", "ipv6_subnet", "hide"); // $this->obj_form->add_action("domain_type", "domain_reverse_ipv6", "ipv6_autofill", "hide"); // $this->obj_form->add_action("ipv4_autofill", "default", "ipv4_autofill_domain", "hide"); // $this->obj_form->add_action("ipv4_autofill", "1", "ipv4_autofill_domain", "show"); $structure = NULL; $structure["fieldname"] = "domain_description"; $structure["type"] = "textarea"; $this->obj_form->add_input($structure); // SOA configuration $structure = NULL; $structure["fieldname"] = "soa_hostmaster"; $structure["type"] = "input"; $structure["options"]["req"] = "yes"; $structure["defaultvalue"] = $GLOBALS["config"]["DEFAULT_HOSTMASTER"]; $this->obj_form->add_input($structure); $structure = NULL; $structure["fieldname"] = "soa_serial"; $structure["type"] = "input"; $structure["options"]["req"] = "yes"; $structure["defaultvalue"] = date("Ymd") . "01"; $this->obj_form->add_input($structure); $structure = NULL; $structure["fieldname"] = "soa_refresh"; $structure["type"] = "input"; $structure["options"]["req"] = "yes"; $structure["defaultvalue"] = "21600"; $this->obj_form->add_input($structure); $structure = NULL; $structure["fieldname"] = "soa_retry"; $structure["type"] = "input"; $structure["options"]["req"] = "yes"; $structure["defaultvalue"] = "3600"; $this->obj_form->add_input($structure); $structure["fieldname"] = "soa_expire"; $structure["type"] = "input"; $structure["options"]["req"] = "yes"; $structure["defaultvalue"] = "604800"; $this->obj_form->add_input($structure); $structure["fieldname"] = "soa_default_ttl"; $structure["type"] = "input"; $structure["options"]["req"] = "yes"; $structure["defaultvalue"] = $GLOBALS["config"]["DEFAULT_TTL_SOA"]; $this->obj_form->add_input($structure); // define main domain subforms $this->obj_form->subforms["domain_details"] = array("domain_type", "domain_name", "ipv4_help", "ipv4_network", "ipv6_help", "ipv6_network", "domain_description"); $this->obj_form->subforms["domain_soa"] = array("soa_hostmaster", "soa_serial", "soa_refresh", "soa_retry", "soa_expire", "soa_default_ttl"); /* Imported Records The record import logic is not as advanced as the regular record handling page, it's primarily intended to display the import and allow correction before submission. For more advanced configuration and addition of rows, the user should import the domain and then adjust like normal. */ // subform header $this->obj_form->subforms["domain_records"] = array("record_import_guide"); $structure = NULL; $structure["fieldname"] = "record_import_guide"; $structure["type"] = "message"; $structure["defaultvalue"] = "<p>" . lang_trans("record_import_guide") . "</p>"; $this->obj_form->add_input($structure); if (empty($_SESSION["error"]["num_records"])) { // no records returned $structure = NULL; $structure["fieldname"] = "record_import_notice"; $structure["type"] = "message"; $structure["defaultvalue"] = "<p>" . lang_trans("records_not_imported") . "</p>"; $structure["options"]["css_row_class"] = "table_highlight_important"; $this->obj_form->add_input($structure); $this->obj_form->subforms["domain_records"][] = "record_import_notice"; } else { // headers $this->obj_form->subforms["domain_records"][] = "record_header"; $this->obj_form->subforms_grouped["domain_records"]["record_header"][] = "record_header_type"; $this->obj_form->subforms_grouped["domain_records"]["record_header"][] = "record_header_ttl"; $this->obj_form->subforms_grouped["domain_records"]["record_header"][] = "record_header_prio"; $this->obj_form->subforms_grouped["domain_records"]["record_header"][] = "record_header_name"; $this->obj_form->subforms_grouped["domain_records"]["record_header"][] = "record_header_content"; $this->obj_form->subforms_grouped["domain_records"]["record_header"][] = "record_header_import"; $structure = NULL; $structure["fieldname"] = "record_header_type"; $structure["type"] = "text"; $structure["defaultvalue"] = lang_trans("record_header_type"); $this->obj_form->add_input($structure); $structure = NULL; $structure["fieldname"] = "record_header_ttl"; $structure["type"] = "text"; $structure["defaultvalue"] = lang_trans("record_header_ttl"); $this->obj_form->add_input($structure); $structure = NULL; $structure["fieldname"] = "record_header_prio"; $structure["type"] = "text"; $structure["defaultvalue"] = lang_trans("record_header_prio"); $this->obj_form->add_input($structure); $structure = NULL; $structure["fieldname"] = "record_header_name"; $structure["type"] = "text"; $structure["defaultvalue"] = lang_trans("record_header_name"); $this->obj_form->add_input($structure); $structure = NULL; $structure["fieldname"] = "record_header_content"; $structure["type"] = "text"; $structure["defaultvalue"] = lang_trans("record_header_content"); $this->obj_form->add_input($structure); $structure = NULL; $structure["fieldname"] = "record_header_import"; $structure["type"] = "text"; $structure["defaultvalue"] = lang_trans("record_header_import"); $this->obj_form->add_input($structure); // draw pre-defined nameserver records $obj_sql = new sql_query(); $obj_sql->string = "SELECT server_name FROM name_servers"; $obj_sql->execute(); if ($obj_sql->num_rows()) { $obj_sql->fetch_array(); $i = 0; foreach ($obj_sql->data as $data_ns) { $i++; // record form items $structure = NULL; $structure["fieldname"] = "ns_" . $i . "_type"; $structure["type"] = "text"; $structure["defaultvalue"] = "NS"; $this->obj_form->add_input($structure); $structure = NULL; $structure["fieldname"] = "ns_" . $i . "_ttl"; $structure["type"] = "text"; $structure["defaultvalue"] = $GLOBALS["config"]["DEFAULT_TTL_NS"]; $this->obj_form->add_input($structure); $structure = NULL; $structure["fieldname"] = "ns_" . $i . "_prio"; $structure["type"] = "text"; $structure["defaultvalue"] = ""; $this->obj_form->add_input($structure); $structure = NULL; $structure["fieldname"] = "ns_" . $i . "_name"; $structure["type"] = "text"; $structure["defaultvalue"] = "@"; $this->obj_form->add_input($structure); $structure = NULL; $structure["fieldname"] = "ns_" . $i . "_content"; $structure["type"] = "text"; $structure["defaultvalue"] = $data_ns["server_name"]; $this->obj_form->add_input($structure); $structure = NULL; $structure["fieldname"] = "ns_" . $i . "_import"; $structure["type"] = "checkbox"; $structure["defaultvalue"] = "on"; $structure["options"]["disabled"] = "yes"; $structure["options"]["label"] = "Import"; $this->obj_form->add_input($structure); // domain records $this->obj_form->subforms["domain_records"][] = "ns_" . $i; $this->obj_form->subforms_grouped["domain_records"]["ns_" . $i][] = "ns_" . $i . "_type"; $this->obj_form->subforms_grouped["domain_records"]["ns_" . $i][] = "ns_" . $i . "_ttl"; $this->obj_form->subforms_grouped["domain_records"]["ns_" . $i][] = "ns_" . $i . "_prio"; $this->obj_form->subforms_grouped["domain_records"]["ns_" . $i][] = "ns_" . $i . "_name"; $this->obj_form->subforms_grouped["domain_records"]["ns_" . $i][] = "ns_" . $i . "_content"; $this->obj_form->subforms_grouped["domain_records"]["ns_" . $i][] = "ns_" . $i . "_import"; } } // end of pre-defined nameserver loop // loop through imported records and create form structure for ($i = 0; $i < $_SESSION["error"]["num_records"]; $i++) { $record = $_SESSION["error"]["records"][$i]; // record form items $structure = form_helper_prepare_dropdownfromdb("record_" . $i . "_type", "SELECT type as label, type as id FROM `dns_record_types` WHERE type!='SOA'"); $structure["options"]["width"] = "100"; $structure["defaultvalue"] = $record["type"]; $this->obj_form->add_input($structure); if (!$record["ttl"]) { $record["ttl"] = $GLOBALS["config"]["DEFAULT_TTL_OTHER"]; } $structure = NULL; $structure["fieldname"] = "record_" . $i . "_ttl"; $structure["type"] = "input"; $structure["options"]["width"] = "100"; $structure["defaultvalue"] = $record["ttl"]; $this->obj_form->add_input($structure); $structure = NULL; $structure["fieldname"] = "record_" . $i . "_prio"; $structure["type"] = "input"; $structure["options"]["width"] = "100"; $structure["defaultvalue"] = $record["prio"]; $this->obj_form->add_input($structure); $structure = NULL; $structure["fieldname"] = "record_" . $i . "_name"; $structure["type"] = "input"; $structure["defaultvalue"] = $record["name"]; $this->obj_form->add_input($structure); $structure = NULL; $structure["fieldname"] = "record_" . $i . "_content"; $structure["type"] = "input"; $structure["defaultvalue"] = $record["content"]; $this->obj_form->add_input($structure); $structure = NULL; $structure["fieldname"] = "record_" . $i . "_import"; $structure["type"] = "checkbox"; $structure["defaultvalue"] = "on"; $structure["options"]["label"] = "Import"; $this->obj_form->add_input($structure); // domain records $this->obj_form->subforms["domain_records"][] = "record_" . $i; $this->obj_form->subforms_grouped["domain_records"]["record_" . $i][] = "record_" . $i . "_type"; $this->obj_form->subforms_grouped["domain_records"]["record_" . $i][] = "record_" . $i . "_ttl"; $this->obj_form->subforms_grouped["domain_records"]["record_" . $i][] = "record_" . $i . "_prio"; $this->obj_form->subforms_grouped["domain_records"]["record_" . $i][] = "record_" . $i . "_name"; $this->obj_form->subforms_grouped["domain_records"]["record_" . $i][] = "record_" . $i . "_content"; $this->obj_form->subforms_grouped["domain_records"]["record_" . $i][] = "record_" . $i . "_import"; } } /* Unmatched Lines Report Sadly it's not always possible to import *every* line of ever zone file out there - the styles can vary by far too much to match at times. We have a section of the form to display the records which do not match so that users are notified and thus able to make corrections if needed. */ // subform header $this->obj_form->subforms["unmatched_import"] = array("unmatched_import_help", "unmatched_import_notice"); $structure = NULL; $structure["fieldname"] = "unmatched_import_help"; $structure["type"] = "message"; $structure["defaultvalue"] = "<p>" . lang_trans("unmatched_import_help") . "</p>"; $this->obj_form->add_input($structure); if (empty($_SESSION["error"]["unmatched"])) { // no unmatched rows $structure = NULL; $structure["fieldname"] = "unmatched_import_notice"; $structure["type"] = "message"; $structure["defaultvalue"] = "<p>" . lang_trans("import_notice_no_unmatched_rows") . "</p>"; $structure["options"]["css_row_class"] = "table_highlight_open"; $this->obj_form->add_input($structure); } else { // import notice $structure = NULL; $structure["fieldname"] = "unmatched_import_notice"; $structure["type"] = "message"; $structure["defaultvalue"] = "<p>" . lang_trans("import_notice_unmatched_rows") . "</p>"; $structure["options"]["css_row_class"] = "table_highlight_important"; $this->obj_form->add_input($structure); // add all the unmatched rows for ($i = 0; $i < count($_SESSION["error"]["unmatched"]); $i++) { $this->obj_form->subforms["unmatched_import"][] = "unmatched_row_{$i}"; $structure = NULL; $structure["fieldname"] = "unmatched_row_{$i}"; $structure["type"] = "message"; $structure["defaultvalue"] = "\"" . $_SESSION["error"]["unmatched"][$i] . "\""; $this->obj_form->add_input($structure); } } // end of unmatched lines loop /* Submission */ // submit section $structure = NULL; $structure["fieldname"] = "submit"; $structure["type"] = "submit"; $structure["defaultvalue"] = "Save Changes"; $this->obj_form->add_input($structure); $structure = NULL; $structure["fieldname"] = "mode"; $structure["type"] = "hidden"; $structure["defaultvalue"] = $this->mode; $this->obj_form->add_input($structure); $structure = NULL; $structure["fieldname"] = "num_records"; $structure["type"] = "hidden"; $structure["defaultvalue"] = $_SESSION["error"]["num_records"]; $this->obj_form->add_input($structure); // define submit subforms $this->obj_form->subforms["hidden"] = array("mode", "num_records"); $this->obj_form->subforms["submit"] = array("submit"); // import data // if (error_check()) // { // $_SESSION["error"]["form"]["domain_import"] = "error"; // $this->obj_form->load_data_error(); // } foreach (array_keys($this->obj_form->structure) as $fieldname) { if (isset($_SESSION["error"][$fieldname])) { $this->obj_form->structure[$fieldname]["defaultvalue"] = stripslashes($_SESSION["error"][$fieldname]); } } } // end of mode }
function execute() { log_debug("invoice_form_delete", "Executing execute()"); $sql_obj = new sql_query(); $sql_obj->string = "SELECT locked, amount_paid FROM account_" . $this->type . " WHERE id='" . $this->invoiceid . "' LIMIT 1"; $sql_obj->execute(); $sql_obj->fetch_array(); $this->locked = $sql_obj->data[0]["locked"]; $this->amount_paid = $sql_obj->data[0]["amount_paid"]; /* Start Form */ $this->obj_form = new form_input(); $this->obj_form->formname = $this->type . "_invoice_delete"; $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_invoice"; $structure["type"] = "text"; $this->obj_form->add_input($structure); $structure = NULL; $structure["fieldname"] = "delete_confirm"; $structure["type"] = "checkbox"; $structure["options"]["label"] = "Yes, I wish to delete this invoice and realise that once deleted the data can not be recovered."; $this->obj_form->add_input($structure); // hidden fields $structure = NULL; $structure["fieldname"] = "date_create"; $structure["type"] = "hidden"; $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"] = "Delete Invoice"; $this->obj_form->add_input($structure); // load data $this->obj_form->sql_query = "SELECT date_create, code_invoice, locked, amount_paid FROM account_" . $this->type . " WHERE id='" . $this->invoiceid . "'"; $this->obj_form->load_data(); $this->obj_form->subforms[$this->type . "_invoice_delete"] = array("code_invoice"); $this->obj_form->subforms["hidden"] = array("id_invoice", "date_create"); if ($this->locked) { $this->obj_form->subforms["submit"] = array(""); } else { $this->obj_form->subforms["submit"] = array("delete_confirm", "submit"); } }
function render_html() { // calcuate next/previous week/year if ($this->date_selected_weekofyear == 1) { $date_option_previousyear = $this->date_selected_year - 1; $date_option_previousweek = 52; $date_option_nextyear = $this->date_selected_year; $date_option_nextweek = 2; } elseif ($this->date_selected_weekofyear == 52) { $date_option_previousyear = $this->date_selected_year; $date_option_previousweek = 51; $date_option_nextyear = $this->date_selected_year + 1; $date_option_nextweek = 1; } else { $date_option_previousyear = $this->date_selected_year; $date_option_previousweek = $this->date_selected_weekofyear - 1; $date_option_nextyear = $this->date_selected_year; $date_option_nextweek = $this->date_selected_weekofyear + 1; } // Week view header print "<h3>TIME REGISTRATION</h3><br><br>"; /* Unbilled Time */ if (user_permissions_get("projects_timegroup")) { /* 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); } } // fetch amount of unbilled time $sql_obj = new sql_query(); $sql_obj->prepare_sql_settable("timereg"); $sql_obj->prepare_sql_addfield("timebooked", "SUM(timereg.time_booked)"); if ($this->access_staff_ids) { $sql_obj->prepare_sql_addwhere("employeeid IN (" . format_arraytocommastring($this->access_staff_ids) . ")"); } $sql_obj->prepare_sql_addjoin("LEFT JOIN time_groups ON timereg.groupid = time_groups.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) { $i = 0; foreach ($unbilled_ids_keys as $id) { $i++; if ($i == $unbilled_ids_count) { $unbilled_ids_sql .= "timereg.id='{$id}' "; } else { $unbilled_ids_sql .= "timereg.id='{$id}' OR "; } } $sql_obj->prepare_sql_addwhere("({$unbilled_ids_sql})"); $sql_obj->generate_sql(); $sql_obj->execute(); $sql_obj->fetch_array(); list($unbilled_time_hours, $unbilled_time_mins) = explode(":", time_format_hourmins($sql_obj->data[0]["timebooked"])); if ($unbilled_time_hours > 0 && $unbilled_time_mins > 0) { $message = "There are currently {$unbilled_time_hours} hours and {$unbilled_time_mins} minutes of unbilled time to be processed. Click here to view."; } elseif ($unbilled_time_hours > 0) { $message = "There are currently {$unbilled_time_hours} hours of unbilled time to be processed. Click here to view."; } elseif ($unbilled_time_mins > 0) { $message = "There are currently {$unbilled_time_mins} minutes of unbilled time to be processed. Click here to view."; } } else { $message = "There is no unbilled time to be processed."; } // display print "<br>"; format_linkbox("default", "index.php?page=timekeeping/unbilled.php", "<p><b>UNBILLED TIME</b></p><p>{$message}</p>"); } /*end unbilled time*/ print "<br />"; /* Time booked */ // fetch amount of time booked for today $sql_obj = new sql_query(); $sql_obj->prepare_sql_settable("timereg"); $sql_obj->prepare_sql_addfield("timebooked", "SUM(timereg.time_booked)"); $sql_obj->prepare_sql_addwhere("date='" . date("Y-m-d") . "'"); if ($this->access_staff_ids) { $sql_obj->prepare_sql_addwhere("employeeid IN (" . format_arraytocommastring($this->access_staff_ids) . ")"); } $sql_obj->generate_sql(); $sql_obj->execute(); $sql_obj->fetch_array(); list($booked_time_hours, $booked_time_mins) = explode(":", time_format_hourmins($sql_obj->data[0]["timebooked"])); if ($booked_time_hours > 0 && $booked_time_mins > 0) { $message = "<b>Time booked for today: {$booked_time_hours} hours and {$booked_time_mins} minutes.</b><br />Click here to add more time."; } elseif ($booked_time_hours > 0) { $message = "<b>Time booked for today: {$booked_time_hours} hours.</b><br />Click here to add more time."; } elseif ($booked_time_mins > 0) { $message = "<b>Time booked for today: {$booked_time_mins} minutes.</b><br />Click here to add more time."; } else { $message = "<b>No time has been booked for today</b><br />Click here to add time.</b>"; } format_linkbox("default", "index.php?page=timekeeping/timereg-day-edit.php", "<p>{$message}</p>"); print "<br />"; print "<table class=\"table_highlight\" width=\"100%\"><tr>"; // Week selection links print "<td width=\"70%\">"; print "<b>WEEK " . $this->date_selected_weekofyear . ", " . $this->date_selected_year . "</b><br>"; print "(" . time_format_humandate($this->date_selected_start) . " to " . time_format_humandate($this->date_selected_end) . ")<br>"; print "<br>"; print "<p><b>"; print "<a class=\"button\" href=\"index.php?page=timekeeping/timereg.php&employeeid=" . $this->employeeid . "&weekofyear=" . $date_option_previousweek . "&year=" . $date_option_previousyear . "\"><< Previous Week</a>"; // check for date in the future if ($this->config_timesheet_booktofuture == "disabled") { if (time_date_to_timestamp(time_calculate_weekstart($date_option_nextweek, $date_option_nextyear)) < time()) { // end date is in not in the future print " <a class=\"button\" href=\"index.php?page=timekeeping/timereg.php&employeeid=" . $this->employeeid . "&weekofyear=" . $date_option_nextweek . "&year=" . $date_option_nextyear . "\">Next Week >></a>"; } } else { print " <a class=\"button\" href=\"index.php?page=timekeeping/timereg.php&employeeid=" . $this->employeeid . "&weekofyear=" . $date_option_nextweek . "&year=" . $date_option_nextyear . "\">Next Week >></a>"; } print "</b></p>"; print "</td>"; // goto date form print "<td width=\"30%\">"; print "<form method=\"get\" action=\"index.php\" class=\"form_standard\">"; $this->obj_form_goto->render_field("date"); print "<br>"; $this->obj_form_goto->render_field("page"); $this->obj_form_goto->render_field("submit"); print "</form>"; print "</td>"; print "</tr></table><br>"; // Employee selection form // // we use a custom form display method here, since the normal form // class will draw a fully styled form in a table. // if ($this->employeeid) { print "<table class=\"table_highlight\" width=\"100%\"><tr><td width=\"100%\">"; } else { print "<table class=\"table_highlight_important\" width=\"100%\"><tr><td width=\"100%\">"; } print "<form method=\"get\" action=\"index.php\" class=\"form_standard\">"; print "<p><b>Select an employee to view:</b></p>"; $this->obj_form_employee->render_field("employeeid"); $this->obj_form_employee->render_field("weekofyear"); $this->obj_form_employee->render_field("year"); $this->obj_form_employee->render_field("page"); $this->obj_form_employee->render_field("submit"); print "</form>"; print "</td></tr></table><br>"; if ($this->employeeid) { // custom labels and links if ($this->config_timesheet_booktofuture == "disabled") { if (time_date_to_timestamp($this->date_selected_daysofweek[0]) < time()) { $this->obj_table_week->custom_column_link("monday", "index.php?page=timekeeping/timereg-day.php&date=" . $this->date_selected_daysofweek[0] . ""); } if (time_date_to_timestamp($this->date_selected_daysofweek[1]) < time()) { $this->obj_table_week->custom_column_link("tuesday", "index.php?page=timekeeping/timereg-day.php&date=" . $this->date_selected_daysofweek[1] . ""); } if (time_date_to_timestamp($this->date_selected_daysofweek[2]) < time()) { $this->obj_table_week->custom_column_link("wednesday", "index.php?page=timekeeping/timereg-day.php&date=" . $this->date_selected_daysofweek[2] . ""); } if (time_date_to_timestamp($this->date_selected_daysofweek[3]) < time()) { $this->obj_table_week->custom_column_link("thursday", "index.php?page=timekeeping/timereg-day.php&date=" . $this->date_selected_daysofweek[3] . ""); } if (time_date_to_timestamp($this->date_selected_daysofweek[4]) < time()) { $this->obj_table_week->custom_column_link("friday", "index.php?page=timekeeping/timereg-day.php&date=" . $this->date_selected_daysofweek[4] . ""); } if (time_date_to_timestamp($this->date_selected_daysofweek[5]) < time()) { $this->obj_table_week->custom_column_link("saturday", "index.php?page=timekeeping/timereg-day.php&date=" . $this->date_selected_daysofweek[5] . ""); } if (time_date_to_timestamp($this->date_selected_daysofweek[6]) < time()) { $this->obj_table_week->custom_column_link("sunday", "index.php?page=timekeeping/timereg-day.php&date=" . $this->date_selected_daysofweek[6] . ""); } } else { // add links $this->obj_table_week->custom_column_link("monday", "index.php?page=timekeeping/timereg-day.php&date=" . $this->date_selected_daysofweek[0] . ""); $this->obj_table_week->custom_column_link("tuesday", "index.php?page=timekeeping/timereg-day.php&date=" . $this->date_selected_daysofweek[1] . ""); $this->obj_table_week->custom_column_link("wednesday", "index.php?page=timekeeping/timereg-day.php&date=" . $this->date_selected_daysofweek[2] . ""); $this->obj_table_week->custom_column_link("thursday", "index.php?page=timekeeping/timereg-day.php&date=" . $this->date_selected_daysofweek[3] . ""); $this->obj_table_week->custom_column_link("friday", "index.php?page=timekeeping/timereg-day.php&date=" . $this->date_selected_daysofweek[4] . ""); $this->obj_table_week->custom_column_link("saturday", "index.php?page=timekeeping/timereg-day.php&date=" . $this->date_selected_daysofweek[5] . ""); $this->obj_table_week->custom_column_link("sunday", "index.php?page=timekeeping/timereg-day.php&date=" . $this->date_selected_daysofweek[6] . ""); } // column labels $this->obj_table_week->custom_column_label("monday", "Monday<br><font style=\"font-size: 8px;\">(" . time_format_humandate($this->date_selected_daysofweek[0]) . ")</font>"); $this->obj_table_week->custom_column_label("tuesday", "Tuesday<br><font style=\"font-size: 8px;\">(" . time_format_humandate($this->date_selected_daysofweek[1]) . ")</font>"); $this->obj_table_week->custom_column_label("wednesday", "Wednesday<br><font style=\"font-size: 8px;\">(" . time_format_humandate($this->date_selected_daysofweek[2]) . ")</font>"); $this->obj_table_week->custom_column_label("thursday", "Thursday<br><font style=\"font-size: 8px;\">(" . time_format_humandate($this->date_selected_daysofweek[3]) . ")</font>"); $this->obj_table_week->custom_column_label("friday", "Friday<br><font style=\"font-size: 8px;\">(" . time_format_humandate($this->date_selected_daysofweek[4]) . ")</font>"); $this->obj_table_week->custom_column_label("saturday", "Saturday<br><font style=\"font-size: 8px;\">(" . time_format_humandate($this->date_selected_daysofweek[5]) . ")</font>"); $this->obj_table_week->custom_column_label("sunday", "Sunday<br><font style=\"font-size: 8px;\">(" . time_format_humandate($this->date_selected_daysofweek[6]) . ")</font>"); // display week time table $this->obj_table_week->render_table_html(); print "<table width=\"100%\">"; // add time link if (user_permissions_staff_get("timereg_write", $this->employeeid)) { print "<td align=\"left\" valign=\"top\"><p><a class=\"button\" href=\"index.php?page=timekeeping/timereg-day-edit.php\">Add new time entry</a></p></td>"; } else { print "<p><i>You have read-only access to this employee and therefore can not add any more time.</i></p>"; } // display CSV/PDF download link print "<td align=\"right\">"; print "<p><a class=\"button_export\" href=\"index-export.php?mode=csv&page=timekeeping/timereg.php\">Export as CSV</a></p>"; print "<p><a class=\"button_export\" href=\"index-export.php?mode=pdf&page=timekeeping/timereg.php\">Export as PDF</a></p>"; print "</td>"; print "</table>"; } }
function execute() { // define customer list table $this->obj_table_list = new table(); $this->obj_table_list->language = $_SESSION["user"]["lang"]; $this->obj_table_list->tablename = "customer_list_billing"; // define all the columns and structure $this->obj_table_list->add_column("standard", "code_customer", ""); $this->obj_table_list->add_column("standard", "name_customer", ""); $this->obj_table_list->add_column("standard", "billing_direct_debit", ""); $this->obj_table_list->add_column("money", "balance_owed", "NONE"); // defaults $this->obj_table_list->columns = array("code_customer", "name_customer", 'billing_direct_debit', 'balance_owed'); $this->obj_table_list->columns_order = array("name_customer"); $this->obj_table_list->columns_order_options = array("code_customer", "name_customer", "name_contact", "contact_phone", "contact_mobile", "contact_email", "contact_fax", "date_start", "date_end", "tax_number", "address1_city", "address1_state", "address1_country"); // define SQL structure $this->obj_table_list->sql_obj->prepare_sql_settable("customers"); $this->obj_table_list->sql_obj->prepare_sql_addfield("id", ""); /* // define SQL structure $this->obj_table->sql_obj->prepare_sql_settable("account_ar"); $this->obj_table->sql_obj->prepare_sql_addfield("id", "account_ar.id"); $this->obj_table->sql_obj->prepare_sql_addjoin("LEFT JOIN customers ON customers.id = account_ar.customerid"); $this->obj_table->sql_obj->prepare_sql_addjoin("LEFT JOIN staff ON staff.id = account_ar.employeeid"); */ // acceptable filter options $structure = NULL; $structure["fieldname"] = "date_start"; $structure["type"] = "date"; $structure["sql"] = "date_start >= 'value'"; $this->obj_table_list->add_filter($structure); $structure = NULL; $structure["fieldname"] = "date_end"; $structure["type"] = "date"; $structure["sql"] = "date_end <= 'value' AND date_end != '0000-00-00'"; $this->obj_table_list->add_filter($structure); /* $structure = NULL; $structure["fieldname"] = "searchbox"; $structure["type"] = "input"; $structure["sql"] = "(code_customer LIKE '%value%' OR name_customer LIKE '%value%')"; $this->obj_table_list->add_filter($structure); */ $structure = NULL; $structure["fieldname"] = "billing_method"; $structure["type"] = "checkbox"; $structure["options"]["label"] = "Billing method Direct Debit"; $structure["defaultvalue"] = "1"; $structure["sql"] = "billing_method = 'direct debit'"; $this->obj_table_list->add_filter($structure); // load settings from options form $this->obj_table_list->load_options_form(); // fetch all the customer information $this->obj_table_list->generate_sql(); $this->obj_table_list->load_data_sql(); // handle balance owed if (in_array('balance_owed', $this->obj_table_list->columns)) { $obj_balance_owed_sql = new sql_query(); $obj_balance_owed_sql->string = "SELECT customerid, sum(bal) AS balance_owed FROM (\n\t\t\t\tSELECT ar.customerid, sum(ar.amount_total - ar.amount_paid) as bal \n\t\t\t\tFROM account_ar AS ar \n\t\t\t\tWHERE 1 GROUP BY ar.customerid\n\t\t\t\tUNION\n\t\t\t\tSELECT arc.customerid, sum(arc.amount_total) as bal\n\t\t\t\tFROM account_ar_credit AS arc\n\t\t\t\tWHERE 1 GROUP BY arc.customerid\n\t\t\t\t) as tbl GROUP by customerid"; $obj_balance_owed_sql->execute(); if ($obj_balance_owed_sql->num_rows()) { $obj_balance_owed_sql->fetch_array(); foreach ($obj_balance_owed_sql->data as $data_balance_owed) { $map_balance_owed[$data_balance_owed['customerid']] = $data_balance_owed['balance_owed']; } } // replace with 0.00 or the calculated balance value for ($i = 0; $i < $this->obj_table_list->data_num_rows; $i++) { $this->obj_table_list->data[$i]["balance_owed"] = "0.00"; if (isset($map_balance_owed[$this->obj_table_list->data[$i]['id']])) { $this->obj_table_list->data[$i]["balance_owed"] = $map_balance_owed[$this->obj_table_list->data[$i]['id']]; } // we dont want 0 balance (or credit) records here if ($this->obj_table_list->data[$i]["balance_owed"] <= 0) { unset($this->obj_table_list->data[$i]); } } // re index after the potential unsets $this->obj_table_list->data = @array_values($this->obj_table_list->data); $this->obj_table_list->data_num_rows = count($this->obj_table_list->data); unset($map_balance_owed); unset($obj_balance_owed_sql); } }
function invoice_form_export_process($type, $returnpage_error, $returnpage_success) { log_debug("inc_invoices_forms", "Executing invoice_form_export_process({$type}, {$returnpage_error}, {$returnpage_success})"); /* Start the invoice */ $invoice = new invoice(); $invoice->type = $type; /* Fetch all form data */ // get the ID for an edit $invoice->id = @security_form_input_predefined("int", "id_invoice", 1, ""); // general details $data["formname"] = @security_form_input_predefined("any", "formname", 1, ""); if ($data["formname"] == "invoice_export_email") { // send email $data["sender"] = @security_form_input_predefined("any", "sender", 1, ""); $data["subject"] = @security_form_input_predefined("any", "subject", 1, ""); $data["email_to"] = @security_form_input_predefined("multiple_email", "email_to", 1, ""); $data["email_cc"] = @security_form_input_predefined("multiple_email", "email_cc", 0, ""); $data["email_bcc"] = @security_form_input_predefined("multiple_email", "email_bcc", 0, ""); $data["message"] = @security_form_input_predefined("any", "email_message", 1, ""); // check if email sending is permitted if (sql_get_singlevalue("SELECT value FROM config WHERE name='EMAIL_ENABLE'") != "enabled") { log_write("error", "inc_invoices_process", "Sorry, the ability to email invoices has been disabled. Please contact your system administrator if you require this feature to be enabled."); } } else { // PDF download $data["invoice_mark_as_sent"] = @security_form_input_predefined("any", "invoice_mark_as_sent", 0, ""); } // make sure that the invoice exists $sql_obj = new sql_query(); $sql_obj->string = "SELECT id FROM `account_" . $invoice->type . "` WHERE id='" . $invoice->id . "'"; $sql_obj->execute(); if (!$sql_obj->num_rows()) { $_SESSION["error"]["message"][] = "The invoice you have attempted to edit - " . $invoice->id . " - does not exist in this system."; } //// ERROR CHECKING /////////////////////// /// if there was an error, go back to the entry page if (!empty($_SESSION["error"]["message"])) { header("Location: ../../index.php?page={$returnpage_error}&id=" . $invoice->id . ""); exit(0); } else { if ($data["formname"] == "invoice_export_email") { /* Generate a PDF of the invoice and email it to the customer */ // stripslashes from the variables - by default all input variables are quoted for security reasons but // we don't want this going through to the email. $data["subject"] = stripslashes($data["subject"]); $data["message"] = stripslashes($data["message"]); // send email $invoice->load_data(); $invoice->email_invoice($data["sender"], $data["email_to"], $data["email_cc"], $data["email_bcc"], $data["subject"], $data["message"]); $_SESSION["notification"]["message"][] = "Email sent successfully."; } else { /* Mark invoice as being sent if user requests it */ if ($data["invoice_mark_as_sent"]) { $sql_obj = new sql_query(); $sql_obj->string = "UPDATE account_" . $invoice->type . " SET date_sent='" . date("Y-m-d") . "', sentmethod='manual' WHERE id='" . $invoice->id . "'"; $sql_obj->execute(); } /* Provide PDF to user's browser */ // generate PDF $invoice->load_data(); $invoice->generate_pdf(); // PDF headers if ($type == "quotes") { $filename = "/tmp/quote_" . $invoice->data["code_quote"] . ".pdf"; } else { $filename = "/tmp/invoice_" . $invoice->data["code_invoice"] . ".pdf"; } // required for IE, otherwise Content-disposition is ignored if (ini_get('zlib.output_compression')) { ini_set('zlib.output_compression', 'Off'); } header("Pragma: public"); // required header("Expires: 0"); header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); header("Cache-Control: private", false); // required for certain browsers header("Content-Type: application/pdf"); header("Content-Disposition: attachment; filename=\"" . basename($filename) . "\";"); header("Content-Transfer-Encoding: binary"); // output the PDF print $invoice->obj_pdf->output; exit(0); } // display updated details header("Location: ../../index.php?page={$returnpage_success}&id=" . $invoice->id . ""); exit(0); } // end if passed tests }