function report_Extention($smarty, $module_name, $local_templates_dir, $pDB_cdr, $pDB_ext) { $arrFormElements = array("date_from" => array("LABEL" => _tr("Start date"), "REQUIRED" => "yes", "INPUT_TYPE" => "DATE", "INPUT_EXTRA_PARAM" => "", "VALIDATION_TYPE" => "text", "VALIDATION_EXTRA_PARAM" => ""), "date_to" => array("LABEL" => _tr("End date"), "REQUIRED" => "no", "INPUT_TYPE" => "DATE", "INPUT_EXTRA_PARAM" => "", "VALIDATION_TYPE" => "text", "VALIDATION_EXTRA_PARAM" => ""), "extensions" => array("LABEL" => _tr("Number"), "REQUIRED" => "no", "INPUT_TYPE" => "SELECT", "INPUT_EXTRA_PARAM" => loadExtentions($pDB_ext), "VALIDATION_TYPE" => "text", "EDITABLE" => "yes", "VALIDATION_EXTRA_PARAM" => ""), "classify_by" => array("LABEL" => "", "REQUIRED" => "no", "INPUT_TYPE" => "SELECT", "INPUT_EXTRA_PARAM" => array("Number" => _tr('Extension (Number)'), "Queue" => _tr('Queue'), "Trunk" => _tr('Trunk')), "VALIDATION_TYPE" => "text", "EDITABLE" => "yes", "VALIDATION_EXTRA_PARAM" => "", 'ONCHANGE' => 'show_elements();'), "call_to" => array("LABEL" => _tr("Number"), "REQUIRED" => "yes", "INPUT_TYPE" => "TEXT", "INPUT_EXTRA_PARAM" => array("id" => 'call_to'), "VALIDATION_TYPE" => "text", "EDITABLE" => "yes", "VALIDATION_EXTRA_PARAM" => ""), "trunks" => array("LABEL" => "Trunk", "REQUIRED" => "no", "INPUT_TYPE" => "SELECT", "INPUT_EXTRA_PARAM" => loadTrunks($pDB_ext), "VALIDATION_TYPE" => "text", "EDITABLE" => "yes", "VALIDATION_EXTRA_PARAM" => "")); $oFilterForm = new paloForm($smarty, $arrFormElements); $smarty->assign("SHOW", _tr("Show")); $smarty->assign("HERE", _tr("Here")); $date_ini = getParameter("date_from"); $date_fin = getParameter("date_to"); $ext = getParameter("call_to"); $date_ini2 = translateDate($date_ini); $date_fin2 = translateDate($date_fin); $ext2 = $ext; $option = ""; if (isset($_POST["classify_by"])) { $option = $_POST["classify_by"]; $smarty->assign("classify_by", $option); } if (getAction() == "show") { $smarty->assign("date_from", $date_ini); $smarty->assign("date_1", $date_ini); $smarty->assign("date_to", $date_fin); $smarty->assign("date_2", $date_fin); $date_ini2 = translateDate($date_ini); $date_fin2 = translateDate($date_fin); } else { $_POST["date_from"] = date("d M Y"); $_POST["date_to"] = date("d M Y"); $date_ini = date("d M Y"); $date_fin = date("d M Y"); $date_ini2 = translateDate($date_ini); $date_fin2 = translateDate($date_fin); } $_POST["extensions"] = $ext; $smarty->assign("value_2", $date_ini); $smarty->assign("module_name", $module_name); $pExtention = new paloSantoExtention($pDB_cdr); $ruta_img = array(); $error = false; if ($option == "Number") { if (!preg_match("/^[1-9]{1}[[:digit:]]*\$/", $ext) && isset($ext)) { $error = true; $smarty->assign("mb_title", _tr("Validation Error")); $smarty->assign("mb_message", _tr("The extension must be numeric and can not start with zero")); } $smarty->assign("SELECTED_1", "selected"); $smarty->assign("SELECTED_2", ""); $smarty->assign("SELECTED_3", ""); $numIn = 0; $numOut = 0; $numTot = 0; $result = $pExtention->countCallsByExtension($date_ini2, $date_fin2, $ext); if (is_array($result)) { $numIn = $result['num_incoming_call']; $numOut = $result['num_outgoing_call']; $numTot = $numIn + $numOut; } if ($numIn != 0) { $VALUE = (int) (100 * ($numIn / $numTot)); } else { $VALUE = 0; } $ruta_img = array("?menu={$module_name}&action=grafic&du={$VALUE}%&in={$numIn}&out={$numOut}&ext={$ext2}&tot={$numTot}&rawmode=yes"); } else { if ($option == "Queue") { $smarty->assign("SELECTED_1", ""); $smarty->assign("SELECTED_2", "selected"); $smarty->assign("SELECTED_3", ""); $ruta_img = array("?menu={$module_name}&action=grafic_queue&queue={$ext2}&dti={$date_ini2}&dtf={$date_fin2}&rawmode=yes"); } else { if ($option == "Trunk") { $smarty->assign("SELECTED_1", ""); $smarty->assign("SELECTED_2", ""); $smarty->assign("SELECTED_3", "selected"); $trunkT = getParameter("trunks"); $smarty->assign("trunks", $trunkT); $ruta_img = array("?menu={$module_name}&action=grafic_trunk&trunk={$trunkT}&dti={$date_ini2}&dtf={$date_fin2}&rawmode=yes", "?menu={$module_name}&action=grafic_trunk2&trunk={$trunkT}&dti={$date_ini2}&dtf={$date_fin2}&rawmode=yes"); } } } for ($i = 0; $i < count($ruta_img); $i++) { $ruta_img[$i] = "<img src='" . $ruta_img[$i] . "' border='0'>"; } if (count($ruta_img) > 0 && !$error) { $smarty->assign("ruta_img", "<tr class='letra12'><td align='center'>" . implode(' ', $ruta_img) . '<td></tr>'); } else { $smarty->assign("ruta_img", "<tr class='letra12'><td align='center'><td></tr>"); } $smarty->assign("icon", "modules/{$module_name}/images/reports_graphic_reports.png"); $htmlForm = $oFilterForm->fetchForm("{$local_templates_dir}/filter.tpl", _tr("Graphic Report"), $_POST); $contenidoModulo = "<form method='POST' style='margin-bottom:0;' action='?menu={$module_name}'>" . $htmlForm . "</form>"; return $contenidoModulo; }
function report_Extention($smarty, $module_name, $local_templates_dir, $arrLang, $pDB_cdr, $pDB_ext, $arrLangModule) { $arrCalls = array("All" => $arrLang["All"], "Incoming_Calls" => $arrLang["Incoming Calls"], "Outcoming_Calls" => "Outcoming Calls"); $arrFormElements = array("date_from" => array("LABEL" => $arrLangModule["Start date"], "REQUIRED" => "yes", "INPUT_TYPE" => "DATE", "INPUT_EXTRA_PARAM" => "", "VALIDATION_TYPE" => "text", "VALIDATION_EXTRA_PARAM" => ""), "date_to" => array("LABEL" => $arrLangModule["End date"], "REQUIRED" => "no", "INPUT_TYPE" => "DATE", "INPUT_EXTRA_PARAM" => "", "VALIDATION_TYPE" => "text", "VALIDATION_EXTRA_PARAM" => ""), "extensions" => array("LABEL" => $arrLangModule["Number"], "REQUIRED" => "no", "INPUT_TYPE" => "SELECT", "INPUT_EXTRA_PARAM" => loadExtentions($pDB_ext), "VALIDATION_TYPE" => "text", "EDITABLE" => "yes", "VALIDATION_EXTRA_PARAM" => ""), "extensions_option" => array("LABEL" => "", "REQUIRED" => "no", "INPUT_TYPE" => "SELECT", "INPUT_EXTRA_PARAM" => array("Number" => "Number", "Queue" => "Queue", "Trunk" => "Trunk"), "VALIDATION_TYPE" => "text", "EDITABLE" => "yes", "VALIDATION_EXTRA_PARAM" => ""), "call_to" => array("LABEL" => $arrLangModule["Number"], "REQUIRED" => "yes", "INPUT_TYPE" => "TEXT", "INPUT_EXTRA_PARAM" => array("id" => 'call_to'), "VALIDATION_TYPE" => "text", "EDITABLE" => "yes", "VALIDATION_EXTRA_PARAM" => ""), "trunks" => array("LABEL" => "Trunk", "REQUIRED" => "no", "INPUT_TYPE" => "SELECT", "INPUT_EXTRA_PARAM" => loadTrunks($pDB_ext), "VALIDATION_TYPE" => "text", "EDITABLE" => "yes", "VALIDATION_EXTRA_PARAM" => "")); $oFilterForm = new paloForm($smarty, $arrFormElements); $smarty->assign("SHOW", $arrLang["Show"]); $smarty->assign("HERE", $arrLangModule["Here"]); $date_ini = getParameter("date_from"); $date_fin = getParameter("date_to"); $ext = getParameter("call_to"); $calls_io = getParameter("calls"); $date_ini2 = ConverterDate($date_ini); $date_fin2 = ConverterDate($date_fin); $ext2 = $ext; $option = ""; if (isset($_POST["classify_by"])) { $option = $_POST["classify_by"]; $smarty->assign("classify_by", $option); } if (getAction() == "show") { $smarty->assign("date_from", $date_ini); $smarty->assign("date_1", $date_ini); $smarty->assign("date_to", $date_fin); $smarty->assign("date_2", $date_fin); $date_ini2 = ConverterDate($date_ini); $date_fin2 = ConverterDate($date_fin); } else { $_POST["date_from"] = date("d M Y"); $_POST["date_to"] = date("d M Y"); $date_ini = date("d M Y"); $date_fin = date("d M Y"); $date_ini2 = ConverterDate($date_ini); $date_fin2 = ConverterDate($date_fin); } $_POST["extensions"] = $ext; $_POST["calls"] = $calls_io; $smarty->assign("value_2", $date_ini); $smarty->assign("module_name", $module_name); $pExtention = new paloSantoExtention($pDB_cdr); $ruta_img = array(); $error = false; if ($option == "Number") { if (!preg_match("/^[1-9]{1}[[:digit:]]*\$/", $ext) && isset($ext)) { $error = true; $smarty->assign("mb_title", $arrLang["Validation Error"]); $smarty->assign("mb_message", $arrLang["The extension must be numeric and can not start with zero"]); } $smarty->assign("SELECTED_1", "selected"); $smarty->assign("SELECTED_2", ""); $smarty->assign("SELECTED_3", ""); //Paginacion //$limit = 15; $total_datos = $pExtention->ObtainNumExtention($date_ini2, $date_fin2, $ext2, $calls_io); $total = $total_datos[0]; $numIn = 0; $numOut = 0; $numTot = 0; if ($calls_io == "Incoming_Calls") { //CUANDO ES INCOMING $numTot_T = $pExtention->ObtainNumExtention($date_ini2, $date_fin2, $ext2, ""); //total TODOS $numTot = $numTot_T[0]; //$total -> incoming $numIn = $total; $numOut = $numTot - $numIn; } else { if ($calls_io == "Outcoming_Calls") { $numTot_T = $pExtention->ObtainNumExtention($date_ini2, $date_fin2, $ext2, ""); //total todos $numTot = $numTot_T[0]; //$total -> outcoming $numIn = $numTot - $total; $numOut = $total; } else { $numIn_T = $pExtention->ObtainNumExtentionByIOrO($date_ini2, $date_fin2, $ext, 'in'); //$total -> todos $numTot = $total; $numIn = $numIn_T[0]; $numOut = $total - $numIn; } } if ($numIn != 0) { $VALUE = (int) (100 * ($numIn / $numTot)); } else { $VALUE = 0; } $ruta_img = array("?menu={$module_name}&action=grafic&du={$VALUE}%&in={$numIn}&out={$numOut}&ext={$ext2}&tot={$numTot}&rawmode=yes"); } else { if ($option == "Queue") { $smarty->assign("SELECTED_1", ""); $smarty->assign("SELECTED_2", "selected"); $smarty->assign("SELECTED_3", ""); $ruta_img = array("?menu={$module_name}&action=grafic_queue&queue={$ext2}&dti={$date_ini2}&dtf={$date_fin2}&rawmode=yes"); } else { if ($option == "Trunk") { $smarty->assign("SELECTED_1", ""); $smarty->assign("SELECTED_2", ""); $smarty->assign("SELECTED_3", "selected"); $trunkT = getParameter("trunks"); $smarty->assign("trunks", $trunkT); $ruta_img = array("?menu={$module_name}&action=grafic_trunk&trunk={$trunkT}&dti={$date_ini2}&dtf={$date_fin2}&rawmode=yes", "?menu={$module_name}&action=grafic_trunk2&trunk={$trunkT}&dti={$date_ini2}&dtf={$date_fin2}&rawmode=yes"); } else { } } } for ($i = 0; $i < count($ruta_img); $i++) { $ruta_img[$i] = "<img src='" . $ruta_img[$i] . "' border='0'>"; } if (count($ruta_img) > 0 && !$error) { $smarty->assign("ruta_img", "<tr class='letra12'><td align='center'>" . implode(' ', $ruta_img) . '<td></tr>'); } else { $smarty->assign("ruta_img", "<tr class='letra12'><td align='center'><td></tr>"); } $smarty->assign("icon", "modules/{$module_name}/images/reports_graphic_reports.png"); $htmlForm = $oFilterForm->fetchForm("{$local_templates_dir}/filter.tpl", $arrLangModule["Graphic Report"], $_POST); $contenidoModulo = "<form method='POST' style='margin-bottom:0;' action='?menu={$module_name}'>" . $htmlForm . "</form>"; return $contenidoModulo; }