Exemple #1
0
 /**
  * This function takes care of all the things common to all
  * pages. This typically involves assigning the appropriate
  * smarty variable :)
  *
  * @return string The content generated by running this page
  */
 function run()
 {
     if ($this->_embedded) {
         return;
     }
     self::$_template->assign('mode', $this->_mode);
     self::$_template->assign('tplFile', $this->getTemplateFileName());
     // invoke the pagRun hook, CRM-3906
     require_once 'CRM/Utils/Hook.php';
     CRM_Utils_Hook::pageRun($this);
     if ($this->_print) {
         if ($this->_print == CRM_Core_Smarty::PRINT_SNIPPET || $this->_print == CRM_Core_Smarty::PRINT_PDF) {
             $content = self::$_template->fetch('CRM/common/snippet.tpl');
         } else {
             $content = self::$_template->fetch('CRM/common/print.tpl');
         }
         if ($this->_print == CRM_Core_Smarty::PRINT_PDF) {
             require_once 'CRM/Utils/PDF/Utils.php';
             CRM_Utils_PDF_Utils::domlib($content, "{$this->_name}.pdf");
         } else {
             echo $content;
         }
         exit;
     }
     $config =& CRM_Core_Config::singleton();
     $content = self::$_template->fetch('CRM/common/' . strtolower($config->userFramework) . '.tpl');
     echo CRM_Utils_System::theme('page', $content, true, $this->_print);
     return;
 }
Exemple #2
0
 /**
  * process the form after the input has been submitted and validated
  *
  * @access public
  * @return None
  */
 public function postProcess()
 {
     // get all the details needed to generate a receipt
     $contribIDs = implode(',', $this->_contributionIds);
     require_once 'CRM/Contribute/Form/Task/Status.php';
     $details =& CRM_Contribute_Form_Task_Status::getDetails($contribIDs);
     require_once 'CRM/Core/Payment/BaseIPN.php';
     $baseIPN = new CRM_Core_Payment_BaseIPN();
     $message = array();
     $template =& CRM_Core_Smarty::singleton();
     foreach ($details as $contribID => $detail) {
         $input = $ids = $objects = array();
         $input['component'] = $detail['component'];
         $ids['contact'] = $detail['contact'];
         $ids['contribution'] = $contribID;
         $ids['contributionRecur'] = null;
         $ids['contributionPage'] = null;
         $ids['membership'] = $detail['membership'];
         $ids['participant'] = $detail['participant'];
         $ids['event'] = $detail['event'];
         if (!$baseIPN->validateData($input, $ids, $objects, false)) {
             CRM_Core_Error::fatal();
         }
         $contribution =& $objects['contribution'];
         // CRM_Core_Error::debug('o',$objects);
         // set some fake input values so we can reuse IPN code
         $input['amount'] = $contribution->total_amount;
         $input['is_test'] = $contribution->is_test;
         $input['fee_amount'] = $contribution->fee_amount;
         $input['net_amount'] = $contribution->net_amount;
         $input['trxn_id'] = $contribution->trxn_id;
         $input['trxn_date'] = isset($contribution->trxn_date) ? $contribution->trxn_date : null;
         // CRM_Core_Error::debug('input',$input);
         $values = array();
         $mail = $baseIPN->sendMail($input, $ids, $objects, $values, false, true);
         $mail = str_replace("\n\n", "<p>", $mail);
         $mail = str_replace("\n", "<br/>", $mail);
         $message[] = $mail;
         // reset template values before processing next transactions
         $template->clearTemplateVars();
     }
     require_once 'CRM/Utils/PDF/Utils.php';
     CRM_Utils_PDF_Utils::domlib($message, "civicrmContributionReceipt.pdf");
     exit;
 }
Exemple #3
0
 /**
  * render the page using a custom templating
  * system
  *
  * @param object  $page the CRM_Core_Form page
  * @param boolean $ret  should we echo or return output
  *
  * @return void
  * @access public
  */
 function renderForm(&$page, $ret = false)
 {
     $this->_setRenderTemplates($page);
     $template =& CRM_Core_Smarty::singleton();
     $template->assign('form', $page->toSmarty());
     $template->assign('isForm', 1);
     $controller =& $page->controller;
     if ($controller->getEmbedded()) {
         return;
     }
     $template->assign('action', $page->getAction());
     $template->assign('tplFile', $page->getTemplateFileName());
     $content = $template->fetch($controller->getTemplateFile());
     $print = $controller->getPrint();
     if ($print) {
         $html =& $content;
     } else {
         $html = CRM_Utils_System::theme('page', $content, true, $print, $ret);
     }
     if ($ret) {
         return $html;
     }
     if ($print) {
         if ($print == CRM_Core_Smarty::PRINT_PDF) {
             require_once 'CRM/Utils/PDF/Utils.php';
             CRM_Utils_PDF_Utils::domlib($content, "{$page->_name}.pdf");
         } else {
             echo $html;
         }
         exit;
     }
 }
Exemple #4
0
 /**
  * process the form after the input has been submitted and validated
  *
  * @access public
  * @return None
  */
 public function postProcess()
 {
     // get all the details needed to generate a receipt
     $contribIDs = implode(',', $this->_contributionIds);
     require_once 'CRM/Contribute/Form/Task/Status.php';
     $details =& CRM_Contribute_Form_Task_Status::getDetails($contribIDs);
     require_once 'CRM/Core/Payment/BaseIPN.php';
     $baseIPN = new CRM_Core_Payment_BaseIPN();
     $message = array();
     $template = CRM_Core_Smarty::singleton();
     $params = $this->controller->exportValues($this->_name);
     $createPdf = false;
     if ($params['output'] == "pdf_receipt") {
         $createPdf = true;
     }
     $excludeContactIds = array();
     if (!$createPdf) {
         $returnProperties = array('email' => 1, 'do_not_email' => 1, 'is_deceased' => 1, 'on_hold' => 1);
         require_once 'CRM/Mailing/BAO/Mailing.php';
         list($contactDetails) = CRM_Mailing_BAO_Mailing::getDetails($this->_contactIds, $returnProperties, false, false);
         foreach ($contactDetails as $id => $values) {
             if (empty($values['email']) || CRM_Utils_Array::value('do_not_email', $values) || CRM_Utils_Array::value('is_deceased', $values) || CRM_Utils_Array::value('on_hold', $values)) {
                 $suppressedEmails++;
                 $excludeContactIds[] = $values['contact_id'];
             }
         }
     }
     foreach ($details as $contribID => $detail) {
         $input = $ids = $objects = array();
         if (in_array($detail['contact'], $excludeContactIds)) {
             continue;
         }
         $input['component'] = $detail['component'];
         $ids['contact'] = $detail['contact'];
         $ids['contribution'] = $contribID;
         $ids['contributionRecur'] = null;
         $ids['contributionPage'] = null;
         $ids['membership'] = $detail['membership'];
         $ids['participant'] = $detail['participant'];
         $ids['event'] = $detail['event'];
         if (!$baseIPN->validateData($input, $ids, $objects, false)) {
             CRM_Core_Error::fatal();
         }
         $contribution =& $objects['contribution'];
         // CRM_Core_Error::debug('o',$objects);
         // set some fake input values so we can reuse IPN code
         $input['amount'] = $contribution->total_amount;
         $input['is_test'] = $contribution->is_test;
         $input['fee_amount'] = $contribution->fee_amount;
         $input['net_amount'] = $contribution->net_amount;
         $input['trxn_id'] = $contribution->trxn_id;
         $input['trxn_date'] = isset($contribution->trxn_date) ? $contribution->trxn_date : null;
         // CRM_Core_Error::debug('input',$input);
         $values = array();
         $mail = $baseIPN->sendMail($input, $ids, $objects, $values, false, $createPdf);
         if (!$mail['html']) {
             $mail = str_replace("\n\n", "<p>", $mail);
             $mail = str_replace("\n", "<br/>", $mail);
         }
         $message[] = $mail;
         // reset template values before processing next transactions
         $template->clearTemplateVars();
     }
     if ($createPdf) {
         require_once 'CRM/Utils/PDF/Utils.php';
         CRM_Utils_PDF_Utils::domlib($message, 'civicrmContributionReceipt.pdf', false, 'portrait', 'letter');
         CRM_Utils_System::civiExit();
     } else {
         if ($suppressedEmails) {
             $status = array('', ts('Email was NOT sent to %1 contacts (no email address on file, or communication preferences specify DO NOT EMAIL, or contact is deceased).', array(1 => $suppressedEmails)));
         } else {
             $status = array('', ts('Your mail has been sent.'));
         }
         CRM_Core_Session::setStatus($status);
     }
 }