f22464f4 by Prashant Jadhav

summary tab

1 parent f1d28282
......@@ -3077,7 +3077,255 @@ function createRacingCust()
return $data;
}
//for RLP
function createRLP()
{
$dataarr=$this->recruitdata["peopledata"];
$rlpcust = DB::table('p11086_cop_rlp_cust_base_uat')->where('pbcode','=',$dataarr["client"])->where('cod_cust','=',$dataarr["clientcode"])->select('*')->get();
$data="";
//echo "<pre>".print_r($rlpcust)."</pre>";
$data.="<fieldset><legend class='new-recruit_legend'>RLP Customer WISE</legend>";
$data.="<div class=custom1 style='width:100%;'>
<h2></h2>";
$data.="<hr><br><table class='table kDataTable' cellpadding=0 cellspacing=0 border=0>
<thead><tr>
<td class='table_hrm_heading_green'>Product</td>
<td class='table_hrm_heading_green'>Opportunity</td>
<td class='table_hrm_heading_green'>Contacted</td>
<td class='table_hrm_heading_green'>Total Unique Calls Made to customer with Opportunity </td>
<td class='table_hrm_heading_green'>Total Unique Customers Pitched</td>
<td class='table_hrm_heading_green'>LG (Offline)</td>
<td class='table_hrm_heading_green'>LC</td>
<td class='table_hrm_heading_green'>Activation</td>
</tr></thead>";
$data.="<tr>
<td>Auto Loan</td>
<td>
<table>
<tr><td>".$rlpcust[0]->al_qm_opp."</td></tr><tr><td>".$rlpcust[0]->al_upg_opp."</td></tr><tr><td>".$rlpcust[0]->al_al_cnc_opp."</td></tr><tr><td>".$rlpcust[0]->al_pa_opp."</td></tr><tr><td>".$rlpcust[0]->al_zip_opp."</td></tr></table>
</td>
<td>".$rlpcust[0]->al_called_opp."</td>
<td>".$rlpcust[0]->al_pitch."</td>
<td></td>
<td>".$rlpcust[0]->al_lg."</td>
<td></td>
<td></td>
</tr>
<tr>
<td>Personal Loan</td>
<td>
<table>
<tr><td>".$rlpcust[0]->pl_10sec_opp."</td></tr><tr><td>".$rlpcust[0]->pl_pa_opp."</td></tr><tr><td>".$rlpcust[0]->pl_pq_opp."</td></tr><tr><td>".$rlpcust[0]->bl_10sec_opp."</td></tr><tr><td>".$rlpcust[0]->bl_pq_opp."</td></tr>
</table>
</td>
<td>".$rlpcust[0]->pl_called_opp."</td>
<td>".$rlpcust[0]->pl_pitch."</td>
<td></td>
<td>".$rlpcust[0]->pl_lg."</td>
<td></td>
<td></td>
</tr>
<tr>
<td>Two Wheeler Loan</td>
<td>".$rlpcust[0]->twl_pa_opp."</td>
<td>".$rlpcust[0]->twl_called_opp."</td>
<td>".$rlpcust[0]->twl_pitch."</td>
<td></td>
<td>".$rlpcust[0]->twl_lg."</td>
<td></td>
<td></td>
</tr>
<tr>
<td>Home Loan</td>
<td>
<table>
<tr><td>".$rlpcust[0]->hl_pq_opp."<td></tr><tr><td>".$rlpcust[0]->hl_bt_opp."<td></tr>
</table>
</td>
<td>".$rlpcust[0]->hl_called_opp."</td>
<td>".$rlpcust[0]->hl_pitch."</td>
<td></td>
<td>".$rlpcust[0]->hl_pitch."</td>
<td></td>
<td></td>
</tr>
<tr>
<td>Gold Loan</td>
<td>GL</td>
<td></td>
<td>".$rlpcust[0]->gl_pitch."</td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td>Loan Against Securities</td>
<td>".$rlpcust[0]->las_opp."</td>
<td>".$rlpcust[0]->las_called_opp."</td>
<td>".$rlpcust[0]->las_pitch."</td>
<td></td>
<td>".$rlpcust[0]->las_lg."</td>
<td></td>
<td></td>
</tr>
<tr>
<td>Loan Against Property</td>
<td>".$rlpcust[0]->lap_opp."</td>
<td>".$rlpcust[0]->lap_called_opp."</td>
<td></td>
<td></td>
<td>".$rlpcust[0]->lap_lg."</td>
<td></td>
<td></td>
</tr>
<tr>
<td>HSL</td>
<td>".$rlpcust[0]->hsl_opp."</td>
<td>".$rlpcust[0]->hsl_called_opp."</td>
<td>".$rlpcust[0]->hsl_pitch."</td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td>Credit Card</td>
<td>".$rlpcust[0]->cc_eli_new_opp."</td>
<td>".$rlpcust[0]->cc_called_opp."</td>
<td>".$rlpcust[0]->cc_pitch."</td>
<td></td>
<td>".$rlpcust[0]->cc_lg."</td>
<td></td>
<td></td>
</tr>
<tr>
<td>CC Activation</td>
<td>".$rlpcust[0]->cc_activation_opp."</td>
<td>".$rlpcust[0]->cc_activation_called_opp."</td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td>LI</td>
<td>".$rlpcust[0]->li_opp."</td>
<td>".$rlpcust[0]->li_called_opp."</td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td>FD</td>
<td>".$rlpcust[0]->fd_opp."</td>
<td>".$rlpcust[0]->fd_called_opp."</td>
<td>".$rlpcust[0]->fd_pitch."</td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td>SAVINGS LTD(Transections (0-3))</td>
<td>".$rlpcust[0]->ltd_act_saving_opp."</td>
<td>".$rlpcust[0]->ltd_act_saving_called_opp."</td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td>Mobile Banking/Netbanking</td>
<td>".$rlpcust[0]->mb_opp."</td>
<td>".$rlpcust[0]->mb_called_opp."</td>
<td>".$rlpcust[0]->mb_pitch."</td>
<td></td>
<td></td>
<td></td>
<td>".$rlpcust[0]->nb_mb_lg."</td>
</tr>
<tr>
<td>Aadhaar</td>
<td>".$rlpcust[0]->aadhaar_opp."</td>
<td>".$rlpcust[0]->aadhaar_called_opp."</td>
<td>".$rlpcust[0]->aadhaar_pitch."</td>
<td></td>
<td></td>
<td></td>
<td>".$rlpcust[0]->aadhaar_activation."</td>
</tr>
<tr>
<td>Digital 2.0 Score (Inactive)</td>
<td>".$rlpcust[0]->digi2_score_opp."</td>
<td>".$rlpcust[0]->digi2_score_called_opp."</td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td>Digital 2.0 Score (Bill Pay Inactive)</td>
<td>".$rlpcust[0]->digi_billpay_opp."</td>
<td>".$rlpcust[0]->digi_billpay_called_opp."</td>
<td>".$rlpcust[0]->bill_pay_pitch."</td>
<td></td>
<td>".$rlpcust[0]->las_lg."</td>
<td></td>
<td></td>
</tr>
<tr>
<td>Digital 2.0 Score(Basic Banking Inactive)</td>
<td>".$rlpcust[0]->digi_basic_banking_opp."</td>
<td>".$rlpcust[0]->digi_basic_banking_called_opp."</td>
<td>".$rlpcust[0]->las_pitch."</td>
<td></td>
<td>".$rlpcust[0]->las_lg."</td>
<td></td>
<td></td>
</tr>
<tr>
<td>Digital 2.0 Score(Ecom Shopping Inactive)</td>
<td>".$rlpcust[0]->digi_ecom_shopping_opp."</td>
<td>".$rlpcust[0]->digi_ecom_shopping_called_opp."</td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td>Digital 2.0 Score(Investment Inactive)</td>
<td>".$rlpcust[0]->digi_investment_opp."</td>
<td>".$rlpcust[0]->digi_investment_called_opp."</td>
<td>".$rlpcust[0]->invest_pitch."</td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td>Digital 2.0 Score(PHYSICAL Inactive)</td>
<td>".$rlpcust[0]->digi_physical_opp."</td>
<td>".$rlpcust[0]->digi_physical_called_opp."</td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
</table></div></fieldset>";
return $data;
}
function colorCodeRec($id)
{
......@@ -3142,6 +3390,7 @@ function CreateForm(&$frm)
//if(Auth::user()->username =="B654321" || Auth::user()->username =="B12345")
//{
$frm['Lead Entry Form']["{{id}} {{firstname}}"][]=array();
$frm['RLP']["{{id}} {{firstname}}"][]=array();
//}
}
}
......@@ -3210,6 +3459,7 @@ function CreateForm(&$frm)
//if($tbname=='RacingCustomer')$tabsdata.=$this->createRacingCust();
if($tbname=='Racing Format')$tabsdata.=$this->createRacingCust();
if($tbname=='Lead Entry Form')$tabsdata.=$this->createLeadEntryForm();
if($tbname=='RLP')$tabsdata.=$this->createRLP();
$tabsdata.="</div>";
$i++;
}
......
......@@ -123,7 +123,8 @@ return [
"Role" => ["disp"=>"Role","icon"=>"home","dash"=>"","onclick"=>""],
"DialMode" => ["disp"=>"DialMode","icon"=>"home","dash"=>"","onclick"=>""],
"SupervisorModule" => ["disp"=>"SupervisorModule","icon"=>"globe","dash"=>"","onclick"=>"menuAction('SupervisorModule');"],
"Notes" => ["disp"=>"Notes","icon"=>"globe","dash"=>"","onclick"=>"menuAction('notes');"],
"Notes" => ["disp"=>"Notes","icon"=>"globe","dash"=>"","onclick"=>"menuAction('notes');"],
"RLP" => ["disp"=>"RLP","icon"=>"globe","dash"=>"","onclick"=>"menuAction('rlp');"],
"Group" => ["disp"=>"Group","icon"=>"home","dash"=>"","onclick"=>"",
"title"=>env('app_name', 'Application'),
"keywords"=>"Kstych",
......@@ -134,6 +135,7 @@ return [
],
'app_groups' => [], //loaded from db
'admindebug' => filter_var(env('APP_ADMIN_DEBUG',true), FILTER_VALIDATE_BOOLEAN),
'name' => env('app_name', 'Application'),
......
......@@ -221,6 +221,8 @@ function waitKeyUpRun(varid,fncall,wttime)
function menuAction(menu)
{
$(".homemenu").removeClass("active");
//doAjax(menu,'','content','ajax_'+menu,'singlethis','GET');
//for rlp pbwise call ajax
if(menu=='rlp'){
pbcode=$('#tcampaign_select').val();
doAjax(menu+'?pbcode='+pbcode,'','content','ajax_'+menu,'singlethis','GET');
......
<?php namespace App\Http\Controllers;
use Auth;
use Input;
use Response;
use Config;
use App\Models\Group;
use App\Models\Master;
use App\Models\Record;
use App\Models\CRMCall;
use App\Models\CRMCallArchive;
use App\Models\CRM;
use App\Models\CRMCampaign;
use App\Models\CRMList;
use App\Jobs\KHRMSLib;
use App\Models\Sipid;
use App\Models\Dialline;
use App\Models\UserLog;
use App\Models\Kqueue;
use DB;
use Log;
use Session;
$client='';
class DialerController extends Controller {
public function __construct()
{
$this->middleware('auth');
$this->middleware('module_access');
}
public function index()
{
}
public function create()
{
}
public function store()
{
$action=Input::get('action');
$client=Input::get('client');
$kstychCall=json_decode(html_entity_decode(Input::get("kstychCall"),ENT_QUOTES, "UTF-8"),true);
$kstychDialer=json_decode(html_entity_decode(Input::get("kstychDialer"),ENT_QUOTES, "UTF-8"),true);
if($action=="previewnext")
{
$wakka = new KHRMSLib();
$roclientstr=array();
$oclientlst=$wakka->clientsReadAccess();
if(!empty($oclientlst))foreach($oclientlst as $tclnt)if($tclnt!=""){$roclientstr[]="'$tclnt'";}
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);
if(!empty($users))
{
$searchresult.="<div id=divworking></div><div style='clear:both'></div><script>kSetDData('C','previewcrmid','".$users[0]['id']."');showRecruit(\"".$users[0]['id']."\");</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('');
});
</script>";
}
else
{
$searchresult.="<div id=internalid_matchlist></div><script>createSearchRecordDiv('internalid_matchlist');</script>";
}
return Response::make($searchresult);
}
if($action=="newcall")
{
$wakka = new KHRMSLib();
$roclientstr=array();
$oclientlst=$wakka->clientsReadAccess();
foreach($oclientlst as $tclnt)if($tclnt!=""){$roclientstr[]="'$tclnt'";}
if(!empty($roclientstr))$roclientstr="and client in (".implode(",",$roclientstr).")";else $roclientstr="";
$users=array();$callnumber=$kstychCall['callnumber'];
//code by prashant Jadhav for manual calls on alternate number and same mobile number assign to different records then it shows another customer info while dialing--------
if($kstychCall['crmid'])
{
$crmid=$kstychCall['previewcrmid'];
}
else
{
$crmid=$kstychCall['previewcrmid'];
}
if($kstychDialer['mDialerState']=="Manual")
{
if($crmid!="")
{
$tusers=$wakka->getPersonIDs("(mobile like '%".substr($callnumber,-10)."' OR
altphone1 like '%".substr($callnumber,-10)."' OR
altphone2 like '%".substr($callnumber,-10)."' OR
altphone3 like '%".substr($callnumber,-10)."' OR
altphone4 like '%".substr($callnumber,-10)."' OR
altphone5 like '%".substr($callnumber,-10)."' OR
altphone6 like '%".substr($callnumber,-10)."' OR
altphone7 like '%".substr($callnumber,-10)."' OR
altphone8 like '%".substr($callnumber,-10)."' OR
altphone9 like '%".substr($callnumber,-10)."' OR
altphone10 like '%".substr($callnumber,-10)."') and id=$crmid ");
/*$tusers=$wakka->getPersonIDs("(mobile like '%".substr($callnumber,-10)."' OR
altphone1 like '%$callnumber' OR
altphone2 like '%$callnumber' OR
altphone3 like '%$callnumber' OR
altphone4 like '%$callnumber' OR
altphone5 like '%$callnumber' OR
altphone6 like '%$callnumber' OR
altphone7 like '%$callnumber' OR
altphone8 like '%$callnumber' OR
altphone9 like '%$callnumber' OR
altphone10 like '%$callnumber') and id=$crmid ");*/
}
else
{
$tusers=$wakka->getPersonIDs("mobile like '%".substr($callnumber,-10)."' OR
altphone1 like '%".substr($callnumber,-10)."' OR
altphone2 like '%".substr($callnumber,-10)."' OR
altphone3 like '%".substr($callnumber,-10)."' OR
altphone4 like '%".substr($callnumber,-10)."' OR
altphone5 like '%".substr($callnumber,-10)."' OR
altphone6 like '%".substr($callnumber,-10)."' OR
altphone7 like '%".substr($callnumber,-10)."' OR
altphone8 like '%".substr($callnumber,-10)."' OR
altphone9 like '%".substr($callnumber,-10)."' OR
altphone10 like '%".substr($callnumber,-10)."' ");
/*$tusers=$wakka->getPersonIDs("mobile like '%".substr($callnumber,-10)."' OR
altphone1 like '%$callnumber' OR
altphone2 like '%$callnumber' OR
altphone3 like '%$callnumber' OR
altphone4 like '%$callnumber' OR
altphone5 like '%$callnumber' OR
altphone6 like '%$callnumber' OR
altphone7 like '%$callnumber' OR
altphone8 like '%$callnumber' OR
altphone9 like '%$callnumber' OR
altphone10 like '%$callnumber' ");*/
}
/*if($crmid!=""){
$tusers=$wakka->getPersonIDs("mobile like '%".substr($callnumber,-10)."' and id=$crmid ");
}else{
$tusers=$wakka->getPersonIDs("mobile like '%".substr($callnumber,-10)."'");
}*/
$uids=array();foreach($tusers as $tuser)if(isset($tuser['id']))$uids[]=$tuser['id']+0;
$idstr=implode(",",$uids);if($idstr=="")$idstr="''";
//$users=$wakka->getPersons("mobile like '%$callnumber' and id in ($idstr) $roclientstr");
$users=$wakka->getPersons("(mobile like '%$callnumber' OR
altphone1 like '%$callnumber' OR
altphone2 like '%$callnumber' OR
altphone3 like '%$callnumber' OR
altphone4 like '%$callnumber' OR
altphone5 like '%$callnumber' OR
altphone6 like '%$callnumber' OR
altphone7 like '%$callnumber' OR
altphone8 like '%$callnumber' OR
altphone9 like '%$callnumber' OR
altphone10 like '%$callnumber' ) and id in ($idstr) $roclientstr");
//code end by prashant Jadhav for manual calls on alternate number
// if(!$users)
// {
// for($i=1;$i<=10;$i++)
// {
// $users=$wakka->getPersons("altphone$i = '$callnumber' $roclientstr");
// if(!empty($users))break;
// }
// }
if(!$users)
{
$users=array(0=>array('id'=>0,'peopledata'=> serialize(array('client'=>'','department'=>'','mobile'=>$callnumber))));
}
}
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);
}
$searchresult='<div style="clear:both"></div><div id=divworking></div><div style="clear:both"></div>';
if(!empty($users))
{
if(sizeof($users)>=1)
{
$ppldata=unserialize($users[0]['peopledata']);
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)
{
$mastersdata=$wakka->getCompanyMaster($ppldata['client']);
$callerid="";if(!empty($mastersdata["DialerDID"]))$callerid=$mastersdata["DialerDID"];
if($callerid=="")$callerid=Auth::user()->exten;
$calleridarr=explode(":",$callerid);$dspan="1";
if(isset($calleridarr[1])){$callerid=$calleridarr[0];$dspan=$calleridarr[1];}
//see if user is online on this sipid
$sipid=Sipid::find($kstychDialer['phone']);
if($sipid&&$sipid->user==Auth::user()->id&&$sipid->status==1)
{
$dialline=Dialline::where("status","=","Free")->where("enabled","=","1");
if($dspan!="")$dialline=$dialline->where('dspan','=',$dspan);
$dialline=$dialline->orderBy('updated_at','ASC')->first();
if($dialline)
{
$dialline->status="Blocked";
$dialline->save();
$nowts=microtime(true)*1000;
//get ts_Wait
$userlog=UserLog::where('user_id','=',Auth::user()->id)->orderBy("id","DESC")->first();
$ts_Wait=$userlog->getLastTs($sipid->id,$nowts);
$userlog->save();
//start the call log
$crmcall=new CRMCall();
$crmcall->number=$callnumber;
$crmcall->user_id=Auth::user()->id;
$crmcall->sipid_id=$sipid->id;
$crmcall->crm_id=$users[0]['id'];
$crmcall->client=$ppldata['client'];
$crmcall->department=$ppldata['department'];
$crmcall->state='New';
$crmcall->type=$kstychDialer['mDialerState'];
$crmcall->dialline_id=$dialline->id;
$crmcall->setTs('ts_Wait',$ts_Wait);
$crmcall->setTs('ts_Call',$nowts);
$crmcall->did=$callerid;
$tdata=array();
$crmcall->data=json_encode($tdata);
$crmcall->save();
//$wakka->setPersonKey($crmcall->crm_id,"dialer_lastcall",date("Y-m-d H:i:s"));
//start actual calls
$ppldata['dialer_lastcall']=date("Y-m-d H:i:s");
$preppldata['peopledata'] = serialize($ppldata);
$wakka->setPerson($ppldata['peopledata']['id'],$preppldata);
$newqueue=new Kqueue();
$newqueue->userToConf($sipid);
$newqueue=new Kqueue();
$newqueue->custToConf($sipid,$callnumber,$callerid,$crmcall,$dialline);
$searchresult.="<script>kSetDData('C','callid','".$crmcall->id."');kSetDData('C','crmid','".$users[0]['id']."');kSetDData('C','callnumber','$callnumber');showRecruit(\"".$users[0]['id']."\");</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('');
});
</script>";
return Response::make($searchresult);
}
else
{
return Response::make("<script>kstychCall['crmid']=0;kSetDData('C','previewcrmid','');simpleNotification('error','topRight','No Lines Free to Dial!');</script>");
}
}
else
{
return Response::make("<script>kstychCall['crmid']=0;kSetDData('C','previewcrmid','');simpleNotification('error','topRight','You Are Not Connected!');</script>");
}
}
else
{
$wakka->setPersonKey($users[0]['id'],"status","NoNumber");
return Response::make($searchresult."<script>kstychCall['crmid']=0;kSetDData('C','previewcrmid','');simpleNotification('error','topRight','No Number in Record!');</script>");
}
}
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."<script>kstychCall['crmid']=0;kSetDData('C','previewcrmid','');simpleNotification('error','topRight','No Records Found!');createSearchRecordDiv('dialersearchbox');</script>");
}
if($action=="addconfcall")
{
$retstr="";
$callnumber=Input::get("confnumber");
$callerid="";
//see if user is online on this sipid
$sipid=Sipid::find($kstychDialer['phone']);
if($sipid&&$sipid->user==Auth::user()->id&&$sipid->status==1)
{
$oldcrmcall=CRMCall::find($kstychCall['callid']);
if($oldcrmcall)
{
$olddialline=Dialline::find($oldcrmcall->dialline_id);
$dspan="1";if($olddialline)$dspan=$olddialline->dspan;
$dialline=Dialline::where("status","=","Free")->where("enabled","=","1");
if($dspan!="")$dialline=$dialline->where('dspan','=',$dspan);
$dialline=$dialline->orderBy('updated_at','ASC')->first();
if($dialline)
{
$callerid=$oldcrmcall->did;
$dialline->status="Blocked";
$dialline->save();
$nowts=microtime(true)*1000;
//start the call log
$crmcall=new CRMCall();
$crmcall->number=$callnumber;
$crmcall->user_id=Auth::user()->id;
$crmcall->sipid_id=$sipid->id;
$crmcall->crm_id=$oldcrmcall->crm_id;
$crmcall->client=$oldcrmcall->client;
$crmcall->department=$oldcrmcall->department;
$crmcall->state='New';
$crmcall->userstatus='Conference';
$crmcall->usersubstatus='Conference';
$crmcall->type='Conference';
$crmcall->dialline_id=$dialline->id;
$crmcall->setTs('ts_Wait',$nowts);
$crmcall->setTs('ts_Call',$nowts);
$crmcall->did=$callerid;
$tdata=array();
$crmcall->data=json_encode($tdata);
$crmcall->save();
//start actual calls
$newqueue=new Kqueue();
$newqueue->userToConf($sipid);
$newqueue=new Kqueue();
$newqueue->custToConf($sipid,$callnumber,$callerid,$crmcall,$dialline);
$retstr=$crmcall->id;
}
else
{
$retstr="Error : No Lines Free to Dial!";
}
}
else
{
$retstr="Error : No calls to conference found!";
}
}
else
{
$retstr="Error : You Are Not Connected!";
}
return Response::make($retstr);
}
if($action=="hangupall")
{
$res=0;
$callid=intval($kstychCall['callid'])+0;
$crmcall=CRMCall::find($callid);
if($crmcall&&$crmcall->user_id==Auth::user()->id)
{
if($crmcall->state=='New'&&time()-strtotime($crmcall->created_at)<=3)
{
return Response::make("//Error : Dialstate is $crmcall->state");
}
else
{
$dialline=Dialline::find($crmcall->dialline_id);
if($dialline)
{
if($crmcall->state!='Hangup')
{
$crmcall->hsource='User';
$crmcall->save();
}
//hangup
$newqueue=new Kqueue();
$newqueue->hangupChannel($dialline);
if($kstychDialer["keeplocalconf"]=="0")
{
$newqueue=new Kqueue();
$newqueue->hangupChannelS($kstychDialer['connection']['channel'],$dialline->server);
}
//hangup any conf calls
if(is_array($kstychCall['connections']))foreach($kstychCall['connections'] as $num=>$conn)
{
if(!empty($conn['callid']))
{
$tcrmcall=CRMCall::find($conn['callid']);
if($tcrmcall)
{
$tdialline=Dialline::find($tcrmcall->dialline_id);
if($tdialline)
{
$newqueue=new Kqueue();
$newqueue->hangupChannel($tdialline);
$res.=$conn['callid']."_";
}
}
}
}
return Response::make("//SENT $res");
}
else return Response::make("//Error : Dialline Not found ($callid)");
}
}
else return Response::make("//Error : Call Not Found ($callid)");
}
if($action=="closecall")
{
$callid=intval($kstychCall['callid'])+0;
$crmcall=CRMCall::find($callid);
if($crmcall&&$crmcall->user_id==Auth::user()->id)
{
$nowts=microtime(true)*1000;
if($kstychCall["usercallback"]!="")
{
$kstychCall["usercallback"]=date("Y-m-d H:i:s",strtotime($kstychCall["usercallback"].":00")+((Auth::user()->timezone)*60));
}
$crmcall->setTs('ts_Close',$nowts);
$crmcall->userstatus =$kstychCall["userstatus"];
$crmcall->usersubstatus =$kstychCall["usersubstatus"];
$crmcall->usercallback =$kstychCall["usercallback"];
$crmcall->attempt =$kstychCall["attempt"];//attempt dropdown value insert.
//preg_replace("/[^ \w]+/", "", $kstychCall["userremarks"]);
$crmcall->userremarks =preg_replace("/[^ \w]+/","", $kstychCall["userremarks"]);
$wakka = new KHRMSLib();
if($crmcall->crm_id==0)
{
if($kstychCall["crmid"]>0)
{
$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($crmcall->crm_id>0)
{
if(is_array($kstychCall["userdata"]))
{
foreach($kstychCall["userdata"] as $tcrmid=>$tuserdata)
{
if($tcrmid==$crmcall->crm_id)
{
$crmcall->userdata=json_encode($kstychCall["userdata"][$tcrmid]);
}
else
{
$empty="?";
foreach($kstychCall["userdata"][$tcrmid] as $key=>$val)
{
if(trim($val)!=""){$empty="no";break;}
}
if($empty=="no")
{
$tcrmcall=new CRMCall();
$tcrmcall->number=$crmcall->number;
$tcrmcall->user_id=Auth::user()->id;
$tcrmcall->sipid_id=$crmcall->sipid_id;
$tcrmcall->crm_id=$tcrmid;
$tcrmcall->client=$crmcall->client;
$tcrmcall->department=$crmcall->department;
$tcrmcall->state='Hangup';
$tcrmcall->type='NoCall';
$tcrmcall->userstatus='NoCall';
$tcrmcall->usersubstatus='NoCall';
//$tcrmcall->dialline_id='';
$tcrmcall->setTs('ts_Wait',$nowts);
$tcrmcall->did=$crmcall->did;
$tdata=array();
$tcrmcall->data=json_encode($tdata);
$tcrmcall->userdata=json_encode($kstychCall["userdata"][$tcrmid]);
$tcrmcall->save();
$tuser=$wakka->getPerson($tcrmid);
$tuser['peopledata']["dialer_status"]=$kstychCall["userstatus"];
$tuser['peopledata']["dialer_substatus"]=$kstychCall["usersubstatus"];
$tuser['peopledata']["dialer_callback"]=$kstychCall["usercallback"];
$tuser['peopledata']["dialer_remarks"]=str_replace("'","",kstychCall["userremarks"]);
$tuser['peopledata']["dialer_flag"]=$kstychCall["userflag"];
$tuser["bttc"]=$kstychCall["bttc_day"].":".$kstychCall["bttc_hrs"];
$tuser["serv_vs_prod"]=$kstychCall["serv_vs_prod"];
$tuser["resolution"]=$kstychCall["resolution"];
$tuser["satisfy"]=$kstychCall["satisfy"];
$tuser["final_call_assess"]=$kstychCall["final_call_assess"];
$tuser['peopledata']["dialer_userdata"]=$kstychCall["userdata"][$tcrmid];
if($tuser['peopledata']["status"]=='New' || $tuser['peopledata']["status"]=='NEW')$tuser['peopledata']["status"]="Called";
//for Supervisor Comments - By Manish
$tuser['agentcomments']=$kstychCall["agentcomments"];
$tuser['supcomntid']=$kstychCall["supcomntid"];
$tuser['peopledata']["dialer_lastcall"]=date("Y-m-d H:i:s");
$wakka->setPerson($tcrmid,$tuser);
}
}
}
}
$user=$wakka->getPerson($crmcall->crm_id);
if($user['peopledata']['id']==$crmcall->crm_id)
{
$user['peopledata']["dialer_status"]=$kstychCall["userstatus"];
$user['peopledata']["dialer_substatus"]=$kstychCall["usersubstatus"];
$user['peopledata']["dialer_callback"]=$kstychCall["usercallback"];
$user['peopledata']["dialer_remarks"]=str_replace("'","",$kstychCall["userremarks"]);
$user['peopledata']["dialer_flag"]=$kstychCall["userflag"];
$user['peopledata']["bttc"]=$kstychCall["bttc_day"].":".$kstychCall["bttc_hrs"];
$user['peopledata']["service_vs_product"]=$kstychCall["serv_vs_prod"];
$user['peopledata']["resolution"]=$kstychCall["resolution"];
$user['peopledata']["satisfaction"]=$kstychCall["satisfy"];
$user['peopledata']["final_call_assessment"]=$kstychCall["final_call_assess"];
// For Add Priority Snippet In Waterfall Bucket
if($user['peopledata']["priority"])
$user['peopledata']["priority"] = '';
if($user['peopledata']["mf_isa"])
$user['peopledata']["mf_isa"] = '';
$user['peopledata']["dialer_userdata"]=$kstychCall["userdata"][$crmcall->crm_id];
$user['peopledata']["dialer_lastcall"]=date("Y-m-d H:i:s");
if($user['peopledata']["status"]=='New' || $user['peopledata']["status"]=='NEW')$user['peopledata']["status"]="Called";
//for Supervisor Comments - By Manish
$user['agentcomments']=$kstychCall["agentcomments"];
$user['supcomntid']=$kstychCall["supcomntid"];
$wakka->setPerson($crmcall->crm_id,$user);
//update groupid if this is not groupid TODO move to config
if($user['peopledata']['clientcode']!=$user['peopledata']['clientinternalid'])
{
$tusers=$wakka->getPersons(" clientinternalid='".$user['peopledata']['clientinternalid']."' limit 1");
if(!empty($tusers))
{
$tppldata=unserialize($tusers[0]['peopledata']);
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"]);
$wakka->setPersonKey($tusers[0]['id'],'dialer_substatus',$user['peopledata']["dialer_substatus"]);
}
}
}
}
}
$crmcall->saveRecFileSize();
$crmcall->save();
/*if(Auth::user()->id=='92')
{*/
$fullremark=preg_replace("/[^ \w]+/", "", $kstychCall['fullremark']);
DB::insert(DB::raw("insert into full_remark set call_id='$callid',fullremark='$fullremark'"));
//}
/*$fullremark=preg_replace("/[^ \w]+/", "", $kstychCall['fullremark']);
DB::table('full_remark')->insert(['call_id'=>$callid,'fullremark'=>$fullremark]);*/
$userlog=UserLog::where('user_id','=',Auth::user()->id)->orderBy("id","DESC")->first();
$userlog->getLastTs($crmcall->sipid_id,$nowts);
$userlog->save();
}
return Response::make("");
}
//WRAPUP - Done By Manish
if($action == 'wrapup')
{
$callid=intval($kstychCall['callid'])+0;
$crmcall=CRMCall::find($callid);
if($crmcall&&$crmcall->user_id==Auth::user()->id)
{
$nowts=microtime(true)*1000;
$userstatus=$kstychCall["userstatus"];
$usersubstatus=$kstychCall["usersubstatus"];
$userlog=UserLog::where('user_id','=',Auth::user()->id)->orderBy("id","DESC")->first();
$userlog->getLastTs($crmcall->sipid_id,$nowts,$userstatus,$usersubstatus);
$userlog->save();
}
return Response::make("");
}
if($action=="kCallAction")
{
$actiontype=Input::get('actiontype');
$conf=Input::get("conf");
$channel=Input::get("channel");
if($actiontype=="Hangup")
{
$tdialline=Dialline::where('channel','=',$channel)->first();
if($tdialline)
{
$newqueue=new Kqueue();
$newqueue->hangupChannel($tdialline);
}
}
if($actiontype=="MuteMic")
{
$tdialline=Dialline::where('channel','=',$channel)->first();
if($tdialline)
{
$newqueue=new Kqueue();
$newqueue->channelMuteMic($tdialline->channel,$tdialline->server);
}
}
if($actiontype=="MuteSpeaker")
{
$tdialline=Dialline::where('channel','=',$channel)->first();
if($tdialline)
{
$newqueue=new Kqueue();
$newqueue->channelMuteSpeaker($tdialline->channel,$tdialline->server);
}
}
if($actiontype=="UnMuteMic")
{
$tdialline=Dialline::where('channel','=',$channel)->first();
if($tdialline)
{
$newqueue=new Kqueue();
$newqueue->channelUnMuteMic($tdialline->channel,$tdialline->server);
}
}
if($actiontype=="UnMuteSpeaker")
{
$tdialline=Dialline::where('channel','=',$channel)->first();
if($tdialline)
{
$newqueue=new Kqueue();
$newqueue->channelUnMuteSpeaker($tdialline->channel,$tdialline->server);
}
}
return Response::make("");
}
if($action=="dialerstate")
{
$ready=0;if($kstychDialer['mDialerState']=="Ready"&&$kstychCall['mCallState']=="Wait")$ready=1;
$nowts=microtime(true)*1000;
$sipid=Sipid::find($kstychDialer['phone']);
if($sipid&&$sipid->user==Auth::user()->id&&$sipid->status==1)
{
$sipid->ready=$ready;
$sipid->save();
$userlog=UserLog::where('user_id','=',Auth::user()->id)->orderBy("id","DESC")->first();
$userlog->getLastTs($sipid->id,$nowts,$kstychDialer['mDialerState'],$kstychDialer['mDialerSubState']);
$userlog->save();
}
return Response::make("");
}
if($action=="spychannel")
{
$sipid=Sipid::find($kstychDialer['phone']);
$tosip=Input::get('sipid');
$mode=Input::get('mode');
$modes=array('L'=>'2000','B'=>'2002','W'=>'2001');
if($sipid&&$tosip!=""&&isset($modes[$mode]))
{
$newqueue=new Kqueue();
$newqueue->sipOriginate($sipid,$modes[$mode].$tosip,"kstychDialerSpy");
}
return Response::make("");
}
if($action=="recarchive")
{
$type=Input::get("type");
if($type=="stageupload")
{
return view("layout.module.dialer.recarchive",array());
}
}
}
public function show($id)
{
/*if(time()>strtotime('14:30:00') || time()<strtotime('03:30:00'))
{
Session::flush();
}*/
if($id=="bucketdata")
{
$client=Input::get("client","");
$bucket=Input::get("bucket");
$currentstatus=Input::get("currentstatus");
$legalstatus=Input::get("legalstatus");
$page=intval(Input::get('page'));if($page<1)$page=1;
$skey=Input::get('skey');
$stxt=Input::get('stxt');
$skey='';
/*if($skey=="ID")$key='id';
if($skey=="FirstName")$key='firstname';
if($skey=="LastName")$key='lastname';
if($skey=="Client")$key='client';
if($skey=="Mobile")$key='mobile';
if($skey=="Email")$key='emailid';
if($skey=="Passport")$key='passportno';
if($skey=="IBAN")$key='ibannumber';
if($skey=="Status")$key='currentstatus';
if($skey=="PersonalID")$key='laborcardpersonalid';
if($skey=="InternalID")$key='clientinternalid';
if($skey=="ClientCode")$key='clientcode';
if($key!=''&&$stxt!='')$key=" and $key like '$stxt%'";else $key="";*/
/*if($stxt!='')$skey=" and (id like '$stxt%' or firstname like '$stxt%' or lastname like '$stxt%' or client like '$stxt%' or mobile 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 (firstname like '$stxt%' or mobile 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!="")
{
$owclientstr[]="'$tclnt'";
if($client=="")$client=$tclnt;
}
if(!empty($owclientstr))$owclientstr="and client in (".implode(",",$owclientstr).")";else $owclientstr="";
if($client!="")$owclientstr="and client='$client'";
$roclientstr=array();$didlinesstr=array();if(Auth::user()->exten!="")$didlinesstr[]=Auth::user()->exten;
$roclientlst=$wakka->clientsReadAccess();
if(!empty($roclientlst))foreach($roclientlst as $tclnt)if($tclnt!="")
{
$roclientstr[]="'$tclnt'";
if($client=="")$client=$tclnt;
$mastersdata=$wakka->getCompanyMaster($tclnt);
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="";
$roclientstrAll=$roclientstr;
if($client!="")$roclientstr="and client='$client'";
$bl=20;
$bs=($page-1)*$bl;
$dbres=array();
if($bucket=="CurrentQueue")$dbres=$this->getCallSequencing(20);
else if($bucket=="Priority")$dbres=$wakka->getPersons("priority in (1,2,3,4,5,6,7,8,9,10) $owclientstr limit $bs,$bl");
else if($bucket=="TotalData")$dbres=$wakka->getPersons("1=1 and currentstatus='$currentstatus' and legalstatus='$legalstatus' and status!='Noqueue' $owclientstr limit $bs,$bl");
else if($bucket=="SearchData")$dbres=$wakka->getPersons("1=1 $roclientstrAll $skey limit $bs,$bl");
else if($bucket=="NotCalled")$dbres=$wakka->getPersons("status='New' and currentstatus='$currentstatus' and legalstatus='$legalstatus' $owclientstr limit $bs,$bl");
else if($bucket=="Called")$dbres=$wakka->getPersons("status='Called' $owclientstr limit $bs,$bl");
else if($bucket=="Priority")$dbres=$wakka->getPersons("status='Priority' $owclientstr limit $bs,$bl");
else if($bucket=="Flagged-Called")$dbres=$wakka->getPersons("dialer_flag='VIP' and currentstatus='$currentstatus' and legalstatus='$legalstatus' $owclientstr limit $bs,$bl");
else if($bucket=="Flagged-Notcalled")$dbres=$wakka->getPersons("mf_isa='VIP' and currentstatus='$currentstatus' and legalstatus='$legalstatus' $owclientstr limit $bs,$bl");
else if($bucket=="MissedCalls")
{
$udidlinesstr = array();
foreach($didlinesstr as $didlinestr){
$didlinestrArr=explode(":",$didlinestr);
$udidlinesstr[] = substr($didlinestrArr[0], env('didnumber'));
}
$mc=CRMCall::where('userstatus','=','InboundDROP')->where('created_at','>',date('Y-m-d H:i:s',time()-(7*24*60*60)));
$mc=$mc->where(function ($query) use($roclientlst,$udidlinesstr){
$query->orWhereIn('client',$roclientlst)->orWhereIn('did',$udidlinesstr);
});
$mc=$mc->get();
$number_list=array();
foreach($mc as $key=>$tcall){
$tccal=substr($tcall->number,-10);
$mc_number=CRMCall::where('userstatus','!=','InboundDROP')->where ('created_at','>',$tcall->created_at)->where('number','like',"%".$tccal."%")->orderBy("id","DESC")->first();
$mccount= count($mc_number);
if($mccount==0){
$number_list[] = $tcall->number;
}
}
if(count($number_list) > 0) {
$lcalls=DB::select("SELECT * FROM crmcalls where id in (SELECT max(id) FROM crmcalls WHERE number IN ('" . implode("','", $number_list). "') GROUP BY number )");
foreach($lcalls as $lcall)
{
if($lcall->userstatus=="InboundDROP")
{
if($lcall->crm_id>0)
{
$reccrm_ids[] = "'".$lcall->crm_id."'";
}
else
{
$recordValue = DB::table('records')->where('mobile','=',substr($lcall->number,-10))->get();
if($recordValue){
$reccrm_ids[] = "'".$recordValue[0]->id."'";
}
else{
$dbres[]=array('client'=>$lcall->client,'mobile'=>substr($lcall->number,-10),'callid'=>$lcall->id);
}
}
}
}
if(!empty($reccrm_ids))
{
$recids_str = implode(",", $reccrm_ids);
$rec=$wakka->getPersons("id in ($recids_str)");
$dbres = array_merge($dbres,$rec);
}
}
}
else if($bucket=="CallsToday")$dbres=$wakka->getPersons("dialer_lastcall>='".date("Y-m-d 00:00:00",time()+((Auth::user()->timezone)*60))."' $owclientstr limit $bs,$bl");
else if($bucket=="CallsMonth")$dbres=$wakka->getPersons("dialer_lastcall>='".date("Y-m-01 00:00:00",time()+((Auth::user()->timezone)*60))."' $owclientstr limit $bs,$bl");
else
{
$currentstatus2='';$legalstatus2='';
if($currentstatus!="")$currentstatus2=" and currentstatus='$currentstatus' ";
if($legalstatus!="")$legalstatus2=" and legalstatus='$legalstatus' ";
$dbres=$wakka->getPersons("dialer_status='$bucket' $currentstatus2 $legalstatus2 $owclientstr limit $bs,$bl");
}
$ccountsummary=array();$k=1;//Log::info(count($dbres));
foreach($dbres as $dbrow)
{
if(isset($dbrow['callid']))
{
$lastcall=CRMCall::find($dbrow['callid']);
$callcntmonth=CRMCall::where("number","=",$dbrow['mobile'])->where("created_at",">=",date("Y-m-01 H:i:s",time()+((Auth::user()->timezone)*60)))->count();
}
else if($dbrow['id']>0)
{
$lastcall=CRMCall::where("crm_id","=",$dbrow['id'])->where('type','!=','Conference')->orderBy("id","DESC")->first();
$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;
$ccountsummary[$callcntmonth]++;
$type="";$lasttime="";$dispo="";$subdispo="";$followup="";$remarks="";$did="";
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));
$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));
$remarks=$lastcall->userremarks;
$did=$lastcall->did;
}
if(stristr($dbrow[firstname], "Potential") != "")
{
$rows.="<tr style='background-color: #59ee7c;color:#ffffff;font-weight: bolder;font-size:115%'>";
}
else
{
$rows.="<tr>";
}
if($bucket=="MissedCalls"){
$type="Inbound";
}
//onclick call disable for the manual mode is not assign to user code by prashant Jadhav
$userdialmode=Auth::user()->dialmode_assign;
$userdialmode=explode(",",$userdialmode);
if(in_array('Manual',$userdialmode))
{
$rows.="<td><a href=# class='' onclick='dialerQuickOpen(\"$dbrow[id]\",\"$dbrow[mobile]\",\"Manual\",\"\",0);return false;'><i class='fa fa-phone'></i></a></td>";
}
else
{
$rows.="<td><a href=# class='' return false;'><i class='fa fa-phone'></i></a></td>";
}
$rows.="<td>$k</td>
<td title='$dbrow[id]'>$dbrow[client]</td>
<td title=''>$dbrow[clientinternalid]</td>
<td title=''>$dbrow[clientcode]</td>
<td>$dbrow[firstname]</td>";
if(in_array('Manual',$userdialmode))
{
$rows.="<td><a href=# class='' onclick='dialerQuickOpen(\"$dbrow[id]\",\"$dbrow[mobile]\",\"Manual\",\"\",0);return false;'>$dbrow[mobile]</a></td>";
}
else
{
$rows.="<td><a href=# class='' return false;'>$dbrow[mobile]</a></td>";
}
$rows.="<td>$type</td>
<td>$lasttime</td>
<td title='$subdispo :: $remarks'>$dispo</td>
<td>$followup</td>
<td>$dbrow[status]</td>
<td>C".str_pad($callcntmonth,3, "0", STR_PAD_LEFT)."</td>
<!--<td><a href=# class='' onclick='dialerQuickOpen(\"$dbrow[id]\",\"$dbrow[mobile]\",\"Progressive\",\"\",0);return false;'><i class='fa fa-phone'></i></a> <a href=# class='' onclick='dialerQuickOpen(\"$dbrow[id]\",\"$dbrow[mobile]\",\"DialNext\",\"\",0);return false;'><i class='fa fa-file'></i></a></td>-->
<td>$did</td>
</tr>";
$k++;
}
$summarycounts="";
$message_display="";
ksort($ccountsummary);
foreach($ccountsummary as $key=>$val)
{
$summarycounts.="<span class='label label-small label-default'>C".str_pad($key,3, "0", STR_PAD_LEFT)." : $val</span>&nbsp;";
}
//Dispodelay running message on PB's Screen Code by Prashant Jadhav
$pb_message=DB::table('supervisor_message')->where('sup_id','=',Auth::user()->supervisor)->where('agents','like','%'.Auth::user()->username.'%')->where('status','like','%'.Auth::user()->username."-Unread".'%')->get();
//echo "<pre>".print_r($pb_message)."</pre>";
if(is_array($pb_message))
{
foreach ($pb_message as $messagekey => $messageval)
{
$message_display .="<marquee style='font-size:115%;font-weight: bolder;color:#3B2092'>".$messageval->message."</marquee>";
}
}
$data="<h5>Bucket : $bucket</h5>$message_display<hr>$summarycounts<br>";
//code end
$data.="<a class='pre_nxt' href='#' onclick=\"dialerLoadData('$bucket','$currentstatus','$legalstatus',".($page-1).",$('#dialerbkey').html(),$('#dialerbtxt').val());return false;\">&lt;&lt; Previous Page</a>
<a class='pre_nxt' href='#' onclick=\"dialerLoadData('$bucket','$currentstatus','$legalstatus',".($page+1).",$('#dialerbkey').html(),$('#dialerbtxt').val());return false;\">Next Page &gt;&gt;</a>
<span class=pull-right>
<input type=text class='form-control pull-left' style='width:200px' placeholder='search..' value='$stxt' id=dialerbtxt>
<button class='btn btn-default pull-right' onclick=\"dialerLoadData('SearchData','','',1,$('#dialerbkey').html(),$('#dialerbtxt').val());return false\"> Search </button>
</span>";
$data.="
<div style='clear:both'></div>
<table class='table '>
<thead>
<tr>
<th></th>
<th></th>
<th>Campaign</th>
<th>Group_ID</th>
<th>Cust_ID</th>
<th>Name</th>
<th>Number</th>
<th>Type</th>
<th>LastCall</th>
<th>Disposition</th>
<th>NextFollowup</th>
<th>Status</th>
<th>Count</th>
<!--<th></th>-->
<th>DID</th>
</tr>
</thead>
<tbody>
$rows
</table>";
return Response::make($data);
}
if($id=="reports")
{
return view("layout.module.dialer.reports",array());
}
if($id=="campaigns")
{
return view("layout.module.dialer.campaigns",array());
}
if($id=="calllog")
{
return view("layout.module.dialer.calllog",array());
}
if($id=="agentreport")
{
return view("layout.module.dialer.agentreport",array());
}
if($id=="campreport")
{
return view("layout.module.dialer.campreport",array());
}
if($id=="statusreport")
{
return view("layout.module.dialer.statusreport",array());
}
if($id=="questionnaire")
{
return view("layout.module.dialer.questairereport",array());
}
if($id=="callmanagement")
{
return view("layout.module.dialer.callmanagementreport",array());
}
if($id=="supmessages")
{
return view("layout.module.dialer.supmessagesreport",array());
}
if($id=='playrecfile')
{
$calllog=CRMCallArchive::find(Input::get("calllog"));
$file=$calllog->getRecFilePath();
$ext=$calllog->getRecFileExt();
if($ext=='wav')
{
header('Content-type: audio/x-wav');
header("Content-length: ".filesize($file));
header("Content-disposition: attachment; filename=\"".basename($file)."\"");
readfile("$file");
}
if($ext=='gsm')
{
$out=Input::get("out","ogg");
header("Content-type: audio/x-$out");
header("Content-disposition: attachment; filename=\"".basename($file).".$out\"");
$descriptorspec = array(0 => array("pipe", "r"),1 => array("pipe", "w"),2 => array("pipe", "w"));
$process = proc_open( "/usr/bin/sox $file /tmp/".basename($file).".$out", $descriptorspec, $pipes );
while( stream_get_contents( $pipes[1] ));
header("Content-length: ".filesize("/tmp/".basename($file).".$out"));
readfile("/tmp/".basename($file).".$out");unlink("/tmp/".basename($file).".$out");
fclose( $pipes[1] );
fclose( $pipes[2] );
}
return;
}
if($id=="liveusers")
{
return view("layout.module.dialer.liveusers",array());
}
if($id=="recarchive")
{
return view("layout.module.dialer.recarchive",array());
}
if($id=="recqc")
{
return view("layout.module.dialer.recqc",array());
}
//relationship area dropdown option fetched code. code by Yashwant Sir
if($id=="relationship")
{
$type=Input::get("type");
$id=Input::get("id");
if($type != "" && $id != ""){
if($type == "category"){
$output = "<option value=''>Select Category</option>";
$category = DB::table("relationship_category")->where("service_id",$id)->where("title","!=","")->where("status","=","Active")->get();
foreach($category as $cat){
$output .= "<option value='".$cat->id."'>".$cat->title."</option>";
}
return $output;
}else if($type == "subCategory"){
$output = "<option value=''>Select Sub Category</option>";
$subCategory = DB::table("relationship_sub_category")->where("category_id",$id)->where("title","!=","")->where("status","=","Active")->get();
foreach($subCategory as $cat){
$output .= "<option value='".$cat->title."'>".$cat->title."</option>";
}
return $output;
}
}
}
//pending missed call alert for supervisors code by Prashant Jadhav
if($id=="missedcallalert")
{
$user=Auth::user();
if($user->usertype=="Supervisor"||$user->usertype=="Admin")
{
$dbres=array();
$wakka = new KHRMSLib();
$rows="";
$owclientstr=array();
$oclientlst=$wakka->clientsOwnerRWAccess();
if(!empty($oclientlst))foreach($oclientlst as $tclnt)if($tclnt!="")
{
$owclientstr[]="'$tclnt'";
if($client=="")$client=$tclnt;
}
if(!empty($owclientstr))$owclientstr="and client in (".implode(",",$owclientstr).")";else $owclientstr="";
if($client!="")$owclientstr="and client='$client'";
$roclientstr=array();$didlinesstr=array();if(Auth::user()->exten!="")$didlinesstr[]=Auth::user()->exten;
$roclientlst=$wakka->clientsReadAccess();
if(!empty($roclientlst))foreach($roclientlst as $tclnt)if($tclnt!="")
{
$roclientstr[]="'$tclnt'";
if($client=="")$client=$tclnt;
$mastersdata=$wakka->getCompanyMaster($tclnt);
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="";
$roclientstrAll=$roclientstr;
if($client!="")$roclientstr="and client='$client'";
if(!empty($mastersdata["DialerDID"]))$didlinesstr[]=$mastersdata["DialerDID"];
$udidlinesstr = array();
foreach($didlinesstr as $didlinestr){
$didlinestrArr=explode(":",$didlinestr);
$udidlinesstr[] = substr($didlinestrArr[0], env('didnumber'));
}
/*$mc=CRMCall::where('userstatus','=','InboundDROP')->where('created_at','>=',date('Y-m-d H:i:s',time()-15*60));*/
$mc=CRMCall::where('userstatus','=','InboundDROP')->where('created_at','>',date('Y-m-d H:i:s',time()-(7*24*60*60)));
$mc=$mc->where(function ($query) use($roclientlst,$udidlinesstr){
$query->orWhereIn('client',$roclientlst)->orWhereIn('did',$udidlinesstr);
});
$mc=$mc->get();
$number_list=array();
foreach($mc as $key=>$tcall){
$tccal=substr($tcall->number,-10);
$mc_number=CRMCall::where('userstatus','!=','InboundDROP')->where ('created_at','>',$tcall->created_at)->where('number','like',"%".$tccal."%")->orderBy("id","DESC")->first();
$mccount= count($mc_number);
if($mccount==0){
$number_list[] = $tcall->number;
}
}
if(count($number_list) > 0)
{
$lcalls=DB::select("SELECT * FROM crmcalls where id in (SELECT max(id) FROM crmcalls WHERE number IN ('" . implode("','", $number_list). "') GROUP BY number )");
foreach($lcalls as $lcall)
{
if($lcall->userstatus=="InboundDROP")
{
if($lcall->crm_id>0)
{
$reccrm_ids[] = "'".$lcall->crm_id."'";
}
else
{
$recordValue = DB::table('records')->where('mobile','=',substr($lcall->number,-10))->get();
if($recordValue){
$reccrm_ids[] = "'".$recordValue[0]->id."'";
}
else{
$dbres[]=array('client'=>$lcall->client,'mobile'=>substr($lcall->number,-10),'callid'=>$lcall->id,'datetime'=>$lcall->updated_at);
}
}
}
}
if(!empty($reccrm_ids))
{
$recids_str = implode(",", $reccrm_ids);
$rec=$wakka->getPersons("id in ($recids_str)");
$dbres = array_merge($dbres,$rec);
$mobile="";
foreach ($dbres as $dbrow)
{
$mobile.= $dbrow['mobile']."-".$dbrow['client']."-".$dbrow['datetime'].",";
}
return "<script>alert('Missed call is pending for :-----".$mobile." !')</script>";
//echo "<pre>".print_r($dbres)."</pre>";
}
else
{
return;
}
}
}
}
return view("layout.module.dialer.$id",array());
}
public function edit($id)
{
}
public function update($id)
{
}
public function destroy($id)
{
//
}
public function dashboard()
{
//echo "OK";
}
private function getCallSequencing($limit)
{
$wakka = new KHRMSLib();
$roclientstr=array();$didlinesstr=array();
if(Auth::user()->exten!="")$didlinesstr[]=Auth::user()->exten;
$oclientlst=$wakka->clientsOwnerRWAccess();
if(!empty($oclientlst))foreach($oclientlst as $tclnt)if($tclnt!="")
{
$roclientstr[]="'$tclnt'";
$mastersdata=$wakka->getCompanyMaster($tclnt);
if(!empty($mastersdata["DialerDID"]))$didlinesstr[]=$mastersdata["DialerDID"];
}
$mroclientstr = $roclientstr;
$client=Input::get("client");
if(!empty($roclientstr))$roclientstr="client='$client'";else $roclientstr="";
//if(!empty($roclientstr))$roclientstr="client in (".implode(",",$roclientstr).")";else $roclientstr="";
$users=array();
if(Auth::user()->usertype!="User"){$tusers=array();return $tusers;}
// if(!empty($roclientstr))$roclientstr="client=''";else $roclientstr="";
$clientDetails=$wakka->getPersons("$roclientstr order by dialer_lastcall asc");
if($limit>0)
{
$tusers = array_filter($clientDetails, function($var){
return ($var['dialer_status']=='InboundDROP');
});
$l=1;
foreach($tusers as $tuser){
if(!isset($users[$tuser['id']])){
$users[$tuser['id']]=$tuser;
$l++;
if($l>$limit)
break;
}
}
$limit=$limit-sizeof($tusers);
}
if($limit>0)
{
if(!empty($didlinesstr))
{
$udidlinesstr = array();
foreach($didlinesstr as $didlinestr){
$didlinestrArr=explode(":",$didlinestr);
$udidlinesstr[] = substr($didlinestrArr[0], -8);
}
$tusers=array();
$mc=CRMCall::where('userstatus','=','InboundDROP')->where('created_at','>',date('Y-m-d H:i:s',time()-(7*24*60*60)));
$mc=$mc->where(function ($query) use($mroclientstr,$udidlinesstr){
$query->orWhereIn('client',$mroclientstr)->orWhereIn('did',$udidlinesstr);
});
$mc=$mc->get();
$number_list=array();
foreach($mc as $key=>$tcall){
$tccal=substr($tcall->number,-10);
$mc_number=CRMCall::where('userstatus','!=','InboundDROP')
->where('created_at','>',$tcall->created_at)
->where('number','like',"%".$tccal."%")
->orderBy("id","DESC")
->first();
$mccount= count($mc_number);
if($mccount==0){
$number_list[] = $tcall->number;
}
}
$othermissedcalls=DB::select("SELECT * FROM crmcalls where id in (SELECT max(id) FROM crmcalls WHERE number IN
('" . implode("','", $number_list). "') GROUP BY number )");
// $othermissedcalls=CRMCall::where('crm_id','=','0')->where('userstatus','=','InboundDROP')->where('did','like','%'.$didlinesstr.'%')->where('created_at','>',date('Y-m-d H:i:s',time()-(7*24*60*60)))->take($limit)->groupBy('number')->get();
/* Changes For Missed Call - 14/02/17 */
foreach($othermissedcalls as $othermissedcall)
{
$crmnumber = substr($othermissedcall->number, -10);
$tcall=array_filter($clientDetails, function($var) use ($crmnumber){
return ($var['mobile']==$crmnumber);
});
if($tcall)
{
$tcall = array_values($tcall);
$tcall = $tcall[0];
if(isset($tcall['id']) || $tcall['dialer_status']=="InboundDROP")
{
$tusers[$othermissedcall->id]=array('id'=>$tcall['id'],'mobile'=>$othermissedcall->number,'client'=>$tcall['client'],'clientcode'=>$tcall['clientcode'],'clientinternalid'=>$tcall['clientinternalid'], 'firstname'=>$tcall['firstname'],'callid'=>$othermissedcall->id);
}
}
}
/* Changes For Missed Call - 14/02/17 */
foreach($tusers as $tuser)if(!isset($users[$tuser['id']]))$users[$tuser['id']]=$tuser;
$limit=$limit-sizeof($tusers);
}
}
if($limit>0)
{
$tusers = array_filter($clientDetails, function($var){
return (strtotime($var['dialer_callback'])<strtotime(date('Y-m-d H:i:s',time()+(15*60)))&&$var['dialer_status']=='Contacted - FollowUp - Specific');
});
$l=1;
foreach($tusers as $tuser){
if(!isset($users[$tuser['id']])){
$users[$tuser['id']]=$tuser;
$l++;
if($l>$limit)
break;
}
}
$limit=$limit-sizeof($tusers);
}
// if(Auth::user()->id=="49"){
for($p=10;$p>0;$p--)
{
if($limit>0)
{
$tusers = array_filter($clientDetails, function($var) use ($p){
return (($var['priority']==$p)&&$var['mobile']!='');
}, ARRAY_FILTER_USE_BOTH);
if(!empty($tusers))
{
$l=1;
foreach($tusers as $tuser){
if(!isset($users[$tuser['id']])){
$users[$tuser['id']]=$tuser;
$l++;
if($l>$limit)
break;
}
}
$limit=$limit-sizeof($tusers);
}
}
}
// }
if($limit>0)
{
$tusers = array_filter($clientDetails, function($var){
return ($var['status']=='New'&&$var['mobile']!='');
});
$l=1;
foreach($tusers as $tuser){
if(!isset($users[$tuser['id']])){
$users[$tuser['id']]=$tuser;
$l++;
if($l>$limit)
break;
}
}
$limit=$limit-sizeof($tusers);
}
if($limit>0)
{
$tusers = array_filter($clientDetails, function($var){
return ($var['status']=='Called'&&$var['dialer_status']=='Not Contactable - Non Human Voice');
});
$l=1;
foreach($tusers as $tuser){
if(!isset($users[$tuser['id']])){
$users[$tuser['id']]=$tuser;
$l++;
if($l>$limit)
break;
}
}
$limit=$limit-sizeof($tusers);
}
if($limit>0)
{
$tusers = array_filter($clientDetails, function($var){
return ($var['status']=='Called'&&$var['dialer_status']=='Not Contactable - Human Voice');
});
$l=1;
foreach($tusers as $tuser){
if(!isset($users[$tuser['id']])){
$users[$tuser['id']]=$tuser;
$l++;
if($l>$limit)
break;
}
}
$limit=$limit-sizeof($tusers);
}
if($limit>0)
{
$tusers = array_filter($clientDetails, function($var){
return ($var['status']=='Called'&&$var['dialer_status']=='Contacted - Follow-Up - Generic');
});
$l=1;
foreach($tusers as $tuser){
if(!isset($users[$tuser['id']])){
$users[$tuser['id']]=$tuser;
$l++;
if($l>$limit)
break;
}
}
$limit=$limit-sizeof($tusers);
}
if($limit>0)
{
$tusers = array_filter($clientDetails, function($var){
return ($var['status']=='Called'&&$var['dialer_status']=='AUTOWRAPUP');
});
$l=1;
foreach($tusers as $tuser){
if(!isset($users[$tuser['id']])){
$users[$tuser['id']]=$tuser;
$l++;
if($l>$limit)
break;
}
}
$limit=$limit-sizeof($tusers);
}
$tusers=array();foreach($users as $tuser)$tusers[]=$tuser;
return $tusers;
}
}
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!