コード例 #1
0
ファイル: PDF.php プロジェクト: rajeshrhino/civicrm-core
 /**
  * Build all the data structures needed to build the form.
  *
  * @return void
  */
 public function preProcess()
 {
     $id = CRM_Utils_Request::retrieve('id', 'Positive', $this, FALSE);
     if ($id) {
         $this->_contributionIds = array($id);
         $this->_componentClause = " civicrm_contribution.id IN ( {$id} ) ";
         $this->_single = TRUE;
         $this->assign('totalSelectedContributions', 1);
     } else {
         parent::preProcess();
     }
     // check that all the contribution ids have pending status
     $query = "\nSELECT count(*)\nFROM   civicrm_contribution\nWHERE  contribution_status_id != 1\nAND    {$this->_componentClause}";
     $count = CRM_Core_DAO::singleValueQuery($query);
     if ($count != 0) {
         CRM_Core_Error::statusBounce("Please select only online contributions with Completed status.");
     }
     // we have all the contribution ids, so now we get the contact ids
     parent::setContactIDs();
     $this->assign('single', $this->_single);
     $qfKey = CRM_Utils_Request::retrieve('qfKey', 'String', $this);
     $urlParams = 'force=1';
     if (CRM_Utils_Rule::qfKey($qfKey)) {
         $urlParams .= "&qfKey={$qfKey}";
     }
     $url = CRM_Utils_System::url('civicrm/contribute/search', $urlParams);
     $breadCrumb = array(array('url' => $url, 'title' => ts('Search Results')));
     CRM_Utils_System::appendBreadCrumb($breadCrumb);
     CRM_Utils_System::setTitle(ts('Print Contribution Receipts'));
 }
コード例 #2
0
ファイル: Batch.php プロジェクト: ksecor/civicrm
 /**
  * build all the data structures needed to build the form
  *
  * @return void
  * @access public
  */
 function preProcess()
 {
     /*
      * initialize the task and row fields
      */
     parent::preProcess();
 }
コード例 #3
0
ファイル: Status.php プロジェクト: hampelm/Ginsberg-CiviDemo
 /**
  * build all the data structures needed to build the form
  *
  * @return void
  * @access public
  */
 function preProcess()
 {
     $id = CRM_Utils_Request::retrieve('id', 'Positive', $this, false);
     if ($id) {
         $this->_contributionIds = array($id);
         $this->_componentClause = " civicrm_contribution.id IN ( {$id} ) ";
         $this->_single = true;
         $this->assign('totalSelectedContributions', 1);
     } else {
         parent::preProcess();
     }
     // check that all the contribution ids have pending status
     $query = "\nSELECT count(*)\nFROM   civicrm_contribution\nWHERE  contribution_status_id != 2\nAND    {$this->_componentClause}";
     $count = CRM_Core_DAO::singleValueQuery($query, CRM_Core_DAO::$_nullArray);
     if ($count != 0) {
         CRM_Core_Error::statusBounce(ts('Please select only online contributions with Pending status.'));
     }
     // ensure that all contributions are generated online by pay later
     $query = "\nSELECT DISTINCT( source ) as source\nFROM   civicrm_contribution\nWHERE  {$this->_componentClause}";
     $dao = CRM_Core_DAO::executeQuery($query, CRM_Core_DAO::$_nullArray);
     while ($dao->fetch()) {
         if (strpos($dao->source, ts('Online Contribution')) === false && strpos($dao->source, ts('Online Event Registration')) === false) {
             CRM_Core_Error::statusBounce("<strong>Update Pending Contribution Status</strong> can only be used for pending online contributions (made using the 'Pay Later' option). The Source for these contributions starts with 'Online ...'. Please de-select any offline contributions and try again.");
         }
     }
     // we have all the contribution ids, so now we get the contact ids
     parent::setContactIDs();
     $this->assign('single', $this->_single);
 }
コード例 #4
0
 /**
  * build all the data structures needed to build the form
  *
  * @return void
  * @access public
  */
 function preProcess()
 {
     CRM_Contact_Form_Task_EmailCommon::preProcessFromAddress($this);
     parent::preProcess();
     // we have all the contribution ids, so now we get the contact ids
     parent::setContactIDs();
     $this->assign('single', $this->_single);
 }
コード例 #5
0
ファイル: Delete.php プロジェクト: nganivet/civicrm-core
 /**
  * Build all the data structures needed to build the form.
  */
 public function preProcess()
 {
     //check for delete
     if (!CRM_Core_Permission::checkActionPermission('CiviContribute', CRM_Core_Action::DELETE)) {
         CRM_Core_Error::fatal(ts('You do not have permission to access this page.'));
     }
     parent::preProcess();
 }
コード例 #6
0
ファイル: Print.php プロジェクト: bhirsch/voipdrupal-4.7-1.0
 /**
  * build all the data structures needed to build the form
  *
  * @return void
  * @access public
  */
 function preProcess()
 {
     parent::preprocess();
     // set print view, so that print templates are called
     $this->controller->setPrint(true);
     // create the selector, controller and run - store results in session
     $fv = $this->get('formValues');
     $selector =& new CRM_Contribute_Selector_Search($fv, $this->_action, $this->_contributionClause);
     $controller =& new CRM_Core_Selector_Controller($selector, null, null, CRM_CORE_ACTION_VIEW, $this, CRM_CORE_SELECTOR_CONTROLLER_SCREEN);
     $controller->setEmbedded(true);
     $controller->run();
 }
コード例 #7
0
ファイル: Batch.php プロジェクト: saurabhbatra96/civicrm-core
 /**
  * Build all the data structures needed to build the form.
  */
 public function preProcess()
 {
     // initialize the task and row fields
     parent::preProcess();
     //get the contact read only fields to display.
     $readOnlyFields = array_merge(array('sort_name' => ts('Name')), CRM_Core_BAO_Setting::valueOptions(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'contact_autocomplete_options', TRUE, NULL, FALSE, 'name', TRUE));
     //get the read only field data.
     $returnProperties = array_fill_keys(array_keys($readOnlyFields), 1);
     $contactDetails = CRM_Contact_BAO_Contact_Utils::contactDetails($this->_contributionIds, 'CiviContribute', $returnProperties);
     $this->assign('contactDetails', $contactDetails);
     $this->assign('readOnlyFields', $readOnlyFields);
 }
コード例 #8
0
ファイル: Email.php プロジェクト: bhirsch/voipdev
 /**
  * build all the data structures needed to build the form
  *
  * @return void
  * @access public
  */
 function preProcess()
 {
     $cid = CRM_Utils_Request::retrieve('cid', 'Positive', $this, false);
     if ($cid) {
         CRM_Contact_Form_Task_EmailCommon::preProcessSingle($this, $cid);
     } else {
         parent::preProcess();
         // we have all the contribution ids, so now we get the contact ids
         parent::setContactIDs();
     }
     $this->assign('single', $this->_single);
 }
コード例 #9
0
 /**
  * build all the data structures needed to build the form
  *
  * @return void
  * @access public
  */
 function preProcess()
 {
     parent::preProcess();
     $rows = array();
     // display name and contribution details of all selected contacts
     $contribIDs = implode(',', $this->_contributionIds);
     $query = "\n    SELECT co.total_amount as amount,\n           co.receive_date as receive_date,\n           co.source       as source,\n           ct.display_name as display_name\n      FROM civicrm_contribution co\nINNER JOIN civicrm_contact ct ON ( co.contact_id = ct.id )\n     WHERE co.id IN ( {$contribIDs} )";
     $dao = CRM_Core_DAO::executeQuery($query, CRM_Core_DAO::$_nullArray);
     while ($dao->fetch()) {
         $rows[] = array('display_name' => $dao->display_name, 'amount' => $dao->amount, 'source' => $dao->source, 'receive_date' => $dao->receive_date);
     }
     $this->assign('rows', $rows);
 }
 /**
  * build all the data structures needed to build the form
  *
  * @return void
  * @access public
  */
 function preProcess()
 {
     parent::preProcess();
     require_once 'CRM/Civigiftaid/Utils/Contribution.php';
     list($total, $toRemove, $notInBatch, $alreadySubmited) = CRM_Civigiftaid_Utils_Contribution::_validationRemoveContributionFromBatch($this->_contributionIds);
     $this->assign('selectedContributions', $total);
     $this->assign('totalToRemoveContributions', count($toRemove));
     $this->assign('notInBatchContributions', count($notInBatch));
     $this->assign('alreadySubmitedContributions', count($alreadySubmited));
     $contributionsToRemoveRows = CRM_Civigiftaid_Utils_Contribution::getContributionDetails($toRemove);
     $this->assign('contributionsToRemoveRows', $contributionsToRemoveRows);
     $contributionsAlreadySubmitedRows = CRM_Civigiftaid_Utils_Contribution::getContributionDetails($alreadySubmited);
     $this->assign('contributionsAlreadySubmitedRows', $contributionsAlreadySubmitedRows);
     $contributionsNotInBatchRows = CRM_Civigiftaid_Utils_Contribution::getContributionDetails($notInBatch);
     $this->assign('contributionsNotInBatchRows', $contributionsNotInBatchRows);
 }
コード例 #11
0
 function postProcess()
 {
     $session = CRM_Core_Session::singleton();
     $userContext = $session->readUserContext();
     $values = $this->exportValues();
     CRM_Donrec_Form_Task_Rebook::rebook($this->_contributionIds, trim($values['contactId']), $userContext);
     parent::postProcess();
     // finally, redirect to original contact's contribution overview
     $origin_contact_id = CRM_Donrec_Form_Task_Rebook::checkSameContact($this->_contributionIds, NULL);
     if (!empty($origin_contact_id)) {
         $url = CRM_Utils_System::url('civicrm/contact/view', "reset=1&cid={$origin_contact_id}&selectedChild=contribute");
     } else {
         $url = CRM_Utils_System::url('civicrm', "");
     }
     CRM_Utils_System::redirect($url);
 }
コード例 #12
0
ファイル: Print.php プロジェクト: kidaa30/yes
 /**
  * Build all the data structures needed to build the form.
  *
  * @return void
  */
 public function preProcess()
 {
     parent::preprocess();
     // set print view, so that print templates are called
     $this->controller->setPrint(1);
     // get the formatted params
     $queryParams = $this->get('queryParams');
     $sortID = NULL;
     if ($this->get(CRM_Utils_Sort::SORT_ID)) {
         $sortID = CRM_Utils_Sort::sortIDValue($this->get(CRM_Utils_Sort::SORT_ID), $this->get(CRM_Utils_Sort::SORT_DIRECTION));
     }
     $selector = new CRM_Contribute_Selector_Search($queryParams, $this->_action, $this->_componentClause);
     $controller = new CRM_Core_Selector_Controller($selector, NULL, $sortID, CRM_Core_Action::VIEW, $this, CRM_Core_Selector_Controller::SCREEN);
     $controller->setEmbedded(TRUE);
     $controller->run();
 }
コード例 #13
0
ファイル: Batch.php プロジェクト: bhirsch/voipdev
 /**
  * build all the data structures needed to build the form
  *
  * @return void
  * @access public
  */
 function preProcess()
 {
     /*
      * initialize the task and row fields
      */
     parent::preProcess();
     //get the contact read only fields to display.
     require_once 'CRM/Core/BAO/Preferences.php';
     $readOnlyFields = array_merge(array('sort_name' => ts('Name')), CRM_Core_BAO_Preferences::valueOptions('contact_autocomplete_options', true, null, false, 'name', true));
     //get the read only field data.
     $returnProperties = array_fill_keys(array_keys($readOnlyFields), 1);
     require_once 'CRM/Contact/BAO/Contact/Utils.php';
     $contactDetails = CRM_Contact_BAO_Contact_Utils::contactDetails($this->_contributionIds, 'CiviContribute', $returnProperties);
     $this->assign('contactDetails', $contactDetails);
     $this->assign('readOnlyFields', $readOnlyFields);
 }
コード例 #14
0
ファイル: PDFLetter.php プロジェクト: vakeesan26/civicrm-core
 /**
  * Build all the data structures needed to build the form.
  *
  * @return void
  */
 public function preProcess()
 {
     $this->skipOnHold = $this->skipDeceased = FALSE;
     CRM_Contact_Form_Task_PDFLetterCommon::preProcess($this);
     // store case id if present
     $this->_caseId = CRM_Utils_Request::retrieve('caseid', 'Positive', $this, FALSE);
     // retrieve contact ID if this is 'single' mode
     $cid = CRM_Utils_Request::retrieve('cid', 'Positive', $this, FALSE);
     $this->_activityId = CRM_Utils_Request::retrieve('id', 'Positive', $this, FALSE);
     if ($cid) {
         CRM_Contact_Form_Task_PDFLetterCommon::preProcessSingle($this, $cid);
         $this->_single = TRUE;
         $this->_cid = $cid;
     } else {
         parent::preProcess();
     }
     $this->assign('single', $this->_single);
 }
コード例 #15
0
 /**
  * build all the data structures needed to build the form
  *
  * @return void
  * @access public
  */
 function preProcess()
 {
     parent::preProcess();
     require_once 'GiftAid/Utils/Contribution.php';
     list($total, $added, $alreadyAdded, $notValid) = GiftAid_Utils_Contribution::_validateContributionToBatch($this->_contributionIds);
     $this->assign('selectedContributions', $total);
     $this->assign('totalAddedContributions', count($added));
     $this->assign('alreadyAddedContributions', count($alreadyAdded));
     $this->assign('notValidContributions', count($notValid));
     // get details of contribution that will be added to this batch.
     $contributionsAddedRows = array();
     $contributionsAddedRows = GiftAid_Utils_Contribution::getContributionDetails($added);
     $this->assign('contributionsAddedRows', $contributionsAddedRows);
     // get details of contribution thatare already added to this batch.
     $contributionsAlreadyAddedRows = array();
     $contributionsAlreadyAddedRows = GiftAid_Utils_Contribution::getContributionDetails($alreadyAdded);
     $this->assign('contributionsAlreadyAddedRows', $contributionsAlreadyAddedRows);
 }
コード例 #16
0
ファイル: PickProfile.php プロジェクト: nganivet/civicrm-core
 /**
  * Build all the data structures needed to build the form.
  */
 public function preProcess()
 {
     // initialize the task and row fields
     parent::preProcess();
     $session = CRM_Core_Session::singleton();
     $this->_userContext = $session->readUserContext();
     CRM_Utils_System::setTitle(ts('Batch Update Contributions Via Profile'));
     $validate = FALSE;
     //validations
     if (count($this->_contributionIds) > $this->_maxContributions) {
         CRM_Core_Session::setStatus(ts("The maximum number of contributions you can select for Batch update is %1. You have selected %2. Please select fewer contributions from your search results and try again.", array(1 => $this->_maxContributions, 2 => count($this->_contributionIds))), ts('Batch Update Error'), 'error');
         $validate = TRUE;
     }
     // than redirect
     if ($validate) {
         CRM_Utils_System::redirect($this->_userContext);
     }
 }
コード例 #17
0
 /**
  * build all the data structures needed to build the form
  *
  * @return void
  * @access public
  */
 function preProcess()
 {
     //check for permission to edit contributions
     if (!CRM_Core_Permission::check('issue cdn tax receipts')) {
         CRM_Core_Error::fatal(ts('You do not have permission to access this page', array('domain' => 'org.civicrm.cdntaxreceipts')));
     }
     parent::preProcess();
     $receipts = array('original' => array('email' => 0, 'print' => 0), 'duplicate' => array('email' => 0, 'print' => 0));
     // count and categorize contributions
     foreach ($this->_contributionIds as $id) {
         if (cdntaxreceipts_eligibleForReceipt($id)) {
             list($issued_on, $receipt_id) = cdntaxreceipts_issued_on($id);
             $key = empty($issued_on) ? 'original' : 'duplicate';
             list($method, $email) = cdntaxreceipts_sendMethodForContribution($id);
             $receipts[$key][$method]++;
         }
     }
     $this->_receipts = $receipts;
 }
コード例 #18
0
ファイル: PickProfile.php プロジェクト: ksecor/civicrm
 /**
  * build all the data structures needed to build the form
  *
  * @return void
  * @access public
  */
 function preProcess()
 {
     /*
      * initialize the task and row fields
      */
     parent::preProcess();
     $session =& CRM_Core_Session::singleton();
     $this->_userContext = $session->readUserContext();
     CRM_Utils_System::setTitle(ts('Batch Profile Update for Contribution'));
     $validate = false;
     //validations
     if (count($this->_contributionIds) > $this->_maxContributions) {
         CRM_Core_Session::setStatus("The maximum number of contributions you can select for Batch Update is {$this->_maxContributions}. You have selected " . count($this->_contributionIds) . ". Please select fewer contributions from your search results and try again.");
         $validate = true;
     }
     if ($validate) {
         // than redirect
         CRM_Utils_System::redirect($this->_userContext);
     }
 }
コード例 #19
0
ファイル: Delete.php プロジェクト: bhirsch/voipdrupal-4.7-1.0
 /**
  * build all the data structures needed to build the form
  *
  * @return void
  * @access public
  */
 function preProcess()
 {
     // uncomment when adding support for single contrib delete
     //      $cid = CRM_Utils_Request::retrieve( 'cid', $this, false );
     //       if ( $cid ) {
     //           // not sure why this is needed :(
     //           // also add the cid params to the Menu array
     //           CRM_Utils_Menu::addParam( 'cid', $cid );
     //
     //           // create menus ..
     //           $startWeight = CRM_Utils_Menu::getMaxWeight('civicrm/contact/view');
     //           $startWeight++;
     //           CRM_Core_BAO_CustomGroup::addMenuTabs(CRM_Contact_BAO_Contact::getContactType($cid), 'civicrm/contact/view/cd', $startWeight);
     //           $this->_contactIds = array( $cid );
     //           $this->_single     = true;
     //           $this->assign( 'totalSelectedContacts', 1 );
     //       } else {
     parent::preProcess();
     //       }
 }
コード例 #20
0
 /**
  * build all the data structures needed to build the form
  *
  * @return void
  * @access public
  */
 function preProcess()
 {
     $id = CRM_Utils_Request::retrieve('id', 'Positive', $this, FALSE);
     if ($id) {
         $this->_contributionIds = array($id);
         $this->_componentClause = " civicrm_contribution.id IN ( {$id} ) ";
         $this->_single = TRUE;
         $this->assign('totalSelectedContributions', 1);
     } else {
         parent::preProcess();
     }
     // check that all the contribution ids have pending status
     $query = "\nSELECT count(*)\nFROM   civicrm_contribution\nWHERE  contribution_status_id != 2\nAND    {$this->_componentClause}";
     $count = CRM_Core_DAO::singleValueQuery($query, CRM_Core_DAO::$_nullArray);
     if ($count != 0) {
         CRM_Core_Error::statusBounce(ts('Please select only online contributions with Pending status.'));
     }
     // we have all the contribution ids, so now we get the contact ids
     parent::setContactIDs();
     $this->assign('single', $this->_single);
 }
コード例 #21
0
 /**
  * Build all the data structures needed to build the form.
  *
  * @return void
  */
 public function preProcess()
 {
     $id = CRM_Utils_Request::retrieve('id', 'Positive', $this, FALSE);
     if ($id) {
         $this->_contributionIds = array($id);
         $this->_componentClause = " civicrm_contribution.id IN ( {$id} ) ";
         $this->_single = TRUE;
         $this->assign('totalSelectedContributions', 1);
         // set the redirection after actions
         $contactId = CRM_Utils_Request::retrieve('cid', 'Positive', $this, FALSE);
         $url = CRM_Utils_System::url('civicrm/contact/view/contribution', "action=view&reset=1&id={$id}&cid={$contactId}&context=contribution&selectedChild=contribute");
         CRM_Core_Session::singleton()->pushUserContext($url);
     } else {
         parent::preProcess();
     }
     // check that all the contribution ids have status Completed, Pending, Refunded.
     $this->_contributionStatusId = CRM_Contribute_PseudoConstant::contributionStatus(NULL, 'name');
     $status = array('Completed', 'Pending', 'Refunded');
     $statusId = array();
     foreach ($this->_contributionStatusId as $key => $value) {
         if (in_array($value, $status)) {
             $statusId[] = $key;
         }
     }
     $Id = implode(",", $statusId);
     $query = "SELECT count(*) FROM civicrm_contribution WHERE contribution_status_id NOT IN ({$Id}) AND {$this->_componentClause}";
     $count = CRM_Core_DAO::singleValueQuery($query);
     if ($count != 0) {
         CRM_Core_Error::statusBounce(ts('Please select only contributions with Completed, Pending, Refunded status.'));
     }
     // we have all the contribution ids, so now we get the contact ids
     parent::setContactIDs();
     $this->assign('single', $this->_single);
     $qfKey = CRM_Utils_Request::retrieve('qfKey', 'String', $this);
     $urlParams = 'force=1';
     if (CRM_Utils_Rule::qfKey($qfKey)) {
         $urlParams .= "&qfKey={$qfKey}";
     }
     $url = CRM_Utils_System::url('civicrm/contribute/search', $urlParams);
     $breadCrumb = array(array('url' => $url, 'title' => ts('Search Results')));
     CRM_Utils_System::appendBreadCrumb($breadCrumb);
     $this->_selectedOutput = CRM_Utils_Request::retrieve('select', 'String', $this);
     $this->assign('selectedOutput', $this->_selectedOutput);
     if ($this->_selectedOutput == 'email') {
         CRM_Utils_System::setTitle(ts('Email Invoice'));
     } else {
         CRM_Utils_System::setTitle(ts('Print Contribution Invoice'));
     }
 }
コード例 #22
0
ファイル: Select.php プロジェクト: kcristiano/civicrm-core
 /**
  * Build all the data structures needed to build the form.
  *
  * @param
  *
  * @return void
  */
 public function preProcess()
 {
     //special case for custom search, directly give option to download csv file
     $customSearchID = $this->get('customSearchID');
     if ($customSearchID) {
         CRM_Export_BAO_Export::exportCustom($this->get('customSearchClass'), $this->get('formValues'), $this->get(CRM_Utils_Sort::SORT_ORDER));
     }
     $this->_selectAll = FALSE;
     $this->_exportMode = self::CONTACT_EXPORT;
     $this->_componentIds = array();
     $this->_componentClause = NULL;
     // get the submitted values based on search
     if ($this->_action == CRM_Core_Action::ADVANCED) {
         $values = $this->controller->exportValues('Advanced');
     } elseif ($this->_action == CRM_Core_Action::PROFILE) {
         $values = $this->controller->exportValues('Builder');
     } elseif ($this->_action == CRM_Core_Action::COPY) {
         $values = $this->controller->exportValues('Custom');
     } else {
         // we need to determine component export
         $stateMachine = $this->controller->getStateMachine();
         $formName = CRM_Utils_System::getClassName($stateMachine);
         $componentName = explode('_', $formName);
         $components = array('Contribute', 'Member', 'Event', 'Pledge', 'Case', 'Grant', 'Activity');
         if (in_array($componentName[1], $components)) {
             switch ($componentName[1]) {
                 case 'Contribute':
                     $this->_exportMode = self::CONTRIBUTE_EXPORT;
                     break;
                 case 'Member':
                     $this->_exportMode = self::MEMBER_EXPORT;
                     break;
                 case 'Event':
                     $this->_exportMode = self::EVENT_EXPORT;
                     break;
                 case 'Pledge':
                     $this->_exportMode = self::PLEDGE_EXPORT;
                     break;
                 case 'Case':
                     $this->_exportMode = self::CASE_EXPORT;
                     break;
                 case 'Grant':
                     $this->_exportMode = self::GRANT_EXPORT;
                     break;
                 case 'Activity':
                     $this->_exportMode = self::ACTIVITY_EXPORT;
                     break;
             }
             $className = "CRM_{$componentName[1]}_Form_Task";
             $className::preProcessCommon($this, TRUE);
             $values = $this->controller->exportValues('Search');
         } else {
             $values = $this->controller->exportValues('Basic');
         }
     }
     $count = 0;
     $this->_matchingContacts = FALSE;
     if (CRM_Utils_Array::value('radio_ts', $values) == 'ts_sel') {
         foreach ($values as $key => $value) {
             if (strstr($key, 'mark_x')) {
                 $count++;
             }
             if ($count > 2) {
                 $this->_matchingContacts = TRUE;
                 break;
             }
         }
     }
     $componentMode = $this->get('component_mode');
     switch ($componentMode) {
         case 2:
             CRM_Contribute_Form_Task::preProcessCommon($this, TRUE);
             $this->_exportMode = self::CONTRIBUTE_EXPORT;
             $componentName = array('', 'Contribute');
             break;
         case 3:
             CRM_Event_Form_Task::preProcessCommon($this, TRUE);
             $this->_exportMode = self::EVENT_EXPORT;
             $componentName = array('', 'Event');
             break;
         case 4:
             CRM_Activity_Form_Task::preProcessCommon($this, TRUE);
             $this->_exportMode = self::ACTIVITY_EXPORT;
             $componentName = array('', 'Activity');
             break;
         case 5:
             CRM_Member_Form_Task::preProcessCommon($this, TRUE);
             $this->_exportMode = self::MEMBER_EXPORT;
             $componentName = array('', 'Member');
             break;
         case 6:
             CRM_Case_Form_Task::preProcessCommon($this, TRUE);
             $this->_exportMode = self::CASE_EXPORT;
             $componentName = array('', 'Case');
             break;
     }
     $this->_task = $values['task'];
     if ($this->_exportMode == self::CONTACT_EXPORT) {
         $contactTasks = CRM_Contact_Task::taskTitles();
         $taskName = $contactTasks[$this->_task];
         $component = FALSE;
         CRM_Contact_Form_Task::preProcessCommon($this, TRUE);
     } else {
         $this->assign('taskName', "Export {$componentName['1']}");
         $className = "CRM_{$componentName[1]}_Task";
         $componentTasks = $className::tasks();
         $taskName = $componentTasks[$this->_task];
         $component = TRUE;
     }
     if ($this->_componentTable) {
         $query = "\nSELECT count(*)\nFROM   {$this->_componentTable}\n";
         $totalSelectedRecords = CRM_Core_DAO::singleValueQuery($query);
     } else {
         $totalSelectedRecords = count($this->_componentIds);
     }
     $this->assign('totalSelectedRecords', $totalSelectedRecords);
     $this->assign('taskName', $taskName);
     $this->assign('component', $component);
     // all records actions = save a search
     if ($values['radio_ts'] == 'ts_all' || $this->_task == CRM_Contact_Task::SAVE_SEARCH) {
         $this->_selectAll = TRUE;
         $rowCount = $this->get('rowCount');
         if ($rowCount > 2) {
             $this->_matchingContacts = TRUE;
         }
         $this->assign('totalSelectedRecords', $rowCount);
     }
     $this->assign('matchingContacts', $this->_matchingContacts);
     $this->set('componentIds', $this->_componentIds);
     $this->set('selectAll', $this->_selectAll);
     $this->set('exportMode', $this->_exportMode);
     $this->set('componentClause', $this->_componentClause);
     $this->set('componentTable', $this->_componentTable);
 }
コード例 #23
0
 /**
  * Process the form after the input has been submitted and validated.
  *
  * @param CRM_Contribute_Form_Task $form
  */
 public static function postProcess(&$form)
 {
     $formValues = $form->controller->exportValues($form->getName());
     list($formValues, $categories, $html_message, $messageToken, $returnProperties) = self::processMessageTemplate($formValues);
     $isPDF = FALSE;
     $emailParams = array();
     if (!empty($formValues['email_options'])) {
         $returnProperties['email'] = $returnProperties['on_hold'] = $returnProperties['is_deceased'] = $returnProperties['do_not_email'] = 1;
         $emailParams = array('subject' => $formValues['subject']);
         // We need display_name for emailLetter() so add to returnProperties here
         $returnProperties['display_name'] = 1;
         if (stristr($formValues['email_options'], 'pdfemail')) {
             $isPDF = TRUE;
         }
     }
     // update dates ?
     $receipt_update = isset($formValues['receipt_update']) ? $formValues['receipt_update'] : FALSE;
     $thankyou_update = isset($formValues['thankyou_update']) ? $formValues['thankyou_update'] : FALSE;
     $nowDate = date('YmdHis');
     $receipts = $thanks = $emailed = 0;
     $updateStatus = '';
     $task = 'CRM_Contribution_Form_Task_PDFLetterCommon';
     $realSeparator = ', ';
     $tableSeparators = array('td' => '</td><td>', 'tr' => '</td></tr><tr><td>');
     //the original thinking was mutliple options - but we are going with only 2 (comma & td) for now in case
     // there are security (& UI) issues we need to think through
     if (isset($formValues['group_by_separator'])) {
         if (in_array($formValues['group_by_separator'], array('td', 'tr'))) {
             $realSeparator = $tableSeparators[$formValues['group_by_separator']];
         } elseif ($formValues['group_by_separator'] == 'br') {
             $realSeparator = "<br />";
         }
     }
     $separator = '****~~~~';
     // a placeholder in case the separator is common in the string - e.g ', '
     $validated = FALSE;
     $groupBy = $formValues['group_by'];
     // skip some contacts ?
     $skipOnHold = isset($form->skipOnHold) ? $form->skipOnHold : FALSE;
     $skipDeceased = isset($form->skipDeceased) ? $form->skipDeceased : TRUE;
     $contributionIDs = $form->getVar('_contributionIds');
     if ($form->_includesSoftCredits) {
         //@todo - comment on what is stored there
         $contributionIDs = $form->getVar('_contributionContactIds');
     }
     list($contributions, $contacts) = self::buildContributionArray($groupBy, $contributionIDs, $returnProperties, $skipOnHold, $skipDeceased, $messageToken, $task, $separator, $form->_includesSoftCredits);
     $html = array();
     foreach ($contributions as $contributionId => $contribution) {
         $contact =& $contacts[$contribution['contact_id']];
         $grouped = $groupByID = 0;
         if ($groupBy) {
             $groupByID = empty($contribution[$groupBy]) ? 0 : $contribution[$groupBy];
             $contribution = $contact['combined'][$groupBy][$groupByID];
             $grouped = TRUE;
         }
         self::assignCombinedContributionValues($contact, $contributions, $groupBy, $groupByID);
         if (empty($groupBy) || empty($contact['is_sent'][$groupBy][$groupByID])) {
             if (!$validated && in_array($realSeparator, $tableSeparators) && !self::isValidHTMLWithTableSeparator($messageToken, $html_message)) {
                 $realSeparator = ', ';
                 CRM_Core_Session::setStatus(ts('You have selected the table cell separator, but one or more token fields are not placed inside a table cell. This would result in invalid HTML, so comma separators have been used instead.'));
             }
             $validated = TRUE;
             $html[$contributionId] = str_replace($separator, $realSeparator, self::resolveTokens($html_message, $contact, $contribution, $messageToken, $categories, $grouped, $separator));
             $contact['is_sent'][$groupBy][$groupByID] = TRUE;
             if (!empty($formValues['email_options'])) {
                 if (self::emailLetter($contact, $html[$contributionId], $isPDF, $formValues, $emailParams)) {
                     $emailed++;
                     if (!stristr($formValues['email_options'], 'both')) {
                         unset($html[$contributionId]);
                     }
                 }
             }
         }
         // update dates (do it for each contribution including grouped recurring contribution)
         //@todo - the 2 calls below bypass all hooks. Using the api would possibly be slower than one call but not than 2
         if ($receipt_update) {
             $result = CRM_Core_DAO::setFieldValue('CRM_Contribute_DAO_Contribution', $contributionId, 'receipt_date', $nowDate);
             if ($result) {
                 $receipts++;
             }
         }
         if ($thankyou_update) {
             $result = CRM_Core_DAO::setFieldValue('CRM_Contribute_DAO_Contribution', $contributionId, 'thankyou_date', $nowDate);
             if ($result) {
                 $thanks++;
             }
         }
     }
     //createActivities requires both $form->_contactIds and $contacts -
     //@todo - figure out why
     $form->_contactIds = array_keys($contacts);
     self::createActivities($form, $html_message, $form->_contactIds);
     if (!empty($html)) {
         CRM_Utils_PDF_Utils::html2pdf($html, "CiviLetter.pdf", FALSE, $formValues);
     }
     $form->postProcessHook();
     if ($emailed) {
         $updateStatus = ts('Receipts have been emailed to %1 contributions.', array(1 => $emailed));
     }
     if ($receipts) {
         $updateStatus = ts('Receipt date has been updated for %1 contributions.', array(1 => $receipts));
     }
     if ($thanks) {
         $updateStatus .= ' ' . ts('Thank-you date has been updated for %1 contributions.', array(1 => $thanks));
     }
     if ($updateStatus) {
         CRM_Core_Session::setStatus($updateStatus);
     }
     if (!empty($html)) {
         // ie. we have only sent emails - lets no show a white screen
         CRM_Utils_System::civiExit(1);
     }
 }
コード例 #24
0
 /**
  * Generate the contribution array from the form, we fill in the contact details and determine any aggregation
  * around contact_id of contribution_recur_id
  *
  * @param string $groupBy
  * @param CRM_Contribute_Form_Task $form
  * @param array $returnProperties
  * @param bool $skipOnHold
  * @param bool $skipDeceased
  * @param array $messageToken
  * @param string $task
  * @param string $separator
  *
  * @return array
  */
 public static function buildContributionArray($groupBy, $form, $returnProperties, $skipOnHold, $skipDeceased, $messageToken, $task, $separator)
 {
     $contributions = $contacts = $notSent = array();
     $contributionIDs = $form->getVar('_contributionIds');
     if ($form->_includesSoftCredits) {
         //@todo - comment on what is stored there
         $contributionIDs = $form->getVar('_contributionContactIds');
     }
     foreach ($contributionIDs as $item => $contributionId) {
         // get contribution information
         $contribution = CRM_Utils_Token::getContributionTokenDetails(array('contribution_id' => $contributionId), $returnProperties, NULL, $messageToken, $task);
         $contribution = $contributions[$contributionId] = $contribution[$contributionId];
         if ($form->_includesSoftCredits) {
             //@todo find out why this happens & add comments
             list($contactID) = explode('-', $item);
             $contactID = (int) $contactID;
         } else {
             $contactID = $contribution['contact_id'];
         }
         if (!isset($contacts[$contactID])) {
             list($contact) = CRM_Utils_Token::getTokenDetails(array('contact_id' => $contactID), $returnProperties, $skipOnHold, $skipDeceased, NULL, $messageToken, $task);
             $contacts[$contactID] = $contact[$contactID];
             $contacts[$contactID]['contact_aggregate'] = 0;
             $contacts[$contactID]['combined'] = $contacts[$contactID]['contribution_ids'] = array();
         }
         $contacts[$contactID]['contact_aggregate'] += $contribution['total_amount'];
         $groupByID = empty($contribution[$groupBy]) ? 0 : $contribution[$groupBy];
         $contacts[$contactID]['contribution_ids'][$groupBy][$groupByID][$contributionId] = TRUE;
         if (!isset($contacts[$contactID]['combined'][$groupBy]) || !isset($contacts[$contactID]['combined'][$groupBy][$groupByID])) {
             $contacts[$contactID]['combined'][$groupBy][$groupByID] = $contribution;
             $contacts[$contactID]['aggregates'][$groupBy][$groupByID] = $contribution['total_amount'];
         } else {
             $contacts[$contactID]['combined'][$groupBy][$groupByID] = self::combineContributions($contacts[$contactID]['combined'][$groupBy][$groupByID], $contribution, $separator);
             $contacts[$contactID]['aggregates'][$groupBy][$groupByID] += $contribution['total_amount'];
         }
     }
     return array($contributions, $contacts);
 }
コード例 #25
0
ファイル: Select.php プロジェクト: hampelm/Ginsberg-CiviDemo
 /**
  * build all the data structures needed to build the form
  *
  * @param
  * @return void
  * @access public
  */
 function preProcess()
 {
     //special case for custom search, directly give option to download csv file
     $customSearchID = $this->get('customSearchID');
     if ($customSearchID) {
         require_once 'CRM/Export/BAO/Export.php';
         CRM_Export_BAO_Export::exportCustom($this->get('customSearchClass'), $this->get('formValues'), $this->get(CRM_Utils_Sort::SORT_ORDER));
     }
     $this->_selectAll = false;
     $this->_exportMode = self::CONTACT_EXPORT;
     // get the submitted values based on search
     if ($this->_action == CRM_Core_Action::ADVANCED) {
         $values = $this->controller->exportValues('Advanced');
     } else {
         if ($this->_action == CRM_Core_Action::PROFILE) {
             $values = $this->controller->exportValues('Builder');
         } else {
             if ($this->_action == CRM_Core_Action::COPY) {
                 $values = $this->controller->exportValues('Custom');
             } else {
                 // we need to determine component export
                 $stateMachine =& $this->controller->getStateMachine();
                 $formName = CRM_Utils_System::getClassName($stateMachine);
                 $componentName = explode('_', $formName);
                 $components = array('Contribute', 'Member', 'Event', 'Pledge', 'Case', 'Grant', 'Activity');
                 if (in_array($componentName[1], $components)) {
                     eval('$this->_exportMode = self::' . strtoupper($componentName[1]) . '_EXPORT;');
                     require_once "CRM/{$componentName[1]}/Form/Task.php";
                     eval('CRM_' . $componentName[1] . '_Form_Task::preProcessCommon( $this, true );');
                     $values = $this->controller->exportValues('Search');
                 } else {
                     $values = $this->controller->exportValues('Basic');
                 }
             }
         }
     }
     $componentMode = $this->get('component_mode');
     switch ($componentMode) {
         case 2:
             require_once "CRM/Contribute/Form/Task.php";
             CRM_Contribute_Form_Task::preProcessCommon($this, true);
             $this->_exportMode = self::CONTRIBUTE_EXPORT;
             $componentName = array('', 'Contribute');
             break;
         case 3:
             require_once "CRM/Event/Form/Task.php";
             CRM_Event_Form_Task::preProcessCommon($this, true);
             $this->_exportMode = self::EVENT_EXPORT;
             $componentName = array('', 'Event');
             break;
         case 4:
             require_once "CRM/Activity/Form/Task.php";
             CRM_Activity_Form_Task::preProcessCommon($this, true);
             $this->_exportMode = self::ACTIVITY_EXPORT;
             $componentName = array('', 'Activity');
             break;
     }
     require_once 'CRM/Contact/Task.php';
     $this->_task = $values['task'];
     if ($this->_exportMode == self::CONTACT_EXPORT) {
         $contactTasks = CRM_Contact_Task::taskTitles();
         $taskName = $contactTasks[$this->_task];
         require_once "CRM/Contact/Form/Task.php";
         CRM_Contact_Form_Task::preProcessCommon($this, true);
     } else {
         $this->assign('taskName', "Export {$componentName['1']}");
         eval('$componentTasks = CRM_' . $componentName[1] . '_Task::tasks();');
         $taskName = $componentTasks[$this->_task];
     }
     if ($this->_componentTable) {
         $query = "\nSELECT count(*)\nFROM   {$this->_componentTable}\n";
         $totalSelectedRecords = CRM_Core_DAO::singleValueQuery($query);
     } else {
         $totalSelectedRecords = count($this->_componentIds);
     }
     $this->assign('totalSelectedRecords', $totalSelectedRecords);
     $this->assign('taskName', $taskName);
     // all records actions = save a search
     if ($values['radio_ts'] == 'ts_all' || $this->_task == CRM_Contact_Task::SAVE_SEARCH) {
         $this->_selectAll = true;
         $this->assign('totalSelectedRecords', $this->get('rowCount'));
     }
     $this->set('componentIds', $this->_componentIds);
     $this->set('selectAll', $this->_selectAll);
     $this->set('exportMode', $this->_exportMode);
     $this->set('componentClause', $this->_componentClause);
     $this->set('componentTable', $this->_componentTable);
 }
コード例 #26
0
 /**
  * build all the data structures needed to build the form
  *
  * @return void
  * @access public
  */
 function preProcess()
 {
     //check for permission to edit contributions
     if (!CRM_Core_Permission::check('issue cdn tax receipts')) {
         CRM_Core_Error::fatal(ts('You do not have permission to access this page', array('domain' => 'org.civicrm.cdntaxreceipts')));
     }
     parent::preProcess();
     $this->_contributions_status = array();
     $this->_issue_type = array('original', 'duplicate');
     $this->_receipts = array();
     $this->_years = array();
     $receipts = array('totals' => array('total_contrib' => 0, 'loading_errors' => 0, 'total_contacts' => 0, 'original' => 0, 'duplicate' => 0));
     $this->_contributions_status = cdntaxreceipts_contributions_get_status($this->_contributionIds);
     // Get the number of years selected
     foreach ($this->_contributions_status as $contrib_status) {
         $this->_years[$contrib_status['receive_year']] = $contrib_status['receive_year'];
     }
     foreach ($this->_years as $year) {
         foreach ($this->_issue_type as $issue_type) {
             $receipts[$issue_type][$year] = array('total_contrib' => 0, 'total_amount' => 0, 'email' => array('contribution_count' => 0, 'receipt_count' => 0), 'print' => array('contribution_count' => 0, 'receipt_count' => 0), 'total_contacts' => 0, 'total_eligible_amount' => 0, 'not_eligible' => 0, 'not_eligible_amount' => 0, 'contact_ids' => array());
         }
     }
     // Count and categorize contributions
     foreach ($this->_contributionIds as $id) {
         $status = isset($this->_contributions_status[$id]) ? $this->_contributions_status[$id] : NULL;
         if (is_array($status)) {
             $year = $status['receive_year'];
             $issue_type = empty($status['receipt_id']) ? 'original' : 'duplicate';
             $receipts[$issue_type][$year]['total_contrib']++;
             // Note: non-deductible amount has already had hook called in cdntaxreceipts_contributions_get_status
             $receipts[$issue_type][$year]['total_amount'] += $status['total_amount'];
             $receipts[$issue_type][$year]['not_eligible_amount'] += $status['non_deductible_amount'];
             if ($status['eligible']) {
                 list($method, $email) = cdntaxreceipts_sendMethodForContact($status['contact_id']);
                 $receipts[$issue_type][$year][$method]['contribution_count']++;
                 if (!isset($receipts[$issue_type][$year]['contact_ids'][$status['contact_id']])) {
                     $receipts[$issue_type][$year]['contact_ids'][$status['contact_id']] = array('issue_method' => $method, 'contributions' => array());
                     $receipts[$issue_type][$year][$method]['receipt_count']++;
                 }
                 // Here we store all the contribution details for each contact_id
                 $receipts[$issue_type][$year]['contact_ids'][$status['contact_id']]['contributions'][$id] = $status;
             } else {
                 $receipts[$issue_type][$year]['not_eligible']++;
                 // $receipts[$issue_type][$year]['not_eligible_amount'] += $status['total_amount'];
             }
             // Global totals
             $receipts['totals']['total_contrib']++;
             $receipts['totals'][$issue_type]++;
             if ($status['contact_id']) {
                 $receipts['totals']['total_contacts']++;
             }
         } else {
             $receipts['loading_errors']++;
         }
     }
     foreach ($this->_issue_type as $issue_type) {
         foreach ($this->_years as $year) {
             $receipts[$issue_type][$year]['total_contacts'] = count($receipts[$issue_type][$year]['contact_ids']);
         }
     }
     $this->_receipts = $receipts;
 }