function execute()
 {
     /*
     	Define form structure
     */
     $this->obj_form = new form_input();
     $this->obj_form->formname = "services_bundles_service";
     $this->obj_form->language = $_SESSION["user"]["lang"];
     $this->obj_form->action = "services/bundles-service-add-process.php";
     $this->obj_form->method = "post";
     // service dropdown
     $structure = form_helper_prepare_dropdownfromdb("id_service", "SELECT services.id as id, name_service as label FROM `services` LEFT JOIN service_types ON service_types.id = services.typeid WHERE service_types.name != 'bundle' ORDER BY name_service");
     $this->obj_form->add_input($structure);
     // hidden fields
     $structure = NULL;
     $structure["fieldname"] = "id_bundle";
     $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_bundle");
     $this->obj_form->subforms["bundle_services"] = array("id_service");
     $this->obj_form->subforms["submit"] = array("submit");
     $this->obj_form->load_data_error();
 }
Example #2
0
 function execute()
 {
     // define basic form details
     $this->obj_form = new form_input();
     $this->obj_form->formname = "service_group_add";
     $this->obj_form->language = $_SESSION["user"]["lang"];
     $this->obj_form->action = "services/groups-edit-process.php";
     $this->obj_form->method = "post";
     // general
     $structure = NULL;
     $structure["fieldname"] = "group_name";
     $structure["type"] = "input";
     $structure["options"]["req"] = "yes";
     $this->obj_form->add_input($structure);
     $structure = NULL;
     $structure["fieldname"] = "group_description";
     $structure["type"] = "input";
     $this->obj_form->add_input($structure);
     $structure = form_helper_prepare_dropdownfromdb("id_parent", "SELECT id, group_name as label, id_parent FROM service_groups");
     $structure["options"]["search_filter"] = "yes";
     $this->obj_form->add_input($structure);
     // submit button
     $structure = NULL;
     $structure["fieldname"] = "submit";
     $structure["type"] = "submit";
     $structure["defaultvalue"] = "submit";
     $this->obj_form->add_input($structure);
     // define subforms
     $this->obj_form->subforms["service_group_add"] = array("group_name", "group_description", "id_parent");
     $this->obj_form->subforms["submit"] = array("submit");
     // load any data returned due to errors
     $this->obj_form->load_data_error();
 }
Example #3
0
 function execute()
 {
     // establish a new table object
     $this->obj_table = new table();
     $this->obj_table->language = $_SESSION["user"]["lang"];
     $this->obj_table->tablename = "cdr_rate_tables";
     // define all the columns and structure
     $this->obj_table->add_column("standard", "rate_table_name", "");
     $this->obj_table->add_column("standard", "name_vendor", "vendors.name_vendor");
     $this->obj_table->add_column("standard", "rate_table_description", "");
     // defaults
     $this->obj_table->columns = array("rate_table_name", "name_vendor", "rate_table_description");
     $this->obj_table->columns_order = array("rate_table_name");
     $this->obj_table->columns_order_options = array("rate_table_name", "name_vendor");
     // define SQL structure
     $this->obj_table->sql_obj->prepare_sql_settable("cdr_rate_tables");
     $this->obj_table->sql_obj->prepare_sql_addfield("id", "cdr_rate_tables.id");
     $this->obj_table->sql_obj->prepare_sql_addjoin("LEFT JOIN vendors ON vendors.id = cdr_rate_tables.id_vendor");
     // acceptable filter options
     $structure["fieldname"] = "searchbox";
     $structure["type"] = "input";
     $structure["sql"] = "(rate_table_name LIKE '%value%' OR rate_table_description LIKE '%value%')";
     $this->obj_table->add_filter($structure);
     $structure = form_helper_prepare_dropdownfromdb("name_vendor", "SELECT id, code_vendor as label, name_vendor as label1 FROM vendors ORDER BY name_vendor ASC");
     $structure["sql"] = "cdr_rate_tables.id_vendor='value'";
     $structure["options"]["search_filter"] = "yes";
     $this->obj_table->add_filter($structure);
     // load options
     $this->obj_table->load_options_form();
     // fetch all the service information
     $this->obj_table->generate_sql();
     $this->obj_table->load_data_sql();
 }
Example #4
0
function charts_form_prepare_acccountdropdown($fieldname, $menu_name)
{
    log_debug("inc_charts", "Executing charts_form_prepare_accountdropdown({$fieldname}, {$menu_name})");
    // see if we need to fetch the ID for the name
    // (see function comments - this will be phased out eventually)
    if (is_int($menu_name)) {
        log_debug("inc_charts", "Obsolete: Use of menu ID rather than menu name");
        $menuid = $menu_name;
    } else {
        $menuid = sql_get_singlevalue("SELECT id as value FROM account_chart_menu WHERE value='{$menu_name}'");
    }
    // fetch list of suitable charts belonging to the menu requested.
    $sql_query = "SELECT " . "account_charts.id as id, " . "account_charts.code_chart as label, " . "account_charts.description as label1 " . "FROM account_charts " . "LEFT JOIN account_charts_menus ON account_charts_menus.chartid = account_charts.id " . "WHERE account_charts_menus.menuid='{$menuid}' " . "ORDER BY account_charts.code_chart";
    $return = form_helper_prepare_dropdownfromdb($fieldname, $sql_query);
    // if we don't get any form data returned this means no charts with the required
    // permissions exist in the database, so we need to return a graceful error.
    if (!$return) {
        $structure = NULL;
        $structure["fieldname"] = $fieldname;
        $structure["type"] = "text";
        $structure["defaultvalue"] = "No suitable charts avaliable";
        return $structure;
    } else {
        return $return;
    }
}
Example #5
0
 function execute()
 {
     // establish a new table object
     $this->obj_table = new table();
     $this->obj_table->language = $_SESSION["user"]["lang"];
     $this->obj_table->tablename = "vendor_invoices";
     // define all the columns and structure
     $this->obj_table->add_column("standard", "code_invoice", "account_ap.code_invoice");
     $this->obj_table->add_column("standard", "code_ordernumber", "account_ap.code_ordernumber");
     $this->obj_table->add_column("standard", "code_ponumber", "account_ap.code_ponumber");
     $this->obj_table->add_column("standard", "name_staff", "staff.name_staff");
     $this->obj_table->add_column("date", "date_trans", "account_ap.date_trans");
     $this->obj_table->add_column("date", "date_due", "account_ap.date_due");
     $this->obj_table->add_column("price", "amount_tax", "account_ap.amount_tax");
     $this->obj_table->add_column("price", "amount", "account_ap.amount");
     $this->obj_table->add_column("price", "amount_total", "account_ap.amount_total");
     $this->obj_table->add_column("price", "amount_paid", "account_ap.amount_paid");
     // totals
     $this->obj_table->total_columns = array("amount_tax", "amount", "amount_total", "amount_paid");
     // defaults
     $this->obj_table->columns = array("code_invoice", "name_staff", "date_trans", "date_due", "amount_total", "amount_paid");
     $this->obj_table->columns_order = array("code_invoice");
     // define SQL structure
     $this->obj_table->sql_obj->prepare_sql_settable("account_ap");
     $this->obj_table->sql_obj->prepare_sql_addfield("id", "account_ap.id");
     $this->obj_table->sql_obj->prepare_sql_addjoin("LEFT JOIN staff ON staff.id = account_ap.employeeid");
     $this->obj_table->sql_obj->prepare_sql_addwhere("account_ap.vendorid='" . $this->id . "'");
     // acceptable filter options
     $this->obj_table->add_fixed_option("id", $this->id);
     $structure = NULL;
     $structure["fieldname"] = "date_start";
     $structure["type"] = "date";
     $structure["sql"] = "date_trans >= 'value'";
     $this->obj_table->add_filter($structure);
     $structure = NULL;
     $structure["fieldname"] = "date_end";
     $structure["type"] = "date";
     $structure["sql"] = "date_trans <= 'value'";
     $this->obj_table->add_filter($structure);
     $structure = form_helper_prepare_dropdownfromdb("employeeid", "SELECT id, staff_code as label, name_staff as label1 FROM staff ORDER BY name_staff");
     $structure["sql"] = "account_ap.employeeid='value'";
     $this->obj_table->add_filter($structure);
     $structure = NULL;
     $structure["fieldname"] = "invoice_notes_search";
     $structure["type"] = "input";
     $structure["sql"] = "notes LIKE '%value%'";
     $this->obj_table->add_filter($structure);
     $structure = NULL;
     $structure["fieldname"] = "hide_closed";
     $structure["type"] = "checkbox";
     $structure["options"]["label"] = "Hide Closed Invoices";
     $structure["defaultvalue"] = "";
     $structure["sql"] = "account_ap.amount_paid!=account_ap.amount_total";
     $this->obj_table->add_filter($structure);
     // load options
     $this->obj_table->load_options_form();
     // fetch all the chart information
     $this->obj_table->generate_sql();
     $this->obj_table->load_data_sql();
 }
Example #6
0
 function execute()
 {
     /*
     	Define form structure
     */
     $this->obj_form = new form_input();
     $this->obj_form->formname = "support_ticket_add";
     $this->obj_form->language = $_SESSION["user"]["lang"];
     $this->obj_form->action = "support/edit-process.php";
     $this->obj_form->method = "post";
     // general
     $structure = NULL;
     $structure["fieldname"] = "title";
     $structure["type"] = "input";
     $structure["options"]["req"] = "yes";
     $this->obj_form->add_input($structure);
     $structure = NULL;
     $structure["fieldname"] = "date_start";
     $structure["type"] = "date";
     $structure["defaultvalue"] = date("Y-m-d");
     $structure["options"]["req"] = "yes";
     $this->obj_form->add_input($structure);
     $structure = NULL;
     $structure["fieldname"] = "date_end";
     $structure["type"] = "date";
     $this->obj_form->add_input($structure);
     $structure = NULL;
     $structure["fieldname"] = "details";
     $structure["type"] = "textarea";
     $structure["options"]["width"] = "600";
     $structure["options"]["height"] = "100";
     $this->obj_form->add_input($structure);
     // status + priority
     $structure = form_helper_prepare_dropdownfromdb("status", "SELECT id, value as label FROM support_tickets_status");
     $structure["options"]["req"] = "yes";
     $this->obj_form->add_input($structure);
     $structure = form_helper_prepare_dropdownfromdb("priority", "SELECT id, value as label FROM support_tickets_priority");
     $this->obj_form->add_input($structure);
     // customer/product/project/service ID
     // submit section
     if (user_permissions_get("support_write")) {
         $structure = NULL;
         $structure["fieldname"] = "submit";
         $structure["type"] = "submit";
         $structure["defaultvalue"] = "Save Changes";
         $this->obj_form->add_input($structure);
     } else {
         $structure = NULL;
         $structure["fieldname"] = "submit";
         $structure["type"] = "message";
         $structure["defaultvalue"] = "<p><i>Sorry, you don't have permissions to make changes to support_ticket records.</i></p>";
         $this->obj_form->add_input($structure);
     }
     // define subforms
     $this->obj_form->subforms["support_ticket_details"] = array("title", "priority", "details");
     $this->obj_form->subforms["support_ticket_status"] = array("status", "date_start", "date_end");
     $this->obj_form->subforms["submit"] = array("submit");
     // fetch the form data
     $this->obj_form->load_data_error();
 }
Example #7
0
 function execute()
 {
     // establish a new table object
     $this->obj_table = new table();
     $this->obj_table->language = $_SESSION["user"]["lang"];
     $this->obj_table->tablename = "account_quotes";
     // define all the columns and structure
     $this->obj_table->add_column("standard", "code_quote", "account_quotes.code_quote");
     $this->obj_table->add_column("standard", "name_customer", "CONCAT_WS(' -- ', customers.code_customer, customers.name_customer)");
     $this->obj_table->add_column("standard", "name_staff", "CONCAT_WS(' -- ', staff.staff_code, staff.name_staff)");
     $this->obj_table->add_column("date", "date_trans", "account_quotes.date_trans");
     $this->obj_table->add_column("date", "date_validtill", "account_quotes.date_validtill");
     $this->obj_table->add_column("price", "amount_tax", "account_quotes.amount_tax");
     $this->obj_table->add_column("price", "amount", "account_quotes.amount");
     $this->obj_table->add_column("price", "amount_total", "account_quotes.amount_total");
     $this->obj_table->add_column("bool_tick", "sent", "account_quotes.sentmethod");
     // totals
     $this->obj_table->total_columns = array("amount_tax", "amount", "amount_total");
     // defaults
     $this->obj_table->columns = array("code_quote", "name_customer", "date_trans", "amount_total");
     $this->obj_table->columns_order = array("code_quote");
     $this->obj_table->columns_order_options = array("code_quote", "name_customer", "name_staff", "date_trans", "date_validtill", "sent");
     // define SQL structure
     $this->obj_table->sql_obj->prepare_sql_settable("account_quotes");
     $this->obj_table->sql_obj->prepare_sql_addfield("id", "account_quotes.id");
     $this->obj_table->sql_obj->prepare_sql_addjoin("LEFT JOIN customers ON customers.id = account_quotes.customerid");
     $this->obj_table->sql_obj->prepare_sql_addjoin("LEFT JOIN staff ON staff.id = account_quotes.employeeid");
     // acceptable filter options
     $structure = NULL;
     $structure["fieldname"] = "date_start";
     $structure["type"] = "date";
     $structure["sql"] = "date_trans >= 'value'";
     $this->obj_table->add_filter($structure);
     $structure = NULL;
     $structure["fieldname"] = "date_end";
     $structure["type"] = "date";
     $structure["sql"] = "date_trans <= 'value'";
     $this->obj_table->add_filter($structure);
     $structure = form_helper_prepare_dropdownfromdb("employeeid", "SELECT id, staff_code as label, name_staff as label1 FROM staff ORDER BY name_staff");
     $structure["sql"] = "account_quotes.employeeid='value'";
     $structure["options"]["search_filter"] = "enabled";
     $this->obj_table->add_filter($structure);
     $structure = form_helper_prepare_dropdownfromdb("customerid", "SELECT id, code_customer as label, name_customer as label1 FROM customers ORDER BY name_customer");
     $structure["sql"] = "account_quotes.customerid='value'";
     $structure["options"]["search_filter"] = "enabled";
     $this->obj_table->add_filter($structure);
     $structure = NULL;
     $structure["fieldname"] = "hide_closed";
     $structure["type"] = "checkbox";
     $structure["options"]["label"] = "Hide Expired Quotes";
     $structure["defaultvalue"] = "enabled";
     $structure["sql"] = "account_quotes.date_validtill > '" . date("Y-m-d") . "'";
     $this->obj_table->add_filter($structure);
     // load options
     $this->obj_table->load_options_form();
     // fetch all the chart information
     $this->obj_table->generate_sql();
     $this->obj_table->load_data_sql();
 }
 function execute()
 {
     // define basic form details
     $this->obj_form = new form_input();
     $this->obj_form->formname = "cdr_rate_table_view";
     $this->obj_form->language = $_SESSION["user"]["lang"];
     $this->obj_form->action = "services/cdr-rates-edit-process.php";
     $this->obj_form->method = "post";
     // general
     $structure = NULL;
     $structure["fieldname"] = "rate_table_name";
     $structure["type"] = "input";
     $structure["options"]["req"] = "yes";
     $this->obj_form->add_input($structure);
     $structure = NULL;
     $structure["fieldname"] = "rate_table_description";
     $structure["type"] = "input";
     $this->obj_form->add_input($structure);
     $structure = form_helper_prepare_dropdownfromdb("id_vendor", "SELECT id, code_vendor as label, name_vendor as label1 FROM vendors ORDER BY name_vendor");
     $structure["options"]["req"] = "yes";
     $structure["options"]["width"] = "600";
     $structure["options"]["search_filter"] = "yes";
     $this->obj_form->add_input($structure);
     $structure = form_helper_prepare_dropdownfromdb("id_usage_mode", "SELECT id, description as label FROM cdr_rate_usage_modes ORDER BY name");
     $structure["options"]["req"] = "yes";
     $structure["options"]["width"] = "600";
     $this->obj_form->add_input($structure);
     // hidden fields
     $structure = NULL;
     $structure["fieldname"] = "id";
     $structure["type"] = "hidden";
     $structure["defaultvalue"] = $this->obj_rate_table->id;
     $this->obj_form->add_input($structure);
     // submit button
     $structure = NULL;
     $structure["fieldname"] = "submit";
     $structure["type"] = "submit";
     $structure["defaultvalue"] = "submit";
     $this->obj_form->add_input($structure);
     // define subforms
     $this->obj_form->subforms["rate_table_view"] = array("rate_table_name", "rate_table_description", "id_vendor", "id_usage_mode");
     $this->obj_form->subforms["hidden"] = array("id");
     if (user_permissions_get("services_write")) {
         $this->obj_form->subforms["submit"] = array("submit");
     } else {
         $this->obj_form->subforms["submit"] = array("");
     }
     // load any data returned due to errors
     if (error_check()) {
         $this->obj_form->load_data_error();
     } else {
         $this->obj_rate_table->load_data();
         $this->obj_form->structure["rate_table_name"]["defaultvalue"] = $this->obj_rate_table->data["rate_table_name"];
         $this->obj_form->structure["rate_table_description"]["defaultvalue"] = $this->obj_rate_table->data["rate_table_description"];
         $this->obj_form->structure["id_vendor"]["defaultvalue"] = $this->obj_rate_table->data["id_vendor"];
         $this->obj_form->structure["id_usage_mode"]["defaultvalue"] = $this->obj_rate_table->data["id_usage_mode"];
     }
 }
 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.
     */
 }
Example #10
0
 function execute()
 {
     // establish a new table object
     $this->obj_table = new table();
     $this->obj_table->language = $_SESSION["user"]["lang"];
     $this->obj_table->tablename = "product_list";
     // define all the columns and structure
     $this->obj_table->add_column("standard", "code_product", "");
     $this->obj_table->add_column("standard", "name_product", "");
     $this->obj_table->add_column("standard", "account_sales", "CONCAT_WS(' -- ',account_charts.code_chart,account_charts.description)");
     $this->obj_table->add_column("standard", "id_product_group", "product_groups.group_name");
     $this->obj_table->add_column("price", "price_cost", "");
     $this->obj_table->add_column("price", "price_sale", "");
     $this->obj_table->add_column("percentage", "discount", "");
     $this->obj_table->add_column("date", "date_start", "");
     $this->obj_table->add_column("date", "date_end", "");
     $this->obj_table->add_column("date", "date_current", "");
     $this->obj_table->add_column("standard", "quantity_instock", "");
     $this->obj_table->add_column("standard", "quantity_vendor", "");
     // defaults
     $this->obj_table->columns = array("code_product", "name_product", "account_sales", "price_cost", "price_sale");
     $this->obj_table->columns_order = array("code_product");
     $this->obj_table->columns_order_options = array("code_product", "name_product", "account_sales", "date_current", "quantity_instock", "quantity_vendor");
     // define SQL structure
     $this->obj_table->sql_obj->prepare_sql_settable("products");
     $this->obj_table->sql_obj->prepare_sql_addfield("id", "products.id");
     $this->obj_table->sql_obj->prepare_sql_addjoin("LEFT JOIN account_charts ON account_charts.id = products.account_sales");
     $this->obj_table->sql_obj->prepare_sql_addjoin("LEFT JOIN product_groups ON product_groups.id = products.id_product_group");
     // acceptable filter options
     $structure = NULL;
     $structure["fieldname"] = "searchbox";
     $structure["type"] = "input";
     $structure["sql"] = "(name_product LIKE '%value%' OR code_product LIKE '%value%')";
     $this->obj_table->add_filter($structure);
     $structure = form_helper_prepare_dropdownfromdb("id_product_group", "SELECT id, group_name as label FROM product_groups ORDER BY group_name ASC");
     $structure["sql"] = "products.id_product_group='value'";
     $structure["options"]["search_filter"] = "yes";
     $this->obj_table->add_filter($structure);
     $structure = NULL;
     $structure["fieldname"] = "hide_ex_products";
     $structure["type"] = "checkbox";
     $structure["sql"] = "date_end='0000-00-00'";
     $structure["defaultvalue"] = "on";
     $structure["options"]["label"] = "Hide any products which are no longer sold";
     $this->obj_table->add_filter($structure);
     // load options
     $this->obj_table->load_options_form();
     // fetch all the product information
     $this->obj_table->generate_sql();
     $this->obj_table->load_data_sql();
 }
Example #11
0
 function execute()
 {
     // establish a new table object
     $this->obj_table = new table();
     $this->obj_table->language = $_SESSION["user"]["lang"];
     $this->obj_table->tablename = "changelog";
     // define all the columns and structure
     $this->obj_table->add_column("timestamp", "timestamp", "");
     $this->obj_table->add_column("standard", "server_name", "name_servers.server_name");
     $this->obj_table->add_column("standard", "domain_name", "dns_domains.domain_name");
     $this->obj_table->add_column("standard", "username", "");
     $this->obj_table->add_column("standard", "log_type", "");
     $this->obj_table->add_column("standard", "log_contents", "");
     // defaults
     $this->obj_table->columns = array("timestamp", "server_name", "domain_name", "username", "log_type", "log_contents");
     $this->obj_table->sql_obj->prepare_sql_settable("logs");
     $this->obj_table->sql_obj->prepare_sql_addjoin("LEFT JOIN name_servers ON name_servers.id = logs.id_server");
     $this->obj_table->sql_obj->prepare_sql_addjoin("LEFT JOIN dns_domains ON dns_domains.id = logs.id_domain");
     $this->obj_table->sql_obj->prepare_sql_addorderby_desc("timestamp");
     // acceptable filter options
     $structure = NULL;
     $structure["fieldname"] = "searchbox";
     $structure["type"] = "input";
     $structure["sql"] = "(server_name LIKE '%value%' OR domain_name LIKE '%value%' OR log_type LIKE '%value%' OR log_contents LIKE '%value%')";
     $this->obj_table->add_filter($structure);
     $structure = NULL;
     $structure["fieldname"] = "num_logs_rows";
     $structure["type"] = "input";
     $structure["sql"] = "";
     $structure["defaultvalue"] = "1000";
     $this->obj_table->add_filter($structure);
     $structure = form_helper_prepare_dropdownfromdb("id_server_name", "SELECT id, server_name as label FROM name_servers ORDER BY server_name");
     $structure["type"] = "dropdown";
     $structure["sql"] = "id_server='value'";
     $this->obj_table->add_filter($structure);
     $structure = form_helper_prepare_dropdownfromdb("id_domain", "SELECT id, domain_name as label FROM dns_domains ORDER BY domain_name");
     $structure["type"] = "dropdown";
     $structure["sql"] = "id_domain='value'";
     $this->obj_table->add_filter($structure);
     // load options
     if (isset($this->obj_server_name->id)) {
         $this->obj_table->add_fixed_option("id", $this->obj_server_name->id);
     }
     $this->obj_table->load_options_form();
     // generate SQL
     $this->obj_table->generate_sql();
     // load limit filter
     $this->obj_table->sql_obj->string .= "LIMIT " . $this->obj_table->filter["filter_num_logs_rows"]["defaultvalue"];
     // load data from DB
     $this->obj_table->load_data_sql();
 }
Example #12
0
 function execute()
 {
     /*
     	Define form structure
     */
     $this->obj_form = new form_input();
     $this->obj_form->formname = "transaction_add";
     $this->obj_form->language = $_SESSION["user"]["lang"];
     $this->obj_form->action = "accounts/gl/edit-process.php";
     $this->obj_form->method = "post";
     // general
     $structure = NULL;
     $structure["fieldname"] = "code_gl";
     $structure["type"] = "input";
     $this->obj_form->add_input($structure);
     $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 = form_helper_prepare_dropdownfromdb("employeeid", "SELECT id, staff_code as label, name_staff as label1 FROM staff WHERE date_end = '0000-00-00' ORDER BY staff_code");
     $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"] = "description";
     $structure["type"] = "input";
     $structure["options"]["req"] = "yes";
     $structure["options"]["width"] = "600";
     $this->obj_form->add_input($structure);
     $structure = NULL;
     $structure["fieldname"] = "notes";
     $structure["type"] = "textarea";
     $structure["options"]["width"] = "600";
     $structure["options"]["height"] = "50";
     $this->obj_form->add_input($structure);
     // submit button
     $structure = NULL;
     $structure["fieldname"] = "submit";
     $structure["type"] = "submit";
     $structure["defaultvalue"] = "Create Transaction";
     $this->obj_form->add_input($structure);
     // define subforms
     $this->obj_form->subforms["general_ledger_transaction_details"] = array("code_gl", "date_trans", "employeeid", "description", "notes");
     $this->obj_form->subforms["submit"] = array("submit");
     // load any data returned due to errors
     $this->obj_form->load_data_error();
 }
 function execute()
 {
     log_debug("services_form_plan", "Executing execute()");
     /*
     	Fetch plan type information
     */
     $sql_plan_obj = new sql_query();
     $sql_plan_obj->string = "SELECT services.typeid, service_types.name FROM services LEFT JOIN service_types ON service_types.id = services.typeid WHERE services.id='" . $this->serviceid . "' LIMIT 1";
     $sql_plan_obj->execute();
     $sql_plan_obj->fetch_array();
     /*
     	Define form structure
     */
     $this->obj_form = new form_input();
     $this->obj_form->formname = "service_plan";
     $this->obj_form->language = $_SESSION["user"]["lang"];
     $this->obj_form->action = "services/plan-edit-process.php";
     $this->obj_form->method = "post";
     // general details
     $structure = NULL;
     $structure["fieldname"] = "name_service";
     $structure["type"] = "text";
     $this->obj_form->add_input($structure);
     $structure = form_helper_prepare_radiofromdb("billing_cycle", "SELECT id, name as label, description as label1 FROM billing_cycles WHERE active='1' ORDER BY priority");
     $structure["options"]["req"] = "yes";
     $this->obj_form->add_input($structure);
     $structure = NULL;
     $structure["fieldname"] = "price";
     $structure["type"] = "money";
     $structure["options"]["req"] = "yes";
     $this->obj_form->add_input($structure);
     $structure = NULL;
     $structure["fieldname"] = "price_setup";
     $structure["type"] = "money";
     $structure["options"]["req"] = "yes";
     $this->obj_form->add_input($structure);
     $structure = NULL;
     $structure["fieldname"] = "discount";
     $structure["type"] = "input";
     $structure["options"]["width"] = 50;
     $structure["options"]["label"] = " %";
     $structure["options"]["max_length"] = "6";
     $this->obj_form->add_input($structure);
     /*
     	Type-specific Form Options
     */
     switch ($sql_plan_obj->data[0]["name"]) {
         case "generic_with_usage":
             /*
             	GENERIC_WITH_USAGE
             
             	This service is to be used for any non-traffic, non-time accounting service that needs to track usage. Examples of this
             	could be counting the number of API requests, size of disk usage on a vhost, etc.
             */
             // custom
             $structure = NULL;
             $structure["fieldname"] = "plan_information";
             $structure["type"] = "message";
             $structure["defaultvalue"] = "<i>This section is where you define what units you wish to bill in, along with the cost of excess units. It is acceptable to leave the price for extra units set to 0.00 if you have some other method of handling excess usage (eg: rate shaping rather than billing). If you wish to create an uncapped/unlimited usage service, set both the price for extra units and the included units to 0.</i>";
             $this->obj_form->add_input($structure);
             $structure = NULL;
             $structure["fieldname"] = "units";
             $structure["type"] = "input";
             $structure["options"]["req"] = "yes";
             $this->obj_form->add_input($structure);
             $structure = NULL;
             $structure["fieldname"] = "included_units";
             $structure["type"] = "input";
             $structure["options"]["req"] = "yes";
             $this->obj_form->add_input($structure);
             $structure = NULL;
             $structure["fieldname"] = "price_extraunits";
             $structure["type"] = "money";
             $structure["options"]["req"] = "yes";
             $this->obj_form->add_input($structure);
             $structure = form_helper_prepare_radiofromdb("usage_mode", "SELECT id, description as label FROM service_usage_modes");
             $structure["options"]["req"] = "yes";
             $this->obj_form->add_input($structure);
             // general
             $structure = form_helper_prepare_radiofromdb("billing_mode", "SELECT id, name as label, description as label1 FROM billing_modes WHERE active='1' AND name NOT LIKE '%advance%'");
             $structure["options"]["req"] = "yes";
             // replace all the -- joiners with <br> for clarity
             for ($i = 0; $i < count($structure["values"]); $i++) {
                 $structure["translations"][$structure["values"][$i]] = str_replace("--", "<br><i>", $structure["translations"][$structure["values"][$i]]);
                 $structure["translations"][$structure["values"][$i]] .= "</i>";
             }
             $this->obj_form->add_input($structure);
             // usage alerts
             $structure = NULL;
             $structure["fieldname"] = "alert_80pc";
             $structure["type"] = "checkbox";
             $structure["options"]["no_fieldname"] = "yes";
             $structure["options"]["label"] = "Send customers email warnings when they hit 80% of their usage";
             $this->obj_form->add_input($structure);
             $structure = NULL;
             $structure["fieldname"] = "alert_100pc";
             $structure["type"] = "checkbox";
             $structure["options"]["no_fieldname"] = "yes";
             $structure["options"]["label"] = "Send customers email warnings when they hit 100% of their usage";
             $this->obj_form->add_input($structure);
             $structure = NULL;
             $structure["fieldname"] = "alert_extraunits";
             $structure["type"] = "input";
             $this->obj_form->add_input($structure);
             // subforms
             $this->obj_form->subforms["service_plan"] = array("name_service", "price", "price_setup", "discount", "billing_cycle", "billing_mode");
             $this->obj_form->subforms["service_plan_custom"] = array("plan_information", "units", "included_units", "price_extraunits", "usage_mode");
             $this->obj_form->subforms["service_plan_alerts"] = array("alert_80pc", "alert_100pc", "alert_extraunits");
             break;
         case "licenses":
             /*
             					LICENSES
             */
             $structure = NULL;
             $structure["fieldname"] = "plan_information";
             $structure["type"] = "message";
             $structure["defaultvalue"] = "<i>For licenses services, the price field and included units specify how much for the number of base licenses. The extra units price field specifies how much for additional licenses.</i>";
             $this->obj_form->add_input($structure);
             $structure = NULL;
             $structure["fieldname"] = "units";
             $structure["type"] = "input";
             $structure["options"]["req"] = "yes";
             $structure["options"]["autoselect"] = "yes";
             $this->obj_form->add_input($structure);
             $structure = NULL;
             $structure["fieldname"] = "included_units";
             $structure["type"] = "input";
             $structure["options"]["req"] = "yes";
             $this->obj_form->add_input($structure);
             $structure = NULL;
             $structure["fieldname"] = "price_extraunits";
             $structure["type"] = "money";
             $structure["options"]["req"] = "yes";
             $this->obj_form->add_input($structure);
             // general
             $structure = form_helper_prepare_radiofromdb("billing_mode", "SELECT id, name as label, description as label1 FROM billing_modes WHERE active='1' AND name NOT LIKE '%telco%'");
             $structure["options"]["req"] = "yes";
             // replace all the -- joiners with <br> for clarity
             for ($i = 0; $i < count($structure["values"]); $i++) {
                 $structure["translations"][$structure["values"][$i]] = str_replace("--", "<br><i>", $structure["translations"][$structure["values"][$i]]);
                 $structure["translations"][$structure["values"][$i]] .= "</i>";
             }
             $this->obj_form->add_input($structure);
             // subforms
             $this->obj_form->subforms["service_plan"] = array("name_service", "price", "price_setup", "discount", "billing_cycle", "billing_mode");
             $this->obj_form->subforms["service_plan_custom"] = array("plan_information", "units", "included_units", "price_extraunits");
             break;
         case "time":
             /*
             	TIME
             
             	Incrementing usage counters.
             */
             $structure = NULL;
             $structure["fieldname"] = "plan_information";
             $structure["type"] = "message";
             $structure["defaultvalue"] = "<i>This section is where you define what units you wish to bill in, along with the cost of excess units. It is acceptable to leave the price for extra units set to 0.00 if you have some other method of handling excess usage (eg: rate shaping rather than billing). If you wish to create an uncapped/unlimited usage service, set both the price for extra units and the included units to 0.</i>";
             $this->obj_form->add_input($structure);
             $structure = form_helper_prepare_radiofromdb("units", "SELECT id, name as label, description as label1 FROM service_units WHERE typeid='" . $sql_plan_obj->data[0]["typeid"] . "' AND active='1' ORDER BY name");
             $structure["options"]["req"] = "yes";
             $structure["options"]["autoselect"] = "yes";
             $this->obj_form->add_input($structure);
             $structure = NULL;
             $structure["fieldname"] = "included_units";
             $structure["type"] = "input";
             $structure["options"]["req"] = "yes";
             $this->obj_form->add_input($structure);
             $structure = NULL;
             $structure["fieldname"] = "price_extraunits";
             $structure["type"] = "money";
             $structure["options"]["req"] = "yes";
             $this->obj_form->add_input($structure);
             // general
             $structure = form_helper_prepare_radiofromdb("billing_mode", "SELECT id, name as label, description as label1 FROM billing_modes WHERE active='1' AND name NOT LIKE '%advance%'");
             $structure["options"]["req"] = "yes";
             // replace all the -- joiners with <br> for clarity
             for ($i = 0; $i < count($structure["values"]); $i++) {
                 $structure["translations"][$structure["values"][$i]] = str_replace("--", "<br><i>", $structure["translations"][$structure["values"][$i]]);
                 $structure["translations"][$structure["values"][$i]] .= "</i>";
             }
             $this->obj_form->add_input($structure);
             // usage alerts
             $structure = NULL;
             $structure["fieldname"] = "alert_80pc";
             $structure["type"] = "checkbox";
             $structure["options"]["no_fieldname"] = "yes";
             $structure["options"]["label"] = "Send customers email warnings when they hit 80% of their usage";
             $this->obj_form->add_input($structure);
             $structure = NULL;
             $structure["fieldname"] = "alert_100pc";
             $structure["type"] = "checkbox";
             $structure["options"]["no_fieldname"] = "yes";
             $structure["options"]["label"] = "Send customers email warnings when they hit 100% of their usage";
             $this->obj_form->add_input($structure);
             $structure = NULL;
             $structure["fieldname"] = "alert_extraunits";
             $structure["type"] = "input";
             $this->obj_form->add_input($structure);
             // subforms
             $this->obj_form->subforms["service_plan"] = array("name_service", "price", "price_setup", "discount", "billing_cycle", "billing_mode");
             $this->obj_form->subforms["service_plan_custom"] = array("plan_information", "units", "included_units", "price_extraunits");
             $this->obj_form->subforms["service_plan_alerts"] = array("alert_80pc", "alert_100pc", "alert_extraunits");
             // handle misconfiguration
             if (empty($this->obj_form->structure["units"]["values"])) {
                 $this->obj_form->structure["units"]["type"] = "text";
                 $this->obj_form->structure["units"]["defaultvalue"] = "error_no_units_available";
             }
             break;
         case "data_traffic":
             /*
             	DATA_TRAFFIC
             		
             	Data traffic service types are reasonably complex and allow multiple data caps to be assigned, based
             	on the selected traffic types.
             */
             /*
             					data_traffic: General service optionsd
             */
             // general
             $structure = form_helper_prepare_radiofromdb("billing_mode", "SELECT id, name as label, description as label1 FROM billing_modes WHERE active='1' AND name NOT LIKE '%advance%'");
             $structure["options"]["req"] = "yes";
             // replace all the -- joiners with <br> for clarity
             for ($i = 0; $i < count($structure["values"]); $i++) {
                 $structure["translations"][$structure["values"][$i]] = str_replace("--", "<br><i>", $structure["translations"][$structure["values"][$i]]);
                 $structure["translations"][$structure["values"][$i]] .= "</i>";
             }
             $this->obj_form->add_input($structure);
             // subforms
             $this->obj_form->subforms["service_plan"] = array("name_service", "price", "price_setup", "discount", "billing_cycle", "billing_mode");
             /*
             	data_traffic: Service Plan Options
             */
             $structure = NULL;
             $structure["fieldname"] = "plan_information";
             $structure["type"] = "message";
             $structure["defaultvalue"] = "<i>This section is where you define what units you wish to bill in, along with the cost of excess units. It is acceptable to leave the price for extra units set to 0.00 if you have some other method of handling excess usage (eg: rate shaping rather than billing). If you wish to create an uncapped/unlimited usage service, set both the price for extra units and the included units to 0.</i>";
             $this->obj_form->add_input($structure);
             $structure = form_helper_prepare_radiofromdb("units", "SELECT id, name as label, description as label1 FROM service_units WHERE typeid='" . $sql_plan_obj->data[0]["typeid"] . "' AND active='1' ORDER BY name");
             $structure["options"]["req"] = "yes";
             $structure["options"]["autoselect"] = "yes";
             $this->obj_form->add_input($structure);
             // handle misconfiguration
             if (empty($this->obj_form->structure["units"]["values"])) {
                 $this->obj_form->structure["units"]["type"] = "text";
                 $this->obj_form->structure["units"]["defaultvalue"] = "error_no_units_available";
             }
             // subforms
             $this->obj_form->subforms["service_plan_custom"] = array("plan_information", "units");
             /*
             	data_traffic: Service Plan Datacaps
             */
             // help info
             $structure = NULL;
             $structure["fieldname"] = "traffic_cap_help";
             $structure["type"] = "message";
             $structure["defaultvalue"] = "<p>Define the traffic cap(s) for the selected service below - note that the \"Any\" type will always exist and applies to any traffic that doesn't match any of the other types matched to the customer on this service.</p>";
             $this->obj_form->add_input($structure);
             $this->obj_form->subforms["traffic_caps"][] = "traffic_cap_help";
             // header
             $structure = NULL;
             $structure["fieldname"] = "traffic_cap_header_active";
             $structure["type"] = "text";
             $structure["defaultvalue"] = lang_trans("header_traffic_cap_active");
             $this->obj_form->add_input($structure);
             $structure = NULL;
             $structure["fieldname"] = "traffic_cap_header_name";
             $structure["type"] = "text";
             $structure["defaultvalue"] = lang_trans("header_traffic_cap_name");
             $this->obj_form->add_input($structure);
             $structure = NULL;
             $structure["fieldname"] = "traffic_cap_header_mode";
             $structure["type"] = "text";
             $structure["defaultvalue"] = lang_trans("header_traffic_cap_mode");
             $this->obj_form->add_input($structure);
             $structure = NULL;
             $structure["fieldname"] = "traffic_cap_header_units_included";
             $structure["type"] = "text";
             $structure["defaultvalue"] = lang_trans("header_traffic_units_included");
             $this->obj_form->add_input($structure);
             $structure = NULL;
             $structure["fieldname"] = "traffic_cap_header_units_price";
             $structure["type"] = "text";
             $structure["defaultvalue"] = lang_trans("header_traffic_units_price");
             $this->obj_form->add_input($structure);
             $this->obj_form->subforms_grouped["traffic_caps"]["traffic_cap_header"][] = "traffic_cap_header_active";
             $this->obj_form->subforms_grouped["traffic_caps"]["traffic_cap_header"][] = "traffic_cap_header_name";
             $this->obj_form->subforms_grouped["traffic_caps"]["traffic_cap_header"][] = "traffic_cap_header_mode";
             $this->obj_form->subforms_grouped["traffic_caps"]["traffic_cap_header"][] = "traffic_cap_header_units_included";
             $this->obj_form->subforms_grouped["traffic_caps"]["traffic_cap_header"][] = "traffic_cap_header_units_price";
             $this->obj_form->subforms["traffic_caps"][] = "traffic_cap_header";
             // loop through all the traffic types
             $obj_sql_traffic_types = new sql_query();
             $obj_sql_traffic_types->string = "SELECT id, type_name FROM traffic_types ORDER BY id='1', type_name DESC";
             $obj_sql_traffic_types->execute();
             $obj_sql_traffic_types->num_rows();
             // will always be at least one, need for loop
             $obj_sql_traffic_types->fetch_array();
             for ($i = 0; $i < $obj_sql_traffic_types->data_num_rows; $i++) {
                 // define form fields
                 $structure = NULL;
                 $structure["fieldname"] = "traffic_cap_" . $i . "_active";
                 $structure["type"] = "checkbox";
                 $structure["options"]["label"] = "Apply to Service";
                 if ($obj_sql_traffic_types->data[$i]["id"] == 1) {
                     $structure["options"]["disabled"] = "yes";
                     $structure["defaultvalue"] = "on";
                 }
                 $this->obj_form->add_input($structure);
                 $structure = NULL;
                 $structure["fieldname"] = "traffic_cap_" . $i . "_id";
                 $structure["type"] = "hidden";
                 $structure["defaultvalue"] = $obj_sql_traffic_types->data[$i]["id"];
                 $this->obj_form->add_input($structure);
                 $structure = NULL;
                 $structure["fieldname"] = "traffic_cap_" . $i . "_name";
                 $structure["type"] = "text";
                 $structure["defaultvalue"] = $obj_sql_traffic_types->data[$i]["type_name"];
                 $this->obj_form->add_input($structure);
                 $structure = NULL;
                 $structure["fieldname"] = "traffic_cap_" . $i . "_mode";
                 $structure["type"] = "dropdown";
                 $structure["values"][0] = "unlimited";
                 $structure["values"][1] = "capped";
                 $structure["defaultvalue"] = "unlimited";
                 $structure["options"]["width"] = "100";
                 $this->obj_form->add_input($structure);
                 $structure = NULL;
                 $structure["fieldname"] = "traffic_cap_" . $i . "_units_included";
                 $structure["type"] = "input";
                 $structure["options"]["width"] = "100";
                 $structure["options"]["label"] = "_units_";
                 // javascript replace with unit name
                 $this->obj_form->add_input($structure);
                 $structure = NULL;
                 $structure["fieldname"] = "traffic_cap_" . $i . "_units_price";
                 $structure["type"] = "money";
                 $structure["options"]["label"] = "_units_";
                 // javascript replace with unit name
                 $this->obj_form->add_input($structure);
                 $this->obj_form->subforms_grouped["traffic_caps"]["traffic_cap_" . $i][] = "traffic_cap_" . $i . "_active";
                 $this->obj_form->subforms_grouped["traffic_caps"]["traffic_cap_" . $i][] = "traffic_cap_" . $i . "_name";
                 $this->obj_form->subforms_grouped["traffic_caps"]["traffic_cap_" . $i][] = "traffic_cap_" . $i . "_mode";
                 $this->obj_form->subforms_grouped["traffic_caps"]["traffic_cap_" . $i][] = "traffic_cap_" . $i . "_units_included";
                 $this->obj_form->subforms_grouped["traffic_caps"]["traffic_cap_" . $i][] = "traffic_cap_" . $i . "_units_price";
                 $this->obj_form->subforms_grouped["traffic_caps"]["traffic_cap_" . $i][] = "traffic_cap_" . $i . "_id";
                 $this->obj_form->subforms["traffic_caps"][] = "traffic_cap_" . $i;
                 // fetch data caps for this service, if any
                 $obj_sql_traffic_cap = new sql_query();
                 $obj_sql_traffic_cap->string = "SELECT mode, units_price, units_included FROM `traffic_caps` WHERE id_service='" . $this->serviceid . "' AND id_traffic_type='" . $obj_sql_traffic_types->data[$i]["id"] . "' LIMIT 1";
                 $obj_sql_traffic_cap->execute();
                 if ($obj_sql_traffic_cap->num_rows()) {
                     $obj_sql_traffic_cap->fetch_array();
                     $this->obj_form->structure["traffic_cap_" . $i . "_active"]["defaultvalue"] = "on";
                     $this->obj_form->structure["traffic_cap_" . $i . "_mode"]["defaultvalue"] = $obj_sql_traffic_cap->data[0]["mode"];
                     $this->obj_form->structure["traffic_cap_" . $i . "_units_included"]["defaultvalue"] = $obj_sql_traffic_cap->data[0]["units_included"];
                     $this->obj_form->structure["traffic_cap_" . $i . "_units_price"]["defaultvalue"] = $obj_sql_traffic_cap->data[0]["units_price"];
                 }
                 unset($obj_sql_traffic_cap);
             }
             /*
             	data_traffic: Service Usage Alerts
             */
             // usage alerts
             $structure = NULL;
             $structure["fieldname"] = "alert_80pc";
             $structure["type"] = "checkbox";
             $structure["options"]["no_fieldname"] = "yes";
             $structure["options"]["label"] = "Send customers email warnings when they hit 80% of their usage";
             $this->obj_form->add_input($structure);
             $structure = NULL;
             $structure["fieldname"] = "alert_100pc";
             $structure["type"] = "checkbox";
             $structure["options"]["no_fieldname"] = "yes";
             $structure["options"]["label"] = "Send customers email warnings when they hit 100% of their usage";
             $this->obj_form->add_input($structure);
             $structure = NULL;
             $structure["fieldname"] = "alert_extraunits";
             $structure["type"] = "input";
             $this->obj_form->add_input($structure);
             // subforms
             $this->obj_form->subforms["service_plan_alerts"] = array("alert_80pc", "alert_100pc", "alert_extraunits");
             break;
         case "bundle":
             // do not offer any advance billing methods
             // general
             $structure = form_helper_prepare_radiofromdb("billing_mode", "SELECT id, name as label, description as label1 FROM billing_modes WHERE active='1' AND name NOT LIKE '%advance%'");
             $structure["options"]["req"] = "yes";
             // replace all the -- joiners with <br> for clarity
             for ($i = 0; $i < count($structure["values"]); $i++) {
                 $structure["translations"][$structure["values"][$i]] = str_replace("--", "<br><i>", $structure["translations"][$structure["values"][$i]]);
                 $structure["translations"][$structure["values"][$i]] .= "</i>";
             }
             $this->obj_form->add_input($structure);
             // subforms
             $this->obj_form->subforms["service_plan"] = array("name_service", "price", "price_setup", "discount", "billing_cycle", "billing_mode");
             break;
         case "phone_single":
         case "phone_tollfree":
         case "phone_trunk":
             /*
             	Phones services are plans that get call cost values from rate tables.
             */
             // general
             $structure = form_helper_prepare_radiofromdb("billing_mode", "SELECT id, name as label, description as label1 FROM billing_modes WHERE active='1' AND name NOT LIKE '%advance%'");
             $structure["options"]["req"] = "yes";
             // replace all the -- joiners with <br> for clarity
             for ($i = 0; $i < count($structure["values"]); $i++) {
                 $structure["translations"][$structure["values"][$i]] = str_replace("--", "<br><i>", $structure["translations"][$structure["values"][$i]]);
                 $structure["translations"][$structure["values"][$i]] .= "</i>";
             }
             $this->obj_form->add_input($structure);
             // CDR info
             $structure = NULL;
             $structure["fieldname"] = "cdr_information";
             $structure["type"] = "message";
             $structure["defaultvalue"] = "<i>For phone services, call charges are defined in rate tables - you should setup general rate tables using the \"<a href=\"index.php?page=services/cdr-rates.php\">CDR Rate Tables</a>\" page. You can over-ride certain rates using the Rate Override page in the menu above.</i>";
             $this->obj_form->add_input($structure);
             $structure = form_helper_prepare_dropdownfromdb("id_rate_table", "SELECT id, rate_table_name as label FROM cdr_rate_tables");
             $structure["options"]["req"] = "yes";
             $this->obj_form->add_input($structure);
             // DDI options
             if ($sql_plan_obj->data[0]["name"] == "phone_trunk") {
                 $structure = NULL;
                 $structure["fieldname"] = "phone_ddi_info";
                 $structure["type"] = "message";
                 $structure["defaultvalue"] = "<i>Use these fields to define the number of DDIs included in the plan as well as the cost of each DDI that a customer may want in addition of what is included with the plan.</i>";
                 $this->obj_form->add_input($structure);
                 $structure = NULL;
                 $structure["fieldname"] = "phone_ddi_included_units";
                 $structure["type"] = "input";
                 $structure["options"]["req"] = "yes";
                 $structure["defaultvalue"] = 1;
                 $this->obj_form->add_input($structure);
                 $structure = NULL;
                 $structure["fieldname"] = "phone_ddi_price_extra_units";
                 $structure["type"] = "money";
                 $this->obj_form->add_input($structure);
             }
             // trunk options
             if ($sql_plan_obj->data[0]["name"] == "phone_trunk" || $sql_plan_obj->data[0]["name"] == "phone_tollfree") {
                 $structure = NULL;
                 $structure["fieldname"] = "phone_trunk_info";
                 $structure["type"] = "message";
                 $structure["defaultvalue"] = "<i>Define the number of trunks (concurrent calls) that are included in the service, as well as the cost of each additional trunk that a customer may have.</i>";
                 $this->obj_form->add_input($structure);
                 $structure = NULL;
                 $structure["fieldname"] = "phone_trunk_included_units";
                 $structure["type"] = "input";
                 $structure["options"]["req"] = "yes";
                 $structure["defaultvalue"] = 1;
                 $this->obj_form->add_input($structure);
                 $structure = NULL;
                 $structure["fieldname"] = "phone_trunk_price_extra_units";
                 $structure["type"] = "money";
                 $this->obj_form->add_input($structure);
             }
             // subforms
             $this->obj_form->subforms["service_plan"] = array("name_service", "price", "price_setup", "discount", "billing_cycle", "billing_mode");
             $this->obj_form->subforms["service_plan_cdr"] = array("cdr_information", "id_rate_table");
             if ($sql_plan_obj->data[0]["name"] == "phone_trunk") {
                 $this->obj_form->subforms["service_plan_ddi"] = array("phone_ddi_info", "phone_ddi_included_units", "phone_ddi_price_extra_units");
             }
             if ($sql_plan_obj->data[0]["name"] == "phone_trunk" || $sql_plan_obj->data[0]["name"] == "phone_tollfree") {
                 $this->obj_form->subforms["service_plan_trunks"] = array("phone_trunk_info", "phone_trunk_included_units", "phone_trunk_price_extra_units");
             }
             break;
         case "generic_no_usage":
         default:
             // no extra fields to display
             // general
             $structure = form_helper_prepare_radiofromdb("billing_mode", "SELECT id, name as label, description as label1 FROM billing_modes WHERE active='1' AND name NOT LIKE '%telco%'");
             $structure["options"]["req"] = "yes";
             // replace all the -- joiners with <br> for clarity
             for ($i = 0; $i < count($structure["values"]); $i++) {
                 $structure["translations"][$structure["values"][$i]] = str_replace("--", "<br><i>", $structure["translations"][$structure["values"][$i]]);
                 $structure["translations"][$structure["values"][$i]] .= "</i>";
             }
             $this->obj_form->add_input($structure);
             // subforms
             $this->obj_form->subforms["service_plan"] = array("name_service", "price", "price_setup", "discount", "billing_cycle", "billing_mode");
             break;
     }
     // 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_service";
     $structure["type"] = "hidden";
     $structure["defaultvalue"] = $this->serviceid;
     $this->obj_form->add_input($structure);
     // define subforms
     $this->obj_form->subforms["hidden"] = array("id_service");
     if (user_permissions_get("services_write")) {
         $this->obj_form->subforms["submit"] = array("submit");
     } else {
         $this->obj_form->subforms["submit"] = array();
     }
     /*
     	Load Data
     */
     // load service details
     $this->obj_form->sql_query = "SELECT * FROM `services` WHERE id='" . $this->serviceid . "' LIMIT 1";
     $this->obj_form->load_data();
     // handle misconfiguration gracefully
     if (empty($this->obj_form->structure["billing_cycle"]["values"])) {
         $this->obj_form->structure["billing_cycle"]["type"] = "text";
         $this->obj_form->structure["billing_cycle"]["defaultvalue"] = "error_no_billing_cycles_available";
     }
     if ($sql_plan_obj->data[0]["name"] == "generic_with_usage") {
         if ($this->obj_form->structure["units"]["defaultvalue"] == 0) {
             $this->obj_form->structure["units"]["defaultvalue"] = "units";
         }
     }
     // load options data
     $sql_obj = new sql_query();
     $sql_obj->string = "SELECT option_name, option_value FROM services_options WHERE option_type='service' AND option_type_id='" . $this->serviceid . "'";
     $sql_obj->execute();
     if ($sql_obj->num_rows()) {
         $sql_obj->fetch_array();
         foreach ($sql_obj->data as $data_options) {
             if (isset($this->obj_form->structure[$data_options["option_name"]])) {
                 $this->obj_form->structure[$data_options["option_name"]]["defaultvalue"] = $data_options["option_value"];
             }
         }
     }
 }
Example #14
0
 function execute()
 {
     /*
     	Process Date Options
     */
     // get the start date of the week
     $this->date_selected_start = time_calculate_weekstart($this->date_selected_weekofyear, $this->date_selected_year);
     // get the dates for each day of the week
     $this->date_selected_daysofweek = time_calculate_daysofweek($this->date_selected_start);
     // get the end date of the week
     $this->date_selected_end = $this->date_selected_daysofweek[6];
     /*
     	Employee Selection Form
     */
     $this->obj_form_employee = new form_input();
     $this->obj_form_employee->formname = "timereg_employee";
     $this->obj_form_employee->language = $_SESSION["user"]["lang"];
     // 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) {
         $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"]["autoselect"] = "on";
     $structure["options"]["search_filter"] = "yes";
     $this->obj_form_employee->add_input($structure);
     // 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];
     }
     // if there is currently no employee set, and the user has configured
     // a default employeeid, automatically select that ID and update the
     // session variables
     if (!$this->employeeid && $_SESSION["user"]["default_employeeid"]) {
         $this->employeeid = $_SESSION["user"]["default_employeeid"];
         $_SESSION["form"]["timereg"]["employeeid"] = $_SESSION["user"]["default_employeeid"];
     }
     $structure["options"]["autoselect"] = "on";
     $structure["options"]["width"] = "600";
     $structure["defaultvalue"] = $this->employeeid;
     $this->obj_form_employee->add_input($structure);
     // hidden values
     $structure = NULL;
     $structure["fieldname"] = "page";
     $structure["type"] = "hidden";
     $structure["defaultvalue"] = $_GET["page"];
     $this->obj_form_employee->add_input($structure);
     $structure = NULL;
     $structure["fieldname"] = "weekofyear";
     $structure["type"] = "hidden";
     $structure["defaultvalue"] = $this->date_selected_weekofyear;
     $this->obj_form_employee->add_input($structure);
     $structure = NULL;
     $structure["fieldname"] = "year";
     $structure["type"] = "hidden";
     $structure["defaultvalue"] = $this->date_selected_year;
     $this->obj_form_employee->add_input($structure);
     // submit button
     $structure = NULL;
     $structure["fieldname"] = "submit";
     $structure["type"] = "submit";
     $structure["defaultvalue"] = "Display";
     $this->obj_form_employee->add_input($structure);
     if ($this->employeeid) {
         /*
         	DEFINE WEEK TABLE
         	
         	We need to create a table showing all time booked for the currently
         	selected week.
         
         	1. Get a list of all project from the database that had time booked against
         	   them this week.
         
         	2. Fetch total time spent on each project, for each day.
         
         	3. Display into a table, with easy edit + add links.
         */
         // establish a new table object
         $this->obj_table_week = new table();
         $this->obj_table_week->language = $_SESSION["user"]["lang"];
         $this->obj_table_week->tablename = "timereg_list";
         // define all the columns and structure
         $this->obj_table_week->add_column("standard", "projectandphase", "");
         $this->obj_table_week->add_column("hourmins", "monday", "");
         $this->obj_table_week->add_column("hourmins", "tuesday", "");
         $this->obj_table_week->add_column("hourmins", "wednesday", "");
         $this->obj_table_week->add_column("hourmins", "thursday", "");
         $this->obj_table_week->add_column("hourmins", "friday", "");
         $this->obj_table_week->add_column("hourmins", "saturday", "");
         $this->obj_table_week->add_column("hourmins", "sunday", "");
         // defaults
         $this->obj_table_week->columns = array("projectandphase", "monday", "tuesday", "wednesday", "thursday", "friday", "saturday", "sunday");
         // totals
         $this->obj_table_week->total_columns = array("monday", "tuesday", "wednesday", "thursday", "friday", "saturday", "sunday");
         $this->obj_table_week->total_rows = array("monday", "tuesday", "wednesday", "thursday", "friday", "saturday", "sunday");
         // define SQL structure
         $this->obj_table_week->sql_obj->prepare_sql_settable("timeregs");
         // map dates to day of the week
         $days[$this->date_selected_daysofweek[0]] = "monday";
         $days[$this->date_selected_daysofweek[1]] = "tuesday";
         $days[$this->date_selected_daysofweek[2]] = "wednesday";
         $days[$this->date_selected_daysofweek[3]] = "thursday";
         $days[$this->date_selected_daysofweek[4]] = "friday";
         $days[$this->date_selected_daysofweek[5]] = "saturday";
         $days[$this->date_selected_daysofweek[6]] = "sunday";
         /*
         	Fetch the data
         
         	This step is too complete to use the automatic SQL generation code in the tables class. What we need to do is:
         	 1. Fetch each phase ID for the day
         	 2. Create a combined project/phase name value
         	 3. Total up all time spent on that project/phase for the day
         	 4. Add the data to the $timereg->data[$rowid]["columnname"] structure.
         	 5. Draw the table using render_table()
         */
         $phasearray = array();
         // 1. Fetch each phase ID for the day
         // create the query
         $sql_obj = new sql_query();
         $sql_obj->string = "SELECT " . "phaseid " . "FROM `timereg` " . "WHERE employeeid='" . $this->employeeid . "' " . "AND date >= '" . $this->date_selected_start . "' " . "AND date <= '" . $this->date_selected_end . "'";
         // fetch the data
         log_debug("timereg", "Fetching all phase IDs for bookings in the week");
         $sql_obj->execute();
         // process any results
         if ($sql_obj->num_rows()) {
             $sql_obj->fetch_array();
             foreach ($sql_obj->data as $data) {
                 // create an array of all the phase ids, without any duplicates
                 if (!in_array($data["phaseid"], $phasearray)) {
                     $phasearray[] = $data["phaseid"];
                 }
             }
         }
         $this->obj_table_week->data_num_rows = count($phasearray);
         // we have all the phases/projects that have been booked for the day (if any).
         // we now run through them...
         foreach ($phasearray as $phaseid) {
             $tmparray = NULL;
             // 2. Fetch the project and phase name values
             // create the query
             $sql_obj = new sql_query();
             $sql_obj->string = "SELECT " . "project_phases.name_phase, " . "projects.name_project, " . "projects.code_project " . "FROM project_phases " . "LEFT JOIN projects ON project_phases.projectid = projects.id " . "WHERE project_phases.id='{$phaseid}'";
             // fetch the data
             log_debug("timereg", "Fetching project and phase name values for phase {$phaseid}");
             $sql_obj->execute();
             // process the name data
             $sql_obj->fetch_array();
             foreach ($sql_obj->data as $data) {
                 $tmparray["projectandphase"] = $data["code_project"] . " -- " . $data["name_project"] . " - " . $data["name_phase"];
             }
             // 3. Total up all time spent on that project/phase for the day
             // create the query
             $sql_obj = new sql_query();
             $sql_obj->string = "SELECT " . "date, " . "time_booked " . "FROM timereg " . "WHERE employeeid='" . $this->employeeid . "' " . "AND date >= '" . $this->date_selected_start . "' " . "AND date <= '" . $this->date_selected_end . "' " . "AND phaseid='{$phaseid}'";
             // fetch the data
             log_debug("timereg", "Fetching all hours for phase {$phaseid}");
             $sql_obj->execute();
             // process the data
             $sql_obj->fetch_array();
             foreach ($sql_obj->data as $data) {
                 @($tmparray[$days[$data["date"]]] += $data["time_booked"]);
             }
             // 4. Add the data to the table data structure to allow rendering
             $this->obj_table_week->data[] = $tmparray;
         }
     }
     // valid employee selected for viewing
     /*
     	Date GOTO form
     */
     $this->obj_form_goto = new form_input();
     $this->obj_form_goto->formname = "timereg_goto";
     $this->obj_form_goto->language = $_SESSION["user"]["lang"];
     $structure = NULL;
     $structure["fieldname"] = "date";
     $structure["type"] = "date";
     $structure["defaultvalue"] = date("Y-m-d");
     $this->obj_form_goto->add_input($structure);
     $structure = NULL;
     $structure["fieldname"] = "page";
     $structure["type"] = "hidden";
     $structure["defaultvalue"] = "timekeeping/timereg-day.php";
     $this->obj_form_goto->add_input($structure);
     // submit button
     $structure = NULL;
     $structure["fieldname"] = "submit";
     $structure["type"] = "submit";
     $structure["defaultvalue"] = "Goto Date";
     $this->obj_form_goto->add_input($structure);
 }
Example #15
0
 function execute()
 {
     /*
     	Define form structure
     */
     $this->obj_form = new form_input();
     $this->obj_form->formname = "transaction_view";
     $this->obj_form->language = $_SESSION["user"]["lang"];
     $this->obj_form->action = "accounts/gl/edit-process.php";
     $this->obj_form->method = "post";
     // general
     $structure = NULL;
     $structure["fieldname"] = "code_gl";
     $structure["type"] = "input";
     $this->obj_form->add_input($structure);
     $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);
     $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";
     $this->obj_form->add_input($structure);
     $structure = NULL;
     $structure["fieldname"] = "description";
     $structure["type"] = "input";
     $structure["options"]["width"] = "600";
     $this->obj_form->add_input($structure);
     $structure = NULL;
     $structure["fieldname"] = "description_useall";
     $structure["type"] = "checkbox";
     $structure["options"]["label"] = "Check this to use the description above as the description in all the rows below. Untick if you wish to have different messages for each transaction item.";
     $structure["defaultvalue"] = "on";
     $this->obj_form->add_input($structure);
     $structure = NULL;
     $structure["fieldname"] = "notes";
     $structure["type"] = "textarea";
     $structure["options"]["width"] = "600";
     $structure["options"]["height"] = "50";
     $this->obj_form->add_input($structure);
     /*
     	Define transaction form structure
     */
     // unless there has been error data returned, fetch all the transactions
     // from the DB, and work out the number of rows
     if (!isset($_SESSION["error"]["form"][$this->obj_form->formname])) {
         $sql_trans_obj = new sql_query();
         $sql_trans_obj->string = "SELECT date_trans, amount_debit, amount_credit, chartid, source, memo FROM `account_trans` WHERE type='gl' AND customid='" . $this->id . "'";
         $sql_trans_obj->execute();
         if ($sql_trans_obj->num_rows()) {
             $sql_trans_obj->fetch_array();
             $this->num_trans = $sql_trans_obj->data_num_rows + 1;
         }
     } else {
         $this->num_trans = @security_script_input('/^[0-9]*$/', $_SESSION["error"]["num_trans"]) + 1;
     }
     // ensure there are always 2 rows at least, additional rows are added if required (ie viewing
     // an existing transaction) or on the fly when needed by javascript UI.
     if ($this->num_trans < 2) {
         $this->num_trans = 2;
     }
     // transaction rows
     for ($i = 0; $i < $this->num_trans; $i++) {
         // account
         $structure = form_helper_prepare_dropdownfromdb("trans_" . $i . "_account", "SELECT id, code_chart as label, description as label1 FROM account_charts WHERE chart_type!='1' ORDER BY code_chart");
         $structure["options"]["width"] = "200";
         $this->obj_form->add_input($structure);
         // debit field
         $structure = NULL;
         $structure["fieldname"] = "trans_" . $i . "_debit";
         $structure["type"] = "input";
         $structure["options"]["width"] = "80";
         $this->obj_form->add_input($structure);
         // credit field
         $structure = NULL;
         $structure["fieldname"] = "trans_" . $i . "_credit";
         $structure["type"] = "input";
         $structure["options"]["width"] = "80";
         $this->obj_form->add_input($structure);
         // source
         $structure = NULL;
         $structure["fieldname"] = "trans_" . $i . "_source";
         $structure["type"] = "input";
         $structure["options"]["width"] = "100";
         $this->obj_form->add_input($structure);
         // description
         $structure = NULL;
         $structure["fieldname"] = "trans_" . $i . "_description";
         $structure["type"] = "textarea";
         $this->obj_form->add_input($structure);
         // if we have data from a sql query, load it in
         if ($sql_trans_obj->data_num_rows) {
             if (isset($sql_trans_obj->data[$i]["chartid"])) {
                 $this->obj_form->structure["trans_" . $i . "_debit"]["defaultvalue"] = $sql_trans_obj->data[$i]["amount_debit"];
                 $this->obj_form->structure["trans_" . $i . "_credit"]["defaultvalue"] = $sql_trans_obj->data[$i]["amount_credit"];
                 $this->obj_form->structure["trans_" . $i . "_account"]["defaultvalue"] = $sql_trans_obj->data[$i]["chartid"];
                 $this->obj_form->structure["trans_" . $i . "_source"]["defaultvalue"] = $sql_trans_obj->data[$i]["source"];
                 $this->obj_form->structure["trans_" . $i . "_description"]["defaultvalue"] = $sql_trans_obj->data[$i]["memo"];
             }
         }
     }
     // total fields
     $structure = NULL;
     $structure["fieldname"] = "total_debit";
     $structure["type"] = "hidden";
     $this->obj_form->add_input($structure);
     $structure = NULL;
     $structure["fieldname"] = "total_credit";
     $structure["type"] = "hidden";
     $this->obj_form->add_input($structure);
     $structure = NULL;
     $structure["fieldname"] = "money_format";
     $structure["type"] = "hidden";
     $structure["defaultvalue"] = format_money(0);
     $this->obj_form->add_input($structure);
     // hidden
     $structure = NULL;
     $structure["fieldname"] = "id_transaction";
     $structure["type"] = "hidden";
     $structure["defaultvalue"] = $this->id;
     $this->obj_form->add_input($structure);
     $structure = NULL;
     $structure["fieldname"] = "num_trans";
     $structure["type"] = "hidden";
     $structure["defaultvalue"] = "{$this->num_trans}";
     $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);
     // fetch the general form data
     $this->obj_form->sql_query = "SELECT * FROM `account_gl` WHERE id='" . $this->id . "' LIMIT 1";
     $this->obj_form->load_data();
     // calculate totals
     for ($i = 0; $i < $this->num_trans; $i++) {
         @($this->obj_form->structure["total_debit"]["defaultvalue"] += $this->obj_form->structure["trans_" . $i . "_debit"]["defaultvalue"]);
         @($this->obj_form->structure["total_credit"]["defaultvalue"] += $this->obj_form->structure["trans_" . $i . "_credit"]["defaultvalue"]);
     }
 }
Example #16
0
 function execute()
 {
     /*
     	Define form structure
     */
     $this->obj_form = new form_input();
     $this->obj_form->formname = "customer_view";
     $this->obj_form->language = $_SESSION["user"]["lang"];
     $this->obj_form->action = "customers/edit-process.php";
     $this->obj_form->method = "post";
     // general
     $structure = NULL;
     $structure["fieldname"] = "code_customer";
     $structure["type"] = "input";
     $structure["options"]["req"] = "yes";
     $this->obj_form->add_input($structure);
     $structure = NULL;
     $structure["fieldname"] = "name_customer";
     $structure["type"] = "input";
     $structure["options"]["req"] = "yes";
     $this->obj_form->add_input($structure);
     $structure = NULL;
     $structure["fieldname"] = "date_start";
     $structure["type"] = "date";
     $structure["options"]["req"] = "yes";
     $this->obj_form->add_input($structure);
     $structure = NULL;
     $structure["fieldname"] = "date_end";
     $structure["type"] = "date";
     $this->obj_form->add_input($structure);
     //contacts
     // this should be replaced with load_data_contacts in some point in the future.
     $sql_contacts_obj = new sql_query();
     $sql_contacts_obj->string = "SELECT id, role, contact, description FROM customer_contacts WHERE customer_id = " . $this->id;
     $sql_contacts_obj->execute();
     $sql_contacts_obj->fetch_array();
     if (!empty($_SESSION["error"]["num_contacts"])) {
         $this->num_contacts = stripslashes($_SESSION["error"]["num_contacts"]);
     } else {
         if ($sql_contacts_obj->num_rows()) {
             $this->num_contacts = $sql_contacts_obj->num_rows();
         } else {
             $this->num_contacts = 0;
         }
     }
     $structure = NULL;
     $structure["fieldname"] = "num_contacts";
     $structure["type"] = "hidden";
     $structure["defaultvalue"] = $this->num_contacts;
     $this->obj_form->add_input($structure);
     for ($i = 0; $i < $this->num_contacts; $i++) {
         $structure = NULL;
         $structure["fieldname"] = "contact_id_" . $i;
         $structure["type"] = "hidden";
         $structure["defaultvalue"] = $sql_contacts_obj->data[$i]["id"];
         $this->obj_form->add_input($structure);
         $structure = NULL;
         $structure["fieldname"] = "delete_contact_" . $i;
         $structure["type"] = "hidden";
         $structure["defaultvalue"] = "false";
         $this->obj_form->add_input($structure);
         $structure = NULL;
         $structure["fieldname"] = "contact_" . $i;
         $structure["type"] = "input";
         $structure["defaultvalue"] = $sql_contacts_obj->data[$i]["contact"];
         if (isset($_SESSION["error"]["contact_" . $i . "-error"])) {
             $structure["options"]["css_field_class"] = "hidden_form_field_error";
         } else {
             $structure["options"]["css_field_class"] = "hidden_form_field";
         }
         $structure["options"]["width"] = "200";
         $this->obj_form->add_input($structure);
         $structure = NULL;
         $structure["fieldname"] = "role_" . $i;
         $structure["type"] = "dropdown";
         $structure["defaultvalue"] = $sql_contacts_obj->data[$i]["role"];
         $structure["options"]["width"] = "205";
         if ($i == 0) {
             $structure["values"] = array("accounts");
             $structure["options"]["autoselect"] = "yes";
             $structure["options"]["disabled"] = "yes";
         } else {
             $structure["values"] = array("other");
             $structure["options"]["autoselect"] = "yes";
         }
         if (isset($_SESSION["error"]["contact_" . $i . "-error"])) {
             $structure["options"]["css_field_class"] = "hidden_form_field_error";
         } else {
             $structure["options"]["css_field_class"] = "hidden_form_field";
         }
         $this->obj_form->add_input($structure);
         $structure = NULL;
         $structure["fieldname"] = "description_" . $i;
         $structure["type"] = "textarea";
         $structure["defaultvalue"] = $sql_contacts_obj->data[$i]["description"];
         if (isset($_SESSION["error"]["contact_" . $i . "-error"])) {
             $structure["options"]["css_field_class"] = "hidden_form_field_error";
         } else {
             $structure["options"]["css_field_class"] = "hidden_form_field";
         }
         $structure["options"]["width"] = "205";
         $structure["options"]["height"] = "";
         $this->obj_form->add_input($structure);
         //contact records
         $sql_records_obj = new sql_query();
         if (!empty($sql_contacts_obj->data[$i]["id"])) {
             $sql_records_obj->string = "SELECT id, type, label, detail FROM customer_contact_records WHERE contact_id= " . $sql_contacts_obj->data[$i]["id"] . " ORDER BY type";
             $sql_records_obj->execute();
             $sql_records_obj->fetch_array();
         }
         if (!empty($_SESSION["error"]["num_records_{$i}"])) {
             $num_records = stripslashes($_SESSION["error"]["num_records_{$i}"]);
         } else {
             if ($sql_records_obj->num_rows()) {
                 $num_records = $sql_records_obj->num_rows();
             } else {
                 $num_records = 0;
             }
         }
         $structure = NULL;
         $structure["fieldname"] = "num_records_" . $i;
         $structure["type"] = "hidden";
         $structure["defaultvalue"] = $num_records;
         $this->obj_form->add_input($structure);
         if ($num_records > 0) {
             for ($j = 0; $j < $num_records; $j++) {
                 $structure = NULL;
                 $structure["fieldname"] = "contact_" . $i . "_record_id_" . $j;
                 $structure["type"] = "hidden";
                 $structure["defaultvalue"] = $sql_records_obj->data[$j]["id"];
                 $this->obj_form->add_input($structure);
                 $structure = NULL;
                 $structure["fieldname"] = "contact_" . $i . "_delete_" . $j;
                 $structure["type"] = "hidden";
                 $structure["defaultvalue"] = "false";
                 $this->obj_form->add_input($structure);
                 $structure = NULL;
                 $structure["fieldname"] = "contact_" . $i . "_type_" . $j;
                 $structure["type"] = "hidden";
                 $structure["defaultvalue"] = $sql_records_obj->data[$j]["type"];
                 $this->obj_form->add_input($structure);
                 $structure = NULL;
                 $structure["fieldname"] = "contact_" . $i . "_label_" . $j;
                 $structure["type"] = "hidden";
                 $structure["defaultvalue"] = $sql_records_obj->data[$j]["label"];
                 $this->obj_form->add_input($structure);
                 $structure = NULL;
                 $structure["fieldname"] = "contact_" . $i . "_detail_" . $j;
                 $structure["type"] = "input";
                 $structure["defaultvalue"] = $sql_records_obj->data[$j]["detail"];
                 $structure["options"]["width"] = "";
                 $this->obj_form->add_input($structure);
             }
         }
     }
     // taxes
     $structure = NULL;
     $structure["fieldname"] = "tax_number";
     $structure["type"] = "input";
     $this->obj_form->add_input($structure);
     $structure = NULL;
     $structure = form_helper_prepare_dropdownfromdb("tax_default", "SELECT id, name_tax as label FROM account_taxes");
     $this->obj_form->add_input($structure);
     // list all the taxes so the user can enable or disable the taxes
     $sql_tax_obj = new sql_query();
     $sql_tax_obj->string = "SELECT id, name_tax, description FROM account_taxes ORDER BY name_tax";
     $sql_tax_obj->execute();
     if ($sql_tax_obj->num_rows()) {
         // user note
         $structure = NULL;
         $structure["fieldname"] = "tax_message";
         $structure["type"] = "message";
         $structure["defaultvalue"] = "<p>Select all the taxes below which apply to this customer. Any taxes not selected, will not be added to invoices for this customer.</p>";
         $this->obj_form->add_input($structure);
         // fetch customer's current tax status
         if (!isset($_SESSION["error"]["message"])) {
             $sql_customer_taxes_obj = new sql_query();
             $sql_customer_taxes_obj->string = "SELECT taxid FROM customers_taxes WHERE customerid='" . $this->id . "'";
             $sql_customer_taxes_obj->execute();
             if ($sql_customer_taxes_obj->num_rows()) {
                 $sql_customer_taxes_obj->fetch_array();
             }
         }
         // 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";
             // check if this tax is currently checked
             if ($sql_customer_taxes_obj->data_num_rows) {
                 foreach ($sql_customer_taxes_obj->data as $data) {
                     if ($data["taxid"] == $data_tax["id"]) {
                         $structure["defaultvalue"] = "on";
                     }
                 }
             }
             // add to form
             $this->obj_form->add_input($structure);
             $this->tax_array[] = "tax_" . $data_tax["id"];
         }
     } else {
         $structure = NULL;
         $structure["fieldname"] = "tax_message";
         $structure["type"] = "message";
         $structure["defaultvalue"] = "<p>No taxes can be selected for this customer, as there have been no taxes configured yet.</p>";
         $this->obj_form->add_input($structure);
     }
     // purchase options
     $structure = NULL;
     $structure["fieldname"] = "discount";
     $structure["type"] = "input";
     $structure["options"]["width"] = 50;
     $structure["options"]["label"] = " %";
     $structure["options"]["max_length"] = "6";
     $this->obj_form->add_input($structure);
     // billing address
     $structure = NULL;
     $structure["fieldname"] = "address1_street";
     $structure["type"] = "textarea";
     $this->obj_form->add_input($structure);
     $structure = NULL;
     $structure["fieldname"] = "address1_city";
     $structure["type"] = "input";
     $this->obj_form->add_input($structure);
     $structure = NULL;
     $structure["fieldname"] = "address1_state";
     $structure["type"] = "input";
     $this->obj_form->add_input($structure);
     $structure = NULL;
     $structure["fieldname"] = "address1_country";
     $structure["type"] = "input";
     $this->obj_form->add_input($structure);
     $structure = NULL;
     $structure["fieldname"] = "address1_zipcode";
     $structure["type"] = "input";
     $this->obj_form->add_input($structure);
     // shipping address
     $structure = NULL;
     $structure["fieldname"] = "address1_same_as_2";
     $structure["type"] = "checkbox";
     $structure["options"]["label"] = " " . lang_trans("address1_same_as_2_help");
     $structure["options"]["css_row_class"] = "shipping_same_address";
     $this->obj_form->add_input($structure);
     $structure = NULL;
     $structure["fieldname"] = "address2_street";
     $structure["type"] = "textarea";
     $structure["options"]["css_row_class"] = "shipping_address";
     $this->obj_form->add_input($structure);
     $structure = NULL;
     $structure["fieldname"] = "address2_city";
     $structure["type"] = "input";
     $structure["options"]["css_row_class"] = "shipping_address";
     $this->obj_form->add_input($structure);
     $structure = NULL;
     $structure["fieldname"] = "address2_state";
     $structure["type"] = "input";
     $structure["options"]["css_row_class"] = "shipping_address";
     $this->obj_form->add_input($structure);
     $structure = NULL;
     $structure["fieldname"] = "address2_country";
     $structure["type"] = "input";
     $structure["options"]["css_row_class"] = "shipping_address";
     $this->obj_form->add_input($structure);
     $structure = NULL;
     $structure["fieldname"] = "address2_zipcode";
     $structure["type"] = "input";
     $structure["options"]["css_row_class"] = "shipping_address";
     $this->obj_form->add_input($structure);
     // billing options
     $structure = NULL;
     $structure["fieldname"] = "billing_method";
     $structure["type"] = "radio";
     $structure["values"] = array("manual", "direct debit");
     //, "credit card");
     $structure["defaultvalue"] = "standalone";
     $structure["options"]["css_row_class"] = "billing_method";
     $this->obj_form->add_input($structure);
     $structure = NULL;
     $structure["fieldname"] = "billing_direct_debit";
     $structure["type"] = "input";
     $structure["options"]["css_row_class"] = "billing_direct_debit";
     $this->obj_form->add_input($structure);
     // reseller options
     $structure = NULL;
     $structure["fieldname"] = "reseller_customer";
     $structure["type"] = "radio";
     $structure["values"] = array("standalone", "reseller", "customer_of_reseller");
     $structure["defaultvalue"] = "standalone";
     $structure["options"]["css_row_class"] = "reseller_customer";
     $this->obj_form->add_input($structure);
     $structure = NULL;
     $structure = form_helper_prepare_dropdownfromdb("reseller_id", "SELECT id, code_customer as label, name_customer as label1 FROM customers WHERE reseller_customer = 'reseller' AND id <> " . $this->id);
     $this->obj_form->add_input($structure);
     $structure = NULL;
     $structure["fieldname"] = "reseller_message";
     $structure["type"] = "message";
     $structure["defaultvalue"] = "<p>Each customer in the system can either be classified for the Reseller Options as either a standalone customer, a reseller to other customers, or as a customer of a reseller. By default new customers are standalone.</p>";
     $this->obj_form->add_input($structure);
     // submit section
     if (user_permissions_get("customers_write")) {
         $structure = NULL;
         $structure["fieldname"] = "submit";
         $structure["type"] = "submit";
         $structure["defaultvalue"] = "Save Changes";
         $this->obj_form->add_input($structure);
     }
     // hidden
     $structure = NULL;
     $structure["fieldname"] = "id_customer";
     $structure["type"] = "hidden";
     $structure["defaultvalue"] = $this->id;
     $this->obj_form->add_input($structure);
     // fetch the form data
     $this->obj_form->sql_query = "SELECT * FROM `customers` WHERE id='" . $this->id . "' LIMIT 1";
     $this->obj_form->load_data();
 }
Example #17
0
 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
     $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 \n\t\t\t\t\t\t\t\t\t\t\tprojects.code_project as label,\n\t\t\t\t\t\t\t\t\t\t\tprojects.name_project as label1,\n\t\t\t\t\t\t\t\t\t\t\tproject_phases.id as id, \n\t\t\t\t\t\t\t\t\t\t\tproject_phases.name_phase as label1\n\t\t\t\t\t\t\t\t\t\tFROM `projects` \n\t\t\t\t\t\t\t\t\t\tLEFT JOIN project_phases ON project_phases.projectid = projects.id\n\t\t\t\t\t\t\t\t\t\tWHERE\n\t\t\t\t\t\t\t\t\t\t\tprojects.internal_only='0'\n\t\t\t\t\t\t\t\t\t\tORDER BY\n\t\t\t\t\t\t\t\t\t\t\tprojects.name_project,\n\t\t\t\t\t\t\t\t\t\t\tproject_phases.name_phase");
     $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"] = "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);
     $structure = NULL;
     $structure["fieldname"] = "groupby";
     $structure["type"] = "radio";
     $structure["values"] = array("none", "name_phase", "name_staff");
     $structure["defaultvalue"] = "none";
     $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();
     // add group by options
     if ($this->obj_table->filter["filter_groupby"]["defaultvalue"] != "none") {
         $this->obj_table->sql_obj->prepare_sql_addgroupby($this->obj_table->filter["filter_groupby"]["defaultvalue"]);
         // replace timereg value with SUM query
         $this->obj_table->structure["time_booked"]["dbname"] = "SUM(timereg.time_booked)";
         switch ($this->obj_table->filter["filter_groupby"]["defaultvalue"]) {
             case "name_staff":
                 $this->obj_table->columns = array("name_staff", "time_booked");
                 $this->obj_table->columns_order = array();
                 $this->obj_table->columns_order_options = array("name_staff");
                 break;
             case "name_phase":
                 $this->obj_table->columns = array("name_phase", "time_booked");
                 $this->obj_table->columns_order = array();
                 $this->obj_table->columns_order_options = array("name_phase");
                 break;
         }
     }
     // generate & execute SQL query	(only if time entries exist)
     $this->obj_table->generate_sql();
     if ($unbilled_ids_count) {
         $this->obj_table->load_data_sql();
     }
     // delete any rows which belong to processed time groups
     for ($i = 0; $i < $this->obj_table->data_num_rows; $i++) {
         if ($this->obj_table->data[$i]["timegroupinvoiceid"]) {
             $this->obj_table->data[$i] = NULL;
         }
     }
 }
Example #18
0
 function execute()
 {
     /*
      * Validate a POST (page navigation move will prompt this)
      */
     if (isset($_POST['record_custom_page'])) {
         // fetch data from POST and validate - we then return values
         $data = stripslashes_deep($this->obj_domain->validate_custom_records());
         // validate the record_custom_page for returning the user to their page, default to page 1 if any errors in validating...
         $data['record_custom_page'] = @security_form_input_predefined("int", "record_custom_page", 1, "");
         /*
         			echo '<tr><td colspan="100%">post-validation POST data<pre>'; 
         			echo '<pre>';
         			print_R($data);
         			echo '</pre>';
         			echo '</td></tr>';
         			die("debug");
         */
         if (error_check()) {
             log_write("debug", "records-ajax", "POST records provided but error encountered, failing");
             $_SESSION["error"]["form"]["domain_records"] = "failed";
             $this->page = $data['record_custom_page'];
         } else {
             // no errors... set the records to the session
             $_SESSION['form']['domain_records'][$this->obj_domain->id][$data['record_custom_page']] = $data['records'];
         }
     }
     /*
     	Load domain data & records
     */
     $this->num_records_custom_total = $this->obj_domain->data_record_custom_count();
     $this->obj_domain->load_data();
     // if the data is present in the session then it has either changed and is awaiting submission
     // or the user has visited that page before during this edit session
     if (isset($_SESSION['form']['domain_records'][$this->obj_domain->id][$this->page]) && count($_SESSION['form']['domain_records'][$this->obj_domain->id][$this->page])) {
         log_debug("execute", 'Loading records from session as previous load or edit detected');
         $this->obj_domain->data['records'] = $_SESSION['form']['domain_records'][$this->obj_domain->id][$this->page];
         /*
         echo '<tr><td colspan="100%">from sesssion<pre>';
         print_R($this->obj_domain->data['records']);
         echo '</td></tr>';
         */
     } else {
         log_debug("execute", 'Loading records from db for page: ' . $this->page);
         $this->obj_domain->load_data_record_custom($this->offset, $GLOBALS["config"]['PAGINATION_DOMAIN_RECORDS']);
         /*
         echo '<tr><td colspan="100%">from db<pre>';
         print_R($this->obj_domain->data['records']);
         echo '</td></tr>';
         */
     }
     // work out the IP for reverse domains
     if (strpos($this->obj_domain->data["domain_name"], "in-addr.arpa")) {
         // IPv4
         $ip = explode(".", $this->obj_domain->data["domain_name"]);
         $this->obj_domain->data["domain_ip_prefix"] = $ip[2] . "." . $ip[1] . "." . $ip[0];
     } elseif (strpos($this->obj_domain->data["domain_name"], "ip6.arpa")) {
         // IPv6
         $ip_reverse = substr($this->obj_domain->data["domain_name"], 0, strlen($this->obj_domain->data["domain_name"]) - 9);
         $ip_array = array();
         $i = 0;
         foreach (array_reverse(explode(".", $ip_reverse)) as $ip) {
             $i++;
             $ip_array[] = $ip;
             if ($i == 4) {
                 $i = 0;
                 $ip_array[] = ":";
             }
         }
         $this->obj_domain->data["domain_ip_prefix"] = implode("", $ip_array);
     }
     /*
     	Define form structure
     */
     $this->obj_form = new form_input();
     $this->obj_form->formname = "domain_records";
     $this->obj_form->language = $_SESSION["user"]["lang"];
     $this->obj_form->action = "domains/records-process.php";
     $this->obj_form->method = "post";
     /*
     	General Domain Info
     */
     $structure = NULL;
     $structure["fieldname"] = "domain_name";
     $structure["type"] = "message";
     $structure["options"]["css_row_class"] = "table_highlight";
     $structure["defaultvalue"] = "<p><b>Domain " . $this->obj_domain->data["domain_name"] . " selected for adjustment</b></p>";
     $this->obj_form->add_input($structure);
     /*
     	Define stucture for all other record types
     
     	This includes A, AAAA, PTR and other record types.
     */
     // fetch all the known record types from the database
     $dns_record_types = sql_get_singlecol("SELECT type as value FROM `dns_record_types` WHERE user_selectable='1'");
     // unless there has been error data returned, fetch all the records
     // and work out the number of rows
     if (!isset($_SESSION["error"]["form"][$this->obj_form->formname])) {
         $this->num_records_custom = 1;
         foreach ($this->obj_domain->data["records"] as $record) {
             if (in_array($record["type"], $dns_record_types)) {
                 $this->num_records_custom++;
             }
         }
     } else {
         $this->num_records_custom = @security_script_input('/^[0-9]*$/', $_SESSION["error"]["num_records_custom"]);
     }
     // ensure there are at least two rows, if more are needed when entering information,
     // then the javascript functions will provide.
     if ($this->num_records_custom < 2) {
         $this->num_records_custom = 2;
     }
     // custom domain records
     for ($i = 0; $i < $this->num_records_custom; $i++) {
         // values
         $structure = NULL;
         $structure["fieldname"] = "record_custom_" . $i . "_id";
         $structure["type"] = "hidden";
         $this->obj_form->add_input($structure);
         if (strpos($this->obj_domain->data["domain_name"], "arpa")) {
             $structure = NULL;
             $structure["fieldname"] = "record_custom_" . $i . "_type";
             $structure["type"] = "text";
             $structure["defaultvalue"] = "PTR";
             $this->obj_form->add_input($structure);
         } else {
             $structure = form_helper_prepare_dropdownfromdb("record_custom_" . $i . "_type", "SELECT type as label, type as id FROM `dns_record_types` WHERE user_selectable='1' AND is_standard='1'");
             $structure["defaultvalue"] = "A";
             $structure["options"]["width"] = "100";
             $this->obj_form->add_input($structure);
         }
         $structure = NULL;
         $structure["fieldname"] = "record_custom_" . $i . "_name";
         $structure["type"] = "input";
         if (strpos($this->obj_domain->data["domain_name"], "in-addr.arpa")) {
             $structure["options"]["width"] = "50";
             $structure["options"]["max_length"] = "3";
             $structure["options"]["prelabel"] = $this->obj_domain->data["domain_ip_prefix"] . ". ";
             $structure["options"]["help"] = "?";
         } elseif (strpos($this->obj_domain->data["domain_name"], "ip6.arpa")) {
             $structure["options"]["width"] = "300";
             $structure["options"]["prelabel"] = " ";
             $structure["options"]["help"] = $this->obj_domain->data["domain_ip_prefix"] . "....";
             $structure["options"]["autofill"] = $this->obj_domain->data["domain_ip_prefix"];
         } else {
             $structure["options"]["width"] = "300";
             $structure["options"]["help"] = "Record name, eg www";
         }
         $this->obj_form->add_input($structure);
         $structure = NULL;
         $structure["fieldname"] = "record_custom_" . $i . "_content";
         $structure["type"] = "input";
         $structure["options"]["width"] = "300";
         if (strpos($this->obj_domain->data["domain_name"], "arpa")) {
             // both IPv4 and IPv6
             $structure["options"]["help"] = "Reverse record name, eg www.example.com";
         } else {
             $structure["options"]["help"] = "Target IP, eg 192.168.0.1";
         }
         $this->obj_form->add_input($structure);
         $structure = NULL;
         $structure["fieldname"] = "record_custom_" . $i . "_ttl";
         $structure["type"] = "input";
         $structure["options"]["width"] = "80";
         $structure["defaultvalue"] = $this->obj_domain->data["soa_default_ttl"];
         $this->obj_form->add_input($structure);
         $structure = NULL;
         $structure["fieldname"] = "record_custom_" . $i . "_delete_undo";
         $structure["type"] = "hidden";
         $structure["defaultvalue"] = "false";
         $this->obj_form->add_input($structure);
         if (!strpos($this->obj_domain->data["domain_name"], "arpa")) {
             $structure = NULL;
             $structure["fieldname"] = "record_custom_" . $i . "_reverse_ptr";
             $structure["type"] = "checkbox";
             $structure["options"]["label"] = "";
             $this->obj_form->add_input($structure);
             $structure = NULL;
             $structure["fieldname"] = "record_custom_" . $i . "_reverse_ptr_orig";
             $structure["type"] = "hidden";
             $this->obj_form->add_input($structure);
         }
     }
     // load in what data we have
     //disable invalid fields
     $i = 0;
     foreach ($this->obj_domain->data["records"] as $record) {
         if (in_array($record["type"], $dns_record_types)) {
             // special ID rules
             if ($record["id"]) {
                 $this->obj_form->structure["record_custom_" . $i . "_id"]["defaultvalue"] = $record["id"];
             } else {
                 $this->obj_form->structure["record_custom_" . $i . "_id"]["defaultvalue"] = $record["id_record"];
             }
             // fetch data
             $this->obj_form->structure["record_custom_" . $i . "_type"]["defaultvalue"] = $record["type"];
             $this->obj_form->structure["record_custom_" . $i . "_prio"]["defaultvalue"] = $record["prio"];
             $this->obj_form->structure["record_custom_" . $i . "_name"]["defaultvalue"] = $record["name"];
             $this->obj_form->structure["record_custom_" . $i . "_content"]["defaultvalue"] = $record["content"];
             $this->obj_form->structure["record_custom_" . $i . "_ttl"]["defaultvalue"] = $record["ttl"];
             if ($record["type"] == "CNAME") {
                 // disable inappropate values for CNAME fields
                 $this->obj_form->structure["record_custom_" . $i . "_reverse_ptr"]["options"]["disabled"] = "yes";
                 $this->obj_form->structure["record_custom_" . $i . "_reverse_ptr_orig"]["options"]["disabled"] = "yes";
             } elseif ($record["type"] == "PTR") {
                 if (strpos($this->obj_domain->data["domain_name"], "ip6.arpa")) {
                     // IPv6 PTR records are in ARPA format, we should convert it to something human readable
                     $this->obj_form->structure["record_custom_" . $i . "_name"]["defaultvalue"] = ipv6_convert_fromarpa($record["name"]);
                 }
             } elseif ($record["type"] != "PTR") {
                 if ($record["type"] == "A" || $record["type"] == "AAAA") {
                     // check if this record has a reverse PTR value
                     $obj_ptr = new domain_records();
                     $obj_ptr->find_reverse_domain($record["content"]);
                     if ($obj_ptr->id_record) {
                         $obj_ptr->load_data_record();
                         if ($record["name"] == "@" || $record["name"] == "*" || preg_match("/^\\*\\.[A-Za-z0-9:._-]+\$/", $record["name"])) {
                             $record["name"] = $this->obj_domain->data["domain_name"];
                         }
                         if ($obj_ptr->data_record["content"] == $record["name"] || $obj_ptr->data_record["content"] == $record["name"] . "." . $this->obj_domain->data["domain_name"]) {
                             $this->obj_form->structure["record_custom_" . $i . "_reverse_ptr"]["defaultvalue"] = "on";
                             $this->obj_form->structure["record_custom_" . $i . "_reverse_ptr_orig"]["defaultvalue"] = "on";
                         }
                     }
                     unset($obj_ptr);
                 } else {
                     // reverse PTR not valid for this record type
                     $this->obj_form->structure["record_custom_" . $i . "_reverse_ptr"]["options"]["disabled"] = "yes";
                 }
             }
             $i++;
         }
     }
     // hidden
     $structure = NULL;
     $structure["fieldname"] = "id_domain";
     $structure["type"] = "hidden";
     $structure["defaultvalue"] = $this->obj_domain->id;
     $this->obj_form->add_input($structure);
     $structure = NULL;
     $structure["fieldname"] = "record_custom_page";
     $structure["type"] = "hidden";
     $structure["defaultvalue"] = "{$this->page}";
     $this->obj_form->add_input($structure);
     $structure = NULL;
     $structure["fieldname"] = "num_records_custom";
     $structure["type"] = "hidden";
     $structure["defaultvalue"] = "{$this->num_records_custom}";
     $this->obj_form->add_input($structure);
     // a record that can be set to determine the form status for final submit
     $structure = NULL;
     $structure["fieldname"] = "record_custom_status";
     $structure["type"] = "hidden";
     // fetch data in event of an error
     if (error_check()) {
         $this->obj_form->load_data_error();
         $structure["defaultvalue"] = "0";
     } else {
         $structure["defaultvalue"] = "1";
     }
     $this->obj_form->add_input($structure);
 }
 function execute()
 {
     $this->statement_array = $_SESSION["statement_array"];
     $values_array = array("ar", "ap", "transfer", "bank_fee", "interest");
     $this->obj_form = new form_input();
     $this->obj_form->formname = "bankstatement_assign";
     $i = 1;
     foreach ($this->statement_array as $transaction => $data) {
         $name = "transaction" . $i;
         /*
         	1. DETERMINE TRANSACTION TYPE
         
         	Determine what type of row this bank statement line item is. We do this
         	by keyword matching and checking for information such as amount being
         	positive/negative.
         */
         $row_assignment = null;
         if ($data["amount"] > 0) {
             $row_assignment = 'ar';
         }
         $lowercased_strings = strtolower($data['other_party']) . " " . strtolower($data['transaction_type']) . " " . strtolower($data['particulars']) . " " . strtolower($data['code']);
         $search_regex = "/(interest|transfer|fee|tax|account\\smaintenance){1}/";
         preg_match($search_regex, $lowercased_strings, $matches);
         switch ($matches[1]) {
             case 'tax':
             case 'transfer':
                 $row_assignment = 'transfer';
                 break;
             case 'interest':
                 $row_assignment = 'interest';
                 break;
             case 'fee':
             case 'account maintenance':
                 $row_assignment = 'bank_fee';
                 break;
             default:
                 if ($row_assignment == null) {
                     $row_assignment = 'ap';
                 }
                 break;
         }
         // assignment drop down
         $structure = NULL;
         $structure["fieldname"] = $name . "-assign";
         $structure["type"] = "dropdown";
         $structure["values"] = $values_array;
         $structure["defaultvalue"] = $row_assignment;
         $this->obj_form->add_input($structure);
         /*
         	2. HIDDEN ATTRIBUTES NEEDED FOR PROCESSING
         */
         // hidden date field
         $structure = NULL;
         $structure["fieldname"] = $name . "-date";
         $structure["type"] = "hidden";
         $structure["defaultvalue"] = date("Y-m-d", strtotime(str_replace("/", "-", $data["date"])));
         $this->obj_form->add_input($structure);
         // hidden amount field
         $structure = NULL;
         $structure["fieldname"] = $name . "-amount";
         $structure["type"] = "hidden";
         $structure["defaultvalue"] = $data["amount"];
         $this->obj_form->add_input($structure);
         //hidden other_party field
         if (isset($data["other_party"]) && $data["other_party"] != "") {
             $structure = NULL;
             $structure["fieldname"] = $name . "-other_party";
             $structure["type"] = "hidden";
             $structure["defaultvalue"] = $data["other_party"];
             $this->obj_form->add_input($structure);
         }
         //hidden transaction_type field
         if (isset($data["transaction_type"]) && $data["transaction_type"] != "") {
             $structure = NULL;
             $structure["fieldname"] = $name . "-transaction_type";
             $structure["type"] = "hidden";
             $structure["defaultvalue"] = $data["transaction_type"];
             $this->obj_form->add_input($structure);
         }
         //hidden code field
         if (isset($data["code"]) && $data["code"] != "") {
             $structure = NULL;
             $structure["fieldname"] = $name . "-code";
             $structure["type"] = "hidden";
             $structure["defaultvalue"] = $data["code"];
             $this->obj_form->add_input($structure);
         }
         //hidden reference field
         if (isset($data["reference"]) && $data["reference"] != "") {
             $structure = NULL;
             $structure["fieldname"] = $name . "-reference";
             $structure["type"] = "hidden";
             $structure["defaultvalue"] = $data["reference"];
             $this->obj_form->add_input($structure);
         }
         //hidden particulars field
         if (isset($data["particulars"]) && $data["particulars"] != "") {
             $structure = NULL;
             $structure["fieldname"] = $name . "-particulars";
             $structure["type"] = "hidden";
             $structure["defaultvalue"] = $data["particulars"];
             $this->obj_form->add_input($structure);
         }
         /*
         	3. AR TRANSACTION OPTIONS
         
         	We attempt to match the customer and/or the invoice here.
         */
         // customer drop down
         $structure = NULL;
         $structure = form_helper_prepare_dropdownfromdb($name . "-customer", "SELECT id, code_customer AS label, name_customer AS label1 FROM customers ORDER BY code_customer ASC");
         $search_values = array();
         $search_values[] = strtolower(preg_quote($data['other_party'], "/"));
         if ($data["reference"] != null) {
             $search_values[] = strtolower(preg_quote($data['reference'], "/"));
         }
         if ($data["code"] != null) {
             $search_values[] = strtolower(preg_quote($data['code'], "/"));
         }
         if ($data["particulars"] != null) {
             $search_values[] = strtolower(preg_quote($data['particulars'], "/"));
         }
         if (is_array($search_values) && is_array($structure["translations"])) {
             $matching_entries = preg_grep("/" . implode("|", $search_values) . "/i", $structure['translations']);
             $matching_entry_keys = array_keys($matching_entries);
             $structure["defaultvalue"] = $matching_entry_keys[0];
         }
         $this->obj_form->add_input($structure);
         // AR invoice drop down
         $structure = NULL;
         $structure = form_helper_prepare_dropdownfromdb($name . "-arinvoice", "SELECT id, code_invoice AS label, amount_total AS label1 FROM account_ar WHERE amount_paid < amount_total ORDER BY code_invoice ASC");
         $search_values = array();
         $search_values[] = strtolower(preg_quote(str_replace("-", '', " " . $data['amount']), "/"));
         if ($data["reference"] != null) {
             $search_values[] = strtolower(preg_quote($data['reference'], "/"));
         }
         if ($data["code"] != null) {
             $search_values[] = strtolower(preg_quote($data['code'], "/"));
         }
         if ($data["particulars"] != null) {
             $search_values[] = strtolower(preg_quote($data['particulars'], "/"));
         }
         if (is_array($search_values) && is_array($structure["translations"])) {
             $matching_entries = preg_grep("/" . implode("|", $search_values) . "/i", $structure['translations']);
             $matching_entry_keys = array_keys($matching_entries);
             $structure["defaultvalue"] = $matching_entry_keys[0];
         }
         $this->obj_form->add_input($structure);
         /*
         	4. AP TRANSACTION OPTIONS
         
         	We attempt to match the vendor and/or the invoice here.
         */
         // vendors drop down
         $structure = NULL;
         $structure = form_helper_prepare_dropdownfromdb($name . "-vendor", "SELECT id, code_vendor AS label, name_vendor AS label1 FROM vendors ORDER BY code_vendor ASC");
         $search_values = array();
         $search_values[] = strtolower(preg_quote($data['other_party'], "/"));
         if ($data["reference"] != null) {
             $search_values[] = strtolower(preg_quote($data['reference'], "/"));
         }
         if ($data["code"] != null) {
             $search_values[] = strtolower(preg_quote($data['code'], "/"));
         }
         if ($data["particulars"] != null) {
             $search_values[] = strtolower(preg_quote($data['particulars'], "/"));
         }
         if (is_array($search_values) && is_array($structure["translations"])) {
             $matching_entries = preg_grep("/" . implode("|", $search_values) . "/i", $structure['translations']);
             $matching_entry_keys = array_keys($matching_entries);
             $structure["defaultvalue"] = $matching_entry_keys[0];
         }
         $this->obj_form->add_input($structure);
         //AP invoice drop down
         $structure = NULL;
         $structure = form_helper_prepare_dropdownfromdb($name . "-apinvoice", "SELECT id, code_invoice AS label, amount_total AS label1 FROM account_ap WHERE amount_paid < amount_total ORDER BY code_invoice ASC");
         $search_values = array();
         $search_values[] = strtolower(preg_quote(str_replace("-", '', " " . $data['amount']), "/"));
         if ($data["reference"] != null) {
             $search_values[] = strtolower(preg_quote($data['reference'], "/"));
         }
         if ($data["code"] != null) {
             $search_values[] = strtolower(preg_quote($data['code'], "/"));
         }
         if ($data["particulars"] != null) {
             $search_values[] = strtolower(preg_quote($data['particulars'], "/"));
         }
         if (is_array($search_values) && is_array($structure["translations"])) {
             $matching_entries = preg_grep("/" . implode("|", $search_values) . "/i", $structure['translations']);
             $matching_entry_keys = array_keys($matching_entries);
             $structure["defaultvalue"] = $matching_entry_keys[0];
         }
         $this->obj_form->add_input($structure);
         /*
         	5. BANK FEE/CHARGES
         
         	Bank charges are always going to be from the current asset account to an expense account.
         */
         //Bank fees expense account drop down
         $structure = NULL;
         $structure = form_helper_prepare_dropdownfromdb($name . "-bankfeesexpense", "SELECT ac.id, ac.code_chart AS label, ac.description AS label1 FROM account_charts ac JOIN account_chart_type act ON ac.chart_type = act.id WHERE act.value = \"Expense\" ORDER BY ac.code_chart ASC");
         $this->obj_form->add_input($structure);
         //Bank fees asset account drop down
         $structure = NULL;
         $structure = form_helper_prepare_dropdownfromdb($name . "-bankfeesasset", "SELECT ac.id, ac.code_chart AS label, ac.description AS label1 FROM account_charts ac JOIN account_chart_type act ON ac.chart_type = act.id WHERE act.value = \"Asset\" ORDER BY ac.code_chart ASC");
         $structure["defaultvalue"] = $_SESSION["dest_account"];
         $this->obj_form->add_input($structure);
         /*
         	6. INTEREST
         */
         //Interest asset account drop down
         $structure = NULL;
         $structure = form_helper_prepare_dropdownfromdb($name . "-interestasset", "SELECT ac.id, ac.code_chart AS label, ac.description AS label1 FROM account_charts ac JOIN account_chart_type act ON ac.chart_type = act.id WHERE act.value = \"Asset\" ORDER BY ac.code_chart ASC");
         $this->obj_form->add_input($structure);
         //Interest income account drop down
         $structure = NULL;
         $structure = form_helper_prepare_dropdownfromdb($name . "-interestincome", "SELECT ac.id, ac.code_chart AS label, ac.description AS label1 FROM account_charts ac JOIN account_chart_type act ON ac.chart_type = act.id WHERE act.value = \"Income\" ORDER BY ac.code_chart ASC");
         $this->obj_form->add_input($structure);
         /*
         	7. GENERAL ACCOUNT TRANSFER
         
         	Not much to do for account transfers, but we can choose which account is selected for to/from based on
         	the default selected account.
         */
         if ($data["amount"] > 0) {
             // Transfer INTO the selected account
             //
             // Transfer from account drop down
             $structure = NULL;
             $structure = form_helper_prepare_dropdownfromdb($name . "-transferfrom", "SELECT ac.id, ac.code_chart AS label, ac.description AS label1 FROM account_charts ac JOIN account_chart_type act ON ac.chart_type = act.id ORDER BY ac.code_chart ASC");
             $this->obj_form->add_input($structure);
             //Transfer to account drop down
             $structure = NULL;
             $structure = form_helper_prepare_dropdownfromdb($name . "-transferto", "SELECT ac.id, ac.code_chart AS label, ac.description AS label1 FROM account_charts ac JOIN account_chart_type act ON ac.chart_type = act.id ORDER BY ac.code_chart ASC");
             $structure["defaultvalue"] = $_SESSION["dest_account"];
             $this->obj_form->add_input($structure);
         } else {
             // Transfer FROM the selected account
             //
             // Transfer from account drop down
             $structure = NULL;
             $structure = form_helper_prepare_dropdownfromdb($name . "-transferfrom", "SELECT ac.id, ac.code_chart AS label, ac.description AS label1 FROM account_charts ac JOIN account_chart_type act ON ac.chart_type = act.id ORDER BY ac.code_chart ASC");
             $structure["defaultvalue"] = $_SESSION["dest_account"];
             $this->obj_form->add_input($structure);
             //Transfer to account drop down
             $structure = NULL;
             $structure = form_helper_prepare_dropdownfromdb($name . "-transferto", "SELECT ac.id, ac.code_chart AS label, ac.description AS label1 FROM account_charts ac JOIN account_chart_type act ON ac.chart_type = act.id ORDER BY ac.code_chart ASC");
             $this->obj_form->add_input($structure);
         }
         /*
         	8. ENABLE/DISABLE FIELD
         
         	Users have the option of excluding rows that they don't want processed by unchecking them from the import.
         */
         // Hidden enabled field
         $structure = NULL;
         $structure["fieldname"] = $name . "-enabled";
         $structure["type"] = "hidden";
         // if the amount is not a number, disable the row
         if (!is_numeric($data["amount"])) {
             $structure["defaultvalue"] = "false";
         } else {
             $structure["defaultvalue"] = "true";
         }
         $this->obj_form->add_input($structure);
         $i++;
     }
     // hidden field for number of transactions
     $structure = NULL;
     $structure["fieldname"] = "num_trans";
     $structure["type"] = "hidden";
     $structure["defaultvalue"] = count($this->statement_array);
     $this->obj_form->add_input($structure);
     $structure = NULL;
     $structure["fieldname"] = "submit";
     $structure["type"] = "submit";
     $structure["defaultvalue"] = "Apply";
     $this->obj_form->add_input($structure);
     if (error_check()) {
         $this->obj_form->load_data_error();
     }
 }
Example #20
0
 function execute()
 {
     // fetch user options from the database
     $sql_obj = new sql_query();
     $sql_obj->string = "SELECT name, value FROM users_options WHERE userid='" . $this->id . "'";
     $sql_obj->execute();
     if ($sql_obj->num_rows()) {
         $sql_obj->fetch_array();
         // structure the results into a form we can then use to fill the fields in the form
         foreach ($sql_obj->data as $data) {
             $options[$data["name"]] = $data["value"];
         }
     }
     /*
     	Define form structure
     */
     $this->obj_form = new form_input();
     $this->obj_form->formname = "user_view";
     $this->obj_form->language = $_SESSION["user"]["lang"];
     $this->obj_form->action = "user/user-edit-process.php";
     $this->obj_form->method = "post";
     // general
     $structure = NULL;
     $structure["fieldname"] = "id_user";
     $structure["type"] = "text";
     $structure["defaultvalue"] = $this->id;
     $this->obj_form->add_input($structure);
     $structure = NULL;
     $structure["fieldname"] = "username";
     $structure["type"] = "input";
     $structure["options"]["req"] = "yes";
     $this->obj_form->add_input($structure);
     $structure = NULL;
     $structure["fieldname"] = "realname";
     $structure["type"] = "input";
     $structure["options"]["req"] = "yes";
     $this->obj_form->add_input($structure);
     $structure = NULL;
     $structure["fieldname"] = "contact_email";
     $structure["type"] = "input";
     $structure["options"]["req"] = "yes";
     $this->obj_form->add_input($structure);
     // passwords
     $structure = NULL;
     $structure["fieldname"] = "password_message";
     $structure["type"] = "message";
     $structure["defaultvalue"] = "<i>Only input a password if you wish to change the existing one.</i>";
     $this->obj_form->add_input($structure);
     $structure = NULL;
     $structure["fieldname"] = "password";
     $structure["type"] = "password";
     $this->obj_form->add_input($structure);
     $structure = NULL;
     $structure["fieldname"] = "password_confirm";
     $structure["type"] = "password";
     $this->obj_form->add_input($structure);
     // last login information
     $structure = NULL;
     $structure["fieldname"] = "time";
     $structure["type"] = "text";
     $this->obj_form->add_input($structure);
     $structure = NULL;
     $structure["fieldname"] = "ipaddress";
     $structure["type"] = "text";
     $this->obj_form->add_input($structure);
     // options
     $structure = form_helper_prepare_radiofromdb("option_lang", "SELECT name as id, name as label FROM language_avaliable ORDER BY name");
     $structure["defaultvalue"] = $options["lang"];
     $this->obj_form->add_input($structure);
     $structure = NULL;
     $structure["fieldname"] = "option_dateformat";
     $structure["type"] = "radio";
     $structure["values"] = array("yyyy-mm-dd", "mm-dd-yyyy", "dd-Mmm-yyyy", "dd-mm-yyyy");
     $structure["defaultvalue"] = $options["dateformat"];
     $this->obj_form->add_input($structure);
     $structure = form_helper_prepare_timezonedropdown("option_timezone");
     $structure["defaultvalue"] = $options["timezone"];
     $structure["options"]["width"] = "600";
     $structure["options"]["search_filter"] = "enabled";
     $this->obj_form->add_input($structure);
     $structure = NULL;
     $structure["fieldname"] = "option_shrink_tableoptions";
     $structure["type"] = "checkbox";
     $structure["defaultvalue"] = $options["shrink_tableoptions"];
     $structure["options"]["label"] = "Automatically hide the options table when using defaults";
     $this->obj_form->add_input($structure);
     $structure = NULL;
     $structure["fieldname"] = "option_table_limit";
     $structure["type"] = "input";
     $structure["defaultvalue"] = $options["table_limit"];
     $structure["options"]["label"] = " " . lang_trans("help_table_limit");
     $structure["options"]["width"] = "100";
     $this->obj_form->add_input($structure);
     $structure = form_helper_prepare_dropdownfromdb("option_default_employeeid", "SELECT id, staff_code as label, name_staff as label1 FROM staff ORDER BY name_staff");
     $structure["options"]["autoselect"] = "yes";
     $structure["options"]["width"] = "600";
     $structure["defaultvalue"] = $options["default_employeeid"];
     $structure["options"]["search_filter"] = "enabled";
     $this->obj_form->add_input($structure);
     $structure = NULL;
     $structure["fieldname"] = "option_debug";
     $structure["type"] = "checkbox";
     $structure["defaultvalue"] = $options["debug"];
     $structure["options"]["label"] = "Enable debug logging - this will impact performance a bit but will show a full trail of all functions and SQL queries made</i>";
     $this->obj_form->add_input($structure);
     $structure = NULL;
     $structure["fieldname"] = "option_concurrent_logins";
     $structure["type"] = "checkbox";
     $structure["defaultvalue"] = $options["concurrent_logins"];
     $structure["options"]["label"] = "Permit this user to make multiple simultaneous logins (recommended for SOAP users)</i>";
     $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["user_view"] = array("id_user", "username", "realname", "contact_email");
     $this->obj_form->subforms["user_password"] = array("password_message", "password", "password_confirm");
     $this->obj_form->subforms["user_info"] = array("time", "ipaddress");
     $this->obj_form->subforms["user_options"] = array("option_lang", "option_dateformat", "option_timezone", "option_shrink_tableoptions", "option_table_limit", "option_default_employeeid", "option_debug", "option_concurrent_logins");
     $this->obj_form->subforms["submit"] = array("submit");
     // fetch the form data
     $this->obj_form->sql_query = "SELECT id, username, realname, contact_email, time, ipaddress FROM `users` WHERE id='" . $this->id . "' LIMIT 1";
     $this->obj_form->load_data();
     // convert the last login time to a human readable value
     $this->obj_form->structure["time"]["defaultvalue"] = date("Y-m-d H:i:s", $this->obj_form->structure["time"]["defaultvalue"]);
 }
Example #21
0
 function execute()
 {
     /*
     	Employee Selection Form
     */
     $this->obj_form_employee = new form_input();
     $this->obj_form_employee->formname = "timereg_employee";
     $this->obj_form_employee->language = $_SESSION["user"]["lang"];
     // 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) {
         $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);
     // 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["defaultvalue"] = $this->employeeid;
     $this->obj_form_employee->add_input($structure);
     // hidden values
     $structure = NULL;
     $structure["fieldname"] = "page";
     $structure["type"] = "hidden";
     $structure["defaultvalue"] = $_GET["page"];
     $this->obj_form_employee->add_input($structure);
     $structure = NULL;
     $structure["fieldname"] = "date";
     $structure["type"] = "hidden";
     $structure["defaultvalue"] = $this->date;
     $this->obj_form_employee->add_input($structure);
     // submit button
     $structure = NULL;
     $structure["fieldname"] = "submit";
     $structure["type"] = "submit";
     $structure["defaultvalue"] = "Display";
     $this->obj_form_employee->add_input($structure);
     if ($this->employeeid) {
         /*
         	DRAW DAY TABLE
         
         	We need to display a table showing all time booked for the currently
         	selected day.
         */
         // establish a new table object
         $this->obj_table_day = new table();
         $this->obj_table_day->language = $_SESSION["user"]["lang"];
         $this->obj_table_day->tablename = "timereg_table";
         // define all the columns and structure
         $this->obj_table_day->add_column("standard", "name_project", "CONCAT_WS(' -- ', projects.code_project, projects.name_project)");
         $this->obj_table_day->add_column("standard", "name_phase", "project_phases.name_phase");
         $this->obj_table_day->add_column("hourmins", "time_booked", "timereg.time_booked");
         $this->obj_table_day->add_column("standard", "description", "timereg.description");
         // defaults
         $this->obj_table_day->columns = array("name_project", "name_phase", "description", "time_booked");
         $this->obj_table_day->columns_order = array("name_project", "name_phase");
         // create totals
         $this->obj_table_day->total_columns = array("time_booked");
         // define SQL
         $this->obj_table_day->sql_obj->prepare_sql_settable("timereg");
         $this->obj_table_day->sql_obj->prepare_sql_addfield("id", "timereg.id");
         $this->obj_table_day->sql_obj->prepare_sql_addjoin("LEFT JOIN project_phases ON timereg.phaseid = project_phases.id");
         $this->obj_table_day->sql_obj->prepare_sql_addjoin("LEFT JOIN projects ON project_phases.projectid = projects.id");
         $this->obj_table_day->sql_obj->prepare_sql_addwhere("timereg.employeeid = '" . $this->employeeid . "'");
         $this->obj_table_day->sql_obj->prepare_sql_addwhere("timereg.date = '" . $this->date . "'");
         // execute SQL statement
         $this->obj_table_day->generate_sql();
         $this->obj_table_day->load_data_sql();
     }
 }
Example #22
0
 function execute()
 {
     // define basic form details
     $this->obj_form = new form_input();
     $this->obj_form->formname = "customer_add";
     $this->obj_form->language = $_SESSION["user"]["lang"];
     $this->obj_form->action = "customers/edit-process.php";
     $this->obj_form->method = "post";
     // general
     $structure = NULL;
     $structure["fieldname"] = "code_customer";
     $structure["type"] = "input";
     $this->obj_form->add_input($structure);
     $structure = NULL;
     $structure["fieldname"] = "name_customer";
     $structure["type"] = "input";
     $structure["options"]["req"] = "yes";
     $this->obj_form->add_input($structure);
     $structure = NULL;
     $structure["fieldname"] = "date_start";
     $structure["type"] = "date";
     $structure["defaultvalue"] = date("Y-m-d");
     $structure["options"]["req"] = "yes";
     $this->obj_form->add_input($structure);
     $structure = NULL;
     $structure["fieldname"] = "date_end";
     $structure["type"] = "date";
     $this->obj_form->add_input($structure);
     //contacts
     if (!empty($_SESSION["error"]["num_contacts"])) {
         $this->num_contacts = stripslashes($_SESSION["error"]["num_contacts"]);
     } else {
         $this->num_contacts = 1;
     }
     $structure = NULL;
     $structure["fieldname"] = "num_contacts";
     $structure["type"] = "hidden";
     $structure["defaultvalue"] = $this->num_contacts;
     $this->obj_form->add_input($structure);
     for ($i = 0; $i < $this->num_contacts; $i++) {
         $structure = NULL;
         $structure["fieldname"] = "contact_id_" . $i;
         $structure["type"] = "hidden";
         $this->obj_form->add_input($structure);
         $structure = NULL;
         $structure["fieldname"] = "delete_contact_" . $i;
         $structure["type"] = "hidden";
         $structure["defaultvalue"] = "false";
         $this->obj_form->add_input($structure);
         $structure = NULL;
         $structure["fieldname"] = "contact_" . $i;
         $structure["type"] = "input";
         if (isset($_SESSION["error"]["contact_" . $i . "-error"])) {
             $structure["options"]["css_field_class"] = "hidden_form_field_error";
         } else {
             if (empty($_SESSION["error"]) && $i == 0) {
                 $structure["options"]["css_field_class"] = "hidden_form_field_error";
             } else {
                 $structure["options"]["css_field_class"] = "hidden_form_field";
             }
         }
         $structure["options"]["width"] = "200";
         $this->obj_form->add_input($structure);
         $structure = NULL;
         $structure["fieldname"] = "role_" . $i;
         $structure["type"] = "dropdown";
         $structure["options"]["width"] = "205";
         if ($i == 0) {
             $structure["values"] = array("accounts");
             $structure["options"]["autoselect"] = "yes";
             $structure["options"]["disabled"] = "yes";
         } else {
             $structure["values"] = array("other");
             $structure["options"]["autoselect"] = "yes";
         }
         if (isset($_SESSION["error"]["contact_" . $i . "-error"])) {
             $structure["options"]["css_field_class"] = "hidden_form_field_error";
         } else {
             if (empty($_SESSION["error"]) && $i == 0) {
                 $structure["options"]["css_field_class"] = "hidden_form_field_error";
             } else {
                 $structure["options"]["css_field_class"] = "hidden_form_field";
             }
         }
         $this->obj_form->add_input($structure);
         $structure = NULL;
         $structure["fieldname"] = "description_" . $i;
         $structure["type"] = "textarea";
         if (isset($_SESSION["error"]["contact_" . $i . "-error"])) {
             $structure["options"]["css_field_class"] = "hidden_form_field_error";
         } else {
             if (empty($_SESSION["error"]) && $i == 0) {
                 $structure["options"]["css_field_class"] = "hidden_form_field_error";
             } else {
                 $structure["options"]["css_field_class"] = "hidden_form_field";
             }
         }
         $structure["options"]["width"] = "205";
         $structure["options"]["height"] = "";
         $this->obj_form->add_input($structure);
         //contact records
         if (!empty($_SESSION["error"]["num_records_{$i}"])) {
             $num_records = stripslashes($_SESSION["error"]["num_records_{$i}"]);
         } else {
             $num_records = 0;
         }
         $structure = NULL;
         $structure["fieldname"] = "num_records_" . $i;
         $structure["type"] = "hidden";
         $structure["defaultvalue"] = $num_records;
         $this->obj_form->add_input($structure);
         if ($num_records > 0) {
             for ($j = 0; $j < $num_records; $j++) {
                 $structure = NULL;
                 $structure["fieldname"] = "contact_" . $i . "_record_id_" . $j;
                 $structure["type"] = "hidden";
                 $this->obj_form->add_input($structure);
                 $structure = NULL;
                 $structure["fieldname"] = "contact_" . $i . "_delete_" . $j;
                 $structure["type"] = "hidden";
                 $structure["defaultvalue"] = "false";
                 $this->obj_form->add_input($structure);
                 $structure = NULL;
                 $structure["fieldname"] = "contact_" . $i . "_type_" . $j;
                 $structure["type"] = "hidden";
                 $this->obj_form->add_input($structure);
                 $structure = NULL;
                 $structure["fieldname"] = "contact_" . $i . "_label_" . $j;
                 $structure["type"] = "hidden";
                 $this->obj_form->add_input($structure);
                 $structure = NULL;
                 $structure["fieldname"] = "contact_" . $i . "_detail_" . $j;
                 $structure["type"] = "input";
                 $structure["options"]["width"] = "";
                 $this->obj_form->add_input($structure);
             }
         }
     }
     // taxes
     $structure = NULL;
     $structure["fieldname"] = "tax_number";
     $structure["type"] = "input";
     $this->obj_form->add_input($structure);
     $structure = NULL;
     $structure = form_helper_prepare_dropdownfromdb("tax_default", "SELECT id, name_tax as label FROM account_taxes");
     $this->obj_form->add_input($structure);
     // list all the taxes so the user can enable or disable the taxes
     $sql_tax_obj = new sql_query();
     $sql_tax_obj->string = "SELECT id, name_tax, description, default_customers FROM account_taxes ORDER BY name_tax";
     $sql_tax_obj->execute();
     if ($sql_tax_obj->num_rows()) {
         // user note
         $structure = NULL;
         $structure["fieldname"] = "tax_message";
         $structure["type"] = "message";
         $structure["defaultvalue"] = "<p>Select all the taxes below which apply to this customer. Any taxes not selected, will not be added to invoices for this customer.</p>";
         $this->obj_form->add_input($structure);
         // 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";
             //check if tax is set as a default
             if ($data_tax["default_customers"]) {
                 $structure["defaultvalue"] = "on";
             }
             // add to form
             $this->obj_form->add_input($structure);
             $this->tax_array[] = "tax_" . $data_tax["id"];
         }
     } else {
         $structure = NULL;
         $structure["fieldname"] = "tax_message";
         $structure["type"] = "message";
         $structure["defaultvalue"] = "<p>No taxes can be selected for this customer, as there have been no taxes configured yet.</p>";
         $this->obj_form->add_input($structure);
     }
     // purchase options
     $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);
     $this->obj_form->subforms["customer_purchase"] = array("discount");
     // billing address
     $structure = NULL;
     $structure["fieldname"] = "address1_street";
     $structure["type"] = "textarea";
     $this->obj_form->add_input($structure);
     $structure = NULL;
     $structure["fieldname"] = "address1_city";
     $structure["type"] = "input";
     $this->obj_form->add_input($structure);
     $structure = NULL;
     $structure["fieldname"] = "address1_state";
     $structure["type"] = "input";
     $this->obj_form->add_input($structure);
     $structure = NULL;
     $structure["fieldname"] = "address1_country";
     $structure["type"] = "input";
     $this->obj_form->add_input($structure);
     $structure = NULL;
     $structure["fieldname"] = "address1_zipcode";
     $structure["type"] = "input";
     $this->obj_form->add_input($structure);
     // shipping address
     $structure = NULL;
     $structure["fieldname"] = "address1_same_as_2";
     $structure["type"] = "checkbox";
     $structure["options"]["label"] = " " . lang_trans("address1_same_as_2_help");
     $structure["options"]["css_row_class"] = "shipping_same_address";
     $this->obj_form->add_input($structure);
     $structure = NULL;
     $structure["fieldname"] = "address2_street";
     $structure["type"] = "textarea";
     $structure["options"]["css_row_class"] = "shipping_address";
     $this->obj_form->add_input($structure);
     $structure = NULL;
     $structure["fieldname"] = "address2_city";
     $structure["type"] = "input";
     $structure["options"]["css_row_class"] = "shipping_address";
     $this->obj_form->add_input($structure);
     $structure = NULL;
     $structure["fieldname"] = "address2_state";
     $structure["type"] = "input";
     $structure["options"]["css_row_class"] = "shipping_address";
     $this->obj_form->add_input($structure);
     $structure = NULL;
     $structure["fieldname"] = "address2_country";
     $structure["type"] = "input";
     $structure["options"]["css_row_class"] = "shipping_address";
     $this->obj_form->add_input($structure);
     $structure = NULL;
     $structure["fieldname"] = "address2_zipcode";
     $structure["type"] = "input";
     $structure["options"]["css_row_class"] = "shipping_address";
     $this->obj_form->add_input($structure);
     // reseller options
     $structure = NULL;
     $structure["fieldname"] = "reseller_customer";
     $structure["type"] = "radio";
     $structure["values"] = array("standalone", "reseller", "customer_of_reseller");
     $structure["defaultvalue"] = "standalone";
     $structure["options"]["css_row_class"] = "reseller_customer";
     $this->obj_form->add_input($structure);
     $structure = NULL;
     $structure = form_helper_prepare_dropdownfromdb("reseller_id", "SELECT id, code_customer as label, name_customer as label1 FROM customers WHERE reseller_customer = 'reseller'");
     $this->obj_form->add_input($structure);
     $structure = NULL;
     $structure["fieldname"] = "reseller_message";
     $structure["type"] = "message";
     $structure["defaultvalue"] = "<p>Each customer in the system can either be classified for the Reseller Options as either a standalone customer, a reseller to other customers, or as a customer of a reseller. By default new customers are standalone.</p>";
     $this->obj_form->add_input($structure);
     // submit button
     $structure = NULL;
     $structure["fieldname"] = "submit";
     $structure["type"] = "submit";
     $structure["defaultvalue"] = "Create Customer";
     $this->obj_form->add_input($structure);
     // load any data returned due to errors
     $this->obj_form->load_data_error();
 }
 function execute()
 {
     // establish a new table object
     $this->obj_table = new table();
     $this->obj_table->language = $_SESSION["user"]["lang"];
     $this->obj_table->tablename = "account-statements";
     // define all the columns and structure
     $this->obj_table->add_column("standard", "code_invoice", "account_ar.code_invoice");
     $this->obj_table->add_column("standard", "code_ordernumber", "account_ar.code_ordernumber");
     $this->obj_table->add_column("standard", "code_ponumber", "account_ar.code_ponumber");
     $this->obj_table->add_column("standard", "name_customer", "CONCAT_WS(' -- ', customers.code_customer, customers.name_customer)");
     $this->obj_table->add_column("standard", "name_staff", "CONCAT_WS(' -- ', staff.staff_code, staff.name_staff)");
     $this->obj_table->add_column("date", "date_trans", "account_ar.date_trans");
     $this->obj_table->add_column("date", "date_due", "account_ar.date_due");
     $this->obj_table->add_column("price", "amount_tax", "account_ar.amount_tax");
     $this->obj_table->add_column("price", "amount", "account_ar.amount");
     $this->obj_table->add_column("price", "amount_total", "account_ar.amount_total");
     $this->obj_table->add_column("price", "amount_paid", "account_ar.amount_paid");
     $this->obj_table->add_column("date", "date_sent", "account_ar.date_sent");
     $this->obj_table->add_column("bool_tick", "sent", "account_ar.sentmethod");
     $this->obj_table->add_column("standard", "days_overdue", "DATEDIFF(CURDATE(), account_ar.date_due)");
     $this->obj_table->add_column("standard", "send_reminder", "NONE");
     // defaults
     $this->obj_table->columns = array("code_invoice", "name_customer", "amount_total", "date_due", "date_sent", "days_overdue", "send_reminder");
     $this->obj_table->columns_order = array("date_due");
     $this->obj_table->columns_order_options = array("code_invoice", "name_customer", "amount_total", "date_due", "date_sent", "days_overdue", "send_reminder");
     // 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_addfield("since_sent", "DATEDIFF(CURDATE(), account_ar.date_sent)");
     $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");
     $this->obj_table->sql_obj->prepare_sql_addwhere("account_ar.amount_total > account_ar.amount_paid");
     // acceptable filter options
     $structure = NULL;
     $structure["fieldname"] = "days_overdue";
     $structure["type"] = "input";
     $structure["sql"] = "DATEDIFF(CURDATE(), account_ar.date_due) >= 'value'";
     $structure["options"]["width"] = 30;
     $structure["defaultvalue"] = $GLOBALS["config"]["ACCOUNTS_TERMS_DAYS"];
     $this->obj_table->add_filter($structure);
     $structure = NULL;
     $structure["fieldname"] = "date_start";
     $structure["type"] = "date";
     $structure["sql"] = "date_trans >= 'value'";
     $this->obj_table->add_filter($structure);
     $structure = NULL;
     $structure["fieldname"] = "date_end";
     $structure["type"] = "date";
     $structure["sql"] = "date_trans <= 'value'";
     $this->obj_table->add_filter($structure);
     $structure = form_helper_prepare_dropdownfromdb("employeeid", "SELECT id, staff_code as label, name_staff as label1 FROM staff ORDER BY name_staff");
     $structure["sql"] = "account_ar.employeeid='value'";
     $structure["options"]["search_filter"] = "enabled";
     $this->obj_table->add_filter($structure);
     $structure = form_helper_prepare_dropdownfromdb("customerid", "SELECT id, code_customer as label, name_customer as label1 FROM customers ORDER BY name_customer");
     $structure["sql"] = "account_ar.customerid='value'";
     $structure["options"]["search_filter"] = "enabled";
     $this->obj_table->add_filter($structure);
     // load options
     $this->obj_table->load_options_form();
     // minimum of 1 days overdue
     if ($this->obj_table->filter["filter_days_overdue"]["defaultvalue"] < 1) {
         $this->obj_table->filter["filter_days_overdue"]["defaultvalue"] = 1;
     }
     // fetch all the chart information
     $this->obj_table->generate_sql();
     $this->obj_table->load_data_sql();
     //establish new form object
     $this->obj_form = new form_input();
     $this->obj_form->formname = "account-statements";
     $this->obj_form->language = $_SESSION["user"]["lang"];
     $this->obj_form->action = "accounts/ar/account-statements-process.php";
     $this->obj_form->method = "post";
     //create form fields
     for ($i = 0; $i < $this->obj_table->data_num_rows; $i++) {
         $structure = NULL;
         $structure["fieldname"] = "send_reminder_{$i}";
         $structure["type"] = "checkbox";
         $structure["options"]["nolabel"] = "true";
         $this->obj_form->add_input($structure);
         $structure = NULL;
         $structure["fieldname"] = "invoice_id_{$i}";
         $structure["type"] = "hidden";
         $structure["defaultvalue"] = $this->obj_table->data[$i]["id"];
         $this->obj_form->add_input($structure);
         $structure = NULL;
         $structure["fieldname"] = "days_overdue_{$i}";
         $structure["type"] = "hidden";
         $structure["defaultvalue"] = $this->obj_table->data[$i]["days_overdue"];
         $this->obj_form->add_input($structure);
     }
     //form fields for email options
     $structure = NULL;
     $structure["fieldname"] = "sender";
     $structure["type"] = "radio";
     $structure["defaultvalue"] = "system";
     $structure["values"] = array("system", "user");
     $structure["translations"]["system"] = sql_get_singlevalue("SELECT value FROM config WHERE name='COMPANY_NAME'") . " &lt;" . sql_get_singlevalue("SELECT value FROM config WHERE name='COMPANY_CONTACT_EMAIL'") . "&gt;";
     $structure["translations"]["user"] = user_information("realname") . " &lt;" . user_information("contact_email") . "&gt;";
     $this->obj_form->add_input($structure);
     $structure = NULL;
     $structure["fieldname"] = "subject";
     $structure["type"] = "input";
     $structure["defaultvalue"] = "Overdue Notice: Invoice (code_invoice)";
     $structure["options"]["width"] = "600";
     $this->obj_form->add_input($structure);
     $structure = NULL;
     $structure["fieldname"] = "email_message";
     $structure["type"] = "textarea";
     $structure["defaultvalue"] = sql_get_singlevalue("SELECT value FROM config WHERE name IN('TEMPLATE_INVOICE_REMINDER_EMAIL') LIMIT 1");
     $structure["options"]["width"] = "600";
     $structure["options"]["height"] = "100";
     $this->obj_form->add_input($structure);
     $structure = NULL;
     $structure["fieldname"] = "num_records";
     $structure["type"] = "hidden";
     $structure["defaultvalue"] = $this->obj_table->data_num_rows;
     $this->obj_form->add_input($structure);
     $structure = NULL;
     $structure["fieldname"] = "submit";
     $structure["type"] = "submit";
     $structure["defaultvalue"] = "Send Reminders";
     $this->obj_form->add_input($structure);
     //load any error data
     $this->obj_form->load_data();
 }
Example #24
0
 function execute()
 {
     /// Basic Table Structure
     // establish a new table object
     $this->obj_table = new table();
     $this->obj_table->language = $_SESSION["user"]["lang"];
     $this->obj_table->tablename = "time_billed";
     // define all the columns and structure
     $this->obj_table->add_column("standard", "name_group", "time_groups.name_group");
     $this->obj_table->add_column("standard", "name_customer", "CONCAT_WS(' -- ', customers.code_customer, customers.name_customer)");
     $this->obj_table->add_column("standard", "code_invoice", "account_ar.code_invoice");
     $this->obj_table->add_column("standard", "description", "time_groups.description");
     $this->obj_table->add_column("hourmins", "time_billed", "NONE");
     $this->obj_table->add_column("hourmins", "time_not_billed", "NONE");
     // defaults
     $this->obj_table->columns = array("name_group", "name_customer", "code_invoice", "description", "time_billed", "time_not_billed");
     $this->obj_table->columns_order = array("name_customer", "name_group");
     $this->obj_table->columns_order_options = array("name_customer", "name_group", "name_customer", "code_invoice", "description");
     // define SQL structure
     $this->obj_table->sql_obj->prepare_sql_settable("time_groups");
     $this->obj_table->sql_obj->prepare_sql_addfield("id", "time_groups.id");
     $this->obj_table->sql_obj->prepare_sql_addfield("invoiceid", "time_groups.invoiceid");
     $this->obj_table->sql_obj->prepare_sql_addjoin("LEFT JOIN customers ON time_groups.customerid = customers.id");
     $this->obj_table->sql_obj->prepare_sql_addjoin("LEFT JOIN account_ar ON time_groups.invoiceid = account_ar.id");
     $this->obj_table->sql_obj->prepare_sql_addwhere("time_groups.projectid = '" . $this->id . "'");
     /// Filtering/Display Options
     // fixed options
     $this->obj_table->add_fixed_option("id", $this->id);
     // acceptable filter options
     $structure = form_helper_prepare_dropdownfromdb("customerid", "SELECT id, code_customer as label, name_customer as label1 FROM customers ORDER BY name_customer");
     $structure["sql"] = "time_groups.customerid='value'";
     $structure["options"]["search_filter"] = "yes";
     $this->obj_table->add_filter($structure);
     $structure = NULL;
     $structure["fieldname"] = "hide_closed";
     $structure["type"] = "checkbox";
     $structure["options"]["label"] = "Hide time groups belong to invoices";
     $structure["defaultvalue"] = "enabled";
     $structure["sql"] = "time_groups.invoiceid='0'";
     $this->obj_table->add_filter($structure);
     $structure = NULL;
     $structure["fieldname"] = "searchbox";
     $structure["type"] = "input";
     $structure["sql"] = "(time_groups.description LIKE '%value%' OR time_groups.name_group LIKE '%value%')";
     $this->obj_table->add_filter($structure);
     $this->obj_table->total_columns = array("time_billed", "time_not_billed");
     // load options
     $this->obj_table->load_options_form();
     // generate & execute SQL query
     $this->obj_table->generate_sql();
     $this->obj_table->load_data_sql();
     // run through all the data rows to make custom changes
     if ($this->obj_table->data_num_rows) {
         for ($i = 0; $i < $this->obj_table->data_num_rows; $i++) {
             // fetch the time totals
             // (because we have to do two different sums, we can't use a join)
             $sql_obj = new sql_query();
             $sql_obj->string = "SELECT time_booked, billable FROM timereg WHERE groupid='" . $this->obj_table->data[$i]["id"] . "'";
             $sql_obj->execute();
             if ($sql_obj->num_rows()) {
                 $sql_obj->fetch_array();
                 foreach ($sql_obj->data as $data) {
                     if ($data["billable"] == 0) {
                         $this->obj_table->data[$i]["time_not_billed"] += $data["time_booked"];
                     } else {
                         $this->obj_table->data[$i]["time_billed"] += $data["time_booked"];
                     }
                 }
             }
         }
     }
 }
Example #25
0
 function execute()
 {
     /*
     	Define form structure
     */
     $this->obj_form = new form_input();
     $this->obj_form->formname = "service_view";
     $this->obj_form->language = $_SESSION["user"]["lang"];
     $this->obj_form->action = "customers/service-edit-process.php";
     $this->obj_form->method = "post";
     // general
     if ($this->obj_customer->id_service_customer) {
         /*
         	An existing service is being adjusted
         */
         // general
         $structure = NULL;
         $structure["fieldname"] = "id_service_customer";
         $structure["type"] = "text";
         $structure["defaultvalue"] = $this->obj_customer->id_service_customer;
         $this->obj_form->add_input($structure);
         $structure = NULL;
         $structure["fieldname"] = "service_parent";
         $structure["type"] = "text";
         $structure["options"]["nohidden"] = 1;
         $structure["defaultvalue"] = "<a href=\"index.php?page=services/view.php&id=" . $this->obj_customer->obj_service->id . "\">" . sql_get_singlevalue("SELECT name_service as value FROM services WHERE id='" . $this->obj_customer->obj_service->id . "' LIMIT 1") . "</a>";
         $this->obj_form->add_input($structure);
         $structure = NULL;
         $structure["fieldname"] = "name_service";
         $structure["type"] = "input";
         $structure["options"]["req"] = "yes";
         $this->obj_form->add_input($structure);
         $structure = NULL;
         $structure["fieldname"] = "description";
         $structure["type"] = "textarea";
         $this->obj_form->add_input($structure);
         $this->obj_form->subforms["service_edit"] = array("id_service_customer", "service_parent", "name_service", "description");
         // service controls
         $structure = NULL;
         $structure["fieldname"] = "control_help";
         $structure["type"] = "message";
         $structure["defaultvalue"] = "When disabling services, the best approach is to set the last period date, and ABS will correctly bill to that final date, handle usage/partial periods and issue a final invoice, before disabling the service automatically - however it is possible to disable a service immediently if so desired by using the active checkbox.";
         $this->obj_form->add_input($structure);
         $structure = NULL;
         $structure["fieldname"] = "active";
         $structure["type"] = "checkbox";
         $structure["options"]["label"] = "Service is enabled";
         $this->obj_form->add_input($structure);
         $structure = NULL;
         $structure["fieldname"] = "date_period_last";
         $structure["type"] = "date";
         $structure["options"]["label"] = " Earliest termination date is: " . time_format_humandate(sql_get_singlevalue("SELECT date_end as value FROM services_customers_periods WHERE id_service_customer='" . $this->obj_customer->id_service_customer . "' ORDER BY date_end DESC LIMIT 1"));
         $this->obj_form->add_input($structure);
         $this->obj_form->subforms["service_controls"] = array("control_help", "active", "date_period_last");
         // billing
         $structure = NULL;
         $structure["fieldname"] = "billing_cycle_string";
         $structure["type"] = "text";
         $this->obj_form->add_input($structure);
         if ($this->locked_datechange) {
             // the service has been billed, the start date is fixed.
             $structure = NULL;
             $structure["fieldname"] = "date_period_first";
             $structure["type"] = "text";
             $this->obj_form->add_input($structure);
             $structure = NULL;
             $structure["fieldname"] = "date_period_next";
             $structure["type"] = "text";
             $this->obj_form->add_input($structure);
         } else {
             // service has not yet been billed, so the dates can still be adjusted
             $structure = NULL;
             $structure["fieldname"] = "date_period_first";
             $structure["type"] = "date";
             $this->obj_form->add_input($structure);
             $structure = NULL;
             $structure["fieldname"] = "date_period_next";
             $structure["type"] = "text";
             $this->obj_form->add_input($structure);
         }
         $this->obj_form->subforms["service_billing"] = array("billing_cycle_string", "date_period_first", "date_period_next");
         $pos = stristr($this->obj_customer->obj_service->data["typeid_string"], "phone_");
         if ($pos !== FALSE && $pos == 0) {
             $structure = NULL;
             $structure["fieldname"] = "billing_cdr_csv_output";
             $structure["options"]["label"] = " " . lang_trans("billing_cdr_csv_output_help");
             $structure["type"] = "checkbox";
             $this->obj_form->add_input($structure);
             $this->obj_form->subforms["service_billing"][] = "billing_cdr_csv_output";
         }
         if (!$this->obj_customer->service_get_is_bundle_item()) {
             // price customisation
             $structure = NULL;
             $structure["fieldname"] = "price";
             $structure["type"] = "money";
             $structure["options"]["req"] = "yes";
             $this->obj_form->add_input($structure);
             $structure = NULL;
             $structure["fieldname"] = "discount";
             $structure["type"] = "input";
             $structure["options"]["width"] = 50;
             $structure["options"]["label"] = " %";
             $structure["options"]["max_length"] = "6";
             $this->obj_form->add_input($structure);
             $this->obj_form->subforms["service_price"] = array("price", "discount");
             // setup charges - only display if the service is inactive
             if (!sql_get_singlevalue("SELECT active as value FROM services_customers WHERE id='" . $this->obj_customer->id_service_customer . "' LIMIT 1")) {
                 $structure = NULL;
                 $structure["fieldname"] = "info_setup_help";
                 $structure["type"] = "message";
                 $structure["defaultvalue"] = "<p>" . lang_trans("info_setup_help") . "</p>";
                 $this->obj_form->add_input($structure);
                 $structure = NULL;
                 $structure["fieldname"] = "price_setup";
                 $structure["type"] = "money";
                 $structure["options"]["req"] = "yes";
                 $this->obj_form->add_input($structure);
                 $structure = NULL;
                 $structure["fieldname"] = "discount_setup";
                 $structure["type"] = "input";
                 $structure["options"]["width"] = 50;
                 $structure["options"]["label"] = " %";
                 $structure["options"]["max_length"] = "6";
                 $structure["defaultvalue"] = $this->obj_customer->obj_service->data["discount"];
                 $this->obj_form->add_input($structure);
                 $this->obj_form->subforms["service_setup"] = array("info_setup_help", "price_setup", "discount_setup");
             } else {
                 $structure = NULL;
                 $structure["fieldname"] = "info_setup_help";
                 $structure["type"] = "message";
                 $structure["defaultvalue"] = "<p>A setup fee of " . format_money($this->obj_customer->obj_service->data["price_setup"]) . " was charged for this service.</p>";
                 $this->obj_form->add_input($structure);
                 $this->obj_form->subforms["service_setup"] = array("info_setup_help");
             }
         }
         // end if not bundle
         // service-type specific sections
         switch ($this->obj_customer->obj_service->data["typeid_string"]) {
             case "bundle":
                 /*
                 	Bundle Service
                 
                 	Display a hyperlinked list of all the component services belonging to
                 	the bundle.
                 */
                 $structure = NULL;
                 $structure["fieldname"] = "bundle_msg";
                 $structure["type"] = "message";
                 $structure["defaultvalue"] = "<p>This service is a bundle, containing a number of other services. Note that enabling/disabling or deleting this bundle service will affect all the component services below.</p>";
                 $this->obj_form->add_input($structure);
                 // fetch all the items for the bundle that have been setup for this customer and
                 // display some details in a table inside of a form field. (kinda ugly rendering hack, but works OK)
                 $structure = NULL;
                 $structure["fieldname"] = "bundle_components";
                 $structure["type"] = "message";
                 $structure["defaultvalue"] = "<table class=\"table_highlight\">";
                 $sql_obj = new sql_query();
                 $sql_obj->string = "SELECT id, serviceid as id_service FROM services_customers WHERE bundleid='" . $this->obj_customer->id_service_customer . "'";
                 $sql_obj->execute();
                 if ($sql_obj->num_rows()) {
                     $sql_obj->fetch_array();
                     foreach ($sql_obj->data as $data_component) {
                         $obj_component = new service();
                         $obj_component->id = $data_component["id_service"];
                         $obj_component->option_type = "customer";
                         $obj_component->option_type_id = $data_component["id"];
                         $obj_component->load_data();
                         $obj_component->load_data_options();
                         if (sql_get_singlevalue("SELECT active as value FROM services_customers WHERE id='" . $data_component["id"] . "' LIMIT 1")) {
                             $obj_component->active_status_string = "<td class=\"table_highlight_info\">active</td>";
                         } else {
                             $obj_component->active_status_string = "<td class=\"table_highlight_important\">disabled</td>";
                         }
                         $structure["defaultvalue"] .= "<tr>" . "<td>Bundle Component: <b>" . $obj_component->data["name_service"] . "</b></td>" . $obj_component->active_status_string . "<td>" . $obj_component->data["description"] . "</td>" . "<td><a class=\"button_small\" href=\"index.php?page=customers/service-edit.php&id_customer=" . $this->obj_customer->id . "&id_service_customer=" . $obj_component->option_type_id . "\">View Service</a></td>" . "</tr>";
                     }
                 }
                 $structure["defaultvalue"] .= "</table>";
                 $this->obj_form->add_input($structure);
                 $this->obj_form->subforms["service_bundle"] = array("bundle_msg", "bundle_components");
                 break;
             case "licenses":
                 $structure = NULL;
                 $structure["fieldname"] = "quantity_msg";
                 $structure["type"] = "message";
                 $structure["defaultvalue"] = "<i>Because this is a license service, you need to specifiy how many license in the box below. Note that this will only affect billing from the next invoice. If you wish to charge for usage between now and the next invoice, you will need to generate a manual invoice.</i>";
                 $this->obj_form->add_input($structure);
                 $structure = NULL;
                 $structure["fieldname"] = "quantity";
                 $structure["type"] = "input";
                 $structure["options"]["req"] = "yes";
                 $this->obj_form->add_input($structure);
                 $this->obj_form->subforms["service_options_licenses"] = array("quantity_msg", "quantity");
                 break;
             case "data_traffic":
                 // help info
                 $structure = NULL;
                 $structure["fieldname"] = "traffic_cap_help";
                 $structure["type"] = "message";
                 $structure["defaultvalue"] = "<p>If desired, traffic types, data caps and overage changes can be overridden here to customise a service for a particular customer.</p>";
                 $this->obj_form->add_input($structure);
                 $this->obj_form->subforms["traffic_caps"][] = "traffic_cap_help";
                 // header
                 $structure = NULL;
                 $structure["fieldname"] = "traffic_cap_header_name";
                 $structure["type"] = "text";
                 $structure["defaultvalue"] = lang_trans("header_traffic_cap_name");
                 $this->obj_form->add_input($structure);
                 $structure = NULL;
                 $structure["fieldname"] = "traffic_cap_header_mode";
                 $structure["type"] = "text";
                 $structure["defaultvalue"] = lang_trans("header_traffic_cap_mode");
                 $this->obj_form->add_input($structure);
                 $structure = NULL;
                 $structure["fieldname"] = "traffic_cap_header_units_included";
                 $structure["type"] = "text";
                 $structure["defaultvalue"] = lang_trans("header_traffic_units_included");
                 $this->obj_form->add_input($structure);
                 $structure = NULL;
                 $structure["fieldname"] = "traffic_cap_header_units_price";
                 $structure["type"] = "text";
                 $structure["defaultvalue"] = lang_trans("header_traffic_units_price");
                 $this->obj_form->add_input($structure);
                 $this->obj_form->subforms_grouped["traffic_caps"]["traffic_cap_header"][] = "traffic_cap_header_name";
                 $this->obj_form->subforms_grouped["traffic_caps"]["traffic_cap_header"][] = "traffic_cap_header_mode";
                 $this->obj_form->subforms_grouped["traffic_caps"]["traffic_cap_header"][] = "traffic_cap_header_units_included";
                 $this->obj_form->subforms_grouped["traffic_caps"]["traffic_cap_header"][] = "traffic_cap_header_units_price";
                 $this->obj_form->subforms["traffic_caps"][] = "traffic_cap_header";
                 // fetch service unitname
                 $unitname = sql_get_singlevalue("SELECT name as value FROM service_units WHERE id='" . $this->obj_customer->obj_service->data["units"] . "'");
                 // manual load of override values for data cap services
                 $data_traffic_overrides = new traffic_caps();
                 $data_traffic_overrides->id_service = $this->obj_customer->obj_service->id;
                 $data_traffic_overrides->id_service_customer = $this->obj_customer->id_service_customer;
                 $data_traffic_overrides->load_data_traffic_caps();
                 $data_traffic_overrides->load_data_override_caps();
                 for ($i = 0; $i < $data_traffic_overrides->data_num_rows; $i++) {
                     // define form fields
                     $structure = NULL;
                     $structure["fieldname"] = "traffic_cap_" . $i . "_id";
                     $structure["type"] = "hidden";
                     $structure["defaultvalue"] = $data_traffic_overrides->data[$i]["id_type"];
                     $this->obj_form->add_input($structure);
                     $structure = NULL;
                     $structure["fieldname"] = "traffic_cap_" . $i . "_name";
                     $structure["type"] = "text";
                     $structure["defaultvalue"] = $data_traffic_overrides->data[$i]["type_name"];
                     $this->obj_form->add_input($structure);
                     $structure = NULL;
                     $structure["fieldname"] = "traffic_cap_" . $i . "_mode";
                     $structure["type"] = "dropdown";
                     $structure["values"][0] = "unlimited";
                     $structure["values"][1] = "capped";
                     $structure["defaultvalue"] = $data_traffic_overrides->data[$i]["cap_mode"];
                     $structure["options"]["width"] = "100";
                     $this->obj_form->add_input($structure);
                     $structure = NULL;
                     $structure["fieldname"] = "traffic_cap_" . $i . "_units_included";
                     $structure["type"] = "input";
                     $structure["options"]["width"] = "100";
                     $structure["options"]["label"] = " {$unitname}";
                     $structure["defaultvalue"] = $data_traffic_overrides->data[$i]["cap_units_included"];
                     $this->obj_form->add_input($structure);
                     $structure = NULL;
                     $structure["fieldname"] = "traffic_cap_" . $i . "_units_price";
                     $structure["type"] = "money";
                     $structure["options"]["label"] = " per {$unitname} additional usage.";
                     $structure["defaultvalue"] = $data_traffic_overrides->data[$i]["cap_units_price"];
                     $this->obj_form->add_input($structure);
                     $structure = NULL;
                     $structure["fieldname"] = "traffic_cap_" . $i . "_override";
                     $structure["type"] = "text";
                     $structure["options"]["nohidden"] = 1;
                     if (!empty($data_traffic_overrides->data[$i]["override"])) {
                         $structure["defaultvalue"] = "<span class=\"table_highlight_important\">SERVICE OVERRIDE</span>";
                     }
                     $this->obj_form->add_input($structure);
                     $this->obj_form->subforms_grouped["traffic_caps"]["traffic_cap_" . $i][] = "traffic_cap_" . $i . "_name";
                     $this->obj_form->subforms_grouped["traffic_caps"]["traffic_cap_" . $i][] = "traffic_cap_" . $i . "_mode";
                     $this->obj_form->subforms_grouped["traffic_caps"]["traffic_cap_" . $i][] = "traffic_cap_" . $i . "_units_included";
                     $this->obj_form->subforms_grouped["traffic_caps"]["traffic_cap_" . $i][] = "traffic_cap_" . $i . "_units_price";
                     $this->obj_form->subforms_grouped["traffic_caps"]["traffic_cap_" . $i][] = "traffic_cap_" . $i . "_override";
                     $this->obj_form->subforms_grouped["traffic_caps"]["traffic_cap_" . $i][] = "traffic_cap_" . $i . "_id";
                     $this->obj_form->subforms["traffic_caps"][] = "traffic_cap_" . $i;
                 }
                 unset($data_traffic_overrides);
                 break;
             case "phone_single":
                 // single DDI
                 $structure = NULL;
                 $structure["fieldname"] = "phone_ddi_info";
                 $structure["type"] = "message";
                 $structure["defaultvalue"] = "<i>You must set the DDI of the phone here for billing purposes</i>";
                 $this->obj_form->add_input($structure);
                 $structure = NULL;
                 $structure["fieldname"] = "phone_ddi_single";
                 $structure["type"] = "input";
                 $structure["options"]["req"] = "yes";
                 $structure["options"]["help"] = "eg: 6412345678";
                 $this->obj_form->add_input($structure);
                 if ($GLOBALS["config"]["SERVICE_CDR_LOCAL"] == "prefix") {
                     /*
                     	Prefix-based local rates are easy, we define the prefix number and
                     	from that we match when doing the rate billing.
                     */
                     $structure = NULL;
                     $structure["fieldname"] = "phone_local_prefix";
                     $structure["type"] = "input";
                     $structure["options"]["req"] = "yes";
                     $structure["options"]["help"] = "eg: 64123";
                     $structure["options"]["label"] = " Any calls to numbers matching this prefix will be charged at LOCAL rate.";
                     $this->obj_form->add_input($structure);
                 } else {
                     /*
                     	Handling destination based local calling rates is complex, since we need to:
                      	- fetch a list of all destinations
                     		- include overrides for the service
                     		- include overrides for the customer
                     		- include base zones
                     	- display the label instructing on use
                     	- handle regions that have no destination/description
                     */
                     // fetch all rates, including override rates
                     $obj_local_rates = new cdr_rate_table_rates_override();
                     $obj_local_rates->id = $this->obj_customer->obj_service->data["id_rate_table"];
                     $obj_local_rates->option_type = "customer";
                     $obj_local_rates->option_type_id = $this->obj_customer->id_service_customer;
                     $obj_local_rates->option_type_serviceid = $this->obj_customer->obj_service->id;
                     $obj_local_rates->load_data_rate_all();
                     $obj_local_rates->load_data_rate_all_override();
                     // aggregate the destination
                     $cdr_destinations = array();
                     $cdr_destinations["NONE"] = 1;
                     // placeholder for no local region
                     foreach ($obj_local_rates->data["rates"] as $rate) {
                         if (!empty($rate["rate_description"])) {
                             $cdr_destinations[$rate["rate_description"]] = 1;
                         }
                     }
                     $cdr_destinations = array_keys($cdr_destinations);
                     sort($cdr_destinations);
                     // generate dropdown object
                     $structure = NULL;
                     $structure["fieldname"] = "phone_local_prefix";
                     $structure["type"] = "dropdown";
                     $structure["values"] = $cdr_destinations;
                     $structure["options"]["req"] = "yes";
                     $structure["options"]["label"] = " Charge calls to any prefix in this region as \"LOCAL\" call rates.";
                     $this->obj_form->add_input($structure);
                 }
                 $this->obj_form->subforms["service_options_ddi"] = array("phone_ddi_info", "phone_ddi_single", "phone_local_prefix");
                 break;
             case "phone_tollfree":
                 // single DDI
                 $structure = NULL;
                 $structure["fieldname"] = "phone_ddi_info";
                 $structure["type"] = "message";
                 $structure["defaultvalue"] = "<i>You must set the DDI of the tollfree number here for billing purposes.</i>";
                 $this->obj_form->add_input($structure);
                 $structure = NULL;
                 $structure["fieldname"] = "phone_ddi_single";
                 $structure["type"] = "input";
                 $structure["options"]["req"] = "yes";
                 $this->obj_form->add_input($structure);
                 $this->obj_form->subforms["service_options_ddi"] = array("phone_ddi_info", "phone_ddi_single");
                 // trunk options
                 $structure = NULL;
                 $structure["fieldname"] = "phone_trunk_info";
                 $structure["type"] = "message";
                 $structure["defaultvalue"] = "<i>Define the number of trunks (concurrent calls) that are included in the service, depending on the service plan, there may be additional charges concurred.</i>";
                 $this->obj_form->add_input($structure);
                 $structure = NULL;
                 $structure["fieldname"] = "phone_trunk_included_units";
                 $structure["type"] = "input";
                 $structure["options"]["req"] = "yes";
                 $structure["options"]["width"] = "100";
                 $structure["options"]["label"] = " trunks included in service base fee.";
                 $this->obj_form->add_input($structure);
                 $structure = NULL;
                 $structure["fieldname"] = "phone_trunk_quantity";
                 $structure["type"] = "input";
                 $structure["options"]["req"] = "yes";
                 $structure["options"]["width"] = "100";
                 $structure["options"]["label"] = " trunks assigned to customer (any more than included units will be charged at price per additional trunk).";
                 $this->obj_form->add_input($structure);
                 $structure = NULL;
                 $structure["fieldname"] = "phone_trunk_price_extra_units";
                 $structure["type"] = "money";
                 $this->obj_form->add_input($structure);
                 $this->obj_form->subforms["service_options_trunks"] = array("phone_trunk_info", "phone_trunk_included_units", "phone_trunk_quantity", "phone_trunk_price_extra_units");
                 break;
             case "phone_trunk":
                 /*
                 	
                 	TODO: Javascript-based DDI Configuration
                 
                 
                 					//create html string to input into message field to show DDIs
                 					$html_string = "<div id=\"ddi_form\"><table id=\"ddi_table\"  cellspacing=\"0\"><tr class=\"table_highlight\">
                 								<td><b>" .lang_trans("ddi_start"). "</b></td>
                 								<td><b>" .lang_trans("ddi_finish"). "</b></td>
                 								<td><b>" .lang_trans("description"). "</b></td>
                 								<td>&nbsp;</td></tr>";
                 					
                 					//work out the number of DDI rows needed
                 					if (!isset($_SESSION["error"]["form"][$this->obj_form->formname]))
                 					{
                 						$sql_obj		= New sql_query;
                 						$sql_obj->string	= "SELECT * FROM services_customers_ddi WHERE id_service_customer = '" .$this->obj_customer->id_service_customer. "'";
                 						$sql_obj->execute();
                 				
                 						if ($sql_obj->num_rows())
                 						{
                 							$sql_obj->fetch_array();
                 					
                 							if ($sql_obj->data_num_rows < 2)
                 							{
                 								$this->num_ddi_rows = 2;
                 							}
                 							else
                 							{
                 								$this->num_ddi_rows = $sql_obj->data_num_rows+1;
                 							}
                 						}
                 					}
                 					else
                 					{
                 						$this->num_ddi_rows = @security_script_input('/^[0-9]*$/', $_SESSION["error"]["num_ddi_rows"])+1;
                 					}
                 					
                 					$structure = NULL;
                 					$structure["fieldname"]		= "num_ddi_rows";
                 					$structure["type"]		= "hidden";
                 					$structure["defaultvalue"]	= $this->num_ddi_rows;
                 					$this->obj_form->add_input($structure);
                 					$this->obj_form->subforms["hidden"][] = "num_ddi_rows";
                 					
                 					for ($i= 0; $i < $this->num_ddi_rows; $i++)
                 					{
                 						$html_string .= "<tr class=\"table_highlight\">
                 									<td><input type=\"text\" name=\"ddi_start_$i\" ";
                 						if (isset($sql_obj->data[$i]["ddi_start"]))
                 						{
                 							$html_string .= " value=\"" .$sql_obj->data[$i]["ddi_start"]. "\" /></td>";
                 						}
                 						else
                 						{
                 							$html_string .= " value=\"\" /></td>";
                 						}
                 						
                 						$html_string .= "<td><input type=\"text\" name=\"ddi_finish_$i\" ";
                 						if (isset($sql_obj->data[$i]["ddi_finish"]))
                 						{
                 							$html_string .= " value=\"" .$sql_obj->data[$i]["ddi_finish"]. "\" /></td>";
                 						}
                 						else
                 						{
                 							$html_string .= " value=\"\" /></td>";
                 						}
                 						
                 						$html_string .= "<td><textarea name=\"description_$i\">";
                 						if (isset($sql_obj->data[$i]["description"]))
                 						{
                 							$html_string .= $sql_obj->data[$i]["description"]. "</textarea></td>";
                 						}
                 						else
                 						{
                 							$html_string .= "</textarea></td>";
                 						}
                 						
                 						$html_string .= "<td><input type=\"hidden\" name=\"delete_$i\" ";
                 						if (isset($_SESSION["error"]["form"][$this->obj_form->formname]))
                 						{
                 							$html_string .= " value=\"" .security_script_input_predefined("any",$_SESSION["error"]["delete_$i"]). "\" />";
                 						}
                 						else
                 						{
                 							$html_string .= " value=\"false\" />";
                 						}
                 						$html_string .= "<input type=\"hidden\" name=\"id_$i\" ";
                 						if (isset($_SESSION["error"]["form"][$this->obj_form->formname]))
                 						{
                 							$html_string .= " value=\"" .security_script_input_predefined("any",$_SESSION["error"]["id_$i"]). "\" />";
                 						}
                 						else
                 						{
                 							$html_string .= " value=\"\" />";
                 						}
                 						$html_string .= "<a href=\"\" id=\"delete_link_$i\">delete</a></td></tr>";
                 					}
                 					
                 					$html_string .= "</table></div>";
                 */
                 // DDI options
                 $structure = NULL;
                 $structure["fieldname"] = "phone_ddi_info";
                 $structure["type"] = "message";
                 $structure["defaultvalue"] = "<p>This is a phone trunk service - with this service you are able to have multiple individual DDIs and DDI ranges. Note that it is important to define all the DDIs belonging to this customer, otherwise they may be able to make calls without being charged.<br><br><a class=\"button_small\" href=\"index.php?page=customers/service-ddi.php&id_customer=" . $this->obj_customer->id . "&id_service_customer=" . $this->obj_customer->id_service_customer . "\">Configure Customer's DDIs</a></p>";
                 //					$structure["defaultvalue"]	= "<p>This is a phone trunk service - with this service you are able to have multiple individual DDIs and DDI ranges. Note that it is important to define all the DDIs belonging to this customer, otherwise they may be able to make calls without being charged.<br><br>" .$html_string. "</p>";
                 $this->obj_form->add_input($structure);
                 $structure = NULL;
                 $structure["fieldname"] = "phone_ddi_included_units";
                 $structure["type"] = "input";
                 $structure["options"]["req"] = "yes";
                 $structure["options"]["width"] = "100";
                 $structure["options"]["label"] = " DDI numbers included in service plan fee";
                 $this->obj_form->add_input($structure);
                 $structure = NULL;
                 $structure["fieldname"] = "phone_ddi_price_extra_units";
                 $structure["type"] = "money";
                 $this->obj_form->add_input($structure);
                 // trunk options
                 $structure = NULL;
                 $structure["fieldname"] = "phone_trunk_info";
                 $structure["type"] = "message";
                 $structure["defaultvalue"] = "<p>Define the number of trunks (concurrent calls) that are included in the service, depending on the service plan, there may be additional charges concurred.</p>";
                 $this->obj_form->add_input($structure);
                 $structure = NULL;
                 $structure["fieldname"] = "phone_trunk_included_units";
                 $structure["type"] = "input";
                 $structure["options"]["req"] = "yes";
                 $structure["options"]["width"] = "100";
                 $structure["options"]["label"] = " trunks included in service base fee.";
                 $this->obj_form->add_input($structure);
                 $structure = NULL;
                 $structure["fieldname"] = "phone_trunk_quantity";
                 $structure["type"] = "input";
                 $structure["options"]["req"] = "yes";
                 $structure["options"]["width"] = "100";
                 $structure["options"]["label"] = " trunks assigned to customer (any more than included units will be charged at price per additional trunk).";
                 $this->obj_form->add_input($structure);
                 $structure = NULL;
                 $structure["fieldname"] = "phone_trunk_price_extra_units";
                 $structure["type"] = "money";
                 $this->obj_form->add_input($structure);
                 $this->obj_form->subforms["service_options_ddi"] = array("phone_ddi_info", "phone_ddi_included_units", "phone_ddi_price_extra_units");
                 $this->obj_form->subforms["service_options_trunks"] = array("phone_trunk_info", "phone_trunk_included_units", "phone_trunk_quantity", "phone_trunk_price_extra_units");
                 break;
         }
         /*
         	Check if item belongs to a bundle - if it does, display
         	additional information fields.
         */
         if ($parentid = $this->obj_customer->service_get_is_bundle_item()) {
             // info about bundle
             $structure = NULL;
             $structure["fieldname"] = "bundle_item_msg";
             $structure["type"] = "message";
             $structure["defaultvalue"] = "<p>This service is a part of a bundle assigned to this customer - you can enable/disable this service independently, but the customer will still be billed the same base bundle plan fee.</p>";
             $this->obj_form->add_input($structure);
             // link to parent item
             $obj_component = new service();
             $obj_component->option_type = "customer";
             $obj_component->option_type_id = $parentid;
             $obj_component->verify_id_options();
             $obj_component->load_data();
             $obj_component->load_data_options();
             $structure = NULL;
             $structure["fieldname"] = "bundle_item_parent";
             $structure["type"] = "message";
             $structure["defaultvalue"] = "<table class=\"table_highlight\">" . "<tr>" . "<td>Bundle Parent: <b>" . $obj_component->data["name_service"] . "</b></td>" . "<td>" . $obj_component->data["description"] . "</td>" . "<td><a class=\"button_small\" href=\"index.php?page=customers/service-edit.php&id_customer=" . $this->obj_customer->id . "&id_service_customer=" . $obj_component->option_type_id . "\">View Service</a></td>" . "</tr>" . "</table>";
             $this->obj_form->add_input($structure);
             $this->obj_form->subforms["service_bundle_item"] = array("bundle_item_msg", "bundle_item_parent");
         }
     } else {
         /*
         	A new service is being added
         */
         // basic attributes
         $structure = form_helper_prepare_dropdownfromdb("serviceid", "SELECT id, name_service as label FROM services WHERE active='1' ORDER BY name_service");
         $structure["options"]["req"] = "yes";
         $this->obj_form->add_input($structure);
         $structure = NULL;
         $structure["fieldname"] = "date_period_first";
         $structure["type"] = "date";
         $structure["options"]["req"] = "yes";
         $structure["defaultvalue"] = date("Y-m-d");
         $this->obj_form->add_input($structure);
         $structure = NULL;
         $structure["fieldname"] = "description";
         $structure["type"] = "textarea";
         $this->obj_form->add_input($structure);
         $this->obj_form->subforms["service_add"] = array("serviceid", "date_period_first", "description");
         // migration mode options - these allow some nifty tricks like creating
         // a service period in the previous month to be able to bill for past usage
         if ($GLOBALS['config']['SERVICE_MIGRATION_MODE'] == 1) {
             $structure = NULL;
             $structure["fieldname"] = "migration_date_period_usage_override";
             $structure["type"] = "radio";
             $structure["values"] = array("migration_use_period_date", "migration_use_usage_date");
             $structure["defaultvalue"] = "migration_use_period_date";
             $this->obj_form->add_input($structure);
             $structure = NULL;
             $structure["fieldname"] = "migration_date_period_usage_first";
             $structure["type"] = "date";
             $this->obj_form->add_input($structure);
             $this->obj_form->add_action("migration_date_period_usage_override", "default", "migration_date_period_usage_first", "hide");
             $this->obj_form->add_action("migration_date_period_usage_override", "migration_use_usage_date", "migration_date_period_usage_first", "show");
             $this->obj_form->subforms["service_migration"] = array("migration_date_period_usage_override", "migration_date_period_usage_first");
         }
     }
     // hidden values
     $structure = NULL;
     $structure["fieldname"] = "id_customer";
     $structure["type"] = "hidden";
     $structure["defaultvalue"] = $this->obj_customer->id;
     $this->obj_form->add_input($structure);
     // submit button
     $structure = NULL;
     $structure["fieldname"] = "submit";
     $structure["type"] = "submit";
     if ($this->obj_customer->id_service_customer) {
         $structure["defaultvalue"] = "Save Changes";
     } else {
         $structure["defaultvalue"] = "Add Service";
     }
     $this->obj_form->add_input($structure);
     // define base subforms
     $this->obj_form->subforms["hidden"][] = "id_customer";
     if (user_permissions_get("customers_write")) {
         $this->obj_form->subforms["submit"] = array("submit");
     } else {
         $this->obj_form->subforms["submit"] = array();
     }
     // fetch the form data if editing
     if ($this->obj_customer->id_service_customer) {
         // fetch service data
         $this->obj_form->structure["description"]["defaultvalue"] = $this->obj_customer->obj_service->data["description"];
         $this->obj_form->structure["name_service"]["defaultvalue"] = $this->obj_customer->obj_service->data["name_service"];
         foreach (array_keys($this->obj_customer->obj_service->data) as $option_name) {
             if (isset($this->obj_form->structure[$option_name])) {
                 $this->obj_form->structure[$option_name]["defaultvalue"] = $this->obj_customer->obj_service->data[$option_name];
             }
         }
         // fetch DB data
         $this->obj_form->sql_query = "SELECT active, date_period_first, date_period_next, date_period_last FROM `services_customers` WHERE id='" . $this->obj_customer->id_service_customer . "' LIMIT 1";
         $this->obj_form->load_data();
     }
     if (error_check()) {
         // load any data returned due to errors
         $this->obj_form->load_data_error();
     }
 }
 function execute()
 {
     /*
     	Define fields and column examples
     */
     $this->num_col = count($_SESSION["csv_array"][0]);
     $values_array = array("col_destination", "col_prefix", "col_cost_price", "col_sale_price");
     $this->obj_form = new form_input();
     $this->obj_form->formname = "cdr_rate_table_import_csv";
     // for each entry in the sub array, create a drop down menu
     for ($i = 1; $i <= $this->num_col; $i++) {
         $name = "column" . $i;
         $structure = NULL;
         $structure["fieldname"] = $name;
         $structure["type"] = "dropdown";
         $structure["values"] = $values_array;
         $this->obj_form->add_input($structure);
     }
     // import options
     $structure = NULL;
     $structure["fieldname"] = "cdr_rate_import_mode";
     $structure["type"] = "radio";
     $structure["values"] = array("cdr_import_delete_existing", "cdr_import_update_existing");
     $structure["defaultvalue"] = "cdr_import_update_existing";
     $this->obj_form->add_input($structure);
     $structure = form_helper_prepare_dropdownfromdb("rate_billgroup", "SELECT id, billgroup_name as label FROM cdr_rate_billgroups");
     $structure["options"]["req"] = "yes";
     $structure["options"]["width"] = "100";
     $this->obj_form->add_input($structure);
     $structure = NULL;
     $structure["fieldname"] = "cdr_rate_import_cost_price";
     $structure["type"] = "radio";
     $structure["values"] = array("cdr_import_cost_price_use_csv", "cdr_import_cost_price_nothing");
     $this->obj_form->add_input($structure);
     $structure = NULL;
     $structure["fieldname"] = "cdr_rate_import_sale_price";
     $structure["type"] = "radio";
     $structure["values"] = array("cdr_import_sale_price_use_csv", "cdr_import_sale_price_nothing", "cdr_import_sale_price_margin");
     $this->obj_form->add_input($structure);
     $structure = NULL;
     $structure["fieldname"] = "cdr_rate_import_sale_price_margin";
     $structure["type"] = "input";
     $structure["options"]["width"] = "50";
     $this->obj_form->add_input($structure);
     // hidden fields
     $structure = NULL;
     $structure["fieldname"] = "id_rate_table";
     $structure["type"] = "hidden";
     $structure["defaultvalue"] = $this->obj_rate_table->id;
     $this->obj_form->add_input($structure);
     $structure = NULL;
     $structure["fieldname"] = "num_cols";
     $structure["type"] = "hidden";
     $structure["defaultvalue"] = $this->num_col;
     $this->obj_form->add_input($structure);
     // submit
     $structure = NULL;
     $structure["fieldname"] = "submit";
     $structure["type"] = "submit";
     $structure["defaultvalue"] = "submit";
     $this->obj_form->add_input($structure);
     /*
     	populate an array of examples
     	create one for each entry in the sub arrays
     */
     for ($i = 0; $i < $this->num_col; $i++) {
         //check for example in each array
         //start from the bottom to find examples- this ensures more accurate data
         //do not create an example if no data is present in any of the columns
         for ($j = count($_SESSION["csv_array"]) - 1; $j > 0; $j--) {
             if ($_SESSION["csv_array"][$j][$i] != "") {
                 $this->example_array[$i + 1] = $_SESSION["csv_array"][$j][$i];
                 break;
             }
         }
     }
     /*
     	Load error data (if any)
     */
     if (error_check()) {
         $this->obj_form->load_data_error();
     }
 }
Example #27
0
 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()
 {
     // establish a new table object
     $this->obj_table = new table();
     $this->obj_table->language = $_SESSION["user"]["lang"];
     $this->obj_table->tablename = "cdr_rate_table_items";
     // define all the columns and structure
     if ($this->mode == "group") {
         $this->obj_table->add_column("standard", "rate_prefix", "GROUP_CONCAT(' ', rate_prefix)");
     } else {
         $this->obj_table->add_column("standard", "rate_prefix", "");
     }
     $this->obj_table->add_column("standard", "rate_description", "");
     $this->obj_table->add_column("standard", "rate_billgroup", "cdr_rate_billgroups.billgroup_name");
     $this->obj_table->add_column("money_float", "rate_price_sale", "");
     $this->obj_table->add_column("money_float", "rate_price_cost", "");
     // defaults
     $this->obj_table->columns = array("rate_prefix", "rate_description", "rate_billgroup", "rate_price_sale", "rate_price_cost");
     $this->obj_table->columns_order = array("rate_prefix");
     $this->obj_table->columns_order_options = array("rate_prefix", "rate_description", "rate_billgroup");
     $this->obj_table->limit_rows = "1000";
     // define SQL structure
     $this->obj_table->sql_obj->prepare_sql_settable("cdr_rate_tables_values");
     $this->obj_table->sql_obj->prepare_sql_addjoin("LEFT JOIN cdr_rate_billgroups ON cdr_rate_billgroups.id = cdr_rate_tables_values.rate_billgroup");
     $this->obj_table->sql_obj->prepare_sql_addfield("id", "cdr_rate_tables_values.id");
     $this->obj_table->sql_obj->prepare_sql_addwhere("id_rate_table='" . $this->obj_rate_table->id . "'");
     $this->obj_table->sql_obj->prepare_sql_addgroupby("rate_description, rate_billgroup, rate_price_sale, rate_price_cost");
     // acceptable filter options
     $structure["fieldname"] = "searchbox_prefix";
     $structure["type"] = "input";
     $structure["sql"] = "rate_prefix LIKE 'value%'";
     $this->obj_table->add_filter($structure);
     $structure["fieldname"] = "searchbox_desc";
     $structure["type"] = "input";
     $structure["sql"] = "rate_description LIKE '%value%'";
     $this->obj_table->add_filter($structure);
     $structure = form_helper_prepare_dropdownfromdb("billgroup", "SELECT id, billgroup_name as label FROM cdr_rate_billgroups");
     $structure["sql"] = "rate_billgroup='value'";
     $structure["options"]["search_filter"] = NULL;
     $this->obj_table->add_filter($structure);
     $structure["fieldname"] = "search_summarise";
     $structure["type"] = "checkbox";
     $structure["sql"] = "";
     $structure["defaultvalue"] = "on";
     $this->obj_table->add_filter($structure);
     $this->obj_table->add_fixed_option("id", $this->obj_rate_table->id);
     // load options
     $this->obj_table->load_options_form();
     // increase limit of group data
     $obj_group_sql = new sql_query();
     $obj_group_sql->string = "SET group_concat_max_len = 4092";
     $obj_group_sql->execute();
     // fetch all the service information
     $this->obj_table->generate_sql();
     $this->obj_table->load_data_sql();
 }
 function execute()
 {
     // load data
     $this->obj_customer->load_data();
     // define basic form details
     $this->obj_form = new form_input();
     $this->obj_form->formname = "cdr_override_edit";
     $this->obj_form->language = $_SESSION["user"]["lang"];
     $this->obj_form->action = "customers/service-cdr-override-edit-process.php";
     $this->obj_form->method = "post";
     // service details
     $structure = NULL;
     $structure["fieldname"] = "name_customer";
     $structure["type"] = "text";
     $this->obj_form->add_input($structure);
     $structure = NULL;
     $structure["fieldname"] = "service_name";
     $structure["type"] = "text";
     $this->obj_form->add_input($structure);
     $structure = NULL;
     $structure["fieldname"] = "service_description";
     $structure["type"] = "text";
     $this->obj_form->add_input($structure);
     // rate table details
     $structure = NULL;
     $structure["fieldname"] = "rate_table_name";
     $structure["type"] = "text";
     $this->obj_form->add_input($structure);
     $structure = NULL;
     $structure["fieldname"] = "rate_table_description";
     $structure["type"] = "text";
     $this->obj_form->add_input($structure);
     // item options
     $structure = NULL;
     $structure["fieldname"] = "rate_prefix";
     $structure["type"] = "input";
     $structure["options"]["req"] = "yes";
     $this->obj_form->add_input($structure);
     $structure = NULL;
     $structure["fieldname"] = "rate_description";
     $structure["type"] = "input";
     $structure["options"]["req"] = "yes";
     $this->obj_form->add_input($structure);
     $structure = form_helper_prepare_dropdownfromdb("rate_billgroup", "SELECT id, billgroup_name as label FROM cdr_rate_billgroups");
     $structure["options"]["req"] = "yes";
     $structure["options"]["width"] = "100";
     $this->obj_form->add_input($structure);
     $structure = NULL;
     $structure["fieldname"] = "rate_price_sale";
     $structure["type"] = "money";
     $structure["options"]["req"] = "yes";
     $this->obj_form->add_input($structure);
     $structure = NULL;
     $structure["fieldname"] = "rate_price_cost";
     $structure["type"] = "money";
     $this->obj_form->add_input($structure);
     // hidden
     $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_service_customer";
     $structure["type"] = "hidden";
     $structure["defaultvalue"] = $this->obj_customer->id_service_customer;
     $this->obj_form->add_input($structure);
     $structure = NULL;
     $structure["fieldname"] = "id_rate_override";
     $structure["type"] = "hidden";
     $structure["defaultvalue"] = $this->obj_cdr_rate_table->id_rate_override;
     $this->obj_form->add_input($structure);
     // submit button
     $structure = NULL;
     $structure["fieldname"] = "submit";
     $structure["type"] = "submit";
     $structure["defaultvalue"] = "submit";
     $this->obj_form->add_input($structure);
     // define subforms
     $this->obj_form->subforms["service_details"] = array("name_customer", "service_name", "service_description");
     $this->obj_form->subforms["rate_table_details"] = array("rate_table_name", "rate_table_description");
     $this->obj_form->subforms["rate_table_items"] = array("rate_prefix", "rate_description", "rate_billgroup", "rate_price_sale", "rate_price_cost");
     $this->obj_form->subforms["hidden"] = array("id_customer", "id_service_customer", "id_rate_override");
     $this->obj_form->subforms["submit"] = array("submit");
     // load any data returned due to errors
     if (error_check()) {
         $this->obj_form->load_data_error();
     } else {
         $this->obj_cdr_rate_table->load_data();
         // load rate values from standard item
         if ($this->obj_cdr_rate_table->id_rate) {
             $this->obj_cdr_rate_table->load_data_rate();
         }
         // load override values
         if ($this->obj_cdr_rate_table->id_rate_override) {
             $this->obj_cdr_rate_table->load_data_rate_override();
         }
         $this->obj_form->structure["name_customer"]["defaultvalue"] = $this->obj_customer->data["name_customer"];
         $this->obj_form->structure["service_name"]["defaultvalue"] = $this->obj_customer->obj_service->data["name_service"];
         $this->obj_form->structure["service_description"]["defaultvalue"] = $this->obj_customer->obj_service->data["description"];
         $this->obj_form->structure["rate_table_name"]["defaultvalue"] = $this->obj_cdr_rate_table->data["rate_table_name"];
         $this->obj_form->structure["rate_table_description"]["defaultvalue"] = $this->obj_cdr_rate_table->data["rate_table_description"];
         $this->obj_form->structure["rate_prefix"]["defaultvalue"] = $this->obj_cdr_rate_table->data_rate["rate_prefix"];
         $this->obj_form->structure["rate_description"]["defaultvalue"] = $this->obj_cdr_rate_table->data_rate["rate_description"];
         $this->obj_form->structure["rate_billgroup"]["defaultvalue"] = $this->obj_cdr_rate_table->data_rate["rate_billgroup"];
         $this->obj_form->structure["rate_price_sale"]["defaultvalue"] = $this->obj_cdr_rate_table->data_rate["rate_price_sale"];
         $this->obj_form->structure["rate_price_cost"]["defaultvalue"] = $this->obj_cdr_rate_table->data_rate["rate_price_cost"];
     }
 }
 function execute()
 {
     // establish a new table object
     $this->obj_table = new table();
     $this->obj_table->language = $_SESSION["user"]["lang"];
     $this->obj_table->tablename = "invoice-bulk-payments-ar";
     // define all the columns and structure
     $this->obj_table->add_column("standard", "code_invoice", "account_ar.code_invoice");
     $this->obj_table->add_column("standard", "code_ordernumber", "account_ar.code_ordernumber");
     $this->obj_table->add_column("standard", "code_ponumber", "account_ar.code_ponumber");
     $this->obj_table->add_column("standard", "name_customer", "CONCAT_WS(' -- ', customers.code_customer, customers.name_customer)");
     $this->obj_table->add_column("standard", "name_staff", "CONCAT_WS(' -- ', staff.staff_code, staff.name_staff)");
     $this->obj_table->add_column("date", "date_trans", "account_ar.date_trans");
     $this->obj_table->add_column("date", "date_due", "account_ar.date_due");
     $this->obj_table->add_column("price", "amount_tax", "account_ar.amount_tax");
     $this->obj_table->add_column("price", "amount", "account_ar.amount");
     $this->obj_table->add_column("price", "amount_total", "account_ar.amount_total");
     $this->obj_table->add_column("price", "amount_paid", "account_ar.amount_paid");
     $this->obj_table->add_column("bool_tick", "sent", "account_ar.sentmethod");
     $this->obj_table->add_column("standard", "pay", "NONE");
     // defaults
     $this->obj_table->columns = array("code_invoice", "name_customer", "date_trans", "amount_total", "amount_paid", "pay");
     $this->obj_table->columns_order = array("code_invoice");
     $this->obj_table->columns_order_options = array("code_invoice", "code_ordernumber", "code_ponumber", "name_customer", "name_staff", "date_trans", "date_due", "sent", "pay");
     // 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_trans >= 'value'";
     $this->obj_table->add_filter($structure);
     $structure = NULL;
     $structure["fieldname"] = "date_end";
     $structure["type"] = "date";
     $structure["sql"] = "date_trans <= 'value'";
     $this->obj_table->add_filter($structure);
     $structure = form_helper_prepare_dropdownfromdb("employeeid", "SELECT id, staff_code as label, name_staff as label1 FROM staff ORDER BY name_staff");
     $structure["sql"] = "account_ar.employeeid='value'";
     $structure["options"]["search_filter"] = "enabled";
     $this->obj_table->add_filter($structure);
     $structure = form_helper_prepare_dropdownfromdb("customerid", "SELECT id, code_customer as label, name_customer as label1 FROM customers ORDER BY name_customer");
     $structure["sql"] = "account_ar.customerid='value'";
     $structure["options"]["search_filter"] = "enabled";
     $this->obj_table->add_filter($structure);
     $structure = NULL;
     $structure["fieldname"] = "hide_closed";
     $structure["type"] = "checkbox";
     $structure["options"]["label"] = "Hide Closed Invoices";
     $structure["defaultvalue"] = "enabled";
     $structure["sql"] = "account_ar.amount_paid!=account_ar.amount_total";
     $this->obj_table->add_filter($structure);
     // load options
     $this->obj_table->load_options_form();
     // fetch all the chart information
     $this->obj_table->generate_sql();
     $this->obj_table->load_data_sql();
     //establish new form object
     $this->obj_form = new form_input();
     $this->obj_form->formname = "invoice-bulk-payments-ar";
     $this->obj_form->language = $_SESSION["user"]["lang"];
     $this->obj_form->action = "accounts/ar/invoice-bulk-payments-process.php";
     $this->obj_form->method = "post";
     $highest_invoice_id = 0;
     //create form fields
     for ($i = 0; $i < $this->obj_table->data_num_rows; $i++) {
         $structure = NULL;
         $structure["fieldname"] = "pay_invoice_" . $this->obj_table->data[$i]["id"];
         $structure["type"] = "checkbox";
         $structure["options"]["nolabel"] = "true";
         $this->obj_form->add_input($structure);
         $structure = NULL;
         $structure["fieldname"] = "checked_status_invoice_" . $this->obj_table->data[$i]["id"];
         $structure["type"] = "hidden";
         $structure["defaultvalue"] = "false";
         $this->obj_form->add_input($structure);
         $structure = NULL;
         $structure["fieldname"] = "amount_invoice_" . $this->obj_table->data[$i]["id"];
         $structure["type"] = "money";
         $this->obj_form->add_input($structure);
         if ($this->obj_table->data[$i]["id"] > $highest_invoice_id) {
             $highest_invoice_id = $this->obj_table->data[$i]["id"];
         }
     }
     $structure = NULL;
     $structure["fieldname"] = "payment_date";
     $structure["type"] = "date";
     $structure["defaultvalue"] = date("Y-m-d");
     $structure["options"]["prelabel"] = "Payment Date: ";
     $this->obj_form->add_input($structure);
     $structure = NULL;
     $structure = charts_form_prepare_acccountdropdown("chartid", "ar_payment");
     $this->obj_form->add_input($structure);
     $structure = NULL;
     $structure["fieldname"] = "highest_invoice_id";
     $structure["type"] = "hidden";
     $structure["defaultvalue"] = $highest_invoice_id;
     $this->obj_form->add_input($structure);
     $structure = NULL;
     $structure["fieldname"] = "submit";
     $structure["type"] = "submit";
     $structure["defaultvalue"] = "Submit Payments";
     $this->obj_form->add_input($structure);
     //load any error data
     $this->obj_form->load_data();
 }