In advanced -> default settings add the following cdr->format->text = xml,json and cdr->storage->text = db,dir

This commit is contained in:
Mark Crane
2014-06-14 07:07:04 +00:00
parent 0a37951438
commit 0d7e95a1e9
2 changed files with 45 additions and 15 deletions
+28 -11
View File
@@ -193,6 +193,7 @@
} }
//determine where the xml cdr will be archived //determine where the xml cdr will be archived
/*
$sql = "select * from v_vars "; $sql = "select * from v_vars ";
$sql .= "where var_name = 'xml_cdr_archive' "; $sql .= "where var_name = 'xml_cdr_archive' ";
$row = $db->query($sql)->fetch(); $row = $db->query($sql)->fetch();
@@ -217,14 +218,15 @@
$xml_cdr_archive = 'dir'; $xml_cdr_archive = 'dir';
break; break;
} }
*/
//if xml_cdr_archive is set to db then insert it. //save to the database in xml format
if ($xml_cdr_archive == "xml" || $xml_cdr_archive == "db") { if ($_SESSION['cdr']['format']['text'] == "xml" && $_SESSION['cdr']['storage']['text'] == "db") {
$database->fields['xml'] = check_str($xml_string); $database->fields['xml'] = check_str($xml_string);
} }
//if xml_cdr_archive is set to db then insert it. //save to the database in json format
if ($xml_cdr_archive == "json") { if ($_SESSION['cdr']['format']['text'] == "json" && $_SESSION['cdr']['storage']['text'] == "db") {
$database->fields['json'] = json_encode($xml); $database->fields['json'] = json_encode($xml);
} }
@@ -256,16 +258,24 @@
if(!file_exists($tmp_dir)) { if(!file_exists($tmp_dir)) {
mkdir($tmp_dir, 0777, true); mkdir($tmp_dir, 0777, true);
} }
$tmp_file = $uuid.'.xml'; if ($_SESSION['cdr']['format']['text'] == "xml") {
$fh = fopen($tmp_dir.'/'.$tmp_file, 'w'); $tmp_file = $uuid.'.xml';
fwrite($fh, $xml_string); $fh = fopen($tmp_dir.'/'.$tmp_file, 'w');
fwrite($fh, $xml_string);
}
else {
$tmp_file = $uuid.'.json';
$fh = fopen($tmp_dir.'/'.$tmp_file, 'w');
fwrite($fh, json_encode($xml));
}
fclose($fh); fclose($fh);
if ($debug) { if ($debug) {
echo $e->getMessage(); echo $e->getMessage();
} }
$error = "true"; $error = "true";
} }
//if xml_cdr_archive is set to dir, then store it.
if ($_SESSION['cdr']['storage']['text'] == "dir" && $error != "true") {
if ($xml_cdr_archive == "dir" && $error != "true") { if ($xml_cdr_archive == "dir" && $error != "true") {
if (strlen($uuid) > 0) { if (strlen($uuid) > 0) {
$tmp_time = strtotime($start_stamp); $tmp_time = strtotime($start_stamp);
@@ -276,9 +286,16 @@
if(!file_exists($tmp_dir)) { if(!file_exists($tmp_dir)) {
mkdir($tmp_dir, 0777, true); mkdir($tmp_dir, 0777, true);
} }
$tmp_file = $uuid.'.xml'; if ($_SESSION['cdr']['format']['text'] == "xml") {
$fh = fopen($tmp_dir.'/'.$tmp_file, 'w'); $tmp_file = $uuid.'.xml';
fwrite($fh, $xml_string); $fh = fopen($tmp_dir.'/'.$tmp_file, 'w');
fwrite($fh, $xml_string);
}
else {
$tmp_file = $uuid.'.json';
$fh = fopen($tmp_dir.'/'.$tmp_file, 'w');
fwrite($fh, json_encode($xml));
}
fclose($fh); fclose($fh);
} }
} }
+17 -4
View File
@@ -118,10 +118,23 @@ require_once "resources/paging.php";
foreach($result as $row) { foreach($result as $row) {
if ($previous_category != $row['default_setting_category']) { if ($previous_category != $row['default_setting_category']) {
echo "<tr><td colspan='4' align='left'>\n"; echo "<tr>\n";
if ($previous_category != '') { echo "<br /><br />"; } echo " <td colspan='4' align='left'>\n";
echo " <br />\n"; if ($previous_category != '') { echo " <br /><br />"; }
echo " <b>".ucfirst($row['default_setting_category'])."</b>&nbsp;</td></tr>\n"; echo " <br />\n";
echo " <b>\n";
if (strtolower($row['default_setting_category']) == "cdr") {
echo " CDR";
}
elseif (strtolower($row['default_setting_category']) == "ldap") {
echo " LDAP";
}
else {
echo " ".ucfirst($row['default_setting_category']);
}
echo " </b>\n";
echo " </td>\n";
echo "</tr>\n";
echo "<tr>\n"; echo "<tr>\n";
echo th_order_by('default_setting_subcategory', $text['label-subcategory'], $order_by, $order); echo th_order_by('default_setting_subcategory', $text['label-subcategory'], $order_by, $order);
echo th_order_by('default_setting_name', $text['label-type'], $order_by, $order); echo th_order_by('default_setting_name', $text['label-type'], $order_by, $order);