stop dual load on calling
Showing
2 changed files
with
312 additions
and
131 deletions
| ... | @@ -2,31 +2,23 @@ | ... | @@ -2,31 +2,23 @@ |
| 2 | 2 | ||
| 3 | namespace App\Http\Controllers; | 3 | namespace App\Http\Controllers; |
| 4 | 4 | ||
| 5 | use Auth; | ||
| 6 | use Input; | ||
| 7 | use Response; | ||
| 8 | use App\Http\Controllers\HomeController; | 5 | use App\Http\Controllers\HomeController; |
| 9 | use App\Models\Group; | 6 | use App\Jobs\DialerLib; |
| 10 | use App\Models\Master; | 7 | use App\Jobs\KHRMSLib; |
| 11 | use App\Models\Record; | 8 | use App\Models\AgentNumber; |
| 12 | use App\Models\CRMCall; | 9 | use App\Models\CRMCall; |
| 13 | use App\Models\CRMCallArchive; | 10 | use App\Models\CRMCallArchive; |
| 14 | use App\Models\CRM; | ||
| 15 | use App\Models\CRMCampaign; | ||
| 16 | use App\Models\CRMList; | ||
| 17 | use App\Models\Cutoff; | 11 | use App\Models\Cutoff; |
| 18 | use App\Jobs\KHRMSLib; | ||
| 19 | use App\Jobs\DialerLib; | ||
| 20 | use App\Models\Sipid; | ||
| 21 | use App\Models\Dialline; | 12 | use App\Models\Dialline; |
| 22 | use App\Models\AgentNumber; | ||
| 23 | use App\Models\UserLog; | ||
| 24 | use App\Models\User; | ||
| 25 | use App\Models\Kqueue; | 13 | use App\Models\Kqueue; |
| 26 | use App\Models\QCFeedback; | 14 | use App\Models\QCFeedback; |
| 15 | use App\Models\Sipid; | ||
| 16 | use App\Models\User; | ||
| 17 | use App\Models\UserLog; | ||
| 18 | use Auth; | ||
| 27 | use DB; | 19 | use DB; |
| 28 | use Log; | 20 | use Input; |
| 29 | use Session; | 21 | use Response; |
| 30 | 22 | ||
| 31 | $client = ''; | 23 | $client = ''; |
| 32 | 24 | ||
| ... | @@ -109,7 +101,6 @@ class DialerController extends Controller | ... | @@ -109,7 +101,6 @@ class DialerController extends Controller |
| 109 | 101 | ||
| 110 | $userlogData = UserLog::where('user_id', '=', $user)->orderBy("id", "DESC")->first(); | 102 | $userlogData = UserLog::where('user_id', '=', $user)->orderBy("id", "DESC")->first(); |
| 111 | 103 | ||
| 112 | |||
| 113 | $content = ''; | 104 | $content = ''; |
| 114 | $content .= "freeDialline::" . $freeDialline . PHP_EOL . PHP_EOL; | 105 | $content .= "freeDialline::" . $freeDialline . PHP_EOL . PHP_EOL; |
| 115 | $content .= "waitingDiallineToPatch::" . $waitingToPatch . PHP_EOL . PHP_EOL; | 106 | $content .= "waitingDiallineToPatch::" . $waitingToPatch . PHP_EOL . PHP_EOL; |
| ... | @@ -148,18 +139,29 @@ class DialerController extends Controller | ... | @@ -148,18 +139,29 @@ class DialerController extends Controller |
| 148 | 139 | ||
| 149 | $roclientstr = array(); | 140 | $roclientstr = array(); |
| 150 | $oclientlst = $wakka->clientsReadAccess(); | 141 | $oclientlst = $wakka->clientsReadAccess(); |
| 151 | if (!empty($oclientlst)) foreach ($oclientlst as $tclnt) if ($tclnt != "") { | 142 | if (!empty($oclientlst)) { |
| 143 | foreach ($oclientlst as $tclnt) { | ||
| 144 | if ($tclnt != "") { | ||
| 152 | $roclientstr[] = "'$tclnt'"; | 145 | $roclientstr[] = "'$tclnt'"; |
| 153 | } | 146 | } |
| 147 | } | ||
| 148 | } | ||
| 149 | |||
| 154 | $roclientstr = ""; | 150 | $roclientstr = ""; |
| 155 | $roclientstr[] = "'$client'"; | 151 | $roclientstr[] = "'$client'"; |
| 156 | if (!empty($roclientstr)) $roclientstr = "and client in (" . implode(",", $roclientstr) . ")"; | 152 | if (!empty($roclientstr)) { |
| 157 | else $roclientstr = ""; | 153 | $roclientstr = "and client in (" . implode(",", $roclientstr) . ")"; |
| 154 | } else { | ||
| 155 | $roclientstr = ""; | ||
| 156 | } | ||
| 158 | 157 | ||
| 159 | $users = array(); | 158 | $users = array(); |
| 160 | $searchresult = ""; | 159 | $searchresult = ""; |
| 161 | if (!empty($kstychCall["previewcrmid"])) $users = $wakka->getPersons("id='" . $kstychCall["previewcrmid"] . "' $roclientstr limit 1"); | 160 | if (!empty($kstychCall["previewcrmid"])) { |
| 162 | else $users = $this->getCallSequencing(1, $client); | 161 | $users = $wakka->getPersons("id='" . $kstychCall["previewcrmid"] . "' $roclientstr limit 1"); |
| 162 | } else { | ||
| 163 | $users = $this->getCallSequencing(1, $client); | ||
| 164 | } | ||
| 163 | 165 | ||
| 164 | $wakka->setPersonKey($users[0]['id'], "status", "Incall"); | 166 | $wakka->setPersonKey($users[0]['id'], "status", "Incall"); |
| 165 | 167 | ||
| ... | @@ -175,22 +177,27 @@ class DialerController extends Controller | ... | @@ -175,22 +177,27 @@ class DialerController extends Controller |
| 175 | $searchresult .= "<div id=internalid_matchlist></div><script>createSearchRecordDiv('internalid_matchlist');</script>"; | 177 | $searchresult .= "<div id=internalid_matchlist></div><script>createSearchRecordDiv('internalid_matchlist');</script>"; |
| 176 | } | 178 | } |
| 177 | 179 | ||
| 178 | |||
| 179 | return Response::make($searchresult); | 180 | return Response::make($searchresult); |
| 180 | } | 181 | } |
| 181 | 182 | ||
| 182 | if ($action == "newcall") { | 183 | if ($action == "newcall") { |
| 183 | $wakka = new KHRMSLib(); | 184 | $wakka = new KHRMSLib(); |
| 184 | 185 | $redial = Input::get("redial"); | |
| 185 | $roclientstr = array(); | 186 | $roclientstr = array(); |
| 186 | $enable = "enable"; | 187 | $enable = "enable"; |
| 187 | $oclientlst = $wakka->clientsReadAccess(); | 188 | $oclientlst = $wakka->clientsReadAccess(); |
| 188 | foreach ($oclientlst as $tclnt) if ($tclnt != "") { | 189 | foreach ($oclientlst as $tclnt) { |
| 190 | if ($tclnt != "") { | ||
| 189 | $roclientstr[] = "'$tclnt'"; | 191 | $roclientstr[] = "'$tclnt'"; |
| 190 | } | 192 | } |
| 193 | } | ||
| 194 | |||
| 191 | $roclientstr[] = "'$client'"; | 195 | $roclientstr[] = "'$client'"; |
| 192 | if (!empty($roclientstr)) $roclientstr = "and client in (" . implode(",", $roclientstr) . ")"; | 196 | if (!empty($roclientstr)) { |
| 193 | else $roclientstr = ""; | 197 | $roclientstr = "and client in (" . implode(",", $roclientstr) . ")"; |
| 198 | } else { | ||
| 199 | $roclientstr = ""; | ||
| 200 | } | ||
| 194 | 201 | ||
| 195 | $users = array(); | 202 | $users = array(); |
| 196 | $callnumber = $kstychCall['callnumber']; | 203 | $callnumber = $kstychCall['callnumber']; |
| ... | @@ -213,7 +220,7 @@ class DialerController extends Controller | ... | @@ -213,7 +220,7 @@ class DialerController extends Controller |
| 213 | 'peopledata' => $ppldata, | 220 | 'peopledata' => $ppldata, |
| 214 | 'mobile' => substr($callnumber, -10), | 221 | 'mobile' => substr($callnumber, -10), |
| 215 | 'client' => $client, | 222 | 'client' => $client, |
| 216 | 'status' => 'Called' | 223 | 'status' => 'Called', |
| 217 | ); | 224 | ); |
| 218 | $idstr = $wakka->Query($Rquery, "", $Rtable, $Rvalues); | 225 | $idstr = $wakka->Query($Rquery, "", $Rtable, $Rvalues); |
| 219 | 226 | ||
| ... | @@ -222,61 +229,88 @@ class DialerController extends Controller | ... | @@ -222,61 +229,88 @@ class DialerController extends Controller |
| 222 | } | 229 | } |
| 223 | 230 | ||
| 224 | if ($kstychDialer['mDialerState'] == "DialNext" || $kstychDialer['mDialerState'] == "Progressive") { | 231 | if ($kstychDialer['mDialerState'] == "DialNext" || $kstychDialer['mDialerState'] == "Progressive") { |
| 225 | if ($kstychCall['previewcrmid'] != "") $users = $wakka->getPersons("id='" . $kstychCall['previewcrmid'] . "' $roclientstr limit 1"); | 232 | if ($kstychCall['previewcrmid'] != "") { |
| 226 | else if ($kstychCall['callnumber'] != "") $users = $wakka->getPersons("mobile='" . $kstychCall['callnumber'] . "' $roclientstr limit 1"); | 233 | $users = $wakka->getPersons("id='" . $kstychCall['previewcrmid'] . "' $roclientstr limit 1"); |
| 227 | else $users = $this->getCallSequencing(1, $client); | 234 | } else if ($kstychCall['callnumber'] != "") { |
| 235 | $users = $wakka->getPersons("mobile='" . $kstychCall['callnumber'] . "' $roclientstr limit 1"); | ||
| 236 | } else { | ||
| 237 | $users = $this->getCallSequencing(1, $client); | ||
| 238 | } | ||
| 239 | |||
| 228 | } | 240 | } |
| 229 | $wakka->setPersonKey($users[0]['id'], "status", "Incall"); | 241 | $wakka->setPersonKey($users[0]['id'], "status", "Incall"); |
| 230 | // $searchresult = '<div style="clear:both"></div><div id=divworking></div><div style="clear:both"></div>'; | 242 | // $searchresult = '<div style="clear:both"></div><div id=divworking></div><div style="clear:both"></div>'; |
| 231 | 243 | ||
| 232 | if (!empty($users)) { | 244 | if (!empty($users)) { |
| 233 | if (sizeof($users) >= 1) { | 245 | if (sizeof($users) >= 1) { |
| 234 | $searchresult = "<div style='clear:both'></div><div id=divworking></div><div style='clear:both'></div><script>showRecruit(\"" . $users[0]['id'] . "\",\"" . $enable . "\");</script>"; | 246 | if ($redial!="redial") { |
| 235 | 247 | print_r($redial); | |
| 236 | 248 | ||
| 237 | $searchresult .= "<script>kSetDData('C','crmid','" . $users[0]['id'] . "');kSetDData('C','callnumber','$callnumber');</script>"; | ||
| 238 | 249 | ||
| 250 | $searchresult = "<div style='clear:both'></div><div id=divworking></div><div style='clear:both'></div><script>showRecruit(\"" . $users[0]['id'] . "\",\"" . $enable . "\");</script>"; | ||
| 239 | 251 | ||
| 252 | $searchresult .= "<script>kSetDData('C','crmid','" . $users[0]['id'] . "');kSetDData('C','callnumber','$callnumber');</script>"; | ||
| 240 | 253 | ||
| 241 | $searchresult .= "<div id=internalid_matchlist></div><script> | 254 | $searchresult .= "<div id=internalid_matchlist></div><script> |
| 242 | doAjax('record?action=quicksearch','maintextsearch_1_txt=" . $users[0]['clientinternalid'] . "&maintextsearch_1_span=InternalID','internalid_matchlist','searchMutex', 'searchxhr','POST',function(retstr){ | 255 | doAjax('record?action=quicksearch','maintextsearch_1_txt=" . $users[0]['clientinternalid'] . "&maintextsearch_1_span=InternalID','internalid_matchlist','searchMutex', 'searchxhr','POST',function(retstr){ |
| 243 | if(retstr.responseText.indexOf('No Records Found!')>-1)$('#internalid_matchlist').html(''); | 256 | if(retstr.responseText.indexOf('No Records Found!')>-1)$('#internalid_matchlist').html(''); |
| 244 | }); | 257 | });</script>"; |
| 245 | 258 | } | |
| 246 | doAjax('dialer?action=agentcall&users=" . urlencode(json_encode($users)) . "&callnumber=" . $callnumber . "&client=" . $client. "&mDialerState=" . $kstychDialer['mDialerState'] . "','','', 'ajax_manualdial','singlefail','POST',function(retstr){ | 259 | $searchresult .="<script>doAjax('dialer?action=agentcall&users=" . urlencode(json_encode($users)) . "&callnumber=" . $callnumber . "&client=" . $client . "&mDialerState=" . $kstychDialer['mDialerState'] . "','','', 'ajax_manualdial','singlefail','POST',function(retstr){ |
| 247 | console.log(retstr.responseText); | 260 | var string = retstr.responseText.trim(); |
| 248 | doAjax('dialer?action=dialcall&sipid="retstr.responseText"','','', 'ajax_manualdial','singlefail','POST'); | 261 | if(string){ |
| 262 | var string1=string.split('&'); | ||
| 263 | var string2=string1[7].split('='); | ||
| 264 | console.log(string1); | ||
| 265 | console.log(string2[1]); | ||
| 266 | kSetDData('C','callid',string2[1]); | ||
| 267 | doAjax(retstr.responseText,'','', 'ajax_manualdial','singlefail','POST');} | ||
| 249 | }); | 268 | }); |
| 250 | </script>"; | 269 | </script>"; |
| 251 | 270 | ||
| 252 | |||
| 253 | return Response::make($searchresult); | 271 | return Response::make($searchresult); |
| 254 | } else { | 272 | } else { |
| 255 | return Response::make($searchresult . "<script>kstychCall['crmid']=0;kSetDData('C','previewcrmid','');simpleNotification('error','topRight','Multiple Records Found!');createSearchRecordDiv('dialersearchbox');</script>"); | 273 | return Response::make($searchresult . "<script>kstychCall['crmid']=0;kSetDData('C','previewcrmid','');simpleNotification('error','topRight','Multiple Records Found!');createSearchRecordDiv('dialersearchbox');</script>"); |
| 256 | } | 274 | } |
| 257 | } else return Response::make($searchresult .= "<div id=internalid_matchlist></div><script>createSearchRecordDiv('internalid_matchlist');</script>"); | 275 | } else { |
| 276 | return Response::make($searchresult .= "<div id=internalid_matchlist></div><script>createSearchRecordDiv('internalid_matchlist');</script>"); | ||
| 277 | } | ||
| 278 | |||
| 258 | } | 279 | } |
| 259 | if ($action == "agentcall") { | 280 | if ($action == "agentcall") { |
| 260 | $wakka = new KHRMSLib(); | 281 | $wakka = new KHRMSLib(); |
| 261 | $users=json_decode(html_entity_decode(Input::get("users"))); | 282 | $users = json_decode(html_entity_decode(Input::get("users"))); |
| 262 | $callnumber=Input::get("callnumber"); | 283 | $callnumber = Input::get("callnumber"); |
| 263 | $client=Input::get("client"); | 284 | $client = Input::get("client"); |
| 264 | $mDialerState=Input::get("mDialerState"); | 285 | $mDialerState = Input::get("mDialerState"); |
| 265 | if (!empty($users)) { | 286 | if (!empty($users)) { |
| 266 | if (sizeof($users) >= 1) { | 287 | if (sizeof($users) >= 1) { |
| 267 | $users[0]->peopledata = preg_replace_callback('!s:(\d+):"(.*?)";!', function ($m) { | 288 | $users[0]->peopledata = preg_replace_callback('!s:(\d+):"(.*?)";!', function ($m) { |
| 268 | return "s:" . strlen($m[2]) . ":\"" . $m[2] . "\";"; | 289 | return "s:" . strlen($m[2]) . ":\"" . $m[2] . "\";"; |
| 269 | }, $users[0]->peopledata); | 290 | }, $users[0]->peopledata); |
| 270 | $ppldata = unserialize($users[0]->peopledata); | 291 | $ppldata = unserialize($users[0]->peopledata); |
| 271 | if (!isset($ppldata['client'])) $ppldata['client'] = ""; | 292 | if (!isset($ppldata['client'])) { |
| 272 | if (!isset($ppldata['department'])) $ppldata['department'] = ""; | 293 | $ppldata['client'] = ""; |
| 294 | } | ||
| 295 | |||
| 296 | if (!isset($ppldata['department'])) { | ||
| 297 | $ppldata['department'] = ""; | ||
| 298 | } | ||
| 299 | |||
| 300 | if ($callnumber == "" || intval($callnumber) <= 0) { | ||
| 301 | $callnumber = $ppldata['mobile']; | ||
| 302 | } | ||
| 273 | 303 | ||
| 274 | if ($callnumber == "" || intval($callnumber) <= 0) $callnumber = $ppldata['mobile']; | ||
| 275 | if ($callnumber != "" && intval($callnumber) > 0) { | 304 | if ($callnumber != "" && intval($callnumber) > 0) { |
| 276 | $mastersdata = $wakka->getCompanyMaster($ppldata['client']); | 305 | $mastersdata = $wakka->getCompanyMaster($ppldata['client']); |
| 277 | $callerid = ""; | 306 | $callerid = ""; |
| 278 | if (!empty($mastersdata["DialerDID"])) $callerid = $mastersdata["DialerDID"]; | 307 | if (!empty($mastersdata["DialerDID"])) { |
| 279 | if ($callerid == "") $callerid = Auth::user()->exten; | 308 | $callerid = $mastersdata["DialerDID"]; |
| 309 | } | ||
| 310 | |||
| 311 | if ($callerid == "") { | ||
| 312 | $callerid = Auth::user()->exten; | ||
| 313 | } | ||
| 280 | 314 | ||
| 281 | $calleridarr = explode(":", $callerid); | 315 | $calleridarr = explode(":", $callerid); |
| 282 | $dspan = "1"; | 316 | $dspan = "1"; |
| ... | @@ -286,7 +320,8 @@ class DialerController extends Controller | ... | @@ -286,7 +320,8 @@ class DialerController extends Controller |
| 286 | } | 320 | } |
| 287 | //see if user is online on this sipid | 321 | //see if user is online on this sipid |
| 288 | $userstatus = false; | 322 | $userstatus = false; |
| 289 | if (Auth::user()->sessiontype == '1') { //Mobile Session | 323 | if (Auth::user()->sessiontype == '1') { |
| 324 | //Mobile Session | ||
| 290 | $sipid = AgentNumber::where('user_id', Auth::user()->id)->first(); | 325 | $sipid = AgentNumber::where('user_id', Auth::user()->id)->first(); |
| 291 | if ($sipid && $sipid->status == 2) { | 326 | if ($sipid && $sipid->status == 2) { |
| 292 | $userstatus = true; | 327 | $userstatus = true; |
| ... | @@ -310,7 +345,8 @@ class DialerController extends Controller | ... | @@ -310,7 +345,8 @@ class DialerController extends Controller |
| 310 | break; | 345 | break; |
| 311 | } | 346 | } |
| 312 | } | 347 | } |
| 313 | } else { //Webrtc session | 348 | } else { |
| 349 | //Webrtc session | ||
| 314 | $sipid = Sipid::find($kstychDialer['phone']); | 350 | $sipid = Sipid::find($kstychDialer['phone']); |
| 315 | if ($sipid && $sipid->user == Auth::user()->id && $sipid->status == 1) { | 351 | if ($sipid && $sipid->user == Auth::user()->id && $sipid->status == 1) { |
| 316 | $userstatus = true; | 352 | $userstatus = true; |
| ... | @@ -321,12 +357,18 @@ class DialerController extends Controller | ... | @@ -321,12 +357,18 @@ class DialerController extends Controller |
| 321 | if ($userstatus) { | 357 | if ($userstatus) { |
| 322 | if ($dspan == "1") { | 358 | if ($dspan == "1") { |
| 323 | $dialline = Dialline::where("status", "=", "Free")->where("enabled", "=", "1"); | 359 | $dialline = Dialline::where("status", "=", "Free")->where("enabled", "=", "1"); |
| 324 | if ($dspan != "") $dialline = $dialline->where('dspan', '=', '1')->where('id', '<=', '30'); | 360 | if ($dspan != "") { |
| 361 | $dialline = $dialline->where('dspan', '=', '1')->where('id', '<=', '30'); | ||
| 362 | } | ||
| 363 | |||
| 325 | $dialline = $dialline->orderBy('updated_at', 'ASC')->first(); | 364 | $dialline = $dialline->orderBy('updated_at', 'ASC')->first(); |
| 326 | } | 365 | } |
| 327 | if (empty($dialline)) { | 366 | if (empty($dialline)) { |
| 328 | $dialline = Dialline::where("status", "=", "Free")->where("enabled", "=", "1"); | 367 | $dialline = Dialline::where("status", "=", "Free")->where("enabled", "=", "1"); |
| 329 | if ($dspan != "") $dialline = $dialline->where('dspan', '=', '2')->where('id', '>', '30'); | 368 | if ($dspan != "") { |
| 369 | $dialline = $dialline->where('dspan', '=', '2')->where('id', '>', '30'); | ||
| 370 | } | ||
| 371 | |||
| 330 | $dialline = $dialline->orderBy('updated_at', 'ASC')->first(); | 372 | $dialline = $dialline->orderBy('updated_at', 'ASC')->first(); |
| 331 | } | 373 | } |
| 332 | 374 | ||
| ... | @@ -381,14 +423,12 @@ class DialerController extends Controller | ... | @@ -381,14 +423,12 @@ class DialerController extends Controller |
| 381 | // $newqueue = new Kqueue(); | 423 | // $newqueue = new Kqueue(); |
| 382 | // $newqueue->custToMagentConf($sipid, $crmcall, $callerid, $dialline); | 424 | // $newqueue->custToMagentConf($sipid, $crmcall, $callerid, $dialline); |
| 383 | // } | 425 | // } |
| 384 | $sipid=$sipid->toArray(); | 426 | $sipid = $sipid->toArray(); |
| 385 | 427 | ||
| 386 | $searchresult .= " | 428 | $searchresult .= " |
| 387 | " . 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)) . "; | 429 | 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)) . " |
| 388 | |||
| 389 | "; | 430 | "; |
| 390 | 431 | ||
| 391 | |||
| 392 | return Response::make($searchresult); | 432 | return Response::make($searchresult); |
| 393 | } else { | 433 | } else { |
| 394 | return Response::make("<script>kstychCall['crmid']=0;kSetDData('C','previewcrmid','');simpleNotification('error','topRight','No Lines Free to Dial!');</script>"); | 434 | 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 | ... | @@ -404,7 +444,10 @@ class DialerController extends Controller |
| 404 | } else { | 444 | } else { |
| 405 | return Response::make($searchresult . "<script>kstychCall['crmid']=0;kSetDData('C','previewcrmid','');simpleNotification('error','topRight','Multiple Records Found!');createSearchRecordDiv('dialersearchbox');</script>"); | 445 | return Response::make($searchresult . "<script>kstychCall['crmid']=0;kSetDData('C','previewcrmid','');simpleNotification('error','topRight','Multiple Records Found!');createSearchRecordDiv('dialersearchbox');</script>"); |
| 406 | } | 446 | } |
| 407 | } else return Response::make($searchresult .= "<div id=internalid_matchlist></div><script>createSearchRecordDiv('internalid_matchlist');</script>"); | 447 | } else { |
| 448 | return Response::make($searchresult .= "<div id=internalid_matchlist></div><script>createSearchRecordDiv('internalid_matchlist');</script>"); | ||
| 449 | } | ||
| 450 | |||
| 408 | } | 451 | } |
| 409 | if ($action == "dialcall") { | 452 | if ($action == "dialcall") { |
| 410 | //echo(urldecode(Input::get("sipid1"))); | 453 | //echo(urldecode(Input::get("sipid1"))); |
| ... | @@ -414,11 +457,12 @@ class DialerController extends Controller | ... | @@ -414,11 +457,12 @@ class DialerController extends Controller |
| 414 | // substr($string, 0, -1); | 457 | // substr($string, 0, -1); |
| 415 | //echo (trim(html_entity_decode($t0),'"')); | 458 | //echo (trim(html_entity_decode($t0),'"')); |
| 416 | //dd(html_entity_decode(Input::get("sipid1"))); | 459 | //dd(html_entity_decode(Input::get("sipid1"))); |
| 417 | $sipid=json_decode(html_entity_decode(Input::get("sipid"))); | 460 | $sipid = json_decode(html_entity_decode(Input::get("sipid"))); |
| 418 | $callnumber=json_decode(html_entity_decode(Input::get("callnumber"))); | 461 | $callnumber = json_decode(html_entity_decode(Input::get("callnumber"))); |
| 419 | $callerid=json_decode(html_entity_decode(Input::get("callerid"))); | 462 | $callerid = json_decode(html_entity_decode(Input::get("callerid"))); |
| 420 | $crmcall=json_decode(html_entity_decode(Input::get("crmcall"))); | 463 | $crmcall = json_decode(html_entity_decode(Input::get("crmcall"))); |
| 421 | $dialline=json_decode(html_entity_decode(Input::get("dialline"))); | 464 | $dialline = json_decode(html_entity_decode(Input::get("dialline"))); |
| 465 | //dd($sipid, $callnumber, $callerid, $crmcall,$dialline, html_entity_decode(Input::get("dialline"))); | ||
| 422 | //dd($sipid,$callnumber,$callerid,$crmcall,$dialline); | 466 | //dd($sipid,$callnumber,$callerid,$crmcall,$dialline); |
| 423 | //dd(Input::get("sipid1")); | 467 | //dd(Input::get("sipid1")); |
| 424 | // $sipid = Input::get("sipid"); | 468 | // $sipid = Input::get("sipid"); |
| ... | @@ -455,10 +499,15 @@ class DialerController extends Controller | ... | @@ -455,10 +499,15 @@ class DialerController extends Controller |
| 455 | if ($oldcrmcall) { | 499 | if ($oldcrmcall) { |
| 456 | $olddialline = Dialline::find($oldcrmcall->dialline_id); | 500 | $olddialline = Dialline::find($oldcrmcall->dialline_id); |
| 457 | $dspan = "1"; | 501 | $dspan = "1"; |
| 458 | if ($olddialline) $dspan = $olddialline->dspan; | 502 | if ($olddialline) { |
| 503 | $dspan = $olddialline->dspan; | ||
| 504 | } | ||
| 459 | 505 | ||
| 460 | $dialline = Dialline::where("status", "=", "Free")->where("enabled", "=", "1"); | 506 | $dialline = Dialline::where("status", "=", "Free")->where("enabled", "=", "1"); |
| 461 | if ($dspan != "") $dialline = $dialline->where('dspan', '=', $dspan); | 507 | if ($dspan != "") { |
| 508 | $dialline = $dialline->where('dspan', '=', $dspan); | ||
| 509 | } | ||
| 510 | |||
| 462 | $dialline = $dialline->orderBy('updated_at', 'ASC')->first(); | 511 | $dialline = $dialline->orderBy('updated_at', 'ASC')->first(); |
| 463 | 512 | ||
| 464 | if ($dialline) { | 513 | if ($dialline) { |
| ... | @@ -494,8 +543,6 @@ class DialerController extends Controller | ... | @@ -494,8 +543,6 @@ class DialerController extends Controller |
| 494 | $crmcall->data = json_encode($tdata); | 543 | $crmcall->data = json_encode($tdata); |
| 495 | $crmcall->save(); | 544 | $crmcall->save(); |
| 496 | 545 | ||
| 497 | |||
| 498 | |||
| 499 | //start actual calls | 546 | //start actual calls |
| 500 | $newqueue = new Kqueue(); | 547 | $newqueue = new Kqueue(); |
| 501 | $newqueue->userToConf($sipid); | 548 | $newqueue->userToConf($sipid); |
| ... | @@ -533,7 +580,7 @@ class DialerController extends Controller | ... | @@ -533,7 +580,7 @@ class DialerController extends Controller |
| 533 | Cutoff::where('user_id', '=', $user_id)->where('c_name', '=', $campaign)->update( | 580 | Cutoff::where('user_id', '=', $user_id)->where('c_name', '=', $campaign)->update( |
| 534 | [ | 581 | [ |
| 535 | 'hangup_time' => date('Y-m-d H:i:s'), | 582 | 'hangup_time' => date('Y-m-d H:i:s'), |
| 536 | 'avg_dispo' => $avgTimeArr['avgdisposec'] | 583 | 'avg_dispo' => $avgTimeArr['avgdisposec'], |
| 537 | ] | 584 | ] |
| 538 | ); | 585 | ); |
| 539 | } else { | 586 | } else { |
| ... | @@ -546,7 +593,6 @@ class DialerController extends Controller | ... | @@ -546,7 +593,6 @@ class DialerController extends Controller |
| 546 | $cutoff->save(); | 593 | $cutoff->save(); |
| 547 | } | 594 | } |
| 548 | } | 595 | } |
| 549 | |||
| 550 | $callid = intval($kstychCall['callid']) + 0; | 596 | $callid = intval($kstychCall['callid']) + 0; |
| 551 | $crmcall = CRMCall::find($callid); | 597 | $crmcall = CRMCall::find($callid); |
| 552 | 598 | ||
| ... | @@ -586,7 +632,8 @@ class DialerController extends Controller | ... | @@ -586,7 +632,8 @@ class DialerController extends Controller |
| 586 | } | 632 | } |
| 587 | 633 | ||
| 588 | //hangup any conf calls | 634 | //hangup any conf calls |
| 589 | if (is_array($kstychCall['connections'])) foreach ($kstychCall['connections'] as $num => $conn) { | 635 | if (is_array($kstychCall['connections'])) { |
| 636 | foreach ($kstychCall['connections'] as $num => $conn) { | ||
| 590 | if (!empty($conn['callid'])) { | 637 | if (!empty($conn['callid'])) { |
| 591 | $tcrmcall = CRMCall::find($conn['callid']); | 638 | $tcrmcall = CRMCall::find($conn['callid']); |
| 592 | if ($tcrmcall) { | 639 | if ($tcrmcall) { |
| ... | @@ -600,11 +647,18 @@ class DialerController extends Controller | ... | @@ -600,11 +647,18 @@ class DialerController extends Controller |
| 600 | } | 647 | } |
| 601 | } | 648 | } |
| 602 | } | 649 | } |
| 650 | } | ||
| 603 | 651 | ||
| 604 | return Response::make("//SENT $res"); | 652 | return Response::make("//SENT $res"); |
| 605 | } else return Response::make("//Error : Dialline Not found ($callid)"); | 653 | } else { |
| 654 | return Response::make("//Error : Dialline Not found ($callid)"); | ||
| 606 | } | 655 | } |
| 607 | } else return Response::make("//Error : Call Not Found ($callid)"); | 656 | |
| 657 | } | ||
| 658 | } else { | ||
| 659 | return Response::make("//Error : Call Not Found ($callid)"); | ||
| 660 | } | ||
| 661 | |||
| 608 | } | 662 | } |
| 609 | 663 | ||
| 610 | if ($action == "closecall") { | 664 | if ($action == "closecall") { |
| ... | @@ -663,7 +717,10 @@ class DialerController extends Controller | ... | @@ -663,7 +717,10 @@ class DialerController extends Controller |
| 663 | $crmcall->crm_id = $kstychCall["crmid"]; | 717 | $crmcall->crm_id = $kstychCall["crmid"]; |
| 664 | 718 | ||
| 665 | $temparr = $wakka->getPerson($crmcall->crm_id); | 719 | $temparr = $wakka->getPerson($crmcall->crm_id); |
| 666 | if (isset($temparr) && isset($temparr['peopledata']) && isset($temparr['peopledata']['client'])) $crmcall->client = $temparr['peopledata']['client']; | 720 | if (isset($temparr) && isset($temparr['peopledata']) && isset($temparr['peopledata']['client'])) { |
| 721 | $crmcall->client = $temparr['peopledata']['client']; | ||
| 722 | } | ||
| 723 | |||
| 667 | } | 724 | } |
| 668 | } | 725 | } |
| 669 | 726 | ||
| ... | @@ -724,7 +781,10 @@ class DialerController extends Controller | ... | @@ -724,7 +781,10 @@ class DialerController extends Controller |
| 724 | $tuser["final_call_assess"] = $kstychCall["final_call_assess"]; | 781 | $tuser["final_call_assess"] = $kstychCall["final_call_assess"]; |
| 725 | 782 | ||
| 726 | $tuser['peopledata']["dialer_userdata"] = $kstychCall["userdata"][$tcrmid]; | 783 | $tuser['peopledata']["dialer_userdata"] = $kstychCall["userdata"][$tcrmid]; |
| 727 | if ($tuser['peopledata']["status"] == 'New' || $tuser['peopledata']["status"] == 'Incall' || $tuser['peopledata']["status"] == 'AutoCall') $tuser['peopledata']["status"] = "Called"; | 784 | if ($tuser['peopledata']["status"] == 'New' || $tuser['peopledata']["status"] == 'Incall' || $tuser['peopledata']["status"] == 'AutoCall') { |
| 785 | $tuser['peopledata']["status"] = "Called"; | ||
| 786 | } | ||
| 787 | |||
| 728 | $tuser['peopledata']["dialer_lastcall"] = date("Y-m-d H:i:s"); | 788 | $tuser['peopledata']["dialer_lastcall"] = date("Y-m-d H:i:s"); |
| 729 | $tuser['peopledata']["usr_id"] = Auth::user()->id; | 789 | $tuser['peopledata']["usr_id"] = Auth::user()->id; |
| 730 | $wakka->setPerson($tcrmid, $tuser); | 790 | $wakka->setPerson($tcrmid, $tuser); |
| ... | @@ -733,7 +793,6 @@ class DialerController extends Controller | ... | @@ -733,7 +793,6 @@ class DialerController extends Controller |
| 733 | } | 793 | } |
| 734 | } | 794 | } |
| 735 | 795 | ||
| 736 | |||
| 737 | $user = $wakka->getPerson($crmcall->crm_id); | 796 | $user = $wakka->getPerson($crmcall->crm_id); |
| 738 | if ($user['peopledata']['id'] == $crmcall->crm_id) { | 797 | if ($user['peopledata']['id'] == $crmcall->crm_id) { |
| 739 | $user['peopledata']["dialer_status"] = $kstychCall["userstatus"]; | 798 | $user['peopledata']["dialer_status"] = $kstychCall["userstatus"]; |
| ... | @@ -756,7 +815,10 @@ class DialerController extends Controller | ... | @@ -756,7 +815,10 @@ class DialerController extends Controller |
| 756 | $user['peopledata']["dialer_userdata"] = $kstychCall["userdata"][$crmcall->crm_id]; | 815 | $user['peopledata']["dialer_userdata"] = $kstychCall["userdata"][$crmcall->crm_id]; |
| 757 | $user['peopledata']["dialer_lastcall"] = date("Y-m-d H:i:s"); | 816 | $user['peopledata']["dialer_lastcall"] = date("Y-m-d H:i:s"); |
| 758 | $user['peopledata']["usr_id"] = Auth::user()->id; | 817 | $user['peopledata']["usr_id"] = Auth::user()->id; |
| 759 | if ($user['peopledata']["status"] == 'New' || $user['peopledata']["status"] == 'Incall' || $user['peopledata']["status"] == 'AutoCall') $user['peopledata']["status"] = "Called"; | 818 | if ($user['peopledata']["status"] == 'New' || $user['peopledata']["status"] == 'Incall' || $user['peopledata']["status"] == 'AutoCall') { |
| 819 | $user['peopledata']["status"] = "Called"; | ||
| 820 | } | ||
| 821 | |||
| 760 | $wakka->setPerson($crmcall->crm_id, $user); | 822 | $wakka->setPerson($crmcall->crm_id, $user); |
| 761 | 823 | ||
| 762 | //update groupid if this is not groupid TODO move to config | 824 | //update groupid if this is not groupid TODO move to config |
| ... | @@ -768,7 +830,10 @@ class DialerController extends Controller | ... | @@ -768,7 +830,10 @@ class DialerController extends Controller |
| 768 | return "s:" . strlen($m[2]) . ":\"" . $m[2] . "\";"; | 830 | return "s:" . strlen($m[2]) . ":\"" . $m[2] . "\";"; |
| 769 | }, $tusers[0]['peopledata']); | 831 | }, $tusers[0]['peopledata']); |
| 770 | $tppldata = unserialize($tusers[0]['peopledata']); | 832 | $tppldata = unserialize($tusers[0]['peopledata']); |
| 771 | if ($tppldata['status'] == 'New') $wakka->setPersonKey($tusers[0]['id'], 'status', 'Called'); | 833 | if ($tppldata['status'] == 'New') { |
| 834 | $wakka->setPersonKey($tusers[0]['id'], 'status', 'Called'); | ||
| 835 | } | ||
| 836 | |||
| 772 | //if($tppldata['dialer_status']=='') //TODO Config | 837 | //if($tppldata['dialer_status']=='') //TODO Config |
| 773 | { | 838 | { |
| 774 | $wakka->setPersonKey($tusers[0]['id'], 'dialer_status', $user['peopledata']["dialer_status"]); | 839 | $wakka->setPersonKey($tusers[0]['id'], 'dialer_status', $user['peopledata']["dialer_status"]); |
| ... | @@ -873,7 +938,10 @@ class DialerController extends Controller | ... | @@ -873,7 +938,10 @@ class DialerController extends Controller |
| 873 | } | 938 | } |
| 874 | } else { | 939 | } else { |
| 875 | $sipid = AgentNumber::where('user_id', \Auth::user()->id)->where('status', '2')->first(); | 940 | $sipid = AgentNumber::where('user_id', \Auth::user()->id)->where('status', '2')->first(); |
| 876 | if ($sipid) $sipstatus = true; | 941 | if ($sipid) { |
| 942 | $sipstatus = true; | ||
| 943 | } | ||
| 944 | |||
| 877 | } | 945 | } |
| 878 | if ($sipstatus) { | 946 | if ($sipstatus) { |
| 879 | $sipid->ready = $ready; | 947 | $sipid->ready = $ready; |
| ... | @@ -890,12 +958,13 @@ class DialerController extends Controller | ... | @@ -890,12 +958,13 @@ class DialerController extends Controller |
| 890 | if ($action == "usersel") { | 958 | if ($action == "usersel") { |
| 891 | $currDialerState = $kstychDialer['mDialerState']; | 959 | $currDialerState = $kstychDialer['mDialerState']; |
| 892 | 960 | ||
| 893 | if ($kstychDialer['mDialerSubState'] != "") | 961 | if ($kstychDialer['mDialerSubState'] != "") { |
| 894 | $currDialerState = $kstychDialer['mDialerSubState']; | 962 | $currDialerState = $kstychDialer['mDialerSubState']; |
| 963 | } | ||
| 895 | 964 | ||
| 896 | DB::table('users')->where('id', Auth::user()->id)->update([ | 965 | DB::table('users')->where('id', Auth::user()->id)->update([ |
| 897 | 'sel_campaign' => $client, | 966 | 'sel_campaign' => $client, |
| 898 | 'current_dialmode' => $currDialerState | 967 | 'current_dialmode' => $currDialerState, |
| 899 | ]); | 968 | ]); |
| 900 | 969 | ||
| 901 | return Response::make(""); | 970 | return Response::make(""); |
| ... | @@ -956,65 +1025,111 @@ class DialerController extends Controller | ... | @@ -956,65 +1025,111 @@ class DialerController extends Controller |
| 956 | $currentstatus = Input::get("currentstatus"); | 1025 | $currentstatus = Input::get("currentstatus"); |
| 957 | $legalstatus = Input::get("legalstatus"); | 1026 | $legalstatus = Input::get("legalstatus"); |
| 958 | $page = intval(Input::get('page')); | 1027 | $page = intval(Input::get('page')); |
| 959 | if ($page < 1) $page = 1; | 1028 | if ($page < 1) { |
| 1029 | $page = 1; | ||
| 1030 | } | ||
| 1031 | |||
| 960 | $skey = Input::get('skey'); | 1032 | $skey = Input::get('skey'); |
| 961 | $stxt = Input::get('stxt'); | 1033 | $stxt = Input::get('stxt'); |
| 962 | $skey = ''; | 1034 | $skey = ''; |
| 963 | 1035 | ||
| 964 | 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%')"; | 1036 | if ($stxt != '') { |
| 965 | else $skey = ""; | 1037 | $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%')"; |
| 1038 | } else { | ||
| 1039 | $skey = ""; | ||
| 1040 | } | ||
| 966 | 1041 | ||
| 967 | $wakka = new KHRMSLib(); | 1042 | $wakka = new KHRMSLib(); |
| 968 | $rows = ""; | 1043 | $rows = ""; |
| 969 | 1044 | ||
| 970 | $owclientstr = array(); | 1045 | $owclientstr = array(); |
| 971 | $oclientlst = $wakka->clientsOwnerRWAccess(); | 1046 | $oclientlst = $wakka->clientsOwnerRWAccess(); |
| 972 | if (!empty($oclientlst)) foreach ($oclientlst as $tclnt) if ($tclnt != "") { | 1047 | if (!empty($oclientlst)) { |
| 1048 | foreach ($oclientlst as $tclnt) { | ||
| 1049 | if ($tclnt != "") { | ||
| 973 | $owclientstr[] = "'$tclnt'"; | 1050 | $owclientstr[] = "'$tclnt'"; |
| 974 | if ($client == "") $client = $tclnt; | 1051 | if ($client == "") { |
| 1052 | $client = $tclnt; | ||
| 1053 | } | ||
| 1054 | |||
| 1055 | } | ||
| 1056 | } | ||
| 1057 | } | ||
| 1058 | |||
| 1059 | if (!empty($owclientstr)) { | ||
| 1060 | $owclientstr = "and client in (" . implode(",", $owclientstr) . ")"; | ||
| 1061 | } else { | ||
| 1062 | $owclientstr = ""; | ||
| 1063 | } | ||
| 1064 | |||
| 1065 | if ($client != "") { | ||
| 1066 | $owclientstr = "client='$client' and"; | ||
| 975 | } | 1067 | } |
| 976 | if (!empty($owclientstr)) $owclientstr = "and client in (" . implode(",", $owclientstr) . ")"; | ||
| 977 | else $owclientstr = ""; | ||
| 978 | if ($client != "") $owclientstr = "client='$client' and"; | ||
| 979 | 1068 | ||
| 980 | $roclientstr = array(); | 1069 | $roclientstr = array(); |
| 981 | $didlinesstr = array(); | 1070 | $didlinesstr = array(); |
| 982 | if (Auth::user()->exten != "") $didlinesstr[] = Auth::user()->exten; | 1071 | if (Auth::user()->exten != "") { |
| 1072 | $didlinesstr[] = Auth::user()->exten; | ||
| 1073 | } | ||
| 1074 | |||
| 983 | $roclientlst = $wakka->clientsReadAccess(); | 1075 | $roclientlst = $wakka->clientsReadAccess(); |
| 984 | 1076 | ||
| 985 | if (!empty($roclientlst)) foreach ($roclientlst as $tclnt) if ($tclnt != "") { | 1077 | if (!empty($roclientlst)) { |
| 1078 | foreach ($roclientlst as $tclnt) { | ||
| 1079 | if ($tclnt != "") { | ||
| 986 | $roclientstr[] = "'$tclnt'"; | 1080 | $roclientstr[] = "'$tclnt'"; |
| 987 | if ($client == "") $client = $tclnt; | 1081 | if ($client == "") { |
| 1082 | $client = $tclnt; | ||
| 1083 | } | ||
| 988 | 1084 | ||
| 989 | $mastersdata = $wakka->getCompanyMaster($tclnt); | 1085 | $mastersdata = $wakka->getCompanyMaster($tclnt); |
| 990 | if (!empty($mastersdata["DialerDID"])) $didlinesstr[] = $mastersdata["DialerDID"]; | 1086 | if (!empty($mastersdata["DialerDID"])) { |
| 1087 | $didlinesstr[] = $mastersdata["DialerDID"]; | ||
| 991 | } | 1088 | } |
| 1089 | |||
| 1090 | } | ||
| 1091 | } | ||
| 1092 | } | ||
| 1093 | |||
| 992 | foreach ($didlinesstr as $k => $dids) { | 1094 | foreach ($didlinesstr as $k => $dids) { |
| 993 | $didarr = explode(":", $dids); | 1095 | $didarr = explode(":", $dids); |
| 994 | $didlinesstr[$k] = $didarr[0]; | 1096 | $didlinesstr[$k] = $didarr[0]; |
| 995 | } | 1097 | } |
| 996 | 1098 | ||
| 997 | if (!empty($roclientstr)) $roclientstr = "and client in (" . implode(",", $roclientstr) . ")"; | 1099 | if (!empty($roclientstr)) { |
| 998 | else $roclientstr = ""; | 1100 | $roclientstr = "and client in (" . implode(",", $roclientstr) . ")"; |
| 1101 | } else { | ||
| 1102 | $roclientstr = ""; | ||
| 1103 | } | ||
| 1104 | |||
| 999 | $roclientstrAll = $roclientstr; | 1105 | $roclientstrAll = $roclientstr; |
| 1000 | if ($client != "") $roclientstr = "and client='$client'"; | 1106 | if ($client != "") { |
| 1107 | $roclientstr = "and client='$client'"; | ||
| 1108 | } | ||
| 1001 | 1109 | ||
| 1002 | $bl = 20; | 1110 | $bl = 20; |
| 1003 | $bs = ($page - 1) * $bl; | 1111 | $bs = ($page - 1) * $bl; |
| 1004 | 1112 | ||
| 1005 | $dbres = array(); | 1113 | $dbres = array(); |
| 1006 | if ($bucket == "CurrentQueue") $dbres = $this->getCallSequencing($bl); | 1114 | if ($bucket == "CurrentQueue") { |
| 1007 | else if ($bucket == "TotalData") $dbres = $wakka->getPersons("$owclientstr 1=1"); | 1115 | $dbres = $this->getCallSequencing($bl); |
| 1008 | else if ($bucket == "SearchData") $dbres = $wakka->getPersons("1=1 $roclientstr $skey limit $bs,$bl"); | 1116 | } else if ($bucket == "TotalData") { |
| 1009 | else if ($bucket == "NotCalled") $dbres = $wakka->getPersons("$owclientstr status in ('New') limit $bs,$bl"); | 1117 | $dbres = $wakka->getPersons("$owclientstr 1=1"); |
| 1010 | else if ($bucket == "Called") $dbres = $wakka->getPersons("$owclientstr status='Called' limit $bs,$bl"); | 1118 | } else if ($bucket == "SearchData") { |
| 1011 | else if ($bucket == "MissedCalls") { | 1119 | $dbres = $wakka->getPersons("1=1 $roclientstr $skey limit $bs,$bl"); |
| 1120 | } else if ($bucket == "NotCalled") { | ||
| 1121 | $dbres = $wakka->getPersons("$owclientstr status in ('New') limit $bs,$bl"); | ||
| 1122 | } else if ($bucket == "Called") { | ||
| 1123 | $dbres = $wakka->getPersons("$owclientstr status='Called' limit $bs,$bl"); | ||
| 1124 | } else if ($bucket == "MissedCalls") { | ||
| 1012 | function searchFor($number, $array) | 1125 | function searchFor($number, $array) |
| 1013 | { | 1126 | { |
| 1014 | foreach ($array as $key => $value) { | 1127 | foreach ($array as $key => $value) { |
| 1015 | if ($value->number == $number) | 1128 | if ($value->number == $number) { |
| 1016 | $numArr[] = $value; | 1129 | $numArr[] = $value; |
| 1017 | } | 1130 | } |
| 1131 | |||
| 1132 | } | ||
| 1018 | return $numArr; | 1133 | return $numArr; |
| 1019 | } | 1134 | } |
| 1020 | 1135 | ||
| ... | @@ -1033,7 +1148,10 @@ class DialerController extends Controller | ... | @@ -1033,7 +1148,10 @@ class DialerController extends Controller |
| 1033 | if ($lcall->userstatus == "InboundDROP") { | 1148 | if ($lcall->userstatus == "InboundDROP") { |
| 1034 | if ($tcall->crm_id > 0) { | 1149 | if ($tcall->crm_id > 0) { |
| 1035 | $rec = $wakka->getPersons("id=$tcall->crm_id")[0]; | 1150 | $rec = $wakka->getPersons("id=$tcall->crm_id")[0]; |
| 1036 | if ($rec['dialer_status'] == "InboundDROP") $dbres[] = $rec; | 1151 | if ($rec['dialer_status'] == "InboundDROP") { |
| 1152 | $dbres[] = $rec; | ||
| 1153 | } | ||
| 1154 | |||
| 1037 | } else { | 1155 | } else { |
| 1038 | if ($tcall->client == ".") { | 1156 | if ($tcall->client == ".") { |
| 1039 | $recordValue = DB::table('records')->where('mobile', '=', $tcall->number)->get(); | 1157 | $recordValue = DB::table('records')->where('mobile', '=', $tcall->number)->get(); |
| ... | @@ -1045,14 +1163,21 @@ class DialerController extends Controller | ... | @@ -1045,14 +1163,21 @@ class DialerController extends Controller |
| 1045 | } | 1163 | } |
| 1046 | } | 1164 | } |
| 1047 | } | 1165 | } |
| 1048 | } 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"); | 1166 | } else if ($bucket == "CallsToday") { |
| 1049 | 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"); | 1167 | $dbres = $wakka->getPersons("$owclientstr dialer_lastcall>='" . date("Y-m-d 00:00:00", time() + ((Auth::user()->timezone) * 60)) . "' limit $bs,$bl"); |
| 1050 | 1168 | } else if ($bucket == "CallsMonth") { | |
| 1051 | else { | 1169 | $dbres = $wakka->getPersons("$owclientstr dialer_lastcall>='" . date("Y-m-01 00:00:00", time() + ((Auth::user()->timezone) * 60)) . "' limit $bs,$bl"); |
| 1170 | } else { | ||
| 1052 | $currentstatus2 = ''; | 1171 | $currentstatus2 = ''; |
| 1053 | $legalstatus2 = ''; | 1172 | $legalstatus2 = ''; |
| 1054 | if ($currentstatus != "") $currentstatus2 = " and currentstatus='$currentstatus' "; | 1173 | if ($currentstatus != "") { |
| 1055 | if ($legalstatus != "") $legalstatus2 = " and legalstatus='$legalstatus' "; | 1174 | $currentstatus2 = " and currentstatus='$currentstatus' "; |
| 1175 | } | ||
| 1176 | |||
| 1177 | if ($legalstatus != "") { | ||
| 1178 | $legalstatus2 = " and legalstatus='$legalstatus' "; | ||
| 1179 | } | ||
| 1180 | |||
| 1056 | $dbres = $wakka->getPersons("dialer_status='$bucket' $currentstatus2 $legalstatus2 $owclientstr limit $bs,$bl"); | 1181 | $dbres = $wakka->getPersons("dialer_status='$bucket' $currentstatus2 $legalstatus2 $owclientstr limit $bs,$bl"); |
| 1057 | } | 1182 | } |
| 1058 | 1183 | ||
| ... | @@ -1071,7 +1196,10 @@ class DialerController extends Controller | ... | @@ -1071,7 +1196,10 @@ class DialerController extends Controller |
| 1071 | $callcntmonth = CRMCall::where("crm_id", "=", $dbrow['id'])->where("created_at", ">=", date("Y-m-01 H:i:s", time() + ((Auth::user()->timezone) * 60)))->count(); | 1196 | $callcntmonth = CRMCall::where("crm_id", "=", $dbrow['id'])->where("created_at", ">=", date("Y-m-01 H:i:s", time() + ((Auth::user()->timezone) * 60)))->count(); |
| 1072 | } | 1197 | } |
| 1073 | 1198 | ||
| 1074 | if (!isset($ccountsummary[$callcntmonth])) $ccountsummary[$callcntmonth] = 0; | 1199 | if (!isset($ccountsummary[$callcntmonth])) { |
| 1200 | $ccountsummary[$callcntmonth] = 0; | ||
| 1201 | } | ||
| 1202 | |||
| 1075 | $ccountsummary[$callcntmonth]++; | 1203 | $ccountsummary[$callcntmonth]++; |
| 1076 | 1204 | ||
| 1077 | $type = ""; | 1205 | $type = ""; |
| ... | @@ -1084,13 +1212,21 @@ class DialerController extends Controller | ... | @@ -1084,13 +1212,21 @@ class DialerController extends Controller |
| 1084 | if ($lastcall) { | 1212 | if ($lastcall) { |
| 1085 | $type = $lastcall->type; | 1213 | $type = $lastcall->type; |
| 1086 | $lasttime = $lastcall->created_at; | 1214 | $lasttime = $lastcall->created_at; |
| 1087 | if ($lasttime == "0000-00-00 00:00:00") $lasttime = ""; | 1215 | if ($lasttime == "0000-00-00 00:00:00") { |
| 1088 | else $lasttime = date("d-M-y H:i:s", strtotime($lasttime) - ((Auth::user()->timezone) * 60)); | 1216 | $lasttime = ""; |
| 1217 | } else { | ||
| 1218 | $lasttime = date("d-M-y H:i:s", strtotime($lasttime) - ((Auth::user()->timezone) * 60)); | ||
| 1219 | } | ||
| 1220 | |||
| 1089 | $dispo = $lastcall->userstatus; | 1221 | $dispo = $lastcall->userstatus; |
| 1090 | $subdispo = $lastcall->usersubstatus; | 1222 | $subdispo = $lastcall->usersubstatus; |
| 1091 | $followup = $dbrow[dialer_callback]; | 1223 | $followup = $dbrow[dialer_callback]; |
| 1092 | if ($followup == "0000-00-00 00:00:00") $followup = ""; | 1224 | if ($followup == "0000-00-00 00:00:00") { |
| 1093 | else $followup = date("d-M-y H:i:s", strtotime($followup) - (Auth::user()->timezone * 60)); | 1225 | $followup = ""; |
| 1226 | } else { | ||
| 1227 | $followup = date("d-M-y H:i:s", strtotime($followup) - (Auth::user()->timezone * 60)); | ||
| 1228 | } | ||
| 1229 | |||
| 1094 | $remarks = $lastcall->userremarks; | 1230 | $remarks = $lastcall->userremarks; |
| 1095 | $did = $lastcall->did; | 1231 | $did = $lastcall->did; |
| 1096 | } | 1232 | } |
| ... | @@ -1237,7 +1373,6 @@ class DialerController extends Controller | ... | @@ -1237,7 +1373,6 @@ class DialerController extends Controller |
| 1237 | $userlog = new UserLog(); | 1373 | $userlog = new UserLog(); |
| 1238 | $reportDataArray = $userlog->getAgentPerformanceReportUserLogData($start_date, $end_date, $start_time, $end_time, $client, $type); | 1374 | $reportDataArray = $userlog->getAgentPerformanceReportUserLogData($start_date, $end_date, $start_time, $end_time, $client, $type); |
| 1239 | 1375 | ||
| 1240 | |||
| 1241 | $dateDataArray = $userlog->getDatesForReport($start_date, $end_date, $start_time, $end_time, $type); | 1376 | $dateDataArray = $userlog->getDatesForReport($start_date, $end_date, $start_time, $end_time, $type); |
| 1242 | $daySTART = $dateDataArray['daySTART']; | 1377 | $daySTART = $dateDataArray['daySTART']; |
| 1243 | $dayEND = $dateDataArray['dayEND']; | 1378 | $dayEND = $dateDataArray['dayEND']; |
| ... | @@ -1268,7 +1403,6 @@ class DialerController extends Controller | ... | @@ -1268,7 +1403,6 @@ class DialerController extends Controller |
| 1268 | $userlog = new UserLog(); | 1403 | $userlog = new UserLog(); |
| 1269 | $reportDataArray = $userlog->getAgentTimingSummaryReportUserLogData($start_date, $end_date, $start_time, $end_time, $client, $type); | 1404 | $reportDataArray = $userlog->getAgentTimingSummaryReportUserLogData($start_date, $end_date, $start_time, $end_time, $client, $type); |
| 1270 | 1405 | ||
| 1271 | |||
| 1272 | $dateDataArray = $userlog->getDatesForReport($start_date, $end_date, $start_time, $end_time, $type); | 1406 | $dateDataArray = $userlog->getDatesForReport($start_date, $end_date, $start_time, $end_time, $type); |
| 1273 | 1407 | ||
| 1274 | $daySTART = $dateDataArray['daySTART']; | 1408 | $daySTART = $dateDataArray['daySTART']; |
| ... | @@ -1365,7 +1499,6 @@ class DialerController extends Controller | ... | @@ -1365,7 +1499,6 @@ class DialerController extends Controller |
| 1365 | // | 1499 | // |
| 1366 | } | 1500 | } |
| 1367 | 1501 | ||
| 1368 | |||
| 1369 | public function dashboard() | 1502 | public function dashboard() |
| 1370 | { | 1503 | { |
| 1371 | //echo "OK"; | 1504 | //echo "OK"; |
| ... | @@ -1378,13 +1511,23 @@ class DialerController extends Controller | ... | @@ -1378,13 +1511,23 @@ class DialerController extends Controller |
| 1378 | // Log::info("APP_Test:" + env('app_ip')); | 1511 | // Log::info("APP_Test:" + env('app_ip')); |
| 1379 | $roclientstr = array(); | 1512 | $roclientstr = array(); |
| 1380 | $didlinesstr = array(); | 1513 | $didlinesstr = array(); |
| 1381 | if (Auth::user()->exten != "") $didlinesstr[] = Auth::user()->exten; | 1514 | if (Auth::user()->exten != "") { |
| 1515 | $didlinesstr[] = Auth::user()->exten; | ||
| 1516 | } | ||
| 1517 | |||
| 1382 | $oclientlst = $wakka->clientsOwnerRWAccess(); | 1518 | $oclientlst = $wakka->clientsOwnerRWAccess(); |
| 1383 | if (!empty($oclientlst)) foreach ($oclientlst as $tclnt) if ($tclnt != "") { | 1519 | if (!empty($oclientlst)) { |
| 1520 | foreach ($oclientlst as $tclnt) { | ||
| 1521 | if ($tclnt != "") { | ||
| 1384 | $roclientstr[] = (is_null($client)) ? "'$tclnt'" : "'$client'"; | 1522 | $roclientstr[] = (is_null($client)) ? "'$tclnt'" : "'$client'"; |
| 1385 | 1523 | ||
| 1386 | $mastersdata = $wakka->getCompanyMaster($tclnt); | 1524 | $mastersdata = $wakka->getCompanyMaster($tclnt); |
| 1387 | if (!empty($mastersdata["DialerDID"])) $didlinesstr[] = $mastersdata["DialerDID"]; | 1525 | if (!empty($mastersdata["DialerDID"])) { |
| 1526 | $didlinesstr[] = $mastersdata["DialerDID"]; | ||
| 1527 | } | ||
| 1528 | |||
| 1529 | } | ||
| 1530 | } | ||
| 1388 | } | 1531 | } |
| 1389 | 1532 | ||
| 1390 | $roclientstr = "client = '$client'"; | 1533 | $roclientstr = "client = '$client'"; |
| ... | @@ -1396,19 +1539,32 @@ class DialerController extends Controller | ... | @@ -1396,19 +1539,32 @@ class DialerController extends Controller |
| 1396 | if ($limit > 0) { | 1539 | if ($limit > 0) { |
| 1397 | $callbackDate = date("Y-m-d H:i:s", strtotime(date("Y-m-d H:i:s")) - (330 * 60)); | 1540 | $callbackDate = date("Y-m-d H:i:s", strtotime(date("Y-m-d H:i:s")) - (330 * 60)); |
| 1398 | $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"); | 1541 | $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"); |
| 1399 | foreach ($tusers as $tuser) if (!isset($users[$tuser['id']])) $users[$tuser['id']] = $tuser; | 1542 | foreach ($tusers as $tuser) { |
| 1543 | if (!isset($users[$tuser['id']])) { | ||
| 1544 | $users[$tuser['id']] = $tuser; | ||
| 1545 | } | ||
| 1546 | } | ||
| 1547 | |||
| 1400 | $limit = $limit - sizeof($tusers); | 1548 | $limit = $limit - sizeof($tusers); |
| 1401 | } | 1549 | } |
| 1402 | 1550 | ||
| 1403 | if ($limit > 0) { | 1551 | if ($limit > 0) { |
| 1404 | 1552 | ||
| 1405 | $tusers = $wakka->getPersons("status In ('called','Incall') and mobile!='' and $roclientstr order by dialer_lastcall asc limit $limit"); | 1553 | $tusers = $wakka->getPersons("status In ('called','Incall') and mobile!='' and $roclientstr order by dialer_lastcall asc limit $limit"); |
| 1406 | foreach ($tusers as $tuser) if (!isset($users[$tuser['id']])) $users[$tuser['id']] = $tuser; | 1554 | foreach ($tusers as $tuser) { |
| 1555 | if (!isset($users[$tuser['id']])) { | ||
| 1556 | $users[$tuser['id']] = $tuser; | ||
| 1557 | } | ||
| 1558 | } | ||
| 1559 | |||
| 1407 | $limit = $limit - sizeof($tusers); | 1560 | $limit = $limit - sizeof($tusers); |
| 1408 | } | 1561 | } |
| 1409 | 1562 | ||
| 1410 | $tusers = array(); | 1563 | $tusers = array(); |
| 1411 | foreach ($users as $tuser) $tusers[] = $tuser; | 1564 | foreach ($users as $tuser) { |
| 1565 | $tusers[] = $tuser; | ||
| 1566 | } | ||
| 1567 | |||
| 1412 | return $tusers; | 1568 | return $tusers; |
| 1413 | } | 1569 | } |
| 1414 | 1570 | ... | ... |
| ... | @@ -634,9 +634,17 @@ function incomingPopupAlert(var1,var2,var3) | ... | @@ -634,9 +634,17 @@ function incomingPopupAlert(var1,var2,var3) |
| 634 | kDesktopNotification("",var1,var2,1500); | 634 | kDesktopNotification("",var1,var2,1500); |
| 635 | } | 635 | } |
| 636 | 636 | ||
| 637 | function outgoingCall() | 637 | function outgoingCall(redial='') |
| 638 | { | 638 | { |
| 639 | var dialersearchresults=''; | ||
| 640 | if (redial!="redial") { | ||
| 641 | var dialersearchresults='dialersearchresults'; | ||
| 639 | $("#dialersearchresults").html(""); | 642 | $("#dialersearchresults").html(""); |
| 643 | }else{ | ||
| 644 | |||
| 645 | var displaydata=$("#dialersearchresults").html(); | ||
| 646 | |||
| 647 | } | ||
| 640 | kSetDData('C','callnumber',$("#manualdialnumber_txt").val()); | 648 | kSetDData('C','callnumber',$("#manualdialnumber_txt").val()); |
| 641 | 649 | ||
| 642 | var datastr="kstychCall="+JSON.stringify(kstychCall); | 650 | var datastr="kstychCall="+JSON.stringify(kstychCall); |
| ... | @@ -648,7 +656,10 @@ function outgoingCall() | ... | @@ -648,7 +656,10 @@ function outgoingCall() |
| 648 | { | 656 | { |
| 649 | if(kstychCall['callnumber']!="") | 657 | if(kstychCall['callnumber']!="") |
| 650 | { | 658 | { |
| 651 | doAjax('dialer?action=newcall&client='+client,datastr,'dialersearchresults', 'ajax_manualdial','singlefail','POST', function(retstr){ | 659 | doAjax('dialer?action=newcall&client='+client+'&redial='+redial,datastr,dialersearchresults, 'ajax_manualdial','singlefail','POST', function(retstr){ |
| 660 | if (redial=="redial"){ | ||
| 661 | $("#dialersearchresults").html(displaydata); | ||
| 662 | } | ||
| 652 | if(kstychCall['crmid']!="") | 663 | if(kstychCall['crmid']!="") |
| 653 | { | 664 | { |
| 654 | kSetDData('C','mCallState','Call'); | 665 | kSetDData('C','mCallState','Call'); |
| ... | @@ -675,7 +686,10 @@ function outgoingCall() | ... | @@ -675,7 +686,10 @@ function outgoingCall() |
| 675 | 686 | ||
| 676 | if(kstychDialer['mDialerState']=="DialNext") | 687 | if(kstychDialer['mDialerState']=="DialNext") |
| 677 | { | 688 | { |
| 678 | doAjax('dialer?action=newcall&client='+client,datastr,'dialersearchresults', 'ajax_manualdial','singlefail','POST', function(retstr){ | 689 | doAjax('dialer?action=newcall&client='+client,datastr,dialersearchresults, 'ajax_manualdial','singlefail','POST', function(retstr){ |
| 690 | if (redial=="redial"){ | ||
| 691 | $("#dialersearchresults").html(displaydata); | ||
| 692 | } | ||
| 679 | if(kstychCall['crmid']!="") | 693 | if(kstychCall['crmid']!="") |
| 680 | { | 694 | { |
| 681 | kSetDData('C','mCallState','Call'); | 695 | kSetDData('C','mCallState','Call'); |
| ... | @@ -695,7 +709,10 @@ function outgoingCall() | ... | @@ -695,7 +709,10 @@ function outgoingCall() |
| 695 | 709 | ||
| 696 | if(kstychDialer['mDialerState']=="Progressive") | 710 | if(kstychDialer['mDialerState']=="Progressive") |
| 697 | { | 711 | { |
| 698 | doAjax('dialer?action=newcall&client='+client,datastr,'dialersearchresults', 'ajax_manualdial','singlefail','POST', function(retstr){ | 712 | doAjax('dialer?action=newcall&client='+client+'&redial='+redial,datastr,dialersearchresults, 'ajax_manualdial','singlefail','POST', function(retstr){ |
| 713 | if (redial=="redial"){ | ||
| 714 | $("#dialersearchresults").html(displaydata); | ||
| 715 | } | ||
| 699 | if(kstychCall['crmid']!="") | 716 | if(kstychCall['crmid']!="") |
| 700 | { | 717 | { |
| 701 | kSetDData('C','mCallState','Call'); | 718 | kSetDData('C','mCallState','Call'); |
| ... | @@ -965,7 +982,7 @@ function resetDialer() | ... | @@ -965,7 +982,7 @@ function resetDialer() |
| 965 | kSetDData('C','ts_Dispo',0); | 982 | kSetDData('C','ts_Dispo',0); |
| 966 | kSetDData('C','ts_Close',0); | 983 | kSetDData('C','ts_Close',0); |
| 967 | 984 | ||
| 968 | updateDialerState("action","dialnext"); | 985 | updateDialerState("action","dialnext","redial"); |
| 969 | 986 | ||
| 970 | return; | 987 | return; |
| 971 | } | 988 | } |
| ... | @@ -1124,9 +1141,17 @@ function updateDialerState(objstr,key,val,key2,val2) | ... | @@ -1124,9 +1141,17 @@ function updateDialerState(objstr,key,val,key2,val2) |
| 1124 | if(objstr=="action") | 1141 | if(objstr=="action") |
| 1125 | { | 1142 | { |
| 1126 | 1143 | ||
| 1127 | if(key=="dialnext") | 1144 | if(key=="dialnext" && val== "redial") |
| 1128 | { | 1145 | { |
| 1146 | alert(val+"1"); | ||
| 1147 | outgoingCall(val); | ||
| 1148 | |||
| 1149 | } | ||
| 1150 | if(key=="dialnext" && val== ""){ | ||
| 1151 | |||
| 1152 | alert(val+"2"); | ||
| 1129 | outgoingCall(); | 1153 | outgoingCall(); |
| 1154 | |||
| 1130 | } | 1155 | } |
| 1131 | if(key=="hangupall") | 1156 | if(key=="hangupall") |
| 1132 | { | 1157 | { | ... | ... |
-
Please register or sign in to post a comment