Пример #1
0
 /**
  * Process the form submission.
  */
 public function postProcess()
 {
     $params = $this->controller->exportValues($this->_name);
     if ($this->_action & CRM_Core_Action::DELETE) {
         CRM_Core_Session::setStatus("", ts("Batch Deleted"), "success");
         CRM_Batch_BAO_Batch::deleteBatch($this->_id);
         return;
     }
     if ($this->_id) {
         $params['id'] = $this->_id;
     } else {
         $session = CRM_Core_Session::singleton();
         $params['created_id'] = $session->get('userID');
         $params['created_date'] = CRM_Utils_Date::processDate(date("Y-m-d"), date("H:i:s"));
     }
     // always create with data entry status
     $params['status_id'] = CRM_Core_OptionGroup::getValue('batch_status', 'Data Entry', 'name');
     $batch = CRM_Batch_BAO_Batch::create($params);
     // redirect to batch entry page.
     $session = CRM_Core_Session::singleton();
     if ($this->_action & CRM_Core_Action::ADD) {
         $session->replaceUserContext(CRM_Utils_System::url('civicrm/batch/entry', "id={$batch->id}&reset=1&action=add"));
     } else {
         $session->replaceUserContext(CRM_Utils_System::url('civicrm/batch/entry', "id={$batch->id}&reset=1"));
     }
 }