function row($k) { ?> <div class="row"> <?php for ($i = 0; $i <= $k; $i++) { print combo($k, $i) . " "; } ?> </div> <?php }
function listarColas($pDB, $smarty, $module_name, $local_templates_dir) { require_once "libs/paloSantoGrid.class.php"; global $arrLang; $oColas = new paloSantoColaEntrante($pDB); // Verificar si alguna cola debe activarse o inactivarse if (!is_null($id = getParameter('id'))) { if (!is_null(getParameter('activate'))) { $bExito = $oColas->cambiarMonitoreoCola($id, 'A'); } elseif (!is_null(getParameter('deactivate'))) { $bExito = $oColas->cambiarMonitoreoCola($id, 'I'); } if (!$bExito) { $smarty->assign("mb_title", _tr('Unable to change activation')); $smarty->assign("mb_message", $oColas->errMsg); } } // Estado indicado por el filtro $sEstado = getParameter('estatus'); if (is_null($sEstado)) { $sEstado = 'A'; } if (!in_array($sEstado, array('', 'A', 'I'))) { $sEstado = 'A'; } if ($sEstado == '') { $sEstado = NULL; } // Consulta de las colas $arrDataQueues = $oColas->leerColas(NULL, $sEstado); if (!is_array($arrDataQueues)) { $smarty->assign("mb_title", _tr('Unable to read queues')); $smarty->assign("mb_message", _tr('Cannot read queues') . ' - ' . $oColas->errMsg); $arrDataQueues = array(); } // Construcción del reporte $end = count($arrDataQueues); $url = construirUrl(array('menu' => $module_name), array('nav', 'start')); $arrGrid = array("title" => _tr('Queue List'), 'url' => $url, "icon" => "images/list.png", "width" => "99%", "start" => $end == 0 ? 0 : 1, "end" => $end, "total" => $end, "columns" => array(array("name" => "<input class=\"button\" type=\"submit\" name=\"activate\" value=\"" . _tr('Activate') . "\" />" . "<input class=\"button\" type=\"submit\" name=\"deactivate\" value=\"" . _tr('Deactivate') . "\" />"), array("name" => _tr('Name Queue')), array("name" => _tr('Status')), array("name" => _tr('Options')))); $oGrid = new paloSantoGrid($smarty); $arrData = array(); foreach ($arrDataQueues as $tuplaQueue) { $arrData[] = array("<input type=\"radio\" name=\"id\" value=\"{$tuplaQueue['id']}\" />", $tuplaQueue['queue'], $tuplaQueue['estatus'] == 'A' ? _tr('Active') : _tr('Inactive'), "<a href=\"?menu={$module_name}&action=edit_queue&id_queue={$tuplaQueue['id']}\">[" . htmlentities(_tr('Edit'), ENT_COMPAT, 'UTF-8') . "]</a>"); } $oGrid->showFilter('<table width="100%" border="0"><tr>' . '<td align="right"><b>' . _tr('Status') . '</b></td>' . '<td align="left"><select name="estatus" onchange="submit();">' . combo(array('' => _tr('all'), 'A' => _tr('active'), 'I' => _tr('inactive')), $sEstado) . '</select></td>' . '<td align="right"><b><a href="?menu=' . $module_name . '&action=new_queue">' . _tr('Select Queue') . ' »</a></b></td>' . '</tr></table>'); $sContenido = $oGrid->fetchGrid($arrGrid, $arrData, $arrLang); if (strpos($sContenido, '<form') === FALSE) { $sContenido = "<form method=\"POST\" style=\"margin-bottom:0;\" action=\"{$url}\">{$sContenido}</form>"; } return $sContenido; }
<?php $table = $_POST['table']; $fields = $table::$fields; function combo($table) { $list = $table::SELECT('1 ORDER BY id'); $result = array(); foreach ($list as &$l) { $result[$l->ID()] = $l->toString(); } return $result; } foreach ($fields as $F => &$f) { if (!$f['native']) { $f['combo'] = combo($f['type']); } $f['name'] = $F; } function rows($table) { $rows = $table::SELECT('1 ORDER BY id'); $fields = $table::$fields; $result = array(); foreach ($rows as &$r) { $row = array(); $row['id'] = $r->ID(); foreach ($fields as $F => $f) { $method = 'get' . $F; if ($f['native']) { $row[$F] = $r->{$method}();
function listadoForm($pDB, $smarty, $module_name, $local_templates_dir) { global $arrLang; $oDataForm = new paloSantoDataForm($pDB); // preguntando por el estado del filtro if (!isset($_POST['cbo_estado']) || $_POST['cbo_estado'] == "") { $_POST['cbo_estado'] = "A"; } $arrDataForm = $oDataForm->getFormularios(NULL, $_POST['cbo_estado']); $end = count($arrDataForm); $arrData = array(); if (is_array($arrDataForm)) { foreach ($arrDataForm as $DataForm) { $arrTmp = array(); $arrTmp[0] = $DataForm['nombre']; if (!isset($DataForm['descripcion']) || $DataForm['descripcion'] == "") { $DataForm['descripcion'] = " "; } $arrTmp[1] = $DataForm['descripcion']; if ($DataForm['estatus'] == 'I') { $arrTmp[2] = _tr('Inactive'); $arrTmp[3] = " <a href='?menu={$module_name}&action=preview&id=" . $DataForm['id'] . "'>" . _tr('Preview') . "</a>"; } else { $arrTmp[2] = _tr('Active'); $arrTmp[3] = " <a href='?menu={$module_name}&action=preview&id=" . $DataForm['id'] . "'>" . _tr('Preview') . "</a>"; } $arrData[] = $arrTmp; } } $url = construirUrl(array('menu' => $module_name), array('nav', 'start')); $arrGrid = array("title" => _tr("Form List"), "url" => $url, "icon" => "images/list.png", "width" => "99%", "start" => $end == 0 ? 0 : 1, "end" => $end, "total" => $end, "columns" => array(0 => array("name" => _tr("Form Name"), "property1" => ""), 1 => array("name" => _tr("Form Description"), "property1" => ""), 2 => array("name" => _tr("Status"), "property1" => ""), 3 => array("name" => _tr("Options"), "property1" => ""))); $estados = array("all" => _tr("All"), "A" => _tr("Active"), "I" => _tr("Inactive")); $combo_estados = "<select name='cbo_estado' id='cbo_estado' onChange='submit();'>" . combo($estados, $_POST['cbo_estado']) . "</select>"; $oGrid = new paloSantoGrid($smarty); $oGrid->showFilter("<table width='100%' border='0'><tr>" . "<td>" . _tr("Forms") . "</td>" . "<td class='letra12' align='right'><b>" . _tr("Status") . ":</b> {$combo_estados}</td>" . "</tr></table>"); $sContenido = $oGrid->fetchGrid($arrGrid, $arrData, $arrLang); if (strpos($sContenido, '<form') === FALSE) { $sContenido = "<form method=\"POST\" style=\"margin-bottom:0;\" action=\"{$url}\">{$sContenido}</form>"; } return $sContenido; }
break; case 'recopilar': $respuestas = $_POST["respuestas"]; $idEncuesta = $_POST["hfIdEncuesta"]; $idRespuesta = $_POST["hfidRespuesta"]; $identificador = $_POST["hfIde"]; $recopilador = $_POST["hfRecopilador"]; $codigoPers = $_POST["hfCodigoPers"]; //print_r($_POST); $rta = contestarEncuesta($idEncuesta, $idRespuesta, $respuestas, $identificador, $recopilador, $codigoPers); break; case 'combo': $usuario = $oLogin->getIdUsuario(); $default = $_POST['vdefaul']; $selected = $_POST["selected"]; $rta = combo($default, $selected, $usuario); break; case 'nuevaCopia': $usuario = $oLogin->getIdUsuario(); $titulo = $_POST["txtTituloCopia"]; $idEncuesta = $_POST['cbMisEnc']; $rta = copiarEncuesta($idEncuesta, $titulo, $usuario); break; case 'publicar': $usuario = $oLogin->getIdUsuario(); $idEncuesta = $_POST['idEncuesta']; $fechaIni = $_POST['txtFcIni']; $fechaFin = $_POST['txtFcFin']; $recolectores = $_POST['ckRecolector']; $codigoWeb = $_POST['hfCodigoWeb']; $enlaceWeb = $_POST['txtEnlaceWeb'];
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; }
<a class="red" style="font-size:1.4em"> <i class="glyphicon glyphicon-minus-sign"></i></a> <a class="green" style="font-size:1.4em" onclick="agregarOpcionOM1()"><i class="glyphicon glyphicon-plus-sign"></i></a> </div> </div>'; return $salida; } if ($_POST) { $rta = ""; try { $oper = $_POST['oper']; switch ($oper) { case 'combo': $default = $_POST['vdefaul']; $selected = $_POST["selected"]; $rta = combo($default, $selected); break; case 'NuevaPregunta': $tipo = $_POST['tipo']; $Nro = $_POST['Nro']; switch ($tipo) { case '1': $rta = formTipoPregOM1($Nro); break; } break; } } catch (Exception $e) { echo "<div class='form-group has-error col-md-10'>\r\n <input type='text' class='form-control' id='error2' value='Error ejecutar la operación'>\r\n </div>"; exit; }
function listadoHoldTime($pDB, $smarty, $module_name, $local_templates_dir, &$oGrid, &$arrGrid, &$arrData) { $arrData = array(); $oCalls = new paloSantoHoldTime($pDB); $fecha_init = date("d M Y"); $fecha_end = date("d M Y"); // preguntamos por el TIPO del filtro (Entrante/Saliente) if (!isset($_POST['cbo_tipos']) || $_POST['cbo_tipos'] == "") { $_POST['cbo_tipos'] = "E"; //por defecto las consultas seran de Llamadas Entrantes } $tipo = 'E'; $entrantes = 'T'; $salientes = 'T'; if (isset($_POST['cbo_tipos'])) { $tipo = $_POST['cbo_tipos']; } if (isset($_POST['cbo_estado_entrantes'])) { $entrantes = $_POST['cbo_estado_entrantes']; } if (isset($_POST['cbo_estado_salientes'])) { $salientes = $_POST['cbo_estado_salientes']; } //validamos la fecha if (isset($_POST['txt_fecha_init']) && isset($_POST['txt_fecha_end'])) { $fecha_init_actual = $_POST['txt_fecha_init']; $fecha_end_actual = $_POST['txt_fecha_end']; } elseif (isset($_GET['txt_fecha_init']) && isset($_GET['txt_fecha_end'])) { $fecha_init_actual = $_GET['txt_fecha_init']; $fecha_end_actual = $_GET['txt_fecha_end']; } else { $fecha_init_actual = $fecha_init; $fecha_end_actual = $fecha_end; } $sValidacion = "^[[:digit:]]{1,2}[[:space:]]+[[:alnum:]]{3}[[:space:]]+[[:digit:]]{4}\$"; if (isset($_POST['submit_fecha']) || isset($_POST['cbo_tipos'])) { // si se ha presionado el boton pregunto si hay una fecha de inicio elegida if (isset($_POST['txt_fecha_init']) && $_POST['txt_fecha_init'] != "" && isset($_POST['txt_fecha_end']) && $_POST['txt_fecha_end'] != "") { // sihay una fecha de inicio pregunto si es valido el formato de la fecha if (ereg($sValidacion, $_POST['txt_fecha_init'])) { // si el formato es valido procedo a convertir la fecha en un arreglo que contiene // el anio , mes y dia seleccionados $fecha_init = $fecha_init_actual; //$_POST['txt_fecha_init']; $arrFecha_init = explode('-', translateDate($fecha_init)); } else { // si la fecha esta en un formato no valido se envia un mensaje de error $smarty->assign("mb_title", _tr("Error")); $smarty->assign("mb_message", _tr("Debe ingresar una fecha valida")); } // pregunto si es valido el formato de la fecha final if (ereg($sValidacion, $_POST['txt_fecha_end'])) { // si el formato es valido procedo a convertir la fecha en un arreglo que contiene // el anio , mes y dia seleccionados $fecha_end = $fecha_end_actual; //$_POST['txt_fecha_end']; $arrFecha_end = explode('-', translateDate($fecha_end)); } else { // si la fecha esta en un formato no valido se envia un mensaje de error $smarty->assign("mb_title", _tr("Error")); $smarty->assign("mb_message", _tr("Debe ingresar una fecha valida")); } //PRUEBA $arrFilterExtraVars = array("cbo_tipos" => $tipo, "cbo_estado_entrantes" => $entrantes, "cbo_estado_salientes" => $salientes, "txt_fecha_init" => $_POST['txt_fecha_init'], "txt_fecha_end" => $_POST['txt_fecha_end']); //PRUEBA } elseif (isset($_GET['txt_fecha_init']) && $_GET['txt_fecha_init'] != "" && isset($_GET['txt_fecha_end']) && $_GET['txt_fecha_end'] != "") { if (ereg($sValidacion, $_GET['txt_fecha_init'])) { // si el formato es valido procedo a convertir la fecha en un arreglo que contiene // el anio , mes y dia seleccionados $fecha_init = $fecha_init_actual; //$_POST['txt_fecha_init']; $arrFecha_init = explode('-', translateDate($fecha_init)); } else { // si la fecha esta en un formato no valido se envia un mensaje de error $smarty->assign("mb_title", _tr("Error")); $smarty->assign("mb_message", _tr("Debe ingresar una fecha valida")); } // pregunto si es valido el formato de la fecha final if (ereg($sValidacion, $_GET['txt_fecha_end'])) { // si el formato es valido procedo a convertir la fecha en un arreglo que contiene // el anio , mes y dia seleccionados $fecha_end = $fecha_end_actual; //$_POST['txt_fecha_end']; $arrFecha_end = explode('-', translateDate($fecha_end)); } else { // si la fecha esta en un formato no valido se envia un mensaje de error $smarty->assign("mb_title", _tr("Error")); $smarty->assign("mb_message", _tr("Debe ingresar una fecha valida")); } $tipo = $_GET['cbo_tipos']; $entrantes = $_GET['cbo_estado_entrantes']; $salientes = $_GET['cbo_estado_salientes']; $arrFilterExtraVars = array("cbo_tipos" => $_GET['cbo_tipos'], "cbo_estado_entrantes" => $_GET['cbo_estado_entrantes'], "cbo_estado_salientes" => $_GET['cbo_estado_salientes'], "txt_fecha_init" => $_GET['txt_fecha_init'], "txt_fecha_end" => $_GET['txt_fecha_end']); } elseif (!isset($fecha_init) && !isset($fecha_end)) { // si se ha presionado el boton para listar por fechas, y no se ha ingresado una fecha // se le muestra al usuario un mensaje de error $smarty->assign("mb_title", _tr("Error")); $smarty->assign("mb_message", _tr("Debe ingresar una fecha inicio/fin")); } } $bElastixNuevo = method_exists('paloSantoGrid', 'setURL'); $bExportando = $bElastixNuevo ? $oGrid->isExportAction() : isset($_GET['exportcsv']) && $_GET['exportcsv'] == 'yes' || isset($_GET['exportspreadsheet']) && $_GET['exportspreadsheet'] == 'yes' || isset($_GET['exportpdf']) && $_GET['exportpdf'] == 'yes'; //para el pagineo // LISTADO $limit = 50; $offset = 0; //numero de registros $arrCallsTmp = $oCalls->getHoldTime($tipo, $entrantes, $salientes, translateDate($fecha_init), translateDate($fecha_end), $limit, $offset); $totalCalls = $arrCallsTmp['NumRecords']; if ($bElastixNuevo) { $oGrid->setLimit($limit); $oGrid->setTotal($totalCalls); $offset = $oGrid->calculateOffset(); } else { // Si se quiere avanzar a la sgte. pagina if (isset($_GET['nav']) && $_GET['nav'] == "end") { // Mejorar el sgte. bloque. if ($totalCalls % $limit == 0) { $offset = $totalCalls - $limit; } else { $offset = $totalCalls - $totalCalls % $limit; } } // Si se quiere avanzar a la sgte. pagina if (isset($_GET['nav']) && $_GET['nav'] == "next") { $offset = $_GET['start'] + $limit - 1; } // Si se quiere retroceder if (isset($_GET['nav']) && $_GET['nav'] == "previous") { $offset = $_GET['start'] - $limit - 1; } } // Construyo el URL base $url = array('menu' => $module_name); if (isset($arrFilterExtraVars) && is_array($arrFilterExtraVars) && count($arrFilterExtraVars) > 0) { $url = array_merge($url, $arrFilterExtraVars); } //fin de pagineo //llamamos a la función que hace la consulta a la base según los criterios de búsqueda $arrCalls = $oCalls->getHoldTime($tipo, $entrantes, $salientes, translateDate($fecha_init), translateDate($fecha_end), $limit, $offset); //Llenamos el contenido de las columnas $arrTmp = array(); $sTagInicio = !$bExportando ? '<b>' : ''; $sTagFinal = $sTagInicio != '' ? '</b>' : ''; if (is_array($arrCalls)) { $end = $arrCalls['NumRecords']; foreach ($arrCalls['Data'] as $calls) { $arrTmp[0] = $calls['cola']; //primeramente enceramos los valores de horas $arrTmp[1] = ""; $arrTmp[2] = ""; $arrTmp[3] = ""; $arrTmp[4] = ""; $arrTmp[5] = ""; $arrTmp[6] = ""; $arrTmp[7] = ""; $arrTmp[8] = ""; $arrTmp[9] = ""; foreach ($calls as $intervalo => $num_veces) { if ($intervalo == '0') { $arrTmp[1] = $num_veces; } elseif ($intervalo == '1') { $arrTmp[2] = $num_veces; } elseif ($intervalo == '2') { $arrTmp[3] = $num_veces; } elseif ($intervalo == '3') { $arrTmp[4] = $num_veces; } elseif ($intervalo == '4') { $arrTmp[5] = $num_veces; } elseif ($intervalo == '5') { $arrTmp[6] = $num_veces; } elseif ($intervalo == "6") { $arrTmp[7] = $num_veces; } elseif ($intervalo == 'tiempo_promedio') { //tiempo promedio de espera en segundos $arrTmp[8] = number_format($num_veces, 0); } elseif ($intervalo == 'nuevo_valor_maximo') { //valor mayor en segundos $arrTmp[9] = $num_veces; } $arrTmp[10] = sumNumCalls($arrTmp); } $arrData[] = $arrTmp; } $arrTmp[0] = $sTagInicio . _tr("Total") . $sTagFinal; for ($j = 1; $j <= 8; $j++) { $sum = 0; for ($i = 0; $i < count($arrData); $i++) { $sum = $sum + $arrData[$i][$j]; } $arrTmp[$j] = $sTagInicio . $sum . $sTagFinal; } $sumTotalCalls = $maxTimeWait = 0; for ($i = 0; $i < count($arrData); $i++) { $maxTimeWait = $oCalls->getMaxWait($maxTimeWait, $arrData[$i][9]); $sumTotalCalls = $sumTotalCalls + $arrData[$i][10]; } $arrTmp[10] = $sTagInicio . $sumTotalCalls . $sTagFinal; $arrTmp[9] = $sTagInicio . $maxTimeWait . $sTagFinal; $arrData[] = $arrTmp; } //Para el combo de tipos $tipos = array("E" => _tr("Ingoing"), "S" => _tr("Outgoing")); $combo_tipos = "<select name='cbo_tipos' id='cbo_tipos' onChange='submit();'>" . combo($tipos, $_POST['cbo_tipos']) . "</select>"; //para el combo de entrantes if (isset($_POST['cbo_estado_entrantes'])) { $cbo_estado_entrates = $_POST['cbo_estado_entrantes']; } elseif (isset($_GET['cbo_estado_entrantes'])) { $cbo_estado_entrates = $_GET['cbo_estado_entrantes']; } else { $cbo_estado_entrates = 'T'; } $estados_entrantes = array("T" => _tr("Todas"), "E" => _tr("Exitosas"), "A" => _tr("Abandonadas")); $combo_estados_entrantes = "<select name='cbo_estado_entrantes' id='cbo_estado_entrantes' >" . combo($estados_entrantes, $cbo_estado_entrates) . "</select>"; //para el combo de salientes if (isset($_POST['cbo_estado_salientes'])) { $cbo_estado_salientes = $_POST['cbo_estado_salientes']; } elseif (isset($_GET['cbo_estado_salientes'])) { $cbo_estado_salientes = $_GET['cbo_estado_salientes']; } else { $cbo_estado_salientes = 'T'; } $estados_salientes = array("T" => _tr("Todas"), "E" => _tr("Exitosas"), "N" => _tr("No Realizadas"), "A" => _tr("Abandonadas")); $combo_estados_salientes = "<select name='cbo_estado_salientes' id='cbo_estado_salientes' >" . combo($estados_salientes, $cbo_estado_salientes) . "</select>"; //validamos que combo se cargará segun lo electo en combo TIPO, al principio le seteamos por defecto el de ENTRANTES $td = "<td class='letra12' align='right'>" . _tr("Estado") . "</td><td>{$combo_estados_entrantes}</td>"; if (isset($_POST['cbo_tipos']) && $_POST['cbo_tipos'] == "E") { $td = "<td class='letra12' align='left'>" . _tr("Estado") . "</td><td>{$combo_estados_entrantes}</td>"; } elseif (isset($_POST['cbo_tipos']) && $_POST['cbo_tipos'] == "S") { $td = "<td class='letra12' align='left'>" . _tr("Estado") . "</td><td>{$combo_estados_salientes}</td>"; } $oGrid->showFilter(insertarCabeceraCalendario() . "\n\n <table width='100%' border='0'>\n <tr>\n <td align='left'>\n <table>\n <tr>\n <td class='letra12'>\n " . _tr("Date Init") . "\n <span class='required'>*</span>\n </td>\n <td>\n " . insertarDateInit($fecha_init_actual) . "\n </td>\n <td class='letra12'>\n \n </td>\n <td class='letra12'>\n " . _tr("Date End") . "\n <span class='required'>*</span>\n </td>\n <td>\n " . insertarDateEnd($fecha_end_actual) . "\n </td>\n\n </tr>\n\n <tr>\n <td class='letra12' align='left'>" . _tr("Tipo") . "</td>\n <td>{$combo_tipos}</td>\n <td class='letra12'>\n \n </td>\n " . $td . "\n <td>\n <input type='submit' name='submit_fecha' value=" . _tr("Find") . " class='button'>\n </td>\n </tr>\n </table>\n </td>\n </tr>\n </table>\n\n "); $oGrid->enableExport(); if ($bElastixNuevo) { $oGrid->setURL($url); $oGrid->setData($arrData); $arrColumnas = array(_tr("Cola"), "0 - 10", "11 - 20", "21 - 30", "31 - 40", "41 - 50", "51 - 60", "61 >", _tr("Tiempo Promedio Espera(Seg)"), _tr("Espera Mayor(seg)"), _tr("Total Calls")); $oGrid->setColumns($arrColumnas); $oGrid->setTitle(_tr("Hold Time")); $oGrid->pagingShow(true); $oGrid->setNameFile_Export(_tr("Hold Time")); $smarty->assign("SHOW", _tr("Show")); return $oGrid->fetchGrid(); } else { global $arrLang; $offset = 0; $limit = $totalCalls; //Llenamos las cabeceras $url = construirURL($url, array("nav", "start")); $arrGrid = array("title" => _tr("Hold Time"), "url" => $url, "icon" => "images/list.png", "width" => "99%", "start" => $end == 0 ? 0 : $offset + 1, "end" => $offset + $limit <= $end ? $offset + $limit : $end, "total" => $end, "columns" => array(0 => array("name" => _tr("Cola"), "property1" => ""), 1 => array("name" => "0 - 10", "property1" => ""), 2 => array("name" => "11 - 20", "property1" => ""), 3 => array("name" => "21 - 30", "property1" => ""), 4 => array("name" => "31 - 40", "property1" => ""), 5 => array("name" => "41 - 50", "property1" => ""), 6 => array("name" => "51 - 60", "property1" => ""), 7 => array("name" => "61 >", "property1" => ""), 8 => array("name" => _tr("Tiempo Promedio Espera(Seg)"), "property1" => ""), 9 => array("name" => _tr("Espera Mayor(seg)"), "property1" => ""), 10 => array("name" => _tr("Total Calls"), "property1" => ""))); if (isset($_GET['exportpdf']) && $_GET['exportpdf'] == 'yes' && method_exists($oGrid, 'fetchGridPDF')) { return $oGrid->fetchGridPDF($arrGrid, $arrData); } if (isset($_GET['exportspreadsheet']) && $_GET['exportspreadsheet'] == 'yes' && method_exists($oGrid, 'fetchGridXLS')) { return $oGrid->fetchGridXLS($arrGrid, $arrData); } if ($bExportando) { $fechaActual = date("d M Y"); header("Cache-Control: private"); header("Pragma: cache"); header('Content-Type: application/octec-stream'); $title = "\"" . $fechaActual . ".csv\""; header("Content-disposition: inline; filename={$title}"); header('Content-Type: application/force-download'); } if ($bExportando) { return $oGrid->fetchGridCSV($arrGrid, $arrData); } $sContenido = $oGrid->fetchGrid($arrGrid, $arrData, $arrLang); if (strpos($sContenido, '<form') === FALSE) { $sContenido = "<form method=\"POST\" style=\"margin-bottom:0;\" action=\"{$url}\">{$sContenido}</form>"; } return $sContenido; } }