Calllogupdate, userlogtest and rmconnect updates
Showing
3 changed files
with
294 additions
and
2 deletions
| ... | @@ -70,10 +70,24 @@ class Calllogupdate extends Command { | ... | @@ -70,10 +70,24 @@ class Calllogupdate extends Command { |
| 70 | $server_id="0".$server_id; | 70 | $server_id="0".$server_id; |
| 71 | } | 71 | } |
| 72 | 72 | ||
| 73 | $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'")); | ||
| 73 | 74 | ||
| 74 | 75 | ||
| 75 | 76 | $alistupdate=DB::select(DB::raw("SELECT id,userstatus,usersubstatus from crmcalls where created_at>'".date("Y-m-d",$logdate)."'")); | |
| 76 | $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))."'")); | 77 | foreach ($alist as $aline) { |
| 78 | foreach($alistupdate as $cline) | ||
| 79 | { | ||
| 80 | if( $aline->crmcall_id == $cline->id ){ | ||
| 81 | if( $aline->dispo != $cline->userstatus){ | ||
| 82 | echo " ^ DISPo".$aline->dispo." ^ ".$cline->userstatus." ^ ".$aline->crmcall_id." ^ ".$cline->id; | ||
| 83 | }else{ | ||
| 84 | echo " ^ ElseDISPo".$aline->dispo." ^ ".$cline->userstatus." ^ ".$aline->crmcall_id." ^ ".$cline->id; | ||
| 85 | } | ||
| 86 | } | ||
| 87 | } | ||
| 88 | } | ||
| 89 | exit; | ||
| 90 | try{ | ||
| 77 | foreach ($alistupdate as $aline) { | 91 | foreach ($alistupdate as $aline) { |
| 78 | $clientcode="";$currentstatus="";$legalstatus="";$record_id=""; | 92 | $clientcode="";$currentstatus="";$legalstatus="";$record_id=""; |
| 79 | if($aline->crm_id>0) | 93 | if($aline->crm_id>0) |
| ... | @@ -139,10 +153,15 @@ class Calllogupdate extends Command { | ... | @@ -139,10 +153,15 @@ class Calllogupdate extends Command { |
| 139 | 153 | ||
| 140 | 154 | ||
| 141 | } | 155 | } |
| 156 | } | ||
| 157 | catch(Exception $e){ | ||
| 158 | echo $e->getMessage(),"\n"; | ||
| 159 | }finally { | ||
| 142 | 160 | ||
| 143 | echo "\n".date('Y-m-d H:i:s')."\n"; | 161 | echo "\n".date('Y-m-d H:i:s')."\n"; |
| 144 | DB::connection("conn")->disconnect(); | 162 | DB::connection("conn")->disconnect(); |
| 145 | } | 163 | } |
| 164 | } | ||
| 146 | 165 | ||
| 147 | } | 166 | } |
| 148 | 167 | ... | ... |
| 1 | <?php namespace App\Console\Commands; | ||
| 2 | |||
| 3 | use Illuminate\Console\Command; | ||
| 4 | use DB; | ||
| 5 | use Config; | ||
| 6 | |||
| 7 | use App\Models\User; | ||
| 8 | use App\Models\Accesslog; | ||
| 9 | |||
| 10 | use App\Models\CRMCall; | ||
| 11 | use Schema; | ||
| 12 | use PDO; | ||
| 13 | |||
| 14 | use Illuminate\Database\Schema\Blueprint; | ||
| 15 | |||
| 16 | class Userlog_data_test extends Command { | ||
| 17 | |||
| 18 | /** | ||
| 19 | * The console command name. | ||
| 20 | * | ||
| 21 | * @var string | ||
| 22 | */ | ||
| 23 | protected $signature = 'Userlog_data_test'; | ||
| 24 | |||
| 25 | /** | ||
| 26 | * The console command description. | ||
| 27 | * | ||
| 28 | * @var string | ||
| 29 | */ | ||
| 30 | protected $description = 'Userlog_data_test'; | ||
| 31 | |||
| 32 | /** | ||
| 33 | * Execute the console command. | ||
| 34 | * | ||
| 35 | * @return mixed | ||
| 36 | */ | ||
| 37 | public function handle() | ||
| 38 | { | ||
| 39 | $nowts=time(); | ||
| 40 | echo "\n".date('Y-m-d')."\n"; | ||
| 41 | |||
| 42 | $logdate=strtotime('-1 day'); | ||
| 43 | $date=date('F_Y'); | ||
| 44 | echo date("Y-m-d",$logdate); | ||
| 45 | $tcol=0;$fieldsarr=array();$extrahdrarr=array(); | ||
| 46 | $server_ip=env('app_ip'); | ||
| 47 | $central_ip=env('central_ip'); | ||
| 48 | |||
| 49 | $conn = array( | ||
| 50 | 'driver' => 'mysql', | ||
| 51 | 'host' => $central_ip, | ||
| 52 | 'database' => env('DB_DATABASE', 'kstych_flexydial'), | ||
| 53 | 'username' => env('DB_USERNAME', 'root'), | ||
| 54 | 'password' => env('DB_PASSWORD', ''), | ||
| 55 | 'charset' => 'utf8', | ||
| 56 | 'collation' => 'utf8_unicode_ci', | ||
| 57 | 'prefix' => '', | ||
| 58 | 'options' => array( | ||
| 59 | PDO::ATTR_TIMEOUT => 5, | ||
| 60 | ), | ||
| 61 | ); | ||
| 62 | Config::set("database.connections.conn", $conn); | ||
| 63 | if(DB::connection("conn")->getDatabaseName()) | ||
| 64 | { | ||
| 65 | $serverclist=DB::connection("conn")->select(DB::raw("select id from server_details where server_ip='$server_ip'")); | ||
| 66 | $server_id=$serverclist[0]->id; | ||
| 67 | if($server_id<10){ | ||
| 68 | $server_id="0".$server_id; | ||
| 69 | } | ||
| 70 | |||
| 71 | |||
| 72 | $i=0; | ||
| 73 | |||
| 74 | |||
| 75 | $ulist=DB::select(DB::raw("select * from users WHERE 1")); | ||
| 76 | foreach($ulist as $uline) { | ||
| 77 | $users[$uline->id] = $uline->username; | ||
| 78 | } | ||
| 79 | 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)."'"))){ | ||
| 80 | |||
| 81 | |||
| 82 | foreach($alist as $aline) { | ||
| 83 | $i++; | ||
| 84 | $global_id = $server_id . $i; | ||
| 85 | if($aline->enddate=='0000-00-00'|| $aline->endtime=='00:00:00' || $aline->durationsec=='0') | ||
| 86 | { | ||
| 87 | $enddatetime=date("Y-m-d H:i:s",strtotime($aline->updated_at)); | ||
| 88 | $enddate=explode(" ",$enddatetime)[0]; | ||
| 89 | $endtime=explode(" ",$enddatetime)[1]; | ||
| 90 | //echo "endtime".$endtime; | ||
| 91 | //$durationsec=date("Y-m-d H:i:s",strtotime($endtime-$aline->starttime)); | ||
| 92 | $durationsec=strtotime(date("Y-m-d H:i:s",strtotime($endtime)-strtotime($aline->starttime))); | ||
| 93 | //echo "durationsec".$durationsec; | ||
| 94 | if($aline->created_at==$aline->updated_at){ $durationsec=0; } | ||
| 95 | } | ||
| 96 | else | ||
| 97 | { | ||
| 98 | $enddate=$aline->enddate; | ||
| 99 | $endtime=$aline->endtime; | ||
| 100 | $durationsec=$aline->durationsec; | ||
| 101 | } | ||
| 102 | //echo $endtime."^".$enddate."^".$durationsec; | ||
| 103 | $rowdata = array('server'=>$server_id,'server_ip'=>$server_ip,'global_id'=>$global_id,'id'=>$aline->id, | ||
| 104 | 'created_at'=>$aline->created_at,'updated_at'=>$aline->updated_at,'user_id'=>$aline->user_id,'user'=>$users[$aline->user_id], | ||
| 105 | 'startdate'=>$aline->startdate,'starttime'=>$aline->starttime,'enddate'=>$enddate,'endtime'=>$endtime, | ||
| 106 | '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'=>'' | ||
| 107 | ); | ||
| 108 | |||
| 109 | $data=json_decode($aline->data,true); | ||
| 110 | foreach($data as $sipid=>$sdata) | ||
| 111 | { | ||
| 112 | $prets= isset($sdata[1]) ? $sdata[1] : (strtotime($aline->startdate . " " . $aline->starttime)+19600)*1000; | ||
| 113 | if(isset($sdata['states'])) | ||
| 114 | { | ||
| 115 | $previous="login"; | ||
| 116 | foreach($sdata['states'] as $fts=>$states) | ||
| 117 | { | ||
| 118 | if($states[0] != 1) | ||
| 119 | { | ||
| 120 | //if($previous!='paused-wrapup'){ | ||
| 121 | $rowdata[$previous] +=round(($fts-$prets)/1000,2); | ||
| 122 | |||
| 123 | $previous = (trim($states[1]) != '') ? strtolower($states[0]."-".$states[1]) : strtolower($states[0]); | ||
| 124 | $prets=$fts; | ||
| 125 | //} | ||
| 126 | } | ||
| 127 | |||
| 128 | } | ||
| 129 | $rowdata[$previous] += round(($sdata['ts']-$prets)/1000,2); | ||
| 130 | } | ||
| 131 | } | ||
| 132 | //$rowdata["login"] = $aline->durationsec; | ||
| 133 | $rowdata["login"] = $durationsec; | ||
| 134 | |||
| 135 | //$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']; | ||
| 136 | /*$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']);*/ | ||
| 137 | |||
| 138 | |||
| 139 | $key_value = ''; | ||
| 140 | /*foreach($rowdata AS $key=>$value) { | ||
| 141 | //if($key == 1){ $key } | ||
| 142 | if($key != 1 && $key != 'paused-wrapup'){ | ||
| 143 | $key_value .= "`$key` = '$value', "; | ||
| 144 | } | ||
| 145 | }*/ | ||
| 146 | |||
| 147 | $startTime=$aline->startdate." ".$aline->starttime; | ||
| 148 | |||
| 149 | //$endTime=$aline->enddate." ".$aline->endtime; | ||
| 150 | if($aline->enddate=='0000-00-00'|| $aline->endtime=='00:00:00' || $aline->durationsec=='0') | ||
| 151 | { | ||
| 152 | $endTime=date("Y-m-d H:i:s",strtotime($aline->updated_at)); | ||
| 153 | }else{ | ||
| 154 | $endTime=$aline->enddate." ".$aline->endtime; | ||
| 155 | } | ||
| 156 | //$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."'")); | ||
| 157 | $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."'")); | ||
| 158 | |||
| 159 | $ts_Wait=0;$ts_Call=0;$ts_Talk=0;$ts_Dispo=0; | ||
| 160 | $progTs_Wait=0;$progTs_Call=0;$progTs_Talk=0;$progTs_Dispo=0; | ||
| 161 | $manTs_Wait=0;$manTs_Call=0;$manTs_Talk=0;$manTs_Dispo=0; | ||
| 162 | $inbTs_Wait=0;$inbTs_Call=0;$inbTs_Talk=0;$inbTs_Dispo=0; | ||
| 163 | $tt_prog=0;$tt_man=0;$tt_inb=0; | ||
| 164 | $force_Close=0;$force_Wait=0;$force_Call=0;$force_Talk=0;$force_Dispo=0; | ||
| 165 | |||
| 166 | if($crmCalls!=null){ | ||
| 167 | foreach($crmCalls as $crmCall){ | ||
| 168 | /*$ts_Wait += round(($crmCall->ts_Call - $crmCall->ts_Wait)/1000,2); | ||
| 169 | $ts_Call += round(($crmCall->ts_Talk - $crmCall->ts_Call)/1000,2); | ||
| 170 | $ts_Talk += round(($crmCall->ts_Dispo - $crmCall->ts_Talk)/1000,2); | ||
| 171 | $ts_Dispo += round(($crmCall->ts_Close - $crmCall->ts_Dispo)/1000,2);*/ | ||
| 172 | if($crmCall->userstatus =='FORCEDCLOSE' || $crmCall->updated_at > $endTime) | ||
| 173 | { | ||
| 174 | $force_Wait += round(($crmCall->ts_Call - $crmCall->ts_Wait)/1000,2); | ||
| 175 | $force_Call += round(($crmCall->ts_Talk - $crmCall->ts_Call)/1000,2); | ||
| 176 | $force_Talk += round(($crmCall->ts_Dispo - $crmCall->ts_Talk)/1000,2); | ||
| 177 | $force_Dispo += round(($crmCall->ts_Close - $crmCall->ts_Dispo)/1000,2); | ||
| 178 | }else{ | ||
| 179 | $ts_Wait += round(($crmCall->ts_Call - $crmCall->ts_Wait)/1000,2); | ||
| 180 | $ts_Call += round(($crmCall->ts_Talk - $crmCall->ts_Call)/1000,2); | ||
| 181 | $ts_Talk += round(($crmCall->ts_Dispo - $crmCall->ts_Talk)/1000,2); | ||
| 182 | $ts_Dispo += round(($crmCall->ts_Close - $crmCall->ts_Dispo)/1000,2); | ||
| 183 | if($crmCall->type == 'Progressive') | ||
| 184 | { | ||
| 185 | $progTs_Wait += round(($crmCall->ts_Call - $crmCall->ts_Wait)/1000,2); | ||
| 186 | $progTs_Call += round(($crmCall->ts_Talk - $crmCall->ts_Call)/1000,2); | ||
| 187 | $progTs_Talk += round(($crmCall->ts_Dispo - $crmCall->ts_Talk)/1000,2); | ||
| 188 | $progTs_Dispo += round(($crmCall->ts_Close - $crmCall->ts_Dispo)/1000,2); | ||
| 189 | } | ||
| 190 | |||
| 191 | if($crmCall->type == 'Manual') | ||
| 192 | { | ||
| 193 | /*$manTs_Wait += round($crmCall->waitSec/1000,2); | ||
| 194 | $manTs_Call += round($crmCall->callSec/1000,2); | ||
| 195 | $manTs_Talk += round(($crmCall->talkSec+$crmCall->recstartSec+$crmCall->recendSec)/1000,2); | ||
| 196 | $manTs_Dispo += round($crmCall->dispoSec/1000,2);*/ | ||
| 197 | $manTs_Wait += round(($crmCall->ts_Call - $crmCall->ts_Wait)/1000,2); | ||
| 198 | $manTs_Call += round(($crmCall->ts_Talk - $crmCall->ts_Call)/1000,2); | ||
| 199 | $manTs_Talk += round(($crmCall->ts_Dispo - $crmCall->ts_Talk)/1000,2); | ||
| 200 | $manTs_Dispo += round(($crmCall->ts_Close - $crmCall->ts_Dispo)/1000,2); | ||
| 201 | //echo round($crmCall->dispoSec/1000,2).":"; | ||
| 202 | } | ||
| 203 | |||
| 204 | if($crmCall->type == 'Inbound') | ||
| 205 | { | ||
| 206 | $inbTs_Wait += round(($crmCall->ts_Call - $crmCall->ts_Wait)/1000,2); | ||
| 207 | $inbTs_Call += round(($crmCall->ts_Talk - $crmCall->ts_Call)/1000,2); | ||
| 208 | $inbTs_Talk += round(($crmCall->ts_Dispo - $crmCall->ts_Talk)/1000,2); | ||
| 209 | $inbTs_Dispo += round(($crmCall->ts_Close - $crmCall->ts_Dispo)/1000,2); | ||
| 210 | } | ||
| 211 | } | ||
| 212 | } | ||
| 213 | } | ||
| 214 | //print_r($manTs_Dispo); | ||
| 215 | $tt_prog = $progTs_Wait + $progTs_Call + $progTs_Talk + $progTs_Dispo; | ||
| 216 | $tt_man = $manTs_Wait + $manTs_Call + $manTs_Talk + $manTs_Dispo; | ||
| 217 | $tt_inb = $inbTs_Wait + $inbTs_Call + $inbTs_Talk + $inbTs_Dispo; | ||
| 218 | $tt_act_inb=$tt_inb-$inbTs_Call; | ||
| 219 | $prod_TOS = $ts_Wait + $ts_Call + $ts_Talk + $ts_Dispo; | ||
| 220 | $force_Close = $force_Wait + $force_Call + $force_Talk + $force_Dispo; | ||
| 221 | $key_value .= "`tt_prog` = '$tt_prog', "; | ||
| 222 | $key_value .= "`tt_man` = '$tt_man', "; | ||
| 223 | $key_value .= "`tt_inb` = '$tt_inb', "; | ||
| 224 | |||
| 225 | $key_value .= "`force_Close` = '$force_Close',"; | ||
| 226 | $key_value .= "`ts_Wait` = '$ts_Wait', "; | ||
| 227 | $key_value .= "`ts_Call` = '$ts_Call', "; | ||
| 228 | $key_value .= "`ts_Talk` = '$ts_Talk', "; | ||
| 229 | $key_value .= "`ts_Dispo` = '$ts_Dispo', "; | ||
| 230 | $key_value .= "`progts_Wait` = '$progTs_Wait', "; | ||
| 231 | $key_value .= "`progts_Call` = '$progTs_Call', "; | ||
| 232 | $key_value .= "`progts_Talk` = '$progTs_Talk', "; | ||
| 233 | $key_value .= "`progts_Dispo` = '$progTs_Dispo', "; | ||
| 234 | $key_value .= "`mants_Wait` = '$manTs_Wait', "; | ||
| 235 | $key_value .= "`mants_Call` = '$manTs_Call', "; | ||
| 236 | $key_value .= "`mants_Talk` = '$manTs_Talk', "; | ||
| 237 | $key_value .= "`mants_Dispo` = '$manTs_Dispo', "; | ||
| 238 | $key_value .= "`incts_Wait` = '$inbTs_Wait', "; | ||
| 239 | $key_value .= "`incts_Call` = '$inbTs_Call', "; | ||
| 240 | $key_value .= "`incts_Talk` = '$inbTs_Talk', "; | ||
| 241 | $key_value .= "`incts_Dispo` = '$inbTs_Dispo', "; | ||
| 242 | $key_value .= "`prod_tos` = '$prod_TOS', "; | ||
| 243 | |||
| 244 | $key_value .= "`manual` = '$tt_man',"; | ||
| 245 | $key_value .= "`progressive` = '$tt_prog',"; | ||
| 246 | $key_value .= "`ready-incoming` = '$tt_act_inb',"; | ||
| 247 | $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); | ||
| 248 | //$key_value = ''; | ||
| 249 | foreach($rowdata AS $key=>$value) { | ||
| 250 | //if($key == 1){ $key } | ||
| 251 | if($key != 1 && $key != 'paused-wrapup' && $key != 'progressive' && $key != 'manual' && $key != 'ready-incoming'){ | ||
| 252 | $key_value .= "`$key` = '$value', "; | ||
| 253 | } | ||
| 254 | } | ||
| 255 | $key_value = substr($key_value, 0, -2); | ||
| 256 | //print_r($key_value); | ||
| 257 | $userlogsTable = "userlogs_".$date; | ||
| 258 | //echo $userlogsTable; | ||
| 259 | DB::connection("conn")->insert(DB::raw("INSERT INTO ".$userlogsTable." SET $key_value")); | ||
| 260 | //DB::connection("conn")->insert(DB::raw("INSERT INTO userlogs_13_11_2018_bk SET $key_value")); | ||
| 261 | |||
| 262 | } | ||
| 263 | |||
| 264 | } | ||
| 265 | } | ||
| 266 | } | ||
| 267 | } |
| ... | @@ -1197,8 +1197,14 @@ class KPAMIListen implements IEventListener | ... | @@ -1197,8 +1197,14 @@ class KPAMIListen implements IEventListener |
| 1197 | foreach($allsipids as $tsip) | 1197 | foreach($allsipids as $tsip) |
| 1198 | { | 1198 | { |
| 1199 | $newqueue=new Kqueue(); | 1199 | $newqueue=new Kqueue(); |
| 1200 | include( app_path() . '/Hacks/DisabledDIDs.php'); | ||
| 1201 | if( in_array(substr($crmcall->number,-10),$DisableNumbersArray) ){ | ||
| 1202 | $newqueue->sipNotify($tsip,"popupalert"," Incoming Calls","RM-Connect |".$crmcall->client,""); | ||
| 1203 | }else{ | ||
| 1200 | $newqueue->sipNotify($tsip,"popupalert"," Incoming Calls",$crmcall->number."|".$crmcall->client,""); | 1204 | $newqueue->sipNotify($tsip,"popupalert"," Incoming Calls",$crmcall->number."|".$crmcall->client,""); |
| 1201 | } | 1205 | } |
| 1206 | //$newqueue->sipNotify($tsip,"popupalert"," Incoming Calls",$crmcall->number."|".$crmcall->client,""); | ||
| 1207 | } | ||
| 1202 | } | 1208 | } |
| 1203 | else | 1209 | else |
| 1204 | { | 1210 | { | ... | ... |
-
Please register or sign in to post a comment