a02abcee by Manish Mihsra

Added New Monitoring Report

1 parent c5a7b341
......@@ -21,6 +21,7 @@ use App\Models\Cutoff;
use App\Jobs\KHRMSLib;
use App\Models\Sipid;
use App\Models\Dialline;
use App\Models\User;
use App\Models\UserLog;
use App\Models\Kqueue;
use DB;
......@@ -37,14 +38,122 @@ class ReportController extends Controller
public function show($id)
{
$data = array();
$wakka = new KHRMSLib();
$dashboarduser = Auth::user();
$timeoffset = $dashboarduser->timezone; //-330; //$dashboarduser->timezone;
$timeoffset = $timeoffset*60;
if($id=="reports")
{
return view("layout.module.reports.reports",array());
}
if($id=="campaigns")
return view("layout.module.reports.reports");
}
$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'] : "Select";
$oclientlst = $wakka->clientsReadAccess();
sort($oclientlst);
$oclientlst[0] = 'Select';
$data['wakka'] = $wakka;
$data['dashboarduser'] = $dashboarduser;
$data['timeoffset'] = $timeoffset;
$data['logtime'] = $logtime;
$data['logtimeto'] = $logtimeto;
$data['logdate'] = $logdate;
$data['logdateto'] = $logdateto;
$data['campaign'] = $campaign;
$data['oclientlst'] = $oclientlst;
if($id=="liveusers")
{
return view("layout.module.reports.campaigns",array());
$campStr = "";
$ratio = 0;
$totalCall = 0;
$dialedCall = 0;
$waitCall = 0;
$inCall = 0;
$availChnl = 0;
$usrIdArr = array();
$tabHeadStr = "";
$tabBodyStr = "";
foreach($oclientlst as $c)
{
$s="";
if($c==$campaign)$s='selected';
$campStr .= "<option value='$c' $s>$c</option>";
}
if ($campaign != "Select") {
$mastersdata=$wakka->getCompanyMaster($campaign);
if(!empty($mastersdata["autodialercampaign"]))$ratio=$mastersdata["autodialercampaign"];
$userArr = User::where('presence', '=', "1")->where('sel_campaign', '=', $campaign)->select('id','username','fullname','current_dialmode')->get();
$diallineArr = Dialline::where("enabled","=","1")->get();
$totalChnl = $diallineArr->count();
foreach ($diallineArr as $dialline) {
if($dialline->status!= 'Free')$totalCall++;
if($dialline->status!= 'Free' && $dialline->src_channel!= '' && $dialline->channel== '')$dialedCall++;
if($dialline->status== 'Auto' && $dialline->conf== '' && $dialline->src_channel!= '' && $dialline->channel!= '')$waitCall++;
if($dialline->status!= 'Free' && $dialline->conf!= '')$inCall++;
}
$availChnl = $totalChnl - $totalCall;
$tabHeadStr .= "<tr>
<th>User</th>
<th>Campaign</th>
<th>Mode</th>
<th>Status</th>
</tr>";
foreach ($userArr as $usr) {
$usrIdArr[] = $usr->id;
$statusStr = "<span class='btn btn-sm btn-warning'>Free</span>";
$sipIdArr = Sipid::where('user', "=", $usr->id)->where('status', '=', 1)->select('id', 'status', 'ready', 'patched')->first();
if($sipIdArr->ready==1)$statusStr = "<span class='btn btn-sm btn-success'>Available</span>";
if($sipIdArr->patched==1)$statusStr = "<span class='btn btn-sm btn-info'>OnCall</span>";
if($sipIdArr->prepare_call==1&&$sipIdArr->patched==0)$statusStr = "<span class='btn btn-sm btn-info'>Wrap-Up</span>";
$tabBodyStr .= "<tr><td>".$usr->fullname."</td>";
$tabBodyStr .= "<td>".$campaign."</td>";
$tabBodyStr .= "<td>".$usr->current_dialmode."</td>";
$tabBodyStr .= "<td>".$statusStr."</td></tr>";
}
$freeUsr = Sipid::whereIn('user',$usrIdArr)->where('status', '=', 1)->where('ready', '=', 1)->where('patched', '=', 0)->count();
$data['ratio'] = $ratio;
$data['totalUsr'] = $userArr->count();
$data['totalChnl'] = $totalChnl;
$data['availChnl'] = $availChnl;
$data['dialedCall'] = $dialedCall;
$data['waitCall'] = $waitCall;
$data['inCall'] = $inCall;
$data['freeUsr'] = $totalChnl;
$data['tabHeadStr'] = $tabHeadStr;
$data['tabBodyStr'] = $tabBodyStr;
}
$data['campStr'] = $campStr;
return view("layout.module.reports.liveusers", $data);
}
if($id=="calllog")
......@@ -52,9 +161,14 @@ class ReportController extends Controller
return view("layout.module.reports.calllog",array());
}
if($id=="agentreport")
if($id=="agenttime")
{
return view("layout.module.reports.agentreport",array());
return view("layout.module.reports.agenttime",array());
}
if($id=="agenttimeAverage")
{
return view("layout.module.reports.agenttimeAverage",array());
}
if($id=="campreport")
......@@ -67,34 +181,9 @@ class ReportController extends Controller
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")
if($id=="relationshipreport")
{
return view("layout.module.reports.recqc",array());
return view("layout.module.reports.relationshipreport",array());
}
}
}
......
......@@ -478,6 +478,12 @@ class KPAMIListen implements IEventListener
$tsip=Sipid::find($crmcall->sipid_id);
if(!empty($tsip))
{
$tsip->patched=0;
$tsip->save();
}
//$newqueue=new Kqueue();
//$newqueue->playhangupfile($dialline->channel,$dialline->server);
......@@ -733,6 +739,7 @@ class KPAMIListen implements IEventListener
$dialline=Dialline::find($crmcall->dialline_id);
if($dialline)
{
$dialline->src_channel=$dchannel;
$dialline->channel=$dchannel;
$dialline->save();
}
......@@ -745,7 +752,30 @@ class KPAMIListen implements IEventListener
$crmcall->save();
}
}
}else if($accountcodearr[1]=="a")
{
$crmcall=CRMCall::find($accountcodearr[2]);
if($crmcall)
{
$nowts=microtime(true)*1000;
$crmcall->setTs('ts_Call',$nowts);
$crmcall->state=$eventname;
$dialline=Dialline::find($crmcall->dialline_id);
if($dialline)
{
$dialline->src_channel=$dchannel;
$dialline->save();
}
$crmcall->addEventLog($nowts,"$accountcode:Unknown : $eventname $dchannelstate:$dchannelstatedesc $duniqueid $dexten:$dpriority $channel $dialstring");
$crmcall->save();
}
}
}
}
......@@ -805,18 +835,22 @@ class KPAMIListen implements IEventListener
$crmcall->state=$eventname;
$crmcall->status=$dialstatus;
$tsip=Sipid::find($crmcall->sipid_id);
$tsip->patched=1;
$tsip->save();
$dialline=Dialline::find($crmcall->dialline_id);
if($dialline)
{
$dialline->conf="1000".$tsip->id;
$dialline->channel=$channel;
$dialline->save();
}
$recfile=$crmcall->newRecFilePath();
$tsip=Sipid::find($crmcall->sipid_id);
//start recording
$newqueue=new Kqueue();
$newqueue->recordChannel($tsip->server,$dchannel,$recfile);
......@@ -957,6 +991,7 @@ class KPAMIListen implements IEventListener
$dialline=Dialline::find($crmcall->dialline_id);
if($dialline)
{
$dialline->src_channel=$dchannel;
$dialline->channel=$dchannel;
$dialline->save();
}
......@@ -969,7 +1004,30 @@ class KPAMIListen implements IEventListener
$crmcall->save();
}
}
}else if($accountcodearr[1]=="a")
{
$crmcall=CRMCall::find($accountcodearr[2]);
if($crmcall)
{
$nowts=microtime(true)*1000;
$crmcall->setTs('ts_Call',$nowts);
$crmcall->state=$eventname;
$dialline=Dialline::find($crmcall->dialline_id);
if($dialline)
{
$dialline->src_channel=$dchannel;
$dialline->save();
}
$crmcall->addEventLog($nowts,"$accountcode:Unknown : $eventname $dchannelstate:$dchannelstatedesc $duniqueid $dexten:$dpriority $channel $dialstring");
$crmcall->save();
}
}
}
}
......@@ -1034,17 +1092,21 @@ class KPAMIListen implements IEventListener
$crmcall->state=$eventname;
$crmcall->status=$dialstatus;
$tsip=Sipid::find($crmcall->sipid_id);
$tsip->patched=1;
$tsip->save();
$dialline=Dialline::find($crmcall->dialline_id);
if($dialline)
{
$dialline->conf="1000".$tsip->id;
$dialline->channel=$channel;
$dialline->save();
}
$recfile=$crmcall->newRecFilePath();
$tsip=Sipid::find($crmcall->sipid_id);
//start recording
$newqueue=new Kqueue();
$newqueue->recordChannel($tsip->server,$dchannel,$recfile);
......@@ -1534,8 +1596,10 @@ class KPAMIListen implements IEventListener
$crmcall->save();
$dialline->conf="1000".$found->id;
$dialline->user_id = $found->user;
$dialline->conf = "1000".$found->id;
$dialline->save();
if($crmcall->crm_id>0){
DB::table('records')->where('id',$crmcall->crm_id)->update(['filter_condition'=>'3','usr_id'=>$found->user]);
......
......@@ -14,7 +14,7 @@ class User extends Authenticatable
protected $table = 'users';
protected $hidden = array('password');
protected $fillable = array('username','password','email','status','organization','group','data');
protected $fillable = array('username','password','email','status','organization','group','data','sel_campaign','current_dialmode');
private $dataarr=array();
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!