CDR: Search Source explicitly by extension number.

This commit is contained in:
Nate Jones 2014-08-03 04:03:44 +00:00
parent 83a9b8e969
commit 7b648618ad
3 changed files with 125 additions and 35 deletions

View File

@ -68,6 +68,19 @@ else {
echo "}\n";
echo "</script>\n";
//javascript to toggle input/select boxes
echo "<script type='text/javascript'>";
echo " function toggle(field) {";
echo " if (field == 'source') {";
echo " document.getElementById('caller_extension_uuid').selectedIndex = 0;";
echo " document.getElementById('caller_id_number').value = '';";
echo " $('#caller_extension_uuid').toggle();";
echo " $('#caller_id_number').toggle();";
echo " if ($('#caller_id_number').is(':visible')) { $('#caller_id_number').focus(); } else { $('#caller_extension_uuid').focus(); }";
echo " }";
echo " }";
echo "</script>";
//page title and description
echo "<div align='center'>";
echo "<table width='100%' border='0' cellpadding='0' cellspacing='0'>\n";
@ -90,7 +103,9 @@ else {
echo " <input type='hidden' name='start_stamp_begin' value='$start_stamp_begin'>\n";
echo " <input type='hidden' name='start_stamp_end' value='$start_stamp_end'>\n";
echo " <input type='hidden' name='hangup_cause' value='$hangup_cause'>\n";
echo " <input type='hidden' name='caller_extension_uuid' value='$caller_extension_uuid'>\n";
echo " <input type='hidden' name='caller_id_number' value='$caller_id_number'>\n";
echo " <input type='hidden' name='destination_extension_uuid' value='$destination_extension_uuid'>\n";
echo " <input type='hidden' name='destination_number' value='$destination_number'>\n";
echo " <input type='hidden' name='answer_stamp_begin' value='$answer_stamp_begin'>\n";
echo " <input type='hidden' name='answer_stamp_end' value='$answer_stamp_end'>\n";
@ -221,22 +236,46 @@ else {
echo "</td>";
echo "<td width='33%' style='vertical-align: top;'>\n";
// set visibility of Source field(s)
if ($caller_extension_uuid == '' && $caller_id_number != '') {
$style['caller_extension_uuid'] = 'display: none;';
}
else {
$style['caller_id_number'] = 'display: none;';
}
echo "<table width='100%' border='0' cellpadding='6' cellspacing='0'>\n";
echo " <tr>\n";
echo " <td class='vncell' valign='top' nowrap='nowrap' width='30%'>\n";
echo " ".$text['label-source']."\n";
echo " </td>\n";
echo " <td class='vtable' width='70%' align='left'>\n";
echo " <input type='text' class='formfld' name='caller_id_number' value='$caller_id_number'>\n";
echo " <td class='vtable' width='70%' align='left' style='white-space: nowrap;'>\n";
echo " <select class='formfld' style='".$style['caller_extension_uuid']."' name='caller_extension_uuid' id='caller_extension_uuid'>\n";
echo " <option value=''></option>";
$sql = "select extension_uuid, extension, number_alias from v_extensions ";
$sql .= "where domain_uuid = '".$_SESSION['domain_uuid']."' ";
$sql .= "order by ";
$sql .= "extension asc ";
$sql .= ", number_alias asc ";
$prep_statement = $db->prepare(check_sql($sql));
$prep_statement -> execute();
$result_e = $prep_statement -> fetchAll(PDO::FETCH_NAMED);
foreach ($result_e as &$row) {
$selected = ($row['extension_uuid'] == $caller_extension_uuid) ? "selected" : null;
echo " <option value='".$row['extension_uuid']."' ".$selected.">".((is_numeric($row['extension'])) ? $row['extension'] : $row['number_alias']." (".$row['extension'].")")."</option>";
}
unset ($prep_statement);
echo " </select>\n";
echo " <input type='text' class='formfld' style='".$style['caller_id_number']."' name='caller_id_number' id='caller_id_number' value='".$caller_id_number."'>\n";
echo " <input type='button' id='btn_toggle_source' class='btn' name='' alt='".$text['button-back']."' value='<' onclick=\"toggle('source');\">\n";
echo " </td>\n";
echo " </tr>\n";
echo " <tr>\n";
echo " <td class='vncell' valign='top' nowrap='nowrap' width='30%'>\n";
echo " ".$text['label-destination']."\n";
echo " </td>\n";
echo " <td class='vtable' width='70%' align='left'>\n";
echo " <input type='text' class='formfld' name='destination_number' value='$destination_number'>\n";
echo " <td class='vtable' width='70%' align='left' style='white-space: nowrap;'>\n";
echo " <input type='text' class='formfld' name='destination_number' id='destination_number' value='".$destination_number."'>\n";
echo " </td>\n";
echo " </tr>\n";
echo "</table>\n";
@ -250,9 +289,9 @@ else {
echo " ".$text['label-start_range']."\n";
echo " </td>\n";
echo " <td class='vtable' width='70%' align='left' style='white-space: nowrap;'>\n";
echo " <input type='text' class='formfld' style='min-width: 115px;' name='start_stamp_begin' data-calendar=\"{format: '%Y-%m-%d %H:%M', listYears: true, hideOnPick: false, fxName: null, showButtons: true}\" value='$start_stamp_begin'>\n";
echo " <input type='text' class='formfld' style='min-width: 115px; width: 115px;' name='start_stamp_begin' data-calendar=\"{format: '%Y-%m-%d %H:%M', listYears: true, hideOnPick: false, fxName: null, showButtons: true}\" value='$start_stamp_begin'>\n";
echo " > ";
echo " <input type='text' class='formfld' style='min-width: 115px;' name='start_stamp_end' data-calendar=\"{format: '%Y-%m-%d %H:%M', listYears: true, hideOnPick: false, fxName: null, showButtons: true}\" value='$start_stamp_end'>\n";
echo " <input type='text' class='formfld' style='min-width: 115px; width: 115px;' name='start_stamp_end' data-calendar=\"{format: '%Y-%m-%d %H:%M', listYears: true, hideOnPick: false, fxName: null, showButtons: true}\" value='$start_stamp_end'>\n";
echo " </td>\n";
echo " </tr>\n";
echo " <tr>\n";

View File

@ -52,6 +52,7 @@ else {
$direction = check_str($_REQUEST["direction"]);
$caller_id_name = check_str($_REQUEST["caller_id_name"]);
$caller_id_number = check_str($_REQUEST["caller_id_number"]);
$caller_extension_uuid = check_str($_REQUEST["caller_extension_uuid"]);
$destination_number = check_str($_REQUEST["destination_number"]);
$context = check_str($_REQUEST["context"]);
$start_stamp_begin = check_str($_REQUEST["start_stamp_begin"]);
@ -87,6 +88,9 @@ else {
$mod_caller_id_name = str_replace("*", "%", $caller_id_name);
$sql_where_ands[] = "caller_id_name like '".$mod_caller_id_name."'";
}
if (strlen($caller_extension_uuid) > 0) {
$sql_where_ands[] = "extension_uuid = '".$caller_extension_uuid."'";
}
if (strlen($caller_id_number) > 0) {
$mod_caller_id_number = str_replace("*", "%", $caller_id_number);
$sql_where_ands[] = "caller_id_number like '".$mod_caller_id_number."'";

View File

@ -42,29 +42,47 @@ else {
}
require_once "resources/header.php";
//javascript to toggle input/select boxes
echo "<script type='text/javascript'>";
echo " function toggle(field) {";
echo " if (field == 'source') {";
echo " document.getElementById('caller_extension_uuid').selectedIndex = 0;";
echo " document.getElementById('caller_id_number').value = '';";
echo " $('#caller_extension_uuid').toggle();";
echo " $('#caller_id_number').toggle();";
echo " if ($('#caller_id_number').is(':visible')) { $('#caller_id_number').focus(); } else { $('#caller_extension_uuid').focus(); }";
echo " }";
echo " }";
echo "</script>";
echo "<div align='center'>";
echo "<table width='100%' border='0' cellpadding='0' cellspacing='2'>\n";
echo "<tr class='border'>\n";
echo " <td align=\"left\">\n";
echo " <br>";
echo "<form method='post' action='xml_cdr.php'>\n";
echo "<table width='100%' border='0' cellpadding='0' cellspacing='0'>\n";
echo " <tr class='border'>\n";
echo " <td align=\"left\">\n";
echo "<table width='100%' cellpadding='6' cellspacing='0'>\n";
echo "<tr>\n";
echo "<td width='30%' nowrap valign='top'><b>Advanced Search</b></td>\n";
echo "<td width='70%' align='right' valign='top'>";
echo " <input type='button' class='btn' name='' alt='back' onclick=\"window.location='xml_cdr.php'\" value='Back'>";
echo " <input type='submit' name='submit' class='btn' value='Search'>";
echo " <br /><br />";
echo "</td>\n";
echo "</tr>\n";
echo " <tr>\n";
echo " <td class='vncell' valign='top' nowrap='nowrap' width='30%'>\n";
echo " <td width='30%' nowrap valign='top'><b>Advanced Search</b></td>\n";
echo " <td width='70%' align='right' valign='top'>";
echo " <input type='button' class='btn' name='' alt='back' onclick=\"window.location='xml_cdr.php'\" value='Back'>";
echo " <input type='submit' name='submit' class='btn' value='Search'>";
echo " <br /><br />";
echo " </td>\n";
echo " </tr>\n";
echo "</table>\n";
echo "<table cellpadding='0' cellspacing='0' border='0' width='100%'>\n";
echo " <tr>\n";
echo " <td width='50%' style='vertical-align: top;'>\n";
echo "<table width='100%' cellpadding='6' cellspacing='0'>\n";
echo " <tr>\n";
echo " <td width='30%' class='vncell' valign='top' nowrap='nowrap'>\n";
echo " ".$text['label-direction']."\n";
echo " </td>\n";
echo " <td class='vtable' width='70%' align='left'>\n";
echo " <td width='70%' class='vtable' align='left'>\n";
echo " <select name='direction' class='formfld'>\n";
echo " <option value=''></option>\n";
if ($direction == "inbound") {
@ -94,7 +112,26 @@ echo " <td class='vtable'><input type='text' class='formfld' name='caller_id_na
echo " </tr>";
echo " <tr>";
echo " <td class='vncell'>".$text['label-caller_id_number']."</td>"; //source number
echo " <td class='vtable'><input type='text' class='formfld' name='caller_id_number' value='$caller_id_number'></td>";
echo " <td class='vtable'>";
echo " <select class='formfld' name='caller_extension_uuid' id='caller_extension_uuid'>\n";
echo " <option value=''></option>";
$sql = "select extension_uuid, extension, number_alias from v_extensions ";
$sql .= "where domain_uuid = '".$_SESSION['domain_uuid']."' ";
$sql .= "order by ";
$sql .= "extension asc ";
$sql .= ", number_alias asc ";
$prep_statement = $db->prepare(check_sql($sql));
$prep_statement -> execute();
$result_e = $prep_statement -> fetchAll(PDO::FETCH_NAMED);
foreach ($result_e as &$row) {
$selected = ($row['extension_uuid'] == $caller_extension_uuid) ? "selected" : null;
echo " <option value='".$row['extension_uuid']."' ".$selected.">".((is_numeric($row['extension'])) ? $row['extension'] : $row['number_alias']." (".$row['extension'].")")."</option>";
}
unset ($prep_statement);
echo " </select>\n";
echo " <input type='text' class='formfld' style='display: none;' name='caller_id_number' id='caller_id_number' value='".$caller_id_number."'>\n";
echo " <input type='button' id='btn_toggle_source' class='btn' name='' alt='".$text['button-back']."' value='<' onclick=\"toggle('source');\">\n";
echo " </td>";
echo " </tr>";
echo " <tr>";
echo " <td class='vncell'>".$text['label-destination']."</td>";
@ -107,34 +144,40 @@ echo " </tr>";
echo " <tr>";
echo " <td class='vncell'>".$text['label-start_range']."</td>";
echo " <td class='vtable'>";
echo " <input type='text' class='formfld' style='min-width: 115px;' name='start_stamp_begin' data-calendar=\"{format: '%Y-%m-%d %H:%M', listYears: true, hideOnPick: false, fxName: null, showButtons: true}\" value='$start_stamp_begin'>";
echo " <input type='text' class='formfld' style='min-width: 115px; width: 115px;' name='start_stamp_begin' data-calendar=\"{format: '%Y-%m-%d %H:%M', listYears: true, hideOnPick: false, fxName: null, showButtons: true}\" value='$start_stamp_begin'>";
echo " > ";
echo " <input type='text' class='formfld' style='min-width: 115px;' name='start_stamp_end' data-calendar=\"{format: '%Y-%m-%d %H:%M', listYears: true, hideOnPick: false, fxName: null, showButtons: true}\" value='$start_stamp_end'>";
echo " <input type='text' class='formfld' style='min-width: 115px; width: 115px;' name='start_stamp_end' data-calendar=\"{format: '%Y-%m-%d %H:%M', listYears: true, hideOnPick: false, fxName: null, showButtons: true}\" value='$start_stamp_end'>";
echo " </td>";
echo " </tr>";
echo " <tr>";
echo " <td class='vncell'>".$text['label-answer_range']."</td>";
echo " <td class='vtable'>";
echo " <input type='text' class='formfld' style='min-width: 115px;' name='answer_stamp_begin' data-calendar=\"{format: '%Y-%m-%d %H:%M', listYears: true, hideOnPick: false, fxName: null, showButtons: true}\" value='$answer_stamp_begin'>";
echo " <input type='text' class='formfld' style='min-width: 115px; width: 115px;' name='answer_stamp_begin' data-calendar=\"{format: '%Y-%m-%d %H:%M', listYears: true, hideOnPick: false, fxName: null, showButtons: true}\" value='$answer_stamp_begin'>";
echo " > ";
echo " <input type='text' class='formfld' style='min-width: 115px;' name='answer_stamp_end' data-calendar=\"{format: '%Y-%m-%d %H:%M', listYears: true, hideOnPick: false, fxName: null, showButtons: true}\" value='$answer_stamp_end'>";
echo " <input type='text' class='formfld' style='min-width: 115px; width: 115px;' name='answer_stamp_end' data-calendar=\"{format: '%Y-%m-%d %H:%M', listYears: true, hideOnPick: false, fxName: null, showButtons: true}\" value='$answer_stamp_end'>";
echo " </td>";
echo " </tr>";
echo " <tr>";
echo " <td class='vncell'>".$text['label-end_range']."</td>";
echo " <td class='vtable'>";
echo " <input type='text' class='formfld' style='min-width: 115px;' name='end_stamp_begin' data-calendar=\"{format: '%Y-%m-%d %H:%M', listYears: true, hideOnPick: false, fxName: null, showButtons: true}\" value='$end_stamp_begin'>";
echo " <input type='text' class='formfld' style='min-width: 115px; width: 115px;' name='end_stamp_begin' data-calendar=\"{format: '%Y-%m-%d %H:%M', listYears: true, hideOnPick: false, fxName: null, showButtons: true}\" value='$end_stamp_begin'>";
echo " > ";
echo " <input type='text' class='formfld' style='min-width: 115px;' name='end_stamp_end' data-calendar=\"{format: '%Y-%m-%d %H:%M', listYears: true, hideOnPick: false, fxName: null, showButtons: true}\" value='$end_stamp_end'>";
echo " <input type='text' class='formfld' style='min-width: 115px; width: 115px;' name='end_stamp_end' data-calendar=\"{format: '%Y-%m-%d %H:%M', listYears: true, hideOnPick: false, fxName: null, showButtons: true}\" value='$end_stamp_end'>";
echo " </td>";
echo " </tr>";
echo " <tr>";
echo " <td class='vncell'>".$text['label-duration']."</td>";
echo " <td class='vtable'><input type='text' class='formfld' name='duration' value='$duration'></td>";
echo " </tr>";
echo "</table>";
echo " </td>";
echo " <td width='50%' style='vertical-align: top;'>\n";
echo "<table width='100%' cellpadding='6' cellspacing='0'>\n";
echo " <tr>";
echo " <td class='vncell'>".$text['label-billsec']."</td>";
echo " <td class='vtable'><input type='text' class='formfld' name='billsec' value='$billsec'></td>";
echo " <td width='30%' class='vncell'>".$text['label-billsec']."</td>";
echo " <td width='70%' class='vtable'><input type='text' class='formfld' name='billsec' value='$billsec'></td>";
echo " </tr>";
echo " <tr>";
echo " <td class='vncell'>".$text['label-hangup_cause']."</td>";
@ -172,11 +215,15 @@ echo " <tr>";
echo " <td colspan='2' align='right'><input type='submit' name='submit' class='btn' value='".$text['button-search']."'></td>";
echo " </tr>";
echo "</table>";
echo "</form>";
echo " </td>";
echo " </td>";
echo " </tr>";
echo "</table>";
echo " </td>";
echo " </tr>";
echo "</table>";
echo "</form>";
echo "</div>";
require_once "resources/footer.php";