summary tab
Showing
4 changed files
with
1829 additions
and
1 deletions
| ... | @@ -3077,7 +3077,255 @@ function createRacingCust() | ... | @@ -3077,7 +3077,255 @@ function createRacingCust() |
| 3077 | 3077 | ||
| 3078 | return $data; | 3078 | return $data; |
| 3079 | } | 3079 | } |
| 3080 | //for RLP | ||
| 3081 | function createRLP() | ||
| 3082 | { | ||
| 3083 | $dataarr=$this->recruitdata["peopledata"]; | ||
| 3084 | $rlpcust = DB::table('p11086_cop_rlp_cust_base_uat')->where('pbcode','=',$dataarr["client"])->where('cod_cust','=',$dataarr["clientcode"])->select('*')->get(); | ||
| 3085 | $data=""; | ||
| 3086 | //echo "<pre>".print_r($rlpcust)."</pre>"; | ||
| 3087 | $data.="<fieldset><legend class='new-recruit_legend'>RLP Customer WISE</legend>"; | ||
| 3088 | |||
| 3089 | $data.="<div class=custom1 style='width:100%;'> | ||
| 3090 | <h2></h2>"; | ||
| 3080 | 3091 | ||
| 3092 | $data.="<hr><br><table class='table kDataTable' cellpadding=0 cellspacing=0 border=0> | ||
| 3093 | <thead><tr> | ||
| 3094 | <td class='table_hrm_heading_green'>Product</td> | ||
| 3095 | <td class='table_hrm_heading_green'>Opportunity</td> | ||
| 3096 | <td class='table_hrm_heading_green'>Contacted</td> | ||
| 3097 | <td class='table_hrm_heading_green'>Total Unique Calls Made to customer with Opportunity </td> | ||
| 3098 | <td class='table_hrm_heading_green'>Total Unique Customers Pitched</td> | ||
| 3099 | <td class='table_hrm_heading_green'>LG (Offline)</td> | ||
| 3100 | <td class='table_hrm_heading_green'>LC</td> | ||
| 3101 | <td class='table_hrm_heading_green'>Activation</td> | ||
| 3102 | </tr></thead>"; | ||
| 3103 | $data.="<tr> | ||
| 3104 | <td>Auto Loan</td> | ||
| 3105 | <td> | ||
| 3106 | <table> | ||
| 3107 | <tr><td>".$rlpcust[0]->al_qm_opp."</td></tr><tr><td>".$rlpcust[0]->al_upg_opp."</td></tr><tr><td>".$rlpcust[0]->al_al_cnc_opp."</td></tr><tr><td>".$rlpcust[0]->al_pa_opp."</td></tr><tr><td>".$rlpcust[0]->al_zip_opp."</td></tr></table> | ||
| 3108 | </td> | ||
| 3109 | <td>".$rlpcust[0]->al_called_opp."</td> | ||
| 3110 | <td>".$rlpcust[0]->al_pitch."</td> | ||
| 3111 | <td></td> | ||
| 3112 | <td>".$rlpcust[0]->al_lg."</td> | ||
| 3113 | <td></td> | ||
| 3114 | <td></td> | ||
| 3115 | </tr> | ||
| 3116 | <tr> | ||
| 3117 | <td>Personal Loan</td> | ||
| 3118 | <td> | ||
| 3119 | <table> | ||
| 3120 | <tr><td>".$rlpcust[0]->pl_10sec_opp."</td></tr><tr><td>".$rlpcust[0]->pl_pa_opp."</td></tr><tr><td>".$rlpcust[0]->pl_pq_opp."</td></tr><tr><td>".$rlpcust[0]->bl_10sec_opp."</td></tr><tr><td>".$rlpcust[0]->bl_pq_opp."</td></tr> | ||
| 3121 | </table> | ||
| 3122 | </td> | ||
| 3123 | <td>".$rlpcust[0]->pl_called_opp."</td> | ||
| 3124 | <td>".$rlpcust[0]->pl_pitch."</td> | ||
| 3125 | <td></td> | ||
| 3126 | <td>".$rlpcust[0]->pl_lg."</td> | ||
| 3127 | <td></td> | ||
| 3128 | <td></td> | ||
| 3129 | </tr> | ||
| 3130 | <tr> | ||
| 3131 | <td>Two Wheeler Loan</td> | ||
| 3132 | <td>".$rlpcust[0]->twl_pa_opp."</td> | ||
| 3133 | <td>".$rlpcust[0]->twl_called_opp."</td> | ||
| 3134 | <td>".$rlpcust[0]->twl_pitch."</td> | ||
| 3135 | <td></td> | ||
| 3136 | <td>".$rlpcust[0]->twl_lg."</td> | ||
| 3137 | <td></td> | ||
| 3138 | <td></td> | ||
| 3139 | </tr> | ||
| 3140 | <tr> | ||
| 3141 | <td>Home Loan</td> | ||
| 3142 | <td> | ||
| 3143 | <table> | ||
| 3144 | <tr><td>".$rlpcust[0]->hl_pq_opp."<td></tr><tr><td>".$rlpcust[0]->hl_bt_opp."<td></tr> | ||
| 3145 | </table> | ||
| 3146 | </td> | ||
| 3147 | <td>".$rlpcust[0]->hl_called_opp."</td> | ||
| 3148 | <td>".$rlpcust[0]->hl_pitch."</td> | ||
| 3149 | <td></td> | ||
| 3150 | <td>".$rlpcust[0]->hl_pitch."</td> | ||
| 3151 | <td></td> | ||
| 3152 | <td></td> | ||
| 3153 | </tr> | ||
| 3154 | <tr> | ||
| 3155 | <td>Gold Loan</td> | ||
| 3156 | <td>GL</td> | ||
| 3157 | <td></td> | ||
| 3158 | <td>".$rlpcust[0]->gl_pitch."</td> | ||
| 3159 | <td></td> | ||
| 3160 | <td></td> | ||
| 3161 | <td></td> | ||
| 3162 | <td></td> | ||
| 3163 | </tr> | ||
| 3164 | <tr> | ||
| 3165 | <td>Loan Against Securities</td> | ||
| 3166 | <td>".$rlpcust[0]->las_opp."</td> | ||
| 3167 | <td>".$rlpcust[0]->las_called_opp."</td> | ||
| 3168 | <td>".$rlpcust[0]->las_pitch."</td> | ||
| 3169 | <td></td> | ||
| 3170 | <td>".$rlpcust[0]->las_lg."</td> | ||
| 3171 | <td></td> | ||
| 3172 | <td></td> | ||
| 3173 | </tr> | ||
| 3174 | <tr> | ||
| 3175 | <td>Loan Against Property</td> | ||
| 3176 | <td>".$rlpcust[0]->lap_opp."</td> | ||
| 3177 | <td>".$rlpcust[0]->lap_called_opp."</td> | ||
| 3178 | <td></td> | ||
| 3179 | <td></td> | ||
| 3180 | <td>".$rlpcust[0]->lap_lg."</td> | ||
| 3181 | <td></td> | ||
| 3182 | <td></td> | ||
| 3183 | </tr> | ||
| 3184 | <tr> | ||
| 3185 | <td>HSL</td> | ||
| 3186 | <td>".$rlpcust[0]->hsl_opp."</td> | ||
| 3187 | <td>".$rlpcust[0]->hsl_called_opp."</td> | ||
| 3188 | <td>".$rlpcust[0]->hsl_pitch."</td> | ||
| 3189 | <td></td> | ||
| 3190 | <td></td> | ||
| 3191 | <td></td> | ||
| 3192 | <td></td> | ||
| 3193 | </tr> | ||
| 3194 | <tr> | ||
| 3195 | <td>Credit Card</td> | ||
| 3196 | <td>".$rlpcust[0]->cc_eli_new_opp."</td> | ||
| 3197 | <td>".$rlpcust[0]->cc_called_opp."</td> | ||
| 3198 | <td>".$rlpcust[0]->cc_pitch."</td> | ||
| 3199 | <td></td> | ||
| 3200 | <td>".$rlpcust[0]->cc_lg."</td> | ||
| 3201 | <td></td> | ||
| 3202 | <td></td> | ||
| 3203 | </tr> | ||
| 3204 | <tr> | ||
| 3205 | <td>CC Activation</td> | ||
| 3206 | <td>".$rlpcust[0]->cc_activation_opp."</td> | ||
| 3207 | <td>".$rlpcust[0]->cc_activation_called_opp."</td> | ||
| 3208 | <td></td> | ||
| 3209 | <td></td> | ||
| 3210 | <td></td> | ||
| 3211 | <td></td> | ||
| 3212 | <td></td> | ||
| 3213 | </tr> | ||
| 3214 | <tr> | ||
| 3215 | <td>LI</td> | ||
| 3216 | <td>".$rlpcust[0]->li_opp."</td> | ||
| 3217 | <td>".$rlpcust[0]->li_called_opp."</td> | ||
| 3218 | <td></td> | ||
| 3219 | <td></td> | ||
| 3220 | <td></td> | ||
| 3221 | <td></td> | ||
| 3222 | <td></td> | ||
| 3223 | </tr> | ||
| 3224 | <tr> | ||
| 3225 | <td>FD</td> | ||
| 3226 | <td>".$rlpcust[0]->fd_opp."</td> | ||
| 3227 | <td>".$rlpcust[0]->fd_called_opp."</td> | ||
| 3228 | <td>".$rlpcust[0]->fd_pitch."</td> | ||
| 3229 | <td></td> | ||
| 3230 | <td></td> | ||
| 3231 | <td></td> | ||
| 3232 | <td></td> | ||
| 3233 | </tr> | ||
| 3234 | <tr> | ||
| 3235 | <td>SAVINGS LTD(Transections (0-3))</td> | ||
| 3236 | <td>".$rlpcust[0]->ltd_act_saving_opp."</td> | ||
| 3237 | <td>".$rlpcust[0]->ltd_act_saving_called_opp."</td> | ||
| 3238 | <td></td> | ||
| 3239 | <td></td> | ||
| 3240 | <td></td> | ||
| 3241 | <td></td> | ||
| 3242 | <td></td> | ||
| 3243 | </tr> | ||
| 3244 | <tr> | ||
| 3245 | <td>Mobile Banking/Netbanking</td> | ||
| 3246 | <td>".$rlpcust[0]->mb_opp."</td> | ||
| 3247 | <td>".$rlpcust[0]->mb_called_opp."</td> | ||
| 3248 | <td>".$rlpcust[0]->mb_pitch."</td> | ||
| 3249 | <td></td> | ||
| 3250 | <td></td> | ||
| 3251 | <td></td> | ||
| 3252 | <td>".$rlpcust[0]->nb_mb_lg."</td> | ||
| 3253 | </tr> | ||
| 3254 | <tr> | ||
| 3255 | <td>Aadhaar</td> | ||
| 3256 | <td>".$rlpcust[0]->aadhaar_opp."</td> | ||
| 3257 | <td>".$rlpcust[0]->aadhaar_called_opp."</td> | ||
| 3258 | <td>".$rlpcust[0]->aadhaar_pitch."</td> | ||
| 3259 | <td></td> | ||
| 3260 | <td></td> | ||
| 3261 | <td></td> | ||
| 3262 | <td>".$rlpcust[0]->aadhaar_activation."</td> | ||
| 3263 | </tr> | ||
| 3264 | <tr> | ||
| 3265 | <td>Digital 2.0 Score (Inactive)</td> | ||
| 3266 | <td>".$rlpcust[0]->digi2_score_opp."</td> | ||
| 3267 | <td>".$rlpcust[0]->digi2_score_called_opp."</td> | ||
| 3268 | <td></td> | ||
| 3269 | <td></td> | ||
| 3270 | <td></td> | ||
| 3271 | <td></td> | ||
| 3272 | <td></td> | ||
| 3273 | </tr> | ||
| 3274 | <tr> | ||
| 3275 | <td>Digital 2.0 Score (Bill Pay Inactive)</td> | ||
| 3276 | <td>".$rlpcust[0]->digi_billpay_opp."</td> | ||
| 3277 | <td>".$rlpcust[0]->digi_billpay_called_opp."</td> | ||
| 3278 | <td>".$rlpcust[0]->bill_pay_pitch."</td> | ||
| 3279 | <td></td> | ||
| 3280 | <td>".$rlpcust[0]->las_lg."</td> | ||
| 3281 | <td></td> | ||
| 3282 | <td></td> | ||
| 3283 | </tr> | ||
| 3284 | <tr> | ||
| 3285 | <td>Digital 2.0 Score(Basic Banking Inactive)</td> | ||
| 3286 | <td>".$rlpcust[0]->digi_basic_banking_opp."</td> | ||
| 3287 | <td>".$rlpcust[0]->digi_basic_banking_called_opp."</td> | ||
| 3288 | <td>".$rlpcust[0]->las_pitch."</td> | ||
| 3289 | <td></td> | ||
| 3290 | <td>".$rlpcust[0]->las_lg."</td> | ||
| 3291 | <td></td> | ||
| 3292 | <td></td> | ||
| 3293 | </tr> | ||
| 3294 | <tr> | ||
| 3295 | <td>Digital 2.0 Score(Ecom Shopping Inactive)</td> | ||
| 3296 | <td>".$rlpcust[0]->digi_ecom_shopping_opp."</td> | ||
| 3297 | <td>".$rlpcust[0]->digi_ecom_shopping_called_opp."</td> | ||
| 3298 | <td></td> | ||
| 3299 | <td></td> | ||
| 3300 | <td></td> | ||
| 3301 | <td></td> | ||
| 3302 | <td></td> | ||
| 3303 | </tr> | ||
| 3304 | <tr> | ||
| 3305 | <td>Digital 2.0 Score(Investment Inactive)</td> | ||
| 3306 | <td>".$rlpcust[0]->digi_investment_opp."</td> | ||
| 3307 | <td>".$rlpcust[0]->digi_investment_called_opp."</td> | ||
| 3308 | <td>".$rlpcust[0]->invest_pitch."</td> | ||
| 3309 | <td></td> | ||
| 3310 | <td></td> | ||
| 3311 | <td></td> | ||
| 3312 | <td></td> | ||
| 3313 | </tr> | ||
| 3314 | <tr> | ||
| 3315 | <td>Digital 2.0 Score(PHYSICAL Inactive)</td> | ||
| 3316 | <td>".$rlpcust[0]->digi_physical_opp."</td> | ||
| 3317 | <td>".$rlpcust[0]->digi_physical_called_opp."</td> | ||
| 3318 | <td></td> | ||
| 3319 | <td></td> | ||
| 3320 | <td></td> | ||
| 3321 | <td></td> | ||
| 3322 | <td></td> | ||
| 3323 | </tr> | ||
| 3324 | </table></div></fieldset>"; | ||
| 3325 | |||
| 3326 | return $data; | ||
| 3327 | |||
| 3328 | } | ||
| 3081 | 3329 | ||
| 3082 | function colorCodeRec($id) | 3330 | function colorCodeRec($id) |
| 3083 | { | 3331 | { |
| ... | @@ -3142,6 +3390,7 @@ function CreateForm(&$frm) | ... | @@ -3142,6 +3390,7 @@ function CreateForm(&$frm) |
| 3142 | //if(Auth::user()->username =="B654321" || Auth::user()->username =="B12345") | 3390 | //if(Auth::user()->username =="B654321" || Auth::user()->username =="B12345") |
| 3143 | //{ | 3391 | //{ |
| 3144 | $frm['Lead Entry Form']["{{id}} {{firstname}}"][]=array(); | 3392 | $frm['Lead Entry Form']["{{id}} {{firstname}}"][]=array(); |
| 3393 | $frm['RLP']["{{id}} {{firstname}}"][]=array(); | ||
| 3145 | //} | 3394 | //} |
| 3146 | } | 3395 | } |
| 3147 | } | 3396 | } |
| ... | @@ -3210,6 +3459,7 @@ function CreateForm(&$frm) | ... | @@ -3210,6 +3459,7 @@ function CreateForm(&$frm) |
| 3210 | //if($tbname=='RacingCustomer')$tabsdata.=$this->createRacingCust(); | 3459 | //if($tbname=='RacingCustomer')$tabsdata.=$this->createRacingCust(); |
| 3211 | if($tbname=='Racing Format')$tabsdata.=$this->createRacingCust(); | 3460 | if($tbname=='Racing Format')$tabsdata.=$this->createRacingCust(); |
| 3212 | if($tbname=='Lead Entry Form')$tabsdata.=$this->createLeadEntryForm(); | 3461 | if($tbname=='Lead Entry Form')$tabsdata.=$this->createLeadEntryForm(); |
| 3462 | if($tbname=='RLP')$tabsdata.=$this->createRLP(); | ||
| 3213 | $tabsdata.="</div>"; | 3463 | $tabsdata.="</div>"; |
| 3214 | $i++; | 3464 | $i++; |
| 3215 | } | 3465 | } | ... | ... |
| ... | @@ -123,7 +123,8 @@ return [ | ... | @@ -123,7 +123,8 @@ return [ |
| 123 | "Role" => ["disp"=>"Role","icon"=>"home","dash"=>"","onclick"=>""], | 123 | "Role" => ["disp"=>"Role","icon"=>"home","dash"=>"","onclick"=>""], |
| 124 | "DialMode" => ["disp"=>"DialMode","icon"=>"home","dash"=>"","onclick"=>""], | 124 | "DialMode" => ["disp"=>"DialMode","icon"=>"home","dash"=>"","onclick"=>""], |
| 125 | "SupervisorModule" => ["disp"=>"SupervisorModule","icon"=>"globe","dash"=>"","onclick"=>"menuAction('SupervisorModule');"], | 125 | "SupervisorModule" => ["disp"=>"SupervisorModule","icon"=>"globe","dash"=>"","onclick"=>"menuAction('SupervisorModule');"], |
| 126 | "Notes" => ["disp"=>"Notes","icon"=>"globe","dash"=>"","onclick"=>"menuAction('notes');"], | 126 | "Notes" => ["disp"=>"Notes","icon"=>"globe","dash"=>"","onclick"=>"menuAction('notes');"], |
| 127 | "RLP" => ["disp"=>"RLP","icon"=>"globe","dash"=>"","onclick"=>"menuAction('rlp');"], | ||
| 127 | "Group" => ["disp"=>"Group","icon"=>"home","dash"=>"","onclick"=>"", | 128 | "Group" => ["disp"=>"Group","icon"=>"home","dash"=>"","onclick"=>"", |
| 128 | "title"=>env('app_name', 'Application'), | 129 | "title"=>env('app_name', 'Application'), |
| 129 | "keywords"=>"Kstych", | 130 | "keywords"=>"Kstych", |
| ... | @@ -134,6 +135,7 @@ return [ | ... | @@ -134,6 +135,7 @@ return [ |
| 134 | ], | 135 | ], |
| 135 | 136 | ||
| 136 | 137 | ||
| 138 | |||
| 137 | 'app_groups' => [], //loaded from db | 139 | 'app_groups' => [], //loaded from db |
| 138 | 'admindebug' => filter_var(env('APP_ADMIN_DEBUG',true), FILTER_VALIDATE_BOOLEAN), | 140 | 'admindebug' => filter_var(env('APP_ADMIN_DEBUG',true), FILTER_VALIDATE_BOOLEAN), |
| 139 | 'name' => env('app_name', 'Application'), | 141 | 'name' => env('app_name', 'Application'), | ... | ... |
| ... | @@ -221,6 +221,8 @@ function waitKeyUpRun(varid,fncall,wttime) | ... | @@ -221,6 +221,8 @@ 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'); | ||
| 225 | //for rlp pbwise call ajax | ||
| 224 | if(menu=='rlp'){ | 226 | if(menu=='rlp'){ |
| 225 | pbcode=$('#tcampaign_select').val(); | 227 | pbcode=$('#tcampaign_select').val(); |
| 226 | doAjax(menu+'?pbcode='+pbcode,'','content','ajax_'+menu,'singlethis','GET'); | 228 | doAjax(menu+'?pbcode='+pbcode,'','content','ajax_'+menu,'singlethis','GET'); | ... | ... |
| 1 | <?php namespace App\Http\Controllers; | ||
| 2 | |||
| 3 | use Auth; | ||
| 4 | use Input; | ||
| 5 | use Response; | ||
| 6 | use Config; | ||
| 7 | use App\Models\Group; | ||
| 8 | use App\Models\Master; | ||
| 9 | use App\Models\Record; | ||
| 10 | use App\Models\CRMCall; | ||
| 11 | use App\Models\CRMCallArchive; | ||
| 12 | use App\Models\CRM; | ||
| 13 | use App\Models\CRMCampaign; | ||
| 14 | use App\Models\CRMList; | ||
| 15 | use App\Jobs\KHRMSLib; | ||
| 16 | use App\Models\Sipid; | ||
| 17 | use App\Models\Dialline; | ||
| 18 | use App\Models\UserLog; | ||
| 19 | use App\Models\Kqueue; | ||
| 20 | use DB; | ||
| 21 | use Log; | ||
| 22 | use Session; | ||
| 23 | $client=''; | ||
| 24 | |||
| 25 | class DialerController extends Controller { | ||
| 26 | |||
| 27 | public function __construct() | ||
| 28 | { | ||
| 29 | $this->middleware('auth'); | ||
| 30 | $this->middleware('module_access'); | ||
| 31 | |||
| 32 | } | ||
| 33 | |||
| 34 | public function index() | ||
| 35 | { | ||
| 36 | |||
| 37 | } | ||
| 38 | public function create() | ||
| 39 | { | ||
| 40 | |||
| 41 | } | ||
| 42 | public function store() | ||
| 43 | { | ||
| 44 | $action=Input::get('action'); | ||
| 45 | $client=Input::get('client'); | ||
| 46 | |||
| 47 | $kstychCall=json_decode(html_entity_decode(Input::get("kstychCall"),ENT_QUOTES, "UTF-8"),true); | ||
| 48 | $kstychDialer=json_decode(html_entity_decode(Input::get("kstychDialer"),ENT_QUOTES, "UTF-8"),true); | ||
| 49 | |||
| 50 | if($action=="previewnext") | ||
| 51 | { | ||
| 52 | $wakka = new KHRMSLib(); | ||
| 53 | |||
| 54 | $roclientstr=array(); | ||
| 55 | $oclientlst=$wakka->clientsReadAccess(); | ||
| 56 | if(!empty($oclientlst))foreach($oclientlst as $tclnt)if($tclnt!=""){$roclientstr[]="'$tclnt'";} | ||
| 57 | |||
| 58 | if(!empty($roclientstr))$roclientstr="and client in (".implode(",",$roclientstr).")";else $roclientstr=""; | ||
| 59 | |||
| 60 | $users=array();$searchresult=""; | ||
| 61 | if(!empty($kstychCall["previewcrmid"]))$users=$wakka->getPersons("id='".$kstychCall["previewcrmid"]."' $roclientstr limit 1"); | ||
| 62 | else $users=$this->getCallSequencing(1); | ||
| 63 | |||
| 64 | if(!empty($users)) | ||
| 65 | { | ||
| 66 | $searchresult.="<div id=divworking></div><div style='clear:both'></div><script>kSetDData('C','previewcrmid','".$users[0]['id']."');showRecruit(\"".$users[0]['id']."\");</script>"; | ||
| 67 | |||
| 68 | $searchresult.="<div id=internalid_matchlist></div><script> | ||
| 69 | doAjax('record?action=quicksearch','maintextsearch_1_txt=".$users[0]['clientinternalid']."&maintextsearch_1_span=InternalID','internalid_matchlist','searchMutex', 'searchxhr','POST',function(retstr){ | ||
| 70 | if(retstr.responseText.indexOf('No Records Found!')>-1)$('#internalid_matchlist').html(''); | ||
| 71 | }); | ||
| 72 | </script>"; | ||
| 73 | } | ||
| 74 | else | ||
| 75 | { | ||
| 76 | $searchresult.="<div id=internalid_matchlist></div><script>createSearchRecordDiv('internalid_matchlist');</script>"; | ||
| 77 | } | ||
| 78 | |||
| 79 | |||
| 80 | return Response::make($searchresult); | ||
| 81 | } | ||
| 82 | |||
| 83 | if($action=="newcall") | ||
| 84 | { | ||
| 85 | $wakka = new KHRMSLib(); | ||
| 86 | |||
| 87 | $roclientstr=array(); | ||
| 88 | $oclientlst=$wakka->clientsReadAccess(); | ||
| 89 | foreach($oclientlst as $tclnt)if($tclnt!=""){$roclientstr[]="'$tclnt'";} | ||
| 90 | if(!empty($roclientstr))$roclientstr="and client in (".implode(",",$roclientstr).")";else $roclientstr=""; | ||
| 91 | |||
| 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-------- | ||
| 94 | if($kstychCall['crmid']) | ||
| 95 | { | ||
| 96 | $crmid=$kstychCall['previewcrmid']; | ||
| 97 | } | ||
| 98 | else | ||
| 99 | { | ||
| 100 | $crmid=$kstychCall['previewcrmid']; | ||
| 101 | |||
| 102 | } | ||
| 103 | if($kstychDialer['mDialerState']=="Manual") | ||
| 104 | { | ||
| 105 | |||
| 106 | if($crmid!="") | ||
| 107 | { | ||
| 108 | $tusers=$wakka->getPersonIDs("(mobile like '%".substr($callnumber,-10)."' OR | ||
| 109 | altphone1 like '%".substr($callnumber,-10)."' OR | ||
| 110 | altphone2 like '%".substr($callnumber,-10)."' OR | ||
| 111 | altphone3 like '%".substr($callnumber,-10)."' OR | ||
| 112 | altphone4 like '%".substr($callnumber,-10)."' OR | ||
| 113 | altphone5 like '%".substr($callnumber,-10)."' OR | ||
| 114 | altphone6 like '%".substr($callnumber,-10)."' OR | ||
| 115 | altphone7 like '%".substr($callnumber,-10)."' OR | ||
| 116 | altphone8 like '%".substr($callnumber,-10)."' OR | ||
| 117 | altphone9 like '%".substr($callnumber,-10)."' OR | ||
| 118 | altphone10 like '%".substr($callnumber,-10)."') and id=$crmid "); | ||
| 119 | /*$tusers=$wakka->getPersonIDs("(mobile like '%".substr($callnumber,-10)."' OR | ||
| 120 | altphone1 like '%$callnumber' OR | ||
| 121 | altphone2 like '%$callnumber' OR | ||
| 122 | altphone3 like '%$callnumber' OR | ||
| 123 | altphone4 like '%$callnumber' OR | ||
| 124 | altphone5 like '%$callnumber' OR | ||
| 125 | altphone6 like '%$callnumber' OR | ||
| 126 | altphone7 like '%$callnumber' OR | ||
| 127 | altphone8 like '%$callnumber' OR | ||
| 128 | altphone9 like '%$callnumber' OR | ||
| 129 | altphone10 like '%$callnumber') and id=$crmid ");*/ | ||
| 130 | |||
| 131 | } | ||
| 132 | else | ||
| 133 | { | ||
| 134 | $tusers=$wakka->getPersonIDs("mobile like '%".substr($callnumber,-10)."' OR | ||
| 135 | altphone1 like '%".substr($callnumber,-10)."' OR | ||
| 136 | altphone2 like '%".substr($callnumber,-10)."' OR | ||
| 137 | altphone3 like '%".substr($callnumber,-10)."' OR | ||
| 138 | altphone4 like '%".substr($callnumber,-10)."' OR | ||
| 139 | altphone5 like '%".substr($callnumber,-10)."' OR | ||
| 140 | altphone6 like '%".substr($callnumber,-10)."' OR | ||
| 141 | altphone7 like '%".substr($callnumber,-10)."' OR | ||
| 142 | altphone8 like '%".substr($callnumber,-10)."' OR | ||
| 143 | altphone9 like '%".substr($callnumber,-10)."' OR | ||
| 144 | altphone10 like '%".substr($callnumber,-10)."' "); | ||
| 145 | /*$tusers=$wakka->getPersonIDs("mobile like '%".substr($callnumber,-10)."' OR | ||
| 146 | altphone1 like '%$callnumber' OR | ||
| 147 | altphone2 like '%$callnumber' OR | ||
| 148 | altphone3 like '%$callnumber' OR | ||
| 149 | altphone4 like '%$callnumber' OR | ||
| 150 | altphone5 like '%$callnumber' OR | ||
| 151 | altphone6 like '%$callnumber' OR | ||
| 152 | altphone7 like '%$callnumber' OR | ||
| 153 | altphone8 like '%$callnumber' OR | ||
| 154 | altphone9 like '%$callnumber' OR | ||
| 155 | altphone10 like '%$callnumber' ");*/ | ||
| 156 | } | ||
| 157 | |||
| 158 | /*if($crmid!=""){ | ||
| 159 | $tusers=$wakka->getPersonIDs("mobile like '%".substr($callnumber,-10)."' and id=$crmid "); | ||
| 160 | }else{ | ||
| 161 | $tusers=$wakka->getPersonIDs("mobile like '%".substr($callnumber,-10)."'"); | ||
| 162 | }*/ | ||
| 163 | |||
| 164 | $uids=array();foreach($tusers as $tuser)if(isset($tuser['id']))$uids[]=$tuser['id']+0; | ||
| 165 | $idstr=implode(",",$uids);if($idstr=="")$idstr="''"; | ||
| 166 | |||
| 167 | //$users=$wakka->getPersons("mobile like '%$callnumber' and id in ($idstr) $roclientstr"); | ||
| 168 | |||
| 169 | $users=$wakka->getPersons("(mobile like '%$callnumber' OR | ||
| 170 | altphone1 like '%$callnumber' OR | ||
| 171 | altphone2 like '%$callnumber' OR | ||
| 172 | altphone3 like '%$callnumber' OR | ||
| 173 | altphone4 like '%$callnumber' OR | ||
| 174 | altphone5 like '%$callnumber' OR | ||
| 175 | altphone6 like '%$callnumber' OR | ||
| 176 | altphone7 like '%$callnumber' OR | ||
| 177 | altphone8 like '%$callnumber' OR | ||
| 178 | altphone9 like '%$callnumber' OR | ||
| 179 | altphone10 like '%$callnumber' ) and id in ($idstr) $roclientstr"); | ||
| 180 | //code end by prashant Jadhav for manual calls on alternate number | ||
| 181 | |||
| 182 | // if(!$users) | ||
| 183 | // { | ||
| 184 | // for($i=1;$i<=10;$i++) | ||
| 185 | // { | ||
| 186 | // $users=$wakka->getPersons("altphone$i = '$callnumber' $roclientstr"); | ||
| 187 | // if(!empty($users))break; | ||
| 188 | // } | ||
| 189 | // } | ||
| 190 | |||
| 191 | if(!$users) | ||
| 192 | { | ||
| 193 | $users=array(0=>array('id'=>0,'peopledata'=> serialize(array('client'=>'','department'=>'','mobile'=>$callnumber)))); | ||
| 194 | } | ||
| 195 | } | ||
| 196 | |||
| 197 | if($kstychDialer['mDialerState']=="DialNext"||$kstychDialer['mDialerState']=="Progressive") | ||
| 198 | { | ||
| 199 | if($kstychCall['previewcrmid']!="")$users=$wakka->getPersons("id='".$kstychCall['previewcrmid']."' $roclientstr limit 1"); | ||
| 200 | else if($kstychCall['callnumber']!="")$users=$wakka->getPersons("mobile='".$kstychCall['callnumber']."' $roclientstr limit 1"); | ||
| 201 | else $users=$this->getCallSequencing(1); | ||
| 202 | } | ||
| 203 | |||
| 204 | $searchresult='<div style="clear:both"></div><div id=divworking></div><div style="clear:both"></div>'; | ||
| 205 | if(!empty($users)) | ||
| 206 | { | ||
| 207 | if(sizeof($users)>=1) | ||
| 208 | { | ||
| 209 | $ppldata=unserialize($users[0]['peopledata']); | ||
| 210 | if(!isset($ppldata['client']))$ppldata['client']=""; | ||
| 211 | if(!isset($ppldata['department']))$ppldata['department']=""; | ||
| 212 | |||
| 213 | if($callnumber==""||intval($callnumber)<=0)$callnumber=$ppldata['mobile']; | ||
| 214 | if($callnumber!=""&&intval($callnumber)>0) | ||
| 215 | { | ||
| 216 | $mastersdata=$wakka->getCompanyMaster($ppldata['client']); | ||
| 217 | $callerid="";if(!empty($mastersdata["DialerDID"]))$callerid=$mastersdata["DialerDID"]; | ||
| 218 | if($callerid=="")$callerid=Auth::user()->exten; | ||
| 219 | |||
| 220 | $calleridarr=explode(":",$callerid);$dspan="1"; | ||
| 221 | if(isset($calleridarr[1])){$callerid=$calleridarr[0];$dspan=$calleridarr[1];} | ||
| 222 | |||
| 223 | //see if user is online on this sipid | ||
| 224 | $sipid=Sipid::find($kstychDialer['phone']); | ||
| 225 | if($sipid&&$sipid->user==Auth::user()->id&&$sipid->status==1) | ||
| 226 | { | ||
| 227 | |||
| 228 | $dialline=Dialline::where("status","=","Free")->where("enabled","=","1"); | ||
| 229 | if($dspan!="")$dialline=$dialline->where('dspan','=',$dspan); | ||
| 230 | $dialline=$dialline->orderBy('updated_at','ASC')->first(); | ||
| 231 | |||
| 232 | if($dialline) | ||
| 233 | { | ||
| 234 | $dialline->status="Blocked"; | ||
| 235 | $dialline->save(); | ||
| 236 | |||
| 237 | $nowts=microtime(true)*1000; | ||
| 238 | |||
| 239 | //get ts_Wait | ||
| 240 | $userlog=UserLog::where('user_id','=',Auth::user()->id)->orderBy("id","DESC")->first(); | ||
| 241 | $ts_Wait=$userlog->getLastTs($sipid->id,$nowts); | ||
| 242 | $userlog->save(); | ||
| 243 | |||
| 244 | //start the call log | ||
| 245 | $crmcall=new CRMCall(); | ||
| 246 | $crmcall->number=$callnumber; | ||
| 247 | $crmcall->user_id=Auth::user()->id; | ||
| 248 | $crmcall->sipid_id=$sipid->id; | ||
| 249 | $crmcall->crm_id=$users[0]['id']; | ||
| 250 | $crmcall->client=$ppldata['client']; | ||
| 251 | $crmcall->department=$ppldata['department']; | ||
| 252 | $crmcall->state='New'; | ||
| 253 | $crmcall->type=$kstychDialer['mDialerState']; | ||
| 254 | $crmcall->dialline_id=$dialline->id; | ||
| 255 | |||
| 256 | $crmcall->setTs('ts_Wait',$ts_Wait); | ||
| 257 | $crmcall->setTs('ts_Call',$nowts); | ||
| 258 | |||
| 259 | $crmcall->did=$callerid; | ||
| 260 | |||
| 261 | $tdata=array(); | ||
| 262 | $crmcall->data=json_encode($tdata); | ||
| 263 | $crmcall->save(); | ||
| 264 | |||
| 265 | //$wakka->setPersonKey($crmcall->crm_id,"dialer_lastcall",date("Y-m-d H:i:s")); | ||
| 266 | |||
| 267 | //start actual calls | ||
| 268 | $ppldata['dialer_lastcall']=date("Y-m-d H:i:s"); | ||
| 269 | $preppldata['peopledata'] = serialize($ppldata); | ||
| 270 | $wakka->setPerson($ppldata['peopledata']['id'],$preppldata); | ||
| 271 | |||
| 272 | $newqueue=new Kqueue(); | ||
| 273 | $newqueue->userToConf($sipid); | ||
| 274 | $newqueue=new Kqueue(); | ||
| 275 | $newqueue->custToConf($sipid,$callnumber,$callerid,$crmcall,$dialline); | ||
| 276 | |||
| 277 | |||
| 278 | $searchresult.="<script>kSetDData('C','callid','".$crmcall->id."');kSetDData('C','crmid','".$users[0]['id']."');kSetDData('C','callnumber','$callnumber');showRecruit(\"".$users[0]['id']."\");</script>"; | ||
| 279 | |||
| 280 | |||
| 281 | |||
| 282 | $searchresult.="<div id=internalid_matchlist></div><script> | ||
| 283 | doAjax('record?action=quicksearch','maintextsearch_1_txt=".$users[0]['clientinternalid']."&maintextsearch_1_span=InternalID','internalid_matchlist','searchMutex', 'searchxhr','POST',function(retstr){ | ||
| 284 | if(retstr.responseText.indexOf('No Records Found!')>-1)$('#internalid_matchlist').html(''); | ||
| 285 | }); | ||
| 286 | </script>"; | ||
| 287 | |||
| 288 | |||
| 289 | return Response::make($searchresult); | ||
| 290 | } | ||
| 291 | else | ||
| 292 | { | ||
| 293 | return Response::make("<script>kstychCall['crmid']=0;kSetDData('C','previewcrmid','');simpleNotification('error','topRight','No Lines Free to Dial!');</script>"); | ||
| 294 | } | ||
| 295 | } | ||
| 296 | else | ||
| 297 | { | ||
| 298 | return Response::make("<script>kstychCall['crmid']=0;kSetDData('C','previewcrmid','');simpleNotification('error','topRight','You Are Not Connected!');</script>"); | ||
| 299 | } | ||
| 300 | } | ||
| 301 | else | ||
| 302 | { | ||
| 303 | $wakka->setPersonKey($users[0]['id'],"status","NoNumber"); | ||
| 304 | |||
| 305 | return Response::make($searchresult."<script>kstychCall['crmid']=0;kSetDData('C','previewcrmid','');simpleNotification('error','topRight','No Number in Record!');</script>"); | ||
| 306 | } | ||
| 307 | } | ||
| 308 | else | ||
| 309 | { | ||
| 310 | return Response::make($searchresult."<script>kstychCall['crmid']=0;kSetDData('C','previewcrmid','');simpleNotification('error','topRight','Multiple Records Found!');createSearchRecordDiv('dialersearchbox');</script>"); | ||
| 311 | } | ||
| 312 | } | ||
| 313 | else return Response::make($searchresult."<script>kstychCall['crmid']=0;kSetDData('C','previewcrmid','');simpleNotification('error','topRight','No Records Found!');createSearchRecordDiv('dialersearchbox');</script>"); | ||
| 314 | } | ||
| 315 | |||
| 316 | if($action=="addconfcall") | ||
| 317 | { | ||
| 318 | $retstr=""; | ||
| 319 | $callnumber=Input::get("confnumber"); | ||
| 320 | $callerid=""; | ||
| 321 | |||
| 322 | //see if user is online on this sipid | ||
| 323 | $sipid=Sipid::find($kstychDialer['phone']); | ||
| 324 | if($sipid&&$sipid->user==Auth::user()->id&&$sipid->status==1) | ||
| 325 | { | ||
| 326 | $oldcrmcall=CRMCall::find($kstychCall['callid']); | ||
| 327 | if($oldcrmcall) | ||
| 328 | { | ||
| 329 | $olddialline=Dialline::find($oldcrmcall->dialline_id); | ||
| 330 | $dspan="1";if($olddialline)$dspan=$olddialline->dspan; | ||
| 331 | |||
| 332 | $dialline=Dialline::where("status","=","Free")->where("enabled","=","1"); | ||
| 333 | if($dspan!="")$dialline=$dialline->where('dspan','=',$dspan); | ||
| 334 | $dialline=$dialline->orderBy('updated_at','ASC')->first(); | ||
| 335 | |||
| 336 | if($dialline) | ||
| 337 | { | ||
| 338 | |||
| 339 | $callerid=$oldcrmcall->did; | ||
| 340 | |||
| 341 | $dialline->status="Blocked"; | ||
| 342 | $dialline->save(); | ||
| 343 | |||
| 344 | $nowts=microtime(true)*1000; | ||
| 345 | |||
| 346 | //start the call log | ||
| 347 | $crmcall=new CRMCall(); | ||
| 348 | $crmcall->number=$callnumber; | ||
| 349 | $crmcall->user_id=Auth::user()->id; | ||
| 350 | $crmcall->sipid_id=$sipid->id; | ||
| 351 | $crmcall->crm_id=$oldcrmcall->crm_id; | ||
| 352 | $crmcall->client=$oldcrmcall->client; | ||
| 353 | $crmcall->department=$oldcrmcall->department; | ||
| 354 | $crmcall->state='New'; | ||
| 355 | $crmcall->userstatus='Conference'; | ||
| 356 | $crmcall->usersubstatus='Conference'; | ||
| 357 | $crmcall->type='Conference'; | ||
| 358 | $crmcall->dialline_id=$dialline->id; | ||
| 359 | |||
| 360 | $crmcall->setTs('ts_Wait',$nowts); | ||
| 361 | $crmcall->setTs('ts_Call',$nowts); | ||
| 362 | |||
| 363 | $crmcall->did=$callerid; | ||
| 364 | |||
| 365 | $tdata=array(); | ||
| 366 | $crmcall->data=json_encode($tdata); | ||
| 367 | $crmcall->save(); | ||
| 368 | |||
| 369 | |||
| 370 | |||
| 371 | //start actual calls | ||
| 372 | $newqueue=new Kqueue(); | ||
| 373 | $newqueue->userToConf($sipid); | ||
| 374 | $newqueue=new Kqueue(); | ||
| 375 | $newqueue->custToConf($sipid,$callnumber,$callerid,$crmcall,$dialline); | ||
| 376 | |||
| 377 | $retstr=$crmcall->id; | ||
| 378 | } | ||
| 379 | else | ||
| 380 | { | ||
| 381 | $retstr="Error : No Lines Free to Dial!"; | ||
| 382 | } | ||
| 383 | } | ||
| 384 | else | ||
| 385 | { | ||
| 386 | $retstr="Error : No calls to conference found!"; | ||
| 387 | } | ||
| 388 | } | ||
| 389 | else | ||
| 390 | { | ||
| 391 | $retstr="Error : You Are Not Connected!"; | ||
| 392 | } | ||
| 393 | |||
| 394 | return Response::make($retstr); | ||
| 395 | } | ||
| 396 | |||
| 397 | if($action=="hangupall") | ||
| 398 | { | ||
| 399 | $res=0; | ||
| 400 | $callid=intval($kstychCall['callid'])+0; | ||
| 401 | $crmcall=CRMCall::find($callid); | ||
| 402 | if($crmcall&&$crmcall->user_id==Auth::user()->id) | ||
| 403 | { | ||
| 404 | if($crmcall->state=='New'&&time()-strtotime($crmcall->created_at)<=3) | ||
| 405 | { | ||
| 406 | return Response::make("//Error : Dialstate is $crmcall->state"); | ||
| 407 | } | ||
| 408 | else | ||
| 409 | { | ||
| 410 | $dialline=Dialline::find($crmcall->dialline_id); | ||
| 411 | if($dialline) | ||
| 412 | { | ||
| 413 | if($crmcall->state!='Hangup') | ||
| 414 | { | ||
| 415 | $crmcall->hsource='User'; | ||
| 416 | $crmcall->save(); | ||
| 417 | } | ||
| 418 | |||
| 419 | //hangup | ||
| 420 | $newqueue=new Kqueue(); | ||
| 421 | $newqueue->hangupChannel($dialline); | ||
| 422 | if($kstychDialer["keeplocalconf"]=="0") | ||
| 423 | { | ||
| 424 | $newqueue=new Kqueue(); | ||
| 425 | $newqueue->hangupChannelS($kstychDialer['connection']['channel'],$dialline->server); | ||
| 426 | } | ||
| 427 | |||
| 428 | //hangup any conf calls | ||
| 429 | if(is_array($kstychCall['connections']))foreach($kstychCall['connections'] as $num=>$conn) | ||
| 430 | { | ||
| 431 | if(!empty($conn['callid'])) | ||
| 432 | { | ||
| 433 | $tcrmcall=CRMCall::find($conn['callid']); | ||
| 434 | if($tcrmcall) | ||
| 435 | { | ||
| 436 | $tdialline=Dialline::find($tcrmcall->dialline_id); | ||
| 437 | if($tdialline) | ||
| 438 | { | ||
| 439 | $newqueue=new Kqueue(); | ||
| 440 | $newqueue->hangupChannel($tdialline); | ||
| 441 | |||
| 442 | $res.=$conn['callid']."_"; | ||
| 443 | } | ||
| 444 | } | ||
| 445 | } | ||
| 446 | } | ||
| 447 | |||
| 448 | return Response::make("//SENT $res"); | ||
| 449 | } | ||
| 450 | else return Response::make("//Error : Dialline Not found ($callid)"); | ||
| 451 | } | ||
| 452 | } | ||
| 453 | else return Response::make("//Error : Call Not Found ($callid)"); | ||
| 454 | } | ||
| 455 | |||
| 456 | if($action=="closecall") | ||
| 457 | { | ||
| 458 | $callid=intval($kstychCall['callid'])+0; | ||
| 459 | $crmcall=CRMCall::find($callid); | ||
| 460 | if($crmcall&&$crmcall->user_id==Auth::user()->id) | ||
| 461 | { | ||
| 462 | $nowts=microtime(true)*1000; | ||
| 463 | |||
| 464 | if($kstychCall["usercallback"]!="") | ||
| 465 | { | ||
| 466 | $kstychCall["usercallback"]=date("Y-m-d H:i:s",strtotime($kstychCall["usercallback"].":00")+((Auth::user()->timezone)*60)); | ||
| 467 | } | ||
| 468 | |||
| 469 | $crmcall->setTs('ts_Close',$nowts); | ||
| 470 | |||
| 471 | $crmcall->userstatus =$kstychCall["userstatus"]; | ||
| 472 | $crmcall->usersubstatus =$kstychCall["usersubstatus"]; | ||
| 473 | $crmcall->usercallback =$kstychCall["usercallback"]; | ||
| 474 | $crmcall->attempt =$kstychCall["attempt"];//attempt dropdown value insert. | ||
| 475 | |||
| 476 | //preg_replace("/[^ \w]+/", "", $kstychCall["userremarks"]); | ||
| 477 | $crmcall->userremarks =preg_replace("/[^ \w]+/","", $kstychCall["userremarks"]); | ||
| 478 | |||
| 479 | |||
| 480 | |||
| 481 | $wakka = new KHRMSLib(); | ||
| 482 | |||
| 483 | if($crmcall->crm_id==0) | ||
| 484 | { | ||
| 485 | if($kstychCall["crmid"]>0) | ||
| 486 | { | ||
| 487 | $crmcall->crm_id=$kstychCall["crmid"]; | ||
| 488 | |||
| 489 | $temparr=$wakka->getPerson($crmcall->crm_id); | ||
| 490 | if(isset($temparr)&&isset($temparr['peopledata'])&&isset($temparr['peopledata']['client']))$crmcall->client=$temparr['peopledata']['client']; | ||
| 491 | } | ||
| 492 | } | ||
| 493 | |||
| 494 | if($crmcall->crm_id>0) | ||
| 495 | { | ||
| 496 | if(is_array($kstychCall["userdata"])) | ||
| 497 | { | ||
| 498 | foreach($kstychCall["userdata"] as $tcrmid=>$tuserdata) | ||
| 499 | { | ||
| 500 | if($tcrmid==$crmcall->crm_id) | ||
| 501 | { | ||
| 502 | $crmcall->userdata=json_encode($kstychCall["userdata"][$tcrmid]); | ||
| 503 | } | ||
| 504 | else | ||
| 505 | { | ||
| 506 | $empty="?"; | ||
| 507 | foreach($kstychCall["userdata"][$tcrmid] as $key=>$val) | ||
| 508 | { | ||
| 509 | if(trim($val)!=""){$empty="no";break;} | ||
| 510 | } | ||
| 511 | if($empty=="no") | ||
| 512 | { | ||
| 513 | $tcrmcall=new CRMCall(); | ||
| 514 | $tcrmcall->number=$crmcall->number; | ||
| 515 | $tcrmcall->user_id=Auth::user()->id; | ||
| 516 | $tcrmcall->sipid_id=$crmcall->sipid_id; | ||
| 517 | $tcrmcall->crm_id=$tcrmid; | ||
| 518 | $tcrmcall->client=$crmcall->client; | ||
| 519 | $tcrmcall->department=$crmcall->department; | ||
| 520 | $tcrmcall->state='Hangup'; | ||
| 521 | $tcrmcall->type='NoCall'; | ||
| 522 | $tcrmcall->userstatus='NoCall'; | ||
| 523 | $tcrmcall->usersubstatus='NoCall'; | ||
| 524 | //$tcrmcall->dialline_id=''; | ||
| 525 | |||
| 526 | $tcrmcall->setTs('ts_Wait',$nowts); | ||
| 527 | |||
| 528 | $tcrmcall->did=$crmcall->did; | ||
| 529 | |||
| 530 | $tdata=array(); | ||
| 531 | $tcrmcall->data=json_encode($tdata); | ||
| 532 | |||
| 533 | $tcrmcall->userdata=json_encode($kstychCall["userdata"][$tcrmid]); | ||
| 534 | |||
| 535 | $tcrmcall->save(); | ||
| 536 | |||
| 537 | |||
| 538 | |||
| 539 | $tuser=$wakka->getPerson($tcrmid); | ||
| 540 | $tuser['peopledata']["dialer_status"]=$kstychCall["userstatus"]; | ||
| 541 | $tuser['peopledata']["dialer_substatus"]=$kstychCall["usersubstatus"]; | ||
| 542 | $tuser['peopledata']["dialer_callback"]=$kstychCall["usercallback"]; | ||
| 543 | $tuser['peopledata']["dialer_remarks"]=str_replace("'","",kstychCall["userremarks"]); | ||
| 544 | $tuser['peopledata']["dialer_flag"]=$kstychCall["userflag"]; | ||
| 545 | |||
| 546 | $tuser["bttc"]=$kstychCall["bttc_day"].":".$kstychCall["bttc_hrs"]; | ||
| 547 | $tuser["serv_vs_prod"]=$kstychCall["serv_vs_prod"]; | ||
| 548 | $tuser["resolution"]=$kstychCall["resolution"]; | ||
| 549 | $tuser["satisfy"]=$kstychCall["satisfy"]; | ||
| 550 | $tuser["final_call_assess"]=$kstychCall["final_call_assess"]; | ||
| 551 | |||
| 552 | $tuser['peopledata']["dialer_userdata"]=$kstychCall["userdata"][$tcrmid]; | ||
| 553 | if($tuser['peopledata']["status"]=='New' || $tuser['peopledata']["status"]=='NEW')$tuser['peopledata']["status"]="Called"; | ||
| 554 | |||
| 555 | //for Supervisor Comments - By Manish | ||
| 556 | $tuser['agentcomments']=$kstychCall["agentcomments"]; | ||
| 557 | $tuser['supcomntid']=$kstychCall["supcomntid"]; | ||
| 558 | |||
| 559 | $tuser['peopledata']["dialer_lastcall"]=date("Y-m-d H:i:s"); | ||
| 560 | $wakka->setPerson($tcrmid,$tuser); | ||
| 561 | } | ||
| 562 | } | ||
| 563 | } | ||
| 564 | } | ||
| 565 | |||
| 566 | |||
| 567 | $user=$wakka->getPerson($crmcall->crm_id); | ||
| 568 | if($user['peopledata']['id']==$crmcall->crm_id) | ||
| 569 | { | ||
| 570 | $user['peopledata']["dialer_status"]=$kstychCall["userstatus"]; | ||
| 571 | $user['peopledata']["dialer_substatus"]=$kstychCall["usersubstatus"]; | ||
| 572 | $user['peopledata']["dialer_callback"]=$kstychCall["usercallback"]; | ||
| 573 | $user['peopledata']["dialer_remarks"]=str_replace("'","",$kstychCall["userremarks"]); | ||
| 574 | $user['peopledata']["dialer_flag"]=$kstychCall["userflag"]; | ||
| 575 | |||
| 576 | $user['peopledata']["bttc"]=$kstychCall["bttc_day"].":".$kstychCall["bttc_hrs"]; | ||
| 577 | $user['peopledata']["service_vs_product"]=$kstychCall["serv_vs_prod"]; | ||
| 578 | $user['peopledata']["resolution"]=$kstychCall["resolution"]; | ||
| 579 | $user['peopledata']["satisfaction"]=$kstychCall["satisfy"]; | ||
| 580 | $user['peopledata']["final_call_assessment"]=$kstychCall["final_call_assess"]; | ||
| 581 | |||
| 582 | // For Add Priority Snippet In Waterfall Bucket | ||
| 583 | if($user['peopledata']["priority"]) | ||
| 584 | $user['peopledata']["priority"] = ''; | ||
| 585 | |||
| 586 | if($user['peopledata']["mf_isa"]) | ||
| 587 | $user['peopledata']["mf_isa"] = ''; | ||
| 588 | |||
| 589 | $user['peopledata']["dialer_userdata"]=$kstychCall["userdata"][$crmcall->crm_id]; | ||
| 590 | $user['peopledata']["dialer_lastcall"]=date("Y-m-d H:i:s"); | ||
| 591 | if($user['peopledata']["status"]=='New' || $user['peopledata']["status"]=='NEW')$user['peopledata']["status"]="Called"; | ||
| 592 | //for Supervisor Comments - By Manish | ||
| 593 | $user['agentcomments']=$kstychCall["agentcomments"]; | ||
| 594 | $user['supcomntid']=$kstychCall["supcomntid"]; | ||
| 595 | |||
| 596 | $wakka->setPerson($crmcall->crm_id,$user); | ||
| 597 | |||
| 598 | //update groupid if this is not groupid TODO move to config | ||
| 599 | if($user['peopledata']['clientcode']!=$user['peopledata']['clientinternalid']) | ||
| 600 | { | ||
| 601 | $tusers=$wakka->getPersons(" clientinternalid='".$user['peopledata']['clientinternalid']."' limit 1"); | ||
| 602 | |||
| 603 | if(!empty($tusers)) | ||
| 604 | { | ||
| 605 | $tppldata=unserialize($tusers[0]['peopledata']); | ||
| 606 | if($tppldata['status']=='New')$wakka->setPersonKey($tusers[0]['id'],'status','Called'); | ||
| 607 | //if($tppldata['dialer_status']=='') //TODO Config | ||
| 608 | { | ||
| 609 | $wakka->setPersonKey($tusers[0]['id'],'dialer_status',$user['peopledata']["dialer_status"]); | ||
| 610 | $wakka->setPersonKey($tusers[0]['id'],'dialer_substatus',$user['peopledata']["dialer_substatus"]); | ||
| 611 | } | ||
| 612 | } | ||
| 613 | } | ||
| 614 | } | ||
| 615 | } | ||
| 616 | |||
| 617 | $crmcall->saveRecFileSize(); | ||
| 618 | $crmcall->save(); | ||
| 619 | |||
| 620 | /*if(Auth::user()->id=='92') | ||
| 621 | {*/ | ||
| 622 | $fullremark=preg_replace("/[^ \w]+/", "", $kstychCall['fullremark']); | ||
| 623 | |||
| 624 | DB::insert(DB::raw("insert into full_remark set call_id='$callid',fullremark='$fullremark'")); | ||
| 625 | //} | ||
| 626 | |||
| 627 | /*$fullremark=preg_replace("/[^ \w]+/", "", $kstychCall['fullremark']); | ||
| 628 | |||
| 629 | DB::table('full_remark')->insert(['call_id'=>$callid,'fullremark'=>$fullremark]);*/ | ||
| 630 | $userlog=UserLog::where('user_id','=',Auth::user()->id)->orderBy("id","DESC")->first(); | ||
| 631 | $userlog->getLastTs($crmcall->sipid_id,$nowts); | ||
| 632 | $userlog->save(); | ||
| 633 | } | ||
| 634 | |||
| 635 | return Response::make(""); | ||
| 636 | } | ||
| 637 | |||
| 638 | //WRAPUP - Done By Manish | ||
| 639 | if($action == 'wrapup') | ||
| 640 | { | ||
| 641 | $callid=intval($kstychCall['callid'])+0; | ||
| 642 | $crmcall=CRMCall::find($callid); | ||
| 643 | if($crmcall&&$crmcall->user_id==Auth::user()->id) | ||
| 644 | { | ||
| 645 | $nowts=microtime(true)*1000; | ||
| 646 | |||
| 647 | $userstatus=$kstychCall["userstatus"]; | ||
| 648 | $usersubstatus=$kstychCall["usersubstatus"]; | ||
| 649 | |||
| 650 | $userlog=UserLog::where('user_id','=',Auth::user()->id)->orderBy("id","DESC")->first(); | ||
| 651 | $userlog->getLastTs($crmcall->sipid_id,$nowts,$userstatus,$usersubstatus); | ||
| 652 | $userlog->save(); | ||
| 653 | } | ||
| 654 | |||
| 655 | return Response::make(""); | ||
| 656 | } | ||
| 657 | |||
| 658 | if($action=="kCallAction") | ||
| 659 | { | ||
| 660 | $actiontype=Input::get('actiontype'); | ||
| 661 | $conf=Input::get("conf"); | ||
| 662 | $channel=Input::get("channel"); | ||
| 663 | |||
| 664 | if($actiontype=="Hangup") | ||
| 665 | { | ||
| 666 | $tdialline=Dialline::where('channel','=',$channel)->first(); | ||
| 667 | if($tdialline) | ||
| 668 | { | ||
| 669 | $newqueue=new Kqueue(); | ||
| 670 | $newqueue->hangupChannel($tdialline); | ||
| 671 | } | ||
| 672 | } | ||
| 673 | |||
| 674 | if($actiontype=="MuteMic") | ||
| 675 | { | ||
| 676 | $tdialline=Dialline::where('channel','=',$channel)->first(); | ||
| 677 | if($tdialline) | ||
| 678 | { | ||
| 679 | $newqueue=new Kqueue(); | ||
| 680 | $newqueue->channelMuteMic($tdialline->channel,$tdialline->server); | ||
| 681 | } | ||
| 682 | } | ||
| 683 | if($actiontype=="MuteSpeaker") | ||
| 684 | { | ||
| 685 | $tdialline=Dialline::where('channel','=',$channel)->first(); | ||
| 686 | if($tdialline) | ||
| 687 | { | ||
| 688 | $newqueue=new Kqueue(); | ||
| 689 | $newqueue->channelMuteSpeaker($tdialline->channel,$tdialline->server); | ||
| 690 | } | ||
| 691 | } | ||
| 692 | if($actiontype=="UnMuteMic") | ||
| 693 | { | ||
| 694 | $tdialline=Dialline::where('channel','=',$channel)->first(); | ||
| 695 | if($tdialline) | ||
| 696 | { | ||
| 697 | $newqueue=new Kqueue(); | ||
| 698 | $newqueue->channelUnMuteMic($tdialline->channel,$tdialline->server); | ||
| 699 | } | ||
| 700 | } | ||
| 701 | if($actiontype=="UnMuteSpeaker") | ||
| 702 | { | ||
| 703 | $tdialline=Dialline::where('channel','=',$channel)->first(); | ||
| 704 | if($tdialline) | ||
| 705 | { | ||
| 706 | $newqueue=new Kqueue(); | ||
| 707 | $newqueue->channelUnMuteSpeaker($tdialline->channel,$tdialline->server); | ||
| 708 | } | ||
| 709 | } | ||
| 710 | |||
| 711 | return Response::make(""); | ||
| 712 | } | ||
| 713 | |||
| 714 | if($action=="dialerstate") | ||
| 715 | { | ||
| 716 | $ready=0;if($kstychDialer['mDialerState']=="Ready"&&$kstychCall['mCallState']=="Wait")$ready=1; | ||
| 717 | $nowts=microtime(true)*1000; | ||
| 718 | |||
| 719 | $sipid=Sipid::find($kstychDialer['phone']); | ||
| 720 | if($sipid&&$sipid->user==Auth::user()->id&&$sipid->status==1) | ||
| 721 | { | ||
| 722 | $sipid->ready=$ready; | ||
| 723 | $sipid->save(); | ||
| 724 | |||
| 725 | $userlog=UserLog::where('user_id','=',Auth::user()->id)->orderBy("id","DESC")->first(); | ||
| 726 | $userlog->getLastTs($sipid->id,$nowts,$kstychDialer['mDialerState'],$kstychDialer['mDialerSubState']); | ||
| 727 | $userlog->save(); | ||
| 728 | } | ||
| 729 | return Response::make(""); | ||
| 730 | } | ||
| 731 | |||
| 732 | if($action=="spychannel") | ||
| 733 | { | ||
| 734 | $sipid=Sipid::find($kstychDialer['phone']); | ||
| 735 | |||
| 736 | $tosip=Input::get('sipid'); | ||
| 737 | $mode=Input::get('mode'); | ||
| 738 | $modes=array('L'=>'2000','B'=>'2002','W'=>'2001'); | ||
| 739 | |||
| 740 | if($sipid&&$tosip!=""&&isset($modes[$mode])) | ||
| 741 | { | ||
| 742 | $newqueue=new Kqueue(); | ||
| 743 | $newqueue->sipOriginate($sipid,$modes[$mode].$tosip,"kstychDialerSpy"); | ||
| 744 | } | ||
| 745 | return Response::make(""); | ||
| 746 | } | ||
| 747 | |||
| 748 | if($action=="recarchive") | ||
| 749 | { | ||
| 750 | $type=Input::get("type"); | ||
| 751 | if($type=="stageupload") | ||
| 752 | { | ||
| 753 | return view("layout.module.dialer.recarchive",array()); | ||
| 754 | } | ||
| 755 | |||
| 756 | } | ||
| 757 | |||
| 758 | } | ||
| 759 | public function show($id) | ||
| 760 | { | ||
| 761 | /*if(time()>strtotime('14:30:00') || time()<strtotime('03:30:00')) | ||
| 762 | { | ||
| 763 | Session::flush(); | ||
| 764 | }*/ | ||
| 765 | |||
| 766 | if($id=="bucketdata") | ||
| 767 | { | ||
| 768 | $client=Input::get("client",""); | ||
| 769 | $bucket=Input::get("bucket"); | ||
| 770 | $currentstatus=Input::get("currentstatus"); | ||
| 771 | $legalstatus=Input::get("legalstatus"); | ||
| 772 | $page=intval(Input::get('page'));if($page<1)$page=1; | ||
| 773 | $skey=Input::get('skey'); | ||
| 774 | $stxt=Input::get('stxt'); | ||
| 775 | |||
| 776 | |||
| 777 | |||
| 778 | $skey=''; | ||
| 779 | /*if($skey=="ID")$key='id'; | ||
| 780 | if($skey=="FirstName")$key='firstname'; | ||
| 781 | if($skey=="LastName")$key='lastname'; | ||
| 782 | if($skey=="Client")$key='client'; | ||
| 783 | if($skey=="Mobile")$key='mobile'; | ||
| 784 | if($skey=="Email")$key='emailid'; | ||
| 785 | if($skey=="Passport")$key='passportno'; | ||
| 786 | if($skey=="IBAN")$key='ibannumber'; | ||
| 787 | if($skey=="Status")$key='currentstatus'; | ||
| 788 | if($skey=="PersonalID")$key='laborcardpersonalid'; | ||
| 789 | if($skey=="InternalID")$key='clientinternalid'; | ||
| 790 | if($skey=="ClientCode")$key='clientcode'; | ||
| 791 | if($key!=''&&$stxt!='')$key=" and $key like '$stxt%'";else $key="";*/ | ||
| 792 | |||
| 793 | /*if($stxt!='')$skey=" and (id like '$stxt%' or firstname like '$stxt%' or lastname like '$stxt%' or client like '$stxt%' or mobile like '$stxt%' or emailid like '$stxt%' or passportno like '$stxt%' or ibannumber like '$stxt%' or currentstatus like '$stxt%' or laborcardpersonalid like '$stxt%' or clientinternalid like '$stxt%' or clientcode like '$stxt%')";else $skey="";*/ | ||
| 794 | |||
| 795 | if($stxt!='')$skey=" and (firstname like '$stxt%' or mobile like '$stxt%' or clientcode like '$stxt%')";else $skey=""; | ||
| 796 | |||
| 797 | $wakka = new KHRMSLib(); | ||
| 798 | $rows=""; | ||
| 799 | |||
| 800 | $owclientstr=array(); | ||
| 801 | $oclientlst=$wakka->clientsOwnerRWAccess(); | ||
| 802 | |||
| 803 | if(!empty($oclientlst))foreach($oclientlst as $tclnt)if($tclnt!="") | ||
| 804 | { | ||
| 805 | $owclientstr[]="'$tclnt'"; | ||
| 806 | if($client=="")$client=$tclnt; | ||
| 807 | } | ||
| 808 | if(!empty($owclientstr))$owclientstr="and client in (".implode(",",$owclientstr).")";else $owclientstr=""; | ||
| 809 | if($client!="")$owclientstr="and client='$client'"; | ||
| 810 | |||
| 811 | $roclientstr=array();$didlinesstr=array();if(Auth::user()->exten!="")$didlinesstr[]=Auth::user()->exten; | ||
| 812 | $roclientlst=$wakka->clientsReadAccess(); | ||
| 813 | |||
| 814 | if(!empty($roclientlst))foreach($roclientlst as $tclnt)if($tclnt!="") | ||
| 815 | { | ||
| 816 | $roclientstr[]="'$tclnt'"; | ||
| 817 | if($client=="")$client=$tclnt; | ||
| 818 | |||
| 819 | $mastersdata=$wakka->getCompanyMaster($tclnt); | ||
| 820 | if(!empty($mastersdata["DialerDID"]))$didlinesstr[]=$mastersdata["DialerDID"]; | ||
| 821 | } | ||
| 822 | foreach($didlinesstr as $k=>$dids) | ||
| 823 | { | ||
| 824 | $didarr=explode(":",$dids); | ||
| 825 | $didlinesstr[$k]=$didarr[0]; | ||
| 826 | } | ||
| 827 | |||
| 828 | if(!empty($roclientstr))$roclientstr="and client in (".implode(",",$roclientstr).")";else $roclientstr=""; | ||
| 829 | $roclientstrAll=$roclientstr; | ||
| 830 | if($client!="")$roclientstr="and client='$client'"; | ||
| 831 | |||
| 832 | $bl=20; | ||
| 833 | $bs=($page-1)*$bl; | ||
| 834 | |||
| 835 | $dbres=array(); | ||
| 836 | if($bucket=="CurrentQueue")$dbres=$this->getCallSequencing(20); | ||
| 837 | else if($bucket=="Priority")$dbres=$wakka->getPersons("priority in (1,2,3,4,5,6,7,8,9,10) $owclientstr limit $bs,$bl"); | ||
| 838 | else if($bucket=="TotalData")$dbres=$wakka->getPersons("1=1 and currentstatus='$currentstatus' and legalstatus='$legalstatus' and status!='Noqueue' $owclientstr limit $bs,$bl"); | ||
| 839 | else if($bucket=="SearchData")$dbres=$wakka->getPersons("1=1 $roclientstrAll $skey limit $bs,$bl"); | ||
| 840 | else if($bucket=="NotCalled")$dbres=$wakka->getPersons("status='New' and currentstatus='$currentstatus' and legalstatus='$legalstatus' $owclientstr limit $bs,$bl"); | ||
| 841 | else if($bucket=="Called")$dbres=$wakka->getPersons("status='Called' $owclientstr limit $bs,$bl"); | ||
| 842 | else if($bucket=="Priority")$dbres=$wakka->getPersons("status='Priority' $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"); | ||
| 844 | else if($bucket=="Flagged-Notcalled")$dbres=$wakka->getPersons("mf_isa='VIP' and currentstatus='$currentstatus' and legalstatus='$legalstatus' $owclientstr limit $bs,$bl"); | ||
| 845 | |||
| 846 | else if($bucket=="MissedCalls") | ||
| 847 | { | ||
| 848 | $udidlinesstr = array(); | ||
| 849 | foreach($didlinesstr as $didlinestr){ | ||
| 850 | $didlinestrArr=explode(":",$didlinestr); | ||
| 851 | $udidlinesstr[] = substr($didlinestrArr[0], env('didnumber')); | ||
| 852 | } | ||
| 853 | |||
| 854 | $mc=CRMCall::where('userstatus','=','InboundDROP')->where('created_at','>',date('Y-m-d H:i:s',time()-(7*24*60*60))); | ||
| 855 | $mc=$mc->where(function ($query) use($roclientlst,$udidlinesstr){ | ||
| 856 | $query->orWhereIn('client',$roclientlst)->orWhereIn('did',$udidlinesstr); | ||
| 857 | }); | ||
| 858 | $mc=$mc->get(); | ||
| 859 | |||
| 860 | $number_list=array(); | ||
| 861 | |||
| 862 | foreach($mc as $key=>$tcall){ | ||
| 863 | |||
| 864 | $tccal=substr($tcall->number,-10); | ||
| 865 | $mc_number=CRMCall::where('userstatus','!=','InboundDROP')->where ('created_at','>',$tcall->created_at)->where('number','like',"%".$tccal."%")->orderBy("id","DESC")->first(); | ||
| 866 | |||
| 867 | |||
| 868 | |||
| 869 | $mccount= count($mc_number); | ||
| 870 | if($mccount==0){ | ||
| 871 | $number_list[] = $tcall->number; | ||
| 872 | } | ||
| 873 | } | ||
| 874 | |||
| 875 | if(count($number_list) > 0) { | ||
| 876 | $lcalls=DB::select("SELECT * FROM crmcalls where id in (SELECT max(id) FROM crmcalls WHERE number IN ('" . implode("','", $number_list). "') GROUP BY number )"); | ||
| 877 | |||
| 878 | foreach($lcalls as $lcall) | ||
| 879 | { | ||
| 880 | if($lcall->userstatus=="InboundDROP") | ||
| 881 | { | ||
| 882 | if($lcall->crm_id>0) | ||
| 883 | { | ||
| 884 | $reccrm_ids[] = "'".$lcall->crm_id."'"; | ||
| 885 | } | ||
| 886 | else | ||
| 887 | { | ||
| 888 | $recordValue = DB::table('records')->where('mobile','=',substr($lcall->number,-10))->get(); | ||
| 889 | if($recordValue){ | ||
| 890 | $reccrm_ids[] = "'".$recordValue[0]->id."'"; | ||
| 891 | } | ||
| 892 | else{ | ||
| 893 | $dbres[]=array('client'=>$lcall->client,'mobile'=>substr($lcall->number,-10),'callid'=>$lcall->id); | ||
| 894 | } | ||
| 895 | } | ||
| 896 | } | ||
| 897 | } | ||
| 898 | |||
| 899 | if(!empty($reccrm_ids)) | ||
| 900 | { | ||
| 901 | $recids_str = implode(",", $reccrm_ids); | ||
| 902 | $rec=$wakka->getPersons("id in ($recids_str)"); | ||
| 903 | $dbres = array_merge($dbres,$rec); | ||
| 904 | } | ||
| 905 | } | ||
| 906 | |||
| 907 | |||
| 908 | } | ||
| 909 | else if($bucket=="CallsToday")$dbres=$wakka->getPersons("dialer_lastcall>='".date("Y-m-d 00:00:00",time()+((Auth::user()->timezone)*60))."' $owclientstr limit $bs,$bl"); | ||
| 910 | else if($bucket=="CallsMonth")$dbres=$wakka->getPersons("dialer_lastcall>='".date("Y-m-01 00:00:00",time()+((Auth::user()->timezone)*60))."' $owclientstr limit $bs,$bl"); | ||
| 911 | |||
| 912 | else | ||
| 913 | { | ||
| 914 | $currentstatus2='';$legalstatus2=''; | ||
| 915 | if($currentstatus!="")$currentstatus2=" and currentstatus='$currentstatus' "; | ||
| 916 | if($legalstatus!="")$legalstatus2=" and legalstatus='$legalstatus' "; | ||
| 917 | $dbres=$wakka->getPersons("dialer_status='$bucket' $currentstatus2 $legalstatus2 $owclientstr limit $bs,$bl"); | ||
| 918 | } | ||
| 919 | |||
| 920 | $ccountsummary=array();$k=1;//Log::info(count($dbres)); | ||
| 921 | foreach($dbres as $dbrow) | ||
| 922 | { | ||
| 923 | if(isset($dbrow['callid'])) | ||
| 924 | { | ||
| 925 | $lastcall=CRMCall::find($dbrow['callid']); | ||
| 926 | $callcntmonth=CRMCall::where("number","=",$dbrow['mobile'])->where("created_at",">=",date("Y-m-01 H:i:s",time()+((Auth::user()->timezone)*60)))->count(); | ||
| 927 | } | ||
| 928 | else if($dbrow['id']>0) | ||
| 929 | { | ||
| 930 | $lastcall=CRMCall::where("crm_id","=",$dbrow['id'])->where('type','!=','Conference')->orderBy("id","DESC")->first(); | ||
| 931 | $callcntmonth=CRMCall::where("crm_id","=",$dbrow['id'])->where("created_at",">=",date("Y-m-01 H:i:s",time()+((Auth::user()->timezone)*60)))->count(); | ||
| 932 | } | ||
| 933 | |||
| 934 | if(!isset($ccountsummary[$callcntmonth]))$ccountsummary[$callcntmonth]=0; | ||
| 935 | $ccountsummary[$callcntmonth]++; | ||
| 936 | |||
| 937 | $type="";$lasttime="";$dispo="";$subdispo="";$followup="";$remarks="";$did=""; | ||
| 938 | |||
| 939 | if($lastcall) | ||
| 940 | { | ||
| 941 | $type=$lastcall->type; | ||
| 942 | $lasttime=$lastcall->created_at;if($lasttime=="0000-00-00 00:00:00")$lasttime="";else $lasttime=date("d-M-y H:i:s",strtotime($lasttime)-((Auth::user()->timezone)*60)); | ||
| 943 | $dispo=$lastcall->userstatus; | ||
| 944 | $subdispo=$lastcall->usersubstatus; | ||
| 945 | $followup=$dbrow[dialer_callback];if($followup=="0000-00-00 00:00:00")$followup="";else $followup=date("d-M-y H:i:s",strtotime($followup)-(Auth::user()->timezone*60)); | ||
| 946 | $remarks=$lastcall->userremarks; | ||
| 947 | $did=$lastcall->did; | ||
| 948 | } | ||
| 949 | |||
| 950 | if(stristr($dbrow[firstname], "Potential") != "") | ||
| 951 | { | ||
| 952 | $rows.="<tr style='background-color: #59ee7c;color:#ffffff;font-weight: bolder;font-size:115%'>"; | ||
| 953 | } | ||
| 954 | else | ||
| 955 | { | ||
| 956 | $rows.="<tr>"; | ||
| 957 | } | ||
| 958 | if($bucket=="MissedCalls"){ | ||
| 959 | $type="Inbound"; | ||
| 960 | } | ||
| 961 | |||
| 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> | ||
| 977 | <td title='$dbrow[id]'>$dbrow[client]</td> | ||
| 978 | <td title=''>$dbrow[clientinternalid]</td> | ||
| 979 | <td title=''>$dbrow[clientcode]</td> | ||
| 980 | <td>$dbrow[firstname]</td>"; | ||
| 981 | |||
| 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> | ||
| 993 | <td>$lasttime</td> | ||
| 994 | <td title='$subdispo :: $remarks'>$dispo</td> | ||
| 995 | <td>$followup</td> | ||
| 996 | <td>$dbrow[status]</td> | ||
| 997 | <td>C".str_pad($callcntmonth,3, "0", STR_PAD_LEFT)."</td> | ||
| 998 | <!--<td><a href=# class='' onclick='dialerQuickOpen(\"$dbrow[id]\",\"$dbrow[mobile]\",\"Progressive\",\"\",0);return false;'><i class='fa fa-phone'></i></a> <a href=# class='' onclick='dialerQuickOpen(\"$dbrow[id]\",\"$dbrow[mobile]\",\"DialNext\",\"\",0);return false;'><i class='fa fa-file'></i></a></td>--> | ||
| 999 | <td>$did</td> | ||
| 1000 | </tr>"; | ||
| 1001 | $k++; | ||
| 1002 | } | ||
| 1003 | |||
| 1004 | $summarycounts=""; | ||
| 1005 | $message_display=""; | ||
| 1006 | ksort($ccountsummary); | ||
| 1007 | foreach($ccountsummary as $key=>$val) | ||
| 1008 | { | ||
| 1009 | $summarycounts.="<span class='label label-small label-default'>C".str_pad($key,3, "0", STR_PAD_LEFT)." : $val</span> "; | ||
| 1010 | } | ||
| 1011 | //Dispodelay running message on PB's Screen Code by Prashant Jadhav | ||
| 1012 | $pb_message=DB::table('supervisor_message')->where('sup_id','=',Auth::user()->supervisor)->where('agents','like','%'.Auth::user()->username.'%')->where('status','like','%'.Auth::user()->username."-Unread".'%')->get(); | ||
| 1013 | |||
| 1014 | //echo "<pre>".print_r($pb_message)."</pre>"; | ||
| 1015 | if(is_array($pb_message)) | ||
| 1016 | { | ||
| 1017 | foreach ($pb_message as $messagekey => $messageval) | ||
| 1018 | { | ||
| 1019 | $message_display .="<marquee style='font-size:115%;font-weight: bolder;color:#3B2092'>".$messageval->message."</marquee>"; | ||
| 1020 | } | ||
| 1021 | } | ||
| 1022 | |||
| 1023 | $data="<h5>Bucket : $bucket</h5>$message_display<hr>$summarycounts<br>"; | ||
| 1024 | //code end | ||
| 1025 | |||
| 1026 | $data.="<a class='pre_nxt' href='#' onclick=\"dialerLoadData('$bucket','$currentstatus','$legalstatus',".($page-1).",$('#dialerbkey').html(),$('#dialerbtxt').val());return false;\"><< Previous Page</a> | ||
| 1027 | <a class='pre_nxt' href='#' onclick=\"dialerLoadData('$bucket','$currentstatus','$legalstatus',".($page+1).",$('#dialerbkey').html(),$('#dialerbtxt').val());return false;\">Next Page >></a> | ||
| 1028 | |||
| 1029 | <span class=pull-right> | ||
| 1030 | <input type=text class='form-control pull-left' style='width:200px' placeholder='search..' value='$stxt' id=dialerbtxt> | ||
| 1031 | <button class='btn btn-default pull-right' onclick=\"dialerLoadData('SearchData','','',1,$('#dialerbkey').html(),$('#dialerbtxt').val());return false\"> Search </button> | ||
| 1032 | </span>"; | ||
| 1033 | |||
| 1034 | $data.=" | ||
| 1035 | <div style='clear:both'></div> | ||
| 1036 | |||
| 1037 | <table class='table '> | ||
| 1038 | <thead> | ||
| 1039 | <tr> | ||
| 1040 | <th></th> | ||
| 1041 | <th></th> | ||
| 1042 | <th>Campaign</th> | ||
| 1043 | <th>Group_ID</th> | ||
| 1044 | <th>Cust_ID</th> | ||
| 1045 | <th>Name</th> | ||
| 1046 | <th>Number</th> | ||
| 1047 | <th>Type</th> | ||
| 1048 | <th>LastCall</th> | ||
| 1049 | <th>Disposition</th> | ||
| 1050 | <th>NextFollowup</th> | ||
| 1051 | <th>Status</th> | ||
| 1052 | <th>Count</th> | ||
| 1053 | <!--<th></th>--> | ||
| 1054 | <th>DID</th> | ||
| 1055 | </tr> | ||
| 1056 | </thead> | ||
| 1057 | <tbody> | ||
| 1058 | $rows | ||
| 1059 | </table>"; | ||
| 1060 | return Response::make($data); | ||
| 1061 | } | ||
| 1062 | if($id=="reports") | ||
| 1063 | { | ||
| 1064 | return view("layout.module.dialer.reports",array()); | ||
| 1065 | } | ||
| 1066 | if($id=="campaigns") | ||
| 1067 | { | ||
| 1068 | return view("layout.module.dialer.campaigns",array()); | ||
| 1069 | } | ||
| 1070 | if($id=="calllog") | ||
| 1071 | { | ||
| 1072 | return view("layout.module.dialer.calllog",array()); | ||
| 1073 | } | ||
| 1074 | if($id=="agentreport") | ||
| 1075 | { | ||
| 1076 | return view("layout.module.dialer.agentreport",array()); | ||
| 1077 | } | ||
| 1078 | if($id=="campreport") | ||
| 1079 | { | ||
| 1080 | return view("layout.module.dialer.campreport",array()); | ||
| 1081 | } | ||
| 1082 | if($id=="statusreport") | ||
| 1083 | { | ||
| 1084 | return view("layout.module.dialer.statusreport",array()); | ||
| 1085 | } | ||
| 1086 | if($id=="questionnaire") | ||
| 1087 | { | ||
| 1088 | return view("layout.module.dialer.questairereport",array()); | ||
| 1089 | } | ||
| 1090 | if($id=="callmanagement") | ||
| 1091 | { | ||
| 1092 | return view("layout.module.dialer.callmanagementreport",array()); | ||
| 1093 | } | ||
| 1094 | if($id=="supmessages") | ||
| 1095 | { | ||
| 1096 | return view("layout.module.dialer.supmessagesreport",array()); | ||
| 1097 | } | ||
| 1098 | |||
| 1099 | if($id=='playrecfile') | ||
| 1100 | { | ||
| 1101 | $calllog=CRMCallArchive::find(Input::get("calllog")); | ||
| 1102 | |||
| 1103 | $file=$calllog->getRecFilePath(); | ||
| 1104 | $ext=$calllog->getRecFileExt(); | ||
| 1105 | if($ext=='wav') | ||
| 1106 | { | ||
| 1107 | header('Content-type: audio/x-wav'); | ||
| 1108 | header("Content-length: ".filesize($file)); | ||
| 1109 | header("Content-disposition: attachment; filename=\"".basename($file)."\""); | ||
| 1110 | readfile("$file"); | ||
| 1111 | } | ||
| 1112 | if($ext=='gsm') | ||
| 1113 | { | ||
| 1114 | $out=Input::get("out","ogg"); | ||
| 1115 | |||
| 1116 | header("Content-type: audio/x-$out"); | ||
| 1117 | header("Content-disposition: attachment; filename=\"".basename($file).".$out\""); | ||
| 1118 | $descriptorspec = array(0 => array("pipe", "r"),1 => array("pipe", "w"),2 => array("pipe", "w")); | ||
| 1119 | $process = proc_open( "/usr/bin/sox $file /tmp/".basename($file).".$out", $descriptorspec, $pipes ); | ||
| 1120 | while( stream_get_contents( $pipes[1] )); | ||
| 1121 | header("Content-length: ".filesize("/tmp/".basename($file).".$out")); | ||
| 1122 | readfile("/tmp/".basename($file).".$out");unlink("/tmp/".basename($file).".$out"); | ||
| 1123 | fclose( $pipes[1] ); | ||
| 1124 | fclose( $pipes[2] ); | ||
| 1125 | } | ||
| 1126 | return; | ||
| 1127 | } | ||
| 1128 | if($id=="liveusers") | ||
| 1129 | { | ||
| 1130 | return view("layout.module.dialer.liveusers",array()); | ||
| 1131 | } | ||
| 1132 | if($id=="recarchive") | ||
| 1133 | { | ||
| 1134 | return view("layout.module.dialer.recarchive",array()); | ||
| 1135 | } | ||
| 1136 | if($id=="recqc") | ||
| 1137 | { | ||
| 1138 | return view("layout.module.dialer.recqc",array()); | ||
| 1139 | } | ||
| 1140 | //relationship area dropdown option fetched code. code by Yashwant Sir | ||
| 1141 | if($id=="relationship") | ||
| 1142 | { | ||
| 1143 | $type=Input::get("type"); | ||
| 1144 | $id=Input::get("id"); | ||
| 1145 | if($type != "" && $id != ""){ | ||
| 1146 | if($type == "category"){ | ||
| 1147 | $output = "<option value=''>Select Category</option>"; | ||
| 1148 | $category = DB::table("relationship_category")->where("service_id",$id)->where("title","!=","")->where("status","=","Active")->get(); | ||
| 1149 | foreach($category as $cat){ | ||
| 1150 | $output .= "<option value='".$cat->id."'>".$cat->title."</option>"; | ||
| 1151 | } | ||
| 1152 | return $output; | ||
| 1153 | }else if($type == "subCategory"){ | ||
| 1154 | $output = "<option value=''>Select Sub Category</option>"; | ||
| 1155 | $subCategory = DB::table("relationship_sub_category")->where("category_id",$id)->where("title","!=","")->where("status","=","Active")->get(); | ||
| 1156 | foreach($subCategory as $cat){ | ||
| 1157 | $output .= "<option value='".$cat->title."'>".$cat->title."</option>"; | ||
| 1158 | } | ||
| 1159 | return $output; | ||
| 1160 | } | ||
| 1161 | } | ||
| 1162 | } | ||
| 1163 | //pending missed call alert for supervisors code by Prashant Jadhav | ||
| 1164 | if($id=="missedcallalert") | ||
| 1165 | { | ||
| 1166 | |||
| 1167 | |||
| 1168 | $user=Auth::user(); | ||
| 1169 | if($user->usertype=="Supervisor"||$user->usertype=="Admin") | ||
| 1170 | { | ||
| 1171 | |||
| 1172 | $dbres=array(); | ||
| 1173 | $wakka = new KHRMSLib(); | ||
| 1174 | $rows=""; | ||
| 1175 | |||
| 1176 | $owclientstr=array(); | ||
| 1177 | $oclientlst=$wakka->clientsOwnerRWAccess(); | ||
| 1178 | |||
| 1179 | |||
| 1180 | |||
| 1181 | if(!empty($oclientlst))foreach($oclientlst as $tclnt)if($tclnt!="") | ||
| 1182 | { | ||
| 1183 | $owclientstr[]="'$tclnt'"; | ||
| 1184 | if($client=="")$client=$tclnt; | ||
| 1185 | } | ||
| 1186 | if(!empty($owclientstr))$owclientstr="and client in (".implode(",",$owclientstr).")";else $owclientstr=""; | ||
| 1187 | if($client!="")$owclientstr="and client='$client'"; | ||
| 1188 | |||
| 1189 | $roclientstr=array();$didlinesstr=array();if(Auth::user()->exten!="")$didlinesstr[]=Auth::user()->exten; | ||
| 1190 | $roclientlst=$wakka->clientsReadAccess(); | ||
| 1191 | |||
| 1192 | if(!empty($roclientlst))foreach($roclientlst as $tclnt)if($tclnt!="") | ||
| 1193 | { | ||
| 1194 | $roclientstr[]="'$tclnt'"; | ||
| 1195 | if($client=="")$client=$tclnt; | ||
| 1196 | |||
| 1197 | $mastersdata=$wakka->getCompanyMaster($tclnt); | ||
| 1198 | if(!empty($mastersdata["DialerDID"]))$didlinesstr[]=$mastersdata["DialerDID"]; | ||
| 1199 | } | ||
| 1200 | foreach($didlinesstr as $k=>$dids) | ||
| 1201 | { | ||
| 1202 | $didarr=explode(":",$dids); | ||
| 1203 | $didlinesstr[$k]=$didarr[0]; | ||
| 1204 | } | ||
| 1205 | |||
| 1206 | if(!empty($roclientstr))$roclientstr="and client in (".implode(",",$roclientstr).")";else $roclientstr=""; | ||
| 1207 | $roclientstrAll=$roclientstr; | ||
| 1208 | if($client!="")$roclientstr="and client='$client'"; | ||
| 1209 | if(!empty($mastersdata["DialerDID"]))$didlinesstr[]=$mastersdata["DialerDID"]; | ||
| 1210 | $udidlinesstr = array(); | ||
| 1211 | foreach($didlinesstr as $didlinestr){ | ||
| 1212 | $didlinestrArr=explode(":",$didlinestr); | ||
| 1213 | $udidlinesstr[] = substr($didlinestrArr[0], env('didnumber')); | ||
| 1214 | } | ||
| 1215 | |||
| 1216 | /*$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))); | ||
| 1218 | $mc=$mc->where(function ($query) use($roclientlst,$udidlinesstr){ | ||
| 1219 | $query->orWhereIn('client',$roclientlst)->orWhereIn('did',$udidlinesstr); | ||
| 1220 | }); | ||
| 1221 | $mc=$mc->get(); | ||
| 1222 | |||
| 1223 | $number_list=array(); | ||
| 1224 | |||
| 1225 | foreach($mc as $key=>$tcall){ | ||
| 1226 | |||
| 1227 | $tccal=substr($tcall->number,-10); | ||
| 1228 | $mc_number=CRMCall::where('userstatus','!=','InboundDROP')->where ('created_at','>',$tcall->created_at)->where('number','like',"%".$tccal."%")->orderBy("id","DESC")->first(); | ||
| 1229 | |||
| 1230 | $mccount= count($mc_number); | ||
| 1231 | if($mccount==0){ | ||
| 1232 | $number_list[] = $tcall->number; | ||
| 1233 | } | ||
| 1234 | } | ||
| 1235 | |||
| 1236 | if(count($number_list) > 0) | ||
| 1237 | { | ||
| 1238 | $lcalls=DB::select("SELECT * FROM crmcalls where id in (SELECT max(id) FROM crmcalls WHERE number IN ('" . implode("','", $number_list). "') GROUP BY number )"); | ||
| 1239 | |||
| 1240 | foreach($lcalls as $lcall) | ||
| 1241 | { | ||
| 1242 | if($lcall->userstatus=="InboundDROP") | ||
| 1243 | { | ||
| 1244 | if($lcall->crm_id>0) | ||
| 1245 | { | ||
| 1246 | $reccrm_ids[] = "'".$lcall->crm_id."'"; | ||
| 1247 | } | ||
| 1248 | else | ||
| 1249 | { | ||
| 1250 | $recordValue = DB::table('records')->where('mobile','=',substr($lcall->number,-10))->get(); | ||
| 1251 | if($recordValue){ | ||
| 1252 | $reccrm_ids[] = "'".$recordValue[0]->id."'"; | ||
| 1253 | } | ||
| 1254 | else{ | ||
| 1255 | $dbres[]=array('client'=>$lcall->client,'mobile'=>substr($lcall->number,-10),'callid'=>$lcall->id,'datetime'=>$lcall->updated_at); | ||
| 1256 | } | ||
| 1257 | } | ||
| 1258 | } | ||
| 1259 | } | ||
| 1260 | |||
| 1261 | if(!empty($reccrm_ids)) | ||
| 1262 | { | ||
| 1263 | $recids_str = implode(",", $reccrm_ids); | ||
| 1264 | $rec=$wakka->getPersons("id in ($recids_str)"); | ||
| 1265 | $dbres = array_merge($dbres,$rec); | ||
| 1266 | |||
| 1267 | $mobile=""; | ||
| 1268 | foreach ($dbres as $dbrow) | ||
| 1269 | { | ||
| 1270 | |||
| 1271 | $mobile.= $dbrow['mobile']."-".$dbrow['client']."-".$dbrow['datetime'].","; | ||
| 1272 | } | ||
| 1273 | return "<script>alert('Missed call is pending for :-----".$mobile." !')</script>"; | ||
| 1274 | //echo "<pre>".print_r($dbres)."</pre>"; | ||
| 1275 | } | ||
| 1276 | else | ||
| 1277 | { | ||
| 1278 | return; | ||
| 1279 | } | ||
| 1280 | } | ||
| 1281 | } | ||
| 1282 | } | ||
| 1283 | |||
| 1284 | return view("layout.module.dialer.$id",array()); | ||
| 1285 | } | ||
| 1286 | public function edit($id) | ||
| 1287 | { | ||
| 1288 | |||
| 1289 | } | ||
| 1290 | public function update($id) | ||
| 1291 | { | ||
| 1292 | |||
| 1293 | } | ||
| 1294 | public function destroy($id) | ||
| 1295 | { | ||
| 1296 | // | ||
| 1297 | } | ||
| 1298 | |||
| 1299 | |||
| 1300 | public function dashboard() | ||
| 1301 | { | ||
| 1302 | //echo "OK"; | ||
| 1303 | } | ||
| 1304 | |||
| 1305 | private function getCallSequencing($limit) | ||
| 1306 | { | ||
| 1307 | $wakka = new KHRMSLib(); | ||
| 1308 | |||
| 1309 | $roclientstr=array();$didlinesstr=array(); | ||
| 1310 | if(Auth::user()->exten!="")$didlinesstr[]=Auth::user()->exten; | ||
| 1311 | $oclientlst=$wakka->clientsOwnerRWAccess(); | ||
| 1312 | if(!empty($oclientlst))foreach($oclientlst as $tclnt)if($tclnt!="") | ||
| 1313 | { | ||
| 1314 | $roclientstr[]="'$tclnt'"; | ||
| 1315 | |||
| 1316 | $mastersdata=$wakka->getCompanyMaster($tclnt); | ||
| 1317 | if(!empty($mastersdata["DialerDID"]))$didlinesstr[]=$mastersdata["DialerDID"]; | ||
| 1318 | } | ||
| 1319 | |||
| 1320 | $mroclientstr = $roclientstr; | ||
| 1321 | |||
| 1322 | $client=Input::get("client"); | ||
| 1323 | |||
| 1324 | if(!empty($roclientstr))$roclientstr="client='$client'";else $roclientstr=""; | ||
| 1325 | //if(!empty($roclientstr))$roclientstr="client in (".implode(",",$roclientstr).")";else $roclientstr=""; | ||
| 1326 | |||
| 1327 | $users=array(); | ||
| 1328 | |||
| 1329 | if(Auth::user()->usertype!="User"){$tusers=array();return $tusers;} | ||
| 1330 | |||
| 1331 | // if(!empty($roclientstr))$roclientstr="client=''";else $roclientstr=""; | ||
| 1332 | |||
| 1333 | $clientDetails=$wakka->getPersons("$roclientstr order by dialer_lastcall asc"); | ||
| 1334 | |||
| 1335 | if($limit>0) | ||
| 1336 | { | ||
| 1337 | $tusers = array_filter($clientDetails, function($var){ | ||
| 1338 | return ($var['dialer_status']=='InboundDROP'); | ||
| 1339 | }); | ||
| 1340 | |||
| 1341 | $l=1; | ||
| 1342 | foreach($tusers as $tuser){ | ||
| 1343 | if(!isset($users[$tuser['id']])){ | ||
| 1344 | $users[$tuser['id']]=$tuser; | ||
| 1345 | $l++; | ||
| 1346 | |||
| 1347 | if($l>$limit) | ||
| 1348 | break; | ||
| 1349 | } | ||
| 1350 | } | ||
| 1351 | |||
| 1352 | $limit=$limit-sizeof($tusers); | ||
| 1353 | } | ||
| 1354 | |||
| 1355 | if($limit>0) | ||
| 1356 | { | ||
| 1357 | if(!empty($didlinesstr)) | ||
| 1358 | { | ||
| 1359 | $udidlinesstr = array(); | ||
| 1360 | foreach($didlinesstr as $didlinestr){ | ||
| 1361 | $didlinestrArr=explode(":",$didlinestr); | ||
| 1362 | $udidlinesstr[] = substr($didlinestrArr[0], -8); | ||
| 1363 | } | ||
| 1364 | $tusers=array(); | ||
| 1365 | |||
| 1366 | $mc=CRMCall::where('userstatus','=','InboundDROP')->where('created_at','>',date('Y-m-d H:i:s',time()-(7*24*60*60))); | ||
| 1367 | $mc=$mc->where(function ($query) use($mroclientstr,$udidlinesstr){ | ||
| 1368 | $query->orWhereIn('client',$mroclientstr)->orWhereIn('did',$udidlinesstr); | ||
| 1369 | }); | ||
| 1370 | $mc=$mc->get(); | ||
| 1371 | |||
| 1372 | $number_list=array(); | ||
| 1373 | foreach($mc as $key=>$tcall){ | ||
| 1374 | |||
| 1375 | $tccal=substr($tcall->number,-10); | ||
| 1376 | $mc_number=CRMCall::where('userstatus','!=','InboundDROP') | ||
| 1377 | ->where('created_at','>',$tcall->created_at) | ||
| 1378 | ->where('number','like',"%".$tccal."%") | ||
| 1379 | ->orderBy("id","DESC") | ||
| 1380 | ->first(); | ||
| 1381 | |||
| 1382 | $mccount= count($mc_number); | ||
| 1383 | if($mccount==0){ | ||
| 1384 | $number_list[] = $tcall->number; | ||
| 1385 | } | ||
| 1386 | } | ||
| 1387 | |||
| 1388 | $othermissedcalls=DB::select("SELECT * FROM crmcalls where id in (SELECT max(id) FROM crmcalls WHERE number IN | ||
| 1389 | ('" . implode("','", $number_list). "') GROUP BY number )"); | ||
| 1390 | |||
| 1391 | // $othermissedcalls=CRMCall::where('crm_id','=','0')->where('userstatus','=','InboundDROP')->where('did','like','%'.$didlinesstr.'%')->where('created_at','>',date('Y-m-d H:i:s',time()-(7*24*60*60)))->take($limit)->groupBy('number')->get(); | ||
| 1392 | |||
| 1393 | /* Changes For Missed Call - 14/02/17 */ | ||
| 1394 | |||
| 1395 | foreach($othermissedcalls as $othermissedcall) | ||
| 1396 | { | ||
| 1397 | $crmnumber = substr($othermissedcall->number, -10); | ||
| 1398 | |||
| 1399 | $tcall=array_filter($clientDetails, function($var) use ($crmnumber){ | ||
| 1400 | return ($var['mobile']==$crmnumber); | ||
| 1401 | }); | ||
| 1402 | |||
| 1403 | if($tcall) | ||
| 1404 | { | ||
| 1405 | $tcall = array_values($tcall); | ||
| 1406 | $tcall = $tcall[0]; | ||
| 1407 | |||
| 1408 | if(isset($tcall['id']) || $tcall['dialer_status']=="InboundDROP") | ||
| 1409 | { | ||
| 1410 | $tusers[$othermissedcall->id]=array('id'=>$tcall['id'],'mobile'=>$othermissedcall->number,'client'=>$tcall['client'],'clientcode'=>$tcall['clientcode'],'clientinternalid'=>$tcall['clientinternalid'], 'firstname'=>$tcall['firstname'],'callid'=>$othermissedcall->id); | ||
| 1411 | } | ||
| 1412 | } | ||
| 1413 | |||
| 1414 | } | ||
| 1415 | |||
| 1416 | /* Changes For Missed Call - 14/02/17 */ | ||
| 1417 | |||
| 1418 | foreach($tusers as $tuser)if(!isset($users[$tuser['id']]))$users[$tuser['id']]=$tuser; | ||
| 1419 | |||
| 1420 | $limit=$limit-sizeof($tusers); | ||
| 1421 | } | ||
| 1422 | } | ||
| 1423 | |||
| 1424 | |||
| 1425 | if($limit>0) | ||
| 1426 | { | ||
| 1427 | $tusers = array_filter($clientDetails, function($var){ | ||
| 1428 | return (strtotime($var['dialer_callback'])<strtotime(date('Y-m-d H:i:s',time()+(15*60)))&&$var['dialer_status']=='Contacted - FollowUp - Specific'); | ||
| 1429 | }); | ||
| 1430 | |||
| 1431 | $l=1; | ||
| 1432 | foreach($tusers as $tuser){ | ||
| 1433 | if(!isset($users[$tuser['id']])){ | ||
| 1434 | $users[$tuser['id']]=$tuser; | ||
| 1435 | $l++; | ||
| 1436 | |||
| 1437 | if($l>$limit) | ||
| 1438 | break; | ||
| 1439 | } | ||
| 1440 | } | ||
| 1441 | |||
| 1442 | $limit=$limit-sizeof($tusers); | ||
| 1443 | } | ||
| 1444 | |||
| 1445 | // if(Auth::user()->id=="49"){ | ||
| 1446 | |||
| 1447 | for($p=10;$p>0;$p--) | ||
| 1448 | { | ||
| 1449 | if($limit>0) | ||
| 1450 | { | ||
| 1451 | $tusers = array_filter($clientDetails, function($var) use ($p){ | ||
| 1452 | return (($var['priority']==$p)&&$var['mobile']!=''); | ||
| 1453 | }, ARRAY_FILTER_USE_BOTH); | ||
| 1454 | |||
| 1455 | if(!empty($tusers)) | ||
| 1456 | { | ||
| 1457 | $l=1; | ||
| 1458 | foreach($tusers as $tuser){ | ||
| 1459 | if(!isset($users[$tuser['id']])){ | ||
| 1460 | $users[$tuser['id']]=$tuser; | ||
| 1461 | $l++; | ||
| 1462 | |||
| 1463 | if($l>$limit) | ||
| 1464 | break; | ||
| 1465 | } | ||
| 1466 | } | ||
| 1467 | |||
| 1468 | $limit=$limit-sizeof($tusers); | ||
| 1469 | } | ||
| 1470 | } | ||
| 1471 | } | ||
| 1472 | |||
| 1473 | // } | ||
| 1474 | if($limit>0) | ||
| 1475 | { | ||
| 1476 | $tusers = array_filter($clientDetails, function($var){ | ||
| 1477 | return ($var['status']=='New'&&$var['mobile']!=''); | ||
| 1478 | }); | ||
| 1479 | |||
| 1480 | $l=1; | ||
| 1481 | foreach($tusers as $tuser){ | ||
| 1482 | if(!isset($users[$tuser['id']])){ | ||
| 1483 | $users[$tuser['id']]=$tuser; | ||
| 1484 | $l++; | ||
| 1485 | |||
| 1486 | if($l>$limit) | ||
| 1487 | break; | ||
| 1488 | } | ||
| 1489 | } | ||
| 1490 | |||
| 1491 | $limit=$limit-sizeof($tusers); | ||
| 1492 | } | ||
| 1493 | |||
| 1494 | if($limit>0) | ||
| 1495 | { | ||
| 1496 | $tusers = array_filter($clientDetails, function($var){ | ||
| 1497 | return ($var['status']=='Called'&&$var['dialer_status']=='Not Contactable - Non Human Voice'); | ||
| 1498 | }); | ||
| 1499 | |||
| 1500 | $l=1; | ||
| 1501 | foreach($tusers as $tuser){ | ||
| 1502 | if(!isset($users[$tuser['id']])){ | ||
| 1503 | $users[$tuser['id']]=$tuser; | ||
| 1504 | $l++; | ||
| 1505 | |||
| 1506 | if($l>$limit) | ||
| 1507 | break; | ||
| 1508 | } | ||
| 1509 | } | ||
| 1510 | |||
| 1511 | $limit=$limit-sizeof($tusers); | ||
| 1512 | } | ||
| 1513 | |||
| 1514 | if($limit>0) | ||
| 1515 | { | ||
| 1516 | $tusers = array_filter($clientDetails, function($var){ | ||
| 1517 | return ($var['status']=='Called'&&$var['dialer_status']=='Not Contactable - Human Voice'); | ||
| 1518 | }); | ||
| 1519 | $l=1; | ||
| 1520 | foreach($tusers as $tuser){ | ||
| 1521 | if(!isset($users[$tuser['id']])){ | ||
| 1522 | $users[$tuser['id']]=$tuser; | ||
| 1523 | $l++; | ||
| 1524 | |||
| 1525 | if($l>$limit) | ||
| 1526 | break; | ||
| 1527 | } | ||
| 1528 | } | ||
| 1529 | |||
| 1530 | $limit=$limit-sizeof($tusers); | ||
| 1531 | } | ||
| 1532 | |||
| 1533 | if($limit>0) | ||
| 1534 | { | ||
| 1535 | $tusers = array_filter($clientDetails, function($var){ | ||
| 1536 | return ($var['status']=='Called'&&$var['dialer_status']=='Contacted - Follow-Up - Generic'); | ||
| 1537 | }); | ||
| 1538 | $l=1; | ||
| 1539 | foreach($tusers as $tuser){ | ||
| 1540 | if(!isset($users[$tuser['id']])){ | ||
| 1541 | $users[$tuser['id']]=$tuser; | ||
| 1542 | $l++; | ||
| 1543 | |||
| 1544 | if($l>$limit) | ||
| 1545 | break; | ||
| 1546 | } | ||
| 1547 | } | ||
| 1548 | |||
| 1549 | $limit=$limit-sizeof($tusers); | ||
| 1550 | } | ||
| 1551 | |||
| 1552 | if($limit>0) | ||
| 1553 | { | ||
| 1554 | $tusers = array_filter($clientDetails, function($var){ | ||
| 1555 | return ($var['status']=='Called'&&$var['dialer_status']=='AUTOWRAPUP'); | ||
| 1556 | }); | ||
| 1557 | $l=1; | ||
| 1558 | foreach($tusers as $tuser){ | ||
| 1559 | if(!isset($users[$tuser['id']])){ | ||
| 1560 | $users[$tuser['id']]=$tuser; | ||
| 1561 | $l++; | ||
| 1562 | |||
| 1563 | if($l>$limit) | ||
| 1564 | break; | ||
| 1565 | } | ||
| 1566 | } | ||
| 1567 | |||
| 1568 | $limit=$limit-sizeof($tusers); | ||
| 1569 | } | ||
| 1570 | |||
| 1571 | $tusers=array();foreach($users as $tuser)$tusers[]=$tuser; | ||
| 1572 | return $tusers; | ||
| 1573 | } | ||
| 1574 | } |
-
Please register or sign in to post a comment