PluginProbe
Property Hive / trunk
Property Hive vtrunk
2.2.6 2.2.5 2.2.4 2.2.3 2.2.2 1.4.46 1.4.47 1.4.48 1.4.49 1.4.5 1.4.50 1.4.51 1.4.52 1.4.53 1.4.54 1.4.55 1.4.56 1.4.57 1.4.58 1.4.59 1.4.6 1.4.60 1.4.61 1.4.62 1.4.63 All 259 releases
propertyhive / includes / admin / class-ph-admin-reports.php

class-ph-admin-reports.php in Property Hive trunk, at includes/admin/class-ph-admin-reports.php

139 lines 4.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * PropertyHive Admin Reports Class.
4 *
5 * @author PropertyHive
6 * @category Admin
7 * @package PropertyHive/Admin
8 * @version 1.0.0
9 */
10
11 if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
12
13 if ( ! class_exists( 'PH_Admin_Reports' ) ) :
14
15 /**
16 * PH_Admin_Reports
17 */
18 class PH_Admin_Reports {
19
20 /**
21 * Handles the display of the main Property Hive reports page in admin.
22 *
23 * @access public
24 * @return void
25 */
26 public static function output() {
27
28 $reports = self::get_reports();
29 $first_tab = array_keys( $reports );
30 $current_tab = ! empty( $_GET['tab'] ) ? sanitize_title( $_GET['tab'] ) : $first_tab[0];
31 $current_report = isset( $_GET['report'] ) ? sanitize_title( $_GET['report'] ) : current( array_keys( $reports[ $current_tab ]['reports'] ) );
32
33 include_once( 'reports/class-ph-admin-report.php' );
34 include_once( 'views/html-admin-page-reports.php' );
35 }
36
37 /**
38 * Returns the definitions for the reports to show in admin.
39 *
40 * @return array
41 */
42 public static function get_reports()
43 {
44 $reports = array(
45 'properties' => array(
46 'title' => __( 'Properties', 'propertyhive' ),
47 'reports' => array()
48 )
49 );
50
51 if ( get_option('propertyhive_active_departments_sales', '') == 'yes' )
52 {
53 $reports['properties']['reports']['sales_property_stock_analysis'] = array(
54 'title' => __( 'Sales Property Stock Analysis', 'propertyhive' ),
55 'description' => '',
56 'hide_title' => true,
57 'callback' => array( __CLASS__, 'get_report' )
58 );
59 $reports['properties']['reports']['sales_property_popularity'] = array(
60 'title' => __( 'Sales Property Popularity', 'propertyhive' ),
61 'description' => '',
62 'hide_title' => true,
63 'callback' => array( __CLASS__, 'get_report' )
64 );
65 }
66
67 if ( get_option('propertyhive_active_departments_lettings', '') == 'yes' )
68 {
69 $reports['properties']['reports']['lettings_property_stock_analysis'] = array(
70 'title' => __( 'Lettings Property Stock Analysis', 'propertyhive' ),
71 'description' => '',
72 'hide_title' => true,
73 'callback' => array( __CLASS__, 'get_report' )
74 );
75 $reports['properties']['reports']['lettings_property_popularity'] = array(
76 'title' => __( 'Lettings Property Popularity', 'propertyhive' ),
77 'description' => '',
78 'hide_title' => true,
79 'callback' => array( __CLASS__, 'get_report' )
80 );
81 }
82
83 $reports['properties']['reports']['incomplete_properties'] = array(
84 'title' => __( 'Incomplete Properties', 'propertyhive' ),
85 'description' => '',
86 'hide_title' => true,
87 'callback' => array( __CLASS__, 'get_report' )
88 );
89
90 /*if ( get_option('propertyhive_module_disabled_contacts', '') != 'yes' )
91 {
92 $reports['applicants'] = array(
93 'title' => __( 'Applicants', 'propertyhive' ),
94 'reports' => array(
95 "applicant_demand_analysis" => array(
96 'title' => __( 'Applicant Demand Analysis', 'propertyhive' ),
97 'description' => '',
98 'hide_title' => true,
99 'callback' => array( __CLASS__, 'get_report' )
100 ),
101 )
102 );
103 }*/
104
105 $reports = apply_filters( 'propertyhive_admin_reports', $reports );
106
107 foreach ( $reports as $key => $report_group ) {
108 if ( isset( $reports[ $key ]['charts'] ) ) {
109 $reports[ $key ]['reports'] = $reports[ $key ]['charts'];
110 }
111
112 foreach ( $reports[ $key ]['reports'] as $report_key => $report ) {
113 if ( isset( $reports[ $key ]['reports'][ $report_key ]['function'] ) ) {
114 $reports[ $key ]['reports'][ $report_key ]['callback'] = $reports[ $key ]['reports'][ $report_key ]['function'];
115 }
116 }
117 }
118
119 return $reports;
120 }
121
122 /**
123 * Get a report from our reports subfolder.
124 */
125 public static function get_report( $name ) {
126 $name = sanitize_title( str_replace( '_', '-', $name ) );
127 $class = 'PH_Report_' . str_replace( '-', '_', $name );
128
129 include_once( apply_filters( 'ph_admin_reports_path', 'reports/class-ph-report-' . $name . '.php', $name, $class ) );
130
131 if ( ! class_exists( $class ) )
132 return;
133
134 $report = new $class();
135 $report->output_report();
136 }
137 }
138
139 endif;