4 +--------------------------------------------------------------------+
5 | CiviCRM version 4.3 |
6 +--------------------------------------------------------------------+
7 | Copyright CiviCRM LLC (c) 2004-2013 |
8 +--------------------------------------------------------------------+
9 | This file is a part of CiviCRM. |
11 | CiviCRM is free software; you can copy, modify, and distribute it |
12 | under the terms of the GNU Affero General Public License |
13 | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
15 | CiviCRM is distributed in the hope that it will be useful, but |
16 | WITHOUT ANY WARRANTY; without even the implied warranty of |
17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
18 | See the GNU Affero General Public License for more details. |
20 | You should have received a copy of the GNU Affero General Public |
21 | License and the CiviCRM Licensing Exception along |
22 | with this program; if not, contact CiviCRM LLC |
23 | at info[AT]civicrm[DOT]org. If you have questions about the |
24 | GNU Affero General Public License or the licensing of CiviCRM, |
25 | see the CiviCRM license FAQ at http://civicrm.org/licensing |
26 +--------------------------------------------------------------------+
32 * @copyright CiviCRM LLC (c) 2004-2013
37 require_once 'CRM/Core/Page.php';
38 require_once 'CRM/Grant/BAO/GrantProgram.php';
42 * Page for displaying list of contribution types
44 class CRM_Grant_Page_GrantProgram
extends CRM_Core_Page
49 * The action links that we need to display for the browse screen
53 private static $_links;
57 * @return array (reference) of action links
61 if (!(self
::$_links)) {
62 self
::$_links = array(
63 CRM_Core_Action
::VIEW
=> array(
65 'url' => 'civicrm/grant_program',
66 'qs' => 'action=view&id=%%id%%&reset=1',
67 'title' => ts('View Grant Program')
69 CRM_Core_Action
::UPDATE
=> array(
71 'url' => 'civicrm/grant_program',
72 'qs' => 'action=update&id=%%id%%&reset=1',
73 'title' => ts('Edit Grant Program')
75 CRM_Core_Action
::DELETE
=> array(
76 'name' => ts('Delete'),
77 'url' => 'civicrm/grant_program',
78 'qs' => 'action=delete&id=%%id%%',
79 'title' => ts('Delete Grant Program')
88 $grantProgram = array();
89 require_once 'CRM/Grant/DAO/GrantProgram.php';
90 $dao = new CRM_Grant_DAO_GrantProgram();
92 $dao->orderBy('label');
95 while ($dao->fetch()) {
96 $grantProgram[$dao->id
] = array();
97 CRM_Core_DAO
::storeValues( $dao, $grantProgram[$dao->id
]);
98 $action = array_sum(array_keys($this->links()));
100 $grantProgram[$dao->id
]['action'] = CRM_Core_Action
::formLink(self
::links(), $action,
101 array('id' => $dao->id
));
103 require_once 'CRM/Grant/PseudoConstant.php';
104 $grantType = CRM_Grant_PseudoConstant
::grantType( );
105 $grantStatus = CRM_Grant_PseudoConstant
::grantProgramStatus( );
106 foreach ( $grantProgram as $key => $value ) {
107 $grantProgram[$key]['grant_type_id'] = $grantType[CRM_Grant_BAO_GrantProgram
::getOptionValue($grantProgram[$key]['grant_type_id'])];
108 $grantProgram[$key]['status_id'] = $grantStatus[CRM_Grant_BAO_GrantProgram
::getOptionValue($grantProgram[$key]['status_id'])];
110 $this->assign('rows',$grantProgram );
115 $action = CRM_Utils_Request
::retrieve('action', 'String',
117 if ( $action & CRM_Core_Action
::VIEW
) {
118 $this->view( $action);
119 } else if ( $action & ( CRM_Core_Action
::UPDATE | CRM_Core_Action
::ADD | CRM_Core_Action
::DELETE
) ) {
120 $this->edit( $action);
124 $this->assign('action', $action);
125 return parent
::run( );
128 function edit($action)
130 $controller = new CRM_Core_Controller_Simple('CRM_Grant_Form_GrantProgram', ts(''), $action);
131 $controller->setEmbedded(true);
132 $result = $controller->process();
133 $result = $controller->run();
136 function view( $action )
138 $controller = new CRM_Core_Controller_Simple( 'CRM_Grant_Form_GrantProgramView', ts(''), $action );
139 $controller->setEmbedded( true );
140 $result = $controller->process();
141 $result = $controller->run();