From 940a2b9c7676656e333aafa8cc987601372f888b Mon Sep 17 00:00:00 2001 From: andycol Date: Sat, 22 Apr 2017 18:22:21 +0200 Subject: [PATCH] Add export to Pin Numbers application (#2126) * Add files via upload * Update pin_numbers.php * Create pin_download.php * Delete {$mac}.cfg * Update pin_numbers.php * fix status not displaying any result the Status block was showing as blank even if enabled/disabled This will now fix it --- app/call_flows/call_flows.php | 3 +- app/pin_numbers/pin_download.php | 144 +++++++++++++++++++++++++++++++ app/pin_numbers/pin_numbers.php | 4 +- 3 files changed, 148 insertions(+), 3 deletions(-) create mode 100644 app/pin_numbers/pin_download.php diff --git a/app/call_flows/call_flows.php b/app/call_flows/call_flows.php index db3a5fa96d..27b7476455 100644 --- a/app/call_flows/call_flows.php +++ b/app/call_flows/call_flows.php @@ -167,7 +167,7 @@ $tr_link = "href='call_flow_edit.php?id=".$row['call_flow_uuid']."'"; } echo "\n"; - echo " "; + //echo " "; if ($row['call_flow_status'] != "false") { echo $row['call_flow_label']; } @@ -177,6 +177,7 @@ echo " \n"; echo " \n"; //echo " ".$row['call_flow_name']." \n"; + echo " ".$row['call_flow_status']." \n"; echo " ".$row['call_flow_extension']." \n"; echo " ".$row['call_flow_feature_code']." \n"; //echo " ".$row['call_flow_context']." \n"; diff --git a/app/pin_numbers/pin_download.php b/app/pin_numbers/pin_download.php new file mode 100644 index 0000000000..d347fc3dd1 --- /dev/null +++ b/app/pin_numbers/pin_download.php @@ -0,0 +1,144 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +include "root.php"; +require_once "resources/require.php"; +require_once "resources/check_auth.php"; +require_once "resources/paging.php"; +if (if_group("superadmin")) { + //access granted +} +else { + echo "access denied"; + exit; +} + +//add multi-lingual support +$language = new text; +$text = $language->get(); + +function array2csv(array &$array) +{ + if (count($array) == 0) { + return null; + } + ob_start(); + $df = fopen("php://output", 'w'); + fputcsv($df, array_keys(reset($array))); + foreach ($array as $row) { + fputcsv($df, $row); + } + fclose($df); + return ob_get_clean(); +} + +function download_send_headers($filename) { + // disable caching + $now = gmdate("D, d M Y H:i:s"); + header("Expires: Tue, 03 Jul 2001 06:00:00 GMT"); + header("Cache-Control: max-age=0, no-cache, must-revalidate, proxy-revalidate"); + header("Last-Modified: {$now} GMT"); + + // force download + header("Content-Type: application/force-download"); + header("Content-Type: application/octet-stream"); + header("Content-Type: application/download"); + + // disposition / encoding on response body + header("Content-Disposition: attachment;filename={$filename}"); + header("Content-Transfer-Encoding: binary"); +} + +if (isset($_REQUEST["column_group"])) { + + + $columns = implode(",",$_REQUEST["column_group"]); + $sql = "select " . $columns . " from v_pin_numbers "; + $sql .= " where domain_uuid = '".$domain_uuid."' "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $pin_numbers = $prep_statement->fetchAll(PDO::FETCH_ASSOC); + unset ($sql, $prep_statement); +// print_r($pin_numbers); + + download_send_headers("data_export_" . date("Y-m-d") . ".csv"); + echo array2csv($pin_numbers); + die(); + +} + +$columns[] = 'pin_number_uuid'; +$columns[] = 'domain_uuid'; +$columns[] = 'pin_number'; +$columns[] = 'accountcode'; +$columns[] = 'enabled'; +$columns[] = 'description'; + +$c = 0; +$row_style["0"] = "row_style0"; +$row_style["1"] = "row_style1"; + +//begin the page content + require_once "resources/header.php"; + + echo "
\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + foreach ($columns as $value) { + echo "\n"; + echo " "; + echo " "; + echo " "; + echo ""; + if ($c==0) { $c=1; } else { $c=0; } + } + + echo " \n"; + echo " \n"; + echo " "; + + echo "
"; + echo " Column Name"; + echo " Description"; + echo "
"; + echo " $value"; + echo ""; + echo "
\n"; + echo "
"; + echo " \n"; + echo "
"; + echo "

"; + echo "
"; + +//include the footer + require_once "resources/footer.php"; +?> + diff --git a/app/pin_numbers/pin_numbers.php b/app/pin_numbers/pin_numbers.php index f34f3f30b6..56fee3d31e 100644 --- a/app/pin_numbers/pin_numbers.php +++ b/app/pin_numbers/pin_numbers.php @@ -102,6 +102,7 @@ $row_style["1"] = "row_style1"; //show the content + echo "\n"; echo "\n"; echo " \n"; echo " \n"; @@ -182,5 +183,4 @@ //include the footer require_once "resources/footer.php"; - -?> \ No newline at end of file +?>
".$text['title-pin_numbers']."