From 1b2a47dd6c9f4a9696a4ac098b2ad1e2529d9269 Mon Sep 17 00:00:00 2001 From: FusionPBX Date: Tue, 23 Jul 2024 22:59:58 -0600 Subject: [PATCH] Add voicemail export --- app/voicemails/app_config.php | 5 +- app/voicemails/app_languages.php | 81 +++++++++++++ app/voicemails/voicemail_export.php | 182 ++++++++++++++++++++++++++++ app/voicemails/voicemails.php | 7 +- 4 files changed, 272 insertions(+), 3 deletions(-) create mode 100644 app/voicemails/voicemail_export.php diff --git a/app/voicemails/app_config.php b/app/voicemails/app_config.php index 933ffef18c..9233f060e2 100644 --- a/app/voicemails/app_config.php +++ b/app/voicemails/app_config.php @@ -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'] = ""; -?> +?> \ No newline at end of file diff --git a/app/voicemails/app_languages.php b/app/voicemails/app_languages.php index 56023fad08..bfc9aab2b0 100644 --- a/app/voicemails/app_languages.php +++ b/app/voicemails/app_languages.php @@ -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'] = "يقرأ"; diff --git a/app/voicemails/voicemail_export.php b/app/voicemails/voicemail_export.php new file mode 100644 index 0000000000..76c92ae138 --- /dev/null +++ b/app/voicemails/voicemail_export.php @@ -0,0 +1,182 @@ + + Portions created by the Initial Developer are Copyright (C) 2024 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ + +//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 "
\n"; + + echo "
\n"; + echo "
".$text['header-voicemail_export']."
\n"; + echo "
\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 "
\n"; + echo "
\n"; + echo "
\n"; + + echo $text['description-voicemail_export']; + echo "

\n"; + + echo "\n"; + echo "\n"; + echo " \n"; + echo " \n"; + echo "\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 "\n"; + echo " \n"; + echo " "; + echo ""; + $x++; + } + } + + echo "
\n"; + echo " \n"; + echo " ".$text['label-column_name']."
\n"; + echo " \n"; + echo " ".$column_name."
\n"; + echo "
\n"; + echo "\n"; + echo "
\n"; + +//include the footer + require_once "resources/footer.php"; + +?> \ No newline at end of file diff --git a/app/voicemails/voicemails.php b/app/voicemails/voicemails.php index 593b6521d8..3850f0d9d2 100644 --- a/app/voicemails/voicemails.php +++ b/app/voicemails/voicemails.php @@ -204,7 +204,10 @@ echo "
".$text['title-voicemails']." (".$num_rows.")
\n"; echo "
\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"; -?> +?> \ No newline at end of file