campaign : bulk upload and assign desposition to campaign
Showing
7 changed files
with
556 additions
and
74 deletions
| ... | @@ -8,8 +8,8 @@ use App\Services\FormBuilder; | ... | @@ -8,8 +8,8 @@ use App\Services\FormBuilder; |
| 8 | use Illuminate\Http\Request; | 8 | use Illuminate\Http\Request; |
| 9 | use Response; | 9 | use Response; |
| 10 | use App\Models\User; | 10 | use App\Models\User; |
| 11 | use Excel; | 11 | use SimpleXLSX; |
| 12 | use File; | 12 | use App\Jobs\KHRMSLib; |
| 13 | 13 | ||
| 14 | class CampaignController extends Controller { | 14 | class CampaignController extends Controller { |
| 15 | 15 | ||
| ... | @@ -40,6 +40,9 @@ class CampaignController extends Controller { | ... | @@ -40,6 +40,9 @@ class CampaignController extends Controller { |
| 40 | $username[] = $alluser->username; | 40 | $username[] = $alluser->username; |
| 41 | } | 41 | } |
| 42 | 42 | ||
| 43 | /* $dispositionList=DB::table('hrms_masters')->select('*')->where('status','=','Active', )->get();*/ | ||
| 44 | |||
| 45 | |||
| 43 | //$data['client'] = $client; | 46 | //$data['client'] = $client; |
| 44 | if(isset($username))$data['username'] = $username; | 47 | if(isset($username))$data['username'] = $username; |
| 45 | return view("layout.module.campaign.index",$data); | 48 | return view("layout.module.campaign.index",$data); |
| ... | @@ -51,52 +54,42 @@ class CampaignController extends Controller { | ... | @@ -51,52 +54,42 @@ class CampaignController extends Controller { |
| 51 | 54 | ||
| 52 | public function store(Request $request) | 55 | public function store(Request $request) |
| 53 | { | 56 | { |
| 54 | $action = Input::get("action"); | ||
| 55 | |||
| 56 | // if($action=="createCampaign") | ||
| 57 | // { | ||
| 58 | // $this->validate($request,[ | ||
| 59 | // 'campaignName' => 'required|alpha_dash', | ||
| 60 | // ]); | ||
| 61 | |||
| 62 | // $campaignName = Input::get("campaignName"); | ||
| 63 | 57 | ||
| 64 | // if($campaignName != ""){ | 58 | $action = Input::get("action"); |
| 65 | // Campaign::insert(["mkey"=>$campaignName,"mtype"=>"company"]); | 59 | if($action == 'upload'){ |
| 66 | // $data['campaignDetails'] = Campaign::where("mtype","=","company")->where("mkey","=",$campaignName)->first(); | ||
| 67 | // return view("layout.module.campaign.campaign",$data); | ||
| 68 | // }else{ | ||
| 69 | // return "<script>simpleNotification('error','topRight','Campaign name should not be blank.');</script><br/><p class='text-danger text-center'>Campaign name should not be blank.</p>"; | ||
| 70 | // } | ||
| 71 | // } | ||
| 72 | |||
| 73 | // if($action=="buildForm") | ||
| 74 | // { | ||
| 75 | // $rawData = Input::get("rawData"); | ||
| 76 | // $fb = new FormBuilder(); | ||
| 77 | // $output = $fb->buildForm($rawData); | ||
| 78 | // return $output; | ||
| 79 | // } | ||
| 80 | |||
| 81 | // if($action=="dataUpload") | ||
| 82 | // { | ||
| 83 | // return view("layout.module.campaign.campaignTabData"); | ||
| 84 | // } | ||
| 85 | |||
| 86 | if($action == 'upload'){ | ||
| 87 | try{ | ||
| 88 | if($request->hasFile('file')){ | 60 | if($request->hasFile('file')){ |
| 89 | $extension = File::extension($request->file->getClientOriginalName()); | 61 | include_once(app_path().'/lib/phpexcel/PHPExcel.php'); |
| 90 | if ($extension == "xlsx" || $extension == "xls" || $extension == "csv") { | 62 | include(app_path().'/lib/simplexlsx-master/simplexlsx.class.php'); |
| 91 | 63 | ||
| 92 | $path = $request->file->getRealPath(); | 64 | $path = $request->file->getRealPath(); |
| 93 | $data = Excel::load($path, function($reader) { | 65 | $objSimpleXLSX = SimpleXLSX::parse($path); |
| 94 | })->get(); | 66 | |
| 95 | if(!empty($data) && $data->count()){ | 67 | $objWorksheet = $objSimpleXLSX->rows(); |
| 96 | 68 | $highestColumn = count($objWorksheet[0]); | |
| 97 | foreach ($data as $key => $value) { | 69 | $highestrow=count($objWorksheet); |
| 98 | 70 | ||
| 99 | if(!empty($value->name)){ | 71 | for($i=0;$i<$highestrow;$i++) |
| 72 | { | ||
| 73 | $excelarray[$i]=array(); | ||
| 74 | for ($head = 0; $head < $highestColumn; $head++) | ||
| 75 | { | ||
| 76 | if($i==0) | ||
| 77 | { | ||
| 78 | $keys[$head]=trim($objWorksheet[$i][$head]); | ||
| 79 | |||
| 80 | } | ||
| 81 | else | ||
| 82 | { | ||
| 83 | $excelarray[$i][$keys[$head]]=trim($objWorksheet[$i][$head]); | ||
| 84 | } | ||
| 85 | } | ||
| 86 | } | ||
| 87 | |||
| 88 | for($i=1;$i<$highestrow;$i++) | ||
| 89 | { | ||
| 90 | if($excelarray[$i]["name"]!="" || $excelarray[$i]["name"]!="0" || $excelarray[$i]["name"]!=0 ) | ||
| 91 | { | ||
| 92 | if(!empty($excelarray[$i]["name"])){ | ||
| 100 | $campaign = Input::get("selectCampaignField"); | 93 | $campaign = Input::get("selectCampaignField"); |
| 101 | 94 | ||
| 102 | if($campaign=="all"){ | 95 | if($campaign=="all"){ |
| ... | @@ -109,7 +102,7 @@ class CampaignController extends Controller { | ... | @@ -109,7 +102,7 @@ class CampaignController extends Controller { |
| 109 | $campaign=substr($campaign, 0, -1); | 102 | $campaign=substr($campaign, 0, -1); |
| 110 | } | 103 | } |
| 111 | 104 | ||
| 112 | $usercampaign=User::where('username','=',trim($value->name))->first(); | 105 | $usercampaign=User::where('username','=',trim($excelarray[$i]["name"]))->first(); |
| 113 | $campaignList =$usercampaign->clients.",".$campaign; | 106 | $campaignList =$usercampaign->clients.",".$campaign; |
| 114 | $data=json_decode($usercampaign->data,true); | 107 | $data=json_decode($usercampaign->data,true); |
| 115 | if(isset($data['hrmsdata'])) | 108 | if(isset($data['hrmsdata'])) |
| ... | @@ -128,24 +121,148 @@ class CampaignController extends Controller { | ... | @@ -128,24 +121,148 @@ class CampaignController extends Controller { |
| 128 | $usercampaign->data=$data; | 121 | $usercampaign->data=$data; |
| 129 | $usercampaign->save(); | 122 | $usercampaign->save(); |
| 130 | } | 123 | } |
| 131 | 124 | } | |
| 132 | } | 125 | } |
| 133 | 126 | ||
| 134 | } | 127 | } |
| 135 | |||
| 136 | } | ||
| 137 | } | ||
| 138 | }catch(Exception $e) { | ||
| 139 | Log::error($e->getMessage()); | ||
| 140 | } | 128 | } |
| 141 | } | 129 | |
| 130 | if($action == 'bulkupload'){ | ||
| 131 | if($request->hasFile('file')){ | ||
| 132 | include_once(app_path().'/lib/phpexcel/PHPExcel.php'); | ||
| 133 | include(app_path().'/lib/simplexlsx-master/simplexlsx.class.php'); | ||
| 134 | |||
| 135 | $path = $request->file->getRealPath(); | ||
| 136 | $objSimpleXLSX = SimpleXLSX::parse($path); | ||
| 137 | |||
| 138 | |||
| 139 | $objWorksheet = $objSimpleXLSX->rows(); | ||
| 140 | $highestColumn = count($objWorksheet[0]); | ||
| 141 | $highestrow=count($objWorksheet); | ||
| 142 | |||
| 143 | |||
| 144 | $dbUsers=DB::table('users')->select('username', 'data')->where('status','=','Active')->get(); | ||
| 145 | $dbCampaigns=DB::table('hrms_masters')->select('mkey')->where('status','=','Active')->get(); | ||
| 146 | |||
| 147 | $activeUser = array(); | ||
| 148 | $activeCampaign = array(); | ||
| 149 | $activeUserData = array(); | ||
| 150 | foreach ($dbUsers as $key => $dbUser){ | ||
| 151 | $activeUser[] = $dbUser->username; | ||
| 152 | $activeUserData[$dbUser->username] = $dbUser->data; | ||
| 153 | } | ||
| 154 | foreach ($dbCampaigns as $key => $dbCampaign)$activeCampaign[] = $dbCampaign->mkey; | ||
| 155 | |||
| 156 | $campaigns = array(); | ||
| 157 | $users = array(); | ||
| 158 | for($row=0;$row<$highestrow;$row++) | ||
| 159 | { | ||
| 160 | if($row!=0 && !empty(trim($objWorksheet[$row][0]))){ | ||
| 161 | |||
| 162 | if(in_array(trim($objWorksheet[$row][0]), $activeCampaign) && in_array(trim($objWorksheet[$row][1]), $activeUser)){ | ||
| 163 | |||
| 164 | $users[trim($objWorksheet[$row][1])][] = $objWorksheet[$row][0]; | ||
| 165 | } | ||
| 166 | } | ||
| 167 | } | ||
| 168 | |||
| 169 | foreach ($users as $userName => $campaigns) { | ||
| 170 | $campaignList = implode(',', $campaigns); | ||
| 171 | |||
| 172 | $data=json_decode($activeUserData[$userName],true); | ||
| 173 | |||
| 174 | if(isset($data['hrmsdata'])) | ||
| 175 | { | ||
| 176 | $hrmsdata=unserialize($data['hrmsdata']); | ||
| 177 | $hrmsdata['clientsownerlist'] = $campaignList; | ||
| 178 | $data['hrmsdata']=serialize($hrmsdata); | ||
| 179 | }else | ||
| 180 | { | ||
| 181 | $hrmsdata['clientsownerlist'] = $campaignList; | ||
| 182 | $data['hrmsdata']=serialize($hrmsdata); | ||
| 183 | } | ||
| 184 | $data=json_encode($data); | ||
| 185 | |||
| 186 | DB::table('users')->where('username', $userName)->update(['clients'=>$campaignList, 'data' => $data]); | ||
| 187 | } | ||
| 188 | } | ||
| 189 | } | ||
| 190 | |||
| 191 | // if($action=="createCampaign") | ||
| 192 | // { | ||
| 193 | // $this->validate($request,[ | ||
| 194 | // 'campaignName' => 'required|alpha_dash', | ||
| 195 | // ]); | ||
| 196 | |||
| 197 | // $campaignName = Input::get("campaignName"); | ||
| 198 | |||
| 199 | // if($campaignName != ""){ | ||
| 200 | // Campaign::insert(["mkey"=>$campaignName,"mtype"=>"company"]); | ||
| 201 | // $data['campaignDetails'] = Campaign::where("mtype","=","company")->where("mkey","=",$campaignName)->first(); | ||
| 202 | // return view("layout.module.campaign.campaign",$data); | ||
| 203 | // }else{ | ||
| 204 | // return "<script>simpleNotification('error','topRight','Campaign name should not be blank.');</script><br/><p class='text-danger text-center'>Campaign name should not be blank.</p>"; | ||
| 205 | // } | ||
| 206 | // } | ||
| 207 | |||
| 208 | // if($action=="buildForm") | ||
| 209 | // { | ||
| 210 | // $rawData = Input::get("rawData"); | ||
| 211 | // $fb = new FormBuilder(); | ||
| 212 | // $output = $fb->buildForm($rawData); | ||
| 213 | // return $output; | ||
| 214 | // } | ||
| 215 | |||
| 216 | // if($action=="dataUpload") | ||
| 217 | // { | ||
| 218 | // return view("layout.module.campaign.campaignTabData"); | ||
| 219 | // } | ||
| 142 | } | 220 | } |
| 143 | 221 | ||
| 144 | public function show($id) | 222 | public function show($id) |
| 145 | { | 223 | { |
| 146 | if($id=="show") | 224 | if($id=="show") |
| 147 | { | 225 | { |
| 226 | $gthis = new KHRMSLib(); | ||
| 148 | $campaign = Input::get("campaign"); | 227 | $campaign = Input::get("campaign"); |
| 228 | |||
| 229 | $mastersdata=$gthis->getCompanyMaster($campaign); | ||
| 230 | $disposition = array(); | ||
| 231 | if(empty($mastersdata['dialerDispoList']))$mastersdata['dialerDispoList']=$gthis->HRCoreVars['dialerDispoList']; | ||
| 232 | $dispoarr=explode("~",$mastersdata['dialerDispoList']); | ||
| 233 | foreach($dispoarr as $dispo) | ||
| 234 | { | ||
| 235 | if(!empty($dispo)) | ||
| 236 | { | ||
| 237 | $dispoprts=explode("|",$dispo); | ||
| 238 | if(sizeof($dispoprts)>=3) | ||
| 239 | { | ||
| 240 | $disposition[$dispoprts[1]] = $dispoprts[2]; | ||
| 241 | $dispositionCode[$dispoprts[1]] = $dispoprts[0]; | ||
| 242 | /*$data.="dialerdispoarray['$dispoprts[1]']='$dispoprts[2]'; | ||
| 243 | dispoClassArray['$dispoprts[0]']='$dispoprts[1]';";*/ | ||
| 244 | } | ||
| 245 | } | ||
| 246 | } | ||
| 247 | $data['disposition'] = $disposition; | ||
| 248 | $data['dispositionCode'] = $dispositionCode; | ||
| 249 | |||
| 250 | |||
| 251 | $dispositionList=DB::table('hrms_masters')->select('*')->where('status','=','Active')->where("mkey","=",$campaign)->where("mtype","=",'coreconfig')->first(); | ||
| 252 | |||
| 253 | $dispolist=explode("~",$dispositionList->mvalue); | ||
| 254 | $dispositionList = array(); | ||
| 255 | foreach ($dispolist as $key => $dispo) { | ||
| 256 | if(!empty($dispo)) | ||
| 257 | { | ||
| 258 | $dispoprts=explode("|",$dispo); | ||
| 259 | $dispositionList[$dispoprts[1]]= $dispoprts[2]; | ||
| 260 | } | ||
| 261 | } | ||
| 262 | |||
| 263 | $data['dispositionList'] = $dispositionList; | ||
| 264 | |||
| 265 | |||
| 149 | if($campaign != ""){ | 266 | if($campaign != ""){ |
| 150 | //this condition for getting all campaign data | 267 | //this condition for getting all campaign data |
| 151 | if($campaign == "all") | 268 | if($campaign == "all") |
| ... | @@ -166,6 +283,7 @@ class CampaignController extends Controller { | ... | @@ -166,6 +283,7 @@ class CampaignController extends Controller { |
| 166 | $data['queryLogs'] = DB::table("campaign_query")->where('campaign', '=', $campaign)->get(); | 283 | $data['queryLogs'] = DB::table("campaign_query")->where('campaign', '=', $campaign)->get(); |
| 167 | // $data['dataList'] = DB::table("records")->select(DB::Raw('list_id, count(*) as recordCount'))->where("client","=",$campaign)->groupBy('list_id')->get(); | 284 | // $data['dataList'] = DB::table("records")->select(DB::Raw('list_id, count(*) as recordCount'))->where("client","=",$campaign)->groupBy('list_id')->get(); |
| 168 | $userassignedcampign=DB::table('users')->select('username','clients')->whereRaw(' FIND_IN_SET(?,clients)', [$campaign])->get(); | 285 | $userassignedcampign=DB::table('users')->select('username','clients')->whereRaw(' FIND_IN_SET(?,clients)', [$campaign])->get(); |
| 286 | //$scheduledCampaign = Campaign::where("mtype","=","company")->where("mkey","=",$campaign)->first(); | ||
| 169 | return view("layout.module.campaign.campaign",$data,compact('userassignedcampign')); | 287 | return view("layout.module.campaign.campaign",$data,compact('userassignedcampign')); |
| 170 | } | 288 | } |
| 171 | 289 | ||
| ... | @@ -185,7 +303,6 @@ class CampaignController extends Controller { | ... | @@ -185,7 +303,6 @@ class CampaignController extends Controller { |
| 185 | }else{ | 303 | }else{ |
| 186 | $queryConditions = '1'; | 304 | $queryConditions = '1'; |
| 187 | } | 305 | } |
| 188 | |||
| 189 | $queryInCondition = Input::get("queryInCondition"); | 306 | $queryInCondition = Input::get("queryInCondition"); |
| 190 | if($queryInCondition != 'null'){ | 307 | if($queryInCondition != 'null'){ |
| 191 | $queryInCondition = str_replace('"', "'", $queryInCondition); | 308 | $queryInCondition = str_replace('"', "'", $queryInCondition); |
| ... | @@ -195,21 +312,23 @@ class CampaignController extends Controller { | ... | @@ -195,21 +312,23 @@ class CampaignController extends Controller { |
| 195 | }else{ | 312 | }else{ |
| 196 | $queryInCondition = ''; | 313 | $queryInCondition = ''; |
| 197 | } | 314 | } |
| 198 | |||
| 199 | $queryLimit = Input::get("queryLimit"); | 315 | $queryLimit = Input::get("queryLimit"); |
| 200 | $queryOffset = Input::get("queryOffset"); | 316 | $queryOffset = Input::get("queryOffset"); |
| 201 | $checkedValue = Input::get("checkedValue"); | 317 | $checkedValue = Input::get("checkedValue"); |
| 202 | $fields = explode(",", $querySelect); | 318 | $fields = explode(",", $querySelect); |
| 203 | 319 | ||
| 204 | $i = 1; $output = ''; | 320 | $i = 1; $output = ''; |
| 205 | try { | 321 | try { |
| 322 | |||
| 206 | 323 | ||
| 207 | if($campaign=="All") | 324 | if($campaign=="All") |
| 208 | { | 325 | { |
| 209 | $selQuery = "SELECT $querySelect FROM records WHERE $queryConditions $queryInCondition LIMIT $queryLimit OFFSET $queryOffset"; | 326 | // $selQuery = "SELECT $querySelect FROM records WHERE $queryConditions LIMIT $queryLimit OFFSET $queryOffset"; |
| 327 | $selQuery = "SELECT $querySelect FROM records WHERE $queryConditions $queryInCondition LIMIT $queryLimit OFFSET $queryOffset"; | ||
| 210 | $sqlQuery = DB::select($selQuery); | 328 | $sqlQuery = DB::select($selQuery); |
| 211 | }else | 329 | }else |
| 212 | { | 330 | { |
| 331 | //$selQuery = "SELECT $querySelect FROM records WHERE client = '$campaign' AND $queryConditions LIMIT $queryLimit OFFSET $queryOffset"; | ||
| 213 | $selQuery = "SELECT $querySelect FROM records WHERE client = '$campaign' AND $queryConditions $queryInCondition LIMIT $queryLimit OFFSET $queryOffset"; | 332 | $selQuery = "SELECT $querySelect FROM records WHERE client = '$campaign' AND $queryConditions $queryInCondition LIMIT $queryLimit OFFSET $queryOffset"; |
| 214 | $sqlQuery = DB::select($selQuery); | 333 | $sqlQuery = DB::select($selQuery); |
| 215 | } | 334 | } |
| ... | @@ -228,6 +347,7 @@ class CampaignController extends Controller { | ... | @@ -228,6 +347,7 @@ class CampaignController extends Controller { |
| 228 | $output .= "<p class='text-danger'>".$ex->getMessage()."</p>"; | 347 | $output .= "<p class='text-danger'>".$ex->getMessage()."</p>"; |
| 229 | return $output; | 348 | return $output; |
| 230 | } | 349 | } |
| 350 | |||
| 231 | if(count($sqlQuery)){ | 351 | if(count($sqlQuery)){ |
| 232 | $output .= '<div style="overflow-x:auto;"><table class="table table-bordered"><thead><tr><th class="text-center">#</th>'; | 352 | $output .= '<div style="overflow-x:auto;"><table class="table table-bordered"><thead><tr><th class="text-center">#</th>'; |
| 233 | foreach ($fields as $key) { | 353 | foreach ($fields as $key) { |
| ... | @@ -303,7 +423,6 @@ class CampaignController extends Controller { | ... | @@ -303,7 +423,6 @@ class CampaignController extends Controller { |
| 303 | }else{ | 423 | }else{ |
| 304 | $queryConditions = '1'; | 424 | $queryConditions = '1'; |
| 305 | } | 425 | } |
| 306 | |||
| 307 | $queryInCondition = Input::get("queryInCondition"); | 426 | $queryInCondition = Input::get("queryInCondition"); |
| 308 | if($queryInCondition != 'null'){ | 427 | if($queryInCondition != 'null'){ |
| 309 | $queryInCondition = str_replace('"', "'", $queryInCondition); | 428 | $queryInCondition = str_replace('"', "'", $queryInCondition); |
| ... | @@ -318,10 +437,12 @@ class CampaignController extends Controller { | ... | @@ -318,10 +437,12 @@ class CampaignController extends Controller { |
| 318 | 437 | ||
| 319 | try { | 438 | try { |
| 320 | if($campaign=="All"){ | 439 | if($campaign=="All"){ |
| 321 | $selQuery = "SELECT $querySelect FROM records WHERE $queryConditions $queryInCondition LIMIT $queryLimit OFFSET $queryOffset"; | 440 | //$selQuery = "SELECT $querySelect FROM records WHERE $queryConditions LIMIT $queryLimit OFFSET $queryOffset"; |
| 322 | $sqlQuery = DB::select($selQuery); | 441 | $selQuery = "SELECT $querySelect FROM records WHERE $queryConditions $queryInCondition LIMIT $queryLimit OFFSET $queryOffset"; |
| 442 | $sqlQuery = DB::select($selQuery); | ||
| 323 | }else{ | 443 | }else{ |
| 324 | $selQuery = "SELECT $querySelect FROM records WHERE client = '$campaign' AND $queryConditions $queryInCondition LIMIT $queryLimit OFFSET $queryOffset"; | 444 | $selQuery = "SELECT $querySelect FROM records WHERE client = '$campaign' AND $queryConditions $queryInCondition LIMIT $queryLimit OFFSET $queryOffset"; |
| 445 | //$selQuery = "SELECT $querySelect FROM records WHERE client = '$campaign' AND $queryConditions LIMIT $queryLimit OFFSET $queryOffset"; | ||
| 325 | $sqlQuery = DB::select($selQuery); | 446 | $sqlQuery = DB::select($selQuery); |
| 326 | } | 447 | } |
| 327 | } catch(\Illuminate\Database\QueryException $ex){ | 448 | } catch(\Illuminate\Database\QueryException $ex){ |
| ... | @@ -399,14 +520,17 @@ class CampaignController extends Controller { | ... | @@ -399,14 +520,17 @@ class CampaignController extends Controller { |
| 399 | { | 520 | { |
| 400 | $hrmsdata=unserialize($data['hrmsdata']); | 521 | $hrmsdata=unserialize($data['hrmsdata']); |
| 401 | $hrmsdata['clientsownerlist'] = $campaignList; | 522 | $hrmsdata['clientsownerlist'] = $campaignList; |
| 523 | //print_r($hrmsdata['clientsownerlist']); | ||
| 402 | $data['hrmsdata']=serialize($hrmsdata); | 524 | $data['hrmsdata']=serialize($hrmsdata); |
| 525 | //print_r($data['hrmsdata']); | ||
| 403 | }else | 526 | }else |
| 404 | { | 527 | { |
| 405 | $hrmsdata['clientsownerlist'] = $campaignList; | 528 | $hrmsdata['clientsownerlist'] = $campaignList; |
| 406 | $data['hrmsdata']=serialize($hrmsdata); | 529 | $data['hrmsdata']=serialize($hrmsdata); |
| 530 | print_r($data['hrmsdata']); | ||
| 407 | } | 531 | } |
| 408 | $data=json_encode($data); | 532 | $data=json_encode($data); |
| 409 | 533 | //print_r($data); | |
| 410 | $usercampaign->updated_at=date("Y-m-d H:i:s"); | 534 | $usercampaign->updated_at=date("Y-m-d H:i:s"); |
| 411 | $usercampaign->clients=$campaignList; | 535 | $usercampaign->clients=$campaignList; |
| 412 | $usercampaign->data=$data; | 536 | $usercampaign->data=$data; |
| ... | @@ -453,25 +577,110 @@ class CampaignController extends Controller { | ... | @@ -453,25 +577,110 @@ class CampaignController extends Controller { |
| 453 | if(isset($data['hrmsdata'])) | 577 | if(isset($data['hrmsdata'])) |
| 454 | { | 578 | { |
| 455 | $hrmsdata=unserialize($data['hrmsdata']); | 579 | $hrmsdata=unserialize($data['hrmsdata']); |
| 580 | //print_r($hrmsdata); | ||
| 456 | $hrms_arr=explode(",", $hrmsdata['clientsownerlist']); | 581 | $hrms_arr=explode(",", $hrmsdata['clientsownerlist']); |
| 457 | $update_campaign[]=$campaign; | 582 | $update_campaign[]=$campaign; |
| 458 | $update_hrms=array_diff($hrms_arr, $update_campaign); | 583 | $update_hrms=array_diff($hrms_arr, $update_campaign); |
| 459 | $hrmsdata['clientsownerlist']= implode(",",$update_hrms); | 584 | $hrmsdata['clientsownerlist']= implode(",",$update_hrms); |
| 585 | $final = implode(",",$update_hrms); | ||
| 586 | // print_r($hrmsdata['clientsownerlist']); | ||
| 460 | $data['hrmsdata']=serialize($hrmsdata); | 587 | $data['hrmsdata']=serialize($hrmsdata); |
| 461 | $data=json_encode($data); | 588 | $data=json_encode($data); |
| 462 | 589 | ||
| 463 | } | 590 | } |
| 464 | $usercampaign1=User::where('username','=',$agent)->first(); | 591 | $usercampaign1=User::where('username','=',$agent)->first(); |
| 465 | $usercampaign1->updated_at=date("Y-m-d H:i:s"); | 592 | $usercampaign1->updated_at=date("Y-m-d H:i:s"); |
| 466 | $usercampaign1->clients=$finalcampaign; | 593 | $usercampaign1->clients=$finalcampaign; |
| 467 | $usercampaign1->data=$data; | 594 | $usercampaign1->data=$data; |
| 468 | $usercampaign1->save(); | 595 | $usercampaign1->save(); |
| 469 | // DB::statement("update users set updated_at='".date("Y-m-d H:i:s")."',clients='$finalcampaign',data='$data' where username='$agent'"); | 596 | //DB::statement("update users set updated_at='".date("Y-m-d H:i:s")."',clients='$finalcampaign',data='$data' where username='$agent'"); |
| 470 | } | 597 | } |
| 471 | } | 598 | } |
| 472 | 599 | ||
| 473 | return; | 600 | return; |
| 474 | } | 601 | } |
| 602 | if($id=="schedulecampaign"){ | ||
| 603 | $campaign = Input::get("selectCampaignField"); | ||
| 604 | $starttime = Input::get("starttime"); | ||
| 605 | $endtime = Input::get("endtime"); | ||
| 606 | //return view("layout.module.outputreport.supervisorreport", $data); | ||
| 607 | /*$updateschedule = Campaign::where("mtype","=","company")->where("mkey","=",$campaign)->first(); | ||
| 608 | $updateschedule->campaignstartdate=$starttime; | ||
| 609 | $updateschedule->campaignenddate=$endtime; | ||
| 610 | $updateschedule->save();*/ | ||
| 611 | /* $scheduledCampaign = Campaign::where("mtype","=","company")->where("mkey","=",$campaign)->get(); | ||
| 612 | $data['scheduledCampaign']=$scheduledCampaign; | ||
| 613 | return view("layout/module/campaign/campaignScheduler",$data);*/ | ||
| 614 | DB::statement("update hrms_masters set campaignstartdate='$starttime:00',campaignenddate='$endtime:00' where mkey='$campaign' and mtype='company'"); | ||
| 615 | } | ||
| 616 | |||
| 617 | if($id=="bulkupload"){ | ||
| 618 | return view("layout.module.campaign.bulkupload"); | ||
| 619 | } | ||
| 620 | |||
| 621 | if($id=='deleteAssignDisposition'){ | ||
| 622 | |||
| 623 | } | ||
| 624 | |||
| 625 | if($id=="assigndisposition"){ | ||
| 626 | $wakka = new KHRMSLib(); | ||
| 627 | $code = Input::get('code'); | ||
| 628 | $disposition = Input::get('disposition'); | ||
| 629 | $subDisposition = Input::get('subDisposition'); | ||
| 630 | $campaign = Input::get("selectCampaignField"); | ||
| 631 | |||
| 632 | if($wakka->getCount("hrms_masters","mkey='$campaign' and mtype='coreconfig'")==0){ | ||
| 633 | $mvalue = "dialerDispoList=$code|$disposition|$subDisposition"; | ||
| 634 | DB::table('hrms_masters')->insert(['mkey'=>$campaign, 'mtype'=>'coreconfig', 'mvalue'=>$mvalue,'status'=>'active']); | ||
| 635 | }else{ | ||
| 636 | $hrmsdata = DB::table('hrms_masters')->where('mkey','=', $campaign)->where('mtype','=', 'coreconfig')->select('*')->first(); | ||
| 637 | |||
| 638 | $dispolist=explode("~",$hrmsdata->mvalue); | ||
| 639 | $dispositionList = array(); | ||
| 640 | foreach ($dispolist as $key => $dispo) { | ||
| 641 | if(!empty($dispo)) | ||
| 642 | { | ||
| 643 | $dispoprts=explode("|",$dispo); | ||
| 644 | if($dispoprts[1] == $disposition){ | ||
| 645 | $mvalue = $hrmsdata->mvalue; | ||
| 646 | $mvalue = str_replace($dispoprts[2], $subDisposition, $mvalue); | ||
| 647 | }else{ | ||
| 648 | $mvalue .= $hrmsdata->mvalue."~$code|$disposition|$subDisposition"; | ||
| 649 | } | ||
| 650 | } | ||
| 651 | } | ||
| 652 | |||
| 653 | $wakka->Query("update hrms_masters set mvalue='$mvalue' where mkey='$campaign' and mtype='coreconfig';"); | ||
| 654 | } | ||
| 655 | |||
| 656 | |||
| 657 | } | ||
| 658 | |||
| 659 | if($id == "sampleDataExcel"){ | ||
| 660 | /*$objPHPExcel = new \PHPExcel(); | ||
| 661 | $objPHPExcel->getProperties() | ||
| 662 | ->setCreator("Temporaris") | ||
| 663 | ->setLastModifiedBy("Temporaris") | ||
| 664 | ->setTitle("Template Relevé des heures intérimaires") | ||
| 665 | ->setSubject("Template excel") | ||
| 666 | ->setDescription("Template excel permettant la création d'un ou plusieurs relevés d'heures") | ||
| 667 | ->setKeywords("Template excel"); | ||
| 668 | $objPHPExcel->setActiveSheetIndex(0); | ||
| 669 | $objPHPExcel->getActiveSheet()->SetCellValue('A1', "12"); | ||
| 670 | |||
| 671 | $writer = \PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5'); | ||
| 672 | header('Content-Type: application/vnd.ms-excel'); | ||
| 673 | header('Content-Disposition: attachment;filename="excel.xls"'); | ||
| 674 | header('Cache-Control: max-age=0'); | ||
| 675 | |||
| 676 | $writer->save('php://output'); | ||
| 677 | |||
| 678 | return ;*/ | ||
| 679 | |||
| 680 | return view("layout.module.campaign.sampleDataExcel"); | ||
| 681 | } | ||
| 682 | |||
| 683 | return; | ||
| 475 | } | 684 | } |
| 476 | 685 | ||
| 477 | public function edit($id) | 686 | public function edit($id) |
| ... | @@ -486,4 +695,4 @@ class CampaignController extends Controller { | ... | @@ -486,4 +695,4 @@ class CampaignController extends Controller { |
| 486 | { | 695 | { |
| 487 | } | 696 | } |
| 488 | 697 | ||
| 489 | } | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
| 698 | } | ... | ... |
| ... | @@ -113,7 +113,11 @@ return [ | ... | @@ -113,7 +113,11 @@ return [ |
| 113 | "RecordingArchive"=>["menuAction('dialer/recarchive');","A"], | 113 | "RecordingArchive"=>["menuAction('dialer/recarchive');","A"], |
| 114 | ]], | 114 | ]], |
| 115 | 115 | ||
| 116 | "Campaign" => ["disp"=>"Campaign","icon"=>"file","dash"=>"","onclick"=>"menuAction('campaign');"], | 116 | |
| 117 | "Campaign" => ["disp"=>"Campaign","icon"=>"file","dash"=>"Dialer", | ||
| 118 | "submenu"=>["Campaign"=>["menuAction('campaign');"], | ||
| 119 | "Bulk Upload"=>["menuAction('campaign/bulkupload');"], | ||
| 120 | ]], | ||
| 117 | 121 | ||
| 118 | 122 | ||
| 119 | "Admin" => ["disp"=>"Admin","icon"=>"gear","dash"=>"", | 123 | "Admin" => ["disp"=>"Admin","icon"=>"gear","dash"=>"", | ... | ... |
| 1 | <div class="container-fluid"> | ||
| 2 | <div class="layout-app"> | ||
| 3 | <div class="row"> | ||
| 4 | <div class="col-md-12"> | ||
| 5 | <div class="col-separator col-separator-first col-unscrollable box"> | ||
| 6 | <div class="innerAll"> | ||
| 7 | <h4>Bulk Upload</h4> | ||
| 8 | <hr style="margin-bottom: 10px;" /> | ||
| 9 | |||
| 10 | <div class="row"> | ||
| 11 | <div class="col-lg-6"> | ||
| 12 | <div class="form-inline"> | ||
| 13 | <form method="post" id="bulkUpload" enctype="multipart/form-data"> | ||
| 14 | <input type=hidden name=uploadSet value='1'> | ||
| 15 | {{ csrf_field() }} | ||
| 16 | <div class="col-md-2"> | ||
| 17 | <label>Upload Users:</label> | ||
| 18 | </div> | ||
| 19 | <div class="col-md-4"> | ||
| 20 | <input type="file" name="file" id="file" required /> | ||
| 21 | </div> | ||
| 22 | <div class="col-md-2"> | ||
| 23 | <input type="submit" name="upload" id="upload" class="btn btn-primary" value="Upload"> | ||
| 24 | |||
| 25 | </div> | ||
| 26 | <div class="col-md-2"> | ||
| 27 | <span><a href="javascript:void(0)" id="downloadExcel">Sample excel format</a></span> | ||
| 28 | </div> | ||
| 29 | </form> | ||
| 30 | </div> | ||
| 31 | </div> | ||
| 32 | <div class="col-lg-6"> | ||
| 33 | |||
| 34 | </div> | ||
| 35 | </div> | ||
| 36 | |||
| 37 | </div> | ||
| 38 | </div> | ||
| 39 | </div> | ||
| 40 | </div> | ||
| 41 | |||
| 42 | </div> | ||
| 43 | </div> | ||
| 44 | |||
| 45 | <script> | ||
| 46 | $(document).ready(function(){ | ||
| 47 | $('#bulkUpload').on('submit', function(event){ | ||
| 48 | event.preventDefault(); | ||
| 49 | var formData = new FormData(this); | ||
| 50 | $.ajax({ | ||
| 51 | url:"campaign?action=bulkupload", | ||
| 52 | method:"POST", | ||
| 53 | data:formData, | ||
| 54 | dataType:'JSON', | ||
| 55 | contentType: false, | ||
| 56 | cache: false, | ||
| 57 | processData: false, | ||
| 58 | success:function(data) | ||
| 59 | { | ||
| 60 | simpleNotification('Success','topRight',"Campaign assign suceesfully!"); | ||
| 61 | $('#bulkUpload').trigger("reset"); | ||
| 62 | $("#file").val(null); | ||
| 63 | }, | ||
| 64 | error: function(error) | ||
| 65 | { | ||
| 66 | simpleNotification('Success','topRight',"Something went wrong!"); | ||
| 67 | }, | ||
| 68 | }); | ||
| 69 | }); | ||
| 70 | |||
| 71 | $('#downloadExcel').click(function(){ | ||
| 72 | event.preventDefault(); | ||
| 73 | doAjax("campaign/sampleDataExcel","","","","","GET"); | ||
| 74 | return false; | ||
| 75 | }); | ||
| 76 | }); | ||
| 77 | </script> | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
| ... | @@ -60,6 +60,9 @@ | ... | @@ -60,6 +60,9 @@ |
| 60 | <li role="presentation"> | 60 | <li role="presentation"> |
| 61 | <a href="#assign" aria-controls="sql" role="tab" data-toggle="tab">Assign</a> | 61 | <a href="#assign" aria-controls="sql" role="tab" data-toggle="tab">Assign</a> |
| 62 | </li> | 62 | </li> |
| 63 | <li role="presentation"> | ||
| 64 | <a href="#disposition" aria-controls="sql" role="tab" data-toggle="tab">Disposition</a> | ||
| 65 | </li> | ||
| 63 | </ul> | 66 | </ul> |
| 64 | <div class="tab-content"> | 67 | <div class="tab-content"> |
| 65 | <!-- <div role="tabpanel" class="tab-pane" id="ctCrm"> | 68 | <!-- <div role="tabpanel" class="tab-pane" id="ctCrm"> |
| ... | @@ -81,6 +84,9 @@ | ... | @@ -81,6 +84,9 @@ |
| 81 | <div role="tabpanel" class="tab-pane" id="assign"> | 84 | <div role="tabpanel" class="tab-pane" id="assign"> |
| 82 | @include("layout/module/campaign/campaignAssignToAgents") | 85 | @include("layout/module/campaign/campaignAssignToAgents") |
| 83 | </div> | 86 | </div> |
| 87 | <div role="tabpanel" class="tab-pane" id="disposition"> | ||
| 88 | @include("layout/module/campaign/campaignAssignToDisposition") | ||
| 89 | </div> | ||
| 84 | </div> | 90 | </div> |
| 85 | </div> | 91 | </div> |
| 86 | </div> | 92 | </div> | ... | ... |
| ... | @@ -44,10 +44,6 @@ $dashboarduser=Auth::user(); | ... | @@ -44,10 +44,6 @@ $dashboarduser=Auth::user(); |
| 44 | //$data['client'] = $client; | 44 | //$data['client'] = $client; |
| 45 | // if(isset($username))$data->username = $username; | 45 | // if(isset($username))$data->username = $username; |
| 46 | 46 | ||
| 47 | if(isset($_POST['uploadSet'])){ | ||
| 48 | print_r($_FILES); | ||
| 49 | exit('test'); | ||
| 50 | } | ||
| 51 | ?> | 47 | ?> |
| 52 | <div class="row"> | 48 | <div class="row"> |
| 53 | <div class="col-md-12"> | 49 | <div class="col-md-12"> | ... | ... |
| 1 | <?php | ||
| 2 | /*$dashboarduser=Auth::user(); | ||
| 3 | if($dashboarduser->usertype != 'Admin'){ | ||
| 4 | $allusers=User::where(function ($query) use($dashboarduser) { | ||
| 5 | $query->where('supervisor','=',$dashboarduser->username) | ||
| 6 | ->orWhere('lteam2','=',$dashboarduser->username) | ||
| 7 | ->orWhere('lteam','=',$dashboarduser->username); | ||
| 8 | })->get(); | ||
| 9 | } | ||
| 10 | else | ||
| 11 | { | ||
| 12 | $allusers=DB::table('users')->select('*')->where('status','=','Active')->get(); | ||
| 13 | } | ||
| 14 | |||
| 15 | foreach($userassignedcampign as $userassigned) | ||
| 16 | { | ||
| 17 | $userassignedcamp[] = $userassigned->username; | ||
| 18 | } | ||
| 19 | |||
| 20 | foreach($allusers as $alluser) | ||
| 21 | { | ||
| 22 | if (isset($userassignedcamp)) { | ||
| 23 | if (!in_array($alluser->username, $userassignedcamp)) | ||
| 24 | { | ||
| 25 | $username[] = $alluser->username; | ||
| 26 | } | ||
| 27 | } | ||
| 28 | else{ | ||
| 29 | $username[] = $alluser->username; | ||
| 30 | } | ||
| 31 | |||
| 32 | } | ||
| 33 | foreach($allusers as $user) | ||
| 34 | { | ||
| 35 | $campaigns=$user->clients; | ||
| 36 | if(isset($data->hrmsdata)) | ||
| 37 | {print_r('man');echo "<br><br>"; | ||
| 38 | $hrmsdata=unserialize($data['hrmsdata']); | ||
| 39 | // $campaignList = $hrmsdata['clientsownerlist'];print_r($campaignList); | ||
| 40 | } | ||
| 41 | //$username[] = $alluser->username; | ||
| 42 | }*/ | ||
| 43 | |||
| 44 | //$data['client'] = $client; | ||
| 45 | // if(isset($username))$data->username = $username; | ||
| 46 | |||
| 47 | ?> | ||
| 48 | <div class="row"> | ||
| 49 | <div class="col-md-12"> | ||
| 50 | <div class="panel panel-info"> | ||
| 51 | <div class="panel-body"> | ||
| 52 | <div class="row"> | ||
| 53 | <div class="col-md-2"> | ||
| 54 | <label>Select Disposition:</label> | ||
| 55 | </div> | ||
| 56 | <div class="col-md-6"> | ||
| 57 | <!-- <select id="disposition" onchange='subDisposition($(this).val());' class="select2multi" style='width:100%' multiple=""> | ||
| 58 | <option value></option> | ||
| 59 | <?php //if(isset($disposition))foreach($disposition as $kay => $val){;echo "<option value='$val'>$kay</option>";} ?> | ||
| 60 | </select> --> | ||
| 61 | <select id="disposition" class="form-control" onchange='subDisposition($(this).val());'> | ||
| 62 | <option value></option> | ||
| 63 | <?php if(isset($disposition)) | ||
| 64 | foreach($disposition as $kay => $val) | ||
| 65 | { | ||
| 66 | $code = $dispositionCode[$kay]; | ||
| 67 | echo "<option data-id='$code' data-text='$kay' value='$val'>$kay</option>"; | ||
| 68 | } ?> | ||
| 69 | </select> | ||
| 70 | |||
| 71 | </div> | ||
| 72 | </div> | ||
| 73 | <div class="row"> | ||
| 74 | <div class="col-md-2"> | ||
| 75 | <label>Select Sub Disposition:</label> | ||
| 76 | </div> | ||
| 77 | <div class="col-md-6"> | ||
| 78 | <select id="subDisposition" class="select2multi" style='width:100%' multiple=""> | ||
| 79 | </select> | ||
| 80 | </select>` | ||
| 81 | </div> | ||
| 82 | </div> | ||
| 83 | <div class="row"> | ||
| 84 | <div class="col-md-2"> | ||
| 85 | <div class="col-md-2"> | ||
| 86 | <button id="assigndesposition" class="btn btn-xs btn-info">Assign Disposition | ||
| 87 | </button> | ||
| 88 | </div> | ||
| 89 | </div> | ||
| 90 | </div> | ||
| 91 | |||
| 92 | </div> | ||
| 93 | </div> | ||
| 94 | </div> | ||
| 95 | |||
| 96 | <div class="col-sm-12"> | ||
| 97 | <div class="panel panel-info"> | ||
| 98 | <div class="panel-heading"><strong>Disposition List</strong></div> | ||
| 99 | <div class="panel-body" id=""> | ||
| 100 | <ul class="list-group"> | ||
| 101 | <?php foreach($dispositionList as $key => $val) { | ||
| 102 | |||
| 103 | ?> | ||
| 104 | <li class="list-group-item"><!-- <input type="radio" name="query" id="currQuery" value="{{$queryLog->id}}" {{$queryLog->current_queue?"checked":""}}> --> | ||
| 105 | <div class="col-sm-12"> | ||
| 106 | <div class="col-sm-3"><?php echo $key; ?></div> | ||
| 107 | <div class="col-sm-4"><?php echo $val; ?></div>. | ||
| 108 | <!-- <div class="col-sm-3"><a class="innerAll" href="#" onclick="doAjax('campaign/deleteAssignDisposition','','userformdiv','ajax_users_delete','singlethis','DELETE');return false;"> | ||
| 109 | <span class="btn btn-primary btn-xs"><i class="fa fa-trash-o"></i></span> | ||
| 110 | </a></div> --> | ||
| 111 | </div> | ||
| 112 | |||
| 113 | </li> | ||
| 114 | <?php } ?> | ||
| 115 | </ul> | ||
| 116 | </div> | ||
| 117 | </div> | ||
| 118 | </div> | ||
| 119 | |||
| 120 | </div> | ||
| 121 | |||
| 122 | <script> | ||
| 123 | function subDisposition(dispo) | ||
| 124 | { | ||
| 125 | var dispolist = dispo.split(','); | ||
| 126 | /*var dispolist = []; | ||
| 127 | |||
| 128 | $.each( dispo, function( index, value ){ | ||
| 129 | dispolist = $.merge( dispolist, value.split(',') ); | ||
| 130 | });*/ | ||
| 131 | |||
| 132 | $("#subDisposition").select2("val", "Select"); | ||
| 133 | updateJSSelect('subDisposition',dispolist); | ||
| 134 | } | ||
| 135 | |||
| 136 | $('#assigndesposition').click(function() | ||
| 137 | { | ||
| 138 | var code = $('#disposition').find(':selected').attr('data-id') | ||
| 139 | //var disposition = $("#disposition option:selected").text(); | ||
| 140 | var disposition = $('#disposition').find(':selected').attr('data-text') | ||
| 141 | var subDisposition = $('#subDisposition').val(); | ||
| 142 | var selectCampaignField = $('#selectCampaignField').val(); | ||
| 143 | |||
| 144 | |||
| 145 | if(disposition&&selectCampaignField) | ||
| 146 | { | ||
| 147 | var postdata='disposition='+disposition; | ||
| 148 | postdata+='&code='+code; | ||
| 149 | postdata+='&disposition='+disposition; | ||
| 150 | postdata+='&subDisposition='+subDisposition; | ||
| 151 | postdata+='&selectCampaignField='+selectCampaignField; | ||
| 152 | doAjax("campaign/assigndisposition",postdata,"campaignDetailsArea","","","GET",function(retrstr){ | ||
| 153 | simpleNotification('Success','topRight',"Campaign assign suceesfully!"); | ||
| 154 | doAjax("campaign/show","campaign="+selectCampaignField,"campaignDetailsArea","","","GET"); | ||
| 155 | $("#subDisposition").select2("val", "Select"); | ||
| 156 | |||
| 157 | }); | ||
| 158 | } | ||
| 159 | else | ||
| 160 | { | ||
| 161 | $("#campaignDetailsArea").html('<br/><p class="text-danger text-center">Please select the campaign and disposition.</p>'); | ||
| 162 | } | ||
| 163 | |||
| 164 | |||
| 165 | |||
| 166 | }); | ||
| 167 | |||
| 168 | </script> | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
| 1 | <?php | ||
| 2 | |||
| 3 | include_once(app_path().'/lib/phpexcel/PHPExcel.php'); | ||
| 4 | |||
| 5 | $inputFileType = "Excel5"; | ||
| 6 | $objReader = PHPExcel_IOFactory::createReader($inputFileType); | ||
| 7 | $objPHPExcel = $objReader->load("assets/extras/blank.xls"); | ||
| 8 | $baseRow = 2; | ||
| 9 | |||
| 10 | $objPHPExcel->getActiveSheet()->setCellValue('A1', "12"); | ||
| 11 | |||
| 12 | |||
| 13 | header('Content-Type: application/vnd.ms-excel'); | ||
| 14 | header('Content-Disposition: attachment;filename="Output.xls"'); | ||
| 15 | header('Cache-Control: max-age=0'); | ||
| 16 | |||
| 17 | $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, $inputFileType); | ||
| 18 | $objWriter->save('php://output'); | ||
| 19 | |||
| 20 | return ; | ||
| 21 | |||
| 22 | ?> | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
-
Please register or sign in to post a comment