示例#1
0
 /** 
  * Function to process the form 
  * 
  * @access public 
  * @return None 
  */
 public function postProcess()
 {
     if ($this->_action & CRM_Core_Action::DELETE) {
         require_once 'CRM/Grant/BAO/Grant.php';
         CRM_Grant_BAO_Grant::del($this->_id);
         return;
     }
     if ($this->_action & CRM_Core_Action::UPDATE) {
         $ids['grant'] = $this->_id;
     }
     // get the submitted form values.
     $params = $this->controller->exportValues($this->_name);
     if (!$params['grant_report_received']) {
         $params['grant_report_received'] = "null";
     }
     // set the contact, when contact is selected
     if (CRM_Utils_Array::value('contact_select_id', $params)) {
         $this->_contactID = $params['contact_select_id'][1];
     }
     $params['contact_id'] = $this->_contactID;
     $dates = array('application_received_date', 'decision_date', 'money_transfer_date', 'grant_due_date');
     foreach ($dates as $d) {
         $params[$d] = CRM_Utils_Date::processDate($params[$d], null, true);
     }
     $ids['note'] = array();
     if ($this->_noteId) {
         $ids['note']['id'] = $this->_noteId;
     }
     // process custom data
     $customFields = CRM_Core_BAO_CustomField::getFields('Grant');
     $params['custom'] = CRM_Core_BAO_CustomField::postProcess($params, $customFields, $this->_id, 'Grant');
     // add attachments as needed
     CRM_Core_BAO_File::formatAttachment($params, $params, 'civicrm_grant', $this->_id);
     require_once 'CRM/Grant/BAO/Grant.php';
     $grant = CRM_Grant_BAO_Grant::create($params, $ids);
     $buttonName = $this->controller->getButtonName();
     $session = CRM_Core_Session::singleton();
     if ($this->_context == 'standalone') {
         if ($buttonName == $this->getButtonName('upload', 'new')) {
             $session->replaceUserContext(CRM_Utils_System::url('civicrm/grant/add', 'reset=1&action=add&context=standalone'));
         } else {
             $session->replaceUserContext(CRM_Utils_System::url('civicrm/contact/view', "reset=1&cid={$this->_contactID}&selectedChild=grant"));
         }
     } else {
         if ($buttonName == $this->getButtonName('upload', 'new')) {
             $session->replaceUserContext(CRM_Utils_System::url('civicrm/contact/view/grant', "reset=1&action=add&context=grant&cid={$this->_contactID}"));
         }
     }
 }
示例#2
0
 /**
  * Function to process the form
  *
  * @access public
  *
  * @return void
  */
 public function postProcess()
 {
     if ($this->_action & CRM_Core_Action::DELETE) {
         CRM_Grant_BAO_Grant::del($this->_id);
         return;
     }
     if ($this->_action & CRM_Core_Action::UPDATE) {
         $ids['grant_id'] = $this->_id;
     }
     // get the submitted form values.
     $params = $this->controller->exportValues($this->_name);
     if (empty($params['grant_report_received'])) {
         $params['grant_report_received'] = "null";
     }
     // set the contact, when contact is selected
     if ($this->_context == 'standalone') {
         $this->_contactID = $params['contact_id'];
     }
     $params['contact_id'] = $this->_contactID;
     $ids['note'] = array();
     if ($this->_noteId) {
         $ids['note']['id'] = $this->_noteId;
     }
     // build custom data getFields array
     $customFieldsGrantType = CRM_Core_BAO_CustomField::getFields('Grant', FALSE, FALSE, CRM_Utils_Array::value('grant_type_id', $params));
     $customFields = CRM_Utils_Array::crmArrayMerge($customFieldsGrantType, CRM_Core_BAO_CustomField::getFields('Grant', FALSE, FALSE, NULL, NULL, TRUE));
     $params['custom'] = CRM_Core_BAO_CustomField::postProcess($params, $customFields, $this->_id, 'Grant');
     // add attachments as needed
     CRM_Core_BAO_File::formatAttachment($params, $params, 'civicrm_grant', $this->_id);
     $grant = CRM_Grant_BAO_Grant::create($params, $ids);
     $buttonName = $this->controller->getButtonName();
     $session = CRM_Core_Session::singleton();
     if ($this->_context == 'standalone') {
         if ($buttonName == $this->getButtonName('upload', 'new')) {
             $session->replaceUserContext(CRM_Utils_System::url('civicrm/grant/add', 'reset=1&action=add&context=standalone'));
         } else {
             $session->replaceUserContext(CRM_Utils_System::url('civicrm/contact/view', "reset=1&cid={$this->_contactID}&selectedChild=grant"));
         }
     } elseif ($buttonName == $this->getButtonName('upload', 'new')) {
         $session->replaceUserContext(CRM_Utils_System::url('civicrm/contact/view/grant', "reset=1&action=add&context=grant&cid={$this->_contactID}"));
     }
 }