XML CDR add call direction to the advanced search

This commit is contained in:
Mark Crane 2014-07-17 17:35:14 +00:00
parent 5c5ec5e4f6
commit 14ca8e1963
2 changed files with 50 additions and 14 deletions

View File

@ -17,7 +17,7 @@
The Initial Developer of the Original Code is
Mark J Crane <markjcrane@fusionpbx.com>
Portions created by the Initial Developer are Copyright (C) 2008-2014
Portions created by the Initial Developer are Copyright (C) 2008-2012
the Initial Developer. All Rights Reserved.
Contributor(s):
@ -314,6 +314,14 @@ else {
require_once "app/billings/functions.php";
require_once "resources/classes/database.php";
$database = new database;
$database->table = "v_billings";
$tv = (strlen($_GET["accountcode"])?$_GET["accountcode"]:$_SESSION[domain_name]);
$database->sql = "SELECT currency from v_billings WHERE type_value='$tv'";
$database->result = $database->execute();
$currency = (strlen($database->result[0]['currency'])?$database->result[0]['currency']:'USD');
unset($database->sql);
unset($database->result);
}
if ($result_count > 0) {
foreach($result as $row) {
@ -440,28 +448,26 @@ else {
if (file_exists($_SERVER['DOCUMENT_ROOT'].PROJECT_PATH."/app/billings/app_config.php")){
$database->table = "v_xml_cdr";
$accountcode = (strlen($row["accountcode"])?$row["accountcode"]:$_SESSION[domain_name]);
$database->sql = "SELECT currency FROM v_billings WHERE type_value='$accountcode'";
$database->result = $database->execute();
$billing_currency = (strlen($database->result[0]['currency'])?$database->result[0]['currency']:'USD');
unset($database->sql);
unset($database->result);
$price = $row['call_sell'];
$lcr_direction = (strlen($row['direction'])?$row['direction']:"outbound");
$sell_price = $row['call_sell'];
$lcr_direction = (strlen($row['direction'])?$row['direction']:"outbound");
$n = (($lcr_direction == "inbound")?$row['caller_id_number']:$row['destination_number']);
if ($lcr_direction == "inbound"){
$n = $row['caller_id_number'];
}
$database->table = "v_lcr";
$database->sql = "SELECT currency FROM v_lcr WHERE v_lcr.carrier_uuid= '' AND v_lcr.enabled='true' AND v_lcr.lcr_direction='$lcr_direction' AND v_lcr.digits IN (".number_series($n).") ORDER BY digits DESC, rate ASC, date_start DESC LIMIT 1";
$database->sql = "SELECT currency FROM v_lcr WHERE v_lcr.carrier_uuid= '' AND v_lcr.lcr_direction='$lcr_direction' AND v_lcr.digits IN (".number_series($n).") ORDER BY digits DESC, rate ASC, date_start DESC LIMIT 1";
$database->result = $database->execute();
//print "<pre>"; print_r($database->result); print "[".$database->result[0]['currency']."]"; print "</pre>";
$lcr_currency = ((is_string($database->result[0]['currency']) && strlen($database->result[0]['currency']))?$database->result[0]['currency']:'USD'); //billed currency
$billed_currency = ((is_string($database->result[0]['currency']) && strlen($database->result[0]['currency']))?$database->result[0]['currency']:'USD'); //billed currency
unset($database->sql);
unset($database->result);
$price = currency_convert($sell_price, $billing_currency, $lcr_currency);
echo " <td valign='top' class='".$row_style[$c]."'>".number_format($price,6)." $billing_currency</td>\n";
$price = currency_convert($price, $currency, $billed_currency);
echo " <td valign='top' class='".$row_style[$c]."'>".number_format($price,6)." $billed_currency</td>\n";
}
if (permission_exists("xml_cdr_pdd")) {
echo " <td valign='top' class='".$row_style[$c]."'>".number_format($row['pdd_ms']/1000,2)."s</td>\n";
@ -509,4 +515,5 @@ else {
//show the footer
require_once "resources/footer.php";
?>
?>

View File

@ -34,7 +34,8 @@ else {
exit;
}
if (count($_POST)>0) {
if (count($_POST) > 0) {
$direction = $_POST["direction"];
$cdr_id = $_POST["cdr_id"];
$caller_id_name = $_POST["caller_id_name"];
$caller_id_number = $_POST["caller_id_number"];
@ -75,6 +76,34 @@ else {
echo "</td>\n";
echo "</tr>\n";
echo " <tr>\n";
echo " <td class='vncell' valign='top' nowrap='nowrap' width='30%'>\n";
echo " ".$text['label-direction']."\n";
echo " </td>\n";
echo " <td class='vtable' width='70%' align='left'>\n";
echo " <select name='direction' class='formfld'>\n";
echo " <option value=''></option>\n";
if ($direction == "inbound") {
echo " <option value='inbound' selected='selected'>".$text['label-inbound']."</option>\n";
}
else {
echo " <option value='inbound'>".$text['label-inbound']."</option>\n";
}
if ($direction == "outbound") {
echo " <option value='outbound' selected='selected'>".$text['label-outbound']."</option>\n";
}
else {
echo " <option value='outbound'>".$text['label-outbound']."</option>\n";
}
if ($direction == "local") {
echo " <option value='local' selected='selected'>".$text['label-local']."</option>\n";
}
else {
echo " <option value='local'>".$text['label-local']."</option>\n";
}
echo " </select>\n";
echo " </td>\n";
echo " </tr>\n";
echo " <tr>";
echo " <td class='vncell'>Source Name:</td>";
echo " <td class='vtable'><input type='text' class='formfld' name='caller_id_name' value='$caller_id_name'></td>";