Example #1
0
 function execute()
 {
     /*
     	Define form structure
     */
     $this->obj_form = new form_input();
     $this->obj_form->formname = "chart_add";
     $this->obj_form->language = $_SESSION["user"]["lang"];
     $this->obj_form->action = "accounts/charts/edit-process.php";
     $this->obj_form->method = "post";
     // general
     $structure = NULL;
     $structure["fieldname"] = "code_chart";
     $structure["type"] = "input";
     $this->obj_form->add_input($structure);
     $structure = NULL;
     $structure["fieldname"] = "description";
     $structure["type"] = "input";
     $structure["options"]["req"] = "yes";
     $this->obj_form->add_input($structure);
     $structure = form_helper_prepare_radiofromdb("chart_type", "SELECT id, value as label FROM account_chart_type");
     $structure["options"]["req"] = "yes";
     $this->obj_form->add_input($structure);
     // submit button
     $structure = NULL;
     $structure["fieldname"] = "submit";
     $structure["type"] = "submit";
     $structure["defaultvalue"] = "Create Chart";
     $this->obj_form->add_input($structure);
     // define subforms
     $this->obj_form->subforms["chart_details"] = array("code_chart", "description", "chart_type");
     $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 #3
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 #4
0
 function execute()
 {
     /*
     	Define form structure
     */
     $this->obj_form = new form_input();
     $this->obj_form->formname = "name_server_edit";
     $this->obj_form->language = $_SESSION["user"]["lang"];
     $this->obj_form->action = "servers/edit-process.php";
     $this->obj_form->method = "post";
     // general
     $structure = NULL;
     $structure["fieldname"] = "server_name";
     $structure["type"] = "input";
     $structure["options"]["req"] = "yes";
     $this->obj_form->add_input($structure);
     $structure = NULL;
     $structure["fieldname"] = "server_description";
     $structure["type"] = "textarea";
     $this->obj_form->add_input($structure);
     // api
     $structure = NULL;
     $structure["fieldname"] = "server_type";
     $structure["type"] = "radio";
     $structure["values"] = array("api", "route53");
     if ($GLOBALS["config"]["ZONE_DB_TYPE"] == "powerdns-mysql") {
         $structure["values"][] = "powerdns-compat";
     }
     $structure["defaultvalue"] = "api";
     $this->obj_form->add_input($structure);
     $this->obj_form->add_action("server_type", "default", "api_auth_key", "hide");
     $this->obj_form->add_action("server_type", "default", "server_primary", "show");
     $this->obj_form->add_action("server_type", "default", "server_record", "show");
     $this->obj_form->add_action("server_type", "default", "route53_access_key", "hide");
     $this->obj_form->add_action("server_type", "default", "route53_secret_key", "hide");
     $this->obj_form->add_action("server_type", "api", "api_auth_key", "show");
     $this->obj_form->add_action("server_type", "api", "server_primary", "show");
     $this->obj_form->add_action("server_type", "api", "server_record", "show");
     $this->obj_form->add_action("server_type", "api", "route53_access_key", "hide");
     $this->obj_form->add_action("server_type", "api", "route53_secret_key", "hide");
     $this->obj_form->add_action("server_type", "route53", "api_auth_key", "hide");
     $this->obj_form->add_action("server_type", "route53", "server_primary", "hide");
     $this->obj_form->add_action("server_type", "route53", "server_record", "hide");
     $this->obj_form->add_action("server_type", "route53", "route53_access_key", "show");
     $this->obj_form->add_action("server_type", "route53", "route53_secret_key", "show");
     $structure = NULL;
     $structure["fieldname"] = "api_auth_key";
     $structure["type"] = "input";
     $structure["options"]["req"] = "yes";
     $structure["options"]["label"] = " " . lang_trans("help_api_auth_key");
     $this->obj_form->add_input($structure);
     $structure = NULL;
     $structure["fieldname"] = "route53_access_key";
     $structure["type"] = "input";
     $structure["options"]["req"] = "yes";
     $structure["options"]["label"] = " " . lang_trans("route53_access_key");
     $this->obj_form->add_input($structure);
     $structure = NULL;
     $structure["fieldname"] = "route53_secret_key";
     $structure["type"] = "input";
     $structure["options"]["req"] = "yes";
     $structure["options"]["help"] = "Secret Key Hidden, Click to Change";
     $structure["options"]["label"] = " " . lang_trans("help_hosted_route53_secret_key");
     $this->obj_form->add_input($structure);
     // server attributes
     $structure = form_helper_prepare_radiofromdb("id_group", "SELECT id, group_name as label, group_description as label1 FROM name_servers_groups");
     $structure["options"]["req"] = "yes";
     $structure["options"]["autoselect"] = 1;
     $this->obj_form->add_input($structure);
     $structure = NULL;
     $structure["fieldname"] = "server_primary";
     $structure["type"] = "checkbox";
     $structure["options"]["req"] = "yes";
     $structure["options"]["label"] = lang_trans("server_primary_option_help");
     $this->obj_form->add_input($structure);
     $structure = NULL;
     $structure["fieldname"] = "server_record";
     $structure["type"] = "checkbox";
     $structure["options"]["req"] = "yes";
     $structure["options"]["label"] = lang_trans("server_record_option_help");
     $structure["defaultvalue"] = "on";
     $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);
     // subforms
     $this->obj_form->subforms["server_details"] = array("server_name", "server_description");
     $this->obj_form->subforms["server_type"] = array("server_type", "api_auth_key", "route53_access_key", "route53_secret_key");
     $this->obj_form->subforms["server_domains"] = array("id_group", "server_primary", "server_record");
     $this->obj_form->subforms["submit"] = array("submit");
     // load data
     if (error_check()) {
         $this->obj_form->load_data_error();
     }
 }
Example #5
0
 function execute()
 {
     /*
     	Define form structure
     */
     $this->obj_form = new form_input();
     $this->obj_form->formname = "name_server_edit";
     $this->obj_form->language = $_SESSION["user"]["lang"];
     $this->obj_form->action = "servers/edit-process.php";
     $this->obj_form->method = "post";
     // general
     $structure = NULL;
     $structure["fieldname"] = "server_name";
     $structure["type"] = "input";
     $structure["options"]["req"] = "yes";
     $this->obj_form->add_input($structure);
     $structure = NULL;
     $structure["fieldname"] = "server_description";
     $structure["type"] = "textarea";
     $this->obj_form->add_input($structure);
     // api
     $structure = NULL;
     $structure["fieldname"] = "server_type";
     $structure["type"] = "radio";
     $structure["values"] = array("api", "route53");
     if ($GLOBALS["config"]["ZONE_DB_TYPE"] == "powerdns-mysql") {
         $structure["values"][] = "powerdns-compat";
     }
     $structure["defaultvalue"] = "api";
     $this->obj_form->add_input($structure);
     $this->obj_form->add_action("server_type", "default", "api_auth_key", "hide");
     $this->obj_form->add_action("server_type", "default", "server_primary", "show");
     $this->obj_form->add_action("server_type", "default", "server_record", "show");
     $this->obj_form->add_action("server_type", "default", "route53_access_key", "hide");
     $this->obj_form->add_action("server_type", "default", "route53_secret_key", "hide");
     $this->obj_form->add_action("server_type", "default", "sync_status_log", "show");
     $this->obj_form->add_action("server_type", "api", "api_auth_key", "show");
     $this->obj_form->add_action("server_type", "api", "server_primary", "show");
     $this->obj_form->add_action("server_type", "api", "server_record", "show");
     $this->obj_form->add_action("server_type", "api", "route53_access_key", "hide");
     $this->obj_form->add_action("server_type", "api", "route53_secret_key", "hide");
     $this->obj_form->add_action("server_type", "api", "sync_status_log", "show");
     $this->obj_form->add_action("server_type", "route53", "api_auth_key", "hide");
     $this->obj_form->add_action("server_type", "route53", "server_primary", "hide");
     $this->obj_form->add_action("server_type", "route53", "server_record", "hide");
     $this->obj_form->add_action("server_type", "route53", "route53_access_key", "show");
     $this->obj_form->add_action("server_type", "route53", "route53_secret_key", "show");
     $this->obj_form->add_action("server_type", "route53", "sync_status_log", "hide");
     $structure = NULL;
     $structure["fieldname"] = "api_auth_key";
     $structure["type"] = "input";
     $structure["options"]["req"] = "yes";
     $structure["options"]["label"] = " " . lang_trans("help_api_auth_key");
     $this->obj_form->add_input($structure);
     $structure = NULL;
     $structure["fieldname"] = "route53_access_key";
     $structure["type"] = "input";
     $structure["options"]["req"] = "yes";
     $structure["options"]["label"] = " " . lang_trans("route53_access_key");
     $this->obj_form->add_input($structure);
     $structure = NULL;
     $structure["fieldname"] = "route53_secret_key";
     $structure["type"] = "input";
     $structure["options"]["req"] = "yes";
     $structure["options"]["help"] = "Secret Key Hidden, Click to Change";
     $structure["options"]["label"] = " " . lang_trans("help_hosted_route53_secret_key");
     $this->obj_form->add_input($structure);
     // server attributes
     $structure = form_helper_prepare_radiofromdb("id_group", "SELECT id, group_name as label, group_description as label1 FROM name_servers_groups");
     $structure["options"]["req"] = "yes";
     $this->obj_form->add_input($structure);
     $structure = NULL;
     $structure["fieldname"] = "server_primary";
     $structure["type"] = "checkbox";
     $structure["options"]["req"] = "yes";
     $structure["options"]["label"] = lang_trans("server_primary_option_help");
     $this->obj_form->add_input($structure);
     $structure = NULL;
     $structure["fieldname"] = "server_record";
     $structure["type"] = "checkbox";
     $structure["options"]["req"] = "yes";
     $structure["options"]["label"] = lang_trans("server_record_option_help");
     $this->obj_form->add_input($structure);
     // sync status
     $structure = NULL;
     $structure["fieldname"] = "sync_status_config";
     $structure["type"] = "text";
     $structure["options"]["nohidden"] = "hide";
     $this->obj_form->add_input($structure);
     $structure = NULL;
     $structure["fieldname"] = "sync_status_log";
     $structure["type"] = "text";
     $structure["options"]["nohidden"] = "hide";
     $this->obj_form->add_input($structure);
     // hidden section
     $structure = NULL;
     $structure["fieldname"] = "id_name_server";
     $structure["type"] = "hidden";
     $structure["defaultvalue"] = $this->obj_name_server->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["server_details"] = array("server_name", "server_description");
     $this->obj_form->subforms["server_type"] = array("server_type", "api_auth_key", "route53_access_key", "route53_secret_key");
     $this->obj_form->subforms["server_domains"] = array("id_group", "server_primary", "server_record");
     $this->obj_form->subforms["server_status"] = array("sync_status_config", "sync_status_log");
     $this->obj_form->subforms["hidden"] = array("id_name_server");
     $this->obj_form->subforms["submit"] = array("submit");
     // import data
     if (error_check()) {
         $this->obj_form->load_data_error();
     } else {
         if ($this->obj_name_server->load_data()) {
             $this->obj_form->structure["server_name"]["defaultvalue"] = $this->obj_name_server->data["server_name"];
             $this->obj_form->structure["server_description"]["defaultvalue"] = $this->obj_name_server->data["server_description"];
             $this->obj_form->structure["id_group"]["defaultvalue"] = $this->obj_name_server->data["id_group"];
             $this->obj_form->structure["server_primary"]["defaultvalue"] = $this->obj_name_server->data["server_primary"];
             $this->obj_form->structure["server_record"]["defaultvalue"] = $this->obj_name_server->data["server_record"];
             $this->obj_form->structure["server_type"]["defaultvalue"] = $this->obj_name_server->data["server_type"];
             switch ($this->obj_name_server->data["server_type"]) {
                 case "route53":
                     $keys = unserialize($this->obj_name_server->data["api_auth_key"]);
                     $this->obj_form->structure["route53_access_key"]["defaultvalue"] = $keys["route53_access_key"];
                     break;
                 case "api":
                 default:
                     $this->obj_form->structure["api_auth_key"]["defaultvalue"] = $this->obj_name_server->data["api_auth_key"];
                     break;
             }
             if (!empty($this->obj_name_server->data["sync_status_config"])) {
                 $this->obj_form->structure["sync_status_config"]["defaultvalue"] = "<span class=\"table_highlight_important\">" . lang_trans("status_unsynced") . "</span> Last synced on " . time_format_humandate($this->obj_name_server->data["api_sync_config"]) . " " . date("H:i:s", $this->obj_name_server->data["api_sync_log"]) . "";
             } else {
                 $this->obj_form->structure["sync_status_config"]["defaultvalue"] = "<span class=\"table_highlight_open\">" . lang_trans("status_synced") . "</span>";
             }
             if ($GLOBALS["config"]["FEATURE_LOGS_ENABLE"]) {
                 if (!empty($this->obj_name_server->data["sync_status_log"])) {
                     $this->obj_form->structure["sync_status_log"]["defaultvalue"] = "<span class=\"table_highlight_important\">" . lang_trans("status_unsynced") . "</span> Logging appears stale, last synced on " . time_format_humandate($this->obj_name_server->data["api_sync_log"]) . " " . date("H:i:s", $this->obj_name_server->data["api_sync_log"]) . "";
                 } else {
                     $this->obj_form->structure["sync_status_log"]["defaultvalue"] = "<span class=\"table_highlight_open\">" . lang_trans("status_synced") . "</span> Last log message delivered on " . time_format_humandate($this->obj_name_server->data["api_sync_log"]) . " " . date("H:i:s", $this->obj_name_server->data["api_sync_log"]) . "";
                 }
             } else {
                 $this->obj_form->structure["sync_status_log"]["defaultvalue"] = "<span class=\"table_highlight_disabled\">" . lang_trans("status_disabled") . "</span>";
             }
         }
     }
 }
Example #6
0
 function execute()
 {
     /*
     	Define form structure
     */
     $this->obj_form = new form_input();
     $this->obj_form->formname = "user_options";
     $this->obj_form->language = $_SESSION["user"]["lang"];
     $this->obj_form->action = "user/options-process.php";
     $this->obj_form->method = "post";
     // 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"];
         }
     }
     // general
     $structure = NULL;
     $structure["fieldname"] = "username";
     $structure["type"] = "text";
     $structure["defaultvalue"] = $_SESSION["user"]["name"];
     $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);
     // submit section
     $structure = NULL;
     $structure["fieldname"] = "submit";
     $structure["type"] = "submit";
     $structure["defaultvalue"] = "Save Changes";
     $this->obj_form->add_input($structure);
     // define main subforms
     $this->obj_form->subforms["user_view"] = array("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");
     // OPTIONS:
     // language
     $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);
     $this->obj_form->subforms["user_options"][] = "option_lang";
     // date format
     $structure = NULL;
     $structure["fieldname"] = "option_dateformat";
     $structure["type"] = "radio";
     $structure["values"] = array("yyyy-mm-dd", "mm-dd-yyyy", "dd-mm-yyyy");
     $structure["defaultvalue"] = $options["dateformat"];
     $this->obj_form->add_input($structure);
     $this->obj_form->subforms["user_options"][] = "option_dateformat";
     /*
     		Timezone support not required for this application
     
     		// timezone
     		$structure 			= form_helper_prepare_timezonedropdown("option_timezone");
     		$structure["defaultvalue"]	= $options["timezone"];
     		$this->obj_form->add_input($structure);
     		
     		$this->obj_form->subforms["user_options"][]	= "option_timezone";
     */
     // table options form shrink configuration
     $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);
     $this->obj_form->subforms["user_options"][] = "option_shrink_tableoptions";
     // administrator-only option
     if (user_permissions_get("namedadmins")) {
         // debugging
         $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>(note: this option is only avaliable to administrators)</i>";
         $this->obj_form->add_input($structure);
         // concurrent logins
         $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</i>";
         $this->obj_form->add_input($structure);
         $this->obj_form->subforms["user_options"][] = "option_debug";
         $this->obj_form->subforms["user_options"][] = "option_concurrent_logins";
     }
     // remaining subforms
     $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"]);
 }
 function execute()
 {
     /*
     	Define form structure
     */
     $this->obj_form = new form_input();
     $this->obj_form->formname = "config_locale";
     $this->obj_form->language = $_SESSION["user"]["lang"];
     $this->obj_form->action = "admin/config_locale-process.php";
     $this->obj_form->method = "post";
     // language options
     $structure = form_helper_prepare_radiofromdb("LANGUAGE_DEFAULT", "SELECT name as id, name as label FROM language_avaliable ORDER BY name");
     $structure["options"]["no_translate_fieldname"] = "yes";
     $this->obj_form->add_input($structure);
     // appearance options
     $structure = form_helper_prepare_dropdownfromdb("THEME_DEFAULT", "SELECT id, theme_name as label FROM themes ORDER BY theme_name");
     $structure["options"]["autoselect"] = "yes";
     $structure["options"]["no_translate_fieldname"] = "yes";
     $this->obj_form->add_input($structure);
     $structure = NULL;
     $structure["fieldname"] = "TABLE_LIMIT";
     $structure["type"] = "input";
     $structure["options"]["no_translate_fieldname"] = "yes";
     $structure["options"]["label"] = " " . lang_trans("help_table_limit");
     $this->obj_form->add_input($structure);
     // time options
     $structure = form_helper_prepare_timezonedropdown("TIMEZONE_DEFAULT");
     $structure["options"]["no_translate_fieldname"] = "yes";
     $structure["options"]["search_filter"] = "yes";
     $this->obj_form->add_input($structure);
     $structure = NULL;
     $structure["fieldname"] = "DATEFORMAT";
     $structure["type"] = "radio";
     $structure["values"] = array("yyyy-mm-dd", "mm-dd-yyyy", "dd-Mmm-yyyy", "dd-mm-yyyy");
     $structure["options"]["no_translate_fieldname"] = "yes";
     $this->obj_form->add_input($structure);
     // currency options
     $structure = NULL;
     $structure["fieldname"] = "CURRENCY_DEFAULT_NAME";
     $structure["type"] = "input";
     $structure["options"]["no_translate_fieldname"] = "yes";
     $this->obj_form->add_input($structure);
     $structure = NULL;
     $structure["fieldname"] = "CURRENCY_DEFAULT_SYMBOL";
     $structure["type"] = "input";
     $structure["options"]["no_translate_fieldname"] = "yes";
     $this->obj_form->add_input($structure);
     $structure = NULL;
     $structure["fieldname"] = "CURRENCY_DEFAULT_SYMBOL_POSITION";
     $structure["type"] = "radio";
     $structure["values"] = array("before", "after");
     $structure["options"]["no_translate_fieldname"] = "yes";
     $structure["translations"]["before"] = "Before the currency value (eg: \$20)";
     $structure["translations"]["after"] = "After the currency value (eg: 20 RSD)";
     $this->obj_form->add_input($structure);
     $structure = NULL;
     $structure["fieldname"] = "CURRENCY_DEFAULT_THOUSANDS_SEPARATOR";
     $structure["type"] = "input";
     $structure["options"]["no_translate_fieldname"] = "yes";
     $this->obj_form->add_input($structure);
     $structure = NULL;
     $structure["fieldname"] = "CURRENCY_DEFAULT_DECIMAL_SEPARATOR";
     $structure["type"] = "input";
     $structure["options"]["no_translate_fieldname"] = "yes";
     $this->obj_form->add_input($structure);
     // submit section
     $structure = NULL;
     $structure["fieldname"] = "submit";
     $structure["type"] = "submit";
     $structure["defaultvalue"] = "Save Changes";
     $this->obj_form->add_input($structure);
     // define subforms
     $this->obj_form->subforms["config_language"] = array("LANGUAGE_DEFAULT");
     $this->obj_form->subforms["config_appearance"] = array("THEME_DEFAULT", "TABLE_LIMIT");
     $this->obj_form->subforms["config_date"] = array("DATEFORMAT", "TIMEZONE_DEFAULT");
     $this->obj_form->subforms["config_currency"] = array("CURRENCY_DEFAULT_NAME", "CURRENCY_DEFAULT_SYMBOL", "CURRENCY_DEFAULT_SYMBOL_POSITION", "CURRENCY_DEFAULT_THOUSANDS_SEPARATOR", "CURRENCY_DEFAULT_DECIMAL_SEPARATOR");
     $this->obj_form->subforms["submit"] = array("submit");
     if (error_check()) {
         // load error datas
         $this->obj_form->load_data_error();
     } else {
         // fetch all the values from the database
         $sql_config_obj = new sql_query();
         $sql_config_obj->string = "SELECT name, value FROM config ORDER BY name";
         $sql_config_obj->execute();
         $sql_config_obj->fetch_array();
         foreach ($sql_config_obj->data as $data_config) {
             $this->obj_form->structure[$data_config["name"]]["defaultvalue"] = $data_config["value"];
         }
         unset($sql_config_obj);
     }
 }