Exemplo n.º 1
0
function reportListadodecampañas($smarty, $module_name, $local_templates_dir, &$pDB, $arrConf)
{
    $pListadodecampañas = new paloSantoListadodecampañas($pDB);
    $filter_field = getParameter("filter_field");
    $filter_value = getParameter("filter_value");
    //begin grid parameters
    $oGrid = new paloSantoGrid($smarty);
    $oGrid->setTitle(_tr("Listado de campañas"));
    $oGrid->pagingShow(true);
    // show paging section.
    $oGrid->enableExport();
    // enable export.
    $oGrid->setNameFile_Export(_tr("Listado de campañas"));
    $url = array("menu" => $module_name, "filter_field" => $filter_field, "filter_value" => $filter_value);
    $oGrid->setURL($url);
    $arrColumns = array(_tr("Nombre"), _tr("Fecha Inicial"), _tr("Fecha Final"), _tr("Form"), _tr("# de Bases"), _tr("# de Agentes"), _tr("Tipo"), _tr("Acción"));
    $oGrid->setColumns($arrColumns);
    $total = $pListadodecampañas->getNumListadodecampañas($filter_field, $filter_value);
    $arrData = null;
    if ($oGrid->isExportAction()) {
        $limit = $total;
        // max number of rows.
        $offset = 0;
        // since the start.
    } else {
        $limit = 20;
        $oGrid->setLimit($limit);
        $oGrid->setTotal($total);
        $offset = $oGrid->calculateOffset();
    }
    $arrResult = $pListadodecampañas->getListadodecampañas($limit, $offset, $filter_field, $filter_value);
    if (is_array($arrResult) && $total > 0) {
        foreach ($arrResult as $key => $value) {
            $arrBasesAgentes = $pListadodecampañas->getBasesAgentes($value['id']);
            $arrTmp[0] = $value['nombre'];
            $arrTmp[1] = $value['fecha_inicio'];
            $arrTmp[2] = $value['fecha_fin'];
            $arrTmp[3] = $value['form'];
            $arrTmp[4] = $arrBasesAgentes['bases'];
            $arrTmp[5] = $arrBasesAgentes['agentes'];
            $arrTmp[6] = $value['tipo'];
            if ($value['tipo'] == "RECARGABLE") {
                $arrTmp[7] = "<a href=index.php?menu=hispana_campania_recargable&action=view_edit&id=" . $value['id'] . ">Editar</a>";
            } else {
                $arrTmp[7] = "<a href=index.php?menu=hispana_crear_campania&action=view_edit&id=" . $value['id'] . ">Editar</a>";
            }
            $arrData[] = $arrTmp;
        }
    }
    $oGrid->setData($arrData);
    //begin section filter
    $oFilterForm = new paloForm($smarty, createFieldFilter());
    $smarty->assign("SHOW", _tr("Show"));
    $htmlFilter = $oFilterForm->fetchForm("{$local_templates_dir}/filter.tpl", "", $_POST);
    //end section filter
    $oGrid->showFilter(trim($htmlFilter));
    $content = $oGrid->fetchGrid();
    //end grid parameters
    return $content;
}
Exemplo n.º 2
0
function reportListadodebases($smarty, $module_name, $local_templates_dir, &$pDB, $arrConf)
{
    $pListadodebases = new paloSantoListadodebases($pDB);
    $filter_field = getParameter("filter_field");
    $filter_value = getParameter("filter_value");
    //begin grid parameters
    $oGrid = new paloSantoGrid($smarty);
    $oGrid->setTitle(_tr("Listado de bases"));
    $oGrid->pagingShow(true);
    // show paging section.
    $oGrid->enableExport();
    // enable export.
    $oGrid->setNameFile_Export(_tr("Listado de bases"));
    $url = array("menu" => $module_name, "filter_field" => $filter_field, "filter_value" => $filter_value);
    $oGrid->setURL($url);
    $arrColumns = array(_tr("Base"), _tr("CI"), _tr("Nombre"), _tr("Apellido"), _tr("Provincia"), _tr("Ciudad"), _tr("Nacimiento"), _tr("Correo personal"), _tr("Correo trabajo"), _tr("Estado civil"), _tr("Action"));
    $oGrid->setColumns($arrColumns);
    $total = $pListadodebases->getNumListadodebases($filter_field, $filter_value);
    $arrData = null;
    if ($oGrid->isExportAction()) {
        $limit = $total;
        // max number of rows.
        $offset = 0;
        // since the start.
    } else {
        //$limit  = 20;
        $limit = 200;
        $oGrid->setLimit($limit);
        $oGrid->setTotal($total);
        $offset = $oGrid->calculateOffset();
    }
    $arrResult = $pListadodebases->getListadodebases($limit, $offset, $filter_field, $filter_value);
    if (is_array($arrResult) && $total > 0) {
        foreach ($arrResult as $key => $value) {
            $arrTmp[0] = $value['base'];
            $arrTmp[1] = $value['ci'];
            $arrTmp[2] = $value['nombre'];
            $arrTmp[3] = $value['apellido'];
            $arrTmp[4] = $value['provincia'];
            $arrTmp[5] = $value['ciudad'];
            $arrTmp[6] = $value['nacimiento'];
            $arrTmp[7] = $value['correo_personal'];
            $arrTmp[8] = $value['correo_trabajo'];
            $arrTmp[9] = $value['estado_civil'];
            $arrTmp[10] = "<a href='?menu=hispana_clientes_datosbasicos&ci=" . $value['ci'] . "'>Editar</a>";
            $arrData[] = $arrTmp;
        }
    }
    $oGrid->setData($arrData);
    //begin section filter
    $oFilterForm = new paloForm($smarty, createFieldFilter());
    $smarty->assign("SHOW", _tr("Show"));
    $htmlFilter = $oFilterForm->fetchForm("{$local_templates_dir}/filter.tpl", "", $_POST);
    //end section filter
    $oGrid->showFilter(trim($htmlFilter));
    $content = $oGrid->fetchGrid();
    //end grid parameters
    return $content;
}
Exemplo n.º 3
0
function reportReporteGeneraldeGestión($smarty, $module_name, $local_templates_dir, &$pDB, $arrConf)
{
    $pReporteGeneraldeGestión = new paloSantoReporteGeneraldeGestión($pDB);
    $filter_field = getParameter("filter_field");
    $filter_value = getParameter("filter_value");
    //begin grid parameters
    $oGrid = new paloSantoGrid($smarty);
    $oGrid->setTitle(_tr("Reporte General de Gestión"));
    $oGrid->pagingShow(true);
    // show paging section.
    $oGrid->enableExport();
    // enable export.
    $oGrid->setNameFile_Export(_tr("Reporte General de Gestión"));
    $url = array("menu" => $module_name, "filter_field" => $filter_field, "filter_value" => $filter_value);
    $oGrid->setURL($url);
    $arrColumns = array(_tr("Campaña"), _tr("Cliente"), _tr("CI"), _tr("Teléfono"), _tr("Agente"), _tr("Calltype"), _tr("Fecha"), _tr("Audio"));
    $oGrid->setColumns($arrColumns);
    $total = $pReporteGeneraldeGestión->getNumReporteGeneraldeGestión($filter_field, $filter_value);
    $arrData = null;
    if ($oGrid->isExportAction()) {
        $limit = $total;
        // max number of rows.
        $offset = 0;
        // since the start.
    } else {
        $limit = 20;
        $oGrid->setLimit($limit);
        $oGrid->setTotal($total);
        $offset = $oGrid->calculateOffset();
    }
    $arrResult = $pReporteGeneraldeGestión->getReporteGeneraldeGestión($limit, $offset, $filter_field, $filter_value);
    if (is_array($arrResult) && $total > 0) {
        foreach ($arrResult as $key => $value) {
            $arrTmp[0] = $value['campania'];
            $arrTmp[1] = $value['cliente'];
            $arrTmp[2] = $value['cedula'];
            $arrTmp[3] = $value['telefono'];
            $arrTmp[4] = $value['agente'];
            $arrTmp[5] = $value['calltype'];
            $arrTmp[6] = $value['fecha'];
            if (stripos($value['calltype'], "contactado") >= 0) {
                $arrTmp[7] = "<a href=monitoring_translator.php?action=download&id=" . $value['timestamp'] . "&rawmode=yes>Descargar</a>";
            }
            //$arrTmp[7] = "";
            $arrData[] = $arrTmp;
        }
    }
    $oGrid->setData($arrData);
    //begin section filter
    $oFilterForm = new paloForm($smarty, createFieldFilter());
    $smarty->assign("SHOW", _tr("Show"));
    $htmlFilter = $oFilterForm->fetchForm("{$local_templates_dir}/filter.tpl", "", $_POST);
    //end section filter
    $oGrid->showFilter(trim($htmlFilter));
    $content = $oGrid->fetchGrid();
    //end grid parameters
    return $content;
}
Exemplo n.º 4
0
function reportReportedeCalltypes($smarty, $module_name, $local_templates_dir, &$pDB, $arrConf)
{
    $pReportedeCalltypes = new paloSantoAgendadosAgente($pDB);
    $filter_field = getParameter("filter_field");
    $filter_value = getParameter("filter_value");
    $aditional_key = getParameter("aditional_key");
    $aditional_value = getParameter("aditional_value");
    $mostrar_adicionales = getParameter("mostrar_adicionales");
    $calltype_list = getParameter("calltype_list");
    //begin grid parameters
    $oGrid = new paloSantoGrid($smarty);
    $oGrid->setTitle(_tr("Agendados de Agente"));
    $oGrid->pagingShow(true);
    // show paging section.
    $oGrid->enableExport();
    // enable export.
    $oGrid->setNameFile_Export(_tr("Agendados de Agente"));
    $url = array("menu" => $module_name, "filter_field" => $filter_field, "filter_value" => $filter_value, "aditional_value" => $aditional_value, "aditional_key" => $aditional_key, "mostrar_adicionales" => $mostrar_adicionales);
    $oGrid->setURL($url);
    $arrColumns = array(_tr("Campaña"), _tr("Origen"), _tr("Agendamiento"), _tr("Cliente"), _tr("Teléfono"), _tr("Mejor calltype"), _tr("Observación"), _tr("Acción"));
    //Datos Adicionales
    $arrColumnasAdicionales = $pReportedeCalltypes->getColumnasAdicionales();
    if ($mostrar_adicionales == "on") {
        $arrColumns = array_merge($arrColumns, $arrColumnasAdicionales);
    }
    //fin datos adicionales
    $oGrid->setColumns($arrColumns);
    $total = $pReportedeCalltypes->getNumReporteAgendados($filter_field, $filter_value, $_SESSION['elastix_user'], $aditional_key, $aditional_value, $calltype_list);
    $arrData = null;
    if ($oGrid->isExportAction()) {
        $limit = $total;
        // max number of rows.
        $offset = 0;
        // since the start.
    } else {
        $limit = 200;
        // default 20 (muy poco)
        $oGrid->setLimit($limit);
        $oGrid->setTotal($total);
        $offset = $oGrid->calculateOffset();
    }
    $arrResult = $pReportedeCalltypes->getReporteAgendados($limit, $offset, $filter_field, $filter_value, $_SESSION['elastix_user'], $aditional_key, $aditional_value, $calltype_list);
    if (is_array($arrResult) && $total > 0) {
        foreach ($arrResult as $key => $value) {
            $arrTmp[0] = $value['campania'];
            $arrTmp[1] = $value['origen'];
            $arrTmp[2] = $value['fecha_agendamiento'];
            $arrTmp[3] = $value['cliente'];
            $arrTmp[4] = $value['telefono'];
            $arrTmp[5] = $value['contactabilidad'] . " - " . $value['mejor_calltype'];
            $arrTmp[6] = $value['observacion'];
            if (empty($value[id_campania_cliente])) {
                $arrTmp[7] = "<a href=index.php?menu=hispana_interfaz_agente&action=gestionar&id_campania_cliente_recargable={$value['id_campania_recargable_cliente']}>Gestionar</a>";
            } else {
                $arrTmp[7] = "<a href=index.php?menu=hispana_interfaz_agente&action=gestionar&id_campania_cliente={$value['id_campania_cliente']}>Gestionar</a>";
            }
            if ($mostrar_adicionales == "on") {
                if (empty($value[id_campania_cliente])) {
                    $arrDatosAdicionales = $pReportedeCalltypes->getDatosAdicionalesRecargable($value["id_campania_recargable_cliente"]);
                } else {
                    $arrDatosAdicionales = $pReportedeCalltypes->getDatosAdicionales($value["ci"]);
                }
                $i = 8;
                foreach ($arrColumnasAdicionales as $k => $columnaAdicional) {
                    $arrTmp[$i] = $arrDatosAdicionales[$columnaAdicional];
                    $i++;
                }
                unset($arrDatosAdicionales);
            }
            $arrData[] = $arrTmp;
        }
    }
    $oGrid->setData($arrData);
    /* Para colocar en $arrTmp 
     */
    //begin section filter
    $arrFormElements = createFieldFilter();
    //if($mostrar_adicionales=="on"){
    foreach ($arrColumnasAdicionales as $key => $value) {
        $arrAdicionales[$value] = $value;
    }
    $arrCalltypes = $pReportedeCalltypes->getCalltypes();
    $arrFormElements["calltype_list"] = array("LABEL" => _tr("Calltype"), "REQUIRED" => "no", "INPUT_TYPE" => "SELECT", "INPUT_EXTRA_PARAM" => $arrCalltypes, "VALIDATION_TYPE" => "text", "VALIDATION_EXTRA_PARAM" => "");
    $arrFormElements["aditional_key"] = array("LABEL" => _tr("Campo Adicional"), "REQUIRED" => "no", "INPUT_TYPE" => "SELECT", "INPUT_EXTRA_PARAM" => $arrAdicionales, "VALIDATION_TYPE" => "text", "VALIDATION_EXTRA_PARAM" => "");
    $arrFormElements["aditional_value"] = array("LABEL" => _tr("Valor"), "REQUIRED" => "no", "INPUT_TYPE" => "TEXT", "INPUT_EXTRA_PARAM" => "", "VALIDATION_TYPE" => "text", "VALIDATION_EXTRA_PARAM" => "");
    //}
    $oFilterForm = new paloForm($smarty, $arrFormElements);
    $smarty->assign("SHOW", _tr("Show"));
    $htmlFilter = $oFilterForm->fetchForm("{$local_templates_dir}/filter.tpl", "", $_POST);
    //end section filter
    $oGrid->showFilter(trim($htmlFilter));
    $content = $oGrid->fetchGrid();
    //end grid parameters
    return $content;
}
Exemplo n.º 5
0
function reportReporteEfectividad($smarty, $module_name, $local_templates_dir, &$pDB, $arrConf)
{
    $pReporteEfectividad = new paloSantoReporteEfectividad($pDB);
    $filter_field = getParameter("filter_field");
    $filter_value = getParameter("filter_value");
    //begin grid parameters
    $oGrid = new paloSantoGrid($smarty);
    $oGrid->setTitle(_tr("Reporte de efectividad"));
    $oGrid->pagingShow(true);
    // show paging section.
    $oGrid->enableExport();
    // enable export.
    $oGrid->setNameFile_Export(_tr("Reporte de efectividad"));
    $url = array("menu" => $module_name, "filter_field" => $filter_field, "filter_value" => $filter_value);
    $oGrid->setURL($url);
    $arrColumns = array(_tr("Campaña"), _tr("Acción"));
    $oGrid->setColumns($arrColumns);
    $total = $pReporteEfectividad->getNumReporteEfectividad($filter_field, $filter_value);
    $arrData = null;
    if ($oGrid->isExportAction()) {
        $limit = $total;
        // max number of rows.
        $offset = 0;
        // since the start.
    } else {
        $limit = 20;
        $oGrid->setLimit($limit);
        $oGrid->setTotal($total);
        $offset = $oGrid->calculateOffset();
    }
    $arrResult = $pReporteEfectividad->getReporteEfectividad($limit, $offset, $filter_field, $filter_value);
    if (is_array($arrResult) && $total > 0) {
        foreach ($arrResult as $key => $value) {
            $arrTmp[0] = $value['nombre'];
            $arrTmp[1] = "<a href=index.php?menu={$module_name}&id={$value['id']}&action=efectividad>Ver reporte de efectividad</a>";
            $arrData[] = $arrTmp;
        }
    }
    $oGrid->setData($arrData);
    //begin section filter
    $oFilterForm = new paloForm($smarty, createFieldFilter());
    $smarty->assign("SHOW", _tr("Show"));
    $htmlFilter = $oFilterForm->fetchForm("{$local_templates_dir}/filter.tpl", "", $_POST);
    //end section filter
    $oGrid->showFilter(trim($htmlFilter));
    $content = $oGrid->fetchGrid();
    //end grid parameters
    return $content;
}
Exemplo n.º 6
0
function reportListadodeCallTypes($smarty, $module_name, $local_templates_dir, &$pDB, $arrConf)
{
    $pListadodeCallTypes = new paloSantoListadodeCallTypes($pDB);
    $filter_field = getParameter("filter_field");
    $filter_value = getParameter("filter_value");
    //begin grid parameters
    $oGrid = new paloSantoGrid($smarty);
    $oGrid->setTitle(_tr("Listado de Call Types"));
    $oGrid->pagingShow(true);
    // show paging section.
    $oGrid->enableExport();
    // enable export.
    $oGrid->setNameFile_Export(_tr("Listado de Call Types"));
    $url = array("menu" => $module_name, "filter_field" => $filter_field, "filter_value" => $filter_value);
    $oGrid->setURL($url);
    $arrColumns = array(_tr("Campaña"), _tr("Call Type"), _tr("Clase de Call Type"), _tr("Peso"), _tr("Status"), _tr("Acción"));
    $oGrid->setColumns($arrColumns);
    $total = $pListadodeCallTypes->getNumListadodeCallTypes($filter_field, $filter_value);
    $arrData = null;
    if ($oGrid->isExportAction()) {
        $limit = $total;
        // max number of rows.
        $offset = 0;
        // since the start.
    } else {
        $limit = 20;
        $oGrid->setLimit($limit);
        $oGrid->setTotal($total);
        $offset = $oGrid->calculateOffset();
    }
    $arrResult = $pListadodeCallTypes->getListadodeCallTypes($limit, $offset, $filter_field, $filter_value);
    if (is_array($arrResult) && $total > 0) {
        foreach ($arrResult as $key => $value) {
            $arrTmp[0] = $value['campania'];
            $arrTmp[1] = $value['call_type'];
            $arrTmp[2] = $value['clase'];
            $arrTmp[3] = $value['peso'];
            $arrTmp[4] = $value['status'] == "A" ? "Activo" : "Inactivo";
            $arrTmp[5] = "<a href=index.php?menu={$module_name}&id={$value['id']}&id_campania={$value['id_campania']}&action=change_status&status=";
            if ($value['status'] == "A") {
                $arrTmp[5] .= "I";
                $accion = "Desactivar";
            } else {
                $arrTmp[5] .= "A";
                $accion = "Activar";
            }
            $arrTmp[5] .= ">{$accion}</a>";
            $arrTmp[5] .= " <a href=index.php?menu=hispana_call_types&id={$value['id']}&id_campania={$value['id_campania']}&action=view_edit>Editar</a>";
            $arrData[] = $arrTmp;
        }
    }
    $oGrid->setData($arrData);
    //begin section filter
    $oFilterForm = new paloForm($smarty, createFieldFilter());
    $smarty->assign("SHOW", _tr("Show"));
    $htmlFilter = $oFilterForm->fetchForm("{$local_templates_dir}/filter.tpl", "", $_POST);
    //end section filter
    $oGrid->showFilter(trim($htmlFilter));
    $content = $oGrid->fetchGrid();
    //end grid parameters
    return $content;
}
Exemplo n.º 7
0
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>&nbsp;\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;
}
Exemplo n.º 8
0
function reportReportedeCalltypes($smarty, $module_name, $local_templates_dir, &$pDB, $arrConf)
{
    $pReportedeCalltypes = new paloSantoReportedeCalltypes($pDB);
    $filter_field = getParameter("filter_field");
    $filter_value = getParameter("filter_value");
    $id_campania = getParameter("id_campania");
    $filter_field_adicional = getParameter("adicionales");
    $filter_value_adicional = getParameter("filtro_adicional");
    //begin grid parameters
    $oGrid = new paloSantoGrid($smarty);
    $oGrid->setTitle(_tr("Reporte Ultima Gestion Recargables"));
    $oGrid->pagingShow(true);
    // show paging section.
    $oGrid->enableExport();
    // enable export.
    $oGrid->setNameFile_Export(_tr("Reporte Ultima Gestion Recargables"));
    $url = array("menu" => $module_name, "filter_field" => $filter_field, "filter_value" => $filter_value, "id_campania" => $id_campania, "adicionales" => $filter_field_adicional, "filtro_adicional" => $filter_value_adicional);
    $oGrid->setURL($url);
    // Columnas base
    $arrColumns = array(_tr("Fecha"), _tr("Hora"), _tr("Campaña"), _tr("Base"), _tr("Cliente"), _tr("CI"), _tr("Teléfono"), _tr("Agente"), _tr("Contactabilidad"), _tr("Calltype"), _tr("Provincia"), _tr("Ciudad"), _tr("Nacimiento"), _tr("Correo Personal"), _tr("Correo Trabajo"), _tr("Estado Civil"), _tr("Formulario"));
    // Otras columnas
    if ($id_campania != "") {
        // Columnas adicionales
        $arrColumnasAdicionales = $pReportedeCalltypes->getColumnasAdicionales($id_campania);
        $arrColumns = array_merge($arrColumns, $arrColumnasAdicionales);
        $smarty->assign("mostrarAdicional", "si");
        $smarty->assign("filtro_adicionales", filter_adicionales($arrColumnasAdicionales, null));
        // Columnas de gestión
        $arrTmp = $pReportedeCalltypes->getFormFields($id_campania);
        $i = 0;
        foreach ($arrTmp as $formField) {
            $arrOrden[] = $formField['id'];
            $arrColumnsAdicionales[$i] = $formField['etiqueta'];
            $i++;
        }
        $arrColumns = array_merge($arrColumns, $arrColumnsAdicionales);
    }
    $oGrid->setColumns($arrColumns);
    $total = $pReportedeCalltypes->getNumReportedeCalltypes($filter_field, $filter_value, $id_campania, $filter_field_adicional, $filter_value_adicional);
    $arrData = null;
    if ($oGrid->isExportAction()) {
        $limit = $total;
        // max number of rows.
        $offset = 0;
        // since the start.
    } else {
        $limit = 20;
        // default 20
        $oGrid->setLimit($limit);
        $oGrid->setTotal($total);
        $offset = $oGrid->calculateOffset();
    }
    $arrResult = $pReportedeCalltypes->getReportedeCalltypes($limit, $offset, $filter_field, $filter_value, $id_campania, $filter_field_adicional, $filter_value_adicional);
    if (is_array($arrResult) && $total > 0) {
        foreach ($arrResult as $key => $value) {
            $fecha = date("Y-m-d", strtotime($value['fecha']));
            $hora = date("H:i:s", strtotime($value['fecha']));
            $arrTmp[0] = $fecha;
            $arrTmp[1] = $hora;
            $arrTmp[2] = $value['campania'];
            $arrTmp[3] = $value['base'];
            $arrTmp[4] = $value['cliente'];
            $arrTmp[5] = $value['ci'];
            $arrTmp[6] = $value['telefono'];
            $arrTmp[7] = $value['agente'];
            $arrTmp[8] = $value['contactabilidad'];
            $arrTmp[9] = $value['calltype'];
            $arrTmp[10] = $value['provincia'];
            $arrTmp[11] = $value['ciudad'];
            $arrTmp[12] = $value['nacimiento'];
            $arrTmp[13] = $value['correo_personal'];
            $arrTmp[14] = $value['correo_trabajo'];
            $arrTmp[15] = $value['estado_civil'];
            // $arrTmp[8] = $value['formulario'];
            // Así lo requiere RUBENING
            $arrTmp[16] = "<a href=modules/{$module_name}/gestion_info.php?id_gestion={$value['id_gestion']} target=\"_blank\" onClick=\"window.open(this.href, this.target, 'width=600,height=400'); return false;\">Ver gestión</a>" . "<br>" . "<a href=modules/{$module_name}/gestion_edit.php?id_gestion={$value['id_gestion']}&user="******"elastix_user"] . " target=\"_blank\" onClick=\"window.open(this.href, this.target, 'width=600,height=400,scrollbars=1'); return false;\">Editar</a>";
            // Datos adicionales
            $arrDatosAdicionales = $pReportedeCalltypes->getDatosAdicionales($value['id_cliente'], $value['id_base']);
            $i = 17;
            foreach ($arrColumnasAdicionales as $k => $columnaAdicional) {
                $arrTmp[$i] = $arrDatosAdicionales[$columnaAdicional];
                $i++;
            }
            unset($arrDatosAdicionales);
            $numColumnasFijas = $i;
            // Datos de gestión
            $arrFormValues = $pReportedeCalltypes->getFormValues($value['id_gestion']);
            // array_search retorna el key dado el valor a buscar
            foreach ($arrFormValues as $formValue) {
                // echo $formValue['valor'] . " " . array_search($formValue['id_form_field'],$arrOrden) . "<br>";
                $ubicacionReal = array_search($formValue['id_form_field'], $arrOrden) + $numColumnasFijas;
                if (is_array($formValue['valor'])) {
                    $formValue['valor'] = print_r($formValue['valor'], true);
                }
                $arrTmp[$ubicacionReal] = $formValue['valor'];
            }
            $arrData[] = $arrTmp;
            unset($arrTmp);
        }
    }
    $oGrid->setData($arrData);
    /* Para colocar en $arrTmp 
     */
    //begin section filter
    $oFilterForm = new paloForm($smarty, createFieldFilter());
    $smarty->assign("SHOW", _tr("Show"));
    $smarty->assign("filter_campaign", filter_campaign($pDB, $id_campania));
    $htmlFilter = $oFilterForm->fetchForm("{$local_templates_dir}/filter.tpl", "", $_POST);
    //end section filter
    $oGrid->showFilter(trim($htmlFilter));
    $content = $oGrid->fetchGrid();
    //end grid parameters
    return $content;
}
Exemplo n.º 9
0
function _moduleContent(&$smarty, $module_name)
{
    require_once "modules/{$module_name}/libs/ringgroup.php";
    //include module files
    include_once "modules/{$module_name}/configs/default.conf.php";
    load_language_module($module_name);
    global $arrConf;
    global $arrConfModule;
    $arrConf = array_merge($arrConf, $arrConfModule);
    //folder path for custom templates
    $base_dir = dirname($_SERVER['SCRIPT_FILENAME']);
    $templates_dir = isset($arrConf['templates_dir']) ? $arrConf['templates_dir'] : 'themes';
    $local_templates_dir = "{$base_dir}/modules/{$module_name}/" . $templates_dir . '/' . $arrConf['theme'];
    // DSN para consulta de cdrs
    $dsn = generarDSNSistema('asteriskuser', 'asteriskcdrdb');
    $pDB = new paloDB($dsn);
    $oCDR = new paloSantoCDR($pDB);
    $pDBACL = new paloDB($arrConf['elastix_dsn']['acl']);
    if (!empty($pDBACL->errMsg)) {
        return "ERROR DE DB: {$pDBACL->errMsg}";
    }
    $pACL = new paloACL($pDBACL);
    if (!empty($pACL->errMsg)) {
        return "ERROR DE ACL: {$pACL->errMsg}";
    }
    $exten = '6868';
    //$pACL->getUserExtension($_SESSION['elastix_user']);
    $isAdministrator = true;
    //$pACL->isUserAdministratorGroup($_SESSION['elastix_user']);
    if (is_null($exten) || $exten == "") {
        if (!$isAdministrator) {
            $smarty->assign('mb_message', "<b>" . _tr("contact_admin") . "</b>");
            return "";
        } else {
            $smarty->assign('mb_message', "<b>" . _tr("no_extension") . "</b>");
        }
    }
    // Para usuarios que no son administradores, se restringe a los CDR de la
    // propia extensión
    $sExtension = $isAdministrator ? '' : $pACL->getUserExtension($_SESSION['elastix_user']);
    // DSN para consulta de ringgroups
    $dsn_asterisk = generarDSNSistema('asteriskuser', 'asterisk');
    $pDB_asterisk = new paloDB($dsn_asterisk);
    $oRG = new RingGroup($pDB_asterisk);
    $dataRG = $oRG->getRingGroup();
    $dataRG[''] = _tr('(Any ringgroup)');
    // Cadenas estáticas en la plantilla
    $smarty->assign(array("Filter" => _tr("Filter")));
    $arrFormElements = array("date_start" => array("LABEL" => _tr("Start Date"), "REQUIRED" => "yes", "INPUT_TYPE" => "DATE", "INPUT_EXTRA_PARAM" => "", "VALIDATION_TYPE" => "ereg", "VALIDATION_EXTRA_PARAM" => "^[[:digit:]]{1,2}[[:space:]]+[[:alnum:]]{3}[[:space:]]+[[:digit:]]{4}\$"), "date_end" => array("LABEL" => _tr("End Date"), "REQUIRED" => "yes", "INPUT_TYPE" => "DATE", "INPUT_EXTRA_PARAM" => "", "VALIDATION_TYPE" => "ereg", "VALIDATION_EXTRA_PARAM" => "^[[:digit:]]{1,2}[[:space:]]+[[:alnum:]]{3}[[:space:]]+[[:digit:]]{4}\$"), "field_name" => array("LABEL" => _tr("Field Name"), "REQUIRED" => "no", "INPUT_TYPE" => "SELECT", "INPUT_EXTRA_PARAM" => array("dst" => _tr("Destination"), "src" => _tr("Source"), "channel" => _tr("Src. Channel"), "accountcode" => _tr("Account Code"), "dstchannel" => _tr("Dst. Channel")), "VALIDATION_TYPE" => "ereg", "VALIDATION_EXTRA_PARAM" => "^(dst|src|channel|dstchannel|accountcode)\$"), "field_pattern" => array("LABEL" => _tr("Field"), "REQUIRED" => "no", "INPUT_TYPE" => "TEXT", "INPUT_EXTRA_PARAM" => "", "VALIDATION_TYPE" => "ereg", "VALIDATION_EXTRA_PARAM" => "^[\\*|[:alnum:]@_\\.,/\\-]+\$"), "status" => array("LABEL" => _tr("Status"), "REQUIRED" => "no", "INPUT_TYPE" => "SELECT", "INPUT_EXTRA_PARAM" => array("ALL" => _tr("ALL"), "ANSWERED" => _tr("ANSWERED"), "BUSY" => _tr("BUSY"), "FAILED" => _tr("FAILED"), "NO ANSWER " => _tr("NO ANSWER")), "VALIDATION_TYPE" => "text", "VALIDATION_EXTRA_PARAM" => ""), "ringgroup" => array("LABEL" => _tr("Ring Group"), "REQUIRED" => "no", "INPUT_TYPE" => "SELECT", "INPUT_EXTRA_PARAM" => $dataRG, "VALIDATION_TYPE" => "text", "VALIDATION_EXTRA_PARAM" => ""));
    $oFilterForm = new paloForm($smarty, $arrFormElements);
    // Parámetros base y validación de parámetros
    $url = array('menu' => $module_name);
    $paramFiltroBase = $paramFiltro = array('date_start' => date("d M Y"), 'date_end' => date("d M Y"), 'field_name' => 'dst', 'field_pattern' => '', 'status' => 'ALL', 'ringgroup' => '');
    foreach (array_keys($paramFiltro) as $k) {
        if (!is_null(getParameter($k))) {
            $paramFiltro[$k] = getParameter($k);
        }
    }
    $oGrid = new paloSantoGrid($smarty);
    if ($paramFiltro['date_start'] === "") {
        $paramFiltro['date_start'] = " ";
    }
    if ($paramFiltro['date_end'] === "") {
        $paramFiltro['date_end'] = " ";
    }
    $valueFieldName = $arrFormElements['field_name']["INPUT_EXTRA_PARAM"][$paramFiltro['field_name']];
    $valueStatus = $arrFormElements['status']["INPUT_EXTRA_PARAM"][$paramFiltro['status']];
    $valueRingGRoup = $arrFormElements['ringgroup']["INPUT_EXTRA_PARAM"][$paramFiltro['ringgroup']];
    $oGrid->addFilterControl(_tr("Filter applied: ") . _tr("Start Date") . " = " . $paramFiltro['date_start'] . ", " . _tr("End Date") . " = " . $paramFiltro['date_end'], $paramFiltro, array('date_start' => date("d M Y"), 'date_end' => date("d M Y")), true);
    $oGrid->addFilterControl(_tr("Filter applied: ") . $valueFieldName . " = " . $paramFiltro['field_pattern'], $paramFiltro, array('field_name' => "dst", 'field_pattern' => ""));
    $oGrid->addFilterControl(_tr("Filter applied: ") . _tr("Status") . " = " . $valueStatus, $paramFiltro, array('status' => 'ALL'), true);
    $oGrid->addFilterControl(_tr("Filter applied: ") . _tr("Ring Group") . " = " . $valueRingGRoup, $paramFiltro, array('ringgroup' => ''));
    $htmlFilter = $oFilterForm->fetchForm("{$local_templates_dir}/filter.tpl", "", $paramFiltro);
    if (!$oFilterForm->validateForm($paramFiltro)) {
        $smarty->assign(array('mb_title' => _tr('Validation Error'), 'mb_message' => '<b>' . _tr('The following fields contain errors') . ':</b><br/>' . implode(', ', array_keys($oFilterForm->arrErroresValidacion))));
        $paramFiltro = $paramFiltroBase;
        unset($_POST['delete']);
        // Se aborta el intento de borrar CDRs, si había uno.
    }
    // Tradudir fechas a formato ISO para comparación y para API de CDRs.
    $url = array_merge($url, $paramFiltro);
    $paramFiltro['date_start'] = translateDate($paramFiltro['date_start']) . ' 00:00:00';
    $paramFiltro['date_end'] = translateDate($paramFiltro['date_end']) . ' 23:59:59';
    // Valores de filtrado que no se seleccionan mediante filtro
    if ($sExtension != '') {
        $paramFiltro['extension'] = $sExtension;
    }
    // Ejecutar el borrado, si se ha validado.
    if (isset($_POST['delete'])) {
        if ($isAdministrator) {
            if ($paramFiltro['date_start'] <= $paramFiltro['date_end']) {
                $r = $oCDR->borrarCDRs($paramFiltro);
                if (!$r) {
                    $smarty->assign(array('mb_title' => _tr('ERROR'), 'mb_message' => $oCDR->errMsg));
                }
            } else {
                $smarty->assign(array('mb_title' => _tr('ERROR'), 'mb_message' => _tr("Please End Date must be greater than Start Date")));
            }
        } else {
            $smarty->assign(array('mb_title' => _tr('ERROR'), 'mb_message' => _tr("Only administrators can delete CDRs")));
        }
    }
    $oGrid->setTitle(_tr("CDR Report"));
    $oGrid->pagingShow(true);
    // show paging section.
    $oGrid->enableExport();
    // enable export.
    $oGrid->setNameFile_Export(_tr("CDRReport"));
    $oGrid->setURL($url);
    //if($isAdministrator)
    //$oGrid->deleteList("Are you sure you wish to delete CDR(s) Report(s)?","delete",_tr("Delete"));
    $arrData = null;
    if (!isset($sExtension) || $sExtension == "" && !$isAdministrator) {
        $total = 0;
    } else {
        $total = $oCDR->contarCDRs($paramFiltro);
    }
    if ($oGrid->isExportAction()) {
        $limit = $total;
        $offset = 0;
        $arrColumns = array(_tr("Date"), _tr("Source"), _tr("Ring Group"), _tr("Destination"), _tr("Src. Channel"), _tr("Account Code"), _tr("Dst. Channel"), _tr("Status"), _tr("Duration"));
        $oGrid->setColumns($arrColumns);
        $arrResult = $oCDR->listarCDRs($paramFiltro, $limit, $offset);
        if (is_array($arrResult['cdrs']) && $total > 0) {
            foreach ($arrResult['cdrs'] as $key => $value) {
                $arrTmp[0] = date("d-m-Y H:i:s", strtotime($value[0]));
                $arrTmp[1] = $value[1];
                $arrTmp[2] = $value[11];
                $arrTmp[3] = $value[3];
                $arrTmp[4] = $value[9];
                $arrTmp[5] = $value[5];
                $iDuracion = $value[8];
                $iSec = $iDuracion % 60;
                $iDuracion = (int) (($iDuracion - $iSec) / 60);
                $iMin = $iDuracion % 60;
                $iDuracion = (int) (($iDuracion - $iMin) / 60);
                $sTiempo = "{$value[6]}s";
                if ($value[6] >= 60) {
                    if ($iDuracion > 0) {
                        $sTiempo .= " ({$iDuracion}h {$iMin}m {$iSec}s)";
                    } elseif ($iMin > 0) {
                        $sTiempo .= " ({$iMin}m {$iSec}s)";
                    }
                }
                $arrTmp[7] = $sTiempo;
                $arrData[] = $arrTmp;
            }
        }
        if (!is_array($arrResult)) {
            $smarty->assign(array('mb_title' => _tr('ERROR'), 'mb_message' => $oCDR->errMsg));
        }
    } else {
        $limit = 20;
        $oGrid->setLimit($limit);
        $oGrid->setTotal($total);
        $offset = $oGrid->calculateOffset();
        $arrResult = $oCDR->listarCDRs($paramFiltro, $limit, $offset);
        $arrColumns = array('STT', _tr("Date"), _tr("Source"), _tr("Destination"), _tr("Src. Channel"), _tr("Dst. Channel"), _tr("Status"), _tr("Duration"));
        $oGrid->setColumns($arrColumns);
        if (is_array($arrResult['cdrs']) && $total > 0) {
            $index = 0;
            foreach ($arrResult['cdrs'] as $key => $value) {
                $arrTmp[0] = $index;
                $arrTmp[1] = date("d-m-Y H:i:s", strtotime($value[0]));
                $arrTmp[2] = $value[1];
                $arrTmp[3] = $value[2];
                $arrTmp[4] = channel_lookup($pDB_asterisk, $value[3]);
                $arrTmp[5] = channel_lookup($pDB_asterisk, $value[4]);
                $arrTmp[6] = $value[5];
                $iDuracion = $value[8];
                $iSec = $iDuracion % 60;
                $iDuracion = (int) (($iDuracion - $iSec) / 60);
                $iMin = $iDuracion % 60;
                $iDuracion = (int) (($iDuracion - $iMin) / 60);
                $sTiempo = "{$value[8]}s";
                if ($value[7] >= 60) {
                    if ($iDuracion > 0) {
                        $sTiempo .= " ({$iDuracion}h {$iMin}m {$iSec}s)";
                    } elseif ($iMin > 0) {
                        $sTiempo .= " ({$iMin}m {$iSec}s)";
                    }
                }
                $arrTmp[7] = $sTiempo;
                $arrData[] = $arrTmp;
                $index++;
            }
        }
        if (!is_array($arrResult)) {
            $smarty->assign(array('mb_title' => _tr('ERROR'), 'mb_message' => $oCDR->errMsg));
        }
    }
    $oGrid->setData($arrData);
    $smarty->assign("SHOW", _tr("Show"));
    $oGrid->showFilter($htmlFilter);
    $content = $oGrid->fetchGrid();
    return $content;
}
Exemplo n.º 10
0
function reportClientesCampania($smarty, $module_name, $local_templates_dir, &$pDB, $arrConf)
{
    $pClientesagendados = new paloSantoClientesCampania($pDB);
    $filter_field = getParameter("filter_field");
    $filter_value = getParameter("filter_value");
    //begin grid parameters
    $oGrid = new paloSantoGrid($smarty);
    $oGrid->setTplFile("/var/www/html/modules/{$module_name}/themes/default/_list.tpl");
    $oGrid->setTitle(_tr("Clientes por campaña"));
    $oGrid->pagingShow(true);
    // show paging section.
    $oGrid->enableExport();
    // enable export.
    $oGrid->setNameFile_Export(_tr("Clientes por campaña"));
    $url = array("menu" => $module_name, "filter_field" => $filter_field, "filter_value" => $filter_value);
    $oGrid->setURL($url);
    $arrColumns = array(_tr("CI"), _tr("Cliente"), _tr("Campaña"), _tr("Agendamiento"), _tr("Agendado a"), _tr("Acción"));
    $oGrid->setColumns($arrColumns);
    $total = $pClientesagendados->getNumClientesCampania($filter_field, $filter_value);
    $arrData = null;
    if ($oGrid->isExportAction()) {
        $limit = $total;
        // max number of rows.
        $offset = 0;
        // since the start.
    } else {
        $limit = 100;
        $oGrid->setLimit($limit);
        $oGrid->setTotal($total);
        $offset = $oGrid->calculateOffset();
    }
    $arrResult = $pClientesagendados->getClientesCampania($limit, $offset, $filter_field, $filter_value);
    if (is_array($arrResult) && $total > 0) {
        foreach ($arrResult as $key => $value) {
            $arrTmp[0] = $value['ci'];
            $arrTmp[1] = $value['cliente'];
            $arrTmp[2] = $value['campania'];
            $arrTmp[3] = $value['fecha_agendamiento'];
            $arrTmp[4] = $value['agente_agendado'];
            //$arrTmp[3] = getFormSelectAgentesCampania($pClientesagendados,$value['id_campania'],$value['id_campania_cliente'],$value['agente_agendado']);
            $arrTmp[5] = "<a href='index.php?menu={$module_name}&id_campania_cliente={$value['id_campania_cliente']}&action=agendar'>Agendar</a>" . " / <a href='index.php?menu=hispana_clientes_datosbasicos&id_cliente=" . $value['id_cliente'] . "'>Editar</a>";
            $arrData[] = $arrTmp;
        }
    }
    $oGrid->setData($arrData);
    //begin section filter
    $oFilterForm = new paloForm($smarty, createFieldFilter());
    $smarty->assign("SHOW", _tr("Show"));
    $htmlFilter = $oFilterForm->fetchForm("{$local_templates_dir}/filter.tpl", "", $_POST);
    //end section filter
    $oGrid->showFilter(trim($htmlFilter));
    $content = $oGrid->fetchGrid();
    //end grid parameters
    return $content;
}
Exemplo n.º 11
0
function _moduleContent(&$smarty, $module_name)
{
    include_once "libs/paloSantoGrid.class.php";
    include_once "libs/paloSantoDB.class.php";
    include_once "libs/paloSantoForm.class.php";
    include_once "libs/paloSantoConfig.class.php";
    require_once "libs/misc.lib.php";
    //Incluir librería de lenguaje
    load_language_module($module_name);
    //include module files
    include_once "modules/{$module_name}/configs/default.conf.php";
    include_once "modules/{$module_name}/libs/paloSantoCallPerAgent.class.php";
    global $arrConf;
    global $arrLang;
    $arrCallsAgentTmp = 0;
    //folder path for custom templates
    $base_dir = dirname($_SERVER['SCRIPT_FILENAME']);
    $templates_dir = isset($arrConfig['templates_dir']) ? $arrConfig['templates_dir'] : 'themes';
    $local_templates_dir = "{$base_dir}/modules/{$module_name}/" . $templates_dir . '/' . $arrConf['theme'];
    $pConfig = new paloConfig("/etc", "amportal.conf", "=", "[[:space:]]*=[[:space:]]*");
    $arrConfig = $pConfig->leer_configuracion(false);
    $pDB = new paloDB($cadena_dsn);
    $arrData = array();
    $oCallsAgent = new paloSantoCallsAgent($pDB);
    $urlVars = array('menu' => $module_name);
    $smarty->assign("menu", "calls_per_agent");
    $smarty->assign("Filter", _tr('Query'));
    $arrFormElements = createFieldFilter();
    $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";
    $arrFilterExtraVars = null;
    $fieldPat = array();
    if (isset($_POST['filter'])) {
        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";
            if (!empty($_POST['field_pattern'])) {
                $fieldPat[$_POST['field_name']][] = $_POST['field_pattern'];
            }
            if (!empty($_POST['field_pattern_1'])) {
                $fieldPat[$_POST['field_name_1']][] = $_POST['field_pattern_1'];
            }
            $arrFilterExtraVars = array("date_start" => $_POST['date_start'], "date_end" => $_POST['date_end'], "field_name" => $_POST['field_name'], "field_pattern" => $_POST['field_pattern'], "field_name_1" => $_POST['field_name_1'], "field_pattern_1" => $_POST['field_pattern_1']);
        } else {
            // Error
            $smarty->assign("mb_title", _tr("Validation Error"));
            $arrErrores = $oFilterForm->arrErroresValidacion;
            $strErrorMsg = "<b>" . _tr('The following fields contain errors') . ":</b><br>";
            foreach ($arrErrores as $k => $v) {
                $strErrorMsg .= "{$k}, ";
            }
            $strErrorMsg .= "";
            $smarty->assign("mb_message", $strErrorMsg);
        }
        $htmlFilter = $contenidoModulo = $oFilterForm->fetchForm("{$local_templates_dir}/filter.tpl", "", $_POST);
    } else {
        if (isset($_GET['date_start']) and isset($_GET['date_end'])) {
            $date_start = translateDate($_GET['date_start']) . " 00:00:00";
            $date_end = translateDate($_GET['date_end']) . " 23:59:59";
            if (!empty($_GET['field_pattern'])) {
                $fieldPat[$_GET['field_name']][] = $_GET['field_pattern'];
            }
            if (!empty($_GET['field_pattern_1'])) {
                $fieldPat[$_GET['field_name_1']][] = $_GET['field_pattern_1'];
            }
            $arrFilterExtraVars = array("date_start" => $_GET['date_start'], "date_end" => $_GET['date_end']);
            $htmlFilter = $contenidoModulo = $oFilterForm->fetchForm("{$local_templates_dir}/filter.tpl", "", $_GET);
        } else {
            $htmlFilter = $contenidoModulo = $oFilterForm->fetchForm("{$local_templates_dir}/filter.tpl", "", array('date_start' => date("d M Y"), 'date_end' => date("d M Y"), 'field_name' => 'agent', 'field_pattern' => '', 'field_name_1' => 'agent', 'field_pattern_1' => ''));
        }
    }
    $bElastixNuevo = method_exists('paloSantoGrid', 'setURL');
    $oGrid = new paloSantoGrid($smarty);
    $oGrid->enableExport();
    // enable export.
    $oGrid->showFilter($htmlFilter);
    $bExportando = $bElastixNuevo ? $oGrid->isExportAction() : isset($_GET['exportcsv']) && $_GET['exportcsv'] == 'yes' || isset($_GET['exportspreadsheet']) && $_GET['exportspreadsheet'] == 'yes' || isset($_GET['exportpdf']) && $_GET['exportpdf'] == 'yes';
    $offset = 0;
    $limit = 20;
    if (isset($fieldPat['type'])) {
        $fieldPat['type'] = array_map('strtoupper', $fieldPat['type']);
    }
    $arrCallsAgentTmp = $oCallsAgent->obtenerCallsAgent($date_start, $date_end, $fieldPat);
    if (!is_array($arrCallsAgentTmp)) {
        $smarty->assign(array('mb_title' => _tr('ERROR'), 'mb_message' => $oCallsAgent->errMsg));
        $arrCallsAgentTmp = array();
    }
    $totalCallsAgents = count($arrCallsAgentTmp);
    // Si se quiere avanzar a la sgte. pagina
    if ($bElastixNuevo) {
        $oGrid->setLimit($limit);
        $oGrid->setTotal($totalCallsAgents + 1);
        $offset = $oGrid->calculateOffset();
    } else {
        if (isset($_GET['nav']) && $_GET['nav'] == "end") {
            // Mejorar el sgte. bloque.
            if ($totalCallsAgents % $limit == 0) {
                $offset = $totalCallsAgents - $limit;
            } else {
                $offset = $totalCallsAgents - $totalCallsAgents % $limit;
            }
        }
        // Si se quiere avanzar a la sgte. pagina
        if (isset($_GET['nav']) && $_GET['nav'] == "next") {
            $offset = $_GET['start'] + $limit - 1;
        }
        // Si se quiere retroceder
        if (isset($_GET['nav']) && $_GET['nav'] == "previous") {
            $offset = $_GET['start'] - $limit - 1;
        }
    }
    // Bloque comun
    $arrCallsAgent = array_slice($arrCallsAgentTmp, $offset, $limit);
    $arrData = array();
    $sumCallAnswered = $sumDuration = $timeMayor = 0;
    foreach ($arrCallsAgent as $cdr) {
        $arrData[] = array($cdr['agent_number'], htmlentities($cdr['agent_name'], ENT_COMPAT, 'UTF-8'), $cdr['type'], $cdr['queue'], $cdr['num_answered'], formatoSegundos($cdr['sum_duration']), formatoSegundos($cdr['avg_duration']), formatoSegundos($cdr['max_duration']));
        $sumCallAnswered += $cdr['num_answered'];
        // Total de llamadas contestadas
        $sumDuration += $cdr['sum_duration'];
        // Total de segundos en llamadas
        $timeMayor = $timeMayor < $cdr['max_duration'] ? $cdr['max_duration'] : $timeMayor;
    }
    $sTagInicio = !$bExportando ? '<b>' : '';
    $sTagFinal = $sTagInicio != '' ? '</b>' : '';
    $arrData[] = array($sTagInicio . _tr('Total') . $sTagFinal, '', '', '', $sTagInicio . $sumCallAnswered . $sTagFinal, $sTagInicio . formatoSegundos($sumDuration) . $sTagFinal, $sTagInicio . formatoSegundos($sumCallAnswered > 0 ? $sumDuration / $sumCallAnswered : 0) . $sTagFinal, $sTagInicio . formatoSegundos($timeMayor) . $sTagFinal);
    // Construyo el URL base
    if (isset($arrFilterExtraVars) && is_array($arrFilterExtraVars) && count($arrFilterExtraVars) > 0) {
        $urlVars = array_merge($urlVars, $arrFilterExtraVars);
    }
    if ($bElastixNuevo) {
        $oGrid->setURL(construirURL($urlVars, array("nav", "start")));
        $oGrid->setData($arrData);
        $arrColumnas = array(_tr("No.Agent"), _tr("Agent"), _tr("Type"), _tr("Queue"), _tr("Calls answered"), _tr("Duration"), _tr("Average"), _tr("Call longest"));
        $oGrid->setColumns($arrColumnas);
        $oGrid->setTitle(_tr("Calls per Agent"));
        $oGrid->pagingShow(true);
        $oGrid->setNameFile_Export(_tr("Calls per Agent"));
        $smarty->assign("SHOW", _tr("Show"));
        return $oGrid->fetchGrid();
    } else {
        $url = construirURL($urlVars, array("nav", "start"));
        $offset = 0;
        $total = count($arrData);
        $limit = $total;
        $arrGrid = array("title" => _tr("Calls per Agent"), "url" => $url, "icon" => "images/user.png", "width" => "99%", "start" => $total == 0 ? 0 : $offset + 1, "end" => $offset + $limit <= $total ? $offset + $limit : $total, "total" => $total, "columns" => array(0 => array("name" => _tr("No.Agent"), "property" => ""), 1 => array("name" => _tr("Agent"), "property" => ""), 2 => array("name" => _tr("Type"), "property" => ""), 3 => array("name" => _tr("Queue"), "property" => ""), 4 => array("name" => _tr("Calls answered"), "property" => ""), 5 => array("name" => _tr("Duration"), "property" => ""), 6 => array("name" => _tr("Average"), "property" => ""), 7 => array("name" => _tr("Call longest"), "property" => "")));
        if (isset($_GET['exportpdf']) && $_GET['exportpdf'] == 'yes' && method_exists($oGrid, 'fetchGridPDF')) {
            return $oGrid->fetchGridPDF($arrGrid, $arrData);
        }
        if (isset($_GET['exportspreadsheet']) && $_GET['exportspreadsheet'] == 'yes' && method_exists($oGrid, 'fetchGridXLS')) {
            return $oGrid->fetchGridXLS($arrGrid, $arrData);
        }
        if ($bExportando) {
            header("Cache-Control: private");
            header("Pragma: cache");
            header('Content-Type: application/octet-stream');
            header('Content-disposition: inline; filename="calls_per_agent.csv"');
            header('Content-Type: application/force-download');
        }
        if ($bExportando) {
            return $oGrid->fetchGridCSV($arrGrid, $arrData);
        }
        $sContenido = $oGrid->fetchGrid($arrGrid, $arrData, $arrLang);
        if (strpos($sContenido, '<form') === FALSE) {
            $sContenido = "<form  method=\"POST\" style=\"margin-bottom:0;\" action=\"{$url}\">{$sContenido}</form>";
        }
        return $sContenido;
    }
}
Exemplo n.º 12
0
function report_CashCollection($smarty, $module_name, $local_templates_dir, &$pDB, $pDB_2)
{
    $pCashCollection = new Cash_Collection($pDB);
    $pACL = new paloACL($pDB_2);
    // get filter parameters
    $filter = array('date_start' => trim($_POST['date_start']) == '' ? '' : date("Y-m-d", strtotime($_POST['date_start'])), 'date_end' => trim($_POST['date_end']) == '' ? '' : date("Y-m-d", strtotime($_POST['date_end'])), 'customer_name' => trim($_POST['customer_name']), 'customer_phone' => trim($_POST['customer_number']), 'ticket_code' => trim($_POST['ticket_code']), 'status' => trim($_POST['status']));
    //begin grid parameters
    $oGrid = new paloSantoGrid($smarty);
    $oGrid->setTitle("Thu tiền giao vé");
    $oGrid->pagingShow(true);
    // show paging section.
    $oGrid->enableExport();
    // enable export.
    $oGrid->setNameFile_Export("Cash_Collection");
    $url = array("menu" => $module_name);
    $oGrid->setURL($url);
    $arrColumns = array("ID", "Tên Khách Hàng", "Số điện thoại", "Ngày mua vé", "Booker", "Địa chỉ", "Tiền trả", "Mã số vé", "Tình trạng", "Nhân viên giao", "Ngày phân công", "Nhân viên nhận tiền", "Ngày nhận tiền", "   ");
    $oGrid->setColumns($arrColumns);
    $total = $pCashCollection->getNumCash_Collection($filter);
    $arrData = null;
    if ($oGrid->isExportAction()) {
        $limit = $total;
        // max number of rows.
        $offset = 0;
        // since the start.
    } else {
        $limit = 20;
        $oGrid->setLimit($limit);
        $oGrid->setTotal($total);
        $offset = $oGrid->calculateOffset();
    }
    $arrResult = $pCashCollection->getCash_Collection($limit, $offset, $filter);
    if (is_array($arrResult) && $total > 0) {
        foreach ($arrResult as $key => $value) {
            $ticket = '';
            $name = $pACL->getUsers($value['accounting_id']);
            $elastix_user = is_null($value['accounting_id']) ? '(Chưa nhận)' : $name[0][1];
            foreach ($value['ticket_code'] as $row) {
                $ticket .= $row . '<br>';
            }
            $arrTmp[0] = $value['id'];
            $arrTmp[1] = $value['customer_name'];
            $arrTmp[2] = $value['customer_phone'];
            $arrTmp[3] = is_null($value['purchase_date']) ? '' : date("d-m-Y H:m:s", strtotime($value['purchase_date']));
            $arrTmp[4] = $value['agent_name'];
            $arrTmp[5] = '<a href="javascript:void(1)" onclick="alert(\'' . $value['deliver_address'] . '\')">Xem</a>';
            $arrTmp[6] = $value['pay_amount'];
            $arrTmp[7] = $ticket;
            $arrTmp[8] = showStatus($value['status']);
            $arrTmp[9] = $value['delivery_name'];
            $arrTmp[10] = is_null($value['delivery_date']) ? '' : date("d-m-Y H:m:s", strtotime($value['delivery_date']));
            $arrTmp[11] = $elastix_user;
            $arrTmp[12] = is_null($value['collection_date']) ? '' : date("d-m-Y H:m:s", strtotime($value['collection_date']));
            $arrTmp[13] = $value['status'] == 'Đang giao' ? '<a href="javascript:void(1)" onclick="collect_form(\'' . $value['id'] . '\')">Nhận tiền</a>' : '';
            $arrData[] = $arrTmp;
        }
    }
    $oGrid->setData($arrData);
    //begin section filter
    $oFilterForm = new paloForm($smarty, createFieldFilter());
    // get delivery man list
    $delivery_man_list = $pCashCollection->getDeliveryMan();
    $smarty->assign("DELIVERY_MAN_LIST", $delivery_man_list);
    $htmlFilter = $oFilterForm->fetchForm("{$local_templates_dir}/filter.tpl", "", $_POST);
    //end section filter
    $oGrid->showFilter(trim($htmlFilter));
    $content = $oGrid->fetchGrid();
    //end grid parameters
    return $content;
}
Exemplo n.º 13
0
function listadoLoginLogout($pDB, $smarty, $module_name, $local_templates_dir)
{
    $oCalls = new paloSantoLoginLogout($pDB);
    $smarty->assign(array('SHOW' => _tr('Show'), 'Filter' => _tr('Find')));
    $arrFormElements = array('date_start' => array('LABEL' => _tr('Date Init'), '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('Date End'), 'REQUIRED' => 'yes', 'INPUT_TYPE' => 'DATE', 'INPUT_EXTRA_PARAM' => '', 'VALIDATION_TYPE' => 'ereg', 'VALIDATION_EXTRA_PARAM' => '^[[:digit:]]{1,2}[[:space:]]+[[:alnum:]]{3}[[:space:]]+[[:digit:]]{4}$'), 'detailtype' => array('LABEL' => _tr('Tipo'), 'REQUIRED' => 'no', 'INPUT_TYPE' => 'SELECT', 'INPUT_EXTRA_PARAM' => array('D' => _tr('Detallado'), 'G' => _tr('General')), 'VALIDATION_TYPE' => 'text', 'VALIDATION_EXTRA_PARAM' => ''), 'queue' => array('LABEL' => _tr('Incoming Queue'), 'REQUIRED' => 'no', 'INPUT_TYPE' => 'SELECT', 'INPUT_EXTRA_PARAM' => generarComboColasEntrantes($oCalls), 'VALIDATION_TYPE' => 'text', 'VALIDATION_EXTRA_PARAM' => '^\\d+$'));
    $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'), 'detailtype' => 'D', 'queue' => '');
    foreach (array_keys($paramFiltro) as $k) {
        if (!is_null(getParameter($k))) {
            $paramFiltro[$k] = getParameter($k);
        }
    }
    $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;
    }
    // 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';
    // Consulta y recorte de registros
    $recordset = $oCalls->leerRegistrosLoginLogout($paramFiltro['detailtype'], $paramFiltro['date_start'], $paramFiltro['date_end'], trim($paramFiltro['queue']) == '' ? NULL : $paramFiltro['queue']);
    if (!is_array($recordset)) {
        $smarty->assign(array('mb_title' => _tr('Query Error'), 'mb_message' => $oCalls->errMsg));
        $recordset = array();
    }
    $oGrid = new paloSantoGrid($smarty);
    $bExportando = $oGrid->isExportAction();
    $oGrid->setLimit(LIMITE_PAGINA);
    $oGrid->setTotal(count($recordset));
    $offset = $oGrid->calculateOffset();
    // Formato del arreglo de datos a mostrar
    $arrData = array();
    $sTagInicio = !$bExportando ? '<b>' : '';
    $sTagFinal = $sTagInicio != '' ? '</b>' : '';
    $recordSlice = $bExportando ? $recordset : array_slice($recordset, $offset, LIMITE_PAGINA);
    foreach ($recordSlice as $tupla) {
        $arrData[] = array($tupla['number'], $tupla['name'], $tupla['datetime_init'], $tupla['estado'] == 'ONLINE' ? $sTagInicio . $tupla['datetime_end'] . $sTagFinal : $tupla['datetime_end'], format_time($tupla['duration']), format_time($tupla['total_incoming']), format_time($tupla['total_outgoing']), format_time($tupla['total_incoming'] + $tupla['total_outgoing']), number_format(100.0 * ($tupla['duration'] <= 0 ? 0 : ($tupla['total_incoming'] + $tupla['total_outgoing']) / $tupla['duration']), 2), _tr($tupla['estado']));
    }
    // Calcular totales de pie de página
    $ktotales = array('duration', 'total_incoming', 'total_outgoing');
    $totales = array_combine($ktotales, array_fill(0, count($ktotales), 0));
    foreach ($recordset as $tupla) {
        foreach ($ktotales as $k) {
            $totales[$k] += $tupla[$k];
        }
    }
    $arrData[] = array($sTagInicio . _tr('Total') . $sTagFinal, '', '', '', $sTagInicio . format_time($totales['duration']) . $sTagFinal, $sTagInicio . format_time($totales['total_incoming']) . $sTagFinal, $sTagInicio . format_time($totales['total_outgoing']) . $sTagFinal, $sTagInicio . format_time($totales['total_incoming'] + $totales['total_outgoing']) . $sTagFinal, '', '');
    $oGrid->enableExport();
    $oGrid->setURL($url);
    $oGrid->setData($arrData);
    $arrColumnas = array(_tr('Agente'), _tr('Nombre'), _tr('Date Init'), _tr('Date End'), _tr('Total Login'), _tr('Llamadas entrantes'), _tr('Llamadas salientes'), _tr('Tiempo en Llamadas'), _tr('Service(%)'), _tr('Estado'));
    $oGrid->setColumns($arrColumnas);
    $oGrid->setTitle(_tr('Login Logout'));
    $oGrid->pagingShow(true);
    $oGrid->setNameFile_Export(_tr('Login Logout'));
    $oGrid->showFilter($htmlFilter);
    return $oGrid->fetchGrid();
}
Exemplo n.º 14
0
function reportListadodecampañas($smarty, $module_name, $local_templates_dir, &$pDB, $arrConf)
{
    $pListadodecampañas = new paloSantoListadodecampañas($pDB);
    $filter_field = getParameter("filter_field");
    $filter_value = getParameter("filter_value");
    //begin grid parameters
    $oGrid = new paloSantoGrid($smarty);
    $oGrid->setTitle(_tr("Listado de Reportes Offline"));
    $oGrid->pagingShow(true);
    // show paging section.
    $oGrid->enableExport();
    // enable export.
    $oGrid->setNameFile_Export(_tr("Listado de Reportes Offline"));
    $url = array("menu" => $module_name, "filter_field" => $filter_field, "filter_value" => $filter_value);
    $oGrid->setURL($url);
    $arrColumns = array(_tr("Campania"), _tr("Tipo"), _tr("Status"), _tr("Acción"));
    $oGrid->setColumns($arrColumns);
    $total = $pListadodecampañas->getNumListadodecampañas($filter_field, $filter_value);
    $arrData = null;
    if ($oGrid->isExportAction()) {
        $limit = $total;
        // max number of rows.
        $offset = 0;
        // since the start.
    } else {
        $limit = 20;
        $oGrid->setLimit($limit);
        $oGrid->setTotal($total);
        $offset = $oGrid->calculateOffset();
    }
    $arrResult = $pListadodecampañas->getListadodecampañas($limit, $offset, $filter_field, $filter_value);
    if (is_array($arrResult) && $total > 0) {
        foreach ($arrResult as $key => $value) {
            //$arrBasesAgentes = $pListadodecampañas->getBasesAgentes($value['id']);
            $arrTmp[0] = $value['nombre'];
            $arrTmp[1] = $value['tipo'];
            if ($value['status'] == "I") {
                $arrTmp[2] = "En Proceso";
                $arrTmp[3] = "";
            } else {
                $arrTmp[2] = "Finalizado";
                $arrTmp[3] = "<a href=" . $value['ruta'] . ">Descargar</a>";
            }
            $arrData[] = $arrTmp;
        }
    }
    $oGrid->setData($arrData);
    //begin section filter
    $oFilterForm = new paloForm($smarty, createFieldFilter());
    $smarty->assign("SHOW", _tr("Show"));
    $htmlFilter = $oFilterForm->fetchForm("{$local_templates_dir}/filter.tpl", "", $_POST);
    //end section filter
    $oGrid->showFilter(trim($htmlFilter));
    $content = $oGrid->fetchGrid();
    //end grid parameters
    return $content;
}
Exemplo n.º 15
0
function reportReportedetalladodegestión($smarty, $module_name, $local_templates_dir, &$pDB, $arrConf)
{
    $pReportedetallado = new paloSantoReportedetalladodegestión($pDB);
    $filter_field = getParameter("filter_field");
    $filter_value = getParameter("filter_value");
    //begin grid parameters
    $oGrid = new paloSantoGrid($smarty);
    $oGrid->setTitle(_tr("Reporte detallado de gestión"));
    $oGrid->pagingShow(true);
    // show paging section.
    $oGrid->enableExport();
    // enable export.
    $oGrid->setNameFile_Export(_tr("Reporte detallado de gestión"));
    $url = array("menu" => $module_name, "filter_field" => $filter_field, "filter_value" => $filter_value);
    $oGrid->setURL($url);
    $arrColumns = array(_tr("Campaña"), _tr("Fecha"), _tr("Cliente"), _tr("CI"), _tr("Teléfono"), _tr("Agente"), _tr("Calltype"));
    $numColumnasFijas = sizeof($arrColumns);
    if (isset($filter_field) && is_numeric($filter_field)) {
        // si está seteado el número de campaña, busca los campos del form de dicha campaña
        $arrTmp = $pReportedetallado->getFormFields($filter_field);
        // _pre($arrTmp);
        $i = 0;
        foreach ($arrTmp as $formField) {
            $arrOrden[] = $formField['id'];
            $arrColumnsAdicionales[$i] = $formField['etiqueta'];
            $i++;
        }
        $arrColumns = array_merge($arrColumns, $arrColumnsAdicionales);
    }
    // _pre($arrOrden);
    // _pre($arrColumns);
    unset($arrTmp);
    $oGrid->setColumns($arrColumns);
    $total = $pReportedetallado->getNumReportedetalladodegestion($filter_field);
    // $filter_field sólo contien el id de la campaña
    $arrData = null;
    if ($oGrid->isExportAction()) {
        $limit = $total;
        // max number of rows.
        $offset = 0;
        // since the start.
    } else {
        $limit = 200;
        $oGrid->setLimit($limit);
        $oGrid->setTotal($total);
        $offset = $oGrid->calculateOffset();
    }
    //    $arrResult =$pReportedetallado->getReportedetalladodegestion($limit, $offset, $filter_field); // $filter_field sólo contien el id de la campaña
    $arrResult = $pReportedetallado->getReportedeCalltypes($limit, $offset, $filter_field, $filter_value);
    if (is_array($arrResult) && $total > 0) {
        foreach ($arrResult as $key => $value) {
            $arrTmp[0] = $value['campania'];
            $arrTmp[1] = $value['campania'];
            $arrTmp[2] = $value['cliente'];
            $arrTmp[3] = $value['ci'];
            $arrTmp[4] = $value['telefono'];
            $arrTmp[5] = $value['agente'];
            $arrTmp[6] = $value['mejor_calltype'];
            // $arrFormValues = $pReportedetallado->getFormValues($value['id_gestion_campania']);
            $arrFormValues = $pReportedetallado->getFormValues($value['id_gestion_mejor_calltype']);
            // array_search retorna el key dado el valor a buscar
            foreach ($arrFormValues as $formValue) {
                // echo $formValue['valor'] . " " . array_search($formValue['id_form_field'],$arrOrden) . "<br>";
                $ubicacionReal = array_search($formValue['id_form_field'], $arrOrden) + $numColumnasFijas;
                $arrTmp[$ubicacionReal] = $formValue['valor'];
            }
            $arrData[] = $arrTmp;
        }
    }
    $oGrid->setData($arrData);
    //begin section filter
    $oFilterForm = new paloForm($smarty, createFieldFilter($pReportedetallado));
    $smarty->assign("SHOW", _tr("Show"));
    $htmlFilter = $oFilterForm->fetchForm("{$local_templates_dir}/filter.tpl", "", $_POST);
    //end section filter
    $oGrid->showFilter(trim($htmlFilter));
    $content = $oGrid->fetchGrid();
    //end grid parameters
    return $content;
}
Exemplo n.º 16
0
function reportOtrosdatos($smarty, $module_name, $local_templates_dir, &$pDB, $arrConf)
{
    $pOtrosdatos = new paloSantoOtrosdatos($pDB);
    $filter_field = getParameter("filter_field");
    $filter_value = getParameter("filter_value");
    //begin grid parameters
    $oGrid = new paloSantoGrid($smarty);
    $oGrid->setTitle(_tr("Datos complementarios"));
    $oGrid->pagingShow(true);
    // show paging section.
    $oGrid->enableExport();
    // enable export.
    $oGrid->setNameFile_Export(_tr("Datos complementarios"));
    $url = array("menu" => $module_name, "filter_field" => $filter_field, "filter_value" => $filter_value);
    $oGrid->setURL($url);
    switch ($filter_field) {
        case "cliente_direccion":
            $arrColumns = array(_tr("Descripción"), _tr("Dirección"), _tr("Acción"));
            break;
        case "cliente_adicional":
            $arrColumns = array(_tr("Descripción"), _tr("Dato adicional"), _tr("Acción"));
            break;
        case "cliente_telefono":
        default:
            $arrColumns = array(_tr("Descripción"), _tr("Número"), _tr("Acción"));
            break;
    }
    $oGrid->setColumns($arrColumns);
    if (!empty($_SESSION["id_campania_cliente_recargable"])) {
        $total = $pOtrosdatos->getNumOtrosdatosRecargable($filter_field, $filter_value, $_SESSION['id_campania_cliente_recargable']);
    } elseif (!empty($_SESSION['id_cliente'])) {
        $total = $pOtrosdatos->getNumOtrosdatosIdCliente($filter_field, $filter_value, $_SESSION['id_cliente']);
    } else {
        $total = $pOtrosdatos->getNumOtrosdatos($filter_field, $filter_value, $_SESSION['ci']);
    }
    $arrData = null;
    if ($oGrid->isExportAction()) {
        $limit = $total;
        // max number of rows.
        $offset = 0;
        // since the start.
    } else {
        $limit = 20;
        $oGrid->setLimit($limit);
        $oGrid->setTotal($total);
        $offset = $oGrid->calculateOffset();
    }
    if (!empty($_SESSION["id_campania_cliente_recargable"])) {
        $arrResult = $pOtrosdatos->getOtrosdatosRecargable($limit, $offset, $filter_field, $filter_value, $_SESSION["id_campania_cliente_recargable"]);
    } elseif (!empty($_SESSION['id_cliente'])) {
        $arrResult = $pOtrosdatos->getOtrosdatosIdCliente($limit, $offset, $filter_field, $filter_value, $_SESSION['id_cliente']);
    } else {
        $arrResult = $pOtrosdatos->getOtrosdatos($limit, $offset, $filter_field, $filter_value, $_SESSION['ci']);
    }
    //_pre($arrResult);
    if (is_array($arrResult) && $total > 0) {
        foreach ($arrResult as $key => $value) {
            $arrTmp[0] = $value['descripcion'];
            $arrTmp[1] = $value['valor'];
            $arrTmp[2] = "<a href=index.php?menu=hispana_clientes_datosotros_reporte&id={$value['id']}&action=delete&filter_field={$filter_field} onclick = \"if (! confirm('¿Realmente desea desactivarlo?')) return false;\">Desactivar</a>";
            if ($filter_field == "cliente_adicional") {
                // se pueden editar los adicionales del cliente
                $arrTmp[2] .= " <a href=index.php?menu=hispana_clientes_datosotros_reporte&id={$value['id']}&action=view_edit&filter_field={$filter_field}>Editar</a>";
            }
            $arrData[] = $arrTmp;
        }
    }
    $oGrid->setData($arrData);
    //begin section filter
    $oFilterForm = new paloForm($smarty, createFieldFilter());
    $smarty->assign("SHOW", _tr("Show"));
    $htmlFilter = $oFilterForm->fetchForm("{$local_templates_dir}/filter.tpl", "", $_POST);
    //end section filter
    $oGrid->showFilter(trim($htmlFilter));
    $content = $oGrid->fetchGrid();
    //end grid parameters
    return $content;
}
Exemplo n.º 17
0
function reportReportsBreak($smarty, $module_name, $local_templates_dir, &$pDB)
{
    // Obtener rango de fechas de consulta. Si no existe, se asume día de hoy
    $sFechaInicio = date('d M Y');
    if (isset($_GET['txt_fecha_init'])) {
        $sFechaInicio = $_GET['txt_fecha_init'];
    }
    if (isset($_POST['txt_fecha_init'])) {
        $sFechaInicio = $_POST['txt_fecha_init'];
    }
    $sFechaFinal = date('d M Y');
    if (isset($_GET['txt_fecha_end'])) {
        $sFechaFinal = $_GET['txt_fecha_end'];
    }
    if (isset($_POST['txt_fecha_end'])) {
        $sFechaFinal = $_POST['txt_fecha_end'];
    }
    $arrFilterExtraVars = array("txt_fecha_init" => $sFechaInicio, "txt_fecha_end" => $sFechaFinal);
    $arrFormElements = createFieldFilter();
    $oFilterForm = new paloForm($smarty, $arrFormElements);
    // Validación de las fechas recogidas
    if (!$oFilterForm->validateForm($arrFilterExtraVars)) {
        $smarty->assign("mb_title", _tr("Validation Error"));
        $arrErrores = $oFilterForm->arrErroresValidacion;
        $strErrorMsg = '<b>' . _tr('The following fields contain errors') . '</b><br/>';
        foreach ($arrErrores as $k => $v) {
            $strErrorMsg .= "{$k}, ";
        }
        $smarty->assign("mb_message", $strErrorMsg);
        $arrFilterExtraVars = array("txt_fecha_init" => date('d M Y'), "txt_fecha_end" => date('d M Y'));
    }
    $htmlFilter = $oFilterForm->fetchForm("{$local_templates_dir}/filter.tpl", "", $arrFilterExtraVars);
    // Obtener fechas en formato yyyy-mm-dd
    $sFechaInicio = translateDate($arrFilterExtraVars['txt_fecha_init']);
    $sFechaFinal = translateDate($arrFilterExtraVars['txt_fecha_end']);
    $oReportsBreak = new paloSantoReportsBreak($pDB);
    //begin grid parameters
    $bElastixNuevo = method_exists('paloSantoGrid', 'setURL');
    $oGrid = new paloSantoGrid($smarty);
    $oGrid->enableExport();
    // enable export.
    $oGrid->showFilter($htmlFilter);
    $arrColumnas = array(_tr('Agent Number'), _tr('Agent Name'));
    $bExportando = $bElastixNuevo ? $oGrid->isExportAction() : isset($_GET['exportcsv']) && $_GET['exportcsv'] == 'yes' || isset($_GET['exportspreadsheet']) && $_GET['exportspreadsheet'] == 'yes' || isset($_GET['exportpdf']) && $_GET['exportpdf'] == 'yes';
    $datosBreaks = $oReportsBreak->getReportesBreak($sFechaInicio, $sFechaFinal);
    $mapa = array();
    // Columna del break dado su ID
    $sTagInicio = !$bExportando ? '<b>' : '';
    $sTagFinal = $sTagInicio != '' ? '</b>' : '';
    $filaTotales = array($sTagInicio . _tr('Total') . $sTagFinal, '');
    foreach ($datosBreaks['breaks'] as $idBreak => $sNombreBreak) {
        $mapa[$idBreak] = count($arrColumnas);
        $arrColumnas[] = $sNombreBreak;
        $filaTotales[] = 0;
        // Total de segundos usado por todos los agentes en este break
    }
    $mapa['TOTAL'] = count($arrColumnas);
    $filaTotales[] = 0;
    // Total de segundos usado por todos los agentes en todos los breaks
    $arrColumnas[] = _tr('Total');
    $arrData = array();
    foreach ($datosBreaks['reporte'] as $infoAgente) {
        $filaAgente = array($infoAgente['numero_agente'], $infoAgente['nombre_agente']);
        $iTotalAgente = 0;
        // Total de segundos usados por agente en breaks
        // Valor inicial de todos los breaks es 0 segundos
        foreach (array_keys($datosBreaks['breaks']) as $idBreak) {
            $filaAgente[$mapa[$idBreak]] = '00:00:00';
        }
        // Asignar duración del break para este agente y break
        foreach ($infoAgente['breaks'] as $tuplaBreak) {
            $sTagInicio = !$bExportando && $tuplaBreak['duracion'] > 0 ? '<font color="green">' : '';
            $sTagFinal = $sTagInicio != '' ? '</font>' : '';
            $filaAgente[$mapa[$tuplaBreak['id_break']]] = $sTagInicio . formatoSegundos($tuplaBreak['duracion']) . $sTagFinal;
            $iTotalAgente += $tuplaBreak['duracion'];
            $filaTotales[$mapa[$tuplaBreak['id_break']]] += $tuplaBreak['duracion'];
            $filaTotales[$mapa['TOTAL']] += $tuplaBreak['duracion'];
        }
        // Total para todos los breaks de este agente
        $filaAgente[$mapa['TOTAL']] = formatoSegundos($iTotalAgente);
        $arrData[] = $filaAgente;
    }
    $sTagInicio = !$bExportando ? '<b>' : '';
    $sTagFinal = $sTagInicio != '' ? '</b>' : '';
    foreach ($mapa as $iPos) {
        $filaTotales[$iPos] = $sTagInicio . formatoSegundos($filaTotales[$iPos]) . $sTagFinal;
    }
    $arrData[] = $filaTotales;
    if ($bElastixNuevo) {
        $oGrid->setURL(construirURL($arrFilterExtraVars));
        $oGrid->setData($arrData);
        $oGrid->setColumns($arrColumnas);
        $oGrid->setTitle(_tr("Reports Break"));
        $oGrid->pagingShow(false);
        $oGrid->setNameFile_Export(_tr("Reports Break"));
        $smarty->assign("SHOW", _tr("Show"));
        return $oGrid->fetchGrid();
    } else {
        $url = construirURL($arrFilterExtraVars);
        $offset = 0;
        $total = count($datosBreaks['reporte']) + 1;
        $limit = $total;
        function _map_name($s)
        {
            return array('name' => $s);
        }
        $arrGrid = array("title" => _tr('Reports Break'), "url" => $url, "icon" => "images/list.png", "width" => "99%", "start" => $total == 0 ? 0 : $offset + 1, "end" => $offset + $limit <= $total ? $offset + $limit : $total, "total" => $total, "columns" => array_map('_map_name', $arrColumnas));
        if (isset($_GET['exportpdf']) && $_GET['exportpdf'] == 'yes' && method_exists($oGrid, 'fetchGridPDF')) {
            return $oGrid->fetchGridPDF($arrGrid, $arrData);
        }
        if (isset($_GET['exportspreadsheet']) && $_GET['exportspreadsheet'] == 'yes' && method_exists($oGrid, 'fetchGridXLS')) {
            return $oGrid->fetchGridXLS($arrGrid, $arrData);
        }
        if ($bExportando) {
            $title = $sFechaInicio . "-" . $sFechaFinal;
            header("Cache-Control: private");
            header("Pragma: cache");
            header('Content-Type: text/csv; charset=utf-8; header=present');
            header("Content-disposition: attachment; filename=\"" . $title . ".csv\"");
        }
        if ($bExportando) {
            return $oGrid->fetchGridCSV($arrGrid, $arrData);
        }
        $sContenido = $oGrid->fetchGrid($arrGrid, $arrData);
        if (strpos($sContenido, '<form') === FALSE) {
            $sContenido = "<form  method=\"POST\" style=\"margin-bottom:0;\" action=\"{$url}\">{$sContenido}</form>";
        }
        return $sContenido;
    }
}
Exemplo n.º 18
0
function report_AccessAudit($smarty, $module_name, $local_templates_dir)
{
    global $arrPermission;
    $pAccessLogs = new paloSantoAccessaudit();
    $listaFechas = $pAccessLogs->astLog->listarFechas();
    $arrFormElements = createFieldFilter($listaFechas);
    $field_pattern = getParameter("filter");
    $busqueda = getParameter('busqueda');
    $sUltimaBusqueda = getParameter('ultima_busqueda');
    $iUltimoOffset = getParameter('ultimo_offset');
    if (is_null($busqueda) || trim($busqueda) == '') {
        $busqueda = '';
    }
    if ($busqueda != '') {
        $_POST['busqueda'] = $busqueda;
    }
    /* Última búsqueda, si existe */
    if (is_null($sUltimaBusqueda) || $sUltimaBusqueda == '' || is_null($iUltimoOffset) || !ereg('^[[:digit:]]+$', $iUltimoOffset)) {
        $sUltimaBusqueda = NULL;
        $iUltimoOffset = NULL;
    }
    if (!ereg($arrFormElements['filter']['VALIDATION_EXTRA_PARAM'], $field_pattern)) {
        $field_pattern = $listaFechas[count($listaFechas) - 1];
    }
    $_POST['filter'] = $field_pattern;
    $oFilterForm = new paloForm($smarty, $arrFormElements);
    $oGrid = new paloSantoGrid($smarty);
    $oGrid->setTitle(_tr("Audit"));
    $oGrid->setIcon("web/apps/{$module_name}/images/security_audit.png");
    $oGrid->pagingShow(true);
    // show paging section.
    if (in_array("export", $arrPermission)) {
        $oGrid->enableExport();
    }
    // enable export.
    $oGrid->setNameFile_Export(_tr("Access audit"));
    if (in_array("export", $arrPermission)) {
        $isExport = $oGrid->isExportAction();
    } else {
        $isExport = false;
    }
    $total_datos = $pAccessLogs->ObtainNumAccessLogs($field_pattern);
    $totalBytes = $total_datos[0];
    $iNumLineasPorPagina = 30;
    $iEstimadoBytesPagina = $iNumLineasPorPagina * 128;
    $iOffsetVerdadero = getParameter('offset');
    if (is_null($iOffsetVerdadero) || !ereg('^[[:digit:]]+$', $iOffsetVerdadero)) {
        $iOffsetVerdadero = 0;
    }
    if ($iOffsetVerdadero >= $totalBytes) {
        $iOffsetVerdadero = 0;
    }
    if (isset($_GET['filter']) && isset($_POST['filter']) && $_GET['filter'] != $_POST['filter']) {
        $iOffsetVerdadero = 0;
    }
    /* Para ubicarse en la página, se obtiene la región 5 páginas estimadas hacia delante y
         5 páginas estimadas hacia atrás desde el offset indicado.
       */
    $inicioRango = $iOffsetVerdadero - 5 * $iEstimadoBytesPagina;
    if ($inicioRango < 0) {
        $inicioRango = 0;
    }
    if ($isExport) {
        $arrResult = $pAccessLogs->ObtainAccessLogs($totalBytes, 0, $field_pattern, NULL, $isExport);
    } else {
        $arrResult = $pAccessLogs->ObtainAccessLogs(10 * $iEstimadoBytesPagina, $inicioRango, $field_pattern, NULL, $isExport);
    }
    /* Localizar la línea del offset verdadero, así como los offsets de las páginas previa y siguiente */
    for ($iPos = 0; $iPos < count($arrResult); $iPos++) {
        if ($arrResult[$iPos]['offset'] >= $iOffsetVerdadero) {
            break;
        }
    }
    $iPosPrevio = $iPos - $iNumLineasPorPagina;
    $iPosSiguiente = $iPos + $iNumLineasPorPagina;
    if ($iPosPrevio < 0) {
        $iPosPrevio = 0;
    }
    if ($iPosSiguiente > count($arrResult) - 1) {
        $iPosSiguiente = count($arrResult) - 1;
    }
    $iOffsetPrevio = $arrResult[$iPosPrevio]['offset'];
    $iOffsetSiguiente = $arrResult[$iPosSiguiente]['offset'];
    $limit = 30;
    $total = (int) ($totalBytes / 128);
    $offset = $iOffsetVerdadero;
    $nav = getParameter('nav');
    if ($nav) {
        switch ($nav) {
            case 'start':
                $offset = 0;
                break;
            case 'end':
                /* Caso especial: se debe tomar la última sección del log */
                $inicioRango = $totalBytes - 5 * $iEstimadoBytesPagina;
                if ($inicioRango < 0) {
                    $inicioRango = 0;
                }
                if ($isExport) {
                    $arrResult = $pAccessLogs->ObtainAccessLogs($totalBytes, 0, $field_pattern, $busqueda != '' ? $busqueda : NULL, $isExport);
                } else {
                    $arrResult = $pAccessLogs->ObtainAccessLogs(10 * $iEstimadoBytesPagina, $inicioRango, $field_pattern, NULL, $isExport);
                }
                if (count($arrResult) <= $iNumLineasPorPagina) {
                    $offset = $arrResult[0]['offset'];
                } else {
                    $offset = $arrResult[count($arrResult) - $iNumLineasPorPagina]['offset'];
                }
                break;
            case 'next':
                $offset = $iOffsetSiguiente;
                break;
            case 'previous':
                $offset = $iOffsetPrevio;
                break;
            case 'bypage':
                $numPage = $limit == 0 ? 0 : ceil($total / $limit);
                $page = getParameter("page");
                if (preg_match("/[0-9]+/", $page) == 0) {
                    // no es un número
                    $page = 1;
                }
                if ($page > $numPage) {
                    // se está solicitando una pagina mayor a las que existen
                    $page = $numPage;
                }
                $start = ($page - 1) * $limit + 1 - $limit;
                //$accion = "next";
                if ($start + $limit <= 1) {
                    break;
                }
                /*$inicioRango = $page * $iEstimadoBytesPagina;
                
                        $arrResult =$pAccessLogs->ObtainAccessLogs(10 * $iEstimadoBytesPagina, $inicioRango, $field_pattern, NULL, $isExport);
                        $offset = $arrResult[0]['offset'];
                
                        $oGrid->setOffsetValue($offset);
                
                        $oGrid->setEnd(((int)($offset / 128) + $iNumLineasPorPagina) <= $oGrid->getTotal() ? (int)($offset / 128) + $iNumLineasPorPagina : $oGrid->getTotal());
                
                        $oGrid->setStart(($oGrid->getTotal()==0) ? 0 : (1 + (int)($offset / 128)));*/
                $inicioBusqueda = $page * $iEstimadoBytesPagina - $iEstimadoBytesPagina;
                $arrResult = $pAccessLogs->ObtainAccessLogs(10 * $iEstimadoBytesPagina, $inicioBusqueda, $field_pattern, NULL, $isExport);
                $offset = $arrResult[0]['offset'];
                $oGrid->setOffsetValue($offset);
                break;
        }
    }
    // Buscar la cadena de texto indicada, y modificar offset si se encuentra
    $smarty->assign("SEARCHNEXT", _tr('Search'));
    if (isset($_POST['searchnext']) && $busqueda != '') {
        $pAccessLogs->astLog->posicionarMensaje($field_pattern, $offset);
        $posBusqueda = $pAccessLogs->astLog->buscarTextoMensaje($busqueda);
        if (!is_null($posBusqueda)) {
            $offset = $posBusqueda[1];
            $smarty->assign('SEARCHNEXT', _tr('Search next'));
            $_POST['ultima_busqueda'] = $busqueda;
            $_POST['ultimo_offset'] = $offset;
            // Si el offset anterior indicado es idéntico al offset recién encontrado
            // y la cadena de búsqueda es también idéntica, se asume que se ha
            // pedido una búsqueda de la siguiente ocurrencia.
            if (!is_null($sUltimaBusqueda) && !is_null($iUltimoOffset) && $offset == $iUltimoOffset && $sUltimaBusqueda == $busqueda) {
                $pAccessLogs->astLog->posicionarMensaje($field_pattern, $offset);
                $pAccessLogs->astLog->siguienteMensaje();
                // Sólo para ignorar primera ocurrencia
                $posBusqueda = $pAccessLogs->astLog->buscarTextoMensaje($busqueda);
                if (!is_null($posBusqueda)) {
                    $offset = $posBusqueda[1];
                    $_POST['ultimo_offset'] = $offset;
                }
            }
        } else {
        }
    }
    $url = array('menu' => $module_name, 'filter' => $field_pattern, 'offset' => $offset, 'busqueda' => $busqueda, 'ultima_busqueda' => isset($_POST['ultima_busqueda']) ? $_POST['ultima_busqueda'] : '', 'ultimo_offset' => isset($_POST['ultimo_offset']) ? $_POST['ultimo_offset'] : '');
    $oGrid->setURL($url);
    //Fin Paginacion
    if ($isExport) {
        $arrResult = $pAccessLogs->ObtainAccessLogs($totalBytes, 0, $field_pattern, $busqueda != '' ? $busqueda : NULL, $isExport);
    } else {
        $arrResult = $pAccessLogs->ObtainAccessLogs(10 * $iEstimadoBytesPagina, $offset, $field_pattern, $busqueda != '' ? $busqueda : NULL, $isExport);
    }
    if (!$isExport) {
        $arrResult = array_slice($arrResult, 0, $iNumLineasPorPagina);
    }
    $arrData = null;
    if (is_array($arrResult) && $totalBytes > 0) {
        foreach ($arrResult as $key => $value) {
            $arrTmp[0] = $value['fecha'];
            $arrTmp[1] = $value['tipo'];
            $arrTmp[2] = $value['origen'];
            $arrTmp[3] = $value['linea'];
            $arrData[] = $arrTmp;
        }
    }
    $arrColumns = array(_tr("Date"), _tr("Type"), _tr("User"), _tr("Message"));
    $oGrid->setColumns($arrColumns);
    $oGrid->setData($arrData);
    $oGrid->setStart($totalBytes == 0 ? 0 : 1 + (int) ($offset / 128));
    $t = (int) ($totalBytes / 128);
    $e = (int) ($offset / 128) + $iNumLineasPorPagina;
    $e = $t <= $e ? $t : $e;
    $oGrid->setEnd($e + 1);
    $oGrid->setTotal($t + 1);
    $oGrid->setLimit(30);
    $_POST['offset'] = $offset;
    $smarty->assign("SHOW", _tr("Show"));
    $oGrid->addFilterControl(_tr("Filter applied: ") . _tr("Date") . " = " . $_POST['filter'], $_POST, array('filter' => $listaFechas[count($listaFechas) - 1]), true);
    $oGrid->addFilterControl(_tr("Filter applied: ") . _tr('Search string') . " = " . $busqueda, $_POST, array('busqueda' => ""));
    $htmlFilter = $oFilterForm->fetchForm("{$local_templates_dir}/filter.tpl", "", $_POST);
    $oGrid->showFilter(trim($htmlFilter));
    return $oGrid->fetchGrid();
}
Exemplo n.º 19
0
function reportMissedCalls($smarty, $module_name, $local_templates_dir, &$pDB, &$pDBACL, $pACL, $arrConf)
{
    ini_set('max_execution_time', 3600);
    $pCallingReport = new paloSantoMissedCalls($pDB);
    $oFilterForm = new paloForm($smarty, createFieldFilter());
    $filter_field = getParameter("filter_field");
    $filter_value = getParameter("filter_value");
    $date_start = getParameter("date_start");
    $date_end = getParameter("date_end");
    //begin grid parameters
    $oGrid = new paloSantoGrid($smarty);
    $oGrid->setTitle(_tr("Missed Calls"));
    $oGrid->pagingShow(true);
    // show paging section.
    $oGrid->enableExport();
    // enable export.
    $oGrid->setNameFile_Export(_tr("Missed Calls"));
    $url = array("menu" => $module_name, "filter_field" => $filter_field, "filter_value" => $filter_value);
    $date_start = isset($date_start) ? $date_start : date("d M Y") . ' 00:00';
    $date_end = isset($date_end) ? $date_end : date("d M Y") . ' 23:59';
    $_POST['date_start'] = $date_start;
    $_POST['date_end'] = $date_end;
    $parmFilter = array("date_start" => $date_start, "date_end" => $date_end);
    if (!$oFilterForm->validateForm($parmFilter)) {
        $smarty->assign(array('mb_title' => _tr('Validation Error'), 'mb_message' => '<b>' . _tr('The following fields contain errors') . ':</b><br/>' . implode(', ', array_keys($oFilterForm->arrErroresValidacion))));
        $date_start = date("d M Y") . ' 00:00';
        $date_end = date("d M Y") . ' 23:59';
    }
    $url = array_merge($url, array('date_start' => $date_start, 'date_end' => $date_end));
    $oGrid->setURL($url);
    $arrColumns = array(_tr("Date"), _tr("Source"), _tr("Destination"), _tr("Time since last call"), _tr("Number of attempts"), _tr("Status"));
    $oGrid->setColumns($arrColumns);
    $arrData = null;
    $date_start_format = date('Y-m-d H:i:s', strtotime($date_start . ":00"));
    $date_end_format = date('Y-m-d H:i:s', strtotime($date_end . ":59"));
    // Para usuarios que no son administradores, se restringe a los CDR de la
    // propia extensión
    $sExtension = $pACL->isUserAdministratorGroup($_SESSION['elastix_user']) ? '' : $pACL->getUserExtension($_SESSION['elastix_user']);
    $total = $pCallingReport->getNumCallingReport($date_start_format, $date_end_format, $filter_field, $filter_value, $sExtension);
    if ($oGrid->isExportAction()) {
        $limit = $total;
        // max number of rows.
        $offset = 0;
        // since the start.
        $arrResult = $pCallingReport->getCallingReport($date_start_format, $date_end_format, $filter_field, $filter_value, $sExtension);
        $arrData = $pCallingReport->showDataReport($arrResult, $total);
        $size = count($arrData);
        $oGrid->setData($arrData);
    } else {
        $limit = 20;
        $oGrid->setLimit($limit);
        $arrResult = $pCallingReport->getCallingReport($date_start_format, $date_end_format, $filter_field, $filter_value, $sExtension);
        $arrData = $pCallingReport->showDataReport($arrResult, $total);
        if ($pCallingReport->errMsg != '') {
            $smarty->assign('mb_message', $pCallingReport->errMsg);
        }
        //recalculando el total para la paginación
        $size = count($arrData);
        $oGrid->setTotal($size);
        $offset = $oGrid->calculateOffset();
        //echo $size." : ".$offset;
        $arrResult = $pCallingReport->getDataByPagination($arrData, $limit, $offset);
        $oGrid->setData($arrResult);
    }
    //begin section filter
    $smarty->assign("SHOW", _tr("Show"));
    $htmlFilter = $oFilterForm->fetchForm("{$local_templates_dir}/filter.tpl", "", $_POST);
    //end section filter
    $oGrid->showFilter(trim($htmlFilter));
    $content = $oGrid->fetchGrid();
    //end grid parameters
    return $content;
}
Exemplo n.º 20
0
function reportContact($smarty, $module_name, $local_templates_dir, &$pDB, $arrConf)
{
    global $arrCredentials;
    $coreContact = new coreContact($pDB);
    $jsonObject = new PaloSantoJSON();
    //obtener los parametros del filtro
    $filters['ftype_contacto'] = getParameter('ftype_contacto');
    $filters['filter'] = getParameter('filter');
    $filters['filter_value'] = getParameter('filter_value');
    $validatedfilters = $coreContact->validatedFilters($filters);
    $total = $coreContact->getTotalContactsByFilter($validatedfilters);
    if ($total === false) {
        $total = 0;
        $smarty->assign("MSG_ERROR_FIELD", _tr("Error en database"));
        $jsonObject->set_error($coreContact->sqlContact->getErrorMsg());
        return $jsonObject->createJSON();
    }
    $limit = 7;
    $oGrid = new paloSantoGrid($smarty);
    $oGrid->setLimit($limit);
    $oGrid->setTotal($total);
    $offset = $oGrid->calculateOffset();
    $end = $offset + $limit <= $total ? $offset + $limit : $total;
    $oGrid->setStart($total == 0 ? 0 : $offset + 1);
    $oGrid->setEnd($end);
    $currentPage = $oGrid->calculateCurrentPage();
    $numPage = $oGrid->calculateNumPage();
    $url['menu'] = $module_name;
    $url['ftype_contacto'] = $filters['ftype_contacto'];
    $url['filter'] = $filters['filter'];
    $url['filter_value'] = $filters['filter_value'];
    $oGrid->setTitle(_tr('Contacts List'));
    $oGrid->setURL($url);
    $oGrid->enableExport();
    // enable export.
    $oGrid->setNameFile_Export(_tr("ContactsExport"));
    $arrColumn = array();
    if ($oGrid->isExportAction()) {
        // arreglo de columnas para mostrar en los archivos de exportacion
        $arrColumn[] = 'Name';
        //if($validatedfilters['table']=="internal"){
        if ($validatedfilters['table'] == "internal") {
            $arrColumn[] = 'Ext';
        } else {
            $arrColumn[] = 'Phone';
        }
        $arrColumn[] = 'Email';
        $arrColumn[] = 'Type Contact';
    } else {
        //arreglo de columnas para mostrar en la grilla
        $arrColumn[] = "<span class='glyphicon glyphicon-check'></span>";
        $arrColumn[] = _tr('Picture');
        $arrColumn[] = _tr('Name');
        //if($validatedfilters['table']=="internal"){
        $arrColumn[] = _tr('Ext / Phone');
        $arrColumn[] = _tr('Email');
        $arrColumn[] = _tr('Call');
        $arrColumn[] = _tr('Transfer');
        $arrColumn[] = _tr('Type Contact');
    }
    $oGrid->setColumns($arrColumn);
    $validatedfilters = $coreContact->validatedFilters($filters);
    //enviamos como parametros limit, offset y los filtros validados
    $contacts = $coreContact->getContacts($limit, $offset, $validatedfilters);
    $arrDatosGrid = array();
    if ($contacts === false) {
        $smarty->assign("MSG_ERROR_FIELD", $coreContact->getErrorMsg());
        $jsonObject->set_error($coreContact->getErrorMsg());
        return $jsonObject->createJSON();
    } else {
        if ($oGrid->isExportAction()) {
            // data para exportar en los archivos
            foreach ($contacts as $value) {
                $tmp = array();
                $tmp[] = $value['name'];
                if (empty($value['work_phone'])) {
                    $tmp[] = "N/A";
                } else {
                    $tmp[] = $value['work_phone'];
                }
                if (!empty($value['username'])) {
                    $tmp[] = $value['username'];
                } else {
                    $tmp[] = "N/A";
                }
                if ($validatedfilters['table'] != "internal") {
                    if ($value['status'] == "isPrivate") {
                        $tmp[] = _tr('Private');
                    } else {
                        $tmp[] = _tr('Public');
                    }
                } else {
                    $tmp[] = _tr('Public');
                }
                $arrDatosGrid[] = $tmp;
            }
        } else {
            //data para mostrar en las grillas
            foreach ($contacts as $value) {
                $tmp = array();
                if ($validatedfilters['table'] == "internal") {
                    $tmp[] = "<input type='checkbox' name='checkContacts' id='{$value['id']}' disabled >";
                } else {
                    if ($arrCredentials['idUser'] == $value['iduser']) {
                        $tmp[] = "<input type='checkbox' name='checkContacts' id='{$value['id']}'>";
                    } else {
                        $tmp[] = "<input type='checkbox' name='checkContacts' id='{$value['id']}' disabled >";
                    }
                }
                if ($validatedfilters['table'] == "internal") {
                    $tmp[] = "<img id='img-users' width='16' height='16' alt='image' src='index.php?menu=_elastixutils&action=getImage&ID={$value['id']}&rawmode=yes'/>";
                } else {
                    $tmp[] = "<img id='img-users' width='16' height='16' alt='image' src='index.php?menu={$module_name}&action=getImageExtContact&image={$value['picture']}&rawmode=yes'/>";
                }
                if ($validatedfilters['table'] == "internal") {
                    $tmp[] = htmlentities($value['name'], ENT_QUOTES, "UTF-8");
                } else {
                    if ($arrCredentials['idUser'] == $value['iduser']) {
                        $tmp[] = "<a href='#' onclick='editContact({$value['id']})'>" . htmlentities($value['name'], ENT_QUOTES, "UTF-8") . "</a>";
                    } else {
                        $tmp[] = htmlentities($value['name'], ENT_QUOTES, "UTF-8");
                    }
                }
                if ($validatedfilters['table'] == "internal") {
                    $tmp[] = htmlentities($value['extension'], ENT_QUOTES, "UTF-8");
                } else {
                    if (empty($value['work_phone'])) {
                        $tmp[] = "N/A";
                    } else {
                        $tmp[] = htmlentities($value['work_phone'], ENT_QUOTES, "UTF-8");
                    }
                }
                if (!empty($value['username'])) {
                    $tmp[] = htmlentities($value['username'], ENT_QUOTES, "UTF-8");
                } else {
                    $tmp[] = "N/A";
                }
                //$tmp[]="<span class='glyphicon glyphicon-earphone'></span>";
                $tmp[] = "<a href='#' onclick='callContact({$value['id']})'><span class='glyphicon glyphicon-earphone'></span></a>";
                if ($validatedfilters['table'] == "internal") {
                    //$tmp[]=_tr('Transfer');
                    $tmp[] = "<a href='#' onclick='transferCall({$value['id']})'>" . _tr('Transfer') . "</a>";
                } else {
                    $tmp[] = "N/A";
                }
                if ($validatedfilters['table'] != "internal") {
                    if ($value['status'] == "isPrivate") {
                        $tmp[] = _tr('Private');
                    } else {
                        $tmp[] = _tr('Public');
                    }
                } else {
                    $tmp[] = _tr('Public');
                }
                $arrDatosGrid[] = $tmp;
            }
        }
    }
    $action = getParameter('action');
    if ($action == 'search') {
        $arrData['url'] = $oGrid->getURL();
        $arrData['url'] = str_replace('&amp;', '&', $arrData['url']);
        $arrData['numPage'] = $numPage;
        $arrData['currentPage'] = $currentPage;
        $arrData['content'] = $arrDatosGrid;
        $jsonObject->set_message($arrData);
        return $jsonObject->createJSON();
    }
    $oGrid->addButtonAction("new_contact", "<span class='glyphicon glyphicon-user'></span> New Contact", "", "newContact()");
    $oGrid->addButtonAction("remove_contact", "<span class='glyphicon glyphicon-remove'></span> Delete Contacts", "", "deleteContacts('" . _tr("Are you sure you wish to delete the contact.") . "')");
    $oGrid->addButtonAction("elx_upload_file", "<span class='glyphicon glyphicon-upload'></span> Upload from CSV", "", "");
    $oGrid->addButtonAction("elx_export_data", "<span class='glyphicon glyphicon-download'></span>", "", "");
    $oGrid->addButtonAction("elx_show_filter", "<span class='glyphicon glyphicon-filter'></span> Show filter", "", "");
    $arrayData = array();
    $arrFormFilter = createFilterForm();
    $oFilterForm = new paloForm($smarty, $arrFormFilter);
    $htmlFilter = $oFilterForm->fetchForm("{$local_templates_dir}/filter.tpl", _tr('extension'), $arrayData);
    $oGrid->showFilter(trim($htmlFilter));
    $contenidoModulo = actionsReport($arrDatosGrid, $oGrid);
    return $contenidoModulo;
}
Exemplo n.º 21
0
function listHistogram($pDB, $smarty, $module_name, $local_templates_dir)
{
    global $arrLang;
    // Tipo de llamada
    $comboTipos = array("E" => _tr("Ingoing"), "S" => _tr("Outgoing"));
    $sTipoLlamada = 'E';
    if (isset($_GET['tipo'])) {
        $sTipoLlamada = $_GET['tipo'];
    }
    if (isset($_POST['tipo'])) {
        $sTipoLlamada = $_POST['tipo'];
    }
    if (!in_array($sTipoLlamada, array_keys($comboTipos))) {
        $sTipoLlamada = 'E';
    }
    $_POST['tipo'] = $sTipoLlamada;
    // Para llenar el formulario
    $smarty->assign('TIPO', $_POST['tipo']);
    // Estado de la llamada
    $comboEstados = array('T' => _tr('All'), 'E' => _tr('Completed'), 'A' => _tr('Abandoned'));
    if ($sTipoLlamada == 'S') {
        $comboEstados['N'] = _tr('No answer/Short call');
    }
    $sEstadoLlamada = 'T';
    if (isset($_GET['estado'])) {
        $sEstadoLlamada = $_GET['estado'];
    }
    if (isset($_POST['estado'])) {
        $sEstadoLlamada = $_POST['estado'];
    }
    if (!in_array($sEstadoLlamada, array_keys($comboEstados))) {
        $sEstadoLlamada = 'E';
    }
    $_POST['estado'] = $sEstadoLlamada;
    // Para llenar el formulario
    $smarty->assign('ESTADO', $_POST['estado']);
    // Rango de fechas
    $sFechaInicial = $sFechaFinal = date('Y-m-d');
    if (isset($_GET['fecha_ini'])) {
        $sFechaInicial = date('Y-m-d', strtotime($_GET['fecha_ini']));
    }
    if (isset($_POST['fecha_ini'])) {
        $sFechaInicial = date('Y-m-d', strtotime($_POST['fecha_ini']));
    }
    if (isset($_GET['fecha_fin'])) {
        $sFechaFinal = date('Y-m-d', strtotime($_GET['fecha_fin']));
    }
    if (isset($_POST['fecha_fin'])) {
        $sFechaFinal = date('Y-m-d', strtotime($_POST['fecha_fin']));
    }
    $_POST['fecha_ini'] = date('d M Y', strtotime($sFechaInicial));
    $_POST['fecha_fin'] = date('d M Y', strtotime($sFechaFinal));
    $smarty->assign('FECHA_INI', $sFechaInicial);
    $smarty->assign('FECHA_FIN', $sFechaFinal);
    // Recuperar la lista de llamadas
    $oCalls = new paloSantoCallsHour($pDB);
    $arrCalls = $oCalls->getCalls($sTipoLlamada, $sEstadoLlamada, $sFechaInicial, $sFechaFinal);
    // TODO: manejar error al obtener llamadas
    if (!is_array($arrCalls)) {
        $smarty->assign("mb_title", _tr("Validation Error"));
        $smarty->assign("mb_message", $oCalls->errMsg);
        $arrCalls = array();
    }
    // Lista de colas a elegir para gráfico. Sólo se elige de las colas devueltas
    // por la lista de datos.
    $listaColas = array_keys($arrCalls);
    $comboColas = array('' => _tr('All'));
    if (count($listaColas) > 0) {
        $comboColas += array_combine($listaColas, $listaColas);
    }
    $sColaElegida = NULL;
    if (isset($_GET['queue'])) {
        $sColaElegida = $_GET['queue'];
    }
    if (isset($_POST['queue'])) {
        $sColaElegida = $_POST['queue'];
    }
    if (!in_array($sColaElegida, $listaColas)) {
        $sColaElegida = '';
    }
    $_POST['queue'] = $sColaElegida;
    // Para llenar el formulario
    $smarty->assign('QUEUE', $_POST['queue']);
    $url = construirURL(array('menu' => $module_name, 'tipo' => $sTipoLlamada, 'estado' => $sEstadoLlamada, 'queue' => $sColaElegida, 'fecha_ini' => $sFechaInicial, 'fecha_fin' => $sFechaFinal), array('nav', 'start'));
    $smarty->assign('url', $url);
    // Construir el arreglo como debe mostrarse en la tabla desglose
    $arrData = array();
    for ($i = 0; $i < 24; $i++) {
        $arrData[$i] = array(sprintf('%02d:00', $i));
    }
    $arrData[24] = array(_tr('Total Calls'));
    $arrCols = array(0 => array('name' => _tr('Hour')));
    $arrTodos = array_fill(0, 24, 0);
    foreach ($arrCalls as $sQueue => $hist) {
        if (empty($sColaElegida) || $sColaElegida == $sQueue) {
            $arrCols[] = array('name' => $sQueue);
            $iTotalCola = 0;
            foreach ($hist as $i => $iNumCalls) {
                $arrData[$i][] = $iNumCalls;
                $arrTodos[$i] += $iNumCalls;
                $iTotalCola += $iNumCalls;
            }
            $arrData[24][] = $iTotalCola;
        }
    }
    $arrCols[] = array('name' => _tr('All'));
    $iTotalCola = 0;
    foreach ($arrTodos as $i => $iNumCalls) {
        $arrData[$i][] = $iNumCalls;
        $iTotalCola += $iNumCalls;
    }
    $arrData[24][] = $iTotalCola;
    $smarty->assign('MODULE_NAME', $module_name);
    $smarty->assign('LABEL_FIND', _tr('Find'));
    $formFilter = getFormFilter($comboTipos, $comboEstados, $comboColas);
    $oForm = new paloForm($smarty, $formFilter);
    //Llenamos las cabeceras
    $arrGrid = array("title" => _tr("Graphic Calls per hour"), "url" => $url, "icon" => "images/list.png", "width" => "99%", "start" => 0, "end" => 0, "total" => 0, "columns" => $arrCols);
    $oGrid = new paloSantoGrid($smarty);
    $oGrid->showFilter($oForm->fetchForm("{$local_templates_dir}/filter-graphic-calls.tpl", NULL, $_POST));
    $oGrid->enableExport();
    if (isset($_GET['exportcsv']) && $_GET['exportcsv'] == 'yes') {
        $fechaActual = date("Y-m-d");
        header("Cache-Control: private");
        header("Pragma: cache");
        header('Content-Type: text/csv; charset=UTF-8; header=present');
        $title = "\"calls-per-hour-" . $fechaActual . ".csv\"";
        header("Content-disposition: attachment; filename={$title}");
        return $oGrid->fetchGridCSV($arrGrid, $arrData);
    } else {
        $bExportando = isset($_GET['exportcsv']) && $_GET['exportcsv'] == 'yes' || isset($_GET['exportspreadsheet']) && $_GET['exportspreadsheet'] == 'yes' || isset($_GET['exportpdf']) && $_GET['exportpdf'] == 'yes';
        $sContenido = $oGrid->fetchGrid($arrGrid, $arrData, $arrLang);
        if (!$bExportando) {
            if (strpos($sContenido, '<form') === FALSE) {
                $sContenido = "<form  method=\"POST\" style=\"margin-bottom:0;\" action=\"{$url}\">{$sContenido}</form>";
            }
        }
        return $sContenido;
    }
}
Exemplo n.º 22
0
function reportClientesagendados($smarty, $module_name, $local_templates_dir, &$pDB, $arrConf)
{
    $pClientesagendados = new paloSantoClientesagendados($pDB);
    $filter_field = getParameter("filter_field");
    $filter_value = getParameter("filter_value");
    //begin grid parameters
    $oGrid = new paloSantoGrid($smarty);
    $oGrid->setTplFile("/var/www/html/modules/{$module_name}/themes/default/_list.tpl");
    $oGrid->setTitle(_tr("Clientes agendados"));
    $oGrid->pagingShow(true);
    // show paging section.
    $oGrid->enableExport();
    // enable export.
    $oGrid->setNameFile_Export(_tr("Clientes agendados"));
    $url = array("menu" => $module_name, "filter_field" => $filter_field, "filter_value" => $filter_value);
    $oGrid->setURL($url);
    $arrColumns = array(_tr("Apellido"), _tr("Nombre"), _tr("CI"), _tr("Campaña"), _tr("Fecha de agendamiento"), _tr("Call type"), _tr("Agente agendado"), "<input class=\"button\" type=\"submit\" name=\"action\" value=\"Reasignar\">");
    $oGrid->setColumns($arrColumns);
    $total = $pClientesagendados->getNumClientesagendados($filter_field, $filter_value);
    $arrData = null;
    if ($oGrid->isExportAction()) {
        $limit = $total;
        // max number of rows.
        $offset = 0;
        // since the start.
    } else {
        $limit = 20;
        $oGrid->setLimit($limit);
        $oGrid->setTotal($total);
        $offset = $oGrid->calculateOffset();
    }
    $arrResult = $pClientesagendados->getClientesagendados($limit, $offset, $filter_field, $filter_value);
    if (is_array($arrResult) && $total > 0) {
        foreach ($arrResult as $key => $value) {
            $arrTmp[0] = $value['apellido'];
            $arrTmp[1] = $value['nombre'];
            $arrTmp[2] = $value['ci'];
            $arrTmp[3] = $value['nombre_campania'];
            $arrTmp[4] = $value['fecha_agendamiento'];
            $arrTmp[5] = $value['ultimo_calltype'];
            $arrTmp[6] = $value['agente_agendado'];
            if (empty($value['id_campania_cliente'])) {
                $arrTmp[7] = getFormSelectAgentesCampaniaRecargable($pClientesagendados, $value['id_campania'], $value['id_campania_recargable_cliente'], $value['agente_agendado']);
            } else {
                $arrTmp[7] = getFormSelectAgentesCampania($pClientesagendados, $value['id_campania'], $value['id_campania_cliente'], $value['agente_agendado']);
            }
            $arrData[] = $arrTmp;
        }
    }
    $oGrid->setData($arrData);
    //begin section filter
    $oFilterForm = new paloForm($smarty, createFieldFilter());
    $smarty->assign("SHOW", _tr("Show"));
    $htmlFilter = $oFilterForm->fetchForm("{$local_templates_dir}/filter.tpl", "", $_POST);
    //end section filter
    $oGrid->showFilter(trim($htmlFilter));
    $content = $oGrid->fetchGrid();
    //end grid parameters
    return $content;
}
Exemplo n.º 23
0
function reportRegestion($smarty, $module_name, $local_templates_dir, &$pDB, $arrConf)
{
    $pRegestion = new paloSantoRegestion($pDB);
    $filter_field = getParameter("filter_field");
    $filter_value = getParameter("filter_value");
    //begin grid parameters
    $oGrid = new paloSantoGrid($smarty);
    $oGrid->setTitle(_tr("Regestión de campañas"));
    $oGrid->pagingShow(true);
    // show paging section.
    $oGrid->enableExport();
    // enable export.
    $oGrid->setNameFile_Export(_tr("Regestión de campañas"));
    $url = array("menu" => $module_name, "filter_field" => $filter_field, "filter_value" => $filter_value);
    $oGrid->setURL($url);
    $arrColumns = array(_tr("Campaña padre"), _tr("Clase de calltypes"), _tr("Acción"));
    $oGrid->setColumns($arrColumns);
    $total = $pRegestion->getNumRegestion($filter_field, $filter_value);
    $arrData = null;
    if ($oGrid->isExportAction()) {
        $limit = $total;
        // max number of rows.
        $offset = 0;
        // since the start.
    } else {
        $limit = 20;
        $oGrid->setLimit($limit);
        $oGrid->setTotal($total);
        $offset = $oGrid->calculateOffset();
    }
    $arrResult = $pRegestion->getRegestion($limit, $offset, $filter_field, $filter_value);
    if (is_array($arrResult) && $total > 0) {
        foreach ($arrResult as $key => $value) {
            $arrTmp[0] = $value['nombre'];
            $arrTmp[1] = "<form method='POST' action=\"index.php?menu={$module_name}\">";
            $arrTmp[1] .= "<select name=\"clase_calltype\">\n\t\t\t      <option value=\"Contactado\">Contactado</option>\n\t\t\t      <option value=\"No contactado\">No contactado</option>\n\t\t\t      <option value=\"Agendado\">Agendado</option>\n\t\t\t  </select>";
            $arrTmp[1] .= "<input type=hidden name=\"action\" value=\"view_edit\">";
            $arrTmp[1] .= "<input type=hidden name=\"id\" value={$value['id']}>";
            $arrTmp[2] = "<input type=submit value=\"Regestionar\">";
            $arrTmp[2] .= "</form>";
            $arrData[] = $arrTmp;
        }
    }
    $oGrid->setData($arrData);
    //begin section filter
    $oFilterForm = new paloForm($smarty, createFieldFilter());
    $smarty->assign("SHOW", _tr("Show"));
    $htmlFilter = $oFilterForm->fetchForm("{$local_templates_dir}/filter.tpl", "", $_POST);
    //end section filter
    $oGrid->showFilter(trim($htmlFilter));
    $content = $oGrid->fetchGrid();
    //end grid parameters
    return $content;
}
Exemplo n.º 24
0
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>&nbsp;";
                    $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;
}
Exemplo n.º 25
0
function reportWeakKeys($smarty, $module_name, $local_templates_dir, &$pDB, $arrConf)
{
    $pWeakKeys = new paloSantoWeakKeys($pDB);
    $filter_field = getParameter("filter_field");
    $filter_value = getParameter("filter_value");
    //begin grid parameters
    $oGrid = new paloSantoGrid($smarty);
    $total = $pWeakKeys->getNumWeakKeys($filter_field, $filter_value);
    $pDB2 = new paloDB($arrConf['elastix_dsn']['acl']);
    $pACL = new paloACL($pDB2);
    $oGrid->enableExport();
    // enable csv export.
    $oGrid->pagingShow(true);
    // show paging section.
    $oGrid->setTitle(_tr("Weak Secrets"));
    $oGrid->setIcon("modules/{$module_name}/images/security_weak_keys.png");
    $oGrid->setNameFile_Export(_tr("Weak Secrets"));
    if ($oGrid->isExportAction()) {
        $limit = $total;
        $offset = 0;
        $bExportation = true;
    } else {
        $limit = 30;
        $oGrid->setLimit($limit);
        $oGrid->setTotal($total);
        $offset = $oGrid->calculateOffset();
        $bExportation = false;
    }
    $url = array('menu' => $module_name, 'filter_field' => $filter_field, 'filter_value' => $filter_value);
    $oGrid->setURL($url);
    $arrResult = $pWeakKeys->getWeakKeys($limit, $offset, $filter_field, $filter_value);
    $arrData = null;
    //$arrResult =$pWeakKeys->getWeakKeysChecker();
    $arrColumns = array(_tr("Extension"), _tr("Description"), _tr("Status"));
    $oGrid->setColumns($arrColumns);
    if (is_array($arrResult) && $total > 0) {
        foreach ($arrResult as $tech) {
            foreach ($tech as $key => $value) {
                $arrTmp[0] = $value['id'];
                $arrTmp[1] = $value['description'];
                $mensaje = getMensaje($value['id'], $value['data']);
                if ($mensaje != "OK" && !$bExportation) {
                    if ($pACL->isUserAdministratorGroup($_SESSION['elastix_user']) || $pACL->getUserExtension($_SESSION['elastix_user']) == $value['id']) {
                        $mensaje = _tr("Weak Key") . ": {$mensaje} &nbsp;<a href='?menu={$module_name}&action=change&id={$value['id']}'>" . _tr("Change Secret") . "</a>";
                    }
                }
                $arrTmp[2] = $mensaje;
                $arrData[] = $arrTmp;
            }
        }
    }
    $oGrid->setData($arrData);
    //begin section filter
    $arrFormFilterWeakKeys = createFieldFilter();
    $oFilterForm = new paloForm($smarty, $arrFormFilterWeakKeys);
    $smarty->assign("SHOW", _tr("Show"));
    $_POST["filter_field"] = $filter_field;
    $_POST["filter_value"] = $filter_value;
    $oGrid->addFilterControl(_tr("Filter applied: ") . _tr("Extension") . " = " . $filter_value, $_POST, array("filter_field" => "extension", "filter_value" => ""));
    $htmlFilter = $oFilterForm->fetchForm("{$local_templates_dir}/filter.tpl", "", $_POST);
    //end section filter
    $oGrid->showFilter(trim($htmlFilter));
    $content = $oGrid->fetchGrid();
    //end grid parameters
    return $content;
}
Exemplo n.º 26
0
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;
}
Exemplo n.º 27
0
function _moduleContent(&$smarty, $module_name)
{
    //include module files
    include_once "modules/{$module_name}/configs/default.conf.php";
    include_once "modules/{$module_name}/libs/paloSantoCallsDetail.class.php";
    include_once "modules/agent_console/getinfo.php";
    global $arrConf;
    load_language_module($module_name);
    //folder path for custom templates
    $base_dir = dirname($_SERVER['SCRIPT_FILENAME']);
    $templates_dir = isset($arrConfig['templates_dir']) ? $arrConfig['templates_dir'] : 'themes';
    $local_templates_dir = "{$base_dir}/modules/{$module_name}/" . $templates_dir . '/' . $arrConf['theme'];
    // added by Tri Do
    $sAction = getParameter('action');
    switch ($sAction) {
        case 'viewNote':
            return viewNote();
            break;
        case 'viewDelivery':
            return view_delivery();
            break;
        default:
            break;
    }
    // Cadenas estáticas de Smarty
    $smarty->assign(array("Filter" => _tr('Filter'), "SHOW" => _tr("Show")));
    $bElastixNuevo = method_exists('paloSantoGrid', 'setURL');
    // Variables iniciales para posición de grid
    $offset = 0;
    $limit = 50;
    $total = 0;
    // Para poder consultar las colas activas
    $pConfig = new paloConfig("/etc", "amportal.conf", "=", "[[:space:]]*=[[:space:]]*");
    $ampconfig = $pConfig->leer_configuracion(false);
    $ampdsn = $ampconfig['AMPDBENGINE']['valor'] . "://" . $ampconfig['AMPDBUSER']['valor'] . ":" . $ampconfig['AMPDBPASS']['valor'] . "@" . $ampconfig['AMPDBHOST']['valor'] . "/asterisk";
    $oQueue = new paloQueue($ampdsn);
    $listaColas = $oQueue->getQueue();
    if (!is_array($listaColas)) {
        $smarty->assign("mb_title", _tr("Error when connecting to database"));
        $smarty->assign("mb_message", $oQueue->errMsg);
    }
    // Para poder consultar los agentes de campañas
    $pDB = new paloDB($cadena_dsn);
    $oCallsDetail = new paloSantoCallsDetail($pDB);
    $listaAgentes = $oCallsDetail->getAgents();
    // Para llenar el select de agentes
    $urlVars = array('menu' => $module_name);
    $arrFormElements = createFieldFilter($listaAgentes, $listaColas);
    $oFilterForm = new paloForm($smarty, $arrFormElements);
    // Validar y aplicar las variables de filtro
    $paramLista = NULL;
    $paramFiltro = array();
    foreach (array('date_start', 'date_end', 'calltype', 'agent', 'queue', 'phone') as $k) {
        $paramFiltro[$k] = getParameter($k);
    }
    if (!isset($paramFiltro['date_start'])) {
        $paramFiltro['date_start'] = date("d M Y");
    }
    if (!isset($paramFiltro['date_end'])) {
        $paramFiltro['date_end'] = date("d M Y");
    }
    if (!$oFilterForm->validateForm($paramFiltro)) {
        // Hay un error al validar las variables del filtro
        $smarty->assign("mb_title", _tr("Validation Error"));
        $arrErrores = $oFilterForm->arrErroresValidacion;
        $strErrorMsg = "<b>" . _tr('The following fields contain errors') . ":</b><br>";
        $strErrorMsg = implode(', ', array_keys($arrErrores));
        $smarty->assign("mb_message", $strErrorMsg);
    } else {
        $urlVars = array_merge($urlVars, $paramFiltro);
        $paramLista = $paramFiltro;
        $paramLista['date_start'] = translateDate($paramFiltro['date_start']) . " 00:00:00";
        $paramLista['date_end'] = translateDate($paramFiltro['date_end']) . " 23:59:59";
    }
    $htmlFilter = $oFilterForm->fetchForm("{$local_templates_dir}/filter.tpl", "", $paramFiltro);
    // Inicio de objeto grilla y asignación de filtro
    $oGrid = new paloSantoGrid($smarty);
    $oGrid->enableExport();
    // enable export.
    $oGrid->showFilter($htmlFilter);
    $bExportando = $bElastixNuevo ? $oGrid->isExportAction() : isset($_GET['exportcsv']) && $_GET['exportcsv'] == 'yes' || isset($_GET['exportspreadsheet']) && $_GET['exportspreadsheet'] == 'yes' || isset($_GET['exportpdf']) && $_GET['exportpdf'] == 'yes';
    // Ejecutar la consulta con las variables ya validadas
    $arrData = array();
    $total = 0;
    if (is_array($paramLista)) {
        $total = $oCallsDetail->contarDetalleLlamadas($paramLista);
        if (is_null($total)) {
            $smarty->assign("mb_title", _tr("Error when connecting to database"));
            $smarty->assign("mb_message", $oCallsDetail->errMsg);
            $total = 0;
        } else {
            // Habilitar la exportación de todo el contenido consultado
            if ($bExportando) {
                $limit = $total;
            }
            // Calcular el offset de la petición de registros
            if ($bElastixNuevo) {
                $oGrid->setLimit($limit);
                $oGrid->setTotal($total);
                $offset = $oGrid->calculateOffset();
            } else {
                // Si se quiere avanzar a la sgte. pagina
                if (isset($_GET['nav']) && $_GET['nav'] == "end") {
                    // Mejorar el sgte. bloque.
                    if ($total % $limit == 0) {
                        $offset = $total - $limit;
                    } else {
                        $offset = $total - $total % $limit;
                    }
                }
                // Si se quiere avanzar a la sgte. pagina
                if (isset($_GET['nav']) && $_GET['nav'] == "next") {
                    $offset = $_GET['start'] + $limit - 1;
                }
                // Si se quiere retroceder
                if (isset($_GET['nav']) && $_GET['nav'] == "previous") {
                    $offset = $_GET['start'] - $limit - 1;
                }
            }
            // Ejecutar la consulta de los datos en el offset indicado
            $recordset = $oCallsDetail->leerDetalleLlamadas($paramLista, $limit, $offset);
            // add STT
            for ($i = 0; $i < count($recordset); $i++) {
                $recordset[$i]['stt'] = $i + 1;
            }
            if (!is_array($recordset)) {
                $smarty->assign("mb_title", _tr("Error when connecting to database"));
                $smarty->assign("mb_message", $oCallsDetail->errMsg);
                $total = 0;
            } else {
                function _calls_detail_map_recordset($cdr)
                {
                    $mapaEstados = array('abandonada' => 'Bỏ nhỡ', 'Abandoned' => 'Bỏ nhỡ', 'terminada' => 'Đã nghe', 'Success' => 'Đã nghe', 'fin-monitoreo' => _tr('End Monitor'), 'Failure' => _tr('Failure'), 'NoAnswer' => _tr('NoAnswer'), 'OnQueue' => _tr('OnQueue'), 'Placing' => _tr('Placing'), 'Ringing' => _tr('Ringing'), 'ShortCall' => _tr('ShortCall'), 'activa' => 'Đang gọi');
                    return array($cdr['stt'], $cdr[0], htmlentities($cdr[1], ENT_COMPAT, "UTF-8"), substr($cdr[2], 0, 10), substr($cdr[2], 11, 8), substr($cdr[3], 0, 10), substr($cdr[3], 11, 8), is_null($cdr[4]) ? '-' : formatoSegundos($cdr[4]), is_null($cdr[5]) ? '-' : formatoSegundos($cdr[5]), $cdr[6], $cdr[8], $cdr[9], isset($mapaEstados[$cdr[10]]) ? $mapaEstados[$cdr[10]] : _tr($cdr[10]), is_null($cdr[12]) || trim($cdr[12] == '') ? '' : '<a href="javascript:void(0)" onclick="view_note(\'' . $cdr[11] . '\')">Xem</a>');
                }
                $arrData = array_map('_calls_detail_map_recordset', $recordset);
            }
        }
    }
    $arrColumnas = array('STT', 'Số Agent', 'Nhân viên', _tr("Start Date"), _tr("Start Time"), _tr("End Date"), _tr("End Time"), "Thời lượng", _tr("Thời gian chờ"), _tr("Queue"), _tr("Số điện thoại"), _tr("Chuyển máy"), _tr("Status"), 'Nội dung');
    if ($bElastixNuevo) {
        $oGrid->setURL(construirURL($urlVars, array("nav", "start")));
        $oGrid->setData($arrData);
        $oGrid->setColumns($arrColumnas);
        $oGrid->setTitle('Chi tiết cuộc gọi Call Center');
        $oGrid->pagingShow(true);
        $oGrid->setNameFile_Export(_tr("Calls Detail"));
        return $oGrid->fetchGrid();
    } else {
        global $arrLang;
        $url = construirURL($urlVars, array("nav", "start"));
        function _map_name($s)
        {
            return array('name' => $s);
        }
        $arrGrid = array("title" => _tr("Calls Detail"), "url" => $url, "icon" => "images/user.png", "width" => "99%", "start" => $total == 0 ? 0 : $offset + 1, "end" => $offset + $limit <= $total ? $offset + $limit : $total, "total" => $total, "columns" => array_map('_map_name', $arrColumnas));
        if (isset($_GET['exportpdf']) && $_GET['exportpdf'] == 'yes' && method_exists($oGrid, 'fetchGridPDF')) {
            return $oGrid->fetchGridPDF($arrGrid, $arrData);
        }
        if (isset($_GET['exportspreadsheet']) && $_GET['exportspreadsheet'] == 'yes' && method_exists($oGrid, 'fetchGridXLS')) {
            return $oGrid->fetchGridXLS($arrGrid, $arrData);
        }
        if ($bExportando) {
            header("Cache-Control: private");
            header("Pragma: cache");
            // Se requiere para HTTPS bajo IE6
            header('Content-disposition: inline; filename="calls_detail.csv"');
            header("Content-Type: text/csv; charset=UTF-8");
        }
        if ($bExportando) {
            return $oGrid->fetchGridCSV($arrGrid, $arrData);
        }
        $sContenido = $oGrid->fetchGrid($arrGrid, $arrData, $arrLang);
        if (strpos($sContenido, '<form') === FALSE) {
            $sContenido = "<form  method=\"POST\" style=\"margin-bottom:0;\" action=\"{$url}\">{$sContenido}</form>";
        }
        return $sContenido;
    }
}
Exemplo n.º 28
0
function reportReportedeCalltypes($smarty, $module_name, $local_templates_dir, &$pDB, $arrConf, $argv)
{
    $pReportedeCalltypes = new paloSantoReportedeCalltypes($pDB);
    $filter_field = $argv[3];
    //getParameter("filter_field");
    $filter_value = $argv[4];
    //getParameter("filter_value");
    $id_campania = $argv[1];
    //getParameter("id_campania");
    $tiempo_unix = $argv[2];
    $nombre_archivo = '/modules/hispana_reporte_calltype/reportes/Reporte_de_Calltypes_' . $id_campania . "_{$tiempo_unix}.xls";
    $pReportedeCalltypes->registraReporteOffline($id_campania, $tiempo_unix, $nombre_archivo, "{$filter_field}={$filter_value}");
    //begin grid parameters
    $oGrid = new paloSantoGrid($smarty);
    $oGrid->setTitle(_tr("Reporte de Calltypes"));
    $oGrid->pagingShow(true);
    // show paging section.
    $oGrid->enableExport();
    // enable export.
    $oGrid->setNameFile_Export(_tr("Reporte de Calltypes"));
    $url = array("menu" => $module_name, "filter_field" => $filter_field, "filter_value" => $filter_value, "id_campania" => $id_campania);
    $oGrid->setURL($url);
    // Columnas base
    $arrColumns = array(_tr("Fecha"), _tr("Campaña"), _tr("Base"), _tr("Cliente"), _tr("CI"), _tr("Teléfono"), _tr("Agente"), _tr("Contactabilidad"), _tr("Mejor calltype"), _tr("Formulario"));
    // Otras columnas
    if ($id_campania != "") {
        // Columnas adicionales
        $arrColumnasAdicionales = $pReportedeCalltypes->getColumnasAdicionales($id_campania);
        $arrColumns = array_merge($arrColumns, $arrColumnasAdicionales);
        // Columnas de gestión
        $arrTmp = $pReportedeCalltypes->getFormFields($id_campania);
        $i = 0;
        foreach ($arrTmp as $formField) {
            $arrOrden[] = $formField['id'];
            $arrColumnsAdicionales[$i] = $formField['etiqueta'];
            $i++;
        }
        $arrColumns = array_merge($arrColumns, $arrColumnsAdicionales);
    }
    $oGrid->setColumns($arrColumns);
    $total = $pReportedeCalltypes->getNumReportedeCalltypes($filter_field, $filter_value, $id_campania);
    $arrData = null;
    //if($oGrid->isExportAction()){
    $limit = $total;
    // max number of rows.
    $offset = 0;
    // since the start.
    /*}else{
          $limit  = 20; // default 20
          $oGrid->setLimit($limit);
          $oGrid->setTotal($total);
          $offset = $oGrid->calculateOffset();
      }*/
    $arrResult = $pReportedeCalltypes->getReportedeCalltypes($limit, $offset, $filter_field, $filter_value, $id_campania);
    if (is_array($arrResult) && $total > 0) {
        foreach ($arrResult as $key => $value) {
            $arrTmp[0] = $value['fecha'];
            $arrTmp[1] = $value['base'];
            $arrTmp[2] = $value['campania'];
            $arrTmp[3] = $value['cliente'];
            $arrTmp[4] = $value['ci'];
            $arrTmp[5] = $value['telefono'];
            $arrTmp[6] = $value['agente'];
            $arrTmp[7] = $value['contactabilidad'];
            $arrTmp[8] = $value['mejor_calltype'];
            // $arrTmp[8] = $value['formulario'];
            // Así lo requiere RUBENING
            /*$arrTmp[9] = "<a href=modules/$module_name/gestion_info.php?id_gestion=$value[id_gestion_mejor_calltype] target=\"_blank\" onClick=\"window.open(this.href, this.target, 'width=600,height=400'); return false;\">Ver gestión</a>".
               "<br>".
              "<a href=modules/$module_name/gestion_edit.php?id_gestion=$value[id_gestion_mejor_calltype]&user="******"elastix_user"]." target=\"_blank\" onClick=\"window.open(this.href, this.target, 'width=600,height=400'); return false;\">Editar</a>"*/
            //$arrTmp[9] = "<a href=modules/$module_name/gestion_info.php?id_gestion=$value[id_gestion_mejor_calltype] target=\"_blank\" onClick=\"window.open(this.href, this.target, 'width=600,height=400'); return false;\">Ver gestión</a>";
            // Datos adicionales
            $arrDatosAdicionales = $pReportedeCalltypes->getDatosAdicionales($value['ci']);
            $i = 10;
            foreach ($arrColumnasAdicionales as $k => $columnaAdicional) {
                $arrTmp[$i] = $arrDatosAdicionales[$columnaAdicional];
                $i++;
            }
            unset($arrDatosAdicionales);
            $numColumnasFijas = $i;
            // Datos de gestión
            $arrFormValues = $pReportedeCalltypes->getFormValues($value['id_gestion_mejor_calltype']);
            // array_search retorna el key dado el valor a buscar
            foreach ($arrFormValues as $formValue) {
                // echo $formValue['valor'] . " " . array_search($formValue['id_form_field'],$arrOrden) . "<br>";
                $ubicacionReal = array_search($formValue['id_form_field'], $arrOrden) + $numColumnasFijas;
                if (is_array($formValue['valor'])) {
                    $formValue['valor'] = print_r($formValue['valor'], true);
                }
                $arrTmp[$ubicacionReal] = $formValue['valor'];
            }
            $arrData[] = $arrTmp;
            unset($arrTmp);
        }
    }
    $oGrid->setData($arrData);
    /* Para colocar en $arrTmp 
     */
    //begin section filter
    //$oFilterForm = new paloForm($smarty, createFieldFilter());
    //$smarty->assign("SHOW", _tr("Show"));
    //$smarty->assign("filter_campaign", filter_campaign($pDB, $id_campania));
    //$htmlFilter  = $oFilterForm->fetchForm("$local_templates_dir/filter.tpl","",$_POST);
    //end section filter
    //$oGrid->showFilter(trim($htmlFilter));
    $export = $oGrid->exportType();
    $content = $oGrid->fetchGrid();
    //end grid parameters
    //REPORTE OFFLINE
    //exportspreadsheet=yes&rawmode=yes
    if ($export == 'csv' || $export == 'pdf' || ($export = 'xls')) {
        $nombre_archivo = '/var/www/html/modules/hispana_reporte_calltype/reportes/Reporte_de_Calltypes_' . $id_campania . "_{$tiempo_unix}." . $export;
        $fd = fopen($nombre_archivo, "w");
        fwrite($fd, $content);
        fclose($fd);
    }
    $nombre_archivo = '/modules/hispana_reporte_calltype/reportes/Reporte_de_Calltypes_' . $id_campania . "_{$tiempo_unix}." . $export;
    $pReportedeCalltypes->actualizaReporteOffline($id_campania, $tiempo_unix);
    return $content;
}
Exemplo n.º 29
0
function report_TicketDelivery($smarty, $module_name, $local_templates_dir, &$pDB, $pDB_2)
{
    $pTicket_Delivery = new Ticket_Delivery($pDB);
    $pACL = new paloACL($pDB_2);
    $img_dir = "modules/{$module_name}/images/";
    // get filter parameters
    $filter = array('date_start' => trim($_POST['date_start']) == '' ? '' : date("Y-m-d", strtotime($_POST['date_start'])), 'date_end' => trim($_POST['date_end']) == '' ? '' : date("Y-m-d", strtotime($_POST['date_end'])), 'customer_name' => trim($_POST['customer_name']), 'customer_phone' => trim($_POST['customer_number']), 'ticket_code' => trim($_POST['ticket_code']), 'status' => trim($_POST['status']));
    //begin grid parameters
    $oGrid = new paloSantoGrid($smarty);
    $oGrid->setTitle("Yêu cầu giao vé");
    $oGrid->setTableName("delivery_grid");
    $oGrid->pagingShow(true);
    // show paging section.
    $oGrid->enableExport();
    // enable export.
    $oGrid->setNameFile_Export("ticket_delivery");
    $url = array("menu" => $module_name);
    $oGrid->setURL($url);
    $arrColumns = array("ID", "Tên Khách Hàng", "Số điện thoại", "Booker", "Địa chỉ", "Tiền trả", "Mã số vé", "Tình trạng", "Nhân viên giao", "Ngày phân công", "Vé đính kèm", "Ngày nhận tiền", "Xử lý", "Chi tiết", " ");
    $oGrid->setColumns($arrColumns);
    $total = $pTicket_Delivery->getNumTicket_Delivery($filter);
    $arrData = null;
    if ($oGrid->isExportAction()) {
        $limit = $total;
        // max number of rows.
        $offset = 0;
        // since the start.
    } else {
        $limit = 20;
        $oGrid->setLimit($limit);
        $oGrid->setTotal($total);
        $offset = $oGrid->calculateOffset();
    }
    $arrResult = $pTicket_Delivery->getTicket_Delivery($limit, $offset, $filter);
    if (is_array($arrResult) && $total > 0) {
        foreach ($arrResult as $key => $value) {
            $ticket = '';
            $name = $pACL->getUsers($value['accounting_id']);
            $elastix_user = is_null($value['accounting_id']) ? '(Chưa nhận)' : $name[0][1];
            // show files
            $download = '';
            foreach ($value['ticket_attachment'] as $row) {
                $url = "/modules/agent_console/ajax-attachments-handler.php?download=" . $row['filepath'] . "&name=" . $row['filename'];
                $filename = $row['filename'];
                $download .= "*<a href='{$url}' target='_blank' title='{$filename}'>" . shorten($filename) . "</a><br/>";
            }
            $print = '<a href="javascript:void(0)" onclick="print(\'' . $value['id'] . '\')"><img src="' . $img_dir . 'print.png" title="In phiếu"></a>';
            $enable = $value['isActive'] == '1' ? '<a href="javascript:void(0)" onclick="disable(\'' . $value['id'] . '\')"><img src="' . $img_dir . 'disable.png" title="Hủy yêu cầu giao vé"></a>&nbsp;' : '
            <a href="javascript:void(0)" onclick="enable(\'' . $value['id'] . '\')"><img src="' . $img_dir . 'enable.png" title="Tạo lại yêu cầu giao vé"></a>';
            $print .= '&nbsp;&nbsp;' . $enable;
            // function show base on status
            if ($value['isActive'] == '0') {
                $value['status'] = 'Đã hủy';
            }
            switch ($value['status']) {
                case 'Mới':
                    $function = '<a href="javascript:void(1)" onclick="assign_form(\'' . $value['id'] . '\')"><img src="' . $img_dir . 'assign.png" title="Phân công"></a>';
                    break;
                case 'Đang giao':
                    $function = '<a href="javascript:void(1)" onclick="assign_form(\'' . $value['id'] . '\')"><img src="' . $img_dir . 'assign.png" title="Đổi phân công"></a>&nbsp;
                        <a href="javascript:void(1)" onclick="collect_form(\'' . $value['id'] . '\',\'' . $elastix_user . '\')"><img src="' . $img_dir . 'result.png" title="Kết quả"></a>';
                    break;
                case 'Đã nhận tiền':
                    $function = '<a href="javascript:void(1)" onclick="uncollect_form(\'' . $value['id'] . '\',\'' . $elastix_user . '\')"><img src="' . $img_dir . 'unpaid.png" title="Hủy nhận tiền"></a>';
                    break;
                case 'Chờ xử lý':
                    $function = '<a href="javascript:void(1)" onclick="assign_form(\'' . $value['id'] . '\')"><img src="' . $img_dir . 'assign.png" title="Phân công"></a>';
                    break;
                default:
                    $function = '';
            }
            // show ticket code
            foreach ($value['ticket_code'] as $row) {
                $ticket .= $row . '<br>';
            }
            $arrTmp[0] = $value['id'];
            $arrTmp[1] = $value['customer_name'];
            $arrTmp[2] = $value['customer_phone'];
            $arrTmp[3] = '<span title="Chi nhánh: ' . $value['office'] . '">' . $value['agent_name'] . '</span>';
            $arrTmp[4] = '<a href="javascript:void(1)" title="' . $value['deliver_address'] . '"
			                onclick="view_address(\'' . $value['deliver_address'] . '\')">' . shorten($value['deliver_address']) . '
			              </a>';
            $arrTmp[5] = $value['pay_amount'];
            $arrTmp[6] = $ticket;
            $arrTmp[7] = showStatus($value['status']);
            $arrTmp[8] = $value['delivery_name'];
            $arrTmp[9] = is_null($value['delivery_date']) ? '' : date("d-m-Y H:m:s", strtotime($value['delivery_date']));
            $arrTmp[10] = $download;
            $arrTmp[11] = is_null($value['collection_date']) ? '' : date("d-m-Y H:m:s", strtotime($value['collection_date']));
            $arrTmp[12] = $function;
            $arrTmp[13] = '<a href="javascript:void(1)" onclick="view_log(\'' . $value['id'] . '\')">
			            <img src="' . $img_dir . 'extra.png" title="Xem chi tiết"></a>';
            $arrTmp[14] = $print;
            $arrData[] = $arrTmp;
        }
    }
    $oGrid->setData($arrData);
    //begin section filter
    $oFilterForm = new paloForm($smarty, createFieldFilter());
    // get delivery man list
    $delivery_man_list = $pTicket_Delivery->getDeliveryMan();
    $smarty->assign("DELIVERY_MAN_LIST", $delivery_man_list);
    $htmlFilter = $oFilterForm->fetchForm("{$local_templates_dir}/filter.tpl", "", $_POST);
    //end section filter
    $oGrid->showFilter(trim($htmlFilter));
    $content = $oGrid->fetchGrid();
    //end grid parameters
    return $content;
}
Exemplo n.º 30
0
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'/>&nbsp;&nbsp;</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;
}