function getExtensionsVegaForm($smarty, $module_name, $local_templates_dir, $dsnAsterisk, $dsnSqlite, $arrConf, $validationError) { $paloEndPoint = new paloSantoEndPoint($dsnAsterisk, $dsnSqlite); $arrSession = getSession(); $mac = $arrSession["endpoint_configurator"]["mac"]; if (!$validationError) { $arrParameters = $paloEndPoint->getEndpointParameters($mac); if ($arrParameters === false) { $smarty->assign("mb_title", _tr("ERROR")); $smarty->assign("mb_message", _tr("In the query to database endpoint.db")); return endpointConfiguratedShow($smarty, $module_name, $local_templates_dir, $dsnAsterisk, $dsnSqlite, $arrConf); } $_DATA = array(); foreach ($arrParameters as $key => $parameter) { $_DATA[$parameter["name"]] = $parameter["value"]; } $_DATA = array_merge($_DATA, $_POST); $arrCountry = $paloEndPoint->getCountries(); if ($arrCountry === false) { $smarty->assign("mb_title", _tr("ERROR")); $smarty->assign("mb_message", _tr("In the query to database endpoint.db")); return endpointConfiguratedShow($smarty, $module_name, $local_templates_dir, $dsnAsterisk, $dsnSqlite, $arrConf); } foreach ($arrCountry as $country) { $arrComboCountry[$country["id"]] = _tr($country["country"]); } asort($arrComboCountry); $arrFormData = createFieldFormData($arrComboCountry); $oForm = new paloForm($smarty, $arrFormData); //************TODO: FALTAN MAS VALIDACIONES*************************** if (!$oForm->validateForm($_POST)) { // Falla la validación básica del formulario $strErrorMsg = "<b>" . _tr('The following fields contain errors') . ":</b><br/>"; $arrErrores = $oForm->arrErroresValidacion; if (is_array($arrErrores) && count($arrErrores) > 0) { foreach ($arrErrores as $k => $v) { $strErrorMsg .= "{$k}: [{$v['mensaje']}] <br /> "; } } $smarty->assign("mb_title", _tr("Validation Error")); $smarty->assign("mb_message", $strErrorMsg); return getVegaData($smarty, $module_name, $local_templates_dir, $dsnAsterisk, $dsnSqlite, $arrConf); } elseif (!$paloEndPoint->countryExists(getParameter("country"))) { $smarty->assign("mb_title", _tr("Validation Error")); $smarty->assign("mb_message", _tr("The selected country is not in the list")); return getVegaData($smarty, $module_name, $local_templates_dir, $dsnAsterisk, $dsnSqlite, $arrConf); } elseif ((int) getParameter("analog_trunk_lines") < 0 || (int) getParameter("analog_trunk_lines") > 32 || (int) getParameter("analog_extension_lines") < 0 || (int) getParameter("analog_extension_lines") > 32) { $smarty->assign("mb_title", _tr("Validation Error")); $smarty->assign("mb_message", _tr("The number of analog trunk lines and the number of analog extension lines must be greater than 0 but less than 32")); return getVegaData($smarty, $module_name, $local_templates_dir, $dsnAsterisk, $dsnSqlite, $arrConf); } elseif (getParameter("router_present") != "no" && getParameter("router_present") != "yes") { $smarty->assign("mb_title", _tr("Validation Error")); $smarty->assign("mb_message", _tr("Invalid option for field router present (2 Ethernet)")); return getVegaData($smarty, $module_name, $local_templates_dir, $dsnAsterisk, $dsnSqlite, $arrConf); } elseif (getParameter("pbx_side") != "lan" && getParameter("pbx_side") != "wan") { $smarty->assign("mb_title", _tr("Validation Error")); $smarty->assign("mb_message", _tr("Invalid option for field in which side is the IP PBX")); return getVegaData($smarty, $module_name, $local_templates_dir, $dsnAsterisk, $dsnSqlite, $arrConf); } elseif (getParameter("telnet_username") == getParameter("telnet_password")) { $smarty->assign("mb_title", _tr("Validation Error")); $smarty->assign("mb_message", _tr("Password NOT allowed to be the same as the username")); return getVegaData($smarty, $module_name, $local_templates_dir, $dsnAsterisk, $dsnSqlite, $arrConf); } elseif (getParameter("option_network_lan") == "lan_static" && (getParameter("lan_ip_address") == "" || getParameter("lan_ip_mask") == "")) { $smarty->assign("mb_title", _tr("Validation Error")); $smarty->assign("mb_message", "LAN: " . _tr("For static ip configuration you have to enter an ip address and a mask")); return getVegaData($smarty, $module_name, $local_templates_dir, $dsnAsterisk, $dsnSqlite, $arrConf); } elseif (getParameter("router_present") == "yes" && getParameter("option_network_wan") == "wan_static" && (getParameter("wan_ip_address") == "" || getParameter("wan_ip_mask") == "")) { $smarty->assign("mb_title", _tr("Validation Error")); $smarty->assign("mb_message", "WAN: " . _tr("For static ip configuration you have to enter an ip address and a mask")); return getVegaData($smarty, $module_name, $local_templates_dir, $dsnAsterisk, $dsnSqlite, $arrConf); } elseif ((int) getParameter("increment") < 1 || (int) getParameter("increment") > 10) { $smarty->assign("mb_title", _tr("Validation Error")); $smarty->assign("mb_message", _tr("The increment must be a number from 1 to 10")); return getVegaData($smarty, $module_name, $local_templates_dir, $dsnAsterisk, $dsnSqlite, $arrConf); } elseif (getParameter("option_network_lan") != "lan_static" && getParameter("option_network_lan") != "lan_dhcp" || getParameter("option_network_wan") != "wan_static" && getParameter("option_network_wan") != "wan_dhcp") { $smarty->assign("mb_title", _tr("Validation Error")); $smarty->assign("mb_message", _tr("The options for networks LAN and WAN can only be static or DHCP")); return getVegaData($smarty, $module_name, $local_templates_dir, $dsnAsterisk, $dsnSqlite, $arrConf); } elseif (getParameter("option_network_lan") == "lan_static" && (getParameter("lan_ip_address") == "" || getParameter("lan_ip_mask") == "")) { $smarty->assign("mb_title", _tr("Validation Error")); $smarty->assign("mb_message", "LAN: " . _tr("For static ip configuration you have to enter an ip address and a mask")); return getVegaData($smarty, $module_name, $local_templates_dir, $dsnAsterisk, $dsnSqlite, $arrConf); } //**************************FIN DE VALIDACIONES***************************** $arrSession["endpoint_configurator"]["telnet_username"] = getParameter("telnet_username"); $arrSession["endpoint_configurator"]["telnet_password"] = getParameter("telnet_password"); $arrSession["endpoint_configurator"]["analog_extension_lines"] = getParameter("analog_extension_lines"); $arrSession["endpoint_configurator"]["analog_trunk_lines"] = getParameter("analog_trunk_lines"); $arrSession["endpoint_configurator"]["router_present"] = getParameter("router_present"); $arrSession["endpoint_configurator"]["pbx_side"] = getParameter("pbx_side"); // $arrSession["endpoint_configurator"]["sntp_address"] = getParameter("sntp_address"); $arrSession["endpoint_configurator"]["dns_address"] = getParameter("dns_address"); if (getParameter("option_network_lan") == "lan_static") { $arrSession["endpoint_configurator"]["lan_type"] = "static"; $arrSession["endpoint_configurator"]["lan_ip_address"] = getParameter("lan_ip_address"); $arrSession["endpoint_configurator"]["lan_ip_mask"] = getParameter("lan_ip_mask"); } else { $arrSession["endpoint_configurator"]["lan_type"] = "dhcp"; } if (getParameter("option_network_wan") == "wan_static") { $arrSession["endpoint_configurator"]["wan_type"] = "static"; $arrSession["endpoint_configurator"]["wan_ip_address"] = getParameter("wan_ip_address"); $arrSession["endpoint_configurator"]["wan_ip_mask"] = getParameter("wan_ip_mask"); } else { $arrSession["endpoint_configurator"]["wan_type"] = "dhcp"; } $arrSession["endpoint_configurator"]["default_gateway"] = getParameter("default_gateway"); $arrSession["endpoint_configurator"]["pbx_address"] = getParameter("pbx_address"); $arrSession["endpoint_configurator"]["sip_port"] = getParameter("sip_port"); $arrSession["endpoint_configurator"]["country"] = getParameter("country"); $arrSession["endpoint_configurator"]["first_extension_vega"] = getParameter("first_extension_vega"); $arrSession["endpoint_configurator"]["increment"] = getParameter("increment"); $arrSession["endpoint_configurator"]["registration"] = getParameter("registration"); $arrSession["endpoint_configurator"]["registration_password"] = getParameter("registration_password"); // $arrSession["endpoint_configurator"]["extensions_sip_port"] = getParameter("extensions_sip_port"); // $arrSession["endpoint_configurator"]["lines_sip_port"] = getParameter("lines_sip_port"); /* $arrSession["endpoint_configurator"]["timeout"] = getParameter("timeout"); $arrSession["endpoint_configurator"]["delivery_announcements"] = getParameter("delivery_announcements"); $arrSession["endpoint_configurator"]["wait_callerID"] = getParameter("wait_callerID"); $arrSession["endpoint_configurator"]["callerID_format"] = getParameter("callerID_format"); $arrSession["endpoint_configurator"]["callerID_presentation"] = getParameter("callerID_presentation");*/ putSession($arrSession); } else { $_DATA = $_POST; if (isset($arrSession["endpoint_configurator"]) && is_array($arrSession["endpoint_configurator"])) { $_DATA = array_merge($_DATA, $arrSession["endpoint_configurator"]); } } if ($arrSession["endpoint_configurator"]["analog_extension_lines"] > 0) { $smarty->assign("REQUIRED_FIELD", _tr("Required field")); $smarty->assign("CANCEL", _tr("Cancel")); $smarty->assign("RETURN", _tr("Return")); $smarty->assign("IMG", "/modules/{$module_name}/images/sangoma.gif"); if ($arrSession["endpoint_configurator"]["analog_trunk_lines"] == 0) { $smarty->assign("NEXT", _tr("Save")); $smarty->assign("NEXT2", "save_vega"); } else { $smarty->assign("NEXT", _tr("Next")); $smarty->assign("NEXT2", "next_2_vega"); } $fields = ""; $model = $arrSession["endpoint_model"][$arrSession["endpoint_configurator"]["mac"]]; $title = _tr("Extensions Configuration for Vega (FXS)"); $fields .= "<tr align='center' style='font-size:14px; font-weight:bold; '><td>" . _tr("Port ID") . "</td><td>" . _tr("Enabled") . "<br><input type='checkbox' name='checkall' class='checkall'/> </td><td>" . _tr("Caller ID") . "</td><td>" . _tr("Call Conference") . "</td><td>" . _tr("Call Transfer") . "</td><td>" . _tr("Call Waiting") . "</td><td>" . _tr("Do Not Disturbe Enable") . "</td><td>" . _tr("Interface") . "</td><td>" . _tr("DN") . "</td><td>" . _tr("Username") . "</td> </tr>"; $comboOnOff = array("on" => _tr("On"), "off" => _tr("Off")); $comboCallerId = array("on" => _tr("On"), "off" => _tr("Off"), "cidcw" => _tr("cidcw")); $check = ""; for ($i = 0; $i < $arrSession["endpoint_configurator"]["analog_extension_lines"]; $i++) { $extension = $arrSession["endpoint_configurator"]["first_extension_vega"] + $i * $arrSession["endpoint_configurator"]["increment"]; if (!isset($_DATA["user{$i}"])) { $_DATA["user{$i}"] = $extension; } if (!isset($_DATA["authentication_user{$i}"])) { $_DATA["authentication_user{$i}"] = $extension; } if (!isset($_DATA["user_name{$i}"])) { $_DATA["user_name{$i}"] = $extension; } $number = $i + 1; if (isset($_DATA["enable{$i}"]) && $_DATA["enable{$i}"] == 1) { $check = "checked=checked"; } else { $check = ""; } $fields .= "<tr class='letra12' align='center'>\n <td width='5%' align='center'><b>{$number}</b></td>\n <td class='enable'><input type='checkbox' name='enable{$i}' {$check}/></td>\n <td><select name='caller_id{$i}'>" . combo($comboCallerId, $_DATA["caller_id{$i}"]) . "</select></td>\n <td><select name='call_conference{$i}'>" . combo($comboOnOff, $_DATA["call_conference{$i}"]) . "</select></td>\n <td><select name='call_transfer{$i}'>" . combo($comboOnOff, $_DATA["call_transfer{$i}"]) . "</select></td>\n <td><select name='call_waiting{$i}'>" . combo($comboOnOff, $_DATA["call_waiting{$i}"]) . "</select></td>\n <td width='5%'><select name='call_dnd{$i}'>" . combo($comboOnOff, $_DATA["call_dnd{$i}"]) . "</select></td>\n <td><input type='text' maxlength='40' style='width: 100px;' value='" . $_DATA["user_name{$i}"] . "' name='user_name{$i}'></td>\n <td><input type='text' maxlength='40' style='width: 100px;' value='" . $_DATA["user{$i}"] . "' name='user{$i}'></td>\n <td><input type='text' maxlength='40' style='width: 100px;' value='FXS{$number}' name='authentication_user{$i}'></td>\n </tr>"; /* $fields .= "<tr class='letra12'> <td width='5%'><b>"._tr("Extension")." $number:</b></td> <td width='5%'>$extension</td> <td><input type='checkbox'name='chkext$i' /></td> <td><b>"._tr("User Name")." $number:</b></td> <td><input type='text' maxlength='100' style='width: 200px;' value='".$_DATA["user_name$i"]."' name='user_name$i'></td> <td><b>"._tr("User")." $number:</b> <span class='required'>*</span></td> <td><input type='text' maxlength='100' style='width: 200px;' value='".$_DATA["user$i"]."' name='user$i'></td> <td><b>"._tr("Authentication User")." $number:</b> <span class='required'>*</span></td> <td><input type='text' maxlength='100' style='width: 200px;' value='".$_DATA["authentication_user$i"]."' name='authentication_user$i'></td> </tr>";*/ } $smarty->assign("fields", $fields); $oForm = new paloForm($smarty, array()); $htmlForm = $oForm->fetchForm("{$local_templates_dir}/vega_extensions.tpl", $title, $_DATA); $content = "<form method='POST' style='margin-bottom:0;' action='?menu={$module_name}'>" . $htmlForm . "</form>"; } else { $content = getLinesVegaForm($smarty, $module_name, $local_templates_dir, $dsnAsterisk, $dsnSqlite, $arrConf, false); } return $content; }