requirement changes
Showing
14 changed files
with
485 additions
and
6627 deletions
application/app/Http/Controllers/DialerController.php
100755 → 100644
| ... | @@ -90,7 +90,7 @@ class DialerController extends Controller { | ... | @@ -90,7 +90,7 @@ class DialerController extends Controller { |
| 90 | if(!empty($roclientstr))$roclientstr="and client in (".implode(",",$roclientstr).")";else $roclientstr=""; | 90 | if(!empty($roclientstr))$roclientstr="and client in (".implode(",",$roclientstr).")";else $roclientstr=""; |
| 91 | 91 | ||
| 92 | $users=array();$callnumber=$kstychCall['callnumber']; | 92 | $users=array();$callnumber=$kstychCall['callnumber']; |
| 93 | //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-------- | 93 | //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-------- |
| 94 | if($kstychCall['crmid']) | 94 | if($kstychCall['crmid']) |
| 95 | { | 95 | { |
| 96 | $crmid=$kstychCall['previewcrmid']; | 96 | $crmid=$kstychCall['previewcrmid']; |
| ... | @@ -471,6 +471,7 @@ if($action=="closecall") | ... | @@ -471,6 +471,7 @@ if($action=="closecall") |
| 471 | $crmcall->userstatus =$kstychCall["userstatus"]; | 471 | $crmcall->userstatus =$kstychCall["userstatus"]; |
| 472 | $crmcall->usersubstatus =$kstychCall["usersubstatus"]; | 472 | $crmcall->usersubstatus =$kstychCall["usersubstatus"]; |
| 473 | $crmcall->usercallback =$kstychCall["usercallback"]; | 473 | $crmcall->usercallback =$kstychCall["usercallback"]; |
| 474 | $crmcall->attempt =$kstychCall["attempt"];//attempt dropdown value insert. | ||
| 474 | 475 | ||
| 475 | //preg_replace("/[^ \w]+/", "", $kstychCall["userremarks"]); | 476 | //preg_replace("/[^ \w]+/", "", $kstychCall["userremarks"]); |
| 476 | $crmcall->userremarks =preg_replace("/[^ \w]+/","", $kstychCall["userremarks"]); | 477 | $crmcall->userremarks =preg_replace("/[^ \w]+/","", $kstychCall["userremarks"]); |
| ... | @@ -757,10 +758,10 @@ if($action=="recarchive") | ... | @@ -757,10 +758,10 @@ if($action=="recarchive") |
| 757 | } | 758 | } |
| 758 | public function show($id) | 759 | public function show($id) |
| 759 | { | 760 | { |
| 760 | if(time()>strtotime('14:30:00') || time()<strtotime('03:30:00')) | 761 | /*if(time()>strtotime('14:30:00') || time()<strtotime('03:30:00')) |
| 761 | { | 762 | { |
| 762 | Session::flush(); | 763 | Session::flush(); |
| 763 | } | 764 | }*/ |
| 764 | 765 | ||
| 765 | if($id=="bucketdata") | 766 | if($id=="bucketdata") |
| 766 | { | 767 | { |
| ... | @@ -840,14 +841,14 @@ public function show($id) | ... | @@ -840,14 +841,14 @@ public function show($id) |
| 840 | else if($bucket=="Called")$dbres=$wakka->getPersons("status='Called' $owclientstr limit $bs,$bl"); | 841 | else if($bucket=="Called")$dbres=$wakka->getPersons("status='Called' $owclientstr limit $bs,$bl"); |
| 841 | else if($bucket=="Priority")$dbres=$wakka->getPersons("status='Priority' $owclientstr limit $bs,$bl"); | 842 | else if($bucket=="Priority")$dbres=$wakka->getPersons("status='Priority' $owclientstr limit $bs,$bl"); |
| 842 | else if($bucket=="Flagged-Called")$dbres=$wakka->getPersons("dialer_flag='VIP' and currentstatus='$currentstatus' and legalstatus='$legalstatus' $owclientstr limit $bs,$bl"); | 843 | else if($bucket=="Flagged-Called")$dbres=$wakka->getPersons("dialer_flag='VIP' and currentstatus='$currentstatus' and legalstatus='$legalstatus' $owclientstr limit $bs,$bl"); |
| 843 | else if($bucket=="Flagged-Notcalled")$dbres=$wakka->getPersons("mf_isa='VIP' and currentstatus='$currentstatus' and legalstatus='$legalstatus' and status='New' $owclientstr limit $bs,$bl"); | 844 | else if($bucket=="Flagged-Notcalled")$dbres=$wakka->getPersons("mf_isa='VIP' and currentstatus='$currentstatus' and legalstatus='$legalstatus' $owclientstr limit $bs,$bl"); |
| 844 | 845 | ||
| 845 | else if($bucket=="MissedCalls") | 846 | else if($bucket=="MissedCalls") |
| 846 | { | 847 | { |
| 847 | $udidlinesstr = array(); | 848 | $udidlinesstr = array(); |
| 848 | foreach($didlinesstr as $didlinestr){ | 849 | foreach($didlinesstr as $didlinestr){ |
| 849 | $didlinestrArr=explode(":",$didlinestr); | 850 | $didlinestrArr=explode(":",$didlinestr); |
| 850 | $udidlinesstr[] = substr($didlinestrArr[0], -8); | 851 | $udidlinesstr[] = substr($didlinestrArr[0], env('didnumber')); |
| 851 | } | 852 | } |
| 852 | 853 | ||
| 853 | $mc=CRMCall::where('userstatus','=','InboundDROP')->where('created_at','>',date('Y-m-d H:i:s',time()-(7*24*60*60))); | 854 | $mc=CRMCall::where('userstatus','=','InboundDROP')->where('created_at','>',date('Y-m-d H:i:s',time()-(7*24*60*60))); |
| ... | @@ -957,14 +958,38 @@ public function show($id) | ... | @@ -957,14 +958,38 @@ public function show($id) |
| 957 | if($bucket=="MissedCalls"){ | 958 | if($bucket=="MissedCalls"){ |
| 958 | $type="Inbound"; | 959 | $type="Inbound"; |
| 959 | } | 960 | } |
| 960 | $rows.="<td><a href=# class='' onclick='dialerQuickOpen(\"$dbrow[id]\",\"$dbrow[mobile]\",\"Manual\",\"\",0);return false;'><i class='fa fa-phone'></i></a></td> | 961 | |
| 961 | <td>$k</td> | 962 | //onclick call disable for the manual mode is not assign to user code by prashant Jadhav |
| 963 | $userdialmode=Auth::user()->dialmode_assign; | ||
| 964 | $userdialmode=explode(",",$userdialmode); | ||
| 965 | |||
| 966 | if(in_array('Manual',$userdialmode)) | ||
| 967 | { | ||
| 968 | $rows.="<td><a href=# class='' onclick='dialerQuickOpen(\"$dbrow[id]\",\"$dbrow[mobile]\",\"Manual\",\"\",0);return false;'><i class='fa fa-phone'></i></a></td>"; | ||
| 969 | } | ||
| 970 | else | ||
| 971 | { | ||
| 972 | $rows.="<td><a href=# class='' return false;'><i class='fa fa-phone'></i></a></td>"; | ||
| 973 | } | ||
| 974 | |||
| 975 | |||
| 976 | $rows.="<td>$k</td> | ||
| 962 | <td title='$dbrow[id]'>$dbrow[client]</td> | 977 | <td title='$dbrow[id]'>$dbrow[client]</td> |
| 963 | <td title=''>$dbrow[clientinternalid]</td> | 978 | <td title=''>$dbrow[clientinternalid]</td> |
| 964 | <td title=''>$dbrow[clientcode]</td> | 979 | <td title=''>$dbrow[clientcode]</td> |
| 965 | <td>$dbrow[firstname]</td> | 980 | <td>$dbrow[firstname]</td>"; |
| 966 | <td><a href=# class='' onclick='dialerQuickOpen(\"$dbrow[id]\",\"$dbrow[mobile]\",\"Manual\",\"\",0);return false;'>$dbrow[mobile]</a></td> | 981 | |
| 967 | <td>$type</td> | 982 | if(in_array('Manual',$userdialmode)) |
| 983 | { | ||
| 984 | $rows.="<td><a href=# class='' onclick='dialerQuickOpen(\"$dbrow[id]\",\"$dbrow[mobile]\",\"Manual\",\"\",0);return false;'>$dbrow[mobile]</a></td>"; | ||
| 985 | } | ||
| 986 | else | ||
| 987 | { | ||
| 988 | $rows.="<td><a href=# class='' return false;'>$dbrow[mobile]</a></td>"; | ||
| 989 | } | ||
| 990 | |||
| 991 | |||
| 992 | $rows.="<td>$type</td> | ||
| 968 | <td>$lasttime</td> | 993 | <td>$lasttime</td> |
| 969 | <td title='$subdispo :: $remarks'>$dispo</td> | 994 | <td title='$subdispo :: $remarks'>$dispo</td> |
| 970 | <td>$followup</td> | 995 | <td>$followup</td> |
| ... | @@ -1120,14 +1145,14 @@ public function show($id) | ... | @@ -1120,14 +1145,14 @@ public function show($id) |
| 1120 | if($type != "" && $id != ""){ | 1145 | if($type != "" && $id != ""){ |
| 1121 | if($type == "category"){ | 1146 | if($type == "category"){ |
| 1122 | $output = "<option value=''>Select Category</option>"; | 1147 | $output = "<option value=''>Select Category</option>"; |
| 1123 | $category = DB::table("relationship_category")->where("service_id",$id)->where("title","!=","")->get(); | 1148 | $category = DB::table("relationship_category")->where("service_id",$id)->where("title","!=","")->where("status","=","Active")->get(); |
| 1124 | foreach($category as $cat){ | 1149 | foreach($category as $cat){ |
| 1125 | $output .= "<option value='".$cat->id."'>".$cat->title."</option>"; | 1150 | $output .= "<option value='".$cat->id."'>".$cat->title."</option>"; |
| 1126 | } | 1151 | } |
| 1127 | return $output; | 1152 | return $output; |
| 1128 | }else if($type == "subCategory"){ | 1153 | }else if($type == "subCategory"){ |
| 1129 | $output = "<option value=''>Select Sub Category</option>"; | 1154 | $output = "<option value=''>Select Sub Category</option>"; |
| 1130 | $subCategory = DB::table("relationship_sub_category")->where("category_id",$id)->where("title","!=","")->get(); | 1155 | $subCategory = DB::table("relationship_sub_category")->where("category_id",$id)->where("title","!=","")->where("status","=","Active")->get(); |
| 1131 | foreach($subCategory as $cat){ | 1156 | foreach($subCategory as $cat){ |
| 1132 | $output .= "<option value='".$cat->title."'>".$cat->title."</option>"; | 1157 | $output .= "<option value='".$cat->title."'>".$cat->title."</option>"; |
| 1133 | } | 1158 | } |
| ... | @@ -1185,11 +1210,11 @@ public function show($id) | ... | @@ -1185,11 +1210,11 @@ public function show($id) |
| 1185 | $udidlinesstr = array(); | 1210 | $udidlinesstr = array(); |
| 1186 | foreach($didlinesstr as $didlinestr){ | 1211 | foreach($didlinesstr as $didlinestr){ |
| 1187 | $didlinestrArr=explode(":",$didlinestr); | 1212 | $didlinestrArr=explode(":",$didlinestr); |
| 1188 | $udidlinesstr[] = substr($didlinestrArr[0], -8); | 1213 | $udidlinesstr[] = substr($didlinestrArr[0], env('didnumber')); |
| 1189 | } | 1214 | } |
| 1190 | 1215 | ||
| 1191 | /*$mc=CRMCall::where('userstatus','=','InboundDROP')->where('created_at','>=',date('Y-m-d H:i:s',time()-15*60));*/ | 1216 | /*$mc=CRMCall::where('userstatus','=','InboundDROP')->where('created_at','>=',date('Y-m-d H:i:s',time()-15*60));*/ |
| 1192 | $mc=CRMCall::where('userstatus','=','InboundDROP')->where('created_at','<',date('Y-m-d H:i:s',time()-(15*60))); | 1217 | $mc=CRMCall::where('userstatus','=','InboundDROP')->where('created_at','>',date('Y-m-d H:i:s',time()-(7*24*60*60))); |
| 1193 | $mc=$mc->where(function ($query) use($roclientlst,$udidlinesstr){ | 1218 | $mc=$mc->where(function ($query) use($roclientlst,$udidlinesstr){ |
| 1194 | $query->orWhereIn('client',$roclientlst)->orWhereIn('did',$udidlinesstr); | 1219 | $query->orWhereIn('client',$roclientlst)->orWhereIn('did',$udidlinesstr); |
| 1195 | }); | 1220 | }); |
| ... | @@ -1227,7 +1252,7 @@ public function show($id) | ... | @@ -1227,7 +1252,7 @@ public function show($id) |
| 1227 | $reccrm_ids[] = "'".$recordValue[0]->id."'"; | 1252 | $reccrm_ids[] = "'".$recordValue[0]->id."'"; |
| 1228 | } | 1253 | } |
| 1229 | else{ | 1254 | else{ |
| 1230 | $dbres[]=array('client'=>$lcall->client,'mobile'=>substr($lcall->number,-10),'callid'=>$lcall->id); | 1255 | $dbres[]=array('client'=>$lcall->client,'mobile'=>substr($lcall->number,-10),'callid'=>$lcall->id,'datetime'=>$lcall->updated_at); |
| 1231 | } | 1256 | } |
| 1232 | } | 1257 | } |
| 1233 | } | 1258 | } |
| ... | @@ -1243,9 +1268,9 @@ public function show($id) | ... | @@ -1243,9 +1268,9 @@ public function show($id) |
| 1243 | foreach ($dbres as $dbrow) | 1268 | foreach ($dbres as $dbrow) |
| 1244 | { | 1269 | { |
| 1245 | 1270 | ||
| 1246 | $mobile.= $dbrow['mobile']."-".$dbrow['client'].","; | 1271 | $mobile.= $dbrow['mobile']."-".$dbrow['client']."-".$dbrow['datetime'].","; |
| 1247 | } | 1272 | } |
| 1248 | return "<script>simpleNotification('error','topRight','Missed call is pending for ".$mobile." !')</script>"; | 1273 | return "<script>alert('Missed call is pending for :-----".$mobile." !')</script>"; |
| 1249 | //echo "<pre>".print_r($dbres)."</pre>"; | 1274 | //echo "<pre>".print_r($dbres)."</pre>"; |
| 1250 | } | 1275 | } |
| 1251 | else | 1276 | else | ... | ... |
| ... | @@ -208,5 +208,15 @@ class RecordController extends Controller { | ... | @@ -208,5 +208,15 @@ class RecordController extends Controller { |
| 208 | 208 | ||
| 209 | return view('layout.module.record.commentsUpload',$data); | 209 | return view('layout.module.record.commentsUpload',$data); |
| 210 | } | 210 | } |
| 211 | public function rlpPbwise() | ||
| 212 | { | ||
| 213 | $data = array(); | ||
| 214 | |||
| 215 | $pbcode=Input::get('pbcode'); | ||
| 216 | |||
| 217 | $data['pbcode']=$pbcode; | ||
| 218 | return view('layout.module.record.rlppbwise',$data); | ||
| 211 | 219 | ||
| 220 | } | ||
| 212 | } | 221 | } |
| 222 | ... | ... |
| ... | @@ -91,5 +91,7 @@ Route::group(['middleware' => ['web']], function () { | ... | @@ -91,5 +91,7 @@ Route::group(['middleware' => ['web']], function () { |
| 91 | Route::post('racingcustupdate',array('uses'=> 'RacingCustomerController@updateracingcust', 'as'=>'upload.updateraccust')); | 91 | Route::post('racingcustupdate',array('uses'=> 'RacingCustomerController@updateracingcust', 'as'=>'upload.updateraccust')); |
| 92 | Route::get('dialmode', array('uses'=> 'DialModeController@dialmodeview', 'as'=>'view.module')); | 92 | Route::get('dialmode', array('uses'=> 'DialModeController@dialmodeview', 'as'=>'view.module')); |
| 93 | Route::post('dialmodeassign', array('uses'=> 'DialModeController@dialmodeassign', 'as'=>'assign.dialmodes')); | 93 | Route::post('dialmodeassign', array('uses'=> 'DialModeController@dialmodeassign', 'as'=>'assign.dialmodes')); |
| 94 | //for the rlp pbwise | ||
| 95 | Route::get('rlp', array('uses'=> 'RecordController@rlpPbwise', 'as'=>'rlppb.comments')); | ||
| 94 | 96 | ||
| 95 | }); | 97 | }); | ... | ... |
| ... | @@ -584,6 +584,19 @@ $data.="</div><div style='width:49%;float:left'> | ... | @@ -584,6 +584,19 @@ $data.="</div><div style='width:49%;float:left'> |
| 584 | <label class=label-small_new style='width:25%;' title=''>Call Remarks:</label> | 584 | <label class=label-small_new style='width:25%;' title=''>Call Remarks:</label> |
| 585 | <textarea id='dialer_fullremarks' name='fullremarks' style='width:70%' maxlength=4000></textarea> | 585 | <textarea id='dialer_fullremarks' name='fullremarks' style='width:70%' maxlength=4000></textarea> |
| 586 | </p>"; | 586 | </p>"; |
| 587 | $attemptsval=""; | ||
| 588 | |||
| 589 | for($i=1;$i<=50;$i++) | ||
| 590 | { | ||
| 591 | $attemptsval.="<option value='".$i."'>".$i."</option>"; | ||
| 592 | } | ||
| 593 | |||
| 594 | $data.="<p style='clear:both'> | ||
| 595 | <label class=label-small_new style='width:25%;' title=''>Attempts: </label> | ||
| 596 | <select class='form_hrm_select' id='attempt' name='attempt' style='width:50%'>'".$attemptsval."' | ||
| 597 | </select> | ||
| 598 | </p>"; | ||
| 599 | |||
| 587 | 600 | ||
| 588 | //Supervisor Comments - By Manish on 16/02/17 | 601 | //Supervisor Comments - By Manish on 16/02/17 |
| 589 | /*if($dataarr['clientcode']) | 602 | /*if($dataarr['clientcode']) | ... | ... |
| 1 | var loggedin=0; | ||
| 2 | |||
| 3 | var sTransferNumber; | ||
| 4 | var oRingTone, oRingbackTone; | ||
| 5 | var oSipStack, oSipSessionRegister, oSipSessionCall, oSipSessionTransferCall; | ||
| 6 | var videoRemote, videoLocal, audioRemote; | ||
| 7 | var bFullScreen = false; | ||
| 8 | var oNotifICall; | ||
| 9 | var bDisableVideo = false; | ||
| 10 | var viewLocalScreencast; // <video> (webrtc) or <div> (webrtc4all) | ||
| 11 | var oConfigCall; | ||
| 12 | var oReadyStateTimer; | ||
| 13 | |||
| 14 | var divVideo, divCallOptions; | ||
| 15 | var hangupgrowl=0; | ||
| 16 | var answergrowl=0; | ||
| 17 | var txtDisplayName, txtPrivateIdentity, txtPublicIdentity, txtRealm; | ||
| 18 | var txtPhoneNumber; | ||
| 19 | var btnCall, btnHangUp; | ||
| 20 | var txtRegStatus, txtCallStatus; | ||
| 21 | var btnRegister, btnUnRegister; | ||
| 22 | var btnFullScreen, btnHoldResume, btnTransfer, btnKeyPad; | ||
| 23 | |||
| 24 | |||
| 25 | var kstychDialer={}; | ||
| 26 | kstychDialer['mDialerState']='Paused'; | ||
| 27 | kstychDialer['mDialerSubState']='NotReady'; | ||
| 28 | kstychDialer['mDialerCampaign']=''; | ||
| 29 | kstychDialer['mdispodata']=''; | ||
| 30 | kstychDialer['mDialNextStatus']='New'; | ||
| 31 | kstychDialer['mmanualallow']='No'; | ||
| 32 | kstychDialer['pendingDataSize']=0; | ||
| 33 | kstychDialer['phone']=kstychAppObject['user']['sipid']; | ||
| 34 | kstychDialer['connection']={'number':'1000'+kstychAppObject['user']['sipid'],'connected':0,'mic':1,'speaker':1,'channel':'','holdext':''}; | ||
| 35 | kstychDialer["keeplocalconf"]=kstychAppObject['config']['kDialer_keeplocalconf']; | ||
| 36 | kstychDialer['RedialLast']=''; | ||
| 37 | |||
| 38 | var kstychCall={}; | ||
| 39 | kstychCall['mCallState']='Wait'; //states : ,Wait,Call,Dispo,Close | ||
| 40 | kstychCall['ts_Wait']=getNowTS(); | ||
| 41 | kstychCall['ts_Call']=0; | ||
| 42 | kstychCall['ts_Talk']=0; | ||
| 43 | kstychCall['ts_Dispo']=0; | ||
| 44 | kstychCall['ts_Close']=0; | ||
| 45 | kstychCall['callnumber']=''; | ||
| 46 | kstychCall['connections']={}; | ||
| 47 | kstychCall['callid']=''; | ||
| 48 | kstychCall['crmid']=''; | ||
| 49 | kstychCall['campaignid']=''; | ||
| 50 | kstychCall['listid']=''; | ||
| 51 | kstychCall['mdial_CallACK']=0; | ||
| 52 | kstychCall['mcalldata']=''; | ||
| 53 | kstychCall['userstatus']=''; | ||
| 54 | kstychCall['usersubstatus']=''; | ||
| 55 | kstychCall['usercallback']=''; | ||
| 56 | kstychCall['userremarks']=''; | ||
| 57 | kstychCall['agentcomments']=''; | ||
| 58 | kstychCall['supcomntid']=''; | ||
| 59 | kstychCall['userdata']={}; | ||
| 60 | kstychCall['previewcrmid']=''; | ||
| 61 | kstychCall['callWrapupTime']=300; | ||
| 62 | kstychCall['prograssiveDelay']=120; | ||
| 63 | kstychCall['ts_now']=0; | ||
| 64 | |||
| 65 | kstychCall['bttc_day']=''; | ||
| 66 | kstychCall['bttc_hrs']=''; | ||
| 67 | kstychCall['serv_vs_prod']=''; | ||
| 68 | kstychCall['resolution']=''; | ||
| 69 | kstychCall['satisfy']=''; | ||
| 70 | kstychCall['final_call_assess']=''; | ||
| 71 | |||
| 72 | function kGetDData(obj,key) | ||
| 73 | { | ||
| 74 | if(obj=="D") | ||
| 75 | { | ||
| 76 | if(kstychDialer[key])return kstychDialer[key]; | ||
| 77 | } | ||
| 78 | if(obj=="C") | ||
| 79 | { | ||
| 80 | if(kstychCall[key])return kstychCall[key]; | ||
| 81 | } | ||
| 82 | return false; | ||
| 83 | } | ||
| 84 | function kSetDData(obj,key,val) | ||
| 85 | { | ||
| 86 | if(obj=="D") | ||
| 87 | { | ||
| 88 | kstychDialer[key]=val; | ||
| 89 | } | ||
| 90 | if(obj=="C") | ||
| 91 | { | ||
| 92 | kstychCall[key]=val; | ||
| 93 | } | ||
| 94 | |||
| 95 | //TODO update backend user session (userlog) | ||
| 96 | return false; | ||
| 97 | } | ||
| 98 | |||
| 99 | function getNowTS() | ||
| 100 | { | ||
| 101 | return Math.floor(Date.now()); | ||
| 102 | } | ||
| 103 | |||
| 104 | function kcallNewConnection(number) | ||
| 105 | { | ||
| 106 | var clines=kGetDData('C','connections'); | ||
| 107 | if(!clines[number]) | ||
| 108 | { | ||
| 109 | clines[number]={}; | ||
| 110 | clines[number]['connected']=0; | ||
| 111 | clines[number]['channel']=''; | ||
| 112 | clines[number]['callid']=''; | ||
| 113 | clines[number]['ts_Call']=0; | ||
| 114 | clines[number]['ts_Talk']=0; | ||
| 115 | clines[number]['ts_Dispo']=0; | ||
| 116 | clines[number]['speaker']=1; | ||
| 117 | clines[number]['mic']=1; | ||
| 118 | clines[number]['holdext']=''; | ||
| 119 | kSetDData('C','connections',clines); | ||
| 120 | } | ||
| 121 | } | ||
| 122 | function kcallSetConnection(number,key,val) | ||
| 123 | { | ||
| 124 | kcallNewConnection(number); | ||
| 125 | var clines=kGetDData('C','connections'); | ||
| 126 | clines[number][key]=val; | ||
| 127 | kSetDData('C','connections',clines); | ||
| 128 | } | ||
| 129 | function kcallGetConnection(number,key) | ||
| 130 | { | ||
| 131 | kcallNewConnection(number); | ||
| 132 | var clines=kGetDData('C','connections'); | ||
| 133 | return clines[number][key]; | ||
| 134 | } | ||
| 135 | function kcallHasConnection(number) | ||
| 136 | { | ||
| 137 | var clines=kGetDData('C','connections'); | ||
| 138 | if(!clines[number])return false; | ||
| 139 | return true; | ||
| 140 | } | ||
| 141 | |||
| 142 | function dialerQuickOpen(varid,num,state,substate,autorun) | ||
| 143 | { | ||
| 144 | if(kstychCall['mCallState']=="Wait") | ||
| 145 | { | ||
| 146 | var oldpreviewid=kstychCall['previewcrmid']; | ||
| 147 | kstychCall['previewcrmid']=''; | ||
| 148 | kstychCall['callnumber']=''; | ||
| 149 | kstychCall['crmid']=''; | ||
| 150 | |||
| 151 | if(varid!=''&&varid>0) | ||
| 152 | { | ||
| 153 | if(num!=''&&num!='0') | ||
| 154 | { | ||
| 155 | kstychCall['callnumber']=num; | ||
| 156 | $("#manualdialnumber_txt").val(num); | ||
| 157 | } | ||
| 158 | |||
| 159 | if(oldpreviewid!=varid||state!=kstychDialer['mDialerState']) | ||
| 160 | { | ||
| 161 | kstychCall['previewcrmid']=varid;//progressiveDelay set to 1 //TODO | ||
| 162 | updateDialerState("dialer","mDialerState",state,"mDialerSubState",substate); | ||
| 163 | } | ||
| 164 | else | ||
| 165 | { | ||
| 166 | kstychCall['previewcrmid']=varid; | ||
| 167 | updateDialerState(); | ||
| 168 | } | ||
| 169 | kDialerModel(); | ||
| 170 | } | ||
| 171 | else | ||
| 172 | { | ||
| 173 | if(num!='') | ||
| 174 | { | ||
| 175 | $("#manualdialnumber_txt").val(num); | ||
| 176 | updateDialerState("dialer","mDialerState","Manual"); | ||
| 177 | kDialerModel(); | ||
| 178 | if(autorun==1)setTimeout(function(){$("#manualdial_btn").click()},350); | ||
| 179 | } | ||
| 180 | } | ||
| 181 | } | ||
| 182 | else | ||
| 183 | { | ||
| 184 | simpleNotification('error','topRight',"Already on call!"); | ||
| 185 | } | ||
| 186 | } | ||
| 187 | function dialerAddAlt(i,varid) | ||
| 188 | { | ||
| 189 | var phone=$("#dialer_altphone"+i).val(); | ||
| 190 | var desc=$("#dialer_altphone_lbl_"+i).val(); | ||
| 191 | |||
| 192 | if(!/^\d{10}$/.test(phone)&&!/^\d{11}$/.test(phone)) | ||
| 193 | { | ||
| 194 | simpleNotification('error','topRight',"Please enter 10 or 11 neumeric digits only"); | ||
| 195 | return; | ||
| 196 | } | ||
| 197 | if(desc=="") | ||
| 198 | { | ||
| 199 | simpleNotification('error','topRight',"Please enter number description"); | ||
| 200 | return; | ||
| 201 | } | ||
| 202 | |||
| 203 | if(phone!="") | ||
| 204 | { | ||
| 205 | var data="varid="+varid; | ||
| 206 | data+="&keys=altphone"+i+",altphone_lbl_"+i; | ||
| 207 | data+="&altphone"+i+"="+phone; | ||
| 208 | data+="&altphone_lbl_"+i+"="+desc; | ||
| 209 | |||
| 210 | doAjax('record?action=addkey',data,'dialersearchresults', 'ajax_manualdial','singlefail','POST', function(retstr){ | ||
| 211 | $("#dialersearchresults").html('<div id=divworking></div><div style="clear:both"></div>'); | ||
| 212 | showRecruit(varid); | ||
| 213 | }); | ||
| 214 | } | ||
| 215 | |||
| 216 | } | ||
| 217 | function dialerDelAlt(i,varid) | ||
| 218 | { | ||
| 219 | doAjax('record?action=delaltphone&i='+i+'&varid='+varid,'','dialersearchresults', 'ajax_manualdial','singlefail','POST', function(retstr){ | ||
| 220 | $("#dialersearchresults").html('<div id=divworking></div><div style="clear:both"></div>'); | ||
| 221 | showRecruit(varid); | ||
| 222 | }); | ||
| 223 | } | ||
| 224 | |||
| 225 | function kDialerSpy(sipid,fun) | ||
| 226 | { | ||
| 227 | var datastr="kstychCall="+JSON.stringify(kstychCall); | ||
| 228 | datastr+="&kstychDialer="+JSON.stringify(kstychDialer); | ||
| 229 | |||
| 230 | datastr+="&sipid="+sipid; | ||
| 231 | datastr+="&mode="+fun; | ||
| 232 | |||
| 233 | try{sipHangUp();}catch(e){console.log(e);} | ||
| 234 | doAjax('dialer?action=spychannel',datastr,'__fake__div__', 'ajax_spydial','singlefail','POST', function(retstr){ | ||
| 235 | |||
| 236 | }); | ||
| 237 | } | ||
| 238 | function kCallAction(num,action) | ||
| 239 | { | ||
| 240 | //action : MuteSpeaker,UnMuteSpeaker,MuteMic,UnMuteMic,Hangup,Hold,UnHold | ||
| 241 | if(num=="u") | ||
| 242 | { | ||
| 243 | if(action=="MuteMic")kstychDialer['connection']['mic']=sipToggleMute(); | ||
| 244 | if(action=="UnMuteMic")kstychDialer['connection']['mic']=sipToggleMute(); | ||
| 245 | if(action=="MuteSpeaker"); | ||
| 246 | if(action=="UnMuteSpeaker"); | ||
| 247 | if(action=="Hangup"); | ||
| 248 | //if(action=="Hold"); | ||
| 249 | //if(action=="UnHold"); | ||
| 250 | } | ||
| 251 | else | ||
| 252 | { | ||
| 253 | if(num=="c")num=kstychCall['callnumber']; | ||
| 254 | var channel=kcallGetConnection(num,'channel'); | ||
| 255 | if(channel!='') | ||
| 256 | { | ||
| 257 | if(action=="MuteMic")kcallSetConnection(num,'mic',0); | ||
| 258 | if(action=="UnMuteMic")kcallSetConnection(num,'mic',1); | ||
| 259 | if(action=="MuteSpeaker")kcallSetConnection(num,'speaker',0); | ||
| 260 | if(action=="UnMuteSpeaker")kcallSetConnection(num,'speaker',1); | ||
| 261 | if(action=="Hangup"); | ||
| 262 | //if(action=="Hold")kcallSetConnection(num,'holdext'); | ||
| 263 | //if(action=="UnHold")kcallSetConnection(num,'holdext'); | ||
| 264 | |||
| 265 | doAjax('dialer?action=kCallAction&actiontype='+action+'&conf='+kstychDialer['connection']['number']+'&channel='+channel,'','__fake__div__', 'ajax_confdial','singlefail','POST', function(retstr){ | ||
| 266 | |||
| 267 | }); | ||
| 268 | } | ||
| 269 | else simpleNotification('error','topRight',"No Channel for ["+num+"]"); | ||
| 270 | } | ||
| 271 | |||
| 272 | updateDialerState(); | ||
| 273 | } | ||
| 274 | |||
| 275 | function dialerDispNumberClick() | ||
| 276 | { | ||
| 277 | var lastnumber=$("#spandialer_num").html(); | ||
| 278 | |||
| 279 | if(kstychCall['mCallState']=="Dispo") | ||
| 280 | { | ||
| 281 | saveCloseDialerCall("REDIAL"); | ||
| 282 | } | ||
| 283 | } | ||
| 284 | function dialerAddConfCall() | ||
| 285 | { | ||
| 286 | var confnumber=$("#dialerConfNumberTxt").val(); | ||
| 287 | if(confnumber==''||confnumber.length<2) | ||
| 288 | { | ||
| 289 | simpleNotification('error','topRight',"Empty Number"); | ||
| 290 | return; | ||
| 291 | } | ||
| 292 | |||
| 293 | if(!kcallHasConnection(kstychCall['callnumber'])||kstychCall['ts_Dispo']>1) | ||
| 294 | { | ||
| 295 | simpleNotification('error','topRight',"No call to conference"); | ||
| 296 | return; | ||
| 297 | } | ||
| 298 | |||
| 299 | var datastr="kstychCall="+JSON.stringify(kstychCall); | ||
| 300 | datastr+="&kstychDialer="+JSON.stringify(kstychDialer); | ||
| 301 | |||
| 302 | kcallNewConnection(confnumber); | ||
| 303 | doAjax('dialer?action=addconfcall&confnumber='+confnumber,datastr,'__fake__div__', 'ajax_confdial','singlefail','POST', function(retstr){ | ||
| 304 | if(retstr.responseText.indexOf('Error')<0) | ||
| 305 | { | ||
| 306 | kcallSetConnection(confnumber,'callid',retstr.responseText); | ||
| 307 | kcallSetConnection(confnumber,'ts_Call',getNowTS()); | ||
| 308 | |||
| 309 | updateDialerState(); | ||
| 310 | } | ||
| 311 | else | ||
| 312 | { | ||
| 313 | simpleNotification('error','topRight',retstr.responseText); | ||
| 314 | } | ||
| 315 | }); | ||
| 316 | } | ||
| 317 | |||
| 318 | function incomingCall(calllog,crmid,number) | ||
| 319 | { | ||
| 320 | $("#dialersearchresults").html('<div id=divworking></div><div style="clear:both"></div>'); | ||
| 321 | |||
| 322 | kcallSetConnection(number,'callid',calllog); | ||
| 323 | kcallSetConnection(number,'connected',1); | ||
| 324 | |||
| 325 | kSetDData('C','callid',calllog); | ||
| 326 | kSetDData('C','crmid',crmid); | ||
| 327 | |||
| 328 | if(crmid>0)showRecruit(crmid); | ||
| 329 | else | ||
| 330 | { | ||
| 331 | createSearchRecordDiv('dialersearchresults'); | ||
| 332 | } | ||
| 333 | |||
| 334 | kSetDData('C','mCallState','Call'); | ||
| 335 | kSetDData('C','ts_Call',getNowTS()); | ||
| 336 | kSetDData('C','ts_Talk',getNowTS()); | ||
| 337 | |||
| 338 | kstychCall["callnumber"]=number; | ||
| 339 | |||
| 340 | updateDialerState(); | ||
| 341 | kDialerModel(); | ||
| 342 | } | ||
| 343 | |||
| 344 | function dialerUIUpdate(var1,var2,var3) | ||
| 345 | { | ||
| 346 | var3parts=var3.split("~"); | ||
| 347 | var3parts[2]=atob(var3parts[2]); | ||
| 348 | if(var1=="dialstart") | ||
| 349 | { | ||
| 350 | if(var2=="c") | ||
| 351 | { | ||
| 352 | if(var3parts[1]&&var3parts[1]!="") | ||
| 353 | { | ||
| 354 | kcallSetConnection(var3parts[1],'connected',1); | ||
| 355 | kcallSetConnection(var3parts[1],'channel',var3parts[2]); | ||
| 356 | kcallSetConnection(var3parts[1],'ts_Call',getNowTS()); | ||
| 357 | if(var3parts[1]==kstychCall['callnumber'])kSetDData('C','ts_Call',getNowTS()); | ||
| 358 | |||
| 359 | updateDialerState(); | ||
| 360 | } | ||
| 361 | } | ||
| 362 | else if(var2=="u") | ||
| 363 | { | ||
| 364 | var dialerConnection=kGetDData("D","connection"); | ||
| 365 | dialerConnection['channel']=var3parts[2]; | ||
| 366 | kSetDData("D","connection",dialerConnection); | ||
| 367 | } | ||
| 368 | } | ||
| 369 | |||
| 370 | if(var1=="dialend") | ||
| 371 | { | ||
| 372 | if(var2=="c") | ||
| 373 | { | ||
| 374 | if(var3parts[1]&&var3parts[1]!="") | ||
| 375 | { | ||
| 376 | kcallSetConnection(var3parts[1],'connected',1); | ||
| 377 | kcallSetConnection(var3parts[1],'channel',var3parts[2]); | ||
| 378 | kcallSetConnection(var3parts[1],'ts_Talk',getNowTS()); | ||
| 379 | if(var3parts[1]==kstychCall['callnumber'])kSetDData('C','ts_Talk',getNowTS()); | ||
| 380 | |||
| 381 | updateDialerState(); | ||
| 382 | } | ||
| 383 | } | ||
| 384 | } | ||
| 385 | |||
| 386 | if(var1=="hangup") | ||
| 387 | { | ||
| 388 | if(var2=="c") | ||
| 389 | { | ||
| 390 | if(var3parts[1]&&var3parts[1]!="") | ||
| 391 | { | ||
| 392 | kcallSetConnection(var3parts[1],'connected',0); | ||
| 393 | if(kcallGetConnection(var3parts[1],'ts_Call')==0)kcallSetConnection(var3parts[1],'ts_Call',getNowTS()); | ||
| 394 | if(kcallGetConnection(var3parts[1],'ts_Talk')==0)kcallSetConnection(var3parts[1],'ts_Talk',getNowTS()); | ||
| 395 | kcallSetConnection(var3parts[1],'ts_Dispo',getNowTS()); | ||
| 396 | |||
| 397 | if(var3parts[1]==kstychCall['callnumber']) | ||
| 398 | { | ||
| 399 | if(kstychCall['ts_Call']==0)kSetDData('C','ts_Call',getNowTS()); | ||
| 400 | if(kstychCall['ts_Talk']==0)kSetDData('C','ts_Talk',getNowTS()); | ||
| 401 | |||
| 402 | kSetDData('C','ts_Dispo',getNowTS()); | ||
| 403 | hangupCall(); | ||
| 404 | } | ||
| 405 | |||
| 406 | updateDialerState(); | ||
| 407 | } | ||
| 408 | } | ||
| 409 | } | ||
| 410 | } | ||
| 411 | |||
| 412 | function incomingPopupAlert(var1,var2,var3) | ||
| 413 | { | ||
| 414 | //var incomingnotify=growlSNotify(var1,var2,"top-right"); | ||
| 415 | //setTimeout(function(){$.gritter.remove(incomingnotify, {fade: true,speed: 'slow'});incomingnotify=0;},1500); | ||
| 416 | |||
| 417 | $.titleAlert(var1+" "+var2, { | ||
| 418 | requireBlur:true, | ||
| 419 | stopOnFocus:true, | ||
| 420 | duration:1500, | ||
| 421 | interval:500 | ||
| 422 | }); | ||
| 423 | |||
| 424 | kDesktopNotification("",var1,var2,1500); | ||
| 425 | } | ||
| 426 | |||
| 427 | function outgoingCall() | ||
| 428 | { | ||
| 429 | $("#dialersearchresults").html(""); | ||
| 430 | kSetDData('C','callnumber',$("#manualdialnumber_txt").val()); | ||
| 431 | |||
| 432 | var datastr="kstychCall="+JSON.stringify(kstychCall); | ||
| 433 | datastr+="&kstychDialer="+JSON.stringify(kstychDialer); | ||
| 434 | |||
| 435 | if(kstychDialer['mDialerState']=="Manual") | ||
| 436 | { | ||
| 437 | if(kstychCall['callnumber']!="") | ||
| 438 | { | ||
| 439 | doAjax('dialer?action=newcall',datastr,'dialersearchresults', 'ajax_manualdial','singlefail','POST', function(retstr){ | ||
| 440 | if(kstychCall['crmid']!="") | ||
| 441 | { | ||
| 442 | kSetDData('C','mCallState','Call'); | ||
| 443 | kSetDData('C','ts_Call',getNowTS()); | ||
| 444 | |||
| 445 | if(kstychCall['crmid']==0) | ||
| 446 | { | ||
| 447 | createSearchRecordDiv('dialersearchresults'); | ||
| 448 | } | ||
| 449 | updateDialerState(); | ||
| 450 | } | ||
| 451 | else | ||
| 452 | { | ||
| 453 | kSetDData('C','previewcrmid',''); | ||
| 454 | updateDialerState("dialer","mDialerState","Manual"); | ||
| 455 | } | ||
| 456 | }); | ||
| 457 | } | ||
| 458 | else | ||
| 459 | { | ||
| 460 | simpleNotification('error','topRight',"Empty Number"); | ||
| 461 | } | ||
| 462 | } | ||
| 463 | if(kstychDialer['mDialerState']=="DialNext") | ||
| 464 | { | ||
| 465 | doAjax('dialer?action=newcall',datastr,'dialersearchresults', 'ajax_manualdial','singlefail','POST', function(retstr){ | ||
| 466 | if(kstychCall['crmid']!="") | ||
| 467 | { | ||
| 468 | kSetDData('C','mCallState','Call'); | ||
| 469 | kSetDData('C','ts_Call',getNowTS()); | ||
| 470 | |||
| 471 | updateDialerState(); | ||
| 472 | } | ||
| 473 | else | ||
| 474 | { | ||
| 475 | simpleNotification('error','topRight',"Failed to Dial Next ["+kstychDialer['mDialNextStatus']+"] Record"); | ||
| 476 | |||
| 477 | kSetDData('C','previewcrmid',''); | ||
| 478 | updateDialerState("dialer","mDialerState","DialNext"); | ||
| 479 | } | ||
| 480 | }); | ||
| 481 | } | ||
| 482 | if(kstychDialer['mDialerState']=="Progressive") | ||
| 483 | { | ||
| 484 | doAjax('dialer?action=newcall',datastr,'dialersearchresults', 'ajax_manualdial','singlefail','POST', function(retstr){ | ||
| 485 | if(kstychCall['crmid']!="") | ||
| 486 | { | ||
| 487 | kSetDData('C','mCallState','Call'); | ||
| 488 | kSetDData('C','ts_Call',getNowTS()); | ||
| 489 | |||
| 490 | updateDialerState(); | ||
| 491 | } | ||
| 492 | else | ||
| 493 | { | ||
| 494 | simpleNotification('error','topRight',"Failed to Dial Next ["+kstychDialer['mDialNextStatus']+"] Record"); | ||
| 495 | //Cleanup? | ||
| 496 | |||
| 497 | kSetDData('C','previewcrmid',''); | ||
| 498 | updateDialerState("dialer","mDialerState","DialNext"); | ||
| 499 | } | ||
| 500 | }); | ||
| 501 | } | ||
| 502 | |||
| 503 | |||
| 504 | //check if current state is valid to make a call | ||
| 505 | //prepare ajax parameters | ||
| 506 | //call dialer controller to submit request | ||
| 507 | //check return values for success | ||
| 508 | //update dialer and call objects | ||
| 509 | } | ||
| 510 | function hangupCall() | ||
| 511 | { | ||
| 512 | kstychCall['ts_now']=getNowTS(); | ||
| 513 | |||
| 514 | var datastr="kstychCall="+JSON.stringify(kstychCall); | ||
| 515 | datastr+="&kstychDialer="+JSON.stringify(kstychDialer); | ||
| 516 | doAjax('dialer?action=hangupall',datastr,'', 'ajax_manualdial','singlefail','POST', | ||
| 517 | function(retstr){ | ||
| 518 | |||
| 519 | if(retstr.responseText.indexOf('Error')<0) | ||
| 520 | { | ||
| 521 | kSetDData('C','mCallState',"Dispo"); | ||
| 522 | kSetDData('C','ts_Dispo',getNowTS()); | ||
| 523 | |||
| 524 | if(kstychDialer["keeplocalconf"]==0) | ||
| 525 | { | ||
| 526 | try{sipHangUp();}catch(e){console.log(e);} | ||
| 527 | var dialerConnection=kGetDData("D","connection"); | ||
| 528 | dialerConnection['connected']=0; | ||
| 529 | dialerConnection['channel']=''; | ||
| 530 | updateDialerState("dialer","connection",dialerConnection); | ||
| 531 | } | ||
| 532 | else updateDialerState(); | ||
| 533 | } | ||
| 534 | else | ||
| 535 | { | ||
| 536 | simpleNotification('error','topRight',retstr.responseText); | ||
| 537 | updateDialerState(); | ||
| 538 | } | ||
| 539 | }); | ||
| 540 | } | ||
| 541 | function saveCloseDialerCall(flag) | ||
| 542 | { | ||
| 543 | kstychCall['userstatus']=$('#dialer_userstatus').val(); | ||
| 544 | kstychCall['usersubstatus']=$('#dialer_usersubstatus').val(); | ||
| 545 | kstychCall['usercallback']=$('#dialer_usercallback').val(); | ||
| 546 | kstychCall['userremarks']=$('#dialer_userremarks').val(); | ||
| 547 | kstychCall['userflag']=$('#dialer_flag').val(); | ||
| 548 | kstychCall['priority']=$('#priority').val(); | ||
| 549 | |||
| 550 | kstychCall['bttc_day']=$('#bttc_day').val(); | ||
| 551 | kstychCall['bttc_hrs']=$('#bttc_hrs').val(); | ||
| 552 | kstychCall['serv_vs_prod']=$('#serv_vs_prod').val(); | ||
| 553 | kstychCall['resolution']=$('#resolution').val(); | ||
| 554 | kstychCall['satisfy']=$('#satisfy').val(); | ||
| 555 | kstychCall['final_call_assess']=$('#final_call_assess').val(); | ||
| 556 | |||
| 557 | //Supervisor Call Management Value - By Manish on 16-02-17 | ||
| 558 | kstychCall['agentcomments']=$('#agent_comment').val(); | ||
| 559 | kstychCall['supcomntid']=$('#sup_comnt_id').val(); | ||
| 560 | |||
| 561 | if(typeof customerDispofields != 'undefined')kstychCall['userdata']=customerDispofields; | ||
| 562 | |||
| 563 | if(flag=="AUTOWRAPUP") | ||
| 564 | { | ||
| 565 | kstychCall['userstatus']="AUTOWRAPUP"; | ||
| 566 | kstychCall['usersubstatus']="AUTOWRAPUP"; | ||
| 567 | $('#dialer_usercallback').val(""); | ||
| 568 | kstychCall['usercallback']=""; | ||
| 569 | kstychCall['userremarks']=""; | ||
| 570 | kstychCall['userflag']=""; | ||
| 571 | } | ||
| 572 | else if(flag=="REDIAL") | ||
| 573 | { | ||
| 574 | kstychCall['userstatus']="REDIAL"; | ||
| 575 | kstychCall['usersubstatus']="REDIAL"; | ||
| 576 | $('#dialer_usercallback').val(""); | ||
| 577 | kstychCall['usercallback']=""; | ||
| 578 | kstychCall['userremarks']=""; | ||
| 579 | kstychCall['userflag']=""; | ||
| 580 | |||
| 581 | kstychDialer['RedialLast']='Yes'; | ||
| 582 | } | ||
| 583 | else if(!$('#dialer_userstatus').length) | ||
| 584 | { | ||
| 585 | kstychCall['userstatus']="NORECORD"; | ||
| 586 | kstychCall['usersubstatus']="NORECORD"; | ||
| 587 | kstychCall['usercallback']=""; | ||
| 588 | kstychCall['userremarks']=""; | ||
| 589 | kstychCall['userflag']=""; | ||
| 590 | |||
| 591 | $('#dialer_usercallback').val(""); | ||
| 592 | } | ||
| 593 | else | ||
| 594 | { | ||
| 595 | |||
| 596 | |||
| 597 | if(kstychCall['userstatus']==""||kstychCall['usersubstatus']=="") | ||
| 598 | { | ||
| 599 | simpleNotification('error','topRight',"Please Select Disposition and Subdisposition"); | ||
| 600 | return; | ||
| 601 | } | ||
| 602 | |||
| 603 | //For $ dropdown Condition - Changes done By Manish on 27-10-16 | ||
| 604 | /*if(kstychCall['userstatus']=="Contacted - FollowUp - Specific" || kstychCall['userstatus']=="Contacted - Follow-Up - Generic") | ||
| 605 | { | ||
| 606 | if(kstychCall['final_call_assess']==""&&kstychCall['serv_vs_prod']==""&&kstychCall['resolution']==""&&kstychCall['satisfy']=="") | ||
| 607 | { | ||
| 608 | simpleNotification('Error','topRight',"Please Select ALL(Service vs Product and Resolution and Satisfaction and Final_call_Assessment)"); | ||
| 609 | return; | ||
| 610 | } | ||
| 611 | }*/ | ||
| 612 | |||
| 613 | if(kstychCall['userstatus'].toLowerCase().indexOf("followup")>-1||kstychCall['userstatus'].toLowerCase().indexOf("callback")>-1) | ||
| 614 | { | ||
| 615 | if($('#dialer_usercallback').val()=="") | ||
| 616 | { | ||
| 617 | simpleNotification('error','topRight',"Please select Callback date within one month in future"); | ||
| 618 | return; | ||
| 619 | } | ||
| 620 | } | ||
| 621 | else | ||
| 622 | { | ||
| 623 | if($('#dialer_usercallback').val()!="") | ||
| 624 | { | ||
| 625 | simpleNotification('error','topRight',"You Cannot input Callback date time in this Disposition"); | ||
| 626 | return; | ||
| 627 | } | ||
| 628 | } | ||
| 629 | |||
| 630 | |||
| 631 | var date1 = new Date(); | ||
| 632 | var date2 = new Date($('#dialer_usercallback').val()); | ||
| 633 | var diff = date2.getTime() - date1.getTime(); | ||
| 634 | if(diff<0||diff>30*24*60*60*1000) | ||
| 635 | { | ||
| 636 | simpleNotification('error','topRight',"Please select Callback date within one month in future"); | ||
| 637 | return; | ||
| 638 | } | ||
| 639 | var hours = date2.getHours(); | ||
| 640 | var mins = date2.getMinutes(); | ||
| 641 | var fullhour=hours+(mins/60); | ||
| 642 | if(fullhour<9||fullhour>19) | ||
| 643 | { | ||
| 644 | simpleNotification('error','topRight',"Please select Callback Time date within 9AM and 7PM"); | ||
| 645 | return; | ||
| 646 | } | ||
| 647 | |||
| 648 | } | ||
| 649 | |||
| 650 | if($("#recruitsavedata").length)$("#recruitsavedata").click();//TODO hold div in reset, or any error will be lost | ||
| 651 | |||
| 652 | var datastr="kstychCall="+JSON.stringify(kstychCall); | ||
| 653 | datastr+="&kstychDialer="+JSON.stringify(kstychDialer); | ||
| 654 | doAjax('dialer?action=closecall',datastr,'', 'ajax_manualdial','singlefail','POST', | ||
| 655 | function(retstr){ | ||
| 656 | kSetDData('C','mCallState',"Close"); | ||
| 657 | kSetDData('C','ts_Close',getNowTS()); | ||
| 658 | updateDialerState("action","reset",""); | ||
| 659 | }); | ||
| 660 | |||
| 661 | //Dialog box after Save & Close-Taking from KFormLib.php | ||
| 662 | $finalCallAssess = $('#final_call_assess').val(); | ||
| 663 | |||
| 664 | if($finalCallAssess == 'Very Good Call With Customer') | ||
| 665 | { | ||
| 666 | /*$.gritter.add({ | ||
| 667 | title: 'type', | ||
| 668 | text: 'text', | ||
| 669 | class_name: 'gritter-b-center' | ||
| 670 | });*/ | ||
| 671 | $('#goodCall').dialog({ | ||
| 672 | modal: true, | ||
| 673 | position: ['center'], | ||
| 674 | resizable: false, | ||
| 675 | closeOnEscape: false, | ||
| 676 | open: function(event, ui){ | ||
| 677 | $(".ui.dialog-titlebar-close", ui.dialog | ui).hide(); | ||
| 678 | setTimeout(function(){$('#goodCall').dialog('close');},5000); | ||
| 679 | } | ||
| 680 | }); | ||
| 681 | |||
| 682 | //setTimeout(function(){$('#goodCall').dialog('close');},5000); | ||
| 683 | } | ||
| 684 | |||
| 685 | if($finalCallAssess == 'Ok Call') | ||
| 686 | { | ||
| 687 | $('#okCall').dialog({ | ||
| 688 | open: function(event, ui){ | ||
| 689 | $(this).css({'max-height':500, 'overflow-y':'auto'}); | ||
| 690 | }, | ||
| 691 | modal: true, | ||
| 692 | position: ['center'], | ||
| 693 | resizable: false, | ||
| 694 | closeOnEscape: false}); | ||
| 695 | |||
| 696 | setTimeout(function(){$('#okCall').dialog('close');},5000); | ||
| 697 | } | ||
| 698 | |||
| 699 | if($finalCallAssess == 'Not Interested Customer') | ||
| 700 | { | ||
| 701 | $('#notInterest').dialog({ | ||
| 702 | open: function(event, ui){ | ||
| 703 | $(this).css({'max-height':500, 'overflow-y':'auto'}); | ||
| 704 | }, | ||
| 705 | modal: true, | ||
| 706 | position: ['center'], | ||
| 707 | resizable: false, | ||
| 708 | closeOnEscape: false}); | ||
| 709 | |||
| 710 | setTimeout(function(){$('#notInterest').dialog('close');},5000); | ||
| 711 | } | ||
| 712 | |||
| 713 | if($finalCallAssess == 'Iritated Customer') | ||
| 714 | { | ||
| 715 | $('#iritCust').dialog({ | ||
| 716 | open: function(event, ui){ | ||
| 717 | $(this).css({'max-height':500, 'overflow-y':'auto'}); | ||
| 718 | }, | ||
| 719 | modal: true, | ||
| 720 | position: ['center'], | ||
| 721 | resizable: false, | ||
| 722 | closeOnEscape: false}); | ||
| 723 | |||
| 724 | setTimeout(function(){$('#iritCust').dialog('close');},5000); | ||
| 725 | } | ||
| 726 | |||
| 727 | if($finalCallAssess == 'Angry') | ||
| 728 | { | ||
| 729 | $('#angry').dialog({ | ||
| 730 | open: function(event, ui){ | ||
| 731 | $(this).css({'max-height':500, 'overflow-y':'auto'}); | ||
| 732 | }, | ||
| 733 | modal: true, | ||
| 734 | position: ['center'], | ||
| 735 | resizable: false, | ||
| 736 | closeOnEscape: false}); | ||
| 737 | |||
| 738 | setTimeout(function(){$('#angry').dialog('close');},5000); | ||
| 739 | } | ||
| 740 | } | ||
| 741 | |||
| 742 | function showWrapUp() | ||
| 743 | { | ||
| 744 | kstychCall['userstatus']="Paused"; | ||
| 745 | kstychCall['usersubstatus']="WRAPUP"; | ||
| 746 | $('#dialer_usercallback').val(""); | ||
| 747 | kstychCall['usercallback']=""; | ||
| 748 | kstychCall['userremarks']=""; | ||
| 749 | kstychCall['userflag']=""; | ||
| 750 | |||
| 751 | var datastr="kstychCall="+JSON.stringify(kstychCall); | ||
| 752 | datastr+="&kstychDialer="+JSON.stringify(kstychDialer); | ||
| 753 | doAjax('dialer?action=wrapup',datastr,'', 'ajax_manualdial','singlefail','POST', | ||
| 754 | function(retstr){ | ||
| 755 | dialerTimersUpdate(); | ||
| 756 | }); | ||
| 757 | } | ||
| 758 | |||
| 759 | function resetDialer() | ||
| 760 | { | ||
| 761 | if(kstychDialer['RedialLast']=="Yes") | ||
| 762 | { | ||
| 763 | kstychDialer['RedialLast']=''; | ||
| 764 | |||
| 765 | kSetDData('C','mCallState',"Wait"); | ||
| 766 | kSetDData('C','ts_Wait',getNowTS()); | ||
| 767 | kSetDData('C','ts_Call',0); | ||
| 768 | kSetDData('C','ts_Talk',0); | ||
| 769 | kSetDData('C','ts_Dispo',0); | ||
| 770 | kSetDData('C','ts_Close',0); | ||
| 771 | |||
| 772 | updateDialerState("action","dialnext"); | ||
| 773 | |||
| 774 | return; | ||
| 775 | } | ||
| 776 | |||
| 777 | |||
| 778 | var dialerResetForceState=kstychDialer['mDialerState']; | ||
| 779 | var dialerResetForceSubState=kstychDialer['mDialerSubState']; | ||
| 780 | |||
| 781 | dialerResetForceState="Progressive";//Hardcoded TODO change to config | ||
| 782 | dialerResetForceSubState=""; | ||
| 783 | |||
| 784 | if(kstychCall['userstatus']=="AUTOWRAPUP") | ||
| 785 | { | ||
| 786 | dialerResetForceState="Paused"; | ||
| 787 | dialerResetForceSubState="AUTOWRAPUP"; | ||
| 788 | } | ||
| 789 | |||
| 790 | if(kstychCall['userstatus']=="WRAPUP") | ||
| 791 | { | ||
| 792 | dialerResetForceState="Paused"; | ||
| 793 | dialerResetForceSubState="WRAPUP"; | ||
| 794 | } | ||
| 795 | |||
| 796 | //TODO check hangup any connections? | ||
| 797 | |||
| 798 | $("#dialersearchresults").html("");//CANNOT clear this until we have a solution of error handling in save form | ||
| 799 | $("#manualdialnumber_txt").val(""); | ||
| 800 | |||
| 801 | resetCallArray(); | ||
| 802 | |||
| 803 | $("#dialersearchbox").html(""); | ||
| 804 | $(".dialer_conf_divs").remove(); | ||
| 805 | |||
| 806 | updateDialerState("dialer","mDialerState",dialerResetForceState,"mDialerSubState",dialerResetForceSubState); | ||
| 807 | |||
| 808 | } | ||
| 809 | function resetCallArray() | ||
| 810 | { | ||
| 811 | kSetDData('C','mCallState',"Wait"); | ||
| 812 | kSetDData('C','ts_Wait',getNowTS()); | ||
| 813 | kSetDData('C','ts_Call',0); | ||
| 814 | kSetDData('C','ts_Talk',0); | ||
| 815 | kSetDData('C','ts_Dispo',0); | ||
| 816 | kSetDData('C','ts_Close',0); | ||
| 817 | kSetDData('C','callnumber',""); | ||
| 818 | kSetDData('C','connections',{}); | ||
| 819 | kSetDData('C','callid',""); | ||
| 820 | kSetDData('C','crmid',""); | ||
| 821 | kSetDData('C','campaignid',""); | ||
| 822 | kSetDData('C','listid',""); | ||
| 823 | kSetDData('C','mdial_CallACK',""); | ||
| 824 | kSetDData('C','mcalldata',""); | ||
| 825 | |||
| 826 | kSetDData('C','userstatus',""); | ||
| 827 | kSetDData('C','usersubstatus',""); | ||
| 828 | kSetDData('C','usercallback',""); | ||
| 829 | kSetDData('C','userremarks',""); | ||
| 830 | kSetDData('C','agentcomments',""); | ||
| 831 | kSetDData('C','supcomntid',""); | ||
| 832 | kSetDData('C','userflag',""); | ||
| 833 | kSetDData('C','bttc_day',""); | ||
| 834 | kSetDData('C','bttc_hrs',""); | ||
| 835 | kSetDData('C','serv_vs_prod',""); | ||
| 836 | kSetDData('C','resolution',""); | ||
| 837 | kSetDData('C','satisfy',""); | ||
| 838 | kSetDData('C','final_call_assess',""); | ||
| 839 | kSetDData('C','userdata',{}); | ||
| 840 | if(typeof customerDispofields != 'undefined')customerDispofields={}; | ||
| 841 | |||
| 842 | kSetDData('C','previewcrmid',""); | ||
| 843 | kSetDData('C','callWrapupTime',300); | ||
| 844 | kSetDData('C','prograssiveDelay',120); | ||
| 845 | } | ||
| 846 | |||
| 847 | function updateDialerState(objstr,key,val,key2,val2) | ||
| 848 | { | ||
| 849 | if(objstr=="dialer") | ||
| 850 | { | ||
| 851 | kSetDData("D",key,val); | ||
| 852 | kSetDData("D",key2,val2); | ||
| 853 | if(key=='mDialerState') | ||
| 854 | { | ||
| 855 | if(!key2||key2=="")kSetDData("D","mDialerSubState",""); | ||
| 856 | |||
| 857 | if(val=="Paused") | ||
| 858 | { | ||
| 859 | resetCallArray(); | ||
| 860 | } | ||
| 861 | |||
| 862 | $("#dialersearchresults").html(""); | ||
| 863 | kSetDData('C','ts_Wait',getNowTS());//TODO reset here? | ||
| 864 | |||
| 865 | var datastr="kstychCall="+JSON.stringify(kstychCall); | ||
| 866 | datastr+="&kstychDialer="+JSON.stringify(kstychDialer); | ||
| 867 | doAjax('dialer?action=dialerstate',datastr,'', 'ajax_manualdial','singlefail','POST', | ||
| 868 | function(retstr){ | ||
| 869 | |||
| 870 | if(val=="Progressive"||(kstychCall['previewcrmid']!=""&&kstychCall['previewcrmid']>0)) | ||
| 871 | { | ||
| 872 | if(kstychCall['final_call_assess']=='' || kstychCall['final_call_assess']!=undefined){ | ||
| 873 | setTimeout(function(){doAjax('dialer?action=previewnext',datastr,'dialersearchresults', 'ajax_manualdial2','singlefail','POST', | ||
| 874 | function(retstr){ | ||
| 875 | if(kstychCall['previewcrmid']!="") | ||
| 876 | { | ||
| 877 | updateDialerState(); | ||
| 878 | } | ||
| 879 | else | ||
| 880 | { | ||
| 881 | resetCallArray(); | ||
| 882 | simpleNotification('error','topRight',"Failed to Dial Next Record"); | ||
| 883 | updateDialerState("dialer","mDialerState","DialNext"); | ||
| 884 | } | ||
| 885 | });},4000); | ||
| 886 | }else | ||
| 887 | { | ||
| 888 | doAjax('dialer?action=previewnext',datastr,'dialersearchresults', 'ajax_manualdial2','singlefail','POST', | ||
| 889 | function(retstr){ | ||
| 890 | if(kstychCall['previewcrmid']!="") | ||
| 891 | { | ||
| 892 | updateDialerState(); | ||
| 893 | } | ||
| 894 | else | ||
| 895 | { | ||
| 896 | resetCallArray(); | ||
| 897 | simpleNotification('error','topRight',"Failed to Dial Next Record"); | ||
| 898 | updateDialerState("dialer","mDialerState","DialNext"); | ||
| 899 | } | ||
| 900 | }); | ||
| 901 | } | ||
| 902 | |||
| 903 | } | ||
| 904 | |||
| 905 | updateDialerState(); | ||
| 906 | }); | ||
| 907 | } | ||
| 908 | } | ||
| 909 | if(objstr=="call") | ||
| 910 | { | ||
| 911 | kSetDData('C',key,val); | ||
| 912 | kSetDData("C",key2,val2); | ||
| 913 | } | ||
| 914 | |||
| 915 | if(objstr=="action") | ||
| 916 | { | ||
| 917 | if(key=="dialnext") | ||
| 918 | { | ||
| 919 | outgoingCall(); | ||
| 920 | } | ||
| 921 | if(key=="hangupall") | ||
| 922 | { | ||
| 923 | hangupCall(); | ||
| 924 | } | ||
| 925 | if(key=="saveclose") | ||
| 926 | { | ||
| 927 | saveCloseDialerCall(); | ||
| 928 | } | ||
| 929 | if(key=="reset") | ||
| 930 | { | ||
| 931 | resetDialer(); | ||
| 932 | } | ||
| 933 | } | ||
| 934 | |||
| 935 | updateDialerUI(); | ||
| 936 | ////////////////////////////////////////////////////////////// | ||
| 937 | if(objstr=="")return; | ||
| 938 | |||
| 939 | //$("#kTopBarExtra").parent().addClass("open"); | ||
| 940 | |||
| 941 | //run this function on every state change? | ||
| 942 | //take dialer and call objects and send to controller for update | ||
| 943 | } | ||
| 944 | function updateDialerUI() | ||
| 945 | { | ||
| 946 | $("#spandialer_num").html(kstychCall["callnumber"]); | ||
| 947 | if(kstychCall["callnumber"]!="")$("#dialertimes2").show(); | ||
| 948 | else $("#dialertimes2").hide(); | ||
| 949 | |||
| 950 | if($("#dialerManualAllowLI").length)kSetDData("D",'mmanualallow','Yes'); | ||
| 951 | |||
| 952 | ////////////////////////////////////////////////////////////// | ||
| 953 | var statestr="<i class='fa fa-phone'></i> : "+kstychDialer['mDialerState']; | ||
| 954 | if(kstychDialer['mDialerState']=="Paused")statestr="<i class='fa fa-pause'></i> : "+kstychDialer['mDialerSubState']; | ||
| 955 | if(kstychDialer['mDialerState']=="Ready")statestr="<i class='fa fa-phone'></i> : "+kstychDialer['mDialerSubState']; | ||
| 956 | $("#dialerstate_btn").html(statestr); | ||
| 957 | |||
| 958 | |||
| 959 | if(kstychDialer['mDialerState']=="Paused") | ||
| 960 | { | ||
| 961 | $("#dialerstate_div").width("150px"); | ||
| 962 | $("#manualdial_btn").hide();$("#manualdialnumber_txt").hide(); | ||
| 963 | $("#dialerstate_btn").parent().removeClass("rounded-left"); | ||
| 964 | $("#dialerstate_btn").parent().removeClass("btn-info").addClass("btn-primary"); | ||
| 965 | } | ||
| 966 | else if(kstychDialer['mDialerState']=="Ready") | ||
| 967 | { | ||
| 968 | $("#dialerstate_div").width("150px"); | ||
| 969 | $("#manualdial_btn").show();$("#manualdialnumber_txt").hide(); | ||
| 970 | $("#dialerstate_btn").parent().addClass("rounded-left"); | ||
| 971 | $("#dialerstate_btn").parent().removeClass("btn-primary").addClass("btn-info"); | ||
| 972 | } | ||
| 973 | else if(kstychDialer['mDialerState']=="Manual") | ||
| 974 | { | ||
| 975 | $("#dialerstate_div").width("350px"); | ||
| 976 | $("#manualdial_btn").show();$("#manualdialnumber_txt").show(); | ||
| 977 | $("#dialerstate_btn").parent().addClass("rounded-left"); | ||
| 978 | $("#dialerstate_btn").parent().removeClass("btn-primary").addClass("btn-info"); | ||
| 979 | } | ||
| 980 | else if(kstychDialer['mDialerState']=="DialNext") | ||
| 981 | { | ||
| 982 | $("#dialerstate_div").width("150px"); | ||
| 983 | $("#manualdial_btn").show();$("#manualdialnumber_txt").hide(); | ||
| 984 | $("#dialerstate_btn").parent().addClass("rounded-left"); | ||
| 985 | $("#dialerstate_btn").parent().removeClass("btn-primary").addClass("btn-info"); | ||
| 986 | } | ||
| 987 | else if(kstychDialer['mDialerState']=="Progressive") | ||
| 988 | { | ||
| 989 | $("#dialerstate_div").width("150px"); | ||
| 990 | $("#manualdial_btn").show();$("#manualdialnumber_txt").hide(); | ||
| 991 | $("#dialerstate_btn").parent().removeClass("rounded-left"); | ||
| 992 | $("#dialerstate_btn").parent().removeClass("btn-primary").addClass("btn-info"); | ||
| 993 | } | ||
| 994 | ////////////////////////////////////////////////////////////// | ||
| 995 | |||
| 996 | ////////////////////////////////////////////////////////////// | ||
| 997 | var uStateArr=[]; | ||
| 998 | uStateArr['conficon_u_a']='btn-primary';uStateArr['conficon_u_i']='fa-chain-broken'; | ||
| 999 | if(kstychDialer['connection']['connected']==1) | ||
| 1000 | { | ||
| 1001 | uStateArr['conficon_u_a']='btn-success';uStateArr['conficon_u_i']='fa-chain'; | ||
| 1002 | } | ||
| 1003 | uStateArr['mic']='UnMuteMic';uStateArr['micicon']='fa-microphone-slash'; | ||
| 1004 | if(kstychDialer['connection']['mic']==1) | ||
| 1005 | { | ||
| 1006 | uStateArr['mic']='MuteMic';uStateArr['micicon']='fa-microphone'; | ||
| 1007 | } | ||
| 1008 | |||
| 1009 | var calluhtml="<a data-toggle='dropdown' href='#' class='btn btn-stroke "+uStateArr['conficon_u_a']+" btn-circle dropdown-toggle' onmouseout='$(this).blur()' id=conficon_u_a><i class='fa "+uStateArr['conficon_u_i']+"' id=conficon_u_i></i> </a>"; | ||
| 1010 | calluhtml+="<ul class='dropdown-menu'>"; | ||
| 1011 | calluhtml+="<li data-toggle='tooltip' data-title='My Channel' data-placement='left' data-tcontainer='body'><a href='#' onclick='return false;'><i class='fa fa-info'></i></a></li>"; | ||
| 1012 | //calluhtml+="<li data-toggle='tooltip' data-title='MuteSpeaker' data-placement='left' data-tcontainer='body'><a href='#' onclick='kCallAction(\"u\",\"MuteSpeaker\");return false;'><i class='fa fa-volume-off'></i></a></li>"; | ||
| 1013 | calluhtml+="<li data-toggle='tooltip' data-title='"+uStateArr['mic']+"' data-placement='left' data-tcontainer='body'><a href='#' onclick='kCallAction(\"u\",\""+uStateArr['mic']+"\");return false;'><i class='fa "+uStateArr['micicon']+"'></i></a></li>"; | ||
| 1014 | //calluhtml+="<li data-toggle='tooltip' data-title='Hangup' data-placement='left' data-tcontainer='body'><a href='#' onclick='kCallAction(\"u\",\"Hangup\");return false;'><i class='fa fa-times-circle'></i></a></li>"; | ||
| 1015 | //calluhtml+="<li data-toggle='tooltip' data-title='Hold' data-placement='left' data-tcontainer='body'><a href='#' onclick='kCallAction(\"u\",\"Hold\");return false;'><i class='fa fa-pause'></i></a></li>"; | ||
| 1016 | calluhtml+="</ul>"; | ||
| 1017 | $("#connections_div_u").html(calluhtml); | ||
| 1018 | |||
| 1019 | $(".dialer_conf_divs").remove(); | ||
| 1020 | var confhtml=''; | ||
| 1021 | for(var key in kstychCall['connections']) | ||
| 1022 | { | ||
| 1023 | if(kstychCall['connections'].hasOwnProperty(key)) | ||
| 1024 | { | ||
| 1025 | if(key==kstychCall['callnumber']) | ||
| 1026 | { | ||
| 1027 | var cStateArr=[]; | ||
| 1028 | cStateArr['conficon_c0_a']='btn-primary';cStateArr['conficon_c0_i']='fa-chain-broken'; | ||
| 1029 | if(kstychCall['connections'][key]['connected']==1) | ||
| 1030 | { | ||
| 1031 | cStateArr['conficon_c0_a']='btn-success';cStateArr['conficon_c0_i']='fa-chain'; | ||
| 1032 | } | ||
| 1033 | cStateArr['mic']='UnMuteMic';cStateArr['micicon']='fa-microphone-slash'; | ||
| 1034 | if(kstychCall['connections'][key]['mic']==1) | ||
| 1035 | { | ||
| 1036 | cStateArr['mic']='MuteMic';cStateArr['micicon']='fa-microphone'; | ||
| 1037 | } | ||
| 1038 | cStateArr['speaker']='UnMuteSpeaker';cStateArr['speakericon']='fa-volume-off'; | ||
| 1039 | if(kstychCall['connections'][key]['speaker']==1) | ||
| 1040 | { | ||
| 1041 | cStateArr['speaker']='MuteSpeaker';cStateArr['speakericon']='fa-volume-up'; | ||
| 1042 | } | ||
| 1043 | cStateArr['holdext']='UnHold';cStateArr['holdexticon']='fa-play'; | ||
| 1044 | if(kstychCall['connections'][key]['holdext']=='') | ||
| 1045 | { | ||
| 1046 | cStateArr['holdext']='Hold';cStateArr['holdexticon']='fa-pause'; | ||
| 1047 | } | ||
| 1048 | |||
| 1049 | var callchtml="<a data-toggle='dropdown' href='#' class='btn btn-stroke "+cStateArr['conficon_c0_a']+" btn-circle dropdown-toggle' onmouseout='$(this).blur()' id=conficon_c0_a><i class='fa "+cStateArr['conficon_c0_i']+"' id=conficon_c0_i></i> </a>"; | ||
| 1050 | callchtml+="<ul class='dropdown-menu'>"; | ||
| 1051 | callchtml+="<li data-toggle='tooltip' data-title='"+key+"' data-placement='left' data-tcontainer='body'><a href='#' onclick='return false;'><i class='fa fa-info'></i></a></li>"; | ||
| 1052 | callchtml+="<li data-toggle='tooltip' data-title='"+cStateArr['speaker']+"' data-placement='left' data-tcontainer='body'><a href='#' onclick='kCallAction(\"c\",\""+cStateArr['speaker']+"\");return false;'><i class='fa "+cStateArr['speakericon']+"'></i></a></li>"; | ||
| 1053 | callchtml+="<li data-toggle='tooltip' data-title='"+cStateArr['mic']+"' data-placement='left' data-tcontainer='body'><a href='#' onclick='kCallAction(\"c\",\""+cStateArr['mic']+"\");return false;'><i class='fa "+cStateArr['micicon']+"'></i></a></li>"; | ||
| 1054 | callchtml+="<li data-toggle='tooltip' data-title='Hangup' data-placement='left' data-tcontainer='body'><a href='#' onclick='kCallAction(\"c\",\"Hangup\");return false;'><i class='fa fa-times-circle'></i></a></li>"; | ||
| 1055 | //callchtml+="<li data-toggle='tooltip' data-title='"+cStateArr['holdext']+"' data-placement='left' data-tcontainer='body'><a href='#' onclick='kCallAction(\"c\",\""+cStateArr['holdext']+"\");return false;'><i class='fa "+cStateArr['holdexticon']+"'></i></a></li></ul>"; | ||
| 1056 | $("#connections_div_c").html(callchtml); | ||
| 1057 | } | ||
| 1058 | else | ||
| 1059 | { | ||
| 1060 | var tStateArr=[]; | ||
| 1061 | tStateArr['conficon_t_a']='btn-primary';tStateArr['conficon_t_i']='fa-chain-broken'; | ||
| 1062 | if(kstychCall['connections'][key]['connected']==1) | ||
| 1063 | { | ||
| 1064 | tStateArr['conficon_t_a']='btn-success';tStateArr['conficon_t_i']='fa-chain'; | ||
| 1065 | } | ||
| 1066 | tStateArr['mic']='UnMuteMic';tStateArr['micicon']='fa-microphone-slash'; | ||
| 1067 | if(kstychCall['connections'][key]['mic']==1) | ||
| 1068 | { | ||
| 1069 | tStateArr['mic']='MuteMic';tStateArr['micicon']='fa-microphone'; | ||
| 1070 | } | ||
| 1071 | tStateArr['speaker']='UnMuteSpeaker';tStateArr['speakericon']='fa-volume-off'; | ||
| 1072 | if(kstychCall['connections'][key]['speaker']==1) | ||
| 1073 | { | ||
| 1074 | tStateArr['speaker']='MuteSpeaker';tStateArr['speakericon']='fa-volume-up'; | ||
| 1075 | } | ||
| 1076 | tStateArr['holdext']='UnHold';tStateArr['holdexticon']='fa-play'; | ||
| 1077 | if(kstychCall['connections'][key]['holdext']=='') | ||
| 1078 | { | ||
| 1079 | tStateArr['holdext']='Hold';tStateArr['holdexticon']='fa-pause'; | ||
| 1080 | } | ||
| 1081 | |||
| 1082 | confhtml+="<div class='dropdown dropdown-icons dialer_conf_divs' confphonenumber='"+key+"' >"; | ||
| 1083 | confhtml+="<a data-toggle='dropdown' href='#' class='btn btn-stroke "+tStateArr['conficon_t_a']+" btn-circle dropdown-toggle' onmouseout='$(this).blur()'><i class='fa "+tStateArr['conficon_t_i']+"'></i> </a>"; | ||
| 1084 | confhtml+="<ul class='dropdown-menu'>"; | ||
| 1085 | confhtml+="<li data-toggle='tooltip' data-title='"+key+"' data-placement='left' data-tcontainer='body'><a href='#' onclick='return false;'><i class='fa fa-info'></i></a></li>"; | ||
| 1086 | confhtml+="<li data-toggle='tooltip' data-title='"+tStateArr['speaker']+"' data-placement='left' data-tcontainer='body'><a href='#' onclick='kCallAction(\""+key+"\",\""+tStateArr['speaker']+"\");return false;'><i class='fa "+tStateArr['speakericon']+"'></i></a></li>"; | ||
| 1087 | confhtml+="<li data-toggle='tooltip' data-title='"+tStateArr['mic']+"' data-placement='left' data-tcontainer='body'><a href='#' onclick='kCallAction(\""+key+"\",\""+tStateArr['mic']+"\");return false;'><i class='fa "+tStateArr['micicon']+"'></i></a></li>"; | ||
| 1088 | confhtml+="<li data-toggle='tooltip' data-title='Hangup' data-placement='left' data-tcontainer='body'><a href='#' onclick='kCallAction(\""+key+"\",\"Hangup\");return false;'><i class='fa fa-times-circle'></i></a></li>"; | ||
| 1089 | //confhtml+="<li data-toggle='tooltip' data-title='"+tStateArr['holdext']+"' data-placement='left' data-tcontainer='body'><a href='#' onclick='kCallAction(\""+key+"\",\""+tStateArr['holdext']+"\");return false;'><i class='fa "+tStateArr['holdexticon']+"'></i></a></li>"; | ||
| 1090 | confhtml+="</ul></div>"; | ||
| 1091 | } | ||
| 1092 | } | ||
| 1093 | } | ||
| 1094 | $(confhtml).insertAfter("#connections_div_c"); | ||
| 1095 | ////////////////////////////////////////////////////////////// | ||
| 1096 | |||
| 1097 | ////////////////////////////////////////////////////////////// | ||
| 1098 | if(kstychCall['mCallState']=="Wait") | ||
| 1099 | { | ||
| 1100 | $("#dialerstate_btn").parent().attr("disabled",false); | ||
| 1101 | if(kstychDialer['mmanualallow']=='Yes')$("#manualdialnumber_txt").attr("disabled",false); | ||
| 1102 | else $("#manualdialnumber_txt").attr("disabled",true); | ||
| 1103 | |||
| 1104 | $("#manualdial_btn").attr("disabled",false); | ||
| 1105 | $("#manualdial_btn").attr("dialaction","dialnext"); | ||
| 1106 | $("#manualdial_btn").html("<i class='fa fa-play text-default'></i>"); | ||
| 1107 | |||
| 1108 | if(kstychDialer['mDialerState']=="Ready") | ||
| 1109 | { | ||
| 1110 | var readyDelay=Math.ceil((getNowTS()-kstychCall['ts_Wait'])/1000); | ||
| 1111 | |||
| 1112 | $("#manualdial_btn").attr("disabled",true); | ||
| 1113 | $("#manualdial_btn").attr("dialaction",""); | ||
| 1114 | $("#manualdial_btn").html("Waiting");// : "+readyDelay); | ||
| 1115 | |||
| 1116 | } | ||
| 1117 | } | ||
| 1118 | if(kstychCall['mCallState']=="Call") | ||
| 1119 | { | ||
| 1120 | $("#dialerstate_btn").parent().attr("disabled",true); | ||
| 1121 | $("#manualdialnumber_txt").attr("disabled",true); | ||
| 1122 | |||
| 1123 | $("#manualdial_btn").attr("disabled",false); | ||
| 1124 | $("#manualdial_btn").attr("dialaction","hangupall"); | ||
| 1125 | $("#manualdial_btn").html("<i class='fa fa-times text-primary'></i> Hangup"); | ||
| 1126 | } | ||
| 1127 | if(kstychCall['mCallState']=="Dispo") | ||
| 1128 | { | ||
| 1129 | $("#dialerstate_btn").parent().attr("disabled",true); | ||
| 1130 | $("#manualdialnumber_txt").attr("disabled",true); | ||
| 1131 | |||
| 1132 | $("#manualdial_btn").attr("disabled",false); | ||
| 1133 | $("#manualdial_btn").attr("dialaction","saveclose"); | ||
| 1134 | $("#manualdial_btn").html("<i class='fa fa-save text-success'></i> Save & Close"); | ||
| 1135 | } | ||
| 1136 | if(kstychCall['mCallState']=="Close") | ||
| 1137 | { | ||
| 1138 | $("#dialerstate_btn").parent().attr("disabled",true); | ||
| 1139 | $("#manualdialnumber_txt").attr("disabled",true); | ||
| 1140 | |||
| 1141 | $("#manualdial_btn").attr("disabled",true); | ||
| 1142 | $("#manualdial_btn").attr("dialaction",""); | ||
| 1143 | $("#manualdial_btn").html("<i class='fa fa-pause text-default'></i>"); | ||
| 1144 | } | ||
| 1145 | ////////////////////////////////////////////////////////////// | ||
| 1146 | } | ||
| 1147 | |||
| 1148 | function dialerTimersUpdate() | ||
| 1149 | { | ||
| 1150 | var dispD="0";var dispT="0";var dispC="0";var dispW="0"; | ||
| 1151 | |||
| 1152 | if(kstychCall['ts_Dispo']>1) | ||
| 1153 | { | ||
| 1154 | if(Math.ceil(((kstychCall['ts_Dispo']-kstychCall['ts_Talk'])/1000))<3) | ||
| 1155 | { | ||
| 1156 | kstychCall['callWrapupTime']=90; | ||
| 1157 | if(typeof dispoClassArray!='undefined' && typeof dispoClassArray['NA'] != 'undefined') | ||
| 1158 | { | ||
| 1159 | if($('#dialer_userstatus').val()=="") | ||
| 1160 | { | ||
| 1161 | $('#dialer_userstatus').val(dispoClassArray['NA']); | ||
| 1162 | $('#dialer_userstatus').change(); | ||
| 1163 | } | ||
| 1164 | } | ||
| 1165 | } | ||
| 1166 | |||
| 1167 | var thiswraptime=Math.ceil(kstychCall['callWrapupTime']-((getNowTS()-kstychCall['ts_Dispo'])/1000)); | ||
| 1168 | |||
| 1169 | if(thiswraptime<=0) | ||
| 1170 | { | ||
| 1171 | saveCloseDialerCall('AUTOWRAPUP'); | ||
| 1172 | } | ||
| 1173 | |||
| 1174 | if(thiswraptime==90 || thiswraptime==300) | ||
| 1175 | { | ||
| 1176 | showWrapUp(); | ||
| 1177 | } | ||
| 1178 | |||
| 1179 | dispD="Wrapup : "+thiswraptime; | ||
| 1180 | $("#spandialer_ts").html(dispD); | ||
| 1181 | $("#dialertimes1").removeClass("btn-default").addClass("btn-primary"); | ||
| 1182 | } | ||
| 1183 | else if(kstychCall['ts_Talk']>1) | ||
| 1184 | { | ||
| 1185 | dispT="Talk : "+Math.ceil(((getNowTS()-kstychCall['ts_Talk'])/1000)); | ||
| 1186 | $("#spandialer_ts").html(dispT); | ||
| 1187 | $("#dialertimes1").removeClass("btn-primary").addClass("btn-default"); | ||
| 1188 | } | ||
| 1189 | else if(kstychCall['ts_Call']>1) | ||
| 1190 | { | ||
| 1191 | dispC="Call : "+Math.ceil(((getNowTS()-kstychCall['ts_Call'])/1000)); | ||
| 1192 | $("#spandialer_ts").html(dispC); | ||
| 1193 | $("#dialertimes1").removeClass("btn-primary").addClass("btn-default"); | ||
| 1194 | } | ||
| 1195 | else if(kstychCall['ts_Wait']>1) | ||
| 1196 | { | ||
| 1197 | dispW="Wait : "+Math.ceil(((getNowTS()-kstychCall['ts_Wait'])/1000)); | ||
| 1198 | $("#spandialer_ts").html(dispW); | ||
| 1199 | $("#dialertimes1").removeClass("btn-primary").addClass("btn-default"); | ||
| 1200 | } | ||
| 1201 | |||
| 1202 | |||
| 1203 | if(kstychCall['mCallState']=="Wait") | ||
| 1204 | { | ||
| 1205 | if(kstychDialer['mDialerState']=="Progressive") | ||
| 1206 | { | ||
| 1207 | var progressiveDelay=Math.ceil(kstychCall['prograssiveDelay']-((getNowTS()-kstychCall['ts_Wait'])/1000)); | ||
| 1208 | |||
| 1209 | if(progressiveDelay<0)progressiveDelay=0; | ||
| 1210 | |||
| 1211 | $("#manualdial_btn").attr("disabled",false); | ||
| 1212 | $("#manualdial_btn").attr("dialaction","dialnext"); | ||
| 1213 | $("#manualdial_btn").html("<i class='fa fa-play text-default'></i> "+progressiveDelay); | ||
| 1214 | |||
| 1215 | if(progressiveDelay<=0)$("#manualdial_btn").click(); | ||
| 1216 | } | ||
| 1217 | } | ||
| 1218 | |||
| 1219 | setTimeout(dialerTimersUpdate,1000); | ||
| 1220 | } | ||
| 1221 | |||
| 1222 | function kDialerConnected() | ||
| 1223 | { | ||
| 1224 | updateDialerState(); | ||
| 1225 | dialerTimersUpdate(); | ||
| 1226 | $("#dialerQuickControlDiv").show(); | ||
| 1227 | } | ||
| 1228 | function kDialerInit() | ||
| 1229 | { | ||
| 1230 | if(kstychAppObject['user']['id']!=0) | ||
| 1231 | { | ||
| 1232 | //simpleNotification("warning","topRight","Trying to Enable Voice Services"); | ||
| 1233 | |||
| 1234 | txtDisplayName = kstychAppObject['user']['sipid']; | ||
| 1235 | txtPrivateIdentity = kstychAppObject['user']['sipid']; | ||
| 1236 | txtPublicIdentity = "sip:"+kstychAppObject['user']['sipid']+"@"+kstychAppObject['user']['sipserver']; | ||
| 1237 | txtRealm = kstychAppObject['user']['sipserver']; | ||
| 1238 | |||
| 1239 | //txtPhoneNumber=document.getElementById("txtphno"); | ||
| 1240 | txtPhoneNumber = '1000'+kstychAppObject['user']['sipid']; | ||
| 1241 | |||
| 1242 | btnCall = false; | ||
| 1243 | btnHangUp = true; | ||
| 1244 | |||
| 1245 | btnFullScreen = false; | ||
| 1246 | audioRemote = document.getElementById("audio_remote"); | ||
| 1247 | videoLocal = document.getElementById("video_local"); | ||
| 1248 | videoRemote = document.getElementById("video_remote"); | ||
| 1249 | |||
| 1250 | SIPml.setDebugLevel(kstychAppObject['config']['appdebug']==0 ? "error" : "info"); | ||
| 1251 | |||
| 1252 | |||
| 1253 | //expert stuff //siddharth | ||
| 1254 | cbVideoDisable = true; | ||
| 1255 | if(window.location.protocol == 'https:')txtWebsocketServerUrl = "wss://"+kstychAppObject['user']['sipssldomain']+":8089/ws"; | ||
| 1256 | else txtWebsocketServerUrl = "ws://"+txtRealm+":8088/ws"; | ||
| 1257 | txtSIPOutboundProxyUrl = "";//txtSIPOutboundProxyUrl="udp://"+txtRealm+":5060"; | ||
| 1258 | |||
| 1259 | var preInit = function() { | ||
| 1260 | // set default webrtc type (before initialization) | ||
| 1261 | var s_webrtc_type = null;//getPVal("wt"); | ||
| 1262 | var s_fps = null;//getPVal("fps"); | ||
| 1263 | var s_mvs = null;//getPVal("mvs"); // maxVideoSize | ||
| 1264 | var s_mbwu = null;//getPVal("mbwu"); // maxBandwidthUp (kbps) | ||
| 1265 | var s_mbwd = null;//getPVal("mbwd"); // maxBandwidthUp (kbps) | ||
| 1266 | var s_za = null;//getPVal("za"); // ZeroArtifacts | ||
| 1267 | var s_ndb = null;//getPVal("ndb"); // NativeDebug | ||
| 1268 | |||
| 1269 | if (s_webrtc_type) SIPml.setWebRtcType(s_webrtc_type); | ||
| 1270 | |||
| 1271 | // initialize SIPML5 | ||
| 1272 | SIPml.init(postInit); | ||
| 1273 | |||
| 1274 | // set other options after initialization | ||
| 1275 | if (s_fps) SIPml.setFps(parseFloat(s_fps)); | ||
| 1276 | if (s_mvs) SIPml.setMaxVideoSize(s_mvs); | ||
| 1277 | if (s_mbwu) SIPml.setMaxBandwidthUp(parseFloat(s_mbwu)); | ||
| 1278 | if (s_mbwd) SIPml.setMaxBandwidthDown(parseFloat(s_mbwd)); | ||
| 1279 | if (s_za) SIPml.setZeroArtifacts(s_za === "true"); | ||
| 1280 | if (s_ndb == "true") SIPml.startNativeDebug(); | ||
| 1281 | |||
| 1282 | //var rinningApps = SIPml.getRunningApps(); | ||
| 1283 | //var _rinningApps = Base64.decode(rinningApps); | ||
| 1284 | //tsk_utils_log_info(_rinningApps); | ||
| 1285 | } | ||
| 1286 | |||
| 1287 | oReadyStateTimer = setInterval(function () { | ||
| 1288 | if (document.readyState === "complete") { | ||
| 1289 | clearInterval(oReadyStateTimer); | ||
| 1290 | // initialize SIPML5 | ||
| 1291 | preInit(); | ||
| 1292 | } | ||
| 1293 | }, | ||
| 1294 | 500); | ||
| 1295 | } | ||
| 1296 | } | ||
| 1297 | window.onload = function () | ||
| 1298 | { | ||
| 1299 | kDialerInit(); | ||
| 1300 | }; | ||
| 1301 | |||
| 1302 | function postInit() | ||
| 1303 | { | ||
| 1304 | // check for WebRTC support | ||
| 1305 | if (!SIPml.isWebRtcSupported()) | ||
| 1306 | { | ||
| 1307 | // is it chrome? | ||
| 1308 | if (SIPml.getNavigatorFriendlyName() == 'chrome') | ||
| 1309 | { | ||
| 1310 | document.location="msie?oldchrome"; | ||
| 1311 | return; | ||
| 1312 | } | ||
| 1313 | if (SIPml.getNavigatorFriendlyName() == 'ie'||SIPml.getNavigatorFriendlyName() == 'netscape') | ||
| 1314 | { | ||
| 1315 | document.location="msie"; | ||
| 1316 | return; | ||
| 1317 | } | ||
| 1318 | // checks for WebSocket support | ||
| 1319 | if (!SIPml.isWebSocketSupported() && !SIPml.isWebRtc4AllSupported()) | ||
| 1320 | { | ||
| 1321 | document.location="msie?nowebsockets"; | ||
| 1322 | return; | ||
| 1323 | } | ||
| 1324 | } | ||
| 1325 | |||
| 1326 | if (!SIPml.isWebRtc4AllSupported() && !SIPml.isWebRtcSupported()) | ||
| 1327 | { | ||
| 1328 | document.location="msie?notsupported"; | ||
| 1329 | return; | ||
| 1330 | } | ||
| 1331 | |||
| 1332 | oConfigCall = { | ||
| 1333 | audio_remote: audioRemote, | ||
| 1334 | video_local: videoLocal, | ||
| 1335 | video_remote: videoRemote, | ||
| 1336 | screencast_window_id: 0x00000000, // entire desktop | ||
| 1337 | bandwidth: { audio:undefined, video:undefined }, | ||
| 1338 | video_size: { minWidth:undefined, minHeight:undefined, maxWidth:undefined, maxHeight:undefined }, | ||
| 1339 | events_listener: { events: '*', listener: onSipEventSession }, | ||
| 1340 | sip_caps: [ | ||
| 1341 | { name: '+g.oma.sip-im' }, | ||
| 1342 | { name: 'language', value: '\"en,fr\"' } | ||
| 1343 | ] | ||
| 1344 | }; | ||
| 1345 | sipRegister(); | ||
| 1346 | //simpleNotification("warning","topRight","Requesting Voice Permissions"); | ||
| 1347 | //navigator.getUserMedia = (navigator.getUserMedia ||navigator.webkitGetUserMedia ||navigator.mozGetUserMedia || navigator.msGetUserMedia); | ||
| 1348 | //navigator.getUserMedia({video: false, audio: true},function(localMediaStream) {},function(err) {simpleNotification("error","topRight","Your Browser doesnot support Voice. Some functions will not work.");}); | ||
| 1349 | |||
| 1350 | } | ||
| 1351 | |||
| 1352 | |||
| 1353 | // sends SIP REGISTER request to login | ||
| 1354 | function sipRegister() { | ||
| 1355 | // catch exception for IE (DOM not ready) | ||
| 1356 | try | ||
| 1357 | { | ||
| 1358 | if (!txtRealm || !txtPrivateIdentity || !txtPublicIdentity) { | ||
| 1359 | txtRegStatus = '<b>Please fill madatory fields (*)</b>'; | ||
| 1360 | simpleNotification("error","topRight",txtRegStatus); | ||
| 1361 | return; | ||
| 1362 | } | ||
| 1363 | var o_impu = tsip_uri.prototype.Parse(txtPublicIdentity); | ||
| 1364 | if (!o_impu || !o_impu.s_user_name || !o_impu.s_host) { | ||
| 1365 | txtRegStatus = "<b>[" + txtPublicIdentity + "] is not a valid Public identity</b>"; | ||
| 1366 | simpleNotification("error","topRight",txtRegStatus); | ||
| 1367 | return; | ||
| 1368 | } | ||
| 1369 | |||
| 1370 | // enable notifications if not already done | ||
| 1371 | if (window.webkitNotifications && window.webkitNotifications.checkPermission() != 0) { | ||
| 1372 | window.webkitNotifications.requestPermission(); | ||
| 1373 | } | ||
| 1374 | |||
| 1375 | var iceServers=[{ url: 'stun:'+kstychAppObject['user']['sipserver']+':3478'}, { url:'turn:'+kstychAppObject['user']['sipserver'], credential:'1234',username: 'kstych'}]; | ||
| 1376 | if(kstychAppObject['config']['use-ice']=='no')iceServers=[{ url: 'stun:127.0.0.1:3478'}]; | ||
| 1377 | |||
| 1378 | // create SIP stack | ||
| 1379 | oSipStack = new SIPml.Stack({ | ||
| 1380 | realm: txtRealm, | ||
| 1381 | impi: txtPrivateIdentity, | ||
| 1382 | impu: txtPublicIdentity, | ||
| 1383 | password: kstychAppObject['user']['sipauth'], | ||
| 1384 | display_name: txtDisplayName, | ||
| 1385 | websocket_proxy_url: txtWebsocketServerUrl, | ||
| 1386 | outbound_proxy_url: txtSIPOutboundProxyUrl, | ||
| 1387 | ice_servers: iceServers, | ||
| 1388 | enable_rtcweb_breaker: false, | ||
| 1389 | events_listener: { events: '*', listener: onSipEventStack }, | ||
| 1390 | enable_early_ims: true, // Must be true unless you're using a real IMS network | ||
| 1391 | enable_media_stream_cache: false, | ||
| 1392 | bandwidth: null, // could be redefined a session-level | ||
| 1393 | video_size: null, // could be redefined a session-level | ||
| 1394 | sip_headers: [ | ||
| 1395 | { name: 'User-Agent', value: 'IM-client/Kstych' }, | ||
| 1396 | { name: 'Organization', value: 'Kstych Pvt Ltd' } | ||
| 1397 | ] | ||
| 1398 | } | ||
| 1399 | ); | ||
| 1400 | |||
| 1401 | if (oSipStack.start() != 0) { | ||
| 1402 | txtRegStatus = '<b>Failed to start the SIP stack</b>'; | ||
| 1403 | simpleNotification("error","topRight",txtRegStatus); | ||
| 1404 | } | ||
| 1405 | else {loggedin=1;return;} | ||
| 1406 | } | ||
| 1407 | catch (e) { | ||
| 1408 | txtRegStatus = "<b>2:" + e + "</b>"; | ||
| 1409 | simpleNotification("error","topRight",txtRegStatus); | ||
| 1410 | } | ||
| 1411 | } | ||
| 1412 | |||
| 1413 | // sends SIP REGISTER (expires=0) to logout | ||
| 1414 | function sipUnRegister(type) | ||
| 1415 | { | ||
| 1416 | if (oSipStack) { | ||
| 1417 | try{sipHangUp();}catch(e){console.log(e);} | ||
| 1418 | oSipStack.stop(); // shutdown all sessions | ||
| 1419 | } | ||
| 1420 | |||
| 1421 | if(!type) | ||
| 1422 | { | ||
| 1423 | /* simpleNotification("warning","topRight","Retrying in 10 sec...");*/ | ||
| 1424 | $("#phonetopbar").hide(); | ||
| 1425 | //setTimeout(sipRegister,10*1000); | ||
| 1426 | document.location='/logout'; | ||
| 1427 | } | ||
| 1428 | else loggedin=0; | ||
| 1429 | } | ||
| 1430 | |||
| 1431 | // makes a call (SIP INVITE) | ||
| 1432 | function sipCall(s_type,destination) { | ||
| 1433 | if(oSipStack) | ||
| 1434 | { | ||
| 1435 | if (oSipSessionCall) { | ||
| 1436 | txtCallStatus = '<i>Already in a Call...</i>'; | ||
| 1437 | simpleNotification("warning","topRight",txtCallStatus); | ||
| 1438 | } | ||
| 1439 | else { | ||
| 1440 | if (!tsk_string_is_null_or_empty(destination)) { | ||
| 1441 | |||
| 1442 | if(s_type == 'call-screenshare') { | ||
| 1443 | if(!SIPml.isScreenShareSupported()) { | ||
| 1444 | alert('Screen sharing not supported. Are you using chrome 26+?'); | ||
| 1445 | return; | ||
| 1446 | } | ||
| 1447 | if (!location.protocol.match('https')){ | ||
| 1448 | if (confirm("Screen sharing requires https://. Do you want to be redirected?")) { | ||
| 1449 | sipUnRegister(); | ||
| 1450 | window.location = 'msie?httpsneeded'; | ||
| 1451 | } | ||
| 1452 | return; | ||
| 1453 | } | ||
| 1454 | } | ||
| 1455 | btnCall = true; | ||
| 1456 | btnHangUp = false; | ||
| 1457 | |||
| 1458 | |||
| 1459 | // create call session | ||
| 1460 | oSipSessionCall = oSipStack.newSession(s_type, oConfigCall); | ||
| 1461 | // make call | ||
| 1462 | if (oSipSessionCall.call(destination) != 0) { | ||
| 1463 | oSipSessionCall = null; | ||
| 1464 | txtCallStatus = 'Failed to make call'; | ||
| 1465 | simpleNotification("error","topRight",txtCallStatus); | ||
| 1466 | btnCall = false; | ||
| 1467 | btnHangUp = true; | ||
| 1468 | return; | ||
| 1469 | } | ||
| 1470 | } | ||
| 1471 | } | ||
| 1472 | } | ||
| 1473 | } | ||
| 1474 | function sipAnswer() | ||
| 1475 | { | ||
| 1476 | if(oSipStack){ | ||
| 1477 | if (oSipSessionCall) { | ||
| 1478 | txtCallStatus = '<i>Connecting...</i>'; | ||
| 1479 | //simpleNotification("warning","topRight",txtCallStatus); | ||
| 1480 | oSipSessionCall.accept(oConfigCall); | ||
| 1481 | } | ||
| 1482 | } | ||
| 1483 | if(answergrowl)$.gritter.remove(answergrowl, {fade: true,speed: 'slow'}); | ||
| 1484 | } | ||
| 1485 | |||
| 1486 | // Share entire desktop aor application using BFCP or WebRTC native implementation | ||
| 1487 | function sipShareScreen() { | ||
| 1488 | if (SIPml.getWebRtcType() === 'w4a') { | ||
| 1489 | // Sharing using BFCP -> requires an active session | ||
| 1490 | if (!oSipSessionCall) { | ||
| 1491 | txtCallStatus = '<i>No active session</i>'; | ||
| 1492 | return; | ||
| 1493 | } | ||
| 1494 | if (oSipSessionCall.bfcpSharing) { | ||
| 1495 | if (oSipSessionCall.stopBfcpShare(oConfigCall) != 0) { | ||
| 1496 | txtCallStatus = 'Failed to stop BFCP share'; | ||
| 1497 | } | ||
| 1498 | else { | ||
| 1499 | oSipSessionCall.bfcpSharing = false; | ||
| 1500 | } | ||
| 1501 | } | ||
| 1502 | else { | ||
| 1503 | oConfigCall.screencast_window_id = 0x00000000; | ||
| 1504 | if (oSipSessionCall.startBfcpShare(oConfigCall) != 0) { | ||
| 1505 | txtCallStatus = 'Failed to start BFCP share'; | ||
| 1506 | } | ||
| 1507 | else { | ||
| 1508 | oSipSessionCall.bfcpSharing = true; | ||
| 1509 | } | ||
| 1510 | } | ||
| 1511 | } | ||
| 1512 | else { | ||
| 1513 | sipCall('call-screenshare',txtPhoneNumber); | ||
| 1514 | } | ||
| 1515 | } | ||
| 1516 | |||
| 1517 | |||
| 1518 | |||
| 1519 | // transfers the call | ||
| 1520 | function sipTransfer(s_destination) { | ||
| 1521 | if (oSipSessionCall) { | ||
| 1522 | if (!tsk_string_is_null_or_empty(s_destination)) { | ||
| 1523 | btnTransfer.disabled = true; | ||
| 1524 | if (oSipSessionCall.transfer(s_destination) != 0) { | ||
| 1525 | txtCallStatus = '<i>Call transfer failed</i>'; | ||
| 1526 | btnTransfer.disabled = false; | ||
| 1527 | return; | ||
| 1528 | } | ||
| 1529 | txtCallStatus = '<i>Transfering the call...</i>'; | ||
| 1530 | } | ||
| 1531 | } | ||
| 1532 | } | ||
| 1533 | |||
| 1534 | // holds or resumes the call | ||
| 1535 | function sipToggleHoldResume() { | ||
| 1536 | if (oSipSessionCall) { | ||
| 1537 | var i_ret; | ||
| 1538 | btnHoldResume.disabled = true; | ||
| 1539 | txtCallStatus = oSipSessionCall.bHeld ? '<i>Resuming the call...</i>' : '<i>Holding the call...</i>'; | ||
| 1540 | i_ret = oSipSessionCall.bHeld ? oSipSessionCall.resume() : oSipSessionCall.hold(); | ||
| 1541 | if (i_ret != 0) { | ||
| 1542 | txtCallStatus = '<i>Hold / Resume failed</i>'; | ||
| 1543 | btnHoldResume.disabled = false; | ||
| 1544 | return; | ||
| 1545 | } | ||
| 1546 | } | ||
| 1547 | } | ||
| 1548 | |||
| 1549 | // Mute or Unmute the call | ||
| 1550 | function sipToggleMute() { | ||
| 1551 | if (oSipSessionCall) { | ||
| 1552 | var i_ret; | ||
| 1553 | var bMute = !oSipSessionCall.bMute; | ||
| 1554 | txtCallStatus = bMute ? '<i>Mute the call...</i>' : '<i>Unmute the call...</i>'; | ||
| 1555 | i_ret = oSipSessionCall.mute('audio'/*could be 'video'*/, bMute); | ||
| 1556 | if (i_ret != 0) { | ||
| 1557 | simpleNotification('error','topRight',"Mute / Unmute failed"); | ||
| 1558 | return; | ||
| 1559 | } | ||
| 1560 | oSipSessionCall.bMute = bMute; | ||
| 1561 | var btnMute = bMute ? "Mute" : "Unmute"; | ||
| 1562 | simpleNotification('success','topRight',"You are now ["+btnMute+"]"); | ||
| 1563 | |||
| 1564 | return bMute ? 0 : 1; | ||
| 1565 | } | ||
| 1566 | return 1; | ||
| 1567 | } | ||
| 1568 | |||
| 1569 | // terminates the call (SIP BYE or CANCEL) | ||
| 1570 | function sipHangUp() { | ||
| 1571 | try | ||
| 1572 | { | ||
| 1573 | stopRingbackTone(); | ||
| 1574 | stopRingTone(); | ||
| 1575 | |||
| 1576 | if (oSipSessionCall) { | ||
| 1577 | txtCallStatus = '<i>Terminating the call...</i>'; | ||
| 1578 | oSipSessionCall.hangup({events_listener: { events: '*', listener: onSipEventSession }}); | ||
| 1579 | //simpleNotification("warning","topRight","Call Terminated."); | ||
| 1580 | } | ||
| 1581 | //$("#phonetopbar").hide(); | ||
| 1582 | } | ||
| 1583 | catch(e){console.log(e);} | ||
| 1584 | |||
| 1585 | if(hangupgrowl)$.gritter.remove(hangupgrowl, {fade: true,speed: 'slow'}); | ||
| 1586 | if(answergrowl)$.gritter.remove(answergrowl, {fade: true,speed: 'slow'}); | ||
| 1587 | } | ||
| 1588 | |||
| 1589 | function sipSendDTMF(c){ | ||
| 1590 | if(oSipSessionCall && c){ | ||
| 1591 | if(oSipSessionCall.dtmf(c) == 0){ | ||
| 1592 | try { dtmfTone.play(); } catch(e){ } | ||
| 1593 | } | ||
| 1594 | } | ||
| 1595 | } | ||
| 1596 | |||
| 1597 | function startRingTone() { | ||
| 1598 | try { ringtone.play(); } | ||
| 1599 | catch (e) { } | ||
| 1600 | } | ||
| 1601 | |||
| 1602 | function stopRingTone() { | ||
| 1603 | try { ringtone.pause(); } | ||
| 1604 | catch (e) { } | ||
| 1605 | } | ||
| 1606 | |||
| 1607 | function startRingbackTone() { | ||
| 1608 | try { ringbacktone.play(); } | ||
| 1609 | catch (e) { } | ||
| 1610 | } | ||
| 1611 | |||
| 1612 | function stopRingbackTone() { | ||
| 1613 | try { ringbacktone.pause(); } | ||
| 1614 | catch (e) { } | ||
| 1615 | } | ||
| 1616 | |||
| 1617 | function toggleFullScreen() { | ||
| 1618 | if (videoRemote.webkitSupportsFullscreen) { | ||
| 1619 | fullScreen(!videoRemote.webkitDisplayingFullscreen); | ||
| 1620 | } | ||
| 1621 | else { | ||
| 1622 | fullScreen(!bFullScreen); | ||
| 1623 | } | ||
| 1624 | } | ||
| 1625 | |||
| 1626 | function fullScreen(b_fs) { | ||
| 1627 | return false;//TODO | ||
| 1628 | bFullScreen = b_fs; | ||
| 1629 | if (tsk_utils_have_webrtc4native() && bFullScreen && videoRemote.webkitSupportsFullscreen) { | ||
| 1630 | if (bFullScreen) { | ||
| 1631 | videoRemote.webkitEnterFullScreen(); | ||
| 1632 | } | ||
| 1633 | else { | ||
| 1634 | videoRemote.webkitExitFullscreen(); | ||
| 1635 | } | ||
| 1636 | } | ||
| 1637 | else { | ||
| 1638 | if (tsk_utils_have_webrtc4npapi()) { | ||
| 1639 | try { if(window.__o_display_remote) window.__o_display_remote.setFullScreen(b_fs); } | ||
| 1640 | catch (e) { /*divVideo.setAttribute("class", b_fs ? "full-screen" : "normal-screen");*/ } | ||
| 1641 | } | ||
| 1642 | else { | ||
| 1643 | //divVideo.setAttribute("class", b_fs ? "full-screen" : "normal-screen"); | ||
| 1644 | } | ||
| 1645 | } | ||
| 1646 | } | ||
| 1647 | |||
| 1648 | function showNotifICall(s_number) { | ||
| 1649 | return false;//TODO | ||
| 1650 | // permission already asked when we registered | ||
| 1651 | if (window.webkitNotifications && window.webkitNotifications.checkPermission() == 0) { | ||
| 1652 | if (oNotifICall) { | ||
| 1653 | oNotifICall.cancel(); | ||
| 1654 | } | ||
| 1655 | oNotifICall = window.webkitNotifications.createNotification('images/sipml-34x39.png', 'Incaming call', 'Incoming call from ' + s_number); | ||
| 1656 | oNotifICall.onclose = function () { oNotifICall = null; }; | ||
| 1657 | oNotifICall.show(); | ||
| 1658 | } | ||
| 1659 | } | ||
| 1660 | |||
| 1661 | |||
| 1662 | function uiOnConnectionEvent(b_connected, b_connecting) { | ||
| 1663 | // should be enum: connecting, connected, terminating, terminated | ||
| 1664 | //TODO | ||
| 1665 | btnRegister = b_connected || b_connecting; | ||
| 1666 | btnUnRegister = !b_connected && !b_connecting; | ||
| 1667 | btnCall = !(b_connected && tsk_utils_have_webrtc() && tsk_utils_have_stream()); | ||
| 1668 | btnHangUp = !oSipSessionCall; | ||
| 1669 | } | ||
| 1670 | |||
| 1671 | function uiVideoDisplayEvent(b_local, b_added) { | ||
| 1672 | return false;//TODO | ||
| 1673 | var o_elt_video = b_local ? videoLocal : videoRemote; | ||
| 1674 | |||
| 1675 | if (b_added) { | ||
| 1676 | if (SIPml.isWebRtc4AllSupported()) { | ||
| 1677 | if (b_local) { | ||
| 1678 | if (WebRtc4all_GetDisplayLocal()) WebRtc4all_GetDisplayLocal().style.visibility = "visible"; | ||
| 1679 | if (WebRtc4all_GetDisplayLocalScreencast()) WebRtc4all_GetDisplayLocalScreencast().style.visibility = "visible"; | ||
| 1680 | //videoLocal.style.visibility = "visible"; | ||
| 1681 | //viewLocalScreencast.style.visibility = "visible"; | ||
| 1682 | //if (WebRtc4all_GetDisplayLocal()) WebRtc4all_GetDisplayLocal().hidden = false; | ||
| 1683 | //if (WebRtc4all_GetDisplayLocalScreencast()) WebRtc4all_GetDisplayLocalScreencast().hidden = false; | ||
| 1684 | } | ||
| 1685 | else { | ||
| 1686 | if (WebRtc4all_GetDisplayRemote()) WebRtc4all_GetDisplayRemote().style.visibility = "visible"; | ||
| 1687 | //videoRemote.style.visibility = "visible"; | ||
| 1688 | //if (WebRtc4all_GetDisplayRemote()) WebRtc4all_GetDisplayRemote().hidden = false; | ||
| 1689 | } | ||
| 1690 | } | ||
| 1691 | else { | ||
| 1692 | o_elt_video.style.opacity = 1; | ||
| 1693 | } | ||
| 1694 | uiVideoDisplayShowHide(true); | ||
| 1695 | } | ||
| 1696 | else { | ||
| 1697 | if (SIPml.isWebRtc4AllSupported()) { | ||
| 1698 | if (b_local) { | ||
| 1699 | if (WebRtc4all_GetDisplayLocal()) WebRtc4all_GetDisplayLocal().style.visibility = "hidden"; | ||
| 1700 | if (WebRtc4all_GetDisplayLocalScreencast()) WebRtc4all_GetDisplayLocalScreencast().style.visibility = "hidden"; | ||
| 1701 | //videoLocal.style.visibility = "hidden"; | ||
| 1702 | //viewLocalScreencast.style.visibility = "hidden"; | ||
| 1703 | //if (WebRtc4all_GetDisplayLocal()) WebRtc4all_GetDisplayLocal().hidden = true; | ||
| 1704 | //if (WebRtc4all_GetDisplayLocalScreencast()) WebRtc4all_GetDisplayLocalScreencast().hidden = true; | ||
| 1705 | } | ||
| 1706 | else { | ||
| 1707 | if (WebRtc4all_GetDisplayRemote()) WebRtc4all_GetDisplayRemote().style.visibility = "hidden"; | ||
| 1708 | //videoRemote.style.visibility = "hidden"; | ||
| 1709 | //if (WebRtc4all_GetDisplayRemote()) WebRtc4all_GetDisplayRemote().hidden = true; | ||
| 1710 | } | ||
| 1711 | } | ||
| 1712 | else{ | ||
| 1713 | o_elt_video.style.opacity = 0; | ||
| 1714 | } | ||
| 1715 | fullScreen(false); | ||
| 1716 | } | ||
| 1717 | } | ||
| 1718 | |||
| 1719 | function uiVideoDisplayShowHide(b_show) { | ||
| 1720 | //TODO | ||
| 1721 | if (b_show) { | ||
| 1722 | |||
| 1723 | } | ||
| 1724 | else { | ||
| 1725 | |||
| 1726 | } | ||
| 1727 | btnFullScreen.disabled = !b_show; | ||
| 1728 | } | ||
| 1729 | |||
| 1730 | function uiCallTerminated(s_description){ | ||
| 1731 | |||
| 1732 | btnCall = false; | ||
| 1733 | btnHangUp = true; | ||
| 1734 | |||
| 1735 | oSipSessionCall = null; | ||
| 1736 | |||
| 1737 | stopRingbackTone(); | ||
| 1738 | stopRingTone(); | ||
| 1739 | |||
| 1740 | txtCallStatus = "<i>" + s_description + "</i>"; | ||
| 1741 | uiVideoDisplayShowHide(false); | ||
| 1742 | //divCallOptions.style.opacity = 0; | ||
| 1743 | |||
| 1744 | if (oNotifICall) { | ||
| 1745 | oNotifICall.cancel(); | ||
| 1746 | oNotifICall = null; | ||
| 1747 | } | ||
| 1748 | |||
| 1749 | uiVideoDisplayEvent(true, false); | ||
| 1750 | uiVideoDisplayEvent(false, false); | ||
| 1751 | |||
| 1752 | setTimeout(function () { if (!oSipSessionCall) txtCallStatus = ''; }, 2500); | ||
| 1753 | |||
| 1754 | if(hangupgrowl)$.gritter.remove(hangupgrowl, {fade: true,speed: 'slow'}); | ||
| 1755 | } | ||
| 1756 | |||
| 1757 | // Callback function for SIP Stacks | ||
| 1758 | function onSipEventStack(e /*SIPml.Stack.Event*/) { | ||
| 1759 | tsk_utils_log_info('==stack event = ' + e.type); | ||
| 1760 | switch (e.type) { | ||
| 1761 | case 'started': | ||
| 1762 | { | ||
| 1763 | // catch exception for IE (DOM not ready) | ||
| 1764 | try { | ||
| 1765 | // LogIn (REGISTER) as soon as the stack finish starting | ||
| 1766 | oSipSessionRegister = this.newSession('register', { | ||
| 1767 | expires: 200, | ||
| 1768 | events_listener: { events: '*', listener: onSipEventSession }, | ||
| 1769 | sip_caps: [ | ||
| 1770 | { name: '+g.oma.sip-im', value: null }, | ||
| 1771 | { name: '+audio', value: null }, | ||
| 1772 | { name: 'language', value: '\"en,fr\"' } | ||
| 1773 | ] | ||
| 1774 | }); | ||
| 1775 | oSipSessionRegister.register(); | ||
| 1776 | } | ||
| 1777 | catch (e) { | ||
| 1778 | txtRegStatus = txtRegStatus = "<b>1:" + e + "</b>"; | ||
| 1779 | simpleNotification("success","topRight",txtRegStatus); | ||
| 1780 | btnRegister = false; | ||
| 1781 | } | ||
| 1782 | break; | ||
| 1783 | } | ||
| 1784 | case 'stopping': case 'stopped': case 'failed_to_start': case 'failed_to_stop': | ||
| 1785 | { | ||
| 1786 | var bFailure = (e.type == 'failed_to_start') || (e.type == 'failed_to_stop'); | ||
| 1787 | oSipStack = null; | ||
| 1788 | oSipSessionRegister = null; | ||
| 1789 | oSipSessionCall = null; | ||
| 1790 | |||
| 1791 | uiOnConnectionEvent(false, false); | ||
| 1792 | |||
| 1793 | stopRingbackTone(); | ||
| 1794 | stopRingTone(); | ||
| 1795 | |||
| 1796 | uiVideoDisplayShowHide(false); | ||
| 1797 | //divCallOptions.style.opacity = 0; | ||
| 1798 | |||
| 1799 | txtCallStatus = ''; | ||
| 1800 | if(loggedin) | ||
| 1801 | { | ||
| 1802 | txtRegStatus = bFailure ? "<i>Disconnected: <b>" + e.description + "</b></i>" : "<i>Disconnected</i>"; | ||
| 1803 | //simpleNotification("warning","topRight",txtRegStatus+", Retrying in 10 sec..."); | ||
| 1804 | //setTimeout(sipRegister,10*1000);//TODO dont retry too many times, idleapp instead | ||
| 1805 | document.location='/logout'; | ||
| 1806 | } | ||
| 1807 | else | ||
| 1808 | { | ||
| 1809 | if(e.type=='stopped')doLogout(1); | ||
| 1810 | } | ||
| 1811 | break; | ||
| 1812 | } | ||
| 1813 | |||
| 1814 | case 'i_new_call': | ||
| 1815 | { | ||
| 1816 | if (oSipSessionCall) { | ||
| 1817 | // do not accept the incoming call if we're already 'in call' | ||
| 1818 | e.newSession.hangup(); // comment this line for multi-line support | ||
| 1819 | } | ||
| 1820 | else { | ||
| 1821 | oSipSessionCall = e.newSession; | ||
| 1822 | |||
| 1823 | btnCall = 'Answer'; | ||
| 1824 | btnHangUp = 'Reject'; | ||
| 1825 | btnCall = false; | ||
| 1826 | btnHangUp = false; | ||
| 1827 | |||
| 1828 | var sRemoteNumber = (oSipSessionCall.getRemoteFriendlyName() || 'unknown'); | ||
| 1829 | |||
| 1830 | if(sRemoteNumber=='1000'+kstychAppObject['user']['sipid']) | ||
| 1831 | { | ||
| 1832 | //auto answer if own conf | ||
| 1833 | var dialerConnection=kGetDData("D","connection"); | ||
| 1834 | dialerConnection['connected']=1; | ||
| 1835 | updateDialerState("dialer","connection",dialerConnection); | ||
| 1836 | sipAnswer(); | ||
| 1837 | } | ||
| 1838 | else | ||
| 1839 | { | ||
| 1840 | startRingTone(); | ||
| 1841 | txtCallStatus = "<i><a href=# onclick='sipAnswer();return false;'>Incoming call Click Here To Answer</a></i> from [<b>" + sRemoteNumber + "</b>]"; | ||
| 1842 | //showNotifICall(sRemoteNumber); | ||
| 1843 | answergrowl=growlSNotify("Incoming Call",txtCallStatus,"top-right"); | ||
| 1844 | hangupgrowl=growlSNotify("Incoming Call","<a href=# onclick='sipHangUp();return false;' style='color:white'>Click here to hangup</a>","top-right"); | ||
| 1845 | } | ||
| 1846 | //showNotifICall(sRemoteNumber); | ||
| 1847 | } | ||
| 1848 | break; | ||
| 1849 | } | ||
| 1850 | |||
| 1851 | case 'm_permission_requested': | ||
| 1852 | { | ||
| 1853 | //document.getElementById('divNavbarInner').setAttribute('class', 'navbar-inner-red'); | ||
| 1854 | break; | ||
| 1855 | } | ||
| 1856 | case 'm_permission_accepted': | ||
| 1857 | case 'm_permission_refused': | ||
| 1858 | { | ||
| 1859 | //document.getElementById('divNavbarInner').setAttribute('class', 'navbar-inner'); | ||
| 1860 | if(e.type == 'm_permission_refused'){ | ||
| 1861 | uiCallTerminated('Media stream permission denied'); | ||
| 1862 | } | ||
| 1863 | break; | ||
| 1864 | } | ||
| 1865 | |||
| 1866 | case 'starting': default: break; | ||
| 1867 | } | ||
| 1868 | }; | ||
| 1869 | |||
| 1870 | // Callback function for SIP sessions (INVITE, REGISTER, MESSAGE...) | ||
| 1871 | function onSipEventSession(e /* SIPml.Session.Event */) { | ||
| 1872 | tsk_utils_log_info('==session event = ' + e.type); | ||
| 1873 | |||
| 1874 | switch (e.type) { | ||
| 1875 | case 'connecting': case 'connected': | ||
| 1876 | { | ||
| 1877 | var bConnected = (e.type == 'connected'); | ||
| 1878 | if (e.session == oSipSessionRegister) { | ||
| 1879 | uiOnConnectionEvent(bConnected, !bConnected); | ||
| 1880 | txtRegStatus = "<i>" + e.description + "</i>"; | ||
| 1881 | if(bConnected){/*simpleNotification("success","topRight","Connected");*//*$("#phonetopbar").show();*/kDialerConnected();} | ||
| 1882 | } | ||
| 1883 | else if (e.session == oSipSessionCall) { | ||
| 1884 | btnHangUp = 'HangUp'; | ||
| 1885 | btnCall = true; | ||
| 1886 | btnHangUp = false; | ||
| 1887 | btnTransfer = false; | ||
| 1888 | |||
| 1889 | if (bConnected) { | ||
| 1890 | stopRingbackTone(); | ||
| 1891 | stopRingTone(); | ||
| 1892 | |||
| 1893 | if (oNotifICall) { | ||
| 1894 | oNotifICall.cancel(); | ||
| 1895 | oNotifICall = null; | ||
| 1896 | } | ||
| 1897 | } | ||
| 1898 | |||
| 1899 | txtCallStatus = "<i>" + e.description + "</i>"; | ||
| 1900 | //simpleNotification("success","topRight",txtCallStatus); | ||
| 1901 | //divCallOptions.style.opacity = bConnected ? 1 : 0; | ||
| 1902 | |||
| 1903 | if (SIPml.isWebRtc4AllSupported()) { // IE don't provide stream callback | ||
| 1904 | uiVideoDisplayEvent(true, true); | ||
| 1905 | uiVideoDisplayEvent(false, true); | ||
| 1906 | } | ||
| 1907 | } | ||
| 1908 | break; | ||
| 1909 | } // 'connecting' | 'connected' | ||
| 1910 | case 'terminating': case 'terminated': | ||
| 1911 | { | ||
| 1912 | if (e.session == oSipSessionRegister) { | ||
| 1913 | uiOnConnectionEvent(false, false); | ||
| 1914 | |||
| 1915 | oSipSessionCall = null; | ||
| 1916 | oSipSessionRegister = null; | ||
| 1917 | |||
| 1918 | txtRegStatus = "<i>" + e.description + "</i>"; | ||
| 1919 | //simpleNotification("warning","topRight",txtRegStatus); | ||
| 1920 | } | ||
| 1921 | else if (e.session == oSipSessionCall) { | ||
| 1922 | uiCallTerminated(e.description); | ||
| 1923 | } | ||
| 1924 | break; | ||
| 1925 | } // 'terminating' | 'terminated' | ||
| 1926 | |||
| 1927 | case 'm_stream_video_local_added': | ||
| 1928 | { | ||
| 1929 | if (e.session == oSipSessionCall) { | ||
| 1930 | uiVideoDisplayEvent(true, true); | ||
| 1931 | } | ||
| 1932 | break; | ||
| 1933 | } | ||
| 1934 | case 'm_stream_video_local_removed': | ||
| 1935 | { | ||
| 1936 | if (e.session == oSipSessionCall) { | ||
| 1937 | uiVideoDisplayEvent(true, false); | ||
| 1938 | } | ||
| 1939 | break; | ||
| 1940 | } | ||
| 1941 | case 'm_stream_video_remote_added': | ||
| 1942 | { | ||
| 1943 | if (e.session == oSipSessionCall) { | ||
| 1944 | uiVideoDisplayEvent(false, true); | ||
| 1945 | } | ||
| 1946 | break; | ||
| 1947 | } | ||
| 1948 | case 'm_stream_video_remote_removed': | ||
| 1949 | { | ||
| 1950 | if (e.session == oSipSessionCall) { | ||
| 1951 | uiVideoDisplayEvent(false, false); | ||
| 1952 | } | ||
| 1953 | break; | ||
| 1954 | } | ||
| 1955 | |||
| 1956 | case 'm_stream_audio_local_added': | ||
| 1957 | case 'm_stream_audio_local_removed': | ||
| 1958 | case 'm_stream_audio_remote_added': | ||
| 1959 | case 'm_stream_audio_remote_removed': | ||
| 1960 | { | ||
| 1961 | break; | ||
| 1962 | } | ||
| 1963 | |||
| 1964 | case 'i_ect_new_call': | ||
| 1965 | { | ||
| 1966 | oSipSessionTransferCall = e.session; | ||
| 1967 | break; | ||
| 1968 | } | ||
| 1969 | |||
| 1970 | case 'i_ao_request': | ||
| 1971 | { | ||
| 1972 | if(e.session == oSipSessionCall){ | ||
| 1973 | var iSipResponseCode = e.getSipResponseCode(); | ||
| 1974 | if (iSipResponseCode == 180 || iSipResponseCode == 183) { | ||
| 1975 | startRingbackTone(); | ||
| 1976 | txtCallStatus = '<i>Remote ringing...</i>'; | ||
| 1977 | //simpleNotification("warning","topRight",txtCallStatus); | ||
| 1978 | } | ||
| 1979 | } | ||
| 1980 | break; | ||
| 1981 | } | ||
| 1982 | |||
| 1983 | case 'm_early_media': | ||
| 1984 | { | ||
| 1985 | if(e.session == oSipSessionCall){ | ||
| 1986 | stopRingbackTone(); | ||
| 1987 | stopRingTone(); | ||
| 1988 | txtCallStatus = '<i>Early media started</i>'; | ||
| 1989 | //simpleNotification("warning","topRight",txtCallStatus); | ||
| 1990 | } | ||
| 1991 | break; | ||
| 1992 | } | ||
| 1993 | |||
| 1994 | case 'm_local_hold_ok': | ||
| 1995 | { | ||
| 1996 | if(e.session == oSipSessionCall){ | ||
| 1997 | if (oSipSessionCall.bTransfering) { | ||
| 1998 | oSipSessionCall.bTransfering = false; | ||
| 1999 | // this.AVSession.TransferCall(this.transferUri); | ||
| 2000 | } | ||
| 2001 | btnHoldResume = false; | ||
| 2002 | txtCallStatus = '<i>Call placed on hold</i>'; | ||
| 2003 | oSipSessionCall.bHeld = true; | ||
| 2004 | //simpleNotification("success","topRight",txtCallStatus); | ||
| 2005 | } | ||
| 2006 | break; | ||
| 2007 | } | ||
| 2008 | case 'm_local_hold_nok': | ||
| 2009 | { | ||
| 2010 | if(e.session == oSipSessionCall){ | ||
| 2011 | oSipSessionCall.bTransfering = false; | ||
| 2012 | btnHoldResume = false; | ||
| 2013 | txtCallStatus = '<i>Failed to place remote party on hold</i>'; | ||
| 2014 | //simpleNotification("error","topRight",txtCallStatus); | ||
| 2015 | } | ||
| 2016 | break; | ||
| 2017 | } | ||
| 2018 | case 'm_local_resume_ok': | ||
| 2019 | { | ||
| 2020 | if(e.session == oSipSessionCall){ | ||
| 2021 | oSipSessionCall.bTransfering = false; | ||
| 2022 | btnHoldResume = false; | ||
| 2023 | txtCallStatus = '<i>Call taken off hold</i>'; | ||
| 2024 | oSipSessionCall.bHeld = false; | ||
| 2025 | //simpleNotification("warning","topRight",txtCallStatus); | ||
| 2026 | |||
| 2027 | if (SIPml.isWebRtc4AllSupported()) { // IE don't provide stream callback yet | ||
| 2028 | uiVideoDisplayEvent(true, true); | ||
| 2029 | uiVideoDisplayEvent(false, true); | ||
| 2030 | } | ||
| 2031 | } | ||
| 2032 | break; | ||
| 2033 | } | ||
| 2034 | case 'm_local_resume_nok': | ||
| 2035 | { | ||
| 2036 | if(e.session == oSipSessionCall){ | ||
| 2037 | oSipSessionCall.bTransfering = false; | ||
| 2038 | btnHoldResume = false; | ||
| 2039 | txtCallStatus = '<i>Failed to unhold call</i>'; | ||
| 2040 | //simpleNotification("error","topRight",txtCallStatus); | ||
| 2041 | } | ||
| 2042 | break; | ||
| 2043 | } | ||
| 2044 | case 'm_remote_hold': | ||
| 2045 | { | ||
| 2046 | if(e.session == oSipSessionCall){ | ||
| 2047 | txtCallStatus = '<i>Placed on hold by remote party</i>'; | ||
| 2048 | //simpleNotification("warning","topRight",txtCallStatus); | ||
| 2049 | } | ||
| 2050 | break; | ||
| 2051 | } | ||
| 2052 | case 'm_remote_resume': | ||
| 2053 | { | ||
| 2054 | if(e.session == oSipSessionCall){ | ||
| 2055 | txtCallStatus = '<i>Taken off hold by remote party</i>'; | ||
| 2056 | //simpleNotification("warning","topRight",txtCallStatus); | ||
| 2057 | } | ||
| 2058 | break; | ||
| 2059 | } | ||
| 2060 | case 'm_bfcp_info': | ||
| 2061 | { | ||
| 2062 | if(e.session == oSipSessionCall){ | ||
| 2063 | txtCallStatus.innerHTML = 'BFCP Info: <i>'+ e.description +'</i>'; | ||
| 2064 | } | ||
| 2065 | break; | ||
| 2066 | } | ||
| 2067 | case 'o_ect_trying': | ||
| 2068 | { | ||
| 2069 | if(e.session == oSipSessionCall){ | ||
| 2070 | txtCallStatus = '<i>Call transfer in progress...</i>'; | ||
| 2071 | //simpleNotification("warning","topRight",txtCallStatus); | ||
| 2072 | } | ||
| 2073 | break; | ||
| 2074 | } | ||
| 2075 | case 'o_ect_accepted': | ||
| 2076 | { | ||
| 2077 | if(e.session == oSipSessionCall){ | ||
| 2078 | txtCallStatus = '<i>Call transfer accepted</i>'; | ||
| 2079 | //simpleNotification("success","topRight",txtCallStatus); | ||
| 2080 | } | ||
| 2081 | break; | ||
| 2082 | } | ||
| 2083 | case 'o_ect_completed': | ||
| 2084 | case 'i_ect_completed': | ||
| 2085 | { | ||
| 2086 | if(e.session == oSipSessionCall){ | ||
| 2087 | txtCallStatus = '<i>Call transfer completed</i>'; | ||
| 2088 | //simpleNotification("success","topRight",txtCallStatus); | ||
| 2089 | btnTransfer = false; | ||
| 2090 | if (oSipSessionTransferCall) { | ||
| 2091 | oSipSessionCall = oSipSessionTransferCall; | ||
| 2092 | } | ||
| 2093 | oSipSessionTransferCall = null; | ||
| 2094 | } | ||
| 2095 | break; | ||
| 2096 | } | ||
| 2097 | case 'o_ect_failed': | ||
| 2098 | case 'i_ect_failed': | ||
| 2099 | { | ||
| 2100 | if(e.session == oSipSessionCall){ | ||
| 2101 | txtCallStatus = '<i>Call transfer failed</i>'; | ||
| 2102 | //simpleNotification("error","topRight",txtCallStatus); | ||
| 2103 | btnTransfer = false; | ||
| 2104 | } | ||
| 2105 | break; | ||
| 2106 | } | ||
| 2107 | case 'o_ect_notify': | ||
| 2108 | case 'i_ect_notify': | ||
| 2109 | { | ||
| 2110 | if(e.session == oSipSessionCall){ | ||
| 2111 | txtCallStatus = "<i>Call Transfer: <b>" + e.getSipResponseCode() + " " + e.description + "</b></i>"; | ||
| 2112 | //simpleNotification("success","topRight",txtCallStatus); | ||
| 2113 | if (e.getSipResponseCode() >= 300) { | ||
| 2114 | if (oSipSessionCall.bHeld) { | ||
| 2115 | oSipSessionCall.resume(); | ||
| 2116 | } | ||
| 2117 | btnTransfer = false; | ||
| 2118 | } | ||
| 2119 | } | ||
| 2120 | break; | ||
| 2121 | } | ||
| 2122 | case 'i_ect_requested': | ||
| 2123 | { | ||
| 2124 | if(e.session == oSipSessionCall){ | ||
| 2125 | var s_message = "Do you accept call transfer to [" + e.getTransferDestinationFriendlyName() + "]?";//FIXME | ||
| 2126 | if (confirm(s_message)) { | ||
| 2127 | txtCallStatus = "<i>Call transfer in progress...</i>"; | ||
| 2128 | //simpleNotification("warning","topRight",txtCallStatus); | ||
| 2129 | oSipSessionCall.acceptTransfer(); | ||
| 2130 | break; | ||
| 2131 | } | ||
| 2132 | oSipSessionCall.rejectTransfer(); | ||
| 2133 | } | ||
| 2134 | break; | ||
| 2135 | } | ||
| 2136 | |||
| 2137 | } | ||
| 2138 | } | ||
| 2139 | |||
| 2140 | |||
| 2141 | function dialerSipMsg(omsg) | ||
| 2142 | { | ||
| 2143 | try | ||
| 2144 | { | ||
| 2145 | if(omsg.ao_headers[6].s_name=='kstych-data') | ||
| 2146 | { | ||
| 2147 | var vparts=omsg.ao_headers[6].s_value.split("|"); | ||
| 2148 | |||
| 2149 | vparts[1]=atob(vparts[1]); | ||
| 2150 | vparts[2]=atob(vparts[2]); | ||
| 2151 | |||
| 2152 | if(vparts[0]=="chat")incomingChat(vparts[1],vparts[2],vparts[3]); | ||
| 2153 | else if(vparts[0]=="presence")incomingPresense(vparts[1],vparts[2],vparts[3]); | ||
| 2154 | else if(vparts[0]=="wallreload")incomingwallReload(vparts[1],vparts[2],vparts[3]); | ||
| 2155 | else if(vparts[0]=="liveconf")incomingLiveconf(vparts[1],vparts[2],vparts[3]); | ||
| 2156 | else if(vparts[0]=="notify")incomingNotification(vparts[1],vparts[2],vparts[3]); | ||
| 2157 | else if(vparts[0]=="popupalert")incomingPopupAlert(vparts[1],vparts[2],vparts[3]); | ||
| 2158 | |||
| 2159 | else if(vparts[0]=="incomingCall")incomingCall(vparts[1],vparts[2],vparts[3]); | ||
| 2160 | else if(vparts[0]=="dialerUI")dialerUIUpdate(vparts[1],vparts[2],vparts[3]); | ||
| 2161 | |||
| 2162 | else if(vparts[0]=="adminCommand")adminCommand(vparts[1],vparts[2],vparts[3]); | ||
| 2163 | } | ||
| 2164 | //if(omsg.ao_headers.) | ||
| 2165 | //window.console.log(omsg.ao_headers[6]); | ||
| 2166 | } | ||
| 2167 | catch(e){} | ||
| 2168 | } |
| 1 | var loggedin=0; | ||
| 2 | |||
| 3 | var sTransferNumber; | ||
| 4 | var oRingTone, oRingbackTone; | ||
| 5 | var oSipStack, oSipSessionRegister, oSipSessionCall, oSipSessionTransferCall; | ||
| 6 | var videoRemote, videoLocal, audioRemote; | ||
| 7 | var bFullScreen = false; | ||
| 8 | var oNotifICall; | ||
| 9 | var bDisableVideo = false; | ||
| 10 | var viewLocalScreencast; // <video> (webrtc) or <div> (webrtc4all) | ||
| 11 | var oConfigCall; | ||
| 12 | var oReadyStateTimer; | ||
| 13 | |||
| 14 | var divVideo, divCallOptions; | ||
| 15 | var hangupgrowl=0; | ||
| 16 | var answergrowl=0; | ||
| 17 | var txtDisplayName, txtPrivateIdentity, txtPublicIdentity, txtRealm; | ||
| 18 | var txtPhoneNumber; | ||
| 19 | var btnCall, btnHangUp; | ||
| 20 | var txtRegStatus, txtCallStatus; | ||
| 21 | var btnRegister, btnUnRegister; | ||
| 22 | var btnFullScreen, btnHoldResume, btnTransfer, btnKeyPad; | ||
| 23 | |||
| 24 | |||
| 25 | var kstychDialer={}; | ||
| 26 | kstychDialer['mDialerState']='Paused'; | ||
| 27 | kstychDialer['mDialerSubState']='NotReady'; | ||
| 28 | kstychDialer['mDialerCampaign']=''; | ||
| 29 | kstychDialer['mdispodata']=''; | ||
| 30 | kstychDialer['mDialNextStatus']='New'; | ||
| 31 | kstychDialer['mmanualallow']='No'; | ||
| 32 | kstychDialer['pendingDataSize']=0; | ||
| 33 | kstychDialer['phone']=kstychAppObject['user']['sipid']; | ||
| 34 | kstychDialer['connection']={'number':'1000'+kstychAppObject['user']['sipid'],'connected':0,'mic':1,'speaker':1,'channel':'','holdext':''}; | ||
| 35 | kstychDialer["keeplocalconf"]=kstychAppObject['config']['kDialer_keeplocalconf']; | ||
| 36 | kstychDialer['RedialLast']=''; | ||
| 37 | |||
| 38 | var kstychCall={}; | ||
| 39 | kstychCall['mCallState']='Wait'; //states : ,Wait,Call,Dispo,Close | ||
| 40 | kstychCall['ts_Wait']=getNowTS(); | ||
| 41 | kstychCall['ts_Call']=0; | ||
| 42 | kstychCall['ts_Talk']=0; | ||
| 43 | kstychCall['ts_Dispo']=0; | ||
| 44 | kstychCall['ts_Close']=0; | ||
| 45 | kstychCall['callnumber']=''; | ||
| 46 | kstychCall['connections']={}; | ||
| 47 | kstychCall['callid']=''; | ||
| 48 | kstychCall['crmid']=''; | ||
| 49 | kstychCall['campaignid']=''; | ||
| 50 | kstychCall['listid']=''; | ||
| 51 | kstychCall['mdial_CallACK']=0; | ||
| 52 | kstychCall['mcalldata']=''; | ||
| 53 | kstychCall['userstatus']=''; | ||
| 54 | kstychCall['usersubstatus']=''; | ||
| 55 | kstychCall['usercallback']=''; | ||
| 56 | kstychCall['userremarks']=''; | ||
| 57 | kstychCall['userdata']={}; | ||
| 58 | kstychCall['previewcrmid']=''; | ||
| 59 | kstychCall['callWrapupTime']=300; | ||
| 60 | kstychCall['prograssiveDelay']=120; | ||
| 61 | kstychCall['ts_now']=0; | ||
| 62 | |||
| 63 | kstychCall['bttc_day']=''; | ||
| 64 | kstychCall['bttc_hrs']=''; | ||
| 65 | kstychCall['serv_vs_prod']=''; | ||
| 66 | kstychCall['resolution']=''; | ||
| 67 | kstychCall['satisfy']=''; | ||
| 68 | kstychCall['final_call_assess']=''; | ||
| 69 | |||
| 70 | function kGetDData(obj,key) | ||
| 71 | { | ||
| 72 | if(obj=="D") | ||
| 73 | { | ||
| 74 | if(kstychDialer[key])return kstychDialer[key]; | ||
| 75 | } | ||
| 76 | if(obj=="C") | ||
| 77 | { | ||
| 78 | if(kstychCall[key])return kstychCall[key]; | ||
| 79 | } | ||
| 80 | return false; | ||
| 81 | } | ||
| 82 | function kSetDData(obj,key,val) | ||
| 83 | { | ||
| 84 | if(obj=="D") | ||
| 85 | { | ||
| 86 | kstychDialer[key]=val; | ||
| 87 | } | ||
| 88 | if(obj=="C") | ||
| 89 | { | ||
| 90 | kstychCall[key]=val; | ||
| 91 | } | ||
| 92 | |||
| 93 | //TODO update backend user session (userlog) | ||
| 94 | return false; | ||
| 95 | } | ||
| 96 | |||
| 97 | function getNowTS() | ||
| 98 | { | ||
| 99 | return Math.floor(Date.now()); | ||
| 100 | } | ||
| 101 | |||
| 102 | function kcallNewConnection(number) | ||
| 103 | { | ||
| 104 | var clines=kGetDData('C','connections'); | ||
| 105 | if(!clines[number]) | ||
| 106 | { | ||
| 107 | clines[number]={}; | ||
| 108 | clines[number]['connected']=0; | ||
| 109 | clines[number]['channel']=''; | ||
| 110 | clines[number]['callid']=''; | ||
| 111 | clines[number]['ts_Call']=0; | ||
| 112 | clines[number]['ts_Talk']=0; | ||
| 113 | clines[number]['ts_Dispo']=0; | ||
| 114 | clines[number]['speaker']=1; | ||
| 115 | clines[number]['mic']=1; | ||
| 116 | clines[number]['holdext']=''; | ||
| 117 | kSetDData('C','connections',clines); | ||
| 118 | } | ||
| 119 | } | ||
| 120 | function kcallSetConnection(number,key,val) | ||
| 121 | { | ||
| 122 | kcallNewConnection(number); | ||
| 123 | var clines=kGetDData('C','connections'); | ||
| 124 | clines[number][key]=val; | ||
| 125 | kSetDData('C','connections',clines); | ||
| 126 | } | ||
| 127 | function kcallGetConnection(number,key) | ||
| 128 | { | ||
| 129 | kcallNewConnection(number); | ||
| 130 | var clines=kGetDData('C','connections'); | ||
| 131 | return clines[number][key]; | ||
| 132 | } | ||
| 133 | function kcallHasConnection(number) | ||
| 134 | { | ||
| 135 | var clines=kGetDData('C','connections'); | ||
| 136 | if(!clines[number])return false; | ||
| 137 | return true; | ||
| 138 | } | ||
| 139 | |||
| 140 | function dialerQuickOpen(varid,num,state,substate,autorun) | ||
| 141 | { | ||
| 142 | if(kstychCall['mCallState']=="Wait") | ||
| 143 | { | ||
| 144 | var oldpreviewid=kstychCall['previewcrmid']; | ||
| 145 | kstychCall['previewcrmid']=''; | ||
| 146 | kstychCall['callnumber']=''; | ||
| 147 | kstychCall['crmid']=''; | ||
| 148 | |||
| 149 | if(varid!=''&&varid>0) | ||
| 150 | { | ||
| 151 | if(num!=''&&num!='0') | ||
| 152 | { | ||
| 153 | kstychCall['callnumber']=num; | ||
| 154 | $("#manualdialnumber_txt").val(num); | ||
| 155 | } | ||
| 156 | |||
| 157 | if(oldpreviewid!=varid||state!=kstychDialer['mDialerState']) | ||
| 158 | { | ||
| 159 | kstychCall['previewcrmid']=varid;//progressiveDelay set to 1 //TODO | ||
| 160 | updateDialerState("dialer","mDialerState",state,"mDialerSubState",substate); | ||
| 161 | } | ||
| 162 | else | ||
| 163 | { | ||
| 164 | kstychCall['previewcrmid']=varid; | ||
| 165 | updateDialerState(); | ||
| 166 | } | ||
| 167 | kDialerModel(); | ||
| 168 | } | ||
| 169 | else | ||
| 170 | { | ||
| 171 | if(num!='') | ||
| 172 | { | ||
| 173 | $("#manualdialnumber_txt").val(num); | ||
| 174 | updateDialerState("dialer","mDialerState","Manual"); | ||
| 175 | kDialerModel(); | ||
| 176 | if(autorun==1)setTimeout(function(){$("#manualdial_btn").click()},350); | ||
| 177 | } | ||
| 178 | } | ||
| 179 | } | ||
| 180 | else | ||
| 181 | { | ||
| 182 | simpleNotification('error','topRight',"Already on call!"); | ||
| 183 | } | ||
| 184 | } | ||
| 185 | function dialerAddAlt(i,varid) | ||
| 186 | { | ||
| 187 | var phone=$("#dialer_altphone"+i).val(); | ||
| 188 | var desc=$("#dialer_altphone_lbl_"+i).val(); | ||
| 189 | |||
| 190 | if(!/^\d{10}$/.test(phone)&&!/^\d{11}$/.test(phone)) | ||
| 191 | { | ||
| 192 | simpleNotification('error','topRight',"Please enter 10 or 11 neumeric digits only"); | ||
| 193 | return; | ||
| 194 | } | ||
| 195 | if(desc=="") | ||
| 196 | { | ||
| 197 | simpleNotification('error','topRight',"Please enter number description"); | ||
| 198 | return; | ||
| 199 | } | ||
| 200 | |||
| 201 | if(phone!="") | ||
| 202 | { | ||
| 203 | var data="varid="+varid; | ||
| 204 | data+="&keys=altphone"+i+",altphone_lbl_"+i; | ||
| 205 | data+="&altphone"+i+"="+phone; | ||
| 206 | data+="&altphone_lbl_"+i+"="+desc; | ||
| 207 | |||
| 208 | doAjax('record?action=addkey',data,'dialersearchresults', 'ajax_manualdial','singlefail','POST', function(retstr){ | ||
| 209 | $("#dialersearchresults").html('<div id=divworking></div><div style="clear:both"></div>'); | ||
| 210 | showRecruit(varid); | ||
| 211 | }); | ||
| 212 | } | ||
| 213 | |||
| 214 | } | ||
| 215 | function dialerDelAlt(i,varid) | ||
| 216 | { | ||
| 217 | doAjax('record?action=delaltphone&i='+i+'&varid='+varid,'','dialersearchresults', 'ajax_manualdial','singlefail','POST', function(retstr){ | ||
| 218 | $("#dialersearchresults").html('<div id=divworking></div><div style="clear:both"></div>'); | ||
| 219 | showRecruit(varid); | ||
| 220 | }); | ||
| 221 | } | ||
| 222 | |||
| 223 | function kDialerSpy(sipid,fun) | ||
| 224 | { | ||
| 225 | var datastr="kstychCall="+JSON.stringify(kstychCall); | ||
| 226 | datastr+="&kstychDialer="+JSON.stringify(kstychDialer); | ||
| 227 | |||
| 228 | datastr+="&sipid="+sipid; | ||
| 229 | datastr+="&mode="+fun; | ||
| 230 | |||
| 231 | try{sipHangUp();}catch(e){console.log(e);} | ||
| 232 | doAjax('dialer?action=spychannel',datastr,'__fake__div__', 'ajax_spydial','singlefail','POST', function(retstr){ | ||
| 233 | |||
| 234 | }); | ||
| 235 | } | ||
| 236 | function kCallAction(num,action) | ||
| 237 | { | ||
| 238 | //action : MuteSpeaker,UnMuteSpeaker,MuteMic,UnMuteMic,Hangup,Hold,UnHold | ||
| 239 | if(num=="u") | ||
| 240 | { | ||
| 241 | if(action=="MuteMic")kstychDialer['connection']['mic']=sipToggleMute(); | ||
| 242 | if(action=="UnMuteMic")kstychDialer['connection']['mic']=sipToggleMute(); | ||
| 243 | if(action=="MuteSpeaker"); | ||
| 244 | if(action=="UnMuteSpeaker"); | ||
| 245 | if(action=="Hangup"); | ||
| 246 | //if(action=="Hold"); | ||
| 247 | //if(action=="UnHold"); | ||
| 248 | } | ||
| 249 | else | ||
| 250 | { | ||
| 251 | if(num=="c")num=kstychCall['callnumber']; | ||
| 252 | var channel=kcallGetConnection(num,'channel'); | ||
| 253 | if(channel!='') | ||
| 254 | { | ||
| 255 | if(action=="MuteMic")kcallSetConnection(num,'mic',0); | ||
| 256 | if(action=="UnMuteMic")kcallSetConnection(num,'mic',1); | ||
| 257 | if(action=="MuteSpeaker")kcallSetConnection(num,'speaker',0); | ||
| 258 | if(action=="UnMuteSpeaker")kcallSetConnection(num,'speaker',1); | ||
| 259 | if(action=="Hangup"); | ||
| 260 | //if(action=="Hold")kcallSetConnection(num,'holdext'); | ||
| 261 | //if(action=="UnHold")kcallSetConnection(num,'holdext'); | ||
| 262 | |||
| 263 | doAjax('dialer?action=kCallAction&actiontype='+action+'&conf='+kstychDialer['connection']['number']+'&channel='+channel,'','__fake__div__', 'ajax_confdial','singlefail','POST', function(retstr){ | ||
| 264 | |||
| 265 | }); | ||
| 266 | } | ||
| 267 | else simpleNotification('error','topRight',"No Channel for ["+num+"]"); | ||
| 268 | } | ||
| 269 | |||
| 270 | updateDialerState(); | ||
| 271 | } | ||
| 272 | |||
| 273 | function dialerDispNumberClick() | ||
| 274 | { | ||
| 275 | var lastnumber=$("#spandialer_num").html(); | ||
| 276 | |||
| 277 | if(kstychCall['mCallState']=="Dispo") | ||
| 278 | { | ||
| 279 | saveCloseDialerCall("REDIAL"); | ||
| 280 | } | ||
| 281 | } | ||
| 282 | function dialerAddConfCall() | ||
| 283 | { | ||
| 284 | var confnumber=$("#dialerConfNumberTxt").val(); | ||
| 285 | if(confnumber==''||confnumber.length<2) | ||
| 286 | { | ||
| 287 | simpleNotification('error','topRight',"Empty Number"); | ||
| 288 | return; | ||
| 289 | } | ||
| 290 | |||
| 291 | if(!kcallHasConnection(kstychCall['callnumber'])||kstychCall['ts_Dispo']>1) | ||
| 292 | { | ||
| 293 | simpleNotification('error','topRight',"No call to conference"); | ||
| 294 | return; | ||
| 295 | } | ||
| 296 | |||
| 297 | var datastr="kstychCall="+JSON.stringify(kstychCall); | ||
| 298 | datastr+="&kstychDialer="+JSON.stringify(kstychDialer); | ||
| 299 | |||
| 300 | kcallNewConnection(confnumber); | ||
| 301 | doAjax('dialer?action=addconfcall&confnumber='+confnumber,datastr,'__fake__div__', 'ajax_confdial','singlefail','POST', function(retstr){ | ||
| 302 | if(retstr.responseText.indexOf('Error')<0) | ||
| 303 | { | ||
| 304 | kcallSetConnection(confnumber,'callid',retstr.responseText); | ||
| 305 | kcallSetConnection(confnumber,'ts_Call',getNowTS()); | ||
| 306 | |||
| 307 | updateDialerState(); | ||
| 308 | } | ||
| 309 | else | ||
| 310 | { | ||
| 311 | simpleNotification('error','topRight',retstr.responseText); | ||
| 312 | } | ||
| 313 | }); | ||
| 314 | } | ||
| 315 | |||
| 316 | function incomingCall(calllog,crmid,number) | ||
| 317 | { | ||
| 318 | $("#dialersearchresults").html('<div id=divworking></div><div style="clear:both"></div>'); | ||
| 319 | |||
| 320 | kcallSetConnection(number,'callid',calllog); | ||
| 321 | kcallSetConnection(number,'connected',1); | ||
| 322 | |||
| 323 | kSetDData('C','callid',calllog); | ||
| 324 | kSetDData('C','crmid',crmid); | ||
| 325 | |||
| 326 | if(crmid>0)showRecruit(crmid); | ||
| 327 | else | ||
| 328 | { | ||
| 329 | createSearchRecordDiv('dialersearchresults'); | ||
| 330 | } | ||
| 331 | |||
| 332 | kSetDData('C','mCallState','Call'); | ||
| 333 | kSetDData('C','ts_Call',getNowTS()); | ||
| 334 | kSetDData('C','ts_Talk',getNowTS()); | ||
| 335 | |||
| 336 | kstychCall["callnumber"]=number; | ||
| 337 | |||
| 338 | updateDialerState(); | ||
| 339 | kDialerModel(); | ||
| 340 | } | ||
| 341 | |||
| 342 | function dialerUIUpdate(var1,var2,var3) | ||
| 343 | { | ||
| 344 | var3parts=var3.split("~"); | ||
| 345 | var3parts[2]=atob(var3parts[2]); | ||
| 346 | if(var1=="dialstart") | ||
| 347 | { | ||
| 348 | if(var2=="c") | ||
| 349 | { | ||
| 350 | if(var3parts[1]&&var3parts[1]!="") | ||
| 351 | { | ||
| 352 | kcallSetConnection(var3parts[1],'connected',1); | ||
| 353 | kcallSetConnection(var3parts[1],'channel',var3parts[2]); | ||
| 354 | kcallSetConnection(var3parts[1],'ts_Call',getNowTS()); | ||
| 355 | if(var3parts[1]==kstychCall['callnumber'])kSetDData('C','ts_Call',getNowTS()); | ||
| 356 | |||
| 357 | updateDialerState(); | ||
| 358 | } | ||
| 359 | } | ||
| 360 | else if(var2=="u") | ||
| 361 | { | ||
| 362 | var dialerConnection=kGetDData("D","connection"); | ||
| 363 | dialerConnection['channel']=var3parts[2]; | ||
| 364 | kSetDData("D","connection",dialerConnection); | ||
| 365 | } | ||
| 366 | } | ||
| 367 | |||
| 368 | if(var1=="dialend") | ||
| 369 | { | ||
| 370 | if(var2=="c") | ||
| 371 | { | ||
| 372 | if(var3parts[1]&&var3parts[1]!="") | ||
| 373 | { | ||
| 374 | kcallSetConnection(var3parts[1],'connected',1); | ||
| 375 | kcallSetConnection(var3parts[1],'channel',var3parts[2]); | ||
| 376 | kcallSetConnection(var3parts[1],'ts_Talk',getNowTS()); | ||
| 377 | if(var3parts[1]==kstychCall['callnumber'])kSetDData('C','ts_Talk',getNowTS()); | ||
| 378 | |||
| 379 | updateDialerState(); | ||
| 380 | } | ||
| 381 | } | ||
| 382 | } | ||
| 383 | |||
| 384 | if(var1=="hangup") | ||
| 385 | { | ||
| 386 | if(var2=="c") | ||
| 387 | { | ||
| 388 | if(var3parts[1]&&var3parts[1]!="") | ||
| 389 | { | ||
| 390 | kcallSetConnection(var3parts[1],'connected',0); | ||
| 391 | if(kcallGetConnection(var3parts[1],'ts_Call')==0)kcallSetConnection(var3parts[1],'ts_Call',getNowTS()); | ||
| 392 | if(kcallGetConnection(var3parts[1],'ts_Talk')==0)kcallSetConnection(var3parts[1],'ts_Talk',getNowTS()); | ||
| 393 | kcallSetConnection(var3parts[1],'ts_Dispo',getNowTS()); | ||
| 394 | |||
| 395 | if(var3parts[1]==kstychCall['callnumber']) | ||
| 396 | { | ||
| 397 | if(kstychCall['ts_Call']==0)kSetDData('C','ts_Call',getNowTS()); | ||
| 398 | if(kstychCall['ts_Talk']==0)kSetDData('C','ts_Talk',getNowTS()); | ||
| 399 | |||
| 400 | kSetDData('C','ts_Dispo',getNowTS()); | ||
| 401 | hangupCall(); | ||
| 402 | } | ||
| 403 | |||
| 404 | updateDialerState(); | ||
| 405 | } | ||
| 406 | } | ||
| 407 | } | ||
| 408 | } | ||
| 409 | |||
| 410 | function incomingPopupAlert(var1,var2,var3) | ||
| 411 | { | ||
| 412 | //var incomingnotify=growlSNotify(var1,var2,"top-right"); | ||
| 413 | //setTimeout(function(){$.gritter.remove(incomingnotify, {fade: true,speed: 'slow'});incomingnotify=0;},1500); | ||
| 414 | |||
| 415 | $.titleAlert(var1+" "+var2, { | ||
| 416 | requireBlur:true, | ||
| 417 | stopOnFocus:true, | ||
| 418 | duration:1500, | ||
| 419 | interval:500 | ||
| 420 | }); | ||
| 421 | |||
| 422 | kDesktopNotification("",var1,var2,1500); | ||
| 423 | } | ||
| 424 | |||
| 425 | function outgoingCall() | ||
| 426 | { | ||
| 427 | $("#dialersearchresults").html(""); | ||
| 428 | kSetDData('C','callnumber',$("#manualdialnumber_txt").val()); | ||
| 429 | |||
| 430 | var datastr="kstychCall="+JSON.stringify(kstychCall); | ||
| 431 | datastr+="&kstychDialer="+JSON.stringify(kstychDialer); | ||
| 432 | |||
| 433 | if(kstychDialer['mDialerState']=="Manual") | ||
| 434 | { | ||
| 435 | if(kstychCall['callnumber']!="") | ||
| 436 | { | ||
| 437 | doAjax('dialer?action=newcall',datastr,'dialersearchresults', 'ajax_manualdial','singlefail','POST', function(retstr){ | ||
| 438 | if(kstychCall['crmid']!="") | ||
| 439 | { | ||
| 440 | kSetDData('C','mCallState','Call'); | ||
| 441 | kSetDData('C','ts_Call',getNowTS()); | ||
| 442 | |||
| 443 | if(kstychCall['crmid']==0) | ||
| 444 | { | ||
| 445 | createSearchRecordDiv('dialersearchresults'); | ||
| 446 | } | ||
| 447 | updateDialerState(); | ||
| 448 | } | ||
| 449 | else | ||
| 450 | { | ||
| 451 | kSetDData('C','previewcrmid',''); | ||
| 452 | updateDialerState("dialer","mDialerState","Manual"); | ||
| 453 | } | ||
| 454 | }); | ||
| 455 | } | ||
| 456 | else | ||
| 457 | { | ||
| 458 | simpleNotification('error','topRight',"Empty Number"); | ||
| 459 | } | ||
| 460 | } | ||
| 461 | if(kstychDialer['mDialerState']=="DialNext") | ||
| 462 | { | ||
| 463 | doAjax('dialer?action=newcall',datastr,'dialersearchresults', 'ajax_manualdial','singlefail','POST', function(retstr){ | ||
| 464 | if(kstychCall['crmid']!="") | ||
| 465 | { | ||
| 466 | kSetDData('C','mCallState','Call'); | ||
| 467 | kSetDData('C','ts_Call',getNowTS()); | ||
| 468 | |||
| 469 | updateDialerState(); | ||
| 470 | } | ||
| 471 | else | ||
| 472 | { | ||
| 473 | simpleNotification('error','topRight',"Failed to Dial Next ["+kstychDialer['mDialNextStatus']+"] Record"); | ||
| 474 | |||
| 475 | kSetDData('C','previewcrmid',''); | ||
| 476 | updateDialerState("dialer","mDialerState","DialNext"); | ||
| 477 | } | ||
| 478 | }); | ||
| 479 | } | ||
| 480 | if(kstychDialer['mDialerState']=="Progressive") | ||
| 481 | { | ||
| 482 | doAjax('dialer?action=newcall',datastr,'dialersearchresults', 'ajax_manualdial','singlefail','POST', function(retstr){ | ||
| 483 | if(kstychCall['crmid']!="") | ||
| 484 | { | ||
| 485 | kSetDData('C','mCallState','Call'); | ||
| 486 | kSetDData('C','ts_Call',getNowTS()); | ||
| 487 | |||
| 488 | updateDialerState(); | ||
| 489 | } | ||
| 490 | else | ||
| 491 | { | ||
| 492 | simpleNotification('error','topRight',"Failed to Dial Next ["+kstychDialer['mDialNextStatus']+"] Record"); | ||
| 493 | //Cleanup? | ||
| 494 | |||
| 495 | kSetDData('C','previewcrmid',''); | ||
| 496 | updateDialerState("dialer","mDialerState","DialNext"); | ||
| 497 | } | ||
| 498 | }); | ||
| 499 | } | ||
| 500 | |||
| 501 | |||
| 502 | //check if current state is valid to make a call | ||
| 503 | //prepare ajax parameters | ||
| 504 | //call dialer controller to submit request | ||
| 505 | //check return values for success | ||
| 506 | //update dialer and call objects | ||
| 507 | } | ||
| 508 | function hangupCall() | ||
| 509 | { | ||
| 510 | kstychCall['ts_now']=getNowTS(); | ||
| 511 | |||
| 512 | var datastr="kstychCall="+JSON.stringify(kstychCall); | ||
| 513 | datastr+="&kstychDialer="+JSON.stringify(kstychDialer); | ||
| 514 | doAjax('dialer?action=hangupall',datastr,'', 'ajax_manualdial','singlefail','POST', | ||
| 515 | function(retstr){ | ||
| 516 | |||
| 517 | if(retstr.responseText.indexOf('Error')<0) | ||
| 518 | { | ||
| 519 | kSetDData('C','mCallState',"Dispo"); | ||
| 520 | kSetDData('C','ts_Dispo',getNowTS()); | ||
| 521 | |||
| 522 | if(kstychDialer["keeplocalconf"]==0) | ||
| 523 | { | ||
| 524 | try{sipHangUp();}catch(e){console.log(e);} | ||
| 525 | var dialerConnection=kGetDData("D","connection"); | ||
| 526 | dialerConnection['connected']=0; | ||
| 527 | dialerConnection['channel']=''; | ||
| 528 | updateDialerState("dialer","connection",dialerConnection); | ||
| 529 | } | ||
| 530 | else updateDialerState(); | ||
| 531 | } | ||
| 532 | else | ||
| 533 | { | ||
| 534 | simpleNotification('error','topRight',retstr.responseText); | ||
| 535 | updateDialerState(); | ||
| 536 | } | ||
| 537 | }); | ||
| 538 | } | ||
| 539 | function saveCloseDialerCall(flag) | ||
| 540 | { | ||
| 541 | kstychCall['userstatus']=$('#dialer_userstatus').val(); | ||
| 542 | kstychCall['usersubstatus']=$('#dialer_usersubstatus').val(); | ||
| 543 | kstychCall['usercallback']=$('#dialer_usercallback').val(); | ||
| 544 | kstychCall['userremarks']=$('#dialer_userremarks').val(); | ||
| 545 | kstychCall['userflag']=$('#dialer_flag').val(); | ||
| 546 | kstychCall['priority']=$('#priority').val(); | ||
| 547 | |||
| 548 | kstychCall['bttc_day']=$('#bttc_day').val(); | ||
| 549 | kstychCall['bttc_hrs']=$('#bttc_hrs').val(); | ||
| 550 | kstychCall['serv_vs_prod']=$('#serv_vs_prod').val(); | ||
| 551 | kstychCall['resolution']=$('#resolution').val(); | ||
| 552 | kstychCall['satisfy']=$('#satisfy').val(); | ||
| 553 | kstychCall['final_call_assess']=$('#final_call_assess').val(); | ||
| 554 | |||
| 555 | if(typeof customerDispofields != 'undefined')kstychCall['userdata']=customerDispofields; | ||
| 556 | |||
| 557 | if(flag=="AUTOWRAPUP") | ||
| 558 | { | ||
| 559 | kstychCall['userstatus']="AUTOWRAPUP"; | ||
| 560 | kstychCall['usersubstatus']="AUTOWRAPUP"; | ||
| 561 | $('#dialer_usercallback').val(""); | ||
| 562 | kstychCall['usercallback']=""; | ||
| 563 | kstychCall['userremarks']=""; | ||
| 564 | kstychCall['userflag']=""; | ||
| 565 | } | ||
| 566 | else if(flag=="REDIAL") | ||
| 567 | { | ||
| 568 | kstychCall['userstatus']="REDIAL"; | ||
| 569 | kstychCall['usersubstatus']="REDIAL"; | ||
| 570 | $('#dialer_usercallback').val(""); | ||
| 571 | kstychCall['usercallback']=""; | ||
| 572 | kstychCall['userremarks']=""; | ||
| 573 | kstychCall['userflag']=""; | ||
| 574 | |||
| 575 | kstychDialer['RedialLast']='Yes'; | ||
| 576 | } | ||
| 577 | else if(!$('#dialer_userstatus').length) | ||
| 578 | { | ||
| 579 | kstychCall['userstatus']="NORECORD"; | ||
| 580 | kstychCall['usersubstatus']="NORECORD"; | ||
| 581 | kstychCall['usercallback']=""; | ||
| 582 | kstychCall['userremarks']=""; | ||
| 583 | kstychCall['userflag']=""; | ||
| 584 | |||
| 585 | $('#dialer_usercallback').val(""); | ||
| 586 | } | ||
| 587 | else | ||
| 588 | { | ||
| 589 | |||
| 590 | |||
| 591 | if(kstychCall['userstatus']==""||kstychCall['usersubstatus']=="") | ||
| 592 | { | ||
| 593 | simpleNotification('error','topRight',"Please Select Disposition and Subdisposition"); | ||
| 594 | return; | ||
| 595 | } | ||
| 596 | |||
| 597 | //For $ dropdown Condition - Changes done By Manish on 27-10-16 | ||
| 598 | /*if(kstychCall['userstatus']=="Contacted - FollowUp - Specific" || kstychCall['userstatus']=="Contacted - Follow-Up - Generic") | ||
| 599 | { | ||
| 600 | if(kstychCall['final_call_assess']==""&&kstychCall['serv_vs_prod']==""&&kstychCall['resolution']==""&&kstychCall['satisfy']=="") | ||
| 601 | { | ||
| 602 | simpleNotification('Error','topRight',"Please Select ALL(Service vs Product and Resolution and Satisfaction and Final_call_Assessment)"); | ||
| 603 | return; | ||
| 604 | } | ||
| 605 | }*/ | ||
| 606 | |||
| 607 | if(kstychCall['userstatus'].toLowerCase().indexOf("followup")>-1||kstychCall['userstatus'].toLowerCase().indexOf("callback")>-1) | ||
| 608 | { | ||
| 609 | if($('#dialer_usercallback').val()=="") | ||
| 610 | { | ||
| 611 | simpleNotification('error','topRight',"Please select Callback date within one month in future"); | ||
| 612 | return; | ||
| 613 | } | ||
| 614 | } | ||
| 615 | else | ||
| 616 | { | ||
| 617 | if($('#dialer_usercallback').val()!="") | ||
| 618 | { | ||
| 619 | simpleNotification('error','topRight',"You Cannot input Callback date time in this Disposition"); | ||
| 620 | return; | ||
| 621 | } | ||
| 622 | } | ||
| 623 | |||
| 624 | |||
| 625 | var date1 = new Date(); | ||
| 626 | var date2 = new Date($('#dialer_usercallback').val()); | ||
| 627 | var diff = date2.getTime() - date1.getTime(); | ||
| 628 | if(diff<0||diff>30*24*60*60*1000) | ||
| 629 | { | ||
| 630 | simpleNotification('error','topRight',"Please select Callback date within one month in future"); | ||
| 631 | return; | ||
| 632 | } | ||
| 633 | var hours = date2.getHours(); | ||
| 634 | var mins = date2.getMinutes(); | ||
| 635 | var fullhour=hours+(mins/60); | ||
| 636 | if(fullhour<9||fullhour>19) | ||
| 637 | { | ||
| 638 | simpleNotification('error','topRight',"Please select Callback Time date within 9AM and 7PM"); | ||
| 639 | return; | ||
| 640 | } | ||
| 641 | |||
| 642 | } | ||
| 643 | |||
| 644 | if($("#recruitsavedata").length)$("#recruitsavedata").click();//TODO hold div in reset, or any error will be lost | ||
| 645 | |||
| 646 | var datastr="kstychCall="+JSON.stringify(kstychCall); | ||
| 647 | datastr+="&kstychDialer="+JSON.stringify(kstychDialer); | ||
| 648 | doAjax('dialer?action=closecall',datastr,'', 'ajax_manualdial','singlefail','POST', | ||
| 649 | function(retstr){ | ||
| 650 | kSetDData('C','mCallState',"Close"); | ||
| 651 | kSetDData('C','ts_Close',getNowTS()); | ||
| 652 | updateDialerState("action","reset",""); | ||
| 653 | }); | ||
| 654 | |||
| 655 | //Dialog box after Save & Close-Taking from KFormLib.php | ||
| 656 | $finalCallAssess = $('#final_call_assess').val(); | ||
| 657 | |||
| 658 | if($finalCallAssess == 'Very Good Call With Customer') | ||
| 659 | { | ||
| 660 | /*$.gritter.add({ | ||
| 661 | title: 'type', | ||
| 662 | text: 'text', | ||
| 663 | class_name: 'gritter-b-center' | ||
| 664 | });*/ | ||
| 665 | $('#goodCall').dialog({ | ||
| 666 | modal: true, | ||
| 667 | position: ['center'], | ||
| 668 | resizable: false, | ||
| 669 | closeOnEscape: false, | ||
| 670 | open: function(event, ui){ | ||
| 671 | $(".ui.dialog-titlebar-close", ui.dialog | ui).hide(); | ||
| 672 | setTimeout(function(){$('#goodCall').dialog('close');},5000); | ||
| 673 | } | ||
| 674 | }); | ||
| 675 | |||
| 676 | //setTimeout(function(){$('#goodCall').dialog('close');},5000); | ||
| 677 | } | ||
| 678 | |||
| 679 | if($finalCallAssess == 'Ok Call') | ||
| 680 | { | ||
| 681 | $('#okCall').dialog({ | ||
| 682 | open: function(event, ui){ | ||
| 683 | $(this).css({'max-height':500, 'overflow-y':'auto'}); | ||
| 684 | }, | ||
| 685 | modal: true, | ||
| 686 | position: ['center'], | ||
| 687 | resizable: false, | ||
| 688 | closeOnEscape: false}); | ||
| 689 | |||
| 690 | setTimeout(function(){$('#okCall').dialog('close');},5000); | ||
| 691 | } | ||
| 692 | |||
| 693 | if($finalCallAssess == 'Not Interested Customer') | ||
| 694 | { | ||
| 695 | $('#notInterest').dialog({ | ||
| 696 | open: function(event, ui){ | ||
| 697 | $(this).css({'max-height':500, 'overflow-y':'auto'}); | ||
| 698 | }, | ||
| 699 | modal: true, | ||
| 700 | position: ['center'], | ||
| 701 | resizable: false, | ||
| 702 | closeOnEscape: false}); | ||
| 703 | |||
| 704 | setTimeout(function(){$('#notInterest').dialog('close');},5000); | ||
| 705 | } | ||
| 706 | |||
| 707 | if($finalCallAssess == 'Iritated Customer') | ||
| 708 | { | ||
| 709 | $('#iritCust').dialog({ | ||
| 710 | open: function(event, ui){ | ||
| 711 | $(this).css({'max-height':500, 'overflow-y':'auto'}); | ||
| 712 | }, | ||
| 713 | modal: true, | ||
| 714 | position: ['center'], | ||
| 715 | resizable: false, | ||
| 716 | closeOnEscape: false}); | ||
| 717 | |||
| 718 | setTimeout(function(){$('#iritCust').dialog('close');},5000); | ||
| 719 | } | ||
| 720 | |||
| 721 | if($finalCallAssess == 'Angry') | ||
| 722 | { | ||
| 723 | $('#angry').dialog({ | ||
| 724 | open: function(event, ui){ | ||
| 725 | $(this).css({'max-height':500, 'overflow-y':'auto'}); | ||
| 726 | }, | ||
| 727 | modal: true, | ||
| 728 | position: ['center'], | ||
| 729 | resizable: false, | ||
| 730 | closeOnEscape: false}); | ||
| 731 | |||
| 732 | setTimeout(function(){$('#angry').dialog('close');},5000); | ||
| 733 | } | ||
| 734 | } | ||
| 735 | |||
| 736 | function showWrapUp() | ||
| 737 | { | ||
| 738 | kstychCall['userstatus']="Paused"; | ||
| 739 | kstychCall['usersubstatus']="WRAPUP"; | ||
| 740 | $('#dialer_usercallback').val(""); | ||
| 741 | kstychCall['usercallback']=""; | ||
| 742 | kstychCall['userremarks']=""; | ||
| 743 | kstychCall['userflag']=""; | ||
| 744 | |||
| 745 | var datastr="kstychCall="+JSON.stringify(kstychCall); | ||
| 746 | datastr+="&kstychDialer="+JSON.stringify(kstychDialer); | ||
| 747 | doAjax('dialer?action=wrapup',datastr,'', 'ajax_manualdial','singlefail','POST', | ||
| 748 | function(retstr){ | ||
| 749 | dialerTimersUpdate(); | ||
| 750 | }); | ||
| 751 | } | ||
| 752 | |||
| 753 | function resetDialer() | ||
| 754 | { | ||
| 755 | if(kstychDialer['RedialLast']=="Yes") | ||
| 756 | { | ||
| 757 | kstychDialer['RedialLast']=''; | ||
| 758 | |||
| 759 | kSetDData('C','mCallState',"Wait"); | ||
| 760 | kSetDData('C','ts_Wait',getNowTS()); | ||
| 761 | kSetDData('C','ts_Call',0); | ||
| 762 | kSetDData('C','ts_Talk',0); | ||
| 763 | kSetDData('C','ts_Dispo',0); | ||
| 764 | kSetDData('C','ts_Close',0); | ||
| 765 | |||
| 766 | updateDialerState("action","dialnext"); | ||
| 767 | |||
| 768 | return; | ||
| 769 | } | ||
| 770 | |||
| 771 | |||
| 772 | var dialerResetForceState=kstychDialer['mDialerState']; | ||
| 773 | var dialerResetForceSubState=kstychDialer['mDialerSubState']; | ||
| 774 | |||
| 775 | dialerResetForceState="Progressive";//Hardcoded TODO change to config | ||
| 776 | dialerResetForceSubState=""; | ||
| 777 | |||
| 778 | if(kstychCall['userstatus']=="AUTOWRAPUP") | ||
| 779 | { | ||
| 780 | dialerResetForceState="Paused"; | ||
| 781 | dialerResetForceSubState="AUTOWRAPUP"; | ||
| 782 | } | ||
| 783 | |||
| 784 | if(kstychCall['userstatus']=="WRAPUP") | ||
| 785 | { | ||
| 786 | dialerResetForceState="Paused"; | ||
| 787 | dialerResetForceSubState="WRAPUP"; | ||
| 788 | } | ||
| 789 | |||
| 790 | //TODO check hangup any connections? | ||
| 791 | |||
| 792 | $("#dialersearchresults").html("");//CANNOT clear this until we have a solution of error handling in save form | ||
| 793 | $("#manualdialnumber_txt").val(""); | ||
| 794 | |||
| 795 | resetCallArray(); | ||
| 796 | |||
| 797 | $("#dialersearchbox").html(""); | ||
| 798 | $(".dialer_conf_divs").remove(); | ||
| 799 | |||
| 800 | updateDialerState("dialer","mDialerState",dialerResetForceState,"mDialerSubState",dialerResetForceSubState); | ||
| 801 | |||
| 802 | } | ||
| 803 | function resetCallArray() | ||
| 804 | { | ||
| 805 | kSetDData('C','mCallState',"Wait"); | ||
| 806 | kSetDData('C','ts_Wait',getNowTS()); | ||
| 807 | kSetDData('C','ts_Call',0); | ||
| 808 | kSetDData('C','ts_Talk',0); | ||
| 809 | kSetDData('C','ts_Dispo',0); | ||
| 810 | kSetDData('C','ts_Close',0); | ||
| 811 | kSetDData('C','callnumber',""); | ||
| 812 | kSetDData('C','connections',{}); | ||
| 813 | kSetDData('C','callid',""); | ||
| 814 | kSetDData('C','crmid',""); | ||
| 815 | kSetDData('C','campaignid',""); | ||
| 816 | kSetDData('C','listid',""); | ||
| 817 | kSetDData('C','mdial_CallACK',""); | ||
| 818 | kSetDData('C','mcalldata',""); | ||
| 819 | |||
| 820 | kSetDData('C','userstatus',""); | ||
| 821 | kSetDData('C','usersubstatus',""); | ||
| 822 | kSetDData('C','usercallback',""); | ||
| 823 | kSetDData('C','userremarks',""); | ||
| 824 | kSetDData('C','userflag',""); | ||
| 825 | kSetDData('C','bttc_day',""); | ||
| 826 | kSetDData('C','bttc_hrs',""); | ||
| 827 | kSetDData('C','serv_vs_prod',""); | ||
| 828 | kSetDData('C','resolution',""); | ||
| 829 | kSetDData('C','satisfy',""); | ||
| 830 | kSetDData('C','final_call_assess',""); | ||
| 831 | kSetDData('C','userdata',{}); | ||
| 832 | if(typeof customerDispofields != 'undefined')customerDispofields={}; | ||
| 833 | |||
| 834 | kSetDData('C','previewcrmid',""); | ||
| 835 | kSetDData('C','callWrapupTime',300); | ||
| 836 | kSetDData('C','prograssiveDelay',120); | ||
| 837 | } | ||
| 838 | |||
| 839 | function updateDialerState(objstr,key,val,key2,val2) | ||
| 840 | { | ||
| 841 | if(objstr=="dialer") | ||
| 842 | { | ||
| 843 | kSetDData("D",key,val); | ||
| 844 | kSetDData("D",key2,val2); | ||
| 845 | if(key=='mDialerState') | ||
| 846 | { | ||
| 847 | if(!key2||key2=="")kSetDData("D","mDialerSubState",""); | ||
| 848 | |||
| 849 | if(val=="Paused") | ||
| 850 | { | ||
| 851 | resetCallArray(); | ||
| 852 | } | ||
| 853 | |||
| 854 | $("#dialersearchresults").html(""); | ||
| 855 | kSetDData('C','ts_Wait',getNowTS());//TODO reset here? | ||
| 856 | |||
| 857 | var datastr="kstychCall="+JSON.stringify(kstychCall); | ||
| 858 | datastr+="&kstychDialer="+JSON.stringify(kstychDialer); | ||
| 859 | doAjax('dialer?action=dialerstate',datastr,'', 'ajax_manualdial','singlefail','POST', | ||
| 860 | function(retstr){ | ||
| 861 | |||
| 862 | if(val=="Progressive"||(kstychCall['previewcrmid']!=""&&kstychCall['previewcrmid']>0)) | ||
| 863 | { | ||
| 864 | if(kstychCall['final_call_assess']=='' || kstychCall['final_call_assess']!=undefined){ | ||
| 865 | setTimeout(function(){doAjax('dialer?action=previewnext',datastr,'dialersearchresults', 'ajax_manualdial2','singlefail','POST', | ||
| 866 | function(retstr){ | ||
| 867 | if(kstychCall['previewcrmid']!="") | ||
| 868 | { | ||
| 869 | updateDialerState(); | ||
| 870 | } | ||
| 871 | else | ||
| 872 | { | ||
| 873 | resetCallArray(); | ||
| 874 | simpleNotification('error','topRight',"Failed to Dial Next Record"); | ||
| 875 | updateDialerState("dialer","mDialerState","DialNext"); | ||
| 876 | } | ||
| 877 | });},4000); | ||
| 878 | }else | ||
| 879 | { | ||
| 880 | doAjax('dialer?action=previewnext',datastr,'dialersearchresults', 'ajax_manualdial2','singlefail','POST', | ||
| 881 | function(retstr){ | ||
| 882 | if(kstychCall['previewcrmid']!="") | ||
| 883 | { | ||
| 884 | updateDialerState(); | ||
| 885 | } | ||
| 886 | else | ||
| 887 | { | ||
| 888 | resetCallArray(); | ||
| 889 | simpleNotification('error','topRight',"Failed to Dial Next Record"); | ||
| 890 | updateDialerState("dialer","mDialerState","DialNext"); | ||
| 891 | } | ||
| 892 | }); | ||
| 893 | } | ||
| 894 | |||
| 895 | } | ||
| 896 | |||
| 897 | updateDialerState(); | ||
| 898 | }); | ||
| 899 | } | ||
| 900 | } | ||
| 901 | if(objstr=="call") | ||
| 902 | { | ||
| 903 | kSetDData('C',key,val); | ||
| 904 | kSetDData("C",key2,val2); | ||
| 905 | } | ||
| 906 | |||
| 907 | if(objstr=="action") | ||
| 908 | { | ||
| 909 | if(key=="dialnext") | ||
| 910 | { | ||
| 911 | outgoingCall(); | ||
| 912 | } | ||
| 913 | if(key=="hangupall") | ||
| 914 | { | ||
| 915 | hangupCall(); | ||
| 916 | } | ||
| 917 | if(key=="saveclose") | ||
| 918 | { | ||
| 919 | saveCloseDialerCall(); | ||
| 920 | } | ||
| 921 | if(key=="reset") | ||
| 922 | { | ||
| 923 | resetDialer(); | ||
| 924 | } | ||
| 925 | } | ||
| 926 | |||
| 927 | updateDialerUI(); | ||
| 928 | ////////////////////////////////////////////////////////////// | ||
| 929 | if(objstr=="")return; | ||
| 930 | |||
| 931 | //$("#kTopBarExtra").parent().addClass("open"); | ||
| 932 | |||
| 933 | //run this function on every state change? | ||
| 934 | //take dialer and call objects and send to controller for update | ||
| 935 | } | ||
| 936 | function updateDialerUI() | ||
| 937 | { | ||
| 938 | $("#spandialer_num").html(kstychCall["callnumber"]); | ||
| 939 | if(kstychCall["callnumber"]!="")$("#dialertimes2").show(); | ||
| 940 | else $("#dialertimes2").hide(); | ||
| 941 | |||
| 942 | if($("#dialerManualAllowLI").length)kSetDData("D",'mmanualallow','Yes'); | ||
| 943 | |||
| 944 | ////////////////////////////////////////////////////////////// | ||
| 945 | var statestr="<i class='fa fa-phone'></i> : "+kstychDialer['mDialerState']; | ||
| 946 | if(kstychDialer['mDialerState']=="Paused")statestr="<i class='fa fa-pause'></i> : "+kstychDialer['mDialerSubState']; | ||
| 947 | if(kstychDialer['mDialerState']=="Ready")statestr="<i class='fa fa-phone'></i> : "+kstychDialer['mDialerSubState']; | ||
| 948 | $("#dialerstate_btn").html(statestr); | ||
| 949 | |||
| 950 | |||
| 951 | if(kstychDialer['mDialerState']=="Paused") | ||
| 952 | { | ||
| 953 | $("#dialerstate_div").width("150px"); | ||
| 954 | $("#manualdial_btn").hide();$("#manualdialnumber_txt").hide(); | ||
| 955 | $("#dialerstate_btn").parent().removeClass("rounded-left"); | ||
| 956 | $("#dialerstate_btn").parent().removeClass("btn-info").addClass("btn-primary"); | ||
| 957 | } | ||
| 958 | else if(kstychDialer['mDialerState']=="Ready") | ||
| 959 | { | ||
| 960 | $("#dialerstate_div").width("150px"); | ||
| 961 | $("#manualdial_btn").show();$("#manualdialnumber_txt").hide(); | ||
| 962 | $("#dialerstate_btn").parent().addClass("rounded-left"); | ||
| 963 | $("#dialerstate_btn").parent().removeClass("btn-primary").addClass("btn-info"); | ||
| 964 | } | ||
| 965 | else if(kstychDialer['mDialerState']=="Manual") | ||
| 966 | { | ||
| 967 | $("#dialerstate_div").width("350px"); | ||
| 968 | $("#manualdial_btn").show();$("#manualdialnumber_txt").show(); | ||
| 969 | $("#dialerstate_btn").parent().addClass("rounded-left"); | ||
| 970 | $("#dialerstate_btn").parent().removeClass("btn-primary").addClass("btn-info"); | ||
| 971 | } | ||
| 972 | else if(kstychDialer['mDialerState']=="DialNext") | ||
| 973 | { | ||
| 974 | $("#dialerstate_div").width("150px"); | ||
| 975 | $("#manualdial_btn").show();$("#manualdialnumber_txt").hide(); | ||
| 976 | $("#dialerstate_btn").parent().addClass("rounded-left"); | ||
| 977 | $("#dialerstate_btn").parent().removeClass("btn-primary").addClass("btn-info"); | ||
| 978 | } | ||
| 979 | else if(kstychDialer['mDialerState']=="Progressive") | ||
| 980 | { | ||
| 981 | $("#dialerstate_div").width("150px"); | ||
| 982 | $("#manualdial_btn").show();$("#manualdialnumber_txt").hide(); | ||
| 983 | $("#dialerstate_btn").parent().removeClass("rounded-left"); | ||
| 984 | $("#dialerstate_btn").parent().removeClass("btn-primary").addClass("btn-info"); | ||
| 985 | } | ||
| 986 | ////////////////////////////////////////////////////////////// | ||
| 987 | |||
| 988 | ////////////////////////////////////////////////////////////// | ||
| 989 | var uStateArr=[]; | ||
| 990 | uStateArr['conficon_u_a']='btn-primary';uStateArr['conficon_u_i']='fa-chain-broken'; | ||
| 991 | if(kstychDialer['connection']['connected']==1) | ||
| 992 | { | ||
| 993 | uStateArr['conficon_u_a']='btn-success';uStateArr['conficon_u_i']='fa-chain'; | ||
| 994 | } | ||
| 995 | uStateArr['mic']='UnMuteMic';uStateArr['micicon']='fa-microphone-slash'; | ||
| 996 | if(kstychDialer['connection']['mic']==1) | ||
| 997 | { | ||
| 998 | uStateArr['mic']='MuteMic';uStateArr['micicon']='fa-microphone'; | ||
| 999 | } | ||
| 1000 | |||
| 1001 | var calluhtml="<a data-toggle='dropdown' href='#' class='btn btn-stroke "+uStateArr['conficon_u_a']+" btn-circle dropdown-toggle' onmouseout='$(this).blur()' id=conficon_u_a><i class='fa "+uStateArr['conficon_u_i']+"' id=conficon_u_i></i> </a>"; | ||
| 1002 | calluhtml+="<ul class='dropdown-menu'>"; | ||
| 1003 | calluhtml+="<li data-toggle='tooltip' data-title='My Channel' data-placement='left' data-tcontainer='body'><a href='#' onclick='return false;'><i class='fa fa-info'></i></a></li>"; | ||
| 1004 | //calluhtml+="<li data-toggle='tooltip' data-title='MuteSpeaker' data-placement='left' data-tcontainer='body'><a href='#' onclick='kCallAction(\"u\",\"MuteSpeaker\");return false;'><i class='fa fa-volume-off'></i></a></li>"; | ||
| 1005 | calluhtml+="<li data-toggle='tooltip' data-title='"+uStateArr['mic']+"' data-placement='left' data-tcontainer='body'><a href='#' onclick='kCallAction(\"u\",\""+uStateArr['mic']+"\");return false;'><i class='fa "+uStateArr['micicon']+"'></i></a></li>"; | ||
| 1006 | //calluhtml+="<li data-toggle='tooltip' data-title='Hangup' data-placement='left' data-tcontainer='body'><a href='#' onclick='kCallAction(\"u\",\"Hangup\");return false;'><i class='fa fa-times-circle'></i></a></li>"; | ||
| 1007 | //calluhtml+="<li data-toggle='tooltip' data-title='Hold' data-placement='left' data-tcontainer='body'><a href='#' onclick='kCallAction(\"u\",\"Hold\");return false;'><i class='fa fa-pause'></i></a></li>"; | ||
| 1008 | calluhtml+="</ul>"; | ||
| 1009 | $("#connections_div_u").html(calluhtml); | ||
| 1010 | |||
| 1011 | $(".dialer_conf_divs").remove(); | ||
| 1012 | var confhtml=''; | ||
| 1013 | for(var key in kstychCall['connections']) | ||
| 1014 | { | ||
| 1015 | if(kstychCall['connections'].hasOwnProperty(key)) | ||
| 1016 | { | ||
| 1017 | if(key==kstychCall['callnumber']) | ||
| 1018 | { | ||
| 1019 | var cStateArr=[]; | ||
| 1020 | cStateArr['conficon_c0_a']='btn-primary';cStateArr['conficon_c0_i']='fa-chain-broken'; | ||
| 1021 | if(kstychCall['connections'][key]['connected']==1) | ||
| 1022 | { | ||
| 1023 | cStateArr['conficon_c0_a']='btn-success';cStateArr['conficon_c0_i']='fa-chain'; | ||
| 1024 | } | ||
| 1025 | cStateArr['mic']='UnMuteMic';cStateArr['micicon']='fa-microphone-slash'; | ||
| 1026 | if(kstychCall['connections'][key]['mic']==1) | ||
| 1027 | { | ||
| 1028 | cStateArr['mic']='MuteMic';cStateArr['micicon']='fa-microphone'; | ||
| 1029 | } | ||
| 1030 | cStateArr['speaker']='UnMuteSpeaker';cStateArr['speakericon']='fa-volume-off'; | ||
| 1031 | if(kstychCall['connections'][key]['speaker']==1) | ||
| 1032 | { | ||
| 1033 | cStateArr['speaker']='MuteSpeaker';cStateArr['speakericon']='fa-volume-up'; | ||
| 1034 | } | ||
| 1035 | cStateArr['holdext']='UnHold';cStateArr['holdexticon']='fa-play'; | ||
| 1036 | if(kstychCall['connections'][key]['holdext']=='') | ||
| 1037 | { | ||
| 1038 | cStateArr['holdext']='Hold';cStateArr['holdexticon']='fa-pause'; | ||
| 1039 | } | ||
| 1040 | |||
| 1041 | var callchtml="<a data-toggle='dropdown' href='#' class='btn btn-stroke "+cStateArr['conficon_c0_a']+" btn-circle dropdown-toggle' onmouseout='$(this).blur()' id=conficon_c0_a><i class='fa "+cStateArr['conficon_c0_i']+"' id=conficon_c0_i></i> </a>"; | ||
| 1042 | callchtml+="<ul class='dropdown-menu'>"; | ||
| 1043 | callchtml+="<li data-toggle='tooltip' data-title='"+key+"' data-placement='left' data-tcontainer='body'><a href='#' onclick='return false;'><i class='fa fa-info'></i></a></li>"; | ||
| 1044 | callchtml+="<li data-toggle='tooltip' data-title='"+cStateArr['speaker']+"' data-placement='left' data-tcontainer='body'><a href='#' onclick='kCallAction(\"c\",\""+cStateArr['speaker']+"\");return false;'><i class='fa "+cStateArr['speakericon']+"'></i></a></li>"; | ||
| 1045 | callchtml+="<li data-toggle='tooltip' data-title='"+cStateArr['mic']+"' data-placement='left' data-tcontainer='body'><a href='#' onclick='kCallAction(\"c\",\""+cStateArr['mic']+"\");return false;'><i class='fa "+cStateArr['micicon']+"'></i></a></li>"; | ||
| 1046 | callchtml+="<li data-toggle='tooltip' data-title='Hangup' data-placement='left' data-tcontainer='body'><a href='#' onclick='kCallAction(\"c\",\"Hangup\");return false;'><i class='fa fa-times-circle'></i></a></li>"; | ||
| 1047 | //callchtml+="<li data-toggle='tooltip' data-title='"+cStateArr['holdext']+"' data-placement='left' data-tcontainer='body'><a href='#' onclick='kCallAction(\"c\",\""+cStateArr['holdext']+"\");return false;'><i class='fa "+cStateArr['holdexticon']+"'></i></a></li></ul>"; | ||
| 1048 | $("#connections_div_c").html(callchtml); | ||
| 1049 | } | ||
| 1050 | else | ||
| 1051 | { | ||
| 1052 | var tStateArr=[]; | ||
| 1053 | tStateArr['conficon_t_a']='btn-primary';tStateArr['conficon_t_i']='fa-chain-broken'; | ||
| 1054 | if(kstychCall['connections'][key]['connected']==1) | ||
| 1055 | { | ||
| 1056 | tStateArr['conficon_t_a']='btn-success';tStateArr['conficon_t_i']='fa-chain'; | ||
| 1057 | } | ||
| 1058 | tStateArr['mic']='UnMuteMic';tStateArr['micicon']='fa-microphone-slash'; | ||
| 1059 | if(kstychCall['connections'][key]['mic']==1) | ||
| 1060 | { | ||
| 1061 | tStateArr['mic']='MuteMic';tStateArr['micicon']='fa-microphone'; | ||
| 1062 | } | ||
| 1063 | tStateArr['speaker']='UnMuteSpeaker';tStateArr['speakericon']='fa-volume-off'; | ||
| 1064 | if(kstychCall['connections'][key]['speaker']==1) | ||
| 1065 | { | ||
| 1066 | tStateArr['speaker']='MuteSpeaker';tStateArr['speakericon']='fa-volume-up'; | ||
| 1067 | } | ||
| 1068 | tStateArr['holdext']='UnHold';tStateArr['holdexticon']='fa-play'; | ||
| 1069 | if(kstychCall['connections'][key]['holdext']=='') | ||
| 1070 | { | ||
| 1071 | tStateArr['holdext']='Hold';tStateArr['holdexticon']='fa-pause'; | ||
| 1072 | } | ||
| 1073 | |||
| 1074 | confhtml+="<div class='dropdown dropdown-icons dialer_conf_divs' confphonenumber='"+key+"' >"; | ||
| 1075 | confhtml+="<a data-toggle='dropdown' href='#' class='btn btn-stroke "+tStateArr['conficon_t_a']+" btn-circle dropdown-toggle' onmouseout='$(this).blur()'><i class='fa "+tStateArr['conficon_t_i']+"'></i> </a>"; | ||
| 1076 | confhtml+="<ul class='dropdown-menu'>"; | ||
| 1077 | confhtml+="<li data-toggle='tooltip' data-title='"+key+"' data-placement='left' data-tcontainer='body'><a href='#' onclick='return false;'><i class='fa fa-info'></i></a></li>"; | ||
| 1078 | confhtml+="<li data-toggle='tooltip' data-title='"+tStateArr['speaker']+"' data-placement='left' data-tcontainer='body'><a href='#' onclick='kCallAction(\""+key+"\",\""+tStateArr['speaker']+"\");return false;'><i class='fa "+tStateArr['speakericon']+"'></i></a></li>"; | ||
| 1079 | confhtml+="<li data-toggle='tooltip' data-title='"+tStateArr['mic']+"' data-placement='left' data-tcontainer='body'><a href='#' onclick='kCallAction(\""+key+"\",\""+tStateArr['mic']+"\");return false;'><i class='fa "+tStateArr['micicon']+"'></i></a></li>"; | ||
| 1080 | confhtml+="<li data-toggle='tooltip' data-title='Hangup' data-placement='left' data-tcontainer='body'><a href='#' onclick='kCallAction(\""+key+"\",\"Hangup\");return false;'><i class='fa fa-times-circle'></i></a></li>"; | ||
| 1081 | //confhtml+="<li data-toggle='tooltip' data-title='"+tStateArr['holdext']+"' data-placement='left' data-tcontainer='body'><a href='#' onclick='kCallAction(\""+key+"\",\""+tStateArr['holdext']+"\");return false;'><i class='fa "+tStateArr['holdexticon']+"'></i></a></li>"; | ||
| 1082 | confhtml+="</ul></div>"; | ||
| 1083 | } | ||
| 1084 | } | ||
| 1085 | } | ||
| 1086 | $(confhtml).insertAfter("#connections_div_c"); | ||
| 1087 | ////////////////////////////////////////////////////////////// | ||
| 1088 | |||
| 1089 | ////////////////////////////////////////////////////////////// | ||
| 1090 | if(kstychCall['mCallState']=="Wait") | ||
| 1091 | { | ||
| 1092 | $("#dialerstate_btn").parent().attr("disabled",false); | ||
| 1093 | if(kstychDialer['mmanualallow']=='Yes')$("#manualdialnumber_txt").attr("disabled",false); | ||
| 1094 | else $("#manualdialnumber_txt").attr("disabled",true); | ||
| 1095 | |||
| 1096 | $("#manualdial_btn").attr("disabled",false); | ||
| 1097 | $("#manualdial_btn").attr("dialaction","dialnext"); | ||
| 1098 | $("#manualdial_btn").html("<i class='fa fa-play text-default'></i>"); | ||
| 1099 | |||
| 1100 | if(kstychDialer['mDialerState']=="Ready") | ||
| 1101 | { | ||
| 1102 | var readyDelay=Math.ceil((getNowTS()-kstychCall['ts_Wait'])/1000); | ||
| 1103 | |||
| 1104 | $("#manualdial_btn").attr("disabled",true); | ||
| 1105 | $("#manualdial_btn").attr("dialaction",""); | ||
| 1106 | $("#manualdial_btn").html("Waiting");// : "+readyDelay); | ||
| 1107 | |||
| 1108 | } | ||
| 1109 | } | ||
| 1110 | if(kstychCall['mCallState']=="Call") | ||
| 1111 | { | ||
| 1112 | $("#dialerstate_btn").parent().attr("disabled",true); | ||
| 1113 | $("#manualdialnumber_txt").attr("disabled",true); | ||
| 1114 | |||
| 1115 | $("#manualdial_btn").attr("disabled",false); | ||
| 1116 | $("#manualdial_btn").attr("dialaction","hangupall"); | ||
| 1117 | $("#manualdial_btn").html("<i class='fa fa-times text-primary'></i> Hangup"); | ||
| 1118 | } | ||
| 1119 | if(kstychCall['mCallState']=="Dispo") | ||
| 1120 | { | ||
| 1121 | $("#dialerstate_btn").parent().attr("disabled",true); | ||
| 1122 | $("#manualdialnumber_txt").attr("disabled",true); | ||
| 1123 | |||
| 1124 | $("#manualdial_btn").attr("disabled",false); | ||
| 1125 | $("#manualdial_btn").attr("dialaction","saveclose"); | ||
| 1126 | $("#manualdial_btn").html("<i class='fa fa-save text-success'></i> Save & Close"); | ||
| 1127 | } | ||
| 1128 | if(kstychCall['mCallState']=="Close") | ||
| 1129 | { | ||
| 1130 | $("#dialerstate_btn").parent().attr("disabled",true); | ||
| 1131 | $("#manualdialnumber_txt").attr("disabled",true); | ||
| 1132 | |||
| 1133 | $("#manualdial_btn").attr("disabled",true); | ||
| 1134 | $("#manualdial_btn").attr("dialaction",""); | ||
| 1135 | $("#manualdial_btn").html("<i class='fa fa-pause text-default'></i>"); | ||
| 1136 | } | ||
| 1137 | ////////////////////////////////////////////////////////////// | ||
| 1138 | } | ||
| 1139 | |||
| 1140 | function dialerTimersUpdate() | ||
| 1141 | { | ||
| 1142 | var dispD="0";var dispT="0";var dispC="0";var dispW="0"; | ||
| 1143 | |||
| 1144 | if(kstychCall['ts_Dispo']>1) | ||
| 1145 | { | ||
| 1146 | if(Math.ceil(((kstychCall['ts_Dispo']-kstychCall['ts_Talk'])/1000))<3) | ||
| 1147 | { | ||
| 1148 | kstychCall['callWrapupTime']=90; | ||
| 1149 | if(typeof dispoClassArray!='undefined' && typeof dispoClassArray['NA'] != 'undefined') | ||
| 1150 | { | ||
| 1151 | if($('#dialer_userstatus').val()=="") | ||
| 1152 | { | ||
| 1153 | $('#dialer_userstatus').val(dispoClassArray['NA']); | ||
| 1154 | $('#dialer_userstatus').change(); | ||
| 1155 | } | ||
| 1156 | } | ||
| 1157 | } | ||
| 1158 | |||
| 1159 | var thiswraptime=Math.ceil(kstychCall['callWrapupTime']-((getNowTS()-kstychCall['ts_Dispo'])/1000)); | ||
| 1160 | |||
| 1161 | if(thiswraptime<=0) | ||
| 1162 | { | ||
| 1163 | saveCloseDialerCall('AUTOWRAPUP'); | ||
| 1164 | } | ||
| 1165 | |||
| 1166 | if(thiswraptime==90 || thiswraptime==300) | ||
| 1167 | { | ||
| 1168 | showWrapUp(); | ||
| 1169 | } | ||
| 1170 | |||
| 1171 | dispD="Wrapup : "+thiswraptime; | ||
| 1172 | $("#spandialer_ts").html(dispD); | ||
| 1173 | $("#dialertimes1").removeClass("btn-default").addClass("btn-primary"); | ||
| 1174 | } | ||
| 1175 | else if(kstychCall['ts_Talk']>1) | ||
| 1176 | { | ||
| 1177 | dispT="Talk : "+Math.ceil(((getNowTS()-kstychCall['ts_Talk'])/1000)); | ||
| 1178 | $("#spandialer_ts").html(dispT); | ||
| 1179 | $("#dialertimes1").removeClass("btn-primary").addClass("btn-default"); | ||
| 1180 | } | ||
| 1181 | else if(kstychCall['ts_Call']>1) | ||
| 1182 | { | ||
| 1183 | dispC="Call : "+Math.ceil(((getNowTS()-kstychCall['ts_Call'])/1000)); | ||
| 1184 | $("#spandialer_ts").html(dispC); | ||
| 1185 | $("#dialertimes1").removeClass("btn-primary").addClass("btn-default"); | ||
| 1186 | } | ||
| 1187 | else if(kstychCall['ts_Wait']>1) | ||
| 1188 | { | ||
| 1189 | dispW="Wait : "+Math.ceil(((getNowTS()-kstychCall['ts_Wait'])/1000)); | ||
| 1190 | $("#spandialer_ts").html(dispW); | ||
| 1191 | $("#dialertimes1").removeClass("btn-primary").addClass("btn-default"); | ||
| 1192 | } | ||
| 1193 | |||
| 1194 | |||
| 1195 | if(kstychCall['mCallState']=="Wait") | ||
| 1196 | { | ||
| 1197 | if(kstychDialer['mDialerState']=="Progressive") | ||
| 1198 | { | ||
| 1199 | var progressiveDelay=Math.ceil(kstychCall['prograssiveDelay']-((getNowTS()-kstychCall['ts_Wait'])/1000)); | ||
| 1200 | |||
| 1201 | if(progressiveDelay<0)progressiveDelay=0; | ||
| 1202 | |||
| 1203 | $("#manualdial_btn").attr("disabled",false); | ||
| 1204 | $("#manualdial_btn").attr("dialaction","dialnext"); | ||
| 1205 | $("#manualdial_btn").html("<i class='fa fa-play text-default'></i> "+progressiveDelay); | ||
| 1206 | |||
| 1207 | if(progressiveDelay<=0)$("#manualdial_btn").click(); | ||
| 1208 | } | ||
| 1209 | } | ||
| 1210 | |||
| 1211 | setTimeout(dialerTimersUpdate,1000); | ||
| 1212 | } | ||
| 1213 | |||
| 1214 | function kDialerConnected() | ||
| 1215 | { | ||
| 1216 | updateDialerState(); | ||
| 1217 | dialerTimersUpdate(); | ||
| 1218 | $("#dialerQuickControlDiv").show(); | ||
| 1219 | } | ||
| 1220 | function kDialerInit() | ||
| 1221 | { | ||
| 1222 | if(kstychAppObject['user']['id']!=0) | ||
| 1223 | { | ||
| 1224 | //simpleNotification("warning","topRight","Trying to Enable Voice Services"); | ||
| 1225 | |||
| 1226 | txtDisplayName = kstychAppObject['user']['sipid']; | ||
| 1227 | txtPrivateIdentity = kstychAppObject['user']['sipid']; | ||
| 1228 | txtPublicIdentity = "sip:"+kstychAppObject['user']['sipid']+"@"+kstychAppObject['user']['sipserver']; | ||
| 1229 | txtRealm = kstychAppObject['user']['sipserver']; | ||
| 1230 | |||
| 1231 | //txtPhoneNumber=document.getElementById("txtphno"); | ||
| 1232 | txtPhoneNumber = '1000'+kstychAppObject['user']['sipid']; | ||
| 1233 | |||
| 1234 | btnCall = false; | ||
| 1235 | btnHangUp = true; | ||
| 1236 | |||
| 1237 | btnFullScreen = false; | ||
| 1238 | audioRemote = document.getElementById("audio_remote"); | ||
| 1239 | videoLocal = document.getElementById("video_local"); | ||
| 1240 | videoRemote = document.getElementById("video_remote"); | ||
| 1241 | |||
| 1242 | SIPml.setDebugLevel(kstychAppObject['config']['appdebug']==0 ? "error" : "info"); | ||
| 1243 | |||
| 1244 | |||
| 1245 | //expert stuff //siddharth | ||
| 1246 | cbVideoDisable = true; | ||
| 1247 | if(window.location.protocol == 'https:')txtWebsocketServerUrl = "wss://"+kstychAppObject['user']['sipssldomain']+":8089/ws"; | ||
| 1248 | else txtWebsocketServerUrl = "ws://"+txtRealm+":8088/ws"; | ||
| 1249 | txtSIPOutboundProxyUrl = "";//txtSIPOutboundProxyUrl="udp://"+txtRealm+":5060"; | ||
| 1250 | |||
| 1251 | var preInit = function() { | ||
| 1252 | // set default webrtc type (before initialization) | ||
| 1253 | var s_webrtc_type = null;//getPVal("wt"); | ||
| 1254 | var s_fps = null;//getPVal("fps"); | ||
| 1255 | var s_mvs = null;//getPVal("mvs"); // maxVideoSize | ||
| 1256 | var s_mbwu = null;//getPVal("mbwu"); // maxBandwidthUp (kbps) | ||
| 1257 | var s_mbwd = null;//getPVal("mbwd"); // maxBandwidthUp (kbps) | ||
| 1258 | var s_za = null;//getPVal("za"); // ZeroArtifacts | ||
| 1259 | var s_ndb = null;//getPVal("ndb"); // NativeDebug | ||
| 1260 | |||
| 1261 | if (s_webrtc_type) SIPml.setWebRtcType(s_webrtc_type); | ||
| 1262 | |||
| 1263 | // initialize SIPML5 | ||
| 1264 | SIPml.init(postInit); | ||
| 1265 | |||
| 1266 | // set other options after initialization | ||
| 1267 | if (s_fps) SIPml.setFps(parseFloat(s_fps)); | ||
| 1268 | if (s_mvs) SIPml.setMaxVideoSize(s_mvs); | ||
| 1269 | if (s_mbwu) SIPml.setMaxBandwidthUp(parseFloat(s_mbwu)); | ||
| 1270 | if (s_mbwd) SIPml.setMaxBandwidthDown(parseFloat(s_mbwd)); | ||
| 1271 | if (s_za) SIPml.setZeroArtifacts(s_za === "true"); | ||
| 1272 | if (s_ndb == "true") SIPml.startNativeDebug(); | ||
| 1273 | |||
| 1274 | //var rinningApps = SIPml.getRunningApps(); | ||
| 1275 | //var _rinningApps = Base64.decode(rinningApps); | ||
| 1276 | //tsk_utils_log_info(_rinningApps); | ||
| 1277 | } | ||
| 1278 | |||
| 1279 | oReadyStateTimer = setInterval(function () { | ||
| 1280 | if (document.readyState === "complete") { | ||
| 1281 | clearInterval(oReadyStateTimer); | ||
| 1282 | // initialize SIPML5 | ||
| 1283 | preInit(); | ||
| 1284 | } | ||
| 1285 | }, | ||
| 1286 | 500); | ||
| 1287 | } | ||
| 1288 | } | ||
| 1289 | window.onload = function () | ||
| 1290 | { | ||
| 1291 | kDialerInit(); | ||
| 1292 | }; | ||
| 1293 | |||
| 1294 | function postInit() | ||
| 1295 | { | ||
| 1296 | // check for WebRTC support | ||
| 1297 | if (!SIPml.isWebRtcSupported()) | ||
| 1298 | { | ||
| 1299 | // is it chrome? | ||
| 1300 | if (SIPml.getNavigatorFriendlyName() == 'chrome') | ||
| 1301 | { | ||
| 1302 | document.location="msie?oldchrome"; | ||
| 1303 | return; | ||
| 1304 | } | ||
| 1305 | if (SIPml.getNavigatorFriendlyName() == 'ie'||SIPml.getNavigatorFriendlyName() == 'netscape') | ||
| 1306 | { | ||
| 1307 | document.location="msie"; | ||
| 1308 | return; | ||
| 1309 | } | ||
| 1310 | // checks for WebSocket support | ||
| 1311 | if (!SIPml.isWebSocketSupported() && !SIPml.isWebRtc4AllSupported()) | ||
| 1312 | { | ||
| 1313 | document.location="msie?nowebsockets"; | ||
| 1314 | return; | ||
| 1315 | } | ||
| 1316 | } | ||
| 1317 | |||
| 1318 | if (!SIPml.isWebRtc4AllSupported() && !SIPml.isWebRtcSupported()) | ||
| 1319 | { | ||
| 1320 | document.location="msie?notsupported"; | ||
| 1321 | return; | ||
| 1322 | } | ||
| 1323 | |||
| 1324 | oConfigCall = { | ||
| 1325 | audio_remote: audioRemote, | ||
| 1326 | video_local: videoLocal, | ||
| 1327 | video_remote: videoRemote, | ||
| 1328 | screencast_window_id: 0x00000000, // entire desktop | ||
| 1329 | bandwidth: { audio:undefined, video:undefined }, | ||
| 1330 | video_size: { minWidth:undefined, minHeight:undefined, maxWidth:undefined, maxHeight:undefined }, | ||
| 1331 | events_listener: { events: '*', listener: onSipEventSession }, | ||
| 1332 | sip_caps: [ | ||
| 1333 | { name: '+g.oma.sip-im' }, | ||
| 1334 | { name: 'language', value: '\"en,fr\"' } | ||
| 1335 | ] | ||
| 1336 | }; | ||
| 1337 | sipRegister(); | ||
| 1338 | //simpleNotification("warning","topRight","Requesting Voice Permissions"); | ||
| 1339 | //navigator.getUserMedia = (navigator.getUserMedia ||navigator.webkitGetUserMedia ||navigator.mozGetUserMedia || navigator.msGetUserMedia); | ||
| 1340 | //navigator.getUserMedia({video: false, audio: true},function(localMediaStream) {},function(err) {simpleNotification("error","topRight","Your Browser doesnot support Voice. Some functions will not work.");}); | ||
| 1341 | |||
| 1342 | } | ||
| 1343 | |||
| 1344 | |||
| 1345 | // sends SIP REGISTER request to login | ||
| 1346 | function sipRegister() { | ||
| 1347 | // catch exception for IE (DOM not ready) | ||
| 1348 | try | ||
| 1349 | { | ||
| 1350 | if (!txtRealm || !txtPrivateIdentity || !txtPublicIdentity) { | ||
| 1351 | txtRegStatus = '<b>Please fill madatory fields (*)</b>'; | ||
| 1352 | simpleNotification("error","topRight",txtRegStatus); | ||
| 1353 | return; | ||
| 1354 | } | ||
| 1355 | var o_impu = tsip_uri.prototype.Parse(txtPublicIdentity); | ||
| 1356 | if (!o_impu || !o_impu.s_user_name || !o_impu.s_host) { | ||
| 1357 | txtRegStatus = "<b>[" + txtPublicIdentity + "] is not a valid Public identity</b>"; | ||
| 1358 | simpleNotification("error","topRight",txtRegStatus); | ||
| 1359 | return; | ||
| 1360 | } | ||
| 1361 | |||
| 1362 | // enable notifications if not already done | ||
| 1363 | if (window.webkitNotifications && window.webkitNotifications.checkPermission() != 0) { | ||
| 1364 | window.webkitNotifications.requestPermission(); | ||
| 1365 | } | ||
| 1366 | |||
| 1367 | var iceServers=[{ url: 'stun:'+kstychAppObject['user']['sipserver']+':3478'}, { url:'turn:'+kstychAppObject['user']['sipserver'], credential:'1234',username: 'kstych'}]; | ||
| 1368 | if(kstychAppObject['config']['use-ice']=='no')iceServers=[{ url: 'stun:127.0.0.1:3478'}]; | ||
| 1369 | |||
| 1370 | // create SIP stack | ||
| 1371 | oSipStack = new SIPml.Stack({ | ||
| 1372 | realm: txtRealm, | ||
| 1373 | impi: txtPrivateIdentity, | ||
| 1374 | impu: txtPublicIdentity, | ||
| 1375 | password: kstychAppObject['user']['sipauth'], | ||
| 1376 | display_name: txtDisplayName, | ||
| 1377 | websocket_proxy_url: txtWebsocketServerUrl, | ||
| 1378 | outbound_proxy_url: txtSIPOutboundProxyUrl, | ||
| 1379 | ice_servers: iceServers, | ||
| 1380 | enable_rtcweb_breaker: false, | ||
| 1381 | events_listener: { events: '*', listener: onSipEventStack }, | ||
| 1382 | enable_early_ims: true, // Must be true unless you're using a real IMS network | ||
| 1383 | enable_media_stream_cache: false, | ||
| 1384 | bandwidth: null, // could be redefined a session-level | ||
| 1385 | video_size: null, // could be redefined a session-level | ||
| 1386 | sip_headers: [ | ||
| 1387 | { name: 'User-Agent', value: 'IM-client/Kstych' }, | ||
| 1388 | { name: 'Organization', value: 'Kstych Pvt Ltd' } | ||
| 1389 | ] | ||
| 1390 | } | ||
| 1391 | ); | ||
| 1392 | |||
| 1393 | if (oSipStack.start() != 0) { | ||
| 1394 | txtRegStatus = '<b>Failed to start the SIP stack</b>'; | ||
| 1395 | simpleNotification("error","topRight",txtRegStatus); | ||
| 1396 | } | ||
| 1397 | else {loggedin=1;return;} | ||
| 1398 | } | ||
| 1399 | catch (e) { | ||
| 1400 | txtRegStatus = "<b>2:" + e + "</b>"; | ||
| 1401 | simpleNotification("error","topRight",txtRegStatus); | ||
| 1402 | } | ||
| 1403 | } | ||
| 1404 | |||
| 1405 | // sends SIP REGISTER (expires=0) to logout | ||
| 1406 | function sipUnRegister(type) | ||
| 1407 | { | ||
| 1408 | if (oSipStack) { | ||
| 1409 | try{sipHangUp();}catch(e){console.log(e);} | ||
| 1410 | oSipStack.stop(); // shutdown all sessions | ||
| 1411 | } | ||
| 1412 | |||
| 1413 | if(!type) | ||
| 1414 | { | ||
| 1415 | /* simpleNotification("warning","topRight","Retrying in 10 sec...");*/ | ||
| 1416 | $("#phonetopbar").hide(); | ||
| 1417 | //setTimeout(sipRegister,10*1000); | ||
| 1418 | document.location='/logout'; | ||
| 1419 | } | ||
| 1420 | else loggedin=0; | ||
| 1421 | } | ||
| 1422 | |||
| 1423 | // makes a call (SIP INVITE) | ||
| 1424 | function sipCall(s_type,destination) { | ||
| 1425 | if(oSipStack) | ||
| 1426 | { | ||
| 1427 | if (oSipSessionCall) { | ||
| 1428 | txtCallStatus = '<i>Already in a Call...</i>'; | ||
| 1429 | simpleNotification("warning","topRight",txtCallStatus); | ||
| 1430 | } | ||
| 1431 | else { | ||
| 1432 | if (!tsk_string_is_null_or_empty(destination)) { | ||
| 1433 | |||
| 1434 | if(s_type == 'call-screenshare') { | ||
| 1435 | if(!SIPml.isScreenShareSupported()) { | ||
| 1436 | alert('Screen sharing not supported. Are you using chrome 26+?'); | ||
| 1437 | return; | ||
| 1438 | } | ||
| 1439 | if (!location.protocol.match('https')){ | ||
| 1440 | if (confirm("Screen sharing requires https://. Do you want to be redirected?")) { | ||
| 1441 | sipUnRegister(); | ||
| 1442 | window.location = 'msie?httpsneeded'; | ||
| 1443 | } | ||
| 1444 | return; | ||
| 1445 | } | ||
| 1446 | } | ||
| 1447 | btnCall = true; | ||
| 1448 | btnHangUp = false; | ||
| 1449 | |||
| 1450 | |||
| 1451 | // create call session | ||
| 1452 | oSipSessionCall = oSipStack.newSession(s_type, oConfigCall); | ||
| 1453 | // make call | ||
| 1454 | if (oSipSessionCall.call(destination) != 0) { | ||
| 1455 | oSipSessionCall = null; | ||
| 1456 | txtCallStatus = 'Failed to make call'; | ||
| 1457 | simpleNotification("error","topRight",txtCallStatus); | ||
| 1458 | btnCall = false; | ||
| 1459 | btnHangUp = true; | ||
| 1460 | return; | ||
| 1461 | } | ||
| 1462 | } | ||
| 1463 | } | ||
| 1464 | } | ||
| 1465 | } | ||
| 1466 | function sipAnswer() | ||
| 1467 | { | ||
| 1468 | if(oSipStack){ | ||
| 1469 | if (oSipSessionCall) { | ||
| 1470 | txtCallStatus = '<i>Connecting...</i>'; | ||
| 1471 | //simpleNotification("warning","topRight",txtCallStatus); | ||
| 1472 | oSipSessionCall.accept(oConfigCall); | ||
| 1473 | } | ||
| 1474 | } | ||
| 1475 | if(answergrowl)$.gritter.remove(answergrowl, {fade: true,speed: 'slow'}); | ||
| 1476 | } | ||
| 1477 | |||
| 1478 | // Share entire desktop aor application using BFCP or WebRTC native implementation | ||
| 1479 | function sipShareScreen() { | ||
| 1480 | if (SIPml.getWebRtcType() === 'w4a') { | ||
| 1481 | // Sharing using BFCP -> requires an active session | ||
| 1482 | if (!oSipSessionCall) { | ||
| 1483 | txtCallStatus = '<i>No active session</i>'; | ||
| 1484 | return; | ||
| 1485 | } | ||
| 1486 | if (oSipSessionCall.bfcpSharing) { | ||
| 1487 | if (oSipSessionCall.stopBfcpShare(oConfigCall) != 0) { | ||
| 1488 | txtCallStatus = 'Failed to stop BFCP share'; | ||
| 1489 | } | ||
| 1490 | else { | ||
| 1491 | oSipSessionCall.bfcpSharing = false; | ||
| 1492 | } | ||
| 1493 | } | ||
| 1494 | else { | ||
| 1495 | oConfigCall.screencast_window_id = 0x00000000; | ||
| 1496 | if (oSipSessionCall.startBfcpShare(oConfigCall) != 0) { | ||
| 1497 | txtCallStatus = 'Failed to start BFCP share'; | ||
| 1498 | } | ||
| 1499 | else { | ||
| 1500 | oSipSessionCall.bfcpSharing = true; | ||
| 1501 | } | ||
| 1502 | } | ||
| 1503 | } | ||
| 1504 | else { | ||
| 1505 | sipCall('call-screenshare',txtPhoneNumber); | ||
| 1506 | } | ||
| 1507 | } | ||
| 1508 | |||
| 1509 | |||
| 1510 | |||
| 1511 | // transfers the call | ||
| 1512 | function sipTransfer(s_destination) { | ||
| 1513 | if (oSipSessionCall) { | ||
| 1514 | if (!tsk_string_is_null_or_empty(s_destination)) { | ||
| 1515 | btnTransfer.disabled = true; | ||
| 1516 | if (oSipSessionCall.transfer(s_destination) != 0) { | ||
| 1517 | txtCallStatus = '<i>Call transfer failed</i>'; | ||
| 1518 | btnTransfer.disabled = false; | ||
| 1519 | return; | ||
| 1520 | } | ||
| 1521 | txtCallStatus = '<i>Transfering the call...</i>'; | ||
| 1522 | } | ||
| 1523 | } | ||
| 1524 | } | ||
| 1525 | |||
| 1526 | // holds or resumes the call | ||
| 1527 | function sipToggleHoldResume() { | ||
| 1528 | if (oSipSessionCall) { | ||
| 1529 | var i_ret; | ||
| 1530 | btnHoldResume.disabled = true; | ||
| 1531 | txtCallStatus = oSipSessionCall.bHeld ? '<i>Resuming the call...</i>' : '<i>Holding the call...</i>'; | ||
| 1532 | i_ret = oSipSessionCall.bHeld ? oSipSessionCall.resume() : oSipSessionCall.hold(); | ||
| 1533 | if (i_ret != 0) { | ||
| 1534 | txtCallStatus = '<i>Hold / Resume failed</i>'; | ||
| 1535 | btnHoldResume.disabled = false; | ||
| 1536 | return; | ||
| 1537 | } | ||
| 1538 | } | ||
| 1539 | } | ||
| 1540 | |||
| 1541 | // Mute or Unmute the call | ||
| 1542 | function sipToggleMute() { | ||
| 1543 | if (oSipSessionCall) { | ||
| 1544 | var i_ret; | ||
| 1545 | var bMute = !oSipSessionCall.bMute; | ||
| 1546 | txtCallStatus = bMute ? '<i>Mute the call...</i>' : '<i>Unmute the call...</i>'; | ||
| 1547 | i_ret = oSipSessionCall.mute('audio'/*could be 'video'*/, bMute); | ||
| 1548 | if (i_ret != 0) { | ||
| 1549 | simpleNotification('error','topRight',"Mute / Unmute failed"); | ||
| 1550 | return; | ||
| 1551 | } | ||
| 1552 | oSipSessionCall.bMute = bMute; | ||
| 1553 | var btnMute = bMute ? "Mute" : "Unmute"; | ||
| 1554 | simpleNotification('success','topRight',"You are now ["+btnMute+"]"); | ||
| 1555 | |||
| 1556 | return bMute ? 0 : 1; | ||
| 1557 | } | ||
| 1558 | return 1; | ||
| 1559 | } | ||
| 1560 | |||
| 1561 | // terminates the call (SIP BYE or CANCEL) | ||
| 1562 | function sipHangUp() { | ||
| 1563 | try | ||
| 1564 | { | ||
| 1565 | stopRingbackTone(); | ||
| 1566 | stopRingTone(); | ||
| 1567 | |||
| 1568 | if (oSipSessionCall) { | ||
| 1569 | txtCallStatus = '<i>Terminating the call...</i>'; | ||
| 1570 | oSipSessionCall.hangup({events_listener: { events: '*', listener: onSipEventSession }}); | ||
| 1571 | //simpleNotification("warning","topRight","Call Terminated."); | ||
| 1572 | } | ||
| 1573 | //$("#phonetopbar").hide(); | ||
| 1574 | } | ||
| 1575 | catch(e){console.log(e);} | ||
| 1576 | |||
| 1577 | if(hangupgrowl)$.gritter.remove(hangupgrowl, {fade: true,speed: 'slow'}); | ||
| 1578 | if(answergrowl)$.gritter.remove(answergrowl, {fade: true,speed: 'slow'}); | ||
| 1579 | } | ||
| 1580 | |||
| 1581 | function sipSendDTMF(c){ | ||
| 1582 | if(oSipSessionCall && c){ | ||
| 1583 | if(oSipSessionCall.dtmf(c) == 0){ | ||
| 1584 | try { dtmfTone.play(); } catch(e){ } | ||
| 1585 | } | ||
| 1586 | } | ||
| 1587 | } | ||
| 1588 | |||
| 1589 | function startRingTone() { | ||
| 1590 | try { ringtone.play(); } | ||
| 1591 | catch (e) { } | ||
| 1592 | } | ||
| 1593 | |||
| 1594 | function stopRingTone() { | ||
| 1595 | try { ringtone.pause(); } | ||
| 1596 | catch (e) { } | ||
| 1597 | } | ||
| 1598 | |||
| 1599 | function startRingbackTone() { | ||
| 1600 | try { ringbacktone.play(); } | ||
| 1601 | catch (e) { } | ||
| 1602 | } | ||
| 1603 | |||
| 1604 | function stopRingbackTone() { | ||
| 1605 | try { ringbacktone.pause(); } | ||
| 1606 | catch (e) { } | ||
| 1607 | } | ||
| 1608 | |||
| 1609 | function toggleFullScreen() { | ||
| 1610 | if (videoRemote.webkitSupportsFullscreen) { | ||
| 1611 | fullScreen(!videoRemote.webkitDisplayingFullscreen); | ||
| 1612 | } | ||
| 1613 | else { | ||
| 1614 | fullScreen(!bFullScreen); | ||
| 1615 | } | ||
| 1616 | } | ||
| 1617 | |||
| 1618 | function fullScreen(b_fs) { | ||
| 1619 | return false;//TODO | ||
| 1620 | bFullScreen = b_fs; | ||
| 1621 | if (tsk_utils_have_webrtc4native() && bFullScreen && videoRemote.webkitSupportsFullscreen) { | ||
| 1622 | if (bFullScreen) { | ||
| 1623 | videoRemote.webkitEnterFullScreen(); | ||
| 1624 | } | ||
| 1625 | else { | ||
| 1626 | videoRemote.webkitExitFullscreen(); | ||
| 1627 | } | ||
| 1628 | } | ||
| 1629 | else { | ||
| 1630 | if (tsk_utils_have_webrtc4npapi()) { | ||
| 1631 | try { if(window.__o_display_remote) window.__o_display_remote.setFullScreen(b_fs); } | ||
| 1632 | catch (e) { /*divVideo.setAttribute("class", b_fs ? "full-screen" : "normal-screen");*/ } | ||
| 1633 | } | ||
| 1634 | else { | ||
| 1635 | //divVideo.setAttribute("class", b_fs ? "full-screen" : "normal-screen"); | ||
| 1636 | } | ||
| 1637 | } | ||
| 1638 | } | ||
| 1639 | |||
| 1640 | function showNotifICall(s_number) { | ||
| 1641 | return false;//TODO | ||
| 1642 | // permission already asked when we registered | ||
| 1643 | if (window.webkitNotifications && window.webkitNotifications.checkPermission() == 0) { | ||
| 1644 | if (oNotifICall) { | ||
| 1645 | oNotifICall.cancel(); | ||
| 1646 | } | ||
| 1647 | oNotifICall = window.webkitNotifications.createNotification('images/sipml-34x39.png', 'Incaming call', 'Incoming call from ' + s_number); | ||
| 1648 | oNotifICall.onclose = function () { oNotifICall = null; }; | ||
| 1649 | oNotifICall.show(); | ||
| 1650 | } | ||
| 1651 | } | ||
| 1652 | |||
| 1653 | |||
| 1654 | function uiOnConnectionEvent(b_connected, b_connecting) { | ||
| 1655 | // should be enum: connecting, connected, terminating, terminated | ||
| 1656 | //TODO | ||
| 1657 | btnRegister = b_connected || b_connecting; | ||
| 1658 | btnUnRegister = !b_connected && !b_connecting; | ||
| 1659 | btnCall = !(b_connected && tsk_utils_have_webrtc() && tsk_utils_have_stream()); | ||
| 1660 | btnHangUp = !oSipSessionCall; | ||
| 1661 | } | ||
| 1662 | |||
| 1663 | function uiVideoDisplayEvent(b_local, b_added) { | ||
| 1664 | return false;//TODO | ||
| 1665 | var o_elt_video = b_local ? videoLocal : videoRemote; | ||
| 1666 | |||
| 1667 | if (b_added) { | ||
| 1668 | if (SIPml.isWebRtc4AllSupported()) { | ||
| 1669 | if (b_local) { | ||
| 1670 | if (WebRtc4all_GetDisplayLocal()) WebRtc4all_GetDisplayLocal().style.visibility = "visible"; | ||
| 1671 | if (WebRtc4all_GetDisplayLocalScreencast()) WebRtc4all_GetDisplayLocalScreencast().style.visibility = "visible"; | ||
| 1672 | //videoLocal.style.visibility = "visible"; | ||
| 1673 | //viewLocalScreencast.style.visibility = "visible"; | ||
| 1674 | //if (WebRtc4all_GetDisplayLocal()) WebRtc4all_GetDisplayLocal().hidden = false; | ||
| 1675 | //if (WebRtc4all_GetDisplayLocalScreencast()) WebRtc4all_GetDisplayLocalScreencast().hidden = false; | ||
| 1676 | } | ||
| 1677 | else { | ||
| 1678 | if (WebRtc4all_GetDisplayRemote()) WebRtc4all_GetDisplayRemote().style.visibility = "visible"; | ||
| 1679 | //videoRemote.style.visibility = "visible"; | ||
| 1680 | //if (WebRtc4all_GetDisplayRemote()) WebRtc4all_GetDisplayRemote().hidden = false; | ||
| 1681 | } | ||
| 1682 | } | ||
| 1683 | else { | ||
| 1684 | o_elt_video.style.opacity = 1; | ||
| 1685 | } | ||
| 1686 | uiVideoDisplayShowHide(true); | ||
| 1687 | } | ||
| 1688 | else { | ||
| 1689 | if (SIPml.isWebRtc4AllSupported()) { | ||
| 1690 | if (b_local) { | ||
| 1691 | if (WebRtc4all_GetDisplayLocal()) WebRtc4all_GetDisplayLocal().style.visibility = "hidden"; | ||
| 1692 | if (WebRtc4all_GetDisplayLocalScreencast()) WebRtc4all_GetDisplayLocalScreencast().style.visibility = "hidden"; | ||
| 1693 | //videoLocal.style.visibility = "hidden"; | ||
| 1694 | //viewLocalScreencast.style.visibility = "hidden"; | ||
| 1695 | //if (WebRtc4all_GetDisplayLocal()) WebRtc4all_GetDisplayLocal().hidden = true; | ||
| 1696 | //if (WebRtc4all_GetDisplayLocalScreencast()) WebRtc4all_GetDisplayLocalScreencast().hidden = true; | ||
| 1697 | } | ||
| 1698 | else { | ||
| 1699 | if (WebRtc4all_GetDisplayRemote()) WebRtc4all_GetDisplayRemote().style.visibility = "hidden"; | ||
| 1700 | //videoRemote.style.visibility = "hidden"; | ||
| 1701 | //if (WebRtc4all_GetDisplayRemote()) WebRtc4all_GetDisplayRemote().hidden = true; | ||
| 1702 | } | ||
| 1703 | } | ||
| 1704 | else{ | ||
| 1705 | o_elt_video.style.opacity = 0; | ||
| 1706 | } | ||
| 1707 | fullScreen(false); | ||
| 1708 | } | ||
| 1709 | } | ||
| 1710 | |||
| 1711 | function uiVideoDisplayShowHide(b_show) { | ||
| 1712 | //TODO | ||
| 1713 | if (b_show) { | ||
| 1714 | |||
| 1715 | } | ||
| 1716 | else { | ||
| 1717 | |||
| 1718 | } | ||
| 1719 | btnFullScreen.disabled = !b_show; | ||
| 1720 | } | ||
| 1721 | |||
| 1722 | function uiCallTerminated(s_description){ | ||
| 1723 | |||
| 1724 | btnCall = false; | ||
| 1725 | btnHangUp = true; | ||
| 1726 | |||
| 1727 | oSipSessionCall = null; | ||
| 1728 | |||
| 1729 | stopRingbackTone(); | ||
| 1730 | stopRingTone(); | ||
| 1731 | |||
| 1732 | txtCallStatus = "<i>" + s_description + "</i>"; | ||
| 1733 | uiVideoDisplayShowHide(false); | ||
| 1734 | //divCallOptions.style.opacity = 0; | ||
| 1735 | |||
| 1736 | if (oNotifICall) { | ||
| 1737 | oNotifICall.cancel(); | ||
| 1738 | oNotifICall = null; | ||
| 1739 | } | ||
| 1740 | |||
| 1741 | uiVideoDisplayEvent(true, false); | ||
| 1742 | uiVideoDisplayEvent(false, false); | ||
| 1743 | |||
| 1744 | setTimeout(function () { if (!oSipSessionCall) txtCallStatus = ''; }, 2500); | ||
| 1745 | |||
| 1746 | if(hangupgrowl)$.gritter.remove(hangupgrowl, {fade: true,speed: 'slow'}); | ||
| 1747 | } | ||
| 1748 | |||
| 1749 | // Callback function for SIP Stacks | ||
| 1750 | function onSipEventStack(e /*SIPml.Stack.Event*/) { | ||
| 1751 | tsk_utils_log_info('==stack event = ' + e.type); | ||
| 1752 | switch (e.type) { | ||
| 1753 | case 'started': | ||
| 1754 | { | ||
| 1755 | // catch exception for IE (DOM not ready) | ||
| 1756 | try { | ||
| 1757 | // LogIn (REGISTER) as soon as the stack finish starting | ||
| 1758 | oSipSessionRegister = this.newSession('register', { | ||
| 1759 | expires: 200, | ||
| 1760 | events_listener: { events: '*', listener: onSipEventSession }, | ||
| 1761 | sip_caps: [ | ||
| 1762 | { name: '+g.oma.sip-im', value: null }, | ||
| 1763 | { name: '+audio', value: null }, | ||
| 1764 | { name: 'language', value: '\"en,fr\"' } | ||
| 1765 | ] | ||
| 1766 | }); | ||
| 1767 | oSipSessionRegister.register(); | ||
| 1768 | } | ||
| 1769 | catch (e) { | ||
| 1770 | txtRegStatus = txtRegStatus = "<b>1:" + e + "</b>"; | ||
| 1771 | simpleNotification("success","topRight",txtRegStatus); | ||
| 1772 | btnRegister = false; | ||
| 1773 | } | ||
| 1774 | break; | ||
| 1775 | } | ||
| 1776 | case 'stopping': case 'stopped': case 'failed_to_start': case 'failed_to_stop': | ||
| 1777 | { | ||
| 1778 | var bFailure = (e.type == 'failed_to_start') || (e.type == 'failed_to_stop'); | ||
| 1779 | oSipStack = null; | ||
| 1780 | oSipSessionRegister = null; | ||
| 1781 | oSipSessionCall = null; | ||
| 1782 | |||
| 1783 | uiOnConnectionEvent(false, false); | ||
| 1784 | |||
| 1785 | stopRingbackTone(); | ||
| 1786 | stopRingTone(); | ||
| 1787 | |||
| 1788 | uiVideoDisplayShowHide(false); | ||
| 1789 | //divCallOptions.style.opacity = 0; | ||
| 1790 | |||
| 1791 | txtCallStatus = ''; | ||
| 1792 | if(loggedin) | ||
| 1793 | { | ||
| 1794 | txtRegStatus = bFailure ? "<i>Disconnected: <b>" + e.description + "</b></i>" : "<i>Disconnected</i>"; | ||
| 1795 | //simpleNotification("warning","topRight",txtRegStatus+", Retrying in 10 sec..."); | ||
| 1796 | //setTimeout(sipRegister,10*1000);//TODO dont retry too many times, idleapp instead | ||
| 1797 | document.location='/logout'; | ||
| 1798 | } | ||
| 1799 | else | ||
| 1800 | { | ||
| 1801 | if(e.type=='stopped')doLogout(1); | ||
| 1802 | } | ||
| 1803 | break; | ||
| 1804 | } | ||
| 1805 | |||
| 1806 | case 'i_new_call': | ||
| 1807 | { | ||
| 1808 | if (oSipSessionCall) { | ||
| 1809 | // do not accept the incoming call if we're already 'in call' | ||
| 1810 | e.newSession.hangup(); // comment this line for multi-line support | ||
| 1811 | } | ||
| 1812 | else { | ||
| 1813 | oSipSessionCall = e.newSession; | ||
| 1814 | |||
| 1815 | btnCall = 'Answer'; | ||
| 1816 | btnHangUp = 'Reject'; | ||
| 1817 | btnCall = false; | ||
| 1818 | btnHangUp = false; | ||
| 1819 | |||
| 1820 | var sRemoteNumber = (oSipSessionCall.getRemoteFriendlyName() || 'unknown'); | ||
| 1821 | |||
| 1822 | if(sRemoteNumber=='1000'+kstychAppObject['user']['sipid']) | ||
| 1823 | { | ||
| 1824 | //auto answer if own conf | ||
| 1825 | var dialerConnection=kGetDData("D","connection"); | ||
| 1826 | dialerConnection['connected']=1; | ||
| 1827 | updateDialerState("dialer","connection",dialerConnection); | ||
| 1828 | sipAnswer(); | ||
| 1829 | } | ||
| 1830 | else | ||
| 1831 | { | ||
| 1832 | startRingTone(); | ||
| 1833 | txtCallStatus = "<i><a href=# onclick='sipAnswer();return false;'>Incoming call Click Here To Answer</a></i> from [<b>" + sRemoteNumber + "</b>]"; | ||
| 1834 | //showNotifICall(sRemoteNumber); | ||
| 1835 | answergrowl=growlSNotify("Incoming Call",txtCallStatus,"top-right"); | ||
| 1836 | hangupgrowl=growlSNotify("Incoming Call","<a href=# onclick='sipHangUp();return false;' style='color:white'>Click here to hangup</a>","top-right"); | ||
| 1837 | } | ||
| 1838 | //showNotifICall(sRemoteNumber); | ||
| 1839 | } | ||
| 1840 | break; | ||
| 1841 | } | ||
| 1842 | |||
| 1843 | case 'm_permission_requested': | ||
| 1844 | { | ||
| 1845 | //document.getElementById('divNavbarInner').setAttribute('class', 'navbar-inner-red'); | ||
| 1846 | break; | ||
| 1847 | } | ||
| 1848 | case 'm_permission_accepted': | ||
| 1849 | case 'm_permission_refused': | ||
| 1850 | { | ||
| 1851 | //document.getElementById('divNavbarInner').setAttribute('class', 'navbar-inner'); | ||
| 1852 | if(e.type == 'm_permission_refused'){ | ||
| 1853 | uiCallTerminated('Media stream permission denied'); | ||
| 1854 | } | ||
| 1855 | break; | ||
| 1856 | } | ||
| 1857 | |||
| 1858 | case 'starting': default: break; | ||
| 1859 | } | ||
| 1860 | }; | ||
| 1861 | |||
| 1862 | // Callback function for SIP sessions (INVITE, REGISTER, MESSAGE...) | ||
| 1863 | function onSipEventSession(e /* SIPml.Session.Event */) { | ||
| 1864 | tsk_utils_log_info('==session event = ' + e.type); | ||
| 1865 | |||
| 1866 | switch (e.type) { | ||
| 1867 | case 'connecting': case 'connected': | ||
| 1868 | { | ||
| 1869 | var bConnected = (e.type == 'connected'); | ||
| 1870 | if (e.session == oSipSessionRegister) { | ||
| 1871 | uiOnConnectionEvent(bConnected, !bConnected); | ||
| 1872 | txtRegStatus = "<i>" + e.description + "</i>"; | ||
| 1873 | if(bConnected){/*simpleNotification("success","topRight","Connected");*//*$("#phonetopbar").show();*/kDialerConnected();} | ||
| 1874 | } | ||
| 1875 | else if (e.session == oSipSessionCall) { | ||
| 1876 | btnHangUp = 'HangUp'; | ||
| 1877 | btnCall = true; | ||
| 1878 | btnHangUp = false; | ||
| 1879 | btnTransfer = false; | ||
| 1880 | |||
| 1881 | if (bConnected) { | ||
| 1882 | stopRingbackTone(); | ||
| 1883 | stopRingTone(); | ||
| 1884 | |||
| 1885 | if (oNotifICall) { | ||
| 1886 | oNotifICall.cancel(); | ||
| 1887 | oNotifICall = null; | ||
| 1888 | } | ||
| 1889 | } | ||
| 1890 | |||
| 1891 | txtCallStatus = "<i>" + e.description + "</i>"; | ||
| 1892 | //simpleNotification("success","topRight",txtCallStatus); | ||
| 1893 | //divCallOptions.style.opacity = bConnected ? 1 : 0; | ||
| 1894 | |||
| 1895 | if (SIPml.isWebRtc4AllSupported()) { // IE don't provide stream callback | ||
| 1896 | uiVideoDisplayEvent(true, true); | ||
| 1897 | uiVideoDisplayEvent(false, true); | ||
| 1898 | } | ||
| 1899 | } | ||
| 1900 | break; | ||
| 1901 | } // 'connecting' | 'connected' | ||
| 1902 | case 'terminating': case 'terminated': | ||
| 1903 | { | ||
| 1904 | if (e.session == oSipSessionRegister) { | ||
| 1905 | uiOnConnectionEvent(false, false); | ||
| 1906 | |||
| 1907 | oSipSessionCall = null; | ||
| 1908 | oSipSessionRegister = null; | ||
| 1909 | |||
| 1910 | txtRegStatus = "<i>" + e.description + "</i>"; | ||
| 1911 | //simpleNotification("warning","topRight",txtRegStatus); | ||
| 1912 | } | ||
| 1913 | else if (e.session == oSipSessionCall) { | ||
| 1914 | uiCallTerminated(e.description); | ||
| 1915 | } | ||
| 1916 | break; | ||
| 1917 | } // 'terminating' | 'terminated' | ||
| 1918 | |||
| 1919 | case 'm_stream_video_local_added': | ||
| 1920 | { | ||
| 1921 | if (e.session == oSipSessionCall) { | ||
| 1922 | uiVideoDisplayEvent(true, true); | ||
| 1923 | } | ||
| 1924 | break; | ||
| 1925 | } | ||
| 1926 | case 'm_stream_video_local_removed': | ||
| 1927 | { | ||
| 1928 | if (e.session == oSipSessionCall) { | ||
| 1929 | uiVideoDisplayEvent(true, false); | ||
| 1930 | } | ||
| 1931 | break; | ||
| 1932 | } | ||
| 1933 | case 'm_stream_video_remote_added': | ||
| 1934 | { | ||
| 1935 | if (e.session == oSipSessionCall) { | ||
| 1936 | uiVideoDisplayEvent(false, true); | ||
| 1937 | } | ||
| 1938 | break; | ||
| 1939 | } | ||
| 1940 | case 'm_stream_video_remote_removed': | ||
| 1941 | { | ||
| 1942 | if (e.session == oSipSessionCall) { | ||
| 1943 | uiVideoDisplayEvent(false, false); | ||
| 1944 | } | ||
| 1945 | break; | ||
| 1946 | } | ||
| 1947 | |||
| 1948 | case 'm_stream_audio_local_added': | ||
| 1949 | case 'm_stream_audio_local_removed': | ||
| 1950 | case 'm_stream_audio_remote_added': | ||
| 1951 | case 'm_stream_audio_remote_removed': | ||
| 1952 | { | ||
| 1953 | break; | ||
| 1954 | } | ||
| 1955 | |||
| 1956 | case 'i_ect_new_call': | ||
| 1957 | { | ||
| 1958 | oSipSessionTransferCall = e.session; | ||
| 1959 | break; | ||
| 1960 | } | ||
| 1961 | |||
| 1962 | case 'i_ao_request': | ||
| 1963 | { | ||
| 1964 | if(e.session == oSipSessionCall){ | ||
| 1965 | var iSipResponseCode = e.getSipResponseCode(); | ||
| 1966 | if (iSipResponseCode == 180 || iSipResponseCode == 183) { | ||
| 1967 | startRingbackTone(); | ||
| 1968 | txtCallStatus = '<i>Remote ringing...</i>'; | ||
| 1969 | //simpleNotification("warning","topRight",txtCallStatus); | ||
| 1970 | } | ||
| 1971 | } | ||
| 1972 | break; | ||
| 1973 | } | ||
| 1974 | |||
| 1975 | case 'm_early_media': | ||
| 1976 | { | ||
| 1977 | if(e.session == oSipSessionCall){ | ||
| 1978 | stopRingbackTone(); | ||
| 1979 | stopRingTone(); | ||
| 1980 | txtCallStatus = '<i>Early media started</i>'; | ||
| 1981 | //simpleNotification("warning","topRight",txtCallStatus); | ||
| 1982 | } | ||
| 1983 | break; | ||
| 1984 | } | ||
| 1985 | |||
| 1986 | case 'm_local_hold_ok': | ||
| 1987 | { | ||
| 1988 | if(e.session == oSipSessionCall){ | ||
| 1989 | if (oSipSessionCall.bTransfering) { | ||
| 1990 | oSipSessionCall.bTransfering = false; | ||
| 1991 | // this.AVSession.TransferCall(this.transferUri); | ||
| 1992 | } | ||
| 1993 | btnHoldResume = false; | ||
| 1994 | txtCallStatus = '<i>Call placed on hold</i>'; | ||
| 1995 | oSipSessionCall.bHeld = true; | ||
| 1996 | //simpleNotification("success","topRight",txtCallStatus); | ||
| 1997 | } | ||
| 1998 | break; | ||
| 1999 | } | ||
| 2000 | case 'm_local_hold_nok': | ||
| 2001 | { | ||
| 2002 | if(e.session == oSipSessionCall){ | ||
| 2003 | oSipSessionCall.bTransfering = false; | ||
| 2004 | btnHoldResume = false; | ||
| 2005 | txtCallStatus = '<i>Failed to place remote party on hold</i>'; | ||
| 2006 | //simpleNotification("error","topRight",txtCallStatus); | ||
| 2007 | } | ||
| 2008 | break; | ||
| 2009 | } | ||
| 2010 | case 'm_local_resume_ok': | ||
| 2011 | { | ||
| 2012 | if(e.session == oSipSessionCall){ | ||
| 2013 | oSipSessionCall.bTransfering = false; | ||
| 2014 | btnHoldResume = false; | ||
| 2015 | txtCallStatus = '<i>Call taken off hold</i>'; | ||
| 2016 | oSipSessionCall.bHeld = false; | ||
| 2017 | //simpleNotification("warning","topRight",txtCallStatus); | ||
| 2018 | |||
| 2019 | if (SIPml.isWebRtc4AllSupported()) { // IE don't provide stream callback yet | ||
| 2020 | uiVideoDisplayEvent(true, true); | ||
| 2021 | uiVideoDisplayEvent(false, true); | ||
| 2022 | } | ||
| 2023 | } | ||
| 2024 | break; | ||
| 2025 | } | ||
| 2026 | case 'm_local_resume_nok': | ||
| 2027 | { | ||
| 2028 | if(e.session == oSipSessionCall){ | ||
| 2029 | oSipSessionCall.bTransfering = false; | ||
| 2030 | btnHoldResume = false; | ||
| 2031 | txtCallStatus = '<i>Failed to unhold call</i>'; | ||
| 2032 | //simpleNotification("error","topRight",txtCallStatus); | ||
| 2033 | } | ||
| 2034 | break; | ||
| 2035 | } | ||
| 2036 | case 'm_remote_hold': | ||
| 2037 | { | ||
| 2038 | if(e.session == oSipSessionCall){ | ||
| 2039 | txtCallStatus = '<i>Placed on hold by remote party</i>'; | ||
| 2040 | //simpleNotification("warning","topRight",txtCallStatus); | ||
| 2041 | } | ||
| 2042 | break; | ||
| 2043 | } | ||
| 2044 | case 'm_remote_resume': | ||
| 2045 | { | ||
| 2046 | if(e.session == oSipSessionCall){ | ||
| 2047 | txtCallStatus = '<i>Taken off hold by remote party</i>'; | ||
| 2048 | //simpleNotification("warning","topRight",txtCallStatus); | ||
| 2049 | } | ||
| 2050 | break; | ||
| 2051 | } | ||
| 2052 | case 'm_bfcp_info': | ||
| 2053 | { | ||
| 2054 | if(e.session == oSipSessionCall){ | ||
| 2055 | txtCallStatus.innerHTML = 'BFCP Info: <i>'+ e.description +'</i>'; | ||
| 2056 | } | ||
| 2057 | break; | ||
| 2058 | } | ||
| 2059 | case 'o_ect_trying': | ||
| 2060 | { | ||
| 2061 | if(e.session == oSipSessionCall){ | ||
| 2062 | txtCallStatus = '<i>Call transfer in progress...</i>'; | ||
| 2063 | //simpleNotification("warning","topRight",txtCallStatus); | ||
| 2064 | } | ||
| 2065 | break; | ||
| 2066 | } | ||
| 2067 | case 'o_ect_accepted': | ||
| 2068 | { | ||
| 2069 | if(e.session == oSipSessionCall){ | ||
| 2070 | txtCallStatus = '<i>Call transfer accepted</i>'; | ||
| 2071 | //simpleNotification("success","topRight",txtCallStatus); | ||
| 2072 | } | ||
| 2073 | break; | ||
| 2074 | } | ||
| 2075 | case 'o_ect_completed': | ||
| 2076 | case 'i_ect_completed': | ||
| 2077 | { | ||
| 2078 | if(e.session == oSipSessionCall){ | ||
| 2079 | txtCallStatus = '<i>Call transfer completed</i>'; | ||
| 2080 | //simpleNotification("success","topRight",txtCallStatus); | ||
| 2081 | btnTransfer = false; | ||
| 2082 | if (oSipSessionTransferCall) { | ||
| 2083 | oSipSessionCall = oSipSessionTransferCall; | ||
| 2084 | } | ||
| 2085 | oSipSessionTransferCall = null; | ||
| 2086 | } | ||
| 2087 | break; | ||
| 2088 | } | ||
| 2089 | case 'o_ect_failed': | ||
| 2090 | case 'i_ect_failed': | ||
| 2091 | { | ||
| 2092 | if(e.session == oSipSessionCall){ | ||
| 2093 | txtCallStatus = '<i>Call transfer failed</i>'; | ||
| 2094 | //simpleNotification("error","topRight",txtCallStatus); | ||
| 2095 | btnTransfer = false; | ||
| 2096 | } | ||
| 2097 | break; | ||
| 2098 | } | ||
| 2099 | case 'o_ect_notify': | ||
| 2100 | case 'i_ect_notify': | ||
| 2101 | { | ||
| 2102 | if(e.session == oSipSessionCall){ | ||
| 2103 | txtCallStatus = "<i>Call Transfer: <b>" + e.getSipResponseCode() + " " + e.description + "</b></i>"; | ||
| 2104 | //simpleNotification("success","topRight",txtCallStatus); | ||
| 2105 | if (e.getSipResponseCode() >= 300) { | ||
| 2106 | if (oSipSessionCall.bHeld) { | ||
| 2107 | oSipSessionCall.resume(); | ||
| 2108 | } | ||
| 2109 | btnTransfer = false; | ||
| 2110 | } | ||
| 2111 | } | ||
| 2112 | break; | ||
| 2113 | } | ||
| 2114 | case 'i_ect_requested': | ||
| 2115 | { | ||
| 2116 | if(e.session == oSipSessionCall){ | ||
| 2117 | var s_message = "Do you accept call transfer to [" + e.getTransferDestinationFriendlyName() + "]?";//FIXME | ||
| 2118 | if (confirm(s_message)) { | ||
| 2119 | txtCallStatus = "<i>Call transfer in progress...</i>"; | ||
| 2120 | //simpleNotification("warning","topRight",txtCallStatus); | ||
| 2121 | oSipSessionCall.acceptTransfer(); | ||
| 2122 | break; | ||
| 2123 | } | ||
| 2124 | oSipSessionCall.rejectTransfer(); | ||
| 2125 | } | ||
| 2126 | break; | ||
| 2127 | } | ||
| 2128 | |||
| 2129 | } | ||
| 2130 | } | ||
| 2131 | |||
| 2132 | |||
| 2133 | function dialerSipMsg(omsg) | ||
| 2134 | { | ||
| 2135 | try | ||
| 2136 | { | ||
| 2137 | if(omsg.ao_headers[6].s_name=='kstych-data') | ||
| 2138 | { | ||
| 2139 | var vparts=omsg.ao_headers[6].s_value.split("|"); | ||
| 2140 | |||
| 2141 | vparts[1]=atob(vparts[1]); | ||
| 2142 | vparts[2]=atob(vparts[2]); | ||
| 2143 | |||
| 2144 | if(vparts[0]=="chat")incomingChat(vparts[1],vparts[2],vparts[3]); | ||
| 2145 | else if(vparts[0]=="presence")incomingPresense(vparts[1],vparts[2],vparts[3]); | ||
| 2146 | else if(vparts[0]=="wallreload")incomingwallReload(vparts[1],vparts[2],vparts[3]); | ||
| 2147 | else if(vparts[0]=="liveconf")incomingLiveconf(vparts[1],vparts[2],vparts[3]); | ||
| 2148 | else if(vparts[0]=="notify")incomingNotification(vparts[1],vparts[2],vparts[3]); | ||
| 2149 | else if(vparts[0]=="popupalert")incomingPopupAlert(vparts[1],vparts[2],vparts[3]); | ||
| 2150 | |||
| 2151 | else if(vparts[0]=="incomingCall")incomingCall(vparts[1],vparts[2],vparts[3]); | ||
| 2152 | else if(vparts[0]=="dialerUI")dialerUIUpdate(vparts[1],vparts[2],vparts[3]); | ||
| 2153 | |||
| 2154 | else if(vparts[0]=="adminCommand")adminCommand(vparts[1],vparts[2],vparts[3]); | ||
| 2155 | } | ||
| 2156 | //if(omsg.ao_headers.) | ||
| 2157 | //window.console.log(omsg.ao_headers[6]); | ||
| 2158 | } | ||
| 2159 | catch(e){} | ||
| 2160 | } |
| 1 | var loggedin=0; | ||
| 2 | |||
| 3 | var sTransferNumber; | ||
| 4 | var oRingTone, oRingbackTone; | ||
| 5 | var oSipStack, oSipSessionRegister, oSipSessionCall, oSipSessionTransferCall; | ||
| 6 | var videoRemote, videoLocal, audioRemote; | ||
| 7 | var bFullScreen = false; | ||
| 8 | var oNotifICall; | ||
| 9 | var bDisableVideo = false; | ||
| 10 | var viewLocalScreencast; // <video> (webrtc) or <div> (webrtc4all) | ||
| 11 | var oConfigCall; | ||
| 12 | var oReadyStateTimer; | ||
| 13 | |||
| 14 | var divVideo, divCallOptions; | ||
| 15 | var hangupgrowl=0; | ||
| 16 | var answergrowl=0; | ||
| 17 | var txtDisplayName, txtPrivateIdentity, txtPublicIdentity, txtRealm; | ||
| 18 | var txtPhoneNumber; | ||
| 19 | var btnCall, btnHangUp; | ||
| 20 | var txtRegStatus, txtCallStatus; | ||
| 21 | var btnRegister, btnUnRegister; | ||
| 22 | var btnFullScreen, btnHoldResume, btnTransfer, btnKeyPad; | ||
| 23 | |||
| 24 | |||
| 25 | var kstychDialer={}; | ||
| 26 | kstychDialer['mDialerState']='Paused'; | ||
| 27 | kstychDialer['mDialerSubState']='NotReady'; | ||
| 28 | kstychDialer['mDialerCampaign']=''; | ||
| 29 | kstychDialer['mdispodata']=''; | ||
| 30 | kstychDialer['mDialNextStatus']='New'; | ||
| 31 | kstychDialer['mmanualallow']='No'; | ||
| 32 | kstychDialer['pendingDataSize']=0; | ||
| 33 | kstychDialer['phone']=kstychAppObject['user']['sipid']; | ||
| 34 | kstychDialer['connection']={'number':'1000'+kstychAppObject['user']['sipid'],'connected':0,'mic':1,'speaker':1,'channel':'','holdext':''}; | ||
| 35 | kstychDialer["keeplocalconf"]=kstychAppObject['config']['kDialer_keeplocalconf']; | ||
| 36 | kstychDialer['RedialLast']=''; | ||
| 37 | |||
| 38 | var kstychCall={}; | ||
| 39 | kstychCall['mCallState']='Wait'; //states : ,Wait,Call,Dispo,Close | ||
| 40 | kstychCall['ts_Wait']=getNowTS(); | ||
| 41 | kstychCall['ts_Call']=0; | ||
| 42 | kstychCall['ts_Talk']=0; | ||
| 43 | kstychCall['ts_Dispo']=0; | ||
| 44 | kstychCall['ts_Close']=0; | ||
| 45 | kstychCall['callnumber']=''; | ||
| 46 | kstychCall['connections']={}; | ||
| 47 | kstychCall['callid']=''; | ||
| 48 | kstychCall['crmid']=''; | ||
| 49 | kstychCall['campaignid']=''; | ||
| 50 | kstychCall['listid']=''; | ||
| 51 | kstychCall['mdial_CallACK']=0; | ||
| 52 | kstychCall['mcalldata']=''; | ||
| 53 | kstychCall['userstatus']=''; | ||
| 54 | kstychCall['usersubstatus']=''; | ||
| 55 | kstychCall['usercallback']=''; | ||
| 56 | kstychCall['userremarks']=''; | ||
| 57 | kstychCall['userdata']={}; | ||
| 58 | kstychCall['previewcrmid']=''; | ||
| 59 | kstychCall['callWrapupTime']=300; | ||
| 60 | kstychCall['prograssiveDelay']=120; | ||
| 61 | kstychCall['ts_now']=0; | ||
| 62 | |||
| 63 | kstychCall['bttc_day']=''; | ||
| 64 | kstychCall['bttc_hrs']=''; | ||
| 65 | kstychCall['serv_vs_prod']=''; | ||
| 66 | kstychCall['resolution']=''; | ||
| 67 | kstychCall['satisfy']=''; | ||
| 68 | kstychCall['final_call_assess']=''; | ||
| 69 | |||
| 70 | function kGetDData(obj,key) | ||
| 71 | { | ||
| 72 | if(obj=="D") | ||
| 73 | { | ||
| 74 | if(kstychDialer[key])return kstychDialer[key]; | ||
| 75 | } | ||
| 76 | if(obj=="C") | ||
| 77 | { | ||
| 78 | if(kstychCall[key])return kstychCall[key]; | ||
| 79 | } | ||
| 80 | return false; | ||
| 81 | } | ||
| 82 | function kSetDData(obj,key,val) | ||
| 83 | { | ||
| 84 | if(obj=="D") | ||
| 85 | { | ||
| 86 | kstychDialer[key]=val; | ||
| 87 | } | ||
| 88 | if(obj=="C") | ||
| 89 | { | ||
| 90 | kstychCall[key]=val; | ||
| 91 | } | ||
| 92 | |||
| 93 | //TODO update backend user session (userlog) | ||
| 94 | return false; | ||
| 95 | } | ||
| 96 | |||
| 97 | function getNowTS() | ||
| 98 | { | ||
| 99 | return Math.floor(Date.now()); | ||
| 100 | } | ||
| 101 | |||
| 102 | function kcallNewConnection(number) | ||
| 103 | { | ||
| 104 | var clines=kGetDData('C','connections'); | ||
| 105 | if(!clines[number]) | ||
| 106 | { | ||
| 107 | clines[number]={}; | ||
| 108 | clines[number]['connected']=0; | ||
| 109 | clines[number]['channel']=''; | ||
| 110 | clines[number]['callid']=''; | ||
| 111 | clines[number]['ts_Call']=0; | ||
| 112 | clines[number]['ts_Talk']=0; | ||
| 113 | clines[number]['ts_Dispo']=0; | ||
| 114 | clines[number]['speaker']=1; | ||
| 115 | clines[number]['mic']=1; | ||
| 116 | clines[number]['holdext']=''; | ||
| 117 | kSetDData('C','connections',clines); | ||
| 118 | } | ||
| 119 | } | ||
| 120 | function kcallSetConnection(number,key,val) | ||
| 121 | { | ||
| 122 | kcallNewConnection(number); | ||
| 123 | var clines=kGetDData('C','connections'); | ||
| 124 | clines[number][key]=val; | ||
| 125 | kSetDData('C','connections',clines); | ||
| 126 | } | ||
| 127 | function kcallGetConnection(number,key) | ||
| 128 | { | ||
| 129 | kcallNewConnection(number); | ||
| 130 | var clines=kGetDData('C','connections'); | ||
| 131 | return clines[number][key]; | ||
| 132 | } | ||
| 133 | function kcallHasConnection(number) | ||
| 134 | { | ||
| 135 | var clines=kGetDData('C','connections'); | ||
| 136 | if(!clines[number])return false; | ||
| 137 | return true; | ||
| 138 | } | ||
| 139 | |||
| 140 | function dialerQuickOpen(varid,num,state,substate,autorun) | ||
| 141 | { | ||
| 142 | if(kstychCall['mCallState']=="Wait") | ||
| 143 | { | ||
| 144 | var oldpreviewid=kstychCall['previewcrmid']; | ||
| 145 | kstychCall['previewcrmid']=''; | ||
| 146 | kstychCall['callnumber']=''; | ||
| 147 | kstychCall['crmid']=''; | ||
| 148 | |||
| 149 | if(varid!=''&&varid>0) | ||
| 150 | { | ||
| 151 | if(num!=''&&num!='0') | ||
| 152 | { | ||
| 153 | kstychCall['callnumber']=num; | ||
| 154 | $("#manualdialnumber_txt").val(num); | ||
| 155 | } | ||
| 156 | |||
| 157 | if(oldpreviewid!=varid||state!=kstychDialer['mDialerState']) | ||
| 158 | { | ||
| 159 | kstychCall['previewcrmid']=varid;//progressiveDelay set to 1 //TODO | ||
| 160 | updateDialerState("dialer","mDialerState",state,"mDialerSubState",substate); | ||
| 161 | } | ||
| 162 | else | ||
| 163 | { | ||
| 164 | kstychCall['previewcrmid']=varid; | ||
| 165 | updateDialerState(); | ||
| 166 | } | ||
| 167 | kDialerModel(); | ||
| 168 | } | ||
| 169 | else | ||
| 170 | { | ||
| 171 | if(num!='') | ||
| 172 | { | ||
| 173 | $("#manualdialnumber_txt").val(num); | ||
| 174 | updateDialerState("dialer","mDialerState","Manual"); | ||
| 175 | kDialerModel(); | ||
| 176 | if(autorun==1)setTimeout(function(){$("#manualdial_btn").click()},350); | ||
| 177 | } | ||
| 178 | } | ||
| 179 | } | ||
| 180 | else | ||
| 181 | { | ||
| 182 | simpleNotification('error','topRight',"Already on call!"); | ||
| 183 | } | ||
| 184 | } | ||
| 185 | function dialerAddAlt(i,varid) | ||
| 186 | { | ||
| 187 | var phone=$("#dialer_altphone"+i).val(); | ||
| 188 | var desc=$("#dialer_altphone_lbl_"+i).val(); | ||
| 189 | |||
| 190 | if(!/^\d{10}$/.test(phone)&&!/^\d{11}$/.test(phone)) | ||
| 191 | { | ||
| 192 | simpleNotification('error','topRight',"Please enter 10 or 11 neumeric digits only"); | ||
| 193 | return; | ||
| 194 | } | ||
| 195 | if(desc=="") | ||
| 196 | { | ||
| 197 | simpleNotification('error','topRight',"Please enter number description"); | ||
| 198 | return; | ||
| 199 | } | ||
| 200 | |||
| 201 | if(phone!="") | ||
| 202 | { | ||
| 203 | var data="varid="+varid; | ||
| 204 | data+="&keys=altphone"+i+",altphone_lbl_"+i; | ||
| 205 | data+="&altphone"+i+"="+phone; | ||
| 206 | data+="&altphone_lbl_"+i+"="+desc; | ||
| 207 | |||
| 208 | doAjax('record?action=addkey',data,'dialersearchresults', 'ajax_manualdial','singlefail','POST', function(retstr){ | ||
| 209 | $("#dialersearchresults").html('<div id=divworking></div><div style="clear:both"></div>'); | ||
| 210 | showRecruit(varid); | ||
| 211 | }); | ||
| 212 | } | ||
| 213 | |||
| 214 | } | ||
| 215 | function dialerDelAlt(i,varid) | ||
| 216 | { | ||
| 217 | doAjax('record?action=delaltphone&i='+i+'&varid='+varid,'','dialersearchresults', 'ajax_manualdial','singlefail','POST', function(retstr){ | ||
| 218 | $("#dialersearchresults").html('<div id=divworking></div><div style="clear:both"></div>'); | ||
| 219 | showRecruit(varid); | ||
| 220 | }); | ||
| 221 | } | ||
| 222 | |||
| 223 | function kDialerSpy(sipid,fun) | ||
| 224 | { | ||
| 225 | var datastr="kstychCall="+JSON.stringify(kstychCall); | ||
| 226 | datastr+="&kstychDialer="+JSON.stringify(kstychDialer); | ||
| 227 | |||
| 228 | datastr+="&sipid="+sipid; | ||
| 229 | datastr+="&mode="+fun; | ||
| 230 | |||
| 231 | try{sipHangUp();}catch(e){console.log(e);} | ||
| 232 | doAjax('dialer?action=spychannel',datastr,'__fake__div__', 'ajax_spydial','singlefail','POST', function(retstr){ | ||
| 233 | |||
| 234 | }); | ||
| 235 | } | ||
| 236 | function kCallAction(num,action) | ||
| 237 | { | ||
| 238 | //action : MuteSpeaker,UnMuteSpeaker,MuteMic,UnMuteMic,Hangup,Hold,UnHold | ||
| 239 | if(num=="u") | ||
| 240 | { | ||
| 241 | if(action=="MuteMic")kstychDialer['connection']['mic']=sipToggleMute(); | ||
| 242 | if(action=="UnMuteMic")kstychDialer['connection']['mic']=sipToggleMute(); | ||
| 243 | if(action=="MuteSpeaker"); | ||
| 244 | if(action=="UnMuteSpeaker"); | ||
| 245 | if(action=="Hangup"); | ||
| 246 | //if(action=="Hold"); | ||
| 247 | //if(action=="UnHold"); | ||
| 248 | } | ||
| 249 | else | ||
| 250 | { | ||
| 251 | if(num=="c")num=kstychCall['callnumber']; | ||
| 252 | var channel=kcallGetConnection(num,'channel'); | ||
| 253 | if(channel!='') | ||
| 254 | { | ||
| 255 | if(action=="MuteMic")kcallSetConnection(num,'mic',0); | ||
| 256 | if(action=="UnMuteMic")kcallSetConnection(num,'mic',1); | ||
| 257 | if(action=="MuteSpeaker")kcallSetConnection(num,'speaker',0); | ||
| 258 | if(action=="UnMuteSpeaker")kcallSetConnection(num,'speaker',1); | ||
| 259 | if(action=="Hangup"); | ||
| 260 | //if(action=="Hold")kcallSetConnection(num,'holdext'); | ||
| 261 | //if(action=="UnHold")kcallSetConnection(num,'holdext'); | ||
| 262 | |||
| 263 | doAjax('dialer?action=kCallAction&actiontype='+action+'&conf='+kstychDialer['connection']['number']+'&channel='+channel,'','__fake__div__', 'ajax_confdial','singlefail','POST', function(retstr){ | ||
| 264 | |||
| 265 | }); | ||
| 266 | } | ||
| 267 | else simpleNotification('error','topRight',"No Channel for ["+num+"]"); | ||
| 268 | } | ||
| 269 | |||
| 270 | updateDialerState(); | ||
| 271 | } | ||
| 272 | |||
| 273 | function dialerDispNumberClick() | ||
| 274 | { | ||
| 275 | var lastnumber=$("#spandialer_num").html(); | ||
| 276 | |||
| 277 | if(kstychCall['mCallState']=="Dispo") | ||
| 278 | { | ||
| 279 | saveCloseDialerCall("REDIAL"); | ||
| 280 | } | ||
| 281 | } | ||
| 282 | function dialerAddConfCall() | ||
| 283 | { | ||
| 284 | var confnumber=$("#dialerConfNumberTxt").val(); | ||
| 285 | if(confnumber==''||confnumber.length<2) | ||
| 286 | { | ||
| 287 | simpleNotification('error','topRight',"Empty Number"); | ||
| 288 | return; | ||
| 289 | } | ||
| 290 | |||
| 291 | if(!kcallHasConnection(kstychCall['callnumber'])||kstychCall['ts_Dispo']>1) | ||
| 292 | { | ||
| 293 | simpleNotification('error','topRight',"No call to conference"); | ||
| 294 | return; | ||
| 295 | } | ||
| 296 | |||
| 297 | var datastr="kstychCall="+JSON.stringify(kstychCall); | ||
| 298 | datastr+="&kstychDialer="+JSON.stringify(kstychDialer); | ||
| 299 | |||
| 300 | kcallNewConnection(confnumber); | ||
| 301 | doAjax('dialer?action=addconfcall&confnumber='+confnumber,datastr,'__fake__div__', 'ajax_confdial','singlefail','POST', function(retstr){ | ||
| 302 | if(retstr.responseText.indexOf('Error')<0) | ||
| 303 | { | ||
| 304 | kcallSetConnection(confnumber,'callid',retstr.responseText); | ||
| 305 | kcallSetConnection(confnumber,'ts_Call',getNowTS()); | ||
| 306 | |||
| 307 | updateDialerState(); | ||
| 308 | } | ||
| 309 | else | ||
| 310 | { | ||
| 311 | simpleNotification('error','topRight',retstr.responseText); | ||
| 312 | } | ||
| 313 | }); | ||
| 314 | } | ||
| 315 | |||
| 316 | function incomingCall(calllog,crmid,number) | ||
| 317 | { | ||
| 318 | $("#dialersearchresults").html('<div id=divworking></div><div style="clear:both"></div>'); | ||
| 319 | |||
| 320 | kcallSetConnection(number,'callid',calllog); | ||
| 321 | kcallSetConnection(number,'connected',1); | ||
| 322 | |||
| 323 | kSetDData('C','callid',calllog); | ||
| 324 | kSetDData('C','crmid',crmid); | ||
| 325 | |||
| 326 | if(crmid>0)showRecruit(crmid); | ||
| 327 | else | ||
| 328 | { | ||
| 329 | createSearchRecordDiv('dialersearchresults'); | ||
| 330 | } | ||
| 331 | |||
| 332 | kSetDData('C','mCallState','Call'); | ||
| 333 | kSetDData('C','ts_Call',getNowTS()); | ||
| 334 | kSetDData('C','ts_Talk',getNowTS()); | ||
| 335 | |||
| 336 | kstychCall["callnumber"]=number; | ||
| 337 | |||
| 338 | updateDialerState(); | ||
| 339 | kDialerModel(); | ||
| 340 | } | ||
| 341 | |||
| 342 | function dialerUIUpdate(var1,var2,var3) | ||
| 343 | { | ||
| 344 | var3parts=var3.split("~"); | ||
| 345 | var3parts[2]=atob(var3parts[2]); | ||
| 346 | if(var1=="dialstart") | ||
| 347 | { | ||
| 348 | if(var2=="c") | ||
| 349 | { | ||
| 350 | if(var3parts[1]&&var3parts[1]!="") | ||
| 351 | { | ||
| 352 | kcallSetConnection(var3parts[1],'connected',1); | ||
| 353 | kcallSetConnection(var3parts[1],'channel',var3parts[2]); | ||
| 354 | kcallSetConnection(var3parts[1],'ts_Call',getNowTS()); | ||
| 355 | if(var3parts[1]==kstychCall['callnumber'])kSetDData('C','ts_Call',getNowTS()); | ||
| 356 | |||
| 357 | updateDialerState(); | ||
| 358 | } | ||
| 359 | } | ||
| 360 | else if(var2=="u") | ||
| 361 | { | ||
| 362 | var dialerConnection=kGetDData("D","connection"); | ||
| 363 | dialerConnection['channel']=var3parts[2]; | ||
| 364 | kSetDData("D","connection",dialerConnection); | ||
| 365 | } | ||
| 366 | } | ||
| 367 | |||
| 368 | if(var1=="dialend") | ||
| 369 | { | ||
| 370 | if(var2=="c") | ||
| 371 | { | ||
| 372 | if(var3parts[1]&&var3parts[1]!="") | ||
| 373 | { | ||
| 374 | kcallSetConnection(var3parts[1],'connected',1); | ||
| 375 | kcallSetConnection(var3parts[1],'channel',var3parts[2]); | ||
| 376 | kcallSetConnection(var3parts[1],'ts_Talk',getNowTS()); | ||
| 377 | if(var3parts[1]==kstychCall['callnumber'])kSetDData('C','ts_Talk',getNowTS()); | ||
| 378 | |||
| 379 | updateDialerState(); | ||
| 380 | } | ||
| 381 | } | ||
| 382 | } | ||
| 383 | |||
| 384 | if(var1=="hangup") | ||
| 385 | { | ||
| 386 | if(var2=="c") | ||
| 387 | { | ||
| 388 | if(var3parts[1]&&var3parts[1]!="") | ||
| 389 | { | ||
| 390 | kcallSetConnection(var3parts[1],'connected',0); | ||
| 391 | if(kcallGetConnection(var3parts[1],'ts_Call')==0)kcallSetConnection(var3parts[1],'ts_Call',getNowTS()); | ||
| 392 | if(kcallGetConnection(var3parts[1],'ts_Talk')==0)kcallSetConnection(var3parts[1],'ts_Talk',getNowTS()); | ||
| 393 | kcallSetConnection(var3parts[1],'ts_Dispo',getNowTS()); | ||
| 394 | |||
| 395 | if(var3parts[1]==kstychCall['callnumber']) | ||
| 396 | { | ||
| 397 | if(kstychCall['ts_Call']==0)kSetDData('C','ts_Call',getNowTS()); | ||
| 398 | if(kstychCall['ts_Talk']==0)kSetDData('C','ts_Talk',getNowTS()); | ||
| 399 | |||
| 400 | kSetDData('C','ts_Dispo',getNowTS()); | ||
| 401 | hangupCall(); | ||
| 402 | } | ||
| 403 | |||
| 404 | updateDialerState(); | ||
| 405 | } | ||
| 406 | } | ||
| 407 | } | ||
| 408 | } | ||
| 409 | |||
| 410 | function incomingPopupAlert(var1,var2,var3) | ||
| 411 | { | ||
| 412 | //var incomingnotify=growlSNotify(var1,var2,"top-right"); | ||
| 413 | //setTimeout(function(){$.gritter.remove(incomingnotify, {fade: true,speed: 'slow'});incomingnotify=0;},1500); | ||
| 414 | |||
| 415 | $.titleAlert(var1+" "+var2, { | ||
| 416 | requireBlur:true, | ||
| 417 | stopOnFocus:true, | ||
| 418 | duration:1500, | ||
| 419 | interval:500 | ||
| 420 | }); | ||
| 421 | |||
| 422 | kDesktopNotification("",var1,var2,1500); | ||
| 423 | } | ||
| 424 | |||
| 425 | function outgoingCall() | ||
| 426 | { | ||
| 427 | $("#dialersearchresults").html(""); | ||
| 428 | kSetDData('C','callnumber',$("#manualdialnumber_txt").val()); | ||
| 429 | |||
| 430 | var datastr="kstychCall="+JSON.stringify(kstychCall); | ||
| 431 | datastr+="&kstychDialer="+JSON.stringify(kstychDialer); | ||
| 432 | |||
| 433 | if(kstychDialer['mDialerState']=="Manual") | ||
| 434 | { | ||
| 435 | if(kstychCall['callnumber']!="") | ||
| 436 | { | ||
| 437 | doAjax('dialer?action=newcall',datastr,'dialersearchresults', 'ajax_manualdial','singlefail','POST', function(retstr){ | ||
| 438 | if(kstychCall['crmid']!="") | ||
| 439 | { | ||
| 440 | kSetDData('C','mCallState','Call'); | ||
| 441 | kSetDData('C','ts_Call',getNowTS()); | ||
| 442 | |||
| 443 | if(kstychCall['crmid']==0) | ||
| 444 | { | ||
| 445 | createSearchRecordDiv('dialersearchresults'); | ||
| 446 | } | ||
| 447 | updateDialerState(); | ||
| 448 | } | ||
| 449 | else | ||
| 450 | { | ||
| 451 | kSetDData('C','previewcrmid',''); | ||
| 452 | updateDialerState("dialer","mDialerState","Manual"); | ||
| 453 | } | ||
| 454 | }); | ||
| 455 | } | ||
| 456 | else | ||
| 457 | { | ||
| 458 | simpleNotification('error','topRight',"Empty Number"); | ||
| 459 | } | ||
| 460 | } | ||
| 461 | if(kstychDialer['mDialerState']=="DialNext") | ||
| 462 | { | ||
| 463 | doAjax('dialer?action=newcall',datastr,'dialersearchresults', 'ajax_manualdial','singlefail','POST', function(retstr){ | ||
| 464 | if(kstychCall['crmid']!="") | ||
| 465 | { | ||
| 466 | kSetDData('C','mCallState','Call'); | ||
| 467 | kSetDData('C','ts_Call',getNowTS()); | ||
| 468 | |||
| 469 | updateDialerState(); | ||
| 470 | } | ||
| 471 | else | ||
| 472 | { | ||
| 473 | simpleNotification('error','topRight',"Failed to Dial Next ["+kstychDialer['mDialNextStatus']+"] Record"); | ||
| 474 | |||
| 475 | kSetDData('C','previewcrmid',''); | ||
| 476 | updateDialerState("dialer","mDialerState","DialNext"); | ||
| 477 | } | ||
| 478 | }); | ||
| 479 | } | ||
| 480 | if(kstychDialer['mDialerState']=="Progressive") | ||
| 481 | { | ||
| 482 | doAjax('dialer?action=newcall',datastr,'dialersearchresults', 'ajax_manualdial','singlefail','POST', function(retstr){ | ||
| 483 | if(kstychCall['crmid']!="") | ||
| 484 | { | ||
| 485 | kSetDData('C','mCallState','Call'); | ||
| 486 | kSetDData('C','ts_Call',getNowTS()); | ||
| 487 | |||
| 488 | updateDialerState(); | ||
| 489 | } | ||
| 490 | else | ||
| 491 | { | ||
| 492 | simpleNotification('error','topRight',"Failed to Dial Next ["+kstychDialer['mDialNextStatus']+"] Record"); | ||
| 493 | //Cleanup? | ||
| 494 | |||
| 495 | kSetDData('C','previewcrmid',''); | ||
| 496 | updateDialerState("dialer","mDialerState","DialNext"); | ||
| 497 | } | ||
| 498 | }); | ||
| 499 | } | ||
| 500 | |||
| 501 | |||
| 502 | //check if current state is valid to make a call | ||
| 503 | //prepare ajax parameters | ||
| 504 | //call dialer controller to submit request | ||
| 505 | //check return values for success | ||
| 506 | //update dialer and call objects | ||
| 507 | } | ||
| 508 | function hangupCall() | ||
| 509 | { | ||
| 510 | kstychCall['ts_now']=getNowTS(); | ||
| 511 | |||
| 512 | var datastr="kstychCall="+JSON.stringify(kstychCall); | ||
| 513 | datastr+="&kstychDialer="+JSON.stringify(kstychDialer); | ||
| 514 | doAjax('dialer?action=hangupall',datastr,'', 'ajax_manualdial','singlefail','POST', | ||
| 515 | function(retstr){ | ||
| 516 | |||
| 517 | if(retstr.responseText.indexOf('Error')<0) | ||
| 518 | { | ||
| 519 | kSetDData('C','mCallState',"Dispo"); | ||
| 520 | kSetDData('C','ts_Dispo',getNowTS()); | ||
| 521 | |||
| 522 | if(kstychDialer["keeplocalconf"]==0) | ||
| 523 | { | ||
| 524 | try{sipHangUp();}catch(e){console.log(e);} | ||
| 525 | var dialerConnection=kGetDData("D","connection"); | ||
| 526 | dialerConnection['connected']=0; | ||
| 527 | dialerConnection['channel']=''; | ||
| 528 | updateDialerState("dialer","connection",dialerConnection); | ||
| 529 | } | ||
| 530 | else updateDialerState(); | ||
| 531 | } | ||
| 532 | else | ||
| 533 | { | ||
| 534 | simpleNotification('error','topRight',retstr.responseText); | ||
| 535 | updateDialerState(); | ||
| 536 | } | ||
| 537 | }); | ||
| 538 | } | ||
| 539 | function saveCloseDialerCall(flag) | ||
| 540 | { | ||
| 541 | kstychCall['userstatus']=$('#dialer_userstatus').val(); | ||
| 542 | kstychCall['usersubstatus']=$('#dialer_usersubstatus').val(); | ||
| 543 | kstychCall['usercallback']=$('#dialer_usercallback').val(); | ||
| 544 | kstychCall['userremarks']=$('#dialer_userremarks').val(); | ||
| 545 | kstychCall['userflag']=$('#dialer_flag').val(); | ||
| 546 | kstychCall['priority']=$('#priority').val(); | ||
| 547 | |||
| 548 | kstychCall['bttc_day']=$('#bttc_day').val(); | ||
| 549 | kstychCall['bttc_hrs']=$('#bttc_hrs').val(); | ||
| 550 | kstychCall['serv_vs_prod']=$('#serv_vs_prod').val(); | ||
| 551 | kstychCall['resolution']=$('#resolution').val(); | ||
| 552 | kstychCall['satisfy']=$('#satisfy').val(); | ||
| 553 | kstychCall['final_call_assess']=$('#final_call_assess').val(); | ||
| 554 | |||
| 555 | if(typeof customerDispofields != 'undefined')kstychCall['userdata']=customerDispofields; | ||
| 556 | |||
| 557 | if(flag=="AUTOWRAPUP") | ||
| 558 | { | ||
| 559 | kstychCall['userstatus']="AUTOWRAPUP"; | ||
| 560 | kstychCall['usersubstatus']="AUTOWRAPUP"; | ||
| 561 | $('#dialer_usercallback').val(""); | ||
| 562 | kstychCall['usercallback']=""; | ||
| 563 | kstychCall['userremarks']=""; | ||
| 564 | kstychCall['userflag']=""; | ||
| 565 | } | ||
| 566 | else if(flag=="REDIAL") | ||
| 567 | { | ||
| 568 | kstychCall['userstatus']="REDIAL"; | ||
| 569 | kstychCall['usersubstatus']="REDIAL"; | ||
| 570 | $('#dialer_usercallback').val(""); | ||
| 571 | kstychCall['usercallback']=""; | ||
| 572 | kstychCall['userremarks']=""; | ||
| 573 | kstychCall['userflag']=""; | ||
| 574 | |||
| 575 | kstychDialer['RedialLast']='Yes'; | ||
| 576 | } | ||
| 577 | else if(!$('#dialer_userstatus').length) | ||
| 578 | { | ||
| 579 | kstychCall['userstatus']="NORECORD"; | ||
| 580 | kstychCall['usersubstatus']="NORECORD"; | ||
| 581 | kstychCall['usercallback']=""; | ||
| 582 | kstychCall['userremarks']=""; | ||
| 583 | kstychCall['userflag']=""; | ||
| 584 | |||
| 585 | $('#dialer_usercallback').val(""); | ||
| 586 | } | ||
| 587 | else | ||
| 588 | { | ||
| 589 | |||
| 590 | |||
| 591 | if(kstychCall['userstatus']==""||kstychCall['usersubstatus']=="") | ||
| 592 | { | ||
| 593 | simpleNotification('error','topRight',"Please Select Disposition and Subdisposition"); | ||
| 594 | return; | ||
| 595 | } | ||
| 596 | |||
| 597 | //For $ dropdown Condition - Changes done By Manish on 27-10-16 | ||
| 598 | /*if(kstychCall['userstatus']=="Contacted - FollowUp - Specific" || kstychCall['userstatus']=="Contacted - Follow-Up - Generic") | ||
| 599 | { | ||
| 600 | if(kstychCall['final_call_assess']==""&&kstychCall['serv_vs_prod']==""&&kstychCall['resolution']==""&&kstychCall['satisfy']=="") | ||
| 601 | { | ||
| 602 | simpleNotification('Error','topRight',"Please Select ALL(Service vs Product and Resolution and Satisfaction and Final_call_Assessment)"); | ||
| 603 | return; | ||
| 604 | } | ||
| 605 | }*/ | ||
| 606 | |||
| 607 | if(kstychCall['userstatus'].toLowerCase().indexOf("followup")>-1||kstychCall['userstatus'].toLowerCase().indexOf("callback")>-1) | ||
| 608 | { | ||
| 609 | if($('#dialer_usercallback').val()=="") | ||
| 610 | { | ||
| 611 | simpleNotification('error','topRight',"Please select Callback date within one month in future"); | ||
| 612 | return; | ||
| 613 | } | ||
| 614 | } | ||
| 615 | else | ||
| 616 | { | ||
| 617 | if($('#dialer_usercallback').val()!="") | ||
| 618 | { | ||
| 619 | simpleNotification('error','topRight',"You Cannot input Callback date time in this Disposition"); | ||
| 620 | return; | ||
| 621 | } | ||
| 622 | } | ||
| 623 | |||
| 624 | |||
| 625 | var date1 = new Date(); | ||
| 626 | var date2 = new Date($('#dialer_usercallback').val()); | ||
| 627 | var diff = date2.getTime() - date1.getTime(); | ||
| 628 | if(diff<0||diff>30*24*60*60*1000) | ||
| 629 | { | ||
| 630 | simpleNotification('error','topRight',"Please select Callback date within one month in future"); | ||
| 631 | return; | ||
| 632 | } | ||
| 633 | var hours = date2.getHours(); | ||
| 634 | var mins = date2.getMinutes(); | ||
| 635 | var fullhour=hours+(mins/60); | ||
| 636 | if(fullhour<9||fullhour>19) | ||
| 637 | { | ||
| 638 | simpleNotification('error','topRight',"Please select Callback Time date within 9AM and 7PM"); | ||
| 639 | return; | ||
| 640 | } | ||
| 641 | |||
| 642 | } | ||
| 643 | |||
| 644 | if($("#recruitsavedata").length)$("#recruitsavedata").click();//TODO hold div in reset, or any error will be lost | ||
| 645 | |||
| 646 | var datastr="kstychCall="+JSON.stringify(kstychCall); | ||
| 647 | datastr+="&kstychDialer="+JSON.stringify(kstychDialer); | ||
| 648 | doAjax('dialer?action=closecall',datastr,'', 'ajax_manualdial','singlefail','POST', | ||
| 649 | function(retstr){ | ||
| 650 | kSetDData('C','mCallState',"Close"); | ||
| 651 | kSetDData('C','ts_Close',getNowTS()); | ||
| 652 | updateDialerState("action","reset",""); | ||
| 653 | }); | ||
| 654 | |||
| 655 | //Dialog box after Save & Close-Taking from KFormLib.php | ||
| 656 | $finalCallAssess = $('#final_call_assess').val(); | ||
| 657 | |||
| 658 | if($finalCallAssess == 'Very Good Call With Customer') | ||
| 659 | { | ||
| 660 | /*$.gritter.add({ | ||
| 661 | title: 'type', | ||
| 662 | text: 'text', | ||
| 663 | class_name: 'gritter-b-center' | ||
| 664 | });*/ | ||
| 665 | $('#goodCall').dialog({ | ||
| 666 | modal: true, | ||
| 667 | position: ['center'], | ||
| 668 | resizable: false, | ||
| 669 | closeOnEscape: false, | ||
| 670 | open: function(event, ui){ | ||
| 671 | $(".ui.dialog-titlebar-close", ui.dialog | ui).hide(); | ||
| 672 | setTimeout(function(){$('#goodCall').dialog('close');},5000); | ||
| 673 | } | ||
| 674 | }); | ||
| 675 | |||
| 676 | //setTimeout(function(){$('#goodCall').dialog('close');},5000); | ||
| 677 | } | ||
| 678 | |||
| 679 | if($finalCallAssess == 'Ok Call') | ||
| 680 | { | ||
| 681 | $('#okCall').dialog({ | ||
| 682 | open: function(event, ui){ | ||
| 683 | $(this).css({'max-height':500, 'overflow-y':'auto'}); | ||
| 684 | }, | ||
| 685 | modal: true, | ||
| 686 | position: ['center'], | ||
| 687 | resizable: false, | ||
| 688 | closeOnEscape: false}); | ||
| 689 | |||
| 690 | setTimeout(function(){$('#okCall').dialog('close');},5000); | ||
| 691 | } | ||
| 692 | |||
| 693 | if($finalCallAssess == 'Not Interested Customer') | ||
| 694 | { | ||
| 695 | $('#notInterest').dialog({ | ||
| 696 | open: function(event, ui){ | ||
| 697 | $(this).css({'max-height':500, 'overflow-y':'auto'}); | ||
| 698 | }, | ||
| 699 | modal: true, | ||
| 700 | position: ['center'], | ||
| 701 | resizable: false, | ||
| 702 | closeOnEscape: false}); | ||
| 703 | |||
| 704 | setTimeout(function(){$('#notInterest').dialog('close');},5000); | ||
| 705 | } | ||
| 706 | |||
| 707 | if($finalCallAssess == 'Iritated Customer') | ||
| 708 | { | ||
| 709 | $('#iritCust').dialog({ | ||
| 710 | open: function(event, ui){ | ||
| 711 | $(this).css({'max-height':500, 'overflow-y':'auto'}); | ||
| 712 | }, | ||
| 713 | modal: true, | ||
| 714 | position: ['center'], | ||
| 715 | resizable: false, | ||
| 716 | closeOnEscape: false}); | ||
| 717 | |||
| 718 | setTimeout(function(){$('#iritCust').dialog('close');},5000); | ||
| 719 | } | ||
| 720 | |||
| 721 | if($finalCallAssess == 'Angry') | ||
| 722 | { | ||
| 723 | $('#angry').dialog({ | ||
| 724 | open: function(event, ui){ | ||
| 725 | $(this).css({'max-height':500, 'overflow-y':'auto'}); | ||
| 726 | }, | ||
| 727 | modal: true, | ||
| 728 | position: ['center'], | ||
| 729 | resizable: false, | ||
| 730 | closeOnEscape: false}); | ||
| 731 | |||
| 732 | setTimeout(function(){$('#angry').dialog('close');},5000); | ||
| 733 | } | ||
| 734 | } | ||
| 735 | |||
| 736 | function showWrapUp() | ||
| 737 | { | ||
| 738 | kstychCall['userstatus']="Paused"; | ||
| 739 | kstychCall['usersubstatus']="WRAPUP"; | ||
| 740 | $('#dialer_usercallback').val(""); | ||
| 741 | kstychCall['usercallback']=""; | ||
| 742 | kstychCall['userremarks']=""; | ||
| 743 | kstychCall['userflag']=""; | ||
| 744 | |||
| 745 | var datastr="kstychCall="+JSON.stringify(kstychCall); | ||
| 746 | datastr+="&kstychDialer="+JSON.stringify(kstychDialer); | ||
| 747 | doAjax('dialer?action=wrapup',datastr,'', 'ajax_manualdial','singlefail','POST', | ||
| 748 | function(retstr){ | ||
| 749 | dialerTimersUpdate(); | ||
| 750 | }); | ||
| 751 | } | ||
| 752 | |||
| 753 | function resetDialer() | ||
| 754 | { | ||
| 755 | if(kstychDialer['RedialLast']=="Yes") | ||
| 756 | { | ||
| 757 | kstychDialer['RedialLast']=''; | ||
| 758 | |||
| 759 | kSetDData('C','mCallState',"Wait"); | ||
| 760 | kSetDData('C','ts_Wait',getNowTS()); | ||
| 761 | kSetDData('C','ts_Call',0); | ||
| 762 | kSetDData('C','ts_Talk',0); | ||
| 763 | kSetDData('C','ts_Dispo',0); | ||
| 764 | kSetDData('C','ts_Close',0); | ||
| 765 | |||
| 766 | updateDialerState("action","dialnext"); | ||
| 767 | |||
| 768 | return; | ||
| 769 | } | ||
| 770 | |||
| 771 | |||
| 772 | var dialerResetForceState=kstychDialer['mDialerState']; | ||
| 773 | var dialerResetForceSubState=kstychDialer['mDialerSubState']; | ||
| 774 | |||
| 775 | //dialerResetForceState="Progressive";//Hardcoded TODO change to config | ||
| 776 | //dialerResetForceSubState=""; | ||
| 777 | |||
| 778 | if(kstychCall['userstatus']=="AUTOWRAPUP") | ||
| 779 | { | ||
| 780 | dialerResetForceState="Paused"; | ||
| 781 | dialerResetForceSubState="AUTOWRAPUP"; | ||
| 782 | } | ||
| 783 | |||
| 784 | if(kstychCall['userstatus']=="WRAPUP") | ||
| 785 | { | ||
| 786 | dialerResetForceState="Paused"; | ||
| 787 | dialerResetForceSubState="WRAPUP"; | ||
| 788 | } | ||
| 789 | |||
| 790 | //TODO check hangup any connections? | ||
| 791 | |||
| 792 | $("#dialersearchresults").html("");//CANNOT clear this until we have a solution of error handling in save form | ||
| 793 | $("#manualdialnumber_txt").val(""); | ||
| 794 | |||
| 795 | resetCallArray(); | ||
| 796 | |||
| 797 | $("#dialersearchbox").html(""); | ||
| 798 | $(".dialer_conf_divs").remove(); | ||
| 799 | |||
| 800 | updateDialerState("dialer","mDialerState",dialerResetForceState,"mDialerSubState",dialerResetForceSubState); | ||
| 801 | |||
| 802 | } | ||
| 803 | function resetCallArray() | ||
| 804 | { | ||
| 805 | kSetDData('C','mCallState',"Wait"); | ||
| 806 | kSetDData('C','ts_Wait',getNowTS()); | ||
| 807 | kSetDData('C','ts_Call',0); | ||
| 808 | kSetDData('C','ts_Talk',0); | ||
| 809 | kSetDData('C','ts_Dispo',0); | ||
| 810 | kSetDData('C','ts_Close',0); | ||
| 811 | kSetDData('C','callnumber',""); | ||
| 812 | kSetDData('C','connections',{}); | ||
| 813 | kSetDData('C','callid',""); | ||
| 814 | kSetDData('C','crmid',""); | ||
| 815 | kSetDData('C','campaignid',""); | ||
| 816 | kSetDData('C','listid',""); | ||
| 817 | kSetDData('C','mdial_CallACK',""); | ||
| 818 | kSetDData('C','mcalldata',""); | ||
| 819 | |||
| 820 | kSetDData('C','userstatus',""); | ||
| 821 | kSetDData('C','usersubstatus',""); | ||
| 822 | kSetDData('C','usercallback',""); | ||
| 823 | kSetDData('C','userremarks',""); | ||
| 824 | kSetDData('C','userflag',""); | ||
| 825 | kSetDData('C','bttc_day',""); | ||
| 826 | kSetDData('C','bttc_hrs',""); | ||
| 827 | kSetDData('C','serv_vs_prod',""); | ||
| 828 | kSetDData('C','resolution',""); | ||
| 829 | kSetDData('C','satisfy',""); | ||
| 830 | kSetDData('C','final_call_assess',""); | ||
| 831 | kSetDData('C','userdata',{}); | ||
| 832 | if(typeof customerDispofields != 'undefined')customerDispofields={}; | ||
| 833 | |||
| 834 | kSetDData('C','previewcrmid',""); | ||
| 835 | kSetDData('C','callWrapupTime',300); | ||
| 836 | kSetDData('C','prograssiveDelay',120); | ||
| 837 | } | ||
| 838 | |||
| 839 | function updateDialerState(objstr,key,val,key2,val2) | ||
| 840 | { | ||
| 841 | if(objstr=="dialer") | ||
| 842 | { | ||
| 843 | kSetDData("D",key,val); | ||
| 844 | kSetDData("D",key2,val2); | ||
| 845 | if(key=='mDialerState') | ||
| 846 | { | ||
| 847 | if(!key2||key2=="")kSetDData("D","mDialerSubState",""); | ||
| 848 | |||
| 849 | if(val=="Paused") | ||
| 850 | { | ||
| 851 | resetCallArray(); | ||
| 852 | } | ||
| 853 | |||
| 854 | $("#dialersearchresults").html(""); | ||
| 855 | kSetDData('C','ts_Wait',getNowTS());//TODO reset here? | ||
| 856 | |||
| 857 | var datastr="kstychCall="+JSON.stringify(kstychCall); | ||
| 858 | datastr+="&kstychDialer="+JSON.stringify(kstychDialer); | ||
| 859 | doAjax('dialer?action=dialerstate',datastr,'', 'ajax_manualdial','singlefail','POST', | ||
| 860 | function(retstr){ | ||
| 861 | |||
| 862 | if(val=="Progressive"||(kstychCall['previewcrmid']!=""&&kstychCall['previewcrmid']>0)) | ||
| 863 | { | ||
| 864 | if(kstychCall['final_call_assess']=='' || kstychCall['final_call_assess']!=undefined){ | ||
| 865 | setTimeout(function(){doAjax('dialer?action=previewnext',datastr,'dialersearchresults', 'ajax_manualdial2','singlefail','POST', | ||
| 866 | function(retstr){ | ||
| 867 | if(kstychCall['previewcrmid']!="") | ||
| 868 | { | ||
| 869 | updateDialerState(); | ||
| 870 | } | ||
| 871 | else | ||
| 872 | { | ||
| 873 | resetCallArray(); | ||
| 874 | simpleNotification('error','topRight',"Failed to Dial Next Record"); | ||
| 875 | updateDialerState("dialer","mDialerState","DialNext"); | ||
| 876 | } | ||
| 877 | });},4000); | ||
| 878 | }else | ||
| 879 | { | ||
| 880 | doAjax('dialer?action=previewnext',datastr,'dialersearchresults', 'ajax_manualdial2','singlefail','POST', | ||
| 881 | function(retstr){ | ||
| 882 | if(kstychCall['previewcrmid']!="") | ||
| 883 | { | ||
| 884 | updateDialerState(); | ||
| 885 | } | ||
| 886 | else | ||
| 887 | { | ||
| 888 | resetCallArray(); | ||
| 889 | simpleNotification('error','topRight',"Failed to Dial Next Record"); | ||
| 890 | updateDialerState("dialer","mDialerState","DialNext"); | ||
| 891 | } | ||
| 892 | }); | ||
| 893 | } | ||
| 894 | |||
| 895 | } | ||
| 896 | |||
| 897 | updateDialerState(); | ||
| 898 | }); | ||
| 899 | } | ||
| 900 | } | ||
| 901 | if(objstr=="call") | ||
| 902 | { | ||
| 903 | kSetDData('C',key,val); | ||
| 904 | kSetDData("C",key2,val2); | ||
| 905 | } | ||
| 906 | |||
| 907 | if(objstr=="action") | ||
| 908 | { | ||
| 909 | if(key=="dialnext") | ||
| 910 | { | ||
| 911 | outgoingCall(); | ||
| 912 | } | ||
| 913 | if(key=="hangupall") | ||
| 914 | { | ||
| 915 | hangupCall(); | ||
| 916 | } | ||
| 917 | if(key=="saveclose") | ||
| 918 | { | ||
| 919 | saveCloseDialerCall(); | ||
| 920 | } | ||
| 921 | if(key=="reset") | ||
| 922 | { | ||
| 923 | resetDialer(); | ||
| 924 | } | ||
| 925 | } | ||
| 926 | |||
| 927 | updateDialerUI(); | ||
| 928 | ////////////////////////////////////////////////////////////// | ||
| 929 | if(objstr=="")return; | ||
| 930 | |||
| 931 | //$("#kTopBarExtra").parent().addClass("open"); | ||
| 932 | |||
| 933 | //run this function on every state change? | ||
| 934 | //take dialer and call objects and send to controller for update | ||
| 935 | } | ||
| 936 | function updateDialerUI() | ||
| 937 | { | ||
| 938 | $("#spandialer_num").html(kstychCall["callnumber"]); | ||
| 939 | if(kstychCall["callnumber"]!="")$("#dialertimes2").show(); | ||
| 940 | else $("#dialertimes2").hide(); | ||
| 941 | |||
| 942 | if($("#dialerManualAllowLI").length)kSetDData("D",'mmanualallow','Yes'); | ||
| 943 | |||
| 944 | ////////////////////////////////////////////////////////////// | ||
| 945 | var statestr="<i class='fa fa-phone'></i> : "+kstychDialer['mDialerState']; | ||
| 946 | if(kstychDialer['mDialerState']=="Paused")statestr="<i class='fa fa-pause'></i> : "+kstychDialer['mDialerSubState']; | ||
| 947 | if(kstychDialer['mDialerState']=="Ready")statestr="<i class='fa fa-phone'></i> : "+kstychDialer['mDialerSubState']; | ||
| 948 | $("#dialerstate_btn").html(statestr); | ||
| 949 | |||
| 950 | |||
| 951 | if(kstychDialer['mDialerState']=="Paused") | ||
| 952 | { | ||
| 953 | $("#dialerstate_div").width("150px"); | ||
| 954 | $("#manualdial_btn").hide();$("#manualdialnumber_txt").hide(); | ||
| 955 | $("#dialerstate_btn").parent().removeClass("rounded-left"); | ||
| 956 | $("#dialerstate_btn").parent().removeClass("btn-info").addClass("btn-primary"); | ||
| 957 | } | ||
| 958 | else if(kstychDialer['mDialerState']=="Ready") | ||
| 959 | { | ||
| 960 | $("#dialerstate_div").width("150px"); | ||
| 961 | $("#manualdial_btn").show();$("#manualdialnumber_txt").hide(); | ||
| 962 | $("#dialerstate_btn").parent().addClass("rounded-left"); | ||
| 963 | $("#dialerstate_btn").parent().removeClass("btn-primary").addClass("btn-info"); | ||
| 964 | } | ||
| 965 | else if(kstychDialer['mDialerState']=="Manual") | ||
| 966 | { | ||
| 967 | $("#dialerstate_div").width("350px"); | ||
| 968 | $("#manualdial_btn").show();$("#manualdialnumber_txt").show(); | ||
| 969 | $("#dialerstate_btn").parent().addClass("rounded-left"); | ||
| 970 | $("#dialerstate_btn").parent().removeClass("btn-primary").addClass("btn-info"); | ||
| 971 | } | ||
| 972 | else if(kstychDialer['mDialerState']=="DialNext") | ||
| 973 | { | ||
| 974 | $("#dialerstate_div").width("150px"); | ||
| 975 | $("#manualdial_btn").show();$("#manualdialnumber_txt").hide(); | ||
| 976 | $("#dialerstate_btn").parent().addClass("rounded-left"); | ||
| 977 | $("#dialerstate_btn").parent().removeClass("btn-primary").addClass("btn-info"); | ||
| 978 | } | ||
| 979 | else if(kstychDialer['mDialerState']=="Progressive") | ||
| 980 | { | ||
| 981 | $("#dialerstate_div").width("150px"); | ||
| 982 | $("#manualdial_btn").show();$("#manualdialnumber_txt").hide(); | ||
| 983 | $("#dialerstate_btn").parent().removeClass("rounded-left"); | ||
| 984 | $("#dialerstate_btn").parent().removeClass("btn-primary").addClass("btn-info"); | ||
| 985 | } | ||
| 986 | ////////////////////////////////////////////////////////////// | ||
| 987 | |||
| 988 | ////////////////////////////////////////////////////////////// | ||
| 989 | var uStateArr=[]; | ||
| 990 | uStateArr['conficon_u_a']='btn-primary';uStateArr['conficon_u_i']='fa-chain-broken'; | ||
| 991 | if(kstychDialer['connection']['connected']==1) | ||
| 992 | { | ||
| 993 | uStateArr['conficon_u_a']='btn-success';uStateArr['conficon_u_i']='fa-chain'; | ||
| 994 | } | ||
| 995 | uStateArr['mic']='UnMuteMic';uStateArr['micicon']='fa-microphone-slash'; | ||
| 996 | if(kstychDialer['connection']['mic']==1) | ||
| 997 | { | ||
| 998 | uStateArr['mic']='MuteMic';uStateArr['micicon']='fa-microphone'; | ||
| 999 | } | ||
| 1000 | |||
| 1001 | var calluhtml="<a data-toggle='dropdown' href='#' class='btn btn-stroke "+uStateArr['conficon_u_a']+" btn-circle dropdown-toggle' onmouseout='$(this).blur()' id=conficon_u_a><i class='fa "+uStateArr['conficon_u_i']+"' id=conficon_u_i></i> </a>"; | ||
| 1002 | calluhtml+="<ul class='dropdown-menu'>"; | ||
| 1003 | calluhtml+="<li data-toggle='tooltip' data-title='My Channel' data-placement='left' data-tcontainer='body'><a href='#' onclick='return false;'><i class='fa fa-info'></i></a></li>"; | ||
| 1004 | //calluhtml+="<li data-toggle='tooltip' data-title='MuteSpeaker' data-placement='left' data-tcontainer='body'><a href='#' onclick='kCallAction(\"u\",\"MuteSpeaker\");return false;'><i class='fa fa-volume-off'></i></a></li>"; | ||
| 1005 | calluhtml+="<li data-toggle='tooltip' data-title='"+uStateArr['mic']+"' data-placement='left' data-tcontainer='body'><a href='#' onclick='kCallAction(\"u\",\""+uStateArr['mic']+"\");return false;'><i class='fa "+uStateArr['micicon']+"'></i></a></li>"; | ||
| 1006 | //calluhtml+="<li data-toggle='tooltip' data-title='Hangup' data-placement='left' data-tcontainer='body'><a href='#' onclick='kCallAction(\"u\",\"Hangup\");return false;'><i class='fa fa-times-circle'></i></a></li>"; | ||
| 1007 | //calluhtml+="<li data-toggle='tooltip' data-title='Hold' data-placement='left' data-tcontainer='body'><a href='#' onclick='kCallAction(\"u\",\"Hold\");return false;'><i class='fa fa-pause'></i></a></li>"; | ||
| 1008 | calluhtml+="</ul>"; | ||
| 1009 | $("#connections_div_u").html(calluhtml); | ||
| 1010 | |||
| 1011 | $(".dialer_conf_divs").remove(); | ||
| 1012 | var confhtml=''; | ||
| 1013 | for(var key in kstychCall['connections']) | ||
| 1014 | { | ||
| 1015 | if(kstychCall['connections'].hasOwnProperty(key)) | ||
| 1016 | { | ||
| 1017 | if(key==kstychCall['callnumber']) | ||
| 1018 | { | ||
| 1019 | var cStateArr=[]; | ||
| 1020 | cStateArr['conficon_c0_a']='btn-primary';cStateArr['conficon_c0_i']='fa-chain-broken'; | ||
| 1021 | if(kstychCall['connections'][key]['connected']==1) | ||
| 1022 | { | ||
| 1023 | cStateArr['conficon_c0_a']='btn-success';cStateArr['conficon_c0_i']='fa-chain'; | ||
| 1024 | } | ||
| 1025 | cStateArr['mic']='UnMuteMic';cStateArr['micicon']='fa-microphone-slash'; | ||
| 1026 | if(kstychCall['connections'][key]['mic']==1) | ||
| 1027 | { | ||
| 1028 | cStateArr['mic']='MuteMic';cStateArr['micicon']='fa-microphone'; | ||
| 1029 | } | ||
| 1030 | cStateArr['speaker']='UnMuteSpeaker';cStateArr['speakericon']='fa-volume-off'; | ||
| 1031 | if(kstychCall['connections'][key]['speaker']==1) | ||
| 1032 | { | ||
| 1033 | cStateArr['speaker']='MuteSpeaker';cStateArr['speakericon']='fa-volume-up'; | ||
| 1034 | } | ||
| 1035 | cStateArr['holdext']='UnHold';cStateArr['holdexticon']='fa-play'; | ||
| 1036 | if(kstychCall['connections'][key]['holdext']=='') | ||
| 1037 | { | ||
| 1038 | cStateArr['holdext']='Hold';cStateArr['holdexticon']='fa-pause'; | ||
| 1039 | } | ||
| 1040 | |||
| 1041 | var callchtml="<a data-toggle='dropdown' href='#' class='btn btn-stroke "+cStateArr['conficon_c0_a']+" btn-circle dropdown-toggle' onmouseout='$(this).blur()' id=conficon_c0_a><i class='fa "+cStateArr['conficon_c0_i']+"' id=conficon_c0_i></i> </a>"; | ||
| 1042 | callchtml+="<ul class='dropdown-menu'>"; | ||
| 1043 | callchtml+="<li data-toggle='tooltip' data-title='"+key+"' data-placement='left' data-tcontainer='body'><a href='#' onclick='return false;'><i class='fa fa-info'></i></a></li>"; | ||
| 1044 | callchtml+="<li data-toggle='tooltip' data-title='"+cStateArr['speaker']+"' data-placement='left' data-tcontainer='body'><a href='#' onclick='kCallAction(\"c\",\""+cStateArr['speaker']+"\");return false;'><i class='fa "+cStateArr['speakericon']+"'></i></a></li>"; | ||
| 1045 | callchtml+="<li data-toggle='tooltip' data-title='"+cStateArr['mic']+"' data-placement='left' data-tcontainer='body'><a href='#' onclick='kCallAction(\"c\",\""+cStateArr['mic']+"\");return false;'><i class='fa "+cStateArr['micicon']+"'></i></a></li>"; | ||
| 1046 | callchtml+="<li data-toggle='tooltip' data-title='Hangup' data-placement='left' data-tcontainer='body'><a href='#' onclick='kCallAction(\"c\",\"Hangup\");return false;'><i class='fa fa-times-circle'></i></a></li>"; | ||
| 1047 | //callchtml+="<li data-toggle='tooltip' data-title='"+cStateArr['holdext']+"' data-placement='left' data-tcontainer='body'><a href='#' onclick='kCallAction(\"c\",\""+cStateArr['holdext']+"\");return false;'><i class='fa "+cStateArr['holdexticon']+"'></i></a></li></ul>"; | ||
| 1048 | $("#connections_div_c").html(callchtml); | ||
| 1049 | } | ||
| 1050 | else | ||
| 1051 | { | ||
| 1052 | var tStateArr=[]; | ||
| 1053 | tStateArr['conficon_t_a']='btn-primary';tStateArr['conficon_t_i']='fa-chain-broken'; | ||
| 1054 | if(kstychCall['connections'][key]['connected']==1) | ||
| 1055 | { | ||
| 1056 | tStateArr['conficon_t_a']='btn-success';tStateArr['conficon_t_i']='fa-chain'; | ||
| 1057 | } | ||
| 1058 | tStateArr['mic']='UnMuteMic';tStateArr['micicon']='fa-microphone-slash'; | ||
| 1059 | if(kstychCall['connections'][key]['mic']==1) | ||
| 1060 | { | ||
| 1061 | tStateArr['mic']='MuteMic';tStateArr['micicon']='fa-microphone'; | ||
| 1062 | } | ||
| 1063 | tStateArr['speaker']='UnMuteSpeaker';tStateArr['speakericon']='fa-volume-off'; | ||
| 1064 | if(kstychCall['connections'][key]['speaker']==1) | ||
| 1065 | { | ||
| 1066 | tStateArr['speaker']='MuteSpeaker';tStateArr['speakericon']='fa-volume-up'; | ||
| 1067 | } | ||
| 1068 | tStateArr['holdext']='UnHold';tStateArr['holdexticon']='fa-play'; | ||
| 1069 | if(kstychCall['connections'][key]['holdext']=='') | ||
| 1070 | { | ||
| 1071 | tStateArr['holdext']='Hold';tStateArr['holdexticon']='fa-pause'; | ||
| 1072 | } | ||
| 1073 | |||
| 1074 | confhtml+="<div class='dropdown dropdown-icons dialer_conf_divs' confphonenumber='"+key+"' >"; | ||
| 1075 | confhtml+="<a data-toggle='dropdown' href='#' class='btn btn-stroke "+tStateArr['conficon_t_a']+" btn-circle dropdown-toggle' onmouseout='$(this).blur()'><i class='fa "+tStateArr['conficon_t_i']+"'></i> </a>"; | ||
| 1076 | confhtml+="<ul class='dropdown-menu'>"; | ||
| 1077 | confhtml+="<li data-toggle='tooltip' data-title='"+key+"' data-placement='left' data-tcontainer='body'><a href='#' onclick='return false;'><i class='fa fa-info'></i></a></li>"; | ||
| 1078 | confhtml+="<li data-toggle='tooltip' data-title='"+tStateArr['speaker']+"' data-placement='left' data-tcontainer='body'><a href='#' onclick='kCallAction(\""+key+"\",\""+tStateArr['speaker']+"\");return false;'><i class='fa "+tStateArr['speakericon']+"'></i></a></li>"; | ||
| 1079 | confhtml+="<li data-toggle='tooltip' data-title='"+tStateArr['mic']+"' data-placement='left' data-tcontainer='body'><a href='#' onclick='kCallAction(\""+key+"\",\""+tStateArr['mic']+"\");return false;'><i class='fa "+tStateArr['micicon']+"'></i></a></li>"; | ||
| 1080 | confhtml+="<li data-toggle='tooltip' data-title='Hangup' data-placement='left' data-tcontainer='body'><a href='#' onclick='kCallAction(\""+key+"\",\"Hangup\");return false;'><i class='fa fa-times-circle'></i></a></li>"; | ||
| 1081 | //confhtml+="<li data-toggle='tooltip' data-title='"+tStateArr['holdext']+"' data-placement='left' data-tcontainer='body'><a href='#' onclick='kCallAction(\""+key+"\",\""+tStateArr['holdext']+"\");return false;'><i class='fa "+tStateArr['holdexticon']+"'></i></a></li>"; | ||
| 1082 | confhtml+="</ul></div>"; | ||
| 1083 | } | ||
| 1084 | } | ||
| 1085 | } | ||
| 1086 | $(confhtml).insertAfter("#connections_div_c"); | ||
| 1087 | ////////////////////////////////////////////////////////////// | ||
| 1088 | |||
| 1089 | ////////////////////////////////////////////////////////////// | ||
| 1090 | if(kstychCall['mCallState']=="Wait") | ||
| 1091 | { | ||
| 1092 | $("#dialerstate_btn").parent().attr("disabled",false); | ||
| 1093 | if(kstychDialer['mmanualallow']=='Yes')$("#manualdialnumber_txt").attr("disabled",false); | ||
| 1094 | else $("#manualdialnumber_txt").attr("disabled",true); | ||
| 1095 | |||
| 1096 | $("#manualdial_btn").attr("disabled",false); | ||
| 1097 | $("#manualdial_btn").attr("dialaction","dialnext"); | ||
| 1098 | $("#manualdial_btn").html("<i class='fa fa-play text-default'></i>"); | ||
| 1099 | |||
| 1100 | if(kstychDialer['mDialerState']=="Ready") | ||
| 1101 | { | ||
| 1102 | var readyDelay=Math.ceil((getNowTS()-kstychCall['ts_Wait'])/1000); | ||
| 1103 | |||
| 1104 | $("#manualdial_btn").attr("disabled",true); | ||
| 1105 | $("#manualdial_btn").attr("dialaction",""); | ||
| 1106 | $("#manualdial_btn").html("Waiting");// : "+readyDelay); | ||
| 1107 | |||
| 1108 | } | ||
| 1109 | } | ||
| 1110 | if(kstychCall['mCallState']=="Call") | ||
| 1111 | { | ||
| 1112 | $("#dialerstate_btn").parent().attr("disabled",true); | ||
| 1113 | $("#manualdialnumber_txt").attr("disabled",true); | ||
| 1114 | |||
| 1115 | $("#manualdial_btn").attr("disabled",false); | ||
| 1116 | $("#manualdial_btn").attr("dialaction","hangupall"); | ||
| 1117 | $("#manualdial_btn").html("<i class='fa fa-times text-primary'></i> Hangup"); | ||
| 1118 | } | ||
| 1119 | if(kstychCall['mCallState']=="Dispo") | ||
| 1120 | { | ||
| 1121 | $("#dialerstate_btn").parent().attr("disabled",true); | ||
| 1122 | $("#manualdialnumber_txt").attr("disabled",true); | ||
| 1123 | |||
| 1124 | $("#manualdial_btn").attr("disabled",false); | ||
| 1125 | $("#manualdial_btn").attr("dialaction","saveclose"); | ||
| 1126 | $("#manualdial_btn").html("<i class='fa fa-save text-success'></i> Save & Close"); | ||
| 1127 | } | ||
| 1128 | if(kstychCall['mCallState']=="Close") | ||
| 1129 | { | ||
| 1130 | $("#dialerstate_btn").parent().attr("disabled",true); | ||
| 1131 | $("#manualdialnumber_txt").attr("disabled",true); | ||
| 1132 | |||
| 1133 | $("#manualdial_btn").attr("disabled",true); | ||
| 1134 | $("#manualdial_btn").attr("dialaction",""); | ||
| 1135 | $("#manualdial_btn").html("<i class='fa fa-pause text-default'></i>"); | ||
| 1136 | } | ||
| 1137 | ////////////////////////////////////////////////////////////// | ||
| 1138 | } | ||
| 1139 | |||
| 1140 | function dialerTimersUpdate() | ||
| 1141 | { | ||
| 1142 | var dispD="0";var dispT="0";var dispC="0";var dispW="0"; | ||
| 1143 | |||
| 1144 | if(kstychCall['ts_Dispo']>1) | ||
| 1145 | { | ||
| 1146 | if(Math.ceil(((kstychCall['ts_Dispo']-kstychCall['ts_Talk'])/1000))<3) | ||
| 1147 | { | ||
| 1148 | kstychCall['callWrapupTime']=90; | ||
| 1149 | if(typeof dispoClassArray!='undefined' && typeof dispoClassArray['NA'] != 'undefined') | ||
| 1150 | { | ||
| 1151 | if($('#dialer_userstatus').val()=="") | ||
| 1152 | { | ||
| 1153 | $('#dialer_userstatus').val(dispoClassArray['NA']); | ||
| 1154 | $('#dialer_userstatus').change(); | ||
| 1155 | } | ||
| 1156 | } | ||
| 1157 | } | ||
| 1158 | |||
| 1159 | var thiswraptime=Math.ceil(kstychCall['callWrapupTime']-((getNowTS()-kstychCall['ts_Dispo'])/1000)); | ||
| 1160 | console.log("prashant"); | ||
| 1161 | console.log(thiswraptime); | ||
| 1162 | if(thiswraptime<=0) | ||
| 1163 | { | ||
| 1164 | saveCloseDialerCall('AUTOWRAPUP'); | ||
| 1165 | } | ||
| 1166 | |||
| 1167 | if(thiswraptime==90 || thiswraptime==300) | ||
| 1168 | { | ||
| 1169 | showWrapUp(); | ||
| 1170 | } | ||
| 1171 | |||
| 1172 | dispD="Wrapup : "+thiswraptime; | ||
| 1173 | $("#spandialer_ts").html(dispD); | ||
| 1174 | $("#dialertimes1").removeClass("btn-default").addClass("btn-primary"); | ||
| 1175 | } | ||
| 1176 | else if(kstychCall['ts_Talk']>1) | ||
| 1177 | { | ||
| 1178 | dispT="Talk : "+Math.ceil(((getNowTS()-kstychCall['ts_Talk'])/1000)); | ||
| 1179 | $("#spandialer_ts").html(dispT); | ||
| 1180 | $("#dialertimes1").removeClass("btn-primary").addClass("btn-default"); | ||
| 1181 | } | ||
| 1182 | else if(kstychCall['ts_Call']>1) | ||
| 1183 | { | ||
| 1184 | dispC="Call : "+Math.ceil(((getNowTS()-kstychCall['ts_Call'])/1000)); | ||
| 1185 | $("#spandialer_ts").html(dispC); | ||
| 1186 | $("#dialertimes1").removeClass("btn-primary").addClass("btn-default"); | ||
| 1187 | } | ||
| 1188 | else if(kstychCall['ts_Wait']>1) | ||
| 1189 | { | ||
| 1190 | dispW="Wait : "+Math.ceil(((getNowTS()-kstychCall['ts_Wait'])/1000)); | ||
| 1191 | $("#spandialer_ts").html(dispW); | ||
| 1192 | $("#dialertimes1").removeClass("btn-primary").addClass("btn-default"); | ||
| 1193 | } | ||
| 1194 | |||
| 1195 | |||
| 1196 | if(kstychCall['mCallState']=="Wait") | ||
| 1197 | { | ||
| 1198 | if(kstychDialer['mDialerState']=="Progressive") | ||
| 1199 | { | ||
| 1200 | var progressiveDelay=Math.ceil(kstychCall['prograssiveDelay']-((getNowTS()-kstychCall['ts_Wait'])/1000)); | ||
| 1201 | |||
| 1202 | if(progressiveDelay<0)progressiveDelay=0; | ||
| 1203 | |||
| 1204 | $("#manualdial_btn").attr("disabled",false); | ||
| 1205 | $("#manualdial_btn").attr("dialaction","dialnext"); | ||
| 1206 | $("#manualdial_btn").html("<i class='fa fa-play text-default'></i> "+progressiveDelay); | ||
| 1207 | |||
| 1208 | if(progressiveDelay<=0)$("#manualdial_btn").click(); | ||
| 1209 | } | ||
| 1210 | } | ||
| 1211 | |||
| 1212 | setTimeout(dialerTimersUpdate,1000); | ||
| 1213 | } | ||
| 1214 | |||
| 1215 | function kDialerConnected() | ||
| 1216 | { | ||
| 1217 | updateDialerState(); | ||
| 1218 | dialerTimersUpdate(); | ||
| 1219 | $("#dialerQuickControlDiv").show(); | ||
| 1220 | } | ||
| 1221 | function kDialerInit() | ||
| 1222 | { | ||
| 1223 | if(kstychAppObject['user']['id']!=0) | ||
| 1224 | { | ||
| 1225 | //simpleNotification("warning","topRight","Trying to Enable Voice Services"); | ||
| 1226 | |||
| 1227 | txtDisplayName = kstychAppObject['user']['sipid']; | ||
| 1228 | txtPrivateIdentity = kstychAppObject['user']['sipid']; | ||
| 1229 | txtPublicIdentity = "sip:"+kstychAppObject['user']['sipid']+"@"+kstychAppObject['user']['sipserver']; | ||
| 1230 | txtRealm = kstychAppObject['user']['sipserver']; | ||
| 1231 | |||
| 1232 | //txtPhoneNumber=document.getElementById("txtphno"); | ||
| 1233 | txtPhoneNumber = '1000'+kstychAppObject['user']['sipid']; | ||
| 1234 | |||
| 1235 | btnCall = false; | ||
| 1236 | btnHangUp = true; | ||
| 1237 | |||
| 1238 | btnFullScreen = false; | ||
| 1239 | audioRemote = document.getElementById("audio_remote"); | ||
| 1240 | videoLocal = document.getElementById("video_local"); | ||
| 1241 | videoRemote = document.getElementById("video_remote"); | ||
| 1242 | |||
| 1243 | SIPml.setDebugLevel(kstychAppObject['config']['appdebug']==0 ? "error" : "info"); | ||
| 1244 | |||
| 1245 | |||
| 1246 | //expert stuff //siddharth | ||
| 1247 | cbVideoDisable = true; | ||
| 1248 | if(window.location.protocol == 'https:')txtWebsocketServerUrl = "wss://"+kstychAppObject['user']['sipssldomain']+":8089/ws"; | ||
| 1249 | else txtWebsocketServerUrl = "ws://"+txtRealm+":8088/ws"; | ||
| 1250 | txtSIPOutboundProxyUrl = "";//txtSIPOutboundProxyUrl="udp://"+txtRealm+":5060"; | ||
| 1251 | |||
| 1252 | var preInit = function() { | ||
| 1253 | // set default webrtc type (before initialization) | ||
| 1254 | var s_webrtc_type = null;//getPVal("wt"); | ||
| 1255 | var s_fps = null;//getPVal("fps"); | ||
| 1256 | var s_mvs = null;//getPVal("mvs"); // maxVideoSize | ||
| 1257 | var s_mbwu = null;//getPVal("mbwu"); // maxBandwidthUp (kbps) | ||
| 1258 | var s_mbwd = null;//getPVal("mbwd"); // maxBandwidthUp (kbps) | ||
| 1259 | var s_za = null;//getPVal("za"); // ZeroArtifacts | ||
| 1260 | var s_ndb = null;//getPVal("ndb"); // NativeDebug | ||
| 1261 | |||
| 1262 | if (s_webrtc_type) SIPml.setWebRtcType(s_webrtc_type); | ||
| 1263 | |||
| 1264 | // initialize SIPML5 | ||
| 1265 | SIPml.init(postInit); | ||
| 1266 | |||
| 1267 | // set other options after initialization | ||
| 1268 | if (s_fps) SIPml.setFps(parseFloat(s_fps)); | ||
| 1269 | if (s_mvs) SIPml.setMaxVideoSize(s_mvs); | ||
| 1270 | if (s_mbwu) SIPml.setMaxBandwidthUp(parseFloat(s_mbwu)); | ||
| 1271 | if (s_mbwd) SIPml.setMaxBandwidthDown(parseFloat(s_mbwd)); | ||
| 1272 | if (s_za) SIPml.setZeroArtifacts(s_za === "true"); | ||
| 1273 | if (s_ndb == "true") SIPml.startNativeDebug(); | ||
| 1274 | |||
| 1275 | //var rinningApps = SIPml.getRunningApps(); | ||
| 1276 | //var _rinningApps = Base64.decode(rinningApps); | ||
| 1277 | //tsk_utils_log_info(_rinningApps); | ||
| 1278 | } | ||
| 1279 | |||
| 1280 | oReadyStateTimer = setInterval(function () { | ||
| 1281 | if (document.readyState === "complete") { | ||
| 1282 | clearInterval(oReadyStateTimer); | ||
| 1283 | // initialize SIPML5 | ||
| 1284 | preInit(); | ||
| 1285 | } | ||
| 1286 | }, | ||
| 1287 | 500); | ||
| 1288 | } | ||
| 1289 | } | ||
| 1290 | window.onload = function () | ||
| 1291 | { | ||
| 1292 | kDialerInit(); | ||
| 1293 | }; | ||
| 1294 | |||
| 1295 | function postInit() | ||
| 1296 | { | ||
| 1297 | // check for WebRTC support | ||
| 1298 | if (!SIPml.isWebRtcSupported()) | ||
| 1299 | { | ||
| 1300 | // is it chrome? | ||
| 1301 | if (SIPml.getNavigatorFriendlyName() == 'chrome') | ||
| 1302 | { | ||
| 1303 | document.location="msie?oldchrome"; | ||
| 1304 | return; | ||
| 1305 | } | ||
| 1306 | if (SIPml.getNavigatorFriendlyName() == 'ie'||SIPml.getNavigatorFriendlyName() == 'netscape') | ||
| 1307 | { | ||
| 1308 | document.location="msie"; | ||
| 1309 | return; | ||
| 1310 | } | ||
| 1311 | // checks for WebSocket support | ||
| 1312 | if (!SIPml.isWebSocketSupported() && !SIPml.isWebRtc4AllSupported()) | ||
| 1313 | { | ||
| 1314 | document.location="msie?nowebsockets"; | ||
| 1315 | return; | ||
| 1316 | } | ||
| 1317 | } | ||
| 1318 | |||
| 1319 | if (!SIPml.isWebRtc4AllSupported() && !SIPml.isWebRtcSupported()) | ||
| 1320 | { | ||
| 1321 | document.location="msie?notsupported"; | ||
| 1322 | return; | ||
| 1323 | } | ||
| 1324 | |||
| 1325 | oConfigCall = { | ||
| 1326 | audio_remote: audioRemote, | ||
| 1327 | video_local: videoLocal, | ||
| 1328 | video_remote: videoRemote, | ||
| 1329 | screencast_window_id: 0x00000000, // entire desktop | ||
| 1330 | bandwidth: { audio:undefined, video:undefined }, | ||
| 1331 | video_size: { minWidth:undefined, minHeight:undefined, maxWidth:undefined, maxHeight:undefined }, | ||
| 1332 | events_listener: { events: '*', listener: onSipEventSession }, | ||
| 1333 | sip_caps: [ | ||
| 1334 | { name: '+g.oma.sip-im' }, | ||
| 1335 | { name: 'language', value: '\"en,fr\"' } | ||
| 1336 | ] | ||
| 1337 | }; | ||
| 1338 | sipRegister(); | ||
| 1339 | //simpleNotification("warning","topRight","Requesting Voice Permissions"); | ||
| 1340 | //navigator.getUserMedia = (navigator.getUserMedia ||navigator.webkitGetUserMedia ||navigator.mozGetUserMedia || navigator.msGetUserMedia); | ||
| 1341 | //navigator.getUserMedia({video: false, audio: true},function(localMediaStream) {},function(err) {simpleNotification("error","topRight","Your Browser doesnot support Voice. Some functions will not work.");}); | ||
| 1342 | |||
| 1343 | } | ||
| 1344 | |||
| 1345 | |||
| 1346 | // sends SIP REGISTER request to login | ||
| 1347 | function sipRegister() { | ||
| 1348 | // catch exception for IE (DOM not ready) | ||
| 1349 | try | ||
| 1350 | { | ||
| 1351 | if (!txtRealm || !txtPrivateIdentity || !txtPublicIdentity) { | ||
| 1352 | txtRegStatus = '<b>Please fill madatory fields (*)</b>'; | ||
| 1353 | simpleNotification("error","topRight",txtRegStatus); | ||
| 1354 | return; | ||
| 1355 | } | ||
| 1356 | var o_impu = tsip_uri.prototype.Parse(txtPublicIdentity); | ||
| 1357 | if (!o_impu || !o_impu.s_user_name || !o_impu.s_host) { | ||
| 1358 | txtRegStatus = "<b>[" + txtPublicIdentity + "] is not a valid Public identity</b>"; | ||
| 1359 | simpleNotification("error","topRight",txtRegStatus); | ||
| 1360 | return; | ||
| 1361 | } | ||
| 1362 | |||
| 1363 | // enable notifications if not already done | ||
| 1364 | if (window.webkitNotifications && window.webkitNotifications.checkPermission() != 0) { | ||
| 1365 | window.webkitNotifications.requestPermission(); | ||
| 1366 | } | ||
| 1367 | |||
| 1368 | var iceServers=[{ url: 'stun:'+kstychAppObject['user']['sipserver']+':3478'}, { url:'turn:'+kstychAppObject['user']['sipserver'], credential:'1234',username: 'kstych'}]; | ||
| 1369 | if(kstychAppObject['config']['use-ice']=='no')iceServers=[{ url: 'stun:127.0.0.1:3478'}]; | ||
| 1370 | |||
| 1371 | // create SIP stack | ||
| 1372 | oSipStack = new SIPml.Stack({ | ||
| 1373 | realm: txtRealm, | ||
| 1374 | impi: txtPrivateIdentity, | ||
| 1375 | impu: txtPublicIdentity, | ||
| 1376 | password: kstychAppObject['user']['sipauth'], | ||
| 1377 | display_name: txtDisplayName, | ||
| 1378 | websocket_proxy_url: txtWebsocketServerUrl, | ||
| 1379 | outbound_proxy_url: txtSIPOutboundProxyUrl, | ||
| 1380 | ice_servers: iceServers, | ||
| 1381 | enable_rtcweb_breaker: false, | ||
| 1382 | events_listener: { events: '*', listener: onSipEventStack }, | ||
| 1383 | enable_early_ims: true, // Must be true unless you're using a real IMS network | ||
| 1384 | enable_media_stream_cache: false, | ||
| 1385 | bandwidth: null, // could be redefined a session-level | ||
| 1386 | video_size: null, // could be redefined a session-level | ||
| 1387 | sip_headers: [ | ||
| 1388 | { name: 'User-Agent', value: 'IM-client/Kstych' }, | ||
| 1389 | { name: 'Organization', value: 'Kstych Pvt Ltd' } | ||
| 1390 | ] | ||
| 1391 | } | ||
| 1392 | ); | ||
| 1393 | |||
| 1394 | if (oSipStack.start() != 0) { | ||
| 1395 | txtRegStatus = '<b>Failed to start the SIP stack</b>'; | ||
| 1396 | simpleNotification("error","topRight",txtRegStatus); | ||
| 1397 | } | ||
| 1398 | else {loggedin=1;return;} | ||
| 1399 | } | ||
| 1400 | catch (e) { | ||
| 1401 | txtRegStatus = "<b>2:" + e + "</b>"; | ||
| 1402 | simpleNotification("error","topRight",txtRegStatus); | ||
| 1403 | } | ||
| 1404 | } | ||
| 1405 | |||
| 1406 | // sends SIP REGISTER (expires=0) to logout | ||
| 1407 | function sipUnRegister(type) | ||
| 1408 | { | ||
| 1409 | if (oSipStack) { | ||
| 1410 | try{sipHangUp();}catch(e){console.log(e);} | ||
| 1411 | oSipStack.stop(); // shutdown all sessions | ||
| 1412 | } | ||
| 1413 | |||
| 1414 | if(!type) | ||
| 1415 | { | ||
| 1416 | /* simpleNotification("warning","topRight","Retrying in 10 sec...");*/ | ||
| 1417 | $("#phonetopbar").hide(); | ||
| 1418 | //setTimeout(sipRegister,10*1000); | ||
| 1419 | document.location='/logout'; | ||
| 1420 | } | ||
| 1421 | else loggedin=0; | ||
| 1422 | } | ||
| 1423 | |||
| 1424 | // makes a call (SIP INVITE) | ||
| 1425 | function sipCall(s_type,destination) { | ||
| 1426 | if(oSipStack) | ||
| 1427 | { | ||
| 1428 | if (oSipSessionCall) { | ||
| 1429 | txtCallStatus = '<i>Already in a Call...</i>'; | ||
| 1430 | simpleNotification("warning","topRight",txtCallStatus); | ||
| 1431 | } | ||
| 1432 | else { | ||
| 1433 | if (!tsk_string_is_null_or_empty(destination)) { | ||
| 1434 | |||
| 1435 | if(s_type == 'call-screenshare') { | ||
| 1436 | if(!SIPml.isScreenShareSupported()) { | ||
| 1437 | alert('Screen sharing not supported. Are you using chrome 26+?'); | ||
| 1438 | return; | ||
| 1439 | } | ||
| 1440 | if (!location.protocol.match('https')){ | ||
| 1441 | if (confirm("Screen sharing requires https://. Do you want to be redirected?")) { | ||
| 1442 | sipUnRegister(); | ||
| 1443 | window.location = 'msie?httpsneeded'; | ||
| 1444 | } | ||
| 1445 | return; | ||
| 1446 | } | ||
| 1447 | } | ||
| 1448 | btnCall = true; | ||
| 1449 | btnHangUp = false; | ||
| 1450 | |||
| 1451 | |||
| 1452 | // create call session | ||
| 1453 | oSipSessionCall = oSipStack.newSession(s_type, oConfigCall); | ||
| 1454 | // make call | ||
| 1455 | if (oSipSessionCall.call(destination) != 0) { | ||
| 1456 | oSipSessionCall = null; | ||
| 1457 | txtCallStatus = 'Failed to make call'; | ||
| 1458 | simpleNotification("error","topRight",txtCallStatus); | ||
| 1459 | btnCall = false; | ||
| 1460 | btnHangUp = true; | ||
| 1461 | return; | ||
| 1462 | } | ||
| 1463 | } | ||
| 1464 | } | ||
| 1465 | } | ||
| 1466 | } | ||
| 1467 | function sipAnswer() | ||
| 1468 | { | ||
| 1469 | if(oSipStack){ | ||
| 1470 | if (oSipSessionCall) { | ||
| 1471 | txtCallStatus = '<i>Connecting...</i>'; | ||
| 1472 | //simpleNotification("warning","topRight",txtCallStatus); | ||
| 1473 | oSipSessionCall.accept(oConfigCall); | ||
| 1474 | } | ||
| 1475 | } | ||
| 1476 | if(answergrowl)$.gritter.remove(answergrowl, {fade: true,speed: 'slow'}); | ||
| 1477 | } | ||
| 1478 | |||
| 1479 | // Share entire desktop aor application using BFCP or WebRTC native implementation | ||
| 1480 | function sipShareScreen() { | ||
| 1481 | if (SIPml.getWebRtcType() === 'w4a') { | ||
| 1482 | // Sharing using BFCP -> requires an active session | ||
| 1483 | if (!oSipSessionCall) { | ||
| 1484 | txtCallStatus = '<i>No active session</i>'; | ||
| 1485 | return; | ||
| 1486 | } | ||
| 1487 | if (oSipSessionCall.bfcpSharing) { | ||
| 1488 | if (oSipSessionCall.stopBfcpShare(oConfigCall) != 0) { | ||
| 1489 | txtCallStatus = 'Failed to stop BFCP share'; | ||
| 1490 | } | ||
| 1491 | else { | ||
| 1492 | oSipSessionCall.bfcpSharing = false; | ||
| 1493 | } | ||
| 1494 | } | ||
| 1495 | else { | ||
| 1496 | oConfigCall.screencast_window_id = 0x00000000; | ||
| 1497 | if (oSipSessionCall.startBfcpShare(oConfigCall) != 0) { | ||
| 1498 | txtCallStatus = 'Failed to start BFCP share'; | ||
| 1499 | } | ||
| 1500 | else { | ||
| 1501 | oSipSessionCall.bfcpSharing = true; | ||
| 1502 | } | ||
| 1503 | } | ||
| 1504 | } | ||
| 1505 | else { | ||
| 1506 | sipCall('call-screenshare',txtPhoneNumber); | ||
| 1507 | } | ||
| 1508 | } | ||
| 1509 | |||
| 1510 | |||
| 1511 | |||
| 1512 | // transfers the call | ||
| 1513 | function sipTransfer(s_destination) { | ||
| 1514 | if (oSipSessionCall) { | ||
| 1515 | if (!tsk_string_is_null_or_empty(s_destination)) { | ||
| 1516 | btnTransfer.disabled = true; | ||
| 1517 | if (oSipSessionCall.transfer(s_destination) != 0) { | ||
| 1518 | txtCallStatus = '<i>Call transfer failed</i>'; | ||
| 1519 | btnTransfer.disabled = false; | ||
| 1520 | return; | ||
| 1521 | } | ||
| 1522 | txtCallStatus = '<i>Transfering the call...</i>'; | ||
| 1523 | } | ||
| 1524 | } | ||
| 1525 | } | ||
| 1526 | |||
| 1527 | // holds or resumes the call | ||
| 1528 | function sipToggleHoldResume() { | ||
| 1529 | if (oSipSessionCall) { | ||
| 1530 | var i_ret; | ||
| 1531 | btnHoldResume.disabled = true; | ||
| 1532 | txtCallStatus = oSipSessionCall.bHeld ? '<i>Resuming the call...</i>' : '<i>Holding the call...</i>'; | ||
| 1533 | i_ret = oSipSessionCall.bHeld ? oSipSessionCall.resume() : oSipSessionCall.hold(); | ||
| 1534 | if (i_ret != 0) { | ||
| 1535 | txtCallStatus = '<i>Hold / Resume failed</i>'; | ||
| 1536 | btnHoldResume.disabled = false; | ||
| 1537 | return; | ||
| 1538 | } | ||
| 1539 | } | ||
| 1540 | } | ||
| 1541 | |||
| 1542 | // Mute or Unmute the call | ||
| 1543 | function sipToggleMute() { | ||
| 1544 | if (oSipSessionCall) { | ||
| 1545 | var i_ret; | ||
| 1546 | var bMute = !oSipSessionCall.bMute; | ||
| 1547 | txtCallStatus = bMute ? '<i>Mute the call...</i>' : '<i>Unmute the call...</i>'; | ||
| 1548 | i_ret = oSipSessionCall.mute('audio'/*could be 'video'*/, bMute); | ||
| 1549 | if (i_ret != 0) { | ||
| 1550 | simpleNotification('error','topRight',"Mute / Unmute failed"); | ||
| 1551 | return; | ||
| 1552 | } | ||
| 1553 | oSipSessionCall.bMute = bMute; | ||
| 1554 | var btnMute = bMute ? "Mute" : "Unmute"; | ||
| 1555 | simpleNotification('success','topRight',"You are now ["+btnMute+"]"); | ||
| 1556 | |||
| 1557 | return bMute ? 0 : 1; | ||
| 1558 | } | ||
| 1559 | return 1; | ||
| 1560 | } | ||
| 1561 | |||
| 1562 | // terminates the call (SIP BYE or CANCEL) | ||
| 1563 | function sipHangUp() { | ||
| 1564 | try | ||
| 1565 | { | ||
| 1566 | stopRingbackTone(); | ||
| 1567 | stopRingTone(); | ||
| 1568 | |||
| 1569 | if (oSipSessionCall) { | ||
| 1570 | txtCallStatus = '<i>Terminating the call...</i>'; | ||
| 1571 | oSipSessionCall.hangup({events_listener: { events: '*', listener: onSipEventSession }}); | ||
| 1572 | //simpleNotification("warning","topRight","Call Terminated."); | ||
| 1573 | } | ||
| 1574 | //$("#phonetopbar").hide(); | ||
| 1575 | } | ||
| 1576 | catch(e){console.log(e);} | ||
| 1577 | |||
| 1578 | if(hangupgrowl)$.gritter.remove(hangupgrowl, {fade: true,speed: 'slow'}); | ||
| 1579 | if(answergrowl)$.gritter.remove(answergrowl, {fade: true,speed: 'slow'}); | ||
| 1580 | } | ||
| 1581 | |||
| 1582 | function sipSendDTMF(c){ | ||
| 1583 | if(oSipSessionCall && c){ | ||
| 1584 | if(oSipSessionCall.dtmf(c) == 0){ | ||
| 1585 | try { dtmfTone.play(); } catch(e){ } | ||
| 1586 | } | ||
| 1587 | } | ||
| 1588 | } | ||
| 1589 | |||
| 1590 | function startRingTone() { | ||
| 1591 | try { ringtone.play(); } | ||
| 1592 | catch (e) { } | ||
| 1593 | } | ||
| 1594 | |||
| 1595 | function stopRingTone() { | ||
| 1596 | try { ringtone.pause(); } | ||
| 1597 | catch (e) { } | ||
| 1598 | } | ||
| 1599 | |||
| 1600 | function startRingbackTone() { | ||
| 1601 | try { ringbacktone.play(); } | ||
| 1602 | catch (e) { } | ||
| 1603 | } | ||
| 1604 | |||
| 1605 | function stopRingbackTone() { | ||
| 1606 | try { ringbacktone.pause(); } | ||
| 1607 | catch (e) { } | ||
| 1608 | } | ||
| 1609 | |||
| 1610 | function toggleFullScreen() { | ||
| 1611 | if (videoRemote.webkitSupportsFullscreen) { | ||
| 1612 | fullScreen(!videoRemote.webkitDisplayingFullscreen); | ||
| 1613 | } | ||
| 1614 | else { | ||
| 1615 | fullScreen(!bFullScreen); | ||
| 1616 | } | ||
| 1617 | } | ||
| 1618 | |||
| 1619 | function fullScreen(b_fs) { | ||
| 1620 | return false;//TODO | ||
| 1621 | bFullScreen = b_fs; | ||
| 1622 | if (tsk_utils_have_webrtc4native() && bFullScreen && videoRemote.webkitSupportsFullscreen) { | ||
| 1623 | if (bFullScreen) { | ||
| 1624 | videoRemote.webkitEnterFullScreen(); | ||
| 1625 | } | ||
| 1626 | else { | ||
| 1627 | videoRemote.webkitExitFullscreen(); | ||
| 1628 | } | ||
| 1629 | } | ||
| 1630 | else { | ||
| 1631 | if (tsk_utils_have_webrtc4npapi()) { | ||
| 1632 | try { if(window.__o_display_remote) window.__o_display_remote.setFullScreen(b_fs); } | ||
| 1633 | catch (e) { /*divVideo.setAttribute("class", b_fs ? "full-screen" : "normal-screen");*/ } | ||
| 1634 | } | ||
| 1635 | else { | ||
| 1636 | //divVideo.setAttribute("class", b_fs ? "full-screen" : "normal-screen"); | ||
| 1637 | } | ||
| 1638 | } | ||
| 1639 | } | ||
| 1640 | |||
| 1641 | function showNotifICall(s_number) { | ||
| 1642 | return false;//TODO | ||
| 1643 | // permission already asked when we registered | ||
| 1644 | if (window.webkitNotifications && window.webkitNotifications.checkPermission() == 0) { | ||
| 1645 | if (oNotifICall) { | ||
| 1646 | oNotifICall.cancel(); | ||
| 1647 | } | ||
| 1648 | oNotifICall = window.webkitNotifications.createNotification('images/sipml-34x39.png', 'Incaming call', 'Incoming call from ' + s_number); | ||
| 1649 | oNotifICall.onclose = function () { oNotifICall = null; }; | ||
| 1650 | oNotifICall.show(); | ||
| 1651 | } | ||
| 1652 | } | ||
| 1653 | |||
| 1654 | |||
| 1655 | function uiOnConnectionEvent(b_connected, b_connecting) { | ||
| 1656 | // should be enum: connecting, connected, terminating, terminated | ||
| 1657 | //TODO | ||
| 1658 | btnRegister = b_connected || b_connecting; | ||
| 1659 | btnUnRegister = !b_connected && !b_connecting; | ||
| 1660 | btnCall = !(b_connected && tsk_utils_have_webrtc() && tsk_utils_have_stream()); | ||
| 1661 | btnHangUp = !oSipSessionCall; | ||
| 1662 | } | ||
| 1663 | |||
| 1664 | function uiVideoDisplayEvent(b_local, b_added) { | ||
| 1665 | return false;//TODO | ||
| 1666 | var o_elt_video = b_local ? videoLocal : videoRemote; | ||
| 1667 | |||
| 1668 | if (b_added) { | ||
| 1669 | if (SIPml.isWebRtc4AllSupported()) { | ||
| 1670 | if (b_local) { | ||
| 1671 | if (WebRtc4all_GetDisplayLocal()) WebRtc4all_GetDisplayLocal().style.visibility = "visible"; | ||
| 1672 | if (WebRtc4all_GetDisplayLocalScreencast()) WebRtc4all_GetDisplayLocalScreencast().style.visibility = "visible"; | ||
| 1673 | //videoLocal.style.visibility = "visible"; | ||
| 1674 | //viewLocalScreencast.style.visibility = "visible"; | ||
| 1675 | //if (WebRtc4all_GetDisplayLocal()) WebRtc4all_GetDisplayLocal().hidden = false; | ||
| 1676 | //if (WebRtc4all_GetDisplayLocalScreencast()) WebRtc4all_GetDisplayLocalScreencast().hidden = false; | ||
| 1677 | } | ||
| 1678 | else { | ||
| 1679 | if (WebRtc4all_GetDisplayRemote()) WebRtc4all_GetDisplayRemote().style.visibility = "visible"; | ||
| 1680 | //videoRemote.style.visibility = "visible"; | ||
| 1681 | //if (WebRtc4all_GetDisplayRemote()) WebRtc4all_GetDisplayRemote().hidden = false; | ||
| 1682 | } | ||
| 1683 | } | ||
| 1684 | else { | ||
| 1685 | o_elt_video.style.opacity = 1; | ||
| 1686 | } | ||
| 1687 | uiVideoDisplayShowHide(true); | ||
| 1688 | } | ||
| 1689 | else { | ||
| 1690 | if (SIPml.isWebRtc4AllSupported()) { | ||
| 1691 | if (b_local) { | ||
| 1692 | if (WebRtc4all_GetDisplayLocal()) WebRtc4all_GetDisplayLocal().style.visibility = "hidden"; | ||
| 1693 | if (WebRtc4all_GetDisplayLocalScreencast()) WebRtc4all_GetDisplayLocalScreencast().style.visibility = "hidden"; | ||
| 1694 | //videoLocal.style.visibility = "hidden"; | ||
| 1695 | //viewLocalScreencast.style.visibility = "hidden"; | ||
| 1696 | //if (WebRtc4all_GetDisplayLocal()) WebRtc4all_GetDisplayLocal().hidden = true; | ||
| 1697 | //if (WebRtc4all_GetDisplayLocalScreencast()) WebRtc4all_GetDisplayLocalScreencast().hidden = true; | ||
| 1698 | } | ||
| 1699 | else { | ||
| 1700 | if (WebRtc4all_GetDisplayRemote()) WebRtc4all_GetDisplayRemote().style.visibility = "hidden"; | ||
| 1701 | //videoRemote.style.visibility = "hidden"; | ||
| 1702 | //if (WebRtc4all_GetDisplayRemote()) WebRtc4all_GetDisplayRemote().hidden = true; | ||
| 1703 | } | ||
| 1704 | } | ||
| 1705 | else{ | ||
| 1706 | o_elt_video.style.opacity = 0; | ||
| 1707 | } | ||
| 1708 | fullScreen(false); | ||
| 1709 | } | ||
| 1710 | } | ||
| 1711 | |||
| 1712 | function uiVideoDisplayShowHide(b_show) { | ||
| 1713 | //TODO | ||
| 1714 | if (b_show) { | ||
| 1715 | |||
| 1716 | } | ||
| 1717 | else { | ||
| 1718 | |||
| 1719 | } | ||
| 1720 | btnFullScreen.disabled = !b_show; | ||
| 1721 | } | ||
| 1722 | |||
| 1723 | function uiCallTerminated(s_description){ | ||
| 1724 | |||
| 1725 | btnCall = false; | ||
| 1726 | btnHangUp = true; | ||
| 1727 | |||
| 1728 | oSipSessionCall = null; | ||
| 1729 | |||
| 1730 | stopRingbackTone(); | ||
| 1731 | stopRingTone(); | ||
| 1732 | |||
| 1733 | txtCallStatus = "<i>" + s_description + "</i>"; | ||
| 1734 | uiVideoDisplayShowHide(false); | ||
| 1735 | //divCallOptions.style.opacity = 0; | ||
| 1736 | |||
| 1737 | if (oNotifICall) { | ||
| 1738 | oNotifICall.cancel(); | ||
| 1739 | oNotifICall = null; | ||
| 1740 | } | ||
| 1741 | |||
| 1742 | uiVideoDisplayEvent(true, false); | ||
| 1743 | uiVideoDisplayEvent(false, false); | ||
| 1744 | |||
| 1745 | setTimeout(function () { if (!oSipSessionCall) txtCallStatus = ''; }, 2500); | ||
| 1746 | |||
| 1747 | if(hangupgrowl)$.gritter.remove(hangupgrowl, {fade: true,speed: 'slow'}); | ||
| 1748 | } | ||
| 1749 | |||
| 1750 | // Callback function for SIP Stacks | ||
| 1751 | function onSipEventStack(e /*SIPml.Stack.Event*/) { | ||
| 1752 | tsk_utils_log_info('==stack event = ' + e.type); | ||
| 1753 | switch (e.type) { | ||
| 1754 | case 'started': | ||
| 1755 | { | ||
| 1756 | // catch exception for IE (DOM not ready) | ||
| 1757 | try { | ||
| 1758 | // LogIn (REGISTER) as soon as the stack finish starting | ||
| 1759 | oSipSessionRegister = this.newSession('register', { | ||
| 1760 | expires: 200, | ||
| 1761 | events_listener: { events: '*', listener: onSipEventSession }, | ||
| 1762 | sip_caps: [ | ||
| 1763 | { name: '+g.oma.sip-im', value: null }, | ||
| 1764 | { name: '+audio', value: null }, | ||
| 1765 | { name: 'language', value: '\"en,fr\"' } | ||
| 1766 | ] | ||
| 1767 | }); | ||
| 1768 | oSipSessionRegister.register(); | ||
| 1769 | } | ||
| 1770 | catch (e) { | ||
| 1771 | txtRegStatus = txtRegStatus = "<b>1:" + e + "</b>"; | ||
| 1772 | simpleNotification("success","topRight",txtRegStatus); | ||
| 1773 | btnRegister = false; | ||
| 1774 | } | ||
| 1775 | break; | ||
| 1776 | } | ||
| 1777 | case 'stopping': case 'stopped': case 'failed_to_start': case 'failed_to_stop': | ||
| 1778 | { | ||
| 1779 | var bFailure = (e.type == 'failed_to_start') || (e.type == 'failed_to_stop'); | ||
| 1780 | oSipStack = null; | ||
| 1781 | oSipSessionRegister = null; | ||
| 1782 | oSipSessionCall = null; | ||
| 1783 | |||
| 1784 | uiOnConnectionEvent(false, false); | ||
| 1785 | |||
| 1786 | stopRingbackTone(); | ||
| 1787 | stopRingTone(); | ||
| 1788 | |||
| 1789 | uiVideoDisplayShowHide(false); | ||
| 1790 | //divCallOptions.style.opacity = 0; | ||
| 1791 | |||
| 1792 | txtCallStatus = ''; | ||
| 1793 | if(loggedin) | ||
| 1794 | { | ||
| 1795 | txtRegStatus = bFailure ? "<i>Disconnected: <b>" + e.description + "</b></i>" : "<i>Disconnected</i>"; | ||
| 1796 | //simpleNotification("warning","topRight",txtRegStatus+", Retrying in 10 sec..."); | ||
| 1797 | //setTimeout(sipRegister,10*1000);//TODO dont retry too many times, idleapp instead | ||
| 1798 | document.location='/logout'; | ||
| 1799 | } | ||
| 1800 | else | ||
| 1801 | { | ||
| 1802 | if(e.type=='stopped')doLogout(1); | ||
| 1803 | } | ||
| 1804 | break; | ||
| 1805 | } | ||
| 1806 | |||
| 1807 | case 'i_new_call': | ||
| 1808 | { | ||
| 1809 | if (oSipSessionCall) { | ||
| 1810 | // do not accept the incoming call if we're already 'in call' | ||
| 1811 | e.newSession.hangup(); // comment this line for multi-line support | ||
| 1812 | } | ||
| 1813 | else { | ||
| 1814 | oSipSessionCall = e.newSession; | ||
| 1815 | |||
| 1816 | btnCall = 'Answer'; | ||
| 1817 | btnHangUp = 'Reject'; | ||
| 1818 | btnCall = false; | ||
| 1819 | btnHangUp = false; | ||
| 1820 | |||
| 1821 | var sRemoteNumber = (oSipSessionCall.getRemoteFriendlyName() || 'unknown'); | ||
| 1822 | |||
| 1823 | if(sRemoteNumber=='1000'+kstychAppObject['user']['sipid']) | ||
| 1824 | { | ||
| 1825 | //auto answer if own conf | ||
| 1826 | var dialerConnection=kGetDData("D","connection"); | ||
| 1827 | dialerConnection['connected']=1; | ||
| 1828 | updateDialerState("dialer","connection",dialerConnection); | ||
| 1829 | sipAnswer(); | ||
| 1830 | } | ||
| 1831 | else | ||
| 1832 | { | ||
| 1833 | startRingTone(); | ||
| 1834 | txtCallStatus = "<i><a href=# onclick='sipAnswer();return false;'>Incoming call Click Here To Answer</a></i> from [<b>" + sRemoteNumber + "</b>]"; | ||
| 1835 | //showNotifICall(sRemoteNumber); | ||
| 1836 | answergrowl=growlSNotify("Incoming Call",txtCallStatus,"top-right"); | ||
| 1837 | hangupgrowl=growlSNotify("Incoming Call","<a href=# onclick='sipHangUp();return false;' style='color:white'>Click here to hangup</a>","top-right"); | ||
| 1838 | } | ||
| 1839 | //showNotifICall(sRemoteNumber); | ||
| 1840 | } | ||
| 1841 | break; | ||
| 1842 | } | ||
| 1843 | |||
| 1844 | case 'm_permission_requested': | ||
| 1845 | { | ||
| 1846 | //document.getElementById('divNavbarInner').setAttribute('class', 'navbar-inner-red'); | ||
| 1847 | break; | ||
| 1848 | } | ||
| 1849 | case 'm_permission_accepted': | ||
| 1850 | case 'm_permission_refused': | ||
| 1851 | { | ||
| 1852 | //document.getElementById('divNavbarInner').setAttribute('class', 'navbar-inner'); | ||
| 1853 | if(e.type == 'm_permission_refused'){ | ||
| 1854 | uiCallTerminated('Media stream permission denied'); | ||
| 1855 | } | ||
| 1856 | break; | ||
| 1857 | } | ||
| 1858 | |||
| 1859 | case 'starting': default: break; | ||
| 1860 | } | ||
| 1861 | }; | ||
| 1862 | |||
| 1863 | // Callback function for SIP sessions (INVITE, REGISTER, MESSAGE...) | ||
| 1864 | function onSipEventSession(e /* SIPml.Session.Event */) { | ||
| 1865 | tsk_utils_log_info('==session event = ' + e.type); | ||
| 1866 | |||
| 1867 | switch (e.type) { | ||
| 1868 | case 'connecting': case 'connected': | ||
| 1869 | { | ||
| 1870 | var bConnected = (e.type == 'connected'); | ||
| 1871 | if (e.session == oSipSessionRegister) { | ||
| 1872 | uiOnConnectionEvent(bConnected, !bConnected); | ||
| 1873 | txtRegStatus = "<i>" + e.description + "</i>"; | ||
| 1874 | if(bConnected){/*simpleNotification("success","topRight","Connected");*//*$("#phonetopbar").show();*/kDialerConnected();} | ||
| 1875 | } | ||
| 1876 | else if (e.session == oSipSessionCall) { | ||
| 1877 | btnHangUp = 'HangUp'; | ||
| 1878 | btnCall = true; | ||
| 1879 | btnHangUp = false; | ||
| 1880 | btnTransfer = false; | ||
| 1881 | |||
| 1882 | if (bConnected) { | ||
| 1883 | stopRingbackTone(); | ||
| 1884 | stopRingTone(); | ||
| 1885 | |||
| 1886 | if (oNotifICall) { | ||
| 1887 | oNotifICall.cancel(); | ||
| 1888 | oNotifICall = null; | ||
| 1889 | } | ||
| 1890 | } | ||
| 1891 | |||
| 1892 | txtCallStatus = "<i>" + e.description + "</i>"; | ||
| 1893 | //simpleNotification("success","topRight",txtCallStatus); | ||
| 1894 | //divCallOptions.style.opacity = bConnected ? 1 : 0; | ||
| 1895 | |||
| 1896 | if (SIPml.isWebRtc4AllSupported()) { // IE don't provide stream callback | ||
| 1897 | uiVideoDisplayEvent(true, true); | ||
| 1898 | uiVideoDisplayEvent(false, true); | ||
| 1899 | } | ||
| 1900 | } | ||
| 1901 | break; | ||
| 1902 | } // 'connecting' | 'connected' | ||
| 1903 | case 'terminating': case 'terminated': | ||
| 1904 | { | ||
| 1905 | if (e.session == oSipSessionRegister) { | ||
| 1906 | uiOnConnectionEvent(false, false); | ||
| 1907 | |||
| 1908 | oSipSessionCall = null; | ||
| 1909 | oSipSessionRegister = null; | ||
| 1910 | |||
| 1911 | txtRegStatus = "<i>" + e.description + "</i>"; | ||
| 1912 | //simpleNotification("warning","topRight",txtRegStatus); | ||
| 1913 | } | ||
| 1914 | else if (e.session == oSipSessionCall) { | ||
| 1915 | uiCallTerminated(e.description); | ||
| 1916 | } | ||
| 1917 | break; | ||
| 1918 | } // 'terminating' | 'terminated' | ||
| 1919 | |||
| 1920 | case 'm_stream_video_local_added': | ||
| 1921 | { | ||
| 1922 | if (e.session == oSipSessionCall) { | ||
| 1923 | uiVideoDisplayEvent(true, true); | ||
| 1924 | } | ||
| 1925 | break; | ||
| 1926 | } | ||
| 1927 | case 'm_stream_video_local_removed': | ||
| 1928 | { | ||
| 1929 | if (e.session == oSipSessionCall) { | ||
| 1930 | uiVideoDisplayEvent(true, false); | ||
| 1931 | } | ||
| 1932 | break; | ||
| 1933 | } | ||
| 1934 | case 'm_stream_video_remote_added': | ||
| 1935 | { | ||
| 1936 | if (e.session == oSipSessionCall) { | ||
| 1937 | uiVideoDisplayEvent(false, true); | ||
| 1938 | } | ||
| 1939 | break; | ||
| 1940 | } | ||
| 1941 | case 'm_stream_video_remote_removed': | ||
| 1942 | { | ||
| 1943 | if (e.session == oSipSessionCall) { | ||
| 1944 | uiVideoDisplayEvent(false, false); | ||
| 1945 | } | ||
| 1946 | break; | ||
| 1947 | } | ||
| 1948 | |||
| 1949 | case 'm_stream_audio_local_added': | ||
| 1950 | case 'm_stream_audio_local_removed': | ||
| 1951 | case 'm_stream_audio_remote_added': | ||
| 1952 | case 'm_stream_audio_remote_removed': | ||
| 1953 | { | ||
| 1954 | break; | ||
| 1955 | } | ||
| 1956 | |||
| 1957 | case 'i_ect_new_call': | ||
| 1958 | { | ||
| 1959 | oSipSessionTransferCall = e.session; | ||
| 1960 | break; | ||
| 1961 | } | ||
| 1962 | |||
| 1963 | case 'i_ao_request': | ||
| 1964 | { | ||
| 1965 | if(e.session == oSipSessionCall){ | ||
| 1966 | var iSipResponseCode = e.getSipResponseCode(); | ||
| 1967 | if (iSipResponseCode == 180 || iSipResponseCode == 183) { | ||
| 1968 | startRingbackTone(); | ||
| 1969 | txtCallStatus = '<i>Remote ringing...</i>'; | ||
| 1970 | //simpleNotification("warning","topRight",txtCallStatus); | ||
| 1971 | } | ||
| 1972 | } | ||
| 1973 | break; | ||
| 1974 | } | ||
| 1975 | |||
| 1976 | case 'm_early_media': | ||
| 1977 | { | ||
| 1978 | if(e.session == oSipSessionCall){ | ||
| 1979 | stopRingbackTone(); | ||
| 1980 | stopRingTone(); | ||
| 1981 | txtCallStatus = '<i>Early media started</i>'; | ||
| 1982 | //simpleNotification("warning","topRight",txtCallStatus); | ||
| 1983 | } | ||
| 1984 | break; | ||
| 1985 | } | ||
| 1986 | |||
| 1987 | case 'm_local_hold_ok': | ||
| 1988 | { | ||
| 1989 | if(e.session == oSipSessionCall){ | ||
| 1990 | if (oSipSessionCall.bTransfering) { | ||
| 1991 | oSipSessionCall.bTransfering = false; | ||
| 1992 | // this.AVSession.TransferCall(this.transferUri); | ||
| 1993 | } | ||
| 1994 | btnHoldResume = false; | ||
| 1995 | txtCallStatus = '<i>Call placed on hold</i>'; | ||
| 1996 | oSipSessionCall.bHeld = true; | ||
| 1997 | //simpleNotification("success","topRight",txtCallStatus); | ||
| 1998 | } | ||
| 1999 | break; | ||
| 2000 | } | ||
| 2001 | case 'm_local_hold_nok': | ||
| 2002 | { | ||
| 2003 | if(e.session == oSipSessionCall){ | ||
| 2004 | oSipSessionCall.bTransfering = false; | ||
| 2005 | btnHoldResume = false; | ||
| 2006 | txtCallStatus = '<i>Failed to place remote party on hold</i>'; | ||
| 2007 | //simpleNotification("error","topRight",txtCallStatus); | ||
| 2008 | } | ||
| 2009 | break; | ||
| 2010 | } | ||
| 2011 | case 'm_local_resume_ok': | ||
| 2012 | { | ||
| 2013 | if(e.session == oSipSessionCall){ | ||
| 2014 | oSipSessionCall.bTransfering = false; | ||
| 2015 | btnHoldResume = false; | ||
| 2016 | txtCallStatus = '<i>Call taken off hold</i>'; | ||
| 2017 | oSipSessionCall.bHeld = false; | ||
| 2018 | //simpleNotification("warning","topRight",txtCallStatus); | ||
| 2019 | |||
| 2020 | if (SIPml.isWebRtc4AllSupported()) { // IE don't provide stream callback yet | ||
| 2021 | uiVideoDisplayEvent(true, true); | ||
| 2022 | uiVideoDisplayEvent(false, true); | ||
| 2023 | } | ||
| 2024 | } | ||
| 2025 | break; | ||
| 2026 | } | ||
| 2027 | case 'm_local_resume_nok': | ||
| 2028 | { | ||
| 2029 | if(e.session == oSipSessionCall){ | ||
| 2030 | oSipSessionCall.bTransfering = false; | ||
| 2031 | btnHoldResume = false; | ||
| 2032 | txtCallStatus = '<i>Failed to unhold call</i>'; | ||
| 2033 | //simpleNotification("error","topRight",txtCallStatus); | ||
| 2034 | } | ||
| 2035 | break; | ||
| 2036 | } | ||
| 2037 | case 'm_remote_hold': | ||
| 2038 | { | ||
| 2039 | if(e.session == oSipSessionCall){ | ||
| 2040 | txtCallStatus = '<i>Placed on hold by remote party</i>'; | ||
| 2041 | //simpleNotification("warning","topRight",txtCallStatus); | ||
| 2042 | } | ||
| 2043 | break; | ||
| 2044 | } | ||
| 2045 | case 'm_remote_resume': | ||
| 2046 | { | ||
| 2047 | if(e.session == oSipSessionCall){ | ||
| 2048 | txtCallStatus = '<i>Taken off hold by remote party</i>'; | ||
| 2049 | //simpleNotification("warning","topRight",txtCallStatus); | ||
| 2050 | } | ||
| 2051 | break; | ||
| 2052 | } | ||
| 2053 | case 'm_bfcp_info': | ||
| 2054 | { | ||
| 2055 | if(e.session == oSipSessionCall){ | ||
| 2056 | txtCallStatus.innerHTML = 'BFCP Info: <i>'+ e.description +'</i>'; | ||
| 2057 | } | ||
| 2058 | break; | ||
| 2059 | } | ||
| 2060 | case 'o_ect_trying': | ||
| 2061 | { | ||
| 2062 | if(e.session == oSipSessionCall){ | ||
| 2063 | txtCallStatus = '<i>Call transfer in progress...</i>'; | ||
| 2064 | //simpleNotification("warning","topRight",txtCallStatus); | ||
| 2065 | } | ||
| 2066 | break; | ||
| 2067 | } | ||
| 2068 | case 'o_ect_accepted': | ||
| 2069 | { | ||
| 2070 | if(e.session == oSipSessionCall){ | ||
| 2071 | txtCallStatus = '<i>Call transfer accepted</i>'; | ||
| 2072 | //simpleNotification("success","topRight",txtCallStatus); | ||
| 2073 | } | ||
| 2074 | break; | ||
| 2075 | } | ||
| 2076 | case 'o_ect_completed': | ||
| 2077 | case 'i_ect_completed': | ||
| 2078 | { | ||
| 2079 | if(e.session == oSipSessionCall){ | ||
| 2080 | txtCallStatus = '<i>Call transfer completed</i>'; | ||
| 2081 | //simpleNotification("success","topRight",txtCallStatus); | ||
| 2082 | btnTransfer = false; | ||
| 2083 | if (oSipSessionTransferCall) { | ||
| 2084 | oSipSessionCall = oSipSessionTransferCall; | ||
| 2085 | } | ||
| 2086 | oSipSessionTransferCall = null; | ||
| 2087 | } | ||
| 2088 | break; | ||
| 2089 | } | ||
| 2090 | case 'o_ect_failed': | ||
| 2091 | case 'i_ect_failed': | ||
| 2092 | { | ||
| 2093 | if(e.session == oSipSessionCall){ | ||
| 2094 | txtCallStatus = '<i>Call transfer failed</i>'; | ||
| 2095 | //simpleNotification("error","topRight",txtCallStatus); | ||
| 2096 | btnTransfer = false; | ||
| 2097 | } | ||
| 2098 | break; | ||
| 2099 | } | ||
| 2100 | case 'o_ect_notify': | ||
| 2101 | case 'i_ect_notify': | ||
| 2102 | { | ||
| 2103 | if(e.session == oSipSessionCall){ | ||
| 2104 | txtCallStatus = "<i>Call Transfer: <b>" + e.getSipResponseCode() + " " + e.description + "</b></i>"; | ||
| 2105 | //simpleNotification("success","topRight",txtCallStatus); | ||
| 2106 | if (e.getSipResponseCode() >= 300) { | ||
| 2107 | if (oSipSessionCall.bHeld) { | ||
| 2108 | oSipSessionCall.resume(); | ||
| 2109 | } | ||
| 2110 | btnTransfer = false; | ||
| 2111 | } | ||
| 2112 | } | ||
| 2113 | break; | ||
| 2114 | } | ||
| 2115 | case 'i_ect_requested': | ||
| 2116 | { | ||
| 2117 | if(e.session == oSipSessionCall){ | ||
| 2118 | var s_message = "Do you accept call transfer to [" + e.getTransferDestinationFriendlyName() + "]?";//FIXME | ||
| 2119 | if (confirm(s_message)) { | ||
| 2120 | txtCallStatus = "<i>Call transfer in progress...</i>"; | ||
| 2121 | //simpleNotification("warning","topRight",txtCallStatus); | ||
| 2122 | oSipSessionCall.acceptTransfer(); | ||
| 2123 | break; | ||
| 2124 | } | ||
| 2125 | oSipSessionCall.rejectTransfer(); | ||
| 2126 | } | ||
| 2127 | break; | ||
| 2128 | } | ||
| 2129 | |||
| 2130 | } | ||
| 2131 | } | ||
| 2132 | |||
| 2133 | |||
| 2134 | function dialerSipMsg(omsg) | ||
| 2135 | { | ||
| 2136 | try | ||
| 2137 | { | ||
| 2138 | if(omsg.ao_headers[6].s_name=='kstych-data') | ||
| 2139 | { | ||
| 2140 | var vparts=omsg.ao_headers[6].s_value.split("|"); | ||
| 2141 | |||
| 2142 | vparts[1]=atob(vparts[1]); | ||
| 2143 | vparts[2]=atob(vparts[2]); | ||
| 2144 | |||
| 2145 | if(vparts[0]=="chat")incomingChat(vparts[1],vparts[2],vparts[3]); | ||
| 2146 | else if(vparts[0]=="presence")incomingPresense(vparts[1],vparts[2],vparts[3]); | ||
| 2147 | else if(vparts[0]=="wallreload")incomingwallReload(vparts[1],vparts[2],vparts[3]); | ||
| 2148 | else if(vparts[0]=="liveconf")incomingLiveconf(vparts[1],vparts[2],vparts[3]); | ||
| 2149 | else if(vparts[0]=="notify")incomingNotification(vparts[1],vparts[2],vparts[3]); | ||
| 2150 | else if(vparts[0]=="popupalert")incomingPopupAlert(vparts[1],vparts[2],vparts[3]); | ||
| 2151 | |||
| 2152 | else if(vparts[0]=="incomingCall")incomingCall(vparts[1],vparts[2],vparts[3]); | ||
| 2153 | else if(vparts[0]=="dialerUI")dialerUIUpdate(vparts[1],vparts[2],vparts[3]); | ||
| 2154 | |||
| 2155 | else if(vparts[0]=="adminCommand")adminCommand(vparts[1],vparts[2],vparts[3]); | ||
| 2156 | } | ||
| 2157 | //if(omsg.ao_headers.) | ||
| 2158 | //window.console.log(omsg.ao_headers[6]); | ||
| 2159 | } | ||
| 2160 | catch(e){} | ||
| 2161 | } |
application/public/assets/js/dialer.js
100755 → 100644
| 1 | // variable comes from env file: envCallback | ||
| 2 | |||
| 3 | var loggedin=0; | 1 | var loggedin=0; |
| 4 | 2 | ||
| 5 | var sTransferNumber; | 3 | var sTransferNumber; |
| ... | @@ -56,6 +54,7 @@ kstychCall['userstatus']=''; | ... | @@ -56,6 +54,7 @@ kstychCall['userstatus']=''; |
| 56 | kstychCall['usersubstatus']=''; | 54 | kstychCall['usersubstatus']=''; |
| 57 | kstychCall['usercallback']=''; | 55 | kstychCall['usercallback']=''; |
| 58 | kstychCall['userremarks']=''; | 56 | kstychCall['userremarks']=''; |
| 57 | kstychCall["attempt"]=''; | ||
| 59 | kstychCall['fullremark']=''; | 58 | kstychCall['fullremark']=''; |
| 60 | kstychCall['agentcomments']=''; | 59 | kstychCall['agentcomments']=''; |
| 61 | kstychCall['supcomntid']=''; | 60 | kstychCall['supcomntid']=''; |
| ... | @@ -280,9 +279,11 @@ function kCallAction(num,action) | ... | @@ -280,9 +279,11 @@ function kCallAction(num,action) |
| 280 | function dialerDispNumberClick() | 279 | function dialerDispNumberClick() |
| 281 | { | 280 | { |
| 282 | var lastnumber=$("#spandialer_num").html(); | 281 | var lastnumber=$("#spandialer_num").html(); |
| 282 | kstychCall['callWrapupTime']=300; | ||
| 283 | 283 | ||
| 284 | if(kstychCall['mCallState']=="Dispo") | 284 | if(kstychCall['mCallState']=="Dispo") |
| 285 | { | 285 | { |
| 286 | |||
| 286 | saveCloseDialerCall("REDIAL"); | 287 | saveCloseDialerCall("REDIAL"); |
| 287 | } | 288 | } |
| 288 | } | 289 | } |
| ... | @@ -425,7 +426,7 @@ function incomingPopupAlert(var1,var2,var3) | ... | @@ -425,7 +426,7 @@ function incomingPopupAlert(var1,var2,var3) |
| 425 | duration:1500, | 426 | duration:1500, |
| 426 | interval:500 | 427 | interval:500 |
| 427 | }); | 428 | }); |
| 428 | incomingbeepstart(); | 429 | //incomingbeepstart(); |
| 429 | kDesktopNotification("",var1,var2,1500); | 430 | kDesktopNotification("",var1,var2,1500); |
| 430 | } | 431 | } |
| 431 | 432 | ||
| ... | @@ -550,7 +551,7 @@ function saveCloseDialerCall(flag) | ... | @@ -550,7 +551,7 @@ function saveCloseDialerCall(flag) |
| 550 | kstychCall['userstatus']=$('#dialer_userstatus').val(); | 551 | kstychCall['userstatus']=$('#dialer_userstatus').val(); |
| 551 | kstychCall['usersubstatus']=$('#dialer_usersubstatus').val(); | 552 | kstychCall['usersubstatus']=$('#dialer_usersubstatus').val(); |
| 552 | kstychCall['usercallback']=$('#dialer_usercallback').val(); | 553 | kstychCall['usercallback']=$('#dialer_usercallback').val(); |
| 553 | 554 | kstychCall["attempt"]=$('#attempt').val();//attempt dropdown value insert | |
| 554 | 555 | ||
| 555 | //kstychCall['userremarks']=$('#dialer_userremarks').val(); | 556 | //kstychCall['userremarks']=$('#dialer_userremarks').val(); |
| 556 | //4000 character limit remark By PrashanT Jadhav | 557 | //4000 character limit remark By PrashanT Jadhav |
| ... | @@ -601,6 +602,7 @@ function saveCloseDialerCall(flag) | ... | @@ -601,6 +602,7 @@ function saveCloseDialerCall(flag) |
| 601 | kstychCall['usercallback']=""; | 602 | kstychCall['usercallback']=""; |
| 602 | kstychCall['userremarks']=""; | 603 | kstychCall['userremarks']=""; |
| 603 | kstychCall['userflag']=""; | 604 | kstychCall['userflag']=""; |
| 605 | kstychCall["attempt"]=""; | ||
| 604 | 606 | ||
| 605 | $('#dialer_usercallback').val(""); | 607 | $('#dialer_usercallback').val(""); |
| 606 | } | 608 | } |
| ... | @@ -1226,6 +1228,7 @@ function dialerTimersUpdate() | ... | @@ -1226,6 +1228,7 @@ function dialerTimersUpdate() |
| 1226 | } | 1228 | } |
| 1227 | else if(kstychCall['ts_Talk']>1) | 1229 | else if(kstychCall['ts_Talk']>1) |
| 1228 | { | 1230 | { |
| 1231 | kstychCall['callWrapupTime']=300; | ||
| 1229 | dispT="Talk : "+Math.ceil(((getNowTS()-kstychCall['ts_Talk'])/1000)); | 1232 | dispT="Talk : "+Math.ceil(((getNowTS()-kstychCall['ts_Talk'])/1000)); |
| 1230 | $("#spandialer_ts").html(dispT); | 1233 | $("#spandialer_ts").html(dispT); |
| 1231 | $("#dialertimes1").removeClass("btn-primary").addClass("btn-default"); | 1234 | $("#dialertimes1").removeClass("btn-primary").addClass("btn-default"); | ... | ... |
| ... | @@ -221,7 +221,10 @@ function waitKeyUpRun(varid,fncall,wttime) | ... | @@ -221,7 +221,10 @@ function waitKeyUpRun(varid,fncall,wttime) |
| 221 | function menuAction(menu) | 221 | function menuAction(menu) |
| 222 | { | 222 | { |
| 223 | $(".homemenu").removeClass("active"); | 223 | $(".homemenu").removeClass("active"); |
| 224 | doAjax(menu,'','content','ajax_'+menu,'singlethis','GET'); | 224 | if(menu=='rlp'){ |
| 225 | pbcode=$('#tcampaign_select').val(); | ||
| 226 | doAjax(menu+'?pbcode='+pbcode,'','content','ajax_'+menu,'singlethis','GET'); | ||
| 227 | }else doAjax(menu,'','content','ajax_'+menu,'singlethis','GET'); | ||
| 225 | 228 | ||
| 226 | var menuparts=menu.split("?"); | 229 | var menuparts=menu.split("?"); |
| 227 | if(menuparts[0]=='dashboard'){$("#mainmenuhome").addClass("active");$("#mmainmenuhome").addClass("active");} | 230 | if(menuparts[0]=='dashboard'){$("#mainmenuhome").addClass("active");$("#mmainmenuhome").addClass("active");} | ... | ... |
application/resources/views/layout/main_menu.blade.php
100755 → 100644
| ... | @@ -355,9 +355,9 @@ if($user->usertype=="Supervisor"||$user->usertype=="Admin") | ... | @@ -355,9 +355,9 @@ if($user->usertype=="Supervisor"||$user->usertype=="Admin") |
| 355 | <script> | 355 | <script> |
| 356 | function doSomething() { | 356 | function doSomething() { |
| 357 | 357 | ||
| 358 | doAjax("dialer/missedcallalert","","missedcalalertid","","","GET"); | 358 | doAjax("dialer/missedcallalert","","missedcalalertid","","","GET");// //doAjax("dialer/relationship?type=category&id="+id,"","relationshipCategory","","","GET"); |
| 359 | //doAjax("dialer/relationship?type=category&id="+id,"","relationshipCategory","","","GET"); | ||
| 360 | } | 359 | } |
| 361 | setInterval(doSomething, 60000); | 360 | setInterval(doSomething, 900000); |
| 361 | //setInterval(doSomething, 60000); | ||
| 362 | </script> | 362 | </script> |
| 363 | <?php } ?> | 363 | <?php } ?> | ... | ... |
application/public/assets/js/070817_dialer.js
→
application/resources/views/layout/module/dialer/dialer.js
100755 → 100644
| ... | @@ -54,6 +54,8 @@ kstychCall['userstatus']=''; | ... | @@ -54,6 +54,8 @@ kstychCall['userstatus']=''; |
| 54 | kstychCall['usersubstatus']=''; | 54 | kstychCall['usersubstatus']=''; |
| 55 | kstychCall['usercallback']=''; | 55 | kstychCall['usercallback']=''; |
| 56 | kstychCall['userremarks']=''; | 56 | kstychCall['userremarks']=''; |
| 57 | kstychCall["attempt"]=''; | ||
| 58 | kstychCall['fullremark']=''; | ||
| 57 | kstychCall['agentcomments']=''; | 59 | kstychCall['agentcomments']=''; |
| 58 | kstychCall['supcomntid']=''; | 60 | kstychCall['supcomntid']=''; |
| 59 | kstychCall['userdata']={}; | 61 | kstychCall['userdata']={}; |
| ... | @@ -183,6 +185,8 @@ function dialerQuickOpen(varid,num,state,substate,autorun) | ... | @@ -183,6 +185,8 @@ function dialerQuickOpen(varid,num,state,substate,autorun) |
| 183 | { | 185 | { |
| 184 | simpleNotification('error','topRight',"Already on call!"); | 186 | simpleNotification('error','topRight',"Already on call!"); |
| 185 | } | 187 | } |
| 188 | |||
| 189 | $("#dialerstate_btn").parent().attr("disabled",true); | ||
| 186 | } | 190 | } |
| 187 | function dialerAddAlt(i,varid) | 191 | function dialerAddAlt(i,varid) |
| 188 | { | 192 | { |
| ... | @@ -275,9 +279,11 @@ function kCallAction(num,action) | ... | @@ -275,9 +279,11 @@ function kCallAction(num,action) |
| 275 | function dialerDispNumberClick() | 279 | function dialerDispNumberClick() |
| 276 | { | 280 | { |
| 277 | var lastnumber=$("#spandialer_num").html(); | 281 | var lastnumber=$("#spandialer_num").html(); |
| 282 | kstychCall['callWrapupTime']=300; | ||
| 278 | 283 | ||
| 279 | if(kstychCall['mCallState']=="Dispo") | 284 | if(kstychCall['mCallState']=="Dispo") |
| 280 | { | 285 | { |
| 286 | |||
| 281 | saveCloseDialerCall("REDIAL"); | 287 | saveCloseDialerCall("REDIAL"); |
| 282 | } | 288 | } |
| 283 | } | 289 | } |
| ... | @@ -420,7 +426,7 @@ function incomingPopupAlert(var1,var2,var3) | ... | @@ -420,7 +426,7 @@ function incomingPopupAlert(var1,var2,var3) |
| 420 | duration:1500, | 426 | duration:1500, |
| 421 | interval:500 | 427 | interval:500 |
| 422 | }); | 428 | }); |
| 423 | 429 | //incomingbeepstart(); | |
| 424 | kDesktopNotification("",var1,var2,1500); | 430 | kDesktopNotification("",var1,var2,1500); |
| 425 | } | 431 | } |
| 426 | 432 | ||
| ... | @@ -428,15 +434,17 @@ function outgoingCall() | ... | @@ -428,15 +434,17 @@ function outgoingCall() |
| 428 | { | 434 | { |
| 429 | $("#dialersearchresults").html(""); | 435 | $("#dialersearchresults").html(""); |
| 430 | kSetDData('C','callnumber',$("#manualdialnumber_txt").val()); | 436 | kSetDData('C','callnumber',$("#manualdialnumber_txt").val()); |
| 431 | 437 | //console.log("kstychcall--"+JSON.stringify(kstychCall)); | |
| 432 | var datastr="kstychCall="+JSON.stringify(kstychCall); | 438 | var datastr="kstychCall="+JSON.stringify(kstychCall); |
| 433 | datastr+="&kstychDialer="+JSON.stringify(kstychDialer); | 439 | datastr+="&kstychDialer="+JSON.stringify(kstychDialer); |
| 434 | 440 | ||
| 441 | var client = $('#tcampaign_select').val(); | ||
| 442 | |||
| 435 | if(kstychDialer['mDialerState']=="Manual") | 443 | if(kstychDialer['mDialerState']=="Manual") |
| 436 | { | 444 | { |
| 437 | if(kstychCall['callnumber']!="") | 445 | if(kstychCall['callnumber']!="") |
| 438 | { | 446 | { |
| 439 | doAjax('dialer?action=newcall',datastr,'dialersearchresults', 'ajax_manualdial','singlefail','POST', function(retstr){ | 447 | doAjax('dialer?action=newcall&client='+client,datastr,'dialersearchresults', 'ajax_manualdial','singlefail','POST', function(retstr){ |
| 440 | if(kstychCall['crmid']!="") | 448 | if(kstychCall['crmid']!="") |
| 441 | { | 449 | { |
| 442 | kSetDData('C','mCallState','Call'); | 450 | kSetDData('C','mCallState','Call'); |
| ... | @@ -462,7 +470,7 @@ function outgoingCall() | ... | @@ -462,7 +470,7 @@ function outgoingCall() |
| 462 | } | 470 | } |
| 463 | if(kstychDialer['mDialerState']=="DialNext") | 471 | if(kstychDialer['mDialerState']=="DialNext") |
| 464 | { | 472 | { |
| 465 | doAjax('dialer?action=newcall',datastr,'dialersearchresults', 'ajax_manualdial','singlefail','POST', function(retstr){ | 473 | doAjax('dialer?action=newcall&client='+client,datastr,'dialersearchresults', 'ajax_manualdial','singlefail','POST', function(retstr){ |
| 466 | if(kstychCall['crmid']!="") | 474 | if(kstychCall['crmid']!="") |
| 467 | { | 475 | { |
| 468 | kSetDData('C','mCallState','Call'); | 476 | kSetDData('C','mCallState','Call'); |
| ... | @@ -481,7 +489,7 @@ function outgoingCall() | ... | @@ -481,7 +489,7 @@ function outgoingCall() |
| 481 | } | 489 | } |
| 482 | if(kstychDialer['mDialerState']=="Progressive") | 490 | if(kstychDialer['mDialerState']=="Progressive") |
| 483 | { | 491 | { |
| 484 | doAjax('dialer?action=newcall',datastr,'dialersearchresults', 'ajax_manualdial','singlefail','POST', function(retstr){ | 492 | doAjax('dialer?action=newcall&client='+client,datastr,'dialersearchresults', 'ajax_manualdial','singlefail','POST', function(retstr){ |
| 485 | if(kstychCall['crmid']!="") | 493 | if(kstychCall['crmid']!="") |
| 486 | { | 494 | { |
| 487 | kSetDData('C','mCallState','Call'); | 495 | kSetDData('C','mCallState','Call'); |
| ... | @@ -543,9 +551,15 @@ function saveCloseDialerCall(flag) | ... | @@ -543,9 +551,15 @@ function saveCloseDialerCall(flag) |
| 543 | kstychCall['userstatus']=$('#dialer_userstatus').val(); | 551 | kstychCall['userstatus']=$('#dialer_userstatus').val(); |
| 544 | kstychCall['usersubstatus']=$('#dialer_usersubstatus').val(); | 552 | kstychCall['usersubstatus']=$('#dialer_usersubstatus').val(); |
| 545 | kstychCall['usercallback']=$('#dialer_usercallback').val(); | 553 | kstychCall['usercallback']=$('#dialer_usercallback').val(); |
| 546 | kstychCall['userremarks']=$('#dialer_userremarks').val(); | 554 | kstychCall["attempt"]=$('#attempt').val();//attempt dropdown value insert |
| 555 | |||
| 556 | //kstychCall['userremarks']=$('#dialer_userremarks').val(); | ||
| 557 | //4000 character limit remark By PrashanT Jadhav | ||
| 558 | kstychCall['fullremark']=$('#dialer_fullremarks').val(); | ||
| 559 | |||
| 547 | kstychCall['userflag']=$('#dialer_flag').val(); | 560 | kstychCall['userflag']=$('#dialer_flag').val(); |
| 548 | kstychCall['priority']=$('#priority').val(); | 561 | kstychCall['priority']=$('#priority').val(); |
| 562 | |||
| 549 | 563 | ||
| 550 | kstychCall['bttc_day']=$('#bttc_day').val(); | 564 | kstychCall['bttc_day']=$('#bttc_day').val(); |
| 551 | kstychCall['bttc_hrs']=$('#bttc_hrs').val(); | 565 | kstychCall['bttc_hrs']=$('#bttc_hrs').val(); |
| ... | @@ -557,6 +571,7 @@ function saveCloseDialerCall(flag) | ... | @@ -557,6 +571,7 @@ function saveCloseDialerCall(flag) |
| 557 | //Supervisor Call Management Value - By Manish on 16-02-17 | 571 | //Supervisor Call Management Value - By Manish on 16-02-17 |
| 558 | kstychCall['agentcomments']=$('#agent_comment').val(); | 572 | kstychCall['agentcomments']=$('#agent_comment').val(); |
| 559 | kstychCall['supcomntid']=$('#sup_comnt_id').val(); | 573 | kstychCall['supcomntid']=$('#sup_comnt_id').val(); |
| 574 | var client = $('#tcampaign_select').val(); | ||
| 560 | 575 | ||
| 561 | if(typeof customerDispofields != 'undefined')kstychCall['userdata']=customerDispofields; | 576 | if(typeof customerDispofields != 'undefined')kstychCall['userdata']=customerDispofields; |
| 562 | 577 | ||
| ... | @@ -651,6 +666,7 @@ function saveCloseDialerCall(flag) | ... | @@ -651,6 +666,7 @@ function saveCloseDialerCall(flag) |
| 651 | 666 | ||
| 652 | var datastr="kstychCall="+JSON.stringify(kstychCall); | 667 | var datastr="kstychCall="+JSON.stringify(kstychCall); |
| 653 | datastr+="&kstychDialer="+JSON.stringify(kstychDialer); | 668 | datastr+="&kstychDialer="+JSON.stringify(kstychDialer); |
| 669 | //console.log("datastr----"+datastr); | ||
| 654 | doAjax('dialer?action=closecall',datastr,'', 'ajax_manualdial','singlefail','POST', | 670 | doAjax('dialer?action=closecall',datastr,'', 'ajax_manualdial','singlefail','POST', |
| 655 | function(retstr){ | 671 | function(retstr){ |
| 656 | kSetDData('C','mCallState',"Close"); | 672 | kSetDData('C','mCallState',"Close"); |
| ... | @@ -778,8 +794,8 @@ function resetDialer() | ... | @@ -778,8 +794,8 @@ function resetDialer() |
| 778 | var dialerResetForceState=kstychDialer['mDialerState']; | 794 | var dialerResetForceState=kstychDialer['mDialerState']; |
| 779 | var dialerResetForceSubState=kstychDialer['mDialerSubState']; | 795 | var dialerResetForceSubState=kstychDialer['mDialerSubState']; |
| 780 | 796 | ||
| 781 | //dialerResetForceState="Progressive";//Hardcoded TODO change to config | 797 | dialerResetForceState="Progressive";//Hardcoded TODO change to config |
| 782 | //dialerResetForceSubState=""; | 798 | dialerResetForceSubState=""; |
| 783 | 799 | ||
| 784 | if(kstychCall['userstatus']=="AUTOWRAPUP") | 800 | if(kstychCall['userstatus']=="AUTOWRAPUP") |
| 785 | { | 801 | { |
| ... | @@ -871,7 +887,9 @@ function updateDialerState(objstr,key,val,key2,val2) | ... | @@ -871,7 +887,9 @@ function updateDialerState(objstr,key,val,key2,val2) |
| 871 | 887 | ||
| 872 | var datastr="kstychCall="+JSON.stringify(kstychCall); | 888 | var datastr="kstychCall="+JSON.stringify(kstychCall); |
| 873 | datastr+="&kstychDialer="+JSON.stringify(kstychDialer); | 889 | datastr+="&kstychDialer="+JSON.stringify(kstychDialer); |
| 874 | doAjax('dialer?action=dialerstate',datastr,'', 'ajax_manualdial','singlefail','POST', | 890 | var client = $('#tcampaign_select').val(); |
| 891 | |||
| 892 | doAjax('dialer?action=dialerstate&client='+client,datastr,'', 'ajax_manualdial','singlefail','POST', | ||
| 875 | function(retstr){ | 893 | function(retstr){ |
| 876 | 894 | ||
| 877 | // if(val=="Progressive"||(kstychCall['previewcrmid']!=""&&kstychCall['previewcrmid']>0)) | 895 | // if(val=="Progressive"||(kstychCall['previewcrmid']!=""&&kstychCall['previewcrmid']>0)) |
| ... | @@ -911,7 +929,7 @@ function updateDialerState(objstr,key,val,key2,val2) | ... | @@ -911,7 +929,7 @@ function updateDialerState(objstr,key,val,key2,val2) |
| 911 | 929 | ||
| 912 | if(val=="Progressive"||(kstychCall['previewcrmid']!=""&&kstychCall['previewcrmid']>0)) | 930 | if(val=="Progressive"||(kstychCall['previewcrmid']!=""&&kstychCall['previewcrmid']>0)) |
| 913 | { | 931 | { |
| 914 | doAjax('dialer?action=previewnext',datastr,'dialersearchresults', 'ajax_manualdial2','singlefail','POST', | 932 | doAjax('dialer?action=previewnext&client='+client,datastr,'dialersearchresults', 'ajax_manualdial2','singlefail','POST', |
| 915 | function(retstr){ | 933 | function(retstr){ |
| 916 | if(kstychCall['previewcrmid']!="") | 934 | if(kstychCall['previewcrmid']!="") |
| 917 | { | 935 | { |
| ... | @@ -1124,7 +1142,7 @@ function updateDialerUI() | ... | @@ -1124,7 +1142,7 @@ function updateDialerUI() |
| 1124 | ////////////////////////////////////////////////////////////// | 1142 | ////////////////////////////////////////////////////////////// |
| 1125 | if(kstychCall['mCallState']=="Wait") | 1143 | if(kstychCall['mCallState']=="Wait") |
| 1126 | { | 1144 | { |
| 1127 | $("#dialerstate_btn").parent().attr("disabled",false); | 1145 | if(kstychDialer['mDialerState']!="Manual"){$("#dialerstate_btn").parent().attr("disabled",false)}; |
| 1128 | if(kstychDialer['mmanualallow']=='Yes')$("#manualdialnumber_txt").attr("disabled",false); | 1146 | if(kstychDialer['mmanualallow']=='Yes')$("#manualdialnumber_txt").attr("disabled",false); |
| 1129 | else $("#manualdialnumber_txt").attr("disabled",true); | 1147 | else $("#manualdialnumber_txt").attr("disabled",true); |
| 1130 | 1148 | ||
| ... | @@ -1209,6 +1227,7 @@ function dialerTimersUpdate() | ... | @@ -1209,6 +1227,7 @@ function dialerTimersUpdate() |
| 1209 | } | 1227 | } |
| 1210 | else if(kstychCall['ts_Talk']>1) | 1228 | else if(kstychCall['ts_Talk']>1) |
| 1211 | { | 1229 | { |
| 1230 | kstychCall['callWrapupTime']=300; | ||
| 1212 | dispT="Talk : "+Math.ceil(((getNowTS()-kstychCall['ts_Talk'])/1000)); | 1231 | dispT="Talk : "+Math.ceil(((getNowTS()-kstychCall['ts_Talk'])/1000)); |
| 1213 | $("#spandialer_ts").html(dispT); | 1232 | $("#spandialer_ts").html(dispT); |
| 1214 | $("#dialertimes1").removeClass("btn-primary").addClass("btn-default"); | 1233 | $("#dialertimes1").removeClass("btn-primary").addClass("btn-default"); |
| ... | @@ -1640,7 +1659,14 @@ function stopRingbackTone() { | ... | @@ -1640,7 +1659,14 @@ function stopRingbackTone() { |
| 1640 | try { ringbacktone.pause(); } | 1659 | try { ringbacktone.pause(); } |
| 1641 | catch (e) { } | 1660 | catch (e) { } |
| 1642 | } | 1661 | } |
| 1643 | 1662 | function incomingbeepstart() { | |
| 1663 | try { incomingbeep.play(); } | ||
| 1664 | catch (e) { } | ||
| 1665 | } | ||
| 1666 | function incomingbeepstop() { | ||
| 1667 | try { incomingbeep.pause(); } | ||
| 1668 | catch (e) { } | ||
| 1669 | } | ||
| 1644 | function toggleFullScreen() { | 1670 | function toggleFullScreen() { |
| 1645 | if (videoRemote.webkitSupportsFullscreen) { | 1671 | if (videoRemote.webkitSupportsFullscreen) { |
| 1646 | fullScreen(!videoRemote.webkitDisplayingFullscreen); | 1672 | fullScreen(!videoRemote.webkitDisplayingFullscreen); | ... | ... |
| ... | @@ -7,40 +7,49 @@ use App\Models\SupervisonComments; | ... | @@ -7,40 +7,49 @@ use App\Models\SupervisonComments; |
| 7 | $wakka = new KHRMSLib(); | 7 | $wakka = new KHRMSLib(); |
| 8 | $dashboarduser=Auth::user(); | 8 | $dashboarduser=Auth::user(); |
| 9 | 9 | ||
| 10 | $agents=array(); | 10 | //$agents=array(); |
| 11 | $sup_status=""; | ||
| 11 | if(isset($_GET['logdate']))$logdate=strtotime($_GET['logdate']." 00:00:00"); | 12 | if(isset($_GET['logdate']))$logdate=strtotime($_GET['logdate']." 00:00:00"); |
| 12 | else $logdate=strtotime(date('Y-m-d')." 00:00:00"); | 13 | else $logdate=strtotime(date('Y-m-d')." 00:00:00"); |
| 13 | 14 | ||
| 14 | if(isset($_GET['logtodate']))$logtodate=strtotime($_GET['logtodate']." 23:59:59"); | 15 | if(isset($_GET['logtodate']))$logtodate=strtotime($_GET['logtodate']." 23:59:59"); |
| 15 | else $logtodate=strtotime(date('Y-m-d')." 23:59:59"); | 16 | else $logtodate=strtotime(date('Y-m-d')." 23:59:59"); |
| 16 | 17 | ||
| 17 | 18 | if(isset($_GET['agents'])) $agents=$_GET['agents']; | |
| 18 | |||
| 19 | if(isset($_GET['agents'])) | ||
| 20 | { | ||
| 21 | $agents[]=$_GET['agents']; | ||
| 22 | |||
| 23 | |||
| 24 | } | ||
| 25 | else $agents=""; | 19 | else $agents=""; |
| 26 | 20 | ||
| 21 | if(isset($_GET['sup_status'])) $sup_status=$_GET['sup_status']; | ||
| 22 | else $sup_status=""; | ||
| 27 | 23 | ||
| 28 | 24 | ||
| 29 | 25 | /*$pb_code=implode(",",$agents); | |
| 30 | /*$pb_code=implode(",",$agents); | ||
| 31 | echo "-----".$$pb_code;*/ | 26 | echo "-----".$$pb_code;*/ |
| 32 | 27 | ||
| 33 | $userarr=array();$i=1; | 28 | $userarr=array();$i=1; |
| 34 | $reporthead=array("id","date","pb_name","pb_code","pb_code","pb_landline_contact_no","supervisor_mail_id","group_id","group_id_name","cust_id","cust_name","relationship_with_group_id","cust_id_next","cust_name_next","relationship_with_group_id_next","new_group_addition_to_group","racing_from","supervisor_status","Submit"); | 29 | $reportarray=array(); |
| 30 | $reporthead=array("id","date","pb_name","pb_code","pb_code","pb_landline_contact_no","supervisor_mail_id","group_id","group_id_name","cust_id","cust_name","relationship_with_group_id","cust_id_next","cust_name_next","relationship_with_group_id_next","new_group_addition_to_group","racing_from","supervisor_status","supervisor_update","Submit"); | ||
| 35 | 31 | ||
| 36 | if(isset($_GET['agents'])){ | 32 | if($agents=="" && $sup_status=="") |
| 37 | print_r($agents); | 33 | { |
| 38 | $reportarray=DB::table('potentialcustomer_details')->select('*')->where('date','>=',date("Y-m-d H:i:s",$logdate))->where('date','<=',date("Y-m-d H:i:s",$logtodate))->whereIn('pb_code',$agents)->get(); | ||
| 39 | 34 | ||
| 40 | }else{ | 35 | $reportarray=DB::table('potentialcustomer_details')->select('*')->where('date','>=',date("Y-m-d H:i:s",$logdate))->where('date','<=',date("Y-m-d H:i:s",$logtodate))->get(); |
| 36 | |||
| 37 | }else if($agents!="" && $sup_status==""){ | ||
| 38 | |||
| 39 | $reportarray=DB::table('potentialcustomer_details')->select('*')->where('date','>=',date("Y-m-d H:i:s",$logdate))->where('date','<=',date("Y-m-d H:i:s",$logtodate))->where('pb_code','=',$agents)->get(); | ||
| 40 | |||
| 41 | }else if($agents=="" && $sup_status!="") | ||
| 42 | { | ||
| 43 | |||
| 44 | /* $reportarray=DB::table('potentialcustomer_details')->select('*')->where('date','>=','"'.date("Y-m-d H:i:s",$logdate).'"')->where('date','<=','"'.date("Y-m-d H:i:s",$logtodate).'"')->where('supervisor_statu','=','"'.$sup_status.'"')->get();*/ | ||
| 45 | |||
| 46 | $reportarray = DB::select(DB::raw("SELECT * FROM potentialcustomer_details where date >='".date("Y-m-d H:i:s",$logdate)."' and date <= '".date("Y-m-d H:i:s",$logtodate)."' and supervisor_status='".$sup_status."' ")); | ||
| 41 | 47 | ||
| 42 | $reportarray=DB::table('potentialcustomer_details')->select('*')->where('date','>=',date("Y-m-d H:i:s",$logdate))->where('date','<=',date("Y-m-d H:i:s",$logtodate))->get(); | 48 | |
| 49 | }else{ | ||
| 50 | /*$reportarray=DB::table('potentialcustomer_details')->select('*')->where('date','>=',date("Y-m-d H:i:s",$logdate))->where('date','<=',date("Y-m-d H:i:s",$logtodate))->where('pb_code','=',$agents)->where('supervisor_status','=','"'.$sup_status.'"')->get();*/ | ||
| 43 | 51 | ||
| 52 | $reportarray = DB::select(DB::raw("SELECT * FROM potentialcustomer_details where date >='".date("Y-m-d H:i:s",$logdate)."' and date <= '".date("Y-m-d H:i:s",$logtodate)."' and pb_code = '".$agents."' and supervisor_status='".$sup_status."' ")); | ||
| 44 | } | 53 | } |
| 45 | 54 | ||
| 46 | //echo $reportarray;die(); | 55 | //echo $reportarray;die(); |
| ... | @@ -103,6 +112,7 @@ if(Input::has("dllogxls")) | ... | @@ -103,6 +112,7 @@ if(Input::has("dllogxls")) |
| 103 | } | 112 | } |
| 104 | //echo "<pre><br>".print_r($reportarray)."</pre>"; | 113 | //echo "<pre><br>".print_r($reportarray)."</pre>"; |
| 105 | $highestColumn = sizeof($reporthead); | 114 | $highestColumn = sizeof($reporthead); |
| 115 | $supervisorstatus=""; | ||
| 106 | //echo $highestColumn; | 116 | //echo $highestColumn; |
| 107 | if(count($reportarray)) { | 117 | if(count($reportarray)) { |
| 108 | $outhead="<tr>";$outstr="";$id=""; | 118 | $outhead="<tr>";$outstr="";$id=""; |
| ... | @@ -114,6 +124,7 @@ if(count($reportarray)) { | ... | @@ -114,6 +124,7 @@ if(count($reportarray)) { |
| 114 | 124 | ||
| 115 | foreach($reportarray as $uid=>$uarr) | 125 | foreach($reportarray as $uid=>$uarr) |
| 116 | { | 126 | { |
| 127 | |||
| 117 | 128 | ||
| 118 | $outstr.="<tr>"; | 129 | $outstr.="<tr>"; |
| 119 | for ($head = 0; $head < $highestColumn; $head++){ | 130 | for ($head = 0; $head < $highestColumn; $head++){ |
| ... | @@ -123,8 +134,11 @@ if(count($reportarray)) { | ... | @@ -123,8 +134,11 @@ if(count($reportarray)) { |
| 123 | if($reporthead[$head]=="id"){ | 134 | if($reporthead[$head]=="id"){ |
| 124 | $id=$uarr->$reporthead[$head]; | 135 | $id=$uarr->$reporthead[$head]; |
| 125 | } | 136 | } |
| 137 | |||
| 138 | |||
| 126 | if($reporthead[$head]=="supervisor_status"){ | 139 | if($reporthead[$head]=="supervisor_status"){ |
| 127 | $outstr.="<td><select id='".$id."_action_taken'><option value='Pending'>Pending</option><option value='Action Taken'>Action Taken</option><option value='Rejected'>Rejected</option></select></td>"; | 140 | $supervisorstatus=$uarr->$reporthead[$head]; |
| 141 | $outstr.="<td><select id='".$id."_action_taken'><option value=".$supervisorstatus.">".$supervisorstatus."</option><option value='Pending'>Pending</option><option value='Action Taken'>Action Taken</option><option value='Rejected'>Rejected</option></select></td>"; | ||
| 128 | }else if($reporthead[$head]=="Submit"){ | 142 | }else if($reporthead[$head]=="Submit"){ |
| 129 | $outstr.="<td><input type='button' id='".$id."_save' value='Save' onclick='updatesupervisorfeedback($id);'></td>"; | 143 | $outstr.="<td><input type='button' id='".$id."_save' value='Save' onclick='updatesupervisorfeedback($id);'></td>"; |
| 130 | }else { | 144 | }else { |
| ... | @@ -180,21 +194,28 @@ $(document).ready(function() | ... | @@ -180,21 +194,28 @@ $(document).ready(function() |
| 180 | 194 | ||
| 181 | Date:From <input size=10 id='modfrom' name='modfrom' type='text' value='<?php echo date("Y-m-d",$logdate); ?>' onchange='statusLogReloadFun("");'/> | 195 | Date:From <input size=10 id='modfrom' name='modfrom' type='text' value='<?php echo date("Y-m-d",$logdate); ?>' onchange='statusLogReloadFun("");'/> |
| 182 | To<input size=10 id='modto' name='modto' type='text' value='<?php echo date("Y-m-d",$logtodate); ?>' onchange='statusLogReloadFun("");'/> | 196 | To<input size=10 id='modto' name='modto' type='text' value='<?php echo date("Y-m-d",$logtodate); ?>' onchange='statusLogReloadFun("");'/> |
| 183 | <!--PB Code: | 197 | PB Code: |
| 184 | <select id='usrname' class=select2multi multiple="" style="width: 30%;" > --> | 198 | <select id='usrname' class=select2multi style="width: 20%;" > |
| 185 | <?php | 199 | <?php |
| 186 | /*$companyarr=$wakka->LoadAll("select * from hrms_masters where mtype='company'"); | 200 | $companyarr=$wakka->LoadAll("select * from hrms_masters where mtype='company'"); |
| 187 | foreach($companyarr as $tcompany) | 201 | foreach($companyarr as $tcompany) |
| 188 | { | 202 | { |
| 189 | $seltxt=''; | 203 | $seltxt=''; |
| 190 | if(strstr(",".$clientslist.",",",$tcompany[mkey],"))$seltxt='selected="selected"'; | 204 | if(strstr(",".$clientslist.",",",$tcompany[mkey],"))$seltxt='selected="selected"'; |
| 191 | echo "<option value='$tcompany[mkey]' $seltxt>$tcompany[mkey]</option>"; | 205 | echo "<option value='$agents'>$agents</option> <option value='$tcompany[mkey]' $seltxt>$tcompany[mkey]</option>"; |
| 192 | }*/ | 206 | } |
| 193 | ?> | 207 | ?> |
| 194 | 208 | ||
| 195 | <!-- </select> | 209 | </select> |
| 210 | Supervisor Status:<select class=select2multi id='sup_status' style="width: 20%;"> | ||
| 211 | <option value=''></option> | ||
| 212 | <option value='Pending'>Pending</option> | ||
| 213 | <option value='Action Taken'>Action Taken</option> | ||
| 214 | <option value='Rejected'>Rejected</option> | ||
| 215 | </select> | ||
| 216 | |||
| 196 | 217 | ||
| 197 | <button class="pull-right btn btn-sm btn-default" onclick='statusLogReloadFun("");return false;' title='Search' style='margin-top:-1px'><i class='fa fa-search'></i>Search</button> --> | 218 | <button class="pull-right btn btn-sm btn-default" onclick='statusLogReloadFun("");return false;' title='Search' style='margin-top:-1px'><i class='fa fa-search'></i>Search</button> |
| 198 | 219 | ||
| 199 | </div> | 220 | </div> |
| 200 | 221 | ||
| ... | @@ -209,28 +230,43 @@ Date:From <input size=10 id='modfrom' name='modfrom' type='text' value='<?php ec | ... | @@ -209,28 +230,43 @@ Date:From <input size=10 id='modfrom' name='modfrom' type='text' value='<?php ec |
| 209 | <div id=dialoglog></div> | 230 | <div id=dialoglog></div> |
| 210 | </div> | 231 | </div> |
| 211 | <script> | 232 | <script> |
| 233 | |||
| 212 | function dlAgentlogXls() | 234 | function dlAgentlogXls() |
| 213 | { | 235 | { |
| 214 | window.open('dialer/raicingcustomerreport?dllogxls=1&logdate='+$("#modfrom").val()+'&logtodate='+$("#modto").val());return false; | 236 | var agents=$('#usrname').val(); |
| 237 | var sup_status=$('#sup_status').val(); | ||
| 238 | if(agents=="" && sup_status=="" ){ | ||
| 239 | window.open('dialer/raicingcustomerreport?dllogxls=1&logdate='+$("#modfrom").val()+'&logtodate='+$("#modto").val());return false; | ||
| 240 | }else if(sup_status=="" && agents!=""){ | ||
| 241 | window.open('dialer/raicingcustomerreport?dllogxls=1&logdate='+$("#modfrom").val()+'&logtodate='+$("#modto").val()+'&agents='+agents);return false; | ||
| 242 | }else if(sup_status!="" && agents==""){ | ||
| 243 | window.open('dialer/raicingcustomerreport?dllogxls=1&logdate='+$("#modfrom").val()+'&logtodate='+$("#modto").val()+'&sup_status='+sup_status);return false; | ||
| 244 | }else{ | ||
| 245 | window.open('dialer/raicingcustomerreport?dllogxls=1&logdate='+$("#modfrom").val()+'&logtodate='+$("#modto").val()+'&agents='+agents+'&sup_status='+sup_status);return false; | ||
| 246 | } | ||
| 247 | |||
| 215 | } | 248 | } |
| 216 | function dataString() | 249 | function dataString() |
| 217 | { | 250 | { |
| 218 | /*var agents=$('#usrname').val(); | 251 | |
| 219 | var agentsval=[]; | 252 | var agents=$('#usrname').val(); |
| 253 | var sup_status=$('#sup_status').val(); | ||
| 254 | |||
| 255 | if(agents=="" && sup_status=="" ) | ||
| 256 | { | ||
| 257 | return 'logdate='+$("#modfrom").val()+'&logtodate='+$("#modto").val() | ||
| 258 | } | ||
| 259 | else if(sup_status=="" && agents!="") | ||
| 260 | { | ||
| 261 | return 'logdate='+$("#modfrom").val()+'&logtodate='+$("#modto").val()+'&agents='+agents; | ||
| 262 | }else if(sup_status!="" && agents==""){ | ||
| 263 | return 'logdate='+$("#modfrom").val()+'&logtodate='+$("#modto").val()+'&sup_status='+sup_status; | ||
| 264 | } | ||
| 265 | else | ||
| 266 | { | ||
| 267 | return 'logdate='+$("#modfrom").val()+'&logtodate='+$("#modto").val()+'&agents='+agents+'&sup_status='+sup_status; | ||
| 268 | } | ||
| 220 | 269 | ||
| 221 | if(agents=="" || agents==null){ | ||
| 222 | |||
| 223 | }else | ||
| 224 | { | ||
| 225 | for(i=0;i<agents.length;i++) | ||
| 226 | { | ||
| 227 | agentsval[i] = "'" + String(agents[i]) + "'"; | ||
| 228 | } | ||
| 229 | agentsval=agentsval.join(","); | ||
| 230 | |||
| 231 | return 'logdate='+$("#modfrom").val()+'&logdateto='+$("#modto").val()+'&agents='+agentsval; | ||
| 232 | }*/ | ||
| 233 | return 'logdate='+$("#modfrom").val()+'&logdateto='+$("#modto").val(); | ||
| 234 | } | 270 | } |
| 235 | function statusLogReloadFun(sortby) | 271 | function statusLogReloadFun(sortby) |
| 236 | { | 272 | { | ... | ... |
| ... | @@ -5,27 +5,27 @@ $dashboarduser=Auth::user(); | ... | @@ -5,27 +5,27 @@ $dashboarduser=Auth::user(); |
| 5 | $i=0; | 5 | $i=0; |
| 6 | 6 | ||
| 7 | if($dashboarduser->usertype != 'Admin'){ | 7 | if($dashboarduser->usertype != 'Admin'){ |
| 8 | $allusers=User::where(function ($query) use($dashboarduser) { | 8 | $allusers=User::where(function ($query) use($dashboarduser) { |
| 9 | $query->where('supervisor','=',$dashboarduser->username) | 9 | $query->where('supervisor','=',$dashboarduser->username) |
| 10 | ->orWhere('lteam2','=',$dashboarduser->username) | 10 | ->orWhere('lteam2','=',$dashboarduser->username) |
| 11 | ->orWhere('lteam','=',$dashboarduser->username); | 11 | ->orWhere('lteam','=',$dashboarduser->username); |
| 12 | })->get(); | 12 | })->get(); |
| 13 | } | 13 | } |
| 14 | else | 14 | else |
| 15 | { | 15 | { |
| 16 | $allusers=DB::table('users')->select('*')->get(); | 16 | $allusers=DB::table('users')->select('*')->get(); |
| 17 | } | 17 | } |
| 18 | 18 | ||
| 19 | foreach($allusers as $user){ | 19 | foreach($allusers as $user){ |
| 20 | 20 | ||
| 21 | echo ""; | 21 | echo ""; |
| 22 | 22 | ||
| 23 | $outstr.="<tr><td>".$i++."</td> | 23 | $outstr.="<tr><td>".$i++."</td> |
| 24 | <td>".$user->username."</td> | 24 | <td>".$user->username."</td> |
| 25 | <td>".$user->fullname."</td> | 25 | <td>".$user->fullname."</td> |
| 26 | <td>".$user->dialmode_assign."</td> | 26 | <td>".$user->dialmode_assign."</td> |
| 27 | 27 | ||
| 28 | </tr>"; | 28 | </tr>"; |
| 29 | } | 29 | } |
| 30 | ?> | 30 | ?> |
| 31 | 31 | ||
| ... | @@ -40,64 +40,64 @@ foreach($allusers as $user){ | ... | @@ -40,64 +40,64 @@ foreach($allusers as $user){ |
| 40 | 40 | ||
| 41 | <br> | 41 | <br> |
| 42 | <div class='container'> | 42 | <div class='container'> |
| 43 | 43 | ||
| 44 | <select id='dialmodeassign' class=select2multi multiple="" style="width: 30%;"> | 44 | <select id='dialmodeassign' class=select2multi multiple="" style="width: 30%;"> |
| 45 | <option value="Progressive">Progressive</option> | 45 | <option value="Progressive">Progressive</option> |
| 46 | <option value="Manual">Manual</option> | 46 | <option value="Manual">Manual</option> |
| 47 | <option value="Incoming">Incoming</option> | 47 | <option value="Incoming">Incoming</option> |
| 48 | </select> | 48 | </select> |
| 49 | 49 | ||
| 50 | <select id='username' class=select2multi multiple="" style="width: 30%;"> | 50 | <select id='username' class=select2multi multiple="" style="width: 30%;"> |
| 51 | <option value></option> | 51 | <option value></option> |
| 52 | <?php foreach($username as $user){;echo "<option value='$user'>$user</option>";} ?> | 52 | <?php foreach($username as $user){;echo "<option value='$user'>$user</option>";} ?> |
| 53 | </select> | 53 | </select> |
| 54 | </div> | 54 | </div> |
| 55 | <br> | 55 | <br> |
| 56 | <div class='container'> | 56 | <div class='container'> |
| 57 | <button type="button" class="btn btn-warning" id='assignmode' style=' margin: 15px 0 5px 770px;'> | 57 | <button type="button" class="btn btn-warning" id='assignmode' style=' margin: 15px 0 5px 770px;'> |
| 58 | <span class="glyphicon glyphicon-send"></span> Assign Dialing Mode | 58 | <span class="glyphicon glyphicon-send"></span> Assign Dialing Mode |
| 59 | </button> | 59 | </button> |
| 60 | </div> | 60 | </div> |
| 61 | </div> | 61 | </div> |
| 62 | <div style='overflow:auto'> | 62 | <div style='overflow:auto'> |
| 63 | <table id=logtable class='footable table table-striped table-bordered table-white table-primary footable-loaded' style='font-size:12px'> | 63 | <table id=logtable class='footable table table-striped table-bordered table-white table-primary footable-loaded' style='font-size:12px'> |
| 64 | <thead> | 64 | <thead> |
| 65 | <tr> | 65 | <tr> |
| 66 | <th>#</th> | 66 | <th>#</th> |
| 67 | <th>User Id</th> | 67 | <th>User Id</th> |
| 68 | <th>Name</th> | 68 | <th>Name</th> |
| 69 | <th>Assign Mode</th> | 69 | <th>Assign Mode</th> |
| 70 | 70 | ||
| 71 | </tr> | 71 | </tr> |
| 72 | </thead> | 72 | </thead> |
| 73 | <?php echo $outstr; ?> | 73 | <?php echo $outstr; ?> |
| 74 | </table> | 74 | </table> |
| 75 | </div> | 75 | </div> |
| 76 | </div> | 76 | </div> |
| 77 | </div> | 77 | </div> |
| 78 | </div> | 78 | </div> |
| 79 | <script> | 79 | <script> |
| 80 | $('#assignmode').click(function() | 80 | $('#assignmode').click(function() |
| 81 | { | 81 | { |
| 82 | var agents = $('#username').val(); | 82 | var agents = $('#username').val(); |
| 83 | var dialmodeassign = $('#dialmodeassign').val(); | 83 | var dialmodeassign = $('#dialmodeassign').val(); |
| 84 | 84 | ||
| 85 | if(agents&&dialmodeassign) | 85 | if(agents&&dialmodeassign) |
| 86 | { | 86 | { |
| 87 | var postdata='agents='+agents; | 87 | var postdata='agents='+agents; |
| 88 | postdata+='&dialmodeassign='+dialmodeassign; | 88 | postdata+='&dialmodeassign='+dialmodeassign; |
| 89 | doAjax('dialmodeassign',postdata,'','','singlethis','POST',function(retrstr){ | 89 | doAjax('dialmodeassign',postdata,'','','singlethis','POST',function(retrstr){ |
| 90 | simpleNotification('Success','topRight',"Dial mode assign suceesfully!"); | 90 | simpleNotification('Success','topRight',"Dial mode assign suceesfully!"); |
| 91 | $("#usrname").select2("val", "Select User..."); | 91 | $("#usrname").select2("val", "Select User..."); |
| 92 | $("#dialmodeassign").select2("val", "Select Dial Mode..."); | 92 | $("#dialmodeassign").select2("val", "Select Dial Mode..."); |
| 93 | 93 | ||
| 94 | }); | 94 | }); |
| 95 | } | 95 | } |
| 96 | else | 96 | else |
| 97 | { | 97 | { |
| 98 | alert("Please insert something"); | 98 | alert("Please insert something"); |
| 99 | } | 99 | } |
| 100 | 100 | ||
| 101 | }); | 101 | }); |
| 102 | </script> | 102 | </script> |
| 103 | 103 | ... | ... |
| 1 | <?php | ||
| 2 | use App\Jobs\KHRMSLib; | ||
| 3 | use App\Models\CRMCall; | ||
| 4 | |||
| 5 | $wakka=new KHRMSLib(); | ||
| 6 | $roclientlst=$wakka->clientsReadAccess(); | ||
| 7 | if(isset($_GET['pbcode']))$pbcode=$_GET['pbcode']; | ||
| 8 | else $pbcode=''; | ||
| 9 | |||
| 10 | $alist=DB::table('p11086_cop_rlp_pb_base_uat') | ||
| 11 | ->select(DB::Raw("*")) | ||
| 12 | ->where('pbcode','=',$pbcode) | ||
| 13 | ->get(); | ||
| 14 | //print_r($alist); | ||
| 15 | |||
| 16 | ?> | ||
| 17 | <style>#logtable.td{vertical-align:top;}#logtable.tr{height:28px;overflow-y:hidden;}</style> | ||
| 18 | |||
| 19 | <div class="layout-app"><!-- row-app --> | ||
| 20 | <div class="row row-app"> | ||
| 21 | |||
| 22 | <div class="col-md-12"> | ||
| 23 | |||
| 24 | <div class="col-separator col-separator-first col-unscrollable box"> | ||
| 25 | <div style='clear:both;margin:2% 0 0 1%;border: 2px solid #F5F5F5;padding:2%;border-radius: 5px;'> | ||
| 26 | <center><h4>RLP PB WISE</center> | ||
| 27 | |||
| 28 | <br> | ||
| 29 | <div class='container'> | ||
| 30 | |||
| 31 | PB CODE:<select id='pb_code' class=select2multi style="width:20%;" onclick="pbcodeSelect();"> | ||
| 32 | <?php foreach($roclientlst as $c){$s="";if($c==$pbcode)$s='selected';echo "<option value='$c' $s>$c</option>";} ?> | ||
| 33 | </select> | ||
| 34 | </div> | ||
| 35 | </div> | ||
| 36 | </div> | ||
| 37 | <div style='overflow:auto;margin-top: 10px;'> | ||
| 38 | <table id='logtable' class='footable table table-striped table-bordered table-white table-primary footable-loaded' style='font-size:12px';margin:0; border:1px solid #BBB;> | ||
| 39 | <thead> | ||
| 40 | <tr> | ||
| 41 | <th>Product</th> | ||
| 42 | <th>Opportunity</th> | ||
| 43 | <th>Contacted</th> | ||
| 44 | <th>Pitched</th> | ||
| 45 | <th>LG</th> | ||
| 46 | </tr> | ||
| 47 | </thead> | ||
| 48 | <tr> | ||
| 49 | <td>AL</td> | ||
| 50 | <td><?php echo $alist[0]->al_qm_opp + $alist[0]->al_upg_opp + $alist[0]->al_al_cnc_opp + $alist[0]->al_pa_opp + $alist[0]->al_zip_opp ?></td> | ||
| 51 | <td><?php echo $alist[0]->al_called_opp ?></td> | ||
| 52 | <td><?php echo $alist[0]->al_pitch ?></td> | ||
| 53 | <td><?php echo $alist[0]->al_lg ?></td> | ||
| 54 | </tr> | ||
| 55 | <tr> | ||
| 56 | <td>PL/BL</td> | ||
| 57 | <td><?php echo $alist[0]->pl_10sec_opp+$alist[0]->pl_pa_opp+$alist[0]->pl_pq_opp+$alist[0]->bl_10sec_opp+$alist[0]->bl_pq_opp ?></td> | ||
| 58 | <td><?php echo $alist[0]->pl_called_opp ?></td> | ||
| 59 | <td><?php echo $alist[0]->pl_pitch ?></td> | ||
| 60 | <td><?php echo $alist[0]->pl_lg ?></td> | ||
| 61 | </tr> | ||
| 62 | <tr> | ||
| 63 | <td>Retail Assets</td> | ||
| 64 | <td><?php echo $alist[0]->twl_pa_opp+$alist[0]->hl_pq_opp+$alist[0]->hl_bt_opp+$alist[0]->gl_pitch+$alist[0]->las_opp+$alist[0]->lap_opp ?></td> | ||
| 65 | <td><?php echo $alist[0]->twl_called_opp+$alist[0]->hl_called_opp+$alist[0]->las_called_opp+$alist[0]->lap_called_opp ?></td> | ||
| 66 | <td><?php echo $alist[0]->twl_pitch+$alist[0]->hl_pitch+$alist[0]->gl_pitch+$alist[0]->las_pitch ?></td> | ||
| 67 | <td><?php echo $alist[0]->twl_lg+$alist[0]->hl_lg+$alist[0]->gl_lg+$alist[0]->las_lg+$alist[0]->lap_lg ?></td> | ||
| 68 | </tr> | ||
| 69 | <tr> | ||
| 70 | <td>HSL</td> | ||
| 71 | <td><?php echo $alist[0]->hsl_opp ?></td> | ||
| 72 | <td><?php echo $alist[0]->hsl_called_opp ?></td> | ||
| 73 | <td><?php echo $alist[0]->hsl_pitch ?></td> | ||
| 74 | <td></td> | ||
| 75 | </tr> | ||
| 76 | <tr> | ||
| 77 | <td>Credit Card- New Sourcing</td> | ||
| 78 | <td><?php echo $alist[0]->cc_eli_new_opp ?></td> | ||
| 79 | <td><?php echo $alist[0]->cc_activation_opp ?></td> | ||
| 80 | <td><?php echo $alist[0]->cc_pitch ?></td> | ||
| 81 | <td><?php echo $alist[0]->cc_lg ?></td> | ||
| 82 | </tr> | ||
| 83 | <tr> | ||
| 84 | <td>Credit Card- LTD Activation on Carded</td> | ||
| 85 | <td><?php echo $alist[0]->cc_activation_opp ?></td> | ||
| 86 | <td><?php echo $alist[0]->cc_activation_called_opp ?></td> | ||
| 87 | <td></td> | ||
| 88 | <td</td> | ||
| 89 | </tr> | ||
| 90 | <tr> | ||
| 91 | <td>Insurance LI</td> | ||
| 92 | <td><?php echo $alist[0]->li_opp ?></td> | ||
| 93 | <td><?php echo $alist[0]->li_called_opp ?></td> | ||
| 94 | <td></td> | ||
| 95 | <td></td> | ||
| 96 | </tr> | ||
| 97 | <tr> | ||
| 98 | <td>FD</td> | ||
| 99 | <td><?php echo $alist[0]->fd_opp ?></td> | ||
| 100 | <td><?php echo $alist[0]->fd_called_opp ?></td> | ||
| 101 | <td><?php echo $alist[0]->fd_pitch ?></td> | ||
| 102 | <td></td> | ||
| 103 | </tr> | ||
| 104 | <tr> | ||
| 105 | <td>LTD Activation-Savings Account</td> | ||
| 106 | <td><?php echo $alist[0]->ltd_act_saving_opp ?></td> | ||
| 107 | <td><?php echo $alist[0]->ltd_act_saving_opp ?></td> | ||
| 108 | <td></td> | ||
| 109 | <td></td> | ||
| 110 | </tr> | ||
| 111 | <tr> | ||
| 112 | <td>NB/MB Activations</td> | ||
| 113 | <td><?php echo $alist[0]->mb_opp ?></td> | ||
| 114 | <td><?php echo $alist[0]->mb_called_opp ?></td> | ||
| 115 | <td><?php echo $alist[0]->mb_pitch ?></td> | ||
| 116 | <td><?php echo $alist[0]->nb_mb_lg ?></td> | ||
| 117 | </tr> | ||
| 118 | <tr> | ||
| 119 | <td>Aadhar Seeding</td> | ||
| 120 | <td><?php echo $alist[0]->aadhaar_opp ?></td> | ||
| 121 | <td><?php echo $alist[0]->aadhaar_called_opp ?></td> | ||
| 122 | <td><?php echo $alist[0]->aadhaar_pitch ?></td> | ||
| 123 | <td><?php echo $alist[0]->aadhaar_activation ?></td> | ||
| 124 | </tr> | ||
| 125 | <tr> | ||
| 126 | <td>Digital Activation</td> | ||
| 127 | <td><?php echo $alist[0]->digi2_score_opp ?></td> | ||
| 128 | <td><?php echo $alist[0]->digi2_score_called_opp ?></td> | ||
| 129 | <td></td> | ||
| 130 | <td></td> | ||
| 131 | </tr> | ||
| 132 | <tr> | ||
| 133 | <td>BillPayments</td> | ||
| 134 | <td><?php echo $alist[0]->digi_billpay_opp ?></td> | ||
| 135 | <td><?php echo $alist[0]->digi_billpay_called_opp ?></td> | ||
| 136 | <td><?php echo $alist[0]->bill_pay_pitch ?></td> | ||
| 137 | <td></td> | ||
| 138 | </tr> | ||
| 139 | <tr> | ||
| 140 | <td>Financial Transactions</td> | ||
| 141 | <td><?php echo $alist[0]->digi_basic_banking_opp ?></td> | ||
| 142 | <td><?php echo $alist[0]->digi_basic_banking_called_opp ?></td> | ||
| 143 | <td></td> | ||
| 144 | <td></td> | ||
| 145 | </tr> | ||
| 146 | <tr> | ||
| 147 | <td>Digital 2.0 Score(Ecom Shopping Inactive)</td> | ||
| 148 | <td><?php echo $alist[0]->digi_ecom_shopping_opp ?></td> | ||
| 149 | <td><?php echo $alist[0]->digi_ecom_shopping_called_opp ?></td> | ||
| 150 | <td></td> | ||
| 151 | <td> </td> | ||
| 152 | </tr> | ||
| 153 | <tr> | ||
| 154 | <td>Digital 2.0 Score(Investment Inactive)</td> | ||
| 155 | <td><?php echo $alist[0]->digi_investment_opp ?></td> | ||
| 156 | <td><?php echo $alist[0]->digi_investment_called_opp ?></td> | ||
| 157 | <td><?php echo $alist[0]->invest_pitch ?></td> | ||
| 158 | <td></td> | ||
| 159 | </tr> | ||
| 160 | <tr> | ||
| 161 | <td>Reduction in Physical Transactions</td> | ||
| 162 | <td><?php echo $alist[0]->invest_pitch ?></td> | ||
| 163 | <td><?php echo $alist[0]->invest_pitch ?></td> | ||
| 164 | <td></td> | ||
| 165 | <td></td> | ||
| 166 | </tr> | ||
| 167 | <tr> | ||
| 168 | <td>% of Groups Contacted</td> | ||
| 169 | <td> </td> | ||
| 170 | <td> </td> | ||
| 171 | <td> </td> | ||
| 172 | <td> </td> | ||
| 173 | </tr> | ||
| 174 | <tr> | ||
| 175 | <td>Movement of Groups to higher engagement</td> | ||
| 176 | <td> </td> | ||
| 177 | <td> </td> | ||
| 178 | <td> </td> | ||
| 179 | <td></td> | ||
| 180 | </tr> | ||
| 181 | <tr> | ||
| 182 | <td>CASA Growth</td> | ||
| 183 | <td> </td> | ||
| 184 | <td> </td> | ||
| 185 | <td> </td> | ||
| 186 | <td> </td> | ||
| 187 | </tr> | ||
| 188 | <tr> | ||
| 189 | <td>Mutual Fund</td> | ||
| 190 | <td> </td> | ||
| 191 | <td> </td> | ||
| 192 | <td> </td> | ||
| 193 | <td> </td> | ||
| 194 | </tr> | ||
| 195 | </table> | ||
| 196 | </div> | ||
| 197 | <div id=dialoglog></div> | ||
| 198 | </div> | ||
| 199 | </div> | ||
| 200 | </div> | ||
| 201 | <style>#logtable.td{vertical-align:top;}#logtable.tr{height:28px;overflow-y:hidden;}</style> | ||
| 202 | <script> | ||
| 203 | $(document).ready(function() | ||
| 204 | { | ||
| 205 | if(!$('#dialoglog').hasClass('ui-dialog-content')) | ||
| 206 | { | ||
| 207 | $('#dialoglog').dialog({ | ||
| 208 | autoOpen: false, | ||
| 209 | width: '70%', | ||
| 210 | buttons: { | ||
| 211 | "Ok": function() { | ||
| 212 | $(this).dialog("close"); | ||
| 213 | }, | ||
| 214 | "Cancel": function() { | ||
| 215 | $(this).dialog("close"); | ||
| 216 | } | ||
| 217 | } | ||
| 218 | }); | ||
| 219 | } | ||
| 220 | |||
| 221 | waitKeyUpRun("filter",function() { filter2(document.getElementById('filter'), 'logtable') },"2000"); | ||
| 222 | |||
| 223 | }); | ||
| 224 | function pbcodeSelect() | ||
| 225 | { | ||
| 226 | var pbcode=$('#pb_code').val(); | ||
| 227 | doAjax('rlp?pbcode='+pbcode,'','content','ajax_rlp','singlethis','GET'); | ||
| 228 | } | ||
| 229 | </script> | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
-
Please register or sign in to post a comment