Portions created by the Initial Developer are Copyright (C) 2008-2016 the Initial Developer. All Rights Reserved. Contributor(s): Mark J Crane Luis Daniel Lucio Quiroz */ //includes require_once "root.php"; require_once "resources/require.php"; //permisisions require_once "resources/check_auth.php"; if (permission_exists('xml_cdr_view')) { //access granted } else { echo "access denied"; exit; } //add multi-lingual support $language = new text; $text = $language->get(); //additional includes require_once "resources/header.php"; //retrieve submitted data $quick_select = check_str($_REQUEST['quick_select']); $start_stamp_begin = check_str($_REQUEST['start_stamp_begin']); $start_stamp_end = check_str($_REQUEST['start_stamp_end']); $include_internal = check_str($_REQUEST['include_internal']); $quick_select = (sizeof($_REQUEST) == 0) ? 3 : $quick_select; //set default //get the summary $cdr = new xml_cdr; $cdr->domain_uuid = $_SESSION['domain_uuid']; $cdr->quick_select = $quick_select; $cdr->start_stamp_begin = $start_stamp_begin; $cdr->start_stamp_end = $start_stamp_end; $cdr->include_internal = $include_internal; $summary = $cdr->user_summary(); //set the http header if ($_REQUEST['type'] == "csv") { //set the headers header('Content-type: application/octet-binary'); header('Content-Disposition: attachment; filename=user-summary.csv'); //show the column names on the first line $z = 0; foreach($summary[1] as $key => $val) { if ($z == 0) { echo '"'.$key.'"'; } else { echo ',"'.$key.'"'; } $z++; } echo "\n"; //add the values to the csv $x = 0; foreach($summary as $users) { $z = 0; foreach($users as $key => $val) { if ($z == 0) { echo '"'.$summary[$x][$key].'"'; } else { echo ',"'.$summary[$x][$key].'"'; } $z++; } echo "\n"; $x++; } exit; } //page title and description echo "\n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo "
\n"; echo " ".$text['title-extension_summary']."

\n"; echo "
"; echo " 0) { echo $_SERVER["QUERY_STRING"]."&type=csv';\">\n"; } else { echo "type=csv';\">\n"; } if (permission_exists('xml_cdr_all') && $_GET['showall'] != 'true') { echo " \n"; } echo "
\n"; echo "
\n"; if (permission_exists('xml_cdr_search')) { echo "
\n"; echo "\n"; echo " \n"; echo " "; echo " "; echo " "; echo " "; echo " "; echo " "; echo " "; echo " "; echo "
\n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo "
\n"; echo " ".$text['label-preset']."\n"; echo " \n"; echo " \n"; echo "
\n"; echo "
\n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo "
\n"; echo " ".$text['label-start_date_time']."\n"; echo " \n"; echo " \n"; echo "
\n"; echo "
\n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo "
\n"; echo " ".$text['label-end_date_time']."\n"; echo " \n"; echo " \n"; echo "
\n"; echo "
\n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo "
\n"; echo " ".$text['label-include_internal']."\n"; echo " \n"; echo " \n"; echo "
\n"; echo "
"; echo " \n"; echo " \n"; echo "
"; echo "
"; echo "

"; } //show the results echo "\n"; echo " \n"; if ($_GET['showall'] && permission_exists('xml_cdr_all')) { echo " \n"; } echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; $c = 0; $row_style["0"] = "row_style0"; $row_style["1"] = "row_style1"; if (isset($summary)) foreach ($summary as $key => $row) { $tr_link = "xhref='xml_cdr.php?'"; echo "\n"; if ($_GET['showall'] && permission_exists('xml_cdr_all')) { echo " \n"; } echo " \n"; echo " \n"; //echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo "\n"; $c = ($c==0) ? 1 : 0; } echo "
".$text['label-domain']."".$text['label-extension']."".$text['label-number_alias']."".$text['label-missed']."".$text['label-no_answer']."".$text['label-busy']."".$text['label-aloc']."".$text['label-inbound_calls']."".$text['label-inbound_duration']."".$text['label-outbound_calls']."".$text['label-outbound_duration']."".$text['label-description']."
".$row['domain_name']."".$row['extension']."".$row['number_alias']." ".$row['answered']." ".$row['missed']." ".$row['no_answer']." ".$row['busy']." ".gmdate("H:i:s",$row['aloc'])."  ". $row['inbound_calls'] ."".(($row['inbound_duration'] != '0') ? gmdate("G:i:s", $row['inbound_duration']) : '0:00:00')." ".(($row['outbound_calls'] != '') ? $row['outbound_calls'] : "0")."".(($row['outbound_duration'] != '') ? gmdate("G:i:s", $row['outbound_duration']) : '0:00:00')."".$row['description']." 
"; echo "

"; //show the footer require_once "resources/footer.php"; ?>