| 1 |
<?php |
|---|
| 2 |
|
|---|
| 3 |
|
|---|
| 4 |
|
|---|
| 5 |
|
|---|
| 6 |
|
|---|
| 7 |
|
|---|
| 8 |
|
|---|
| 9 |
|
|---|
| 10 |
|
|---|
| 11 |
|
|---|
| 12 |
|
|---|
| 13 |
|
|---|
| 14 |
|
|---|
| 15 |
|
|---|
| 16 |
|
|---|
| 17 |
|
|---|
| 18 |
|
|---|
| 19 |
|
|---|
| 20 |
|
|---|
| 21 |
|
|---|
| 22 |
if (!defined('FREEPBX_IS_AUTH')) { die('No direct script access allowed'); } |
|---|
| 23 |
|
|---|
| 24 |
|
|---|
| 25 |
include_once("crypt.php"); |
|---|
| 26 |
switch ($action) { |
|---|
| 27 |
case 'cdr_play': |
|---|
| 28 |
case 'cdr_audio': |
|---|
| 29 |
include_once("$action.php"); |
|---|
| 30 |
exit; |
|---|
| 31 |
break; |
|---|
| 32 |
default: |
|---|
| 33 |
break; |
|---|
| 34 |
} |
|---|
| 35 |
|
|---|
| 36 |
global $amp_conf; |
|---|
| 37 |
|
|---|
| 38 |
$REC_CRYPT_PASSWORD = (isset($amp_conf['AMPPLAYKEY']) && trim($amp_conf['AMPPLAYKEY']) != "")?trim($amp_conf['AMPPLAYKEY']):'TheWindCriesMary'; |
|---|
| 39 |
$dispnum = "cdr"; |
|---|
| 40 |
$db_result_limit = 100; |
|---|
| 41 |
|
|---|
| 42 |
|
|---|
| 43 |
$db_name = !empty($amp_conf['CDRDBNAME'])?$amp_conf['CDRDBNAME']:"asteriskcdrdb"; |
|---|
| 44 |
$db_table_name = !empty($amp_conf['CDRDBTABLENAME'])?$amp_conf['CDRDBTABLENAME']:"cdr"; |
|---|
| 45 |
$system_monitor_dir = isset($amp_conf['ASTSPOOLDIR'])?$amp_conf['ASTSPOOLDIR']."/monitor":"/var/spool/asterisk/monitor"; |
|---|
| 46 |
|
|---|
| 47 |
|
|---|
| 48 |
|
|---|
| 49 |
if (!empty($amp_conf["CDRDBHOST"]) && !empty($amp_conf["CDRDBTYPE"])) { |
|---|
| 50 |
$db_hash = array('mysql' => 'mysql', 'postgres' => 'pgsql'); |
|---|
| 51 |
$db_type = $db_hash[$amp_conf["CDRDBTYPE"]]; |
|---|
| 52 |
$db_host = $amp_conf["CDRDBHOST"]; |
|---|
| 53 |
$db_port = empty($amp_conf["CDRDBPORT"]) ? '' : ':' . $amp_conf["CDRDBPORT"]; |
|---|
| 54 |
$db_user = empty($amp_conf["CDRDBUSER"]) ? $amp_conf["AMPDBUSER"] : $amp_conf["CDRDBUSER"]; |
|---|
| 55 |
$db_pass = empty($amp_conf["CDRDBPASS"]) ? $amp_conf["AMPDBPASS"] : $amp_conf["CDRDBPASS"]; |
|---|
| 56 |
$datasource = $db_type . '://' . $db_user . ':' . $db_pass . '@' . $db_host . $db_port . '/' . $db_name; |
|---|
| 57 |
$dbcdr = DB::connect($datasource); |
|---|
| 58 |
if(DB::isError($dbcdr)) { |
|---|
| 59 |
die_freepbx($dbcdr->getDebugInfo()); |
|---|
| 60 |
} |
|---|
| 61 |
} else { |
|---|
| 62 |
$dbcdr = $db; |
|---|
| 63 |
} |
|---|
| 64 |
|
|---|
| 65 |
$h_step = 30; |
|---|
| 66 |
?> |
|---|
| 67 |
<h3><?php echo _('CDR Reports'); ?></h3><hr> |
|---|
| 68 |
<div id="maincdr"> |
|---|
| 69 |
<table class="cdr"> |
|---|
| 70 |
<tr><td> |
|---|
| 71 |
<form method="post" enctype="application/x-www-form-urlencoded"> |
|---|
| 72 |
<fieldset> |
|---|
| 73 |
<legend class="title"><?php echo _("Call Detail Record Search")?></legend> |
|---|
| 74 |
<table width="100%"> |
|---|
| 75 |
<tr> |
|---|
| 76 |
<th><?php echo _("Order By")?></th> |
|---|
| 77 |
<th><?php echo _("Search conditions")?></th> |
|---|
| 78 |
<th> </th> |
|---|
| 79 |
</tr> |
|---|
| 80 |
<tr> |
|---|
| 81 |
<?php $calldate_tooltip = _("Select time span for your report. You can select Date, Month, Year, Hour and Minute to narrow your search");?> |
|---|
| 82 |
<td><input <?php if (empty($_POST['order']) || $_POST['order'] == 'calldate') { echo 'checked="checked"'; } ?> type="radio" name="order" value="calldate" /> <?php echo "<a href=\"#\" class=\"info\">"._("Call Date")."<span>".$calldate_tooltip."</span></a>"?>:</td> |
|---|
| 83 |
<td><?php echo _("From")?>: |
|---|
| 84 |
<input type="text" name="startday" id="startday" size="2" maxlength="2" value="<?php if (isset($_POST['startday'])) { echo htmlspecialchars($_POST['startday']); } else { echo '01'; } ?>" /> |
|---|
| 85 |
<select name="startmonth" id="startmonth"> |
|---|
| 86 |
<?php |
|---|
| 87 |
$months = array('01' => _('January'), '02' => _('February'), '03' => _('March'), '04' => _('April'), '05' => _('May'), '06' => _('June'), '07' => _('July'), '08' => _('August'), '09' => _('September'), '10' => _('October'), '11' => _('November'), '12' => _('December')); |
|---|
| 88 |
foreach ($months as $i => $month) { |
|---|
| 89 |
if ((empty($_POST['startmonth']) && date('m') == $i) || (isset($_POST['startmonth']) && $_POST['startmonth'] == $i)) { |
|---|
| 90 |
echo "<option value=\"$i\" selected=\"selected\">$month</option>\n"; |
|---|
| 91 |
} else { |
|---|
| 92 |
echo "<option value=\"$i\">$month</option>\n"; |
|---|
| 93 |
} |
|---|
| 94 |
} |
|---|
| 95 |
?> |
|---|
| 96 |
</select> |
|---|
| 97 |
<select name="startyear" id="startyear"> |
|---|
| 98 |
<?php |
|---|
| 99 |
for ( $i = 2000; $i <= date('Y'); $i++) { |
|---|
| 100 |
if ((empty($_POST['startyear']) && date('Y') == $i) || (isset($_POST['startyear']) && $_POST['startyear'] == $i)) { |
|---|
| 101 |
echo "<option value=\"$i\" selected=\"selected\">$i</option>\n"; |
|---|
| 102 |
} else { |
|---|
| 103 |
echo "<option value=\"$i\">$i</option>\n"; |
|---|
| 104 |
} |
|---|
| 105 |
} |
|---|
| 106 |
?> |
|---|
| 107 |
</select> |
|---|
| 108 |
<input type="text" name="starthour" id="starthour" size="2" maxlength="2" value="<?php if (isset($_POST['starthour'])) { echo htmlspecialchars($_POST['starthour']); } else { echo '00'; } ?>" />: |
|---|
| 109 |
<input type="text" name="startmin" id="startmin" size="2" maxlength="2" value="<?php if (isset($_POST['startmin'])) { echo htmlspecialchars($_POST['startmin']); } else { echo '00'; } ?>" /><?php echo _("To")?>: |
|---|
| 110 |
<input type="text" name="endday" id="endday" size="2" maxlength="2" value="<?php if (isset($_POST['endday'])) { echo htmlspecialchars($_POST['endday']); } else { echo '31'; } ?>" /> |
|---|
| 111 |
<select name="endmonth" id="endmonth"> |
|---|
| 112 |
<?php |
|---|
| 113 |
foreach ($months as $i => $month) { |
|---|
| 114 |
if ((empty($_POST['endmonth']) && date('m') == $i) || (isset($_POST['endmonth']) && $_POST['endmonth'] == $i)) { |
|---|
| 115 |
echo "<option value=\"$i\" selected=\"selected\">$month</option>\n"; |
|---|
| 116 |
} else { |
|---|
| 117 |
echo "<option value=\"$i\">$month</option>\n"; |
|---|
| 118 |
} |
|---|
| 119 |
} |
|---|
| 120 |
?> |
|---|
| 121 |
</select> |
|---|
| 122 |
<select name="endyear" id="endyear"> |
|---|
| 123 |
<?php |
|---|
| 124 |
for ( $i = 2000; $i <= date('Y'); $i++) { |
|---|
| 125 |
if ((empty($_POST['endyear']) && date('Y') == $i) || (isset($_POST['endyear']) && $_POST['endyear'] == $i)) { |
|---|
| 126 |
echo " <option value=\"$i\" selected=\"selected\">$i</option>\n"; |
|---|
| 127 |
} else { |
|---|
| 128 |
echo " <option value=\"$i\">$i</option>\n"; |
|---|
| 129 |
} |
|---|
| 130 |
} |
|---|
| 131 |
?> |
|---|
| 132 |
</select> |
|---|
| 133 |
<input type="text" name="endhour" id="endhour" size="2" maxlength="2" value="<?php if (isset($_POST['endhour'])) { echo htmlspecialchars($_POST['endhour']); } else { echo '23'; } ?>" />: |
|---|
| 134 |
<input type="text" name="endmin" id="endmin" size="2" maxlength="2" value="<?php if (isset($_POST['endmin'])) { echo htmlspecialchars($_POST['endmin']); } else { echo '59'; } ?>" /> |
|---|
| 135 |
</td> |
|---|
| 136 |
<td rowspan="10" valign='top' align='right'> |
|---|
| 137 |
<fieldset> |
|---|
| 138 |
<legend class="title"><?php echo _("Extra options")?></legend> |
|---|
| 139 |
<table> |
|---|
| 140 |
<tr> |
|---|
| 141 |
<td><?php echo _("Report type")?> : </td> |
|---|
| 142 |
<td> |
|---|
| 143 |
<input <?php if ( (empty($_POST['need_html']) && empty($_POST['need_chart']) && empty($_POST['need_chart_cc']) && empty($_POST['need_csv'])) || ( ! empty($_POST['need_html']) && $_POST['need_html'] == 'true' ) ) { echo 'checked="checked"'; } ?> type="checkbox" name="need_html" value="true" /> : <?php echo _("CDR search")?><br /> |
|---|
| 144 |
<input <?php if ( ! empty($_POST['need_csv']) && $_POST['need_csv'] == 'true' ) { echo 'checked="checked"'; } ?> type="checkbox" name="need_csv" value="true" /> : <?php echo _("CSV file")?><br/> |
|---|
| 145 |
<input <?php if ( ! empty($_POST['need_chart']) && $_POST['need_chart'] == 'true' ) { echo 'checked="checked"'; } ?> type="checkbox" name="need_chart" value="true" /> : <?php echo _("Call Graph")?><br /> |
|---|
| 146 |
<!-- |
|---|
| 147 |
<input <?php if ( ! empty($_POST['need_chart_cc']) && $_POST['need_chart_cc'] == 'true' ) { echo 'checked="checked"'; } ?> type="checkbox" name="need_chart_cc" value="true" /> : <?php echo _("Concurrent Calls")?><br /> |
|---|
| 148 |
--> |
|---|
| 149 |
</td> |
|---|
| 150 |
</tr> |
|---|
| 151 |
<tr> |
|---|
| 152 |
<td><label for="Result limit"><?php echo _("Result limit")?> : </label></td> |
|---|
| 153 |
<td> |
|---|
| 154 |
<input value="<?php |
|---|
| 155 |
if (isset($_POST['limit']) ) { |
|---|
| 156 |
echo htmlspecialchars($_POST['limit']); |
|---|
| 157 |
} else { |
|---|
| 158 |
echo $db_result_limit; |
|---|
| 159 |
} ?>" name="limit" size="6" /> |
|---|
| 160 |
</td> |
|---|
| 161 |
</tr> |
|---|
| 162 |
</table> |
|---|
| 163 |
</fieldset> |
|---|
| 164 |
</td> |
|---|
| 165 |
</tr> |
|---|
| 166 |
<tr> |
|---|
| 167 |
<?php $channel_tooltip = _("Select Source Channel to search for. You can enter just the channel type like SIP, IAX2 or Local. You can also include the destination for the channel, like SIP/1234.");?> |
|---|
| 168 |
<td><input <?php if (isset($_POST['order']) && $_POST['order'] == 'channel') { echo 'checked="checked"'; } ?> type="radio" name="order" value="channel" /> <label for="channel"><?php echo "<a href=\"#\" class=\"info\">"._("Src Channel")."<span>$channel_tooltip</span></a>"?>:</label></td> |
|---|
| 169 |
<td><input type="text" name="channel" id="channel" value="<?php if (isset($_POST['channel'])) { echo htmlspecialchars($_POST['channel']); } ?>" /> |
|---|
| 170 |
<?php echo _("Not")?>:<input <?php if ( isset($_POST['channel_neg'] ) && $_POST['channel_neg'] == 'true' ) { echo 'checked="checked"'; } ?> type="checkbox" name="channel_neg" value="true" /> |
|---|
| 171 |
<?php echo _("Begins With")?>:<input <?php if (empty($_POST['channel_mod']) || $_POST['channel_mod'] == 'begins_with') { echo 'checked="checked"'; } ?> type="radio" name="channel_mod" value="begins_with" /> |
|---|
| 172 |
<?php echo _("Contains")?>:<input <?php if (isset($_POST['channel_mod']) && $_POST['channel_mod'] == 'contains') { echo 'checked="checked"'; } ?> type="radio" name="channel_mod" value="contains" /> |
|---|
| 173 |
<?php echo _("Ends With")?>:<input <?php if (isset($_POST['channel_mod']) && $_POST['channel_mod'] == 'ends_with') { echo 'checked="checked"'; } ?> type="radio" name="channel_mod" value="ends_with" /> |
|---|
| 174 |
<?php echo _("Exactly")?>:<input <?php if (isset($_POST['channel_mod']) && $_POST['channel_mod'] == 'exact') { echo 'checked="checked"'; } ?> type="radio" name="channel_mod" value="exact" /> |
|---|
| 175 |
</td> |
|---|
| 176 |
</tr> |
|---|
| 177 |
<tr> |
|---|
| 178 |
<?php $source_tooltip = _("Search for source calls. You can enter multiple sources separated by a comma. This field support Asterisk regular expression. Example<br>");?> |
|---|
| 179 |
<?php $source_tooltip .= _("<b>_2XXN, _562., _.0075</b> = search for any match of these numbers<br>");?> |
|---|
| 180 |
<?php $source_tooltip .= _("<b>_!2XXN, _562., _.0075</b> = Search for any match <b>except</b> for these numbers");?> |
|---|
| 181 |
<?php $source_tooltip .= _("<br>Asterisk pattern matching<br>");?> |
|---|
| 182 |
<?php $source_tooltip .= _("<b>X</b> = matches any digit from 0-9<br>");?> |
|---|
| 183 |
<?php $source_tooltip .= _("<b>Z</b> = matches any digit from 1-9<br>");?> |
|---|
| 184 |
<?php $source_tooltip .= _("<b>N</b> = matches any digit from 2-9<br>");?> |
|---|
| 185 |
<?php $source_tooltip .= _("<b>[1237-9]</b> = matches any digit or letter in the brackets<br>(in this example, 1,2,3,7,8,9)<br>");?> |
|---|
| 186 |
<?php $source_tooltip .= _("<b>.</b> = wildcard, matches one or more characters<br>");?> |
|---|
| 187 |
<td><input <?php if (isset($_POST['order']) && $_POST['order'] == 'src') { echo 'checked="checked"'; } ?> type="radio" name="order" value="src" /> <label for="src"><?php echo "<a href=\"#\" class=\"info\">"._("Source")."<span>$source_tooltip</span></a>"?>:</label></td> |
|---|
| 188 |
<td><input type="text" name="src" id="src" value="<?php if (isset($_POST['src'])) { echo htmlspecialchars($_POST['src']); } ?>" /> |
|---|
| 189 |
<?php echo _("Not")?>:<input <?php if ( isset($_POST['src_neg'] ) && $_POST['src_neg'] == 'true' ) { echo 'checked="checked"'; } ?> type="checkbox" name="src_neg" value="true" /> |
|---|
| 190 |
<?php echo _("Begins With")?>:<input <?php if (empty($_POST['src_mod']) || $_POST['src_mod'] == 'begins_with') { echo 'checked="checked"'; } ?> type="radio" name="src_mod" value="begins_with" /> |
|---|
| 191 |
<?php echo _("Contains")?>:<input <?php if (isset($_POST['src_mod']) && $_POST['src_mod'] == 'contains') { echo 'checked="checked"'; } ?> type="radio" name="src_mod" value="contains" /> |
|---|
| 192 |
<?php echo _("Ends With")?>:<input <?php if (isset($_POST['src_mod']) && $_POST['src_mod'] == 'ends_with') { echo 'checked="checked"'; } ?> type="radio" name="src_mod" value="ends_with" /> |
|---|
| 193 |
<?php echo _("Exactly")?>:<input <?php if (isset($_POST['src_mod']) && $_POST['src_mod'] == 'exact') { echo 'checked="checked"'; } ?> type="radio" name="src_mod" value="exact" /> |
|---|
| 194 |
</td> |
|---|
| 195 |
</tr> |
|---|
| 196 |
<tr> |
|---|
| 197 |
<?php $callerid_tooltip = _("Search for CallerID. If your CallerID begins with \" then you must supply this in your search if you select Begins With.");?> |
|---|
| 198 |
<td><input <?php if (isset($_POST['order']) && $_POST['order'] == 'clid') { echo 'checked="checked"'; } ?> type="radio" name="order" value="clid" /> <label for="clid"><?php echo "<a href=\"#\" class=\"info\">"._("CallerID")."<span>$callerid_tooltip</span></a>"?></label></td> |
|---|
| 199 |
<td><input type="text" name="clid" id="clid" value="<?php if (isset($_POST['clid'])) { echo htmlspecialchars($_POST['clid']); } ?>" /> |
|---|
| 200 |
<?php echo _("Not")?>:<input <?php if ( isset($_POST['clid_neg'] ) && $_POST['clid_neg'] == 'true' ) { echo 'checked="checked"'; } ?> type="checkbox" name="clid_neg" value="true" /> |
|---|
| 201 |
<?php echo _("Begins With")?>:<input <?php if (empty($_POST['clid_mod']) || $_POST['clid_mod'] == 'begins_with') { echo 'checked="checked"'; } ?> type="radio" name="clid_mod" value="begins_with" /> |
|---|
| 202 |
<?php echo _("Contains")?>:<input <?php if (isset($_POST['clid_mod']) && $_POST['clid_mod'] == 'contains') { echo 'checked="checked"'; } ?> type="radio" name="clid_mod" value="contains" /> |
|---|
| 203 |
<?php echo _("Ends With")?>:<input <?php if (isset($_POST['clid_mod']) && $_POST['clid_mod'] == 'ends_with') { echo 'checked="checked"'; } ?> type="radio" name="clid_mod" value="ends_with" /> |
|---|
| 204 |
<?php echo _("Exactly")?>:<input <?php if (isset($_POST['clid_mod']) && $_POST['clid_mod'] == 'exact') { echo 'checked="checked"'; } ?> type="radio" name="clid_mod" value="exact" /> |
|---|
| 205 |
</td> |
|---|
| 206 |
</tr> |
|---|
| 207 |
<tr> |
|---|
| 208 |
<?php $did_tooltip = _("Search for a DID.");?> |
|---|
| 209 |
<td><input <?php if (isset($_POST['order']) && $_POST['order'] == 'did') { echo 'checked="checked"'; } ?> type="radio" name="order" value="did" /> <label for="did"><?php echo "<a href=\"#\" class=\"info\">"._("DID")."<span>$did_tooltip</span></a>"?></label></td> |
|---|
| 210 |
<td><input type="text" name="did" id="clid" value="<?php if (isset($_POST['did'])) { echo htmlspecialchars($_POST['did']); } ?>" /> |
|---|
| 211 |
<?php echo _("Not")?>:<input <?php if ( isset($_POST['did_neg'] ) && $_POST['did_neg'] == 'true' ) { echo 'checked="checked"'; } ?> type="checkbox" name="did_neg" value="true" /> |
|---|
| 212 |
<?php echo _("Begins With")?>:<input <?php if (empty($_POST['did_mod']) || $_POST['did_mod'] == 'begins_with') { echo 'checked="checked"'; } ?> type="radio" name="did_mod" value="begins_with" /> |
|---|
| 213 |
<?php echo _("Contains")?>:<input <?php if (isset($_POST['did_mod']) && $_POST['did_mod'] == 'contains') { echo 'checked="checked"'; } ?> type="radio" name="did_mod" value="contains" /> |
|---|
| 214 |
<?php echo _("Ends With")?>:<input <?php if (isset($_POST['did_mod']) && $_POST['did_mod'] == 'ends_with') { echo 'checked="checked"'; } ?> type="radio" name="did_mod" value="ends_with" /> |
|---|
| 215 |
<?php echo _("Exactly")?>:<input <?php if (isset($_POST['did_mod']) && $_POST['did_mod'] == 'exact') { echo 'checked="checked"'; } ?> type="radio" name="did_mod" value="exact" /> |
|---|
| 216 |
</td> |
|---|
| 217 |
</tr> |
|---|
| 218 |
<tr> |
|---|
| 219 |
<?php $dstchannel_tooltip = _("Select Destination Channel to search for. It can be just the channel type like SIP, IAX2 or Local. It can include the destination for the channel, like SIP/1234.");?> |
|---|
| 220 |
<td><input <?php if (isset($_POST['order']) && $_POST['order'] == 'dstchannel') { echo 'checked="checked"'; } ?> type="radio" name="order" value="dstchannel" /> <label for="dstchannel"><?php echo "<a href=\"#\" class=\"info\">"._("Dst Channel")."<span>$dstchannel_tooltip</span></a>"?>:</label></td> |
|---|
| 221 |
<td><input type="text" name="dstchannel" id="dstchannel" value="<?php if (isset($_POST['dstchannel'])) { echo htmlspecialchars($_POST['dstchannel']); } ?>" /> |
|---|
| 222 |
<?php echo _("Not")?>:<input <?php if ( isset($_POST['dstchannel_neg'] ) && $_POST['dstchannel_neg'] == 'true' ) { echo 'checked="checked"'; } ?> type="checkbox" name="dstchannel_neg" value="true" /> |
|---|
| 223 |
<?php echo _("Begins With")?>:<input <?php if (empty($_POST['dstchannel_mod']) || $_POST['dstchannel_mod'] == 'begins_with') { echo 'checked="checked"'; } ?> type="radio" name="dstchannel_mod" value="begins_with" /> |
|---|
| 224 |
<?php echo _("Contains")?>:<input <?php if (isset($_POST['dstchannel_mod']) && $_POST['dstchannel_mod'] == 'contains') { echo 'checked="checked"'; } ?> type="radio" name="dstchannel_mod" value="contains" /> |
|---|
| 225 |
<?php echo _("Ends With")?>:<input <?php if (isset($_POST['dstchannel_mod']) && $_POST['dstchannel_mod'] == 'ends_with') { echo 'checked="checked"'; } ?> type="radio" name="dstchannel_mod" value="ends_with" /> |
|---|
| 226 |
<?php echo _("Exactly")?>:<input <?php if (isset($_POST['dstchannel_mod']) && $_POST['dstchannel_mod'] == 'exact') { echo 'checked="checked"'; } ?> type="radio" name="dstchannel_mod" value="exact" /> |
|---|
| 227 |
</td> |
|---|
| 228 |
</tr> |
|---|
| 229 |
<tr> |
|---|
| 230 |
<?php $destination_tooltip = _("Search for destination calls. You can enter multiple sources separated by a comma. This field support Asterisk regular expression. Example<br>");?> |
|---|
| 231 |
<?php $destination_tooltip .= _("<b>_2XXN, _562., _.0075</b> = search for any match of these numbers<br>");?> |
|---|
| 232 |
<?php $destination_tooltip .= _("<b>_!2XXN, _562., _.0075</b> = Search for any match <b>except</b> for these numbers");?> |
|---|
| 233 |
<?php $destination_tooltip .= _("<br>Asterisk pattern matching<br>");?> |
|---|
| 234 |
<?php $destination_tooltip .= _("<b>X</b> = matches any digit from 0-9<br>");?> |
|---|
| 235 |
<?php $destination_tooltip .= _("<b>Z</b> = matches any digit from 1-9<br>");?> |
|---|
| 236 |
<?php $destination_tooltip .= _("<b>N</b> = matches any digit from 2-9<br>");?> |
|---|
| 237 |
<?php $destination_tooltip .= _("<b>[1237-9]</b> = matches any digit or letter in the brackets<br>(in this example, 1,2,3,7,8,9)<br>");?> |
|---|
| 238 |
<?php $destination_tooltip .= _("<b>.</b> = wildcard, matches one or more characters<br>");?> |
|---|
| 239 |
<td><input <?php if (isset($_POST['order']) && $_POST['order'] == 'dst') { echo 'checked="checked"'; } ?> type="radio" name="order" value="dst" /> <label for="dst"><?php echo "<a href=\"#\" class=\"info\">"._("Destination")."<span>$destination_tooltip</span></a>"?>:</label></td> |
|---|
| 240 |
<td><input type="text" name="dst" id="dst" value="<?php if (isset($_POST['dst'])) { echo htmlspecialchars($_POST['dst']); } ?>" /> |
|---|
| 241 |
<?php echo _("Not")?>:<input <?php if ( isset($_POST['dst_neg'] ) && $_POST['dst_neg'] == 'true' ) { echo 'checked="checked"'; } ?> type="checkbox" name="dst_neg" value="true" /> |
|---|
| 242 |
<?php echo _("Begins With")?>:<input <?php if (empty($_POST['dst_mod']) || $_POST['dst_mod'] == 'begins_with') { echo 'checked="checked"'; } ?> type="radio" name="dst_mod" value="begins_with" /> |
|---|
| 243 |
<?php echo _("Contains")?>:<input <?php if (isset($_POST['dst_mod']) && $_POST['dst_mod'] == 'contains') { echo 'checked="checked"'; } ?> type="radio" name="dst_mod" value="contains" /> |
|---|
| 244 |
<?php echo _("Ends With")?>:<input <?php if (isset($_POST['dst_mod']) && $_POST['dst_mod'] == 'ends_with') { echo 'checked="checked"'; } ?> type="radio" name="dst_mod" value="ends_with" /> |
|---|
| 245 |
<?php echo _("Exactly")?>:<input <?php if (isset($_POST['dst_mod']) && $_POST['dst_mod'] == 'exact') { echo 'checked="checked"'; } ?> type="radio" name="dst_mod" value="exact" /> |
|---|
| 246 |
</td> |
|---|
| 247 |
</tr> |
|---|
| 248 |
<tr> |
|---|
| 249 |
<?php $userfield_tooltip = _("Search for userfield data (if enabled).");?> |
|---|
| 250 |
<td><input <?php if (isset($_POST['order']) && $_POST['order'] == 'userfield') { echo 'checked="checked"'; } ?> type="radio" name="order" value="userfield" /> <label for="userfield"><?php echo "<a href=\"#\" class=\"info\">"._("Userfield")."<span>$userfield_tooltip</span></a>"?>:</label></td> |
|---|
| 251 |
<td><input type="text" name="userfield" id="userfield" value="<?php if (isset($_POST['userfield'])) { echo htmlspecialchars($_POST['userfield']); } ?>" /> |
|---|
| 252 |
<?php echo _("Not")?>:<input <?php if ( isset($_POST['userfield_neg'] ) && $_POST['userfield_neg'] == 'true' ) { echo 'checked="checked"'; } ?> type="checkbox" name="userfield_neg" value="true" /> |
|---|
| 253 |
<?php echo _("Begins With")?>:<input <?php if (empty($_POST['userfield_mod']) || $_POST['userfield_mod'] == 'begins_with') { echo 'checked="checked"'; } ?> type="radio" name="userfield_mod" value="begins_with" /> |
|---|
| 254 |
<?php echo _("Contains")?>:<input <?php if (isset($_POST['userfield_mod']) && $_POST['userfield_mod'] == 'contains') { echo 'checked="checked"'; } ?> type="radio" name="userfield_mod" value="contains" /> |
|---|
| 255 |
<?php echo _("Ends With")?>:<input <?php if (isset($_POST['userfield_mod']) && $_POST['userfield_mod'] == 'ends_with') { echo 'checked="checked"'; } ?> type="radio" name="userfield_mod" value="ends_with" /> |
|---|
| 256 |
<?php echo _("Exactly")?>:<input <?php if (isset($_POST['userfield_mod']) && $_POST['userfield_mod'] == 'exact') { echo 'checked="checked"'; } ?> type="radio" name="userfield_mod" value="exact" /> |
|---|
| 257 |
</td> |
|---|
| 258 |
</tr> |
|---|
| 259 |
<tr> |
|---|
| 260 |
<?php $accountcode_tooltip = _("Search for accountcode.");?> |
|---|
| 261 |
<td><input <?php if (isset($_POST['order']) && $_POST['order'] == 'accountcode') { echo 'checked="checked"'; } ?> type="radio" name="order" value="accountcode" /> <label for="userfield"><?php echo "<a href=\"#\" class=\"info\">"._("Account Code")."<span>$accountcode_tooltip</span></a>"?>:</label></td> |
|---|
| 262 |
<td><input type="text" name="accountcode" id="accountcode" value="<?php if (isset($_POST['accountcode'])) { echo htmlspecialchars($_POST['accountcode']); } ?>" /> |
|---|
| 263 |
<?php echo _("Not")?>:<input <?php if ( isset($_POST['accountcode_neg'] ) && $_POST['accountcode_neg'] == 'true' ) { echo 'checked="checked"'; } ?> type="checkbox" name="accountcode_neg" value="true" /> |
|---|
| 264 |
<?php echo _("Begins With")?>:<input <?php if (empty($_POST['accountcode_mod']) || $_POST['accountcode_mod'] == 'begins_with') { echo 'checked="checked"'; } ?> type="radio" name="accountcode_mod" value="begins_with" /> |
|---|
| 265 |
<?php echo _("Contains")?>:<input <?php if (isset($_POST['accountcode_mod']) && $_POST['accountcode_mod'] == 'contains') { echo 'checked="checked"'; } ?> type="radio" name="accountcode_mod" value="contains" /> |
|---|
| 266 |
<?php echo _("Ends With")?>:<input <?php if (isset($_POST['accountcode_mod']) && $_POST['accountcode_mod'] == 'ends_with') { echo 'checked="checked"'; } ?> type="radio" name="accountcode_mod" value="ends_with" /> |
|---|
| 267 |
<?php echo _("Exactly")?>:<input <?php if (isset($_POST['accountcode_mod']) && $_POST['accountcode_mod'] == 'exact') { echo 'checked="checked"'; } ?> type="radio" name="accountcode_mod" value="exact" /> |
|---|
| 268 |
</td> |
|---|
| 269 |
</tr> |
|---|
| 270 |
<tr> |
|---|
| 271 |
<?php $duration_tooltip = _("Search for calls that matches the call length specified.");?> |
|---|
| 272 |
<td><input <?php if (isset($_POST['order']) && $_POST['order'] == 'duration') { echo 'checked="checked"'; } ?> type="radio" name="order" value="duration" /> <label><?php echo "<a href=\"#\" class=\"info\">"._("Duration")."<span>$duration_tooltip</span></a>"?>:</label></td> |
|---|
| 273 |
<td><?php echo _("Between")?>: |
|---|
| 274 |
<input type="text" name="dur_min" value="<?php if (isset($_POST['dur_min'])) { echo htmlspecialchars($_POST['dur_min']); } ?>" size="3" maxlength="5" /> |
|---|
| 275 |
<?php echo _("And")?>: |
|---|
| 276 |
<input type="text" name="dur_max" value="<?php if (isset($_POST['dur_max'])) { echo htmlspecialchars($_POST['dur_max']); } ?>" size="3" maxlength="5" /> |
|---|
| 277 |
<?php echo _("Seconds")?> |
|---|
| 278 |
</td> |
|---|
| 279 |
</tr> |
|---|
| 280 |
<tr> |
|---|
| 281 |
<?php $disposition_tooltip = _("Search for calls that matches either ANSWERED, BUSY, FAILED or NO ANSWER.");?> |
|---|
| 282 |
<td><input <?php if (isset($_POST['order']) && $_POST['order'] == 'disposition') { echo 'checked="checked"'; } ?> type="radio" name="order" value="disposition" /> <label for="disposition"><?php echo "<a href=\"#\" class=\"info\">"._("Disposition")."<span>$disposition_tooltip</span></a>"?>:</label></td> |
|---|
| 283 |
<td> |
|---|
| 284 |
|
|---|
| 285 |
<select name="disposition" id="disposition"> |
|---|
| 286 |
<option <?php if (empty($_POST['disposition']) || $_POST['disposition'] == 'all') { echo 'selected="selected"'; } ?> value="all"><?php echo _("All Dispositions")?></option> |
|---|
| 287 |
<option <?php if (isset($_POST['disposition']) && $_POST['disposition'] == 'ANSWERED') { echo 'selected="selected"'; } ?> value="ANSWERED"><?php echo _("Answered")?></option> |
|---|
| 288 |
<option <?php if (isset($_POST['disposition']) && $_POST['disposition'] == 'BUSY') { echo 'selected="selected"'; } ?> value="BUSY"><?php echo _("Busy")?></option> |
|---|
| 289 |
<option <?php if (isset($_POST['disposition']) && $_POST['disposition'] == 'FAILED') { echo 'selected="selected"'; } ?> value="FAILED"><?php echo _("Failed")?></option> |
|---|
| 290 |
<option <?php if (isset($_POST['disposition']) && $_POST['disposition'] == 'NO ANSWER') { echo 'selected="selected"'; } ?> value="NO ANSWER"><?php echo _("No Answer")?></option> |
|---|
| 291 |
</select> |
|---|
| 292 |
<?php echo _("Not")?>:<input <?php if ( isset($_POST['dispositio_neg'] ) && $_POST['disposition_neg'] == 'true' ) { echo 'checked="checked"'; } ?> type="checkbox" name="disposition_neg" value="true" /> |
|---|
| 293 |
</td> |
|---|
| 294 |
</tr> |
|---|
| 295 |
<tr> |
|---|
| 296 |
<td> |
|---|
| 297 |
<select name="sort" id="sort"> |
|---|
| 298 |
<option <?php if (isset($_POST['sort']) && $_POST['sort'] == 'ASC') { echo 'selected="selected"'; } ?> value="ASC"><?php echo _("Oldest First")?></option> |
|---|
| 299 |
<option <?php if (empty($_POST['sort']) || $_POST['sort'] == 'DESC') { echo 'selected="selected"'; } ?> value="DESC"><?php echo _("Newest First")?></option> |
|---|
| 300 |
</select> |
|---|
| 301 |
</td> |
|---|
| 302 |
<td><table width="100%"><tr><td> |
|---|
| 303 |
<label for="group"><?php echo _("Group By")?>:</label> |
|---|
| 304 |
<select name="group" id="group"> |
|---|
| 305 |
<optgroup label="<?php echo _("Account Information")?>"> |
|---|
| 306 |
<option <?php if (isset($_POST['group']) && $_POST['group'] == 'accountcode') { echo 'selected="selected"'; } ?> value="accountcode"><?php echo _("Account Code")?></option> |
|---|
| 307 |
<option <?php if (isset($_POST['group']) && $_POST['group'] == 'userfield') { echo 'selected="selected"'; } ?> value="userfield"><?php echo _("User Field")?></option> |
|---|
| 308 |
</optgroup> |
|---|
| 309 |
<optgroup label="<?php echo _("Date/Time")?>"> |
|---|
| 310 |
<option <?php if (isset($_POST['group']) && $_POST['group'] == 'minutes1') { echo 'selected="selected"'; } ?> value="minutes1"><?php echo _("Minute")?></option> |
|---|
| 311 |
<option <?php if (isset($_POST['group']) && $_POST['group'] == 'minutes10') { echo 'selected="selected"'; } ?> value="minutes10"><?php echo _("10 Minutes")?></option> |
|---|
| 312 |
<option <?php if (isset($_POST['group']) && $_POST['group'] == 'hour') { echo 'selected="selected"'; } ?> value="hour"><?php echo _("Hour")?></option> |
|---|
| 313 |
<option <?php if (isset($_POST['group']) && $_POST['group'] == 'hour_of_day') { echo 'selected="selected"'; } ?> value="hour_of_day"><?php echo _("Hour of day")?></option> |
|---|
| 314 |
<option <?php if (isset($_POST['group']) && $_POST['group'] == 'day_of_week') { echo 'selected="selected"'; } ?> value="day_of_week"><?php echo _("Day of week")?></option> |
|---|
| 315 |
<option <?php if (empty($_POST['group']) || $_POST['group'] == 'day') { echo 'selected="selected"'; } ?> value="day"><?php echo _("Day")?></option> |
|---|
| 316 |
<option <?php if (isset($_POST['group']) && $_POST['group'] == 'week') { echo 'selected="selected"'; } ?> value="week"><?php echo _("Week ( Sun-Sat )")?></option> |
|---|
| 317 |
<option <?php if (isset($_POST['group']) && $_POST['group'] == 'month') { echo 'selected="selected"'; } ?> value="month"><?php echo _("Month")?></option> |
|---|
| 318 |
</optgroup> |
|---|
| 319 |
<optgroup label="<?php echo _("Telephone Number")?>"> |
|---|
| 320 |
<option <?php if (isset($_POST['group']) && $_POST['group'] == 'src') { echo 'selected="selected"'; } ?> value="src"><?php echo _("Source Number")?></option> |
|---|
| 321 |
<option <?php if (isset($_POST['group']) && $_POST['group'] == 'dst') { echo 'selected="selected"'; } ?> value="dst"><?php echo _("Destination Number")?></option> |
|---|
| 322 |
</optgroup> |
|---|
| 323 |
<optgroup label="<?php echo _("Tech info")?>"> |
|---|
| 324 |
<option <?php if (isset($_POST['group']) && $_POST['group'] == 'disposition') { echo 'selected="selected"'; } ?> value="disposition">Disposition</option> |
|---|
| 325 |
<option <?php if (isset($_POST['group']) && $_POST['group'] == 'disposition_by_day') { echo 'selected="selected"'; } ?> value="disposition_by_day">Disposition by Day</option> |
|---|
| 326 |
<option <?php if (isset($_POST['group']) && $_POST['group'] == 'disposition_by_hour') { echo 'selected="selected"'; } ?> value="disposition_by_hour">Disposition by Hour</option> |
|---|
| 327 |
<option <?php if (isset($_POST['group']) && $_POST['group'] == 'dcontext') { echo 'selected="selected"'; } ?> value="dcontext">Destination context</option> |
|---|
| 328 |
</optgroup> |
|---|
| 329 |
</select></td><td align="left" width="40%"> |
|---|
| 330 |
<input type="submit" value="<?php echo _("Search")?>" /> |
|---|
| 331 |
</td></td></table> |
|---|
| 332 |
</td> |
|---|
| 333 |
</tr> |
|---|
| 334 |
</table> |
|---|
| 335 |
</fieldset> |
|---|
| 336 |
</form> |
|---|
| 337 |
</td> |
|---|
| 338 |
</tr> |
|---|
| 339 |
</table> |
|---|
| 340 |
<a id="CDR"></a> |
|---|
| 341 |
|
|---|
| 342 |
<?php |
|---|
| 343 |
foreach ( array_keys($_POST) as $key ) { |
|---|
| 344 |
$_POST[$key] = preg_replace('/;/', ' ', $_POST[$key]); |
|---|
| 345 |
$_POST[$key] = mysql_real_escape_string($_POST[$key]); |
|---|
| 346 |
} |
|---|
| 347 |
|
|---|
| 348 |
$startmonth = empty($_POST['startmonth']) ? date('m') : $_POST['startmonth']; |
|---|
| 349 |
$startyear = empty($_POST['startyear']) ? date('Y') : $_POST['startyear']; |
|---|
| 350 |
|
|---|
| 351 |
if (empty($_POST['startday'])) { |
|---|
| 352 |
$startday = '01'; |
|---|
| 353 |
} elseif (isset($_POST['startday']) && ($_POST['startday'] > date('t', strtotime("$startyear-$startmonth")))) { |
|---|
| 354 |
$startday = $_POST['startday'] = date('t', strtotime("$startyear-$startmonth")); |
|---|
| 355 |
} else { |
|---|
| 356 |
$startday = sprintf('%02d',$_POST['startday']); |
|---|
| 357 |
} |
|---|
| 358 |
$starthour = empty($_POST['starthour']) ? '00' : sprintf('%02d',$_POST['starthour']); |
|---|
| 359 |
$startmin = empty($_POST['startmin']) ? '00' : sprintf('%02d',$_POST['startmin']); |
|---|
| 360 |
|
|---|
| 361 |
$startdate = "'$startyear-$startmonth-$startday $starthour:$startmin:00'"; |
|---|
| 362 |
$start_timestamp = mktime( $starthour, $startmin, 59, $startmonth, $startday, $startyear ); |
|---|
| 363 |
|
|---|
| 364 |
$endmonth = empty($_POST['endmonth']) ? date('m') : $_POST['endmonth']; |
|---|
| 365 |
$endyear = empty($_POST['endyear']) ? date('Y') : $_POST['endyear']; |
|---|
| 366 |
|
|---|
| 367 |
if (empty($_POST['endday']) || (isset($_POST['endday']) && ($_POST['endday'] > date('t', strtotime("$endyear-$endmonth-01"))))) { |
|---|
| 368 |
$endday = $_POST['endday'] = date('t', strtotime("$endyear-$endmonth")); |
|---|
| 369 |
} else { |
|---|
| 370 |
$endday = sprintf('%02d',$_POST['endday']); |
|---|
| 371 |
} |
|---|
| 372 |
$endhour = empty($_POST['endhour']) ? '23' : sprintf('%02d',$_POST['endhour']); |
|---|
| 373 |
$endmin = empty($_POST['endmin']) ? '59' : sprintf('%02d',$_POST['endmin']); |
|---|
| 374 |
|
|---|
| 375 |
$enddate = "'$endyear-$endmonth-$endday $endhour:$endmin:59'"; |
|---|
| 376 |
$end_timestamp = mktime( $endhour, $endmin, 59, $endmonth, $endday, $endyear ); |
|---|
| 377 |
|
|---|
| 378 |
|
|---|
| 379 |
|
|---|
| 380 |
|
|---|
| 381 |
if ( !isset($_POST['src']) ) { |
|---|
| 382 |
$src_number = NULL; |
|---|
| 383 |
} else { |
|---|
| 384 |
$src_number = cdr_asteriskregexp2sqllike( 'src', '' ); |
|---|
| 385 |
} |
|---|
| 386 |
|
|---|
| 387 |
if ( !isset($_POST['dst']) ) { |
|---|
| 388 |
$dst_number = NULL; |
|---|
| 389 |
} else { |
|---|
| 390 |
$dst_number = cdr_asteriskregexp2sqllike( 'dst', '' ); |
|---|
| 391 |
} |
|---|
| 392 |
|
|---|
| 393 |
$date_range = "calldate BETWEEN $startdate AND $enddate"; |
|---|
| 394 |
$mod_vars['channel'][] = !isset($_POST['channel']) ? NULL : $_POST['channel']; |
|---|
| 395 |
$mod_vars['channel'][] = empty($_POST['channel_mod']) ? NULL : $_POST['channel_mod']; |
|---|
| 396 |
$mod_vars['channel'][] = empty($_POST['channel_neg']) ? NULL : $_POST['channel_neg']; |
|---|
| 397 |
$mod_vars['src'][] = $src_number; |
|---|
| 398 |
$mod_vars['src'][] = empty($_POST['src_mod']) ? NULL : $_POST['src_mod']; |
|---|
| 399 |
$mod_vars['src'][] = empty($_POST['src_neg']) ? NULL : $_POST['src_neg']; |
|---|
| 400 |
$mod_vars['clid'][] = !isset($_POST['clid']) ? NULL : $_POST['clid']; |
|---|
| 401 |
$mod_vars['clid'][] = empty($_POST['clid_mod']) ? NULL : $_POST['clid_mod']; |
|---|
| 402 |
$mod_vars['clid'][] = empty($_POST['clid_neg']) ? NULL : $_POST['clid_neg']; |
|---|
| 403 |
$mod_vars['did'][] = !isset($_POST['did']) ? NULL : $_POST['did']; |
|---|
| 404 |
$mod_vars['did'][] = empty($_POST['did_mod']) ? NULL : $_POST['did_mod']; |
|---|
| 405 |
$mod_vars['did'][] = empty($_POST['did_neg']) ? NULL : $_POST['did_neg']; |
|---|
| 406 |
$mod_vars['dstchannel'][] = !isset($_POST['dstchannel']) ? NULL : $_POST['dstchannel']; |
|---|
| 407 |
$mod_vars['dstchannel'][] = empty($_POST['dstchannel_mod']) ? NULL : $_POST['dstchannel_mod']; |
|---|
| 408 |
$mod_vars['dstchannel'][] = empty($_POST['dstchannel_neg']) ? NULL : $_POST['dstchannel_neg']; |
|---|
| 409 |
$mod_vars['dst'][] = $dst_number; |
|---|
| 410 |
$mod_vars['dst'][] = empty($_POST['dst_mod']) ? NULL : $_POST['dst_mod']; |
|---|
| 411 |
$mod_vars['dst'][] = empty($_POST['dst_neg']) ? NULL : $_POST['dst_neg']; |
|---|
| 412 |
$mod_vars['userfield'][] = !isset($_POST['userfield']) ? NULL : $_POST['userfield']; |
|---|
| 413 |
$mod_vars['userfield'][] = empty($_POST['userfield_mod']) ? NULL : $_POST['userfield_mod']; |
|---|
| 414 |
$mod_vars['userfield'][] = empty($_POST['userfield_neg']) ? NULL : $_POST['userfield_neg']; |
|---|
| 415 |
$mod_vars['accountcode'][] = !isset($_POST['accountcode']) ? NULL : $_POST['accountcode']; |
|---|
| 416 |
$mod_vars['accountcode'][] = empty($_POST['accountcode_mod']) ? NULL : $_POST['accountcode_mod']; |
|---|
| 417 |
$mod_vars['accountcode'][] = empty($_POST['accountcode_neg']) ? NULL : $_POST['accountcode_neg']; |
|---|
| 418 |
$result_limit = !isset($_POST['limit']) ? $db_result_limit : $_POST['limit']; |
|---|
| 419 |
|
|---|
| 420 |
foreach ($mod_vars as $key => $val) { |
|---|
| 421 |
if (is_blank($val[0])) { |
|---|
| 422 |
unset($_POST[$key.'_mod']); |
|---|
| 423 |
$$key = NULL; |
|---|
| 424 |
} else { |
|---|
| 425 |
$pre_like = ''; |
|---|
| 426 |
if ( $val[2] == 'true' ) { |
|---|
| 427 |
$pre_like = ' NOT '; |
|---|
| 428 |
} |
|---|
| 429 |
switch ($val[1]) { |
|---|
| 430 |
case "contains": |
|---|
| 431 |
if ($key == 'src') { |
|---|
| 432 |
$values = explode(',',$val[0]); |
|---|
| 433 |
if (count($values) > 1) { |
|---|
| 434 |
foreach ($values as $key_like => $value_like) { |
|---|
| 435 |
if ($key_like == 0) { |
|---|
| 436 |
$$key = "AND $key $pre_like LIKE '%$value_like%'"; |
|---|
| 437 |
} else { |
|---|
| 438 |
$$key .= " OR $key $pre_like LIKE '%$value_like%'"; |
|---|
| 439 |
} |
|---|
| 440 |
} |
|---|
| 441 |
} else { |
|---|
| 442 |
$$key = "AND $key $pre_like LIKE '%$val[0]%'"; |
|---|
| 443 |
} |
|---|
| 444 |
} else { |
|---|
| 445 |
$$key = "AND $key $pre_like LIKE '%$val[0]%'"; |
|---|
| 446 |
} |
|---|
| 447 |
break; |
|---|
| 448 |
case "ends_with": |
|---|
| 449 |
if ($key == 'src') { |
|---|
| 450 |
$values = explode(',',$val[0]); |
|---|
| 451 |
if (count($values) > 1) { |
|---|
| 452 |
foreach ($values as $key_like => $value_like) { |
|---|
| 453 |
if ($key_like == 0) { |
|---|
| 454 |
$$key = "AND $key $pre_like LIKE '%$value_like'"; |
|---|
| 455 |
} else { |
|---|
| 456 |
$$key .= " OR $key $pre_like LIKE '%$value_like'"; |
|---|
| 457 |
} |
|---|
| 458 |
} |
|---|
| 459 |
} else { |
|---|
| 460 |
$$key = "AND $key $pre_like LIKE '%$val[0]'"; |
|---|
| 461 |
} |
|---|
| 462 |
} else { |
|---|
| 463 |
$$key = "AND $key $pre_like LIKE '%$val[0]'"; |
|---|
| 464 |
} |
|---|
| 465 |
break; |
|---|
| 466 |
case "exact": |
|---|
| 467 |
if ( $val[2] == 'true' ) { |
|---|
| 468 |
$$key = "AND $key != '$val[0]'"; |
|---|
| 469 |
} else { |
|---|
| 470 |
$$key = "AND $key = '$val[0]'"; |
|---|
| 471 |
} |
|---|
| 472 |
break; |
|---|
| 473 |
case "asterisk-regexp": |
|---|
| 474 |
$ast_dids = preg_split('/\s*,\s*/', $val[0], -1, PREG_SPLIT_NO_EMPTY); |
|---|
| 475 |
$ast_key = ''; |
|---|
| 476 |
foreach ($ast_dids as $did) { |
|---|
| 477 |
if (strlen($ast_key) > 0 ) { |
|---|
| 478 |
if ( $pre_like == ' NOT ' ) { |
|---|
| 479 |
$ast_key .= " and "; |
|---|
| 480 |
} else { |
|---|
| 481 |
$ast_key .= " or "; |
|---|
| 482 |
} |
|---|
| 483 |
if ( '_' == substr($did,0,1) ) { |
|---|
| 484 |
$did = substr($did,1); |
|---|
| 485 |
} |
|---|
| 486 |
} |
|---|
| 487 |
$ast_key .= " $key $pre_like RLIKE '^$did\$'"; |
|---|
| 488 |
} |
|---|
| 489 |
$$key = "AND ( $ast_key )"; |
|---|
| 490 |
break; |
|---|
| 491 |
case "begins_with": |
|---|
| 492 |
default: |
|---|
| 493 |
if ($key == 'src') { |
|---|
| 494 |
$values = explode(',',$val[0]); |
|---|
| 495 |
if (count($values) > 1) { |
|---|
| 496 |
foreach ($values as $key_like => $value_like) { |
|---|
| 497 |
if ($key_like == 0) { |
|---|
| 498 |
$$key = "AND $key $pre_like LIKE '$value_like%'"; |
|---|
| 499 |
} else { |
|---|
| 500 |
$$key .= " OR $key $pre_like LIKE '$value_like%'"; |
|---|
| 501 |
} |
|---|
| 502 |
} |
|---|
| 503 |
} else { |
|---|
| 504 |
$$key = "AND $key $pre_like LIKE '$val[0]%'"; |
|---|
| 505 |
} |
|---|
| 506 |
} else { |
|---|
| 507 |
$$key = "AND $key $pre_like LIKE '$val[0]%'"; |
|---|
| 508 |
} |
|---|
| 509 |
} |
|---|
| 510 |
} |
|---|
| 511 |
} |
|---|
| 512 |
|
|---|
| 513 |
if ( isset($_POST['disposition_neg']) && $_POST['disposition_neg'] == 'true' ) { |
|---|
| 514 |
$disposition = (empty($_POST['disposition']) || $_POST['disposition'] == 'all') ? NULL : "AND disposition != '$_POST[disposition]'"; |
|---|
| 515 |
} else { |
|---|
| 516 |
$disposition = (empty($_POST['disposition']) || $_POST['disposition'] == 'all') ? NULL : "AND disposition = '$_POST[disposition]'"; |
|---|
| 517 |
} |
|---|
| 518 |
|
|---|
| 519 |
$duration = (!isset($_POST['dur_min']) || is_blank($_POST['dur_max'])) ? NULL : "AND duration BETWEEN '$_POST[dur_min]' AND '$_POST[dur_max]'"; |
|---|
| 520 |
$order = empty($_POST['order']) ? 'ORDER BY calldate' : "ORDER BY $_POST[order]"; |
|---|
| 521 |
$sort = empty($_POST['sort']) ? 'DESC' : $_POST['sort']; |
|---|
| 522 |
$group = empty($_POST['group']) ? 'day' : $_POST['group']; |
|---|
| 523 |
|
|---|
| 524 |
|
|---|
| 525 |
$where = "WHERE $date_range $channel $dstchannel $src $clid $did $dst $userfield $accountcode $disposition $duration"; |
|---|
| 526 |
|
|---|
| 527 |
if ( isset($_POST['need_csv']) && $_POST['need_csv'] == 'true' ) { |
|---|
| 528 |
$query = "(SELECT calldate, clid, did, src, dst, dcontext, channel, dstchannel, lastapp, lastdata, duration, billsec, disposition, amaflags, accountcode, uniqueid, userfield FROM $db_name.$db_table_name $where $order $sort LIMIT $result_limit)"; |
|---|
| 529 |
$resultcsv = $dbcdr->getAll($query, DB_FETCHMODE_ASSOC); |
|---|
| 530 |
cdr_export_csv($resultcsv); |
|---|
| 531 |
} |
|---|
| 532 |
|
|---|
| 533 |
if ( isset($_POST['need_html']) && $_POST['need_html'] == 'true' ) { |
|---|
| 534 |
$query = "SELECT `calldate`, `clid`, `did`, `src`, `dst`, `dcontext`, `channel`, `dstchannel`, `lastapp`, `lastdata`, `duration`, `billsec`, `disposition`, `amaflags`, `accountcode`, `uniqueid`, `userfield`, unix_timestamp(calldate) as `call_timestamp`, `recordingfile` FROM $db_name.$db_table_name $where $order $sort LIMIT $result_limit"; |
|---|
| 535 |
$results = $dbcdr->getAll($query, DB_FETCHMODE_ASSOC); |
|---|
| 536 |
} |
|---|
| 537 |
if ( isset($results) ) { |
|---|
| 538 |
$tot_calls_raw = sizeof($results); |
|---|
| 539 |
} else { |
|---|
| 540 |
$tot_calls_raw = 0; |
|---|
| 541 |
} |
|---|
| 542 |
if ( $tot_calls_raw ) { |
|---|
| 543 |
echo "<p class=\"center title\">"._("Call Detail Record - Search Returned")." ".$tot_calls_raw." "._("Calls")."</p>"; |
|---|
| 544 |
echo "<table id=\"cdr_table\" class=\"cdr\">"; |
|---|
| 545 |
|
|---|
| 546 |
$i = $h_step - 1; |
|---|
| 547 |
$id = -1; |
|---|
| 548 |
foreach($results as $row) { |
|---|
| 549 |
++$id; |
|---|
| 550 |
++$i; |
|---|
| 551 |
if ($i == $h_step) { |
|---|
| 552 |
?> |
|---|
| 553 |
<tr> |
|---|
| 554 |
<th class="record_col"><?php echo _("Call Date")?></th> |
|---|
| 555 |
<th class="record_col"><?php echo _("Recording")?></th> |
|---|
| 556 |
<th class="record_col"><?php echo _("System")?></th> |
|---|
| 557 |
<th class="record_col"><?php echo _("Src Chan.")?></th> |
|---|
| 558 |
<th class="record_col"><?php echo _("Source")?></th> |
|---|
| 559 |
<th class="record_col"><?php echo _("DID")?></th> |
|---|
| 560 |
<th class="record_col"><?php echo _("App.")?></th> |
|---|
| 561 |
<th class="record_col"><?php echo _("Dest.")?></th> |
|---|
| 562 |
<th class="record_col"><?php echo _("Dst. Chan.")?></th> |
|---|
| 563 |
<th class="record_col"><?php echo _("Disposition")?></th> |
|---|
| 564 |
<th class="record_col"><?php echo _("Duration")?></th> |
|---|
| 565 |
<th class="record_col"><?php echo _("Userfield")?></th> |
|---|
| 566 |
<th class="record_col"><?php echo _("Account")?></th> |
|---|
| 567 |
<th class="img_col"><a href="#CDR" title="Go to the top of the CDR table"><img src="images/scrollup.gif" alt="CDR Table" /></a></th> |
|---|
| 568 |
<th class="img_col"><a href="#Graph" title="Go to the top of the CDR graph"><img src="images/scrolldown.gif" alt="CDR Graph" /></a></th> |
|---|
| 569 |
</tr> |
|---|
| 570 |
<?php |
|---|
| 571 |
$i = 0; |
|---|
| 572 |
++$id; |
|---|
| 573 |
} |
|---|
| 574 |
|
|---|
| 575 |
|
|---|
| 576 |
* a recording may have been planned but not done so this assures there are no dead links. |
|---|
| 577 |
*/ |
|---|
| 578 |
if ($row['recordingfile']) { |
|---|
| 579 |
$rec_parts = explode('-',$row['recordingfile']); |
|---|
| 580 |
$fyear = substr($rec_parts[3],0,4); |
|---|
| 581 |
$fmonth = substr($rec_parts[3],4,2); |
|---|
| 582 |
$fday = substr($rec_parts[3],6,2); |
|---|
| 583 |
$monitor_base = $amp_conf['MIXMON_DIR'] ? $amp_conf['MIXMON_DIR'] : $amp_conf['ASTSPOOLDIR'] . '/monitor'; |
|---|
| 584 |
$recordingfile = "$monitor_base/$fyear/$fmonth/$fday/" . $row['recordingfile']; |
|---|
| 585 |
if (!file_exists($recordingfile)) { |
|---|
| 586 |
$recordingfile = ''; |
|---|
| 587 |
} |
|---|
| 588 |
} else { |
|---|
| 589 |
$recordingfile = ''; |
|---|
| 590 |
} |
|---|
| 591 |
|
|---|
| 592 |
echo " <tr class=\"record\">\n"; |
|---|
| 593 |
cdr_formatCallDate($row['calldate']); |
|---|
| 594 |
cdr_formatRecordingFile($recordingfile, $row['recordingfile'], $id); |
|---|
| 595 |
cdr_formatUniqueID($row['uniqueid']); |
|---|
| 596 |
cdr_formatChannel($row['channel']); |
|---|
| 597 |
cdr_formatSrc($row['src'], $row['clid']); |
|---|
| 598 |
cdr_formatDID($row['did']); |
|---|
| 599 |
cdr_formatApp($row['lastapp'], $row['lastdata']); |
|---|
| 600 |
cdr_formatDst($row['dst'], $row['dcontext']); |
|---|
| 601 |
cdr_formatChannel($row['dstchannel']); |
|---|
| 602 |
cdr_formatDisposition($row['disposition'], $row['amaflags']); |
|---|
| 603 |
cdr_formatDuration($row['duration'], $row['billsec']); |
|---|
| 604 |
cdr_formatUserField($row['userfield']); |
|---|
| 605 |
cdr_formatAccountCode($row['accountcode']); |
|---|
| 606 |
echo " <td></td>\n"; |
|---|
| 607 |
echo " <td></td>\n"; |
|---|
| 608 |
echo " </tr>\n"; |
|---|
| 609 |
} |
|---|
| 610 |
echo "</table>"; |
|---|
| 611 |
} |
|---|
| 612 |
?> |
|---|
| 613 |
|
|---|
| 614 |
<!-- Display Call Usage Graph --> |
|---|
| 615 |
<?php |
|---|
| 616 |
|
|---|
| 617 |
echo '<a id="Graph"></a>'; |
|---|
| 618 |
|
|---|
| 619 |
|
|---|
| 620 |
$group_by_field = $group; |
|---|
| 621 |
|
|---|
| 622 |
$group_by_field_php = array( '', 32, '' ); |
|---|
| 623 |
|
|---|
| 624 |
switch ($group) { |
|---|
| 625 |
case "disposition_by_day": |
|---|
| 626 |
$graph_col_title = 'Disposition by day'; |
|---|
| 627 |
$group_by_field_php = array('%Y-%m-%d / ',17,''); |
|---|
| 628 |
$group_by_field = "CONCAT(DATE_FORMAT(calldate, '$group_by_field_php[0]'),disposition)"; |
|---|
| 629 |
break; |
|---|
| 630 |
case "disposition_by_hour": |
|---|
| 631 |
$graph_col_title = 'Disposition by hour'; |
|---|
| 632 |
$group_by_field_php = array( '%Y-%m-%d %H / ', 20, '' ); |
|---|
| 633 |
$group_by_field = "CONCAT(DATE_FORMAT(calldate, '$group_by_field_php[0]'),disposition)"; |
|---|
| 634 |
break; |
|---|
| 635 |
case "disposition": |
|---|
| 636 |
$graph_col_title = 'Disposition'; |
|---|
| 637 |
break; |
|---|
| 638 |
case "dcontext": |
|---|
| 639 |
$graph_col_title = 'Destination context'; |
|---|
| 640 |
break; |
|---|
| 641 |
case "accountcode": |
|---|
| 642 |
$graph_col_title = _("Account Code"); |
|---|
| 643 |
break; |
|---|
| 644 |
case "dst": |
|---|
| 645 |
$graph_col_title = _("Destination Number"); |
|---|
| 646 |
break; |
|---|
| 647 |
case "src": |
|---|
| 648 |
$graph_col_title = _("Source Number"); |
|---|
| 649 |
break; |
|---|
| 650 |
case "userfield": |
|---|
| 651 |
$graph_col_title = _("User Field"); |
|---|
| 652 |
break; |
|---|
| 653 |
case "hour": |
|---|
| 654 |
$group_by_field_php = array( '%Y-%m-%d %H', 13, '' ); |
|---|
| 655 |
$group_by_field = "DATE_FORMAT(calldate, '$group_by_field_php[0]')"; |
|---|
| 656 |
$graph_col_title = _("Hour"); |
|---|
| 657 |
break; |
|---|
| 658 |
case "hour_of_day": |
|---|
| 659 |
$group_by_field_php = array('%H',2,''); |
|---|
| 660 |
$group_by_field = "DATE_FORMAT(calldate, '$group_by_field_php[0]')"; |
|---|
| 661 |
$graph_col_title = _("Hour of day"); |
|---|
| 662 |
break; |
|---|
| 663 |
case "week": |
|---|
| 664 |
$group_by_field_php = array('%V',2,''); |
|---|
| 665 |
$group_by_field = "DATE_FORMAT(calldate, '$group_by_field_php[0]') "; |
|---|
| 666 |
$graph_col_title = _("Week ( Sun-Sat )"); |
|---|
| 667 |
break; |
|---|
| 668 |
case "month": |
|---|
| 669 |
$group_by_field_php = array('%Y-%m',7,''); |
|---|
| 670 |
$group_by_field = "DATE_FORMAT(calldate, '$group_by_field_php[0]')"; |
|---|
| 671 |
$graph_col_title = _("Month"); |
|---|
| 672 |
break; |
|---|
| 673 |
case "day_of_week": |
|---|
| 674 |
$group_by_field_php = array('%w - %A',20,''); |
|---|
| 675 |
$group_by_field = "DATE_FORMAT( calldate, '%W' )"; |
|---|
| 676 |
$graph_col_title = _("Day of week"); |
|---|
| 677 |
break; |
|---|
| 678 |
case "minutes1": |
|---|
| 679 |
$group_by_field_php = array( '%Y-%m-%d %H:%M', 16, '' ); |
|---|
| 680 |
$group_by_field = "DATE_FORMAT(calldate, '%Y-%m-%d %H:%i')"; |
|---|
| 681 |
$graph_col_title = _("Minute"); |
|---|
| 682 |
break; |
|---|
| 683 |
case "minutes10": |
|---|
| 684 |
$group_by_field_php = array('%Y-%m-%d %H:%M',15,'0'); |
|---|
| 685 |
$group_by_field = "CONCAT(SUBSTR(DATE_FORMAT(calldate, '%Y-%m-%d %H:%i'),1,15), '0')"; |
|---|
| 686 |
$graph_col_title = _("10 Minutes"); |
|---|
| 687 |
break; |
|---|
| 688 |
case "day": |
|---|
| 689 |
default: |
|---|
| 690 |
$group_by_field_php = array('%Y-%m-%d',10,''); |
|---|
| 691 |
$group_by_field = "DATE_FORMAT(calldate, '$group_by_field_php[0]')"; |
|---|
| 692 |
$graph_col_title = _("Day"); |
|---|
| 693 |
} |
|---|
| 694 |
|
|---|
| 695 |
if ( isset($_POST['need_chart']) && $_POST['need_chart'] == 'true' ) { |
|---|
| 696 |
$query2 = "SELECT $group_by_field AS group_by_field, count(*) AS total_calls, sum(duration) AS total_duration FROM $db_name.$db_table_name $where GROUP BY group_by_field ORDER BY group_by_field ASC LIMIT $result_limit"; |
|---|
| 697 |
$result2 = $dbcdr->getAll($query2, DB_FETCHMODE_ASSOC); |
|---|
| 698 |
|
|---|
| 699 |
$tot_calls = 0; |
|---|
| 700 |
$tot_duration = 0; |
|---|
| 701 |
$max_calls = 0; |
|---|
| 702 |
$max_duration = 0; |
|---|
| 703 |
$tot_duration_secs = 0; |
|---|
| 704 |
$result_array = array(); |
|---|
| 705 |
foreach($result2 as $row) { |
|---|
| 706 |
$tot_duration_secs += $row['total_duration']; |
|---|
| 707 |
$tot_calls += $row['total_calls']; |
|---|
| 708 |
if ( $row['total_calls'] > $max_calls ) { |
|---|
| 709 |
$max_calls = $row['total_calls']; |
|---|
| 710 |
} |
|---|
| 711 |
if ( $row['total_duration'] > $max_duration ) { |
|---|
| 712 |
$max_duration = $row['total_duration']; |
|---|
| 713 |
} |
|---|
| 714 |
array_push($result_array,$row); |
|---|
| 715 |
} |
|---|
| 716 |
$tot_duration = sprintf('%02d', intval($tot_duration_secs/60)).':'.sprintf('%02d', intval($tot_duration_secs%60)); |
|---|
| 717 |
|
|---|
| 718 |
if ( $tot_calls ) { |
|---|
| 719 |
$html = "<p class=\"center title\">"._("Call Detail Record - Call Graph by")." ".$graph_col_title."</p><table class=\"cdr\">"; |
|---|
| 720 |
$html .= "<tr><th class=\"end_col\">". $graph_col_title . "</th>"; |
|---|
| 721 |
$html .= "<th class=\"center_col\">"._("Total Calls").": ". $tot_calls ." / "._("Max Calls").": ". $max_calls ." / "._("Total Duration").": ". $tot_duration ."</th>"; |
|---|
| 722 |
$html .= "<th class=\"end_col\">"._("Average Call Time")."</th>"; |
|---|
| 723 |
$html .= "<th class=\"img_col\"><a href=\"#CDR\" title=\""._("Go to the top of the CDR table")."\"><img src=\"images/scrollup.gif\" alt=\"CDR Table\" /></a></th>"; |
|---|
| 724 |
$html .= "<th class=\"img_col\"><a href=\"#Graph\" title=\""._("Go to the CDR Graph")."\"><img src=\"images/scrolldown.gif\" alt=\"CDR Graph\" /></a></th>"; |
|---|
| 725 |
$html .= "</tr>"; |
|---|
| 726 |
echo $html; |
|---|
| 727 |
|
|---|
| 728 |
foreach ($result_array as $row) { |
|---|
| 729 |
$avg_call_time = sprintf('%02d', intval(($row['total_duration']/$row['total_calls'])/60)).':'.sprintf('%02d', intval($row['total_duration']/$row['total_calls']%60)); |
|---|
| 730 |
$bar_calls = $row['total_calls']/$max_calls*100; |
|---|
| 731 |
$percent_tot_calls = intval($row['total_calls']/$tot_calls*100); |
|---|
| 732 |
$bar_duration = $row['total_duration']/$max_duration*100; |
|---|
| 733 |
$percent_tot_duration = intval($row['total_duration']/$tot_duration_secs*100); |
|---|
| 734 |
$html_duration = sprintf('%02d', intval($row['total_duration']/60)).':'.sprintf('%02d', intval($row['total_duration']%60)); |
|---|
| 735 |
echo " <tr>\n"; |
|---|
| 736 |
echo " <td class=\"end_col\">".$row['group_by_field']."</td><td class=\"center_col\"><div class=\"bar_calls\" style=\"width : $bar_calls%\">".$row['total_calls']." - $percent_tot_calls%</div><div class=\"bar_duration\" style=\"width : $bar_duration%\">$html_duration - $percent_tot_duration%</div></td><td class=\"chart_data\">$avg_call_time</td>\n"; |
|---|
| 737 |
echo " <td></td>\n"; |
|---|
| 738 |
echo " <td></td>\n"; |
|---|
| 739 |
echo " </tr>\n"; |
|---|
| 740 |
} |
|---|
| 741 |
echo "</table>"; |
|---|
| 742 |
} |
|---|
| 743 |
} |
|---|
| 744 |
if ( isset($_POST['need_chart_cc']) && $_POST['need_chart_cc'] == 'true' ) { |
|---|
| 745 |
$date_range = "( (calldate BETWEEN $startdate AND $enddate) or (calldate + interval duration second BETWEEN $startdate AND $enddate) or ( calldate + interval duration second >= $enddate AND calldate <= $startdate ) )"; |
|---|
| 746 |
$where = "WHERE $date_range $channel $dstchannel $src $clid $dst $userfield $accountcode $disposition $duration"; |
|---|
| 747 |
|
|---|
| 748 |
$tot_calls = 0; |
|---|
| 749 |
$max_calls = 0; |
|---|
| 750 |
$result_array_cc = array(); |
|---|
| 751 |
$result_array = array(); |
|---|
| 752 |
if ( strpos($group_by_field,'DATE_FORMAT') === false ) { |
|---|
| 753 |
|
|---|
| 754 |
$query3 = "SELECT $group_by_field AS group_by_field, count(*) AS total_calls, unix_timestamp(calldate) AS ts, duration FROM $db_name.$db_table_name $where GROUP BY group_by_field, unix_timestamp(calldate) ORDER BY group_by_field ASC LIMIT $result_limit"; |
|---|
| 755 |
$result3 = $dbcdr->getAll($query3, DB_FETCHMODE_ASSOC); |
|---|
| 756 |
$group_by_str = ''; |
|---|
| 757 |
foreach($result3 as $row) { |
|---|
| 758 |
if ( $group_by_str != $row['group_by_field'] ) { |
|---|
| 759 |
$group_by_str = $row['group_by_field']; |
|---|
| 760 |
$result_array = array(); |
|---|
| 761 |
} |
|---|
| 762 |
for ( $i=$row['ts']; $i<=$row['ts']+$row['duration']; ++$i ) { |
|---|
| 763 |
if ( isset($result_array[ "$i" ]) ) { |
|---|
| 764 |
$result_array[ "$i" ] += $row['total_calls']; |
|---|
| 765 |
} else { |
|---|
| 766 |
$result_array[ "$i" ] = $row['total_calls']; |
|---|
| 767 |
} |
|---|
| 768 |
if ( $max_calls < $result_array[ "$i" ] ) { |
|---|
| 769 |
$max_calls = $result_array[ "$i" ]; |
|---|
| 770 |
} |
|---|
| 771 |
if ( ! isset($result_array_cc[ $row['group_by_field'] ]) || $result_array_cc[ $row['group_by_field'] ][1] < $result_array[ "$i" ] ) { |
|---|
| 772 |
$result_array_cc[$row['group_by_field']][0] = $i; |
|---|
| 773 |
$result_array_cc[$row['group_by_field']][1] = $result_array[ "$i" ]; |
|---|
| 774 |
} |
|---|
| 775 |
} |
|---|
| 776 |
$tot_calls += $row['total_calls']; |
|---|
| 777 |
} |
|---|
| 778 |
} else { |
|---|
| 779 |
|
|---|
| 780 |
$query3 = "SELECT unix_timestamp(calldate) AS ts, duration FROM $db_name.$db_table_name $where ORDER BY unix_timestamp(calldate) ASC LIMIT $result_limit"; |
|---|
| 781 |
$result3 = $dbcdr->getAll($query3, DB_FETCHMODE_ASSOC); |
|---|
| 782 |
$group_by_str = ''; |
|---|
| 783 |
foreach($result3 as $row) { |
|---|
| 784 |
$group_by_str_cur = substr(strftime($group_by_field_php[0],$row['ts']),0,$group_by_field_php[1]) . $group_by_field_php[2]; |
|---|
| 785 |
if ( $group_by_str_cur != $group_by_str ) { |
|---|
| 786 |
if ( $group_by_str ) { |
|---|
| 787 |
for ( $i=$start_timestamp; $i<$row['ts']; ++$i ) { |
|---|
| 788 |
if ( ! isset($result_array_cc[ "$group_by_str" ]) || ( isset($result_array["$i"]) && $result_array_cc[ "$group_by_str" ][1] < $result_array["$i"] ) ) { |
|---|
| 789 |
$result_array_cc[ "$group_by_str" ][0] = $i; |
|---|
| 790 |
$result_array_cc[ "$group_by_str" ][1] = isset($result_array["$i"]) ? $result_array["$i"] : 0; |
|---|
| 791 |
} |
|---|
| 792 |
unset( $result_array[$i] ); |
|---|
| 793 |
} |
|---|
| 794 |
$start_timestamp = $row['ts']; |
|---|
| 795 |
} |
|---|
| 796 |
$group_by_str = $group_by_str_cur; |
|---|
| 797 |
} |
|---|
| 798 |
for ( $i=$row['ts']; $i<=$row['ts']+$row['duration']; ++$i ) { |
|---|
| 799 |
if ( isset($result_array["$i"]) ) { |
|---|
| 800 |
++$result_array["$i"]; |
|---|
| 801 |
} else { |
|---|
| 802 |
$result_array["$i"]=1; |
|---|
| 803 |
} |
|---|
| 804 |
if ( $max_calls < $result_array["$i"] ) { |
|---|
| 805 |
$max_calls = $result_array["$i"]; |
|---|
| 806 |
} |
|---|
| 807 |
} |
|---|
| 808 |
$tot_calls++; |
|---|
| 809 |
} |
|---|
| 810 |
for ( $i=$start_timestamp; $i<=$end_timestamp; ++$i ) { |
|---|
| 811 |
$group_by_str = substr(strftime($group_by_field_php[0],$i),0,$group_by_field_php[1]) . $group_by_field_php[2]; |
|---|
| 812 |
if ( ! isset($result_array_cc[ "$group_by_str" ]) || ( isset($result_array["$i"]) && $result_array_cc[ "$group_by_str" ][1] < $result_array["$i"] ) ) { |
|---|
| 813 |
$result_array_cc[ "$group_by_str" ][0] = $i; |
|---|
| 814 |
$result_array_cc[ "$group_by_str" ][1] = isset($result_array["$i"]) ? $result_array["$i"] : 0; |
|---|
| 815 |
} |
|---|
| 816 |
} |
|---|
| 817 |
} |
|---|
| 818 |
if ( $tot_calls ) { |
|---|
| 819 |
$html = "<p class=\"center title\">"._("Call Detail Record - Concurrent Calls by")." ".$graph_col_title."</p><table class=\"cdr\">"; |
|---|
| 820 |
$html .= "<tr><th class=\"end_col\">". $graph_col_title . "</th>"; |
|---|
| 821 |
$html .= "<th class=\"center_col\">"._("Total Calls").": ". $tot_calls ." / "._("Max Calls").": ". $max_calls ."</th>"; |
|---|
| 822 |
$html .= "<th class=\"end_col\">"._("Time")."</th>"; |
|---|
| 823 |
$html .= "</tr>"; |
|---|
| 824 |
echo $html; |
|---|
| 825 |
|
|---|
| 826 |
ksort($result_array_cc); |
|---|
| 827 |
|
|---|
| 828 |
foreach ( array_keys($result_array_cc) as $group_by_key ) { |
|---|
| 829 |
$full_time = strftime( '%Y-%m-%d %H:%M:%S', $result_array_cc[ "$group_by_key" ][0] ); |
|---|
| 830 |
$group_by_cur = $result_array_cc[ "$group_by_key" ][1]; |
|---|
| 831 |
$bar_calls = $group_by_cur/$max_calls*100; |
|---|
| 832 |
echo " <tr>\n"; |
|---|
| 833 |
echo " <td class=\"end_col\">$group_by_key</td><td class=\"center_col\"><div class=\"bar_calls\" style=\"width : $bar_calls%\"> $group_by_cur</div></td><td>$full_time</td>\n"; |
|---|
| 834 |
echo " </tr>\n"; |
|---|
| 835 |
} |
|---|
| 836 |
|
|---|
| 837 |
echo "</table>"; |
|---|
| 838 |
} |
|---|
| 839 |
} |
|---|
| 840 |
|
|---|
| 841 |
?> |
|---|
| 842 |
</div> |
|---|
| 843 |
|
|---|