function render_html()
 {
     // Title + Summary
     print "<h3>DEPENDENCIES CHECK</h3><br>";
     print "<p>This page checks each of the billing system's dependencies. If a red 'x' appears in the status column, the system cannot find that module.</p>";
     print "<table class=\"table_content\" cellspacing=\"0\" width=\"100%\">";
     print "<tr>";
     print "<td class=\"header\">";
     print "<b>" . lang_trans("dependency_status") . "</b>";
     print "</td>";
     print "<td class=\"header\">";
     print "<b>" . lang_trans("dependency_name") . "</b>";
     print "</td>";
     print "<td class=\"header\">";
     print "<b>" . lang_trans("dependency_location") . "</b>";
     print "</td>";
     print "</tr>";
     //parse through the array to generate table rows
     foreach ($this->table_array as $name => $data) {
         print "<tr>";
         print "<td>";
         if ($data["status"]) {
             print "<img alt=\"Y\" src=\"images/icons/tick_16.gif\">";
         } else {
             print "<img alt=\"N\" src=\"images/icons/cross_16.gif\">";
         }
         print "</td>";
         print "<td>";
         print "<b>" . $name . "</b>";
         print "</td>";
         print "<td>";
         print $data["location"];
         print "</td>";
         print "</tr>";
     }
     print "</table>";
 }
 function execute()
 {
     /*
     	Define form structure
     */
     $this->obj_form = new form_input();
     $this->obj_form->formname = "config_application";
     $this->obj_form->language = $_SESSION["user"]["lang"];
     $this->obj_form->action = "admin/config_application-process.php";
     $this->obj_form->method = "post";
     // default codes
     $structure = NULL;
     $structure["fieldname"] = "ACCOUNTS_AP_INVOICENUM";
     $structure["type"] = "input";
     $structure["options"]["no_translate_fieldname"] = "yes";
     $this->obj_form->add_input($structure);
     $structure = NULL;
     $structure["fieldname"] = "ACCOUNTS_AR_INVOICENUM";
     $structure["type"] = "input";
     $structure["options"]["no_translate_fieldname"] = "yes";
     $this->obj_form->add_input($structure);
     $structure = NULL;
     $structure["fieldname"] = "ACCOUNTS_GL_TRANSNUM";
     $structure["type"] = "input";
     $structure["options"]["no_translate_fieldname"] = "yes";
     $this->obj_form->add_input($structure);
     $structure = NULL;
     $structure["fieldname"] = "ACCOUNTS_QUOTES_NUM";
     $structure["type"] = "input";
     $structure["options"]["no_translate_fieldname"] = "yes";
     $this->obj_form->add_input($structure);
     $structure = NULL;
     $structure["fieldname"] = "ACCOUNTS_CREDIT_NUM";
     $structure["type"] = "input";
     $structure["options"]["no_translate_fieldname"] = "yes";
     $this->obj_form->add_input($structure);
     $structure = NULL;
     $structure["fieldname"] = "CODE_ACCOUNT";
     $structure["type"] = "input";
     $structure["options"]["no_translate_fieldname"] = "yes";
     $this->obj_form->add_input($structure);
     $structure = NULL;
     $structure["fieldname"] = "CODE_CUSTOMER";
     $structure["type"] = "input";
     $structure["options"]["no_translate_fieldname"] = "yes";
     $this->obj_form->add_input($structure);
     $structure = NULL;
     $structure["fieldname"] = "CODE_PRODUCT";
     $structure["type"] = "input";
     $structure["options"]["no_translate_fieldname"] = "yes";
     $this->obj_form->add_input($structure);
     $structure = NULL;
     $structure["fieldname"] = "CODE_PROJECT";
     $structure["type"] = "input";
     $structure["options"]["no_translate_fieldname"] = "yes";
     $this->obj_form->add_input($structure);
     $structure = NULL;
     $structure["fieldname"] = "CODE_VENDOR";
     $structure["type"] = "input";
     $structure["options"]["no_translate_fieldname"] = "yes";
     $this->obj_form->add_input($structure);
     $structure = NULL;
     $structure["fieldname"] = "CODE_STAFF";
     $structure["type"] = "input";
     $structure["options"]["no_translate_fieldname"] = "yes";
     $this->obj_form->add_input($structure);
     // invoicing options
     $structure = NULL;
     $structure["fieldname"] = "ACCOUNTS_SERVICES_ADVANCEBILLING";
     $structure["type"] = "input";
     $structure["options"]["no_translate_fieldname"] = "yes";
     $structure["options"]["width"] = "50";
     $structure["options"]["label"] = " days";
     $this->obj_form->add_input($structure);
     $structure = NULL;
     $structure["fieldname"] = "ACCOUNTS_SERVICES_DATESHIFT";
     $structure["type"] = "input";
     $structure["options"]["no_translate_fieldname"] = "yes";
     $structure["options"]["width"] = "50";
     $structure["options"]["label"] = " " . lang_trans("help_accounts_services_dateshift");
     $this->obj_form->add_input($structure);
     $structure = NULL;
     $structure["fieldname"] = "ACCOUNTS_TERMS_DAYS";
     $structure["type"] = "input";
     $structure["options"]["no_translate_fieldname"] = "yes";
     $this->obj_form->add_input($structure);
     $structure = NULL;
     $structure["fieldname"] = "ACCOUNTS_AUTOPAY";
     $structure["type"] = "checkbox";
     $structure["options"]["no_translate_fieldname"] = "yes";
     $structure["options"]["label"] = " Check to have invoices automatically paid where there is credit or reoccuring billing details.";
     $this->obj_form->add_input($structure);
     // email options
     $structure = NULL;
     $structure["fieldname"] = "ACCOUNTS_EMAIL_ADDRESS";
     $structure["type"] = "input";
     $structure["options"]["label"] = " Internal email address to send billing system related emails to.";
     $structure["options"]["no_translate_fieldname"] = "yes";
     $this->obj_form->add_input($structure);
     $structure = NULL;
     $structure["fieldname"] = "ACCOUNTS_INVOICE_AUTOEMAIL";
     $structure["type"] = "checkbox";
     $structure["options"]["label"] = "Tick to have service and order invoices automatically emailed to customers when created, from address will be COMPANY_EMAIL_ADDRESS";
     $structure["options"]["no_translate_fieldname"] = "yes";
     $this->obj_form->add_input($structure);
     $structure = NULL;
     $structure["fieldname"] = "ACCOUNTS_INVOICE_BATCHREPORT";
     $structure["type"] = "checkbox";
     $structure["options"]["label"] = "Tick to have an invoice batch report sent to ACCOUNTS_EMAIL_ADDRESS when invoices are automatically generated.";
     $structure["options"]["no_translate_fieldname"] = "yes";
     $this->obj_form->add_input($structure);
     $structure = NULL;
     $structure["fieldname"] = "ACCOUNTS_EMAIL_AUTOBCC";
     $structure["type"] = "checkbox";
     $structure["options"]["label"] = "Always BCC outgoing invoice emails to ACCOUNTS_EMAIL_ADDRESS";
     $structure["options"]["no_translate_fieldname"] = "yes";
     $this->obj_form->add_input($structure);
     // service email options
     $structure = NULL;
     $structure["fieldname"] = "SERVICES_USAGEALERTS_ENABLE";
     $structure["type"] = "checkbox";
     $structure["options"]["label"] = "Tick to have service usage alerts delivered to customers (where customers/services are enabled for it).";
     $structure["options"]["no_translate_fieldname"] = "yes";
     $this->obj_form->add_input($structure);
     // orders options
     $structure = NULL;
     $structure["fieldname"] = "ORDERS_BILL_ONSERVICE";
     $structure["type"] = "checkbox";
     $structure["options"]["label"] = "Automatically bill customer orders when the next service bill is generated.";
     $structure["options"]["no_translate_fieldname"] = "yes";
     $this->obj_form->add_input($structure);
     $structure = NULL;
     $structure["fieldname"] = "ORDERS_BILL_ENDOFMONTH";
     $structure["type"] = "checkbox";
     $structure["options"]["label"] = "Automatically bill customer orders at the end of the calender month.";
     $structure["options"]["no_translate_fieldname"] = "yes";
     $this->obj_form->add_input($structure);
     // timesheet options
     $structure = NULL;
     $structure["fieldname"] = "TIMESHEET_BOOKTOFUTURE";
     $structure["type"] = "checkbox";
     $structure["options"]["label"] = "Allow users to book time to dates in the future";
     $structure["options"]["no_translate_fieldname"] = "yes";
     $this->obj_form->add_input($structure);
     // audit locking
     $structure = NULL;
     $structure["fieldname"] = "ACCOUNTS_INVOICE_LOCK";
     $structure["type"] = "input";
     $structure["options"]["no_translate_fieldname"] = "yes";
     $this->obj_form->add_input($structure);
     $structure = NULL;
     $structure["fieldname"] = "ACCOUNTS_GL_LOCK";
     $structure["type"] = "input";
     $structure["options"]["no_translate_fieldname"] = "yes";
     $this->obj_form->add_input($structure);
     $structure = NULL;
     $structure["fieldname"] = "JOURNAL_LOCK";
     $structure["type"] = "input";
     $structure["options"]["no_translate_fieldname"] = "yes";
     $this->obj_form->add_input($structure);
     $structure = NULL;
     $structure["fieldname"] = "TIMESHEET_LOCK";
     $structure["type"] = "input";
     $structure["options"]["no_translate_fieldname"] = "yes";
     $this->obj_form->add_input($structure);
     // misc
     $structure = NULL;
     $structure["fieldname"] = "UPLOAD_MAXBYTES";
     $structure["type"] = "input";
     $structure["options"]["no_translate_fieldname"] = "yes";
     $structure["options"]["label"] = " Bytes. Server maximum is " . ini_get('upload_max_filesize') . ", to increase server limit, you must edit php.ini";
     $this->obj_form->add_input($structure);
     $structure = NULL;
     $structure["fieldname"] = "API_URL";
     $structure["type"] = "input";
     $structure["options"]["no_translate_fieldname"] = "yes";
     $structure["options"]["label"] = " This URL will be used in namespace and soap address URLS in the WSDL files.";
     $this->obj_form->add_input($structure);
     // amberstats phone home
     $structure = NULL;
     $structure["fieldname"] = "PHONE_HOME";
     $structure["type"] = "checkbox";
     $structure["options"]["label"] = "Report back to the developers with application, OS, PHP version and a random unique ID so we can better improve this software. (all information is anonymous, private and greatly appreciated. We use this information to focus development and packaging on the main platforms our users are running to better meet your needs.";
     $structure["options"]["no_translate_fieldname"] = "yes";
     $this->obj_form->add_input($structure);
     $phone_home_info = new phone_home();
     $phone_home_info->stats_generate();
     $structure = NULL;
     $structure["fieldname"] = "PHONE_HOME_EXAMPLE";
     $structure["type"] = "text";
     $structure["defaultvalue"] = "<i>Actual information to be sent: " . format_arraytocommastring(array_values($phone_home_info->stats)) . "</i>";
     $structure["options"]["no_fieldname"] = "yes";
     $structure["options"]["no_shift"] = "yes";
     $this->obj_form->add_input($structure);
     // security options
     $structure = NULL;
     $structure["fieldname"] = "SESSION_TIMEOUT";
     $structure["type"] = "input";
     $structure["options"]["label"] = " seconds idle before logging user out";
     $structure["options"]["no_translate_fieldname"] = "yes";
     $structure["defaultvalue"] = "7200";
     $this->obj_form->add_input($structure);
     $structure = NULL;
     $structure["fieldname"] = "BLACKLIST_ENABLE";
     $structure["type"] = "checkbox";
     $structure["options"]["label"] = "Enable to prevent brute-force login attempts";
     $structure["options"]["no_translate_fieldname"] = "yes";
     $this->obj_form->add_input($structure);
     $structure = NULL;
     $structure["fieldname"] = "BLACKLIST_LIMIT";
     $structure["type"] = "input";
     $structure["options"]["no_translate_fieldname"] = "yes";
     $this->obj_form->add_input($structure);
     // dangerous options
     if ($GLOBALS["config"]["dangerous_conf_options"] == "enabled") {
         $structure = NULL;
         $structure["fieldname"] = "EMAIL_ENABLE";
         $structure["type"] = "checkbox";
         $structure["options"]["label"] = "Enable or disable the ability to send emails. If you don't trust users not to try using the system to spam people (eg: if this is a demo system) then it is highly recommended to disable this option.";
         $structure["options"]["no_translate_fieldname"] = "yes";
         $this->obj_form->add_input($structure);
         $structure = NULL;
         $structure["fieldname"] = "DATA_STORAGE_METHOD";
         $structure["type"] = "radio";
         $structure["values"] = array("database", "filesystem");
         $structure["options"]["no_translate_fieldname"] = "yes";
         $this->obj_form->add_input($structure);
         $structure = NULL;
         $structure["fieldname"] = "DATA_STORAGE_LOCATION";
         $structure["type"] = "input";
         $structure["options"]["no_translate_fieldname"] = "yes";
         $this->obj_form->add_input($structure);
         $structure = NULL;
         $structure["fieldname"] = "PATH_TMPDIR";
         $structure["type"] = "input";
         $structure["options"]["no_translate_fieldname"] = "yes";
         $this->obj_form->add_input($structure);
         $structure = NULL;
         $structure["fieldname"] = "APP_PDFLATEX";
         $structure["type"] = "input";
         $structure["options"]["no_translate_fieldname"] = "yes";
         $this->obj_form->add_input($structure);
         $structure = NULL;
         $structure["fieldname"] = "APP_WKHTMLTOPDF";
         $structure["type"] = "input";
         $structure["options"]["no_translate_fieldname"] = "yes";
         $this->obj_form->add_input($structure);
         $structure = NULL;
         $structure["fieldname"] = "APP_MYSQL_DUMP";
         $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_defcodes"] = array("ACCOUNTS_AP_INVOICENUM", "ACCOUNTS_AR_INVOICENUM", "ACCOUNTS_GL_TRANSNUM", "ACCOUNTS_QUOTES_NUM", "ACCOUNTS_CREDIT_NUM", "CODE_ACCOUNT", "CODE_CUSTOMER", "CODE_VENDOR", "CODE_PRODUCT", "CODE_PROJECT", "CODE_STAFF");
     $this->obj_form->subforms["config_accounts"] = array("ACCOUNTS_SERVICES_ADVANCEBILLING", "ACCOUNTS_SERVICES_DATESHIFT", "ACCOUNTS_TERMS_DAYS", "ACCOUNTS_AUTOPAY");
     $this->obj_form->subforms["config_accounts_email"] = array("ACCOUNTS_EMAIL_ADDRESS", "ACCOUNTS_INVOICE_AUTOEMAIL", "ACCOUNTS_EMAIL_AUTOBCC", "ACCOUNTS_INVOICE_BATCHREPORT");
     $this->obj_form->subforms["config_services_email"] = array("SERVICES_USAGEALERTS_ENABLE");
     $this->obj_form->subforms["config_orders"] = array("ORDERS_BILL_ONSERVICE", "ORDERS_BILL_ENDOFMONTH");
     $this->obj_form->subforms["config_timesheet"] = array("TIMESHEET_BOOKTOFUTURE");
     $this->obj_form->subforms["config_auditlocking"] = array("ACCOUNTS_INVOICE_LOCK", "ACCOUNTS_GL_LOCK", "JOURNAL_LOCK", "TIMESHEET_LOCK");
     $this->obj_form->subforms["config_contributions"] = array("PHONE_HOME", "PHONE_HOME_EXAMPLE");
     $this->obj_form->subforms["config_security"] = array("SESSION_TIMEOUT", "BLACKLIST_ENABLE", "BLACKLIST_LIMIT");
     $this->obj_form->subforms["config_misc"] = array("UPLOAD_MAXBYTES", "API_URL");
     if ($GLOBALS["config"]["dangerous_conf_options"] == "enabled") {
         $this->obj_form->subforms["config_dangerous"] = array("PATH_TMPDIR", "APP_PDFLATEX", "APP_WKHTMLTOPDF", "APP_MYSQL_DUMP", "EMAIL_ENABLE", "DATA_STORAGE_LOCATION", "DATA_STORAGE_METHOD");
     }
     $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);
     }
 }
예제 #3
0
function get_dropdown($p_control_array, $p_control_name, $p_match = '', $p_add_any = false, $p_multiple = false)
{
    $t_control_array = $p_control_array;
    if ($p_multiple) {
        $t_size = ' size="5"';
        $t_multiple = ' multiple="multiple"';
    } else {
        $t_size = '';
        $t_multiple = '';
    }
    $t_info = sprintf("<select %s name=\"%s\" id=\"%s\"%s>", $t_multiple, $p_control_name, $p_control_name, $t_size);
    if ($p_add_any) {
        array_unshift_assoc($t_control_array, META_FILTER_ANY, lang_trans('[any]'));
    }
    while (list($t_name, $t_desc) = each($t_control_array)) {
        $t_sel = '';
        if (is_array($p_match)) {
            if (in_array($t_name, array_values($p_match)) || in_array($t_desc, array_values($p_match))) {
                $t_sel = ' selected="selected"';
            }
        } else {
            if ($t_name === $p_match || $t_desc === $p_match) {
                $t_sel = ' selected="selected"';
            }
        }
        $t_info .= sprintf("<option%s value=\"%s\">%s</option>", $t_sel, $t_name, $t_desc);
    }
    $t_info .= "</select>\n";
    return $t_info;
}
예제 #4
0
 function generate_pdf()
 {
     log_debug("invoice", "Executing generate_pdf()");
     // load data if required
     if (!is_array($this->invoice_fields)) {
         $this->load_data();
         $this->load_data_export();
     }
     // start the PDF object
     //
     // note: the & allows decontructors to operate
     //       Unfortunatly this trick is now deprecated with PHP 5.3.x and creates unsilencable errors ~JC 20100110
     //
     // get template filename based on currently selected options
     $template_data = sql_get_singlerow("SELECT `template_type`, `template_file` FROM templates WHERE template_type IN('" . $this->type . "_invoice_tex', '" . $this->type . "_invoice_htmltopdf') AND active='1' LIMIT 1");
     //exit("<pre>".print_r($template_data, true)."</pre>");
     switch ($template_data['template_type']) {
         case $this->type . '_invoice_htmltopdf':
             $this->obj_pdf = new template_engine_htmltopdf();
             $template_file = $template_data['template_file'] . "/index.html";
             if (is_dir("../../{$template_data['template_file']}")) {
                 $this->obj_pdf->set_template_directory("../../{$template_data['template_file']}");
             } else {
                 $this->obj_pdf->set_template_directory("../{$template_data['template_file']}");
             }
             break;
         case $this->type . '_invoice_tex':
         default:
             $this->obj_pdf = new template_engine_latex();
             $template_file = $template_data['template_file'] . ".tex";
             break;
     }
     if (!$template_file) {
         // fall back to old version
         //
         // TODO: we can remove this fallback code once the new templating system is fully implemented, this is to
         // just make everything work whilst stuff like quote templates are being added.
         //
         $template_file = "templates/latex/" . $this->type . "_invoice";
     }
     // load template
     if (file_exists("../../{$template_file}")) {
         $this->obj_pdf->prepare_load_template("../../{$template_file}");
     } elseif (file_exists("../{$template_file}")) {
         $this->obj_pdf->prepare_load_template("../{$template_file}");
     } else {
         // if we can't find the template file, then something is rather wrong.
         log_write("error", "invoice", "Unable to find template file {$template_file}, currently running in directory " . getcwd() . ", fatal error.");
         return 0;
     }
     /*
     	Company Data
     */
     // company logo
     $this->obj_pdf->prepare_add_file("company_logo", "png", "COMPANY_LOGO", 0);
     /*
     	Previous Activity
     
     	Some invoice PDFs include a "previous activity" statement function displaying past account activity - we only display unpaid
     	invoices.
     */
     $structure_pastactivity = array();
     $structure_pastactivity[0] = array();
     // reserved for past balance
     $amount_outstanding = sql_get_singlevalue("SELECT SUM(amount_total - amount_paid) as value FROM account_ar WHERE customerid='" . $this->data["customerid"] . "' AND id!='" . $this->id . "' AND date_trans <= '" . $this->data["date_trans"] . "'");
     $amount_outstanding_past = $amount_outstanding;
     $sql_past_obj = new sql_query();
     $sql_past_obj->string = "SELECT id, code_invoice, date_trans, amount_total, amount_paid, date_trans FROM account_ar WHERE customerid='" . $this->data["customerid"] . "' AND id!='" . $this->id . "' AND date_trans <= '" . $this->data["date_trans"] . "' ORDER BY date_trans DESC LIMIT 2";
     $sql_past_obj->execute();
     if ($sql_past_obj->num_rows()) {
         $sql_past_obj->fetch_array();
         foreach ($sql_past_obj->data as $data_row) {
             // invoice
             $itemdata = array();
             $itemdata["item_date_raw"] = time_date_to_timestamp($data_row["date_trans"]) . "." . $data_row["id"] . "00";
             // used to sort items
             $itemdata["item_date"] = time_format_humandate($data_row["date_trans"]);
             $itemdata["item_details"] = "Invoice " . $data_row["code_invoice"] . "";
             $itemdata["item_amount"] = format_money($data_row["amount_total"]);
             $structure_pastactivity[] = $itemdata;
             // payments (if any)
             if ($data_row["amount_paid"] > 0) {
                 $sql_pay_obj = new sql_query();
                 $sql_pay_obj->string = "SELECT id, amount FROM account_items WHERE invoiceid='" . $data_row["id"] . "' AND type='payment'";
                 $sql_pay_obj->execute();
                 $sql_pay_obj->fetch_array();
                 foreach ($sql_pay_obj->data as $data_pay) {
                     // update balance
                     $amount_outstanding_past = $amount_outstanding_past + $data_pay["amount"];
                     // source & date
                     $pay_date = sql_get_singlevalue("SELECT option_value as value FROM account_items_options WHERE itemid='" . $data_pay["id"] . "' AND option_name='DATE_TRANS' LIMIT 1");
                     $pay_credit = sql_get_singlevalue("SELECT option_value as value FROM account_items_options WHERE itemid='" . $data_pay["id"] . "' AND option_name='CREDIT' LIMIT 1");
                     // add payment item
                     $itemdata = array();
                     $itemdata["item_date_raw"] = time_date_to_timestamp($pay_date) . "." . $data_row["id"] . "01";
                     // used to sort items
                     $itemdata["item_date"] = time_format_humandate($pay_date);
                     if ($pay_credit) {
                         $itemdata["item_details"] = "Credit applied to invoice " . $data_row["code_invoice"] . "";
                     } else {
                         $itemdata["item_details"] = "Payment against invoice " . $data_row["code_invoice"] . "";
                     }
                     $itemdata["item_amount"] = "-" . format_money($data_pay["amount"]);
                     $structure_pastactivity[] = $itemdata;
                 }
                 unset($sql_pay_obj);
             }
             $amount_outstanding_past = $amount_outstanding_past - $data_row["amount_total"];
         }
         // sort by date, to correct payment & invoice ordering
         if (!function_exists("cmp_date")) {
             function cmp_date($a, $b)
             {
                 if ($a["item_date_raw"] == $b["item_date_raw"]) {
                     return 0;
                 }
                 return $a["item_date_raw"] < $b["item_date_raw"] ? -1 : 1;
             }
         }
         usort($structure_pastactivity, "cmp_date");
         // add previous balance item
         $structure_pastactivity[0]["item_date"] = "Previous Balance";
         $structure_pastactivity[0]["item_details"] = "";
         $structure_pastactivity[0]["item_amount"] = format_money($amount_outstanding_past);
     } else {
         $itemdata = array();
         $itemdata["item_date"] = time_format_humandate(date("Y-m-d"));
         $itemdata["item_details"] = "No Past Activity";
         $itemdata["item_amount"] = "";
         $structure_pastactivity[0] = $itemdata;
         $amount_outstanding = "0.00";
     }
     $this->obj_pdf->prepare_add_array("previous_items", $structure_pastactivity);
     $this->obj_pdf->prepare_add_field("amount_outstanding", format_money($amount_outstanding));
     unset($structure_pastactivity);
     unset($sql_past_obj);
     /*
     	Add general invoice details from load_data_export	
     */
     $this->invoice_fields["amount_total"] = format_money($this->data["amount_total"] - $this->data["amount_paid"]);
     $this->invoice_fields["amount_total_final"] = format_money($this->data["amount_total"] - $this->data["amount_paid"] + $amount_outstanding);
     foreach ($this->invoice_fields as $invoice_field_key => $invoice_field_value) {
         $this->obj_pdf->prepare_add_field($invoice_field_key, $invoice_field_value);
     }
     /*
     	Invoice Items
     	(excluding tax items - these need to be processed in a different way)
     */
     // fetch invoice items
     $sql_items_obj = new sql_query();
     $sql_items_obj->string = "SELECT " . "id, type, chartid, customid, quantity, units, amount, price, description " . "FROM account_items " . "WHERE invoiceid='" . $this->id . "' " . "AND invoicetype='" . $this->type . "' " . "AND type!='tax' " . "AND type!='payment' " . "ORDER BY type, customid, chartid, description";
     $sql_items_obj->execute();
     $sql_items_obj->fetch_array();
     $structure_invoiceitems = array();
     $structure_group_summary = array();
     foreach ($sql_items_obj->data as $itemdata) {
         $structure = array();
         $structure["quantity"] = $itemdata["quantity"];
         switch ($itemdata["type"]) {
             case "product":
                 /*
                 	Fetch product code
                 */
                 $sql_obj = new sql_query();
                 $sql_obj->string = "SELECT code_product FROM products WHERE id='" . $itemdata["customid"] . "' LIMIT 1";
                 $sql_obj->execute();
                 $sql_obj->fetch_array();
                 $structure["info"] = $sql_obj->data[0]["code_product"];
                 unset($sql_obj);
                 /*
                 	Fetch discount (if any)
                 */
                 $itemdata["discount"] = sql_get_singlevalue("SELECT option_value as value FROM account_items_options WHERE itemid='" . $itemdata["id"] . "' AND option_name='DISCOUNT'");
                 /*
                 	Calculate Amount
                 
                 	(Amount field already has discount removed, but we can't use this for export, since we want the line item to be the full
                 	 amount, with an additional line item for the discount)
                 */
                 $itemdata["amount"] = $itemdata["price"] * $itemdata["quantity"];
                 $sql_obj = new sql_query();
                 $sql_obj->string = "SELECT product_groups.group_name " . " FROM products " . " LEFT JOIN product_groups " . " ON product_groups.id = products.id_product_group " . " WHERE products.id = '" . $itemdata["customid"] . "' " . " LIMIT 1";
                 $sql_obj->execute();
                 $sql_obj->fetch_array();
                 if ($sql_obj->data[0]["group_name"] != null) {
                     $structure["group"] = $sql_obj->data[0]["group_name"];
                 } else {
                     $structure["group"] = lang_trans("group_products");
                 }
                 break;
             case "time":
                 /*
                 	Fetch time group ID
                 */
                 $groupid = sql_get_singlevalue("SELECT option_value as value FROM account_items_options WHERE itemid='" . $itemdata["id"] . "' AND option_name='TIMEGROUPID'");
                 $structure["info"] = sql_get_singlevalue("SELECT CONCAT_WS(' -- ', projects.code_project, time_groups.name_group) as value FROM time_groups LEFT JOIN projects ON projects.id = time_groups.projectid WHERE time_groups.id='{$groupid}' LIMIT 1");
                 /*
                 	Fetch discount (if any)
                 */
                 $itemdata["discount"] = sql_get_singlevalue("SELECT option_value as value FROM account_items_options WHERE itemid='" . $itemdata["id"] . "' AND option_name='DISCOUNT'");
                 /*
                 	Calculate Amount
                 
                 	(Amount field already has discount removed, but we can't use this for export, since we want the line item to be the full
                 	 amount, with an additional line item for the discount)
                 */
                 $itemdata["amount"] = $itemdata["price"] * $itemdata["quantity"];
                 $structure["group"] = lang_trans("group_time");
                 break;
             case "service":
             case "service_usage":
                 /*
                 	Fetch Service Name
                 */
                 $sql_obj = new sql_query();
                 $sql_obj->string = "SELECT name_service FROM services WHERE id='" . $itemdata["customid"] . "' LIMIT 1";
                 $sql_obj->execute();
                 $sql_obj->fetch_array();
                 $structure["info"] = $sql_obj->data[0]["name_service"];
                 unset($sql_obj);
                 /*
                 	Fetch discount (if any)
                 */
                 $itemdata["discount"] = sql_get_singlevalue("SELECT option_value as value FROM account_items_options WHERE itemid='" . $itemdata["id"] . "' AND option_name='DISCOUNT'");
                 /*
                 	Calculate Amount
                 
                 	(Amount field already has discount removed, but we can't use this for export, since we want the line item to be the full
                 	 amount, with an additional line item for the discount)
                 */
                 $itemdata["amount"] = $itemdata["price"] * $itemdata["quantity"];
                 /*
                 	Fetch CDR group if any
                 */
                 $itemdata["CDR_BILLGROUP"] = sql_get_singlevalue("SELECT option_value as value FROM account_items_options WHERE itemid='" . $itemdata["id"] . "' AND option_name='CDR_BILLGROUP'");
                 /*
                 	Set the service group
                 
                 	This is used for layout and titling purposes on the invoice - there are several options, we need to fetch the service group depending
                 	on whether the service item is a plan or usage item and specific service types might have other group conditions, eg CDR_BILLGROUP.
                 */
                 $sql_obj = new sql_query();
                 if ($itemdata["type"] == "service_usage") {
                     if ($itemdata["CDR_BILLGROUP"]) {
                         $sql_obj->string = "SELECT CONCAT_WS(' ', billgroup_name, 'Call Charges') as group_name FROM cdr_rate_billgroups WHERE id='" . $itemdata["CDR_BILLGROUP"] . "' LIMIT 1";
                     } else {
                         $sql_obj->string = "SELECT service_groups.group_name FROM services LEFT JOIN service_groups ON service_groups.id = services.id_service_group_usage WHERE services.id = '" . $itemdata["customid"] . "' LIMIT 1";
                     }
                 } else {
                     $sql_obj->string = "SELECT service_groups.group_name FROM services LEFT JOIN service_groups ON service_groups.id = services.id_service_group WHERE services.id = '" . $itemdata["customid"] . "' LIMIT 1";
                 }
                 $sql_obj->execute();
                 $sql_obj->fetch_array();
                 $structure["group"] = $sql_obj->data[0]["group_name"];
                 unset($sql_obj);
                 break;
             case "standard":
                 /*
                 	Fetch account name and blank a few fields
                 */
                 $sql_obj = new sql_query();
                 $sql_obj->string = "SELECT CONCAT_WS(' -- ',code_chart,description) as name_account FROM account_charts WHERE id='" . $itemdata["chartid"] . "' LIMIT 1";
                 $sql_obj->execute();
                 $sql_obj->fetch_array();
                 $structure["info"] = $sql_obj->data[0]["name_account"];
                 $structure["quantity"] = " ";
                 $itemdata["price"] = NULL;
                 $structure["group"] = lang_trans("group_other");
                 $structure["group_num"] = "1";
                 unset($sql_obj);
                 break;
         }
         // define group summary values
         if (!isset($structure_group_summary[$structure["group"]])) {
             $structure_group_summary[$structure["group"]] = 0;
         }
         $structure_group_summary[$structure["group"]] += $itemdata["amount"];
         // finalise item
         $structure["description"] = trim($itemdata["description"]);
         $structure["units"] = $itemdata["units"];
         if ($itemdata["price"]) {
             $structure["price"] = format_money($itemdata["price"]);
         } else {
             $structure["price"] = "";
         }
         $structure["amount"] = format_money($itemdata["amount"]);
         $structure_invoiceitems[] = $structure;
         // if a discount exists, then we add an additional item row for the discount
         if (!empty($itemdata["discount"])) {
             $structure["description"] = "Discount of " . $itemdata["discount"] . "%";
             $structure["quantity"] = "";
             $structure["units"] = "";
             $structure["price"] = "";
             // work out the discount amount to remove
             $discount_calc = $itemdata["discount"] / 100;
             $discount_calc = $itemdata["amount"] * $discount_calc;
             $structure["amount"] = "-" . format_money($discount_calc);
             // track for summary report
             if (!isset($structure_group_summary["group_discount"])) {
                 $structure_group_summary["group_discount"] = $discount_calc;
             } else {
                 $structure_group_summary["group_discount"] += $discount_calc;
             }
             // add extra line item
             $structure_invoiceitems[] = $structure;
         }
     }
     foreach ($structure_invoiceitems as $invoice_item) {
         $invoice_items_by_group[$invoice_item['group']][] = $invoice_item;
     }
     ksort($invoice_items_by_group);
     if (count($invoice_items_by_group) > 1) {
         $structure_invoiceitems = array();
         foreach ($invoice_items_by_group as $invoice_item_set) {
             $structure_invoiceitems = array_merge($structure_invoiceitems, $invoice_item_set);
         }
     }
     //exit("<pre>".print_r($structure_invoiceitems,true)."</pre>");
     $this->obj_pdf->prepare_add_array("invoice_items", $structure_invoiceitems);
     unset($sql_items_obj);
     /*
     	Tax Items
     */
     // fetch tax items
     $sql_tax_obj = new sql_query();
     $sql_tax_obj->string = "SELECT " . "account_items.amount, " . "account_taxes.name_tax, " . "account_taxes.taxnumber " . "FROM " . "account_items " . "LEFT JOIN account_taxes ON account_taxes.id = account_items.customid " . "WHERE " . "invoiceid='" . $this->id . "' " . "AND invoicetype='" . $this->type . "' " . "AND type='tax'";
     $sql_tax_obj->execute();
     if ($sql_tax_obj->num_rows()) {
         $sql_tax_obj->fetch_array();
         $structure_taxitems = array();
         foreach ($sql_tax_obj->data as $taxdata) {
             $structure = array();
             $structure["name_tax"] = $taxdata["name_tax"];
             $structure["taxnumber"] = $taxdata["taxnumber"];
             $structure["amount"] = format_money($taxdata["amount"]);
             $structure_taxitems[] = $structure;
         }
     }
     $this->obj_pdf->prepare_add_array("taxes", $structure_taxitems);
     /*
     	Payment Items
     */
     // fetch payment items
     $sql_payment_obj = new sql_query();
     $sql_payment_obj->string = "SELECT id, amount, description FROM account_items WHERE invoiceid='" . $this->id . "' AND invoicetype='" . $this->type . "' AND type='payment'";
     $sql_payment_obj->execute();
     $structure_payments = array();
     if ($sql_payment_obj->num_rows()) {
         $sql_payment_obj->fetch_array();
         foreach ($sql_payment_obj->data as $itemdata) {
             $structure = array();
             if (sql_get_singlevalue("SELECT option_value as value FROM account_items_options WHERE itemid='" . $itemdata["id"] . "' AND option_name='CREDIT' LIMIT 1")) {
                 $structure["label"] = "Credit Applied";
             } else {
                 $structure["label"] = "Payment";
             }
             $structure["amount"] = format_money($itemdata["amount"]);
             $structure["date"] = time_format_humandate(sql_get_singlevalue("SELECT option_value as value FROM account_items_options WHERE option_name='DATE_TRANS' AND itemid='" . $itemdata["id"] . "' LIMIT 1"));
             $structure_payments[] = $structure;
         }
     }
     $this->obj_pdf->prepare_add_array("invoice_payments", $structure_payments);
     /*
     	Group Summaries
     
     	Some invoice templates have a summary header page with totals for each group type. Users can
     	then read through for full item listings and details.
     */
     $stucture_group_summary_final = array();
     // add all non-discount groups
     foreach (array_keys($structure_group_summary) as $group_name) {
         if ($group_name != 'group_discount') {
             $structure = array();
             $structure["group_name"] = $group_name;
             $structure["group_amount"] = format_money($structure_group_summary[$group_name]);
             $structure_group_summary_final[] = $structure;
         }
     }
     // add discount group last
     if (isset($structure_group_summary["group_discount"]) && $structure_group_summary["group_discount"] > 0) {
         $structure = array();
         $structure["group_name"] = lang_trans('group_discount');
         $structure["group_amount"] = "-" . format_money($structure_group_summary['group_discount']);
         $structure_group_summary_final[] = $structure;
     }
     $this->obj_pdf->prepare_add_array("summary_items", $structure_group_summary_final);
     // depending on the billing options we may adjust template display, ensure default is set first
     $this->obj_pdf->prepare_add_field('billing_default', 1);
     $billing_option = sql_get_singlevalue("SELECT billing_method AS value FROM customers WHERE id='" . $this->data["customerid"] . "'");
     log_write("debug", "inc_invoice", "Billing option for customer is: " . $billing_option);
     switch ($billing_option) {
         case 'direct debit':
             $this->obj_pdf->prepare_add_field('billing_direct_debit', 1);
             $this->obj_pdf->prepare_add_field('billing_default', '');
             break;
         case 'manual':
         default:
             $this->obj_pdf->prepare_add_field('billing_default', 1);
             break;
     }
     /*
     	Output PDF
     */
     // perform string escaping for latex
     $this->obj_pdf->prepare_escape_fields();
     // fillter template data
     $this->obj_pdf->fillter_template_data();
     // fill template
     $this->obj_pdf->prepare_filltemplate();
     /*
     	Debugging Functions
     
     	Debugging invoice generation can be tricky, especially when making large number of
     	development changes. These functions need to be uncommented in code, future releases
     	should make them a checkable option.
     */
     // display invoice in browser, suitable for HTML-based invoices only
     //foreach ($this->obj_pdf->processed as $line)
     //{
     //	$line = str_replace('(tmp_filename)', "../../". $template_data['template_file'] ."/", $line);
     //	print $line;
     //}
     // output raw HTML
     //print "<pre>";
     //print_r($this->obj_pdf->processed);
     //print "</pre>";
     //die("Terminated Generation");
     // generate PDF output
     $this->obj_pdf->generate_pdf();
 }
예제 #5
0
 function render_html()
 {
     /*
     	All other records
     */
     print "<tr class=\"table_highlight_info\">";
     print "<td width=\"10%\"><b>" . lang_trans("record_type") . "</b></td>";
     if (strpos($this->obj_domain->data["domain_name"], "arpa")) {
         print "<td width=\"15%\"><b>" . lang_trans("record_ttl") . "</b></td>";
     } else {
         print "<td width=\"10%\"><b>" . lang_trans("record_ttl") . "</b></td>";
     }
     print "<td width=\"35%\"><b>" . lang_trans("record_name") . "</b></td>";
     print "<td width=\"35%\"><b>" . lang_trans("record_content") . "</b></td>";
     if (!strpos($this->obj_domain->data["domain_name"], "arpa")) {
         print "<td width=\"5%\"><b>" . lang_trans("reverse_ptr") . "</b></td>";
     }
     print "<td width=\"5%\">&nbsp;</td>";
     print "</tr>";
     // display all the rows
     for ($i = 0; $i < $this->num_records_custom; $i++) {
         if (isset($_SESSION["error"]["record_custom_" . $i . "-error"])) {
             print "<tr class=\"form_error\">";
         } else {
             print "<tr class=\"table_highlight\">";
         }
         print "<td width=\"10%\" valign=\"top\">";
         $this->obj_form->render_field("record_custom_" . $i . "_type");
         $this->obj_form->render_field("record_custom_" . $i . "_id");
         print "</td>";
         if (strpos($this->obj_domain->data["domain_name"], "arpa")) {
             print "<td width=\"15%\" valign=\"top\">";
         } else {
             print "<td width=\"15%\" valign=\"top\">";
         }
         $this->obj_form->render_field("record_custom_" . $i . "_ttl");
         print "</td>";
         print "<td width=\"35%\" valign=\"top\">";
         $this->obj_form->render_field("record_custom_" . $i . "_name");
         print "</td>";
         print "<td width=\"35%\" valign=\"top\">";
         $this->obj_form->render_field("record_custom_" . $i . "_content");
         print "</td>";
         if (!strpos($this->obj_domain->data["domain_name"], "arpa")) {
             print "<td width=\"5%\" valign=\"top\" align=\"center\">";
             $this->obj_form->render_field("record_custom_" . $i . "_reverse_ptr");
             $this->obj_form->render_field("record_custom_" . $i . "_reverse_ptr_orig");
             print "</td>";
         }
         print "<td width=\"5%\" valign=\"top\" align=\"center\">";
         $this->obj_form->render_field("record_custom_" . $i . "_delete_undo");
         print "<strong class=\"delete_undo\"><a href=\"\">delete</a></strong>";
         print "</td>";
         print "</tr>";
     }
     // spacer
     print "<tr><td colspan=\"100%\"><p>" . $this->get_pagination_row() . "<span style=\"float:right;\" id=\"domain_records_custom_loading\" style=\"display:hidden;\"><img src=\"images/wait20.gif\" /></span></p></td></tr>";
     // hidden fields
     $this->obj_form->render_field("record_custom_id_domain");
     //$this->obj_form->render_field("num_records_ns");
     //$this->obj_form->render_field("num_records_mx");
     $this->obj_form->render_field("num_records_custom");
     $this->obj_form->render_field("record_custom_page");
     $this->obj_form->render_field("record_custom_status");
     // end table + form
     ///print "</table>";
     ///print "</form>";
 }
 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"];
             }
         }
     }
 }
예제 #7
0
 function render_menu_breadcrumbs()
 {
     log_write("debug", "menu_main", "Executing render_breadcrumbs()");
     // only display if the user is not viewing the top of the site
     if (count($this->menu_order) == 1) {
         return 0;
     }
     /*
     	We now run through the menu order and also fetch the title
     	for the current page, and add all the page titles to an array.
     
     	By doing this, we eliminate any duplicated page titles and can
     	do a breadcrumb trail with no dupes.
     */
     $breadcrumbs = array();
     // menu steps
     for ($i = 1; $i <= count($this->menu_order); $i++) {
         foreach ($this->menu_structure as $data) {
             if ($data["topic"] == $this->menu_order[$i]) {
                 if ($data["topic"]) {
                     if (!in_array($data["topic"], $breadcrumbs)) {
                         // add the page to the breadcrumbs
                         $breadcrumbs[] = $data["topic"];
                     }
                 }
             }
         }
     }
     // current page
     foreach ($this->menu_structure as $data) {
         if ($data["link"] == $this->page) {
             if ($data["topic"]) {
                 if (!in_array($data["topic"], $breadcrumbs)) {
                     // add the page to the breadcrumbs
                     $breadcrumbs[] = $data["topic"];
                 }
             }
         }
     }
     /*
     	Output the provided bread crumbs
     */
     print "<p style=\"margin: 0px; padding: 4px;\"><b>";
     print "<a href=\"index.php\">Amberdms</a> &gt; ";
     for ($i = 0; $i < count($breadcrumbs); $i++) {
         foreach ($this->menu_structure as $data) {
             if ($data["topic"] == $breadcrumbs[$i]) {
                 print "<a href=\"index.php?page=" . $data["link"] . "\" title=" . lang_trans($data["topic"]) . ">" . lang_trans($data["topic"]) . "</a>";
                 if ($i < count($breadcrumbs) - 1) {
                     print " &gt; ";
                 }
             }
         }
     }
     print "</b></p>";
     return 1;
 }
예제 #8
0
function security_script_input($expression, $value, $mode = 0)
{
    // if the input matches the regex, all is good, otherwise set to "error".
    if (preg_match($expression, $value)) {
        $value = addslashes($value);
        return $value;
    } else {
        // failure to validate
        if ($mode) {
            $valuename = vname($valuename);
            $_SESSION["error"]["message"][] = "Invalid " . lang_trans($valuename) . " supplied, please correct.";
            $_SESSION["error"][$valuename] = 0;
            return $value;
        } else {
            return "error";
        }
    }
}
예제 #9
0
 function render_html()
 {
     // display header
     print "<h3>CUSTOMER ATTRIBUTES</h3><br>";
     print "<p>Use this page to define attributes such as install dates, model numbers, serial numbers or other values of interest in an easy to search form. For more detailed text or file uploads, use the journal instead.</p>";
     if ($this->no_attributes == "true") {
         format_msgbox("info", "<p>You do not have any attributes currently assigned to this customer, use the fields below to begin entering some.</p>");
         print "<br>";
     }
     //add new group field/ button
     if (user_permissions_get("customers_write")) {
         print "<p id=\"show_add_group\"><strong><a href=\"\" class=\"button_small\">Create New Group...</a></strong></p>";
         print "<p class=\"add_group\"><strong>Create New Group:</strong></p>";
         print "<p class=\"add_group\">Name: <input type=\"text\" name=\"add_group\" /> &nbsp; <a href=\"\" class=\"button_small\" id=\"add_group\">Add</a> &nbsp; <a href=\"\" class=\"button_small\" id=\"close_add_group\">Cancel</a></p>";
     }
     // start form/table structure
     print "<form method=\"" . $this->obj_form->method . "\" action=\"" . $this->obj_form->action . "\" class=\"form_standard\">";
     print "<table id=\"attributes_table\" class=\"form_table\" width=\"100%\">";
     // display all the rows
     foreach ($this->group_arrays as $group_id => $attributes) {
         //header
         if (count($this->group_arrays) == 1) {
             print "<tr class=\"header hide_attributes\" id=\"group_row_" . $group_id . "\">";
         } else {
             print "<tr class=\"header show_attributes\" id=\"group_row_" . $group_id . "\">";
         }
         print "<td colspan=\"3\">";
         print "<div class=\"group_name\" id=\"group_name_" . $group_id . "\"><b>" . $attributes["name"] . "</b>";
         print "</div>";
         if (user_permissions_get("customers_write")) {
             print "<div class=\"group_links\">&nbsp;";
             print "<a href\"\" id=\"delete_group_" . $group_id . "\" class=\"delete_group button_small\">delete</a>";
             print "&nbsp;&nbsp;";
             print "<a href=\"\" class=\"show_change_group_name button_small\" id=\"show_change_group_name_" . $group_id . "\">change name</a>";
             print "&nbsp;</div>";
         }
         print "<div class=\"change_group_name\" id=\"change_group_name_" . $group_id . "\"><input type=\"text\" value=\"" . $attributes["name"] . "\" name=\"change_group_name_" . $group_id . "\" /> &nbsp; <a href=\"\" class=\"button_small change_group_name_button\" id=\"change_group_name_button_" . $group_id . "\">Change</a> &nbsp; <a href=\"\" class=\"button_small close_change_group_name\" id=\"close_change_group_name_" . $group_id . "\">Cancel</a></div>";
         $this->obj_form->render_field("group_" . $group_id . "_new_attributes");
         print "<input type=\"hidden\" name=\"group_delete_status_" . $group_id . "\" value=\"false\" />";
         print "</td>";
         if (count($this->group_arrays) == 1) {
             print "<td class=\"expand_collapse\"><b>^</b></td>";
         } else {
             print "<td class=\"expand_collapse\"><b>v</b></td>";
         }
         print "</tr>";
         //subheader
         if (count($this->group_arrays) == 1) {
             print "<tr class=\"header group_row_" . $group_id . "\">";
         } else {
             print "<tr class=\"header hidden_attribute_row group_row_" . $group_id . "\">";
         }
         print "<td><b>" . lang_trans("attribute_key") . "</b></td>";
         print "<td><b>" . lang_trans("attribute_value") . "</b></td>";
         print "<td><br/></td>";
         print "<td><br/></td>";
         print "</tr>";
         if (count($this->group_arrays) == 1) {
             print "<tr class=\"group_row_" . $group_id . "\">";
         } else {
             print "<tr class=\"hidden_attribute_row group_row_" . $group_id . "\">";
         }
         print "<td colspan=\"4\"></td>";
         print "</tr>";
         //display each attribute in the group
         foreach ($attributes as $key => $id) {
             if ((string) $key != "name") {
                 if (isset($_SESSION["error"]["attribute_" . $id . "_value-error"]) || isset($_SESSION["error"]["attribute_" . $id . "_key-error"])) {
                     print "<tr class=\"table_highlight form_error group_row_" . $group_id . "\" >";
                 } else {
                     if (count($this->group_arrays) == 1) {
                         print "<tr class=\"table_highlight group_row_" . $group_id . "\">";
                     } else {
                         print "<tr class=\"hidden_attribute_row table_highlight group_row_" . $group_id . "\">";
                     }
                 }
                 print "<td width=\"30%\" valign=\"top\">";
                 $this->obj_form->render_field("attribute_" . $id . "_key");
                 $this->obj_form->render_field("attribute_" . $id . "_id");
                 print "</td>";
                 print "<td width=\"50%\" valign=\"top\">";
                 $this->obj_form->render_field("attribute_" . $id . "_value");
                 print "</td>";
                 print "<td width=\"15%\" valign=\"top\">";
                 $this->obj_form->render_field("attribute_" . $id . "_group");
                 if (user_permissions_get("customers_write")) {
                     print "<strong><a href=\"\" ";
                     if (count($this->group_arrays) == 1) {
                         print "class=\"hidden_move\" ";
                     }
                     print "id=\"move_row_" . $id . "\">move...</a></strong>";
                 }
                 print "</td>";
                 print "<td width=\"5%\" valign=\"top\">";
                 if (user_permissions_get("customers_write")) {
                     if ($this->obj_form->structure["attribute_" . $id . "_delete_undo"]["defaultvalue"] != "disabled") {
                         $this->obj_form->render_field("attribute_" . $id . "_delete_undo");
                         print "<strong class=\"delete_undo\"><a href=\"\">delete</a></strong>";
                     }
                 }
                 print "</td>";
                 print "</tr>";
             }
         }
         print "<tr>";
         print "<td colspan=\"4\"></td>";
         print "</tr>";
     }
     print "<tr>";
     print "<td colspan=\"4\"></td>";
     print "</tr>";
     if (user_permissions_get("customers_write")) {
         // form submit
         print "<tr class=\"header\">";
         print "<td colspan=\"4\"><b>" . lang_trans("submit") . "</b></td>";
         print "</tr>";
         $this->obj_form->render_row("submit");
     }
     // end table + form
     print "</table>";
     // hidden fields
     $this->obj_form->render_field("id_customer");
     $this->obj_form->render_field("highest_attr_id");
     $this->obj_form->render_field("new_groups");
     $this->obj_form->render_field("group_list");
     for ($i = 0; $i < count($this->new_groups_array); $i++) {
         if (!empty($this->new_groups_array[$i])) {
             $this->obj_form->render_field("group_" . $this->new_groups_array[$i] . "_attribute_list");
         }
     }
     print "</form>";
     if (!user_permissions_get("customers_write")) {
         format_msgbox("locked", "<p>Sorry, you do not have permission to edit this customer</p>");
     }
     // manually call form javascript functions
     $this->obj_form->render_javascript();
 }
예제 #10
0
 function execute()
 {
     /*
     	Define form structure
     */
     $this->obj_form = new form_input();
     $this->obj_form->formname = "domain_add";
     $this->obj_form->language = $_SESSION["user"]["lang"];
     $this->obj_form->action = "domains/edit-process.php";
     $this->obj_form->method = "post";
     // general
     $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/24";
     $structure["options"]["label"] = " include /cidr for ranges greater than /24";
     $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_forward";
     $structure["type"] = "checkbox";
     $structure["options"]["label"] = lang_trans("help_ipv4_autofill_forward");
     $structure["options"]["req"] = "yes";
     $this->obj_form->add_input($structure);
     $structure = NULL;
     $structure["fieldname"] = "ipv4_autofill_reverse_from_forward";
     $structure["type"] = "checkbox";
     $structure["options"]["label"] = lang_trans("help_ipv4_autofill_reverse_from_forward");
     $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_autofill", "hide");
     $this->obj_form->add_action("domain_type", "default", "ipv4_autofill_domain", "hide");
     $this->obj_form->add_action("domain_type", "default", "ipv4_autofill_forward", "hide");
     $this->obj_form->add_action("domain_type", "default", "ipv4_autofill_reverse_from_forward", "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", "ipv6_autofill", "hide");
     //		$this->obj_form->add_action("domain_type", "default", "ipv6_autofill_domain", "hide");
     //		$this->obj_form->add_action("domain_type", "default", "ipv6_autofill_forward", "hide");
     $this->obj_form->add_action("domain_type", "default", "ipv6_autofill_reverse_from_forward", "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_autofill", "show");
     $this->obj_form->add_action("domain_type", "domain_reverse_ipv6", "domain_name", "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_autofill", "show");
     $this->obj_form->add_action("domain_type", "domain_reverse_ipv6", "ipv6_autofill_reverse_from_forward", "show");
     $this->obj_form->add_action("ipv4_autofill", "default", "ipv4_autofill_domain", "hide");
     $this->obj_form->add_action("ipv4_autofill", "default", "ipv4_autofill_forward", "hide");
     $this->obj_form->add_action("ipv4_autofill", "default", "ipv4_autofill_reverse_from_forward", "hide");
     $this->obj_form->add_action("ipv4_autofill", "1", "ipv4_autofill_domain", "show");
     $this->obj_form->add_action("ipv4_autofill", "1", "ipv4_autofill_forward", "show");
     $this->obj_form->add_action("ipv4_autofill", "1", "ipv4_autofill_reverse_from_forward", "show");
     /*
     		$this->obj_form->add_action("ipv6_autofill", "default", "ipv6_autofill_domain", "hide");
     		$this->obj_form->add_action("ipv6_autofill", "default", "ipv6_autofill_forward", "hide");
     		$this->obj_form->add_action("ipv6_autofill", "default", "ipv6_autofill_reverse_from_forward", "hide");
     		$this->obj_form->add_action("ipv6_autofill", "1", "ipv6_autofill_domain", "show");
     		$this->obj_form->add_action("ipv6_autofill", "1", "ipv6_autofill_forward", "show");
     		$this->obj_form->add_action("ipv6_autofill", "1", "ipv6_autofill_reverse_from_forward", "show");
     */
     $structure = NULL;
     $structure["fieldname"] = "domain_description";
     $structure["type"] = "textarea";
     $this->obj_form->add_input($structure);
     // domain groups
     $sql_name_server_group_obj = new sql_query();
     $sql_name_server_group_obj->string = "SELECT id, group_name, group_description FROM name_servers_groups ORDER BY group_name";
     $sql_name_server_group_obj->execute();
     if ($sql_name_server_group_obj->num_rows()) {
         // user note
         $structure = NULL;
         $structure["fieldname"] = "domain_message";
         $structure["type"] = "message";
         $structure["defaultvalue"] = "<p>" . lang_trans("help_domain_group_selection") . "</p>";
         $this->obj_form->add_input($structure);
         $this->domain_array[] = "domain_message";
         // run through all the domains
         $sql_name_server_group_obj->fetch_array();
         foreach ($sql_name_server_group_obj->data as $data_group) {
             // define domain checkbox
             $structure = NULL;
             $structure["fieldname"] = "name_server_group_" . $data_group["id"];
             $structure["type"] = "checkbox";
             $structure["options"]["label"] = $data_group["group_name"] . " -- " . $data_group["group_description"];
             $structure["options"]["no_fieldname"] = "enable";
             // by default, mark all groups selected - failure to select, will equal success
             $structure["defaultvalue"] = "on";
             // add to form
             $this->obj_form->add_input($structure);
             $this->domain_array[] = "name_server_group_" . $data_group["id"];
         }
     }
     // 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_OTHER"];
     $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["domain_details"]	= array("domain_type", "domain_name", "ipv4_help", "ipv4_network", "ipv4_autofill", "ipv4_autofill_forward", "ipv4_autofill_reverse_from_forward", "ipv4_autofill_domain", "ipv6_help", "ipv6_network", "ipv6_autofill", "ipv6_autofill_forward", "ipv6_autofill_reverse_from_forward", "ipv6_autofill_domain", "domain_description");
     $this->obj_form->subforms["domain_details"] = array("domain_type", "domain_name", "ipv4_help", "ipv4_network", "ipv4_autofill", "ipv4_autofill_forward", "ipv4_autofill_reverse_from_forward", "ipv4_autofill_domain", "ipv6_help", "ipv6_network", "domain_description");
     $this->obj_form->subforms["domain_groups"] = $this->domain_array;
     $this->obj_form->subforms["domain_soa"] = array("soa_hostmaster", "soa_serial", "soa_refresh", "soa_retry", "soa_expire", "soa_default_ttl");
     $this->obj_form->subforms["submit"] = array("submit");
     // import data
     if (error_check()) {
         $this->obj_form->load_data_error();
     }
 }
예제 #11
0
 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);
     }
 }
예제 #12
0
 function render_html()
 {
     // heading
     print "<h3>VENDORS/SUPPLIERS LIST</h3><br><br>";
     // display options form
     $this->obj_table->render_options_form();
     // display data
     if (!count($this->obj_table->columns)) {
         format_msbbox("important", "<p>Please select some valid options to display.</p>");
     } elseif (!$this->obj_table->data_num_rows) {
         format_msgbox("info", "<p>You currently have no vendors in your database.</p>");
     } else {
         // calculate all the totals and prepare processed values
         $this->obj_table->render_table_prepare();
         // display header row
         print "<table class=\"table_content\" cellspacing=\"0\" width=\"100%\">";
         print "<tr>";
         foreach ($this->obj_table->columns as $column) {
             print "<td class=\"header\"><b>" . $this->obj_table->render_columns[$column] . "</b></td>";
         }
         //placeholder for links
         print "<td class=\"header\">&nbsp;</td>";
         print "</tr>";
         // display data
         for ($i = 0; $i < $this->obj_table->data_num_rows; $i++) {
             $vendor_id = $this->obj_table->data[$i]["id"];
             $contact_id = sql_get_singlevalue("SELECT id AS value FROM vendor_contacts WHERE vendor_id = '" . $vendor_id . "' AND role = 'accounts' LIMIT 1");
             print "<tr>";
             foreach ($this->obj_table->columns as $columns) {
                 print "<td valign=\"top\">";
                 //contact name
                 if ($columns == "name_contact") {
                     $value = sql_get_singlevalue("SELECT contact AS value FROM vendor_contacts WHERE id = '" . $contact_id . "' LIMIT 1");
                     if ($value) {
                         print $value;
                     }
                 } else {
                     if ($columns == "contact_phone") {
                         $value = sql_get_singlevalue("SELECT detail AS value FROM vendor_contact_records WHERE contact_id = '" . $contact_id . "' AND type = 'phone' LIMIT 1");
                         if ($value) {
                             print $value;
                         }
                     } else {
                         if ($columns == "contact_mobile") {
                             $value = sql_get_singlevalue("SELECT detail AS value FROM vendor_contact_records WHERE contact_id = '" . $contact_id . "' AND type= 'mobile' LIMIT 1");
                             if ($value) {
                                 print $value;
                             }
                         } else {
                             if ($columns == "contact_email") {
                                 $value = sql_get_singlevalue("SELECT detail AS value FROM vendor_contact_records WHERE contact_id = '" . $contact_id . "' AND type= 'email' LIMIT 1");
                                 if ($value) {
                                     print $value;
                                 }
                             } else {
                                 if ($columns == "contact_fax") {
                                     $value = sql_get_singlevalue("SELECT detail AS value FROM vendor_contact_records WHERE contact_id = '" . $contact_id . "' AND type= 'fax' LIMIT 1");
                                     if ($value) {
                                         print $value;
                                     }
                                 } else {
                                     if ($this->obj_table->data_render[$i][$columns]) {
                                         //								print $columns;
                                         print $this->obj_table->data_render[$i][$columns];
                                     } else {
                                         print "&nbsp;";
                                     }
                                 }
                             }
                         }
                     }
                 }
                 print "</td>";
             }
             //links
             print "<td align=\"right\" nowrap >";
             print "<a class=\"button_small\" href=\"index.php?page=vendors/view.php&id=" . $this->obj_table->data[$i]["id"] . "\">" . lang_trans("details") . "</a>";
             print "<a class=\"button_small\" href=\"index.php?page=vendors/invoices.php&id=" . $this->obj_table->data[$i]["id"] . "\">" . lang_trans("invoices") . "</a>";
             print "</td>";
             print "</tr>";
         }
         print "</table>";
         print "<br />";
         //			 display CSV & PDF download links
         print "<p align=\"right\"><a class=\"button_export\" href=\"index-export.php?mode=csv&page=vendors/vendors.php\">Export as CSV</a></p>";
         print "<p align=\"right\"><a class=\"button_export\" href=\"index-export.php?mode=pdf&page=vendors/vendors.php\">Export as PDF</a></p>";
     }
 }
예제 #13
0
 function execute()
 {
     /*
     	Define form structure
     */
     $this->obj_form = new form_input();
     $this->obj_form->formname = "domain_edit";
     $this->obj_form->language = $_SESSION["user"]["lang"];
     $this->obj_form->action = "domains/edit-process.php";
     $this->obj_form->method = "post";
     // general
     $structure = NULL;
     $structure["fieldname"] = "domain_name";
     $structure["type"] = "input";
     $structure["options"]["req"] = "yes";
     $this->obj_form->add_input($structure);
     $structure = NULL;
     $structure["fieldname"] = "domain_description";
     $structure["type"] = "input";
     $structure["options"]["req"] = "yes";
     $this->obj_form->add_input($structure);
     $structure = NULL;
     $structure["fieldname"] = "domain_description";
     $structure["type"] = "textarea";
     $this->obj_form->add_input($structure);
     // domain groups
     $sql_name_server_group_obj = new sql_query();
     $sql_name_server_group_obj->string = "SELECT id, group_name, group_description FROM name_servers_groups ORDER BY group_name";
     $sql_name_server_group_obj->execute();
     if ($sql_name_server_group_obj->num_rows()) {
         // user note
         $structure = NULL;
         $structure["fieldname"] = "domain_message";
         $structure["type"] = "message";
         $structure["defaultvalue"] = "<p>" . lang_trans("help_domain_group_selection") . "</p>";
         $this->obj_form->add_input($structure);
         $this->domain_array[] = "domain_message";
         // fetch customer's current domain status
         if (!isset($_SESSION["error"]["message"])) {
             $sql_domain_groups_obj = new sql_query();
             $sql_domain_groups_obj->string = "SELECT id_group FROM dns_domains_groups WHERE id_domain='" . $this->obj_domain->id . "'";
             $sql_domain_groups_obj->execute();
             if ($sql_domain_groups_obj->num_rows()) {
                 $sql_domain_groups_obj->fetch_array();
             }
         }
         // run through all the domains
         $sql_name_server_group_obj->fetch_array();
         foreach ($sql_name_server_group_obj->data as $data_group) {
             // define domain checkbox
             $structure = NULL;
             $structure["fieldname"] = "name_server_group_" . $data_group["id"];
             $structure["type"] = "checkbox";
             $structure["options"]["label"] = $data_group["group_name"] . " -- " . $data_group["group_description"];
             $structure["options"]["no_fieldname"] = "enable";
             // check if this domain is currently checked
             if ($sql_domain_groups_obj->data_num_rows) {
                 foreach ($sql_domain_groups_obj->data as $data) {
                     if ($data["id_group"] == $data_group["id"]) {
                         $structure["defaultvalue"] = "on";
                     }
                 }
             }
             // add to form
             $this->obj_form->add_input($structure);
             $this->domain_array[] = "name_server_group_" . $data_group["id"];
         }
     }
     // SOA configuration
     $structure = NULL;
     $structure["fieldname"] = "soa_hostmaster";
     $structure["type"] = "input";
     $structure["options"]["req"] = "yes";
     $this->obj_form->add_input($structure);
     $structure = NULL;
     $structure["fieldname"] = "soa_serial";
     $structure["type"] = "input";
     $structure["options"]["req"] = "yes";
     $this->obj_form->add_input($structure);
     $structure = NULL;
     $structure["fieldname"] = "soa_refresh";
     $structure["type"] = "input";
     $structure["options"]["req"] = "yes";
     $this->obj_form->add_input($structure);
     $structure = NULL;
     $structure["fieldname"] = "soa_retry";
     $structure["type"] = "input";
     $structure["options"]["req"] = "yes";
     $this->obj_form->add_input($structure);
     $structure["fieldname"] = "soa_expire";
     $structure["type"] = "input";
     $structure["options"]["req"] = "yes";
     $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);
     // hidden section
     $structure = NULL;
     $structure["fieldname"] = "id_domain";
     $structure["type"] = "hidden";
     $structure["defaultvalue"] = $this->obj_domain->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["domain_details"] = array("domain_name", "domain_description");
     $this->obj_form->subforms["domain_groups"] = $this->domain_array;
     $this->obj_form->subforms["domain_soa"] = array("soa_hostmaster", "soa_serial", "soa_refresh", "soa_retry", "soa_expire", "soa_default_ttl");
     $this->obj_form->subforms["hidden"] = array("id_domain");
     $this->obj_form->subforms["submit"] = array("submit");
     // import data
     if (error_check()) {
         $this->obj_form->load_data_error();
     } else {
         if ($this->obj_domain->load_data()) {
             $this->obj_form->structure["domain_name"]["defaultvalue"] = $this->obj_domain->data["domain_name"];
             $this->obj_form->structure["domain_description"]["defaultvalue"] = $this->obj_domain->data["domain_description"];
             $this->obj_form->structure["soa_hostmaster"]["defaultvalue"] = $this->obj_domain->data["soa_hostmaster"];
             $this->obj_form->structure["soa_serial"]["defaultvalue"] = $this->obj_domain->data["soa_serial"];
             $this->obj_form->structure["soa_refresh"]["defaultvalue"] = $this->obj_domain->data["soa_refresh"];
             $this->obj_form->structure["soa_retry"]["defaultvalue"] = $this->obj_domain->data["soa_retry"];
             $this->obj_form->structure["soa_expire"]["defaultvalue"] = $this->obj_domain->data["soa_expire"];
             $this->obj_form->structure["soa_default_ttl"]["defaultvalue"] = $this->obj_domain->data["soa_default_ttl"];
         }
     }
 }
예제 #14
0
 function render_html()
 {
     // Title + Summary
     print "<h3>DOMAIN NAME RECORDS</h3><br>";
     print "<p>Below is a list of all the records for your domain name, if you change any of them and click save, the changes will be applied and the name servers will reload shortly.</p>";
     /*
     	Basic domain details
     
     	We have to do this manually in order to be able to handle all the transaction rows
     */
     // start form/table structure
     print "<form method=\"" . $this->obj_form->method . "\" action=\"" . $this->obj_form->action . "\" class=\"form_standard\" name=\"domain_records\">";
     print "<table class=\"form_table\" width=\"100%\">";
     // general form fields
     print "<tr class=\"header\">";
     print "<td colspan=\"2\"><b>" . lang_trans("domain_details") . "</b></td>";
     print "</tr>";
     $this->obj_form->render_row("domain_name");
     print "</tr>";
     // spacer
     print "<tr><td colspan=\"2\"><br></td></tr>";
     /*
     	NS Records
     */
     print "<tr class=\"header\">";
     print "<td colspan=\"2\"><b>" . lang_trans("domain_records_ns") . "</b></td>";
     print "</tr>";
     print "<tr>";
     print "<td colspan=\"2\" width=\"100%\">";
     print "<p>" . lang_trans("domain_records_ns_help") . "</p>";
     print "<table width=\"100%\">";
     print "<tr class=\"table_highlight_info\">";
     print "<td width=\"10%\"><b>" . lang_trans("record_type") . "</b></td>";
     print "<td width=\"15%\"><b>" . lang_trans("record_ttl") . "</b></td>";
     print "<td width=\"35%\"><b>" . lang_trans("record_origin") . "</b></td>";
     print "<td width=\"35%\"><b>" . lang_trans("record_content") . "</b></td>";
     print "<td width=\"5%\">&nbsp;</td>";
     print "</tr>";
     print "</tr>";
     // display all the rows
     for ($i = 0; $i < $this->num_records_ns; $i++) {
         if (isset($_SESSION["error"]["record_ns_" . $i . "-error"])) {
             print "<tr class=\"form_error\">";
         } else {
             print "<tr class=\"table_highlight\">";
         }
         print "<td width=\"10%\" valign=\"top\">";
         $this->obj_form->render_field("record_ns_" . $i . "_type");
         $this->obj_form->render_field("record_ns_" . $i . "_id");
         print "</td>";
         print "<td width=\"15%\" valign=\"top\">";
         $this->obj_form->render_field("record_ns_" . $i . "_ttl");
         print "</td>";
         print "<td width=\"35%\" valign=\"top\">";
         $this->obj_form->render_field("record_ns_" . $i . "_name");
         print "</td>";
         print "<td width=\"35%\" valign=\"top\">";
         $this->obj_form->render_field("record_ns_" . $i . "_content");
         print "</td>";
         print "<td width=\"5%\" valign=\"top\">";
         if ($this->obj_form->structure["record_ns_" . $i . "_delete_undo"]["defaultvalue"] != "disabled") {
             $this->obj_form->render_field("record_ns_" . $i . "_delete_undo");
             print "<strong class=\"delete_undo\"><a href=\"\">delete</a></strong>";
         }
         print "</td>";
         print "</tr>";
     }
     print "</table>";
     print "</td></tr>";
     // spacer
     print "<tr><td colspan=\"2\"><br></td></tr>";
     /*
     	MX Records
     */
     print "<tr class=\"header\">";
     print "<td colspan=\"2\"><b>" . lang_trans("domain_records_mx") . "</b></td>";
     print "</tr>";
     print "<tr>";
     print "<td colspan=\"2\" width=\"100%\">";
     print "<table width=\"100%\">";
     print "<p>" . lang_trans("domain_records_mx_help") . "</p>";
     print "<tr class=\"table_highlight_info\">";
     print "<td width=\"10%\"><b>" . lang_trans("record_type") . "</b></td>";
     print "<td width=\"15%\"><b>" . lang_trans("record_ttl") . "</b></td>";
     print "<td width=\"10%\"><b>" . lang_trans("record_prio") . "</b></td>";
     print "<td width=\"25%\"><b>" . lang_trans("record_origin") . "</b></td>";
     print "<td width=\"35%\"><b>" . lang_trans("record_content") . "</b></td>";
     print "<td width=\"5%\">&nbsp;</td>";
     print "</tr>";
     // display all the rows
     for ($i = 0; $i < $this->num_records_mx; $i++) {
         if (isset($_SESSION["error"]["record_mx_" . $i . "-error"])) {
             print "<tr class=\"form_error\">";
         } else {
             print "<tr class=\"table_highlight\">";
         }
         print "<td width=\"10%\" valign=\"top\">";
         $this->obj_form->render_field("record_mx_" . $i . "_type");
         $this->obj_form->render_field("record_mx_" . $i . "_id");
         print "</td>";
         print "<td width=\"15%\" valign=\"top\">";
         $this->obj_form->render_field("record_mx_" . $i . "_ttl");
         print "</td>";
         print "<td width=\"10%\" valign=\"top\">";
         $this->obj_form->render_field("record_mx_" . $i . "_prio");
         print "</td>";
         print "<td width=\"25%\" valign=\"top\">";
         $this->obj_form->render_field("record_mx_" . $i . "_name");
         print "</td>";
         print "<td width=\"35%\" valign=\"top\">";
         $this->obj_form->render_field("record_mx_" . $i . "_content");
         print "</td>";
         print "<td width=\"5%\" valign=\"top\">";
         $this->obj_form->render_field("record_mx_" . $i . "_delete_undo");
         print "<strong class=\"delete_undo\"><a href=\"\">delete</a></strong>";
         print "</td>";
         print "</tr>";
     }
     print "</table>";
     print "</td></tr>";
     // spacer
     print "<tr><td colspan=\"2\"><br></td></tr>";
     /*	
     	Custom Records
     
     	The definition and display of custom records is controlled in domain/records-ajax.php.
     */
     print "<tr class=\"header\">";
     print "<td colspan=\"2\"><b>" . lang_trans("domain_records_custom") . "</b></td>";
     print "</tr>";
     print "<tr>";
     print "<td colspan=\"2\" width=\"100%\">";
     print "<table width=\"100%\" id=\"domain_records_custom\">";
     print "</table>";
     print "</td></tr>";
     // spacer
     print "<tr><td colspan=\"2\"><br></td></tr>";
     // hidden fields
     $this->obj_form->render_field("id_domain");
     $this->obj_form->render_field("num_records_ns");
     $this->obj_form->render_field("num_records_mx");
     $this->obj_form->render_field("form_session");
     // $this->obj_form->render_field("num_records_custom");
     // form submit
     print "<tr class=\"header\">";
     print "<td colspan=\"2\"><b>" . lang_trans("submit") . "</b></td>";
     print "</tr>";
     $this->obj_form->render_row("submit");
     // end table + form
     print "</table>";
     print "</form>";
 }
예제 #15
0
 function render_html()
 {
     // Title + Summary
     print "<h3>TEMPLATE SELECTION</h3><br>";
     print "<p>You can adjust the PDFs generated by the Amberdms Billing System by using different templates - these templates may include different languages, different layouts or other styling effects.</p>";
     format_msgbox("info", "<p>If you have made your own template you would like to contribute back or if you need customisation work, please contact <a href=\"mailto:support@amberdms.com\">support@amberdms.com</a> for details and we will be happy to assist.</p>");
     foreach ($this->obj_sql_invoice_data as $invoice_type_name => $invoice_type_data) {
         foreach ($invoice_type_data['templates'] as $data_sql) {
             if ($data_sql["active"]) {
                 $current_template_url = $data_sql["template_file"] . "_icon.png";
                 $current_template_name = $data_sql["template_name"];
                 $current_template_description = $data_sql["template_description"];
                 break;
             }
         }
         print "<form action=" . $this->obj_form->action . " method=" . $this->obj_form->method . ">";
         print "<br /><br /><table width=\"100%\" cellspacing=\"0\" cellpadding=\"0\" class=\"template_table\">";
         print "<tr class=\"current_template_row\">";
         print "<td class=\"current_template_cell\" colspan=\"2\">";
         print "<div class=\"current_template_header\"><p><h3>" . $invoice_type_data['name'] . ":</h3></p></div>";
         print "<p><img class=\"current_template_image\" src=\"" . $current_template_url . "\" /></p>";
         print "<p class=\"current_template_description\"><b>" . $current_template_name . "</b><br />";
         print $current_template_description . "</p><br />";
         print "<p><strong><a class=\"change_template\" id=\"change_template\" href=\"\">Change...</a></strong></p>";
         print "</td>";
         print "<td class=\"filler_cell\">";
         print "</td>";
         print "<td class=\"filler_cell\">";
         print "</td>";
         print "</tr>";
         $j = -1;
         $array = array();
         for ($i = 0; $i < count($invoice_type_data['templates']); $i++) {
             if ($i % 3 == 0) {
                 $j++;
             }
             $array[$j][] = $i;
         }
         for ($j = 0; $j < count($array); $j++) {
             //images
             print "<tr class=\"available_templates_row ar_invoices_templates\">";
             for ($i = 0; $i < 3; $i++) {
                 if (isset($array[$j][$i])) {
                     $id = $array[$j][$i];
                     print "<td class=\"available_templates_cell\">";
                     print "<img  src=\"" . $invoice_type_data['templates'][$id]["template_file"] . "_icon.png\">";
                     print "</td>";
                 } else {
                     print "<td class=\"filler_cell\">";
                     print "</td>";
                 }
             }
             print "</tr>";
             //details
             print "<tr class=\"available_templates_row ar_invoices_templates\">";
             for ($i = 0; $i < 3; $i++) {
                 if (isset($array[$j][$i])) {
                     $id = $array[$j][$i];
                     print "<td class=\"available_templates_cell\" valign=\"top\">";
                     print "<p><strong>" . $invoice_type_data['templates'][$id]["template_name"] . "</strong></p>";
                     print "<p>" . $invoice_type_data['templates'][$id]["template_description"] . "</p>";
                     print "</td>";
                 } else {
                     print "<td class=\"filler_cell\">";
                     print "</td>";
                 }
             }
             print "</tr>";
             //select
             print "<tr class=\"available_templates_row " . $invoice_type_name . "_templates\">";
             for ($i = 0; $i < 3; $i++) {
                 if (isset($array[$j][$i])) {
                     $id = $array[$j][$i];
                     print "<td class=\"available_templates_cell\">";
                     print "<p><input type=\"radio\" name=\"selected_template\" id=\"" . $invoice_type_data['templates'][$id]["id"] . "\" value=\"" . $invoice_type_data['templates'][$id]["id"] . "\" ";
                     if ($invoice_type_data['templates'][$id]["active"]) {
                         print "checked ";
                     }
                     print "><label for=\"" . $invoice_type_data['templates'][$id]["id"] . "\"> " . lang_trans("use_this_template") . "</label></p>";
                     print "</td>";
                 } else {
                     print "<td class=\"filler_cell\">";
                     print "</td>";
                 }
             }
             print "</tr>";
         }
         print "<tr class=\"available_templates_row ar_invoices_templates\">";
         print "<td class=\"available_templates_cell\" colspan=\"3\">";
         print "<input type=\"hidden\" name=\"action\" value=\"pdf_template\">&nbsp;&nbsp;";
         print "<input type=\"hidden\" name=\"template_type\" value=\"" . $invoice_type_name . "\">&nbsp;&nbsp;";
         print "<input type=\"submit\" value=\"Save Changes\">&nbsp;&nbsp;";
         print "<input type=\"button\" value=\"Cancel\" class=\"cancelbutton\">";
         print "<br />&nbsp;";
         print "</td>";
         print "</tr>";
         print "</table>";
         print "</form>";
     }
     // Loop through the email template forms, displaying them.
     foreach ($this->email_template_array as $email_template_data) {
         print "<form action=" . $email_template_data['form']->action . " method=" . $email_template_data['form']->method . ">";
         print "<br /><br /><table width=\"100%\" cellspacing=\"0\" cellpadding=\"0\" class=\"template_table\">";
         print "<tr class=\"current_template_row\">";
         print "<td class=\"current_template_cell\" colspan=\"2\">";
         print "<div class=\"current_template_header\"><p><h3>" . $email_template_data['name'] . ":</h3></p></div>";
         print "<p><img class=\"current_template_image\" src=\"" . $email_template_data['image'] . "\" /></p>";
         print "<div class='email_template_text'>";
         print "<p class=\"current_template_description current_email_template\">";
         print $email_template_data['description'] . "</p><br />";
         print "<p><strong><a class=\"change_template\" id=\"change_template\" href=\"\">Change...</a></strong></p>";
         print "</div>";
         print "</td>";
         print "<td class=\"filler_cell\">";
         print "</td>";
         print "<td class=\"filler_cell\">";
         print "</td>";
         print "</tr>";
         print "<tr class=\"available_templates_row ar_invoices_templates\">";
         print "<td class=\"available_templates_cell\" colspan=\"3\">";
         print "<div>";
         $email_template_data['form']->render_field('email_message');
         $email_template_data['form']->render_field('action');
         $email_template_data['form']->render_field('template_type');
         print "</div>";
         print "<br />&nbsp;";
         print "<div>";
         print "<input type=\"submit\" value=\"Save Changes\">&nbsp;&nbsp;";
         print "<input type=\"button\" value=\"Cancel\" class=\"cancelbutton\">";
         print "</div>";
         print "<br />&nbsp;";
         print "</td>";
         print "</tr>";
         print "</table>";
         print "</form>";
     }
 }
예제 #16
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 render_html()
 {
     /*
     	Header
     */
     // Title + Summary
     print "<h3>CDR IMPORT COLUMN CLARIFICATION</h3><br>";
     print "<p>Please match the CSV file columns with the correct ones for importing and choose additional import options</p>";
     // display the form
     print "<form class=\"form_standard\" action=\"services/cdr-rates-import-csv-process.php\" method=\"post\" enctype=\"multipart/form-data\">";
     print "<table class=\"form_table\">";
     /*
     	Field Assignment
     */
     print "<tr class=\"header\">";
     print "<td><b>Column</b></td>";
     print "<td><b>Example</b></td>";
     print "<td><b>Field</b></td>";
     print "</tr>";
     for ($i = 1; $i <= $this->num_col; $i++) {
         if (isset($this->example_array[$i])) {
             $name = "column" . $i;
             $name_error = $name . "-error";
             if (isset($_SESSION["error"][$name_error])) {
                 print "<tr class=\"form_error\">";
             } else {
                 print "<tr id=\"" . $name . "\">";
             }
             print "<td>";
             print "Column " . $i;
             print "</td>";
             print "<td>";
             print $this->example_array[$i];
             print "</td>";
             print "<td>";
             $this->obj_form->render_field($name);
             print "</td>";
             print "</tr>";
         }
     }
     /*
     	Import Options
     */
     print "<tr class=\"header\">";
     print "<td colspan=\"3\"><b>" . lang_trans("cdr_rate_import_options") . "</b></td>";
     print "</tr>";
     if (isset($_SESSION["error"]["cdr_rate_import_mode"])) {
         print "<tr class=\"form_error\">";
     } else {
         print "<tr id=\"cdr_rate_import_mode\">";
     }
     print "<td colspan=\"2\">" . lang_trans("cdr_rate_import_mode") . " *</td>";
     print "<td>";
     $this->obj_form->render_field("cdr_rate_import_mode");
     print "</td>";
     print "</tr>";
     if (isset($_SESSION["error"]["rate_billgroup"])) {
         print "<tr class=\"form_error\">";
     } else {
         print "<tr id=\"rate_billgroup\">";
     }
     print "<td colspan=\"2\">" . lang_trans("rate_billgroup") . " *</td>";
     print "<td>";
     $this->obj_form->render_field("rate_billgroup");
     print "</td>";
     print "</tr>";
     if (isset($_SESSION["error"]["cdr_rate_import_cost_price"])) {
         print "<tr class=\"form_error\">";
     } else {
         print "<tr id=\"cdr_rate_import_mode\">";
     }
     print "<td colspan=\"2\">" . lang_trans("cdr_rate_import_cost_price") . " *</td>";
     print "<td>";
     $this->obj_form->render_field("cdr_rate_import_cost_price");
     print "</td>";
     print "</tr>";
     if (isset($_SESSION["error"]["cdr_rate_import_sale_price"])) {
         print "<tr class=\"form_error\">";
     } else {
         print "<tr id=\"cdr_rate_import_sale_price\">";
     }
     print "<td colspan=\"2\">" . lang_trans("cdr_rate_import_sale_price") . " *</td>";
     print "<td>";
     $this->obj_form->render_field("cdr_rate_import_sale_price");
     print "</td>";
     print "</tr>";
     if (isset($_SESSION["error"]["cdr_rate_import_sale_price_margin"])) {
         print "<tr class=\"form_error\">";
     } else {
         print "<tr id=\"cdr_rate_import_sale_price_margin\">";
     }
     print "<td colspan=\"2\">" . lang_trans("cdr_rate_import_sale_price_margin") . "</td>";
     print "<td>";
     $this->obj_form->render_field("cdr_rate_import_sale_price_margin");
     print " %</td>";
     print "</tr>";
     /*
     	Hidden & Submit
     */
     print "<tr class=\"header\">";
     print "<td colspan=\"3\"><b>" . lang_trans("submit") . "</b></td>";
     print "</tr>";
     print "<tr id=\"submit\">";
     print "<td colspan=\"3\">";
     $this->obj_form->render_field("num_cols");
     $this->obj_form->render_field("id_rate_table");
     $this->obj_form->render_field("submit");
     print "</td>";
     print "</tr>";
     print "</table>";
     print "</form>";
 }
예제 #18
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>";
             }
         }
     }
 }
예제 #19
0
    $structure["fieldname"] = "trans_label";
    $structure["type"] = "input";
    $structure["options"]["req"] = "yes";
    $obj_form->add_input($structure);
    $structure = NULL;
    $structure["fieldname"] = "trans_translation";
    $structure["type"] = "input";
    $structure["options"]["req"] = "yes";
    $obj_form->add_input($structure);
    $structure = NULL;
    $structure["fieldname"] = "submit";
    $structure["type"] = "message";
    $structure["defaultvalue"] = "<p><a class=\"button\" id=\"trans_submit\" href=\"\">Save Changes</a></p>";
    $obj_form->add_input($structure);
    // define subforms
    $obj_form->subforms["translate"] = array("trans_label", "trans_translation");
    $obj_form->subforms["submit"] = array("submit");
    // fetch the form data
    //	$obj_form->sql_query = "SELECT * FROM `customers` WHERE id='". $this->id ."' LIMIT 1";
    //	$obj_form->load_data();
    /*
    	Render Form
    */
    print "<div id=\"trans_popup\">";
    print "<a id=\"trans_popup_close\">[X]</a>";
    print "<h3>" . lang_trans("trans_form_title") . "</h3>";
    print "<p>" . lang_trans("trans_form_desc") . "</p>";
    $obj_form->render_form();
    print "</div>";
    print "<div id=\"trans_popup_background\"></div>";
}
예제 #20
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();
     }
 }
예제 #21
0
 function render_table_pdf($template = NULL)
 {
     log_debug("table", "Executing render_table_pdf()");
     if (!$template) {
         $template = "amberphplib_table_default.tex";
     }
     // calculate all the totals and prepare processed values
     if (!isset($this->data_render)) {
         $this->render_table_prepare();
     }
     // start the PDF object
     $template_pdf = new template_engine_latex();
     // load template
     $template_pdf->prepare_load_template("templates/latex/{$template}");
     /*
     	Generate PDF Template
     */
     log_write("debug", "table", "Generating custom PDF template latex...");
     // init values
     $output_tabledata = array();
     // fetch the number of columns so we can draw the latex table
     $col_num = count($this->columns);
     // work out the number columns with the totals
     $col_num_with_total = $col_num;
     if ($this->total_rows) {
         $col_num_with_total++;
     }
     // fetch column widths (float of percent of one)
     $col_width = 0.9 / $col_num_with_total;
     $output_tabledata[] = '\\noindent \\begin{longtable}{';
     for ($i = 0; $i < $col_num_with_total; $i++) {
         $output_tabledata[] = '>{\\centering}p{' . $col_width . '\\columnwidth}';
     }
     $output_tabledata[] = '}\\cline{1-' . $col_num_with_total . '}';
     // define column headers
     for ($i = 0; $i < $col_num; $i++) {
         $output_tabledata[] = '\\textbf{' . $this->render_columns[$this->columns[$i]] . '}';
         if ($i != $col_num - 1) {
             $output_tabledata[] = " & ";
         }
     }
     // add header for total
     if ($this->total_rows) {
         $output_tabledata[] = ' & \\textbf{Total} ';
     }
     $output_tabledata[] = '\\endfirsthead \\cline{1-' . $col_num_with_total . '}';
     // table foreach loop
     $output_tabledata[] = '%% foreach table\\_data';
     $line = "";
     $line .= '%% ';
     for ($i = 0; $i < $col_num; $i++) {
         $line .= '(column\\_' . $i . ')';
         if ($i != $col_num - 1) {
             $line .= " & ";
         }
     }
     if ($this->total_rows) {
         $line .= ' & (column\\_total) ';
     }
     $line .= '\\tabularnewline';
     $output_tabledata[] = $line;
     $output_tabledata[] = '%% end';
     // display totals for columns (if required)
     if ($this->total_columns) {
         $output_tabledata[] = '\\cline{1-' . $col_num_with_total . '}';
         $line = "";
         for ($i = 0; $i < $col_num; $i++) {
             $line .= '(column\\_total\\_' . $i . ')';
             if ($i != $col_num - 1) {
                 $line .= " & ";
             }
         }
         if ($this->total_rows) {
             $line .= ' & (column\\_total\\_total) ';
         }
         $line .= '\\tabularnewline';
         $output_tabledata[] = $line;
     }
     // end data table
     $output_tabledata[] = '\\cline{1-' . $col_num_with_total . '}';
     $output_tabledata[] = '\\end{longtable}';
     /*
     	Write changes to PDF template in memory
     */
     log_write("debug", "table", "Writing custom PDF template in memory");
     $template_new = array();
     foreach ($template_pdf->template as $line_orig) {
         if ($line_orig == "%% TABLE_DATA\n") {
             foreach ($output_tabledata as $line_new) {
                 $template_new[] = $line_new . "\n";
             }
         } else {
             $template_new[] = $line_orig;
         }
     }
     // overwrite memory version with processed version
     $template_pdf->template = $template_new;
     unset($template_new);
     /*
     	Fill Template
     */
     // company logo
     $template_pdf->prepare_add_file("company_logo", "png", "COMPANY_LOGO", 0);
     // table name
     $template_pdf->prepare_add_field("table_name", lang_trans($this->tablename));
     // table options
     $structure_main = NULL;
     // add date created option
     $structure = array();
     $structure["option_name"] = lang_trans("date_created");
     $structure["option_value"] = time_format_humandate();
     $structure_main[] = $structure;
     foreach (array_keys($this->filter) as $filtername) {
         $structure = array();
         $structure["option_name"] = lang_trans($filtername);
         switch ($this->filter[$filtername]["type"]) {
             case "date":
                 $structure["option_value"] = time_format_humandate($this->filter[$filtername]["defaultvalue"]);
                 break;
             case "timestamp":
                 $structure["option_value"] = time_format_humandate($this->filter[$filtername]["defaultvalue"]);
                 break;
             default:
                 // for all other types of filters, just display raw
                 if ($this->filter[$filtername]["defaultvalue"]) {
                     $structure["option_value"] = $this->filter[$filtername]["defaultvalue"];
                 } else {
                     $structure["option_value"] = "---";
                 }
                 break;
         }
         $structure_main[] = $structure;
     }
     $template_pdf->prepare_add_array("table_options", $structure_main);
     // main table data rows
     $structure_main = NULL;
     for ($i = 0; $i < $this->data_num_rows; $i++) {
         $structure = array();
         // add data for all selected columns
         for ($j = 0; $j < count($this->columns); $j++) {
             $structure["column_{$j}"] = $this->data_render[$i]["" . $this->columns[$j] . ""];
         }
         // optional: row totals column
         if ($this->total_rows) {
             $structure["column_total"] = $this->data_render[$i]["total"];
         }
         $structure_main[] = $structure;
     }
     $template_pdf->prepare_add_array("table_data", $structure_main);
     // totals
     if ($this->total_columns) {
         for ($j = 0; $j < count($this->columns); $j++) {
             $column = $this->columns[$j];
             if (in_array($column, $this->total_columns)) {
                 $template_pdf->prepare_add_field('column_total_' . $j, $this->data_render["total"][$column]);
             } else {
                 $template_pdf->prepare_add_field('column_total_' . $j, "");
             }
         }
         // optional: totals for rows
         if ($this->total_rows) {
             $template_pdf->prepare_add_field('column_total_total', $this->data_render["total"]["total"]);
         }
         print "\n";
     }
     /*
     	Output PDF
     */
     // perform string escaping for latex
     $template_pdf->prepare_escape_fields();
     // fill template
     $template_pdf->prepare_filltemplate();
     // generate PDF output
     $template_pdf->generate_pdf();
     // display PDF
     print $template_pdf->output;
     //		print_r($template_pdf->template);
     //		print_r($template_pdf->processed);
     //		print_r($template_pdf->data_array);
 }
예제 #22
0
 function execute()
 {
     /*
     	Define form structure
     */
     $this->obj_form = new form_input();
     $this->obj_form->formname = "config_services";
     $this->obj_form->language = $_SESSION["user"]["lang"];
     $this->obj_form->action = "admin/config_services-process.php";
     $this->obj_form->method = "post";
     /*
     	Configure Service Types & Labels
     */
     $structure = NULL;
     $structure["fieldname"] = "service_types_enabled";
     $structure["type"] = "text";
     $structure["defaultvalue"] = "<p>" . lang_trans("service_types_selection_help") . "</p>";
     $this->obj_form->add_input($structure);
     $this->obj_form->subforms["config_service_types"] = array("service_types_enabled");
     $obj_sql = new sql_query();
     $obj_sql->string = "SELECT id, name, description, active FROM service_types ORDER BY name";
     $obj_sql->execute();
     if ($obj_sql->num_rows()) {
         $obj_sql->fetch_array();
         foreach ($obj_sql->data as $data_row) {
             // enable/disable
             $structure = NULL;
             $structure["fieldname"] = "service_type_" . $data_row["id"] . "_enable";
             $structure["type"] = "checkbox";
             $structure["options"]["label"] = $data_row["name"];
             if ($data_row["active"]) {
                 $structure["defaultvalue"] = 1;
             }
             $this->obj_form->add_input($structure);
             // description
             $structure = NULL;
             $structure["fieldname"] = "service_type_" . $data_row["id"] . "_description";
             $structure["type"] = "input";
             $structure["defaultvalue"] = $data_row["description"];
             $structure["options"]["width"] = "800";
             $this->obj_form->add_input($structure);
             // grouping
             $this->obj_form->subforms["config_service_types"][] = "service_type_" . $data_row["id"];
             $this->obj_form->subforms_grouped["config_service_types"]["service_type_" . $data_row["id"]][] = "service_type_" . $data_row["id"] . "_enable";
             $this->obj_form->subforms_grouped["config_service_types"]["service_type_" . $data_row["id"]][] = "service_type_" . $data_row["id"] . "_description";
         }
     }
     unset($obj_sql);
     /*
     	Configure service billing cycles
     
     	We provide the ability to enable/disable service billing cycles in the UI to make things easier
     	for the users.
     */
     $structure = NULL;
     $structure["fieldname"] = "billing_cycle_enabled";
     $structure["type"] = "text";
     $structure["defaultvalue"] = "<p>" . lang_trans("billing_cycle_selection_help") . "</p>";
     $this->obj_form->add_input($structure);
     $this->obj_form->subforms["config_billing_cycle"] = array("billing_cycle_enabled");
     $obj_sql = new sql_query();
     $obj_sql->string = "SELECT id, name, description, active FROM billing_cycles ORDER BY priority";
     $obj_sql->execute();
     if ($obj_sql->num_rows()) {
         $obj_sql->fetch_array();
         foreach ($obj_sql->data as $data_row) {
             $structure = NULL;
             $structure["fieldname"] = "billing_cycle_" . $data_row["id"];
             $structure["type"] = "checkbox";
             $structure["options"]["label"] = $data_row["name"] . " -- " . $data_row["description"];
             $structure["options"]["no_fieldname"] = 1;
             $structure["options"]["no_shift"] = 1;
             if ($data_row["active"]) {
                 $structure["defaultvalue"] = 1;
             }
             $this->obj_form->add_input($structure);
             $this->obj_form->subforms["config_billing_cycle"][] = "billing_cycle_" . $data_row["id"];
         }
     }
     unset($obj_sql);
     /*
     	Configure service billing modes
     
     	We provide the ability to enable/disable service billing modes in the UI to make things easier
     	for the users.
     */
     $structure = NULL;
     $structure["fieldname"] = "billing_mode_enabled";
     $structure["type"] = "text";
     $structure["defaultvalue"] = "<p>" . lang_trans("billing_mode_selection_help") . "</p>";
     $this->obj_form->add_input($structure);
     $this->obj_form->subforms["config_billing_mode"] = array("billing_mode_enabled");
     $obj_sql = new sql_query();
     $obj_sql->string = "SELECT id, name, description, active FROM billing_modes ORDER BY id";
     $obj_sql->execute();
     if ($obj_sql->num_rows()) {
         $obj_sql->fetch_array();
         foreach ($obj_sql->data as $data_row) {
             $structure = NULL;
             $structure["fieldname"] = "billing_mode_" . $data_row["id"];
             $structure["type"] = "checkbox";
             $structure["options"]["label"] = $data_row["name"] . " -- " . $data_row["description"];
             $structure["options"]["no_fieldname"] = 1;
             $structure["options"]["no_shift"] = 1;
             if ($data_row["active"]) {
                 $structure["defaultvalue"] = 1;
             }
             $this->obj_form->add_input($structure);
             $this->obj_form->subforms["config_billing_mode"][] = "billing_mode_" . $data_row["id"];
         }
     }
     unset($obj_sql);
     /*
     	Configure service usage unit options
     
     	We allow the administor to enable/disable service units from being displayed as options (primarily 
     	to prevent staff confusion.
     */
     $structure = NULL;
     $structure["fieldname"] = "service_units_enabled";
     $structure["type"] = "text";
     $structure["defaultvalue"] = "<p>" . lang_trans("service_unit_selection_help") . "</p>";
     $this->obj_form->add_input($structure);
     $this->obj_form->subforms["config_usage_units"] = array("service_units_enabled");
     $obj_sql = new sql_query();
     $obj_sql->string = "SELECT id, name, description, active FROM service_units ORDER BY typeid, name";
     $obj_sql->execute();
     if ($obj_sql->num_rows()) {
         $obj_sql->fetch_array();
         foreach ($obj_sql->data as $data_row) {
             $structure = NULL;
             $structure["fieldname"] = "service_unit_" . $data_row["id"];
             $structure["type"] = "checkbox";
             $structure["options"]["label"] = $data_row["name"] . " -- " . $data_row["description"];
             $structure["options"]["no_fieldname"] = 1;
             $structure["options"]["no_shift"] = 1;
             if ($data_row["active"]) {
                 $structure["defaultvalue"] = 1;
             }
             $this->obj_form->add_input($structure);
             $this->obj_form->subforms["config_usage_units"][] = "service_unit_" . $data_row["id"];
         }
     }
     unset($obj_sql);
     /*
     	usage services data source configuration
     
     	We limit this to enabled servers, since it could be misused to try breaking into SQL databases
     	if run by untrusted administrators.
     */
     if ($GLOBALS["config"]["dangerous_conf_options"] == "enabled") {
         $structure = NULL;
         $structure["fieldname"] = "SERVICE_TRAFFIC_MODE";
         $structure["type"] = "radio";
         $structure["values"] = array("internal", "external");
         $structure["translations"]["internal"] = "Use an internal database for usage records, uploaded via the SOAP API";
         $structure["translations"]["external"] = "Use an external SQL database for fetching usage records (such as a netflow DB)";
         $structure["options"]["no_translate_fieldname"] = "yes";
         $this->obj_form->add_input($structure);
         $structure = NULL;
         $structure["fieldname"] = "SERVICE_TRAFFIC_DB_TYPE";
         $structure["type"] = "radio";
         $structure["values"] = array("mysql_netflow_daily", "mysql_traffic_summary");
         $structure["translations"]["mysql_netflow_daily"] = "MySQL Netflow Daily Tables (traffic_YYYYMMDD)";
         $structure["translations"]["mysql_traffic_summary"] = "MySQL Traffic Summary Tables (traffic_summary)";
         $structure["options"]["autoselect"] = "yes";
         $structure["options"]["no_translate_fieldname"] = "yes";
         $this->obj_form->add_input($structure);
         $structure = NULL;
         $structure["fieldname"] = "SERVICE_TRAFFIC_DB_HOST";
         $structure["type"] = "input";
         $structure["options"]["no_translate_fieldname"] = "yes";
         $this->obj_form->add_input($structure);
         $structure = NULL;
         $structure["fieldname"] = "SERVICE_TRAFFIC_DB_NAME";
         $structure["type"] = "input";
         $structure["options"]["no_translate_fieldname"] = "yes";
         $this->obj_form->add_input($structure);
         $structure = NULL;
         $structure["fieldname"] = "SERVICE_TRAFFIC_DB_USERNAME";
         $structure["type"] = "input";
         $structure["options"]["no_translate_fieldname"] = "yes";
         $this->obj_form->add_input($structure);
         $structure = NULL;
         $structure["fieldname"] = "SERVICE_TRAFFIC_DB_PASSWORD";
         $structure["type"] = "input";
         $structure["options"]["no_translate_fieldname"] = "yes";
         $this->obj_form->add_input($structure);
         // set javascript actions
         $this->obj_form->add_action("SERVICE_TRAFFIC_MODE", "default", "SERVICE_TRAFFIC_DB_TYPE", "hide");
         $this->obj_form->add_action("SERVICE_TRAFFIC_MODE", "default", "SERVICE_TRAFFIC_DB_HOST", "hide");
         $this->obj_form->add_action("SERVICE_TRAFFIC_MODE", "default", "SERVICE_TRAFFIC_DB_NAME", "hide");
         $this->obj_form->add_action("SERVICE_TRAFFIC_MODE", "default", "SERVICE_TRAFFIC_DB_USERNAME", "hide");
         $this->obj_form->add_action("SERVICE_TRAFFIC_MODE", "default", "SERVICE_TRAFFIC_DB_PASSWORD", "hide");
         $this->obj_form->add_action("SERVICE_TRAFFIC_MODE", "external", "SERVICE_TRAFFIC_DB_TYPE", "show");
         $this->obj_form->add_action("SERVICE_TRAFFIC_MODE", "external", "SERVICE_TRAFFIC_DB_HOST", "show");
         $this->obj_form->add_action("SERVICE_TRAFFIC_MODE", "external", "SERVICE_TRAFFIC_DB_NAME", "show");
         $this->obj_form->add_action("SERVICE_TRAFFIC_MODE", "external", "SERVICE_TRAFFIC_DB_USERNAME", "show");
         $this->obj_form->add_action("SERVICE_TRAFFIC_MODE", "external", "SERVICE_TRAFFIC_DB_PASSWORD", "show");
         // add subform
         $this->obj_form->subforms["config_usage_traffic"] = array("SERVICE_TRAFFIC_MODE", "SERVICE_TRAFFIC_DB_TYPE", "SERVICE_TRAFFIC_DB_HOST", "SERVICE_TRAFFIC_DB_NAME", "SERVICE_TRAFFIC_DB_USERNAME", "SERVICE_TRAFFIC_DB_PASSWORD");
     } else {
         //
         // explain that the configuration is locked and tell the user the current source of records.
         //
         $structure = NULL;
         $structure["fieldname"] = "SERVICE_TRAFFIC_MSG";
         $structure["type"] = "message";
         if (sql_get_singlevalue("SELECT value FROM config WHERE name='SERVICE_TRAFFIC_MODE' LIMIT 1") == "internal") {
             $structure["defaultvalue"] = "<p>Using internal database for usage records (this configuration is locked by the system administrator)</p>";
         } else {
             $structure["defaultvalue"] = "<p>Use external database for usage records (this configuration is locked by the system administrator)</p>";
         }
         $structure["options"]["css_row_class"] = "table_highlight_info";
         $structure["options"]["no_translate_fieldname"] = "yes";
         $this->obj_form->add_input($structure);
         $this->obj_form->subforms["config_usage_traffic"] = array("SERVICE_TRAFFIC_MSG");
     }
     /*
     	cdr services data source configuration
     
     	We limit this to enabled servers, since it could be misused to try breaking into SQL databases
     	if run by untrusted administrators.
     */
     if ($GLOBALS["config"]["dangerous_conf_options"] == "enabled") {
         $structure = NULL;
         $structure["fieldname"] = "SERVICE_CDR_MODE";
         $structure["type"] = "radio";
         $structure["values"] = array("internal", "external");
         $structure["translations"]["internal"] = "Use an internal database for usage records, uploaded via the SOAP API";
         $structure["translations"]["external"] = "Use an external SQL database for fetching usage records.";
         $structure["options"]["no_translate_fieldname"] = "yes";
         $this->obj_form->add_input($structure);
         $structure = NULL;
         $structure["fieldname"] = "SERVICE_CDR_DB_TYPE";
         $structure["type"] = "radio";
         $structure["values"] = array("mysql_asterisk");
         $structure["translations"]["mysql_asterisk"] = "MySQL-based Asterisk CDR Database";
         $structure["options"]["autoselect"] = "yes";
         $structure["options"]["no_translate_fieldname"] = "yes";
         $this->obj_form->add_input($structure);
         $structure = NULL;
         $structure["fieldname"] = "SERVICE_CDR_DB_HOST";
         $structure["type"] = "input";
         $structure["options"]["no_translate_fieldname"] = "yes";
         $this->obj_form->add_input($structure);
         $structure = NULL;
         $structure["fieldname"] = "SERVICE_CDR_DB_NAME";
         $structure["type"] = "input";
         $structure["options"]["no_translate_fieldname"] = "yes";
         $this->obj_form->add_input($structure);
         $structure = NULL;
         $structure["fieldname"] = "SERVICE_CDR_DB_USERNAME";
         $structure["type"] = "input";
         $structure["options"]["no_translate_fieldname"] = "yes";
         $this->obj_form->add_input($structure);
         $structure = NULL;
         $structure["fieldname"] = "SERVICE_CDR_DB_PASSWORD";
         $structure["type"] = "input";
         $structure["options"]["no_translate_fieldname"] = "yes";
         $this->obj_form->add_input($structure);
         // set javascript actions
         $this->obj_form->add_action("SERVICE_CDR_MODE", "default", "SERVICE_CDR_DB_TYPE", "hide");
         $this->obj_form->add_action("SERVICE_CDR_MODE", "default", "SERVICE_CDR_DB_HOST", "hide");
         $this->obj_form->add_action("SERVICE_CDR_MODE", "default", "SERVICE_CDR_DB_NAME", "hide");
         $this->obj_form->add_action("SERVICE_CDR_MODE", "default", "SERVICE_CDR_DB_USERNAME", "hide");
         $this->obj_form->add_action("SERVICE_CDR_MODE", "default", "SERVICE_CDR_DB_PASSWORD", "hide");
         $this->obj_form->add_action("SERVICE_CDR_MODE", "external", "SERVICE_CDR_DB_TYPE", "show");
         $this->obj_form->add_action("SERVICE_CDR_MODE", "external", "SERVICE_CDR_DB_HOST", "show");
         $this->obj_form->add_action("SERVICE_CDR_MODE", "external", "SERVICE_CDR_DB_NAME", "show");
         $this->obj_form->add_action("SERVICE_CDR_MODE", "external", "SERVICE_CDR_DB_USERNAME", "show");
         $this->obj_form->add_action("SERVICE_CDR_MODE", "external", "SERVICE_CDR_DB_PASSWORD", "show");
         // add subform
         $this->obj_form->subforms["config_usage_cdr"] = array("SERVICE_CDR_MODE", "SERVICE_CDR_DB_TYPE", "SERVICE_CDR_DB_HOST", "SERVICE_CDR_DB_NAME", "SERVICE_CDR_DB_USERNAME", "SERVICE_CDR_DB_PASSWORD");
     } else {
         //
         // explain that the configuration is locked and tell the user the current source of records.
         //
         $structure = NULL;
         $structure["fieldname"] = "SERVICE_CDR_MSG";
         $structure["type"] = "message";
         if (sql_get_singlevalue("SELECT value FROM config WHERE name='SERVICE_CDR_MODE' LIMIT 1") == "internal") {
             $structure["defaultvalue"] = "<p>Using internal database for usage records (this configuration is locked by the system administrator)</p>";
         } else {
             $structure["defaultvalue"] = "<p>Use external database for usage records (this configuration is locked by the system administrator)</p>";
         }
         $structure["options"]["css_row_class"] = "table_highlight_info";
         $structure["options"]["no_translate_fieldname"] = "yes";
         $this->obj_form->add_input($structure);
         $this->obj_form->subforms["config_usage_cdr"] = array("SERVICE_CDR_MSG");
     }
     // CDR optons
     $structure = NULL;
     $structure["fieldname"] = "SERVICE_CDR_LOCAL";
     $structure["type"] = "radio";
     $structure["options"]["no_translate_fieldname"] = "yes";
     $structure["values"] = array("prefix", "destination");
     $structure["translations"]["prefix"] = "Define local customer region by prefix (eg: \"64123\")";
     $structure["translations"]["destination"] = "Define local customer region by destination string (eg: \"Wellington\")";
     $this->obj_form->add_input($structure);
     $structure = NULL;
     $structure["fieldname"] = "SERVICE_CDR_BILLSELF";
     $structure["type"] = "radio";
     $structure["options"]["no_translate_fieldname"] = "yes";
     $structure["values"] = array("free", "local", "regular");
     $structure["translations"]["free"] = "Free calling between a customer's own DDIs";
     $structure["translations"]["local"] = "\"LOCAL\" calling rate for calls between a customer's own DDI";
     $structure["translations"]["regular"] = "Regular calling rates for calls between a customer's own DDI";
     $this->obj_form->add_input($structure);
     $structure = NULL;
     $structure["fieldname"] = "SERVICE_CDR_EXPORT_FORMAT";
     $structure["type"] = "radio";
     $structure["options"]["no_translate_fieldname"] = "yes";
     $structure["values"] = array("csv_padded");
     $structure["translations"]["csv_padded"] = "Export CDRs in padded CSV format";
     $this->obj_form->add_input($structure);
     $this->obj_form->subforms["config_options_cdr"] = array("SERVICE_CDR_LOCAL", "SERVICE_CDR_BILLSELF", "SERVICE_CDR_EXPORT_FORMAT");
     // migration mode options
     $structure = NULL;
     $structure["fieldname"] = "SERVICE_MIGRATION_MODE";
     $structure["type"] = "checkbox";
     $structure["options"]["label"] = "When enabled, provides additional options to service creation to create a part usage period.";
     $structure["options"]["no_translate_fieldname"] = "yes";
     $this->obj_form->add_input($structure);
     // misc
     $structure = NULL;
     $structure["fieldname"] = "SERVICE_PARTPERIOD_MODE";
     $structure["type"] = "radio";
     $structure["values"] = array("seporate", "merge");
     $structure["translations"]["seporate"] = "Invoice a partial period (eg new customer signup) in a seporate invoice.";
     $structure["translations"]["merge"] = "Add the additional period to next month's invoice.";
     $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_migration"] = array("SERVICE_MIGRATION_MODE");
     $this->obj_form->subforms["config_misc"] = array("SERVICE_PARTPERIOD_MODE");
     $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);
     }
 }
예제 #23
0
 function generate_pdf()
 {
     log_debug("inc_credits", "Executing generate_pdf()");
     // load data if required
     if (!is_array($this->credit_fields)) {
         $this->load_data();
         $this->load_data_export();
     }
     // start the PDF object
     //
     // note: the & allows decontructors to operate
     //       Unfortunatly this trick is now deprecated with PHP 5.3.x and creates unsilencable errors ~JC 20100110
     //
     // get template filename based on currently selected options
     $template_data = sql_get_singlerow("SELECT `template_type`, `template_file` FROM templates WHERE template_type IN('" . $this->type . "_tex', '" . $this->type . "_htmltopdf') AND active='1' LIMIT 1");
     //exit("<pre>".print_r($template_data, true)."</pre>");
     switch ($template_data['template_type']) {
         case $this->type . '_htmltopdf':
             $this->obj_pdf =& new template_engine_htmltopdf();
             $template_file = $template_data['template_file'] . "/index.html";
             if (is_dir("../../{$template_data['template_file']}")) {
                 $this->obj_pdf->set_template_directory("../../{$template_data['template_file']}");
             } else {
                 $this->obj_pdf->set_template_directory("../{$template_data['template_file']}");
             }
             break;
         case $this->type . '_tex':
         default:
             $this->obj_pdf =& new template_engine_latex();
             $template_file = $template_data['template_file'] . ".tex";
             break;
     }
     if (!$template_file) {
         // fall back to old version
         //
         // TODO: we can remove this fallback code once the new templating system is fully implemented, this is to
         // just make everything work whilst stuff like quote templates are being added.
         //
         $template_file = "templates/latex/" . $this->type . "";
     }
     // load template
     if (file_exists("../../{$template_file}")) {
         $this->obj_pdf->prepare_load_template("../../{$template_file}");
     } elseif (file_exists("../{$template_file}")) {
         $this->obj_pdf->prepare_load_template("../{$template_file}");
     } else {
         // if we can't find the template file, then something is rather wrong.
         log_write("error", "inc_credits", "Unable to find template file {$template_file}, currently running in directory " . getcwd() . ", fatal error.");
         return 0;
     }
     /*
     	Company Data
     */
     // company logo
     $this->obj_pdf->prepare_add_file("company_logo", "png", "COMPANY_LOGO", 0);
     // convert the credit_fields array into
     foreach ($this->credit_fields as $credit_field_key => $credit_field_value) {
         $this->obj_pdf->prepare_add_field($credit_field_key, $credit_field_value);
     }
     /*
     	Fetch credit items (all credit items other than tax, are type == 'credit')
     */
     // fetch invoice items
     $sql_items_obj = new sql_query();
     $sql_items_obj->string = "SELECT " . "id, type, chartid, customid, quantity, units, amount, price, description " . "FROM account_items " . "WHERE invoiceid='" . $this->id . "' " . "AND invoicetype='" . $this->type . "' " . "AND type='credit' " . "ORDER BY customid, chartid, description";
     $sql_items_obj->execute();
     $sql_items_obj->fetch_array();
     $structure_credititems = array();
     foreach ($sql_items_obj->data as $itemdata) {
         $structure = array();
         $structure["info"] = "CREDIT";
         $structure["quantity"] = " ";
         $structure["group"] = lang_trans("group_other");
         $structure["price"] = "";
         $structure["description"] = trim($itemdata["description"]);
         $structure["units"] = $itemdata["units"];
         $structure["amount"] = format_money($itemdata["amount"], 1);
         $structure_credititems[] = $structure;
     }
     //exit("<pre>".print_r($structure_credititems,true)."</pre>");
     $this->obj_pdf->prepare_add_array("credit_items", $structure_credititems);
     unset($sql_items_obj);
     /*
     	Tax Items
     */
     // fetch tax items
     $sql_tax_obj = new sql_query();
     $sql_tax_obj->string = "SELECT " . "account_items.amount, " . "account_taxes.name_tax, " . "account_taxes.taxnumber " . "FROM " . "account_items " . "LEFT JOIN account_taxes ON account_taxes.id = account_items.customid " . "WHERE " . "invoiceid='" . $this->id . "' " . "AND invoicetype='" . $this->type . "' " . "AND type='tax'";
     $sql_tax_obj->execute();
     if ($sql_tax_obj->num_rows()) {
         $sql_tax_obj->fetch_array();
         $structure_taxitems = array();
         foreach ($sql_tax_obj->data as $taxdata) {
             $structure = array();
             $structure["name_tax"] = $taxdata["name_tax"];
             $structure["taxnumber"] = $taxdata["taxnumber"];
             $structure["amount"] = format_money($taxdata["amount"]);
             $structure_taxitems[] = $structure;
         }
     }
     $this->obj_pdf->prepare_add_array("taxes", $structure_taxitems);
     /*
     	Output PDF
     */
     // perform string escaping for latex
     $this->obj_pdf->prepare_escape_fields();
     // fillter template data
     $this->obj_pdf->fillter_template_data();
     // fill template
     $this->obj_pdf->prepare_filltemplate();
     // Useful for debugging - shows the processed template lines BEFORE it is fed to the render engine
     //print "<pre>";
     //print_r($this->obj_pdf->processed);
     //print "</pre>";
     // generate PDF output
     $this->obj_pdf->generate_pdf();
 }
예제 #24
0
function get_dropdown($p_control_array, $p_control_name, $p_match = '', $p_add_any = false, $p_multiple = false, $p_change_script = '')
{
    $t_control_array = $p_control_array;
    if ($p_multiple) {
        $t_size = ' SIZE="5"';
        $t_multiple = ' MULTIPLE';
    } else {
        $t_size = '';
        $t_multiple = '';
    }
    $t_script = $p_change_script == '' ? '' : ' onchange="' . $p_change_script . '"';
    $t_info = sprintf("<SELECT %s NAME=\"%s\" id=\"%s\"%s%s>", $t_multiple, $p_control_name, $p_control_name, $t_size, $t_script);
    if ($p_add_any) {
        array_unshift_assoc($t_control_array, FILTER_META_ANY, lang_trans('[any]'));
    }
    while (list($t_name, $t_desc) = each($t_control_array)) {
        $t_sel = "";
        if (is_array($p_match)) {
            if (in_array($t_name, array_values($p_match)) || in_array($t_desc, array_values($p_match))) {
                $t_sel = " SELECTED";
            }
        } else {
            if ($t_name === $p_match || $t_desc === $p_match) {
                $t_sel = " SELECTED";
            }
        }
        $t_info .= sprintf("<OPTION%s VALUE=\"%s\">%s", $t_sel, $t_name, $t_desc);
    }
    $t_info .= "</SELECT>\n";
    return $t_info;
}
예제 #25
0
 function render_html()
 {
     // title
     print "<h3>CUSTOMER DETAILS</h3><br>";
     print "<p>This page allows you to view and adjust the customer's records.</p>";
     print "<form class=\"form_standard\" action=\"" . $this->obj_form->action . "\" method=\"" . $this->obj_form->method . "\" enctype=\"multipart/form-data\">";
     print "<table class=\"form_table\" width=\"100%\">";
     //customer details
     print "<tr class=\"header\">";
     print "<td colspan=\"2\"><b>" . lang_trans("customer_view") . "</b></td>";
     print "</tr>";
     $this->obj_form->render_row("code_customer");
     $this->obj_form->render_row("name_customer");
     $this->obj_form->render_row("date_start");
     $this->obj_form->render_row("date_end");
     print "</table>";
     print "<br />";
     //customer contacts
     print "<table id=\"customer_contacts_table\" class=\"form_table\" width=\"100%\">";
     print "<tr class=\"header\">";
     print "<td colspan=\"2\"><b>" . lang_trans("customer_contacts") . "</b></td>";
     print "</tr>";
     for ($i = 0; $i < $this->num_contacts; $i++) {
         print "<tr >";
         print "<td>";
         if (isset($_SESSION["error"]["contact_" . $i . "-error"])) {
             print "<table id=\"contact_box_{$i}\" class=\"error_box contact_box\">";
         } else {
             print "<table id=\"contact_box_{$i}\" class=\"contact_box\">";
         }
         print "<tr>";
         //contact name
         print "<td width=\"25%\">";
         $this->obj_form->render_field("contact_id_{$i}");
         if (isset($_SESSION["error"]["contact_" . $i . "-error"])) {
             print "<span>";
         } else {
             print "<span class=\"hidden_text\">";
         }
         print "<label for=\"contact_{$i}\" >Name: </label><br />";
         print "</span>";
         $this->obj_form->render_field("contact_{$i}");
         if (isset($_SESSION["error"]["contact_" . $i . "-error"])) {
             print "<span>";
         } else {
             print "<span class=\"hidden_text\">";
         }
         print "<label for=\"role_{$i}\">Role: </label><br />";
         print "</span>";
         $this->obj_form->render_field("role_{$i}");
         $this->obj_form->render_field("num_records_{$i}");
         print "<div ";
         if (isset($_SESSION["error"]["contact_" . $i . "-error"])) {
             print "class=\"hidden_text\" ";
         }
         print "id=\"contact_text_{$i}\"><b>" . lang_trans($this->obj_form->structure["contact_{$i}"]["defaultvalue"]) . "</b>";
         print "<br />(" . lang_trans($this->obj_form->structure["role_{$i}"]["defaultvalue"]) . ")</div>";
         print "</td>";
         //delete contact link
         print "<td width=\"75%\" class=\"delete_contact_cell\">";
         $this->obj_form->render_field("delete_contact_{$i}");
         if ($i == 0) {
             print "&nbsp;";
         } else {
             print "<a id=\"delete_contact_{$i}\" href=\"\">delete contact...</a>";
         }
         print "</td>";
         print "</tr>";
         print "<tr>";
         //contact description
         print "<td width=\"25%\" class=\"description_cell\">";
         if (isset($_SESSION["error"]["contact_" . $i . "-error"])) {
             print "<span>";
         } else {
             print "<span class=\"hidden_text\">";
         }
         print "<label for=\"description_{$i}\">Description: </label><br />";
         print "</span>";
         $this->obj_form->render_field("description_{$i}");
         print "<p class=\"";
         if ($_SESSION["error"]["contact_" . $i . "-error"]) {
             print "hidden_text ";
         }
         print "contact_description\" id=\"description_text_{$i}\">" . $this->obj_form->structure["description_{$i}"]["defaultvalue"] . "</p>";
         if (isset($_SESSION["error"]["contact_" . $i . "-error"])) {
             print "<p class=\"change_contact\"><a id=\"change_contact_{$i}\" href=\"\" >done</a></p>";
         } else {
             print "<p class=\"change_contact\"><a id=\"change_contact_{$i}\" href=\"\" >change...</a></p>";
         }
         print "<input type=\"hidden\" name=\"change_contact_{$i}\" value=\"";
         if ($_SESSION["error"]["contact_" . $i . "-error"]) {
             print "open\" />";
         } else {
             print "closed\" />";
         }
         print "</td>";
         //contact records table
         print "<td width=\"75%\"  align=\"right\">";
         print "<table id=\"records_table_{$i}\" class=\"records_table\">";
         if ($this->obj_form->structure["num_records_{$i}"]["defaultvalue"] > 0) {
             for ($j = 0; $j < $this->obj_form->structure["num_records_{$i}"]["defaultvalue"]; $j++) {
                 print "<tr id=\"contact_" . $i . "_record_row_" . $j . "\">";
                 //record type
                 print "<td>";
                 $this->obj_form->render_field("contact_" . $i . "_record_id_" . $j);
                 $this->obj_form->render_field("contact_" . $i . "_type_" . $j);
                 $type = $this->obj_form->structure["contact_" . $i . "_type_" . $j]["defaultvalue"];
                 if ($type == "phone") {
                     print "<b>P</b>";
                 } elseif ($type == "fax") {
                     print "<b>F</b>";
                 } elseif ($type == "mobile") {
                     print "<b>M</b>";
                 } elseif ($type == "email") {
                     print "<b>E</b>";
                 }
                 print "</td>";
                 //record label
                 print "<td>";
                 $this->obj_form->render_field("contact_" . $i . "_label_" . $j);
                 print $this->obj_form->structure["contact_" . $i . "_label_" . $j]["defaultvalue"];
                 print "</td>";
                 //record detail
                 print "<td>";
                 $this->obj_form->render_field("contact_" . $i . "_detail_" . $j);
                 print "</td>";
                 //delete record link
                 print "<td class=\"delete_record\">";
                 $this->obj_form->render_field("contact_" . $i . "_delete_" . $j);
                 print "<a id=\"contact_" . $i . "_delete_" . $j . "\" href=\"\">delete</a>";
                 print "</td>";
                 print "</tr>";
             }
         }
         print "</table>";
         print "<br />";
         //add record form
         print "<div class=\"add_record\">";
         print "<div id=\"add_record_link_{$i}\"><a id=\"add_record_{$i}\" href=\"\">Add Record</a></div>";
         print "<div class=\"add_record_form\" id=\"add_record_form_{$i}\">";
         print "<table class=\"add_record_table\">";
         print "<tr>";
         print "<td colspan=2><b>Add Record</b></td>";
         print "</tr><tr>";
         print "<td>Record Type</td>";
         print "<td><select name=\"new_record_type_{$i}\">";
         print "<option value=\"phone\">Phone</option>";
         print "<option value=\"fax\">Fax</option>";
         print "<option value=\"mobile\">Mobile</option>";
         print "<option value=\"email\">Email</option>";
         print "</select></td>";
         print "</tr><tr>";
         print "<td>Label</td>";
         print "<td><input name=\"new_record_label_{$i}\" /></td>";
         print "</tr><tr>";
         print "<td>Detail</td>";
         print "<td><input name=\"new_record_detail_{$i}\" /></td>";
         print "</tr><tr>";
         print "<td colspan=2 class=\"insert_new_record\"><a class=\"disabled_link button_small\" id=\"insert_record_{$i}\" href=\"\">Insert</a></td></tr>";
         print "</table>";
         print "</div>";
         print "</div>";
         print "</td>";
         print "</tr>";
         print "</table>";
         print "</td>";
         print "</tr>";
     }
     print "<tr id=\"add_new_contact_row\">";
     print "<td>";
     print "<div class=\"add_contact_div\"><a href=\"\" id=\"add_new_contact\">Add New Contact</a></div>";
     print "</td>";
     print "</tr>";
     print "</table>";
     print "<br />";
     //customer taxes
     print "<table class=\"form_table\" width=\"100%\">";
     print "<tr class=\"header\">";
     print "<td colspan=\"2\"><b>" . lang_trans("customer_taxes") . "</b></td>";
     print "</tr>";
     $this->obj_form->render_row("tax_number");
     $this->obj_form->render_row("tax_default");
     $this->obj_form->render_row("tax_message");
     for ($i = 0; $i < count($this->tax_array); $i++) {
         $this->obj_form->render_row($this->tax_array[$i]);
     }
     print "</table>";
     print "<br />";
     //customer purchase
     print "<table class=\"form_table\" width=\"100%\">";
     print "<tr class=\"header\">";
     print "<td colspan=\"2\"><b>" . lang_trans("customer_purchase") . "</b></td>";
     print "</tr>";
     $this->obj_form->render_row("discount");
     print "</table>";
     print "<br />";
     //billing address
     print "<table class=\"form_table\" width=\"100%\">";
     print "<tr class=\"header\">";
     print "<td colspan=\"2\"><b>" . lang_trans("address_billing") . "</b></td>";
     print "</tr>";
     $this->obj_form->render_row("address1_street");
     $this->obj_form->render_row("address1_city");
     $this->obj_form->render_row("address1_state");
     $this->obj_form->render_row("address1_country");
     $this->obj_form->render_row("address1_zipcode");
     print "</table>";
     print "<br />";
     //shipping address
     print "<table class=\"form_table\" width=\"100%\">";
     print "<tr class=\"header\">";
     print "<td colspan=\"2\"><b>" . lang_trans("address_shipping") . "</b></td>";
     print "</tr>";
     $this->obj_form->render_row("address1_same_as_2");
     $this->obj_form->render_row("address2_street");
     $this->obj_form->render_row("address2_city");
     $this->obj_form->render_row("address2_state");
     $this->obj_form->render_row("address2_country");
     $this->obj_form->render_row("address2_zipcode");
     print "</table>";
     print "<br />";
     //billing options
     print "<table class=\"form_table\" width=\"100%\">";
     print "<tr class=\"header\">";
     print "<td colspan=\"2\"><b>" . lang_trans("billing_options") . "</b></td>";
     print "</tr>";
     $this->obj_form->render_row("billing_method");
     $this->obj_form->render_row("billing_direct_debit");
     print "</table>";
     print "<br />";
     //reseller options
     print "<table class=\"form_table\" width=\"100%\">";
     print "<tr class=\"header\">";
     print "<td colspan=\"2\"><b>" . lang_trans("reseller_options") . "</b></td>";
     print "</tr>";
     $this->obj_form->render_row("reseller_customer");
     $this->obj_form->render_row("reseller_id");
     $this->obj_form->render_row("reseller_message");
     print "</table>";
     print "<br />";
     if (user_permissions_get("customers_write")) {
         print "<table class=\"form_table\" width=\"100%\">";
         print "<tr class=\"header\">";
         print "<td colspan=\"2\"><b>" . lang_trans("submit") . "</b></td>";
         print "</tr>";
         $this->obj_form->render_row("submit");
         print "</table>";
     } else {
         format_msgbox("locked", "<p>Sorry, you do not have permission to edit this customer</p>");
     }
     $this->obj_form->render_field("id_customer");
     $this->obj_form->render_field("num_contacts");
     print "</form>";
 }
예제 #26
0
 function execute()
 {
     // establish a new table object
     $this->obj_table = new table();
     $this->obj_table->language = $_SESSION["user"]["lang"];
     $this->obj_table->tablename = "name_servers";
     // define all the columns and structure
     $this->obj_table->add_column("bool_tick", "server_primary", "");
     $this->obj_table->add_column("bool_tick", "server_record", "");
     $this->obj_table->add_column("standard", "server_name", "");
     $this->obj_table->add_column("standard", "server_group", "name_servers_groups.group_name");
     $this->obj_table->add_column("standard", "server_description", "");
     $this->obj_table->add_column("standard", "server_type", "");
     $this->obj_table->add_column("standard", "sync_status_zones", "NONE");
     $this->obj_table->add_column("standard", "sync_status_log", "NONE");
     // defaults
     $this->obj_table->columns = array("server_primary", "server_record", "server_name", "server_description", "server_group", "server_type", "sync_status_zones", "sync_status_log");
     $this->obj_table->columns_order = array("server_name");
     $this->obj_table->columns_order_options = array("server_name");
     $this->obj_table->sql_obj->prepare_sql_settable("name_servers");
     $this->obj_table->sql_obj->prepare_sql_addjoin("LEFT JOIN name_servers_groups ON name_servers_groups.id = name_servers.id_group");
     $this->obj_table->sql_obj->prepare_sql_addfield("id", "name_servers.id");
     $this->obj_table->sql_obj->prepare_sql_addfield("api_sync_config", "");
     $this->obj_table->sql_obj->prepare_sql_addfield("api_sync_log", "");
     // load data
     $this->obj_table->generate_sql();
     $this->obj_table->load_data_sql();
     // check sync status
     $sync_status_config = sql_get_singlevalue("SELECT value FROM config WHERE name='SYNC_STATUS_CONFIG'");
     for ($i = 0; $i < $this->obj_table->data_num_rows; $i++) {
         switch ($this->obj_table->data[$i]["server_type"]) {
             case "route53":
                 // check the SOA of the mapped zones against the actual zones. The Mapped SOA is only
                 // updated once a successful change has been sent to Route53.
                 $num_unsynced = sql_get_singlevalue("SELECT COUNT(id_domain) as value FROM cloud_zone_map LEFT JOIN dns_domains ON cloud_zone_map.id_domain=dns_domains.id WHERE cloud_zone_map.id_name_server='" . $this->obj_table->data[$i]["id"] . "' AND cloud_zone_map.soa_serial!=dns_domains.soa_serial");
                 if ($num_unsynced) {
                     $this->obj_table->data[$i]["sync_status_zones"] = "<span class=\"table_highlight_important\">" . lang_trans("status_unsynced") . "</span>";
                 } else {
                     $this->obj_table->data[$i]["sync_status_zones"] = "<span class=\"table_highlight_open\">" . lang_trans("status_synced") . "</span>";
                 }
                 // only route53 logs are self generated, so always show as synced.
                 $this->obj_table->data[$i]["sync_status_log"] = "<span class=\"table_highlight_open\">" . lang_trans("status_synced") . "</span>";
                 // set primary and NS record for route53 hosts
                 $this->obj_table->data[$i]["server_primary"] = 1;
                 $this->obj_table->data[$i]["server_record"] = 1;
                 break;
             case "api":
             default:
                 if ($sync_status_config != $this->obj_table->data[$i]["api_sync_config"]) {
                     $this->obj_table->data[$i]["sync_status_zones"] = "<span class=\"table_highlight_important\">" . lang_trans("status_unsynced") . "</span>";
                 } else {
                     $this->obj_table->data[$i]["sync_status_zones"] = "<span class=\"table_highlight_open\">" . lang_trans("status_synced") . "</span>";
                 }
                 if ($GLOBALS["config"]["FEATURE_LOGS_API"]) {
                     if (time() - $this->obj_table->data[$i]["api_sync_log"] > 86400) {
                         $this->obj_table->data[$i]["sync_status_log"] = "<span class=\"table_highlight_important\">" . lang_trans("status_unsynced") . "</span>";
                     } else {
                         $this->obj_table->data[$i]["sync_status_log"] = "<span class=\"table_highlight_open\">" . lang_trans("status_synced") . "</span>";
                     }
                 } else {
                     $this->obj_table->data[$i]["sync_status_log"] = "<span class=\"table_highlight_disabled\">" . lang_trans("status_disabled") . "</span>";
                 }
                 break;
         }
     }
 }
예제 #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
 }
예제 #28
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"]);
 }
예제 #29
0
 function render_html()
 {
     // heading
     print "<h3>CUSTOMER LIST</h3><br><br>";
     print "<p>List of customers with direct debit enabled and a current balance</p>";
     // load options form
     // $this->obj_table_list->render_options_form();
     // display results
     if (!count($this->obj_table_list->columns)) {
         format_msgbox("important", "<p>Please select some valid options to display.</p>");
     } else {
         if (!$this->obj_table_list->data_num_rows) {
             format_msgbox("info", "<p>You currently have no customers in your database.</p>");
         } else {
             // phases link
             //			$structure = NULL;
             //			$structure["reseller_id"]["column"]	= "id";
             //			$this->obj_table_list->add_link("customer_reseller", "customers/view.php", $structure);
             // calculate all the totals and prepare processed values
             $this->obj_table_list->render_table_prepare();
             // display header row
             print "<table class=\"table_content\" cellspacing=\"0\" width=\"100%\">";
             print "<tr>";
             foreach ($this->obj_table_list->columns as $column) {
                 print "<td class=\"header\"><b>" . $this->obj_table_list->render_columns[$column] . "</b></td>";
             }
             //placeholder for links
             print "<td class=\"header\">&nbsp;</td>";
             print "</tr>";
             // display data
             for ($i = 0; $i < $this->obj_table_list->data_num_rows; $i++) {
                 $customer_id = $this->obj_table_list->data[$i]["id"];
                 $contact_id = sql_get_singlevalue("SELECT id AS value FROM customer_contacts WHERE customer_id = '" . $customer_id . "' AND role = 'accounts' LIMIT 1");
                 print "<tr>";
                 foreach ($this->obj_table_list->columns as $columns) {
                     print "<td valign=\"top\">";
                     //contact name
                     if ($columns == "name_contact") {
                         $value = sql_get_singlevalue("SELECT contact AS value FROM customer_contacts WHERE id = '" . $contact_id . "' LIMIT 1");
                         if ($value) {
                             print $value;
                         }
                     } else {
                         if ($columns == "contact_phone") {
                             $value = sql_get_singlevalue("SELECT detail AS value FROM customer_contact_records WHERE contact_id = '" . $contact_id . "' AND type = 'phone' LIMIT 1");
                             if ($value) {
                                 print $value;
                             }
                         } else {
                             if ($columns == "contact_mobile") {
                                 $value = sql_get_singlevalue("SELECT detail AS value FROM customer_contact_records WHERE contact_id = '" . $contact_id . "' AND type= 'mobile' LIMIT 1");
                                 if ($value) {
                                     print $value;
                                 }
                             } else {
                                 if ($columns == "contact_email") {
                                     $value = sql_get_singlevalue("SELECT detail AS value FROM customer_contact_records WHERE contact_id = '" . $contact_id . "' AND type= 'email' LIMIT 1");
                                     if ($value) {
                                         print $value;
                                     }
                                 } else {
                                     if ($columns == "contact_fax") {
                                         $value = sql_get_singlevalue("SELECT detail AS value FROM customer_contact_records WHERE contact_id = '" . $contact_id . "' AND type= 'fax' LIMIT 1");
                                         if ($value) {
                                             print $value;
                                         }
                                     } else {
                                         if ($this->obj_table_list->data_render[$i][$columns]) {
                                             //								print $columns;
                                             print $this->obj_table_list->data_render[$i][$columns];
                                         } else {
                                             print "&nbsp;";
                                         }
                                     }
                                 }
                             }
                         }
                     }
                     print "</td>";
                 }
                 //links
                 print "<td align=\"right\" nowrap >";
                 print "<a class=\"button_small\" href=\"index.php?page=customers/view.php&id=" . $this->obj_table_list->data[$i]["id"] . "\">" . lang_trans("details") . "</a> ";
                 print "<a class=\"button_small\" href=\"index.php?page=customers/attributes.php&id_customer=" . $this->obj_table_list->data[$i]["id"] . "\">" . lang_trans("tbl_lnk_attributes") . "</a> ";
                 print "<a class=\"button_small\" href=\"index.php?page=customers/orders.php&id_customer=" . $this->obj_table_list->data[$i]["id"] . "\">" . lang_trans("orders") . "</a> ";
                 print "<a class=\"button_small\" href=\"index.php?page=customers/invoices.php&id=" . $this->obj_table_list->data[$i]["id"] . "\">" . lang_trans("invoices") . "</a> ";
                 print "<a class=\"button_small\" href=\"index.php?page=customers/services.php&id=" . $this->obj_table_list->data[$i]["id"] . "\">" . lang_trans("services") . "</a> ";
                 print "</td>";
                 print "</tr>";
             }
             print "</table>";
             print "<br />";
             // display CSV/PDF download link
             print "<p align=\"right\"><a class=\"button_export\" style=\"font-weight: normal;\"  href=\"index-export.php?mode=csv&page=customers/customers-billing.php\">Export as CSV</a></p>";
             print "<p align=\"right\"><a class=\"button_export\" style=\"font-weight: normal;\" href=\"index-export.php?mode=pdf&page=customers/customers-billing.php\">Export as PDF</a></p>";
         }
     }
 }
예제 #30
0
 function render_html()
 {
     // heading
     print "<h3>RESELLER CUSTOMERS LIST</h3><br>";
     print "<p>The following list of customers is made up of all customers who belong to this reseller. To add a customer to this reseller, adjust the customer's details and select the reseller they should belong to.</p>";
     /*
     	TODO: this code is a big copy and paste job from customers/customers.php, we should
     	turn it into a function so that we don't keep cloning features between the applications.
     
     	DEVELOPER IS VERY NAUGHTY AND MUST BE PUNISHED.
     */
     // load options form
     $this->obj_table_list->render_options_form();
     // display results
     if (!count($this->obj_table_list->columns)) {
         format_msgbox("important", "<p>Please select some valid options to display.</p>");
     } else {
         if (!$this->obj_table_list->data_num_rows) {
             format_msgbox("info", "<p>There are currently no customers associated to this reseller.</p>");
         } else {
             // calculate all the totals and prepare processed values
             $this->obj_table_list->render_table_prepare();
             // display header row
             print "<table class=\"table_content\" cellspacing=\"0\" width=\"100%\">";
             print "<tr>";
             foreach ($this->obj_table_list->columns as $column) {
                 print "<td class=\"header\"><b>" . $this->obj_table_list->render_columns[$column] . "</b></td>";
             }
             //placeholder for links
             print "<td class=\"header\">&nbsp;</td>";
             print "</tr>";
             // display data
             for ($i = 0; $i < $this->obj_table_list->data_num_rows; $i++) {
                 $customer_id = $this->obj_table_list->data[$i]["id"];
                 $contact_id = sql_get_singlevalue("SELECT id AS value FROM customer_contacts WHERE customer_id = '" . $customer_id . "' AND role = 'accounts' LIMIT 1");
                 print "<tr>";
                 foreach ($this->obj_table_list->columns as $columns) {
                     print "<td valign=\"top\">";
                     //contact name
                     if ($columns == "name_contact") {
                         $value = sql_get_singlevalue("SELECT contact AS value FROM customer_contacts WHERE id = '" . $contact_id . "' LIMIT 1");
                         if ($value) {
                             print $value;
                         }
                     } else {
                         if ($columns == "contact_phone") {
                             $value = sql_get_singlevalue("SELECT detail AS value FROM customer_contact_records WHERE contact_id = '" . $contact_id . "' AND type = 'phone' LIMIT 1");
                             if ($value) {
                                 print $value;
                             }
                         } else {
                             if ($columns == "contact_mobile") {
                                 $value = sql_get_singlevalue("SELECT detail AS value FROM customer_contact_records WHERE contact_id = '" . $contact_id . "' AND type= 'mobile' LIMIT 1");
                                 if ($value) {
                                     print $value;
                                 }
                             } else {
                                 if ($columns == "contact_email") {
                                     $value = sql_get_singlevalue("SELECT detail AS value FROM customer_contact_records WHERE contact_id = '" . $contact_id . "' AND type= 'email' LIMIT 1");
                                     if ($value) {
                                         print $value;
                                     }
                                 } else {
                                     if ($columns == "contact_fax") {
                                         $value = sql_get_singlevalue("SELECT detail AS value FROM customer_contact_records WHERE contact_id = '" . $contact_id . "' AND type= 'fax' LIMIT 1");
                                         if ($value) {
                                             print $value;
                                         }
                                     } else {
                                         if ($this->obj_table_list->data_render[$i][$columns]) {
                                             //								print $columns;
                                             print $this->obj_table_list->data_render[$i][$columns];
                                         } else {
                                             print "&nbsp;";
                                         }
                                     }
                                 }
                             }
                         }
                     }
                     print "</td>";
                 }
                 //links
                 print "<td align=\"right\" nowrap >";
                 print "<a class=\"button_small\" href=\"index.php?page=customers/view.php&id=" . $this->obj_table_list->data[$i]["id"] . "\">" . lang_trans("details") . "</a> ";
                 print "</td>";
                 print "</tr>";
             }
             print "</table>";
             print "<br />";
             // display CSV/PDF download link
             print "<p align=\"right\"><a class=\"button_export\" style=\"font-weight: normal;\"  href=\"index-export.php?mode=csv&page=customers/customers.php\">Export as CSV</a></p>";
             print "<p align=\"right\"><a class=\"button_export\" style=\"font-weight: normal;\" href=\"index-export.php?mode=pdf&page=customers/customers.php\">Export as PDF</a></p>";
         }
     }
 }