function listPortKnockUsers(&$smarty, $module_name, $local_templates_dir, &$pDB, $arrConf) { $pACL = new paloACL($arrConf['elastix_dsn']['acl']); $pk = new paloSantoPortKnockUsers($pDB); // Manejar la operación de borrar todas las autorizaciones de un usuario if (isset($_POST['delete']) && isset($_POST['id_user'])) { $r = $pk->deleteUserAuthorizations($_POST['id_user']); if (!$r) { $smarty->assign("mb_title", _tr("ERROR")); $smarty->assign("mb_message", $pk->errMsg); } else { // Ejecutar iptables para revocar las reglas del usuario require_once "modules/sec_rules/libs/paloSantoRules.class.php"; $pr = new paloSantoRules($pDB); $pr->activateRules(); $smarty->assign("mb_title", _tr("Message")); $smarty->assign("mb_message", _tr("Revocation successful")); } } $oGrid = new paloSantoGrid($smarty); $oGrid->setTitle(_tr('PortKnock Users')); $oGrid->setColumns(array('', _tr('User'), _tr('Authorized ports'), _tr('Options'))); $oGrid->deleteList(_tr('Are you sure you wish to revoke the user authorizations?'), 'delete', _tr('Revoke authorizations')); $oGrid->addNew("?menu={$module_name}&action=new", _tr('Authorize new user'), true); // Construcción de la vista de usuarios autorizados $data = array(); $recordset = $pk->listAuthorizedUsers(); if (is_array($recordset)) { foreach ($recordset as $id_user => $auths) { $userinfo = $pACL->getUsers($id_user); $protocols = array(); foreach ($auths as $a) { $protocols[] = $a['name']; } $data[] = array('<input type="radio" name="id_user" value="' . $id_user . '" />', $userinfo[0][1], implode(' ', $protocols), "<a href=\"?menu={$module_name}&action=edit&id_user={$id_user}\">[" . _tr('Add/Remove Ports') . "]</a>"); } } $oGrid->pagingShow(false); $url = array("menu" => $module_name); $oGrid->setURL($url); $oGrid->setData($data); return $oGrid->fetchGrid(); }
function reportDHCP_Configuration($smarty, $module_name, $local_templates_dir, &$pDB, $arrConf) { $pDHCP_Configuration = new paloSantoDHCP_Configuration($pDB); $filter_field = getParameter("filter_field"); $filter_value = getParameter("filter_value"); $action = getParameter("nav"); $start = getParameter("start"); //begin grid parameters $oGrid = new paloSantoGrid($smarty); $nameOpt = array("hostname" => _tr('Host Name'), "ipaddress" => _tr('IP Address'), "macaddress" => _tr('MAC Address')); if (isset($nameOpt[$filter_field])) { $valorFiltro = $nameOpt[$filter_field]; } else { $valorFiltro = ""; } $oGrid->addFilterControl(_tr("Filter applied ") . " " . $valorFiltro . " = {$filter_value}", $_POST, array("filter_field" => "hostname", "filter_value" => "")); $totalDHCP_Configuration = $pDHCP_Configuration->contarIpFijas($filter_field, $filter_value); $oGrid->addNew("new_dhcpconft", _tr("Assign IP Address")); $oGrid->deleteList("Are you sure you wish to delete the DHCP configuration.", "delete_dhcpConf", _tr("Delete")); $limit = 20; $total = $totalDHCP_Configuration; $oGrid->setLimit($limit); $oGrid->setTotal($total); $oGrid->calculatePagination($action, $start); $offset = $oGrid->getOffsetValue(); $end = $oGrid->getEnd(); $arrData = null; $arrResult = $pDHCP_Configuration->leerIPsFijas($limit, $offset, $filter_field, $filter_value); if (is_array($arrResult) && $total > 0) { foreach ($arrResult as $key => $value) { $arrTmp[0] = "<input type='checkbox' name='DhcpConfID_{$value['id']}' />"; $arrTmp[1] = "<a href='?menu={$module_name}&action=view_dhcpconf&id=" . $value['id'] . "'>" . $value['hostname'] . "</a>"; $arrTmp[2] = $value['ipaddress']; $arrTmp[3] = $value['macaddress']; $arrData[] = $arrTmp; } } $buttonDelete = ""; $arrGrid = array("title" => _tr('Assign IP Address to Host'), "icon" => "modules/{$module_name}/images/system_network_assign_ip_address.png", "width" => "99%", "start" => $total == 0 ? 0 : $offset + 1, "end" => $end, "total" => $total, "url" => array('menu' => $module_name, 'filter_field' => $filter_field, 'filter_value' => $filter_value), "columns" => array(0 => array("name" => $buttonDelete, "property1" => ""), 1 => array("name" => _tr('Host Name'), "property1" => ""), 2 => array("name" => _tr('IP Address'), "property1" => ""), 3 => array("name" => _tr('MAC Address'), "property1" => ""))); //begin section filter $arrFormFilterDHCP_Configuration = createFieldFilter(); $oFilterForm = new paloForm($smarty, $arrFormFilterDHCP_Configuration); $smarty->assign("SHOW", _tr('Show')); $htmlFilter = $oFilterForm->fetchForm("{$local_templates_dir}/filter.tpl", "", $_POST); //end section filter $oGrid->showFilter(trim($htmlFilter)); $contenidoModulo = $oGrid->fetchGrid($arrGrid, $arrData); //end grid parameters return $contenidoModulo; }
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 report_conference($smarty, $module_name, $local_templates_dir, $pDB, $arrLang2, $arrConfig, $dsn_agi_manager, $dsnAsterisk) { global $arrLang; global $arrConf; $bSoporteWebConf = file_exists('modules/conferenceroom_list/libs/conferenceActions.lib.php'); $arrConference = array("Past_Conferences" => $arrLang["Past Conferences"], "Current_Conferences" => $arrLang["Current Conferences"], "Future_Conferences" => $arrLang["Future Conferences"]); $arrFormElements = array("conference" => array("LABEL" => $arrLang["State"], "REQUIRED" => "yes", "INPUT_TYPE" => "SELECT", "INPUT_EXTRA_PARAM" => $arrConference, "VALIDATION_TYPE" => "text", "VALIDATION_EXTRA_PARAM" => "", "EDITABLE" => "no", "SIZE" => "1"), "filter" => array("LABEL" => $arrLang["Filter"], "REQUIRED" => "no", "INPUT_TYPE" => "TEXT", "INPUT_EXTRA_PARAM" => array("id" => "filter_value"), "VALIDATION_TYPE" => "text", "VALIDATION_EXTRA_PARAM" => "")); $oFilterForm = new paloForm($smarty, $arrFormElements); $smarty->assign("SHOW", $arrLang["Show"]); // $smarty->assign("NEW_CONFERENCE", $arrLang["New Conference"]); $startDate = $endDate = date("Y-m-d H:i:s"); $conference = getParameter("conference"); $field_pattern = getParameter("filter"); if ($conference) { $_POST['conference'] = $conference; } else { $_POST['conference'] = "Current_Conferences"; } $oGrid = new paloSantoGrid($smarty); $oGrid->addFilterControl(_tr("Filter applied: ") . _tr("State") . " = " . $arrConference[$_POST['conference']], $_POST, array("conference" => "Current_Conferences"), true); $oGrid->addFilterControl(_tr("Filter applied: ") . _tr("Conference Name") . " = {$field_pattern}", $_POST, array("filter" => "")); $htmlFilter = $oFilterForm->fetchForm("{$local_templates_dir}/conference.tpl", "", $_POST); $pConference = new paloSantoConference($pDB); $total_datos = $pConference->ObtainNumConferences($startDate, $endDate, "confDesc", $field_pattern, $conference); //Paginacion $limit = 8; $total = $total_datos[0]; $oGrid->setLimit($limit); $oGrid->setTotal($total); $offset = $oGrid->calculateOffset(); $end = $offset + $limit <= $total ? $offset + $limit : $total; $url = array('menu' => $module_name, 'conference' => $conference, 'filter' => $field_pattern); //Fin Paginacion $arrResult = $pConference->ObtainConferences($limit, $offset, $startDate, $endDate, "confDesc", $field_pattern, $conference); $pConfWeb = NULL; if ($bSoporteWebConf) { $pConfWeb = embedded_prepareWebConfLister(); } $arrData = null; if (is_array($arrResult) && $total > 0) { // En caso de haber soporte de conferencias web, se recoge el ID de // conferencia telefónica asociada a la conferencia web, y se construye // la lista de datos para las columnas adicionales $listaWebConf = array(); if (!is_null($pConfWeb)) { $pACL = new paloACL($arrConf['elastix_dsn']['acl']); $listaWC = $pConfWeb->listarConferencias($pACL->isUserAdministratorGroup($_SESSION['elastix_user'])); foreach ($listaWC as $tuplaConf) { if (!is_null($tuplaConf['id_cbmysql_conference'])) { $listaWebConf[$tuplaConf['id_cbmysql_conference']] = $tuplaConf; } } } foreach ($arrResult as $key => $conference) { $arrTmp[0] = "<input type='checkbox' name='conference_{$conference['bookId']}' />"; $arrTmp[1] = "<a href='?menu={$module_name}&accion=view_conference&conferenceId=" . $conference['bookId'] . "'>" . htmlentities($conference['confDesc'], ENT_COMPAT, "UTF-8") . "</a>"; $arrTmp[2] = $conference['roomNo']; $arrTmp[3] = $conference['startTime'] . ' - ' . $conference['endTime']; if ($_POST['conference'] == "Current_Conferences") { $arrCallers = $pConference->ObtainCallers($dsn_agi_manager, $conference['roomNo']); $numCallers = count($arrCallers); $arrTmp[4] = "<a href='?menu={$module_name}&accion=show_callers&roomNo=" . $conference['roomNo'] . "'>{$numCallers} / {$conference['maxUser']}</a>"; } else { $arrTmp[4] = $conference['maxUser']; } if ($bSoporteWebConf) { $arrTmp[5] = ''; $arrTmp[6] = ''; $arrTmp[7] = ''; $arrTmp[8] = ''; if (isset($listaWebConf[$conference['bookId']])) { $tuplaConf = $listaWebConf[$conference['bookId']]; $arrTmp[5] = htmlentities($tuplaConf['tema'], ENT_COMPAT, "UTF-8"); $arrTmp[6] = $tuplaConf['num_invitados']; $arrTmp[7] = $tuplaConf['num_documentos']; $arrTmp[8] = "<a href=\"?menu={$module_name}&action=list_guests&id_conference={$tuplaConf['id_conferencia']}\">[{$arrLang['List guests']}]</a> " . "<a href=\"?menu={$module_name}&action=list_chatlog&id_conference={$tuplaConf['id_conferencia']}\">[{$arrLang['Chatlog']}]</a>"; } } $arrData[] = $arrTmp; } } $arrGrid = array("title" => $arrLang["Conference"], "url" => $url, "icon" => "/modules/{$module_name}/images/pbx_conference.png", "width" => "99%", "start" => $total == 0 ? 0 : $offset + 1, "end" => $end, "total" => $total, 'columns' => array(array('name' => ""), array("name" => $arrLang["Conference Name"]), array("name" => $arrLang["Conference #"]), array('name' => 'Period'), array('name' => $arrLang["Participants"]))); if ($bSoporteWebConf) { $arrGrid['columns'][] = array('name' => $arrLang['Topic']); $arrGrid['columns'][] = array('name' => $arrLang['# Guests']); $arrGrid['columns'][] = array('name' => $arrLang['# Docs']); $arrGrid['columns'][] = array('name' => $arrLang['Options']); } $oGrid->addNew("new_conference", _tr('New Conference')); $oGrid->deleteList(_tr("Are you sure you wish to delete conference (es)?"), "delete_conference", _tr("Delete")); $oGrid->showFilter(trim($htmlFilter)); $contenidoModulo = $oGrid->fetchGrid($arrGrid, $arrData, $arrLang); return $contenidoModulo; }
function reportCDR($smarty, $module_name, $local_templates_dir, $pDB, $arrConf, $credentials) { global $arrPermission; $error = ''; $pCDR = new paloSantoCDR($pDB); $pORGZ = new paloSantoOrganization($arrConf['elastix_dsn']["elastix"]); $pPBX = new paloAsteriskDB($arrConf['elastix_dsn']["elastix"]); if ($credentials['userlevel'] == 'superadmin') { $domain = getParameter('organization'); $domain = empty($domain) ? 'all' : $domain; $arrOrgz = array("all" => _tr("all")); foreach ($pORGZ->getOrganization(array()) as $value) { $arrOrgz[$value["domain"]] = $value["name"]; } } else { $arrOrgz = array(); $domain = $credentials['domain']; } $date_start = getParameter('date_start'); if (!preg_match("/^[[:digit:]]{1,2}[[:space:]]+[[:alnum:]]{3}[[:space:]]+[[:digit:]]{4}\$/", $date_start)) { $date_start = date("d M Y"); } $date_end = getParameter('date_end'); if (!preg_match("/^[[:digit:]]{1,2}[[:space:]]+[[:alnum:]]{3}[[:space:]]+[[:digit:]]{4}\$/", $date_end)) { $date_end = date("d M Y"); } $src = getParameter("src"); if (isset($src) && $src != '') { $expression = $pPBX->getRegexPatternFromAsteriskPattern($src); if ($expression === false) { $src = ''; } } $dst = getParameter("dst"); if (isset($dst) && $dst != '') { $expression = $pPBX->getRegexPatternFromAsteriskPattern($dst); if ($expression === false) { $dst = ''; } } $src_channel = getParameter("src_channel"); $dst_channel = getParameter("dst_channel"); $calltype = getParameter("calltype"); $arrCallType = array("all" => _tr("ALL"), 'incoming' => _tr('Incoming'), 'outgoing' => _tr("Outgoing")); $calltype = array_key_exists($calltype, $arrCallType) ? $calltype : "all"; $status = getParameter("status"); $arrStatus = array("all" => _tr("ALL"), 'ANSWERED' => _tr('ANSWERED'), 'BUSY' => _tr("BUSY"), 'FAILED' => _tr("FAILED"), "NO ANSWER " => _tr("NO ANSWER")); $status = array_key_exists($status, $arrStatus) ? $status : "all"; $accountcode = getParameter('accountcode'); $url['menu'] = $module_name; $url['organization'] = $paramFiltro['organization'] = $domain; $url['date_start'] = $paramFiltro['date_start'] = $date_start; $url['date_end'] = $paramFiltro['date_end'] = $date_end; $url['src'] = $paramFiltro['src'] = $src; $url['dst'] = $paramFiltro['dst'] = $dst; $url['src_channel'] = $paramFiltro['src_channel'] = $src_channel; $url['dst_channel'] = $paramFiltro['dst_channel'] = $dst_channel; $url['calltype'] = $paramFiltro['calltype'] = $calltype; $url['status'] = $paramFiltro['status'] = $status; $url['accountcode'] = $paramFiltro['accountcode'] = $accountcode; //permission $delete = in_array("delete", $arrPermission); $export = in_array("export", $arrPermission); //begin grid parameters $oGrid = new paloSantoGrid($smarty); $oGrid->setTitle(_tr("CDR Report")); $oGrid->pagingShow(true); if ($export) { $oGrid->enableExport(); // enable export. $oGrid->setNameFile_Export(_tr("CDRReport")); } $oGrid->setURL($url); if ($delete && !$oGrid->isExportAction()) { $arrColumns[] = "<input type='checkbox' name='cdrcheckall' class='cdrcheckall' id='cdrcheckall' onclick='jqCheckAll(this.id)';>"; } if ($credentials['userlevel'] == 'superadmin') { $arrColumns[] = _tr("Organization"); } $arrColumns[] = _tr("Date"); $arrColumns[] = _tr("Source"); if ($credentials['userlevel'] != 'superadmin') { $arrColumns[] = _tr("Ring Group"); } $arrColumns[] = _tr("Destination"); $arrColumns[] = _tr("Src. Channel"); $arrColumns[] = _tr("Account Code"); $arrColumns[] = _tr("Dst. Channel"); $arrColumns[] = _tr("Call Direction"); $arrColumns[] = _tr("Status"); $arrColumns[] = _tr("Duration"); $oGrid->setColumns($arrColumns); //get NumCDR $total = $pCDR->getNumCDR($paramFiltro); if ($total === false) { $total = 0; $error = _tr("An error has ocurred to retrieve CDR data") . " " . "DATABASE ERROR"; } $arrData = array(); $arrResult = array(); if ($total != 0) { if ($oGrid->isExportAction()) { if (!$export) { $arrData = _tr('INVALID ACTION'); } else { $arrResult = $pCDR->listarCDRs($paramFiltro); } } else { $limit = 20; $oGrid->setLimit($limit); $oGrid->setTotal($total); $offset = $oGrid->calculateOffset(); $arrResult = $pCDR->listarCDRs($paramFiltro, $limit, $offset); } } if ($arrResult === false) { $error = _tr('CDR data could not be retrieved.') . " " . "DATABASE ERROR"; } else { foreach ($arrResult as $value) { $arrTmp = array(); if ($delete && !$oGrid->isExportAction()) { $arrTmp[] = "<input type='checkbox' name='crdDel[]' class='cdrdelete' value='{$value['6']}' />"; } if ($credentials['userlevel'] == "superadmin") { $arrTmp[] = isset($arrOrgz[$value[11]]) ? $arrOrgz[$value[11]] : ''; } $arrTmp[] = $value[0]; //calldate $arrTmp[] = $value[1]; //src if ($credentials['userlevel'] != "superadmin") { $arrTmp[] = $value[10]; } //rg_name $arrTmp[] = $value[2]; //dst $arrTmp[] = $value[3]; //channel $arrTmp[] = $value[9]; //accountcode $arrTmp[] = $value[4]; //dst_channel if ($value[12] == "1" || $value[13] == "1") { //call_type $arrTmp[] = $value[12] == "1" ? "outgoing" : "incoming"; } else { $arrTmp[] = ""; } $arrTmp[] = $value[5]; //disposition $iDuracion = $value[8]; //billsec $iSec = $iDuracion % 60; $iDuracion = (int) (($iDuracion - $iSec) / 60); $iMin = $iDuracion % 60; $iDuracion = (int) (($iDuracion - $iMin) / 60); $sTiempo = "{$value[8]}s"; if ($value[8] >= 60) { if ($iDuracion > 0) { $sTiempo .= " ({$iDuracion}h {$iMin}m {$iSec}s)"; } elseif ($iMin > 0) { $sTiempo .= " ({$iMin}m {$iSec}s)"; } } $arrTmp[] = $sTiempo; $arrData[] = $arrTmp; } } $oGrid->setData($arrData); if ($error != "") { $smarty->assign("mb_title", _tr("MESSAGE")); $smarty->assign("mb_message", $error); } //begin section filter $smarty->assign("USERLEVEL", $credentials['userlevel']); $smarty->assign("SEARCH", "<input type='submit' class='button' value='" . _tr('Search') . "' name='report'>"); if ($delete) { $oGrid->deleteList(_tr("Are you sure you want to delete?"), "delete", _tr("Delete Selected"), false); } if ($credentials['userlevel'] == 'superadmin') { $_POST["organization"] = $domain; $oGrid->addFilterControl(_tr("Filter applied ") . _tr("Organization") . " = " . $arrOrgz[$domain], $_POST, array("organization" => "all"), true); } $_POST['date_start'] = $paramFiltro['date_start']; $_POST['date_end'] = $paramFiltro['date_end']; $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); //DATE START - DATE END $_POST["src"] = $src; // source $oGrid->addFilterControl(_tr("Filter applied ") . _tr("Source") . " = " . $src, $_POST, array("src" => "")); $_POST["dst"] = $dst; // destination $oGrid->addFilterControl(_tr("Filter applied ") . _tr("Destination") . " = " . $dst, $_POST, array("dst" => "")); $_POST["src_channel"] = $src_channel; // source channel $oGrid->addFilterControl(_tr("Filter applied ") . _tr("Source Channel") . " = " . $src_channel, $_POST, array("src_channel" => "")); $_POST["dst_channel"] = $dst_channel; // destination channel $oGrid->addFilterControl(_tr("Filter applied ") . _tr("Destination Channel") . " = " . $dst_channel, $_POST, array("dst_channel" => "")); $_POST["calltype"] = $calltype; // call type $oGrid->addFilterControl(_tr("Filter applied ") . _tr("Call Destination") . " = " . $arrCallType[$calltype], $_POST, array("calltype" => "all"), true); $_POST["status"] = $status; // call status $oGrid->addFilterControl(_tr("Filter applied ") . _tr("Call Status") . " = " . $arrStatus[$status], $_POST, array("status" => "all"), true); $_POST["accountcode"] = $accountcode; // destination channel $oGrid->addFilterControl(_tr("Filter applied ") . _tr("Account Code") . " = " . $dst, $_POST, array("accountcode" => "")); $arrForm = createFieldFilter($arrOrgz, $arrCallType, $arrStatus); $oFilterForm = new paloForm($smarty, $arrForm); $htmlFilter = $oFilterForm->fetchForm("{$local_templates_dir}/filter.tpl", "", $_POST); $oGrid->showFilter(trim($htmlFilter)); $content = $oGrid->fetchGrid(); return $content; }
function report_adress_book($smarty, $module_name, $local_templates_dir, $pDB, $pDB_2, $arrLang, $arrConf, $dsn_agi_manager, $dsnAsterisk) { $padress_book = new paloAdressBook($pDB); $arrBooker = $padress_book->getBookerList(); $arrPayment_type = array(0 => 'Khách lẻ không thường xuyên', 1 => 'Khách lẻ thường xuyên', 2 => 'Khách hàng công ty', 3 => 'Khách hàng đại lý'); $arrComboElements = array("customer_code" => "Mã khách hàng", "firstname" => "Tên khách hàng", "phone" => "Số điện thoại", "email" => "Email", "agent_id" => "Booker", "sale" => "Kinh Doanh", "booker" => "Kế Toán", "type" => "Loại khách hàng"); $arrFormElements = array("field" => array("LABEL" => "Tìm theo", "REQUIRED" => "no", "INPUT_TYPE" => "SELECT", "INPUT_EXTRA_PARAM" => $arrComboElements, "VALIDATION_TYPE" => "text", "VALIDATION_EXTRA_PARAM" => ""), "pattern" => array("LABEL" => "", "REQUIRED" => "no", "INPUT_TYPE" => "TEXT", "VALIDATION_TYPE" => "text", "VALIDATION_EXTRA_PARAM" => "", "INPUT_EXTRA_PARAM" => array('id' => 'filter_value')), "booker" => array("LABEL" => "", "REQUIRED" => "no", "INPUT_TYPE" => "SELECT", "INPUT_EXTRA_PARAM" => $arrBooker, "VALIDATION_TYPE" => "text", "VALIDATION_EXTRA_PARAM" => ""), "payment" => array("LABEL" => "", "REQUIRED" => "no", "INPUT_TYPE" => "SELECT", "INPUT_EXTRA_PARAM" => $arrPayment_type, "VALIDATION_TYPE" => "text", "VALIDATION_EXTRA_PARAM" => "")); $oFilterForm = new paloForm($smarty, $arrFormElements); $smarty->assign("SHOW", "Tìm"); $smarty->assign("module_name", $module_name); $field = NULL; $pattern = NULL; $namePattern = NULL; if (isset($_POST['field']) and isset($_POST['pattern']) and $_POST['pattern'] != "") { $field = $_POST['field']; $pattern = "%" . trim($_POST['pattern']) . "%"; $namePattern = trim($_POST['pattern']); //$nameField=$arrComboElements[$field]; //$agent_id = $_POST['booker']; //$payment_type = $_POST['booker']; } $arrFilter = array("field" => $field, "pattern" => $namePattern); $startDate = $endDate = date("Y-m-d H:i:s"); $oGrid = new paloSantoGrid($smarty); $oGrid->enableExport(); // enable export. $oGrid->setNameFile_Export("HNH_KhachHang"); $oGrid->addFilterControl(_tr("Filter applied ") . $field . " = {$namePattern}", $arrFilter, array("field" => "name", "pattern" => "")); $htmlFilter = $oFilterForm->fetchForm("{$local_templates_dir}/filter_adress_book.tpl", "", $arrFilter); $total = $padress_book->getAddressBook(NULL, NULL, $field, $pattern, TRUE); $total_datos = $total[0]["total"]; //Paginacion if ($oGrid->isExportAction()) { $total = $total_datos; $limit = $total; $arr_cols = array(0 => array("name" => "Mã KH", "property1" => ""), 1 => array("name" => "Tên khách hàng", "property1" => ""), 2 => array("name" => "Họ/Hình thức", "property1" => ""), 3 => array("name" => "Điện thoại/Liên hệ", "property1" => ""), 4 => array("name" => "Email/Liên hệ", "property1" => ""), 5 => array("name" => "Booker", "property1" => ""), 6 => array("name" => "Kinh doanh", "property1" => ""), 7 => array("name" => "Kế toán", "property1" => ""), 8 => array("name" => "Phân loại", "property1" => ""), 9 => array("name" => "Thẻ thành viên", "property1" => ""), 10 => array("name" => "Cách thanh toán", "property1" => "")); } else { $limit = 20; $total = $total_datos; $arr_cols = array(0 => array("name" => "", "property1" => ""), 1 => array("name" => "Mã KH", "property1" => ""), 2 => array("name" => "Tên khách hàng", "property1" => ""), 3 => array("name" => "Họ/Hình thức", "property1" => ""), 4 => array("name" => "Điện thoại/Liên hệ", "property1" => ""), 5 => array("name" => "Email/Liên hệ", "property1" => ""), 6 => array("name" => "Booker", "property1" => ""), 7 => array("name" => "Kinh doanh", "property1" => ""), 8 => array("name" => "Kế toán", "property1" => ""), 9 => array("name" => "Phân loại", "property1" => ""), 10 => array("name" => "Thẻ thành viên", "property1" => ""), 11 => array("name" => "Cách thanh toán", "property1" => ""), 12 => array("name" => "Lựa chọn", "property1" => "")); } $oGrid->setLimit($limit); $oGrid->setTotal($total); $offset = $oGrid->calculateOffset(); $inicio = $total == 0 ? 0 : $offset + 1; $end = $offset + $limit <= $total ? $offset + $limit : $total; //Fin Paginacion $arrResult = $padress_book->getAddressBook($limit, $offset, $field, $pattern, FALSE); //var_dump($arrResult);die; $arrData = null; //echo print_r($arrResult,true); if (is_array($arrResult) && $total > 0) { if ($oGrid->isExportAction()) { foreach ($arrResult as $key => $adress_book) { $typeContact = ""; switch ($adress_book['type']) { case '0': $typeContact = "Khách hàng lẽ"; break; case '1': $typeContact = "Khách lẽ thường xuyên"; break; case '2': $typeContact = 'Khách hàng công ty'; break; case '3': $typeContact = "Khách hàng đại lý"; break; default: break; } $phone_list = ''; if (isset($adress_book['number']) && count($adress_book['number']) > 0) { foreach ($adress_book['number'] as $phone) { $phone_list .= is_null($phone) || trim($phone) == '' ? '' : $phone . '\\n'; } } //SDT column $email_list = ''; if (count($adress_book['email']) > 0) { foreach ($adress_book['email'] as $email) { $email_list .= is_null($email) || trim($email) == '' ? '' : $email . '\\n'; } } $arrTmp[] = $adress_book['customer_code']; //Ten column $arrTmp[] = $adress_book['firstname']; //Ten column $arrTmp[] = $adress_book['lastname']; //Ten column $arrTmp[] = $phone_list; $arrTmp[] = $email_list; $arrTmp[] = $adress_book['booker']; $arrTmp[] = $adress_book['sale']; $arrTmp[] = $adress_book['accountant']; $arrTmp[] = $typeContact; $arrTmp[] = $adress_book['membership']; $arrTmp[] = $adress_book['payment']; $arrData[] = $arrTmp; } } else { foreach ($arrResult as $key => $adress_book) { switch ($adress_book['type']) { case '0': $typeContact = '<img border=0 src="/modules/' . $module_name . '/images/nor-customer.png" title="Khách hàng lẽ"/>KLE'; break; case '1': $typeContact = '<img border=0 src="/modules/' . $module_name . '/images/fre-customer.png" title="Khách hàng lẽ thường xuyên"/>KLE-TX'; break; case '2': $typeContact = '<img border=0 src="/modules/' . $module_name . '/images/company.png" title="Khách hàng công ty"/>CTY'; break; case '3': $typeContact = '<img border=0 src="/modules/' . $module_name . '/images/agency.png" title="Khách hàng đại lý"/>DLY'; break; default: break; } $phone_list = ''; if (isset($adress_book['number']) && count($adress_book['number']) > 0) { foreach ($adress_book['number'] as $phone) { $phone1 = explode('-', $phone); $call = trim($phone1[0]); $phone_list .= is_null($call) || trim($call) == '' ? '' : "<a href='?menu={$module_name}&action=call2phone&id=" . $call . "'><img border=0 src='/modules/{$module_name}/images/call.png' title='Gọi số " . $call . "'/></a> " . $phone . '<br/>'; //SDT column } } $email_list = ''; if (count($adress_book['email']) > 0) { foreach ($adress_book['email'] as $email) { $phone1 = explode('-', $email); $addr = trim($phone1[0]); $email_list .= is_null($addr) || trim($addr) == '' ? '' : '<a title="Gửi mail đến hộp mail này" href="mailto:' . $addr . '?Subject=[CallCenter]:" target="_top">' . $email . '</a><br/>'; } } $arrTmp[0] = "<input type='checkbox' name='contact_{$adress_book['id']}' />"; $arrTmp[1] = $adress_book['customer_code']; //Ten column $arrTmp[2] = $adress_book['firstname']; //Ten column $arrTmp[3] = $adress_book['lastname']; //Ten column $arrTmp[4] = $phone_list; $arrTmp[5] = $email_list; $arrTmp[6] = $adress_book['booker']; $arrTmp[7] = $adress_book['sale']; $arrTmp[8] = $adress_book['accountant']; $arrTmp[9] = $typeContact; $arrTmp[10] = $adress_book['membership']; $arrTmp[11] = $adress_book['payment']; $arrTmp[12] = "<a href='?menu={$module_name}&action=show&id=" . $adress_book['id'] . "'><img src='modules/{$module_name}/images/extra.png' title='Xem'></a> \n <a href='?menu={$module_name}&action=edit&id=" . $adress_book['id'] . "'><img src='modules/{$module_name}/images/edit.png' title='Sửa'></a> "; $arrData[] = $arrTmp; } } } $oGrid->deleteList("Bạn có muốn xóa khách hàng này không?", "delete", "Xóa"); $arrGrid = array("title" => "Thông tin khách hàng", "url" => array('menu' => $module_name, 'filter' => $pattern), "icon" => "modules/{$module_name}/images/address_book.png", "width" => "99%", "start" => $inicio, "end" => $end, "total" => $total, "columns" => $arr_cols); $oGrid->addNew("new", "Thêm khách hàng"); $oGrid->showFilter(trim($htmlFilter)); $contenidoModulo = $oGrid->fetchGrid($arrGrid, $arrData, $arrLang); return $contenidoModulo; }
function reportDIDorganization($smarty, $module_name, $local_templates_dir, $pDB, $arrConf, $credentials) { $pORGZ = new paloSantoOrganization($pDB); $pDID = new paloDidPBX($pDB); $domain = getParameter('domain'); if ($credentials['userlevel'] != "superadmin") { $domain = $credentials['domain']; } if (!preg_match("/^(([[:alnum:]-]+)\\.)+([[:alnum:]])+\$/", $domain)) { $smarty->assign("mb_title", _tr("ERROR")); $smarty->assign("mb_message", _tr("Invalid domain format")); return reportOrganization($smarty, $module_name, $local_templates_dir, $pDB, $arrConf, $credentials); } $total = $pDID->getTotalDID($domain); if ($total === false) { $smarty->assign("mb_title", _tr("ERROR")); $smarty->assign("mb_message", _tr("An error has ocurred to retrieve DID data")); return reportOrganization($smarty, $module_name, $local_templates_dir, $pDB, $arrConf, $credentials); } $limit = 20; $oGrid = new paloSantoGrid($smarty); $oGrid->setLimit($limit); $oGrid->setTotal($total); $offset = $oGrid->calculateOffset(); $end = $offset + $limit <= $total ? $offset + $limit : $total; $url['menu'] = $module_name; $url['domain'] = $domain; $oGrid->setTitle(_tr('DID Organization List')); $oGrid->setURL($url); $oGrid->setWidth("99%"); $oGrid->setStart($total == 0 ? 0 : $offset + 1); $oGrid->setEnd($end); $oGrid->setTotal($total); if ($credentials['userlevel'] == "superadmin") { $arrColumns[] = ''; $arrColumns[] = _tr("Organization Domain"); } $arrColumns[] = _tr("DID"); $arrColumns[] = _tr("Type"); $arrColumns[] = _tr("Country"); $arrColumns[] = _tr("City"); $arrColumns[] = _tr("Country Code / Area Code"); $oGrid->setColumns($arrColumns); $arrData = array(); $arrDID = $pDID->getDIDs($domain, null, null, null, $limit, $offset); if ($arrDID === false) { $smarty->assign("mb_title", _tr("ERROR")); $smarty->assign("mb_message", _tr("An error has ocurred to retrieve DID data")); return reportOrganization($smarty, $module_name, $local_templates_dir, $pDB, $arrConf, $credentials); } else { //si es un usuario solo se ve su didsion //si es un administrador ve todas las didsiones foreach ($arrDID as $did) { $arrTmp = array(); if ($credentials["userlevel"] == "superadmin") { $arrTmp[] = "<input type='checkbox' name='dids[]' value='{$did['id']}' />"; $arrTmp[] = $did["organization_domain"]; } $arrTmp[] = $did['did']; $arrTmp[] = $did["type"]; $arrTmp[] = $did["country"]; $arrTmp[] = $did["city"]; $arrTmp[] = $did["country_code"] . " / " . $did["area_code"]; $arrData[] = $arrTmp; } } if ($credentials['userlevel'] == "superadmin") { $oGrid->addNew("assignDIDs", _tr("Add DID")); $oGrid->deleteList(_tr('Are you sure you wish REMOVE this DID from organization'), 'removeDID', "Remove DID"); } $content = $oGrid->fetchGrid(array(), $arrData); return $content; }
function report_backup_restore($smarty, $module_name, $local_templates_dir, $dir_backup, &$pDB) { $total_archivos = array_reverse(array_map('basename', glob("{$dir_backup}/*.tar"))); // Paginacion $limit = 10; $total = count($total_archivos); $oGrid = new paloSantoGrid($smarty); $oGrid->setLimit($limit); $oGrid->setTotal($total); $offset = $oGrid->calculateOffset(); $end = $oGrid->getEnd(); $nombre_archivos = array_slice($total_archivos, $offset, $limit); //Fin Paginacion // obtencion de parametros desde la base $pFTPBackup = new paloSantoFTPBackup($pDB); $_DATA = $pFTPBackup->getStatusAutomaticBackupById(1); if (!(is_array($_DATA) & count($_DATA) > 0)) { $_DATA['status'] = "DISABLED"; } $arrData = null; if (is_array($nombre_archivos) && $total > 0) { foreach ($nombre_archivos as $key => $nombre_archivo) { $arrTmp[0] = "<input type='checkbox' name='chk[" . $nombre_archivo . "]' id='chk[" . $nombre_archivo . "]'/>"; $arrTmp[1] = "<a href='?menu={$module_name}&action=download_file&file_name={$nombre_archivo}&rawmode=yes'>{$nombre_archivo}</a>"; $fecha = ""; // se parsea el archivo para obtener la fecha if (preg_match("/\\w*-\\d{4}\\d{2}\\d{2}\\d{2}\\d{2}\\d{2}-\\w{2}\\.\\w*/", $nombre_archivo)) { //elastixbackup-20110720122759-p7.tar $arrMatchFile = preg_split("/-/", $nombre_archivo); $data = $arrMatchFile[1]; $fecha = substr($data, -8, 2) . "/" . substr($data, -10, 2) . "/" . substr($data, 0, 4) . " " . substr($data, -6, 2) . ":" . substr($data, -4, 2) . ":" . substr($data, -2, 2); $id = $arrMatchFile[1] . "-" . $arrMatchFile[2]; } $arrTmp[2] = $fecha; $arrTmp[3] = "<input type='submit' name='submit_restore[" . $nombre_archivo . "]' value='" . _tr('Restore') . "' class='button' />"; $arrData[] = $arrTmp; } } $arrGrid = array("title" => _tr('Backup List'), "url" => array('menu' => $module_name), "icon" => "/modules/{$module_name}/images/system_backup_restore.png", "width" => "99%", "start" => $total == 0 ? 0 : $offset + 1, "end" => $end, "total" => $total, "columns" => array(0 => array("name" => ""), 1 => array("name" => _tr('Name Backup')), 2 => array("name" => _tr('Date')), 3 => array("name" => _tr('Action')))); $time = $_DATA['status']; $smarty->assign("FILE_UPLOAD", _tr('File Upload')); $smarty->assign("AUTOMATIC", _tr('AUTOMATIC')); $smarty->assign("UPLOAD", _tr('Upload')); $smarty->assign("FTP_BACKUP", _tr('FTP Backup')); $oGrid->addNew("backup", _tr("Backup")); $oGrid->deleteList(_tr("Are you sure you wish to delete backup (s)?"), 'delete_backup', _tr("Delete")); $oGrid->customAction("view_form_FTP", _tr("FTP Backup")); $backupIntervals = array('DISABLED' => _tr('DISABLED'), 'DAILY' => _tr('DAILY'), 'MONTHLY' => _tr('MONTHLY'), 'WEEKLY' => _tr('WEEKLY')); $oGrid->addComboAction("time", _tr("AUTOMATIC"), $backupIntervals, $time, 'automatic'); $contenidoModulo = $oGrid->fetchGrid($arrGrid, $arrData); return $contenidoModulo; }
function reportRecording($smarty, $module_name, $local_templates_dir, &$pDB, $arrConf, $credentials) { global $arrPermission; $error = ""; $pORGZ = new paloSantoOrganization($pDB); $name = getParameter("name"); if ($credentials['userlevel'] == 'superadmin') { $domain = getParameter('organization'); $domain = empty($domain) ? 'all' : $domain; $arrOrgz = array("all" => _tr("all")); foreach ($pORGZ->getOrganization(array()) as $value) { $arrOrgz[$value["domain"]] = $value["name"]; } } else { $arrOrgz = array(); $domain = $credentials['domain']; } $url['menu'] = $module_name; $url['organization'] = $domain; $url['name'] = $name; $pRecording = new paloSantoRecordings($pDB); $total = $pRecording->getNumRecording($domain, $name); if ($total === false) { $error = $pRecording->errMsg; $total = 0; } $limit = 20; $oGrid = new paloSantoGrid($smarty); $oGrid->setLimit($limit); $oGrid->setTotal($total); $offset = $oGrid->calculateOffset(); $end = $offset + $limit <= $total ? $offset + $limit : $total; //permission $create = in_array("create", $arrPermission); $edit = in_array("edit", $arrPermission); $delete = in_array("delete", $arrPermission); if ($delete) { $check = " <input type='checkbox' name='checkall' class='checkall' id='checkall' onclick='jqCheckAll(this.id);' />"; } else { $check = ""; } $oGrid->setTitle(_tr('Recordings List')); //$oGrid->setIcon('url de la imagen'); $oGrid->setWidth("99%"); $oGrid->setStart($total == 0 ? 0 : $offset + 1); $oGrid->setEnd($end); $oGrid->setTotal($total); $oGrid->setURL($url); $arrColumns[] = $check; if ($credentials['userlevel'] == 'superadmin') { $arrColumns[] = _tr("Organization"); } $arrColumns[] = _tr("Name"); //$arrColumns[]=_tr("Source"); $arrColumns[] = _tr(""); $oGrid->setColumns($arrColumns); $arrRecordings = array(); $arrData = array(); if ($total != 0) { $arrRecordings = $pRecording->getRecordings($domain, $name, $limit, $offset); } if ($arrRecordings === false) { $error = _tr("Error to obtain Recordings") . $pRecording->errMsg; $arrRecordings = array(); } $i = 0; foreach ($arrRecordings as $recording) { $arrTmp = array(); $ext = explode(".", $recording["name"]); if ($delete) { $arrTmp[] = " <input type ='checkbox' class='delete' name='record_delete[]' value='" . $recording['uniqueid'] . "' />"; } if ($credentials['userlevel'] == 'superadmin') { $arrTmp[] = $recording["organization_domain"] == '' ? '' : $arrOrgz[$recording["organization_domain"]]; } //$arrTmp[] = $recording["source"]; $idfile = $recording['uniqueid']; if ($ext[1] == "gsm") { $div_display = ''; } else { $div_display = "<div class='single' id='{$i}' style='display:inline;'><span data-src='index.php?menu={$module_name}&action=download&id={$idfile}&rawmode=yes'><img style='cursor:pointer;' width='13px' src='web/apps/recordings/images/sound.png'/> </span></div>"; } $download = "<a href='index.php?menu={$module_name}&action=download&id={$idfile}&rawmode=yes'>" . $recording['name'] . "</a>"; $arrTmp[] = $div_display . $download; $arrTmp[] = "<audio></audio>"; $i++; $arrData[] = $arrTmp; } $smarty->assign("USERLEVEL", $credentials['userlevel']); $smarty->assign("SEARCH", "<input type='submit' class='button' value='" . _tr('Search') . "' name='report'>"); if ($create) { $oGrid->addNew("add_recording", _tr("Add Recording")); } if ($delete) { $oGrid->deleteList(_tr("Are you sure you want to delete?"), "remove", _tr("Delete Selected"), false); } if ($error != "") { $smarty->assign("mb_title", _tr("MESSAGE")); $smarty->assign("mb_message", $error); } if ($credentials['userlevel'] == 'superadmin') { $_POST["organization"] = $domain; $oGrid->addFilterControl(_tr("Filter applied ") . _tr("Organization") . " = " . $arrOrgz[$domain], $_POST, array("organization" => "all"), true); } $_POST["name"] = $name; // name $oGrid->addFilterControl(_tr("Filter applied ") . _tr("Name") . " = " . $name, $_POST, array("name" => "")); $arrFormElements = createFieldFilter($arrOrgz); $oFilterForm = new paloForm($smarty, $arrFormElements); $htmlFilter = $oFilterForm->fetchForm("{$local_templates_dir}/filter.tpl", "", $_POST); $oGrid->showFilter(trim($htmlFilter)); $contenidoModulo = $oGrid->fetchGrid(array(), $arrData); return $contenidoModulo; }
function listarFaxes(&$smarty, $module_name, $local_templates_dir, $pDB, $credentials) { global $arrPermission; $pORGZ = new paloSantoOrganization($pDB); $smarty->assign(array('SEARCH' => _tr('Search'))); $smarty->assign('USERLEVEL', $credentials['userlevel']); $arrOrgz = array(0 => "all"); $organization = getParameter('organization'); if ($credentials['userlevel'] == 'superadmin') { if (empty($organization)) { $organization = 0; } if ($pORGZ->getNumOrganization(array()) > 0) { foreach ($pORGZ->getOrganization(array()) as $value) { $arrOrgz[$value["id"]] = $value["name"]; } } } else { $tmpOrg = $pORGZ->getOrganizationById($credentials['id_organization']); $arrOrgz[$tmpOrg["id"]] = $tmpOrg['name']; $organization = $credentials['id_organization']; } $oFax = new paloFaxVisor($pDB); // Generación del filtro $oFilterForm = new paloForm($smarty, getFormElements($arrOrgz)); // 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')); if ($credentials['userlevel'] == 'superadmin') { $_POST["organization"] = $organization; $oGrid->addFilterControl(_tr("Filter applied ") . _tr("Organization") . " = " . $arrOrgz[$organization], $_POST, array("organization" => 0), true); //organization } $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; } $url = array_merge($url, $paramFiltro); $oGrid->setTitle(_tr("Fax Viewer")); $oGrid->setIcon("web/apps/{$module_name}/images/kfaxview.png"); $oGrid->pagingShow(true); // show paging section. $oGrid->setURL($url); $arrData = NULL; if ($organization == 0) { $total = $oFax->obtener_cantidad_faxes(null, $paramFiltro['name_company'], $paramFiltro['fax_company'], $paramFiltro['date_fax'], $paramFiltro['filter']); } else { $total = $oFax->obtener_cantidad_faxes($organization, $paramFiltro['name_company'], $paramFiltro['fax_company'], $paramFiltro['date_fax'], $paramFiltro['filter']); } if ($total === false) { $total = 0; $smarty->assign(array('mb_title' => _tr('ERROR'), 'mb_message' => $oFax->errMsg)); } $delete = in_array('delete_fax', $arrPermission); $edit = in_array('edit_fax', $arrPermission); $limit = 20; $oGrid->setLimit($limit); $oGrid->setTotal($total); $offset = $oGrid->calculateOffset(); if ($delete) { $columns[] = "<input type='checkbox' class='checkall'/>"; } if ($credentials['userlevel'] == 'superadmin') { $columns[] = _tr('Organization'); } $columns[] = _tr('Type'); $columns[] = _tr('File'); $columns[] = _tr('Fax Cid Name'); $columns[] = _tr('Fax Cid Number'); $columns[] = _tr('Fax Destiny'); $columns[] = _tr('Fax Date'); $columns[] = _tr('Status'); if ($edit) { $columns[] = _tr('Options'); } $oGrid->setColumns($columns); if ($total > 0) { if ($organization == 0) { $arrResult = $oFax->obtener_faxes(null, $paramFiltro['name_company'], $paramFiltro['fax_company'], $paramFiltro['date_fax'], $offset, $limit, $paramFiltro['filter']); } else { $arrResult = $oFax->obtener_faxes($organization, $paramFiltro['name_company'], $paramFiltro['fax_company'], $paramFiltro['date_fax'], $offset, $limit, $paramFiltro['filter']); } if (!is_array($arrResult)) { $smarty->assign(array('mb_title' => _tr('ERROR'), 'mb_message' => $oFax->errMsg)); } else { foreach ($arrResult as $fax) { foreach (array('pdf_file', 'company_name', 'company_fax', 'destiny_name', 'destiny_fax') as $k) { $fax[$k] = htmlentities($fax[$k], ENT_COMPAT, 'UTF-8'); } $doc = explode(".", $fax['pdf_file']); $iddoc = $doc[0]; $arrTmp = array(); if ($delete) { $arrTmp[] = '<input type="checkbox" name="faxes[]" value="' . $fax['id'] . '" />'; } if ($credentials['userlevel'] == 'superadmin') { $arrTmp[] = 'ttt'; } //$arrOrg[$fax['id_organization']]; $arrTmp[] = _tr($fax['type']); $arrTmp[] = 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']; $arrTmp[] = $fax['company_name']; $arrTmp[] = $fax['company_fax']; $arrTmp[] = $fax['destiny_name'] . " - " . $fax['destiny_fax']; $arrTmp[] = $fax['date']; $arrTmp[] = _tr($fax['status']) . (empty($fax['errormsg']) ? '' : ': ' . $fax['errormsg']); if ($edit) { $arrTmp[] = "<a href='?menu={$module_name}&action=edit&id=" . $fax['id'] . "'>" . _tr('Edit') . "</a>"; } $arrData[] = $arrTmp; } } } $oGrid->setData($arrData); if ($delete) { $oGrid->deleteList(_tr('Are you sure you wish to delete fax (es)?'), "faxes_delete", _tr("Delete")); } $oGrid->showFilter($htmlFilter); return $oGrid->fetchGrid(); }
function report_adress_book($smarty, $module_name, $local_templates_dir, $pDB, $pDB_2, $arrLang, $arrConf, $dsn_agi_manager, $dsnAsterisk) { $padress_book = new paloPhoneBook($pDB); $arrComboElements = array("firstname" => "Tên", "lastname" => "Họ", "extension" => "Số nội bộ", "mobile" => "Số điện thoại", "company_mobile" => "Số công ty"); $arrFormElements = array("field" => array("LABEL" => "Tìm theo", "REQUIRED" => "no", "INPUT_TYPE" => "SELECT", "INPUT_EXTRA_PARAM" => $arrComboElements, "VALIDATION_TYPE" => "text", "VALIDATION_EXTRA_PARAM" => ""), "pattern" => array("LABEL" => "", "REQUIRED" => "no", "INPUT_TYPE" => "TEXT", "INPUT_EXTRA_PARAM" => "", "VALIDATION_TYPE" => "text", "VALIDATION_EXTRA_PARAM" => "", "INPUT_EXTRA_PARAM" => array('id' => 'filter_value'))); $oFilterForm = new paloForm($smarty, $arrFormElements); $smarty->assign("SHOW", "Tìm"); $smarty->assign("NEW_adress_book", "Thêm khách hàng mới"); $smarty->assign("CSV", $arrLang["CSV"]); $smarty->assign("module_name", $module_name); $field = NULL; $pattern = NULL; $namePattern = NULL; $allowSelection = array("firstname", "lastname", "extension", "mobile", "company_mobile"); if (isset($_POST['field']) and isset($_POST['pattern']) and $_POST['pattern'] != "") { $field = $_POST['field']; if (!in_array($field, $allowSelection)) { $field = "firstname"; } $pattern = "%{$_POST['pattern']}%"; $namePattern = $_POST['pattern']; $nameField = $arrComboElements[$field]; } $arrFilter = array("field" => $field, "pattern" => $namePattern); $startDate = $endDate = date("Y-m-d H:i:s"); $oGrid = new paloSantoGrid($smarty); $oGrid->addFilterControl(_tr("Filter applied ") . $field . " = {$namePattern}", $arrFilter, array("field" => "name", "pattern" => "")); $htmlFilter = $oFilterForm->fetchForm("{$local_templates_dir}/filter.tpl", "", $arrFilter); $total = $padress_book->getAddressBook(NULL, NULL, $field, $pattern, TRUE); $total_datos = $total[0]["total"]; //Paginacion $limit = 20; $total = $total_datos; $oGrid->setLimit($limit); $oGrid->setTotal($total); $offset = $oGrid->calculateOffset(); $inicio = $total == 0 ? 0 : $offset + 1; $end = $offset + $limit <= $total ? $offset + $limit : $total; //Fin Paginacion $arrResult = $padress_book->getAddressBook($limit, $offset, $field, $pattern, FALSE); //var_dump($arrResult);die; $arrData = null; //echo print_r($arrResult,true); if (is_array($arrResult) && $total > 0) { foreach ($arrResult as $key => $adress_book) { $arrTmp[0] = "<input type='checkbox' name='contact_{$adress_book['id']}' />"; $arrTmp[1] = $adress_book['firstname']; //Ten column $arrTmp[2] = $adress_book['lastname']; //Ten column $arrTmp[3] = $adress_book['department']; //Ten column $arrTmp[4] = is_null($adress_book['company_mobile']) || $adress_book['company_mobile'] == '' ? '' : "<a href='?menu={$module_name}&action=call2phone&id=" . $adress_book['company_mobile'] . "'><img border=0 src='/modules/{$module_name}/images/call.png' title='Gọi số " . $adress_book['company_mobile'] . "'/></a>" . $adress_book['company_mobile']; $arrTmp[5] = is_null($adress_book['mobile']) || $adress_book['mobile'] == '' ? '' : "<a href='?menu={$module_name}&action=call2phone&id=" . $adress_book['mobile'] . "'><img border=0 src='/modules/{$module_name}/images/call.png' title='Gọi số " . $adress_book['mobile'] . "'/></a>" . $adress_book['mobile']; $arrTmp[6] = is_null($adress_book['extension']) || $adress_book['extension'] == '' ? '' : "<a href='?menu={$module_name}&action=call2phone&id=" . $adress_book['extension'] . "'><img border=0 src='/modules/{$module_name}/images/call.png' title='Gọi số " . $adress_book['extension'] . "'/></a>" . $adress_book['extension']; $arrTmp[7] = '<a title="Gửi mail đến hộp mail này" href="mailto:' . $adress_book['email'] . '?Subject=[CallCenter]:" target="_top">' . $adress_book['email'] . '</a>'; $arrTmp[8] = $adress_book['note']; $arrTmp[9] = "<a href='?menu={$module_name}&action=edit&id=" . $adress_book['id'] . "'>Edit</a>"; $arrData[] = $arrTmp; } } $oGrid->deleteList("Bạn có muốn xóa người này không?", "delete", "Xóa"); $arrGrid = array("title" => "Danh bạ điện thoại", "url" => array('menu' => $module_name, 'filter' => $pattern), "icon" => "modules/{$module_name}/images/address_book.png", "width" => "99%", "start" => $inicio, "end" => $end, "total" => $total, "columns" => array(0 => array("name" => '', "property1" => ""), 1 => array("name" => "Tên", "property1" => ""), 2 => array("name" => "Họ", "property1" => ""), 3 => array("name" => "Phòng - Công ty", "property1" => ""), 4 => array("name" => "Số di động công ty", "property1" => ""), 5 => array("name" => "Số di động", "property1" => ""), 6 => array("name" => "Số nội bộ", "property1" => ""), 7 => array("name" => "Email", "property1" => ""), 8 => array("name" => "Ghi chú", "property1" => ""), 9 => array("name" => "Sửa", "property1" => ""))); $oGrid->addNew("new", "Thêm danh bạ"); $oGrid->showFilter(trim($htmlFilter)); $contenidoModulo = $oGrid->fetchGrid($arrGrid, $arrData, $arrLang); return $contenidoModulo; }
function reportConference($smarty, $module_name, $local_templates_dir, &$pDB, $arrConf, $credentials) { global $arrPermission; $pORGZ = new paloSantoOrganization($pDB); $error = ""; $date = date("Y-m-d H:i"); $state_conf = getParameter("state_conf"); $name_conf = getParameter("name_conf"); $type_conf = getParameter("type_conf"); if (empty($state_conf)) { $state_conf = "all"; } if (empty($type_conf)) { $type_conf = "both"; } if (is_null($name_conf)) { $name_conf = ""; } if ($credentials['userlevel'] == "superadmin") { $domain = getParameter("organization"); $domain = empty($domain) ? 'all' : $domain; $arrOrgz = array("all" => _tr("all")); foreach ($pORGZ->getOrganization(array()) as $value) { $arrOrgz[$value["domain"]] = $value["name"]; } } else { $arrOrgz = array(); $domain = $credentials['domain']; } $url['menu'] = $module_name; $url["state_conf"] = $state_conf; $url["name_conf"] = $name_conf; $url["type_conf"] = $type_conf; $url['date'] = $date; $pconference = new paloConference($pDB, $domain); $total = $pconference->getTotalConference($domain, $date, $state_conf, $type_conf, $name_conf); if ($total === false) { $error = $pconference->errMsg; $total = 0; } $limit = 20; $oGrid = new paloSantoGrid($smarty); $oGrid->setLimit($limit); $oGrid->setTotal($total); $offset = $oGrid->calculateOffset(); $end = $offset + $limit <= $total ? $offset + $limit : $total; $oGrid->setTitle(_tr('Conference')); $oGrid->setWidth("99%"); $oGrid->setStart($total == 0 ? 0 : $offset + 1); $oGrid->setEnd($end); $oGrid->setTotal($total); $oGrid->setURL($url); //permission $delete = in_array("delete_conf", $arrPermission); $create = in_array("create_conf", $arrPermission); $edit = in_array("edit_conf", $arrPermission); $invite_part = in_array("admin_conference_participant", $arrPermission); if ($delete) { $arrColum[] = _tr(""); } $arrColum[] = _tr("Name"); $arrColum[] = _tr("Room Number"); $arrColum[] = _tr("Period"); $arrColum[] = _tr("Participants / MaxUsers"); $arrColum[] = _tr("Status"); $oGrid->setColumns($arrColum); $arrData = array(); $arrconference = array(); if ($total != 0) { $arrconference = $pconference->getConferesPagging($domain, $date, $limit, $offset, $state_conf, $type_conf, $name_conf); } $session = getSession(); if ($arrconference === false) { $error = _tr("Error getting conference data.") . $pconference->errMsg; } else { foreach ($arrconference as $conf) { $arrTmp = array(); if ($delete) { $arrTmp[] = "<input type='checkbox' name='confdel[]' value='{$conf['bookid']}'/>"; //delete } if ($edit) { $arrTmp[] = "<a href='?menu={$module_name}&action=view&id_conf={$conf['bookid']}&organization={$conf['organization_domain']}'>" . htmlentities($conf["name"], ENT_QUOTES, "UTF-8") . "</a>"; //name } else { $arrTmp[] = htmlentities($conf["name"], ENT_QUOTES, "UTF-8"); } $arrTmp[] = $conf["ext_conf"]; //roomnumber $perid = "No Set"; if (!empty($conf["startTime"]) && $conf["startTime"] != "1900-01-01 12:00:00") { $perid = $conf["startTime"] . " - " . $conf["endtime"]; } $arrTmp[] = $perid; //period $max = empty($conf["maxusers"]) ? "unlimited" : $conf["maxusers"]; $participants = "<spam class='conf_memb' id='{$conf['bookid']}'>" . $conf["members"] . " / {$max} </spam>"; $status = "<spam class='conf_status'></spam>"; if ($perid != "No Set") { $date = time(); if ($date >= strtotime($conf["startTime"]) && $date <= strtotime($conf["endtime"])) { if ($invite_part) { $participants = "<a href='?menu={$module_name}&action=current_conf&id_conf={$conf['bookid']}&organization={$conf['organization_domain']}' class='conf_memb' id='{$conf['bookid']}'>" . $conf["members"] . " / {$max}</a>"; } $status = "<spam class='conf_status' style='color:green'/>" . _tr("In Progress") . "</spam>"; } else { if ($date < strtotime($conf["startTime"])) { $status = "<spam class='conf_status'>" . _tr("Future") . "</spam>"; } else { $status = "<spam class='conf_status'>" . _tr("Past") . "</spam>"; } } } else { if ($invite_part) { $participants = "<a href='?menu={$module_name}&action=current_conf&id_conf={$conf['bookid']}&organization={$conf['organization_domain']}' class='conf_memb' id='{$conf['bookid']}'>" . $conf["members"] . " / {$max}</a>"; } } $arrTmp[] = $participants; $arrTmp[] = $status; $arrData[] = $arrTmp; //se usa para comprobar si ha habido cambios en el estado de las conferencias $session['conference']["conf_list"][$conf['bookid']] = array($participants, $status); } } //se escribe en session el estado actual de las conferencias putSession($session); //filters $smarty->assign("USERLEVEL", $credentials['userlevel']); $smarty->assign("SEARCH", "<input type='submit' class='button' value='" . _tr('Search') . "' name='report'>"); if ($pORGZ->getNumOrganization(array()) >= 1) { if ($create) { if ($credentials['userlevel'] == 'superadmin') { $oGrid->addComboAction("organization_add", _tr("ADD Conference"), array_slice($arrOrgz, 1), $selected = null, "create_conference", $onchange_select = null); } else { $oGrid->addNew("create_conference", _tr("ADD Conference")); } } if ($delete) { $oGrid->deleteList(_tr("Are you sure you wish to delete conference (es)?"), "delete_conference", _tr("Delete")); } if ($credentials['userlevel'] == 'superadmin') { $_POST["organization"] = $domain; $oGrid->addFilterControl(_tr("Filter applied ") . _tr("Organization") . " = " . $arrOrgz[$domain], $_POST, array("organization" => "all"), true); } //arreglo usado para formar los elementos del filtro $arrState = array("all" => _tr("All"), "past" => _tr("Past Conference"), "current" => _tr("Current Conference"), "future" => _tr("Future Conference")); $arrType = array("both" => _tr("Both"), "yes" => _tr("Schedule"), "no" => _tr("No Schedule")); $oGrid->addFilterControl(_tr("Filter applied: ") . _tr("State") . " = " . $arrState[$state_conf], $state_conf, array("state_conf" => "all"), true); $oGrid->addFilterControl(_tr("Filter applied: ") . _tr("Name") . " = " . $name_conf, $name_conf, array("name_conf" => "")); $oGrid->addFilterControl(_tr("Filter applied: ") . _tr("Type") . " = " . $arrType[$type_conf], $type_conf, array("type_conf" => "both"), true); $smarty->assign("SHOW", _tr("Show")); $arrFormElements = createFieldFilter($arrState, $arrType, $arrOrgz); $oFilterForm = new paloForm($smarty, $arrFormElements); $htmlFilter = $oFilterForm->fetchForm("{$local_templates_dir}/filter.tpl", "", $_POST); $oGrid->showFilter(trim($htmlFilter)); } else { $smarty->assign("mb_title", _tr("MESSAGE")); $smarty->assign("mb_message", _tr("It's necesary you create at least one organization so you can use this module")); } if ($error != "") { $smarty->assign("mb_title", _tr("MESSAGE")); $smarty->assign("mb_message", $error); } $contenidoModulo = $oGrid->fetchGrid(array(), $arrData); $contenidoModulo .= "<input type='hidden' name='grid_limit' id='grid_limit' value='{$limit}'>"; $contenidoModulo .= "<input type='hidden' name='grid_offset' id='grid_offset' value='{$offset}'>"; $contenidoModulo .= "<input type='hidden' name='conf_action' id='conf_action' value='report'>"; $mensaje = showMessageReload($module_name, $pDB, $credentials); $contenidoModulo = $mensaje . $contenidoModulo; return $contenidoModulo; }
function reportMonitoring($smarty, $module_name, $local_templates_dir, &$pDB, $arrConf, $credentials) { global $arrPermission; $error = ''; $pMonitoring = new paloSantoMonitoring($pDB); $pORGZ = new paloSantoOrganization($arrConf['elastix_dsn']["elastix"]); $pPBX = new paloAsteriskDB($arrConf['elastix_dsn']["elastix"]); if ($credentials['userlevel'] == 'superadmin') { $domain = getParameter('organization'); $domain = empty($domain) ? 'all' : $domain; $arrOrgz = array("all" => _tr("all")); foreach ($pORGZ->getOrganization(array()) as $value) { $arrOrgz[$value["domain"]] = $value["name"]; } } else { $arrOrgz = array(); $domain = $credentials['domain']; } $date_start = getParameter('date_start'); if (!preg_match("/^[[:digit:]]{1,2}[[:space:]]+[[:alnum:]]{3}[[:space:]]+[[:digit:]]{4}\$/", $date_start)) { $date_start = date("d M Y"); } $date_end = getParameter('date_end'); if (!preg_match("/^[[:digit:]]{1,2}[[:space:]]+[[:alnum:]]{3}[[:space:]]+[[:digit:]]{4}\$/", $date_end)) { $date_end = date("d M Y"); } $arrType = array("" => "", "conference" => _tr("Conference"), "group" => _tr("Group"), "queue" => _tr("Queue"), 'incoming' => _tr('Incoming'), 'outgoing' => _tr("Outgoing")); $type = getParameter("type"); $type = array_key_exists($type, $arrType) ? $type : ""; $source = getParameter("source"); if (isset($source) && $source != '') { $expression = $pPBX->getRegexPatternFromAsteriskPattern($source); if ($expression === false) { $source = ''; } } $destination = getParameter("destination"); if (isset($destination) && $destination != '') { $expression = $pPBX->getRegexPatternFromAsteriskPattern($destination); if ($expression === false) { $destination = ''; } } $url['menu'] = $module_name; $url['organization'] = $arrProp['organization'] = $domain; $url['date_start'] = $arrProp['date_start'] = $date_start; $url['date_end'] = $arrProp['date_end'] = $date_end; $url['source'] = $arrProp['source'] = $source; $url['destination'] = $arrProp['destination'] = $destination; $url['type'] = $arrProp['type'] = $type; //permission $delete = in_array("delete", $arrPermission); $export = in_array("export", $arrPermission); //begin grid parameters $oGrid = new paloSantoGrid($smarty); $oGrid->setTitle(_tr("Monitoring")); $oGrid->setIcon("web/apps/{$module_name}/images/pbx_monitoring.png"); $oGrid->pagingShow(true); // show paging section. if ($export) { $oGrid->enableExport(); } // enable export. $oGrid->setNameFile_Export(_tr("Monitoring")); $oGrid->setURL($url); if ($delete && !$oGrid->isExportAction()) { $arrColumns[] = ""; } if ($credentials['userlevel'] == 'superadmin') { $arrColumns[] = _tr('organization'); } $arrColumns[] = _tr("Date"); $arrColumns[] = _tr("Time"); $arrColumns[] = _tr("Source"); $arrColumns[] = _tr("Destination"); $arrColumns[] = _tr("Duration"); $arrColumns[] = _tr("Type"); $arrColumns[] = _tr("File"); if (!$oGrid->isExportAction()) { $arrColumns[] = ""; //to display audio } $oGrid->setColumns($arrColumns); $totalMonitoring = $pMonitoring->getNumMonitoring($arrProp); if ($totalMonitoring === false) { $error = _tr('Recordings could not be retrieved.') . " " . "DATABASE ERROR"; $totalMonitoring = 0; } $arrData = array(); $arrResult = array(); if ($totalMonitoring != 0) { if ($oGrid->isExportAction()) { $arrResult = $pMonitoring->getMonitoring($arrProp); } else { $limit = 20; $total = $totalMonitoring; $oGrid->setLimit($limit); $oGrid->setTotal($total); $offset = $oGrid->calculateOffset(); $arrProp['limit'] = $limit; $arrProp['offset'] = $offset; $arrResult = $pMonitoring->getMonitoring($arrProp); } } if ($arrResult === false) { $error = _tr('Recordings could not be retrieved.') . " " . "DATABASE ERROR"; } else { if ($oGrid->isExportAction()) { if (!$export) { $arrData = _tr('INVALID ACTION'); } foreach ($arrResult as $monitoring) { $arrTmp = array(); if ($credentials['userlevel'] == 'superadmin') { $arrTmp[] = isset($arrOrgz[$monitoring['organization_domain']]) ? $arrOrgz[$monitoring['organization_domain']] : ''; } $arrTmp[] = date('d M Y', strtotime($monitoring['calldate'])); //date $arrTmp[] = date('H:i:s', strtotime($monitoring['calldate'])); //time $arrTmp[] = $monitoring['src']; //source $arrTmp[] = $monitoring['dst']; //destination $arrTmp[] = SecToHHMMSS($monitoring['duration']); //duration $namefile = basename($monitoring['userfield']); $namefile = str_replace("audio:", "", $namefile); if ($monitoring['toout'] == '1') { $arrTmp[] = $arrType['outgoing']; } elseif ($monitoring['fromout'] == '1') { $arrTmp[] = $arrType['incoming']; } else { if ($namefile[0] == 'g') { $arrTmp[] = $arrType['group']; } elseif ($namefile[0] == 'q') { $arrTmp[] = $arrType['queue']; } elseif (strpos($namefile, "meetme-conf") !== false) { $arrTmp[] = $arrType['conference']; } else { $arrTmp[] = ""; } } $arrTmp[] = $namefile; $arrData[] = $arrTmp; } } else { $i = 0; foreach ($arrResult as $monitoring) { $arrTmp = array(); if ($delete) { $arrTmp[] = "<input type='checkbox' name='recordDel[]' value='{$monitoring['uniqueid']}' />"; } if ($credentials['userlevel'] == 'superadmin') { $arrTmp[] = isset($arrOrgz[$monitoring['organization_domain']]) ? $arrOrgz[$monitoring['organization_domain']] : ''; } $arrTmp[] = date('d M Y', strtotime($monitoring['calldate'])); //date $arrTmp[] = date('H:i:s', strtotime($monitoring['calldate'])); //time $arrTmp[] = $monitoring['src']; //source $arrTmp[] = $monitoring['dst']; //destination $arrTmp[] = SecToHHMMSS($monitoring['duration']); //duration $namefile = basename($monitoring['userfield']); $namefile = str_replace("audio:", "", $namefile); if ($monitoring['toout'] == '1') { $arrTmp[] = $arrType['outgoing']; } elseif ($monitoring['fromout'] == '1') { $arrTmp[] = $arrType['incoming']; } else { if ($namefile[0] == 'g') { $arrTmp[] = $arrType['group']; } elseif ($namefile[0] == 'q') { $arrTmp[] = $arrType['queue']; } elseif (strpos($namefile, "meetme-conf") !== false) { $arrTmp[] = $arrType['conference']; } else { $arrTmp[] = ""; } } if ($namefile == 'deleted') { $arrTmp[] = $namefile; $arrTmp[] = ""; } else { $explod_name = explode(".", $namefile); $ext = array_pop($explod_name); if ($ext == 'gsm' || $ext == 'WAV') { $div_display = "<a href=\"javascript:popUp('index.php?menu={$module_name}&action=display_record&id={$monitoring['uniqueid']}&rawmode=yes',350,100)\"><img style='cursor:pointer;' width='13px' src='web/apps/recordings/images/sound.png'/></a> "; } else { $div_display = "<div class='single' id='{$i}' style='display:inline;'><span data-src='index.php?menu={$module_name}&action=download&id={$monitoring['uniqueid']}&rawmode=yes'><img style='cursor:pointer;' width='13px' src='web/apps/recordings/images/sound.png'/> </span></div>"; } $download = "<a href='index.php?menu={$module_name}&action=download&id={$monitoring['uniqueid']}&rawmode=yes'>" . $namefile . "</a>"; $arrTmp[] = $div_display . $download; $arrTmp[] = "<audio></audio>"; } $i++; $arrData[] = $arrTmp; } } } $oGrid->setData($arrData); if ($error != "") { $smarty->assign("mb_title", _tr("MESSAGE")); $smarty->assign("mb_message", $error); } //begin section filter $smarty->assign("USERLEVEL", $credentials['userlevel']); $smarty->assign("SEARCH", "<input type='submit' class='button' value='" . _tr('Search') . "' name='report'>"); if ($delete) { $oGrid->deleteList(_tr("Are you sure you want to delete?"), "delete", _tr("Delete Selected"), false); } if ($credentials['userlevel'] == 'superadmin') { $_POST["organization"] = $domain; $oGrid->addFilterControl(_tr("Filter applied ") . _tr("Organization") . " = " . $arrOrgz[$domain], $_POST, array("organization" => _tr("all")), true); } $_POST['date_start'] = $arrProp['date_start']; $_POST['date_end'] = $arrProp['date_end']; $oGrid->addFilterControl(_tr("Filter applied ") . _tr("Start Date") . " = " . $arrProp['date_start'] . ", " . _tr("End Date") . " = " . $arrProp['date_end'], $arrProp, array('date_start' => date("d M Y"), 'date_end' => date("d M Y")), true); //DATE START - DATE END $_POST["type"] = $type; // type $oGrid->addFilterControl(_tr("Filter applied ") . _tr("Type") . " = " . $arrType[$type], $_POST, array("type" => "")); $_POST["source"] = $source; // source $oGrid->addFilterControl(_tr("Filter applied ") . _tr("Source") . " = " . $source, $_POST, array("source" => "")); $_POST["destination"] = $destination; // destination $oGrid->addFilterControl(_tr("Filter applied ") . _tr("Destination") . " = " . $source, $_POST, array("destination" => "")); $arrForm = createFieldFilter($arrOrgz, $arrType); $oFilterForm = new paloForm($smarty, $arrForm); $htmlFilter = $oFilterForm->fetchForm("{$local_templates_dir}/filter.tpl", "", $_POST); $oGrid->showFilter(trim($htmlFilter)); //end section filter $content = $oGrid->fetchGrid(); return $content; }
function _moduleContent(&$smarty, $module_name) { include_once "libs/paloSantoGrid.class.php"; include_once "libs/paloSantoConfig.class.php"; include_once "libs/paloSantoACL.class.php"; include_once "libs/paloSantoForm.class.php"; require_once "libs/misc.lib.php"; include_once "lib/paloSantoVoiceMail.class.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']; //segun el usuario que esta logoneado consulto si tiene asignada extension para buscar los voicemails $pDB = new paloDB($arrConf['elastix_dsn']['acl']); $pConfig = new paloConfig("/etc", "amportal.conf", "=", "[[:space:]]*=[[:space:]]*"); $arrAMP = $pConfig->leer_configuracion(false); $dsnAsterisk = $arrAMP['AMPDBENGINE']['valor'] . "://" . $arrAMP['AMPDBUSER']['valor'] . ":" . $arrAMP['AMPDBPASS']['valor'] . "@" . $arrAMP['AMPDBHOST']['valor'] . "/asterisk"; $pDB_ast = new paloDB($dsnAsterisk); 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>"; } $arrVoiceData = array(); $inicio = $fin = $total = 0; $extension = $pACL->getUserExtension($_SESSION['elastix_user']); $ext = $extension; $esAdministrador = $pACL->isUserAdministratorGroup($_SESSION['elastix_user']); $bandCustom = true; if (is_null($ext) || $ext == "") { $bandCustom = false; if (!$esAdministrador) { $smarty->assign("mb_message", "<b>" . $arrLang["contact_admin"] . "</b>"); return ""; } } if ($esAdministrador) { $extension = "[[:digit:]]+"; } $smarty->assign("menu", "voicemail"); $smarty->assign("Filter", $arrLang['Show']); //formulario para el filtro $arrFormElements = createFieldFormVoiceList($arrLang); $oFilterForm = new paloForm($smarty, $arrFormElements); // Por omision las fechas toman el sgte. valor (la fecha de hoy) $date_start = date("Y-m-d") . " 00:00:00"; $date_end = date("Y-m-d") . " 23:59:59"; $dateStartFilter = getParameter('date_start'); $dateEndFilter = getParameter('date_end'); $report = false; if (getParameter('filter')) { if ($oFilterForm->validateForm($_POST)) { // Exito, puedo procesar los datos ahora. $date_start = translateDate($dateStartFilter) . " 00:00:00"; $date_end = translateDate($dateEndFilter) . " 23:59:59"; $arrFilterExtraVars = array("date_start" => $dateStartFilter, "date_end" => $dateEndFilter); } else { // Error $smarty->assign("mb_title", $arrLang["Validation Error"]); $arrErrores = $oFilterForm->arrErroresValidacion; $strErrorMsg = "<b>{$arrLang['The following fields contain errors']}:</b><br>"; foreach ($arrErrores as $k => $v) { $strErrorMsg .= "{$k}, "; } $strErrorMsg .= ""; $smarty->assign("mb_message", $strErrorMsg); } if ($dateStartFilter == "") { $dateStartFilter = " "; } if ($dateEndFilter == "") { $dateEndFilter = " "; } //se añade control a los filtros $report = true; $arrDate = array('date_start' => $dateStartFilter, 'date_end' => $dateEndFilter); $htmlFilter = $oFilterForm->fetchForm("{$local_templates_dir}/filter.tpl", "", $_POST); } else { if (isset($dateStartFilter) and isset($dateEndFilter)) { $report = true; $date_start = translateDate($dateStartFilter) . " 00:00:00"; $date_end = translateDate($dateEndFilter) . " 23:59:59"; $arrDate = array('date_start' => $dateStartFilter, 'date_end' => $dateEndFilter); $arrFilterExtraVars = array("date_start" => $dateStartFilter, "date_end" => $dateEndFilter); $htmlFilter = $contenidoModulo = $oFilterForm->fetchForm("{$local_templates_dir}/filter.tpl", "", $_GET); } else { $report = true; //se añade control a los filtros $arrDate = array('date_start' => date("d M Y"), 'date_end' => date("d M Y")); $htmlFilter = $contenidoModulo = $oFilterForm->fetchForm("{$local_templates_dir}/filter.tpl", "", array('date_start' => date("d M Y"), 'date_end' => date("d M Y"))); } } $oGrid = new paloSantoGrid($smarty); if ($report) { $oGrid->addFilterControl(_tr("Filter applied ") . _tr("Start Date") . " = " . $arrDate['date_start'] . ", " . _tr("End Date") . " = " . $arrDate['date_end'], $arrDate, array('date_start' => date("d M Y"), 'date_end' => date("d M Y")), true); } if (getParameter('submit_eliminar')) { borrarVoicemails(); if ($oFilterForm->validateForm($_POST)) { // Exito, puedo procesar los datos ahora. $date_start = translateDate($_POST['date_start']) . " 00:00:00"; $date_end = translateDate($_POST['date_end']) . " 23:59:59"; $arrFilterExtraVars = array("date_start" => $_POST['date_start'], "date_end" => $_POST['date_end']); } $htmlFilter = $oFilterForm->fetchForm("{$local_templates_dir}/filter.tpl", "", $_POST); } if (getParameter('config')) { if (!(is_null($ext) || $ext == "")) { return form_config($smarty, $module_name, $local_templates_dir, $arrLang, $ext, $pDB_ast); } } if (getParameter('save')) { if (!save_config($smarty, $module_name, $local_templates_dir, $arrLang, $ext, $pDB_ast)) { return form_config($smarty, $module_name, $local_templates_dir, $arrLang, $ext, $pDB_ast); } } if (getParameter('action') == "display_record") { $file = getParameter("name"); $ext = getParameter("ext"); $user = isset($_SESSION['elastix_user']) ? $_SESSION['elastix_user'] : ""; $extension = $pACL->getUserExtension($user); $esAdministrador = $pACL->isUserAdministratorGroup($user); $path = "/var/spool/asterisk/voicemail/default"; $voicemailPath = "{$path}/{$ext}/INBOX/" . base64_decode($file); $tmpfile = basename($voicemailPath); $filetmp = "{$path}/{$ext}/INBOX/{$tmpfile}"; if (!is_file($filetmp)) { die("<b>404 " . $arrLang["no_file"] . "</b>"); } if (!$esAdministrador) { if ($extension != $ext) { die("<b>404 " . $arrLang["no_file"] . "</b>"); } $voicemailPath = "{$path}/{$extension}/INBOX/" . base64_decode($file); } if (isset($file) && preg_match("/^[[:alpha:]]+[[:digit:]]+\\.(wav|WAV|Wav|mp3|gsm)\$/", base64_decode($file))) { if (!is_file($voicemailPath)) { die("<b>404 " . $arrLang["no_file"] . "</b>"); } $sContenido = ""; $name = basename($voicemailPath); $format = substr(strtolower($name), -3); // This will set the Content-Type to the appropriate setting for the file $ctype = ''; switch ($format) { case "mp3": $ctype = "audio/mpeg"; break; case "wav": $ctype = "audio/x-wav"; break; case "Wav": $ctype = "audio/x-wav"; break; case "WAV": $ctype = "audio/x-wav"; break; case "gsm": $ctype = "audio/x-gsm"; break; // not downloadable // not downloadable default: die("<b>404 " . $arrLang["no_file"] . "</b>"); break; } if ($sContenido == "") { $session_id = session_id(); } $sContenido = <<<contenido <embed src='index.php?menu={$module_name}&action=download&ext={$ext}&name={$file}&rawmode=yes&elastixSession={$session_id}' width=300, height=20 autoplay=true loop=false type="{$ctype}"></embed><br> contenido; $smarty->assign("CONTENT", $sContenido); $smarty->display("_common/popup.tpl"); } else { die("<b>404 " . $arrLang["no_file"] . "</b>"); } return; } if (getParameter('action') == "download") { $user = isset($_SESSION['elastix_user']) ? $_SESSION['elastix_user'] : ""; $extension = $pACL->getUserExtension($user); $esAdministrador = $pACL->isUserAdministratorGroup($user); $record = getParameter("name"); $ext = getParameter("ext"); if (!preg_match("/^[[:digit:]]+\$/", $ext)) { Header("HTTP/1.1 404 Not Found"); die("<b>404 " . $arrLang["no_file"] . "</b>"); } $record = base64_decode($record); $path = "/var/spool/asterisk/voicemail/default"; $voicemailPath = "{$path}/{$ext}/INBOX/" . $record; //"$path/$record"; $tmpfile = basename($voicemailPath); $filetmp = "{$path}/{$ext}/INBOX/{$tmpfile}"; if (!is_file($filetmp)) { die("<b>404 " . $arrLang["no_file"] . "</b>"); } if (!$esAdministrador) { if ($extension != $ext) { Header("HTTP/1.1 404 Not Found"); die("<b>404 " . $arrLang["no_extension"] . "</b>"); } $voicemailPath = "{$path}/{$extension}/INBOX/" . $record; } if (isset($record) && preg_match("/^[[:alpha:]]+[[:digit:]]+\\.(wav|WAV|Wav|mp3|gsm)\$/", $record)) { // See if the file exists if (!is_file($voicemailPath)) { Header("HTTP/1.1 404 Not Found"); die("<b>404 " . $arrLang["no_file"] . "</b>"); } // Gather relevent info about file $size = filesize($voicemailPath); $name = basename($voicemailPath); //$extension = strtolower(substr(strrchr($name,"."),1)); $extension = substr(strtolower($name), -3); // This will set the Content-Type to the appropriate setting for the file $ctype = ''; switch ($extension) { case "mp3": $ctype = "audio/mpeg"; break; case "wav": $ctype = "audio/x-wav"; break; case "Wav": $ctype = "audio/x-wav"; break; case "WAV": $ctype = "audio/x-wav"; break; case "gsm": $ctype = "audio/x-gsm"; break; // not downloadable // not downloadable default: die("<b>404 " . $arrLang["no_file"] . "</b>"); break; } // need to check if file is mislabeled or a liar. $fp = fopen($voicemailPath, "rb"); if ($size && $ctype && $fp) { header("Pragma: public"); header("Expires: 0"); header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); header("Cache-Control: public"); header("Content-Description: wav file"); header("Content-Type: " . $ctype); header("Content-Disposition: attachment; filename=" . $name); header("Content-Transfer-Encoding: binary"); header("Content-length: " . $size); fpassthru($fp); } } else { Header("HTTP/1.1 404 Not Found"); die("<b>404 " . $arrLang["no_file"] . "</b>"); } return; } $end = 0; $url = array('menu' => $module_name); //si tiene extension consulto sino, muestro un mensaje de que no tiene asociada extension $archivos = array(); if (!(is_null($ext) || $ext == "") || $esAdministrador) { if (is_null($ext) || $ext == "") { $smarty->assign("mb_message", "<b>" . $arrLang["no_extension_assigned"] . "</b>"); } $path = "/var/spool/asterisk/voicemail/default"; $folder = "INBOX"; if ($esAdministrador) { if ($handle = opendir($path)) { while (false !== ($dir = readdir($handle))) { if ($dir != "." && $dir != ".." && ereg($extension, $dir, $regs) && is_dir($path . "/" . $dir)) { $directorios[] = $dir; } } } } else { $directorios[] = $extension; } //if($esAdministrador) $arrData = array(); foreach ($directorios as $directorio) { $voicemailPath = "{$path}/{$directorio}/{$folder}"; if (file_exists($voicemailPath)) { if ($handle = opendir($voicemailPath)) { $bExito = true; while (false !== ($file = readdir($handle))) { //no tomar en cuenta . y .. //buscar los archivos de texto (txt) que son los que contienen los datos de las llamadas if ($file != "." && $file != ".." && ereg("(.+)\\.[txt|TXT]", $file, $regs)) { //leer la info del archivo $pConfig = new paloConfig($voicemailPath, $file, "=", "[[:space:]]*=[[:space:]]*"); $arrVoiceMailDes = array(); $arrVoiceMailDes = $pConfig->leer_configuracion(false); //verifico que tenga datos if (is_array($arrVoiceMailDes) && count($arrVoiceMailDes) > 0 && isset($arrVoiceMailDes['origtime']['valor'])) { //uso las fechas del filtro //si la fecha de llamada esta dentro del rango, la muestro $fecha = date("Y-m-d", $arrVoiceMailDes['origtime']['valor']); $hora = date("H:i:s", $arrVoiceMailDes['origtime']['valor']); if (strtotime("{$fecha} {$hora}") <= strtotime($date_end) && strtotime("{$fecha} {$hora}") >= strtotime($date_start)) { $arrTmp[0] = "<input type='checkbox' name='" . utf8_encode("voc-" . $file) . ",{$directorio}' />"; $arrTmp[1] = $fecha; $arrTmp[2] = $hora; $arrTmp[3] = $arrVoiceMailDes['callerid']['valor']; $arrTmp[4] = $arrVoiceMailDes['origmailbox']['valor']; $arrTmp[5] = $arrVoiceMailDes['duration']['valor'] . ' sec.'; $pathRecordFile = base64_encode($regs[1] . '.wav'); $recordingLink = "<a href='#' onClick=\"javascript:popUp('index.php?menu={$module_name}&action=display_record&ext={$directorio}&name={$pathRecordFile}&rawmode=yes',350,100); return false;\">{$arrLang['Listen']}</a> "; $recordingLink .= "<a href='?menu={$module_name}&action=download&ext={$directorio}&name={$pathRecordFile}&rawmode=yes'>{$arrLang['Download']}</a>"; $arrTmp[6] = $recordingLink; $arrData[] = $arrTmp; } } } } closedir($handle); } } else { // No vale la ruta } } /* function sort_voicemails_hora_desc($a, $b) { return ($a[2] == $b[2]) ? 0 : (($a[2] < $b[2]) ? 1 : -1); } function sort_voicemails_fecha_desc($a, $b) { return ($a[1] == $b[1]) ? 0 : (($a[1] < $b[1]) ? 1 : -1); } usort($arrData, 'sort_voicemails_hora_desc'); usort($arrData, 'sort_voicemails_fecha_desc'); */ $fechas = array(); $horas = array(); foreach ($arrData as $llave => $fila) { $fechas[$llave] = $fila[1]; $horas[$llave] = $fila[2]; } array_multisort($fechas, SORT_DESC, $horas, SORT_DESC, $arrData); //Paginacion $limit = 15; $total = count($arrData); $oGrid->setLimit($limit); $oGrid->setTotal($total); $offset = $oGrid->calculateOffset(); $end = $offset + $limit <= $total ? $offset + $limit : $total; // Construyo el URL base if (isset($arrFilterExtraVars) && is_array($arrFilterExtraVars) and count($arrFilterExtraVars) > 0) { $url = array_merge($url, $arrFilterExtraVars); } //Fin Paginacion $arrVoiceData = array_slice($arrData, $offset, $limit); } else { $smarty->assign("mb_message", "<b>" . $arrLang["contact_admin"] . "</b>"); } $arrGrid = array("title" => $arrLang["Voicemail List"], "url" => $url, "icon" => "/modules/{$module_name}/images/pbx_voicemail.png", "width" => "99%", "start" => $total == 0 ? 0 : $offset + 1, "end" => $end, "total" => $total, "columns" => array(0 => array("name" => "", "property1" => ""), 1 => array("name" => $arrLang["Date"], "property1" => ""), 2 => array("name" => $arrLang["Time"], "property1" => ""), 3 => array("name" => $arrLang["CallerID"], "property1" => ""), 4 => array("name" => $arrLang["Extension"], "property1" => ""), 5 => array("name" => $arrLang["Duration"], "property1" => ""), 6 => array("name" => $arrLang["Message"], "property1" => ""))); if ($bandCustom == true) { $oGrid->customAction("config", _tr("Configuration")); } $oGrid->deleteList(_tr("Are you sure you wish to delete voicemails?"), "submit_eliminar", _tr("Delete")); $oGrid->showFilter($htmlFilter); $contenidoModulo = $oGrid->fetchGrid($arrGrid, $arrVoiceData, $arrLang); if (strpos($contenidoModulo, '<form') === FALSE) { $contenidoModulo = "<form style='margin-bottom:0;' method='POST' action='?menu={$module_name}'>{$contenidoModulo}</form>"; } return $contenidoModulo; }
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 _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 = $pACL->getUserExtension($_SESSION['elastix_user']); $isAdministrator = $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] = $value[0]; $arrTmp[1] = $value[1]; $arrTmp[2] = $value[11]; $arrTmp[3] = $value[2]; $arrTmp[4] = $value[3]; $arrTmp[5] = $value[9]; $arrTmp[6] = $value[4]; $arrTmp[7] = $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[8] >= 60) { if ($iDuracion > 0) { $sTiempo .= " ({$iDuracion}h {$iMin}m {$iSec}s)"; } elseif ($iMin > 0) { $sTiempo .= " ({$iMin}m {$iSec}s)"; } } $arrTmp[8] = $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(_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); if (is_array($arrResult['cdrs']) && $total > 0) { foreach ($arrResult['cdrs'] as $key => $value) { $arrTmp[0] = $value[0]; $arrTmp[1] = $value[1]; $arrTmp[2] = $value[11]; $arrTmp[3] = $value[2]; $arrTmp[4] = $value[3]; $arrTmp[5] = $value[9]; $arrTmp[6] = $value[4]; $arrTmp[7] = $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[8] >= 60) { if ($iDuracion > 0) { $sTiempo .= " ({$iDuracion}h {$iMin}m {$iSec}s)"; } elseif ($iMin > 0) { $sTiempo .= " ({$iMin}m {$iSec}s)"; } } $arrTmp[8] = $sTiempo; $arrData[] = $arrTmp; } } 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 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 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 report_adress_book($smarty, $module_name, $local_templates_dir, $pDB, $pDB_2, $arrLang, $arrConf, $dsn_agi_manager, $dsnAsterisk) { $padress_book = new paloAdressBook($pDB); $pACL = new paloACL($pDB_2); $user = $_SESSION["elastix_user"]; $id_user = $pACL->getIdUser($user); $extension = $pACL->getUserExtension($user); if (is_null($extension) || $extension == "") { if ($pACL->isUserAdministratorGroup($user)) { $smarty->assign("mb_title", _tr("MESSAGE")); $smarty->assign("mb_message", "<b>" . $arrLang["You don't have extension number associated with user"] . "</b>"); } else { $smarty->assign("mb_message", "<b>" . $arrLang["contact_admin"] . "</b>"); } } if (getParameter('select_directory_type') != null && getParameter('select_directory_type') == 'external') { $smarty->assign("external_sel", 'selected=selected'); $directory_type = 'external'; } else { $smarty->assign("internal_sel", 'selected=selected'); $directory_type = 'internal'; } $_POST['select_directory_type'] = $directory_type; $arrComboElements = array("name" => $arrLang["Name"], "telefono" => $arrLang["Phone Number"]); if ($directory_type == 'external') { $arrComboElements["last_name"] = $arrLang["Last Name"]; } $arrFormElements = array("field" => array("LABEL" => $arrLang["Filter"], "REQUIRED" => "no", "INPUT_TYPE" => "SELECT", "INPUT_EXTRA_PARAM" => $arrComboElements, "VALIDATION_TYPE" => "text", "VALIDATION_EXTRA_PARAM" => ""), "pattern" => array("LABEL" => "", "REQUIRED" => "no", "INPUT_TYPE" => "TEXT", "INPUT_EXTRA_PARAM" => "", "VALIDATION_TYPE" => "text", "VALIDATION_EXTRA_PARAM" => "", "INPUT_EXTRA_PARAM" => array('id' => 'filter_value'))); $oFilterForm = new paloForm($smarty, $arrFormElements); $smarty->assign("SHOW", $arrLang["Show"]); $smarty->assign("NEW_adress_book", $arrLang["New Contact"]); $smarty->assign("CSV", $arrLang["CSV"]); $smarty->assign("module_name", $module_name); $smarty->assign("Phone_Directory", $arrLang["Phone Directory"]); $smarty->assign("Internal", $arrLang["Internal"]); $smarty->assign("External", $arrLang["External"]); $field = NULL; $pattern = NULL; $namePattern = NULL; $allowSelection = array("name", "telefono", "last_name"); if (isset($_POST['field']) and isset($_POST['pattern']) and $_POST['pattern'] != "") { $field = $_POST['field']; if (!in_array($field, $allowSelection)) { $field = "name"; } $pattern = "%{$_POST['pattern']}%"; $namePattern = $_POST['pattern']; $nameField = $arrComboElements[$field]; } $arrFilter = array("select_directory_type" => $directory_type, "field" => $field, "pattern" => $namePattern); $startDate = $endDate = date("Y-m-d H:i:s"); $oGrid = new paloSantoGrid($smarty); $oGrid->addFilterControl(_tr("Filter applied ") . _tr("Phone Directory") . " = {$directory_type} ", $arrFilter, array("select_directory_type" => "internal"), true); $oGrid->addFilterControl(_tr("Filter applied ") . $field . " = {$namePattern}", $arrFilter, array("field" => "name", "pattern" => "")); $htmlFilter = $oFilterForm->fetchForm("{$local_templates_dir}/filter_adress_book.tpl", "", $arrFilter); if ($directory_type == 'external') { $total = $padress_book->getAddressBook(NULL, NULL, $field, $pattern, TRUE, $id_user); } else { $total = $padress_book->getDeviceFreePBX($dsnAsterisk, NULL, NULL, $field, $pattern, TRUE); } $total_datos = $total[0]["total"]; //Paginacion $limit = 20; $total = $total_datos; $oGrid->setLimit($limit); $oGrid->setTotal($total); $offset = $oGrid->calculateOffset(); $inicio = $total == 0 ? 0 : $offset + 1; $end = $offset + $limit <= $total ? $offset + $limit : $total; //Fin Paginacion if ($directory_type == 'external') { $arrResult = $padress_book->getAddressBook($limit, $offset, $field, $pattern, FALSE, $id_user); } else { $arrResult = $padress_book->getDeviceFreePBX($dsnAsterisk, $limit, $offset, $field, $pattern); } $arrData = null; //echo print_r($arrResult,true); if (is_array($arrResult) && $total > 0) { $arrMails = array(); $typeContact = ""; if ($directory_type == 'internal') { $arrMails = $padress_book->getMailsFromVoicemail(); } foreach ($arrResult as $key => $adress_book) { if ($directory_type == 'external') { $exten = explode(".", $adress_book["picture"]); if (isset($exten[count($exten) - 1])) { $exten = $exten[count($exten) - 1]; } $picture = "/var/www/address_book_images/{$adress_book['id']}_Thumbnail.{$exten}"; if (file_exists($picture)) { $arrTmp[1] = "<a href='?menu={$module_name}&action=show&id=" . $adress_book['id'] . "'><img alt='image' border='0' src='index.php?menu={$module_name}&action=getImage&idPhoto={$adress_book['id']}&thumbnail=yes&rawmode=yes'/></a>"; } else { $defaultPicture = "modules/{$module_name}/images/Icon-user_Thumbnail.png"; $arrTmp[1] = "<a href='?menu={$module_name}&action=show&id=" . $adress_book['id'] . "'><img border='0' alt='image' src='{$defaultPicture}'/></a>"; } } $arrTmp[0] = $directory_type == 'external' ? "<input type='checkbox' name='contact_{$adress_book['id']}' />" : ''; if ($directory_type == 'external') { $email = $adress_book['email']; if ($adress_book['status'] == 'isPublic') { if ($id_user == $adress_book['iduser']) { $typeContact = "<div><div style='float: left;'><a href='?menu={$module_name}&action=show&id=" . $adress_book['id'] . "'><img alt='public' style='padding: 5px;' title='" . $arrLang['Public Contact'] . "' border='0' src='modules/{$module_name}/images/public_edit.png' /></a></div><div style='padding: 16px 0px 0px 5px; text-align:center;'><span style='visibility: hidden;'>" . $arrLang['Public editable'] . "</span></div></div>"; $arrTmp[0] = "<input type='checkbox' name='contact_{$adress_book['id']}' />"; } else { $typeContact = "<div><div style='float: left;'><a href='?menu={$module_name}&action=show&id=" . $adress_book['id'] . "'><img alt='public' style='padding: 5px;' title='" . $arrLang['Public Contact'] . "' border='0' src='modules/{$module_name}/images/public.png' /></a></div><div style='padding: 16px 0px 0px 5px; text-align:center;'><span style='visibility: hidden;'>" . $arrLang['Public not editable'] . "</span></div></div>"; $arrTmp[0] = ""; } } else { $typeContact = "<div><div style='float: left;'><a href='?menu={$module_name}&action=show&id=" . $adress_book['id'] . "'><img alt='private' style='padding: 5px;' title='" . $arrLang['Private Contact'] . "' border='0' src='modules/{$module_name}/images/contact.png' /></a></div><div style='padding: 16px 0px 0px 5px; text-align:center;'><span style='visibility: hidden;'>" . $arrLang['Private'] . "</span></div></div>"; } } else { if (isset($arrMails[$adress_book['id']])) { $email = $arrMails[$adress_book['id']]; $typeContact = "<div><div style='float: left;'><img alt='public' title='" . $arrLang['Public Contact'] . "' src='modules/{$module_name}/images/public.png' /></div><div style='padding: 16px 0px 0px 5px; text-align:center;'><span style='visibility: hidden;'>" . $arrLang['Public not editable'] . "</span></div></div>"; } else { $email = ''; $typeContact = "<div><div style='float: left;'><img alt='public' title='" . $arrLang['Public Contact'] . "' src='modules/{$module_name}/images/public.png' /></div><div style='padding: 16px 0px 0px 5px; text-align:center;'><span style='visibility: hidden;'>" . $arrLang['Public not editable'] . "</span></div></div>"; } } $arrTmp[2] = $directory_type == 'external' ? "<a href='?menu={$module_name}&action=show&id=" . $adress_book['id'] . "'>" . htmlspecialchars($adress_book['last_name'], ENT_QUOTES, "UTF-8") . " " . htmlspecialchars($adress_book['name'], ENT_QUOTES, "UTF-8") . "</a>" : $adress_book['description']; $arrTmp[3] = $directory_type == 'external' ? $adress_book['telefono'] : $adress_book['id']; $arrTmp[4] = $email; $arrTmp[5] = "<a href='?menu={$module_name}&action=call2phone&id=" . $adress_book['id'] . "&type=" . $directory_type . "'><img border=0 src='/modules/{$module_name}/images/call.png' /></a>"; $arrTmp[6] = "<a href='?menu={$module_name}&action=transfer_call&id=" . $adress_book['id'] . "&type=" . $directory_type . "'>{$arrLang["Transfer"]}</a>"; $arrTmp[7] = $typeContact; $arrData[] = $arrTmp; } } if ($directory_type == 'external') { $name = ""; $picture = $arrLang["picture"]; $oGrid->deleteList(_tr("Are you sure you wish to delete the contact."), "delete", _tr("Delete")); } else { $name = ""; $picture = ""; } $arrGrid = array("title" => $arrLang["Address Book"], "url" => array('menu' => $module_name, 'filter' => $pattern, 'select_directory_type' => $directory_type), "icon" => "modules/{$module_name}/images/address_book.png", "width" => "99%", "start" => $inicio, "end" => $end, "total" => $total, "columns" => array(0 => array("name" => $name, "property1" => ""), 1 => array("name" => $picture, "property1" => ""), 2 => array("name" => $arrLang["Name"], "property1" => ""), 3 => array("name" => $arrLang["Phone Number"], "property1" => ""), 4 => array("name" => $arrLang["Email"], "property1" => ""), 5 => array("name" => $arrLang["Call"], "property1" => ""), 6 => array("name" => $arrLang["Transfer"], "property1" => ""), 7 => array("name" => $arrLang["Type Contact"], "property1" => ""))); $oGrid->addNew("new", _tr("New Contact")); $oGrid->showFilter(trim($htmlFilter)); $contenidoModulo = $oGrid->fetchGrid($arrGrid, $arrData, $arrLang); return $contenidoModulo; }
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 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 reportEmailList($smarty, $module_name, $local_templates_dir, &$pDB, $arrConf) { $pEmailList = new paloSantoEmailList($pDB); $pEmail = new paloEmail($pDB); $arrDomains = $pEmail->getDomains(); if (count($arrDomains) == 0) { $smarty->assign("mb_message", _tr("There is no domain created. To use this module you need at least one domain. You can create a domain in the module Email->Domains")); } else { $smarty->assign("VirtualDomains", 1); } $arrDominios = array("all" => _tr("All")); foreach ($arrDomains as $domain) { $arrDominios[$domain[0]] = $domain[1]; } $arrFormFilterEmailList = createFieldFilter($arrDominios); $oFilterForm = new paloForm($smarty, $arrFormFilterEmailList); //Verifico si en el archivo /etc/postfix/main.cf las variables alias_map y virtual_alias_map están apuntando a los archivos correctos, de no ser así se lo corrige $checkPostfixFile = $pEmailList->checkPostfixFile(); //begin grid parameters $oGrid = new paloSantoGrid($smarty); if (getParameter("domain")) { $id_domain = getParameter("domain"); } else { $id_domain = "all"; } $_POST["domain"] = $id_domain; $total = $pEmailList->getNumEmailList($id_domain); $limit = 20; $oGrid->setLimit($limit); $oGrid->setTotal($total); $oGrid->setTitle(_tr("Email List")); $oGrid->setIcon("/modules/{$module_name}/images/email.png"); $oGrid->pagingShow(true); // show paging section. $offset = $oGrid->calculateOffset(); $url = array('menu' => $module_name, 'domain' => $id_domain); $oGrid->setURL($url); $button_eliminar = ""; $arrResult = $pEmailList->getEmailList($id_domain, $limit, $offset); $arrColumns = array($button_eliminar, _tr("List name"), _tr("Membership"), _tr("Action")); $oGrid->setColumns($arrColumns); $arrData = null; if (is_array($arrResult) && $total > 0) { foreach ($arrResult as $key => $value) { $arrTmp[0] = "<input type='checkbox' name='" . $value['id'] . "' id='" . $value['id'] . "'>"; $domainName = $pEmailList->getDomainName($value['id_domain']); $arrTmp[1] = "<a href='?menu={$module_name}&action=view_memberlist&id=" . $value['id'] . "'>{$value['listname']}@{$domainName}</a>"; $arrTmp[2] = $pEmailList->getTotalMembers($value['id']); $arrTmp[3] = "<a href='?menu={$module_name}&action=new_memberlist&id=" . $value['id'] . "'>[ " . _tr("Add Members") . " ]</a> <a href='?menu={$module_name}&action=remove_memberlist&id=" . $value['id'] . "'>[ " . _tr("Remove members") . " ]</a> <a href='?menu={$module_name}&action=view_memberlist&id=" . $value['id'] . "'>[ " . _tr("View members") . " ]</a>"; $arrData[] = $arrTmp; } } $oGrid->setData($arrData); //begin section filter //ya no se usa esa variable smarty //$smarty->assign("NEW_EMAILLIST", _tr("New Email list")); $oGrid->addFilterControl(_tr("Filter applied ") . _tr("Domain") . " = " . $arrDominios[$id_domain], $_POST, array("domain" => "all"), true); $htmlFilter = $oFilterForm->fetchForm("{$local_templates_dir}/filter.tpl", "", $_POST); //end section filter $oGrid->addNew("new_emaillist", _tr("New Email list")); $oGrid->deleteList(_tr("Are you sure you wish to delete the Email List(s)."), "delete", _tr("Delete")); $oGrid->showFilter(trim($htmlFilter)); $content = $oGrid->fetchGrid(); if (strpos($content, '<form') === FALSE) { $content = "<form method='POST' style='margin-bottom:0;' action=" . construirURL($url) . ">{$content}</form>"; } //end grid parameters return $content; }