Find this useful? Enter your email to receive occasional updates for securing PHP code.
Signing you up...
Thank you for signing up!
PHP Decode
<?php namespace App\Modules\User\Controllers;use App\Http\Controllers\Controller;use App\H..
Decoded Output download
<?php namespace App\Modules\User\Controllers;use App\Http\Controllers\Controller;use App\Http\Requests;use App\Modules\User\helper;use File;use GuzzleHttp\Client;use Illuminate\Http\Request;use Illuminate\Support\Facades\Log;use Illuminate\Support\Facades\Response;use Illuminate\Support\Facades\Session;use Illuminate\Support\Facades\Storage;use Illuminate\Support\Facades\Validator;class UserController extends Controller{protected $client;protected $API_URL;protected $helper;protected $VERSION;protected $API_URL_3;protected $VERSION_3;public function __construct(){$this->client=new Client();$this->API_URL=env('API_HOST');$this->helper=new helper();$this->VERSION=env('API_VERSION');$this->API_URL_3=env('API_HOST_V3');$this->VERSION_3=env('API_VERSION_3');$this->user=$this->helper->getHostName();}public function loginPage(Request $request,$username=null){try{$plan=[];$checkUserCount=0;if(isset($username)){$apikey=env('APP_AMEMBER_KEY');$username=base64_decode($username);$result=json_decode($this->curl_execution(env('APP_AMEMBER_URL')."check-access/by-login?_key=$apikey&login=$username"),true);if($result['ok']&&!empty($result['subscriptions'])){$checkPlan=$this->checkPlans($result['subscriptions']);$totalFileds=\GuzzleHttp\json_decode($this->curl_execution(env('APP_AMEMBER_URL')."users?_key=$apikey&_filter[user_id]=".$result['user_id']),true);$resultInvoice=json_decode($this->curl_execution(env('APP_AMEMBER_URL')."invoices?_key=".$apikey."&_filter[user_id]=".$result['user_id']),true);$adminInfo=json_decode($this->curl_execution(env('APP_AMEMBER_URL')."users?_key=".$apikey."&_filter[user_id]=".$result['user_id']),true);$currentPlanIndex=$this->checkActiveInvoice($resultInvoice,$checkPlan);if(isset($totalFileds[0]['numberofusers'])){if($resultInvoice['_total']!=0){if($currentPlanIndex!='-1'){$currentPlan=$resultInvoice[$currentPlanIndex];$currentPlan=$currentPlan['nested']['invoice-items'];$options=json_decode($currentPlan[0]['options']);if(isset($options->{'No of Users'})){if((int)$totalFileds[0]['numberofusers']>=(int)$options->{'No of Users'}->value){$checkUserCount=1;}}else{$checkUserCount=1;}}}else if($totalFileds[0]['numberofusers']!=""&&$totalFileds[0]['numberofusers']!=0){$checkUserCount=1;}}if(isset($totalFileds[0]['numberofusers'])&&$checkUserCount==1){$plan['item_id']=$checkPlan;$plan['item_title']="Manually-Added-User";$plan['no_of_users']=$totalFileds[0]['numberofusers'];$plan['email']=$result['email'];$plan['name']=$result['name'];$plan['avatar']=env('APP_URL')."amember/avatar/".$totalFileds[0]['avatar'];Session::put('plan',$plan);$result['product_id']=$checkPlan;$result['begin_date']=date('Y-m-d');$result['expire_date']=$result['subscriptions'][$checkPlan];}else if($resultInvoice['_total']!=0){if($currentPlanIndex!='-1'){$currentPlan=$resultInvoice[$currentPlanIndex];$currentPlan=$currentPlan['nested']['invoice-items'];$keyAccess=0;for($k=0;$k<count($resultInvoice[$currentPlanIndex]['nested']['access']);$k++){if($resultInvoice[$currentPlanIndex]['nested']['access'][$k]['expire_date']>date('Y-m-d')){$keyAccess=$k;}}$result['product_id']=$resultInvoice[$currentPlanIndex]['nested']['access'][$keyAccess]['product_id']?$resultInvoice[$currentPlanIndex]['nested']['access'][0]['product_id']:'';$result['begin_date']=$resultInvoice[$currentPlanIndex]['nested']['access'][$keyAccess]['begin_date']?$resultInvoice[$currentPlanIndex]['nested']['access'][0]['begin_date']:'';$result['expire_date']=$resultInvoice[$currentPlanIndex]['nested']['access'][$keyAccess]['expire_date'];$options=json_decode($currentPlan[0]['options']);$plan['item_id']=$currentPlan[0]['item_id'];$plan['item_title']=$currentPlan[0]['item_title'];$plan['no_of_users']=$options->{'No of Users'}->value;$plan['email']=$result['email'];$plan['name']=$result['name'];$plan['avatar']=env('APP_URL')."amember/avatar/".$adminInfo[0]['avatar'];Session::put('plan',$plan);}else{header('location:'.env('APP_URL').'amember/member/index');exit();}}else{header('location:'.env('APP_URL').'amember/member/index');exit();}}else{header('location:'.env('APP_URL').'amember/member/index');exit();}$api_url=$this->API_URL_3.'api/'.env('API_VERSION_3').'/auth/admin';$api_url_old=$this->API_URL.'api/v1/admin-authentication';$method="post";$amemberData=array("name"=>$result['name'],"first_name"=>$result['name_f'],"last_name"=>$result['name_l'],"email"=>$result['email'],"username"=>$result['login'],"product_id"=>$result['product_id'],"begin_date"=>$result['begin_date'],"expire_date"=>$result['expire_date'],"timezone"=>"Africa/Bamako","amember_id"=>$result['user_id'],"total_allowed_user_count"=>$plan['no_of_users']);$adminAuthResponse=$this->client->post($api_url,['form_params'=>$amemberData,'headers'=>['user-agent'=>$_SERVER['HTTP_USER_AGENT'],'Content-Type'=>'application/x-www-form-urlencoded',]]);$your_date=strtotime($result['expire_date']);$plan_expire_date=(int)(explode(".",round(($your_date-time())/(60*60*24)))[0]);Session::put('expirePlaneDate',$plan_expire_date);if($adminAuthResponse->getStatusCode()==200){$adminAuthResponse=json_decode($adminAuthResponse->getBody()->getContents(),true);if($adminAuthResponse['feedback']==0)Session::put('feedback',$adminAuthResponse['feedback']);if($adminAuthResponse['code']==200){Session::put('locale',$adminAuthResponse['language']);$admin=array('token'=>array('user_id'=>$adminAuthResponse['organization_id'],'my_self'=>$adminAuthResponse['user_id'],'data'=>$adminAuthResponse['data'],'is_admin'=>$adminAuthResponse['is_admin'],'is_manager'=>$adminAuthResponse['is_manager'],'is_teamlead'=>$adminAuthResponse['is_teamlead'],'organization_id'=>$adminAuthResponse['organization_id'],'login'=>$result['login'],'email'=>$result['email'],'loggedRole'=>$adminAuthResponse['role']));foreach($adminAuthResponse['feature']as $feature){if($feature['status']==1){$admin[$feature['name']]=1;}else{$admin[$feature['name']]=0;}}$role=str_replace(' ','',strtolower($adminAuthResponse['role']));Session::put('role',$role);Session::put($role,$admin);if(Session::has('Region')){Session::forget('Region');}return redirect('admin/dashboard');}else{header('location:'.env('APP_URL').'amember/member/index');exit();}}else{header('location:'.env('APP_URL').'amember/member/index');exit();}}else{header('location:'.env('APP_URL').'amember/member/index');exit();}}catch(\Exception $e){Log::info('Exception '.$e->getLine()."=> code =>".$e->getCode()." => message => ".$e->getMessage());header('location:'.env('APP_URL').'amember/member/index');exit();}}/** Temporary India Login Page*/ public function loginPageIndia(Request $request,$username=null){try{$plan=[];$checkUserCount=0;if(isset($username)){$apikey=env('APP_AMEMBER_KEY_INDIA');$username=base64_decode($username);$result=json_decode($this->curl_execution(env('APP_AMEMBER_URL_INDIA')."check-access/by-login?_key=$apikey&login=$username"),true);if($result['ok']&&!empty($result['subscriptions'])){$checkPlan=$this->checkPlans($result['subscriptions']);$totalFileds=\GuzzleHttp\json_decode($this->curl_execution(env('APP_AMEMBER_URL_INDIA')."users?_key=$apikey&_filter[user_id]=".$result['user_id']),true);$resultInvoice=json_decode($this->curl_execution(env('APP_AMEMBER_URL_INDIA')."invoices?_key=".$apikey."&_filter[user_id]=".$result['user_id']),true);$adminInfo=json_decode($this->curl_execution(env('APP_AMEMBER_URL_INDIA')."users?_key=".$apikey."&_filter[user_id]=".$result['user_id']),true);$currentPlanIndex=$this->checkActiveInvoice($resultInvoice,$checkPlan);if(isset($totalFileds[0]['numberofusers'])){if($resultInvoice['_total']!=0){if($currentPlanIndex!='-1'){$currentPlan=$resultInvoice[$currentPlanIndex];$currentPlan=$currentPlan['nested']['invoice-items'];$options=json_decode($currentPlan[0]['options']);if(isset($options->{'No of Users'})){if((int)$totalFileds[0]['numberofusers']>=(int)$options->{'No of Users'}->value){$checkUserCount=1;}}else{$checkUserCount=1;}}}else if($totalFileds[0]['numberofusers']!=""&&$totalFileds[0]['numberofusers']!=0){$checkUserCount=1;}}if(isset($totalFileds[0]['numberofusers'])&&$checkUserCount==1){$plan['item_id']=$checkPlan;$plan['item_title']="Manually-Added-User";$plan['no_of_users']=$totalFileds[0]['numberofusers'];$plan['email']=$result['email'];$plan['name']=$result['name'];Session::put('plan',$plan);$result['product_id']=$checkPlan;$result['begin_date']=date('Y-m-d');$result['expire_date']=$result['subscriptions'][$checkPlan];}else if($resultInvoice['_total']!=0){if($currentPlanIndex!='-1'){$currentPlan=$resultInvoice[$currentPlanIndex];$currentPlan=$currentPlan['nested']['invoice-items'];$keyAccess=0;$kMax=count($resultInvoice[$currentPlanIndex]['nested']['access']);for($k=0;$k<$kMax;$k++){if($resultInvoice[$currentPlanIndex]['nested']['access'][$k]['expire_date']>date('Y-m-d')){$keyAccess=$k;}}$result['product_id']=$resultInvoice[$currentPlanIndex]['nested']['access'][$keyAccess]['product_id']?$resultInvoice[$currentPlanIndex]['nested']['access'][0]['product_id']:'';$result['begin_date']=$resultInvoice[$currentPlanIndex]['nested']['access'][$keyAccess]['begin_date']?$resultInvoice[$currentPlanIndex]['nested']['access'][0]['begin_date']:'';$result['expire_date']=$resultInvoice[$currentPlanIndex]['nested']['access'][$keyAccess]['expire_date'];$options=json_decode($currentPlan[0]['options']);$plan['item_id']=$currentPlan[0]['item_id'];$plan['item_title']=$currentPlan[0]['item_title'];$plan['no_of_users']=$options->{'No of Users'}->value;$plan['email']=$result['email'];$plan['name']=$result['name'];Session::put('plan',$plan);}else{header('location:'.env('APP_URL').'amember-i/member/index');exit();}}else{header('location:'.env('APP_URL').'amember-i/member/index');exit();}}else{header('location:'.env('APP_URL').'amember-i/member/index');exit();}$api_url=$this->API_URL_3.'api/'.env('API_VERSION_3').'/auth/admin';$amemberData=array("name"=>$result['name'],"first_name"=>$result['name_f'],"last_name"=>$result['name_l'],"email"=>$result['email'],"username"=>$result['login'],"product_id"=>$result['product_id'],"begin_date"=>$result['begin_date'],"expire_date"=>$result['expire_date'],"timezone"=>"Asia/Kolkata","amember_id"=>$result['user_id'],"total_allowed_user_count"=>$plan['no_of_users'],"region"=>"2");$adminAuthResponse=$this->client->post($api_url,['form_params'=>$amemberData,'headers'=>['user-agent'=>$_SERVER['HTTP_USER_AGENT'],'Content-Type'=>'application/x-www-form-urlencoded',]]);$your_date=strtotime($result['expire_date']);$plan_expire_date=(int)(explode(".",round(($your_date-time())/(60*60*24)))[0]);Session::put('expirePlaneDate',$plan_expire_date);if($adminAuthResponse->getStatusCode()===200){$adminAuthResponse=json_decode($adminAuthResponse->getBody()->getContents(),true);if($adminAuthResponse['feedback']==0)Session::put('feedback',$adminAuthResponse['feedback']);if($adminAuthResponse['code']===200){Session::put('locale',$adminAuthResponse['language']);$admin=array('token'=>array('user_id'=>$adminAuthResponse['organization_id'],'my_self'=>$adminAuthResponse['user_id'],'data'=>$adminAuthResponse['data'],'is_admin'=>$adminAuthResponse['is_admin'],'is_manager'=>$adminAuthResponse['is_manager'],'is_teamlead'=>$adminAuthResponse['is_teamlead'],'organization_id'=>$adminAuthResponse['organization_id'],'login'=>$result['login'],'email'=>$result['email'],'loggedRole'=>$adminAuthResponse['role']));foreach($adminAuthResponse['feature']as $feature){if($feature['status']==1){$admin[$feature['name']]=1;}else{$admin[$feature['name']]=0;}}$role=str_replace(' ','',strtolower($adminAuthResponse['role']));Session::put('role',$role);Session::put($role,$admin);Session::put('Region','India');return redirect('admin/dashboard');}else{header('location:'.env('APP_URL').'amember-i/member/index');exit();}}else{header('location:'.env('APP_URL').'amember-i/member/index');exit();}}else{header('location:'.env('APP_URL').'amember-i/member/index');exit();}}catch(\Exception $e){Log::info('Exception '.$e->getLine()."=> code =>".$e->getCode()." => message => ".$e->getMessage());header('location:'.env('APP_URL').'amember-i/member/index');exit();}}public function loginpageWhitelabel(Request $request,$username=null,$password=null){try{if(isset($username)){$apikey=env('APP_AMEMBER_KEY');$username=base64_decode($username);$password=urlencode(base64_decode($password));$result=json_decode($this->curl_execution(env('APP_AMEMBER_URL')."check-access/by-login-pass?_key=$apikey&login=$username&pass=$password"),true);if($result['ok']&&!empty($result['subscriptions'])){$plan=[];$checkPlan=$this->checkPlans($result['subscriptions']);$totalFileds=\GuzzleHttp\json_decode($this->curl_execution(env('APP_AMEMBER_URL')."users?_key=$apikey&_filter[user_id]=".$result['user_id']),true);$resultInvoice=json_decode($this->curl_execution(env('APP_AMEMBER_URL')."invoices?_key=".$apikey."&_filter[user_id]=".$result['user_id']),true);$adminInfo=json_decode($this->curl_execution(env('APP_AMEMBER_URL')."users?_key=".$apikey."&_filter[user_id]=".$result['user_id']),true);if($resultInvoice['_total']!=0){$currentPlanIndex=$this->checkActiveInvoice($resultInvoice,$checkPlan);$currentPlan=$resultInvoice[$currentPlanIndex];$plan['currentPlan']['plan_id']=$checkPlan;$plan['currentPlan']['tm_started']=$currentPlan['tm_started'];$plan['currentPlan']['rebill_date']=$currentPlan['rebill_date'];}if(isset($totalFileds[0]['numberofusers'])){if($totalFileds[0]['numberofusers']!=""&&$totalFileds[0]['numberofusers']!=0){$plan['item_id']=$checkPlan;$plan['item_title']="Manually-Added-User";$plan['no_of_users']=$totalFileds[0]['numberofusers'];$plan['email']=$result['email'];$plan['name']=$result['login'];$plan['avatar']=env('APP_URL')."amember/avatar/".$totalFileds[0]['avatar'];Session::put('plan',$plan);$result['product_id']=$checkPlan;$result['begin_date']=date('Y-m-d');$result['expire_date']=$result['subscriptions'][$checkPlan];}}else if($resultInvoice['_total']!=0){$currentPlanIndex=$this->checkActiveInvoice($resultInvoice,$checkPlan);if($currentPlanIndex!='-1'){$currentPlan=$resultInvoice[$currentPlanIndex];$currentPlan=$currentPlan['nested']['invoice-items'];$keyAccess=0;for($k=0;$k<count($resultInvoice[$currentPlanIndex]['nested']['access']);$k++){if($resultInvoice[$currentPlanIndex]['nested']['access'][$k]['expire_date']>date('Y-m-d')){$keyAccess=$k;}}$result['product_id']=$resultInvoice[$currentPlanIndex]['nested']['access'][$keyAccess]['product_id']?$resultInvoice[$currentPlanIndex]['nested']['access'][0]['product_id']:'';$result['begin_date']=$resultInvoice[$currentPlanIndex]['nested']['access'][$keyAccess]['begin_date']?$resultInvoice[$currentPlanIndex]['nested']['access'][0]['begin_date']:'';$result['expire_date']=$resultInvoice[$currentPlanIndex]['nested']['access'][$keyAccess]['expire_date'];$options=json_decode($currentPlan[0]['options']);$plan['item_id']=$currentPlan[0]['item_id'];$plan['item_title']=$currentPlan[0]['item_title'];$plan['no_of_users']=$options->{'No of Users'}->value;$plan['email']=$result['email'];$plan['name']=$result['login'];$plan['avatar']=env('APP_URL')."amember/avatar/".$adminInfo[0]['avatar'];Session::put('plan',$plan);}else{return redirect('admin-login')->with('error','Invalid subscription');}}else{return redirect('admin-login')->with('error','Invoice issue please, contact support Team');}}else{return redirect('admin-login')->with('error','Invalid subscription');}$api_url=$this->API_URL_3.'api/'.env('API_VERSION_3').'/auth/admin';$method="post";$amemberData=array("name"=>$result['name'],"first_name"=>$result['name_f'],"last_name"=>$result['name_l'],"email"=>$result['email'],"username"=>$result['login'],"product_id"=>$result['product_id'],"begin_date"=>$result['begin_date'],"expire_date"=>$result['expire_date'],"timezone"=>"Africa/Bamako","amember_id"=>$result['user_id'],"total_allowed_user_count"=>$plan['no_of_users']);$your_date=strtotime($result['expire_date']);$plan_expire_date=(int)(explode(".",round(($your_date-time())/(60*60*24)))[0]);$adminAuthResponse=$this->client->post($api_url,['form_params'=>$amemberData,'headers'=>['user-agent'=>$_SERVER['HTTP_USER_AGENT'],'Content-Type'=>'application/x-www-form-urlencoded',]]);if($adminAuthResponse->getStatusCode()==200){$adminAuthResponse=json_decode($adminAuthResponse->getBody()->getContents(),true);if($adminAuthResponse['feedback']==0)Session::put('feedback',$adminAuthResponse['feedback']);if($adminAuthResponse['code']==200){Session::put('locale',$adminAuthResponse['language']);$admin=array('token'=>array('user_id'=>$adminAuthResponse['organization_id'],'my_self'=>$adminAuthResponse['user_id'],'data'=>$adminAuthResponse['data'],'is_admin'=>$adminAuthResponse['is_admin'],'is_manager'=>$adminAuthResponse['is_manager'],'is_teamlead'=>$adminAuthResponse['is_teamlead'],'organization_id'=>$adminAuthResponse['organization_id'],'login'=>$result['login'],'email'=>$result['email']));foreach($adminAuthResponse['feature']as $feature){if($feature['status']==1){$admin[$feature['name']]=1;}else{$admin[$feature['name']]=0;}}$role=str_replace(' ','',strtolower($adminAuthResponse['role']));Session::put('role',$role);Session::put($role,$admin);Session::put('expirePlaneDate',$plan_expire_date);return redirect('admin/dashboard');}else{return redirect('admin-login')->with('error','Invalid authentication');}}else{return redirect('admin-login')->with('error','Invalid authentication');}}else{return redirect('admin-login')->with('error','Username not provided');}}catch(\Exception $e){Log::info('Exception '.$e->getLine()."=> code =>".$e->getCode()." => message => ".$e->getMessage());return redirect('admin-login')->with('error','Something went wrong. Please contact support Team');}}public function resellerClientLogin(Request $request,$username=null,$password=null,$isClient=true){try{$api_url=$this->API_URL_3.'api/'.env('API_VERSION_3').'/auth/client';$amemberData=array("username"=>base64_decode($username),"password"=>base64_decode($password));$adminAuthResponse=$this->client->post($api_url,['form_params'=>$amemberData,'headers'=>['user-agent'=>$_SERVER['HTTP_USER_AGENT'],'Content-Type'=>'application/x-www-form-urlencoded',]]);if($adminAuthResponse->getStatusCode()===200){$adminAuthResponse=json_decode($adminAuthResponse->getBody()->getContents(),true);if($adminAuthResponse['code']===400){return redirect('admin-login')->with('error',$adminAuthResponse['message']);}if($adminAuthResponse['feedback']===0){Session::put('feedback',$adminAuthResponse['feedback']);}if($adminAuthResponse['code']===200){Session::put('locale',$adminAuthResponse['language']);$admin=array('token'=>array('user_id'=>$adminAuthResponse['organization_id'],'my_self'=>$adminAuthResponse['user_id'],'data'=>$adminAuthResponse['data'],'is_admin'=>true,'is_manager'=>$adminAuthResponse['is_manager'],'is_teamlead'=>$adminAuthResponse['is_teamlead'],'organization_id'=>$adminAuthResponse['organization_id'],'login'=>base64_decode($username),'email'=>$adminAuthResponse['email']?? '','photo_path'=>'../'.env('DEFAULT_IMAGE')));foreach($adminAuthResponse['feature']as $feature){if($feature['status']===1){$admin[$feature['name']]=1;}else{$admin[$feature['name']]=0;}}$role=str_replace(' ','',strtolower('Admin'));Session::put('role',$role);Session::put($role,$admin);Session::put('client',true);$count=2;Session::put('expirePlaneDate',str_replace('"','',$adminAuthResponse['expire_date'],$count));return redirect('admin/dashboard');}else{return redirect('admin-login')->with('error','Invalid authentication');}}else{return redirect('admin-login')->with('error','Invalid authentication');}}catch(\Exception $e){try{if($e->getCode()===400){$response=$e->getResponse();$responseBodyAsString=\GuzzleHttp\json_decode($response->getBody()->getContents());return redirect('admin-login')->with('error',$responseBodyAsString->message);}Log::info('Exception '.$e->getLine()."=> code =>".$e->getCode()." => message => ".$e->getMessage());return redirect('admin-login')->with('error','Invalid authentication');}catch(\Exception $e){Log::info('Exception '.$e->getLine()."=> code =>".$e->getCode()." => message => ".$e->getMessage());return redirect('admin-login')->with('error','Something went wrong. Please contact admin');}}}public function checkActiveInvoice($invoice,$plan){for($i=$invoice['_total']-1;$i>=0;$i--){if(($invoice[$i]['status']==1||$invoice[$i]['status']==5||$invoice[$i]['status']==4||$invoice[$i]['status']==2||$invoice[$i]['status']==3)&&$invoice[$i]['nested']['invoice-items'][0]['item_id']==$plan)return $i;else continue;}return-1;}public function curl_execution($url){$ch=curl_init();curl_setopt($ch,CURLOPT_URL,$url);curl_setopt($ch,CURLOPT_RETURNTRANSFER,true);$result=curl_exec($ch);return $result;}public function checkPlans($plans){$currentDate=date('Y-m-d');if((strtotime($plans[max(array_keys($plans))])>=strtotime($currentDate))){return max(array_keys($plans));}else{unset($plans[max(array_keys($plans))]);return $this->checkPlans($plans);}}public function forgotPassword(Request $request){$result=[];$data=$request->all();try{$api_url=$this->API_URL_3.'api/'.$this->VERSION_3.'/password/forgot-password';$method="post";$response=$this->helper->postApiCall($method,$api_url,$data,false,true);if($response['data']['code']==200){$result['code']=200;$result['data']=$response['data']['data'];$result['msg']=$response['data']['message'];}else{$result['code']=$response['data']['code'];$result['msg']=$response['data']['code']==400?$response['data']['message']:$response['data']['error'];}return $result;}catch(\Exception $e){Log::info('Exception '.$e->getLine()."=> code =>".$e->getCode()." => message => ".$e->getMessage());$result['code']=500;$result['msg']="Something went wrong...";return $result;}}public function resetPage(Request $request){if(Session::has('admin'))return redirect('/dashboard');else{$email=$request->email;$token=$request->token;return view("User::adminLogin")->with('reset',$request->all());}}public function login(Request $request){if($request->isMethod('get')){if(Session::has(env('Manager')))return redirect(env('Manager').'/dashboard');else if(Session::has(env('Employee'))){return redirect(env('Employee').'/myTimeline?id='.Session::get(env('Employee'))['token']['user_id']);}else return view("User::adminLogin")->with('reset',[]);}else if($request->isMethod('post')){$rules=array("email"=>'required | email',"password"=>'required');try{$validator=Validator::make($request->all(),$rules);if($validator->fails()){return redirect()->back()->withErrors($validator)->withInput();}else{$method="post";$loginData=array("email"=>$request->email,"password"=>$request->password,"ip"=>$request->ip );$api_url=$this->API_URL_3.'api/'.$this->VERSION_3.'/auth/user';try{$response=$this->client->post($api_url,['form_params'=>$loginData,'headers'=>['user-agent'=>$_SERVER['HTTP_USER_AGENT'],'Content-Type'=>'application/x-www-form-urlencoded',]]);}catch(\GuzzleHttp\Exception\RequestException $e){Log::info('Exception '.$e->getLine()." => Function Name =>Login => code =>".$e->getCode()." => message => ".$e->getMessage());$parsedMessage=json_decode($e->getResponse()->getBody()->getContents());return redirect('login')->with('error',$parsedMessage->message);}if($response->getStatusCode()==200){$response=json_decode($response->getBody()->getContents(),true);if($response['code']==200){Session::put('locale',$response['language']);if($response['photo_path']=='undefined')$response['photo_path']=env('DEFAULT_IMAGE');elseif(substr($response['photo_path'],0,5)==="https")$response['photo_path']=$response['photo_path'];else $response['photo_path']=env('API_HOST').$response['photo_path'];$response['login']=$response['user_name'];$loginSession=array('token'=>$response);foreach($response['feature']as $feature){if($feature['status']==1){$loginSession[$feature['name']]=1;}else{$loginSession[$feature['name']]=0;}}$role=str_replace(' ','',strtolower($response['role']));Session::put('role',$role);if($role=="employee"){Session::put('employee',$loginSession);Session::put('EmployeeLogged',$role);return redirect(env('Employee').'/myTimeline?id='.Session::get(env('Employee'))['token']['user_id']);}else if($role!=env('Employee')||$role!=env('Admin')){Session::put(env('Manager'),$loginSession);return redirect(env('Manager').'/dashboard');}else{return redirect('login')->with('error',$response['message']);}}else if($response['code']==400){return redirect('login')->with('error',$response['message']);}else{return redirect('login')->with('error',$response['error']);}}}}catch(\Exception $e){Log::info('Exception '.$e->getLine()." => Function Name =>Login => code =>".$e->getCode()." => message => ".$e->getMessage());return redirect('login')->with('error',$e->getMessage());}}}public function changeRole(Request $request){if(Session::has(env('Manager'))||Session::has(env('Employee'))){$api_url=$this->API_URL_3.'api/'.$this->VERSION_3.'/auth/role-account-switch';$method='post';$data['role_id']=(int)$request->role_id;$response=$this->helper->postApiCall($method,$api_url,$data);if($response['data']['code']==200){$response=$response['data'];Session::forget($this->helper->getHostName());if($response['photo_path']=='undefined')$response['photo_path']=env('DEFAULT_IMAGE');elseif(substr($response['photo_path'],0,5)==="https")$response['photo_path']=$response['photo_path'];else $response['photo_path']=env('API_HOST').$response['photo_path'];$response['login']=$response['user_name'];$loginSession=array('token'=>$response);foreach($response['feature']as $feature){if($feature['status']==1){$loginSession[$feature['name']]=1;}else{$loginSession[$feature['name']]=0;}}$role=str_replace(' ','',strtolower($response['role']));Session::put('role',$role);if($role=="employee"){Session::put('employee',$loginSession);Session::put('EmployeeLogged',$role);return redirect(env('Employee').'/myTimeline?id='.Session::get(env('Employee'))['token']['user_id']);}else if($role!=env('Employee')||$role!=env('Admin')){Session::put(env('Manager'),$loginSession);return redirect(env('Manager').'/dashboard');}else{return redirect('login')->with('error',$response['message']);}}}else return view("User::adminLogin")->with('reset',[]);}public function resetPassword(Request $request){$result=[];$data=$request->all();try{$rules=array("new_password"=>'required|max:20|min:8',"confirm_password"=>'required_with:passwd|same:new_password',);$validator=Validator::make($request->all(),$rules);if($validator->fails()){return $validator->errors();}else{$api_url=$this->API_URL_3.'api/'.$this->VERSION_3.'/password/reset-password';$method="put";$response=$this->helper->postApiCall($method,$api_url,$data,false,true);if($response['code']==200){$result['code']=200;$result['data']=$response['data'];$result['msg']=$response['message'];}else{$result['code']=$response['code'];$result['msg']=$response['code']==400?$response['message']:$response['error'];}return $result;}}catch(\Exception $e){Log::info('Exception '.$e->getLine()."=> code =>".$e->getCode()." => message => ".$e->getMessage());$result['code']=500;$result['msg']="Something went wrong...";return $result;}}public function contactDetailsCheck(Request $request){$data=[];$error=[];if($request->input('ContactCheck')=="1"){$number=str_replace(" ","",$request->input('number'));$data['phone']=$request->input('CountryCode')."-".$number;}else if($request->input('ContactCheck')=="5"){$error['code']=400;$error['msg']="Invalid contact details";}return['data'=>$data,'error'=>$error];}public function EmployeeRegistration(Request $request){$rules=array("name"=>'required|max:32|min:2|regex:/([a-zA-Z-]+)([0-9-]*)/',"Full_Name"=>'required|regex:/([a-zA-Z-]+)/',"email"=>'required|email|regex:/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,6})+$/',"password"=>'required |regex:/^(?=.*\d)(?=.*[!-\/:-@\[-`{-~]).{8,}$/',"confirmPassword"=>'required_with:passwd|same:password',"empCode"=>'required|',"locId"=>'required|regex:/[1-9]*[0-9-]/',"depId"=>'required|regex:/[0-9-]/',"roleId"=>'required|regex:/[0-9-]/',"TimeZoneOffset"=>'required',);try{$customMessage=['name.max'=>__('messages.firstName_length'),'passwd.regex'=>__('messages.Password_formate'),'c_passwd.required_with'=>__('messages.confirm_password'),'c_passwd.same'=>__('messages.Password_missmatch'),'username.regex'=>__('messages.Username_alphanumeric'),'first_name.regex'=>__('messages.special_characters'),];$validator=Validator::make($request->all(),$rules,$customMessage);if($validator->fails()){return $validator->errors();}else{if($request->input('number')!=null){$contact=$this->contactDetailsCheck($request);if(count($contact['error'])!=0)return $contact['error'];else if(count($contact['data'])!=0)$data['phone']=$contact['data']['phone'];}$api_url=$this->API_URL_3.'api/'.$this->VERSION_3.'/user/user-register';$method='post';$data['first_name']=$request->input('name');$data['last_name']=$request->input('Full_Name');$data['email']=strtolower($request->input('email'));$data['password']=$this->encryptDecryptPswd($request,1,0);$data['emp_code']=$request->input('empCode');$data['location_id']=$request->input('locId');$data['department_id']=$request->input('depId');$data['date_join']=$request->input('date');$data['address']=$request->input('address');$data['role_id']=$request->input('roleId');$data['role']=$request->input('role');$data['status']="1";$data['location']=$request->input('location');$data['department']=$request->input('departement_name');$data['timezone_offset']=$request->input("TimeZoneOffset");$data['timezone']=$request->input("TimeZoneName");$data['project_name']=isset($request->projectname)?$request->input('projectname'):'';$data['shift_id']=(int)$request->shiftCheck;$data['skip']="0";$data['limit']="100";$response=$this->helper->postApiCall($method,$api_url,$data);if($response['statusCode']==200){$result['code']=($response['data']['code']);$result['msg']=($response['data']['message']);$result['data']=($response['data']['data']);$result['error']=($response['data']['error']);if($request->file!=null){$image=$request->file;$pathToStorage=storage_path("images");if(!file_exists($pathToStorage))mkdir($pathToStorage,0777,true);$publishimage=$image->getClientOriginalName();$path=$pathToStorage."/".$publishimage;file_put_contents($path,file_get_contents($image->path()));$multipartData=array("name"=>"avatar","file"=>$path);$uploadUrl=$this->API_URL_3.'api/'.$this->VERSION_3.'/user/upload-profilepic-drive?user_id='.$response['data']['data']['user_id'];$uploadResponse=$this->helper->postApiCall($method,$uploadUrl,$multipartData,true);if($uploadResponse['data']['code']!=200){$result['code']="406";$result['msg']=$uploadResponse['data']['message']." And, Employee details registered successfully";$result['data']=$response['data']['data'];}}return $result;}else{return $this->helper->responseHandler($response);}}}catch(\Exception $e){return $this->ExceptionErrorHandler($e,"400",' UserController => EmployeeRegistration => Method-post');}}/**
* logout
* * This is used to logout application and clearing the session and cookies
* @param mixed $request
* @return void
*/ public function logout(Request $request){/**
** Clearing the cookies
*/ setcookie('LocationIdCookie','');setcookie('RoleIdCookie','');setcookie('DepartmentCookie','');$this->destroyAuthToken();if($this->helper->getHostName()==env('Manager')){Session::forget(env('Manager'));}Session::forget($this->helper->getHostName());Session::forget('role');Session::forget('feedback');Session::forget('adminForPassAmmId');if(Session::has('leftOverLicenses'))Session::forget('leftOverLicenses');if(Session::has('plan')&&$this->user==env('Admin')||Session::has('client')){Session::forget('plan');Session::forget(env('Admin'));Session::forget('client');return redirect('admin-login');}else{return redirect('login');}}/**
* authTokenExpire
** This is to expire the auth token once logout the application
* @return void
*/ public function destroyAuthToken(){try{$api_url=$this->API_URL_3.'api/'.$this->VERSION_3.'/auth/logout';$this->helper->postApiCall("get",$api_url,0);}catch(\Exception $e){return $this->ExceptionErrorHandler($e,"400",' UserController => logout => Method-post');}}public function logouut(){if(Session::has('admin'))Session::forget('admin');if(Session::has('plan'))Session::forget('plan');return redirect('/');}public function dashboard(){$showPopUP=0;if(!($this->helper->checkOrgDisable())){if(Session::has('feedback')){$showPopUP=1;}}$admin=0;if(Session::has(env('Admin'))&&$this->user==env('Admin')){$admin=1;}$api_url=$this->API_URL_3.'api/'.$this->VERSION_3.'/employeeNotification/unread-count';try{$response=$this->helper->postApiCall('get',$api_url,[]);if($response['code']==200){Session::put("notify",$response['data']['count']);}}catch(\Exception $e){Log::info("Exception in dashboard ".$e->getMessage());}$responseData['department']=app('App\Modules\User\Controllers\ProductivityController')->getDepartment();$responseData['location']=app('App\Modules\User\Controllers\ProductivityController')->getLocationsDept();$responseData['users']=app('App\Modules\User\Controllers\ProductivityController')->getUsers();return view("User::dashboard")->with(['admin'=>$admin,'showPopUP'=>$showPopUP,'response'=>$responseData]);}public function dashboardData(Request $request){$result['data']['register_employees']=0;$result['data']['assigned_employees']=0;$result['data']['online_employees']=0;$result['data']['offline_employees']=0;$result['data']['currently_offline_employees']=0;$result['data']['suspended_employees']=0;$result['data']['working_hours']=0;$result['data']['non_working_hours']=0;$result['data']['total_hours']=0;$result['data']['absent_employees']=0;$result['data']['percentage_total_hours']=0;$result['data']['percentage_working_hours']=0;$result['data']['percentage_non_working_hours']=0;$api_url=$this->API_URL_3.'api/'.$this->VERSION_3.'/dashboard/employees?date='.$request->input("date");try{$response=$this->helper->postApiCall('get',$api_url,[]);if($response['code']==200){if(isset($response['data']['registeredEmp'])){$result['data']['register_employees']=count($response['data']['registeredEmp']);$result['data']['assigned_employees']=count($response['data']['registeredEmp']);}if(isset($response['data']['assigned_employees'])){$result['data']['assigned_employees']=count($response['data']['registeredEmp']);}$result['data']['absent_employees']=count($response['data']['absentEmp']);$result['data']['suspended_employees']=count($response['data']['suspendedEmp']);$result['data']['online_employees']=count($response['data']['onlineEmps']);$result['data']['offline_employees']=count($response['data']['idleEmps']);$result['data']['currently_offline_employees']=count($response['data']['offlineEmp']);$data['code']=200;$data['data']=$result['data'];return $data;}}catch(\Exception $e){Log::info("Exception in dashboard ".$e->getMessage());}}public function getActivityBreakdownData(Request $request){try{$api_url=$this->API_URL_3.'api/'.$this->VERSION_3.'/dashboard/activity-breakdown?'.$request->input("data");$response=$this->helper->postApiCall('get',$api_url,[]);return $this->helper->responseHandlerWithoutStatusCode($response);}catch(\Exception $e){return $this->helper->errorHandler($e,'getActivityBreakdownData');}}public function getApplicationWebsiteData(Request $request){try{$api_url=$this->API_URL_3.'api/'.$this->VERSION_3.'/dashboard/top-app-web?'.$request->input("data");$response=$this->helper->postApiCall('get',$api_url,[]);return $this->helper->responseHandlerWithoutStatusCode($response);}catch(\Exception $e){return $this->helper->errorHandler($e,'getApplicationWebsiteData');}}public function getPerformanceData(Request $request){try{$api_url=$this->API_URL_3.'api/'.$this->VERSION_3.'/dashboard/performance?'.$request->input("data");$response=$this->helper->postApiCall('get',$api_url,[]);return $this->helper->responseHandlerWithoutStatusCode($response);}catch(\Exception $e){return $this->helper->errorHandler($e,'getPerformanceData');}}public function getEmployeesData(Request $request){try{$api_url=$this->API_URL_3.'api/'.$this->VERSION_3.'/dashboard/productive-and-nonproductive?'.$request->input("data");$response=$this->helper->postApiCall('get',$api_url,[]);return $this->helper->responseHandlerWithoutStatusCode($response);}catch(\Exception $e){return $this->helper->errorHandler($e,'getEmployeesData');}}public function getPresentRate(Request $request){try{$api_url=$this->API_URL_3.'api/'.$this->VERSION_3.'/dashboard/productivity/department?'.$request->input("data");$method="get";$response=$this->helper->postApiCall($method,$api_url,[]);return $this->helper->responseHandlerWithoutStatusCode($response);}catch(\Exception $e){Log::info('Exception '.$e->getLine()."=> code =>".$e->getCode()." => message => ".$e->getMessage());$result['code']=$e->getCode();$result['error']="Something went wrong...";return $result;}}public function desktop_control(Request $request){return view("User::DesktopControls.desktopControl");}public function action_control(Request $request){$api_url=$this->API_URL.'api/v1/desktop-Setting-multi-user';$method="post";$data=$request->all();try{$response=$this->helper->postApiCall($method,$api_url,$data);if($response['statusCode']==200){$result['code']=200;$result['msg']='Success';$result['data']=$response['data'];}else{$result['code']=400;$result['msg']=$response['error'];$result['data']=null;}return $result;}catch(\Exception $e){Log::info('Exception '.$e->getLine()."=> code =>".$e->getCode()." => message => ".$e->getMessage());return redirect('login')->with('error','Something went wrong');}}/**
* @Desc API function, to Fetch All Departments
* @return All Departments
*/ public function getDepartments(){try{$api_url=$this->API_URL_3.'api/'.$this->VERSION_3.'/department/get-departments';$method="post";$data['skip']="";$data['limit']="";try{$response=$this->helper->postApiCall($method,$api_url,$data);if($response['statusCode']==200){if($response['data']['code']==200){$result['code']=200;$result['msg']=$response['data']['message'];$result['data']=$response['data'];}else{$result['code']=400;$result['msg']=$response['data']['code']==400?$response['data']['message']:$response['data']['error'];$result['data']=$response['data'];}}return $result;}catch(\GuzzleHttp\Exception\RequestException $e){return $this->guzzleErrorHandler($e,' UserController => getDepartments => Method-post ');}}catch(\Exception $e){return $this->ExceptionErrorHandler($e,500,' UserController => getDepartments => Method-post');}}/**
* @Desc API function, to show workingHours based upon user or department
* @return Working Hours
*/ public function workingHours(Request $request){$api_url=$this->API_URL.'api/v1/working-hours';$method='post';$data['location_id']=$request->input("location_id");$data['department_id']=$request->input("depId");$data['user_id']=$request->input("userId");$data['from_date']=$request->input("fromDateselect");$data['to_date']=$request->input("toDateselect");try{$response=$this->helper->postApiCall($method,$api_url,$data);if($response['statusCode']==200){$result['code']=$response['data']['code'];$result['msg']=($response['data']['message']);$result['data']=($response['data']['data']);}else{$result['code']=400;$result['msg']=$response['data']['code']==400?$response['data']['message']:$response['data']['error'];$result['data']=$response['data']['data'];}return $result;}catch(\Exception $e){Log::info('Exception '.$e->getLine()."=> code =>".$e->getCode()." => message => ".$e->getMessage());$result['code']='500';$result['msg']="Something went wrong...";$result['data']=null;return $result;}}public function error(){return redirect()->back()->with('alert','Sorry, already existed');}/**
* @Desc API function, to View the employee-details page
* @return UI view
*/ public function EmpDetails(Request $request){if($request->isMethod('get')){return view('User::EmployeeDetail.employeDetail',["LocationData"=>$this->getAllLocations(),"DepartmentData"=>$this->getDepartments(),"RoleData"=>$this->getRoles(),"ShiftData"=>$this->helper->shiftById(0)['data'],"EmployeeData"=>$this->EmployeeDetails($request)]);}}/**
* @Desc API function, to get the employee-details
* @return Filetered data
*/ public function EmployeeDetails(Request $request){$api_url=$this->API_URL_3.'api/'.$this->VERSION_3.'/user/fetch-users';$method="post";$location_id=count($request->all())!=0?$request->LocationId:"";$department_id=count($request->all())!=0?$request->DepartmentId:"";$role_id=count($request->all())!=0?$request->RoleId:"";$data['status']="";if(isset($request->activeStatus)&&$request->activeStatus!=""){$data['status']=(int)$request->activeStatus;}if($location_id==0||$department_id==0||$role_id==0&&count($request->all())!=0){if($location_id)$data['location_id']=$location_id;else $data['location_id']="";if($department_id)$data['department_id']=$department_id;else $data['department_id']="";if($role_id)$data['role_id']=$role_id;else $data['role_id']="";}else{$data['location_id']=$location_id;$data['department_id']=$department_id;$data['role_id']=$role_id;}$data['day']=date("Y-m-d");$data['limit']=count($request->all())!=0?$request->input('showEntries'):10;$data['skip']=count($request->all())!=0?$request->input('skipvalue'):0;$data['name']=count($request->all())!=0?($request->input('searchText')!=null?$request->input('searchText'):""):"";if($request->input('sortName')!=''&&count($request->all())!=0){$data['sortColumn']=$request->input('sortName');$data['sortOrder']=$request->input('sortOrder');}if(count($request->all())!=0&&isset($request->CollapseMerge)&&$request->CollapseMerge==="1"){$data['emp_code']=isset($request->EmployeeCode)&&$request->EmployeeCode!==null?$request->input('EmployeeCode'):'';$data['expand']=1;}try{$response=$this->helper->postApiCall($method,$api_url,$data);if($response['data']['code']==200){$result['code']=$response['data']['code'];$result['msg']=$response['data']['message'];$result['getData']=$response['data']['data'];$result['data']=$response['data']['data']['user_data'];$result['data']=$this->multi_unique($result['data']);$result['status']=$response['data']['data']['status_data'];return $result;}else{$result['code']=($response['data']['code']);$result['msg']=$response['data']['message'];$result['error']=$response['data']['error'];$result['data']=($response['data']['data']);return($result);}}catch(\Exception $e){return $this->ExceptionErrorHandler($e,201,' UserController => EmployeeDetails => Method-post');}}function multi_unique($src){$output=array_map("unserialize",array_unique(array_map("serialize",$src)));return $output;}/**
* @Desc API function, to get the assigned employee-list under the manager
* @return Status message
*/ public function ManagerUserDetails(Request $request){$helper=new helper();$api_url=$this->API_URL_3.'api/'.$this->VERSION_3.'/user/get-assigned-employee';$method="post";$data['limit']="100000";$data['to_assigned_id']=Session::get($helper->getHostName())['token']['user_id'];($request->locationId==0||$request->locationId==null)?$data['location_id']="":$data['location_id']=$request->locationId;($request->departmentId==0||$request->departmentId==null)?null:$data['department_id']=$request->departmentId;($request->RoleId==0||$request->RoleId==null)?null:$data['role_id']=$request->RoleId;try{$response=$helper->postApiCall($method,$api_url,$data);if($response['data']['code']==200){$result['code']=$response['data']['code'];$result['msg']=$response['data']['message'];$result['data']=$response['data']['data'];$result['status']=$response['data']['data']['status_data'];return $result;}else{$result['code']=201;$result['msg']=$response['data']['message'];return($result);}}catch(\Exception $e){return $this->ExceptionErrorHandler($e,201,' UserController => ManagerUserDetails => Method-post');}}public function ManagerListUserDetails(Request $request){$helper=new helper();$api_url=$this->API_URL_3.'api/'.$this->VERSION_3.'/user/get-assigned-employee';$data['to_assigned_id']=Session::get($helper->getHostName())['token']['user_id'];($request->input('LocationId')==0||$request->input('LocationId')==null)?$data['location_id']="":$data['location_id']=$request->input('LocationId');($request->input('DepartmentId')==0||$request->input('DepartmentId')==null)?null:$data['department_id']=$request->input('DepartmentId');($request->input('RoleId')==0||$request->input('RoleId')==null)?null:$data['role_id']=$request->input('RoleId');$data['sortColumn']=$request->input('sortName')!=null?$request->input('sortName'):"";$data['sortOrder']=$request->input('sortOrder')!=null?$request->input('sortOrder'):"";$data['name']=$request->input('searchText')!=null?$request->input('searchText'):"";$data['skip']=$request->input('skipvalue');$data['limit']=$request->input('showEntries');$data['status']="";if(isset($request->activeStatus)&&$request->activeStatus!=""){$data['status']=(int)$request->activeStatus;}try{$response=$helper->postApiCall("post",$api_url,$data);return $this->helper->responseHandler($response);}catch(\Exception $e){return $this->ExceptionErrorHandler($e,201,' UserController => ManagerUserDetails => Method-post');}}/**
* @Desc API function, to get department by selected location
* @return the departemnets in the selected location
*/ public function getDeptByLocation(Request $request){$api_url=$this->API_URL_3.'api/'.$this->VERSION_3.'/location/get-department-by-location';$method="post";$location_id=$request->id;if($location_id==0)$data['location_id']="";if(!$request->id)$data['location_id']="";else $data['location_id']=$location_id;if($location_id=="All"){$data['location_id']="";}if(isset($request->roleId))$data['role_id']=$request->input('roleId');try{$response=$this->helper->postApiCall($method,$api_url,$data);if($response['data']['code']==200){$result['code']=$response['data']['code'];$result['msg']=$response['data']['message'];$result['data']=$response['data']['data'];return $result;}else{$result['code']=$response['data']['code'];$result['msg']=$response['data']['message'];$result['data']=$response['data']['data'];return($result);}}catch(\Exception $e){return $this->ExceptionErrorHandler($e,"201",' UserController => getDeptByLocation => Method-post');}}public function getAllLocations(){try{$api_url=$this->API_URL_3.'api/'.$this->VERSION_3.'/location/get-locations';$method="post";$data['skip']=0;$data['limit']="";try{$response=$this->helper->postApiCall($method,$api_url,$data);return $this->helper->responseHandler($response);}catch(\GuzzleHttp\Exception\RequestException $e){return $this->guzzleErrorHandler($e,' UserController => getAllLocations => Method-post ');}}catch(\Exception $e){return $this->ExceptionErrorHandler($e,"400",' UserController => getAllLocations => Method-post');}}public function show_details(Request $request){$api_url=$this->API_URL_3.'api/'.$this->VERSION_3.'/user/get-user';$method='post';$data['user_id']=$request->userId;$data['skip']="0";$data['limit']="10";try{$response=$this->helper->postApiCall($method,$api_url,$data);if(isset($request->editOption)&&$request->input('editOption')=='0'){if($response['data']['code']==200){$response['data']['data']['password']=$this->encryptDecryptPswd($request,2,$response['data']['data']['password']);}}return $this->helper->responseHandler($response);}catch(\Exception $e){return $this->ExceptionErrorHandler($e,"400",' UserController => show_details => Method-post');}}public function getUserDetails($id){$api_url=$this->API_URL_3.'api/'.$this->VERSION_3.'/user/get-user';$method='post';$data['user_id']=$id;try{$response=$this->helper->postApiCall($method,$api_url,$data);return $this->helper->responseHandler($response);}catch(\Exception $e){return $this->ExceptionErrorHandler($e,"400",' UserController => getUserDetails => Method-post');}}public function EmpScreenshotsView(Request $request){$api_url=$this->API_URL_3.'api/'.$this->VERSION_3.'/user/get-user';$method='post';$data['user_id']="$request->id";try{$response=$this->helper->postApiCall($method,$api_url,$data);if($response['data']['data']!=null){return view("User::EmployeeDetail.screenShots",["ScreenShots"=>$response,"userId"=>$request->id]);}else{return redirect('/dashboard')->with(Session::flash('message','Searched User Details Not Found'));}}catch(\Exception $e){return $this->ExceptionErrorHandler($e,"400",' UserController => EmpScreenshotsView => Method-post');}}public function EmpScreenshots(Request $request){if($request->isMethod("Post")){$FormTime=(explode(":",$request->input('fromTime')));$ToTime=(explode(":",$request->input('ToTime')));ini_set('max_execution_time',3600);$j=0;$arry=[];$arraySS=[];if($request->isMethod("post")){$api_url=$this->API_URL_3.'api/'.$this->VERSION_3.'/user/get-screenshots-new';$method='post';$data['user_id']=$request->userId;$data['date']=$request->Date;$data['mail']=$request->Email;$data['from_hour']=$FormTime[0];$data['to_hour']=$ToTime[0];$option['selected']=$request->selected;$opts=["https"=>["method"=>"GET","header"=>"Referer: https://drive.google.com/"]];$context=stream_context_create($opts);if($request->selected==2){try{$response=$this->helper->postApiCall($method,$api_url,$data);$SSlength=$response['data']['data']['screenshot'];for($i=0;$i<count($SSlength);$i++){if(count($SSlength[$i]['s'])!=0){if($response['data']['data']['screenshot'][$i]['pageToken']!=null&&$response['data']['code']==200){$data['pageTokens']=$response['data']['data']['screenshot'][$i]['pageToken'];array_push($arry,$response['data']['data']['screenshot'][$i]['s']);array_push($arraySS,$response);$j++;$fromTime=$response['data']['data']['screenshot'][$i]['t'];$totime=$fromTime+1;for($k=0;$k<3;){$api_url=$this->API_URL.'api/v1/get-screenshots';$method='post';$data['user_id']=$request->userId;$data['date']=$request->Date;$data['mail']=$request->Email;$data['from_hour']=$fromTime;$data['to_hour']=$totime;$data['limit']="80";$data['pageToken']=$data['pageTokens'];$responses=$this->helper->postApiCall($method,$api_url,$data);if($responses['data']['data']['screenshot'][0]['pageToken']!=null){$data['pageTokens']=$responses['data']['data']['screenshot'][0]['pageToken'];$k++;$j++;array_push($arry,$responses['data']['data']['screenshot'][0]['s']);}else{$j++;array_push($arry,$responses['data']['data']['screenshot'][0]['s']);break;}}}else{array_push($arry,$response['data']['data']['screenshot'][$i]['s']);array_push($arraySS,$response);}}}$dir_path=[];if(count($arry)!=0){$ssArray=[];if(is_dir(public_path().'\Download')){$count="0";if(true){$dirPaths="Download/";$files=glob($dirPaths.'*',GLOB_MARK);foreach($files as $file){if(is_dir($file)){self::deleteDir($file);}else{unlink($file);}}$count++;}if($count===1){$dir_path="Download";if(!file_exists($dir_path)){mkdir($dir_path,0777,true);}else if(file_exists($dir_path)){File::deleteDirectory(public_path('Download'));mkdir($dir_path,0777,true);}foreach($arry as $ss){if(count($ss)!=0){foreach($ss as $ssData){$emp_name=$response['data']['data']['name'];$img_path=$dir_path."/".$ssData["name"];file_put_contents($img_path,file_get_contents(str_replace("&","&",$ssData["link"]),false,$context));}}}}}else{foreach($arry as $ss){foreach($ss as $ssData){$emp_name=$response['data']['data']['name'];$dir_path="Download";if(!file_exists($dir_path)){mkdir($dir_path,0777,true);}$img_path=$dir_path."/".$ssData["name"];file_put_contents($img_path,file_get_contents(str_replace("&","&",$ssData["link"]),false,$context));}}}$responses['data']['data']['screenshot']=$ssArray;}else{$responses['data']['data']['screenshot']=null;}$code=$arraySS;$Showpath=$dir_path;$result['code']="200";$result['option']=$option['selected'];$result['path']=$Showpath;$result['response']=$arraySS;return $result;}catch(\Exception $e){Log::info('Exception EmpScreenshots '.$e->getLine()."=> code =>".$e->getCode()." => message => ".$e->getMessage());$result['code']="400";$result['msg']="Something went wrong...";$result['option']="2";return($result);}}else if($request->selected==1){try{$response=$this->helper->postApiCall($method,$api_url,$data);$result['code']=$response['data']['code'];$result['msg']=$response['data']['message'];$result['option']=$option['selected'];$result['path']='null';$result['data']=($response);return $result;}catch(\Exception $e){Log::info('Exception '.$e->getLine()."=> code =>".$e->getCode()." => message => ".$e->getMessage());$result['code']="400";$result['msg']="Something went wrong...";$result['option']=$option['selected'];$result['data']="null";return $result;}}}}}public function SSwithToken(Request $request){$api_url=$this->API_URL_3.'api/'.$this->VERSION_3.'/user/get-screenshots-new';$method='post';$data['user_id']=$request->userId;$data['date']=$request->Date;$data['mail']=$request->Email;$data['from_hour']=$request->fromTime;$data['to_hour']=$request->ToTime;$data['limit']="60";$data['pageToken']=$request->PageToken;try{$response=$this->helper->postApiCall($method,$api_url,$data);$result['code']=$response['data']['code'];$result['msg']=$response['data']['message'];$result['data']=($response);return $result;}catch(\Exception $e){return $this->ExceptionErrorHandler($e,"400",' UserController => SSwithToken => Method-post');}}public function getActiveStorage(Request $request){try{$api_url=$this->API_URL_3.'api/'.$this->VERSION_3.'/storage/active-storage-type';$response=$this->helper->postApiCall('get',$api_url,0);if(isset($response['data']['creds'])&&$this->user==env('Employee')){unset($response['data']['creds']);}return $this->helper->responseHandlerWithoutStatusCode($response);}catch(\GuzzleHttp\Exception\RequestException $e){return $this->guzzleErrorHandler($e,' UserController => getActiveStorage => Method-get ');}}public function UserCastID(Request $request){try{$api_url=$this->API_URL_3.'api/'.$this->VERSION_3.'/employee/get-employee-room-id?employee_id='.$request->userId;$response=$this->helper->postApiCall('get',$api_url,0);return $this->helper->responseHandlerWithoutStatusCode($response);}catch(\GuzzleHttp\Exception\RequestException $e){return $this->guzzleErrorHandler($e,' UserController => UserCastID => Method-get ');}}public function deleteFiles($dirPath){if(!is_dir($dirPath)){throw new InvalidArgumentException("$dirPath must be a directory");}if(substr($dirPath,strlen($dirPath)-1,1)!='/'){$dirPath.='/';}$files=glob($dirPath.'*',GLOB_MARK);foreach($files as $file){if(is_dir($file)){self::deleteDir($file);}else{unlink($file);}}}public function downloadSSZip(Request $request){$name=$request->name;$ldate=date('d-m-Y');$dirPath="Download";\Zipper::make(public_path(''.$name.'('.$ldate.').zip'))->add($dirPath)->close();$this->deleteFiles($dirPath);rmdir($dirPath);$filename=public_path(''.$name.'('.$ldate.').zip');header('Content-Type: application/zip');header('Content-Disposition: attachment; filename="'.basename($filename).'"');header('Content-Length: '.filesize($filename));flush();readfile($filename);unlink($filename);}public function getRoles(){try{$api_url=$this->API_URL_3.'api/'.$this->VERSION_3.'/organization/get-role';$method='get';try{$response=$this->helper->postApiCall($method,$api_url,0);return $this->helper->responseHandlerWithoutStatusCode($response);}catch(\GuzzleHttp\Exception\RequestException $e){return $this->guzzleErrorHandler($e,' UserController => getRoles => Method-get ');}}catch(\Exception $e){return $this->ExceptionErrorHandler($e,"400",' UserController => getRoles => Method-get');}}public function editEmployee(Request $request){$result=[];$rules=array("name"=>'required|max:32|min:1|regex:/([a-zA-Z-]+)([0-9-]*)/',"Full_name"=>'required|max:32|min:1|regex:/([a-zA-Z-]+)([0-9-]*)/',"email"=>'required|email|regex:/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,6})+$/',"password"=>'required |regex:/^(?=.*\d)(?=.*[!-\/:-@\[-`{-~]).{8,}$/',"confirmPassword"=>'required_with:passwd|same:password',"EmpCode"=>'required|',"locId"=>'required|regex:/[1-9]*[0-9-]/',"depId"=>'required|regex:/[0-9-]/',"roleId"=>'required',);try{$customMessage=['name.required'=>__('messages.inputRequired'),'Full_name.required'=>__('messages.inputRequired'),'email.required'=>__('messages.inputRequired'),'password.required'=>__('messages.inputRequired'),'EmpCode.required'=>__('messages.inputRequired'),'locId.required'=>__('messages.inputRequired'),'depId.required'=>__('messages.inputRequired'),'roleId.required'=>__('messages.inputRequired'),'name.max'=>__('messages.firstName_length'),'password.regex'=>__('messages.Password_formate'),'confirmPassword.required_with'=>__('messages.confirm_password'),'confirmPassword.same'=>__('messages.Password_missmatch'),'username.regex'=>__('messages.Username_alphanumeric'),'first_name.regex'=>__('messages.special_characters'),];$validator=Validator::make($request->all(),$rules,$customMessage);if($validator->fails()){return $validator->errors();}else{if($request->input('number')!=null){$contact=$this->contactDetailsCheck($request);if(count($contact['error'])!=0)return $contact['error'];else if(count($contact['data'])!=0)$data['phone']=$contact['data']['phone'];}else{$data['phone']=$request->input('CountryCode')."-"."";}$api_url=$this->API_URL_3.'api/'.$this->VERSION_3.'/user/user-profile-update';$method='post';$data['userId']=$request->input('hideId');$data['first_name']=$request->input('name');$data['last_name']=$request->input('Full_name');$data['email']=strtolower($request->input('email'));$data['password']=$this->encryptDecryptPswd($request,1,0);$data['emp_code']=$request->input('EmpCode');$data['location']=$request->input('location');$data['location_id']=$request->input('locId');$data['role_id']=$request->input('roleId');$data['department']=$request->input('department');$data['department_id']=$request->input('depId');$data['joinDate']=$request->input('date');$data['address']=$request->input('address')!=null?$request->input('address'):" ";$data['shift_id']=$request->input('shiftCheck');$data['project_name']=isset($request->projectname)?$request->input('projectname'):'';if($request->input("timeZoneOffset")!=null){$data['timezone_offset']=$request->input("timeZoneOffset");$data['timezone']=$request->input("timeZoneName");}$data['status']="1";$response=$this->helper->postApiCall($method,$api_url,$data);if($response['statusCode']==200){if($response['data']['code']==200){$result['code']=$response['data']['code'];$result['msg']=$response['data']['message'];$result['data']=($response['data']);}else{$result['code']=$response['data']['code'];$result['msg']=$response['data']['message'];$result['error']=strval($response['data']['error']);}}if($request->file!=null){$image=$request->file;$pathToStorage=storage_path("images");if(!file_exists($pathToStorage))mkdir($pathToStorage,0777,true);$publishimage=$image->getClientOriginalName();$path=$pathToStorage."/".$publishimage;file_put_contents($path,file_get_contents($image->path()));$multipartData=array("name"=>"avatar","file"=>$path);$uploadUrl=$this->API_URL_3.'api/'.$this->VERSION_3.'/user/upload-profilepic-drive?user_id='.$request->input('hideId');$uploadResponse=$this->helper->postApiCall($method,$uploadUrl,$multipartData,true);if($uploadResponse['data']['code']==200){$result['avatar']=$uploadResponse['data']['data']['photo_path'];}else{$result['code']=$uploadResponse['data']['code'];$result['msg']=$uploadResponse['data']['message'];$result['error']=$uploadResponse['data']['error']['sqlMessage']?? '';}}return $result;}}catch(\Exception $e){return $this->ExceptionErrorHandler($e,"404",' UserController => editEmployee => Method-delete');}}public function Employeedelete(Request $request){$api_url=$this->API_URL_3.'api/'.$this->VERSION_3.'/user/user-delete-multiple';$method='delete';$data['user_ids']=[$request->input('DetedId')];if(Session::has('leftOverLicenses'))Session::forget('leftOverLicenses');try{$response=$this->helper->postApiCall($method,$api_url,$data);return $this->helper->responseHandlerWithoutStatusCode($response);}catch(\Exception $e){return $this->ExceptionErrorHandler($e,400,' UserController => Employeedelete => Method-delete');}}public function UpgradeToManager(Request $request){$api_url=$this->API_URL_3.'api/'.$this->VERSION_3.'/user/user-profile-update';$method='post';$data['userId']=$request->input('User-Id');$data['role_id']=$request->input('Param');if($request->input('Param')==null){$result['code']=205;return $result;}else{try{$response=$this->helper->postApiCall($method,$api_url,$data);return $this->helper->responseHandler($response);}catch(\Exception $e){return $this->ExceptionErrorHandler($e,"400",' UserController => UpgradeToManager => Method-put');}}}public function DeleteMultiple(Request $request){$result['user_ids']=explode(",",$request->input('seluserids'));$method="delete";$api_url=$this->API_URL_3.'api/'.$this->VERSION_3.'/user/user-delete-multiple';try{$response=$this->helper->postApiCall($method,$api_url,$result);return $this->helper->responseHandlerWithoutStatusCode($response);}catch(\Exception $e){return $this->ExceptionErrorHandler($e,"500",' UserController => DeleteMultiple => Method-delete');}}public function MultipleActive(Request $request){$method="put";$api_url=$this->API_URL_3.'api/'.$this->VERSION_3.'/user/update-user-status';$data['user_ids']=explode(",",$request->seluserids);$data['status']="1";try{$response=$this->helper->postApiCall($method,$api_url,$data);return $this->helper->responseHandlerWithoutStatusCode($response);}catch(\Exception $e){return $this->ExceptionErrorHandler($e,"500",' UserController => MultipleActive => Method-put');}}public function SuspendMultiple(Request $request){$method="put";$api_url=$this->API_URL_3.'api/'.$this->VERSION_3.'/user/update-user-status';$data['user_ids']=explode(",",$request->input('seluserids'));$data['status']="2";try{$response=$this->helper->postApiCall($method,$api_url,$data);return $this->helper->responseHandlerWithoutStatusCode($response);}catch(\Exception $e){return $this->ExceptionErrorHandler($e,"500",' UserController => SuspendMultiple => Method-put');}}public function ManagerList(Request $request){$api_url=$this->API_URL_3.'api/'.$this->VERSION_3.'/user/fetch-users';$method='post';$data['role_id']=$request->input('RoleId');$data['limit']=10000;try{$response=$this->helper->postApiCall($method,$api_url,$data);$api=$this->API_URL_3.'api/'.$this->VERSION_3.'/user/employee-assigned-to';if($response['data']['code']==200){$request->input('AssignedId')!=null?$data['user_id']=$request->input('AssignedId'):null;$UserAssignedsuperior=$request->input('AssignedId')!=null?$this->helper->postApiCall($method,$api,$data):null;$result['code']=$response['data']['code'];$result['msg']=($response['data']['message']);$result['data']=($response['data']['data']['user_data']);if($request->input('AssignedId')!=null){$result['superiorCode']=$UserAssignedsuperior['data']['code'];$result['superiorData']=$UserAssignedsuperior['data']['data'];}else{$result['superiorCode']="400";$result['superiorData']="null";}return $result;}else{$result['code']=$response['data']['code'];$result['msg']=$response['error'];$result['data']=$response['data']['data'];return $result;}}catch(\Exception $e){return $this->ExceptionErrorHandler($e,"400",' UserController => ManagerList => Method-post');}}public function managerEmployeeList(Request $request){$api_url=$this->API_URL.'api/v1/get-assigned-employee-to-manager';$method='post';$data['limit']="10000";$data['manager_id']=$request->userId;try{$response=$this->helper->postApiCall($method,$api_url,$data);if($response['statusCode']==200){$result['code']=($response['data']['code']);$result['data']=($response['data']['data']);return $result;}else{$result['code']=400;$result['message']=$response['error'];$result['data']=null;return $result;}}catch(\Exception $e){return $this->ExceptionErrorHandler($e,"400",' UserController => managerEmployeeList => Method-post');}}public function managerAssignedEmployeeList(Request $request){$api_url=$this->API_URL_3.'api/'.$this->VERSION_3.'/user/get-assigned-employee';$data['to_assigned_id']=$request->userId;$data['to_assign_role_id']=$request->input('FilteredRoleId');$method='post';$data['limit']="1000000";try{$response=$this->helper->postApiCall($method,$api_url,$data);if($response['data']['code']=="200"){$result['code']=($response['data']['code']);$result['data']=($response['data']['data']);return $result;}else{$result['code']=$response['data']['code'];$result['msg']=$response['data']['message'];$result['error']=$response['data']['error'];$result['data']=null;return $result;}}catch(\Exception $e){return $this->ExceptionErrorHandler($e,"400",' UserController => managerAssignedEmployeeList => Method-post');}}public function AssignManager(Request $request){$api_url=$this->API_URL.'api/v1/assign-user-manager';$method='post';if($request->input('UserIds')!=null){$data['user_ids']=explode(',',$request->input('UserIds'));}else $data['user_ids']=[$request->input('User_id')];$data['manager_id']=$request->input('ManagerId');try{if($data['manager_id'][0]=="null"){$Error['Result']="501";$Error['msg']="Please select a manager";return $Error;}else{$response=$this->helper->postApiCall($method,$api_url,$data);$result['code']=$response['data']['code'];$result['msg']=$response['data']['message'];$result['data']=$response['data']['data'];return $result;}}catch(\Exception $e){return $this->ExceptionErrorHandler($e,"400",' UserController => AssignManager => Method-post');}}public function AssignMultipleManager(Request $request){$api_url=$this->API_URL.'api/v1/assign-user-manager-multi';$method='post';$data['user_id']=$request->User_id;$data['manager_ids']=explode(',',$request->input('ManagerId'));try{if($request->ManagerId==null){$Error['Result']="501";$Error['msg']="Please select a manager";return $Error;}else{$response=$this->helper->postApiCall($method,$api_url,$data);$result['code']=$response['data']['code'];$result['msg']=$response['data']['message'];$result['data']=$response['data']['data'];$result['InputData']=$data;return $result;}}catch(\Exception $e){return $this->ExceptionErrorHandler($e,"400",' UserController => AssignMultipleManager => Method-post');}}public function UnAssignManager(Request $request){$api_url=$this->API_URL_3.'api/'.$this->VERSION_3.'/user/unassign-user';if($request->input('user_id')!=null){$data['user_ids']=explode(",",$request->input('user_id'));}else{$data['user_ids']=explode(",",$request->input('user_idhide'));}$data['to_assigned_id']=$request->input('manager_id');$data['role_id']=$request->input('role_id');$method='delete';try{$response=$this->helper->postApiCall($method,$api_url,$data);if($response['code']==200){$api_url=$this->API_URL_3.'api/'.$this->VERSION_3.'/user/get-user';$method='post';$data['user_id']=$request->input('manager_id');$data['skip']="0";$data['limit']="10";$responses=$this->helper->postApiCall($method,$api_url,$data);$result['code']=($response['code']);$result['message']=($response['message']);$result['data']=($response['data']);if($responses['data']['code']==200){$result['ManagerList']=$responses['data']['data'];}else $result['ManagerList']="null";$result['HitAPI']=$request->input('HitAPI');return $result;}else{$result['code']=$response['code'];$result['message']=$response['message'];$result['data']=$response['data'];$result['error']=$response['error'];return $result;}}catch(\Exception $e){return $this->ExceptionErrorHandler($e,201,' UserController => UnAssignManager => Method-delete');}}public function AssignTLtoEmployee(Request $request){$api_url=$this->API_URL.'api/v1/assign-user-teamlead';$method='post';$data['user_ids']=$request->input('User_id')=="0"?explode(',',$request->input('User_ids')):[$request->input('User_id')];$data['teamlead_id']=$request->input('TeamLeaderId');try{$response=$this->helper->postApiCall($method,$api_url,$data);$result['code']=$response['data']['code'];$result['msg']=$response['data']['message'];$result['data']=$response['data']['data'];$result['error']=$response['data']['error'];}catch(\Exception $e){return $this->ExceptionErrorHandler($e,201,' UserController => AssignTLtoEmployee => Method-post');}return $result;}public function appTime(Request $request){$date="";if($request->isMethod("get")){$date=date("m/d/Y");}else if($request->isMethod("Post")){$date=$request->input("date");}$value="0";$skipValue="";$finalData=[];$api_url=$this->API_URL.'api/v1/apps-activity-track';$method='post';$data['user_id']=$request->input('userId');$data['date']=$date;$data['skip']="0";$data['limit']="10000";try{$response=$this->helper->postApiCall($method,$api_url,$data);if($response['data']['code']==200){array_push($finalData,$response['data']['data']['apps']);if($response['data']['data']['has_more_data']){$value++;$skipValue=$response['data']['data']['skip_value'];do{$data['skip']=$skipValue;$data['limit']="10000";$result=$this->helper->postApiCall($method,$api_url,$data);if($result['data']['code']==200){array_push($finalData,$result['data']['data']['apps']);if($result['data']['data']['has_more_data'])$skipValue=$result['data']['data']['skip_value'];else $value="0";}else $value="0";}while($value!="0");}}$result['code']=$response['data']['code'];$result['msg']=$response['data']['message'];$result['data']=$finalData;return $result;}catch(\Exception $e){return $this->ExceptionErrorHandler($e,400,' UserController => appTime => Method-post');}}public function webTime(Request $request){$date="";if($request->isMethod("get")){$date=date("m/d/Y");}else if($request->isMethod("Post")){$date=$request->input("date");}$value="0";$skipValue="";$finalData=[];$api_url=$this->API_URL.'api/v1/browser-activity-track';$method='post';$data['user_id']=$request->input('userId');$data['date']=$date;$data['skip']="0";$data['limit']="100000";try{$response=$this->helper->postApiCall($method,$api_url,$data);if($response['data']['code']==200){array_push($finalData,$response['data']['data']['apps']);if($response['data']['data']['has_more_data']){$value++;$skipValue=$response['data']['data']['skip_value'];do{$data['skip']=$skipValue;$data['limit']="10000";$result=$this->helper->postApiCall($method,$api_url,$data);if($result['data']['code']==200){array_push($finalData,$result['data']['data']['apps']);if($result['data']['data']['has_more_data'])$skipValue=$result['data']['data']['skip_value'];else $value="0";}else $value="0";}while($value!="0");}}$result['code']=$response['data']['code'];$result['msg']=$response['data']['message'];$result['data']=$finalData;return $result;}catch(\Exception $e){return $this->ExceptionErrorHandler($e,400,' UserController => webTime => Method-post');}}public function uploadBulkReg(Request $request){$method="post";$result=[];try{$file=$request->file;$pathToStorage=storage_path("bulk");if(!file_exists($pathToStorage))mkdir($pathToStorage,0777,true);$filename=$file->getClientOriginalName();$path=$pathToStorage."/".$filename;file_put_contents($path,file_get_contents($file->path()));$multipartData=array("name"=>"file","file"=>$path,);$uploadUrl=$this->API_URL_3.'api/'.$this->VERSION_3.'/user/user-register-bulk?count='.$request->input('count');$response=$this->helper->postApiCall($method,$uploadUrl,$multipartData,true);unlink(storage_path('bulk/'.$filename));return $this->helper->responseHandler($response);}catch(\Exception $e){return $this->ExceptionErrorHandler($e,500,' UserController => uploadBulkReg => Method-post');}}public function editBulkReg(Request $request){$method="post";$result=[];try{$file=$request->file;$pathToStorage=storage_path("bulk");if(!file_exists($pathToStorage))mkdir($pathToStorage,0777,true);$filename=$file->getClientOriginalName();$path=$pathToStorage."/".$filename;file_put_contents($path,file_get_contents($file->path()));$multipartData=array("name"=>"file","file"=>$path,);$uploadUrl=$this->API_URL_3.'api/'.$this->VERSION_3.'/user/bulk-update';$response=$this->helper->postApiCall($method,$uploadUrl,$multipartData,true);unlink(storage_path('bulk/'.$filename));$result['code']=$response['data']['code'];$result['msg']=$response['data']['message'];$result['data']=$response['data']['data'];$result['error']=$response['data']['error'];$result['inputData']=$request->input('count');return $result;}catch(\GuzzleHttp\Exception\RequestException $e){return $this->helper->GuzzleHTTPException($e,'editBulkReg');}}public function deleteBulkReg(Request $request){$method="post";$result=[];try{$file=$request->file;$pathToStorage=storage_path("bulk");if(!file_exists($pathToStorage))mkdir($pathToStorage,0777,true);$filename=$file->getClientOriginalName();$path=$pathToStorage."/".$filename;file_put_contents($path,file_get_contents($file->path()));$multipartData=array("name"=>"file","file"=>$path,);$uploadUrl=$this->API_URL_3.'api/'.$this->VERSION_3.'/user/user-delete-bulk';$response=$this->helper->postApiCall($method,$uploadUrl,$multipartData,true);unlink(storage_path('bulk/'.$filename));$result['code']=$response['data']['code'];$result['msg']=$response['data']['message'];$result['data']=$response['data']['data'];$result['error']=$response['data']['error'];return $result;}catch(\GuzzleHttp\Exception\RequestException $e){return $this->helper->GuzzleHTTPException($e,'deleteBulkReg');}}public function AssignMangerTL(Request $request){$SameId['code']=$error['code']="409";$error['msg']="Please, Select the option to assign...";$SameId['msg']="Please, Avoid To Assign The User To Himself...";if($request->input('role_type')==null)return $error;$api_url=$this->API_URL_3.'api/'.$this->VERSION_3.'/user/employee-assign';$method='post';if($request->input('Form')=="1"){if(in_array($request->input('User_id'),explode(",",$request->input('MangerIds'))))return $SameId;$managerId_s=explode(',',$request->input('MangerIds'));$data['employee_multi_upperole']=(object)["user_id"=>$request->input('User_id'),"role_id"=>$request->input('role_type'),"to_assign_ids"=>$managerId_s[0]!=""?$managerId_s:[]];}else if($request->input('Form')=="2"){if(in_array($request->input('MangerIds'),explode(",",$request->input('userIds'))))return $SameId;if($request->input('MangerIds')==null)return $error;$data['employee_to_assign']=(object)["user_ids"=>explode(',',$request->input('userIds')),"to_assign_id"=>$request->input('MangerIds'),"role_id"=>$request->input('role_type')];}try{$response=$this->helper->postApiCall($method,$api_url,$data);$result['code']=$response['data']['code'];$result['msg']=$response['data']['message'];$result['data']=$response['data']['data'];$result['inputData']=$request->all();$result['error']=$response['data']['error'];return $result;}catch(\Exception $e){return $this->ExceptionErrorHandler($e,"400",' UserController => AssignMangerTL => Method-post');}}public function uploadLogo(Request $request){$result=[];if($request->isMethod('get')){try{return view('User::logoUpload');}catch(\Exception $e){Log::info('exception in uploadLogo get '.$e->getMessage());}}else if($request->isMethod(('post'))){try{$validator=Validator::make($request->all(),['title'=>'required|max:255','logo'=>'required|image','favicon'=>'required|image|dimensions:max_width=1000,max_height:1000','logoname'=>'required']);if($validator->fails()){return Response::json(array('success'=>true,'errors'=>$validator->getMessageBag()->toArray()),400);}else{$result["code"]=200;}}catch(\Exception $e){$result['code']=500;$result['message']="Something went wrong. Please try again later";Log::info(" Exception in uploadLogo post ".$e->getMessage());}return $result;}}public function userUpdate(Request $request){try{$curl=curl_init();curl_setopt_array($curl,array(CURLOPT_URL=>"https://app.dev.empmonitor.com/amember/api/users/5?_key=aeLGOx5WmesWCrLa5VHp&name_f=Suresh%20Babu&numberofusers=502",CURLOPT_RETURNTRANSFER=>true,CURLOPT_ENCODING=>"",CURLOPT_MAXREDIRS=>10,CURLOPT_TIMEOUT=>0,CURLOPT_FOLLOWLOCATION=>true,CURLOPT_HTTP_VERSION=>CURL_HTTP_VERSION_1_1,CURLOPT_CUSTOMREQUEST=>"PUT",CURLOPT_HTTPHEADER=>array("Cookie: PHPSESSID=jn8uhtb1pgmqmht0qkot3rh8ev"),));$response=curl_exec($curl);curl_close($curl);if((json_decode($response,true))[0]['numberofusers']==502){echo "Your data has been updated please wait for 5 minutes....";return redirect('/amember/member');}else{echo "Data updation failed.. 5 minutes will redirect you to login page....";return redirect('');}}catch(\Exception $e){Log::info("Exception in userUpdate ".$e->getMessage()." => ".$e->getLine());return redirect('/amember/member');}}public function resellerLogin(Request $request){$logoPath='assets/images/logos/'.md5($_SERVER['HTTP_HOST']).'.png';if(!(\Illuminate\Support\Facades\File::exists(public_path($logoPath)))){Storage::disk('logos')->copy('assets/images/logos/EmpLogo.png',$logoPath);}$faviconPath='assets/images/favicons/'.md5($_SERVER['HTTP_HOST']).'.png';if(!(\Illuminate\Support\Facades\File::exists(public_path($faviconPath)))){Storage::disk('logos')->copy('assets/images/favicons/EmpFavicon.png',$faviconPath);}if($request->isMethod('get')){if(Session::has('admin')){return redirect('admin/dashboard');}return view('User::loginWhitelabel');}else if($request->isMethod('post')){$validator=Validator::make($request->all(),['password'=>'required|max:255','username'=>'required',]);if($validator->fails()){return redirect('admin-login')->withErrors($validator)->withInput();}else{$username=base64_encode($request->username);$password=base64_encode($request->password);$isClient=$request->isClient;if($isClient==="true"){return redirect('/resellerClientLogin/'.$username.'/'.$password.'/'.$isClient);}else{return redirect('/loginpageWhitelabel/'.$username.'/'.$password);}}}}public function logoutwhite(Request $request){Session::forget('admin');if(Session::has('plan')){Session::forget('plan');Session::flush();return redirect("admin-login");}else{Session::flush();return redirect('login');}}public function getOnline(Request $request){$result=[];try{$api_url=$this->API_URL_3.'api/'.$this->VERSION_3.'/dashboard/employees?date='.$request->input("date");$response=$this->helper->postApiCall('get',$api_url,[]);if($response['code']==200){$result['code']=200;$type=$request->type;switch($type){case 1:$result['data']=$response['data']['onlineEmps'];break;case 2:$result['data']=$response['data']['idleEmps'];break;case 3:$result['data']=$response['data']['absentEmp'];break;case 4:$result['data']=$response['data']['suspendedEmp'];break;case 5:$result['data']=$response['data']['registeredEmp'];break;case 6:$result['data']=$response['data']['offlineEmp'];break;default:$result['data']=$response['data'];break;}}else{$result['code']=202;$result['message']="Something went wrong.";}}catch(\Exception $e){Log::info("Exception in getAbsent ".$e->getMessage());$result['code']=500;$result['message']="Something went wrong. Please try again later";}return $result;}public function loginEmployee(Request $request){if($request->isMethod('get')){if(Session::has('employee')){return redirect(env('Employee').'/myTimeline?id='.Session::get(env('Employee'))['token']['user_id']);}return view("User::employeeLogin")->with('reset',[]);}else if($request->isMethod('post')){$rules=array("email"=>'required | email',"password"=>'required');try{$validator=Validator::make($request->all(),$rules);if($validator->fails()){return redirect()->back()->withErrors($validator)->withInput();}else{$loginData=array("userName"=>$request->email,"password"=>$request->password,"ip"=>$request->ip);$api_url=$this->API_URL.'api/v1/emp/auth';$response=$this->client->post($api_url,['form_params'=>$loginData,'headers'=>['user-agent'=>$_SERVER['HTTP_USER_AGENT'],'Content-Type'=>'application/x-www-form-urlencoded',]]);if($response->getStatusCode()==200){$response=json_decode($response->getBody()->getContents(),true);if($response['code']==200){if($response['photo_path']=='undefined')$response['photo_path']=env('DEFAULT_IMAGE');elseif(substr($response['photo_path'],0,5)==="https")$response['photo_path']=$response['photo_path'];else $response['photo_path']=env('API_HOST').$response['photo_path'];$employee=array('token'=>$response);Session::put(env('Employee'),$employee);return redirect(env('Employee').'/myTimeline?id='.Session::get(env('Employee'))['token']['user_id']);return view('User::Employee.NewEmployeeDashboard');}else if($response['code']==400){return redirect('employee-login')->with('error',$response['message']);}else{return redirect('employee-login')->with('error',$response['error']);}}}}catch(\Exception $e){Log::info('Exception '.$e->getLine()."=> code =>".$e->getCode()." => message => ".$e->getMessage());return redirect('employee-login')->with('error',$e->getMessage());}}}public function consolidatedReport(Request $request){$admin=[];if(Session::has(env('Admin'))){$admin["admin"]=1;}else{$admin["admin"]=0;$admin["user_id"]=Session::get($this->helper->getHostName())['token']['user_id'];}$location=$this->getAllLocations();$department=$this->getDepartments();return view("User::Report.consolidatedReports")->with(array('location'=>$location,'departments'=>$department,'admin'=>$admin));}public function TrackUserSettingView(Request $request){$UserData=$this->getUserTrackDetails($request,$request->id);$projectsOfUser=$this->getProjectsByUserId($request);$api=$this->API_URL_3.'api/'.$this->VERSION_3.'/settings/options';$SettingOptions=$this->helper->postApiCall('get',$api,0);if($UserData['code']===200){if(in_array($UserData['data']['tracking_rule_type'],[1,2,3])){return view('User::EmployeeDetail.trackUserSetting',["userId"=>$request->id,"data"=>$UserData,"trackUserData"=>3,"DropDownOption"=>$SettingOptions,"OrgGroups"=>$this->get_group(),'UserProjects'=>$projectsOfUser,'storageStatus'=>(new SettingsController())->storageStatus($request)]);}else{return view('User::EmployeeDetail.trackUserSetting',["userId"=>$request->id,"data"=>$UserData,"trackUserData"=>1,"DropDownOption"=>$SettingOptions,"OrgGroups"=>$this->get_group(),'UserProjects'=>$projectsOfUser]);}}else return redirect('dashboard')->with(Session::flash('message','Searched User Details Not Found'));}public function TrackUserSetting(Request $request){$fixedConstant=["1","2","3","4","5","6","7"];$days=(object)[];if($request->input('Track_rule_type')=='3'){switch($request->input('TrackingScenario')){case "unlimited":{$rules=["unlimitedDays"=>'required',];}break;case "fixed":{$rules=["FixedListTimes"=>'required',];}break;case "networkBased":{$rules=["MACaddress"=>['required','regex:/^(([0-9-]|[1-9][0-9-]|1[0-9-][0-9-]|2[0-4][0-9-]|25[0-5])(\.(?!$)|$)){4}$/i'],];}break;case "projectBased":{$rules=["projectBasedIds"=>'required'];}break;default:{$rules=["default"=>"default"];}}$customMessage=['MACaddress.required'=>__('messages.mac_ip_required'),'MACaddress.regex'=>__('messages.valid_mac_ip'),'geoLocation.required'=>__('messages.required'),];$validator=Validator::make($request->all(),$rules,$customMessage);if($validator->fails()){$data['code']="205";$data['errors']=$validator->errors();return $data;}if($this->helper->checkOrgIdle()){if($request->input('TrackingScenario')==='geoLocation'&&$request->geoLocation=="[]"){$data['code']="408";$data['errors']=__('messages.required');return $data;}}}try{$trackScenario=new \stdClass();switch($request->input('TrackingScenario')){case "unlimited":{$trackScenario=(object)["unlimited"=>(object)["day"=>$request->input('unlimitedDays'),],"domain"=>[],];}break;case "fixed":{foreach(explode(",",$request->input('FixedListTimes'))as $validate){$time=explode("#",$validate);switch($time[0]){case "MONDAY":{$days->mon=(object)["status"=>"true","time"=>(object)["start"=>$time[1],"end"=>$time[2]]];$fixedConstant=\array_diff($fixedConstant,["1"]);}break;case "TUESDAY":{$days->tue=(object)["status"=>"true","time"=>(object)["start"=>$time[1],"end"=>$time[2]]];$fixedConstant=\array_diff($fixedConstant,["2"]);}break;case "WEDNESDAY":{$days->wed=(object)["status"=>"true","time"=>(object)["start"=>$time[1],"end"=>$time[2]]];$fixedConstant=\array_diff($fixedConstant,["3"]);}break;case "THURSDAY":{$days->thu=(object)["status"=>"true","time"=>(object)["start"=>$time[1],"end"=>$time[2]]];$fixedConstant=\array_diff($fixedConstant,["4"]);}break;case "FRIDAY":{$days->fri=(object)["status"=>"true","time"=>(object)["start"=>$time[1],"end"=>$time[2]]];$fixedConstant=\array_diff($fixedConstant,["5"]);}break;case "SATURDAY":{$days->sat=(object)["status"=>"true","time"=>(object)["start"=>$time[1],"end"=>$time[2]]];$fixedConstant=\array_diff($fixedConstant,["6"]);}break;case "SUNDAY":{$days->sun=(object)["status"=>"true","time"=>(object)["start"=>$time[1],"end"=>$time[2]]];$fixedConstant=\array_diff($fixedConstant,["7"]);}}}if(count($fixedConstant)!=0){foreach($fixedConstant as $numbers){switch($numbers){case "1":{$days->mon=(object)["status"=>"false","time"=>(object)["start"=>"10:00","end"=>"11:00"]];}break;case "2":{$days->tue=(object)["status"=>"false","time"=>(object)["start"=>"10:00","end"=>"11:00"]];}break;case "3":{$days->wed=(object)["status"=>"false","time"=>(object)["start"=>"10:00","end"=>"11:00"]];}break;case "4":{$days->thu=(object)["status"=>"false","time"=>(object)["start"=>"10:00","end"=>"11:00"]];}break;case "5":{$days->fri=(object)["status"=>"false","time"=>(object)["start"=>"10:00","end"=>"11:00"]];}break;case "6":{$days->sat=(object)["status"=>"false","time"=>(object)["start"=>"10:00","end"=>"11:00"]];}break;case "7":{$days->sun=(object)["status"=>"false","time"=>(object)["start"=>"10:00","end"=>"11:00"]];}}}}$trackScenario=(object)["fixed"=>$days,"domain"=>[],];}break;case "networkBased":{$trackScenario=(object)["networkBased"=>(object)["networkName"=>$request->input('NetworkName'),"ipAddress"=>$request->input('MACaddress'),"officeNetwork"=>$request->input('officeNetwork')],"domain"=>[],];}break;case "manual":{$trackScenario=(object)["manual"=>(object)["day"=>"1,2,3,4,5,6"],"domain"=>[],];}break;case "projectBased":{$projectsArray=[];foreach(explode(",",$request->input('projectBasedIds'))as $projects){array_push($projectsArray,(object)['id'=>$projects,]);}$trackScenario=(object)["projectBased"=>$projectsArray,];}break;case "geoLocation":{$geoLocation=[];$response=json_decode($request->geoLocation);$temp=[];foreach($response as $res){$temp["location"]=$res->location;$temp["lon"]=$res->lon;$temp["lat"]=$res->lat;$temp["distance"]=$res->distance;array_push($geoLocation,(object)$temp);}$trackScenario=(object)["geoLocation"=>$geoLocation];}}$video1280=0;$video1080=0;$video720=0;$data['employee_id']=$request->input('UserId');$data['type']=($request->input('Track_rule_type')=='undefined')?3:$request->input('Track_rule_type');$data['group_id']=($request->input('group_id'));$frequencyPerHour=($this->helper->checkOrangeClient())?2:$request->input('SSFrequency');$ScreenshotsOption=($this->helper->checkOrangeClient())?0:$request->input('ScreenshotsOption');$data['track_data']=(object)["system"=>(object)["type"=>$request->input('SystemRoll'),"visibility"=>$request->input('EmpIcon'),'autoUpdate'=>$request->input('auto_update')],"screenshot"=>(object)["frequencyPerHour"=>$frequencyPerHour,],"screenRecord"=>(object)["ultrafast_1280_21"=>$video1280,"ultrafast_1080_21"=>$video1080,"ultrafast_720_21"=>$video720,],"features"=>(object)["application_usage"=>"0","web_usage"=>$request->input('WebsiteOption'),"keystrokes"=>$request->input('KeyStrokeOption'),"screenshots"=>$ScreenshotsOption,"block_websites"=>$request->input('BlockWebsiteOption'),],"breakInMinute"=>30,"timesheetIdleTime"=>$request->input('timesheetIdleTime'),"idleInMinute"=>$request->input('IdleTime'),"trackingMode"=>($request->input('TrackingScenario')),"tracking"=>(object)$trackScenario,"manual_clock_in"=>($request->input('manual_clock_in')),"is_attendance_override"=>($request->input('is_attendance_override')),"usbDisable"=>$request->input('usbDisable'),"systemLock"=>$request->input('systemLock'),"userBlock"=>$request->userBlock,"block"=>(object)array("contact"=>$request->userBlockContact,"email"=>$request->userBlockEmail,"logo"=>$request->userBlockLogo,)];if(isset(json_decode($request->input('domainTrackData'))->tracking->domain)){$trackScenario->domain=json_decode($request->input('domainTrackData'))->tracking->domain;if(isset($trackScenario->domain->suspendPrivateBrowsing))$trackScenario->domain->suspendPrivateBrowsing=($trackScenario->domain->suspendPrivateBrowsing=='true'||$trackScenario->domain->suspendPrivateBrowsing==true)?'true':'false';if(isset($trackScenario->domain->suspendKeystrokesPasswords)){if(($trackScenario->domain->suspendKeystrokesPasswords=='true')){$trackScenario->domain->suspendKeystrokesPasswords="true";}else{$trackScenario->domain->suspendKeystrokesPasswords="false";}}}if(isset($trackScenario->domain->daysAndTimes)){foreach($trackScenario->domain->daysAndTimes as $key=>$value){$trackScenario->domain->daysAndTimes->$key->status=$value->status=="true"?"true":"false";}}$api_url=$this->API_URL_3.'api/'.$this->VERSION_3.'/settings/user-tracking-setting';$method="post";$response=$this->helper->postApiCall($method,$api_url,$data);return $this->helper->responseHandler($response);}catch(\Exception $e){return $this->ExceptionErrorHandler($e,405,' UserController => TrackUserSetting => Method-post');}return $result;}public function AdvanceTrackUserSetting(Request $request){($request->login_from_other_system==='1')&&($this->agentLogout($request->employee_id));$data['track_data']=(json_decode($request->track_data,true));$data['employee_id']=$request->employee_id;$data['type']=$request->type;$data['group_id']=$request->group_id;$data['track_data']['system']['visibility']=$data['track_data']['system']['visibility']==true?'true':"false";if((isset($data['track_data']['screenshot']['employeeAccessibility'])))$data['track_data']['screenshot']['employeeAccessibility']=$data['track_data']['screenshot']['employeeAccessibility']==true?'true':"false";if((isset($data['track_data']['screenshot']['employeeCanDelete'])))$data['track_data']['screenshot']['employeeCanDelete']=$data['track_data']['screenshot']['employeeCanDelete']==true?'true':"false";if((isset($data['track_data']['task']['employeeCanCreateTask'])))$data['track_data']['task']['employeeCanCreateTask']=$data['track_data']['task']['employeeCanCreateTask']==true?'true':"false";if((isset($data['track_data']['tracking']['fixed']))){foreach($data['track_data']['tracking']['fixed']as $key=>$value){$data['track_data']['tracking']['fixed'][$key]['status']=$value["status"]=="true"?"true":"false";}}if(isset($data['track_data']['tracking']['app']['daysAndTimes'])){foreach($data['track_data']['tracking']['app']['daysAndTimes']as $key=>$value){$data['track_data']['tracking']['app']['daysAndTimes'][$key]['status']=$value["status"]=="true"?"true":"false";}}if($request->MONITORONOFF=="on"){$request->MONITORONOFF="true";}else if($request->MONITORONOFF=="off"){$request->MONITORONOFF="false";}else{if(isset($data['track_data']['tracking']['domain']['suspendKeystrokesPasswords'])){$request->MONITORONOFF=$data['track_data']['tracking']['domain']['suspendKeystrokesPasswords']=='true'?'true':"false";}}$errors=[];$needle=['\\','/'];$array1=($request->userTrackingWebsite!=null)?$request->userTrackingWebsite:[];$array2=($request->userTracSuspendWebsiteVisit!=null)?$request->userTracSuspendWebsiteVisit:[];$array3=($request->userTracSuspendKeystrokeWebsite!=null)?$request->userTracSuspendKeystrokeWebsite:[];$check=[];$check2=[];$MonitorWebsite=[];$MonitorWebsitedata=[];$SuspendMonitorWebsite=[];$SuspendMonitorWebsitedata=[];$websiteSuspendKeystrokeWebsite=[];$blockingApplication=[];$blockingWebsitesData=[];$blockingWebsites=[];$websiteSuspendKeystrokeWebsitedata=[];if(count($array1)>0&&count($array2)>0)$check=array_intersect($array1,$array2);if(count($check)>0){$response['code']=404;$response['msg']=__('messages.duplicateValue');$response['data']=null;return $response;}$pattern="/\b(?:\.)[-a-z0-9+&@#\/%?=~_|!:,.;]*[-a-z0-9+&@#\/%=~_|]/i";if($request->userTrackingWebsite!=null){foreach($request->userTrackingWebsite as $key=>$value){if(!(preg_match($pattern,$value))){$errors[]=$value;}else{$domainData=$this->get_domain($value);if(!in_array($domainData,$MonitorWebsite)){$MonitorWebsite[]=$domainData;$MonitorWebsitedata[]=$value;}}}if(count($errors)>0){$valid=$this->urlValidationFunction($errors,201);if($valid!=null)return Response::json($valid,200);}else{$request->userTrackingWebsite=$MonitorWebsitedata;}}if($request->userTracSuspendWebsiteVisit!=null){foreach($request->userTracSuspendWebsiteVisit as $key=>$value){if(!(preg_match($pattern,$value))){$errors[]=$value;}else{$domainData=$this->get_domain($value);if(!in_array($domainData,$SuspendMonitorWebsite)){$SuspendMonitorWebsite[]=$domainData;$SuspendMonitorWebsitedata[]=$value;}}}if(count($errors)>0){$valid=$this->urlValidationFunction($errors,202);if($valid!=null)return Response::json($valid,200);}else{$request->userTracSuspendWebsiteVisit=$SuspendMonitorWebsitedata;}}if($request->userTracSuspendKeystrokeWebsite!=null){foreach($request->userTracSuspendKeystrokeWebsite as $key=>$value){if(!(preg_match($pattern,$value))){$errors[]=$value;}else{$domainData=$this->get_domain($value);if(!in_array($domainData,$websiteSuspendKeystrokeWebsite)){$websiteSuspendKeystrokeWebsite[]=$domainData;$websiteSuspendKeystrokeWebsitedata[]=$value;}}}if(count($errors)>0){$valid=$this->urlValidationFunction($errors,203);if($valid!=null)return Response::json($valid,200);}else{$request->userTracSuspendKeystrokeWebsite=$websiteSuspendKeystrokeWebsitedata;}}if($request->userTrackBlockingWebsite!=null){foreach($request->userTrackBlockingWebsite as $key=>$value){$url=preg_replace("(^https?://)","",$value);$url=strpos($url,'www')!==0?"www.$url":$url;if(!(preg_match($pattern,$url))){$errors[]=$url;}else{$domainData=$this->get_domain($url);if(!in_array($domainData,$blockingWebsites)){$blockingWebsites[]=$domainData;$blockingWebsitesData[]=$url;}}}if(count($errors)>0){$valid=$this->urlValidationFunction($errors,405);if($valid!=null)return Response::json($valid,200);}else{$request->userTrackBlockingWebsite=$blockingWebsitesData;}}if($request->userTrackBlockingApplciation!=null){$blockingApplication=implode(",",$request->input('userTrackBlockingApplciation'));}else $blockingApplication="";if(count($MonitorWebsite)>0&&count($SuspendMonitorWebsite)>0&&count($blockingWebsites)>0)$check=array_intersect($MonitorWebsite,$SuspendMonitorWebsite,$blockingWebsites);if(count($check)>0){$response['code']=404;$response['msg']=__('messages.duplicateValue');$response['data']=null;return $response;}$data['track_data']['usbDisable']=$request->USB_feature;$data['track_data']['tracking']['domain']=array("monitorOnly"=>$request->userTrackingWebsite,"suspendMonitorWhenVisited"=>$request->userTracSuspendWebsiteVisit,"suspendKeystrokesWhenVisited"=>$request->userTracSuspendKeystrokeWebsite,"websiteBlockList"=>$request->userTrackBlockingWebsite,"appBlockList"=>$blockingApplication,"suspendKeystrokesPasswords"=>$request->MONITORONOFF);$data['track_data']['userBlock']=(int)$request->userBlock;$customMessage=['userBlockContact.required'=>__('Contact is required'),'userBlockEmail.required'=>__('Email is required'),];$rules=["userBlockContact"=>'required',"userBlockEmail"=>'required'];$validator=Validator::make($request->all(),$rules,$customMessage);if((int)$request->userBlock===1&&$validator->fails()){$error['code']=205;$error['errors']=$validator->errors();return $error;}$data['track_data']['block']=(object)array("contact"=>$request->userBlockContact,"email"=>$request->userBlockEmail,"logo"=>$request->userBlockLogo,);try{$api_url=$this->API_URL_3.'api/'.$this->VERSION_3.'/settings/user-tracking-setting';$method="post";$response=$this->helper->postApiCall($method,$api_url,$data);if($response['statusCode']==200){if($response['data']['code']==200){$result['code']=200;$result['advanceWebsiteData']=$data['track_data']['tracking']['domain'];$result['msg']=$response['data']['message'];}else{$result['code']=$response['data']['code'];$result['msg']=$response['data']['code']==400?$response['data']['message']:$result['msg']=$response['data']['code']==404?$response['data']['error']:$response['data']['message'];}}}catch(\Exception $e){$result=$this->ExceptionErrorHandler($e,405,' UserController => TrackUserSetting => Method-post');}return $result;}public function getUserTrackDetails(Request $request,$id){$api=$this->API_URL_3.'api/'.$this->VERSION_3.'/settings/get-emp-setting-trac';$method="post";$data['employee_id']=$id;try{$response=$this->helper->postApiCall($method,$api,$data);if($response['data']['code']==200){if(!(isset($response['data']['data']['custom_tracking_rule']['tracking']['domain']))){$response['data']['data']['custom_tracking_rule']['tracking']['domain']['suspendKeystrokesPasswords']="true";}}$result['code']=$response['data']['code'];$result['msg']=$response['data']['message'];$result['data']=$response['data']['data'];}catch(\Exception $e){return $this->ExceptionErrorHandler($e,205,' UserController => TrackUserSetting => Method-post');}return($result);}public function loginPageNewAPI(Request $request,$username=null){if(Session::has('admin')){return redirect('dashboard');}try{$checkUserCount=0;$apikey=env('APP_AMEMBER_KEY');$result=json_decode($this->curl_execution(env('APP_AMEMBER_URL')."check-access/by-login?_key=$apikey&login=$request->username"),true);if($result['ok']&&!empty($result['subscriptions'])){$plan=[];$checkPlan=$this->checkPlans($result['subscriptions']);$totalFileds=\GuzzleHttp\json_decode($this->curl_execution(env('APP_AMEMBER_URL')."users?_key=$apikey&_filter[user_id]=".$result['user_id']),true);$resultInvoice=json_decode($this->curl_execution(env('APP_AMEMBER_URL')."invoices?_key=".$apikey."&_filter[user_id]=".$result['user_id']),true);$adminInfo=json_decode($this->curl_execution(env('APP_AMEMBER_URL')."users?_key=".$apikey."&_filter[user_id]=".$result['user_id']),true);$currentPlanIndex=$this->checkActiveInvoice($resultInvoice,$checkPlan);if(isset($totalFileds[0]['numberofusers'])){if($resultInvoice['_total']!=0){if($currentPlanIndex!='-1'){$currentPlan=$resultInvoice[$currentPlanIndex];$currentPlan=$currentPlan['nested']['invoice-items'];$options=json_decode($currentPlan[0]['options']);if(isset($options->{'No of Users'})){if((int)$totalFileds[0]['numberofusers']>=(int)$options->{'No of Users'}->value){$checkUserCount=1;}}else{$checkUserCount=1;}}}else if($totalFileds[0]['numberofusers']!=""&&$totalFileds[0]['numberofusers']!=0){$checkUserCount=1;}}if(isset($totalFileds[0]['numberofusers'])&&$checkUserCount==1){$plan['item_id']=$checkPlan;$plan['item_title']="Manually-Added-User";$plan['no_of_users']=$totalFileds[0]['numberofusers'];$plan['email']=$result['email'];$plan['name']=$result['name'];$plan['avatar']=env('APP_URL')."amember/avatar/".$totalFileds[0]['avatar'];Session::put('plan',$plan);$result['product_id']=$checkPlan;$result['begin_date']=date('Y-m-d');$result['expire_date']=$result['subscriptions'][$checkPlan];}else if($resultInvoice['_total']!=0){if($currentPlanIndex!='-1'){$currentPlan=$resultInvoice[$currentPlanIndex];$currentPlan=$currentPlan['nested']['invoice-items'];$keyAccess=0;for($k=0;$k<count($resultInvoice[$currentPlanIndex]['nested']['access']);$k++){if($resultInvoice[$currentPlanIndex]['nested']['access'][$k]['expire_date']>date('Y-m-d')){$keyAccess=$k;}}$result['product_id']=$resultInvoice[$currentPlanIndex]['nested']['access'][$keyAccess]['product_id']?$resultInvoice[$currentPlanIndex]['nested']['access'][0]['product_id']:'';$result['begin_date']=$resultInvoice[$currentPlanIndex]['nested']['access'][$keyAccess]['begin_date']?$resultInvoice[$currentPlanIndex]['nested']['access'][0]['begin_date']:'';$result['expire_date']=$resultInvoice[$currentPlanIndex]['nested']['access'][$keyAccess]['expire_date'];$options=json_decode($currentPlan[0]['options']);$plan['item_id']=$currentPlan[0]['item_id'];$plan['item_title']=$currentPlan[0]['item_title'];$plan['no_of_users']=$options->{'No of Users'}->value;$plan['email']=$result['email'];$plan['name']=$result['name'];$plan['avatar']=env('APP_URL')."amember/avatar/".$adminInfo[0]['avatar'];Session::put('plan',$plan);}else{return redirect('login-member')->with('error','Invalid subscription');}}else{return redirect('login-member')->with('error','Invalid subscription');}}else{if(isset($result['msg'])){return redirect('login-member')->with('error',$result['msg']);}return redirect('login-member')->with('error','Something went wrong. Please contact support Team');}$api_url=$this->API_URL_3.'api/'.env('API_VERSION_3').'/auth/admin';$method="post";$amemberData=array("name"=>$result['name'],"first_name"=>$result['name_f'],"last_name"=>$result['name_l'],"email"=>$result['email'],"username"=>$result['login'],"product_id"=>$result['product_id'],"begin_date"=>$result['begin_date'],"expire_date"=>$result['expire_date'],"timezone"=>"Africa/Bamako");$adminAuthResponse=$this->client->post($api_url,['form_params'=>$amemberData,'headers'=>['user-agent'=>$_SERVER['HTTP_USER_AGENT'],'Content-Type'=>'application/x-www-form-urlencoded',]]);if($adminAuthResponse->getStatusCode()==200){$adminAuthResponse=json_decode($adminAuthResponse->getBody()->getContents(),true);if($adminAuthResponse['code']==200){Session::put('locale',$adminAuthResponse['language']);$admin=array('token'=>array('data'=>$adminAuthResponse['data'],'is_admin'=>$adminAuthResponse['is_admin'],'is_manager'=>$adminAuthResponse['is_manager'],'is_teamlead'=>$adminAuthResponse['is_teamlead'],'login'=>$result['login'],'email'=>$result['email']));$role=str_replace(' ','',strtolower($adminAuthResponse['role']));Session::put('role',$role);Session::put($role,$admin);if(isset($_POST['remember'])){setcookie('member_name',$request->username,time()+(365*24*60*60),['httponly'=>true,'secure'=>true,'samesite'=>'Strict']);setcookie('member_password',$request->password,time()+(365*24*60*60),['httponly'=>true,'secure'=>true,'samesite'=>'Strict']);}else{setcookie('member_name','');setcookie('member_password','');}return redirect('dashboard');}else{return redirect('login-member')->with('error','Invalid authentication');}}else{return redirect('login-member')->with('error','Invalid authentication');}}catch(\Exception $e){Log::info('Exception '.$e->getLine()."=> code =>".$e->getCode()." => message => ".$e->getMessage());return redirect('login-member')->with('error','Something went wrong. Please contact support Team');}}public function memberLogin(Request $request){if(Session::has('admin')){return redirect('dashboard');}return view('User::login-member')->with('reset',[]);}public function ExceptionErrorHandler($exception,$code,$functionName){Log::info('Exception '.$exception->getLine()." => Function Name => ".$functionName." => code =>".$exception->getCode()." => message => ".$exception->getMessage());$result['code']=$code;$result['msg']="Please, Reload and try again...";$result['ErrorMessage']=$exception->getMessage();return $result;}public function guzzleErrorHandler($guzzleException,$functionName){$response=$guzzleException->getResponse();$result['code']=403;$result['msg']=$response->reasonPhrase;Log::info("GuzzleException => Function Name => ".$functionName."=> code =>".$result['code']." => message => ".$result['msg']);return $result;}public function DownloadUserSetup(Request $request){return view("User::download_setup_link",["DownloadLinksDetails"=>$this->DownloadLinks()]);}public function DownloadLinks(){$api='https://service.empmonitor.com/api/v3/organization-build/build-on-premise?email='.Session::get(env('Admin'))['token']['email'];try{$response=$this->helper->postApiCall("get",$api,[]);$result['code']=$response['code'];$result['msg']=$response['message'];$result['data']=$response['data'];$result['error']=$response['error'];if($result['code']===400){$this->GenerateBuilds();}return $result;}catch(\Exception $e){return $this->ExceptionErrorHandler($e,400,' UserController => DownloadLinks => Method-post');}}public function GenerateBuilds(){$api=$this->API_URL_3.'api/'.$this->VERSION_3.'/build/create';try{$input['email']=Session::get('admin')['token']['email'];$response=$this->helper->postApiCall("post",$api,$input);$result['code']=$response['code'];$result['msg']=$response['message'];$result['data']=$response['data'];$result['error']=$response['error'];return $result;}catch(\Exception $e){return $this->ExceptionErrorHandler($e,400,' UserController => GenerateBuilds => Method-post');}}public function empAttendanceSheet(){return view("User::EmployeeDetail.emp_attendance",["LocationData"=>$this->getAllLocations(),"DepartementData"=>$this->getDepartments(),"TodayDate"=>date('M/Y')]);}public function attendanceListEmployees(Request $request){$date=$request->input('date')!=null?$request->input('date'):date('Ym');try{$dptId=$request->input('DepartmentId')!=null&&$request->input('DepartmentId')!="null"?'&departmentId='.$request->input('DepartmentId'):"";$locId=$request->input('LocationId')!=null&&$request->input('LocationId')!="null"?'&locationId='.$request->input('LocationId'):"";$skip=$request->input('skip')!=null&&$request->input('skip')!="null"?'&skip='.$request->input('skip'):"";$searchText=$request->input('searhcText')!=null&&$request->input('searhcText')!="null"?'&search='.$request->input('searhcText'):"";$sortName=$request->input('sortName')!=null&&$request->input('sortName')!="null"?'&sortColumn='.$request->input('sortName'):"";$sortOrder=$request->input('sortOrder')!=null&&$request->input('sortOrder')!="null"?'&sortOrder='.$request->input('sortOrder'):"";$limit=$request->input('limit')!=null&&$request->input('limit')!="null"?'&limit='.$request->input('limit'):"";$api=$this->API_URL_3.'api/'.$this->VERSION_3.'/employee/attendance-sheet?date='.$date.$limit.$locId.$dptId.$skip.$searchText.$sortName.$sortOrder;$response=$this->helper->postApiCall('get',$api,[]);return $this->helper->responseHandlerWithoutStatusCode($response);}catch(\GuzzleHttp\Exception\RequestException $e){return $this->helper->GuzzleHTTPException($e,"attendanceListEmployees");}return $result;}public function permissionDenied(){return view('User::permissionDenied');}public function excelAllDataOfUsers(Request $request){$api=$this->API_URL_3.'api/'.$this->VERSION_3.'/user/employee-list';$data['status']=$request->input('Status');$request->input('Location')!=0&&$request->input('Location')!='null'?$data['location_id']=$request->input('Location'):null;$request->input('Department')!=0&&$request->input('Department')!='null'?$data['department_id']=$request->input('Department'):null;$request->input('Role')!=0&&$request->input('Role')!='null'?$data['role_id']=$request->input('Role'):null;$request->input('SearchText')!=null?$data['name']=$request->input('SearchText'):null;$request->input('employeeId_s')!=null?$data['employee_ids']=explode(',',$request->input('employeeId_s')):null;try{$response=$this->helper->postApiCall("post",$api,$data);return $this->helper->responseHandler($response);}catch(\GuzzleHttp\Exception\RequestException $e){return $this->helper->GuzzleHTTPException($e,' UserController => excelAllDataOfUsers => Method-post');}}public function get_group(){try{$api_url=$this->API_URL_3.'api/'.env('API_VERSION_3').'/groups';$method="get";try{$response=$this->helper->postApiCall($method,$api_url,0);return $this->helper->responseHandlerWithoutStatusCode($response);}catch(\GuzzleHttp\Exception\RequestException $e){return $this->guzzleErrorHandler($e,' SettingsController => get_group => Method-get ');}}catch(\Exception $e){return $this->helper->errorHandler($e,' SettingsController => get_group => Method-get ');}}function get_domain($url){$pieces=parse_url($url);$domain=isset($pieces['host'])?$pieces['host']:$pieces['path'];if(preg_match('/(?P<domain>[a-z0-9][a-z0-9\-]{1,63}\.[a-z\.]{2,6})$/i',$domain,$regs)){return $regs['domain'];}return false;}public function urlValidationFunction(array$errors,$code){if(count($errors)>0){$response['code']=$code;$response['msg']=array_unique($errors);$response['data']=null;return $response;}}public function adminForgotPassword(Request $request){$validator=Validator::make($request->all(),['adminEmailId'=>'required|email',],['adminEmailId.required'=>'Email id is required','adminEmailId.min'=>'The admin email id must be a valid email address.',]);if($validator->fails()){$response['code']=201;$response['msg']=$validator->errors()->all();$response['data']=null;return Response::json($response,200);}$result=[];$data['email']=$request->adminEmailId;$data['isClient']=$request->isClient;$apiUrl='/password/admin/reset';if($request->isClient==="true")$apiUrl='/password/forgot-password';try{$api_url=$this->API_URL_3.'api/'.$this->VERSION_3.$apiUrl;$response=$this->helper->postApiCall("post",$api_url,$data);return $this->helper->responseHandler($response);}catch(\Exception $e){Log::info('Exception '.$e->getLine()."=> code =>".$e->getCode()." => message => ".$e->getMessage());$result['code']=500;$result['msg']="Something went wrong...";return $result;}}public function adminResetPassword(Request $request){return view("User::resellerPasswordReset");}public function adminNewPassword(Request $request){$validator=Validator::make($request->all(),["new_password"=>'required|min:8',"confirm_password"=>'required|same:new_password'],['new_password.required'=>'password is required','new_password.min'=>'Minimum 8 charecters Required','confirm_password.required'=>'confirm password is required','confirm_password.same'=>'password mismatch',]);if($validator->fails()){$response['code']=201;$response['msg']=$validator->errors()->all();$response['data']=null;return Response::json($response,200);}$amember_id=Session::get('adminForPassAmmId');$result=json_decode($this->curl_execution(env('APP_AMEMBER_URL')."users/".$amember_id."?_method=PUT&_key=".env('APP_AMEMBER_KEY')."&pass=".$request->new_password),true);if(isset($result['0']['user_id'])&&$result['0']['user_id']==$amember_id){$result['code']=200;$result['data']=null;$result['msg']="success";}else{$result['code']=400;$result['data']=null;$result['msg']="error";}return $result;}public function verifyAdminForgotPassword(Request $request){$adminForPassAmmId=$this->encryptDecryptPswd($request,2,$request->id);Session::forget('adminForPassAmmId');Session::put('adminForPassAmmId',$adminForPassAmmId);try{if(isset($request->id)){return redirect('admin-reset-password');}else{return redirect('admin-login');}}catch(\Exception $e){Log::info('Exception '.$e->getLine()."=> code =>".$e->getCode()." => message => ".$e->getMessage());$result['code']=500;$result['msg']="Something went wrong...";return $result;}}/**
* encryptDecryptPswd
* *This is used for hashing the password to improve security
* @param mixed $request
* @param mixed $param
* @param string $password
* @return void
*/ public function encryptDecryptPswd(Request $request,$param,$password){$name=$request->input('password');$encryptionMethod=env('PASSWORD_ALGORITHM');$secret=env('CRYPTO_PASSWORD');$iv=env('PASSWORD_IV');$encryptedMessage=openssl_encrypt($name,$encryptionMethod,$secret,0,$iv);$decryptedMessage=openssl_decrypt($password,$encryptionMethod,$secret,0,$iv);if(!$decryptedMessage)$decryptedMessage="";return $param===1?$encryptedMessage:$decryptedMessage;}public function getProjectsByUserId(Request $request){try{$employeeId="employee_ids=[".$request->input('id')."]";$api=$this->API_URL_3.'api/'.$this->VERSION_3.'/project/get-employees-all-projects?'.$employeeId;$result=$this->helper->postApiCall('get',$api,0);return $this->helper->responseHandlerWithoutStatusCode($result);}catch(\Exception $e){return $this->ExceptionErrorHandler($e,205,' UserController => TrackUserSetting => Method-post');}}public function unInstallerDownload(Request $request){$file=$request->input('type')==="1"?($request->input('bit')==="32"?public_path()."/UninstallerFile/Uninstaller(x86)_employeeID.rar":public_path()."/UninstallerFile/Uninstaller(x64)_employeeID.rar"):($request->input('bit')==="32"?public_path()."/UninstallerFile/Uninstaller(x86)_organizationID.rar":public_path()."/UninstallerFile/Uninstaller(x64)_organizationID.rar");$name=$request->input('bit')==="32"?"Uninstaller(x86)_":"Uninstaller(x64)_";$headers=array('Content-Type: application/rar',);$Id=$request->input('type')==="1"?$request->id:Session::get(env('Admin'))['token']['organization_id'];return Response::download($file,$name.$Id.'.rar',$headers);}public function getLogo(Request $request){$api=$this->API_URL_3.'api/'.$this->VERSION_3.'/organization/upload-logo';try{$result=$this->helper->postApiCall("get",$api,[]);if($result['code']===200){return $result;}else{$documents["file"]=array("name"=>"file","file"=>config('app.url').'assets/images/logos/remote_lock_logo.png');$api_url=$this->API_URL_3.'api/'.$this->VERSION_3.'/organization/upload-logo';$data=$this->helper->postApiCall("post",$api_url,$documents['file'],true);if($data['statusCode']===200){return $data['data'];}}}catch(\Exception $e){return $this->ExceptionErrorHandler($e,400,' UserController => getLogo => Method-get');}}public function userBlockLogo(Request $request){$file=$request->file_documents;try{$pathToStorage=public_path('assets/hrms/assets/image');;if(!file_exists($pathToStorage)){mkdir($pathToStorage,0777,true);}$filename=$file->getClientOriginalName();$filename=str_replace(' ','',$filename);$path=$pathToStorage."/".$filename;file_put_contents($path,file_get_contents($file->path()));$documents["file"]=array("name"=>"file","file"=>$path);$api_url=$this->API_URL_3.'api/'.$this->VERSION_3.'/organization/upload-logo';$result=$this->helper->postApiCall("post",$api_url,$documents['file'],true);unlink($path);return $result;}catch(\Exception $e){return $this->ExceptionErrorHandler($e,"400",'PayrollController => fileUploadForEmployee => Method-post');}}public function agentLogout($emp_id){$api_url=$this->API_URL_3.'api/'.$this->VERSION_3.'/auth/agent-logout?employeeId='.$emp_id;try{return $this->helper->postApiCall('get',$api_url,[]);}catch(\Exception $e){return $this->helper->errorHandler($e,' EmployeeDetailsController => agentLogout => Method-get ');}}public function agentEmpLogout(Request $request){try{$response=$this->agentLogout($request->emp_id);if($response['code']==200){$result['code']=200;$result['data']=$response['data'];$result['msg']=$response['message'];}else{$result['code']=$response['code'];$result['msg']=$response['code']==400?$response['message']:$response['error'];}return $result;}catch(\Exception $e){return $this->helper->errorHandler($e,' EmployeeDetailsController => agentLogout => Method-get ');}}public function getToAssignedDetails(Request $request){$api_url=$this->API_URL_3.'api/'.$this->VERSION_3.'/user/get-user';$method='post';try{$response=$this->helper->postApiCall($method,$api_url,$request->all());return $this->helper->responseHandler($response);}catch(\Exception $e){return $this->ExceptionErrorHandler($e,"400",' UserController => getToAssignedDetails => Method-post');}}public function getSuperiorData(Request $request){$api_url=$this->helper->API_URL_3.'/user/employee-assigned-to';try{$response=$this->helper->postApiCall('post',$api_url,$request->all());return $this->helper->responseHandler($response);}catch(\Exception $e){return $this->ExceptionErrorHandler($e,"400",' UserController => getToAssignedDetails => Method-post');}}public function getActiveUnactiveData(Request $request){try{$api_url=$this->API_URL_3.'api/'.env('API_VERSION_3').'/timesheet/?location_id='.$request->locationId.'&department_id='.($request->departmentId==='null'?'0':$request->departmentId).'&start_date='.$request->start_date.'T00:00:00.000Z&end_date='.$request->end_date.'T00:00:00.000Z&employee_id=0';$method="get";try{$response=$this->helper->postApiCall($method,$api_url,$request->all());if($response['code']==200){$result['code']=200;$result['msg']=$response['message'];$resultData=[];foreach($response['data']['user_data']as $value){if(array_key_exists($value['id'],$resultData)){$resultData[$value['id']]['computer_activities_time']=(int)$resultData[$value['id']]['computer_activities_time']+(int)$value['computer_activities_time'];}else{$resultData[$value['id']]=$value;}}$result['data']=$resultData;}else{$result['code']=400;$result['msg']=$response['code']==400?$response['message']:$response['error'];$result['data']=$response['data'];}return $result;}catch(\GuzzleHttp\Exception\RequestException $e){return $this->guzzleErrorHandler($e,' UserController => getActiveUnactiveData => Method-get ');}}catch(\Exception $e){return $this->helper->errorHandler($e,' UserController => getActiveUnactiveData => Method-get ');}}public function AssignShift(Request $request){try{$api_url=$this->helper->API_URL_3.'/user/assign-shift-bulk-employees';$method='put';if($request->input('seluserids')!=null){$data['employees_id']=explode(',',$request->input('seluserids'));}else $data['employees_id']=[$request->input('seluserids')];$data['shift_id']=$request->input('shiftId');$response=$this->helper->postApiCall($method,$api_url,$data);return $response;}catch(\Exception $e){return $this->ExceptionErrorHandler($e,"400",' UserController => AssignShift => Method-put');}}public function employeeAttendanceSheet(){return view("User::employee_attendance",["LocationData"=>$this->getAllLocations(),"DepartementData"=>$this->getDepartments(),"TodayDate"=>date('M/Y')]);}public function employeeAttendanceList(Request $request){$date=$request->input('date')!=null?$request->input('date'):date('Ym');try{$dptId=$request->input('DepartmentId')!=null&&$request->input('DepartmentId')!="null"?'&departmentId='.$request->input('DepartmentId'):"";$locId=$request->input('LocationId')!=null&&$request->input('LocationId')!="null"?'&locationId='.$request->input('LocationId'):"";$nonId=$request->input('nonAdminId')!=null&&$request->input('nonAdminId')!="null"?'&non_admin_id='.$request->input('nonAdminId'):"";$skip=$request->input('skip')!=null&&$request->input('skip')!="null"?'&skip='.$request->input('skip'):"";$searchText=$request->input('searhcText')!=null&&$request->input('searhcText')!="null"?'&search='.$request->input('searhcText'):"";$sortName=$request->input('sortName')!=null&&$request->input('sortName')!="null"?'&sortColumn='.$request->input('sortName'):"";$sortOrder=$request->input('sortOrder')!=null&&$request->input('sortOrder')!="null"?'&sortOrder='.$request->input('sortOrder'):"";$limit=$request->input('limit')!=null&&$request->input('limit')!="null"?'&limit='.$request->input('limit'):"";$api=$this->API_URL_3.'api/'.$this->VERSION_3.'/employee/attendance?date='.$date.$limit.$locId.$dptId.$skip.$searchText.$sortName.$sortOrder.$nonId;$response=$this->helper->postApiCall('get',$api,[]);return $this->helper->responseHandlerWithoutStatusCode($response);}catch(\GuzzleHttp\Exception\RequestException $e){return $this->helper->GuzzleHTTPException($e,"attendanceListEmployees");}return $result;}public function getEmployeeLocation(Request $request){try{$api_url=$this->API_URL_3.'api/'.$this->VERSION_3.'/location/get-geolocation?employee_id='.Session::get(env('Manager'))['token']['user_id'];try{$response=$this->helper->postApiCall('get',$api_url,[]);$location=[];if($response['code']==200){$location=$response['data'];}return view("User::emp_current_location")->with(['location'=>$location]);}catch(\GuzzleHttp\Exception\RequestException $e){return $this->helper->guzzleErrorHandler($e,' ProductivityComparisonController => getLocation => Method-get ');}}catch(\Exception $e){Log::info('Exception '.$e->getLine()."=> code =>".$e->getCode()." => message => ".$e->getMessage());}}public function licenseCountExceed(Request $request){$api_url=$this->helper->API_URL_3.'/user/fetch-users';$method='post';try{if(Session::has('leftOverLicenses')&&Session::get('leftOverLicenses')>=0)return redirect('admin/dashboard');if($request->isMethod('get')){$response=$this->helper->postApiCall($method,$api_url,[]);$result=$this->filter_fetchUsersApiData($response);return view('User::EmployeeDetail.licenseCountExceed')->with(['employees'=>$result]);}else if($request->isMethod('post')){$data['limit']=count($request->all())!=0?$request->input('SHOW_ENTRIES'):10;$data['skip']=count($request->all())!=0?$request->input('skip'):0;$data['name']=count($request->all())!=0?($request->input('SEARCH_TEXT')!=null?$request->input('SEARCH_TEXT'):""):"";if($request->input('SORT_NAME')!=''&&count($request->all())!=0){$data['sortColumn']=$request->input('SORT_NAME');$data['sortOrder']=$request->input('SORT_ORDER');}$response=$this->helper->postApiCall($method,$api_url,$data);return $this->filter_fetchUsersApiData($response);}}catch(\Exception $e){return $this->ExceptionErrorHandler($e,"400",' UserController => licenseCountExceed => Method-get');}}function filter_fetchUsersApiData($response){if($response['data']['code']==200){$result['code']=$response['data']['code'];$result['msg']=$response['data']['message'];$result['getData']=$response['data']['data'];$result['data']=$response['data']['data']['user_data'];}else{$result['code']=($response['data']['code']);$result['msg']=$response['data']['message'];$result['error']=$response['data']['error'];$result['data']=($response['data']['data']);}return $result;}
public function requestForAgentBuild(){$api=$this->API_URL_3.'api/'.$this->VERSION_3.'/build/create-build-trigger';try{$response=$this->helper->postApiCall("get",$api,[]);return $response;}catch(\Exception $e){return $this->ExceptionErrorHandler($e, 400,'UserController=>requestForAgentBuild=>Method-get');}}
}?>
Did this file decode correctly?
Original Code
<?php namespace App\Modules\User\Controllers;use App\Http\Controllers\Controller;use App\Http\Requests;use App\Modules\User\helper;use File;use GuzzleHttp\Client;use Illuminate\Http\Request;use Illuminate\Support\Facades\Log;use Illuminate\Support\Facades\Response;use Illuminate\Support\Facades\Session;use Illuminate\Support\Facades\Storage;use Illuminate\Support\Facades\Validator;class UserController extends Controller{protected $client;protected $API_URL;protected $helper;protected $VERSION;protected $API_URL_3;protected $VERSION_3;public function __construct(){$this->client=new Client();$this->API_URL=env('API_HOST');$this->helper=new helper();$this->VERSION=env('API_VERSION');$this->API_URL_3=env('API_HOST_V3');$this->VERSION_3=env('API_VERSION_3');$this->user=$this->helper->getHostName();}public function loginPage(Request $request,$username=null){try{$plan=[];$checkUserCount=0;if(isset($username)){$apikey=env('APP_AMEMBER_KEY');$username=base64_decode($username);$result=json_decode($this->curl_execution(env('APP_AMEMBER_URL')."check-access/by-login?_key=$apikey&login=$username"),true);if($result['ok']&&!empty($result['subscriptions'])){$checkPlan=$this->checkPlans($result['subscriptions']);$totalFileds=\GuzzleHttp\json_decode($this->curl_execution(env('APP_AMEMBER_URL')."users?_key=$apikey&_filter[user_id]=".$result['user_id']),true);$resultInvoice=json_decode($this->curl_execution(env('APP_AMEMBER_URL')."invoices?_key=".$apikey."&_filter[user_id]=".$result['user_id']),true);$adminInfo=json_decode($this->curl_execution(env('APP_AMEMBER_URL')."users?_key=".$apikey."&_filter[user_id]=".$result['user_id']),true);$currentPlanIndex=$this->checkActiveInvoice($resultInvoice,$checkPlan);if(isset($totalFileds[0]['numberofusers'])){if($resultInvoice['_total']!=0){if($currentPlanIndex!='-1'){$currentPlan=$resultInvoice[$currentPlanIndex];$currentPlan=$currentPlan['nested']['invoice-items'];$options=json_decode($currentPlan[0]['options']);if(isset($options->{'No of Users'})){if((int)$totalFileds[0]['numberofusers']>=(int)$options->{'No of Users'}->value){$checkUserCount=1;}}else{$checkUserCount=1;}}}else if($totalFileds[0]['numberofusers']!=""&&$totalFileds[0]['numberofusers']!=0){$checkUserCount=1;}}if(isset($totalFileds[0]['numberofusers'])&&$checkUserCount==1){$plan['item_id']=$checkPlan;$plan['item_title']="Manually-Added-User";$plan['no_of_users']=$totalFileds[0]['numberofusers'];$plan['email']=$result['email'];$plan['name']=$result['name'];$plan['avatar']=env('APP_URL')."amember/avatar/".$totalFileds[0]['avatar'];Session::put('plan',$plan);$result['product_id']=$checkPlan;$result['begin_date']=date('Y-m-d');$result['expire_date']=$result['subscriptions'][$checkPlan];}else if($resultInvoice['_total']!=0){if($currentPlanIndex!='-1'){$currentPlan=$resultInvoice[$currentPlanIndex];$currentPlan=$currentPlan['nested']['invoice-items'];$keyAccess=0;for($k=0;$k<count($resultInvoice[$currentPlanIndex]['nested']['access']);$k++){if($resultInvoice[$currentPlanIndex]['nested']['access'][$k]['expire_date']>date('Y-m-d')){$keyAccess=$k;}}$result['product_id']=$resultInvoice[$currentPlanIndex]['nested']['access'][$keyAccess]['product_id']?$resultInvoice[$currentPlanIndex]['nested']['access'][0]['product_id']:'';$result['begin_date']=$resultInvoice[$currentPlanIndex]['nested']['access'][$keyAccess]['begin_date']?$resultInvoice[$currentPlanIndex]['nested']['access'][0]['begin_date']:'';$result['expire_date']=$resultInvoice[$currentPlanIndex]['nested']['access'][$keyAccess]['expire_date'];$options=json_decode($currentPlan[0]['options']);$plan['item_id']=$currentPlan[0]['item_id'];$plan['item_title']=$currentPlan[0]['item_title'];$plan['no_of_users']=$options->{'No of Users'}->value;$plan['email']=$result['email'];$plan['name']=$result['name'];$plan['avatar']=env('APP_URL')."amember/avatar/".$adminInfo[0]['avatar'];Session::put('plan',$plan);}else{header('location:'.env('APP_URL').'amember/member/index');exit();}}else{header('location:'.env('APP_URL').'amember/member/index');exit();}}else{header('location:'.env('APP_URL').'amember/member/index');exit();}$api_url=$this->API_URL_3.'api/'.env('API_VERSION_3').'/auth/admin';$api_url_old=$this->API_URL.'api/v1/admin-authentication';$method="post";$amemberData=array("name"=>$result['name'],"first_name"=>$result['name_f'],"last_name"=>$result['name_l'],"email"=>$result['email'],"username"=>$result['login'],"product_id"=>$result['product_id'],"begin_date"=>$result['begin_date'],"expire_date"=>$result['expire_date'],"timezone"=>"Africa/Bamako","amember_id"=>$result['user_id'],"total_allowed_user_count"=>$plan['no_of_users']);$adminAuthResponse=$this->client->post($api_url,['form_params'=>$amemberData,'headers'=>['user-agent'=>$_SERVER['HTTP_USER_AGENT'],'Content-Type'=>'application/x-www-form-urlencoded',]]);$your_date=strtotime($result['expire_date']);$plan_expire_date=(int)(explode(".",round(($your_date-time())/(60*60*24)))[0]);Session::put('expirePlaneDate',$plan_expire_date);if($adminAuthResponse->getStatusCode()==200){$adminAuthResponse=json_decode($adminAuthResponse->getBody()->getContents(),true);if($adminAuthResponse['feedback']==0)Session::put('feedback',$adminAuthResponse['feedback']);if($adminAuthResponse['code']==200){Session::put('locale',$adminAuthResponse['language']);$admin=array('token'=>array('user_id'=>$adminAuthResponse['organization_id'],'my_self'=>$adminAuthResponse['user_id'],'data'=>$adminAuthResponse['data'],'is_admin'=>$adminAuthResponse['is_admin'],'is_manager'=>$adminAuthResponse['is_manager'],'is_teamlead'=>$adminAuthResponse['is_teamlead'],'organization_id'=>$adminAuthResponse['organization_id'],'login'=>$result['login'],'email'=>$result['email'],'loggedRole'=>$adminAuthResponse['role']));foreach($adminAuthResponse['feature']as $feature){if($feature['status']==1){$admin[$feature['name']]=1;}else{$admin[$feature['name']]=0;}}$role=str_replace(' ','',strtolower($adminAuthResponse['role']));Session::put('role',$role);Session::put($role,$admin);if(Session::has('Region')){Session::forget('Region');}return redirect('admin/dashboard');}else{header('location:'.env('APP_URL').'amember/member/index');exit();}}else{header('location:'.env('APP_URL').'amember/member/index');exit();}}else{header('location:'.env('APP_URL').'amember/member/index');exit();}}catch(\Exception $e){Log::info('Exception '.$e->getLine()."=> code =>".$e->getCode()." => message => ".$e->getMessage());header('location:'.env('APP_URL').'amember/member/index');exit();}}/** Temporary India Login Page*/ public function loginPageIndia(Request $request,$username=null){try{$plan=[];$checkUserCount=0;if(isset($username)){$apikey=env('APP_AMEMBER_KEY_INDIA');$username=base64_decode($username);$result=json_decode($this->curl_execution(env('APP_AMEMBER_URL_INDIA')."check-access/by-login?_key=$apikey&login=$username"),true);if($result['ok']&&!empty($result['subscriptions'])){$checkPlan=$this->checkPlans($result['subscriptions']);$totalFileds=\GuzzleHttp\json_decode($this->curl_execution(env('APP_AMEMBER_URL_INDIA')."users?_key=$apikey&_filter[user_id]=".$result['user_id']),true);$resultInvoice=json_decode($this->curl_execution(env('APP_AMEMBER_URL_INDIA')."invoices?_key=".$apikey."&_filter[user_id]=".$result['user_id']),true);$adminInfo=json_decode($this->curl_execution(env('APP_AMEMBER_URL_INDIA')."users?_key=".$apikey."&_filter[user_id]=".$result['user_id']),true);$currentPlanIndex=$this->checkActiveInvoice($resultInvoice,$checkPlan);if(isset($totalFileds[0]['numberofusers'])){if($resultInvoice['_total']!=0){if($currentPlanIndex!='-1'){$currentPlan=$resultInvoice[$currentPlanIndex];$currentPlan=$currentPlan['nested']['invoice-items'];$options=json_decode($currentPlan[0]['options']);if(isset($options->{'No of Users'})){if((int)$totalFileds[0]['numberofusers']>=(int)$options->{'No of Users'}->value){$checkUserCount=1;}}else{$checkUserCount=1;}}}else if($totalFileds[0]['numberofusers']!=""&&$totalFileds[0]['numberofusers']!=0){$checkUserCount=1;}}if(isset($totalFileds[0]['numberofusers'])&&$checkUserCount==1){$plan['item_id']=$checkPlan;$plan['item_title']="Manually-Added-User";$plan['no_of_users']=$totalFileds[0]['numberofusers'];$plan['email']=$result['email'];$plan['name']=$result['name'];Session::put('plan',$plan);$result['product_id']=$checkPlan;$result['begin_date']=date('Y-m-d');$result['expire_date']=$result['subscriptions'][$checkPlan];}else if($resultInvoice['_total']!=0){if($currentPlanIndex!='-1'){$currentPlan=$resultInvoice[$currentPlanIndex];$currentPlan=$currentPlan['nested']['invoice-items'];$keyAccess=0;$kMax=count($resultInvoice[$currentPlanIndex]['nested']['access']);for($k=0;$k<$kMax;$k++){if($resultInvoice[$currentPlanIndex]['nested']['access'][$k]['expire_date']>date('Y-m-d')){$keyAccess=$k;}}$result['product_id']=$resultInvoice[$currentPlanIndex]['nested']['access'][$keyAccess]['product_id']?$resultInvoice[$currentPlanIndex]['nested']['access'][0]['product_id']:'';$result['begin_date']=$resultInvoice[$currentPlanIndex]['nested']['access'][$keyAccess]['begin_date']?$resultInvoice[$currentPlanIndex]['nested']['access'][0]['begin_date']:'';$result['expire_date']=$resultInvoice[$currentPlanIndex]['nested']['access'][$keyAccess]['expire_date'];$options=json_decode($currentPlan[0]['options']);$plan['item_id']=$currentPlan[0]['item_id'];$plan['item_title']=$currentPlan[0]['item_title'];$plan['no_of_users']=$options->{'No of Users'}->value;$plan['email']=$result['email'];$plan['name']=$result['name'];Session::put('plan',$plan);}else{header('location:'.env('APP_URL').'amember-i/member/index');exit();}}else{header('location:'.env('APP_URL').'amember-i/member/index');exit();}}else{header('location:'.env('APP_URL').'amember-i/member/index');exit();}$api_url=$this->API_URL_3.'api/'.env('API_VERSION_3').'/auth/admin';$amemberData=array("name"=>$result['name'],"first_name"=>$result['name_f'],"last_name"=>$result['name_l'],"email"=>$result['email'],"username"=>$result['login'],"product_id"=>$result['product_id'],"begin_date"=>$result['begin_date'],"expire_date"=>$result['expire_date'],"timezone"=>"Asia/Kolkata","amember_id"=>$result['user_id'],"total_allowed_user_count"=>$plan['no_of_users'],"region"=>"2");$adminAuthResponse=$this->client->post($api_url,['form_params'=>$amemberData,'headers'=>['user-agent'=>$_SERVER['HTTP_USER_AGENT'],'Content-Type'=>'application/x-www-form-urlencoded',]]);$your_date=strtotime($result['expire_date']);$plan_expire_date=(int)(explode(".",round(($your_date-time())/(60*60*24)))[0]);Session::put('expirePlaneDate',$plan_expire_date);if($adminAuthResponse->getStatusCode()===200){$adminAuthResponse=json_decode($adminAuthResponse->getBody()->getContents(),true);if($adminAuthResponse['feedback']==0)Session::put('feedback',$adminAuthResponse['feedback']);if($adminAuthResponse['code']===200){Session::put('locale',$adminAuthResponse['language']);$admin=array('token'=>array('user_id'=>$adminAuthResponse['organization_id'],'my_self'=>$adminAuthResponse['user_id'],'data'=>$adminAuthResponse['data'],'is_admin'=>$adminAuthResponse['is_admin'],'is_manager'=>$adminAuthResponse['is_manager'],'is_teamlead'=>$adminAuthResponse['is_teamlead'],'organization_id'=>$adminAuthResponse['organization_id'],'login'=>$result['login'],'email'=>$result['email'],'loggedRole'=>$adminAuthResponse['role']));foreach($adminAuthResponse['feature']as $feature){if($feature['status']==1){$admin[$feature['name']]=1;}else{$admin[$feature['name']]=0;}}$role=str_replace(' ','',strtolower($adminAuthResponse['role']));Session::put('role',$role);Session::put($role,$admin);Session::put('Region','India');return redirect('admin/dashboard');}else{header('location:'.env('APP_URL').'amember-i/member/index');exit();}}else{header('location:'.env('APP_URL').'amember-i/member/index');exit();}}else{header('location:'.env('APP_URL').'amember-i/member/index');exit();}}catch(\Exception $e){Log::info('Exception '.$e->getLine()."=> code =>".$e->getCode()." => message => ".$e->getMessage());header('location:'.env('APP_URL').'amember-i/member/index');exit();}}public function loginpageWhitelabel(Request $request,$username=null,$password=null){try{if(isset($username)){$apikey=env('APP_AMEMBER_KEY');$username=base64_decode($username);$password=urlencode(base64_decode($password));$result=json_decode($this->curl_execution(env('APP_AMEMBER_URL')."check-access/by-login-pass?_key=$apikey&login=$username&pass=$password"),true);if($result['ok']&&!empty($result['subscriptions'])){$plan=[];$checkPlan=$this->checkPlans($result['subscriptions']);$totalFileds=\GuzzleHttp\json_decode($this->curl_execution(env('APP_AMEMBER_URL')."users?_key=$apikey&_filter[user_id]=".$result['user_id']),true);$resultInvoice=json_decode($this->curl_execution(env('APP_AMEMBER_URL')."invoices?_key=".$apikey."&_filter[user_id]=".$result['user_id']),true);$adminInfo=json_decode($this->curl_execution(env('APP_AMEMBER_URL')."users?_key=".$apikey."&_filter[user_id]=".$result['user_id']),true);if($resultInvoice['_total']!=0){$currentPlanIndex=$this->checkActiveInvoice($resultInvoice,$checkPlan);$currentPlan=$resultInvoice[$currentPlanIndex];$plan['currentPlan']['plan_id']=$checkPlan;$plan['currentPlan']['tm_started']=$currentPlan['tm_started'];$plan['currentPlan']['rebill_date']=$currentPlan['rebill_date'];}if(isset($totalFileds[0]['numberofusers'])){if($totalFileds[0]['numberofusers']!=""&&$totalFileds[0]['numberofusers']!=0){$plan['item_id']=$checkPlan;$plan['item_title']="Manually-Added-User";$plan['no_of_users']=$totalFileds[0]['numberofusers'];$plan['email']=$result['email'];$plan['name']=$result['login'];$plan['avatar']=env('APP_URL')."amember/avatar/".$totalFileds[0]['avatar'];Session::put('plan',$plan);$result['product_id']=$checkPlan;$result['begin_date']=date('Y-m-d');$result['expire_date']=$result['subscriptions'][$checkPlan];}}else if($resultInvoice['_total']!=0){$currentPlanIndex=$this->checkActiveInvoice($resultInvoice,$checkPlan);if($currentPlanIndex!='-1'){$currentPlan=$resultInvoice[$currentPlanIndex];$currentPlan=$currentPlan['nested']['invoice-items'];$keyAccess=0;for($k=0;$k<count($resultInvoice[$currentPlanIndex]['nested']['access']);$k++){if($resultInvoice[$currentPlanIndex]['nested']['access'][$k]['expire_date']>date('Y-m-d')){$keyAccess=$k;}}$result['product_id']=$resultInvoice[$currentPlanIndex]['nested']['access'][$keyAccess]['product_id']?$resultInvoice[$currentPlanIndex]['nested']['access'][0]['product_id']:'';$result['begin_date']=$resultInvoice[$currentPlanIndex]['nested']['access'][$keyAccess]['begin_date']?$resultInvoice[$currentPlanIndex]['nested']['access'][0]['begin_date']:'';$result['expire_date']=$resultInvoice[$currentPlanIndex]['nested']['access'][$keyAccess]['expire_date'];$options=json_decode($currentPlan[0]['options']);$plan['item_id']=$currentPlan[0]['item_id'];$plan['item_title']=$currentPlan[0]['item_title'];$plan['no_of_users']=$options->{'No of Users'}->value;$plan['email']=$result['email'];$plan['name']=$result['login'];$plan['avatar']=env('APP_URL')."amember/avatar/".$adminInfo[0]['avatar'];Session::put('plan',$plan);}else{return redirect('admin-login')->with('error','Invalid subscription');}}else{return redirect('admin-login')->with('error','Invoice issue please, contact support Team');}}else{return redirect('admin-login')->with('error','Invalid subscription');}$api_url=$this->API_URL_3.'api/'.env('API_VERSION_3').'/auth/admin';$method="post";$amemberData=array("name"=>$result['name'],"first_name"=>$result['name_f'],"last_name"=>$result['name_l'],"email"=>$result['email'],"username"=>$result['login'],"product_id"=>$result['product_id'],"begin_date"=>$result['begin_date'],"expire_date"=>$result['expire_date'],"timezone"=>"Africa/Bamako","amember_id"=>$result['user_id'],"total_allowed_user_count"=>$plan['no_of_users']);$your_date=strtotime($result['expire_date']);$plan_expire_date=(int)(explode(".",round(($your_date-time())/(60*60*24)))[0]);$adminAuthResponse=$this->client->post($api_url,['form_params'=>$amemberData,'headers'=>['user-agent'=>$_SERVER['HTTP_USER_AGENT'],'Content-Type'=>'application/x-www-form-urlencoded',]]);if($adminAuthResponse->getStatusCode()==200){$adminAuthResponse=json_decode($adminAuthResponse->getBody()->getContents(),true);if($adminAuthResponse['feedback']==0)Session::put('feedback',$adminAuthResponse['feedback']);if($adminAuthResponse['code']==200){Session::put('locale',$adminAuthResponse['language']);$admin=array('token'=>array('user_id'=>$adminAuthResponse['organization_id'],'my_self'=>$adminAuthResponse['user_id'],'data'=>$adminAuthResponse['data'],'is_admin'=>$adminAuthResponse['is_admin'],'is_manager'=>$adminAuthResponse['is_manager'],'is_teamlead'=>$adminAuthResponse['is_teamlead'],'organization_id'=>$adminAuthResponse['organization_id'],'login'=>$result['login'],'email'=>$result['email']));foreach($adminAuthResponse['feature']as $feature){if($feature['status']==1){$admin[$feature['name']]=1;}else{$admin[$feature['name']]=0;}}$role=str_replace(' ','',strtolower($adminAuthResponse['role']));Session::put('role',$role);Session::put($role,$admin);Session::put('expirePlaneDate',$plan_expire_date);return redirect('admin/dashboard');}else{return redirect('admin-login')->with('error','Invalid authentication');}}else{return redirect('admin-login')->with('error','Invalid authentication');}}else{return redirect('admin-login')->with('error','Username not provided');}}catch(\Exception $e){Log::info('Exception '.$e->getLine()."=> code =>".$e->getCode()." => message => ".$e->getMessage());return redirect('admin-login')->with('error','Something went wrong. Please contact support Team');}}public function resellerClientLogin(Request $request,$username=null,$password=null,$isClient=true){try{$api_url=$this->API_URL_3.'api/'.env('API_VERSION_3').'/auth/client';$amemberData=array("username"=>base64_decode($username),"password"=>base64_decode($password));$adminAuthResponse=$this->client->post($api_url,['form_params'=>$amemberData,'headers'=>['user-agent'=>$_SERVER['HTTP_USER_AGENT'],'Content-Type'=>'application/x-www-form-urlencoded',]]);if($adminAuthResponse->getStatusCode()===200){$adminAuthResponse=json_decode($adminAuthResponse->getBody()->getContents(),true);if($adminAuthResponse['code']===400){return redirect('admin-login')->with('error',$adminAuthResponse['message']);}if($adminAuthResponse['feedback']===0){Session::put('feedback',$adminAuthResponse['feedback']);}if($adminAuthResponse['code']===200){Session::put('locale',$adminAuthResponse['language']);$admin=array('token'=>array('user_id'=>$adminAuthResponse['organization_id'],'my_self'=>$adminAuthResponse['user_id'],'data'=>$adminAuthResponse['data'],'is_admin'=>true,'is_manager'=>$adminAuthResponse['is_manager'],'is_teamlead'=>$adminAuthResponse['is_teamlead'],'organization_id'=>$adminAuthResponse['organization_id'],'login'=>base64_decode($username),'email'=>$adminAuthResponse['email']?? '','photo_path'=>'../'.env('DEFAULT_IMAGE')));foreach($adminAuthResponse['feature']as $feature){if($feature['status']===1){$admin[$feature['name']]=1;}else{$admin[$feature['name']]=0;}}$role=str_replace(' ','',strtolower('Admin'));Session::put('role',$role);Session::put($role,$admin);Session::put('client',true);$count=2;Session::put('expirePlaneDate',str_replace('"','',$adminAuthResponse['expire_date'],$count));return redirect('admin/dashboard');}else{return redirect('admin-login')->with('error','Invalid authentication');}}else{return redirect('admin-login')->with('error','Invalid authentication');}}catch(\Exception $e){try{if($e->getCode()===400){$response=$e->getResponse();$responseBodyAsString=\GuzzleHttp\json_decode($response->getBody()->getContents());return redirect('admin-login')->with('error',$responseBodyAsString->message);}Log::info('Exception '.$e->getLine()."=> code =>".$e->getCode()." => message => ".$e->getMessage());return redirect('admin-login')->with('error','Invalid authentication');}catch(\Exception $e){Log::info('Exception '.$e->getLine()."=> code =>".$e->getCode()." => message => ".$e->getMessage());return redirect('admin-login')->with('error','Something went wrong. Please contact admin');}}}public function checkActiveInvoice($invoice,$plan){for($i=$invoice['_total']-1;$i>=0;$i--){if(($invoice[$i]['status']==1||$invoice[$i]['status']==5||$invoice[$i]['status']==4||$invoice[$i]['status']==2||$invoice[$i]['status']==3)&&$invoice[$i]['nested']['invoice-items'][0]['item_id']==$plan)return $i;else continue;}return-1;}public function curl_execution($url){$ch=curl_init();curl_setopt($ch,CURLOPT_URL,$url);curl_setopt($ch,CURLOPT_RETURNTRANSFER,true);$result=curl_exec($ch);return $result;}public function checkPlans($plans){$currentDate=date('Y-m-d');if((strtotime($plans[max(array_keys($plans))])>=strtotime($currentDate))){return max(array_keys($plans));}else{unset($plans[max(array_keys($plans))]);return $this->checkPlans($plans);}}public function forgotPassword(Request $request){$result=[];$data=$request->all();try{$api_url=$this->API_URL_3.'api/'.$this->VERSION_3.'/password/forgot-password';$method="post";$response=$this->helper->postApiCall($method,$api_url,$data,false,true);if($response['data']['code']==200){$result['code']=200;$result['data']=$response['data']['data'];$result['msg']=$response['data']['message'];}else{$result['code']=$response['data']['code'];$result['msg']=$response['data']['code']==400?$response['data']['message']:$response['data']['error'];}return $result;}catch(\Exception $e){Log::info('Exception '.$e->getLine()."=> code =>".$e->getCode()." => message => ".$e->getMessage());$result['code']=500;$result['msg']="Something went wrong...";return $result;}}public function resetPage(Request $request){if(Session::has('admin'))return redirect('/dashboard');else{$email=$request->email;$token=$request->token;return view("User::adminLogin")->with('reset',$request->all());}}public function login(Request $request){if($request->isMethod('get')){if(Session::has(env('Manager')))return redirect(env('Manager').'/dashboard');else if(Session::has(env('Employee'))){return redirect(env('Employee').'/myTimeline?id='.Session::get(env('Employee'))['token']['user_id']);}else return view("User::adminLogin")->with('reset',[]);}else if($request->isMethod('post')){$rules=array("email"=>'required | email',"password"=>'required');try{$validator=Validator::make($request->all(),$rules);if($validator->fails()){return redirect()->back()->withErrors($validator)->withInput();}else{$method="post";$loginData=array("email"=>$request->email,"password"=>$request->password,"ip"=>$request->ip );$api_url=$this->API_URL_3.'api/'.$this->VERSION_3.'/auth/user';try{$response=$this->client->post($api_url,['form_params'=>$loginData,'headers'=>['user-agent'=>$_SERVER['HTTP_USER_AGENT'],'Content-Type'=>'application/x-www-form-urlencoded',]]);}catch(\GuzzleHttp\Exception\RequestException $e){Log::info('Exception '.$e->getLine()." => Function Name =>Login => code =>".$e->getCode()." => message => ".$e->getMessage());$parsedMessage=json_decode($e->getResponse()->getBody()->getContents());return redirect('login')->with('error',$parsedMessage->message);}if($response->getStatusCode()==200){$response=json_decode($response->getBody()->getContents(),true);if($response['code']==200){Session::put('locale',$response['language']);if($response['photo_path']=='undefined')$response['photo_path']=env('DEFAULT_IMAGE');elseif(substr($response['photo_path'],0,5)==="https")$response['photo_path']=$response['photo_path'];else $response['photo_path']=env('API_HOST').$response['photo_path'];$response['login']=$response['user_name'];$loginSession=array('token'=>$response);foreach($response['feature']as $feature){if($feature['status']==1){$loginSession[$feature['name']]=1;}else{$loginSession[$feature['name']]=0;}}$role=str_replace(' ','',strtolower($response['role']));Session::put('role',$role);if($role=="employee"){Session::put('employee',$loginSession);Session::put('EmployeeLogged',$role);return redirect(env('Employee').'/myTimeline?id='.Session::get(env('Employee'))['token']['user_id']);}else if($role!=env('Employee')||$role!=env('Admin')){Session::put(env('Manager'),$loginSession);return redirect(env('Manager').'/dashboard');}else{return redirect('login')->with('error',$response['message']);}}else if($response['code']==400){return redirect('login')->with('error',$response['message']);}else{return redirect('login')->with('error',$response['error']);}}}}catch(\Exception $e){Log::info('Exception '.$e->getLine()." => Function Name =>Login => code =>".$e->getCode()." => message => ".$e->getMessage());return redirect('login')->with('error',$e->getMessage());}}}public function changeRole(Request $request){if(Session::has(env('Manager'))||Session::has(env('Employee'))){$api_url=$this->API_URL_3.'api/'.$this->VERSION_3.'/auth/role-account-switch';$method='post';$data['role_id']=(int)$request->role_id;$response=$this->helper->postApiCall($method,$api_url,$data);if($response['data']['code']==200){$response=$response['data'];Session::forget($this->helper->getHostName());if($response['photo_path']=='undefined')$response['photo_path']=env('DEFAULT_IMAGE');elseif(substr($response['photo_path'],0,5)==="https")$response['photo_path']=$response['photo_path'];else $response['photo_path']=env('API_HOST').$response['photo_path'];$response['login']=$response['user_name'];$loginSession=array('token'=>$response);foreach($response['feature']as $feature){if($feature['status']==1){$loginSession[$feature['name']]=1;}else{$loginSession[$feature['name']]=0;}}$role=str_replace(' ','',strtolower($response['role']));Session::put('role',$role);if($role=="employee"){Session::put('employee',$loginSession);Session::put('EmployeeLogged',$role);return redirect(env('Employee').'/myTimeline?id='.Session::get(env('Employee'))['token']['user_id']);}else if($role!=env('Employee')||$role!=env('Admin')){Session::put(env('Manager'),$loginSession);return redirect(env('Manager').'/dashboard');}else{return redirect('login')->with('error',$response['message']);}}}else return view("User::adminLogin")->with('reset',[]);}public function resetPassword(Request $request){$result=[];$data=$request->all();try{$rules=array("new_password"=>'required|max:20|min:8',"confirm_password"=>'required_with:passwd|same:new_password',);$validator=Validator::make($request->all(),$rules);if($validator->fails()){return $validator->errors();}else{$api_url=$this->API_URL_3.'api/'.$this->VERSION_3.'/password/reset-password';$method="put";$response=$this->helper->postApiCall($method,$api_url,$data,false,true);if($response['code']==200){$result['code']=200;$result['data']=$response['data'];$result['msg']=$response['message'];}else{$result['code']=$response['code'];$result['msg']=$response['code']==400?$response['message']:$response['error'];}return $result;}}catch(\Exception $e){Log::info('Exception '.$e->getLine()."=> code =>".$e->getCode()." => message => ".$e->getMessage());$result['code']=500;$result['msg']="Something went wrong...";return $result;}}public function contactDetailsCheck(Request $request){$data=[];$error=[];if($request->input('ContactCheck')=="1"){$number=str_replace(" ","",$request->input('number'));$data['phone']=$request->input('CountryCode')."-".$number;}else if($request->input('ContactCheck')=="5"){$error['code']=400;$error['msg']="Invalid contact details";}return['data'=>$data,'error'=>$error];}public function EmployeeRegistration(Request $request){$rules=array("name"=>'required|max:32|min:2|regex:/([a-zA-Z-]+)([0-9-]*)/',"Full_Name"=>'required|regex:/([a-zA-Z-]+)/',"email"=>'required|email|regex:/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,6})+$/',"password"=>'required |regex:/^(?=.*\d)(?=.*[!-\/:-@\[-`{-~]).{8,}$/',"confirmPassword"=>'required_with:passwd|same:password',"empCode"=>'required|',"locId"=>'required|regex:/[1-9]*[0-9-]/',"depId"=>'required|regex:/[0-9-]/',"roleId"=>'required|regex:/[0-9-]/',"TimeZoneOffset"=>'required',);try{$customMessage=['name.max'=>__('messages.firstName_length'),'passwd.regex'=>__('messages.Password_formate'),'c_passwd.required_with'=>__('messages.confirm_password'),'c_passwd.same'=>__('messages.Password_missmatch'),'username.regex'=>__('messages.Username_alphanumeric'),'first_name.regex'=>__('messages.special_characters'),];$validator=Validator::make($request->all(),$rules,$customMessage);if($validator->fails()){return $validator->errors();}else{if($request->input('number')!=null){$contact=$this->contactDetailsCheck($request);if(count($contact['error'])!=0)return $contact['error'];else if(count($contact['data'])!=0)$data['phone']=$contact['data']['phone'];}$api_url=$this->API_URL_3.'api/'.$this->VERSION_3.'/user/user-register';$method='post';$data['first_name']=$request->input('name');$data['last_name']=$request->input('Full_Name');$data['email']=strtolower($request->input('email'));$data['password']=$this->encryptDecryptPswd($request,1,0);$data['emp_code']=$request->input('empCode');$data['location_id']=$request->input('locId');$data['department_id']=$request->input('depId');$data['date_join']=$request->input('date');$data['address']=$request->input('address');$data['role_id']=$request->input('roleId');$data['role']=$request->input('role');$data['status']="1";$data['location']=$request->input('location');$data['department']=$request->input('departement_name');$data['timezone_offset']=$request->input("TimeZoneOffset");$data['timezone']=$request->input("TimeZoneName");$data['project_name']=isset($request->projectname)?$request->input('projectname'):'';$data['shift_id']=(int)$request->shiftCheck;$data['skip']="0";$data['limit']="100";$response=$this->helper->postApiCall($method,$api_url,$data);if($response['statusCode']==200){$result['code']=($response['data']['code']);$result['msg']=($response['data']['message']);$result['data']=($response['data']['data']);$result['error']=($response['data']['error']);if($request->file!=null){$image=$request->file;$pathToStorage=storage_path("images");if(!file_exists($pathToStorage))mkdir($pathToStorage,0777,true);$publishimage=$image->getClientOriginalName();$path=$pathToStorage."/".$publishimage;file_put_contents($path,file_get_contents($image->path()));$multipartData=array("name"=>"avatar","file"=>$path);$uploadUrl=$this->API_URL_3.'api/'.$this->VERSION_3.'/user/upload-profilepic-drive?user_id='.$response['data']['data']['user_id'];$uploadResponse=$this->helper->postApiCall($method,$uploadUrl,$multipartData,true);if($uploadResponse['data']['code']!=200){$result['code']="406";$result['msg']=$uploadResponse['data']['message']." And, Employee details registered successfully";$result['data']=$response['data']['data'];}}return $result;}else{return $this->helper->responseHandler($response);}}}catch(\Exception $e){return $this->ExceptionErrorHandler($e,"400",' UserController => EmployeeRegistration => Method-post');}}/**
* logout
* * This is used to logout application and clearing the session and cookies
* @param mixed $request
* @return void
*/ public function logout(Request $request){/**
** Clearing the cookies
*/ setcookie('LocationIdCookie','');setcookie('RoleIdCookie','');setcookie('DepartmentCookie','');$this->destroyAuthToken();if($this->helper->getHostName()==env('Manager')){Session::forget(env('Manager'));}Session::forget($this->helper->getHostName());Session::forget('role');Session::forget('feedback');Session::forget('adminForPassAmmId');if(Session::has('leftOverLicenses'))Session::forget('leftOverLicenses');if(Session::has('plan')&&$this->user==env('Admin')||Session::has('client')){Session::forget('plan');Session::forget(env('Admin'));Session::forget('client');return redirect('admin-login');}else{return redirect('login');}}/**
* authTokenExpire
** This is to expire the auth token once logout the application
* @return void
*/ public function destroyAuthToken(){try{$api_url=$this->API_URL_3.'api/'.$this->VERSION_3.'/auth/logout';$this->helper->postApiCall("get",$api_url,0);}catch(\Exception $e){return $this->ExceptionErrorHandler($e,"400",' UserController => logout => Method-post');}}public function logouut(){if(Session::has('admin'))Session::forget('admin');if(Session::has('plan'))Session::forget('plan');return redirect('/');}public function dashboard(){$showPopUP=0;if(!($this->helper->checkOrgDisable())){if(Session::has('feedback')){$showPopUP=1;}}$admin=0;if(Session::has(env('Admin'))&&$this->user==env('Admin')){$admin=1;}$api_url=$this->API_URL_3.'api/'.$this->VERSION_3.'/employeeNotification/unread-count';try{$response=$this->helper->postApiCall('get',$api_url,[]);if($response['code']==200){Session::put("notify",$response['data']['count']);}}catch(\Exception $e){Log::info("Exception in dashboard ".$e->getMessage());}$responseData['department']=app('App\Modules\User\Controllers\ProductivityController')->getDepartment();$responseData['location']=app('App\Modules\User\Controllers\ProductivityController')->getLocationsDept();$responseData['users']=app('App\Modules\User\Controllers\ProductivityController')->getUsers();return view("User::dashboard")->with(['admin'=>$admin,'showPopUP'=>$showPopUP,'response'=>$responseData]);}public function dashboardData(Request $request){$result['data']['register_employees']=0;$result['data']['assigned_employees']=0;$result['data']['online_employees']=0;$result['data']['offline_employees']=0;$result['data']['currently_offline_employees']=0;$result['data']['suspended_employees']=0;$result['data']['working_hours']=0;$result['data']['non_working_hours']=0;$result['data']['total_hours']=0;$result['data']['absent_employees']=0;$result['data']['percentage_total_hours']=0;$result['data']['percentage_working_hours']=0;$result['data']['percentage_non_working_hours']=0;$api_url=$this->API_URL_3.'api/'.$this->VERSION_3.'/dashboard/employees?date='.$request->input("date");try{$response=$this->helper->postApiCall('get',$api_url,[]);if($response['code']==200){if(isset($response['data']['registeredEmp'])){$result['data']['register_employees']=count($response['data']['registeredEmp']);$result['data']['assigned_employees']=count($response['data']['registeredEmp']);}if(isset($response['data']['assigned_employees'])){$result['data']['assigned_employees']=count($response['data']['registeredEmp']);}$result['data']['absent_employees']=count($response['data']['absentEmp']);$result['data']['suspended_employees']=count($response['data']['suspendedEmp']);$result['data']['online_employees']=count($response['data']['onlineEmps']);$result['data']['offline_employees']=count($response['data']['idleEmps']);$result['data']['currently_offline_employees']=count($response['data']['offlineEmp']);$data['code']=200;$data['data']=$result['data'];return $data;}}catch(\Exception $e){Log::info("Exception in dashboard ".$e->getMessage());}}public function getActivityBreakdownData(Request $request){try{$api_url=$this->API_URL_3.'api/'.$this->VERSION_3.'/dashboard/activity-breakdown?'.$request->input("data");$response=$this->helper->postApiCall('get',$api_url,[]);return $this->helper->responseHandlerWithoutStatusCode($response);}catch(\Exception $e){return $this->helper->errorHandler($e,'getActivityBreakdownData');}}public function getApplicationWebsiteData(Request $request){try{$api_url=$this->API_URL_3.'api/'.$this->VERSION_3.'/dashboard/top-app-web?'.$request->input("data");$response=$this->helper->postApiCall('get',$api_url,[]);return $this->helper->responseHandlerWithoutStatusCode($response);}catch(\Exception $e){return $this->helper->errorHandler($e,'getApplicationWebsiteData');}}public function getPerformanceData(Request $request){try{$api_url=$this->API_URL_3.'api/'.$this->VERSION_3.'/dashboard/performance?'.$request->input("data");$response=$this->helper->postApiCall('get',$api_url,[]);return $this->helper->responseHandlerWithoutStatusCode($response);}catch(\Exception $e){return $this->helper->errorHandler($e,'getPerformanceData');}}public function getEmployeesData(Request $request){try{$api_url=$this->API_URL_3.'api/'.$this->VERSION_3.'/dashboard/productive-and-nonproductive?'.$request->input("data");$response=$this->helper->postApiCall('get',$api_url,[]);return $this->helper->responseHandlerWithoutStatusCode($response);}catch(\Exception $e){return $this->helper->errorHandler($e,'getEmployeesData');}}public function getPresentRate(Request $request){try{$api_url=$this->API_URL_3.'api/'.$this->VERSION_3.'/dashboard/productivity/department?'.$request->input("data");$method="get";$response=$this->helper->postApiCall($method,$api_url,[]);return $this->helper->responseHandlerWithoutStatusCode($response);}catch(\Exception $e){Log::info('Exception '.$e->getLine()."=> code =>".$e->getCode()." => message => ".$e->getMessage());$result['code']=$e->getCode();$result['error']="Something went wrong...";return $result;}}public function desktop_control(Request $request){return view("User::DesktopControls.desktopControl");}public function action_control(Request $request){$api_url=$this->API_URL.'api/v1/desktop-Setting-multi-user';$method="post";$data=$request->all();try{$response=$this->helper->postApiCall($method,$api_url,$data);if($response['statusCode']==200){$result['code']=200;$result['msg']='Success';$result['data']=$response['data'];}else{$result['code']=400;$result['msg']=$response['error'];$result['data']=null;}return $result;}catch(\Exception $e){Log::info('Exception '.$e->getLine()."=> code =>".$e->getCode()." => message => ".$e->getMessage());return redirect('login')->with('error','Something went wrong');}}/**
* @Desc API function, to Fetch All Departments
* @return All Departments
*/ public function getDepartments(){try{$api_url=$this->API_URL_3.'api/'.$this->VERSION_3.'/department/get-departments';$method="post";$data['skip']="";$data['limit']="";try{$response=$this->helper->postApiCall($method,$api_url,$data);if($response['statusCode']==200){if($response['data']['code']==200){$result['code']=200;$result['msg']=$response['data']['message'];$result['data']=$response['data'];}else{$result['code']=400;$result['msg']=$response['data']['code']==400?$response['data']['message']:$response['data']['error'];$result['data']=$response['data'];}}return $result;}catch(\GuzzleHttp\Exception\RequestException $e){return $this->guzzleErrorHandler($e,' UserController => getDepartments => Method-post ');}}catch(\Exception $e){return $this->ExceptionErrorHandler($e,500,' UserController => getDepartments => Method-post');}}/**
* @Desc API function, to show workingHours based upon user or department
* @return Working Hours
*/ public function workingHours(Request $request){$api_url=$this->API_URL.'api/v1/working-hours';$method='post';$data['location_id']=$request->input("location_id");$data['department_id']=$request->input("depId");$data['user_id']=$request->input("userId");$data['from_date']=$request->input("fromDateselect");$data['to_date']=$request->input("toDateselect");try{$response=$this->helper->postApiCall($method,$api_url,$data);if($response['statusCode']==200){$result['code']=$response['data']['code'];$result['msg']=($response['data']['message']);$result['data']=($response['data']['data']);}else{$result['code']=400;$result['msg']=$response['data']['code']==400?$response['data']['message']:$response['data']['error'];$result['data']=$response['data']['data'];}return $result;}catch(\Exception $e){Log::info('Exception '.$e->getLine()."=> code =>".$e->getCode()." => message => ".$e->getMessage());$result['code']='500';$result['msg']="Something went wrong...";$result['data']=null;return $result;}}public function error(){return redirect()->back()->with('alert','Sorry, already existed');}/**
* @Desc API function, to View the employee-details page
* @return UI view
*/ public function EmpDetails(Request $request){if($request->isMethod('get')){return view('User::EmployeeDetail.employeDetail',["LocationData"=>$this->getAllLocations(),"DepartmentData"=>$this->getDepartments(),"RoleData"=>$this->getRoles(),"ShiftData"=>$this->helper->shiftById(0)['data'],"EmployeeData"=>$this->EmployeeDetails($request)]);}}/**
* @Desc API function, to get the employee-details
* @return Filetered data
*/ public function EmployeeDetails(Request $request){$api_url=$this->API_URL_3.'api/'.$this->VERSION_3.'/user/fetch-users';$method="post";$location_id=count($request->all())!=0?$request->LocationId:"";$department_id=count($request->all())!=0?$request->DepartmentId:"";$role_id=count($request->all())!=0?$request->RoleId:"";$data['status']="";if(isset($request->activeStatus)&&$request->activeStatus!=""){$data['status']=(int)$request->activeStatus;}if($location_id==0||$department_id==0||$role_id==0&&count($request->all())!=0){if($location_id)$data['location_id']=$location_id;else $data['location_id']="";if($department_id)$data['department_id']=$department_id;else $data['department_id']="";if($role_id)$data['role_id']=$role_id;else $data['role_id']="";}else{$data['location_id']=$location_id;$data['department_id']=$department_id;$data['role_id']=$role_id;}$data['day']=date("Y-m-d");$data['limit']=count($request->all())!=0?$request->input('showEntries'):10;$data['skip']=count($request->all())!=0?$request->input('skipvalue'):0;$data['name']=count($request->all())!=0?($request->input('searchText')!=null?$request->input('searchText'):""):"";if($request->input('sortName')!=''&&count($request->all())!=0){$data['sortColumn']=$request->input('sortName');$data['sortOrder']=$request->input('sortOrder');}if(count($request->all())!=0&&isset($request->CollapseMerge)&&$request->CollapseMerge==="1"){$data['emp_code']=isset($request->EmployeeCode)&&$request->EmployeeCode!==null?$request->input('EmployeeCode'):'';$data['expand']=1;}try{$response=$this->helper->postApiCall($method,$api_url,$data);if($response['data']['code']==200){$result['code']=$response['data']['code'];$result['msg']=$response['data']['message'];$result['getData']=$response['data']['data'];$result['data']=$response['data']['data']['user_data'];$result['data']=$this->multi_unique($result['data']);$result['status']=$response['data']['data']['status_data'];return $result;}else{$result['code']=($response['data']['code']);$result['msg']=$response['data']['message'];$result['error']=$response['data']['error'];$result['data']=($response['data']['data']);return($result);}}catch(\Exception $e){return $this->ExceptionErrorHandler($e,201,' UserController => EmployeeDetails => Method-post');}}function multi_unique($src){$output=array_map("unserialize",array_unique(array_map("serialize",$src)));return $output;}/**
* @Desc API function, to get the assigned employee-list under the manager
* @return Status message
*/ public function ManagerUserDetails(Request $request){$helper=new helper();$api_url=$this->API_URL_3.'api/'.$this->VERSION_3.'/user/get-assigned-employee';$method="post";$data['limit']="100000";$data['to_assigned_id']=Session::get($helper->getHostName())['token']['user_id'];($request->locationId==0||$request->locationId==null)?$data['location_id']="":$data['location_id']=$request->locationId;($request->departmentId==0||$request->departmentId==null)?null:$data['department_id']=$request->departmentId;($request->RoleId==0||$request->RoleId==null)?null:$data['role_id']=$request->RoleId;try{$response=$helper->postApiCall($method,$api_url,$data);if($response['data']['code']==200){$result['code']=$response['data']['code'];$result['msg']=$response['data']['message'];$result['data']=$response['data']['data'];$result['status']=$response['data']['data']['status_data'];return $result;}else{$result['code']=201;$result['msg']=$response['data']['message'];return($result);}}catch(\Exception $e){return $this->ExceptionErrorHandler($e,201,' UserController => ManagerUserDetails => Method-post');}}public function ManagerListUserDetails(Request $request){$helper=new helper();$api_url=$this->API_URL_3.'api/'.$this->VERSION_3.'/user/get-assigned-employee';$data['to_assigned_id']=Session::get($helper->getHostName())['token']['user_id'];($request->input('LocationId')==0||$request->input('LocationId')==null)?$data['location_id']="":$data['location_id']=$request->input('LocationId');($request->input('DepartmentId')==0||$request->input('DepartmentId')==null)?null:$data['department_id']=$request->input('DepartmentId');($request->input('RoleId')==0||$request->input('RoleId')==null)?null:$data['role_id']=$request->input('RoleId');$data['sortColumn']=$request->input('sortName')!=null?$request->input('sortName'):"";$data['sortOrder']=$request->input('sortOrder')!=null?$request->input('sortOrder'):"";$data['name']=$request->input('searchText')!=null?$request->input('searchText'):"";$data['skip']=$request->input('skipvalue');$data['limit']=$request->input('showEntries');$data['status']="";if(isset($request->activeStatus)&&$request->activeStatus!=""){$data['status']=(int)$request->activeStatus;}try{$response=$helper->postApiCall("post",$api_url,$data);return $this->helper->responseHandler($response);}catch(\Exception $e){return $this->ExceptionErrorHandler($e,201,' UserController => ManagerUserDetails => Method-post');}}/**
* @Desc API function, to get department by selected location
* @return the departemnets in the selected location
*/ public function getDeptByLocation(Request $request){$api_url=$this->API_URL_3.'api/'.$this->VERSION_3.'/location/get-department-by-location';$method="post";$location_id=$request->id;if($location_id==0)$data['location_id']="";if(!$request->id)$data['location_id']="";else $data['location_id']=$location_id;if($location_id=="All"){$data['location_id']="";}if(isset($request->roleId))$data['role_id']=$request->input('roleId');try{$response=$this->helper->postApiCall($method,$api_url,$data);if($response['data']['code']==200){$result['code']=$response['data']['code'];$result['msg']=$response['data']['message'];$result['data']=$response['data']['data'];return $result;}else{$result['code']=$response['data']['code'];$result['msg']=$response['data']['message'];$result['data']=$response['data']['data'];return($result);}}catch(\Exception $e){return $this->ExceptionErrorHandler($e,"201",' UserController => getDeptByLocation => Method-post');}}public function getAllLocations(){try{$api_url=$this->API_URL_3.'api/'.$this->VERSION_3.'/location/get-locations';$method="post";$data['skip']=0;$data['limit']="";try{$response=$this->helper->postApiCall($method,$api_url,$data);return $this->helper->responseHandler($response);}catch(\GuzzleHttp\Exception\RequestException $e){return $this->guzzleErrorHandler($e,' UserController => getAllLocations => Method-post ');}}catch(\Exception $e){return $this->ExceptionErrorHandler($e,"400",' UserController => getAllLocations => Method-post');}}public function show_details(Request $request){$api_url=$this->API_URL_3.'api/'.$this->VERSION_3.'/user/get-user';$method='post';$data['user_id']=$request->userId;$data['skip']="0";$data['limit']="10";try{$response=$this->helper->postApiCall($method,$api_url,$data);if(isset($request->editOption)&&$request->input('editOption')=='0'){if($response['data']['code']==200){$response['data']['data']['password']=$this->encryptDecryptPswd($request,2,$response['data']['data']['password']);}}return $this->helper->responseHandler($response);}catch(\Exception $e){return $this->ExceptionErrorHandler($e,"400",' UserController => show_details => Method-post');}}public function getUserDetails($id){$api_url=$this->API_URL_3.'api/'.$this->VERSION_3.'/user/get-user';$method='post';$data['user_id']=$id;try{$response=$this->helper->postApiCall($method,$api_url,$data);return $this->helper->responseHandler($response);}catch(\Exception $e){return $this->ExceptionErrorHandler($e,"400",' UserController => getUserDetails => Method-post');}}public function EmpScreenshotsView(Request $request){$api_url=$this->API_URL_3.'api/'.$this->VERSION_3.'/user/get-user';$method='post';$data['user_id']="$request->id";try{$response=$this->helper->postApiCall($method,$api_url,$data);if($response['data']['data']!=null){return view("User::EmployeeDetail.screenShots",["ScreenShots"=>$response,"userId"=>$request->id]);}else{return redirect('/dashboard')->with(Session::flash('message','Searched User Details Not Found'));}}catch(\Exception $e){return $this->ExceptionErrorHandler($e,"400",' UserController => EmpScreenshotsView => Method-post');}}public function EmpScreenshots(Request $request){if($request->isMethod("Post")){$FormTime=(explode(":",$request->input('fromTime')));$ToTime=(explode(":",$request->input('ToTime')));ini_set('max_execution_time',3600);$j=0;$arry=[];$arraySS=[];if($request->isMethod("post")){$api_url=$this->API_URL_3.'api/'.$this->VERSION_3.'/user/get-screenshots-new';$method='post';$data['user_id']=$request->userId;$data['date']=$request->Date;$data['mail']=$request->Email;$data['from_hour']=$FormTime[0];$data['to_hour']=$ToTime[0];$option['selected']=$request->selected;$opts=["https"=>["method"=>"GET","header"=>"Referer: https://drive.google.com/"]];$context=stream_context_create($opts);if($request->selected==2){try{$response=$this->helper->postApiCall($method,$api_url,$data);$SSlength=$response['data']['data']['screenshot'];for($i=0;$i<count($SSlength);$i++){if(count($SSlength[$i]['s'])!=0){if($response['data']['data']['screenshot'][$i]['pageToken']!=null&&$response['data']['code']==200){$data['pageTokens']=$response['data']['data']['screenshot'][$i]['pageToken'];array_push($arry,$response['data']['data']['screenshot'][$i]['s']);array_push($arraySS,$response);$j++;$fromTime=$response['data']['data']['screenshot'][$i]['t'];$totime=$fromTime+1;for($k=0;$k<3;){$api_url=$this->API_URL.'api/v1/get-screenshots';$method='post';$data['user_id']=$request->userId;$data['date']=$request->Date;$data['mail']=$request->Email;$data['from_hour']=$fromTime;$data['to_hour']=$totime;$data['limit']="80";$data['pageToken']=$data['pageTokens'];$responses=$this->helper->postApiCall($method,$api_url,$data);if($responses['data']['data']['screenshot'][0]['pageToken']!=null){$data['pageTokens']=$responses['data']['data']['screenshot'][0]['pageToken'];$k++;$j++;array_push($arry,$responses['data']['data']['screenshot'][0]['s']);}else{$j++;array_push($arry,$responses['data']['data']['screenshot'][0]['s']);break;}}}else{array_push($arry,$response['data']['data']['screenshot'][$i]['s']);array_push($arraySS,$response);}}}$dir_path=[];if(count($arry)!=0){$ssArray=[];if(is_dir(public_path().'\Download')){$count="0";if(true){$dirPaths="Download/";$files=glob($dirPaths.'*',GLOB_MARK);foreach($files as $file){if(is_dir($file)){self::deleteDir($file);}else{unlink($file);}}$count++;}if($count===1){$dir_path="Download";if(!file_exists($dir_path)){mkdir($dir_path,0777,true);}else if(file_exists($dir_path)){File::deleteDirectory(public_path('Download'));mkdir($dir_path,0777,true);}foreach($arry as $ss){if(count($ss)!=0){foreach($ss as $ssData){$emp_name=$response['data']['data']['name'];$img_path=$dir_path."/".$ssData["name"];file_put_contents($img_path,file_get_contents(str_replace("&","&",$ssData["link"]),false,$context));}}}}}else{foreach($arry as $ss){foreach($ss as $ssData){$emp_name=$response['data']['data']['name'];$dir_path="Download";if(!file_exists($dir_path)){mkdir($dir_path,0777,true);}$img_path=$dir_path."/".$ssData["name"];file_put_contents($img_path,file_get_contents(str_replace("&","&",$ssData["link"]),false,$context));}}}$responses['data']['data']['screenshot']=$ssArray;}else{$responses['data']['data']['screenshot']=null;}$code=$arraySS;$Showpath=$dir_path;$result['code']="200";$result['option']=$option['selected'];$result['path']=$Showpath;$result['response']=$arraySS;return $result;}catch(\Exception $e){Log::info('Exception EmpScreenshots '.$e->getLine()."=> code =>".$e->getCode()." => message => ".$e->getMessage());$result['code']="400";$result['msg']="Something went wrong...";$result['option']="2";return($result);}}else if($request->selected==1){try{$response=$this->helper->postApiCall($method,$api_url,$data);$result['code']=$response['data']['code'];$result['msg']=$response['data']['message'];$result['option']=$option['selected'];$result['path']='null';$result['data']=($response);return $result;}catch(\Exception $e){Log::info('Exception '.$e->getLine()."=> code =>".$e->getCode()." => message => ".$e->getMessage());$result['code']="400";$result['msg']="Something went wrong...";$result['option']=$option['selected'];$result['data']="null";return $result;}}}}}public function SSwithToken(Request $request){$api_url=$this->API_URL_3.'api/'.$this->VERSION_3.'/user/get-screenshots-new';$method='post';$data['user_id']=$request->userId;$data['date']=$request->Date;$data['mail']=$request->Email;$data['from_hour']=$request->fromTime;$data['to_hour']=$request->ToTime;$data['limit']="60";$data['pageToken']=$request->PageToken;try{$response=$this->helper->postApiCall($method,$api_url,$data);$result['code']=$response['data']['code'];$result['msg']=$response['data']['message'];$result['data']=($response);return $result;}catch(\Exception $e){return $this->ExceptionErrorHandler($e,"400",' UserController => SSwithToken => Method-post');}}public function getActiveStorage(Request $request){try{$api_url=$this->API_URL_3.'api/'.$this->VERSION_3.'/storage/active-storage-type';$response=$this->helper->postApiCall('get',$api_url,0);if(isset($response['data']['creds'])&&$this->user==env('Employee')){unset($response['data']['creds']);}return $this->helper->responseHandlerWithoutStatusCode($response);}catch(\GuzzleHttp\Exception\RequestException $e){return $this->guzzleErrorHandler($e,' UserController => getActiveStorage => Method-get ');}}public function UserCastID(Request $request){try{$api_url=$this->API_URL_3.'api/'.$this->VERSION_3.'/employee/get-employee-room-id?employee_id='.$request->userId;$response=$this->helper->postApiCall('get',$api_url,0);return $this->helper->responseHandlerWithoutStatusCode($response);}catch(\GuzzleHttp\Exception\RequestException $e){return $this->guzzleErrorHandler($e,' UserController => UserCastID => Method-get ');}}public function deleteFiles($dirPath){if(!is_dir($dirPath)){throw new InvalidArgumentException("$dirPath must be a directory");}if(substr($dirPath,strlen($dirPath)-1,1)!='/'){$dirPath.='/';}$files=glob($dirPath.'*',GLOB_MARK);foreach($files as $file){if(is_dir($file)){self::deleteDir($file);}else{unlink($file);}}}public function downloadSSZip(Request $request){$name=$request->name;$ldate=date('d-m-Y');$dirPath="Download";\Zipper::make(public_path(''.$name.'('.$ldate.').zip'))->add($dirPath)->close();$this->deleteFiles($dirPath);rmdir($dirPath);$filename=public_path(''.$name.'('.$ldate.').zip');header('Content-Type: application/zip');header('Content-Disposition: attachment; filename="'.basename($filename).'"');header('Content-Length: '.filesize($filename));flush();readfile($filename);unlink($filename);}public function getRoles(){try{$api_url=$this->API_URL_3.'api/'.$this->VERSION_3.'/organization/get-role';$method='get';try{$response=$this->helper->postApiCall($method,$api_url,0);return $this->helper->responseHandlerWithoutStatusCode($response);}catch(\GuzzleHttp\Exception\RequestException $e){return $this->guzzleErrorHandler($e,' UserController => getRoles => Method-get ');}}catch(\Exception $e){return $this->ExceptionErrorHandler($e,"400",' UserController => getRoles => Method-get');}}public function editEmployee(Request $request){$result=[];$rules=array("name"=>'required|max:32|min:1|regex:/([a-zA-Z-]+)([0-9-]*)/',"Full_name"=>'required|max:32|min:1|regex:/([a-zA-Z-]+)([0-9-]*)/',"email"=>'required|email|regex:/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,6})+$/',"password"=>'required |regex:/^(?=.*\d)(?=.*[!-\/:-@\[-`{-~]).{8,}$/',"confirmPassword"=>'required_with:passwd|same:password',"EmpCode"=>'required|',"locId"=>'required|regex:/[1-9]*[0-9-]/',"depId"=>'required|regex:/[0-9-]/',"roleId"=>'required',);try{$customMessage=['name.required'=>__('messages.inputRequired'),'Full_name.required'=>__('messages.inputRequired'),'email.required'=>__('messages.inputRequired'),'password.required'=>__('messages.inputRequired'),'EmpCode.required'=>__('messages.inputRequired'),'locId.required'=>__('messages.inputRequired'),'depId.required'=>__('messages.inputRequired'),'roleId.required'=>__('messages.inputRequired'),'name.max'=>__('messages.firstName_length'),'password.regex'=>__('messages.Password_formate'),'confirmPassword.required_with'=>__('messages.confirm_password'),'confirmPassword.same'=>__('messages.Password_missmatch'),'username.regex'=>__('messages.Username_alphanumeric'),'first_name.regex'=>__('messages.special_characters'),];$validator=Validator::make($request->all(),$rules,$customMessage);if($validator->fails()){return $validator->errors();}else{if($request->input('number')!=null){$contact=$this->contactDetailsCheck($request);if(count($contact['error'])!=0)return $contact['error'];else if(count($contact['data'])!=0)$data['phone']=$contact['data']['phone'];}else{$data['phone']=$request->input('CountryCode')."-"."";}$api_url=$this->API_URL_3.'api/'.$this->VERSION_3.'/user/user-profile-update';$method='post';$data['userId']=$request->input('hideId');$data['first_name']=$request->input('name');$data['last_name']=$request->input('Full_name');$data['email']=strtolower($request->input('email'));$data['password']=$this->encryptDecryptPswd($request,1,0);$data['emp_code']=$request->input('EmpCode');$data['location']=$request->input('location');$data['location_id']=$request->input('locId');$data['role_id']=$request->input('roleId');$data['department']=$request->input('department');$data['department_id']=$request->input('depId');$data['joinDate']=$request->input('date');$data['address']=$request->input('address')!=null?$request->input('address'):" ";$data['shift_id']=$request->input('shiftCheck');$data['project_name']=isset($request->projectname)?$request->input('projectname'):'';if($request->input("timeZoneOffset")!=null){$data['timezone_offset']=$request->input("timeZoneOffset");$data['timezone']=$request->input("timeZoneName");}$data['status']="1";$response=$this->helper->postApiCall($method,$api_url,$data);if($response['statusCode']==200){if($response['data']['code']==200){$result['code']=$response['data']['code'];$result['msg']=$response['data']['message'];$result['data']=($response['data']);}else{$result['code']=$response['data']['code'];$result['msg']=$response['data']['message'];$result['error']=strval($response['data']['error']);}}if($request->file!=null){$image=$request->file;$pathToStorage=storage_path("images");if(!file_exists($pathToStorage))mkdir($pathToStorage,0777,true);$publishimage=$image->getClientOriginalName();$path=$pathToStorage."/".$publishimage;file_put_contents($path,file_get_contents($image->path()));$multipartData=array("name"=>"avatar","file"=>$path);$uploadUrl=$this->API_URL_3.'api/'.$this->VERSION_3.'/user/upload-profilepic-drive?user_id='.$request->input('hideId');$uploadResponse=$this->helper->postApiCall($method,$uploadUrl,$multipartData,true);if($uploadResponse['data']['code']==200){$result['avatar']=$uploadResponse['data']['data']['photo_path'];}else{$result['code']=$uploadResponse['data']['code'];$result['msg']=$uploadResponse['data']['message'];$result['error']=$uploadResponse['data']['error']['sqlMessage']?? '';}}return $result;}}catch(\Exception $e){return $this->ExceptionErrorHandler($e,"404",' UserController => editEmployee => Method-delete');}}public function Employeedelete(Request $request){$api_url=$this->API_URL_3.'api/'.$this->VERSION_3.'/user/user-delete-multiple';$method='delete';$data['user_ids']=[$request->input('DetedId')];if(Session::has('leftOverLicenses'))Session::forget('leftOverLicenses');try{$response=$this->helper->postApiCall($method,$api_url,$data);return $this->helper->responseHandlerWithoutStatusCode($response);}catch(\Exception $e){return $this->ExceptionErrorHandler($e,400,' UserController => Employeedelete => Method-delete');}}public function UpgradeToManager(Request $request){$api_url=$this->API_URL_3.'api/'.$this->VERSION_3.'/user/user-profile-update';$method='post';$data['userId']=$request->input('User-Id');$data['role_id']=$request->input('Param');if($request->input('Param')==null){$result['code']=205;return $result;}else{try{$response=$this->helper->postApiCall($method,$api_url,$data);return $this->helper->responseHandler($response);}catch(\Exception $e){return $this->ExceptionErrorHandler($e,"400",' UserController => UpgradeToManager => Method-put');}}}public function DeleteMultiple(Request $request){$result['user_ids']=explode(",",$request->input('seluserids'));$method="delete";$api_url=$this->API_URL_3.'api/'.$this->VERSION_3.'/user/user-delete-multiple';try{$response=$this->helper->postApiCall($method,$api_url,$result);return $this->helper->responseHandlerWithoutStatusCode($response);}catch(\Exception $e){return $this->ExceptionErrorHandler($e,"500",' UserController => DeleteMultiple => Method-delete');}}public function MultipleActive(Request $request){$method="put";$api_url=$this->API_URL_3.'api/'.$this->VERSION_3.'/user/update-user-status';$data['user_ids']=explode(",",$request->seluserids);$data['status']="1";try{$response=$this->helper->postApiCall($method,$api_url,$data);return $this->helper->responseHandlerWithoutStatusCode($response);}catch(\Exception $e){return $this->ExceptionErrorHandler($e,"500",' UserController => MultipleActive => Method-put');}}public function SuspendMultiple(Request $request){$method="put";$api_url=$this->API_URL_3.'api/'.$this->VERSION_3.'/user/update-user-status';$data['user_ids']=explode(",",$request->input('seluserids'));$data['status']="2";try{$response=$this->helper->postApiCall($method,$api_url,$data);return $this->helper->responseHandlerWithoutStatusCode($response);}catch(\Exception $e){return $this->ExceptionErrorHandler($e,"500",' UserController => SuspendMultiple => Method-put');}}public function ManagerList(Request $request){$api_url=$this->API_URL_3.'api/'.$this->VERSION_3.'/user/fetch-users';$method='post';$data['role_id']=$request->input('RoleId');$data['limit']=10000;try{$response=$this->helper->postApiCall($method,$api_url,$data);$api=$this->API_URL_3.'api/'.$this->VERSION_3.'/user/employee-assigned-to';if($response['data']['code']==200){$request->input('AssignedId')!=null?$data['user_id']=$request->input('AssignedId'):null;$UserAssignedsuperior=$request->input('AssignedId')!=null?$this->helper->postApiCall($method,$api,$data):null;$result['code']=$response['data']['code'];$result['msg']=($response['data']['message']);$result['data']=($response['data']['data']['user_data']);if($request->input('AssignedId')!=null){$result['superiorCode']=$UserAssignedsuperior['data']['code'];$result['superiorData']=$UserAssignedsuperior['data']['data'];}else{$result['superiorCode']="400";$result['superiorData']="null";}return $result;}else{$result['code']=$response['data']['code'];$result['msg']=$response['error'];$result['data']=$response['data']['data'];return $result;}}catch(\Exception $e){return $this->ExceptionErrorHandler($e,"400",' UserController => ManagerList => Method-post');}}public function managerEmployeeList(Request $request){$api_url=$this->API_URL.'api/v1/get-assigned-employee-to-manager';$method='post';$data['limit']="10000";$data['manager_id']=$request->userId;try{$response=$this->helper->postApiCall($method,$api_url,$data);if($response['statusCode']==200){$result['code']=($response['data']['code']);$result['data']=($response['data']['data']);return $result;}else{$result['code']=400;$result['message']=$response['error'];$result['data']=null;return $result;}}catch(\Exception $e){return $this->ExceptionErrorHandler($e,"400",' UserController => managerEmployeeList => Method-post');}}public function managerAssignedEmployeeList(Request $request){$api_url=$this->API_URL_3.'api/'.$this->VERSION_3.'/user/get-assigned-employee';$data['to_assigned_id']=$request->userId;$data['to_assign_role_id']=$request->input('FilteredRoleId');$method='post';$data['limit']="1000000";try{$response=$this->helper->postApiCall($method,$api_url,$data);if($response['data']['code']=="200"){$result['code']=($response['data']['code']);$result['data']=($response['data']['data']);return $result;}else{$result['code']=$response['data']['code'];$result['msg']=$response['data']['message'];$result['error']=$response['data']['error'];$result['data']=null;return $result;}}catch(\Exception $e){return $this->ExceptionErrorHandler($e,"400",' UserController => managerAssignedEmployeeList => Method-post');}}public function AssignManager(Request $request){$api_url=$this->API_URL.'api/v1/assign-user-manager';$method='post';if($request->input('UserIds')!=null){$data['user_ids']=explode(',',$request->input('UserIds'));}else $data['user_ids']=[$request->input('User_id')];$data['manager_id']=$request->input('ManagerId');try{if($data['manager_id'][0]=="null"){$Error['Result']="501";$Error['msg']="Please select a manager";return $Error;}else{$response=$this->helper->postApiCall($method,$api_url,$data);$result['code']=$response['data']['code'];$result['msg']=$response['data']['message'];$result['data']=$response['data']['data'];return $result;}}catch(\Exception $e){return $this->ExceptionErrorHandler($e,"400",' UserController => AssignManager => Method-post');}}public function AssignMultipleManager(Request $request){$api_url=$this->API_URL.'api/v1/assign-user-manager-multi';$method='post';$data['user_id']=$request->User_id;$data['manager_ids']=explode(',',$request->input('ManagerId'));try{if($request->ManagerId==null){$Error['Result']="501";$Error['msg']="Please select a manager";return $Error;}else{$response=$this->helper->postApiCall($method,$api_url,$data);$result['code']=$response['data']['code'];$result['msg']=$response['data']['message'];$result['data']=$response['data']['data'];$result['InputData']=$data;return $result;}}catch(\Exception $e){return $this->ExceptionErrorHandler($e,"400",' UserController => AssignMultipleManager => Method-post');}}public function UnAssignManager(Request $request){$api_url=$this->API_URL_3.'api/'.$this->VERSION_3.'/user/unassign-user';if($request->input('user_id')!=null){$data['user_ids']=explode(",",$request->input('user_id'));}else{$data['user_ids']=explode(",",$request->input('user_idhide'));}$data['to_assigned_id']=$request->input('manager_id');$data['role_id']=$request->input('role_id');$method='delete';try{$response=$this->helper->postApiCall($method,$api_url,$data);if($response['code']==200){$api_url=$this->API_URL_3.'api/'.$this->VERSION_3.'/user/get-user';$method='post';$data['user_id']=$request->input('manager_id');$data['skip']="0";$data['limit']="10";$responses=$this->helper->postApiCall($method,$api_url,$data);$result['code']=($response['code']);$result['message']=($response['message']);$result['data']=($response['data']);if($responses['data']['code']==200){$result['ManagerList']=$responses['data']['data'];}else $result['ManagerList']="null";$result['HitAPI']=$request->input('HitAPI');return $result;}else{$result['code']=$response['code'];$result['message']=$response['message'];$result['data']=$response['data'];$result['error']=$response['error'];return $result;}}catch(\Exception $e){return $this->ExceptionErrorHandler($e,201,' UserController => UnAssignManager => Method-delete');}}public function AssignTLtoEmployee(Request $request){$api_url=$this->API_URL.'api/v1/assign-user-teamlead';$method='post';$data['user_ids']=$request->input('User_id')=="0"?explode(',',$request->input('User_ids')):[$request->input('User_id')];$data['teamlead_id']=$request->input('TeamLeaderId');try{$response=$this->helper->postApiCall($method,$api_url,$data);$result['code']=$response['data']['code'];$result['msg']=$response['data']['message'];$result['data']=$response['data']['data'];$result['error']=$response['data']['error'];}catch(\Exception $e){return $this->ExceptionErrorHandler($e,201,' UserController => AssignTLtoEmployee => Method-post');}return $result;}public function appTime(Request $request){$date="";if($request->isMethod("get")){$date=date("m/d/Y");}else if($request->isMethod("Post")){$date=$request->input("date");}$value="0";$skipValue="";$finalData=[];$api_url=$this->API_URL.'api/v1/apps-activity-track';$method='post';$data['user_id']=$request->input('userId');$data['date']=$date;$data['skip']="0";$data['limit']="10000";try{$response=$this->helper->postApiCall($method,$api_url,$data);if($response['data']['code']==200){array_push($finalData,$response['data']['data']['apps']);if($response['data']['data']['has_more_data']){$value++;$skipValue=$response['data']['data']['skip_value'];do{$data['skip']=$skipValue;$data['limit']="10000";$result=$this->helper->postApiCall($method,$api_url,$data);if($result['data']['code']==200){array_push($finalData,$result['data']['data']['apps']);if($result['data']['data']['has_more_data'])$skipValue=$result['data']['data']['skip_value'];else $value="0";}else $value="0";}while($value!="0");}}$result['code']=$response['data']['code'];$result['msg']=$response['data']['message'];$result['data']=$finalData;return $result;}catch(\Exception $e){return $this->ExceptionErrorHandler($e,400,' UserController => appTime => Method-post');}}public function webTime(Request $request){$date="";if($request->isMethod("get")){$date=date("m/d/Y");}else if($request->isMethod("Post")){$date=$request->input("date");}$value="0";$skipValue="";$finalData=[];$api_url=$this->API_URL.'api/v1/browser-activity-track';$method='post';$data['user_id']=$request->input('userId');$data['date']=$date;$data['skip']="0";$data['limit']="100000";try{$response=$this->helper->postApiCall($method,$api_url,$data);if($response['data']['code']==200){array_push($finalData,$response['data']['data']['apps']);if($response['data']['data']['has_more_data']){$value++;$skipValue=$response['data']['data']['skip_value'];do{$data['skip']=$skipValue;$data['limit']="10000";$result=$this->helper->postApiCall($method,$api_url,$data);if($result['data']['code']==200){array_push($finalData,$result['data']['data']['apps']);if($result['data']['data']['has_more_data'])$skipValue=$result['data']['data']['skip_value'];else $value="0";}else $value="0";}while($value!="0");}}$result['code']=$response['data']['code'];$result['msg']=$response['data']['message'];$result['data']=$finalData;return $result;}catch(\Exception $e){return $this->ExceptionErrorHandler($e,400,' UserController => webTime => Method-post');}}public function uploadBulkReg(Request $request){$method="post";$result=[];try{$file=$request->file;$pathToStorage=storage_path("bulk");if(!file_exists($pathToStorage))mkdir($pathToStorage,0777,true);$filename=$file->getClientOriginalName();$path=$pathToStorage."/".$filename;file_put_contents($path,file_get_contents($file->path()));$multipartData=array("name"=>"file","file"=>$path,);$uploadUrl=$this->API_URL_3.'api/'.$this->VERSION_3.'/user/user-register-bulk?count='.$request->input('count');$response=$this->helper->postApiCall($method,$uploadUrl,$multipartData,true);unlink(storage_path('bulk/'.$filename));return $this->helper->responseHandler($response);}catch(\Exception $e){return $this->ExceptionErrorHandler($e,500,' UserController => uploadBulkReg => Method-post');}}public function editBulkReg(Request $request){$method="post";$result=[];try{$file=$request->file;$pathToStorage=storage_path("bulk");if(!file_exists($pathToStorage))mkdir($pathToStorage,0777,true);$filename=$file->getClientOriginalName();$path=$pathToStorage."/".$filename;file_put_contents($path,file_get_contents($file->path()));$multipartData=array("name"=>"file","file"=>$path,);$uploadUrl=$this->API_URL_3.'api/'.$this->VERSION_3.'/user/bulk-update';$response=$this->helper->postApiCall($method,$uploadUrl,$multipartData,true);unlink(storage_path('bulk/'.$filename));$result['code']=$response['data']['code'];$result['msg']=$response['data']['message'];$result['data']=$response['data']['data'];$result['error']=$response['data']['error'];$result['inputData']=$request->input('count');return $result;}catch(\GuzzleHttp\Exception\RequestException $e){return $this->helper->GuzzleHTTPException($e,'editBulkReg');}}public function deleteBulkReg(Request $request){$method="post";$result=[];try{$file=$request->file;$pathToStorage=storage_path("bulk");if(!file_exists($pathToStorage))mkdir($pathToStorage,0777,true);$filename=$file->getClientOriginalName();$path=$pathToStorage."/".$filename;file_put_contents($path,file_get_contents($file->path()));$multipartData=array("name"=>"file","file"=>$path,);$uploadUrl=$this->API_URL_3.'api/'.$this->VERSION_3.'/user/user-delete-bulk';$response=$this->helper->postApiCall($method,$uploadUrl,$multipartData,true);unlink(storage_path('bulk/'.$filename));$result['code']=$response['data']['code'];$result['msg']=$response['data']['message'];$result['data']=$response['data']['data'];$result['error']=$response['data']['error'];return $result;}catch(\GuzzleHttp\Exception\RequestException $e){return $this->helper->GuzzleHTTPException($e,'deleteBulkReg');}}public function AssignMangerTL(Request $request){$SameId['code']=$error['code']="409";$error['msg']="Please, Select the option to assign...";$SameId['msg']="Please, Avoid To Assign The User To Himself...";if($request->input('role_type')==null)return $error;$api_url=$this->API_URL_3.'api/'.$this->VERSION_3.'/user/employee-assign';$method='post';if($request->input('Form')=="1"){if(in_array($request->input('User_id'),explode(",",$request->input('MangerIds'))))return $SameId;$managerId_s=explode(',',$request->input('MangerIds'));$data['employee_multi_upperole']=(object)["user_id"=>$request->input('User_id'),"role_id"=>$request->input('role_type'),"to_assign_ids"=>$managerId_s[0]!=""?$managerId_s:[]];}else if($request->input('Form')=="2"){if(in_array($request->input('MangerIds'),explode(",",$request->input('userIds'))))return $SameId;if($request->input('MangerIds')==null)return $error;$data['employee_to_assign']=(object)["user_ids"=>explode(',',$request->input('userIds')),"to_assign_id"=>$request->input('MangerIds'),"role_id"=>$request->input('role_type')];}try{$response=$this->helper->postApiCall($method,$api_url,$data);$result['code']=$response['data']['code'];$result['msg']=$response['data']['message'];$result['data']=$response['data']['data'];$result['inputData']=$request->all();$result['error']=$response['data']['error'];return $result;}catch(\Exception $e){return $this->ExceptionErrorHandler($e,"400",' UserController => AssignMangerTL => Method-post');}}public function uploadLogo(Request $request){$result=[];if($request->isMethod('get')){try{return view('User::logoUpload');}catch(\Exception $e){Log::info('exception in uploadLogo get '.$e->getMessage());}}else if($request->isMethod(('post'))){try{$validator=Validator::make($request->all(),['title'=>'required|max:255','logo'=>'required|image','favicon'=>'required|image|dimensions:max_width=1000,max_height:1000','logoname'=>'required']);if($validator->fails()){return Response::json(array('success'=>true,'errors'=>$validator->getMessageBag()->toArray()),400);}else{$result["code"]=200;}}catch(\Exception $e){$result['code']=500;$result['message']="Something went wrong. Please try again later";Log::info(" Exception in uploadLogo post ".$e->getMessage());}return $result;}}public function userUpdate(Request $request){try{$curl=curl_init();curl_setopt_array($curl,array(CURLOPT_URL=>"https://app.dev.empmonitor.com/amember/api/users/5?_key=aeLGOx5WmesWCrLa5VHp&name_f=Suresh%20Babu&numberofusers=502",CURLOPT_RETURNTRANSFER=>true,CURLOPT_ENCODING=>"",CURLOPT_MAXREDIRS=>10,CURLOPT_TIMEOUT=>0,CURLOPT_FOLLOWLOCATION=>true,CURLOPT_HTTP_VERSION=>CURL_HTTP_VERSION_1_1,CURLOPT_CUSTOMREQUEST=>"PUT",CURLOPT_HTTPHEADER=>array("Cookie: PHPSESSID=jn8uhtb1pgmqmht0qkot3rh8ev"),));$response=curl_exec($curl);curl_close($curl);if((json_decode($response,true))[0]['numberofusers']==502){echo "Your data has been updated please wait for 5 minutes....";return redirect('/amember/member');}else{echo "Data updation failed.. 5 minutes will redirect you to login page....";return redirect('');}}catch(\Exception $e){Log::info("Exception in userUpdate ".$e->getMessage()." => ".$e->getLine());return redirect('/amember/member');}}public function resellerLogin(Request $request){$logoPath='assets/images/logos/'.md5($_SERVER['HTTP_HOST']).'.png';if(!(\Illuminate\Support\Facades\File::exists(public_path($logoPath)))){Storage::disk('logos')->copy('assets/images/logos/EmpLogo.png',$logoPath);}$faviconPath='assets/images/favicons/'.md5($_SERVER['HTTP_HOST']).'.png';if(!(\Illuminate\Support\Facades\File::exists(public_path($faviconPath)))){Storage::disk('logos')->copy('assets/images/favicons/EmpFavicon.png',$faviconPath);}if($request->isMethod('get')){if(Session::has('admin')){return redirect('admin/dashboard');}return view('User::loginWhitelabel');}else if($request->isMethod('post')){$validator=Validator::make($request->all(),['password'=>'required|max:255','username'=>'required',]);if($validator->fails()){return redirect('admin-login')->withErrors($validator)->withInput();}else{$username=base64_encode($request->username);$password=base64_encode($request->password);$isClient=$request->isClient;if($isClient==="true"){return redirect('/resellerClientLogin/'.$username.'/'.$password.'/'.$isClient);}else{return redirect('/loginpageWhitelabel/'.$username.'/'.$password);}}}}public function logoutwhite(Request $request){Session::forget('admin');if(Session::has('plan')){Session::forget('plan');Session::flush();return redirect("admin-login");}else{Session::flush();return redirect('login');}}public function getOnline(Request $request){$result=[];try{$api_url=$this->API_URL_3.'api/'.$this->VERSION_3.'/dashboard/employees?date='.$request->input("date");$response=$this->helper->postApiCall('get',$api_url,[]);if($response['code']==200){$result['code']=200;$type=$request->type;switch($type){case 1:$result['data']=$response['data']['onlineEmps'];break;case 2:$result['data']=$response['data']['idleEmps'];break;case 3:$result['data']=$response['data']['absentEmp'];break;case 4:$result['data']=$response['data']['suspendedEmp'];break;case 5:$result['data']=$response['data']['registeredEmp'];break;case 6:$result['data']=$response['data']['offlineEmp'];break;default:$result['data']=$response['data'];break;}}else{$result['code']=202;$result['message']="Something went wrong.";}}catch(\Exception $e){Log::info("Exception in getAbsent ".$e->getMessage());$result['code']=500;$result['message']="Something went wrong. Please try again later";}return $result;}public function loginEmployee(Request $request){if($request->isMethod('get')){if(Session::has('employee')){return redirect(env('Employee').'/myTimeline?id='.Session::get(env('Employee'))['token']['user_id']);}return view("User::employeeLogin")->with('reset',[]);}else if($request->isMethod('post')){$rules=array("email"=>'required | email',"password"=>'required');try{$validator=Validator::make($request->all(),$rules);if($validator->fails()){return redirect()->back()->withErrors($validator)->withInput();}else{$loginData=array("userName"=>$request->email,"password"=>$request->password,"ip"=>$request->ip);$api_url=$this->API_URL.'api/v1/emp/auth';$response=$this->client->post($api_url,['form_params'=>$loginData,'headers'=>['user-agent'=>$_SERVER['HTTP_USER_AGENT'],'Content-Type'=>'application/x-www-form-urlencoded',]]);if($response->getStatusCode()==200){$response=json_decode($response->getBody()->getContents(),true);if($response['code']==200){if($response['photo_path']=='undefined')$response['photo_path']=env('DEFAULT_IMAGE');elseif(substr($response['photo_path'],0,5)==="https")$response['photo_path']=$response['photo_path'];else $response['photo_path']=env('API_HOST').$response['photo_path'];$employee=array('token'=>$response);Session::put(env('Employee'),$employee);return redirect(env('Employee').'/myTimeline?id='.Session::get(env('Employee'))['token']['user_id']);return view('User::Employee.NewEmployeeDashboard');}else if($response['code']==400){return redirect('employee-login')->with('error',$response['message']);}else{return redirect('employee-login')->with('error',$response['error']);}}}}catch(\Exception $e){Log::info('Exception '.$e->getLine()."=> code =>".$e->getCode()." => message => ".$e->getMessage());return redirect('employee-login')->with('error',$e->getMessage());}}}public function consolidatedReport(Request $request){$admin=[];if(Session::has(env('Admin'))){$admin["admin"]=1;}else{$admin["admin"]=0;$admin["user_id"]=Session::get($this->helper->getHostName())['token']['user_id'];}$location=$this->getAllLocations();$department=$this->getDepartments();return view("User::Report.consolidatedReports")->with(array('location'=>$location,'departments'=>$department,'admin'=>$admin));}public function TrackUserSettingView(Request $request){$UserData=$this->getUserTrackDetails($request,$request->id);$projectsOfUser=$this->getProjectsByUserId($request);$api=$this->API_URL_3.'api/'.$this->VERSION_3.'/settings/options';$SettingOptions=$this->helper->postApiCall('get',$api,0);if($UserData['code']===200){if(in_array($UserData['data']['tracking_rule_type'],[1,2,3])){return view('User::EmployeeDetail.trackUserSetting',["userId"=>$request->id,"data"=>$UserData,"trackUserData"=>3,"DropDownOption"=>$SettingOptions,"OrgGroups"=>$this->get_group(),'UserProjects'=>$projectsOfUser,'storageStatus'=>(new SettingsController())->storageStatus($request)]);}else{return view('User::EmployeeDetail.trackUserSetting',["userId"=>$request->id,"data"=>$UserData,"trackUserData"=>1,"DropDownOption"=>$SettingOptions,"OrgGroups"=>$this->get_group(),'UserProjects'=>$projectsOfUser]);}}else return redirect('dashboard')->with(Session::flash('message','Searched User Details Not Found'));}public function TrackUserSetting(Request $request){$fixedConstant=["1","2","3","4","5","6","7"];$days=(object)[];if($request->input('Track_rule_type')=='3'){switch($request->input('TrackingScenario')){case "unlimited":{$rules=["unlimitedDays"=>'required',];}break;case "fixed":{$rules=["FixedListTimes"=>'required',];}break;case "networkBased":{$rules=["MACaddress"=>['required','regex:/^(([0-9-]|[1-9][0-9-]|1[0-9-][0-9-]|2[0-4][0-9-]|25[0-5])(\.(?!$)|$)){4}$/i'],];}break;case "projectBased":{$rules=["projectBasedIds"=>'required'];}break;default:{$rules=["default"=>"default"];}}$customMessage=['MACaddress.required'=>__('messages.mac_ip_required'),'MACaddress.regex'=>__('messages.valid_mac_ip'),'geoLocation.required'=>__('messages.required'),];$validator=Validator::make($request->all(),$rules,$customMessage);if($validator->fails()){$data['code']="205";$data['errors']=$validator->errors();return $data;}if($this->helper->checkOrgIdle()){if($request->input('TrackingScenario')==='geoLocation'&&$request->geoLocation=="[]"){$data['code']="408";$data['errors']=__('messages.required');return $data;}}}try{$trackScenario=new \stdClass();switch($request->input('TrackingScenario')){case "unlimited":{$trackScenario=(object)["unlimited"=>(object)["day"=>$request->input('unlimitedDays'),],"domain"=>[],];}break;case "fixed":{foreach(explode(",",$request->input('FixedListTimes'))as $validate){$time=explode("#",$validate);switch($time[0]){case "MONDAY":{$days->mon=(object)["status"=>"true","time"=>(object)["start"=>$time[1],"end"=>$time[2]]];$fixedConstant=\array_diff($fixedConstant,["1"]);}break;case "TUESDAY":{$days->tue=(object)["status"=>"true","time"=>(object)["start"=>$time[1],"end"=>$time[2]]];$fixedConstant=\array_diff($fixedConstant,["2"]);}break;case "WEDNESDAY":{$days->wed=(object)["status"=>"true","time"=>(object)["start"=>$time[1],"end"=>$time[2]]];$fixedConstant=\array_diff($fixedConstant,["3"]);}break;case "THURSDAY":{$days->thu=(object)["status"=>"true","time"=>(object)["start"=>$time[1],"end"=>$time[2]]];$fixedConstant=\array_diff($fixedConstant,["4"]);}break;case "FRIDAY":{$days->fri=(object)["status"=>"true","time"=>(object)["start"=>$time[1],"end"=>$time[2]]];$fixedConstant=\array_diff($fixedConstant,["5"]);}break;case "SATURDAY":{$days->sat=(object)["status"=>"true","time"=>(object)["start"=>$time[1],"end"=>$time[2]]];$fixedConstant=\array_diff($fixedConstant,["6"]);}break;case "SUNDAY":{$days->sun=(object)["status"=>"true","time"=>(object)["start"=>$time[1],"end"=>$time[2]]];$fixedConstant=\array_diff($fixedConstant,["7"]);}}}if(count($fixedConstant)!=0){foreach($fixedConstant as $numbers){switch($numbers){case "1":{$days->mon=(object)["status"=>"false","time"=>(object)["start"=>"10:00","end"=>"11:00"]];}break;case "2":{$days->tue=(object)["status"=>"false","time"=>(object)["start"=>"10:00","end"=>"11:00"]];}break;case "3":{$days->wed=(object)["status"=>"false","time"=>(object)["start"=>"10:00","end"=>"11:00"]];}break;case "4":{$days->thu=(object)["status"=>"false","time"=>(object)["start"=>"10:00","end"=>"11:00"]];}break;case "5":{$days->fri=(object)["status"=>"false","time"=>(object)["start"=>"10:00","end"=>"11:00"]];}break;case "6":{$days->sat=(object)["status"=>"false","time"=>(object)["start"=>"10:00","end"=>"11:00"]];}break;case "7":{$days->sun=(object)["status"=>"false","time"=>(object)["start"=>"10:00","end"=>"11:00"]];}}}}$trackScenario=(object)["fixed"=>$days,"domain"=>[],];}break;case "networkBased":{$trackScenario=(object)["networkBased"=>(object)["networkName"=>$request->input('NetworkName'),"ipAddress"=>$request->input('MACaddress'),"officeNetwork"=>$request->input('officeNetwork')],"domain"=>[],];}break;case "manual":{$trackScenario=(object)["manual"=>(object)["day"=>"1,2,3,4,5,6"],"domain"=>[],];}break;case "projectBased":{$projectsArray=[];foreach(explode(",",$request->input('projectBasedIds'))as $projects){array_push($projectsArray,(object)['id'=>$projects,]);}$trackScenario=(object)["projectBased"=>$projectsArray,];}break;case "geoLocation":{$geoLocation=[];$response=json_decode($request->geoLocation);$temp=[];foreach($response as $res){$temp["location"]=$res->location;$temp["lon"]=$res->lon;$temp["lat"]=$res->lat;$temp["distance"]=$res->distance;array_push($geoLocation,(object)$temp);}$trackScenario=(object)["geoLocation"=>$geoLocation];}}$video1280=0;$video1080=0;$video720=0;$data['employee_id']=$request->input('UserId');$data['type']=($request->input('Track_rule_type')=='undefined')?3:$request->input('Track_rule_type');$data['group_id']=($request->input('group_id'));$frequencyPerHour=($this->helper->checkOrangeClient())?2:$request->input('SSFrequency');$ScreenshotsOption=($this->helper->checkOrangeClient())?0:$request->input('ScreenshotsOption');$data['track_data']=(object)["system"=>(object)["type"=>$request->input('SystemRoll'),"visibility"=>$request->input('EmpIcon'),'autoUpdate'=>$request->input('auto_update')],"screenshot"=>(object)["frequencyPerHour"=>$frequencyPerHour,],"screenRecord"=>(object)["ultrafast_1280_21"=>$video1280,"ultrafast_1080_21"=>$video1080,"ultrafast_720_21"=>$video720,],"features"=>(object)["application_usage"=>"0","web_usage"=>$request->input('WebsiteOption'),"keystrokes"=>$request->input('KeyStrokeOption'),"screenshots"=>$ScreenshotsOption,"block_websites"=>$request->input('BlockWebsiteOption'),],"breakInMinute"=>30,"timesheetIdleTime"=>$request->input('timesheetIdleTime'),"idleInMinute"=>$request->input('IdleTime'),"trackingMode"=>($request->input('TrackingScenario')),"tracking"=>(object)$trackScenario,"manual_clock_in"=>($request->input('manual_clock_in')),"is_attendance_override"=>($request->input('is_attendance_override')),"usbDisable"=>$request->input('usbDisable'),"systemLock"=>$request->input('systemLock'),"userBlock"=>$request->userBlock,"block"=>(object)array("contact"=>$request->userBlockContact,"email"=>$request->userBlockEmail,"logo"=>$request->userBlockLogo,)];if(isset(json_decode($request->input('domainTrackData'))->tracking->domain)){$trackScenario->domain=json_decode($request->input('domainTrackData'))->tracking->domain;if(isset($trackScenario->domain->suspendPrivateBrowsing))$trackScenario->domain->suspendPrivateBrowsing=($trackScenario->domain->suspendPrivateBrowsing=='true'||$trackScenario->domain->suspendPrivateBrowsing==true)?'true':'false';if(isset($trackScenario->domain->suspendKeystrokesPasswords)){if(($trackScenario->domain->suspendKeystrokesPasswords=='true')){$trackScenario->domain->suspendKeystrokesPasswords="true";}else{$trackScenario->domain->suspendKeystrokesPasswords="false";}}}if(isset($trackScenario->domain->daysAndTimes)){foreach($trackScenario->domain->daysAndTimes as $key=>$value){$trackScenario->domain->daysAndTimes->$key->status=$value->status=="true"?"true":"false";}}$api_url=$this->API_URL_3.'api/'.$this->VERSION_3.'/settings/user-tracking-setting';$method="post";$response=$this->helper->postApiCall($method,$api_url,$data);return $this->helper->responseHandler($response);}catch(\Exception $e){return $this->ExceptionErrorHandler($e,405,' UserController => TrackUserSetting => Method-post');}return $result;}public function AdvanceTrackUserSetting(Request $request){($request->login_from_other_system==='1')&&($this->agentLogout($request->employee_id));$data['track_data']=(json_decode($request->track_data,true));$data['employee_id']=$request->employee_id;$data['type']=$request->type;$data['group_id']=$request->group_id;$data['track_data']['system']['visibility']=$data['track_data']['system']['visibility']==true?'true':"false";if((isset($data['track_data']['screenshot']['employeeAccessibility'])))$data['track_data']['screenshot']['employeeAccessibility']=$data['track_data']['screenshot']['employeeAccessibility']==true?'true':"false";if((isset($data['track_data']['screenshot']['employeeCanDelete'])))$data['track_data']['screenshot']['employeeCanDelete']=$data['track_data']['screenshot']['employeeCanDelete']==true?'true':"false";if((isset($data['track_data']['task']['employeeCanCreateTask'])))$data['track_data']['task']['employeeCanCreateTask']=$data['track_data']['task']['employeeCanCreateTask']==true?'true':"false";if((isset($data['track_data']['tracking']['fixed']))){foreach($data['track_data']['tracking']['fixed']as $key=>$value){$data['track_data']['tracking']['fixed'][$key]['status']=$value["status"]=="true"?"true":"false";}}if(isset($data['track_data']['tracking']['app']['daysAndTimes'])){foreach($data['track_data']['tracking']['app']['daysAndTimes']as $key=>$value){$data['track_data']['tracking']['app']['daysAndTimes'][$key]['status']=$value["status"]=="true"?"true":"false";}}if($request->MONITORONOFF=="on"){$request->MONITORONOFF="true";}else if($request->MONITORONOFF=="off"){$request->MONITORONOFF="false";}else{if(isset($data['track_data']['tracking']['domain']['suspendKeystrokesPasswords'])){$request->MONITORONOFF=$data['track_data']['tracking']['domain']['suspendKeystrokesPasswords']=='true'?'true':"false";}}$errors=[];$needle=['\\','/'];$array1=($request->userTrackingWebsite!=null)?$request->userTrackingWebsite:[];$array2=($request->userTracSuspendWebsiteVisit!=null)?$request->userTracSuspendWebsiteVisit:[];$array3=($request->userTracSuspendKeystrokeWebsite!=null)?$request->userTracSuspendKeystrokeWebsite:[];$check=[];$check2=[];$MonitorWebsite=[];$MonitorWebsitedata=[];$SuspendMonitorWebsite=[];$SuspendMonitorWebsitedata=[];$websiteSuspendKeystrokeWebsite=[];$blockingApplication=[];$blockingWebsitesData=[];$blockingWebsites=[];$websiteSuspendKeystrokeWebsitedata=[];if(count($array1)>0&&count($array2)>0)$check=array_intersect($array1,$array2);if(count($check)>0){$response['code']=404;$response['msg']=__('messages.duplicateValue');$response['data']=null;return $response;}$pattern="/\b(?:\.)[-a-z0-9+&@#\/%?=~_|!:,.;]*[-a-z0-9+&@#\/%=~_|]/i";if($request->userTrackingWebsite!=null){foreach($request->userTrackingWebsite as $key=>$value){if(!(preg_match($pattern,$value))){$errors[]=$value;}else{$domainData=$this->get_domain($value);if(!in_array($domainData,$MonitorWebsite)){$MonitorWebsite[]=$domainData;$MonitorWebsitedata[]=$value;}}}if(count($errors)>0){$valid=$this->urlValidationFunction($errors,201);if($valid!=null)return Response::json($valid,200);}else{$request->userTrackingWebsite=$MonitorWebsitedata;}}if($request->userTracSuspendWebsiteVisit!=null){foreach($request->userTracSuspendWebsiteVisit as $key=>$value){if(!(preg_match($pattern,$value))){$errors[]=$value;}else{$domainData=$this->get_domain($value);if(!in_array($domainData,$SuspendMonitorWebsite)){$SuspendMonitorWebsite[]=$domainData;$SuspendMonitorWebsitedata[]=$value;}}}if(count($errors)>0){$valid=$this->urlValidationFunction($errors,202);if($valid!=null)return Response::json($valid,200);}else{$request->userTracSuspendWebsiteVisit=$SuspendMonitorWebsitedata;}}if($request->userTracSuspendKeystrokeWebsite!=null){foreach($request->userTracSuspendKeystrokeWebsite as $key=>$value){if(!(preg_match($pattern,$value))){$errors[]=$value;}else{$domainData=$this->get_domain($value);if(!in_array($domainData,$websiteSuspendKeystrokeWebsite)){$websiteSuspendKeystrokeWebsite[]=$domainData;$websiteSuspendKeystrokeWebsitedata[]=$value;}}}if(count($errors)>0){$valid=$this->urlValidationFunction($errors,203);if($valid!=null)return Response::json($valid,200);}else{$request->userTracSuspendKeystrokeWebsite=$websiteSuspendKeystrokeWebsitedata;}}if($request->userTrackBlockingWebsite!=null){foreach($request->userTrackBlockingWebsite as $key=>$value){$url=preg_replace("(^https?://)","",$value);$url=strpos($url,'www')!==0?"www.$url":$url;if(!(preg_match($pattern,$url))){$errors[]=$url;}else{$domainData=$this->get_domain($url);if(!in_array($domainData,$blockingWebsites)){$blockingWebsites[]=$domainData;$blockingWebsitesData[]=$url;}}}if(count($errors)>0){$valid=$this->urlValidationFunction($errors,405);if($valid!=null)return Response::json($valid,200);}else{$request->userTrackBlockingWebsite=$blockingWebsitesData;}}if($request->userTrackBlockingApplciation!=null){$blockingApplication=implode(",",$request->input('userTrackBlockingApplciation'));}else $blockingApplication="";if(count($MonitorWebsite)>0&&count($SuspendMonitorWebsite)>0&&count($blockingWebsites)>0)$check=array_intersect($MonitorWebsite,$SuspendMonitorWebsite,$blockingWebsites);if(count($check)>0){$response['code']=404;$response['msg']=__('messages.duplicateValue');$response['data']=null;return $response;}$data['track_data']['usbDisable']=$request->USB_feature;$data['track_data']['tracking']['domain']=array("monitorOnly"=>$request->userTrackingWebsite,"suspendMonitorWhenVisited"=>$request->userTracSuspendWebsiteVisit,"suspendKeystrokesWhenVisited"=>$request->userTracSuspendKeystrokeWebsite,"websiteBlockList"=>$request->userTrackBlockingWebsite,"appBlockList"=>$blockingApplication,"suspendKeystrokesPasswords"=>$request->MONITORONOFF);$data['track_data']['userBlock']=(int)$request->userBlock;$customMessage=['userBlockContact.required'=>__('Contact is required'),'userBlockEmail.required'=>__('Email is required'),];$rules=["userBlockContact"=>'required',"userBlockEmail"=>'required'];$validator=Validator::make($request->all(),$rules,$customMessage);if((int)$request->userBlock===1&&$validator->fails()){$error['code']=205;$error['errors']=$validator->errors();return $error;}$data['track_data']['block']=(object)array("contact"=>$request->userBlockContact,"email"=>$request->userBlockEmail,"logo"=>$request->userBlockLogo,);try{$api_url=$this->API_URL_3.'api/'.$this->VERSION_3.'/settings/user-tracking-setting';$method="post";$response=$this->helper->postApiCall($method,$api_url,$data);if($response['statusCode']==200){if($response['data']['code']==200){$result['code']=200;$result['advanceWebsiteData']=$data['track_data']['tracking']['domain'];$result['msg']=$response['data']['message'];}else{$result['code']=$response['data']['code'];$result['msg']=$response['data']['code']==400?$response['data']['message']:$result['msg']=$response['data']['code']==404?$response['data']['error']:$response['data']['message'];}}}catch(\Exception $e){$result=$this->ExceptionErrorHandler($e,405,' UserController => TrackUserSetting => Method-post');}return $result;}public function getUserTrackDetails(Request $request,$id){$api=$this->API_URL_3.'api/'.$this->VERSION_3.'/settings/get-emp-setting-trac';$method="post";$data['employee_id']=$id;try{$response=$this->helper->postApiCall($method,$api,$data);if($response['data']['code']==200){if(!(isset($response['data']['data']['custom_tracking_rule']['tracking']['domain']))){$response['data']['data']['custom_tracking_rule']['tracking']['domain']['suspendKeystrokesPasswords']="true";}}$result['code']=$response['data']['code'];$result['msg']=$response['data']['message'];$result['data']=$response['data']['data'];}catch(\Exception $e){return $this->ExceptionErrorHandler($e,205,' UserController => TrackUserSetting => Method-post');}return($result);}public function loginPageNewAPI(Request $request,$username=null){if(Session::has('admin')){return redirect('dashboard');}try{$checkUserCount=0;$apikey=env('APP_AMEMBER_KEY');$result=json_decode($this->curl_execution(env('APP_AMEMBER_URL')."check-access/by-login?_key=$apikey&login=$request->username"),true);if($result['ok']&&!empty($result['subscriptions'])){$plan=[];$checkPlan=$this->checkPlans($result['subscriptions']);$totalFileds=\GuzzleHttp\json_decode($this->curl_execution(env('APP_AMEMBER_URL')."users?_key=$apikey&_filter[user_id]=".$result['user_id']),true);$resultInvoice=json_decode($this->curl_execution(env('APP_AMEMBER_URL')."invoices?_key=".$apikey."&_filter[user_id]=".$result['user_id']),true);$adminInfo=json_decode($this->curl_execution(env('APP_AMEMBER_URL')."users?_key=".$apikey."&_filter[user_id]=".$result['user_id']),true);$currentPlanIndex=$this->checkActiveInvoice($resultInvoice,$checkPlan);if(isset($totalFileds[0]['numberofusers'])){if($resultInvoice['_total']!=0){if($currentPlanIndex!='-1'){$currentPlan=$resultInvoice[$currentPlanIndex];$currentPlan=$currentPlan['nested']['invoice-items'];$options=json_decode($currentPlan[0]['options']);if(isset($options->{'No of Users'})){if((int)$totalFileds[0]['numberofusers']>=(int)$options->{'No of Users'}->value){$checkUserCount=1;}}else{$checkUserCount=1;}}}else if($totalFileds[0]['numberofusers']!=""&&$totalFileds[0]['numberofusers']!=0){$checkUserCount=1;}}if(isset($totalFileds[0]['numberofusers'])&&$checkUserCount==1){$plan['item_id']=$checkPlan;$plan['item_title']="Manually-Added-User";$plan['no_of_users']=$totalFileds[0]['numberofusers'];$plan['email']=$result['email'];$plan['name']=$result['name'];$plan['avatar']=env('APP_URL')."amember/avatar/".$totalFileds[0]['avatar'];Session::put('plan',$plan);$result['product_id']=$checkPlan;$result['begin_date']=date('Y-m-d');$result['expire_date']=$result['subscriptions'][$checkPlan];}else if($resultInvoice['_total']!=0){if($currentPlanIndex!='-1'){$currentPlan=$resultInvoice[$currentPlanIndex];$currentPlan=$currentPlan['nested']['invoice-items'];$keyAccess=0;for($k=0;$k<count($resultInvoice[$currentPlanIndex]['nested']['access']);$k++){if($resultInvoice[$currentPlanIndex]['nested']['access'][$k]['expire_date']>date('Y-m-d')){$keyAccess=$k;}}$result['product_id']=$resultInvoice[$currentPlanIndex]['nested']['access'][$keyAccess]['product_id']?$resultInvoice[$currentPlanIndex]['nested']['access'][0]['product_id']:'';$result['begin_date']=$resultInvoice[$currentPlanIndex]['nested']['access'][$keyAccess]['begin_date']?$resultInvoice[$currentPlanIndex]['nested']['access'][0]['begin_date']:'';$result['expire_date']=$resultInvoice[$currentPlanIndex]['nested']['access'][$keyAccess]['expire_date'];$options=json_decode($currentPlan[0]['options']);$plan['item_id']=$currentPlan[0]['item_id'];$plan['item_title']=$currentPlan[0]['item_title'];$plan['no_of_users']=$options->{'No of Users'}->value;$plan['email']=$result['email'];$plan['name']=$result['name'];$plan['avatar']=env('APP_URL')."amember/avatar/".$adminInfo[0]['avatar'];Session::put('plan',$plan);}else{return redirect('login-member')->with('error','Invalid subscription');}}else{return redirect('login-member')->with('error','Invalid subscription');}}else{if(isset($result['msg'])){return redirect('login-member')->with('error',$result['msg']);}return redirect('login-member')->with('error','Something went wrong. Please contact support Team');}$api_url=$this->API_URL_3.'api/'.env('API_VERSION_3').'/auth/admin';$method="post";$amemberData=array("name"=>$result['name'],"first_name"=>$result['name_f'],"last_name"=>$result['name_l'],"email"=>$result['email'],"username"=>$result['login'],"product_id"=>$result['product_id'],"begin_date"=>$result['begin_date'],"expire_date"=>$result['expire_date'],"timezone"=>"Africa/Bamako");$adminAuthResponse=$this->client->post($api_url,['form_params'=>$amemberData,'headers'=>['user-agent'=>$_SERVER['HTTP_USER_AGENT'],'Content-Type'=>'application/x-www-form-urlencoded',]]);if($adminAuthResponse->getStatusCode()==200){$adminAuthResponse=json_decode($adminAuthResponse->getBody()->getContents(),true);if($adminAuthResponse['code']==200){Session::put('locale',$adminAuthResponse['language']);$admin=array('token'=>array('data'=>$adminAuthResponse['data'],'is_admin'=>$adminAuthResponse['is_admin'],'is_manager'=>$adminAuthResponse['is_manager'],'is_teamlead'=>$adminAuthResponse['is_teamlead'],'login'=>$result['login'],'email'=>$result['email']));$role=str_replace(' ','',strtolower($adminAuthResponse['role']));Session::put('role',$role);Session::put($role,$admin);if(isset($_POST['remember'])){setcookie('member_name',$request->username,time()+(365*24*60*60),['httponly'=>true,'secure'=>true,'samesite'=>'Strict']);setcookie('member_password',$request->password,time()+(365*24*60*60),['httponly'=>true,'secure'=>true,'samesite'=>'Strict']);}else{setcookie('member_name','');setcookie('member_password','');}return redirect('dashboard');}else{return redirect('login-member')->with('error','Invalid authentication');}}else{return redirect('login-member')->with('error','Invalid authentication');}}catch(\Exception $e){Log::info('Exception '.$e->getLine()."=> code =>".$e->getCode()." => message => ".$e->getMessage());return redirect('login-member')->with('error','Something went wrong. Please contact support Team');}}public function memberLogin(Request $request){if(Session::has('admin')){return redirect('dashboard');}return view('User::login-member')->with('reset',[]);}public function ExceptionErrorHandler($exception,$code,$functionName){Log::info('Exception '.$exception->getLine()." => Function Name => ".$functionName." => code =>".$exception->getCode()." => message => ".$exception->getMessage());$result['code']=$code;$result['msg']="Please, Reload and try again...";$result['ErrorMessage']=$exception->getMessage();return $result;}public function guzzleErrorHandler($guzzleException,$functionName){$response=$guzzleException->getResponse();$result['code']=403;$result['msg']=$response->reasonPhrase;Log::info("GuzzleException => Function Name => ".$functionName."=> code =>".$result['code']." => message => ".$result['msg']);return $result;}public function DownloadUserSetup(Request $request){return view("User::download_setup_link",["DownloadLinksDetails"=>$this->DownloadLinks()]);}public function DownloadLinks(){$api='https://service.empmonitor.com/api/v3/organization-build/build-on-premise?email='.Session::get(env('Admin'))['token']['email'];try{$response=$this->helper->postApiCall("get",$api,[]);$result['code']=$response['code'];$result['msg']=$response['message'];$result['data']=$response['data'];$result['error']=$response['error'];if($result['code']===400){$this->GenerateBuilds();}return $result;}catch(\Exception $e){return $this->ExceptionErrorHandler($e,400,' UserController => DownloadLinks => Method-post');}}public function GenerateBuilds(){$api=$this->API_URL_3.'api/'.$this->VERSION_3.'/build/create';try{$input['email']=Session::get('admin')['token']['email'];$response=$this->helper->postApiCall("post",$api,$input);$result['code']=$response['code'];$result['msg']=$response['message'];$result['data']=$response['data'];$result['error']=$response['error'];return $result;}catch(\Exception $e){return $this->ExceptionErrorHandler($e,400,' UserController => GenerateBuilds => Method-post');}}public function empAttendanceSheet(){return view("User::EmployeeDetail.emp_attendance",["LocationData"=>$this->getAllLocations(),"DepartementData"=>$this->getDepartments(),"TodayDate"=>date('M/Y')]);}public function attendanceListEmployees(Request $request){$date=$request->input('date')!=null?$request->input('date'):date('Ym');try{$dptId=$request->input('DepartmentId')!=null&&$request->input('DepartmentId')!="null"?'&departmentId='.$request->input('DepartmentId'):"";$locId=$request->input('LocationId')!=null&&$request->input('LocationId')!="null"?'&locationId='.$request->input('LocationId'):"";$skip=$request->input('skip')!=null&&$request->input('skip')!="null"?'&skip='.$request->input('skip'):"";$searchText=$request->input('searhcText')!=null&&$request->input('searhcText')!="null"?'&search='.$request->input('searhcText'):"";$sortName=$request->input('sortName')!=null&&$request->input('sortName')!="null"?'&sortColumn='.$request->input('sortName'):"";$sortOrder=$request->input('sortOrder')!=null&&$request->input('sortOrder')!="null"?'&sortOrder='.$request->input('sortOrder'):"";$limit=$request->input('limit')!=null&&$request->input('limit')!="null"?'&limit='.$request->input('limit'):"";$api=$this->API_URL_3.'api/'.$this->VERSION_3.'/employee/attendance-sheet?date='.$date.$limit.$locId.$dptId.$skip.$searchText.$sortName.$sortOrder;$response=$this->helper->postApiCall('get',$api,[]);return $this->helper->responseHandlerWithoutStatusCode($response);}catch(\GuzzleHttp\Exception\RequestException $e){return $this->helper->GuzzleHTTPException($e,"attendanceListEmployees");}return $result;}public function permissionDenied(){return view('User::permissionDenied');}public function excelAllDataOfUsers(Request $request){$api=$this->API_URL_3.'api/'.$this->VERSION_3.'/user/employee-list';$data['status']=$request->input('Status');$request->input('Location')!=0&&$request->input('Location')!='null'?$data['location_id']=$request->input('Location'):null;$request->input('Department')!=0&&$request->input('Department')!='null'?$data['department_id']=$request->input('Department'):null;$request->input('Role')!=0&&$request->input('Role')!='null'?$data['role_id']=$request->input('Role'):null;$request->input('SearchText')!=null?$data['name']=$request->input('SearchText'):null;$request->input('employeeId_s')!=null?$data['employee_ids']=explode(',',$request->input('employeeId_s')):null;try{$response=$this->helper->postApiCall("post",$api,$data);return $this->helper->responseHandler($response);}catch(\GuzzleHttp\Exception\RequestException $e){return $this->helper->GuzzleHTTPException($e,' UserController => excelAllDataOfUsers => Method-post');}}public function get_group(){try{$api_url=$this->API_URL_3.'api/'.env('API_VERSION_3').'/groups';$method="get";try{$response=$this->helper->postApiCall($method,$api_url,0);return $this->helper->responseHandlerWithoutStatusCode($response);}catch(\GuzzleHttp\Exception\RequestException $e){return $this->guzzleErrorHandler($e,' SettingsController => get_group => Method-get ');}}catch(\Exception $e){return $this->helper->errorHandler($e,' SettingsController => get_group => Method-get ');}}function get_domain($url){$pieces=parse_url($url);$domain=isset($pieces['host'])?$pieces['host']:$pieces['path'];if(preg_match('/(?P<domain>[a-z0-9][a-z0-9\-]{1,63}\.[a-z\.]{2,6})$/i',$domain,$regs)){return $regs['domain'];}return false;}public function urlValidationFunction(array$errors,$code){if(count($errors)>0){$response['code']=$code;$response['msg']=array_unique($errors);$response['data']=null;return $response;}}public function adminForgotPassword(Request $request){$validator=Validator::make($request->all(),['adminEmailId'=>'required|email',],['adminEmailId.required'=>'Email id is required','adminEmailId.min'=>'The admin email id must be a valid email address.',]);if($validator->fails()){$response['code']=201;$response['msg']=$validator->errors()->all();$response['data']=null;return Response::json($response,200);}$result=[];$data['email']=$request->adminEmailId;$data['isClient']=$request->isClient;$apiUrl='/password/admin/reset';if($request->isClient==="true")$apiUrl='/password/forgot-password';try{$api_url=$this->API_URL_3.'api/'.$this->VERSION_3.$apiUrl;$response=$this->helper->postApiCall("post",$api_url,$data);return $this->helper->responseHandler($response);}catch(\Exception $e){Log::info('Exception '.$e->getLine()."=> code =>".$e->getCode()." => message => ".$e->getMessage());$result['code']=500;$result['msg']="Something went wrong...";return $result;}}public function adminResetPassword(Request $request){return view("User::resellerPasswordReset");}public function adminNewPassword(Request $request){$validator=Validator::make($request->all(),["new_password"=>'required|min:8',"confirm_password"=>'required|same:new_password'],['new_password.required'=>'password is required','new_password.min'=>'Minimum 8 charecters Required','confirm_password.required'=>'confirm password is required','confirm_password.same'=>'password mismatch',]);if($validator->fails()){$response['code']=201;$response['msg']=$validator->errors()->all();$response['data']=null;return Response::json($response,200);}$amember_id=Session::get('adminForPassAmmId');$result=json_decode($this->curl_execution(env('APP_AMEMBER_URL')."users/".$amember_id."?_method=PUT&_key=".env('APP_AMEMBER_KEY')."&pass=".$request->new_password),true);if(isset($result['0']['user_id'])&&$result['0']['user_id']==$amember_id){$result['code']=200;$result['data']=null;$result['msg']="success";}else{$result['code']=400;$result['data']=null;$result['msg']="error";}return $result;}public function verifyAdminForgotPassword(Request $request){$adminForPassAmmId=$this->encryptDecryptPswd($request,2,$request->id);Session::forget('adminForPassAmmId');Session::put('adminForPassAmmId',$adminForPassAmmId);try{if(isset($request->id)){return redirect('admin-reset-password');}else{return redirect('admin-login');}}catch(\Exception $e){Log::info('Exception '.$e->getLine()."=> code =>".$e->getCode()." => message => ".$e->getMessage());$result['code']=500;$result['msg']="Something went wrong...";return $result;}}/**
* encryptDecryptPswd
* *This is used for hashing the password to improve security
* @param mixed $request
* @param mixed $param
* @param string $password
* @return void
*/ public function encryptDecryptPswd(Request $request,$param,$password){$name=$request->input('password');$encryptionMethod=env('PASSWORD_ALGORITHM');$secret=env('CRYPTO_PASSWORD');$iv=env('PASSWORD_IV');$encryptedMessage=openssl_encrypt($name,$encryptionMethod,$secret,0,$iv);$decryptedMessage=openssl_decrypt($password,$encryptionMethod,$secret,0,$iv);if(!$decryptedMessage)$decryptedMessage="";return $param===1?$encryptedMessage:$decryptedMessage;}public function getProjectsByUserId(Request $request){try{$employeeId="employee_ids=[".$request->input('id')."]";$api=$this->API_URL_3.'api/'.$this->VERSION_3.'/project/get-employees-all-projects?'.$employeeId;$result=$this->helper->postApiCall('get',$api,0);return $this->helper->responseHandlerWithoutStatusCode($result);}catch(\Exception $e){return $this->ExceptionErrorHandler($e,205,' UserController => TrackUserSetting => Method-post');}}public function unInstallerDownload(Request $request){$file=$request->input('type')==="1"?($request->input('bit')==="32"?public_path()."/UninstallerFile/Uninstaller(x86)_employeeID.rar":public_path()."/UninstallerFile/Uninstaller(x64)_employeeID.rar"):($request->input('bit')==="32"?public_path()."/UninstallerFile/Uninstaller(x86)_organizationID.rar":public_path()."/UninstallerFile/Uninstaller(x64)_organizationID.rar");$name=$request->input('bit')==="32"?"Uninstaller(x86)_":"Uninstaller(x64)_";$headers=array('Content-Type: application/rar',);$Id=$request->input('type')==="1"?$request->id:Session::get(env('Admin'))['token']['organization_id'];return Response::download($file,$name.$Id.'.rar',$headers);}public function getLogo(Request $request){$api=$this->API_URL_3.'api/'.$this->VERSION_3.'/organization/upload-logo';try{$result=$this->helper->postApiCall("get",$api,[]);if($result['code']===200){return $result;}else{$documents["file"]=array("name"=>"file","file"=>config('app.url').'assets/images/logos/remote_lock_logo.png');$api_url=$this->API_URL_3.'api/'.$this->VERSION_3.'/organization/upload-logo';$data=$this->helper->postApiCall("post",$api_url,$documents['file'],true);if($data['statusCode']===200){return $data['data'];}}}catch(\Exception $e){return $this->ExceptionErrorHandler($e,400,' UserController => getLogo => Method-get');}}public function userBlockLogo(Request $request){$file=$request->file_documents;try{$pathToStorage=public_path('assets/hrms/assets/image');;if(!file_exists($pathToStorage)){mkdir($pathToStorage,0777,true);}$filename=$file->getClientOriginalName();$filename=str_replace(' ','',$filename);$path=$pathToStorage."/".$filename;file_put_contents($path,file_get_contents($file->path()));$documents["file"]=array("name"=>"file","file"=>$path);$api_url=$this->API_URL_3.'api/'.$this->VERSION_3.'/organization/upload-logo';$result=$this->helper->postApiCall("post",$api_url,$documents['file'],true);unlink($path);return $result;}catch(\Exception $e){return $this->ExceptionErrorHandler($e,"400",'PayrollController => fileUploadForEmployee => Method-post');}}public function agentLogout($emp_id){$api_url=$this->API_URL_3.'api/'.$this->VERSION_3.'/auth/agent-logout?employeeId='.$emp_id;try{return $this->helper->postApiCall('get',$api_url,[]);}catch(\Exception $e){return $this->helper->errorHandler($e,' EmployeeDetailsController => agentLogout => Method-get ');}}public function agentEmpLogout(Request $request){try{$response=$this->agentLogout($request->emp_id);if($response['code']==200){$result['code']=200;$result['data']=$response['data'];$result['msg']=$response['message'];}else{$result['code']=$response['code'];$result['msg']=$response['code']==400?$response['message']:$response['error'];}return $result;}catch(\Exception $e){return $this->helper->errorHandler($e,' EmployeeDetailsController => agentLogout => Method-get ');}}public function getToAssignedDetails(Request $request){$api_url=$this->API_URL_3.'api/'.$this->VERSION_3.'/user/get-user';$method='post';try{$response=$this->helper->postApiCall($method,$api_url,$request->all());return $this->helper->responseHandler($response);}catch(\Exception $e){return $this->ExceptionErrorHandler($e,"400",' UserController => getToAssignedDetails => Method-post');}}public function getSuperiorData(Request $request){$api_url=$this->helper->API_URL_3.'/user/employee-assigned-to';try{$response=$this->helper->postApiCall('post',$api_url,$request->all());return $this->helper->responseHandler($response);}catch(\Exception $e){return $this->ExceptionErrorHandler($e,"400",' UserController => getToAssignedDetails => Method-post');}}public function getActiveUnactiveData(Request $request){try{$api_url=$this->API_URL_3.'api/'.env('API_VERSION_3').'/timesheet/?location_id='.$request->locationId.'&department_id='.($request->departmentId==='null'?'0':$request->departmentId).'&start_date='.$request->start_date.'T00:00:00.000Z&end_date='.$request->end_date.'T00:00:00.000Z&employee_id=0';$method="get";try{$response=$this->helper->postApiCall($method,$api_url,$request->all());if($response['code']==200){$result['code']=200;$result['msg']=$response['message'];$resultData=[];foreach($response['data']['user_data']as $value){if(array_key_exists($value['id'],$resultData)){$resultData[$value['id']]['computer_activities_time']=(int)$resultData[$value['id']]['computer_activities_time']+(int)$value['computer_activities_time'];}else{$resultData[$value['id']]=$value;}}$result['data']=$resultData;}else{$result['code']=400;$result['msg']=$response['code']==400?$response['message']:$response['error'];$result['data']=$response['data'];}return $result;}catch(\GuzzleHttp\Exception\RequestException $e){return $this->guzzleErrorHandler($e,' UserController => getActiveUnactiveData => Method-get ');}}catch(\Exception $e){return $this->helper->errorHandler($e,' UserController => getActiveUnactiveData => Method-get ');}}public function AssignShift(Request $request){try{$api_url=$this->helper->API_URL_3.'/user/assign-shift-bulk-employees';$method='put';if($request->input('seluserids')!=null){$data['employees_id']=explode(',',$request->input('seluserids'));}else $data['employees_id']=[$request->input('seluserids')];$data['shift_id']=$request->input('shiftId');$response=$this->helper->postApiCall($method,$api_url,$data);return $response;}catch(\Exception $e){return $this->ExceptionErrorHandler($e,"400",' UserController => AssignShift => Method-put');}}public function employeeAttendanceSheet(){return view("User::employee_attendance",["LocationData"=>$this->getAllLocations(),"DepartementData"=>$this->getDepartments(),"TodayDate"=>date('M/Y')]);}public function employeeAttendanceList(Request $request){$date=$request->input('date')!=null?$request->input('date'):date('Ym');try{$dptId=$request->input('DepartmentId')!=null&&$request->input('DepartmentId')!="null"?'&departmentId='.$request->input('DepartmentId'):"";$locId=$request->input('LocationId')!=null&&$request->input('LocationId')!="null"?'&locationId='.$request->input('LocationId'):"";$nonId=$request->input('nonAdminId')!=null&&$request->input('nonAdminId')!="null"?'&non_admin_id='.$request->input('nonAdminId'):"";$skip=$request->input('skip')!=null&&$request->input('skip')!="null"?'&skip='.$request->input('skip'):"";$searchText=$request->input('searhcText')!=null&&$request->input('searhcText')!="null"?'&search='.$request->input('searhcText'):"";$sortName=$request->input('sortName')!=null&&$request->input('sortName')!="null"?'&sortColumn='.$request->input('sortName'):"";$sortOrder=$request->input('sortOrder')!=null&&$request->input('sortOrder')!="null"?'&sortOrder='.$request->input('sortOrder'):"";$limit=$request->input('limit')!=null&&$request->input('limit')!="null"?'&limit='.$request->input('limit'):"";$api=$this->API_URL_3.'api/'.$this->VERSION_3.'/employee/attendance?date='.$date.$limit.$locId.$dptId.$skip.$searchText.$sortName.$sortOrder.$nonId;$response=$this->helper->postApiCall('get',$api,[]);return $this->helper->responseHandlerWithoutStatusCode($response);}catch(\GuzzleHttp\Exception\RequestException $e){return $this->helper->GuzzleHTTPException($e,"attendanceListEmployees");}return $result;}public function getEmployeeLocation(Request $request){try{$api_url=$this->API_URL_3.'api/'.$this->VERSION_3.'/location/get-geolocation?employee_id='.Session::get(env('Manager'))['token']['user_id'];try{$response=$this->helper->postApiCall('get',$api_url,[]);$location=[];if($response['code']==200){$location=$response['data'];}return view("User::emp_current_location")->with(['location'=>$location]);}catch(\GuzzleHttp\Exception\RequestException $e){return $this->helper->guzzleErrorHandler($e,' ProductivityComparisonController => getLocation => Method-get ');}}catch(\Exception $e){Log::info('Exception '.$e->getLine()."=> code =>".$e->getCode()." => message => ".$e->getMessage());}}public function licenseCountExceed(Request $request){$api_url=$this->helper->API_URL_3.'/user/fetch-users';$method='post';try{if(Session::has('leftOverLicenses')&&Session::get('leftOverLicenses')>=0)return redirect('admin/dashboard');if($request->isMethod('get')){$response=$this->helper->postApiCall($method,$api_url,[]);$result=$this->filter_fetchUsersApiData($response);return view('User::EmployeeDetail.licenseCountExceed')->with(['employees'=>$result]);}else if($request->isMethod('post')){$data['limit']=count($request->all())!=0?$request->input('SHOW_ENTRIES'):10;$data['skip']=count($request->all())!=0?$request->input('skip'):0;$data['name']=count($request->all())!=0?($request->input('SEARCH_TEXT')!=null?$request->input('SEARCH_TEXT'):""):"";if($request->input('SORT_NAME')!=''&&count($request->all())!=0){$data['sortColumn']=$request->input('SORT_NAME');$data['sortOrder']=$request->input('SORT_ORDER');}$response=$this->helper->postApiCall($method,$api_url,$data);return $this->filter_fetchUsersApiData($response);}}catch(\Exception $e){return $this->ExceptionErrorHandler($e,"400",' UserController => licenseCountExceed => Method-get');}}function filter_fetchUsersApiData($response){if($response['data']['code']==200){$result['code']=$response['data']['code'];$result['msg']=$response['data']['message'];$result['getData']=$response['data']['data'];$result['data']=$response['data']['data']['user_data'];}else{$result['code']=($response['data']['code']);$result['msg']=$response['data']['message'];$result['error']=$response['data']['error'];$result['data']=($response['data']['data']);}return $result;}
public function requestForAgentBuild(){$api=$this->API_URL_3.'api/'.$this->VERSION_3.'/build/create-build-trigger';try{$response=$this->helper->postApiCall("get",$api,[]);return $response;}catch(\Exception $e){return $this->ExceptionErrorHandler($e, 400,'UserController=>requestForAgentBuild=>Method-get');}}
}?>
Function Calls
None |
Stats
MD5 | a0f8a9b80cc5564ca733d9e639c9ba15 |
Eval Count | 0 |
Decode Time | 132 ms |