Ejemplo n.º 1
0
 /**
  * Build the form
  *
  * @access public
  *
  * @return void
  */
 function buildQuickForm()
 {
     $grantStatus = CRM_Grant_PseudoConstant::grantStatus();
     $this->addElement('select', 'status_id', ts('Grant Status'), array('' => '') + $grantStatus);
     $this->addElement('text', 'amount_granted', ts('Amount Granted'));
     $this->addRule('amount_granted', ts('Please enter a valid amount.'), 'money');
     $this->addDate('decision_date', ts('Grant Decision'), FALSE, array('formatType' => 'custom'));
     $this->assign('elements', array('status_id', 'amount_granted', 'decision_date'));
     $this->assign('totalSelectedGrants', count($this->_grantIds));
     $this->addDefaultButtons(ts('Update Grants'), 'done');
 }
 /**
  * Get all the n grant statuses
  *
  * @access public
  *
  * @return array - array reference of all grant statuses if any
  * @static
  */
 public static function &grantStatus($id = NULL)
 {
     if (!self::$grantStatus) {
         self::$grantStatus = array();
         self::$grantStatus = CRM_Core_OptionGroup::values('grant_status');
     }
     if ($id) {
         return self::$grantStatus[$id];
     }
     return self::$grantStatus;
 }
Ejemplo n.º 3
0
 /**
  * Get all the n grant statuses
  *
  * @access public
  * @return array - array reference of all grant statuses if any
  * @static
  */
 public static function &grantStatus($id = null)
 {
     if (!self::$grantStatus) {
         self::$grantStatus = array();
         require_once "CRM/Core/OptionGroup.php";
         self::$grantStatus = CRM_Core_OptionGroup::values("grant_status");
     }
     if ($id) {
         return self::$grantStatus[$id];
     }
     return self::$grantStatus;
 }
Ejemplo n.º 4
0
 /**  
  * Function to set variables up before form is built  
  *                                                            
  * @return void  
  * @access public  
  */
 public function preProcess()
 {
     $this->_contactID = CRM_Utils_Request::retrieve('cid', 'Positive', $this);
     $this->_id = CRM_Utils_Request::retrieve('id', 'Positive', $this);
     $context = CRM_Utils_Request::retrieve('context', 'String', $this);
     $this->assign('context', $context);
     $values = array();
     $params['id'] = $this->_id;
     require_once 'CRM/Grant/BAO/Grant.php';
     CRM_Grant_BAO_Grant::retrieve($params, $values);
     require_once 'CRM/Grant/PseudoConstant.php';
     $grantType = CRM_Grant_PseudoConstant::grantType();
     $grantStatus = CRM_Grant_PseudoConstant::grantStatus();
     $this->assign('grantType', $grantType[$values['grant_type_id']]);
     $this->assign('grantStatus', $grantStatus[$values['status_id']]);
     $grantTokens = array('amount_total', 'amount_requested', 'amount_granted', 'rationale', 'grant_report_received', 'application_received_date', 'decision_date', 'money_transfer_date', 'grant_due_date');
     foreach ($grantTokens as $token) {
         $this->assign($token, CRM_Utils_Array::value($token, $values));
     }
     if (isset($this->_id)) {
         require_once 'CRM/Core/BAO/Note.php';
         $noteDAO = new CRM_Core_BAO_Note();
         $noteDAO->entity_table = 'civicrm_grant';
         $noteDAO->entity_id = $this->_id;
         if ($noteDAO->find(true)) {
             $this->_noteId = $noteDAO->id;
         }
     }
     if (isset($this->_noteId)) {
         $this->assign('note', CRM_Core_DAO::getFieldValue('CRM_Core_DAO_Note', $this->_noteId, 'note'));
     }
     // add Grant to Recent Items
     require_once 'CRM/Utils/Recent.php';
     require_once 'CRM/Contact/BAO/Contact.php';
     require_once 'CRM/Utils/Money.php';
     $url = CRM_Utils_System::url('civicrm/contact/view/grant', "action=view&reset=1&id={$values['id']}&cid={$values['contact_id']}&context=home");
     $title = CRM_Contact_BAO_Contact::displayName($values['contact_id']) . ' - ' . ts('Grant') . ': ' . CRM_Utils_Money::format($values['amount_total']) . ' (' . $grantType[$values['grant_type_id']] . ')';
     $recentOther = array();
     if (CRM_Core_Permission::checkActionPermission('CiviGrant', CRM_Core_Action::UPDATE)) {
         $recentOther['editUrl'] = CRM_Utils_System::url('civicrm/contact/view/grant', "action=update&reset=1&id={$values['id']}&cid={$values['contact_id']}&context=home");
     }
     if (CRM_Core_Permission::checkActionPermission('CiviGrant', CRM_Core_Action::DELETE)) {
         $recentOther['deleteUrl'] = CRM_Utils_System::url('civicrm/contact/view/grant', "action=delete&reset=1&id={$values['id']}&cid={$values['contact_id']}&context=home");
     }
     CRM_Utils_Recent::add($title, $url, $values['id'], 'Grant', $values['contact_id'], null, $recentOther);
     require_once 'CRM/Core/BAO/File.php';
     $attachment = CRM_Core_BAO_File::attachmentInfo('civicrm_grant', $this->_id);
     $this->assign('attachment', $attachment);
     $groupTree =& CRM_Core_BAO_CustomGroup::getTree("Grant", $this, $this->_id, 0);
     CRM_Core_BAO_CustomGroup::buildCustomDataView($this, $groupTree);
     $this->assign('id', $this->_id);
 }
Ejemplo n.º 5
0
 /**
  * Function to get events Summary
  *
  * @static
  *
  * @return array Array of event summary values
  */
 static function getGrantSummary($admin = FALSE)
 {
     $query = "\n            SELECT status_id, count(id) as status_total\n            FROM civicrm_grant  GROUP BY status_id";
     $dao = CRM_Core_DAO::executeQuery($query, CRM_Core_DAO::$_nullArray);
     $status = array();
     $summary = array();
     $summary['total_grants'] = NULL;
     $status = CRM_Grant_PseudoConstant::grantStatus();
     foreach ($status as $id => $name) {
         $stats[$id] = array('label' => $name, 'total' => 0);
     }
     while ($dao->fetch()) {
         $stats[$dao->status_id] = array('label' => $status[$dao->status_id], 'total' => $dao->status_total);
         $summary['total_grants'] += $dao->status_total;
     }
     $summary['per_status'] = $stats;
     return $summary;
 }
Ejemplo n.º 6
0
 function alterDisplay(&$rows)
 {
     // custom code to alter rows
     $entryFound = false;
     foreach ($rows as $rowNum => $row) {
         if (array_key_exists('civicrm_grant_grant_type_id', $row)) {
             if ($value = $row['civicrm_grant_grant_type_id']) {
                 $rows[$rowNum]['civicrm_grant_grant_type_id'] = CRM_Grant_PseudoConstant::grantType($value);
             }
             $entryFound = true;
         }
         if (array_key_exists('civicrm_grant_status_id', $row)) {
             if ($value = $row['civicrm_grant_status_id']) {
                 $rows[$rowNum]['civicrm_grant_status_id'] = CRM_Grant_PseudoConstant::grantStatus($value);
             }
             $entryFound = true;
         }
         if (array_key_exists('civicrm_grant_grant_report_received', $row)) {
             if ($value = $row['civicrm_grant_grant_report_received']) {
                 if ($value == 1) {
                     $value = 'Yes';
                 } else {
                     $value = 'No';
                 }
                 $rows[$rowNum]['civicrm_grant_grant_report_received'] = $value;
             }
             $entryFound = true;
         }
         if (!$entryFound) {
             break;
         }
     }
 }
Ejemplo n.º 7
0
 function alterDisplay(&$rows)
 {
     // custom code to alter rows
     $entryFound = FALSE;
     foreach ($rows as $rowNum => $row) {
         // convert display name to links
         if (array_key_exists('civicrm_contact_sort_name', $row) && array_key_exists('civicrm_contact_id', $row)) {
             $url = CRM_Utils_System::url('civicrm/contact/view', 'reset=1&cid=' . $row['civicrm_contact_id'], $this->_absoluteUrl);
             $rows[$rowNum]['civicrm_contact_sort_name_link'] = $url;
             $rows[$rowNum]['civicrm_contact_sort_name_hover'] = ts("View contact details for this record.");
             $entryFound = TRUE;
         }
         if (array_key_exists('civicrm_grant_grant_type_id', $row)) {
             if ($value = $row['civicrm_grant_grant_type_id']) {
                 $rows[$rowNum]['civicrm_grant_grant_type_id'] = CRM_Grant_PseudoConstant::grantType($value);
             }
             $entryFound = TRUE;
         }
         if (array_key_exists('civicrm_grant_status_id', $row)) {
             if ($value = $row['civicrm_grant_status_id']) {
                 $rows[$rowNum]['civicrm_grant_status_id'] = CRM_Grant_PseudoConstant::grantStatus($value);
             }
             $entryFound = TRUE;
         }
         if (array_key_exists('civicrm_grant_grant_report_received', $row)) {
             if ($value = $row['civicrm_grant_grant_report_received']) {
                 if ($value == 1) {
                     $value = 'Yes';
                 } else {
                     $value = 'No';
                 }
                 $rows[$rowNum]['civicrm_grant_grant_report_received'] = $value;
             }
             $entryFound = TRUE;
         }
         if (!$entryFound) {
             break;
         }
     }
 }
Ejemplo n.º 8
0
 /**
  * returns all the rows in the given offset and rowCount     *
  * @param enum   $action   the action being performed
  * @param int    $offset   the row number to start from
  * @param int    $rowCount the number of rows to return
  * @param string $sort     the sql string that describes the sort order
  * @param enum   $output   what should the result set include (web/email/csv)
  *
  * @return int   the total number of rows for this action
  */
 function &getRows($action, $offset, $rowCount, $sort, $output = null)
 {
     $result = $this->_query->searchQuery($offset, $rowCount, $sort, false, false, false, false, false, $this->_grantClause);
     // process the result of the query
     $rows = array();
     //CRM-4418 check for view, edit, delete
     $permissions = array(CRM_Core_Permission::VIEW);
     if (CRM_Core_Permission::check('edit grants')) {
         $permissions[] = CRM_Core_Permission::EDIT;
     }
     if (CRM_Core_Permission::check('delete in CiviGrant')) {
         $permissions[] = CRM_Core_Permission::DELETE;
     }
     $mask = CRM_Core_Action::mask($permissions);
     require_once 'CRM/Grant/PseudoConstant.php';
     $grantStatus = array();
     $grantStatus = CRM_Grant_PseudoConstant::grantStatus();
     $grantType = array();
     $grantType = CRM_Grant_PseudoConstant::grantType();
     while ($result->fetch()) {
         $row = array();
         // the columns we are interested in
         foreach (self::$_properties as $property) {
             if (isset($result->{$property})) {
                 $row[$property] = $result->{$property};
             }
         }
         //fix status display
         $row['grant_status'] = $grantStatus[$row['grant_status_id']];
         $row['grant_type'] = $grantType[$row['grant_type_id']];
         if ($this->_context == 'search') {
             $row['checkbox'] = CRM_Core_Form::CB_PREFIX . $result->grant_id;
         }
         $row['action'] = CRM_Core_Action::formLink(self::links(), $mask, array('id' => $result->grant_id, 'cid' => $result->contact_id, 'cxt' => $this->_context));
         require_once 'CRM/Contact/BAO/Contact/Utils.php';
         $row['contact_type'] = CRM_Contact_BAO_Contact_Utils::getImage($result->contact_sub_type ? $result->contact_sub_type : $result->contact_type);
         $rows[] = $row;
     }
     return $rows;
 }