c5a7b341 by Manish Mihsra

Working on Report

1 parent c47d5151
Showing 36 changed files with 9878 additions and 248 deletions
<?php
Route::get('/', array('uses'=> 'HomeController@index', 'as'=>'index.root'));
Route::get('index', array('uses'=> 'HomeController@index', 'as'=>'index.index'));
Route::get('test_table_8', 'Rom8Controller@testTable');
Route::get('eg', 'egController@eg');
Route::group(['middleware' => ['web']], function () {
Route::get('home', array('uses' => 'HomeController@home', 'as'=>'home.home'));
Route::get('login', array('uses'=> 'HomeController@login', 'as'=>'home.login'));
Route::post('login', array('uses'=> 'HomeController@do_login', 'as'=>'home.do_login'));
Route::get('logout', array('uses'=> 'HomeController@logout', 'as'=>'home.logout'));
Route::get('signup', array('uses'=> 'HomeController@signup', 'as'=>'home.signup'));
Route::post('signup', array('uses'=> 'HomeController@do_signup', 'as'=>'home.do_signup'));
Route::get('userfiles/{path}',array('uses'=>'HomeController@userfiles','as'=>'userfiles.get'))->where('path', '.*');
Route::get('unsubscribe', array('uses'=> 'HomeController@unsubscribe', 'as'=>'home.unsubscribe'));
Route::any('forgotpassword', array('uses'=> 'HomeController@forgotpassword', 'as'=>'signup.forgotpassword'));
Route::get('profile', array('before' => 'auth','uses' => 'HomeController@profile', 'as'=>'profile.index'));
Route::post('profile', array('before' => 'auth','uses' => 'HomeController@do_profile', 'as'=>'profile.update'));
Route::get('msie', array('uses'=> 'HomeController@msie', 'as'=>'login.msie'));
Route::any('ajaxerror', array('uses'=> 'HomeController@ajaxerror', 'as'=>'home.ajaxerror'));
Route::any('gettoken', array('uses'=> 'HomeController@gettoken', 'as'=>'home.gettoken'));
Route::any('idleapp', array('uses'=> 'HomeController@idleapp', 'as'=>'home.idleapp'));
Route::any('fileupload', array('uses'=> 'HomeController@fileupload', 'as'=>'upload.file'));
Route::get('cron', array('uses'=> 'HomeController@cron', 'as'=>'cron.cron'));
Route::get('style', array('uses'=> 'HomeController@style', 'as'=>'style.index'));
Route::get('jshead', array('uses'=> 'HomeController@jshead', 'as'=>'jshead.index'));
Route::get('jsbody', array('uses'=> 'HomeController@jsbody', 'as'=>'jsbody.index'));
Route::resource('dashboard','DashboardController');
Route::resource('notification','NotificationController');
Route::resource('message','MessageController');
Route::resource('task','TaskController');
Route::resource('user','UserController');
Route::resource('group','GroupController');
Route::resource('role','RoleController');
Route::resource('dispositionPlan','DispositionPlanController');
Route::resource('master','MasterController');
Route::resource('admin','AdminController');
Route::resource('record','RecordController');
Route::resource('campaign','CampaignController');
Route::resource('dialer','DialerController');
Route::resource('hr','HRController');
Route::resource('social','SocialController');
Route::resource('web','WebController');
Route::get('notes', array('uses' => 'NotesController@loadQuestions', 'as'=>'questionare.load_questions'));
Route::post('notes',array('uses' => 'NotesController@store', 'as'=>'notes.store'));
Route::get('questionare/{qid?}/{optid?}/{level?}', array('uses' => 'QuestionareController@loadQuestions', 'as'=>'questionare.load_questions'));
Route::post('questionare', array('uses' => 'QuestionareController@saveQuestionAire', 'as'=>'questionare.save'));
//Route::get('notes', array('uses' => 'NotesController@index', 'as'=>'notes.index'));
//Route::resource('notesupdate','NotesController');
Route::get('exceldownload', function()
{
return view("layout.module.userupload.exceldata");
});
Route::post('useruploaddata', array('uses' => 'UserController@userUpload', 'as'=>'useruploaddata'));
//Supervisor Call Mangement - By Manish on 16-02-17
Route::get('SupervisorModule', array('uses'=> 'RecordController@supervisorUpload', 'as'=>'upload.comments'));
//Supervisor Call Mangement - By Manish on 22-03-17
Route::post('complaint', array('uses'=> 'ComplaintController@saveComplaint', 'as'=>'upload.complaint'));
Route::post('resclassUnit', array('uses'=> 'ComplaintController@getBranchName', 'as'=>'get.branchname'));
Route::post('childcase', array('uses'=> 'ComplaintController@saveChildCase', 'as'=>'upload.case'));
//Supervisor Message Announcement - By Manish on 12-04-17
Route::get('category/{resClassUnit}', array('uses'=> 'ComplaintController@getCat', 'as'=>'get.cat'));
Route::get('subcategory/{catId}/{resClassUnit}', array('uses'=> 'ComplaintController@getSubCat', 'as'=>'get.subcat'));
Route::post('SupervisorMessage', array('uses'=> 'MessageController@sendSupVisorMessage', 'as'=>'send.message'));
Route::get('supmessage/{msg_id?}/{username?}', array('uses'=> 'MessageController@viewSupVisorMessage', 'as'=>'view.allmessage'));
Route::get('viewmessage/{msg_id?}/{username?}', array('uses'=> 'MessageController@viewMessage', 'as'=>'view.message'));
//Addition of Customer Racing
Route::post('custrace', array('uses'=> 'RacingCustomerController@saveRacingCustomer', 'as'=>'upload.raccust'));
//Addition of Lead Entry Form
Route::post('leadentryform', array('uses'=> 'LeadEntryFormController@saveLeadEntryFormDetails', 'as'=>'upload.rleadform'));
Route::post('oaentryform', array('uses'=> 'OneAssistController@saveOneAssistFormDetails', 'as'=>'upload.oaleadform'));
Route::post('racingcustupdate',array('uses'=> 'RacingCustomerController@updateracingcust', 'as'=>'upload.updateraccust'));
Route::get('dialmode', array('uses'=> 'DialModeController@dialmodeview', 'as'=>'view.module'));
Route::post('dialmodeassign', array('uses'=> 'DialModeController@dialmodeassign', 'as'=>'assign.dialmodes'));
///for the rlp pbwise
Route::get('rlp', array('uses'=> 'RecordController@rlpPbwise', 'as'=>'rlppb.comments'));
});
......@@ -1547,42 +1547,7 @@ print_r($supervisorUsers);
$data['count'] = $count;
return view("layout.module.dialer.appointment",$data);
}
if($id=="reports")
{
return view("layout.module.dialer.reports",array());
}
if($id=="campaigns")
{
return view("layout.module.dialer.campaigns",array());
}
if($id=="calllog")
{
return view("layout.module.dialer.calllog",array());
}
if($id=="agentreport")
{
return view("layout.module.dialer.agentreport",array());
}
if($id=="campreport")
{
return view("layout.module.dialer.campreport",array());
}
if($id=="statusreport")
{
return view("layout.module.dialer.statusreport",array());
}
if($id=="questionnaire")
{
return view("layout.module.dialer.questairereport",array());
}
if($id=="callmanagement")
{
return view("layout.module.dialer.callmanagementreport",array());
}
if($id=="supmessages")
{
return view("layout.module.dialer.supmessagesreport",array());
}
if($id=='playrecfile')
{
......@@ -1613,18 +1578,6 @@ print_r($supervisorUsers);
}
return;
}
if($id=="liveusers")
{
return view("layout.module.dialer.liveusers",array());
}
if($id=="recarchive")
{
return view("layout.module.dialer.recarchive",array());
}
if($id=="recqc")
{
return view("layout.module.dialer.recqc",array());
}
//relationship area dropdown option fetched code. code by Yashwant Sir
if($id=="relationship")
{
......
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Auth;
use Input;
use Response;
use Config;
use App\Http\Requests;
use App\Models\Group;
use App\Models\Master;
use App\Models\Record;
use App\Models\CRMCall;
use App\Models\CRMCallArchive;
use App\Models\CRM;
use App\Models\CRMCampaign;
use App\Models\CRMList;
use App\Models\Cutoff;
use App\Jobs\KHRMSLib;
use App\Models\Sipid;
use App\Models\Dialline;
use App\Models\UserLog;
use App\Models\Kqueue;
use DB;
use Log;
use Session;
class ReportController extends Controller
{
public function __construct()
{
$this->middleware('auth');
$this->middleware('module_access');
}
public function show($id)
{
if($id=="reports")
{
return view("layout.module.reports.reports",array());
}
if($id=="campaigns")
{
return view("layout.module.reports.campaigns",array());
}
if($id=="calllog")
{
return view("layout.module.reports.calllog",array());
}
if($id=="agentreport")
{
return view("layout.module.reports.agentreport",array());
}
if($id=="campreport")
{
return view("layout.module.reports.campreport",array());
}
if($id=="statusreport")
{
return view("layout.module.reports.statusreport",array());
}
if($id=="questionnaire")
{
return view("layout.module.reports.questairereport",array());
}
if($id=="callmanagement")
{
return view("layout.module.reports.callmanagementreport",array());
}
if($id=="supmessages")
{
return view("layout.module.reports.supmessagesreport",array());
}
if($id=="liveusers")
{
return view("layout.module.reports.liveusers",array());
}
if($id=="recarchive")
{
return view("layout.module.reports.recarchive",array());
}
if($id=="recqc")
{
return view("layout.module.reports.recqc",array());
}
}
}
<?php
Route::get('/', array('uses'=> 'HomeController@index', 'as'=>'index.root'));
Route::get('index', array('uses'=> 'HomeController@index', 'as'=>'index.index'));
Route::get('test_table_8', 'Rom8Controller@testTable');
Route::get('eg', 'egController@eg');
Route::group(['middleware' => ['web']], function () {
Route::get('home', array('uses' => 'HomeController@home', 'as'=>'home.home'));
Route::get('login', array('uses'=> 'HomeController@login', 'as'=>'home.login'));
Route::post('login', array('uses'=> 'HomeController@do_login', 'as'=>'home.do_login'));
Route::get('logout', array('uses'=> 'HomeController@logout', 'as'=>'home.logout'));
Route::get('signup', array('uses'=> 'HomeController@signup', 'as'=>'home.signup'));
Route::post('signup', array('uses'=> 'HomeController@do_signup', 'as'=>'home.do_signup'));
Route::get('userfiles/{path}',array('uses'=>'HomeController@userfiles','as'=>'userfiles.get'))->where('path', '.*');
Route::get('unsubscribe', array('uses'=> 'HomeController@unsubscribe', 'as'=>'home.unsubscribe'));
Route::any('forgotpassword', array('uses'=> 'HomeController@forgotpassword', 'as'=>'signup.forgotpassword'));
Route::get('profile', array('before' => 'auth','uses' => 'HomeController@profile', 'as'=>'profile.index'));
Route::post('profile', array('before' => 'auth','uses' => 'HomeController@do_profile', 'as'=>'profile.update'));
Route::get('msie', array('uses'=> 'HomeController@msie', 'as'=>'login.msie'));
Route::any('ajaxerror', array('uses'=> 'HomeController@ajaxerror', 'as'=>'home.ajaxerror'));
Route::any('gettoken', array('uses'=> 'HomeController@gettoken', 'as'=>'home.gettoken'));
Route::any('idleapp', array('uses'=> 'HomeController@idleapp', 'as'=>'home.idleapp'));
Route::any('fileupload', array('uses'=> 'HomeController@fileupload', 'as'=>'upload.file'));
Route::get('cron', array('uses'=> 'HomeController@cron', 'as'=>'cron.cron'));
Route::get('style', array('uses'=> 'HomeController@style', 'as'=>'style.index'));
Route::get('jshead', array('uses'=> 'HomeController@jshead', 'as'=>'jshead.index'));
Route::get('jsbody', array('uses'=> 'HomeController@jsbody', 'as'=>'jsbody.index'));
Route::resource('dashboard','DashboardController');
Route::resource('notification','NotificationController');
Route::resource('message','MessageController');
Route::resource('task','TaskController');
Route::resource('user','UserController');
Route::resource('group','GroupController');
Route::resource('role','RoleController');
Route::resource('master','MasterController');
Route::resource('admin','AdminController');
Route::resource('record','RecordController');
Route::resource('campaign','CampaignController');
Route::resource('dialer','DialerController');
Route::resource('hr','HRController');
Route::resource('social','SocialController');
Route::resource('web','WebController');
Route::get('notes', array('uses' => 'NotesController@loadQuestions', 'as'=>'questionare.load_questions'));
Route::post('notes',array('uses' => 'NotesController@store', 'as'=>'notes.store'));
Route::get('questionare/{qid?}/{optid?}/{level?}', array('uses' => 'QuestionareController@loadQuestions', 'as'=>'questionare.load_questions'));
Route::post('questionare', array('uses' => 'QuestionareController@saveQuestionAire', 'as'=>'questionare.save'));
//Route::get('notes', array('uses' => 'NotesController@index', 'as'=>'notes.index'));
//Route::resource('notesupdate','NotesController');
Route::get('exceldownload', function()
{
return view("layout.module.userupload.exceldata");
});
Route::post('useruploaddata', array('uses' => 'UserController@userUpload', 'as'=>'useruploaddata'));
//Supervisor Call Mangement - By Manish on 16-02-17
Route::get('SupervisorModule', array('uses'=> 'RecordController@supervisorUpload', 'as'=>'upload.comments'));
//Supervisor Call Mangement - By Manish on 22-03-17
Route::post('complaint', array('uses'=> 'ComplaintController@saveComplaint', 'as'=>'upload.complaint'));
Route::post('resclassUnit', array('uses'=> 'ComplaintController@getBranchName', 'as'=>'get.branchname'));
Route::post('childcase', array('uses'=> 'ComplaintController@saveChildCase', 'as'=>'upload.case'));
//Supervisor Message Announcement - By Manish on 12-04-17
Route::get('category/{resClassUnit}', array('uses'=> 'ComplaintController@getCat', 'as'=>'get.cat'));
Route::get('subcategory/{catId}/{resClassUnit}', array('uses'=> 'ComplaintController@getSubCat', 'as'=>'get.subcat'));
Route::post('SupervisorMessage', array('uses'=> 'MessageController@sendSupVisorMessage', 'as'=>'send.message'));
Route::get('supmessage/{msg_id?}/{username?}', array('uses'=> 'MessageController@viewSupVisorMessage', 'as'=>'view.allmessage'));
Route::get('viewmessage/{msg_id?}/{username?}', array('uses'=> 'MessageController@viewMessage', 'as'=>'view.message'));
//Addition of Customer Racing
Route::post('custrace', array('uses'=> 'RacingCustomerController@saveRacingCustomer', 'as'=>'upload.raccust'));
//Addition of Lead Entry Form
Route::post('leadentryform', array('uses'=> 'LeadEntryFormController@saveLeadEntryFormDetails', 'as'=>'upload.rleadform'));
Route::post('oaentryform', array('uses'=> 'OneAssistController@saveOneAssistFormDetails', 'as'=>'upload.oaleadform'));
Route::post('racingcustupdate',array('uses'=> 'RacingCustomerController@updateracingcust', 'as'=>'upload.updateraccust'));
Route::get('dialmode', array('uses'=> 'DialModeController@dialmodeview', 'as'=>'view.module'));
Route::post('dialmodeassign', array('uses'=> 'DialModeController@dialmodeassign', 'as'=>'assign.dialmodes'));
///for the rlp pbwise
Route::get('rlp', array('uses'=> 'RecordController@rlpPbwise', 'as'=>'rlppb.comments'));
});
......@@ -53,6 +53,7 @@ Route::group(['middleware' => ['web']], function () {
Route::resource('hr','HRController');
Route::resource('social','SocialController');
Route::resource('web','WebController');
Route::resource('report','ReportController');
Route::get('notes', array('uses' => 'NotesController@loadQuestions', 'as'=>'questionare.load_questions'));
Route::post('notes',array('uses' => 'NotesController@store', 'as'=>'notes.store'));
......
......@@ -98,7 +98,7 @@ return [
"Task" => ["disp"=>"Tasks","icon"=>"edit","dash"=>"","onclick"=>"showBlock('Workflow');"],
"Dialer" => ["disp"=>"Dialer","icon"=>"phone","dash"=>"Dialer",
"submenu"=>["Dialer"=>["kDialerModel();"],
"Reports"=>["menuAction('dialer/reports');"],
"Reports"=>["menuAction('report/reports');"],
]],
"DialerCampaign" => ["disp"=>"Dialer","icon"=>"phone","dash"=>"",
"submenu"=>[
......@@ -129,6 +129,7 @@ return [
"Record" => ["disp"=>"Record","icon"=>"file","dash"=>"","onclick"=>""],
"User" => ["disp"=>"User","icon"=>"home","dash"=>"","onclick"=>""],
"Role" => ["disp"=>"Role","icon"=>"home","dash"=>"","onclick"=>""],
"Report" => ["disp"=>"Report","icon"=>"home","dash"=>"","onclick"=>""],
"DialMode" => ["disp"=>"DialMode","icon"=>"home","dash"=>"","onclick"=>""],
"SupervisorModule" => ["disp"=>"SupervisorModule","icon"=>"globe","dash"=>"","onclick"=>"menuAction('SupervisorModule');"],
"Notes" => ["disp"=>"Notes","icon"=>"globe","dash"=>"","onclick"=>"menuAction('notes');"],
......
<?php
use App\Models\Sipid;
use App\Models\UserLog;
use App\Models\CRMCall;
use App\Models\User;
use App\Jobs\KHRMSLib;
$selectedvals=explode(":",Input::get("selectedvals",":::::"));
$hdfcnodes=array();
$offline=array();
$arr=Config::get("app.hdfcnodes");
foreach($arr as $server=>$arrline)
{
$tvals=explode(":",$arrline);
if($selectedvals[0]=="")$hdfcnodes[]=$server;
else if($selectedvals[0]==$tvals[0])
{
if($selectedvals[1]=="")$hdfcnodes[]=$server;
else if($selectedvals[1]==$tvals[1])
{
if($selectedvals[2]=="")$hdfcnodes[]=$server;
else if($selectedvals[2]==$tvals[2])
{
if($selectedvals[3]=="")$hdfcnodes[]=$server;
else if($selectedvals[3]==$tvals[3])
{
if($selectedvals[4]=="")$hdfcnodes[]=$server;
else if($selectedvals[4]==$tvals[4])
{
$hdfcnodes[]=$server;
}
}
}
}
}
}
$wakka = new KHRMSLib();
$dashboarduser=Auth::user();
$uidlist=array();$onlineusers=array();
if(isset($_GET['logdate']))$logdate=strtotime($_GET['logdate']." 00:00:00");
else $logdate=strtotime(date('Y-m-d')." 00:00:00");
$i=1;
$reporthead=array("#","UserId","UserName","In","Out","InOut","Sessions","Duration");
$reportarray=array();
foreach($hdfcnodes as $ci=>$server)
{
$conn = array(
'driver' => 'mysql',
'host' => $server,
'database' => env('DB_DATABASE', 'kstych_flexydial'),
'username' => env('DB_USERNAME', 'root'),
'password' => env('DB_PASSWORD', ''),
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
'options' => array(
PDO::ATTR_TIMEOUT => 5,
),
);
Config::set("database.connections.conn$ci", $conn);
try
{
DB::connection("conn$ci")->getDatabaseName();
$alist=UserLog::on("conn$ci")->where('created_at','>=',date("Y-m-d H:i:s",$logdate))->where('created_at','<=',date("Y-m-d H:i:s",$logdate+24*60*60))->where('durationsec','>',0);
$alist=$alist->get();
$userarr=array();
foreach($alist as $aline)
{
if(!isset($userarr[$aline->user_id."conn$ci"]))$userarr[$aline->user_id."conn$ci"]=User::on("conn$ci")->find($aline->user_id."conn$ci");
$tuser=$userarr[$aline->user_id."conn$ci"];
if(!isset($reportarray[$aline->user_id."conn$ci"]))$reportarray[$aline->user_id."conn$ci"]=array("#"=>$i++,"UserId"=>$aline->user_id."conn$ci","UserName"=>$tuser->username,"In"=>"","Out"=>"","InOut"=>0,"Sessions"=>0,"Duration"=>0);
if($reportarray[$aline->user_id."conn$ci"]["In"]=="")$reportarray[$aline->user_id."conn$ci"]["In"]=date("Y-m-d H:i:s",strtotime($aline->created_at)-($dashboarduser->timezone*60));
$reportarray[$aline->user_id."conn$ci"]["Out"]=date("Y-m-d H:i:s",strtotime($aline->updated_at)-($dashboarduser->timezone*60));
$reportarray[$aline->user_id."conn$ci"]["InOut"]=strtotime($reportarray[$aline->user_id."conn$ci"]["Out"])-strtotime($reportarray[$aline->user_id."conn$ci"]["In"]);
$data=json_decode($aline->data,true);
foreach($data as $sipid=>$sdata)
{
$reportarray[$aline->user_id."conn$ci"]["Sessions"]++;
$reportarray[$aline->user_id."conn$ci"]["Duration"]+=$aline->durationsec;
if(isset($sdata['states']))
{
$previous="Login";
$prets=strtotime($aline->startdate." ".$aline->starttime);
foreach($sdata['states'] as $ts=>$states)
{
$fts=$ts/1000;
if(!in_array($previous,$reporthead))$reporthead[]=$previous;
$reportarray[$aline->user_id."conn$ci"][$previous]+=round($fts-$prets,2);
$previous=$states[0]."-".$states[1];$prets=$fts;
}
if(!in_array($previous,$reporthead))$reporthead[]=$previous;
$reportarray[$aline->user_id."conn$ci"][$previous]+=round((strtotime($aline->enddate." ".$aline->endtime))-$prets,2);
}
else
{
$reportarray[$aline->user_id."conn$ci"]["Login"]+=$aline->durationsec;
}
}
}
}catch(Exception $e)
{
$offline[]=$server;
}
}
if(Input::has("dllogxls"))
{
include_once(app_path().'/lib/phpexcel/PHPExcel.php');
$inputFileType = "Excel5";
$objReader = PHPExcel_IOFactory::createReader($inputFileType);
$objPHPExcel = $objReader->load("assets/extras/blank.xls");
$baseRow = 3;
$highestColumn = sizeof($reporthead);
for ($head = 0; $head < $highestColumn; $head++){
$colstr=PHPExcel_Cell::stringFromColumnIndex($head);
$objPHPExcel->getActiveSheet()->setCellValue($colstr."1", $reporthead[$head]);
}
foreach($reportarray as $uid=>$uarr)
{
$row = $baseRow++;
$col = 0;
for ($head = 0; $head < $highestColumn; $head++){
$colstr=PHPExcel_Cell::stringFromColumnIndex($head);
$objPHPExcel->getActiveSheet()->setCellValue($colstr.$row, $uarr[$reporthead[$head]]);
}
}
header('Content-Type: application/vnd.ms-excel');
header('Content-Disposition: attachment;filename="AgentLog.xls"');
header('Cache-Control: max-age=0');
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, $inputFileType);
$objWriter->save('php://output');
return ;
}
$highestColumn = sizeof($reporthead);
$outhead="<tr>";$outstr="";
for ($head = 0; $head < $highestColumn; $head++){
$outhead.="<td>".$reporthead[$head]."</td>";
}
$outhead.="</tr>";
foreach($reportarray as $uid=>$uarr)
{
$outstr.="<tr>";
for ($head = 0; $head < $highestColumn; $head++){
$outstr.="<td>".$uarr[$reporthead[$head]]."</td>";
}
$outstr.="</tr>";
}
//charts
$cat1=array();
$cat1arr=array();
foreach($reportarray as $uid=>$uarr)
{
$cat1[]="'$uarr[UserName]'";
for ($head = 8; $head < $highestColumn; $head++){
if(!isset($cat1arr[$reporthead[$head]]))$cat1arr[$reporthead[$head]]=array();
$cat1arr[$reporthead[$head]][$uarr["#"]]=round($uarr[$reporthead[$head]]/60,1);
if(empty($cat1arr[$reporthead[$head]][$uarr["#"]]))$cat1arr[$reporthead[$head]][$uarr["#"]]=0;
}
}
$cat1arrstr="";
foreach($cat1arr as $name=>$data)
{
$cat1arrstr.="{ name: '$name',\ndata : [";
$cat1arrstr.=implode(",",$data);
$cat1arrstr.="] },\n";
}
$cat2=array();
foreach($reportarray as $uid=>$uarr)
{
for ($head = 8; $head < $highestColumn; $head++){
$cat2["'".$reporthead[$head]."'"]+=round($uarr[$reporthead[$head]]/60,1);
}
}
?>
<div class=innerAll>
<style>#logtable.td{vertical-align:top;}#logtable.tr{height:28px;overflow-y:hidden;}</style>
<script>
$(document).ready(function()
{
if(!$('#dialoglog').hasClass('ui-dialog-content'))
{
$('#dialoglog').dialog({
autoOpen: false,
width: '70%',
buttons: {
"Ok": function() {
$(this).dialog("close");
},
"Cancel": function() {
$(this).dialog("close");
}
}
});
}
waitKeyUpRun("filter",function() { filter2(document.getElementById('filter'), 'logtable') },"2000");
$('#modfrom').datepicker({dateFormat: 'yy-mm-dd',inline: true,changeYear: true,selectOtherMonths: true,yearRange: '<?php echo (date('Y')-70).":".(date('Y')+5); ?>'});
});
</script>
<div style="float:left;width:50%">
Search <input id=filter name="filter" type="text">
Date : <input size=10 id='modfrom' name='modfrom' type='text' value='<?php echo date("Y-m-d",$logdate); ?>' onchange='agentLogReloadFun("");' />
</div>
<div style="float:left;width:50%">
<button class="pull-right btn btn-sm btn-default" onclick='dlAgentlogXls();return false;' title='Download' style='margin-top:-8px'><i class='fa fa-download'></i> Download</button>
</div>
<div style="clear:both"></div>
<hr>
<div class=col-md-12>
<div id=userlogschart1 style='min-height:300px;width:100%'></div>
<script>
$(function () {
$('#userlogschart1').highcharts({
chart: {
type: 'column'
},
title: {
text: ''
},
xAxis: {
labels:{
enabled:false//default is true
},
categories: [<?php echo implode(",",$cat1); ?>]
},
yAxis: {
min: 0,
title: {
text: ''
},
stackLabels: {
enabled: false,
// style: {
// fontWeight: '',
// color: (Highcharts.theme && Highcharts.theme.textColor) || 'gray'
// }
}
},
// legend: {
// align: 'right',
// x: -30,
// verticalAlign: 'top',
// y: 25,
// floating: true,
// backgroundColor: (Highcharts.theme && Highcharts.theme.background2) || 'white',
// borderColor: '#CCC',
// borderWidth: 1,
// shadow: false
// },
tooltip: {
headerFormat: '<b>{point.x}</b><br/>',
pointFormat: '{series.name}: {point.y}<br/>Total: {point.stackTotal}'
},
plotOptions: {
column: {
stacking: 'normal',
dataLabels: {
enabled: false,
// color: (Highcharts.theme && Highcharts.theme.dataLabelsColor) || 'white',
// style: {
// textShadow: '0 0 3px black'
// }
}
}
},
series: [<?php echo $cat1arrstr; ?>]
});
});
function agentLogReloadFun(sortby)
{
var sortstr='';if(sortby!="")sortstr="&sort="+sortby
doAjax('dialer/aagentreport?logdate='+$("#modfrom").val()+sortstr+'&selectedvals='+getarvalval(),'','rightmainreportdiv','ajax_dialer_reports','singlethis','GET');
}
function dlAgentlogXls()
{
window.open('dialer/aagentreport?dllogxls=1&logdate='+$("#modfrom").val()+'&selectedvals='+getarvalval());return false;
}
</script>
</div>
<div style='clear:both'></div>
<div class=col-md-12>
<div id=userlogschart2 style='min-height:300px;width:100%'></div>
<script>
$(function () {
$('#userlogschart2').highcharts({
chart: {
type: 'column'
},
title: {
text: ''
},
subtitle: {
text: ''
},
xAxis: {
categories: [<?php echo implode(",",array_keys($cat2)); ?>],
crosshair: true
},
yAxis: {
min: 0,
title: {
text: ''
}
},
tooltip: {
headerFormat: '<span style="font-size:10px">{point.key}</span><table>',
pointFormat: '<tr><td style="color:{series.color};padding:0">{series.name}: </td>' +
'<td style="padding:0"><b>{point.y:.1f}</b></td></tr>',
footerFormat: '</table>',
shared: true,
useHTML: true
},
plotOptions: {
column: {
pointPadding: 0.2,
borderWidth: 0
}
},
legend : {
floating: true,
align: 'right',
x: -30,
verticalAlign: 'top',
},
series: [{
name: 'Mins',
data: [<?php echo implode(",",array_values($cat2)); ?>]
},]
});
});
</script>
</div>
<div style='clear:both'></div>
<div style='overflow:auto'>
<table id=logtable class='footable table table-striped table-bordered table-white table-primary footable-loaded' style='font-size:12px'>
<thead>
<?php echo $outhead; ?>
</thead>
<?php echo $outstr; ?>
</table>
</div>
<div id=dialoglog></div>
</div>
<?php
use App\Models\CRMCall;
use App\Models\User;
use App\Jobs\KHRMSLib;
$selectedvals=explode(":",Input::get("selectedvals",":::::"));
$hdfcnodes=array();
$offline=array();
$arr=Config::get("app.hdfcnodes");
foreach($arr as $server=>$arrline)
{
$tvals=explode(":",$arrline);
if($selectedvals[0]=="")$hdfcnodes[]=$server;
else if($selectedvals[0]==$tvals[0])
{
if($selectedvals[1]=="")$hdfcnodes[]=$server;
else if($selectedvals[1]==$tvals[1])
{
if($selectedvals[2]=="")$hdfcnodes[]=$server;
else if($selectedvals[2]==$tvals[2])
{
if($selectedvals[3]=="")$hdfcnodes[]=$server;
else if($selectedvals[3]==$tvals[3])
{
if($selectedvals[4]=="")$hdfcnodes[]=$server;
else if($selectedvals[4]==$tvals[4])
{
$hdfcnodes[]=$server;
}
}
}
}
}
}
$wakka = new KHRMSLib();
$dashboarduser=Auth::user();
$i=1;
$totaltime=0;$ttlovr10=0;$ttlovr5=0;$ttlovr1=0;$ttlovr0=0;$outstr="";$usrcnt=0;
$totaltimeIn=0;$ttlovr10In=0;$ttlovr5In=0;$ttlovr1In=0;$ttlovr0In=0;$usrcntIn=0;
$actionarr=array();$actionarrIn=array();
if(isset($_GET['logdate']))$logdate=strtotime($_GET['logdate']." 00:00:00");else $logdate=strtotime(date('Y-m-d')." 00:00:00");
if(Input::has("dllogxls"))
{
include_once(app_path().'/lib/phpexcel/PHPExcel.php');
$inputFileType = "Excel5";
$objReader = PHPExcel_IOFactory::createReader($inputFileType);
$objPHPExcel = $objReader->load("assets/extras/blank.xls");
$baseRow = 3;
$tcol=0;$fieldsarr=array();$extrahdrarr=array();
$fieldsarr[$tcol++]='#';
$fieldsarr[$tcol++]='Start';
$fieldsarr[$tcol++]='Length';
$fieldsarr[$tcol++]='User';
$fieldsarr[$tcol++]='Name';
$fieldsarr[$tcol++]='Dispo';
$fieldsarr[$tcol++]='SubDispo';
$fieldsarr[$tcol++]='CB';
$fieldsarr[$tcol++]='Number';
$fieldsarr[$tcol++]='ClientCode';
$fieldsarr[$tcol++]='CurrentStatus';
$fieldsarr[$tcol++]='LegalStatus';
$fieldsarr[$tcol++]='Data';
$fieldsarr[$tcol++]='SubData';
$fieldsarr[$tcol++]='State';
$fieldsarr[$tcol++]='HSource';
$fieldsarr[$tcol++]='Type';
$fieldsarr[$tcol++]='Status';
$fieldsarr[$tcol++]='StatusCode';
$fieldsarr[$tcol++]='StatusStr';
$fieldsarr[$tcol++]='DialLine';
$fieldsarr[$tcol++]='DID';
$fieldsarr[$tcol++]='WaitSec';
$fieldsarr[$tcol++]='CallSec';
$fieldsarr[$tcol++]='TalkSec';
$fieldsarr[$tcol++]='DispoSec';
$fieldsarr[$tcol++]='Remarks';
$highestColumn = sizeof($fieldsarr);
for ($head = 0; $head < $highestColumn; $head++){
$colstr=PHPExcel_Cell::stringFromColumnIndex($head);
$objPHPExcel->getActiveSheet()->setCellValue($colstr."1", $fieldsarr[$head]);
}
$ii=1;
foreach($hdfcnodes as $ci=>$server)
{
$conn = array(
'driver' => 'mysql',
'host' => $server,
'database' => env('DB_DATABASE', 'kstych_flexydial'),
'username' => env('DB_USERNAME', 'root'),
'password' => env('DB_PASSWORD', ''),
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
'options' => array(
PDO::ATTR_TIMEOUT => 5,
),
);
Config::set("database.connections.conn$ci", $conn);
try
{
DB::connection("conn$ci")->getDatabaseName();
$alist=CRMCall::on("conn$ci")->where('created_at','>=',date("Y-m-d H:i:s",$logdate))->where('created_at','<=',date("Y-m-d H:i:s",$logdate+24*60*60));
if(Input::get('sort')=='cpu')$alist=$alist->orderBy("callSec","DESC");else $alist=$alist->orderBy("id","DESC");$alist=$alist->get();
$userarr=array();
foreach($alist as $aline)
{
$row = $baseRow++;
$col = 0;
$clientcode="";$currentstatus="";$legalstatus="";
if($aline->crm_id>0)
{
$user=$wakka->getPerson($aline->crm_id);
$clientcode=$user["peopledata"]["clientcode"];
$currentstatus=$user["peopledata"]["currentstatus"];
$legalstatus=$user["peopledata"]["legalstatus"];
}
$tpostdata=json_decode($aline->data,true);
$fulldate=date("Y-m-d H:i:s",strtotime($aline->created_at)-($dashboarduser->timezone*60));
$talktime=$aline->talkSec+$aline->recstartSec+$aline->recendSec;
$length=round(($aline->waitSec+$aline->callSec+$talktime+$aline->dispoSec)/1000,2);
if(!isset($userarr[$aline->user_id])&&$aline->user_id>0)$userarr[$aline->user_id]=User::on("conn$ci")->find($aline->user_id);
$dispname="";if(isset($userarr[$aline->user_id]))$dispname=$userarr[$aline->user_id]->dispname();
$username="";if(isset($userarr[$aline->user_id]))$username=$userarr[$aline->user_id]->username;
$objPHPExcel->getActiveSheet()->getCellByColumnAndRow($col++,$row)->setValueExplicit($ii++);
$objPHPExcel->getActiveSheet()->getCellByColumnAndRow($col++,$row)->setValueExplicit($fulldate);
$objPHPExcel->getActiveSheet()->getCellByColumnAndRow($col++,$row)->setValueExplicit($length);
$objPHPExcel->getActiveSheet()->getCellByColumnAndRow($col++,$row)->setValueExplicit($username);
$objPHPExcel->getActiveSheet()->getCellByColumnAndRow($col++,$row)->setValueExplicit($dispname);
$objPHPExcel->getActiveSheet()->getCellByColumnAndRow($col++,$row)->setValueExplicit($aline->userstatus);
$objPHPExcel->getActiveSheet()->getCellByColumnAndRow($col++,$row)->setValueExplicit($aline->usersubstatus);
$objPHPExcel->getActiveSheet()->getCellByColumnAndRow($col++,$row)->setValueExplicit(($aline->usercallback!="0000-00-00 00:00:00"?date("Y-m-d H:i:s",strtotime($aline->usercallback)-($dashboarduser->timezone*60)):""));
$objPHPExcel->getActiveSheet()->getCellByColumnAndRow($col++,$row)->setValueExplicit($aline->number);
$objPHPExcel->getActiveSheet()->getCellByColumnAndRow($col++,$row)->setValueExplicit($clientcode);
$objPHPExcel->getActiveSheet()->getCellByColumnAndRow($col++,$row)->setValueExplicit($currentstatus);
$objPHPExcel->getActiveSheet()->getCellByColumnAndRow($col++,$row)->setValueExplicit($legalstatus);
$objPHPExcel->getActiveSheet()->getCellByColumnAndRow($col++,$row)->setValueExplicit($aline->client);
$objPHPExcel->getActiveSheet()->getCellByColumnAndRow($col++,$row)->setValueExplicit($aline->department);
$objPHPExcel->getActiveSheet()->getCellByColumnAndRow($col++,$row)->setValueExplicit($aline->state);
$objPHPExcel->getActiveSheet()->getCellByColumnAndRow($col++,$row)->setValueExplicit($aline->hsource);
$objPHPExcel->getActiveSheet()->getCellByColumnAndRow($col++,$row)->setValueExplicit($aline->type);
$objPHPExcel->getActiveSheet()->getCellByColumnAndRow($col++,$row)->setValueExplicit($aline->status);
$objPHPExcel->getActiveSheet()->getCellByColumnAndRow($col++,$row)->setValueExplicit($aline->statuscode);
$objPHPExcel->getActiveSheet()->getCellByColumnAndRow($col++,$row)->setValueExplicit($aline->substatus);
$objPHPExcel->getActiveSheet()->getCellByColumnAndRow($col++,$row)->setValueExplicit($aline->dialline_id);
$objPHPExcel->getActiveSheet()->getCellByColumnAndRow($col++,$row)->setValueExplicit($aline->did);
$objPHPExcel->getActiveSheet()->getCellByColumnAndRow($col++,$row)->setValueExplicit(round($aline->waitSec/1000,2));
$objPHPExcel->getActiveSheet()->getCellByColumnAndRow($col++,$row)->setValueExplicit(round($aline->callSec/1000,2));
$objPHPExcel->getActiveSheet()->getCellByColumnAndRow($col++,$row)->setValueExplicit(round($talktime/1000,2));
$objPHPExcel->getActiveSheet()->getCellByColumnAndRow($col++,$row)->setValueExplicit(round($aline->dispoSec/1000,2));
$objPHPExcel->getActiveSheet()->getCellByColumnAndRow($col++,$row)->setValueExplicit($aline->userremarks);
$userdata=json_decode($aline->userdata,true);
$extravals=$extrahdrarr;
if(!empty($userdata))
{
foreach($userdata as $key=>$val)
{
if(!isset($extrahdrarr[$key]))
{
$extrahdrarr[$key]="";
$extravals[$key]="";
$colstr=PHPExcel_Cell::stringFromColumnIndex(sizeof($fieldsarr)+sizeof($extrahdrarr));
$objPHPExcel->getActiveSheet()->setCellValue($colstr."1", $key);
}
$extravals[$key]=$val;
}
foreach($extravals as $key=>$val)
{
$objPHPExcel->getActiveSheet()->getCellByColumnAndRow($col++,$row)->setValueExplicit($val);
}
}
}
}catch(Exception $e)
{
$offline[]=$server;
}
}
header('Content-Type: application/vnd.ms-excel');
header('Content-Disposition: attachment;filename="CallLog.xls"');
header('Cache-Control: max-age=0');
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, $inputFileType);
$objWriter->save('php://output');
return ;
}
foreach($hdfcnodes as $ci=>$server)
{
$conn = array(
'driver' => 'mysql',
'host' => $server,
'database' => env('DB_DATABASE', 'kstych_flexydial'),
'username' => env('DB_USERNAME', 'root'),
'password' => env('DB_PASSWORD', ''),
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
'options' => array(
PDO::ATTR_TIMEOUT => 5,
),
);
Config::set("database.connections.conn$ci", $conn);
try
{
DB::connection("conn$ci")->getDatabaseName();
$alist=CRMCall::on("conn$ci")->where('created_at','>=',date("Y-m-d H:i:s",$logdate))->where('created_at','<=',date("Y-m-d H:i:s",$logdate+24*60*60));
if(Input::get('sort')=='cpu')$alist=$alist->orderBy("callSec","DESC");else $alist=$alist->orderBy("id","DESC");$alist=$alist->get();
$userarr=array();
foreach($alist as $aline)
{
$clientcode="";
if($aline->crm_id>0)
{
$user=$wakka->getPerson($aline->crm_id);
$clientcode=$user["peopledata"]["clientcode"];
}
$tpostdata=json_decode($aline->data,true);
$fulldate=date("Y-m-d H:i:s",strtotime($aline->created_at)-($dashboarduser->timezone*60));
$talktime=$aline->talkSec+$aline->recstartSec+$aline->recendSec;
$length=round(($aline->waitSec+$aline->callSec+$talktime+$aline->dispoSec)/1000,2);
if(!isset($userarr[$aline->user_id])&&$aline->user_id>0)$userarr[$aline->user_id]=User::on("conn$ci")->find($aline->user_id);
$dispname="";if(isset($userarr[$aline->user_id]))$dispname=$userarr[$aline->user_id]->dispname();
$username="";if(isset($userarr[$aline->user_id]))$username=$userarr[$aline->user_id]->username;
$recstr='';
if($dashboarduser->moduleACL("Dialer",false,false,true))
{
if(isset($tpostdata['recFolder']))$recstr="<a href=# onclick='getCallRec(".$aline->id.");return false;' title='Size : ".round($aline->recsize/1024,0)." KB'><i class='fa fa-play-circle'></i> &nbsp;</a> <a href='dialer/playrecfile?calllog=$aline->id&out=wav' title=''><i class='fa fa-download'></i> &nbsp;</a><span id='recspan_".$aline->id."'</span>";
}
$outstr.="<tr><td>".$i."</td>
<td title='$fulldate'>".explode(" ",$fulldate)[1]."</td>
<td>$length</td>
<td>".$username."</td>
<td>".$dispname."</td>
<td title='".str_replace("'"," ",$aline->userremarks)."'>".$aline->userstatus."</td>
<td>".$aline->usersubstatus."</td>
<td>".($aline->usercallback!="0000-00-00 00:00:00"?date("Y-m-d H:i:s",strtotime($aline->usercallback)-($dashboarduser->timezone*60)):"")."</td>
<td><a href=# class='' onclick='dialerQuickOpen(\"$aline->crm_id\",\"$aline->number\",\"Progressive\",\"\",0);return false;'>".$aline->number."</a></td>
<td>$clientcode</td>
<td>".$aline->client."</td>
<td>".$aline->department."</td>
<td>".$aline->state."</td>
<td>".$aline->hsource."</td>
<td>".$aline->type."</td>
<td>".$aline->status."</td>
<td>".$aline->statuscode."</td>
<td>".$aline->substatus."</td>
<td>".$aline->dialline_id."</td>
<td>".$aline->did."</td>
<td>".round($aline->waitSec/1000,2)."</td>
<td>".round($aline->callSec/1000,2)."</td>
<td>".round($talktime/1000,2)."</td>
<td>".round($aline->dispoSec/1000,2)."</td>
<td>$recstr</td>
</tr>";
if($aline->type=='Inbound')
{
if($talktime>120000)$ttlovr10In++;
else if($talktime>60000)$ttlovr5In++;
else if($talktime>30000)$ttlovr1In++;
else if($talktime>1000)$ttlovr0In++;
$totaltimeIn+=round($talktime/1000,2);
$usrcntIn++;
$turl=$aline->status." - ".$aline->statuscode." - ".$aline->substatus;
if(!isset($actionarrIn[$turl]))$actionarrIn[$turl]=array('cnt'=>0,'time'=>0);
$actionarrIn[$turl]['cnt']++;
$actionarrIn[$turl]['time']+=round(($aline->callSec+$talktime)/1000,2);
}
else
{
if($talktime>120000)$ttlovr10++;
else if($talktime>60000)$ttlovr5++;
else if($talktime>30000)$ttlovr1++;
else if($talktime>1000)$ttlovr0++;
$totaltime+=round($talktime/1000,2);
$usrcnt++;
$turl=$aline->status." - ".$aline->statuscode." - ".$aline->substatus;
if(!isset($actionarr[$turl]))$actionarr[$turl]=array('cnt'=>0,'time'=>0);
$actionarr[$turl]['cnt']++;
$actionarr[$turl]['time']+=round(($aline->callSec+$talktime)/1000,2);
}
$i++;
}
}catch(Exception $e)
{
$offline[]=$server;
}
}
?>
<div class=innerAll>
<style>#logtable.td{vertical-align:top;}#logtable.tr{height:28px;overflow-y:hidden;}</style>
<script>
function showExtraPost(varstr)
{
doAjax("hr?action=LiveUsers","getpostdata="+varstr,"dialoglog");
$('#dialoglog').dialog('open');
return false;
}
$(document).ready(function()
{
if(!$('#dialoglog').hasClass('ui-dialog-content'))
{
$('#dialoglog').dialog({
autoOpen: false,
width: '70%',
buttons: {
"Ok": function() {
$(this).dialog("close");
},
"Cancel": function() {
$(this).dialog("close");
}
}
});
}
waitKeyUpRun("filter",function() { filter2(document.getElementById('filter'), 'logtable') },"2000");
$('#modfrom').datepicker({dateFormat: 'yy-mm-dd',inline: true,changeYear: true,selectOtherMonths: true,yearRange: '<?php echo (date('Y')-70).":".(date('Y')+5); ?>'});
});
</script>
<div style="float:left;width:50%">
Search <input id=filter name="filter" type="text">
Date : <input size=10 id='modfrom' name='modfrom' type='text' value='<?php echo date("Y-m-d",$logdate); ?>' onchange='callLogReloadFun("");' />
</div>
<div style="float:left;width:50%">
<button class="pull-right btn btn-sm btn-default" onclick='dlCalllogXls();return false;' title='Download' style='margin-top:-8px'><i class='fa fa-download'></i> Download</button>
</div>
<div style="clear:both"></div>
<hr>
<?php
$categories=array();$avgarr=array();$cntarr=array();
foreach($actionarr as $act=>$actarr)
{
if($actarr['cnt']>sizeof($alist)/150)
{
//echo "<label>$act</label> ".round($actarr['time']/$actarr['cnt'],2)." [".round($actarr[time],1)."/$actarr[cnt]]<br>";
$categories[]="'$act'";
$avgarr[]=-round($actarr['time']/$actarr['cnt'],2);
$cntarr[]=$actarr['cnt'];
}
}
array_multisort($cntarr,$avgarr,$categories);
$categoriesIn=array();$avgarrIn=array();$cntarrIn=array();
foreach($actionarrIn as $act=>$actarr)
{
if($actarr['cnt']>sizeof($alist)/150)
{
//echo "<label>$act</label> ".round($actarr['time']/$actarr['cnt'],2)." [".round($actarr[time],1)."/$actarr[cnt]]<br>";
$categoriesIn[]="'$act'";
$avgarrIn[]=-round($actarr['time']/$actarr['cnt'],2);
$cntarrIn[]=$actarr['cnt'];
}
}
array_multisort($cntarrIn,$avgarrIn,$categoriesIn);
?>
<div class=col-md-2>
<br>
<h5>Stats - Outbound</h5><hr><br>
<ul style="list-style:none">
<li class="notify_alert">
<span><a href=# onclick="return false;">Total CallTime</a></span>
<span class="label label-small label-default pull-right" >{!!round($totaltime,2)!!}</span>
</li>
<li class="notify_alert">
<span><a href=# onclick="return false;">Total Calls</a></span>
<span class="label label-small label-default pull-right" >{!!$usrcnt!!}</span>
</li>
<li class="notify_alert">
<span><a href=# onclick="return false;">Average CallTime</a></span>
<span class="label label-small label-default pull-right" >{!!($usrcnt>0)?round($totaltime/$usrcnt,2):'0'!!}</span>
</li>
<li class="notify_alert">
<span><a href=# onclick="return false;">Calls > 2 Min</a></span>
<span class="label label-small label-default pull-right" >{!!$ttlovr10!!}</span>
</li>
<li class="notify_alert">
<span><a href=# onclick="return false;">Calls > 1 Min</a></span>
<span class="label label-small label-default pull-right" >{!!$ttlovr5!!}</span>
</li>
<li class="notify_alert">
<span><a href=# onclick="return false;">Calls > 30 sec</a></span>
<span class="label label-small label-default pull-right" >{!!$ttlovr1!!}</span>
</li>
<li class="notify_alert">
<span><a href=# onclick="return false;">Calls > 1 sec</a></span>
<span class="label label-small label-default pull-right" >{!!$ttlovr0!!}</span>
</li>
</ul>
</div>
<div class=col-md-10>
<div id=userlogschart1 style='min-height:300px;height:<?php echo sizeof($categories)*18; ?>px;width:100%'></div>
<script>
$(function () {
var categories = [<?php echo implode(",",$categories); ?>];
$(document).ready(function () {
var userchart1=new Highcharts.Chart({
chart: {
renderTo: 'userlogschart1',
type: 'bar'
},
title: {
text: 'User Actions by Avg time and Usages'
},
xAxis: [{
categories: categories,
reversed: false,
labels: {
step: 1
}
}, { // mirror axis on right side
opposite: true,
reversed: false,
categories: categories,
linkedTo: 0,
labels: {
//step: 1
formatter: function () {
return '';
}
}
}],
yAxis: {
// title: {
// text: null
// },
// labels: {
// formatter: function () {
// return (Math.abs(this.value) / 1000000) + 'M';
// }
// },
// min: -4000000,
// max: 4000000
},
plotOptions: {
series: {
stacking: 'normal'
}
},
tooltip: {
formatter: function () {
return '<b>' + this.series.name + ' ' + this.point.category + '</b><br/>' +
'Val: ' + Highcharts.numberFormat(Math.abs(this.point.y), 0);
}
},
series: [{
name: 'Avg Time',
data: [<?php echo implode(",",$avgarr); ?>]
}, {
name: 'Count',
data: [<?php echo implode(",",$cntarr); ?>]
}]
});
});
});
function callLogReloadFun(sortby)
{
var sortstr='';if(sortby!="")sortstr="&sort="+sortby
doAjax('dialer/acalllog?logdate='+$("#modfrom").val()+sortstr+'&selectedvals='+getarvalval(),'','rightmainreportdiv','ajax_dialer_reports','singlethis','GET');
}
function getCallRec(id)
{
doAjax("dialer/acalllog","getCallRec=1&calllog="+id+'&selectedvals='+getarvalval(),'recspan_'+id,'rec_ajax','singlefail','GET');
}
function dlCalllogXls()
{
window.open('dialer/acalllog?dllogxls=1&logdate='+$("#modfrom").val()+'&selectedvals='+getarvalval());return false;
}
</script>
</div>
<div style='clear:both'></div>
<div class=col-md-2>
<br>
<h5>Stats - Inbound</h5><hr><br>
<ul style="list-style:none">
<li class="notify_alert">
<span><a href=# onclick="return false;">Total CallTime</a></span>
<span class="label label-small label-default pull-right" >{!!round($totaltimeIn,2)!!}</span>
</li>
<li class="notify_alert">
<span><a href=# onclick="return false;">Total Calls</a></span>
<span class="label label-small label-default pull-right" >{!!$usrcntIn!!}</span>
</li>
<li class="notify_alert">
<span><a href=# onclick="return false;">Average CallTime</a></span>
<span class="label label-small label-default pull-right" >{!!($usrcntIn>0)?round($totaltimeIn/$usrcntIn,2):'0'!!}</span>
</li>
<li class="notify_alert">
<span><a href=# onclick="return false;">Calls > 2 Min</a></span>
<span class="label label-small label-default pull-right" >{!!$ttlovr10In!!}</span>
</li>
<li class="notify_alert">
<span><a href=# onclick="return false;">Calls > 1 Min</a></span>
<span class="label label-small label-default pull-right" >{!!$ttlovr5In!!}</span>
</li>
<li class="notify_alert">
<span><a href=# onclick="return false;">Calls > 30 sec</a></span>
<span class="label label-small label-default pull-right" >{!!$ttlovr1In!!}</span>
</li>
<li class="notify_alert">
<span><a href=# onclick="return false;">Calls > 1 sec</a></span>
<span class="label label-small label-default pull-right" >{!!$ttlovr0In!!}</span>
</li>
</ul>
</div>
<div class=col-md-10>
<div id=userlogschart2 style='min-height:300px;height:<?php echo sizeof($categoriesIn)*18; ?>px;width:100%'></div>
<script>
$(function () {
var categories = [<?php echo implode(",",$categoriesIn); ?>];
$(document).ready(function () {
var userchart1=new Highcharts.Chart({
chart: {
renderTo: 'userlogschart2',
type: 'bar'
},
title: {
text: 'User Actions by Avg time and Usages'
},
xAxis: [{
categories: categories,
reversed: false,
labels: {
step: 1
}
}, { // mirror axis on right side
opposite: true,
reversed: false,
categories: categories,
linkedTo: 0,
labels: {
//step: 1
formatter: function () {
return '';
}
}
}],
yAxis: {
// title: {
// text: null
// },
// labels: {
// formatter: function () {
// return (Math.abs(this.value) / 1000000) + 'M';
// }
// },
// min: -4000000,
// max: 4000000
},
plotOptions: {
series: {
stacking: 'normal'
}
},
tooltip: {
formatter: function () {
return '<b>' + this.series.name + ' ' + this.point.category + '</b><br/>' +
'Val: ' + Highcharts.numberFormat(Math.abs(this.point.y), 0);
}
},
series: [{
name: 'Avg Time',
data: [<?php echo implode(",",$avgarrIn); ?>]
}, {
name: 'Count',
data: [<?php echo implode(",",$cntarrIn); ?>]
}]
});
});
});
</script>
</div>
<div style='clear:both'></div>
<div style='overflow:auto'>
<table id=logtable class='footable table table-striped table-bordered table-white table-primary footable-loaded' style='font-size:12px'>
<thead>
<tr>
<th>#</th>
<th>Start</th>
<th onclick='callLogReloadFun("");return false;'>Length</th>
<th>User</th>
<th>Name</th>
<th>Dispo</th>
<th>SubDispo</th>
<th>CB</th>
<th style='width:120px'>Number</th>
<th>ClientCode</th>
<th>Data</th>
<th>SubData</th>
<th>State</th>
<th>HSource</th>
<th>Type</th>
<th>Status</th>
<th>StatusCode</th>
<th>StatusStr</th>
<th>DialLine</th>
<th>DID</th>
<th>WaitSec</th>
<th>CallSec</th>
<th>TalkSec</th>
<th>DispoSec</th>
<th>Recording</th>
</tr>
</thead>
<?php echo $outstr; ?>
</table>
</div>
<?php
function convert($size)
{
$unit=array('b','kb','mb','gb','tb','pb');
return @round($size/pow(1024,($i=floor(log($size,1024)))),2).' '.$unit[$i];
}
echo "<br>".convert(memory_get_peak_usage(true)); // 123 kb
?>
<div id=dialoglog></div>
</div>
<?php
use App\Models\CRMCall;
use App\Models\User;
use App\Jobs\KHRMSLib;
$selectedvals=explode(":",Input::get("selectedvals",":::::"));
$hdfcnodes=array();
$offline=array();
$arr=Config::get("app.hdfcnodes");
foreach($arr as $server=>$arrline)
{
$tvals=explode(":",$arrline);
if($selectedvals[0]=="")$hdfcnodes[]=$server;
else if($selectedvals[0]==$tvals[0])
{
if($selectedvals[1]=="")$hdfcnodes[]=$server;
else if($selectedvals[1]==$tvals[1])
{
if($selectedvals[2]=="")$hdfcnodes[]=$server;
else if($selectedvals[2]==$tvals[2])
{
if($selectedvals[3]=="")$hdfcnodes[]=$server;
else if($selectedvals[3]==$tvals[3])
{
if($selectedvals[4]=="")$hdfcnodes[]=$server;
else if($selectedvals[4]==$tvals[4])
{
$hdfcnodes[]=$server;
}
}
}
}
}
}
$wakka = new KHRMSLib();
$dashboarduser=Auth::user();
if(isset($_GET['logdate']))$logdate=strtotime($_GET['logdate']." 00:00:00");
else $logdate=strtotime(date('Y-m-d')." 00:00:00");
$i=1;
$reporthead=array("#","UserId","UserName","Count","Total","Wait","Call","Talk","Dispo");
$reportarray=array();
foreach($hdfcnodes as $ci=>$server)
{
$conn = array(
'driver' => 'mysql',
'host' => $server,
'database' => env('DB_DATABASE', 'kstych_flexydial'),
'username' => env('DB_USERNAME', 'root'),
'password' => env('DB_PASSWORD', ''),
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
'options' => array(
PDO::ATTR_TIMEOUT => 5,
),
);
Config::set("database.connections.conn$ci", $conn);
try
{
DB::connection("conn$ci")->getDatabaseName();
$alist=CRMCall::on("conn$ci")->where('created_at','>=',date("Y-m-d H:i:s",$logdate))->where('created_at','<=',date("Y-m-d H:i:s",$logdate+24*60*60));
$alist=$alist->get();
$userarr=array();
foreach($alist as $aline)
{
if(!isset($userarr[$aline->user_id."conn$ci"]))$userarr[$aline->user_id."conn$ci"]=User::on("conn$ci")->find($aline->user_id."conn$ci");
$tuser=$userarr[$aline->user_id."conn$ci"];
if(!isset($reportarray[$aline->user_id."conn$ci"]))$reportarray[$aline->user_id."conn$ci"]=array("#"=>$i++,"UserId"=>$tuser->id,"UserName"=>$tuser->username,"Count"=>0,"Total"=>0,"Wait"=>0,"Call"=>0,"Talk"=>0,"Dispo"=>0);
$talktime=$aline->talkSec+$aline->recstartSec+$aline->recendSec;
$reportarray[$aline->user_id."conn$ci"]["Count"]++;
$reportarray[$aline->user_id."conn$ci"]["Total"]+=round(($aline->waitSec+$aline->callSec+$talktime+$aline->dispoSec)/1000,2);
$reportarray[$aline->user_id."conn$ci"]["Wait"]+=round($aline->waitSec/1000,2);
$reportarray[$aline->user_id."conn$ci"]["Call"]+=round($aline->callSec/1000,2);
$reportarray[$aline->user_id."conn$ci"]["Talk"]+=round($talktime/1000,2);
$reportarray[$aline->user_id."conn$ci"]["Dispo"]+=round($aline->dispoSec/1000,2);
}
}catch(Exception $e)
{
$offline[]=$server;
}
}
if(Input::has("dllogxls"))
{
include_once(app_path().'/lib/phpexcel/PHPExcel.php');
$inputFileType = "Excel5";
$objReader = PHPExcel_IOFactory::createReader($inputFileType);
$objPHPExcel = $objReader->load("assets/extras/blank.xls");
$baseRow = 3;
$highestColumn = sizeof($reporthead);
for ($head = 0; $head < $highestColumn; $head++){
$colstr=PHPExcel_Cell::stringFromColumnIndex($head);
$objPHPExcel->getActiveSheet()->setCellValue($colstr."1", $reporthead[$head]);
}
foreach($reportarray as $uid=>$uarr)
{
$row = $baseRow++;
$col = 0;
for ($head = 0; $head < $highestColumn; $head++){
$colstr=PHPExcel_Cell::stringFromColumnIndex($head);
$objPHPExcel->getActiveSheet()->setCellValue($colstr.$row, $uarr[$reporthead[$head]]);
}
}
header('Content-Type: application/vnd.ms-excel');
header('Content-Disposition: attachment;filename="TimeLog.xls"');
header('Cache-Control: max-age=0');
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, $inputFileType);
$objWriter->save('php://output');
return ;
}
$highestColumn = sizeof($reporthead);
$outhead="<tr>";$outstr="";
for ($head = 0; $head < $highestColumn; $head++){
$outhead.="<td>".$reporthead[$head]."</td>";
}
$outhead.="</tr>";
foreach($reportarray as $uid=>$uarr)
{
$outstr.="<tr>";
for ($head = 0; $head < $highestColumn; $head++){
$outstr.="<td>".$uarr[$reporthead[$head]]."</td>";
}
$outstr.="</tr>";
}
//charts
$cat1=array();
$cat1arr=array();
foreach($reportarray as $uid=>$uarr)
{
$cat1[]="'$uarr[UserName]'";
for ($head = 5; $head < $highestColumn; $head++){
if(!isset($cat1arr[$reporthead[$head]]))$cat1arr[$reporthead[$head]]=array();
$cat1arr[$reporthead[$head]][$uarr["#"]]=round($uarr[$reporthead[$head]]/60,1);
if(empty($cat1arr[$reporthead[$head]][$uarr["#"]]))$cat1arr[$reporthead[$head]][$uarr["#"]]=0;
}
}
$cat1arrstr="";
foreach($cat1arr as $name=>$data)
{
$cat1arrstr.="{ name: '$name',\ndata : [";
$cat1arrstr.=implode(",",$data);
$cat1arrstr.="] },\n";
}
$cat2=array();
foreach($reportarray as $uid=>$uarr)
{
for ($head = 5; $head < $highestColumn; $head++){
$cat2["'".$reporthead[$head]."'"]+=round($uarr[$reporthead[$head]]/60,1);
}
}
?>
<div class=innerAll>
<style>#logtable.td{vertical-align:top;}#logtable.tr{height:28px;overflow-y:hidden;}</style>
<script>
$(document).ready(function()
{
if(!$('#dialoglog').hasClass('ui-dialog-content'))
{
$('#dialoglog').dialog({
autoOpen: false,
width: '70%',
buttons: {
"Ok": function() {
$(this).dialog("close");
},
"Cancel": function() {
$(this).dialog("close");
}
}
});
}
waitKeyUpRun("filter",function() { filter2(document.getElementById('filter'), 'logtable') },"2000");
$('#modfrom').datepicker({dateFormat: 'yy-mm-dd',inline: true,changeYear: true,selectOtherMonths: true,yearRange: '<?php echo (date('Y')-70).":".(date('Y')+5); ?>'});
});
</script>
<div style="float:left;width:50%">
Search <input id=filter name="filter" type="text">
Date : <input size=10 id='modfrom' name='modfrom' type='text' value='<?php echo date("Y-m-d",$logdate); ?>' onchange='campLogReloadFun("");' />
</div>
<div style="float:left;width:50%">
<button class="pull-right btn btn-sm btn-default" onclick='dlAgentlogXls();return false;' title='Download' style='margin-top:-8px'><i class='fa fa-download'></i> Download</button>
</div>
<div style="clear:both"></div>
<hr>
<div class=col-md-12>
<div id=userlogschart1 style='min-height:300px;width:100%'></div>
<script>
$(function () {
$('#userlogschart1').highcharts({
chart: {
type: 'column'
},
title: {
text: ''
},
xAxis: {
labels:{
enabled:false//default is true
},
categories: [<?php echo implode(",",$cat1); ?>]
},
yAxis: {
min: 0,
title: {
text: ''
},
stackLabels: {
enabled: false,
// style: {
// fontWeight: '',
// color: (Highcharts.theme && Highcharts.theme.textColor) || 'gray'
// }
}
},
// legend: {
// align: 'right',
// x: -30,
// verticalAlign: 'top',
// y: 25,
// floating: true,
// backgroundColor: (Highcharts.theme && Highcharts.theme.background2) || 'white',
// borderColor: '#CCC',
// borderWidth: 1,
// shadow: false
// },
tooltip: {
headerFormat: '<b>{point.x}</b><br/>',
pointFormat: '{series.name}: {point.y}<br/>Total: {point.stackTotal}'
},
plotOptions: {
column: {
stacking: 'normal',
dataLabels: {
enabled: false,
// color: (Highcharts.theme && Highcharts.theme.dataLabelsColor) || 'white',
// style: {
// textShadow: '0 0 3px black'
// }
}
}
},
series: [<?php echo $cat1arrstr; ?>]
});
});
function campLogReloadFun(sortby)
{
var sortstr='';if(sortby!="")sortstr="&sort="+sortby
doAjax('dialer/acampreport?logdate='+$("#modfrom").val()+sortstr+'&selectedvals='+getarvalval(),'','rightmainreportdiv','ajax_dialer_reports','singlethis','GET');
}
function dlAgentlogXls()
{
window.open('dialer/acampreport?dllogxls=1&logdate='+$("#modfrom").val()+'&selectedvals='+getarvalval());return false;
}
</script>
</div>
<div style='clear:both'></div>
<div class=col-md-12>
<div id=userlogschart2 style='min-height:300px;width:100%'></div>
<script>
$(function () {
$('#userlogschart2').highcharts({
chart: {
type: 'column'
},
title: {
text: ''
},
subtitle: {
text: ''
},
xAxis: {
categories: [<?php echo implode(",",array_keys($cat2)); ?>],
crosshair: true
},
yAxis: {
min: 0,
title: {
text: ''
}
},
tooltip: {
headerFormat: '<span style="font-size:10px">{point.key}</span><table>',
pointFormat: '<tr><td style="color:{series.color};padding:0">{series.name}: </td>' +
'<td style="padding:0"><b>{point.y:.1f}</b></td></tr>',
footerFormat: '</table>',
shared: true,
useHTML: true
},
plotOptions: {
column: {
pointPadding: 0.2,
borderWidth: 0
}
},
legend : {
floating: true,
align: 'right',
x: -30,
verticalAlign: 'top',
},
series: [{
name: 'Mins',
data: [<?php echo implode(",",array_values($cat2)); ?>]
},]
});
});
</script>
</div>
<div style='clear:both'></div>
<div style='overflow:auto'>
<table id=logtable class='footable table table-striped table-bordered table-white table-primary footable-loaded' style='font-size:12px'>
<thead>
<?php echo $outhead; ?>
</thead>
<?php echo $outstr; ?>
</table>
</div>
<div id=dialoglog></div>
</div>
<?php
use App\Models\Sipid;
use App\Models\UserLog;
use App\Models\CRMCall;
use App\Models\User;
use App\Jobs\KHRMSLib;
$wakka = new KHRMSLib();
$dashboarduser=Auth::user();
$uidlist=array();$onlineusers=array();
if(isset($_GET['logdate']))$logdate=strtotime($_GET['logdate']." 00:00:00");
else $logdate=strtotime(date('Y-m-d')." 00:00:00");
$alist=UserLog::where('created_at','>=',date("Y-m-d H:i:s",$logdate))->where('created_at','<=',date("Y-m-d H:i:s",$logdate+24*60*60))->where('durationsec','>',0);
//if(!$dashboarduser->moduleACL("Admin",false,false,true))
if($dashboarduser->usertype != 'Admin')
{
$uidlist[]=$dashboarduser->id;
$allusers=User::where(function ($query) use($dashboarduser) {
$query->where('supervisor','=',$dashboarduser->username)
->orWhere('lteam2','=',$dashboarduser->username)
->orWhere('lteam','=',$dashboarduser->username);
})->get();
foreach($allusers as $tuser)
{
$uidlist[]=$tuser->id;
if($tuser->presence==1)$onlineusers[]=$tuser;
}
$alist=$alist->whereIn('user_id',$uidlist);
}
else
{
$allusers=User::all();
foreach($allusers as $tuser)
{
$uidlist[]=$tuser->id;
if($tuser->presence==1)$onlineusers[]=$tuser;
}
}
//$sipids=Sipid::whereIn("user",$uidlist)->where("status","=","1")->get();
$alist=$alist->get();
$userarr=array();$i=1;
$reporthead=array("#","UserId","User","Name","In","Out","InOut","Sessions","Duration","not-ready","Manual-","Progressive-","Prod-TOS","Prog-Time","Man-Time","Inc-Time","Talk-Time","Disp-Time","Wait-Time","Call-Time","Prog-Talk-Time","Prog-Disp-Time","Prog-Wait-Time","Prog-Call-Time","Man-Talk-Time","Man-Disp-Time","Man-Wait-Time","Man-Call-Time","Inc-Talk-Time","Inc-Disp-Time","Inc-Wait-Time","Inc-Call-Time");
$reportarray=array();
foreach($alist as $aline)
{
if(!isset($userarr[$aline->user_id."conn$ci"]))$userarr[$aline->user_id."conn$ci"]=User::find($aline->user_id."conn$ci");
$tuser=$userarr[$aline->user_id."conn$ci"];
/*
if(!isset($reportarray[$aline->user_id."conn$ci"]))$reportarray[$aline->user_id."conn$ci"]=array("#"=>$i++,"UserId"=>$aline->user_id."conn$ci","User"=>$tuser->username,"Name"=>$tuser->fullname,"In"=>"","Out"=>"","InOut"=>0,"Sessions"=>0,"Duration"=>0);
*/
if(!isset($reportarray[$aline->user_id."conn$ci"]))$reportarray[$aline->user_id."conn$ci"]=array("#"=>$i++,"UserId"=>$aline->user_id,"User"=>$tuser->username,"Name"=>$tuser->fullname,"In"=>"","Out"=>"","InOut"=>0,"Sessions"=>0,"Duration"=>0,"not-ready"=>0);
if($reportarray[$aline->user_id."conn$ci"]["In"]=="")$reportarray[$aline->user_id."conn$ci"]["In"]=date("Y-m-d H:i:s",strtotime($aline->created_at)-($dashboarduser->timezone*60));
$reportarray[$aline->user_id."conn$ci"]["Out"]=date("Y-m-d H:i:s",strtotime($aline->updated_at)-($dashboarduser->timezone*60));
$reportarray[$aline->user_id."conn$ci"]["InOut"]=strtotime($reportarray[$aline->user_id."conn$ci"]["Out"])-strtotime($reportarray[$aline->user_id."conn$ci"]["In"]);
// $reportarray[$aline->user_id."conn$ci"]["not-ready"]=12;
$reportarray[$aline->user_id."conn$ci"]["Sessions"]++;
if($aline->durationsec!=0){
$reportarray[$aline->user_id."conn$ci"]["Duration"]=$aline->durationsec;
$data=json_decode($aline->data,true);
foreach($data as $sipid=>$sdata)
{
$pts=$sdata['ts'];
// $reportarray[$aline->user_id."conn$ci"]["Sessions"]++;
// $reportarray[$aline->user_id."conn$ci"]["Duration"]+=$aline->durationsec;
if(isset($sdata['states']))
{
$previous="Login";
$fts="";
$prets=strtotime($aline->startdate." ".$aline->starttime);
foreach($sdata['states'] as $ts=>$states)
{
if($fts!=""){
/*$fts=$ts/1000;*/
if(!in_array($previous,$reporthead))$reporthead[]=$previous;
$reportarray[$aline->user_id."conn$ci"][$previous]+=round($ts-$prets,2)/1000;
}
$prets=$ts;
$fts=$ts;
$previous=$states[0]."-".$states[1];
}
//print_r($sdata['states']);
if(!in_array($previous,$reporthead))$reporthead[]=$previous;
$reportarray[$aline->user_id."conn$ci"][$previous]+=round($pts-$fts,2);
}
else
{
// $reportarray[$aline->user_id."conn$ci"]["Login"]+=$aline->durationsec;
}
}
$startTime=$aline->startdate." ".$aline->starttime;
$endTime=$aline->enddate." ".$aline->endtime;
$crmCalls=DB::select(DB::raw("select user_id,type,ts_Wait,ts_Call,ts_Talk,ts_Recstart,ts_Recend,ts_Dispo,ts_Close from crmcalls WHERE updated_at>='".$startTime."' and updated_at<'".$endTime."' and user_id='".$aline->user_id."'"));
$ts_Wait=0;$ts_Call=0;$ts_Talk=0;$ts_Dispo=0;
$progTs_Wait=0;$progTs_Call=0;$progTs_Talk=0;$progTs_Dispo=0;
$manTs_Wait=0;$manTs_Call=0;$manTs_Talk=0;$manTs_Dispo=0;
$inbTs_Wait=0;$inbTs_Call=0;$inbTs_Talk=0;$inbTs_Dispo=0;
$tt_prog=0;$tt_man=0;$tt_inb=0;
if($crmCalls!=null){
foreach($crmCalls as $crmCall){
$ts_Wait += round(($crmCall->ts_Call - $crmCall->ts_Wait)/1000,2);
$ts_Call += round(($crmCall->ts_Talk - $crmCall->ts_Call)/1000,2);
$ts_Talk += round(($crmCall->ts_Dispo - $crmCall->ts_Talk)/1000,2);
$ts_Dispo += round(($crmCall->ts_Close - $crmCall->ts_Dispo)/1000,2);
if($crmCall->type == 'Progressive')
{
$progTs_Wait += round(($crmCall->ts_Call - $crmCall->ts_Wait)/1000,2);
$progTs_Call += round(($crmCall->ts_Talk - $crmCall->ts_Call)/1000,2);
$progTs_Talk += round(($crmCall->ts_Dispo - $crmCall->ts_Talk)/1000,2);
$progTs_Dispo += round(($crmCall->ts_Close - $crmCall->ts_Dispo)/1000,2);
}
if($crmCall->type == 'Manual')
{
$manTs_Wait += round(($crmCall->ts_Call - $crmCall->ts_Wait)/1000,2);
$manTs_Call += round(($crmCall->ts_Talk - $crmCall->ts_Call)/1000,2);
$manTs_Talk += round(($crmCall->ts_Dispo - $crmCall->ts_Talk)/1000,2);
$manTs_Dispo += round(($crmCall->ts_Close - $crmCall->ts_Dispo)/1000,2);
}
if($crmCall->type == 'Inbound')
{
$inbTs_Wait += round(($crmCall->ts_Call - $crmCall->ts_Wait)/1000,2);
$inbTs_Call += round(($crmCall->ts_Talk - $crmCall->ts_Call)/1000,2);
$inbTs_Talk += round(($crmCall->ts_Dispo - $crmCall->ts_Talk)/1000,2);
$inbTs_Dispo += round(($crmCall->ts_Close - $crmCall->ts_Dispo)/1000,2);
}
}
}
$tt_prog = $progTs_Wait + $progTs_Call + $progTs_Talk + $progTs_Dispo;
$tt_man = $manTs_Wait + $manTs_Call + $manTs_Talk + $manTs_Dispo;
$tt_inb = $inbTs_Wait + $inbTs_Call + $inbTs_Talk + $inbTs_Dispo;
$prod_TOS = $ts_Wait + $ts_Call + $ts_Talk + $ts_Dispo;
$reportarray[$aline->user_id."conn$ci"]["Prog-Time"]= $tt_prog;
$reportarray[$aline->user_id."conn$ci"]["Man-Time"]= $tt_man;
$reportarray[$aline->user_id."conn$ci"]["Inc-Time"]= $tt_inb;
$reportarray[$aline->user_id."conn$ci"]["Wait-Time"]= $ts_Wait;
$reportarray[$aline->user_id."conn$ci"]["Call-Time"]= $ts_Call;
$reportarray[$aline->user_id."conn$ci"]["Talk-Time"]= $ts_Talk;
$reportarray[$aline->user_id."conn$ci"]["Disp-Time"]= $ts_Dispo;
$reportarray[$aline->user_id."conn$ci"]["Prog-Wait-Time"]= $progTs_Wait;
$reportarray[$aline->user_id."conn$ci"]["Prog-Call-Time"]= $progTs_Call;
$reportarray[$aline->user_id."conn$ci"]["Prog-Talk-Time"]= $progTs_Talk;
$reportarray[$aline->user_id."conn$ci"]["Prog-Disp-Time"]= $progTs_Dispo;
$reportarray[$aline->user_id."conn$ci"]["Man-Wait-Time"]= $manTs_Wait;
$reportarray[$aline->user_id."conn$ci"]["Man-Call-Time"]= $manTs_Call;
$reportarray[$aline->user_id."conn$ci"]["Man-Talk-Time"]= $manTs_Talk;
$reportarray[$aline->user_id."conn$ci"]["Man-Disp-Time"]= $manTs_Dispo;
$reportarray[$aline->user_id."conn$ci"]["Inc-Wait-Time"]= $inbTs_Wait;
$reportarray[$aline->user_id."conn$ci"]["Inc-Call-Time"]= $inbTs_Call;
$reportarray[$aline->user_id."conn$ci"]["Inc-Talk-Time"]= $inbTs_Talk;
$reportarray[$aline->user_id."conn$ci"]["Inc-Disp-Time"]= $inbTs_Dispo;
$reportarray[$aline->user_id."conn$ci"]["Prod-TOS"]= $prod_TOS;
}
}
if(Input::has("dllogxls"))
{
include_once(app_path().'/lib/phpexcel/PHPExcel.php');
$inputFileType = "Excel5";
$objReader = PHPExcel_IOFactory::createReader($inputFileType);
$objPHPExcel = $objReader->load("assets/extras/blank.xls");
$baseRow = 3;
$highestColumn = sizeof($reporthead);
for ($head = 0; $head < $highestColumn; $head++){
if($head==9){
$colstr=PHPExcel_Cell::stringFromColumnIndex($head);
$objPHPExcel->getActiveSheet()->setCellValue($colstr."1", "NotReady");
$colstr=PHPExcel_Cell::stringFromColumnIndex(10);
$objPHPExcel->getActiveSheet()->setCellValue($colstr."1", "ProdTos");
}else{
if($head<9){
$colstr=PHPExcel_Cell::stringFromColumnIndex($head);
$objPHPExcel->getActiveSheet()->setCellValue($colstr."1", $reporthead[$head]);
}else{
$rom=$head+1;
$colstr=PHPExcel_Cell::stringFromColumnIndex($rom);
$objPHPExcel->getActiveSheet()->setCellValue($colstr."1", $reporthead[$head]);
}
}
}
foreach($reportarray as $uid=>$uarr)
{
$row = $baseRow++;
$col = 0;
$rom='';
$notreadyn=0;
for ($head = 10; $head < $highestColumn; $head++){
//if($head!=12)
$notreadyn=$notreadyn+$uarr[$reporthead[$head]];
$rom.=",".$uarr[$reporthead[$head]].",";
}
$notready=$uarr[$reporthead[8]]-$notreadyn;
for ($head = 0; $head < $highestColumn; $head++){
if($head==9){
$colstr=PHPExcel_Cell::stringFromColumnIndex($head);
$objPHPExcel->getActiveSheet()->setCellValue($colstr.$row, $notready);
$prodtos=$uarr[$reporthead[10]]+$uarr[$reporthead[12]];
$colstr=PHPExcel_Cell::stringFromColumnIndex(10);
$objPHPExcel->getActiveSheet()->setCellValue($colstr.$row,$prodtos);
}else{
if($head<9){ $colstr=PHPExcel_Cell::stringFromColumnIndex($head);
$objPHPExcel->getActiveSheet()->setCellValue($colstr.$row, $uarr[$reporthead[$head]]);
}else{
$rom=$head+1;
$colstr=PHPExcel_Cell::stringFromColumnIndex($rom);
$objPHPExcel->getActiveSheet()->setCellValue($colstr.$row, $uarr[$reporthead[$head]]);
}
}
}
}
header('Content-Type: application/vnd.ms-excel');
header('Content-Disposition: attachment;filename="AgentLog.xls"');
header('Cache-Control: max-age=0');
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, $inputFileType);
$objWriter->save('php://output');
return ;
}
$highestColumn = sizeof($reporthead);
$outhead="<tr>";$outstr="";
for ($head = 0; $head < $highestColumn; $head++){
/*if($reporthead[$head]=='Login'){
$outhead.="<td> NotReady </td>";
$outhead.="<td> ProdTos </td>";
}else{*/
$outhead.="<td>".$reporthead[$head]."</td>";
/*}*/
}
$outhead.="</tr>";
$prodtos='';
$notreadyn=0;
$rom='';
foreach($reportarray as $uid=>$uarr)
{
$rom='';
$notreadyn=0;
for ($head = 10; $head < $highestColumn; $head++){
//if($head!=12)
$notreadyn=$notreadyn+$uarr[$reporthead[$head]];
$rom.=",".$uarr[$reporthead[$head]].",";
}
$notready=$uarr[$reporthead[8]]-$notreadyn;
$outstr.="<tr>";
for ($head = 0; $head < $highestColumn; $head++){
if($head==9){
$outstr.="<td>".gmdate('H:i:s',round($notready))."</td>";
// $outstr.="<td>".gmdate('H:i:s',round($uarr[$reporthead[$head]]))."</td>";
$prodtos=$uarr[$reporthead[10]]+$uarr[$reporthead[12]];
$outstr.="<td>".gmdate('H:i:s',round($prodtos))."</td>";
}else{
if($head>7||$head==6){
//if($head==12){
//$outstr.="<td>".gmdate('H:i:s',$uarr[$reporthead[$head]]).",".$uarr[$reporthead[$head]]."</td>";
//}else{
$outstr.="<td>".gmdate('H:i:s',round($uarr[$reporthead[$head]]))."</td>";
//}
}else{
$outstr.="<td>".$uarr[$reporthead[$head]]."</td>";
}
}
}
$outstr.="</tr>";
}
//charts
$cat1=array();
$cat1arr=array();
foreach($reportarray as $uid=>$uarr)
{
$cat1[]="'$uarr[UserName]'";
for ($head = 8; $head < $highestColumn; $head++){
if(!isset($cat1arr[$reporthead[$head]]))$cat1arr[$reporthead[$head]]=array();
$cat1arr[$reporthead[$head]][$uarr["#"]]=round($uarr[$reporthead[$head]]/60,1);
if(empty($cat1arr[$reporthead[$head]][$uarr["#"]]))$cat1arr[$reporthead[$head]][$uarr["#"]]=0;
}
}
$cat1arrstr="";
foreach($cat1arr as $name=>$data)
{
$cat1arrstr.="{ name: '$name',\ndata : [";
$cat1arrstr.=implode(",",$data);
$cat1arrstr.="] },\n";
}
$cat2=array();
foreach($reportarray as $uid=>$uarr)
{
for ($head = 8; $head < $highestColumn; $head++){
$cat2["'".$reporthead[$head]."'"]+=round($uarr[$reporthead[$head]]/60,1);
}
}
?>
<div class=innerAll>
<style>#logtable.td{vertical-align:top;}#logtable.tr{height:28px;overflow-y:hidden;}</style>
<script>
$(document).ready(function()
{
if(!$('#dialoglog').hasClass('ui-dialog-content'))
{
$('#dialoglog').dialog({
autoOpen: false,
width: '70%',
buttons: {
"Ok": function() {
$(this).dialog("close");
},
"Cancel": function() {
$(this).dialog("close");
}
}
});
}
waitKeyUpRun("filter",function() { filter2(document.getElementById('filter'), 'logtable') },"2000");
$('#modfrom').datepicker({dateFormat: 'yy-mm-dd',inline: true,changeYear: true,selectOtherMonths: true,yearRange: '<?php echo (date('Y')-70).":".(date('Y')+5); ?>'});
});
</script>
<div style="float:left;width:50%">
Search <input id=filter name="filter" type="text">
Date : <input size=10 id='modfrom' name='modfrom' type='text' value='<?php echo date("Y-m-d",$logdate); ?>' onchange='agentLogReloadFun("");' />
</div>
<div style="float:left;width:50%">
<button class="pull-right btn btn-sm btn-default" onclick='dlAgentlogXls();return false;' title='Download' style='margin-top:-8px'><i class='fa fa-download'></i> Download</button>
</div>
<div style="clear:both"></div>
<hr>
<div class=col-md-12>
<div id=userlogschart1 style='min-height:300px;width:100%'></div>
<script>
$(function () {
$('#userlogschart1').highcharts({
chart: {
type: 'column'
},
title: {
text: ''
},
xAxis: {
labels:{
enabled:false//default is true
},
categories: [<?php echo implode(",",$cat1); ?>]
},
yAxis: {
min: 0,
title: {
text: ''
},
stackLabels: {
enabled: false,
// style: {
// fontWeight: '',
// color: (Highcharts.theme && Highcharts.theme.textColor) || 'gray'
// }
}
},
// legend: {
// align: 'right',
// x: -30,
// verticalAlign: 'top',
// y: 25,
// floating: true,
// backgroundColor: (Highcharts.theme && Highcharts.theme.background2) || 'white',
// borderColor: '#CCC',
// borderWidth: 1,
// shadow: false
// },
tooltip: {
headerFormat: '<b>{point.x}</b><br/>',
pointFormat: '{series.name}: {point.y}<br/>Total: {point.stackTotal}'
},
plotOptions: {
column: {
stacking: 'normal',
dataLabels: {
enabled: false,
// color: (Highcharts.theme && Highcharts.theme.dataLabelsColor) || 'white',
// style: {
// textShadow: '0 0 3px black'
// }
}
}
},
series: [<?php echo $cat1arrstr; ?>]
});
});
function agentLogReloadFun(sortby)
{
var sortstr='';if(sortby!="")sortstr="&sort="+sortby
doAjax('dialer/agentreport?logdate='+$("#modfrom").val()+sortstr,'','rightmainreportdiv','ajax_dialer_reports','singlethis','GET');
}
function dlAgentlogXls()
{
window.open('dialer/agentreport?dllogxls=1&logdate='+$("#modfrom").val());return false;
}
</script>
</div>
<div style='clear:both'></div>
<div class=col-md-12>
<div id=userlogschart2 style='min-height:300px;width:100%'></div>
<script>
$(function () {
$('#userlogschart2').highcharts({
chart: {
type: 'column'
},
title: {
text: ''
},
subtitle: {
text: ''
},
xAxis: {
categories: [<?php echo implode(",",array_keys($cat2)); ?>],
crosshair: true
},
yAxis: {
min: 0,
title: {
text: ''
}
},
tooltip: {
headerFormat: '<span style="font-size:10px">{point.key}</span><table>',
pointFormat: '<tr><td style="color:{series.color};padding:0">{series.name}: </td>' +
'<td style="padding:0"><b>{point.y:.1f}</b></td></tr>',
footerFormat: '</table>',
shared: true,
useHTML: true
},
plotOptions: {
column: {
pointPadding: 0.2,
borderWidth: 0
}
},
legend : {
floating: true,
align: 'right',
x: -30,
verticalAlign: 'top',
},
series: [{
name: 'Mins',
data: [<?php echo implode(",",array_values($cat2)); ?>]
},]
});
});
</script>
</div>
<div style='clear:both'></div>
<div style='overflow:auto'>
<table id=logtable class='footable table table-striped table-bordered table-white table-primary footable-loaded' style='font-size:12px'>
<thead>
<?php echo $outhead; ?>
</thead>
<?php echo $outstr; ?>
</table>
</div>
<div id=dialoglog></div>
</div>
<?php
use App\Models\CRMCall;
use App\Models\CRMCallArchive;
use App\Models\User;
use App\Models\UserLog;
use App\Jobs\KHRMSLib;
$wakka = new KHRMSLib();
$dashboarduser=Auth::user();
$timeoffset = $dashboarduser->timezone; //-330; //$dashboarduser->timezone;
$timeoffset = $timeoffset*60;
$logtime =(isset($_GET['logtime'])) ? $_GET['logtime'] :9;
$logtimeto =(isset($_GET['logtimeto']))? $_GET['logtimeto']:20;
$logdate =(isset($_GET['logdate'])) ? strtotime($_GET['logdate']." ".$logtime.":00:00")
: strtotime(date("Y-m-d")." 09:00:00");
$logdateto =(isset($_GET['logdateto']))? strtotime($_GET['logdateto']." ".$logtimeto.":00:00")
: strtotime(date("Y-m-d")." 20:00:00");
$campaign =(isset($_GET['campaign'])) ? $_GET['campaign'] : "All";
// testing input
//$logtime = 9;$logtimeto = 20;$logdate = strtotime("2017-10-26 ".$logtime.":00:00");$logdateto = strtotime("2017-10-26 ".$logtimeto.":00:00");$campaign = 'All';
// testing input
$alist=CRMCallArchive::where('user_id','!=',0)->where('created_at','>=',date("Y-m-d H:i:s",$logdate+$timeoffset))->where('created_at','<=',date("Y-m-d H:i:s",$logdateto+$timeoffset));
$alist->orderBy('user_id', 'ASC')->orderBy('ts_Close', 'ASC');
$userlog=UserLog::where('created_at','>=',date("Y-m-d H:i:s",$logdate+$timeoffset))->where('created_at','<=',date("Y-m-d H:i:s",$logdateto+$timeoffset));
if($campaign != 'All') $alist->where('client','=',$campaign);
$userarr=array();
$allusers = DB::table('users as u1')->leftjoin('users AS u2', 'u2.username', '=', 'u1.supervisor')
->select('u1.id','u1.username','u1.fullname AS telecaller', 'u2.fullname AS sepervisor')
->where('u1.status','=','Active');
$roclientstr=array();$didlinesstr=array();
if($dashboarduser->exten!="")$didlinesstr[]=$dashboarduser->exten;
$oclientlst=$wakka->clientsReadAccess(); sort($oclientlst); $oclientlst[0] = 'All';
if(!empty($oclientlst))foreach($oclientlst as $tclnt)if($tclnt!="")
{
$roclientstr[]="$tclnt";
$mastersdata=$wakka->getCompanyMaster($tclnt);
if(!empty($mastersdata["DialerDID"]))$didlinesstr[]=$mastersdata["DialerDID"];
}
$breaks=array("Paused","AgentBriefing","TeamMeeting","QualityFeedback","LunchBreak","TeaBreak","UtilityBreak","FloorAnnouncements","DownTime");
$reporthead=array_merge(array("#","RM","RM Code","Team Manager","Sessions","CallCount","TOS","Net Total","Wait","Call","Talk","Dispo","ProgressiveTotal","P-Call","P-Talk","P-Dispo","ManualTotal","M-Call","M-Talk","M-Dispo","IncomingTotal","I-Call","I-Talk","I-Dispo","PausedTotal"),$breaks);
$reportarray=array();
$i=1;
if($dashboarduser->usertype != 'Admin')
{
$uidlist=array($dashboarduser->id);
$allusers=$allusers->where(function ($query) use($dashboarduser) {
$query->where('u1.supervisor','=',$dashboarduser->username)
->orWhere('u1.lteam2','=',$dashboarduser->username)
->orWhere('u1.lteam','=',$dashboarduser->username);
})->get();
foreach($allusers as $tuser)
{
$uidlist[]=$tuser->id;
$reportarray[$tuser->id]=array("#"=>$i++,"RM"=>$tuser->telecaller,"RM Code"=>$tuser->username,"Team Manager"=>$tuser->sepervisor);
}
$reportarray[$dashboarduser->id]=array("#"=>$i++,"RM"=>$dashboarduser->fullname,"RM Code"=>$dashboarduser->username,"Team Manager"=>$dashboarduser->supervisor);
$alist=$alist->whereIn('user_id',$uidlist);
/*$alist=$alist->where(function ($query) use($roclientstr,$uidlist,$didlinesstr){
$query->orWhereIn('client',$roclientstr)
->orWhereIn('did',$didlinesstr);
});*/
$userlog=$userlog->whereIn('user_id',$uidlist);
}else{
$allusers=$allusers->get();
foreach($allusers as $tuser)
{
$reportarray[$tuser->id]=array("#"=>$i++,"RM"=>$tuser->telecaller,"RM Code"=>$tuser->username,"Team Manager"=>$tuser->sepervisor);
}
}
// echo "<pre>"; print_r($allusers);exit;
$alist=$alist->get();
$userlog=$userlog->get();
$prev_close = 0;
// echo count($userlog);exit;
foreach($alist as $aline)
{
if($prev_user != $aline->user_id || $prev_close <= $aline->ts_Wait)
{
$userid=$aline->user_id;
$talktime=$aline->talkSec+$aline->recstartSec+$aline->recendSec;
$totaltime=$aline->callSec+$talktime+$aline->dispoSec;
$reportarray[$userid]["oncall"]+=$totaltime/1000;
// $reportarray[$userid]["Wait"]+=$aline->waitSec/1000;
$reportarray[$userid]["Call"]+=$aline->callSec/1000;
$reportarray[$userid]["Talk"]+=$talktime/1000;
$reportarray[$userid]["Dispo"]+=$aline->dispoSec/1000;
if($aline->type == 'Progressive')
{
$reportarray[$userid]["P-Call"]+=$aline->callSec/1000;
$reportarray[$userid]["P-Talk"]+=$talktime/1000;
$reportarray[$userid]["P-Dispo"]+=$aline->dispoSec/1000;
$reportarray[$userid]["ProgressiveTotal"]+=($aline->callSec/1000)+($talktime/1000)+($aline->dispoSec/1000);
}
if($aline->type == 'Manual')
{
$reportarray[$userid]["M-Call"]+=$aline->callSec/1000;
$reportarray[$userid]["M-Talk"]+=$talktime/1000;
$reportarray[$userid]["M-Dispo"]+=$aline->dispoSec/1000;
$reportarray[$userid]["ManualTotal"]+=($aline->callSec/1000)+($talktime/1000)+($aline->dispoSec/1000);
}
if($aline->type == 'Inbound')
{
$reportarray[$userid]["I-Call"]+=$aline->callSec/1000;
$reportarray[$userid]["I-Talk"]+=$talktime/1000;
$reportarray[$userid]["I-Dispo"]+=$aline->dispoSec/1000;
$reportarray[$userid]["IncomingTotal"]+=($aline->callSec/1000)+($talktime/1000)+($aline->dispoSec/1000);
}
}
$reportarray[$userid]["CallCount"]++;
$prev_close = $aline->ts_Close;//-ts_Wait
$prev_user = $aline->user_id;//-ts_Wait
}
function cmp($a, $b) {
return $a["ts"] - $b["ts"];
}
$userLogin=array();
foreach($userlog as $ulog)
{
$data=json_decode($ulog->data,true);
usort($data, "cmp");
$lastSip = end($data);
$starttime = strtotime($ulog->startdate.' '.$ulog->starttime);
//echo "starttime:".$starttime;
$endtime = round($lastSip['ts']/1000);
//console.log($endtime);
//echo "End time:".$endtime;
$userLogin[$ulog->user_id]['duration'] += ($endtime-$starttime);
//echo "Userlog:".$userLogin[$ulog->user_id]['duration'];
$userLogin[$ulog->user_id]['start'][] = $starttime;
$userLogin[$ulog->user_id]['end'][] = $endtime;
$prets=strtotime($ulog->startdate." ".$ulog->starttime)*1000;
$previous="Paused-Paused";
foreach($data as $sdata)
{
$pts=$sdata['ts'];
if(isset($sdata['states']))
{
foreach($sdata['states'] as $ts=>$states)
{
if($previous != "Paused-WRAPUP")$previous = str_replace('Paused-', '', $previous);
if(!in_array($previous,$reporthead) && !in_array($previous,array('Progressive-','Manual-','Ready-Incoming','Ready-Predictive','DialNext-','Paused-WRAPUP'))) {
$previous = 'Paused';
}
$reportarray[$ulog->user_id][$previous]+=round($ts-$prets,2)/1000;
$prets=$ts;
$previous=$states[0].'-'.$states[1];
}
if($previous != "Paused-WRAPUP")$previous = str_replace('Paused-', '', $previous);
$reportarray[$ulog->user_id][$previous]+=round($pts-$prets,2)/1000;
$prets=$pts;
}
}
}
if(count($userLogin)) foreach ($userLogin as $userid => $value)
{
$break_time=0;
foreach ($breaks as $break) {
$break_time+=$reportarray[$userid][$break];
$reportarray[$userid]["PausedTotal"]+=$reportarray[$userid][$break];
}
$sessionsStr = "";
for($i = 0; $i < count($value['start']); $i++){
if($sessionsStr == ""){
$sessionsStr .= date("Y-m-d H:i:s", $value['start'][$i]-$timeoffset)." - ".date("Y-m-d H:i:s", $value['end'][$i]-$timeoffset);
}else{
$sessionsStr .= ",\n".date("Y-m-d H:i:s", $value['start'][$i]-$timeoffset)." - ".date("Y-m-d H:i:s", $value['end'][$i]-$timeoffset);
}
}
$reportarray[$userid]["Sessions"]=$sessionsStr;
// $reportarray[$userid]["Signin"]=date("Y-m-d H:i:s", min($value['start'])-$timeoffset);
// $reportarray[$userid]["Signout"]=date("Y-m-d H:i:s", max($value['end'])-$timeoffset);
$reportarray[$userid]["TOS"]=$value['duration'];
$reportarray[$userid]["Net Total"]=$value['duration']-$break_time;
$reportarray[$userid]["Wait"]=$reportarray[$userid]["Net Total"]-$reportarray[$userid]['oncall'];
if($reportarray[$userid]["Wait"] < 0){
$reportarray[$userid]["Net Total"] += abs($reportarray[$userid]["Wait"]);
$reportarray[$userid]["TOS"] += abs($reportarray[$userid]["Wait"]);
$reportarray[$userid]["Wait"] = 0;
}
}
$highestColumn = sizeof($reporthead);
if(count($reportarray)) {
$outhead="<tr>";$outstr="";
for ($head = 0; $head < $highestColumn; $head++){
if($reporthead[$head] == "Sessions"){
$outhead.="<td style='width:270px;display:block;'>".$reporthead[$head]."</td>";
}elseif($reporthead[$head] == "PausedTotal" || $reporthead[$head] == "ProgressiveTotal" || $reporthead[$head] == "ManualTotal" || $reporthead[$head] == "IncomingTotal"){
$outhead.="<td class='warning'>".$reporthead[$head]."</td>";
}elseif($reporthead[$head] == "Paused"){
$outhead.="<td>ManualPaused</td>";
}else{
$outhead.="<td>".$reporthead[$head]."</td>";
}
}
$outhead.="</tr>";
$utotalarr = array("RM"=>'Net Total');
$reportRowNo = 1;
foreach($reportarray as $uid=>$uarr)
{
if(array_key_exists('TOS',$uarr) && array_key_exists('RM Code',$uarr))
{
$outstr.="<tr>";
for ($head = 0; $head < $highestColumn; $head++){
if($head < 1){
$data_str = $reportRowNo; $reportRowNo++;
}elseif($head < 5) {
// if($head < 6) {
$data_str = $uarr[$reporthead[$head]];
}
elseif($head < 6) {
$data_str = $uarr[$reporthead[$head]];
$utotalarr[$reporthead[$head]] += $uarr[$reporthead[$head]];
}
else {
$data_str = secToDuration(round($uarr[$reporthead[$head]]));
$utotalarr[$reporthead[$head]] += $uarr[$reporthead[$head]];
}
if($head == 12 || $head == 16 || $head == 20 || $head == 24){
$outstr.="<td class='warning'>".$data_str."</td>";
}else{
$outstr.="<td>".$data_str."</td>";
}
}
$outstr.="</tr>";
}
}
$outstr.="<tr>";
for ($head = 0; $head < $highestColumn; $head++)
{
if($head < 6) {
$data_str = $utotalarr[$reporthead[$head]];
}
else {
$data_str = secToDuration($utotalarr[$reporthead[$head]]);
}
if($head == 12 || $head == 16 || $head == 20 || $head == 24){
$outstr.="<td class='warning'>".$data_str."</td>";
}else{
$outstr.="<td>".$data_str."</td>";
}
}
$outstr.="</tr>";
} else {
$outhead.="<tr><td>No Records Found.</td></tr>";
}
if(Input::has("dllogxls"))
{
include_once(app_path().'/lib/phpexcel/PHPExcel.php');
$inputFileType = "Excel5";
$objReader = PHPExcel_IOFactory::createReader($inputFileType);
$objPHPExcel = $objReader->load("assets/extras/blank.xls");
$baseRow = 2;
$highestColumn = sizeof($reporthead);
for ($head = 0; $head < $highestColumn; $head++){
$colstr=PHPExcel_Cell::stringFromColumnIndex($head);
$objPHPExcel->getActiveSheet()->setCellValue($colstr."1", $reporthead[$head]);
}
foreach($reportarray as $uid=>$uarr)
{
if(array_key_exists('TOS',$uarr) && array_key_exists('RM Code',$uarr))
{
$row = $baseRow++;
$col = 0;
for ($head = 0; $head < $highestColumn; $head++){
$excelval = ($head < 6) ? $uarr[$reporthead[$head]] : secToDuration(round($uarr[$reporthead[$head]]));
$colstr=PHPExcel_Cell::stringFromColumnIndex($head);
$objPHPExcel->getActiveSheet()->setCellValue($colstr.$row, $excelval);
}
$row++;
}
}
//$row++;
for ($head = 0; $head < $highestColumn; $head++){
$excelval = ($head < 6) ? $utotalarr[$reporthead[$head]] : secToDuration(round($utotalarr[$reporthead[$head]]));
$colstr=PHPExcel_Cell::stringFromColumnIndex($head);
$objPHPExcel->getActiveSheet()->setCellValue($colstr.$row, $excelval);
}
header('Content-Type: application/vnd.ms-excel');
header('Content-Disposition: attachment;filename="AgentTime.xls"');
header('Cache-Control: max-age=0');
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, $inputFileType);
$objWriter->save('php://output');
return ;
}
function secToDuration($sec) {
return sprintf("%02d%s%02d%s%02d", floor($sec/3600), ':', ($sec/60)%60, ':', $sec%60);
}
?>
<style>#logtable.td{vertical-align:top;padding:20px;}#logtable.tr{height:28px;overflow-y:hidden;}
/*#logtable.table thead tr{
display:block;
}
#logtable.table tbody{
display:block;
height:500px;
overflow:auto;//set tbody to auto
}*/
</style>
<div class=innerAll>
<h4 style="float:left;width:50%;margin:10px 0;">Login Report <small>(Agent Time Report)</small></h4>
<div style="float:right;width:50%">
<?php if(Auth::user()->username=='admin'){ ?>
<button class="pull-right btn btn-sm btn-default" onclick='dlAgentlogXls();return false;' title='Download'><i class='fa fa-download'></i> Download</button>
<?php } ?>
</div>
<div style="clear:both"></div>
<hr style="margin-bottom: 5px;">
<div>
Search <input id=filter name="filter" type="text" style="border:1px solid #efefef; padding: 2px 10px;">&nbsp;&nbsp;
Date: From <input size=10 id='modfrom' name='modfrom' type='text' value='<?php echo date("Y-m-d",$logdate); ?>' onchange='statusLogReloadFun("");' />
<select id="modtime" style="border:1px solid #efefef;" onchange='statusLogReloadFun("");'>
<?php
foreach (range(0,23) as $hour) {
$selected = ($hour == $logtime) ? "selected" : "";
echo "<option value='$hour' $selected>".str_pad($hour, 2, "0", STR_PAD_LEFT) . ":00</option>";
}
?>
</select>
To <input size=10 id='modto' name='modto' type='text' value='<?php echo date("Y-m-d",$logdateto); ?>' onchange='statusLogReloadFun("");' />
<select id="modtimeto" style="border:1px solid #efefef;" onchange='statusLogReloadFun("");'>
<?php
foreach (range(0,23) as $hour) {
$selected = ($hour == $logtimeto) ? "selected" : "";
echo "<option value='$hour' $selected>".str_pad($hour, 2, "0", STR_PAD_LEFT) . ":00</option>";
}
?></select>&nbsp;&nbsp;
Campaign
<select id="campaign" style="border:1px solid #efefef;" onchange='statusLogReloadFun("");'>
<?php foreach($oclientlst as $c){$s="";if($c==$campaign)$s='selected';echo "<option value='$c' $s>$c</option>";} ?>
</select>
</div>
<div style="clear:both"></div>
<hr style="margin:5px;">
<div style="overflow: auto; margin-top: 10px;">
<table id=logtable class='footable table table-striped table-bordered table-white table-primary footable-loaded' style='font-size:12px; margin:0; border:1px solid #BBB;'>
<thead><?php echo $outhead; ?></thead>
<tbody id="logTableData"><?php echo $outstr; ?></tbody>
</table>
</div>
<div id=dialoglog></div>
</div>
<script>
$(document).ready(function() {
if(!$('#dialoglog').hasClass('ui-dialog-content'))
{
$('#dialoglog').dialog({
autoOpen: false,
width: '70%',
buttons: {
"Ok": function() {
$(this).dialog("close");
},
"Cancel": function() {
$(this).dialog("close");
}
}
});
}
waitKeyUpRun("filter",function() { filter2(document.getElementById('filter'), 'logTableData') },"2000");
$('#modfrom').datepicker({dateFormat: 'yy-mm-dd',inline: true,changeYear: true,selectOtherMonths: true,yearRange: '<?php echo (date('Y')-70).":".(date('Y')+5); ?>'});
$('#modto').datepicker({dateFormat: 'yy-mm-dd',inline: true,changeYear: true,selectOtherMonths: true,yearRange: '<?php echo (date('Y')-70).":".(date('Y')+5); ?>'});
});
function dataString()
{
return 'logdate='+$("#modfrom").val()+'&logtime='+$("#modtime").val()+'&logdateto='+$("#modto").val()+'&logtimeto='+$("#modtimeto").val()+'&campaign='+$("#campaign").val();
}
function statusLogReloadFun(sortby)
{
var sortstr='';if(sortby!="")sortstr="&sort="+sortby
var searchStr = dataString();
doAjax('dialer/agenttime?'+searchStr+sortstr,'','rightmainreportdiv','ajax_dialer_reports','singlethis','GET');
}
function dlAgentlogXls()
{
var searchStr = dataString();
window.open('dialer/agenttime?dllogxls=1&'+searchStr);
return false;
}
</script>
<?php
use App\Models\CRMCall;
use App\Models\CRMCallArchive;
use App\Models\User;
use App\Models\UserLog;
use App\Jobs\KHRMSLib;
$wakka = new KHRMSLib();
$dashboarduser=Auth::user();
$timeoffset = $dashboarduser->timezone; //-330; //$dashboarduser->timezone;
$timeoffset = $timeoffset*60;
$logtime =(isset($_GET['logtime'])) ? $_GET['logtime'] :9;
$logtimeto =(isset($_GET['logtimeto']))? $_GET['logtimeto']:20;
$logdate =(isset($_GET['logdate'])) ? strtotime($_GET['logdate']." ".$logtime.":00:00")
: strtotime(date("Y-m-d")." 09:00:00");
$logdateto =(isset($_GET['logdateto']))? strtotime($_GET['logdateto']." ".$logtimeto.":00:00")
: strtotime(date("Y-m-d")." 20:00:00");
$campaign =(isset($_GET['campaign'])) ? $_GET['campaign'] : "All";
// testing input
//$logtime = 9;$logtimeto = 20;$logdate = strtotime("2017-10-26 ".$logtime.":00:00");$logdateto = strtotime("2017-10-26 ".$logtimeto.":00:00");$campaign = 'All';
// testing input
$alist=CRMCallArchive::where('user_id','!=',0)->where('created_at','>=',date("Y-m-d H:i:s",$logdate+$timeoffset))->where('created_at','<=',date("Y-m-d H:i:s",$logdateto+$timeoffset));
$alist->orderBy('user_id', 'ASC')->orderBy('ts_Close', 'ASC');
$userlog=UserLog::where('created_at','>=',date("Y-m-d H:i:s",$logdate+$timeoffset))->where('created_at','<=',date("Y-m-d H:i:s",$logdateto+$timeoffset));
if($campaign != 'All') $alist->where('client','=',$campaign);
$userarr=array();
$allusers = DB::table('users as u1')->leftjoin('users AS u2', 'u2.username', '=', 'u1.supervisor')
->select('u1.id','u1.username','u1.fullname AS telecaller', 'u2.fullname AS sepervisor')
->where('u1.status','=','Active');
$roclientstr=array();$didlinesstr=array();
if($dashboarduser->exten!="")$didlinesstr[]=$dashboarduser->exten;
$oclientlst=$wakka->clientsReadAccess(); sort($oclientlst); $oclientlst[0] = 'All';
if(!empty($oclientlst))foreach($oclientlst as $tclnt)if($tclnt!="")
{
$roclientstr[]="$tclnt";
$mastersdata=$wakka->getCompanyMaster($tclnt);
if(!empty($mastersdata["DialerDID"]))$didlinesstr[]=$mastersdata["DialerDID"];
}
$breaks=array("Paused","AgentBriefing","TeamMeeting","QualityFeedback","LunchBreak","TeaBreak","UtilityBreak","FloorAnnouncements","DownTime");
$reporthead=array_merge(array("#","RM","RM Code","Team Manager","Sessions","CallCount","TOS","Net Total","Wait","Call","Talk","Dispo","ProgressiveTotal","P-Call","P-Talk","P-Dispo","ManualTotal","M-Call","M-Talk","M-Dispo","IncomingTotal","I-Call","I-Talk","I-Dispo","PausedTotal"),$breaks);
$reportarray=array();
$i=1;
if($dashboarduser->usertype != 'Admin')
{
$uidlist=array($dashboarduser->id);
$allusers=$allusers->where(function ($query) use($dashboarduser) {
$query->where('u1.supervisor','=',$dashboarduser->username)
->orWhere('u1.lteam2','=',$dashboarduser->username)
->orWhere('u1.lteam','=',$dashboarduser->username);
})->get();
foreach($allusers as $tuser)
{
$uidlist[]=$tuser->id;
$reportarray[$tuser->id]=array("#"=>$i++,"RM"=>$tuser->telecaller,"RM Code"=>$tuser->username,"Team Manager"=>$tuser->sepervisor);
}
$reportarray[$dashboarduser->id]=array("#"=>$i++,"RM"=>$dashboarduser->fullname,"RM Code"=>$dashboarduser->username,"Team Manager"=>$dashboarduser->supervisor);
$alist=$alist->whereIn('user_id',$uidlist);
/*$alist=$alist->where(function ($query) use($roclientstr,$uidlist,$didlinesstr){
$query->orWhereIn('client',$roclientstr)
->orWhereIn('did',$didlinesstr);
});*/
$userlog=$userlog->whereIn('user_id',$uidlist);
}else{
$allusers=$allusers->get();
foreach($allusers as $tuser)
{
$reportarray[$tuser->id]=array("#"=>$i++,"RM"=>$tuser->telecaller,"RM Code"=>$tuser->username,"Team Manager"=>$tuser->sepervisor);
}
}
// echo "<pre>"; print_r($allusers);exit;
$alist=$alist->get();
$userlog=$userlog->get();
$prev_close = 0;
// echo count($userlog);exit;
$userLogin=array();
$startdatearry=array();
foreach ($userlog as $ulogstartdate) {
array_push($startdatearry,$ulogstartdate->startdate);
}
$countlogindays=count(array_unique($startdatearry));
foreach($userlog as $ulog)
{
$data=json_decode($ulog->data,true);
usort($data, "cmp");
$lastSip = end($data);
$starttime = strtotime($ulog->startdate.' '.$ulog->starttime);
$endtime = round($lastSip['ts']/1000);
$userLogin[$ulog->user_id]['duration'] += ($endtime-$starttime);
$userLogin[$ulog->user_id]['start'][] = $starttime;
$userLogin[$ulog->user_id]['end'][] = $endtime;
$prets=strtotime($ulog->startdate." ".$ulog->starttime)*1000;
$previous="Paused-Paused";
foreach($data as $sdata)
{
$pts=$sdata['ts'];
if(isset($sdata['states']))
{
foreach($sdata['states'] as $ts=>$states)
{
if($previous != "Paused-WRAPUP")$previous = str_replace('Paused-', '', $previous);
if(!in_array($previous,$reporthead) && !in_array($previous,array('Progressive-','Manual-','Ready-Incoming','Ready-Predictive','DialNext-','Paused-WRAPUP'))) {
$previous = 'Paused';
}
$reportarray[$ulog->user_id][$previous]+=round($ts-$prets,2)/1000;
$prets=$ts;
$previous=$states[0].'-'.$states[1];
}
if($previous != "Paused-WRAPUP")$previous = str_replace('Paused-', '', $previous);
$reportarray[$ulog->user_id][$previous]+=round($pts-$prets,2)/1000;
$prets=$pts;
}
}
}
foreach($alist as $aline)
{
if($prev_user != $aline->user_id || $prev_close <= $aline->ts_Wait)
{
$userid=$aline->user_id;
$talktime=$aline->talkSec+$aline->recstartSec+$aline->recendSec;
$totaltime=$aline->callSec+$talktime+$aline->dispoSec;
$reportarray[$userid]["oncall"]+=($totaltime/1000)/$countlogindays;
// $reportarray[$userid]["Wait"]+=$aline->waitSec/1000;
$reportarray[$userid]["Call"]+=($aline->callSec/1000)/$countlogindays;
$reportarray[$userid]["Talk"]+=($talktime/1000)/$countlogindays;
$reportarray[$userid]["Dispo"]+=($aline->dispoSec/1000)/$countlogindays;
if($aline->type == 'Progressive')
{
$reportarray[$userid]["P-Call"]+=($aline->callSec/1000)/$countlogindays;
$reportarray[$userid]["P-Talk"]+=($talktime/1000)/$countlogindays;
$reportarray[$userid]["P-Dispo"]+=($aline->dispoSec/1000)/$countlogindays;
$reportarray[$userid]["ProgressiveTotal"]+=(($aline->callSec/1000)+($talktime/1000)+($aline->dispoSec/1000))/$countlogindays;
}
if($aline->type == 'Manual')
{
$reportarray[$userid]["M-Call"]+=($aline->callSec/1000)/$countlogindays;
$reportarray[$userid]["M-Talk"]+=($talktime/1000)/$countlogindays;
$reportarray[$userid]["M-Dispo"]+=($aline->dispoSec/1000)/$countlogindays;
$reportarray[$userid]["ManualTotal"]+=(($aline->callSec/1000)+($talktime/1000)+($aline->dispoSec/1000))/$countlogindays;
}
if($aline->type == 'Inbound')
{
$reportarray[$userid]["I-Call"]+=($aline->callSec/1000)/$countlogindays;
$reportarray[$userid]["I-Talk"]+=($talktime/1000)/$countlogindays;
$reportarray[$userid]["I-Dispo"]+=($aline->dispoSec/1000)/$countlogindays;
$reportarray[$userid]["IncomingTotal"]+=(($aline->callSec/1000)+($talktime/1000)+($aline->dispoSec/1000))/$countlogindays;
}
}
$reportarray[$userid]["CallCount"]++;
$prev_close = $aline->ts_Close;//-ts_Wait
$prev_user = $aline->user_id;//-ts_Wait
}
function cmp($a, $b) {
return $a["ts"] - $b["ts"];
}
if(count($userLogin)) foreach ($userLogin as $userid => $value)
{
$break_time=0;
foreach ($breaks as $break) {
$break_time+=$reportarray[$userid][$break];
$reportarray[$userid]["PausedTotal"]+=$reportarray[$userid][$break];
}
$sessionsStr = "";
for($i = 0; $i < count($value['start']); $i++){
if($sessionsStr == ""){
$sessionsStr .= date("Y-m-d H:i:s", $value['start'][$i]-$timeoffset)." - ".date("Y-m-d H:i:s", $value['end'][$i]-$timeoffset);
}else{
$sessionsStr .= ",\n".date("Y-m-d H:i:s", $value['start'][$i]-$timeoffset)." - ".date("Y-m-d H:i:s", $value['end'][$i]-$timeoffset);
}
}
$reportarray[$userid]["Sessions"]=$sessionsStr;
// $reportarray[$userid]["Signin"]=date("Y-m-d H:i:s", min($value['start'])-$timeoffset);
// $reportarray[$userid]["Signout"]=date("Y-m-d H:i:s", max($value['end'])-$timeoffset);
$reportarray[$userid]["TOS"]=$value['duration']/$countlogindays;
$reportarray[$userid]["Net Total"]=($value['duration']-$break_time)/$countlogindays;
$reportarray[$userid]["Wait"]=($reportarray[$userid]["Net Total"]-$reportarray[$userid]['oncall']);
if($reportarray[$userid]["Wait"] < 0){
$reportarray[$userid]["Net Total"] += abs($reportarray[$userid]["Wait"]);
$reportarray[$userid]["TOS"] += abs($reportarray[$userid]["Wait"]);
$reportarray[$userid]["Wait"] = 0;
}
}
$highestColumn = sizeof($reporthead);
if(count($reportarray)) {
$outhead="<tr>";$outstr="";
for ($head = 0; $head < $highestColumn; $head++){
if($reporthead[$head] == "Sessions"){
$outhead.="<td style='width:270px;display:block;'>".$reporthead[$head]."</td>";
}elseif($reporthead[$head] == "PausedTotal" || $reporthead[$head] == "ProgressiveTotal" || $reporthead[$head] == "ManualTotal" || $reporthead[$head] == "IncomingTotal"){
$outhead.="<td class='warning'>".$reporthead[$head]."</td>";
}elseif($reporthead[$head] == "Paused"){
$outhead.="<td>ManualPaused</td>";
}else{
$outhead.="<td>".$reporthead[$head]."</td>";
}
}
$outhead.="</tr>";
$utotalarr = array("RM"=>'Net Total');
$reportRowNo = 1;
foreach($reportarray as $uid=>$uarr)
{
if(array_key_exists('TOS',$uarr) && array_key_exists('RM Code',$uarr))
{
$outstr.="<tr>";
for ($head = 0; $head < $highestColumn; $head++){
if($head < 1){
$data_str = $reportRowNo; $reportRowNo++;
}elseif($head < 5) {
// if($head < 6) {
$data_str = $uarr[$reporthead[$head]];
}
elseif($head < 6) {
$data_str = $uarr[$reporthead[$head]];
$utotalarr[$reporthead[$head]] += $uarr[$reporthead[$head]];
}
else {
$data_str = secToDuration(round($uarr[$reporthead[$head]]));
$utotalarr[$reporthead[$head]] += $uarr[$reporthead[$head]];
}
if($head == 12 || $head == 16 || $head == 20 || $head == 24){
$outstr.="<td class='warning'>".$data_str."</td>";
}else{
$outstr.="<td>".$data_str."</td>";
}
}
$outstr.="</tr>";
}
}
$outstr.="<tr>";
for ($head = 0; $head < $highestColumn; $head++)
{
if($head < 6) {
$data_str = $utotalarr[$reporthead[$head]];
}
else {
$data_str = secToDuration($utotalarr[$reporthead[$head]]);
}
if($head == 12 || $head == 16 || $head == 20 || $head == 24){
$outstr.="<td class='warning'>".$data_str."</td>";
}else{
$outstr.="<td>".$data_str."</td>";
}
}
$outstr.="</tr>";
} else {
$outhead.="<tr><td>No Records Found.</td></tr>";
}
if(Input::has("dllogxls"))
{
include_once(app_path().'/lib/phpexcel/PHPExcel.php');
$inputFileType = "Excel5";
$objReader = PHPExcel_IOFactory::createReader($inputFileType);
$objPHPExcel = $objReader->load("assets/extras/blank.xls");
$baseRow = 2;
$highestColumn = sizeof($reporthead);
for ($head = 0; $head < $highestColumn; $head++){
$colstr=PHPExcel_Cell::stringFromColumnIndex($head);
$objPHPExcel->getActiveSheet()->setCellValue($colstr."1", $reporthead[$head]);
}
foreach($reportarray as $uid=>$uarr)
{
$row = $baseRow++;
$col = 0;
for ($head = 0; $head < $highestColumn; $head++){
$excelval = ($head < 6) ? $uarr[$reporthead[$head]] : secToDuration(round($uarr[$reporthead[$head]]));
$colstr=PHPExcel_Cell::stringFromColumnIndex($head);
$objPHPExcel->getActiveSheet()->setCellValue($colstr.$row, $excelval);
}
}
$row++;
for ($head = 0; $head < $highestColumn; $head++){
$excelval = ($head < 6) ? $utotalarr[$reporthead[$head]] : secToDuration(round($utotalarr[$reporthead[$head]]));
$colstr=PHPExcel_Cell::stringFromColumnIndex($head);
$objPHPExcel->getActiveSheet()->setCellValue($colstr.$row, $excelval);
}
header('Content-Type: application/vnd.ms-excel');
header('Content-Disposition: attachment;filename="AgentTime.xls"');
header('Cache-Control: max-age=0');
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, $inputFileType);
$objWriter->save('php://output');
return ;
}
function secToDuration($sec) {
return sprintf("%02d%s%02d%s%02d", floor($sec/3600), ':', ($sec/60)%60, ':', $sec%60);
}
?>
<style>#logtable.td{vertical-align:top;padding:20px;}#logtable.tr{height:28px;overflow-y:hidden;}
/*#logtable.table thead tr{
display:block;
}
#logtable.table tbody{
display:block;
height:500px;
overflow:auto;//set tbody to auto
}*/
</style>
<div class=innerAll>
<h4 style="float:left;width:50%;margin:10px 0;">Login Report <small>(Agent Time Average Report)</small></h4>
<div style="float:right;width:50%">
<!-- <button class="pull-right btn btn-sm btn-default" onclick='dlAgentlogXls();return false;' title='Download'><i class='fa fa-download'></i> Download</button> -->
</div>
<div style="clear:both"></div>
<hr style="margin-bottom: 5px;">
<div>
Search <input id=filter name="filter" type="text" style="border:1px solid #efefef; padding: 2px 10px;">&nbsp;&nbsp;
Date: From <input size=10 id='modfrom' name='modfrom' type='text' value='<?php echo date("Y-m-d",$logdate); ?>' onchange='statusLogReloadFun("");' />
<select id="modtime" style="border:1px solid #efefef;" onchange='statusLogReloadFun("");'>
<?php
foreach (range(0,23) as $hour) {
$selected = ($hour == $logtime) ? "selected" : "";
echo "<option value='$hour' $selected>".str_pad($hour, 2, "0", STR_PAD_LEFT) . ":00</option>";
}
?>
</select>
To <input size=10 id='modto' name='modto' type='text' value='<?php echo date("Y-m-d",$logdateto); ?>' onchange='statusLogReloadFun("");' />
<select id="modtimeto" style="border:1px solid #efefef;" onchange='statusLogReloadFun("");'>
<?php
foreach (range(0,23) as $hour) {
$selected = ($hour == $logtimeto) ? "selected" : "";
echo "<option value='$hour' $selected>".str_pad($hour, 2, "0", STR_PAD_LEFT) . ":00</option>";
}
?></select>&nbsp;&nbsp;
Campaign
<select id="campaign" style="border:1px solid #efefef;" onchange='statusLogReloadFun("");'>
<?php foreach($oclientlst as $c){$s="";if($c==$campaign)$s='selected';echo "<option value='$c' $s>$c</option>";} ?>
</select>
</div>
<div style="clear:both"></div>
<hr style="margin:5px;">
<div style="overflow: auto; margin-top: 10px;">
<table id=logtable class='footable table table-striped table-bordered table-white table-primary footable-loaded' style='font-size:12px; margin:0; border:1px solid #BBB;'>
<thead><?php echo $outhead; ?></thead>
<tbody id="logTableData"><?php echo $outstr; ?></tbody>
</table>
</div>
<div id=dialoglog></div>
</div>
<script>
$(document).ready(function() {
if(!$('#dialoglog').hasClass('ui-dialog-content'))
{
$('#dialoglog').dialog({
autoOpen: false,
width: '70%',
buttons: {
"Ok": function() {
$(this).dialog("close");
},
"Cancel": function() {
$(this).dialog("close");
}
}
});
}
waitKeyUpRun("filter",function() { filter2(document.getElementById('filter'), 'logTableData') },"2000");
$('#modfrom').datepicker({dateFormat: 'yy-mm-dd',inline: true,changeYear: true,selectOtherMonths: true,yearRange: '<?php echo (date('Y')-70).":".(date('Y')+5); ?>'});
$('#modto').datepicker({dateFormat: 'yy-mm-dd',inline: true,changeYear: true,selectOtherMonths: true,yearRange: '<?php echo (date('Y')-70).":".(date('Y')+5); ?>'});
});
function dataString()
{
return 'logdate='+$("#modfrom").val()+'&logtime='+$("#modtime").val()+'&logdateto='+$("#modto").val()+'&logtimeto='+$("#modtimeto").val()+'&campaign='+$("#campaign").val();
}
function statusLogReloadFun(sortby)
{
var sortstr='';if(sortby!="")sortstr="&sort="+sortby
var searchStr = dataString();
doAjax('dialer/agenttimeAverage?'+searchStr+sortstr,'','rightmainreportdiv','ajax_dialer_reports','singlethis','GET');
}
function dlAgentlogXls()
{
var searchStr = dataString();
window.open('dialer/agenttimeAverage?dllogxls=1&'+searchStr);
return false;
}
</script>
<?php
use App\Models\CRMCall;
use App\Models\Dialline;
use App\Models\Sipid;
use App\Models\User;
use App\Models\UserLog;
use App\Models\Kqueue;
use App\Jobs\KHRMSLib;
$selectedvals=explode(":",Input::get("selectedvals",":::::"));
$hdfcnodes=array();
$offline=array();
$arr=Config::get("app.hdfcnodes");
foreach($arr as $server=>$arrline)
{
$tvals=explode(":",$arrline);
if($selectedvals[0]=="")$hdfcnodes[]=$server;
else if($selectedvals[0]==$tvals[0])
{
if($selectedvals[1]=="")$hdfcnodes[]=$server;
else if($selectedvals[1]==$tvals[1])
{
if($selectedvals[2]=="")$hdfcnodes[]=$server;
else if($selectedvals[2]==$tvals[2])
{
if($selectedvals[3]=="")$hdfcnodes[]=$server;
else if($selectedvals[3]==$tvals[3])
{
if($selectedvals[4]=="")$hdfcnodes[]=$server;
else if($selectedvals[4]==$tvals[4])
{
$hdfcnodes[]=$server;
}
}
}
}
}
}
$wakka = new KHRMSLib();
$dashboarduser=Auth::user();
$nowts=time();
$chart=array('ts'=>date('H:i:s',time()-($dashboarduser->timezone*60)),'Online'=>0,'NoCall'=>0,'InCall'=>0,'CallWait'=>0,'CmdList'=>0);
$alist=array();
$sipidsfound=array();
$userarr=array();$i=1;
$reporthead=array("#","ID","User","Campaign","Station","Status","CRMId","Number","Type","State","Duration");
$reportarray=array();
foreach($hdfcnodes as $ci=>$server)
{
$conn = array(
'driver' => 'mysql',
'host' => $server,
'database' => env('DB_DATABASE', 'kstych_flexydial'),
'username' => env('DB_USERNAME', 'root'),
'password' => env('DB_PASSWORD', ''),
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
'options' => array(
PDO::ATTR_TIMEOUT => 5,
),
);
Config::set("database.connections.conn$ci", $conn);
try
{
DB::connection("conn$ci")->getDatabaseName();
$allusers=User::on("conn$ci")->where("status","=","Active")->get();
foreach($allusers as $tuser)$uidlist[]=$tuser->id;
$newcalls=Dialline::on("conn$ci")->where('status','!=','Free')->where('conf','=','')->orderBy('updated_at')->get();
$acalls=Dialline::on("conn$ci")->where('status','!=','Free')->where('conf','!=','')->orderBy('updated_at')->get();
$sipids=Sipid::on("conn$ci")->whereIn("user",$uidlist)->where("status","=","1")->get();
foreach($newcalls as $newcall)
{
$tcall=CRMCall::on("conn$ci")->where('dialline_id','=',$newcall->id)->orderBy('id','DESC')->first();
$un="";$uid="";$us="";
if($tcall->user_id>0)
{
$tuser=User::on("conn$ci")->find($tcall->user_id);
$un=$tuser->username;
$uid=userchatbox($tuser).$tuser->id;
$userlog=UserLog::on("conn$ci")->where('user_id','=',$tuser->id)->orderBy("id","DESC")->first();
$stend=$userlog->getLastStatus();
$us="$stend[0]-$stend[1]";
$chart['Online']++;
$chart['InCall']++;
}
else $chart['CallWait']++;
$obj=array();
$obj["#"]=$i++;
$obj["ID"]=$uid;
$obj["User"]=$un;
$obj["Campaign"]=$tcall->client;
$obj["Station"]=$tcall->sipid_id.userSpyStr($tcall->sipid_id);
$obj["Status"]=$us;
$obj["CRMId"]=$tcall->crm_id;
$obj["Number"]=$tcall->number;
$obj["Type"]=$tcall->type;
$obj["State"]=$tcall->state;
$obj["Duration"]=$nowts-strtotime($tcall->created_at);
$reportarray[$newcall->id]=$obj;
if(!empty($tcall->sipid_id))$sipidsfound[]=$tcall->sipid_id;
}
foreach($acalls as $acall)
{
$tcall=CRMCall::on("conn$ci")->where('dialline_id','=',$acall->id)->orderBy('id','DESC')->first();
$tsipid=substr($acall->conf,4);
$tsip=Sipid::on("conn$ci")->find($tsipid);
$clidata=json_decode($tsip->clients,true);
$tuser=User::on("conn$ci")->find($tsip->user);
$userlog=UserLog::on("conn$ci")->where('user_id','=',$tuser->id)->orderBy("id","DESC")->first();
$stend=$userlog->getLastStatus();
$obj=array();
$obj["#"]=$i++;
$obj["ID"]=userchatbox($tuser).$tsip->user;
$obj["User"]=$tuser->username;
$obj["Campaign"]=substr($clidata['r'],0,20);
$obj["Station"]=$tsip->id.userSpyStr($tsip->id);
$obj["Status"]="$stend[0]-$stend[1]";
$obj["CRMId"]=$tcall->crm_id;
$obj["Number"]=$tcall->number;
$obj["Type"]=$tcall->type;
$obj["State"]=$tcall->state;
$obj["Duration"]=$nowts-strtotime($tcall->created_at);
$reportarray[$acall->id]=$obj;
$sipidsfound[]=$tsipid;
$chart['Online']++;
$chart['InCall']++;
}
foreach($sipids as $sipid)
{
if(!in_array($sipid->id,$sipidsfound))
{
$clidata=json_decode($sipid->clients,true);
$tuser=User::on("conn$ci")->find($sipid->user);
$userlog=UserLog::on("conn$ci")->where('user_id','=',$tuser->id)->orderBy("id","DESC")->first();
$stend=$userlog->getLastStatus();
$obj=array();
$obj["#"]=$i++;
$obj["ID"]=userchatbox($tuser).$sipid->user;
$obj["User"]=$tuser->username;
$obj["Campaign"]=substr($clidata['r'],0,20);
$obj["Station"]=$sipid->id.userSpyStr($sipid->id);
$obj["Status"]="$stend[0]-$stend[1]";
$obj["CRMId"]="";
$obj["Number"]="";
$obj["Type"]="";
$obj["State"]="";
$obj["Duration"]="";
$reportarray[]=$obj;
$chart['Online']++;
$chart['NoCall']++;
}
}
$chart['CmdList']=-1*Kqueue::on("conn$ci")->count();
}catch(Exception $e)
{
$offline[]=$server;
}
}
if(Input::get('chartvals')==1)
{
echo json_encode($chart);
return;
}
$highestColumn = sizeof($reporthead);
$outhead="<tr>";$outstr="";
for ($head = 0; $head < $highestColumn; $head++){
$outhead.="<td>".$reporthead[$head]."</td>";
}
$outhead.="</tr>";
foreach($reportarray as $uid=>$uarr)
{
$outstr.="<tr>";
for ($head = 0; $head < $highestColumn; $head++){
$outstr.="<td>".$uarr[$reporthead[$head]]."</td>";
}
$outstr.="</tr>";
}
function userchatbox($tuser)
{
}
function userSpyStr($sipid)
{
}
//charts
?>
<div class=innerAll>
<style>#logtable.td{vertical-align:top;}#logtable.tr{height:28px;overflow-y:hidden;}</style>
<script>
$(document).ready(function()
{
if(!$('#dialoglog').hasClass('ui-dialog-content'))
{
$('#dialoglog').dialog({
autoOpen: false,
width: '70%',
buttons: {
"Ok": function() {
$(this).dialog("close");
},
"Cancel": function() {
$(this).dialog("close");
}
}
});
}
});
</script>
<div style="float:left;width:50%">
<h5>Dialer : Live</h5>
</div>
<div style="float:left;width:50%">
<button class="pull-right btn btn-sm btn-default" onclick='liveLogReloadFun(10);return false;' title='Reload' style='margin-top:-8px'><i class='fa fa-refresh'></i> Reload</button>
</div>
<div style="clear:both"></div>
<hr>
<div class=col-md-12>
<div id=liveuserlogschart1{!!$nowts!!} style='min-height:300px;width:100%'></div>
<script>
var livechart001='';
$(function () {
livechart001=$('#liveuserlogschart1{!!$nowts!!}').highcharts({
title: {
text: '',
x: -20 //center
},
subtitle: {
text: '',
x: -20
},
xAxis: {
categories: [<?php $ccc=array();for($c=60;$c>0;$c--){echo "'",date('H:i:s',time()-($c*10)-($dashboarduser->timezone*60))."',";$ccc[]="0";}$ccc="[".implode(",",$ccc)."]"; ?>],
labels:{
enabled:false//default is true
},
},
yAxis: {
title: {
text: ''
},
plotLines: [{
value: 0,
width: 1,
color: '#808080'
}]
},
tooltip: {
valueSuffix: ''
},
legend: {
},
series: [{
name: 'Online',
data: {!!Input::get('Online',$ccc)!!}
}, {
name: 'NoCall',
data: {!!Input::get('NoCall',$ccc)!!}
}, {
name: 'InCall',
data: {!!Input::get('InCall',$ccc)!!}
}, {
name: 'CallWait',
data: {!!Input::get('CallWait',$ccc)!!}
}, {
name: 'CmdList',visible: false,
data: {!!Input::get('CmdList',$ccc)!!}
}]
});
});
function liveLogReloadFun(delay)
{
var tchart=livechart001.highcharts();
var sdata='';
sdata+='&Online='+JSON.stringify(tchart.series[0].yData);
sdata+='&NoCall='+JSON.stringify(tchart.series[1].yData);
sdata+='&InCall='+JSON.stringify(tchart.series[2].yData);
sdata+='&CallWait='+JSON.stringify(tchart.series[3].yData);
sdata+='&CmdList='+JSON.stringify(tchart.series[4].yData);
setTimeout(function(){
if($("#liveuserlogschart1{!!$nowts!!}").length)
doAjax('dialer/aliveusers',sdata+'&selectedvals='+getarvalval(),'rightmainreportdiv','ajax_dialer_reports','singlethis','GET');
},delay);
}
function liveLogReloadChartFun(delay)
{
setTimeout(function(){
if($("#liveuserlogschart1{!!$nowts!!}").length)
doAjax('dialer/aliveusers','chartvals=1'+'&selectedvals='+getarvalval(),'__FD__','ajax_dialer_reports','singlethis','GET',function(res)
{
var resobj=JSON.parse(res.responseText);
var tchart=livechart001.highcharts();
var shift = tchart.series[0].data.length > 60;
// add the point
tchart.series[0].addPoint([resobj['ts'],resobj['Online']], true, shift);
tchart.series[1].addPoint([resobj['ts'],resobj['NoCall']], true, shift);
tchart.series[2].addPoint([resobj['ts'],resobj['InCall']], true, shift);
tchart.series[3].addPoint([resobj['ts'],resobj['CallWait']],true,shift);
tchart.series[4].addPoint([resobj['ts'],resobj['CmdList']],true,shift);
// call it again after one second
setTimeout(liveLogReloadChartFun, 5000);
});
},delay);
}
liveLogReloadChartFun(10);
</script>
</div>
<div style='clear:both'></div>
<div style='clear:both'></div>
<div style='overflow:auto'>
<table id=logtable class='footable table table-striped table-bordered table-white table-primary footable-loaded' style='font-size:12px'>
<thead>
<?php echo $outhead; ?>
</thead>
<?php echo $outstr; ?>
</table>
</div>
<div id=dialoglog></div>
</div>
<!--
<?php
//if($dashboarduser->moduleACL("Admin",false,false,true))print_r(Config::get('app.sqllog'));
foreach($arr as $server=>$arrline)
{
if(in_array($server,$hdfcnodes))echo "$server => $arrline\n";
}
?>
-->
<?php
$dashboarduser=Auth::user();
$timeoffset=$dashboarduser->timezone*60;
?>
<div class="container-fluid">
<div class="layout-app">
<div class="row">
<div class="col-md-12">
<div class="col-separator col-separator-first col-unscrollable box">
<div class="innerAll">
<div>
<h4 id='tcampaign_select' value=<?php if(!empty($client)) echo $client; ?>>Appointment <?php if(!empty($client)) echo ": ".$client; ?></h4></div>
<hr style="margin-bottom: 10px;" />
<table class='table'
<thead>
<tr>
<th></th>
<th></th>
<?php if(empty($client)) echo "<th>Campaign</th>" ?>
<th>Cust_ID</th>
<th>Name</th>
<th>Number</th>
<!-- <th>Type</th>-->
<th>LastCall</th>
<!-- <th>Disposition</th> --->
<th>Appointment Date</th>
<!--- <th>Status</th> --->
<!-- <th>Count</th> -->
<!--<th></th>-->
<!-- <th>DID</th> -->
</tr>
</thead>
<tbody>
<?php
if($count > 0){
foreach ($appointment as $key => $value) { //echo "<pre>";print_r($value);exit;?>
<tr>
<td></td>
<td></td>
<?php if(empty($client)) echo "<td>$value->client</td>" ?>
<td><?php echo $value->cust_id; ?></td>
<td><?php echo $value->customer_name; ?></td>
<td><a href=# class='' onclick='dialerQuickOpen("<?php echo $value->id; ?>","<?php echo $value->mobile; ?>","Manual","",0);return false;'><?php echo $value->mobile; ?></a></td>
<td><?php echo date("Y-m-d H:i:s",strtotime($value->dialer_lastcall)-$timeoffset); ?></td>
<!--<td><?php //echo $value->dialer_status; ?></td>-->
<td><?php echo date("Y-m-d H:i:s",strtotime($value->dialer_appointment)-$timeoffset); ?></td>
<!--<td><?php //echo $value->status; ?></td>-->
</tr>
<?php }
}else{ ?>
<td colspan="9" align="center">No Record Available</td>
<?php } ?>
</table>
<div id="campaignDetailsArea"></div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="layout-app"><!-- row-app -->
<div class="row row-app">
<!-- col -->
<div class="col-md-2 col-sm-3">
<!-- col-separator -->
<div class="col-separator col-separator-first box col-unscrollable">
<!-- col-table -->
<div class="col-table" style='padding-left: 13px;padding-right: 13px;'>
<h4 class="innerAll margin-none border-bottom" style='background: #fff;'>Dialer Reports</h4>
<!-- col-table-row -->
<div class="col-table-row">
<!-- col-app -->
<div class="col-app col-unscrollable">
<!-- col-app -->
<div class="col-app">
<ul class="list-group list-group-1 margin-none borders-none" style='padding-right: 26px;'>
<li class="list-group-item">
<a href="#" onclick="areportsFun('aliveusers');return false"><i class="fa fa-circle-o"></i> Live</a>
</li>
<li class="list-group-item">
<a href="#" onclick="areportsFun('acalllog');return false"><i class="fa fa-circle-o"></i> Call</a>
</li>
<li class="list-group-item">
<a href="#" onclick="areportsFun('aagentreport');return false"><i class="fa fa-circle-o"></i> Login</a>
</li>
<li class="list-group-item">
<a href="#" onclick="areportsFun('acampreport');return false"><i class="fa fa-circle-o"></i> Time</a>
</li>
<li class="list-group-item">
<a href="#" onclick="areportsFun('astatusreport');return false"><i class="fa fa-circle-o"></i> Status</a>
</li>
<li class="list-group-item"></li>
<div class="col-separator-h"></div>
<h5 class="innerAll margin-none border-bottom" style='background: #fff;'>Filters</h5>
<li class="list-group-item">
<select class=form-control id=arval0 onchange='arvalChange(0);'><option value=''></option><option value='COP'>COP</option><option value='Prime'>Prime</option></select>
<select class=form-control id=arval1 onchange='arvalChange(1);'><option value=''></option></select>
<select class=form-control id=arval2 onchange='arvalChange(2);'><option value=''></option></select>
<select class=form-control id=arval3 onchange='arvalChange(3);'><option value=''></option></select>
<select class=form-control id=arval4 onchange='arvalChange(4);'><option value=''></option></select>
</li>
</ul>
</div>
<!-- // END col-app -->
</div>
<!-- // END col-app -->
</div>
<!-- // END col-table-row -->
</div>
<!-- // END col-table -->
</div>
<!-- // END col-separator.box -->
</div>
<!-- // END col -->
<!-- col -->
<div class="col-md-10 col-sm-9" style='border-right:13px solid #eaeaea'>
<!-- col-separator.box -->
<div class="col-separator col-unscrollable box">
<!-- col-table -->
<div class="col-table">
<!-- <h4 class="innerAll margin-none border-bottom">My Sessions</h4> -->
<!-- col-table-row -->
<div class="col-table-row" style='background: #fff;'>
<!-- col-app -->
<div class="col-app col-unscrollable">
<!-- col-app -->
<div class="col-app" style='position:relative'>
<div class="" id=rightmainreportdiv>
</div>
</div>
<!-- // END col-app -->
</div>
<!-- // END col-app.col-unscrollable -->
</div>
<!-- // END col-table-row -->
</div>
<!-- // END col-table -->
</div>
<!-- // END col-separator.box -->
</div>
<!-- // END col -->
</div>
<!-- // END row-app -->
</div>
<script>
function areportsFun(report)
{
doAjax('dialer/'+report,'selectedvals='+getarvalval(),'rightmainreportdiv','ajax_dialer_reports','singlethis','GET');
}
var arvalvalue="::::::";
function arvalChange(x)
{
<?php echo "var arr=JSON.parse('".json_encode(Config::get("app.hdfcnodes"))."');"; ?>
var selectopts=[''];
for(i=4;i>x;i--)updateJSSelect("arval"+i,selectopts);
for (var server in arr)
{
tvals=arr[server].split(":");
if($("#arval"+x).val()==tvals[x])if(jQuery.inArray(tvals[x+1], selectopts)<0)selectopts[selectopts.length]=tvals[x+1];
}
x++;updateJSSelect("arval"+x,selectopts);
}
function getarvalval()
{
arvalvalue="";for(i=0;i<5;i++)arvalvalue+=$("#arval"+i).val()+':';
return arvalvalue;
}
</script>
<?php
use App\Models\CRMCall;
use App\Models\User;
use App\Jobs\KHRMSLib;
$selectedvals=explode(":",Input::get("selectedvals",":::::"));
$hdfcnodes=array();
$offline=array();
$arr=Config::get("app.hdfcnodes");
foreach($arr as $server=>$arrline)
{
$tvals=explode(":",$arrline);
if($selectedvals[0]=="")$hdfcnodes[]=$server;
else if($selectedvals[0]==$tvals[0])
{
if($selectedvals[1]=="")$hdfcnodes[]=$server;
else if($selectedvals[1]==$tvals[1])
{
if($selectedvals[2]=="")$hdfcnodes[]=$server;
else if($selectedvals[2]==$tvals[2])
{
if($selectedvals[3]=="")$hdfcnodes[]=$server;
else if($selectedvals[3]==$tvals[3])
{
if($selectedvals[4]=="")$hdfcnodes[]=$server;
else if($selectedvals[4]==$tvals[4])
{
$hdfcnodes[]=$server;
}
}
}
}
}
}
$wakka = new KHRMSLib();
$dashboarduser=Auth::user();
if(isset($_GET['logdate']))$logdate=strtotime($_GET['logdate']." 00:00:00");
else $logdate=strtotime(date('Y-m-d')." 00:00:00");
$i=1;
$reporthead=array("#","UserId","UserName","Count","Total");
$reportarray=array();
foreach($hdfcnodes as $ci=>$server)
{
$conn = array(
'driver' => 'mysql',
'host' => $server,
'database' => env('DB_DATABASE', 'kstych_flexydial'),
'username' => env('DB_USERNAME', 'root'),
'password' => env('DB_PASSWORD', ''),
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
'options' => array(
PDO::ATTR_TIMEOUT => 5,
),
);
Config::set("database.connections.conn$ci", $conn);
try
{
DB::connection("conn$ci")->getDatabaseName();
$alist=CRMCall::on("conn$ci")->where('created_at','>=',date("Y-m-d H:i:s",$logdate))->where('created_at','<=',date("Y-m-d H:i:s",$logdate+24*60*60));
$alist=$alist->get();
$userarr=array();
foreach($alist as $aline)
{
if(!isset($userarr[$aline->user_id."conn$ci"]))$userarr[$aline->user_id."conn$ci"]=User::on("conn$ci")->find($aline->user_id."conn$ci");
$tuser=$userarr[$aline->user_id."conn$ci"];
if(!isset($reportarray[$aline->user_id."conn$ci"]))$reportarray[$aline->user_id."conn$ci"]=array("#"=>$i++,"UserId"=>$tuser->id,"UserName"=>$tuser->username,"Count"=>0,"Total"=>0,"Wait"=>0,"Call"=>0,"Talk"=>0,"Dispo"=>0);
$talktime=$aline->talkSec+$aline->recstartSec+$aline->recendSec;
$reportarray[$aline->user_id."conn$ci"]["Count"]++;
$reportarray[$aline->user_id."conn$ci"]["Total"]+=round(($aline->waitSec+$aline->callSec+$talktime+$aline->dispoSec)/1000,2);
$ststr=$aline->userstatus."-".$aline->usersubstatus;
if(!in_array($ststr,$reporthead))$reporthead[]=$ststr;
$reportarray[$aline->user_id."conn$ci"][$ststr]++;
}
}catch(Exception $e)
{
$offline[]=$server;
}
}
if(Input::has("dllogxls"))
{
include_once(app_path().'/lib/phpexcel/PHPExcel.php');
$inputFileType = "Excel5";
$objReader = PHPExcel_IOFactory::createReader($inputFileType);
$objPHPExcel = $objReader->load("assets/extras/blank.xls");
$baseRow = 3;
$highestColumn = sizeof($reporthead);
for ($head = 0; $head < $highestColumn; $head++){
$colstr=PHPExcel_Cell::stringFromColumnIndex($head);
$objPHPExcel->getActiveSheet()->setCellValue($colstr."1", $reporthead[$head]);
}
foreach($reportarray as $uid=>$uarr)
{
$row = $baseRow++;
$col = 0;
for ($head = 0; $head < $highestColumn; $head++){
$colstr=PHPExcel_Cell::stringFromColumnIndex($head);
$objPHPExcel->getActiveSheet()->setCellValue($colstr.$row, $uarr[$reporthead[$head]]);
}
}
header('Content-Type: application/vnd.ms-excel');
header('Content-Disposition: attachment;filename="StatusLog.xls"');
header('Cache-Control: max-age=0');
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, $inputFileType);
$objWriter->save('php://output');
return ;
}
$highestColumn = sizeof($reporthead);
$outhead="<tr>";$outstr="";
for ($head = 0; $head < $highestColumn; $head++){
$outhead.="<td>".$reporthead[$head]."</td>";
}
$outhead.="</tr>";
foreach($reportarray as $uid=>$uarr)
{
$outstr.="<tr>";
for ($head = 0; $head < $highestColumn; $head++){
$outstr.="<td>".$uarr[$reporthead[$head]]."</td>";
}
$outstr.="</tr>";
}
//charts
$cat1=array();
$cat1arr=array();
foreach($reportarray as $uid=>$uarr)
{
$cat1[]="'$uarr[UserName]'";
for ($head = 5; $head < $highestColumn; $head++){
if(!isset($cat1arr[$reporthead[$head]]))$cat1arr[$reporthead[$head]]=array();
$cat1arr[$reporthead[$head]][$uarr["#"]]=round($uarr[$reporthead[$head]],1);
if(empty($cat1arr[$reporthead[$head]][$uarr["#"]]))$cat1arr[$reporthead[$head]][$uarr["#"]]=0;
}
}
$cat1arrstr="";
foreach($cat1arr as $name=>$data)
{
$extra="";if($name=="InboundDROP-InboundDROP")$extra=",visible: false";
$cat1arrstr.="{ name: '$name',\ndata : [";
$cat1arrstr.=implode(",",$data);
$cat1arrstr.="] $extra },\n";
}
$cat2=array();
foreach($reportarray as $uid=>$uarr)
{
for ($head = 5; $head < $highestColumn; $head++){
$cat2["'".$reporthead[$head]."'"]+=round($uarr[$reporthead[$head]],1);
}
}
?>
<div class=innerAll>
<style>#logtable.td{vertical-align:top;}#logtable.tr{height:28px;overflow-y:hidden;}</style>
<script>
$(document).ready(function()
{
if(!$('#dialoglog').hasClass('ui-dialog-content'))
{
$('#dialoglog').dialog({
autoOpen: false,
width: '70%',
buttons: {
"Ok": function() {
$(this).dialog("close");
},
"Cancel": function() {
$(this).dialog("close");
}
}
});
}
waitKeyUpRun("filter",function() { filter2(document.getElementById('filter'), 'logtable') },"2000");
$('#modfrom').datepicker({dateFormat: 'yy-mm-dd',inline: true,changeYear: true,selectOtherMonths: true,yearRange: '<?php echo (date('Y')-70).":".(date('Y')+5); ?>'});
});
</script>
<div style="float:left;width:50%">
Search <input id=filter name="filter" type="text">
Date : <input size=10 id='modfrom' name='modfrom' type='text' value='<?php echo date("Y-m-d",$logdate); ?>' onchange='statusLogReloadFun("");' />
</div>
<div style="float:left;width:50%">
<button class="pull-right btn btn-sm btn-default" onclick='dlAgentlogXls();return false;' title='Download' style='margin-top:-8px'><i class='fa fa-download'></i> Download</button>
</div>
<div style="clear:both"></div>
<hr>
<div class=col-md-12>
<div id=userlogschart1 style='min-height:300px;width:100%'></div>
<script>
$(function () {
$('#userlogschart1').highcharts({
chart: {
type: 'column'
},
title: {
text: ''
},
xAxis: {
labels:{
enabled:false//default is true
},
categories: [<?php echo implode(",",$cat1); ?>]
},
yAxis: {
min: 0,
title: {
text: ''
},
stackLabels: {
enabled: false,
// style: {
// fontWeight: '',
// color: (Highcharts.theme && Highcharts.theme.textColor) || 'gray'
// }
}
},
// legend: {
// align: 'right',
// x: -30,
// verticalAlign: 'top',
// y: 25,
// floating: true,
// backgroundColor: (Highcharts.theme && Highcharts.theme.background2) || 'white',
// borderColor: '#CCC',
// borderWidth: 1,
// shadow: false
// },
tooltip: {
headerFormat: '<b>{point.x}</b><br/>',
pointFormat: '{series.name}: {point.y}<br/>Total: {point.stackTotal}'
},
plotOptions: {
column: {
stacking: 'normal',
dataLabels: {
enabled: false,
// color: (Highcharts.theme && Highcharts.theme.dataLabelsColor) || 'white',
// style: {
// textShadow: '0 0 3px black'
// }
}
}
},
series: [<?php echo $cat1arrstr; ?>]
});
});
function statusLogReloadFun(sortby)
{
var sortstr='';if(sortby!="")sortstr="&sort="+sortby
doAjax('dialer/astatusreport?logdate='+$("#modfrom").val()+sortstr+'&selectedvals='+getarvalval(),'','rightmainreportdiv','ajax_dialer_reports','singlethis','GET');
}
function dlAgentlogXls()
{
window.open('dialer/astatusreport?dllogxls=1&logdate='+$("#modfrom").val()+'&selectedvals='+getarvalval());return false;
}
</script>
</div>
<div style='clear:both'></div>
<div class=col-md-12>
<div id=userlogschart2 style='min-height:300px;width:100%'></div>
<script>
$(function () {
$('#userlogschart2').highcharts({
chart: {
type: 'column'
},
title: {
text: ''
},
subtitle: {
text: ''
},
xAxis: {
categories: [<?php echo implode(",",array_keys($cat2)); ?>],
crosshair: true,
labels:{
enabled:false//default is true
},
},
yAxis: {
min: 0,
title: {
text: ''
}
},
tooltip: {
headerFormat: '<span style="font-size:10px">{point.key}</span><table>',
pointFormat: '<tr><td style="color:{series.color};padding:0">{series.name}: </td>' +
'<td style="padding:0"><b>{point.y:.1f}</b></td></tr>',
footerFormat: '</table>',
shared: true,
useHTML: true
},
plotOptions: {
column: {
pointPadding: 0.2,
borderWidth: 0
}
},
legend : {
floating: true,
align: 'right',
x: -30,
verticalAlign: 'top',
},
series: [{
name: 'Count',
data: [<?php echo implode(",",array_values($cat2)); ?>]
},]
});
});
</script>
</div>
<div style='clear:both'></div>
<div style='overflow:auto'>
<table id=logtable class='footable table table-striped table-bordered table-white table-primary footable-loaded' style='font-size:12px'>
<thead>
<?php echo $outhead; ?>
</thead>
<?php echo $outstr; ?>
</table>
</div>
<div id=dialoglog></div>
</div>
<?php
use App\Models\CRMCallArchive;
use App\Models\CRMCall;
use App\Models\User;
use App\Jobs\KHRMSLib;
$wakka = new KHRMSLib();
$dashboarduser=Auth::user();
$userdialmode=$dashboarduser->dialmode_assign;
$userdialmode=explode(",",$userdialmode);
$timeoffset=$dashboarduser->timezone*60;
//echo $timeoffset;
$logtime =(isset($_GET['logtime'])) ? $_GET['logtime'] :7;
$logtimeto =(isset($_GET['logtimeto']))? $_GET['logtimeto']:22;
$key =(isset($_GET['key'])) ? $_GET['key'] : "All";
$value =(isset($_GET['value'])) ? $_GET['value'] : "";
$logdate =(isset($_GET['logdate'])) ? strtotime($_GET['logdate']." ".$logtime.":00:00") : strtotime(date("Y-m-d")." 07:00:00");
//echo $logdate;
$logdateto =(isset($_GET['logdate']))? strtotime($_GET['logdate']." ".$logtimeto.":00:00") : strtotime(date("Y-m-d")." 22:00:00");
//echo $logdateto;
$prevlogdate = strtotime(date('Y-m-d', strtotime('-7 day')));
if(Input::get("getCallRec")=="1")
{
if($logdate < $prevlogdate){
$calllog=CRMCallArchive::find(Input::get("calllog"));
}else{
$calllog=CRMCall::find(Input::get("calllog"));
}
$tdata=json_decode($calllog->data,true);
echo '<audio controls src="dialer/playrecfile?calllog='.$calllog->id.'" />';
return;
}
if($logdate < $prevlogdate)
{
if($key =='userstatus')
{
$alist=CRMCallArchive::where('created_at','>=',date("Y-m-d H:i:s",$logdate+$timeoffset))->where('created_at','<=',date("Y-m-d H:i:s",$logdateto+$timeoffset))->where($key,'like',$value.'%');
}else if($key=='fullname' || $key=='username')
{
$users=User::where($key,'like','%'.$value.'%')->get();
foreach ($users as $user) {
//echo $user->id;
$alist=CRMCallArchive::where('created_at','>=',date("Y-m-d H:i:s",$logdate+$timeoffset))->where('created_at','<=',date("Y-m-d H:i:s",$logdateto+$timeoffset))->where('user_id','=',$user->id);
}
}else if($key != 'All')
{
//echo $key;
$alist=CRMCallArchive::where('created_at','>=',date("Y-m-d H:i:s",$logdate+$timeoffset))->where('created_at','<=',date("Y-m-d H:i:s",$logdateto+$timeoffset))->where($key,'like','%'.$value.'%');
}else
{
$alist=CRMCallArchive::where('created_at','>=',date("Y-m-d H:i:s",$logdate+$timeoffset))->where('created_at','<=',date("Y-m-d H:i:s",$logdateto+$timeoffset));
}
}
else
{
if($key =='userstatus')
{
$alist=CRMCall::where('created_at','>=',date("Y-m-d H:i:s",$logdate+$timeoffset))->where('created_at','<=',date("Y-m-d H:i:s",$logdateto+$timeoffset))->where($key,'like',$value.'%');
}else if($key=='fullname' || $key=='username')
{
$users=User::where($key,'like','%'.$value.'%')->get();
foreach ($users as $user) {
//echo $user->id;
$alist=CRMCall::where('created_at','>=',date("Y-m-d H:i:s",$logdate+$timeoffset))->where('created_at','<=',date("Y-m-d H:i:s",$logdateto+$timeoffset))->where('user_id','=',$user->id);
}
}else if($key != 'All')
{
//echo $key;
$alist=CRMCall::where('created_at','>=',date("Y-m-d H:i:s",$logdate+$timeoffset))->where('created_at','<=',date("Y-m-d H:i:s",$logdateto+$timeoffset))->where($key,'like','%'.$value.'%');
}else
{
$alist=CRMCall::where('created_at','>=',date("Y-m-d H:i:s",$logdate+$timeoffset))->where('created_at','<=',date("Y-m-d H:i:s",$logdateto+$timeoffset));
}
//$alist=CRMCall::where('created_at','>=',date("Y-m-d H:i:s",$logdate+$timeoffset))->where('created_at','<=',date("Y-m-d H:i:s",$logdateto+$timeoffset));
//echo "2";
}
/*if($key =='userstatus')
{
$alist-> where($key,'like',$value.'%');
}else if($key=='fullname' || $key=='username')
{
$users=User::where($key,'like','%'.$value.'%')->get();
foreach ($users as $user) {
//echo $user->id;
$alist->where('user_id','=',$user->id);
}
}else if($key != 'All')
{
//echo $key;
$alist->where($key,'like','%'.$value.'%');
}else
{
$alist;
}*/
//if(!$dashboarduser->moduleACL("Dialer",false,false,true))
if($dashboarduser->usertype != 'Admin')
{
$uidlist=array($dashboarduser->id);
$allusers=User::where(function ($query) use($dashboarduser) {
$query->where('supervisor','=',$dashboarduser->username)
->orWhere('lteam2','=',$dashboarduser->username)
->orWhere('lteam','=',$dashboarduser->username);
})->get();
// ->where(function ($query) {
// $query->where('status', '=', 'Active');
// })->get();
foreach($allusers as $tuser)$uidlist[]=$tuser->id;
$roclientstr=array();$didlinesstr=array();
if($dashboarduser->exten!="")$didlinesstr[]=$dashboarduser->exten;
$oclientlst=$wakka->clientsReadAccess();
if(!empty($oclientlst))foreach($oclientlst as $tclnt)if($tclnt!="")
{
$roclientstr[]="$tclnt";
$mastersdata=$wakka->getCompanyMaster($tclnt);
if(!empty($mastersdata["DialerDID"]))$didlinesstr[]=$mastersdata["DialerDID"];
}
$alist=$alist->where(function ($query) use($roclientstr,$uidlist,$didlinesstr){
$query//->orWhereIn('client',$roclientstr)
->orWhereIn('user_id',$uidlist)
->orWhereIn('did',$didlinesstr);
});
}
if(Input::get('sort')=='cpu')$alist=$alist->orderBy("callSec","DESC");
else $alist=$alist->orderBy("id","DESC");
$alist=$alist->get();
$userarr=array();
$i=sizeof($alist);if(!empty($_GET['sort']))$i=1;
$totaltime=0;$ttlovr10=0;$ttlovr5=0;$ttlovr1=0;$ttlovr0=0;$outstr="";$usrcnt=0;$ttlin0=0;
$totaltimeIn=0;$ttlovr10In=0;$ttlovr5In=0;$ttlovr1In=0;$ttlovr0In=0;$usrcntIn=0;$ttloverin0=0;
$actionarr=array();$actionarrIn=array();
$callarraid='';
$crm_id='';
foreach($alist as $aline)
{
$callarraid.=$aline->id.",";
if($aline->crm_id>0)$crm_id.=$aline->crm_id.",";
}
$callarraid=substr($callarraid,0,-1);
$callarraid=explode(",", $callarraid);
$crm_id=substr($crm_id,0,-1);
$crm_id=explode(",", $crm_id);
$alist_remark=DB::table('full_remark')->select('fullremark','call_id')->whereIn('call_id',$callarraid)->get();
foreach($alist_remark as $aline)
{
$remarkval[$aline->call_id]=$aline->fullremark;
}
$clientcodearr=DB::table('records')->select('cust_id','id')->whereIn('id',$crm_id)->get();
foreach ($clientcodearr as $clientid)
{
$clientcodeval[$clientid->id]=$clientid->cust_id;
//$currentstatusval[$clientid->id]=$clientid->currentstatus;
//$legalstatusval[$clientid->id]=$clientid->legalstatus;
}
if(Input::has("dllogxls"))
{
include_once(app_path().'/lib/phpexcel/PHPExcel.php');
$inputFileType = "Excel5";
$objReader = PHPExcel_IOFactory::createReader($inputFileType);
$objPHPExcel = $objReader->load("assets/extras/blank.xls");
$baseRow = 3;
$tcol=0;$fieldsarr=array();$extrahdrarr=array();
$fieldsarr[$tcol++]='#';
$fieldsarr[$tcol++]='Start';
$fieldsarr[$tcol++]='Length';
$fieldsarr[$tcol++]='User';
$fieldsarr[$tcol++]='Name';
$fieldsarr[$tcol++]='Dispo';
$fieldsarr[$tcol++]='SubDispo';
$fieldsarr[$tcol++]='CB';
$fieldsarr[$tcol++]='Number';
$fieldsarr[$tcol++]='ClientCode';
$fieldsarr[$tcol++]='CurrentStatus';
$fieldsarr[$tcol++]='LegalStatus';
$fieldsarr[$tcol++]='Campaign';
$fieldsarr[$tcol++]='Department';
$fieldsarr[$tcol++]='State';
$fieldsarr[$tcol++]='HSource';
$fieldsarr[$tcol++]='Type';
$fieldsarr[$tcol++]='Status';
$fieldsarr[$tcol++]='StatusCode';
$fieldsarr[$tcol++]='StatusStr';
$fieldsarr[$tcol++]='DialLine';
$fieldsarr[$tcol++]='DID';
$fieldsarr[$tcol++]='WaitSec';
$fieldsarr[$tcol++]='CallSec';
$fieldsarr[$tcol++]='TalkSec';
$fieldsarr[$tcol++]='DispoSec';
$fieldsarr[$tcol++]='Remarks';
$highestColumn = sizeof($fieldsarr);
for ($head = 0; $head < $highestColumn; $head++){
$colstr=PHPExcel_Cell::stringFromColumnIndex($head);
$objPHPExcel->getActiveSheet()->setCellValue($colstr."1", $fieldsarr[$head]);
}
$ii=1;
foreach($alist as $aline)
{
$row = $baseRow++;
$col = 0;
$clientcode="";$currentstatus="";$legalstatus="";
if($aline->crm_id>0)
{
/*$user=$wakka->getPerson($aline->crm_id);
$clientcode=$user["peopledata"]["clientcode"];
$currentstatus=$user["peopledata"]["currentstatus"];
$legalstatus=$user["peopledata"]["legalstatus"];*/
$clientcode=$clientcodeval[$aline->crm_id];
// $currentstatus=$currentstatusval[$aline->crm_id];
// $legalstatus=$legalstatusval[$aline->crm_id];
}
$tpostdata=json_decode($aline->data,true);
$fulldate=date("Y-m-d H:i:s",strtotime($aline->created_at)-$timeoffset);
$talktime=$aline->talkSec+$aline->recstartSec+$aline->recendSec;
//$length=round(($aline->waitSec+$aline->callSec+$talktime+$aline->dispoSec)/1000,2);
$length=gmdate("H:i:s",round(($aline->waitSec+$aline->callSec+$talktime+$aline->dispoSec)/1000));
$fullremarkvalue='';
$fullremarkvalue=$remarkval[$aline->id];
if($fullremarkvalue=="")
{
$fullremarkvalue=$aline->userremarks;
}
if(!isset($userarr[$aline->user_id])&&$aline->user_id>0)$userarr[$aline->user_id]=User::find($aline->user_id);
$dispname="";if(isset($userarr[$aline->user_id]))$dispname=$userarr[$aline->user_id]->dispname();
$username="";if(isset($userarr[$aline->user_id]))$username=$userarr[$aline->user_id]->username;
$recstr='';
if($dashboarduser->moduleACL("Dialer",false,false,true))
{
if(isset($tpostdata['recFolder']))$recstr="<a href=# onclick='getCallRec(".$aline->id.");return false;' title='Size : ".round($aline->recsize/1024,0)." KB'><i class='fa fa-play-circle'></i> &nbsp;</a> <a href='dialer/playrecfile?calllog=$aline->id&out=wav' title=''><i class='fa fa-download'></i> &nbsp;</a><span id='recspan_".$aline->id."'</span>";
}
$objPHPExcel->getActiveSheet()->getCellByColumnAndRow($col++,$row)->setValueExplicit($ii++);
$objPHPExcel->getActiveSheet()->getCellByColumnAndRow($col++,$row)->setValueExplicit($fulldate);
$objPHPExcel->getActiveSheet()->getCellByColumnAndRow($col++,$row)->setValueExplicit($length);
$objPHPExcel->getActiveSheet()->getCellByColumnAndRow($col++,$row)->setValueExplicit($username);
$objPHPExcel->getActiveSheet()->getCellByColumnAndRow($col++,$row)->setValueExplicit($dispname);
$objPHPExcel->getActiveSheet()->getCellByColumnAndRow($col++,$row)->setValueExplicit($aline->userstatus);
$objPHPExcel->getActiveSheet()->getCellByColumnAndRow($col++,$row)->setValueExplicit($aline->usersubstatus);
$objPHPExcel->getActiveSheet()->getCellByColumnAndRow($col++,$row)->setValueExplicit(($aline->usercallback!="0000-00-00 00:00:00"?date("Y-m-d H:i:s",strtotime($aline->usercallback)-($timeoffset)):""));
$objPHPExcel->getActiveSheet()->getCellByColumnAndRow($col++,$row)->setValueExplicit($aline->number);
$objPHPExcel->getActiveSheet()->getCellByColumnAndRow($col++,$row)->setValueExplicit($clientcode);
$objPHPExcel->getActiveSheet()->getCellByColumnAndRow($col++,$row)->setValueExplicit($currentstatus);
$objPHPExcel->getActiveSheet()->getCellByColumnAndRow($col++,$row)->setValueExplicit($legalstatus);
$objPHPExcel->getActiveSheet()->getCellByColumnAndRow($col++,$row)->setValueExplicit($aline->client);
$objPHPExcel->getActiveSheet()->getCellByColumnAndRow($col++,$row)->setValueExplicit($aline->department);
$objPHPExcel->getActiveSheet()->getCellByColumnAndRow($col++,$row)->setValueExplicit($aline->state);
$objPHPExcel->getActiveSheet()->getCellByColumnAndRow($col++,$row)->setValueExplicit($aline->hsource);
$objPHPExcel->getActiveSheet()->getCellByColumnAndRow($col++,$row)->setValueExplicit($aline->type);
$objPHPExcel->getActiveSheet()->getCellByColumnAndRow($col++,$row)->setValueExplicit($aline->status);
$objPHPExcel->getActiveSheet()->getCellByColumnAndRow($col++,$row)->setValueExplicit($aline->statuscode);
$objPHPExcel->getActiveSheet()->getCellByColumnAndRow($col++,$row)->setValueExplicit($aline->substatus);
$objPHPExcel->getActiveSheet()->getCellByColumnAndRow($col++,$row)->setValueExplicit($aline->dialline_id);
$objPHPExcel->getActiveSheet()->getCellByColumnAndRow($col++,$row)->setValueExplicit($aline->did);
$objPHPExcel->getActiveSheet()->getCellByColumnAndRow($col++,$row)->setValueExplicit(gmdate("H:i:s",round($aline->waitSec/1000,2)));
$objPHPExcel->getActiveSheet()->getCellByColumnAndRow($col++,$row)->setValueExplicit(gmdate("H:i:s",round($aline->callSec/1000,2)));
$objPHPExcel->getActiveSheet()->getCellByColumnAndRow($col++,$row)->setValueExplicit(gmdate("H:i:s",round($talktime/1000,2)));
$objPHPExcel->getActiveSheet()->getCellByColumnAndRow($col++,$row)->setValueExplicit(gmdate("H:i:s",round($aline->dispoSec/1000,2)));
/*$objPHPExcel->getActiveSheet()->getCellByColumnAndRow($col++,$row)->setValueExplicit($aline->userremarks);*/
/*$objPHPExcel->getActiveSheet()->getCellByColumnAndRow($col++,$row)->setValueExplicit($aline->fullremark);*/
$objPHPExcel->getActiveSheet()->getCellByColumnAndRow($col++,$row)->setValueExplicit($fullremarkvalue);
$userdata=json_decode($aline->userdata,true);
$extravals=$extrahdrarr;
if(!empty($userdata))
{
foreach($userdata as $key=>$val)
{
if(!isset($extrahdrarr[$key]))
{
$extrahdrarr[$key]="";
$extravals[$key]="";
$colstr=PHPExcel_Cell::stringFromColumnIndex(sizeof($fieldsarr)+sizeof($extrahdrarr));
$objPHPExcel->getActiveSheet()->setCellValue($colstr."1", $key);
}
$extravals[$key]=$val;
}
foreach($extravals as $key=>$val)
{
$objPHPExcel->getActiveSheet()->getCellByColumnAndRow($col++,$row)->setValueExplicit($val);
}
}
}
header('Content-Type: application/vnd.ms-excel');
header('Content-Disposition: attachment;filename="CallLog.xls"');
header('Cache-Control: max-age=0');
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, $inputFileType);
$objWriter->save('php://output');
return ;
}
foreach($alist as $aline)
{
$clientcode="";
if($aline->crm_id>0)
{
/*$user=$wakka->getPerson($aline->crm_id);
$clientcode=$user["peopledata"]["clientcode"];*/
$clientcode=$clientcodeval[$aline->crm_id];
}
$tpostdata=json_decode($aline->data,true);
$fulldate=date("Y-m-d H:i:s",strtotime($aline->created_at)-($timeoffset));
$talktime=$aline->talkSec+$aline->recstartSec+$aline->recendSec;
//$length=round(($aline->waitSec+$aline->callSec+$talktime+$aline->dispoSec)/1000,2);
$length=gmdate("H:i:s",round(($aline->waitSec+$aline->callSec+$talktime+$aline->dispoSec)/1000,2));
if(!isset($userarr[$aline->user_id])&&$aline->user_id>0)$userarr[$aline->user_id]=User::find($aline->user_id);
$dispname="";if(isset($userarr[$aline->user_id]))$dispname=$userarr[$aline->user_id]->dispname();
$username="";if(isset($userarr[$aline->user_id]))$username=$userarr[$aline->user_id]->username;
$recstr='';
if($dashboarduser->moduleACL("Dialer",false,false,true))
{
if(isset($tpostdata['recFolder']))$recstr="<a href=# onclick='getCallRec(".$aline->id.");return false;' title='Size : ".round($aline->recsize/1024,0)." KB'><i class='fa fa-play-circle'></i> &nbsp;</a> <a href='dialer/playrecfile?calllog=$aline->id&out=wav' title=''><i class='fa fa-download'></i> &nbsp;</a><span id='recspan_".$aline->id."'</span>";
}
$outstr.="<tr><td>".$i."</td>
<td title='$fulldate'>".$fulldate."</td>
<td>".$length."</td>
<td>".$username."</td>
<td>".$dispname."</td>
<td title='".str_replace("'"," ",$aline->userremarks)."'>".$aline->userstatus."</td>
<td>".$aline->usersubstatus."</td>
<td>".($aline->usercallback!="0000-00-00 00:00:00"?date("Y-m-d H:i:s",strtotime($aline->usercallback)+($dashboarduser->timezone*60)):"")."</td>";
//onclick call disable for the manual mode is not assign to user code by prashant Jadhav
if(in_array('Manual',$userdialmode))
{
/*$outstr.="<td><a href=# class='' onclick='dialerQuickOpen(\"$aline->crm_id\",\"$aline->number\",\"Manual\",\"\",0);return false;'>".$aline->number."</a></td>";*/
$outstr.="<td>$aline->number</td>";
}
else
{
$outstr.="<td><a href=# class='' return false;'>".$aline->number."</a></td>";
}
$outstr.="<td>$clientcode</td>
<td>".$aline->client."</td>
<td>".$aline->department."</td>
<td>".$aline->state."</td>
<td>".$aline->hsource."</td>
<td>".$aline->type."</td>
<td>".$aline->status."</td>
<td>".$aline->substatus."</td>
<td>".$aline->dialline_id."</td>
<td>".$aline->did."</td>
<td>".gmdate("H:i:s",round($aline->waitSec/1000,2))."</td>
<td>".gmdate("H:i:s",round($aline->callSec/1000,2))."</td>
<td>".gmdate("H:i:s",round($talktime/1000,2))."</td>
<td>".gmdate("H:i:s",round($aline->dispoSec/1000,2))."</td>
<td>$recstr</td>
</tr>";
if($aline->type=='Inbound')
{
if($talktime>120000)$ttlovr10In++;
else if($talktime>60000)$ttlovr5In++;
else if($talktime>30000)$ttlovr1In++;
else if($talktime>1000)$ttlovr0In++;
else $ttloverin0++;
$totaltimeIn+=round($talktime/1000,2);
$usrcntIn++;
$turl=$aline->status." - ".$aline->statuscode." - ".$aline->substatus;
if(!isset($actionarrIn[$turl]))$actionarrIn[$turl]=array('cnt'=>0,'time'=>0);
$actionarrIn[$turl]['cnt']++;
$actionarrIn[$turl]['time']+=round(($aline->callSec+$talktime)/1000,2);
}
else
{
if($talktime>120000)$ttlovr10++;
else if($talktime>60000)$ttlovr5++;
else if($talktime>30000)$ttlovr1++;
else if($talktime>1000)$ttlovr0++;
else $ttlin0++;
$totaltime+=round($talktime/1000,2);
$usrcnt++;
$turl=$aline->status." - ".$aline->statuscode." - ".$aline->substatus;
if(!isset($actionarr[$turl]))$actionarr[$turl]=array('cnt'=>0,'time'=>0);
$actionarr[$turl]['cnt']++;
$actionarr[$turl]['time']+=round(($aline->callSec+$talktime)/1000,2);
}
if(!empty($_GET['sort']))$i++;else $i--;
}
?>
<div class=innerAll>
<style>#logtable.td{vertical-align:top;}#logtable.tr{height:28px;overflow-y:hidden;}</style>
<script>
function showExtraPost(varstr)
{
doAjax("hr?action=LiveUsers","getpostdata="+varstr,"dialoglog");
$('#dialoglog').dialog('open');
return false;
}
$(document).ready(function()
{
if(!$('#dialoglog').hasClass('ui-dialog-content'))
{
$('#dialoglog').dialog({
autoOpen: false,
width: '70%',
buttons: {
"Ok": function() {
$(this).dialog("close");
},
"Cancel": function() {
$(this).dialog("close");
}
}
});
}
waitKeyUpRun("filter",function() { filter2(document.getElementById('filter'), 'logtable') },"2000");
$('#modfrom').datepicker({dateFormat: 'yy-mm-dd',inline: true,changeYear: true,selectOtherMonths: true,yearRange: '<?php echo (date('Y')-70).":".(date('Y')+5); ?>'});
});
</script>
<div>
<select id="crmCol" style="border:1px solid #efefef;">
<option>All</option>
<option value="userstatus">Disposition</option>
<option value="usersubstatus">Sub-Disposition</option>
<option value="number">Number</option>
<option value="client">Campaign</option>
<option value="did">DID</option>
<option value="type">Type</option>
<option value="fullname">Name</option>
<option value="username">User</option>
</select>
<input id=filter name="filter" type="text">
<script type="text/javascript">
document.getElementById('crmCol').value = "<?php echo $key;?>";
document.getElementById('filter').value = "<?php echo $value;?>";
</script>
Date : <input size=10 id='modfrom' name='modfrom' type='text' value='<?php echo date("Y-m-d",$logdate); ?>' />
Time From:<select id="modtime" style="border:1px solid #efefef;">
<?php
foreach (range(0,23) as $hour) {
$selected = ($hour == $logtime) ? "selected" : "";
echo "<option value='$hour' $selected>".str_pad($hour, 2, "0", STR_PAD_LEFT) . ":00</option>";
}
?>
</select>
To: <select id="modtimeto" style="border:1px solid #efefef;">
<?php
foreach (range(0,23) as $hour) {
$selected = ($hour == $logtimeto) ? "selected" : "";
echo "<option value='$hour' $selected>".str_pad($hour, 2, "0", STR_PAD_LEFT) . ":00</option>";
}
?>
</select>
<button id="load" onclick='callLogReloadFun("");return false;' value='Submit'>Submit</button>&nbsp;&nbsp;
</div>
<div style="float:right;width:30%">
<?php if(Auth::user()->username=='admin'){ ?>
<button class="pull-right btn btn-sm btn-default" onclick='dlCalllogXls();return false;' title='Download' style='margin-top:-8px'><i class='fa fa-download'></i> Download</button>
<?php } ?>
</div>
<div style="clear:both"></div>
<hr>
<?php
$categories=array();$avgarr=array();$cntarr=array();
foreach($actionarr as $act=>$actarr)
{
if($actarr['cnt']>sizeof($alist)/150)
{
//echo "<label>$act</label> ".round($actarr['time']/$actarr['cnt'],2)." [".round($actarr[time],1)."/$actarr[cnt]]<br>";
$categories[]="'$act'";
$avgarr[]=-round($actarr['time']/$actarr['cnt'],2);
$cntarr[]=$actarr['cnt'];
}
}
array_multisort($cntarr,$avgarr,$categories);
$categoriesIn=array();$avgarrIn=array();$cntarrIn=array();
foreach($actionarrIn as $act=>$actarr)
{
if($actarr['cnt']>sizeof($alist)/150)
{
//echo "<label>$act</label> ".round($actarr['time']/$actarr['cnt'],2)." [".round($actarr[time],1)."/$actarr[cnt]]<br>";
$categoriesIn[]="'$act'";
$avgarrIn[]=-round($actarr['time']/$actarr['cnt'],2);
$cntarrIn[]=$actarr['cnt'];
}
}
array_multisort($cntarrIn,$avgarrIn,$categoriesIn);
?>
<div class=col-md-3>
<br>
<h5>Stats - Outbound</h5><hr><br>
<ul style="list-style:none">
<li class="notify_alert">
<span><a href=# onclick="return false;">Total CallTime</a></span>
<span class="label label-small label-default pull-right" >{!!round($totaltime,2)!!}</span>
</li>
<li class="notify_alert">
<span><a href=# onclick="return false;">Total Calls</a></span>
<span class="label label-small label-default pull-right" >{!!$usrcnt!!}</span>
</li>
<li class="notify_alert">
<span><a href=# onclick="return false;">Average CallTime</a></span>
<span class="label label-small label-default pull-right" >{!!($usrcnt>0)?round($totaltime/$usrcnt,2):'0'!!}</span>
</li>
<li class="notify_alert">
<span><a href=# onclick="return false;">Calls > 2 Min</a></span>
<span class="label label-small label-default pull-right" >{!!$ttlovr10!!}</span>
</li>
<li class="notify_alert">
<span><a href=# onclick="return false;">Calls > 60 to 120 sec</a></span>
<span class="label label-small label-default pull-right" >{!!$ttlovr5!!}</span>
</li>
<li class="notify_alert">
<span><a href=# onclick="return false;">Calls 31 to 60 sec</a></span>
<span class="label label-small label-default pull-right" >{!!$ttlovr1!!}</span>
</li>
<li class="notify_alert">
<span><a href=# onclick="return false;">Calls 1 to 30 sec</a></span>
<span class="label label-small label-default pull-right" >{!!$ttlovr0!!}</span>
</li>
<li class="notify_alert">
<span><a href=# onclick="return false;">Calls < 1 sec</a></span>
<span class="label label-small label-default pull-right" >{!!$ttlin0!!}</span>
</li>
</ul>
</div>
<!-- div class=col-md-10>
<div id=userlogschart1 style='min-height:300px;height:<?php echo sizeof($categories)*18; ?>px;width:100%'></div>
<script>
$(function () {
var categories = [<?php echo implode(",",$categories); ?>];
$(document).ready(function () {
var userchart1=new Highcharts.Chart({
chart: {
renderTo: 'userlogschart1',
type: 'bar'
},
title: {
text: 'User Actions by Avg time and Usages'
},
xAxis: [{
categories: categories,
reversed: false,
labels: {
step: 1
}
}, { // mirror axis on right side
opposite: true,
reversed: false,
categories: categories,
linkedTo: 0,
labels: {
//step: 1
formatter: function () {
return '';
}
}
}],
yAxis: {
// title: {
// text: null
// },
// labels: {
// formatter: function () {
// return (Math.abs(this.value) / 1000000) + 'M';
// }
// },
// min: -4000000,
// max: 4000000
},
plotOptions: {
series: {
stacking: 'normal'
}
},
tooltip: {
formatter: function () {
return '<b>' + this.series.name + ' ' + this.point.category + '</b><br/>' +
'Val: ' + Highcharts.numberFormat(Math.abs(this.point.y), 0);
}
},
series: [{
name: 'Avg Time',
data: [<?php echo implode(",",$avgarr); ?>]
}, {
name: 'Count',
data: [<?php echo implode(",",$cntarr); ?>]
}]
});
});
});
function callLogReloadFun(sortby)
{
var sortstr='';if(sortby!="")sortstr="&sort="+sortby
doAjax('dialer/calllog?logdate='+$("#modfrom").val()+sortstr,'','rightmainreportdiv','ajax_dialer_reports','singlethis','GET');
}
function getCallRec(id)
{
doAjax("dialer/calllog","getCallRec=1&calllog="+id+"&logdate="+$("#modfrom").val(),'recspan_'+id,'rec_ajax','singlefail','GET');
}
function dlCalllogXls()
{
window.open('dialer/calllog?dllogxls=1&logdate='+$("#modfrom").val());return false;
}
</script>
</div -->
<script>
function dataString()
{
return 'logdate='+$("#modfrom").val()+'&logtime='+$("#modtime").val()+'&logtimeto='+$("#modtimeto").val()+'&key='+$("#crmCol").val()+'&value='+$("#filter").val();
}
function callLogReloadFun(sortby)
{
var sortstr='';if(sortby!="")sortstr="&sort="+sortby
var searchStr = dataString();
doAjax('dialer/calllog?'+searchStr+sortstr,'','rightmainreportdiv','ajax_dialer_reports','singlethis','GET');
}
function getCallRec(id)
{
doAjax("dialer/calllog","getCallRec=1&calllog="+id+"&logdate="+$("#modfrom").val(),'recspan_'+id,'rec_ajax','singlefail','GET');
}
function dlCalllogXls()
{
var searchStr = dataString();
window.open('dialer/calllog?dllogxls=1&'+searchStr);return false;
}
</script>
<div style='clear:both'></div>
<div class=col-md-3>
<br>
<h5>Stats - Inbound</h5><hr><br>
<ul style="list-style:none">
<li class="notify_alert">
<span><a href=# onclick="return false;">Total CallTime</a></span>
<span class="label label-small label-default pull-right" >{!!round($totaltimeIn,2)!!}</span>
</li>
<li class="notify_alert">
<span><a href=# onclick="return false;">Total Calls</a></span>
<span class="label label-small label-default pull-right" >{!!$usrcntIn!!}</span>
</li>
<li class="notify_alert">
<span><a href=# onclick="return false;">Average CallTime</a></span>
<span class="label label-small label-default pull-right" >{!!($usrcntIn>0)?round($totaltimeIn/$usrcntIn,2):'0'!!}</span>
</li>
<li class="notify_alert">
<span><a href=# onclick="return false;">Calls > 2 Min </a></span>
<span class="label label-small label-default pull-right" >{!!$ttlovr10In!!}</span>
</li>
<li class="notify_alert">
<span><a href=# onclick="return false;">Calls 61 to 120 sec</a></span>
<span class="label label-small label-default pull-right" >{!!$ttlovr5In!!}</span>
</li>
<li class="notify_alert">
<span><a href=# onclick="return false;">Calls 31 to 60 sec</a></span>
<span class="label label-small label-default pull-right" >{!!$ttlovr1In!!}</span>
</li>
<li class="notify_alert">
<span><a href=# onclick="return false;">Calls 1 sec to 30 sec</a></span>
<span class="label label-small label-default pull-right" >{!!$ttlovr0In!!}</span>
</li>
<li class="notify_alert">
<span><a href=# onclick="return false;">Calls < 1 sec</a></span>
<span class="label label-small label-default pull-right" >{!!$ttloverin0!!}</span>
</li>
</ul>
</div>
<!-- div class=col-md-10>
<div id=userlogschart2 style='min-height:300px;height:<?php echo sizeof($categoriesIn)*18; ?>px;width:100%'></div>
<script>
$(function () {
var categories = [<?php echo implode(",",$categoriesIn); ?>];
$(document).ready(function () {
var userchart1=new Highcharts.Chart({
chart: {
renderTo: 'userlogschart2',
type: 'bar'
},
title: {
text: 'User Actions by Avg time and Usages'
},
xAxis: [{
categories: categories,
reversed: false,
labels: {
step: 1
}
}, { // mirror axis on right side
opposite: true,
reversed: false,
categories: categories,
linkedTo: 0,
labels: {
//step: 1
formatter: function () {
return '';
}
}
}],
yAxis: {
// title: {
// text: null
// },
// labels: {
// formatter: function () {
// return (Math.abs(this.value) / 1000000) + 'M';
// }
// },
// min: -4000000,
// max: 4000000
},
plotOptions: {
series: {
stacking: 'normal'
}
},
tooltip: {
formatter: function () {
return '<b>' + this.series.name + ' ' + this.point.category + '</b><br/>' +
'Val: ' + Highcharts.numberFormat(Math.abs(this.point.y), 0);
}
},
series: [{
name: 'Avg Time',
data: [<?php echo implode(",",$avgarrIn); ?>]
}, {
name: 'Count',
data: [<?php echo implode(",",$cntarrIn); ?>]
}]
});
});
});
</script>
</div -->
<div style='clear:both'></div>
<div style='overflow:auto'>
<table id=logtable class='footable table table-striped table-bordered table-white table-primary footable-loaded' style='font-size:12px'>
<thead>
<tr>
<th>#</th>
<th>Start</th>
<th onclick='callLogReloadFun("");return false;'>Length</th>
<th>User</th>
<th>Name</th>
<th>Dispo</th>
<th>SubDispo</th>
<th>CB</th>
<th style='width:120px'>Number</th>
<th>ClientCode</th>
<th>Campaign</th>
<th>Department</th>
<th>State</th>
<th>HSource</th>
<th>Type</th>
<th>Status</th>
<th>StatusStr</th>
<th>DialLine</th>
<th>DID</th>
<th>WaitSec</th>
<th>CallSec</th>
<th>TalkSec</th>
<th>DispoSec</th>
<th>Recording</th>
</tr>
</thead>
<?php echo $outstr; ?>
</table>
</div>
<?php
function convert($size)
{
$unit=array('b','kb','mb','gb','tb','pb');
return @round($size/pow(1024,($i=floor(log($size,1024)))),2).' '.$unit[$i];
}
echo "<br>".convert(memory_get_peak_usage(true)); // 123 kb
?>
<div id=dialoglog></div>
</div>
<?php
use App\Models\CRMCall;
use App\Models\User;
use App\Jobs\KHRMSLib;
use App\Models\SupervisonComments;
$wakka = new KHRMSLib();
$dashboarduser=Auth::user();
if(isset($_GET['logdate']))$logdate=strtotime($_GET['logdate']." 00:00:00");
else $logdate=strtotime(date('Y-m-d')." 00:00:00");
if(isset($_GET['logtodate']))$logtodate=strtotime($_GET['logtodate']." 23:59:59");
else $logtodate=strtotime(date('Y-m-d')." 23:59:59");
$userarr=array();$i=1;
$reporthead=array("id","created_at","updated_at","clientcode","supvisor_id","supvisor_recommends","agent","agent_comments");
$reportarray=DB::table('supervisor_comments')->select('*')->where('updated_at','>=',date("Y-m-d H:i:s",$logdate))->where('updated_at','<=',date("Y-m-d H:i:s",$logtodate))->get();
if(Input::has("dllogxls"))
{
include_once(app_path().'/lib/phpexcel/PHPExcel.php');
$inputFileType = "Excel5";
$objReader = PHPExcel_IOFactory::createReader($inputFileType);
$objPHPExcel = $objReader->load("assets/extras/blank.xls");
$baseRow = 2;
$highestColumn = sizeof($reporthead);
for ($head = 0; $head < $highestColumn; $head++){
$colstr=PHPExcel_Cell::stringFromColumnIndex($head);
$objPHPExcel->getActiveSheet()->setCellValue($colstr."1", $reporthead[$head]);
}
foreach($reportarray as $uid=>$uarr)
{
$row = $baseRow++;
$col = 0;
for ($head = 0; $head < $highestColumn; $head++){
if($reporthead[$head]=="created_at")
$uarr->$reporthead[$head]=date("Y-m-d H:i:s",strtotime($uarr->$reporthead[$head])+330*60);
if($reporthead[$head]=="updated_at")
$uarr->$reporthead[$head]=date("Y-m-d H:i:s",strtotime($uarr->$reporthead[$head])+330*60);
$colstr=PHPExcel_Cell::stringFromColumnIndex($head);
$objPHPExcel->getActiveSheet()->setCellValue($colstr.$row, $uarr->$reporthead[$head]);
}
}
header('Content-Type: application/vnd.ms-excel');
header('Content-Disposition: attachment;filename="CallManagement.xls"');
header('Cache-Control: max-age=0');
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, $inputFileType);
$objWriter->save('php://output');
return ;
}
?>
<div class=innerAll>
<style>#logtable.td{vertical-align:top;}#logtable.tr{height:28px;overflow-y:hidden;}</style>
<script>
$(document).ready(function()
{
if(!$('#dialoglog').hasClass('ui-dialog-content'))
{
$('#dialoglog').dialog({
autoOpen: false,
width: '70%',
buttons: {
"Ok": function() {
$(this).dialog("close");
},
"Cancel": function() {
$(this).dialog("close");
}
}
});
}
waitKeyUpRun("filter",function() { filter2(document.getElementById('filter'), 'logtable') },"2000");
$('#modfrom').datepicker({dateFormat: 'yy-mm-dd',inline: true,changeYear: true,selectOtherMonths: true,yearRange: '<?php echo (date('Y')-70).":".(date('Y')+5); ?>'});
$('#modto').datepicker({dateFormat: 'yy-mm-dd',inline: true,changeYear: true,selectOtherMonths: true,yearRange: '<?php echo (date('Y')-70).":".(date('Y')+5); ?>'});
});
</script>
<div style="float:left;width:50%">
From : <input size=10 id='modfrom' name='modfrom' type='text' value='<?php echo date("Y-m-d",$logdate); ?>' />
&nbsp;&nbsp;To : <input size=10 id='modto' name='modto' type='text' value='<?php echo date("Y-m-d",$logtodate); ?>' />
</div>
<div style="float:right;width:50%">
<button class="pull-right btn btn-sm btn-default" onclick='dlAgentlogXls();return false;' title='Download' style='margin-top:-8px'><i class='fa fa-download'></i> Download</button>
</div>
<div style="clear:both"></div>
<hr>
<div class=col-md-12>
<div id=userlogschart1 style='min-height:300px;width:100%'></div>
</div>
<script>
function dlAgentlogXls()
{
window.open('dialer/callmanagement?dllogxls=1&logdate='+$("#modfrom").val()+'&logtodate='+$("#modto").val());return false;
}
</script>
<div style='clear:both'></div>
<div class=col-md-12>
<div id=userlogschart2 style='min-height:300px;width:100%'></div>
</div>
<div style='clear:both'></div>
<div style='overflow:auto'>
<table id=logtable class='footable table table-striped table-bordered table-white table-primary footable-loaded' style='font-size:12px'>
<thead>
<?php /*echo $outhead;*/ ?>
</thead>
<?php /*echo $outstr;*/ ?>
</table>
</div>
<div id=dialoglog></div>
</div>
<?php
$reportTitle = 'Campaign Wise Report';
$returnblade = 'campaignreport';
$view_path = Config::get('view.paths');
include_once($view_path[0].'/layout/module/dialer/reporthead.blade.php');
$alist1=$alist;
//$alist=$alist->whereIn('c.userstatus',array('Interested', 'Reprised', 'No contact', 'Not Interested', 'Not Eligible', 'FollowUp'));
$alist=$alist->get();
//$alist1=$alist1->whereIn('c.userstatus',array('Not Interested', 'Not Eligible'));
$alist1=$alist1->groupBy('c.userstatus', 'c.id');
$alist1=$alist1->get();
$i=1;
$reporthead=array("#","Campaign","Data Received","Callable Data","Data Utilised","Attempts","Intensity","Contacts","Not Interested","Not Eligible","FollowUp","Reprised","No contact","Lead Count","Lead Value","Contacts%","Not Interested%","Not Eligible%");
$reporthead1=array("Campaign Name", "Grand Total");
$reportarray=$reportarray1=array();
if(count($alist))
foreach($alist as $aline)
{
$arraykey = $aline->client;
if(!isset($reportarray[$arraykey]))$reportarray[$arraykey]=array("#"=>$i++,"Campaign"=>$aline->client,"Data Received"=>0,"Callable Data"=>0,"Data Utilised"=>0,"Attempts"=>0,"Intensity"=>0,"Contacts"=>0,"Not Interested"=>0,"Not Eligible"=>0,"FollowUp"=>0,"Lead Count"=>0,"Lead Value"=>0,"Contacts%"=>0,"Not Interested%"=>0,"Not Eligible%"=>0,"Customer_lists"=>array());
if(!is_null($aline->crm_id)) {
$reportarray[$arraykey]["Customer_lists"][] = $aline->crm_id;
}
$reportarray[$arraykey]["Callable Data"] = count(array_unique($reportarray[$arraykey]["Customer_lists"]));
$reportarray[$arraykey]["Data Utilised"] = count(array_unique($reportarray[$arraykey]["Customer_lists"]));
$reportarray[$arraykey]["Attempts"]++;
if(stristr($aline->dialer_status,'Not Contactable') == ""){print_r($aline->dialer_status);echo "<br>";
$reportarray[$arraykey]["Contacts"] = array();
$reportarray[$arraykey]["Contacts"][] = $aline->crm_id;
$reportarray[$arraykey]["Contacts"]=count(array_unique($reportarray[$arraykey]["Contacts"]));
}
$reportarray[$arraykey][$aline->dialer_status]++;
if($aline->dialer_status == 'Interested') {
//$ststr=str_replace('Top up ', '', $aline->usersubstatus);
//$reportarray[$arraykey][$aline->usersubstatus]++;
$reportarray[$arraykey]['Lead Count']++;
}
$ststr= $aline->client;
$reportarray[$arraykey][$ststr]++;
/* if($aline->userstatus == 'Interested') {
$ststr=str_replace('Top up ', '', $aline->usersubstatus);
$reportarray[$arraykey][$ststr]++;
} */
}
$highestColumn = sizeof($reporthead);
if(count($reportarray)) {
$outhead="<tr>";$outstr="";
for ($head = 0; $head < $highestColumn; $head++){
if($reporthead[$head] == '#' && false) {
$mode_str = "<a onclick='displayMode(".'"summation"'.");return false;' href='#'><i class='fa fa-plus-square-o'></i></a> / <a onclick='displayMode(".'"percent"'.");return false;' href='#'>%</a>";
$outhead.="<td>".$mode_str."</td>";
}
else {
$outhead.="<td>".$reporthead[$head]."</td>";
}
}
$outhead.="</tr>";
$utotalarr = array("Campaign"=>'Total');
foreach($reportarray as $uid=>$uarr)
{
$outstr.="<tr>";
for ($head = 0; $head < $highestColumn; $head++){
if($head < 2) {
$data_str = $uarr[$reporthead[$head]];
}
elseif($head == 6) {
$data_str = ($uarr[$reporthead[4]] > 0) ? number_format(@($uarr[$reporthead[5]]/$uarr[$reporthead[4]]), 2 ) : '';
}
elseif($head == 15) {
$data_str = ($uarr[$reporthead[4]] != 0) ? number_format(@($uarr[$reporthead[7]]/$uarr[$reporthead[4]]) * 100, 2 ) . '%' : '';
}
elseif($head == 16) {
$data_str = ($uarr[$reporthead[4]] != 0) ? number_format(@($uarr[$reporthead[8]]/$uarr[$reporthead[4]]) * 100, 2 ) . '%' : '';
}
elseif($head == 17) {
$data_str = ($uarr[$reporthead[4]] != 0) ? number_format(@($uarr[$reporthead[9]]/$uarr[$reporthead[4]]) * 100, 2 ) . '%' : '';
}
elseif($head < 50) {
$data_str = $uarr[$reporthead[$head]];
$utotalarr[$reporthead[$head]] += $uarr[$reporthead[$head]];
}
else {
$data_str = '<span class="summation" style="display:block;">'.$uarr[$reporthead[$head]].'</span>';
$data_str .= '<span class="percent" style="display:none;">'.number_format(@($uarr[$reporthead[$head]]/$uarr['Attempts']) * 100, 2 ).'%</span>';
$utotalarr[$reporthead[$head]] += $uarr[$reporthead[$head]];
}
$outstr.="<td>".$data_str."</td>";
}
$outstr.="</tr>";
}
$outstr.="<tr>";
for ($head = 0; $head < $highestColumn; $head++)
{
if($head == 6) {
$data_str = number_format(@($utotalarr[$reporthead[5]]/$utotalarr[$reporthead[4]]), 2 );
}
elseif($head == 15) {
$data_str = number_format(@($utotalarr[$reporthead[7]]/$utotalarr[$reporthead[4]]) * 100, 2 ) . '%';
}
elseif($head == 16) {
$data_str = number_format(@($utotalarr[$reporthead[8]]/$utotalarr[$reporthead[4]]) * 100, 2 ) . '%';
}
elseif($head == 17) {
$data_str = number_format(@($utotalarr[$reporthead[9]]/$utotalarr[$reporthead[4]]) * 100, 2 ) . '%';
}
elseif($head < 50) {
$data_str = $utotalarr[$reporthead[$head]];
}
else {
$data_str = '<span class="summation" style="display:block;">'.$utotalarr[$reporthead[$head]].'</span>';
$data_str .= '<span class="percent" style="display:none;">'.number_format(@($utotalarr[$reporthead[$head]]/$utotalarr['Attempts']) * 100, 2 ).'%</span>';
}
$outstr.="<td>".$data_str."</td>";
}
$outstr.="</tr>";
}
else {
$outhead.="<tr><td>No Records Found.</td></tr>";
}
$i=1;
$reporthead1=array("Campaign Name", "Grand Total");
$reportarray1=array();
if(count($alist1))
foreach($alist1 as $aline)
{
$arrayheadkey = $aline->userstatus . ' Reason';
if(!isset($reportarray1[$arrayheadkey]))$reportarray1[$arrayheadkey]=array("Campaign Name"=>$arrayheadkey,"Grand Total"=>0);
$ststr = $aline->client; $reportarray1[$arrayheadkey][$ststr]++; $reportarray1[$arrayheadkey]["Grand Total"]++;
$tuser=$userarr[$aline->user_id];
$arraykey = ($aline->userstatus == 'Not Interested') ? 'NI-' . $aline->usersubstatus : 'NE-' . $aline->usersubstatus;
if(!isset($reportarray1[$arraykey]))$reportarray1[$arraykey]=array("Campaign Name"=>$arraykey,"Grand Total"=>0);
$ststr = $aline->usersubstatus; $reportarray1[$arraykey][$ststr]++; $reportarray1[$arraykey]["Grand Total"]++;
$ststr=$aline->client;
if(!in_array($ststr,$reporthead1))$reporthead1[]=$ststr;
$reportarray1[$arraykey][$ststr]++;
}
$highestColumn1 = sizeof($reporthead1);
if(count($reportarray1)) {
$outhead1="<tr>";$outstr1="";
for ($head = 0; $head < $highestColumn1; $head++){
if($reporthead1[$head] == '#' && false) {
$mode_str = "<a onclick='displayMode(".'"summation"'.");return false;' href='#'><i class='fa fa-plus-square-o'></i></a> / <a onclick='displayMode(".'"percent"'.");return false;' href='#'>%</a>";
$outhead1.="<td>".$mode_str."</td>";
}
else {
$outhead1.="<td>".$reporthead1[$head]."</td>";
}
}
$outhead1.="</tr>";
//$utotalarr = array("Campaign Name"=>'Not Interested Reason');
foreach($reportarray1 as $uid=>$uarr)
{
$outstr.="<tr>";
for ($head = 0; $head < $highestColumn1; $head++){
if($head < 1) {
$data_str = $uarr[$reporthead1[$head]];
}
elseif($head < 50) {
$data_str = $uarr[$reporthead1[$head]];
$utotalarr[$reporthead1[$head]] += $uarr[$reporthead1[$head]];
}
else {
$data_str = '<span class="summation" style="display:block;">'.$uarr[$reporthead1[$head]].'</span>';
$data_str .= '<span class="percent" style="display:none;">'.number_format(@($uarr[$reporthead1[$head]]/$uarr['Total']) * 100, 2 ).'%</span>';
$utotalarr[$reporthead1[$head]] += $uarr[$reporthead1[$head]];
}
$outstr1.="<td>".$data_str."</td>";
}
$outstr1.="</tr>";
}
$outstr1.="<tr>";
}
/* else {
$outhead1.="<tr><td>No Records Found.</td></tr>";
} */
if(Input::has("dllogxls"))
{
include_once(app_path().'/lib/phpexcel/PHPExcel.php');
$inputFileType = "Excel5";
$objReader = PHPExcel_IOFactory::createReader($inputFileType);
$objPHPExcel = $objReader->load("assets/extras/blank.xls");
$baseRow = 2;
$highestColumn = sizeof($reporthead);
for ($head = 0; $head < $highestColumn; $head++){
$colstr=PHPExcel_Cell::stringFromColumnIndex($head);
$objPHPExcel->getActiveSheet()->setCellValue($colstr."1", $reporthead[$head]);
}
foreach($reportarray as $uid=>$uarr)
{
$row = $baseRow++;
$col = 0;
for ($head = 0; $head < $highestColumn; $head++){
$printval = ($head != 6) ? $uarr[$reporthead[$head]] : (($uarr[$reporthead[4]] > 0) ? number_format(@($uarr[$reporthead[5]]/$uarr[$reporthead[4]]), 2 ) : '');
if($head == 15) {
$printval = ($uarr[$reporthead[4]] != 0) ? number_format(@($uarr[$reporthead[7]]/$uarr[$reporthead[4]]) * 100, 2 ) . '%' : '';
}
if($head == 16) {
$printval = ($uarr[$reporthead[4]] != 0) ? number_format(@($uarr[$reporthead[8]]/$uarr[$reporthead[4]]) * 100, 2 ) . '%' : '';
}
if($head == 17) {
$printval = ($uarr[$reporthead[4]] != 0) ? number_format(@($uarr[$reporthead[9]]/$uarr[$reporthead[4]]) * 100, 2 ) . '%' : '';
}
$colstr=PHPExcel_Cell::stringFromColumnIndex($head);
$objPHPExcel->getActiveSheet()->setCellValue($colstr.$row, $printval);
}
}
$row++;
for ($head = 0; $head < $highestColumn; $head++){
$printval = ($head != 6) ? $utotalarr[$reporthead[$head]] : (($utotalarr[$reporthead[4]] > 0) ? number_format(@($utotalarr[$reporthead[5]]/$utotalarr[$reporthead[4]]), 2 ) : '');
if($head == 15) {
$printval = ($utotalarr[$reporthead[4]] != 0) ? number_format(@($utotalarr[$reporthead[7]]/$utotalarr[$reporthead[4]]) * 100, 2 ) . '%' : '';
}
if($head == 16) {
$printval = ($utotalarr[$reporthead[4]] != 0) ? number_format(@($utotalarr[$reporthead[8]]/$utotalarr[$reporthead[4]]) * 100, 2 ) . '%' : '';
}
if($head == 17) {
$printval = ($utotalarr[$reporthead[4]] != 0) ? number_format(@($utotalarr[$reporthead[9]]/$utotalarr[$reporthead[4]]) * 100, 2 ) . '%' : '';
}
$colstr=PHPExcel_Cell::stringFromColumnIndex($head);
$objPHPExcel->getActiveSheet()->setCellValue($colstr.$row, $printval);
}
$baseRow = $row+3;
$highestColumn1 = sizeof($reporthead1);
for ($head = 0; $head < $highestColumn1; $head++){
$colstr=PHPExcel_Cell::stringFromColumnIndex($head);
$objPHPExcel->getActiveSheet()->setCellValue($colstr.$baseRow, $reporthead1[$head]);
}
$baseRow++;
foreach($reportarray1 as $uid=>$uarr)
{
$row = $baseRow++;
$col = 0;
for ($head = 0; $head < $highestColumn1; $head++){
$colstr=PHPExcel_Cell::stringFromColumnIndex($head);
$objPHPExcel->getActiveSheet()->setCellValue($colstr.$row, $uarr[$reporthead1[$head]]);
}
}
header('Content-Type: application/vnd.ms-excel');
header('Content-Disposition: attachment;filename="Campaignreport.xls"');
header('Cache-Control: max-age=0');
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, $inputFileType);
$objWriter->save('php://output');
return ;
}
?>
@include('layout.module.dialer.searchform')
<div style="overflow: auto; margin-top: 10px;">
<table id=logtable class='footable table table-striped table-bordered table-white table-primary footable-loaded' style='font-size:12px; margin:0; border:1px solid #BBB;'>
<thead><?php echo $outhead; ?></thead>
<?php echo $outstr; ?>
</table>
</div>
<div style="overflow: auto; margin-top: 10px;">
<table id=logtable class='footable table table-striped table-bordered table-white table-primary footable-loaded' style='font-size:12px; margin:0; border:1px solid #BBB;'>
<thead><?php echo $outhead1; ?></thead>
<?php echo $outstr1; ?>
</table>
</div>
</div>
<div class="layout-app"><!-- row-app -->
<div class="row row-app">
<!-- col -->
<div class="col-md-2 col-sm-3">
<!-- col-separator -->
<div class="col-separator col-separator-first box col-unscrollable">
<!-- col-table -->
<div class="col-table" style='padding-left: 13px;padding-right: 13px;'>
<h4 class="innerAll margin-none border-bottom" style='background: #fff;'>Campaign Admin</h4>
<!-- col-table-row -->
<div class="col-table-row">
<!-- col-app -->
<div class="col-app col-unscrollable">
<!-- col-app -->
<div class="col-app">
<ul class="list-group list-group-1 margin-none borders-none" style='padding-right: 26px;'>
<li class="list-group-item">
<a href="#" onclick="doAjax('dialer/camplist','','rightmainreportdiv','ajax_dialer_reports','singlethis','GET');return false"><i class="fa fa-circle-o"></i> List Campaigns</a>
</li>
<li class="list-group-item">
<a href="#" onclick="doAjax('dialer/campchurn','','rightmainreportdiv','ajax_dialer_reports','singlethis','GET');return false"><i class="fa fa-circle-o"></i> Churn Rules</a>
</li>
<?php if(Auth::user()->moduleACL("Dialer",true,true,true)){ ?>
<?php } ?>
</ul>
</div>
<!-- // END col-app -->
</div>
<!-- // END col-app -->
</div>
<!-- // END col-table-row -->
</div>
<!-- // END col-table -->
</div>
<!-- // END col-separator.box -->
</div>
<!-- // END col -->
<!-- col -->
<div class="col-md-10 col-sm-9" style='border-right:13px solid #eaeaea'>
<!-- col-separator.box -->
<div class="col-separator col-unscrollable box">
<!-- col-table -->
<div class="col-table">
<!-- <h4 class="innerAll margin-none border-bottom">My Sessions</h4> -->
<!-- col-table-row -->
<div class="col-table-row" style='background: #fff;'>
<!-- col-app -->
<div class="col-app col-unscrollable">
<!-- col-app -->
<div class="col-app" style='position:relative'>
<div class="" id=rightmainreportdiv>
<script>
//doAjax('dialer/campaign_list','','rightmainreportdiv','ajax_dialer_reports','singlethis','GET');
</script>
</div>
</div>
<!-- // END col-app -->
</div>
<!-- // END col-app.col-unscrollable -->
</div>
<!-- // END col-table-row -->
</div>
<!-- // END col-table -->
</div>
<!-- // END col-separator.box -->
</div>
<!-- // END col -->
</div>
<!-- // END row-app -->
</div>
<?php
use App\Models\CRMCall;
use App\Models\User;
use App\Jobs\KHRMSLib;
$wakka = new KHRMSLib();
$dashboarduser=Auth::user();
if(isset($_GET['logdate']))$logdate=strtotime($_GET['logdate']." 00:00:00");
else $logdate=strtotime(date('Y-m-d')." 00:00:00");
$alist=CRMCall::where('created_at','>=',date("Y-m-d H:i:s",$logdate))->where('created_at','<=',date("Y-m-d H:i:s",$logdate+24*60*60));
//if(!$dashboarduser->moduleACL("Dialer",false,false,true))
if($dashboarduser->usertype != 'Admin')
{
$uidlist=array($dashboarduser->id);
$allusers=User::where(function ($query) use($dashboarduser) {
$query->where('supervisor','=',$dashboarduser->username)
->orWhere('lteam2','=',$dashboarduser->username)
->orWhere('lteam','=',$dashboarduser->username);
})->get();
// ->where(function ($query) {
// $query->where('status', '=', 'Active');
// })->get();
foreach($allusers as $tuser)$uidlist[]=$tuser->id;
$roclientstr=array();$didlinesstr=array();
if($dashboarduser->exten!="")$didlinesstr[]=$dashboarduser->exten;
$oclientlst=$wakka->clientsReadAccess();
if(!empty($oclientlst))foreach($oclientlst as $tclnt)if($tclnt!="")
{
$roclientstr[]="$tclnt";
$mastersdata=$wakka->getCompanyMaster($tclnt);
if(!empty($mastersdata["DialerDID"]))$didlinesstr[]=$mastersdata["DialerDID"];
}
$alist=$alist->where(function ($query) use($roclientstr,$uidlist,$didlinesstr){
$query//->orWhereIn('client',$roclientstr)
->orWhereIn('user_id',$uidlist)
->orWhereIn('did',$didlinesstr);
});
}
$alist=$alist->get();
//$total=0;
$userarr=array();$i=1;
$reporthead=array("#","UserId","User","Name","Count","Total","Wait","Call","Talk","Dispo");
$reportarray=array();
foreach($alist as $aline)
{
if(!isset($userarr[$aline->user_id]))$userarr[$aline->user_id]=User::find($aline->user_id);
$tuser=$userarr[$aline->user_id];
if(!isset($reportarray[$aline->user_id]))$reportarray[$aline->user_id]=array("#"=>$i++,"UserId"=>$tuser->id,"User"=>$tuser->username,"Name"=>$tuser->fullname,"Count"=>0,"Total"=>0,"Wait"=>0,"Call"=>0,"Talk"=>0,"Dispo"=>0);
$talktime=$aline->talkSec+$aline->recstartSec+$aline->recendSec;
//$total+=round(($aline->waitSec+$aline->callSec+$talktime+$aline->dispoSec)/1000,2);
$reportarray[$aline->user_id]["Count"]++;
$reportarray[$aline->user_id]["Total"]+=round(($aline->waitSec+$aline->callSec+$talktime+$aline->dispoSec)/1000,2);
//$reportarray[$aline->user_id]["Total"]=gmdate("H:i:s",$reportarray[$aline->user_id]["Total"]+round(($aline->waitSec+$aline->callSec+$talktime+$aline->dispoSec)/1000,2));
//$reportarray[$aline->user_id]["Total"]=gmdate("H:i:s",$total);
//$reportarray[$aline->user_id]["Total"]+=gmdate("H:i:s",round(($aline->waitSec+$aline->callSec+$talktime+$aline->dispoSec)/1000,2));
$reportarray[$aline->user_id]["Wait"]+=round($aline->waitSec/1000,2);
$reportarray[$aline->user_id]["Call"]+=round($aline->callSec/1000,2);
$reportarray[$aline->user_id]["Talk"]+=round($talktime/1000,2);
$reportarray[$aline->user_id]["Dispo"]+=round($aline->dispoSec/1000,2);
}
if(Input::has("dllogxls"))
{
include_once(app_path().'/lib/phpexcel/PHPExcel.php');
$inputFileType = "Excel5";
$objReader = PHPExcel_IOFactory::createReader($inputFileType);
$objPHPExcel = $objReader->load("assets/extras/blank.xls");
$baseRow = 3;
$highestColumn = sizeof($reporthead);
for ($head = 0; $head < $highestColumn; $head++){
$colstr=PHPExcel_Cell::stringFromColumnIndex($head);
$objPHPExcel->getActiveSheet()->setCellValue($colstr."1", $reporthead[$head]);
}
foreach($reportarray as $uid=>$uarr)
{
$row = $baseRow++;
$col = 0;
for ($head = 0; $head < $highestColumn; $head++){
$colstr=PHPExcel_Cell::stringFromColumnIndex($head);
$objPHPExcel->getActiveSheet()->setCellValue($colstr.$row, $uarr[$reporthead[$head]]);
}
}
header('Content-Type: application/vnd.ms-excel');
header('Content-Disposition: attachment;filename="TimeLog.xls"');
header('Cache-Control: max-age=0');
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, $inputFileType);
$objWriter->save('php://output');
return ;
}
$highestColumn = sizeof($reporthead);
$outhead="<tr>";$outstr="";
for ($head = 0; $head < $highestColumn; $head++){
$outhead.="<td>".$reporthead[$head]."</td>";
}
$outhead.="</tr>";
foreach($reportarray as $uid=>$uarr)
{
if(!empty($uarr['UserId'])){
$outstr.="<tr>";
for ($head = 0; $head < $highestColumn; $head++){
$outstr.="<td>".$uarr[$reporthead[$head]]."</td>";
}
$outstr.="</tr>";
}else{
$outstr.="<tr>";
for ($head = 0; $head < $highestColumn; $head++){
if($reporthead[$head]=='UserId'){
$outstr.="<td>Inbound</td>";
}else{
$outstr.="<td>".$uarr[$reporthead[$head]]."</td>";
}
}
$outstr.="</tr>";
}
}
/*
foreach($reportarray as $uid=>$uarr)
{
$outstr.="<tr>";
for ($head = 0; $head < $highestColumn; $head++){
$outstr.="<td>".$uarr[$reporthead[$head]]."</td>";
}
$outstr.="</tr>";
}
*/
//charts
$cat1=array();
$cat1arr=array();
foreach($reportarray as $uid=>$uarr)
{
$cat1[]="'$uarr[UserName]'";
for ($head = 5; $head < $highestColumn; $head++){
if(!isset($cat1arr[$reporthead[$head]]))$cat1arr[$reporthead[$head]]=array();
$cat1arr[$reporthead[$head]][$uarr["#"]]=round($uarr[$reporthead[$head]]/60,1);
if(empty($cat1arr[$reporthead[$head]][$uarr["#"]]))$cat1arr[$reporthead[$head]][$uarr["#"]]=0;
}
}
$cat1arrstr="";
foreach($cat1arr as $name=>$data)
{
$cat1arrstr.="{ name: '$name',\ndata : [";
$cat1arrstr.=implode(",",$data);
$cat1arrstr.="] },\n";
}
$cat2=array();
foreach($reportarray as $uid=>$uarr)
{
for ($head = 5; $head < $highestColumn; $head++){
$cat2["'".$reporthead[$head]."'"]+=round($uarr[$reporthead[$head]]/60,1);
}
}
?>
<div class=innerAll>
<style>#logtable.td{vertical-align:top;}#logtable.tr{height:28px;overflow-y:hidden;}</style>
<script>
$(document).ready(function()
{
if(!$('#dialoglog').hasClass('ui-dialog-content'))
{
$('#dialoglog').dialog({
autoOpen: false,
width: '70%',
buttons: {
"Ok": function() {
$(this).dialog("close");
},
"Cancel": function() {
$(this).dialog("close");
}
}
});
}
waitKeyUpRun("filter",function() { filter2(document.getElementById('filter'), 'logtable') },"2000");
$('#modfrom').datepicker({dateFormat: 'yy-mm-dd',inline: true,changeYear: true,selectOtherMonths: true,yearRange: '<?php echo (date('Y')-70).":".(date('Y')+5); ?>'});
});
</script>
<div style="float:left;width:50%">
Search <input id=filter name="filter" type="text">
Date : <input size=10 id='modfrom' name='modfrom' type='text' value='<?php echo date("Y-m-d",$logdate); ?>' onchange='campLogReloadFun("");' />
</div>
<div style="float:left;width:50%">
<button class="pull-right btn btn-sm btn-default" onclick='dlAgentlogXls();return false;' title='Download' style='margin-top:-8px'><i class='fa fa-download'></i> Download</button>
</div>
<div style="clear:both"></div>
<hr>
<!--div class=col-md-12>
<div id=userlogschart1 style='min-height:300px;width:100%'></div>
<script>
$(function () {
$('#userlogschart1').highcharts({
chart: {
type: 'column'
},
title: {
text: ''
},
xAxis: {
labels:{
enabled:false//default is true
},
categories: [<?php echo implode(",",$cat1); ?>]
},
yAxis: {
min: 0,
title: {
text: ''
},
stackLabels: {
enabled: false,
// style: {
// fontWeight: '',
// color: (Highcharts.theme && Highcharts.theme.textColor) || 'gray'
// }
}
},
// legend: {
// align: 'right',
// x: -30,
// verticalAlign: 'top',
// y: 25,
// floating: true,
// backgroundColor: (Highcharts.theme && Highcharts.theme.background2) || 'white',
// borderColor: '#CCC',
// borderWidth: 1,
// shadow: false
// },
tooltip: {
headerFormat: '<b>{point.x}</b><br/>',
pointFormat: '{series.name}: {point.y}<br/>Total: {point.stackTotal}'
},
plotOptions: {
column: {
stacking: 'normal',
dataLabels: {
enabled: false,
// color: (Highcharts.theme && Highcharts.theme.dataLabelsColor) || 'white',
// style: {
// textShadow: '0 0 3px black'
// }
}
}
},
series: [<?php echo $cat1arrstr; ?>]
});
});
function campLogReloadFun(sortby)
{
var sortstr='';if(sortby!="")sortstr="&sort="+sortby
doAjax('dialer/campreport?logdate='+$("#modfrom").val()+sortstr,'','rightmainreportdiv','ajax_dialer_reports','singlethis','GET');
}
function dlAgentlogXls()
{
window.open('dialer/campreport?dllogxls=1&logdate='+$("#modfrom").val());return false;
}
</script>
</div -->
<script>
function campLogReloadFun(sortby)
{
var sortstr='';if(sortby!="")sortstr="&sort="+sortby
doAjax('dialer/campreport?logdate='+$("#modfrom").val()+sortstr,'','rightmainreportdiv','ajax_dialer_reports','singlethis','GET');
}
function dlAgentlogXls()
{
window.open('dialer/campreport?dllogxls=1&logdate='+$("#modfrom").val());return false;
}
</script>
<div style='clear:both'></div>
<div class=col-md-12>
<div id=userlogschart2 style='min-height:300px;width:100%'></div>
<script>
$(function () {
$('#userlogschart2').highcharts({
chart: {
type: 'column'
},
title: {
text: ''
},
subtitle: {
text: ''
},
xAxis: {
categories: [<?php echo implode(",",array_keys($cat2)); ?>],
crosshair: true
},
yAxis: {
min: 0,
title: {
text: ''
}
},
tooltip: {
headerFormat: '<span style="font-size:10px">{point.key}</span><table>',
pointFormat: '<tr><td style="color:{series.color};padding:0">{series.name}: </td>' +
'<td style="padding:0"><b>{point.y:.1f}</b></td></tr>',
footerFormat: '</table>',
shared: true,
useHTML: true
},
plotOptions: {
column: {
pointPadding: 0.2,
borderWidth: 0
}
},
legend : {
floating: true,
align: 'right',
x: -30,
verticalAlign: 'top',
},
series: [{
name: 'Mins',
data: [<?php echo implode(",",array_values($cat2)); ?>]
},]
});
});
</script>
</div>
<div style='clear:both'></div>
<div style='overflow:auto'>
<table id=logtable class='footable table table-striped table-bordered table-white table-primary footable-loaded' style='font-size:12px'>
<thead>
<?php echo $outhead; ?>
</thead>
<?php echo $outstr; ?>
</table>
</div>
<div id=dialoglog></div>
</div>
<?php
use App\Models\CRMCall;
use App\Models\User;
use App\Jobs\KHRMSLib;
use App\Models\SupervisonComments;
$wakka = new KHRMSLib();
$dashboarduser=Auth::user();
if(isset($_GET['logdate']))$logdate=strtotime($_GET['logdate']." 00:00:00");
else $logdate=strtotime(date('Y-m-d')." 00:00:00");
if(isset($_GET['logtodate']))$logtodate=strtotime($_GET['logtodate']." 23:59:59");
else $logtodate=strtotime(date('Y-m-d')." 23:59:59");
$userarr=array();$i=1;
$reporthead=array("id","upload_date","call_id","cust_band","cust_type","source_of_info","service_type","priority","category","sub_category","resolving_branch","cust_city","acknowledge","resolve_class_unit","complainant_name","existing_customer","cust_id","shadow_cust_id","casa_number","docket_number","cust_mobile","contact_number","email","case_reference","logging_branch_name","logging_class_unit","nature_of_complaint","detailed_suggestion","additional_info","cust_name_on_card","card_number","aan","logging_branch_code","resolving_branch_code","status");
$reportarray=DB::table('complaint_details')->select('*')->where('upload_date','>=',date("Y-m-d H:i:s",$logdate))->where('upload_date','<=',date("Y-m-d H:i:s",$logtodate))->get();
//Child Case
if(isset($_GET['clogdate']))$clogdate=strtotime($_GET['clogdate']." 00:00:00");
else $clogdate=strtotime(date('Y-m-d')." 00:00:00");
if(isset($_GET['clogtodate']))$clogtodate=strtotime($_GET['clogtodate']." 23:59:59");
else $clogtodate=strtotime(date('Y-m-d')." 23:59:59");
$cuserarr=array();$i=1;
$creporthead=array("id","upload_date","complaint_id","cust_type","service_type","priority","category","sub_category","resolving_branch","resolve_class_unit","complainant_name","comments","task_desc","additional_info","status");
$creportarray=DB::table('comp_child_details')->select('*')->where('upload_date','>=',date("Y-m-d H:i:s",$clogdate))->where('upload_date','<=',date("Y-m-d H:i:s",$clogtodate))->get();
if(Input::has("dllogxls"))
{
include_once(app_path().'/lib/phpexcel/PHPExcel.php');
$inputFileType = "Excel5";
$objReader = PHPExcel_IOFactory::createReader($inputFileType);
$objPHPExcel = $objReader->load("assets/extras/blank.xls");
$baseRow = 2;
$highestColumn = sizeof($reporthead);
for ($head = 0; $head < $highestColumn; $head++){
$colstr=PHPExcel_Cell::stringFromColumnIndex($head);
$objPHPExcel->getActiveSheet()->setCellValue($colstr."1", $reporthead[$head]);
}
foreach($reportarray as $uid=>$uarr)
{
$row = $baseRow++;
$col = 0;
for ($head = 0; $head < $highestColumn; $head++){
if($reporthead[$head]=="upload_date")
$uarr->$reporthead[$head]=date("Y-m-d H:i:s",strtotime($uarr->$reporthead[$head])+330*60);
$colstr=PHPExcel_Cell::stringFromColumnIndex($head);
$objPHPExcel->getActiveSheet()->setCellValue($colstr.$row, $uarr->$reporthead[$head]);
}
}
header('Content-Type: application/vnd.ms-excel');
header('Content-Disposition: attachment;filename="Complaint.xls"');
header('Cache-Control: max-age=0');
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, $inputFileType);
$objWriter->save('php://output');
return ;
}
if(Input::has("cdllogxls"))
{
include_once(app_path().'/lib/phpexcel/PHPExcel.php');
$inputFileType = "Excel5";
$objReader = PHPExcel_IOFactory::createReader($inputFileType);
$objPHPExcel = $objReader->load("assets/extras/blank.xls");
$baseRow = 2;
$highestColumn = sizeof($creporthead);
for ($head = 0; $head < $highestColumn; $head++){
$colstr=PHPExcel_Cell::stringFromColumnIndex($head);
$objPHPExcel->getActiveSheet()->setCellValue($colstr."1", $creporthead[$head]);
}
foreach($creportarray as $uid=>$uarr)
{
$row = $baseRow++;
$col = 0;
for ($head = 0; $head < $highestColumn; $head++){
if($creporthead[$head]=="upload_date")
$uarr->$reporthead[$head]=date("Y-m-d H:i:s",strtotime($uarr->$creporthead[$head])+330*60);
$colstr=PHPExcel_Cell::stringFromColumnIndex($head);
$objPHPExcel->getActiveSheet()->setCellValue($colstr.$row, $uarr->$creporthead[$head]);
}
}
header('Content-Type: application/vnd.ms-excel');
header('Content-Disposition: attachment;filename="Childcase.xls"');
header('Cache-Control: max-age=0');
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, $inputFileType);
$objWriter->save('php://output');
return ;
}
?>
<div class=innerAll>
<style>#logtable.td{vertical-align:top;}#logtable.tr{height:28px;overflow-y:hidden;}</style>
<script>
$(document).ready(function()
{
if(!$('#dialoglog').hasClass('ui-dialog-content'))
{
$('#dialoglog').dialog({
autoOpen: false,
width: '70%',
buttons: {
"Ok": function() {
$(this).dialog("close");
},
"Cancel": function() {
$(this).dialog("close");
}
}
});
}
waitKeyUpRun("filter",function() { filter2(document.getElementById('filter'), 'logtable') },"2000");
$('#modfrom').datepicker({dateFormat: 'yy-mm-dd',inline: true,changeYear: true,selectOtherMonths: true,yearRange: '<?php echo (date('Y')-70).":".(date('Y')+5); ?>'});
$('#modto').datepicker({dateFormat: 'yy-mm-dd',inline: true,changeYear: true,selectOtherMonths: true,yearRange: '<?php echo (date('Y')-70).":".(date('Y')+5); ?>'});
$('#cmodfrom').datepicker({dateFormat: 'yy-mm-dd',inline: true,changeYear: true,selectOtherMonths: true,yearRange: '<?php echo (date('Y')-70).":".(date('Y')+5); ?>'});
$('#cmodto').datepicker({dateFormat: 'yy-mm-dd',inline: true,changeYear: true,selectOtherMonths: true,yearRange: '<?php echo (date('Y')-70).":".(date('Y')+5); ?>'});
});
</script>
<div style="float:left;width:50%">
From : <input size=10 id='modfrom' name='modfrom' type='text' value='<?php echo date("Y-m-d",$logdate); ?>' />
&nbsp;&nbsp;To : <input size=10 id='modto' name='modto' type='text' value='<?php echo date("Y-m-d",$logtodate); ?>' />
</div>
<div style="float:right;width:50%">
<button class="pull-right btn btn-sm btn-default" onclick='dlAgentlogXls();return false;' title='Download' style='margin-top:-8px'><i class='fa fa-download'></i> Download</button>
</div>
<div style="clear:both"></div>
<hr>
<br>
<!--
<div style="float:left;width:50%">
<label>Child Case:</label>&nbsp;
From : <input size=10 id='cmodfrom' name='cmodfrom' type='text' value='<?php echo date("Y-m-d",$logdate); ?>' />
&nbsp;&nbsp;To : <input size=10 id='cmodto' name='cmodto' type='text' value='<?php echo date("Y-m-d",$logtodate); ?>' />
</div>
<div style="float:right;width:50%">
<button class="pull-right btn btn-sm btn-ino" onclick='cdlAgentlogXls();return false;' title='Download' style='margin-top:-8px'><i class='fa fa-download'></i> Download</button>
</div>--!>
<div style="clear:both"></div>
<hr>
<div class=col-md-12>
<div id=userlogschart1 style='min-height:300px;width:100%'></div>
</div>
<script>
function dlAgentlogXls()
{
window.open('dialer/complaintreport?dllogxls=1&logdate='+$("#modfrom").val()+'&logtodate='+$("#modto").val());return false;
}
function cdlAgentlogXls()
{
window.open('dialer/complaintreport?cdllogxls=1&clogdate='+$("#cmodfrom").val()+'&clogtodate='+$("#cmodto").val());return false;
}
</script>
<div style='clear:both'></div>
<div class=col-md-12>
<div id=userlogschart2 style='min-height:300px;width:100%'></div>
</div>
<div style='clear:both'></div>
<div style='overflow:auto'>
<table id=logtable class='footable table table-striped table-bordered table-white table-primary footable-loaded' style='font-size:12px'>
<thead>
<?php /*echo $outhead;*/ ?>
</thead>
<?php /*echo $outstr;*/ ?>
</table>
</div>
<div id=dialoglog></div>
</div>
<?php
$dashboarduser=Auth::user();
$timeoffset=$dashboarduser->timezone*60;
?>
<div class="container-fluid">
<div class="layout-app">
<div class="row">
<div class="col-md-12">
<div class="col-separator col-separator-first col-unscrollable box">
<div class="innerAll">
<h4>Follow up <?php if(!empty($client)) echo ": ".$client; ?></h4>
<hr style="margin-bottom: 10px;" />
<table class='table'
<thead>
<tr>
<th></th>
<th></th>
<?php if(empty($client)) echo "<th>Campaign</th>" ?>
<th>Cust_ID</th>
<th>Name</th>
<th>Number</th>
<!-- <th>Type</th>-->
<th>LastCall</th>
<!-- <th>Disposition</th> --->
<th>NextFollowup</th>
<!--- <th>Status</th> --->
<!-- <th>Count</th> -->
<!--<th></th>-->
<!-- <th>DID</th> -->
</tr>
</thead>
<tbody>
<?php
if($count > 0){
foreach ($calllog as $key => $value) { //echo "<pre>";print_r($value);exit;?>
<tr>
<td></td>
<td></td>
<?php if(empty($client)) echo "<td>$value->client</td>" ?>
<td><?php echo $value->cust_id; ?></td>
<td><?php echo $value->customer_name; ?></td>
<td><a href=# class='' onclick='dialerQuickOpen("<?php echo $value->id; ?>","<?php echo $value->mobile; ?>","Manual","",0);return false;'><?php echo $value->mobile; ?></a></td>
<td><?php echo date("Y-m-d H:i:s",strtotime($value->dialer_lastcall)-$timeoffset); ?></td>
<!--<td><?php //echo $value->dialer_status; ?></td>-->
<td><?php echo date("Y-m-d H:i:s",strtotime($value->dialer_callback)-$timeoffset); ?></td>
<!--<td><?php //echo $value->status; ?></td>-->
</tr>
<?php }
}else{ ?>
<td colspan="9" align="center">No Record Available</td>
<?php } ?>
</table>
<div id="campaignDetailsArea"></div>
</div>
</div>
</div>
</div>
</div>
</div>
<?php
use App\Models\CRMCall;
use App\Models\CRMCallArchive;
use App\Models\User;
use App\Models\UserLog;
use App\Jobs\KHRMSLib;
$wakka = new KHRMSLib();
$dashboarduser=Auth::user();
$timeoffset = $dashboarduser->timezone; //-330; //$dashboarduser->timezone;
$timeoffset = $timeoffset*60;
$logtime =(isset($_GET['logtime'])) ? $_GET['logtime'] :9;
$logtimeto =(isset($_GET['logtimeto']))? $_GET['logtimeto']:20;
$logdate =(isset($_GET['logdate'])) ? strtotime($_GET['logdate']." ".$logtime.":00:00")
: strtotime(date("Y-m-d")." 09:00:00");
$logdateto =(isset($_GET['logdateto']))? strtotime($_GET['logdateto']." ".$logtimeto.":00:00")
: strtotime(date("Y-m-d")." 20:00:00");
$oclientlst=$wakka->clientsReadAccess(); sort($oclientlst);
$alist=CRMCallArchive::whereIn('client',$oclientlst)->where('created_at','>=',date("Y-m-d H:i:s",$logdate+$timeoffset))->where('created_at','<=',date("Y-m-d H:i:s",$logdateto+$timeoffset))->orderBy('user_id', 'ASC')->orderBy('ts_Close', 'ASC')->get();
$userlog=UserLog::where('created_at','>=',date("Y-m-d H:i:s",$logdate+$timeoffset))->where('created_at','<=',date("Y-m-d H:i:s",$logdateto+$timeoffset))->get();
$total_Accounts_loaded=DB::table('records')->whereIn('client',$oclientlst)->get();
$breaks=array("AgentBriefing","TeamMeeting","QualityFeedback","LunchBreak","TeaBreak","UtilityBreak","FloorAnnouncements","DownTime");
$reporthead=array("Campaigns","Accounts Loaded","LoggedIn users","Unique accounts dialled","Total accounts Dialled","Disposed Calls","Contacts","RPC","PTP","Preview","Wrap","Idle","Talk","Hold");
$reportarray=array();
$campaign_wisearr= array();
$camp_userlist=array();
$uniquenumberarray=array();
$prev_close = 0;
foreach ($alist as $key => $value) {
if (!array_key_exists($value->client, $camp_userlist)) $camp_userlist[$value->client]=[];
if (!in_array($value->user_id, $camp_userlist[$value->client])) $camp_userlist[$value->client][]=$value->user_id;
$campaign_wisearr[$value->client]["LoggedIn users"] = count($camp_userlist[$value->client]);
$campaign_wisearr[$value->client]["Campaigns"] = $value->client;
$campaign_wisearr[$value->client]["Total accounts Dialled"]++;
if (!array_key_exists($value->client, $uniquenumberarray)) $uniquenumberarray[$value->client]=[];
if (!in_array($value->number, $uniquenumberarray[$value->client])) $uniquenumberarray[$value->client][]=$value->number;
$campaign_wisearr[$value->client]["Unique accounts dialled"] = count($uniquenumberarray[$value->client]);
if($value->userstatus == 'Contacted') {
$campaign_wisearr[$value->client]["Disposed Calls"]++;
}
if($value->resultCode =='PTP'|| $value->resultCode =='CB'||$value->resultCode =='RTP'||$value->resultCode =='CEREP'||$value->resultCode =='PV'||$value->resultCode =='DEAD'||$value->resultCode =='LM'||$value->resultCode =='TPC') {
$campaign_wisearr[$value->client]["Contacts"]++;
}
if($value->resultCode == 'PTP' || $value->resultCode == 'CEREP' || $value->resultCode == 'PV') {
$campaign_wisearr[$value->client]["PTP"]++;
}
if($value->resultCode == 'PTP' || $value->resultCode == 'CB' || $value->resultCode == 'CEREP' || $value->resultCode == 'RTP' || $value->resultCode == 'PV') {
$campaign_wisearr[$value->client]["RPC"]++;
}
if($prev_user != $value->user_id || $prev_close <= $value->ts_Wait)
{
$talktime=$value->talkSec+$value->recstartSec+$value->recendSec;
$totaltime=$value->callSec+$talktime+$value->dispoSec;
$campaign_wisearr[$value->client]["oncall"]+=$totaltime/1000;
// $campaign_wisearr[$value->client]["Preview"]+=$value->waitSec/1000;
$campaign_wisearr[$value->client]["Hold"]+=$value->callSec/1000;
$campaign_wisearr[$value->client]["Talk"]+=$talktime/1000;
$campaign_wisearr[$value->client]["Wrap"]+=$value->dispoSec/1000;
}
$prev_close = $value->ts_Close;//-ts_Wait
$prev_user = $value->user_id;//-ts_Wait
}
function cmp($a, $b) {
return $a["ts"] - $b["ts"];
}
$userLogin=array();
$checkhead = array_merge($reporthead, $breaks);
foreach($userlog as $ulog)
{
$data=json_decode($ulog->data,true);
usort($data, "cmp");
$lastSip = end($data);
$starttime = strtotime($ulog->startdate.' '.$ulog->starttime);
$endtime = round($lastSip['ts']/1000);
$userLogin[$ulog->user_id]['duration'] += ($endtime-$starttime);
$prets=strtotime($ulog->startdate." ".$ulog->starttime)*1000;
$previous="Paused-Paused";
foreach($data as $sdata)
{
$pts=$sdata['ts'];
if(isset($sdata['states']))
{
foreach($sdata['states'] as $ts=>$states)
{
$previous = str_replace('Paused-', '', $previous);
if(!in_array($previous,$checkhead) && !in_array($previous,array('Progressive-','Manual-','Ready-Incoming','Ready-Predictive','DialNext-'))) {
$previous = 'Paused';
}
$reportarray[$ulog->user_id][$previous]+=round($ts-$prets,2)/1000;
$prets=$ts;
$previous=$states[0].'-'.$states[1];
}
$previous = str_replace('Paused-', '', $previous);
$reportarray[$ulog->user_id][$previous]+=round($pts-$prets,2)/1000;
$prets=$pts;
}
}
}
if(count($userLogin)) foreach ($userLogin as $userid => $value)
{
$break_time=0;
foreach ($breaks as $break) {
$break_time+=$reportarray[$userid][$break];
}
$reportarray[$userid]["Duration"]=$value['duration'];
$reportarray[$userid]["Total"]=$value['duration']-$break_time-$reportarray[$userid]['Paused'];
$reportarray[$userid]["Preview"]=$reportarray[$userid]["Total"]-$reportarray[$userid]['oncall'];
$reportarray[$userid]["Breaks"]=$break_time;
$reportarray[$userid]["Idle"]=$reportarray[$userid]['Paused'];
}
$i=1;
foreach ($camp_userlist as $campaign => $campaignUserCountArr) {
// $campaign_wisearr[$campaign]['#']= $i++;
foreach ($campaignUserCountArr as $eachCampaignUserCount) {
if(array_key_exists($eachCampaignUserCount, $reportarray)) {
$campaign_wisearr[$campaign]['Duration'] += $reportarray[$eachCampaignUserCount]['Duration'];
$campaign_wisearr[$campaign]['Idle'] += $reportarray[$eachCampaignUserCount]['Idle'];
$campaign_wisearr[$campaign]['Breaks'] += $reportarray[$eachCampaignUserCount]['Breaks'];
$campaign_wisearr[$campaign]['Preview'] += $reportarray[$eachCampaignUserCount]['Preview'];
$campaign_wisearr[$campaign]['Total'] += $reportarray[$eachCampaignUserCount]['Total'];
}
}
}
foreach ($total_Accounts_loaded as $key => $value) {
$campaign_wisearr[$value->client]["Campaigns"] = $value->client;
$campaign_wisearr[$value->client]['Accounts Loaded']++;
}
$highestColumn = sizeof($reporthead);
if(count($campaign_wisearr)) {
$outhead="<tr>";$outstr="";
for ($head = 0; $head < $highestColumn; $head++){
if($reporthead[$head] == '#') {
$mode_str = "<a onclick='displayMode(".'"summation"'.");return false;' href='#'><i class='fa fa-plus-square-o'></i></a> / <a onclick='displayMode(".'"percent"'.");return false;' href='#'>%</a>";
$outhead.="<td>".$mode_str."</td>";
}
else {
$outhead.="<td>".$reporthead[$head]."</td>";
}
}
$outhead.="</tr>";
$utotalarr = array("Campaigns"=>'Total');
foreach($campaign_wisearr as $uid=>$uarr)
{
$outstr.="<tr>";
for ($head = 0; $head < $highestColumn; $head++){
if($head < 1) {
$data_str = $uarr[$reporthead[$head]];
}
elseif($head < 9) {
$data_str = $uarr[$reporthead[$head]];
$utotalarr[$reporthead[$head]] += $uarr[$reporthead[$head]];
}
else {
$data_str = secToDuration(round($uarr[$reporthead[$head]]));
$utotalarr[$reporthead[$head]] += $uarr[$reporthead[$head]];
}
$outstr.="<td>".$data_str."</td>";
}
$outstr.="</tr>";
}
$outstr.="<tr>";
for ($head = 0; $head < $highestColumn; $head++)
{
if($head < 9) {
$data_str = $utotalarr[$reporthead[$head]];
}
else {
$data_str = secToDuration($utotalarr[$reporthead[$head]]);
}
$outstr.="<td>".$data_str."</td>";
}
$outstr.="</tr>";
}
else
{
$outhead.="<tr><td>No Records Found.</td></tr>";
}
if(Input::has("dllogxls"))
{
include_once(app_path().'/lib/phpexcel/PHPExcel.php');
$inputFileType = "Excel5";
$objReader = PHPExcel_IOFactory::createReader($inputFileType);
$objPHPExcel = $objReader->load("assets/extras/blank.xls");
$baseRow = 2;
$highestColumn = sizeof($reporthead);
for ($head = 0; $head < $highestColumn; $head++){
$colstr=PHPExcel_Cell::stringFromColumnIndex($head);
$objPHPExcel->getActiveSheet()->setCellValue($colstr."1", $reporthead[$head]);
}
foreach($campaign_wisearr as $uid=>$uarr)
{
$row = $baseRow++;
$col = 0;
for ($head = 0; $head < $highestColumn; $head++){
$excelval = ($head < 6) ? $uarr[$reporthead[$head]] : secToDuration(round($uarr[$reporthead[$head]]));
$colstr=PHPExcel_Cell::stringFromColumnIndex($head);
$objPHPExcel->getActiveSheet()->setCellValue($colstr.$row, $excelval);
}
}
$row++;
for ($head = 0; $head < $highestColumn; $head++){
$excelval = ($head < 6) ? $utotalarr[$reporthead[$head]] : secToDuration(round($utotalarr[$reporthead[$head]]));
$colstr=PHPExcel_Cell::stringFromColumnIndex($head);
$objPHPExcel->getActiveSheet()->setCellValue($colstr.$row, $excelval);
}
header('Content-Type: application/vnd.ms-excel');
header('Content-Disposition: attachment;filename="Campaignlevel.xls"');
header('Cache-Control: max-age=0');
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, $inputFileType);
$objWriter->save('php://output');
return ;
}
function secToDuration($sec) {
return sprintf("%02d%s%02d%s%02d", floor($sec/3600), ':', ($sec/60)%60, ':', $sec%60);
}
?>
<style>#logtable.td{vertical-align:top;}#logtable.tr{height:28px;overflow-y:hidden;}</style>
<div class=innerAll>
<h4 style="float:left;width:50%;margin:10px 0;">Campaign Level Report</h4>
<div style="float:right;width:50%">
<button class='pull-right btn btn-sm btn-default' onclick='dlAgentlogXls();return false;' title='Download'><i class='fa fa-download'></i> Download</button>
</div>
<div style="clear:both"></div>
<hr style="margin-bottom: 5px;">
<div>
Search <input id=filter name="filter" type="text" style="border:1px solid #efefef; padding: 2px 10px;">&nbsp;&nbsp;
Date: From <input size=10 id='modfrom' name='modfrom' type='text' value='<?php echo date("Y-m-d",$logdate); ?>' onchange='statusLogReloadFun("");' />
<select id="modtime" style="border:1px solid #efefef;" onchange='statusLogReloadFun("");'>
<?php
foreach (range(0,23) as $hour) {
$selected = ($hour == $logtime) ? "selected" : "";
echo "<option value='$hour' $selected>".str_pad($hour, 2, "0", STR_PAD_LEFT) . ":00</option>";
}
?></select>
To <input size=10 id='modto' name='modto' type='text' value='<?php echo date("Y-m-d",$logdateto); ?>' onchange='statusLogReloadFun("");' />
<select id="modtimeto" style="border:1px solid #efefef;" onchange='statusLogReloadFun("");'>
<?php
foreach (range(0,23) as $hour) {
$selected = ($hour == $logtimeto) ? "selected" : "";
echo "<option value='$hour' $selected>".str_pad($hour, 2, "0", STR_PAD_LEFT) . ":00</option>";
}
?></select>
</div>
<div style="clear:both"></div>
<hr style="margin:5px;">
<div style="overflow: auto; margin-top: 10px;">
<table id=logtable class='footable table table-striped table-bordered table-white table-primary footable-loaded' style='font-size:12px; margin:0; border:1px solid #BBB;'>
<thead><?php echo $outhead; ?></thead>
<?php echo $outstr; ?>
</table>
</div>
<div id=dialoglog></div>
</div>
<script>
$(document).ready(function() {
if(!$('#dialoglog').hasClass('ui-dialog-content'))
{
$('#dialoglog').dialog({
autoOpen: false,
width: '70%',
buttons: {
"Ok": function() {
$(this).dialog("close");
},
"Cancel": function() {
$(this).dialog("close");
}
}
});
}
waitKeyUpRun("filter",function() { filter2(document.getElementById('filter'), 'logtable') },"2000");
$('#modfrom').datepicker({dateFormat: 'yy-mm-dd',inline: true,changeYear: true,selectOtherMonths: true,yearRange: '<?php echo (date('Y')-70).":".(date('Y')+5); ?>'});
$('#modto').datepicker({dateFormat: 'yy-mm-dd',inline: true,changeYear: true,selectOtherMonths: true,yearRange: '<?php echo (date('Y')-70).":".(date('Y')+5); ?>'});
});
function dataString()
{
return 'logdate='+$("#modfrom").val()+'&logtime='+$("#modtime").val()+'&logdateto='+$("#modto").val()+'&logtimeto='+$("#modtimeto").val()+'&campaign=All';//+$("#campaign").val();
}
function statusLogReloadFun(sortby)
{
var sortstr='';if(sortby!="")sortstr="&sort="+sortby
var searchStr = dataString();
doAjax('dialer/campaignlevel?'+searchStr+sortstr,'','rightmainreportdiv','ajax_dialer_reports','singlethis','GET');
}
function dlAgentlogXls()
{
var searchStr = dataString();
window.open('dialer/campaignlevel?dllogxls=1&'+searchStr);
return false;
}
</script>
\ No newline at end of file
<?php
use App\Models\CRMCall;
use App\Models\User;
use App\Jobs\KHRMSLib;
$wakka = new KHRMSLib();
$dashboarduser=Auth::user();
if(isset($_GET['logdate']))$logdate=strtotime($_GET['logdate']." 00:00:00");
else $logdate=strtotime(date('Y-m-d')." 00:00:00");
if(isset($_GET['logtodate']))$logtodate=strtotime($_GET['logtodate']." 23:59:59");
else $logtodate=strtotime(date('Y-m-d')." 23:59:59");
$alist=CRMCall::where('created_at','>=',date("Y-m-d H:i:s",$logdate))->where('created_at','<=',date("Y-m-d H:i:s",$logdate+24*60*60));
//if(!$dashboarduser->moduleACL("Dialer",false,false,true))
if($dashboarduser->usertype != 'Admin')
{
$uidlist=array($dashboarduser->id);
$allusers=User::where(function ($query) use($dashboarduser) {
$query->where('supervisor','=',$dashboarduser->username)
->orWhere('lteam2','=',$dashboarduser->username)
->orWhere('lteam','=',$dashboarduser->username);
})->get();
// ->where(function ($query) {
// $query->where('status', '=', 'Active');
// })->get();
foreach($allusers as $tuser)$uidlist[]=$tuser->id;
$roclientstr=array();$didlinesstr=array();
if($dashboarduser->exten!="")$didlinesstr[]=$dashboarduser->exten;
$oclientlst=$wakka->clientsReadAccess();
if(!empty($oclientlst))foreach($oclientlst as $tclnt)if($tclnt!="")
{
$roclientstr[]="$tclnt";
$mastersdata=$wakka->getCompanyMaster($tclnt);
if(!empty($mastersdata["DialerDID"]))$didlinesstr[]=$mastersdata["DialerDID"];
}
$alist=$alist->where(function ($query) use($roclientstr,$uidlist,$didlinesstr){
$query->orWhereIn('client',$roclientstr)
->orWhereIn('user_id',$uidlist)
->orWhereIn('did',$didlinesstr);
});
}
$alist=$alist->get();
$userarr=array();$i=1;
$reporthead=array("id","created_at","updated_at","user_id","cust_id","call_id","name","number","question_time","question","primary_question","primary_response","primary_text","followup1_question","followup1_response","followup1_text","followup2_question","followup2_response","followup2_text","followup3_question","followup3_response","followup3_text","followup4_question","followup4_response","followup4_text","followup5_question","followup5_response","followup5_text","followup6_question","followup6_response","followup6_text","followup7_question","followup7_response","followup7_text");
//$reportarray=DB::table('questionaire_details')->select('*')->get();
$reportarray=DB::table('questionaire_details')->select('*')->where('updated_at','>=',date("Y-m-d H:i:s",$logdate))->where('updated_at','<=',date("Y-m-d H:i:s",$logtodate))->get();
if(Input::has("dllogxls"))
{
include_once(app_path().'/lib/phpexcel/PHPExcel.php');
$inputFileType = "Excel5";
$objReader = PHPExcel_IOFactory::createReader($inputFileType);
$objPHPExcel = $objReader->load("assets/extras/blank.xls");
$baseRow = 2;
$highestColumn = sizeof($reporthead);
for ($head = 0; $head < $highestColumn; $head++){
$colstr=PHPExcel_Cell::stringFromColumnIndex($head);
$objPHPExcel->getActiveSheet()->setCellValue($colstr."1", $reporthead[$head]);
}
foreach($reportarray as $uid=>$uarr)
{
$row = $baseRow++;
$col = 0;
if($urr->auth_question!='')
{
$urr->auth_question = (array)json_decode($urr->auth_question);
}
for ($head = 0; $head < $highestColumn; $head++){
if($reporthead[$head]=="created_at")
$uarr->$reporthead[$head]=date("Y-m-d H:i:s",strtotime($uarr->$reporthead[$head])+330*60);
if($reporthead[$head]=="updated_at")
$uarr->$reporthead[$head]=date("Y-m-d H:i:s",strtotime($uarr->$reporthead[$head])+330*60);
if($reporthead[$head]=="question_time")
$uarr->$reporthead[$head]=date("Y-m-d H:i:s",strtotime($uarr->$reporthead[$head])+330*60);
$colstr=PHPExcel_Cell::stringFromColumnIndex($head);
$objPHPExcel->getActiveSheet()->setCellValue($colstr.$row, $uarr->$reporthead[$head]);
}
}
header('Content-Type: application/vnd.ms-excel');
header('Content-Disposition: attachment;filename="QAireLog.xls"');
header('Cache-Control: max-age=0');
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, $inputFileType);
$objWriter->save('php://output');
return ;
}
?>
<div class=innerAll>
<style>#logtable.td{vertical-align:top;}#logtable.tr{height:28px;overflow-y:hidden;}</style>
<script>
$(document).ready(function()
{
if(!$('#dialoglog').hasClass('ui-dialog-content'))
{
$('#dialoglog').dialog({
autoOpen: false,
width: '70%',
buttons: {
"Ok": function() {
$(this).dialog("close");
},
"Cancel": function() {
$(this).dialog("close");
}
}
});
}
waitKeyUpRun("filter",function() { filter2(document.getElementById('filter'), 'logtable') },"2000");
$('#modfrom').datepicker({dateFormat: 'yy-mm-dd',inline: true,changeYear: true,selectOtherMonths: true,yearRange: '<?php echo (date('Y')-70).":".(date('Y')+5); ?>'});
$('#modto').datepicker({dateFormat: 'yy-mm-dd',inline: true,changeYear: true,selectOtherMonths: true,yearRange: '<?php echo (date('Y')-70).":".(date('Y')+5); ?>'});
});
</script>
<div style="float:left;width:50%">
From : <input size=10 id='modfrom' name='modfrom' type='text' value='<?php echo date("Y-m-d",$logdate); ?>' />
&nbsp;&nbsp;To : <input size=10 id='modto' name='modto' type='text' value='<?php echo date("Y-m-d",$logtodate); ?>' />
</div>
<div style="float:right;width:50%">
<button class="pull-right btn btn-sm btn-default" onclick='dlAgentlogXls();return false;' title='Download' style='margin-top:-8px'><i class='fa fa-download'></i> Download</button>
</div>
<div style="clear:both"></div>
<hr>
<div class=col-md-12>
<div id=userlogschart1 style='min-height:300px;width:100%'></div>
</div>
<script>
function dlAgentlogXls()
{
//window.open('dialer/questionnaire?dllogxls=1&logdate='+$("#modfrom").val());return false;
window.open('dialer/questionnaire?dllogxls=1&logdate='+$("#modfrom").val()+'&logtodate='+$("#modto").val());return false;
}
</script>
<div style='clear:both'></div>
<div class=col-md-12>
<div id=userlogschart2 style='min-height:300px;width:100%'></div>
</div>
<div style='clear:both'></div>
<div style='overflow:auto'>
<table id=logtable class='footable table table-striped table-bordered table-white table-primary footable-loaded' style='font-size:12px'>
<thead>
<?php /*echo $outhead;*/ ?>
</thead>
<?php /*echo $outstr;*/ ?>
</table>
</div>
<div id=dialoglog></div>
</div>
<?php
use App\Models\CRMCall;
use App\Models\User;
use App\Jobs\KHRMSLib;
use App\Models\SupervisonComments;
$wakka = new KHRMSLib();
$dashboarduser=Auth::user();
//$agents=array();
$sup_status="";
if(isset($_GET['logdate']))$logdate=strtotime($_GET['logdate']." 00:00:00");
else $logdate=strtotime(date('Y-m-d')." 00:00:00");
if(isset($_GET['logtodate']))$logtodate=strtotime($_GET['logtodate']." 23:59:59");
else $logtodate=strtotime(date('Y-m-d')." 23:59:59");
if(isset($_GET['agents'])) $agents=$_GET['agents'];
else $agents="";
if(isset($_GET['sup_status'])) $sup_status=$_GET['sup_status'];
else $sup_status="";
/*$pb_code=implode(",",$agents);
echo "-----".$$pb_code;*/
$userarr=array();$i=1;
$reportarray=array();
$reporthead=array("id","date","pb_name","pb_code","pb_code","pb_landline_contact_no","supervisor_mail_id","group_id","group_id_name","cust_id","cust_name","relationship_with_group_id","cust_id_next","cust_name_next","relationship_with_group_id_next","new_group_addition_to_group","racing_from","supervisor_status","supervisor_update","Submit");
if($agents=="" && $sup_status=="")
{
$reportarray=DB::table('potentialcustomer_details')->select('*')->where('date','>=',date("Y-m-d H:i:s",$logdate))->where('date','<=',date("Y-m-d H:i:s",$logtodate))->get();
}else if($agents!="" && $sup_status==""){
$reportarray=DB::table('potentialcustomer_details')->select('*')->where('date','>=',date("Y-m-d H:i:s",$logdate))->where('date','<=',date("Y-m-d H:i:s",$logtodate))->where('pb_code','=',$agents)->get();
}else if($agents=="" && $sup_status!="")
{
/* $reportarray=DB::table('potentialcustomer_details')->select('*')->where('date','>=','"'.date("Y-m-d H:i:s",$logdate).'"')->where('date','<=','"'.date("Y-m-d H:i:s",$logtodate).'"')->where('supervisor_statu','=','"'.$sup_status.'"')->get();*/
$reportarray = DB::select(DB::raw("SELECT * FROM potentialcustomer_details where date >='".date("Y-m-d H:i:s",$logdate)."' and date <= '".date("Y-m-d H:i:s",$logtodate)."' and supervisor_status='".$sup_status."' "));
}else{
/*$reportarray=DB::table('potentialcustomer_details')->select('*')->where('date','>=',date("Y-m-d H:i:s",$logdate))->where('date','<=',date("Y-m-d H:i:s",$logtodate))->where('pb_code','=',$agents)->where('supervisor_status','=','"'.$sup_status.'"')->get();*/
$reportarray = DB::select(DB::raw("SELECT * FROM potentialcustomer_details where date >='".date("Y-m-d H:i:s",$logdate)."' and date <= '".date("Y-m-d H:i:s",$logtodate)."' and pb_code = '".$agents."' and supervisor_status='".$sup_status."' "));
}
//echo $reportarray;die();
/* $allusers=User::where(function ($query) use($dashboarduser) {
$query->where('supervisor','=',$dashboarduser->username)
->orWhere('lteam2','=',$dashboarduser->username)
->orWhere('lteam','=',$dashboarduser->username);
})->get();
foreach($allusers as $alluser){
$usrData = json_decode($alluser->data);
$usrHRMSData = unserialize($usrData->hrmsdata);
if($usrHRMSData['clientsownerlist']&&$usrHRMSData['clientsownerlist']!='null')
$client[] = $usrHRMSData['clientsownerlist'];
$username[] = $alluser->username;
//print_r($username);
}*/
if(Input::has("dllogxls"))
{
include_once(app_path().'/lib/phpexcel/PHPExcel.php');
$inputFileType = "Excel5";
$objReader = PHPExcel_IOFactory::createReader($inputFileType);
$objPHPExcel = $objReader->load("assets/extras/blank.xls");
$baseRow = 2;
$highestColumn = sizeof($reporthead);
for ($head = 0; $head < $highestColumn; $head++){
$colstr=PHPExcel_Cell::stringFromColumnIndex($head);
$objPHPExcel->getActiveSheet()->setCellValue($colstr."1", $reporthead[$head]);
}
foreach($reportarray as $uid=>$uarr)
{
$row = $baseRow++;
$col = 0;
for ($head = 0; $head < $highestColumn; $head++){
if($reporthead[$head]=="date")
$uarr->$reporthead[$head]=date("Y-m-d H:i:s",strtotime($uarr->$reporthead[$head])+330*60);
$colstr=PHPExcel_Cell::stringFromColumnIndex($head);
$objPHPExcel->getActiveSheet()->setCellValue($colstr.$row, $uarr->$reporthead[$head]);
}
}
header('Content-Type: application/vnd.ms-excel');
header('Content-Disposition: attachment;filename="PotentialCustomers.xls"');
header('Cache-Control: max-age=0');
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, $inputFileType);
$objWriter->save('php://output');
return ;
}
//echo "<pre><br>".print_r($reportarray)."</pre>";
$highestColumn = sizeof($reporthead);
$supervisorstatus="";
//echo $highestColumn;
if(count($reportarray)) {
$outhead="<tr>";$outstr="";$id="";
for ($head = 0; $head < $highestColumn; $head++){
$outhead.="<td>".$reporthead[$head]."</td>";
}
$outhead.="</tr>";
foreach($reportarray as $uid=>$uarr)
{
$outstr.="<tr>";
for ($head = 0; $head < $highestColumn; $head++){
if($reporthead[$head]=="date"){
$uarr->$reporthead[$head]=date("Y-m-d H:i:s",strtotime($uarr->$reporthead[$head])+330*60);
}
if($reporthead[$head]=="id"){
$id=$uarr->$reporthead[$head];
}
if($reporthead[$head]=="supervisor_status"){
$supervisorstatus=$uarr->$reporthead[$head];
$outstr.="<td><select id='".$id."_action_taken'><option value=".$supervisorstatus.">".$supervisorstatus."</option><option value='Pending'>Pending</option><option value='Action Taken'>Action Taken</option><option value='Rejected'>Rejected</option></select></td>";
}else if($reporthead[$head]=="Submit"){
$outstr.="<td><input type='button' id='".$id."_save' value='Save' onclick='updatesupervisorfeedback($id);'></td>";
}else {
$outstr.="<td>".$uarr->$reporthead[$head]."</td>";
}
}
$outstr.="</tr>";
}
}
else {
$outhead.="<tr><td>No Records Found.</td></tr>";
}
?>
<style>#logtable.td{vertical-align:top;}#logtable.tr{height:28px;overflow-y:hidden;}</style>
<script>
$(document).ready(function()
{
if(!$('#dialoglog').hasClass('ui-dialog-content'))
{
$('#dialoglog').dialog({
autoOpen: false,
width: '70%',
buttons: {
"Ok": function() {
$(this).dialog("close");
},
"Cancel": function() {
$(this).dialog("close");
}
}
});
}
waitKeyUpRun("filter",function() { filter2(document.getElementById('filter'), 'logtable') },"2000");
$('#modfrom').datepicker({dateFormat: 'yy-mm-dd',inline: true,changeYear: true,selectOtherMonths: true,yearRange: '<?php echo (date('Y')-70).":".(date('Y')+5); ?>'});
$('#modto').datepicker({dateFormat: 'yy-mm-dd',inline: true,changeYear: true,selectOtherMonths: true,yearRange: '<?php echo (date('Y')-70).":".(date('Y')+5); ?>'});
});
</script>
<div class=innerAll>
<h4 style="float:left;width:50%;margin:10px 0;">Racing Customer</h4>
<div style="float:right;width:50%">
<button class="pull-right btn btn-sm btn-default" onclick='dlAgentlogXls();return false;' title='Download' style='margin-top:-8px'><i class='fa fa-download'></i>Download</button>
</div>
<div style="clear:both"></div>
<hr style="margin-bottom: 5px;">
<div>
Date:From <input size=10 id='modfrom' name='modfrom' type='text' value='<?php echo date("Y-m-d",$logdate); ?>' onchange='statusLogReloadFun("");'/>
&nbsp;&nbsp;To<input size=10 id='modto' name='modto' type='text' value='<?php echo date("Y-m-d",$logtodate); ?>' onchange='statusLogReloadFun("");'/>&nbsp;&nbsp;
PB Code:
<select id='usrname' class=select2multi style="width: 20%;" >
<?php
$companyarr=$wakka->LoadAll("select * from hrms_masters where mtype='company'");
foreach($companyarr as $tcompany)
{
$seltxt='';
if(strstr(",".$clientslist.",",",$tcompany[mkey],"))$seltxt='selected="selected"';
echo "<option value='$agents'>$agents</option> <option value='$tcompany[mkey]' $seltxt>$tcompany[mkey]</option>";
}
?>
</select>
Supervisor Status:<select class=select2multi id='sup_status' style="width: 20%;">
<option value=''></option>
<option value='Pending'>Pending</option>
<option value='Action Taken'>Action Taken</option>
<option value='Rejected'>Rejected</option>
</select>
<button class="pull-right btn btn-sm btn-default" onclick='statusLogReloadFun("");return false;' title='Search' style='margin-top:-1px'><i class='fa fa-search'></i>Search</button>
</div>
<div id=createtaskdiv></div>
<hr style="margin:5px;">
<div style='overflow:auto;margin-top: 10px;'>
<table id=logtable class='footable table table-striped table-bordered table-white table-primary footable-loaded' style='font-size:12px';margin:0; border:1px solid #BBB;>
<thead><?php echo $outhead; ?></thead>
<?php echo $outstr; ?>
</table>
</div>
<div id=dialoglog></div>
</div>
<script>
function dlAgentlogXls()
{
var agents=$('#usrname').val();
var sup_status=$('#sup_status').val();
if(agents=="" && sup_status=="" ){
window.open('dialer/raicingcustomerreport?dllogxls=1&logdate='+$("#modfrom").val()+'&logtodate='+$("#modto").val());return false;
}else if(sup_status=="" && agents!=""){
window.open('dialer/raicingcustomerreport?dllogxls=1&logdate='+$("#modfrom").val()+'&logtodate='+$("#modto").val()+'&agents='+agents);return false;
}else if(sup_status!="" && agents==""){
window.open('dialer/raicingcustomerreport?dllogxls=1&logdate='+$("#modfrom").val()+'&logtodate='+$("#modto").val()+'&sup_status='+sup_status);return false;
}else{
window.open('dialer/raicingcustomerreport?dllogxls=1&logdate='+$("#modfrom").val()+'&logtodate='+$("#modto").val()+'&agents='+agents+'&sup_status='+sup_status);return false;
}
}
function dataString()
{
var agents=$('#usrname').val();
var sup_status=$('#sup_status').val();
if(agents=="" && sup_status=="" )
{
return 'logdate='+$("#modfrom").val()+'&logtodate='+$("#modto").val()
}
else if(sup_status=="" && agents!="")
{
return 'logdate='+$("#modfrom").val()+'&logtodate='+$("#modto").val()+'&agents='+agents;
}else if(sup_status!="" && agents==""){
return 'logdate='+$("#modfrom").val()+'&logtodate='+$("#modto").val()+'&sup_status='+sup_status;
}
else
{
return 'logdate='+$("#modfrom").val()+'&logtodate='+$("#modto").val()+'&agents='+agents+'&sup_status='+sup_status;
}
}
function statusLogReloadFun(sortby)
{
var sortstr='';if(sortby!="")sortstr="&sort="+sortby
var searchStr = dataString();
doAjax('dialer/raicingcustomerreport?'+searchStr+sortstr,'','rightmainreportdiv','ajax_dialer_reports','singlethis','GET');
}
function updatesupervisorfeedback(id)
{
var supervisorstatus=$('#'+id+'_action_taken').val();
var postdata='id='+id;
postdata+='&supervisorstatus='+supervisorstatus;
doAjax('racingcustupdate',postdata,'createtaskdiv','ajaxMutex_recSaveData','singlethis','POST');
}
</script>
<?php
use App\Models\User;
use App\Models\Sipid;
use App\Models\UserLog;
if(Input::has("dlfailed"))
{
return;
}
if(Input::has("process"))
{
echo "simpleNotification('success','topRight','Processing Started');";
return;
}
if(Input::has("archivesearch"))
{
$searchresultH="<br><table class='footable table' cellpadding='0' cellspacing='0' style='border-bottom:black 2px solid;margin-bottom:20px'><thead><tr>
<td class='table_hrm_heading_green'>Status</td>
<td class='table_hrm_heading_green'>Name</td>
<td class='table_hrm_heading_green'>Values<span style='float:right'><a href=# onclick='return false;'>Close</a></span></td>
</tr></thead>";
$searchresultF='</table><div style="clear:both"></div><div id=divworking></div><div style="clear:both"></div>';
$searchresult="";
//for
$searchresult.="
<tr class='recSearchResTbl' style='cursor:pointer' onclick='recArchiveOpen(this);'>
<td></td>
<td></td>
<td></td>
</tr>";
echo $searchresultH.$searchresult.$searchresultF;
return;
}
if(Input::has("savesettings"))
{
echo "simpleNotification('success','topRight','Settings Saved');";
return;
}
?>
<div class="layout-app"><!-- row-app -->
<div class="row row-app">
<div class="col-md-12">
<div class="col-separator col-separator-first col-unscrollable box">
<div class="col-app">
<div class="row-app">
<div class="col-md-9">
<div class="col-separator">
<!-- col-app -->
<div class="box col-unscrollable">
<div class="widget widget-tabs widget-tabs-social-account widget-tabs-responsive">
<div class="widget-body">
<div class="tab-content">
<div id="tabAccount" class="tab-pane active widget-body-regular padding-none border-none reset-components">
<div class="widget widget-tabs border-bottom-none">
<div class="widget-head">
<ul>
<li class="active"><a data-toggle="tab" href="#tab_pageZ" class="glyphicons search" title=''><i></i> Files</a></li>
<li><a data-toggle="tab" href="#tab_page0" class="glyphicons list" title=''><i></i> Staging</a></li>
<li><a data-toggle="tab" href="#tab_page1" class="glyphicons file" title=''><i></i> Processing</a></li>
<li><a data-toggle="tab" href="#tab_page2" class="glyphicons nameplate" title=''><i></i> Archive</a></li>
<li><a data-toggle="tab" href="#tab_page3" class="glyphicons cogwheel" title=''><i></i> Settings</a></li>
</ul>
</div>
<div class="widget-body padding-none">
<div class="tab-content">
<div class="tab-pane innerAll active" id="tab_pageZ" style='min-height:500px'>
<?php
?>
<br>
<h4>Files</h4>
<hr><br>
<div id=recfiles_search></div><div class="clearfix"></div><br><br>
</div>
<div class="tab-pane innerAll" id="tab_page0">
<div class=col-md-6>
<button class="btn btn-default" onclick='window.open("dialer/recarchive?dlfailed=1")'>Download</button> <button class="btn btn-default" onclick='doAjax("dialer/recarchive?process=1","","","recarchive_process","singlefail","GET");return false;'>Process</button><br>
</div>
<div class=col-md-6>
<form method=post enctype="multipart/form-data" action='dialer?action=recarchive&type=stageupload' target='empblkuploaddiv'>
<input type=hidden name=_token value={!!csrf_token()!!}>
<input type=hidden name=empbulkaction value='upload'>
<div class="fileupload fileupload-new margin-none" data-provides="fileupload">
<div class="input-group">
<div class="form-control col-md-3"><i class="fa fa-file fileupload-exists"></i> <span class="fileupload-preview"></span></div>
<span class="input-group-btn">
<span class="btn btn-default btn-file"><span class="fileupload-new">Select file</span><span class="fileupload-exists">Change</span><input type="file" name=empbulkfile id=empbulkfile class="margin-none"></span><a href="#" class="btn fileupload-exists" data-dismiss="fileupload">Remove</a><span class="btn btn-default" onclick='document.forms[0].submit();'>Upload</span>
</span>
</div>
</div>
</form>
<iframe id='empblkuploaddiv' name='empblkuploaddiv' style='width:1px;height:1px;visibility:hidden;display:none'></iframe>
</div>
<div class="clearfix"></div>
<?php
$tabarr=array();
$tabledata="";
?>
<br>
<h4>Staged Records</h4>
<hr><br>
<!-- Table -->
<table class="{!!sizeof($tabarr)>10?'dynamicTable':''!!} tableTools table table-striped table-bordered table-condensed table-white" style='margin-bottom:20px!important'>
<thead>
<tr>
<th>Id</th>
<th>CRMID</th>
<th>ClientId</th>
<th>Mobile</th>
<th>Client</th>
<th>DateSubmitted</th>
<th>Status</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
{!!$tabledata!!}
</tbody>
</table>
<!-- // Table END -->
</div>
<div class="tab-pane innerAll" id="tab_page1">
<?php
$tabarr2=array();
$tabledata2="";
?>
<br>
<h4>Processing Records</h4>
<hr><br>
<!-- Table -->
<table class="{!!sizeof($tabarr2)>10?'dynamicTable':''!!} tableTools table table-striped table-bordered table-condensed table-white" style='margin-bottom:20px!important'>
<thead>
<tr>
<th>Id</th>
<th>CRMID</th>
<th>ClientId</th>
<th>Mobile</th>
<th>Client</th>
<th>DateSubmitted</th>
<th>Status</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
{!!$tabledata2!!}
</tbody>
</table>
<!-- // Table END -->
</div>
<div class="tab-pane innerAll" id="tab_page2" style='min-height:500px'>
<?php
?>
<br>
<h4>Archived Records</h4>
<hr><br>
<div id=recarchive_search></div><div class="clearfix"></div><br><br>
</div>
<div class="tab-pane innerAll" id="tab_page3">
<textarea class=form-control rows=20>Server=10.0.0.1
Server=10.0.0.2
Server=10.0.0.3
Server=10.0.0.4
Server=10.0.0.5</textarea>
<br>
<button class="btn btn-default" onclick='doAjax("dialer/recarchive?savesettings=1","","","recarchive_process","singlefail","GET");return false;'>Save</button>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- // END col-app.col-unscrollable -->
</div>
<!-- // END col-separator -->
</div>
<!-- // END col -->
<!-- col -->
<div class="col-md-3">
<!-- col-separator -->
<div class="col-separator col-separator-last" style='margin-right:25px;padding-right:0px'>
<!-- Heading -->
<h5 class="innerAll margin-none bg-primary">
<i class="fa fa-fw fa-book"></i> Application Stats
<!-- <a href="#" class="btn btn-sm btn-inverse pull-right btn-xs" style="margin-top: -5px;"><i class="fa fa-plus fa-fw"></i>Add New</a> -->
</h5>
<!-- Listing -->
<div class="bg-gray-hover innerAll border-bottom">
<div class="media">
<div style="height:39px; width:39px; overflow:hidden" class="pull-left">
<a href="#" class="pull-left">
<img src="assets/images/people/avatar.jpg" class="media-object" width="39"/>
</a>
</div>
<a class="pull-right innerAll" href="#">
<!-- <span class="btn btn-primary btn-xs"><i class="fa fa-pencil"></i></span> -->
</a>
<div class="media-body">
<h5>Nodes Active 5/5</h5>
<div class="media-body" title="">
<div class="progress progress-small margin-none">
<div class="progress-bar progress-bar-primary" style="width: 100%"></div>
</div>
</div>
</div>
</div>
</div>
<!-- Listing ends-->
<!-- Listing -->
<div class="bg-gray-hover innerAll border-bottom">
<div class="media">
<div style="height:39px; width:39px; overflow:hidden" class="pull-left">
<a href="#" class="pull-left">
<img src="assets/images/people/avatar.jpg" class="media-object" width="39"/>
</a>
</div>
<a class="pull-right innerAll" href="#">
<!-- <span class="btn btn-primary btn-xs"><i class="fa fa-pencil"></i></span> -->
</a>
<div class="media-body">
<h5>Processing 0/0</h5>
<div class="media-body" title="">
<div class="progress progress-small margin-none">
<div class="progress-bar progress-bar-primary" style="width: 0%"></div>
</div>
</div>
</div>
</div>
</div>
<!-- Listing ends-->
<!-- Listing -->
<div class="bg-gray-hover innerAll border-bottom">
<div class="media">
<div style="height:39px; width:39px; overflow:hidden" class="pull-left">
<a href="#" class="pull-left">
<img src="assets/images/people/author_file.jpg" class="media-object" width="39"/>
</a>
</div>
<a class="pull-right innerAll" href="#">
<!-- <span class="btn btn-primary btn-xs"><i class="fa fa-pencil"></i></span> -->
</a>
<div class="media-body">
<?php ?>
<h5>Space Usages</h5>
<div class="media-body" title=''>
<div class="progress progress-small margin-none">
<div class="progress-bar progress-bar-primary" style="width: 50%"></div>
</div>
</div>
</div>
</div>
</div>
<!-- Listing ends-->
<!-- Listing -->
<div class="bg-gray-hover innerAll border-bottom">
<div class="media">
<div style="height:39px; width:39px; overflow:hidden" class="pull-left">
<a href="#" class="pull-left">
<img src="assets/images/people/author_content.jpg" class="media-object" width="39"/>
</a>
</div>
<a class="pull-right innerAll" href="#">
<!-- <span class="btn btn-primary btn-xs"><i class="fa fa-pencil"></i></span> -->
</a>
<div class="media-body">
<?php
?>
<h5> Errors</h5>
<div class="media-body" title=''>
<div class="progress progress-small margin-none">
<div class="progress-bar progress-bar-primary" style="width: 0%"></div>
</div>
</div>
</div>
</div>
</div>
<!-- Listing ends-->
</div>
<!-- // END col-separator -->
<div class="clearfix"></div>
</div>
<!-- // END col-table -->
</div>
<!-- // END col-separator.box -->
</div>
<!-- // END col -->
</div>
</div>
</div>
</div><!-- // END row-app -->
<script>
function createRecSearchRecordDiv(divid)
{
if(currentsearchdivid!="")$("#"+currentsearchdivid).html("");
currentsearchdivid=divid;
var searchRecordDivHTMLLI="ID,FirstName,LastName,Client,Mobile,ClientCode,InternalID".split(",");
searchRecordPreselectList=["","ID","FirstName","Mobile","ClientCode"];
var searchRecordDivHTML="";
for(i=1;i<=4;i++)
{
searchRecordDivHTML+="<div class=col-md-3>";
searchRecordDivHTML+="<div class='widget row widget-heading-simple widget-body-gray' >";
searchRecordDivHTML+="<div class='widget-body'><div class='input-group'>";
searchRecordDivHTML+="<div class='input-group-btn'>";
searchRecordDivHTML+="<div class='dropdown'>";
searchRecordDivHTML+="<button class='btn btn-default dropdown-toggle rounded-left' data-toggle='dropdown'><span id=maintextsearch_"+i+"_span>"+searchRecordPreselectList[i]+"</span> <span class='caret'></span></button>";
searchRecordDivHTML+="<ul class='dropdown-menu pull-left'>";
for(j=0;j<searchRecordDivHTMLLI.length;j++)searchRecordDivHTML+="<li><a href='#' onclick='$(\"#maintextsearch_"+i+"_span\").html($(this).html());return false;'>"+searchRecordDivHTMLLI[j]+"</a></li>";
searchRecordDivHTML+="</ul>";
searchRecordDivHTML+="</div>";
searchRecordDivHTML+="</div>";
searchRecordDivHTML+="<input class='form-control' id='maintextsearch_"+i+"_txt' type='text' onkeyup='recArchiveTextSearchStart();' />";
searchRecordDivHTML+="</div></div>";
searchRecordDivHTML+="</div>";
searchRecordDivHTML+="</div>";
}
searchRecordDivHTML+="<div style='clear:both'></div>";
searchRecordDivHTML+="<div id=searchresults></div>";
$("#"+divid).html(searchRecordDivHTML);
}
var recArchivesearchTimer=null;
function recArchiveTextSearchStart()
{
clearTimeout(recArchivesearchTimer);
searchTimer = setTimeout(recArchivemainTextSearch, 1500);
}
function recArchivemainTextSearch()
{
var searchStr='';
searchStr+='&maintextsearch_1_txt='+$('#maintextsearch_1_txt').val()+'&maintextsearch_1_span='+$("#maintextsearch_1_span").html();
searchStr+='&maintextsearch_2_txt='+$('#maintextsearch_2_txt').val()+'&maintextsearch_2_span='+$("#maintextsearch_2_span").html();
searchStr+='&maintextsearch_3_txt='+$('#maintextsearch_3_txt').val()+'&maintextsearch_3_span='+$("#maintextsearch_3_span").html();
searchStr+='&maintextsearch_4_txt='+$('#maintextsearch_4_txt').val()+'&maintextsearch_4_span='+$("#maintextsearch_4_span").html();
doAjax("dialer/recarchive?archivesearch=1", "searchstring="+searchStr, "searchresults", "searchMutex", "searchxhr","GET");
}
createRecSearchRecordDiv("recfiles_search");
// createRecSearchRecordDiv("recarchive_search");
</script>
<?php
use App\Models\User;
use App\Models\Sipid;
use App\Models\UserLog;
use App\Models\CRMCall;
use App\Jobs\KHRMSLib;
$wakka = new KHRMSLib();
$dashboarduser=Auth::user();
if(Input::has("qcstage"))
{
$stage=Input::get("qcstage");
if($stage=="list")
{
$qcyear=Input::get("qcyearselect",date("Y"));
$qcmonth=Input::get("qcmonthselect",date("m"));
$logdate="$qcyear-$qcmonth";
$mcallcnt=CRMCall::where('created_at','>=',$logdate."-01 00:00:00")->where('created_at','<=',$logdate."-31 23:59:59")->where('state','=','Hangup')->count();
$qccallcnt=CRMCall::where('created_at','>=',$logdate."-01 00:00:00")->where('created_at','<=',$logdate."-31 23:59:59")->where('state','=','Hangup-QC')->count();
$per3=(3*$mcallcnt/100)>$qccallcnt?((3*$mcallcnt/100)-$qccallcnt):0;
$hcalls=CRMCall::where('created_at','>=',$logdate."-01 00:00:00")->where('created_at','<=',$logdate."-31 23:59:59")->where('state','=','Hangup')->orderBy(DB::raw('RAND()'))->take(ceil($per3))->get();
$acallcnt=CRMCall::where('created_at','>=',$logdate."-01 00:00:00")->where('created_at','<=',$logdate."-31 23:59:59")->where('state','=','Archive')->count();
$aqccallcnt=CRMCall::where('created_at','>=',$logdate."-01 00:00:00")->where('created_at','<=',$logdate."-31 23:59:59")->where('state','=','Archive-QC')->count();
$per3=(3*$acallcnt/100)>$aqccallcnt?((3*$acallcnt/100)-$aqccallcnt):0;
$acalls=CRMCall::where('created_at','>=',$logdate."-01 00:00:00")->where('created_at','<=',$logdate."-31 23:59:59")->where('state','=','Archive')->orderBy(DB::raw('RAND()'))->take(ceil($per3))->get();
$alist=$acalls->merge($hcalls);
?>
<div class="col-table-row">
<div class="col-app col-unscrollable">
<div class="col-app">
<div class="row-app">
<div class="col-md-9">
<div class="col-separator">
<!-- Category Heading -->
<div class="heading-buttons bg-gray border-bottom innerR half">
<span class=pull-right>
<a href="#" class="btn btn-sm btn-inverse pull-right" onclick='reloadQCdata();return false;'><i class="fa fa-user fa-refresh"></i> Reload</a>
<select id=qcyearselect class='form-control pull-right' style='width:100px'>
<option value="{!!$qcyear!!}">{!!$qcyear!!}</option>
</select>
<select id=qcmonthselect class='form-control pull-right' style='width:100px'>
<option value="{!!$qcmonth!!}">{!!$qcmonth!!}</option>
</select>
</span>
<h4 class="innerTB margin-bottom-none">QC List</h4>
<div class="clearfix"></div>
</div>
<!-- End Category Heading -->
<div class=innerAll>
<div style='overflow:auto'>
<?php
$outstr="";
foreach($alist as $aline)
{
$clientcode="";
if($aline->crm_id>0)
{
$user=$wakka->getPerson($aline->crm_id);
$clientcode=$user["peopledata"]["clientcode"];
}
$tpostdata=json_decode($aline->data,true);
$fulldate=date("Y-m-d H:i:s",strtotime($aline->created_at)-($dashboarduser->timezone*60));
$talktime=$aline->talkSec+$aline->recstartSec+$aline->recendSec;
$length=round(($aline->waitSec+$aline->callSec+$talktime+$aline->dispoSec)/1000,2);
if(!isset($userarr[$aline->user_id])&&$aline->user_id>0)$userarr[$aline->user_id]=User::find($aline->user_id);
$dispname="";if(isset($userarr[$aline->user_id]))$dispname=$userarr[$aline->user_id]->dispname();
$recstr='';
if($dashboarduser->moduleACL("Admin",false,false,true))
{
if(isset($tpostdata['recFolder']))$recstr="<a href=# onclick='getCallRec(".$aline->id.");return false;' title='Size : ".round($aline->recsize/1024,0)." KB'><i class='fa fa-play-circle'></i> &nbsp;</a> <a href='dialer/playrecfile?calllog=$aline->id' title=''><i class='fa fa-download'></i> &nbsp;</a><span id='recspan_".$aline->id."'</span>";
}
$outstr.="<tr><td>".$i."</td>
<td title='$fulldate'>".explode(" ",$fulldate)[1]."</td>
<td>$length</td>
<td>".$dispname."</td>
<td title='".str_replace("'"," ",$aline->userremarks)."'>".$aline->userstatus."</td>
<td>".$aline->usersubstatus."</td>
<td>".($aline->usercallback!="0000-00-00 00:00:00"?date("Y-m-d H:i:s",strtotime($aline->usercallback)-($dashboarduser->timezone*60)):"")."</td>
<td><a href=# class='' onclick='dialerQuickOpen(\"$aline->crm_id\",\"$aline->number\",\"Progressive\",\"\",0);return false;'>".$aline->number."</a></td>
<td>$clientcode</td>
<td>".$aline->client."</td>
<td>".$aline->department."</td>
<td>".$aline->state."</td>
<td>".$aline->hsource."</td>
<td>".$aline->type."</td>
<td>".$aline->status."</td>
<td>".$aline->statuscode."</td>
<td>".$aline->substatus."</td>
<td>".$aline->dialline_id."</td>
<td>".$aline->did."</td>
<td>".round($aline->waitSec/1000,2)."</td>
<td>".round($aline->callSec/1000,2)."</td>
<td>".round($talktime/1000,2)."</td>
<td>".round($aline->dispoSec/1000,2)."</td>
<td>$recstr</td>
</tr>";
if($aline->type=='Inbound')
{
if($talktime>120000)$ttlovr10In++;
else if($talktime>60000)$ttlovr5In++;
else if($talktime>30000)$ttlovr1In++;
else if($talktime>1000)$ttlovr0In++;
$totaltimeIn+=round($talktime/1000,2);
$usrcntIn++;
$turl=$aline->status." - ".$aline->statuscode." - ".$aline->substatus;
if(!isset($actionarrIn[$turl]))$actionarrIn[$turl]=array('cnt'=>0,'time'=>0);
$actionarrIn[$turl]['cnt']++;
$actionarrIn[$turl]['time']+=round(($aline->callSec+$talktime)/1000,2);
}
else
{
if($talktime>120000)$ttlovr10++;
else if($talktime>60000)$ttlovr5++;
else if($talktime>30000)$ttlovr1++;
else if($talktime>1000)$ttlovr0++;
$totaltime+=round($talktime/1000,2);
$usrcnt++;
$turl=$aline->status." - ".$aline->statuscode." - ".$aline->substatus;
if(!isset($actionarr[$turl]))$actionarr[$turl]=array('cnt'=>0,'time'=>0);
$actionarr[$turl]['cnt']++;
$actionarr[$turl]['time']+=round(($aline->callSec+$talktime)/1000,2);
}
if(!empty($_GET['sort']))$i++;else $i--;
}
?>
<table id=logtable class='footable table table-striped table-bordered table-white table-primary footable-loaded' style='font-size:12px'>
<thead>
<tr>
<th>#</th>
<th>Start</th>
<th onclick='callLogReloadFun("");return false;'>Length</th>
<th>User</th>
<th>Dispo</th>
<th>SubDispo</th>
<th>CB</th>
<th style='width:120px'>Number</th>
<th>ClientCode</th>
<th>Data</th>
<th>SubData</th>
<th>State</th>
<th>HSource</th>
<th>Type</th>
<th>Status</th>
<th>StatusCode</th>
<th>StatusStr</th>
<th>DialLine</th>
<th>DID</th>
<th>WaitSec</th>
<th>CallSec</th>
<th>TalkSec</th>
<th>DispoSec</th>
<th>Recording</th>
</tr>
</thead>
<?php echo $outstr; ?>
</table>
</div>
</div><div class="clearfix"></div>
<div class="col-separator-h"></div>
</div>
<!-- // END col-separator -->
</div>
<!-- // END col -->
<!-- col -->
<div class="col-md-3">
<!-- col-separator -->
<div class="col-separator" style='margin-right:0px'>
<!-- Heading -->
<h5 class="innerAll margin-none bg-primary">
<i class="fa fa-fw fa-book"></i> Stats
<!-- <a href="#" class="btn btn-sm btn-inverse pull-right btn-xs" style="margin-top: -5px;"><i class="fa fa-plus fa-fw"></i>Add New</a> -->
</h5>
<!-- Listing -->
<div class="bg-gray-hover innerAll border-bottom">
<div class="media">
<div style="height:39px; width:39px; overflow:hidden" class="pull-left">
<a href="#" class="pull-left">
<img src="assets/images/people/avatar.jpg" class="media-object" width="39"/>
</a>
</div>
<a class="pull-right innerAll" href="#">
<!-- <span class="btn btn-primary btn-xs"><i class="fa fa-pencil"></i></span> -->
</a>
<div class="media-body">
<?php $totalusers=User::where('status','!=','Disabled')->count();$totalactive=\App\Models\User::where('status','=','Active')->where('usertype','!=','')->count();$totalactivemtd=\App\Models\User::where('status','=','Active')->where('usertype','!=','')->where('updated_at','>',date('Y-m-01 00:00:00'))->count(); ?>
<h5>Users {!!$totalactivemtd!!} MTD/{!!$totalactive!!} Active</h5>
<div class="media-body" title="{!!$totalactivemtd!!}/{!!$totalactive!!} MTD Active/Total Active, {!!round($totalactivemtd*100/$totalactive,1)!!}%">
<div class="progress progress-small margin-none">
<div class="progress-bar progress-bar-primary" style="width: {!!round($totalactivemtd*100/$totalactive,1)!!}%"></div>
</div>
</div>
</div>
</div>
</div>
<!-- Listing ends-->
<!-- Listing -->
<div class="bg-gray-hover innerAll border-bottom">
<div class="media">
<div style="height:39px; width:39px; overflow:hidden" class="pull-left">
<a href="#" class="pull-left">
<img src="assets/images/people/avatar.jpg" class="media-object" width="39"/>
</a>
</div>
<a class="pull-right innerAll" href="#">
<!-- <span class="btn btn-primary btn-xs"><i class="fa fa-pencil"></i></span> -->
</a>
<div class="media-body">
<h5>Total Users {!!$totalactivemtd!!}/{!!$totalactive!!}/{!!$totalusers!!}</h5>
<div class="media-body" title="{!!$totalactive!!}/{!!$totalusers!!} Active/Total , {!!round($totalactive*100/$totalusers,1)!!}%">
<div class="progress progress-small margin-none">
<div class="progress-bar progress-bar-primary" style="width: {!!round($totalactive*100/$totalusers,1)!!}%"></div>
</div>
</div>
</div>
</div>
</div>
<!-- Listing ends-->
<!-- Listing -->
<div class="bg-gray-hover innerAll border-bottom">
<div class="media">
<div style="height:39px; width:39px; overflow:hidden" class="pull-left">
<a href="#" class="pull-left">
<img src="assets/images/people/author_file.jpg" class="media-object" width="39"/>
</a>
</div>
<a class="pull-right innerAll" href="#">
<!-- <span class="btn btn-primary btn-xs"><i class="fa fa-pencil"></i></span> -->
</a>
<div class="media-body">
<?php ?>
<h5>100 MB Space Usages</h5>
<div class="media-body" title='100 GB Limit'>
<div class="progress progress-small margin-none">
<div class="progress-bar progress-bar-primary" style="width: 50%"></div>
</div>
</div>
</div>
</div>
</div>
<!-- Listing ends-->
<!-- Listing -->
<div class="bg-gray-hover innerAll border-bottom">
<div class="media">
<div style="height:39px; width:39px; overflow:hidden" class="pull-left">
<a href="#" class="pull-left">
<img src="assets/images/people/author_content.jpg" class="media-object" width="39"/>
</a>
</div>
<a class="pull-right innerAll" href="#">
<!-- <span class="btn btn-primary btn-xs"><i class="fa fa-pencil"></i></span> -->
</a>
<div class="media-body">
<?php
?>
<h5> Units Viewed Unique Users</h5>
<div class="media-body" title='50% , 50 Total Units'>
<div class="progress progress-small margin-none">
<div class="progress-bar progress-bar-primary" style="width: 50%"></div>
</div>
</div>
</div>
</div>
</div>
<!-- Listing ends-->
</div>
<!-- // END col-separator -->
<div class="clearfix"></div>
</div>
<!-- // END col-table -->
</div>
<!-- // END col-separator.box -->
</div>
<!-- // END col -->
</div>
<!-- // END row-app -->
</div>
<?php
}
if($stage=="settings")
{
?>
<h5>QC Settings</h5>
<?php
}
return;
}
?>
<div class="layout-app"><!-- row-app -->
<div class="row row-app">
<!-- col -->
<div class="col-md-2 col-sm-3">
<!-- col-separator -->
<div class="col-separator col-separator-first box col-unscrollable">
<!-- col-table -->
<div class="col-table" style='padding-left: 13px;padding-right: 13px;'>
<h4 class="innerAll margin-none border-bottom" style='background: #fff;'>Dialer Reports</h4>
<!-- col-table-row -->
<div class="col-table-row">
<!-- col-app -->
<div class="col-app col-unscrollable">
<!-- col-app -->
<div class="col-app">
<ul class="list-group list-group-1 margin-none borders-none" style='padding-right: 26px;'>
<!-- <li class="list-group-item">
<a href="#" onclick="doAjax('dialer/recqc?qcstage=dashboard','','rightmainreportdiv','ajax_dialer_reports','singlethis','GET');return false"><i class="fa fa-circle-o"></i> Dashboard</a>
</li>-->
<li class="list-group-item">
<a href="#" onclick="doAjax('dialer/recqc?qcstage=list','','rightmainreportdiv','ajax_dialer_reports','singlethis','GET');return false"><i class="fa fa-circle-o"></i> QC List</a>
</li>
<?php if(Auth::user()->moduleACL("Dialer",true,true,true)){ ?>
<li class="list-group-item">
<a href="#" onclick="doAjax('dialer/recqc?qcstage=settings','','rightmainreportdiv','ajax_dialer_reports','singlethis','GET');return false"><i class="fa fa-circle-o"></i> QC Settings</a>
</li>
<?php } ?>
</ul>
</div>
<!-- // END col-app -->
</div>
<!-- // END col-app -->
</div>
<!-- // END col-table-row -->
</div>
<!-- // END col-table -->
</div>
<!-- // END col-separator.box -->
</div>
<!-- // END col -->
<!-- col -->
<div class="col-md-10 col-sm-9" style='border-right:13px solid #eaeaea'>
<!-- col-separator.box -->
<div class="col-separator col-unscrollable box">
<!-- col-table -->
<div class="col-table">
<!-- <h4 class="innerAll margin-none border-bottom">My Sessions</h4> -->
<!-- col-table-row -->
<div class="col-table-row" style='background: #fff;'>
<!-- col-app -->
<div class="col-app col-unscrollable">
<!-- col-app -->
<div class="col-app" style='position:relative'>
<div class="" id=rightmainreportdiv>
<script>
doAjax('dialer/recqc?qcstage=list','','rightmainreportdiv','ajax_dialer_reports','singlethis','GET');
</script>
</div>
</div>
<!-- // END col-app -->
</div>
<!-- // END col-app.col-unscrollable -->
</div>
<!-- // END col-table-row -->
</div>
<!-- // END col-table -->
</div>
<!-- // END col-separator.box -->
</div>
<!-- // END col -->
</div>
<!-- // END row-app -->
</div>
<?php
use App\Models\CRMCallArchive;
use App\Models\CRMCall;
use App\Models\User;
use App\Jobs\KHRMSLib;
$wakka = new KHRMSLib();
$dashboarduser=Auth::user();
if(isset($_GET['logdate']))$logdate=strtotime($_GET['logdate']." 00:00:00");
else $logdate=strtotime(date('Y-m-d')." 00:00:00");
$prevlogdate = strtotime(date('Y-m-d', strtotime('-7 day')));
$i=0;
if($logdate < $prevlogdate)
{
$alist=CRMCallArchive::where('created_at','>=',date("Y-m-d H:i:s",$logdate))->where('created_at','<=',date("Y-m-d H:i:s",$logdate+24*60*60))->where('type','!=','Inbound');
}
else
{
$alist=CRMCall::where('created_at','>=',date("Y-m-d H:i:s",$logdate))->where('created_at','<=',date("Y-m-d H:i:s",$logdate+24*60*60))->where('type','!=','Inbound');
}
if($dashboarduser->usertype != 'Admin')
{
$uidlist=array($dashboarduser->id);
$allusers=User::where(function ($query) use($dashboarduser) {
$query->where('supervisor','=',$dashboarduser->username)
->orWhere('lteam2','=',$dashboarduser->username)
->orWhere('lteam','=',$dashboarduser->username);
})->get();
foreach($allusers as $tuser)$uidlist[]=$tuser->id;
$roclientstr=array();$didlinesstr=array();
if($dashboarduser->exten!="")$didlinesstr[]=$dashboarduser->exten;
$oclientlst=$wakka->clientsReadAccess();
if(!empty($oclientlst))foreach($oclientlst as $tclnt)if($tclnt!="")
{
$roclientstr[]="$tclnt";
$mastersdata=$wakka->getCompanyMaster($tclnt);
if(!empty($mastersdata["DialerDID"]))$didlinesstr[]=$mastersdata["DialerDID"];
}
$alist=$alist->where(function ($query) use($roclientstr,$uidlist,$didlinesstr){
$query//->orWhereIn('client',$roclientstr)
->orWhereIn('user_id',$uidlist)
->orWhereIn('did',$didlinesstr);
});
}
if(Input::get('sort')=='cpu')$alist=$alist->orderBy("callSec","DESC");
else $alist=$alist->orderBy("id","DESC");
$alist=$alist->get();
/*
$userarr=array();
$i=sizeof($alist);if(!empty($_GET['sort']))$i=1;
$totaltime=0;$ttlovr10=0;$ttlovr5=0;$ttlovr1=0;$ttlovr0=0;$outstr="";$usrcnt=0;
$totaltimeIn=0;$ttlovr10In=0;$ttlovr5In=0;$ttlovr1In=0;$ttlovr0In=0;$usrcntIn=0;
$actionarr=array();$actionarrIn=array();
*/
if(Input::has("dllogxls"))
{
include_once(app_path().'/lib/phpexcel/PHPExcel.php');
$inputFileType = "Excel5";
$objReader = PHPExcel_IOFactory::createReader($inputFileType);
$objPHPExcel = $objReader->load("assets/extras/blank.xls");
$baseRow = 3;
$tcol=0;$fieldsarr=array();$extrahdrarr=array();
$fieldsarr[$tcol++]='#';
$fieldsarr[$tcol++]='Date';
$fieldsarr[$tcol++]='User_id';
$fieldsarr[$tcol++]='Disposition';
$fieldsarr[$tcol++]='ClientCode';
$fieldsarr[$tcol++]='Services';
/*$fieldsarr[$tcol++]='SubDispo';
$fieldsarr[$tcol++]='CB';
$fieldsarr[$tcol++]='Number';
$fieldsarr[$tcol++]='ClientCode';
$fieldsarr[$tcol++]='CurrentStatus';
$fieldsarr[$tcol++]='LegalStatus';
$fieldsarr[$tcol++]='Data';
$fieldsarr[$tcol++]='SubData';
$fieldsarr[$tcol++]='State';
$fieldsarr[$tcol++]='HSource';
$fieldsarr[$tcol++]='Type';
$fieldsarr[$tcol++]='Status';
$fieldsarr[$tcol++]='StatusCode';
$fieldsarr[$tcol++]='StatusStr';
$fieldsarr[$tcol++]='DialLine';
$fieldsarr[$tcol++]='DID';
$fieldsarr[$tcol++]='WaitSec';
$fieldsarr[$tcol++]='CallSec';
$fieldsarr[$tcol++]='TalkSec';
$fieldsarr[$tcol++]='DispoSec';
$fieldsarr[$tcol++]='Remarks';*/
$highestColumn = sizeof($fieldsarr);
for ($head = 0; $head < $highestColumn; $head++){
$colstr=PHPExcel_Cell::stringFromColumnIndex($head);
$objPHPExcel->getActiveSheet()->setCellValue($colstr."1", $fieldsarr[$head]);
}
$ii=1;
foreach($alist as $aline)
{
$row = $baseRow++;
$col = 0;
$clientcode="";$currentstatus="";$legalstatus="";
if($aline->crm_id>0)
{
$user=$wakka->getPerson($aline->crm_id);
$clientcode=$user["peopledata"]["clientcode"];
$currentstatus=$user["peopledata"]["currentstatus"];
$legalstatus=$user["peopledata"]["legalstatus"];
}
$tpostdata=json_decode($aline->data,true);
$fulldate=date("Y-m-d H:i:s",strtotime($aline->created_at)-($dashboarduser->timezone*60));
$talktime=$aline->talkSec+$aline->recstartSec+$aline->recendSec;
$length=round(($aline->waitSec+$aline->callSec+$talktime+$aline->dispoSec)/1000,2);
if(!isset($userarr[$aline->user_id])&&$aline->user_id>0)$userarr[$aline->user_id]=User::find($aline->user_id);
$dispname="";if(isset($userarr[$aline->user_id]))$dispname=$userarr[$aline->user_id]->dispname();
$username="";if(isset($userarr[$aline->user_id]))$username=$userarr[$aline->user_id]->username;
$userdata=json_decode($aline->userdata,true);
if(!empty($userdata)){
foreach ($userdata as $key=>$val) {
$objPHPExcel->getActiveSheet()->getCellByColumnAndRow($col++,$row)->setValueExplicit($ii++);
$objPHPExcel->getActiveSheet()->getCellByColumnAndRow($col++,$row)->setValueExplicit($Date);
$objPHPExcel->getActiveSheet()->getCellByColumnAndRow($col++,$row)->setValueExplicit($User_id);
$objPHPExcel->getActiveSheet()->getCellByColumnAndRow($col++,$row)->setValueExplicit($Disposition);
$objPHPExcel->getActiveSheet()->getCellByColumnAndRow($col++,$row)->setValueExplicit($ClientCode);
$objPHPExcel->getActiveSheet()->getCellByColumnAndRow($col++,$row)->setValueExplicit($val);
}
}else{
$objPHPExcel->getActiveSheet()->getCellByColumnAndRow($col++,$row)->setValueExplicit($ii++);
$objPHPExcel->getActiveSheet()->getCellByColumnAndRow($col++,$row)->setValueExplicit($Date);
$objPHPExcel->getActiveSheet()->getCellByColumnAndRow($col++,$row)->setValueExplicit($User_id);
$objPHPExcel->getActiveSheet()->getCellByColumnAndRow($col++,$row)->setValueExplicit($Disposition);
$objPHPExcel->getActiveSheet()->getCellByColumnAndRow($col++,$row)->setValueExplicit($ClientCode);
$objPHPExcel->getActiveSheet()->getCellByColumnAndRow($col++,$row)->setValueExplicit();
}
}
header('Content-Type: application/vnd.ms-excel');
header('Content-Disposition: attachment;filename="Relationship.xls"');
header('Cache-Control: max-age=0');
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, $inputFileType);
$objWriter->save('php://output');
return ;
}
foreach($alist as $aline)
{
$clientcode="";
$userdata=json_decode($aline->userdata,true);
if($aline->crm_id>0)
{
$user=$wakka->getPerson($aline->crm_id);
$clientcode=$user["peopledata"]["clientcode"];
}
$tpostdata=json_decode($aline->data,true);
$fulldate=date("Y-m-d H:i:s",strtotime($aline->created_at)-($dashboarduser->timezone*60));
$talktime=$aline->talkSec+$aline->recstartSec+$aline->recendSec;
$length=round(($aline->waitSec+$aline->callSec+$talktime+$aline->dispoSec)/1000,2);
if(!isset($userarr[$aline->user_id])&&$aline->user_id>0)$userarr[$aline->user_id]=User::find($aline->user_id);
$dispname="";if(isset($userarr[$aline->user_id]))$dispname=$userarr[$aline->user_id]->dispname();
$username="";if(isset($userarr[$aline->user_id]))$username=$userarr[$aline->user_id]->username;
if(!empty($userdata)){
foreach ($userdata as $key=>$val) {
$outstr.="<tr><td>".$i++."</td>
<td title='$fulldate'>".explode(" ",$fulldate)[0]."</td>
<td>".$username."</td>
<td title='".str_replace("'"," ",$aline->userremarks)."'>".$aline->userstatus."</td>
<td>$clientcode</td>
<td>$val</td>
</tr>";
}
}else{
$outstr.="<tr><td>".$i++."</td>
<td title='$fulldate'>".explode(" ",$fulldate)[0]."</td>
<td>".$username."</td>
<td title='".str_replace("'"," ",$aline->userremarks)."'>".$aline->userstatus."</td>
<td>$clientcode</td>
<td></td>
</tr>";
}
if($aline->type=='Inbound')
{
if($talktime>120000)$ttlovr10In++;
else if($talktime>60000)$ttlovr5In++;
else if($talktime>30000)$ttlovr1In++;
else if($talktime>1000)$ttlovr0In++;
$totaltimeIn+=round($talktime/1000,2);
$usrcntIn++;
$turl=$aline->status." - ".$aline->statuscode." - ".$aline->substatus;
if(!isset($actionarrIn[$turl]))$actionarrIn[$turl]=array('cnt'=>0,'time'=>0);
$actionarrIn[$turl]['cnt']++;
$actionarrIn[$turl]['time']+=round(($aline->callSec+$talktime)/1000,2);
}
else
{
if($talktime>120000)$ttlovr10++;
else if($talktime>60000)$ttlovr5++;
else if($talktime>30000)$ttlovr1++;
else if($talktime>1000)$ttlovr0++;
$totaltime+=round($talktime/1000,2);
$usrcnt++;
$turl=$aline->status." - ".$aline->statuscode." - ".$aline->substatus;
if(!isset($actionarr[$turl]))$actionarr[$turl]=array('cnt'=>0,'time'=>0);
$actionarr[$turl]['cnt']++;
$actionarr[$turl]['time']+=round(($aline->callSec+$talktime)/1000,2);
}
}
?>
<div class=innerAll>
<style>#logtable.td{vertical-align:top;}#logtable.tr{height:28px;overflow-y:hidden;}</style>
<script>
function showExtraPost(varstr)
{
doAjax("hr?action=LiveUsers","getpostdata="+varstr,"dialoglog");
$('#dialoglog').dialog('open');
return false;
}
$(document).ready(function()
{
if(!$('#dialoglog').hasClass('ui-dialog-content'))
{
$('#dialoglog').dialog({
autoOpen: false,
width: '70%',
buttons: {
"Ok": function() {
$(this).dialog("close");
},
"Cancel": function() {
$(this).dialog("close");
}
}
});
}
waitKeyUpRun("filter",function() { filter2(document.getElementById('filter'), 'logtable') },"2000");
$('#modfrom').datepicker({dateFormat: 'yy-mm-dd',inline: true,changeYear: true,selectOtherMonths: true,yearRange: '<?php echo (date('Y')-70).":".(date('Y')+5); ?>'});
});
</script>
<div style="float:left;width:50%">
Search <input id=filter name="filter" type="text">
Date : <input size=10 id='modfrom' name='modfrom' type='text' value='<?php echo date("Y-m-d",$logdate); ?>' onchange='callLogReloadFun("");' />
</div>
<div style="float:left;width:50%">
<button class="pull-right btn btn-sm btn-default" onclick='dlCalllogXls();return false;' title='Download' style='margin-top:-8px'><i class='fa fa-download'></i> Download</button>
</div>
<div style="clear:both"></div>
<hr>
<?php
$categories=array();$avgarr=array();$cntarr=array();
foreach($actionarr as $act=>$actarr)
{
if($actarr['cnt']>sizeof($alist)/150)
{
$categories[]="'$act'";
$avgarr[]=-round($actarr['time']/$actarr['cnt'],2);
$cntarr[]=$actarr['cnt'];
}
}
array_multisort($cntarr,$avgarr,$categories);
$categoriesIn=array();$avgarrIn=array();$cntarrIn=array();
foreach($actionarrIn as $act=>$actarr)
{
if($actarr['cnt']>sizeof($alist)/150)
{
$categoriesIn[]="'$act'";
$avgarrIn[]=-round($actarr['time']/$actarr['cnt'],2);
$cntarrIn[]=$actarr['cnt'];
}
}
array_multisort($cntarrIn,$avgarrIn,$categoriesIn);
?>
<div class=col-md-10>
<script>
function callLogReloadFun(sortby)
{
var sortstr='';if(sortby!="")sortstr="&sort="+sortby
doAjax('dialer/calllog?logdate='+$("#modfrom").val()+sortstr,'','rightmainreportdiv','ajax_dialer_reports','singlethis','GET');
}
function getCallRec(id)
{
doAjax("dialer/calllog","getCallRec=1&calllog="+id,'recspan_'+id,'rec_ajax','singlefail','GET');
}
function dlCalllogXls()
{
window.open('dialer/relationship?dllogxls=1&logdate='+$("#modfrom").val());return false;
}
</script>
</div>
<div style='clear:both'></div>
<div class=col-md-10>
<script>
</script>
</div>
<div style='clear:both'></div>
<div style='overflow:auto'>
<table id=logtable class='footable table table-striped table-bordered table-white table-primary footable-loaded' style='font-size:12px'>
<thead>
<tr>
<th>#</th>
<th>Date</th>
<th>User_id</th>
<th>Disposition</th>
<th>ClientCode</th>
<th>Services</th>
</tr>
</thead>
<?php echo $outstr; ?>
</table>
</div>
<?php
function convert($size)
{
$unit=array('b','kb','mb','gb','tb','pb');
return @round($size/pow(1024,($i=floor(log($size,1024)))),2).' '.$unit[$i];
}
echo "<br>".convert(memory_get_peak_usage(true)); // 123 kb
?>
<div id=dialoglog></div>
</div>
<?php
use App\Models\CRMCallArchive;
use App\Models\CRMCall;
use App\Models\User;
use App\Jobs\KHRMSLib;
$wakka = new KHRMSLib();
$dashboarduser=Auth::user();
if(isset($_GET['logdate']))$logdate=strtotime($_GET['logdate']." 00:00:00");
else $logdate=strtotime(date('Y-m-d')." 00:00:00");
$prevlogdate = strtotime(date('Y-m-d', strtotime('-7 day')));
$i=0;
if($logdate < $prevlogdate)
{
$alist=CRMCallArchive::where('created_at','>=',date("Y-m-d H:i:s",$logdate))->where('created_at','<=',date("Y-m-d H:i:s",$logdate+24*60*60))->where('type','!=','Inbound');
}
else
{
$alist=CRMCall::where('created_at','>=',date("Y-m-d H:i:s",$logdate))->where('created_at','<=',date("Y-m-d H:i:s",$logdate+24*60*60))->where('type','!=','Inbound');
}
if($dashboarduser->usertype != 'Admin')
{
$uidlist=array($dashboarduser->id);
$allusers=User::where(function ($query) use($dashboarduser) {
$query->where('supervisor','=',$dashboarduser->username)
->orWhere('lteam2','=',$dashboarduser->username)
->orWhere('lteam','=',$dashboarduser->username);
})->get();
foreach($allusers as $tuser)$uidlist[]=$tuser->id;
$roclientstr=array();$didlinesstr=array();
if($dashboarduser->exten!="")$didlinesstr[]=$dashboarduser->exten;
$oclientlst=$wakka->clientsReadAccess();
if(!empty($oclientlst))foreach($oclientlst as $tclnt)if($tclnt!="")
{
$roclientstr[]="$tclnt";
$mastersdata=$wakka->getCompanyMaster($tclnt);
if(!empty($mastersdata["DialerDID"]))$didlinesstr[]=$mastersdata["DialerDID"];
}
$alist=$alist->where(function ($query) use($roclientstr,$uidlist,$didlinesstr){
$query//->orWhereIn('client',$roclientstr)
->orWhereIn('user_id',$uidlist)
->orWhereIn('did',$didlinesstr);
});
}
if(Input::get('sort')=='cpu')$alist=$alist->orderBy("callSec","DESC");
else $alist=$alist->orderBy("id","DESC");
$alist=$alist->get();
/*
$userarr=array();
$i=sizeof($alist);if(!empty($_GET['sort']))$i=1;
$totaltime=0;$ttlovr10=0;$ttlovr5=0;$ttlovr1=0;$ttlovr0=0;$outstr="";$usrcnt=0;
$totaltimeIn=0;$ttlovr10In=0;$ttlovr5In=0;$ttlovr1In=0;$ttlovr0In=0;$usrcntIn=0;
$actionarr=array();$actionarrIn=array();
*/
$callarraid='';
$crm_id='';
foreach($alist as $aline)
{
if($aline->crm_id>0)$crm_id.=$aline->crm_id.",";
}
$crm_id=substr($crm_id,0,-1);
$crm_id=explode(",", $crm_id);
$clientcodearr=DB::table('records')->select('clientcode','id','currentstatus','legalstatus')->whereIn('id',$crm_id)->get();
foreach ($clientcodearr as $clientid)
{
$clientcodeval[$clientid->id]=$clientid->clientcode;
}
if(Input::has("dllogxls"))
{
include_once(app_path().'/lib/phpexcel/PHPExcel.php');
$inputFileType = "Excel5";
$objReader = PHPExcel_IOFactory::createReader($inputFileType);
$objPHPExcel = $objReader->load("assets/extras/blank.xls");
$baseRow = 3;
$tcol=0;$fieldsarr=array();$extrahdrarr=array();
$fieldsarr[$tcol++]='#';
$fieldsarr[$tcol++]='Date';
$fieldsarr[$tcol++]='User_id';
$fieldsarr[$tcol++]='Disposition';
$fieldsarr[$tcol++]='ClientCode';
$fieldsarr[$tcol++]='Services';
$highestColumn = sizeof($fieldsarr);
for ($head = 0; $head < $highestColumn; $head++)
{
$colstr=PHPExcel_Cell::stringFromColumnIndex($head);
$objPHPExcel->getActiveSheet()->setCellValue($colstr."1", $fieldsarr[$head]);
}
$ii=1;
foreach($alist as $aline)
{
//$row = $baseRow++;
$col = 0;
$clientcode="";
$tpostdata=json_decode($aline->data,true);
$fulldate=date("Y-m-d H:i:s",strtotime($aline->created_at)-($dashboarduser->timezone*60));
if(!isset($userarr[$aline->user_id])&&$aline->user_id>0)$userarr[$aline->user_id]=User::find($aline->user_id);
$dispname="";if(isset($userarr[$aline->user_id]))$dispname=$userarr[$aline->user_id]->dispname();
$username="";if(isset($userarr[$aline->user_id]))$username=$userarr[$aline->user_id]->username;
$val='';
$userdata=json_decode($aline->userdata,true);
//echo "<pre>".print_r($userdata)."<br>";
if(!empty($userdata))
{
foreach ($userdata as $key=>$val)
{
if($val!="")
{
$row = $baseRow++;
$col=0;
$clientcode="";
if($aline->crm_id>0)
{
//$user=$wakka->getPerson($aline->crm_id);
//$clientcode=$user["peopledata"]["clientcode"];
$clientcode=$clientcodeval[$aline->crm_id];
}
$objPHPExcel->getActiveSheet()->getCellByColumnAndRow($col++,$row)->setValueExplicit($ii++);
$objPHPExcel->getActiveSheet()->getCellByColumnAndRow($col++,$row)->setValueExplicit($fulldate);
$objPHPExcel->getActiveSheet()->getCellByColumnAndRow($col++,$row)->setValueExplicit($username);
$objPHPExcel->getActiveSheet()->getCellByColumnAndRow($col++,$row)->setValueExplicit($aline->userstatus);
$objPHPExcel->getActiveSheet()->getCellByColumnAndRow($col++,$row)->setValueExplicit($clientcode);
$objPHPExcel->getActiveSheet()->getCellByColumnAndRow($col++,$row)->setValueExplicit($val);
}
}
}
}
header('Content-Type: application/vnd.ms-excel');
header('Content-Disposition: attachment;filename="Relationship.xls"');
header('Cache-Control: max-age=0');
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, $inputFileType);
$objWriter->save('php://output');
return ;
}
foreach($alist as $aline)
{
$clientcode="";
$userdata=json_decode($aline->userdata,true);
if($aline->crm_id>0)
{
//$user=$wakka->getPerson($aline->crm_id);
//$clientcode=$user["peopledata"]["clientcode"];
$clientcode=$clientcodeval[$aline->crm_id];
}
$tpostdata=json_decode($aline->data,true);
$fulldate=date("Y-m-d H:i:s",strtotime($aline->created_at)-($dashboarduser->timezone*60));
$talktime=$aline->talkSec+$aline->recstartSec+$aline->recendSec;
$length=round(($aline->waitSec+$aline->callSec+$talktime+$aline->dispoSec)/1000,2);
if(!isset($userarr[$aline->user_id])&&$aline->user_id>0)$userarr[$aline->user_id]=User::find($aline->user_id);
$dispname="";if(isset($userarr[$aline->user_id]))$dispname=$userarr[$aline->user_id]->dispname();
$username="";if(isset($userarr[$aline->user_id]))$username=$userarr[$aline->user_id]->username;
if(!empty($userdata)){
foreach ($userdata as $key=>$val)
{
if($val!="")
{
$outstr.="<tr><td>".$i++."</td>
<td title='$fulldate'>".explode(" ",$fulldate)[0]."</td>
<td>".$username."</td>
<td title='".str_replace("'"," ",$aline->userremarks)."'>".$aline->userstatus."</td>
<td>$clientcode</td>
<td>$val</td>
</tr>";
}
}
}
/*else
{
$outstr.="<tr><td>".$i++."</td>
<td title='$fulldate'>".explode(" ",$fulldate)[0]."</td>
<td>".$username."</td>
<td title='".str_replace("'"," ",$aline->userremarks)."'>".$aline->userstatus."</td>
<td>$clientcode</td>
<td></td>
</tr>";
}*/
}
?>
<div class=innerAll>
<style>#logtable.td{vertical-align:top;}#logtable.tr{height:28px;overflow-y:hidden;}</style>
<script>
function showExtraPost(varstr)
{
doAjax("hr?action=LiveUsers","getpostdata="+varstr,"dialoglog");
$('#dialoglog').dialog('open');
return false;
}
$(document).ready(function()
{
if(!$('#dialoglog').hasClass('ui-dialog-content'))
{
$('#dialoglog').dialog({
autoOpen: false,
width: '70%',
buttons: {
"Ok": function() {
$(this).dialog("close");
},
"Cancel": function() {
$(this).dialog("close");
}
}
});
}
waitKeyUpRun("filter",function() { filter2(document.getElementById('filter'), 'logtable') },"2000");
$('#modfrom').datepicker({dateFormat: 'yy-mm-dd',inline: true,changeYear: true,selectOtherMonths: true,yearRange: '<?php echo (date('Y')-70).":".(date('Y')+5); ?>'});
});
</script>
<div style="float:left;width:50%">
Search <input id=filter name="filter" type="text">
Date : <input size=10 id='modfrom' name='modfrom' type='text' value='<?php echo date("Y-m-d",$logdate); ?>' onchange='callLogReloadFun("");' />
</div>
<div style="float:left;width:50%">
<button class="pull-right btn btn-sm btn-default" onclick='dlCalllogXls();return false;' title='Download' style='margin-top:-8px'><i class='fa fa-download'></i> Download</button>
</div>
<div style="clear:both"></div>
<hr>
<?php
/*$categories=array();$avgarr=array();$cntarr=array();
foreach($actionarr as $act=>$actarr)
{
if($actarr['cnt']>sizeof($alist)/150)
{
$categories[]="'$act'";
$avgarr[]=-round($actarr['time']/$actarr['cnt'],2);
$cntarr[]=$actarr['cnt'];
}
}
array_multisort($cntarr,$avgarr,$categories);
$categoriesIn=array();$avgarrIn=array();$cntarrIn=array();
foreach($actionarrIn as $act=>$actarr)
{
if($actarr['cnt']>sizeof($alist)/150)
{
$categoriesIn[]="'$act'";
$avgarrIn[]=-round($actarr['time']/$actarr['cnt'],2);
$cntarrIn[]=$actarr['cnt'];
}
}
array_multisort($cntarrIn,$avgarrIn,$categoriesIn);*/
?>
<div class=col-md-10>
<script>
function callLogReloadFun(sortby)
{
var sortstr='';if(sortby!="")sortstr="&sort="+sortby
doAjax('dialer/relationshipreport?logdate='+$("#modfrom").val()+sortstr,'','rightmainreportdiv','ajax_dialer_reports','singlethis','GET');
}
function dlCalllogXls()
{
window.open('dialer/relationshipreport?dllogxls=1&logdate='+$("#modfrom").val());return false;
}
</script>
</div>
<div style='clear:both'></div>
<div class=col-md-10>
<script>
</script>
</div>
<div style='clear:both'></div>
<div style='overflow:auto'>
<table id=logtable class='footable table table-striped table-bordered table-white table-primary footable-loaded' style='font-size:12px'>
<thead>
<tr>
<th>#</th>
<th>Date</th>
<th>User_id</th>
<th>Disposition</th>
<th>ClientCode</th>
<th>Services</th>
</tr>
</thead>
<?php echo $outstr; ?>
</table>
</div>
<?php
function convert($size)
{
$unit=array('b','kb','mb','gb','tb','pb');
return @round($size/pow(1024,($i=floor(log($size,1024)))),2).' '.$unit[$i];
}
echo "<br>".convert(memory_get_peak_usage(true)); // 123 kb
?>
<div id=dialoglog></div>
</div>
<?php
use App\Models\CRMCall;
use App\Models\CRMCallArchive;
use App\Models\User;
use App\Jobs\KHRMSLib;
$wakka = new KHRMSLib();
$dashboarduser=Auth::user();
$timeoffset = $dashboarduser->timezone; //-330; //$dashboarduser->timezone;\
//$timeoffset = $timeoffset*60;
$timeoffset = 0;
$logtime =(isset($_GET['logtime'])) ? $_GET['logtime'] :9;
$logtimeto =(isset($_GET['logtimeto']))? $_GET['logtimeto']:20;
$logdate =(isset($_GET['logdate'])) ? strtotime($_GET['logdate']." ".$logtime.":00:00")
: strtotime(date("Y-m-d")." 09:00:00");
$logdateto =(isset($_GET['logdateto']))? strtotime($_GET['logdateto']." ".$logtimeto.":00:00")
: strtotime(date("Y-m-d")." 20:00:00");
$campaign =explode('||', (isset($_GET['campaign'])) ? $_GET['campaign'] : "All");
$state =explode('||', (isset($_GET['state'])) ? $_GET['state'] : "All");
$product =explode('||', (isset($_GET['product'])) ? $_GET['product'] : "All");
$bucket =explode('||', (isset($_GET['bucket'])) ? $_GET['bucket'] : "All");
$clientlist =$wakka->clientsReadAccess(); $clientlist; $clientlist[0] = 'All';
$alist=DB::table('crmcalls_archive AS c')->leftJoin('records', 'c.crm_id', '=', 'records.id')->where('c.user_id','!=',0);
$alist=$alist ->where('c.created_at','>=',date("Y-m-d H:i:s",$logdate))
->where('c.created_at','<=',date("Y-m-d H:i:s",$logdateto));
$displayAdv = 'none';
if(!in_array('All', $campaign)) {
$displayAdv = 'block';
$alist =$alist->whereIn('c.client',$campaign);
}
$userarr=array();
$allusers = DB::table('users as u1')->leftjoin('users AS u2', 'u2.username', '=', 'u1.supervisor')
->select('u1.id','u1.username','u1.fullname AS telecaller', 'u2.fullname AS sepervisor');
if($dashboarduser->usertype != 'Admin')
{
$uidlist=array($dashboarduser->id);
$allusers=$allusers->where(function ($query) use($dashboarduser) {
$query->where('u1.supervisor','=',$dashboarduser->username)
->orWhere('u1.lteam2','=',$dashboarduser->username)
->orWhere('u1.lteam','=',$dashboarduser->username);
})->get();
foreach($allusers as $tuser)
{
$uidlist[]=$tuser->id;
$userarr[$tuser->id] = $tuser;
}
$alist=$alist->whereIn('c.user_id',$uidlist);
/*$roclientstr=array();$didlinesstr=array();
if($dashboarduser->exten!="")$didlinesstr[]=$dashboarduser->exten;
if(!empty($clientlist))foreach($clientlist as $tclnt)if($tclnt!="")
{
$roclientstr[]="$tclnt";
$mastersdata=$wakka->getCompanyMaster($tclnt);
if(!empty($mastersdata["DialerDID"]))$didlinesstr[]=$mastersdata["DialerDID"];
}
$alist=$alist->where(function ($query) use($roclientstr,$uidlist,$didlinesstr){
$query->orWhereIn('c.client',$roclientstr)
->orWhereIn('c.did',$didlinesstr);
});*/
}
else {
$allusers=$allusers->get();
foreach($allusers as $tuser)
{
$userarr[$tuser->id] = $tuser;
}
}
<div class="layout-app">
<!-- row-app -->
<div class="row row-app">
<!-- col -->
<div class="col-md-2 col-sm-3">
<!-- col-separator -->
<div class="col-separator col-separator-first box col-unscrollable">
<!-- col-table -->
<div class="col-table" style='padding-left: 13px;padding-right: 13px;'>
<h4 class="innerAll margin-none border-bottom" style='background: #fff;'>Dialer Reports</h4>
<!-- col-table-row -->
<div class="col-table-row">
<!-- col-app -->
<div class="col-app col-unscrollable">
<!-- col-app -->
<div class="col-app">
<ul class="list-group list-group-1 margin-none borders-none" style='padding-right: 26px;'>
<li class="list-group-item">
<a href="#" onclick="doAjax('report/liveusers','','rightmainreportdiv','ajax_dialer_reports','singlethis','GET');return false"><i class="fa fa-circle-o"></i> Live</a>
</li>
<li class="list-group-item">
<a href="#" onclick="doAjax('report/calllog','','rightmainreportdiv','ajax_dialer_reports','singlethis','GET');return false"><i class="fa fa-circle-o"></i> Call</a>
</li>
<li class="list-group-item">
<a href="#" onclick="doAjax('report/agenttime','','rightmainreportdiv','ajax_dialer_reports','singlethis','GET');return false"><i class="fa fa-circle-o"></i> Login</a>
</li>
<li class="list-group-item">
<a href="#" onclick="doAjax('report/agenttimeAverage','','rightmainreportdiv','ajax_dialer_reports','singlethis','GET');return false"><i class="fa fa-circle-o"></i> Login Average</a>
</li>
<li class="list-group-item">
<a href="#" onclick="doAjax('report/campreport','','rightmainreportdiv','ajax_dialer_reports','singlethis','GET');return false"><i class="fa fa-circle-o"></i> Time</a>
</li>
<li class="list-group-item">
<a href="#" onclick="doAjax('report/statusreport','','rightmainreportdiv','ajax_dialer_reports','singlethis','GET');return false"><i class="fa fa-circle-o"></i> Status</a>
</li>
<li class="list-group-item">
<a href="#" onclick="doAjax('report/relationshipreport','','rightmainreportdiv','ajax_dialer_reports','singlethis','GET');return false"><i class="fa fa-circle-o"></i>Relationship</a>
</li>
</ul>
</div>
<!-- // END col-app -->
</div>
<!-- // END col-app -->
</div>
<!-- // END col-table-row -->
</div>
<!-- // END col-table -->
</div>
<!-- // END col-separator.box -->
</div>
<!-- // END col -->
<!-- col -->
<div class="col-md-10 col-sm-9" style='border-right:13px solid #eaeaea'>
<!-- col-separator.box -->
<div class="col-separator col-unscrollable box">
<!-- col-table -->
<div class="col-table">
<!-- col-table-row -->
<div class="col-table-row" style='background: #fff;'>
<!-- col-app -->
<div class="col-app col-unscrollable">
<!-- col-app -->
<div class="col-app" style='position:relative'>
<div class="" id=rightmainreportdiv>
<script>
doAjax('report/liveusers','','rightmainreportdiv','ajax_dialer_reports','singlethis','GET');
</script>
</div>
</div>
<!-- // END col-app -->
</div>
<!-- // END col-app.col-unscrollable -->
</div>
<!-- // END col-table-row -->
</div>
<!-- // END col-table -->
</div>
<!-- // END col-separator.box -->
</div>
<!-- // END col -->
</div>
<!-- // END row-app -->
</div>
\ No newline at end of file
<?php
use App\Jobs\KHRMSLib;
use App\Models\CRMCall;
$wakka=new KHRMSLib();
$roclientlst=$wakka->clientsReadAccess();
if(isset($_GET['pbcode']))$pbcode=$_GET['pbcode'];
else $pbcode='';
$alist=DB::table('p11086_cop_rlp_pb_base_uat')
->select(DB::Raw("*"))
->where('pbcode','=',$pbcode)
->get();
//print_r($alist);
?>
<style>#logtable.td{vertical-align:top;}#logtable.tr{height:28px;overflow-y:hidden;}</style>
<div class="layout-app"><!-- row-app -->
<div class="row row-app">
<div class="col-md-12">
<div class="col-separator col-separator-first col-unscrollable box">
<div style='clear:both;margin:2% 0 0 1%;border: 2px solid #F5F5F5;padding:2%;border-radius: 5px;'>
<center><h4>RLP PB WISE</center>
<br>
<div class='container'>
PB CODE:<select id='pb_code' class=select2multi style="width:20%;" onclick="pbcodeSelect();">
<?php foreach($roclientlst as $c){$s="";if($c==$pbcode)$s='selected';echo "<option value='$c' $s>$c</option>";} ?>
</select>
</div>
</div>
</div>
<div style='overflow:auto;margin-top: 10px;'>
<table id='logtable' class='footable table table-striped table-bordered table-white table-primary footable-loaded' style='font-size:12px';margin:0; border:1px solid #BBB;>
<thead>
<tr>
<th>Product</th>
<th>Opportunity</th>
<th>Contacted</th>
<th>Pitched</th>
<th>LG</th>
</tr>
</thead>
<tr>
<td>AL</td>
<td><?php echo $alist[0]->al_qm_opp + $alist[0]->al_upg_opp + $alist[0]->al_al_cnc_opp + $alist[0]->al_pa_opp + $alist[0]->al_zip_opp ?></td>
<td><?php echo $alist[0]->al_called_opp ?></td>
<td><?php echo $alist[0]->al_pitch ?></td>
<td><?php echo $alist[0]->al_lg ?></td>
</tr>
<tr>
<td>PL/BL</td>
<td><?php echo $alist[0]->pl_10sec_opp+$alist[0]->pl_pa_opp+$alist[0]->pl_pq_opp+$alist[0]->bl_10sec_opp+$alist[0]->bl_pq_opp ?></td>
<td><?php echo $alist[0]->pl_called_opp ?></td>
<td><?php echo $alist[0]->pl_pitch ?></td>
<td><?php echo $alist[0]->pl_lg ?></td>
</tr>
<tr>
<td>Retail Assets</td>
<td><?php echo $alist[0]->twl_pa_opp+$alist[0]->hl_pq_opp+$alist[0]->hl_bt_opp+$alist[0]->gl_pitch+$alist[0]->las_opp+$alist[0]->lap_opp ?></td>
<td><?php echo $alist[0]->twl_called_opp+$alist[0]->hl_called_opp+$alist[0]->las_called_opp+$alist[0]->lap_called_opp ?></td>
<td><?php echo $alist[0]->twl_pitch+$alist[0]->hl_pitch+$alist[0]->gl_pitch+$alist[0]->las_pitch ?></td>
<td><?php echo $alist[0]->twl_lg+$alist[0]->hl_lg+$alist[0]->gl_lg+$alist[0]->las_lg+$alist[0]->lap_lg ?></td>
</tr>
<tr>
<td>HSL</td>
<td><?php echo $alist[0]->hsl_opp ?></td>
<td><?php echo $alist[0]->hsl_called_opp ?></td>
<td><?php echo $alist[0]->hsl_pitch ?></td>
<td></td>
</tr>
<tr>
<td>Credit Card- New Sourcing</td>
<td><?php echo $alist[0]->cc_eli_new_opp ?></td>
<td><?php echo $alist[0]->cc_activation_opp ?></td>
<td><?php echo $alist[0]->cc_pitch ?></td>
<td><?php echo $alist[0]->cc_lg ?></td>
</tr>
<tr>
<td>Credit Card- LTD Activation on Carded</td>
<td><?php echo $alist[0]->cc_activation_opp ?></td>
<td><?php echo $alist[0]->cc_activation_called_opp ?></td>
<td></td>
<td</td>
</tr>
<tr>
<td>Insurance LI</td>
<td><?php echo $alist[0]->li_opp ?></td>
<td><?php echo $alist[0]->li_called_opp ?></td>
<td></td>
<td></td>
</tr>
<tr>
<td>FD</td>
<td><?php echo $alist[0]->fd_opp ?></td>
<td><?php echo $alist[0]->fd_called_opp ?></td>
<td><?php echo $alist[0]->fd_pitch ?></td>
<td></td>
</tr>
<tr>
<td>LTD Activation-Savings Account</td>
<td><?php echo $alist[0]->ltd_act_saving_opp ?></td>
<td><?php echo $alist[0]->ltd_act_saving_opp ?></td>
<td></td>
<td></td>
</tr>
<tr>
<td>NB/MB Activations</td>
<td><?php echo $alist[0]->mb_opp ?></td>
<td><?php echo $alist[0]->mb_called_opp ?></td>
<td><?php echo $alist[0]->mb_pitch ?></td>
<td><?php echo $alist[0]->nb_mb_lg ?></td>
</tr>
<tr>
<td>Aadhar Seeding</td>
<td><?php echo $alist[0]->aadhaar_opp ?></td>
<td><?php echo $alist[0]->aadhaar_called_opp ?></td>
<td><?php echo $alist[0]->aadhaar_pitch ?></td>
<td><?php echo $alist[0]->aadhaar_activation ?></td>
</tr>
<tr>
<td>Digital Activation</td>
<td><?php echo $alist[0]->digi2_score_opp ?></td>
<td><?php echo $alist[0]->digi2_score_called_opp ?></td>
<td></td>
<td></td>
</tr>
<tr>
<td>BillPayments</td>
<td><?php echo $alist[0]->digi_billpay_opp ?></td>
<td><?php echo $alist[0]->digi_billpay_called_opp ?></td>
<td><?php echo $alist[0]->bill_pay_pitch ?></td>
<td></td>
</tr>
<tr>
<td>Financial Transactions</td>
<td><?php echo $alist[0]->digi_basic_banking_opp ?></td>
<td><?php echo $alist[0]->digi_basic_banking_called_opp ?></td>
<td></td>
<td></td>
</tr>
<tr>
<td>Digital 2.0 Score(Ecom Shopping Inactive)</td>
<td><?php echo $alist[0]->digi_ecom_shopping_opp ?></td>
<td><?php echo $alist[0]->digi_ecom_shopping_called_opp ?></td>
<td></td>
<td> </td>
</tr>
<tr>
<td>Digital 2.0 Score(Investment Inactive)</td>
<td><?php echo $alist[0]->digi_investment_opp ?></td>
<td><?php echo $alist[0]->digi_investment_called_opp ?></td>
<td><?php echo $alist[0]->invest_pitch ?></td>
<td></td>
</tr>
<tr>
<td>Reduction in Physical Transactions</td>
<td><?php echo $alist[0]->invest_pitch ?></td>
<td><?php echo $alist[0]->invest_pitch ?></td>
<td></td>
<td></td>
</tr>
<tr>
<td>% of Groups Contacted</td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td>Movement of Groups to higher engagement</td>
<td> </td>
<td> </td>
<td> </td>
<td></td>
</tr>
<tr>
<td>CASA Growth</td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td>Mutual Fund</td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
</table>
</div>
<div id=dialoglog></div>
</div>
</div>
</div>
<style>#logtable.td{vertical-align:top;}#logtable.tr{height:28px;overflow-y:hidden;}</style>
<script>
$(document).ready(function()
{
if(!$('#dialoglog').hasClass('ui-dialog-content'))
{
$('#dialoglog').dialog({
autoOpen: false,
width: '70%',
buttons: {
"Ok": function() {
$(this).dialog("close");
},
"Cancel": function() {
$(this).dialog("close");
}
}
});
}
waitKeyUpRun("filter",function() { filter2(document.getElementById('filter'), 'logtable') },"2000");
});
function pbcodeSelect()
{
var pbcode=$('#pb_code').val();
doAjax('rlp?pbcode='+pbcode,'','content','ajax_rlp','singlethis','GET');
}
</script>
\ No newline at end of file
<style>
#logtable.td{vertical-align:top;}#logtable.tr{height:28px;overflow-y:hidden;}
.select2-container-multi{height: 90px; overflow-y: auto;border: 1px solid #efefef;border-radius: 3px !important;}
.select2-container-active{height: 90px; overflow-y: auto;border: 1px solid #5897fb;border-radius: 3px !important;}
.select2-container-multi.select2-container-active.select2-choices{border:none !important; box-shadow: none !important;}
.select2-choices{border:none !important; box-shadow: none !important;}
.select2-drop,.select2-drop-active{border-color: #5897fb;margin-top: -9px;}
</style>
<?php
if($param) {
$clientlist = array_filter($clientlist, function($var) use ($param) { return (strpos(trim($var), $param) !== 0) ? false : true; });
}
?>
<div class=innerAll>
<h4 style="float:left;width:50%;margin:10px 0;">{{ $reportTitle }}</h4>
<div style="float:right;width:50%" id="download_btn">
<button class="pull-right btn btn-sm btn-default" onclick='dlAgentlogXls();return false;' title='Download'><i class='fa fa-download'></i> Download</button>
</div>
<div style="clear:both"></div>
<hr style="margin-bottom: 5px;">
<div>
Search <input id=filter name="filter" type="text" style="border:1px solid #efefef; padding: 2px 10px;">&nbsp;&nbsp;
Date: From <input size=10 id='modfrom' name='modfrom' type='text' value='<?php echo date("Y-m-d",$logdate); ?>' onchange='statusLogReloadFun("");' />
<select id="modtime" style="border:1px solid #efefef;" onchange='statusLogReloadFun("");'>
<?php
foreach (range(0,23) as $hour) {
$selected = ($hour == $logtime) ? "selected" : "";
echo "<option value='$hour' $selected>".str_pad($hour, 2, "0", STR_PAD_LEFT) . ":00</option>";
}
?></select>
To <input size=10 id='modto' name='modto' type='text' value='<?php echo date("Y-m-d",$logdateto); ?>' onchange='statusLogReloadFun("");' />
<select id="modtimeto" style="border:1px solid #efefef;" onchange='statusLogReloadFun("");'>
<?php
foreach (range(0,23) as $hour) {
$selected = ($hour == $logtimeto) ? "selected" : "";
echo "<option value='$hour' $selected>".str_pad($hour, 2, "0", STR_PAD_LEFT) . ":00</option>";
}
?></select>&nbsp;&nbsp;
<button class="pull-right btn btn-sm btn-default" onclick='$("#advance").toggle();' title='Advance Search'><i class='fa fa-search'></i> Advance Search</button>
<div style="clear:both"></div>
<div style="margin-top: 5px; display:{{ $displayAdv }};" id="advance">
<div style="width: 80%;" class="pull-left">
Campaign
<select id="campaignbox" multiple="multiple" style="width:25%" class=select2multi>
<?php foreach($clientlist as $c)
{ $s="";
if($param) {
$s='selected';
echo "<option value='$c' $s>$c</option>";
} else {
if(in_array($c, $campaign))$s='selected';
echo "<option value='$c' $s>$c</option>";
}
}?>
</select>
</div>
<div style="margin-top: 5px;" class="pull-right">
<button class="pull-right btn btn-sm btn-default" onclick='statusLogReloadFun("");' title='Search'><i class='fa fa-search'></i> Search</button>
</div>
</div>
</div>
<div style="clear:both"></div>
<hr style="margin:5px;">
<script>
$(document).ready(function() {
waitKeyUpRun("filter",function() { filter2(document.getElementById('filter'), 'logtable') },"2000");
$('#modfrom').datepicker({dateFormat: 'yy-mm-dd',inline: true,changeYear: true,selectOtherMonths: true,yearRange: '<?php echo (date('Y')-70).":".(date('Y')+5); ?>'});
$('#modto').datepicker({dateFormat: 'yy-mm-dd',inline: true,changeYear: true,selectOtherMonths: true,yearRange: '<?php echo (date('Y')-70).":".(date('Y')+5); ?>'});
});
function dataString()
{
var campaignStr = '';
$('#campaignbox :selected') .each(function(i, sel){
if(campaignStr != '') campaignStr = campaignStr + '||' + $(sel).val();
else campaignStr = $(sel).val();
});
return 'logdate='+$("#modfrom").val()+'&logtime='+$("#modtime").val()+'&logdateto='+$("#modto").val()+'&logtimeto='+$("#modtimeto").val()+'&campaign='+campaignStr;
}
function statusLogReloadFun(sortby)
{
var sortstr='';if(sortby!="")sortstr="&sort="+sortby
var searchStr = dataString();
doAjax('dialer/{{ $returnblade }}?'+searchStr+sortstr,'','rightmainreportdiv','ajax_dialer_reports','singlethis','GET');
}
function dlAgentlogXls()
{
var searchStr = dataString();
window.open('dialer/{{ $returnblade }}?dllogxls=1&'+searchStr);
return false;
}
function breakupXls(report,userId,column)
{
var searchStr = dataString();
window.open('dialer/breakupxls?report='+report+'&userId='+userId+'&column='+column+'&'+searchStr);
return false;
}
function displayMode(mode) {
if(mode == 'percent') {
$(".summation").hide();
$(".percent").show();
}
else {
$(".percent").hide();
$(".summation").show();
}
}
</script>
<?php
use App\Models\CRMCall;
use App\Models\User;
use App\Jobs\KHRMSLib;
$wakka = new KHRMSLib();
$dashboarduser=Auth::user();
if(isset($_GET['logdate']))$logdate=strtotime($_GET['logdate']." 00:00:00");
else $logdate=strtotime(date('Y-m-d')." 00:00:00");
$alist=CRMCall::where('created_at','>=',date("Y-m-d H:i:s",$logdate))->where('created_at','<=',date("Y-m-d H:i:s",$logdate+24*60*60));
//if(!$dashboarduser->moduleACL("Dialer",false,false,true))
if($dashboarduser->usertype != 'Admin')
{
$uidlist=array($dashboarduser->id);
$allusers=User::where(function ($query) use($dashboarduser) {
$query->where('supervisor','=',$dashboarduser->username)
->orWhere('lteam2','=',$dashboarduser->username)
->orWhere('lteam','=',$dashboarduser->username);
})->get();
// ->where(function ($query) {
// $query->where('status', '=', 'Active');
// })->get();
foreach($allusers as $tuser)$uidlist[]=$tuser->id;
$roclientstr=array();$didlinesstr=array();
if($dashboarduser->exten!="")$didlinesstr[]=$dashboarduser->exten;
$oclientlst=$wakka->clientsReadAccess();
if(!empty($oclientlst))foreach($oclientlst as $tclnt)if($tclnt!="")
{
$roclientstr[]="$tclnt";
$mastersdata=$wakka->getCompanyMaster($tclnt);
if(!empty($mastersdata["DialerDID"]))$didlinesstr[]=$mastersdata["DialerDID"];
}
$alist=$alist->where(function ($query) use($roclientstr,$uidlist,$didlinesstr){
$query->orWhereIn('client',$roclientstr)
->orWhereIn('user_id',$uidlist)
->orWhereIn('did',$didlinesstr);
});
}
$alist=$alist->get();
$userarr=array();$i=1;
$reporthead=array("#","UserId","User","Name","Count","Total");
$reportarray=array();
foreach($alist as $aline)
{
if(!isset($userarr[$aline->user_id]))$userarr[$aline->user_id]=User::find($aline->user_id);
$tuser=$userarr[$aline->user_id];
if(!isset($reportarray[$aline->user_id]))$reportarray[$aline->user_id]=array("#"=>$i++,"UserId"=>$tuser->id,"User"=>$tuser->username,"Name"=>$tuser->fullname,"Count"=>0,"Total"=>0,"Wait"=>0,"Call"=>0,"Talk"=>0,"Dispo"=>0);
$talktime=$aline->talkSec+$aline->recstartSec+$aline->recendSec;
$reportarray[$aline->user_id]["Count"]++;
$reportarray[$aline->user_id]["Total"]+=round(($aline->waitSec+$aline->callSec+$talktime+$aline->dispoSec)/1000,2);
$ststr=$aline->userstatus."-".$aline->usersubstatus;
if(!in_array($ststr,$reporthead))$reporthead[]=$ststr;
$reportarray[$aline->user_id][$ststr]++;
}
if(Input::has("dllogxls"))
{
include_once(app_path().'/lib/phpexcel/PHPExcel.php');
$inputFileType = "Excel5";
$objReader = PHPExcel_IOFactory::createReader($inputFileType);
$objPHPExcel = $objReader->load("assets/extras/blank.xls");
$baseRow = 3;
$highestColumn = sizeof($reporthead);
for ($head = 0; $head < $highestColumn; $head++){
$colstr=PHPExcel_Cell::stringFromColumnIndex($head);
$objPHPExcel->getActiveSheet()->setCellValue($colstr."1", $reporthead[$head]);
}
foreach($reportarray as $uid=>$uarr)
{
$row = $baseRow++;
$col = 0;
for ($head = 0; $head < $highestColumn; $head++){
$colstr=PHPExcel_Cell::stringFromColumnIndex($head);
$objPHPExcel->getActiveSheet()->setCellValue($colstr.$row, $uarr[$reporthead[$head]]);
}
}
header('Content-Type: application/vnd.ms-excel');
header('Content-Disposition: attachment;filename="StatusLog.xls"');
header('Cache-Control: max-age=0');
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, $inputFileType);
$objWriter->save('php://output');
return ;
}
$highestColumn = sizeof($reporthead);
$outhead="<tr>";$outstr="";
for ($head = 0; $head < $highestColumn; $head++){
$outhead.="<td>".$reporthead[$head]."</td>";
}
$outhead.="</tr>";
foreach($reportarray as $uid=>$uarr)
{
if(!empty($uarr['UserId'])){
$outstr.="<tr>";
for ($head = 0; $head < $highestColumn; $head++){
$outstr.="<td>".$uarr[$reporthead[$head]]."</td>";
}
$outstr.="</tr>";
}else{
$outstr.="<tr>";
for ($head = 0; $head < $highestColumn; $head++){
if($reporthead[$head]=='UserId'){
$outstr.="<td>Inbound</td>";
}else{
$outstr.="<td>".$uarr[$reporthead[$head]]."</td>";
}
}
$outstr.="</tr>";
}
}
//charts
$cat1=array();
$cat1arr=array();
foreach($reportarray as $uid=>$uarr)
{
$cat1[]="'$uarr[UserName]'";
for ($head = 5; $head < $highestColumn; $head++){
if(!isset($cat1arr[$reporthead[$head]]))$cat1arr[$reporthead[$head]]=array();
$cat1arr[$reporthead[$head]][$uarr["#"]]=round($uarr[$reporthead[$head]],1);
if(empty($cat1arr[$reporthead[$head]][$uarr["#"]]))$cat1arr[$reporthead[$head]][$uarr["#"]]=0;
}
}
$cat1arrstr="";
foreach($cat1arr as $name=>$data)
{
$extra="";if($name=="InboundDROP-InboundDROP")$extra=",visible: false";
$cat1arrstr.="{ name: '$name',\ndata : [";
$cat1arrstr.=implode(",",$data);
$cat1arrstr.="] $extra },\n";
}
$cat2=array();
foreach($reportarray as $uid=>$uarr)
{
for ($head = 5; $head < $highestColumn; $head++){
$cat2["'".$reporthead[$head]."'"]+=round($uarr[$reporthead[$head]],1);
}
}
?>
<div class=innerAll>
<style>#logtable.td{vertical-align:top;}#logtable.tr{height:28px;overflow-y:hidden;}</style>
<script>
$(document).ready(function()
{
if(!$('#dialoglog').hasClass('ui-dialog-content'))
{
$('#dialoglog').dialog({
autoOpen: false,
width: '70%',
buttons: {
"Ok": function() {
$(this).dialog("close");
},
"Cancel": function() {
$(this).dialog("close");
}
}
});
}
waitKeyUpRun("filter",function() { filter2(document.getElementById('filter'), 'logtable') },"2000");
$('#modfrom').datepicker({dateFormat: 'yy-mm-dd',inline: true,changeYear: true,selectOtherMonths: true,yearRange: '<?php echo (date('Y')-70).":".(date('Y')+5); ?>'});
});
</script>
<div style="float:left;width:50%">
Search <input id=filter name="filter" type="text">
Date : <input size=10 id='modfrom' name='modfrom' type='text' value='<?php echo date("Y-m-d",$logdate); ?>' onchange='statusLogReloadFun("");' />
</div>
<div style="float:left;width:50%">
<button class="pull-right btn btn-sm btn-default" onclick='dlAgentlogXls();return false;' title='Download' style='margin-top:-8px'><i class='fa fa-download'></i> Download</button>
</div>
<div style="clear:both"></div>
<hr>
<!--div class=col-md-12>
<div id=userlogschart1 style='min-height:300px;width:100%'></div>
<script>
$(function () {
$('#userlogschart1').highcharts({
chart: {
type: 'column'
},
title: {
text: ''
},
xAxis: {
labels:{
enabled:false//default is true
},
categories: [<?php echo implode(",",$cat1); ?>]
},
yAxis: {
min: 0,
title: {
text: ''
},
stackLabels: {
enabled: false,
// style: {
// fontWeight: '',
// color: (Highcharts.theme && Highcharts.theme.textColor) || 'gray'
// }
}
},
// legend: {
// align: 'right',
// x: -30,
// verticalAlign: 'top',
// y: 25,
// floating: true,
// backgroundColor: (Highcharts.theme && Highcharts.theme.background2) || 'white',
// borderColor: '#CCC',
// borderWidth: 1,
// shadow: false
// },
tooltip: {
headerFormat: '<b>{point.x}</b><br/>',
pointFormat: '{series.name}: {point.y}<br/>Total: {point.stackTotal}'
},
plotOptions: {
column: {
stacking: 'normal',
dataLabels: {
enabled: false,
// color: (Highcharts.theme && Highcharts.theme.dataLabelsColor) || 'white',
// style: {
// textShadow: '0 0 3px black'
// }
}
}
},
series: [<?php echo $cat1arrstr; ?>]
});
});
function statusLogReloadFun(sortby)
{
var sortstr='';if(sortby!="")sortstr="&sort="+sortby
doAjax('dialer/statusreport?logdate='+$("#modfrom").val()+sortstr,'','rightmainreportdiv','ajax_dialer_reports','singlethis','GET');
}
function dlAgentlogXls()
{
window.open('dialer/statusreport?dllogxls=1&logdate='+$("#modfrom").val());return false;
}
</script>
</div -->
<script>
function statusLogReloadFun(sortby)
{
var sortstr='';if(sortby!="")sortstr="&sort="+sortby
doAjax('dialer/statusreport?logdate='+$("#modfrom").val()+sortstr,'','rightmainreportdiv','ajax_dialer_reports','singlethis','GET');
}
function dlAgentlogXls()
{
window.open('dialer/statusreport?dllogxls=1&logdate='+$("#modfrom").val());return false;
}
</script>
<div style='clear:both'></div>
<div class=col-md-12>
<div id=userlogschart2 style='min-height:300px;width:100%'></div>
<script>
$(function () {
$('#userlogschart2').highcharts({
chart: {
type: 'column'
},
title: {
text: ''
},
subtitle: {
text: ''
},
xAxis: {
categories: [<?php echo implode(",",array_keys($cat2)); ?>],
crosshair: true,
labels:{
enabled:false//default is true
},
},
yAxis: {
min: 0,
title: {
text: ''
}
},
tooltip: {
headerFormat: '<span style="font-size:10px">{point.key}</span><table>',
pointFormat: '<tr><td style="color:{series.color};padding:0">{series.name}: </td>' +
'<td style="padding:0"><b>{point.y:.1f}</b></td></tr>',
footerFormat: '</table>',
shared: true,
useHTML: true
},
plotOptions: {
column: {
pointPadding: 0.2,
borderWidth: 0
}
},
legend : {
floating: true,
align: 'right',
x: -30,
verticalAlign: 'top',
},
series: [{
name: 'Count',
data: [<?php echo implode(",",array_values($cat2)); ?>]
},]
});
});
</script>
</div>
<div style='clear:both'></div>
<div style='overflow:auto'>
<table id=logtable class='footable table table-striped table-bordered table-white table-primary footable-loaded' style='font-size:12px'>
<thead>
<?php echo $outhead; ?>
</thead>
<?php echo $outstr; ?>
</table>
</div>
<div id=dialoglog></div>
</div>
<?php
use App\Models\CRMCall;
use App\Models\User;
use App\Jobs\KHRMSLib;
$wakka = new KHRMSLib();
$dashboarduser=Auth::user();
if(isset($_GET['logdate']))$logdate=strtotime($_GET['logdate']." 00:00:00");
else $logdate=strtotime(date('Y-m-d')." 00:00:00");
$alist=CRMCall::where('created_at','>=',date("Y-m-d H:i:s",$logdate))->where('created_at','<=',date("Y-m-d H:i:s",$logdate+24*60*60));
//if(!$dashboarduser->moduleACL("Dialer",false,false,true))
if($dashboarduser->usertype != 'Admin')
{
$uidlist=array($dashboarduser->id);
$allusers=User::where(function ($query) use($dashboarduser) {
$query->where('supervisor','=',$dashboarduser->username)
->orWhere('lteam2','=',$dashboarduser->username)
->orWhere('lteam','=',$dashboarduser->username);
})->get();
// ->where(function ($query) {
// $query->where('status', '=', 'Active');
// })->get();
foreach($allusers as $tuser)$uidlist[]=$tuser->id;
$roclientstr=array();$didlinesstr=array();
if($dashboarduser->exten!="")$didlinesstr[]=$dashboarduser->exten;
$oclientlst=$wakka->clientsReadAccess();
if(!empty($oclientlst))foreach($oclientlst as $tclnt)if($tclnt!="")
{
$roclientstr[]="$tclnt";
$mastersdata=$wakka->getCompanyMaster($tclnt);
if(!empty($mastersdata["DialerDID"]))$didlinesstr[]=$mastersdata["DialerDID"];
}
$alist=$alist->where(function ($query) use($roclientstr,$uidlist,$didlinesstr){
$query->orWhereIn('client',$roclientstr)
->orWhereIn('user_id',$uidlist)
->orWhereIn('did',$didlinesstr);
});
}
$alist=$alist->get();
$userarr=array();$i=1;
$reporthead=array("id","created_at","updated_at","sup_id","message","status");
$reportarray=DB::table('supervisor_message')->where('sup_id','=',Auth::user()->username)->select('*')->get();
if(Input::has("dllogxls"))
{
include_once(app_path().'/lib/phpexcel/PHPExcel.php');
$inputFileType = "Excel5";
$objReader = PHPExcel_IOFactory::createReader($inputFileType);
$objPHPExcel = $objReader->load("assets/extras/blank.xls");
$baseRow = 2;
$highestColumn = sizeof($reporthead);
for ($head = 0; $head < $highestColumn; $head++){
$colstr=PHPExcel_Cell::stringFromColumnIndex($head);
$objPHPExcel->getActiveSheet()->setCellValue($colstr."1", $reporthead[$head]);
}
foreach($reportarray as $uid=>$uarr)
{
$row = $baseRow++;
$col = 0;
for ($head = 0; $head < $highestColumn; $head++){
if($reporthead[$head]=="created_at")
$uarr->$reporthead[$head]=date("Y-m-d H:i:s",strtotime($uarr->$reporthead[$head])+330*60);
if($reporthead[$head]=="updated_at")
$uarr->$reporthead[$head]=date("Y-m-d H:i:s",strtotime($uarr->$reporthead[$head])+330*60);
$colstr=PHPExcel_Cell::stringFromColumnIndex($head);
$objPHPExcel->getActiveSheet()->setCellValue($colstr.$row, $uarr->$reporthead[$head]);
}
}
header('Content-Type: application/vnd.ms-excel');
header('Content-Disposition: attachment;filename="Messages.xls"');
header('Cache-Control: max-age=0');
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, $inputFileType);
$objWriter->save('php://output');
return ;
}
?>
<div class=innerAll>
<style>#logtable.td{vertical-align:top;}#logtable.tr{height:28px;overflow-y:hidden;}</style>
<script>
$(document).ready(function()
{
if(!$('#dialoglog').hasClass('ui-dialog-content'))
{
$('#dialoglog').dialog({
autoOpen: false,
width: '70%',
buttons: {
"Ok": function() {
$(this).dialog("close");
},
"Cancel": function() {
$(this).dialog("close");
}
}
});
}
waitKeyUpRun("filter",function() { filter2(document.getElementById('filter'), 'logtable') },"2000");
$('#modfrom').datepicker({dateFormat: 'yy-mm-dd',inline: true,changeYear: true,selectOtherMonths: true,yearRange: '<?php echo (date('Y')-70).":".(date('Y')+5); ?>'});
$('#modto').datepicker({dateFormat: 'yy-mm-dd',inline: true,changeYear: true,selectOtherMonths: true,yearRange: '<?php echo (date('Y')-70).":".(date('Y')+5); ?>'});
});
</script>
<div style="float:left;width:50%">
</div>
<div style="float:right;width:50%">
<button class="pull-right btn btn-sm btn-default" onclick='dlAgentlogXls();return false;' title='Download' style='margin-top:-8px'><i class='fa fa-download'></i> Download</button>
</div>
<div style="clear:both"></div>
<hr>
<div class=col-md-12>
<div id=userlogschart1 style='min-height:300px;width:100%'></div>
</div>
<script>
function dlAgentlogXls()
{
window.open('dialer/supmessages?dllogxls=1&logdate='+$("#modfrom").val());return false;
}
</script>
<div style='clear:both'></div>
<div class=col-md-12>
<div id=userlogschart2 style='min-height:300px;width:100%'></div>
</div>
<div style='clear:both'></div>
<div style='overflow:auto'>
<table id=logtable class='footable table table-striped table-bordered table-white table-primary footable-loaded' style='font-size:12px'>
<thead>
<?php /*echo $outhead;*/ ?>
</thead>
<?php /*echo $outstr;*/ ?>
</table>
</div>
<div id=dialoglog></div>
</div>
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!