Add voicemail export

This commit is contained in:
FusionPBX
2024-07-23 22:59:58 -06:00
committed by GitHub
parent 46abe4897c
commit 1b2a47dd6c
4 changed files with 272 additions and 3 deletions

View File

@@ -78,6 +78,9 @@
$apps[$x]['permissions'][$y]['name'] = "voicemail_import";
$apps[$x]['permissions'][$y]['groups'][] = "superadmin";
$y++;
$apps[$x]['permissions'][$y]['name'] = "voicemail_export";
$apps[$x]['permissions'][$y]['groups'][] = "superadmin";
$y++;
$apps[$x]['permissions'][$y]['name'] = "voicemail_file";
$apps[$x]['permissions'][$y]['groups'][] = "superadmin";
$apps[$x]['permissions'][$y]['groups'][] = "admin";
@@ -739,4 +742,4 @@
$apps[$x]['db'][$y]['fields'][$z]['type']['mysql'] = "char(36)";
$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = "";
?>
?>

View File

@@ -156,6 +156,33 @@ $text['title-voicemail_import']['zh-cn'] = "语音信箱导入";
$text['title-voicemail_import']['ja-jp'] = "ボイスメールのインポート";
$text['title-voicemail_import']['ko-kr'] = "음성 메일 가져오기";
$text['title-voicemail_export']['en-us'] = "Voicemail Export";
$text['title-voicemail_export']['en-gb'] = "Voicemail Export";
$text['title-voicemail_export']['ar-eg'] = "التصدير";
$text['title-voicemail_export']['de-at'] = "Exportieren";
$text['title-voicemail_export']['de-ch'] = "Exportieren";
$text['title-voicemail_export']['de-de'] = "Exportieren";
$text['title-voicemail_export']['el-gr'] = "Εξαγωγή προορισμού";
$text['title-voicemail_export']['ek-gr'] = "Εξαγωγή";
$text['title-voicemail_export']['es-cl'] = "Exportar";
$text['title-voicemail_export']['es-mx'] = "Exportar";
$text['title-voicemail_export']['fr-ca'] = "Exporter";
$text['title-voicemail_export']['fr-fr'] = "Exporter";
$text['title-voicemail_export']['he-il'] = "יעד היצוא";
$text['title-voicemail_export']['it-it'] = "Esporta";
$text['title-voicemail_export']['nl-nl'] = "Bestemmingsexport";
$text['title-voicemail_export']['pl-pl'] = "Eksportuj";
$text['title-voicemail_export']['pt-br'] = "Exportar";
$text['title-voicemail_export']['pt-pt'] = "Exportar";
$text['title-voicemail_export']['ro-ro'] = "Export de destinație";
$text['title-voicemail_export']['ru-ru'] = "Экспорт";
$text['title-voicemail_export']['sv-se'] = "Export";
$text['title-voicemail_export']['uk-ua'] = "Експортувати";
$text['title-voicemail_export']['tr-tr'] = "Hedef Dışa Aktarma";
$text['title-voicemail_export']['zh-cn'] = "目的地出口";
$text['title-voicemail_export']['ja-jp'] = "宛先エクスポート";
$text['title-voicemail_export']['ko-kr'] = "대상 내보내기";
$text['option-voicemail_file_listen']['en-us'] = "Listen Link (Login Required)";
$text['option-voicemail_file_listen']['en-gb'] = "Listen Link (Login Required)";
$text['option-voicemail_file_listen']['ar-eg'] = "رابط الاستماع (تسجيل الدخول مطلوب)";
@@ -1480,6 +1507,33 @@ $text['header-voicemail_import']['zh-cn'] = "语音信箱导入";
$text['header-voicemail_import']['ja-jp'] = "ボイスメールのインポート";
$text['header-voicemail_import']['ko-kr'] = "음성 메일 가져오기";
$text['header-voicemail_export']['en-us'] = "Destination Export";
$text['header-voicemail_export']['en-gb'] = "Destination Export";
$text['header-voicemail_export']['ar-eg'] = "التصدير";
$text['header-voicemail_export']['de-at'] = "Exportieren";
$text['header-voicemail_export']['de-ch'] = "Exportieren";
$text['header-voicemail_export']['de-de'] = "Exportieren";
$text['header-voicemail_export']['el-gr'] = "Εξαγωγή προορισμού";
$text['header-voicemail_export']['ek-gr'] = "Εξαγωγή";
$text['header-voicemail_export']['es-cl'] = "Exportar";
$text['header-voicemail_export']['es-mx'] = "Exportar";
$text['header-voicemail_export']['fr-ca'] = "Exporter";
$text['header-voicemail_export']['fr-fr'] = "Exporter";
$text['header-voicemail_export']['he-il'] = "יעד היצוא";
$text['header-voicemail_export']['it-it'] = "Esporta";
$text['header-voicemail_export']['nl-nl'] = "Bestemmingsexport";
$text['header-voicemail_export']['pl-pl'] = "Eksportuj";
$text['header-voicemail_export']['pt-br'] = "Exportar";
$text['header-voicemail_export']['pt-pt'] = "Exportar";
$text['header-voicemail_export']['ro-ro'] = "Destinație Export Export Import";
$text['header-voicemail_export']['ru-ru'] = "Экспорт";
$text['header-voicemail_export']['sv-se'] = "Export";
$text['header-voicemail_export']['uk-ua'] = "Експортувати";
$text['header-voicemail_export']['tr-tr'] = "Hedef Dışa Aktarma";
$text['header-voicemail_export']['zh-cn'] = "目的地出口";
$text['header-voicemail_export']['ja-jp'] = "宛先エクスポート";
$text['header-voicemail_export']['ko-kr'] = "대상 내보내기";
$text['header-voicemail_option']['en-us'] = "Voicemail Option";
$text['header-voicemail_option']['en-gb'] = "Voicemail Option";
$text['header-voicemail_option']['ar-eg'] = "خيار البريد الصوتي";
@@ -1870,6 +1924,33 @@ $text['description-voicemail']['zh-cn'] = "语音信箱设置。";
$text['description-voicemail']['ja-jp'] = "ボイスメールの設定。";
$text['description-voicemail']['ko-kr'] = "음성사서함 설정.";
$text['description-voicemail_export']['en-us'] = "Select the fields you wish to include in the export.";
$text['description-voicemail_export']['en-gb'] = "Select the fields you wish to include in the export.";
$text['description-voicemail_export']['ar-eg'] = "حدد الحقول التي ترغب في تضمينها في التصدير.";
$text['description-voicemail_export']['de-at'] = "Wählen Sie die Felder aus, die Sie in den Export einbeziehen möchten.";
$text['description-voicemail_export']['de-ch'] = "Wählen Sie die Felder aus, die Sie in den Export einbeziehen möchten.";
$text['description-voicemail_export']['de-de'] = "Wählen Sie die Felder aus, die Sie in den Export einbeziehen möchten.";
$text['description-voicemail_export']['el-gr'] = "Επιλέξτε τα πεδία που θέλετε να συμπεριλάβετε στην εξαγωγή.";
$text['description-voicemail_export']['ek-gr'] = "Επιλέξτε τα πεδία που θέλετε να συμπεριλάβετε στην εξαγωγή.";
$text['description-voicemail_export']['es-cl'] = "Seleccione los campos que desea incluir en la exportación.";
$text['description-voicemail_export']['es-mx'] = "Seleccione los campos que desea incluir en la exportación.";
$text['description-voicemail_export']['fr-ca'] = "Sélectionnez les champs que vous souhaitez inclure dans l'exportation.";
$text['description-voicemail_export']['fr-fr'] = "Sélectionnez les champs que vous souhaitez inclure dans l'exportation.";
$text['description-voicemail_export']['he-il'] = "בחר את השדות שברצונך לכלול בייצוא.";
$text['description-voicemail_export']['it-it'] = "בחר את השדות שברצונך לכלול בייצוא.";
$text['description-voicemail_export']['nl-nl'] = "Selecteer de velden die u in de export wilt opnemen.";
$text['description-voicemail_export']['pl-pl'] = "Wybierz pola, które chcesz uwzględnić w eksporcie.";
$text['description-voicemail_export']['pt-br'] = "Selecione os campos que deseja incluir na exportação.";
$text['description-voicemail_export']['pt-pt'] = "Selecione os campos que deseja incluir na exportação.";
$text['description-voicemail_export']['ro-ro'] = "Selectați câmpurile pe care doriți să le includeți în export.";
$text['description-voicemail_export']['ru-ru'] = "Выберите поля, которые вы хотите включить в экспорт.";
$text['description-voicemail_export']['sv-se'] = "Välj de fält du vill inkludera i exporten.";
$text['description-voicemail_export']['uk-ua'] = "Виберіть поля, які потрібно включити в експорт.";
$text['description-voicemail_export']['tr-tr'] = "Dışa aktarmaya dahil etmek istediğiniz alanları seçin.";
$text['description-voicemail_export']['zh-cn'] = "选择您希望包含在导出中的字段。";
$text['description-voicemail_export']['ja-jp'] = "エクスポートに含めるフィールドを選択します。";
$text['description-voicemail_export']['ko-kr'] = "내보내기에 포함할 필드를 선택합니다.";
$text['description-read_epoch']['en-us'] = "Read";
$text['description-read_epoch']['en-gb'] = "Read";
$text['description-read_epoch']['ar-eg'] = "يقرأ";

View File

@@ -0,0 +1,182 @@
<?php
/*
FusionPBX
Version: MPL 1.1
The contents of this file are subject to the Mozilla Public License Version
1.1 (the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.mozilla.org/MPL/
Software distributed under the License is distributed on an "AS IS" basis,
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
for the specific language governing rights and limitations under the
License.
The Original Code is FusionPBX
The Initial Developer of the Original Code is
Mark J Crane <markjcrane@fusionpbx.com>
Portions created by the Initial Developer are Copyright (C) 2024
the Initial Developer. All Rights Reserved.
Contributor(s):
Mark J Crane <markjcrane@fusionpbx.com>
*/
//includes files
require_once dirname(__DIR__, 2) . "/resources/require.php";
require_once "resources/check_auth.php";
require_once "resources/paging.php";
//check permissions
if (permission_exists('voicemail_export')) {
//access granted
}
else {
echo "access denied";
exit;
}
//add multi-lingual support
$language = new text;
$text = $language->get();
//define available columns
$available_columns[] = 'domain_uuid';
$available_columns[] = 'voicemail_uuid ';
$available_columns[] = 'voicemail_id';
$available_columns[] = 'voicemail_password';
$available_columns[] = 'greeting_id';
$available_columns[] = 'voicemail_alternate_greet_id';
$available_columns[] = 'voicemail_recording_instructions';
$available_columns[] = 'voicemail_recording_options';
$available_columns[] = 'voicemail_mail_to';
$available_columns[] = 'voicemail_sms_to';
$available_columns[] = 'voicemail_transcription_enabled';
$available_columns[] = 'voicemail_attach_file';
$available_columns[] = 'voicemail_file';
$available_columns[] = 'voicemail_local_after_email';
$available_columns[] = 'voicemail_local_after_forward';
$available_columns[] = 'voicemail_enabled';
$available_columns[] = 'voicemail_description';
$available_columns[] = 'voicemail_name_base64';
$available_columns[] = 'voicemail_tutorial';
//define the functions
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");
}
//get the extensions from the database and send them as output
if (!empty($_REQUEST["column_group"]) && is_array($_REQUEST["column_group"]) && @sizeof($_REQUEST["column_group"]) != 0) {
//validate the token
$token = new token;
if (!$token->validate($_SERVER['PHP_SELF'])) {
message::add($text['message-invalid_token'],'negative');
header('Location: voicemail_export.php');
exit;
}
//validate submitted columns
foreach ($_REQUEST["column_group"] as $column_name) {
if (in_array($column_name, $available_columns)) {
$selected_columns[] = $column_name;
}
}
if (is_array($selected_columns) && @sizeof($selected_columns) != 0) {
$sql = "select ".implode(', ', $selected_columns)." from v_voicemails ";
$sql .= "where domain_uuid = :domain_uuid ";
$parameters['domain_uuid'] = $domain_uuid;
$database = new database;
$voicemails = $database->select($sql, $parameters, 'all');
unset($sql, $parameters, $selected_columns);
download_send_headers("voicemail_export_".date("Y-m-d").".csv");
echo array2csv($voicemails);
exit;
}
}
//create token
$object = new token;
$token = $object->create($_SERVER['PHP_SELF']);
//include the header
$document['title'] = $text['title-voicemail_export'];
require_once "resources/header.php";
//show the content
echo "<form method='post' name='frm' id='frm'>\n";
echo "<div class='action_bar' id='action_bar'>\n";
echo " <div class='heading'><b>".$text['header-voicemail_export']."</b></div>\n";
echo " <div class='actions'>\n";
echo button::create(['type'=>'button','label'=>$text['button-back'],'icon'=>$_SESSION['theme']['button_icon_back'],'id'=>'btn_back','link'=>'voicemails.php']);
echo button::create(['type'=>'submit','label'=>$text['button-export'],'icon'=>$_SESSION['theme']['button_icon_export'],'id'=>'btn_save','style'=>'margin-left: 15px;']);
echo " </div>\n";
echo " <div style='clear: both;'></div>\n";
echo "</div>\n";
echo $text['description-voicemail_export'];
echo "<br /><br />\n";
echo "<table class='list'>\n";
echo "<tr class='list-header'>\n";
echo " <th class='checkbox'>\n";
echo " <input type='checkbox' id='checkbox_all' name='checkbox_all' onclick='list_all_toggle();' ".(empty($available_columns) ? "style='visibility: hidden;'" : null).">\n";
echo " </th>\n";
echo " <th>".$text['label-column_name']."</th>\n";
echo "</tr>\n";
if (is_array($available_columns) && @sizeof($available_columns) != 0) {
$x = 0;
foreach ($available_columns as $column_name) {
$list_row_onclick = "if (!this.checked) { document.getElementById('checkbox_all').checked = false; }";
echo "<tr class='list-row' href='".($list_row_url ?? null)."'>\n";
echo " <td class='checkbox'>\n";
echo " <input type='checkbox' name='column_group[]' id='checkbox_".$x."' value=\"".$column_name."\" onclick=\"".$list_row_onclick."\">\n";
echo " </td>\n";
echo " <td onclick=\"document.getElementById('checkbox_".$x."').checked = document.getElementById('checkbox_".$x."').checked ? false : true; ".$list_row_onclick."\">".$column_name."</td>";
echo "</tr>";
$x++;
}
}
echo "</table>\n";
echo "<br />\n";
echo "<input type='hidden' name='".$token['name']."' value='".$token['hash']."'>\n";
echo "</form>\n";
//include the footer
require_once "resources/footer.php";
?>

View File

@@ -204,7 +204,10 @@
echo " <div class='heading'><b>".$text['title-voicemails']." (".$num_rows.")</b></div>\n";
echo " <div class='actions'>\n";
if (permission_exists('voicemail_import')) {
echo button::create(['type'=>'button','label'=>$text['button-import'],'icon'=>$_SESSION['theme']['button_icon_import'],'style'=>'margin-right: 15px;','link'=>'voicemail_imports.php']);
echo button::create(['type'=>'button','label'=>$text['button-import'],'icon'=>$_SESSION['theme']['button_icon_import'],'style'=>'','link'=>'voicemail_imports.php']);
}
if (permission_exists('voicemail_export')) {
echo button::create(['type'=>'button','label'=>$text['button-export'],'icon'=>$_SESSION['theme']['button_icon_export'],'style'=>'margin-right: 15px;','link'=>'voicemail_export.php']);
}
if (permission_exists('voicemail_add')) {
echo button::create(['type'=>'button','label'=>$text['button-add'],'icon'=>$_SESSION['theme']['button_icon_add'],'id'=>'btn_add','link'=>'voicemail_edit.php']);
@@ -354,4 +357,4 @@
//include the footer
require_once "resources/footer.php";
?>
?>