diff --git a/CRM/Admin/Form/Setting/DonrecSettings.php b/CRM/Admin/Form/Setting/DonrecSettings.php index 74cdf900..c41c32dc 100644 --- a/CRM/Admin/Form/Setting/DonrecSettings.php +++ b/CRM/Admin/Form/Setting/DonrecSettings.php @@ -59,6 +59,23 @@ function buildQuickForm( ) { ts('Packet size', array('domain' => 'de.systopia.donrec')), CRM_Donrec_Logic_Settings::get('donrec_packet_size')); + $this->addElement('text', + 'donrec_bcc_email', + ts('BCC Email', array('domain' => 'de.systopia.donrec')), + CRM_Donrec_Logic_Settings::get('donrec_bcc_email')); + $this->addRule('donrec_bcc_email', ts('Has to be a valid email address', array('domain' => 'de.systopia.donrec')), 'email'); + + $this->addElement('text', + 'donrec_return_path_email', + ts('Email Return Path', array('domain' => 'de.systopia.donrec')), + CRM_Donrec_Logic_Settings::get('donrec_return_path_email')); + $this->addRule('donrec_return_path_email', ts('Has to be a valid email address', array('domain' => 'de.systopia.donrec')), 'email'); + + $this->addElement('select', + 'donrec_email_template', + ts('Email Template', array('domain' => 'de.systopia.donrec')), + CRM_Donrec_Logic_Settings::getAllTemplates()); + $this->addButtons(array( array('type' => 'next', 'name' => ts('Save', array('domain' => 'de.systopia.donrec')), 'isDefault' => TRUE), @@ -80,6 +97,9 @@ public function setDefaultValues() { $defaults['selected_profile'] = 'Default'; $defaults['pdfinfo_path'] = CRM_Donrec_Logic_Settings::get('donrec_pdfinfo_path'); $defaults['packet_size'] = CRM_Donrec_Logic_Settings::get('donrec_packet_size'); + $defaults['donrec_email_template'] = CRM_Donrec_Logic_Settings::get('donrec_email_template'); + $defaults['donrec_return_path_email'] = CRM_Donrec_Logic_Settings::get('donrec_return_path_email'); + $defaults['donrec_bcc_email'] = CRM_Donrec_Logic_Settings::get('donrec_bcc_email'); return $defaults; } @@ -91,6 +111,9 @@ function postProcess() { // save generic settings CRM_Donrec_Logic_Settings::set('donrec_packet_size', $values['packet_size']); + CRM_Donrec_Logic_Settings::set('donrec_email_template', $values['donrec_email_template']); + CRM_Donrec_Logic_Settings::set('donrec_return_path_email', $values['donrec_return_path_email']); + CRM_Donrec_Logic_Settings::set('donrec_bcc_email', $values['donrec_bcc_email']); if ($values['pdfinfo_path']) { CRM_Donrec_Logic_Settings::set('donrec_pdfinfo_path', $values['pdfinfo_path']); } diff --git a/CRM/Donrec/Exporters/BasePDF.php b/CRM/Donrec/Exporters/BasePDF.php index 5137ffd5..53070984 100644 --- a/CRM/Donrec/Exporters/BasePDF.php +++ b/CRM/Donrec/Exporters/BasePDF.php @@ -55,8 +55,7 @@ public function exportSingle($snapshot_receipt, $is_test) { return FALSE; } else { // save file names for wrapup() - $this->postprocessPDF($result, $snapshot_receipt->getID()); - return TRUE; + return $this->postprocessPDF($result, $snapshot_receipt->getID(), $is_test); } } @@ -74,6 +73,8 @@ public function exportBulk($snapshot_receipt, $is_test) { /** * allows the subclasses to process the newly created PDF file */ - protected function postprocessPDF($file, $snapshot_line_id) {} + protected function postprocessPDF($file, $snapshot_line_id, $is_test) { + return TRUE; + } } diff --git a/CRM/Donrec/Exporters/EmailPDF.php b/CRM/Donrec/Exporters/EmailPDF.php new file mode 100644 index 00000000..d342b152 --- /dev/null +++ b/CRM/Donrec/Exporters/EmailPDF.php @@ -0,0 +1,309 @@ + 'de.systopia.donrec')); + } + + /** + * @return a html snippet that defines the options as form elements + */ + static function htmlOptions() { + return ''; + } + + /** + * @return the ID of this importer class + */ + public function getID() { + return 'EMAIL'; + } + + /** + * check whether all requirements are met to run this exporter + * + * @return array: + * 'is_error': set if there is a fatal error + * 'message': error message + */ + public function checkRequirements() { + // Check if email template is set up + $template_id = CRM_Donrec_Logic_Settings::getEmailTemplateID(); + if ($template_id) { + return array('is_error' => FALSE, 'message' => ''); + } else { + return array( + 'is_error' => TRUE, + 'message' => ts("Please select email template in the Donrec settings.", array('domain' => 'de.systopia.donrec')), + ); + } + } + + + /** + * allows the subclasses to process the newly created PDF file + */ + protected function postprocessPDF($file, $snapshot_line_id, $is_test) { + // find the receipt + $error = NULL; + $snapshot = CRM_Donrec_Logic_Snapshot::getSnapshotForLineID($snapshot_line_id); + if (!$snapshot) { + $error = 'snapshot error'; + } else { + $receipt = $snapshot->getLine($snapshot_line_id); + if (!$receipt) { + $error = 'snapshot error'; + } + } + + // try to send the email + if (!$error) { + $error = $this->sendEmail($receipt, $file, $is_test, $snapshot_line_id); + } + + if ($error) { + // create error activity + if (!$is_test) { + civicrm_api3('Activity', 'create', array( + 'activity_type_id' => $this->getEmailErrorActivityID(), + 'subject' => ts("Donation receipt not delivered", array('domain' => 'de.systopia.donrec')), + 'status_id' => CRM_Core_OptionGroup::getValue('activity_status', 'Scheduled', 'name'), + 'activity_date_time' => date('YmdHis'), + 'source_contact_id' => $receipt['created_by'], + 'target_id' => $receipt['contact_id'], + // 'assignee_contact_id'=> (int) $this->config->getAdminContactID(), + 'details' => $this->getErrorMessage($error), + )); + } + + // store the error in the process information (to be processed in wrap-up) + $this->updateProcessInformation($snapshot_line_id, array('email_error' => $error)); + + } // END if $error + return $error == NULL; + } + + + /** + * Will try to send the PDF to the given email + * + * @return NULL if all good, an error message string if it FAILED + */ + protected function sendEmail($receipt, $pdf_file, $is_test, $snapshot_line_id) { + try { + // load contact data + $contact = civicrm_api3('Contact', 'getsingle', array('id' => $receipt['contact_id'])); + + // load email address + if (empty($contact['email'])) { + return 'no email'; + } + + // load the domain + list($domainEmailName, $domainEmailAddress) = CRM_Core_BAO_Domain::getNameAndEmail(); + + // compile the attachment + $attachment = array('fullPath' => $pdf_file, + 'mime_type' => 'application/pdf', + 'cleanName' => ts("Donation Receipt.pdf", array('domain' => 'de.systopia.donrec'))); + + // register some variables + $smarty_variables = array( + 'receipt' => $receipt, + 'contact' => $contact); + + if ($is_test) { + // in test mode: create message + $this->updateProcessInformation($snapshot_line_id, array('sent' => $contact['email'])); + } else { + // in case this is required: make sure the bouce processing is temporarily changed + self::modifyBounceProcessing(); + + civicrm_api3('MessageTemplate', 'send', array( + 'id' => CRM_Donrec_Logic_Settings::getEmailTemplateID(), + 'contact_id' => $contact['id'], + 'to_name' => $contact['display_name'], + 'to_email' => $contact['email'], + 'from' => "\"{$domainEmailName}\" <{$domainEmailAddress}>", + 'template_params' => $smarty_variables, + 'attachments' => array($attachment), + 'bcc' => CRM_Donrec_Logic_Settings::get('donrec_bcc_email'), + )); + } + } catch (Exception $e) { + return $e->getMessage(); + } + return NULL; + } + + /** + * generate the final result + * + * @return array: + * 'is_error': set if there is a fatal error + * 'log': array with keys: 'type', 'level', 'timestamp', 'message' + * 'download_url: URL to download the result + * 'download_name: suggested file name for the download + */ + public function wrapUp($snapshot_id, $is_test, $is_bulk) { + $reply = array(); + $error_counters = array(); + + $snapshot = CRM_Donrec_Logic_Snapshot::get($snapshot_id); + $ids = $snapshot->getIds(); + foreach($ids as $id) { + $proc_info = $this->getProcessInformation($id); + if(!empty($proc_info['email_error'])) { + if (!isset($error_counters[$proc_info['email_error']])) { + $error_counters[$proc_info['email_error']] = 1; + } else { + $error_counters[$proc_info['email_error']] += 1; + } + } + if(!empty($proc_info['sent'])) { + $message = ts("Email would be sent to '%1' (test mode).", array( + 1 => $proc_info['sent'], + 'domain' => 'de.systopia.donrec')); + CRM_Donrec_Logic_Exporter::addLogEntry($reply, $message, CRM_Donrec_Logic_Exporter::LOG_TYPE_INFO); + } + } + + foreach ($error_counters as $error => $count) { + $error_msg = "{$count}x " . $this->getErrorMessage($error); + CRM_Donrec_Logic_Exporter::addLogEntry($reply, $error_msg, CRM_Donrec_Logic_Exporter::LOG_TYPE_ERROR); + } + + // in case there was temporary changes: roll back + self::rollbackBounceProcessing(); + + return $reply; + } + + /** + * Get the activity type id for email errors + * + * If no such activity exists, create a new one + */ + public function getEmailErrorActivityID() { + if ($this->activity_type_id === NULL) { + $this->activity_type_id = (int) CRM_Core_OptionGroup::getValue('activity_type', 'donrec_email_failed', 'name'); + if (!$this->activity_type_id) { + // create new activity type + $option_group = civicrm_api3('OptionGroup', 'getsingle', array('name' => 'activity_type')); + $activity_type = civicrm_api3('OptionValue', 'create', array( + 'option_group_id' => $option_group['id'], + 'name' => 'donrec_email_failed', + 'label' => ts("DonationReceipt Failure", array('domain' => 'de.systopia.donrec')), + )); + $this->activity_type_id = $activity_type['value']; + } + } + + return $this->activity_type_id; + } + + /** + * Will produce a human-readable version of the given error + */ + protected function getErrorMessage($error) { + switch ($error) { + + case 'snapshot error': + // no translation, as this shouldn't happen :) + return 'Internal error, problems with the snapshot. Please file a bug at https://github.com/systopia/de.systopia.donrec/issues'; + + case 'no email': + return ts("No valid email address found for this contact.", array('domain' => 'de.systopia.donrec')); + + default: + $error_msg = ts("Error was: ", array('domain' => 'de.systopia.donrec')); + $error_msg .= $error; + return $error_msg; + } + } + + /** + * If the setting donrec_return_path_email is set: + * - that email is set as the default bounce address, storing the old one + * - the task to send out newsletters will be disabled + * - the old values of the two settings above will be stored + */ + public static function modifyBounceProcessing() { + $stashed_settings = CRM_Donrec_Logic_Settings::get('donrec_email_stashed_settings'); + if (!empty($stashed_settings)) return; // the settings are already manipulated + + // check if somebody entered something + $custom_return_path = CRM_Donrec_Logic_Settings::get('donrec_return_path_email'); + if (empty($custom_return_path)) return; // nothing to be done here + + // disable running mail delivery jobs + $stashed_settings = array('disabled_jobs' => array()); + $active_jobs = civicrm_api3('Job', 'get', array( + 'api_entity' => 'job', + 'api_action' => 'process_mailing', + 'is_active' => 1)); + foreach ($active_jobs['values'] as $job) { + $stashed_settings['disabled_jobs'][] = $job['id']; + civicrm_api3('Job', 'create', array( + 'id' => $job['id'], + 'is_active' => 0)); + } + + // adjust the return path + $stashed_settings['modified_return_paths'] = array(); + $old_return_path = CRM_Core_DAO::executeQuery("SELECT id AS account_id, return_path FROM `civicrm_mail_settings` WHERE is_default=1;"); + while ($old_return_path->fetch()) { + $stashed_settings['modified_return_paths'][$old_return_path->account_id] = $old_return_path->return_path; + CRM_Core_DAO::executeQuery("UPDATE `civicrm_mail_settings` SET return_path=%1 WHERE id=%2;", array( + 1 => array($custom_return_path, 'String'), + 2 => array($old_return_path->account_id, 'Integer'))); + } + + // stash the changes + CRM_Donrec_Logic_Settings::set('donrec_email_stashed_settings', json_encode($stashed_settings)); + } + + /** + * If the modifyBounceProcessing had modified the settings, this should roll it back + */ + public static function rollbackBounceProcessing() { + $stashed_settings = CRM_Donrec_Logic_Settings::get('donrec_email_stashed_settings'); + if (empty($stashed_settings)) return; // no changes + + // decode data + $stashed_settings = json_decode($stashed_settings, TRUE); + + // re-enable the jobs + foreach ($stashed_settings['disabled_jobs'] as $job_id) { + civicrm_api3('Job', 'create', array('id' => $job_id, 'is_active' => 1)); + } + + // restore return paths + foreach ($stashed_settings['modified_return_paths'] as $account_id => $original_return_path) { + CRM_Core_DAO::executeQuery("UPDATE `civicrm_mail_settings` SET return_path=%1 WHERE id=%2;", array( + 1 => array($original_return_path, 'String'), + 2 => array($account_id, 'Integer'))); + } + + // clear stashed_settings + CRM_Donrec_Logic_Settings::set('donrec_email_stashed_settings', ''); + } +} diff --git a/CRM/Donrec/Exporters/GroupedPDF.php b/CRM/Donrec/Exporters/GroupedPDF.php index 955c0f8f..9512e595 100644 --- a/CRM/Donrec/Exporters/GroupedPDF.php +++ b/CRM/Donrec/Exporters/GroupedPDF.php @@ -83,12 +83,14 @@ public function checkRequirements() { /** * allows the subclasses to process the newly created PDF file */ - protected function postprocessPDF($file, $snapshot_line_id) { + protected function postprocessPDF($file, $snapshot_line_id, $is_test) { $pageCount = $this->getPDFPageCount($file); $this->updateProcessInformation($snapshot_line_id, array( 'pdf_file' => $file, 'pdf_pagecount' => $pageCount)); + + return TRUE; } /** diff --git a/CRM/Donrec/Exporters/PDF.php b/CRM/Donrec/Exporters/PDF.php index 508a9782..64104147 100644 --- a/CRM/Donrec/Exporters/PDF.php +++ b/CRM/Donrec/Exporters/PDF.php @@ -30,8 +30,9 @@ static function htmlOptions() { /** * allows the subclasses to process the newly created PDF file */ - protected function postprocessPDF($file, $snapshot_line_id) { + protected function postprocessPDF($file, $snapshot_line_id, $is_test) { $this->updateProcessInformation($snapshot_line_id, array('pdf_file' => $file)); + return TRUE; } diff --git a/CRM/Donrec/Logic/Engine.php b/CRM/Donrec/Logic/Engine.php index 2b5dc25a..21e3a317 100644 --- a/CRM/Donrec/Logic/Engine.php +++ b/CRM/Donrec/Logic/Engine.php @@ -196,12 +196,25 @@ public function nextStep() { // If it is the last do some wrap-up. // Otherwise mark the chunk as processed. //********************************** + $log_messages = array(); if (!$chunk) { foreach ($exporters as $exporter) { $result = $exporter->wrapUp($this->snapshot->getId(), $is_test, $is_bulk); + if (!empty($result['download_name']) && !empty($result['download_url'])) { $files[$exporter->getID()] = array($result['download_name'], $result['download_url']); } + + // collect appropriate error messages + if (!empty($result['log'])) { + foreach ($result['log'] as $log_entry) { + if ( $log_entry['type'] == 'ERROR' + || $log_entry['type'] == 'FATAL' + || ($is_test && $log_entry['type'] == 'INFO')) { + $log_messages[] = $log_entry; + } + } + } } } else { $this->snapshot->markChunkProcessed($chunk, $is_test, $is_bulk); @@ -210,7 +223,14 @@ public function nextStep() { // compile stats //********************************** $stats = $this->createStats(); - // create log-messages + $stats['log'] = $log_messages; + + // add exporter log messages + // foreach ($log_messages as $log_message) { + // CRM_Donrec_Logic_Exporter::addLogEntry($stats, $log_message['message'], $type, $log_message['timestamp']); + // } + + // create final log-message foreach ($exporter_results as $exporter_id => $result) { $msg = sprintf('%s processed %d items - %d succeeded, %d failed', $exporter_id, count($chunk), $result['success'], $result['failure']); $type = ($result['failure'])? 'ERROR' : 'INFO'; diff --git a/CRM/Donrec/Logic/Exporter.php b/CRM/Donrec/Logic/Exporter.php index 8e7d0914..cd4b48a0 100644 --- a/CRM/Donrec/Logic/Exporter.php +++ b/CRM/Donrec/Logic/Exporter.php @@ -25,7 +25,7 @@ abstract class CRM_Donrec_Logic_Exporter { * returns the list of implemented exporters */ public static function listExporters() { - return array('PDF', 'Dummy', 'CSV', 'GroupedPDF'); + return array('PDF', 'Dummy', 'CSV', 'GroupedPDF', 'EmailPDF'); } /** @@ -115,9 +115,12 @@ protected function updateProcessInformation($snapshot_item_id, $array) { /** * create a log entry and add to the give reply */ - public static function addLogEntry(&$reply, $message, $type=self::LOG_TYPE_INFO) { + public static function addLogEntry(&$reply, $message, $type=self::LOG_TYPE_INFO, $timestamp = NULL) { + if ($timestamp == NULL) { + $timestamp = date('Y-m-d H:i:s'); + } $reply['log'][] = array( - 'timestamp' => date('Y-m-d H:i:s'), + 'timestamp' => $timestamp, 'type' => $type, 'message' => $message ); diff --git a/CRM/Donrec/Logic/Settings.php b/CRM/Donrec/Logic/Settings.php index d8c4bb30..1ba66801 100644 --- a/CRM/Donrec/Logic/Settings.php +++ b/CRM/Donrec/Logic/Settings.php @@ -81,4 +81,18 @@ static function getLoggedInContactID() { } return $session->get('userID'); } + + /** + * Get the internal ID of the selected template for sending emails + * + * @return int + */ + public static function getEmailTemplateID() { + $template_id = (int) civicrm_api3('Setting', 'getvalue', array('name' => 'donrec_email_template')); + if ($template_id >= 1) { + return $template_id; + } else { + return NULL; + } + } } diff --git a/CRM/Donrec/Logic/Snapshot.php b/CRM/Donrec/Logic/Snapshot.php index e40d96ab..f5af8b46 100644 --- a/CRM/Donrec/Logic/Snapshot.php +++ b/CRM/Donrec/Logic/Snapshot.php @@ -40,6 +40,20 @@ public static function get($snapshot_id) { } } + /** + * get the snapshot of a given line_id + */ + public static function getSnapshotForLineID($snapshot_line_id) { + $snapshot_id = CRM_Core_DAO::singleValueQuery("SELECT `snapshot_id` FROM `donrec_snapshot` WHERE `id` = %1;", + array(1 => array($snapshot_line_id, 'Integer'))); + if ($snapshot_id) { + // no need to check if it exists, b/c if not the query would be empty + return new CRM_Donrec_Logic_Snapshot($snapshot_id); + } else { + return NULL; + } + } + /** * creates and returns a new snapshot object from the diff --git a/info.xml b/info.xml index cf7425a0..2f454ddc 100644 --- a/info.xml +++ b/info.xml @@ -9,8 +9,8 @@ endres@systopia.de 2017-02-15 - 1.4 - stable + 1.5.beta2 + beta 4.6 4.7 diff --git a/l10n/de.systopia.donrec.pot b/l10n/de.systopia.donrec.pot index 41d58134..31edbb5d 100644 --- a/l10n/de.systopia.donrec.pot +++ b/l10n/de.systopia.donrec.pot @@ -5,7 +5,7 @@ msgid "" msgstr "" "Project-Id-Version: de.systopia.donrec\n" -"POT-Creation-Date: 2016-04-06 18:13+0200\n" +"POT-Creation-Date: 2017-01-19 15:32+0100\n" "Language-Team: CiviCRM Translators \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" @@ -32,6 +32,7 @@ msgstr "" #: CRM/Admin/Form/Setting/DonrecSettings.php donrec.php #: templates/CRM/Admin/Form/Setting/DonrecSettings.tpl +#: templates/CRM/Donrec/Page/Tab.tpl msgid "Receipt ID" msgstr "" @@ -69,6 +70,22 @@ msgstr "" msgid "Packet size" msgstr "" +#: CRM/Admin/Form/Setting/DonrecSettings.php +msgid "BCC Email" +msgstr "" + +#: CRM/Admin/Form/Setting/DonrecSettings.php +msgid "Has to be a valid email address" +msgstr "" + +#: CRM/Admin/Form/Setting/DonrecSettings.php +msgid "Email Return Path" +msgstr "" + +#: CRM/Admin/Form/Setting/DonrecSettings.php +msgid "Email Template" +msgstr "" + #: CRM/Admin/Form/Setting/DonrecSettings.php msgid "Save" msgstr "" @@ -127,6 +144,38 @@ msgstr "" msgid "Don't generate files" msgstr "" +#: CRM/Donrec/Exporters/EmailPDF.php +msgid "Send PDFs via Email" +msgstr "" + +#: CRM/Donrec/Exporters/EmailPDF.php +msgid "Please select email template in the Donrec settings." +msgstr "" + +#: CRM/Donrec/Exporters/EmailPDF.php +msgid "Donation receipt not delivered" +msgstr "" + +#: CRM/Donrec/Exporters/EmailPDF.php +msgid "Donation Receipt.pdf" +msgstr "" + +#: CRM/Donrec/Exporters/EmailPDF.php +msgid "Email would be sent to '%1' (test mode)." +msgstr "" + +#: CRM/Donrec/Exporters/EmailPDF.php +msgid "DonationReceipt Failure" +msgstr "" + +#: CRM/Donrec/Exporters/EmailPDF.php +msgid "No valid email address found for this contact." +msgstr "" + +#: CRM/Donrec/Exporters/EmailPDF.php +msgid "Error was: " +msgstr "" + #: CRM/Donrec/Exporters/GroupedPDF.php msgid "Individual PDFs sorted by page count" msgstr "" @@ -371,6 +420,10 @@ msgstr "" msgid "Missing exporter!" msgstr "" +#: CRM/Donrec/Upgrader/Base.php +msgid "Upgrade %1 to revision %2" +msgstr "" + #: api/v3/DonationReceipt.php msgid "No 'rid' parameter given." msgstr "" @@ -486,10 +539,6 @@ msgstr "" msgid "bulk receipt" msgstr "" -#: donrec.php -msgid "Issued by contact ID" -msgstr "" - #: donrec.php msgid "Issued by contact" msgstr "" @@ -573,6 +622,52 @@ msgid "" "current profile." msgstr "" +#: templates/CRM/Admin/Form/Setting/DonrecSettings.hlp +msgid "" +"In case you select the 'send via email' exporter, this template will be used " +"for the email body." +msgstr "" + +#: templates/CRM/Admin/Form/Setting/DonrecSettings.hlp +msgid "" +"You can set an email address that will receive every email sent as a blind " +"copy." +msgstr "" + +#: templates/CRM/Admin/Form/Setting/DonrecSettings.hlp +msgid "" +"Caution: Activating this setting might violate the HMRC/IRS " +"requirements about the handling of the original receipt." +msgstr "" + +#: templates/CRM/Admin/Form/Setting/DonrecSettings.hlp +msgid "" +"It might be important to you to receive bounces from donation receipts sent " +"out via email. However if the default bounce system is used this information " +"will be processed without you noticing." +msgstr "" + +#: templates/CRM/Admin/Form/Setting/DonrecSettings.hlp +msgid "" +"By providing an email address here, the following happens during live " +"generation:" +msgstr "" + +#: templates/CRM/Admin/Form/Setting/DonrecSettings.hlp +msgid "The email is set as your default bounce address" +msgstr "" + +#: templates/CRM/Admin/Form/Setting/DonrecSettings.hlp +msgid "The task to send out newsletters will be disabled." +msgstr "" + +#: templates/CRM/Admin/Form/Setting/DonrecSettings.hlp +msgid "" +"Caution: All of these changes will be rolled back when the " +"generation process has completed, however in rare cases (like crashes), this " +"rollback might fail." +msgstr "" + #: templates/CRM/Admin/Form/Setting/DonrecSettings.hlp msgid "" "This setting allows you to define the format for the donation receipt's " @@ -678,6 +773,22 @@ msgstr "" msgid "Postal Address Fallback" msgstr "" +#: templates/CRM/Admin/Form/Setting/DonrecSettings.tpl +msgid "Email Settings" +msgstr "" + +#: templates/CRM/Admin/Form/Setting/DonrecSettings.tpl +msgid "Email-Template" +msgstr "" + +#: templates/CRM/Admin/Form/Setting/DonrecSettings.tpl +msgid "BCC Email Address" +msgstr "" + +#: templates/CRM/Admin/Form/Setting/DonrecSettings.tpl +msgid "Return Path Email Address" +msgstr "" + #: templates/CRM/Admin/Form/Setting/DonrecSettings.tpl msgid "General Settings" msgstr "" @@ -970,6 +1081,14 @@ msgstr "" msgid "Creation date" msgstr "" +#: templates/CRM/Donrec/Page/Tab.tpl +msgid "Issued by" +msgstr "" + +#: templates/CRM/Donrec/Page/Tab.tpl +msgid "Unknown" +msgstr "" + #: templates/CRM/Donrec/Page/Tab.tpl msgid "Total amount" msgstr "" diff --git a/l10n/de_DE/LC_MESSAGES/donrec.mo b/l10n/de_DE/LC_MESSAGES/donrec.mo index a77aa29d..25b896fc 100644 Binary files a/l10n/de_DE/LC_MESSAGES/donrec.mo and b/l10n/de_DE/LC_MESSAGES/donrec.mo differ diff --git a/l10n/de_DE/LC_MESSAGES/donrec.po b/l10n/de_DE/LC_MESSAGES/donrec.po index b60d0c8f..7766defb 100644 --- a/l10n/de_DE/LC_MESSAGES/donrec.po +++ b/l10n/de_DE/LC_MESSAGES/donrec.po @@ -1,7 +1,7 @@ msgid "" msgstr "" "Project-Id-Version: SYSTOPIA Donation Receipts\n" -"POT-Creation-Date: 2016-04-06 18:13+0200\n" +"POT-Creation-Date: 2017-01-19 15:32+0100\n" "PO-Revision-Date: \n" "Last-Translator: Bjoern Endres \n" "Language-Team: SYSTOPIA \n" @@ -32,6 +32,7 @@ msgstr "Wasserzeichen Kopie" #: CRM/Admin/Form/Setting/DonrecSettings.php donrec.php #: templates/CRM/Admin/Form/Setting/DonrecSettings.tpl +#: templates/CRM/Donrec/Page/Tab.tpl msgid "Receipt ID" msgstr "Bescheinigungs-ID" @@ -69,6 +70,22 @@ msgstr "Externes Programm: Pfad zu pdfinfo" msgid "Packet size" msgstr "Paketgröße" +#: CRM/Admin/Form/Setting/DonrecSettings.php +msgid "BCC Email" +msgstr "BCC E-Mail" + +#: CRM/Admin/Form/Setting/DonrecSettings.php +msgid "Has to be a valid email address" +msgstr "Muss eine valide E-Mail Adresse sein" + +#: CRM/Admin/Form/Setting/DonrecSettings.php +msgid "Email Return Path" +msgstr "E-Mail Return Path" + +#: CRM/Admin/Form/Setting/DonrecSettings.php +msgid "Email Template" +msgstr "E-Mail Vorlage" + #: CRM/Admin/Form/Setting/DonrecSettings.php msgid "Save" msgstr "Speichern" @@ -121,12 +138,44 @@ msgstr "Zuwendungsbescheinigungen" #: CRM/Donrec/Exporters/CSV.php msgid ".csv" -msgstr "" +msgstr ".csv" #: CRM/Donrec/Exporters/Dummy.php msgid "Don't generate files" msgstr "Keine Dateien erzeugen" +#: CRM/Donrec/Exporters/EmailPDF.php +msgid "Send PDFs via Email" +msgstr "PDF per E-Mail versenden" + +#: CRM/Donrec/Exporters/EmailPDF.php +msgid "Please select email template in the Donrec settings." +msgstr "Bitte das zu verwendende Template in den 'Donation Receipts Settings' einstellen." + +#: CRM/Donrec/Exporters/EmailPDF.php +msgid "Donation receipt not delivered" +msgstr "Zuwendungesbescheinigung nicht zugestellt" + +#: CRM/Donrec/Exporters/EmailPDF.php +msgid "Donation Receipt.pdf" +msgstr "Zuwendungsbescheinigung.pdf" + +#: CRM/Donrec/Exporters/EmailPDF.php +msgid "Email would be sent to '%1' (test mode)." +msgstr "E-Mail würde geschickt werden an '%1' (Testmodus)." + +#: CRM/Donrec/Exporters/EmailPDF.php +msgid "DonationReceipt Failure" +msgstr "Fehler Zuwendungesbescheinigung" + +#: CRM/Donrec/Exporters/EmailPDF.php +msgid "No valid email address found for this contact." +msgstr "Keine gültige E-Mail Adresse für den Kontakt gefunden." + +#: CRM/Donrec/Exporters/EmailPDF.php +msgid "Error was: " +msgstr "Fehlermeldung war:" + #: CRM/Donrec/Exporters/GroupedPDF.php msgid "Individual PDFs sorted by page count" msgstr "Einzelne PDFs, sortiert nach Seitenanzahl" @@ -157,7 +206,7 @@ msgstr "pdfinfo Pfad nicht gesetzt" #: CRM/Donrec/Exporters/GroupedPDF.php msgid ".zip" -msgstr "" +msgstr ".zip" #: CRM/Donrec/Exporters/GroupedPDF.php msgid "%d-page" @@ -229,7 +278,7 @@ msgstr "Sie müssen eine Zuwendung zur Umbuchung angeben." #: CRM/Donrec/Form/Task/Rebook.php CRM/Donrec/Form/Task/RebookTask.php msgid "CiviCRM ID" -msgstr "" +msgstr "CiviCRM ID" #: CRM/Donrec/Form/Task/Rebook.php msgid "At least one of the given contributions doesn't exist!" @@ -365,6 +414,10 @@ msgstr "Der zuvor erstellte Snapshot wurde gelöscht." msgid "Missing exporter!" msgstr "Kein Exporter ausgewählt!" +#: CRM/Donrec/Upgrader/Base.php +msgid "Upgrade %1 to revision %2" +msgstr "" + #: api/v3/DonationReceipt.php msgid "No 'rid' parameter given." msgstr "Fehlender Parameter: 'rid'." @@ -473,10 +526,6 @@ msgstr "Einzelbescheinigung" msgid "bulk receipt" msgstr "Sammelbescheinigung" -#: donrec.php -msgid "Issued by contact ID" -msgstr "Ausgestellt von Kontakt ID" - #: donrec.php msgid "Issued by contact" msgstr "Ausgestellt von Kontakt" @@ -525,6 +574,38 @@ msgstr "Profile ermöglichen es, unterschiedliche Konfigurationen für unterschi msgid "Select the template to be used for creating donation receipt PDFs with the current profile." msgstr "Wählen Sie die Vorlage die für Erzeugung von PDF Dateien für Bescheinigungen mit dem aktuellen Profil." +#: templates/CRM/Admin/Form/Setting/DonrecSettings.hlp +msgid "In case you select the 'send via email' exporter, this template will be used for the email body." +msgstr "Falls Sie die Ausgabe 'PDF per E-Mail versenden\" wählen, wird diese Vorlage für den E-Mail text verwendet." + +#: templates/CRM/Admin/Form/Setting/DonrecSettings.hlp +msgid "You can set an email address that will receive every email sent as a blind copy." +msgstr "Sie können hier eine E-Mail Adresse angeben, die alle verschickten Zuwendungsbescheinigungen als BCC erhalten." + +#: templates/CRM/Admin/Form/Setting/DonrecSettings.hlp +msgid "Caution: Activating this setting might violate the HMRC/IRS requirements about the handling of the original receipt." +msgstr "Achtung: Die Aktivierung dieser Funktion könnte die Auflagen Ihres Finanzamts bezüglich der Zugänglichkeit der Originalbescheinigungen verletzen." + +#: templates/CRM/Admin/Form/Setting/DonrecSettings.hlp +msgid "It might be important to you to receive bounces from donation receipts sent out via email. However if the default bounce system is used this information will be processed without you noticing." +msgstr "Unter Umständen ist es wichtig die Zustellungsfehler der über E-Mail versendeten Zuwendungsbescheinigungen zu erhalten. Normalerweise werden diese Zustellungsfehler einfach von CiviCRM im Hintergrund verarbeitet, und es ist nicht einfach an diese Informationen heranzukommen." + +#: templates/CRM/Admin/Form/Setting/DonrecSettings.hlp +msgid "By providing an email address here, the following happens during live generation:" +msgstr "Wenn Sie hier eine E-Mail Adresse eintragen wird folgendes während des Versands der Zuwendungsbescheinigungen passieren:" + +#: templates/CRM/Admin/Form/Setting/DonrecSettings.hlp +msgid "The email is set as your default bounce address" +msgstr "Die E-Mail Adress wird as Standardadresse für das \"Bounce Processing\" gesetzt." + +#: templates/CRM/Admin/Form/Setting/DonrecSettings.hlp +msgid "The task to send out newsletters will be disabled." +msgstr "Der Job zum Versand on Rundschreiben wird deaktiviert." + +#: templates/CRM/Admin/Form/Setting/DonrecSettings.hlp +msgid "Caution: All of these changes will be rolled back when the generation process has completed, however in rare cases (like crashes), this rollback might fail." +msgstr "Achtung: Diese Änderungen werden nach Abschluss des Versands wieder zurückgenommen, allerdings kann dies in Ausnahmesituationen (z.B. Abstürzen) ausbleiben." + #: templates/CRM/Admin/Form/Setting/DonrecSettings.hlp msgid "This setting allows you to define the format for the donation receipt's serial number. You can use text and tokens to customize it." msgstr "Diese Einstellung erlaubt Ihnen eine Schema für die zu vergebende Seriennummer der Zuwendungsbescheinigungen zu definieren. Dazu können Sie beliebigen Text und die vordefinierten Tokens verwenden." @@ -626,6 +707,22 @@ msgstr "Versandadresse" msgid "Postal Address Fallback" msgstr "Fallback Versandadresse" +#: templates/CRM/Admin/Form/Setting/DonrecSettings.tpl +msgid "Email Settings" +msgstr "E-Mail Versand" + +#: templates/CRM/Admin/Form/Setting/DonrecSettings.tpl +msgid "Email-Template" +msgstr "E-Mail Vorlage" + +#: templates/CRM/Admin/Form/Setting/DonrecSettings.tpl +msgid "BCC Email Address" +msgstr "BCC E-Mail Adresse" + +#: templates/CRM/Admin/Form/Setting/DonrecSettings.tpl +msgid "Return Path Email Address" +msgstr "Return Path E-Mail Adresse" + #: templates/CRM/Admin/Form/Setting/DonrecSettings.tpl msgid "General Settings" msgstr "Allgemeine Einstellungen" @@ -894,6 +991,14 @@ msgstr "zurückgesetzte Kopie" msgid "Creation date" msgstr "Erstelldatum" +#: templates/CRM/Donrec/Page/Tab.tpl +msgid "Issued by" +msgstr "Ausgestellt von" + +#: templates/CRM/Donrec/Page/Tab.tpl +msgid "Unknown" +msgstr "Unbekannt" + #: templates/CRM/Donrec/Page/Tab.tpl msgid "Total amount" msgstr "Gesamtbetrag" @@ -1006,6 +1111,8 @@ msgstr "Sind Sie sicher dass Sie diese Zuwendungsbescheinigung löschen möchten msgid "Temporary file dowload failed." msgstr "Download der temporären Datei fehlgeschlagen." +#~ msgid "Issued by contact ID" +#~ msgstr "Ausgestellt von Kontakt ID" #~ msgctxt "menu" #~ msgid "Donation Receipts Settings" diff --git a/settings/donrec.setting.php b/settings/donrec.setting.php index b34f234f..3ec1cd8e 100644 --- a/settings/donrec.setting.php +++ b/settings/donrec.setting.php @@ -36,6 +36,51 @@ 'is_contact' => 0, 'description' => 'Packet size', ), + 'donrec_return_path_email' => array( + 'group_name' => 'Donation Receipt Settings', + 'group' => 'de.systopia', + 'name' => 'donrec_return_path_email', + 'type' => 'String', + 'default' => '', + 'add' => '4.3', + 'is_domain' => 1, + 'is_contact' => 0, + 'description' => 'Email Return Path', + ), + 'donrec_bcc_email' => array( + 'group_name' => 'Donation Receipt Settings', + 'group' => 'de.systopia', + 'name' => 'donrec_bcc_email', + 'type' => 'String', + 'default' => '', + 'add' => '4.3', + 'is_domain' => 1, + 'is_contact' => 0, + 'description' => 'BCC Email', + ), + 'donrec_email_template' => array( + 'group_name' => 'Donation Receipt Settings', + 'group' => 'de.systopia', + 'name' => 'donrec_email_template', + 'type' => 'Integer', + 'html_type' => 'Select', + 'default' => 0, + 'add' => '4.3', + 'is_domain' => 1, + 'is_contact' => 0, + 'description' => 'Email Template', + ), + 'donrec_email_stashed_settings' => array( + 'group_name' => 'Donation Receipt Settings', + 'group' => 'de.systopia', + 'name' => 'donrec_email_stashed_settings', + 'type' => 'String', + 'default' => 0, + 'add' => '4.3', + 'is_domain' => 1, + 'is_contact' => 0, + 'description' => 'If the EmailPDF exporter modifies the email settings temporarily, the old settings will be stored here.', + ), 'donrec_pdfinfo_path' => array( 'group_name' => 'Donation Receipt Settings', 'group' => 'de.systopia', diff --git a/templates/CRM/Admin/Form/Setting/DonrecSettings.hlp b/templates/CRM/Admin/Form/Setting/DonrecSettings.hlp index 5bc96bb5..dd00bfa2 100644 --- a/templates/CRM/Admin/Form/Setting/DonrecSettings.hlp +++ b/templates/CRM/Admin/Form/Setting/DonrecSettings.hlp @@ -51,6 +51,26 @@

{ts domain="de.systopia.donrec"}Select the template to be used for creating donation receipt PDFs with the current profile.{/ts}

{/htxt} +{htxt id='id-email-template'} +

{ts domain="de.systopia.donrec"}In case you select the 'send via email' exporter, this template will be used for the email body.{/ts}

+{/htxt} + +{htxt id='id-bcc-email'} +

{ts domain="de.systopia.donrec"}You can set an email address that will receive every email sent as a blind copy.{/ts}

+

{ts domain="de.systopia.donrec"}Caution: Activating this setting might violate the HMRC/IRS requirements about the handling of the original receipt.{/ts}

+{/htxt} + +{htxt id='id-return-path-email'} +

{ts domain="de.systopia.donrec"}It might be important to you to receive bounces from donation receipts sent out via email. However if the default bounce system is used this information will be processed without you noticing.{/ts}

+

{ts domain="de.systopia.donrec"}By providing an email address here, the following happens during live generation:{/ts} +

    +
  • {ts domain="de.systopia.donrec"}The email is set as your default bounce address{/ts}
  • +
  • {ts domain="de.systopia.donrec"}The task to send out newsletters will be disabled.{/ts}
  • +
+

+

{ts domain="de.systopia.donrec"}Caution: All of these changes will be rolled back when the generation process has completed, however in rare cases (like crashes), this rollback might fail.{/ts}

+{/htxt} + {htxt id='id-pattern'}

{ts domain="de.systopia.donrec"}This setting allows you to define the format for the donation receipt's serial number. You can use text and tokens to customize it.{/ts} diff --git a/templates/CRM/Admin/Form/Setting/DonrecSettings.tpl b/templates/CRM/Admin/Form/Setting/DonrecSettings.tpl index fccbddf4..40c76e64 100644 --- a/templates/CRM/Admin/Form/Setting/DonrecSettings.tpl +++ b/templates/CRM/Admin/Form/Setting/DonrecSettings.tpl @@ -107,6 +107,28 @@ +
+

+
+

{ts domain="de.systopia.donrec"}Email Settings{/ts}

+
+ + + + + + + + + + + + + +
{$form.donrec_email_template.label}  {$form.donrec_email_template.html}
{$form.donrec_bcc_email.label}  {$form.donrec_bcc_email.html}
{$form.donrec_return_path_email.label}  {$form.donrec_return_path_email.html}
+
+
+

diff --git a/templates/CRM/Donrec/Page/Tab.tpl b/templates/CRM/Donrec/Page/Tab.tpl index 2726483d..e373a722 100644 --- a/templates/CRM/Donrec/Page/Tab.tpl +++ b/templates/CRM/Donrec/Page/Tab.tpl @@ -37,6 +37,15 @@ {/if}
  • {ts domain="de.systopia.donrec"}Creation date{/ts}: {$receipt.issued_on|crmDate:$config->dateformatFull}
  • +
  • + {ts domain="de.systopia.donrec"}Issued by{/ts}: + {if $receipt.issued_by} + {assign var=contact_id value=$receipt.issued_by} + {$receipt.issued_by_display_name} + {else} + {ts domain="de.systopia.donrec"}Unknown{/ts} + {/if} +
  • {ts domain="de.systopia.donrec"}Date{/ts}: {if $receipt.type eq 'SINGLE'} {* for single receipts, print the date of the contribution *}