8bd22406 by G Manojkumar

Calllogupdate, userlogtest and rmconnect updates

1 parent 8f391294
......@@ -70,10 +70,24 @@ class Calllogupdate extends Command {
$server_id="0".$server_id;
}
$alist=DB::connection("conn")->select(DB::raw("select crmcall_id,dispo,subdispo from $calllog_report where created_at>'".date("Y-m-d",$logdate)."' and server='$server_id'"));
$alistupdate=DB::select(DB::raw("SELECT * from crmcalls where call_flag='Z' and created_at <= '".date("Y-m-d H:i:s",$logdate-(05*60))."'"));
$alistupdate=DB::select(DB::raw("SELECT id,userstatus,usersubstatus from crmcalls where created_at>'".date("Y-m-d",$logdate)."'"));
foreach ($alist as $aline) {
foreach($alistupdate as $cline)
{
if( $aline->crmcall_id == $cline->id ){
if( $aline->dispo != $cline->userstatus){
echo " ^ DISPo".$aline->dispo." ^ ".$cline->userstatus." ^ ".$aline->crmcall_id." ^ ".$cline->id;
}else{
echo " ^ ElseDISPo".$aline->dispo." ^ ".$cline->userstatus." ^ ".$aline->crmcall_id." ^ ".$cline->id;
}
}
}
}
exit;
try{
foreach ($alistupdate as $aline) {
$clientcode="";$currentstatus="";$legalstatus="";$record_id="";
if($aline->crm_id>0)
......@@ -139,10 +153,15 @@ class Calllogupdate extends Command {
}
}
catch(Exception $e){
echo $e->getMessage(),"\n";
}finally {
echo "\n".date('Y-m-d H:i:s')."\n";
DB::connection("conn")->disconnect();
}
}
}
......
<?php namespace App\Console\Commands;
use Illuminate\Console\Command;
use DB;
use Config;
use App\Models\User;
use App\Models\Accesslog;
use App\Models\CRMCall;
use Schema;
use PDO;
use Illuminate\Database\Schema\Blueprint;
class Userlog_data_test extends Command {
/**
* The console command name.
*
* @var string
*/
protected $signature = 'Userlog_data_test';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Userlog_data_test';
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
$nowts=time();
echo "\n".date('Y-m-d')."\n";
$logdate=strtotime('-1 day');
$date=date('F_Y');
echo date("Y-m-d",$logdate);
$tcol=0;$fieldsarr=array();$extrahdrarr=array();
$server_ip=env('app_ip');
$central_ip=env('central_ip');
$conn = array(
'driver' => 'mysql',
'host' => $central_ip,
'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", $conn);
if(DB::connection("conn")->getDatabaseName())
{
$serverclist=DB::connection("conn")->select(DB::raw("select id from server_details where server_ip='$server_ip'"));
$server_id=$serverclist[0]->id;
if($server_id<10){
$server_id="0".$server_id;
}
$i=0;
$ulist=DB::select(DB::raw("select * from users WHERE 1"));
foreach($ulist as $uline) {
$users[$uline->id] = $uline->username;
}
if($alist=DB::select(DB::raw("select * from userlogs WHERE created_at>'".date("Y-m-d",$logdate)."' and created_at<'".date("Y-m-d",$logdate+24*60*60)."'"))){
foreach($alist as $aline) {
$i++;
$global_id = $server_id . $i;
if($aline->enddate=='0000-00-00'|| $aline->endtime=='00:00:00' || $aline->durationsec=='0')
{
$enddatetime=date("Y-m-d H:i:s",strtotime($aline->updated_at));
$enddate=explode(" ",$enddatetime)[0];
$endtime=explode(" ",$enddatetime)[1];
//echo "endtime".$endtime;
//$durationsec=date("Y-m-d H:i:s",strtotime($endtime-$aline->starttime));
$durationsec=strtotime(date("Y-m-d H:i:s",strtotime($endtime)-strtotime($aline->starttime)));
//echo "durationsec".$durationsec;
if($aline->created_at==$aline->updated_at){ $durationsec=0; }
}
else
{
$enddate=$aline->enddate;
$endtime=$aline->endtime;
$durationsec=$aline->durationsec;
}
//echo $endtime."^".$enddate."^".$durationsec;
$rowdata = array('server'=>$server_id,'server_ip'=>$server_ip,'global_id'=>$global_id,'id'=>$aline->id,
'created_at'=>$aline->created_at,'updated_at'=>$aline->updated_at,'user_id'=>$aline->user_id,'user'=>$users[$aline->user_id],
'startdate'=>$aline->startdate,'starttime'=>$aline->starttime,'enddate'=>$enddate,'endtime'=>$endtime,
'durationsec'=>$durationsec,'group'=>$aline->group,'login'=>'','dialnext'=>'','manual'=>'','paused'=>'','paused-agentbriefing'=>'','paused-downtime'=>'','paused-floorannouncements'=>'','paused-incoming'=>'','paused-lunchbreak'=>'','paused-manual'=>'','paused-notready'=>'','paused-qualityfeedback'=>'','paused-wrapup'=>'','paused-teabreak'=>'','paused-teammeeting'=>'','paused-utilitybreak'=>'','paused-autowrapup'=>'','progressive'=>'','ready-incoming'=>''
);
$data=json_decode($aline->data,true);
foreach($data as $sipid=>$sdata)
{
$prets= isset($sdata[1]) ? $sdata[1] : (strtotime($aline->startdate . " " . $aline->starttime)+19600)*1000;
if(isset($sdata['states']))
{
$previous="login";
foreach($sdata['states'] as $fts=>$states)
{
if($states[0] != 1)
{
//if($previous!='paused-wrapup'){
$rowdata[$previous] +=round(($fts-$prets)/1000,2);
$previous = (trim($states[1]) != '') ? strtolower($states[0]."-".$states[1]) : strtolower($states[0]);
$prets=$fts;
//}
}
}
$rowdata[$previous] += round(($sdata['ts']-$prets)/1000,2);
}
}
//$rowdata["login"] = $aline->durationsec;
$rowdata["login"] = $durationsec;
//$rowdata['not-ready']=$rowdata['paused-agentbriefing']+$rowdata['paused-autowrapup']+$rowdata['paused-downtime']+$rowdata['paused-floorannouncements']+$rowdata['paused-lunchbreak']+$rowdata['paused-notready']+$rowdata['paused-qualityfeedback']+$rowdata['paused-teammeeting']+$rowdata['paused-teabreak']+$rowdata['paused-utilitybreak'];
/*$rowdata["not-ready"] = $durationsec-($rowdata['dialnext']+$rowdata['manual']+$rowdata['paused']+$rowdata['paused-agentbriefing']+$rowdata['paused-downtime']+$rowdata['paused-floorannouncements']+$rowdata['paused-incoming']+$rowdata['paused-lunchbreak']+$rowdata['paused-manual']+$rowdata['paused-notready']+$rowdata['paused-qualityfeedback']+$rowdata['paused-teabreak']+$rowdata['paused-teammeeting']+$rowdata['paused-utilitybreak']+$rowdata['paused-autowrapup']+$rowdata['progressive']+$rowdata['ready-incoming']);*/
$key_value = '';
/*foreach($rowdata AS $key=>$value) {
//if($key == 1){ $key }
if($key != 1 && $key != 'paused-wrapup'){
$key_value .= "`$key` = '$value', ";
}
}*/
$startTime=$aline->startdate." ".$aline->starttime;
//$endTime=$aline->enddate." ".$aline->endtime;
if($aline->enddate=='0000-00-00'|| $aline->endtime=='00:00:00' || $aline->durationsec=='0')
{
$endTime=date("Y-m-d H:i:s",strtotime($aline->updated_at));
}else{
$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,waitSec,callSec,talkSec,recstartSec,recendSec,dispoSec from crmcalls WHERE created_at>='".$startTime."' and updated_at<'".$endTime."' and user_id='".$aline->user_id."'"));
$crmCalls=DB::select(DB::raw("select updated_at,user_id,type,userstatus,ts_Wait,ts_Call,ts_Talk,ts_Recstart,ts_Recend,ts_Dispo,ts_Close from crmcalls WHERE created_at>='".$startTime."' and created_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;
$force_Close=0;$force_Wait=0;$force_Call=0;$force_Talk=0;$force_Dispo=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->userstatus =='FORCEDCLOSE' || $crmCall->updated_at > $endTime)
{
$force_Wait += round(($crmCall->ts_Call - $crmCall->ts_Wait)/1000,2);
$force_Call += round(($crmCall->ts_Talk - $crmCall->ts_Call)/1000,2);
$force_Talk += round(($crmCall->ts_Dispo - $crmCall->ts_Talk)/1000,2);
$force_Dispo += round(($crmCall->ts_Close - $crmCall->ts_Dispo)/1000,2);
}else{
$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->waitSec/1000,2);
$manTs_Call += round($crmCall->callSec/1000,2);
$manTs_Talk += round(($crmCall->talkSec+$crmCall->recstartSec+$crmCall->recendSec)/1000,2);
$manTs_Dispo += round($crmCall->dispoSec/1000,2);*/
$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);
//echo round($crmCall->dispoSec/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);
}
}
}
}
//print_r($manTs_Dispo);
$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;
$tt_act_inb=$tt_inb-$inbTs_Call;
$prod_TOS = $ts_Wait + $ts_Call + $ts_Talk + $ts_Dispo;
$force_Close = $force_Wait + $force_Call + $force_Talk + $force_Dispo;
$key_value .= "`tt_prog` = '$tt_prog', ";
$key_value .= "`tt_man` = '$tt_man', ";
$key_value .= "`tt_inb` = '$tt_inb', ";
$key_value .= "`force_Close` = '$force_Close',";
$key_value .= "`ts_Wait` = '$ts_Wait', ";
$key_value .= "`ts_Call` = '$ts_Call', ";
$key_value .= "`ts_Talk` = '$ts_Talk', ";
$key_value .= "`ts_Dispo` = '$ts_Dispo', ";
$key_value .= "`progts_Wait` = '$progTs_Wait', ";
$key_value .= "`progts_Call` = '$progTs_Call', ";
$key_value .= "`progts_Talk` = '$progTs_Talk', ";
$key_value .= "`progts_Dispo` = '$progTs_Dispo', ";
$key_value .= "`mants_Wait` = '$manTs_Wait', ";
$key_value .= "`mants_Call` = '$manTs_Call', ";
$key_value .= "`mants_Talk` = '$manTs_Talk', ";
$key_value .= "`mants_Dispo` = '$manTs_Dispo', ";
$key_value .= "`incts_Wait` = '$inbTs_Wait', ";
$key_value .= "`incts_Call` = '$inbTs_Call', ";
$key_value .= "`incts_Talk` = '$inbTs_Talk', ";
$key_value .= "`incts_Dispo` = '$inbTs_Dispo', ";
$key_value .= "`prod_tos` = '$prod_TOS', ";
$key_value .= "`manual` = '$tt_man',";
$key_value .= "`progressive` = '$tt_prog',";
$key_value .= "`ready-incoming` = '$tt_act_inb',";
$rowdata["not-ready"] = $durationsec-($rowdata['dialnext']+$rowdata['paused']+$rowdata['paused-agentbriefing']+$rowdata['paused-downtime']+$rowdata['paused-floorannouncements']+$rowdata['paused-incoming']+$rowdata['paused-lunchbreak']+$rowdata['paused-manual']+$rowdata['paused-notready']+$rowdata['paused-qualityfeedback']+$rowdata['paused-teabreak']+$rowdata['paused-teammeeting']+$rowdata['paused-utilitybreak']+$rowdata['paused-autowrapup']+$tt_man+$tt_prog+$tt_act_inb);
//$key_value = '';
foreach($rowdata AS $key=>$value) {
//if($key == 1){ $key }
if($key != 1 && $key != 'paused-wrapup' && $key != 'progressive' && $key != 'manual' && $key != 'ready-incoming'){
$key_value .= "`$key` = '$value', ";
}
}
$key_value = substr($key_value, 0, -2);
//print_r($key_value);
$userlogsTable = "userlogs_".$date;
//echo $userlogsTable;
DB::connection("conn")->insert(DB::raw("INSERT INTO ".$userlogsTable." SET $key_value"));
//DB::connection("conn")->insert(DB::raw("INSERT INTO userlogs_13_11_2018_bk SET $key_value"));
}
}
}
}
}
......@@ -1197,8 +1197,14 @@ class KPAMIListen implements IEventListener
foreach($allsipids as $tsip)
{
$newqueue=new Kqueue();
include( app_path() . '/Hacks/DisabledDIDs.php');
if( in_array(substr($crmcall->number,-10),$DisableNumbersArray) ){
$newqueue->sipNotify($tsip,"popupalert"," Incoming Calls","RM-Connect |".$crmcall->client,"");
}else{
$newqueue->sipNotify($tsip,"popupalert"," Incoming Calls",$crmcall->number."|".$crmcall->client,"");
}
//$newqueue->sipNotify($tsip,"popupalert"," Incoming Calls",$crmcall->number."|".$crmcall->client,"");
}
}
else
{
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!