浏览代码

Domain Counts (#36)

* Create app_config.php

* Create app_languages.php

* Create app_menu.php

* Create domain_counts.php

* Create root.php
konradSC 8 年之前
父节点
当前提交
31cf7b3ba2
共有 5 个文件被更改,包括 432 次插入0 次删除
  1. 22 0
      domain_counts/app_config.php
  2. 31 0
      domain_counts/app_languages.php
  3. 21 0
      domain_counts/app_menu.php
  4. 268 0
      domain_counts/domain_counts.php
  5. 90 0
      domain_counts/root.php

+ 22 - 0
domain_counts/app_config.php

@@ -0,0 +1,22 @@
+<?php
+	
+	//application details
+		$apps[$x]['name'] = "Domain Counts";
+		$apps[$x]['uuid'] = "21df0a64-8665-4c7c-839f-2bc4663f9651";
+		$apps[$x]['category'] = "System";
+		$apps[$x]['subcategory'] = "";
+		$apps[$x]['version'] = "";
+		$apps[$x]['license'] = "Mozilla Public License 1.1";
+		$apps[$x]['url'] = "http://www.fusionpbx.com";
+		$apps[$x]['description']['en-us'] = "Wizard";
+		
+		
+	//permission details
+		$y = 0;
+		$apps[$x]['permissions'][$y]['name'] = "domain_counts_view";
+		$apps[$x]['permissions'][$y]['menu']['uuid'] = "8db32ec2-85dc-4782-a7b1-d0caf8a4e44e";
+		$apps[$x]['permissions'][$y]['groups'][] = "superadmin";
+		$y++;		
+		
+
+?>

+ 31 - 0
domain_counts/app_languages.php

@@ -0,0 +1,31 @@
+<?php
+$text['title-domain_counts']['en-us'] = "Domain Counts";
+
+$text['header-domain_counts']['en-us'] = "Domain Counts";
+
+$text['description-domain_counts']['en-us'] = "Displays the number of items from all domains";
+
+$text['label-domain_name']['en-us'] = "Domain Name";
+
+$text['label-extensions']['en-us'] = "Extensions";
+
+$text['label-users']['en-us'] = "Users";
+
+$text['label-devices']['en-us'] = "Devices";
+
+$text['label-destinations']['en-us'] = "Destinations";
+
+$text['label-faxes']['en-us'] = "Faxes";
+
+$text['label-ivrs']['en-us'] = "IVR's";
+
+$text['label-voicemails']['en-us'] = "Voicemails";
+
+$text['label-ring_groups']['en-us'] = "Ring Groups";
+
+$text['label-cc_queues']['en-us'] = "CC Queues";
+
+$text['label-contacts']['en-us'] = "Contacts";
+
+$text['button-export']['en-us'] = "Export";
+?>

+ 21 - 0
domain_counts/app_menu.php

@@ -0,0 +1,21 @@
+<?php
+
+$apps[$x]['menu'][0]['title']['en-us'] = "Domain Counts";
+$apps[$x]['menu'][0]['title']['es-cl'] = "";
+$apps[$x]['menu'][0]['title']['fr-fr'] = "";
+$apps[$x]['menu'][0]['title']['pt-pt'] = "";
+$apps[$x]['menu'][0]['title']['pt-br'] = "";
+$apps[$x]['menu'][0]['title']['pl'] = "";
+$apps[$x]['menu'][0]['title']['sv-se'] = "";
+$apps[$x]['menu'][0]['title']['uk'] = "";
+$apps[$x]['menu'][0]['title']['ro'] = "";
+$apps[$x]['menu'][0]['title']['de-at'] = "";
+$apps[$x]['menu'][0]['title']['ar-eg'] = "";
+$apps[$x]['menu'][0]['title']['he'] = "";
+$apps[$x]['menu'][0]['uuid'] = "8db32ec2-85dc-4782-a7b1-d0caf8a4e44e";
+$apps[$x]['menu'][0]['parent_uuid'] = "0438b504-8613-7887-c420-c837ffb20cb1";
+$apps[$x]['menu'][0]['category'] = "internal";
+$apps[$x]['menu'][0]['path'] = "/app/domain_counts/domain_counts.php";
+$apps[$x]['menu'][0]['groups'][] = "superadmin";
+
+?>

+ 268 - 0
domain_counts/domain_counts.php

@@ -0,0 +1,268 @@
+<?php
+/*
+	FusionPBX
+	Version: MPL 1.1
+
+	The contents of this file are subject to the Mozilla Public License Version
+	1.1 (the "License"); you may not use this file except in compliance with
+	the License. You may obtain a copy of the License at
+	http://www.mozilla.org/MPL/
+
+	Software distributed under the License is distributed on an "AS IS" basis,
+	WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+	for the specific language governing rights and limitations under the
+	License.
+
+	The Original Code is FusionPBX
+
+	The Initial Developer of the Original Code is
+	Mark J Crane <[email protected]>
+	Portions created by the Initial Developer are Copyright (C) 2008-2016
+	the Initial Developer. All Rights Reserved.
+
+	Contributor(s):
+	KonradSC <[email protected]>
+*/
+
+//includes
+	include "root.php";
+	require_once "resources/require.php";
+	require_once "resources/check_auth.php";
+
+//include the class
+	require_once "resources/check_auth.php";
+
+//check permissions
+	require_once "resources/check_auth.php";
+	if (permission_exists('domain_counts_view')) {
+		//access granted
+	}
+	else {
+		echo "access denied";
+		exit;
+	}
+	
+//add multi-lingual support
+	$language = new text;
+	$text = $language->get();
+
+//get the http values and set them as variables
+	$order_by = check_str($_GET["order_by"]);
+	$order = check_str($_GET["order"]);
+
+//handle search term
+	$search = check_str($_GET["search"]);
+	if (strlen($search) > 0) {
+		$sql_mod = "WHERE d.domain_name like '%".$search."%' "; 
+	}
+	if (strlen($order_by) < 1) {
+		$order_by = "domain_name";
+		$order = "ASC";
+	}
+
+//get all the counts from the database
+	$sql = "SELECT \n";
+	$sql .= "d.domain_uuid, \n";
+	$sql .= "d.domain_name, \n";
+
+	//extension
+	$sql .= "(\n";
+	$sql .= "select count(*) from v_extensions \n";
+	$sql .= "where domain_uuid = d.domain_uuid\n";
+	$sql .= ") as extension_count, \n";
+	
+	//users
+	$sql .= "(\n";
+	$sql .= "select count(*) from v_users \n";
+	$sql .= "where domain_uuid = d.domain_uuid\n";
+	$sql .= ") as user_count, \n";	
+
+	//devices
+	$sql .= "(\n";
+	$sql .= "select count(*) from v_devices \n";
+	$sql .= "where domain_uuid = d.domain_uuid\n";
+	$sql .= ") as device_count, \n";
+
+	//destinations
+	$sql .= "(\n";
+	$sql .= "select count(*) from v_destinations \n";
+	$sql .= "where domain_uuid = d.domain_uuid\n";
+	$sql .= ") as destination_count, \n";
+	
+	//faxes
+	$sql .= "(\n";
+	$sql .= "select count(*) from v_fax \n";
+	$sql .= "where domain_uuid = d.domain_uuid\n";
+	$sql .= ") as fax_count, \n";
+
+	//ivr
+	$sql .= "(\n";
+	$sql .= "select count(*) from v_ivr_menus \n";
+	$sql .= "where domain_uuid = d.domain_uuid\n";
+	$sql .= ") as ivr_count, \n";
+
+	//voicemail
+	$sql .= "(\n";
+	$sql .= "select count(*) from v_voicemails \n";
+	$sql .= "where domain_uuid = d.domain_uuid\n";
+	$sql .= ") as voicemail_count, \n";
+
+	//ring_group
+	$sql .= "(\n";
+	$sql .= "select count(*) from v_ring_groups \n";
+	$sql .= "where domain_uuid = d.domain_uuid\n";
+	$sql .= ") as ring_group_count, \n";
+
+	//call_center_queues
+	$sql .= "(\n";
+	$sql .= "select count(*) from v_call_center_queues \n";
+	$sql .= "where domain_uuid = d.domain_uuid\n";
+	$sql .= ") as cc_queue_count, \n";
+
+	//contacts
+	$sql .= "(\n";
+	$sql .= "select count(*) from v_contacts \n";
+	$sql .= "where domain_uuid = d.domain_uuid\n";
+	$sql .= ") as contact_count \n";
+	
+	$sql .= "FROM v_domains as d \n";
+	$sql .= $sql_mod; //add search mod from above
+	$sql .= "ORDER BY ".$order_by." ".$order." \n";
+	
+	$database = new database;
+	$database->select($sql);
+	$domain_counts = $database->result;	
+
+//lookup the domain count
+	$database = new database;
+	$database->table = "v_domains";
+	$where[1]["name"] = "domain_uuid";
+	$where[1]["operator"] = "=";
+	$where[1]["value"] = "*";	
+	$numeric_domain_counts = $database->count();
+	unset($database,$result);	
+
+//set the http header
+	if ($_REQUEST['type'] == "csv") {
+	
+		//set the headers
+			header('Content-type: application/octet-binary');
+			header("Content-Disposition: attachment; filename=domain-counts_" . date("Y-m-d") . ".csv");
+
+		//show the column names on the first line
+			$z = 0;
+			foreach($domain_counts[1] as $key => $val) {
+				if ($z == 0) {
+					echo '"'.$key.'"';
+				}
+				else {
+					echo ',"'.$key.'"';
+				}
+				$z++;
+			}
+			echo "\n";
+		
+		//add the values to the csv
+			$x = 0;
+			foreach($domain_counts as $domains) {
+				$z = 0;
+				foreach($domains as $key => $val) {
+					if ($z == 0) {
+						echo '"'.$domain_counts[$x][$key].'"';
+					}
+					else {
+						echo ',"'.$domain_counts[$x][$key].'"';
+					}
+					$z++;
+				}
+				echo "\n";
+				$x++;
+			}
+			exit;
+	}
+	
+//additional includes
+	require_once "resources/header.php";
+	$document['title'] = $text['title-domain_counts'];
+
+//set the alternating styles
+	$c = 0;
+	$row_style["0"] = "row_style0";
+	$row_style["1"] = "row_style1";
+	
+//show the content
+	echo "<table width=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">\n";
+	echo "  <tr>\n";
+	echo "	<td align='left' width='100%'>\n";
+	echo "		<b>".$text['header-domain_counts']." (".$numeric_domain_counts.")</b><br>\n";
+	echo "	</td>\n";
+	echo "		<td align='right' width='100%' style='vertical-align: top;'>";
+	echo "		<form method='get' action=''>\n";
+	echo "			<td style='vertical-align: top; text-align: right; white-space: nowrap;'>\n";
+	echo "				<input type='text' class='txt' style='width: 150px' name='search' id='search' value='".$search."'>";
+	echo "				<input type='submit' class='btn' name='submit' value='".$text['button-search']."'>";
+	echo "				<input type='button' class='btn' value='".$text['button-export']."' ";
+	echo "onclick=\"window.location='domain_counts.php?";
+	if (strlen($_SERVER["QUERY_STRING"]) > 0) { 
+		echo $_SERVER["QUERY_STRING"]."&type=csv';\">\n";
+	} else { 
+		echo "type=csv';\">\n";
+	}
+
+
+#	if ($paging_controls_mini != '') {
+#		echo 			"<span style='margin-left: 15px;'>".$paging_controls_mini."</span>\n";
+#	}
+	echo "			</td>\n";
+	echo "		</form>\n";	
+	echo "  </tr>\n";
+	
+	
+	echo "	<tr>\n";
+	echo "		<td colspan='2'>\n";
+	echo "			".$text['description-domain_counts']."\n";
+	echo "		</td>\n";
+	echo "	</tr>\n";
+	echo "</table>\n";
+	echo "<br />";
+
+	echo "<form name='frm' method='post' action='domain_counts_delete.php'>\n";
+	echo "<table class='tr_hover' width='100%' border='0' cellpadding='0' cellspacing='0'>\n";
+	echo "<tr>\n";
+	echo th_order_by('domain_name', $text['label-domain_name'], $order_by, $order);
+	echo th_order_by('extension_count', $text['label-extensions'], $order_by,$order);
+	echo th_order_by('user_count', $text['label-users'], $order_by, $order);
+	echo th_order_by('device_count', $text['label-devices'], $order_by, $order);
+	echo th_order_by('destination_count', $text['label-destinations'], $order_by, $order);
+	echo th_order_by('fax_count', $text['label-faxes'], $order_by, $order);
+	echo th_order_by('ivr_count', $text['label-ivrs'], $order_by, $order);
+	echo th_order_by('voicemail_count', $text['label-voicemails'], $order_by, $order);
+	echo th_order_by('ring_group_count', $text['label-ring_groups'], $order_by, $order);
+	echo th_order_by('cc_queue_count', $text['label-cc_queues'], $order_by, $order);	
+	echo th_order_by('contact_count', $text['label-contacts'], $order_by, $order);
+	echo "</tr>\n";
+
+	if (isset($domain_counts)) foreach ($domain_counts as $key => $row) {
+		echo "	<td valign='top' class='".$row_style[$c]."'>".$row['domain_name']."</td>\n";
+		echo "	<td valign='top' class='".$row_style[$c]."'>".$row['extension_count']."&nbsp;</td>\n";
+		echo "	<td valign='top' class='".$row_style[$c]."'>".$row['user_count']."&nbsp;</td>\n";
+		echo "	<td valign='top' class='".$row_style[$c]."'>".$row['device_count']."&nbsp;</td>\n";
+		echo "	<td valign='top' class='".$row_style[$c]."'>".$row['destination_count']."&nbsp;</td>\n";
+		echo "	<td valign='top' class='".$row_style[$c]."'>".$row['fax_count']."&nbsp;</td>\n";
+		echo "	<td valign='top' class='".$row_style[$c]."'>".$row['ivr_count']."&nbsp;</td>\n";
+		echo "	<td valign='top' class='".$row_style[$c]."'>".$row['voicemail_count']."&nbsp;</td>\n";
+		echo "	<td valign='top' class='".$row_style[$c]."'>".$row['ring_group_count']."&nbsp;</td>\n";
+		echo "	<td valign='top' class='".$row_style[$c]."'>".$row['cc_queue_count']."&nbsp;</td>\n";
+		echo "	<td valign='top' class='".$row_style[$c]."'>".$row['contact_count']."&nbsp;</td>\n";
+		
+		
+		echo "</tr>\n";
+		$c = ($c==0) ? 1 : 0;
+	}
+
+	echo "</table>";
+	echo "</form>";
+
+//show the footer
+	require_once "resources/footer.php";
+?>

+ 90 - 0
domain_counts/root.php

@@ -0,0 +1,90 @@
+<?php
+/*
+	FusionPBX
+	Version: MPL 1.1
+
+	The contents of this file are subject to the Mozilla Public License Version
+	1.1 (the "License"); you may not use this file except in compliance with
+	the License. You may obtain a copy of the License at
+	http://www.mozilla.org/MPL/
+
+	Software distributed under the License is distributed on an "AS IS" basis,
+	WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+	for the specific language governing rights and limitations under the
+	License.
+
+	The Original Code is FusionPBX
+
+	The Initial Developer of the Original Code is
+	Mark J Crane <[email protected]>
+	Portions created by the Initial Developer are Copyright (C) 2008-2012
+	the Initial Developer. All Rights Reserved.
+
+	Contributor(s):
+	Mark J Crane <[email protected]>
+*/
+
+// make sure the PATH_SEPARATOR is defined
+	umask(2);
+	if (!defined("PATH_SEPARATOR")) {
+		if (strpos($_ENV["OS"], "Win") !== false) {
+			define("PATH_SEPARATOR", ";");
+		} else {
+			define("PATH_SEPARATOR", ":");
+		}
+	}
+
+	if (!isset($output_format)) $output_format = (PHP_SAPI == 'cli') ? 'text' : 'html';
+
+	// make sure the document_root is set
+	$_SERVER["SCRIPT_FILENAME"] = str_replace("\\", '/', $_SERVER["SCRIPT_FILENAME"]);
+	if(PHP_SAPI == 'cli'){
+		chdir(pathinfo(realpath($_SERVER["PHP_SELF"]), PATHINFO_DIRNAME));
+		$script_full_path = str_replace("\\", '/', getcwd() . '/' . $_SERVER["SCRIPT_FILENAME"]);
+		$dirs = explode('/', pathinfo($script_full_path, PATHINFO_DIRNAME));
+		if (file_exists('/project_root.php')) {
+			$path = '/';
+		} else {
+			$i    = 1;
+			$path = '';
+			while ($i < count($dirs)) {
+				$path .= '/' . $dirs[$i];
+				if (file_exists($path. '/project_root.php')) {
+					break;
+				}
+				$i++;
+			}
+		}
+		$_SERVER["DOCUMENT_ROOT"] = $path;
+	}else{
+		$_SERVER["DOCUMENT_ROOT"]   = str_replace($_SERVER["PHP_SELF"], "", $_SERVER["SCRIPT_FILENAME"]);
+	}
+	$_SERVER["DOCUMENT_ROOT"]   = realpath($_SERVER["DOCUMENT_ROOT"]);
+// try to detect if a project path is being used
+	if (!defined('PROJECT_PATH')) {
+		if (is_dir($_SERVER["DOCUMENT_ROOT"]. '/fusionpbx')) {
+			define('PROJECT_PATH', '/fusionpbx');
+		} elseif (file_exists($_SERVER["DOCUMENT_ROOT"]. '/project_root.php')) {
+			define('PROJECT_PATH', '');
+		} else {
+			$dirs = explode('/', str_replace('\\', '/', pathinfo($_SERVER["PHP_SELF"], PATHINFO_DIRNAME)));
+			$i    = 1;
+			$path = $_SERVER["DOCUMENT_ROOT"];
+			while ($i < count($dirs)) {
+				$path .= '/' . $dirs[$i];
+				if (file_exists($path. '/project_root.php')) {
+					break;
+				}
+				$i++;
+			}
+			if(!file_exists($path. '/project_root.php')){
+				die("Failed to locate the Project Root by searching for project_root.php please contact support for assistance");
+			}
+			$project_path = str_replace($_SERVER["DOCUMENT_ROOT"], "", $path);
+			define('PROJECT_PATH', $project_path);
+		}
+		$_SERVER["PROJECT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"] . PROJECT_PATH);
+		set_include_path(get_include_path() . PATH_SEPARATOR . $_SERVER["PROJECT_ROOT"]);
+	}
+
+?>