From 2c810e15fde6385477a980e06486e1c502f7d3ac Mon Sep 17 00:00:00 2001 From: mattf Date: Sat, 2 Mar 2019 23:08:00 +0000 Subject: [PATCH] Added new web pages for mobile application git-svn-id: svn://192.168.202.10@3068 3d104415-ff17-0410-8863-d5cf3c621b8a --- UPGRADE | 2 + docs/LICENSE.txt | 224 ++ www/vicidial/AST_rt_whiteboard_rpt_mobile.php | 872 ++++++ www/vicidial/AST_timeonVDADall.php | 114 +- .../AST_timeonVDADallSUMMARY_mobile.php | 1726 ++++++++++++ www/vicidial/admin.php | 23 +- www/vicidial/admin_header.php | 19 +- www/vicidial/admin_mobile.php | 2459 +++++++++++++++++ .../campaign_summary_mobile_report.php | 629 +++++ www/vicidial/pureknob.js | 1095 ++++++++ www/vicidial/realtime_report_mobile.php | 1815 ++++++++++++ www/vicidial/vicidial_stylesheet.php | 325 ++- .../vicidial_whiteboard_functions.php | 20 +- www/vicidial/whiteboard_reports.php | 73 +- 14 files changed, 9308 insertions(+), 88 deletions(-) create mode 100644 www/vicidial/AST_rt_whiteboard_rpt_mobile.php create mode 100644 www/vicidial/AST_timeonVDADallSUMMARY_mobile.php create mode 100644 www/vicidial/admin_mobile.php create mode 100644 www/vicidial/campaign_summary_mobile_report.php create mode 100644 www/vicidial/pureknob.js create mode 100644 www/vicidial/realtime_report_mobile.php diff --git a/UPGRADE b/UPGRADE index 26eb2bff..542dcb73 100644 --- a/UPGRADE +++ b/UPGRADE @@ -386,6 +386,8 @@ OTHER CHANGES: 107. Added options to define the static prompts to use for the Inbound Group "Play Place in Line" feature +108. Added new web pages for mobile application + diff --git a/docs/LICENSE.txt b/docs/LICENSE.txt index 395acb93..9851ca0c 100644 --- a/docs/LICENSE.txt +++ b/docs/LICENSE.txt @@ -275,3 +275,227 @@ TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + + +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + + + + +The above AGPLv2 license is what the entire VICIdial codebase is released under. + + + +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + + + + +We have also incorporated another small open-soruce project's code into VICIdial +, pure-knob, that is under the Apache 2.0 License, which is shown below: + + + +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/www/vicidial/AST_rt_whiteboard_rpt_mobile.php b/www/vicidial/AST_rt_whiteboard_rpt_mobile.php new file mode 100644 index 00000000..f9fb80dc --- /dev/null +++ b/www/vicidial/AST_rt_whiteboard_rpt_mobile.php @@ -0,0 +1,872 @@ +, Joe Johnson LICENSE: AGPLv2 +# +# Mobile version of real-time report that allows users to create a customized, graphical display of various data sets +# +# 190227-1259 - Initial build +# + +$startMS = microtime(); + +require("dbconnect_mysqli.php"); +require("functions.php"); + +if (file_exists('options.php')) + { + require('options.php'); + } + +$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER']; +$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW']; +$PHP_SELF=$_SERVER['PHP_SELF']; +if (isset($_GET["query_date"])) {$query_date=$_GET["query_date"];} + elseif (isset($_POST["query_date"])) {$query_date=$_POST["query_date"];} +if (isset($_GET["end_date"])) {$end_date=$_GET["end_date"];} + elseif (isset($_POST["end_date"])) {$end_date=$_POST["end_date"];} +if (isset($_GET["query_time"])) {$query_time=$_GET["query_time"];} + elseif (isset($_POST["query_time"])) {$query_time=$_POST["query_time"];} +if (isset($_GET["end_time"])) {$end_time=$_GET["end_time"];} + elseif (isset($_POST["end_time"])) {$end_time=$_POST["end_time"];} +if (isset($_GET["campaigns"])) {$campaigns=$_GET["campaigns"];} + elseif (isset($_POST["campaigns"])) {$campaigns=$_POST["campaigns"];} +if (isset($_GET["users"])) {$users=$_GET["users"];} + elseif (isset($_POST["users"])) {$users=$_POST["users"];} +if (isset($_GET["user_groups"])) {$user_groups=$_GET["user_groups"];} + elseif (isset($_POST["user_groups"])) {$user_groups=$_POST["user_groups"];} +if (isset($_GET["groups"])) {$groups=$_GET["groups"];} + elseif (isset($_POST["groups"])) {$groups=$_POST["groups"];} +if (isset($_GET["dids"])) {$dids=$_GET["dids"];} + elseif (isset($_POST["dids"])) {$dids=$_POST["dids"];} +if (isset($_GET["file_download"])) {$file_download=$_GET["file_download"];} + elseif (isset($_POST["file_download"])) {$file_download=$_POST["file_download"];} +if (isset($_GET["submit"])) {$submit=$_GET["submit"];} + elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];} +if (isset($_GET["SUBMIT"])) {$SUBMIT=$_GET["SUBMIT"];} + elseif (isset($_POST["SUBMIT"])) {$SUBMIT=$_POST["SUBMIT"];} +if (isset($_GET["DB"])) {$DB=$_GET["DB"];} + elseif (isset($_POST["DB"])) {$DB=$_POST["DB"];} +if (isset($_GET["report_display_type"])) {$report_display_type=$_GET["report_display_type"];} + elseif (isset($_POST["report_display_type"])) {$report_display_type=$_POST["report_display_type"];} + +if (!$query_date) {$query_date=date("Y-m-d");} +if (!$end_date) {$end_date=date("Y-m-d");} +if (!$query_time) {$query_time="08:00:00";} +if (!$end_time) {$end_time="17:00:00";} + +if (strlen($shift)<2) {$shift='ALL';} +$report_name="Real-Time Whiteboard Report"; + +############################################# +##### START SYSTEM_SETTINGS LOOKUP ##### +$stmt = "SELECT use_non_latin,outbound_autodial_active,slave_db_server,reports_use_slave_db,enable_languages,language_method,admin_screen_colors FROM system_settings;"; +$rslt=mysql_to_mysqli($stmt, $link); +if ($DB) {$MAIN.="$stmt\n";} +$qm_conf_ct = mysqli_num_rows($rslt); +if ($qm_conf_ct > 0) + { + $row=mysqli_fetch_row($rslt); + $non_latin = $row[0]; + $outbound_autodial_active = $row[1]; + $slave_db_server = $row[2]; + $reports_use_slave_db = $row[3]; + $SSenable_languages = $row[4]; + $SSlanguage_method = $row[5]; + $admin_screen_colors = $row[6]; + } +##### END SETTINGS LOOKUP ##### +########################################### + +if ( (strlen($slave_db_server)>5) and (preg_match("/$report_name/",$reports_use_slave_db)) ) + { + mysqli_close($link); + $use_slave_server=1; + $db_source = 'S'; + require("dbconnect_mysqli.php"); + $MAIN.="\n"; + } + +$stmt = "SELECT local_gmt FROM servers where active='Y' limit 1;"; +$rslt=mysql_to_mysqli($stmt, $link); +if ($DB) {$MAIN.="$stmt\n";} +$gmt_conf_ct = mysqli_num_rows($rslt); +$dst = date("I"); +if ($gmt_conf_ct > 0) + { + $row=mysqli_fetch_row($rslt); + $local_gmt = $row[0]; + $epoch_offset = (($local_gmt + $dst) * 3600); + } + +if ($non_latin < 1) + { + $PHP_AUTH_USER = preg_replace('/[^-_0-9a-zA-Z]/', '', $PHP_AUTH_USER); + $PHP_AUTH_PW = preg_replace('/[^-_0-9a-zA-Z]/', '', $PHP_AUTH_PW); + } +else + { + $PHP_AUTH_PW = preg_replace("/'|\"|\\\\|;/","",$PHP_AUTH_PW); + $PHP_AUTH_USER = preg_replace("/'|\"|\\\\|;/","",$PHP_AUTH_USER); + } + +$stmt="SELECT selected_language from vicidial_users where user='$PHP_AUTH_USER';"; +if ($DB) {echo "|$stmt|\n";} +$rslt=mysql_to_mysqli($stmt, $link); +$sl_ct = mysqli_num_rows($rslt); +if ($sl_ct > 0) + { + $row=mysqli_fetch_row($rslt); + $VUselected_language = $row[0]; + } + +$auth=0; +$reports_auth=0; +$admin_auth=0; +$auth_message = user_authorization($PHP_AUTH_USER,$PHP_AUTH_PW,'REPORTS',1); +if ($auth_message == 'GOOD') + {$auth=1;} + +if ($auth > 0) + { + $stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and user_level > 7 and view_reports='1';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_to_mysqli($stmt, $link); + $row=mysqli_fetch_row($rslt); + $admin_auth=$row[0]; + + $stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and user_level > 6 and view_reports='1';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_to_mysqli($stmt, $link); + $row=mysqli_fetch_row($rslt); + $reports_auth=$row[0]; + + if ($reports_auth < 1) + { + $VDdisplayMESSAGE = _QXZ("You are not allowed to view reports"); + Header ("Content-type: text/html; charset=utf-8"); + echo "$VDdisplayMESSAGE: |$PHP_AUTH_USER|$auth_message|\n"; + exit; + } + if ( ($reports_auth > 0) and ($admin_auth < 1) ) + { + $ADD=999999; + $reports_only_user=1; + } + } +else + { + $VDdisplayMESSAGE = _QXZ("Login incorrect, please try again"); + if ($auth_message == 'LOCK') + { + $VDdisplayMESSAGE = _QXZ("Too many login attempts, try again in 15 minutes"); + Header ("Content-type: text/html; charset=utf-8"); + echo "$VDdisplayMESSAGE: |$PHP_AUTH_USER|$auth_message|\n"; + exit; + } + Header("WWW-Authenticate: Basic realm=\"CONTACT-CENTER-ADMIN\""); + Header("HTTP/1.0 401 Unauthorized"); + echo "$VDdisplayMESSAGE: |$PHP_AUTH_USER|$PHP_AUTH_PW|$auth_message|\n"; + exit; + } + +$stmt="SELECT user_group from vicidial_users where user='$PHP_AUTH_USER';"; +if ($DB) {$MAIN.="|$stmt|\n";} +$rslt=mysql_to_mysqli($stmt, $link); +$row=mysqli_fetch_row($rslt); +$LOGuser_group = $row[0]; + +$stmt="SELECT allowed_campaigns,allowed_reports,admin_viewable_groups,admin_viewable_call_times from vicidial_user_groups where user_group='$LOGuser_group';"; +if ($DB) {$MAIN.="|$stmt|\n";} +$rslt=mysql_to_mysqli($stmt, $link); +$row=mysqli_fetch_row($rslt); +$LOGallowed_campaigns = $row[0]; +$LOGallowed_reports = $row[1]; +$LOGadmin_viewable_groups = $row[2]; +$LOGadmin_viewable_call_times = $row[3]; + +if ( (!preg_match("/$report_name,/",$LOGallowed_reports)) and (!preg_match("/ALL REPORTS/",$LOGallowed_reports)) ) + { + Header("WWW-Authenticate: Basic realm=\"CONTACT-CENTER-ADMIN\""); + Header("HTTP/1.0 401 Unauthorized"); + echo _QXZ("You are not allowed to view this report").": |$PHP_AUTH_USER|$report_name|\n"; + exit; + } + +$LOGadmin_viewable_groupsSQL=''; +$whereLOGadmin_viewable_groupsSQL=''; +if ( (!preg_match('/\-\-ALL\-\-/i',$LOGadmin_viewable_groups)) and (strlen($LOGadmin_viewable_groups) > 3) ) + { + $rawLOGadmin_viewable_groupsSQL = preg_replace("/ -/",'',$LOGadmin_viewable_groups); + $rawLOGadmin_viewable_groupsSQL = preg_replace("/ /","','",$rawLOGadmin_viewable_groupsSQL); + $LOGadmin_viewable_groupsSQL = "and user_group IN('---ALL---','$rawLOGadmin_viewable_groupsSQL')"; + $whereLOGadmin_viewable_groupsSQL = "where user_group IN('---ALL---','$rawLOGadmin_viewable_groupsSQL')"; + } + +$LOGadmin_viewable_call_timesSQL=''; +$whereLOGadmin_viewable_call_timesSQL=''; +if ( (!preg_match('/\-\-ALL\-\-/i', $LOGadmin_viewable_call_times)) and (strlen($LOGadmin_viewable_call_times) > 3) ) + { + $rawLOGadmin_viewable_call_timesSQL = preg_replace("/ -/",'',$LOGadmin_viewable_call_times); + $rawLOGadmin_viewable_call_timesSQL = preg_replace("/ /","','",$rawLOGadmin_viewable_call_timesSQL); + $LOGadmin_viewable_call_timesSQL = "and call_time_id IN('---ALL---','$rawLOGadmin_viewable_call_timesSQL')"; + $whereLOGadmin_viewable_call_timesSQL = "where call_time_id IN('---ALL---','$rawLOGadmin_viewable_call_timesSQL')"; + } + +$NOW_DATE = date("Y-m-d"); +$NOW_TIME = date("Y-m-d H:i:s"); +$STARTtime = date("U"); +if (!isset($groups)) {$groups = array();} +if (!isset($query_date)) {$query_date = $NOW_DATE;} +if (!isset($end_date)) {$end_date = $NOW_DATE;} + +$stmt="SELECT user_group from vicidial_users where user='$PHP_AUTH_USER';"; +if ($DB) {$MAIN.="|$stmt|\n";} +$rslt=mysql_to_mysqli($stmt, $link); +$row=mysqli_fetch_row($rslt); +$LOGuser_group = $row[0]; + +$stmt="SELECT allowed_campaigns,allowed_reports,admin_viewable_groups,admin_viewable_call_times from vicidial_user_groups where user_group='$LOGuser_group';"; +if ($DB) {$MAIN.="|$stmt|\n";} +$rslt=mysql_to_mysqli($stmt, $link); +$row=mysqli_fetch_row($rslt); +$LOGallowed_campaigns = $row[0]; +$LOGallowed_reports = $row[1]; +$LOGadmin_viewable_groups = $row[2]; +$LOGadmin_viewable_call_times = $row[3]; + +if ( (!preg_match("/$report_name/",$LOGallowed_reports)) and (!preg_match("/ALL REPORTS/",$LOGallowed_reports)) ) + { + Header("WWW-Authenticate: Basic realm=\"CONTACT-CENTER-ADMIN\""); + Header("HTTP/1.0 401 Unauthorized"); + echo _QXZ("You are not allowed to view this report").": |$PHP_AUTH_USER|$report_name|\n"; + exit; + } + +$stmt="SELECT campaign_id from vicidial_campaigns $whereLOGallowed_campaignsSQL order by campaign_id;"; +if ($DB) {$MAIN.="$stmt\n";} +$rslt=mysql_to_mysqli($stmt, $link); +$campaigns_to_print = mysqli_num_rows($rslt); +$i=0; +$campaign_string='|'; +$campaigns_selected=count($campaigns); +while ($i < $campaigns_to_print) + { + $row=mysqli_fetch_row($rslt); + $campaign_list[$i] = $row[0]; + $campaign_string .= "$campaign_list[$i]|"; + for ($j=0; $j<$campaigns_selected; $j++) { + if ($campaigns[$j] && $campaign_list[$i]==$campaigns[$j]) {$campaign_name_str.="$campaign_list[$i] - $campaign_names[$i], ";} + if ($campaigns[$j]=="--ALL--") {$campaigns_selected_str.="'$campaign_list[$i]', ";} + } + $i++; + } + + +$i=0; +$users_string='|'; +$users_ct = count($users); +while($i < $users_ct) + { + $users_string .= "$users[$i]|"; + $i++; + } +$stmt="SELECT user, full_name from vicidial_users $whereLOGadmin_viewable_groupsSQL order by user"; +$rslt=mysql_to_mysqli($stmt, $link); +if ($DB) {$MAIN.="$stmt\n";} +$users_to_print = mysqli_num_rows($rslt); +$i=0; +$user_array=array(); # For quick full-name reference +while ($i < $users_to_print) + { + $row=mysqli_fetch_row($rslt); + $user_list[$i]=$row[0]; + $user_names[$i]=$row[1]; + $user_array["$row[0]"]=$row[1]; + $i++; + } + + +$i=0; +$user_groups_string='|'; +$user_groups_ct = count($user_groups); +while($i < $user_groups_ct) + { + $user_groups_string .= "$user_groups[$i]|"; + $i++; + } +$stmt="SELECT user_group, group_name from vicidial_user_groups $whereLOGadmin_viewable_groupsSQL order by user_group"; +$rslt=mysql_to_mysqli($stmt, $link); +if ($DB) {$MAIN.="$stmt\n";} +$user_groups_to_print = mysqli_num_rows($rslt); +$i=0; +$user_group_array=array(); # For quick full-name reference +while ($i < $user_groups_to_print) + { + $row=mysqli_fetch_row($rslt); + $user_group_list[$i]=$row[0]; + $user_group_names[$i]=$row[1]; + $user_group_array["$row[0]"]=$row[1]; + $i++; + } + + +$stmt="SELECT group_id,group_name from vicidial_inbound_groups $whereLOGadmin_viewable_groupsSQL order by group_id;"; +$rslt=mysql_to_mysqli($stmt, $link); +if ($DB) {$MAIN.="$stmt\n";} +$groups_to_print = mysqli_num_rows($rslt); +$i=0; +#$LISTgroups[$i]='---NONE---'; +#$i++; +# $groups_to_print++; +$groups_string='|'; +while ($i < $groups_to_print) + { + $row=mysqli_fetch_row($rslt); + $LISTgroups[$i] = $row[0]; + $LISTgroup_names[$i] = $row[1]; + $LISTgroup_ids[$i] = $row[2]; + $groups_string .= "$LISTgroups[$i]|"; + $i++; + } + + +$i=0; +$group_string='|'; +$group_ct = count($groups); +while($i < $group_ct) + { + if ( (strlen($groups[$i]) > 0) and (preg_match("/\|$groups[$i]\|/",$groups_string)) ) + { + $group_string .= "$groups[$i]|"; + $group_SQL .= "'$groups[$i]',"; + $groupQS .= "&groups[]=$groups[$i]"; + } + $i++; + } +if ( (preg_match('/\s\-\-NONE\-\-\s/',$group_string) ) or ($group_ct < 1) ) + { + $group_SQL = "''"; + } +else + { + $group_SQL = preg_replace('/,$/i', '',$group_SQL); + } +if (strlen($group_SQL)<3) {$group_SQL="''";} + + +$i=0; +$dids_string='|'; +$dids_ct = count($dids); +while($i < $dids_ct) + { + $dids_string .= "$dids[$i]|"; + $i++; + } +$stmt="SELECT did_pattern,did_description,did_id from vicidial_inbound_dids $whereLOGadmin_viewable_groupsSQL order by did_pattern;"; +$rslt=mysql_to_mysqli($stmt, $link); +if ($DB) {$MAIN.="$stmt\n";} +$dids_to_print = mysqli_num_rows($rslt); +$i=0; +$did_array=array(); # For quick full-name reference +while ($i < $dids_to_print) + { + $row=mysqli_fetch_row($rslt); + $did_pattern[$i]=$row[0]; + $did_description[$i]=$row[1]; + $did_ids[$i]=$row[2]; + $did_array["$row[0]"]=$row[1]; + $i++; + } + + + +$MT[0]=''; +$NOW_DATE = date("Y-m-d"); +$NOW_TIME = date("Y-m-d H:i:s"); +$STARTtime = date("U"); +if (!isset($campaigns)) {$campaign = array();} +if (!isset($users)) {$users = array();} +if (!isset($user_groups)) {$user_groups = array();} +if (!isset($dids)) {$dids = array();} +if (!isset($groups)) {$groups = array();} +if (!isset($report_display_type)) {$report_display_type = "HTML";} +if (!isset($query_date)) {$query_date = $NOW_DATE;} +if (!isset($end_date)) {$end_date = $NOW_DATE;} + +$i=0; +$campaigns_string='|'; +$campaign_ct = count($campaigns); +while($i < $campaign_ct) + { + if (in_array("--ALL--", $campaigns)) + { + $campaigns_string = "--ALL--"; + $campaign_SQL .= "'$campaigns[$i]',"; + $campaignQS = "&campaign[]=--ALL--"; + } + else if ( (strlen($campaigns[$i]) > 0) and (!preg_match("/\|$campaigns[$i]\|/",$campaigns_string)) ) + { + $campaigns_string .= "$campaigns[$i]|"; + $campaign_SQL .= "'$campaigns[$i]',"; + $campaignQS .= "&campaigns[]=$campaigns[$i]"; + } + $i++; + } +if ( (preg_match('/\-\-ALL\-\-/',$campaign_string) ) or ($campaign_ct < 1) ) + { + $campaign_SQL = ""; + } +else + { + $campaign_SQL = preg_replace('/,$/i', '',$campaign_SQL); + $WHEREcampaign_SQL=" where campaign_id in ($campaign_SQL) "; + $campaign_SQL=" and campaign_id in ($campaign_SQL) "; + } +if (strlen($campaign_SQL)<3) + { + $campaign_SQL=""; + } + +$i=0; +$users_string='|'; +$user_ct = count($users); +while($i < $user_ct) + { + if (in_array("--ALL--", $users)) + { + $users_string = "--ALL--"; + $user_SQL .= "'$users[$i]',"; + $userQS = "&users[]=--ALL--"; + } + else if ( (strlen($users[$i]) > 0) and (!preg_match("/\|$users[$i]\|/",$users_string)) ) + { + $users_string .= "$users[$i]|"; + $user_SQL .= "'$users[$i]',"; + $userQS .= "&users[]=$users[$i]"; + } + $i++; + } +if ( (preg_match('/\-\-ALL\-\-/',$users_string) ) or ($user_ct < 1) ) + { + $user_SQL = ""; + } +else + { + $user_SQL = preg_replace('/,$/i', '',$user_SQL); + $user_SQL = "and agent_user IN($user_SQL)"; + } +if (strlen($user_SQL)<3) {$user_SQL="";} + +$i=0; +$user_groups_string='|'; +$user_group_ct = count($user_groups); +while($i < $user_group_ct) + { + if (in_array("--ALL--", $user_groups)) + { + $user_groups_string = "--ALL--"; + $user_group_SQL .= "'$user_groups[$i]',"; + $user_groupQS = "&users[]=--ALL--"; + } + else if ( (strlen($user_groups[$i]) > 0) and (!preg_match("/\|$user_groups[$i]\|/",$user_groups_string)) ) + { + $user_groups_string .= "$user_groups[$i]|"; + $user_group_SQL .= "'$user_groups[$i]',"; + $user_groupQS .= "&users[]=$user_groups[$i]"; + } + $i++; + } +if ( (preg_match('/\-\-ALL\-\-/',$user_groups_string) ) or ($user_group_ct < 1) ) + { + $user_group_SQL = ""; + } +else + { + $user_group_SQL = preg_replace('/,$/i', '',$user_group_SQL); + $user_group_SQL = "and user_group IN($user_group_SQL)"; + } +if (strlen($user_group_SQL)<3) {$user_group_SQL="";} + +$i=0; +$groups_string='|'; +$group_ct = count($groups); +while($i < $group_ct) + { + if (in_array("--ALL--", $groups)) + { + $groups_string = "--ALL--"; + $group_SQL .= "'$groups[$i]',"; + $groupQS = "&users[]=--ALL--"; + } + else if ( (strlen($groups[$i]) > 0) and (!preg_match("/\|$groups[$i]\|/",$groups_string)) ) + { + $groups_string .= "$groups[$i]|"; + $group_SQL .= "'$groups[$i]',"; + $groupQS .= "&users[]=$groups[$i]"; + } + $i++; + } +if ( (preg_match('/\-\-ALL\-\-/',$groups_string) ) or ($group_ct < 1) ) + { + $group_SQL = ""; + } +else + { + $group_SQL = preg_replace('/,$/i', '',$group_SQL); + $group_SQL = "and agent_user IN($group_SQL)"; + } +if (strlen($group_SQL)<3) {$group_SQL="";} + + + +##### BEGIN Define colors and logo ##### +$SSmenu_background='015B91'; +$SSframe_background='D9E6FE'; +$SSstd_row1_background='9BB9FB'; +$SSstd_row2_background='B9CBFD'; +$SSstd_row3_background='8EBCFD'; +$SSstd_row4_background='B6D3FC'; +$SSstd_row5_background='FFFFFF'; +$SSalt_row1_background='BDFFBD'; +$SSalt_row2_background='99FF99'; +$SSalt_row3_background='CCFFCC'; + +if ($admin_screen_colors != 'default') + { + $asc_stmt = "SELECT menu_background,frame_background,std_row1_background,std_row2_background,std_row3_background,std_row4_background,std_row5_background,alt_row1_background,alt_row2_background,alt_row3_background,web_logo FROM vicidial_screen_colors where colors_id='$admin_screen_colors';"; + $asc_rslt=mysql_to_mysqli($asc_stmt, $link); + $qm_conf_ct = mysqli_num_rows($rslt); + if ($qm_conf_ct > 0) + { + $asc_row=mysqli_fetch_row($asc_rslt); + $SSmenu_background = $asc_row[0]; + $SSframe_background = $asc_row[1]; + $SSstd_row1_background = $asc_row[2]; + $SSstd_row2_background = $asc_row[3]; + $SSstd_row3_background = $asc_row[4]; + $SSstd_row4_background = $asc_row[5]; + $SSstd_row5_background = $asc_row[6]; + $SSalt_row1_background = $asc_row[7]; + $SSalt_row2_background = $asc_row[8]; + $SSalt_row3_background = $asc_row[9]; + $SSweb_logo = $asc_row[10]; + } + } + + + +# $NWB = "   \"HELP\""; + +$NWB = "\"HELP\""; + +$rerun_rpt_URL="$PHP_SELF?query_date=$query_date&end_date=$end_date&report_display_type=$report_display_type$campaignQS$userQS$managerQS&SUBMIT=$SUBMIT"; + +$HEADER.="\n"; +$HEADER.="\n"; + +$HEADER.="\n"; +$HEADER.="\n"; +$HEADER.=""; + +$HEADER.="\n"; +$HEADER.="\n"; +$HEADER.="\n"; +# $HEADER.="\n"; +$HEADER.="\n"; +$HEADER.="\n"; +$HEADER.="\n"; +$HEADER.=""._QXZ("$report_name")."\n"; + +$MAIN.="
\n"; +$MAIN.=""._QXZ("$report_name")." $NWB#rt_whiteboard_report$NWE\n"; + +$MAIN.=""; +$MAIN.=""; +$MAIN.="\n"; +$MAIN.="\n"; + +$MAIN.="\n"; + +$MAIN.="\n"; +$MAIN.="\n"; + +/* +$MAIN.=""; + +$MAIN.="\n"; +*/ + +$MAIN.=""; + +$MAIN.="\n"; + +$MAIN.="\n"; +$MAIN.=""; + +$MAIN.=""; +$MAIN.="\n"; + +$MAIN.="\n"; +$MAIN.="\n"; + +$MAIN.="\n"; +$MAIN.="\n"; + +$MAIN.="\n"; +$MAIN.="\n"; + +$MAIN.=""; +$MAIN.=""; +# $MAIN.=""; +$MAIN.="
"._QXZ("Report Type").": $NWB#rt_whiteboard_report-report_type$NWE"; +$MAIN.="\n"; +$MAIN.="
"._QXZ("Campaigns").": $NWB#rt_whiteboard_report-parameters$NWE
"; +$MAIN.="\n"; +$MAIN.="
"; +$MAIN.=""._QXZ("Status flags").": $NWB#rt_whiteboard_report-parameters$NWE
"; +$MAIN.="\n"; +$MAIN.="
"._QXZ("In-groups").": $NWB#rt_whiteboard_report-parameters$NWE
"; +$MAIN.="\n"; +$MAIN.="
"._QXZ("DIDs").": $NWB#rt_whiteboard_report-parameters$NWE
"; +$MAIN.="\n"; +$MAIN.="
"._QXZ("User Groups").": $NWB#rt_whiteboard_report-parameters$NWE
"; +$MAIN.="\n"; +$MAIN.="
"._QXZ("Users").": $NWB#rt_whiteboard_report-parameters$NWE
"; +$MAIN.="\n"; +$MAIN.="
"._QXZ("Start date/time").":"; +$MAIN.="
\n"; +$MAIN.=""; + +$MAIN.="\n"; + +$MAIN.="   $NWB#rt_whiteboard_report-start_date$NWE"; + +$MAIN.="
"._QXZ("OR")."
"; +$MAIN.=""._QXZ("Results for the past")." "._QXZ("hours")." $NWB#rt_whiteboard_report-show_results$NWE"; +$MAIN.="
"; +$MAIN.=""; +$MAIN.=""; +$MAIN.=""; +$MAIN.=""; +$MAIN.=""; +$MAIN.=""; +$MAIN.=""; +$MAIN.="
"._QXZ("Target per unit").": $NWB#rt_whiteboard_report-target_per_unit$NWE
"._QXZ("Target gross sales").": $NWB#rt_whiteboard_report-target_gross_sales$NWE
"; +$MAIN.="
\n"; + + +######################## + + +$MAIN.=""; +$MAIN.=""; +$MAIN.=""; +$MAIN.=""; +$MAIN.="
"; + + +$MAIN.=""; +$MAIN.="\n"; +$MAIN.=""; + +header("Content-type: text/html; charset=utf-8"); + +echo "$HEADER"; +$android_header=1; +require("admin_header.php"); +echo "$MAIN"; +flush(); + +?> diff --git a/www/vicidial/AST_timeonVDADall.php b/www/vicidial/AST_timeonVDADall.php index 48a2a95c..97ce0f40 100644 --- a/www/vicidial/AST_timeonVDADall.php +++ b/www/vicidial/AST_timeonVDADall.php @@ -1,7 +1,7 @@ LICENSE: AGPLv2 +# Copyright (C) 2019 Matt Florell LICENSE: AGPLv2 # # live real-time stats for the VICIDIAL Auto-Dialer all servers # @@ -108,6 +108,7 @@ # 170409-1556 - Added IP List validation code # 170615-0023 - Added DIAL status for manual dial agent calls that have not been answered # 180204-1538 - Added display of LIVE Inbound Callback Queue Calls +# 190206-1616 - Added mobile device display variable # $version = '2.14-96'; @@ -191,6 +192,8 @@ if (isset($_GET["droppedOFtotal"])) {$droppedOFtotal=$_GET["droppedOFtotal"]; elseif (isset($_POST["droppedOFtotal"])) {$droppedOFtotal=$_POST["droppedOFtotal"];} if (isset($_GET["report_display_type"])) {$report_display_type=$_GET["report_display_type"];} elseif (isset($_POST["report_display_type"])) {$report_display_type=$_POST["report_display_type"];} +if (isset($_GET["mobile_device"])) {$mobile_device=$_GET["mobile_device"];} + elseif (isset($_POST["mobile_device"])) {$mobile_device=$_POST["mobile_device"];} $report_name = 'Real-Time Main Report'; @@ -653,7 +656,7 @@ $NFB = ''; $NFE = ''; $F=''; $FG=''; $B=''; $BG=''; -$select_list = "
"._QXZ("Select Campaigns").":
"; +$select_list = "
"._QXZ("Select Campaigns").":
"; $select_list .= ""; echo ""; @@ -1906,7 +1909,7 @@ else $agentsONEMIN = sprintf("%01.2f", $agentsONEMIN); $diffONEMIN = sprintf("%01.2f", $diffONEMIN); - if ( ($report_display_type!='WALL_1') and ($report_display_type!='WALL_2') and ($report_display_type!='WALL_3') and ($report_display_type!='WALL_4') ) + if ( ($report_display_type!='WALL_1') and ($report_display_type!='WALL_2') and ($report_display_type!='WALL_3') and ($report_display_type!='WALL_4') and !$mobile_device) { echo "
"._QXZ("CALLS TODAY").":  $callsTODAY   
"; echo ""; @@ -2014,31 +2017,38 @@ else if ( ($report_display_type!='WALL_1') and ($report_display_type!='WALL_2') and ($report_display_type!='WALL_3') and ($report_display_type!='WALL_4') ) { - echo ""; - echo ""; - echo ""; + + if (!$mobile_device) + { + echo ""; + echo ""; + echo ""; + } echo "\n"; +echo "
"._QXZ("DIAL LEVEL").":  $DIALlev   
"; - if ( (!preg_match('/NULL/i',$VSCcat1)) and (strlen($VSCcat1)>0) ) - {echo "$VSCcat1:   $VSCcat1tally       \n";} - if ( (!preg_match('/NULL/i',$VSCcat2)) and (strlen($VSCcat2)>0) ) - {echo "$VSCcat2:   $VSCcat2tally       \n";} - if ( (!preg_match('/NULL/i',$VSCcat3)) and (strlen($VSCcat3)>0) ) - {echo "$VSCcat3:   $VSCcat3tally       \n";} - if ( (!preg_match('/NULL/i',$VSCcat4)) and (strlen($VSCcat4)>0) ) - {echo "$VSCcat4:   $VSCcat4tally       \n";} - echo "
"; + if ( (!preg_match('/NULL/i',$VSCcat1)) and (strlen($VSCcat1)>0) ) + {echo "$VSCcat1:   $VSCcat1tally       \n";} + if ( (!preg_match('/NULL/i',$VSCcat2)) and (strlen($VSCcat2)>0) ) + {echo "$VSCcat2:   $VSCcat2tally       \n";} + if ( (!preg_match('/NULL/i',$VSCcat3)) and (strlen($VSCcat3)>0) ) + {echo "$VSCcat3:   $VSCcat3tally       \n";} + if ( (!preg_match('/NULL/i',$VSCcat4)) and (strlen($VSCcat4)>0) ) + {echo "$VSCcat4:   $VSCcat4tally       \n";} + echo "
"; echo "$ingroup_detail"; if ($RTajax < 1) { - if ($adastats<2) + if (!$mobile_device) { - echo "+ "._QXZ("VIEW MORE").""; - } - else - { - echo "- "._QXZ("VIEW LESS").""; + if ($adastats<2) + { + echo "+ "._QXZ("VIEW MORE").""; + } + else + { + echo "- "._QXZ("VIEW LESS").""; + } } if ($UGdisplay>0) { @@ -2117,7 +2127,7 @@ if ( ($with_inbound != 'O') and ($NOLEADSalert == 'YES') ) if ($ctp > 0) { echo "\n"; - echo "
\n"; + echo "\n"; - echo "\n"; + echo "\n"; echo "\n"; - echo "
\n"; echo "



"._QXZ("Close Alert").""; echo "




"._QXZ("Campaigns with no dialable leads").":

$NDLcampaigns
"; echo "










  "; @@ -2386,45 +2396,45 @@ if ( ($report_display_type=='HTML') or ($report_display_type=='WALL_2') ) $section_width=860; echo ""; - echo "\n"; + echo "
\n"; echo ""; # echo ""; - echo ""; + echo ""; if ($campaign_allow_inbound > 0) { - echo ""; + echo ""; } else { - echo ""; + echo ""; } echo ""; - echo ""; - echo ""; + echo ""; + echo ""; echo ""; - echo ""; - echo ""; + echo ""; + echo ""; echo ""; - echo ""; - echo ""; + echo ""; + echo ""; echo ""; if ($allow_chats) { - echo ""; - echo ""; + echo ""; + echo ""; } else { echo ""; - echo ""; + echo ""; } # echo ""; echo ""; - echo ""; - echo ""; + echo ""; + echo ""; echo ""; echo ""; @@ -2530,7 +2540,7 @@ while($p<$k) } else { - $Cecho .= ""; + $Cecho .= ""; $Cecho .= ""; $Cecho .= ""; $Cecho .= ""; @@ -2597,7 +2607,7 @@ if ($report_display_type=='TEXT') if ($report_display_type=='HTML') { $Aecho = ''; - $Aecho .= "
  "._QXZ("current active calls").""._QXZ("current active calls").""._QXZ("calls being placed").""._QXZ("calls being placed")."   "._QXZ("calls ringing").""._QXZ("calls ringing")."   "._QXZ("calls waiting for agents").""._QXZ("calls waiting for agents")."   "._QXZ("calls in IVR").""._QXZ("calls in IVR")."   "._QXZ("chats waiting for agents").""._QXZ("chats waiting for agents")."       "._QXZ("callback queue calls").""._QXZ("callback queue calls")."
$G$Cstatus$EG$G$Ccampaign_id$EG$G$Cphone_number$EG
"; + $Aecho .= "
"; $Aecho .= ""; $Aecho .= ""; $Aecho .= ""; @@ -3552,23 +3562,23 @@ if ( ($report_display_type=='HTML') or ($report_display_type=='WALL_2') ) # echo "
 "._QXZ("Agents Time On Calls Campaign").": 
\n"; echo ""; # echo ""; - echo ""; - echo ""; + echo ""; + echo ""; echo ""; - echo ""; - echo ""; + echo ""; + echo ""; echo ""; - echo ""; - echo ""; + echo ""; + echo ""; echo ""; - echo ""; - echo ""; + echo ""; + echo ""; echo ""; - echo ""; - echo ""; + echo ""; + echo ""; echo ""; - echo ""; - echo ""; + echo ""; + echo ""; echo ""; echo ""; echo ""; diff --git a/www/vicidial/AST_timeonVDADallSUMMARY_mobile.php b/www/vicidial/AST_timeonVDADallSUMMARY_mobile.php new file mode 100644 index 00000000..3f251033 --- /dev/null +++ b/www/vicidial/AST_timeonVDADallSUMMARY_mobile.php @@ -0,0 +1,1726 @@ +, Joe Johnson LICENSE: AGPLv2 +# +# Mobile version of summary report for all campaigns live real-time stats for the VICIDIAL Auto-Dialer all servers +# +# STOP=4000, SLOW=40, GO=4 seconds refresh interval +# +# changes: +# +# 190129-1258 - First release +# + +require("dbconnect_mysqli.php"); +require("functions.php"); + +$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER']; +$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW']; +$PHP_SELF=$_SERVER['PHP_SELF']; +if (isset($_GET["RR"])) {$RR=$_GET["RR"];} + elseif (isset($_POST["RR"])) {$RR=$_POST["RR"];} +if (isset($_GET["DB"])) {$DB=$_GET["DB"];} + elseif (isset($_POST["DB"])) {$DB=$_POST["DB"];} +if (isset($_GET["adastats"])) {$adastats=$_GET["adastats"];} + elseif (isset($_POST["adastats"])) {$adastats=$_POST["adastats"];} +if (isset($_GET["types"])) {$types=$_GET["types"];} + elseif (isset($_POST["types"])) {$types=$_POST["types"];} +if (isset($_GET["current_displayed_report"])) {$current_displayed_report=$_GET["current_displayed_report"];} + elseif (isset($_POST["current_displayed_report"])) {$current_displayed_report=$_POST["current_displayed_report"];} +if (isset($_GET["submit"])) {$submit=$_GET["submit"];} + elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];} +if (isset($_GET["SUBMIT"])) {$SUBMIT=$_GET["SUBMIT"];} + elseif (isset($_POST["SUBMIT"])) {$SUBMIT=$_POST["SUBMIT"];} +if (isset($_GET["file_download"])) {$file_download=$_GET["file_download"];} + elseif (isset($_POST["file_download"])) {$file_download=$_POST["file_download"];} +if (isset($_GET["browser_dimension"])) {$browser_dimension=$_GET["browser_dimension"];} + elseif (isset($_POST["browser_dimension"])) {$browser_dimension=$_POST["browser_dimension"];} + +if (!isset($RR)) {$RR=4000;} +if (!isset($browser_dimension)) {$browser_dimension=800;} +if (!isset($types)) {$types='LIST ALL CAMPAIGNS';} +$cell_dimension=floor($browser_dimension/10); + +$report_name = 'Real-Time Campaign Summary'; +$db_source = 'M'; + +############################################# +##### START SYSTEM_SETTINGS LOOKUP ##### +$stmt = "SELECT use_non_latin,outbound_autodial_active,slave_db_server,reports_use_slave_db,enable_languages,language_method FROM system_settings;"; +$rslt=mysql_to_mysqli($stmt, $link); +if ($DB) {$MAIN.="$stmt\n";} +$qm_conf_ct = mysqli_num_rows($rslt); +if ($qm_conf_ct > 0) + { + $row=mysqli_fetch_row($rslt); + $non_latin = $row[0]; + $outbound_autodial_active = $row[1]; + $slave_db_server = $row[2]; + $reports_use_slave_db = $row[3]; + $SSenable_languages = $row[4]; + $SSlanguage_method = $row[5]; + } +##### END SETTINGS LOOKUP ##### +########################################### + +if ( (strlen($slave_db_server)>5) and (preg_match("/$report_name/",$reports_use_slave_db)) ) + { + mysqli_close($link); + $use_slave_server=1; + $db_source = 'S'; + require("dbconnect_mysqli.php"); + $MAIN.="\n"; + } + +if ($non_latin < 1) + { + $PHP_AUTH_USER = preg_replace('/[^-_0-9a-zA-Z]/', '', $PHP_AUTH_USER); + $PHP_AUTH_PW = preg_replace('/[^-_0-9a-zA-Z]/', '', $PHP_AUTH_PW); + } +else + { + $PHP_AUTH_PW = preg_replace("/'|\"|\\\\|;/","",$PHP_AUTH_PW); + $PHP_AUTH_USER = preg_replace("/'|\"|\\\\|;/","",$PHP_AUTH_USER); + } + +$stmt="SELECT selected_language from vicidial_users where user='$PHP_AUTH_USER';"; +if ($DB) {echo "|$stmt|\n";} +$rslt=mysql_to_mysqli($stmt, $link); +$sl_ct = mysqli_num_rows($rslt); +if ($sl_ct > 0) + { + $row=mysqli_fetch_row($rslt); + $VUselected_language = $row[0]; + } + +$auth=0; +$reports_auth=0; +$admin_auth=0; +$auth_message = user_authorization($PHP_AUTH_USER,$PHP_AUTH_PW,'REPORTS',1,0); +if ($auth_message == 'GOOD') + {$auth=1;} + +if ($auth > 0) + { + $stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and user_level > 7 and view_reports='1';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_to_mysqli($stmt, $link); + $row=mysqli_fetch_row($rslt); + $admin_auth=$row[0]; + + $stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and user_level > 6 and view_reports='1';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_to_mysqli($stmt, $link); + $row=mysqli_fetch_row($rslt); + $reports_auth=$row[0]; + + if ($reports_auth < 1) + { + $VDdisplayMESSAGE = _QXZ("You are not allowed to view reports"); + Header ("Content-type: text/html; charset=utf-8"); + echo "$VDdisplayMESSAGE: |$PHP_AUTH_USER|$auth_message|\n"; + exit; + } + if ( ($reports_auth > 0) and ($admin_auth < 1) ) + { + $ADD=999999; + $reports_only_user=1; + } + } +else + { + $VDdisplayMESSAGE = _QXZ("Login incorrect, please try again"); + if ($auth_message == 'LOCK') + { + $VDdisplayMESSAGE = _QXZ("Too many login attempts, try again in 15 minutes"); + Header ("Content-type: text/html; charset=utf-8"); + echo "$VDdisplayMESSAGE: |$PHP_AUTH_USER|$auth_message|\n"; + exit; + } + if ($auth_message == 'IPBLOCK') + { + $VDdisplayMESSAGE = _QXZ("Your IP Address is not allowed") . ": $ip"; + Header ("Content-type: text/html; charset=utf-8"); + echo "$VDdisplayMESSAGE: |$PHP_AUTH_USER|$auth_message|\n"; + exit; + } + Header("WWW-Authenticate: Basic realm=\"CONTACT-CENTER-ADMIN\""); + Header("HTTP/1.0 401 Unauthorized"); + echo "$VDdisplayMESSAGE: |$PHP_AUTH_USER|$PHP_AUTH_PW|$auth_message|\n"; + exit; + } + +$stmt="SELECT user_group from vicidial_users where user='$PHP_AUTH_USER';"; +if ($DB) {$MAIN.="|$stmt|\n";} +$rslt=mysql_to_mysqli($stmt, $link); +$row=mysqli_fetch_row($rslt); +$LOGuser_group = $row[0]; + +$stmt="SELECT allowed_campaigns,allowed_reports from vicidial_user_groups where user_group='$LOGuser_group';"; +if ($DB) {$MAIN.="|$stmt|\n";} +$rslt=mysql_to_mysqli($stmt, $link); +$row=mysqli_fetch_row($rslt); +$LOGallowed_campaigns = $row[0]; +$LOGallowed_reports = $row[1]; + +if ( (!preg_match("/$report_name/",$LOGallowed_reports)) and (!preg_match("/ALL REPORTS/",$LOGallowed_reports)) ) + { + Header("WWW-Authenticate: Basic realm=\"CONTACT-CENTER-ADMIN\""); + Header("HTTP/1.0 401 Unauthorized"); + echo _QXZ("You are not allowed to view this report").": |$PHP_AUTH_USER|$report_name|"._QXZ("$report_name")."|\n"; + exit; + } + +$NOW_TIME = date("Y-m-d H:i:s"); +$STARTtime = date("U"); + +$LOGallowed_campaignsSQL=''; +$whereLOGallowed_campaignsSQL=''; +if ( (!preg_match('/\-ALL/i', $LOGallowed_campaigns)) ) + { + $rawLOGallowed_campaignsSQL = preg_replace("/ -/",'',$LOGallowed_campaigns); + $rawLOGallowed_campaignsSQL = preg_replace("/ /","','",$rawLOGallowed_campaignsSQL); + $LOGallowed_campaignsSQL = "and campaign_id IN('$rawLOGallowed_campaignsSQL')"; + $whereLOGallowed_campaignsSQL = "where campaign_id IN('$rawLOGallowed_campaignsSQL')"; + } + +$campaign_typeSQL=''; +if (count($types)<2) { + if ($types == 'AUTO-DIAL ONLY') {$campaign_typeSQL="and dial_method IN('RATIO','ADAPT_HARD_LIMIT','ADAPT_TAPERED','ADAPT_AVERAGE')";} + if ($types == 'MANUAL ONLY') {$campaign_typeSQL="and dial_method IN('MANUAL','INBOUND_MAN')";} + if ($types == 'INBOUND ONLY') {$campaign_typeSQL="and campaign_allow_inbound='Y'";} +} else { + if (!in_array('LIST ALL CAMPAIGNS', $types)) { + $campaign_typeSQL='and ('; + if (in_array('AUTO-DIAL ONLY', $types)) {$campaign_typeSQL="dial_method IN('RATIO','ADAPT_HARD_LIMIT','ADAPT_TAPERED','ADAPT_AVERAGE') or ";} # unset($types['AUTO-DIAL ONLY']); + if (in_array('MANUAL ONLY', $types)) {$campaign_typeSQL="dial_method IN('MANUAL','INBOUND_MAN') or ";} # unset($types['MANUAL ONLY']); + if (in_array('INBOUND ONLY', $types)) {$campaign_typeSQL="campaign_allow_inbound='Y' or ";} # unset($types['INBOUND ONLY']); + $campaign_typeSQL='campaign_id in ('.implode("', '", $types).')'; + $campaign_typeSQL=')'; + } +} + + +$stmt="select campaign_id from vicidial_campaigns where active='Y' $LOGallowed_campaignsSQL $campaign_typeSQL order by campaign_id;"; +$rslt=mysql_to_mysqli($stmt, $link); +if (!isset($DB)) {$DB=0;} +if ($DB) {$MAIN.="$stmt\n";} +$groups_to_print = mysqli_num_rows($rslt); +$i=0; +while ($i < $groups_to_print) + { + $row=mysqli_fetch_row($rslt); + $groups[$i] =$row[0]; + $i++; + } + +## Display campaigns +$stmt="select campaign_id, campaign_name from vicidial_campaigns where active='Y' $LOGallowed_campaignsSQL order by campaign_id;"; +$rslt=mysql_to_mysqli($stmt, $link); +if (!isset($DB)) {$DB=0;} +if ($DB) {$MAIN.="$stmt\n";} +$campaigns_to_print = mysqli_num_rows($rslt); +$campaign_options="\n"; +$i=0; +while ($i < $campaigns_to_print) + { + $row=mysqli_fetch_row($rslt); + $campaign_options.="\n"; + $i++; + } + + +if (!isset($RR)) {$RR=4;} + +require("screen_colors.php"); + + +$HEADER.="\n"; +$HEADER.="\n"; +$HEADER.=""; +$HEADER.="\n"; +$HEADER.="\n"; +$HEADER.="\n"; +$HEADER.="\n"; +$HEADER.="\n"; + +$HEADER.="$report_name\n"; # BGCOLOR='#".$SSmenu_background."' + +$MAIN.="
  "._QXZ("agents logged in").""._QXZ("agents logged in")."   "._QXZ("agents in calls")."$AIDtx"._QXZ("agents in calls")."$AIDtx   "._QXZ("agents waiting").""._QXZ("agents waiting")."   "._QXZ("paused agents").""._QXZ("paused agents")."   "._QXZ("agents in dead calls").""._QXZ("agents in dead calls")."   "._QXZ("agents in dispo").""._QXZ("agents in dispo")."
$agent_total
$report_name
"; + +$k=0; +$JS_text.="var CAMPAIGNS=["; +$JS_text2="var ALL_CAMPAIGNS=["; +$JS_knob=""; +$sub_pct_display=""; +while($k<$groups_to_print) + { + $NFB = ''; + $NFE = ''; + $F=''; $FG=''; $B=''; $BG=''; + + $group = $groups[$k]; + $JS_text.="'$group',"; + $JS_text2.="'$group',"; + $sub_pct_display.="
"; + $sub_pct_display.="
$group
"; + + $CSV_text.="\"$group\"\n"; + + $stmt = "select count(*) from vicidial_campaigns where campaign_id='$group' and campaign_allow_inbound='Y';"; + $rslt=mysql_to_mysqli($stmt, $link); + $row=mysqli_fetch_row($rslt); + $campaign_allow_inbound = $row[0]; + + $stmt="select auto_dial_level,dial_status_a,dial_status_b,dial_status_c,dial_status_d,dial_status_e,lead_order,lead_filter_id,hopper_level,dial_method,adaptive_maximum_level,adaptive_dropped_percentage,adaptive_dl_diff_target,adaptive_intensity,available_only_ratio_tally,adaptive_latest_server_time,local_call_time,dial_timeout,dial_statuses from vicidial_campaigns where campaign_id='" . mysqli_real_escape_string($link, $group) . "';"; + $rslt=mysql_to_mysqli($stmt, $link); + $row=mysqli_fetch_row($rslt); + $DIALlev["$group"] = $row[0]; + $DIALstatusA["$group"] = $row[1]; + $DIALstatusB["$group"] = $row[2]; + $DIALstatusC["$group"] = $row[3]; + $DIALstatusD["$group"] = $row[4]; + $DIALstatusE["$group"] = $row[5]; + $DIALorder["$group"] = $row[6]; + $DIALfilter["$group"] = $row[7]; + $HOPlev["$group"] = $row[8]; + $DIALmethod["$group"] = $row[9]; + $maxDIALlev["$group"] = $row[10]; + $DROPmax["$group"] = $row[11]; + $targetDIFF["$group"] = $row[12]; + $ADAintense["$group"] = $row[13]; + $ADAavailonly["$group"] = $row[14]; + $TAPERtime["$group"] = $row[15]; + $CALLtime["$group"] = $row[16]; + $DIALtimeout["$group"] = $row[17]; + $DIALstatuses["$group"] = $row[18]; + $DIALstatuses["$group"] = (preg_replace("/ -$|^ /","",$DIALstatuses["$group"])); + $DIALstatuses["$group"] = (preg_replace('/\s/', ', ', $DIALstatuses["$group"])); + + $stmt="select count(*) from vicidial_hopper where campaign_id='" . mysqli_real_escape_string($link, $group) . "';"; + $rslt=mysql_to_mysqli($stmt, $link); + $row=mysqli_fetch_row($rslt); + $VDhop["$group"] = $row[0]; + + $stmt="select dialable_leads,calls_today,drops_today,drops_answers_today_pct,differential_onemin,agents_average_onemin,balance_trunk_fill,answers_today,status_category_1,status_category_count_1,status_category_2,status_category_count_2,status_category_3,status_category_count_3,status_category_4,status_category_count_4,agent_calls_today,agent_wait_today,agent_custtalk_today,agent_acw_today,agent_pause_today from vicidial_campaign_stats where campaign_id='" . mysqli_real_escape_string($link, $group) . "';"; + $rslt=mysql_to_mysqli($stmt, $link); + $row=mysqli_fetch_row($rslt); + $DAleads["$group"] = $row[0]; + $callsTODAY["$group"] = $row[1]; + $dropsTODAY["$group"] = $row[2]; + $drpctTODAY["$group"] = $row[3]; + $diffONEMIN["$group"] = $row[4]; + $agentsONEMIN["$group"] = $row[5]; + $balanceFILL["$group"] = $row[6]; + $answersTODAY["$group"] = $row[7]; + $VSCcat1["$group"] = $row[8]; + $VSCcat1tally["$group"] = $row[9]; + $VSCcat2["$group"] = $row[10]; + $VSCcat2tally["$group"] = $row[11]; + $VSCcat3["$group"] = $row[12]; + $VSCcat3tally["$group"] = $row[13]; + $VSCcat4["$group"] = $row[14]; + $VSCcat4tally["$group"] = $row[15]; + $VSCagentcalls["$group"] = $row[16]; + $VSCagentwait["$group"] = $row[17]; + $VSCagentcust["$group"] = $row[18]; + $VSCagentacw["$group"] = $row[19]; + $VSCagentpause["$group"] = $row[20]; + + $diffpctONEMIN = ( MathZDC($diffONEMIN["$group"], $agentsONEMIN["$group"]) * 100); + $diffpctONEMIN = sprintf("%01.2f", $diffpctONEMIN); + $diffpctONEMIN_ary["$group"] = $diffpctONEMIN; + + $stmt="select sum(local_trunk_shortage) from vicidial_campaign_server_stats where campaign_id='" . mysqli_real_escape_string($link, $group) . "';"; + $rslt=mysql_to_mysqli($stmt, $link); + $row=mysqli_fetch_row($rslt); + $balanceSHORT["$group"] = $row[0]; + + ################################################################################ + ### START calculating calls/agents + ################################################################################ + + ################################################################################ + ###### OUTBOUND CALLS + ################################################################################ + if ($campaign_allow_inbound > 0) + { + $stmt="select closer_campaigns from vicidial_campaigns where campaign_id='" . mysqli_real_escape_string($link, $group) . "';"; + $rslt=mysql_to_mysqli($stmt, $link); + $row=mysqli_fetch_row($rslt); + $closer_campaigns = preg_replace("/^ | -$/","",$row[0]); + $closer_campaigns = preg_replace("/ /","','",$closer_campaigns); + $closer_campaigns = "'$closer_campaigns'"; + + $stmt="select status from vicidial_auto_calls where status NOT IN('XFER') and ( (call_type='IN' and campaign_id IN($closer_campaigns)) or (campaign_id='" . mysqli_real_escape_string($link, $group) . "' and call_type='OUT') );"; + } + else + { + if ($group=='XXXX-ALL-ACTIVE-XXXX') {$groupSQL = '';} + else {$groupSQL = " and campaign_id='" . mysqli_real_escape_string($link, $group) . "'";} + + $stmt="select status from vicidial_auto_calls where status NOT IN('XFER') $groupSQL;"; + } + $rslt=mysql_to_mysqli($stmt, $link); + if ($DB) {$MAIN.="$stmt\n";} + $parked_to_print = mysqli_num_rows($rslt); + if ($parked_to_print > 0) + { + $i=0; + $out_total["$group"]=0; + $out_ring["$group"]=0; + $out_live["$group"]=0; + $in_ivr["$group"]=0; + while ($i < $parked_to_print) + { + $row=mysqli_fetch_row($rslt); + + if (preg_match("/LIVE/i",$row[0])) + {$out_live["$group"]++;} + else + { + if (preg_match("/IVR/i",$row[0])) + {$in_ivr["$group"]++;} + if (preg_match("/CLOSER/i",$row[0])) + {$nothing=1;} + else + {$out_ring["$group"]++;} + } + $out_total["$group"]++; + $i++; + } + + if ($out_live > 0) {$F=''; $FG='';} + if ($out_live > 4) {$F=''; $FG='';} + if ($out_live > 9) {$F=''; $FG='';} + if ($out_live > 14) {$F=''; $FG='';} + + } + + ################################################################################### + ###### TIME ON SYSTEM + ################################################################################### + + $agent_incall["$group"]=0; + $agent_ready["$group"]=0; + $agent_paused["$group"]=0; + $agent_total["$group"]=0; + + $stmt="select extension,user,conf_exten,status,server_ip,UNIX_TIMESTAMP(last_call_time),UNIX_TIMESTAMP(last_call_finish),call_server_ip,campaign_id from vicidial_live_agents where campaign_id='" . mysqli_real_escape_string($link, $group) . "';"; + $rslt=mysql_to_mysqli($stmt, $link); + if ($DB) {$MAIN.="$stmt\n";} + $talking_to_print = mysqli_num_rows($rslt); + if ($talking_to_print > 0) + { + $i=0; + $agentcount=0; + while ($i < $talking_to_print) + { + $row=mysqli_fetch_row($rslt); + if (preg_match("/READY|PAUSED/i",$row[3])) + { + $row[5]=$row[6]; + } + $Lstatus = $row[3]; + $status = sprintf("%-6s", $row[3]); + if (!preg_match("/INCALL|QUEUE/i",$row[3])) + {$call_time_S = ($STARTtime - $row[6]);} + else + {$call_time_S = ($STARTtime - $row[5]);} + + $call_time_M = MathZDC($call_time_S, 60); + $call_time_M = round($call_time_M, 2); + $call_time_M_int = intval("$call_time_M"); + $call_time_SEC = ($call_time_M - $call_time_M_int); + $call_time_SEC = ($call_time_SEC * 60); + $call_time_SEC = round($call_time_SEC, 0); + if ($call_time_SEC < 10) {$call_time_SEC = "0$call_time_SEC";} + $call_time_MS = "$call_time_M_int:$call_time_SEC"; + $call_time_MS = sprintf("%7s", $call_time_MS); + $G = ''; $EG = ''; + if (preg_match("/PAUSED/i",$row[3])) + { + if ($call_time_M_int >= 30) + {$i++; continue;} + else + { + $agent_paused["$group"]++; + $agent_total["$group"]++; + } + } + + if ( (preg_match("/INCALL/i",$status)) or (preg_match("/QUEUE/i",$status)) ) {$agent_incall["$group"]++; $agent_total["$group"]++;} + if ( (preg_match("/READY/i",$status)) or (preg_match("/CLOSER/i",$status)) ) {$agent_ready["$group"]++; $agent_total["$group"]++;} + $agentcount++; + $i++; + + } + } + + ################################################################################ + ### END calculating calls/agents + ################################################################################ + + if ($VSCagentcalls > 0) + { + $avgpauseTODAY = MathZDC($VSCagentpause["$group"], $VSCagentcalls["$group"]); + $avgpauseTODAY = round($avgpauseTODAY, 0); + $avgpauseTODAY = sprintf("%01.0f", $avgpauseTODAY); + $avgpauseTODAY_ary["$group"]=$avgpauseTODAY; + + $avgwaitTODAY = MathZDC($VSCagentwait["$group"], $VSCagentcalls["$group"]); + $avgwaitTODAY = round($avgwaitTODAY, 0); + $avgwaitTODAY = sprintf("%01.0f", $avgwaitTODAY); + $avgwaitTODAY_ary["$group"]=$avgwaitTODAY; + + $avgcustTODAY = MathZDC($VSCagentcust["$group"], $VSCagentcalls["$group"]); + $avgcustTODAY = round($avgcustTODAY, 0); + $avgcustTODAY = sprintf("%01.0f", $avgcustTODAY); + $avgcustTODAY_ary["$group"]=$avgcustTODAY; + + $avgacwTODAY = MathZDC($VSCagentacw["$group"], $VSCagentcalls["$group"]); + $avgacwTODAY = round($avgacwTODAY, 0); + $avgacwTODAY = sprintf("%01.0f", $avgacwTODAY); + $avgacwTODAY_ary["$group"]=$avgacwTODAY; + } + +# $MAIN.="\n\n

"; + + + + $k++; + } +$JS_text=preg_replace('/,$/', '', $JS_text); +$JS_text.="];\n"; +$JS_text2=preg_replace('/,$/', '', $JS_text2); +$JS_text2.="];\n"; +$JS_text.=$JS_text2; + +# Output all arrays +$n=0; +$DIALlev_JS='var DIAL_lev=['; +$DIALstatusA_JS='var DIALstatusA=['; +$DIALstatusB_JS='var DIALstatusB=['; +$DIALstatusC_JS='var DIALstatusC=['; +$DIALstatusD_JS='var DIALstatusD=['; +$DIALstatusE_JS='var DIALstatusE=['; +$DIALorder_JS='var DIALorder=['; +$DIALfilter_JS='var DIALfilter=['; +$HOPlev_JS='var HOPlev=['; +$DIALmethod_JS='var DIALmethod=['; +$maxDIALlev_JS='var maxDIALlev=['; +$DROPmax_JS='var DROPmax=['; +$targetDIFF_JS='var targetDIFF=['; +$ADAintense_JS='var ADAintense=['; +$ADAavailonly_JS='var ADAavailonly=['; +$TAPERtime_JS='var TAPERtime=['; +$CALLtime_JS='var CALLtime=['; +$DIALtimeout_JS='var DIALtimeout=['; +$DIALstatuses_JS='var DIALstatuses=['; +$VDhop_JS='var VDhop=['; +$DAleads_JS='var DAleads=['; +$callsTODAY_JS='var callsTODAY=['; +$dropsTODAY_JS='var dropsTODAY=['; +$drpctTODAY_JS='var drpctTODAY=['; +$diffONEMIN_JS='var diffONEMIN=['; +$agentsONEMIN_JS='var agentsONEMIN=['; +$balanceFILL_JS='var balanceFILL=['; +$answersTODAY_JS='var answersTODAY=['; +$VSCcat1_JS='var VSCcat1=['; +$VSCcat1tally_JS='var VSCcat1tally=['; +$VSCcat2_JS='var VSCcat2=['; +$VSCcat2tally_JS='var VSCcat2tally=['; +$VSCcat3_JS='var VSCcat3=['; +$VSCcat3tally_JS='var VSCcat3tally=['; +$VSCcat4_JS='var VSCcat4=['; +$VSCcat4tally_JS='var VSCcat4tally=['; +$VSCagentcalls_JS='var VSCagentcalls=['; +$VSCagentwait_JS='var VSCagentwait=['; +$VSCagentcust_JS='var VSCagentcust=['; +$VSCagentacw_JS='var VSCagentacw=['; +$VSCagentpause_JS='var VSCagentpause=['; +$diffpctONEMIN_ary_JS='var diffpctONEMIN_ary=['; +$balanceSHORT_JS='var balanceSHORT=['; +$out_total_JS='var out_total=['; +$out_ring_JS='var out_ring=['; +$out_live_JS='var out_live=['; +$in_ivr_JS='var in_ivr=['; +$agent_incall_JS='var agent_incall=['; +$agent_ready_JS='var agent_ready=['; +$agent_paused_JS='var agent_paused=['; +$agent_total_JS='var agent_total=['; +$avgpauseTODAY_ary_JS='var avgpauseTODAY_ary=['; +$avgwaitTODAY_ary_JS='var avgwaitTODAY_ary=['; +$avgcustTODAY_ary_JS='var avgcustTODAY_ary=['; +$avgacwTODAY_ary_JS='var avgacwTODAY_ary=['; + +while ($n<$groups_to_print) { + # $DIALlev["$group"] = $row[0]; + $DIALlev_JS .= "'".$DIALlev[$groups[$n]]."',"; + $DIALstatusA_JS .= "'".$DIALstatusA[$groups[$n]]."',"; + $DIALstatusB_JS .= "'".$DIALstatusB[$groups[$n]]."',"; + $DIALstatusC_JS .= "'".$DIALstatusC[$groups[$n]]."',"; + $DIALstatusD_JS .= "'".$DIALstatusD[$groups[$n]]."',"; + $DIALstatusE_JS .= "'".$DIALstatusE[$groups[$n]]."',"; + $DIALorder_JS .= "'".$DIALorder[$groups[$n]]."',"; + $DIALfilter_JS .= "'".$DIALfilter[$groups[$n]]."',"; + $HOPlev_JS .= "'".$HOPlev[$groups[$n]]."',"; + $DIALmethod_JS .= "'".$DIALmethod[$groups[$n]]."',"; + $maxDIALlev_JS .= "'".$maxDIALlev[$groups[$n]]."',"; + $DROPmax_JS .= "'".$DROPmax[$groups[$n]]."',"; + $targetDIFF_JS .= "'".$targetDIFF[$groups[$n]]."',"; + $ADAintense_JS .= "'".$ADAintense[$groups[$n]]."',"; + $ADAavailonly_JS .= "'".$ADAavailonly[$groups[$n]]."',"; + $TAPERtime_JS .= "'".$TAPERtime[$groups[$n]]."',"; + $CALLtime_JS .= "'".$CALLtime[$groups[$n]]."',"; + $DIALtimeout_JS .= "'".$DIALtimeout[$groups[$n]]."',"; + $DIALstatuses_JS .= "'".$DIALstatuses[$groups[$n]]."',"; + $VDhop_JS .= "'".$VDhop[$groups[$n]]."',"; + $DAleads_JS .= "'".$DAleads[$groups[$n]]."',"; + $callsTODAY_JS .= "'".$callsTODAY[$groups[$n]]."',"; + $dropsTODAY_JS .= "'".$dropsTODAY[$groups[$n]]."',"; + $drpctTODAY_JS .= "'".$drpctTODAY[$groups[$n]]."',"; + $diffONEMIN_JS .= "'".$diffONEMIN[$groups[$n]]."',"; + $agentsONEMIN_JS .= "'".$agentsONEMIN[$groups[$n]]."',"; + $balanceFILL_JS .= "'".$balanceFILL[$groups[$n]]."',"; + $answersTODAY_JS .= "'".$answersTODAY[$groups[$n]]."',"; + $VSCcat1_JS .= "'".$VSCcat1[$groups[$n]]."',"; + $VSCcat1tally_JS .= "'".$VSCcat1tally[$groups[$n]]."',"; + $VSCcat2_JS .= "'".$VSCcat2[$groups[$n]]."',"; + $VSCcat2tally_JS .= "'".$VSCcat2tally[$groups[$n]]."',"; + $VSCcat3_JS .= "'".$VSCcat3[$groups[$n]]."',"; + $VSCcat3tally_JS .= "'".$VSCcat3tally[$groups[$n]]."',"; + $VSCcat4_JS .= "'".$VSCcat4[$groups[$n]]."',"; + $VSCcat4tally_JS .= "'".$VSCcat4tally[$groups[$n]]."',"; + $VSCagentcalls_JS .= "'".$VSCagentcalls[$groups[$n]]."',"; + $VSCagentwait_JS .= "'".$VSCagentwait[$groups[$n]]."',"; + $VSCagentcust_JS .= "'".$VSCagentcust[$groups[$n]]."',"; + $VSCagentacw_JS .= "'".$VSCagentacw[$groups[$n]]."',"; + $VSCagentpause_JS .= "'".$VSCagentpause[$groups[$n]]."',"; + $diffpctONEMIN_ary_JS .= "'".$diffpctONEMIN_ary[$groups[$n]]."',"; + $balanceSHORT_JS .= "'".$balanceSHORT[$groups[$n]]."',"; + $out_total_JS .= "'".$out_total[$groups[$n]]."',"; + $out_ring_JS .= "'".$out_ring[$groups[$n]]."',"; + $out_live_JS .= "'".$out_live[$groups[$n]]."',"; + $in_ivr_JS .= "'".$in_ivr[$groups[$n]]."',"; + $agent_incall_JS .= "'".$agent_incall[$groups[$n]]."',"; + $agent_ready_JS .= "'".$agent_ready[$groups[$n]]."',"; + $agent_paused_JS .= "'".$agent_paused[$groups[$n]]."',"; + $agent_total_JS .= "'".$agent_total[$groups[$n]]."',"; + $avgpauseTODAY_ary_JS .= "'".$avgpauseTODAY_ary[$groups[$n]]."',"; + $avgwaitTODAY_ary_JS .= "'".$avgwaitTODAY_ary[$groups[$n]]."',"; + $avgcustTODAY_ary_JS .= "'".$avgcustTODAY_ary[$groups[$n]]."',"; + $avgacwTODAY_ary_JS .= "'".$avgacwTODAY_ary[$groups[$n]]."',"; + $n++; +} + +$DIALlev_JS.="];\n"; +$DIALstatusA_JS.="];\n"; +$DIALstatusB_JS.="];\n"; +$DIALstatusC_JS.="];\n"; +$DIALstatusD_JS.="];\n"; +$DIALstatusE_JS.="];\n"; +$DIALorder_JS.="];\n"; +$DIALfilter_JS.="];\n"; +$HOPlev_JS.="];\n"; +$DIALmethod_JS.="];\n"; +$maxDIALlev_JS.="];\n"; +$DROPmax_JS.="];\n"; +$targetDIFF_JS.="];\n"; +$ADAintense_JS.="];\n"; +$ADAavailonly_JS.="];\n"; +$TAPERtime_JS.="];\n"; +$CALLtime_JS.="];\n"; +$DIALtimeout_JS.="];\n"; +$DIALstatuses_JS.="];\n"; +$VDhop_JS.="];\n"; +$DAleads_JS.="];\n"; +$callsTODAY_JS.="];\n"; +$dropsTODAY_JS.="];\n"; +$drpctTODAY_JS.="];\n"; +$diffONEMIN_JS.="];\n"; +$agentsONEMIN_JS.="];\n"; +$balanceFILL_JS.="];\n"; +$answersTODAY_JS.="];\n"; +$VSCcat1_JS.="];\n"; +$VSCcat1tally_JS.="];\n"; +$VSCcat2_JS.="];\n"; +$VSCcat2tally_JS.="];\n"; +$VSCcat3_JS.="];\n"; +$VSCcat3tally_JS.="];\n"; +$VSCcat4_JS.="];\n"; +$VSCcat4tally_JS.="];\n"; +$VSCagentcalls_JS.="];\n"; +$VSCagentwait_JS.="];\n"; +$VSCagentcust_JS.="];\n"; +$VSCagentacw_JS.="];\n"; +$VSCagentpause_JS.="];\n"; +$diffpctONEMIN_ary_JS.="];\n"; +$balanceSHORT_JS.="];\n"; +$out_total_JS.="];\n"; +$out_ring_JS.="];\n"; +$out_live_JS.="];\n"; +$in_ivr_JS.="];\n"; +$agent_incall_JS.="];\n"; +$agent_ready_JS.="];\n"; +$agent_paused_JS.="];\n"; +$agent_total_JS.="];\n"; +$avgpauseTODAY_ary_JS.="];\n"; +$avgwaitTODAY_ary_JS.="];\n"; +$avgcustTODAY_ary_JS.="];\n"; +$avgacwTODAY_ary_JS.="];\n"; + +$JS_text.=$DIALlev_JS.$DIALstatusA_JS.$DIALstatusB_JS.$DIALstatusC_JS.$DIALstatusD_JS.$DIALstatusE_JS.$DIALorder_JS.$DIALfilter_JS.$HOPlev_JS.$DIALmethod_JS.$maxDIALlev_JS.$DROPmax_JS.$targetDIFF_JS.$ADAintense_JS.$ADAavailonly_JS.$TAPERtime_JS.$CALLtime_JS.$DIALtimeout_JS.$DIALstatuses_JS.$VDhop_JS.$DAleads_JS.$callsTODAY_JS.$dropsTODAY_JS.$drpctTODAY_JS.$diffONEMIN_JS.$agentsONEMIN_JS.$balanceFILL_JS.$answersTODAY_JS.$VSCcat1_JS.$VSCcat1tally_JS.$VSCcat2_JS.$VSCcat2tally_JS.$VSCcat3_JS.$VSCcat3tally_JS.$VSCcat4_JS.$VSCcat4tally_JS.$VSCagentcalls_JS.$VSCagentwait_JS.$VSCagentcust_JS.$VSCagentacw_JS.$VSCagentpause_JS.$diffpctONEMIN_ary_JS.$balanceSHORT_JS.$out_total_JS.$out_ring_JS.$out_live_JS.$in_ivr_JS.$agent_incall_JS.$agent_ready_JS.$agent_paused_JS.$agent_total_JS.$avgpauseTODAY_ary_JS.$avgwaitTODAY_ary_JS.$avgcustTODAY_ary_JS.$avgacwTODAY_ary_JS; +$JS_text=preg_replace('/,];/', '];', $JS_text); + + +$MAIN.=""; +$MAIN.=""; + +$MAIN.=""; +$MAIN.=""; +$MAIN.=""; + +$MAIN.=""; + +$MAIN.=""; +$MAIN.=""; + +$MAIN.=""; + +$MAIN.="
"._QXZ("CAMPAIGNS").":
\n"; +# $MAIN.="\n"; +$MAIN.="
"; +$MAIN.=""; +$MAIN.=""; +$MAIN.=""; +$MAIN.="
"; + +$MAIN.="\n"; +$MAIN.="\n"; +$MAIN.="\n"; +$MAIN.="

\n\n"; + +$MAIN.="
"; +$MAIN.=""; +# $MAIN.="

"; +$MAIN.="
"; +$MAIN.="
"; + + +$MAIN.=""; + +$MAIN.=""; + +$MAIN.=""; + +$MAIN.="\n\n
"; +$MAIN.="\n"; +#$MAIN.="
\n"; + +$MAIN.="\n"; + +# $MAIN.="$db_source\n"; + + if ($file_download>0) { + $FILE_TIME = date("Ymd-His"); + $CSVfilename = "AST_timeonVDADallSUMMARY_$US$FILE_TIME.csv"; + $CSV_text=preg_replace('/\n +,/', ',', $CSV_text); + $CSV_text=preg_replace('/ +\"/', '"', $CSV_text); + $CSV_text=preg_replace('/\" +/', '"', $CSV_text); + // We'll be outputting a TXT file + header('Content-type: application/octet-stream'); + + // It will be called LIST_101_20090209-121212.txt + header("Content-Disposition: attachment; filename=\"$CSVfilename\""); + header('Expires: 0'); + header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); + header('Pragma: public'); + ob_clean(); + flush(); + + echo "$CSV_text"; + + exit; + } else { + header ("Content-type: text/html; charset=utf-8"); + + echo $HEADER; + $android_header=1; + require("admin_header.php"); + # print_r($VDhop); + echo $MAIN; + echo ""; + } + +/* + if (MainGraph) + { + if (document.getElementById('graph_type').value!=graph_type) + { + graph_type=document.getElementById('graph_type').value; + MainGraph.destroy(); + } + else + { + MainGraph.update(); + } + } +*/ +?> \ No newline at end of file diff --git a/www/vicidial/admin.php b/www/vicidial/admin.php index 34ca1325..2ed55f01 100644 --- a/www/vicidial/admin.php +++ b/www/vicidial/admin.php @@ -4476,12 +4476,13 @@ else # 190207-2301 - Fix for user-group, in-group and campaign allowed/permissions matching issues # 190221-1831 - Added force_fronter_audio_stop API function # 190223-0850 - Added static prompt fields for in-group play-place-in-line +# 190302-1745 - Added disclaimers for pure-knob code # # make sure you have added a user to the vicidial_users MySQL table with at least user_level 9 to access this page the first time -$admin_version = '2.14-700a'; -$build = '190223-0850'; +$admin_version = '2.14-701a'; +$build = '190302-1745'; $STARTtime = date("U"); $SQLdate = date("Y-m-d H:i:s"); @@ -41727,16 +41728,28 @@ if ($ADD==999995) echo "
"._QXZ("Trademark").":   \"VICIDIAL\" "._QXZ("is a registered trademark of the")." ViciDial Group. Here is our "._QXZ("trademark use policy")."
"._QXZ("License").":   "._QXZ("The ViciDial Contact Center Suite is released under the")." AGPLv2 "._QXZ("open source license")."
"._QXZ("License").":   "._QXZ("The ViciDial Contact Center Suite is released under the")." AGPLv2 "._QXZ("open source license").".
"._QXZ("Source Code").":   "._QXZ("The ViciDial Call Center Suite software is available for download, and for use, free of cost. You can download the easy to install")." "._QXZ("ViciBox CD ISO version").", "._QXZ("or only the")." "._QXZ("source code")."
\n"; + echo "
\n"; + if ($first_login_link > 0) { echo "

"; - echo "
"._QXZ("Continue on to the Initial Setup")."

  \n"; + echo "
"._QXZ("Continue on to the Initial Setup")."



  \n"; } + + echo "

"._QXZ("Other integrated software disclaimers").":

\n"; + echo "
\n"; + + echo "\n"; + + echo "\n"; + + echo "\n"; + + echo "
"._QXZ("Pure-knob Copyright").":   "._QXZ("The pure-knob javascript library was written by Andre Plötze").", © 2018
"._QXZ("Pure-knob License").":   "._QXZ("Pure-knob is licensed under the")." Apache 2.0 "._QXZ("open source license")."
"._QXZ("Pure-knob Source Code").":   "._QXZ("Pure-knob source code is available at")." "._QXZ("this link").".
\n"; } ##### END copyright trademark license page ##### diff --git a/www/vicidial/admin_header.php b/www/vicidial/admin_header.php index 4f773ffe..b1e3cb30 100644 --- a/www/vicidial/admin_header.php +++ b/www/vicidial/admin_header.php @@ -1,7 +1,7 @@ LICENSE: AGPLv2 +# Copyright (C) 2019 Matt Florell LICENSE: AGPLv2 # # CHANGES @@ -77,7 +77,7 @@ # 180512-1105 - Changed to dynamic DB help # 180614-2200 - Modified audio chooser window to appear at height where mouse was clicked in JS functions # 180618-2300 - Modified calls to audio file chooser function -# 180716-2120 - Fix for audio chooser bug on call menu screen +# 190121-1803 - Added special streamlined header option for mobile devices # $stmt="SELECT admin_home_url,enable_tts_integration,callcard_enabled,custom_fields_enabled,allow_emails,level_8_disable_add,allow_chats,enable_languages,admin_row_click,admin_screen_colors,user_new_lead_limit,user_territories_active,qc_features_active,agent_soundboards,enable_drop_lists,allow_ip_lists from system_settings;"; @@ -339,6 +339,21 @@ if($short_header) ######################### SMALL HTML HEADER END ####################################### +######################### MOBILE HTML HEADER BEGIN #################################### +else if ($android_header) + { + ?> + width='100%'> + + + +
System logo      
+, Joe Johnson LICENSE: AGPLv2 +# +# CHANGES +# 190205-1702 - First Build +# + +$admin_version = '2.14-1a'; +$build = '190205-1702'; + +$startMS = microtime(); + +require("dbconnect_mysqli.php"); +require("functions.php"); + +###################################################################################################### +###################################################################################################### +####### static variable settings for display options +###################################################################################################### +###################################################################################################### + +$page_width='770'; +$section_width='750'; +$header_font_size='12'; +$subheader_font_size='11'; +$subcamp_font_size='11'; +$header_selected_bold=''; +$header_nonselected_bold=''; +$users_color = '#FFFF99'; +$campaigns_color = '#FFCC99'; +$lists_color = '#FFCCCC'; +$ingroups_color = '#CC99FF'; +$remoteagent_color ='#CCFFCC'; +$usergroups_color = '#CCFFFF'; +$scripts_color = '#99FFCC'; +$filters_color = '#CCCCCC'; +$admin_color = '#FF99FF'; +$reports_color = '#99FF33'; + $times_color = '#FF33FF'; + $shifts_color = '#FF33FF'; + $phones_color = '#FF33FF'; + $conference_color = '#FF33FF'; + $server_color = '#FF33FF'; + $templates_color = '#FF33FF'; + $carriers_color = '#FF33FF'; + $settings_color = '#FF33FF'; + $label_color = '#FF33FF'; + $status_color = '#FF33FF'; + $moh_color = '#FF33FF'; + $vm_color = '#FF33FF'; + $tts_color = '#FF33FF'; + $cc_color = '#FF33FF'; + $cts_color = '#FF33FF'; +$subcamp_color = '#FF9933'; +$users_font = 'BLACK'; +$campaigns_font = 'BLACK'; +$lists_font = 'BLACK'; +$ingroups_font = 'BLACK'; +$remoteagent_font = 'BLACK'; +$usergroups_font = 'BLACK'; +$scripts_font = 'BLACK'; +$filters_font = 'BLACK'; +$admin_font = 'BLACK'; +$qc_font = 'BLACK'; +$reports_font = 'BLACK'; + $times_font = 'BLACK'; + $phones_font = 'BLACK'; + $conference_font = 'BLACK'; + $server_font = 'BLACK'; + $settings_font = 'BLACK'; + $label_font = 'BLACK'; + $status_font = 'BLACK'; + $moh_font = 'BLACK'; + $vm_font = 'BLACK'; + $tts_font = 'BLACK'; + $cc_font = 'BLACK'; + $cts_font = 'BLACK'; +$subcamp_font = 'BLACK'; + +### comment this section out for colorful section headings +$users_color = '#E6E6E6'; +$campaigns_color = '#E6E6E6'; +$lists_color = '#E6E6E6'; +$ingroups_color = '#E6E6E6'; +$remoteagent_color ='#E6E6E6'; +$usergroups_color = '#E6E6E6'; +$scripts_color = '#E6E6E6'; +$filters_color = '#E6E6E6'; +$admin_color = '#E6E6E6'; +$qc_color = '#E6E6E6'; +$reports_color = '#E6E6E6'; + $times_color = '#C6C6C6'; + $shifts_color = '#C6C6C6'; + $phones_color = '#C6C6C6'; + $conference_color = '#C6C6C6'; + $server_color = '#C6C6C6'; + $templates_color = '#C6C6C6'; + $carriers_color = '#C6C6C6'; + $settings_color = '#C6C6C6'; + $label_color = '#C6C6C6'; + $colors_color = '#C6C6C6'; + $status_color = '#C6C6C6'; + $moh_color = '#C6C6C6'; + $vm_color = '#C6C6C6'; + $tts_color = '#C6C6C6'; + $cc_color = '#C6C6C6'; + $cts_color = '#C6C6C6'; + $sc_color = '#C6C6C6'; + $sg_color = '#C6C6C6'; + $ar_color = '#C6C6C6'; + $il_color = '#C6C6C6'; +$subcamp_color = '#C6C6C6'; + +$Msubhead_color = '#E6E6E6'; +$Mselected_color = '#C6C6C6'; +$Mhead_color = '#A3C3D6'; +$Mmain_bgcolor = '#015B91'; + +### + + +$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER']; +$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW']; +$PHP_SELF=$_SERVER['PHP_SELF']; +$QUERY_STRING = getenv("QUERY_STRING"); + +$Vreports = 'NONE, Real-Time Main Report, Real-Time Campaign Summary, Real-Time Whiteboard Report, Inbound Report, Inbound Report by DID, Inbound Service Level Report, Inbound Summary Hourly Report, Inbound Daily Report, Inbound DID Report, Inbound DID Summary Report, Agent DID Report, Inbound IVR Report, Inbound Forecasting Report, Advanced Forecasting Report, Outbound Calling Report, Outbound Summary Interval Report, Outbound IVR Report, Callmenu Survey Report, Outbound Lead Source Report, Fronter - Closer Report, Fronter - Closer Detail Report, Lists Campaign Statuses Report, Lists Statuses Report, Campaign Status List Report, Export Calls Report, Export Leads Report, Agent Time Detail, Agent Status Detail, Agent Inbound Status Summary, Agent Performance Detail, Team Performance Detail, Performance Comparison Report, Single Agent Daily, Single Agent Daily Time, User Group Login Report, User Group Hourly Report, User Group Detail Hourly Report, User Timeclock Report, User Group Timeclock Status Report, User Timeclock Detail Report, Server Performance Report, Administration Change Log, List Update Stats, User Stats, User Time Sheet, Download List, Dialer Inventory Report, Maximum System Stats, Maximum Stats Detail, Search Leads Logs, Email Log Report, Carrier Log Report, Campaign Debug, Asterisk Debug, Hangup Cause Report, Lists Pass Report, Called Counts List IDs Report, Agent Debug Log Report, Agent Parked Call Report, Agent-Manager Chat Log, Recording Access Log Report, API Log Report, Real-Time Monitoring Log Report'; + +$UGreports = 'ALL REPORTS, NONE, Real-Time Main Report, Real-Time Campaign Summary, Real-Time Whiteboard Report, Inbound Report, Inbound Report by DID, Inbound Service Level Report, Inbound Summary Hourly Report, Inbound Daily Report, Inbound DID Report, Inbound DID Summary Report, Agent DID Report, Inbound Email Report, Inbound Chat Report, Inbound IVR Report, Inbound Forecasting Report, Advanced Forecasting Report, Outbound Calling Report, Outbound Summary Interval Report, Outbound IVR Report, Callmenu Survey Report, Outbound Lead Source Report, Fronter - Closer Report, Fronter - Closer Detail Report, Lists Campaign Statuses Report, Lists Statuses Report, Campaign Status List Report, Export Calls Report, Export Leads Report, Agent Time Detail, Agent Status Detail, Agent Inbound Status Summary, Agent Performance Detail, Team Performance Detail, Performance Comparison Report, Single Agent Daily, Single Agent Daily Time, User Group Login Report, User Group Hourly Report, User Group Detail Hourly Report, User Timeclock Report, User Group Timeclock Status Report, User Timeclock Detail Report, Server Performance Report, Administration Change Log, List Update Stats, User Stats, User Time Sheet, Download List, Dialer Inventory Report, Custom Reports Links, CallCard Search, Maximum System Stats, Maximum Stats Detail, Search Leads Logs, Email Log Report, Lists Pass Report, Called Counts List IDs Report, Front Page System Summary, Report Page Servers Summary, Admin Utilities Page, Agent Debug Log Report, Agent Parked Call Report, Agent-Manager Chat Log, Recording Access Log Report, API Log Report, Real-Time Monitoring Log Report'; + +$Vtables = 'NONE,log_noanswer,did_agent_log,contact_information'; + +$APIfunctions = 'ALL_FUNCTIONS add_group_alias add_lead add_list add_phone add_phone_alias add_user agent_ingroup_info agent_stats_export agent_status audio_playback blind_monitor call_agent callid_info change_ingroups check_phone_number did_log_export external_add_lead external_dial external_hangup external_pause external_status in_group_status logout moh_list park_call pause_code preview_dial_action ra_call_control recording recording_lookup send_dtmf server_refresh set_timer_action sounds_list st_get_agent_active_lead st_login_log transfer_conference update_fields update_lead update_list update_log_entry update_phone update_phone_alias update_user user_group_status vm_list webphone_url webserver logged_in_agents update_campaign update_did lead_field_info phone_number_log switch_lead ccc_lead_info lead_status_search call_status_stats calls_in_queue_count force_fronter_leave_3way'; + + +### BEGIN housecleaning of old static report files, if not done before ### +if (!file_exists('old_clear')) + { + array_map('unlink', glob("./*.csv")); + array_map('unlink', glob("./*.xls")); + array_map('unlink', glob("./ploticus/*")); + unlink('project_auth_entries.txt'); + + $clear_file=fopen('old_clear', "w"); + fwrite($clear_file, '1'); + fclose($clear_file); + } +### END housecleaning of old static report files ### + +if (isset($_GET["DB"])) {$DB=$_GET["DB"];} + elseif (isset($_POST["DB"])) {$DB=$_POST["DB"];} + + +############################################# +##### START SYSTEM_SETTINGS LOOKUP ##### +$stmt = "SELECT use_non_latin,enable_queuemetrics_logging,enable_vtiger_integration,qc_features_active,outbound_autodial_active,sounds_central_control_active,enable_second_webform,user_territories_active,custom_fields_enabled,admin_web_directory,webphone_url,first_login_trigger,hosted_settings,default_phone_registration_password,default_phone_login_password,default_server_password,test_campaign_calls,active_voicemail_server,voicemail_timezones,default_voicemail_timezone,default_local_gmt,campaign_cid_areacodes_enabled,pllb_grouping_limit,did_ra_extensions_enabled,expanded_list_stats,contacts_enabled,alt_log_server_ip,alt_log_dbname,alt_log_login,alt_log_pass,tables_use_alt_log_db,call_menu_qualify_enabled,admin_list_counts,allow_voicemail_greeting,svn_revision,allow_emails,level_8_disable_add,pass_key,pass_hash_enabled,disable_auto_dial,country_code_list_stats,frozen_server_call_clear,active_modules,allow_chats,enable_languages,language_method,meetme_enter_login_filename,meetme_enter_leave3way_filename,enable_did_entry_list_id,enable_third_webform,default_language,user_hide_realtime_enabled,log_recording_access,alt_ivr_logging,admin_row_click,admin_screen_colors,ofcom_uk_drop_calc,agent_screen_colors,script_remove_js,manual_auto_next,user_new_lead_limit,agent_xfer_park_3way,agent_soundboards,web_loader_phone_length,agent_script,enable_auto_reports,enable_pause_code_limits,enable_drop_lists,allow_ip_lists,system_ip_blacklist,hide_inactive_lists,allow_manage_active_lists,expired_lists_inactive,did_system_filter,enable_gdpr_download_deletion FROM system_settings;"; +$rslt=mysql_to_mysqli($stmt, $link); +if ($DB) {echo "$stmt\n";} +$qm_conf_ct = mysqli_num_rows($rslt); +if ($qm_conf_ct > 0) + { + $row=mysqli_fetch_row($rslt); + $non_latin = $row[0]; + $SSenable_queuemetrics_logging = $row[1]; + $SSenable_vtiger_integration = $row[2]; + $SSqc_features_active = $row[3]; + $SSoutbound_autodial_active = $row[4]; + $SSsounds_central_control_active = $row[5]; + $SSenable_second_webform = $row[6]; + $SSuser_territories_active = $row[7]; + $SScustom_fields_enabled = $row[8]; + $SSadmin_web_directory = $row[9]; + $SSwebphone_url = $row[10]; + $SSfirst_login_trigger = $row[11]; + $SShosted_settings = $row[12]; + $SSdefault_phone_registration_password =$row[13]; + $SSdefault_phone_login_password = $row[14]; + $SSdefault_server_password = $row[15]; + $SStest_campaign_calls = $row[16]; + $SSactive_voicemail_server = $row[17]; + $SSvoicemail_timezones = $row[18]; + $SSdefault_voicemail_timezone = $row[19]; + $SSdefault_local_gmt = $row[20]; + $SScampaign_cid_areacodes_enabled = $row[21]; + $SSpllb_grouping_limit = $row[22]; + $SSdid_ra_extensions_enabled = $row[23]; + $SSexpanded_list_stats = $row[24]; + $SScontacts_enabled = $row[25]; + $SSalt_log_server_ip = $row[26]; + $SSalt_log_dbname = $row[27]; + $SSalt_log_login = $row[28]; + $SSalt_log_pass = $row[29]; + $SStables_use_alt_log_db = $row[30]; + $SScall_menu_qualify_enabled = $row[31]; + $SSadmin_list_counts = $row[32]; + $SSallow_voicemail_greeting = $row[33]; + $SSsvn_revision = $row[34]; + $SSallow_emails = $row[35]; + $SSlevel_8_disable_add = $row[36]; + $SSpass_key = $row[37]; + $SSpass_hash_enabled = $row[38]; + $SSdisable_auto_dial = $row[39]; + $SScountry_code_list_stats = $row[40]; + $SSfrozen_server_call_clear = $row[41]; + $SSactive_modules = $row[42]; + $SSallow_chats = $row[43]; + $SSenable_languages = $row[44]; + $SSlanguage_method = $row[45]; + $SSmeetme_enter_login_filename = $row[46]; + $SSmeetme_enter_leave3way_filename = $row[47]; + $SSenable_did_entry_list_id = $row[48]; + $SSenable_third_webform = $row[49]; + $SSdefault_language = $row[50]; + $SSuser_hide_realtime_enabled = $row[51]; + $SSlog_recording_access = $row[52]; + $SSalt_ivr_logging = $row[53]; + $SSadmin_row_click = $row[54]; + $SSadmin_screen_colors = $row[55]; + $SSofcom_uk_drop_calc = $row[56]; + $SSagent_screen_colors = $row[57]; + $SSscript_remove_js = $row[58]; + $SSmanual_auto_next = $row[59]; + $SSuser_new_lead_limit = $row[60]; + $SSagent_xfer_park_3way = $row[61]; + $SSagent_soundboards = $row[62]; + $SSweb_loader_phone_length = $row[63]; + $SSagent_script = $row[64]; + $SSenable_auto_reports = $row[65]; + $SSenable_pause_code_limits = $row[66]; + $SSenable_drop_lists = $row[67]; + $SSallow_ip_lists = $row[68]; + $SSsystem_ip_blacklist = $row[69]; + $SShide_inactive_lists = $row[70]; + $SSallow_manage_active_lists = $row[71]; + $SSexpired_lists_inactive = $row[72]; + $SSdid_system_filter = $row[73]; + $SSenable_gdpr_download_deletion = $row[74]; + } +##### END SETTINGS LOOKUP ##### +########################################### + +### populate pass_key if not set +if ( ($qm_conf_ct > 0) and (strlen($SSpass_key)<16) ) + { + $SSpass_key = ''; + $possible = "0123456789abcdefghijklmnpqrstvwxyzABCDEFGHIJKLMNPQRSTUVWXYZ"; + $i = 0; + $length = 16; + while ($i < $length) + { + $char = substr($possible, mt_rand(0, strlen($possible)-1), 1); + $SSpass_key .= $char; + $i++; + } + $stmt="UPDATE system_settings set pass_key='$SSpass_key' where ( (pass_key is NULL) or (pass_key='') );"; + $rslt=mysql_to_mysqli($stmt, $link); + } + +# make sure you have added a user to the vicidial_users MySQL table with at least user_level 9 to access this page the first time + +$STARTtime = date("U"); +$SQLdate = date("Y-m-d H:i:s"); +$REPORTdate = date("Y-m-d"); +$EXPtestdate = date("Ymd"); +$CIDdate = date("mdHis"); +while (strlen($CIDdate) > 9) {$CIDdate = substr("$CIDdate", 1);} + +$MT[0]=''; +$US='_'; +$active_lists=0; +$inactive_lists=0; +$modify_refresh_set=0; +$modify_footer_refresh=0; +$check_time = ($STARTtime - 86400); +$SSanswer_transfer_agent = '8368'; +$add_copy_disabled=0; + +$month_old = mktime(0, 0, 0, date("m")-1, date("d"), date("Y")); +$past_month_date = date("Y-m-d H:i:s",$month_old); +$week_old = mktime(0, 0, 0, date("m"), date("d")-7, date("Y")); +$past_week_date = date("Y-m-d H:i:s",$week_old); + +$dtmf[0]='0'; $dtmf_key[0]='0'; +$dtmf[1]='1'; $dtmf_key[1]='1'; +$dtmf[2]='2'; $dtmf_key[2]='2'; +$dtmf[3]='3'; $dtmf_key[3]='3'; +$dtmf[4]='4'; $dtmf_key[4]='4'; +$dtmf[5]='5'; $dtmf_key[5]='5'; +$dtmf[6]='6'; $dtmf_key[6]='6'; +$dtmf[7]='7'; $dtmf_key[7]='7'; +$dtmf[8]='8'; $dtmf_key[8]='8'; +$dtmf[9]='9'; $dtmf_key[9]='9'; +$dtmf[10]='HASH'; $dtmf_key[10]='#'; +$dtmf[11]='STAR'; $dtmf_key[11]='*'; +$dtmf[12]='A'; $dtmf_key[12]='A'; +$dtmf[13]='B'; $dtmf_key[13]='B'; +$dtmf[14]='C'; $dtmf_key[14]='C'; +$dtmf[15]='D'; $dtmf_key[15]='D'; +$dtmf[16]='TIMECHECK'; $dtmf_key[16]='TIMECHECK'; +$dtmf[17]='TIMEOUT'; $dtmf_key[17]='TIMEOUT'; +$dtmf[18]='INVALID'; $dtmf_key[18]='INVALID'; +$dtmf[19]='INVALID_2ND'; $dtmf_key[19]='INVALID_2ND'; +$dtmf[20]='INVALID_3RD'; $dtmf_key[20]='INVALID_3RD'; + +$stmt="SELECT selected_language from vicidial_users where user='$PHP_AUTH_USER';"; +if ($DB) {echo "|$stmt|\n";} +$rslt=mysql_to_mysqli($stmt, $link); +$sl_ct = mysqli_num_rows($rslt); +if ($sl_ct > 0) + { + $row=mysqli_fetch_row($rslt); + $VUselected_language = $row[0]; + } + +if ($force_logout) + { + if( (strlen($PHP_AUTH_USER)>0) or (strlen($PHP_AUTH_PW)>0) ) + { + Header("WWW-Authenticate: Basic realm=\"CONTACT-CENTER-ADMIN\""); + Header("HTTP/1.0 401 Unauthorized"); + } + echo _QXZ("You have now logged out. Thank you")."\n
"._QXZ("To log back in").", "._QXZ("click here").""; + exit; + } +############################################# +##### START SYSTEM_SETTINGS LOOKUP ##### +$stmt = "SELECT use_non_latin,auto_dial_limit,user_territories_active,allow_custom_dialplan,callcard_enabled,admin_modify_refresh,nocache_admin,webroot_writable,allow_emails,manual_dial_validation FROM system_settings;"; +$rslt=mysql_to_mysqli($stmt, $link); +if ($DB) {echo "$stmt\n";} +$qm_conf_ct = mysqli_num_rows($rslt); +if ($qm_conf_ct > 0) + { + $row=mysqli_fetch_row($rslt); + $non_latin = $row[0]; + $SSauto_dial_limit = $row[1]; + $SSuser_territories_active = $row[2]; + $SSallow_custom_dialplan = $row[3]; + $SScallcard_enabled = $row[4]; + $SSadmin_modify_refresh = $row[5]; + $SSnocache_admin = $row[6]; + $SSwebroot_writable = $row[7]; + $SSemail_enabled = $row[8]; + $SSmanual_dial_validation = $row[9]; + + # slightly increase limit value, because PHP somehow thinks 2.8 > 2.8 + $SSauto_dial_limit = ($SSauto_dial_limit + 0.001); + } +##### END SETTINGS LOOKUP ##### +########################################### + +$date = date("r"); +$ip = getenv("REMOTE_ADDR"); +$browser = getenv("HTTP_USER_AGENT"); + +$user_auth=0; +$auth=0; +$reports_auth=0; +$qc_auth=0; +$auth_message = user_authorization($PHP_AUTH_USER,$PHP_AUTH_PW,'QC',1,0); +if ($auth_message == 'GOOD') + {$user_auth=1;} + +if ($user_auth > 0) + { + $stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and user_level > 7 and api_only_user != '1';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_to_mysqli($stmt, $link); + $row=mysqli_fetch_row($rslt); + $auth=$row[0]; + + $stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and user_level > 6 and view_reports='1' and api_only_user != '1';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_to_mysqli($stmt, $link); + $row=mysqli_fetch_row($rslt); + $reports_auth=$row[0]; + + $stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and user_level > 1 and qc_enabled='1' and api_only_user != '1';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_to_mysqli($stmt, $link); + $row=mysqli_fetch_row($rslt); + $qc_auth=$row[0]; + + $reports_only_user=0; + $qc_only_user=0; + if ( ($reports_auth > 0) and ($auth < 1) ) + { + $ADD=999999; + $reports_only_user=1; + } + if ( ($qc_auth > 0) and ($reports_auth < 1) and ($auth < 1) ) + { + if ( ($ADD != '881') and ($ADD != '100000000000000') ) + { + $ADD=100000000000000; + } + $qc_only_user=1; + } + if ( ($qc_auth < 1) and ($reports_auth < 1) and ($auth < 1) ) + { + $VDdisplayMESSAGE = _QXZ("You do not have permission to be here"); + Header ("Content-type: text/html; charset=utf-8"); + echo "$VDdisplayMESSAGE: |$PHP_AUTH_USER|$auth_message|\n"; + exit; + } + } +else + { + $VDdisplayMESSAGE = _QXZ("Login incorrect, please try again"); + if ($auth_message == 'LOCK') + { + $VDdisplayMESSAGE = _QXZ("Too many login attempts, try again in 15 minutes"); + Header ("Content-type: text/html; charset=utf-8"); + echo "$VDdisplayMESSAGE: |$PHP_AUTH_USER|$auth_message|\n"; + exit; + } + if ($auth_message == 'IPBLOCK') + { + $VDdisplayMESSAGE = _QXZ("Your IP Address is not allowed") . ": $ip"; + Header ("Content-type: text/html; charset=utf-8"); + echo "$VDdisplayMESSAGE: |$PHP_AUTH_USER|$auth_message|\n"; + exit; + } + Header("WWW-Authenticate: Basic realm=\"CONTACT-CENTER-ADMIN\""); + Header("HTTP/1.0 401 Unauthorized"); + echo "$VDdisplayMESSAGE: |$PHP_AUTH_USER|$PHP_AUTH_PW|$auth_message|\n"; + exit; + } + +############### + +$stmt="SELECT user_id,user,pass,full_name,user_level,user_group,phone_login,phone_pass,delete_users,delete_user_groups,delete_lists,delete_campaigns,delete_ingroups,delete_remote_agents,load_leads,campaign_detail,ast_admin_access,ast_delete_phones,delete_scripts,modify_leads,hotkeys_active,change_agent_campaign,agent_choose_ingroups,closer_campaigns,scheduled_callbacks,agentonly_callbacks,agentcall_manual,vicidial_recording,vicidial_transfers,delete_filters,alter_agent_interface_options,closer_default_blended,delete_call_times,modify_call_times,modify_users,modify_campaigns,modify_lists,modify_scripts,modify_filters,modify_ingroups,modify_usergroups,modify_remoteagents,modify_servers,view_reports,vicidial_recording_override,alter_custdata_override,qc_enabled,qc_user_level,qc_pass,qc_finish,qc_commit,add_timeclock_log,modify_timeclock_log,delete_timeclock_log,alter_custphone_override,vdc_agent_api_access,modify_inbound_dids,delete_inbound_dids,active,alert_enabled,download_lists,agent_shift_enforcement_override,manager_shift_enforcement_override,shift_override_flag,export_reports,delete_from_dnc,email,user_code,territory,allow_alerts,callcard_admin,force_change_password,modify_shifts,modify_phones,modify_carriers,modify_labels,modify_statuses,modify_voicemail,modify_audiostore,modify_moh,modify_tts,modify_contacts,modify_same_user_level,alter_admin_interface_options,modify_custom_dialplans,modify_languages,selected_language,user_choose_language,modify_colors,api_only_user,modify_auto_reports,modify_ip_lists,export_gdpr_leads from vicidial_users where user='$PHP_AUTH_USER';"; +$rslt=mysql_to_mysqli($stmt, $link); +$row=mysqli_fetch_row($rslt); +$LOGfull_name =$row[3]; +$LOGuser_level =$row[4]; +$LOGuser_group =$row[5]; +$LOGdelete_users =$row[8]; +$LOGdelete_user_groups =$row[9]; +$LOGdelete_lists =$row[10]; +$LOGdelete_campaigns =$row[11]; +$LOGdelete_ingroups =$row[12]; +$LOGdelete_remote_agents =$row[13]; +$LOGload_leads =$row[14]; +$LOGcampaign_detail =$row[15]; +$LOGast_admin_access =$row[16]; +$LOGast_delete_phones =$row[17]; +$LOGdelete_scripts =$row[18]; +$LOGmodify_leads =$row[19]; +$LOGdelete_filters =$row[29]; +$LOGalter_agent_interface =$row[30]; +$LOGdelete_call_times =$row[32]; +$LOGmodify_call_times =$row[33]; +$LOGmodify_users =$row[34]; +$LOGmodify_campaigns =$row[35]; +$LOGmodify_lists =$row[36]; +$LOGmodify_scripts =$row[37]; +$LOGmodify_filters =$row[38]; +$LOGmodify_ingroups =$row[39]; +$LOGmodify_usergroups =$row[40]; +$LOGmodify_remoteagents =$row[41]; +$LOGmodify_servers =$row[42]; +$LOGview_reports =$row[43]; +$LOGmodify_dids =$row[56]; +$LOGdelete_dids =$row[57]; +$LOGmanager_shift_enforcement_override=$row[61]; +$LOGexport_reports =$row[64]; +$LOGdelete_from_dnc =$row[65]; +$LOGcallcard_admin =$row[70]; +$LOGforce_change_password =$row[71]; +$LOGmodify_shifts =$row[72]; +$LOGmodify_phones =$row[73]; +$LOGmodify_carriers =$row[74]; +$LOGmodify_labels =$row[75]; +$LOGmodify_statuses =$row[76]; +$LOGmodify_voicemail =$row[77]; +$LOGmodify_audiostore =$row[78]; +$LOGmodify_moh =$row[79]; +$LOGmodify_tts =$row[80]; +$LOGmodify_contacts =$row[81]; +$LOGmodify_same_user_level =$row[82]; +$LOGalter_admin_interface =$row[83]; +$LOGmodify_custom_dialplans =$row[84]; +$LOGmodify_languages =$row[85]; +$LOGselected_language =$row[86]; +$LOGuser_choose_language =$row[87]; +$LOGmodify_colors =$row[88]; +$LOGapi_only_user =$row[89]; +$LOGmodify_auto_reports =$row[90]; +$LOGmodify_ip_lists =$row[91]; +$LOGexport_gdpr_leads =$row[92]; + +$stmt="SELECT allowed_campaigns,allowed_reports,admin_viewable_groups,admin_viewable_call_times,qc_allowed_campaigns,qc_allowed_inbound_groups from vicidial_user_groups where user_group='$LOGuser_group';"; +$rslt=mysql_to_mysqli($stmt, $link); +$row=mysqli_fetch_row($rslt); +$LOGallowed_campaigns = $row[0]; +$LOGallowed_reports = $row[1]; +$LOGadmin_viewable_groups = $row[2]; +$LOGadmin_viewable_call_times = $row[3]; +$LOGqc_allowed_campaigns = $row[4]; +$LOGqc_allowed_inbound_groups = $row[5]; + +$LOGallowed_campaignsSQL=''; +$campLOGallowed_campaignsSQL=''; +$whereLOGallowed_campaignsSQL=''; +if ( (!preg_match('/\-ALL/i', $LOGallowed_campaigns)) ) + { + $rawLOGallowed_campaignsSQL = preg_replace("/ -/",'',$LOGallowed_campaigns); + $rawLOGallowed_campaignsSQL = preg_replace("/ /","','",$rawLOGallowed_campaignsSQL); + $LOGallowed_campaignsSQL = "and campaign_id IN('$rawLOGallowed_campaignsSQL')"; + $campLOGallowed_campaignsSQL = "and camp.campaign_id IN('$rawLOGallowed_campaignsSQL')"; + $whereLOGallowed_campaignsSQL = "where campaign_id IN('$rawLOGallowed_campaignsSQL')"; + } +$regexLOGallowed_campaigns = " $LOGallowed_campaigns "; + +if (preg_match("/DRA/",$SShosted_settings)) + {$LOGmodify_remoteagents=0;} + +$admin_viewable_groupsALL=0; +$LOGadmin_viewable_groupsSQL=''; +$whereLOGadmin_viewable_groupsSQL=''; +$valLOGadmin_viewable_groupsSQL=''; +$vmLOGadmin_viewable_groupsSQL=''; +if ( (!preg_match('/\-\-ALL\-\-/i',$LOGadmin_viewable_groups)) and (strlen($LOGadmin_viewable_groups) > 3) ) + { + $rawLOGadmin_viewable_groupsSQL = preg_replace("/ -/",'',$LOGadmin_viewable_groups); + $rawLOGadmin_viewable_groupsSQL = preg_replace("/ /","','",$rawLOGadmin_viewable_groupsSQL); + $LOGadmin_viewable_groupsSQL = "and user_group IN('---ALL---','$rawLOGadmin_viewable_groupsSQL')"; + $whereLOGadmin_viewable_groupsSQL = "where user_group IN('---ALL---','$rawLOGadmin_viewable_groupsSQL')"; + $valLOGadmin_viewable_groupsSQL = "and val.user_group IN('---ALL---','$rawLOGadmin_viewable_groupsSQL')"; + $vmLOGadmin_viewable_groupsSQL = "and vm.user_group IN('---ALL---','$rawLOGadmin_viewable_groupsSQL')"; + } +else + {$admin_viewable_groupsALL=1;} +$regexLOGadmin_viewable_groups = " $LOGadmin_viewable_groups "; + +$LOGadmin_viewable_call_timesSQL=''; +$whereLOGadmin_viewable_call_timesSQL=''; +if ( (!preg_match('/\-\-ALL\-\-/i', $LOGadmin_viewable_call_times)) and (strlen($LOGadmin_viewable_call_times) > 3) ) + { + $rawLOGadmin_viewable_call_timesSQL = preg_replace("/ -/",'',$LOGadmin_viewable_call_times); + $rawLOGadmin_viewable_call_timesSQL = preg_replace("/ /","','",$rawLOGadmin_viewable_call_timesSQL); + $LOGadmin_viewable_call_timesSQL = "and call_time_id IN('---ALL---','$rawLOGadmin_viewable_call_timesSQL')"; + $whereLOGadmin_viewable_call_timesSQL = "where call_time_id IN('---ALL---','$rawLOGadmin_viewable_call_timesSQL')"; + } +$regexLOGadmin_viewable_call_times = " $LOGadmin_viewable_call_times "; + +$UUgroups_list=''; +if ($admin_viewable_groupsALL > 0) + {$UUgroups_list .= "\n";} +$stmt="SELECT user_group,group_name from vicidial_user_groups $whereLOGadmin_viewable_groupsSQL order by user_group;"; +$rslt=mysql_to_mysqli($stmt, $link); +$UUgroups_to_print = mysqli_num_rows($rslt); +$o=0; +while ($UUgroups_to_print > $o) + { + $rowx=mysqli_fetch_row($rslt); + $UUgroups_list .= "\n"; + $o++; + } + +$LOGqc_allowed_campaignsSQL=''; +$whereLOGqc_allowed_campaignsSQL=''; +if ( (!preg_match('/\-ALL/i', $LOGqc_allowed_campaigns)) ) + { + $rawLOGqc_allowed_campaignsSQL = preg_replace("/ -/",'',$LOGqc_allowed_campaigns); + $rawLOGqc_allowed_campaignsSQL = preg_replace("/ /","','",$rawLOGqc_allowed_campaignsSQL); + $LOGqc_allowed_campaignsSQL = "and campaign_id IN('$rawLOGqc_allowed_campaignsSQL')"; + $whereLOGqc_allowed_campaignsSQL = "where campaign_id IN('$rawLOGqc_allowed_campaignsSQL')"; + } + +$LOGqc_allowed_inbound_groupsSQL=''; +$whereLOGqc_allowed_inbound_groupsSQL=''; +if ( (!preg_match('/\-ALL/i', $LOGqc_allowed_inbound_groups)) ) + { + $rawLOGqc_allowed_inbound_groupsSQL = preg_replace("/ -/",'',$LOGqc_allowed_inbound_groups); + $rawLOGqc_allowed_inbound_groupsSQL = preg_replace("/ /","','",$rawLOGqc_allowed_inbound_groupsSQL); + $LOGqc_allowed_inbound_groupsSQL = "and group_id IN('$rawLOGqc_allowed_inbound_groupsSQL')"; + $whereLOGqc_allowed_inbound_groupsSQL = "where group_id IN('$rawLOGqc_allowed_inbound_groupsSQL')"; + } + +$SSmenu_background='015B91'; +$SSframe_background='D9E6FE'; +$SSstd_row1_background='9BB9FB'; +$SSstd_row2_background='B9CBFD'; +$SSstd_row3_background='8EBCFD'; +$SSstd_row4_background='B6D3FC'; +$SSstd_row5_background='A3C3D6'; +$SSalt_row1_background='BDFFBD'; +$SSalt_row2_background='99FF99'; +$SSalt_row3_background='CCFFCC'; +$SSweb_logo='default_old'; + +if ($SSadmin_screen_colors != 'default') + { + $stmt = "SELECT menu_background,frame_background,std_row1_background,std_row2_background,std_row3_background,std_row4_background,std_row5_background,alt_row1_background,alt_row2_background,alt_row3_background,web_logo FROM vicidial_screen_colors where colors_id='$SSadmin_screen_colors';"; + $rslt=mysql_to_mysqli($stmt, $link); + if ($DB) {echo "$stmt\n";} + $colors_ct = mysqli_num_rows($rslt); + if ($colors_ct > 0) + { + $row=mysqli_fetch_row($rslt); + $SSmenu_background = $row[0]; + $SSframe_background = $row[1]; + $SSstd_row1_background = $row[2]; + $SSstd_row2_background = $row[3]; + $SSstd_row3_background = $row[4]; + $SSstd_row4_background = $row[5]; + $SSstd_row5_background = $row[6]; + $SSalt_row1_background = $row[7]; + $SSalt_row2_background = $row[8]; + $SSalt_row3_background = $row[9]; + $SSweb_logo = $row[10]; + } + } + +$Mhead_color = $SSstd_row5_background; +$Mmain_bgcolor = $SSmenu_background; +$Mhead_color = $SSstd_row5_background; + +if ($download_max_system_stats_metric_name) + { + if (!$query_date) {$query_date=date("Y-m-d", time()-(29*86400));} + if (!$end_date) + { + $end_date=date("Y-m-d", time()); + } + else if (strtotime($end_date)>strtotime(date("Y-m-d"))) + { + $end_date=date("Y-m-d"); + } + if ($query_date>$end_date) {$query_date=$end_date;} + + $num_graph_days = ceil(abs(strtotime($end_date) - strtotime($query_date)) / 86400)+1; + $CSV_text=""; + + if ($download_max_system_stats_metric_name=="ALL" || $download_max_system_stats_metric_name=="total call count in and out") + { + download_max_system_stats($campaign_id,$num_graph_days,'system','total_calls','total call count in and out',$end_date); + } + if ($download_max_system_stats_metric_name=="ALL" || $download_max_system_stats_metric_name=="total inbound call count") + { + download_max_system_stats($campaign_id,$num_graph_days,'system','total_calls_inbound_all','total inbound call count',$end_date); + } + if ($download_max_system_stats_metric_name=="ALL" || $download_max_system_stats_metric_name=="total outbound call count") + { + download_max_system_stats($campaign_id,$num_graph_days,'system','total_calls_outbound_all','total outbound call count',$end_date); + } + if ($download_max_system_stats_metric_name=="ALL" || $download_max_system_stats_metric_name=="most concurrent calls in and out") + { + download_max_system_stats($campaign_id,$num_graph_days,'system','(max_inbound + max_outbound)','most concurrent calls in and out',$end_date); + } + if ($download_max_system_stats_metric_name=="ALL" || $download_max_system_stats_metric_name=="most concurrent calls inbound total") + { + download_max_system_stats($campaign_id,$num_graph_days,'system','max_inbound','most concurrent calls inbound total',$end_date); + } + if ($download_max_system_stats_metric_name=="ALL" || $download_max_system_stats_metric_name=="most concurrent calls outbound total") + { + download_max_system_stats($campaign_id,$num_graph_days,'system','max_outbound','most concurrent calls outbound total',$end_date); + } + if ($download_max_system_stats_metric_name=="ALL" || $download_max_system_stats_metric_name=="most concurrent agents") + { + download_max_system_stats($campaign_id,$num_graph_days,'system','max_agents','most concurrent agents',$end_date); + } + + $FILE_TIME = date("Ymd-His"); + $CSVfilename = "MAX_SYSTEM_STATS_$US$FILE_TIME.csv"; + $CSV_text=preg_replace('/ +\"/', '"', $CSV_text); + $CSV_text=preg_replace('/\" +/', '"', $CSV_text); + header('Content-type: application/octet-stream'); + + header("Content-Disposition: attachment; filename=\"$CSVfilename\""); + header('Expires: 0'); + header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); + header('Pragma: public'); + ob_clean(); + flush(); + + echo "$CSV_text"; + + exit; + } + + +###################################################################################################### +###################################################################################################### +####### Header settings +###################################################################################################### +###################################################################################################### + + +header ("Content-type: text/html; charset=utf-8"); +if ($SSnocache_admin=='1') + { + header ("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1 + header ("Pragma: no-cache"); // HTTP/1.0 + } +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; + + +echo ""; + +echo "\n"; +echo "\n"; +echo "\n"; + + +if ($SSnocache_admin=='1') + { + echo "\n"; + echo "\n"; + echo "\n"; + } +if ( ($SSadmin_modify_refresh > 1) and (preg_match("/^3/",$ADD)) ) + { + $modify_refresh_set=1; + if (preg_match("/^3/",$ADD)) {$modify_url = "$PHP_SELF?$QUERY_STRING";} + echo "\n"; + } +echo ""._QXZ("ADMINISTRATION").": "; + +echo "\n"; + +echo "\n"; + + +### set the default screen to the user list +if ( (!isset($ADD)) or (strlen($ADD)<1) ) {$ADD="999990";} +if ($ADD=='0') {$ADD="999990";} + +$no_title=1; +$ADMIN=$PHP_SELF; +$android_header=1; +require("admin_header.php"); + + +echo "
"; + +###################### +# ADD=999990 - new main landing page with system stats +###################### +if ($ADD==999990) + { + if ( (preg_match("/Front Page System Summary/",$LOGallowed_reports)) or (preg_match("/ALL REPORTS/",$LOGallowed_reports)) ) + { + $stmt="SELECT closer_campaigns from vicidial_campaigns $whereLOGallowed_campaignsSQL;"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_to_mysqli($stmt, $link); + $row=mysqli_fetch_row($rslt); + $closer_campaigns = preg_replace("/^ | -$/","",$row[0]); + $closer_campaigns = preg_replace("/ /","','",$closer_campaigns); + $closer_campaigns = "'$closer_campaigns'"; + + $stmt="SELECT status from vicidial_auto_calls where status NOT IN('XFER') and ( (call_type='IN' and campaign_id IN($closer_campaigns)) or (call_type='OUT' $LOGallowed_campaignsSQL) );"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_to_mysqli($stmt, $link); + $active_calls=mysqli_num_rows($rslt); + $ringing_calls=0; + if ($active_calls>0) + { + while ($row=mysqli_fetch_row($rslt)) + { + if (!preg_match("/LIVE|CLOSER/i",$row[0])) + {$ringing_calls++;} + } + } + + $active_stmt="SELECT active from vicidial_users $whereLOGadmin_viewable_groupsSQL"; + if ($DB) {echo "|$active_stmt|\n";} + $active_rslt=mysql_to_mysqli($active_stmt, $link); + while ($active_row=mysqli_fetch_array($active_rslt)) + { + $users[$active_row["active"]]++; + } + + $active_stmt="SELECT active from vicidial_campaigns $whereLOGallowed_campaignsSQL"; + if ($DB) {echo "|$active_stmt|\n";} + $active_rslt=mysql_to_mysqli($active_stmt, $link); + while ($active_row=mysqli_fetch_array($active_rslt)) + { + $campaigns[$active_row["active"]]++; + } + + $active_stmt="SELECT active from vicidial_lists $whereLOGallowed_campaignsSQL"; + if ($DB) {echo "|$active_stmt|\n";} + $active_rslt=mysql_to_mysqli($active_stmt, $link); + while ($active_row=mysqli_fetch_array($active_rslt)) + { + $lists[$active_row["active"]]++; + } + + $active_stmt="SELECT did_active from vicidial_inbound_dids $whereLOGadmin_viewable_groupsSQL"; + if ($DB) {echo "|$active_stmt|\n";} + $active_rslt=mysql_to_mysqli($active_stmt, $link); + while ($active_row=mysqli_fetch_array($active_rslt)) + { + $dids[$active_row["did_active"]]++; + } + + $active_stmt="SELECT active from vicidial_inbound_groups $whereLOGadmin_viewable_groupsSQL"; + if ($DB) {echo "|$active_stmt|\n";} + $active_rslt=mysql_to_mysqli($active_stmt, $link); + while ($active_row=mysqli_fetch_array($active_rslt)) + { + $ingroups[$active_row["active"]]++; + } + + $stmt="SELECT extension,user,conf_exten,status,server_ip,UNIX_TIMESTAMP(last_call_time),UNIX_TIMESTAMP(last_call_finish),call_server_ip,campaign_id from vicidial_live_agents $whereLOGallowed_campaignsSQL"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_to_mysqli($stmt, $link); + $agent_incall=0; $agent_total=0; + while($row=mysqli_fetch_array($rslt)) + { + $status=$row[3]; + $agent_total++; + if ( (preg_match("/INCALL/i",$status)) or (preg_match("/QUEUE/i",$status)) ) {$agent_incall++; } + } + if (preg_match("/MXAG/",$SShosted_settings)) + { + $vla_set = $SShosted_settings; + $vla_set = preg_replace("/.*MXAG|_BUILD_|DRA|_MXCS\d+|_MXTR\d+| /",'',$vla_set); + $vla_set = preg_replace('/[^0-9]/','',$vla_set); + if (strlen($vla_set)>0) + { + $AAf=''; $AAb=''; + if ($agent_total >= $vla_set) + {$AAf=''; $AAb='';} + $agent_total = "$AAf$agent_total / $vla_set$AAb"; + } + } + + echo "
"; + + echo "
"; + + if ($LOGview_reports==1) + { + echo "
\n"; + echo ""; + echo ""._QXZ("Real-Time Reports")."
\n"; + echo "\n"; + echo "
\n"; + echo "
\n"; + } + + echo "\n"; + echo " 0) {echo " onclick=\"window.document.location='realtime_report_mobile.php?report_display_type=HTML';\"";} echo ">"; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo " 0) {echo " onclick=\"window.document.location='realtime_report_mobile.php?report_display_type=HTML';\"";} echo ">"; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo "
"._QXZ("Agents Logged In")."   "._QXZ("Agents In Calls")."   "._QXZ("Active Calls")."   "._QXZ("Calls Ringing")."
$agent_total$agent_incall$agent_incall$ringing_calls
"; + echo "

"; + + echo "\n"; + echo ""; + echo "
"; + echo ""; # style='width: 40vw; max-width: 350px;' + echo "
"; + + echo "

"; + + + echo "\n"; + echo ""; + echo ""; + echo ""; + + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + // New voicemailbox code + $stmt="(SELECT voicemail_id,count(*),messages,old_messages,'vm','vm' from vicidial_voicemail where on_login_report='Y' $LOGadmin_viewable_groupsSQL group by voicemail_id) UNION (SELECT voicemail_id,count(*),messages,old_messages,extension,server_ip from phones where on_login_report='Y' $LOGadmin_viewable_groupsSQL group by voicemail_id) order by voicemail_id;"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_to_mysqli($stmt, $link); + $vm_rows=mysqli_num_rows($rslt); + if ($vm_rows>0) + { + echo ""; + echo ""; # Padding + echo ""; + echo ""; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + while($row=mysqli_fetch_array($rslt)) + { + echo "\n"; + if ($row[4] == 'vm') + { + echo "\n"; + } + else + { + echo "\n"; + } + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + } + } + // End new voicemail box code + echo "
"._QXZ("System Summary").":
  "._QXZ("Records")."    "._QXZ("Active")."    "._QXZ("Inactive")."    "._QXZ("Total")."  
"._QXZ("Users").": ".($users["Y"]+0)."".($users["N"]+0)."".($users["Y"]+$users["N"]+0)."
"._QXZ("Campaigns").": ".($campaigns["Y"]+0)."".($campaigns["N"]+0)."".($campaigns["Y"]+$campaigns["N"]+0)."
"._QXZ("Lists").": ".($lists["Y"]+0)."".($lists["N"]+0)."".($lists["Y"]+$lists["N"]+0)."
"._QXZ("In-Groups").": ".($ingroups["Y"]+0)."".($ingroups["N"]+0)."".($ingroups["Y"]+$ingroups["N"]+0)."
"._QXZ("DIDs").": ".($dids["Y"]+0)."".($dids["N"]+0)."".($dids["Y"]+$dids["N"]+0)."
 
  Voicemail Box    New    Old    Total  
$row[0]:$row[0]:$row[2]$row[3]".($row[2]+$row[3])."
\n"; + + echo "
\n"; + + $today=date("Y-m-d"); + $yesterday=date("Y-m-d", mktime(0,0,0,date("m"),date("d")-1,date("Y"))); + $thirtydays=date("Y-m-d", mktime(0,0,0,date("m"),date("d")-29,date("Y"))); + + $total_calls=0; + $total_inbound=0; + $total_outbound=0; + $stmt="SELECT stats_type,sum(total_calls) from vicidial_daily_max_stats where campaign_id!='' and stats_flag='OPEN' and stats_date='$today' $LOGallowed_campaignsSQL group by stats_type;"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_to_mysqli($stmt, $link); + $rows_to_print = mysqli_num_rows($rslt); + if ($rows_to_print > 0) + { + while ($rowx=mysqli_fetch_row($rslt)) + { + $total_calls += $rowx[1]; + if (preg_match('/INGROUP/', $rowx[0])) {$total_inbound+=$rowx[1];} + if (preg_match('/CAMPAIGN/', $rowx[0])) {$total_outbound+=$rowx[1];} + } + } + + $stmt="SELECT * from vicidial_daily_max_stats where stats_date='$today' and stats_flag='OPEN' and stats_type='TOTAL' $LOGallowed_campaignsSQL order by stats_date, campaign_id asc"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_to_mysqli($stmt, $link); + echo "
\n"; + echo ""; + echo ""; +# echo ""; + echo ""; + echo ""; + # echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + + if (mysqli_num_rows($rslt)>0) + { + while ($row=mysqli_fetch_array($rslt)) + { + echo ""; + # echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + } + } + else + { + echo ""; + echo ""; + echo ""; + } + echo "
"._QXZ("Total Stats for Today").":["._QXZ("view max stats")."]
CAMPAIGN ID  "._QXZ("Total Calls")."    "._QXZ("Total Inbound Calls")."    "._QXZ("Total Outbound Calls")."    "._QXZ("Maximum Agents")."  
".$row["campaign_id"]."".($total_calls+0)."".($total_inbound+0)."".($total_outbound+0)."".($row["max_agents"]+0)."
*** "._QXZ("NO ACTIVITY FOR")." $today ***
\n"; + + $total_calls=0; + $total_inbound=0; + $total_outbound=0; + $stmt="SELECT stats_type,sum(total_calls) from vicidial_daily_max_stats where campaign_id!='' and stats_flag='CLOSED' and stats_date='$yesterday' $LOGallowed_campaignsSQL group by stats_type;"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_to_mysqli($stmt, $link); + $rows_to_print = mysqli_num_rows($rslt); + if ($rows_to_print > 0) + { + while ($rowx=mysqli_fetch_row($rslt)) + { + $total_calls += $rowx[1]; + if (preg_match('/INGROUP/', $rowx[0])) {$total_inbound+=$rowx[1];} + if (preg_match('/CAMPAIGN/', $rowx[0])) {$total_outbound+=$rowx[1];} + } + } + + echo "
\n"; + echo ""; + echo ""; + # echo ""; + echo ""; + echo ""; + # echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + + $stmt="SELECT * from vicidial_daily_max_stats where stats_date='$yesterday' and stats_type='TOTAL' $LOGallowed_campaignsSQL order by stats_date, campaign_id asc"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_to_mysqli($stmt, $link); + if (mysqli_num_rows($rslt)>0) + { + while ($row=mysqli_fetch_array($rslt)) + { + echo ""; + #echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + } + } + else + { + echo ""; + echo ""; + echo ""; + } + + echo "

"; + } + else + { + $section_width=640; + echo "
"; + echo "
"._QXZ("Total Stats for Yesterday").":["._QXZ("view max stats")."]
CAMPAIGN ID  "._QXZ("Total Calls")."    "._QXZ("Total Inbound Calls")."    "._QXZ("Total Outbound Calls")."    "._QXZ("Maximum Agents")."  
".$row["campaign_id"]."".($row["total_calls"]+0)." / ".($total_calls+0)."".($total_inbound+0)."".($total_outbound+0)."".($row["max_agents"]+0)."
*** "._QXZ("NO ACTIVITY FOR")." $today ***
\n"; + echo ""; + echo ""; + echo ""; + + echo "

"; + } + } + +echo "
"._QXZ("Welcome")."
\n"; + +#### GRAPHS #### + + echo "
"; + + echo "\n"; + echo ""; + echo ""; + echo "
"; + echo ""; + echo "
"; + + +echo "
\n"; + +$ENDtime = date("U"); + +$RUNtime = ($ENDtime - $STARTtime); + +echo "
\n"; +echo "

"; +echo _QXZ("VERSION").": $admin_version
"; +echo _QXZ("BUILD").": $build\n"; +if (!preg_match("/_BUILD_/",$SShosted_settings)) + {echo "
© 2019 ViciDial Group
";} +echo "
\n"; +?> + +
> +
+ + + + + 1) and ($modify_footer_refresh > 0) and (strlen($modify_url)>10) ) ) + { + echo "\n"; + if ($SSnocache_admin=='1') + { + echo "\n"; + echo "\n"; + echo "\n"; + } + if ( ($SSadmin_modify_refresh > 1) and ($modify_footer_refresh > 0) and (strlen($modify_url)>10) ) + { + echo "\n"; + } + echo "\n"; + } + +echo "\n"; + + +exit; + + +##### CALCULATE COMPLETE LEADS ##### +function complete_leads($DB,$link,$dial_statuses,$camp_lists,$call_count_limit,$single_status,$campaign_id) +{ +if (isset($camp_lists)) + { + if (strlen($camp_lists)>1) + { + if (strlen($dial_statuses)>2) + { + $dial_statuses = preg_replace("/ -$/","",$dial_statuses); + $Dstatuses = explode(" ", $dial_statuses); + $Ds_to_print = (count($Dstatuses) - 0); + $Dsql = ''; + $o=0; + while ($Ds_to_print > $o) + { + $o++; + $Dsql .= "'$Dstatuses[$o]',"; + } + $Dsql = preg_replace("/,$/","",$Dsql); + if (strlen($Dsql) < 2) {$Dsql = "''";} + + $CCLsql = "(called_count < 0) or"; + if ($call_count_limit > 0) + {$CCLsql = "(called_count >= $call_count_limit) or";} + + $complete_statuses=''; + $stmt="SELECT status from vicidial_statuses where completed='Y';"; + $rslt=mysql_to_mysqli($stmt, $link); + $statuses_to_print = mysqli_num_rows($rslt); + $q=0; + while ($statuses_to_print > $q) + { + $rowx=mysqli_fetch_row($rslt); + $complete_statuses.="'$rowx[0]',"; + $q++; + } + $stmt="SELECT status from vicidial_campaign_statuses where completed='Y' $LOGallowed_campaignsSQL;"; + $rslt=mysql_to_mysqli($stmt, $link); + $statuses_to_print = mysqli_num_rows($rslt); + $q=0; + while ($statuses_to_print > $q) + { + $rowx=mysqli_fetch_row($rslt); + $complete_statuses.="'$rowx[0]',"; + $q++; + } + $complete_statuses = preg_replace("/,$/","",$complete_statuses); + if (strlen($complete_statuses) < 2) {$complete_statuses = "''";} + $CSsql = "status IN($complete_statuses)"; + + $stmt="SELECT count(*) FROM vicidial_list where ( (status IN($Dsql)) and (list_id IN($camp_lists)) and ( $CCLsql ($CSsql) ) );"; + #$DB=1; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_to_mysqli($stmt, $link); + $rslt_rows = mysqli_num_rows($rslt); + if ($rslt_rows) + { + $rowx=mysqli_fetch_row($rslt); + $complete_leads = $rowx[0]; + } + else {$complete_leads = '0';} + + if ($DB > 0) {echo "|$DB|\n";} + if ($single_status > 0) + {return $complete_leads;} + else + {echo "There are $complete_leads completed leads in those lists\n";} + } + else + { + echo _QXZ("no dial statuses selected for this campaign")."\n"; + } + } + else + { + echo _QXZ("no active lists selected for this campaign")."\n"; + } + } +else + { + echo _QXZ("no active lists selected for this campaign")."\n"; + } +} + + +##### CALCULATE DIALABLE LEADS ##### +function dialable_leads($DB,$link,$local_call_time,$dial_statuses,$camp_lists,$drop_lockout_time,$call_count_limit,$single_status,$fSQL) +{ +##### BEGIN calculate what gmt_offset_now values are within the allowed local_call_time setting ### +if (isset($camp_lists)) + { + if (strlen($camp_lists)>1) + { + if (strlen($dial_statuses)>2) + { + $g=0; + $p='13'; + $GMT_gmt[0] = ''; + $GMT_hour[0] = ''; + $GMT_day[0] = ''; + $YMD = date("Y-m-d"); + while ($p > -13) + { + $pzone=3600 * $p; + $pmin=(gmdate("i", time() + $pzone)); + $phour=( (gmdate("G", time() + $pzone)) * 100); + $pday=gmdate("w", time() + $pzone); + $tz = sprintf("%.2f", $p); + $GMT_gmt[$g] = "$tz"; + $GMT_day[$g] = "$pday"; + $GMT_hour[$g] = ($phour + $pmin); + $p = ($p - 0.25); + $g++; + } + + $stmt="SELECT call_time_id,call_time_name,call_time_comments,ct_default_start,ct_default_stop,ct_sunday_start,ct_sunday_stop,ct_monday_start,ct_monday_stop,ct_tuesday_start,ct_tuesday_stop,ct_wednesday_start,ct_wednesday_stop,ct_thursday_start,ct_thursday_stop,ct_friday_start,ct_friday_stop,ct_saturday_start,ct_saturday_stop,ct_state_call_times FROM vicidial_call_times where call_time_id='$local_call_time';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_to_mysqli($stmt, $link); + $rowx=mysqli_fetch_row($rslt); + $Gct_default_start = $rowx[3]; + $Gct_default_stop = $rowx[4]; + $Gct_sunday_start = $rowx[5]; + $Gct_sunday_stop = $rowx[6]; + $Gct_monday_start = $rowx[7]; + $Gct_monday_stop = $rowx[8]; + $Gct_tuesday_start = $rowx[9]; + $Gct_tuesday_stop = $rowx[10]; + $Gct_wednesday_start = $rowx[11]; + $Gct_wednesday_stop = $rowx[12]; + $Gct_thursday_start = $rowx[13]; + $Gct_thursday_stop = $rowx[14]; + $Gct_friday_start = $rowx[15]; + $Gct_friday_stop = $rowx[16]; + $Gct_saturday_start = $rowx[17]; + $Gct_saturday_stop = $rowx[18]; + $Gct_state_call_times = $rowx[19]; + $Gct_holidays = $rowx[20]; + + ### BEGIN Check for outbound holiday ### + $holiday_id = ''; + if (strlen($Gct_holidays)>2) + { + $Gct_holidaysSQL = preg_replace("/\|/", "','", "$Gct_holidays"); + $Gct_holidaysSQL = "'".$Gct_holidaysSQL."'"; + + $stmt = "SELECT holiday_id,holiday_date,holiday_name,ct_default_start,ct_default_stop from vicidial_call_time_holidays where holiday_id IN($Gct_holidaysSQL) and holiday_status='ACTIVE' and holiday_date='$YMD' order by holiday_id;"; + $rslt=mysql_to_mysqli($stmt, $link); + if ($DB) {echo "$stmt\n";} + $sthCrows=mysqli_num_rows($rslt); + if ($sthCrows > 0) + { + $aryC=mysqli_fetch_row($rslt); + $holiday_id = $aryC[0]; + $holiday_date = $aryC[1]; + $holiday_name = $aryC[2]; + if($Gct_default_start < $aryC[3]) {$Gct_default_start = $aryC[3];} + if($Gct_default_stop > $aryC[4]) {$Gct_default_stop = $aryC[4];} + if($Gct_sunday_start < $aryC[3]) {$Gct_sunday_start = $aryC[3];} + if($Gct_sunday_stop > $aryC[4]) {$Gct_sunday_stop = $aryC[4];} + if($Gct_monday_start < $aryC[3]) {$Gct_monday_start = $aryC[3];} + if($Gct_monday_stop > $aryC[4]) {$Gct_monday_stop = $aryC[4];} + if($Gct_tuesday_start < $aryC[3]) {$Gct_tuesday_start = $aryC[3];} + if($Gct_tuesday_stop > $aryC[4]) {$Gct_tuesday_stop = $aryC[4];} + if($Gct_wednesday_start < $aryC[3]) {$Gct_wednesday_start = $aryC[3];} + if($Gct_wednesday_stop > $aryC[4]) {$Gct_wednesday_stop = $aryC[4];} + if($Gct_thursday_start < $aryC[3]) {$Gct_thursday_start = $aryC[3];} + if($Gct_thursday_stop > $aryC[4]) {$Gct_thursday_stop = $aryC[4];} + if($Gct_friday_start < $aryC[3]) {$Gct_friday_start = $aryC[3];} + if($Gct_friday_stop > $aryC[4]) {$Gct_friday_stop = $aryC[4];} + if($Gct_saturday_start < $aryC[3]) {$Gct_saturday_start = $aryC[3];} + if($Gct_saturday_stop > $aryC[4]) {$Gct_saturday_stop = $aryC[4];} + if ($DB) {echo "CALL TIME HOLIDAY FOUND! $local_call_time|$holiday_id|$holiday_date|$holiday_name|$Gct_default_start|$Gct_default_stop|\n";} + } + } + ### END Check for outbound holiday ### + + $ct_states = ''; + $ct_state_gmt_SQL = ''; + $ct_srs=0; + $b=0; + if (strlen($Gct_state_call_times)>2) + { + $state_rules = explode('|',$Gct_state_call_times); + $ct_srs = ((count($state_rules)) - 2); + } + while($ct_srs >= $b) + { + if (strlen($state_rules[$b])>1) + { + $stmt="SELECT state_call_time_id,state_call_time_state,state_call_time_name,state_call_time_comments,sct_default_start,sct_default_stop,sct_sunday_start,sct_sunday_stop,sct_monday_start,sct_monday_stop,sct_tuesday_start,sct_tuesday_stop,sct_wednesday_start,sct_wednesday_stop,sct_thursday_start,sct_thursday_stop,sct_friday_start,sct_friday_stop,sct_saturday_start,sct_saturday_stop from vicidial_state_call_times where state_call_time_id='$state_rules[$b]';"; + $rslt=mysql_to_mysqli($stmt, $link); + $row=mysqli_fetch_row($rslt); + $Gstate_call_time_id = $row[0]; + $Gstate_call_time_state = $row[1]; + $Gsct_default_start = $row[4]; + $Gsct_default_stop = $row[5]; + $Gsct_sunday_start = $row[6]; + $Gsct_sunday_stop = $row[7]; + $Gsct_monday_start = $row[8]; + $Gsct_monday_stop = $row[9]; + $Gsct_tuesday_start = $row[10]; + $Gsct_tuesday_stop = $row[11]; + $Gsct_wednesday_start = $row[12]; + $Gsct_wednesday_stop = $row[13]; + $Gsct_thursday_start = $row[14]; + $Gsct_thursday_stop = $row[15]; + $Gsct_friday_start = $row[16]; + $Gsct_friday_stop = $row[17]; + $Gsct_saturday_start = $row[18]; + $Gsct_saturday_stop = $row[19]; + $Sct_holidays = $row[20]; + $ct_states .="'$Gstate_call_time_state',"; + + ### BEGIN Check for outbound state holiday ### + $Sholiday_id = ''; + if ((strlen($Sct_holidays)>2) or ((strlen($holiday_id)>2) and (strlen($Sholiday_id)<2))) + { + # Apply state holiday + if (strlen($Sct_holidays)>2) + { + $Sct_holidaysSQL = preg_replace("/\|/", "','", "$Sct_holidays"); + $Sct_holidaysSQL = "'".$Sct_holidaysSQL."'"; + $stmt = "SELECT holiday_id,holiday_date,holiday_name,ct_default_start,ct_default_stop from vicidial_call_time_holidays where holiday_id IN($Sct_holidaysSQL) and holiday_status='ACTIVE' and holiday_date='$YMD' order by holiday_id;"; + $holidaytype = "STATE CALL TIME HOLIDAY FOUND! "; + } + # Apply call time wide holiday + elseif ((strlen($holiday_id)>2) and (strlen($Sholiday_id)<2)) + { + $stmt = "SELECT holiday_id,holiday_date,holiday_name,ct_default_start,ct_default_stop from vicidial_call_time_holidays where holiday_id='$holiday_id' and holiday_status='ACTIVE' and holiday_date='$YMD' order by holiday_id;"; + $holidaytype = "NO STATE HOLIDAY APPLYING CALL TIME HOLIDAY! "; + } + $rslt=mysql_to_mysqli($stmt, $link); + if ($DB) {echo "$stmt\n";} + $sthCrows=mysqli_num_rows($rslt); + if ($sthCrows > 0) + { + $aryC=mysqli_fetch_row($rslt); + $Sholiday_id = $aryC[0]; + $Sholiday_date = $aryC[1]; + $Sholiday_name = $aryC[2]; + if ( ($Gsct_default_start < $aryC[3]) && ($Gsct_default_stop > 0) ) {$Gsct_default_start = $aryC[3];} + if ( ($Gsct_default_stop > $aryC[4]) && ($Gsct_default_stop > 0) ) {$Gsct_default_stop = $aryC[4];} + if ( ($Gsct_sunday_start < $aryC[3]) && ($Gsct_sunday_stop > 0) ) {$Gsct_sunday_start = $aryC[3];} + if ( ($Gsct_sunday_stop > $aryC[4]) && ($Gsct_sunday_stop > 0) ) {$Gsct_sunday_stop = $aryC[4];} + if ( ($Gsct_monday_start < $aryC[3]) && ($Gsct_monday_stop > 0) ) {$Gsct_monday_start = $aryC[3];} + if ( ($Gsct_monday_stop > $aryC[4]) && ($Gsct_monday_stop > 0) ) {$Gsct_monday_stop = $aryC[4];} + if ( ($Gsct_tuesday_start < $aryC[3]) && ($Gsct_tuesday_stop > 0) ) {$Gsct_tuesday_start = $aryC[3];} + if ( ($Gsct_tuesday_stop > $aryC[4]) && ($Gsct_tuesday_stop > 0) ) {$Gsct_tuesday_stop = $aryC[4];} + if ( ($Gsct_wednesday_start < $aryC[3]) && ($Gsct_wednesday_stop > 0) ) {$Gsct_wednesday_start = $aryC[3];} + if ( ($Gsct_wednesday_stop > $aryC[4]) && ($Gsct_wednesday_stop > 0) ) {$Gsct_wednesday_stop = $aryC[4];} + if ( ($Gsct_thursday_start < $aryC[3]) && ($Gsct_thursday_stop > 0) ) {$Gsct_thursday_start = $aryC[3];} + if ( ($Gsct_thursday_stop > $aryC[4]) && ($Gsct_thursday_stop > 0) ) {$Gsct_thursday_stop = $aryC[4];} + if ( ($Gsct_friday_start < $aryC[3]) && ($Gsct_friday_stop > 0) ) {$Gsct_friday_start = $aryC[3];} + if ( ($Gsct_friday_stop > $aryC[4]) && ($Gsct_friday_stop > 0) ) {$Gsct_friday_stop = $aryC[4];} + if ( ($Gsct_saturday_start < $aryC[3]) && ($Gsct_saturday_stop > 0) ) {$Gsct_saturday_start = $aryC[3];} + if ( ($Gsct_saturday_stop > $aryC[4]) && ($Gsct_saturday_stop > 0) ) {$Gsct_saturday_stop = $aryC[4];} + if ($DB) {echo "$holidaytype |$Gstate_call_time_id|$Gstate_call_time_state|$Sholiday_id|$Sholiday_date|$Sholiday_name|$Gsct_default_start|$Gsct_default_stop|\n";} + } + } + $r=0; + $state_gmt=''; + while($r < $g) + { + if ($GMT_day[$r]==0) #### Sunday local time + { + if (($Gsct_sunday_start==0) and ($Gsct_sunday_stop==0)) + { + if ( ($GMT_hour[$r]>=$Gsct_default_start) and ($GMT_hour[$r]<$Gsct_default_stop) ) + {$state_gmt.="'$GMT_gmt[$r]',";} + } + else + { + if ( ($GMT_hour[$r]>=$Gsct_sunday_start) and ($GMT_hour[$r]<$Gsct_sunday_stop) ) + {$state_gmt.="'$GMT_gmt[$r]',";} + } + } + if ($GMT_day[$r]==1) #### Monday local time + { + if (($Gsct_monday_start==0) and ($Gsct_monday_stop==0)) + { + if ( ($GMT_hour[$r]>=$Gsct_default_start) and ($GMT_hour[$r]<$Gsct_default_stop) ) + {$state_gmt.="'$GMT_gmt[$r]',";} + } + else + { + if ( ($GMT_hour[$r]>=$Gsct_monday_start) and ($GMT_hour[$r]<$Gsct_monday_stop) ) + {$state_gmt.="'$GMT_gmt[$r]',";} + } + } + if ($GMT_day[$r]==2) #### Tuesday local time + { + if (($Gsct_tuesday_start==0) and ($Gsct_tuesday_stop==0)) + { + if ( ($GMT_hour[$r]>=$Gsct_default_start) and ($GMT_hour[$r]<$Gsct_default_stop) ) + {$state_gmt.="'$GMT_gmt[$r]',";} + } + else + { + if ( ($GMT_hour[$r]>=$Gsct_tuesday_start) and ($GMT_hour[$r]<$Gsct_tuesday_stop) ) + {$state_gmt.="'$GMT_gmt[$r]',";} + } + } + if ($GMT_day[$r]==3) #### Wednesday local time + { + if (($Gsct_wednesday_start==0) and ($Gsct_wednesday_stop==0)) + { + if ( ($GMT_hour[$r]>=$Gsct_default_start) and ($GMT_hour[$r]<$Gsct_default_stop) ) + {$state_gmt.="'$GMT_gmt[$r]',";} + } + else + { + if ( ($GMT_hour[$r]>=$Gsct_wednesday_start) and ($GMT_hour[$r]<$Gsct_wednesday_stop) ) + {$state_gmt.="'$GMT_gmt[$r]',";} + } + } + if ($GMT_day[$r]==4) #### Thursday local time + { + if (($Gsct_thursday_start==0) and ($Gsct_thursday_stop==0)) + { + if ( ($GMT_hour[$r]>=$Gsct_default_start) and ($GMT_hour[$r]<$Gsct_default_stop) ) + {$state_gmt.="'$GMT_gmt[$r]',";} + } + else + { + if ( ($GMT_hour[$r]>=$Gsct_thursday_start) and ($GMT_hour[$r]<$Gsct_thursday_stop) ) + {$state_gmt.="'$GMT_gmt[$r]',";} + } + } + if ($GMT_day[$r]==5) #### Friday local time + { + if (($Gsct_friday_start==0) and ($Gsct_friday_stop==0)) + { + if ( ($GMT_hour[$r]>=$Gsct_default_start) and ($GMT_hour[$r]<$Gsct_default_stop) ) + {$state_gmt.="'$GMT_gmt[$r]',";} + } + else + { + if ( ($GMT_hour[$r]>=$Gsct_friday_start) and ($GMT_hour[$r]<$Gsct_friday_stop) ) + {$state_gmt.="'$GMT_gmt[$r]',";} + } + } + if ($GMT_day[$r]==6) #### Saturday local time + { + if (($Gsct_saturday_start==0) and ($Gsct_saturday_stop==0)) + { + if ( ($GMT_hour[$r]>=$Gsct_default_start) and ($GMT_hour[$r]<$Gsct_default_stop) ) + {$state_gmt.="'$GMT_gmt[$r]',";} + } + else + { + if ( ($GMT_hour[$r]>=$Gsct_saturday_start) and ($GMT_hour[$r]<$Gsct_saturday_stop) ) + {$state_gmt.="'$GMT_gmt[$r]',";} + } + } + $r++; + } + $state_gmt = "$state_gmt'99'"; + $ct_state_gmt_SQL .= "or (state='$Gstate_call_time_state' and gmt_offset_now IN($state_gmt)) "; + } + + $b++; + } + if (strlen($ct_states)>2) + { + $ct_states = preg_replace('/,$/i', '',$ct_states); + $ct_statesSQL = "and state NOT IN($ct_states)"; + } + else + { + $ct_statesSQL = ""; + } + + $r=0; + $default_gmt=''; + while($r < $g) + { + if ($GMT_day[$r]==0) #### Sunday local time + { + if (($Gct_sunday_start==0) and ($Gct_sunday_stop==0)) + { + if ( ($GMT_hour[$r]>=$Gct_default_start) and ($GMT_hour[$r]<$Gct_default_stop) ) + {$default_gmt.="'$GMT_gmt[$r]',";} + } + else + { + if ( ($GMT_hour[$r]>=$Gct_sunday_start) and ($GMT_hour[$r]<$Gct_sunday_stop) ) + {$default_gmt.="'$GMT_gmt[$r]',";} + } + } + if ($GMT_day[$r]==1) #### Monday local time + { + if (($Gct_monday_start==0) and ($Gct_monday_stop==0)) + { + if ( ($GMT_hour[$r]>=$Gct_default_start) and ($GMT_hour[$r]<$Gct_default_stop) ) + {$default_gmt.="'$GMT_gmt[$r]',";} + } + else + { + if ( ($GMT_hour[$r]>=$Gct_monday_start) and ($GMT_hour[$r]<$Gct_monday_stop) ) + {$default_gmt.="'$GMT_gmt[$r]',";} + } + } + if ($GMT_day[$r]==2) #### Tuesday local time + { + if (($Gct_tuesday_start==0) and ($Gct_tuesday_stop==0)) + { + if ( ($GMT_hour[$r]>=$Gct_default_start) and ($GMT_hour[$r]<$Gct_default_stop) ) + {$default_gmt.="'$GMT_gmt[$r]',";} + } + else + { + if ( ($GMT_hour[$r]>=$Gct_tuesday_start) and ($GMT_hour[$r]<$Gct_tuesday_stop) ) + {$default_gmt.="'$GMT_gmt[$r]',";} + } + } + if ($GMT_day[$r]==3) #### Wednesday local time + { + if (($Gct_wednesday_start==0) and ($Gct_wednesday_stop==0)) + { + if ( ($GMT_hour[$r]>=$Gct_default_start) and ($GMT_hour[$r]<$Gct_default_stop) ) + {$default_gmt.="'$GMT_gmt[$r]',";} + } + else + { + if ( ($GMT_hour[$r]>=$Gct_wednesday_start) and ($GMT_hour[$r]<$Gct_wednesday_stop) ) + {$default_gmt.="'$GMT_gmt[$r]',";} + } + } + if ($GMT_day[$r]==4) #### Thursday local time + { + if (($Gct_thursday_start==0) and ($Gct_thursday_stop==0)) + { + if ( ($GMT_hour[$r]>=$Gct_default_start) and ($GMT_hour[$r]<$Gct_default_stop) ) + {$default_gmt.="'$GMT_gmt[$r]',";} + } + else + { + if ( ($GMT_hour[$r]>=$Gct_thursday_start) and ($GMT_hour[$r]<$Gct_thursday_stop) ) + {$default_gmt.="'$GMT_gmt[$r]',";} + } + } + if ($GMT_day[$r]==5) #### Friday local time + { + if (($Gct_friday_start==0) and ($Gct_friday_stop==0)) + { + if ( ($GMT_hour[$r]>=$Gct_default_start) and ($GMT_hour[$r]<$Gct_default_stop) ) + {$default_gmt.="'$GMT_gmt[$r]',";} + } + else + { + if ( ($GMT_hour[$r]>=$Gct_friday_start) and ($GMT_hour[$r]<$Gct_friday_stop) ) + {$default_gmt.="'$GMT_gmt[$r]',";} + } + } + if ($GMT_day[$r]==6) #### Saturday local time + { + if (($Gct_saturday_start==0) and ($Gct_saturday_stop==0)) + { + if ( ($GMT_hour[$r]>=$Gct_default_start) and ($GMT_hour[$r]<$Gct_default_stop) ) + {$default_gmt.="'$GMT_gmt[$r]',";} + } + else + { + if ( ($GMT_hour[$r]>=$Gct_saturday_start) and ($GMT_hour[$r]<$Gct_saturday_stop) ) + {$default_gmt.="'$GMT_gmt[$r]',";} + } + } + $r++; + } + + $default_gmt = "$default_gmt'99'"; + $all_gmtSQL = "(gmt_offset_now IN($default_gmt) $ct_statesSQL) $ct_state_gmt_SQL"; + + $dial_statuses = preg_replace("/ -$/","",$dial_statuses); + $Dstatuses = explode(" ", $dial_statuses); + $Ds_to_print = (count($Dstatuses) - 0); + $Dsql = ''; + $o=0; + while ($Ds_to_print > $o) + { + $o++; + $Dsql .= "'$Dstatuses[$o]',"; + } + $Dsql = preg_replace("/,$/","",$Dsql); + if (strlen($Dsql) < 2) {$Dsql = "''";} + + $DLTsql=''; + if ($drop_lockout_time > 0) + { + $DLseconds = ($drop_lockout_time * 3600); + $DLseconds = floor($DLseconds); + $DLseconds = intval("$DLseconds"); + $DLTsql = "and ( ( (status IN('DROP','XDROP')) and (last_local_call_time < CONCAT(DATE_ADD(NOW(), INTERVAL -$DLseconds SECOND),' ',CURTIME()) ) ) or (status NOT IN('DROP','XDROP')) )"; + } + + $CCLsql=''; + if ($call_count_limit > 0) + { + $CCLsql = "and (called_count < $call_count_limit)"; + } + + $EXPsql=''; + $expired_lists=''; + $REPORTdate = date("Y-m-d"); + $stmt="SELECT list_id FROM vicidial_lists where list_id IN($camp_lists) and (active='Y') and (expiration_date < \"$REPORTdate\");"; + #$DB=1; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_to_mysqli($stmt, $link); + $rslt_rows = mysqli_num_rows($rslt); + $f=0; + while ($rslt_rows > $f) + { + $rowx=mysqli_fetch_row($rslt); + $expired_lists .= "'$rowx[0]',"; + $f++; + } + $expired_lists = preg_replace("/,$/",'',$expired_lists); + if (strlen($expired_lists) < 2) {$expired_lists = "''";} + $EXPsql = "and list_id NOT IN($expired_lists)"; + + + ################################# + # Camp List + $stmt="SELECT list_id FROM vicidial_lists where list_id IN($camp_lists) and active='Y';"; + $rslt_list=mysql_to_mysqli($stmt, $link); + $camplists_ct = mysqli_num_rows($rslt_list); + if ($DB) {echo "$camplists_ct|$stmt\n";} + $k=0; + $camp_lists=''; + while ($camplists_ct > $k) + { + $rowA = mysqli_fetch_row($rslt_list); + $camp_lists .= "'$rowA[0]',"; + + ##### Get Call List call time settings + ##### BEGIN calculate what gmt_offset_now values are within the allowed local_call_time setting ### + $g=0; + $p='13'; + $GMT_gmt[0] = ''; + $GMT_hour[0] = ''; + $GMT_day[0] = ''; + $YMD = date("Y-m-d"); + while ($p > -13) + { + $pzone=3600 * $p; + $pmin=(gmdate("i", time() + $pzone)); + $phour=( (gmdate("G", time() + $pzone)) * 100); + $pday=gmdate("w", time() + $pzone); + $tz = sprintf("%.2f", $p); + $GMT_gmt[$g] = "$tz"; + $GMT_day[$g] = "$pday"; + $GMT_hour[$g] = ($phour + $pmin); + $p = ($p - 0.25); + $g++; + } + + # Set List ID Variable + $cur_list_id = $rowA[0]; + $list_local_call_time = ""; + + # Pull the call times for the lists + $stmt="SELECT local_call_time FROM vicidial_lists where list_id='$cur_list_id';"; + $rslt=mysql_to_mysqli($stmt, $link); + $rslt_ct = mysqli_num_rows($rslt); + if ($rslt_ct > 0) + { + #set Cur call_time + $row=mysqli_fetch_row($rslt); + $cur_call_time = $row[0]; + } + + # check that call time exists + if ($cur_call_time != "campaign") + { + $stmt="SELECT count(*) from vicidial_call_times where call_time_id='$cur_call_time';"; + $rslt=mysql_to_mysqli($stmt, $link); + $row=mysqli_fetch_row($rslt); + $call_time_exists = $row[0]; + if ($call_time_exists < 1) + {$cur_call_time = 'campaign';} + } + + ##### BEGIN local call time for list set different than campaign ##### + if ($cur_call_time != "campaign") + { + ##### BEGIN calculate what gmt_offset_now values are within the allowed local_call_time setting ### + $stmt = "SELECT call_time_id,call_time_name,call_time_comments,ct_default_start,ct_default_stop,ct_sunday_start,ct_sunday_stop,ct_monday_start,ct_monday_stop,ct_tuesday_start,ct_tuesday_stop,ct_wednesday_start,ct_wednesday_stop,ct_thursday_start,ct_thursday_stop,ct_friday_start,ct_friday_stop,ct_saturday_start,ct_saturday_stop,ct_state_call_times,ct_holidays FROM vicidial_call_times where call_time_id='$cur_call_time';"; + if ($DB) {echo "$stmt\n";} + $rsltD=mysql_to_mysqli($stmt, $link); + $aryD=mysqli_fetch_row($rsltD); + $Gct_default_start = $aryD[3]; + $Gct_default_stop = $aryD[4]; + $Gct_sunday_start = $aryD[5]; + $Gct_sunday_stop = $aryD[6]; + $Gct_monday_start = $aryD[7]; + $Gct_monday_stop = $aryD[8]; + $Gct_tuesday_start = $aryD[9]; + $Gct_tuesday_stop = $aryD[10]; + $Gct_wednesday_start = $aryD[11]; + $Gct_wednesday_stop = $aryD[12]; + $Gct_thursday_start = $aryD[13]; + $Gct_thursday_stop = $aryD[14]; + $Gct_friday_start = $aryD[15]; + $Gct_friday_stop = $aryD[16]; + $Gct_saturday_start = $aryD[17]; + $Gct_saturday_stop = $aryD[18]; + $Gct_state_call_times = $aryD[19]; + $Gct_holidays = $aryD[20]; + + ### BEGIN Check for outbound holiday ### + $holiday_id = ''; + if (strlen($Gct_holidays)>2) + { + $Gct_holidaysSQL = preg_replace("/\|/", "','", "$Gct_holidays"); + $Gct_holidaysSQL = "'".$Gct_holidaysSQL."'"; + + $stmt = "SELECT holiday_id,holiday_date,holiday_name,ct_default_start,ct_default_stop from vicidial_call_time_holidays where holiday_id IN($Gct_holidaysSQL) and holiday_status='ACTIVE' and holiday_date='$YMD' order by holiday_id;"; + $rslt=mysql_to_mysqli($stmt, $link); + $sthCrows=mysqli_num_rows($rslt); + if ($sthCrows > 0) + { + $aryC=mysqli_fetch_row($rslt); + $holiday_id = $aryC[0]; + $holiday_date = $aryC[1]; + $holiday_name = $aryC[2]; + if ( ($Gct_default_start < $aryC[3]) && ($Gct_default_stop > 0) ) {$Gct_default_start = $aryC[3];} + if ( ($Gct_default_stop > $aryC[4]) && ($Gct_default_stop > 0) ) {$Gct_default_stop = $aryC[4];} + if ( ($Gct_sunday_start < $aryC[3]) && ($Gct_sunday_stop > 0) ) {$Gct_sunday_start = $aryC[3];} + if ( ($Gct_sunday_stop > $aryC[4]) && ($Gct_sunday_stop > 0) ) {$Gct_sunday_stop = $aryC[4];} + if ( ($Gct_monday_start < $aryC[3]) && ($Gct_monday_stop > 0) ) {$Gct_monday_start = $aryC[3];} + if ( ($Gct_monday_stop > $aryC[4]) && ($Gct_monday_stop > 0) ) {$Gct_monday_stop = $aryC[4];} + if ( ($Gct_tuesday_start < $aryC[3]) && ($Gct_tuesday_stop > 0) ) {$Gct_tuesday_start = $aryC[3];} + if ( ($Gct_tuesday_stop > $aryC[4]) && ($Gct_tuesday_stop > 0) ) {$Gct_tuesday_stop = $aryC[4];} + if ( ($Gct_wednesday_start < $aryC[3]) && ($Gct_wednesday_stop > 0) ) {$Gct_wednesday_start = $aryC[3];} + if ( ($Gct_wednesday_stop > $aryC[4]) && ($Gct_wednesday_stop > 0) ) {$Gct_wednesday_stop = $aryC[4];} + if ( ($Gct_thursday_start < $aryC[3]) && ($Gct_thursday_stop > 0) ) {$Gct_thursday_start = $aryC[3];} + if ( ($Gct_thursday_stop > $aryC[4]) && ($Gct_thursday_stop > 0) ) {$Gct_thursday_stop = $aryC[4];} + if ( ($Gct_friday_start < $aryC[3]) && ($Gct_friday_stop > 0) ) {$Gct_friday_start = $aryC[3];} + if ( ($Gct_friday_stop > $aryC[4]) && ($Gct_friday_stop > 0) ) {$Gct_friday_stop = $aryC[4];} + if ( ($Gct_saturday_start < $aryC[3]) && ($Gct_saturday_stop > 0) ) {$Gct_saturday_start = $aryC[3];} + if ( ($Gct_saturday_stop > $aryC[4]) && ($Gct_saturday_stop > 0) ) {$Gct_saturday_stop = $aryC[4];} + if ($DB) {echo "LIST CALL TIME HOLIDAY FOUND! $local_call_time|$holiday_id|$holiday_date|$holiday_name|$Gct_default_start|$Gct_default_stop|\n";} + } + } + ### END Check for outbound holiday ### + + $ct_states = ''; + $ct_state_gmt_SQL = ''; + $ct_srs=0; + $b=0; + if (strlen($Gct_state_call_times)>2) + { + $state_rules = explode('|',$Gct_state_call_times); + $ct_srs = ((count($state_rules)) - 2); + } + while($ct_srs >= $b) + { + if (strlen($state_rules[$b])>1) + { + $stmt = "SELECT state_call_time_id,state_call_time_state,state_call_time_name,state_call_time_comments,sct_default_start,sct_default_stop,sct_sunday_start,sct_sunday_stop,sct_monday_start,sct_monday_stop,sct_tuesday_start,sct_tuesday_stop,sct_wednesday_start,sct_wednesday_stop,sct_thursday_start,sct_thursday_stop,sct_friday_start,sct_friday_stop,sct_saturday_start,sct_saturday_stop,ct_holidays from vicidial_state_call_times where state_call_time_id='$state_rules[$b]';"; + $rslt=mysql_to_mysqli($stmt, $link); + $sthCrows=mysqli_num_rows($rslt); + if ($sthCrows > 0) + { + $aryC=mysqli_fetch_row($rslt); + $Gstate_call_time_id = $aryC[0]; + $Gstate_call_time_state = $aryC[1]; + $Gsct_default_start = $aryC[4]; + $Gsct_default_stop = $aryC[5]; + $Gsct_sunday_start = $aryC[6]; + $Gsct_sunday_stop = $aryC[7]; + $Gsct_monday_start = $aryC[8]; + $Gsct_monday_stop = $aryC[9]; + $Gsct_tuesday_start = $aryC[10]; + $Gsct_tuesday_stop = $aryC[11]; + $Gsct_wednesday_start = $aryC[12]; + $Gsct_wednesday_stop = $aryC[13]; + $Gsct_thursday_start = $aryC[14]; + $Gsct_thursday_stop = $aryC[15]; + $Gsct_friday_start = $aryC[16]; + $Gsct_friday_stop = $aryC[17]; + $Gsct_saturday_start = $aryC[18]; + $Gsct_saturday_stop = $aryC[19]; + $Sct_holidays = $aryC[20]; + $ct_states .="'$Gstate_call_time_state',"; + } + + ### BEGIN Check for outbound state holiday ### + $Sholiday_id = ''; + if ((strlen($Sct_holidays)>2) or ((strlen($holiday_id)>2) and (strlen($Sholiday_id)<2))) + { + #Apply state holiday + if (strlen($Sct_holidays)>2) + { + $Sct_holidaysSQL = preg_replace("/\|/", "','", "$Sct_holidays"); + $Sct_holidaysSQL = "'".$Sct_holidaysSQL."'"; + $stmt = "SELECT holiday_id,holiday_date,holiday_name,ct_default_start,ct_default_stop from vicidial_call_time_holidays where holiday_id IN($Sct_holidaysSQL) and holiday_status='ACTIVE' and holiday_date='$YMD' order by holiday_id;"; + $holidaytype = "LIST STATE CALL TIME HOLIDAY FOUND! "; + } + #Apply call time wide holiday + elseif ((strlen($holiday_id)>2) and (strlen($Sholiday_id)<2)) + { + $stmt = "SELECT holiday_id,holiday_date,holiday_name,ct_default_start,ct_default_stop from vicidial_call_time_holidays where holiday_id='$holiday_id' and holiday_status='ACTIVE' and holiday_date='$YMD' order by holiday_id;"; + $holidaytype = "LIST NO STATE HOLIDAY APPLYING CALL TIME HOLIDAY! "; + } + $rslt=mysql_to_mysqli($stmt, $link); + if ($DB) {echo "$stmt\n";} + $sthCrows=mysqli_num_rows($rslt); + if ($sthCrows > 0) + { + $aryC=mysqli_fetch_row($rslt); + $Sholiday_id = $aryC[0]; + $Sholiday_date = $aryC[1]; + $Sholiday_name = $aryC[2]; + if ( ($Gsct_default_start < $aryC[3]) && ($Gsct_default_stop > 0) ) {$Gsct_default_start = $aryC[3];} + if ( ($Gsct_default_stop > $aryC[4]) && ($Gsct_default_stop > 0) ) {$Gsct_default_stop = $aryC[4];} + if ( ($Gsct_sunday_start < $aryC[3]) && ($Gsct_sunday_stop > 0) ) {$Gsct_sunday_start = $aryC[3];} + if ( ($Gsct_sunday_stop > $aryC[4]) && ($Gsct_sunday_stop > 0) ) {$Gsct_sunday_stop = $aryC[4];} + if ( ($Gsct_monday_start < $aryC[3]) && ($Gsct_monday_stop > 0) ) {$Gsct_monday_start = $aryC[3];} + if ( ($Gsct_monday_stop > $aryC[4]) && ($Gsct_monday_stop > 0) ) {$Gsct_monday_stop = $aryC[4];} + if ( ($Gsct_tuesday_start < $aryC[3]) && ($Gsct_tuesday_stop > 0) ) {$Gsct_tuesday_start = $aryC[3];} + if ( ($Gsct_tuesday_stop > $aryC[4]) && ($Gsct_tuesday_stop > 0) ) {$Gsct_tuesday_stop = $aryC[4];} + if ( ($Gsct_wednesday_start < $aryC[3]) && ($Gsct_wednesday_stop > 0) ) {$Gsct_wednesday_start = $aryC[3];} + if ( ($Gsct_wednesday_stop > $aryC[4]) && ($Gsct_wednesday_stop > 0) ) {$Gsct_wednesday_stop = $aryC[4];} + if ( ($Gsct_thursday_start < $aryC[3]) && ($Gsct_thursday_stop > 0) ) {$Gsct_thursday_start = $aryC[3];} + if ( ($Gsct_thursday_stop > $aryC[4]) && ($Gsct_thursday_stop > 0) ) {$Gsct_thursday_stop = $aryC[4];} + if ( ($Gsct_friday_start < $aryC[3]) && ($Gsct_friday_stop > 0) ) {$Gsct_friday_start = $aryC[3];} + if ( ($Gsct_friday_stop > $aryC[4]) && ($Gsct_friday_stop > 0) ) {$Gsct_friday_stop = $aryC[4];} + if ( ($Gsct_saturday_start < $aryC[3]) && ($Gsct_saturday_stop > 0) ) {$Gsct_saturday_start = $aryC[3];} + if ( ($Gsct_saturday_stop > $aryC[4]) && ($Gsct_saturday_stop > 0) ) {$Gsct_saturday_stop = $aryC[4];} + if ($DB) {echo "$holidaytype |$Gstate_call_time_id|$Gstate_call_time_state|$Sholiday_id|$Sholiday_date|$Sholiday_name|$Gsct_default_start|$Gsct_default_stop|\n";} + } + } + ### END Check for outbound state holiday ### + + $r=0; + $state_gmt=''; + $del_state_gmt=''; + while($r < $g) + { + if ($GMT_day[$r]==0) #### Sunday local time + { + if (($Gsct_sunday_start==0) && ($Gsct_sunday_stop==0)) + { + if ( ($GMT_hour[$r]>=$Gsct_default_start) && ($GMT_hour[$r]<$Gsct_default_stop) ) + {$state_gmt.="'$GMT_gmt[$r]',";} + } + else + { + if ( ($GMT_hour[$r]>=$Gsct_sunday_start) && ($GMT_hour[$r]<$Gsct_sunday_stop) ) + {$state_gmt.="'$GMT_gmt[$r]',";} + } + } + if ($GMT_day[$r]==1) #### Monday local time + { + if (($Gsct_monday_start==0) && ($Gsct_monday_stop==0)) + { + if ( ($GMT_hour[$r]>=$Gsct_default_start) && ($GMT_hour[$r]<$Gsct_default_stop) ) + {$state_gmt.="'$GMT_gmt[$r]',";} + } + else + { + if ( ($GMT_hour[$r]>=$Gsct_monday_start) && ($GMT_hour[$r]<$Gsct_monday_stop) ) + {$state_gmt.="'$GMT_gmt[$r]',";} + } + } + if ($GMT_day[$r]==2) #### Tuesday local time + { + if (($Gsct_tuesday_start==0) && ($Gsct_tuesday_stop==0)) + { + if ( ($GMT_hour[$r]>=$Gsct_default_start) && ($GMT_hour[$r]<$Gsct_default_stop) ) + {$state_gmt.="'$GMT_gmt[$r]',";} + } + else + { + if ( ($GMT_hour[$r]>=$Gsct_tuesday_start) && ($GMT_hour[$r]<$Gsct_tuesday_stop) ) + {$state_gmt.="'$GMT_gmt[$r]',";} + } + } + if ($GMT_day[$r]==3) #### Wednesday local time + { + if (($Gsct_wednesday_start==0) && ($Gsct_wednesday_stop==0)) + { + if ( ($GMT_hour[$r]>=$Gsct_default_start) && ($GMT_hour[$r]<$Gsct_default_stop) ) + {$state_gmt.="'$GMT_gmt[$r]',";} + } + else + { + if ( ($GMT_hour[$r]>=$Gsct_wednesday_start) && ($GMT_hour[$r]<$Gsct_wednesday_stop) ) + {$state_gmt.="'$GMT_gmt[$r]',";} + } + } + if ($GMT_day[$r]==4) #### Thursday local time + { + if (($Gsct_thursday_start==0) && ($Gsct_thursday_stop==0)) + { + if ( ($GMT_hour[$r]>=$Gsct_default_start) && ($GMT_hour[$r]<$Gsct_default_stop) ) + {$state_gmt.="'$GMT_gmt[$r]',";} + } + else + { + if ( ($GMT_hour[$r]>=$Gsct_thursday_start) && ($GMT_hour[$r]<$Gsct_thursday_stop) ) + {$state_gmt.="'$GMT_gmt[$r]',";} + } + } + if ($GMT_day[$r]==5) #### Friday local time + { + if (($Gsct_friday_start==0) && ($Gsct_friday_stop==0)) + { + if ( ($GMT_hour[$r]>=$Gsct_default_start) && ($GMT_hour[$r]<$Gsct_default_stop) ) + {$state_gmt.="'$GMT_gmt[$r]',";} + } + else + { + if ( ($GMT_hour[$r]>=$Gsct_friday_start) && ($GMT_hour[$r]<$Gsct_friday_stop) ) + {$state_gmt.="'$GMT_gmt[$r]',";} + } + } + if ($GMT_day[$r]==6) #### Saturday local time + { + if (($Gsct_saturday_start==0) && ($Gsct_saturday_stop==0)) + { + if ( ($GMT_hour[$r]>=$Gsct_default_start) && ($GMT_hour[$r]<$Gsct_default_stop) ) + {$state_gmt.="'$GMT_gmt[$r]',";} + } + else + { + if ( ($GMT_hour[$r]>=$Gsct_saturday_start) && ($GMT_hour[$r]<$Gsct_saturday_stop) ) + {$state_gmt.="'$GMT_gmt[$r]',";} + } + } + $r++; + } + $state_gmt = "$state_gmt'99'"; + + $del_list_state_gmt_SQL .= "or (List_id=\"$cur_list_id\" and state='$Gstate_call_time_state' and gmt_offset_now NOT IN($state_gmt)) "; + $list_state_gmt_SQL .= "or (List_id=\"$cur_list_id\" and state='$Gstate_call_time_state' and gmt_offset_now IN($state_gmt)) "; + } + + $b++; + } + if (strlen($ct_states)>2) + { + $ct_states = preg_replace("/,$/i",'',$ct_states); + $ct_statesSQL = "and state NOT IN($ct_states)"; + } + else + { + $ct_statesSQL = ""; + } + + $r=0; + $dgA=0; + $list_default_gmt=''; + while($r < $g) + { + if ($DB > 0) + {echo "LCT_gmt: $r|$GMT_day[$r]|$GMT_gmt[$r]|$Gct_sunday_start|$Gct_sunday_stop|$GMT_hour[$r]|$Gct_default_start|$Gct_default_stop\n";} + + if ($GMT_day[$r]==0) #### Sunday local time + { + if (($Gct_sunday_start==0) && ($Gct_sunday_stop==0)) + { + if ( ($GMT_hour[$r]>=$Gct_default_start) && ($GMT_hour[$r]<$Gct_default_stop) ) + {} + else + {$list_default_gmt.="'$GMT_gmt[$r]',";} + } + else + { + if ( ($GMT_hour[$r]>=$Gct_sunday_start) && ($GMT_hour[$r]<$Gct_sunday_stop) ) + {} + else + {$list_default_gmt.="'$GMT_gmt[$r]',";} + } + } + if ($GMT_day[$r]==1) #### Monday local time + { + if (($Gct_monday_start==0) && ($Gct_monday_stop==0)) + { + if ( ($GMT_hour[$r]>=$Gct_default_start) && ($GMT_hour[$r]<$Gct_default_stop) ) + {} + else + {$list_default_gmt.="'$GMT_gmt[$r]',";} + } + else + { + if ( ($GMT_hour[$r]>=$Gct_monday_start) && ($GMT_hour[$r]<$Gct_monday_stop) ) + {} + else + {$list_default_gmt.="'$GMT_gmt[$r]',";} + } + } + if ($GMT_day[$r]==2) #### Tuesday local time + { + if (($Gct_tuesday_start==0) && ($Gct_tuesday_stop==0)) + { + if ( ($GMT_hour[$r]>=$Gct_default_start) && ($GMT_hour[$r]<$Gct_default_stop) ) + {} + else + {$list_default_gmt.="'$GMT_gmt[$r]',";} + } + else + { + if ( ($GMT_hour[$r]>=$Gct_tuesday_start) && ($GMT_hour[$r]<$Gct_tuesday_stop) ) + {} + else + {$list_default_gmt.="'$GMT_gmt[$r]',";} + } + } + if ($GMT_day[$r]==3) #### Wednesday local time + { + if (($Gct_wednesday_start==0) && ($Gct_wednesday_stop==0)) + { + if ( ($GMT_hour[$r]>=$Gct_default_start) && ($GMT_hour[$r]<$Gct_default_stop) ) + {} + else + {$list_default_gmt.="'$GMT_gmt[$r]',";} + } + else + { + if ( ($GMT_hour[$r]>=$Gct_wednesday_start) && ($GMT_hour[$r]<$Gct_wednesday_stop) ) + {} + else + {$list_default_gmt.="'$GMT_gmt[$r]',";} + } + } + if ($GMT_day[$r]==4) #### Thursday local time + { + if (($Gct_thursday_start==0) && ($Gct_thursday_stop==0)) + { + if ( ($GMT_hour[$r]>=$Gct_default_start) && ($GMT_hour[$r]<$Gct_default_stop) ) + {} + else + {$list_default_gmt.="'$GMT_gmt[$r]',";} + } + else + { + if ( ($GMT_hour[$r]>=$Gct_thursday_start) && ($GMT_hour[$r]<$Gct_thursday_stop) ) + {} + else + {$list_default_gmt.="'$GMT_gmt[$r]',";} + } + } + if ($GMT_day[$r]==5) #### Friday local time + { + if (($Gct_friday_start==0) && ($Gct_friday_stop==0)) + { + if ( ($GMT_hour[$r]>=$Gct_default_start) && ($GMT_hour[$r]<$Gct_default_stop) ) + {} + else + {$list_default_gmt.="'$GMT_gmt[$r]',";} + } + else + { + if ( ($GMT_hour[$r]>=$Gct_friday_start) && ($GMT_hour[$r]<$Gct_friday_stop) ) + {} + else + {$list_default_gmt.="'$GMT_gmt[$r]',";} + } + } + if ($GMT_day[$r]==6) #### Saturday local time + { + if (($Gct_saturday_start==0) && ($Gct_saturday_stop==0)) + { + if ( ($GMT_hour[$r]>=$Gct_default_start) && ($GMT_hour[$r]<$Gct_default_stop) ) + {} + else + {$list_default_gmt.="'$GMT_gmt[$r]',";} + } + else + { + if ( ($GMT_hour[$r]>=$Gct_saturday_start) && ($GMT_hour[$r]<$Gct_saturday_stop) ) + {} + else + {$list_default_gmt.="'$GMT_gmt[$r]',";} + } + } + $r++; + } + + $list_default_gmt = "$list_default_gmt'99'"; + $LCTlist_id_sql .= " or ((list_id='$cur_list_id' and gmt_offset_now NOT IN($list_default_gmt) $ct_statesSQL) $list_state_gmt_SQL)"; + } + ##### END local call time for list set different than campaign ##### + + else + { + if (strlen($list_id_sql) < 3) + { + $list_id_sql = "(list_id IN('$cur_list_id'"; + } + else + { + $list_id_sql .= ",'$cur_list_id'"; + } + } + + $k++; + } + $camp_lists = preg_replace("/.$/i","",$camp_lists); + if (strlen($camp_lists) < 4) {$camp_lists="''";} + if (strlen($list_id_sql) < 4) {$list_id_sql="list_id=''";} + else {$list_id_sql .= '))';} + if (strlen($LCTlist_id_sql) > 1) {$list_id_sql .= "$LCTlist_id_sql";} + + + $stmt="SELECT count(*) FROM vicidial_list where called_since_last_reset='N' and status IN($Dsql) and list_id IN($camp_lists) and ($list_id_sql) and ($all_gmtSQL) $CCLsql $DLTsql $fSQL $EXPsql"; + #$DB=1; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_to_mysqli($stmt, $link); + $rslt_rows = mysqli_num_rows($rslt); + if ($rslt_rows) + { + $rowx=mysqli_fetch_row($rslt); + $active_leads = "$rowx[0]"; + } + else {$active_leads = '0';} + + if ($DB > 0) {echo "|$DB|\n";} + if ($single_status > 0) + {return $active_leads;} + else + {echo _QXZ("This campaign has")." $active_leads "._QXZ("leads to be dialed in those lists")."\n";} + } + else + { + echo _QXZ("no dial statuses selected for this campaign")."\n"; + } + } + else + { + echo _QXZ("no active lists selected for this campaign")."\n"; + } + } +else + { + echo _QXZ("no active lists selected for this campaign")."\n"; + } +##### END calculate what gmt_offset_now values are within the allowed local_call_time setting ### +} +?> diff --git a/www/vicidial/campaign_summary_mobile_report.php b/www/vicidial/campaign_summary_mobile_report.php new file mode 100644 index 00000000..bf5a6378 --- /dev/null +++ b/www/vicidial/campaign_summary_mobile_report.php @@ -0,0 +1,629 @@ +, Joe Johnson LICENSE: AGPLv2 +# +# Back-end PHP script that generates text output to be interpreted by AST_timeonVDADallSUMMARY_mobile.php +# +# STOP=4000, SLOW=40, GO=4 seconds refresh interval +# +# changes: +# +# 181212-2329 - Initial build +# + +require("dbconnect_mysqli.php"); +require("functions.php"); + +$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER']; +$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW']; +$PHP_SELF=$_SERVER['PHP_SELF']; +if (isset($_GET["RR"])) {$RR=$_GET["RR"];} + elseif (isset($_POST["RR"])) {$RR=$_POST["RR"];} +if (isset($_GET["DB"])) {$DB=$_GET["DB"];} + elseif (isset($_POST["DB"])) {$DB=$_POST["DB"];} +if (isset($_GET["adastats"])) {$adastats=$_GET["adastats"];} + elseif (isset($_POST["adastats"])) {$adastats=$_POST["adastats"];} +if (isset($_GET["types"])) {$types=$_GET["types"];} + elseif (isset($_POST["types"])) {$types=$_POST["types"];} +if (isset($_GET["current_displayed_report"])) {$current_displayed_report=$_GET["current_displayed_report"];} + elseif (isset($_POST["current_displayed_report"])) {$current_displayed_report=$_POST["current_displayed_report"];} +if (isset($_GET["submit"])) {$submit=$_GET["submit"];} + elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];} +if (isset($_GET["SUBMIT"])) {$SUBMIT=$_GET["SUBMIT"];} + elseif (isset($_POST["SUBMIT"])) {$SUBMIT=$_POST["SUBMIT"];} +if (isset($_GET["file_download"])) {$file_download=$_GET["file_download"];} + elseif (isset($_POST["file_download"])) {$file_download=$_POST["file_download"];} +if (isset($_GET["browser_dimension"])) {$browser_dimension=$_GET["browser_dimension"];} + elseif (isset($_POST["browser_dimension"])) {$browser_dimension=$_POST["browser_dimension"];} + +############################################# +##### START SYSTEM_SETTINGS LOOKUP ##### +$stmt = "SELECT use_non_latin,outbound_autodial_active,slave_db_server,reports_use_slave_db,enable_languages,language_method FROM system_settings;"; +$rslt=mysql_to_mysqli($stmt, $link); +if ($DB) {$MAIN.="$stmt\n";} +$qm_conf_ct = mysqli_num_rows($rslt); +if ($qm_conf_ct > 0) + { + $row=mysqli_fetch_row($rslt); + $non_latin = $row[0]; + $outbound_autodial_active = $row[1]; + $slave_db_server = $row[2]; + $reports_use_slave_db = $row[3]; + $SSenable_languages = $row[4]; + $SSlanguage_method = $row[5]; + } +##### END SETTINGS LOOKUP ##### +########################################### + +if ( (strlen($slave_db_server)>5) and (preg_match("/$report_name/",$reports_use_slave_db)) ) + { + mysqli_close($link); + $use_slave_server=1; + $db_source = 'S'; + require("dbconnect_mysqli.php"); + $MAIN.="\n"; + } + +if ($non_latin < 1) + { + $PHP_AUTH_USER = preg_replace('/[^-_0-9a-zA-Z]/', '', $PHP_AUTH_USER); + $PHP_AUTH_PW = preg_replace('/[^-_0-9a-zA-Z]/', '', $PHP_AUTH_PW); + } +else + { + $PHP_AUTH_PW = preg_replace("/'|\"|\\\\|;/","",$PHP_AUTH_PW); + $PHP_AUTH_USER = preg_replace("/'|\"|\\\\|;/","",$PHP_AUTH_USER); + } + +$stmt="SELECT selected_language from vicidial_users where user='$PHP_AUTH_USER';"; +if ($DB) {echo "|$stmt|\n";} +$rslt=mysql_to_mysqli($stmt, $link); +$sl_ct = mysqli_num_rows($rslt); +if ($sl_ct > 0) + { + $row=mysqli_fetch_row($rslt); + $VUselected_language = $row[0]; + } + +$auth=0; +$reports_auth=0; +$admin_auth=0; +$auth_message = user_authorization($PHP_AUTH_USER,$PHP_AUTH_PW,'REPORTS',1,0); +if ($auth_message == 'GOOD') + {$auth=1;} + +if ($auth > 0) + { + $stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and user_level > 7 and view_reports='1';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_to_mysqli($stmt, $link); + $row=mysqli_fetch_row($rslt); + $admin_auth=$row[0]; + + $stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and user_level > 6 and view_reports='1';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_to_mysqli($stmt, $link); + $row=mysqli_fetch_row($rslt); + $reports_auth=$row[0]; + + if ($reports_auth < 1) + { + $VDdisplayMESSAGE = _QXZ("You are not allowed to view reports"); + Header ("Content-type: text/html; charset=utf-8"); + echo "$VDdisplayMESSAGE: |$PHP_AUTH_USER|$auth_message|\n"; + exit; + } + if ( ($reports_auth > 0) and ($admin_auth < 1) ) + { + $ADD=999999; + $reports_only_user=1; + } + } +else + { + $VDdisplayMESSAGE = _QXZ("Login incorrect, please try again"); + if ($auth_message == 'LOCK') + { + $VDdisplayMESSAGE = _QXZ("Too many login attempts, try again in 15 minutes"); + Header ("Content-type: text/html; charset=utf-8"); + echo "$VDdisplayMESSAGE: |$PHP_AUTH_USER|$auth_message|\n"; + exit; + } + if ($auth_message == 'IPBLOCK') + { + $VDdisplayMESSAGE = _QXZ("Your IP Address is not allowed") . ": $ip"; + Header ("Content-type: text/html; charset=utf-8"); + echo "$VDdisplayMESSAGE: |$PHP_AUTH_USER|$auth_message|\n"; + exit; + } + Header("WWW-Authenticate: Basic realm=\"CONTACT-CENTER-ADMIN\""); + Header("HTTP/1.0 401 Unauthorized"); + echo "$VDdisplayMESSAGE: |$PHP_AUTH_USER|$PHP_AUTH_PW|$auth_message|\n"; + exit; + } + +$stmt="SELECT user_group from vicidial_users where user='$PHP_AUTH_USER';"; +if ($DB) {$MAIN.="|$stmt|\n";} +$rslt=mysql_to_mysqli($stmt, $link); +$row=mysqli_fetch_row($rslt); +$LOGuser_group = $row[0]; + +$stmt="SELECT allowed_campaigns,allowed_reports from vicidial_user_groups where user_group='$LOGuser_group';"; +if ($DB) {$MAIN.="|$stmt|\n";} +$rslt=mysql_to_mysqli($stmt, $link); +$row=mysqli_fetch_row($rslt); +$LOGallowed_campaigns = $row[0]; +$LOGallowed_reports = $row[1]; + +if ( (!preg_match("/$report_name/",$LOGallowed_reports)) and (!preg_match("/ALL REPORTS/",$LOGallowed_reports)) ) + { + Header("WWW-Authenticate: Basic realm=\"CONTACT-CENTER-ADMIN\""); + Header("HTTP/1.0 401 Unauthorized"); + echo _QXZ("You are not allowed to view this report").": |$PHP_AUTH_USER|$report_name|"._QXZ("$report_name")."|\n"; + exit; + } + +$NOW_TIME = date("Y-m-d H:i:s"); +$STARTtime = date("U"); + +$LOGallowed_campaignsSQL=''; +$whereLOGallowed_campaignsSQL=''; +if ( (!preg_match('/\-ALL/i', $LOGallowed_campaigns)) ) + { + $rawLOGallowed_campaignsSQL = preg_replace("/ -/",'',$LOGallowed_campaigns); + $rawLOGallowed_campaignsSQL = preg_replace("/ /","','",$rawLOGallowed_campaignsSQL); + $LOGallowed_campaignsSQL = "and campaign_id IN('$rawLOGallowed_campaignsSQL')"; + $whereLOGallowed_campaignsSQL = "where campaign_id IN('$rawLOGallowed_campaignsSQL')"; + } + +$campaign_typeSQL=''; +if (count($types)<2) { + if (in_array('LIST ALL CAMPAIGNS', $types)) {$campaign_typeSQL="";} + else if (in_array('AUTO-DIAL ONLY', $types)) {$campaign_typeSQL="and dial_method IN('RATIO','ADAPT_HARD_LIMIT','ADAPT_TAPERED','ADAPT_AVERAGE')";} + else if (in_array('MANUAL ONLY', $types)) {$campaign_typeSQL="and dial_method IN('MANUAL','INBOUND_MAN')";} + else if (in_array('INBOUND ONLY', $types)) {$campaign_typeSQL="and campaign_allow_inbound='Y'";} + else {$campaign_typeSQL="and campaign_id='".implode("', '", $types)."'";} +} else { + if (!in_array('LIST ALL CAMPAIGNS', $types)) { + $campaign_typeSQL='and ('; + if (in_array('AUTO-DIAL ONLY', $types)) + { + $campaign_typeSQL.="dial_method IN('RATIO','ADAPT_HARD_LIMIT','ADAPT_TAPERED','ADAPT_AVERAGE') or "; # + $index = array_search('AUTO-DIAL ONLY', $types); + unset($types[$index]); + } + if (in_array('MANUAL ONLY', $types)) + { + $campaign_typeSQL.="dial_method IN('MANUAL','INBOUND_MAN') or "; + $index = array_search('MANUAL ONLY', $types); + unset($types[$index]); + } # + if (in_array('INBOUND ONLY', $types)) + { + $campaign_typeSQL.="campaign_allow_inbound='Y' or "; + $index = array_search('INBOUND ONLY', $types); + unset($types[$index]); + } # + array_values($types); + $campaign_typeSQL.="campaign_id in ('".implode("', '", $types)."')"; + $campaign_typeSQL.=')'; + } +} + + +$stmt="select campaign_id from vicidial_campaigns where active='Y' $LOGallowed_campaignsSQL $campaign_typeSQL order by campaign_id;"; +# echo $stmt; die; +$rslt=mysql_to_mysqli($stmt, $link); +if (!isset($DB)) {$DB=0;} +if ($DB) {$MAIN.="$stmt\n";} +$groups_to_print = mysqli_num_rows($rslt); +$i=0; +while ($i < $groups_to_print) + { + $row=mysqli_fetch_row($rslt); + $groups[$i] =$row[0]; + $i++; + } + +$output_text=""; +$k=0; +while($k<$groups_to_print) + { + $group = $groups[$k]; + $output_text.="$group|"; + $stmt = "select count(*) from vicidial_campaigns where campaign_id='$group' and campaign_allow_inbound='Y';"; + $rslt=mysql_to_mysqli($stmt, $link); + $row=mysqli_fetch_row($rslt); + $campaign_allow_inbound = $row[0]; + + $stmt="select auto_dial_level,dial_status_a,dial_status_b,dial_status_c,dial_status_d,dial_status_e,lead_order,lead_filter_id,hopper_level,dial_method,adaptive_maximum_level,adaptive_dropped_percentage,adaptive_dl_diff_target,adaptive_intensity,available_only_ratio_tally,adaptive_latest_server_time,local_call_time,dial_timeout,dial_statuses from vicidial_campaigns where campaign_id='" . mysqli_real_escape_string($link, $group) . "';"; + $rslt=mysql_to_mysqli($stmt, $link); + $row=mysqli_fetch_row($rslt); + $DIALlev["$group"] = $row[0]; + $DIALstatusA["$group"] = $row[1]; + $DIALstatusB["$group"] = $row[2]; + $DIALstatusC["$group"] = $row[3]; + $DIALstatusD["$group"] = $row[4]; + $DIALstatusE["$group"] = $row[5]; + $DIALorder["$group"] = $row[6]; + $DIALfilter["$group"] = $row[7]; + $HOPlev["$group"] = $row[8]; + $DIALmethod["$group"] = $row[9]; + $maxDIALlev["$group"] = $row[10]; + $DROPmax["$group"] = $row[11]; + $targetDIFF["$group"] = $row[12]; + $ADAintense["$group"] = $row[13]; + $ADAavailonly["$group"] = $row[14]; + $TAPERtime["$group"] = $row[15]; + $CALLtime["$group"] = $row[16]; + $DIALtimeout["$group"] = $row[17]; + $DIALstatuses["$group"] = $row[18]; + $DIALstatuses["$group"] = (preg_replace("/ -$|^ /","",$DIALstatuses["$group"])); + $DIALstatuses["$group"] = (preg_replace('/\s/', ', ', $DIALstatuses["$group"])); + + $stmt="select count(*) from vicidial_hopper where campaign_id='" . mysqli_real_escape_string($link, $group) . "';"; + $rslt=mysql_to_mysqli($stmt, $link); + $row=mysqli_fetch_row($rslt); + $VDhop["$group"] = $row[0]; + + $stmt="select dialable_leads,calls_today,drops_today,drops_answers_today_pct,differential_onemin,agents_average_onemin,balance_trunk_fill,answers_today,status_category_1,status_category_count_1,status_category_2,status_category_count_2,status_category_3,status_category_count_3,status_category_4,status_category_count_4,agent_calls_today,agent_wait_today,agent_custtalk_today,agent_acw_today,agent_pause_today from vicidial_campaign_stats where campaign_id='" . mysqli_real_escape_string($link, $group) . "';"; + $rslt=mysql_to_mysqli($stmt, $link); + $row=mysqli_fetch_row($rslt); + $DAleads["$group"] = $row[0]; + $callsTODAY["$group"] = $row[1]; + $dropsTODAY["$group"] = $row[2]; + $drpctTODAY["$group"] = $row[3]; + $diffONEMIN["$group"] = $row[4]; + $agentsONEMIN["$group"] = $row[5]; + $balanceFILL["$group"] = $row[6]; + $answersTODAY["$group"] = $row[7]; + $VSCcat1["$group"] = $row[8]; + $VSCcat1tally["$group"] = $row[9]; + $VSCcat2["$group"] = $row[10]; + $VSCcat2tally["$group"] = $row[11]; + $VSCcat3["$group"] = $row[12]; + $VSCcat3tally["$group"] = $row[13]; + $VSCcat4["$group"] = $row[14]; + $VSCcat4tally["$group"] = $row[15]; + $VSCagentcalls["$group"] = $row[16]; + $VSCagentwait["$group"] = $row[17]; + $VSCagentcust["$group"] = $row[18]; + $VSCagentacw["$group"] = $row[19]; + $VSCagentpause["$group"] = $row[20]; + + $diffpctONEMIN = ( MathZDC($diffONEMIN["$group"], $agentsONEMIN["$group"]) * 100); + $diffpctONEMIN = sprintf("%01.2f", $diffpctONEMIN); + $diffpctONEMIN_ary["$group"] = $diffpctONEMIN; + + $stmt="select sum(local_trunk_shortage) from vicidial_campaign_server_stats where campaign_id='" . mysqli_real_escape_string($link, $group) . "';"; + $rslt=mysql_to_mysqli($stmt, $link); + $row=mysqli_fetch_row($rslt); + $balanceSHORT["$group"] = $row[0]; + ################################################################################ + ### START calculating calls/agents + ################################################################################ + + ################################################################################ + ###### OUTBOUND CALLS + ################################################################################ + if ($campaign_allow_inbound > 0) + { + $stmt="select closer_campaigns from vicidial_campaigns where campaign_id='" . mysqli_real_escape_string($link, $group) . "';"; + $rslt=mysql_to_mysqli($stmt, $link); + $row=mysqli_fetch_row($rslt); + $closer_campaigns = preg_replace("/^ | -$/","",$row[0]); + $closer_campaigns = preg_replace("/ /","','",$closer_campaigns); + $closer_campaigns = "'$closer_campaigns'"; + + $stmt="select status from vicidial_auto_calls where status NOT IN('XFER') and ( (call_type='IN' and campaign_id IN($closer_campaigns)) or (campaign_id='" . mysqli_real_escape_string($link, $group) . "' and call_type='OUT') );"; + } + else + { + if ($group=='XXXX-ALL-ACTIVE-XXXX') {$groupSQL = '';} + else {$groupSQL = " and campaign_id='" . mysqli_real_escape_string($link, $group) . "'";} + + $stmt="select status from vicidial_auto_calls where status NOT IN('XFER') $groupSQL;"; + } + $rslt=mysql_to_mysqli($stmt, $link); + if ($DB) {$MAIN.="$stmt\n";} + $parked_to_print = mysqli_num_rows($rslt); + if ($parked_to_print > 0) + { + $i=0; + $out_total["$group"]=0; + $out_ring["$group"]=0; + $out_live["$group"]=0; + $in_ivr["$group"]=0; + while ($i < $parked_to_print) + { + $row=mysqli_fetch_row($rslt); + + if (preg_match("/LIVE/i",$row[0])) + {$out_live["$group"]++;} + else + { + if (preg_match("/IVR/i",$row[0])) + {$in_ivr["$group"]++;} + if (preg_match("/CLOSER/i",$row[0])) + {$nothing=1;} + else + {$out_ring["$group"]++;} + } + $out_total["$group"]++; + $i++; + } + + if ($out_live > 0) {$F=''; $FG='';} + if ($out_live > 4) {$F=''; $FG='';} + if ($out_live > 9) {$F=''; $FG='';} + if ($out_live > 14) {$F=''; $FG='';} + + } + + ################################################################################### + ###### TIME ON SYSTEM + ################################################################################### + + $agent_incall["$group"]=0; + $agent_ready["$group"]=0; + $agent_paused["$group"]=0; + $agent_total["$group"]=0; + + $stmt="select extension,user,conf_exten,status,server_ip,UNIX_TIMESTAMP(last_call_time),UNIX_TIMESTAMP(last_call_finish),call_server_ip,campaign_id from vicidial_live_agents where campaign_id='" . mysqli_real_escape_string($link, $group) . "';"; + $rslt=mysql_to_mysqli($stmt, $link); + if ($DB) {$MAIN.="$stmt\n";} + $talking_to_print = mysqli_num_rows($rslt); + if ($talking_to_print > 0) + { + $i=0; + $agentcount=0; + while ($i < $talking_to_print) + { + $row=mysqli_fetch_row($rslt); + if (preg_match("/READY|PAUSED/i",$row[3])) + { + $row[5]=$row[6]; + } + $Lstatus = $row[3]; + $status = sprintf("%-6s", $row[3]); + if (!preg_match("/INCALL|QUEUE/i",$row[3])) + {$call_time_S = ($STARTtime - $row[6]);} + else + {$call_time_S = ($STARTtime - $row[5]);} + + $call_time_M = MathZDC($call_time_S, 60); + $call_time_M = round($call_time_M, 2); + $call_time_M_int = intval("$call_time_M"); + $call_time_SEC = ($call_time_M - $call_time_M_int); + $call_time_SEC = ($call_time_SEC * 60); + $call_time_SEC = round($call_time_SEC, 0); + if ($call_time_SEC < 10) {$call_time_SEC = "0$call_time_SEC";} + $call_time_MS = "$call_time_M_int:$call_time_SEC"; + $call_time_MS = sprintf("%7s", $call_time_MS); + $G = ''; $EG = ''; + if (preg_match("/PAUSED/i",$row[3])) + { + if ($call_time_M_int >= 30) + {$i++; continue;} + else + { + $agent_paused["$group"]++; + $agent_total["$group"]++; + } + } + + if ( (preg_match("/INCALL/i",$status)) or (preg_match("/QUEUE/i",$status)) ) {$agent_incall["$group"]++; $agent_total["$group"]++;} + if ( (preg_match("/READY/i",$status)) or (preg_match("/CLOSER/i",$status)) ) {$agent_ready["$group"]++; $agent_total["$group"]++;} + $agentcount++; + $i++; + } + } + + if ($VSCagentcalls > 0) + { + $avgpauseTODAY = MathZDC($VSCagentpause["$group"], $VSCagentcalls["$group"]); + $avgpauseTODAY = round($avgpauseTODAY, 0); + $avgpauseTODAY = sprintf("%01.0f", $avgpauseTODAY); + $avgpauseTODAY_ary["$group"]=$avgpauseTODAY; + + $avgwaitTODAY = MathZDC($VSCagentwait["$group"], $VSCagentcalls["$group"]); + $avgwaitTODAY = round($avgwaitTODAY, 0); + $avgwaitTODAY = sprintf("%01.0f", $avgwaitTODAY); + $avgwaitTODAY_ary["$group"]=$avgwaitTODAY; + + $avgcustTODAY = MathZDC($VSCagentcust["$group"], $VSCagentcalls["$group"]); + $avgcustTODAY = round($avgcustTODAY, 0); + $avgcustTODAY = sprintf("%01.0f", $avgcustTODAY); + $avgcustTODAY_ary["$group"]=$avgcustTODAY; + + $avgacwTODAY = MathZDC($VSCagentacw["$group"], $VSCagentcalls["$group"]); + $avgacwTODAY = round($avgacwTODAY, 0); + $avgacwTODAY = sprintf("%01.0f", $avgacwTODAY); + $avgacwTODAY_ary["$group"]=$avgacwTODAY; + } + + $k++; + } +$output_text.="\n"; + +# Output all arrays +$n=0; +$DIALlev_output=''; +$DIALstatusA_output=''; +$DIALstatusB_output=''; +$DIALstatusC_output=''; +$DIALstatusD_output=''; +$DIALstatusE_output=''; +$DIALorder_output=''; +$DIALfilter_output=''; +$HOPlev_output=''; +$DIALmethod_output=''; +$maxDIALlev_output=''; +$DROPmax_output=''; +$targetDIFF_output=''; +$ADAintense_output=''; +$ADAavailonly_output=''; +$TAPERtime_output=''; +$CALLtime_output=''; +$DIALtimeout_output=''; +$DIALstatuses_output=''; +$VDhop_output=''; +$DAleads_output=''; +$callsTODAY_output=''; +$dropsTODAY_output=''; +$drpctTODAY_output=''; +$diffONEMIN_output=''; +$agentsONEMIN_output=''; +$balanceFILL_output=''; +$answersTODAY_output=''; +$VSCcat1_output=''; +$VSCcat1tally_output=''; +$VSCcat2_output=''; +$VSCcat2tally_output=''; +$VSCcat3_output=''; +$VSCcat3tally_output=''; +$VSCcat4_output=''; +$VSCcat4tally_output=''; +$VSCagentcalls_output=''; +$VSCagentwait_output=''; +$VSCagentcust_output=''; +$VSCagentacw_output=''; +$VSCagentpause_output=''; +$diffpctONEMIN_ary_output=''; +$balanceSHORT_output=''; +$out_total_output=''; +$out_ring_output=''; +$out_live_output=''; +$in_ivr_output=''; +$agent_incall_output=''; +$agent_ready_output=''; +$agent_paused_output=''; +$agent_total_output=''; +$avgpauseTODAY_ary_output=''; +$avgwaitTODAY_ary_output=''; +$avgcustTODAY_ary_output=''; +$avgacwTODAY_ary_output=''; + + +while ($n<$groups_to_print) { + # $DIALlev["$group"] = $row[0]; + $DIALlev_output .= $DIALlev[$groups[$n]]."|"; + $DIALstatusA_output .= $DIALstatusA[$groups[$n]]."|"; + $DIALstatusB_output .= $DIALstatusB[$groups[$n]]."|"; + $DIALstatusC_output .= $DIALstatusC[$groups[$n]]."|"; + $DIALstatusD_output .= $DIALstatusD[$groups[$n]]."|"; + $DIALstatusE_output .= $DIALstatusE[$groups[$n]]."|"; + $DIALorder_output .= $DIALorder[$groups[$n]]."|"; + $DIALfilter_output .= $DIALfilter[$groups[$n]]."|"; + $HOPlev_output .= $HOPlev[$groups[$n]]."|"; + $DIALmethod_output .= $DIALmethod[$groups[$n]]."|"; + $maxDIALlev_output .= $maxDIALlev[$groups[$n]]."|"; + $DROPmax_output .= $DROPmax[$groups[$n]]."|"; + $targetDIFF_output .= $targetDIFF[$groups[$n]]."|"; + $ADAintense_output .= $ADAintense[$groups[$n]]."|"; + $ADAavailonly_output .= $ADAavailonly[$groups[$n]]."|"; + $TAPERtime_output .= $TAPERtime[$groups[$n]]."|"; + $CALLtime_output .= $CALLtime[$groups[$n]]."|"; + $DIALtimeout_output .= $DIALtimeout[$groups[$n]]."|"; + $DIALstatuses_output .= $DIALstatuses[$groups[$n]]."|"; + $VDhop_output .= $VDhop[$groups[$n]]."|"; + $DAleads_output .= $DAleads[$groups[$n]]."|"; + $callsTODAY_output .= $callsTODAY[$groups[$n]]."|"; + $dropsTODAY_output .= $dropsTODAY[$groups[$n]]."|"; + $drpctTODAY_output .= $drpctTODAY[$groups[$n]]."|"; + $diffONEMIN_output .= $diffONEMIN[$groups[$n]]."|"; + $agentsONEMIN_output .= $agentsONEMIN[$groups[$n]]."|"; + $balanceFILL_output .= $balanceFILL[$groups[$n]]."|"; + $answersTODAY_output .= $answersTODAY[$groups[$n]]."|"; + $VSCcat1_output .= $VSCcat1[$groups[$n]]."|"; + $VSCcat1tally_output .= $VSCcat1tally[$groups[$n]]."|"; + $VSCcat2_output .= $VSCcat2[$groups[$n]]."|"; + $VSCcat2tally_output .= $VSCcat2tally[$groups[$n]]."|"; + $VSCcat3_output .= $VSCcat3[$groups[$n]]."|"; + $VSCcat3tally_output .= $VSCcat3tally[$groups[$n]]."|"; + $VSCcat4_output .= $VSCcat4[$groups[$n]]."|"; + $VSCcat4tally_output .= $VSCcat4tally[$groups[$n]]."|"; + $VSCagentcalls_output .= $VSCagentcalls[$groups[$n]]."|"; + $VSCagentwait_output .= $VSCagentwait[$groups[$n]]."|"; + $VSCagentcust_output .= $VSCagentcust[$groups[$n]]."|"; + $VSCagentacw_output .= $VSCagentacw[$groups[$n]]."|"; + $VSCagentpause_output .= $VSCagentpause[$groups[$n]]."|"; + $diffpctONEMIN_ary_output .= $diffpctONEMIN_ary[$groups[$n]]."|"; + $balanceSHORT_output .= $balanceSHORT[$groups[$n]]."|"; + $out_total_output .= $out_total[$groups[$n]]."|"; + $out_ring_output .= $out_ring[$groups[$n]]."|"; + $out_live_output .= $out_live[$groups[$n]]."|"; + $in_ivr_output .= $in_ivr[$groups[$n]]."|"; + $agent_incall_output .= $agent_incall[$groups[$n]]."|"; + $agent_ready_output .= $agent_ready[$groups[$n]]."|"; + $agent_paused_output .= $agent_paused[$groups[$n]]."|"; + $agent_total_output .= $agent_total[$groups[$n]]."|"; + $avgpauseTODAY_ary_output .= $avgpauseTODAY_ary[$groups[$n]]."|"; + $avgwaitTODAY_ary_output .= $avgwaitTODAY_ary[$groups[$n]]."|"; + $avgcustTODAY_ary_output .= $avgcustTODAY_ary[$groups[$n]]."|"; + $avgacwTODAY_ary_output .= $avgacwTODAY_ary[$groups[$n]]."|"; + $n++; +} + +$DIALlev_output.="\n"; +$DIALstatusA_output.="\n"; +$DIALstatusB_output.="\n"; +$DIALstatusC_output.="\n"; +$DIALstatusD_output.="\n"; +$DIALstatusE_output.="\n"; +$DIALorder_output.="\n"; +$DIALfilter_output.="\n"; +$HOPlev_output.="\n"; +$DIALmethod_output.="\n"; +$maxDIALlev_output.="\n"; +$DROPmax_output.="\n"; +$targetDIFF_output.="\n"; +$ADAintense_output.="\n"; +$ADAavailonly_output.="\n"; +$TAPERtime_output.="\n"; +$CALLtime_output.="\n"; +$DIALtimeout_output.="\n"; +$DIALstatuses_output.="\n"; +$VDhop_output.="\n"; +$DAleads_output.="\n"; +$callsTODAY_output.="\n"; +$dropsTODAY_output.="\n"; +$drpctTODAY_output.="\n"; +$diffONEMIN_output.="\n"; +$agentsONEMIN_output.="\n"; +$balanceFILL_output.="\n"; +$answersTODAY_output.="\n"; +$VSCcat1_output.="\n"; +$VSCcat1tally_output.="\n"; +$VSCcat2_output.="\n"; +$VSCcat2tally_output.="\n"; +$VSCcat3_output.="\n"; +$VSCcat3tally_output.="\n"; +$VSCcat4_output.="\n"; +$VSCcat4tally_output.="\n"; +$VSCagentcalls_output.="\n"; +$VSCagentwait_output.="\n"; +$VSCagentcust_output.="\n"; +$VSCagentacw_output.="\n"; +$VSCagentpause_output.="\n"; +$diffpctONEMIN_ary_output.="\n"; +$balanceSHORT_output.="\n"; +$out_total_output.="\n"; +$out_ring_output.="\n"; +$out_live_output.="\n"; +$in_ivr_output.="\n"; +$agent_incall_output.="\n"; +$agent_ready_output.="\n"; +$agent_paused_output.="\n"; +$agent_total_output.="\n"; +$avgpauseTODAY_ary_output.="\n"; +$avgwaitTODAY_ary_output.="\n"; +$avgcustTODAY_ary_output.="\n"; +$avgacwTODAY_ary_output.="\n"; + +$output_text.=$DIALlev_output.$DIALstatusA_output.$DIALstatusB_output.$DIALstatusC_output.$DIALstatusD_output.$DIALstatusE_output.$DIALorder_output.$DIALfilter_output.$HOPlev_output.$DIALmethod_output.$maxDIALlev_output.$DROPmax_output.$targetDIFF_output.$ADAintense_output.$ADAavailonly_output.$TAPERtime_output.$CALLtime_output.$DIALtimeout_output.$DIALstatuses_output.$VDhop_output.$DAleads_output.$callsTODAY_output.$dropsTODAY_output.$drpctTODAY_output.$diffONEMIN_output.$agentsONEMIN_output.$balanceFILL_output.$answersTODAY_output.$VSCcat1_output.$VSCcat1tally_output.$VSCcat2_output.$VSCcat2tally_output.$VSCcat3_output.$VSCcat3tally_output.$VSCcat4_output.$VSCcat4tally_output.$VSCagentcalls_output.$VSCagentwait_output.$VSCagentcust_output.$VSCagentacw_output.$VSCagentpause_output.$diffpctONEMIN_ary_output.$balanceSHORT_output.$out_total_output.$out_ring_output.$out_live_output.$in_ivr_output.$agent_incall_output.$agent_ready_output.$agent_paused_output.$agent_total_output.$avgpauseTODAY_ary_output.$avgwaitTODAY_ary_output.$avgcustTODAY_ary_output.$avgacwTODAY_ary_output; +$output_text=preg_replace('/\|\n/', "\n", $output_text); + + +print $output_text; \ No newline at end of file diff --git a/www/vicidial/pureknob.js b/www/vicidial/pureknob.js new file mode 100644 index 00000000..eecaa80a --- /dev/null +++ b/www/vicidial/pureknob.js @@ -0,0 +1,1095 @@ +/* + * pure-knob + * + * Canvas-based JavaScript UI element implementing touch, + * keyboard, mouse and scroll wheel support. + * + * Copyright 2018 Andre Plötze + * + * Licensed under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +"use strict"; + +/* + * Custom user interface elements for pure knob. + */ +function PureKnob() { + + /* + * Creates a bar graph element. + */ + this.createBarGraph = function(width, height) { + var heightString = height.toString(); + var widthString = width.toString(); + var canvas = document.createElement('canvas'); + var div = document.createElement('div'); + div.style.display = 'inline-block'; + div.style.height = heightString + 'px'; + div.style.position = 'relative'; + div.style.textAlign = 'center'; + div.style.width = widthString + 'px'; + div.appendChild(canvas); + + /* + * The bar graph object. + */ + var graph = { + '_canvas': canvas, + '_div': div, + '_height': height, + '_width': width, + + /* + * Properties of this bar graph. + */ + '_properties': { + 'colorBG': '#181818', + 'colorFG': '#ff8800', + 'colorMarkers': '#888888', + 'markerStart': 0, + 'markerEnd': 100, + 'markerStep': 20, + 'trackWidth': 0.5, + 'valMin': 0, + 'valMax': 100, + 'valPeaks': [], + 'val': 0 + }, + + /* + * Returns the peak values for this bar graph. + */ + 'getPeaks': function() { + var properties = this._properties; + var peaks = properties.valPeaks; + var numPeaks = peaks.length; + var peaksCopy = []; + + /* + * Iterate over the peak values and copy them. + */ + for (var i = 0; i < numPeaks; i++) { + var peak = peaks[i]; + peaksCopy.push(peak); + } + + return peaksCopy; + }, + + /* + * Returns the value of a property of this bar graph. + */ + 'getProperty': function(key) { + var properties = this._properties; + var value = properties[key]; + return value; + }, + + /* + * Returns the current value of the bar graph. + */ + 'getValue': function() { + var properties = this._properties; + var value = properties.val; + return value; + }, + + /* + * Return the DOM node representing this bar graph. + */ + 'node': function() { + var div = this._div; + return div; + }, + + /* + * Redraw the bar graph on the canvas. + */ + 'redraw': function() { + this.resize(); + var properties = this._properties; + var colorTrack = properties.colorBG; + var colorFilling = properties.colorFG; + var colorMarkers = properties.colorMarkers; + var markerStart = properties.markerStart; + var markerEnd = properties.markerEnd; + var markerStep = properties.markerStep; + var trackWidth = properties.trackWidth; + var valMin = properties.valMin; + var valMax = properties.valMax; + var peaks = properties.valPeaks; + var value = properties.val; + var height = this._height; + var width = this._width; + var lineWidth = Math.round(trackWidth * height); + var halfWidth = 0.5 * lineWidth; + var centerY = 0.5 * height; + var lineTop = centerY - halfWidth; + var lineBottom = centerY + halfWidth; + var relativeValue = (value - valMin) / (valMax - valMin); + var fillingEnd = width * relativeValue; + var numPeaks = peaks.length; + var canvas = this._canvas; + var ctx = canvas.getContext('2d'); + + /* + * Clear the canvas. + */ + ctx.clearRect(0, 0, width, height); + + /* + * Check if markers should be drawn. + */ + if ((markerStart !== null) & (markerEnd !== null) & (markerStep !== null) & (markerStep !== 0)) { + + /* + * Draw the markers. + */ + for (var v = markerStart; v <= markerEnd; v += markerStep) { + var relativePos = (v - valMin) / (valMax - valMin); + var pos = Math.round(width * relativePos); + ctx.beginPath(); + ctx.moveTo(pos, 0); + ctx.lineTo(pos, height); + ctx.lineCap = 'butt'; + ctx.lineWidth = '2'; + ctx.strokeStyle = colorMarkers; + ctx.stroke(); + } + + } + + /* + * Draw the track. + */ + ctx.beginPath(); + ctx.rect(0, lineTop, width, lineWidth); + ctx.fillStyle = colorTrack; + ctx.fill(); + + /* + * Draw the filling. + */ + ctx.beginPath(); + ctx.rect(0, lineTop, fillingEnd, lineWidth); + ctx.fillStyle = colorFilling; + ctx.fill(); + + /* + * Draw the peaks. + */ + for (var i = 0; i < numPeaks; i++) { + var peak = peaks[i]; + var relativePeak = (peak - valMin) / (valMax - valMin); + var pos = Math.round(width * relativePeak); + ctx.beginPath(); + ctx.moveTo(pos, lineTop); + ctx.lineTo(pos, lineBottom); + ctx.lineCap = 'butt'; + ctx.lineWidth = '2'; + ctx.strokeStyle = colorFilling; + ctx.stroke(); + } + + }, + + /* + * This is called as the canvas or the surrounding DIV is resized. + */ + 'resize': function() { + var canvas = this._canvas; + canvas.style.height = '100%'; + canvas.style.width = '100%'; + canvas.height = this._height; + canvas.width = this._width; + }, + + /* + * Sets the peak values of this bar graph. + */ + 'setPeaks': function(peaks) { + var properties = this._properties; + var peaksCopy = []; + var numPeaks = peaks.length; + + /* + * Iterate over the peak values and append them to the array. + */ + for (var i = 0; i < numPeaks; i++) { + var peak = peaks[i]; + peaksCopy.push(peak); + } + + this.setProperty('valPeaks', peaksCopy); + }, + + /* + * Sets the value of a property of this bar graph. + */ + 'setProperty': function(key, value) { + this._properties[key] = value; + this.redraw(); + }, + + /* + * Sets the value of this bar graph. + */ + 'setValue': function(value) { + var properties = this._properties; + var valMin = properties.valMin; + var valMax = properties.valMax; + + /* + * Clamp the actual value into the [valMin; valMax] range. + */ + if (value < valMin) + value = valMin; + else if (value > valMax) + value = valMax; + + // value = Math.round(value); + // alert("Hi: "+value); + this.setProperty('val', value); + } + + }; + + /* + * This is called when the size of the canvas changes. + */ + var resizeListener = function(e) { + graph.redraw(); + }; + + canvas.addEventListener('resize', resizeListener); + return graph; + } + + /* + * Creates a knob element. + */ + this.createKnob = function(width, height, value_type) { + var heightString = height.toString(); + var widthString = width.toString(); + // var widthString = width.toString(); + var smaller = width < height ? width : height; + var fontSize = 0.2 * smaller; + var fontSizeString = fontSize.toString(); + var canvas = document.createElement('canvas'); + var div = document.createElement('div'); + div.style.display = 'inline-block'; + div.style.height = heightString + 'px'; + div.style.position = 'relative'; + div.style.textAlign = 'center'; + div.style.width = widthString + 'px'; + div.appendChild(canvas); + var input = document.createElement('input'); + input.style.appearance = 'textfield'; + input.style.backgroundColor = 'rgba(0, 0, 0, 0.8)'; + input.style.border = 'none'; + input.style.color = '#ff8800'; + input.style.fontFamily = 'sans-serif'; + input.style.fontSize = fontSizeString + 'px'; + input.style.height = heightString + 'px'; + input.style.margin = 'auto'; + input.style.padding = '0px'; + input.style.textAlign = 'center'; + input.style.width = widthString + 'px'; + var inputMode = document.createAttribute('inputmode'); + inputMode.value = 'numeric'; + input.setAttributeNode(inputMode); + var inputDiv = document.createElement('div'); + inputDiv.style.bottom = '0px'; + inputDiv.style.display = 'none'; + inputDiv.style.left = '0px'; + inputDiv.style.position = 'absolute'; + inputDiv.style.right = '0px'; + inputDiv.style.top = '0px'; + inputDiv.appendChild(input); + div.appendChild(inputDiv); + + /* + * The knob object. + */ + var knob = { + '_canvas': canvas, + '_div': div, + '_height': height, + '_input': input, + '_inputDiv': inputDiv, + '_listeners': [], + '_mousebutton': false, + '_previousVal': 0, + '_timeout': null, + '_timeoutDoubleTap': null, + '_touchCount': 0, + '_width': width, + + /* + * Notify listeners about value changes. + */ + '_notifyUpdate': function() { + var properties = this._properties; + var value = properties.val; + var listeners = this._listeners; + var numListeners = listeners.length; + + /* + * Call all listeners. + */ + for (var i = 0; i < numListeners; i++) { + var listener = listeners[i]; + + /* + * Call listener, if it exists. + */ + if (listener !== null) + listener(this, value); + + } + + }, + + /* + * Properties of this knob. + */ + '_properties': { + 'angleEnd': 2.0 * Math.PI, + 'angleOffset': -0.5 * Math.PI, + 'angleStart': 0, + 'colorBG': '#181818', + 'colorFG': '#ff8800', + 'needle': false, + 'readonly': true, + 'trackWidth': 0.4, + 'valMin': 0, + 'valMax': 100, + 'val': 0 + }, + + /* + * Abort value change, restoring the previous value. + */ + 'abort': function() { + var previousValue = this._previousVal; + var properties = this._properties; + properties.val = previousValue; + this.redraw(); + }, + + /* + * Adds an event listener. + */ + 'addListener': function(listener) { + var listeners = this._listeners; + listeners.push(listener); + }, + + /* + * Commit value, indicating that it is no longer temporary. + */ + 'commit': function() { + var properties = this._properties; + var value = properties.val; + this._previousVal = value; + this.redraw(); + this._notifyUpdate(); + }, + + /* + * Returns the value of a property of this knob. + */ + 'getProperty': function(key) { + var properties = this._properties; + var value = properties[key]; + return value; + }, + + /* + * Returns the current value of the knob. + */ + 'getValue': function() { + var properties = this._properties; + var value = properties.val; + return value; + }, + + /* + * Return the DOM node representing this knob. + */ + 'node': function() { + var div = this._div; + return div; + }, + + /* + * Redraw the knob on the canvas. + */ + 'redraw': function() { + this.resize(); + var properties = this._properties; + var needle = properties.needle; + var angleStart = properties.angleStart; + var angleOffset = properties.angleOffset; + var angleEnd = properties.angleEnd; + var actualStart = angleStart + angleOffset; + var actualEnd = angleEnd + angleOffset; + var value = properties.val; + if (value_type=="percent" || value_type=="float") { + var value2=Math.floor(value*10)/10; + var valueStr = value2.toString(); + if (value_type=="percent") { + valueStr+="%"; + } + value = Math.round(value); + } else { + value = Math.round(value); + var valueStr = value.toString(); + } + var valMin = properties.valMin; + var valMax = properties.valMax; + var relValue = (value - valMin) / (valMax - valMin); + var relAngle = relValue * (angleEnd - angleStart); + var angleVal = actualStart + relAngle; + var colorTrack = properties.colorBG; + var colorFilling = properties.colorFG; + var trackWidth = properties.trackWidth; + var height = this._height; + var width = this._width; + var smaller = width < height ? width : height; + var centerX = 0.5 * width; + var centerY = 0.5 * height; + var radius = 0.4 * smaller; + var lineWidth = Math.round(trackWidth * radius); + var fontSize = 0.2 * smaller; + var fontSizeString = fontSize.toString(); + var canvas = this._canvas; + var ctx = canvas.getContext('2d'); + + /* + * Clear the canvas. + */ + ctx.clearRect(0, 0, width, height); + + /* + * Draw the track. + */ + ctx.beginPath(); + ctx.arc(centerX, centerY, radius, actualStart, actualEnd); + ctx.lineCap = 'butt'; + ctx.lineWidth = lineWidth; + ctx.strokeStyle = colorTrack; + ctx.stroke(); + + /* + * Draw the filling. + */ + ctx.beginPath(); + + /* + * Check if we're in needle mode. + */ + if (needle) + ctx.arc(centerX, centerY, radius, angleVal - 0.1, angleVal + 0.1); + else + ctx.arc(centerX, centerY, radius, actualStart, angleVal); + + ctx.lineCap = 'butt'; + ctx.lineWidth = lineWidth; + ctx.strokeStyle = colorFilling; + ctx.stroke(); + + /* + * Draw the number. + */ + ctx.font = fontSizeString + 'px sans-serif'; + ctx.fillStyle = colorFilling; + ctx.textAlign = 'center'; + ctx.textBaseline = 'middle'; + ctx.fillText(valueStr, centerX, centerY); + + /* + * Set the color of the input element. + */ + var elemInput = this._input; + elemInput.style.color = colorFilling; + }, + + /* + * This is called as the canvas or the surrounding DIV is resized. + */ + 'resize': function() { + var canvas = this._canvas; + canvas.style.height = '100%'; + canvas.style.width = '100%'; + canvas.height = this._height; + canvas.width = this._width; + }, + + /* + * Sets the value of a property of this knob. + */ + 'setProperty': function(key, value) { + this._properties[key] = value; + this.redraw(); + }, + + /* + * Sets the value of this knob. + */ + 'setValue': function(value) { + this.setValueFloating(value); + this.commit(); + }, + + /* + * Sets floating (temporary) value of this knob. + */ + 'setValueFloating': function(value) { + var properties = this._properties; + var valMin = properties.valMin; + var valMax = properties.valMax; + + /* + * Clamp the actual value into the [valMin; valMax] range. + */ + if (value < valMin) + value = valMin; + else if (value > valMax) + value = valMax; + + // value = Math.round(value); + // alert("Byes: "+value); + + this.setProperty('val', value); + } + + }; + + /* + * Convert mouse event to value. + */ + var mouseEventToValue = function(e, properties) { + var canvas = e.target; + var width = canvas.scrollWidth; + var height = canvas.scrollHeight; + var centerX = 0.5 * width; + var centerY = 0.5 * height; + var x = e.offsetX; + var y = e.offsetY; + var relX = x - centerX; + var relY = y - centerY; + var angleStart = properties.angleStart; + var angleEnd = properties.angleEnd; + var angleDiff = angleEnd - angleStart; + var angle = Math.atan2(relX, -relY) - angleStart; + var twoPi = 2.0 * Math.PI; + + /* + * Make negative angles positive. + */ + if (angle < 0) { + + if (angleDiff >= twoPi) + angle += twoPi; + else + angle = 0; + + } + + var valMin = properties.valMin; + var valMax = properties.valMax; + var value = ((angle / angleDiff) * (valMax - valMin)) + valMin; + + /* + * Clamp values into valid interval. + */ + if (value < valMin) + value = valMin; + else if (value > valMax) + value = valMax; + + return value; + }; + + /* + * Convert touch event to value. + */ + var touchEventToValue = function(e, properties) { + var canvas = e.target; + var rect = canvas.getBoundingClientRect(); + var offsetX = rect.left; + var offsetY = rect.top; + var width = canvas.scrollWidth; + var height = canvas.scrollHeight; + var centerX = 0.5 * width; + var centerY = 0.5 * height; + var touches = e.targetTouches; + var touch = null; + + /* + * If there are touches, extract the first one. + */ + if (touches.length > 0) + touch = touches.item(0); + + var x = 0.0; + var y = 0.0; + + /* + * If a touch was extracted, calculate coordinates relative to + * the element position. + */ + if (touch !== null) { + var touchX = touch.pageX; + x = touchX - offsetX; + var touchY = touch.pageY; + y = touchY - offsetY; + } + + var relX = x - centerX; + var relY = y - centerY; + var angleStart = properties.angleStart; + var angleEnd = properties.angleEnd; + var angleDiff = angleEnd - angleStart; + var angle = Math.atan2(relX, -relY) - angleStart; + var twoPi = 2.0 * Math.PI; + + /* + * Make negative angles positive. + */ + if (angle < 0) { + + if (angleDiff >= twoPi) + angle += twoPi; + else + angle = 0; + + } + + var valMin = properties.valMin; + var valMax = properties.valMax; + var value = ((angle / angleDiff) * (valMax - valMin)) + valMin; + + /* + * Clamp values into valid interval. + */ + if (value < valMin) + value = valMin; + else if (value > valMax) + value = valMax; + + return value; + }; + + /* + * Show input element on double click. + */ + var doubleClickListener = function(e) { + var properties = knob._properties; + var readonly = properties.readonly; + + /* + * If knob is not read-only, display input element. + */ + if (!readonly) { + e.preventDefault(); + var inputDiv = knob._inputDiv; + inputDiv.style.display = 'block'; + var inputElem = knob._input; + inputElem.focus(); + knob.redraw(); + } + + }; + + /* + * This is called when the mouse button is depressed. + */ + var mouseDownListener = function(e) { + var btn = e.buttons; + + /* + * It is a left-click. + */ + if (btn === 1) { + var properties = knob._properties; + var readonly = properties.readonly; + + /* + * If knob is not read-only, process mouse event. + */ + if (!readonly) { + e.preventDefault(); + var val = mouseEventToValue(e, properties); + knob.setValueFloating(val); + } + + knob._mousebutton = true; + } + + /* + * It is a middle click. + */ + if (btn === 4) { + var properties = knob._properties; + var readonly = properties.readonly; + + /* + * If knob is not read-only, display input element. + */ + if (!readonly) { + e.preventDefault(); + var inputDiv = knob._inputDiv; + inputDiv.style.display = 'block'; + var inputElem = knob._input; + inputElem.focus(); + knob.redraw(); + } + + } + + }; + + /* + * This is called when the mouse cursor is moved. + */ + var mouseMoveListener = function(e) { + var btn = knob._mousebutton; + + /* + * Only process event, if mouse button is depressed. + */ + if (btn) { + var properties = knob._properties; + var readonly = properties.readonly; + + /* + * If knob is not read-only, process mouse event. + */ + if (!readonly) { + e.preventDefault(); + var val = mouseEventToValue(e, properties); + knob.setValueFloating(val); + } + + } + + }; + + /* + * This is called when the mouse button is released. + */ + var mouseUpListener = function(e) { + var btn = knob._mousebutton; + + /* + * Only process event, if mouse button was depressed. + */ + if (btn) { + var properties = knob._properties; + var readonly = properties.readonly; + + /* + * If knob is not read only, process mouse event. + */ + if (!readonly) { + e.preventDefault(); + var val = mouseEventToValue(e, properties); + knob.setValue(val); + } + + } + + knob._mousebutton = false; + }; + + /* + * This is called when the drag action is canceled. + */ + var mouseCancelListener = function(e) { + var btn = knob._mousebutton; + + /* + * Abort action if mouse button was depressed. + */ + if (btn) { + knob.abort(); + knob._mousebutton = false; + } + + }; + + /* + * This is called when a user touches the element. + */ + var touchStartListener = function(e) { + var properties = knob._properties; + var readonly = properties.readonly; + + /* + * If knob is not read-only, process touch event. + */ + if (!readonly) { + var touches = e.touches; + var numTouches = touches.length; + var singleTouch = (numTouches == 1); + + /* + * Only process single touches, not multi-touch + * gestures. + */ + if (singleTouch) { + knob._mousebutton = true; + + /* + * If this is the first touch, bind double tap + * interval. + */ + if (knob._touchCount == 0) { + + /* + * This is executed when the double tap + * interval times out. + */ + var f = function() { + + /* + * If control was tapped exactly + * twice, enable on-screen keyboard. + */ + if (knob._touchCount == 2) { + var properties = knob._properties; + var readonly = properties.readonly; + + /* + * If knob is not read-only, + * display input element. + */ + if (!readonly) { + e.preventDefault(); + var inputDiv = knob._inputDiv; + inputDiv.style.display = 'block'; + var inputElem = knob._input; + inputElem.focus(); + knob.redraw(); + } + + } + + knob._touchCount = 0; + }; + + var timeout = knob._timeoutDoubleTap; + window.clearTimeout(timeout); + timeout = window.setTimeout(f, 500); + knob._timeoutDoubleTap = timeout; + } + + knob._touchCount++; + var val = touchEventToValue(e, properties); + knob.setValueFloating(val); + } + + } + + }; + + /* + * This is called when a user moves a finger on the element. + */ + var touchMoveListener = function(e) { + var btn = knob._mousebutton; + + /* + * Only process event, if mouse button is depressed. + */ + if (btn) { + var properties = knob._properties; + var readonly = properties.readonly; + + /* + * If knob is not read-only, process touch event. + */ + if (!readonly) { + var touches = e.touches; + var numTouches = touches.length; + var singleTouch = (numTouches == 1); + + /* + * Only process single touches, not multi-touch + * gestures. + */ + if (singleTouch) { + e.preventDefault(); + var val = touchEventToValue(e, properties); + knob.setValueFloating(val); + } + + } + + } + + }; + + /* + * This is called when a user lifts a finger off the element. + */ + var touchEndListener = function(e) { + var btn = knob._mousebutton; + + /* + * Only process event, if mouse button was depressed. + */ + if (btn) { + var properties = knob._properties; + var readonly = properties.readonly; + + /* + * If knob is not read only, process touch event. + */ + if (!readonly) { + var touches = e.touches; + var numTouches = touches.length; + var singleTouch = (numTouches == 1); + + /* + * Only process single touches, not multi-touch + * gestures. + */ + if (singleTouch) { + e.preventDefault(); + knob._mousebutton = false; + knob.commit(); + } + + } + + } + + knob._mousebutton = false; + }; + + /* + * This is called when a user cancels a touch action. + */ + var touchCancelListener = function(e) { + var btn = knob._mousebutton; + + /* + * Abort action if mouse button was depressed. + */ + if (btn) { + knob.abort(); + knob._touchCount = 0; + var timeout = knob._timeoutDoubleTap; + window.clearTimeout(timeout); + } + + knob._mousebutton = false; + }; + + /* + * This is called when the size of the canvas changes. + */ + var resizeListener = function(e) { + knob.redraw(); + }; + + /* + * This is called when the mouse wheel is moved. + */ + var scrollListener = function(e) { + var readonly = knob.getProperty('readonly'); + + /* + * If knob is not read only, process mouse wheel event. + */ + if (!readonly) { + e.preventDefault(); + var delta = e.deltaY; + var direction = delta > 0 ? 1 : (delta < 0 ? -1 : 0); + var val = knob.getValue(); + val += direction; + knob.setValueFloating(val); + + /* + * Perform delayed commit. + */ + var commit = function() { + knob.commit(); + }; + + var timeout = knob._timeout; + window.clearTimeout(timeout); + timeout = window.setTimeout(commit, 250); + knob._timeout = timeout; + } + + }; + + /* + * This is called when the user presses a key on the keyboard. + */ + var keyPressListener = function(e) { + var kc = e.keyCode; + + /* + * Hide input element when user presses enter or escape. + */ + if ((kc === 13) || (kc === 27)) { + var inputDiv = knob._inputDiv; + inputDiv.style.display = 'none'; + var input = e.target; + + /* + * Only evaluate value when user pressed enter. + */ + if (kc === 13) { + var value = input.value; + var val = parseInt(value); + var valid = isFinite(val); + + /* + * Check if input is a valid number. + */ + if (valid) + knob.setValue(val); + + } + + input.value = ''; + } + + }; + + canvas.addEventListener('dblclick', doubleClickListener); + canvas.addEventListener('mousedown', mouseDownListener); + canvas.addEventListener('mouseleave', mouseCancelListener); + canvas.addEventListener('mousemove', mouseMoveListener); + canvas.addEventListener('mouseup', mouseUpListener); + canvas.addEventListener('resize', resizeListener); + canvas.addEventListener('touchstart', touchStartListener); + canvas.addEventListener('touchmove', touchMoveListener); + canvas.addEventListener('touchend', touchEndListener); + canvas.addEventListener('touchcancel', touchCancelListener); + canvas.addEventListener('wheel', scrollListener); + input.addEventListener('keypress', keyPressListener); + return knob; + }; + +} + +var pureknob = new PureKnob(); + diff --git a/www/vicidial/realtime_report_mobile.php b/www/vicidial/realtime_report_mobile.php new file mode 100644 index 00000000..ed7ef5df --- /dev/null +++ b/www/vicidial/realtime_report_mobile.php @@ -0,0 +1,1815 @@ +, Joe Johnson LICENSE: AGPLv2 +# +# streamlined mobile version of live real-time stats for the VICIDIAL Auto-Dialer all servers +# +# Rewritten from AST_timeonVDADall.php report to be AJAX and javascript instead +# of link-driven +# +# * Requires AST_timeonVDADall.php for AJAX-derived stats information +# +# CHANGELOG: +# 190206-1616 - First Build +# 190228-1535 - Minor pre-release changes +# + +$startMS = microtime(); + +$version = '2.14-2'; +$build = '190228-1535'; + +header ("Content-type: text/html; charset=utf-8"); + +require("dbconnect_mysqli.php"); +require("functions.php"); + +$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER']; +$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW']; +$PHP_SELF=$_SERVER['PHP_SELF']; +if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];} + elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];} +if (isset($_GET["RR"])) {$RR=$_GET["RR"];} + elseif (isset($_POST["RR"])) {$RR=$_POST["RR"];} +if (isset($_GET["inbound"])) {$inbound=$_GET["inbound"];} + elseif (isset($_POST["inbound"])) {$inbound=$_POST["inbound"];} +if (isset($_GET["group"])) {$group=$_GET["group"];} + elseif (isset($_POST["group"])) {$group=$_POST["group"];} +if (isset($_GET["groups"])) {$groups=$_GET["groups"];} + elseif (isset($_POST["groups"])) {$groups=$_POST["groups"];} +if (isset($_GET["usergroup"])) {$usergroup=$_GET["usergroup"];} + elseif (isset($_POST["usergroup"])) {$usergroup=$_POST["usergroup"];} +if (isset($_GET["user_group_filter"])) {$user_group_filter=$_GET["user_group_filter"];} + elseif (isset($_POST["user_group_filter"])) {$user_group_filter=$_POST["user_group_filter"];} +if (isset($_GET["DB"])) {$DB=$_GET["DB"];} + elseif (isset($_POST["DB"])) {$DB=$_POST["DB"];} +if (isset($_GET["adastats"])) {$adastats=$_GET["adastats"];} + elseif (isset($_POST["adastats"])) {$adastats=$_POST["adastats"];} +if (isset($_GET["submit"])) {$submit=$_GET["submit"];} + elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];} +if (isset($_GET["SUBMIT"])) {$SUBMIT=$_GET["SUBMIT"];} + elseif (isset($_POST["SUBMIT"])) {$SUBMIT=$_POST["SUBMIT"];} +if (isset($_GET["SIPmonitorLINK"])) {$SIPmonitorLINK=$_GET["SIPmonitorLINK"];} + elseif (isset($_POST["SIPmonitorLINK"])) {$SIPmonitorLINK=$_POST["SIPmonitorLINK"];} +if (isset($_GET["IAXmonitorLINK"])) {$IAXmonitorLINK=$_GET["IAXmonitorLINK"];} + elseif (isset($_POST["IAXmonitorLINK"])) {$IAXmonitorLINK=$_POST["IAXmonitorLINK"];} +if (isset($_GET["UGdisplay"])) {$UGdisplay=$_GET["UGdisplay"];} + elseif (isset($_POST["UGdisplay"])) {$UGdisplay=$_POST["UGdisplay"];} +if (isset($_GET["UidORname"])) {$UidORname=$_GET["UidORname"];} + elseif (isset($_POST["UidORname"])) {$UidORname=$_POST["UidORname"];} +if (isset($_GET["orderby"])) {$orderby=$_GET["orderby"];} + elseif (isset($_POST["orderby"])) {$orderby=$_POST["orderby"];} +if (isset($_GET["SERVdisplay"])) {$SERVdisplay=$_GET["SERVdisplay"];} + elseif (isset($_POST["SERVdisplay"])) {$SERVdisplay=$_POST["SERVdisplay"];} +if (isset($_GET["CALLSdisplay"])) {$CALLSdisplay=$_GET["CALLSdisplay"];} + elseif (isset($_POST["CALLSdisplay"])) {$CALLSdisplay=$_POST["CALLSdisplay"];} +if (isset($_GET["PHONEdisplay"])) {$PHONEdisplay=$_GET["PHONEdisplay"];} + elseif (isset($_POST["PHONEdisplay"])) {$PHONEdisplay=$_POST["PHONEdisplay"];} +if (isset($_GET["CUSTPHONEdisplay"])) {$CUSTPHONEdisplay=$_GET["CUSTPHONEdisplay"];} + elseif (isset($_POST["CUSTPHONEdisplay"])) {$CUSTPHONEdisplay=$_POST["CUSTPHONEdisplay"];} +if (isset($_GET["NOLEADSalert"])) {$NOLEADSalert=$_GET["NOLEADSalert"];} + elseif (isset($_POST["NOLEADSalert"])) {$NOLEADSalert=$_POST["NOLEADSalert"];} +if (isset($_GET["DROPINGROUPstats"])) {$DROPINGROUPstats=$_GET["DROPINGROUPstats"];} + elseif (isset($_POST["DROPINGROUPstats"])) {$DROPINGROUPstats=$_POST["DROPINGROUPstats"];} +if (isset($_GET["ALLINGROUPstats"])) {$ALLINGROUPstats=$_GET["ALLINGROUPstats"];} + elseif (isset($_POST["ALLINGROUPstats"])) {$ALLINGROUPstats=$_POST["ALLINGROUPstats"];} +if (isset($_GET["with_inbound"])) {$with_inbound=$_GET["with_inbound"];} + elseif (isset($_POST["with_inbound"])) {$with_inbound=$_POST["with_inbound"];} +if (isset($_GET["monitor_active"])) {$monitor_active=$_GET["monitor_active"];} + elseif (isset($_POST["monitor_active"])) {$monitor_active=$_POST["monitor_active"];} +if (isset($_GET["monitor_phone"])) {$monitor_phone=$_GET["monitor_phone"];} + elseif (isset($_POST["monitor_phone"])) {$monitor_phone=$_POST["monitor_phone"];} +if (isset($_GET["CARRIERstats"])) {$CARRIERstats=$_GET["CARRIERstats"];} + elseif (isset($_POST["CARRIERstats"])) {$CARRIERstats=$_POST["CARRIERstats"];} +if (isset($_GET["PRESETstats"])) {$PRESETstats=$_GET["PRESETstats"];} + elseif (isset($_POST["PRESETstats"])) {$PRESETstats=$_POST["PRESETstats"];} +if (isset($_GET["AGENTtimeSTATS"])) {$AGENTtimeSTATS=$_GET["AGENTtimeSTATS"];} + elseif (isset($_POST["AGENTtimeSTATS"])) {$AGENTtimeSTATS=$_POST["AGENTtimeSTATS"];} +if (isset($_GET["INGROUPcolorOVERRIDE"])) {$INGROUPcolorOVERRIDE=$_GET["INGROUPcolorOVERRIDE"];} + elseif (isset($_POST["INGROUPcolorOVERRIDE"])) {$INGROUPcolorOVERRIDE=$_POST["INGROUPcolorOVERRIDE"];} +if (isset($_GET["droppedOFtotal"])) {$droppedOFtotal=$_GET["droppedOFtotal"];} + elseif (isset($_POST["droppedOFtotal"])) {$droppedOFtotal=$_POST["droppedOFtotal"];} + +$report_name = 'Real-Time Main Report'; +$db_source = 'M'; + +############################################# +##### START SYSTEM_SETTINGS LOOKUP ##### +$stmt = "SELECT use_non_latin,outbound_autodial_active,slave_db_server,reports_use_slave_db,enable_languages,language_method,agent_whisper_enabled,report_default_format,enable_pause_code_limits FROM system_settings;"; +$rslt=mysql_to_mysqli($stmt, $link); +if ($DB) {echo "$stmt\n";} +$qm_conf_ct = mysqli_num_rows($rslt); +if ($qm_conf_ct > 0) + { + $row=mysqli_fetch_row($rslt); + $non_latin = $row[0]; + $outbound_autodial_active = $row[1]; + $slave_db_server = $row[2]; + $reports_use_slave_db = $row[3]; + $SSenable_languages = $row[4]; + $SSlanguage_method = $row[5]; + $agent_whisper_enabled = $row[6]; + $SSreport_default_format = $row[7]; + $SSenable_pause_code_limits = $row[8]; + } +##### END SETTINGS LOOKUP ##### +########################################### + +$webphone_width = '460'; +$webphone_height = '500'; +$webphone_left = '600'; +$webphone_top = '27'; +$webphone_bufw = '250'; +$webphone_bufh = '1'; +$webphone_pad = '10'; +$webphone_clpos = "
  "._QXZ("webphone")." -"; + +if (file_exists('options.php')) + { + require('options.php'); + } + +if (!isset($DB)) + { + if (!isset($RS_DB)) {$DB=0;} + else {$DB = $RS_DB;} + } +if (!isset($RR)) + { + if (!isset($RS_RR)) {$RR=40;} + else {$RR = $RS_RR;} + } +if (!isset($group)) + { + if (!isset($RS_group)) {$group='ALL-ACTIVE';} + else {$group = $RS_group;} + } +if (!isset($usergroup)) + { + if (!isset($RS_usergroup)) {$usergroup='';} + else {$usergroup = $RS_usergroup;} + } +if (!isset($UGdisplay)) + { + if (!isset($RS_UGdisplay)) {$UGdisplay=0;} + else {$UGdisplay = $RS_UGdisplay;} + } +if (!isset($UidORname)) + { + if (!isset($RS_UidORname)) {$UidORname=1;} + else {$UidORname = $RS_UidORname;} + } +if (!isset($orderby)) + { + if (!isset($RS_orderby)) {$orderby='timeup';} + else {$orderby = $RS_orderby;} + } +if (!isset($SERVdisplay)) + { + if (!isset($RS_SERVdisplay)) {$SERVdisplay=0;} + else {$SERVdisplay = $RS_SERVdisplay;} + } +if (!isset($CALLSdisplay)) + { + if (!isset($RS_CALLSdisplay)) {$CALLSdisplay=1;} + else {$CALLSdisplay = $RS_CALLSdisplay;} + } +if (!isset($PHONEdisplay)) + { + if (!isset($RS_PHONEdisplay)) {$PHONEdisplay=0;} + else {$PHONEdisplay = $RS_PHONEdisplay;} + } +if (!isset($CUSTPHONEdisplay)) + { + if (!isset($RS_CUSTPHONEdisplay)) {$CUSTPHONEdisplay=0;} + else {$CUSTPHONEdisplay = $RS_CUSTPHONEdisplay;} + } +if (!isset($PAUSEcodes)) + { + if (!isset($RS_PAUSEcodes)) {$PAUSEcodes='N';} + else {$PAUSEcodes = $RS_PAUSEcodes;} + } +if (!isset($with_inbound)) + { + if (!isset($RS_with_inbound)) + { + if ($outbound_autodial_active > 0) + {$with_inbound='Y';} # N=no, Y=yes, O=only + else + {$with_inbound='O';} # N=no, Y=yes, O=only + } + else {$with_inbound = $RS_with_inbound;} + } +if (!isset($CARRIERstats)) + { + if (!isset($RS_CARRIERstats)) {$CARRIERstats='0';} + else {$CARRIERstats = $RS_CARRIERstats;} + } +if (!isset($PRESETstats)) + { + if (!isset($RS_PRESETstats)) {$PRESETstats='0';} + else {$PRESETstats = $RS_PRESETstats;} + } +if (!isset($AGENTtimeSTATS)) + { + if (!isset($RS_AGENTtimeSTATS)) {$AGENTtimeSTATS='0';} + else {$AGENTtimeSTATS = $RS_AGENTtimeSTATS;} + } +if (!isset($droppedOFtotal)) + { + if (!isset($RS_droppedOFtotal)) {$droppedOFtotal='0';} + else {$droppedOFtotal = $RS_droppedOFtotal;} + } + +$ingroup_detail=''; + +if ( (strlen($group)>1) and (strlen($groups[0])<1) ) {$groups[0] = $group;} +else {$group = $groups[0];} + +$NOW_TIME = date("Y-m-d H:i:s"); +$NOW_DAY = date("Y-m-d"); +$NOW_HOUR = date("H:i:s"); +$STARTtime = date("U"); +$epochONEminuteAGO = ($STARTtime - 60); +$timeONEminuteAGO = date("Y-m-d H:i:s",$epochONEminuteAGO); +$epochFIVEminutesAGO = ($STARTtime - 300); +$timeFIVEminutesAGO = date("Y-m-d H:i:s",$epochFIVEminutesAGO); +$epochFIFTEENminutesAGO = ($STARTtime - 900); +$timeFIFTEENminutesAGO = date("Y-m-d H:i:s",$epochFIFTEENminutesAGO); +$epochONEhourAGO = ($STARTtime - 3600); +$timeONEhourAGO = date("Y-m-d H:i:s",$epochONEhourAGO); +$epochSIXhoursAGO = ($STARTtime - 21600); +$timeSIXhoursAGO = date("Y-m-d H:i:s",$epochSIXhoursAGO); +$epochTWENTYFOURhoursAGO = ($STARTtime - 86400); +$timeTWENTYFOURhoursAGO = date("Y-m-d H:i:s",$epochTWENTYFOURhoursAGO); +$webphone_content=''; + +if ($non_latin < 1) + { + $PHP_AUTH_USER = preg_replace('/[^-_0-9a-zA-Z]/', '', $PHP_AUTH_USER); + $PHP_AUTH_PW = preg_replace('/[^-_0-9a-zA-Z]/', '', $PHP_AUTH_PW); + } +else + { + $PHP_AUTH_PW = preg_replace("/'|\"|\\\\|;/","",$PHP_AUTH_PW); + $PHP_AUTH_USER = preg_replace("/'|\"|\\\\|;/","",$PHP_AUTH_USER); + } +$RR = preg_replace('/[^0-9]/', '', $RR); +$inbound = preg_replace('/[^-_0-9a-zA-Z]/', '', $inbound); +$group = preg_replace('/[^-_0-9a-zA-Z]/', '', $group); +$groups[0] = preg_replace('/[^-_0-9a-zA-Z]/', '', $groups[0]); +$usergroup = preg_replace('/[^-_0-9a-zA-Z]/', '', $usergroup); +$DB = preg_replace('/[^0-9]/', '', $DB); +$adastats = preg_replace('/[^-_0-9a-zA-Z]/', '', $adastats); +$SIPmonitorLINK = preg_replace('/[^-_0-9a-zA-Z]/', '', $SIPmonitorLINK); +$IAXmonitorLINK = preg_replace('/[^-_0-9a-zA-Z]/', '', $IAXmonitorLINK); +$UGdisplay = preg_replace('/[^-_0-9a-zA-Z]/', '', $UGdisplay); +$UidORname = preg_replace('/[^-_0-9a-zA-Z]/', '', $UidORname); +$orderby = preg_replace('/[^-_0-9a-zA-Z]/', '', $orderby); +$SERVdisplay = preg_replace('/[^-_0-9a-zA-Z]/', '', $SERVdisplay); +$CALLSdisplay = preg_replace('/[^-_0-9a-zA-Z]/', '', $CALLSdisplay); +$PHONEdisplay = preg_replace('/[^-_0-9a-zA-Z]/', '', $PHONEdisplay); +$CUSTPHONEdisplay = preg_replace('/[^-_0-9a-zA-Z]/', '', $CUSTPHONEdisplay); +$NOLEADSalert = preg_replace('/[^-_0-9a-zA-Z]/', '', $NOLEADSalert); +$DROPINGROUPstats = preg_replace('/[^-_0-9a-zA-Z]/', '', $DROPINGROUPstats); +$ALLINGROUPstats = preg_replace('/[^-_0-9a-zA-Z]/', '', $ALLINGROUPstats); +$with_inbound = preg_replace('/[^-_0-9a-zA-Z]/', '', $with_inbound); +$monitor_active = preg_replace('/[^-_0-9a-zA-Z]/', '', $monitor_active); +$monitor_phone = preg_replace('/[^-_0-9a-zA-Z]/', '', $monitor_phone); +$CARRIERstats = preg_replace('/[^-_0-9a-zA-Z]/', '', $CARRIERstats); +$PRESETstats = preg_replace('/[^-_0-9a-zA-Z]/', '', $PRESETstats); +$AGENTtimeSTATS = preg_replace('/[^-_0-9a-zA-Z]/', '', $AGENTtimeSTATS); +$INGROUPcolorOVERRIDE = preg_replace('/[^-_0-9a-zA-Z]/', '', $INGROUPcolorOVERRIDE); +$droppedOFtotal = preg_replace('/[^-_0-9a-zA-Z]/', '', $droppedOFtotal); + +$stmt="SELECT selected_language from vicidial_users where user='$PHP_AUTH_USER';"; +if ($DB) {echo "|$stmt|\n";} +$rslt=mysql_to_mysqli($stmt, $link); +$sl_ct = mysqli_num_rows($rslt); +if ($sl_ct > 0) + { + $row=mysqli_fetch_row($rslt); + $VUselected_language = $row[0]; + } + +$auth=0; +$reports_auth=0; +$admin_auth=0; +$auth_message = user_authorization($PHP_AUTH_USER,$PHP_AUTH_PW,'REPORTS',1,0); +if ($auth_message == 'GOOD') + {$auth=1;} + +if ($auth > 0) + { + $stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and user_level > 7 and view_reports='1';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_to_mysqli($stmt, $link); + $row=mysqli_fetch_row($rslt); + $admin_auth=$row[0]; + + $stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and user_level > 6 and view_reports='1';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_to_mysqli($stmt, $link); + $row=mysqli_fetch_row($rslt); + $reports_auth=$row[0]; + + if ($reports_auth < 1) + { + $VDdisplayMESSAGE = _QXZ("You are not allowed to view reports"); + Header ("Content-type: text/html; charset=utf-8"); + echo "$VDdisplayMESSAGE: |$PHP_AUTH_USER|$auth_message|\n"; + exit; + } + if ( ($reports_auth > 0) and ($admin_auth < 1) ) + { + $ADD=999999; + $reports_only_user=1; + } + } +else + { + $VDdisplayMESSAGE = _QXZ("Login incorrect, please try again"); + if ($auth_message == 'LOCK') + { + $VDdisplayMESSAGE = _QXZ("Too many login attempts, try again in 15 minutes"); + Header ("Content-type: text/html; charset=utf-8"); + echo "$VDdisplayMESSAGE: |$PHP_AUTH_USER|$auth_message|\n"; + exit; + } + if ($auth_message == 'IPBLOCK') + { + $VDdisplayMESSAGE = _QXZ("Your IP Address is not allowed") . ": $ip"; + Header ("Content-type: text/html; charset=utf-8"); + echo "$VDdisplayMESSAGE: |$PHP_AUTH_USER|$auth_message|\n"; + exit; + } + Header("WWW-Authenticate: Basic realm=\"CONTACT-CENTER-ADMIN\""); + Header("HTTP/1.0 401 Unauthorized"); + echo "$VDdisplayMESSAGE: |$PHP_AUTH_USER|$PHP_AUTH_PW|$auth_message|\n"; + exit; + } + +##### BEGIN log visit to the vicidial_report_log table ##### +$LOGip = getenv("REMOTE_ADDR"); +$LOGbrowser = getenv("HTTP_USER_AGENT"); +$LOGscript_name = getenv("SCRIPT_NAME"); +$LOGserver_name = getenv("SERVER_NAME"); +$LOGserver_port = getenv("SERVER_PORT"); +$LOGrequest_uri = getenv("REQUEST_URI"); +$LOGhttp_referer = getenv("HTTP_REFERER"); +$LOGbrowser=preg_replace("/\'|\"|\\\\/","",$LOGbrowser); +$LOGrequest_uri=preg_replace("/\'|\"|\\\\/","",$LOGrequest_uri); +$LOGhttp_referer=preg_replace("/\'|\"|\\\\/","",$LOGhttp_referer); +if (preg_match("/443/i",$LOGserver_port)) {$HTTPprotocol = 'https://';} + else {$HTTPprotocol = 'http://';} +if (($LOGserver_port == '80') or ($LOGserver_port == '443') ) {$LOGserver_port='';} +else {$LOGserver_port = ":$LOGserver_port";} +$LOGfull_url = "$HTTPprotocol$LOGserver_name$LOGserver_port$LOGrequest_uri"; + +$LOGhostname = php_uname('n'); +if (strlen($LOGhostname)<1) {$LOGhostname='X';} +if (strlen($LOGserver_name)<1) {$LOGserver_name='X';} + +$stmt="SELECT webserver_id FROM vicidial_webservers where webserver='$LOGserver_name' and hostname='$LOGhostname' LIMIT 1;"; +$rslt=mysql_to_mysqli($stmt, $link); +if ($DB) {echo "$stmt\n";} +$webserver_id_ct = mysqli_num_rows($rslt); +if ($webserver_id_ct > 0) + { + $row=mysqli_fetch_row($rslt); + $webserver_id = $row[0]; + } +else + { + ##### insert webserver entry + $stmt="INSERT INTO vicidial_webservers (webserver,hostname) values('$LOGserver_name','$LOGhostname');"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_to_mysqli($stmt, $link); + $affected_rows = mysqli_affected_rows($link); + $webserver_id = mysqli_insert_id($link); + } + +$stmt="INSERT INTO vicidial_report_log set event_date=NOW(), user='$PHP_AUTH_USER', ip_address='$LOGip', report_name='$report_name', browser='$LOGbrowser', referer='$LOGhttp_referer', notes='$LOGserver_name:$LOGserver_port $LOGscript_name |$groups[0]|', url='$LOGfull_url', webserver='$webserver_id';"; +if ($DB) {echo "|$stmt|\n";} +$rslt=mysql_to_mysqli($stmt, $link); +$report_log_id = mysqli_insert_id($link); +##### END log visit to the vicidial_report_log table ##### + +if ( (strlen($slave_db_server)>5) and (preg_match("/$report_name/",$reports_use_slave_db)) ) + { + mysqli_close($link); + $use_slave_server=1; + $db_source = 'S'; + require("dbconnect_mysqli.php"); + echo "\n"; + } + +if ($auth) + { + $stmt="SELECT user_id,user,pass,full_name,user_level,user_group,phone_login,phone_pass,delete_users,delete_user_groups,delete_lists,delete_campaigns,delete_ingroups,delete_remote_agents,load_leads,campaign_detail,ast_admin_access,ast_delete_phones,delete_scripts,modify_leads,hotkeys_active,change_agent_campaign,agent_choose_ingroups,closer_campaigns,scheduled_callbacks,agentonly_callbacks,agentcall_manual,vicidial_recording,vicidial_transfers,delete_filters,alter_agent_interface_options,closer_default_blended,delete_call_times,modify_call_times,modify_users,modify_campaigns,modify_lists,modify_scripts,modify_filters,modify_ingroups,modify_usergroups,modify_remoteagents,modify_servers,view_reports,vicidial_recording_override,alter_custdata_override,qc_enabled,qc_user_level,qc_pass,qc_finish,qc_commit,add_timeclock_log,modify_timeclock_log,delete_timeclock_log,alter_custphone_override,vdc_agent_api_access,modify_inbound_dids,delete_inbound_dids,active,alert_enabled,download_lists,agent_shift_enforcement_override,manager_shift_enforcement_override,shift_override_flag,export_reports,delete_from_dnc,email,user_code,territory,allow_alerts,callcard_admin,force_change_password,modify_shifts,modify_phones,modify_carriers,modify_labels,modify_statuses,modify_voicemail,modify_audiostore,modify_moh,modify_tts,modify_contacts,modify_same_user_level from vicidial_users where user='$PHP_AUTH_USER';"; + $rslt=mysql_to_mysqli($stmt, $link); + $row=mysqli_fetch_row($rslt); + $LOGfull_name =$row[3]; + $LOGuser_level =$row[4]; + $LOGuser_group =$row[5]; + $LOGdelete_users =$row[8]; + $LOGdelete_user_groups =$row[9]; + $LOGdelete_lists =$row[10]; + $LOGdelete_campaigns =$row[11]; + $LOGdelete_ingroups =$row[12]; + $LOGdelete_remote_agents =$row[13]; + $LOGload_leads =$row[14]; + $LOGcampaign_detail =$row[15]; + $LOGast_admin_access =$row[16]; + $LOGast_delete_phones =$row[17]; + $LOGdelete_scripts =$row[18]; + $LOGdelete_filters =$row[29]; + $LOGalter_agent_interface =$row[30]; + $LOGdelete_call_times =$row[32]; + $LOGmodify_call_times =$row[33]; + $LOGmodify_users =$row[34]; + $LOGmodify_campaigns =$row[35]; + $LOGmodify_lists =$row[36]; + $LOGmodify_scripts =$row[37]; + $LOGmodify_filters =$row[38]; + $LOGmodify_ingroups =$row[39]; + $LOGmodify_usergroups =$row[40]; + $LOGmodify_remoteagents =$row[41]; + $LOGmodify_servers =$row[42]; + $LOGview_reports =$row[43]; + $LOGmodify_dids =$row[56]; + $LOGdelete_dids =$row[57]; + $LOGmanager_shift_enforcement_override=$row[61]; + $LOGexport_reports =$row[64]; + $LOGdelete_from_dnc =$row[65]; + $LOGcallcard_admin =$row[70]; + $LOGforce_change_password =$row[71]; + $LOGmodify_shifts =$row[72]; + $LOGmodify_phones =$row[73]; + $LOGmodify_carriers =$row[74]; + $LOGmodify_labels =$row[75]; + $LOGmodify_statuses =$row[76]; + $LOGmodify_voicemail =$row[77]; + $LOGmodify_audiostore =$row[78]; + $LOGmodify_moh =$row[79]; + $LOGmodify_tts =$row[80]; + $LOGmodify_contacts =$row[81]; + $LOGmodify_same_user_level =$row[82]; + + $stmt="SELECT allowed_campaigns,allowed_reports,admin_viewable_groups,admin_viewable_call_times from vicidial_user_groups where user_group='$LOGuser_group';"; + $rslt=mysql_to_mysqli($stmt, $link); + $row=mysqli_fetch_row($rslt); + $LOGallowed_campaigns = $row[0]; + $LOGallowed_reports = $row[1]; + $LOGadmin_viewable_groups = $row[2]; + $LOGadmin_viewable_call_times = $row[3]; + + $LOGadmin_viewable_groupsSQL=''; + $valLOGadmin_viewable_groupsSQL=''; + $vmLOGadmin_viewable_groupsSQL=''; + if ( (!preg_match('/\-\-ALL\-\-/i',$LOGadmin_viewable_groups)) and (strlen($LOGadmin_viewable_groups) > 3) ) + { + $rawLOGadmin_viewable_groupsSQL = preg_replace("/ \-/",'',$LOGadmin_viewable_groups); + $rawLOGadmin_viewable_groupsSQL = preg_replace("/ /","','",$rawLOGadmin_viewable_groupsSQL); + $LOGadmin_viewable_groupsSQL = "and user_group IN('---ALL---','$rawLOGadmin_viewable_groupsSQL')"; + $whereLOGadmin_viewable_groupsSQL = "where user_group IN('---ALL---','$rawLOGadmin_viewable_groupsSQL')"; + $valLOGadmin_viewable_groupsSQL = "and val.user_group IN('---ALL---','$rawLOGadmin_viewable_groupsSQL')"; + $vmLOGadmin_viewable_groupsSQL = "and vm.user_group IN('---ALL---','$rawLOGadmin_viewable_groupsSQL')"; + } + else + {$admin_viewable_groupsALL=1;} + + } + +# and (preg_match("/MONITOR|BARGE|HIJACK|WHISPER/",$monitor_active) ) ) +if ( (!isset($monitor_phone)) or (strlen($monitor_phone)<1) ) + { + $stmt="select phone_login from vicidial_users where user='$PHP_AUTH_USER';"; + $rslt=mysql_to_mysqli($stmt, $link); + if ($DB) {echo "$stmt\n";} + $row=mysqli_fetch_row($rslt); + $monitor_phone = $row[0]; + } + +$stmt="SELECT realtime_block_user_info,user_group from vicidial_users where user='$PHP_AUTH_USER';"; +if ($DB) {echo "|$stmt|\n";} +$rslt=mysql_to_mysqli($stmt, $link); +$row=mysqli_fetch_row($rslt); +$realtime_block_user_info = $row[0]; +$LOGuser_group = $row[1]; + +$stmt="SELECT allowed_campaigns,allowed_reports,webphone_url_override,webphone_dialpad_override,webphone_systemkey_override from vicidial_user_groups where user_group='$LOGuser_group';"; +if ($DB) {echo "|$stmt|\n";} +$rslt=mysql_to_mysqli($stmt, $link); +$row=mysqli_fetch_row($rslt); +$LOGallowed_campaigns = $row[0]; +$LOGallowed_reports = $row[1]; +$webphone_url = $row[2]; +$webphone_dialpad_override = $row[3]; +$system_key = $row[4]; + +if ( (!preg_match("/$report_name/",$LOGallowed_reports)) and (!preg_match("/ALL REPORTS/",$LOGallowed_reports)) ) + { + Header("WWW-Authenticate: Basic realm=\"CONTACT-CENTER-ADMIN\""); + Header("HTTP/1.0 401 Unauthorized"); + echo _QXZ("You are not allowed to view this report").": |$PHP_AUTH_USER|$report_name|"._QXZ("$report_name")."|\n"; + exit; + } + +$LOGallowed_campaignsSQL=''; +$whereLOGallowed_campaignsSQL=''; +if ( (!preg_match("/ALL-/",$LOGallowed_campaigns)) ) + { + $rawLOGallowed_campaignsSQL = preg_replace("/ -/",'',$LOGallowed_campaigns); + $rawLOGallowed_campaignsSQL = preg_replace("/ /","','",$rawLOGallowed_campaignsSQL); + $LOGallowed_campaignsSQL = "and campaign_id IN('$rawLOGallowed_campaignsSQL')"; + $whereLOGallowed_campaignsSQL = "where campaign_id IN('$rawLOGallowed_campaignsSQL')"; + } +$regexLOGallowed_campaigns = " $LOGallowed_campaigns "; + +$allactivecampaigns=''; +$stmt="select campaign_id,campaign_name from vicidial_campaigns where active='Y' $LOGallowed_campaignsSQL order by campaign_id;"; +$rslt=mysql_to_mysqli($stmt, $link); +if ($DB) {echo "$stmt\n";} +$groups_to_print = mysqli_num_rows($rslt); +$i=0; +$LISTgroups[$i]='ALL-ACTIVE'; +$i++; +$groups_to_print++; +while ($i < $groups_to_print) + { + $row=mysqli_fetch_row($rslt); + $LISTgroups[$i] =$row[0]; + $LISTnames[$i] =$row[1]; + $allactivecampaigns .= "'$LISTgroups[$i]',"; + $i++; + } +$allactivecampaigns .= "''"; + +$i=0; +$group_string='|'; +$group_ct = count($groups); +while($i < $group_ct) + { + $groups[$i] = preg_replace('/[^-_0-9a-zA-Z]/', '', $groups[$i]); + if ( (preg_match("/ $groups[$i] /",$regexLOGallowed_campaigns)) or (preg_match("/ALL-/",$LOGallowed_campaigns)) ) + { + $group_string .= "$groups[$i]|"; + $group_SQL .= "'$groups[$i]',"; + $groupQS .= "&groups[]=$groups[$i]"; + } + + $i++; + } +$group_SQL = preg_replace('/,$/i', '',$group_SQL); + +$i=0; +$user_group_string='|'; +$user_group_ct = count($user_group_filter); +while($i < $user_group_ct) + { + $user_group_filter[$i] = preg_replace('/[^-_0-9a-zA-Z]/', '', $user_group_filter[$i]); +# if ( (preg_match("/ $user_group_filter[$i] /",$regexLOGallowed_campaigns)) or (preg_match("/ALL-/",$LOGallowed_campaigns)) ) +# { + $user_group_string .= "$user_group_filter[$i]|"; + $user_group_SQL .= "'$user_group_filter[$i]',"; + $usergroupQS .= "&user_group_filter[]=$user_group_filter[$i]"; +# } + + $i++; + } +$user_group_SQL = preg_replace('/,$/i', '',$user_group_SQL); + +### if no campaigns selected, display all +if ( ($group_ct < 1) or (strlen($group_string) < 2) ) + { + $groups[0] = 'ALL-ACTIVE'; + $group_string = '|ALL-ACTIVE|'; + $group = 'ALL-ACTIVE'; + $groupQS .= "&groups[]=ALL-ACTIVE"; + } +### if no user groups selected, display all +$user_group_none=0; +if ( ($user_group_ct < 1) or (strlen($user_group_string) < 2) ) + { + $user_group_filter[0] = 'ALL-GROUPS'; + $user_group_string = '|ALL-GROUPS|'; + $usergroupQS .= "&user_group_filter[]=ALL-GROUPS"; + $user_group_none=1; + } + +if ( (preg_match('/\s\-\-NONE\-\-\s/',$group_string) ) or ($group_ct < 1) ) + { + $all_active = 0; + $group_SQL = "''"; + $group_SQLand = "and FALSE"; + $group_SQLwhere = "where FALSE"; + } +elseif ( preg_match('/ALL\-ACTIVE/i',$group_string) ) + { + $all_active = 1; + $group_SQL = $allactivecampaigns; + $group_SQLand = "and campaign_id IN($allactivecampaigns)"; + $group_SQLwhere = "where campaign_id IN($allactivecampaigns)"; + } +else + { + $all_active = 0; + $group_SQLand = "and campaign_id IN($group_SQL)"; + $group_SQLwhere = "where campaign_id IN($group_SQL)"; + } + +if ( (preg_match('/\s\-\-NONE\-\-\s/',$user_group_string) ) or ($user_group_ct < 1) ) + { + $all_active_groups = 0; + $user_group_SQL = "''"; +# $user_group_SQLand = "and FALSE"; +# $user_group_SQLwhere = "where FALSE"; + } +elseif ( preg_match('/ALL\-GROUPS/i',$user_group_string) ) + { + $all_active_groups = 1; +# $user_group_SQL = ''; + $user_group_SQL = "'$rawLOGadmin_viewable_groupsSQL'"; +# $group_SQLand = "and campaign_id IN($allactivecampaigns)"; +# $group_SQLwhere = "where campaign_id IN($allactivecampaigns)"; + } +else + { + $all_active_groups = 0; +# $user_group_SQLand = "and user_group IN($user_group_SQL)"; +# $user_group_SQLwhere = "where user_group IN($user_group_SQL)"; + } + +$stmt="select user_group, group_name from vicidial_user_groups $whereLOGadmin_viewable_groupsSQL order by user_group;"; +$rslt=mysql_to_mysqli($stmt, $link); +if (!isset($DB)) {$DB=0;} +if ($DB) {echo "$stmt\n";} +$usergroups_to_print = mysqli_num_rows($rslt); +$i=0; +$usergroups[$i]='ALL-GROUPS'; +$usergroupnames[$i] = _QXZ("All user groups"); +$i++; +$usergroups_to_print++; +while ($i < $usergroups_to_print) + { + $row=mysqli_fetch_row($rslt); + $usergroups[$i] =$row[0]; + $usergroupnames[$i] =$row[1]; + $i++; + } + +if (!isset($RR)) {$RR=4;} + +$NFB = ''; +$NFE = ''; +$F=''; $FG=''; $B=''; $BG=''; + +$select_list = "
"; +$select_list .= ""; +$select_list .= "
"._QXZ("Select Campaigns").":
"; +$select_list .= ""; +$select_list .= "
("._QXZ("To select more than 1 campaign, hold down the Ctrl key and click").")"; + +$select_list .= "

"._QXZ("Select User Groups").":
"; +$select_list .= ""; + +$select_list .= "
"; +$select_list .= ""._QXZ("Close Panel")."

"; +$select_list .= ""; + +$select_list .= ""; + +$select_list .= ""; + +$select_list .= ""; +$select_list .= ""; + +if ($UGdisplay > 0) + { + $select_list .= ""; + } + +$select_list .= ""; + +$select_list .= ""; + +$select_list .= ""; + +## find if any selected campaigns have presets enabled +$presets_enabled=0; +$stmt="select count(*) from vicidial_campaigns where enable_xfer_presets='ENABLED' $group_SQLand;"; +$rslt=mysql_to_mysqli($stmt, $link); +if ($DB) {$OUToutput .= "$stmt\n";} +$presets_enabled_count = mysqli_num_rows($rslt); +if ($presets_enabled_count > 0) + { + $row=mysqli_fetch_row($rslt); + $presets_enabled = $row[0]; + } +if ($presets_enabled > 0) + { + $select_list .= ""; + } +else + { + $select_list .= ""; + } + +$select_list .= ""; + +$select_list .= ""; + +$select_list .= ""; + + +$select_list .= "
"; +$select_list .= _QXZ("Screen Refresh Rate").":
"; +$select_list .= _QXZ("Inbound").":
"; +$select_list .= _QXZ("Monitor").": "; +$select_list .= ""; +$select_list .= "
 
"; + $select_list .= _QXZ("Select User Group").": "; + $select_list .= "
"; +$select_list .= _QXZ("Dialable Leads Alert").":
"; +$select_list .= _QXZ("Show Drop In-Group Row").":
"; +$select_list .= _QXZ("Show Carrier Stats").":
"; + $select_list .= _QXZ("Show Presets Stats").":
"; +$select_list .= _QXZ("Agent Time Stats").":
"; +$select_list .= _QXZ("In-group color override").":
 

"; +$select_list .= ""; +$select_list .= "         "; +$select_list .= "
"; +$select_list .= "   "; +$select_list .= ""; +$select_list .= ""._QXZ("VERSION").": $version   "._QXZ("BUILD").": $build"; +$select_list .= "
"; + +$open_list = '
'._QXZ("Choose Report Display Options").'
'; + + + +##### BEGIN code for embedded webphone for monitoring ##### +if (strlen($monitor_phone)>1) + { + $stmt="SELECT extension,dialplan_number,server_ip,login,pass,protocol,conf_secret,is_webphone,use_external_server_ip,codecs_list,webphone_dialpad,outbound_cid,webphone_auto_answer from phones where login='$monitor_phone' and active = 'Y';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_to_mysqli($stmt, $link); + $Mph_ct = mysqli_num_rows($rslt); + if ($Mph_ct > 0) + { + $row=mysqli_fetch_row($rslt); + $extension = $row[0]; + $dialplan_number = $row[1]; + $webphone_server_ip = $row[2]; + $login = $row[3]; + $pass = $row[4]; + $protocol = $row[5]; + $conf_secret = $row[6]; + $is_webphone = $row[7]; + $use_external_server_ip = $row[8]; + $codecs_list = $row[9]; + $webphone_dialpad = $row[10]; + $outbound_cid = $row[11]; + $webphone_auto_answer = $row[12]; + + if ($is_webphone == 'Y') + { + ### build Iframe variable content for webphone here + $codecs_list = preg_replace("/ /",'',$codecs_list); + $codecs_list = preg_replace("/-/",'',$codecs_list); + $codecs_list = preg_replace("/&/",'',$codecs_list); + + $stmt="SELECT asterisk_version,web_socket_url,external_web_socket_url from servers where server_ip='$webphone_server_ip' LIMIT 1;"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_to_mysqli($stmt, $link); + $row=mysqli_fetch_row($rslt); + $asterisk_version = $row[0]; + $web_socket_url = $row[1]; + $external_web_socket_url = $row[2]; + if ( ($use_external_server_ip=='Y') and (strlen($external_web_socket_url) > 5) ) + {$web_socket_url = $external_web_socket_url;} + + if ($use_external_server_ip=='Y') + { + ##### find external_server_ip if enabled for this phone account + $stmt="SELECT external_server_ip FROM servers where server_ip='$webphone_server_ip' LIMIT 1;"; + $rslt=mysql_to_mysqli($stmt, $link); + if ($DB) {echo "$stmt\n";} + $exip_ct = mysqli_num_rows($rslt); + if ($exip_ct > 0) + { + $row=mysqli_fetch_row($rslt); + $webphone_server_ip = $row[0]; + } + } + if (strlen($webphone_url) < 6) + { + ##### find webphone_url in system_settings and generate IFRAME code for it ##### + $stmt="SELECT webphone_url FROM system_settings LIMIT 1;"; + $rslt=mysql_to_mysqli($stmt, $link); + if ($DB) {echo "$stmt\n";} + $wu_ct = mysqli_num_rows($rslt); + if ($wu_ct > 0) + { + $row=mysqli_fetch_row($rslt); + $webphone_url = $row[0]; + } + } + if (strlen($system_key) < 1) + { + ##### find system_key in system_settings if populated ##### + $stmt="SELECT webphone_systemkey FROM system_settings LIMIT 1;"; + $rslt=mysql_to_mysqli($stmt, $link); + if ($DB) {echo "$stmt\n";} + $wsk_ct = mysqli_num_rows($rslt); + if ($wsk_ct > 0) + { + $row=mysqli_fetch_row($rslt); + $system_key = $row[0]; + } + } + # echo ""; + if ( ($webphone_dialpad_override != 'DISABLED') and (strlen($webphone_dialpad_override) > 0) ) + {$webphone_dialpad = $webphone_dialpad_override;} + $webphone_options='INITIAL_LOAD'; + if ($webphone_dialpad == 'Y') {$webphone_options .= "--DIALPAD_Y";} + if ($webphone_dialpad == 'N') {$webphone_options .= "--DIALPAD_N";} + if ($webphone_dialpad == 'TOGGLE') {$webphone_options .= "--DIALPAD_TOGGLE";} + if ($webphone_dialpad == 'TOGGLE_OFF') {$webphone_options .= "--DIALPAD_OFF_TOGGLE";} + if ($webphone_auto_answer == 'Y') {$webphone_options .= "--AUTOANSWER_Y";} + if ($webphone_auto_answer == 'N') {$webphone_options .= "--AUTOANSWER_N";} + if (strlen($web_socket_url) > 5) {$webphone_options .= "--WEBSOCKETURL$web_socket_url";} + if ($DB > 0) {echo "";} + + $session_name='RTS01234561234567890'; + + ### base64 encode variables + $b64_phone_login = base64_encode($extension); + $b64_phone_pass = base64_encode($conf_secret); + $b64_session_name = base64_encode($session_name); + $b64_server_ip = base64_encode($webphone_server_ip); + $b64_callerid = base64_encode($outbound_cid); + $b64_protocol = base64_encode($protocol); + $b64_codecs = base64_encode($codecs_list); + $b64_options = base64_encode($webphone_options); + $b64_system_key = base64_encode($system_key); + + $WebPhonEurl = "$webphone_url?phone_login=$b64_phone_login&phone_login=$b64_phone_login&phone_pass=$b64_phone_pass&server_ip=$b64_server_ip&callerid=$b64_callerid&protocol=$b64_protocol&codecs=$b64_codecs&options=$b64_options&system_key=$b64_system_key"; + $webphone_content = ""; + } + } + } +##### END code for embedded webphone for monitoring ##### + + + +?> + + + + + + + + + + +\n"; +echo "$report_name: $group\n"; + + $android_header=1; + + require("admin_header.php"); + +echo "
"; + +echo "
\n"; +echo "\n"; +echo "\n"; + +echo ""; +echo ""; +echo ""; +echo ""; +echo ""; +echo ""; +echo ""; +echo ""; +echo ""; +echo ""; +echo "
"._QXZ("$report_name").""; + echo "\n"; + echo "
\n"; + echo ""._QXZ("Choose Report Display Options").""; + echo "
\n"; + echo "
\n"; +echo "
"; + echo "\n"; + echo "
\n"; + echo ""; + echo "
\n"; + echo "
\n"; +echo "
"; + echo ""._QXZ("RELOAD NOW").""; +echo ""; +# if (preg_match('/ALL\-ACTIVE/i',$group_string)) +# {echo ""._QXZ("MODIFY")." | \n";} +# else +# {echo ""._QXZ("MODIFY")." | \n";} +echo " "; + echo ""._QXZ("SUMMARY")." \n"; +echo ""; + echo ""._QXZ("refresh").": \n\n"; +echo "
"; + + echo "\n"; + echo "
\n"; + echo "$webphone_content\n$webphone_clpos\n"; + echo "
\n"; + echo "
\n"; +echo "\n"; +echo "   "; +echo "\n"; + +/* +echo ""._QXZ("$report_name")."                                                                                                   \n"; +echo "\n"; +echo "
\n"; +echo ""._QXZ("Choose Report Display Options").""; +echo "
\n"; +echo "
\n"; +echo "\n"; +echo "
\n"; +echo ""; +echo "
\n"; +echo "
\n"; +echo "\n"; +echo "
\n"; +echo "$webphone_content\n$webphone_clpos\n"; +echo "
\n"; +echo "
\n"; +echo "\n"; +echo "   "; +echo "\n"; +echo ""._QXZ("RELOAD NOW").""; +if (preg_match('/ALL\-ACTIVE/i',$group_string)) + {echo "     "._QXZ("MODIFY")." | \n";} +else + {echo "     "._QXZ("MODIFY")." | \n";} + +echo ""._QXZ("SUMMARY")."
\n"; + + +echo "       "._QXZ("refresh").": \n\n"; +*/ + +if (!preg_match("/WALL/",$report_display_type)) + { + if ($is_webphone == 'Y') + {echo "     "._QXZ("webphone")." +\n\n";} + else + {echo "     \n\n";} + + if ($webphone_bufh > 10) + {echo "
\n";} + echo "
\n\n"; + + + if ($UGdisplay>0) + {echo " "._QXZ("HIDE USER GROUP")."";} + else + {echo " "._QXZ("VIEW USER GROUP")."";} + if ($SERVdisplay>0) + {echo "     "._QXZ("HIDE SERVER INFO")."";} + else + {echo "     "._QXZ("SHOW SERVER INFO")."";} + if ($CALLSdisplay>0) + {echo "     "._QXZ("HIDE WAITING CALLS")."";} + else + {echo "     "._QXZ("SHOW WAITING CALLS")."";} + if ($ALLINGROUPstats>0) + {echo "     "._QXZ("HIDE IN-GROUP STATS")."";} + else + {echo "     "._QXZ("SHOW IN-GROUP STATS")."";} + if ($PHONEdisplay>0) + {echo "     "._QXZ("HIDE PHONES")."";} + else + {echo "     "._QXZ("SHOW PHONES")."";} + if ($CUSTPHONEdisplay>0) + {echo "     "._QXZ("HIDE CUSTPHONES")."";} + else + {echo "     "._QXZ("SHOW CUSTPHONES")."";} + } + +#echo "
"; +##### END header formatting ##### + +#echo "
"; + +echo "\n"; + + + + + + +if ($db_source == 'S') + { + mysqli_close($link); + $use_slave_server=0; + $db_source = 'M'; + require("dbconnect_mysqli.php"); + } + +$endMS = microtime(); +$startMSary = explode(" ",$startMS); +$endMSary = explode(" ",$endMS); +$runS = ($endMSary[0] - $startMSary[0]); +$runM = ($endMSary[1] - $startMSary[1]); +$TOTALrun = ($runS + $runM); + +$stmt="UPDATE vicidial_report_log set run_time='$TOTALrun' where report_log_id='$report_log_id';"; +if ($DB) {echo "|$stmt|\n";} +$rslt=mysql_to_mysqli($stmt, $link); + + +?> +
+ + + 0) +{ +echo "\n"; +} +?> + + diff --git a/www/vicidial/vicidial_stylesheet.php b/www/vicidial/vicidial_stylesheet.php index 64e2e904..8b63a9fe 100644 --- a/www/vicidial/vicidial_stylesheet.php +++ b/www/vicidial/vicidial_stylesheet.php @@ -1,12 +1,13 @@ , Joe Johnson LICENSE: AGPLv2 +# Copyright (C) 2019 Matt Florell , Joe Johnson LICENSE: AGPLv2 # # CSS/PHP file that uses the system-defined screen colors to display report elements # # 170830-2123 - First build # 180501-0045 - New elements added +# 190129-1303 - New mobile display elements added require("dbconnect_mysqli.php"); require("functions.php"); @@ -71,6 +72,79 @@ redalert {font-size: 18px; font-weight:bold; font-family: Arial, Sans-Serif; col .border2px {border:solid 2px #} +.android_standard { + font-family: Arial, Helvetica, sans-serif; + font-size: 8pt; +} +.android_large { + font-family: Arial, Helvetica, sans-serif; + font-size: 10pt; + font-weight: bold; +} +.android_auto { + font-family: Arial, Helvetica, sans-serif; + font-weight: bold; + font-size: calc(14px + (26 - 14) * ((100vw - 300px) / (1600 - 300))); + line-height: calc(1.3em + (1.5 - 1.2) * ((100vw - 300px)/(1600 - 300))); +} +.android_auto_small { + font-family: Arial, Helvetica, sans-serif; + font-size: calc(8px + (18 - 8) * ((100vw - 300px) / (1600 - 300))); + line-height: calc(1.3em + (1.5 - 1.2) * ((100vw - 300px)/(1600 - 300))); +} +.android_whiteboard_small { + font-family: Arial, Helvetica, sans-serif; + font-size: calc(8px + (16 - 8) * ((100vw - 300px) / (1600 - 300))); + line-height: calc(1.3em + (1.5 - 1.2) * ((100vw - 300px)/(1600 - 300))); +} +.android_campaign_header { + FONT-FAMILY: Courier; + FONT-WEIGHT: bold; + FONT-SIZE: calc(4px + (18 - 4) * ((100vw - 300px) / (1600 - 300))); +} +.android_auto_percent { + font-family: Arial, Helvetica, sans-serif; + font-weight: bold; + width: 24vw; + font-size: calc(14px + (26 - 14) * ((100vw - 300px) / (1600 - 300))); + line-height: calc(1.3em + (1.5 - 1.2) * ((100vw - 300px)/(1600 - 300))); +} +.mobile_whiteboard_td_lg {width: 40vw; max-width: 400px;} +.mobile_whiteboard_td_sm {width: 30vw; max-width: 300px;} +.mobile_whiteboard_select {width: 27vw; max-width: 270px;} +.mobile_whiteboard_button {width: 15vw; max-width: 150px;} +.mobile_whiteboard_display {width: 80vw; max-width:800px; height:70vh; max-height:800px;} + +.autosize_10 {width: 10vw; max-width: 160px;} +.autosize_12 {width: 12vw; max-width: 180px;} + +/* + LEVEL ONE MENU +*/ +ul.dropdown_android { position: relative;} +ul.dropdown_android li { font-weight: bold; float: left; } +ul.dropdown_android a:hover { color: #000; } +ul.dropdown_android a:active { color: #ffa500; } +ul.dropdown_android li a { display: block; border-right: 1px solid #333; color: #222; } +ul.dropdown_android li:last-child a { border-right: none; } /* Doesn't work in IE */ +ul.dropdown_android li.hover, +ul.dropdown_android li:hover { position: relative; } + + +/* + LEVEL TWO MENU +*/ +ul.dropdown_android ul { width: calc(25px + (150 - 25) * ((100vw - 300px) / (1600 - 300))); visibility: hidden; position: absolute; top: 100%; left: -40;} +ul.dropdown_android ul li { font-weight: normal; float: none; top: 100%; margin-top:-4;} + +/* IE 6 & 7 Needs Inline Block */ +ul.dropdown_android ul li a { border-right: none; width: 100%; display: inline-block; } + +/* + LEVEL THREE MENU +*/ +ul.dropdown_android ul ul { left: 100%; top: 0; } +ul.dropdown_android li:hover > ul { visibility: visible; } .records_list_x{ @@ -133,6 +207,10 @@ redalert {font-size: 18px; font-weight:bold; font-family: Arial, Sans-Serif; col padding: 2px; border: solid 1px #; } +.form_field_android { + font-family: Arial, Sans-Serif; + FONT-SIZE: calc(4px + (12 - 4) * ((100vw - 300px) / (1600 - 300))); +} .required_field { font-family: Arial, Sans-Serif; font-size: 10px; @@ -174,6 +252,34 @@ input.red_btn{ border-right-color:#330000; border-bottom-color:#330000; } +input.red_btn_mobile{ + font-family: Arial, Sans-Serif; + font-size: calc(4px + (12 - 4) * ((100vw - 300px) / (1600 - 300))); + width: 10vw; + max-width:250px; + color:#FFFFFF; + font-weight:bold; + background-color:#990000; + border:2px solid; + border-top-color:#FFCCCC; + border-left-color:#FFCCCC; + border-right-color:#330000; + border-bottom-color:#330000; +} +input.red_btn_mobile_lg{ + font-family: Arial, Sans-Serif; + font-size: calc(4px + (12 - 4) * ((100vw - 300px) / (1600 - 300))); + width: 15vw; + max-width:200px; + color:#FFFFFF; + font-weight:bold; + background-color:#990000; + border:2px solid; + border-top-color:#FFCCCC; + border-left-color:#FFCCCC; + border-right-color:#330000; + border-bottom-color:#330000; +} input.green_btn{ font-family: Arial, Sans-Serif; font-size: 12px; @@ -186,6 +292,34 @@ input.green_btn{ border-right-color:#003300; border-bottom-color:#003300; } +input.green_btn_mobile{ + font-family: Arial, Sans-Serif; + font-size: calc(4px + (12 - 4) * ((100vw - 300px) / (1600 - 300))); + width: 10vw; + max-width:250px; + color:#FFFFFF; + font-weight:bold; + background-color:#009900; + border:2px solid; + border-top-color:#CCFFCC; + border-left-color:#CCFFCC; + border-right-color:#003300; + border-bottom-color:#003300; +} +input.green_btn_mobile_lg{ + font-family: Arial, Sans-Serif; + font-size: calc(4px + (12 - 4) * ((100vw - 300px) / (1600 - 300))); + width: 15vw; + max-width:200px; + color:#FFFFFF; + font-weight:bold; + background-color:#009900; + border:2px solid; + border-top-color:#CCFFCC; + border-left-color:#CCFFCC; + border-right-color:#003300; + border-bottom-color:#003300; +} input.blue_btn{ font-family: Arial, Sans-Serif; font-size: 12px; @@ -198,6 +332,18 @@ input.blue_btn{ border-right-color:#000033; border-bottom-color:#000033; } +input.blue_btn_mobile{ + font-family: Arial, Sans-Serif; + font-size: calc(4px + (10 - 4) * ((100vw - 300px) / (1600 - 300))); + color:#FFFFFF; + font-weight:bold; + background-color:#000099; + border:2px solid; + border-top-color:#CCCCFF; + border-left-color:#CCCCFF; + border-right-color:#000033; + border-bottom-color:#000033; +} input.tiny_red_btn{ color:#FFFFFF; font-size:9px; @@ -277,6 +423,16 @@ TABLE.help_td { vertical-align: top; border:solid 4px # } +TABLE.panel_td { + padding: 5px; + font-family: Arial, Helvetica, sans-serif; + color: black; + font-size: 12pt; + font-weight: bold; + background: #; + color: #000000; + vertical-align: top; +} TD.panel_td { padding: 5px; @@ -302,6 +458,16 @@ TD.search_td { vertical-align: top; border:solid 2px #600 } +TD.bbottom { + border-bottom:1pt solid black; +} +TD.btop { + border-top:1pt solid black; +} +TD.bsides { + border-left:1pt solid black; + border-right:1pt solid black; +} /* DIV ELEMENTS */ div.shadowbox @@ -360,8 +526,165 @@ FONT-FAMILY: Courier; padding-left:10px; } +div.android_switchbutton +{ +background-color:#FFCCCC; +box-shadow: 3px 3px 1px #000000; +border:2px solid; +WIDTH: calc(25px + (200 - 25) * ((100vw - 300px) / (1600 - 300))); +FONT-WEIGHT: bold; +FONT-SIZE: calc(6px + (24 - 6) * ((100vw - 300px) / (1600 - 300))); +FONT-FAMILY: Courier; +padding-left:3px; +padding-right:3px; +} +div.android_switchbutton_blue +{ +background-color:#99CCFF; +box-shadow: 3px 3px 1px #000000; +border:2px solid; +WIDTH: calc(25px + (200 - 25) * ((100vw - 300px) / (1600 - 300))); +FONT-WEIGHT: bold; +FONT-SIZE: calc(6px + (24 - 6) * ((100vw - 300px) / (1600 - 300))); +FONT-FAMILY: Courier; +padding-left:3px; +padding-right:3px; +} +div.android_offbutton +{ +background-color:#CCCCCC; +box-shadow: 3px 3px 1px #000000; +border:2px solid; +WIDTH: calc(25px + (200 - 25) * ((100vw - 300px) / (1600 - 300))); +FONT-WEIGHT: bold; +font-color: white; +FONT-SIZE: calc(6px + (24 - 6) * ((100vw - 300px) / (1600 - 300))); +FONT-FAMILY: Courier; +padding-left:3px; +padding-right:3px; +} +div.android_onbutton +{ +background-color:#FFFFFF; +box-shadow: 3px 3px 1px #000000; +border:2px solid; +WIDTH: calc(25px + (200 - 25) * ((100vw - 300px) / (1600 - 300))); +FONT-WEIGHT: bold; +FONT-SIZE: calc(6px + (24 - 6) * ((100vw - 300px) / (1600 - 300))); +FONT-FAMILY: Courier; +padding-left:3px; +padding-right:3px; +} +div.android_offbutton_noshadow +{ +background-color:#CCCCCC; +border:2px solid; +WIDTH: calc(25px + (200 - 25) * ((100vw - 300px) / (1600 - 300))); +FONT-WEIGHT: bold; +font-color: white; +FONT-SIZE: calc(6px + (24 - 6) * ((100vw - 300px) / (1600 - 300))); +FONT-FAMILY: Courier; +padding-left:3px; +padding-right:3px; +} +div.android_onbutton_noshadow +{ +background-color:#FFFFFF; +border:2px solid; +WIDTH: calc(25px + (200 - 25) * ((100vw - 300px) / (1600 - 300))); +FONT-WEIGHT: bold; +FONT-SIZE: calc(6px + (24 - 6) * ((100vw - 300px) / (1600 - 300))); +FONT-FAMILY: Courier; +padding-left:3px; +padding-right:3px; +} +div.dropdown_android_button +{ +background-color:#CCCCCC; +box-shadow: 3px 3px 1px #000000; +border:2px solid; +WIDTH: calc(25px + (200 - 25) * ((100vw - 300px) / (1600 - 300))); +FONT-WEIGHT: bold; +FONT-SIZE: calc(6px + (24 - 6) * ((100vw - 300px) / (1600 - 300))); +FONT-FAMILY: Courier; +padding-left:3px; +padding-right:3px; +} +div.dropdown_android_button:hover{ +background-color: #F3D673; +color: black; +} +div.android_offbutton_large +{ +background-color:#999999; +box-shadow: 3px 3px 1px #000000; +border:2px solid; +WIDTH: calc(50px + (320 - 50) * ((100vw - 300px) / (1600 - 300))); +FONT-WEIGHT: bold; +font-color: white; +FONT-SIZE: calc(6px + (24 - 6) * ((100vw - 300px) / (1600 - 300))); +FONT-FAMILY: Courier; +padding-left:3px; +padding-right:3px; +} +div.android_onbutton_large +{ +background-color:#FFFFFF; +box-shadow: 3px 3px 1px #000000; +border:2px solid; +WIDTH: calc(60px + (320 - 60) * ((100vw - 300px) / (1600 - 300))); +FONT-WEIGHT: bold; +FONT-SIZE: calc(6px + (24 - 6) * ((100vw - 300px) / (1600 - 300))); +FONT-FAMILY: Courier; +padding-left:3px; +padding-right:3px; +} +div.android_table +{ +WIDTH: 100vw; +border:5px solid; +border-radius:5px; +padding-left:3px; +border-color:#; +background-color:#; +} +div.android_settings_table +{ +WIDTH: 94vw; +border:5px solid; +border-radius:5px; +padding-left:3px; +border-color:#; +background-color:#; +} div.help_info {position:absolute; top:0; left:0; display:none;} +span.android_offbutton +{ +background-color:#999999; +box-shadow: 3px 3px 1px #000000; +border:2px solid; +border-radius:5px; +FONT-WEIGHT: bold; +font-color: white; +FONT-SIZE: calc(8px + (14 - 8) * ((100vw - 300px) / (1600 - 300))); +FONT-FAMILY: Courier; +padding-left:3px; +padding-right:3px; +} +span.android_onbutton +{ +background-color:#FFFFFF; +box-shadow: 3px 3px 1px #000000; +border:2px solid; +border-radius:5px; +FONT-WEIGHT: bold; +FONT-SIZE: calc(8px + (14 - 8) * ((100vw - 300px) / (1600 - 300))); +FONT-FAMILY: Courier; +padding-left:3px; +padding-right:3px; +} + .button_active { background-color: #4CAF50; /* Green */ border: 1px solid green; diff --git a/www/vicidial/vicidial_whiteboard_functions.php b/www/vicidial/vicidial_whiteboard_functions.php index 2372c701..3d0d7d1d 100644 --- a/www/vicidial/vicidial_whiteboard_functions.php +++ b/www/vicidial/vicidial_whiteboard_functions.php @@ -1,14 +1,19 @@ // vicidial_whiteboard_functions.php // -// Copyright (C) 2017 Matt Florell , Joe Johnson LICENSE: AGPLv2 +// Copyright (C) 2019 Matt Florell , Joe Johnson LICENSE: AGPLv2 // -// Javascript file used in AST_rt_whiteboard_reports.php +// Javascript file used in AST_rt_whiteboard_reports.php and AST_rt_whiteboard_report_mobile.php // // 171027-2352 - First build +// 190226-1645 - Added mobile variable for mobile versions of reports // var main_canvas = document.getElementById("MainReportCanvas"); @@ -36,7 +41,7 @@ var TGArray_holder=new Array(); function StartRefresh(refresh_rate) { document.getElementById("loading_display").style.display="block"; - if (!refresh_rate) {refresh_rate=5;} + if (!refresh_rate) {refresh_rate=30; RefreshReportWindow();} document.getElementById("query_date2").value=document.getElementById("query_date").value; // document.getElementById("end_date2").value=document.getElementById("end_date").value; document.getElementById("query_time2").value=document.getElementById("query_time").value; @@ -110,9 +115,11 @@ function HighlightRelatedFields(report_type) { } } + document.getElementById("goto_reports").onclick = function() { location.href = "./admin.php?ADD=999999"; }; + document.getElementById("adjust_report").onclick = function() { document.getElementById("query_date").value=document.getElementById("query_date2").value; // document.getElementById("end_date").value=document.getElementById("end_date2").value; @@ -126,7 +133,6 @@ document.getElementById("adjust_report").onclick = function() { function RefreshReportWindow() { - document.getElementById("loading_display").style.display="none"; var query_date=document.getElementById("query_date").value; // var end_date=document.getElementById("end_date").value; var query_time=document.getElementById("query_time").value; @@ -289,6 +295,7 @@ function RefreshReportWindow() { var Top10Entries=0; var PrevTop10Value=0; var Top10Limit="off"; + var alert_text=""; for (var i = 0; i < arrayLength; i++) { @@ -335,6 +342,7 @@ function RefreshReportWindow() { SPHArray[i]=agent_array[7]; TotalCallCountArray[i]=agent_array[8]; TotalCallCount=agent_array[8]; TotalSaleCountArray[i]=agent_array[9]; TotalSaleCount=agent_array[9]; + alert_text=agent_array[10]; TPAArray[i]=target_per_agent; TGArray[i]=target_gross; } @@ -344,7 +352,7 @@ function RefreshReportWindow() { var Top10HTMLChart="
"; Top10HTMLChart+=""; - Top10HTMLChart+=""; + Top10HTMLChart+=""; Top10HTMLChart+=""; Top10HTMLChart+=""; Top10HTMLChart+=""; @@ -641,6 +649,8 @@ function RefreshReportWindow() { // MainGraph.update(); } + document.getElementById("loading_display").style.display="none"; + /* myLineChart.destroy(); diff --git a/www/vicidial/whiteboard_reports.php b/www/vicidial/whiteboard_reports.php index 44018631..749e0caf 100644 --- a/www/vicidial/whiteboard_reports.php +++ b/www/vicidial/whiteboard_reports.php @@ -1,11 +1,12 @@ , Joe Johnson LICENSE: AGPLv2 +# Copyright (C) 2019 Matt Florell , Joe Johnson LICENSE: AGPLv2 # # A PHP file that is for generating the stats that are displayed in the whiteboard report. Returns values. # # 171027-2352 - First build +# 190302-1707 - Added code to exclude active calls from being counted with some stats # require("dbconnect_mysqli.php"); @@ -70,6 +71,10 @@ if ($hourly_display) $rpt_string=""; +$exclude_statuses=array("INCALL", "DISPO", "QUEUE", "DONEM"); +$exc_status_SQL=" and status not in ('".implode("','", $exclude_statuses)."') "; + + $query_date=preg_replace("/[^0-9\-]/", "", $query_date); $end_date=preg_replace("/[^0-9\-]/", "", $end_date); $query_time=preg_replace("/[^0-9\:]/", "", $query_time); @@ -123,7 +128,7 @@ if (preg_match("/status_performance/", $rpt_type)) { $status_SQL=" and status in ($status_str) "; } - $sale_stmt="SELECT distinct status from vicidial_statuses where sale='Y' $status_SQL UNION SELECT distinct status from vicidial_campaign_statuses where sale='Y' $campaign_id_SQL $status_SQL"; + $sale_stmt="SELECT distinct status from vicidial_statuses where sale='Y' $status_SQL $exc_status_SQL UNION SELECT distinct status from vicidial_campaign_statuses where sale='Y' $campaign_id_SQL $status_SQL $exc_status_SQL"; $sale_rslt=mysql_to_mysqli($sale_stmt, $link); $sale_dispos=array(); if ($DB) {$rpt_string.=$sale_stmt."
\n";} @@ -134,13 +139,13 @@ if (preg_match("/status_performance/", $rpt_type)) { $shift_start="$query_date $query_time"; $shift_end="$end_date $end_time"; - $outbound_max_time_stmt="SELECT if(min(call_date) is null, 0, min(call_date)), if(max(call_date) is null, 0, max(call_date)) From vicidial_log where call_date>='$query_date $query_time' and call_date<='$end_date $end_time' $campaign_id_SQL $user_SQL $status_SQL"; + $outbound_max_time_stmt="SELECT if(min(call_date) is null, 0, min(call_date)), if(max(call_date) is null, 0, max(call_date)) From vicidial_log where call_date>='$query_date $query_time' and call_date<='$end_date $end_time' $campaign_id_SQL $user_SQL $status_SQL $exc_status_SQL"; $rslt=mysql_to_mysqli($outbound_max_time_stmt, $link); $row=mysqli_fetch_row($rslt); if ($row[0]>0) {$shift_start=$row[0];} if ($row[1]>0) {$shift_end=$row[1];} - $inbound_max_time_stmt="SELECT if(min(call_date) is null, 0, min(call_date)), if(max(call_date) is null, 0, max(call_date)) From vicidial_closer_log where call_date>='$query_date $query_time' and call_date<='$end_date $end_time' $group_SQL $user_SQL $status_SQL"; + $inbound_max_time_stmt="SELECT if(min(call_date) is null, 0, min(call_date)), if(max(call_date) is null, 0, max(call_date)) From vicidial_closer_log where call_date>='$query_date $query_time' and call_date<='$end_date $end_time' $group_SQL $user_SQL $status_SQL $exc_status_SQL"; $rslt=mysql_to_mysqli($inbound_max_time_stmt, $link); $row=mysqli_fetch_row($rslt); if ($row[0]>0 && preg_replace("/[^0-9]/", "", $row[0]) $key, 'counts' => $val[0], 'sales' => $val[1], 'dead' => $val[2]); + } + + foreach ($kstatus_counts as $key2 => $row2) { + $status_ary[$key2] = $row2['status']; + $counts_ary[$key2] = $row2['counts']; + $sales_ary[$key2] = $row2['sales']; + $dead_ary[$key2] = $row2['dead']; + } + + array_multisort($status_ary, SORT_ASC, $counts_ary, SORT_ASC, $sales_ary, SORT_ASC, $dead_ary, SORT_ASC, $kstatus_counts); + if (count($status_counts)==0) { $rpt_string="REPORT RETURNED NO RESULTS"; } else { - while(list($key, $val)=each($status_counts)) { +# while(list($key, $val)=each($status_counts)) { + foreach ($kstatus_counts as $row) { + $key=$row['status']; + $val0=$row['counts']; + $val1=$row['sales']; - $val[0]+=0; - $val[1]+=0; - $total_calls+=$val[0]; - $total_sales+=$val[1]; + $val0+=0; + $val1+=0; + $total_calls+=$val0; + $total_sales+=$val1; $conv_rate=sprintf("%.2f", 100*MathZDC($val[1], $val[0])); # Conversion rate $cph=sprintf("%.2f", (MathZDC($val[0], ($shift_duration/3600)))); # SPH - this is based on total time since start_time. Switch to $val[2] if you want it based on the individual agent's total time in the dialer. $sph=sprintf("%.2f", (MathZDC($val[1], ($shift_duration/3600)))); # SPH - this is based on total time since start_time. Switch to $val[2] if you want it based on the individual agent's total time in the dialer. - $rpt_string.="$key|$full_name|$val[0]|$val[1]|$shift_duration|$conv_rate|$cph|$sph|$total_calls|$total_sales\n"; + $rpt_string.="$key|$full_name|$val0|$val1|$shift_duration|$conv_rate|$cph|$sph|$total_calls|$total_sales|$inbound_stmt - $outbound_stmt\n"; # Agent/user group, total calls, total sales, total time, conversion rate, sales per hour } } @@ -243,7 +265,7 @@ if (preg_match("/(agent|team)_performance/", $rpt_type)) { $time_row=mysqli_fetch_row($time_rslt); $shift_duration=$time_row[0]; - $sale_stmt="SELECT distinct status from vicidial_statuses where sale='Y' $status_SQL UNION SELECT distinct status from vicidial_campaign_statuses where sale='Y' $campaign_id_SQL $status_SQL"; + $sale_stmt="SELECT distinct status from vicidial_statuses where sale='Y' $status_SQL $exc_status_SQL UNION SELECT distinct status from vicidial_campaign_statuses where sale='Y' $campaign_id_SQL $status_SQL $exc_status_SQL"; $sale_rslt=mysql_to_mysqli($sale_stmt, $link); $sale_dispos=array(); if ($DB) {$rpt_string.=$sale_stmt."
\n";} @@ -252,9 +274,9 @@ if (preg_match("/(agent|team)_performance/", $rpt_type)) { } if (preg_match("/agent_performance/", $rpt_type)) { - $stmt="SELECT user, status, sum(pause_sec+wait_sec+talk_sec+dispo_sec), count(*) from vicidial_agent_log where event_time>='$query_date $query_time' and event_time<='$end_date $end_time' $campaign_id_SQL $user_SQL $user_group_SQL $status_SQL group by user, status order by user, status"; + $stmt="SELECT user, status, sum(pause_sec+wait_sec+talk_sec+dispo_sec), count(*) from vicidial_agent_log where event_time>='$query_date $query_time' and event_time<='$end_date $end_time' $campaign_id_SQL $user_SQL $user_group_SQL $status_SQL $exc_status_SQL group by user, status order by user, status"; } else if (preg_match("/team_performance/", $rpt_type)) { - $stmt="SELECT user_group, status, sum(pause_sec+wait_sec+talk_sec+dispo_sec), count(*) from vicidial_agent_log where event_time>='$query_date $query_time' and event_time<='$end_date $end_time' $campaign_id_SQL $user_SQL $user_group_SQL $status_SQL group by user_group, status order by user_group, status"; + $stmt="SELECT user_group, status, sum(pause_sec+wait_sec+talk_sec+dispo_sec), count(*) from vicidial_agent_log where event_time>='$query_date $query_time' and event_time<='$end_date $end_time' $campaign_id_SQL $user_SQL $user_group_SQL $status_SQL $exc_status_SQL group by user_group, status order by user_group, status"; } if ($DB) {$rpt_string.=$stmt."
\n";} @@ -275,7 +297,12 @@ if (preg_match("/(agent|team)_performance/", $rpt_type)) { $rpt_string="REPORT RETURNED NO RESULTS"; } else { while(list($key, $val)=each($agent_counts)) { - $user_stmt="SELECT full_name from vicidial_users where user='$key'"; + $full_name=""; + if (preg_match('/team_performance/', $rpt_type)) { + $user_stmt="select group_name from vicidial_user_groups where user_group='$key'"; + } else { + $user_stmt="SELECT full_name from vicidial_users where user='$key'"; + } $user_rslt=mysql_to_mysqli($user_stmt, $link); while ($user_row=mysqli_fetch_row($user_rslt)) { $full_name=$user_row[0]; @@ -344,7 +371,7 @@ if (preg_match("/floor_performance/", $rpt_type)) { $status_SQL=" and status in ($status_str) "; } - $sale_stmt="SELECT distinct status from vicidial_statuses where sale='Y' $status_SQL UNION SELECT distinct status from vicidial_campaign_statuses where sale='Y' and campaign_id in ('".implode("','", $campaigns)."') $status_SQL"; + $sale_stmt="SELECT distinct status from vicidial_statuses where sale='Y' $status_SQL $exc_status_SQL UNION SELECT distinct status from vicidial_campaign_statuses where sale='Y' and campaign_id in ('".implode("','", $campaigns)."') $status_SQL $exc_status_SQL"; # $rpt_string.="$sale_stmt\n"; $sale_rslt=mysql_to_mysqli($sale_stmt, $link); $sale_dispos=array(); @@ -352,7 +379,7 @@ if (preg_match("/floor_performance/", $rpt_type)) { array_push($sale_dispos, $sale_row[0]); } - $stmt="SELECT substr(event_time+INTERVAL (pause_sec+wait_sec+talk_sec+dispo_sec) SECOND, 1, 16) as call_end_time_min, status, count(*) from vicidial_agent_log where event_time>='$query_date $query_time' and event_time<='$end_date $end_time' $campaign_id_SQL $user_SQL $user_group_SQL $status_SQL group by call_end_time_min, status order by call_end_time_min, status"; + $stmt="SELECT substr(event_time+INTERVAL (pause_sec+wait_sec+talk_sec+dispo_sec) SECOND, 1, 16) as call_end_time_min, status, count(*) from vicidial_agent_log where event_time>='$query_date $query_time' and event_time<='$end_date $end_time' $campaign_id_SQL $user_SQL $user_group_SQL $status_SQL $exc_status_SQL group by call_end_time_min, status order by call_end_time_min, status"; # $rpt_string.="$stmt\n"; if ($DB) {$rpt_string.=$stmt."
\n";} $rslt=mysql_to_mysqli($stmt, $link); @@ -473,7 +500,7 @@ if (preg_match("/(did|ingroup)_performance/", $rpt_type)) { } } - $sale_stmt="SELECT distinct status from vicidial_statuses where sale='Y' $status_SQL UNION SELECT distinct status from vicidial_campaign_statuses where sale='Y' $campaign_id_SQL $status_SQL"; # Leave it for all campaigns, given the nature. + $sale_stmt="SELECT distinct status from vicidial_statuses where sale='Y' $status_SQL $exc_status_SQL UNION SELECT distinct status from vicidial_campaign_statuses where sale='Y' $campaign_id_SQL $status_SQL $exc_status_SQL"; # Leave it for all campaigns, given the nature. # $rpt_string.="$sale_stmt\n"; $sale_rslt=mysql_to_mysqli($sale_stmt, $link); $sale_dispos=array(); @@ -483,10 +510,10 @@ if (preg_match("/(did|ingroup)_performance/", $rpt_type)) { if (preg_match("/did_performance/", $rpt_type)) { # $stmt="SELECT user, status, sum(pause_sec+wait_sec+talk_sec+dispo_sec), count(*) from vicidial_agent_log where event_time>='$query_date $query_time' and event_time<='$end_date $end_time' $campaign_id_SQL $user_SQL $user_group_SQL group by user, status order by user, status"; - $stmt="SELECT vid.did_pattern, vcl.status, sum(vcl.length_in_sec-vcl.queue_seconds) as call_length, count(*) From vicidial_closer_log vcl, vicidial_did_log vdl, vicidial_inbound_dids vid where vcl.call_date>='$query_date $query_time' and vcl.call_date<='$end_date $end_time' and vcl.uniqueid=vdl.uniqueid and vdl.did_id=vid.did_id $did_SQL $status_SQL group by did_pattern, did_description, status order by did_pattern, status"; + $stmt="SELECT vid.did_pattern, vcl.status, sum(vcl.length_in_sec-vcl.queue_seconds) as call_length, count(*) From vicidial_closer_log vcl, vicidial_did_log vdl, vicidial_inbound_dids vid where vcl.call_date>='$query_date $query_time' and vcl.call_date<='$end_date $end_time' and vcl.uniqueid=vdl.uniqueid and vdl.did_id=vid.did_id $did_SQL $status_SQL $exc_status_SQL group by did_pattern, did_description, status order by did_pattern, status"; } else if (preg_match("/ingroup_performance/", $rpt_type)) { # $stmt="SELECT user_group, status, sum(pause_sec+wait_sec+talk_sec+dispo_sec), count(*) from vicidial_agent_log where event_time>='$query_date $query_time' and event_time<='$end_date $end_time' $campaign_id_SQL $user_SQL $user_group_SQL group by user_group, status order by user_group, status"; - $stmt="SELECT campaign_id, status, sum(length_in_sec-queue_seconds), count(*) from vicidial_closer_log where call_date>='$query_date $query_time' and call_date<='$end_date $end_time' $group_SQL $status_SQL group by campaign_id, status order by campaign_id, status"; + $stmt="SELECT campaign_id, status, sum(length_in_sec-queue_seconds), count(*) from vicidial_closer_log where call_date>='$query_date $query_time' and call_date<='$end_date $end_time' $group_SQL $status_SQL $exc_status_SQL group by campaign_id, status order by campaign_id, status"; } if ($DB) {$rpt_string.=$stmt."
\n";} @@ -561,7 +588,7 @@ if ($rpt_type=="floor_performance_hourly") { $status_SQL=" and status in ($status_str) "; } - $sale_stmt="SELECT distinct status from vicidial_statuses where sale='Y' $status_SQL UNION SELECT distinct status from vicidial_campaign_statuses where sale='Y' and campaign_id in ('".implode("','", $campaigns)."') $status_SQL"; + $sale_stmt="SELECT distinct status from vicidial_statuses where sale='Y' $status_SQL $exc_status_SQL UNION SELECT distinct status from vicidial_campaign_statuses where sale='Y' and campaign_id in ('".implode("','", $campaigns)."') $status_SQL $exc_status_SQL"; # $rpt_string.="$sale_stmt\n"; $sale_rslt=mysql_to_mysqli($sale_stmt, $link); $sale_dispos=array(); @@ -569,7 +596,7 @@ if ($rpt_type=="floor_performance_hourly") { array_push($sale_dispos, $sale_row[0]); } - $stmt="SELECT substr(event_time+INTERVAL (pause_sec+wait_sec+talk_sec+dispo_sec) SECOND, 1, 13) as call_end_time_hour, count(*) from vicidial_agent_log where event_time>='$query_date $query_time' and event_time<='$end_date $end_time' and status in ('".implode("','", $sale_dispos)."') $campaign_id_SQL $status_SQL group by call_end_time_hour order by call_end_time_hour"; + $stmt="SELECT substr(event_time+INTERVAL (pause_sec+wait_sec+talk_sec+dispo_sec) SECOND, 1, 13) as call_end_time_hour, count(*) from vicidial_agent_log where event_time>='$query_date $query_time' and event_time<='$end_date $end_time' and status in ('".implode("','", $sale_dispos)."') $campaign_id_SQL $status_SQL $exc_status_SQL group by call_end_time_hour order by call_end_time_hour"; $rpt_string.="$stmt\n"; if ($DB) {$rpt_string.=$stmt."
\n";} $rslt=mysql_to_mysqli($stmt, $link);
"+"
"+alert_text+"