CRM-15670 Allow overriding of privacy settings & updating of receive_date when sendin...
authorEileen McNaughton <eileen@fuzion.co.nz>
Tue, 2 Dec 2014 01:14:12 +0000 (14:14 +1300)
committerEileen McNaughton <eileen@fuzion.co.nz>
Tue, 2 Dec 2014 01:14:12 +0000 (14:14 +1300)
CRM/Contribute/Form/Task/PDF.php
templates/CRM/Contribute/Form/Task/PDF.tpl

index e3cd688a7dd6e184a383c0463f20d0e686351a46..27302c46d9a4d5017d46299ab252f99124bde5a9 100644 (file)
@@ -119,6 +119,8 @@ AND    {$this->_componentClause}";
     $this->add('select', 'pdf_format_id', ts('Page Format'),
       array(0 => ts('- default -')) + CRM_Core_BAO_PdfFormat::getList(TRUE)
     );
+    $this->add('checkbox', 'receipt_update', ts('Update receipt dates for these contributions'), FALSE);
+    $this->add('checkbox', 'override_privacy', ts('Override privacy setting? (Do no email / Do not mail)'), FALSE);
 
     $this->addButtons(array(
         array(
@@ -139,7 +141,7 @@ AND    {$this->_componentClause}";
    */
   function setDefaultValues() {
     $defaultFormat = CRM_Core_BAO_PdfFormat::getDefaultValues();
-    return array('pdf_format_id' => $defaultFormat['id']);
+    return array('pdf_format_id' => $defaultFormat['id'], 'receipt_update' => 1, 'override_privacy' => 0);
   }
 
   /**
@@ -196,6 +198,7 @@ AND    {$this->_componentClause}";
       $values = array();
       $mail = $elements['baseIPN']->sendMail($input, $ids, $objects, $values, FALSE, $elements['createPdf']);
 
+
       if ($mail['html']) {
         $message[] = $mail['html'];
       }
@@ -205,6 +208,10 @@ AND    {$this->_componentClause}";
 
       // reset template values before processing next transactions
       $template->clearTemplateVars();
+      if (!empty($params['receipt_update'])) {
+        $objects['contribution']->receipt_date = date('Y-m-d H-i-s');
+        $objects['contribution']->save();
+      }
     }
 
     if ($elements['createPdf']) {
@@ -274,11 +281,13 @@ AND    {$this->_componentClause}";
       $pdfElements['suppressedEmails'] = 0;
       $suppressedEmails = 0;
       foreach ($contactDetails as $id => $values) {
-        if (empty($values['email']) || !empty($values['do_not_email']) ||
-            CRM_Utils_Array::value('is_deceased', $values) || !empty($values['on_hold'])) {
-          $suppressedEmails++;
-          $pdfElements['suppressedEmails'] = $suppressedEmails;
-          $excludeContactIds[] = $values['contact_id'];
+        if (empty($values['email']) ||
+          (empty($params['override_privacy']) && !empty($values['do_not_email']))
+          || CRM_Utils_Array::value('is_deceased', $values)
+          || !empty($values['on_hold'])) {
+            $suppressedEmails++;
+            $pdfElements['suppressedEmails'] = $suppressedEmails;
+            $excludeContactIds[] = $values['contact_id'];
         }
       }
     }
index 5fbb55fc15c83711541309ebb68910765bc21fe7..7f03b1b5da7afdd9c803bbc1473c4a0166fc4ee4 100644 (file)
   <tr id="selectPdfFormat" style="display: none;">
     <td>{$form.pdf_format_id.html} {$form.pdf_format_id.label} {help id="id-contribution-receipt" file="CRM/Contact/Form/Task/PDFLetterCommon.hlp"}</td>
   </tr>
+  <tr>
+    <td>{$form.receipt_update.html} {$form.receipt_update.label}</td>
+  </tr>
+  <tr>
+    <td>{$form.override_privacy.html} {$form.override_privacy.label}</td>
+  </tr>
 </table>
 
 <div class="spacer"></div>