c1717535 by Nitesh

stop dual load on calling

1 parent 8126045c
......@@ -2,31 +2,23 @@
namespace App\Http\Controllers;
use Auth;
use Input;
use Response;
use App\Http\Controllers\HomeController;
use App\Models\Group;
use App\Models\Master;
use App\Models\Record;
use App\Jobs\DialerLib;
use App\Jobs\KHRMSLib;
use App\Models\AgentNumber;
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\Jobs\DialerLib;
use App\Models\Sipid;
use App\Models\Dialline;
use App\Models\AgentNumber;
use App\Models\UserLog;
use App\Models\User;
use App\Models\Kqueue;
use App\Models\QCFeedback;
use App\Models\Sipid;
use App\Models\User;
use App\Models\UserLog;
use Auth;
use DB;
use Log;
use Session;
use Input;
use Response;
$client = '';
......@@ -109,7 +101,6 @@ class DialerController extends Controller
$userlogData = UserLog::where('user_id', '=', $user)->orderBy("id", "DESC")->first();
$content = '';
$content .= "freeDialline::" . $freeDialline . PHP_EOL . PHP_EOL;
$content .= "waitingDiallineToPatch::" . $waitingToPatch . PHP_EOL . PHP_EOL;
......@@ -148,18 +139,29 @@ class DialerController extends Controller
$roclientstr = array();
$oclientlst = $wakka->clientsReadAccess();
if (!empty($oclientlst)) foreach ($oclientlst as $tclnt) if ($tclnt != "") {
if (!empty($oclientlst)) {
foreach ($oclientlst as $tclnt) {
if ($tclnt != "") {
$roclientstr[] = "'$tclnt'";
}
}
}
$roclientstr = "";
$roclientstr[] = "'$client'";
if (!empty($roclientstr)) $roclientstr = "and client in (" . implode(",", $roclientstr) . ")";
else $roclientstr = "";
if (!empty($roclientstr)) {
$roclientstr = "and client in (" . implode(",", $roclientstr) . ")";
} else {
$roclientstr = "";
}
$users = array();
$searchresult = "";
if (!empty($kstychCall["previewcrmid"])) $users = $wakka->getPersons("id='" . $kstychCall["previewcrmid"] . "' $roclientstr limit 1");
else $users = $this->getCallSequencing(1, $client);
if (!empty($kstychCall["previewcrmid"])) {
$users = $wakka->getPersons("id='" . $kstychCall["previewcrmid"] . "' $roclientstr limit 1");
} else {
$users = $this->getCallSequencing(1, $client);
}
$wakka->setPersonKey($users[0]['id'], "status", "Incall");
......@@ -175,22 +177,27 @@ class DialerController extends Controller
$searchresult .= "<div id=internalid_matchlist></div><script>createSearchRecordDiv('internalid_matchlist');</script>";
}
return Response::make($searchresult);
}
if ($action == "newcall") {
$wakka = new KHRMSLib();
$redial = Input::get("redial");
$roclientstr = array();
$enable = "enable";
$oclientlst = $wakka->clientsReadAccess();
foreach ($oclientlst as $tclnt) if ($tclnt != "") {
foreach ($oclientlst as $tclnt) {
if ($tclnt != "") {
$roclientstr[] = "'$tclnt'";
}
}
$roclientstr[] = "'$client'";
if (!empty($roclientstr)) $roclientstr = "and client in (" . implode(",", $roclientstr) . ")";
else $roclientstr = "";
if (!empty($roclientstr)) {
$roclientstr = "and client in (" . implode(",", $roclientstr) . ")";
} else {
$roclientstr = "";
}
$users = array();
$callnumber = $kstychCall['callnumber'];
......@@ -213,7 +220,7 @@ class DialerController extends Controller
'peopledata' => $ppldata,
'mobile' => substr($callnumber, -10),
'client' => $client,
'status' => 'Called'
'status' => 'Called',
);
$idstr = $wakka->Query($Rquery, "", $Rtable, $Rvalues);
......@@ -222,61 +229,88 @@ class DialerController extends Controller
}
if ($kstychDialer['mDialerState'] == "DialNext" || $kstychDialer['mDialerState'] == "Progressive") {
if ($kstychCall['previewcrmid'] != "") $users = $wakka->getPersons("id='" . $kstychCall['previewcrmid'] . "' $roclientstr limit 1");
else if ($kstychCall['callnumber'] != "") $users = $wakka->getPersons("mobile='" . $kstychCall['callnumber'] . "' $roclientstr limit 1");
else $users = $this->getCallSequencing(1, $client);
if ($kstychCall['previewcrmid'] != "") {
$users = $wakka->getPersons("id='" . $kstychCall['previewcrmid'] . "' $roclientstr limit 1");
} else if ($kstychCall['callnumber'] != "") {
$users = $wakka->getPersons("mobile='" . $kstychCall['callnumber'] . "' $roclientstr limit 1");
} else {
$users = $this->getCallSequencing(1, $client);
}
}
$wakka->setPersonKey($users[0]['id'], "status", "Incall");
// $searchresult = '<div style="clear:both"></div><div id=divworking></div><div style="clear:both"></div>';
if (!empty($users)) {
if (sizeof($users) >= 1) {
$searchresult = "<div style='clear:both'></div><div id=divworking></div><div style='clear:both'></div><script>showRecruit(\"" . $users[0]['id'] . "\",\"" . $enable . "\");</script>";
if ($redial!="redial") {
print_r($redial);
$searchresult .= "<script>kSetDData('C','crmid','" . $users[0]['id'] . "');kSetDData('C','callnumber','$callnumber');</script>";
$searchresult = "<div style='clear:both'></div><div id=divworking></div><div style='clear:both'></div><script>showRecruit(\"" . $users[0]['id'] . "\",\"" . $enable . "\");</script>";
$searchresult .= "<script>kSetDData('C','crmid','" . $users[0]['id'] . "');kSetDData('C','callnumber','$callnumber');</script>";
$searchresult .= "<div id=internalid_matchlist></div><script>
doAjax('record?action=quicksearch','maintextsearch_1_txt=" . $users[0]['clientinternalid'] . "&maintextsearch_1_span=InternalID','internalid_matchlist','searchMutex', 'searchxhr','POST',function(retstr){
if(retstr.responseText.indexOf('No Records Found!')>-1)$('#internalid_matchlist').html('');
});
doAjax('dialer?action=agentcall&users=" . urlencode(json_encode($users)) . "&callnumber=" . $callnumber . "&client=" . $client. "&mDialerState=" . $kstychDialer['mDialerState'] . "','','', 'ajax_manualdial','singlefail','POST',function(retstr){
console.log(retstr.responseText);
doAjax('dialer?action=dialcall&sipid="retstr.responseText"','','', 'ajax_manualdial','singlefail','POST');
});</script>";
}
$searchresult .="<script>doAjax('dialer?action=agentcall&users=" . urlencode(json_encode($users)) . "&callnumber=" . $callnumber . "&client=" . $client . "&mDialerState=" . $kstychDialer['mDialerState'] . "','','', 'ajax_manualdial','singlefail','POST',function(retstr){
var string = retstr.responseText.trim();
if(string){
var string1=string.split('&');
var string2=string1[7].split('=');
console.log(string1);
console.log(string2[1]);
kSetDData('C','callid',string2[1]);
doAjax(retstr.responseText,'','', 'ajax_manualdial','singlefail','POST');}
});
</script>";
return Response::make($searchresult);
} else {
return Response::make($searchresult . "<script>kstychCall['crmid']=0;kSetDData('C','previewcrmid','');simpleNotification('error','topRight','Multiple Records Found!');createSearchRecordDiv('dialersearchbox');</script>");
}
} else return Response::make($searchresult .= "<div id=internalid_matchlist></div><script>createSearchRecordDiv('internalid_matchlist');</script>");
} else {
return Response::make($searchresult .= "<div id=internalid_matchlist></div><script>createSearchRecordDiv('internalid_matchlist');</script>");
}
}
if ($action == "agentcall") {
$wakka = new KHRMSLib();
$users=json_decode(html_entity_decode(Input::get("users")));
$callnumber=Input::get("callnumber");
$client=Input::get("client");
$mDialerState=Input::get("mDialerState");
$users = json_decode(html_entity_decode(Input::get("users")));
$callnumber = Input::get("callnumber");
$client = Input::get("client");
$mDialerState = Input::get("mDialerState");
if (!empty($users)) {
if (sizeof($users) >= 1) {
$users[0]->peopledata = preg_replace_callback('!s:(\d+):"(.*?)";!', function ($m) {
return "s:" . strlen($m[2]) . ":\"" . $m[2] . "\";";
}, $users[0]->peopledata);
$ppldata = unserialize($users[0]->peopledata);
if (!isset($ppldata['client'])) $ppldata['client'] = "";
if (!isset($ppldata['department'])) $ppldata['department'] = "";
if (!isset($ppldata['client'])) {
$ppldata['client'] = "";
}
if (!isset($ppldata['department'])) {
$ppldata['department'] = "";
}
if ($callnumber == "" || intval($callnumber) <= 0) {
$callnumber = $ppldata['mobile'];
}
if ($callnumber == "" || intval($callnumber) <= 0) $callnumber = $ppldata['mobile'];
if ($callnumber != "" && intval($callnumber) > 0) {
$mastersdata = $wakka->getCompanyMaster($ppldata['client']);
$callerid = "";
if (!empty($mastersdata["DialerDID"])) $callerid = $mastersdata["DialerDID"];
if ($callerid == "") $callerid = Auth::user()->exten;
if (!empty($mastersdata["DialerDID"])) {
$callerid = $mastersdata["DialerDID"];
}
if ($callerid == "") {
$callerid = Auth::user()->exten;
}
$calleridarr = explode(":", $callerid);
$dspan = "1";
......@@ -286,7 +320,8 @@ class DialerController extends Controller
}
//see if user is online on this sipid
$userstatus = false;
if (Auth::user()->sessiontype == '1') { //Mobile Session
if (Auth::user()->sessiontype == '1') {
//Mobile Session
$sipid = AgentNumber::where('user_id', Auth::user()->id)->first();
if ($sipid && $sipid->status == 2) {
$userstatus = true;
......@@ -310,7 +345,8 @@ class DialerController extends Controller
break;
}
}
} else { //Webrtc session
} else {
//Webrtc session
$sipid = Sipid::find($kstychDialer['phone']);
if ($sipid && $sipid->user == Auth::user()->id && $sipid->status == 1) {
$userstatus = true;
......@@ -321,12 +357,18 @@ class DialerController extends Controller
if ($userstatus) {
if ($dspan == "1") {
$dialline = Dialline::where("status", "=", "Free")->where("enabled", "=", "1");
if ($dspan != "") $dialline = $dialline->where('dspan', '=', '1')->where('id', '<=', '30');
if ($dspan != "") {
$dialline = $dialline->where('dspan', '=', '1')->where('id', '<=', '30');
}
$dialline = $dialline->orderBy('updated_at', 'ASC')->first();
}
if (empty($dialline)) {
$dialline = Dialline::where("status", "=", "Free")->where("enabled", "=", "1");
if ($dspan != "") $dialline = $dialline->where('dspan', '=', '2')->where('id', '>', '30');
if ($dspan != "") {
$dialline = $dialline->where('dspan', '=', '2')->where('id', '>', '30');
}
$dialline = $dialline->orderBy('updated_at', 'ASC')->first();
}
......@@ -381,14 +423,12 @@ class DialerController extends Controller
// $newqueue = new Kqueue();
// $newqueue->custToMagentConf($sipid, $crmcall, $callerid, $dialline);
// }
$sipid=$sipid->toArray();
$sipid = $sipid->toArray();
$searchresult .= "
" . urlencode(json_encode($sipid)) . "&callnumber=" . $callnumber . "&callerid=" . urlencode(json_encode($callerid)) . "&crmcall=" . urlencode(json_encode($crmcall)) ."&sipid1=".urlencode(json_encode($sipid))."&dialline=" . urlencode(json_encode($dialline)) . ";
dialer?action=dialcall&sipid=" . urlencode(json_encode($sipid)) . "&callnumber=" . $callnumber . "&callerid=" . urlencode(json_encode($callerid)) . "&crmcall=" . urlencode(json_encode($crmcall)) . "&sipid1=" . urlencode(json_encode($sipid)) . "&dialline=" . urlencode(json_encode($dialline)) . "&sipid1=" . urlencode(json_encode($crmcall->id)) . "
";
return Response::make($searchresult);
} else {
return Response::make("<script>kstychCall['crmid']=0;kSetDData('C','previewcrmid','');simpleNotification('error','topRight','No Lines Free to Dial!');</script>");
......@@ -404,7 +444,10 @@ class DialerController extends Controller
} else {
return Response::make($searchresult . "<script>kstychCall['crmid']=0;kSetDData('C','previewcrmid','');simpleNotification('error','topRight','Multiple Records Found!');createSearchRecordDiv('dialersearchbox');</script>");
}
} else return Response::make($searchresult .= "<div id=internalid_matchlist></div><script>createSearchRecordDiv('internalid_matchlist');</script>");
} else {
return Response::make($searchresult .= "<div id=internalid_matchlist></div><script>createSearchRecordDiv('internalid_matchlist');</script>");
}
}
if ($action == "dialcall") {
//echo(urldecode(Input::get("sipid1")));
......@@ -414,11 +457,12 @@ class DialerController extends Controller
// substr($string, 0, -1);
//echo (trim(html_entity_decode($t0),'"'));
//dd(html_entity_decode(Input::get("sipid1")));
$sipid=json_decode(html_entity_decode(Input::get("sipid")));
$callnumber=json_decode(html_entity_decode(Input::get("callnumber")));
$callerid=json_decode(html_entity_decode(Input::get("callerid")));
$crmcall=json_decode(html_entity_decode(Input::get("crmcall")));
$dialline=json_decode(html_entity_decode(Input::get("dialline")));
$sipid = json_decode(html_entity_decode(Input::get("sipid")));
$callnumber = json_decode(html_entity_decode(Input::get("callnumber")));
$callerid = json_decode(html_entity_decode(Input::get("callerid")));
$crmcall = json_decode(html_entity_decode(Input::get("crmcall")));
$dialline = json_decode(html_entity_decode(Input::get("dialline")));
//dd($sipid, $callnumber, $callerid, $crmcall,$dialline, html_entity_decode(Input::get("dialline")));
//dd($sipid,$callnumber,$callerid,$crmcall,$dialline);
//dd(Input::get("sipid1"));
// $sipid = Input::get("sipid");
......@@ -455,10 +499,15 @@ class DialerController extends Controller
if ($oldcrmcall) {
$olddialline = Dialline::find($oldcrmcall->dialline_id);
$dspan = "1";
if ($olddialline) $dspan = $olddialline->dspan;
if ($olddialline) {
$dspan = $olddialline->dspan;
}
$dialline = Dialline::where("status", "=", "Free")->where("enabled", "=", "1");
if ($dspan != "") $dialline = $dialline->where('dspan', '=', $dspan);
if ($dspan != "") {
$dialline = $dialline->where('dspan', '=', $dspan);
}
$dialline = $dialline->orderBy('updated_at', 'ASC')->first();
if ($dialline) {
......@@ -494,8 +543,6 @@ class DialerController extends Controller
$crmcall->data = json_encode($tdata);
$crmcall->save();
//start actual calls
$newqueue = new Kqueue();
$newqueue->userToConf($sipid);
......@@ -533,7 +580,7 @@ class DialerController extends Controller
Cutoff::where('user_id', '=', $user_id)->where('c_name', '=', $campaign)->update(
[
'hangup_time' => date('Y-m-d H:i:s'),
'avg_dispo' => $avgTimeArr['avgdisposec']
'avg_dispo' => $avgTimeArr['avgdisposec'],
]
);
} else {
......@@ -546,7 +593,6 @@ class DialerController extends Controller
$cutoff->save();
}
}
$callid = intval($kstychCall['callid']) + 0;
$crmcall = CRMCall::find($callid);
......@@ -586,7 +632,8 @@ class DialerController extends Controller
}
//hangup any conf calls
if (is_array($kstychCall['connections'])) foreach ($kstychCall['connections'] as $num => $conn) {
if (is_array($kstychCall['connections'])) {
foreach ($kstychCall['connections'] as $num => $conn) {
if (!empty($conn['callid'])) {
$tcrmcall = CRMCall::find($conn['callid']);
if ($tcrmcall) {
......@@ -600,11 +647,18 @@ class DialerController extends Controller
}
}
}
}
return Response::make("//SENT $res");
} else return Response::make("//Error : Dialline Not found ($callid)");
} else {
return Response::make("//Error : Dialline Not found ($callid)");
}
} else return Response::make("//Error : Call Not Found ($callid)");
}
} else {
return Response::make("//Error : Call Not Found ($callid)");
}
}
if ($action == "closecall") {
......@@ -663,7 +717,10 @@ class DialerController extends Controller
$crmcall->crm_id = $kstychCall["crmid"];
$temparr = $wakka->getPerson($crmcall->crm_id);
if (isset($temparr) && isset($temparr['peopledata']) && isset($temparr['peopledata']['client'])) $crmcall->client = $temparr['peopledata']['client'];
if (isset($temparr) && isset($temparr['peopledata']) && isset($temparr['peopledata']['client'])) {
$crmcall->client = $temparr['peopledata']['client'];
}
}
}
......@@ -724,7 +781,10 @@ class DialerController extends Controller
$tuser["final_call_assess"] = $kstychCall["final_call_assess"];
$tuser['peopledata']["dialer_userdata"] = $kstychCall["userdata"][$tcrmid];
if ($tuser['peopledata']["status"] == 'New' || $tuser['peopledata']["status"] == 'Incall' || $tuser['peopledata']["status"] == 'AutoCall') $tuser['peopledata']["status"] = "Called";
if ($tuser['peopledata']["status"] == 'New' || $tuser['peopledata']["status"] == 'Incall' || $tuser['peopledata']["status"] == 'AutoCall') {
$tuser['peopledata']["status"] = "Called";
}
$tuser['peopledata']["dialer_lastcall"] = date("Y-m-d H:i:s");
$tuser['peopledata']["usr_id"] = Auth::user()->id;
$wakka->setPerson($tcrmid, $tuser);
......@@ -733,7 +793,6 @@ class DialerController extends Controller
}
}
$user = $wakka->getPerson($crmcall->crm_id);
if ($user['peopledata']['id'] == $crmcall->crm_id) {
$user['peopledata']["dialer_status"] = $kstychCall["userstatus"];
......@@ -756,7 +815,10 @@ class DialerController extends Controller
$user['peopledata']["dialer_userdata"] = $kstychCall["userdata"][$crmcall->crm_id];
$user['peopledata']["dialer_lastcall"] = date("Y-m-d H:i:s");
$user['peopledata']["usr_id"] = Auth::user()->id;
if ($user['peopledata']["status"] == 'New' || $user['peopledata']["status"] == 'Incall' || $user['peopledata']["status"] == 'AutoCall') $user['peopledata']["status"] = "Called";
if ($user['peopledata']["status"] == 'New' || $user['peopledata']["status"] == 'Incall' || $user['peopledata']["status"] == 'AutoCall') {
$user['peopledata']["status"] = "Called";
}
$wakka->setPerson($crmcall->crm_id, $user);
//update groupid if this is not groupid TODO move to config
......@@ -768,7 +830,10 @@ class DialerController extends Controller
return "s:" . strlen($m[2]) . ":\"" . $m[2] . "\";";
}, $tusers[0]['peopledata']);
$tppldata = unserialize($tusers[0]['peopledata']);
if ($tppldata['status'] == 'New') $wakka->setPersonKey($tusers[0]['id'], 'status', 'Called');
if ($tppldata['status'] == 'New') {
$wakka->setPersonKey($tusers[0]['id'], 'status', 'Called');
}
//if($tppldata['dialer_status']=='') //TODO Config
{
$wakka->setPersonKey($tusers[0]['id'], 'dialer_status', $user['peopledata']["dialer_status"]);
......@@ -873,7 +938,10 @@ class DialerController extends Controller
}
} else {
$sipid = AgentNumber::where('user_id', \Auth::user()->id)->where('status', '2')->first();
if ($sipid) $sipstatus = true;
if ($sipid) {
$sipstatus = true;
}
}
if ($sipstatus) {
$sipid->ready = $ready;
......@@ -890,12 +958,13 @@ class DialerController extends Controller
if ($action == "usersel") {
$currDialerState = $kstychDialer['mDialerState'];
if ($kstychDialer['mDialerSubState'] != "")
if ($kstychDialer['mDialerSubState'] != "") {
$currDialerState = $kstychDialer['mDialerSubState'];
}
DB::table('users')->where('id', Auth::user()->id)->update([
'sel_campaign' => $client,
'current_dialmode' => $currDialerState
'current_dialmode' => $currDialerState,
]);
return Response::make("");
......@@ -956,65 +1025,111 @@ class DialerController extends Controller
$currentstatus = Input::get("currentstatus");
$legalstatus = Input::get("legalstatus");
$page = intval(Input::get('page'));
if ($page < 1) $page = 1;
if ($page < 1) {
$page = 1;
}
$skey = Input::get('skey');
$stxt = Input::get('stxt');
$skey = '';
if ($stxt != '') $skey = " and (id like '$stxt%' or lan like '$stxt%' or firstname like '$stxt%' or lastname like '$stxt%' or client like '$stxt%' or mobile like '$stxt%' or alternateMobile like '$stxt%' or officeNumber like '$stxt%' or referenceName like '$stxt%' or referenceMobile like '$stxt%' or referenceName2 like '$stxt%' or referenceMobile2 like '$stxt%' or altphone1 like '$stxt%' or altphone2 like '$stxt%' or altphone3 like '$stxt%' or altphone4 like '$stxt%' or altphone5 like '$stxt%' or altphone6 like '$stxt%' or altphone7 like '$stxt%' or altphone8 like '$stxt%' or altphone9 like '$stxt%' or altphone10 like '$stxt%' or emailid like '$stxt%' or passportno like '$stxt%' or ibannumber like '$stxt%' or currentstatus like '$stxt%' or laborcardpersonalid like '$stxt%' or clientinternalid like '$stxt%' or clientcode like '$stxt%')";
else $skey = "";
if ($stxt != '') {
$skey = " and (id like '$stxt%' or lan like '$stxt%' or firstname like '$stxt%' or lastname like '$stxt%' or client like '$stxt%' or mobile like '$stxt%' or alternateMobile like '$stxt%' or officeNumber like '$stxt%' or referenceName like '$stxt%' or referenceMobile like '$stxt%' or referenceName2 like '$stxt%' or referenceMobile2 like '$stxt%' or altphone1 like '$stxt%' or altphone2 like '$stxt%' or altphone3 like '$stxt%' or altphone4 like '$stxt%' or altphone5 like '$stxt%' or altphone6 like '$stxt%' or altphone7 like '$stxt%' or altphone8 like '$stxt%' or altphone9 like '$stxt%' or altphone10 like '$stxt%' or emailid like '$stxt%' or passportno like '$stxt%' or ibannumber like '$stxt%' or currentstatus like '$stxt%' or laborcardpersonalid like '$stxt%' or clientinternalid like '$stxt%' or clientcode like '$stxt%')";
} else {
$skey = "";
}
$wakka = new KHRMSLib();
$rows = "";
$owclientstr = array();
$oclientlst = $wakka->clientsOwnerRWAccess();
if (!empty($oclientlst)) foreach ($oclientlst as $tclnt) if ($tclnt != "") {
if (!empty($oclientlst)) {
foreach ($oclientlst as $tclnt) {
if ($tclnt != "") {
$owclientstr[] = "'$tclnt'";
if ($client == "") $client = $tclnt;
if ($client == "") {
$client = $tclnt;
}
}
}
}
if (!empty($owclientstr)) {
$owclientstr = "and client in (" . implode(",", $owclientstr) . ")";
} else {
$owclientstr = "";
}
if ($client != "") {
$owclientstr = "client='$client' and";
}
if (!empty($owclientstr)) $owclientstr = "and client in (" . implode(",", $owclientstr) . ")";
else $owclientstr = "";
if ($client != "") $owclientstr = "client='$client' and";
$roclientstr = array();
$didlinesstr = array();
if (Auth::user()->exten != "") $didlinesstr[] = Auth::user()->exten;
if (Auth::user()->exten != "") {
$didlinesstr[] = Auth::user()->exten;
}
$roclientlst = $wakka->clientsReadAccess();
if (!empty($roclientlst)) foreach ($roclientlst as $tclnt) if ($tclnt != "") {
if (!empty($roclientlst)) {
foreach ($roclientlst as $tclnt) {
if ($tclnt != "") {
$roclientstr[] = "'$tclnt'";
if ($client == "") $client = $tclnt;
if ($client == "") {
$client = $tclnt;
}
$mastersdata = $wakka->getCompanyMaster($tclnt);
if (!empty($mastersdata["DialerDID"])) $didlinesstr[] = $mastersdata["DialerDID"];
if (!empty($mastersdata["DialerDID"])) {
$didlinesstr[] = $mastersdata["DialerDID"];
}
}
}
}
foreach ($didlinesstr as $k => $dids) {
$didarr = explode(":", $dids);
$didlinesstr[$k] = $didarr[0];
}
if (!empty($roclientstr)) $roclientstr = "and client in (" . implode(",", $roclientstr) . ")";
else $roclientstr = "";
if (!empty($roclientstr)) {
$roclientstr = "and client in (" . implode(",", $roclientstr) . ")";
} else {
$roclientstr = "";
}
$roclientstrAll = $roclientstr;
if ($client != "") $roclientstr = "and client='$client'";
if ($client != "") {
$roclientstr = "and client='$client'";
}
$bl = 20;
$bs = ($page - 1) * $bl;
$dbres = array();
if ($bucket == "CurrentQueue") $dbres = $this->getCallSequencing($bl);
else if ($bucket == "TotalData") $dbres = $wakka->getPersons("$owclientstr 1=1");
else if ($bucket == "SearchData") $dbres = $wakka->getPersons("1=1 $roclientstr $skey limit $bs,$bl");
else if ($bucket == "NotCalled") $dbres = $wakka->getPersons("$owclientstr status in ('New') limit $bs,$bl");
else if ($bucket == "Called") $dbres = $wakka->getPersons("$owclientstr status='Called' limit $bs,$bl");
else if ($bucket == "MissedCalls") {
if ($bucket == "CurrentQueue") {
$dbres = $this->getCallSequencing($bl);
} else if ($bucket == "TotalData") {
$dbres = $wakka->getPersons("$owclientstr 1=1");
} else if ($bucket == "SearchData") {
$dbres = $wakka->getPersons("1=1 $roclientstr $skey limit $bs,$bl");
} else if ($bucket == "NotCalled") {
$dbres = $wakka->getPersons("$owclientstr status in ('New') limit $bs,$bl");
} else if ($bucket == "Called") {
$dbres = $wakka->getPersons("$owclientstr status='Called' limit $bs,$bl");
} else if ($bucket == "MissedCalls") {
function searchFor($number, $array)
{
foreach ($array as $key => $value) {
if ($value->number == $number)
if ($value->number == $number) {
$numArr[] = $value;
}
}
return $numArr;
}
......@@ -1033,7 +1148,10 @@ class DialerController extends Controller
if ($lcall->userstatus == "InboundDROP") {
if ($tcall->crm_id > 0) {
$rec = $wakka->getPersons("id=$tcall->crm_id")[0];
if ($rec['dialer_status'] == "InboundDROP") $dbres[] = $rec;
if ($rec['dialer_status'] == "InboundDROP") {
$dbres[] = $rec;
}
} else {
if ($tcall->client == ".") {
$recordValue = DB::table('records')->where('mobile', '=', $tcall->number)->get();
......@@ -1045,14 +1163,21 @@ class DialerController extends Controller
}
}
}
} else if ($bucket == "CallsToday") $dbres = $wakka->getPersons("$owclientstr dialer_lastcall>='" . date("Y-m-d 00:00:00", time() + ((Auth::user()->timezone) * 60)) . "' limit $bs,$bl");
else if ($bucket == "CallsMonth") $dbres = $wakka->getPersons("$owclientstr dialer_lastcall>='" . date("Y-m-01 00:00:00", time() + ((Auth::user()->timezone) * 60)) . "' limit $bs,$bl");
else {
} else if ($bucket == "CallsToday") {
$dbres = $wakka->getPersons("$owclientstr dialer_lastcall>='" . date("Y-m-d 00:00:00", time() + ((Auth::user()->timezone) * 60)) . "' limit $bs,$bl");
} else if ($bucket == "CallsMonth") {
$dbres = $wakka->getPersons("$owclientstr dialer_lastcall>='" . date("Y-m-01 00:00:00", time() + ((Auth::user()->timezone) * 60)) . "' limit $bs,$bl");
} else {
$currentstatus2 = '';
$legalstatus2 = '';
if ($currentstatus != "") $currentstatus2 = " and currentstatus='$currentstatus' ";
if ($legalstatus != "") $legalstatus2 = " and legalstatus='$legalstatus' ";
if ($currentstatus != "") {
$currentstatus2 = " and currentstatus='$currentstatus' ";
}
if ($legalstatus != "") {
$legalstatus2 = " and legalstatus='$legalstatus' ";
}
$dbres = $wakka->getPersons("dialer_status='$bucket' $currentstatus2 $legalstatus2 $owclientstr limit $bs,$bl");
}
......@@ -1071,7 +1196,10 @@ class DialerController extends Controller
$callcntmonth = CRMCall::where("crm_id", "=", $dbrow['id'])->where("created_at", ">=", date("Y-m-01 H:i:s", time() + ((Auth::user()->timezone) * 60)))->count();
}
if (!isset($ccountsummary[$callcntmonth])) $ccountsummary[$callcntmonth] = 0;
if (!isset($ccountsummary[$callcntmonth])) {
$ccountsummary[$callcntmonth] = 0;
}
$ccountsummary[$callcntmonth]++;
$type = "";
......@@ -1084,13 +1212,21 @@ class DialerController extends Controller
if ($lastcall) {
$type = $lastcall->type;
$lasttime = $lastcall->created_at;
if ($lasttime == "0000-00-00 00:00:00") $lasttime = "";
else $lasttime = date("d-M-y H:i:s", strtotime($lasttime) - ((Auth::user()->timezone) * 60));
if ($lasttime == "0000-00-00 00:00:00") {
$lasttime = "";
} else {
$lasttime = date("d-M-y H:i:s", strtotime($lasttime) - ((Auth::user()->timezone) * 60));
}
$dispo = $lastcall->userstatus;
$subdispo = $lastcall->usersubstatus;
$followup = $dbrow[dialer_callback];
if ($followup == "0000-00-00 00:00:00") $followup = "";
else $followup = date("d-M-y H:i:s", strtotime($followup) - (Auth::user()->timezone * 60));
if ($followup == "0000-00-00 00:00:00") {
$followup = "";
} else {
$followup = date("d-M-y H:i:s", strtotime($followup) - (Auth::user()->timezone * 60));
}
$remarks = $lastcall->userremarks;
$did = $lastcall->did;
}
......@@ -1237,7 +1373,6 @@ class DialerController extends Controller
$userlog = new UserLog();
$reportDataArray = $userlog->getAgentPerformanceReportUserLogData($start_date, $end_date, $start_time, $end_time, $client, $type);
$dateDataArray = $userlog->getDatesForReport($start_date, $end_date, $start_time, $end_time, $type);
$daySTART = $dateDataArray['daySTART'];
$dayEND = $dateDataArray['dayEND'];
......@@ -1268,7 +1403,6 @@ class DialerController extends Controller
$userlog = new UserLog();
$reportDataArray = $userlog->getAgentTimingSummaryReportUserLogData($start_date, $end_date, $start_time, $end_time, $client, $type);
$dateDataArray = $userlog->getDatesForReport($start_date, $end_date, $start_time, $end_time, $type);
$daySTART = $dateDataArray['daySTART'];
......@@ -1365,7 +1499,6 @@ class DialerController extends Controller
//
}
public function dashboard()
{
//echo "OK";
......@@ -1378,13 +1511,23 @@ class DialerController extends Controller
// Log::info("APP_Test:" + env('app_ip'));
$roclientstr = array();
$didlinesstr = array();
if (Auth::user()->exten != "") $didlinesstr[] = Auth::user()->exten;
if (Auth::user()->exten != "") {
$didlinesstr[] = Auth::user()->exten;
}
$oclientlst = $wakka->clientsOwnerRWAccess();
if (!empty($oclientlst)) foreach ($oclientlst as $tclnt) if ($tclnt != "") {
if (!empty($oclientlst)) {
foreach ($oclientlst as $tclnt) {
if ($tclnt != "") {
$roclientstr[] = (is_null($client)) ? "'$tclnt'" : "'$client'";
$mastersdata = $wakka->getCompanyMaster($tclnt);
if (!empty($mastersdata["DialerDID"])) $didlinesstr[] = $mastersdata["DialerDID"];
if (!empty($mastersdata["DialerDID"])) {
$didlinesstr[] = $mastersdata["DialerDID"];
}
}
}
}
$roclientstr = "client = '$client'";
......@@ -1396,19 +1539,32 @@ class DialerController extends Controller
if ($limit > 0) {
$callbackDate = date("Y-m-d H:i:s", strtotime(date("Y-m-d H:i:s")) - (330 * 60));
$tusers = $wakka->getPersons("dialer_callback<'" . $callbackDate . "' and usr_id='" . Auth::user()->id . "' and dialer_callback!='0000-00-00 00:00:00' and dialer_substatus='CB' and dialer_substatus='PTP' and $roclientstr limit $limit");
foreach ($tusers as $tuser) if (!isset($users[$tuser['id']])) $users[$tuser['id']] = $tuser;
foreach ($tusers as $tuser) {
if (!isset($users[$tuser['id']])) {
$users[$tuser['id']] = $tuser;
}
}
$limit = $limit - sizeof($tusers);
}
if ($limit > 0) {
$tusers = $wakka->getPersons("status In ('called','Incall') and mobile!='' and $roclientstr order by dialer_lastcall asc limit $limit");
foreach ($tusers as $tuser) if (!isset($users[$tuser['id']])) $users[$tuser['id']] = $tuser;
foreach ($tusers as $tuser) {
if (!isset($users[$tuser['id']])) {
$users[$tuser['id']] = $tuser;
}
}
$limit = $limit - sizeof($tusers);
}
$tusers = array();
foreach ($users as $tuser) $tusers[] = $tuser;
foreach ($users as $tuser) {
$tusers[] = $tuser;
}
return $tusers;
}
......
......@@ -634,9 +634,17 @@ function incomingPopupAlert(var1,var2,var3)
kDesktopNotification("",var1,var2,1500);
}
function outgoingCall()
function outgoingCall(redial='')
{
var dialersearchresults='';
if (redial!="redial") {
var dialersearchresults='dialersearchresults';
$("#dialersearchresults").html("");
}else{
var displaydata=$("#dialersearchresults").html();
}
kSetDData('C','callnumber',$("#manualdialnumber_txt").val());
var datastr="kstychCall="+JSON.stringify(kstychCall);
......@@ -648,7 +656,10 @@ function outgoingCall()
{
if(kstychCall['callnumber']!="")
{
doAjax('dialer?action=newcall&client='+client,datastr,'dialersearchresults', 'ajax_manualdial','singlefail','POST', function(retstr){
doAjax('dialer?action=newcall&client='+client+'&redial='+redial,datastr,dialersearchresults, 'ajax_manualdial','singlefail','POST', function(retstr){
if (redial=="redial"){
$("#dialersearchresults").html(displaydata);
}
if(kstychCall['crmid']!="")
{
kSetDData('C','mCallState','Call');
......@@ -675,7 +686,10 @@ function outgoingCall()
if(kstychDialer['mDialerState']=="DialNext")
{
doAjax('dialer?action=newcall&client='+client,datastr,'dialersearchresults', 'ajax_manualdial','singlefail','POST', function(retstr){
doAjax('dialer?action=newcall&client='+client,datastr,dialersearchresults, 'ajax_manualdial','singlefail','POST', function(retstr){
if (redial=="redial"){
$("#dialersearchresults").html(displaydata);
}
if(kstychCall['crmid']!="")
{
kSetDData('C','mCallState','Call');
......@@ -695,7 +709,10 @@ function outgoingCall()
if(kstychDialer['mDialerState']=="Progressive")
{
doAjax('dialer?action=newcall&client='+client,datastr,'dialersearchresults', 'ajax_manualdial','singlefail','POST', function(retstr){
doAjax('dialer?action=newcall&client='+client+'&redial='+redial,datastr,dialersearchresults, 'ajax_manualdial','singlefail','POST', function(retstr){
if (redial=="redial"){
$("#dialersearchresults").html(displaydata);
}
if(kstychCall['crmid']!="")
{
kSetDData('C','mCallState','Call');
......@@ -965,7 +982,7 @@ function resetDialer()
kSetDData('C','ts_Dispo',0);
kSetDData('C','ts_Close',0);
updateDialerState("action","dialnext");
updateDialerState("action","dialnext","redial");
return;
}
......@@ -1124,9 +1141,17 @@ function updateDialerState(objstr,key,val,key2,val2)
if(objstr=="action")
{
if(key=="dialnext")
if(key=="dialnext" && val== "redial")
{
alert(val+"1");
outgoingCall(val);
}
if(key=="dialnext" && val== ""){
alert(val+"2");
outgoingCall();
}
if(key=="hangupall")
{
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!