user_dashboard.php 60 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264
  1. <?php
  2. /*
  3. FusionPBX
  4. Version: MPL 1.1
  5. The contents of this file are subject to the Mozilla Public License Version
  6. 1.1 (the "License"); you may not use this file except in compliance with
  7. the License. You may obtain a copy of the License at
  8. http://www.mozilla.org/MPL/
  9. Software distributed under the License is distributed on an "AS IS" basis,
  10. WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  11. for the specific language governing rights and limitations under the
  12. License.
  13. The Original Code is FusionPBX
  14. The Initial Developer of the Original Code is
  15. Mark J Crane <[email protected]>
  16. Portions created by the Initial Developer are Copyright (C) 2008-2019
  17. the Initial Developer. All Rights Reserved.
  18. Contributor(s):
  19. Mark J Crane <[email protected]>
  20. */
  21. //include the root directory
  22. include "root.php";
  23. //if config.php file does not exist then redirect to the install page
  24. if (file_exists($_SERVER["PROJECT_ROOT"]."/resources/config.php")) {
  25. //do nothing
  26. } elseif (file_exists($_SERVER["PROJECT_ROOT"]."/resources/config.php")) {
  27. //original directory
  28. } elseif (file_exists("/etc/fusionpbx/config.php")){
  29. //linux
  30. } elseif (file_exists("/usr/local/etc/fusionpbx/config.php")){
  31. //bsd
  32. } else {
  33. header("Location: ".PROJECT_PATH."/core/install/install.php");
  34. exit;
  35. }
  36. //additional includes
  37. require_once "resources/check_auth.php";
  38. //disable login message
  39. if (isset($_GET['msg']) && $_GET['msg'] == 'dismiss') {
  40. unset($_SESSION['login']['message']['text']);
  41. $sql = "update v_default_settings ";
  42. $sql .= "set default_setting_enabled = 'false' ";
  43. $sql .= "where ";
  44. $sql .= "default_setting_category = 'login' ";
  45. $sql .= "and default_setting_subcategory = 'message' ";
  46. $sql .= "and default_setting_name = 'text' ";
  47. $database = new database;
  48. $database->execute($sql);
  49. unset($sql);
  50. }
  51. //add multi-lingual support
  52. $language = new text;
  53. $text = $language->get();
  54. //load the header
  55. $document['title'] = $text['title-user_dashboard'];
  56. require_once "resources/header.php";
  57. //start the content
  58. echo "<table cellpadding='0' cellspacing='0' border='0' width='100%'>\n";
  59. echo " <tr>\n";
  60. echo " <td valign='top'>";
  61. echo " <b>".$text['header-user_dashboard']."</b><br />";
  62. echo " </td>\n";
  63. echo " <td valign='top' style='text-align: right; white-space: nowrap;'>\n";
  64. if ($_SESSION['theme']['menu_style']['text'] != 'side') {
  65. echo " ".$text['label-welcome']." <a href='".PROJECT_PATH."/core/users/user_edit.php?id=user'>".$_SESSION["username"]."</a>";
  66. }
  67. echo " </td>\n";
  68. echo " </tr>\n";
  69. echo " <tr>\n";
  70. echo " <td colspan='2' valign='top'>";
  71. echo " ".$text['description-user_dashboard'];
  72. echo " </td>\n";
  73. echo " </tr>\n";
  74. echo "</table>\n";
  75. echo "<br />";
  76. //display login message
  77. if (if_group("superadmin") && isset($_SESSION['login']['message']['text']) && $_SESSION['login']['message']['text'] != '') {
  78. echo "<div class='login_message' width='100%'><b>".$text['login-message_attention']."</b>&nbsp;&nbsp;".$_SESSION['login']['message']['text']."&nbsp;&nbsp;(<a href='?msg=dismiss'>".$text['login-message_dismiss']."</a>)</div>";
  79. }
  80. //determine hud blocks
  81. if (is_array($_SESSION['dashboard']) && sizeof($_SESSION['dashboard']) > 0) {
  82. foreach ($_SESSION['groups'] as $index => $group) {
  83. $group_name = $group['group_name'];
  84. if (is_array($_SESSION['dashboard'][$group_name]) && sizeof($_SESSION['dashboard'][$group_name]) > 0) {
  85. foreach ($_SESSION['dashboard'][$group_name] as $hud_block) {
  86. $hud_blocks[] = strtolower($hud_block);
  87. }
  88. }
  89. }
  90. }
  91. if (is_array($hud_blocks) && sizeof($hud_blocks) > 0) {
  92. $selected_blocks = array_unique($hud_blocks);
  93. sort($selected_blocks, SORT_NATURAL);
  94. }
  95. unset($group, $group_name, $index, $hud_block, $hud_blocks);
  96. //collect stats for counts and limits
  97. if ((is_array($selected_blocks) && in_array('counts', $selected_blocks)) || (is_array($selected_blocks) && in_array('limits', $selected_blocks))) {
  98. //domains
  99. if (permission_exists('domain_view')) {
  100. $stats['system']['domains']['total'] = sizeof($_SESSION['domains']);
  101. $stats['system']['domains']['disabled'] = 0;
  102. foreach ($_SESSION['domains'] as $domain) {
  103. $stats['system']['domains']['disabled'] += ($domain['domain_enabled'] != 'true') ? 1 : 0;
  104. }
  105. }
  106. //devices
  107. if (permission_exists('device_view')) {
  108. $stats['system']['devices']['total'] = 0;
  109. $stats['system']['devices']['disabled'] = 0;
  110. $stats['domain']['devices']['total'] = 0;
  111. $stats['domain']['devices']['disabled'] = 0;
  112. $sql = "select domain_uuid, device_enabled from v_devices";
  113. $database = new database;
  114. $result = $database->select($sql, null, 'all');
  115. if (is_array($result) && sizeof($result) != 0) {
  116. $stats['system']['devices']['total'] = sizeof($result);
  117. foreach ($result as $row) {
  118. $stats['system']['devices']['disabled'] += ($row['device_enabled'] != 'true') ? 1 : 0;
  119. if ($row['domain_uuid'] == $_SESSION['domain_uuid']) {
  120. $stats['domain']['devices']['total']++;
  121. $stats['domain']['devices']['disabled'] += ($row['device_enabled'] != 'true') ? 1 : 0;
  122. }
  123. }
  124. }
  125. unset($sql, $result);
  126. }
  127. //extensions
  128. if (permission_exists('extension_view')) {
  129. $stats['system']['extensions']['total'] = 0;
  130. $stats['system']['extensions']['disabled'] = 0;
  131. $stats['domain']['extensions']['total'] = 0;
  132. $stats['domain']['extensions']['disabled'] = 0;
  133. $sql = "select domain_uuid, enabled from v_extensions";
  134. $database = new database;
  135. $result = $database->select($sql, null, 'all');
  136. if (is_array($result) && sizeof($result) != 0) {
  137. $stats['system']['extensions']['total'] = sizeof($result);
  138. foreach ($result as $row) {
  139. $stats['system']['extensions']['disabled'] += ($row['enabled'] != 'true') ? 1 : 0;
  140. if ($row['domain_uuid'] == $_SESSION['domain_uuid']) {
  141. $stats['domain']['extensions']['total']++;
  142. $stats['domain']['extensions']['disabled'] += ($row['enabled'] != 'true') ? 1 : 0;
  143. }
  144. }
  145. }
  146. unset($sql, $result);
  147. }
  148. //gateways
  149. if (permission_exists('gateway_view')) {
  150. $stats['system']['gateways']['total'] = 0;
  151. $stats['system']['gateways']['disabled'] = 0;
  152. $stats['domain']['gateways']['total'] = 0;
  153. $stats['domain']['gateways']['disabled'] = 0;
  154. $sql = "select domain_uuid, enabled from v_gateways";
  155. $database = new database;
  156. $result = $database->select($sql, null, 'all');
  157. if (is_array($result) && sizeof($result) != 0) {
  158. $stats['system']['gateways']['total'] = sizeof($result);
  159. foreach ($result as $row) {
  160. $stats['system']['gateways']['disabled'] += ($row['enabled'] != 'true') ? 1 : 0;
  161. if ($row['domain_uuid'] == $_SESSION['domain_uuid']) {
  162. $stats['domain']['gateways']['total']++;
  163. $stats['domain']['gateways']['disabled'] += ($row['enabled'] != 'true') ? 1 : 0;
  164. }
  165. }
  166. }
  167. unset($sql, $result);
  168. }
  169. //users
  170. if (permission_exists('user_view') || if_group("superadmin")) {
  171. $stats['system']['users']['total'] = 0;
  172. $stats['system']['users']['disabled'] = 0;
  173. $stats['domain']['users']['total'] = 0;
  174. $stats['domain']['users']['disabled'] = 0;
  175. $sql = "select domain_uuid, user_enabled from v_users";
  176. $database = new database;
  177. $result = $database->select($sql, null, 'all');
  178. if (is_array($result) && sizeof($result) != 0) {
  179. $stats['system']['users']['total'] = sizeof($result);
  180. foreach ($result as $row) {
  181. $stats['system']['users']['disabled'] += ($row['user_enabled'] != 'true') ? 1 : 0;
  182. if ($row['domain_uuid'] == $_SESSION['domain_uuid']) {
  183. $stats['domain']['users']['total']++;
  184. $stats['domain']['users']['disabled'] += ($row['user_enabled'] != 'true') ? 1 : 0;
  185. }
  186. }
  187. }
  188. unset($sql, $result);
  189. }
  190. //destinations
  191. if (permission_exists('destination_view')) {
  192. $stats['system']['destinations']['total'] = 0;
  193. $stats['system']['destinations']['disabled'] = 0;
  194. $stats['domain']['destinations']['total'] = 0;
  195. $stats['domain']['destinations']['disabled'] = 0;
  196. $sql = "select domain_uuid, destination_enabled from v_destinations";
  197. $database = new database;
  198. $result = $database->select($sql, null, 'all');
  199. if (is_array($result) && sizeof($result) != 0) {
  200. $stats['system']['destinations']['total'] = sizeof($result);
  201. foreach ($result as $row) {
  202. $stats['system']['destinations']['disabled'] += ($row['destination_enabled'] != 'true') ? 1 : 0;
  203. if ($row['domain_uuid'] == $_SESSION['domain_uuid']) {
  204. $stats['domain']['destinations']['total']++;
  205. $stats['domain']['destinations']['disabled'] += ($row['destination_enabled'] != 'true') ? 1 : 0;
  206. }
  207. }
  208. }
  209. unset($sql, $result);
  210. }
  211. //call center queues
  212. if (permission_exists('call_center_active_view')) {
  213. $stats['system']['call_center_queues']['total'] = 0;
  214. $stats['system']['call_center_queues']['disabled'] = 0;
  215. $stats['domain']['call_center_queues']['total'] = 0;
  216. $stats['domain']['call_center_queues']['disabled'] = 0;
  217. $sql = "select domain_uuid from v_call_center_queues";
  218. $database = new database;
  219. $result = $database->select($sql, null, 'all');
  220. if (is_array($result) && sizeof($result) != 0) {
  221. $stats['system']['call_center_queues']['total'] = sizeof($result);
  222. foreach ($result as $row) {
  223. //$stats['system']['call_center_queues']['disabled'] += ($row['queue_enabled'] != 'true') ? 1 : 0;
  224. if ($row['domain_uuid'] == $_SESSION['domain_uuid']) {
  225. $stats['domain']['call_center_queues']['total']++;
  226. //$stats['domain']['call_center_queues']['disabled'] += ($row['queue_enabled'] != 'true') ? 1 : 0;
  227. }
  228. }
  229. }
  230. unset($sql, $result);
  231. }
  232. //ivr menus
  233. if (permission_exists('ivr_menu_view')) {
  234. $stats['system']['ivr_menus']['total'] = 0;
  235. $stats['system']['ivr_menus']['disabled'] = 0;
  236. $stats['domain']['ivr_menus']['total'] = 0;
  237. $stats['domain']['ivr_menus']['disabled'] = 0;
  238. $sql = "select domain_uuid, ivr_menu_enabled from v_ivr_menus";
  239. $database = new database;
  240. $result = $database->select($sql, null, 'all');
  241. if (is_array($result) && sizeof($result) != 0) {
  242. $stats['system']['ivr_menus']['total'] = sizeof($result);
  243. foreach ($result as $row) {
  244. $stats['system']['ivr_menus']['disabled'] += ($row['ivr_menu_enabled'] != 'true') ? 1 : 0;
  245. if ($row['domain_uuid'] == $_SESSION['domain_uuid']) {
  246. $stats['domain']['ivr_menus']['total']++;
  247. $stats['domain']['ivr_menus']['disabled'] += ($row['ivr_menu_enabled'] != 'true') ? 1 : 0;
  248. }
  249. }
  250. }
  251. unset($sql, $result);
  252. }
  253. //ring groups
  254. if (permission_exists('ring_group_view')) {
  255. $stats['system']['ring_groups']['total'] = 0;
  256. $stats['system']['ring_groups']['disabled'] = 0;
  257. $stats['domain']['ring_groups']['total'] = 0;
  258. $stats['domain']['ring_groups']['disabled'] = 0;
  259. $sql = "select domain_uuid, ring_group_enabled from v_ring_groups";
  260. $database = new database;
  261. $result = $database->select($sql, null, 'all');
  262. if (is_array($result) && sizeof($result) != 0) {
  263. $stats['system']['ring_groups']['total'] = sizeof($result);
  264. foreach ($result as $row) {
  265. $stats['system']['ring_groups']['disabled'] += ($row['ring_group_enabled'] != 'true') ? 1 : 0;
  266. if ($row['domain_uuid'] == $_SESSION['domain_uuid']) {
  267. $stats['domain']['ring_groups']['total']++;
  268. $stats['domain']['ring_groups']['disabled'] += ($row['ring_group_enabled'] != 'true') ? 1 : 0;
  269. }
  270. }
  271. }
  272. unset($sql, $result);
  273. }
  274. //voicemails
  275. if (permission_exists('voicemail_view')) {
  276. $stats['system']['voicemails']['total'] = 0;
  277. $stats['system']['voicemails']['disabled'] = 0;
  278. $stats['domain']['voicemails']['total'] = 0;
  279. $stats['domain']['voicemails']['disabled'] = 0;
  280. $sql = "select domain_uuid, voicemail_enabled from v_voicemails";
  281. $database = new database;
  282. $result = $database->select($sql, null, 'all');
  283. if (is_array($result) && sizeof($result) != 0) {
  284. $stats['system']['voicemails']['total'] = sizeof($result);
  285. foreach ($result as $row) {
  286. $stats['system']['voicemails']['disabled'] += ($row['voicemail_enabled'] != 'true') ? 1 : 0;
  287. if ($row['domain_uuid'] == $_SESSION['domain_uuid']) {
  288. $stats['domain']['voicemails']['total']++;
  289. $stats['domain']['voicemails']['disabled'] += ($row['voicemail_enabled'] != 'true') ? 1 : 0;
  290. }
  291. }
  292. }
  293. unset($sql, $result);
  294. }
  295. //voicemail messages
  296. if (permission_exists('voicemail_message_view')) {
  297. $stats['system']['messages']['total'] = 0;
  298. $stats['system']['messages']['new'] = 0;
  299. $stats['domain']['messages']['total'] = 0;
  300. $stats['domain']['messages']['new'] = 0;
  301. $sql = "select domain_uuid, message_status from v_voicemail_messages";
  302. $database = new database;
  303. $result = $database->select($sql, null, 'all');
  304. if (is_array($result) && sizeof($result) != 0) {
  305. $stats['system']['messages']['total'] = sizeof($result);
  306. foreach ($result as $row) {
  307. $stats['system']['messages']['new'] += ($row['message_status'] != 'saved') ? 1 : 0;
  308. if ($row['domain_uuid'] == $_SESSION['domain_uuid']) {
  309. $stats['domain']['messages']['total']++;
  310. $stats['domain']['messages']['new'] += ($row['message_status'] != 'saved') ? 1 : 0;
  311. }
  312. }
  313. }
  314. unset($sql, $result);
  315. }
  316. }
  317. //build hud block html
  318. $n = 0;
  319. $theme_image_path = $_SERVER["DOCUMENT_ROOT"]."/themes/".$_SESSION['domain']['template']['name']."/images/"; // used for missed and recent calls
  320. //voicemail
  321. if (is_array($selected_blocks) && in_array('voicemail', $selected_blocks) && permission_exists('voicemail_message_view') && file_exists($_SERVER["DOCUMENT_ROOT"].PROJECT_PATH."/app/voicemails/")) {
  322. //required class
  323. require_once "app/voicemails/resources/classes/voicemail.php";
  324. //get the voicemail
  325. $vm = new voicemail;
  326. $vm->db = $db;
  327. $vm->domain_uuid = $_SESSION['domain_uuid'];
  328. $vm->order_by = $order_by;
  329. $vm->order = $order;
  330. $voicemails = $vm->messages();
  331. //sum total and new
  332. $messages['total'] = 0;
  333. $messages['new'] = 0;
  334. if (sizeof($voicemails) > 0) {
  335. foreach($voicemails as $field) {
  336. $messages[$field['voicemail_uuid']]['ext'] = $field['voicemail_id'];
  337. $messages[$field['voicemail_uuid']]['total'] = 0;
  338. $messages[$field['voicemail_uuid']]['new'] = 0;
  339. foreach($field['messages'] as &$row) {
  340. if ($row['message_status'] == '') {
  341. $messages[$field['voicemail_uuid']]['new']++;
  342. $messages['new']++;
  343. }
  344. $messages[$field['voicemail_uuid']]['total']++;
  345. $messages['total']++;
  346. }
  347. }
  348. }
  349. $hud[$n]['html'] = "<span class='hud_title' onclick=\"document.location.href='".PROJECT_PATH."/app/voicemails/voicemail_messages.php';\">".$text['label-voicemail']."</span>";
  350. $hud[$n]['html'] .= "<span class='hud_stat' onclick=\"$('#hud_'+".$n."+'_details').slideToggle('fast');\">".$messages['new']."</span>";
  351. $hud[$n]['html'] .= "<span class='hud_stat_title' onclick=\"$('#hud_'+".$n."+'_details').slideToggle('fast');\">".$text['label-new_messages']."</span>\n";
  352. $hud[$n]['html'] .= "<div class='hud_details' id='hud_".$n."_details'>";
  353. if (sizeof($voicemails) > 0) {
  354. $hud[$n]['html'] .= "<table class='tr_hover' cellpadding='2' cellspacing='0' border='0' width='100%'>";
  355. $hud[$n]['html'] .= "<tr>";
  356. $hud[$n]['html'] .= " <th class='hud_heading' width='50%'>".$text['label-voicemail']."</th>";
  357. $hud[$n]['html'] .= " <th class='hud_heading' style='text-align: center;' width='50%'>".$text['label-new']."</th>";
  358. $hud[$n]['html'] .= " <th class='hud_heading' style='text-align: center;'>".$text['label-total']."</th>";
  359. $hud[$n]['html'] .= "</tr>";
  360. $c = 0;
  361. $row_style["0"] = "row_style0";
  362. $row_style["1"] = "row_style1";
  363. foreach ($messages as $voicemail_uuid => $row) {
  364. if (is_uuid($voicemail_uuid)) {
  365. $tr_link = "href='".PROJECT_PATH."/app/voicemails/voicemail_messages.php?id=".(permission_exists('voicemail_view') ? $voicemail_uuid : $row['ext'])."'";
  366. $hud[$n]['html'] .= "<tr ".$tr_link." style='cursor: pointer;'>";
  367. $hud[$n]['html'] .= " <td class='".$row_style[$c]." hud_text'><a href='".PROJECT_PATH."/app/voicemails/voicemail_messages.php?id=".(permission_exists('voicemail_view') ? $voicemail_uuid : $row['ext'])."'>".$row['ext']."</a></td>";
  368. $hud[$n]['html'] .= " <td class='".$row_style[$c]." hud_text' style='text-align: center;'>".$row['new']."</td>";
  369. $hud[$n]['html'] .= " <td class='".$row_style[$c]." hud_text' style='text-align: center;'>".$row['total']."</td>";
  370. $hud[$n]['html'] .= "</tr>";
  371. $c = ($c) ? 0 : 1;
  372. }
  373. }
  374. $hud[$n]['html'] .= "</table>";
  375. }
  376. else {
  377. $hud[$n]['html'] .= "<br />".$text['label-no_voicemail_assigned'];
  378. }
  379. $hud[$n]['html'] .= "</div>";
  380. $n++;
  381. }
  382. //missed calls
  383. if (is_array($selected_blocks) && in_array('missed', $selected_blocks) && permission_exists('xml_cdr_view') && is_array($_SESSION['user']['extension']) && sizeof($_SESSION['user']['extension']) > 0) {
  384. foreach ($_SESSION['user']['extension'] as $assigned_extension) {
  385. $assigned_extensions[$assigned_extension['extension_uuid']] = $assigned_extension['user'];
  386. }
  387. unset($assigned_extension);
  388. //if also viewing system status, show more recent calls (more room avaialble)
  389. $missed_limit = (is_array($selected_blocks) && in_array('counts', $selected_blocks)) ? 10 : 5;
  390. $sql = "
  391. select
  392. direction,
  393. start_stamp,
  394. start_epoch,
  395. caller_id_name,
  396. caller_id_number,
  397. answer_stamp
  398. from
  399. v_xml_cdr
  400. where
  401. domain_uuid = :domain_uuid
  402. and (
  403. direction = 'inbound'
  404. or direction = 'local'
  405. )
  406. and (missed_call = true or bridge_uuid is null) ";
  407. if (is_array($assigned_extensions) && sizeof($assigned_extensions) != 0) {
  408. $x = 0;
  409. foreach ($assigned_extensions as $assigned_extension_uuid => $assigned_extension) {
  410. $sql_where_array[] = "extension_uuid = :assigned_extension_uuid_".$x;
  411. $sql_where_array[] = "destination_number = :destination_number_".$x;
  412. $parameters['assigned_extension_uuid_'.$x] = $assigned_extension_uuid;
  413. $parameters['destination_number_'.$x] = $assigned_extension;
  414. $x++;
  415. }
  416. if (is_array($sql_where_array) && sizeof($sql_where_array) != 0) {
  417. $sql .= "and (".implode(' or ', $sql_where_array).") ";
  418. }
  419. unset($sql_where_array);
  420. }
  421. $sql .= "
  422. and start_epoch > ".(time() - 86400)."
  423. order by
  424. start_epoch desc";
  425. $parameters['domain_uuid'] = $_SESSION['domain_uuid'];
  426. $database = new database;
  427. $result = $database->select($sql, $parameters, 'all');
  428. $num_rows = is_array($result) ? sizeof($result) : 0;
  429. $c = 0;
  430. $row_style["0"] = "row_style0";
  431. $row_style["1"] = "row_style1";
  432. $hud[$n]['html'] .= "<span class='hud_title' onclick=\"document.location.href='".PROJECT_PATH."/app/xml_cdr/xml_cdr.php?call_result=missed'\">".$text['label-missed_calls']."</span>";
  433. $hud[$n]['html'] .= "<span class='hud_stat' onclick=\"$('#hud_'+".$n."+'_details').slideToggle('fast');\">".$num_rows."</span>";
  434. $hud[$n]['html'] .= "<span class='hud_stat_title' onclick=\"$('#hud_'+".$n."+'_details').slideToggle('fast');\">".$text['label-last_24_hours']."</span>\n";
  435. $hud[$n]['html'] .= "<div class='hud_details' id='hud_".$n."_details'>";
  436. $hud[$n]['html'] .= "<table class='tr_hover' width='100%' cellpadding='0' cellspacing='0' border='0'>\n";
  437. $hud[$n]['html'] .= "<tr>\n";
  438. if ($num_rows > 0) {
  439. $hud[$n]['html'] .= "<th class='hud_heading'>&nbsp;</th>\n";
  440. }
  441. $hud[$n]['html'] .= "<th class='hud_heading' width='100%'>".$text['label-cid_number']."</th>\n";
  442. $hud[$n]['html'] .= "<th class='hud_heading'>".$text['label-missed']."</th>\n";
  443. $hud[$n]['html'] .= "</tr>\n";
  444. if ($num_rows > 0) {
  445. $theme_cdr_images_exist = (
  446. file_exists($theme_image_path."icon_cdr_inbound_voicemail.png") &&
  447. file_exists($theme_image_path."icon_cdr_inbound_cancelled.png") &&
  448. file_exists($theme_image_path."icon_cdr_local_voicemail.png") &&
  449. file_exists($theme_image_path."icon_cdr_local_cancelled.png")
  450. ) ? true : false;
  451. foreach($result as $index => $row) {
  452. if ($index + 1 > $missed_limit) { break; } //only show limit
  453. $tmp_year = date("Y", strtotime($row['start_stamp']));
  454. $tmp_month = date("M", strtotime($row['start_stamp']));
  455. $tmp_day = date("d", strtotime($row['start_stamp']));
  456. $tmp_start_epoch = ($_SESSION['domain']['time_format']['text'] == '12h') ? date("n/j g:ia", $row['start_epoch']) : date("n/j H:i", $row['start_epoch']);
  457. //set click-to-call variables
  458. if (permission_exists('click_to_call_call')) {
  459. $tr_link = "onclick=\"send_cmd('".PROJECT_PATH."/app/click_to_call/click_to_call.php".
  460. "?src_cid_name=".urlencode($row['caller_id_name']).
  461. "&src_cid_number=".urlencode($row['caller_id_number']).
  462. "&dest_cid_name=".urlencode($_SESSION['user']['extension'][0]['outbound_caller_id_name']).
  463. "&dest_cid_number=".urlencode($_SESSION['user']['extension'][0]['outbound_caller_id_number']).
  464. "&src=".urlencode($_SESSION['user']['extension'][0]['user']).
  465. "&dest=".urlencode($row['caller_id_number']).
  466. "&rec=".(isset($_SESSION['click_to_call']['record']['boolean'])?$_SESSION['click_to_call']['record']['boolean']:"false").
  467. "&ringback=".(isset($_SESSION['click_to_call']['ringback']['text'])?$_SESSION['click_to_call']['ringback']['text']:"us-ring").
  468. "&auto_answer=".(isset($_SESSION['click_to_call']['auto_answer']['boolean'])?$_SESSION['click_to_call']['auto_answer']['boolean']:"true").
  469. "');\" ".
  470. "style='cursor: pointer;'";
  471. }
  472. $hud[$n]['html'] .= "<tr ".$tr_link.">\n";
  473. $hud[$n]['html'] .= "<td valign='middle' class='".$row_style[$c]."' style='cursor: help; padding: 0 0 0 6px;'>\n";
  474. if ($theme_cdr_images_exist) {
  475. $call_result = ($row['answer_stamp'] != '') ? 'voicemail' : 'cancelled';
  476. if (isset($row['direction'])) {
  477. $hud[$n]['html'] .= "<img src='".PROJECT_PATH."/themes/".$_SESSION['domain']['template']['name']."/images/icon_cdr_".$row['direction']."_".$call_result.".png' width='16' style='border: none;' title='".$text['label-'.$row['direction']].": ".$text['label-'.$call_result]."'>\n";
  478. }
  479. }
  480. $hud[$n]['html'] .= "</td>\n";
  481. $hud[$n]['html'] .= "<td valign='top' class='".$row_style[$c]." hud_text' nowrap='nowrap'><a href='javascript:void(0);' ".(($row['caller_id_name'] != '') ? "title=\"".$row['caller_id_name']."\"" : null).">".((is_numeric($row['caller_id_number'])) ? format_phone($row['caller_id_number']) : $row['caller_id_number'])."</td>\n";
  482. $hud[$n]['html'] .= "<td valign='top' class='".$row_style[$c]." hud_text' nowrap='nowrap'>".$tmp_start_epoch."</td>\n";
  483. $hud[$n]['html'] .= "</tr>\n";
  484. $c = ($c) ? 0 : 1;
  485. }
  486. }
  487. unset($sql, $parameters, $result, $num_rows, $index, $row);
  488. $hud[$n]['html'] .= "</table>\n";
  489. $hud[$n]['html'] .= "<span style='display: block; margin: 6px 0 7px 0;'><a href='".PROJECT_PATH."/app/xml_cdr/xml_cdr.php?call_result=missed'>".$text['label-view_all']."</a></span>\n";
  490. $hud[$n]['html'] .= "</div>";
  491. $n++;
  492. }
  493. //recent calls
  494. if (is_array($selected_blocks) && in_array('recent', $selected_blocks) && permission_exists('xml_cdr_view') && is_array($_SESSION['user']['extension']) && sizeof($_SESSION['user']['extension']) > 0) {
  495. foreach ($_SESSION['user']['extension'] as $assigned_extension) {
  496. $assigned_extensions[$assigned_extension['extension_uuid']] = $assigned_extension['user'];
  497. }
  498. //if also viewing system status, show more recent calls (more room avaialble)
  499. $recent_limit = (is_array($selected_blocks) && in_array('counts', $selected_blocks)) ? 10 : 5;
  500. $sql = "
  501. select
  502. direction,
  503. start_stamp,
  504. start_epoch,
  505. caller_id_name,
  506. caller_id_number,
  507. destination_number,
  508. answer_stamp,
  509. bridge_uuid,
  510. sip_hangup_disposition
  511. from
  512. v_xml_cdr
  513. where
  514. domain_uuid = :domain_uuid ";
  515. if (is_array($assigned_extensions) && sizeof($assigned_extensions) != 0) {
  516. $x = 0;
  517. foreach ($assigned_extensions as $assigned_extension_uuid => $assigned_extension) {
  518. $sql_where_array[] = "extension_uuid = :extension_uuid_".$x;
  519. $sql_where_array[] = "caller_id_number = :caller_id_number_".$x;
  520. $sql_where_array[] = "destination_number = :destination_number_1_".$x;
  521. $sql_where_array[] = "destination_number = :destination_number_2_".$x;
  522. $parameters['extension_uuid_'.$x] = $assigned_extension_uuid;
  523. $parameters['caller_id_number_'.$x] = $assigned_extension;
  524. $parameters['destination_number_1_'.$x] = $assigned_extension;
  525. $parameters['destination_number_2_'.$x] = '*99'.$assigned_extension;
  526. $x++;
  527. }
  528. if (is_array($sql_where_array) && sizeof($sql_where_array) != 0) {
  529. $sql .= "and (".implode(' or ', $sql_where_array).") ";
  530. }
  531. unset($sql_where_array);
  532. }
  533. $sql .= "
  534. and start_epoch > ".(time() - 86400)."
  535. order by
  536. start_epoch desc";
  537. $parameters['domain_uuid'] = $_SESSION['domain_uuid'];
  538. $database = new database;
  539. $result = $database->select($sql, $parameters, 'all');
  540. $num_rows = is_array($result) ? sizeof($result) : 0;
  541. $c = 0;
  542. $row_style["0"] = "row_style0";
  543. $row_style["1"] = "row_style1";
  544. $hud[$n]['html'] .= "<span class='hud_title' onclick=\"document.location.href='".PROJECT_PATH."/app/xml_cdr/xml_cdr.php';\">".$text['label-recent_calls']."</span>";
  545. $hud[$n]['html'] .= "<span class='hud_stat' onclick=\"$('#hud_'+".$n."+'_details').slideToggle('fast');\">".$num_rows."</span>";
  546. $hud[$n]['html'] .= "<span class='hud_stat_title' onclick=\"$('#hud_'+".$n."+'_details').slideToggle('fast');\">".$text['label-last_24_hours']."</span>\n";
  547. $hud[$n]['html'] .= "<div class='hud_details' id='hud_".$n."_details'>";
  548. $hud[$n]['html'] .= "<table class='tr_hover' width='100%' cellpadding='0' cellspacing='0' border='0'>\n";
  549. $hud[$n]['html'] .= "<tr>\n";
  550. if ($num_rows > 0) {
  551. $hud[$n]['html'] .= "<th class='hud_heading'>&nbsp;</th>\n";
  552. }
  553. $hud[$n]['html'] .= "<th class='hud_heading' width='100%'>".$text['label-cid_number']."</th>\n";
  554. $hud[$n]['html'] .= "<th class='hud_heading'>".$text['label-date_time']."</th>\n";
  555. $hud[$n]['html'] .= "</tr>\n";
  556. if ($num_rows > 0) {
  557. $theme_cdr_images_exist = (
  558. file_exists($theme_image_path."icon_cdr_inbound_answered.png") &&
  559. file_exists($theme_image_path."icon_cdr_inbound_voicemail.png") &&
  560. file_exists($theme_image_path."icon_cdr_inbound_cancelled.png") &&
  561. file_exists($theme_image_path."icon_cdr_inbound_failed.png") &&
  562. file_exists($theme_image_path."icon_cdr_outbound_answered.png") &&
  563. file_exists($theme_image_path."icon_cdr_outbound_cancelled.png") &&
  564. file_exists($theme_image_path."icon_cdr_outbound_failed.png") &&
  565. file_exists($theme_image_path."icon_cdr_local_answered.png") &&
  566. file_exists($theme_image_path."icon_cdr_local_voicemail.png") &&
  567. file_exists($theme_image_path."icon_cdr_local_cancelled.png") &&
  568. file_exists($theme_image_path."icon_cdr_local_failed.png")
  569. ) ? true : false;
  570. foreach($result as $index => $row) {
  571. if ($index + 1 > $recent_limit) { break; } //only show limit
  572. $tmp_year = date("Y", strtotime($row['start_stamp']));
  573. $tmp_month = date("M", strtotime($row['start_stamp']));
  574. $tmp_day = date("d", strtotime($row['start_stamp']));
  575. $tmp_start_epoch = ($_SESSION['domain']['time_format']['text'] == '12h') ? date("n/j g:ia", $row['start_epoch']) : date("n/j H:i", $row['start_epoch']);
  576. //determine name
  577. $cdr_name = ($row['direction'] == 'inbound' || ($row['direction'] == 'local' && is_array($assigned_extensions) && in_array($row['destination_number'], $assigned_extensions))) ? $row['caller_id_name'] : $row['destination_number'];
  578. //determine number to display
  579. if ($row['direction'] == 'inbound' || ($row['direction'] == 'local' && is_array($assigned_extensions) && in_array($row['destination_number'], $assigned_extensions))) {
  580. $cdr_number = (is_numeric($row['caller_id_number'])) ? format_phone($row['caller_id_number']) : $row['caller_id_number'];
  581. $dest = $row['caller_id_number'];
  582. }
  583. else if ($row['direction'] == 'outbound' || ($row['direction'] == 'local' && is_array($assigned_extensions) && in_array($row['caller_id_number'], $assigned_extensions))) {
  584. $cdr_number = (is_numeric($row['destination_number'])) ? format_phone($row['destination_number']) : $row['destination_number'];
  585. $dest = $row['destination_number'];
  586. }
  587. //set click-to-call variables
  588. if (permission_exists('click_to_call_call')) {
  589. $tr_link = "onclick=\"send_cmd('".PROJECT_PATH."/app/click_to_call/click_to_call.php".
  590. "?src_cid_name=".urlencode($cdr_name).
  591. "&src_cid_number=".urlencode($cdr_number).
  592. "&dest_cid_name=".urlencode($_SESSION['user']['extension'][0]['outbound_caller_id_name']).
  593. "&dest_cid_number=".urlencode($_SESSION['user']['extension'][0]['outbound_caller_id_number']).
  594. "&src=".urlencode($_SESSION['user']['extension'][0]['user']).
  595. "&dest=".urlencode($dest).
  596. "&rec=".(isset($_SESSION['click_to_call']['record']['boolean'])?$_SESSION['click_to_call']['record']['boolean']:"false").
  597. "&ringback=".(isset($_SESSION['click_to_call']['ringback']['text'])?$_SESSION['click_to_call']['ringback']['text']:"us-ring").
  598. "&auto_answer=".(isset($_SESSION['click_to_call']['auto_answer']['boolean'])?$_SESSION['click_to_call']['auto_answer']['boolean']:"true").
  599. "');\" ".
  600. "style='cursor: pointer;'";
  601. }
  602. $hud[$n]['html'] .= "<tr ".$tr_link.">\n";
  603. //determine call result and appropriate icon
  604. $hud[$n]['html'] .= "<td valign='middle' class='".$row_style[$c]."' style='cursor: help; padding: 0 0 0 6px;'>\n";
  605. if ($theme_cdr_images_exist) {
  606. if ($row['direction'] == 'inbound' || $row['direction'] == 'local') {
  607. if ($row['answer_stamp'] != '' && $row['bridge_uuid'] != '') { $call_result = 'answered'; }
  608. else if ($row['answer_stamp'] != '' && $row['bridge_uuid'] == '') { $call_result = 'voicemail'; }
  609. else if ($row['answer_stamp'] == '' && $row['bridge_uuid'] == '' && $row['sip_hangup_disposition'] != 'send_refuse') { $call_result = 'cancelled'; }
  610. else { $call_result = 'failed'; }
  611. }
  612. else if ($row['direction'] == 'outbound') {
  613. if ($row['answer_stamp'] != '' && $row['bridge_uuid'] != '') { $call_result = 'answered'; }
  614. else if ($row['answer_stamp'] == '' && $row['bridge_uuid'] != '') { $call_result = 'cancelled'; }
  615. else { $call_result = 'failed'; }
  616. }
  617. if (isset($row['direction'])) {
  618. $hud[$n]['html'] .= "<img src='".PROJECT_PATH."/themes/".$_SESSION['domain']['template']['name']."/images/icon_cdr_".$row['direction']."_".$call_result.".png' width='16' style='border: none;' title='".$text['label-'.$row['direction']].": ".$text['label-'.$call_result]."'>\n";
  619. }
  620. }
  621. $hud[$n]['html'] .= "</td>\n";
  622. $hud[$n]['html'] .= "<td valign='top' class='".$row_style[$c]." hud_text' nowrap='nowrap'><a href='javascript:void(0);' ".(($cdr_name != '') ? "title=\"".$cdr_name."\"" : null).">".$cdr_number."</a></td>\n";
  623. $hud[$n]['html'] .= "<td valign='top' class='".$row_style[$c]." hud_text' nowrap='nowrap'>".$tmp_start_epoch."</td>\n";
  624. $hud[$n]['html'] .= "</tr>\n";
  625. unset($cdr_name, $cdr_number);
  626. $c = ($c) ? 0 : 1;
  627. }
  628. }
  629. unset($sql, $parameters, $result, $num_rows, $index, $row);
  630. $hud[$n]['html'] .= "</table>\n";
  631. $hud[$n]['html'] .= "<span style='display: block; margin: 6px 0 7px 0;'><a href='".PROJECT_PATH."/app/xml_cdr/xml_cdr.php'>".$text['label-view_all']."</a></span>\n";
  632. $hud[$n]['html'] .= "</div>";
  633. $n++;
  634. }
  635. //domain limits
  636. if (is_array($selected_blocks) && in_array('limits', $selected_blocks) && is_array($_SESSION['limit']) && sizeof($_SESSION['limit']) > 0) {
  637. $c = 0;
  638. $row_style["0"] = "row_style0";
  639. $row_style["1"] = "row_style1";
  640. $show_stat = true;
  641. if (permission_exists('extension_view')) {
  642. $onclick = "onclick=\"document.location.href='".PROJECT_PATH."/app/extensions/extensions.php'\"";
  643. $hud_stat = $stats['domain']['extensions']['total'];
  644. $hud_stat_title = $text['label-total_extensions'];
  645. }
  646. else if (permission_exists('destination_view')) {
  647. $onclick = "onclick=\"document.location.href='".PROJECT_PATH."/app/destinations/destinations.php'\"";
  648. $hud_stat = $stats['domain']['destinations']['total'];
  649. $hud_stat_title = $text['label-total_destinations'];
  650. }
  651. else {
  652. $show_stat = false;
  653. }
  654. $hud[$n]['html'] .= "<span class='hud_title' ".$onclick.">".$text['label-domain_limits']."</span>";
  655. if ($show_stat) {
  656. $hud[$n]['html'] .= "<span class='hud_stat' onclick=\"$('#hud_'+".$n."+'_details').slideToggle('fast');\">".$hud_stat."</span>";
  657. $hud[$n]['html'] .= "<span class='hud_stat_title' onclick=\"$('#hud_'+".$n."+'_details').slideToggle('fast');\">".$hud_stat_title."</span>\n";
  658. }
  659. $hud[$n]['html'] .= "<div class='hud_details' id='hud_".$n."_details'>";
  660. $hud[$n]['html'] .= "<table class='tr_hover' width='100%' cellpadding='0' cellspacing='0' border='0'>\n";
  661. $hud[$n]['html'] .= "<tr>\n";
  662. $hud[$n]['html'] .= "<th class='hud_heading' width='50%'>".$text['label-feature']."</th>\n";
  663. $hud[$n]['html'] .= "<th class='hud_heading' width='50%' style='text-align: center;'>".$text['label-used']."</th>\n";
  664. $hud[$n]['html'] .= "<th class='hud_heading' style='text-align: center;'>".$text['label-total']."</th>\n";
  665. $hud[$n]['html'] .= "</tr>\n";
  666. foreach ($_SESSION['limit'] as $category => $value) {
  667. $limit = $value['numeric'];
  668. switch ($category) {
  669. case 'users':
  670. if (!permission_exists('user_view')) { continue 2; }
  671. $url = '/core/users/users.php';
  672. break;
  673. case 'call_center_queues':
  674. if (!permission_exists('call_center_active_view')) { continue 2; }
  675. $url = '/app/call_centers/call_center_queues.php';
  676. break;
  677. case 'destinations':
  678. if (!permission_exists('destination_view')) { continue 2; }
  679. $url = '/app/destinations/destinations.php';
  680. break;
  681. case 'devices':
  682. if (!permission_exists('device_view')) { continue 2; }
  683. $url = '/app/devices/devices.php';
  684. break;
  685. case 'extensions':
  686. if (!permission_exists('extension_view')) { continue 2; }
  687. $url = '/app/extensions/extensions.php';
  688. break;
  689. case 'gateways':
  690. if (!permission_exists('gateway_view')) { continue 2; }
  691. $url = '/app/gateways/gateways.php';
  692. break;
  693. case 'ivr_menus':
  694. if (!permission_exists('ivr_menu_view')) { continue 2; }
  695. $url = '/app/ivr_menus/ivr_menus.php';
  696. break;
  697. case 'ring_groups':
  698. if (!permission_exists('ring_group_view')) { continue 2; }
  699. $url = '/app/ring_groups/ring_groups.php';
  700. break;
  701. }
  702. $tr_link = "href='".PROJECT_PATH.$url."'";
  703. $hud[$n]['html'] .= "<tr ".$tr_link." style='cursor: pointer;'>\n";
  704. $hud[$n]['html'] .= "<td valign='top' class='".$row_style[$c]." hud_text'><a ".$tr_link.">".$text['label-'.$category]."</a></td>\n";
  705. $hud[$n]['html'] .= "<td valign='top' class='".$row_style[$c]." hud_text' style='text-align: center;'>".$stats['domain'][$category]['total']."</td>\n";
  706. $hud[$n]['html'] .= "<td valign='top' class='".$row_style[$c]." hud_text' style='text-align: center;'>".$limit."</td>\n";
  707. $hud[$n]['html'] .= "</tr>\n";
  708. $c = ($c) ? 0 : 1;
  709. }
  710. $hud[$n]['html'] .= "</table>\n";
  711. $hud[$n]['html'] .= "</div>";
  712. $n++;
  713. }
  714. //system/domain counts
  715. if (is_array($selected_blocks) && in_array('counts', $selected_blocks)) {
  716. $c = 0;
  717. $row_style["0"] = "row_style0";
  718. $row_style["1"] = "row_style1";
  719. $scope = (permission_exists('dialplan_add')) ? 'system' : 'domain';
  720. $show_stat = true;
  721. if (permission_exists('domain_view')) {
  722. $onclick = "onclick=\"document.location.href='".PROJECT_PATH."/core/domains/domains.php'\"";
  723. $hud_stat = $stats[$scope]['domains']['total'] - $stats[$scope]['domains']['disabled'];
  724. $hud_stat_title = $text['label-active_domains'];
  725. }
  726. else if (permission_exists('extension_view') && file_exists($_SERVER["DOCUMENT_ROOT"].PROJECT_PATH."/app/extensions/")) {
  727. $onclick = "onclick=\"document.location.href='".PROJECT_PATH."/app/extensions/extensions.php'\"";
  728. $hud_stat = $stats[$scope]['extensions']['total'] - $stats[$scope]['extensions']['disabled'];
  729. $hud_stat_title = $text['label-active_extensions'];
  730. }
  731. else if ((permission_exists('user_view') || if_group("superadmin")) && file_exists($_SERVER["DOCUMENT_ROOT"].PROJECT_PATH."/core/users/")) {
  732. $onclick = "onclick=\"document.location.href='".PROJECT_PATH."/core/users/users.php'\"";
  733. $hud_stat = $stats[$scope]['users']['total'] - $stats[$scope]['users']['disabled'];
  734. $hud_stat_title = $text['label-active_users'];
  735. }
  736. else {
  737. $show_stat = false;
  738. }
  739. $hud[$n]['html'] = "<span class='hud_title' ".$onclick.">".$text['label-system_counts']."</span>";
  740. if ($show_stat) {
  741. $hud[$n]['html'] .= "<span class='hud_stat' onclick=\"$('#hud_'+".$n."+'_details').slideToggle('fast');\">".$hud_stat."</span>";
  742. $hud[$n]['html'] .= "<span class='hud_stat_title' onclick=\"$('#hud_'+".$n."+'_details').slideToggle('fast');\">".$hud_stat_title."</span>\n";
  743. }
  744. $hud[$n]['html'] .= "<div class='hud_details' id='hud_".$n."_details'>";
  745. $hud[$n]['html'] .= "<table class='tr_hover' width='100%' cellpadding='0' cellspacing='0' border='0'>\n";
  746. $hud[$n]['html'] .= "<tr>\n";
  747. $hud[$n]['html'] .= "<th class='hud_heading' width='50%'>".$text['label-item']."</th>\n";
  748. $hud[$n]['html'] .= "<th class='hud_heading' width='50%' style='text-align: center; padding-left: 0; padding-right: 0;'>".$text['label-disabled']."</th>\n";
  749. $hud[$n]['html'] .= "<th class='hud_heading' style='text-align: center;'>".$text['label-total']."</th>\n";
  750. $hud[$n]['html'] .= "</tr>\n";
  751. //domains
  752. if (permission_exists('domain_view')) {
  753. $tr_link = "href='".PROJECT_PATH."/core/domains/domains.php'";
  754. $hud[$n]['html'] .= "<tr ".$tr_link.">\n";
  755. $hud[$n]['html'] .= "<td valign='top' class='".$row_style[$c]." hud_text'><a ".$tr_link.">".$text['label-domains']."</a></td>\n";
  756. $hud[$n]['html'] .= "<td valign='top' class='".$row_style[$c]." hud_text' style='text-align: center;'>".$stats[$scope]['domains']['disabled']."</td>\n";
  757. $hud[$n]['html'] .= "<td valign='top' class='".$row_style[$c]." hud_text' style='text-align: center;'>".$stats[$scope]['domains']['total']."</td>\n";
  758. $hud[$n]['html'] .= "</tr>\n";
  759. $c = ($c) ? 0 : 1;
  760. }
  761. //devices
  762. if (permission_exists('device_view') && file_exists($_SERVER["DOCUMENT_ROOT"].PROJECT_PATH."/app/devices/")) {
  763. $tr_link = "href='".PROJECT_PATH."/app/devices/devices.php'";
  764. $hud[$n]['html'] .= "<tr ".$tr_link.">\n";
  765. $hud[$n]['html'] .= "<td valign='top' class='".$row_style[$c]." hud_text'><a ".$tr_link.">".$text['label-devices']."</a></td>\n";
  766. $hud[$n]['html'] .= "<td valign='top' class='".$row_style[$c]." hud_text' style='text-align: center;'>".$stats[$scope]['devices']['disabled']."</td>\n";
  767. $hud[$n]['html'] .= "<td valign='top' class='".$row_style[$c]." hud_text' style='text-align: center;'>".$stats[$scope]['devices']['total']."</td>\n";
  768. $hud[$n]['html'] .= "</tr>\n";
  769. $c = ($c) ? 0 : 1;
  770. }
  771. //extensions
  772. if (permission_exists('extension_view') && file_exists($_SERVER["DOCUMENT_ROOT"].PROJECT_PATH."/app/extensions/")) {
  773. $tr_link = "href='".PROJECT_PATH."/app/extensions/extensions.php'";
  774. $hud[$n]['html'] .= "<tr ".$tr_link.">\n";
  775. $hud[$n]['html'] .= "<td valign='top' class='".$row_style[$c]." hud_text'><a ".$tr_link.">".$text['label-extensions']."</a></td>\n";
  776. $hud[$n]['html'] .= "<td valign='top' class='".$row_style[$c]." hud_text' style='text-align: center;'>".$stats[$scope]['extensions']['disabled']."</td>\n";
  777. $hud[$n]['html'] .= "<td valign='top' class='".$row_style[$c]." hud_text' style='text-align: center;'>".$stats[$scope]['extensions']['total']."</td>\n";
  778. $hud[$n]['html'] .= "</tr>\n";
  779. $c = ($c) ? 0 : 1;
  780. }
  781. //gateways
  782. if (permission_exists('gateway_view') && file_exists($_SERVER["DOCUMENT_ROOT"].PROJECT_PATH."/app/gateways/")) {
  783. $tr_link = "href='".PROJECT_PATH."/app/gateways/gateways.php'";
  784. $hud[$n]['html'] .= "<tr ".$tr_link.">\n";
  785. $hud[$n]['html'] .= "<td valign='top' class='".$row_style[$c]." hud_text'><a ".$tr_link.">".$text['label-gateways']."</a></td>\n";
  786. $hud[$n]['html'] .= "<td valign='top' class='".$row_style[$c]." hud_text' style='text-align: center;'>".$stats[$scope]['gateways']['disabled']."</td>\n";
  787. $hud[$n]['html'] .= "<td valign='top' class='".$row_style[$c]." hud_text' style='text-align: center;'>".$stats[$scope]['gateways']['total']."</td>\n";
  788. $hud[$n]['html'] .= "</tr>\n";
  789. $c = ($c) ? 0 : 1;
  790. }
  791. //users
  792. if ((permission_exists('user_view') || if_group("superadmin")) && file_exists($_SERVER["DOCUMENT_ROOT"].PROJECT_PATH."/core/users/")) {
  793. $tr_link = "href='".PROJECT_PATH."/core/users/users.php'";
  794. $hud[$n]['html'] .= "<tr ".$tr_link.">\n";
  795. $hud[$n]['html'] .= "<td valign='top' class='".$row_style[$c]." hud_text'><a ".$tr_link.">".$text['label-users']."</a></td>\n";
  796. $hud[$n]['html'] .= "<td valign='top' class='".$row_style[$c]." hud_text' style='text-align: center;'>".$stats[$scope]['users']['disabled']."</td>\n";
  797. $hud[$n]['html'] .= "<td valign='top' class='".$row_style[$c]." hud_text' style='text-align: center;'>".$stats[$scope]['users']['total']."</td>\n";
  798. $hud[$n]['html'] .= "</tr>\n";
  799. $c = ($c) ? 0 : 1;
  800. }
  801. //destinations
  802. if (permission_exists('destination_view') && file_exists($_SERVER["DOCUMENT_ROOT"].PROJECT_PATH."/app/destinations/")) {
  803. $tr_link = "href='".PROJECT_PATH."/app/destinations/destinations.php'";
  804. $hud[$n]['html'] .= "<tr ".$tr_link.">\n";
  805. $hud[$n]['html'] .= "<td valign='top' class='".$row_style[$c]." hud_text'><a ".$tr_link.">".$text['label-destinations']."</a></td>\n";
  806. $hud[$n]['html'] .= "<td valign='top' class='".$row_style[$c]." hud_text' style='text-align: center;'>".$stats[$scope]['destinations']['disabled']."</td>\n";
  807. $hud[$n]['html'] .= "<td valign='top' class='".$row_style[$c]." hud_text' style='text-align: center;'>".$stats[$scope]['destinations']['total']."</td>\n";
  808. $hud[$n]['html'] .= "</tr>\n";
  809. $c = ($c) ? 0 : 1;
  810. }
  811. //call center queues
  812. if (permission_exists('call_center_active_view') && file_exists($_SERVER["DOCUMENT_ROOT"].PROJECT_PATH."/app/call_centers/")) {
  813. $tr_link = "href='".PROJECT_PATH."/app/call_centers/call_center_queues.php'";
  814. $hud[$n]['html'] .= "<tr ".$tr_link.">\n";
  815. $hud[$n]['html'] .= "<td valign='top' class='".$row_style[$c]." hud_text'><a ".$tr_link.">".$text['label-call_center_queues']."</a></td>\n";
  816. $hud[$n]['html'] .= "<td valign='top' class='".$row_style[$c]." hud_text' style='text-align: center;'>".$stats[$scope]['call_center_queues']['disabled']."</td>\n";
  817. $hud[$n]['html'] .= "<td valign='top' class='".$row_style[$c]." hud_text' style='text-align: center;'>".$stats[$scope]['call_center_queues']['total']."</td>\n";
  818. $hud[$n]['html'] .= "</tr>\n";
  819. $c = ($c) ? 0 : 1;
  820. }
  821. //ivr menus
  822. if (permission_exists('ivr_menu_view') && file_exists($_SERVER["DOCUMENT_ROOT"].PROJECT_PATH."/app/ivr_menus/")) {
  823. $tr_link = "href='".PROJECT_PATH."/app/ivr_menus/ivr_menus.php'";
  824. $hud[$n]['html'] .= "<tr ".$tr_link.">\n";
  825. $hud[$n]['html'] .= "<td valign='top' class='".$row_style[$c]." hud_text'><a ".$tr_link.">".$text['label-ivr_menus']."</a></td>\n";
  826. $hud[$n]['html'] .= "<td valign='top' class='".$row_style[$c]." hud_text' style='text-align: center;'>".$stats[$scope]['ivr_menus']['disabled']."</td>\n";
  827. $hud[$n]['html'] .= "<td valign='top' class='".$row_style[$c]." hud_text' style='text-align: center;'>".$stats[$scope]['ivr_menus']['total']."</td>\n";
  828. $hud[$n]['html'] .= "</tr>\n";
  829. $c = ($c) ? 0 : 1;
  830. }
  831. //ring groups
  832. if (permission_exists('ring_group_view') && file_exists($_SERVER["DOCUMENT_ROOT"].PROJECT_PATH."/app/ring_groups/")) {
  833. $tr_link = "href='".PROJECT_PATH."/app/ring_groups/ring_groups.php'";
  834. $hud[$n]['html'] .= "<tr ".$tr_link.">\n";
  835. $hud[$n]['html'] .= "<td valign='top' class='".$row_style[$c]." hud_text'><a ".$tr_link.">".$text['label-ring_groups']."</a></td>\n";
  836. $hud[$n]['html'] .= "<td valign='top' class='".$row_style[$c]." hud_text' style='text-align: center;'>".$stats[$scope]['ring_groups']['disabled']."</td>\n";
  837. $hud[$n]['html'] .= "<td valign='top' class='".$row_style[$c]." hud_text' style='text-align: center;'>".$stats[$scope]['ring_groups']['total']."</td>\n";
  838. $hud[$n]['html'] .= "</tr>\n";
  839. $c = ($c) ? 0 : 1;
  840. }
  841. //voicemails
  842. if (permission_exists('voicemail_view') && file_exists($_SERVER["DOCUMENT_ROOT"].PROJECT_PATH."/app/voicemails/")) {
  843. $tr_link = "href='".PROJECT_PATH."/app/voicemails/voicemails.php'";
  844. $hud[$n]['html'] .= "<tr ".$tr_link.">\n";
  845. $hud[$n]['html'] .= "<td valign='top' class='".$row_style[$c]." hud_text'><a ".$tr_link.">".$text['label-voicemail']."</a></td>\n";
  846. $hud[$n]['html'] .= "<td valign='top' class='".$row_style[$c]." hud_text' style='text-align: center;'>".$stats[$scope]['voicemails']['disabled']."</td>\n";
  847. $hud[$n]['html'] .= "<td valign='top' class='".$row_style[$c]." hud_text' style='text-align: center;'>".$stats[$scope]['voicemails']['total']."</td>\n";
  848. $hud[$n]['html'] .= "</tr>\n";
  849. $c = ($c) ? 0 : 1;
  850. }
  851. //messages
  852. if (permission_exists('voicemail_message_view') && file_exists($_SERVER["DOCUMENT_ROOT"].PROJECT_PATH."/app/voicemails/")) {
  853. $hud[$n]['html'] .= "<tr>\n";
  854. $hud[$n]['html'] .= "<th class='hud_heading' width='50%'>".$text['label-item']."</th>\n";
  855. $hud[$n]['html'] .= "<th class='hud_heading' width='50%' style='text-align: center; padding-left: 0; padding-right: 0;'>".$text['label-new']."</th>\n";
  856. $hud[$n]['html'] .= "<th class='hud_heading' style='text-align: center;'>".$text['label-total']."</th>\n";
  857. $hud[$n]['html'] .= "</tr>\n";
  858. $tr_link = "href='".PROJECT_PATH."/app/voicemails/voicemails.php'";
  859. $hud[$n]['html'] .= "<tr ".$tr_link.">\n";
  860. $hud[$n]['html'] .= "<td valign='top' class='".$row_style[$c]." hud_text'><a ".$tr_link.">".$text['label-messages']."</a></td>\n";
  861. $hud[$n]['html'] .= "<td valign='top' class='".$row_style[$c]." hud_text' style='text-align: center;'>".$stats[$scope]['messages']['new']."</td>\n";
  862. $hud[$n]['html'] .= "<td valign='top' class='".$row_style[$c]." hud_text' style='text-align: center;'>".$stats[$scope]['messages']['total']."</td>\n";
  863. $hud[$n]['html'] .= "</tr>\n";
  864. $c = ($c) ? 0 : 1;
  865. }
  866. $hud[$n]['html'] .= "</table>\n";
  867. $hud[$n]['html'] .= "</div>";
  868. $n++;
  869. }
  870. //system status
  871. if (is_array($selected_blocks) && in_array('system', $selected_blocks)) {
  872. $c = 0;
  873. $row_style["0"] = "row_style0";
  874. $row_style["1"] = "row_style1";
  875. $hud[$n]['html'] = "<span class='hud_title' style='cursor: default;'>".$text['label-system_status']."</span>";
  876. //disk usage
  877. if (PHP_OS == 'FreeBSD' || PHP_OS == 'Linux') {
  878. $tmp = shell_exec("df /home 2>&1");
  879. $tmp = explode("\n", $tmp);
  880. $tmp = preg_replace('!\s+!', ' ', $tmp[1]); // multiple > single space
  881. $tmp = explode(' ', $tmp);
  882. foreach ($tmp as $stat) {
  883. if (substr_count($stat, '%') > 0) { $percent_disk_usage = rtrim($stat,'%'); break; }
  884. }
  885. if ($percent_disk_usage != '') {
  886. $hud[$n]['html'] .= "<span class='hud_stat' onclick=\"$('#hud_'+".$n."+'_details').slideToggle('fast');\">".$percent_disk_usage."</span>";
  887. $hud[$n]['html'] .= "<span class='hud_stat_title' onclick=\"$('#hud_'+".$n."+'_details').slideToggle('fast');\" style='cursor: default;'>".$text['label-disk_usage']." (%)</span>\n";
  888. }
  889. }
  890. $hud[$n]['html'] .= "<div class='hud_details' id='hud_".$n."_details'>";
  891. $hud[$n]['html'] .= "<table class='tr_hover' width='100%' cellpadding='0' cellspacing='0' border='0'>\n";
  892. $hud[$n]['html'] .= "<tr>\n";
  893. $hud[$n]['html'] .= "<th class='hud_heading' width='50%'>".$text['label-item']."</th>\n";
  894. $hud[$n]['html'] .= "<th class='hud_heading' style='text-align: right;'>".$text['label-value']."</th>\n";
  895. $hud[$n]['html'] .= "</tr>\n";
  896. //pbx version
  897. $hud[$n]['html'] .= "<tr class='tr_link_void'>\n";
  898. $hud[$n]['html'] .= "<td valign='top' class='".$row_style[$c]." hud_text'>".(isset($_SESSION['theme']['title']['text'])?$_SESSION['theme']['title']['text']:'FusionPBX')."</td>\n";
  899. $hud[$n]['html'] .= "<td valign='top' class='".$row_style[$c]." hud_text' style='text-align: right;'>".software::version()."</td>\n";
  900. $hud[$n]['html'] .= "</tr>\n";
  901. $c = ($c) ? 0 : 1;
  902. //os uptime
  903. if (stristr(PHP_OS, 'Linux')) {
  904. unset($tmp);
  905. $cut = shell_exec("/usr/bin/which cut");
  906. $uptime = trim(shell_exec(escapeshellcmd($cut." -d. -f1 /proc/uptime")));
  907. $tmp['y'] = floor($uptime/60/60/24/365);
  908. $tmp['d'] = $uptime/60/60/24%365;
  909. $tmp['h'] = $uptime/60/60%24;
  910. $tmp['m'] = $uptime/60%60;
  911. $tmp['s'] = $uptime%60;
  912. $uptime = (($tmp['y'] != 0 && $tmp['y'] != '') ? $tmp['y'].'y ' : null);
  913. $uptime .= (($tmp['d'] != 0 && $tmp['d'] != '') ? $tmp['d'].'d ' : null);
  914. $uptime .= (($tmp['h'] != 0 && $tmp['h'] != '') ? $tmp['h'].'h ' : null);
  915. $uptime .= (($tmp['m'] != 0 && $tmp['m'] != '') ? $tmp['m'].'m ' : null);
  916. $uptime .= (($tmp['s'] != 0 && $tmp['s'] != '') ? $tmp['s'].'s' : null);
  917. if ($uptime != '') {
  918. $hud[$n]['html'] .= "<tr class='tr_link_void'>\n";
  919. $hud[$n]['html'] .= "<td valign='top' class='".$row_style[$c]." hud_text'>".$text['label-system_uptime']."</td>\n";
  920. $hud[$n]['html'] .= "<td valign='top' class='".$row_style[$c]." hud_text' style='text-align: right;'>".$uptime."</td>\n";
  921. $hud[$n]['html'] .= "</tr>\n";
  922. $c = ($c) ? 0 : 1;
  923. }
  924. }
  925. //memory usage (for available memory, use "free | awk 'FNR == 3 {print $4/($3+$4)*100}'" instead)
  926. if (stristr(PHP_OS, 'Linux')) {
  927. $free = shell_exec("/usr/bin/which free");
  928. $awk = shell_exec("/usr/bin/which awk");
  929. $percent_memory = round(shell_exec(escapeshellcmd($free." | ".$awk." 'FNR == 3 {print $3/($3+$4)*100}'")), 1);
  930. if ($percent_memory != '') {
  931. $hud[$n]['html'] .= "<tr class='tr_link_void'>\n";
  932. $hud[$n]['html'] .= "<td valign='top' class='".$row_style[$c]." hud_text'>".$text['label-memory_usage']."</td>\n";
  933. $hud[$n]['html'] .= "<td valign='top' class='".$row_style[$c]." hud_text' style='text-align: right;'>".$percent_memory."%</td>\n";
  934. $hud[$n]['html'] .= "</tr>\n";
  935. $c = ($c) ? 0 : 1;
  936. }
  937. }
  938. //memory available
  939. if (stristr(PHP_OS, 'Linux')) {
  940. $result = trim(shell_exec('free -hw | grep \'Mem:\' | cut -d\' \' -f 55-64'));
  941. if ($result != '') {
  942. $hud[$n]['html'] .= "<tr class='tr_link_void'>\n";
  943. $hud[$n]['html'] .= "<td valign='top' class='".$row_style[$c]." hud_text'>".$text['label-memory_available']."</td>\n";
  944. $hud[$n]['html'] .= "<td valign='top' class='".$row_style[$c]." hud_text' style='text-align: right;'>".$result."</td>\n";
  945. $hud[$n]['html'] .= "</tr>\n";
  946. $c = ($c) ? 0 : 1;
  947. }
  948. }
  949. //disk usage
  950. if (stristr(PHP_OS, 'Linux')) {
  951. //calculated above
  952. if ($percent_disk_usage != '') {
  953. $hud[$n]['html'] .= "<tr class='tr_link_void'>\n";
  954. $hud[$n]['html'] .= "<td valign='top' class='".$row_style[$c]." hud_text'>".$text['label-disk_usage']."</td>\n";
  955. $hud[$n]['html'] .= "<td valign='top' class='".$row_style[$c]." hud_text' style='text-align: right;'>".$percent_disk_usage."%</td>\n";
  956. $hud[$n]['html'] .= "</tr>\n";
  957. $c = ($c) ? 0 : 1;
  958. }
  959. }
  960. //cpu usage
  961. if (stristr(PHP_OS, 'Linux')) {
  962. $result = shell_exec('ps -A -o pcpu');
  963. $percent_cpu = 0;
  964. foreach (explode("\n", $result) as $value) {
  965. if (is_numeric($value)) { $percent_cpu = $percent_cpu + $value; }
  966. }
  967. $result = trim(shell_exec("grep -P '^processor' /proc/cpuinfo"));
  968. $cores = count(explode("\n", $result));
  969. if ($percent_cpu > 1) { $percent_cpu = $percent_cpu / $cores; }
  970. $percent_cpu = round($percent_cpu, 2);
  971. if ($percent_cpu != '') {
  972. $hud[$n]['html'] .= "<tr class='tr_link_void'>\n";
  973. $hud[$n]['html'] .= "<td valign='top' class='".$row_style[$c]." hud_text'>".$text['label-processor_usage']."</td>\n";
  974. $hud[$n]['html'] .= "<td valign='top' class='".$row_style[$c]." hud_text' style='text-align: right;'>".$percent_cpu."%</td>\n";
  975. $hud[$n]['html'] .= "</tr>\n";
  976. $c = ($c) ? 0 : 1;
  977. }
  978. }
  979. //db connections
  980. switch ($db_type) {
  981. case 'pgsql':
  982. $sql = "select count(*) from pg_stat_activity";
  983. break;
  984. case 'mysql':
  985. $sql = "show status where `variable_name` = 'Threads_connected'";
  986. break;
  987. default:
  988. unset($sql);
  989. if ($db_path != '' && $dbfilename != '') {
  990. $tmp = shell_exec("lsof ".realpath($db_path).'/'.$dbfilename);
  991. $tmp = explode("\n", $tmp);
  992. $connections = sizeof($tmp) - 1;
  993. }
  994. }
  995. if ($sql != '') {
  996. $database = new database;
  997. $connections = $database->select($sql, null, 'column');
  998. unset($sql);
  999. }
  1000. if ($connections != '') {
  1001. $hud[$n]['html'] .= "<tr class='tr_link_void'>\n";
  1002. $hud[$n]['html'] .= "<td valign='top' class='".$row_style[$c]." hud_text'>".$text['label-database_connections']."</td>\n";
  1003. $hud[$n]['html'] .= "<td valign='top' class='".$row_style[$c]." hud_text' style='text-align: right;'>".$connections."</td>\n";
  1004. $hud[$n]['html'] .= "</tr>\n";
  1005. $c = ($c) ? 0 : 1;
  1006. }
  1007. //channel count
  1008. if ($fp) {
  1009. $tmp = event_socket_request($fp, 'api status');
  1010. $matches = Array();
  1011. preg_match("/(\d+)\s+session\(s\)\s+\-\speak/", $tmp, $matches);
  1012. $channels = $matches[1] ? $matches[1] : 0;
  1013. $tr_link = "href='".PROJECT_PATH."/app/calls_active/calls_active.php'";
  1014. $hud[$n]['html'] .= "<tr ".$tr_link.">\n";
  1015. $hud[$n]['html'] .= "<td valign='top' class='".$row_style[$c]." hud_text'><a ".$tr_link.">".$text['label-channels']."</a></td>\n";
  1016. $hud[$n]['html'] .= "<td valign='top' class='".$row_style[$c]." hud_text' style='text-align: right;'>".$channels."</td>\n";
  1017. $hud[$n]['html'] .= "</tr>\n";
  1018. $c = ($c) ? 0 : 1;
  1019. }
  1020. //registration count
  1021. if ($fp && file_exists($_SERVER["DOCUMENT_ROOT"].PROJECT_PATH."/app/registrations/")) {
  1022. $registration = new registrations;
  1023. $registrations = $registration->count();
  1024. $tr_link = "href='".PROJECT_PATH."/app/registrations/registrations.php'";
  1025. $hud[$n]['html'] .= "<tr ".$tr_link.">\n";
  1026. $hud[$n]['html'] .= "<td valign='top' class='".$row_style[$c]." hud_text'><a ".$tr_link.">".$text['label-registrations']."</a></td>\n";
  1027. $hud[$n]['html'] .= "<td valign='top' class='".$row_style[$c]." hud_text' style='text-align: right;'>".$registrations."</td>\n";
  1028. $hud[$n]['html'] .= "</tr>\n";
  1029. $c = ($c) ? 0 : 1;
  1030. }
  1031. $hud[$n]['html'] .= "</table>\n";
  1032. $hud[$n]['html'] .= "</div>";
  1033. $n++;
  1034. }
  1035. //output hud blocks
  1036. if (is_array($hud) && sizeof($hud) > 0) {
  1037. //javascript function: send_cmd
  1038. if (((is_array($selected_blocks) && in_array('missed', $selected_blocks)) || (is_array($selected_blocks) && in_array('recent', $selected_blocks))) && permission_exists('xml_cdr_view')) {
  1039. echo "<script type=\"text/javascript\">\n";
  1040. echo " function send_cmd(url) {\n";
  1041. //echo " alert(url);\n";
  1042. echo " if (window.XMLHttpRequest) { // code for IE7+, Firefox, Chrome, Opera, Safari\n";
  1043. echo " xmlhttp=new XMLHttpRequest();\n";
  1044. echo " }\n";
  1045. echo " else {// code for IE6, IE5\n";
  1046. echo " xmlhttp=new ActiveXObject(\"Microsoft.XMLHTTP\");\n";
  1047. echo " }\n";
  1048. echo " xmlhttp.open(\"GET\",url,true);\n";
  1049. echo " xmlhttp.send(null);\n";
  1050. echo " document.getElementById('cmd_reponse').innerHTML=xmlhttp.responseText;\n";
  1051. echo " }\n";
  1052. echo "</script>\n";
  1053. }
  1054. //define grid columns widths and when to use a clear fix
  1055. //-- $col_str[box_total][/usr/bin/which_box]
  1056. //-- $clear_fix[box_total][after_box]
  1057. $col_str[1][1] = "col-xs-12 col-sm-12 col-md-12 col-lg-12";
  1058. for ($n = 1; $n <= 2; $n++) { $col_str[2][$n] = "col-xs-12 col-sm-6 col-md-6 col-lg-6"; }
  1059. for ($n = 1; $n <= 3; $n++) { $col_str[3][$n] = "col-xs-12 col-sm-4 col-md-4 col-lg-4"; }
  1060. for ($n = 1; $n <= 4; $n++) { $col_str[4][$n] = "col-xs-12 col-sm-6 col-md-3 col-lg-3"; }
  1061. for ($n = 1; $n <= 3; $n++) { $col_str[5][$n] = "col-xs-12 col-sm-4 col-md-4 col-lg-2"; }
  1062. $col_str[5][4] = "col-xs-12 col-sm-6 col-md-6 col-lg-3";
  1063. $col_str[5][5] = "col-xs-12 col-sm-6 col-md-6 col-lg-3";
  1064. for ($n = 1; $n <= 6; $n++) { $col_str[6][$n] = "col-xs-12 col-sm-6 col-md-4 col-lg-2"; }
  1065. $clear_fix[4][2] = "visible-sm";
  1066. $clear_fix[5][3] = "visible-sm visible-md";
  1067. $clear_fix[6][2] = "visible-sm";
  1068. $clear_fix[6][3] = "visible-md";
  1069. $clear_fix[6][4] = "visible-sm";
  1070. echo "<div class='row' style='padding: 0 10px;'>";
  1071. foreach ($hud as $index => $block) {
  1072. echo "<div class='".$col_str[sizeof($hud)][$index+1]."'>";
  1073. echo " <div class='row' style='padding: 6px;'>";
  1074. echo " <div class='col-md-12 hud_box' style='padding: 0;'>";
  1075. echo $block['html'];
  1076. echo " <span class='hud_expander' onclick=\"$('#hud_'+".$index."+'_details').slideToggle('fast');\"><span class='fas fa-ellipsis-h'></span></span>";
  1077. echo " </div>";
  1078. echo " </div>";
  1079. echo "</div>";
  1080. if (isset($clear_fix[sizeof($hud)][$index+1]) && $clear_fix[sizeof($hud)][$index+1] != '') {
  1081. echo "<div class='clearfix ".$clear_fix[sizeof($hud)][$index+1]."'></div>";
  1082. }
  1083. }
  1084. echo "</div>";
  1085. }
  1086. //additional items for the dashbaord
  1087. if (!is_array($selected_blocks) || in_array('call_routing', $selected_blocks) || in_array('ring_groups', $selected_blocks)) {
  1088. echo "<div class='row' style='margin-top: 30px;'>\n";
  1089. if (!is_array($selected_blocks) || in_array('caller_id', $selected_blocks)) {
  1090. //caller id management
  1091. if (file_exists($_SERVER["DOCUMENT_ROOT"].PROJECT_PATH."/app/extensions/extension_dashboard.php")) {
  1092. if (permission_exists('extension_caller_id')) {
  1093. $is_included = true;
  1094. echo "<div class='col-xs-12 col-sm-12 col-md-6 col-lg-6' style='margin: 0 0 30px 0;'>\n";
  1095. require_once "app/extensions/extension_dashboard.php";
  1096. echo "</div>";
  1097. }
  1098. }
  1099. }
  1100. if (!is_array($selected_blocks) || in_array('call_routing', $selected_blocks)) {
  1101. //call routing
  1102. if (file_exists($_SERVER["DOCUMENT_ROOT"].PROJECT_PATH."/app/calls/calls.php")) {
  1103. if (permission_exists('follow_me') || permission_exists('call_forward') || permission_exists('do_not_disturb')) {
  1104. $is_included = true;
  1105. echo "<div class='col-xs-12 col-sm-12 col-md-6 col-lg-6' style='margin: 0 0 30px 0;'>\n";
  1106. require_once "app/calls/calls.php";
  1107. echo "</div>\n";
  1108. }
  1109. }
  1110. }
  1111. if (!is_array($selected_blocks) || in_array('ring_groups', $selected_blocks)) {
  1112. //ring group forward
  1113. if (file_exists($_SERVER["DOCUMENT_ROOT"].PROJECT_PATH."/app/ring_groups/ring_group_forward.php")) {
  1114. if (permission_exists('ring_group_forward')) {
  1115. $is_included = true;
  1116. echo "<div class='col-xs-12 col-sm-12 col-md-6 col-lg-6' style='margin: 0 0 30px 0;'>\n";
  1117. require_once "app/ring_groups/ring_group_forward.php";
  1118. echo "</div>";
  1119. }
  1120. }
  1121. }
  1122. if (!is_array($selected_blocks) || in_array('call_center_agents', $selected_blocks)) {
  1123. //call center agent
  1124. if (file_exists($_SERVER["DOCUMENT_ROOT"].PROJECT_PATH."/app/call_centers/call_center_agent_dashboard.php")) {
  1125. if (permission_exists('call_center_agent_view')) {
  1126. $is_included = true;
  1127. echo "<div class='col-xs-12 col-sm-12 col-md-6 col-lg-6' style='margin: 0 0 30px 0;'>\n";
  1128. require_once "app/call_centers/call_center_agent_dashboard.php";
  1129. echo "</div>";
  1130. }
  1131. }
  1132. }
  1133. if (!is_array($selected_blocks) || in_array('device_keys', $selected_blocks)) {
  1134. //device key management
  1135. if (file_exists($_SERVER["DOCUMENT_ROOT"].PROJECT_PATH."/app/devices/device_dashboard.php")) {
  1136. if (permission_exists('device_key_edit')) {
  1137. $is_included = true;
  1138. echo "<div class='col-xs-12 col-sm-12 col-md-6 col-lg-6' style='margin: 15px 0 30px 0;'>\n";
  1139. require_once "app/devices/device_dashboard.php";
  1140. echo "</div>";
  1141. }
  1142. }
  1143. }
  1144. echo "</div>\n";
  1145. }
  1146. //show the footer
  1147. require_once "resources/footer.php";
  1148. ?>