Commit | Line | Data |
---|---|---|
6a488035 | 1 | <?php |
6a488035 TO |
2 | |
3 | /* | |
4 | +--------------------------------------------------------------------+ | |
06b69b18 | 5 | | CiviCRM version 4.5 | |
6a488035 | 6 | +--------------------------------------------------------------------+ |
06b69b18 | 7 | | Copyright CiviCRM LLC (c) 2004-2014 | |
6a488035 TO |
8 | +--------------------------------------------------------------------+ |
9 | | This file is a part of CiviCRM. | | |
10 | | | | |
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. | | |
14 | | | | |
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. | | |
19 | | | | |
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 | +--------------------------------------------------------------------+ | |
27 | */ | |
28 | ||
29 | /** | |
30 | * | |
31 | * @package CRM | |
06b69b18 | 32 | * @copyright CiviCRM LLC (c) 2004-2014 |
6a488035 TO |
33 | * $Id$ |
34 | * | |
35 | */ | |
36 | ||
37 | /** | |
38 | * Page for displaying list of Reprot templates available | |
39 | */ | |
40 | class CRM_Report_Page_List extends CRM_Core_Page { | |
41 | ||
74cf4551 EM |
42 | /** |
43 | * @return array | |
44 | */ | |
6a488035 TO |
45 | public static function &info() { |
46 | $sql = " | |
2f4c2f5d | 47 | SELECT v.id, v.value, v.label, v.description, v.component_id, |
48 | inst.id as instance_id, ifnull( SUBSTRING(comp.name, 5), 'Contact' ) as component_name | |
6a488035 | 49 | FROM civicrm_option_value v |
2f4c2f5d | 50 | INNER JOIN civicrm_option_group g |
6a488035 | 51 | ON (v.option_group_id = g.id AND g.name = 'report_list') |
2f4c2f5d | 52 | LEFT JOIN civicrm_report_instance inst |
6a488035 | 53 | ON v.value = inst.report_id |
2f4c2f5d | 54 | LEFT JOIN civicrm_component comp |
6a488035 TO |
55 | ON v.component_id = comp.id |
56 | WHERE v.is_active = 1 | |
57 | ORDER BY v.weight"; | |
58 | ||
59 | $dao = CRM_Core_DAO::executeQuery($sql); | |
60 | $rows = array(); | |
61 | while ($dao->fetch()) { | |
62 | $url = 'civicrm/report/'; | |
63 | $rows[$dao->component_name][$dao->value]['title'] = $dao->label; | |
64 | $rows[$dao->component_name][$dao->value]['description'] = $dao->description; | |
65 | $rows[$dao->component_name][$dao->value]['url'] = CRM_Utils_System::url('civicrm/report/' . trim($dao->value, '/'), 'reset=1'); | |
66 | if ($dao->instance_id) { | |
67 | $rows[$dao->component_name][$dao->value]['instanceUrl'] = CRM_Utils_System::url('civicrm/report/instance/list', | |
68 | "reset=1&ovid={$dao->id}" | |
69 | ); | |
70 | } | |
71 | } | |
72 | ||
73 | return $rows; | |
74 | } | |
75 | ||
76 | /** | |
77 | * run this page (figure out the action needed and perform it). | |
78 | * | |
79 | * @return void | |
80 | */ | |
81 | function run() { | |
82 | $rows = self::info(); | |
83 | $this->assign('list', $rows); | |
84 | ||
85 | return parent::run(); | |
86 | } | |
87 | } | |
88 |