5523f66a by Manish Mihsra

Added diallines condition before start calling

1 parent 862aa821
...@@ -305,55 +305,57 @@ class CreateCall extends Command { ...@@ -305,55 +305,57 @@ class CreateCall extends Command {
305 305
306 if(sizeof($users)>=1) 306 if(sizeof($users)>=1)
307 { 307 {
308 DB::table('records_'.$client)->where('id',$users[0]['id'])->update(['filter_condition'=>'2','modified'=>date("Y-m-d H:i:s")]); 308 $dialline=Dialline::where('server','=', env('app_ip'))->where("status","=","Free")->where("enabled","=","1")->where("dialstr", "=", $availDialStr)->orderBy('updated_at','ASC')->first();
309 309
310 $record=$wakka->getPerson($users[0]['id'],$client); 310 if(!empty($dialline))
311 if($record)
312 { 311 {
313 $record["peopledata"]["status"]="AutoCall"; 312 $dialline->status="AutoCall";
314 $wakka->setPerson($users[0]['id'],$record,$client); 313 $dialline->regexstr=$client;
315 // DB::table('records_'.$client)->where('id',$users[0]['id'])->update(['filter_condition'=>'2','modified'=>date("Y-m-d H:i:s")]); 314 $dialline->number=$users[0]["mobile"];
316 } 315 $dialline->save();
317 316
318 $dialline=Dialline::where('server','=', env('app_ip'))->where("status","=","Free")->where("enabled","=","1")->where("dialstr", "=", $availDialStr)->orderBy('updated_at','ASC')->first(); 317 DB::table('records_'.$client)->where('id',$users[0]['id'])->update(['filter_condition'=>'2','modified'=>date("Y-m-d H:i:s")]);
319 318
320 $dialline->status="AutoCall"; 319 $record=$wakka->getPerson($users[0]['id'],$client);
321 $dialline->regexstr=$client; 320 if($record)
322 $dialline->number=$users[0]["mobile"]; 321 {
323 $dialline->save(); 322 $record["peopledata"]["status"]="AutoCall";
323 $wakka->setPerson($users[0]['id'],$record,$client);
324 }
324 325
325 $nowts=microtime(true)*1000; 326 $nowts=microtime(true)*1000;
326 327
327 //start the call log 328 //start the call log
328 $crmcall=new CRMCall(); 329 $crmcall=new CRMCall();
329 $crmcall->number=$users[0]["mobile"]; 330 $crmcall->number=$users[0]["mobile"];
330 $crmcall->user_id=0; 331 $crmcall->user_id=0;
331 $crmcall->sipid_id=0; 332 $crmcall->sipid_id=0;
332 $crmcall->crm_id=$users[0]['id']; 333 $crmcall->crm_id=$users[0]['id'];
333 //$crmcall->lan=$users[0]['lan']; 334 //$crmcall->lan=$users[0]['lan'];
334 $crmcall->client=$users[0]['client']; 335 $crmcall->client=$users[0]['client'];
335 $crmcall->department=$users[0]['department']; 336 $crmcall->department=$users[0]['department'];
336 $crmcall->state='New'; 337 $crmcall->state='New';
337 $crmcall->type="AutoCall"; 338 $crmcall->type="AutoCall";
338 $crmcall->dialline_id=$dialline->id; 339 $crmcall->dialline_id=$dialline->id;
339 340
340 $crmcall->setTs('ts_Wait',$nowts); 341 $crmcall->setTs('ts_Wait',$nowts);
341 $crmcall->setTs('ts_Call',$nowts); 342 $crmcall->setTs('ts_Call',$nowts);
342 343
343 $crmcall->did=$callerid; 344 $crmcall->did=$callerid;
344 345
345 $tdata=array(); 346 $tdata=array();
346 $crmcall->data=json_encode($tdata); 347 $crmcall->data=json_encode($tdata);
347 $crmcall->save(); 348 $crmcall->save();
348 349
349 $dialline->call_id=$crmcall->id; 350 $dialline->call_id=$crmcall->id;
350 $dialline->save(); 351 $dialline->save();
351 352
352 //start actual calls 353 //start actual calls
353 $newqueue=new Kqueue(); 354 $newqueue=new Kqueue();
354 $newqueue->autoCallOut($users[0]["mobile"],$callerid,$crmcall,$dialline); 355 $newqueue->autoCallOut($users[0]["mobile"],$callerid,$crmcall,$dialline);
355 356
356 return 1; 357 return 1;
358 }
357 } 359 }
358 return 0; 360 return 0;
359 } 361 }
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!