any body here know how to round up minute in elastix report billing?
like call duration is 1:32min convert to 2min.
every sec exceed from minute will calculate as 1min.
anywhere to edit?
Moderator: jubjang
if($cdr[8] <= 60)
$time = $cdr[8].'s';
else{
$timeToSecond = secondsToTime($cdr[8]);
$time = $cdr[8].'s '.$timeToSecond;
}
if($cdr[8] <= 0) {
$time = $cdr[8].' '.'m';
} elseif (($cdr[8] >= 1) && ($cdr[8] <= 60)) {
$time = '1'.' '.'m';
} else {
$timeToSecond = secondsToTime_2($cdr[8]);
$time = $timeToSecond.' '.'m';
}
function secondsToTime_2($time){
$decimalMinutes = $time/60;
$minutes = floor($decimalMinutes);
$decimalSeconds = $decimalMinutes - $minutes;
$seconds = $decimalSeconds*60;
if ($seconds == 0) {
$minutes = $minutes;
} elseif (($seconds > 0) && ($seconds <= 60)) {
$minutes = $minutes+1;
}
return $minutes;
}
/* vim: set expandtab tabstop=4 softtabstop=4 shiftwidth=4:
Codificación: UTF-8
+----------------------------------------------------------------------+
| Elastix version 0.5 |
| http://www.elastix.org |
+----------------------------------------------------------------------+
| Copyright (c) 2006 Palosanto Solutions S. A. |
+----------------------------------------------------------------------+
| Cdla. Nueva Kennedy Calle E 222 y 9na. Este |
| Telfs. 2283-268, 2294-440, 2284-356 |
| Guayaquil - Ecuador |
| http://www.palosanto.com |
+----------------------------------------------------------------------+
| The contents of this file are subject to the General Public License |
| (GPL) Version 2 (the "License"); you may not use this file except in |
| compliance with the License. You may obtain a copy of the License at |
| http://www.opensource.org/licenses/gpl-license.php |
| |
| Software distributed under the License is distributed on an "AS IS" |
| basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See |
| the License for the specific language governing rights and |
| limitations under the License. |
+----------------------------------------------------------------------+
| The Original Code is: Elastix Open Source. |
| The Initial Developer of the Original Code is PaloSanto Solutions |
+----------------------------------------------------------------------+
$Id: index.php,v 1.1.1.1 2007/07/06 21:31:21 gcarrillo Exp $ */
include_once "libs/paloSantoGrid.class.php";
include_once "libs/paloSantoDB.class.php";
include_once "libs/paloSantoForm.class.php";
include_once "libs/paloSantoConfig.class.php";
include_once "libs/paloSantoCDR.class.php";
require_once "libs/misc.lib.php";
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);
// 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)');
$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";
}
// 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']);
// Cadenas estáticas en la plantilla
$smarty->assign(array(
"Filter" => _tr("Filter"),
"Delete" => _tr("Delete"),
"Delete_Warning" => _tr("Are you sure you wish to delete CDR(s) Report(s)?"),
));
$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 (isset($_GET[$k])) $paramFiltro[$k] = $_GET[$k];
if (isset($_POST[$k])) $paramFiltro[$k] = $_POST[$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;
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($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"),
));
}
}
// Generación del reporte
$oGrid = new paloSantoGrid($smarty);
$oGrid->setTitle(_tr("CDR Report"));
$oGrid->pagingShow(true); // show paging section.
$oGrid->enableExport(); // enable export.
$oGrid->setNameFile_Export(_tr("CDRReport"));
$oGrid->setURL($url);
$arrData = null;
$total = $oCDR->contarCDRs($paramFiltro);
if($oGrid->isExportAction()){
$limit = $total;
$offset = 0;
$arrColumns = array(_tr("Date"), _tr("Source"), _tr("Ring Group"), _tr("Destination"), _tr("Src. Channel"),_tr("Account Code"),_tr("Dst. Channel"),_tr("Status"),_tr("Duration"));
$oGrid->setColumns($arrColumns);
$arrResult = $oCDR->listarCDRs($paramFiltro, $limit, $offset);
if(is_array($arrResult['cdrs']) && $total>0){
foreach($arrResult['cdrs'] as $key => $value){
$arrTmp[0] = $value[0];
$arrTmp[1] = $value[1];
$arrTmp[2] = $value[11];
$arrTmp[3] = $value[2];
$arrTmp[4] = $value[3];
$arrTmp[5] = $value[9];
$arrTmp[6] = $value[4];
$arrTmp[7] = $value[5];
$iDuracion = $value[8];
$iSec = $iDuracion % 60; $iDuracion = (int)(($iDuracion - $iSec) / 60);
$iMin = $iDuracion % 60; $iDuracion = (int)(($iDuracion - $iMin) / 60);
$sTiempo = "{$value[8]}s";
if ($value[8] >= 60) {
if ($iDuracion > 0) $sTiempo .= " ({$iDuracion}h {$iMin}m {$iSec}s)";
elseif ($iMin > 0) $sTiempo .= " ({$iMin}m {$iSec}s)";
}
$arrTmp[8] = $sTiempo;
$arrData[] = $arrTmp;
}
}
if (!is_array($arrResult)) {
$smarty->assign(array(
'mb_title' => _tr('ERROR'),
'mb_message' => $oCDR->errMsg,
));
}
}else {
$limit = 20;
$oGrid->setLimit($limit);
$oGrid->setTotal($total);
$offset = $oGrid->calculateOffset();
$arrResult = $oCDR->listarCDRs($paramFiltro, $limit, $offset);
$arrColumns = array(_tr("Date"), _tr("Source"), _tr("Ring Group"), _tr("Destination"), _tr("Src. Channel"),_tr("Account Code"),_tr("Dst. Channel"),_tr("Status"),_tr("Duration"));
$oGrid->setColumns($arrColumns);
if(is_array($arrResult['cdrs']) && $total>0){
foreach($arrResult['cdrs'] as $key => $value){
$arrTmp[0] = $value[0];
$arrTmp[1] = $value[1];
$arrTmp[2] = $value[11];
$arrTmp[3] = $value[2];
$arrTmp[4] = $value[3];
$arrTmp[5] = $value[9];
$arrTmp[6] = $value[4];
$arrTmp[7] = $value[5];
$iDuracion = $value[8];
$iSec = $iDuracion % 60; $iDuracion = (int)(($iDuracion - $iSec) / 60);
$iMin = $iDuracion % 60; $iDuracion = (int)(($iDuracion - $iMin) / 60);
$sTiempo = "{$value[8]}s";
if ($value[8] >= 60) {
if ($iDuracion > 0) $sTiempo .= " ({$iDuracion}h {$iMin}m {$iSec}s)";
elseif ($iMin > 0) $sTiempo .= " ({$iMin}m {$iSec}s)";
}
$arrTmp[8] = $sTiempo;
$arrData[] = $arrTmp;
}
}
if (!is_array($arrResult)) {
$smarty->assign(array(
'mb_title' => _tr('ERROR'),
'mb_message' => $oCDR->errMsg,
));
}
}
$oGrid->setData($arrData);
$smarty->assign("SHOW", _tr("Show"));
$oGrid->showFilter($htmlFilter);
$content = $oGrid->fetchGrid();
return $content;
}
?>
[root@elastix-a ~]# rpm -qa | grep elastix
elastix-firstboot-2.0.0-14
elastix-email_admin-2.0.0-23
elastix-2.0.0-62
elastix-asterisk-sounds-1.2.3-1
elastix-vtigercrm-5.1.0-8
elastix-agenda-2.0.0-24
elastix-fax-2.0.0-18
elastix-reports-2.0.0-20
elastix-pbx-2.0.0-44
elastix-a2billing-1.3.0-4
elastix-addons-2.0.0-19
elastix-system-2.0.0-40
<?php
/* vim: set expandtab tabstop=4 softtabstop=4 shiftwidth=4:
Codificación: UTF-8
+----------------------------------------------------------------------+
| Elastix version 0.5 |
| http://www.elastix.org |
+----------------------------------------------------------------------+
| Copyright (c) 2006 Palosanto Solutions S. A. |
+----------------------------------------------------------------------+
| Cdla. Nueva Kennedy Calle E 222 y 9na. Este |
| Telfs. 2283-268, 2294-440, 2284-356 |
| Guayaquil - Ecuador |
| http://www.palosanto.com |
+----------------------------------------------------------------------+
| The contents of this file are subject to the General Public License |
| (GPL) Version 2 (the "License"); you may not use this file except in |
| compliance with the License. You may obtain a copy of the License at |
| http://www.opensource.org/licenses/gpl-license.php |
| |
| Software distributed under the License is distributed on an "AS IS" |
| basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See |
| the License for the specific language governing rights and |
| limitations under the License. |
+----------------------------------------------------------------------+
| The Original Code is: Elastix Open Source. |
| The Initial Developer of the Original Code is PaloSanto Solutions |
+----------------------------------------------------------------------+
$Id: index.php,v 1.1.1.1 2007/07/06 21:31:21 gcarrillo Exp $ */
function _moduleContent(&$smarty, $module_name)
{
include_once "libs/paloSantoGrid.class.php";
include_once "libs/paloSantoDB.class.php";
include_once "libs/paloSantoForm.class.php";
include_once "libs/paloSantoConfig.class.php";
include_once "libs/paloSantoCDR.class.php";
require_once "libs/misc.lib.php";
//include module files
include_once "modules/$module_name/configs/default.conf.php";
$lang=get_language();
$base_dir=dirname($_SERVER['SCRIPT_FILENAME']);
$lang_file="modules/$module_name/lang/$lang.lang";
if (file_exists("$base_dir/$lang_file")) include_once "$lang_file";
else include_once "modules/$module_name/lang/en.lang";
//global variables
global $arrConf;
global $arrConfModule;
global $arrLang;
global $arrLangModule;
$arrConf = array_merge($arrConf,$arrConfModule);
$arrLang = array_merge($arrLang,$arrLangModule);
//folder path for custom templates
$base_dir=dirname($_SERVER['SCRIPT_FILENAME']);
$templates_dir=(isset($arrConf['templates_dir']))?$arrConf['templates_dir']:'themes';
$local_templates_dir="$base_dir/modules/$module_name/".$templates_dir.'/'.$arrConf['theme'];
$pConfig = new paloConfig("/etc", "amportal.conf", "=", "[[:space:]]*=[[:space:]]*");
$arrConfAM = $pConfig->leer_configuracion(false);
$dsn = $arrConfAM['AMPDBENGINE']['valor'] . "://" . $arrConfAM['AMPDBUSER']['valor'] . ":" . $arrConfAM['AMPDBPASS']['valor'] . "@" .
$arrConfAM['AMPDBHOST']['valor'] . "/asteriskcdrdb";
// TODO: validar que conexión se realiza correctamente
$pDB = new paloDB($dsn);
$arrData = array();
$oCDR = new paloSantoCDR($pDB);
$pDBACL = new paloDB($arrConf['elastix_dsn']['acl']);
if (!empty($pDBACL->errMsg)) {
echo "ERROR DE DB: $pDBACL->errMsg <br>";
}
$pACL = new paloACL($pDBACL);
if (!empty($pACL->errMsg)) {
echo "ERROR DE ACL: $pACL->errMsg <br>";
}
$extension = $pACL->getUserExtension($_SESSION['elastix_user']);
$esAdministrador = $pACL->isUserAdministratorGroup($_SESSION['elastix_user']);
if($esAdministrador)
$extension = "";
$smarty->assign("menu","cdrreport");
$smarty->assign("Filter",$arrLang['Filter']);
$smarty->assign("Delete",$arrLang['Delete']);
$smarty->assign("Delete_Warning",$arrLang['Are you sure you wish to delete CDR(s) Report(s)?']);
if(isset($_GET['exportcsv']) && $_GET['exportcsv']=='yes') {
$limit = "";
$offset = 0;
if(empty($_GET['date_start'])) {
$date_start = date("Y-m-d") . " 00:00:00";
} else {
$date_start = translateDate($_GET['date_start']) . " 00:00:00";
}
if(empty($_GET['date_end'])) {
$date_end = date("Y-m-d") . " 23:59:59";
} else {
$date_end = translateDate($_GET['date_end']) . " 23:59:59";
}
$field_name = $_GET['field_name'];
$field_pattern = $_GET['field_pattern'];
$status = $_GET['status'];
header("Cache-Control: private");
header("Pragma: cache");
header('Content-Type: application/octec-stream');
//header('Content-Length: '.strlen($this->buffer));
header('Content-disposition: inline; filename="cdrreport.csv"');
header('Content-Type: application/force-download');
//header('Content-Length: '.strlen($this->buffer));
//header('Content-disposition: attachment; filename="'.$name.'"');
} else{
$arrFormElements = array("date_start" => array("LABEL" => $arrLang["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" => $arrLang["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" => $arrLang["Field Name"],
"REQUIRED" => "no",
"INPUT_TYPE" => "SELECT",
"INPUT_EXTRA_PARAM" => array( "dst" => $arrLang["Destination"],
"src" => $arrLang["Source"],
"channel" => $arrLang["Src. Channel"],
"accountcode" => $arrLang["Account Code"],
"dstchannel" => $arrLang["Dst. Channel"]),
"VALIDATION_TYPE" => "ereg",
"VALIDATION_EXTRA_PARAM" => "^(dst|src|channel|dstchannel|accountcode)$"),
"field_pattern" => array("LABEL" => $arrLang["Field"],
"REQUIRED" => "no",
"INPUT_TYPE" => "TEXT",
"INPUT_EXTRA_PARAM" => "",
"VALIDATION_TYPE" => "ereg",
"VALIDATION_EXTRA_PARAM" => "^[\*|[:alnum:]@_\.,/\-]+$"),
"status" => array("LABEL" => $arrLang["Status"],
"REQUIRED" => "no",
"INPUT_TYPE" => "SELECT",
"INPUT_EXTRA_PARAM" => array(
"ALL" => $arrLang["ALL"],
"ANSWERED" => $arrLang["ANSWERED"],
"BUSY" => $arrLang["BUSY"],
"FAILED" => $arrLang["FAILED"],
"NO ANSWER " => $arrLang["NO ANSWER"]),
"VALIDATION_TYPE" => "text",
"VALIDATION_EXTRA_PARAM" => ""),
);
$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";
$field_name = "";
$field_pattern = "";
$status = "ALL";
if(isset($_POST['delete']) || 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";
$field_name = $_POST['field_name'];
$field_pattern = $_POST['field_pattern'];
$status = $_POST['status'];
$arrFilterExtraVars = array("date_start" => $_POST['date_start'], "date_end" => $_POST['date_end'],
"field_name" => $_POST['field_name'], "field_pattern" => $_POST['field_pattern'],"status" => $_POST['status']);
if(isset($_POST['delete']))
$oCDR->Delete_All_CDRs($date_start, $date_end, $field_name, $field_pattern, $status);
} else {
// Error
$smarty->assign("mb_title", $arrLang["Validation Error"]);
$arrErrores=$oFilterForm->arrErroresValidacion;
$strErrorMsg = "<b>{$arrLang['The following fields contain errors']}:</b><br>";
foreach($arrErrores as $k=>$v) {
$strErrorMsg .= "$k, ";
}
$strErrorMsg .= "";
$smarty->assign("mb_message", $strErrorMsg);
}
$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";
$field_name = $_GET['field_name'];
$field_pattern = $_GET['field_pattern'];
$status = $_GET['status'];
$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' => 'dst','field_pattern' => '','status' => 'ALL' ));
}
// LISTADO
$limit = 50;
$offset = 0;
// Si se quiere avanzar a la sgte. pagina
if(isset($_GET['nav']) && $_GET['nav']=="end") {
$arrCDRTmp = $oCDR->obtenerCDRs($limit, $offset, $date_start, $date_end, $field_name, $field_pattern,$status, "", NULL, $extension);
$totalCDRs = $arrCDRTmp['NumRecords'][0];
// Mejorar el sgte. bloque.
if(($totalCDRs%$limit)==0) {
$offset = $totalCDRs - $limit;
} else {
$offset = $totalCDRs - $totalCDRs%$limit;
}
}
// Si se quiere avanzar a la sgte. pagina
if(isset($_GET['nav']) && $_GET['nav']=="next") {
$offset = $_GET['start'] + $limit - 1;
}
// Si se quiere retroceder
if(isset($_GET['nav']) && $_GET['nav']=="previous") {
$offset = $_GET['start'] - $limit - 1;
}
// Construyo el URL base
if(isset($arrFilterExtraVars) && is_array($arrFilterExtraVars) && count($arrFilterExtraVars)>0) {
$url = $arrFilterExtraVars;
} else {
$url = array();
}
}
// Bloque comun
$arrCDR = $oCDR->obtenerCDRs($limit, $offset, $date_start, $date_end, $field_name, $field_pattern,$status, "", NULL, $extension);
$total = $arrCDR['NumRecords'][0];
$arrData = array();
if(isset($arrCDR['Data']) && is_array($arrCDR['Data']))
{
foreach($arrCDR['Data'] as $cdr) {
$time = "";
$arrTmp = array();
$arrTmp[0] = $cdr[0];
$arrTmp[1] = $cdr[1];
$arrTmp[2] = $cdr[2];
$arrTmp[3] = $cdr[3];
$arrTmp[4] = $cdr[9];
$arrTmp[5] = $cdr[4];
$arrTmp[6] = $cdr[5];
// $arrTmp[6] = $cdr[7];
if($cdr[8] <= 0) {
//$time = $cdr[8].'s';
$time = $cdr[8].' '.'m';
} elseif (($cdr[8] >= 1) && ($cdr[8] <= 60)) {
//$time = '60'.'s';
$time = '1'.' '.'m';
} else {
$timeToSecond = secondsToTime_2($cdr[8]);
//$time = $cdr[8].'s '.$timeToSecond;
$time = $timeToSecond.' '.'m';
}
//if($cdr[8] <= 60)
// $time = $cdr[8].'s';
//else{
// $timeToSecond = secondsToTime($cdr[8]);
// $time = $cdr[8].'s '.$timeToSecond;
//}
$arrTmp[7] = $time;
$arrData[] = $arrTmp;
}
}
$arrGrid = array("title" => $arrLang["CDR Report List"],
"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" => $arrLang["Date"],
"property1" => ""),
1 => array("name" => $arrLang["Source"],
"property1" => ""),
2 => array("name" => $arrLang["Destination"],
"property1" => ""),
3 => array("name" => $arrLang["Src. Channel"],
"property" => ""),
4 => array("name" => $arrLang["Account Code"],
"property" => ""),
5 => array("name" => $arrLang["Dst. Channel"],
"property" => ""),
6 => array("name" => $arrLang["Status"],
"property" => ""),
7 => array("name" => $arrLang["Duration"],
"property" => ""),
)
);
// Creo objeto de grid
$oGrid = new paloSantoGrid($smarty);
$oGrid->enableExport();
if(isset($_GET['exportcsv']) && $_GET['exportcsv']=='yes') {
return $oGrid->fetchGridCSV($arrGrid, $arrData);
} else {
$oGrid->showFilter($htmlFilter);
return $oGrid->fetchGrid($arrGrid, $arrData,$arrLang);
}
}
function secondsToTime($time){
if($time >= 3600){
$decimalHours = $time/3600;
$hours = floor($decimalHours);
$decimalMinutes = $decimalHours - $hours;
$minutesTotal = $decimalMinutes*60;
$minutes = floor($minutesTotal);
$decimalSeconds = $minutesTotal - $minutes;
$seconds = $decimalSeconds*60;
return "( ".$hours."h ".$minutes."m ".$seconds."s )";
}
else{
$decimalMinutes = $time/60;
$minutes = floor($decimalMinutes);
$decimalSeconds = $decimalMinutes - $minutes;
$seconds = $decimalSeconds*60;
return "( ".$minutes."m ".$seconds."s )";
}
}
function secondsToTime_2($time){
//if($time >= 3600){
// $decimalHours = $time/3600;
// $hours = floor($decimalHours);
// $decimalMinutes = $decimalHours - $hours;
// $minutesTotal = $decimalMinutes*60;
// $minutes = floor($minutesTotal);
// $decimalSeconds = $minutesTotal - $minutes;
// $seconds = $decimalSeconds*60;
// return "( ".$hours."h ".$minutes."m ".$seconds."s )";
//}
//else{
$decimalMinutes = $time/60;
$minutes = floor($decimalMinutes);
$decimalSeconds = $decimalMinutes - $minutes;
$seconds = $decimalSeconds*60;
if ($seconds == 0) {
$minutes = $minutes;
} elseif (($seconds > 0) && ($seconds <= 60)) {
$minutes = $minutes+1;
//return "( ".$minutes."m)";
}
return $minutes;
//return "( ".$minutes."m ".$seconds."s )";
//}
}
?>
if ($iSec > 0)
$TMin = $iMin + 1;
else $TMin = $iMin;
$charge=(($TMin)*$rate_value)+$rate_offset;
ย้อนกลับไปยัง Elastix - Unified Communications Software
กำลังดูบอร์ดนี้: ไม่มีสมาชิกใหม่ และ บุคคลทั่วไป 8 ท่าน