function reportListadodecampañas($smarty, $module_name, $local_templates_dir, &$pDB, $arrConf) { $pListadodecampañas = new paloSantoListadodecampañas($pDB); $filter_field = getParameter("filter_field"); $filter_value = getParameter("filter_value"); //begin grid parameters $oGrid = new paloSantoGrid($smarty); $oGrid->setTitle(_tr("Listado de campañas")); $oGrid->pagingShow(true); // show paging section. $oGrid->enableExport(); // enable export. $oGrid->setNameFile_Export(_tr("Listado de campañas")); $url = array("menu" => $module_name, "filter_field" => $filter_field, "filter_value" => $filter_value); $oGrid->setURL($url); $arrColumns = array(_tr("Nombre"), _tr("Fecha Inicial"), _tr("Fecha Final"), _tr("Form"), _tr("# de Bases"), _tr("# de Agentes"), _tr("Tipo"), _tr("Acción")); $oGrid->setColumns($arrColumns); $total = $pListadodecampañas->getNumListadodecampañas($filter_field, $filter_value); $arrData = null; if ($oGrid->isExportAction()) { $limit = $total; // max number of rows. $offset = 0; // since the start. } else { $limit = 20; $oGrid->setLimit($limit); $oGrid->setTotal($total); $offset = $oGrid->calculateOffset(); } $arrResult = $pListadodecampañas->getListadodecampañas($limit, $offset, $filter_field, $filter_value); if (is_array($arrResult) && $total > 0) { foreach ($arrResult as $key => $value) { $arrBasesAgentes = $pListadodecampañas->getBasesAgentes($value['id']); $arrTmp[0] = $value['nombre']; $arrTmp[1] = $value['fecha_inicio']; $arrTmp[2] = $value['fecha_fin']; $arrTmp[3] = $value['form']; $arrTmp[4] = $arrBasesAgentes['bases']; $arrTmp[5] = $arrBasesAgentes['agentes']; $arrTmp[6] = $value['tipo']; if ($value['tipo'] == "RECARGABLE") { $arrTmp[7] = "<a href=index.php?menu=hispana_campania_recargable&action=view_edit&id=" . $value['id'] . ">Editar</a>"; } else { $arrTmp[7] = "<a href=index.php?menu=hispana_crear_campania&action=view_edit&id=" . $value['id'] . ">Editar</a>"; } $arrData[] = $arrTmp; } } $oGrid->setData($arrData); //begin section filter $oFilterForm = new paloForm($smarty, createFieldFilter()); $smarty->assign("SHOW", _tr("Show")); $htmlFilter = $oFilterForm->fetchForm("{$local_templates_dir}/filter.tpl", "", $_POST); //end section filter $oGrid->showFilter(trim($htmlFilter)); $content = $oGrid->fetchGrid(); //end grid parameters return $content; }
function listFax($smarty, $module_name, $local_templates_dir) { $limit = 30; $oFax = new paloFax(); $total = $oFax->getTotalFax(); $oGrid = new paloSantoGrid($smarty); $oGrid->setLimit($limit); $oGrid->setTotal($total); $oGrid->pagingShow(true); $oGrid->setURL("?menu=faxlist"); $oGrid->setTitle(_tr("Virtual Fax List")); $oGrid->setIcon("/modules/{$module_name}/images/fax_virtual_fax_list.png"); $arrColumns = array(_tr("Virtual Fax Name"), _tr("Fax Extension"), _tr("Secret"), _tr("Destination Email"), _tr("Caller ID Name"), _tr("Caller ID Number"), _tr("Status")); $oGrid->setColumns($arrColumns); $offset = $oGrid->calculateOffset(); $arrFax = $oFax->getFaxList($offset, $limit); $arrFaxStatus = $oFax->getFaxStatus(); $arrData = array(); foreach ($arrFax as $fax) { $arrTmp = array(); $arrTmp[0] = " <a href='?menu=faxnew&action=view&id=" . $fax['id'] . "'>" . $fax['name'] . "</a>"; $arrTmp[1] = $fax['extension']; $arrTmp[2] = $fax['secret']; $arrTmp[3] = $fax['email']; $arrTmp[4] = $fax['clid_name'] . " "; $arrTmp[5] = $fax['clid_number'] . " "; $arrTmp[6] = $arrFaxStatus['modems']['ttyIAX' . $fax['dev_id']] . ' on ttyIAX' . $fax['dev_id']; $arrData[] = $arrTmp; } $session = getSession(); $session['faxlist']['faxListStatus'] = $arrData; putSession($session); $oGrid->setData($arrData); return $oGrid->fetchGrid(); }
function reportListadodebases($smarty, $module_name, $local_templates_dir, &$pDB, $arrConf) { $pListadodebases = new paloSantoListadodebases($pDB); $filter_field = getParameter("filter_field"); $filter_value = getParameter("filter_value"); //begin grid parameters $oGrid = new paloSantoGrid($smarty); $oGrid->setTitle(_tr("Listado de bases")); $oGrid->pagingShow(true); // show paging section. $oGrid->enableExport(); // enable export. $oGrid->setNameFile_Export(_tr("Listado de bases")); $url = array("menu" => $module_name, "filter_field" => $filter_field, "filter_value" => $filter_value); $oGrid->setURL($url); $arrColumns = array(_tr("Base"), _tr("CI"), _tr("Nombre"), _tr("Apellido"), _tr("Provincia"), _tr("Ciudad"), _tr("Nacimiento"), _tr("Correo personal"), _tr("Correo trabajo"), _tr("Estado civil"), _tr("Action")); $oGrid->setColumns($arrColumns); $total = $pListadodebases->getNumListadodebases($filter_field, $filter_value); $arrData = null; if ($oGrid->isExportAction()) { $limit = $total; // max number of rows. $offset = 0; // since the start. } else { //$limit = 20; $limit = 200; $oGrid->setLimit($limit); $oGrid->setTotal($total); $offset = $oGrid->calculateOffset(); } $arrResult = $pListadodebases->getListadodebases($limit, $offset, $filter_field, $filter_value); if (is_array($arrResult) && $total > 0) { foreach ($arrResult as $key => $value) { $arrTmp[0] = $value['base']; $arrTmp[1] = $value['ci']; $arrTmp[2] = $value['nombre']; $arrTmp[3] = $value['apellido']; $arrTmp[4] = $value['provincia']; $arrTmp[5] = $value['ciudad']; $arrTmp[6] = $value['nacimiento']; $arrTmp[7] = $value['correo_personal']; $arrTmp[8] = $value['correo_trabajo']; $arrTmp[9] = $value['estado_civil']; $arrTmp[10] = "<a href='?menu=hispana_clientes_datosbasicos&ci=" . $value['ci'] . "'>Editar</a>"; $arrData[] = $arrTmp; } } $oGrid->setData($arrData); //begin section filter $oFilterForm = new paloForm($smarty, createFieldFilter()); $smarty->assign("SHOW", _tr("Show")); $htmlFilter = $oFilterForm->fetchForm("{$local_templates_dir}/filter.tpl", "", $_POST); //end section filter $oGrid->showFilter(trim($htmlFilter)); $content = $oGrid->fetchGrid(); //end grid parameters return $content; }
function reportReporteGeneraldeGestión($smarty, $module_name, $local_templates_dir, &$pDB, $arrConf) { $pReporteGeneraldeGestión = new paloSantoReporteGeneraldeGestión($pDB); $filter_field = getParameter("filter_field"); $filter_value = getParameter("filter_value"); //begin grid parameters $oGrid = new paloSantoGrid($smarty); $oGrid->setTitle(_tr("Reporte General de Gestión")); $oGrid->pagingShow(true); // show paging section. $oGrid->enableExport(); // enable export. $oGrid->setNameFile_Export(_tr("Reporte General de Gestión")); $url = array("menu" => $module_name, "filter_field" => $filter_field, "filter_value" => $filter_value); $oGrid->setURL($url); $arrColumns = array(_tr("Campaña"), _tr("Cliente"), _tr("CI"), _tr("Teléfono"), _tr("Agente"), _tr("Calltype"), _tr("Fecha"), _tr("Audio")); $oGrid->setColumns($arrColumns); $total = $pReporteGeneraldeGestión->getNumReporteGeneraldeGestión($filter_field, $filter_value); $arrData = null; if ($oGrid->isExportAction()) { $limit = $total; // max number of rows. $offset = 0; // since the start. } else { $limit = 20; $oGrid->setLimit($limit); $oGrid->setTotal($total); $offset = $oGrid->calculateOffset(); } $arrResult = $pReporteGeneraldeGestión->getReporteGeneraldeGestión($limit, $offset, $filter_field, $filter_value); if (is_array($arrResult) && $total > 0) { foreach ($arrResult as $key => $value) { $arrTmp[0] = $value['campania']; $arrTmp[1] = $value['cliente']; $arrTmp[2] = $value['cedula']; $arrTmp[3] = $value['telefono']; $arrTmp[4] = $value['agente']; $arrTmp[5] = $value['calltype']; $arrTmp[6] = $value['fecha']; if (stripos($value['calltype'], "contactado") >= 0) { $arrTmp[7] = "<a href=monitoring_translator.php?action=download&id=" . $value['timestamp'] . "&rawmode=yes>Descargar</a>"; } //$arrTmp[7] = ""; $arrData[] = $arrTmp; } } $oGrid->setData($arrData); //begin section filter $oFilterForm = new paloForm($smarty, createFieldFilter()); $smarty->assign("SHOW", _tr("Show")); $htmlFilter = $oFilterForm->fetchForm("{$local_templates_dir}/filter.tpl", "", $_POST); //end section filter $oGrid->showFilter(trim($htmlFilter)); $content = $oGrid->fetchGrid(); //end grid parameters return $content; }
function reportTelefonosinactivos($smarty, $module_name, $local_templates_dir, &$pDB, $arrConf) { $pTelefonosinactivos = new paloSantoTelefonosinactivos($pDB); $filter_field = getParameter("filter_field"); $filter_value = getParameter("filter_value"); //begin grid parameters $oGrid = new paloSantoGrid($smarty); $oGrid->setTitle(_tr("Teléfonos inactivos")); $oGrid->pagingShow(true); // show paging section. $oGrid->enableExport(); // enable export. $oGrid->setNameFile_Export(_tr("Teléfonos inactivos")); $url = array("menu" => $module_name, "filter_field" => $filter_field, "filter_value" => $filter_value); $oGrid->setURL($url); $arrColumns = array(_tr("Cliente"), _tr("Cédula"), _tr("Descripción"), _tr("Telefono"), _tr("Acción")); $oGrid->setColumns($arrColumns); $total = $pTelefonosinactivos->getNumTelefonosinactivos($filter_field, $filter_value); $arrData = null; if ($oGrid->isExportAction()) { $limit = $total; // max number of rows. $offset = 0; // since the start. } else { $limit = 200; // Default 20 $oGrid->setLimit($limit); $oGrid->setTotal($total); $offset = $oGrid->calculateOffset(); } $arrResult = $pTelefonosinactivos->getTelefonosinactivos($limit, $offset, $filter_field, $filter_value); if (is_array($arrResult) && $total > 0) { foreach ($arrResult as $key => $value) { $arrTmp[0] = $value['cliente']; $arrTmp[1] = $value['ci']; $arrTmp[2] = $value['descripcion']; $arrTmp[3] = $value['telefono']; $arrTmp[4] = "<a href=index.php?menu={$module_name}&id={$value['id']}&action=activar>Activar</a>"; $arrData[] = $arrTmp; } } $oGrid->setData($arrData); //begin section filter $oFilterForm = new paloForm($smarty, createFieldFilter()); $smarty->assign("SHOW", _tr("Show")); $htmlFilter = $oFilterForm->fetchForm("{$local_templates_dir}/filter.tpl", "", $_POST); //end section filter $oGrid->showFilter(trim($htmlFilter)); $content = $oGrid->fetchGrid(); //end grid parameters return $content; }
function reportReportedeCalltypes($smarty, $module_name, $local_templates_dir, &$pDB, $arrConf) { $pReportedeCalltypes = new paloSantoReportedeCalltypes($pDB); $filter_field = getParameter("filter_field"); $filter_value = getParameter("filter_value"); $id_campania = getParameter("id_campania"); $filter_field_adicional = getParameter("adicionales"); $filter_value_adicional = getParameter("filtro_adicional"); //begin grid parameters $oGrid = new paloSantoGrid($smarty); $oGrid->setTitle(_tr("Reporte Ultima Gestion Recargables")); $oGrid->pagingShow(true); // show paging section. $oGrid->enableExport(); // enable export. $oGrid->setNameFile_Export(_tr("Reporte Ultima Gestion Recargables")); $url = array("menu" => $module_name, "filter_field" => $filter_field, "filter_value" => $filter_value, "id_campania" => $id_campania, "adicionales" => $filter_field_adicional, "filtro_adicional" => $filter_value_adicional); $oGrid->setURL($url); // Columnas base $arrColumns = array(_tr("Fecha"), _tr("Hora"), _tr("Campaña"), _tr("Base"), _tr("Cliente"), _tr("CI"), _tr("Teléfono"), _tr("Agente"), _tr("Contactabilidad"), _tr("Calltype"), _tr("Provincia"), _tr("Ciudad"), _tr("Nacimiento"), _tr("Correo Personal"), _tr("Correo Trabajo"), _tr("Estado Civil"), _tr("Formulario")); // Otras columnas if ($id_campania != "") { // Columnas adicionales $arrColumnasAdicionales = $pReportedeCalltypes->getColumnasAdicionales($id_campania); $arrColumns = array_merge($arrColumns, $arrColumnasAdicionales); $smarty->assign("mostrarAdicional", "si"); $smarty->assign("filtro_adicionales", filter_adicionales($arrColumnasAdicionales, null)); // Columnas de gestión $arrTmp = $pReportedeCalltypes->getFormFields($id_campania); $i = 0; foreach ($arrTmp as $formField) { $arrOrden[] = $formField['id']; $arrColumnsAdicionales[$i] = $formField['etiqueta']; $i++; } $arrColumns = array_merge($arrColumns, $arrColumnsAdicionales); } $oGrid->setColumns($arrColumns); $total = $pReportedeCalltypes->getNumReportedeCalltypes($filter_field, $filter_value, $id_campania, $filter_field_adicional, $filter_value_adicional); $arrData = null; if ($oGrid->isExportAction()) { $limit = $total; // max number of rows. $offset = 0; // since the start. } else { $limit = 20; // default 20 $oGrid->setLimit($limit); $oGrid->setTotal($total); $offset = $oGrid->calculateOffset(); } $arrResult = $pReportedeCalltypes->getReportedeCalltypes($limit, $offset, $filter_field, $filter_value, $id_campania, $filter_field_adicional, $filter_value_adicional); if (is_array($arrResult) && $total > 0) { foreach ($arrResult as $key => $value) { $fecha = date("Y-m-d", strtotime($value['fecha'])); $hora = date("H:i:s", strtotime($value['fecha'])); $arrTmp[0] = $fecha; $arrTmp[1] = $hora; $arrTmp[2] = $value['campania']; $arrTmp[3] = $value['base']; $arrTmp[4] = $value['cliente']; $arrTmp[5] = $value['ci']; $arrTmp[6] = $value['telefono']; $arrTmp[7] = $value['agente']; $arrTmp[8] = $value['contactabilidad']; $arrTmp[9] = $value['calltype']; $arrTmp[10] = $value['provincia']; $arrTmp[11] = $value['ciudad']; $arrTmp[12] = $value['nacimiento']; $arrTmp[13] = $value['correo_personal']; $arrTmp[14] = $value['correo_trabajo']; $arrTmp[15] = $value['estado_civil']; // $arrTmp[8] = $value['formulario']; // Así lo requiere RUBENING $arrTmp[16] = "<a href=modules/{$module_name}/gestion_info.php?id_gestion={$value['id_gestion']} target=\"_blank\" onClick=\"window.open(this.href, this.target, 'width=600,height=400'); return false;\">Ver gestión</a>" . "<br>" . "<a href=modules/{$module_name}/gestion_edit.php?id_gestion={$value['id_gestion']}&user="******"elastix_user"] . " target=\"_blank\" onClick=\"window.open(this.href, this.target, 'width=600,height=400,scrollbars=1'); return false;\">Editar</a>"; // Datos adicionales $arrDatosAdicionales = $pReportedeCalltypes->getDatosAdicionales($value['id_cliente'], $value['id_base']); $i = 17; foreach ($arrColumnasAdicionales as $k => $columnaAdicional) { $arrTmp[$i] = $arrDatosAdicionales[$columnaAdicional]; $i++; } unset($arrDatosAdicionales); $numColumnasFijas = $i; // Datos de gestión $arrFormValues = $pReportedeCalltypes->getFormValues($value['id_gestion']); // array_search retorna el key dado el valor a buscar foreach ($arrFormValues as $formValue) { // echo $formValue['valor'] . " " . array_search($formValue['id_form_field'],$arrOrden) . "<br>"; $ubicacionReal = array_search($formValue['id_form_field'], $arrOrden) + $numColumnasFijas; if (is_array($formValue['valor'])) { $formValue['valor'] = print_r($formValue['valor'], true); } $arrTmp[$ubicacionReal] = $formValue['valor']; } $arrData[] = $arrTmp; unset($arrTmp); } } $oGrid->setData($arrData); /* Para colocar en $arrTmp */ //begin section filter $oFilterForm = new paloForm($smarty, createFieldFilter()); $smarty->assign("SHOW", _tr("Show")); $smarty->assign("filter_campaign", filter_campaign($pDB, $id_campania)); $htmlFilter = $oFilterForm->fetchForm("{$local_templates_dir}/filter.tpl", "", $_POST); //end section filter $oGrid->showFilter(trim($htmlFilter)); $content = $oGrid->fetchGrid(); //end grid parameters return $content; }
function reportClientesCampania($smarty, $module_name, $local_templates_dir, &$pDB, $arrConf) { $pClientesagendados = new paloSantoClientesCampania($pDB); $filter_field = getParameter("filter_field"); $filter_value = getParameter("filter_value"); //begin grid parameters $oGrid = new paloSantoGrid($smarty); $oGrid->setTplFile("/var/www/html/modules/{$module_name}/themes/default/_list.tpl"); $oGrid->setTitle(_tr("Clientes por campaña")); $oGrid->pagingShow(true); // show paging section. $oGrid->enableExport(); // enable export. $oGrid->setNameFile_Export(_tr("Clientes por campaña")); $url = array("menu" => $module_name, "filter_field" => $filter_field, "filter_value" => $filter_value); $oGrid->setURL($url); $arrColumns = array(_tr("CI"), _tr("Cliente"), _tr("Campaña"), _tr("Agendamiento"), _tr("Agendado a"), _tr("Acción")); $oGrid->setColumns($arrColumns); $total = $pClientesagendados->getNumClientesCampania($filter_field, $filter_value); $arrData = null; if ($oGrid->isExportAction()) { $limit = $total; // max number of rows. $offset = 0; // since the start. } else { $limit = 100; $oGrid->setLimit($limit); $oGrid->setTotal($total); $offset = $oGrid->calculateOffset(); } $arrResult = $pClientesagendados->getClientesCampania($limit, $offset, $filter_field, $filter_value); if (is_array($arrResult) && $total > 0) { foreach ($arrResult as $key => $value) { $arrTmp[0] = $value['ci']; $arrTmp[1] = $value['cliente']; $arrTmp[2] = $value['campania']; $arrTmp[3] = $value['fecha_agendamiento']; $arrTmp[4] = $value['agente_agendado']; //$arrTmp[3] = getFormSelectAgentesCampania($pClientesagendados,$value['id_campania'],$value['id_campania_cliente'],$value['agente_agendado']); $arrTmp[5] = "<a href='index.php?menu={$module_name}&id_campania_cliente={$value['id_campania_cliente']}&action=agendar'>Agendar</a>" . " / <a href='index.php?menu=hispana_clientes_datosbasicos&id_cliente=" . $value['id_cliente'] . "'>Editar</a>"; $arrData[] = $arrTmp; } } $oGrid->setData($arrData); //begin section filter $oFilterForm = new paloForm($smarty, createFieldFilter()); $smarty->assign("SHOW", _tr("Show")); $htmlFilter = $oFilterForm->fetchForm("{$local_templates_dir}/filter.tpl", "", $_POST); //end section filter $oGrid->showFilter(trim($htmlFilter)); $content = $oGrid->fetchGrid(); //end grid parameters return $content; }
function reportRules($smarty, $module_name, $local_templates_dir, &$pDB, $arrConf) { $pRules = new paloSantoRules($pDB); $action = getParameter("action"); $id = getParameter("id"); $smarty->assign("ID", $id); $oFilterForm = new paloForm($smarty, array()); //begin grid parameters $oGrid = new paloSantoGrid($smarty); $first_time = $pRules->isFirstTime(); //$oGrid->setTplFile("$local_templates_dir/_list.tpl"); $totalRules = $pRules->ObtainNumRules(); $error = ""; if ($action == 'edit') { $arrtmp = $pRules->getRule($id); $arripsource = explode("/", $arrtmp['ip_source']); $arripdst = explode("/", $arrtmp['ip_destiny']); $arrValues['id_traffic'] = $arrtmp['traffic']; $arrValues['interface_in'] = $arrtmp['eth_in']; $arrValues['interface_out'] = $arrtmp['eth_out']; $arrValues['ip_source'] = $arripsource[0]; $arrValues['mask_source'] = $arripsource[1]; $arrValues['port_in'] = $arrtmp['sport']; $arrValues['ip_destin'] = $arripdst[0]; $arrValues['mask_destin'] = $arripdst[1]; $arrValues['port_out'] = $arrtmp['dport']; $arrValues['type_icmp'] = $arrtmp['icmp_type']; $arrValues['id_ip'] = $arrtmp['number_ip']; $arrValues['id_protocol'] = $arrtmp['protocol']; $arrValues['target'] = $arrtmp['target']; $arrValues['orden'] = $arrtmp['rule_order']; $arrValues['state'] = $arrtmp['state']; $arrValues['id'] = $id; $content = newRules($smarty, $module_name, $local_templates_dir, $pDB, $arrConf, $arrValues, $action); return $content; } elseif ($action == 'Activate') { $pRules->setActivated($id); } elseif ($action == 'Desactivate') { $pRules->setDesactivated($id); } $limit = 30; $total = $totalRules; $oGrid->setLimit($limit); $oGrid->setTotal($total); $oGrid->setTitle(_tr("FireWall Rules")); $oGrid->setIcon("/modules/{$module_name}/images/security_firewall_rules.png"); $oGrid->pagingShow(true); $offset = $oGrid->calculateOffset(); $url = "?menu={$module_name}"; $oGrid->setURL($url); $arrData = null; $arrResult = $pRules->ObtainRules($limit, $offset); $start = getParameter("start"); $accion = getParameter("nav"); if ($accion == "end") { if ($total % $limit == 0) { $start = $total - 2 * $limit + 1; } else { $start = $total - $total % $limit - $limit + 1; } } elseif ($accion == "previous") { $start = $start - 2 * $limit; } if ($first_time) { $arrColumns = array("", _tr("Order"), _tr("Traffic"), _tr("Target"), _tr("Interface"), _tr("IP Source"), _tr("IP Destiny"), _tr("Protocol"), _tr("Details")); } else { $oGrid->deleteList("Are you sure you wish to delete the Rule?", "delete", _tr("Delete")); $arrColumns = array("", _tr("Order"), _tr("Traffic"), _tr("Target"), _tr("Interface"), _tr("IP Source"), _tr("IP Destiny"), _tr("Protocol"), _tr("Details"), "", ""); } $oGrid->setColumns($arrColumns); if (is_array($arrResult) && $total > 0) { foreach ($arrResult as $key => $value) { if (!$first_time) { $arrTmp[0] = "<input type='checkbox' name='id_" . $value['id'] . "' />"; $arrTmp[1] = "<div id='div_{$value['id']}' style='width: 22px; font-size: 14pt;color:#E35332;float:left;text-align:right'>{$value['rule_order']} </div>"; } if (!$first_time) { //if($offset!=0) $arrTmp[1] .= "<a href='javascript:void(0);' class='up' id='rulerup_{$value['id']}_{$value['rule_order']}'>" . "<img src='modules/{$module_name}/images/up.gif' border=0 title='" . _tr('Up') . "' /></a>" . "<a href='javascript:void(0);' class='down' id='rulerdown_{$value['id']}_{$value['rule_order']}'>" . "<img src='modules/{$module_name}/images/down.gif' border=0 title='" . _tr('Down') . "' /></a>"; /*else $arrTmp[1].="<a href='?menu=$module_name&action=$changeOrder&id=$value[id]&order=$value[rule_order]&direction=up;' class='up' id='rulerup_$value[id]_$value[rule_order]'>"."<img src='modules/$module_name/images/up.gif' border=0 title='"._tr('Up')."' /></a>"."<a href='javascript:void(0);' class='down' id='rulerdown_$value[id]_$value[rule_order]'>"."<img src='modules/$module_name/images/down.gif' border=0 title='"._tr('Down')."' /></a>";*/ } if ($value['traffic'] == "INPUT") { $image = "modules/{$module_name}/images/fw_input.gif"; $title = _tr("INPUT"); $arrTmp[4] = _tr("IN") . ": {$value['eth_in']}"; } elseif ($value['traffic'] == "OUTPUT") { $image = "modules/{$module_name}/images/fw_output.gif"; $title = _tr("OUTPUT"); $arrTmp[4] = _tr("OUT") . ": {$value['eth_out']}"; } else { $image = "modules/{$module_name}/images/fw_forward.gif"; $title = _tr("FORWARD"); $arrTmp[4] = _tr("IN") . ": {$value['eth_in']}<br />" . _tr("OUT") . ": {$value['eth_out']}"; } $arrTmp[2] = "<a><img src='{$image}' border=0 title='" . _tr($title) . "'</a>"; if ($value['target'] == "ACCEPT") { $image = "modules/{$module_name}/images/target_accept.gif"; $title = _tr("ACCEPT"); } elseif ($value['target'] == "DROP") { $image = "modules/{$module_name}/images/target_drop.gif"; $title = _tr("DROP"); } else { $image = "modules/{$module_name}/images/target_drop.gif"; $title = _tr("REJECT"); } $arrTmp[3] = "<a><img src='{$image}' border=0 title='" . _tr($title) . "'</a>"; $arrTmp[5] = $value['ip_source']; $arrTmp[6] = $value['ip_destiny']; $arrTmp[7] = $value['protocol']; if ($value['protocol'] == "ICMP") { if ($value["icmp_type"] != "" && $value["icmp_type"] != "ANY") { $protocolName = $pRules->getProtocolName($value["icmp_type"]); } else { $protocolName = $value["icmp_type"]; } $arrTmp[8] = _tr("Type") . ": {$protocolName}"; } else { if ($value['protocol'] == "IP") { if ($value["number_ip"] != "" && $value["number_ip"] != "ANY") { $protocolName = $pRules->getProtocolName($value["number_ip"]); } else { $protocolName = $value["number_ip"]; } $arrTmp[8] = _tr("Number Protocol IP") . ": {$protocolName}"; } else { if ($value['protocol'] == "TCP" || $value['protocol'] == "UDP") { if ($value["sport"] != "" && $value["sport"] != "ANY") { $sportName = $pRules->getProtocolName($value["sport"]); } else { $sportName = $value["sport"]; } if ($value["dport"] != "" && $value["dport"] != "ANY") { $dportName = $pRules->getProtocolName($value["dport"]); } else { $dportName = $value["dport"]; } $arrTmp[8] = _tr("Source Port") . ": {$sportName}" . "<br />" . _tr("Destiny Port") . ": {$dportName}"; } else { if ($value['protocol'] == "STATE") { $arrTmp[8] = $value['state']; } else { $arrTmp[8] = ""; } } } } if (!$first_time) { if ($value['activated'] == 1) { $image = "modules/{$module_name}/images/foco_on.gif"; $activated = "Desactivate"; } else { $image = "modules/{$module_name}/images/foco_off.gif"; $activated = "Activate"; } if ($offset != 0) { $arrTmp[9] = "<a href='?menu={$module_name}&action=" . $activated . "&id=" . $value['id'] . "&nav=next&start={$start}'>" . "<img src='{$image}' border=0 title='" . _tr($activated) . "'</a>"; } else { $arrTmp[9] = "<a href='?menu={$module_name}&action=" . $activated . "&id=" . $value['id'] . "'>" . "<img src='{$image}' border=0 title='" . _tr($activated) . "'</a>"; } $arrTmp[10] = "<a href='?menu={$module_name}&action=edit&id=" . $value['id'] . "'>" . "<img src='modules/{$module_name}/images/edit.gif' border=0 title='" . _tr('Edit') . "'</a>"; } $arrData[] = $arrTmp; } // $arrData[] = array("ctrl" => "separator_line", "start" => 0); } $oGrid->setData($arrData); //$smarty->assign("desactivate", _tr("Desactivate FireWall")); if ($first_time) { $smarty->assign("mb_message", "<b>" . _tr("The firewall is totally desactivated. It is recommended to activate the firewall rules") . "</b>"); $smarty->assign("mb_title", _tr("WARNING")); $mensaje = _tr("The firewall is totally desactivated. It is recommended to activate the firewall rules"); $mensaje2 = _tr("Activate FireWall"); $oGrid->customAction("exec", $mensaje2); } else { $oGrid->customAction("desactivate", _tr("Desactivate FireWall")); $oGrid->addNew("new", _tr("New Rule")); $mensaje = _tr("You have made changes to the definition of firewall rules, for this to take effect in the system press the next button"); $mensaje2 = _tr("Save Changes"); } if ($pRules->isExecutedInSystem()) { $smarty->assign("BORDER", ""); $smarty->assign("DISPLAY", "display:none;"); } else { $smarty->assign("executed_in_sys", $mensaje); $smarty->assign("BORDER", "border:1px solid; color:#AAAAAA"); $smarty->assign("DISPLAY", ""); } $smarty->assign("exec", $mensaje2); if (!$first_time) { if (!$pRules->isExecutedInSystem()) { $smarty->assign("mb_title", _tr("MESSAGE")); $smarty->assign("mb_message", $mensaje . " <form method='POST' style='margin-bottom:0;' action='?menu_sec_rules'><input class='button' type='submit' name='exec' value='{$mensaje2}'></form>"); } } $contenidoModulo = $oGrid->fetchGrid(); if ($arrConf["mainTheme"] == "elastixneo") { $contenidoModulo = "<div id='msg_status' class='mensajeStatus'></div>" . $contenidoModulo; } if (strpos($contenidoModulo, '<form') === FALSE) { $contenidoModulo = "<form method='POST' style='margin-bottom:0;' action={$url}>{$contenidoModulo}</form>"; } //end grid parameters return $contenidoModulo; }
function viewFormDomain($smarty, $module_name, $local_templates_dir, &$pDB, $arrConf, $arrLang) { $pEmail = new paloEmail($pDB); $oGrid = new paloSantoGrid($smarty); $arrDomains = $pEmail->getDomains(); $end = count($arrDomains); $arrData = array(); $oGrid->pagingShow(true); $url = array("menu" => $module_name); $oGrid->setURL($url); $oGrid->setTitle(_tr("Domain List")); $oGrid->setIcon("modules/{$module_name}/images/email_domains.png"); $arrColumns = array(_tr("Domain"), _tr("Number of Accounts")); $oGrid->setColumns($arrColumns); $total = 0; $limit = 20; $limitInferior = ""; $limitSuperior = ""; $oGrid->setLimit($limit); $oGrid->addNew("submit_create_domain", _tr('Create Domain')); if (is_array($arrDomains) && $end > 0) { $oGrid->setTotal($end); $offset = $oGrid->calculateOffset(); $cont = 0; $limitInferior = $offset; $limitSuperior = $offset + $limit - 1; foreach ($arrDomains as $domain) { $arrTmp = array(); if ($cont > $limitSuperior) { break; } if ($cont >= $limitInferior & $cont <= $limitSuperior) { $arrTmp[0] = " <a href='?menu=email_domains&action=view&id=" . $domain[0] . "'>{$domain['1']}</a>"; //obtener el numero de cuentas que posee ese email $arrTmp[1] = $pEmail->getNumberOfAccounts($domain[0]); $arrData[] = $arrTmp; } $cont++; } } else { $oGrid->setTotal($total); $offset = $oGrid->calculateOffset(); } $oGrid->setData($arrData); $content = $oGrid->fetchGrid(); return $content; }
function _moduleContent(&$smarty, $module_name) { require_once "modules/{$module_name}/libs/ringgroup.php"; //include module files include_once "modules/{$module_name}/configs/default.conf.php"; load_language_module($module_name); global $arrConf; global $arrConfModule; $arrConf = array_merge($arrConf, $arrConfModule); //folder path for custom templates $base_dir = dirname($_SERVER['SCRIPT_FILENAME']); $templates_dir = isset($arrConf['templates_dir']) ? $arrConf['templates_dir'] : 'themes'; $local_templates_dir = "{$base_dir}/modules/{$module_name}/" . $templates_dir . '/' . $arrConf['theme']; // DSN para consulta de cdrs $dsn = generarDSNSistema('asteriskuser', 'asteriskcdrdb'); $pDB = new paloDB($dsn); $oCDR = new paloSantoCDR($pDB); $pDBACL = new paloDB($arrConf['elastix_dsn']['acl']); if (!empty($pDBACL->errMsg)) { return "ERROR DE DB: {$pDBACL->errMsg}"; } $pACL = new paloACL($pDBACL); if (!empty($pACL->errMsg)) { return "ERROR DE ACL: {$pACL->errMsg}"; } $exten = '6868'; //$pACL->getUserExtension($_SESSION['elastix_user']); $isAdministrator = true; //$pACL->isUserAdministratorGroup($_SESSION['elastix_user']); if (is_null($exten) || $exten == "") { if (!$isAdministrator) { $smarty->assign('mb_message', "<b>" . _tr("contact_admin") . "</b>"); return ""; } else { $smarty->assign('mb_message', "<b>" . _tr("no_extension") . "</b>"); } } // Para usuarios que no son administradores, se restringe a los CDR de la // propia extensión $sExtension = $isAdministrator ? '' : $pACL->getUserExtension($_SESSION['elastix_user']); // DSN para consulta de ringgroups $dsn_asterisk = generarDSNSistema('asteriskuser', 'asterisk'); $pDB_asterisk = new paloDB($dsn_asterisk); $oRG = new RingGroup($pDB_asterisk); $dataRG = $oRG->getRingGroup(); $dataRG[''] = _tr('(Any ringgroup)'); // Cadenas estáticas en la plantilla $smarty->assign(array("Filter" => _tr("Filter"))); $arrFormElements = array("date_start" => array("LABEL" => _tr("Start Date"), "REQUIRED" => "yes", "INPUT_TYPE" => "DATE", "INPUT_EXTRA_PARAM" => "", "VALIDATION_TYPE" => "ereg", "VALIDATION_EXTRA_PARAM" => "^[[:digit:]]{1,2}[[:space:]]+[[:alnum:]]{3}[[:space:]]+[[:digit:]]{4}\$"), "date_end" => array("LABEL" => _tr("End Date"), "REQUIRED" => "yes", "INPUT_TYPE" => "DATE", "INPUT_EXTRA_PARAM" => "", "VALIDATION_TYPE" => "ereg", "VALIDATION_EXTRA_PARAM" => "^[[:digit:]]{1,2}[[:space:]]+[[:alnum:]]{3}[[:space:]]+[[:digit:]]{4}\$"), "field_name" => array("LABEL" => _tr("Field Name"), "REQUIRED" => "no", "INPUT_TYPE" => "SELECT", "INPUT_EXTRA_PARAM" => array("dst" => _tr("Destination"), "src" => _tr("Source"), "channel" => _tr("Src. Channel"), "accountcode" => _tr("Account Code"), "dstchannel" => _tr("Dst. Channel")), "VALIDATION_TYPE" => "ereg", "VALIDATION_EXTRA_PARAM" => "^(dst|src|channel|dstchannel|accountcode)\$"), "field_pattern" => array("LABEL" => _tr("Field"), "REQUIRED" => "no", "INPUT_TYPE" => "TEXT", "INPUT_EXTRA_PARAM" => "", "VALIDATION_TYPE" => "ereg", "VALIDATION_EXTRA_PARAM" => "^[\\*|[:alnum:]@_\\.,/\\-]+\$"), "status" => array("LABEL" => _tr("Status"), "REQUIRED" => "no", "INPUT_TYPE" => "SELECT", "INPUT_EXTRA_PARAM" => array("ALL" => _tr("ALL"), "ANSWERED" => _tr("ANSWERED"), "BUSY" => _tr("BUSY"), "FAILED" => _tr("FAILED"), "NO ANSWER " => _tr("NO ANSWER")), "VALIDATION_TYPE" => "text", "VALIDATION_EXTRA_PARAM" => ""), "ringgroup" => array("LABEL" => _tr("Ring Group"), "REQUIRED" => "no", "INPUT_TYPE" => "SELECT", "INPUT_EXTRA_PARAM" => $dataRG, "VALIDATION_TYPE" => "text", "VALIDATION_EXTRA_PARAM" => "")); $oFilterForm = new paloForm($smarty, $arrFormElements); // Parámetros base y validación de parámetros $url = array('menu' => $module_name); $paramFiltroBase = $paramFiltro = array('date_start' => date("d M Y"), 'date_end' => date("d M Y"), 'field_name' => 'dst', 'field_pattern' => '', 'status' => 'ALL', 'ringgroup' => ''); foreach (array_keys($paramFiltro) as $k) { if (!is_null(getParameter($k))) { $paramFiltro[$k] = getParameter($k); } } $oGrid = new paloSantoGrid($smarty); if ($paramFiltro['date_start'] === "") { $paramFiltro['date_start'] = " "; } if ($paramFiltro['date_end'] === "") { $paramFiltro['date_end'] = " "; } $valueFieldName = $arrFormElements['field_name']["INPUT_EXTRA_PARAM"][$paramFiltro['field_name']]; $valueStatus = $arrFormElements['status']["INPUT_EXTRA_PARAM"][$paramFiltro['status']]; $valueRingGRoup = $arrFormElements['ringgroup']["INPUT_EXTRA_PARAM"][$paramFiltro['ringgroup']]; $oGrid->addFilterControl(_tr("Filter applied: ") . _tr("Start Date") . " = " . $paramFiltro['date_start'] . ", " . _tr("End Date") . " = " . $paramFiltro['date_end'], $paramFiltro, array('date_start' => date("d M Y"), 'date_end' => date("d M Y")), true); $oGrid->addFilterControl(_tr("Filter applied: ") . $valueFieldName . " = " . $paramFiltro['field_pattern'], $paramFiltro, array('field_name' => "dst", 'field_pattern' => "")); $oGrid->addFilterControl(_tr("Filter applied: ") . _tr("Status") . " = " . $valueStatus, $paramFiltro, array('status' => 'ALL'), true); $oGrid->addFilterControl(_tr("Filter applied: ") . _tr("Ring Group") . " = " . $valueRingGRoup, $paramFiltro, array('ringgroup' => '')); $htmlFilter = $oFilterForm->fetchForm("{$local_templates_dir}/filter.tpl", "", $paramFiltro); if (!$oFilterForm->validateForm($paramFiltro)) { $smarty->assign(array('mb_title' => _tr('Validation Error'), 'mb_message' => '<b>' . _tr('The following fields contain errors') . ':</b><br/>' . implode(', ', array_keys($oFilterForm->arrErroresValidacion)))); $paramFiltro = $paramFiltroBase; unset($_POST['delete']); // Se aborta el intento de borrar CDRs, si había uno. } // Tradudir fechas a formato ISO para comparación y para API de CDRs. $url = array_merge($url, $paramFiltro); $paramFiltro['date_start'] = translateDate($paramFiltro['date_start']) . ' 00:00:00'; $paramFiltro['date_end'] = translateDate($paramFiltro['date_end']) . ' 23:59:59'; // Valores de filtrado que no se seleccionan mediante filtro if ($sExtension != '') { $paramFiltro['extension'] = $sExtension; } // Ejecutar el borrado, si se ha validado. if (isset($_POST['delete'])) { if ($isAdministrator) { if ($paramFiltro['date_start'] <= $paramFiltro['date_end']) { $r = $oCDR->borrarCDRs($paramFiltro); if (!$r) { $smarty->assign(array('mb_title' => _tr('ERROR'), 'mb_message' => $oCDR->errMsg)); } } else { $smarty->assign(array('mb_title' => _tr('ERROR'), 'mb_message' => _tr("Please End Date must be greater than Start Date"))); } } else { $smarty->assign(array('mb_title' => _tr('ERROR'), 'mb_message' => _tr("Only administrators can delete CDRs"))); } } $oGrid->setTitle(_tr("CDR Report")); $oGrid->pagingShow(true); // show paging section. $oGrid->enableExport(); // enable export. $oGrid->setNameFile_Export(_tr("CDRReport")); $oGrid->setURL($url); //if($isAdministrator) //$oGrid->deleteList("Are you sure you wish to delete CDR(s) Report(s)?","delete",_tr("Delete")); $arrData = null; if (!isset($sExtension) || $sExtension == "" && !$isAdministrator) { $total = 0; } else { $total = $oCDR->contarCDRs($paramFiltro); } if ($oGrid->isExportAction()) { $limit = $total; $offset = 0; $arrColumns = array(_tr("Date"), _tr("Source"), _tr("Ring Group"), _tr("Destination"), _tr("Src. Channel"), _tr("Account Code"), _tr("Dst. Channel"), _tr("Status"), _tr("Duration")); $oGrid->setColumns($arrColumns); $arrResult = $oCDR->listarCDRs($paramFiltro, $limit, $offset); if (is_array($arrResult['cdrs']) && $total > 0) { foreach ($arrResult['cdrs'] as $key => $value) { $arrTmp[0] = date("d-m-Y H:i:s", strtotime($value[0])); $arrTmp[1] = $value[1]; $arrTmp[2] = $value[11]; $arrTmp[3] = $value[3]; $arrTmp[4] = $value[9]; $arrTmp[5] = $value[5]; $iDuracion = $value[8]; $iSec = $iDuracion % 60; $iDuracion = (int) (($iDuracion - $iSec) / 60); $iMin = $iDuracion % 60; $iDuracion = (int) (($iDuracion - $iMin) / 60); $sTiempo = "{$value[6]}s"; if ($value[6] >= 60) { if ($iDuracion > 0) { $sTiempo .= " ({$iDuracion}h {$iMin}m {$iSec}s)"; } elseif ($iMin > 0) { $sTiempo .= " ({$iMin}m {$iSec}s)"; } } $arrTmp[7] = $sTiempo; $arrData[] = $arrTmp; } } if (!is_array($arrResult)) { $smarty->assign(array('mb_title' => _tr('ERROR'), 'mb_message' => $oCDR->errMsg)); } } else { $limit = 20; $oGrid->setLimit($limit); $oGrid->setTotal($total); $offset = $oGrid->calculateOffset(); $arrResult = $oCDR->listarCDRs($paramFiltro, $limit, $offset); $arrColumns = array('STT', _tr("Date"), _tr("Source"), _tr("Destination"), _tr("Src. Channel"), _tr("Dst. Channel"), _tr("Status"), _tr("Duration")); $oGrid->setColumns($arrColumns); if (is_array($arrResult['cdrs']) && $total > 0) { $index = 0; foreach ($arrResult['cdrs'] as $key => $value) { $arrTmp[0] = $index; $arrTmp[1] = date("d-m-Y H:i:s", strtotime($value[0])); $arrTmp[2] = $value[1]; $arrTmp[3] = $value[2]; $arrTmp[4] = channel_lookup($pDB_asterisk, $value[3]); $arrTmp[5] = channel_lookup($pDB_asterisk, $value[4]); $arrTmp[6] = $value[5]; $iDuracion = $value[8]; $iSec = $iDuracion % 60; $iDuracion = (int) (($iDuracion - $iSec) / 60); $iMin = $iDuracion % 60; $iDuracion = (int) (($iDuracion - $iMin) / 60); $sTiempo = "{$value[8]}s"; if ($value[7] >= 60) { if ($iDuracion > 0) { $sTiempo .= " ({$iDuracion}h {$iMin}m {$iSec}s)"; } elseif ($iMin > 0) { $sTiempo .= " ({$iMin}m {$iSec}s)"; } } $arrTmp[7] = $sTiempo; $arrData[] = $arrTmp; $index++; } } if (!is_array($arrResult)) { $smarty->assign(array('mb_title' => _tr('ERROR'), 'mb_message' => $oCDR->errMsg)); } } $oGrid->setData($arrData); $smarty->assign("SHOW", _tr("Show")); $oGrid->showFilter($htmlFilter); $content = $oGrid->fetchGrid(); return $content; }
function listarColaFax_raw($smarty, $module_name, $local_templates_dir, $listaColaFax) { $oGrid = new paloSantoGrid($smarty); $oGrid->pagingShow(FALSE); $oGrid->setURL('?menu=faxqueue'); $oGrid->setTitle(_tr('Fax Queue')); $oGrid->deleteList('Are you sure to cancel selected jobs?', 'remove', _tr('Cancel job')); $arrColumns = array('', _tr('Job ID'), _tr('Priority'), _tr('Destination'), _tr('Pages'), _tr('Retries'), _tr('Status')); $oGrid->setColumns($arrColumns); function listarColaFax_toHTML($t) { return array('<input type="radio" name="jobid" value="' . $t['jobid'] . '"/>', $t['jobid'], $t['priority'], $t['outnum'], sprintf(_tr('Sent %d pages of %d'), $t['sentpages'], $t['totalpages']), sprintf(_tr('Try %d of %d'), $t['retries'], $t['totalretries']), '[' . $t['state'] . '] ' . _tr($t['status'])); } $oGrid->setData(array_map('listarColaFax_toHTML', $listaColaFax)); return $oGrid->fetchGrid(); }
function listPortKnockCurrentAuths(&$smarty, $module_name, $local_templates_dir, &$pDB, $arrConf) { $eth_in = getParameter('eth_in'); if (is_null($eth_in)) { Header("Location: ?menu={$module_name}"); return NULL; } include_once "libs/paloSantoACL.class.php"; $pACL = new paloACL($arrConf['elastix_dsn']['acl']); $pk = new paloSantoPortKnockInterfaces($pDB); $oGrid = new paloSantoGrid($smarty); $oGrid->setTitle(_tr('PortKnock Interface Authorizations')); $oGrid->setColumns(array('', _tr('IP'), _tr('User'), _tr('Ports'), _tr('Since'))); $oGrid->deleteList(_tr('Are you sure you wish to revoke this authorization?'), 'delete', _tr('Revoke authorization')); if (isset($_POST['delete']) && isset($_POST['id_user_ip'])) { $l = explode('-', $_POST['id_user_ip']); if (count($l) >= 2) { $bExito = $pk->removeAuthorizationsUserInterface($l[0], $l[1]); if (!$bExito) { $smarty->assign("mb_title", _tr("Error")); $smarty->assign("mb_message", $pk->errMsg); } else { Header("Location: ?menu={$module_name}"); return NULL; } } } $recordset = $pk->listAuthorizationsInterface($eth_in); $data = array(); if (is_array($recordset)) { foreach ($recordset as $id_user => $auth_user) { $userinfo = $pACL->getUsers($id_user); foreach ($auth_user as $ip_source => $auth_ips) { $listaProto = array(); $ruleStart = NULL; foreach ($auth_ips as $id_auth => $info_auth) { $listaProto[] = $info_auth['name']; $ruleStart = $info_auth['rule_start']; } $data[] = array('<input type="radio" name="id_user_ip" value="' . $id_user . '-' . $ip_source . '" />', $ip_source, $userinfo[0][1], implode(' ', $listaProto), $ruleStart); } } } $oGrid->pagingShow(false); $url = array("menu" => $module_name); $oGrid->setURL($url); $oGrid->setData($data); return $oGrid->fetchGrid(); }
function reportWeakKeys($smarty, $module_name, $local_templates_dir, &$pDB, $arrConf) { $pWeakKeys = new paloSantoWeakKeys($pDB); $filter_field = getParameter("filter_field"); $filter_value = getParameter("filter_value"); //begin grid parameters $oGrid = new paloSantoGrid($smarty); $total = $pWeakKeys->getNumWeakKeys($filter_field, $filter_value); $pDB2 = new paloDB($arrConf['elastix_dsn']['acl']); $pACL = new paloACL($pDB2); $oGrid->enableExport(); // enable csv export. $oGrid->pagingShow(true); // show paging section. $oGrid->setTitle(_tr("Weak Secrets")); $oGrid->setIcon("modules/{$module_name}/images/security_weak_keys.png"); $oGrid->setNameFile_Export(_tr("Weak Secrets")); if ($oGrid->isExportAction()) { $limit = $total; $offset = 0; $bExportation = true; } else { $limit = 30; $oGrid->setLimit($limit); $oGrid->setTotal($total); $offset = $oGrid->calculateOffset(); $bExportation = false; } $url = array('menu' => $module_name, 'filter_field' => $filter_field, 'filter_value' => $filter_value); $oGrid->setURL($url); $arrResult = $pWeakKeys->getWeakKeys($limit, $offset, $filter_field, $filter_value); $arrData = null; //$arrResult =$pWeakKeys->getWeakKeysChecker(); $arrColumns = array(_tr("Extension"), _tr("Description"), _tr("Status")); $oGrid->setColumns($arrColumns); if (is_array($arrResult) && $total > 0) { foreach ($arrResult as $tech) { foreach ($tech as $key => $value) { $arrTmp[0] = $value['id']; $arrTmp[1] = $value['description']; $mensaje = getMensaje($value['id'], $value['data']); if ($mensaje != "OK" && !$bExportation) { if ($pACL->isUserAdministratorGroup($_SESSION['elastix_user']) || $pACL->getUserExtension($_SESSION['elastix_user']) == $value['id']) { $mensaje = _tr("Weak Key") . ": {$mensaje} <a href='?menu={$module_name}&action=change&id={$value['id']}'>" . _tr("Change Secret") . "</a>"; } } $arrTmp[2] = $mensaje; $arrData[] = $arrTmp; } } } $oGrid->setData($arrData); //begin section filter $arrFormFilterWeakKeys = createFieldFilter(); $oFilterForm = new paloForm($smarty, $arrFormFilterWeakKeys); $smarty->assign("SHOW", _tr("Show")); $_POST["filter_field"] = $filter_field; $_POST["filter_value"] = $filter_value; $oGrid->addFilterControl(_tr("Filter applied: ") . _tr("Extension") . " = " . $filter_value, $_POST, array("filter_field" => "extension", "filter_value" => "")); $htmlFilter = $oFilterForm->fetchForm("{$local_templates_dir}/filter.tpl", "", $_POST); //end section filter $oGrid->showFilter(trim($htmlFilter)); $content = $oGrid->fetchGrid(); //end grid parameters return $content; }
function _moduleContent(&$smarty, $module_name) { include_once "libs/paloSantoDB.class.php"; include_once "libs/paloSantoGrid.class.php"; include_once "libs/paloSantoACL.class.php"; include_once "modules/{$module_name}/configs/default.conf.php"; load_language_module($module_name); //global variables global $arrConf; global $arrConfModule; $arrConf = array_merge($arrConf, $arrConfModule); /////conexion a php $pDB = new paloDB($arrConf['elastix_dsn']['acl']); //folder path for custom templates $base_dir = dirname($_SERVER['SCRIPT_FILENAME']); $templates_dir = isset($arrConf['templates_dir']) ? $arrConf['templates_dir'] : 'themes'; $local_templates_dir = "{$base_dir}/modules/{$module_name}/" . $templates_dir . '/' . $arrConf['theme']; if (!empty($pDB->errMsg)) { echo "ERROR DE DB: {$pDB->errMsg} <br>"; } $arrData = array(); $pACL = new paloACL($pDB); if (!empty($pACL->errMsg)) { echo "ERROR DE ACL: {$pACL->errMsg} <br>"; } $arrFormElements = array("description" => array("LABEL" => _tr("Description"), "REQUIRED" => "yes", "INPUT_TYPE" => "TEXT", "INPUT_EXTRA_PARAM" => "", "VALIDATION_TYPE" => "text", "VALIDATION_EXTRA_PARAM" => ""), "group" => array("LABEL" => _tr("Group"), "REQUIRED" => "yes", "INPUT_TYPE" => "TEXT", "INPUT_EXTRA_PARAM" => "", "VALIDATION_TYPE" => "text", "VALIDATION_EXTRA_PARAM" => "")); //description id name $contenidoModulo = ""; $smarty->assign("REQUIRED_FIELD", _tr("Required field")); $smarty->assign("CANCEL", _tr("Cancel")); $smarty->assign("APPLY_CHANGES", _tr("Apply changes")); $smarty->assign("SAVE", _tr("Save")); $smarty->assign("EDIT", _tr("Edit")); $smarty->assign("DELETE", _tr("Delete")); $smarty->assign("icon", "modules/{$module_name}/images/system_groups.png"); $smarty->assign("CONFIRM_CONTINUE", _tr("Are you sure you wish to continue?")); if (isset($_POST['submit_create_group'])) { // Implementar include_once "libs/paloSantoForm.class.php"; $arrFillGroup['group'] = ''; $arrFillGroup['description'] = ''; $oForm = new paloForm($smarty, $arrFormElements); $contenidoModulo = $oForm->fetchForm("{$local_templates_dir}/grouplist.tpl", _tr("New Group"), $arrFillGroup); } else { if (isset($_POST['edit'])) { // Tengo que recuperar la data del usuario $pACL = new paloACL($pDB); $arrGroup = $pACL->getGroups($_POST['id_group']); if (!is_array($arrGroup)) { $contenidoModulo = ''; Header("Location: ?menu={$module_name}"); } else { if ($arrGroup[0][1] == 'administrator') { $arrGroup[0][1] = _tr('administrator'); } else { if ($arrGroup[0][1] == 'operator') { $arrGroup[0][1] = _tr('operator'); } else { if ($arrGroup[0][1] == 'extension') { $arrGroup[0][1] = _tr('extension'); } } } if ($arrGroup[0][2] == 'total access') { $arrGroup[0][2] = _tr('total access'); } else { if ($arrGroup[0][2] == 'operator') { $arrGroup[0][2] = _tr('operator'); } else { if ($arrGroup[0][2] == 'extension user') { $arrGroup[0][2] = _tr('extension user'); } } } $arrFillGroup['group'] = $arrGroup[0][1]; $arrFillGroup['description'] = $arrGroup[0][2]; // Implementar include_once "libs/paloSantoForm.class.php"; $oForm = new paloForm($smarty, $arrFormElements); $oForm->setEditMode(); $smarty->assign("id_group", htmlspecialchars($_POST['id_group'], ENT_COMPAT, 'UTF-8')); $contenidoModulo = $oForm->fetchForm("{$local_templates_dir}/grouplist.tpl", _tr('Edit Group') . " \"" . $arrFillGroup['group'] . "\"", $arrFillGroup); } } else { if (isset($_POST['submit_save_group'])) { include_once "libs/paloSantoForm.class.php"; $oForm = new paloForm($smarty, $arrFormElements); if ($oForm->validateForm($_POST)) { // Exito, puedo procesar los datos ahora. $pACL = new paloACL($pDB); // Creo el Grupo $pACL->createGroup($_POST['group'], $_POST['description']); if (!empty($pACL->errMsg)) { // Ocurrio algun error aqui $smarty->assign("mb_message", "ERROR: {$pACL->errMsg}"); $contenidoModulo = $oForm->fetchForm("{$local_templates_dir}/grouplist.tpl", _tr("New Group"), $_POST); } else { header("Location: ?menu=grouplist"); } } else { // Error $smarty->assign("mb_title", _tr("Validation Error")); $arrErrores = $oForm->arrErroresValidacion; $strErrorMsg = "<b>" . _tr('The following fields contain errors') . ":</b><br>"; foreach ($arrErrores as $k => $v) { $strErrorMsg .= "{$k}, "; } $strErrorMsg .= ""; $smarty->assign("mb_message", $strErrorMsg); $contenidoModulo = $oForm->fetchForm("{$local_templates_dir}/grouplist.tpl", _tr("New Group"), $_POST); } } else { if (isset($_POST['submit_apply_changes'])) { $arrGroup = $pACL->getGroups($_POST['id_group']); if (!is_array($arrGroup)) { $contenidoModulo = ''; Header("Location: ?menu={$module_name}"); } else { $group = $arrGroup[0][1]; $description = $arrGroup[0][2]; include_once "libs/paloSantoForm.class.php"; $oForm = new paloForm($smarty, $arrFormElements); $oForm->setEditMode(); if ($oForm->validateForm($_POST)) { // Exito, puedo procesar los datos ahora. $pACL = new paloACL($pDB); if (!$pACL->updateGroup($_POST['id_group'], $_POST['group'], $_POST['description'])) { // Ocurrio algun error aqui $smarty->assign("mb_message", "ERROR: {$pACL->errMsg}"); $contenidoModulo = $oForm->fetchForm("{$local_templates_dir}/grouplist.tpl", _tr("Edit Group"), $_POST); } else { header("Location: ?menu=grouplist"); } } else { // Manejo de Error $smarty->assign("mb_title", _tr("Validation Error")); $arrErrores = $oForm->arrErroresValidacion; $strErrorMsg = "<b>" . _tr('The following fields contain errors') . ":</b><br>"; foreach ($arrErrores as $k => $v) { $strErrorMsg .= "{$k}, "; } $strErrorMsg .= ""; $smarty->assign("mb_message", $strErrorMsg); $arrFillGroup['group'] = $_POST['group']; $arrFillGroup['description'] = $_POST['description']; $smarty->assign("id_group", htmlspecialchars($_POST['id_group'], ENT_COMPAT, 'UTF-8')); $contenidoModulo = $oForm->fetchForm("{$local_templates_dir}/grouplist.tpl", _tr("Edit Group"), $arrFillGroup); } } } else { if (isset($_GET['action']) && $_GET['action'] == "view") { include_once "libs/paloSantoForm.class.php"; $oForm = new paloForm($smarty, $arrFormElements); //- TODO: Tengo que validar que el id sea valido, si no es valido muestro un mensaje de error $oForm->setViewMode(); // Esto es para activar el modo "preview" $arrGroup = $pACL->getGroups($_GET['id']); if (!is_array($arrGroup)) { $contenidoModulo = ''; Header("Location: ?menu={$module_name}"); } else { // Conversion de formato if ($arrGroup[0][1] == 'administrator') { $arrGroup[0][1] = _tr('administrator'); } else { if ($arrGroup[0][1] == 'operator') { $arrGroup[0][1] = _tr('operator'); } else { if ($arrGroup[0][1] == 'extension') { $arrGroup[0][1] = _tr('extension'); } } } if ($arrGroup[0][2] == 'total access') { $arrGroup[0][2] = _tr('total access'); } else { if ($arrGroup[0][2] == 'operator') { $arrGroup[0][2] = _tr('operator'); } else { if ($arrGroup[0][2] == 'extension user') { $arrGroup[0][2] = _tr('extension user'); } } } $arrTmp['group'] = $arrGroup[0][1]; $arrTmp['description'] = $arrGroup[0][2]; $smarty->assign("id_group", htmlspecialchars($_GET['id'], ENT_COMPAT, 'UTF-8')); $contenidoModulo = $oForm->fetchForm("{$local_templates_dir}/grouplist.tpl", _tr("View Group"), $arrTmp); // hay que pasar el arreglo } } else { if (isset($_POST['delete'])) { //- TODO: Validar el id de group if (isset($_POST['id_group']) && $_POST['id_group'] == '1') { // No se puede eliminar al grupo admin $smarty->assign("mb_message", _tr("The administrator group cannot be deleted because is the default Elastix Group. You can delete any other group.")); } else { if ($pACL->HaveUsersTheGroup($_POST['id_group']) == TRUE) { $smarty->assign("mb_message", _tr("The Group have users assigned. You can delete any group that does not have any users assigned in it.")); } else { $pACL->deleteGroup($_POST['id_group']); } } } $nav = getParameter("nav"); $start = getParameter("start"); $total = $pACL->getNumGroups(); $total = $total == NULL ? 0 : $total; $limit = 20; $oGrid = new paloSantoGrid($smarty); $oGrid->setLimit($limit); $oGrid->setTotal($total); $oGrid->pagingShow(true); $oGrid->setURL("?menu=grouplist"); $offset = $oGrid->calculateOffset(); $end = $oGrid->getEnd(); $arrGroups = $pACL->getGroupsPaging($limit, $offset); $end = count($arrGroups); $arrData = array(); foreach ($arrGroups as $group) { $arrTmp = array(); if ($group[1] == 'administrator') { $group[1] = _tr('administrator'); } else { if ($group[1] == 'operator') { $group[1] = _tr('operator'); } else { if ($group[1] == 'extension') { $group[1] = _tr('extension'); } } } if ($group[2] == 'total access') { $group[2] = _tr('total access'); } else { if ($group[2] == 'operator') { $group[2] = _tr('operator'); } else { if ($group[2] == 'extension user') { $group[2] = _tr('extension user'); } } } $arrTmp[0] = " <a href='?menu=grouplist&action=view&id=" . $group[0] . "'>" . $group[1] . "</a>"; //id_group name $arrTmp[1] = $group[2]; //description $arrData[] = $arrTmp; } $arrGrid = array("title" => _tr("Group List"), "icon" => "/modules/{$module_name}/images/system_groups.png", "columns" => array(0 => array("name" => _tr("Group"), "property1" => ""), 1 => array("name" => _tr("Description"), "property1" => ""))); $oGrid->addNew("submit_create_group", _tr("Create New Group")); $contenidoModulo = $oGrid->fetchGrid($arrGrid, $arrData); } } } } } return $contenidoModulo; }
function reportMonitoring($smarty, $module_name, $local_templates_dir, &$pDB, $pACL, $arrConf, $user, $extension, $esAdministrador) { $pMonitoring = new paloSantoMonitoring($pDB); //var_dump($arrConfg); $pMonitoring->setConfig($arrConf); $filter_field = getParameter("filter_field"); switch ($filter_field) { case "dst": $filter_field = "dst"; $nameFilterField = _tr("Destination"); break; case "userfield": $filter_field = "userfield"; $nameFilterField = _tr("Type"); break; default: $filter_field = "src"; $nameFilterField = _tr("Source"); break; } if ($filter_field == "userfield") { $filter_value = getParameter("filter_value_userfield"); $filter = ""; $filter_userfield = $filter_value; } else { $filter_value = getParameter("filter_value"); $filter = $filter_value; $filter_userfield = ""; } switch ($filter_value) { case "outgoing": $smarty->assign("SELECTED_2", "Selected"); $nameFilterUserfield = _tr("Outgoing"); break; case "queue": $smarty->assign("SELECTED_3", "Selected"); $nameFilterUserfield = _tr("Queue"); break; case "group": $smarty->assign("SELECTED_4", "Selected"); $nameFilterUserfield = _tr("Group"); break; default: $smarty->assign("SELECTED_1", "Selected"); $nameFilterUserfield = _tr("Incoming"); break; } $date_ini = getParameter("date_start"); $date_end = getParameter("date_end"); $path_record = $arrConf['records_dir']; $_POST['date_start'] = isset($date_ini) ? $date_ini : date("d M Y"); $_POST['date_end'] = isset($date_end) ? $date_end : date("d M Y"); if ($date_ini === "") { $_POST['date_start'] = " "; } if ($date_end === "") { $_POST['date_end'] = " "; } if (!empty($pACL->errMsg)) { echo "ERROR DE ACL: {$pACL->errMsg} <br>"; } $date_initial = date('Y-m-d', strtotime($_POST['date_start'])) . " 00:00:00"; $date_final = date('Y-m-d', strtotime($_POST['date_end'])) . " 23:59:59"; $_DATA = $_POST; //begin grid parameters $oGrid = new paloSantoGrid($smarty); $oGrid->setTitle(_tr("Monitoring")); $oGrid->setIcon("modules/{$module_name}/images/pbx_monitoring.png"); $oGrid->pagingShow(true); // show paging section. $oGrid->enableExport(); // enable export. $oGrid->setNameFile_Export(_tr("Monitoring")); if ($esAdministrador) { $totalMonitoring = $pMonitoring->getNumMonitoring($filter_field, $filter_value, null, $date_initial, $date_final); } elseif (!($extension == "" || is_null($extension))) { $totalMonitoring = $pMonitoring->getNumMonitoring($filter_field, $filter_value, $extension, $date_initial, $date_final); } else { $totalMonitoring = 0; } $url = array('menu' => $module_name); $paramFilter = array('filter_field' => $filter_field, 'filter_value' => $filter, 'filter_value_userfield' => $filter_userfield, 'date_start' => $_POST['date_start'], 'date_end' => $_POST['date_end']); $url = array_merge($url, $paramFilter); $oGrid->setURL($url); $arrData = null; if ($oGrid->isExportAction()) { $limit = $totalMonitoring; $offset = 0; $arrColumns = array(_tr("Date"), _tr("Time"), _tr("Source"), _tr("Destination"), _tr("Duration"), _tr("Type"), _tr("File")); $oGrid->setColumns($arrColumns); if ($esAdministrador) { $arrResult = $pMonitoring->getMonitoring($limit, $offset, $filter_field, $filter_value, null, $date_initial, $date_final); } elseif (!($extension == "" || is_null($extension))) { $arrResult = $pMonitoring->getMonitoring($limit, $offset, $filter_field, $filter_value, $extension, $date_initial, $date_final); } else { $arrResult = array(); } if (is_array($arrResult) && $totalMonitoring > 0) { foreach ($arrResult as $key => $value) { $arrTmp[0] = date('d M Y', strtotime($value['calldate'])); $arrTmp[1] = date('H:i:s', strtotime($value['calldate'])); $arrTmp[2] = $value['src']; $arrTmp[3] = $value['dst']; $arrTmp[4] = $value['dstchannel']; $arrTmp[5] = SecToHHMMSS($value['duration']); $file = $value['uniqueid']; $namefile = basename($value['userfield']); $namefile = str_replace("audio:", "", $namefile); if ($namefile == 'deleted') { $arrTmp[6] = _tr('Deleted'); } else { switch ($namefile[0]) { case "O": $arrTmp[6] = _tr("Outgoing"); break; case "g": $arrTmp[6] = _tr("Group"); break; case "q": $arrTmp[6] = _tr("Queue"); break; default: $arrTmp[6] = _tr("Incoming"); break; } } $arrTmp[7] = $namefile; $arrTmp[8] = $value['note']; $arrTmp[9] = $value['delivery_id']; $arrData[] = $arrTmp; } } } else { $limit = 20; $total = $totalMonitoring; $oGrid->setLimit($limit); $oGrid->setTotal($total); $offset = $oGrid->calculateOffset(); if ($esAdministrador) { $oGrid->deleteList(_tr("message_alert"), 'submit_eliminar', _tr("Delete")); $buttonDelete = ""; } else { $buttonDelete = ""; } $arrColumns = array($buttonDelete, "Ngày", "Giờ", "Gọi từ", "Gọi đến", "Nhân viên/PSTN", "Thời gian gọi", "Loại", "Ghi âm", "Nội dung", "Giao vé"); $oGrid->setColumns($arrColumns); if ($esAdministrador) { $arrResult = $pMonitoring->getMonitoring($limit, $offset, $filter_field, $filter_value, null, $date_initial, $date_final); } elseif (!($extension == "" || is_null($extension))) { $arrResult = $pMonitoring->getMonitoring($limit, $offset, $filter_field, $filter_value, $extension, $date_initial, $date_final); } else { $arrResult = array(); } if (is_array($arrResult) && $total > 0) { $src = ""; $dst = ""; foreach ($arrResult as $key => $value) { if ($esAdministrador) { $arrTmp[0] = "<input type='checkbox' name='id_" . $value['uniqueid'] . "' />"; } else { $arrTmp[0] = ""; } $arrTmp[1] = date('d M Y', strtotime($value['calldate'])); $arrTmp[2] = date('H:i:s', strtotime($value['calldate'])); if (!isset($value['src']) || $value['src'] == "") { $src = "<font color='gray'>" . _tr("unknown") . "</font>"; } else { $src = $value['src']; } if (!isset($value['dst']) || $value['dst'] == "") { $dst = "<font color='gray'>" . _tr("unknown") . "</font>"; } else { $dst = $value['dst']; } $arrTmp[3] = $src; $arrTmp[4] = $dst; $arrTmp[5] = channel_lookup($pDB, $value['dstchannel']); $arrTmp[6] = "<label title='" . $value['duration'] . " seconds' style='color:green'>" . SecToHHMMSS($value['duration']) . "</label>"; //$file = base64_encode($value['userfield']); $file = $value['uniqueid']; $namefile = basename($value['userfield']); $namefile = str_replace("audio:", "", $namefile); if ($namefile == 'deleted') { $arrTmp[7] = _tr('Deleted'); } else { switch ($namefile[0]) { case "O": $arrTmp[7] = _tr("Outgoing"); break; case "g": $arrTmp[7] = _tr("Group"); break; case "q": $arrTmp[7] = _tr("Queue"); break; default: $arrTmp[7] = _tr("Incoming"); break; } } if ($namefile != 'deleted') { $recordingLink = "<a href=\"javascript:popUp('index.php?menu={$module_name}&action=display_record&id={$file}&namefile={$namefile}&rawmode=yes',350,100);\">" . _tr("Listen") . "</a> "; $recordingLink .= "<a href='?menu={$module_name}&action=download&id={$file}&namefile={$namefile}&rawmode=yes' >" . _tr("Download") . "</a>"; } else { $recordingLink = ''; } $arrTmp[8] = $recordingLink; $arrTmp[9] = is_null($value['note_id']) ? '-' : '<a href="javascript:void(0)" onclick="view_note(\'' . $value['note_id'] . '\')">Xem</a>'; $arrTmp[10] = is_null($value['delivery_id']) ? '-' : '<a href="javascript:void(0)" onclick="view_delivery(\'' . $value['delivery_id'] . '\')">Xem</a>'; $arrData[] = $arrTmp; } } } $oGrid->setData($arrData); //begin section filter $arrFormFilterMonitoring = createFieldFilter(); $oFilterForm = new paloForm($smarty, $arrFormFilterMonitoring); $smarty->assign("INCOMING", _tr("Incoming")); $smarty->assign("OUTGOING", _tr("Outgoing")); $smarty->assign("QUEUE", _tr("Queue")); $smarty->assign("GROUP", _tr("Group")); $smarty->assign("SHOW", _tr("Show")); $_POST["filter_field"] = $filter_field; $_POST["filter_value"] = $filter; $_POST["filter_value_userfield"] = $filter_userfield; $oGrid->addFilterControl(_tr("Filter applied ") . _tr("Start Date") . " = " . $paramFilter['date_start'] . ", " . _tr("End Date") . " = " . $paramFilter['date_end'], $paramFilter, array('date_start' => date("d M Y"), 'date_end' => date("d M Y")), true); if ($filter_field == "userfield") { $oGrid->addFilterControl(_tr("Filter applied ") . " {$nameFilterField} = {$nameFilterUserfield}", $_POST, array('filter_field' => "src", 'filter_value_userfield' => "incoming")); } else { $oGrid->addFilterControl(_tr("Filter applied ") . " {$nameFilterField} = {$filter}", $_POST, array('filter_field' => "src", "filter_value" => "")); } $htmlFilter = $oFilterForm->fetchForm("{$local_templates_dir}/filter.tpl", "", $_POST); //end section filter $oGrid->showFilter(trim($htmlFilter)); $content = $oGrid->fetchGrid(); //end grid parameters return $content; }
function reportClientesagendados($smarty, $module_name, $local_templates_dir, &$pDB, $arrConf) { $pClientesagendados = new paloSantoClientesagendados($pDB); $filter_field = getParameter("filter_field"); $filter_value = getParameter("filter_value"); //begin grid parameters $oGrid = new paloSantoGrid($smarty); $oGrid->setTplFile("/var/www/html/modules/{$module_name}/themes/default/_list.tpl"); $oGrid->setTitle(_tr("Clientes agendados")); $oGrid->pagingShow(true); // show paging section. $oGrid->enableExport(); // enable export. $oGrid->setNameFile_Export(_tr("Clientes agendados")); $url = array("menu" => $module_name, "filter_field" => $filter_field, "filter_value" => $filter_value); $oGrid->setURL($url); $arrColumns = array(_tr("Apellido"), _tr("Nombre"), _tr("CI"), _tr("Campaña"), _tr("Fecha de agendamiento"), _tr("Call type"), _tr("Agente agendado"), "<input class=\"button\" type=\"submit\" name=\"action\" value=\"Reasignar\">"); $oGrid->setColumns($arrColumns); $total = $pClientesagendados->getNumClientesagendados($filter_field, $filter_value); $arrData = null; if ($oGrid->isExportAction()) { $limit = $total; // max number of rows. $offset = 0; // since the start. } else { $limit = 20; $oGrid->setLimit($limit); $oGrid->setTotal($total); $offset = $oGrid->calculateOffset(); } $arrResult = $pClientesagendados->getClientesagendados($limit, $offset, $filter_field, $filter_value); if (is_array($arrResult) && $total > 0) { foreach ($arrResult as $key => $value) { $arrTmp[0] = $value['apellido']; $arrTmp[1] = $value['nombre']; $arrTmp[2] = $value['ci']; $arrTmp[3] = $value['nombre_campania']; $arrTmp[4] = $value['fecha_agendamiento']; $arrTmp[5] = $value['ultimo_calltype']; $arrTmp[6] = $value['agente_agendado']; if (empty($value['id_campania_cliente'])) { $arrTmp[7] = getFormSelectAgentesCampaniaRecargable($pClientesagendados, $value['id_campania'], $value['id_campania_recargable_cliente'], $value['agente_agendado']); } else { $arrTmp[7] = getFormSelectAgentesCampania($pClientesagendados, $value['id_campania'], $value['id_campania_cliente'], $value['agente_agendado']); } $arrData[] = $arrTmp; } } $oGrid->setData($arrData); //begin section filter $oFilterForm = new paloForm($smarty, createFieldFilter()); $smarty->assign("SHOW", _tr("Show")); $htmlFilter = $oFilterForm->fetchForm("{$local_templates_dir}/filter.tpl", "", $_POST); //end section filter $oGrid->showFilter(trim($htmlFilter)); $content = $oGrid->fetchGrid(); //end grid parameters return $content; }
function showLanguages($smarty, $module_name, $local_templates_dir, $arrLang, $arrLangModule) { //$oPaloSanto = new paloSantoLanguageAdmin(); $pLanguages = new paloSantoLanguageAdmin(); $arrFormElements = array("module" => array("LABEL" => $arrLangModule["Select Module"], "REQUIRED" => "no", "INPUT_TYPE" => "SELECT", "INPUT_EXTRA_PARAM" => $pLanguages->leer_directorio_modulos(), "VALIDATION_TYPE" => "text", "VALIDATION_EXTRA_PARAM" => ""), "language" => array("LABEL" => $arrLangModule["Select Language"], "REQUIRED" => "no", "INPUT_TYPE" => "SELECT", "INPUT_EXTRA_PARAM" => $pLanguages->leer_directorio_lenguajes(), "VALIDATION_TYPE" => "text", "VALIDATION_EXTRA_PARAM" => "")); $oFilterForm = new paloForm($smarty, $arrFormElements); $smarty->assign("SHOW", $arrLang["Show"]); $smarty->assign("SAVE_ALL", "Save All"); $module = getParameter("module"); $language = getParameter("language"); $action = getParameter('nav'); $start = getParameter('start'); $smarty->assign("start_value", $start); $smarty->assign("nav_value", $action); $_POST["module"] = $module; $_POST["language"] = $language; $oGrid = new paloSantoGrid($smarty); if (!is_null($module) && !is_null($language)) { $nameModule = $arrFormElements["module"]["INPUT_EXTRA_PARAM"][$module]; $valueLanguage = $arrFormElements["language"]["INPUT_EXTRA_PARAM"][$language]; } else { $nameModule = ""; $valueLanguage = ""; } $oGrid->addFilterControl(_tr("Filter applied: ") . $nameModule . " = " . $valueLanguage, $_POST, array("module" => null, "language" => null)); $htmlFilter = $oFilterForm->fetchForm("{$local_templates_dir}/filter.tpl", "", $_POST); //Paginacion $limit = 20; $total_datos = $pLanguages->ObtainNumLanguages($module, $language); $total = $total_datos; $oGrid->addNew("new", _tr("Add")); $oGrid->customAction("save_all", _tr("Save All")); $oGrid->setLimit($limit); $oGrid->setTotal($total); $oGrid->setTitle(_tr("Language Admin")); $oGrid->setIcon("images/list.png"); $oGrid->pagingShow(true); $offset = $oGrid->calculateOffset(); $url = "?menu={$module_name}&module={$module}&language={$language}"; $oGrid->setURL($url); $arrColumns = array(_tr("Key"), _tr("Value")); $oGrid->setColumns($arrColumns); $arrLangMod = $pLanguages->obtainLanguages($limit, $offset, $module, $language); $arrData = array(); $counter = 1; if (is_array($arrLangMod) && count($arrLangMod) > 0) { foreach ($arrLangMod as $key => $value) { $tmpKey = htmlspecialchars($key); $tmpValue = htmlspecialchars($value); $arrTmp[0] = $tmpKey; $arrTmp[1] = "<input class='table_data' style='width:450px' type='text' name=\"langvalue_{$counter}\" id=\"langvalue_{$counter}\" value=\"{$tmpValue}\" /><input type='hidden' name='langkey_{$counter}' id='langkey_{$counter}' value='{$tmpKey}'>"; $counter++; $arrData[] = $arrTmp; } } $oGrid->setData($arrData); $oGrid->showFilter(trim($htmlFilter)); $moduleContent = $oGrid->fetchGrid(); if (strpos($moduleContent, '<form') === FALSE) { $moduleContent = "<form method='POST' style='margin-bottom:0;' action={$url}>{$moduleContent}</form>"; } return $moduleContent; }
function reportPuertos($smarty, $module_name, $local_templates_dir, &$pDB, $arrConf) { $pPuertos = new paloSantoPortService($pDB); $field_type = getParameter("filter_type"); $field_pattern = getParameter("filter_txt"); //begin grid parameters $oGrid = new paloSantoGrid($smarty); $oGrid->addNew("new", _tr("Define Port")); $oGrid->deleteList("Are you sure you wish to delete the port(s).?", "delete", _tr("Delete")); $totalPuertos = $pPuertos->ObtainNumPuertos($field_type, $field_pattern); $limit = 20; $total = $totalPuertos; $oGrid->setLimit($limit); $oGrid->setTotal($total); $oGrid->setTitle(_tr("Define Ports")); $oGrid->setIcon("modules/{$module_name}/images/security_define_ports.png"); $oGrid->pagingShow(true); $offset = $oGrid->calculateOffset(); $url = array("menu" => $module_name, "filter_type" => $field_type, "filter_txt" => $field_pattern); $oGrid->setURL($url); $arrData = null; $arrResult = $pPuertos->ObtainPuertos($limit, $offset, $field_type, $field_pattern); $button_eliminar = ""; $arrColumns = array($button_eliminar, _tr("Name"), _tr("Protocol"), _tr("Details"), _tr("Option")); $oGrid->setColumns($arrColumns); if (is_array($arrResult) && $total > 0) { foreach ($arrResult as $key => $value) { $arrTmp[0] = "<input type='checkbox' name='" . $value['id'] . "' id='" . $value['id'] . "'>"; $arrTmp[1] = $value['name']; $arrTmp[2] = $value['protocol']; if ($value['protocol'] == "TCP" || $value['protocol'] == "UDP") { $port = $value['details']; $arrTmp[3] = stripos($port, ":") === false ? _tr('Port') . " " . $value['details'] : _tr('Ports') . " " . $value['details']; } elseif ($value['protocol'] == "ICMP") { $arr = explode(":", $value['details']); if (isset($arr[1])) { $arrTmp[3] = "Type: " . $arr[0] . " Code: " . $arr[1]; } } else { $arrTmp[3] = "Protocol Number: " . $value['details']; } $arrTmp[4] = " <a href='?menu={$module_name}&action=view&id=" . $value['id'] . "'>" . _tr('View') . "</a>"; $arrData[] = $arrTmp; } } $oGrid->setData($arrData); //begin section filter $arrFormFilterPuertos = createFieldForm(); $oFilterForm = new paloForm($smarty, $arrFormFilterPuertos); $smarty->assign("SHOW", _tr("Show")); $_POST["filter_type"] = $field_type; $_POST["filter_txt"] = $field_pattern; if (is_null($field_type) || $field_type == "") { $nameFieldType = ""; } else { $nameFieldType = $arrFormFilterPuertos["filter_type"]["INPUT_EXTRA_PARAM"][$field_type]; } $oGrid->addFilterControl(_tr("Filter applied: ") . $nameFieldType . " = " . $field_pattern, $_POST, array("filter_type" => "name", "filter_txt" => "x")); $htmlFilter = $oFilterForm->fetchForm("{$local_templates_dir}/filter.tpl", "", $_POST); //end section filter $oGrid->showFilter(trim($htmlFilter)); $contenidoModulo = $oGrid->fetchGrid(); if (strpos($contenidoModulo, '<form') === FALSE) { $contenidoModulo = "<form method='POST' style='margin-bottom:0;' action={$url}>{$contenidoModulo}</form>"; } //end grid parameters return $contenidoModulo; }
function listarFaxes(&$smarty, $module_name, $local_templates_dir) { $smarty->assign(array('SEARCH' => _tr('Search'))); $oFax = new paloFaxVisor(); // Generación del filtro $oFilterForm = new paloForm($smarty, getFormElements()); // Parámetros base y validación de parámetros $url = array('menu' => $module_name); $paramFiltroBase = $paramFiltro = array('name_company' => '', 'fax_company' => '', 'date_fax' => NULL, 'filter' => 'All'); foreach (array_keys($paramFiltro) as $k) { if (!is_null(getParameter($k))) { $paramFiltro[$k] = getParameter($k); } } $oGrid = new paloSantoGrid($smarty); $arrType = array("All" => _tr('All'), "In" => _tr('in'), "Out" => _tr('out')); $oGrid->addFilterControl(_tr("Filter applied ") . _tr("Company Name") . " = " . $paramFiltro['name_company'], $paramFiltro, array("name_company" => "")); $oGrid->addFilterControl(_tr("Filter applied ") . _tr("Company Fax") . " = " . $paramFiltro['fax_company'], $paramFiltro, array("fax_company" => "")); $oGrid->addFilterControl(_tr("Filter applied ") . _tr("Fax Date") . " = " . $paramFiltro['date_fax'], $paramFiltro, array("date_fax" => NULL)); $oGrid->addFilterControl(_tr("Filter applied ") . _tr("Type Fax") . " = " . $arrType[$paramFiltro['filter']], $paramFiltro, array("filter" => "All"), true); $htmlFilter = $oFilterForm->fetchForm("{$local_templates_dir}/filter.tpl", "", $paramFiltro); if (!$oFilterForm->validateForm($paramFiltro)) { $smarty->assign(array('mb_title' => _tr('Validation Error'), 'mb_message' => '<b>' . _tr('The following fields contain errors') . ':</b><br/>' . implode(', ', array_keys($oFilterForm->arrErroresValidacion)))); $paramFiltro = $paramFiltroBase; unset($_POST['faxes_delete']); // Se aborta el intento de borrar faxes, si había uno. } $url = array_merge($url, $paramFiltro); // Ejecutar el borrado, si se ha validado. if (isset($_POST['faxes_delete']) && isset($_POST['faxes']) && is_array($_POST['faxes']) && count($_POST['faxes']) > 0) { $msgError = NULL; foreach ($_POST['faxes'] as $idFax) { if (!$oFax->deleteInfoFax($idFax)) { if ($oFax->errMsg = '') { $msgError = _tr('Unable to eliminate pdf file from the path.'); } else { $msgError = _tr('Unable to eliminate pdf file from the database.') . ' - ' . $oFax->errMsg; } } } if (!is_null($msgError)) { $smarty->assign(array('mb_title' => _tr('ERROR'), 'mb_message' => $oFax->errMsg)); } } $oGrid->setTitle(_tr("Fax Viewer")); $oGrid->setIcon("modules/{$module_name}/images/kfaxview.png"); $oGrid->pagingShow(true); // show paging section. $oGrid->setURL($url); $arrData = NULL; $total = $oFax->obtener_cantidad_faxes($paramFiltro['name_company'], $paramFiltro['fax_company'], $paramFiltro['date_fax'], $paramFiltro['filter']); $limit = 20; $oGrid->setLimit($limit); $oGrid->setTotal($total); $offset = $oGrid->calculateOffset(); $arrResult = $oFax->obtener_faxes($paramFiltro['name_company'], $paramFiltro['fax_company'], $paramFiltro['date_fax'], $offset, $limit, $paramFiltro['filter']); $oGrid->setColumns(array("", _tr('Type'), _tr('File'), _tr('Company Name'), _tr('Company Fax'), _tr('Fax Destiny'), _tr('Fax Date'), _tr('Status'), _tr('Options'))); if (is_array($arrResult) && $total > 0) { foreach ($arrResult as $fax) { foreach (array('pdf_file', 'company_name', 'company_fax', 'destiny_name', 'destiny_fax', 'errormsg') as $k) { $fax[$k] = htmlentities($fax[$k], ENT_COMPAT, 'UTF-8'); } if (empty($fax['status']) && !empty($fax['errormsg'])) { $fax['status'] = 'failed'; } $arrData[] = array('<input type="checkbox" name="faxes[]" value="' . $fax['id'] . '" />', _tr($fax['type']), strtolower($fax['type']) == 'in' || strpos($fax['pdf_file'], '.pdf') !== FALSE ? "<a href='?menu={$module_name}&action=download&id=" . $fax['id'] . "&rawmode=yes'>" . $fax['pdf_file'] . "</a>" : $fax['pdf_file'], $fax['company_name'], $fax['company_fax'], $fax['destiny_name'] . " - " . $fax['destiny_fax'], $fax['date'], _tr($fax['status']) . (empty($fax['errormsg']) ? '' : ': ' . $fax['errormsg']), "<a href='?menu={$module_name}&action=edit&id=" . $fax['id'] . "'>" . _tr('Edit') . "</a>"); } } if (!is_array($arrResult)) { $smarty->assign(array('mb_title' => _tr('ERROR'), 'mb_message' => $oFax->errMsg)); } $oGrid->setData($arrData); $oGrid->deleteList(_tr('Are you sure you wish to delete fax (es)?'), "faxes_delete", _tr("Delete")); $oGrid->showFilter($htmlFilter); return $oGrid->fetchGrid(); }
function _moduleContent(&$smarty, $module_name) { //include module files include_once "modules/{$module_name}/configs/default.conf.php"; include_once "modules/{$module_name}/libs/paloSantoCallsDetail.class.php"; include_once "modules/agent_console/getinfo.php"; global $arrConf; load_language_module($module_name); //folder path for custom templates $base_dir = dirname($_SERVER['SCRIPT_FILENAME']); $templates_dir = isset($arrConfig['templates_dir']) ? $arrConfig['templates_dir'] : 'themes'; $local_templates_dir = "{$base_dir}/modules/{$module_name}/" . $templates_dir . '/' . $arrConf['theme']; // added by Tri Do $sAction = getParameter('action'); switch ($sAction) { case 'viewNote': return viewNote(); break; case 'viewDelivery': return view_delivery(); break; default: break; } // Cadenas estáticas de Smarty $smarty->assign(array("Filter" => _tr('Filter'), "SHOW" => _tr("Show"))); $bElastixNuevo = method_exists('paloSantoGrid', 'setURL'); // Variables iniciales para posición de grid $offset = 0; $limit = 50; $total = 0; // Para poder consultar las colas activas $pConfig = new paloConfig("/etc", "amportal.conf", "=", "[[:space:]]*=[[:space:]]*"); $ampconfig = $pConfig->leer_configuracion(false); $ampdsn = $ampconfig['AMPDBENGINE']['valor'] . "://" . $ampconfig['AMPDBUSER']['valor'] . ":" . $ampconfig['AMPDBPASS']['valor'] . "@" . $ampconfig['AMPDBHOST']['valor'] . "/asterisk"; $oQueue = new paloQueue($ampdsn); $listaColas = $oQueue->getQueue(); if (!is_array($listaColas)) { $smarty->assign("mb_title", _tr("Error when connecting to database")); $smarty->assign("mb_message", $oQueue->errMsg); } // Para poder consultar los agentes de campañas $pDB = new paloDB($cadena_dsn); $oCallsDetail = new paloSantoCallsDetail($pDB); $listaAgentes = $oCallsDetail->getAgents(); // Para llenar el select de agentes $urlVars = array('menu' => $module_name); $arrFormElements = createFieldFilter($listaAgentes, $listaColas); $oFilterForm = new paloForm($smarty, $arrFormElements); // Validar y aplicar las variables de filtro $paramLista = NULL; $paramFiltro = array(); foreach (array('date_start', 'date_end', 'calltype', 'agent', 'queue', 'phone') as $k) { $paramFiltro[$k] = getParameter($k); } if (!isset($paramFiltro['date_start'])) { $paramFiltro['date_start'] = date("d M Y"); } if (!isset($paramFiltro['date_end'])) { $paramFiltro['date_end'] = date("d M Y"); } if (!$oFilterForm->validateForm($paramFiltro)) { // Hay un error al validar las variables del filtro $smarty->assign("mb_title", _tr("Validation Error")); $arrErrores = $oFilterForm->arrErroresValidacion; $strErrorMsg = "<b>" . _tr('The following fields contain errors') . ":</b><br>"; $strErrorMsg = implode(', ', array_keys($arrErrores)); $smarty->assign("mb_message", $strErrorMsg); } else { $urlVars = array_merge($urlVars, $paramFiltro); $paramLista = $paramFiltro; $paramLista['date_start'] = translateDate($paramFiltro['date_start']) . " 00:00:00"; $paramLista['date_end'] = translateDate($paramFiltro['date_end']) . " 23:59:59"; } $htmlFilter = $oFilterForm->fetchForm("{$local_templates_dir}/filter.tpl", "", $paramFiltro); // Inicio de objeto grilla y asignación de filtro $oGrid = new paloSantoGrid($smarty); $oGrid->enableExport(); // enable export. $oGrid->showFilter($htmlFilter); $bExportando = $bElastixNuevo ? $oGrid->isExportAction() : isset($_GET['exportcsv']) && $_GET['exportcsv'] == 'yes' || isset($_GET['exportspreadsheet']) && $_GET['exportspreadsheet'] == 'yes' || isset($_GET['exportpdf']) && $_GET['exportpdf'] == 'yes'; // Ejecutar la consulta con las variables ya validadas $arrData = array(); $total = 0; if (is_array($paramLista)) { $total = $oCallsDetail->contarDetalleLlamadas($paramLista); if (is_null($total)) { $smarty->assign("mb_title", _tr("Error when connecting to database")); $smarty->assign("mb_message", $oCallsDetail->errMsg); $total = 0; } else { // Habilitar la exportación de todo el contenido consultado if ($bExportando) { $limit = $total; } // Calcular el offset de la petición de registros if ($bElastixNuevo) { $oGrid->setLimit($limit); $oGrid->setTotal($total); $offset = $oGrid->calculateOffset(); } else { // Si se quiere avanzar a la sgte. pagina if (isset($_GET['nav']) && $_GET['nav'] == "end") { // Mejorar el sgte. bloque. if ($total % $limit == 0) { $offset = $total - $limit; } else { $offset = $total - $total % $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; } } // Ejecutar la consulta de los datos en el offset indicado $recordset = $oCallsDetail->leerDetalleLlamadas($paramLista, $limit, $offset); // add STT for ($i = 0; $i < count($recordset); $i++) { $recordset[$i]['stt'] = $i + 1; } if (!is_array($recordset)) { $smarty->assign("mb_title", _tr("Error when connecting to database")); $smarty->assign("mb_message", $oCallsDetail->errMsg); $total = 0; } else { function _calls_detail_map_recordset($cdr) { $mapaEstados = array('abandonada' => 'Bỏ nhỡ', 'Abandoned' => 'Bỏ nhỡ', 'terminada' => 'Đã nghe', 'Success' => 'Đã nghe', 'fin-monitoreo' => _tr('End Monitor'), 'Failure' => _tr('Failure'), 'NoAnswer' => _tr('NoAnswer'), 'OnQueue' => _tr('OnQueue'), 'Placing' => _tr('Placing'), 'Ringing' => _tr('Ringing'), 'ShortCall' => _tr('ShortCall'), 'activa' => 'Đang gọi'); return array($cdr['stt'], $cdr[0], htmlentities($cdr[1], ENT_COMPAT, "UTF-8"), substr($cdr[2], 0, 10), substr($cdr[2], 11, 8), substr($cdr[3], 0, 10), substr($cdr[3], 11, 8), is_null($cdr[4]) ? '-' : formatoSegundos($cdr[4]), is_null($cdr[5]) ? '-' : formatoSegundos($cdr[5]), $cdr[6], $cdr[8], $cdr[9], isset($mapaEstados[$cdr[10]]) ? $mapaEstados[$cdr[10]] : _tr($cdr[10]), is_null($cdr[12]) || trim($cdr[12] == '') ? '' : '<a href="javascript:void(0)" onclick="view_note(\'' . $cdr[11] . '\')">Xem</a>'); } $arrData = array_map('_calls_detail_map_recordset', $recordset); } } } $arrColumnas = array('STT', 'Số Agent', 'Nhân viên', _tr("Start Date"), _tr("Start Time"), _tr("End Date"), _tr("End Time"), "Thời lượng", _tr("Thời gian chờ"), _tr("Queue"), _tr("Số điện thoại"), _tr("Chuyển máy"), _tr("Status"), 'Nội dung'); if ($bElastixNuevo) { $oGrid->setURL(construirURL($urlVars, array("nav", "start"))); $oGrid->setData($arrData); $oGrid->setColumns($arrColumnas); $oGrid->setTitle('Chi tiết cuộc gọi Call Center'); $oGrid->pagingShow(true); $oGrid->setNameFile_Export(_tr("Calls Detail")); return $oGrid->fetchGrid(); } else { global $arrLang; $url = construirURL($urlVars, array("nav", "start")); function _map_name($s) { return array('name' => $s); } $arrGrid = array("title" => _tr("Calls Detail"), "url" => $url, "icon" => "images/user.png", "width" => "99%", "start" => $total == 0 ? 0 : $offset + 1, "end" => $offset + $limit <= $total ? $offset + $limit : $total, "total" => $total, "columns" => array_map('_map_name', $arrColumnas)); 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) { header("Cache-Control: private"); header("Pragma: cache"); // Se requiere para HTTPS bajo IE6 header('Content-disposition: inline; filename="calls_detail.csv"'); header("Content-Type: text/csv; charset=UTF-8"); } 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; } }
function reportRegestion($smarty, $module_name, $local_templates_dir, &$pDB, $arrConf) { $pRegestion = new paloSantoRegestion($pDB); $filter_field = getParameter("filter_field"); $filter_value = getParameter("filter_value"); //begin grid parameters $oGrid = new paloSantoGrid($smarty); $oGrid->setTitle(_tr("Regestión de campañas")); $oGrid->pagingShow(true); // show paging section. $oGrid->enableExport(); // enable export. $oGrid->setNameFile_Export(_tr("Regestión de campañas")); $url = array("menu" => $module_name, "filter_field" => $filter_field, "filter_value" => $filter_value); $oGrid->setURL($url); $arrColumns = array(_tr("Campaña padre"), _tr("Clase de calltypes"), _tr("Acción")); $oGrid->setColumns($arrColumns); $total = $pRegestion->getNumRegestion($filter_field, $filter_value); $arrData = null; if ($oGrid->isExportAction()) { $limit = $total; // max number of rows. $offset = 0; // since the start. } else { $limit = 20; $oGrid->setLimit($limit); $oGrid->setTotal($total); $offset = $oGrid->calculateOffset(); } $arrResult = $pRegestion->getRegestion($limit, $offset, $filter_field, $filter_value); if (is_array($arrResult) && $total > 0) { foreach ($arrResult as $key => $value) { $arrTmp[0] = $value['nombre']; $arrTmp[1] = "<form method='POST' action=\"index.php?menu={$module_name}\">"; $arrTmp[1] .= "<select name=\"clase_calltype\">\n\t\t\t <option value=\"Contactado\">Contactado</option>\n\t\t\t <option value=\"No contactado\">No contactado</option>\n\t\t\t <option value=\"Agendado\">Agendado</option>\n\t\t\t </select>"; $arrTmp[1] .= "<input type=hidden name=\"action\" value=\"view_edit\">"; $arrTmp[1] .= "<input type=hidden name=\"id\" value={$value['id']}>"; $arrTmp[2] = "<input type=submit value=\"Regestionar\">"; $arrTmp[2] .= "</form>"; $arrData[] = $arrTmp; } } $oGrid->setData($arrData); //begin section filter $oFilterForm = new paloForm($smarty, createFieldFilter()); $smarty->assign("SHOW", _tr("Show")); $htmlFilter = $oFilterForm->fetchForm("{$local_templates_dir}/filter.tpl", "", $_POST); //end section filter $oGrid->showFilter(trim($htmlFilter)); $content = $oGrid->fetchGrid(); //end grid parameters return $content; }
function _moduleContent(&$smarty, $module_name) { include_once "libs/paloSantoGrid.class.php"; include_once "libs/paloSantoDB.class.php"; include_once "libs/paloSantoForm.class.php"; include_once "libs/paloSantoConfig.class.php"; include_once "libs/paloSantoTrunk.class.php"; require_once "libs/misc.lib.php"; //include module files include_once "modules/{$module_name}/configs/default.conf.php"; $lang = get_language(); $base_dir = dirname($_SERVER['SCRIPT_FILENAME']); $lang_file = "modules/{$module_name}/lang/{$lang}.lang"; if (file_exists("{$base_dir}/{$lang_file}")) { include_once "{$lang_file}"; } else { include_once "modules/{$module_name}/lang/en.lang"; } //global variables global $arrConf; global $arrConfModule; global $arrLang; global $arrLangModule; $arrConf = array_merge($arrConf, $arrConfModule); $arrLang = array_merge($arrLang, $arrLangModule); //folder path for custom templates $base_dir = dirname($_SERVER['SCRIPT_FILENAME']); $templates_dir = isset($arrConf['templates_dir']) ? $arrConf['templates_dir'] : 'themes'; $local_templates_dir = "{$base_dir}/modules/{$module_name}/" . $templates_dir . '/' . $arrConf['theme']; $contenido = ''; $msgError = ''; $pConfig = new paloConfig("/etc", "amportal.conf", "=", "[[:space:]]*=[[:space:]]*"); $arrConfig = $pConfig->leer_configuracion(false); $dsn = $arrConfig['AMPDBENGINE']['valor'] . "://" . $arrConfig['AMPDBUSER']['valor'] . ":" . $arrConfig['AMPDBPASS']['valor'] . "@" . $arrConfig['AMPDBHOST']['valor'] . "/asterisk"; $pDB = new paloDB($dsn); $pDBSetting = new paloDB($arrConf['elastix_dsn']['settings']); $pDBTrunk = new paloDB($arrConfModule['dsn_conn_database_1']); $arrForm = array("default_rate" => array("LABEL" => $arrLang["Default Rate"], "REQUIRED" => "yes", "INPUT_TYPE" => "TEXT", "INPUT_EXTRA_PARAM" => "", "VALIDATION_TYPE" => "float", "VALIDATION_EXTRA_PARAM" => ""), "default_rate_offset" => array("LABEL" => $arrLang["Default Rate Offset"], "REQUIRED" => "yes", "INPUT_TYPE" => "TEXT", "INPUT_EXTRA_PARAM" => "", "VALIDATION_TYPE" => "float", "VALIDATION_EXTRA_PARAM" => "")); $oForm = new paloForm($smarty, $arrForm); $oForm->setViewMode(); //obtener el valor de la tarifa por defecto $arrDefaultRate['default_rate'] = get_key_settings($pDBSetting, "default_rate"); $arrDefaultRate['default_rate_offset'] = get_key_settings($pDBSetting, "default_rate_offset"); $smarty->assign("EDIT", $arrLang["Edit"]); $smarty->assign("REQUIRED_FIELD", $arrLang["Required field"]); $strReturn = $oForm->fetchForm("{$local_templates_dir}/default_rate.tpl", $arrLang["Default Rate Configuration"], $arrDefaultRate); if (isset($_POST['edit_default'])) { $arrDefaultRate['default_rate'] = get_key_settings($pDBSetting, "default_rate"); $arrDefaultRate['default_rate_offset'] = get_key_settings($pDBSetting, "default_rate_offset"); $oForm = new paloForm($smarty, $arrForm); $smarty->assign("CANCEL", $arrLang["Cancel"]); $smarty->assign("SAVE", $arrLang["Save"]); $smarty->assign("REQUIRED_FIELD", $arrLang["Required field"]); $strReturn = $oForm->fetchForm("{$local_templates_dir}/default_rate.tpl", $arrLang["Default Rate Configuration"], $arrDefaultRate); } else { if (isset($_POST['save_default'])) { $oForm = new paloForm($smarty, $arrForm); $arrDefaultRate['default_rate'] = $_POST['default_rate']; $arrDefaultRate['default_rate_offset'] = $_POST['default_rate_offset']; if ($oForm->validateForm($_POST)) { $bValido = set_key_settings($pDBSetting, 'default_rate', $arrDefaultRate['default_rate']); $bValido = set_key_settings($pDBSetting, 'default_rate_offset', $arrDefaultRate['default_rate_offset']); if (!$bValido) { echo $arrLang["Error when saving default rate"]; } else { header("Location: index.php?menu=billing_setup"); } } else { // Error $smarty->assign("mb_title", $arrLang["Validation Error"]); $smarty->assign("mb_message", $arrLang["Value for rate is not valid"]); $smarty->assign("CANCEL", $arrLang["Cancel"]); $smarty->assign("SAVE", $arrLang["Save"]); $smarty->assign("REQUIRED_FIELD", $arrLang["Required field"]); $strReturn = $oForm->fetchForm("{$local_templates_dir}/default_rate.tpl", $arrLang["Default Rate Configuration"], $arrDefaultRate); } } } $arrTrunks = array(); $arrData = array(); $arrTrunksBill = array(); //obtener todos los trunks $oTrunk = new paloTrunk($pDBTrunk); //obtener todos los trunks que son para billing //$arrTrunksBill=array("DAHDI/g0","DAHDI/g1"); getTrunksBillFiltrado($pDB, $oTrunk, $arrConfig, $arrTrunks, $arrTrunksBill); if (isset($_POST['submit_bill_trunks'])) { //obtengo las que estan guardadas y las que ahora no estan $selectedTrunks = isset($_POST['trunksBills']) ? array_keys($_POST['trunksBills']) : array(); if (count($selectedTrunks) > 0) { foreach ($selectedTrunks as $selectedTrunk) { $nuevaListaTrunks[] = base64_decode($selectedTrunk); } } else { $nuevaListaTrunks = array(); } $listaTrunksNuevos = array_diff($nuevaListaTrunks, $arrTrunksBill); $listaTrunksAusentes = array_diff($arrTrunksBill, $nuevaListaTrunks); //tengo que borrar los trunks ausentes //tengo que agregar los trunks nuevos // print_r($listaTrunksNuevos); //print_r($listaTrunksAusentes); if (count($listaTrunksAusentes) > 0) { $bExito = $oTrunk->deleteTrunksBill($listaTrunksAusentes); if (!$bExito) { $msgError = $oTrunk->errMsg; } } if (count($listaTrunksNuevos) > 0) { $bExito = $oTrunk->saveTrunksBill($listaTrunksNuevos); if (!$bExito) { $msgError .= $oTrunk->errMsg; } } if (!empty($msgError)) { $smarty->assign("mb_message", $msgError); } } getTrunksBillFiltrado($pDB, $oTrunk, $arrConfig, $arrTrunks, $arrTrunksBill); $end = count($arrTrunks); if (is_array($arrTrunks)) { foreach ($arrTrunks as $trunk) { $arrTmp = array(); $checked = in_array($trunk[1], $arrTrunksBill) ? "checked" : ""; $arrTmp[0] = "<input type='checkbox' name='trunksBills[" . base64_encode($trunk[1]) . "]' {$checked}>"; $arrTmp[1] = $trunk[1]; $arrData[] = $arrTmp; } } $arrGrid = array("title" => $arrLang["Trunk Bill Configuration"], "icon" => "/modules/{$module_name}/images/reports_billing_setup.png", "width" => "99%", "start" => $end == 0 ? 0 : 1, "end" => $end, "total" => $end, "columns" => array(0 => array("name" => "", "property1" => ""), 1 => array("name" => $arrLang["Trunk"], "property1" => ""))); $oGrid = new paloSantoGrid($smarty); $oGrid->pagingShow(false); $oGrid->customAction('submit_bill_trunks', _tr('Billing Capable')); $trunk_config = $oGrid->fetchGrid($arrGrid, $arrData, $arrLang); if (strpos($trunk_config, '<form') === FALSE) { $trunk_config = "<form style='margin-bottom:0;' method='POST' action='?menu=billing_setup'>{$trunk_config}</form>"; } //mostrar los dos formularios $contenido .= $strReturn . $trunk_config; return $contenido; }
function addRemovePortsUser($smarty, $module_name, $local_templates_dir, $pDB, $arrConf) { // Listar los usuarios y preparar el combo de usuarios disponibles $pACL = new paloACL($arrConf['elastix_dsn']['acl']); $id_user = getParameter('id_user'); $userlist = $pACL->getUsers(); $cbo_users = array(); foreach ($userlist as $userinfo) { $cbo_users[$userinfo[0]] = $userinfo[1] . ' - ' . $userinfo[2]; } // Verificar si el usuario existe if (!is_null($id_user)) { if (!isset($cbo_users[$id_user])) { Header("Location: ?menu={$module_name}"); return NULL; } } else { $id_user = $userlist[0][0]; } $ps = new paloSantoPortService($pDB); $pk = new paloSantoPortKnockUsers($pDB); // Construir lista de puertos autorizados $userauth = $pk->listAuthorizationsForUser($id_user); $portauths = array(); if (is_array($userauth)) { foreach ($userauth as $auth) { $portauths[$auth['id_port']] = $auth['id']; } } $portlist = $ps->ObtainPuertos($ps->ObtainNumPuertos('', ''), 0, '', ''); $listaIdPuertos = array(); foreach ($portlist as $portinfo) { $listaIdPuertos[] = $portinfo['id']; } if (isset($_POST['apply']) && is_array($_POST['auth_port'])) { // Se requiere aplicar lista de cambios $listaNuevosPuertos = array_keys($_POST['auth_port']); $bReglasBorradas = FALSE; // Borrar la autorización de todos los puertos que ya no aparecen $bExito = TRUE; foreach ($portauths as $id_port => $id_auth) { if (!in_array($id_port, $listaNuevosPuertos)) { if (!$pk->deleteAuthorization($id_auth)) { $smarty->assign("mb_title", _tr("ERROR")); $smarty->assign("mb_message", $pk->errMsg); $bExito = FALSE; break; } else { unset($portauths[$id_port]); $bReglasBorradas = TRUE; } } } if (!$bExito) { break; } // Ingresar la autorización de los puertos nuevos foreach ($listaNuevosPuertos as $id_port) { if (in_array($id_port, $listaIdPuertos) && !isset($portauths[$id_port])) { $id_nueva_auth = $pk->insertAuthorization($id_user, $id_port); if (is_null($id_nueva_auth)) { $smarty->assign("mb_title", _tr("ERROR")); $smarty->assign("mb_message", $pk->errMsg); $bExito = FALSE; break; } else { $portauths[$id_port] = $id_nueva_auth; } } } if ($bExito) { if ($bReglasBorradas) { // Ejecutar iptables para revocar las reglas del usuario require_once "modules/sec_rules/libs/paloSantoRules.class.php"; $pr = new paloSantoRules($pDB); $pr->activateRules(); } Header("Location: ?menu={$module_name}"); return NULL; } } $data = array(); if (is_array($portlist)) { foreach ($portlist as $portinfo) { $id_port = $portinfo['id']; $protocol_details = ''; switch ($portinfo['protocol']) { case 'TCP': case 'UDP': $protocol_details = (stripos($portinfo['details'], ':') === false ? _tr('Port') : _tr('Ports')) . ' ' . $portinfo['details']; break; case 'ICMP': $arr = explode(':', $portinfo['details']); if (isset($arr[1])) { $protocol_details = _tr('Type') . ": " . $arr[0] . " " . _tr('Code') . ": " . $arr[1]; } break; default: $protocol_details = _tr('Protocol Number') . ': ' . $portinfo['details']; break; } $data[] = array("<input type=\"checkbox\" name=\"auth_port[{$id_port}]\" " . (isset($portauths[$id_port]) ? 'checked="checked"' : '') . ' />', htmlentities($portinfo['name'], ENT_COMPAT, 'UTF-8'), htmlentities($portinfo['protocol'], ENT_COMPAT, 'UTF-8'), $protocol_details); } } $oGrid = new paloSantoGrid($smarty); $oGrid->setTitle(_tr('Add/remove ports for user')); $oGrid->setColumns(array('', _tr('Port'), _tr('Protocol'), _tr('Details'))); $oGrid->addSubmitAction('apply', _tr('Apply changes'), "modules/{$module_name}/images/Check.png"); $oGrid->addComboAction('id_user', _tr('User'), $cbo_users, $id_user, 'refresh', 'submit();'); // Construcción de la vista de puertos autorizados $oGrid->pagingShow(false); $url = array("menu" => $module_name); $oGrid->setURL($url); $oGrid->setData($data); return $oGrid->fetchGrid(); }
function report_AccessAudit($smarty, $module_name, $local_templates_dir) { global $arrPermission; $pAccessLogs = new paloSantoAccessaudit(); $listaFechas = $pAccessLogs->astLog->listarFechas(); $arrFormElements = createFieldFilter($listaFechas); $field_pattern = getParameter("filter"); $busqueda = getParameter('busqueda'); $sUltimaBusqueda = getParameter('ultima_busqueda'); $iUltimoOffset = getParameter('ultimo_offset'); if (is_null($busqueda) || trim($busqueda) == '') { $busqueda = ''; } if ($busqueda != '') { $_POST['busqueda'] = $busqueda; } /* Última búsqueda, si existe */ if (is_null($sUltimaBusqueda) || $sUltimaBusqueda == '' || is_null($iUltimoOffset) || !ereg('^[[:digit:]]+$', $iUltimoOffset)) { $sUltimaBusqueda = NULL; $iUltimoOffset = NULL; } if (!ereg($arrFormElements['filter']['VALIDATION_EXTRA_PARAM'], $field_pattern)) { $field_pattern = $listaFechas[count($listaFechas) - 1]; } $_POST['filter'] = $field_pattern; $oFilterForm = new paloForm($smarty, $arrFormElements); $oGrid = new paloSantoGrid($smarty); $oGrid->setTitle(_tr("Audit")); $oGrid->setIcon("web/apps/{$module_name}/images/security_audit.png"); $oGrid->pagingShow(true); // show paging section. if (in_array("export", $arrPermission)) { $oGrid->enableExport(); } // enable export. $oGrid->setNameFile_Export(_tr("Access audit")); if (in_array("export", $arrPermission)) { $isExport = $oGrid->isExportAction(); } else { $isExport = false; } $total_datos = $pAccessLogs->ObtainNumAccessLogs($field_pattern); $totalBytes = $total_datos[0]; $iNumLineasPorPagina = 30; $iEstimadoBytesPagina = $iNumLineasPorPagina * 128; $iOffsetVerdadero = getParameter('offset'); if (is_null($iOffsetVerdadero) || !ereg('^[[:digit:]]+$', $iOffsetVerdadero)) { $iOffsetVerdadero = 0; } if ($iOffsetVerdadero >= $totalBytes) { $iOffsetVerdadero = 0; } if (isset($_GET['filter']) && isset($_POST['filter']) && $_GET['filter'] != $_POST['filter']) { $iOffsetVerdadero = 0; } /* Para ubicarse en la página, se obtiene la región 5 páginas estimadas hacia delante y 5 páginas estimadas hacia atrás desde el offset indicado. */ $inicioRango = $iOffsetVerdadero - 5 * $iEstimadoBytesPagina; if ($inicioRango < 0) { $inicioRango = 0; } if ($isExport) { $arrResult = $pAccessLogs->ObtainAccessLogs($totalBytes, 0, $field_pattern, NULL, $isExport); } else { $arrResult = $pAccessLogs->ObtainAccessLogs(10 * $iEstimadoBytesPagina, $inicioRango, $field_pattern, NULL, $isExport); } /* Localizar la línea del offset verdadero, así como los offsets de las páginas previa y siguiente */ for ($iPos = 0; $iPos < count($arrResult); $iPos++) { if ($arrResult[$iPos]['offset'] >= $iOffsetVerdadero) { break; } } $iPosPrevio = $iPos - $iNumLineasPorPagina; $iPosSiguiente = $iPos + $iNumLineasPorPagina; if ($iPosPrevio < 0) { $iPosPrevio = 0; } if ($iPosSiguiente > count($arrResult) - 1) { $iPosSiguiente = count($arrResult) - 1; } $iOffsetPrevio = $arrResult[$iPosPrevio]['offset']; $iOffsetSiguiente = $arrResult[$iPosSiguiente]['offset']; $limit = 30; $total = (int) ($totalBytes / 128); $offset = $iOffsetVerdadero; $nav = getParameter('nav'); if ($nav) { switch ($nav) { case 'start': $offset = 0; break; case 'end': /* Caso especial: se debe tomar la última sección del log */ $inicioRango = $totalBytes - 5 * $iEstimadoBytesPagina; if ($inicioRango < 0) { $inicioRango = 0; } if ($isExport) { $arrResult = $pAccessLogs->ObtainAccessLogs($totalBytes, 0, $field_pattern, $busqueda != '' ? $busqueda : NULL, $isExport); } else { $arrResult = $pAccessLogs->ObtainAccessLogs(10 * $iEstimadoBytesPagina, $inicioRango, $field_pattern, NULL, $isExport); } if (count($arrResult) <= $iNumLineasPorPagina) { $offset = $arrResult[0]['offset']; } else { $offset = $arrResult[count($arrResult) - $iNumLineasPorPagina]['offset']; } break; case 'next': $offset = $iOffsetSiguiente; break; case 'previous': $offset = $iOffsetPrevio; break; case 'bypage': $numPage = $limit == 0 ? 0 : ceil($total / $limit); $page = getParameter("page"); if (preg_match("/[0-9]+/", $page) == 0) { // no es un número $page = 1; } if ($page > $numPage) { // se está solicitando una pagina mayor a las que existen $page = $numPage; } $start = ($page - 1) * $limit + 1 - $limit; //$accion = "next"; if ($start + $limit <= 1) { break; } /*$inicioRango = $page * $iEstimadoBytesPagina; $arrResult =$pAccessLogs->ObtainAccessLogs(10 * $iEstimadoBytesPagina, $inicioRango, $field_pattern, NULL, $isExport); $offset = $arrResult[0]['offset']; $oGrid->setOffsetValue($offset); $oGrid->setEnd(((int)($offset / 128) + $iNumLineasPorPagina) <= $oGrid->getTotal() ? (int)($offset / 128) + $iNumLineasPorPagina : $oGrid->getTotal()); $oGrid->setStart(($oGrid->getTotal()==0) ? 0 : (1 + (int)($offset / 128)));*/ $inicioBusqueda = $page * $iEstimadoBytesPagina - $iEstimadoBytesPagina; $arrResult = $pAccessLogs->ObtainAccessLogs(10 * $iEstimadoBytesPagina, $inicioBusqueda, $field_pattern, NULL, $isExport); $offset = $arrResult[0]['offset']; $oGrid->setOffsetValue($offset); break; } } // Buscar la cadena de texto indicada, y modificar offset si se encuentra $smarty->assign("SEARCHNEXT", _tr('Search')); if (isset($_POST['searchnext']) && $busqueda != '') { $pAccessLogs->astLog->posicionarMensaje($field_pattern, $offset); $posBusqueda = $pAccessLogs->astLog->buscarTextoMensaje($busqueda); if (!is_null($posBusqueda)) { $offset = $posBusqueda[1]; $smarty->assign('SEARCHNEXT', _tr('Search next')); $_POST['ultima_busqueda'] = $busqueda; $_POST['ultimo_offset'] = $offset; // Si el offset anterior indicado es idéntico al offset recién encontrado // y la cadena de búsqueda es también idéntica, se asume que se ha // pedido una búsqueda de la siguiente ocurrencia. if (!is_null($sUltimaBusqueda) && !is_null($iUltimoOffset) && $offset == $iUltimoOffset && $sUltimaBusqueda == $busqueda) { $pAccessLogs->astLog->posicionarMensaje($field_pattern, $offset); $pAccessLogs->astLog->siguienteMensaje(); // Sólo para ignorar primera ocurrencia $posBusqueda = $pAccessLogs->astLog->buscarTextoMensaje($busqueda); if (!is_null($posBusqueda)) { $offset = $posBusqueda[1]; $_POST['ultimo_offset'] = $offset; } } } else { } } $url = array('menu' => $module_name, 'filter' => $field_pattern, 'offset' => $offset, 'busqueda' => $busqueda, 'ultima_busqueda' => isset($_POST['ultima_busqueda']) ? $_POST['ultima_busqueda'] : '', 'ultimo_offset' => isset($_POST['ultimo_offset']) ? $_POST['ultimo_offset'] : ''); $oGrid->setURL($url); //Fin Paginacion if ($isExport) { $arrResult = $pAccessLogs->ObtainAccessLogs($totalBytes, 0, $field_pattern, $busqueda != '' ? $busqueda : NULL, $isExport); } else { $arrResult = $pAccessLogs->ObtainAccessLogs(10 * $iEstimadoBytesPagina, $offset, $field_pattern, $busqueda != '' ? $busqueda : NULL, $isExport); } if (!$isExport) { $arrResult = array_slice($arrResult, 0, $iNumLineasPorPagina); } $arrData = null; if (is_array($arrResult) && $totalBytes > 0) { foreach ($arrResult as $key => $value) { $arrTmp[0] = $value['fecha']; $arrTmp[1] = $value['tipo']; $arrTmp[2] = $value['origen']; $arrTmp[3] = $value['linea']; $arrData[] = $arrTmp; } } $arrColumns = array(_tr("Date"), _tr("Type"), _tr("User"), _tr("Message")); $oGrid->setColumns($arrColumns); $oGrid->setData($arrData); $oGrid->setStart($totalBytes == 0 ? 0 : 1 + (int) ($offset / 128)); $t = (int) ($totalBytes / 128); $e = (int) ($offset / 128) + $iNumLineasPorPagina; $e = $t <= $e ? $t : $e; $oGrid->setEnd($e + 1); $oGrid->setTotal($t + 1); $oGrid->setLimit(30); $_POST['offset'] = $offset; $smarty->assign("SHOW", _tr("Show")); $oGrid->addFilterControl(_tr("Filter applied: ") . _tr("Date") . " = " . $_POST['filter'], $_POST, array('filter' => $listaFechas[count($listaFechas) - 1]), true); $oGrid->addFilterControl(_tr("Filter applied: ") . _tr('Search string') . " = " . $busqueda, $_POST, array('busqueda' => "")); $htmlFilter = $oFilterForm->fetchForm("{$local_templates_dir}/filter.tpl", "", $_POST); $oGrid->showFilter(trim($htmlFilter)); return $oGrid->fetchGrid(); }
function reportListadodeCallTypes($smarty, $module_name, $local_templates_dir, &$pDB, $arrConf) { $pListadodeCallTypes = new paloSantoListadodeCallTypes($pDB); $filter_field = getParameter("filter_field"); $filter_value = getParameter("filter_value"); //begin grid parameters $oGrid = new paloSantoGrid($smarty); $oGrid->setTitle(_tr("Listado de Call Types")); $oGrid->pagingShow(true); // show paging section. $oGrid->enableExport(); // enable export. $oGrid->setNameFile_Export(_tr("Listado de Call Types")); $url = array("menu" => $module_name, "filter_field" => $filter_field, "filter_value" => $filter_value); $oGrid->setURL($url); $arrColumns = array(_tr("Campaña"), _tr("Call Type"), _tr("Clase de Call Type"), _tr("Peso"), _tr("Status"), _tr("Acción")); $oGrid->setColumns($arrColumns); $total = $pListadodeCallTypes->getNumListadodeCallTypes($filter_field, $filter_value); $arrData = null; if ($oGrid->isExportAction()) { $limit = $total; // max number of rows. $offset = 0; // since the start. } else { $limit = 20; $oGrid->setLimit($limit); $oGrid->setTotal($total); $offset = $oGrid->calculateOffset(); } $arrResult = $pListadodeCallTypes->getListadodeCallTypes($limit, $offset, $filter_field, $filter_value); if (is_array($arrResult) && $total > 0) { foreach ($arrResult as $key => $value) { $arrTmp[0] = $value['campania']; $arrTmp[1] = $value['call_type']; $arrTmp[2] = $value['clase']; $arrTmp[3] = $value['peso']; $arrTmp[4] = $value['status'] == "A" ? "Activo" : "Inactivo"; $arrTmp[5] = "<a href=index.php?menu={$module_name}&id={$value['id']}&id_campania={$value['id_campania']}&action=change_status&status="; if ($value['status'] == "A") { $arrTmp[5] .= "I"; $accion = "Desactivar"; } else { $arrTmp[5] .= "A"; $accion = "Activar"; } $arrTmp[5] .= ">{$accion}</a>"; $arrTmp[5] .= " <a href=index.php?menu=hispana_call_types&id={$value['id']}&id_campania={$value['id_campania']}&action=view_edit>Editar</a>"; $arrData[] = $arrTmp; } } $oGrid->setData($arrData); //begin section filter $oFilterForm = new paloForm($smarty, createFieldFilter()); $smarty->assign("SHOW", _tr("Show")); $htmlFilter = $oFilterForm->fetchForm("{$local_templates_dir}/filter.tpl", "", $_POST); //end section filter $oGrid->showFilter(trim($htmlFilter)); $content = $oGrid->fetchGrid(); //end grid parameters return $content; }
function reportReportedeCalltypes($smarty, $module_name, $local_templates_dir, &$pDB, $arrConf, $argv) { $pReportedeCalltypes = new paloSantoReportedeCalltypes($pDB); $filter_field = $argv[3]; //getParameter("filter_field"); $filter_value = $argv[4]; //getParameter("filter_value"); $id_campania = $argv[1]; //getParameter("id_campania"); $tiempo_unix = $argv[2]; $nombre_archivo = '/modules/hispana_reporte_calltype/reportes/Reporte_de_Calltypes_' . $id_campania . "_{$tiempo_unix}.xls"; $pReportedeCalltypes->registraReporteOffline($id_campania, $tiempo_unix, $nombre_archivo, "{$filter_field}={$filter_value}"); //begin grid parameters $oGrid = new paloSantoGrid($smarty); $oGrid->setTitle(_tr("Reporte de Calltypes")); $oGrid->pagingShow(true); // show paging section. $oGrid->enableExport(); // enable export. $oGrid->setNameFile_Export(_tr("Reporte de Calltypes")); $url = array("menu" => $module_name, "filter_field" => $filter_field, "filter_value" => $filter_value, "id_campania" => $id_campania); $oGrid->setURL($url); // Columnas base $arrColumns = array(_tr("Fecha"), _tr("Campaña"), _tr("Base"), _tr("Cliente"), _tr("CI"), _tr("Teléfono"), _tr("Agente"), _tr("Contactabilidad"), _tr("Mejor calltype"), _tr("Formulario")); // Otras columnas if ($id_campania != "") { // Columnas adicionales $arrColumnasAdicionales = $pReportedeCalltypes->getColumnasAdicionales($id_campania); $arrColumns = array_merge($arrColumns, $arrColumnasAdicionales); // Columnas de gestión $arrTmp = $pReportedeCalltypes->getFormFields($id_campania); $i = 0; foreach ($arrTmp as $formField) { $arrOrden[] = $formField['id']; $arrColumnsAdicionales[$i] = $formField['etiqueta']; $i++; } $arrColumns = array_merge($arrColumns, $arrColumnsAdicionales); } $oGrid->setColumns($arrColumns); $total = $pReportedeCalltypes->getNumReportedeCalltypes($filter_field, $filter_value, $id_campania); $arrData = null; //if($oGrid->isExportAction()){ $limit = $total; // max number of rows. $offset = 0; // since the start. /*}else{ $limit = 20; // default 20 $oGrid->setLimit($limit); $oGrid->setTotal($total); $offset = $oGrid->calculateOffset(); }*/ $arrResult = $pReportedeCalltypes->getReportedeCalltypes($limit, $offset, $filter_field, $filter_value, $id_campania); if (is_array($arrResult) && $total > 0) { foreach ($arrResult as $key => $value) { $arrTmp[0] = $value['fecha']; $arrTmp[1] = $value['base']; $arrTmp[2] = $value['campania']; $arrTmp[3] = $value['cliente']; $arrTmp[4] = $value['ci']; $arrTmp[5] = $value['telefono']; $arrTmp[6] = $value['agente']; $arrTmp[7] = $value['contactabilidad']; $arrTmp[8] = $value['mejor_calltype']; // $arrTmp[8] = $value['formulario']; // Así lo requiere RUBENING /*$arrTmp[9] = "<a href=modules/$module_name/gestion_info.php?id_gestion=$value[id_gestion_mejor_calltype] target=\"_blank\" onClick=\"window.open(this.href, this.target, 'width=600,height=400'); return false;\">Ver gestión</a>". "<br>". "<a href=modules/$module_name/gestion_edit.php?id_gestion=$value[id_gestion_mejor_calltype]&user="******"elastix_user"]." target=\"_blank\" onClick=\"window.open(this.href, this.target, 'width=600,height=400'); return false;\">Editar</a>"*/ //$arrTmp[9] = "<a href=modules/$module_name/gestion_info.php?id_gestion=$value[id_gestion_mejor_calltype] target=\"_blank\" onClick=\"window.open(this.href, this.target, 'width=600,height=400'); return false;\">Ver gestión</a>"; // Datos adicionales $arrDatosAdicionales = $pReportedeCalltypes->getDatosAdicionales($value['ci']); $i = 10; foreach ($arrColumnasAdicionales as $k => $columnaAdicional) { $arrTmp[$i] = $arrDatosAdicionales[$columnaAdicional]; $i++; } unset($arrDatosAdicionales); $numColumnasFijas = $i; // Datos de gestión $arrFormValues = $pReportedeCalltypes->getFormValues($value['id_gestion_mejor_calltype']); // array_search retorna el key dado el valor a buscar foreach ($arrFormValues as $formValue) { // echo $formValue['valor'] . " " . array_search($formValue['id_form_field'],$arrOrden) . "<br>"; $ubicacionReal = array_search($formValue['id_form_field'], $arrOrden) + $numColumnasFijas; if (is_array($formValue['valor'])) { $formValue['valor'] = print_r($formValue['valor'], true); } $arrTmp[$ubicacionReal] = $formValue['valor']; } $arrData[] = $arrTmp; unset($arrTmp); } } $oGrid->setData($arrData); /* Para colocar en $arrTmp */ //begin section filter //$oFilterForm = new paloForm($smarty, createFieldFilter()); //$smarty->assign("SHOW", _tr("Show")); //$smarty->assign("filter_campaign", filter_campaign($pDB, $id_campania)); //$htmlFilter = $oFilterForm->fetchForm("$local_templates_dir/filter.tpl","",$_POST); //end section filter //$oGrid->showFilter(trim($htmlFilter)); $export = $oGrid->exportType(); $content = $oGrid->fetchGrid(); //end grid parameters //REPORTE OFFLINE //exportspreadsheet=yes&rawmode=yes if ($export == 'csv' || $export == 'pdf' || ($export = 'xls')) { $nombre_archivo = '/var/www/html/modules/hispana_reporte_calltype/reportes/Reporte_de_Calltypes_' . $id_campania . "_{$tiempo_unix}." . $export; $fd = fopen($nombre_archivo, "w"); fwrite($fd, $content); fclose($fd); } $nombre_archivo = '/modules/hispana_reporte_calltype/reportes/Reporte_de_Calltypes_' . $id_campania . "_{$tiempo_unix}." . $export; $pReportedeCalltypes->actualizaReporteOffline($id_campania, $tiempo_unix); return $content; }
function report_TicketDelivery($smarty, $module_name, $local_templates_dir, &$pDB, $pDB_2) { $pTicket_Delivery = new Ticket_Delivery($pDB); $pACL = new paloACL($pDB_2); $img_dir = "modules/{$module_name}/images/"; // get filter parameters $filter = array('date_start' => trim($_POST['date_start']) == '' ? '' : date("Y-m-d", strtotime($_POST['date_start'])), 'date_end' => trim($_POST['date_end']) == '' ? '' : date("Y-m-d", strtotime($_POST['date_end'])), 'customer_name' => trim($_POST['customer_name']), 'customer_phone' => trim($_POST['customer_number']), 'ticket_code' => trim($_POST['ticket_code']), 'status' => trim($_POST['status'])); //begin grid parameters $oGrid = new paloSantoGrid($smarty); $oGrid->setTitle("Yêu cầu giao vé"); $oGrid->setTableName("delivery_grid"); $oGrid->pagingShow(true); // show paging section. $oGrid->enableExport(); // enable export. $oGrid->setNameFile_Export("ticket_delivery"); $url = array("menu" => $module_name); $oGrid->setURL($url); $arrColumns = array("ID", "Tên Khách Hàng", "Số điện thoại", "Booker", "Địa chỉ", "Tiền trả", "Mã số vé", "Tình trạng", "Nhân viên giao", "Ngày phân công", "Vé đính kèm", "Ngày nhận tiền", "Xử lý", "Chi tiết", " "); $oGrid->setColumns($arrColumns); $total = $pTicket_Delivery->getNumTicket_Delivery($filter); $arrData = null; if ($oGrid->isExportAction()) { $limit = $total; // max number of rows. $offset = 0; // since the start. } else { $limit = 20; $oGrid->setLimit($limit); $oGrid->setTotal($total); $offset = $oGrid->calculateOffset(); } $arrResult = $pTicket_Delivery->getTicket_Delivery($limit, $offset, $filter); if (is_array($arrResult) && $total > 0) { foreach ($arrResult as $key => $value) { $ticket = ''; $name = $pACL->getUsers($value['accounting_id']); $elastix_user = is_null($value['accounting_id']) ? '(Chưa nhận)' : $name[0][1]; // show files $download = ''; foreach ($value['ticket_attachment'] as $row) { $url = "/modules/agent_console/ajax-attachments-handler.php?download=" . $row['filepath'] . "&name=" . $row['filename']; $filename = $row['filename']; $download .= "*<a href='{$url}' target='_blank' title='{$filename}'>" . shorten($filename) . "</a><br/>"; } $print = '<a href="javascript:void(0)" onclick="print(\'' . $value['id'] . '\')"><img src="' . $img_dir . 'print.png" title="In phiếu"></a>'; $enable = $value['isActive'] == '1' ? '<a href="javascript:void(0)" onclick="disable(\'' . $value['id'] . '\')"><img src="' . $img_dir . 'disable.png" title="Hủy yêu cầu giao vé"></a> ' : ' <a href="javascript:void(0)" onclick="enable(\'' . $value['id'] . '\')"><img src="' . $img_dir . 'enable.png" title="Tạo lại yêu cầu giao vé"></a>'; $print .= ' ' . $enable; // function show base on status if ($value['isActive'] == '0') { $value['status'] = 'Đã hủy'; } switch ($value['status']) { case 'Mới': $function = '<a href="javascript:void(1)" onclick="assign_form(\'' . $value['id'] . '\')"><img src="' . $img_dir . 'assign.png" title="Phân công"></a>'; break; case 'Đang giao': $function = '<a href="javascript:void(1)" onclick="assign_form(\'' . $value['id'] . '\')"><img src="' . $img_dir . 'assign.png" title="Đổi phân công"></a> <a href="javascript:void(1)" onclick="collect_form(\'' . $value['id'] . '\',\'' . $elastix_user . '\')"><img src="' . $img_dir . 'result.png" title="Kết quả"></a>'; break; case 'Đã nhận tiền': $function = '<a href="javascript:void(1)" onclick="uncollect_form(\'' . $value['id'] . '\',\'' . $elastix_user . '\')"><img src="' . $img_dir . 'unpaid.png" title="Hủy nhận tiền"></a>'; break; case 'Chờ xử lý': $function = '<a href="javascript:void(1)" onclick="assign_form(\'' . $value['id'] . '\')"><img src="' . $img_dir . 'assign.png" title="Phân công"></a>'; break; default: $function = ''; } // show ticket code foreach ($value['ticket_code'] as $row) { $ticket .= $row . '<br>'; } $arrTmp[0] = $value['id']; $arrTmp[1] = $value['customer_name']; $arrTmp[2] = $value['customer_phone']; $arrTmp[3] = '<span title="Chi nhánh: ' . $value['office'] . '">' . $value['agent_name'] . '</span>'; $arrTmp[4] = '<a href="javascript:void(1)" title="' . $value['deliver_address'] . '" onclick="view_address(\'' . $value['deliver_address'] . '\')">' . shorten($value['deliver_address']) . ' </a>'; $arrTmp[5] = $value['pay_amount']; $arrTmp[6] = $ticket; $arrTmp[7] = showStatus($value['status']); $arrTmp[8] = $value['delivery_name']; $arrTmp[9] = is_null($value['delivery_date']) ? '' : date("d-m-Y H:m:s", strtotime($value['delivery_date'])); $arrTmp[10] = $download; $arrTmp[11] = is_null($value['collection_date']) ? '' : date("d-m-Y H:m:s", strtotime($value['collection_date'])); $arrTmp[12] = $function; $arrTmp[13] = '<a href="javascript:void(1)" onclick="view_log(\'' . $value['id'] . '\')"> <img src="' . $img_dir . 'extra.png" title="Xem chi tiết"></a>'; $arrTmp[14] = $print; $arrData[] = $arrTmp; } } $oGrid->setData($arrData); //begin section filter $oFilterForm = new paloForm($smarty, createFieldFilter()); // get delivery man list $delivery_man_list = $pTicket_Delivery->getDeliveryMan(); $smarty->assign("DELIVERY_MAN_LIST", $delivery_man_list); $htmlFilter = $oFilterForm->fetchForm("{$local_templates_dir}/filter.tpl", "", $_POST); //end section filter $oGrid->showFilter(trim($htmlFilter)); $content = $oGrid->fetchGrid(); //end grid parameters return $content; }
function reportReportsBreak($smarty, $module_name, $local_templates_dir, &$pDB) { // Obtener rango de fechas de consulta. Si no existe, se asume día de hoy $sFechaInicio = date('d M Y'); if (isset($_GET['txt_fecha_init'])) { $sFechaInicio = $_GET['txt_fecha_init']; } if (isset($_POST['txt_fecha_init'])) { $sFechaInicio = $_POST['txt_fecha_init']; } $sFechaFinal = date('d M Y'); if (isset($_GET['txt_fecha_end'])) { $sFechaFinal = $_GET['txt_fecha_end']; } if (isset($_POST['txt_fecha_end'])) { $sFechaFinal = $_POST['txt_fecha_end']; } $arrFilterExtraVars = array("txt_fecha_init" => $sFechaInicio, "txt_fecha_end" => $sFechaFinal); $arrFormElements = createFieldFilter(); $oFilterForm = new paloForm($smarty, $arrFormElements); // Validación de las fechas recogidas if (!$oFilterForm->validateForm($arrFilterExtraVars)) { $smarty->assign("mb_title", _tr("Validation Error")); $arrErrores = $oFilterForm->arrErroresValidacion; $strErrorMsg = '<b>' . _tr('The following fields contain errors') . '</b><br/>'; foreach ($arrErrores as $k => $v) { $strErrorMsg .= "{$k}, "; } $smarty->assign("mb_message", $strErrorMsg); $arrFilterExtraVars = array("txt_fecha_init" => date('d M Y'), "txt_fecha_end" => date('d M Y')); } $htmlFilter = $oFilterForm->fetchForm("{$local_templates_dir}/filter.tpl", "", $arrFilterExtraVars); // Obtener fechas en formato yyyy-mm-dd $sFechaInicio = translateDate($arrFilterExtraVars['txt_fecha_init']); $sFechaFinal = translateDate($arrFilterExtraVars['txt_fecha_end']); $oReportsBreak = new paloSantoReportsBreak($pDB); //begin grid parameters $bElastixNuevo = method_exists('paloSantoGrid', 'setURL'); $oGrid = new paloSantoGrid($smarty); $oGrid->enableExport(); // enable export. $oGrid->showFilter($htmlFilter); $arrColumnas = array(_tr('Agent Number'), _tr('Agent Name')); $bExportando = $bElastixNuevo ? $oGrid->isExportAction() : isset($_GET['exportcsv']) && $_GET['exportcsv'] == 'yes' || isset($_GET['exportspreadsheet']) && $_GET['exportspreadsheet'] == 'yes' || isset($_GET['exportpdf']) && $_GET['exportpdf'] == 'yes'; $datosBreaks = $oReportsBreak->getReportesBreak($sFechaInicio, $sFechaFinal); $mapa = array(); // Columna del break dado su ID $sTagInicio = !$bExportando ? '<b>' : ''; $sTagFinal = $sTagInicio != '' ? '</b>' : ''; $filaTotales = array($sTagInicio . _tr('Total') . $sTagFinal, ''); foreach ($datosBreaks['breaks'] as $idBreak => $sNombreBreak) { $mapa[$idBreak] = count($arrColumnas); $arrColumnas[] = $sNombreBreak; $filaTotales[] = 0; // Total de segundos usado por todos los agentes en este break } $mapa['TOTAL'] = count($arrColumnas); $filaTotales[] = 0; // Total de segundos usado por todos los agentes en todos los breaks $arrColumnas[] = _tr('Total'); $arrData = array(); foreach ($datosBreaks['reporte'] as $infoAgente) { $filaAgente = array($infoAgente['numero_agente'], $infoAgente['nombre_agente']); $iTotalAgente = 0; // Total de segundos usados por agente en breaks // Valor inicial de todos los breaks es 0 segundos foreach (array_keys($datosBreaks['breaks']) as $idBreak) { $filaAgente[$mapa[$idBreak]] = '00:00:00'; } // Asignar duración del break para este agente y break foreach ($infoAgente['breaks'] as $tuplaBreak) { $sTagInicio = !$bExportando && $tuplaBreak['duracion'] > 0 ? '<font color="green">' : ''; $sTagFinal = $sTagInicio != '' ? '</font>' : ''; $filaAgente[$mapa[$tuplaBreak['id_break']]] = $sTagInicio . formatoSegundos($tuplaBreak['duracion']) . $sTagFinal; $iTotalAgente += $tuplaBreak['duracion']; $filaTotales[$mapa[$tuplaBreak['id_break']]] += $tuplaBreak['duracion']; $filaTotales[$mapa['TOTAL']] += $tuplaBreak['duracion']; } // Total para todos los breaks de este agente $filaAgente[$mapa['TOTAL']] = formatoSegundos($iTotalAgente); $arrData[] = $filaAgente; } $sTagInicio = !$bExportando ? '<b>' : ''; $sTagFinal = $sTagInicio != '' ? '</b>' : ''; foreach ($mapa as $iPos) { $filaTotales[$iPos] = $sTagInicio . formatoSegundos($filaTotales[$iPos]) . $sTagFinal; } $arrData[] = $filaTotales; if ($bElastixNuevo) { $oGrid->setURL(construirURL($arrFilterExtraVars)); $oGrid->setData($arrData); $oGrid->setColumns($arrColumnas); $oGrid->setTitle(_tr("Reports Break")); $oGrid->pagingShow(false); $oGrid->setNameFile_Export(_tr("Reports Break")); $smarty->assign("SHOW", _tr("Show")); return $oGrid->fetchGrid(); } else { $url = construirURL($arrFilterExtraVars); $offset = 0; $total = count($datosBreaks['reporte']) + 1; $limit = $total; function _map_name($s) { return array('name' => $s); } $arrGrid = array("title" => _tr('Reports Break'), "url" => $url, "icon" => "images/list.png", "width" => "99%", "start" => $total == 0 ? 0 : $offset + 1, "end" => $offset + $limit <= $total ? $offset + $limit : $total, "total" => $total, "columns" => array_map('_map_name', $arrColumnas)); 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) { $title = $sFechaInicio . "-" . $sFechaFinal; header("Cache-Control: private"); header("Pragma: cache"); header('Content-Type: text/csv; charset=utf-8; header=present'); header("Content-disposition: attachment; filename=\"" . $title . ".csv\""); } if ($bExportando) { return $oGrid->fetchGridCSV($arrGrid, $arrData); } $sContenido = $oGrid->fetchGrid($arrGrid, $arrData); if (strpos($sContenido, '<form') === FALSE) { $sContenido = "<form method=\"POST\" style=\"margin-bottom:0;\" action=\"{$url}\">{$sContenido}</form>"; } return $sContenido; } }
function reportMemberList($smarty, $module_name, $local_templates_dir, &$pDB, $arrConf, $credentials) { global $arrPermission; $pEmailList = new paloSantoEmailList($pDB); $id_list = getParameter("id"); if ($credentials['userlevel'] == 'superadmin') { $emailList = $pEmailList->getEmailList($id_list); } else { $emailList = $pEmailList->getEmailList($id_list, $credentials['domain']); } if ($emailList == false) { $smarty->assign("mb_title", _tr("Error")); $error = $emailList === false ? _tr("Couldn't be retrieved Email List data") : _tr("Email List does not exist"); $smarty->assign("mb_message", $error); return reportEmailList($smarty, $module_name, $local_templates_dir, $pDB, $arrConf, $credentials); } $field_type = getParameter("filter_type"); $field_pattern = getParameter("filter_txt"); $smarty->assign("IDEMAILLIST", $id_list); $smarty->assign("ACTION", 'view_memberlist'); $smarty->assign("SHOW", _tr("Show")); $smarty->assign("RETURN", _tr("Return")); $smarty->assign("LINK", "?menu={$module_name}&action=export&id={$id_list}&rawmode=yes"); $smarty->assign("EXPORT", _tr("Export Members")); $edit_permission = in_array('edit_list', $arrPermission); $totalMembers = $pEmailList->getTotalMembers($id_list); $oGrid = new paloSantoGrid($smarty); $limit = 20; $oGrid->setLimit($limit); $oGrid->setTotal($totalMembers); $oGrid->setTitle(_tr("List Members of") . " " . $pEmailList->getListName($id_list)); $oGrid->setIcon("web/apps/{$module_name}/images/email.png"); $oGrid->pagingShow(true); $offset = $oGrid->calculateOffset(); $url['menu'] = $module_name; $url['action'] = 'view_memberlist'; $url['id'] = $id_list; $url['filter_type'] = $field_type; $url['filter_txt'] = $field_pattern; $oGrid->setURL($url); if ($edit_permission) { $arrColumns[] = ''; } $arrColumns[] = _tr("Member name"); $arrColumns[] = _tr("Member email"); $oGrid->setColumns($arrColumns); $arrResult = $pEmailList->getMembers($limit, $offset, $id_list, $field_type, $field_pattern); $arrData = null; //print_r($arrResult); if (is_array($arrResult) && $totalMembers > 0) { foreach ($arrResult as $list) { $arrTmp = array(); if ($edit_permission) { $arrTmp[] = "<input type='checkbox' name='del_emailmembers[{$list["mailmember"]}]'>"; } $arrTmp[] = $list["namemember"]; $arrTmp[] = $list["mailmember"]; $arrData[] = $arrTmp; } } $arrFormFilterMembers = createFieldFilterViewMembers(); $oFilterForm = new paloForm($smarty, $arrFormFilterMembers); $arrType = array("name" => _tr("Name"), "email" => _tr("Email")); if (!is_null($field_type)) { $nameField = $arrType[$field_type]; } else { $nameField = ""; } $oGrid->customAction("return", _tr("Return")); if ($edit_permission) { $oGrid->addNew("new_memberlist", _tr("Add Member(s) to List")); $oGrid->deleteList(_tr("Are you sure you wish to delete the Email List(s)."), "remove_memberlist", _tr("Delete")); } $oGrid->customAction("?menu={$module_name}&action=export&id={$id_list}&rawmode=yes", _tr("Export Members"), null, true); $oGrid->addFilterControl(_tr("Filter applied: ") . $nameField . " = " . $field_pattern, $_POST, array("filter_type" => "name", "filter_txt" => "")); $htmlFilter = $oFilterForm->fetchForm("{$local_templates_dir}/view_members.tpl", "", $_POST); $oGrid->showFilter(trim($htmlFilter)); $content = $oGrid->fetchGrid(array(), $arrData); return $content; }
function reportMissedCalls($smarty, $module_name, $local_templates_dir, &$pDB, &$pDBACL, $pACL, $arrConf) { ini_set('max_execution_time', 3600); $pCallingReport = new paloSantoMissedCalls($pDB); $oFilterForm = new paloForm($smarty, createFieldFilter()); $filter_field = getParameter("filter_field"); $filter_value = getParameter("filter_value"); $date_start = getParameter("date_start"); $date_end = getParameter("date_end"); //begin grid parameters $oGrid = new paloSantoGrid($smarty); $oGrid->setTitle(_tr("Missed Calls")); $oGrid->pagingShow(true); // show paging section. $oGrid->enableExport(); // enable export. $oGrid->setNameFile_Export(_tr("Missed Calls")); $url = array("menu" => $module_name, "filter_field" => $filter_field, "filter_value" => $filter_value); $date_start = isset($date_start) ? $date_start : date("d M Y") . ' 00:00'; $date_end = isset($date_end) ? $date_end : date("d M Y") . ' 23:59'; $_POST['date_start'] = $date_start; $_POST['date_end'] = $date_end; $parmFilter = array("date_start" => $date_start, "date_end" => $date_end); if (!$oFilterForm->validateForm($parmFilter)) { $smarty->assign(array('mb_title' => _tr('Validation Error'), 'mb_message' => '<b>' . _tr('The following fields contain errors') . ':</b><br/>' . implode(', ', array_keys($oFilterForm->arrErroresValidacion)))); $date_start = date("d M Y") . ' 00:00'; $date_end = date("d M Y") . ' 23:59'; } $url = array_merge($url, array('date_start' => $date_start, 'date_end' => $date_end)); $oGrid->setURL($url); $arrColumns = array(_tr("Date"), _tr("Source"), _tr("Destination"), _tr("Time since last call"), _tr("Number of attempts"), _tr("Status")); $oGrid->setColumns($arrColumns); $arrData = null; $date_start_format = date('Y-m-d H:i:s', strtotime($date_start . ":00")); $date_end_format = date('Y-m-d H:i:s', strtotime($date_end . ":59")); // Para usuarios que no son administradores, se restringe a los CDR de la // propia extensión $sExtension = $pACL->isUserAdministratorGroup($_SESSION['elastix_user']) ? '' : $pACL->getUserExtension($_SESSION['elastix_user']); $total = $pCallingReport->getNumCallingReport($date_start_format, $date_end_format, $filter_field, $filter_value, $sExtension); if ($oGrid->isExportAction()) { $limit = $total; // max number of rows. $offset = 0; // since the start. $arrResult = $pCallingReport->getCallingReport($date_start_format, $date_end_format, $filter_field, $filter_value, $sExtension); $arrData = $pCallingReport->showDataReport($arrResult, $total); $size = count($arrData); $oGrid->setData($arrData); } else { $limit = 20; $oGrid->setLimit($limit); $arrResult = $pCallingReport->getCallingReport($date_start_format, $date_end_format, $filter_field, $filter_value, $sExtension); $arrData = $pCallingReport->showDataReport($arrResult, $total); if ($pCallingReport->errMsg != '') { $smarty->assign('mb_message', $pCallingReport->errMsg); } //recalculando el total para la paginación $size = count($arrData); $oGrid->setTotal($size); $offset = $oGrid->calculateOffset(); //echo $size." : ".$offset; $arrResult = $pCallingReport->getDataByPagination($arrData, $limit, $offset); $oGrid->setData($arrResult); } //begin section filter $smarty->assign("SHOW", _tr("Show")); $htmlFilter = $oFilterForm->fetchForm("{$local_templates_dir}/filter.tpl", "", $_POST); //end section filter $oGrid->showFilter(trim($htmlFilter)); $content = $oGrid->fetchGrid(); //end grid parameters return $content; }