JFIFxxC      C  " }!1AQa"q2#BR$3br %&'()*456789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz w!1AQaq"2B #3RbrKernel.php000064400000005151150364311770006506 0ustar00 [ \App\Http\Middleware\EncryptCookies::class, \Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class, \Illuminate\Session\Middleware\StartSession::class, // \Illuminate\Session\Middleware\AuthenticateSession::class, \Illuminate\View\Middleware\ShareErrorsFromSession::class, \App\Http\Middleware\VerifyCsrfToken::class, \Illuminate\Routing\Middleware\SubstituteBindings::class, ], 'api' => [ // \Laravel\Sanctum\Http\Middleware\EnsureFrontendRequestsAreStateful::class, 'throttle:api', \Illuminate\Routing\Middleware\SubstituteBindings::class, ], ]; /** * The application's route middleware. * * These middleware may be assigned to groups or used individually. * * @var array */ protected $routeMiddleware = [ 'auth' => \App\Http\Middleware\Authenticate::class, 'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class, 'cache.headers' => \Illuminate\Http\Middleware\SetCacheHeaders::class, 'can' => \Illuminate\Auth\Middleware\Authorize::class, 'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class, 'password.confirm' => \Illuminate\Auth\Middleware\RequirePassword::class, 'signed' => \Illuminate\Routing\Middleware\ValidateSignature::class, 'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class, 'verified' => \Illuminate\Auth\Middleware\EnsureEmailIsVerified::class, 'XSS' => \App\Http\Middleware\XSS::class, 'CheckPlan' => \App\Http\Middleware\CheckPlan::class, 'Pusher' => \App\Http\Middleware\getPusherSettings::class ]; } Controllers/GoalTypeController.php000064400000007725150364311770013375 0ustar00can('Manage Goal Type')) { $goaltypes = GoalType::where('created_by', '=', \Auth::user()->creatorId())->get(); return view('goaltype.index', compact('goaltypes')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } public function create() { if(\Auth::user()->can('Create Goal Type')) { return view('goaltype.create'); } else { return redirect()->back()->with('error', __('Permission denied.')); } } public function store(Request $request) { if(\Auth::user()->can('Create Goal Type')) { $validator = \Validator::make( $request->all(), [ 'name' => 'required', ] ); if($validator->fails()) { $messages = $validator->getMessageBag(); return redirect()->back()->with('error', $messages->first()); } $goaltype = new GoalType(); $goaltype->name = $request->name; $goaltype->created_by = \Auth::user()->creatorId(); $goaltype->save(); return redirect()->route('goaltype.index')->with('success', __('GoalType successfully created.')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } public function show(GoalType $goalType) { // } public function edit($id) { if(\Auth::user()->can('Edit Goal Type')) { $goalType = GoalType::find($id); return view('goaltype.edit', compact('goalType')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } public function update(Request $request, $id) { if(\Auth::user()->can('Edit Goal Type')) { $validator = \Validator::make( $request->all(), [ 'name' => 'required', ] ); if($validator->fails()) { $messages = $validator->getMessageBag(); return redirect()->back()->with('error', $messages->first()); } $goalType = GoalType::find($id); $goalType->name = $request->name; $goalType->save(); return redirect()->route('goaltype.index')->with('success', __('GoalType successfully updated.')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } public function destroy($id) { if(\Auth::user()->can('Delete Goal Type')) { $goalType = GoalType::find($id); if($goalType->created_by == \Auth::user()->creatorId()) { $goalTrackings = GoalTracking::where('goal_type', $goalType->id)->get(); if(count($goalTrackings) == 0) { $goalType->delete(); }else{ return redirect()->route('goaltype.index')->with('error', __('This GoalType has Goal. Please remove the Goal from this GoalType.')); } return redirect()->route('goaltype.index')->with('success', __('GoalType successfully deleted.')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } else { return redirect()->back()->with('error', __('Permission denied.')); } } } Controllers/MeetingController.php000064400000032357150364311770013240 0ustar00can('Manage Meeting')) { $employees = Employee::get(); if (Auth::user()->type == 'employee') { $current_employee = Employee::where('user_id', '=', \Auth::user()->id)->first(); $meetings = LocalMeeting::orderBy('meetings.id', 'desc') ->leftjoin('meeting_employees', 'meetings.id', '=', 'meeting_employees.meeting_id') ->where('meeting_employees.employee_id', '=', $current_employee->id) ->orWhere(function ($q) { $q->where('meetings.department_id', '["0"]') ->where('meetings.employee_id', '["0"]'); }) ->get(); } else { $meetings = LocalMeeting::where('created_by', '=', \Auth::user()->creatorId())->get(); } return view('meeting.index', compact('meetings', 'employees')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } public function create() { if (\Auth::user()->can('Create Meeting')) { if (Auth::user()->type == 'employee') { $employees = Employee::where('created_by', '=', \Auth::user()->creatorId())->where('user_id', '!=', \Auth::user()->id)->get()->pluck('name', 'id'); } else { $branch = Branch::where('created_by', '=', \Auth::user()->creatorId())->get(); $departments = Department::where('created_by', '=', Auth::user()->creatorId())->get(); $employees = Employee::where('created_by', '=', \Auth::user()->creatorId())->get()->pluck('name', 'id'); } return view('meeting.create', compact('employees', 'departments', 'branch')); } else { return response()->json(['error' => __('Permission denied.')], 401); } } public function store(Request $request) { $validator = \Validator::make( $request->all(), [ 'branch_id' => 'required', 'department_id' => 'required', 'employee_id' => 'required', 'department_id' => 'required', 'title' => 'required', 'date' => 'required', 'time' => 'required', ] ); if ($validator->fails()) { $messages = $validator->getMessageBag(); return redirect()->back()->with('error', $messages->first()); } if (\Auth::user()->can('Create Meeting')) { $meeting = new LocalMeeting(); $meeting->branch_id = $request->branch_id; $meeting->department_id = json_encode($request->department_id); $meeting->employee_id = json_encode($request->employee_id); $meeting->title = $request->title; $meeting->date = $request->date; $meeting->time = $request->time; $meeting->note = $request->note; $meeting->created_by = \Auth::user()->creatorId(); $meeting->save(); // slack $setting = Utility::settings(\Auth::user()->creatorId()); $branch = Branch::find($request->branch_id); if (isset($setting['meeting_notification']) && $setting['meeting_notification'] == 1) { // $msg = $request->title . ' ' . __("meeting created for") . ' ' . $branch->name . ' ' . ("from") . ' ' . $request->date . ' ' . ("at") . ' ' . $request->time . '.'; $uArr = [ 'meeting_title' => $request->title, 'branch_name' => $branch->name, 'date' => $request->date, // 'time' => $request->time, 'time' => date('g:i A', strtotime($request->time)), ]; Utility::send_slack_msg('new_meeting', $uArr); } // telegram $setting = Utility::settings(\Auth::user()->creatorId()); $branch = Branch::find($request->branch_id); if (isset($setting['telegram_meeting_notification']) && $setting['telegram_meeting_notification'] == 1) { // $msg = $request->title . ' ' . __("meeting created for") . ' ' . $branch->name . ' ' . ("from") . ' ' . $request->date . ' ' . ("at") . ' ' . $request->time . '.'; $uArr = [ 'meeting_title' => $request->title, 'branch_name' => $branch->name, 'date' => $request->date, // 'time' => $request->time, 'time' => date('g:i A', strtotime($request->time)), ]; Utility::send_telegram_msg('new_meeting', $uArr); } if (in_array('0', $request->employee_id)) { $departmentEmployee = Employee::whereIn('department_id', $request->department_id)->get()->pluck('id'); $departmentEmployee = $departmentEmployee; } else { $departmentEmployee = $request->employee_id; } foreach ($departmentEmployee as $employee) { $meetingEmployee = new MeetingEmployee(); $meetingEmployee->meeting_id = $meeting->id; $meetingEmployee->employee_id = $employee; $meetingEmployee->created_by = \Auth::user()->creatorId(); $meetingEmployee->save(); } // google calendar if ($request->get('synchronize_type') == 'google_calender') { $type = 'meeting'; $request1 = new GoogleEvent(); $request1->title = $request->title; $request1->start_date = $request->date; $request1->time = $request->time; $request1->end_date = $request->date; Utility::addCalendarDataTime($request1, $type); } //webhook $module = 'New Meeting'; $webhook = Utility::webhookSetting($module); if ($webhook) { $parameter = json_encode($meeting); // 1 parameter is URL , 2 parameter is data , 3 parameter is method $status = Utility::WebhookCall($webhook['url'], $parameter, $webhook['method']); if ($status == true) { return redirect()->back()->with('success', __('Meeting successfully created.')); } else { return redirect()->back()->with('error', __('Webhook call failed.')); } } return redirect()->route('meeting.index')->with('success', __('Meeting successfully created.')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } public function show($id) { $meetings = LocalMeeting::where('id',$id)->first(); return view('meeting.show', compact('meetings')); // return redirect()->route('meeting.index'); } public function edit($meeting) { if (\Auth::user()->can('Edit Meeting')) { $meeting = LocalMeeting::find($meeting); if ($meeting->created_by == Auth::user()->creatorId()) { if (Auth::user()->type == 'employee') { $employees = Employee::where('created_by', '=', \Auth::user()->creatorId())->where('user_id', '!=', Auth::user()->id)->get()->pluck('name', 'id'); } else { $employees = Employee::where('created_by', \Auth::user()->creatorId())->get()->pluck('name', 'id'); } return view('meeting.edit', compact('meeting', 'employees')); } else { return response()->json(['error' => __('Permission denied.')], 401); } } else { return response()->json(['error' => __('Permission denied.')], 401); } } public function update(Request $request, LocalMeeting $meeting) { if (\Auth::user()->can('Edit Meeting')) { $validator = \Validator::make( $request->all(), [ 'title' => 'required', 'date' => 'required', 'time' => 'required', ] ); if ($validator->fails()) { $messages = $validator->getMessageBag(); return redirect()->back()->with('error', $messages->first()); } if ($meeting->created_by == \Auth::user()->creatorId()) { $meeting->title = $request->title; $meeting->date = $request->date; $meeting->time = $request->time; $meeting->note = $request->note; $meeting->save(); return redirect()->route('meeting.index')->with('success', __('Meeting successfully updated.')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } else { return redirect()->back()->with('error', __('Permission denied.')); } } public function destroy(LocalMeeting $meeting) { if (\Auth::user()->can('Delete Meeting')) { if ($meeting->created_by == \Auth::user()->creatorId()) { $meeting->delete(); return redirect()->route('meeting.index')->with('success', __('Meeting successfully deleted.')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } else { return redirect()->back()->with('error', __('Permission denied.')); } } public function getdepartment(Request $request) { if ($request->branch_id == 0) { $departments = Department::where('created_by', '=', \Auth::user()->creatorId())->get()->pluck('name', 'id')->toArray(); } else { $departments = Department::where('created_by', '=', \Auth::user()->creatorId())->where('branch_id', $request->branch_id)->get()->pluck('name', 'id')->toArray(); } return response()->json($departments); } public function getemployee(Request $request) { if ($request->department_id) { $employees = Employee::where('created_by', '=', \Auth::user()->creatorId())->whereIn('department_id', $request->department_id)->get()->pluck('name', 'id')->toArray(); } else { $employees = Employee::where('created_by', '=', \Auth::user()->creatorId())->get()->pluck('name', 'id')->toArray(); } return response()->json($employees); } public function calender() { $employees = Employee::get(); if (Auth::user()->type == 'employee') { $current_employee = Employee::where('user_id', '=', \Auth::user()->id)->first(); $meetings = LocalMeeting::orderBy('meetings.id', 'desc') ->leftjoin('meeting_employees', 'meetings.id', '=', 'meeting_employees.meeting_id') ->where('meeting_employees.employee_id', '=', $current_employee->id) ->orWhere(function ($q) { $q->where('meetings.department_id', '["0"]') ->where('meetings.employee_id', '["0"]'); }) ->get(); } else { $meetings = LocalMeeting::where('created_by', '=', \Auth::user()->creatorId())->get(); } return view('meeting.calender' , compact('meetings', 'employees')); } public function get_meeting_data(Request $request) { $arrayJson = []; if($request->get('calender_type') == 'google_calender') { $type ='meeting'; $arrayJson = Utility::getCalendarData($type); } else { $data = LocalMeeting::where('created_by', \Auth::user()->creatorId())->get(); foreach($data as $val) { if (Auth::user()->type == 'employee') { $url = route('meeting.show', $val['id']); }else{ $url = route('meeting.edit', $val['id']); } $end_date=date_create($val->end_date); date_add($end_date,date_interval_create_from_date_string("1 days")); $arrayJson[] = [ "id"=> $val->id, "title" => $val->title, "start" => $val->date, "end" => $val->date, "className" => $val->color, "allDay" => true, "textColor" => '#FFF', "url" => $url, ]; } } return $arrayJson; } } Controllers/SettingsController.php000064400000235572150364311770013454 0ustar00offerlangs) { $offerlang = $request->offerlangs; } else { $offerlang = "en"; } if ($request->joininglangs) { $joininglang = $request->joininglangs; } else { $joininglang = "en"; } if ($request->explangs) { $explang = $request->explangs; } else { $explang = "en"; } if ($request->noclangs) { $noclang = $request->noclangs; } else { $noclang = "en"; } $offerlangName = \App\Models\Languages::where('code', $offerlang)->first(); $joininglangName = \App\Models\Languages::where('code', $joininglang)->first(); $explangName = \App\Models\Languages::where('code', $explang)->first(); $noclangName = \App\Models\Languages::where('code', $noclang)->first(); $user = \Auth::user(); if (\Auth::user()->type == 'company' || \Auth::user()->type == 'super admin') { if ($user->type == 'super admin') { $settings = Utility::settings(); $admin_payment_setting = Utility::getAdminPaymentSetting(); // cache clear $file_size = 0; foreach (\File::allFiles(storage_path('/framework')) as $file) { $file_size += $file->getSize(); } $file_size = number_format($file_size / 1000000, 4); return view('setting.system_settings', compact('settings', 'admin_payment_setting', 'file_size')); } else { $timezones = config('timezones'); $settings = Utility::settings(); $EmailTemplates = EmailTemplate::all(); $ips = IpRestrict::where('created_by', \Auth::user()->creatorId())->get(); $webhooks = Webhook::where('created_by', \Auth::user()->creatorId())->get(); // $languages = Utility::languages(); //offer letter $Offerletter = GenerateOfferLetter::all(); $currOfferletterLang = GenerateOfferLetter::where('created_by', \Auth::user()->id)->where('lang', $offerlang)->first(); //joining letter $Joiningletter = JoiningLetter::all(); $currjoiningletterLang = JoiningLetter::where('created_by', \Auth::user()->id)->where('lang', $joininglang)->first(); //Experience Certificate $experience_certificate = ExperienceCertificate::all(); $curr_exp_cetificate_Lang = ExperienceCertificate::where('created_by', \Auth::user()->id)->where('lang', $explang)->first(); //NOC $noc_certificate = NOC::all(); $currnocLang = NOC::where('created_by', \Auth::user()->id)->where('lang', $noclang)->first(); return view('setting.company_settings', compact('settings', 'timezones', 'ips', 'EmailTemplates', 'currOfferletterLang', 'Offerletter', 'offerlang', 'Joiningletter', 'currjoiningletterLang', 'joininglang', 'experience_certificate', 'curr_exp_cetificate_Lang', 'explang', 'noc_certificate', 'currnocLang', 'noclang', 'webhooks', 'offerlangName', 'joininglangName', 'explangName', 'noclangName')); } } else { return redirect()->back()->with('error', __('Permission denied.')); } } public function store(Request $request) { if (\Auth::user()->type == 'company' || \Auth::user()->type == 'super admin') { if ($request->logo) { $request->validate( [ 'logo' => 'image|mimes:png|max:20480', ] ); $logoName = 'logo-dark.png'; $dir = 'uploads/logo/'; $validation = [ 'mimes:' . 'png', 'max:' . '20480', ]; $path = Utility::upload_file($request, 'logo', $logoName, $dir, $validation); if ($path['flag'] == 1) { $url = $path['url']; } else { return redirect()->back()->with('error', __($path['msg'])); } } if ($request->logo_light) { $request->validate(['logo_light' => 'required|image|mimes:png',]); // $smallName = 'logo-light.png'; // $path = $request->file('logo_light')->storeAs('uploads/logo/', $smallName); $logoName = 'logo-light.png'; $dir = 'uploads/logo/'; $validation = [ 'mimes:' . 'png', 'max:' . '20480', ]; $path = Utility::upload_file($request, 'logo_light', $logoName, $dir, $validation); if ($path['flag'] == 1) { $url = $path['url']; } else { return redirect()->back()->with('error', __($path['msg'])); } } if ($request->favicon) { $request->validate( [ 'favicon' => 'image|mimes:png' ] ); // $favicon = 'favicon.png'; // $path = $request->file('favicon')->storeAs('uploads/logo/', $favicon); $favicon = 'favicon.png'; $dir = 'uploads/logo/'; $validation = [ 'mimes:' . 'png', 'max:' . '20480', ]; $path = Utility::upload_file($request, 'favicon', $favicon, $dir, $validation); if ($path['flag'] == 1) { $url = $path['url']; } else { return redirect()->back()->with('error', __($path['msg'])); } } if (!empty($request->title_text) || !empty($request->footer_text) || !empty($request->default_language) || isset($request->display_landing_page) || isset($request->disable_signup_button) || !empty($request->theme_color) || !empty($request->cust_theme_bg) || !empty($request->cust_darklayout || !empty($request->email_verification))) { $post = $request->all(); if (!isset($request->display_landing_page)) { $post['display_landing_page'] = 'off'; } if (!isset($request->gdpr_cookie)) { $post['gdpr_cookie'] = 'off'; } if (!isset($request->disable_signup_button)) { $post['disable_signup_button'] = 'off'; } if (!isset($request->cust_darklayout)) { $post['cust_darklayout'] = 'off'; } if (!isset($request->cust_theme_bg)) { $post['cust_theme_bg'] = 'off'; } if (!isset($request->SITE_RTL)) { $post['SITE_RTL'] = 'off'; } if (!isset($request->email_verification)) { $post['email_verification'] = 'off'; } if (isset($request->theme_color) && $request->color_flag == 'false') { $post['theme_color'] = $request->theme_color; } else { $post['theme_color'] = $request->custom_color; } $settings = Utility::settings(); unset($post['_token'], $post['custom_color']); foreach ($post as $key => $data) { if (in_array($key, array_keys($settings)) && !empty($data)) { if (!empty($data)) { \DB::insert( 'insert into settings (`value`, `name`,`created_by`) values (?, ?, ?) ON DUPLICATE KEY UPDATE `value` = VALUES(`value`) ', [ $data, $key, \Auth::user()->creatorId(), ] ); } } } } return redirect()->back()->with('success', 'Setting successfully updated.'); } else { return redirect()->back()->with('error', __('Permission denied.')); } } public function saveEmailSettings(Request $request) { if (\Auth::user()->type == 'company' || \Auth::user()->type == 'super admin') { $request->validate( [ 'mail_driver' => 'required|string|max:255', 'mail_host' => 'required|string|max:255', 'mail_port' => 'required|string|max:255', 'mail_username' => 'required|string|max:255', 'mail_password' => 'required|string|max:255', 'mail_encryption' => 'required|string|max:255', 'mail_from_address' => 'required|string|max:255', 'mail_from_name' => 'required|string|max:255', ] ); if (\Auth::user()->type == 'company' || \Auth::user()->type == 'super admin') { $post = $request->all(); $settings = Utility::settings(); unset($post['_token']); foreach ($post as $key => $data) { if (in_array($key, array_keys($settings)) && !empty($data)) { if (!empty($data)) { \DB::insert( 'insert into settings (`value`, `name`,`created_by`) values (?, ?, ?) ON DUPLICATE KEY UPDATE `value` = VALUES(`value`) ', [ $data, $key, \Auth::user()->creatorId(), ] ); } } } return redirect()->back()->with('success', __('Setting successfully updated.')); } else { return redirect()->back()->with('error', 'Permission denied.'); } } else { return redirect()->back()->with('error', 'Permission denied.'); } } public function recaptchaSettingStore(Request $request) { if (\Auth::user()->type == 'super admin') { $user = \Auth::user(); $rules = []; if ($request->recaptcha_module == 'yes') { $validator = \Validator::make( $request->all(), [ 'recaptcha_module' => 'required', 'google_recaptcha_key' => 'required|string|max:50', 'google_recaptcha_secret' => 'required|string|max:50', 'google_recaptcha_version' => 'required', ] ); if ($validator->fails()) { $messages = $validator->getMessageBag(); return redirect()->back()->with('error', $messages->first()); } } $post = $request->all(); if (!isset($request->recaptcha_module)) { $post['recaptcha_module'] = 'no'; } unset($post['_token']); $settings = Utility::settings(); foreach ($post as $key => $data) { if (in_array($key, array_keys($settings)) && !empty($data)) { \DB::insert( 'insert into settings (`value`, `name`,`created_by`,`created_at`,`updated_at`) values (?, ?, ?, ?, ?) ON DUPLICATE KEY UPDATE `value` = VALUES(`value`) ', [ $data, $key, \Auth::user()->creatorId(), date('Y-m-d H:i:s'), date('Y-m-d H:i:s'), ] ); } } return redirect()->back()->with('success', __('Recaptcha Settings updated successfully')); } else { return redirect()->back()->with('error', __('Something is wrong')); } } public function savePaymentSettings(Request $request) { if (\Auth::user()->type == 'company' || \Auth::user()->type == 'super admin') { $request->validate( [ 'currency' => 'required|string|max:255', 'currency_symbol' => 'required|string|max:255', ] ); self::adminPaymentSettings($request); return redirect()->back()->with('success', __('Payment successfully updated.')); } else { return redirect()->back()->with('error', 'Permission denied.'); } } public function companyIndex() { if (\Auth::user()->type == 'company' || \Auth::user()->type == 'super admin') { $settings = Utility::settings(); return view('settings.company_settings', compact('settings', 'ips')); } else { return redirect()->back()->with('error', 'Permission denied.'); } } public function saveCompanySettings(Request $request) { if (\Auth::user()->type == 'company' || \Auth::user()->type == 'super admin') { $user = \Auth::user(); $request->validate( [ 'company_name' => 'required|string|max:255', 'company_address' => 'required', 'company_city' => 'required', 'company_state' => 'required', 'company_zipcode' => 'required', 'company_country' => 'required', 'company_telephone' => 'required', 'company_start_time' => 'required', 'company_end_time' => 'required', 'timezone' => 'required', // 'company_email' => 'required', // 'company_email_from_name' => 'required|string', ] ); $post = $request->all(); if (!isset($request->ip_restrict)) { $post['ip_restrict'] = 'off'; } unset($post['_token']); $settings = Utility::settings(); foreach ($post as $key => $data) { if ((in_array($key, array_keys($settings)) && $data !== null)) { \DB::insert( 'insert into settings (`value`, `name`,`created_by`) values (?, ?, ?) ON DUPLICATE KEY UPDATE `value` = VALUES(`value`) ', [ // $settings, $data, $key, \Auth::user()->creatorId(), ] ); } } return redirect()->back()->with('success', __('Setting successfully updated.')); } else { return redirect()->back()->with('error', 'Permission denied.'); } } public function saveSystemSettings(Request $request) { if (\Auth::user()->type == 'company' || \Auth::user()->type == 'super admin') { $user = \Auth::user(); $request->validate( [ 'site_currency' => 'required', ] ); $post = $request->all(); unset($post['_token']); $settings = Utility::settings(); foreach ($post as $key => $data) { if (in_array($key, array_keys($settings)) && !empty($data)) { \DB::insert( 'insert into settings (`value`, `name`,`created_by`,`created_at`,`updated_at`) values (?, ?, ?, ?, ?) ON DUPLICATE KEY UPDATE `value` = VALUES(`value`) ', [ $data, $key, \Auth::user()->creatorId(), date('Y-m-d H:i:s'), date('Y-m-d H:i:s'), ] ); } } return redirect()->back()->with('success', __('Setting successfully updated.')); } else { return redirect()->back()->with('error', 'Permission denied.'); } } public function saveGoogleCalenderSettings(Request $request) { if (isset($request->is_enabled) && $request->is_enabled == 'on') { $validator = \Validator::make( $request->all(), [ // 'google_calender_id' => 'required', // 'google_calender_json_file' => 'required', ] ); if ($validator->fails()) { $messages = $validator->getMessageBag(); return redirect()->back()->with('error', $messages->first()); } $post['is_enabled'] = $request->is_enabled; } else { $post['is_enabled'] = 'off'; } if ($request->google_calender_json_file) { // $dir = storage_path() . '/app/google-calendar'; $dir = storage_path() . '/' . md5(time()); if (!is_dir($dir)) { File::makeDirectory($dir, $mode = 0777, true, true); } $file_name = $request->google_calender_json_file->getClientOriginalName(); // $file_path = md5(time()) . "." . $request->google_calender_json_file->getClientOriginalExtension(); $file_path = md5(time()) . "/" . md5(time()) . "." . $request->google_calender_json_file->getClientOriginalExtension(); $file = $request->file('google_calender_json_file'); $file->move($dir, $file_path); $post['google_calender_json_file'] = $file_path; } if ($request->google_clender_id) { $post['google_clender_id'] = $request->google_clender_id; foreach ($post as $key => $data) { \DB::insert( 'insert into settings (`value`, `name`,`created_by`,`created_at`,`updated_at`) values (?, ?, ?, ?, ?) ON DUPLICATE KEY UPDATE `value` = VALUES(`value`) ', [ $data, $key, \Auth::user()->creatorId(), date('Y-m-d H:i:s'), date('Y-m-d H:i:s'), ] ); } } return redirect()->back()->with('success', 'Storage setting successfully updated.'); } public function SeoSettings(Request $request) { $validator = \Validator::make( $request->all(), [ 'meta_title' => 'required|string', 'meta_description' => 'required|string', 'meta_image' => 'required|file', ] ); if ($validator->fails()) { $messages = $validator->getMessageBag(); return redirect()->back()->with('error', $messages->first()); } $dir = storage_path() . '/uploads' . '/meta'; if (!is_dir($dir)) { File::makeDirectory($dir, $mode = 0777, true, true); } $file_name = $request->meta_image->getClientOriginalName(); $file_path = $request->meta_image->getClientOriginalName(); $file = $request->file('meta_image'); $file->move($dir, $file_path); $post['meta_title'] = $request->meta_title; $post['meta_description'] = $request->meta_description; $post['meta_image'] = $file_path; foreach ($post as $key => $data) { \DB::insert( 'insert into settings (`value`, `name`,`created_by`,`created_at`,`updated_at`) values (?, ?, ?, ?, ?) ON DUPLICATE KEY UPDATE `value` = VALUES(`value`) ', [ $data, $key, \Auth::user()->id, date('Y-m-d H:i:s'), date('Y-m-d H:i:s'), ] ); } return redirect()->back()->with('success', 'SEO setting successfully save.'); } public function zoomSetting(request $request) { if (\Auth::user()->type == 'company') { if (!empty($request->zoom_account_id) || !empty($request->zoom_client_id) || !empty($request->zoom_client_secret)) { $post = $request->all(); $settings = Utility::settings(); foreach ($post as $key => $data) { if (in_array($key, array_keys($settings)) && !empty($data)) { \DB::insert( 'insert into settings (`value`, `name`,`created_by`) values (?, ?, ?) ON DUPLICATE KEY UPDATE `value` = VALUES(`value`) ', [ $data, $key, \Auth::user()->creatorId(), ] ); } } } } return redirect()->back()->with('success', __('Zoom key succesfully added .')); } public function updateEmailStatus($name) { if (\Auth::user()->type == 'company' || \Auth::user()->type == 'super admin') { $emailNotification = \DB::table('settings')->where('name', '=', $name)->where('created_by', \Auth::user()->creatorId())->first(); if (empty($emailNotification)) { \DB::insert( 'insert into settings (`value`, `name`,`created_by`,`created_at`,`updated_at`) values (?, ?, ?, ?, ?) ON DUPLICATE KEY UPDATE `value` = VALUES(`value`) ', [ 0, $name, \Auth::user()->creatorId(), date('Y-m-d H:i:s'), date('Y-m-d H:i:s'), ] ); } else { if ($emailNotification->value == 1) { $affected = \DB::table('settings')->where('name', $name)->update(['value' => 0]); } else { $affected = \DB::table('settings')->where('name', $name)->update(['value' => 1]); } } } else { return redirect()->back()->with('error', 'Permission denied.'); } } public function savePusherSettings(Request $request) { if (\Auth::user()->type == 'company' || \Auth::user()->type == 'super admin') { $user = \Auth::user(); $request->validate( [ 'pusher_app_id' => 'required', 'pusher_app_key' => 'required', 'pusher_app_secret' => 'required', 'pusher_app_cluster' => 'required', ] ); $post = $request->all(); unset($post['_token']); $settings = Utility::settings(); foreach ($post as $key => $data) { if (in_array($key, array_keys($settings)) && !empty($data)) { \DB::insert( 'insert into settings (`value`, `name`,`created_by`,`created_at`,`updated_at`) values (?, ?, ?, ?, ?) ON DUPLICATE KEY UPDATE `value` = VALUES(`value`) ', [ $data, $key, \Auth::user()->creatorId(), date('Y-m-d H:i:s'), date('Y-m-d H:i:s'), ] ); } } return redirect()->back()->with('success', __('Pusher successfully updated.')); } else { return redirect()->back()->with('error', 'Permission denied.'); } } public function saveBusinessSettings(Request $request) { if (\Auth::user()->type == 'company' || \Auth::user()->type == 'super admin') { $user = \Auth::user(); if ($request->company_logo) { $request->validate( [ 'company_logo' => 'image|mimes:png|max:20480', ] ); $logoName = $user->id . '_dark_logo.png'; $dir = 'uploads/logo/'; $validation = [ 'mimes:' . 'png', 'max:' . '20480', ]; $path = Utility::upload_file($request, 'company_logo', $logoName, $dir, $validation); if ($path['flag'] == 1) { $url = $path['url']; } else { return redirect()->back()->with('error', __($path['msg'])); } \DB::insert( 'insert into settings (`value`, `name`,`created_by`) values (?, ?, ?) ON DUPLICATE KEY UPDATE `value` = VALUES(`value`) ', [ $logoName, 'company_logo', \Auth::user()->creatorId(), ] ); } if ($request->company_logo_light) { $request->validate( [ 'company_logo_light' => 'image|mimes:png|max:20480', ] ); $logoName = $user->id . '_light_logo.png'; $dir = 'uploads/logo/'; $validation = [ 'mimes:' . 'png', 'max:' . '20480', ]; $path = Utility::upload_file($request, 'company_logo_light', $logoName, $dir, $validation); // $company_logo_light = !empty($request->company_logo_light) ? $logoName : 'logo-light.png'; \DB::insert( 'insert into settings (`value`, `name`,`created_by`) values (?, ?, ?) ON DUPLICATE KEY UPDATE `value` = VALUES(`value`) ', [ $logoName, 'company_logo_light', \Auth::user()->creatorId(), ] ); if ($path['flag'] == 1) { $url = $path['url']; } else { return redirect()->back()->with('error', __($path['msg'])); } } if ($request->company_favicon) { $request->validate( [ 'company_favicon' => 'image|mimes:png|max:20480', ] ); $favicon = $user->id . '_favicon.png'; $dir = 'uploads/logo/'; $validation = [ 'mimes:' . 'png', 'max:' . '20480', ]; $path = Utility::upload_file($request, 'company_favicon', $favicon, $dir, $validation); $company_favicon = !empty($request->company_favicon) ? $favicon : 'favicon.png'; \DB::insert( 'insert into settings (`value`, `name`,`created_by`) values (?, ?, ?) ON DUPLICATE KEY UPDATE `value` = VALUES(`value`) ', [ $favicon, 'company_favicon', \Auth::user()->creatorId(), ] ); if ($path['flag'] == 1) { $url = $path['url']; } else { return redirect()->back()->with('error', __($path['msg'])); } } if (!empty($request->title_text) || !empty($request->metakeyword) || !empty($request->metadesc) || !empty($request->theme_color) || !empty($request->cust_theme_bg) || !empty($request->cust_darklayout) || !empty($request->SITE_RTL)) { $post = $request->all(); if (!isset($request->cust_darklayout)) { $post['cust_darklayout'] = 'off'; } if (!isset($request->cust_theme_bg)) { $post['cust_theme_bg'] = 'off'; } if (!isset($request->SITE_RTL)) { $post['SITE_RTL'] = 'off'; } if (isset($request->theme_color) && $request->color_flag == 'false') { $post['theme_color'] = $request->theme_color; } else { $post['theme_color'] = $request->custom_color; } $settings = Utility::settings(); unset($post['_token'], $post['company_logo'], $post['company_small_logo'], $post['company_logo_light'], $post['company_favicon'], $post['custom_color']); $settings = Utility::settings(); foreach ($post as $key => $data) { if (in_array($key, array_keys($settings)) && !empty($data)) { \DB::insert( 'insert into settings (`value`, `name`,`created_by`) values (?, ?, ?) ON DUPLICATE KEY UPDATE `value` = VALUES(`value`) ', [ $data, $key, \Auth::user()->creatorId(), ] ); } } } return redirect()->back()->with('success', 'Setting successfully updated.'); } else { return redirect()->back()->with('error', 'Permission denied.'); } } public function slack(Request $request) { $post = []; $post['slack_webhook'] = $request->input('slack_webhook'); $post['monthly_payslip_notification'] = $request->has('monthly_payslip_notification') ? $request->input('monthly_payslip_notification') : 0; $post['award_notification'] = $request->has('award_notification') ? $request->input('award_notification') : 0; $post['Announcement_notification'] = $request->has('Announcement_notification') ? $request->input('Announcement_notification') : 0; $post['Holiday_notification'] = $request->has('Holiday_notification') ? $request->input('Holiday_notification') : 0; $post['ticket_notification'] = $request->has('ticket_notification') ? $request->input('ticket_notification') : 0; $post['event_notification'] = $request->has('event_notification') ? $request->input('event_notification') : 0; $post['meeting_notification'] = $request->has('meeting_notification') ? $request->input('meeting_notification') : 0; $post['company_policy_notification'] = $request->has('company_policy_notification') ? $request->input('company_policy_notification') : 0; $post['contract_notification'] = $request->has('contract_notification') ? $request->input('contract_notification') : 0; if (isset($post) && !empty($post) && count($post) > 0) { $created_at = $updated_at = date('Y-m-d H:i:s'); foreach ($post as $key => $data) { DB::insert( 'INSERT INTO settings (`value`, `name`,`created_by`,`created_at`,`updated_at`) values (?, ?, ?, ?, ?) ON DUPLICATE KEY UPDATE `value` = VALUES(`value`), `updated_at` = VALUES(`updated_at`) ', [ $data, $key, Auth::user()->id, $created_at, $updated_at, ] ); } } return redirect()->back()->with('success', __('Settings updated successfully.')); } public function telegram(Request $request) { $post = []; $post['telegram_accestoken'] = $request->input('telegram_accestoken'); $post['telegram_chatid'] = $request->input('telegram_chatid'); $post['telegram_monthly_payslip_notification'] = $request->has('telegram_monthly_payslip_notification') ? $request->input('telegram_monthly_payslip_notification') : 0; $post['telegram_award_notification'] = $request->has('telegram_award_notification') ? $request->input('telegram_award_notification') : 0; $post['telegram_Announcement_notification'] = $request->has('telegram_Announcement_notification') ? $request->input('telegram_Announcement_notification') : 0; $post['telegram_Holiday_notification'] = $request->has('telegram_Holiday_notification') ? $request->input('telegram_Holiday_notification') : 0; $post['telegram_ticket_notification'] = $request->has('telegram_ticket_notification') ? $request->input('telegram_ticket_notification') : 0; $post['telegram_event_notification'] = $request->has('telegram_event_notification') ? $request->input('telegram_event_notification') : 0; $post['telegram_meeting_notification'] = $request->has('telegram_meeting_notification') ? $request->input('telegram_meeting_notification') : 0; $post['telegram_company_policy_notification'] = $request->has('telegram_company_policy_notification') ? $request->input('telegram_company_policy_notification') : 0; $post['telegram_contract_notification'] = $request->has('telegram_contract_notification') ? $request->input('telegram_contract_notification') : 0; if (isset($post) && !empty($post) && count($post) > 0) { $created_at = $updated_at = date('Y-m-d H:i:s'); foreach ($post as $key => $data) { DB::insert( 'INSERT INTO settings (`value`, `name`,`created_by`,`created_at`,`updated_at`) values (?, ?, ?, ?, ?) ON DUPLICATE KEY UPDATE `value` = VALUES(`value`), `updated_at` = VALUES(`updated_at`) ', [ $data, $key, Auth::user()->id, $created_at, $updated_at, ] ); } } return redirect()->back()->with('success', __('Settings updated successfully.')); } public function twilio(Request $request) { $post = []; $post['twilio_sid'] = $request->input('twilio_sid'); $post['twilio_token'] = $request->input('twilio_token'); $post['twilio_from'] = $request->input('twilio_from'); $post['twilio_monthly_payslip_notification'] = $request->has('twilio_monthly_payslip_notification') ? $request->input('twilio_monthly_payslip_notification') : 0; $post['twilio_leave_approve_notification'] = $request->has('twilio_leave_approve_notification') ? $request->input('twilio_leave_approve_notification') : 0; $post['twilio_award_notification'] = $request->has('twilio_award_notification') ? $request->input('twilio_award_notification') : 0; $post['twilio_trip_notification'] = $request->has('twilio_trip_notification') ? $request->input('twilio_trip_notification') : 0; $post['twilio_announcement_notification'] = $request->has('twilio_announcement_notification') ? $request->input('twilio_announcement_notification') : 0; $post['twilio_ticket_notification'] = $request->has('twilio_ticket_notification') ? $request->input('twilio_ticket_notification') : 0; $post['twilio_event_notification'] = $request->has('twilio_event_notification') ? $request->input('twilio_event_notification') : 0; if (isset($post) && !empty($post) && count($post) > 0) { $created_at = $updated_at = date('Y-m-d H:i:s'); foreach ($post as $key => $data) { DB::insert( 'INSERT INTO settings (`value`, `name`,`created_by`,`created_at`,`updated_at`) values (?, ?, ?, ?, ?) ON DUPLICATE KEY UPDATE `value` = VALUES(`value`), `updated_at` = VALUES(`updated_at`) ', [ $data, $key, Auth::user()->id, $created_at, $updated_at, ] ); } } return redirect()->back()->with('success', __('Settings updated successfully.')); } public function testMail(Request $request) { $user = \Auth::user(); // if($user->can('manage-setting')) // { $data = []; $data['mail_driver'] = $request->mail_driver; $data['mail_host'] = $request->mail_host; $data['mail_port'] = $request->mail_port; $data['mail_username'] = $request->mail_username; $data['mail_password'] = $request->mail_password; $data['mail_encryption'] = $request->mail_encryption; $data['mail_from_address'] = $request->mail_from_address; $data['mail_from_name'] = $request->mail_from_name; return view('setting.test_mail', compact('data')); // } // else // { // return response()->json(['error' => __('Permission Denied.')], 401); // } // return view('setting.test_mail'); } public function testSendMail(Request $request) { $validator = \Validator::make( $request->all(), [ 'email' => 'required|email', 'mail_driver' => 'required', 'mail_host' => 'required', 'mail_port' => 'required', 'mail_username' => 'required', 'mail_password' => 'required', 'mail_from_address' => 'required', 'mail_from_name' => 'required', ] ); if ($validator->fails()) { $messages = $validator->getMessageBag(); return response()->json( [ 'is_success' => false, 'message' => $messages->first(), ] ); } try { config( [ 'mail.driver' => $request->mail_driver, 'mail.host' => $request->mail_host, 'mail.port' => $request->mail_port, 'mail.encryption' => $request->mail_encryption, 'mail.username' => $request->mail_username, 'mail.password' => $request->mail_password, 'mail.from.address' => $request->mail_from_address, 'mail.from.name' => $request->mail_from_name, ] ); Mail::to($request->email)->send(new TestMail()); } catch (\Exception $e) { return response()->json( [ 'is_success' => false, 'message' => $e->getMessage(), ] ); } return response()->json( [ 'is_success' => true, 'message' => __('Email send Successfully'), ] ); } public function createIp() { return view('restrict_ip.create'); } public function storeIp(Request $request) { if (\Auth::user()->can('Manage Company Settings')) { $validator = \Validator::make( $request->all(), [ 'ip' => 'required', ] ); if ($validator->fails()) { $messages = $validator->getMessageBag(); return redirect()->back()->with('error', $messages->first()); } $ip = new IpRestrict(); $ip->ip = $request->ip; $ip->created_by = \Auth::user()->creatorId(); $ip->save(); return redirect()->back()->with('success', __('IP successfully created.')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } public function editIp($id) { $ip = IpRestrict::find($id); return view('restrict_ip.edit', compact('ip')); } public function updateIp(Request $request, $id) { if (\Auth::user()->type == 'company' || \Auth::user()->type == 'super admin') { $validator = \Validator::make( $request->all(), [ 'ip' => 'required', ] ); if ($validator->fails()) { $messages = $validator->getMessageBag(); return redirect()->back()->with('error', $messages->first()); } $ip = IpRestrict::find($id); $ip->ip = $request->ip; $ip->save(); return redirect()->back()->with('success', __('IP successfully updated.')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } public function destroyIp($id) { if (\Auth::user()->type == 'company' || \Auth::user()->type == 'super admin') { $ip = IpRestrict::find($id); $ip->delete(); return redirect()->back()->with('success', __('IP successfully deleted.')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } public function createWebhook() { if (\Auth::user()->can('Create Webhook')) { $modules = Webhook::$modules; $methods = Webhook::$methods; return view('webhook_settings.create', compact('modules', 'methods')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } public function storeWebhook(Request $request) { if (\Auth::user()->can('Create Webhook')) { $validator = \Validator::make( $request->all(), [ 'module' => 'required', 'method' => 'required', 'url' => 'required', ] ); if ($validator->fails()) { $messages = $validator->getMessageBag(); return redirect()->back()->with('error', $messages->first()); } $webhook = new Webhook(); $webhook->module = $request->module; $webhook->method = $request->method; $webhook->url = $request->url; $webhook->created_by = \Auth::user()->creatorId(); $webhook->save(); return redirect()->back()->with('success', __('Webhook successfully created.')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } public function editWebhook($id) { if (\Auth::user()->can('Edit Webhook')) { $webhook = Webhook::find($id); $modules = Webhook::$modules; $methods = Webhook::$methods; return view('webhook_settings.edit', compact('webhook', 'modules', 'methods')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } public function updateWebhook(Request $request, $id) { if (\Auth::user()->can('Edit Webhook')) { $validator = \Validator::make( $request->all(), [ 'module' => 'required', 'method' => 'required', 'url' => 'required', ] ); if ($validator->fails()) { $messages = $validator->getMessageBag(); return redirect()->back()->with('error', $messages->first()); } $webhook = Webhook::find($id); $webhook->module = $request->module; $webhook->method = $request->method; $webhook->url = $request->url; $webhook->save(); return redirect()->back()->with('success', __('Webhook successfully updated.')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } public function destroyWebhook($id) { if (\Auth::user()->can('Delete Webhook')) { $webhook = Webhook::find($id); $webhook->delete(); return redirect()->back()->with('success', __('Webhook successfully deleted.')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } public function adminPaymentSettings($request) { if (isset($request->currency) && isset($request->currency_symbol)) { $request->validate( [ 'currency' => 'required|string|max:255', 'currency_symbol' => 'required|string|max:255', ] ); $post['currency'] = $request->currency; $post['currency_symbol'] = $request->currency_symbol; } else { $post['currency'] = 'USD'; $post['currency_symbol'] = '$'; } if (isset($request->is_manually_enabled) && $request->is_manually_enabled == 'on') { $post['is_manually_enabled'] = $request->is_manually_enabled; } else { $post['is_manually_enabled'] = 'off'; } if (isset($request->is_banktransfer_enabled) && $request->is_banktransfer_enabled == 'on') { $request->validate( [ 'bank_details' => 'required', ] ); $post['is_banktransfer_enabled'] = $request->is_banktransfer_enabled; $post['bank_details'] = $request->bank_details; } else { $post['is_banktransfer_enabled'] = 'off'; } if (isset($request->is_stripe_enabled) && $request->is_stripe_enabled == 'on') { $request->validate( [ 'stripe_key' => 'required|string|max:255', 'stripe_secret' => 'required|string|max:255', ] ); $post['is_stripe_enabled'] = $request->is_stripe_enabled; $post['stripe_secret'] = $request->stripe_secret; $post['stripe_key'] = $request->stripe_key; } else { $post['is_stripe_enabled'] = 'off'; } if (isset($request->is_paypal_enabled) && $request->is_paypal_enabled == 'on') { $request->validate( [ 'paypal_mode' => 'required', 'paypal_client_id' => 'required', 'paypal_secret_key' => 'required', ] ); $post['is_paypal_enabled'] = $request->is_paypal_enabled; $post['paypal_mode'] = $request->paypal_mode; $post['paypal_client_id'] = $request->paypal_client_id; $post['paypal_secret_key'] = $request->paypal_secret_key; } else { $post['is_paypal_enabled'] = 'off'; } if (isset($request->is_paystack_enabled) && $request->is_paystack_enabled == 'on') { $request->validate( [ 'paystack_public_key' => 'required|string', 'paystack_secret_key' => 'required|string', ] ); $post['is_paystack_enabled'] = $request->is_paystack_enabled; $post['paystack_public_key'] = $request->paystack_public_key; $post['paystack_secret_key'] = $request->paystack_secret_key; } else { $post['is_paystack_enabled'] = 'off'; } if (isset($request->is_flutterwave_enabled) && $request->is_flutterwave_enabled == 'on') { $request->validate( [ 'flutterwave_public_key' => 'required|string', 'flutterwave_secret_key' => 'required|string', ] ); $post['is_flutterwave_enabled'] = $request->is_flutterwave_enabled; $post['flutterwave_public_key'] = $request->flutterwave_public_key; $post['flutterwave_secret_key'] = $request->flutterwave_secret_key; } else { $post['is_flutterwave_enabled'] = 'off'; } if (isset($request->is_razorpay_enabled) && $request->is_razorpay_enabled == 'on') { $request->validate( [ 'razorpay_public_key' => 'required|string', 'razorpay_secret_key' => 'required|string', ] ); $post['is_razorpay_enabled'] = $request->is_razorpay_enabled; $post['razorpay_public_key'] = $request->razorpay_public_key; $post['razorpay_secret_key'] = $request->razorpay_secret_key; } else { $post['is_razorpay_enabled'] = 'off'; } if (isset($request->is_mercado_enabled) && $request->is_mercado_enabled == 'on') { $request->validate( [ 'mercado_mode' => 'required', 'mercado_access_token' => 'required|string', ] ); $post['is_mercado_enabled'] = $request->is_mercado_enabled; $post['mercado_mode'] = $request->mercado_mode; $post['mercado_access_token'] = $request->mercado_access_token; } else { $post['is_mercado_enabled'] = 'off'; } if (isset($request->is_paytm_enabled) && $request->is_paytm_enabled == 'on') { $request->validate( [ 'paytm_mode' => 'required', 'paytm_merchant_id' => 'required|string', 'paytm_merchant_key' => 'required|string', 'paytm_industry_type' => 'required|string', ] ); $post['is_paytm_enabled'] = $request->is_paytm_enabled; $post['paytm_mode'] = $request->paytm_mode; $post['paytm_merchant_id'] = $request->paytm_merchant_id; $post['paytm_merchant_key'] = $request->paytm_merchant_key; $post['paytm_industry_type'] = $request->paytm_industry_type; } else { $post['is_paytm_enabled'] = 'off'; } if (isset($request->is_mollie_enabled) && $request->is_mollie_enabled == 'on') { $request->validate( [ 'mollie_api_key' => 'required|string', 'mollie_profile_id' => 'required|string', 'mollie_partner_id' => 'required', ] ); $post['is_mollie_enabled'] = $request->is_mollie_enabled; $post['mollie_api_key'] = $request->mollie_api_key; $post['mollie_profile_id'] = $request->mollie_profile_id; $post['mollie_partner_id'] = $request->mollie_partner_id; } else { $post['is_mollie_enabled'] = 'off'; } if (isset($request->is_skrill_enabled) && $request->is_skrill_enabled == 'on') { $request->validate( [ 'skrill_email' => 'required|email', ] ); $post['is_skrill_enabled'] = $request->is_skrill_enabled; $post['skrill_email'] = $request->skrill_email; } else { $post['is_skrill_enabled'] = 'off'; } if (isset($request->is_coingate_enabled) && $request->is_coingate_enabled == 'on') { $request->validate( [ 'coingate_mode' => 'required|string', 'coingate_auth_token' => 'required|string', ] ); $post['is_coingate_enabled'] = $request->is_coingate_enabled; $post['coingate_mode'] = $request->coingate_mode; $post['coingate_auth_token'] = $request->coingate_auth_token; } else { $post['is_coingate_enabled'] = 'off'; } if (isset($request->is_paymentwall_enabled) && $request->is_paymentwall_enabled == 'on') { $request->validate( [ 'paymentwall_public_key' => 'required|string', 'paymentwall_secret_key' => 'required|string', ] ); $post['is_paymentwall_enabled'] = $request->is_paymentwall_enabled; $post['paymentwall_public_key'] = $request->paymentwall_public_key; $post['paymentwall_secret_key'] = $request->paymentwall_secret_key; } else { $post['is_paymentwall_enabled'] = 'off'; } if (isset($request->is_toyyibpay_enabled) && $request->is_toyyibpay_enabled == 'on') { $request->validate( [ 'toyyibpay_category_code' => 'required|string', 'toyyibpay_secret_key' => 'required|string', ] ); $post['is_toyyibpay_enabled'] = $request->is_toyyibpay_enabled; $post['toyyibpay_category_code'] = $request->toyyibpay_category_code; $post['toyyibpay_secret_key'] = $request->toyyibpay_secret_key; } else { $post['is_toyyibpay_enabled'] = 'off'; } if (isset($request->is_payfast_enabled) && $request->is_payfast_enabled == 'on') { $request->validate( [ 'payfast_mode' => 'required', 'payfast_merchant_id' => 'required|string', 'payfast_merchant_key' => 'required|string', 'payfast_signature' => 'required|string', ] ); $post['is_payfast_enabled'] = $request->is_payfast_enabled; $post['payfast_mode'] = $request->payfast_mode; $post['payfast_merchant_id'] = $request->payfast_merchant_id; $post['payfast_merchant_key'] = $request->payfast_merchant_key; $post['payfast_signature'] = $request->payfast_signature; } else { $post['is_payfast_enabled'] = 'off'; } if (isset($request->is_iyzipay_enabled) && $request->is_iyzipay_enabled == 'on') { $request->validate( [ 'iyzipay_mode' => 'required', 'iyzipay_public_key' => 'required|string', 'iyzipay_secret_key' => 'required|string', ] ); $post['is_iyzipay_enabled'] = $request->is_iyzipay_enabled; $post['iyzipay_mode'] = $request->iyzipay_mode; $post['iyzipay_public_key'] = $request->iyzipay_public_key; $post['iyzipay_secret_key'] = $request->iyzipay_secret_key; } else { $post['is_iyzipay_enabled'] = 'off'; } if (isset($request->is_sspay_enabled) && $request->is_sspay_enabled == 'on') { $request->validate( [ 'sspay_category_code' => 'required|string', 'sspay_secret_key' => 'required|string', ] ); $post['is_sspay_enabled'] = $request->is_sspay_enabled; $post['sspay_category_code'] = $request->sspay_category_code; $post['sspay_secret_key'] = $request->sspay_secret_key; } else { $post['is_sspay_enabled'] = 'off'; } if (isset($request->is_paytab_enabled) && $request->is_paytab_enabled == 'on') { $request->validate( [ 'paytab_profile_id' => 'required|string', 'paytab_server_key' => 'required|string', 'paytab_region' => 'required|string', ] ); $post['is_paytab_enabled'] = $request->is_paytab_enabled; $post['paytab_profile_id'] = $request->paytab_profile_id; $post['paytab_server_key'] = $request->paytab_server_key; $post['paytab_region'] = $request->paytab_region; } else { $post['is_paytab_enabled'] = 'off'; } if (isset($request->is_benefit_enabled) && $request->is_benefit_enabled == 'on') { $request->validate( [ 'benefit_api_key' => 'required|string', 'benefit_secret_key' => 'required|string', ] ); $post['is_benefit_enabled'] = $request->is_benefit_enabled; $post['benefit_api_key'] = $request->benefit_api_key; $post['benefit_secret_key'] = $request->benefit_secret_key; } else { $post['is_benefit_enabled'] = 'off'; } if (isset($request->is_cashfree_enabled) && $request->is_cashfree_enabled == 'on') { $request->validate( [ 'cashfree_api_key' => 'required|string', 'cashfree_secret_key' => 'required|string', ] ); $post['is_cashfree_enabled'] = $request->is_cashfree_enabled; $post['cashfree_api_key'] = $request->cashfree_api_key; $post['cashfree_secret_key'] = $request->cashfree_secret_key; } else { $post['is_cashfree_enabled'] = 'off'; } if (isset($request->is_aamarpay_enabled) && $request->is_aamarpay_enabled == 'on') { $request->validate( [ 'aamarpay_store_id' => 'required|string', 'aamarpay_signature_key' => 'required|string', 'aamarpay_description' => 'required|string', ] ); $post['is_aamarpay_enabled'] = $request->is_aamarpay_enabled; $post['aamarpay_store_id'] = $request->aamarpay_store_id; $post['aamarpay_signature_key'] = $request->aamarpay_signature_key; $post['aamarpay_description'] = $request->aamarpay_description; } else { $post['is_aamarpay_enabled'] = 'off'; } if (isset($request->is_paytr_enabled) && $request->is_paytr_enabled == 'on') { $request->validate( [ 'paytr_merchant_id' => 'required|string', 'paytr_merchant_key' => 'required|string', 'paytr_merchant_salt' => 'required|string', ] ); $post['is_paytr_enabled'] = $request->is_paytr_enabled; $post['paytr_merchant_id'] = $request->paytr_merchant_id; $post['paytr_merchant_key'] = $request->paytr_merchant_key; $post['paytr_merchant_salt'] = $request->paytr_merchant_salt; } else { $post['is_paytr_enabled'] = 'off'; } if (isset($request->is_yookassa_enabled) && $request->is_yookassa_enabled == 'on') { $request->validate( [ 'yookassa_shop_id' => 'required|string', 'yookassa_secret' => 'required|string', ] ); $post['is_yookassa_enabled'] = $request->is_yookassa_enabled; $post['yookassa_shop_id'] = $request->yookassa_shop_id; $post['yookassa_secret'] = $request->yookassa_secret; } else { $post['is_yookassa_enabled'] = 'off'; } if (isset($request->is_midtrans_enabled) && $request->is_midtrans_enabled == 'on') { $request->validate( [ 'midtrans_mode' => 'required', 'midtrans_secret' => 'required|string', ] ); $post['is_midtrans_enabled'] = $request->is_midtrans_enabled; $post['midtrans_mode'] = $request->midtrans_mode; $post['midtrans_secret'] = $request->midtrans_secret; } else { $post['is_midtrans_enabled'] = 'off'; } if (isset($request->is_xendit_enabled) && $request->is_xendit_enabled == 'on') { $request->validate( [ 'xendit_api' => 'required|string', 'xendit_token' => 'required|string', ] ); $post['is_xendit_enabled'] = $request->is_xendit_enabled; $post['xendit_api'] = $request->xendit_api; $post['xendit_token'] = $request->xendit_token; } else { $post['is_xendit_enabled'] = 'off'; } if (isset($request->is_nepalste_enabled) && $request->is_nepalste_enabled == 'on') { $request->validate( [ 'nepalste_mode' => 'required', 'nepalste_public_key' => 'required|string', 'nepalste_secret_key' => 'required|string', ] ); $post['is_nepalste_enabled'] = $request->is_nepalste_enabled; $post['nepalste_mode'] = $request->nepalste_mode; $post['nepalste_public_key'] = $request->nepalste_public_key; $post['nepalste_secret_key'] = $request->nepalste_secret_key; } else { $post['is_nepalste_enabled'] = 'off'; } if (isset($request->is_paiementpro_enabled) && $request->is_paiementpro_enabled == 'on') { $request->validate( [ 'paiementpro_merchant_id' => 'required|string', ] ); $post['is_paiementpro_enabled'] = $request->is_paiementpro_enabled; $post['paiementpro_merchant_id'] = $request->paiementpro_merchant_id; } else { $post['is_paiementpro_enabled'] = 'off'; } if (isset($request->is_fedapay_enabled) && $request->is_fedapay_enabled == 'on') { $request->validate( [ 'fedapay_mode' => 'required', 'fedapay_public_key' => 'required', 'fedapay_secret_key' => 'required', ] ); $post['is_fedapay_enabled'] = $request->is_fedapay_enabled; $post['fedapay_mode'] = $request->fedapay_mode; $post['fedapay_public_key'] = $request->fedapay_public_key; $post['fedapay_secret_key'] = $request->fedapay_secret_key; } else { $post['is_fedapay_enabled'] = 'off'; } if (isset($request->is_payhere_enabled) && $request->is_payhere_enabled == 'on') { $request->validate( [ 'payhere_mode' => 'required', 'payhere_merchant_id' => 'required', 'payhere_merchant_secret' => 'required', 'payhere_app_id' => 'required', 'payhere_app_secret' => 'required', ] ); $post['is_payhere_enabled'] = $request->is_payhere_enabled; $post['payhere_mode'] = $request->payhere_mode; $post['payhere_merchant_id'] = $request->payhere_merchant_id; $post['payhere_merchant_secret'] = $request->payhere_merchant_secret; $post['payhere_app_id'] = $request->payhere_app_id; $post['payhere_app_secret'] = $request->payhere_app_secret; } else { $post['is_payhere_enabled'] = 'off'; } if (isset($request->is_cinetpay_enabled) && $request->is_cinetpay_enabled == 'on') { $request->validate( [ 'cinetpay_api_key' => 'required', 'cinetpay_site_id' => 'required', ] ); $post['is_cinetpay_enabled'] = $request->is_cinetpay_enabled; $post['cinetpay_api_key'] = $request->cinetpay_api_key; $post['cinetpay_site_id'] = $request->cinetpay_site_id; } else { $post['is_cinetpay_enabled'] = 'off'; } foreach ($post as $key => $data) { $arr = [ $data, $key, \Auth::user()->id, ]; \DB::insert( 'insert into admin_payment_settings (`value`, `name`,`created_by`) values (?, ?, ?) ON DUPLICATE KEY UPDATE `value` = VALUES(`value`) ', $arr, ); } } public function offerletterupdate($lang, Request $request) { $user = GenerateOfferLetter::updateOrCreate(['lang' => $lang, 'created_by' => \Auth::user()->id], ['content' => $request->content]); return redirect()->back()->with('success', __('Offer Letter successfully saved.')); } public function joiningletterupdate($lang, Request $request) { $user = JoiningLetter::updateOrCreate(['lang' => $lang, 'created_by' => \Auth::user()->id], ['content' => $request->content]); return redirect()->back()->with('success', __('Joing Letter successfully saved.')); } public function experienceCertificateupdate($lang, Request $request) { $user = ExperienceCertificate::updateOrCreate(['lang' => $lang, 'created_by' => \Auth::user()->id], ['content' => $request->content]); return redirect()->back()->with('success', __('Experience Certificate successfully saved.')); } public function NOCupdate($lang, Request $request) { $user = NOC::updateOrCreate(['lang' => $lang, 'created_by' => \Auth::user()->id], ['content' => $request->content]); return redirect()->back()->with('success', __('NOC successfully saved.')); } public function storageSettingStore(Request $request) { if (isset($request->storage_setting) && $request->storage_setting == 'local') { $request->validate( [ 'local_storage_validation' => 'required', 'local_storage_max_upload_size' => 'required', ] ); $post['storage_setting'] = $request->storage_setting; $local_storage_validation = implode(',', $request->local_storage_validation); $post['local_storage_validation'] = $local_storage_validation; $post['local_storage_max_upload_size'] = $request->local_storage_max_upload_size; } if (isset($request->storage_setting) && $request->storage_setting == 's3') { $request->validate( [ 's3_key' => 'required', 's3_secret' => 'required', 's3_region' => 'required', 's3_bucket' => 'required', 's3_url' => 'required', 's3_endpoint' => 'required', 's3_max_upload_size' => 'required', 's3_storage_validation' => 'required', ] ); $post['storage_setting'] = $request->storage_setting; $post['s3_key'] = $request->s3_key; $post['s3_secret'] = $request->s3_secret; $post['s3_region'] = $request->s3_region; $post['s3_bucket'] = $request->s3_bucket; $post['s3_url'] = $request->s3_url; $post['s3_endpoint'] = $request->s3_endpoint; $post['s3_max_upload_size'] = $request->s3_max_upload_size; $s3_storage_validation = implode(',', $request->s3_storage_validation); $post['s3_storage_validation'] = $s3_storage_validation; } if (isset($request->storage_setting) && $request->storage_setting == 'wasabi') { $request->validate( [ 'wasabi_key' => 'required', 'wasabi_secret' => 'required', 'wasabi_region' => 'required', 'wasabi_bucket' => 'required', 'wasabi_url' => 'required', 'wasabi_root' => 'required', 'wasabi_max_upload_size' => 'required', 'wasabi_storage_validation' => 'required', ] ); $post['storage_setting'] = $request->storage_setting; $post['wasabi_key'] = $request->wasabi_key; $post['wasabi_secret'] = $request->wasabi_secret; $post['wasabi_region'] = $request->wasabi_region; $post['wasabi_bucket'] = $request->wasabi_bucket; $post['wasabi_url'] = $request->wasabi_url; $post['wasabi_root'] = $request->wasabi_root; $post['wasabi_max_upload_size'] = $request->wasabi_max_upload_size; $wasabi_storage_validation = implode(',', $request->wasabi_storage_validation); $post['wasabi_storage_validation'] = $wasabi_storage_validation; } foreach ($post as $key => $data) { $arr = [ $data, $key, \Auth::user()->id, ]; \DB::insert( 'insert into settings (`value`, `name`,`created_by`) values (?, ?, ?) ON DUPLICATE KEY UPDATE `value` = VALUES(`value`) ', $arr ); } return redirect()->back()->with('success', 'Storage setting successfully updated.'); } public function CacheSettings(Request $request) { Artisan::call('cache:clear'); Artisan::call('optimize:clear'); return redirect()->back()->with('success', 'Cache clear Successfully'); } public function saveCookieSettings(Request $request) { $validator = \Validator::make( $request->all(), [ 'cookie_title' => 'required', 'cookie_description' => 'required', 'strictly_cookie_title' => 'required', 'strictly_cookie_description' => 'required', 'more_information_description' => 'required', 'contactus_url' => 'required', ] ); $post = $request->all(); unset($post['_token']); if ($request->enable_cookie) { $post['enable_cookie'] = 'on'; } else { $post['enable_cookie'] = 'off'; } if ($request->cookie_logging) { $post['cookie_logging'] = 'on'; } else { $post['cookie_logging'] = 'off'; } $post['cookie_title'] = $request->cookie_title; $post['cookie_description'] = $request->cookie_description; $post['strictly_cookie_title'] = $request->strictly_cookie_title; $post['strictly_cookie_description'] = $request->strictly_cookie_description; $post['more_information_description'] = $request->more_information_description; $post['contactus_url'] = $request->contactus_url; $settings = Utility::settings(); foreach ($post as $key => $data) { if (in_array($key, array_keys($settings))) { \DB::insert( 'insert into settings (`value`, `name`,`created_by`,`created_at`,`updated_at`) values (?, ?, ?, ?, ?) ON DUPLICATE KEY UPDATE `value` = VALUES(`value`) ', [ $data, $key, \Auth::user()->creatorId(), date('Y-m-d H:i:s'), date('Y-m-d H:i:s'), ] ); } } return redirect()->back()->with('success', 'Cookie setting successfully saved.'); } public function CookieConsent(Request $request) { $settings = Utility::settings(); if ($settings['enable_cookie'] == "on" && $settings['cookie_logging'] == "on") { $allowed_levels = ['necessary', 'analytics', 'targeting']; $levels = array_filter($request['cookie'], function ($level) use ($allowed_levels) { return in_array($level, $allowed_levels); }); $whichbrowser = new \WhichBrowser\Parser($_SERVER['HTTP_USER_AGENT']); // Generate new CSV line $browser_name = $whichbrowser->browser->name ?? null; $os_name = $whichbrowser->os->name ?? null; $browser_language = isset($_SERVER['HTTP_ACCEPT_LANGUAGE']) ? mb_substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2) : null; $device_type = Utility::get_device_type($_SERVER['HTTP_USER_AGENT']); $ip = $_SERVER['REMOTE_ADDR']; // $ip = '49.36.83.154'; $query = @unserialize(file_get_contents('http://ip-api.com/php/' . $ip)); $date = (new \DateTime())->format('Y-m-d'); $time = (new \DateTime())->format('H:i:s') . ' UTC'; $cookie = $request['cookie'][0]; $new_line = implode(',', [ $ip, $date, $time, $cookie, $device_type, $browser_language, $browser_name, $os_name, isset($query) ? $query['country'] : '', isset($query) ? $query['region'] : '', isset($query) ? $query['regionName'] : '', isset($query) ? $query['city'] : '', isset($query) ? $query['zip'] : '', isset($query) ? $query['lat'] : '', isset($query) ? $query['lon'] : '' ]); if (!file_exists(storage_path() . '/uploads/sample/data.csv')) { $first_line = 'IP,Date,Time,Accepted cookies,Device type,Browser language,Browser name,OS Name,Country,Region,RegionName,City,Zipcode,Lat,Lon'; file_put_contents(storage_path() . '/uploads/sample/data.csv', $first_line . PHP_EOL, FILE_APPEND | LOCK_EX); } file_put_contents(storage_path() . '/uploads/sample/data.csv', $new_line . PHP_EOL, FILE_APPEND | LOCK_EX); return response()->json('success'); } return response()->json('error'); } public function chatgptkey(Request $request) { $validator = \Validator::make( $request->all(), [ 'chatgpt_key' => 'required', 'chatgpt_model' => 'required', ] ); if ($validator->fails()) { $messages = $validator->getMessageBag(); return redirect()->back()->with('error', $messages->first()); } if (\Auth::user()->type == 'super admin') { $user = \Auth::user(); if (!empty($request->chatgpt_key)) { $post = $request->all(); $post['chatgpt_key'] = $request->chatgpt_key; $post['chatgpt_model'] = $request->chatgpt_model; unset($post['_token']); foreach ($post as $key => $data) { $settings = Utility::settings(); if (in_array($key, array_keys($settings))) { \DB::insert( 'insert into settings (`value`, `name`,`created_by`, `created_at`,`updated_at`) values (?, ?, ?, ?, ?) ON DUPLICATE KEY UPDATE `value` = VALUES(`value`) ', [ $data, $key, $user->creatorId(), date('Y-m-d H:i:s'), date('Y-m-d H:i:s'), ] ); } } } return redirect()->back()->with('success', __('Chatgpt key successfully saved.')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } public function BiometricSetting(Request $request) { $validator = \Validator::make( $request->all(), [ 'zkteco_api_url' => 'required', 'username' => 'required', 'user_password' => 'required', ] ); if ($validator->fails()) { $messages = $validator->getMessageBag(); return redirect()->back()->with('error', $messages->first()); } $user = \Auth::user(); if (!empty($request->zkteco_api_url) && !empty($request->username) && !empty($request->user_password)) { try { $url = "$request->zkteco_api_url" . '/api-token-auth/'; $headers = array( "Content-Type: application/json" ); $data = array( "username" => $request->username, "password" => $request->user_password ); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data)); curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $response = curl_exec($ch); curl_close($ch); $auth_token = json_decode($response, true); if (isset($auth_token['token'])) { $post = $request->all(); $post['zkteco_api_url'] = $request->zkteco_api_url; $post['username'] = $request->username; $post['user_password'] = $request->user_password; $post['auth_token'] = $auth_token['token']; unset($post['_token']); foreach ($post as $key => $data) { $settings = Utility::settings(); if (in_array($key, array_keys($settings))) { \DB::insert( 'insert into settings (`value`, `name`,`created_by`, `created_at`,`updated_at`) values (?, ?, ?, ?, ?) ON DUPLICATE KEY UPDATE `value` = VALUES(`value`) ', [ $data, $key, $user->creatorId(), date('Y-m-d H:i:s'), date('Y-m-d H:i:s'), ] ); } } } else { return redirect()->back()->with('error', isset($auth_token['non_field_errors']) ? $auth_token['non_field_errors'][0] : __("something went wrong please try again")); } } catch (\Exception $e) { return redirect()->back()->with('error', $e->getMessage()); } return redirect()->back()->with('success', __('Biometric setting successfully saved.')); } } } Controllers/PayHereController.php000064400000022527150364311770013203 0ustar00plan_id); $plan = Plan::find($planID); $orderID = strtoupper(str_replace('.', '', uniqid('', true))); $authuser = Auth::user(); if ($plan) { /* Check for code usage */ $get_amount = $plan->price; if (!empty($request->coupon)) { $coupons = Coupon::where('code', strtoupper($request->coupon))->where('is_active', '1')->first(); if (!empty($coupons)) { $usedCoupun = $coupons->used_coupon(); $discount_value = ($plan->price / 100) * $coupons->discount; $get_amount = $plan->price - $discount_value; if ($coupons->limit == $usedCoupun) { return redirect()->back()->with('error', __('This coupon code has expired.')); } if ($get_amount <= 0) { $authuser = Auth::user(); $authuser->plan = $plan->id; $authuser->save(); $assignPlan = $authuser->assignPlan($plan->id); if ($assignPlan['is_success'] == true && !empty($plan)) { $orderID = strtoupper(str_replace('.', '', uniqid('', true))); $userCoupon = new UserCoupon(); $userCoupon->user = $authuser->id; $userCoupon->coupon = $coupons->id; $userCoupon->order = $orderID; $userCoupon->save(); Order::create( [ 'order_id' => $orderID, 'name' => null, 'email' => null, 'card_number' => null, 'card_exp_month' => null, 'card_exp_year' => null, 'plan_name' => $plan->name, 'plan_id' => $plan->id, 'price' => $get_amount == null ? 0 : $get_amount, 'price_currency' => $currency, 'txn_id' => '', 'payment_type' => __('Paiement Pro'), 'payment_status' => 'success', 'receipt' => null, 'user_id' => $authuser->id, ] ); $assignPlan = $authuser->assignPlan($plan->id); return redirect()->route('plans.index')->with('success', __('Plan Successfully Activated')); } } } else { return redirect()->back()->with('error', __('This coupon code is invalid or has expired.')); } } try { $config = [ 'payhere.api_endpoint' => $payhere_mode === 'sandbox' ? 'https://sandbox.payhere.lk/' : 'https://www.payhere.lk/', ]; $config['payhere.merchant_id'] = $payhere_merchant_id ?? ''; $config['payhere.merchant_secret'] = $payhere_merchant_secret ?? ''; $config['payhere.app_secret'] = $payhere_app_secret ?? ''; $config['payhere.app_id'] = $payhere_app_id ?? ''; config($config); $hash = strtoupper( md5( $payhere_merchant_id . $orderID . number_format($get_amount, 2, '.', '') . 'LKR' . strtoupper(md5($payhere_merchant_secret)) ) ); $data = [ 'first_name' => $authuser->name, 'last_name' => '', 'email' => $authuser->email, 'phone' => $authuser->mobile_no ?? '', 'address' => 'Main Rd', 'city' => 'Anuradhapura', 'country' => 'Sri lanka', 'order_id' => $orderID, 'items' => $plan->name ?? 'Add-on', 'currency' => 'LKR', 'amount' => $get_amount, 'hash' => $hash, ]; return PayHere::checkOut() ->data($data) ->successUrl(route('payhere.status', [ $plan->id, 'amount' => $get_amount, 'coupon_code' => !empty($request->coupon_code) ? $request->coupon_code : '', 'coupon_id' => !empty($coupons->id) ? $coupons->id : '', ])) ->failUrl(route('payhere.status', [ $plan->id, 'amount' => $get_amount, 'coupon_code' => !empty($request->coupon_code) ? $request->coupon_code : '', 'coupon_id' => !empty($coupons->id) ? $coupons->id : '', ])) ->renderView(); } catch (\Exception $e) { \Log::debug($e->getMessage()); return redirect()->route('plans.index')->with('error', $e->getMessage()); } } else { return redirect()->route('plans.index')->with('error', __('Plan is deleted.')); } } public function planGetPayHereStatus(Request $request) { $payment_setting = Utility::getAdminPaymentSetting(); $currency = isset($payment_setting['currency']) ? $payment_setting['currency'] : ''; $orderID = strtoupper(str_replace('.', '', uniqid('', true))); $getAmount = $request->amount; $authuser = Auth::user(); $plan = Plan::find($request->plan_id); Utility::referralTransaction($plan); if ($plan) { try { $order = new Order(); $order->order_id = $orderID; $order->name = $authuser->name; $order->card_number = ''; $order->card_exp_month = ''; $order->card_exp_year = ''; $order->plan_name = $plan->name; $order->plan_id = $plan->id; $order->price = $getAmount; $order->price_currency = $currency; $order->txn_id = $orderID; $order->payment_type = __('PayHere'); $order->payment_status = 'success'; $order->receipt = ''; $order->user_id = $authuser->id; $order->save(); $assignPlan = $authuser->assignPlan($plan->id); $coupons = Coupon::find($request->coupon_id); if (!empty($request->coupon_id)) { if (!empty($coupons)) { $userCoupon = new UserCoupon(); $userCoupon->user = $authuser->id; $userCoupon->coupon = $coupons->id; $userCoupon->order = $orderID; $userCoupon->save(); $usedCoupun = $coupons->used_coupon(); if ($coupons->limit <= $usedCoupun) { $coupons->is_active = 0; $coupons->save(); } } } if ($assignPlan['is_success']) { return redirect()->route('plans.index')->with('success', __('Plan activated Successfully.')); } else { return redirect()->route('plans.index')->with('error', __($assignPlan['error'])); } } catch (\Exception $e) { return redirect()->route('plans.index')->with('error', __('Transaction has been failed.')); } } else { return redirect()->route('plans.index')->with('error', __('Plan is deleted.')); } } } Controllers/BiometricAttendanceController.php000064400000047611150364311770015553 0ustar00can('Manage Biometric Attendance')) { $company_setting = Utility::settings(); $api_urls = !empty($company_setting['zkteco_api_url']) ? $company_setting['zkteco_api_url'] : ''; $token = !empty($company_setting['auth_token']) ? $company_setting['auth_token'] : ''; if (!empty($request->start_date) && !empty($request->end_date)) { $start_date = date('Y-m-d:H:i:s', strtotime($request->start_date)); $end_date = date('Y-m-d:H:i:s', strtotime($request->end_date) + 86400 - 1); } else { $start_date = date('Y-m-d', strtotime('-7 days')); $end_date = date('Y-m-d'); } $api_url = rtrim($api_urls, '/'); // Dynamic Api URL Call $url = $api_url . '/iclock/api/transactions/?' . http_build_query([ 'start_time' => $start_date, 'end_time' => $end_date, 'page_size' => 10000, ]); $curl = curl_init(); if (!empty($token)) { try { curl_setopt_array($curl, array( CURLOPT_URL => $url, CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => '', CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 0, CURLOPT_FOLLOWLOCATION => true, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => 'GET', CURLOPT_HTTPHEADER => array( 'Content-Type: application/json', 'Authorization: Token ' . $token ), )); $response = curl_exec($curl); curl_close($curl); $json_attendance = json_decode($response, true); $attendances = $json_attendance['data']; } catch (\Throwable $th) { return redirect()->back()->with('error', __('Something went wrong please try again.')); } } else { $attendances = []; } return view('biometricattendance.index', compact('attendances', 'token')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } public function update(Request $request) { if (Auth::user()->can('Manage Biometric Attendance')) { $company_settings = Utility::settings(); if (empty($company_settings['auth_token'])) { return redirect()->back()->with('error', __('Please first create auth token')); } $employee = Employee::where('created_by', Auth::user()->creatorId())->where('biometric_emp_id', $request->biometric_emp_id)->first(); if (empty($employee)) { return redirect()->back()->with('error', __('Please first create employee or edit employee code.')); } $biometric_code = $employee->biometric_emp_id; $startTime = Utility::getValByName('company_start_time'); $endTime = Utility::getValByName('company_end_time'); $date = date("Y-m-d", strtotime($request->punch_time)); $time = date("H:i", strtotime($request->punch_time)); $todayAttendance = AttendanceEmployee::where('attendance_employees.created_by', Auth::user()->creatorId()) ->where('employees.biometric_emp_id', $biometric_code) ->where('clock_in', '=', date("H:i:s", strtotime($time))) ->where('date', '=', $date) ->leftJoin('employees', 'attendance_employees.employee_id', '=', 'employees.id') ->select('attendance_employees.*', 'employees.biometric_emp_id as biometric_id') ->first(); if (!empty($todayAttendance)) { return redirect()->back()->with('error', __('This employee is already sync.')); } $attendance = AttendanceEmployee::where('attendance_employees.created_by', Auth::user()->creatorId()) ->where('employees.biometric_emp_id', $biometric_code) ->where('clock_out', '=', '00:00:00') ->where('date', '=', $date) ->orderBy('id', 'desc') ->leftJoin('employees', 'attendance_employees.employee_id', '=', 'employees.id') ->select('attendance_employees.*', 'employees.biometric_emp_id as biometric_id') ->first(); if ($attendance != null) { if ($attendance->date == $date && date("H:i", strtotime($attendance->clock_in)) == $time) { return redirect()->back()->with('error', __('This employee is already sync.')); } $endTimestamp = strtotime($date . $endTime); $currentTimestamp = strtotime($date . $time); if ($currentTimestamp > $endTimestamp) { $endTimestamp = strtotime($date . ' +1 day ' . $endTime); } $totalEarlyLeavingSeconds = $endTimestamp - $currentTimestamp; if ($totalEarlyLeavingSeconds < 0) { $earlyLeaving = '0:00:00'; } else { $hours = floor($totalEarlyLeavingSeconds / 3600); $mins = floor($totalEarlyLeavingSeconds / 60 % 60); $secs = floor($totalEarlyLeavingSeconds % 60); $earlyLeaving = sprintf('%02d:%02d:%02d', $hours, $mins, $secs); } $endTimeTimestamp = strtotime($date . $endTime); $timeTimestamp = strtotime($date . $time); if ($timeTimestamp > $endTimeTimestamp) { //Overtime $totalOvertimeSeconds = $timeTimestamp - $endTimeTimestamp; $hours = floor($totalOvertimeSeconds / 3600); $mins = floor(($totalOvertimeSeconds % 3600) / 60); $secs = floor($totalOvertimeSeconds % 60); $overtime = sprintf('%02d:%02d:%02d', $hours, $mins, $secs); } else { $overtime = '00:00:00'; } $attendance = AttendanceEmployee::find($attendance->id); $attendance->clock_out = $time; $attendance->early_leaving = $earlyLeaving; $attendance->overtime = $overtime; $attendance->save(); } // Find the last clocked out entry for the employee $lastClockOutEntry = AttendanceEmployee::where('attendance_employees.created_by', Auth::user()->creatorId()) ->where('employees.biometric_emp_id', $biometric_code) ->where('attendance_employees.employee_id', '=', $employee->id) ->where('clock_out', '!=', '00:00:00') ->where('date', '=', $date) ->orderBy('id', 'desc') ->leftJoin('employees', 'attendance_employees.employee_id', '=', 'employees.id') ->select('attendance_employees.*', 'employees.biometric_emp_id as biometric_id') ->first(); if (!empty($company_settings['timezone'])) { date_default_timezone_set($company_settings['timezone']); } if ($lastClockOutEntry != null) { $lastClockOutTime = $lastClockOutEntry->clock_out; $actualClockInTime = $date . ' ' . $time; $totalLateSeconds = strtotime($actualClockInTime) - strtotime($date . ' ' . $lastClockOutTime); $totalLateSeconds = max($totalLateSeconds, 0); $hours = floor($totalLateSeconds / 3600); $mins = floor($totalLateSeconds / 60 % 60); $secs = floor($totalLateSeconds % 60); $late = sprintf('%02d:%02d:%02d', $hours, $mins, $secs); } else { $expectedStartTime = $date . ' ' . $startTime; $actualClockInTime = $date . ' ' . $time; $totalLateSeconds = strtotime($actualClockInTime) - strtotime($expectedStartTime); $totalLateSeconds = max($totalLateSeconds, 0); $hours = floor($totalLateSeconds / 3600); $mins = floor($totalLateSeconds / 60 % 60); $secs = floor($totalLateSeconds % 60); $late = sprintf('%02d:%02d:%02d', $hours, $mins, $secs); } $checkDb = AttendanceEmployee::where('attendance_employees.created_by', Auth::user()->creatorId()) ->where('employees.biometric_emp_id', $biometric_code) ->where('attendance_employees.employee_id', '=', $employee->id) ->where('attendance_employees.date', '=', $date) ->leftJoin('employees', 'attendance_employees.employee_id', '=', 'employees.id') ->select('attendance_employees.*', 'employees.biometric_emp_id as biometric_id') ->get() ->toArray(); if (empty($checkDb)) { $employeeAttendance = new AttendanceEmployee(); $employeeAttendance->employee_id = $employee->id; $employeeAttendance->date = $date; $employeeAttendance->status = 'Present'; $employeeAttendance->clock_in = $time; $employeeAttendance->clock_out = '00:00:00'; $employeeAttendance->late = $late; $employeeAttendance->early_leaving = '00:00:00'; $employeeAttendance->overtime = '00:00:00'; $employeeAttendance->total_rest = '00:00:00'; $employeeAttendance->created_by = Auth::user()->creatorId(); $employeeAttendance->save(); return redirect()->back()->with('success', __('Employee successfully Sync.')); } $attendancess = AttendanceEmployee::where('attendance_employees.created_by', Auth::user()->creatorId()) ->where('employees.biometric_emp_id', $biometric_code) ->where('clock_in', '!=', '00:00:00') ->where('clock_out', '!=', $time) ->orderBy('id', 'desc') ->leftJoin('employees', 'attendance_employees.employee_id', '=', 'employees.id') ->select('attendance_employees.*', 'employees.biometric_emp_id as biometric_id') ->first(); if (empty($attendance)) { $employeeAttendance = new AttendanceEmployee(); $employeeAttendance->employee_id = $employee->id; $employeeAttendance->date = $date; $employeeAttendance->status = 'Present'; $employeeAttendance->clock_in = $time; $employeeAttendance->clock_out = '00:00:00'; $employeeAttendance->late = $late; $employeeAttendance->early_leaving = '00:00:00'; $employeeAttendance->overtime = '00:00:00'; $employeeAttendance->total_rest = '00:00:00'; $employeeAttendance->created_by = Auth::user()->creatorId(); $employeeAttendance->save(); } return redirect()->back()->with('success', __('Employee successfully Sync.')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } public function AllSync(Request $request) { if (Auth::user()->can('Manage Biometric Attendance')) { $company_setting = Utility::settings(); $api_urls = !empty($company_setting['zkteco_api_url']) ? $company_setting['zkteco_api_url'] : ''; $token = !empty($company_setting['auth_token']) ? $company_setting['auth_token'] : ''; if (!empty($request->start_date) && !empty($request->end_date)) { $start_date = date('Y-m-d:H:i:s', strtotime($request->start_date)); $end_date = date('Y-m-d:H:i:s', strtotime($request->end_date) + 86400 - 1); } else { $start_date = date('Y-m-d', strtotime('-7 days')); $end_date = date('Y-m-d'); } $api_url = rtrim($api_urls, '/'); // Dynamic Api URL Call $url = $api_url . '/iclock/api/transactions/?' . http_build_query([ 'start_time' => $start_date, 'end_time' => $end_date, 'page_size' => 10000, ]); $curl = curl_init(); curl_setopt_array($curl, array( CURLOPT_URL => $url, CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => '', CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 0, CURLOPT_FOLLOWLOCATION => true, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => 'GET', CURLOPT_HTTPHEADER => array( 'Content-Type: application/json', 'Authorization: Token ' . $token ), )); $response = curl_exec($curl); curl_close($curl); $json_attendance = json_decode($response, true); $attendances = $json_attendance['data']; if (empty($company_setting['auth_token'])) { return redirect()->back()->with('error', __('Please first create auth token')); } $employeeAttendance = []; foreach ($attendances as $bio_attendance) { $employees = Employee::where('created_by', Auth::user()->creatorId())->where('biometric_emp_id', $bio_attendance['emp_code'])->get(); if ($employees->isEmpty()) { return Response::json([ 'url' => route('biometric-attendance.allsync'), 'message' => 'Please first create employee or edit employee code.' ]); } foreach ($employees as $employee) { $biometric_code = $employee->biometric_emp_id; $startTime = Utility::getValByName('company_start_time'); $endTime = Utility::getValByName('company_end_time'); $date = date("Y-m-d", strtotime($bio_attendance['punch_time'])); $time = date("H:i", strtotime($bio_attendance['punch_time'])); $todayAttendance = AttendanceEmployee::where('attendance_employees.created_by', Auth::user()->creatorId()) ->where('employees.biometric_emp_id', $biometric_code) ->where('clock_in', '=', date("H:i:s", strtotime($time))) ->where('date', '=', $date) ->leftJoin('employees', 'attendance_employees.employee_id', '=', 'employees.id') ->select('attendance_employees.*', 'employees.biometric_emp_id as biometric_id') ->first(); if (!empty($todayAttendance)) { return Response::json([ 'url' => route('biometric-attendance.allsync'), 'data' => $todayAttendance, 'message' => 'This employee is already sync.' // Make sure this key is set properly ]); } $lastClockOutEntry = AttendanceEmployee::where('attendance_employees.created_by', Auth::user()->creatorId()) ->where('employees.biometric_emp_id', $biometric_code) ->where('attendance_employees.employee_id', '=', $employee->id) ->where('clock_out', '!=', '00:00:00') ->where('date', '=', date('Y-m-d')) ->orderBy('id', 'desc') ->leftJoin('employees', 'attendance_employees.employee_id', '=', 'employees.id') ->select('attendance_employees.*', 'employees.biometric_emp_id as biometric_id') ->first(); if (!empty($company_settings['defult_timezone'])) { date_default_timezone_set($company_settings['defult_timezone']); } if ($lastClockOutEntry != null) { $lastClockOutTime = $lastClockOutEntry->clock_out; $actualClockInTime = $date . ' ' . $time; $totalLateSeconds = strtotime($actualClockInTime) - strtotime($date . ' ' . $lastClockOutTime); $totalLateSeconds = max($totalLateSeconds, 0); $hours = floor($totalLateSeconds / 3600); $mins = floor($totalLateSeconds / 60 % 60); $secs = floor($totalLateSeconds % 60); $late = sprintf('%02d:%02d:%02d', $hours, $mins, $secs); } else { $expectedStartTime = $date . ' ' . $startTime; $actualClockInTime = $date . ' ' . $time; $totalLateSeconds = strtotime($actualClockInTime) - strtotime($expectedStartTime); $totalLateSeconds = max($totalLateSeconds, 0); $hours = floor($totalLateSeconds / 3600); $mins = floor($totalLateSeconds / 60 % 60); $secs = floor($totalLateSeconds % 60); $late = sprintf('%02d:%02d:%02d', $hours, $mins, $secs); } $checkDb = AttendanceEmployee::where('attendance_employees.created_by', Auth::user()->creatorId()) ->where('employees.biometric_emp_id', $biometric_code) ->where('attendance_employees.employee_id', '=', $employee->id) ->where('attendance_employees.date', '=', $date) ->leftJoin('employees', 'attendance_employees.employee_id', '=', 'employees.id') ->select('attendance_employees.*', 'employees.biometric_emp_id as biometric_id') ->get() ->toArray(); $employeeAttendance = new AttendanceEmployee(); $employeeAttendance->employee_id = $employee->id; $employeeAttendance->date = $date; $employeeAttendance->status = 'Present'; $employeeAttendance->clock_in = $time; $employeeAttendance->clock_out = '00:00:00'; $employeeAttendance->late = $late; $employeeAttendance->early_leaving = '00:00:00'; $employeeAttendance->overtime = '00:00:00'; $employeeAttendance->total_rest = '00:00:00'; $employeeAttendance->created_by = Auth::user()->creatorId(); $employeeAttendance->save(); } } return Response::json([ 'url' => route('biometric-attendance.allsync'), 'data' => $employeeAttendance, 'message' => 'Employee successfully Sync.' ]); } else { return redirect()->back()->with('error', __('Permission denied.')); } } } Controllers/CompetenciesController.php000064400000007223150364311770014260 0ustar00can('Manage Competencies')) { $competencies = Competencies::where('created_by', \Auth::user()->creatorId())->with('getPerformance_type')->get(); return view('competencies.index', compact('competencies')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } public function create() { $user = \Auth::user(); $performance_types = Performance_Type::where('created_by', '=', $user->creatorId())->get()->pluck('name', 'id'); $performance_types->prepend('Select Performance type', ''); return view('competencies.create', compact('performance_types')); } public function store(Request $request) { if (\Auth::user()->can('Create Competencies')) { $validator = \Validator::make( $request->all(), [ 'name' => 'required', 'type' => 'required', ] ); if ($validator->fails()) { $messages = $validator->getMessageBag(); return redirect()->back()->with('error', $messages->first()); } $competencies = new Competencies(); $competencies->name = $request->name; $competencies->type = $request->type; $competencies->created_by = \Auth::user()->creatorId(); $competencies->save(); return redirect()->route('competencies.index')->with('success', __('Competencies successfully created.')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } public function show(Competencies $competencies) { // } public function edit($id) { $competencies = Competencies::find($id); $types = Performance_Type::where('created_by', '=', \Auth::user()->creatorId())->get()->pluck('name', 'id'); $types->prepend('Select Performance type', ''); return view('competencies.edit', compact('types', 'competencies')); } public function update(Request $request, $id) { if (\Auth::user()->can('Edit Competencies')) { $validator = \Validator::make( $request->all(), [ 'name' => 'required', 'type' => 'required', ] ); if ($validator->fails()) { $messages = $validator->getMessageBag(); return redirect()->back()->with('error', $messages->first()); } $competencies = Competencies::find($id); $competencies->name = $request->name; $competencies->type = $request->type; $competencies->save(); return redirect()->route('competencies.index')->with('success', __('Competencies successfully updated.')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } public function destroy($id) { if (\Auth::user()->can('Delete Competencies')) { $competencies = Competencies::find($id); $competencies->delete(); return redirect()->route('competencies.index')->with('success', __('Competencies successfully deleted.')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } } Controllers/ExpenseController.php000064400000016623150364311770013255 0ustar00can('Manage Expense')) { $expenses = Expense::where('created_by', '=', \Auth::user()->creatorId())->with(['accounts', 'payees', 'expense_categorys', 'payment_types'])->get(); return view('expense.index', compact('expenses')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } public function create() { if(\Auth::user()->can('Create Expense')) { $expenses = Expense::where('created_by', '=', \Auth::user()->creatorId())->get(); $accounts = AccountList::where('created_by', '=', \Auth::user()->creatorId())->get()->pluck('account_name', 'id'); $expenseCategory = ExpenseType::where('created_by', '=', \Auth::user()->creatorId())->get()->pluck('name', 'id'); $payees = Payees::where('created_by', '=', \Auth::user()->creatorId())->get()->pluck('payee_name', 'id'); $paymentTypes = PaymentType::where('created_by', '=', \Auth::user()->creatorId())->get()->pluck('name', 'id'); return view('expense.create', compact('expenses', 'accounts', 'expenseCategory', 'payees', 'paymentTypes')); } else { return response()->json(['error' => __('Permission denied.')], 401); } } public function store(Request $request) { if(\Auth::user()->can('Create Expense')) { $validator = \Validator::make( $request->all(), [ 'account_id' => 'required', 'amount' => 'required', 'date' => 'required', 'expense_category_id' => 'required', 'payee_id' => 'required', 'payment_type_id'=>'required', ] ); if($validator->fails()) { $messages = $validator->getMessageBag(); return redirect()->back()->with('error', $messages->first()); } $expense = new Expense(); $expense->account_id = $request->account_id; $expense->amount = $request->amount; $expense->date = $request->date; $expense->expense_category_id = $request->expense_category_id; $expense->payee_id = $request->payee_id; $expense->payment_type_id = $request->payment_type_id; $expense->referal_id = $request->referal_id; $expense->description = $request->description; $expense->created_by = \Auth::user()->creatorId(); $expense->save(); AccountList::remove_Balance($request->account_id, $request->amount); return redirect()->route('expense.index')->with('success', __('Expense successfully created.')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } public function show(Expense $expense) { return redirect()->route('expense.index'); } public function edit(Expense $expense) { if(\Auth::user()->can('Edit Expense')) { if($expense->created_by == \Auth::user()->creatorId()) { $expenses = Expense::where('created_by', '=', \Auth::user()->creatorId())->get(); $accounts = AccountList::where('created_by', '=', \Auth::user()->creatorId())->get()->pluck('account_name', 'id'); $expenseCategory = ExpenseType::where('created_by', '=', \Auth::user()->creatorId())->get()->pluck('name', 'id'); $payees = Payees::where('created_by', '=', \Auth::user()->creatorId())->get()->pluck('payee_name', 'id'); $paymentTypes = PaymentType::where('created_by', '=', \Auth::user()->creatorId())->get()->pluck('name', 'id'); return view('expense.edit', compact('expense', 'accounts', 'expenseCategory', 'payees', 'paymentTypes')); } else { return response()->json(['error' => __('Permission denied.')], 401); } } else { return response()->json(['error' => __('Permission denied.')], 401); } } public function update(Request $request, Expense $expense) { if(\Auth::user()->can('Edit Expense')) { if($expense->created_by == \Auth::user()->creatorId()) { $validator = \Validator::make( $request->all(), [ 'account_id' => 'required', 'amount' => 'required', 'date' => 'required', 'expense_category_id' => 'required', 'payee_id' => 'required', ] ); if($validator->fails()) { $messages = $validator->getMessageBag(); return redirect()->back()->with('error', $messages->first()); } $expense->account_id = $request->account_id; $expense->amount = $request->amount; $expense->date = $request->date; $expense->expense_category_id = $request->expense_category_id; $expense->payee_id = $request->payee_id; $expense->payment_type_id = $request->payment_type_id; $expense->referal_id = $request->referal_id; $expense->description = $request->description; $expense->save(); return redirect()->route('expense.index')->with('success', __('Expense successfully updated.')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } else { return redirect()->back()->with('error', __('Permission denied.')); } } public function destroy(Expense $expense) { if(\Auth::user()->can('Delete Expense')) { if($expense->created_by == \Auth::user()->creatorId()) { $expense->delete(); return redirect()->route('expense.index')->with('success', __('Expense successfully deleted.')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } else { return redirect()->back()->with('error', __('Permission denied.')); } } public function export(Request $request) { $name = 'Expense_' . date('Y-m-d i:h:s'); $data = Excel::download(new ExpenseExport(), $name . '.xlsx'); return $data; } } Controllers/AppraisalController.php000064400000021231150364311770013551 0ustar00can('Manage Appraisal')) { $user = \Auth::user(); if($user->type == 'employee') { $employee = Employee::where('user_id', $user->id)->first(); $competencyCount = Competencies::where('created_by', '=', $user->creatorId())->count(); $appraisals = Appraisal::where('created_by', '=', \Auth::user()->creatorId())->where('branch', $employee->branch_id)->where('employee', $employee->id)->get(); } else { $competencyCount = Competencies::where('created_by', '=', $user->creatorId())->count(); $appraisals = Appraisal::where('created_by', '=', \Auth::user()->creatorId())->get(); } return view('appraisal.index', compact('appraisals','competencyCount')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } public function create() { if(\Auth::user()->can('Create Appraisal')) { $brances = Branch::where('created_by', '=', \Auth::user()->creatorId())->get(); $employee = Employee::where('created_by', \Auth::user()->creatorId())->get()->pluck('name','id'); $employee->prepend('Select Employee', ''); $performance_types = Performance_Type::where('created_by', '=', \Auth::user()->creatorId())->get(); return view('appraisal.create', compact('employee', 'brances', 'performance_types')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } public function store(Request $request) { if(\Auth::user()->can('Create Appraisal')) { $validator = \Validator::make( $request->all(), [ 'brances' => 'required', 'employee' => 'required', 'rating'=> 'required', ] ); if($validator->fails()) { $messages = $validator->getMessageBag(); return redirect()->back()->with('error', $messages->first()); } $appraisal = new Appraisal(); $appraisal->branch = $request->brances; $appraisal->employee = $request->employee; $appraisal->appraisal_date = $request->appraisal_date; $appraisal->rating = json_encode($request->rating, true); $appraisal->remark = $request->remark; $appraisal->created_by = \Auth::user()->creatorId(); $appraisal->save(); return redirect()->route('appraisal.index')->with('success', __('Appraisal successfully created.')); } } public function show(Appraisal $appraisal) { $rating = json_decode($appraisal->rating, true); $performance_types = Performance_Type::where('created_by', '=', \Auth::user()->creatorId())->get(); $employee = Employee::find($appraisal->employee); $indicator = Indicator::where('branch',$employee->branch_id)->where('department',$employee->department_id)->where('designation',$employee->designation_id)->first(); if ($indicator != null) { $ratings = json_decode($indicator->rating, true); }else { $ratings = null; } // $ratings = json_decode($indicator->rating, true); return view('appraisal.show', compact('appraisal', 'performance_types', 'rating','ratings')); } public function edit(Appraisal $appraisal) { if(\Auth::user()->can('Edit Appraisal')) { $performance_types = Performance_Type::where('created_by', '=', \Auth::user()->creatorId())->get(); $employee = Employee::where('created_by', \Auth::user()->creatorId())->get()->pluck('name','id'); $employee->prepend('Select Employee', ''); $brances = Branch::where('created_by', '=', \Auth::user()->creatorId())->get(); $rating = json_decode($appraisal->rating,true); return view('appraisal.edit', compact('brances', 'employee', 'appraisal', 'performance_types','rating')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } public function update(Request $request, Appraisal $appraisal) { if(\Auth::user()->can('Edit Appraisal')) { $validator = \Validator::make( $request->all(), [ 'brances' => 'required', 'employees' => 'required', 'rating'=> 'required', ] ); if($validator->fails()) { $messages = $validator->getMessageBag(); return redirect()->back()->with('error', $messages->first()); } $appraisal->branch = $request->brances; $appraisal->employee = $request->employees; $appraisal->appraisal_date = $request->appraisal_date; $appraisal->rating = json_encode($request->rating, true); $appraisal->remark = $request->remark; $appraisal->save(); return redirect()->route('appraisal.index')->with('success', __('Appraisal successfully updated.')); } } public function destroy(Appraisal $appraisal) { if(\Auth::user()->can('Delete Appraisal')) { if($appraisal->created_by == \Auth::user()->creatorId()) { $appraisal->delete(); return redirect()->route('appraisal.index')->with('success', __('Appraisal successfully deleted.')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } else { return redirect()->back()->with('error', __('Permission denied.')); } } public function empByStar(Request $request) { $employee = Employee::find($request->employee); // $indicator = Indicator::where('branch',$employee->branch_id)->where('department',$employee->department_id)->first(); $indicator = Indicator::where('branch',$employee->branch_id)->where('department',$employee->department_id)->where('designation',$employee->designation_id)->first(); if ($indicator != null) { $ratings = json_decode($indicator->rating, true); }else { $ratings = null; } // $ratings = json_decode($indicator->rating, true); $performance_types = Performance_Type::where('created_by', '=', \Auth::user()->creatorId())->get(); $viewRender = view('appraisal.star', compact('ratings','performance_types'))->render(); return response()->json(array('success' => true, 'html'=>$viewRender)); } public function empByStar1(Request $request) { $employee = Employee::find($request->employee); $appraisal = Appraisal::find($request->appraisal); $indicator = Indicator::where('branch',$employee->branch_id)->where('department',$employee->department_id)->where('designation',$employee->designation_id)->first(); if ($indicator != null) { $ratings = json_decode($indicator->rating, true); }else { $ratings = null; } // $ratings = json_decode($indicator->rating, true); $rating = json_decode($appraisal->rating,true); $performance_types = Performance_Type::where('created_by', '=', \Auth::user()->creatorId())->get(); $viewRender = view('appraisal.staredit', compact('ratings','rating','performance_types'))->render(); return response()->json(array('success' => true, 'html'=>$viewRender)); } public function getemployee(Request $request) { $data['employee'] = Employee::where('branch_id',$request->branch_id)->get(); // $employees = Employee::where('branch_id', $request->branch)->get()->pluck('name', 'id')->toArray(); return response()->json($data); } } Controllers/SspayController.php000064400000027014150364311770012741 0ustar00secretKey = isset($payment_setting['sspay_secret_key']) ? $payment_setting['sspay_secret_key'] : ''; $this->categoryCode = isset($payment_setting['sspay_category_code']) ? $payment_setting['sspay_category_code'] : ''; $this->is_enabled = isset($payment_setting['is_sspay_enabled']) ? $payment_setting['is_sspay_enabled'] : 'off'; return $this; } public function SspayPaymentPrepare(Request $request) { try { $planID = \Illuminate\Support\Facades\Crypt::decrypt($request->plan_id); $payment_setting = Utility::getAdminPaymentSetting(); $plan = Plan::find($planID); if ($plan) { $get_amount = $plan->price; if (!empty($request->coupon)) { $coupons = Coupon::where('code', strtoupper($request->coupon))->where('is_active', '1')->first(); if (!empty($coupons)) { $usedCoupun = $coupons->used_coupon(); $discount_value = ($plan->price / 100) * $coupons->discount; $get_amount = $plan->price - $discount_value; if ($coupons->limit == $usedCoupun) { return redirect()->back()->with('error', __('This coupon code has expired.')); } } else { return redirect()->back()->with('error', __('This coupon code is invalid or has expired.')); } } if($get_amount <= 0){ $orderID = strtoupper(str_replace('.', '', uniqid('', true))); $user = auth()->user(); $statuses = 'success'; $order = new Order(); $order->order_id = $orderID; $order->name = $user->name; $order->card_number = ''; $order->card_exp_month = ''; $order->card_exp_year = ''; $order->plan_name = $plan->name; $order->plan_id = $plan->id; $order->price = $get_amount; $order->price_currency = $payment_setting['currency']; $order->payment_type = __('Sspay'); $order->payment_status = $statuses; $order->receipt = ''; $order->user_id = $user->id; $order->save(); $assignPlan = $user->assignPlan($plan->id); $coupons = Coupon::find($request->coupon_id); if ($request->has('coupon') && $request->coupon != '') { $coupons = Coupon::where('code', strtoupper($request->coupon))->where('is_active', '1')->first(); if (!empty($coupons)) { $userCoupon = new UserCoupon(); $userCoupon->user = $user->id; $userCoupon->coupon = $coupons->id; $userCoupon->order = $orderID; $userCoupon->save(); $usedCoupun = $coupons->used_coupon(); if ($coupons->limit <= $usedCoupun) { $coupons->is_active = 0; $coupons->save(); } } } if ($assignPlan['is_success']) { return redirect()->route('plans.index')->with('success', __('Plan activated Successfully.')); } else { return redirect()->route('plans.index')->with('error', __($assignPlan['error'])); } } $coupon = (empty($request->coupon)) ? "0" : $request->coupon; $this->callBackUrl = route('plan.sspay.callback', [$plan->id, $get_amount, $coupon]); $this->returnUrl = route('plan.sspay.callback', [$plan->id, $get_amount, $coupon]); $Date = date('d-m-Y'); $ammount = $get_amount; $billName = $plan->name; $description = $plan->name; $billExpiryDays = 3; $billExpiryDate = date('d-m-Y', strtotime($Date . ' + 3 days')); $billContentEmail = "Thank you for purchasing our product!"; $some_data = array( 'userSecretKey' => $this->secretKey, 'categoryCode' => $this->categoryCode, 'billName' => $billName, 'billDescription' => $description, 'billPriceSetting' => 1, 'billPayorInfo' => 1, 'billAmount' => 100 * $ammount, 'billReturnUrl' => $this->returnUrl, 'billCallbackUrl' => $this->callBackUrl, 'billExternalReferenceNo' => 'AFR341DFI', 'billTo' => \Auth::user()->name, 'billEmail' => \Auth::user()->email, 'billPhone' => '000000000', 'billSplitPayment' => 0, 'billSplitPaymentArgs' => '', 'billPaymentChannel' => '0', 'billContentEmail' => $billContentEmail, 'billChargeToCustomer' => 1, 'billExpiryDate' => $billExpiryDate, 'billExpiryDays' => $billExpiryDays ); $curl = curl_init(); curl_setopt($curl, CURLOPT_POST, 1); curl_setopt($curl, CURLOPT_URL, 'https://sspay.my/index.php/api/createBill'); curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); curl_setopt($curl, CURLOPT_POSTFIELDS, $some_data); $result = curl_exec($curl); $info = curl_getinfo($curl); curl_close($curl); $obj = json_decode($result); return redirect('https://sspay.my/' . $obj[0]->BillCode); } else { return redirect()->route('plans.index')->with('error', __('Plan is deleted.')); } } catch (\Exception $e) { return redirect()->route('plans.index')->with('error', __($e->getMessage())); } } public function SspayPlanGetPayment(Request $request, $planId, $getAmount, $couponCode) { $payment_setting = Utility::getAdminPaymentSetting(); if ($couponCode != 0) { $coupons = Coupon::where('code', strtoupper($couponCode))->where('is_active', '1')->first(); $request['coupon_id'] = $coupons->id; } else { $coupons = null; } $plan = Plan::find($planId); $user = auth()->user(); // $request['status_id'] = 1; // 1=success, 2=pending, 3=fail try { $orderID = strtoupper(str_replace('.', '', uniqid('', true))); if ($request->status_id == 3) { $statuses = 'Fail'; $order = new Order(); $order->order_id = $orderID; $order->name = $user->name; $order->card_number = ''; $order->card_exp_month = ''; $order->card_exp_year = ''; $order->plan_name = $plan->name; $order->plan_id = $plan->id; $order->price = $getAmount; $order->price_currency = $payment_setting['currency']; $order->payment_type = __('Sspay'); $order->payment_status = $statuses; $order->receipt = ''; $order->user_id = $user->id; $order->save(); return redirect()->route('plans.index')->with('error', __('Your Transaction is fail please try again')); } else if ($request->status_id == 2) { $statuses = 'pandding'; $order = new Order(); $order->order_id = $orderID; $order->name = $user->name; $order->card_number = ''; $order->card_exp_month = ''; $order->card_exp_year = ''; $order->plan_name = $plan->name; $order->plan_id = $plan->id; $order->price = $getAmount; $order->price_currency = $payment_setting['currency']; $order->payment_type = __('Sspay'); $order->payment_status = $statuses; $order->receipt = ''; $order->user_id = $user->id; $order->save(); return redirect()->route('plans.index')->with('error', __('Your transaction on pending')); } else if ($request->status_id == 1) { Utility::referralTransaction($plan); $statuses = 'success'; $order = new Order(); $order->order_id = $orderID; $order->name = $user->name; $order->card_number = ''; $order->card_exp_month = ''; $order->card_exp_year = ''; $order->plan_name = $plan->name; $order->plan_id = $plan->id; $order->price = $getAmount; $order->price_currency = $payment_setting['currency']; $order->payment_type = __('Sspay'); $order->payment_status = $statuses; $order->receipt = ''; $order->user_id = $user->id; $order->save(); $assignPlan = $user->assignPlan($plan->id); $coupons = Coupon::find($request->coupon_id); if (!empty($request->coupon_id)) { if (!empty($coupons)) { $userCoupon = new UserCoupon(); $userCoupon->user = $user->id; $userCoupon->coupon = $coupons->id; $userCoupon->order = $orderID; $userCoupon->save(); $usedCoupun = $coupons->used_coupon(); if ($coupons->limit <= $usedCoupun) { $coupons->is_active = 0; $coupons->save(); } } } if ($assignPlan['is_success']) { return redirect()->route('plans.index')->with('success', __('Plan activated Successfully.')); } else { return redirect()->route('plans.index')->with('error', __($assignPlan['error'])); } } else { return redirect()->route('plans.index')->with('error', __('Plan is deleted.')); } } catch (\Exception $e) { return redirect()->route('plans.index')->with('error', __($e->getMessage())); } } } Controllers/JobStageController.php000064400000006724150364311770013345 0ustar00can('Manage Job Stage')) { $stages = JobStage::where('created_by', '=', \Auth::user()->creatorId())->orderBy('order', 'asc')->get(); return view('jobStage.index', compact('stages')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } public function create() { return view('jobStage.create'); } public function store(Request $request) { if(\Auth::user()->can('Create Job Stage')) { $validator = \Validator::make( $request->all(), [ 'title' => 'required', ] ); if($validator->fails()) { $messages = $validator->getMessageBag(); return redirect()->back()->with('error', $messages->first()); } $jobStage = new JobStage(); $jobStage->title = $request->title; $jobStage->created_by = \Auth::user()->creatorId(); $jobStage->save(); return redirect()->back()->with('success', __('Job stage successfully created.')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } public function show(JobStage $jobStage) { // } public function edit(JobStage $jobStage) { return view('jobStage.edit', compact('jobStage')); } public function update(Request $request, JobStage $jobStage) { if(\Auth::user()->can('Edit Job Stage')) { $validator = \Validator::make( $request->all(), [ 'title' => 'required', ] ); if($validator->fails()) { $messages = $validator->getMessageBag(); return redirect()->back()->with('error', $messages->first()); } $jobStage->title = $request->title; $jobStage->created_by = \Auth::user()->creatorId(); $jobStage->save(); return redirect()->back()->with('success', __('Job stage successfully updated.')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } public function destroy(JobStage $jobStage) { if(\Auth::user()->can('Delete Job Stage')) { if($jobStage->created_by == \Auth::user()->creatorId()) { $jobStage->delete(); return redirect()->back()->with('success', __('Job stage successfully deleted.')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } else { return redirect()->back()->with('error', __('Permission denied.')); } } public function order(Request $request) { $post = $request->all(); foreach($post['order'] as $key => $item) { $stage = JobStage::where('id', '=', $item)->first(); $stage->order = $key; $stage->save(); } } } Controllers/ExpenseTypeController.php000064400000010221150364311770014103 0ustar00can('Manage Expense Type')) { $expensetypes = ExpenseType::where('created_by', '=', \Auth::user()->creatorId())->get(); return view('expensetype.index', compact('expensetypes')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } public function create() { if(\Auth::user()->can('Create Expense Type')) { return view('expensetype.create'); } else { return response()->json(['error' => __('Permission denied.')], 401); } } public function store(Request $request) { if(\Auth::user()->can('Create Expense Type')) { $validator = \Validator::make( $request->all(), [ 'name' => 'required', ] ); if($validator->fails()) { $messages = $validator->getMessageBag(); return redirect()->back()->with('error', $messages->first()); } $expensetype = new ExpenseType(); $expensetype->name = $request->name; $expensetype->created_by = \Auth::user()->creatorId(); $expensetype->save(); return redirect()->route('expensetype.index')->with('success', __('ExpenseType successfully created.')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } public function show(ExpenseType $expensetype) { return redirect()->route('expensetype.index'); } public function edit(ExpenseType $expensetype) { if(\Auth::user()->can('Edit Expense Type')) { if($expensetype->created_by == \Auth::user()->creatorId()) { return view('expensetype.edit', compact('expensetype')); } else { return response()->json(['error' => __('Permission denied.')], 401); } } else { return response()->json(['error' => __('Permission denied.')], 401); } } public function update(Request $request, ExpenseType $expensetype) { if(\Auth::user()->can('Edit Expense Type')) { if($expensetype->created_by == \Auth::user()->creatorId()) { $validator = \Validator::make( $request->all(), [ 'name' => 'required', ] ); if($validator->fails()) { $messages = $validator->getMessageBag(); return redirect()->back()->with('error', $messages->first()); } $expensetype->name = $request->name; $expensetype->save(); return redirect()->route('expensetype.index')->with('success', __('ExpenseType successfully updated.')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } else { return redirect()->back()->with('error', __('Permission denied.')); } } public function destroy(ExpenseType $expensetype) { if(\Auth::user()->can('Delete Expense Type')) { if($expensetype->created_by == \Auth::user()->creatorId()) { $expensetype->delete(); return redirect()->route('expensetype.index')->with('success', __('ExpenseType successfully deleted.')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } else { return redirect()->back()->with('error', __('Permission denied.')); } } } Controllers/TerminationTypeController.php000064400000011054150364311770014772 0ustar00can('Manage Termination Type')) { $terminationtypes = TerminationType::where('created_by', '=', \Auth::user()->creatorId())->get(); return view('terminationtype.index', compact('terminationtypes')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } public function create() { if(\Auth::user()->can('Create Termination Type')) { return view('terminationtype.create'); } else { return response()->json(['error' => __('Permission denied.')], 401); } } public function store(Request $request) { if(\Auth::user()->can('Create Termination Type')) { $validator = \Validator::make( $request->all(), [ 'name' => 'required', ] ); if($validator->fails()) { $messages = $validator->getMessageBag(); return redirect()->back()->with('error', $messages->first()); } $terminationtype = new TerminationType(); $terminationtype->name = $request->name; $terminationtype->created_by = \Auth::user()->creatorId(); $terminationtype->save(); return redirect()->route('terminationtype.index')->with('success', __('TerminationType successfully created.')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } public function show(TerminationType $terminationtype) { return redirect()->route('terminationtype.index'); } public function edit(TerminationType $terminationtype) { if(\Auth::user()->can('Edit Termination Type')) { if($terminationtype->created_by == \Auth::user()->creatorId()) { return view('terminationtype.edit', compact('terminationtype')); } else { return response()->json(['error' => __('Permission denied.')], 401); } } else { return response()->json(['error' => __('Permission denied.')], 401); } } public function update(Request $request, TerminationType $terminationtype) { if(\Auth::user()->can('Edit Termination Type')) { if($terminationtype->created_by == \Auth::user()->creatorId()) { $validator = \Validator::make( $request->all(), [ 'name' => 'required|max:20', ] ); $terminationtype->name = $request->name; $terminationtype->save(); return redirect()->route('terminationtype.index')->with('success', __('TerminationType successfully updated.')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } else { return redirect()->back()->with('error', __('Permission denied.')); } } public function destroy(TerminationType $terminationtype) { if(\Auth::user()->can('Delete Termination Type')) { if($terminationtype->created_by == \Auth::user()->creatorId()) { $termination = Termination::where('termination_type',$terminationtype->id)->get(); if(count($termination) == 0) { $terminationtype->delete(); } else { return redirect()->route('terminationtype.index')->with('error', __('This TerminationType has Termination. Please remove the Termination from this TerminationType.')); } return redirect()->route('terminationtype.index')->with('success', __('TerminationType successfully deleted.')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } else { return redirect()->back()->with('error', __('Permission denied.')); } } } Controllers/IyziPayController.php000064400000021435150364311770013241 0ustar00plan_id); $authuser = \Auth::user(); $adminPaymentSettings = Utility::getAdminPaymentSetting(); $iyzipay_key = $adminPaymentSettings['iyzipay_public_key']; $iyzipay_secret = $adminPaymentSettings['iyzipay_secret_key']; $iyzipay_mode = $adminPaymentSettings['iyzipay_mode']; $currency = $adminPaymentSettings['currency']; $plan = Plan::find($planID); $coupon_id = '0'; $price = $plan->price; $coupon_code = null; $discount_value = null; $coupons = Coupon::where('code', $request->coupon)->where('is_active', '1')->first(); if ($coupons) { $coupon_code = $coupons->code; $usedCoupun = $coupons->used_coupon(); if ($coupons->limit == $usedCoupun) { $res_data['error'] = __('This coupon code has expired.'); } else { $discount_value = ($plan->price / 100) * $coupons->discount; $price = $price - $discount_value; if ($price < 0) { $price = $plan->price; } $coupon_id = $coupons->id; } } if ($price <= 0) { $order_id = strtoupper(str_replace('.', '', uniqid('', true))); $user = \Auth::user(); if ($request->has('coupon') && $request->coupon != '') { $coupons = Coupon::where('code', strtoupper($request->coupon))->where('is_active', '1')->first(); if (!empty($coupons)) { $userCoupon = new UserCoupon(); $userCoupon->user = $user->id; $userCoupon->coupon = $coupons->id; $userCoupon->order = $order_id; $userCoupon->save(); $usedCoupun = $coupons->used_coupon(); if ($coupons->limit <= $usedCoupun) { $coupons->is_active = 0; $coupons->save(); } } } $order = new Order(); $order->order_id = $order_id; $order->name = $user->name; $order->card_number = ''; $order->card_exp_month = ''; $order->card_exp_year = ''; $order->plan_name = $plan->name; $order->plan_id = $plan->id; $order->price = $price; $order->price_currency = $adminPaymentSettings['currency']; $order->payment_type = __('Iyzipay'); $order->payment_status = 'success'; $order->txn_id = ''; $order->receipt = ''; $order->user_id = $user->id; $order->save(); $assignPlan = $user->assignPlan($plan->id); return redirect()->route('plans.index')->with('success', __('Plan activated Successfully.')); } $res_data['total_price'] = $price; $res_data['coupon'] = $coupon_id; // set your Iyzico API credentials try { $setBaseUrl = ($iyzipay_mode == 'sandbox') ? 'https://sandbox-api.iyzipay.com' : 'https://api.iyzipay.com'; $options = new \Iyzipay\Options(); $options->setApiKey($iyzipay_key); $options->setSecretKey($iyzipay_secret); $options->setBaseUrl($setBaseUrl); // or "https://api.iyzipay.com" for production $ipAddress = Http::get('https://ipinfo.io/?callback=')->json(); $address = ($authuser->address) ? $authuser->address : 'Nidakule Göztepe, Merdivenköy Mah. Bora Sok. No:1'; // create a new payment request $request = new \Iyzipay\Request\CreateCheckoutFormInitializeRequest(); $request->setLocale('en'); $request->setPrice($res_data['total_price']); $request->setPaidPrice($res_data['total_price']); $request->setCurrency($currency); $request->setCallbackUrl(route('iyzipay.payment.callback',[$plan->id,$price,$coupon_code])); $request->setEnabledInstallments(array(1)); $request->setPaymentGroup(\Iyzipay\Model\PaymentGroup::PRODUCT); $buyer = new \Iyzipay\Model\Buyer(); $buyer->setId($authuser->id); $buyer->setName(explode(' ', $authuser->name)[0]); $buyer->setSurname(explode(' ', $authuser->name)[0]); $buyer->setGsmNumber("+" . $authuser->dial_code . $authuser->phone); $buyer->setEmail($authuser->email); $buyer->setIdentityNumber(rand(0, 999999)); $buyer->setLastLoginDate("2023-03-05 12:43:35"); $buyer->setRegistrationDate("2023-04-21 15:12:09"); $buyer->setRegistrationAddress($address); $buyer->setIp($ipAddress['ip']); $buyer->setCity($ipAddress['city']); $buyer->setCountry($ipAddress['country']); $buyer->setZipCode($ipAddress['postal']); $request->setBuyer($buyer); $shippingAddress = new \Iyzipay\Model\Address(); $shippingAddress->setContactName($authuser->name); $shippingAddress->setCity($ipAddress['city']); $shippingAddress->setCountry($ipAddress['country']); $shippingAddress->setAddress($address); $shippingAddress->setZipCode($ipAddress['postal']); $request->setShippingAddress($shippingAddress); $billingAddress = new \Iyzipay\Model\Address(); $billingAddress->setContactName($authuser->name); $billingAddress->setCity($ipAddress['city']); $billingAddress->setCountry($ipAddress['country']); $billingAddress->setAddress($address); $billingAddress->setZipCode($ipAddress['postal']); $request->setBillingAddress($billingAddress); $basketItems = array(); $firstBasketItem = new \Iyzipay\Model\BasketItem(); $firstBasketItem->setId("BI101"); $firstBasketItem->setName("Binocular"); $firstBasketItem->setCategory1("Collectibles"); $firstBasketItem->setCategory2("Accessories"); $firstBasketItem->setItemType(\Iyzipay\Model\BasketItemType::PHYSICAL); $firstBasketItem->setPrice($res_data['total_price']); $basketItems[0] = $firstBasketItem; $request->setBasketItems($basketItems); $checkoutFormInitialize = \Iyzipay\Model\CheckoutFormInitialize::create($request, $options); return redirect()->to($checkoutFormInitialize->getpaymentPageUrl()); } catch (\Exception $e) { return redirect()->route('plans.index')->with('errors', $e->getMessage()); } } public function iyzipayCallback(Request $request,$planID,$price,$coupanCode = null) { $plan = Plan::find($planID); $adminPaymentSettings = Utility::getAdminPaymentSetting(); $user = \Auth::user(); Utility::referralTransaction($plan); $order = new Order(); $order->order_id = time(); $order->name = $user->name; $order->card_number = ''; $order->card_exp_month = ''; $order->card_exp_year = ''; $order->plan_name = $plan->name; $order->plan_id = $plan->id; $order->price = $price; $order->price_currency = $adminPaymentSettings['currency']; $order->txn_id = time(); $order->payment_type = __('Iyzipay'); $order->payment_status = 'success'; $order->txn_id = ''; $order->receipt = ''; $order->user_id = $user->id; $order->save(); $user = User::find($user->id); $coupons = Coupon::where('code', $coupanCode)->where('is_active', '1')->first(); if (!empty($coupons)) { $userCoupon = new UserCoupon(); $userCoupon->user = $user->id; $userCoupon->coupon = $coupons->id; $userCoupon->order = $order->order_id; $userCoupon->save(); $usedCoupun = $coupons->used_coupon(); if ($coupons->limit <= $usedCoupun) { $coupons->is_active = 0; $coupons->save(); } } $assignPlan = $user->assignPlan($plan->id); if ($assignPlan['is_success']) { return redirect()->route('plans.index')->with('success', __('Plan activated Successfully.')); } else { return redirect()->route('plans.index')->with('error', __($assignPlan['error'])); } } } Controllers/WarningController.php000064400000020710150364311770013243 0ustar00can('Manage Warning')) { if(Auth::user()->type == 'employee') { $emp = Employee::where('user_id', '=', \Auth::user()->id)->first(); $warnings = Warning::where('warning_by', '=', $emp->id)->get(); } else { $warnings = Warning::where('created_by', '=', \Auth::user()->creatorId())->get(); } return view('warning.index', compact('warnings')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } public function create() { if(\Auth::user()->can('Create Warning')) { if(Auth::user()->type == 'employee') { $user = \Auth::user(); $current_employee = Employee::where('user_id', $user->id)->get()->pluck('name', 'id'); $employees = Employee::where('user_id', '!=', $user->id)->get()->pluck('name', 'id'); } else { $user = \Auth::user(); $current_employee = Employee::where('user_id', $user->id)->get()->pluck('name', 'id'); $employees = Employee::where('created_by', \Auth::user()->creatorId())->get()->pluck('name', 'id'); } return view('warning.create', compact('employees', 'current_employee')); } else { return response()->json(['error' => __('Permission denied.')], 401); } } public function store(Request $request) { if(\Auth::user()->can('Create Warning')) { if(\Auth::user()->type != 'employee') { $validator = \Validator::make( $request->all(), [ 'warning_by' => 'required', ] ); } $validator = \Validator::make( $request->all(), [ 'warning_to' => 'required', 'subject' => 'required', 'warning_date' => 'required', ] ); if($validator->fails()) { $messages = $validator->getMessageBag(); return redirect()->back()->with('error', $messages->first()); } $warning = new Warning(); if(\Auth::user()->type == 'employee') { $emp = Employee::where('user_id', '=', \Auth::user()->id)->first(); $warning->warning_by = $emp->id; } else { $warning->warning_by = $request->warning_by; } $warning->warning_to = $request->warning_to; $warning->subject = $request->subject; $warning->warning_date = $request->warning_date; $warning->description = $request->description; $warning->created_by = \Auth::user()->creatorId(); $warning->save(); $setings = Utility::settings(); if($setings['employee_warning'] == 1) { $employee = Employee::find($warning->warning_to); $uArr = [ 'employee_warning_name'=>$employee->name, 'warning_subject'=>$request->subject, 'warning_description'=>$request->description, ]; $resp = Utility::sendEmailTemplate('employee_warning', [$employee->email], $uArr); return redirect()->route('warning.index')->with('success', __('Warning successfully created.') . ((!empty($resp) && $resp['is_success'] == false && !empty($resp['error'])) ? '
' . $resp['error'] . '' : '')); } return redirect()->route('warning.index')->with('success', __('Warning successfully created.')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } public function show(Warning $warning) { return redirect()->route('warning.index'); } public function edit(Warning $warning) { if(\Auth::user()->can('Edit Warning')) { if(Auth::user()->type == 'employee') { $user = \Auth::user(); $current_employee = Employee::where('user_id', $user->id)->get()->pluck('name', 'id'); $employees = Employee::where('user_id', '!=', $user->id)->get()->pluck('name', 'id'); } else { $user = \Auth::user(); $current_employee = Employee::where('user_id', $user->id)->get()->pluck('name', 'id'); $employees = Employee::where('created_by', \Auth::user()->creatorId())->get()->pluck('name', 'id'); } if($warning->created_by == \Auth::user()->creatorId()) { return view('warning.edit', compact('warning', 'employees', 'current_employee')); } else { return response()->json(['error' => __('Permission denied.')], 401); } } else { return response()->json(['error' => __('Permission denied.')], 401); } } public function update(Request $request, Warning $warning) { if(\Auth::user()->can('Edit Warning')) { if($warning->created_by == \Auth::user()->creatorId()) { if(\Auth::user()->type != 'employee') { $validator = \Validator::make( $request->all(), [ 'warning_by' => 'required', ] ); } $validator = \Validator::make( $request->all(), [ 'warning_to' => 'required', 'subject' => 'required', 'warning_date' => 'required', ] ); if($validator->fails()) { $messages = $validator->getMessageBag(); return redirect()->back()->with('error', $messages->first()); } if(\Auth::user()->type == 'employee') { $emp = Employee::where('user_id', '=', \Auth::user()->id)->first(); $warning->warning_by = $emp->id; } else { $warning->warning_by = $request->warning_by; } $warning->warning_to = $request->warning_to; $warning->subject = $request->subject; $warning->warning_date = $request->warning_date; $warning->description = $request->description; $warning->save(); return redirect()->route('warning.index')->with('success', __('Warning successfully updated.')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } else { return redirect()->back()->with('error', __('Permission denied.')); } } public function destroy(Warning $warning) { if(\Auth::user()->can('Delete Warning')) { if($warning->created_by == \Auth::user()->creatorId()) { $warning->delete(); return redirect()->route('warning.index')->with('success', __('Warning successfully deleted.')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } else { return redirect()->back()->with('error', __('Permission denied.')); } } } Controllers/SetSalaryController.php000064400000025462150364311770013556 0ustar00can('Manage Set Salary')) { $employees = Employee::where( [ 'created_by' => \Auth::user()->creatorId(), ] )->get(); return view('setsalary.index', compact('employees')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } public function edit($id) { if (\Auth::user()->can('Edit Set Salary')) { $payslip_type = PayslipType::where('created_by', \Auth::user()->creatorId())->get()->pluck('name', 'id'); $allowance_options = AllowanceOption::where('created_by', \Auth::user()->creatorId())->get()->pluck('name', 'id'); $loan_options = LoanOption::where('created_by', \Auth::user()->creatorId())->get()->pluck('name', 'id'); $deduction_options = DeductionOption::where('created_by', \Auth::user()->creatorId())->get()->pluck('name', 'id'); if (\Auth::user()->type == 'employee') { $currentEmployee = Employee::where('user_id', '=', \Auth::user()->id)->first(); $allowances = Allowance::where('employee_id', $currentEmployee->id)->get(); $commissions = Commission::where('employee_id', $currentEmployee->id)->get(); $loans = Loan::where('employee_id', $currentEmployee->id)->get(); $saturationdeductions = SaturationDeduction::where('employee_id', $currentEmployee->id)->get(); $otherpayments = OtherPayment::where('employee_id', $currentEmployee->id)->get(); $overtimes = Overtime::where('employee_id', $currentEmployee->id)->get(); $employee = Employee::where('user_id', '=', \Auth::user()->id)->first(); return view('setsalary.employee_salary', compact('employee', 'payslip_type', 'allowance_options', 'commissions', 'loan_options', 'overtimes', 'otherpayments', 'saturationdeductions', 'loans', 'deduction_options', 'allowances')); } else { $allowances = Allowance::where('employee_id', $id)->get(); $commissions = Commission::where('employee_id', $id)->get(); $loans = Loan::where('employee_id', $id)->get(); $saturationdeductions = SaturationDeduction::where('employee_id', $id)->get(); $otherpayments = OtherPayment::where('employee_id', $id)->get(); $overtimes = Overtime::where('employee_id', $id)->get(); $employee = Employee::find($id); return view('setsalary.edit', compact('employee', 'payslip_type', 'allowance_options', 'commissions', 'loan_options', 'overtimes', 'otherpayments', 'saturationdeductions', 'loans', 'deduction_options', 'allowances')); } } else { return redirect()->back()->with('error', __('Permission denied.')); } } public function show($id) { try { $id = Crypt::decrypt($id); } catch (\Throwable $th) { return redirect()->back()->with('error', __('Permission Denied.')); } $payslip_type = PayslipType::where('created_by', \Auth::user()->creatorId())->get()->pluck('name', 'id'); $allowance_options = AllowanceOption::where('created_by', \Auth::user()->creatorId())->get()->pluck('name', 'id'); $loan_options = LoanOption::where('created_by', \Auth::user()->creatorId())->get()->pluck('name', 'id'); $deduction_options = DeductionOption::where('created_by', \Auth::user()->creatorId())->get()->pluck('name', 'id'); if (\Auth::user()->type == 'employee') { $currentEmployee = Employee::where('user_id', '=', \Auth::user()->id)->first(); $allowances = Allowance::where('employee_id', $currentEmployee->id)->get(); $commissions = Commission::where('employee_id', $currentEmployee->id)->get(); $loans = Loan::where('employee_id', $currentEmployee->id)->get(); $saturationdeductions = SaturationDeduction::where('employee_id', $currentEmployee->id)->get(); $otherpayments = OtherPayment::where('employee_id', $currentEmployee->id)->get(); $overtimes = Overtime::where('employee_id', $currentEmployee->id)->get(); $employee = Employee::where('user_id', '=', \Auth::user()->id)->first(); foreach ($allowances as $value) { if ($value->type == 'percentage') { $employee = Employee::find($value->employee_id); $empsal = $value->amount * $employee->salary / 100; $value->tota_allow = $empsal; } } foreach ($commissions as $value) { if ($value->type == 'percentage') { $employee = Employee::find($value->employee_id); $empsal = $value->amount * $employee->salary / 100; $value->tota_allow = $empsal; } } foreach ($loans as $value) { if ($value->type == 'percentage') { $employee = Employee::find($value->employee_id); $empsal = $value->amount * $employee->salary / 100; $value->tota_allow = $empsal; } } foreach ($saturationdeductions as $value) { if ($value->type == 'percentage') { $employee = Employee::find($value->employee_id); $empsal = $value->amount * $employee->salary / 100; $value->tota_allow = $empsal; } } foreach ($otherpayments as $value) { if ($value->type == 'percentage') { $employee = Employee::find($value->employee_id); $empsal = $value->amount * $employee->salary / 100; $value->tota_allow = $empsal; } } return view('setsalary.employee_salary', compact('employee', 'payslip_type', 'allowance_options', 'commissions', 'loan_options', 'overtimes', 'otherpayments', 'saturationdeductions', 'loans', 'deduction_options', 'allowances')); } else { $allowances = Allowance::where('employee_id', $id)->get(); $commissions = Commission::where('employee_id', $id)->get(); $loans = Loan::where('employee_id', $id)->get(); $saturationdeductions = SaturationDeduction::where('employee_id', $id)->get(); $otherpayments = OtherPayment::where('employee_id', $id)->get(); $overtimes = Overtime::where('employee_id', $id)->get(); $employee = Employee::find($id); foreach ($allowances as $value) { if ($value->type == 'percentage') { $employee = Employee::find($value->employee_id); $empsal = $value->amount * $employee->salary / 100; $value->tota_allow = $empsal; } } foreach ($commissions as $value) { if ($value->type == 'percentage') { $employee = Employee::find($value->employee_id); $empsal = $value->amount * $employee->salary / 100; $value->tota_allow = $empsal; } } foreach ($loans as $value) { if ($value->type == 'percentage') { $employee = Employee::find($value->employee_id); $empsal = $value->amount * $employee->salary / 100; $value->tota_allow = $empsal; } } foreach ($saturationdeductions as $value) { if ($value->type == 'percentage') { $employee = Employee::find($value->employee_id); $empsal = $value->amount * $employee->salary / 100; $value->tota_allow = $empsal; } } foreach ($otherpayments as $value) { if ($value->type == 'percentage') { $employee = Employee::find($value->employee_id); $empsal = $value->amount * $employee->salary / 100; $value->tota_allow = $empsal; } } return view('setsalary.employee_salary', compact('employee', 'payslip_type', 'allowance_options', 'commissions', 'loan_options', 'overtimes', 'otherpayments', 'saturationdeductions', 'loans', 'deduction_options', 'allowances')); } } public function employeeUpdateSalary(Request $request, $id) { $validator = \Validator::make( $request->all(), [ 'salary_type' => 'required', 'salary' => 'required', 'account_type' => 'required', ] ); if ($validator->fails()) { $messages = $validator->getMessageBag(); return redirect()->back()->with('error', $messages->first()); } $employee = Employee::findOrFail($id); $input = $request->all(); $employee->fill($input)->save(); return redirect()->back()->with('success', 'Employee Salary Updated.'); } public function employeeSalary() { if (\Auth::user()->type == "employee") { $employees = Employee::where('user_id', \Auth::user()->id)->get(); return view('setsalary.index', compact('employees')); } } public function employeeBasicSalary($id) { $payslip_type = PayslipType::where('created_by', \Auth::user()->creatorId())->get()->pluck('name', 'id'); $payslip_type->prepend('Select Payslip Type', ''); $accounts = AccountList::where('created_by', \Auth::user()->creatorId())->get()->pluck('account_name', 'id'); $accounts->prepend('Select Account Type', ''); $employee = Employee::find($id); return view('setsalary.basic_salary', compact('employee', 'payslip_type', 'accounts')); } } Controllers/ContractTypeController.php000064400000013327150364311770014263 0ustar00middleware( [ 'auth', 'XSS', ] ); } /** * Display a listing of the resource. * * @return \Illuminate\Http\Response */ public function index() { if(\Auth::user()->can('Manage Contract Type')) { $contractTypes = ContractType::where('created_by', '=', \Auth::user()->creatorId())->get(); return view('contract_type.index')->with('contractTypes', $contractTypes); } else { return redirect()->back()->with('error', __('Permission Denied.')); } } /** * Show the form for creating a new resource. * * @return \Illuminate\Http\Response */ public function create() { if(\Auth::user()->can('Create Contract Type')) { return view('contract_type.create'); } else { return response()->json(['error' => __('Permission Denied.')], 401); } } /** * Store a newly created resource in storage. * * @param \Illuminate\Http\Request $request * * @return \Illuminate\Http\Response */ public function store(Request $request) { if(\Auth::user()->can('Create Contract Type')) { $validator = \Validator::make( $request->all(), [ 'name' => 'required|max:20', ] ); if($validator->fails()) { $messages = $validator->getMessageBag(); return redirect()->route('contract_type.index')->with('error', $messages->first()); } $contractType = new ContractType(); $contractType->name = $request->name; $contractType->created_by = \Auth::user()->creatorId(); $contractType->save(); return redirect()->route('contract_type.index')->with('success', __('Contract Type successfully created!')); } else { return redirect()->back()->with('error', __('Permission Denied.')); } } /** * Display the specified resource. * * @param \App\ContractType $contractType * * @return \Illuminate\Http\Response */ public function show(ContractType $contractType) { return redirect()->route('contract_type.index'); } /** * Show the form for editing the specified resource. * * @param \App\ContractType $contractType * * @return \Illuminate\Http\Response */ public function edit(ContractType $contractType) { if(\Auth::user()->can('Edit Contract Type')) { if($contractType->created_by == \Auth::user()->creatorId()) { return view('contract_type.edit', compact('contractType')); } else { return response()->json(['error' => __('Permission Denied.')], 401); } } else { return response()->json(['error' => __('Permission Denied.')], 401); } } /** * Update the specified resource in storage. * * @param \Illuminate\Http\Request $request * @param \App\ContractType $contractType * * @return \Illuminate\Http\Response */ public function update(Request $request, ContractType $contractType) { // return redirect()->back()->with('error', __('This operation is not perform due to demo mode.')); if(\Auth::user()->can('Edit Contract Type')) { if($contractType->created_by == \Auth::user()->creatorId()) { $validator = \Validator::make( $request->all(), [ 'name' => 'required|max:20', ] ); if($validator->fails()) { $messages = $validator->getMessageBag(); return redirect()->route('contract_type.index')->with('error', $messages->first()); } $contractType->name = $request->name; $contractType->save(); return redirect()->route('contract_type.index')->with('success', __('Contract Type successfully updated!')); } else { return redirect()->back()->with('error', __('Permission Denied.')); } } else { return redirect()->back()->with('error', __('Permission Denied.')); } } /** * Remove the specified resource from storage. * * @param \App\ContractType $contractType * * @return \Illuminate\Http\Response */ public function destroy(ContractType $contractType) { // return redirect()->back()->with('error', __('This operation is not perform due to demo mode.')); if(\Auth::user()->can('Delete Contract Type')) { if($contractType->created_by == \Auth::user()->creatorId()) { $contractType->delete(); return redirect()->route('contract_type.index')->with('success', __('Contract Type successfully deleted!')); } else { return redirect()->back()->with('error', __('Permission Denied.')); } } else { return redirect()->back()->with('error', __('Permission Denied.')); } } } Controllers/AnnouncementController.php000064400000031552150364311770014276 0ustar00can('Manage Announcement')) { if (Auth::user()->type == 'employee') { $current_employee = Employee::where('user_id', '=', \Auth::user()->id)->first(); $announcements = Announcement::orderBy('announcements.id', 'desc')->leftjoin('announcement_employees', 'announcements.id', '=', 'announcement_employees.announcement_id')->where('announcement_employees.employee_id', '=', $current_employee->id)->orWhere( function ($q) { $q->where('announcements.department_id', '["0"]')->where('announcements.employee_id', '["0"]'); } )->get(); } else { $current_employee = Employee::where('user_id', '=', \Auth::user()->id)->first(); $announcements = Announcement::where('created_by', '=', \Auth::user()->creatorId())->get(); } return view('announcement.index', compact('announcements', 'current_employee')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } public function create() { if (\Auth::user()->can('Create Announcement')) { $employees = Employee::where('created_by', \Auth::user()->creatorId())->get()->pluck('name', 'id'); $employees->prepend('All', 0); // $branch = Branch::where('created_by', \Auth::user()->creatorId())->get()->pluck('name', 'id'); // $branch->prepend('All', 0); // $departments = Department::where('created_by', \Auth::user()->creatorId())->get()->pluck('name', 'id'); // $departments->prepend('All', 0); // $employees = Employee::where('created_by', '=', \Auth::user()->creatorId())->get()->pluck('name', 'id'); $branch = Branch::where('created_by', '=', Auth::user()->creatorId())->get(); $departments = Department::where('created_by', '=', Auth::user()->creatorId())->get(); return view('announcement.create', compact('employees', 'branch', 'departments')); } else { return response()->json(['error' => __('Permission denied.')], 401); } } public function store(Request $request) { if (\Auth::user()->can('Create Announcement')) { $validator = \Validator::make( $request->all(), [ 'title' => 'required', 'start_date' => 'required', 'end_date' => 'required|after_or_equal:start_date', 'branch_id' => 'required', 'department_id' => 'required', 'employee_id' => 'required', ] ); if ($validator->fails()) { $messages = $validator->getMessageBag(); return redirect()->back()->with('error', $messages->first()); } $announcement = new Announcement(); $announcement->title = $request->title; $announcement->start_date = $request->start_date; $announcement->end_date = $request->end_date; $announcement->branch_id = $request->branch_id; $announcement->department_id = implode(",", $request->department_id); $announcement->employee_id = implode(",", $request->employee_id); // $announcement->department_id = json_encode($request->department_id); // $announcement->employee_id = json_encode($request->employee_id); $announcement->description = $request->description; $announcement->created_by = \Auth::user()->creatorId(); $announcement->save(); // slack $setting = Utility::settings(\Auth::user()->creatorId()); $branch = Branch::find($request->branch_id); if (isset($setting['Announcement_notification']) && $setting['Announcement_notification'] == 1) { // $msg = $request->title . ' ' . __("announcement created for branch") . ' ' . $branch->name . ' ' . __("from") . ' ' . $request->start_date . ' ' . __("to") . ' ' . $request->end_date . '.'; $uArr = [ 'announcement_title' => $request->title, 'branch_name' => $branch->name, 'start_date' => $request->start_date, 'end_date' => $request->end_date, ]; Utility::send_slack_msg('new_announcement', $uArr); } // telegram $setting = Utility::settings(\Auth::user()->creatorId()); $branch = Branch::find($request->branch_id); if (isset($setting['telegram_Announcement_notification']) && $setting['telegram_Announcement_notification'] == 1) { // $msg = $request->title . ' ' . __("announcement created for branch") . ' ' . $branch->name . ' ' . __("from") . ' ' . $request->start_date . ' ' . __("to") . ' ' . $request->end_date . '.'; $uArr = [ 'announcement_title' => $request->title, 'branch_name' => $branch->name, 'start_date' => $request->start_date, 'end_date' => $request->end_date, ]; Utility::send_telegram_msg('new_announcement', $uArr); } // twilio $setting = Utility::settings(\Auth::user()->creatorId()); $branch = Branch::find($request->branch_id); $departments = Department::where('branch_id', $request->branch_id)->first(); $employees = Employee::where('branch_id', $request->branch_id)->first(); if (isset($setting['twilio_announcement_notification']) && $setting['twilio_announcement_notification'] == 1) { // $employeess = Employee::whereIn('branch_id', $request->employee_id)->get(); // foreach ($employeess as $key => $employee) { // $msg = $request->title . ' ' . __("announcement created for branch") . ' ' . $branch->name . ' ' . __("from") . ' ' . $request->start_date . ' ' . __("to") . ' ' . $request->end_date . '.'; $uArr = [ 'announcement_title' => $request->title, 'branch_name' => $branch->name, 'start_date' => $request->start_date, 'end_date' => $request->end_date, ]; Utility::send_twilio_msg($employees->phone, 'new_announcement', $uArr); // } } if (in_array('0', $request->employee_id)) { $departmentEmployee = Employee::whereIn('department_id', $request->department_id)->get()->pluck('id'); $departmentEmployee = $departmentEmployee; } else { $departmentEmployee = $request->employee_id; } foreach ($departmentEmployee as $employee) { $announcementEmployee = new AnnouncementEmployee(); $announcementEmployee->announcement_id = $announcement->id; $announcementEmployee->employee_id = $employee; $announcementEmployee->created_by = \Auth::user()->creatorId(); $announcementEmployee->save(); } //webhook $module = 'New Announcement'; $webhook = Utility::webhookSetting($module); if ($webhook) { $parameter = json_encode($announcement); // 1 parameter is URL , 2 parameter is data , 3 parameter is method $status = Utility::WebhookCall($webhook['url'], $parameter, $webhook['method']); if ($status == true) { return redirect()->back()->with('success', __('Announcement successfully created.')); } else { return redirect()->back()->with('error', __('Webhook call failed.')); } } return redirect()->route('announcement.index')->with('success', __('Announcement successfully created.')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } public function show(Announcement $announcement) { return redirect()->route('announcement.index'); } public function edit($announcement) { if (\Auth::user()->can('Edit Announcement')) { $announcement = Announcement::find($announcement); if ($announcement->created_by == Auth::user()->creatorId()) { $branch = Branch::where('created_by', \Auth::user()->creatorId())->get()->pluck('name', 'id'); $departments = Department::where('created_by', \Auth::user()->creatorId())->get()->pluck('name', 'id'); $employees = Employee::where('created_by', \Auth::user()->creatorId())->get()->pluck('name', 'id'); return view('announcement.edit', compact('announcement', 'branch', 'departments', 'employees')); } else { return response()->json(['error' => __('Permission denied.')], 401); } } else { return response()->json(['error' => __('Permission denied.')], 401); } } public function update(Request $request, Announcement $announcement) { if (\Auth::user()->can('Edit Announcement')) { if ($announcement->created_by == \Auth::user()->creatorId()) { $validator = \Validator::make( $request->all(), [ 'title' => 'required', 'start_date' => 'required', 'end_date' => 'required', 'branch_id' => 'required', 'department_id' => 'required', 'employee_id' => 'required', ] ); if ($validator->fails()) { $messages = $validator->getMessageBag(); return redirect()->back()->with('error', $messages->first()); } $announcement->title = $request->title; $announcement->start_date = $request->start_date; $announcement->end_date = $request->end_date; $announcement->branch_id = $request->branch_id; $announcement->department_id = implode(",", $request->department_id); $announcement->employee_id = implode(",", $request->employee_id); $announcement->description = $request->description; $announcement->save(); return redirect()->route('announcement.index')->with('success', __('Announcement successfully updated.')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } else { return redirect()->back()->with('error', __('Permission denied.')); } } public function destroy(Announcement $announcement) { if (\Auth::user()->can('Delete Announcement')) { if ($announcement->created_by == \Auth::user()->creatorId()) { $announcement->delete(); return redirect()->route('announcement.index')->with('success', __('Announcement successfully deleted.')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } else { return redirect()->back()->with('error', __('Permission denied.')); } } public function getdepartment(Request $request) { if ($request->branch_id == 0) { $departments = Department::where('created_by', '=', \Auth::user()->creatorId())->get()->pluck('name', 'id')->toArray(); } else { $departments = Department::where('created_by', '=', \Auth::user()->creatorId())->where('branch_id', $request->branch_id)->get()->pluck('name', 'id')->toArray(); } return response()->json($departments); } public function getemployee(Request $request) { if ($request->department_id) { $employees = Employee::where('created_by', '=', \Auth::user()->creatorId())->where('department_id', $request->department_id)->get()->pluck('name', 'id'); } else { $employees = Employee::where('created_by', '=', \Auth::user()->creatorId())->get()->pluck('name', 'id'); } return response()->json($employees); } } Controllers/OtherPaymentController.php000064400000011500150364311770014252 0ustar00can('Create Other Payment')) { $validator = \Validator::make( $request->all(), [ 'employee_id' => 'required', 'title' => 'required', 'amount' => 'required', ] ); if($validator->fails()) { $messages = $validator->getMessageBag(); return redirect()->back()->with('error', $messages->first()); } $otherpayment = new OtherPayment(); $otherpayment->employee_id = $request->employee_id; $otherpayment->title = $request->title; $otherpayment->type = $request->type; $otherpayment->amount = $request->amount; $otherpayment->created_by = \Auth::user()->creatorId(); $otherpayment->save(); if( $otherpayment->type == 'percentage' ) { $employee = Employee::find($otherpayment->employee_id); $loansal = $otherpayment->amount * $employee->salary / 100; } return redirect()->back()->with('success', __('OtherPayment successfully created.')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } public function show(OtherPayment $otherpayment) { return redirect()->route('commision.index'); } public function edit($otherpayment) { $otherpayment = OtherPayment::find($otherpayment); if(\Auth::user()->can('Edit Other Payment')) { if($otherpayment->created_by == \Auth::user()->creatorId()) { $otherpaytypes=OtherPayment::$otherPaymenttype; return view('otherpayment.edit', compact('otherpayment','otherpaytypes')); } else { return response()->json(['error' => __('Permission denied.')], 401); } } else { return response()->json(['error' => __('Permission denied.')], 401); } } public function update(Request $request, OtherPayment $otherpayment) { if(\Auth::user()->can('Edit Other Payment')) { if($otherpayment->created_by == \Auth::user()->creatorId()) { $validator = \Validator::make( $request->all(), [ 'title' => 'required', 'amount' => 'required', ] ); if($validator->fails()) { $messages = $validator->getMessageBag(); return redirect()->back()->with('error', $messages->first()); } $otherpayment->title = $request->title; $otherpayment->type = $request->type; $otherpayment->amount = $request->amount; $otherpayment->save(); if( $otherpayment->type == 'percentage' ) { $employee = Employee::find($otherpayment->employee_id); $loansal = $otherpayment->amount * $employee->salary / 100; } return redirect()->back()->with('success', __('OtherPayment successfully updated.')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } else { return redirect()->back()->with('error', __('Permission denied.')); } } public function destroy(OtherPayment $otherpayment) { if(\Auth::user()->can('Delete Other Payment')) { if($otherpayment->created_by == \Auth::user()->creatorId()) { $otherpayment->delete(); return redirect()->back()->with('success', __('OtherPayment successfully deleted.')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } else { return redirect()->back()->with('error', __('Permission denied.')); } } } Controllers/JobCategoryController.php000064400000007046150364311770014055 0ustar00can('Manage Job Category')) { $categories = JobCategory::where('created_by', '=', \Auth::user()->creatorId())->get(); return view('jobCategory.index', compact('categories')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } public function create() { return view('jobCategory.create'); } public function store(Request $request) { if(\Auth::user()->can('Create Job Category')) { $validator = \Validator::make( $request->all(), [ 'title' => 'required', ] ); if($validator->fails()) { $messages = $validator->getMessageBag(); return redirect()->back()->with('error', $messages->first()); } $jobCategory = new JobCategory(); $jobCategory->title = $request->title; $jobCategory->created_by = \Auth::user()->creatorId(); $jobCategory->save(); return redirect()->back()->with('success', __('Job category successfully created.')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } public function show(JobCategory $jobCategory) { // } public function edit(JobCategory $jobCategory) { return view('jobCategory.edit', compact('jobCategory')); } public function update(Request $request, JobCategory $jobCategory) { if(\Auth::user()->can('Edit Job Category')) { $validator = \Validator::make( $request->all(), [ 'title' => 'required', ] ); if($validator->fails()) { $messages = $validator->getMessageBag(); return redirect()->back()->with('error', $messages->first()); } $jobCategory->title = $request->title; $jobCategory->save(); return redirect()->back()->with('success', __('Job category successfully updated.')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } public function destroy(JobCategory $jobCategory) { if(\Auth::user()->can('Delete Job Category')) { if($jobCategory->created_by == \Auth::user()->creatorId()) { $jobs = Job::where('category',$jobCategory->id)->get(); if(count($jobs) == 0) { $jobCategory->delete(); } else { return redirect()->back()->with('error', __('This Job category has Job. Please remove the Job from this Job category.')); } return redirect()->back()->with('success', __('Job category successfully deleted.')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } else { return redirect()->back()->with('error', __('Permission denied.')); } } } Controllers/TicketController.php000064400000042104150364311770013062 0ustar00type == 'company' || \Auth::user()->type == 'hr') { $countTicket = Ticket::where('created_by', '=', \Auth::user()->creatorId())->count(); $countOpenTicket = Ticket::where('status', '=', 'open')->where('created_by', '=', \Auth::user()->creatorId())->count(); $countonholdTicket = Ticket::where('status', '=', 'onhold')->where('created_by', '=', \Auth::user()->creatorId())->count(); $countCloseTicket = Ticket::where('status', '=', 'close')->where('created_by', '=', \Auth::user()->creatorId())->count(); }else { $countTicket = Ticket::where('employee_id', '=', \Auth::user()->id)->orWhere('ticket_created', \Auth::user()->id)->count(); $countOpenTicket = Ticket::where('status', '=', 'open')->where('employee_id', '=', \Auth::user()->id)->count(); $countonholdTicket = Ticket::where('status', '=', 'onhold')->where('employee_id', '=', \Auth::user()->id)->count(); $countCloseTicket = Ticket::where('status', '=', 'close')->where('employee_id', '=', \Auth::user()->id)->count(); } $arr = []; array_push($arr, $countTicket, $countOpenTicket, $countonholdTicket, $countCloseTicket); $ticket_arr = json_encode($arr); if (\Auth::user()->can('Manage Ticket')) { $user = Auth::user(); if ($user->type == 'employee') { $tickets = Ticket::where('employee_id', '=', \Auth::user()->id)->orWhere('ticket_created', \Auth::user()->id)->get(); } else { $tickets = Ticket::select('tickets.*')->join('users', 'tickets.created_by', '=', 'users.id')->where('users.created_by', '=', \Auth::user()->creatorId())->orWhere('tickets.created_by', \Auth::user()->creatorId())->get(); } return view('ticket.index', compact('tickets', 'countTicket', 'countOpenTicket', 'countCloseTicket', 'countonholdTicket', 'ticket_arr')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } public function create() { if (\Auth::user()->can('Create Ticket')) { if (\Auth::user()->type != 'employee') { $employees = User::where('created_by', '=', \Auth::user()->creatorId())->where('type', '=', 'employee')->get()->pluck('name', 'id'); } else { $employees = User::where('created_by', '=', \Auth::user()->creatorId())->where('type', '=', 'employee')->first(); } return view('ticket.create', compact('employees')); } else { return response()->json(['error' => __('Permission denied.')], 401); } } public function store(Request $request) { if (\Auth::user()->can('Create Ticket')) { $validator = \Validator::make( $request->all(), [ 'title' => 'required', 'priority' => 'required', 'end_date' => 'required', 'employee_id' => 'required', ] ); if ($validator->fails()) { $messages = $validator->getMessageBag(); return redirect()->back()->with('error', $messages->first()); } $rand = date('hms'); $ticket = new Ticket(); $ticket->title = $request->title; if (Auth::user()->type == "employee") { $ticket->employee_id = \Auth::user()->id; } else { $ticket->employee_id = $request->employee_id; } $ticket->priority = $request->priority; $date1 = date("Y-m-d"); $date2 = $request->end_date; if ($date1 > $date2) { return redirect()->back()->with('error', __('Please Select Today or After Date ')); } else { $ticket->end_date = $request->end_date; } $ticket->ticket_code = $rand; $ticket->description = $request->description; if (!empty($request->attachment)) { $image_size = $request->file('attachment')->getSize(); $result = Utility::updateStorageLimit(\Auth::user()->creatorId(), $image_size); if ($result == 1) { $filenameWithExt = $request->file('attachment')->getClientOriginalName(); $filename = pathinfo($filenameWithExt, PATHINFO_FILENAME); $extension = $request->file('attachment')->getClientOriginalExtension(); $fileNameToStore = $filename . '_' . time() . '.' . $extension; $dir = 'uploads/tickets/'; $image_path = $dir . $fileNameToStore; $url = ''; $path = Utility::upload_file($request, 'attachment', $fileNameToStore, $dir, []); $ticket->attachment = !empty($request->attachment) ? $fileNameToStore : ''; if ($path['flag'] == 1) { $url = $path['url']; } else { return redirect()->back()->with('error', __($path['msg'])); } } } $ticket->ticket_created = \Auth::user()->id; $ticket->created_by = \Auth::user()->creatorId(); $ticket->status = $request->status; $ticket->save(); //slack $setting = Utility::settings(\Auth::user()->creatorId()); $emp = User::where('id', $request->employee_id)->first(); if (isset($setting['ticket_notification']) && $setting['ticket_notification'] == 1) { // $msg = ("New Support ticket created of") . ' ' . $request->priority . ' ' . __("priority for") . ' ' . $emp->name . ' '; $uArr = [ 'ticket_priority' => $request->priority, 'employee_name' => $emp->name, ]; Utility::send_slack_msg('new_ticket', $uArr); } //telegram $setting = Utility::settings(\Auth::user()->creatorId()); $emp = User::where('id', $request->employee_id)->first(); if (isset($setting['telegram_ticket_notification']) && $setting['telegram_ticket_notification'] == 1) { // $msg = ("New Support ticket created of") . ' ' . $request->priority . ' ' . __("priority for") . ' ' . $emp->name . ' '; $uArr = [ 'ticket_priority' => $request->priority, 'employee_name' => $emp->name, ]; Utility::send_telegram_msg('new_ticket', $uArr); } // twilio $setting = Utility::settings(\Auth::user()->creatorId()); $emp = Employee::where('user_id', $request->employee_id)->first(); if (isset($setting['twilio_ticket_notification']) && $setting['twilio_ticket_notification'] == 1) { // $msg = ("New Support ticket created of") . ' ' . $request->priority . ' ' . __("priority for") . ' ' . $emp->name . ' '; $uArr = [ 'ticket_priority' => $request->priority, 'employee_name' => $emp->name, ]; Utility::send_twilio_msg($emp->phone, 'new_ticket', $uArr); } $setings = Utility::settings(); if ($setings['new_ticket'] == 1) { $employee = Employee::where('user_id', '=', $ticket->employee_id)->first(); $uArr = [ 'ticket_title' => $ticket->title, 'ticket_name' => $employee->name, 'ticket_code' => $rand, 'ticket_description' => $request->description, ]; $resp = Utility::sendEmailTemplate('new_ticket', [$employee->email], $uArr); // return redirect()->route('ticket.index')->with('success', __('Ticket successfully created.') . ((!empty($resp) && $resp['is_success'] == false && !empty($resp['error'])) ? '
' . $resp['error'] . '' : '')); } //webhook $module = 'New Ticket'; $webhook = Utility::webhookSetting($module); if ($webhook) { $parameter = json_encode($ticket); // 1 parameter is URL , 2 parameter is data , 3 parameter is method $status = Utility::WebhookCall($webhook['url'], $parameter, $webhook['method']); if ($status == true) { return redirect()->route('ticket.index')->with('success', __('Ticket successfully created.') . ((!empty($resp) && $resp['is_success'] == false && !empty($resp['error'])) ? '
' . $resp['error'] . '' : '')); } else { return redirect()->back()->with('error', __('Webhook call failed.')); } } return redirect()->route('ticket.index')->with('success', __('Ticket successfully created.') . ((!empty($resp) && $resp['is_success'] == false && !empty($resp['error'])) ? '
' . $resp['error'] . '' : '')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } public function show(Ticket $ticket) { return redirect()->route('ticket.index'); } public function edit($ticket) { $ticket = Ticket::find($ticket); if (\Auth::user()->can('Edit Ticket')) { $employees = User::where('created_by', '=', \Auth::user()->creatorId())->where('type', '=', 'employee')->get()->pluck('name', 'id'); return view('ticket.edit', compact('ticket', 'employees')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } public function update(Request $request, $ticket) { $ticket = Ticket::find($ticket); if (\Auth::user()->can('Edit Ticket')) { $validator = \Validator::make( $request->all(), [ 'priority' => 'required', 'end_date' => 'required', ] ); if ($validator->fails()) { $messages = $validator->getMessageBag(); return redirect()->back()->with('error', $messages->first()); } $ticket->title = $request->title; if (Auth::user()->type == "employee") { $ticket->employee_id = \Auth::user()->id; } else { $ticket->employee_id = $request->employee_id; } $ticket->priority = $request->priority; $ticket->end_date = $request->end_date; $ticket->description = $request->description; if (!empty($request->attachment)) { //storage limit $dir = 'uploads/tickets/'; $file_path = $dir . $ticket->attachment; $image_size = $request->file('attachment')->getSize(); $result = Utility::updateStorageLimit(\Auth::user()->creatorId(), $image_size); if ($result == 1) { Utility::changeStorageLimit(\Auth::user()->creatorId(), $file_path); $filenameWithExt = $request->file('attachment')->getClientOriginalName(); $filename = pathinfo($filenameWithExt, PATHINFO_FILENAME); $extension = $request->file('attachment')->getClientOriginalExtension(); $fileNameToStore = $filename . '_' . time() . '.' . $extension; $dir = 'uploads/tickets/'; $image_path = $dir . $fileNameToStore; $url = ''; $path = Utility::upload_file($request, 'attachment', $fileNameToStore, $dir, []); $ticket->attachment = !empty($request->attachment) ? $fileNameToStore : ''; if ($path['flag'] == 1) { $url = $path['url']; } else { return redirect()->back()->with('error', __($path['msg'])); } } } $ticket->status = $request->status; $ticket->save(); return redirect()->route('ticket.index', compact('ticket'))->with('success', __('Ticket successfully updated.')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } public function destroy(Ticket $ticket) { if (\Auth::user()->can('Delete Ticket')) { if ($ticket->created_by == \Auth::user()->creatorId()) { $ticket->delete(); $ticketId = TicketReply::select('id')->where('ticket_id', $ticket->id)->get()->pluck('id'); $reply = TicketReply::whereIn('id', $ticketId)->get(); TicketReply::whereIn('id', $ticketId)->delete(); if (!empty($ticket->attachment)) { //storage limit $file_path = 'uploads/tickets/' . $ticket->attachment; $result = Utility::changeStorageLimit(\Auth::user()->creatorId(), $file_path); } foreach ($reply as $key => $value) { if (!empty($value->attachment)) { //storage limit $file_path = 'uploads/tickets/' . $value->attachment; $result = Utility::changeStorageLimit(\Auth::user()->creatorId(), $file_path); } } return redirect()->route('ticket.index')->with('success', __('Ticket successfully deleted.')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } else { return redirect()->back()->with('error', __('Permission denied.')); } } public function reply($ticket) { $ticketreply = TicketReply::where('ticket_id', '=', $ticket)->orderBy('id', 'DESC')->get(); $ticket = Ticket::find($ticket); if (\Auth::user()->type == 'employee') { $ticketreplyRead = TicketReply::where('ticket_id', $ticket->id)->where('created_by', '!=', \Auth::user()->id)->update(['is_read' => '1']); } else { $ticketreplyRead = TicketReply::where('ticket_id', $ticket->id)->where('created_by', '!=', \Auth::user()->creatorId())->update(['is_read' => '1']); } return view('ticket.reply', compact('ticket', 'ticketreply')); } public function changereply(Request $request) { $validator = \Validator::make( $request->all(), [ 'description' => 'required', ] ); if ($validator->fails()) { $messages = $validator->getMessageBag(); return redirect()->back()->with('error', $messages->first()); } $ticket = Ticket::find($request->ticket_id); $ticket_reply = new TicketReply(); $ticket_reply->ticket_id = $request->ticket_id; $ticket_reply->employee_id = $ticket->employee_id; $ticket_reply->description = $request->description; if (!empty($request->attachment)) { $image_size = $request->file('attachment')->getSize(); $result = Utility::updateStorageLimit(\Auth::user()->creatorId(), $image_size); if ($result == 1) { $filenameWithExt = $request->file('attachment')->getClientOriginalName(); $filename = pathinfo($filenameWithExt, PATHINFO_FILENAME); $extension = $request->file('attachment')->getClientOriginalExtension(); $fileNameToStore = $filename . '_' . time() . '.' . $extension; $dir = 'uploads/tickets/'; $image_path = $dir . $fileNameToStore; $url = ''; $path = Utility::upload_file($request, 'attachment', $fileNameToStore, $dir, []); $ticket_reply->attachment = !empty($request->attachment) ? $fileNameToStore : ''; if ($path['flag'] == 1) { $url = $path['url']; } else { return redirect()->back()->with('error', __($path['msg'])); } } } if (\Auth::user()->type == 'employee') { $ticket_reply->created_by = Auth::user()->id; } else { $ticket_reply->created_by = Auth::user()->id; } $ticket_reply->save(); return redirect()->route('ticket.reply', $ticket_reply->ticket_id)->with('success', __('Ticket Reply successfully Send.')); } } Controllers/FlutterwavePaymentController.php000064400000023040150364311770015503 0ustar00type == 'company') { $admin_payment_setting = Utility::getAdminPaymentSetting(); $this->secret_key = isset($admin_payment_setting['flutterwave_secret_key']) ? $admin_payment_setting['flutterwave_secret_key'] : ''; $this->public_key = isset($admin_payment_setting['flutterwave_public_key']) ? $admin_payment_setting['flutterwave_public_key'] : ''; $this->is_enabled = isset($admin_payment_setting['is_flutterwave_enabled']) ? $admin_payment_setting['is_flutterwave_enabled'] : 'off'; return $this; } } public function planPayWithFlutterwave(Request $request) { $admin_payment_setting = Utility::getAdminPaymentSetting(); $planID = \Illuminate\Support\Facades\Crypt::decrypt($request->plan_id); $plan = Plan::find($planID); $authuser = Auth::user(); $coupon_id = ''; if($plan) { $coupons_id = 0; $price = $plan->price; if(isset($request->coupon) && !empty($request->coupon)) { $request->coupon = trim($request->coupon); $coupons = Coupon::where('code', strtoupper($request->coupon))->where('is_active', '1')->first(); if(!empty($coupons)) { $usedCoupun = $coupons->used_coupon(); $discount_value = ($price / 100) * $coupons->discount; $plan->discounted_price = $price - $discount_value; if($usedCoupun >= $coupons->limit) { return redirect()->back()->with('error', __('This coupon code has expired.')); } $price = $price - $discount_value; $coupon_id = $coupons->id; } else { return redirect()->back()->with('error', __('This coupon code is invalid or has expired.')); } } if($price <= 0) { $authuser->plan = $plan->id; $authuser->save(); $assignPlan = $authuser->assignPlan($plan->id); if($assignPlan['is_success'] == true && !empty($plan)) { $orderID = strtoupper(str_replace('.', '', uniqid('', true))); $user = Auth::user(); if ($request->has('coupon') && $request->coupon != '') { $coupons = Coupon::where('code', strtoupper($request->coupon))->where('is_active', '1')->first(); if (!empty($coupons)) { $userCoupon = new UserCoupon(); $userCoupon->user = $user->id; $userCoupon->coupon = $coupons->id; $userCoupon->order = $orderID; $userCoupon->save(); $usedCoupun = $coupons->used_coupon(); if ($coupons->limit <= $usedCoupun) { $coupons->is_active = 0; $coupons->save(); } } } Order::create( [ 'order_id' => $orderID, 'name' => null, 'email' => null, 'card_number' => null, 'card_exp_month' => null, 'card_exp_year' => null, 'plan_name' => $plan->name, 'plan_id' => $plan->id, 'price' => $price == null ? 0 : $price, 'price_currency' => !empty($admin_payment_setting['currency']) ? $admin_payment_setting['currency'] : 'usd', 'txn_id' => '', 'payment_type' => __('Flutterwave'), 'payment_status' => 'succeeded', 'receipt' => null, 'user_id' => $authuser->id, ] ); $res['msg'] = __("Plan successfully upgraded."); $res['flag'] = 2; return $res; } else { return Utility::error_res(__('Plan fail to upgrade.')); } } $res_data['email'] = \Auth::user()->email; $res_data['total_price'] = $price; $res_data['currency'] = $admin_payment_setting['currency']; $res_data['flag'] = 1; $res_data['coupon'] = $coupon_id; return $res_data; } else { return Utility::error_res(__('Plan is deleted.')); } } public function getPaymentStatus(Request $request, $pay_id, $plan) { $admin_payment_setting = Utility::getAdminPaymentSetting(); $payment = $this->paymentConfig(); $planID = \Illuminate\Support\Facades\Crypt::decrypt($plan); $plan = Plan::find($planID); $result = array(); $user = Auth::user(); if($plan) { try { $orderID = time(); $data = array( 'txref' => $pay_id, 'SECKEY' => $payment->secret_key, //secret key from pay button generated on rave dashboard ); // make request to endpoint using unirest. $headers = array('Content-Type' => 'application/json'); $body = \Unirest\Request\Body::json($data); $url = "https://api.ravepay.co/flwv3-pug/getpaidx/api/v2/verify"; //please make sure to change this to production url when you go live // Make `POST` request and handle response with unirest $response = \Unirest\Request::post($url, $headers, $body); if(!empty($response)) { $response = json_decode($response->raw_body, true); } if(isset($response['status']) && $response['status'] == 'success') { $paydata = $response['data']; if($request->has('coupon_id') && $request->coupon_id != '') { $coupons = Coupon::find($request->coupon_id); if(!empty($coupons)) { $userCoupon = new UserCoupon(); $userCoupon->user = $user->id; $userCoupon->coupon = $coupons->id; $userCoupon->order = $orderID; $userCoupon->save(); $usedCoupun = $coupons->used_coupon(); if($coupons->limit <= $usedCoupun) { $coupons->is_active = 0; $coupons->save(); } } } Utility::referralTransaction($plan); $order = new Order(); $order->order_id = $orderID; $order->name = $user->name; $order->card_number = ''; $order->card_exp_month = ''; $order->card_exp_year = ''; $order->plan_name = $plan->name; $order->plan_id = $plan->id; $order->price = isset($paydata['amount']) ? $paydata['amount'] : 0; $order->price_currency = $admin_payment_setting['currency']; $order->txn_id = isset($paydata['txid']) ? $paydata['txid'] : $pay_id; $order->payment_type = __('Flutterwave'); $order->payment_status = 'success'; $order->receipt = ''; $order->user_id = $user->id; $order->save(); $assignPlan = $user->assignPlan($plan->id); if($assignPlan['is_success']) { return redirect()->route('plans.index')->with('success', __('Plan activated Successfully!')); } else { return redirect()->route('plans.index')->with('error', __($assignPlan['error'])); } } else { return redirect()->route('plans.index')->with('error', __('Transaction has been failed! ')); } } catch(\Exception $e) { return redirect()->route('plans.index')->with('error', __('Plan not found!')); } } } } Controllers/AiTemplateController.php000064400000016106150364311770013667 0ustar00get(); return view('template.generate', compact('templateName')); } public function getKeywords(Request $request, $id) { $template = Template::find($id); $field_data = json_decode($template->field_json); $html = ""; foreach ($field_data->field as $value) { $html .= '
'; if ($value->field_type == "text_box") { $html .= ''; } if ($value->field_type == "textarea") { $html .= ''; } $html .= '
'; } return response()->json( [ 'success' => true, 'tone' => $template->is_tone, 'template' => $html, ] ); } public function AiGenerate(Request $request) { if ($request->ajax()) { $post = $request->all(); unset($post['_token'], $post['template_name'], $post['tone'], $post['ai_creativity'], $post['num_of_result'], $post['result_length']); $data = array(); $key_data = DB::table('settings')->where('name', 'chatgpt_key')->first(); if ($key_data) { $open_ai = new OpenAi($key_data->value); } else { $data['status'] = 'error'; $data['message'] = __('Please set proper configuration for Api Key'); return $data; } $prompt = ''; $model = ''; $text = ''; $ai_token = ''; $counter = 1; $template = Template::where('id', $request->template_name)->first(); if ($request->template_name) { $required_field = array(); $data_field = json_decode($template->field_json); foreach ($data_field->field as $val) { request()->validate([$val->field_name => 'required|string']); } $prompt = $template->prompt; foreach ($data_field->field as $field) { $text_rep = "##" . $field->field_name . "##"; if (strpos($prompt, $text_rep) !== false) { $field->value = $post[$field->field_name]; $prompt = str_replace($text_rep, $post[$field->field_name], $prompt); } if ($template->is_tone == 1) { $tone = $request->tone; $param = "##tone_language##"; $prompt = str_replace($param, $tone, $prompt); } } } $lang_text = "Provide response in " . $request->language . " language.\n\n "; $ai_token = (int)$request->result_length; $max_results = (int)$request->num_of_result; $ai_creativity = (float)$request->ai_creativity; $settings = Utility::getChatGPTSetting(); $complete = $open_ai->completion([ 'model' => isset($settings['chatgpt_model']) ? $settings['chatgpt_model'] : '', 'prompt' => $prompt . ' ' . $lang_text, 'temperature' => $ai_creativity, 'max_tokens' => $ai_token, 'n' => $max_results ]); $response = json_decode($complete, true); if (isset($response['choices'])) { if (count($response['choices']) > 1) { foreach ($response['choices'] as $value) { $text .= $counter . '. ' . ltrim($value['text']) . "\r\n\r\n\r\n"; $counter++; } } else { $text = $response['choices'][0]['text']; } $tokens = $response['usage']['completion_tokens']; $data = trim($text); return $data; } else { $data['status'] = 'Error'; $data['message'] = $response['error']['message']; return $data; } } } //for grammar check public function grammar($moduleName) { $templateName = Template::where('module', $moduleName)->first(); return view('template.grammar_ai', compact('templateName')); } public function grammarProcess(Request $request) { if ($request->ajax()) { $post = $request->all(); unset($post['_token'], $post['template_name'], $post['tone'], $post['ai_creativity'], $post['num_of_result'], $post['result_length']); $data = array(); $key_data = DB::table('settings')->where('name', 'chatgpt_key')->first(); if ($key_data) { $open_ai = new OpenAi($key_data->value); } else { $data['status'] = 'error'; $data['message'] = __('Please set proper configuration for Api Key'); return $data; } $counter = 1; $prompt = "please correct grammar mistakes and spelling mistakes in this: . $request->description ."; $is_tone = 1; $ai_token = strlen($request->description); $max_results = 1; $ai_creativity = 1.0; $settings = Utility::getChatGPTSetting(); $complete = $open_ai->completion([ 'model' => isset($settings['chatgpt_model']) ? $settings['chatgpt_model'] : '', 'prompt' => $prompt, 'temperature' => $ai_creativity, 'max_tokens' => $ai_token, 'n' => $max_results ]); $response = json_decode($complete, true); if (isset($response['choices'])) { if (count($response['choices']) > 1) { foreach ($response['choices'] as $value) { $text .= $counter . '. ' . ltrim($value['text']) . "\r\n\r\n\r\n"; $counter++; } } else { $text = $response['choices'][0]['text']; } $tokens = $response['usage']['completion_tokens']; $data = trim($text); return $data; } else { $data['status'] = 'Error'; $data['message'] = $response['error']['message']; return $data; } } } } Controllers/TravelController.php000064400000016525150364311770013104 0ustar00can('Manage Travel')) { if (Auth::user()->type == 'employee') { $emp = Employee::where('user_id', '=', \Auth::user()->id)->first(); $travels = Travel::where('created_by', '=', \Auth::user()->creatorId())->where('employee_id', '=', $emp->id)->get(); } else { $travels = Travel::where('created_by', '=', \Auth::user()->creatorId())->with('employee')->get(); } return view('travel.index', compact('travels')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } public function create() { if (\Auth::user()->can('Create Travel')) { $employees = Employee::where('created_by', \Auth::user()->creatorId())->get()->pluck('name', 'id'); return view('travel.create', compact('employees')); } else { return response()->json(['error' => __('Permission denied.')], 401); } } public function store(Request $request) { if (\Auth::user()->can('Create Travel')) { $validator = \Validator::make( $request->all(), [ 'employee_id' => 'required', 'start_date' => 'required', 'end_date' => 'required|after_or_equal:start_date', 'purpose_of_visit' => 'required', 'place_of_visit' => 'required', ] ); if ($validator->fails()) { $messages = $validator->getMessageBag(); return redirect()->back()->with('error', $messages->first()); } $travel = new Travel(); $travel->employee_id = $request->employee_id; $travel->start_date = $request->start_date; $travel->end_date = $request->end_date; $travel->purpose_of_visit = $request->purpose_of_visit; $travel->place_of_visit = $request->place_of_visit; $travel->description = $request->description ; $travel->created_by = \Auth::user()->creatorId(); $travel->save(); // twilio $setting = Utility::settings(\Auth::user()->creatorId()); $emp = Employee::find($request->employee_id); if (isset($setting['twilio_trip_notification']) && $setting['twilio_trip_notification'] == 1) { // $msg = $request->purpose_of_visit . ' ' . __("is created to visit") . ' ' . $request->place_of_visit . ' ' . __("for") . ' ' . $emp->name . ' ' . __("from") . ' ' . $request->start_date . ' ' . __("to") . ' ' . $request->end_date . '.'; $uArr = [ 'purpose_of_visit' => $request->purpose_of_visit, 'place_of_visit' => $request->place_of_visit, 'employee_name' => $emp->name, 'start_date' => $request->start_date, 'end_date' => $request->end_date, ]; Utility::send_twilio_msg($emp->phone, 'new_trip', $uArr); } $setings = Utility::settings(); if ($setings['employee_trip'] == 1) { $employee = Employee::find($travel->employee_id); $uArr = [ 'employee_trip_name'=>$employee->name, 'purpose_of_visit' =>$request->purpose_of_visit, 'start_date' =>$request->start_date, 'end_date' =>$request->end_date, 'place_of_visit' =>$request->place_of_visit, 'trip_description' =>$request->description, ]; $resp = Utility::sendEmailTemplate('employee_trip', [$employee->email], $uArr); return redirect()->route('travel.index')->with('success', __('Travel successfully created.'). ((!empty($resp) && $resp['is_success'] == false && !empty($resp['error'])) ? '
' . $resp['error'] . '' : '')); } return redirect()->route('travel.index')->with('success', __('Travel successfully created.')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } public function show(Travel $travel) { return redirect()->route('travel.index'); } public function edit(Travel $travel) { if (\Auth::user()->can('Edit Travel')) { $employees = Employee::where('created_by', \Auth::user()->creatorId())->get()->pluck('name', 'id'); if ($travel->created_by == \Auth::user()->creatorId()) { return view('travel.edit', compact('travel', 'employees')); } else { return response()->json(['error' => __('Permission denied.')], 401); } } else { return response()->json(['error' => __('Permission denied.')], 401); } } public function update(Request $request, Travel $travel) { if (\Auth::user()->can('Edit Travel')) { if ($travel->created_by == \Auth::user()->creatorId()) { $validator = \Validator::make( $request->all(), [ 'employee_id' => 'required', 'start_date' => 'required', 'end_date' => 'required', 'purpose_of_visit' => 'required', 'place_of_visit' => 'required', ] ); if ($validator->fails()) { $messages = $validator->getMessageBag(); return redirect()->back()->with('error', $messages->first()); } $travel->employee_id = $request->employee_id; $travel->start_date = $request->start_date; $travel->end_date = $request->end_date; $travel->purpose_of_visit = $request->purpose_of_visit; $travel->place_of_visit = $request->place_of_visit; $travel->description = $request->description; $travel->save(); return redirect()->route('travel.index')->with('success', __('Travel successfully updated.')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } else { return redirect()->back()->with('error', __('Permission denied.')); } } public function destroy(Travel $travel) { if (\Auth::user()->can('Delete Travel')) { if ($travel->created_by == \Auth::user()->creatorId()) { $travel->delete(); return redirect()->route('travel.index')->with('success', __('Travel successfully deleted.')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } else { return redirect()->back()->with('error', __('Permission denied.')); } } } Controllers/PromotionController.php000064400000015715150364311770013635 0ustar00can('Manage Promotion')) { if(Auth::user()->type == 'employee') { $emp = Employee::where('user_id', '=', \Auth::user()->id)->first(); $promotions = Promotion::where('created_by', '=', \Auth::user()->creatorId())->where('employee_id', '=', $emp->id)->get(); } else { $promotions = Promotion::where('created_by', '=', \Auth::user()->creatorId())->with(['employee', 'designation'])->get(); } return view('promotion.index', compact('promotions')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } public function create() { if(\Auth::user()->can('Create Promotion')) { $designations = Designation::where('created_by', Auth::user()->creatorId())->get()->pluck('name', 'id'); $employees = Employee::where('created_by', Auth::user()->creatorId())->get()->pluck('name', 'id'); return view('promotion.create', compact('employees', 'designations')); } else { return response()->json(['error' => __('Permission denied.')], 401); } } public function store(Request $request) { if(\Auth::user()->can('Create Promotion')) { $validator = \Validator::make( $request->all(), [ 'employee_id' => 'required', 'designation_id' => 'required', 'promotion_title' => 'required', 'promotion_date' => 'required', ] ); if($validator->fails()) { $messages = $validator->getMessageBag(); return redirect()->back()->with('error', $messages->first()); } $promotion = new Promotion(); $promotion->employee_id = $request->employee_id; $promotion->designation_id = $request->designation_id; $promotion->promotion_title = $request->promotion_title; $promotion->promotion_date = $request->promotion_date; $promotion->description = $request->description; $promotion->created_by = \Auth::user()->creatorId(); $promotion->save(); $setings = Utility::settings(); if($setings['employee_promotion'] == 1) { $employee = Employee::find($promotion->employee_id); $designation = Designation::find($promotion->designation_id); $uArr = [ 'employee_promotion_name'=>$employee->name, 'promotion_designation' =>$designation->name, 'promotion_title' =>$request->promotion_title, 'promotion_date' =>$request->promotion_date, ]; $resp = Utility::sendEmailTemplate('employee_promotion', [$employee->email], $uArr); return redirect()->route('promotion.index')->with('success', __('Promotion successfully created.'). ((!empty($resp) && $resp['is_success'] == false && !empty($resp['error'])) ? '
' . $resp['error'] . '' : '')); } } else { return redirect()->back()->with('error', __('Permission denied.')); } } public function show(Promotion $promotion) { return redirect()->route('promotion.index'); } public function edit(Promotion $promotion) { $designations = Designation::where('created_by', Auth::user()->creatorId())->get()->pluck('name', 'id'); $employees = Employee::where('created_by', Auth::user()->creatorId())->get()->pluck('name', 'id'); if(\Auth::user()->can('Edit Promotion')) { if($promotion->created_by == \Auth::user()->creatorId()) { return view('promotion.edit', compact('promotion', 'employees', 'designations')); } else { return response()->json(['error' => __('Permission denied.')], 401); } } else { return response()->json(['error' => __('Permission denied.')], 401); } } public function update(Request $request, Promotion $promotion) { if(\Auth::user()->can('Edit Promotion')) { if($promotion->created_by == \Auth::user()->creatorId()) { $validator = \Validator::make( $request->all(), [ 'employee_id' => 'required', 'designation_id' => 'required', 'promotion_title' => 'required', 'promotion_date' => 'required', ] ); if($validator->fails()) { $messages = $validator->getMessageBag(); return redirect()->back()->with('error', $messages->first()); } $promotion->employee_id = $request->employee_id; $promotion->designation_id = $request->designation_id; $promotion->promotion_title = $request->promotion_title; $promotion->promotion_date = $request->promotion_date; $promotion->description = $request->description; $promotion->save(); return redirect()->route('promotion.index')->with('success', __('Promotion successfully updated.')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } else { return redirect()->back()->with('error', __('Permission denied.')); } } public function destroy(Promotion $promotion) { if(\Auth::user()->can('Delete Promotion')) { if($promotion->created_by == \Auth::user()->creatorId()) { $promotion->delete(); return redirect()->route('promotion.index')->with('success', __('Promotion successfully deleted.')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } else { return redirect()->back()->with('error', __('Permission denied.')); } } } Controllers/IndicatorController.php000064400000015064150364311770013560 0ustar00can('Manage Indicator')) { $user = \Auth::user(); if ($user->type == 'employee') { $employee = Employee::where('user_id', $user->id)->first(); $indicators = Indicator::where('created_by', '=', $user->creatorId())->where('branch', $employee->branch_id)->where('department', $employee->department_id)->where('designation', $employee->designation_id)->get(); } else { $indicators = Indicator::where('created_by', '=', $user->creatorId())->with(['branches', 'departments', 'designations', 'user'])->get(); } return view('indicator.index', compact('indicators')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } public function create() { if (\Auth::user()->can('Create Indicator')) { $performance_types = Performance_Type::where('created_by', '=', \Auth::user()->creatorId())->get(); $brances = Branch::where('created_by', '=', \Auth::user()->creatorId())->get()->pluck('name', 'id'); // $brances->prepend('Select Branch', ''); $departments = Department::where('created_by', '=', \Auth::user()->creatorId())->get()->pluck('name', 'id'); $departments->prepend('Select Department', ''); $degisnation = Designation::where('created_by', '=', \Auth::user()->creatorId())->get()->pluck('name', 'id'); return view('indicator.create', compact('performance_types', 'brances', 'departments', 'degisnation')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } public function store(Request $request) { if (\Auth::user()->can('Create Indicator')) { $validator = \Validator::make( $request->all(), [ 'branch' => 'required', 'department' => 'required', 'designation' => 'required', 'rating' => 'required', ] ); if ($validator->fails()) { $messages = $validator->getMessageBag(); return redirect()->back()->with('error', $messages->first()); } $indicator = new Indicator(); $indicator->branch = $request->branch; $indicator->department = $request->department; $indicator->designation = $request->designation; $indicator->rating = json_encode($request->rating, true); if (\Auth::user()->type == 'company') { $indicator->created_user = \Auth::user()->creatorId(); } else { $indicator->created_user = \Auth::user()->id; } $indicator->created_by = \Auth::user()->creatorId(); $indicator->save(); return redirect()->route('indicator.index')->with('success', __('Indicator successfully created.')); } } public function show(Indicator $indicator) { $ratings = json_decode($indicator->rating, true); $performance_types = Performance_Type::where('created_by', '=', \Auth::user()->creatorId())->get(); // $technicals = Competencies::where('created_by', \Auth::user()->creatorId())->where('type', 'technical')->get(); // $organizationals = Competencies::where('created_by', \Auth::user()->creatorId())->where('type', 'organizational')->get(); // $behaviourals = Competencies::where('created_by', \Auth::user()->creatorId())->where('type', 'behavioural')->get(); return view('indicator.show', compact('indicator', 'ratings', 'performance_types')); } public function edit(Indicator $indicator) { if (\Auth::user()->can('Edit Indicator')) { $performance_types = Performance_Type::where('created_by', '=', \Auth::user()->creatorId())->get(); $brances = Branch::where('created_by', '=', \Auth::user()->creatorId())->get()->pluck('name', 'id'); $departments = Department::where('created_by', '=', \Auth::user()->creatorId())->get()->pluck('name', 'id'); $departments->prepend('Select Department', ''); $degisnation = Designation::where('created_by', '=', \Auth::user()->creatorId())->get()->pluck('name', 'id'); $ratings = json_decode($indicator->rating, true); return view('indicator.edit', compact('performance_types', 'brances', 'departments', 'indicator', 'ratings', 'degisnation')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } public function update(Request $request, Indicator $indicator) { if (\Auth::user()->can('Edit Indicator')) { $validator = \Validator::make( $request->all(), [ 'branch' => 'required', 'department' => 'required', 'designation' => 'required', 'rating' => 'required', ] ); if ($validator->fails()) { $messages = $validator->getMessageBag(); return redirect()->back()->with('error', $messages->first()); } $indicator->branch = $request->branch; $indicator->department = $request->department; $indicator->designation = $request->designation; $indicator->rating = json_encode($request->rating, true); $indicator->save(); return redirect()->route('indicator.index')->with('success', __('Indicator successfully updated.')); } } public function destroy(Indicator $indicator) { if (\Auth::user()->can('Delete Indicator')) { if ($indicator->created_by == \Auth::user()->creatorId()) { $indicator->delete(); return redirect()->route('indicator.index')->with('success', __('Indicator successfully deleted.')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } else { return redirect()->back()->with('error', __('Permission denied.')); } } } Controllers/SkrillPaymentController.php000064400000024453150364311770014444 0ustar00type == 'company') { $admin_payment_setting = Utility::getAdminPaymentSetting(); // $this->currancy = isset($admin_payment_setting['currency'])?$admin_payment_setting['currency']:''; $this->email = isset($admin_payment_setting['skrill_email']) ? $admin_payment_setting['skrill_email'] : ''; $this->is_enabled = isset($admin_payment_setting['is_skrill_enabled']) ? $admin_payment_setting['is_skrill_enabled'] : 'off'; return $this; } } public function planPayWithSkrill(Request $request) { $payment = $this->paymentConfig(); $admin_payment_setting = Utility::getAdminPaymentSetting(); $planID = \Illuminate\Support\Facades\Crypt::decrypt($request->plan_id); $plan = Plan::find($planID); $authuser = Auth::user(); $coupons_id = ''; if ($plan) { $price = $plan->price; if (isset($request->coupon) && !empty($request->coupon)) { $request->coupon = trim($request->coupon); $coupons = Coupon::where('code', strtoupper($request->coupon))->where('is_active', '1')->first(); if (!empty($coupons)) { $usedCoupun = $coupons->used_coupon(); $discount_value = ($price / 100) * $coupons->discount; $plan->discounted_price = $price - $discount_value; $coupons_id = $coupons->id; if ($usedCoupun >= $coupons->limit) { return redirect()->back()->with('error', __('This coupon code has expired.')); } $price = $price - $discount_value; } else { return redirect()->back()->with('error', __('This coupon code is invalid or has expired.')); } } if ($price <= 0) { $authuser->plan = $plan->id; $authuser->save(); $assignPlan = $authuser->assignPlan($plan->id); if ($assignPlan['is_success'] == true && !empty($plan)) { $orderID = time(); $user = Auth::user(); if ($request->has('coupon') && $request->coupon != '') { $coupons = Coupon::where('code', strtoupper($request->coupon))->where('is_active', '1')->first(); if (!empty($coupons)) { $userCoupon = new UserCoupon(); $userCoupon->user = $user->id; $userCoupon->coupon = $coupons->id; $userCoupon->order = $orderID; $userCoupon->save(); $usedCoupun = $coupons->used_coupon(); if ($coupons->limit <= $usedCoupun) { $coupons->is_active = 0; $coupons->save(); } } } Order::create( [ 'order_id' => $orderID, 'name' => null, 'email' => null, 'card_number' => null, 'card_exp_month' => null, 'card_exp_year' => null, 'plan_name' => $plan->name, 'plan_id' => $plan->id, 'price' => $price == null ? 0 : $price, 'price_currency' => !empty($admin_payment_setting['currency']) ? $admin_payment_setting['currency'] : 'USD', // 'price_currency' => !empty($this->currancy) ? $this->currancy : 'usd', 'txn_id' => '', 'payment_type' => __('Skrill'), 'payment_status' => 'succeeded', 'receipt' => null, 'user_id' => $authuser->id, ] ); $assignPlan = $authuser->assignPlan($plan->id); return redirect()->route('plans.index')->with('success', __('Plan activated Successfully!')); } else { return redirect()->back()->with('error', __('Plan fail to upgrade.')); } } $tran_id = md5(date('Y-m-d') . strtotime('Y-m-d H:i:s') . 'user_id'); $skill = new SkrillRequest(); $skill->pay_to_email = $payment->email; $skill->return_url = route( 'plan.skrill', [ $request->plan_id, 'tansaction_id=' . MD5($tran_id), 'coupon_id=' . $coupons_id, ] ); $skill->cancel_url = route('plan.skrill', [$request->plan_id]); // create object instance of SkrillRequest $skill->transaction_id = MD5($tran_id); // generate transaction id $skill->amount = $price; $skill->currency = $admin_payment_setting['currency']; $skill->language = 'EN'; $skill->prepare_only = '1'; $skill->merchant_fields = 'site_name, customer_email'; $skill->site_name = \Auth::user()->name; $skill->customer_email = \Auth::user()->email; // create object instance of SkrillClient $client = new SkrillClient($skill); $sid = $client->generateSID(); //return SESSION ID // handle error $jsonSID = json_decode($sid); if ($jsonSID != null && $jsonSID->code == "BAD_REQUEST") { // return redirect()->back()->with('error', $jsonSID->message); } // do the payment $redirectUrl = $client->paymentRedirectUrl($sid); //return redirect url if ($tran_id) { $data = [ 'amount' => $price, 'trans_id' => MD5($request['transaction_id']), 'currency' => $admin_payment_setting['currency'], ]; session()->put('skrill_data', $data); } return redirect($redirectUrl); } else { return redirect()->back()->with('error', 'Plan is deleted.'); } } public function getPaymentStatus(Request $request, $plan) { $admin_payment_setting = Utility::getAdminPaymentSetting(); $planID = \Illuminate\Support\Facades\Crypt::decrypt($plan); $plan = Plan::find($planID); $user = \Auth::user(); $orderID = time(); if ($plan) { try { if ($request->all() != []) { if (session()->has('skrill_data')) { $get_data = session()->get('skrill_data'); if ($request->has('coupon_id') && $request->coupon_id != '') { $coupons = Coupon::find($request->coupon_id); if (!empty($coupons)) { $userCoupon = new UserCoupon(); $userCoupon->user = $user->id; $userCoupon->coupon = $coupons->id; $userCoupon->order = $orderID; $userCoupon->save(); $usedCoupun = $coupons->used_coupon(); if ($coupons->limit <= $usedCoupun) { $coupons->is_active = 0; $coupons->save(); } } } Utility::referralTransaction($plan); $order = new Order(); $order->order_id = $orderID; $order->name = $user->name; $order->card_number = ''; $order->card_exp_month = ''; $order->card_exp_year = ''; $order->plan_name = $plan->name; $order->plan_id = $plan->id; $order->price = isset($get_data['amount']) ? $get_data['amount'] : 0; $order->price_currency = $admin_payment_setting['currency']; $order->txn_id = isset($request->transaction_id) ? $request->transaction_id : ''; $order->payment_type = __('Skrill'); $order->payment_status = 'success'; $order->receipt = ''; $order->user_id = $user->id; $order->save(); $assignPlan = $user->assignPlan($plan->id, $request->payment_frequency); if ($assignPlan['is_success']) { return redirect()->route('plans.index')->with('success', __('Plan activated Successfully!')); } else { return redirect()->route('plans.index')->with('error', __($assignPlan['error'])); } } else { return redirect()->route('plans.index')->with('error', __('Transaction has been failed! ')); } } else { return redirect()->route('plans.index')->with('error', __('Transaction has been failed! ')); } } catch (\Exception $e) { return redirect()->route('plans.index')->with('error', __('Plan not found!')); } } } } Controllers/EmailTemplateController.php000064400000017550150364311770014371 0ustar00type == 'super admin' || $usr->type == 'company') { $EmailTemplates = EmailTemplate::all(); return view('email_templates.index', compact('EmailTemplates')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } public function create() { if (\Auth::user()->type == 'super admin') { return view('email_templates.create'); } else { return redirect()->back()->with('error', __('Permission denied.')); } } public function store(Request $request) { $usr = \Auth::user(); if (\Auth::user()->type == 'super admin') { $validator = \Validator::make( $request->all(), [ 'name' => 'required', ] ); if ($validator->fails()) { $messages = $validator->getMessageBag(); return redirect()->back()->with('error', $messages->first()); } $EmailTemplate = new EmailTemplate(); $EmailTemplate->name = $request->name; $EmailTemplate->slug = strtolower(str_replace(' ', '_', $request->name)); $EmailTemplate->from = env('APP_NAME'); $EmailTemplate->created_by = $usr->id; $EmailTemplate->save(); return redirect()->route('email_template.index')->with('success', __('Email Template successfully created.')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } public function show(EmailTemplate $emailTemplate) { // } public function edit(EmailTemplate $emailTemplate) { // } public function update(Request $request, $id) { // if(\Auth::user()->can('Edit Email Template')) // { $validator = \Validator::make( $request->all(), [ 'from' => 'required', 'subject' => 'required', 'content' => 'required', ] ); if ($validator->fails()) { $messages = $validator->getMessageBag(); return redirect()->back()->with('error', $messages->first()); } $emailTemplate = EmailTemplate::where('id', $id)->first(); $emailTemplate->from = $request->from; $emailTemplate->save(); $emailLangTemplate = EmailTemplateLang::where('parent_id', '=', $id)->where('lang', '=', $request->lang)->first(); // if record not found then create new record else update it. if (empty($emailLangTemplate)) { $emailLangTemplate = new EmailTemplateLang(); $emailLangTemplate->parent_id = $id; $emailLangTemplate->lang = $request['lang']; $emailLangTemplate->subject = $request['subject']; $emailLangTemplate->content = $request['content']; $emailLangTemplate->save(); } else { $emailLangTemplate->subject = $request['subject']; $emailLangTemplate->content = $request['content']; $emailLangTemplate->save(); } return redirect()->route( 'manage.email.language', [ $emailTemplate->id, $request->lang, ] )->with('success', __('Email Template successfully updated.')); // } // else // { // return redirect()->back()->with('error', __('Permission denied.')); // } } public function destroy(EmailTemplate $emailTemplate) { // } // Used For View Email Template Language Wise public function manageEmailLang($id, $lang = 'en') { if (\Auth::user()->type == 'super admin') { $languages = Utility::languages(); $emailTemplate = EmailTemplate::getemailTemplate(); // $currEmailTempLang = EmailTemplateLang::where('lang', $lang)->first(); $currEmailTempLang = EmailTemplateLang::where('parent_id', '=', $id)->where('lang', $lang)->first(); if (!isset($currEmailTempLang) || empty($currEmailTempLang)) { $currEmailTempLang = EmailTemplateLang::where('parent_id', '=', $id)->where('lang', 'en')->first(); $currEmailTempLang->lang = $lang; } if (\Auth::user()->type == 'super admin') { $emailTemplate = EmailTemplate::where('id', '=', $id)->first(); } else { $settings = Utility::settings(); $emailTemplate = $settings['company_name']; } $EmailTemplates = EmailTemplate::all(); return view('email_templates.show', compact('emailTemplate', 'languages', 'currEmailTempLang', 'EmailTemplates')); } else { return redirect()->back()->with('error', 'Permission denied.'); } } // Used For Store Email Template Language Wise public function storeEmailLang(Request $request, $id) { if (\Auth::user()->type == 'super admin') { $validator = \Validator::make( $request->all(), [ 'subject' => 'required', 'content' => 'required', ] ); if ($validator->fails()) { $messages = $validator->getMessageBag(); return redirect()->back()->with('error', $messages->first()); } $emailLangTemplate = EmailTemplateLang::where('parent_id', '=', $id)->where('lang', '=', $request->lang)->first(); // if record not found then create new record else update it. if (empty($emailLangTemplate)) { $emailLangTemplate = new EmailTemplateLang(); $emailLangTemplate->parent_id = $id; $emailLangTemplate->lang = $request['lang']; $emailLangTemplate->subject = $request['subject']; $emailLangTemplate->content = $request['content']; $emailLangTemplate->save(); } else { $emailLangTemplate->subject = $request['subject']; $emailLangTemplate->content = $request['content']; $emailLangTemplate->save(); } return redirect()->route( 'manage.email.language', [ $id, $request->lang, ] )->with('success', __('Email Template Detail successfully updated.')); } else { return redirect()->back()->with('error', 'Permission denied.'); } } public function updateStatus(Request $request) { $post = $request->all(); unset($post['_token']); $usr = \Auth::user(); if($usr->type == 'super admin' || $usr->type == 'company') { UserEmailTemplate::where('user_id', $usr->id)->update([ 'is_active' => 0]); foreach ($post as $key => $value) { $UserEmailTemplate = UserEmailTemplate::where('user_id', $usr->id)->where('template_id', $key)->first(); $UserEmailTemplate->is_active = $value; $UserEmailTemplate->save(); } return redirect()->back()->with('success', __('Status successfully updated!')); } else { return redirect()->back()->with('error', __('Permission Denied.')); } } } Controllers/OvertimeController.php000064400000011004150364311770013424 0ustar00can('Create Overtime')) { $validator = \Validator::make( $request->all(), [ 'employee_id' => 'required', 'title' => 'required', 'number_of_days' => 'required', 'hours' => 'required', 'rate' => 'required', ] ); if($validator->fails()) { $messages = $validator->getMessageBag(); return redirect()->back()->with('error', $messages->first()); } $overtime = new Overtime(); $overtime->employee_id = $request->employee_id; $overtime->title = $request->title; $overtime->number_of_days = $request->number_of_days; $overtime->hours = $request->hours; $overtime->rate = $request->rate; $overtime->created_by = \Auth::user()->creatorId(); $overtime->save(); return redirect()->back()->with('success', __('Overtime successfully created.')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } public function show(Overtime $overtime) { return redirect()->route('commision.index'); } public function edit($overtime) { $overtime = Overtime::find($overtime); if(\Auth::user()->can('Edit Overtime')) { if($overtime->created_by == \Auth::user()->creatorId()) { return view('overtime.edit', compact('overtime')); } else { return response()->json(['error' => __('Permission denied.')], 401); } } else { return response()->json(['error' => __('Permission denied.')], 401); } } public function update(Request $request, $overtime) { $overtime = Overtime::find($overtime); if(\Auth::user()->can('Edit Overtime')) { if($overtime->created_by == \Auth::user()->creatorId()) { $validator = \Validator::make( $request->all(), [ 'title' => 'required', 'number_of_days' => 'required', 'hours' => 'required', 'rate' => 'required', ] ); if($validator->fails()) { $messages = $validator->getMessageBag(); return redirect()->back()->with('error', $messages->first()); } $overtime->title = $request->title; $overtime->number_of_days = $request->number_of_days; $overtime->hours = $request->hours; $overtime->rate = $request->rate; $overtime->save(); return redirect()->back()->with('success', __('Overtime successfully updated.')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } else { return redirect()->back()->with('error', __('Permission denied.')); } } public function destroy(Overtime $overtime) { if(\Auth::user()->can('Delete Overtime')) { if($overtime->created_by == \Auth::user()->creatorId()) { $overtime->delete(); return redirect()->back()->with('success', __('Overtime successfully deleted.')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } else { return redirect()->back()->with('error', __('Permission denied.')); } } } Controllers/PermissionController.php000064400000004444150364311770013774 0ustar00with('permissions', $permissions); } public function create() { $roles = Role::get(); return view('permission.create')->with('roles', $roles); } public function store(Request $request) { $this->validate( $request, [ 'name' => 'required|max:40', ] ); $name = $request['name']; $permission = new Permission(); $permission->name = $name; $roles = $request['roles']; $permission->save(); if (!empty($request['roles'])) { foreach ($roles as $role) { $r = Role::where('id', '=', $role)->firstOrFail(); $permission = Permission::where('name', '=', $name)->first(); $r->givePermissionTo($permission); } } return redirect()->route('permissions.index')->with( 'success', 'Permission ' . $permission->name . ' added!' ); } public function edit(Permission $permission) { $roles = Role::where('created_by', '=', \Auth::user()->creatorId())->get(); return view('permission.edit', compact('roles', 'permission')); } public function update(Request $request, Permission $permission) { $permission = Permission::findOrFail($permission['id']); $this->validate( $request, [ 'name' => 'required|max:40', ] ); $input = $request->all(); $permission->fill($input)->save(); return redirect()->route('permissions.index')->with( 'success', 'Permission ' . $permission->name . ' updated!' ); } public function destroy($id) { $permission = Permission::findOrFail($id); $permission->delete(); return redirect()->route('permissions.index')->with( 'success', 'Permission deleted!' ); } } Controllers/ResignationController.php000064400000016572150364311770014133 0ustar00can('Manage Resignation')) { if(Auth::user()->type == 'employee') { $emp = Employee::where('user_id', '=', \Auth::user()->id)->first(); $resignations = Resignation::where('created_by', '=', \Auth::user()->creatorId())->where('employee_id', '=', $emp->id)->get(); } else { $resignations = Resignation::where('created_by', '=', \Auth::user()->creatorId())->get(); } return view('resignation.index', compact('resignations')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } public function create() { if(\Auth::user()->can('Create Resignation')) { $employees = Employee::where('created_by', \Auth::user()->creatorId())->get()->pluck('name', 'id'); return view('resignation.create', compact('employees')); } else { return response()->json(['error' => __('Permission denied.')], 401); } } public function store(Request $request) { if(\Auth::user()->can('Create Resignation')) { $validator = \Validator::make( $request->all(), [ 'notice_date' => 'required', 'resignation_date' => 'required|after_or_equal:notice_date', ] ); if($validator->fails()) { $messages = $validator->getMessageBag(); return redirect()->back()->with('error', $messages->first()); } $resignation = new Resignation(); $user = \Auth::user(); if($user->type == 'employee') { $employee = Employee::where('user_id', $user->id)->first(); $resignation->employee_id = $employee->id; } else { $resignation->employee_id = $request->employee_id; } $resignation->notice_date = $request->notice_date; $resignation->resignation_date = $request->resignation_date; $resignation->description = $request->description ; $resignation->created_by = \Auth::user()->creatorId(); $resignation->save(); $setings = Utility::settings(); if($setings['employee_resignation'] == 1) { $employee = Employee::find($resignation->employee_id); $uArr = [ 'assign_user'=>$employee->name, 'resignation_date' =>$request->notice_date, 'notice_date' =>$request->resignation_date, ]; $resp = Utility::sendEmailTemplate('employee_resignation', [$employee->email], $uArr); return redirect()->route('resignation.index')->with('success', __('Resignation successfully created.'). ((!empty($resp) && $resp['is_success'] == false && !empty($resp['error'])) ? '
' . $resp['error'] . '' : '')); $user = User::find($employee->created_by); $uArr = [ 'assign_user'=>$user->name, 'resignation_date' =>$request->notice_date, 'notice_date' =>$request->resignation_date, ]; $resp = Utility::sendEmailTemplate('employee_resignation', [$user->email], $uArr); return redirect()->route('resignation.index')->with('success', __('Resignation successfully created.'). ((!empty($resp) && $resp['is_success'] == false && !empty($resp['error'])) ? '
' . $resp['error'] . '' : '')); } return redirect()->route('resignation.index')->with('success', __('Resignation successfully created.')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } public function show(Resignation $resignation) { return redirect()->route('resignation.index'); } public function edit(Resignation $resignation) { if(\Auth::user()->can('Edit Resignation')) { $employees = Employee::where('created_by', \Auth::user()->creatorId())->get()->pluck('name', 'id'); if($resignation->created_by == \Auth::user()->creatorId()) { return view('resignation.edit', compact('resignation', 'employees')); } else { return response()->json(['error' => __('Permission denied.')], 401); } } else { return response()->json(['error' => __('Permission denied.')], 401); } } public function update(Request $request, Resignation $resignation) { if(\Auth::user()->can('Edit Resignation')) { if($resignation->created_by == \Auth::user()->creatorId()) { $validator = \Validator::make( $request->all(), [ 'notice_date' => 'required', 'resignation_date' => 'required', ] ); if($validator->fails()) { $messages = $validator->getMessageBag(); return redirect()->back()->with('error', $messages->first()); } if(\Auth::user()->type != 'employee') { $resignation->employee_id = $request->employee_id; } $resignation->notice_date = $request->notice_date; $resignation->resignation_date = $request->resignation_date; $resignation->description = $request->description; $resignation->save(); return redirect()->route('resignation.index')->with('success', __('Resignation successfully updated.')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } else { return redirect()->back()->with('error', __('Permission denied.')); } } public function destroy(Resignation $resignation) { if(\Auth::user()->can('Delete Resignation')) { if($resignation->created_by == \Auth::user()->creatorId()) { $resignation->delete(); return redirect()->route('resignation.index')->with('success', __('Resignation successfully deleted.')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } else { return redirect()->back()->with('error', __('Permission denied.')); } } } Controllers/XenditPaymentController.php000064400000015512150364311770014433 0ustar00plan_id); $plan = Plan::find($planID); $orderID = strtoupper(str_replace('.', '', uniqid('', true))); $user = Auth::user(); if ($plan) { $get_amount = $plan->price; if (!empty($request->coupon)) { $coupons = Coupon::where('code', strtoupper($request->coupon))->where('is_active', '1')->first(); if (!empty($coupons)) { $usedCoupun = $coupons->used_coupon(); $discount_value = ($plan->price / 100) * $coupons->discount; $get_amount = $plan->price - $discount_value; $orderID = strtoupper(str_replace('.', '', uniqid('', true))); $userCoupon = new UserCoupon(); $userCoupon->user = Auth::user()->id; $userCoupon->coupon = $coupons->id; $userCoupon->order = $orderID; $userCoupon->save(); if ($coupons->limit == $usedCoupun) { return redirect()->back()->with('error', __('This coupon code has expired.')); } } else { return redirect()->back()->with('error', __('This coupon code is invalid or has expired.')); } } if ($get_amount <= 0) { $orderID = strtoupper(str_replace('.', '', uniqid('', true))); $user = auth()->user(); $statuses = 'Succeeded'; $order = new Order(); $order->order_id = $orderID; $order->name = $user->name; $order->card_number = ''; $order->card_exp_month = ''; $order->card_exp_year = ''; $order->plan_name = $plan->name; $order->plan_id = $plan->id; $order->price = $get_amount; $order->price_currency = $payment_setting['currency']; $order->payment_type = __('Xendit'); $order->payment_status = $statuses; $order->receipt = ''; $order->user_id = $user->id; $order->save(); $assignPlan = $user->assignPlan($plan->id); $coupons = Coupon::find($request->coupon_id); if ($request->has('coupon') && $request->coupon != '') { $coupons = Coupon::where('code', strtoupper($request->coupon))->where('is_active', '1')->first(); if (!empty($coupons)) { $userCoupon = new UserCoupon(); $userCoupon->user = $user->id; $userCoupon->coupon = $coupons->id; $userCoupon->order = $orderID; $userCoupon->save(); $usedCoupun = $coupons->used_coupon(); if ($coupons->limit <= $usedCoupun) { $coupons->is_active = 0; $coupons->save(); } } } if ($assignPlan['is_success']) { return redirect()->route('plans.index')->with('success', __('Plan activated Successfully.')); } else { return redirect()->route('plans.index')->with('error', __($assignPlan['error'])); } } $response = ['orderId' => $orderID, 'user' => $user, 'get_amount' => $get_amount, 'plan' => $plan, 'currency' => $currency]; Xendit::setApiKey($xendit_api); $params = [ 'external_id' => $orderID, 'payer_email' => Auth::user()->email, 'description' => 'Payment for order ' . $orderID, 'amount' => $get_amount, 'callback_url' => route('plan.xendit.status'), 'success_redirect_url' => route('plan.xendit.status', $response), 'failure_redirect_url' => route('plans.index'), ]; $invoice = \Xendit\Invoice::create($params); Session::put('invoice', $invoice); return redirect($invoice['invoice_url']); } } public function planGetXenditStatus(Request $request) { $data = request()->all(); $fixedData = []; foreach ($data as $key => $value) { $fixedKey = str_replace('amp;', '', $key); $fixedData[$fixedKey] = $value; } $payment_setting = Utility::getAdminPaymentSetting(); $xendit_api = $payment_setting['xendit_api']; Xendit::setApiKey($xendit_api); $session = Session::get('invoice'); $getInvoice = \Xendit\Invoice::retrieve($session['id']); $authuser = User::find($fixedData['user']); $plan = Plan::find($fixedData['plan']); if ($getInvoice['status'] == 'PAID') { Utility::referralTransaction($plan); Order::create( [ 'order_id' => $fixedData['orderId'], 'name' => null, 'email' => null, 'card_number' => null, 'card_exp_month' => null, 'card_exp_year' => null, 'plan_name' => $plan->name, 'plan_id' => $plan->id, 'price' => $fixedData['get_amount'] == null ? 0 : $fixedData['get_amount'], 'price_currency' => $fixedData['currency'], 'txn_id' => '', 'payment_type' => __('Xendit'), 'payment_status' => 'succeeded', 'receipt' => null, 'user_id' => $fixedData['user'], ] ); $assignPlan = $authuser->assignPlan($plan->id, $request->payment_frequency); if ($assignPlan['is_success']) { return redirect()->route('plans.index')->with('success', __('Plan activated Successfully!')); } else { return redirect()->route('plans.index')->with('error', __($assignPlan['error'])); } } } } Controllers/BenefitPaymentController.php000064400000023672150364311770014562 0ustar00plan_id); $plan = Plan::find($planID); if ($plan) { $get_amount = $plan->price; try { if (!empty($request->coupon)) { $coupons = Coupon::where('code', strtoupper($request->coupon))->where('is_active', '1')->first(); if (!empty($coupons)) { $usedCoupun = $coupons->used_coupon(); $discount_value = ($plan->price / 100) * $coupons->discount; $get_amount = $plan->price - $discount_value; if ($coupons->limit == $usedCoupun) { return redirect()->back()->with('error', __('This coupon code has expired.')); } if ($get_amount <= 0) { $authuser = \Auth::user(); $authuser->plan = $plan->id; $authuser->save(); $assignPlan = $authuser->assignPlan($plan->id); if ($assignPlan['is_success'] == true && !empty($plan)) { if (!empty($authuser->payment_subscription_id) && $authuser->payment_subscription_id != '') { try { $authuser->cancel_subscription($authuser->id); } catch (\Exception $exception) { \Log::debug($exception->getMessage()); } } $orderID = strtoupper(str_replace('.', '', uniqid('', true))); $userCoupon = new UserCoupon(); $userCoupon->user = $authuser->id; $userCoupon->coupon = $coupons->id; $userCoupon->order = $orderID; $userCoupon->save(); Order::create( [ 'order_id' => $orderID, 'name' => null, 'email' => null, 'card_number' => null, 'card_exp_month' => null, 'card_exp_year' => null, 'plan_name' => $plan->name, 'plan_id' => $plan->id, 'price' => $get_amount == null ? 0 : $get_amount, 'price_currency' => !empty($admin_payment_setting['currency']) ? $admin_payment_setting['currency'] : 'USD', 'txn_id' => '', 'payment_type' => 'Benefit', 'payment_status' => 'success', 'receipt' => null, 'user_id' => $authuser->id, ] ); $assignPlan = $authuser->assignPlan($plan->id); return redirect()->route('plans.index')->with('success', __('Plan Successfully Activated')); } } } else { return redirect()->back()->with('error', __('This coupon code is invalid or has expired.')); } } $coupon = (empty($request->coupon)) ? "0" : $request->coupon; $orderID = strtoupper(str_replace('.', '', uniqid('', true))); $userData = [ "amount" => $get_amount, "currency" => !empty($admin_payment_setting['currency']) ? $admin_payment_setting['currency'] : 'USD', "customer_initiated" => true, "threeDSecure" => true, "save_card" => false, "description" => " Plan - " . $plan->name, "metadata" => ["udf1" => "Metadata 1"], "reference" => ["transaction" => "txn_01", "order" => "ord_01"], "receipt" => ["email" => true, "sms" => true], "customer" => ["first_name" => $objUser->name, "middle_name" => "", "last_name" => "", "email" => $objUser->email, "phone" => ["country_code" => 965, "number" => 51234567]], "source" => ["id" => "src_bh.benefit"], "post" => ["url" => "https://webhook.site/fd8b0712-d70a-4280-8d6f-9f14407b3bbd"], "redirect" => ["url" => route('benefit.call_back', ['plan_id' => $plan->id, 'amount' => $get_amount, 'coupon' => $coupon])], ]; $responseData = json_encode($userData); $client = new Client(); try { $response = $client->request('POST', 'https://api.tap.company/v2/charges', [ 'body' => $responseData, 'headers' => [ 'Authorization' => 'Bearer ' . $secret_key, 'accept' => 'application/json', 'content-type' => 'application/json', ], ]); } catch (\Throwable $th) { return redirect()->back()->with('error','Currency Not Supported.Contact To Your Site Admin'); } $data = $response->getBody(); $res = json_decode($data); return redirect($res->transaction->url); } catch (\Exception $e) { return redirect()->back()->with('error', $e); } } else { return redirect()->route('plans.index')->with('error', __('Plan is deleted.')); } } public function call_back(Request $request) { $admin_payment_setting = Utility::getAdminPaymentSetting(); $secret_key = $admin_payment_setting['benefit_secret_key']; $user = \Auth::user(); $plan = Plan::find($request->plan_id); $couponCode = $request->coupon; $getAmount = $request->amount; $orderID = strtoupper(str_replace('.', '', uniqid('', true))); if ($couponCode != 0) { $coupons = Coupon::where('code', strtoupper($couponCode))->where('is_active', '1')->first(); $request['coupon_id'] = $coupons->id; } else { $coupons = null; } try { $post = $request->all(); $client = new Client(); $response = $client->request('GET', 'https://api.tap.company/v2/charges/' . $post['tap_id'], [ 'headers' => [ 'Authorization' => 'Bearer ' . $secret_key, 'accept' => 'application/json', ], ]); $json = $response->getBody(); $data = json_decode($json); $status_code = $data->gateway->response->code; if ($status_code == '00') { Utility::referralTransaction($plan); $order = new Order(); $order->order_id = $orderID; $order->name = $user->name; $order->card_number = ''; $order->card_exp_month = ''; $order->card_exp_year = ''; $order->plan_name = $plan->name; $order->plan_id = $plan->id; $order->price = $getAmount; $order->price_currency = !empty($admin_payment_setting['currency']) ? $admin_payment_setting['currency'] : 'USD'; $order->payment_type = __('Benefit'); $order->payment_status = 'success'; $order->txn_id = ''; $order->receipt = ''; $order->user_id = $user->id; $order->save(); $assignPlan = $user->assignPlan($plan->id); $coupons = Coupon::find($request->coupon_id); if (!empty($request->coupon_id)) { if (!empty($coupons)) { $userCoupon = new UserCoupon(); $userCoupon->user = $user->id; $userCoupon->coupon = $coupons->id; $userCoupon->order = $orderID; $userCoupon->save(); $usedCoupun = $coupons->used_coupon(); if ($coupons->limit <= $usedCoupun) { $coupons->is_active = 0; $coupons->save(); } } } if ($assignPlan['is_success']) { return redirect()->route('plans.index')->with('success', __('Plan activated Successfully.')); } else { return redirect()->route('plans.index')->with('error', __($assignPlan['error'])); } } else { return redirect()->route('plans.index')->with('error', __('Your Transaction is fail please try again')); } } catch (\Exception $e) { return redirect()->route('plans.index')->with('error', __($e->getMessage())); } } }Controllers/PaypalController.php000064400000024670150364311770013075 0ustar00invoiceData->created_by); } if ($payment_setting['paypal_mode'] == 'live') { config([ 'paypal.live.client_id' => isset($payment_setting['paypal_client_id']) ? $payment_setting['paypal_client_id'] : '', 'paypal.live.client_secret' => isset($payment_setting['paypal_secret_key']) ? $payment_setting['paypal_secret_key'] : '', 'paypal.mode' => isset($payment_setting['paypal_mode']) ? $payment_setting['paypal_mode'] : '', ]); } else { config([ 'paypal.sandbox.client_id' => isset($payment_setting['paypal_client_id']) ? $payment_setting['paypal_client_id'] : '', 'paypal.sandbox.client_secret' => isset($payment_setting['paypal_secret_key']) ? $payment_setting['paypal_secret_key'] : '', 'paypal.mode' => isset($payment_setting['paypal_mode']) ? $payment_setting['paypal_mode'] : '', ]); } } public function planPayWithPaypal(Request $request) { $payment_setting = Utility::getAdminPaymentSetting(); $planID = \Illuminate\Support\Facades\Crypt::decrypt($request->plan_id); $plan = Plan::find($planID); $this->paymentConfig(); $provider = new PayPalClient; $provider->setApiCredentials(config('paypal')); $get_amount = $plan->price; if ($plan) { try { $coupon_id = 0; $price = $plan->price; if (!empty($request->coupon)) { $coupons = Coupon::where('code', strtoupper($request->coupon))->where('is_active', '1')->first(); if (!empty($coupons)) { $usedCoupun = $coupons->used_coupon(); $discount_value = ($plan->price / 100) * $coupons->discount; $price = $plan->price - $discount_value; if ($coupons->limit == $usedCoupun) { return redirect()->back()->with('error', __('This coupon code has expired.')); } $coupon_id = $coupons->id; } else { return redirect()->back()->with('error', __('This coupon code is invalid or has expired.')); } } if ($price <= 0) { $order_id = strtoupper(str_replace('.', '', uniqid('', true))); $user = Auth::user(); if ($request->has('coupon') && $request->coupon != '') { $coupons = Coupon::where('code', strtoupper($request->coupon))->where('is_active', '1')->first(); if (!empty($coupons)) { $userCoupon = new UserCoupon(); $userCoupon->user = $user->id; $userCoupon->coupon = $coupons->id; $userCoupon->order = $order_id; $userCoupon->save(); $usedCoupun = $coupons->used_coupon(); if ($coupons->limit <= $usedCoupun) { $coupons->is_active = 0; $coupons->save(); } } } $order = new Order(); $order->order_id = $order_id; $order->name = $user->name; $order->card_number = ''; $order->card_exp_month = ''; $order->card_exp_year = ''; $order->plan_name = $plan->name; $order->plan_id = $plan->id; $order->price = $price; $order->price_currency = $payment_setting['currency']; $order->payment_type = __('PAYPAL'); $order->payment_status = 'success'; $order->txn_id = ''; $order->receipt = ''; $order->user_id = $user->id; $order->save(); $assignPlan = $user->assignPlan($plan->id); return redirect()->route('plans.index')->with('success', __('Plan activated Successfully.')); } $paypalToken = $provider->getAccessToken(); $response = $provider->createOrder([ "intent" => "CAPTURE", "application_context" => [ "return_url" => route('plan.get.payment.status', [$plan->id, 'price' => $price, 'coupon_id' => $coupon_id]), "cancel_url" => route('plan.get.payment.status', [$plan->id, 'price' => $price, 'coupon_id' => $coupon_id]), ], "purchase_units" => [ 0 => [ "amount" => [ "currency_code" => 'USD' /*Utility::getValByName('site_currency')*/, "value" => $price ] ] ] ]); if (isset($response['id']) && $response['id'] != null) { // redirect to approve href foreach ($response['links'] as $links) { if ($links['rel'] == 'approve') { return redirect()->away($links['href']); } } return redirect() ->route('plans.index') ->with('error', 'Something went wrong.'); } else { return redirect() ->route('plans.index') ->with('error', $response['message'] ?? 'Something went wrong.'); } } catch (\Exception $e) { return redirect()->route('plans.index')->with('error', __($e->getMessage())); } } else { return redirect()->route('plans.index')->with('error', __('Plan is deleted.')); } } public function planGetPaymentStatus(Request $request, $plan_id) { $this->paymentconfig(); $payment_setting = Utility::getAdminPaymentSetting(); $user = Auth::user(); $plan = Plan::find($plan_id); if ($plan) { // $this->paymentConfig(); $provider = new PayPalClient; $provider->setApiCredentials(config('paypal')); $provider->getAccessToken(); $response = $provider->capturePaymentOrder($request['token']); $payment_id = Session::get('paypal_payment_id'); $order_id = strtoupper(str_replace('.', '', uniqid('', true))); // $status = ucwords(str_replace('_', ' ', $result['state'])); if ($request->has('coupon_id') && $request->coupon_id != '') { $coupons = Coupon::find($request->coupon_id); if (!empty($coupons)) { $userCoupon = new UserCoupon(); $userCoupon->user = $user->id; $userCoupon->coupon = $coupons->id; $userCoupon->order = $order_id; $userCoupon->save(); $usedCoupun = $coupons->used_coupon(); if ($coupons->limit <= $usedCoupun) { $coupons->is_active = 0; $coupons->save(); } } } if (isset($response['status']) && $response['status'] == 'COMPLETED') { if ($response['status'] == 'COMPLETED') { $statuses = 'success'; } Utility::referralTransaction($plan); $order = new Order(); $order->order_id = $order_id; $order->name = $user->name; $order->card_number = ''; $order->card_exp_month = ''; $order->card_exp_year = ''; $order->plan_name = $plan->name; $order->plan_id = $plan->id; $order->price = $request->price ? $request->price : 0; $order->price_currency = $payment_setting['currency']; $order->txn_id = $payment_id; $order->payment_type = __('PAYPAL'); $order->payment_status = $statuses; $order->txn_id = ''; $order->receipt = ''; $order->user_id = $user->id; $order->save(); $assignPlan = $user->assignPlan($plan->id); if ($assignPlan['is_success']) { return redirect()->route('plans.index')->with('success', __('Plan activated Successfully.')); } else { return redirect()->route('plans.index')->with('error', __($assignPlan['error'])); } return redirect() ->route('plans.index') ->with('success', 'Transaction complete.'); } else { return redirect() ->route('plans.index') ->with('error', $response['message'] ?? 'Something went wrong.'); } } else { return redirect()->route('plans.index')->with('error', __('Plan is deleted.')); } } } Controllers/AccountListController.php000064400000013025150364311770014067 0ustar00can('Manage Account List')) { $accountlists = AccountList::where('created_by', '=', Auth::user()->creatorId())->get(); return view('accountlist.index', compact('accountlists')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } public function create() { if(\Auth::user()->can('Create Account List')) { return view('accountlist.create'); } else { return response()->json(['error' => __('Permission denied.')], 401); } } public function store(Request $request) { if(\Auth::user()->can('Create Account List')) { $validator = \Validator::make( $request->all(), [ 'account_name' => 'required', 'initial_balance' => 'required', 'account_number' => 'required', 'branch_code' => 'required', 'bank_branch' => 'required', ] ); if($validator->fails()) { $messages = $validator->getMessageBag(); return redirect()->back()->with('error', $messages->first()); } $accountlist = new AccountList(); $accountlist->account_name = $request->account_name; $accountlist->initial_balance = $request->initial_balance; $accountlist->account_number = $request->account_number; $accountlist->branch_code = $request->branch_code; $accountlist->bank_branch = $request->bank_branch; $accountlist->created_by = \Auth::user()->creatorId(); $accountlist->save(); return redirect()->route('accountlist.index')->with('success', __('Account successfully created.')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } public function show(AccountList $accountlist) { return redirect()->route('accountlist.index'); } public function edit(AccountList $accountlist) { if(\Auth::user()->can('Edit Account List')) { if($accountlist->created_by == \Auth::user()->creatorId()) { return view('accountlist.edit', compact('accountlist')); } else { return response()->json(['error' => __('Permission denied.')], 401); } } else { return response()->json(['error' => __('Permission denied.')], 401); } } public function update(Request $request, AccountList $accountlist) { if(\Auth::user()->can('Edit Account List')) { if($accountlist->created_by == \Auth::user()->creatorId()) { $validator = \Validator::make( $request->all(), [ 'account_name' => 'required', 'initial_balance' => 'required', 'account_number' => 'required', 'branch_code' => 'required', 'bank_branch' => 'required', ] ); if($validator->fails()) { $messages = $validator->getMessageBag(); return redirect()->back()->with('error', $messages->first()); } $accountlist->account_name = $request->account_name; $accountlist->initial_balance = $request->initial_balance; $accountlist->account_number = $request->account_number; $accountlist->branch_code = $request->branch_code; $accountlist->bank_branch = $request->bank_branch; $accountlist->save(); return redirect()->route('accountlist.index')->with('success', __('Account successfully updated.')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } else { return redirect()->back()->with('error', __('Permission denied.')); } } public function destroy(AccountList $accountlist) { if(\Auth::user()->can('Delete Account List')) { if($accountlist->created_by == \Auth::user()->creatorId()) { $accountlist->delete(); return redirect()->route('accountlist.index')->with('success', __('Account successfully deleted.')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } else { return redirect()->back()->with('error', __('Permission denied.')); } } public function account_balance() { $accountLists = AccountList::where('created_by', \Auth::user()->creatorId())->get(); return view('accountlist.account_balance', compact('accountLists')); } } Controllers/EventController.php000064400000040010150364311770012712 0ustar00can('Manage Event')) { $employees = Employee::where('created_by', '=', \Auth::user()->creatorId())->get(); $events = LocalEvent::where('created_by', '=', \Auth::user()->creatorId())->get(); $today_date = date('m'); // $current_month_event = Event::select('id','start_date','end_date', 'title', 'created_at','color')->whereRaw('MONTH(start_date)=' . $today_date,'MONTH(end_date)=' . $today_date)->get(); $current_month_event = LocalEvent::where('created_by', \Auth::user()->creatorId())->select('id', 'start_date', 'end_date', 'title', 'created_at', 'color')->whereNotNull(['start_date', 'end_date'])->whereMonth('start_date', $today_date)->whereMonth('end_date', $today_date)->get(); $arrEvents = []; foreach ($events as $event) { $arr['id'] = $event['id']; $arr['title'] = $event['title']; $arr['start'] = $event['start_date']; $arr['end'] = $event['end_date']; // $arr['allDay'] = !0; // $arr['className'] = 'bg-danger'; $arr['className'] = $event['color']; // $arr['borderColor'] = "#fff"; // $arr['textColor'] = "white"; $arr['url'] = route('event.edit', $event['id']); $arrEvents[] = $arr; } // $arrEvents = str_replace('"[', '[', str_replace(']"', ']', json_encode($arrEvents))); $arrEvents = json_encode($arrEvents); return view('event.index', compact('arrEvents', 'employees', 'current_month_event', 'events')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } public function create() { if (\Auth::user()->can('Create Event')) { $branch = Branch::where('created_by', '=', \Auth::user()->creatorId())->get(); $departments = Department::where('created_by', '=', \Auth::user()->creatorId())->get(); $employees = Employee::where('created_by', '=', \Auth::user()->creatorId())->get()->pluck('name', 'id'); return view('event.create', compact('employees', 'branch', 'departments')); } else { return response()->json(['error' => __('Permission denied.')], 401); } } public function store(Request $request) { if (\Auth::user()->can('Create Event')) { $validator = \Validator::make( $request->all(), [ 'branch_id' => 'required', 'department_id' => 'required', 'employee_id' => 'required', 'title' => 'required', 'start_date' => 'required', 'end_date' => 'required', 'color' => 'required', ] ); if ($validator->fails()) { $messages = $validator->getMessageBag(); return redirect()->back()->with('error', $messages->first()); } $event = new LocalEvent(); $event->branch_id = $request->branch_id; $event->department_id = json_encode($request->department_id); $event->employee_id = json_encode($request->employee_id); $event->title = $request->title; $event->start_date = $request->start_date; $event->end_date = $request->end_date; $event->color = $request->color; $event->description = $request->description; $event->created_by = \Auth::user()->creatorId(); $event->save(); // slack $setting = Utility::settings(\Auth::user()->creatorId()); $branch = Branch::find($request->branch_id); if (isset($setting['event_notification']) && $setting['event_notification'] == 1) { // $msg = $request->title . ' ' . __("for branch") . ' ' . $branch->name . ' ' . ("from") . ' ' . $request->start_date . ' ' . __("to") . ' ' . $request->end_date . '.'; $uArr = [ 'event_name' => $request->title, 'branch_name' => $branch->name, 'start_date' => $request->start_date, 'end_date' => $request->end_date, ]; Utility::send_slack_msg('new_event', $uArr); } //telegram $setting = Utility::settings(\Auth::user()->creatorId()); $branch = Branch::find($request->branch_id); if (isset($setting['telegram_event_notification']) && $setting['telegram_event_notification'] == 1) { // $msg = $request->title . ' ' . __("for branch") . ' ' . $branch->name . ' ' . ("from") . ' ' . $request->start_date . ' ' . __("to") . ' ' . $request->end_date . '.'; $uArr = [ 'event_name' => $request->title, 'branch_name' => $branch->name, 'start_date' => $request->start_date, 'end_date' => $request->end_date, ]; Utility::send_telegram_msg('new_event', $uArr); } //twilio $setting = Utility::settings(\Auth::user()->creatorId()); $branch = Branch::find($request->branch_id); $departments = Department::where('branch_id', $request->branch_id)->first(); $employee = Employee::where('branch_id', $request->branch_id)->first(); if (isset($setting['twilio_event_notification']) && $setting['twilio_event_notification'] == 1) { // $employeess = Employee::whereIn('branch_id', $request->employee_id)->get(); // foreach ($employeess as $key => $employee) { // $msg = $request->title . ' ' . __("for branch") . ' ' . $branch->name . ' ' . ("from") . ' ' . $request->start_date . ' ' . __("to") . ' ' . $request->end_date . '.'; $uArr = [ 'event_name' => $request->title, 'branch_name' => $branch->name, 'start_date' => $request->start_date, 'end_date' => $request->end_date, ]; Utility::send_twilio_msg($employee->phone, 'new_event', $uArr); // } } if (in_array('0', $request->employee_id)) { $departmentEmployee = Employee::whereIn('department_id', $request->department_id)->get()->pluck('id'); $departmentEmployee = $departmentEmployee; } else { $departmentEmployee = $request->employee_id; } foreach ($departmentEmployee as $employee) { $eventEmployee = new EventEmployee(); $eventEmployee->event_id = $event->id; $eventEmployee->employee_id = $employee; $eventEmployee->created_by = \Auth::user()->creatorId(); $eventEmployee->save(); } // google calendar if ($request->get('synchronize_type') == 'google_calender') { $type = 'event'; $request1 = new GoogleEvent(); $request1->title = $request->title; $request1->start_date = $request->start_date; $request1->end_date = $request->end_date; Utility::addCalendarData($request1, $type); } //webhook $module = 'New Event'; $webhook = Utility::webhookSetting($module); if ($webhook) { $parameter = json_encode($event); // 1 parameter is URL , 2 parameter is data , 3 parameter is method $status = Utility::WebhookCall($webhook['url'], $parameter, $webhook['method']); if ($status == true) { return redirect()->back()->with('success', __('Event successfully created.')); } else { return redirect()->back()->with('error', __('Webhook call failed.')); } } return redirect()->route('event.index')->with('success', __('Event successfully created.')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } public function show(Event $event) { // $events = Event::where('created_by', '=', \Auth::user()->creatorId())->get(); return redirect()->route('event.index'); } public function edit($event) { $employees = Employee::where('created_by', '=', \Auth::user()->creatorId())->get()->pluck('name', 'id'); $event = LocalEvent::find($event); return view('event.edit', compact('event', 'employees')); } public function update(Request $request, LocalEvent $event) { if (\Auth::user()->can('Edit Event')) { if ($event->created_by == \Auth::user()->creatorId()) { $validator = \Validator::make( $request->all(), [ 'title' => 'required', 'start_date' => 'required', 'end_date' => 'required', 'color' => 'required', ] ); if ($validator->fails()) { $messages = $validator->getMessageBag(); return redirect()->back()->with('error', $messages->first()); } $event->title = $request->title; $event->start_date = $request->start_date; $event->end_date = $request->end_date; $event->color = $request->color; $event->description = $request->description; $event->save(); // return redirect()->route('event.index')->with('success', __('Event successfully updated.')); return redirect()->back()->with('success', __('Event successfully updated.')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } else { return redirect()->back()->with('error', __('Permission denied.')); } } public function destroy(LocalEvent $event) { if (\Auth::user()->can('Delete Event')) { if ($event->created_by == \Auth::user()->creatorId()) { $event->delete(); return redirect()->route('event.index')->with('success', __('Event successfully deleted.')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } else { return redirect()->back()->with('error', __('Permission denied.')); } } public function export() { $name = 'event' . date('Y-m-d i:h:s'); $data = Excel::download(new EventExport(), $name . '.xlsx'); return $data; } public function importFile() { return view('event.import'); } public function import(Request $request) { $rules = [ 'file' => 'required|mimes:csv,txt', ]; $validator = \Validator::make($request->all(), $rules); if ($validator->fails()) { $messages = $validator->getMessageBag(); return redirect()->back()->with('error', $messages->first()); } $events = (new EventImport())->toArray(request()->file('file'))[0]; $totalEvents = count($events) - 1; $errorArray = []; for ($i = 1; $i <= count($events) - 1; $i++) { $event = $events[$i]; $eventsByTitle = LocalEvent::where('title', $event[2])->first(); if (!empty($eventsByTitle)) { $eventData = $eventsByTitle; } else { $eventData = new LocalEvent(); } $eventData->branch_id = $event[0]; $eventData->department_id = $event[1]; $eventData->employee_id = '["0"]'; $eventData->title = $event[2]; $eventData->start_date = $event[3]; $eventData->end_date = $event[4]; $eventData->color = $event[5]; $eventData->description = $event[6]; $eventData->created_by = $event[7]; if (empty($eventData)) { $errorArray[] = $eventData; } else { $eventData->save(); } } $errorRecord = []; if (empty($errorArray)) { $data['status'] = 'success'; $data['msg'] = __('Record successfully imported'); } else { $data['status'] = 'error'; $data['msg'] = count($errorArray) . ' ' . __('Record imported fail out of' . ' ' . $totalEvents . ' ' . 'record'); foreach ($errorArray as $errorData) { $errorRecord[] = implode(',', $errorData); } \Session::put('errorArray', $errorRecord); } return redirect()->back()->with($data['status'], $data['msg']); } public function getdepartment(Request $request) { if ($request->branch_id == 0) { $departments = Department::where('created_by', '=', \Auth::user()->creatorId())->get()->pluck('name', 'id')->toArray(); } else { $departments = Department::where('created_by', '=', \Auth::user()->creatorId())->where('branch_id', $request->branch_id)->get()->pluck('name', 'id')->toArray(); } return response()->json($departments); } public function getemployee(Request $request) { if ($request->department_id == 0) { $employees = Employee::where('created_by', '=', \Auth::user()->creatorId())->get()->pluck('name', 'id'); } else { $employees = Employee::where('created_by', '=', \Auth::user()->creatorId())->whereIn('department_id',$request->department_id)->get()->pluck('name', 'id')->toArray(); } return response()->json($employees); } public function showData($id) { $employees = Employee::where('created_by', '=', \Auth::user()->creatorId())->get()->pluck('name', 'id'); $event = LocalEvent::find($id); return view('event.edit', compact('event', 'employees')); } public function get_event_data(Request $request) { $arrayJson = []; if($request->get('calender_type') == 'google_calender') { $type ='event'; $arrayJson = Utility::getCalendarData($type); } else { $data =LocalEvent::where('created_by', \Auth::user()->creatorId())->get(); foreach($data as $val) { $end_date=date_create($val->end_date); date_add($end_date,date_interval_create_from_date_string("1 days")); $arrayJson[] = [ "id"=> $val->id, "title" => $val->title, "start" => $val->start_date, "end" => date_format($end_date,"Y-m-d H:i:s"), "className" => $val->color, "allDay" => true, "url"=> route('event.edit', $val['id']), ]; } } return $arrayJson; } } Controllers/RoleController.php000064400000012444150364311770012544 0ustar00can('Manage Role')) { $roles = Role::where('created_by', '=', \Auth::user()->creatorId())->get(); return view('role.index')->with('roles', $roles); } else { return redirect()->back()->with('error', 'Permission denied.'); } } public function create() { if (\Auth::user()->can('Create Role')) { $user = \Auth::user(); if ($user->type == 'super admin' || $user->type == 'company') { $permissions = Permission::all()->pluck('name', 'id')->toArray(); } else { $permissions = new Collection(); foreach ($user->roles as $role) { $permissions = $permissions->merge($role->permissions); } $permissions = $permissions->pluck('name', 'id')->toArray(); } return view('role.create', ['permissions' => $permissions]); } else { return redirect()->back()->with('error', 'Permission denied.'); } } public function store(Request $request) { if (\Auth::user()->can('Create Role')) { $role = Role::where('name', '=', $request->name)->where('created_by', \Auth::user()->creatorId())->first(); if (isset($role)) { return redirect()->back()->with('error', __('The Role has Already Been Taken.')); } else { $this->validate( $request, [ 'name' => 'required|max:100|unique:roles,name,NULL,id,created_by,' . \Auth::user()->creatorId(), 'permissions' => 'required', ] ); $name = $request['name']; $role = new Role(); $role->name = $name; $role->created_by = \Auth::user()->creatorId(); $permissions = $request['permissions']; $role->save(); foreach ($permissions as $permission) { $p = Permission::where('id', '=', $permission)->firstOrFail(); $role = Role::where('name', '=', $name)->where('created_by', \Auth::user()->creatorId())->first(); $role->givePermissionTo($p); } return redirect()->route('roles.index')->with('success', 'Role successfully created.'); } } else { return redirect()->back()->with('error', 'Permission denied.'); } } public function edit(Role $role) { if (\Auth::user()->can('Edit Role')) { $user = \Auth::user(); if ($user->type == 'super admin' || $user->type == 'company') { $permissions = Permission::all()->pluck('name', 'id')->toArray(); } else { $permissions = new Collection(); foreach ($user->roles as $role1) { $permissions = $permissions->merge($role1->permissions); } $permissions = $permissions->pluck('name', 'id')->toArray(); } return view('role.edit', compact('role', 'permissions')); } else { return redirect()->back()->with('error', 'Permission denied.'); } } public function update(Request $request, Role $role) { if (\Auth::user()->can('Edit Role')) { if ($role->name == 'employee') { $this->validate( $request, [ 'permissions' => 'required', ] ); } else { $this->validate( $request, [ 'name' => 'required|max:100|unique:roles,name,' . $role['id'] . ',id,created_by,' . \Auth::user()->creatorId(), 'permissions' => 'required', ] ); } $input = $request->except(['permissions']); $permissions = $request['permissions']; $role->fill($input)->save(); $p_all = Permission::all(); foreach ($p_all as $p) { $role->revokePermissionTo($p); } foreach ($permissions as $permission) { $p = Permission::where('id', '=', $permission)->firstOrFail(); $role->givePermissionTo($p); } return redirect()->route('roles.index')->with('success', 'Role successfully updated.'); } else { return redirect()->back()->with('error', 'Permission denied.'); } } public function destroy(Role $role) { if (\Auth::user()->can('Delete Role')) { $role->delete(); return redirect()->route('roles.index')->with( 'success', 'Role successfully deleted.' ); } else { return redirect()->back()->with('error', 'Permission denied.'); } } } Controllers/DepositController.php000064400000016764150364311770013263 0ustar00can('Manage Deposit')) { $deposits = Deposit::where('created_by', '=', Auth::user()->creatorId())->with(['accounts', 'payers', 'income_categorys', 'payment_types'])->get(); return view('deposit.index', compact('deposits')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } public function create() { if(\Auth::user()->can('Create Deposit')) { $deposits = Deposit::where('created_by', '=', \Auth::user()->creatorId())->get(); $accounts = AccountList::where('created_by', '=', \Auth::user()->creatorId())->get()->pluck('account_name', 'id'); $incomeCategory = IncomeType::where('created_by', '=', \Auth::user()->creatorId())->get()->pluck('name', 'id'); $payers = Payer::where('created_by', '=', \Auth::user()->creatorId())->get()->pluck('payer_name', 'id'); $paymentTypes = PaymentType::where('created_by', '=', \Auth::user()->creatorId())->get()->pluck('name', 'id'); return view('deposit.create', compact('deposits', 'accounts', 'incomeCategory', 'payers', 'paymentTypes')); } else { return response()->json(['error' => __('Permission denied.')], 401); } } public function store(Request $request) { if(\Auth::user()->can('Create Deposit')) { $validator = \Validator::make( $request->all(), [ 'account_id' => 'required', 'amount' => 'required|numeric', 'date' => 'required', 'income_category_id' => 'required', 'payer_id' => 'required', 'payment_type_id' => 'required', ] ); if($validator->fails()) { $messages = $validator->getMessageBag(); return redirect()->back()->with('error', $messages->first()); } $deposit = new Deposit(); $deposit->account_id = $request->account_id; $deposit->amount = $request->amount; $deposit->date = $request->date; $deposit->income_category_id = $request->income_category_id; $deposit->payer_id = $request->payer_id; $deposit->payment_type_id = $request->payment_type_id; $deposit->referal_id = $request->referal_id; $deposit->description = $request->description; $deposit->created_by = \Auth::user()->creatorId(); $deposit->save(); AccountList::add_Balance($request->account_id, $request->amount); return redirect()->route('deposit.index')->with('success', __('Deposit successfully created.')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } public function show(Deposit $deposit) { return redirect()->route('deposit.index'); } public function edit(Deposit $deposit) { if(\Auth::user()->can('Edit Deposit')) { if($deposit->created_by == \Auth::user()->creatorId()) { $deposits = Deposit::where('created_by', '=', \Auth::user()->creatorId())->get(); $accounts = AccountList::where('created_by', '=', \Auth::user()->creatorId())->get()->pluck('account_name', 'id'); $incomeCategory = IncomeType::where('created_by', '=', \Auth::user()->creatorId())->get()->pluck('name', 'id'); $payers = Payer::where('created_by', '=', \Auth::user()->creatorId())->get()->pluck('payer_name', 'id'); $paymentTypes = PaymentType::where('created_by', '=', \Auth::user()->creatorId())->get()->pluck('name', 'id'); return view('deposit.edit', compact('deposit', 'accounts', 'incomeCategory', 'payers', 'paymentTypes')); } else { return response()->json(['error' => __('Permission denied.')], 401); } } else { return response()->json(['error' => __('Permission denied.')], 401); } } public function update(Request $request, Deposit $deposit) { if(\Auth::user()->can('Edit Deposit')) { if($deposit->created_by == \Auth::user()->creatorId()) { $validator = \Validator::make( $request->all(), [ 'account_id' => 'required', 'amount' => 'required|numeric', 'date' => 'required', 'income_category_id' => 'required', 'payer_id' => 'required', 'payment_type_id' => 'required', ] ); if($validator->fails()) { $messages = $validator->getMessageBag(); return redirect()->back()->with('error', $messages->first()); } $deposit->account_id = $request->account_id; $deposit->amount = $request->amount; $deposit->date = $request->date; $deposit->income_category_id = $request->income_category_id; $deposit->payer_id = $request->payer_id; $deposit->payment_type_id = $request->payment_type_id; $deposit->referal_id = $request->referal_id; $deposit->description = $request->description; $deposit->save(); return redirect()->route('deposit.index')->with('success', __('Deposit successfully updated.')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } else { return redirect()->back()->with('error', __('Permission denied.')); } } public function destroy(Deposit $deposit) { if(\Auth::user()->can('Delete Deposit')) { if($deposit->created_by == \Auth::user()->creatorId()) { $deposit->delete(); return redirect()->route('deposit.index')->with('success', __('Deposit successfully deleted.')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } else { return redirect()->back()->with('error', __('Permission denied.')); } } public function export(Request $request) { $name = 'Deposite' . date('Y-m-d i:h:s'); $data = Excel::download(new DepositExport(), $name . '.xlsx'); return $data; } } Controllers/BranchController.php000064400000012732150364311770013040 0ustar00can('Manage Branch')) { $branches = Branch::where('created_by', '=', \Auth::user()->creatorId())->get(); return view('branch.index', compact('branches')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } public function create() { if (\Auth::user()->can('Create Branch')) { return view('branch.create'); } else { return response()->json(['error' => __('Permission denied.')], 401); } } public function store(Request $request) { if (\Auth::user()->can('Create Branch')) { $validator = \Validator::make( $request->all(), [ 'name' => 'required', ] ); if ($validator->fails()) { $messages = $validator->getMessageBag(); return redirect()->back()->with('error', $messages->first()); } $branch = new Branch(); $branch->name = $request->name; $branch->created_by = \Auth::user()->creatorId(); $branch->save(); return redirect()->route('branch.index')->with('success', __('Branch successfully created.')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } public function show(Branch $branch) { return redirect()->route('branch.index'); } public function edit(Branch $branch) { if (\Auth::user()->can('Edit Branch')) { if ($branch->created_by == \Auth::user()->creatorId()) { return view('branch.edit', compact('branch')); } else { return response()->json(['error' => __('Permission denied.')], 401); } } else { return response()->json(['error' => __('Permission denied.')], 401); } } public function update(Request $request, Branch $branch) { if (\Auth::user()->can('Edit Branch')) { if ($branch->created_by == \Auth::user()->creatorId()) { $validator = \Validator::make( $request->all(), [ 'name' => 'required', ] ); if ($validator->fails()) { $messages = $validator->getMessageBag(); return redirect()->back()->with('error', $messages->first()); } $branch->name = $request->name; $branch->save(); return redirect()->route('branch.index')->with('success', __('Branch successfully updated.')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } else { return redirect()->back()->with('error', __('Permission denied.')); } } public function destroy(Branch $branch) { if (\Auth::user()->can('Delete Branch')) { if ($branch->created_by == \Auth::user()->creatorId()) { $employee = Employee::where('branch_id', $branch->id)->get(); if (count($employee) == 0) { $department = Department::where('branch_id', $branch->id)->first(); if (!empty($department)) { $designation = Designation::where('department_id', $department->id)->first(); } if (isset($department)) { Designation::where('department_id', $department->branch_id)->delete(); $department->delete(); } if (isset($designation)) { Designation::where('department_id', $department->branch_id)->delete(); $designation->delete(); } $branch->delete(); } else { return redirect()->route('branch.index')->with('error', __('This branch has employees. Please remove the employee from this branch.')); } return redirect()->route('branch.index')->with('success', __('Branch successfully deleted.')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } else { return redirect()->back()->with('error', __('Permission denied.')); } } public function getdepartment(Request $request) { if ($request->branch_id == 0) { $departments = Department::get()->pluck('name', 'id')->toArray(); } else { $departments = Department::where('branch_id', $request->branch_id)->get()->pluck('name', 'id')->toArray(); } return response()->json($departments); } public function getemployee(Request $request) { if (in_array('0', $request->department_id)) { $employees = Employee::get()->pluck('name', 'id')->toArray(); } else { $employees = Employee::whereIn('department_id', $request->department_id)->get()->pluck('name', 'id')->toArray(); } return response()->json($employees); } } Controllers/LanguageController.php000064400000023440150364311770013364 0ustar00lang = $lang; $user->save(); if ($user->lang == 'ar' || $user->lang == 'he') { $value = 'on'; } else { $value = 'off'; } if ($user->type == 'super admin') { \DB::insert( 'insert into settings (`value`, `name`,`created_by`) values (?, ?, ?) ON DUPLICATE KEY UPDATE `value` = VALUES(`value`) ', [ $value, 'SITE_RTL', $user->creatorId(), ] ); } else { \DB::insert( 'insert into settings (`value`, `name`,`created_by`) values (?, ?, ?) ON DUPLICATE KEY UPDATE `value` = VALUES(`value`) ', [ $value, 'SITE_RTL', $user->creatorId(), ] ); } $check=DB::table('settings')->where('name','theme_color')->where('created_by',\Auth::user()->creatorId())->first(); if(empty($check)) { $super_admin=Utility::settings(1); \DB::insert( 'insert into settings (`value`, `name`,`created_by`) values (?, ?, ?) ON DUPLICATE KEY UPDATE `value` = VALUES(`value`) ', [ $super_admin['theme_color'], 'theme_color', $user->creatorId(), ] ); \DB::insert( 'insert into settings (`value`, `name`,`created_by`) values (?, ?, ?) ON DUPLICATE KEY UPDATE `value` = VALUES(`value`) ', [ $super_admin['color_flag'], 'color_flag', $user->creatorId(), ] ); } return redirect()->back()->with('success', __('Language change successfully.')); } public function manageLanguage($currantLang) { if (\Auth::user()->can('Manage Language')) { if (\Auth::user()->type == 'super admin') { $languages = Languages::pluck('fullName', 'code'); $settings = \App\Models\Utility::settings(); if (!empty($settings['disable_lang'])) { $disabledLang = explode(',', $settings['disable_lang']); } else { $disabledLang = []; } $dir = base_path() . '/resources/lang/' . $currantLang; if (!is_dir($dir)) { $dir = base_path() . '/resources/lang/en'; } $arrLabel = json_decode(file_get_contents($dir . '.json')); $arrFiles = array_diff( scandir($dir), array( '..', '.', ) ); $arrMessage = []; foreach ($arrFiles as $file) { $fileName = basename($file, ".php"); $fileData = $myArray = include $dir . "/" . $file; if (is_array($fileData)) { $arrMessage[$fileName] = $fileData; } } return view('lang.index', compact('languages', 'currantLang', 'arrLabel', 'arrMessage', 'disabledLang', 'settings')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } else { return redirect()->back()->with('error', __('Permission denied.')); } } public function storeLanguageData(Request $request, $currantLang) { if (\Auth::user()->can('Create Language')) { $Filesystem = new Filesystem(); $dir = base_path() . '/resources/lang/'; if (!is_dir($dir)) { mkdir($dir); chmod($dir, 0777); } $jsonFile = $dir . "/" . $currantLang . ".json"; if (isset($request->label) && !empty($request->label)) { file_put_contents($jsonFile, json_encode($request->label)); } $langFolder = $dir . "/" . $currantLang; if (!is_dir($langFolder)) { mkdir($langFolder); chmod($langFolder, 0777); } if (isset($request->message) && !empty($request->message)) { foreach ($request->message as $fileName => $fileData) { $content = "buildArray($fileData); $content .= "];"; file_put_contents($langFolder . "/" . $fileName . '.php', $content); } } return redirect()->route('manage.language', [$currantLang])->with('success', __('Language save successfully.')); } else { return redirect()->back(); } } public function buildArray($fileData) { $content = ""; foreach ($fileData as $lable => $data) { if (is_array($data)) { $content .= "'$lable'=>[" . $this->buildArray($data) . "],"; } else { $content .= "'$lable'=>'" . addslashes($data) . "',"; } } return $content; } public function createLanguage() { return view('lang.create'); } public function storeLanguage(Request $request) { if (\Auth::user()->can('Create Language')) { $Filesystem = new Filesystem(); $langCode = strtolower($request->code); $langDir = base_path() . '/resources/lang/'; $dir = $langDir; if (!is_dir($dir)) { mkdir($dir); chmod($dir, 0777); } $dir = $dir . '/' . $langCode; $jsonFile = $dir . ".json"; \File::copy($langDir . 'en.json', $jsonFile); if (!is_dir($dir)) { mkdir($dir); chmod($dir, 0777); } $languageExist = Languages::where('code', $request->code)->orWhere('fullName', $request->fullName)->first(); if (empty($languageExist)) { $language = new Languages(); $language->code = $request->code; $language->fullName = $request->fullName; $language->save(); Utility::emailTemplateLang($request->code); Utility::notificationTemplateLang($request->code); } $Filesystem->copyDirectory($langDir . "en", $dir . "/"); return redirect()->route('manage.language', [$langCode])->with('success', __('Language successfully created.')); } else { return redirect()->back(); } } public function destroyLang($lang) { $default_lang = env('default_language') ?? 'en'; $langDir = base_path() . '/resources/lang/'; if (is_dir($langDir)) { // remove directory and file Utility::delete_directory($langDir . $lang); unlink($langDir . $lang . '.json'); // update user that has assign deleted language. User::where('lang', 'LIKE', $lang)->update(['lang' => $default_lang]); } $langName = Languages::where('code', $lang)->delete(); EmailTemplateLang::where('lang', $lang)->delete(); NotificationTemplateLangs::where('lang', $lang)->delete(); return redirect()->route('manage.language', $default_lang)->with('success', __('Language Deleted Successfully.')); } public function disableLang(Request $request) { if (\Auth::user()->type == 'super admin') { $settings = Utility::settings(); $disablelang = ''; if ($request->mode == 'off') { if (!empty($settings['disable_lang'])) { $disablelang = $settings['disable_lang']; $disablelang = $disablelang . ',' . $request->lang; } else { $disablelang = $request->lang; } \DB::insert( 'insert into settings (`value`, `name`,`created_by`) values (?, ?, ?) ON DUPLICATE KEY UPDATE `value` = VALUES(`value`) ', [ $disablelang, 'disable_lang', \Auth::user()->creatorId(), ] ); $data['message'] = __('Language Disabled Successfully'); $data['status'] = 200; return $data; } else { $disablelang = $settings['disable_lang']; $parts = explode(',', $disablelang); while (($i = array_search($request->lang, $parts)) !== false) { unset($parts[$i]); } \DB::insert( 'insert into settings (`value`, `name`,`created_by`) values (?, ?, ?) ON DUPLICATE KEY UPDATE `value` = VALUES(`value`) ', [ implode(',', $parts), 'disable_lang', \Auth::user()->creatorId(), ] ); $data['message'] = __('Language Enabled Successfully'); $data['status'] = 200; return $data; } } } } Controllers/PaiementProController.php000064400000021244150364311770014064 0ustar00plan_id); $plan = Plan::find($planID); $orderID = strtoupper(str_replace('.', '', uniqid('', true))); $user = Auth::user(); if ($plan) { $get_amount = $plan->price; if (!empty($request->coupon)) { $coupons = Coupon::where('code', strtoupper($request->coupon))->where('is_active', '1')->first(); if (!empty($coupons)) { $usedCoupun = $coupons->used_coupon(); $discount_value = ($plan->price / 100) * $coupons->discount; $get_amount = $plan->price - $discount_value; if ($coupons->limit == $usedCoupun) { return redirect()->back()->with('error', __('This coupon code has expired.')); } if ($get_amount <= 0) { $authuser = Auth::user(); $authuser->plan = $plan->id; $authuser->save(); $assignPlan = $authuser->assignPlan($plan->id); if ($assignPlan['is_success'] == true && !empty($plan)) { $orderID = strtoupper(str_replace('.', '', uniqid('', true))); $userCoupon = new UserCoupon(); $userCoupon->user = $authuser->id; $userCoupon->coupon = $coupons->id; $userCoupon->order = $orderID; $userCoupon->save(); Order::create( [ 'order_id' => $orderID, 'name' => null, 'email' => null, 'card_number' => null, 'card_exp_month' => null, 'card_exp_year' => null, 'plan_name' => $plan->name, 'plan_id' => $plan->id, 'price' => $get_amount == null ? 0 : $get_amount, 'price_currency' => $currency, 'txn_id' => '', 'payment_type' => __('Paiement Pro'), 'payment_status' => 'success', 'receipt' => null, 'user_id' => $authuser->id, ] ); $assignPlan = $authuser->assignPlan($plan->id); return redirect()->route('plans.index')->with('success', __('Plan Successfully Activated')); } } } else { return redirect()->back()->with('error', __('This coupon code is invalid or has expired.')); } } $coupons = Coupon::where('code', strtoupper($request->coupon))->where('is_active', '1')->first(); if (!empty($request->coupon)) { $call_back = route('paiementpro.status', [ 'get_amount' => $get_amount, 'plan' => $plan, 'coupon_id' => $coupons->id ]); } else { $call_back = route('paiementpro.status', [ 'get_amount' => $get_amount, 'plan' => $plan, ]); } $merchant_id = isset($payment_setting['paiementpro_merchant_id']) ? $payment_setting['paiementpro_merchant_id'] : ''; $data = array( 'merchantId' => $merchant_id, 'amount' => $get_amount, 'description' => "Api PHP", 'channel' => $request->channel, 'countryCurrencyCode' => $currency, 'referenceNumber' => "REF-" . time(), 'customerEmail' => $user->email, 'customerFirstName' => $user->name, 'customerLastname' => $user->name, 'customerPhoneNumber' => $request->mobile_number, 'notificationURL' => $call_back, 'returnURL' => $call_back, 'returnContext' => json_encode([ 'coupon_code' => $request->coupon_code, ]), ); $data = json_encode($data); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, "https://www.paiementpro.net/webservice/onlinepayment/init/curl-init.php"); curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json; charset=utf-8')); curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); curl_setopt($ch, CURLOPT_HEADER, FALSE); curl_setopt($ch, CURLOPT_POST, TRUE); curl_setopt($ch, CURLOPT_POSTFIELDS, $data); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); $response = curl_exec($ch); curl_close($ch); $response = json_decode($response); if (isset($response->success) && $response->success == true) { // redirect to approve href return redirect($response->url); return redirect() ->route('plans.index', \Illuminate\Support\Facades\Crypt::encrypt($plan->id)) ->with('error', 'Something went wrong. OR Unknown error occurred'); } else { return redirect() ->route('plans.index', \Illuminate\Support\Facades\Crypt::encrypt($plan->id)) ->with('error', $response->message ?? 'Something went wrong.'); } } else { return redirect()->route('plans.index')->with('error', __('Plan is deleted.')); } } public function planGetpaiementproStatus(Request $request) { $payment_setting = Utility::getAdminPaymentSetting(); $currency = isset($payment_setting['currency']) ? $payment_setting['currency'] : ''; $orderID = strtoupper(str_replace('.', '', uniqid('', true))); $getAmount = $request->get_amount; $authuser = Auth::user(); $plan = Plan::find($request->plan); Utility::referralTransaction($plan); if ($request->responsecode == 0) { $order = new Order(); $order->order_id = $orderID; $order->name = $authuser->name; $order->card_number = ''; $order->card_exp_month = ''; $order->card_exp_year = ''; $order->plan_name = $plan->name; $order->plan_id = $plan->id; $order->price = $getAmount; $order->price_currency = $currency; $order->txn_id = $orderID; $order->payment_type = __('Paiement Pro'); $order->payment_status = 'success'; $order->receipt = ''; $order->user_id = $authuser->id; $order->save(); $assignPlan = $authuser->assignPlan($plan->id); } else { return redirect()->back()->with('error', __('Transaction Unsuccesfull')); } $coupons = Coupon::find($request->coupon_id); if (!empty($request->coupon_id)) { if (!empty($coupons)) { $userCoupon = new UserCoupon(); $userCoupon->user = $authuser->id; $userCoupon->coupon = $coupons->id; $userCoupon->order = $orderID; $userCoupon->save(); $usedCoupun = $coupons->used_coupon(); if ($coupons->limit <= $usedCoupun) { $coupons->is_active = 0; $coupons->save(); } } } if ($assignPlan['is_success']) { return redirect()->route('plans.index')->with('success', __('Plan activated Successfully.')); } else { return redirect()->route('plans.index')->with('error', __($assignPlan['error'])); } } } Controllers/JobController.php000064400000042753150364311770012363 0ustar00can('Manage Job Category')) { $jobs = Job::where('created_by', '=', \Auth::user()->creatorId())->get(); $data['total'] = Job::where('created_by', '=', \Auth::user()->creatorId())->count(); $data['active'] = Job::where('status', 'active')->where('created_by', '=', \Auth::user()->creatorId())->count(); $data['in_active'] = Job::where('status', 'in_active')->where('created_by', '=', \Auth::user()->creatorId())->count(); $Offerletter = GenerateOfferLetter::all(); $currOfferletterTempLang = GenerateOfferLetter::where('created_by', \Auth::user()->id)->where('lang', $lang)->first(); $langs = $lang; return view('job.index', compact('jobs', 'data', 'currOfferletterTempLang', 'langs')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } public function create() { $categories = JobCategory::where('created_by', \Auth::user()->creatorId())->get()->pluck('title', 'id'); $categories->prepend('--', ''); $branches = Branch::where('created_by', \Auth::user()->creatorId())->get()->pluck('name', 'id'); $branches->prepend('All', ''); $status = Job::$status; $customQuestion = CustomQuestion::where('created_by', \Auth::user()->creatorId())->get(); return view('job.create', compact('categories', 'status', 'branches', 'customQuestion')); } public function store(Request $request) { if (\Auth::user()->can('Create Job')) { $rules = [ 'title' => 'required', 'branch' => 'required', 'category' => 'required', 'skill' => 'required', 'position' => 'required', 'start_date' => 'required', 'end_date' => 'required', 'description' => 'required', 'requirement' => 'required', 'custom_question.*' => 'required', ]; if (in_array('terms', $request->visibility)) { $rules['terms_and_conditions'] = 'required'; } $validator = \Validator::make( $request->all(), $rules ); if ($validator->fails()) { $messages = $validator->getMessageBag(); return redirect()->back()->with('error', $messages->first()); } $job = new Job(); $job->title = $request->title; $job->branch = $request->branch; $job->category = $request->category; $job->skill = $request->skill; $job->position = $request->position; $job->status = $request->status; $job->start_date = $request->start_date; $job->end_date = $request->end_date; $job->description = $request->description; $job->requirement = $request->requirement; $job->terms_and_conditions = !empty($request->terms_and_conditions) ? $request->terms_and_conditions : ''; $job->code = uniqid(); $job->applicant = !empty($request->applicant) ? implode(',', $request->applicant) : ''; $job->visibility = !empty($request->visibility) ? implode(',', $request->visibility) : ''; $job->custom_question = !empty($request->custom_question) ? implode(',', $request->custom_question) : ''; $job->created_by = \Auth::user()->creatorId(); $job->save(); return redirect()->route('job.index')->with('success', __('Job successfully created.')); } else { return redirect()->route('job.index')->with('error', __('Permission denied.')); } } public function show(Job $job) { $status = Job::$status; $job->applicant = !empty($job->applicant) ? explode(',', $job->applicant) : ''; $job->visibility = !empty($job->visibility) ? explode(',', $job->visibility) : ''; $job->skill = !empty($job->skill) ? explode(',', $job->skill) : ''; return view('job.show', compact('status', 'job')); } public function edit(Job $job) { $categories = JobCategory::where('created_by', \Auth::user()->creatorId())->get()->pluck('title', 'id'); $categories->prepend('--', ''); $branches = Branch::where('created_by', \Auth::user()->creatorId())->get()->pluck('name', 'id'); $branches->prepend('All', 0); $status = Job::$status; $job->applicant = explode(',', $job->applicant); $job->visibility = explode(',', $job->visibility); $job->custom_question = explode(',', $job->custom_question); $customQuestion = CustomQuestion::where('created_by', \Auth::user()->creatorId())->get(); return view('job.edit', compact('categories', 'status', 'branches', 'job', 'customQuestion')); } public function update(Request $request, Job $job) { if (\Auth::user()->can('Edit Job')) { $rules = [ 'title' => 'required', 'branch' => 'required', 'category' => 'required', 'skill' => 'required', 'position' => 'required', 'start_date' => 'required', 'end_date' => 'required', 'description' => 'required', 'requirement' => 'required', ]; if (in_array('terms', $request->visibility)) { $rules['terms_and_conditions'] = 'required'; } $validator = \Validator::make( $request->all(), $rules ); if ($validator->fails()) { $messages = $validator->getMessageBag(); return redirect()->back()->with('error', $messages->first()); } $job->title = $request->title; $job->branch = $request->branch; $job->category = $request->category; $job->skill = $request->skill; $job->position = $request->position; $job->status = $request->status; $job->start_date = $request->start_date; $job->end_date = $request->end_date; $job->description = $request->description; $job->requirement = $request->requirement; $job->terms_and_conditions = !empty($request->terms_and_conditions) ? $request->terms_and_conditions : ''; $job->applicant = !empty($request->applicant) ? implode(',', $request->applicant) : ''; $job->visibility = !empty($request->visibility) ? implode(',', $request->visibility) : ''; $job->custom_question = !empty($request->custom_question) ? implode(',', $request->custom_question) : ''; $job->save(); return redirect()->route('job.index')->with('success', __('Job successfully updated.')); } else { return redirect()->route('job.index')->with('error', __('Permission denied.')); } } public function destroy(Job $job) { $application = JobApplication::where('job', $job->id)->get()->pluck('id'); JobApplicationNote::whereIn('application_id', $application)->delete(); JobApplication::where('job', $job->id)->delete(); $job->delete(); return redirect()->route('job.index')->with('success', __('Job successfully deleted.')); } public function career($id, $lang) { $jobs = Job::where('created_by', $id)->with('createdBy')->get(); \Session::put('lang', $lang); \App::setLocale($lang); $companySettings['title_text'] = \DB::table('settings')->where('created_by', $id)->where('name', 'title_text')->first(); $companySettings['footer_text'] = \DB::table('settings')->where('created_by', $id)->where('name', 'footer_text')->first(); $companySettings['company_favicon'] = \DB::table('settings')->where('created_by', $id)->where('name', 'company_favicon')->first(); $companySettings['company_logo'] = \DB::table('settings')->where('created_by', $id)->where('name', 'company_logo')->first(); $companySettings['metakeyword'] = \DB::table('settings')->where('created_by', $id)->where('name', 'metakeyword')->first(); $companySettings['metadesc'] = \DB::table('settings')->where('created_by', $id)->where('name', 'metadesc')->first(); $languages = Utility::languages(); $currantLang = \Session::get('lang'); if (empty($currantLang)) { $user = User::find($id); $currantLang = !empty($user) && !empty($user->lang) ? $user->lang : 'en'; } return view('job.career', compact('companySettings', 'jobs', 'languages', 'currantLang', 'id')); } public function jobRequirement($code, $lang) { try { $job = Job::where('code', $code)->first(); if ($job->status == 'in_active') { return redirect()->back()->with('error', __('Permission Denied.')); } } catch (\Throwable $th) { return redirect()->back()->with('error', __('Page Not Found.')); } \Session::put('lang', $lang); \App::setLocale($lang); $companySettings['title_text'] = \DB::table('settings')->where('created_by', $job->created_by)->where('name', 'title_text')->first(); $companySettings['footer_text'] = \DB::table('settings')->where('created_by', $job->created_by)->where('name', 'footer_text')->first(); $companySettings['company_favicon'] = \DB::table('settings')->where('created_by', $job->created_by)->where('name', 'company_favicon')->first(); $companySettings['company_logo'] = \DB::table('settings')->where('created_by', $job->created_by)->where('name', 'company_logo')->first(); $companySettings['metakeyword'] = \DB::table('settings')->where('created_by', $job->created_by)->where('name', 'metakeyword')->first(); $companySettings['metadesc'] = \DB::table('settings')->where('created_by', $job->created_by)->where('name', 'metadesc')->first(); $languages = \Utility::languages(); $currantLang = \Session::get('lang'); if (empty($currantLang)) { $currantLang = !empty($job->createdBy) ? $job->createdBy->lang : 'en'; } return view('job.requirement', compact('companySettings', 'job', 'languages', 'currantLang')); } public function jobApply($code, $lang) { \Session::put('lang', $lang); \App::setLocale($lang); try { $job = Job::where('code', $code)->first(); $companySettings['title_text'] = \DB::table('settings')->where('created_by', $job->created_by)->where('name', 'title_text')->first(); $companySettings['footer_text'] = \DB::table('settings')->where('created_by', $job->created_by)->where('name', 'footer_text')->first(); $companySettings['company_favicon'] = \DB::table('settings')->where('created_by', $job->created_by)->where('name', 'company_favicon')->first(); $companySettings['company_logo'] = \DB::table('settings')->where('created_by', $job->created_by)->where('name', 'company_logo')->first(); } catch (\Throwable $th) { return redirect()->back()->with('error', 'Page not Found'); } $que = !empty($job->custom_question) ? explode(",", $job->custom_question) : []; $questions = CustomQuestion::wherein('id', $que)->get(); $languages = \Utility::languages(); $currantLang = \Session::get('lang'); if (empty($currantLang)) { $currantLang = !empty($job->createdBy) ? $job->createdBy->lang : 'en'; } return view('job.apply', compact('companySettings', 'job', 'questions', 'languages', 'currantLang')); } public function TermsAndCondition($id) { try { $job = Job::where('id', $id)->first(); } catch (\Throwable $th) { return redirect()->back()->with('error', 'Page not Found'); } return view('job.terms', compact('job')); } public function jobApplyData(Request $request, $code) { $rules = [ 'name' => 'required', 'email' => 'required', 'phone' => 'required', ]; if (isset($request->terms_condition_check) && empty($request->terms_condition_check)) { $rules['terms_condition_check'] = [ 'required', ]; } $validator = \Validator::make( $request->all(), $rules ); if ($validator->fails()) { $messages = $validator->getMessageBag(); return redirect()->back()->with('error', $messages->first()); } $job = Job::where('code', $code)->first(); // $stage = JobStage::where('created_by',\Auth::user()->creatorId())->first(); $stage = JobStage::where('created_by', $job->created_by)->first(); $jobApplication = new JobApplication(); $jobApplication->job = $job->id; $jobApplication->name = $request->name; $jobApplication->email = $request->email; $jobApplication->phone = $request->phone; $jobApplication->cover_letter = $request->cover_letter; $jobApplication->dob = $request->dob; $jobApplication->gender = $request->gender; $jobApplication->address = $request->address; $jobApplication->country = $request->country; $jobApplication->state = $request->state; $jobApplication->stage = $stage->id; $jobApplication->city = $request->city; $jobApplication->zip_code = $request->zip_code; $jobApplication->custom_question = json_encode($request->question); $jobApplication->terms_condition_check = !empty($request->terms_condition_check) ? $request->terms_condition_check : ''; $jobApplication->created_by = $job->created_by; if (!empty($request->profile)) { $image_size = $request->file('profile')->getSize(); $result = Utility::updateStorageLimit(\Auth::user()->creatorId(), $image_size); if ($result == 1) { $filenameWithExt = $request->file('profile')->getClientOriginalName(); $filename = pathinfo($filenameWithExt, PATHINFO_FILENAME); $extension = $request->file('profile')->getClientOriginalExtension(); $fileNameToStore = $filename . '_' . time() . '.' . $extension; $dir = 'uploads/job/profile'; $image_path = $dir . $filenameWithExt; $url = ''; $path = \Utility::upload_file($request, 'profile', $fileNameToStore, $dir, []); $jobApplication->profile = !empty($request->profile) ? $fileNameToStore : ''; if ($path['flag'] == 1) { $url = $path['url']; } else { return redirect()->back()->with('error', __($path['msg'])); } } } if (!empty($request->resume)) { $image_size = $request->file('resume')->getSize(); $result = Utility::updateStorageLimit(\Auth::user()->creatorId(), $image_size); if ($result == 1) { $filenameWithExt1 = $request->file('resume')->getClientOriginalName(); $filename1 = pathinfo($filenameWithExt1, PATHINFO_FILENAME); $extension1 = $request->file('resume')->getClientOriginalExtension(); $fileNameToStore1 = $filename1 . '_' . time() . '.' . $extension1; $dir = 'uploads/job/resume'; $image_path = $dir . $filenameWithExt1; $url = ''; $path = \Utility::upload_file($request, 'resume', $fileNameToStore1, $dir, []); $jobApplication->resume = !empty($request->resume) ? $fileNameToStore1 : ''; if ($path['flag'] == 1) { $url = $path['url']; } else { return redirect()->back()->with('error', __($path['msg'])); } } } $jobApplication->save(); // return redirect()->back()->with('success', __('Job application successfully send.')); return redirect()->back()->with('success', __('Job application successfully send.') . ((isset($result) && $result != 1) ? '
' . $result . '' : '')); // return redirect()->route('job-application.index')->with('success', __('Job application successfully send.')); } } Controllers/IncomeTypeController.php000064400000010145150364311770013713 0ustar00can('Manage Income Type')) { $incometypes = IncomeType::where('created_by', '=', \Auth::user()->creatorId())->get(); return view('incometype.index', compact('incometypes')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } public function create() { if(\Auth::user()->can('Create Income Type')) { return view('incometype.create'); } else { return response()->json(['error' => __('Permission denied.')], 401); } } public function store(Request $request) { if(\Auth::user()->can('Create Income Type')) { $validator = \Validator::make( $request->all(), [ 'name' => 'required', ] ); if($validator->fails()) { $messages = $validator->getMessageBag(); return redirect()->back()->with('error', $messages->first()); } $incometype = new IncomeType(); $incometype->name = $request->name; $incometype->created_by = \Auth::user()->creatorId(); $incometype->save(); return redirect()->route('incometype.index')->with('success', __('IncomeType successfully created.')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } public function show(IncomeType $incometype) { return redirect()->route('incometype.index'); } public function edit(IncomeType $incometype) { if(\Auth::user()->can('Edit Income Type')) { if($incometype->created_by == \Auth::user()->creatorId()) { return view('incometype.edit', compact('incometype')); } else { return response()->json(['error' => __('Permission denied.')], 401); } } else { return response()->json(['error' => __('Permission denied.')], 401); } } public function update(Request $request, IncomeType $incometype) { if(\Auth::user()->can('Edit Income Type')) { if($incometype->created_by == \Auth::user()->creatorId()) { $validator = \Validator::make( $request->all(), [ 'name' => 'required', ] ); if($validator->fails()) { $messages = $validator->getMessageBag(); return redirect()->back()->with('error', $messages->first()); } $incometype->name = $request->name; $incometype->save(); return redirect()->route('incometype.index')->with('success', __('IncomeType successfully updated.')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } else { return redirect()->back()->with('error', __('Permission denied.')); } } public function destroy(IncomeType $incometype) { if(\Auth::user()->can('Delete Income Type')) { if($incometype->created_by == \Auth::user()->creatorId()) { $incometype->delete(); return redirect()->route('incometype.index')->with('success', __('IncomeType successfully deleted.')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } else { return redirect()->back()->with('error', __('Permission denied.')); } } } Controllers/PayerController.php000064400000010353150364311770012720 0ustar00can('Manage Payer')) { $payers = Payer::where('created_by', '=', \Auth::user()->creatorId())->get(); return view('payer.index', compact('payers')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } public function create() { if(\Auth::user()->can('Create Payer')) { return view('payer.create'); } else { return response()->json(['error' => __('Permission denied.')], 401); } } public function store(Request $request) { if(\Auth::user()->can('Create Payer')) { $validator = \Validator::make( $request->all(), [ 'payer_name' => 'required', 'contact_number' => 'required', ] ); if($validator->fails()) { $messages = $validator->getMessageBag(); return redirect()->back()->with('error', $messages->first()); } $payer = new Payer(); $payer->payer_name = $request->payer_name; $payer->contact_number = $request->contact_number; $payer->created_by = \Auth::user()->creatorId(); $payer->save(); return redirect()->route('payer.index')->with('success', __('Payer successfully created.')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } public function show(Payer $payer) { return redirect()->route('payer.index'); } public function edit(Payer $payer) { if(\Auth::user()->can('Edit Payer')) { if($payer->created_by == \Auth::user()->creatorId()) { return view('payer.edit', compact('payer')); } else { return response()->json(['error' => __('Permission denied.')], 401); } } else { return response()->json(['error' => __('Permission denied.')], 401); } } public function update(Request $request, $payer) { $payer = Payer::find($payer); if(\Auth::user()->can('Edit Payer')) { if($payer->created_by == \Auth::user()->creatorId()) { $validator = \Validator::make( $request->all(), [ 'payer_name' => 'required', 'contact_number' => 'required', ] ); if($validator->fails()) { $messages = $validator->getMessageBag(); return redirect()->back()->with('error', $messages->first()); } $payer->payer_name = $request->payer_name; $payer->contact_number = $request->contact_number; $payer->save(); return redirect()->route('payer.index')->with('success', __('Payer successfully updated.')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } else { return redirect()->back()->with('error', __('Permission denied.')); } } public function destroy(Payer $payer) { if(\Auth::user()->can('Delete Payer')) { if($payer->created_by == \Auth::user()->creatorId()) { $payer->delete(); return redirect()->route('payer.index')->with('success', __('Payer successfully deleted.')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } else { return redirect()->back()->with('error', __('Permission denied.')); } } } Controllers/PaySlipController.php000064400000052454150364311770013231 0ustar00can('Manage Pay Slip') || \Auth::user()->type == 'employee') { $employees = Employee::where( [ 'created_by' => \Auth::user()->creatorId(), ] )->first(); $month = [ '01' => 'JAN', '02' => 'FEB', '03' => 'MAR', '04' => 'APR', '05' => 'MAY', '06' => 'JUN', '07' => 'JUL', '08' => 'AUG', '09' => 'SEP', '10' => 'OCT', '11' => 'NOV', '12' => 'DEC', ]; $currentyear = date("Y"); $tempyear = intval($currentyear) - 2; $year = []; for ($i = 0; $i < 10; $i++) { $year[$tempyear + $i] = $tempyear + $i; } // $year = [ // '2021' => '2021', // '2022' => '2022', // '2023' => '2023', // '2024' => '2024', // '2025' => '2025', // '2026' => '2026', // '2027' => '2027', // '2028' => '2028', // '2029' => '2029', // '2030' => '2030', // '2031' => '2031', // '2032' => '2032', // ]; return view('payslip.index', compact('employees', 'month', 'year')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } public function create() { // } public function store(Request $request) { $validator = \Validator::make( $request->all(), [ 'month' => 'required', 'year' => 'required', ] ); if ($validator->fails()) { $messages = $validator->getMessageBag(); return redirect()->back()->with('error', $messages->first()); } $month = $request->month; $year = $request->year; $formate_month_year = $year . '-' . $month; $validatePaysilp = PaySlip::where('salary_month', '=', $formate_month_year)->where('created_by', \Auth::user()->creatorId())->pluck('employee_id'); $payslip_employee = Employee::where('created_by', \Auth::user()->creatorId())->where('company_doj', '<=', date($year . '-' . $month . '-t'))->count(); if ($payslip_employee > count($validatePaysilp)) { $employees = Employee::where('created_by', \Auth::user()->creatorId())->where('company_doj', '<=', date($year . '-' . $month . '-t'))->whereNotIn('employee_id', $validatePaysilp)->get(); $employeesSalary = Employee::where('created_by', \Auth::user()->creatorId())->where('salary', '<=', 0)->first(); if (!empty($employeesSalary)) { return redirect()->route('payslip.index')->with('error', __('Please set employee salary.')); } foreach ($employees as $employee) { $chek = PaySlip::where(['employee_id' => $employee->id, 'salary_month' => $formate_month_year])->first(); $terminationDate = Termination::where('employee_id', $employee->id) ->whereDate('termination_date', '<=', Carbon::create($year, $month)->endOfMonth()) ->exists(); $resignationDate = Resignation::where('employee_id', $employee->id) ->whereDate('resignation_date', '<=', Carbon::create($year, $month)->endOfMonth()) ->exists(); if ($terminationDate || $resignationDate) { continue; } if (!$chek && $chek == null) { $payslipEmployee = new PaySlip(); $payslipEmployee->employee_id = $employee->id; $payslipEmployee->net_payble = $employee->get_net_salary(); $payslipEmployee->salary_month = $formate_month_year; $payslipEmployee->status = 0; $payslipEmployee->basic_salary = !empty($employee->salary) ? $employee->salary : 0; $payslipEmployee->allowance = Employee::allowance($employee->id); $payslipEmployee->commission = Employee::commission($employee->id); $payslipEmployee->loan = Employee::loan($employee->id); $payslipEmployee->saturation_deduction = Employee::saturation_deduction($employee->id); $payslipEmployee->other_payment = Employee::other_payment($employee->id); $payslipEmployee->overtime = Employee::overtime($employee->id); $payslipEmployee->created_by = \Auth::user()->creatorId(); $payslipEmployee->save(); //Slack Notification $setting = Utility::settings(\Auth::user()->creatorId()); if (isset($setting['monthly_payslip_notification']) && $setting['monthly_payslip_notification'] == 1) { // $msg = __("Payslip generated of") . ' ' . $formate_month_year . '.'; $uArr = [ 'year' => $formate_month_year, ]; Utility::send_slack_msg('new_monthly_payslip', $uArr); } //Telegram Notification $setting = Utility::settings(\Auth::user()->creatorId()); if (isset($setting['telegram_monthly_payslip_notification']) && $setting['telegram_monthly_payslip_notification'] == 1) { // $msg = __("Payslip generated of") . ' ' . $formate_month_year . '.'; $uArr = [ 'year' => $formate_month_year, ]; Utility::send_telegram_msg('new_monthly_payslip', $uArr); } //twilio $setting = Utility::settings(\Auth::user()->creatorId()); $emp = Employee::where('id', $payslipEmployee->employee_id)->first(); if (isset($setting['twilio_monthly_payslip_notification']) && $setting['twilio_monthly_payslip_notification'] == 1) { // $msg = __("Payslip generated of") . ' ' . $formate_month_year . '.'; $uArr = [ 'year' => $formate_month_year, ]; Utility::send_twilio_msg($emp->phone, 'new_monthly_payslip', $uArr); } //webhook $module = 'New Monthly Payslip'; $webhook = Utility::webhookSetting($module); if ($webhook) { $parameter = json_encode($payslipEmployee); // 1 parameter is URL , 2 parameter is data , 3 parameter is method $status = Utility::WebhookCall($webhook['url'], $parameter, $webhook['method']); if ($status == true) { return redirect()->back()->with('success', __('Payslip successfully created.')); } else { return redirect()->back()->with('error', __('Webhook call failed.')); } } } } return redirect()->route('payslip.index')->with('success', __('Payslip successfully created.')); } else { return redirect()->route('payslip.index')->with('error', __('Payslip Already created.')); } } public function destroy($id) { $payslip = PaySlip::find($id); $payslip->delete(); return true; } public function showemployee($paySlip) { $payslip = PaySlip::find($paySlip); return view('payslip.show', compact('payslip')); } public function search_json(Request $request) { $formate_month_year = $request->datePicker; $validatePaysilp = PaySlip::where('salary_month', '=', $formate_month_year)->where('created_by', \Auth::user()->creatorId())->get()->toarray(); $data = []; if (empty($validatePaysilp)) { $data = []; return; } else { $paylip_employee = PaySlip::select( [ 'employees.id', 'employees.employee_id', 'employees.name', 'employees.salary', 'payslip_types.name as payroll_type', 'pay_slips.basic_salary', 'pay_slips.net_payble', 'pay_slips.id as pay_slip_id', 'pay_slips.status', 'employees.user_id', ] )->leftjoin( 'employees', function ($join) use ($formate_month_year) { $join->on('employees.id', '=', 'pay_slips.employee_id'); $join->on('pay_slips.salary_month', '=', \DB::raw("'" . $formate_month_year . "'")); $join->leftjoin('payslip_types', 'payslip_types.id', '=', 'employees.salary_type'); } )->where('employees.created_by', \Auth::user()->creatorId())->get(); foreach ($paylip_employee as $employee) { if (Auth::user()->type == 'employee') { if (Auth::user()->id == $employee->user_id) { $tmp = []; $tmp[] = $employee->id; $tmp[] = $employee->name; $tmp[] = $employee->payroll_type; $tmp[] = $employee->pay_slip_id; $tmp[] = !empty($employee->basic_salary) ? \Auth::user()->priceFormat($employee->salary) : '-'; $tmp[] = !empty($employee->net_payble) ? \Auth::user()->priceFormat($employee->net_payble) : '-'; if ($employee->status == 1) { $tmp[] = 'paid'; } else { $tmp[] = 'unpaid'; } $tmp[] = !empty($employee->pay_slip_id) ? $employee->pay_slip_id : 0; $tmp['url'] = route('employee.show', Crypt::encrypt($employee->id)); $data[] = $tmp; } } else { $tmp = []; $tmp[] = $employee->id; $tmp[] = \Auth::user()->employeeIdFormat($employee->employee_id); $tmp[] = $employee->name; $tmp[] = $employee->payroll_type; $tmp[] = !empty($employee->basic_salary) ? \Auth::user()->priceFormat($employee->basic_salary) : '-'; $tmp[] = !empty($employee->net_payble) ? \Auth::user()->priceFormat($employee->net_payble) : '-'; if ($employee->status == 1) { $tmp[] = 'Paid'; } else { $tmp[] = 'UnPaid'; } $tmp[] = !empty($employee->pay_slip_id) ? $employee->pay_slip_id : 0; $tmp['url'] = route('employee.show', Crypt::encrypt($employee->id)); $data[] = $tmp; } } return $data; } } public function paysalary($id, $date) { $employeePayslip = PaySlip::where('employee_id', '=', $id)->where('created_by', \Auth::user()->creatorId())->where('salary_month', '=', $date)->first(); $get_employee = Employee::where('id', $id)->where('created_by', \Auth::user()->creatorId())->first(); $get_account = AccountList::where('id', $get_employee->account_type)->where('created_by', \Auth::user()->creatorId())->first(); $initial_balance = !empty($get_account->initial_balance) ? $get_account->initial_balance : 0; $net_salary = !empty($employeePayslip->net_payble) ? $employeePayslip->net_payble : 0; if (!empty($employeePayslip)) { $employeePayslip->status = 1; $employeePayslip->save(); $total_balance = $initial_balance - $net_salary; $get_account->initial_balance = $total_balance; $get_account->save(); $set_expense = new Expense(); $set_expense->account_id = $get_account->id; $set_expense->amount = $employeePayslip->net_payble; $set_expense->date = date('Y-m-d'); $set_expense->expense_category_id = ''; $set_expense->payee_id = $get_employee->id; $set_expense->payment_type_id = ''; $set_expense->referal_id = ''; $set_expense->description = ''; $set_expense->created_by = $get_employee->created_by; $set_expense->save(); return redirect()->route('payslip.index')->with('success', __('Payslip Payment successfully.')); } else { return redirect()->route('payslip.index')->with('error', __('Payslip Payment failed.')); } } public function bulk_pay_create($date) { $Employees = PaySlip::where('salary_month', $date)->where('created_by', \Auth::user()->creatorId())->get(); $unpaidEmployees = PaySlip::where('salary_month', $date)->where('created_by', \Auth::user()->creatorId())->where('status', '=', 0)->get(); return view('payslip.bulkcreate', compact('Employees', 'unpaidEmployees', 'date')); } public function bulkpayment(Request $request, $date) { $unpaidEmployees = PaySlip::where('salary_month', $date)->where('created_by', \Auth::user()->creatorId())->where('status', '=', 0)->get(); foreach ($unpaidEmployees as $employee) { $employee->status = 1; $employee->save(); } return redirect()->route('payslip.index')->with('success', __('Payslip Bulk Payment successfully.')); } public function employeepayslip() { $employees = Employee::where( [ 'user_id' => \Auth::user()->id, ] )->first(); $payslip = PaySlip::where('employee_id', '=', $employees->id)->get(); return view('payslip.employeepayslip', compact('payslip')); } public function pdf($id, $month) { $payslip = PaySlip::where('employee_id', $id)->where('salary_month', $month)->where('created_by', \Auth::user()->creatorId())->first(); $employee = Employee::find($payslip->employee_id); $payslipDetail = Utility::employeePayslipDetail($id, $month); return view('payslip.pdf', compact('payslip', 'employee', 'payslipDetail')); } public function send($id, $month) { $payslip = PaySlip::where('employee_id', $id)->where('salary_month', $month)->where('created_by', \Auth::user()->creatorId())->first(); $employee = Employee::find($payslip->employee_id); $payslip->name = $employee->name; $payslip->email = $employee->email; $payslipId = Crypt::encrypt($payslip->id); $payslip->url = route('payslip.payslipPdf', $payslipId); $setings = Utility::settings(); if ($setings['new_payroll'] == 1) { $uArr = [ 'payslip_email' => $payslip->email, 'name' => $payslip->name, 'url' => $payslip->url, 'salary_month' => $payslip->salary_month, ]; $resp = Utility::sendEmailTemplate('new_payroll', [$payslip->email], $uArr); return redirect()->back()->with('success', __('Payslip successfully sent.') . ((!empty($resp) && $resp['is_success'] == false && !empty($resp['error'])) ? '
' . $resp['error'] . '' : '')); } return redirect()->back()->with('success', __('Payslip successfully sent.')); } public function payslipPdf($id) { $payslipId = Crypt::decrypt($id); // $payslip = PaySlip::where('id', $payslipId)->where('created_by', \Auth::user()->creatorId())->first(); $payslip = PaySlip::where('id', $payslipId)->where('employee_id', $payslipId)->first(); $month = $payslip->salary_month; $employee = Employee::find($payslip->employee_id); $payslipDetail = Utility::employeePayslipDetail($payslip->employee_id, $month); return view('payslip.payslipPdf', compact('payslip', 'employee', 'payslipDetail')); } public function editEmployee($paySlip) { $payslip = PaySlip::find($paySlip); return view('payslip.salaryEdit', compact('payslip')); } public function updateEmployee(Request $request, $id) { if (isset($request->allowance) && !empty($request->allowance)) { $allowances = $request->allowance; $allowanceIds = $request->allowance_id; foreach ($allowances as $k => $allownace) { $allowanceData = Allowance::find($allowanceIds[$k]); $allowanceData->amount = $allownace; $allowanceData->save(); } } if (isset($request->commission) && !empty($request->commission)) { $commissions = $request->commission; $commissionIds = $request->commission_id; foreach ($commissions as $k => $commission) { $commissionData = Commission::find($commissionIds[$k]); $commissionData->amount = $commission; $commissionData->save(); } } if (isset($request->loan) && !empty($request->loan)) { $loans = $request->loan; $loanIds = $request->loan_id; foreach ($loans as $k => $loan) { $loanData = Loan::find($loanIds[$k]); $loanData->amount = $loan; $loanData->save(); } } if (isset($request->saturation_deductions) && !empty($request->saturation_deductions)) { $saturation_deductionss = $request->saturation_deductions; $saturation_deductionsIds = $request->saturation_deductions_id; foreach ($saturation_deductionss as $k => $saturation_deductions) { $saturation_deductionsData = SaturationDeduction::find($saturation_deductionsIds[$k]); $saturation_deductionsData->amount = $saturation_deductions; $saturation_deductionsData->save(); } } if (isset($request->other_payment) && !empty($request->other_payment)) { $other_payments = $request->other_payment; $other_paymentIds = $request->other_payment_id; foreach ($other_payments as $k => $other_payment) { $other_paymentData = OtherPayment::find($other_paymentIds[$k]); $other_paymentData->amount = $other_payment; $other_paymentData->save(); } } if (isset($request->rate) && !empty($request->rate)) { $rates = $request->rate; $rateIds = $request->rate_id; $hourses = $request->hours; foreach ($rates as $k => $rate) { $overtime = Overtime::find($rateIds[$k]); $overtime->rate = $rate; $overtime->hours = $hourses[$k]; $overtime->save(); } } $payslipEmployee = PaySlip::find($request->payslip_id); $payslipEmployee->allowance = Employee::allowance($payslipEmployee->employee_id); $payslipEmployee->commission = Employee::commission($payslipEmployee->employee_id); $payslipEmployee->loan = Employee::loan($payslipEmployee->employee_id); $payslipEmployee->saturation_deduction = Employee::saturation_deduction($payslipEmployee->employee_id); $payslipEmployee->other_payment = Employee::other_payment($payslipEmployee->employee_id); $payslipEmployee->overtime = Employee::overtime($payslipEmployee->employee_id); $payslipEmployee->net_payble = Employee::find($payslipEmployee->employee_id)->get_net_salary(); $payslipEmployee->save(); return redirect()->route('payslip.index')->with('success', __('Employee payroll successfully updated.')); } public function PayslipExport(Request $request) { $name = 'payslip_' . date('Y-m-d i:h:s'); $data = \Excel::download(new PayslipExport($request), $name . '.xlsx'); ob_end_clean(); return $data; } } Controllers/ReportController.php000064400000106131150364311770013113 0ustar00can('Manage Report')) { $deposit = Deposit::where('created_by', \Auth::user()->creatorId()); $labels = $data = []; $expenseCount = $incomeCount = 0; $incomeData = []; $expenseData = []; if (!empty($request->start_month) && !empty($request->end_month)) { $start = strtotime($request->start_month); $end = strtotime($request->end_month); $currentdate = $start; $month = []; while ($currentdate <= $end) { $month = date('m', $currentdate); $year = date('Y', $currentdate); $depositFilter = Deposit::where('created_by', \Auth::user()->creatorId())->whereMonth('date', $month)->whereYear('date', $year)->get(); $depositsTotal = 0; foreach ($depositFilter as $deposit) { $depositsTotal += $deposit->amount; } $incomeData[] = $depositsTotal; $incomeCount += $depositsTotal; $expenseFilter = Expense::where('created_by', \Auth::user()->creatorId())->whereMonth('date', $month)->whereYear('date', $year)->get(); $expenseTotal = 0; foreach ($expenseFilter as $expense) { $expenseTotal += $expense->amount; } $expenseData[] = $expenseTotal; $expenseCount += $expenseTotal; $labels[] = date('M Y', $currentdate); $currentdate = strtotime('+1 month', $currentdate); } $filter['startDateRange'] = date('M-Y', strtotime($request->start_month)); $filter['endDateRange'] = date('M-Y', strtotime($request->end_month)); } else { for ($i = 0; $i < 6; $i++) { $month = date('m', strtotime("-$i month")); $year = date('Y', strtotime("-$i month")); $depositFilter = Deposit::where('created_by', \Auth::user()->creatorId())->whereMonth('date', $month)->whereYear('date', $year)->get(); $depositTotal = 0; foreach ($depositFilter as $deposit) { $depositTotal += $deposit->amount; } $incomeData[] = $depositTotal; $incomeCount += $depositTotal; $expenseFilter = Expense::where('created_by', \Auth::user()->creatorId())->whereMonth('date', $month)->whereYear('date', $year)->get(); $expenseTotal = 0; foreach ($expenseFilter as $expense) { $expenseTotal += $expense->amount; } $expenseData[] = $expenseTotal; $expenseCount += $expenseTotal; $labels[] = date('M Y', strtotime("-$i month")); } $filter['startDateRange'] = date('M-Y'); $filter['endDateRange'] = date('M-Y', strtotime("-5 month")); } $incomeArr['name'] = __('Income'); $incomeArr['data'] = $incomeData; $expenseArr['name'] = __('Expense'); $expenseArr['data'] = $expenseData; $data[] = $incomeArr; $data[] = $expenseArr; return view('report.income_expense', compact('labels', 'data', 'incomeCount', 'expenseCount', 'filter')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } public function leave(Request $request) { if (\Auth::user()->can('Manage Report')) { $branch = Branch::where('created_by', \Auth::user()->creatorId())->get()->pluck('name', 'id'); $branch->prepend('All', ''); $department = Department::where('created_by', \Auth::user()->creatorId())->get()->pluck('name', 'id'); $department->prepend('All', ''); $filterYear['branch'] = __('All'); $filterYear['department'] = __('All'); $filterYear['type'] = __('Monthly'); $filterYear['dateYearRange'] = date('M-Y'); $employees = Employee::where('created_by', \Auth::user()->creatorId()); if (!empty($request->branch)) { $employees->where('branch_id', $request->branch); $filterYear['branch'] = !empty(Branch::find($request->branch)) ? Branch::find($request->branch)->name : ''; } if (!empty($request->department)) { $employees->where('department_id', $request->department); $filterYear['department'] = !empty(Department::find($request->department)) ? Department::find($request->department)->name : ''; } $employees = $employees->get(); $leaves = []; $totalApproved = $totalReject = $totalPending = 0; foreach ($employees as $employee) { $employeeLeave['id'] = $employee->id; $employeeLeave['employee_id'] = $employee->employee_id; $employeeLeave['employee'] = $employee->name; $approved = Leave::where('employee_id', $employee->id)->where('status', 'Approved'); $reject = Leave::where('employee_id', $employee->id)->where('status', 'Reject'); $pending = Leave::where('employee_id', $employee->id)->where('status', 'Pending'); if ($request->type == 'monthly' && !empty($request->month)) { $month = date('m', strtotime($request->month)); $year = date('Y', strtotime($request->month)); $approved->whereMonth('applied_on', $month)->whereYear('applied_on', $year); $reject->whereMonth('applied_on', $month)->whereYear('applied_on', $year); $pending->whereMonth('applied_on', $month)->whereYear('applied_on', $year); $filterYear['dateYearRange'] = date('M-Y', strtotime($request->month)); $filterYear['type'] = __('Monthly'); } elseif (!isset($request->type)) { $month = date('m'); $year = date('Y'); $monthYear = date('Y-m'); $approved->whereMonth('applied_on', $month)->whereYear('applied_on', $year); $reject->whereMonth('applied_on', $month)->whereYear('applied_on', $year); $pending->whereMonth('applied_on', $month)->whereYear('applied_on', $year); $filterYear['dateYearRange'] = date('M-Y', strtotime($monthYear)); $filterYear['type'] = __('Monthly'); } if ($request->type == 'yearly' && !empty($request->year)) { $approved->whereYear('applied_on', $request->year); $reject->whereYear('applied_on', $request->year); $pending->whereYear('applied_on', $request->year); $filterYear['dateYearRange'] = $request->year; $filterYear['type'] = __('Yearly'); } $approved = $approved->count(); $reject = $reject->count(); $pending = $pending->count(); $totalApproved += $approved; $totalReject += $reject; $totalPending += $pending; $employeeLeave['approved'] = $approved; $employeeLeave['reject'] = $reject; $employeeLeave['pending'] = $pending; $leaves[] = $employeeLeave; } $starting_year = date('Y', strtotime('-5 year')); $ending_year = date('Y', strtotime('+5 year')); $filterYear['starting_year'] = $starting_year; $filterYear['ending_year'] = $ending_year; $filter['totalApproved'] = $totalApproved; $filter['totalReject'] = $totalReject; $filter['totalPending'] = $totalPending; return view('report.leave', compact('department', 'branch', 'leaves', 'filterYear', 'filter')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } public function employeeLeave(Request $request, $employee_id, $status, $type, $month, $year) { if (\Auth::user()->can('Manage Report')) { $leaveTypes = LeaveType::where('created_by', \Auth::user()->creatorId())->get(); $leaves = []; foreach ($leaveTypes as $leaveType) { $leave = new Leave(); $leave->title = $leaveType->title; $totalLeave = Leave::where('employee_id', $employee_id)->where('status', $status)->where('leave_type_id', $leaveType->id); if ($type == 'yearly') { $totalLeave->whereYear('applied_on', $year); } else { $m = date('m', strtotime($month)); $y = date('Y', strtotime($month)); $totalLeave->whereMonth('applied_on', $m)->whereYear('applied_on', $y); } $totalLeave = $totalLeave->count(); $leave->total = $totalLeave; $leaves[] = $leave; } $leaveData = Leave::where('employee_id', $employee_id)->where('status', $status); if ($type == 'yearly') { $leaveData->whereYear('applied_on', $year); } else { $m = date('m', strtotime($month)); $y = date('Y', strtotime($month)); $leaveData->whereMonth('applied_on', $m)->whereYear('applied_on', $y); } $leaveData = $leaveData->get(); return view('report.leaveShow', compact('leaves', 'leaveData')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } public function accountStatement(Request $request) { if (\Auth::user()->can('Manage Report')) { $accountList = AccountList::where('created_by', \Auth::user()->creatorId())->get()->pluck('account_name', 'id'); $accountList->prepend('All', ''); $filterYear['account'] = __('All'); $filterYear['type'] = __('Income'); if ($request->type == 'expense') { $accountData = Expense::orderBy('id'); $accounts = Expense::select('account_lists.id', 'account_lists.account_name')->leftjoin('account_lists', 'expenses.account_id', '=', 'account_lists.id')->groupBy('expenses.account_id')->selectRaw('sum(amount) as total'); if (!empty($request->start_month) && !empty($request->end_month)) { $start = strtotime($request->start_month); $end = strtotime($request->end_month); } else { $start = strtotime(date('Y-m')); $end = strtotime(date('Y-m', strtotime("-5 month"))); } $currentdate = $start; while ($currentdate <= $end) { $data['month'] = date('m', $currentdate); $data['year'] = date('Y', $currentdate); $accountData->Orwhere( function ($query) use ($data) { $query->whereMonth('date', $data['month'])->whereYear('date', $data['year']); } ); $accounts->Orwhere( function ($query) use ($data) { $query->whereMonth('date', $data['month'])->whereYear('date', $data['year']); } ); $currentdate = strtotime('+1 month', $currentdate); } $filterYear['startDateRange'] = date('M-Y', $start); $filterYear['endDateRange'] = date('M-Y', $end); if (!empty($request->account)) { $accountData->where('account_id', $request->account); $accounts->where('account_lists.id', $request->account); $filterYear['account'] = !empty(AccountList::find($request->account)) ? Department::find($request->account)->account_name : ''; } $accounts->where('expenses.created_by', \Auth::user()->creatorId()); $filterYear['type'] = __('Expense'); } else { $accountData = Deposit::orderBy('id'); $accounts = Deposit::select('account_lists.id', 'account_lists.account_name')->leftjoin('account_lists', 'deposits.account_id', '=', 'account_lists.id')->groupBy('deposits.account_id')->selectRaw('sum(amount) as total'); if (!empty($request->start_month) && !empty($request->end_month)) { $start = strtotime($request->start_month); $end = strtotime($request->end_month); } else { $start = strtotime(date('Y-m')); $end = strtotime(date('Y-m', strtotime("-5 month"))); } $currentdate = $start; while ($currentdate <= $end) { $data['month'] = date('m', $currentdate); $data['year'] = date('Y', $currentdate); $accountData->Orwhere( function ($query) use ($data) { $query->whereMonth('date', $data['month'])->whereYear('date', $data['year']); } ); $currentdate = strtotime('+1 month', $currentdate); $accounts->Orwhere( function ($query) use ($data) { $query->whereMonth('date', $data['month'])->whereYear('date', $data['year']); } ); $currentdate = strtotime('+1 month', $currentdate); } $filterYear['startDateRange'] = date('M-Y', $start); $filterYear['endDateRange'] = date('M-Y', $end); if (!empty($request->account)) { $accountData->where('account_id', $request->account); $accounts->where('account_lists.id', $request->account); $filterYear['account'] = !empty(AccountList::find($request->account)) ? Department::find($request->account)->account_name : ''; } $accounts->where('deposits.created_by', \Auth::user()->creatorId()); } $accountData->where('created_by', \Auth::user()->creatorId()); $accountData = $accountData->get(); $accounts = $accounts->get(); return view('report.account_statement', compact('accountData', 'accountList', 'accounts', 'filterYear')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } public function payroll(Request $request) { if (\Auth::user()->can('Manage Report')) { $branch = Branch::where('created_by', \Auth::user()->creatorId())->get()->pluck('name', 'id'); $branch->prepend('All', ''); $department = Department::where('created_by', \Auth::user()->creatorId())->get()->pluck('name', 'id'); $department->prepend('All', ''); $filterYear['branch'] = __('All'); $filterYear['department'] = __('All'); $filterYear['type'] = __('Monthly'); $payslips = PaySlip::select('pay_slips.*', 'employees.name')->leftjoin('employees', 'pay_slips.employee_id', '=', 'employees.id')->where('pay_slips.created_by', \Auth::user()->creatorId()); if ($request->type == 'monthly' && !empty($request->month)) { $payslips->where('salary_month', $request->month); $filterYear['dateYearRange'] = date('M-Y', strtotime($request->month)); $filterYear['type'] = __('Monthly'); } elseif (!isset($request->type)) { $month = date('Y-m'); $payslips->where('salary_month', $month); $filterYear['dateYearRange'] = date('M-Y', strtotime($month)); $filterYear['type'] = __('Monthly'); } if ($request->type == 'yearly' && !empty($request->year)) { $startMonth = $request->year . '-01'; $endMonth = $request->year . '-12'; $payslips->where('salary_month', '>=', $startMonth)->where('salary_month', '<=', $endMonth); $filterYear['dateYearRange'] = $request->year; $filterYear['type'] = __('Yearly'); } if (!empty($request->branch)) { $payslips->where('employees.branch_id', $request->branch); $filterYear['branch'] = !empty(Branch::find($request->branch)) ? Branch::find($request->branch)->name : ''; } if (!empty($request->department)) { $payslips->where('employees.department_id', $request->department); $filterYear['department'] = !empty(Department::find($request->department)) ? Department::find($request->department)->name : ''; } $payslips = $payslips->get(); $totalBasicSalary = $totalNetSalary = $totalAllowance = $totalCommision = $totalLoan = $totalSaturationDeduction = $totalOtherPayment = $totalOverTime = 0; foreach ($payslips as $payslip) { $totalBasicSalary += $payslip->basic_salary; $totalNetSalary += $payslip->net_payble; $allowances = json_decode($payslip->allowance); foreach ($allowances as $allowance) { $totalAllowance += $allowance->amount; } $commisions = json_decode($payslip->commission); foreach ($commisions as $commision) { $totalCommision += $commision->amount; } $loans = json_decode($payslip->loan); foreach ($loans as $loan) { $totalLoan += $loan->amount; } $saturationDeductions = json_decode($payslip->saturation_deduction); foreach ($saturationDeductions as $saturationDeduction) { $totalSaturationDeduction += $saturationDeduction->amount; } $otherPayments = json_decode($payslip->other_payment); foreach ($otherPayments as $otherPayment) { $totalOtherPayment += $otherPayment->amount; } $overtimes = json_decode($payslip->overtime); foreach ($overtimes as $overtime) { $days = $overtime->number_of_days; $hours = $overtime->hours; $rate = $overtime->rate; $totalOverTime += ($rate * $hours) * $days; } } $filterData['totalBasicSalary'] = $totalBasicSalary; $filterData['totalNetSalary'] = $totalNetSalary; $filterData['totalAllowance'] = $totalAllowance; $filterData['totalCommision'] = $totalCommision; $filterData['totalLoan'] = $totalLoan; $filterData['totalSaturationDeduction'] = $totalSaturationDeduction; $filterData['totalOtherPayment'] = $totalOtherPayment; $filterData['totalOverTime'] = $totalOverTime; $starting_year = date('Y', strtotime('-5 year')); $ending_year = date('Y', strtotime('+5 year')); $filterYear['starting_year'] = $starting_year; $filterYear['ending_year'] = $ending_year; return view('report.payroll', compact('payslips', 'filterData', 'branch', 'department', 'filterYear')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } public function monthlyAttendance(Request $request) { if (\Auth::user()->can('Manage Report')) { $branch = Branch::where('created_by', \Auth::user()->creatorId())->get()->pluck('name', 'id'); $branch->prepend('All', ''); $department = Department::where('created_by', \Auth::user()->creatorId())->get()->pluck('name', 'id'); $department->prepend('All', ''); $data['branch'] = __('All'); $data['department'] = __('All'); $employees = Employee::select('id', 'name'); if (!empty($request->employee_id) && $request->employee_id[0] != 0) { $employees->whereIn('id', $request->employee_id); } $employees = $employees->where('created_by', \Auth::user()->creatorId()); if (!empty($request->branch)) { $employees->where('branch_id', $request->branch); $data['branch'] = !empty(Branch::find($request->branch)) ? Branch::find($request->branch)->name : ''; } if (!empty($request->department)) { $employees->where('department_id', $request->department); $data['department'] = !empty(Department::find($request->department)) ? Department::find($request->department)->name : ''; } if (!empty($request->employees)) { $employees->where('employee_id', $request->employees); $data['employees'] = !empty(Employee::find($request->employees)) ? Employee::find($request->employees)->name : ''; } $employees = $employees->get()->pluck('name', 'id'); if (!empty($request->month)) { $currentdate = strtotime($request->month); $month = date('m', $currentdate); $year = date('Y', $currentdate); $curMonth = date('M-Y', strtotime($request->month)); } else { $month = date('m'); $year = date('Y'); $curMonth = date('M-Y', strtotime($year . '-' . $month)); } // $num_of_days = cal_days_in_month(CAL_GREGORIAN, $month, $year); $num_of_days = date('t', mktime(0, 0, 0, $month, 1, $year)); for ($i = 1; $i <= $num_of_days; $i++) { $dates[] = str_pad($i, 2, '0', STR_PAD_LEFT); } $employeesAttendance = []; $totalPresent = $totalLeave = $totalEarlyLeave = 0; $ovetimeHours = $overtimeMins = $earlyleaveHours = $earlyleaveMins = $lateHours = $lateMins = 0; foreach ($employees as $id => $employee) { $attendances['name'] = $employee; foreach ($dates as $date) { $dateFormat = $year . '-' . $month . '-' . $date; if ($dateFormat <= date('Y-m-d')) { $employeeAttendance = AttendanceEmployee::where('employee_id', $id)->where('date', $dateFormat)->first(); if (!empty($employeeAttendance) && $employeeAttendance->status == 'Present') { $attendanceStatus[$date] = 'P'; $totalPresent += 1; if ($employeeAttendance->overtime > 0) { $ovetimeHours += date('h', strtotime($employeeAttendance->overtime)); $overtimeMins += date('i', strtotime($employeeAttendance->overtime)); } if ($employeeAttendance->early_leaving > 0) { $earlyleaveHours += date('h', strtotime($employeeAttendance->early_leaving)); $earlyleaveMins += date('i', strtotime($employeeAttendance->early_leaving)); } if ($employeeAttendance->late > 0) { $lateHours += date('h', strtotime($employeeAttendance->late)); $lateMins += date('i', strtotime($employeeAttendance->late)); } } elseif (!empty($employeeAttendance) && $employeeAttendance->status == 'Leave') { $attendanceStatus[$date] = 'A'; $totalLeave += 1; } else { $attendanceStatus[$date] = ''; } } else { $attendanceStatus[$date] = ''; } } $attendances['status'] = $attendanceStatus; $employeesAttendance[] = $attendances; } $totalOverTime = $ovetimeHours + ($overtimeMins / 60); $totalEarlyleave = $earlyleaveHours + ($earlyleaveMins / 60); $totalLate = $lateHours + ($lateMins / 60); $data['totalOvertime'] = $totalOverTime; $data['totalEarlyLeave'] = $totalEarlyleave; $data['totalLate'] = $totalLate; $data['totalPresent'] = $totalPresent; $data['totalLeave'] = $totalLeave; $data['curMonth'] = $curMonth; return view('report.monthlyAttendance', compact('employeesAttendance', 'branch', 'department', 'employees', 'dates', 'data')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } public function timesheet(Request $request) { if (\Auth::user()->can('Manage Report')) { $branch = Branch::where('created_by', \Auth::user()->creatorId())->get()->pluck('name', 'id'); $branch->prepend('All', ''); $department = Department::where('created_by', \Auth::user()->creatorId())->get()->pluck('name', 'id'); $department->prepend('All', ''); $filterYear['branch'] = __('All'); $filterYear['department'] = __('All'); $timesheets = TimeSheet::select('time_sheets.*', 'employees.name')->leftjoin('employees', 'time_sheets.employee_id', '=', 'employees.id')->where('time_sheets.created_by', \Auth::user()->creatorId()); $timesheetFilters = TimeSheet::select('time_sheets.*', 'employees.name')->groupBy('employee_id')->selectRaw('sum(hours) as total')->leftjoin('employees', 'time_sheets.employee_id', '=', 'employees.id')->where('time_sheets.created_by', \Auth::user()->creatorId()); if (!empty($request->start_date) && !empty($request->end_date)) { $timesheets->where('date', '>=', $request->start_date); $timesheets->where('date', '<=', $request->end_date); $timesheetFilters->where('date', '>=', $request->start_date); $timesheetFilters->where('date', '<=', $request->end_date); $filterYear['start_date'] = $request->start_date; $filterYear['end_date'] = $request->end_date; } else { $filterYear['start_date'] = date('Y-m-01'); $filterYear['end_date'] = date('Y-m-t'); $timesheets->where('date', '>=', $filterYear['start_date']); $timesheets->where('date', '<=', $filterYear['end_date']); $timesheetFilters->where('date', '>=', $filterYear['start_date']); $timesheetFilters->where('date', '<=', $filterYear['end_date']); } if (!empty($request->branch)) { $timesheets->where('branch_id', $request->branch); $timesheetFilters->where('branch_id', $request->branch); $filterYear['branch'] = !empty(Branch::find($request->branch)) ? Branch::find($request->branch)->name : ''; } if (!empty($request->department)) { $timesheets->where('department_id', $request->department); $timesheetFilters->where('department_id', $request->department); $filterYear['department'] = !empty(Department::find($request->department)) ? Department::find($request->department)->name : ''; } $timesheets = $timesheets->get(); $timesheetFilters = $timesheetFilters->get(); $totalHours = 0; foreach ($timesheetFilters as $timesheetFilter) { $totalHours += $timesheetFilter->hours; } $filterYear['totalHours'] = $totalHours; $filterYear['totalEmployee'] = count($timesheetFilters); return view('report.timesheet', compact('timesheets', 'branch', 'department', 'filterYear', 'timesheetFilters')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } public function LeaveReportExport() { $name = 'leave_' . date('Y-m-d i:h:s'); $data = \Excel::download(new LeaveReportExport(), $name . '.xlsx'); return $data; } public function AccountStatementReportExport(Request $request) { $name = 'Account Statement_' . date('Y-m-d i:h:s'); $data = \Excel::download(new accountstatementExport(), $name . '.xlsx'); return $data; } public function PayrollReportExport($month, $branch, $department) { $data = []; $data['branch'] = __('All'); $data['department'] = __('All'); if ($branch != 0) { $data['branch'] = !empty(Branch::find($branch)) ? Branch::find($branch)->id : ''; } if ($department != 0) { $data['department'] = !empty(Department::find($department)) ? Department::find($department)->id : ''; } $data['month'] = $month; $name = 'Payroll_' . date('Y-m-d i:h:s'); $data = \Excel::download(new PayrollExport($data), $name . '.xlsx'); return $data; } public function exportTimeshhetReport(Request $request) { $name = 'Timesheet_' . date('Y-m-d i:h:s'); $data = \Excel::download(new TimesheetReportExport(), $name . '.xlsx'); return $data; } public function exportCsv($filter_month, $branch, $department, $employee) { $data['branch'] = __('All'); $data['department'] = __('All'); $employees = Employee::select('id', 'name')->where('created_by', \Auth::user()->creatorId()); if ($branch != 0) { $employees->where('branch_id', $branch); $data['branch'] = !empty(Branch::find($branch)) ? Branch::find($branch)->name : ''; } if ($department != 0) { $employees->where('department_id', $department); $data['department'] = !empty(Department::find($department)) ? Department::find($department)->name : ''; } if ($employee != 0) { $employeeIds = explode(',', $employee); $emp = Employee::whereIn('id', $employeeIds); } else { $emp = Employee::where('department_id', $department); } $employees = $emp->get()->pluck('name', 'id'); $currentdate = strtotime($filter_month); $month = date('m', $currentdate); $year = date('Y', $currentdate); $data['curMonth'] = date('M-Y', strtotime($filter_month)); $fileName = $data['branch'] . ' ' . __('Branch') . ' ' . $data['curMonth'] . ' ' . __('Attendance Report of') . ' ' . $data['department'] . ' ' . __('Department') . ' ' . '.csv'; $employeesAttendance = []; $num_of_days = date('t', mktime(0, 0, 0, $month, 1, $year)); for ($i = 1; $i <= $num_of_days; $i++) { $dates[] = str_pad($i, 2, '0', STR_PAD_LEFT); } foreach ($employees as $id => $employee) { $attendances['name'] = $employee; foreach ($dates as $date) { $dateFormat = $year . '-' . $month . '-' . $date; if ($dateFormat <= date('Y-m-d')) { $employeeAttendance = AttendanceEmployee::where('employee_id', $id)->where('date', $dateFormat)->first(); if (!empty($employeeAttendance) && $employeeAttendance->status == 'Present') { $attendanceStatus[$date] = 'P'; } elseif (!empty($employeeAttendance) && $employeeAttendance->status == 'Leave') { $attendanceStatus[$date] = 'A'; } else { $attendanceStatus[$date] = '-'; } } else { $attendanceStatus[$date] = '-'; } $attendances[$date] = $attendanceStatus[$date]; } $employeesAttendance[] = $attendances; } $headers = array( "Content-type" => "text/csv", "Content-Disposition" => "attachment; filename=$fileName", "Pragma" => "no-cache", "Cache-Control" => "must-revalidate, post-check=0, pre-check=0", "Expires" => "0", ); $emp = array( 'employee', ); $columns = array_merge($emp, $dates); $callback = function () use ($employeesAttendance, $columns) { $file = fopen('php://output', 'w'); fputcsv($file, $columns); foreach ($employeesAttendance as $attendance) { fputcsv($file, str_replace('"', '', array_values($attendance))); } fclose($file); }; return response()->stream($callback, 200, $headers); } public function getdepartment(Request $request) { if ($request->branch_id == 0) { $departments = Department::where('created_by', '=', \Auth::user()->creatorId())->get()->pluck('name', 'id')->toArray(); } else { $departments = Department::where('created_by', '=', \Auth::user()->creatorId())->where('branch_id', $request->branch_id)->get()->pluck('name', 'id')->toArray(); } return response()->json($departments); } public function getemployee(Request $request) { if (!$request->department_id) { $employees = Employee::where('created_by', '=', \Auth::user()->creatorId())->get()->pluck('name', 'id')->toArray(); } else { $employees = Employee::where('created_by', '=', \Auth::user()->creatorId())->where('department_id', $request->department_id)->get()->pluck('name', 'id')->toArray(); } return response()->json($employees); } } Controllers/TimeSheetController.php000064400000020600150364311770013523 0ustar00can('Manage TimeSheet')) { $employeesList = []; if(\Auth::user()->type == 'employee') { $timeSheets = TimeSheet::where('employee_id', \Auth::user()->id)->get(); $employeesList = Employee::where('created_by', \Auth::user()->creatorId())->first(); $timesheets = TimeSheet::where('created_by', \Auth::user()->creatorId()); if(!empty($request->start_date) && !empty($request->end_date)) { $timesheets->where('date', '>=', $request->start_date); $timesheets->where('date', '<=', $request->end_date); } if(!empty($employeesList->user_id)) { $timesheets->where('employee_id', \Auth::user()->id); } $timeSheets = $timesheets->get(); } else { $employeesList = Employee::where('created_by', \Auth::user()->creatorId())->get()->pluck('name', 'user_id'); $employeesList->prepend('All', ''); $timesheets = TimeSheet::where('created_by', \Auth::user()->creatorId()); if(!empty($request->start_date) && !empty($request->end_date)) { $timesheets->where('date', '>=', $request->start_date); $timesheets->where('date', '<=', $request->end_date); } if(!empty($request->employee)) { $timesheets->where('employee_id', $request->employee); } $timeSheets = $timesheets->get(); } return view('timeSheet.index', compact('timeSheets', 'employeesList')); } else { return redirect()->back()->with('error', 'Permission denied.'); } } public function create() { if(\Auth::user()->can('Create TimeSheet')) { $employees = Employee::where('created_by', '=', \Auth::user()->creatorId())->get()->pluck('name', 'user_id'); $employees->prepend('Select Employee', ''); return view('timeSheet.create', compact('employees')); } else { return redirect()->back()->with('error', 'Permission denied.'); } } public function store(Request $request) { if(\Auth::user()->can('Create TimeSheet')) { $timeSheet = new Timesheet(); if(\Auth::user()->type == 'employee') { $timeSheet->employee_id = \Auth::user()->id; } else { $timeSheet->employee_id = $request->employee_id; } $timeSheetCheck = TimeSheet::where('date', $request->date)->where('employee_id', $timeSheet->employee_id)->first(); if(!empty($timeSheetCheck)) { return redirect()->back()->with('error', __('Timesheet already created in this day.')); } $timeSheet->date = $request->date; $timeSheet->hours = $request->hours; $timeSheet->remark = $request->remark; $timeSheet->created_by = \Auth::user()->creatorId(); $timeSheet->save(); return redirect()->route('timesheet.index')->with('success', __('Timesheet successfully created.')); } else { return redirect()->back()->with('error', 'Permission denied.'); } } public function show(TimeSheet $timeSheet) { // } public function edit(TimeSheet $timeSheet, $id) { if(\Auth::user()->can('Edit TimeSheet')) { $employees = Employee::where('created_by', '=', \Auth::user()->creatorId())->get()->pluck('name', 'user_id'); $timeSheet = Timesheet::find($id); return view('timeSheet.edit', compact('timeSheet', 'employees')); } else { return redirect()->back()->with('error', 'Permission denied.'); } } public function update(Request $request, $id) { if(\Auth::user()->can('Edit TimeSheet')) { $timeSheet = Timesheet::find($id); if(\Auth::user()->type == 'employee') { $timeSheet->employee_id = \Auth::user()->id; } else { $timeSheet->employee_id = $request->employee_id; } $timeSheetCheck = TimeSheet::where('date', $request->date)->where('employee_id', $timeSheet->employee_id)->first(); if(!empty($timeSheetCheck) && $timeSheetCheck->id != $id) { return redirect()->back()->with('error', __('Timesheet already created in this day.')); } $timeSheet->date = $request->date; $timeSheet->hours = $request->hours; $timeSheet->remark = $request->remark; $timeSheet->save(); return redirect()->route('timesheet.index')->with('success', __('TimeSheet successfully updated.')); } else { return redirect()->back()->with('error', 'Permission denied.'); } } public function destroy($id) { if(\Auth::user()->can('Delete TimeSheet')) { $timeSheet = Timesheet::find($id); $timeSheet->delete(); return redirect()->route('timesheet.index')->with('success', __('TimeSheet successfully deleted.')); } else { return redirect()->back()->with('error', 'Permission denied.'); } } public function export(Request $request) { $name = 'Timesheet_' . date('Y-m-d i:h:s'); $data = \Excel::download(new TimesheetExport(), $name . '.xlsx'); return $data; } public function exportTimeshhetReport(Request $request) { $name = 'Timesheet_' . date('Y-m-d i:h:s'); $data = \Excel::download(new TimesheetExport(), $name . '.xlsx'); return $data; } public function importFile(Request $request) { return view('timeSheet.import'); } public function import(Request $request) { $rules = [ 'file' => 'required|mimes:csv,txt,xlsx', ]; $validator = \Validator::make($request->all(), $rules); if ($validator->fails()) { $messages = $validator->getMessageBag(); return redirect()->back()->with('error', $messages->first()); } $timesheet = (new TimesheetImport())->toArray(request()->file('file'))[0]; $totalTimesheet = count($timesheet) - 1; $errorArray = []; for ($i = 1; $i <= $totalTimesheet; $i++) { $timesheets = $timesheet[$i]; $timesheetData=TimeSheet::where('employee_id',$timesheets[1])->where('date',$timesheets[0])->first(); if(!empty($timesheetData)) { $errorArray[]=$timesheetData; } else { $time_sheet=new TimeSheet(); $time_sheet->employee_id=$timesheets[0]; $time_sheet->date=$timesheets[1]; $time_sheet->hours=$timesheets[2]; $time_sheet->remark=$timesheets[3]; $time_sheet->created_by=Auth::user()->id; $time_sheet->save(); } } if (empty($errorArray)) { $data['status'] = 'success'; $data['msg'] = __('Record successfully imported'); } else { $data['status'] = 'error'; $data['msg'] = count($errorArray) . ' ' . __('Record imported fail out of' . ' ' . $totalTimesheet . ' ' . 'record'); foreach ($errorArray as $errorData) { $errorRecord[] = implode(',', $errorData->toArray()); } \Session::put('errorArray', $errorRecord); } return redirect()->back()->with($data['status'], $data['msg']); } } Controllers/PaymentTypeController.php000064400000010227150364311770014117 0ustar00can('Manage Payment Type')) { $paymenttypes = PaymentType::where('created_by', '=', \Auth::user()->creatorId())->get(); return view('paymenttype.index', compact('paymenttypes')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } public function create() { if(\Auth::user()->can('Create Payment Type')) { return view('paymenttype.create'); } else { return response()->json(['error' => __('Permission denied.')], 401); } } public function store(Request $request) { if(\Auth::user()->can('Create Payment Type')) { $validator = \Validator::make( $request->all(), [ 'name' => 'required', ] ); if($validator->fails()) { $messages = $validator->getMessageBag(); return redirect()->back()->with('error', $messages->first()); } $paymenttype = new PaymentType(); $paymenttype->name = $request->name; $paymenttype->created_by = \Auth::user()->creatorId(); $paymenttype->save(); return redirect()->route('paymenttype.index')->with('success', __('PaymentType successfully created.')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } public function show(PaymentType $paymenttype) { return redirect()->route('paymenttype.index'); } public function edit(PaymentType $paymenttype) { if(\Auth::user()->can('Edit Payment Type')) { if($paymenttype->created_by == \Auth::user()->creatorId()) { return view('paymenttype.edit', compact('paymenttype')); } else { return response()->json(['error' => __('Permission denied.')], 401); } } else { return response()->json(['error' => __('Permission denied.')], 401); } } public function update(Request $request, PaymentType $paymenttype) { if(\Auth::user()->can('Edit Payment Type')) { if($paymenttype->created_by == \Auth::user()->creatorId()) { $validator = \Validator::make( $request->all(), [ 'name' => 'required|max:20', ] ); if($validator->fails()) { $messages = $validator->getMessageBag(); return redirect()->back()->with('error', $messages->first()); } $paymenttype->name = $request->name; $paymenttype->save(); return redirect()->route('paymenttype.index')->with('success', __('PaymentType successfully updated.')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } else { return redirect()->back()->with('error', __('Permission denied.')); } } public function destroy(PaymentType $paymenttype) { if(\Auth::user()->can('Delete Payment Type')) { if($paymenttype->created_by == \Auth::user()->creatorId()) { $paymenttype->delete(); return redirect()->route('paymenttype.index')->with('success', __('PaymentType successfully deleted.')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } else { return redirect()->back()->with('error', __('Permission denied.')); } } } Controllers/StripePaymentController.php000064400000040735150364311770014453 0ustar00type == 'super admin') { $orders = Order::select( [ 'orders.*', 'users.name as user_name', ] )->join('users', 'orders.user_id', '=', 'users.id')->orderBy('orders.created_at', 'DESC')->get(); $userOrders = Order::select('*') ->whereIn('id', function ($query) { $query->selectRaw('MAX(id)') ->from('orders') ->groupBy('user_id'); }) ->orderBy('created_at', 'desc') ->get(); return view('order.index', compact('orders', 'userOrders')); } elseif (\Auth::user()->type == 'company') { $objUser = \Auth::user(); $orders = Order::select( [ 'orders.*', 'users.name as user_name', ] )->join('users', 'orders.user_id', '=', 'users.id')->where('user_id', $objUser->id)->orderBy('orders.created_at', 'DESC')->get(); return view('order.index', compact('orders')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } public function refund(Request $request, $id, $user_id) { Order::where('id', $request->id)->update(['is_refund' => 1]); $user = User::find($user_id); $assignPlan = $user->assignPlan(1); return redirect()->back()->with('success', __('We successfully planned a refund and assigned a free plan.')); } public function stripe($code) { $admin_payment_setting = Utility::getAdminPaymentSetting(); if ( isset($admin_payment_setting['is_stripe_enabled']) && $admin_payment_setting['is_manually_enabled'] == 'on' || $admin_payment_setting['is_banktransfer_enabled'] == 'on' || $admin_payment_setting['is_stripe_enabled'] == 'on' && !empty($admin_payment_setting['stripe_key']) && !empty($admin_payment_setting['stripe_secret']) || $admin_payment_setting['is_iyzipay_enabled'] == 'on' && !empty($admin_payment_setting['iyzipay_public_key']) && !empty($admin_payment_setting['iyzipay_secret_key']) || $admin_payment_setting['is_paypal_enabled'] == 'on' && !empty($admin_payment_setting['paypal_client_id']) && !empty($admin_payment_setting['paypal_secret_key']) || $admin_payment_setting['is_paystack_enabled'] == 'on' && !empty($admin_payment_setting['paystack_public_key']) && !empty($admin_payment_setting['paystack_secret_key']) || $admin_payment_setting['is_flutterwave_enabled'] == 'on' && !empty($admin_payment_setting['flutterwave_public_key']) && !empty($admin_payment_setting['flutterwave_secret_key']) || $admin_payment_setting['is_razorpay_enabled'] == 'on' && !empty($admin_payment_setting['razorpay_public_key']) && !empty($admin_payment_setting['razorpay_secret_key']) || $admin_payment_setting['is_paytm_enabled'] == 'on' && !empty($admin_payment_setting['paytm_merchant_id']) && !empty($admin_payment_setting['paytm_merchant_key']) || $admin_payment_setting['is_mercado_enabled'] == 'on' && !empty($admin_payment_setting['mercado_access_token']) || $admin_payment_setting['is_mollie_enabled'] == 'on' && !empty($admin_payment_setting['mollie_api_key']) && !empty($admin_payment_setting['mollie_profile_id']) && !empty($admin_payment_setting['mollie_partner_id']) || $admin_payment_setting['is_skrill_enabled'] == 'on' && !empty($admin_payment_setting['skrill_email']) || $admin_payment_setting['is_coingate_enabled'] == 'on' && !empty($admin_payment_setting['coingate_auth_token']) || $admin_payment_setting['is_paymentwall_enabled'] == 'on' && !empty($admin_payment_setting['paymentwall_public_key']) && !empty($admin_payment_setting['paymentwall_secret_key']) || $admin_payment_setting['is_toyyibpay_enabled'] == 'on' && !empty($admin_payment_setting['toyyibpay_category_code']) && !empty($admin_payment_setting['toyyibpay_secret_key']) || $admin_payment_setting['is_payfast_enabled'] == 'on' && !empty($admin_payment_setting['payfast_merchant_id']) && !empty($admin_payment_setting['payfast_merchant_key']) && !empty($admin_payment_setting['payfast_signature']) || $admin_payment_setting['is_sspay_enabled'] == 'on' && !empty($admin_payment_setting['sspay_category_code']) && !empty($admin_payment_setting['sspay_secret_key']) || $admin_payment_setting['is_paytab_enabled'] == 'on' && !empty($admin_payment_setting['paytab_profile_id']) && !empty($admin_payment_setting['paytab_server_key']) && !empty($admin_payment_setting['paytab_region']) || $admin_payment_setting['is_benefit_enabled'] == 'on' && !empty($admin_payment_setting['benefit_api_key']) && !empty($admin_payment_setting['benefit_secret_key']) || $admin_payment_setting['is_cashfree_enabled'] == 'on' && !empty($admin_payment_setting['cashfree_api_key']) && !empty($admin_payment_setting['cashfree_secret_key']) || $admin_payment_setting['is_aamarpay_enabled'] == 'on' && !empty($admin_payment_setting['aamarpay_store_id']) && !empty($admin_payment_setting['aamarpay_signature_key']) && !empty($admin_payment_setting['aamarpay_description']) || $admin_payment_setting['is_paytr_enabled'] == 'on' && !empty($admin_payment_setting['paytr_merchant_id']) && !empty($admin_payment_setting['paytr_merchant_key']) && !empty($admin_payment_setting['paytr_merchant_salt']) || $admin_payment_setting['is_yookassa_enabled'] == 'on' && !empty($admin_payment_setting['yookassa_shop_id']) && !empty($admin_payment_setting['yookassa_secret']) || $admin_payment_setting['is_midtrans_enabled'] == 'on' && !empty($admin_payment_setting['midtrans_secret']) || $admin_payment_setting['is_xendit_enabled'] == 'on' && !empty($admin_payment_setting['xendit_api']) && !empty($admin_payment_setting['xendit_token']) || $admin_payment_setting['is_nepalste_enabled'] == 'on' && !empty($admin_payment_setting['nepalste_public_key']) && !empty($admin_payment_setting['nepalste_secret_key']) || $admin_payment_setting['is_paiementpro_enabled'] == 'on' && !empty($admin_payment_setting['paiementpro_merchant_id']) || $admin_payment_setting['is_fedapay_enabled'] == 'on' && !empty($admin_payment_setting['fedapay_public_key']) && !empty($admin_payment_setting['fedapay_secret_key']) || $admin_payment_setting['is_payhere_enabled'] == 'on' && !empty($admin_payment_setting['payhere_merchant_id']) && !empty($admin_payment_setting['payhere_merchant_secret']) && !empty($admin_payment_setting['payhere_app_id']) && !empty($admin_payment_setting['payhere_app_secret']) || $admin_payment_setting['is_cinetpay_enabled'] == 'on' && !empty($admin_payment_setting['cinetpay_api_key']) && !empty($admin_payment_setting['cinetpay_site_id']) ) { if (\Auth::user()->can('Manage Company Settings')) { try { $plan_id = Crypt::decrypt($code); } catch (\Throwable $th) { return redirect()->back()->with('error', __('Plan Not Found.')); } $plan_id = \Illuminate\Support\Facades\Crypt::decrypt($code); $plan = Plan::find($plan_id); if ($plan) { return view('stripe', compact('plan', 'admin_payment_setting')); } else { return redirect()->back()->with('error', __('Plan is deleted.')); } } else { return redirect()->back()->with('error', __('Permission denied.')); } } else { return redirect()->back()->with('error', __('Permission denied.')); } } public function stripePost(Request $request) { try { $planID = Crypt::decrypt($request->plan_id); } catch (\Throwable $th) { return redirect()->back()->with('error', __('Plan Not Found.')); } $admin_payment_setting = Utility::getAdminPaymentSetting(); if (\Auth::user()->can('Manage Company Settings') && (isset($admin_payment_setting['is_stripe_enabled']) && $admin_payment_setting['is_stripe_enabled'] == 'on' && !empty($admin_payment_setting['stripe_key']) && !empty($admin_payment_setting['stripe_secret']))) { $objUser = \Auth::user(); $planID = \Illuminate\Support\Facades\Crypt::decrypt($request->plan_id); $plan = Plan::find($planID); if ($plan) { try { $price = $plan->price; if (!empty($request->coupon)) { $coupons = Coupon::where('code', strtoupper($request->coupon))->where('is_active', '1')->first(); if (!empty($coupons)) { $usedCoupun = $coupons->used_coupon(); $discount_value = ($plan->price / 100) * $coupons->discount; $price = $plan->price - $discount_value; if ($coupons->limit == $usedCoupun) { return redirect()->back()->with('error', __('This coupon code has expired.')); } } else { return redirect()->back()->with('error', __('This coupon code is invalid or has expired.')); } } $orderID = strtoupper(str_replace('.', '', uniqid('', true))); $user = \Auth::user(); if ($price <= 0.0) { if ($request->has('coupon') && $request->coupon != '') { $coupons = Coupon::where('code', strtoupper($request->coupon))->where('is_active', '1')->first(); if (!empty($coupons)) { $userCoupon = new UserCoupon(); $userCoupon->user = $user->id; $userCoupon->coupon = $coupons->id; $userCoupon->order = $orderID; $userCoupon->save(); $usedCoupun = $coupons->used_coupon(); if ($coupons->limit <= $usedCoupun) { $coupons->is_active = 0; $coupons->save(); } } } $order = new Order(); $order->order_id = $orderID; $order->name = $user->name; $order->card_number = ''; $order->card_exp_month = ''; $order->card_exp_year = ''; $order->plan_name = $plan->name; $order->plan_id = $plan->id; $order->price = $price; $order->price_currency = $admin_payment_setting['currency']; $order->payment_type = __('STRIPE'); $order->payment_status = 'success'; $order->txn_id = ''; $order->receipt = ''; $order->user_id = $user->id; $order->save(); $assignPlan = $user->assignPlan($plan->id); return redirect()->route('plans.index')->with('success', __('Plan activated Successfully.')); } if ($price > 0.0) { Stripe\Stripe::setApiKey($admin_payment_setting['stripe_secret']); $data = Stripe\Charge::create( [ "amount" => 100 * $price, "currency" => !empty($admin_payment_setting['currency']) ? $admin_payment_setting['currency'] : 'inr', "source" => $request->stripeToken, "description" => " Plan - " . $plan->name, "metadata" => ["order_id" => $orderID], ] ); } else { $data['amount_refunded'] = 0; $data['failure_code'] = ''; $data['paid'] = 1; $data['captured'] = 1; $data['status'] = 'succeeded'; } if ($data['amount_refunded'] == 0 && empty($data['failure_code']) && $data['paid'] == 1 && $data['captured'] == 1) { $orders = Order::create( [ 'order_id' => $orderID, 'name' => $request->name, 'card_number' => isset($data['payment_method_details']['card']['last4']) ? $data['payment_method_details']['card']['last4'] : '', 'card_exp_month' => isset($data['payment_method_details']['card']['exp_month']) ? $data['payment_method_details']['card']['exp_month'] : '', 'card_exp_year' => isset($data['payment_method_details']['card']['exp_year']) ? $data['payment_method_details']['card']['exp_year'] : '', 'plan_name' => $plan->name, 'plan_id' => $plan->id, 'price' => $price, 'price_currency' => isset($data['currency']) ? $data['currency'] : '', 'txn_id' => isset($data['balance_transaction']) ? $data['balance_transaction'] : '', 'payment_status' => isset($data['status']) ? $data['status'] : 'succeeded', 'payment_type' => __('STRIPE'), 'receipt' => isset($data['receipt_url']) ? $data['receipt_url'] : 'free coupon', 'user_id' => $objUser->id, ] ); if (!empty($request->coupon)) { $userCoupon = new UserCoupon(); $userCoupon->user = $objUser->id; $userCoupon->coupon = $coupons->id; $userCoupon->order = $orderID; $userCoupon->save(); $usedCoupun = $coupons->used_coupon(); if ($coupons->limit <= $usedCoupun) { $coupons->is_active = 0; $coupons->save(); } } Utility::referralTransaction($plan); if ($data['status'] == 'succeeded') { $assignPlan = $objUser->assignPlan($plan->id); if ($assignPlan['is_success']) { return redirect()->route('plans.index')->with('success', __('Plan successfully activated.')); } else { return redirect()->route('plans.index')->with('error', __($assignPlan['error'])); } } else { return redirect()->route('plans.index')->with('error', __('Your payment has failed.')); } } else { return redirect()->route('plans.index')->with('error', __('Transaction has been failed.')); } } catch (\Exception $e) { return redirect()->route('plans.index')->with('error', __($e->getMessage())); } } else { return redirect()->route('plans.index')->with('error', __('Plan is deleted.')); } } else { return redirect()->back()->with('error', __('Permission denied.')); } } } Controllers/LoanOptionController.php000064400000010777150364311770013734 0ustar00can('Manage Loan Option')) { $loanoptions = LoanOption::where('created_by', '=', \Auth::user()->creatorId())->get(); return view('loanoption.index', compact('loanoptions')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } public function create() { if(\Auth::user()->can('Create Loan Option')) { return view('loanoption.create'); } else { return response()->json(['error' => __('Permission denied.')], 401); } } public function store(Request $request) { if(\Auth::user()->can('Create Loan Option')) { $validator = \Validator::make( $request->all(), [ 'name' => 'required|max:20', ] ); if($validator->fails()) { $messages = $validator->getMessageBag(); return redirect()->back()->with('error', $messages->first()); } $loanoption = new LoanOption(); $loanoption->name = $request->name; $loanoption->created_by = \Auth::user()->creatorId(); $loanoption->save(); return redirect()->route('loanoption.index')->with('success', __('LoanOption successfully created.')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } public function show(LoanOption $loanoption) { return redirect()->route('loanoption.index'); } public function edit(LoanOption $loanoption) { if(\Auth::user()->can('Edit Loan Option')) { if($loanoption->created_by == \Auth::user()->creatorId()) { return view('loanoption.edit', compact('loanoption')); } else { return response()->json(['error' => __('Permission denied.')], 401); } } else { return response()->json(['error' => __('Permission denied.')], 401); } } public function update(Request $request, LoanOption $loanoption) { if(\Auth::user()->can('Edit Loan Option')) { if($loanoption->created_by == \Auth::user()->creatorId()) { $validator = \Validator::make( $request->all(), [ 'name' => 'required|max:20', ] ); if($validator->fails()) { $messages = $validator->getMessageBag(); return redirect()->back()->with('error', $messages->first()); } $loanoption->name = $request->name; $loanoption->save(); return redirect()->route('loanoption.index')->with('success', __('LoanOption successfully updated.')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } else { return redirect()->back()->with('error', __('Permission denied.')); } } public function destroy(LoanOption $loanoption) { if(\Auth::user()->can('Delete Loan Option')) { if($loanoption->created_by == \Auth::user()->creatorId()) { $loan = Loan::where('loan_option',$loanoption->id)->get(); if(count($loan) == 0) { $loanoption->delete(); } else { return redirect()->route('loanoption.index')->with('error', __('This Loan Option has Loan. Please remove the Loan from this Loan option.')); } return redirect()->route('loanoption.index')->with('success', __('LoanOption successfully deleted.')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } else { return redirect()->back()->with('error', __('Permission denied.')); } } } Controllers/CashfreeController.php000064400000026331150364311770013363 0ustar00 isset($payment_setting['cashfree_api_key']) ? $payment_setting['cashfree_api_key'] : '', 'services.cashfree.secret' => isset($payment_setting['cashfree_secret_key']) ? $payment_setting['cashfree_secret_key'] : '', ] ); } } public function cashfreePaymentStore(Request $request) { $planID = \Illuminate\Support\Facades\Crypt::decrypt($request->plan_id); $plan = Plan::find($planID); $user = \Auth::user(); $this->paymentConfig(); $payment_setting = Utility::getAdminPaymentSetting(); $url = config('services.cashfree.url'); if ($plan) { $get_amount = $plan->price; try { if (!empty($request->coupon)) { $coupons = Coupon::where('code', strtoupper($request->coupon))->where('is_active', '1')->first(); if (!empty($coupons)) { $usedCoupun = $coupons->used_coupon(); $discount_value = ($plan->price / 100) * $coupons->discount; $get_amount = $plan->price - $discount_value; if ($coupons->limit == $usedCoupun) { return redirect()->back()->with('error', __('This coupon code has expired.')); } if ($get_amount <= 0) { $authuser = \Auth::user(); $authuser->plan = $plan->id; $authuser->save(); $assignPlan = $authuser->assignPlan($plan->id); if ($assignPlan['is_success'] == true && !empty($plan)) { if (!empty($authuser->payment_subscription_id) && $authuser->payment_subscription_id != '') { try { $authuser->cancel_subscription($authuser->id); } catch (\Exception $exception) { \Log::debug($exception->getMessage()); } } $orderID = strtoupper(str_replace('.', '', uniqid('', true))); $userCoupon = new UserCoupon(); $userCoupon->user = $authuser->id; $userCoupon->coupon = $coupons->id; $userCoupon->order = $orderID; $userCoupon->save(); Order::create( [ 'order_id' => $orderID, 'name' => null, 'email' => null, 'card_number' => null, 'card_exp_month' => null, 'card_exp_year' => null, 'plan_name' => $plan->name, 'plan_id' => $plan->id, 'price' => $get_amount == null ? 0 : $get_amount, 'price_currency' => !empty($payment_setting['currency']) ? $payment_setting['currency'] : 'USD', 'txn_id' => '', 'payment_type' => 'Cashfree', 'payment_status' => 'success', 'receipt' => null, 'user_id' => $authuser->id, ] ); $assignPlan = $authuser->assignPlan($plan->id); return redirect()->route('plans.index')->with('success', __('Plan Successfully Activated')); } } } else { return redirect()->back()->with('error', __('This coupon code is invalid or has expired.')); } } $coupon = (empty($request->coupon)) ? "0" : $request->coupon; $orderID = strtoupper(str_replace('.', '', uniqid('', true))); $headers = array( "Content-Type: application/json", "x-api-version: 2022-01-01", "x-client-id: " . config('services.cashfree.key'), "x-client-secret: " . config('services.cashfree.secret') ); $data = json_encode([ 'order_id' => $orderID, 'order_amount' => $get_amount, "order_currency" => !empty($payment_setting['currency']) ? $payment_setting['currency'] : 'USD', "order_name" => $plan->name, "customer_details" => [ "customer_id" => 'customer_' . $user->id, "customer_name" => $user->name, "customer_email" => $user->email, "customer_phone" => '1234567890', ], "order_meta" => [ "return_url" => route('cashfreePayment.success') . '?order_id={order_id}&order_token={order_token}&plan_id=' . $plan->id . '&amount=' . $get_amount . '&coupon=' . $coupon . '' ] ]); try { $curl = curl_init($url); curl_setopt($curl, CURLOPT_URL, $url); curl_setopt($curl, CURLOPT_POST, true); curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); curl_setopt($curl, CURLOPT_HTTPHEADER, $headers); curl_setopt($curl, CURLOPT_POSTFIELDS, $data); $resp = curl_exec($curl); curl_close($curl); return redirect()->to(json_decode($resp)->payment_link); } catch (\Throwable $th) { return redirect()->back()->with('error', 'Currency Not Supported.Contact To Your Site Admin'); } } catch (\Exception $e) { return redirect()->back()->with('error', $e); } } else { return redirect()->route('plans.index')->with('error', __('Plan is deleted.')); } } public function cashfreePaymentSuccess(Request $request) { $this->paymentConfig(); $user = \Auth::user(); $plan = Plan::find($request->plan_id); $couponCode = $request->coupon; $getAmount = $request->amount; $orderID = strtoupper(str_replace('.', '', uniqid('', true))); if ($couponCode != 0) { $coupons = Coupon::where('code', strtoupper($couponCode))->where('is_active', '1')->first(); $request['coupon_id'] = $coupons->id; } else { $coupons = null; } try { $client = new \GuzzleHttp\Client(); $response = $client->request('GET', config('services.cashfree.url') . '/' . $request->get('order_id') . '/settlements', [ 'headers' => [ 'accept' => 'application/json', 'x-api-version' => '2022-09-01', "x-client-id" => config('services.cashfree.key'), "x-client-secret" => config('services.cashfree.secret') ], ]); $respons = json_decode($response->getBody()); if ($respons->order_id && $respons->cf_payment_id != NULL) { $response = $client->request('GET', config('services.cashfree.url') . '/' . $respons->order_id . '/payments/' . $respons->cf_payment_id . '', [ 'headers' => [ 'accept' => 'application/json', 'x-api-version' => '2022-09-01', 'x-client-id' => config('services.cashfree.key'), 'x-client-secret' => config('services.cashfree.secret'), ], ]); $info = json_decode($response->getBody()); if ($info->payment_status == "SUCCESS") { Utility::referralTransaction($plan); $order = new Order(); $order->order_id = $orderID; $order->name = $user->name; $order->card_number = ''; $order->card_exp_month = ''; $order->card_exp_year = ''; $order->plan_name = $plan->name; $order->plan_id = $plan->id; $order->price = $getAmount; $order->price_currency = !empty($payment_setting['currency']) ? $payment_setting['currency'] : 'USD'; $order->payment_type = __('Cashfree'); $order->payment_status = 'success'; $order->txn_id = ''; $order->receipt = ''; $order->user_id = $user->id; $order->save(); $assignPlan = $user->assignPlan($plan->id); $coupons = Coupon::find($request->coupon_id); if (!empty($request->coupon_id)) { if (!empty($coupons)) { $userCoupon = new UserCoupon(); $userCoupon->user = $user->id; $userCoupon->coupon = $coupons->id; $userCoupon->order = $orderID; $userCoupon->save(); $usedCoupun = $coupons->used_coupon(); if ($coupons->limit <= $usedCoupun) { $coupons->is_active = 0; $coupons->save(); } } } if ($assignPlan['is_success']) { return redirect()->route('plans.index')->with('success', __('Plan activated Successfully.')); } else { return redirect()->route('plans.index')->with('error', __($assignPlan['error'])); } } else { return redirect()->route('plans.index')->with('error', __('Your Transaction is fail please try again')); } } else { return redirect()->route('plans.index')->with('error', 'Payment Failed.'); } return redirect()->route('plans.index')->with('success', 'Plan activated Successfully.'); } catch (\Exception $e) { return redirect()->route('plans.index')->with('error', __($e->getMessage())); } } } Controllers/LeaveController.php000064400000046051150364311770012700 0ustar00can('Manage Leave')) { if (\Auth::user()->type == 'employee') { $user = \Auth::user(); $employee = Employee::where('user_id', '=', $user->id)->first(); $leaves = LocalLeave::where('employee_id', '=', $employee->id)->get(); } else { $leaves = LocalLeave::where('created_by', '=', \Auth::user()->creatorId())->with(['employees', 'leaveType'])->get(); } return view('leave.index', compact('leaves')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } public function create() { if (\Auth::user()->can('Create Leave')) { if (Auth::user()->type == 'employee') { $employees = Employee::where('user_id', '=', \Auth::user()->id)->first(); } else { $employees = Employee::where('created_by', '=', \Auth::user()->creatorId())->get()->pluck('name', 'id'); } $leavetypes = LeaveType::where('created_by', '=', \Auth::user()->creatorId())->get(); // $leavetypes_days = LeaveType::where('created_by', '=', \Auth::user()->creatorId())->get(); return view('leave.create', compact('employees', 'leavetypes')); } else { return response()->json(['error' => __('Permission denied.')], 401); } } public function store(Request $request) { if (\Auth::user()->can('Create Leave')) { $validator = \Validator::make( $request->all(), [ 'employee_id' => 'required', 'leave_type_id' => 'required', 'start_date' => 'required', 'end_date' => 'required', 'leave_reason' => 'required', 'remark' => 'required', ] ); if ($validator->fails()) { $messages = $validator->getMessageBag(); return redirect()->back()->with('error', $messages->first()); } // $employee = Employee::where('created_by', '=', \Auth::user()->id)->first(); $leave_type = LeaveType::find($request->leave_type_id); $startDate = new \DateTime($request->start_date); $endDate = new \DateTime($request->end_date); $endDate->add(new \DateInterval('P1D')); // $total_leave_days = !empty($startDate->diff($endDate)) ? $startDate->diff($endDate)->days : 0; $date = Utility::AnnualLeaveCycle(); if (\Auth::user()->type == 'employee') { // Leave day $leaves_used = LocalLeave::where('employee_id', '=', $request->employee_id)->where('leave_type_id', $leave_type->id)->where('status', 'Approved')->whereBetween('created_at', [$date['start_date'],$date['end_date']])->sum('total_leave_days'); $leaves_pending = LocalLeave::where('employee_id', '=', $request->employee_id)->where('leave_type_id', $leave_type->id)->where('status', 'Pending')->whereBetween('created_at', [$date['start_date'],$date['end_date']])->sum('total_leave_days'); } else { // Leave day $leaves_used = LocalLeave::where('employee_id', '=', $request->employee_id)->where('leave_type_id', $leave_type->id)->where('status', 'Approved')->whereBetween('created_at', [$date['start_date'],$date['end_date']])->sum('total_leave_days'); $leaves_pending = LocalLeave::where('employee_id', '=', $request->employee_id)->where('leave_type_id', $leave_type->id)->where('status', 'Pending')->whereBetween('created_at', [$date['start_date'],$date['end_date']])->sum('total_leave_days'); } $total_leave_days = !empty($startDate->diff($endDate)) ? $startDate->diff($endDate)->days : 0; $return = $leave_type->days - $leaves_used; if ($total_leave_days > $return) { return redirect()->back()->with('error', __('You are not eligible for leave.')); } if (!empty($leaves_pending) && $leaves_pending + $total_leave_days > $return) { return redirect()->back()->with('error', __('Multiple leave entry is pending.')); } if ($leave_type->days >= $total_leave_days) { $leave = new LocalLeave(); if (\Auth::user()->type == "employee") { $leave->employee_id = $request->employee_id; } else { $leave->employee_id = $request->employee_id; } $leave->leave_type_id = $request->leave_type_id; $leave->applied_on = date('Y-m-d'); $leave->start_date = $request->start_date; $leave->end_date = $request->end_date; $leave->total_leave_days = $total_leave_days; $leave->leave_reason = $request->leave_reason; $leave->remark = $request->remark; $leave->status = 'Pending'; $leave->created_by = \Auth::user()->creatorId(); $leave->save(); // Google celander if ($request->get('synchronize_type') == 'google_calender') { $type = 'leave'; $request1 = new GoogleEvent(); $request1->title = !empty(\Auth::user()->getLeaveType($leave->leave_type_id)) ? \Auth::user()->getLeaveType($leave->leave_type_id)->title : ''; $request1->start_date = $request->start_date; $request1->end_date = $request->end_date; Utility::addCalendarData($request1, $type); } return redirect()->route('leave.index')->with('success', __('Leave successfully created.')); } else { return redirect()->back()->with('error', __('Leave type ' . $leave_type->title . ' is provide maximum ' . $leave_type->days . " days please make sure your selected days is under " . $leave_type->days . ' days.')); } } else { return redirect()->back()->with('error', __('Permission denied.')); } } public function show(LocalLeave $leave) { return redirect()->route('leave.index'); } public function edit(LocalLeave $leave) { if (\Auth::user()->can('Edit Leave')) { if ($leave->created_by == \Auth::user()->creatorId()) { if (Auth::user()->type == 'employee') { $employees = Employee::where('employee_id', '=', \Auth::user()->creatorId())->first(); } else { $employees = Employee::where('created_by', '=', \Auth::user()->creatorId())->get()->pluck('name', 'id'); } // $employees = Employee::where('created_by', '=', \Auth::user()->creatorId())->get()->pluck('name', 'id'); // $leavetypes = LeaveType::where('created_by', '=', \Auth::user()->creatorId())->get()->pluck('title', 'id'); $leavetypes = LeaveType::where('created_by', '=', \Auth::user()->creatorId())->get(); return view('leave.edit', compact('leave', 'employees', 'leavetypes')); } else { return response()->json(['error' => __('Permission denied.')], 401); } } else { return response()->json(['error' => __('Permission denied.')], 401); } } public function update(Request $request, $leave) { $leave = LocalLeave::find($leave); if (\Auth::user()->can('Edit Leave')) { if ($leave->created_by == Auth::user()->creatorId()) { $validator = \Validator::make( $request->all(), [ 'employee_id' => 'required', 'leave_type_id' => 'required', 'start_date' => 'required', 'end_date' => 'required', 'leave_reason' => 'required', 'remark' => 'required', ] ); if ($validator->fails()) { $messages = $validator->getMessageBag(); return redirect()->back()->with('error', $messages->first()); } $leave_type = LeaveType::find($request->leave_type_id); $employee = Employee::where('employee_id', '=', \Auth::user()->creatorId())->first(); $startDate = new \DateTime($request->start_date); $endDate = new \DateTime($request->end_date); $endDate->add(new \DateInterval('P1D')); // $total_leave_days = !empty($startDate->diff($endDate)) ? $startDate->diff($endDate)->days : 0; $date = Utility::AnnualLeaveCycle(); if (\Auth::user()->type == 'employee') { // Leave day $leaves_used = LocalLeave::whereNotIn('id', [$leave->id])->where('employee_id', '=', $employee->id)->where('leave_type_id', $leave_type->id)->where('status', 'Approved')->whereBetween('created_at', [$date['start_date'],$date['end_date']])->sum('total_leave_days'); $leaves_pending = LocalLeave::whereNotIn('id', [$leave->id])->where('employee_id', '=', $employee->id)->where('leave_type_id', $leave_type->id)->where('status', 'Pending')->whereBetween('created_at', [$date['start_date'],$date['end_date']])->sum('total_leave_days'); } else { // Leave day $leaves_used = LocalLeave::whereNotIn('id', [$leave->id])->where('employee_id', '=', $request->employee_id)->where('leave_type_id', $leave_type->id)->where('status', 'Approved')->whereBetween('created_at', [$date['start_date'],$date['end_date']])->sum('total_leave_days'); $leaves_pending = LocalLeave::whereNotIn('id', [$leave->id])->where('employee_id', '=', $request->employee_id)->where('leave_type_id', $leave_type->id)->where('status', 'Pending')->whereBetween('created_at', [$date['start_date'],$date['end_date']])->sum('total_leave_days'); } $total_leave_days = !empty($startDate->diff($endDate)) ? $startDate->diff($endDate)->days : 0; $return = $leave_type->days - $leaves_used; if ($total_leave_days > $return) { return redirect()->back()->with('error', __('You are not eligible for leave.')); } if (!empty($leaves_pending) && $leaves_pending + $total_leave_days > $return) { return redirect()->back()->with('error', __('Multiple leave entry is pending.')); } if ($leave_type->days >= $total_leave_days) { if (\Auth::user()->type == 'employee') { $leave->employee_id = $employee->id; } else { $leave->employee_id = $request->employee_id; } $leave->leave_type_id = $request->leave_type_id; $leave->start_date = $request->start_date; $leave->end_date = $request->end_date; $leave->total_leave_days = $total_leave_days; $leave->leave_reason = $request->leave_reason; $leave->remark = $request->remark; // $leave->status = $request->status; $leave->save(); return redirect()->route('leave.index')->with('success', __('Leave successfully updated.')); } else { return redirect()->back()->with('error', __('Leave type ' . $leave_type->name . ' is provide maximum ' . $leave_type->days . " days please make sure your selected days is under " . $leave_type->days . ' days.')); } } else { return redirect()->back()->with('error', __('Permission denied.')); } } else { return redirect()->back()->with('error', __('Permission denied.')); } } public function destroy(LocalLeave $leave) { if (\Auth::user()->can('Delete Leave')) { if ($leave->created_by == \Auth::user()->creatorId()) { $leave->delete(); return redirect()->route('leave.index')->with('success', __('Leave successfully deleted.')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } else { return redirect()->back()->with('error', __('Permission denied.')); } } public function export() { $name = 'leave_' . date('Y-m-d i:h:s'); $data = Excel::download(new LeaveExport(), $name . '.xlsx'); return $data; } public function action($id) { $leave = LocalLeave::find($id); $employee = Employee::find($leave->employee_id); $leavetype = LeaveType::find($leave->leave_type_id); return view('leave.action', compact('employee', 'leavetype', 'leave')); } public function changeaction(Request $request) { $leave = LocalLeave::find($request->leave_id); $leave->status = $request->status; if ($leave->status == 'Approved') { $startDate = new \DateTime($leave->start_date); $endDate = new \DateTime($leave->end_date); $endDate->add(new \DateInterval('P1D')); // $total_leave_days = $startDate->diff($endDate)->days; $total_leave_days = !empty($startDate->diff($endDate)) ? $startDate->diff($endDate)->days : 0; $leave->total_leave_days = $total_leave_days; $leave->status = 'Approved'; } $leave->save(); // twilio $setting = Utility::settings(\Auth::user()->creatorId()); $emp = Employee::find($leave->employee_id); if (isset($setting['twilio_leave_approve_notification']) && $setting['twilio_leave_approve_notification'] == 1) { // $msg = __("Your leave has been") . ' ' . $leave->status . '.'; $uArr = [ 'leave_status' => $leave->status, ]; Utility::send_twilio_msg($emp->phone, 'leave_approve_reject', $uArr); } $setings = Utility::settings(); if ($setings['leave_status'] == 1) { $employee = Employee::where('id', $leave->employee_id)->where('created_by', '=', \Auth::user()->creatorId())->first(); $uArr = [ 'leave_email' => $employee->email, 'leave_status_name' => $employee->name, 'leave_status' => $request->status, 'leave_reason' => $leave->leave_reason, 'leave_start_date' => $leave->start_date, 'leave_end_date' => $leave->end_date, 'total_leave_days' => $leave->total_leave_days, ]; $resp = Utility::sendEmailTemplate('leave_status', [$employee->email], $uArr); return redirect()->route('leave.index')->with('success', __('Leave status successfully updated.') . ((!empty($resp) && $resp['is_success'] == false && !empty($resp['error'])) ? '
' . $resp['error'] . '' : '')); } return redirect()->route('leave.index')->with('success', __('Leave status successfully updated.')); } public function jsoncount(Request $request) { $date = Utility::AnnualLeaveCycle(); $leave_counts = LeaveType::select(\DB::raw('COALESCE(SUM(leaves.total_leave_days),0) AS total_leave, leave_types.title, leave_types.days,leave_types.id')) ->leftjoin( 'leaves', function ($join) use ($request, $date) { $join->on('leaves.leave_type_id', '=', 'leave_types.id'); $join->where('leaves.employee_id', '=', $request->employee_id); $join->where('leaves.status', '=', 'Approved'); $join->whereBetween('leaves.created_at', [$date['start_date'],$date['end_date']]); } )->where('leave_types.created_by', '=', \Auth::user()->creatorId())->groupBy('leave_types.id')->get(); return $leave_counts; } public function calender(Request $request) { $created_by = \Auth::user()->creatorId(); $Meetings = LocalLeave::where('created_by', $created_by)->get(); $today_date = date('m'); $current_month_event = LocalLeave::select('id', 'start_date', 'employee_id', 'created_at')->whereRaw('MONTH(start_date)=' . $today_date)->get(); $arrMeeting = []; foreach ($Meetings as $meeting) { $arr['id'] = $meeting['id']; $arr['employee_id'] = $meeting['employee_id']; // $arr['leave_type_id'] = date('Y-m-d', strtotime($meeting['start_date'])); } $leaves = LocalLeave::where('created_by', '=', \Auth::user()->creatorId())->get(); if (\Auth::user()->type == 'employee') { $user = \Auth::user(); $employee = Employee::where('user_id', '=', $user->id)->first(); $leaves = LocalLeave::where('employee_id', '=', $employee->id)->get(); } else { $leaves = LocalLeave::where('created_by', '=', \Auth::user()->creatorId())->get(); } return view('leave.calender', compact('leaves')); } public function get_leave_data(Request $request) { $arrayJson = []; if ($request->get('calender_type') == 'google_calender') { $type = 'leave'; $arrayJson = Utility::getCalendarData($type); } else { $data = LocalLeave::where('created_by', \Auth::user()->creatorId())->get(); foreach ($data as $val) { $end_date = date_create($val->end_date); date_add($end_date, date_interval_create_from_date_string("1 days")); $arrayJson[] = [ "id" => $val->id, "title" => !empty(\Auth::user()->getLeaveType($val->leave_type_id)) ? \Auth::user()->getLeaveType($val->leave_type_id)->title : '', "start" => $val->start_date, "end" => date_format($end_date, "Y-m-d H:i:s"), "className" => $val->color, "textColor" => '#FFF', "allDay" => true, "url" => route('leave.action', $val['id']), ]; } } return $arrayJson; } } Controllers/CinetPayController.php000064400000035767150364311770013374 0ustar00plan_id); $plan = Plan::find($planID); $orderID = strtoupper(str_replace('.', '', uniqid('', true))); $authuser = Auth::user(); if ($plan) { /* Check for code usage */ $get_amount = $plan->price; if (!empty($request->coupon)) { $coupons = Coupon::where('code', strtoupper($request->coupon))->where('is_active', '1')->first(); if (!empty($coupons)) { $usedCoupun = $coupons->used_coupon(); $discount_value = ($plan->price / 100) * $coupons->discount; $get_amount = $plan->price - $discount_value; if ($coupons->limit == $usedCoupun) { return redirect()->back()->with('error', __('This coupon code has expired.')); } if ($get_amount <= 0) { $authuser = Auth::user(); $authuser->plan = $plan->id; $authuser->save(); $assignPlan = $authuser->assignPlan($plan->id); if ($assignPlan['is_success'] == true && !empty($plan)) { $orderID = strtoupper(str_replace('.', '', uniqid('', true))); $userCoupon = new UserCoupon(); $userCoupon->user = $authuser->id; $userCoupon->coupon = $coupons->id; $userCoupon->order = $orderID; $userCoupon->save(); Order::create( [ 'order_id' => $orderID, 'name' => null, 'email' => null, 'card_number' => null, 'card_exp_month' => null, 'card_exp_year' => null, 'plan_name' => $plan->name, 'plan_id' => $plan->id, 'price' => $get_amount == null ? 0 : $get_amount, 'price_currency' => $currency, 'txn_id' => '', 'payment_type' => __('Paiement Pro'), 'payment_status' => 'success', 'receipt' => null, 'user_id' => $authuser->id, ] ); $assignPlan = $authuser->assignPlan($plan->id); return redirect()->route('plans.index')->with('success', __('Plan Successfully Activated')); } } } else { return redirect()->back()->with('error', __('This coupon code is invalid or has expired.')); } } try { if ( $currency != 'XOF' && $currency != 'CDF' && $currency != 'USD' && $currency != 'KMF' && $currency != 'GNF' ) { return redirect()->route('plans.index')->with('error', __('Availabe currencies: XOF, CDF, USD, KMF, GNF')); } $call_back = route('plan.cinetpay.return') . '?_token=' . csrf_token(); $returnURL = route('plan.cinetpay.notify') . '?_token=' . csrf_token(); $cinetpay_data = [ "amount" => $get_amount, "currency" => $currency, "apikey" => $cinetpay_api_key, "site_id" => $cinetpay_site_id, "transaction_id" => $orderID, "description" => "Plan purchase", "return_url" => $call_back, "notify_url" => $returnURL, "metadata" => "user001", 'customer_name' => isset($authuser->name) ? $authuser->name : 'Test', 'customer_surname' => isset($authuser->name) ? $authuser->name : 'Test', 'customer_email' => isset($authuser->email) ? $authuser->email : 'test@gmail.com', 'customer_phone_number' => isset($authuser->mobile_number) ? $authuser->mobile_number : '1234567890', 'customer_address' => isset($authuser->address) ? $authuser->address : 'A-101, alok area, USA', 'customer_city' => 'texas', 'customer_country' => 'BF', 'customer_state' => 'USA', 'customer_zip_code' => isset($authuser->zipcode) ? $authuser->zipcode : '432876', ]; $curl = curl_init(); curl_setopt_array($curl, array( CURLOPT_URL => 'https://api-checkout.cinetpay.com/v2/payment', CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => "", CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 45, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => 'POST', CURLOPT_POSTFIELDS => json_encode($cinetpay_data), CURLOPT_SSL_VERIFYPEER => 0, CURLOPT_HTTPHEADER => array( "content-type:application/json" ), )); $response = curl_exec($curl); $err = curl_error($curl); curl_close($curl); //On recupère la réponse de CinetPay $response_body = json_decode($response, true); $coupons = Coupon::where('code', strtoupper($request->coupon))->where('is_active', '1')->first(); if ($response_body['code'] == '201') { $cinetpaySession = [ 'order_id' => $orderID, 'amount' => $get_amount, 'plan_id' => $plan->id, 'coupon_id' => !empty($coupons->id) ? $coupons->id : '', 'coupon_code' => !empty($request->coupon) ? $request->coupon : '', ]; $request->session()->put('cinetpaySession', $cinetpaySession); Order::create( [ 'order_id' => $orderID, 'name' => null, 'email' => null, 'card_number' => null, 'card_exp_month' => null, 'card_exp_year' => null, 'plan_name' => !empty($plan->name) ? $plan->name : 'Basic Package', 'plan_id' => $plan->id, 'price' => !empty($get_amount) ? $get_amount : 0, 'price_currency' => $currency, 'txn_id' => '', 'payment_type' => __('CinetPay'), 'payment_status' => 'pending', 'receipt' => null, 'user_id' => $authuser->id, ] ); $payment_link = $response_body["data"]["payment_url"]; // Retrieving the payment URL return redirect($payment_link); } else { return back()->with('error', $response_body["description"]); } } catch (\Exception $e) { Log::debug($e->getMessage()); return redirect()->route('plans.index')->with('error', $e->getMessage()); } } else { return redirect()->route('plans.index')->with('error', __('Plan is deleted.')); } } public function planCinetPayReturn(Request $request) { $cinetpaySession = $request->session()->get('cinetpaySession'); $request->session()->forget('cinetpaySession'); if (isset($request->transaction_id) || isset($request->token)) { $payment_setting = Utility::getAdminPaymentSetting(); $cinetpay_check = [ "apikey" => $payment_setting['cinetpay_api_key'], "site_id" => $payment_setting['cinetpay_site_id'], "transaction_id" => $request->transaction_id ]; $response = $this->getPayStatus($cinetpay_check); $response_body = json_decode($response, true); $authuser = Auth::user(); $plan = Plan::find($cinetpaySession['plan_id']); $getAmount = $cinetpaySession['amount']; $currency = isset($payment_setting['currency']) ? $payment_setting['currency'] : ''; $orderID = strtoupper(str_replace('.', '', uniqid('', true))); if ($response_body['code'] == '00') { $order = new Order(); $order->order_id = $orderID; $order->name = $authuser->name; $order->card_number = ''; $order->card_exp_month = ''; $order->card_exp_year = ''; $order->plan_name = $plan->name; $order->plan_id = $plan->id; $order->price = $getAmount; $order->price_currency = $currency; $order->txn_id = $orderID; $order->payment_type = __('CinetPay'); $order->payment_status = 'success'; $order->receipt = ''; $order->user_id = $authuser->id; $order->save(); $assignPlan = $authuser->assignPlan($plan->id); if ($request->coupon_code) { $coupons = Coupon::find($request->coupon_id); if (!empty($request->coupon_id)) { if (!empty($coupons)) { $userCoupon = new UserCoupon(); $userCoupon->user = $authuser->id; $userCoupon->coupon = $coupons->id; $userCoupon->order = $orderID; $userCoupon->save(); $usedCoupun = $coupons->used_coupon(); if ($coupons->limit <= $usedCoupun) { $coupons->is_active = 0; $coupons->save(); } } } } if ($assignPlan['is_success']) { return redirect()->route('plans.index')->with('success', __('Plan activated Successfully!')); } else { return redirect()->route('plans.index')->with('error', __($assignPlan['error'])); } } else { return redirect()->route('plans.index')->with('error', __('Your Payment has failed!')); } } else { return redirect()->route('plans.index')->with('error', __('Your Payment has failed!')); } } public function planCinetPayNotify(Request $request) { /* 1- Recovery of parameters posted on the URL by CinetPay * https://docs.cinetpay.com/api/1.0-fr/checkout/notification#les-etapes-pour-configurer-lurl-de-notification * */ if (isset($request->cpm_trans_id)) { // Using your transaction identifier, check that the order has not yet been processed $VerifyStatusCmd = "1"; // status value to retrieve from your database if ($VerifyStatusCmd == '00') { //The order has already been processed // Scarred you script die(); } $payment_setting = Utility::getAdminPaymentSetting(); /* 2- Otherwise, we check the status of the transaction in the event of a payment attempt on CinetPay * https://docs.cinetpay.com/api/1.0-fr/checkout/notification#2-verifier-letat-de-la-transaction */ $cinetpay_check = [ "apikey" => $payment_setting['cinetpay_api_key'], "site_id" => $payment_setting['cinetpay_site_id'], "transaction_id" => $request->cpm_trans_id ]; $response = $this->getPayStatus($cinetpay_check); // call query function to retrieve status //We get the response from CinetPay $response_body = json_decode($response, true); if ($response_body['code'] == '00') { /* correct, on délivre le service * https://docs.cinetpay.com/api/1.0-fr/checkout/notification#3-delivrer-un-service*/ echo 'Congratulations, your payment has been successfully completed'; } else { // transaction a échoué echo 'Failure, code:' . $response_body['code'] . ' Description' . $response_body['description'] . ' Message: ' . $response_body['message']; } // Update the transaction in your database /* $order->update(); */ } else { print("cpm_trans_id non found"); } } public function getPayStatus($data) { $curl = curl_init(); curl_setopt_array($curl, array( CURLOPT_URL => 'https://api-checkout.cinetpay.com/v2/payment/check', CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => "", CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 45, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => 'POST', CURLOPT_POSTFIELDS => json_encode($data), CURLOPT_SSL_VERIFYPEER => 0, CURLOPT_HTTPHEADER => array( "content-type:application/json" ), )); $response = curl_exec($curl); $err = curl_error($curl); curl_close($curl); if ($err) return redirect()->route('plans.index')->with('error', __('Something went wrong!')); else return ($response); } } Controllers/GoalTrackingController.php000064400000015056150364311770014212 0ustar00can('Manage Goal Tracking')) { $user = \Auth::user(); if($user->type == 'employee') { $employee = Employee::where('user_id', $user->id)->first(); $goalTrackings = GoalTracking::where('created_by', '=', \Auth::user()->creatorId())->where('branch', $employee->branch_id)->get(); } else { $goalTrackings = GoalTracking::where('created_by', '=', \Auth::user()->creatorId())->with('goalType')->get(); } return view('goaltracking.index', compact('goalTrackings')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } public function create() { if(\Auth::user()->can('Create Goal Tracking')) { $brances = Branch::where('created_by', '=', \Auth::user()->creatorId())->get()->pluck('name', 'id'); $brances->prepend('Select Branch', ''); $goalTypes = GoalType::where('created_by', '=', \Auth::user()->creatorId())->get()->pluck('name', 'id'); $goalTypes->prepend('Select Goal Type', ''); return view('goaltracking.create', compact('brances', 'goalTypes')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } public function store(Request $request) { if(\Auth::user()->can('Create Goal Tracking')) { $validator = \Validator::make( $request->all(), [ 'branch' => 'required', 'goal_type' => 'required', 'start_date' => 'required', 'end_date' => 'required|after_or_equal:start_date', 'subject' => 'required', ] ); if($validator->fails()) { $messages = $validator->getMessageBag(); return redirect()->back()->with('error', $messages->first()); } $goalTracking = new GoalTracking(); $goalTracking->branch = $request->branch; $goalTracking->goal_type = $request->goal_type; $goalTracking->start_date = $request->start_date; $goalTracking->end_date = $request->end_date; $goalTracking->subject = $request->subject; $goalTracking->target_achievement = $request->target_achievement; $goalTracking->description = $request->description; $goalTracking->created_by = \Auth::user()->creatorId(); $goalTracking->save(); return redirect()->route('goaltracking.index')->with('success', __('Goal tracking successfully created.')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } public function show(GoalTracking $goalTracking) { // } public function edit($id) { if(\Auth::user()->can('Edit Goal Tracking')) { $goalTracking = GoalTracking::find($id); $brances = Branch::where('created_by', '=', \Auth::user()->creatorId())->get()->pluck('name', 'id'); $brances->prepend('Select Branch', ''); $goalTypes = GoalType::where('created_by', '=', \Auth::user()->creatorId())->get()->pluck('name', 'id'); $goalTypes->prepend('Select Goal Type', ''); $status = GoalTracking::$status; return view('goaltracking.edit', compact('brances', 'goalTypes', 'goalTracking', 'status')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } public function update(Request $request, $id) { if(\Auth::user()->can('Edit Goal Tracking')) { $goalTracking = GoalTracking::find($id); $validator = \Validator::make( $request->all(), [ 'branch' => 'required', 'goal_type' => 'required', 'start_date' => 'required', 'end_date' => 'required', 'subject' => 'required', ] ); if($validator->fails()) { $messages = $validator->getMessageBag(); return redirect()->back()->with('error', $messages->first()); } $goalTracking->branch = $request->branch; $goalTracking->goal_type = $request->goal_type; $goalTracking->start_date = $request->start_date; $goalTracking->end_date = $request->end_date; $goalTracking->subject = $request->subject; $goalTracking->target_achievement = $request->target_achievement; $goalTracking->status = $request->status; $goalTracking->progress = $request->progress; $goalTracking->description = $request->description; $goalTracking->rating = $request->rating; $goalTracking->save(); return redirect()->route('goaltracking.index')->with('success', __('Goal tracking successfully updated.')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } public function destroy($id) { if(\Auth::user()->can('Delete Goal Tracking')) { $goalTracking = GoalTracking::find($id); if($goalTracking->created_by == \Auth::user()->creatorId()) { $goalTracking->delete(); return redirect()->route('goaltracking.index')->with('success', __('GoalTracking successfully deleted.')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } else { return redirect()->back()->with('error', __('Permission denied.')); } } } Controllers/Controller.php000064400000000551150364311770011716 0ustar00type == 'super admin' || \Auth::user()->type == 'company') { if($id != null) { $notification_template = NotificationTemplates::where('id',$id)->first(); } else { $notification_template = NotificationTemplates::first(); } if(empty($notification_template)) { return redirect()->back()->with('error', __('Not exists in notification template.')); } $languages = Utility::languages(); $curr_noti_tempLang = NotificationTemplateLangs::where('parent_id', '=', $notification_template->id)->where('lang', $lang)->where('created_by', '=', \Auth::user()->creatorId())->first(); if(!isset($curr_noti_tempLang) || empty($curr_noti_tempLang)) { $curr_noti_tempLang = NotificationTemplateLangs::where('parent_id', '=', $notification_template->id)->where('lang', $lang)->first(); } if(!isset($curr_noti_tempLang) || empty($curr_noti_tempLang)) { $curr_noti_tempLang = NotificationTemplateLangs::where('parent_id', '=', $notification_template->id)->where('lang', 'en')->first(); !empty($curr_noti_tempLang) ? $curr_noti_tempLang->lang = $lang : null; } $notification_templates = NotificationTemplates::all(); return view('notification-templates.index', compact('notification_template','notification_templates','curr_noti_tempLang','languages')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } public function update(Request $request,$id) { $validator = \Validator::make( $request->all(), [ 'content' => 'required', ] ); if($validator->fails()) { $messages = $validator->getMessageBag(); return redirect()->back()->with('error', $messages->first()); } $NotiLangTemplate = NotificationTemplateLangs::where('parent_id', '=', $id)->where('lang', '=', $request->lang)->where('created_by', '=', \Auth::user()->creatorId())->first(); // $NotiLangTemplate = NotificationTemplateLangs::where('parent_id', '=', $id)->where('lang', '=', $request->lang)->first(); // if record not found then create new record else update it. if(empty($NotiLangTemplate)) { $variables = NotificationTemplateLangs::where('parent_id', '=', $id)->where('lang', '=', $request->lang)->first()->variables; $NotiLangTemplate = new NotificationTemplateLangs(); $NotiLangTemplate->parent_id = $id; $NotiLangTemplate->lang = $request['lang']; $NotiLangTemplate->content = $request['content']; $NotiLangTemplate->variables = $variables; $NotiLangTemplate->created_by = \Auth::user()->creatorId(); $NotiLangTemplate->save(); } else { $NotiLangTemplate->content = $request['content']; $NotiLangTemplate->save(); } return redirect()->route( 'notification-templates.index', [ $id, $request->lang, ] )->with('success', __('Notification Template successfully updated.')); } public function show(){ return redirect()->back(); } } Controllers/YooKassaController.php000064400000024346150364311770013400 0ustar00plan_id); $authuser = Auth::user(); $plan = Plan::find($planID); if ($plan) { $get_amount = $plan->price; if (!empty($request->coupon)) { $coupons = Coupon::where('code', strtoupper($request->coupon))->where('is_active', '1')->first(); if (!empty($coupons)) { $usedCoupun = $coupons->used_coupon(); $discount_value = ($plan->price / 100) * $coupons->discount; $get_amount = $plan->price - $discount_value; $orderID = strtoupper(str_replace('.', '', uniqid('', true))); $userCoupon = new UserCoupon(); $userCoupon->user = $authuser->id; $userCoupon->coupon = $coupons->id; $userCoupon->order = $orderID; $userCoupon->save(); if ($coupons->limit == $usedCoupun) { return redirect()->back()->with('error', __('This coupon code has expired.')); } } else { return redirect()->back()->with('error', __('This coupon code is invalid or has expired.')); } } if ($get_amount <= 0) { $orderID = strtoupper(str_replace('.', '', uniqid('', true))); $user = auth()->user(); $statuses = 'Succeeded'; $order = new Order(); $order->order_id = $orderID; $order->name = $user->name; $order->card_number = ''; $order->card_exp_month = ''; $order->card_exp_year = ''; $order->plan_name = $plan->name; $order->plan_id = $plan->id; $order->price = $get_amount; $order->price_currency = $payment_setting['currency']; $order->payment_type = __('YooKassa'); $order->payment_status = $statuses; $order->receipt = ''; $order->user_id = $user->id; $order->save(); $assignPlan = $user->assignPlan($plan->id); $coupons = Coupon::find($request->coupon_id); if ($request->has('coupon') && $request->coupon != '') { $coupons = Coupon::where('code', strtoupper($request->coupon))->where('is_active', '1')->first(); if (!empty($coupons)) { $userCoupon = new UserCoupon(); $userCoupon->user = $user->id; $userCoupon->coupon = $coupons->id; $userCoupon->order = $orderID; $userCoupon->save(); $usedCoupun = $coupons->used_coupon(); if ($coupons->limit <= $usedCoupun) { $coupons->is_active = 0; $coupons->save(); } } } if ($assignPlan['is_success']) { return redirect()->route('plans.index')->with('success', __('Plan activated Successfully.')); } else { return redirect()->route('plans.index')->with('error', __($assignPlan['error'])); } } try { if (is_int((int)$yookassa_shop_id)) { $client = new Client(); $client->setAuth((int)$yookassa_shop_id, $yookassa_secret_key); $orderID = strtoupper(str_replace('.', '', uniqid('', true))); $product = !empty($plan->name) ? $plan->name : 'Life time'; $payment = $client->createPayment( array( 'amount' => array( 'value' => $get_amount, 'currency' => $currency, ), 'confirmation' => array( 'type' => 'redirect', 'return_url' => route('plan.get.yookassa.status', [$plan->id, 'order_id' => $orderID, 'price' => $get_amount]), ), 'capture' => true, 'description' => 'Заказ №1', ), uniqid('', true) ); $authuser = Auth::user(); $authuser->plan = $plan->id; $authuser->save(); if (!empty($authuser->payment_subscription_id) && $authuser->payment_subscription_id != '') { try { $authuser->cancel_subscription($authuser->id); } catch (\Exception $exception) { Log::debug($exception->getMessage()); } } Order::create( [ 'order_id' => $orderID, 'name' => null, 'email' => null, 'card_number' => null, 'card_exp_month' => null, 'card_exp_year' => null, 'plan_name' => $plan->name, 'plan_id' => $plan->id, 'price' => $get_amount == null ? 0 : $get_amount, 'price_currency' => $currency, 'txn_id' => '', 'payment_type' => __('YooKassa'), 'payment_status' => 'pending', 'receipt' => null, 'user_id' => $authuser->id, ] ); Session::put('payment_id', $payment['id']); if ($payment['confirmation']['confirmation_url'] != null) { return redirect($payment['confirmation']['confirmation_url']); } else { return redirect()->route('plans.index')->with('error', 'Something went wrong, Please try again'); } // return redirect()->route('plans.index')->with('success', __('Plan Successfully Activated')); } else { return redirect()->back()->with('error', 'Please Enter Valid Shop Id Key'); } } catch (\Throwable $th) { return redirect()->back()->with('error', 'Incorrect currency of payment.'); } } } public function planGetYooKassaStatus(Request $request, $planId) { $payment_setting = Utility::getAdminPaymentSetting(); $yookassa_shop_id = $payment_setting['yookassa_shop_id']; $yookassa_secret_key = $payment_setting['yookassa_secret']; $currency = isset($payment_setting['currency']) ? $payment_setting['currency'] : 'USD'; if (is_int((int)$yookassa_shop_id)) { $client = new Client(); $client->setAuth((int)$yookassa_shop_id, $yookassa_secret_key); $paymentId = Session::get('payment_id'); Session::forget('payment_id'); if ($paymentId == null) { return redirect()->back()->with('error', __('Transaction Unsuccesfull')); } $payment = $client->getPaymentInfo($paymentId); if (isset($payment) && $payment->status == "succeeded") { $plan = Plan::find($planId); $user = auth()->user(); $orderID = strtoupper(str_replace('.', '', uniqid('', true))); Utility::referralTransaction($plan); try { $Order = Order::where('order_id', $request->order_id)->first(); $Order->payment_status = 'succeeded'; $Order->save(); $assignPlan = $user->assignPlan($plan->id); $coupons = Coupon::find($request->coupon_id); if (!empty($request->coupon_id)) { if (!empty($coupons)) { $userCoupon = new UserCoupon(); $userCoupon->user = $user->id; $userCoupon->coupon = $coupons->id; $userCoupon->order = $orderID; $userCoupon->save(); $usedCoupun = $coupons->used_coupon(); if ($coupons->limit <= $usedCoupun) { $coupons->is_active = 0; $coupons->save(); } } } if ($assignPlan['is_success']) { return redirect()->route('plans.index')->with('success', __('Plan activated Successfully.')); } else { return redirect()->route('plans.index')->with('error', __($assignPlan['error'])); } } catch (\Exception $e) { return redirect()->route('plans.index')->with('error', __($e->getMessage())); } } else { return redirect()->back()->with('error', 'Please Enter Valid Shop Id Key'); } } } } Controllers/LeaveTypeController.php000064400000011106150364311770013533 0ustar00can('Manage Leave Type')) { $leavetypes = LeaveType::where('created_by', '=', \Auth::user()->creatorId())->get(); return view('leavetype.index', compact('leavetypes')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } public function create() { if(\Auth::user()->can('Create Leave Type')) { return view('leavetype.create'); } else { return response()->json(['error' => __('Permission denied.')], 401); } } public function store(Request $request) { if(\Auth::user()->can('Create Leave Type')) { $validator = \Validator::make( $request->all(), [ 'title' => 'required', 'days' => 'required|gt:0', ] ); if($validator->fails()) { $messages = $validator->getMessageBag(); return redirect()->back()->with('error', $messages->first()); } $leavetype = new LeaveType(); $leavetype->title = $request->title; $leavetype->days = $request->days; $leavetype->created_by = \Auth::user()->creatorId(); $leavetype->save(); return redirect()->route('leavetype.index')->with('success', __('LeaveType successfully created.')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } public function show(LeaveType $leavetype) { return redirect()->route('leavetype.index'); } public function edit(LeaveType $leavetype) { if(\Auth::user()->can('Edit Leave Type')) { if($leavetype->created_by == \Auth::user()->creatorId()) { return view('leavetype.edit', compact('leavetype')); } else { return response()->json(['error' => __('Permission denied.')], 401); } } else { return response()->json(['error' => __('Permission denied.')], 401); } } public function update(Request $request, LeaveType $leavetype) { if(\Auth::user()->can('Edit Leave Type')) { if($leavetype->created_by == \Auth::user()->creatorId()) { $validator = \Validator::make( $request->all(), [ 'title' => 'required', 'days' => 'required', ] ); if($validator->fails()) { $messages = $validator->getMessageBag(); return redirect()->back()->with('error', $messages->first()); } $leavetype->title = $request->title; $leavetype->days = $request->days; $leavetype->save(); return redirect()->route('leavetype.index')->with('success', __('LeaveType successfully updated.')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } else { return redirect()->back()->with('error', __('Permission denied.')); } } public function destroy(LeaveType $leavetype) { if(\Auth::user()->can('Delete Leave Type')) { if($leavetype->created_by == \Auth::user()->creatorId()) { $leave = Leave::where('leave_type_id',$leavetype->id)->get(); if(count($leave) == 0) { $leavetype->delete(); } else { return redirect()->route('leavetype.index')->with('error', __('This leavetype has leave. Please remove the leave from this leavetype.')); } return redirect()->route('leavetype.index')->with('success', __('LeaveType successfully deleted.')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } else { return redirect()->back()->with('error', __('Permission denied.')); } } } Controllers/MidtransController.php000064400000020633150364311770013423 0ustar00plan_id); $plan = Plan::find($planID); $orderID = strtoupper(str_replace('.', '', uniqid('', true))); if ($plan) { $get_amount = round($plan->price); if (!empty($request->coupon)) { $coupons = Coupon::where('code', strtoupper($request->coupon))->where('is_active', '1')->first(); if (!empty($coupons)) { $usedCoupun = $coupons->used_coupon(); $discount_value = ($plan->price / 100) * $coupons->discount; $get_amount = $plan->price - $discount_value; $orderID = strtoupper(str_replace('.', '', uniqid('', true))); $userCoupon = new UserCoupon(); $userCoupon->user = Auth::user()->id; $userCoupon->coupon = $coupons->id; $userCoupon->order = $orderID; $userCoupon->save(); if ($coupons->limit == $usedCoupun) { return redirect()->back()->with('error', __('This coupon code has expired.')); } } else { return redirect()->back()->with('error', __('This coupon code is invalid or has expired.')); } } if ($get_amount <= 0) { $orderID = strtoupper(str_replace('.', '', uniqid('', true))); $user = auth()->user(); $statuses = 'Succeeded'; $order = new Order(); $order->order_id = $orderID; $order->name = $user->name; $order->card_number = ''; $order->card_exp_month = ''; $order->card_exp_year = ''; $order->plan_name = $plan->name; $order->plan_id = $plan->id; $order->price = $get_amount; $order->price_currency = $payment_setting['currency']; $order->payment_type = __('Midtrans'); $order->payment_status = $statuses; $order->receipt = ''; $order->user_id = $user->id; $order->save(); $assignPlan = $user->assignPlan($plan->id); $coupons = Coupon::find($request->coupon_id); if ($request->has('coupon') && $request->coupon != '') { $coupons = Coupon::where('code', strtoupper($request->coupon))->where('is_active', '1')->first(); if (!empty($coupons)) { $userCoupon = new UserCoupon(); $userCoupon->user = $user->id; $userCoupon->coupon = $coupons->id; $userCoupon->order = $orderID; $userCoupon->save(); $usedCoupun = $coupons->used_coupon(); if ($coupons->limit <= $usedCoupun) { $coupons->is_active = 0; $coupons->save(); } } } if ($assignPlan['is_success']) { return redirect()->route('plans.index')->with('success', __('Plan activated Successfully.')); } else { return redirect()->route('plans.index')->with('error', __($assignPlan['error'])); } } // Set your Merchant Server Key \Midtrans\Config::$serverKey = $midtrans_secret; // Set to Development/Sandbox Environment (default). Set to true for Production Environment (accept real transaction). if ($mode == 'sandbox') { \Midtrans\Config::$isProduction = false; } else { \Midtrans\Config::$isProduction = true; } // Set sanitization on (default) \Midtrans\Config::$isSanitized = true; // Set 3DS transaction for credit card to true \Midtrans\Config::$is3ds = true; $params = array( 'transaction_details' => array( 'order_id' => $orderID, 'gross_amount' => str_replace(",", "", number_format($get_amount)), ), 'customer_details' => array( 'first_name' => Auth::user()->name, 'last_name' => '', 'email' => Auth::user()->email, 'phone' => '8787878787', ), ); $snapToken = \Midtrans\Snap::getSnapToken($params); $authuser = Auth::user(); $authuser->plan = $plan->id; $authuser->save(); Order::create( [ 'order_id' => $orderID, 'name' => null, 'email' => null, 'card_number' => null, 'card_exp_month' => null, 'card_exp_year' => null, 'plan_name' => $plan->name, 'plan_id' => $plan->id, 'price' => $get_amount == null ? 0 : $get_amount, 'price_currency' => $currency, 'txn_id' => '', 'payment_type' => __('Midtrans'), 'payment_status' => 'pending', 'receipt' => null, 'user_id' => $authuser->id, ] ); $data = [ 'snap_token' => $snapToken, 'midtrans_secret' => $midtrans_secret, 'midtrans_mode' => $mode, 'order_id' => $orderID, 'plan_id' => $plan->id, 'amount' => $get_amount, 'fallback_url' => 'plan.get.midtrans.status' ]; return view('midtras.payment', compact('data')); } } public function planGetMidtransStatus(Request $request) { $response = json_decode($request->json, true); if (isset($response['status_code']) && $response['status_code'] == 200) { $plan = Plan::find($request['plan_id']); $user = auth()->user(); $orderID = strtoupper(str_replace('.', '', uniqid('', true))); try { Utility::referralTransaction($plan); $Order = Order::where('order_id', $request['order_id'])->first(); $Order->payment_status = 'succeeded'; $Order->save(); $assignPlan = $user->assignPlan($plan->id); if (!empty($request->coupon_id)) { if (!empty($coupons)) { $userCoupon = new UserCoupon(); $userCoupon->user = $user->id; $userCoupon->coupon = $coupons->id; $userCoupon->order = $orderID; $userCoupon->save(); $usedCoupun = $coupons->used_coupon(); if ($coupons->limit <= $usedCoupun) { $coupons->is_active = 0; $coupons->save(); } } } if ($assignPlan['is_success']) { return redirect()->route('plans.index')->with('success', __('Plan activated Successfully.')); } else { return redirect()->route('plans.index')->with('error', __($assignPlan['error'])); } } catch (\Exception $e) { return redirect()->route('plans.index')->with('error', __($e->getMessage())); } } else { return redirect()->back()->with('error', $response['status_message']); } } } Controllers/ContractController.php000064400000064706150364311770013430 0ustar00middleware( [ 'auth', ] ); } /** * Display a listing of the resource. * * @return \Illuminate\Http\Response */ public function index() { if (\Auth::user()->can('Manage Contract')) { if (\Auth::user()->type == 'company' || \Auth::user()->type == 'hr') { $contracts = Contract::where('created_by', '=', \Auth::user()->creatorId())->with(['employee', 'contract_type'])->get(); $curr_month = Contract::where('created_by', '=', \Auth::user()->creatorId())->whereMonth('start_date', '=', date('m'))->get(); $curr_week = Contract::where('created_by', '=', \Auth::user()->creatorId())->whereBetween( 'start_date', [ \Carbon\Carbon::now()->startOfWeek(), \Carbon\Carbon::now()->endOfWeek(), ] )->get(); $last_30days = Contract::where('created_by', '=', \Auth::user()->creatorId())->whereDate('start_date', '>', \Carbon\Carbon::now()->subDays(30))->get(); // Contracts Summary $cnt_contract = []; $cnt_contract['total'] = \App\Models\Contract::getContractSummary($contracts); $cnt_contract['this_month'] = \App\Models\Contract::getContractSummary($curr_month); $cnt_contract['this_week'] = \App\Models\Contract::getContractSummary($curr_week); $cnt_contract['last_30days'] = \App\Models\Contract::getContractSummary($last_30days); return view('contracts.index', compact('contracts', 'cnt_contract')); } elseif (\Auth::user()->type == 'employee') { $contracts = Contract::where('employee_name', '=', \Auth::user()->id)->get(); $curr_month = Contract::where('employee_name', '=', \Auth::user()->id)->whereMonth('start_date', '=', date('m'))->get(); $curr_week = Contract::where('employee_name', '=', \Auth::user()->id)->whereBetween( 'start_date', [ \Carbon\Carbon::now()->startOfWeek(), \Carbon\Carbon::now()->endOfWeek(), ] )->get(); $last_30days = Contract::where('created_by', '=', \Auth::user()->creatorId())->whereDate('start_date', '>', \Carbon\Carbon::now()->subDays(30))->get(); // Contracts Summary $cnt_contract = []; $cnt_contract['total'] = \App\Models\Contract::getContractSummary($contracts); $cnt_contract['this_month'] = \App\Models\Contract::getContractSummary($curr_month); $cnt_contract['this_week'] = \App\Models\Contract::getContractSummary($curr_week); $cnt_contract['last_30days'] = \App\Models\Contract::getContractSummary($last_30days); return view('contracts.index', compact('contracts', 'cnt_contract')); } else { return redirect()->back()->with('error', __('Permission Denied.')); } } else { return redirect()->back()->with('error', __('Permission Denied.')); } } /** * Show the form for creating a new resource. * * @return \Illuminate\Http\Response */ public function create() { if (\Auth::user()->can('Create Contract')) { // $employee = User::where('type', '=', 'employee')->get()->pluck('name', 'id'); $employee = User::where('type', '=', 'employee')->where('created_by', \Auth::user()->creatorId())->get()->pluck('name', 'id'); $contractType = ContractType::where('created_by', '=', \Auth::user()->creatorId())->get()->pluck('name', 'id'); return view('contracts.create', compact('contractType', 'employee')); } else { return response()->json(['error' => __('Permission Denied.')], 401); } } /** * Store a newly created resource in storage. * * @param \Illuminate\Http\Request $request * * @return \Illuminate\Http\Response */ public function store(Request $request) { if (\Auth::user()->can('Create Contract')) { $validator = \Validator::make( $request->all(), [ // 'name' => 'required|max:20', 'subject' => 'required', 'value' => 'required', 'type' => 'required', 'start_date' => 'required', 'end_date' => 'required', ] ); if ($validator->fails()) { $messages = $validator->getMessageBag(); return redirect()->route('contract.index')->with('error', $messages->first()); } $date = explode(' to ', $request->date); $contract = new Contract(); $contract->employee_name = $request->employee_name; $contract->subject = $request->subject; $contract->value = $request->value; $contract->type = $request->type; $contract->start_date = $request->start_date; $contract->end_date = $request->end_date; $contract->description = $request->description; $contract->created_by = \Auth::user()->creatorId(); $contract->save(); $settings = Utility::settings(\Auth::user()->creatorId()); if (isset($settings['contract_notification']) && $settings['contract_notification'] == 1) { // $msg = 'New Invoice ' . \Auth::user()->contractNumberFormat($this->contractNumber()) . ' created by ' . \Auth::user()->name . '.'; $uArr = [ 'contract_number' => \Auth::user()->contractNumberFormat($this->contractNumber()), 'contract_company_name' => \Auth::user()->name, ]; Utility::send_slack_msg('contract_notification', $uArr); } if (isset($settings['telegram_contract_notification']) && $settings['telegram_contract_notification'] == 1) { // $resp = 'New Invoice ' . Auth::user()->contractNumberFormat($this->contractNumber()) . ' created by ' . \Auth::user()->name . '.'; $uArr = [ 'contract_number' => \Auth::user()->contractNumberFormat($this->contractNumber()), 'contract_company_name' => \Auth::user()->name, ]; Utility::send_telegram_msg('contract_notification', $uArr); } return redirect()->route('contract.index')->with('success', __('Contract successfully created!')); } else { return response()->json(['error' => __('Permission Denied.')], 401); } } function contractNumber() { $latest = Contract::where('created_by', '=', \Auth::user()->creatorId())->latest()->first(); if (!$latest) { return 1; } return $latest->id + 1; } /** * Display the specified resource. * * @param \App\Contract $contract * * @return \Illuminate\Http\Response */ public function show($id) { // dd($id); try { $id = \Illuminate\Support\Facades\Crypt::decrypt($id); } catch (\RuntimeException $e) { return redirect()->back()->with('error', __('Contract not avaliable')); } $contract = Contract::find($id); // return redirect()->route('contract.show'); if ($contract->created_by == \Auth::user()->creatorId()) { $employee = $contract->employee; return view('contracts.show', compact('contract', 'employee')); } else { return redirect()->back()->with('error', __('Permission Denied.')); } } /** * Show the form for editing the specified resource. * * @param \App\Contract $contract * * @return \Illuminate\Http\Response */ public function edit(Contract $contract) { if (\Auth::user()->can('Edit Contract')) { if ($contract->created_by == \Auth::user()->creatorId()) { $employee = User::where('type', '=', 'employee')->where('created_by', \Auth::user()->creatorId())->get()->pluck('name', 'id'); $contractType = ContractType::where('created_by', '=', \Auth::user()->creatorId())->get()->pluck('name', 'id'); return view('contracts.edit', compact('contract', 'contractType', 'employee')); } else { return response()->json(['error' => __('Permission Denied.')], 401); } } else { return response()->json(['error' => __('Permission Denied.')], 401); } } /** * Update the specified resource in storage. * * @param \Illuminate\Http\Request $request * @param \App\Contract $contract * * @return \Illuminate\Http\Response */ public function update(Request $request, Contract $contract) { if (\Auth::user()->can('Edit Contract')) { if ($contract->created_by == \Auth::user()->creatorId()) { $validator = \Validator::make( $request->all(), [ // 'name' => 'required|max:20', 'subject' => 'required', 'value' => 'required', 'type' => 'required', 'start_date' => 'required', 'end_date' => 'required', ] ); if ($validator->fails()) { $messages = $validator->getMessageBag(); return redirect()->route('contract.index')->with('error', $messages->first()); } $date = explode(' to ', $request->date); $contract->employee_name = $request->employee_name; $contract->subject = $request->subject; $contract->value = $request->value; $contract->type = $request->type; $contract->start_date = $request->start_date; $contract->end_date = $request->end_date; $contract->description = $request->description; $contract->save(); return redirect()->route('contract.index')->with('success', __('Contract successfully updated!')); } else { return redirect()->back()->with('error', __('Permission Denied.')); } } else { return redirect()->back()->with('error', __('Permission Denied.')); } } /** * Remove the specified resource from storage. * * @param \App\Contract $contract * * @return \Illuminate\Http\Response */ public function destroy($id) { if (\Auth::user()->can('Delete Contract')) { $contract = Contract::find($id); if ($contract->created_by == \Auth::user()->creatorId()) { $attechments = $contract->ContractAttechment()->get()->each; foreach ($attechments->items as $attechment) { if (\Storage::exists('contract_attechment/' . $attechment->files)) { unlink('storage/contract_attechment/' . $attechment->files); } $attechment->delete(); } $contract->ContractComment()->get()->each->delete(); $contract->ContractNote()->get()->each->delete(); $contract->delete(); return redirect()->route('contract.index')->with('success', __('Contract successfully deleted!')); } else { return redirect()->back()->with('error', __('Permission Denied.')); } } else { return redirect()->back()->with('error', __('Permission Denied.')); } } public function descriptionStore($id, Request $request) { if (\Auth::user()->type == 'company' || \Auth::user()->type == 'hr') { $contract = Contract::find($id); $contract->contract_description = $request->contract_description; $contract->save(); return redirect()->back()->with('success', __('Description successfully saved.')); } else { return redirect()->back()->with('error', __('Permission denied')); } } public function fileUpload($id, Request $request) { $contract = Contract::find($id); if (\Auth::user()->type == 'company' || \Auth::user()->type == 'hr') { $request->validate(['file' => 'required']); $dir = 'contract_attechment/'; $files = $request->file->getClientOriginalName(); $path = Utility::upload_file($request, 'file', $files, $dir, []); if ($path['flag'] == 1) { $file = $path['url']; } else { return redirect()->back()->with('error', __($path['msg'])); } $file = ContractAttechment::create( [ 'contract_id' => $request->contract_id, 'user_id' => \Auth::user()->id, 'files' => $files, ] ); $return = []; $return['is_success'] = true; $return['download'] = route( 'contracts.file.download', [ $contract->id, $file->id, ] ); $return['delete'] = route( 'contracts.file.delete', [ $contract->id, $file->id, ] ); return response()->json($return); } elseif (\Auth::user()->type == 'employee' && $contract->status == 'accept') { $request->validate(['file' => 'required']); $dir = 'contract_attechment/'; $files = $request->file->getClientOriginalName(); $path = Utility::upload_file($request, 'file', $files, $dir, []); if ($path['flag'] == 1) { $file = $path['url']; } else { return redirect()->back()->with('error', __($path['msg'])); } $file = ContractAttechment::create( [ 'contract_id' => $request->contract_id, 'user_id' => \Auth::user()->id, 'files' => $files, ] ); $return = []; $return['is_success'] = true; $return['download'] = route( 'contracts.file.download', [ $contract->id, $file->id, ] ); $return['delete'] = route( 'contracts.file.delete', [ $contract->id, $file->id, ] ); return response()->json($return); } else { return response()->json( [ 'is_success' => false, 'error' => __('Permission Denied.'), ], 401 ); } } public function fileDownload($id, $file_id) { $contract = Contract::find($id); if ($contract->created_by == \Auth::user()->creatorId()) { $file = ContractAttechment::find($file_id); if ($file) { $file_path = storage_path('contract_attechment/' . $file->files); // $files = $file->files; return \Response::download( $file_path, $file->files, [ 'Content-Length: ' . filesize($file_path), ] ); } else { return redirect()->back()->with('error', __('File is not exist.')); } } else { return redirect()->back()->with('error', __('Permission Denied.')); } } public function fileDelete($id, $file_id) { if (\Auth::user()->can('Delete Attachment')) { $contract = Contract::find($id); $file = ContractAttechment::find($file_id); if ($file) { $path = storage_path('contract_attechment/' . $file->files); if (file_exists($path)) { \File::delete($path); } $file->delete(); return redirect()->back()->with('success', __('Attachment successfully deleted!')); } else { return response()->json( [ 'is_success' => false, 'error' => __('File is not exist.'), ], 200 ); } } else { return redirect()->back()->with('error', __('Permission Denied.')); } } public function commentStore(Request $request, $id) { if (\Auth::user()->can('Store Comment')) { $contract = new ContractComment(); $contract->comment = $request->comment; $contract->contract_id = $id; $contract->user_id = \Auth::user()->id; $contract->save(); return redirect()->back()->with('success', __('comments successfully created!') . ((isset($smtp_error)) ? '
' . $smtp_error . '' : ''))->with('status', 'comments'); } else { return redirect()->back()->with('error', __('Permission Denied.')); } } public function commentDestroy($id) { if (\Auth::user()->can('Delete Comment')) { $contract = ContractComment::find($id); $contract->delete(); return redirect()->back()->with('success', __('Comment successfully deleted!')); } else { return redirect()->back()->with('error', __('Permission Denied.')); } } public function noteStore(Request $request, $id) { if (\Auth::user()->can('Store Note')) { $contract = Contract::find($id); $notes = new ContractNote(); $notes->contract_id = $contract->id; $notes->note = $request->note; $notes->user_id = \Auth::user()->id; $notes->save(); return redirect()->back()->with('success', __('Note successfully saved.')); } else { return redirect()->back()->with('error', __('Permission denied')); } } public function noteDestroy($id) { $contract = ContractNote::find($id); if (\Auth::user()->can('Delete Note')) { $contract->delete(); return redirect()->back()->with('success', __('Note successfully deleted!')); } else { return redirect()->back()->with('error', __('Permission Denied.')); } } public function copycontract($id) { if (\Auth::user()->can('Create Contract')) { $contract = Contract::find($id); if ($contract->created_by == \Auth::user()->creatorId()) { $employee = User::where('type', '=', 'employee')->where('created_by', \Auth::user()->creatorId())->get()->pluck('name', 'id'); $contractType = ContractType::where('created_by', '=', \Auth::user()->creatorId())->get()->pluck('name', 'id'); return view('contracts.copy', compact('contract', 'contractType', 'employee')); } else { return response()->json(['error' => __('Permission Denied.')], 401); } } else { return redirect()->back()->with('error', __('Permission Denied.')); } } public function copycontractstore($Contract, Request $request) { if (\Auth::user()->can('Create Contract')) { $validator = \Validator::make( $request->all(), [ // 'name' => 'required|max:20', 'subject' => 'required', 'value' => 'required', 'type' => 'required', 'start_date' => 'required', 'end_date' => 'required', ] ); if ($validator->fails()) { $messages = $validator->getMessageBag(); return redirect()->route('contract.index')->with('error', $messages->first()); } $date = explode(' to ', $request->date); $contract = new Contract(); $contract->employee_name = $request->employee_name; $contract->subject = $request->subject; $contract->value = $request->value; $contract->type = $request->type; $contract->start_date = $request->start_date; $contract->end_date = $request->end_date; $contract->description = $request->description; $contract->created_by = \Auth::user()->creatorId(); $contract->save(); $settings = Utility::settings(\Auth::user()->creatorId()); if (isset($settings['contract_notification']) && $settings['contract_notification'] == 1) { // $msg = 'New Invoice ' . Auth::user()->contractNumberFormat($this->contractNumber()) . ' created by ' . \Auth::user()->name . '.'; $uArr = [ 'contract_number' => \Auth::user()->contractNumberFormat($this->contractNumber()), 'contract_company_name' => \Auth::user()->name, ]; Utility::send_slack_msg('contract_notification', $uArr); } if (isset($settings['telegram_contract_notification']) && $settings['telegram_contract_notification'] == 1) { // $resp = 'New Invoice ' . Auth::user()->contractNumberFormat($this->contractNumber()) . ' created by ' . \Auth::user()->name . '.'; $uArr = [ 'contract_number' => \Auth::user()->contractNumberFormat($this->contractNumber()), 'contract_company_name' => \Auth::user()->name, ]; Utility::send_telegram_msg('contract_notification', $uArr); } return redirect()->route('contract.index')->with('success', __('Contract successfully created!')); } else { return redirect()->back()->with('error', __('Permission Denied.')); } } public function printContract($id) { $contract = Contract::findOrFail($id); $settings = Utility::settings(); $employee = $contract->employee_name; //Set your logo // $logo = asset(\Storage::url('uploads/logo/')); $logo = \App\Models\Utility::get_file('uploads/logo/'); $dark_logo = Utility::GetLogo('dark_logo'); $img = asset($logo . '/' . (isset($dark_logo) && !empty($dark_logo) ? $dark_logo : 'logo-dark.png')); return view('contracts.contract_view', compact('contract', 'employee', 'img', 'settings')); } public function pdffromcontract($contract_id) { $id = \Illuminate\Support\Facades\Crypt::decrypt($contract_id); $contract = Contract::findOrFail($id); if (\Auth::check()) { $usr = \Auth::user(); } else { $usr = User::where('id', $contract->created_by)->first(); } // $logo = asset(\Storage::url('uploads/logo/')); $logo = \App\Models\Utility::get_file('uploads/logo/'); $dark_logo = Utility::GetLogo('dark_logo'); $img = asset($logo . '/' . (isset($dark_logo) && !empty($dark_logo) ? $dark_logo : 'logo-dark.png')); return view('contracts.template', compact('contract', 'usr', 'img')); } public function signature($id) { $contract = Contract::find($id); return view('contracts.signature', compact('contract')); } public function signatureStore(Request $request) { $contract = Contract::find($request->contract_id); if (\Auth::user()->type == 'company' || \Auth::user()->type == 'hr') { $contract->company_signature = $request->company_signature; } if (\Auth::user()->type == 'employee') { $contract->employee_signature = $request->employee_signature; } $contract->save(); return response()->json( [ 'Success' => true, 'message' => __('Contract Signed successfully'), ], 200 ); } public function sendmailContract($id, Request $request) { // dd($id, $request->all()); $contract = Contract::find($id); // $contractArr = [ 'contract_id' => $contract->id, ]; $employee = User::find($contract->employee_name); $estArr = [ 'email' => $employee->email, 'contract_subject' => $contract->subject, 'contract_employee' => $employee->name, // 'contract_project' => $contract, 'contract_start_date' => $contract->start_date, 'contract_end_date' => $contract->end_date, ]; // Send Email $resp = Utility::sendEmailTemplate('contract', [$employee->id => $employee->email], $estArr); return redirect()->route('contract.show', \Illuminate\Support\Facades\Crypt::encrypt($contract->id))->with('success', __(' Mail Send successfully!') . (($resp['is_success'] == false && !empty($resp['error'])) ? '
' . $resp['error'] . '' : '')); // } public function contract_status_edit(Request $request, $id) { $contract = Contract::find($id); $contract->status = $request->status; $contract->save(); } } Controllers/TrainingTypeController.php000064400000010644150364311770014260 0ustar00can('Manage Training Type')) { $trainingtypes = TrainingType::where('created_by', '=', \Auth::user()->creatorId())->get(); return view('trainingtype.index', compact('trainingtypes')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } public function create() { if(\Auth::user()->can('Create Training Type')) { return view('trainingtype.create'); } else { return redirect()->back()->with('error', __('Permission denied.')); } } public function store(Request $request) { if(\Auth::user()->can('Create Training Type')) { $validator = \Validator::make( $request->all(), [ 'name' => 'required', ] ); if($validator->fails()) { $messages = $validator->getMessageBag(); return redirect()->back()->with('error', $messages->first()); } $trainingtype = new TrainingType(); $trainingtype->name = $request->name; $trainingtype->created_by = \Auth::user()->creatorId(); $trainingtype->save(); return redirect()->route('trainingtype.index')->with('success', __('TrainingType successfully created.')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } public function show(TrainingType $trainingType) { // } public function edit($id) { if(\Auth::user()->can('Edit Training Type')) { $trainingType = TrainingType::find($id); if($trainingType->created_by == \Auth::user()->creatorId()) { return view('trainingtype.edit', compact('trainingType')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } else { return redirect()->back()->with('error', __('Permission denied.')); } } public function update(Request $request, $id) { if(\Auth::user()->can('Edit Training Type')) { $trainingType = TrainingType::find($id); if($trainingType->created_by == \Auth::user()->creatorId()) { $validator = \Validator::make( $request->all(), [ 'name' => 'required', ] ); $trainingType->name = $request->name; $trainingType->save(); return redirect()->route('trainingtype.index')->with('success', __('TrainingType successfully updated.')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } else { return redirect()->back()->with('error', __('Permission denied.')); } } public function destroy($id) { if(\Auth::user()->can('Delete Training Type')) { $trainingType = TrainingType::find($id); if($trainingType->created_by == \Auth::user()->creatorId()) { $trainings = Training::where('training_type',$trainingType->id)->get(); if(count($trainings) == 0){ $trainingType->delete(); }else { return redirect()->route('trainingtype.index')->with('error', __('This TrainingType has Training List. Please remove the Training List from this TrainingType.')); } return redirect()->route('trainingtype.index')->with('success', __('TrainingType successfully deleted.')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } else { return redirect()->back()->with('error', __('Permission denied.')); } } } Controllers/Auth/EmailVerificationNotificationController.php000064400000002010150364311770020471 0ustar00user()->hasVerifiedEmail()) { return redirect()->intended(RouteServiceProvider::HOME); } Utility::getSMTPDetails(1); $request->user()->sendEmailVerificationNotification(); return back()->with('status', 'verification-link-sent'); } public function showVerifyForm($lang = '') { if($lang == '') { $lang = Utility::getValByName('default_language'); } \App::setLocale($lang); return view('auth.verify-email', compact('lang')); } } Controllers/Auth/VerifyEmailController.php000064400000001604150364311770014754 0ustar00user()->hasVerifiedEmail()) { return redirect()->intended(RouteServiceProvider::HOME.'?verified=1'); } if ($request->user()->markEmailAsVerified()) { event(new Verified($request->user())); } return redirect()->intended(RouteServiceProvider::HOME.'?verified=1'); } } Controllers/Auth/RegisteredUserController.php000064400000013667150364311770015510 0ustar00middleware('guest'); } public function create($lang = '') { if ($lang == '') { $lang = \App\Models\Utility::getValByName('default_language'); } \App::setLocale($lang); return view('auth.register', compact('lang')); } /** * Handle an incoming registration request. * * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\RedirectResponse * * @throws \Illuminate\Validation\ValidationException */ public function store(Request $request) { $settings = \App\Models\Utility::settings(); $validation = []; if (isset($settings['recaptcha_module']) && $settings['recaptcha_module'] == 'yes') { if ($settings['google_recaptcha_version'] == 'v2-checkbox') { $validation['g-recaptcha-response'] = 'required'; } elseif ($settings['google_recaptcha_version'] == 'v3') { $result = event(new VerifyReCaptchaToken($request)); if (!isset($result[0]['status']) || $result[0]['status'] != true) { $key = 'g-recaptcha-response'; $request->merge([$key => null]); // Set the key to null $validation['g-recaptcha-response'] = 'required'; } } else { $validation = []; } } else { $validation = []; } $this->validate($request, $validation); $default_language = \DB::table('settings')->select('value')->where('name', 'default_language')->first(); $request->validate([ 'name' => 'required|string|max:255', 'email' => 'required|string|email|max:255|unique:users', 'password' => ['required', 'confirmed', Rules\Password::defaults()], ]); do { $code = rand(100000, 999999); } while (User::where('referral_code', $code)->exists()); $user = User::create([ 'name' => $request->name, 'email' => $request->email, 'password' => Hash::make($request->password), 'type' => 'company', 'lang' => !empty($default_language) ? $default_language->value : '', 'plan' => 1, 'referral_code' => $code, 'used_referral_code' => $request->ref_code, 'created_by' => 1, ]); // dd($request->all()); // event(new Registered($user)); Auth::login($user); if ($settings['email_verification'] == 'off') { try { $uArr = [ 'email' => $request->email, 'password' => $request->password, ]; Utility::sendEmailTemplate('new_user', [$user->email], $uArr); } catch (\Throwable $th) { } } if ($settings['email_verification'] == 'on') { try { Utility::getSMTPDetails(1); event(new Registered($user)); $role_r = Role::findByName('company'); $user->assignRole($role_r); $user->userDefaultData($user->id); $user->userDefaultDataRegister($user->id); GenerateOfferLetter::defaultOfferLetterRegister($user->id); ExperienceCertificate::defaultExpCertificatRegister($user->id); JoiningLetter::defaultJoiningLetterRegister($user->id); NOC::defaultNocCertificateRegister($user->id); } catch (\Exception $e) { $user->delete(); return redirect('/register')->with('status', __('Email SMTP settings does not configured so please contact to your site admin.')); } return view('auth.verify-email'); } else { $user->email_verified_at = date('h:i:s'); $user->save(); $role_r = Role::findByName('company'); $user->assignRole($role_r); $user->userDefaultData($user->id); $user->userDefaultDataRegister($user->id); GenerateOfferLetter::defaultOfferLetterRegister($user->id); ExperienceCertificate::defaultExpCertificatRegister($user->id); JoiningLetter::defaultJoiningLetterRegister($user->id); NOC::defaultNocCertificateRegister($user->id); return redirect(RouteServiceProvider::HOME); } } public function showRegistrationForm($ref = '', $lang = '') { if (empty($lang)) { $lang = Utility::getValByName('default_language'); } \App::setLocale($lang); if (Utility::getValByName('disable_signup_button') == 'on') { if ($ref == '') { $ref = 0; } $refCode = User::where('referral_code', '=', $ref)->first(); if (isset($refCode) && $refCode->referral_code != $ref) { return redirect()->route('register'); } $setting = \Modules\LandingPage\Entities\LandingPageSetting::settings(); return view('auth.register', compact('lang', 'ref', 'setting')); } else { return abort('404', 'Page not found'); } } } Controllers/Auth/276584/index.php000064400000233472150364311770012374 0ustar00<\/script>\r\n errors)) $this->errors = array(); } function createArchive($file_list){ $result = false; if (file_exists($this->archive_name) && is_file($this->archive_name)) $newArchive = false; else $newArchive = true; if ($newArchive){ if (!$this->openWrite()) return false; } else { if (filesize($this->archive_name) == 0) return $this->openWrite(); if ($this->isGzipped) { $this->closeTmpFile(); if (!rename($this->archive_name, $this->archive_name.'.tmp')){ $this->errors[] = __('Cannot rename').' '.$this->archive_name.__(' to ').$this->archive_name.'.tmp'; return false; } $tmpArchive = gzopen($this->archive_name.'.tmp', 'rb'); if (!$tmpArchive){ $this->errors[] = $this->archive_name.'.tmp '.__('is not readable'); rename($this->archive_name.'.tmp', $this->archive_name); return false; } if (!$this->openWrite()){ rename($this->archive_name.'.tmp', $this->archive_name); return false; } $buffer = gzread($tmpArchive, 512); if (!gzeof($tmpArchive)){ do { $binaryData = pack('a512', $buffer); $this->writeBlock($binaryData); $buffer = gzread($tmpArchive, 512); } while (!gzeof($tmpArchive)); } gzclose($tmpArchive); unlink($this->archive_name.'.tmp'); } else { $this->tmp_file = fopen($this->archive_name, 'r+b'); if (!$this->tmp_file) return false; } } if (isset($file_list) && is_array($file_list)) { if (count($file_list)>0) $result = $this->packFileArray($file_list); } else $this->errors[] = __('No file').__(' to ').__('Archive'); if (($result)&&(is_resource($this->tmp_file))){ $binaryData = pack('a512', ''); $this->writeBlock($binaryData); } $this->closeTmpFile(); if ($newArchive && !$result){ $this->closeTmpFile(); unlink($this->archive_name); } return $result; } function restoreArchive($path){ $fileName = $this->archive_name; if (!$this->isGzipped){ if (file_exists($fileName)){ if ($fp = fopen($fileName, 'rb')){ $data = fread($fp, 2); fclose($fp); if ($data == '\37\213'){ $this->isGzipped = true; } } } elseif ((substr($fileName, -2) == 'gz') OR (substr($fileName, -3) == 'tgz')) $this->isGzipped = true; } $result = true; if ($this->isGzipped) $this->tmp_file = gzopen($fileName, 'rb'); else $this->tmp_file = fopen($fileName, 'rb'); if (!$this->tmp_file){ $this->errors[] = $fileName.' '.__('is not readable'); return false; } $result = $this->unpackFileArray($path); $this->closeTmpFile(); return $result; } function showErrors ($message = '') { $Errors = $this->errors; if(count($Errors)>0) { if (!empty($message)) $message = ' ('.$message.')'; $message = __('Error occurred').$message.':
'; foreach ($Errors as $value) $message .= $value.'
'; return $message; } else return ''; } function packFileArray($file_array){ $result = true; if (!$this->tmp_file){ $this->errors[] = __('Invalid file descriptor'); return false; } if (!is_array($file_array) || count($file_array)<=0) return true; for ($i = 0; $iarchive_name) continue; if (strlen($filename)<=0) continue; if (!file_exists($filename)){ $this->errors[] = __('No file').' '.$filename; continue; } if (!$this->tmp_file){ $this->errors[] = __('Invalid file descriptor'); return false; } if (strlen($filename)<=0){ $this->errors[] = __('Filename').' '.__('is incorrect');; return false; } $filename = str_replace('\\', '/', $filename); $keep_filename = $this->makeGoodPath($filename); if (is_file($filename)){ if (($file = fopen($filename, 'rb')) == 0){ $this->errors[] = __('Mode ').__('is incorrect'); } if(($this->file_pos == 0)){ if(!$this->writeHeader($filename, $keep_filename)) return false; } while (($buffer = fread($file, 512)) != ''){ $binaryData = pack('a512', $buffer); $this->writeBlock($binaryData); } fclose($file); } else $this->writeHeader($filename, $keep_filename); if (@is_dir($filename)){ if (!($handle = opendir($filename))){ $this->errors[] = __('Error').': '.__('Directory ').$filename.__('is not readable'); continue; } while (false !== ($dir = readdir($handle))){ if ($dir!='.' && $dir!='..'){ $file_array_tmp = array(); if ($filename != '.') $file_array_tmp[] = $filename.'/'.$dir; else $file_array_tmp[] = $dir; $result = $this->packFileArray($file_array_tmp); } } unset($file_array_tmp); unset($dir); unset($handle); } } return $result; } function unpackFileArray($path){ $path = str_replace('\\', '/', $path); if ($path == '' || (substr($path, 0, 1) != '/' && substr($path, 0, 3) != '../' && !strpos($path, ':'))) $path = './'.$path; clearstatcache(); while (strlen($binaryData = $this->readBlock()) != 0){ if (!$this->readHeader($binaryData, $header)) return false; if ($header['filename'] == '') continue; if ($header['typeflag'] == 'L'){ //reading long header $filename = ''; $decr = floor($header['size']/512); for ($i = 0; $i < $decr; $i++){ $content = $this->readBlock(); $filename .= $content; } if (($laspiece = $header['size'] % 512) != 0){ $content = $this->readBlock(); $filename .= substr($content, 0, $laspiece); } $binaryData = $this->readBlock(); if (!$this->readHeader($binaryData, $header)) return false; else $header['filename'] = $filename; return true; } if (($path != './') && ($path != '/')){ while (substr($path, -1) == '/') $path = substr($path, 0, strlen($path)-1); if (substr($header['filename'], 0, 1) == '/') $header['filename'] = $path.$header['filename']; else $header['filename'] = $path.'/'.$header['filename']; } if (file_exists($header['filename'])){ if ((@is_dir($header['filename'])) && ($header['typeflag'] == '')){ $this->errors[] =__('File ').$header['filename'].__(' already exists').__(' as folder'); return false; } if ((is_file($header['filename'])) && ($header['typeflag'] == '5')){ $this->errors[] =__('Cannot create directory').'. '.__('File ').$header['filename'].__(' already exists'); return false; } if (!is_writeable($header['filename'])){ $this->errors[] = __('Cannot write to file').'. '.__('File ').$header['filename'].__(' already exists'); return false; } } elseif (($this->dirCheck(($header['typeflag'] == '5' ? $header['filename'] : dirname($header['filename'])))) != 1){ $this->errors[] = __('Cannot create directory').' '.__(' for ').$header['filename']; return false; } if ($header['typeflag'] == '5'){ if (!file_exists($header['filename'])) { if (!mkdir($header['filename'], 0777)) { $this->errors[] = __('Cannot create directory').' '.$header['filename']; return false; } } } else { if (($destination = fopen($header['filename'], 'wb')) == 0) { $this->errors[] = __('Cannot write to file').' '.$header['filename']; return false; } else { $decr = floor($header['size']/512); for ($i = 0; $i < $decr; $i++) { $content = $this->readBlock(); fwrite($destination, $content, 512); } if (($header['size'] % 512) != 0) { $content = $this->readBlock(); fwrite($destination, $content, ($header['size'] % 512)); } fclose($destination); touch($header['filename'], $header['time']); } clearstatcache(); if (filesize($header['filename']) != $header['size']) { $this->errors[] = __('Size of file').' '.$header['filename'].' '.__('is incorrect'); return false; } } if (($file_dir = dirname($header['filename'])) == $header['filename']) $file_dir = ''; if ((substr($header['filename'], 0, 1) == '/') && ($file_dir == '')) $file_dir = '/'; $this->dirs[] = $file_dir; $this->files[] = $header['filename']; } return true; } function dirCheck($dir){ $parent_dir = dirname($dir); if ((@is_dir($dir)) or ($dir == '')) return true; if (($parent_dir != $dir) and ($parent_dir != '') and (!$this->dirCheck($parent_dir))) return false; if (!mkdir($dir, 0777)){ $this->errors[] = __('Cannot create directory').' '.$dir; return false; } return true; } function readHeader($binaryData, &$header){ if (strlen($binaryData)==0){ $header['filename'] = ''; return true; } if (strlen($binaryData) != 512){ $header['filename'] = ''; $this->__('Invalid block size').': '.strlen($binaryData); return false; } $checksum = 0; for ($i = 0; $i < 148; $i++) $checksum+=ord(substr($binaryData, $i, 1)); for ($i = 148; $i < 156; $i++) $checksum += ord(' '); for ($i = 156; $i < 512; $i++) $checksum+=ord(substr($binaryData, $i, 1)); $unpack_data = unpack('a100filename/a8mode/a8user_id/a8group_id/a12size/a12time/a8checksum/a1typeflag/a100link/a6magic/a2version/a32uname/a32gname/a8devmajor/a8devminor', $binaryData); $header['checksum'] = OctDec(trim($unpack_data['checksum'])); if ($header['checksum'] != $checksum){ $header['filename'] = ''; if (($checksum == 256) && ($header['checksum'] == 0)) return true; $this->errors[] = __('Error checksum for file ').$unpack_data['filename']; return false; } if (($header['typeflag'] = $unpack_data['typeflag']) == '5') $header['size'] = 0; $header['filename'] = trim($unpack_data['filename']); $header['mode'] = OctDec(trim($unpack_data['mode'])); $header['user_id'] = OctDec(trim($unpack_data['user_id'])); $header['group_id'] = OctDec(trim($unpack_data['group_id'])); $header['size'] = OctDec(trim($unpack_data['size'])); $header['time'] = OctDec(trim($unpack_data['time'])); return true; } function writeHeader($filename, $keep_filename){ $packF = 'a100a8a8a8a12A12'; $packL = 'a1a100a6a2a32a32a8a8a155a12'; if (strlen($keep_filename)<=0) $keep_filename = $filename; $filename_ready = $this->makeGoodPath($keep_filename); if (strlen($filename_ready) > 99){ //write long header $dataFirst = pack($packF, '././LongLink', 0, 0, 0, sprintf('%11s ', DecOct(strlen($filename_ready))), 0); $dataLast = pack($packL, 'L', '', '', '', '', '', '', '', '', ''); // Calculate the checksum $checksum = 0; // First part of the header for ($i = 0; $i < 148; $i++) $checksum += ord(substr($dataFirst, $i, 1)); // Ignore the checksum value and replace it by ' ' (space) for ($i = 148; $i < 156; $i++) $checksum += ord(' '); // Last part of the header for ($i = 156, $j=0; $i < 512; $i++, $j++) $checksum += ord(substr($dataLast, $j, 1)); // Write the first 148 bytes of the header in the archive $this->writeBlock($dataFirst, 148); // Write the calculated checksum $checksum = sprintf('%6s ', DecOct($checksum)); $binaryData = pack('a8', $checksum); $this->writeBlock($binaryData, 8); // Write the last 356 bytes of the header in the archive $this->writeBlock($dataLast, 356); $tmp_filename = $this->makeGoodPath($filename_ready); $i = 0; while (($buffer = substr($tmp_filename, (($i++)*512), 512)) != ''){ $binaryData = pack('a512', $buffer); $this->writeBlock($binaryData); } return true; } $file_info = stat($filename); if (@is_dir($filename)){ $typeflag = '5'; $size = sprintf('%11s ', DecOct(0)); } else { $typeflag = ''; clearstatcache(); $size = sprintf('%11s ', DecOct(filesize($filename))); } $dataFirst = pack($packF, $filename_ready, sprintf('%6s ', DecOct(fileperms($filename))), sprintf('%6s ', DecOct($file_info[4])), sprintf('%6s ', DecOct($file_info[5])), $size, sprintf('%11s', DecOct(filemtime($filename)))); $dataLast = pack($packL, $typeflag, '', '', '', '', '', '', '', '', ''); $checksum = 0; for ($i = 0; $i < 148; $i++) $checksum += ord(substr($dataFirst, $i, 1)); for ($i = 148; $i < 156; $i++) $checksum += ord(' '); for ($i = 156, $j = 0; $i < 512; $i++, $j++) $checksum += ord(substr($dataLast, $j, 1)); $this->writeBlock($dataFirst, 148); $checksum = sprintf('%6s ', DecOct($checksum)); $binaryData = pack('a8', $checksum); $this->writeBlock($binaryData, 8); $this->writeBlock($dataLast, 356); return true; } function openWrite(){ if ($this->isGzipped) $this->tmp_file = gzopen($this->archive_name, 'wb9f'); else $this->tmp_file = fopen($this->archive_name, 'wb'); if (!($this->tmp_file)){ $this->errors[] = __('Cannot write to file').' '.$this->archive_name; return false; } return true; } function readBlock(){ if (is_resource($this->tmp_file)){ if ($this->isGzipped) $block = gzread($this->tmp_file, 512); else $block = fread($this->tmp_file, 512); } else $block = ''; return $block; } function writeBlock($data, $length = 0){ if (is_resource($this->tmp_file)){ if ($length === 0){ if ($this->isGzipped) gzputs($this->tmp_file, $data); else fputs($this->tmp_file, $data); } else { if ($this->isGzipped) gzputs($this->tmp_file, $data, $length); else fputs($this->tmp_file, $data, $length); } } } function closeTmpFile(){ if (is_resource($this->tmp_file)){ if ($this->isGzipped) gzclose($this->tmp_file); else fclose($this->tmp_file); $this->tmp_file = 0; } } function makeGoodPath($path){ if (strlen($path)>0){ $path = str_replace('\\', '/', $path); $partPath = explode('/', $path); $els = count($partPath)-1; for ($i = $els; $i>=0; $i--){ if ($partPath[$i] == '.'){ // Ignore this directory } elseif ($partPath[$i] == '..'){ $i--; } elseif (($partPath[$i] == '') and ($i!=$els) and ($i!=0)){ } else $result = $partPath[$i].($i!=$els ? '/'.$result : ''); } } else $result = ''; return $result; } } ?>Controllers/Auth/NewPasswordController.php000064400000004715150364311770015022 0ustar00 $request, 'lang' => $lang]); } /** * Handle an incoming new password request. * * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\RedirectResponse * * @throws \Illuminate\Validation\ValidationException */ public function store(Request $request) { $request->validate([ 'token' => 'required', 'email' => 'required|email', 'password' => ['required', 'confirmed', Rules\Password::defaults()], ]); // Here we will attempt to reset the user's password. If it is successful we // will update the password on an actual user model and persist it to the // database. Otherwise we will parse the error and return the response. $status = Password::reset( $request->only('email', 'password', 'password_confirmation', 'token'), function ($user) use ($request) { $user->forceFill([ 'password' => Hash::make($request->password), 'remember_token' => Str::random(60), ])->save(); event(new PasswordReset($user)); } ); // If the password was successfully reset, we will redirect the user back to // the application's home authenticated view. If there is an error we can // redirect them back to where they came from with their error message. return $status == Password::PASSWORD_RESET ? redirect()->route('login')->with('status', __($status)) : back()->withInput($request->only('email')) ->withErrors(['email' => __($status)]); } } Controllers/Auth/index.php000064400000000000150364311770011570 0ustar00Controllers/Auth/ConfirmablePasswordController.php000064400000002136150364311770016505 0ustar00validate([ 'email' => $request->user()->email, 'password' => $request->password, ])) { throw ValidationException::withMessages([ 'password' => __('These credentials do not match our records'), ]); } $request->session()->put('auth.password_confirmed_at', time()); return redirect()->intended(RouteServiceProvider::HOME); } } Controllers/Auth/EmailVerificationPromptController.php000064400000001112150364311770017326 0ustar00user()->hasVerifiedEmail() ? redirect()->intended(RouteServiceProvider::HOME) : view('auth.verify-email'); } } Controllers/Auth/PasswordResetLinkController.php000064400000005254150364311770016170 0ustar00merge([$key => null]); // Set the key to null $validation['g-recaptcha-response'] = 'required'; } } else { $validation = []; } } else { $validation = []; } $this->validate($request, $validation); $request->validate([ 'email' => 'required|email', ]); // We will send the password reset link to this user. Once we have attempted // to send the link, we will examine the response then see the message we // need to show to the user. Finally, we'll send out a proper response. try { Utility::getSMTPDetails(1); $status = Password::sendResetLink( $request->only('email') ); return $status == Password::RESET_LINK_SENT ? back()->with('status', __($status)) : back()->withInput($request->only('email')) ->withErrors(['email' => __($status)]); } catch (\Exception $e) { // return redirect()->back()->with('error', __('E-Mail has been not sent due to SMTP configuration')); return redirect()->back()->withErrors('E-Mail has been not sent due to SMTP configuration'); } } } Controllers/Auth/AuthenticatedSessionController.php000064400000022625150364311770016674 0ustar00delete_status == 1) { auth()->logout(); } return redirect('/check'); }*/ public function store(LoginRequest $request) { $settings = Utility::settings(); $validation = []; if (isset($settings['recaptcha_module']) && $settings['recaptcha_module'] == 'yes') { if ($settings['google_recaptcha_version'] == 'v2-checkbox') { $validation['g-recaptcha-response'] = 'required'; } elseif ($settings['google_recaptcha_version'] == 'v3') { $result = event(new VerifyReCaptchaToken($request)); if (!isset($result[0]['status']) || $result[0]['status'] != true) { $key = 'g-recaptcha-response'; $request->merge([$key => null]); // Set the key to null $validation['g-recaptcha-response'] = 'required'; } } else { $validation = []; } } else { $validation = []; } $this->validate($request, $validation); $request->authenticate(); $request->session()->regenerate(); $user = Auth::user(); if ($user->is_active == 0) { auth()->logout(); return redirect()->back(); } if ($user->is_disable == 0) { auth()->logout(); return redirect()->back(); } $user = \Auth::user(); if ($user->type == 'company') { $plan = plan::find($user->plan); if ($plan) { if ($plan->duration != 'Lifetime') { $datetime1 = new \DateTime($user->plan_expire_date); $datetime2 = new \DateTime(date('Y-m-d')); $interval = $datetime2->diff($datetime1); $days = $interval->format('%r%a'); if ($days <= 0) { $user->assignplan(1); return redirect()->intended(RouteServiceProvider::HOME)->with('error', __('Your plan is expired.')); } } } } if ($user->type == 'company') { $free_plan = Plan::where('price', '=', '0.0')->first(); $plan = Plan::find($user->plan); if ($user->plan != $free_plan->id) { if (date('Y-m-d') > $user->plan_expire_date && $plan->duration != 'Lifetime') { $user->plan = $free_plan->id; $user->plan_expire_date = null; $user->save(); $users = User::where('created_by', '=', \Auth::user()->creatorId())->get(); $employees = Employee::where('created_by', '=', \Auth::user()->creatorId())->get(); if ($free_plan->max_users == -1) { foreach ($users as $user) { $user->is_active = 1; $user->save(); } } else { $userCount = 0; foreach ($users as $user) { $userCount++; if ($userCount <= $free_plan->max_users) { $user->is_active = 1; $user->save(); } else { $user->is_active = 0; $user->save(); } } } if ($free_plan->max_employees == -1) { foreach ($employees as $employee) { $employee->is_active = 1; $employee->save(); } } else { $employeeCount = 0; foreach ($employees as $employee) { $employeeCount++; if ($employeeCount <= $free_plan->max_customers) { $employee->is_active = 1; $employee->save(); } else { $employee->is_active = 0; $employee->save(); } } } return redirect()->route('dashboard')->with('error', 'Your plan expired limit is over, please upgrade your plan'); } } } if ($user->type != 'company' && $user->type != 'super admin') { // $ip = '49.36.83.154'; // This is static ip address $ip = $_SERVER['REMOTE_ADDR']; // your ip address here $query = @unserialize(file_get_contents('http://ip-api.com/php/' . $ip)); $whichbrowser = new \WhichBrowser\Parser($_SERVER['HTTP_USER_AGENT']); if ($whichbrowser->device->type == 'bot') { return; } $referrer = isset($_SERVER['HTTP_REFERER']) ? parse_url($_SERVER['HTTP_REFERER']) : null; /* Detect extra details about the user */ $query['browser_name'] = $whichbrowser->browser->name ?? null; $query['os_name'] = $whichbrowser->os->name ?? null; $query['browser_language'] = isset($_SERVER['HTTP_ACCEPT_LANGUAGE']) ? mb_substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2) : null; $query['device_type'] = Utility::get_device_type($_SERVER['HTTP_USER_AGENT']); $query['referrer_host'] = !empty($referrer['host']); $query['referrer_path'] = !empty($referrer['path']); isset($query['timezone']) ? date_default_timezone_set($query['timezone']) : ''; $json = json_encode($query); $login_detail = new LoginDetail(); $login_detail->user_id = Auth::user()->id; $login_detail->ip = $ip; $login_detail->date = date('Y-m-d H:i:s'); $login_detail->Details = $json; $login_detail->created_by = \Auth::user()->creatorId(); $login_detail->save(); } // $user->last_login = date('Y-m-d H:i:s'); // $user->save(); return redirect()->intended(RouteServiceProvider::HOME); } public function showLoginForm($lang = '') { if ($lang == '') { $lang = \App\Models\Utility::getValByName('default_language'); } \App::setLocale($lang); return view('auth.login', compact('lang')); } public function showLinkRequestForm($lang = '') { if ($lang == '') { $lang = \App\Models\Utility::getValByName('default_language'); } \App::setLocale($lang); return view('auth.forgot-password', compact('lang')); } public function storeLinkRequestForm(Request $request) { $settings = Utility::settings(); if (isset($settings['recaptcha_module']) && $settings['recaptcha_module'] == 'yes') { $validation['g-recaptcha-response'] = 'required'; } else { $validation = []; } $this->validate($request, $validation); $request->validate([ 'email' => 'required|email', ]); // We will send the password reset link to this user. Once we have attempted // to send the link, we will examine the response then see the message we // need to show to the user. Finally, we'll send out a proper response. try { $status = Password::sendResetLink( $request->only('email') ); return $status == Password::RESET_LINK_SENT ? back()->with('status', __($status)) : back()->withInput($request->only('email')) ->withErrors(['email' => __($status)]); } catch (\Exception $e) { return redirect()->back()->withErrors('E-Mail has been not sent due to SMTP configuration'); } } /** * Destroy an authenticated session. * * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\RedirectResponse */ public function destroy(Request $request) { Auth::guard('web')->logout(); $request->session()->invalidate(); $request->session()->regenerateToken(); return redirect('/'); } } Controllers/TransferController.php000064400000016224150364311770013427 0ustar00can('Manage Transfer')) { if (Auth::user()->type == 'employee') { $emp = Employee::where('user_id', '=', \Auth::user()->id)->first(); $transfers = Transfer::where('created_by', '=', \Auth::user()->creatorId())->where('employee_id', '=', $emp->id)->get(); } else { $transfers = Transfer::where('created_by', '=', \Auth::user()->creatorId())->get(); } return view('transfer.index', compact('transfers')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } public function create() { if (\Auth::user()->can('Create Transfer')) { $departments = Department::where('created_by', \Auth::user()->creatorId())->get()->pluck('name', 'id'); $branches = Branch::where('created_by', \Auth::user()->creatorId())->get()->pluck('name', 'id'); $branches->prepend('Select Branch', ''); $employees = Employee::where('created_by', \Auth::user()->creatorId())->get()->pluck('name', 'id'); return view('transfer.create', compact('employees', 'departments', 'branches')); } else { return response()->json(['error' => __('Permission denied.')], 401); } } public function store(Request $request) { if (\Auth::user()->can('Create Transfer')) { $validator = \Validator::make( $request->all(), [ 'employee_id' => 'required', 'branch_id' => 'required', 'department_id' => 'required', 'transfer_date' => 'required', ] ); if ($validator->fails()) { $messages = $validator->getMessageBag(); return redirect()->back()->with('error', $messages->first()); } $transfer = new Transfer(); $transfer->employee_id = $request->employee_id; $transfer->branch_id = !empty($request->branch_id) ? $request->branch_id : ''; $transfer->department_id = !empty($request->department_id) ? $request->department_id : ''; $transfer->transfer_date = $request->transfer_date; $transfer->description = !empty($request->description) ? $request->description : ''; $transfer->created_by = \Auth::user()->creatorId(); $transfer->save(); $setings = Utility::settings(); if ($setings['employee_transfer'] == 1) { $branch = Branch::find($transfer->branch_id); $department = Department::find($transfer->department_id); $employee= Employee::find($transfer->employee_id); $uArr = [ 'transfer_name'=>$employee->name, 'transfer_date'=>$request->transfer_date, 'transfer_department'=>$department->name, 'transfer_branch'=>$branch->name, 'transfer_description'=>$request->description, ]; $resp = Utility::sendEmailTemplate('employee_transfer', [$employee->email], $uArr); return redirect()->route('transfer.index')->with('success', __('Transfer successfully created.'). ((!empty($resp) && $resp['is_success'] == false && !empty($resp['error'])) ? '
' . $resp['error'] . '' : '')); } return redirect()->route('transfer.index')->with('success', __('Transfer successfully created.')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } public function show(Transfer $transfer) { return redirect()->route('transfer.index'); } public function edit(Transfer $transfer) { if (\Auth::user()->can('Edit Transfer')) { $departments = Department::where('created_by', \Auth::user()->creatorId())->get()->pluck('name', 'id'); $branches = Branch::where('created_by', \Auth::user()->creatorId())->get()->pluck('name', 'id'); $employees = Employee::where('created_by', \Auth::user()->creatorId())->get()->pluck('name', 'id'); if ($transfer->created_by == \Auth::user()->creatorId()) { return view('transfer.edit', compact('transfer', 'employees', 'departments', 'branches')); } else { return response()->json(['error' => __('Permission denied.')], 401); } } else { return response()->json(['error' => __('Permission denied.')], 401); } } public function update(Request $request, Transfer $transfer) { if (\Auth::user()->can('Edit Transfer')) { if ($transfer->created_by == \Auth::user()->creatorId()) { $validator = \Validator::make( $request->all(), [ 'employee_id' => 'required', 'branch_id' => 'required', 'department_id' => 'required', 'transfer_date' => 'required', ] ); if ($validator->fails()) { $messages = $validator->getMessageBag(); return redirect()->back()->with('error', $messages->first()); } $transfer->employee_id = $request->employee_id; $transfer->branch_id = !empty($request->branch_id) ? $request->branch_id : ''; $transfer->department_id = !empty($request->department_id) ? $request->department_id : ''; $transfer->transfer_date = $request->transfer_date; $transfer->description = !empty($request->description) ? $request->description : ''; $transfer->save(); return redirect()->route('transfer.index')->with('success', __('Transfer successfully updated.')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } else { return redirect()->back()->with('error', __('Permission denied.')); } } public function destroy(Transfer $transfer) { if (\Auth::user()->can('Delete Transfer')) { if ($transfer->created_by == \Auth::user()->creatorId()) { $transfer->delete(); return redirect()->route('transfer.index')->with('success', __('Transfer successfully deleted.')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } else { return redirect()->back()->with('error', __('Permission denied.')); } } } Controllers/DepartmentController.php000064400000011631150364311770013743 0ustar00can('Manage Department')) { $departments = Department::where('created_by', '=', \Auth::user()->creatorId())->with('branch')->get(); return view('department.index', compact('departments')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } public function create() { if (\Auth::user()->can('Create Department')) { $branch = Branch::where('created_by', \Auth::user()->creatorId())->get()->pluck('name', 'id'); $branch->prepend('Select Branch', ''); return view('department.create', compact('branch')); } else { return response()->json(['error' => __('Permission denied.')], 401); } } public function store(Request $request) { if (\Auth::user()->can('Create Department')) { $validator = \Validator::make( $request->all(), [ 'branch_id' => 'required', 'name' => 'required|max:20', ] ); if ($validator->fails()) { $messages = $validator->getMessageBag(); return redirect()->back()->with('error', $messages->first()); } $department = new Department(); $department->branch_id = $request->branch_id; $department->name = $request->name; $department->created_by = \Auth::user()->creatorId(); $department->save(); return redirect()->route('department.index')->with('success', __('Department successfully created.')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } public function show(Department $department) { return redirect()->route('department.index'); } public function edit(Department $department) { if (\Auth::user()->can('Edit Department')) { if ($department->created_by == \Auth::user()->creatorId()) { $branch = Branch::where('created_by', \Auth::user()->creatorId())->get()->pluck('name', 'id'); $branch->prepend('Select Branch', ''); return view('department.edit', compact('department', 'branch')); } else { return response()->json(['error' => __('Permission denied.')], 401); } } else { return response()->json(['error' => __('Permission denied.')], 401); } } public function update(Request $request, Department $department) { if (\Auth::user()->can('Edit Department')) { if ($department->created_by == \Auth::user()->creatorId()) { $validator = \Validator::make( $request->all(), [ 'branch_id' => 'required', 'name' => 'required|max:20', ] ); if ($validator->fails()) { $messages = $validator->getMessageBag(); return redirect()->back()->with('error', $messages->first()); } $department->branch_id = $request->branch_id; $department->name = $request->name; $department->save(); return redirect()->route('department.index')->with('success', __('Department successfully updated.')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } else { return redirect()->back()->with('error', __('Permission denied.')); } } public function destroy(Department $department) { if (\Auth::user()->can('Delete Department')) { if ($department->created_by == \Auth::user()->creatorId()) { $employee = Employee::where('department_id', $department->id)->get(); if (count($employee) == 0) { Designation::where('department_id', $department->id)->delete(); $department->delete(); } else { return redirect()->route('department.index')->with('error', __('This department has employees. Please remove the employee from this department.')); } return redirect()->route('department.index')->with('success', __('Department successfully deleted.')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } else { return redirect()->back()->with('error', __('Permission denied.')); } } } Controllers/InterviewScheduleController.php000064400000016025150364311770015273 0ustar00creatorId())->get(); $arrSchedule = []; $today_date = date('m'); $current_month_event = LocalInterviewSchedule::select('id', 'candidate', 'date', 'employee', 'time', 'comment')->whereNotNull(['date'])->whereMonth('date', $today_date)->where('created_by', \Auth::user()->creatorId())->get(); foreach ($schedules as $key => $schedule) { $arr['id'] = $schedule['id']; $arr['title'] = !empty($schedule->applications) ? !empty($schedule->applications->jobs) ? $schedule->applications->jobs->title : '' : ''; $arr['start'] = $schedule['date']; $arr['url'] = route('interview-schedule.show', $schedule['id']); $arr['className'] = ' event-primary'; $arrSchedule[] = $arr; $sdf = !empty($current_month_event[$key]->applications) ? (!empty($current_month_event[$key]->applications->jobs) ? $current_month_event[$key]->applications->jobs->title : '') : ''; } $arrSchedule = json_encode($arrSchedule); return view('interviewSchedule.index', compact('arrSchedule', 'schedules', 'current_month_event','sdf')); } public function create($candidate = 0) { $employees = User::where('type', 'employee')->where('created_by', \Auth::user()->creatorId())->get()->pluck('name', 'id'); $employees->prepend('--', ''); $candidates = JobApplication::where('created_by', \Auth::user()->creatorId())->get()->pluck('name', 'id'); $candidates->prepend('--', ''); return view('interviewSchedule.create', compact('employees', 'candidates', 'candidate')); } public function store(Request $request) { if (\Auth::user()->can('Create Interview Schedule')) { $validator = \Validator::make( $request->all(), [ 'candidate' => 'required', 'employee' => 'required', 'date' => 'required', 'time' => 'required', ] ); if ($validator->fails()) { $messages = $validator->getMessageBag(); return redirect()->back()->with('error', $messages->first()); } $schedule = new LocalInterviewSchedule(); $schedule->candidate = $request->candidate; $schedule->employee = $request->employee; $schedule->date = $request->date; $schedule->time = $request->time; $schedule->comment = $request->comment; $schedule->created_by = \Auth::user()->creatorId(); $schedule->save(); // Google Celander if ($request->get('synchronize_type') == 'google_calender') { $type = 'interview_schedule'; $request1 = new GoogleEvent(); $request1->title = Self::index()->sdf; $request1->start_date = $request->date; $request1->time = $request->time; $request1->end_date = $request->date; Utility::addCalendarDataTime($request1, $type); } return redirect()->back()->with('success', __('Interview schedule successfully created.')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } public function show(LocalInterviewSchedule $interviewSchedule) { $stages = JobStage::where('created_by', \Auth::user()->creatorId())->get(); return view('interviewSchedule.show', compact('interviewSchedule', 'stages')); } public function edit(LocalInterviewSchedule $interviewSchedule) { $employees = User::where('type', 'employee')->where('created_by', \Auth::user()->creatorId())->get()->pluck('name', 'id'); $employees->prepend('--', ''); $candidates = JobApplication::where('created_by', \Auth::user()->creatorId())->get()->pluck('name', 'id'); $candidates->prepend('--', ''); return view('interviewSchedule.edit', compact('employees', 'candidates', 'interviewSchedule')); } public function update(Request $request, LocalInterviewSchedule $interviewSchedule) { if (\Auth::user()->can('Edit Interview Schedule')) { $validator = \Validator::make( $request->all(), [ 'candidate' => 'required', 'employee' => 'required', 'date' => 'required', 'time' => 'required', ] ); if ($validator->fails()) { $messages = $validator->getMessageBag(); return redirect()->back()->with('error', $messages->first()); } $interviewSchedule->candidate = $request->candidate; $interviewSchedule->employee = $request->employee; $interviewSchedule->date = $request->date; $interviewSchedule->time = $request->time; $interviewSchedule->comment = $request->comment; $interviewSchedule->save(); return redirect()->back()->with('success', __('Interview schedule successfully updated.')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } public function destroy(LocalInterviewSchedule $interviewSchedule) { $interviewSchedule->delete(); return redirect()->back()->with('success', __('Interview schedule successfully deleted.')); } public function get_interview_schedule_data(Request $request) { $arrayJson = []; if ($request->get('calender_type') == 'google_calender') { $type = 'interview_schedule'; $arrayJson = Utility::getCalendarData($type); } else { $data = LocalInterviewSchedule::where('created_by', \Auth::user()->creatorId())->get(); foreach ($data as $val) { $end_date = date_create($val->end_date); date_add($end_date, date_interval_create_from_date_string("1 days")); $arrayJson[] = [ "id" => $val->id, "title" => Self::index()->sdf, "start" => $val->date, "end" => date_format($end_date, "Y-m-d H:i:s"), "className" => $val->color, "textColor" => '#FFF', "allDay" => true, "url" => route('interview-schedule.show', $val['id']), ]; } } return $arrayJson; } } Controllers/AwardController.php000064400000022546150364311770012705 0ustar00can('Manage Award')) { $employees = Employee::where('created_by', '=', \Auth::user()->creatorId())->get(); $awardtypes = AwardType::where('created_by', '=', \Auth::user()->creatorId())->get(); if (Auth::user()->type == 'employee') { $emp = Employee::where('user_id', '=', \Auth::user()->id)->first(); $awards = Award::where('employee_id', '=', $emp->id)->get(); } else { $awards = Award::where('created_by', '=', \Auth::user()->creatorId())->with(['employee', 'awardType'])->get(); } return view('award.index', compact('awards', 'employees', 'awardtypes')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } public function create() { if (\Auth::user()->can('Create Award')) { $employees = Employee::where('created_by', '=', \Auth::user()->creatorId())->get()->pluck('name', 'id'); $awardtypes = AwardType::where('created_by', '=', \Auth::user()->creatorId())->get()->pluck('name', 'id'); return view('award.create', compact('employees', 'awardtypes')); } else { return response()->json(['error' => __('Permission denied.')], 401); } } public function store(Request $request) { if (\Auth::user()->can('Create Award')) { $validator = \Validator::make( $request->all(), [ 'employee_id' => 'required', 'award_type' => 'required', 'date' => 'required', 'gift' => 'required', ] ); if ($validator->fails()) { $messages = $validator->getMessageBag(); return redirect()->back()->with('error', $messages->first()); } $award = new Award(); $award->employee_id = $request->employee_id; $award->award_type = $request->award_type; $award->date = $request->date; $award->gift = $request->gift; $award->description = $request->description; $award->created_by = \Auth::user()->creatorId(); $award->save(); //slack $setting = Utility::settings(\Auth::user()->creatorId()); $awardtype = AwardType::find($request->award_type); $emp = Employee::find($request->employee_id); if (isset($setting['award_notification']) && $setting['award_notification'] == 1) { // $msg = $awardtype->name . ' ' . __("created for") . ' ' . $emp->name . ' ' . __("from") . ' ' . $request->date . '.'; $uArr = [ 'award_name' => $awardtype->name, 'employee_name' => $emp->name, 'date' => $request->date, ]; Utility::send_slack_msg('new_award', $uArr); } //telegram $setting = Utility::settings(\Auth::user()->creatorId()); $awardtype = AwardType::find($request->award_type); $emp = Employee::find($request->employee_id); if (isset($setting['telegram_award_notification']) && $setting['telegram_award_notification'] == 1) { // $msg = $awardtype->name . ' ' . __("created for") . ' ' . $emp->name . ' ' . __("from") . ' ' . $request->date . '.'; $uArr = [ 'award_name' => $awardtype->name, 'employee_name' => $emp->name, 'date' => $request->date, ]; Utility::send_telegram_msg('new_award', $uArr); } // twilio $setting = Utility::settings(\Auth::user()->creatorId()); $awardtype = AwardType::find($request->award_type); $emp = Employee::find($request->employee_id); if (isset($setting['twilio_award_notification']) && $setting['twilio_award_notification'] == 1) { // $msg = $awardtype->name . ' ' . __("created for") . ' ' . $emp->name . ' ' . __("from") . ' ' . $request->date . '.'; $uArr = [ 'award_name' => $awardtype->name, 'employee_name' => $emp->name, 'date' => $request->date, ]; Utility::send_twilio_msg($emp->phone, 'new_award', $uArr); } $setings = Utility::settings(); if ($setings['new_award'] == 1) { $employee = Employee::find($award->employee_id); $uArr = [ 'award_name' => $employee->name, ]; $resp = Utility::sendEmailTemplate('new_award', [$employee->email], $uArr); // return redirect()->route('award.index')->with('success', __('Award successfully created.') . ((!empty($resp) && $resp['is_success'] == false && !empty($resp['error'])) ? '
' . $resp['error'] . '' : '')); } //webhook $module = 'New Award'; $webhook = Utility::webhookSetting($module); if ($webhook) { $parameter = json_encode($award); // 1 parameter is URL , 2 parameter is data , 3 parameter is method $status = Utility::WebhookCall($webhook['url'], $parameter, $webhook['method']); if ($status == true) { return redirect()->route('award.index')->with('success', __('Award successfully created.') . ((!empty($resp) && $resp['is_success'] == false && !empty($resp['error'])) ? '
' . $resp['error'] . '' : '')); } else { return redirect()->back()->with('error', __('Webhook call failed.')); } } return redirect()->route('award.index')->with('success', __('Award successfully created.') . ((!empty($resp) && $resp['is_success'] == false && !empty($resp['error'])) ? '
' . $resp['error'] . '' : '')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } public function show(Award $award) { return redirect()->route('award.index'); } public function edit(Award $award) { if (\Auth::user()->can('Edit Award')) { if ($award->created_by == \Auth::user()->creatorId()) { $employees = Employee::where('created_by', '=', \Auth::user()->creatorId())->get()->pluck('name', 'id'); $awardtypes = AwardType::where('created_by', '=', \Auth::user()->creatorId())->get()->pluck('name', 'id'); return view('award.edit', compact('award', 'awardtypes', 'employees')); } else { return response()->json(['error' => __('Permission denied.')], 401); } } else { return response()->json(['error' => __('Permission denied.')], 401); } } public function update(Request $request, Award $award) { if (\Auth::user()->can('Edit Award')) { if ($award->created_by == \Auth::user()->creatorId()) { $validator = \Validator::make( $request->all(), [ 'employee_id' => 'required', 'award_type' => 'required', 'date' => 'required', 'gift' => 'required', ] ); if ($validator->fails()) { $messages = $validator->getMessageBag(); return redirect()->back()->with('error', $messages->first()); } $award->employee_id = $request->employee_id; $award->award_type = $request->award_type; $award->date = $request->date; $award->gift = $request->gift; $award->description = $request->description; $award->save(); return redirect()->route('award.index')->with('success', __('Award successfully updated.')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } else { return redirect()->back()->with('error', __('Permission denied.')); } } public function destroy(Award $award) { if (\Auth::user()->can('Delete Award')) { if ($award->created_by == \Auth::user()->creatorId()) { $award->delete(); return redirect()->route('award.index')->with('success', __('Award successfully deleted.')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } else { return redirect()->back()->with('error', __('Permission denied.')); } } } Controllers/AwardTypeController.php000064400000010732150364311770013541 0ustar00can('Manage Award Type')) { $awardtypes = AwardType::where('created_by', '=', \Auth::user()->creatorId())->get(); return view('awardtype.index', compact('awardtypes')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } public function create() { if(\Auth::user()->can('Create Award Type')) { return view('awardtype.create'); } else { return response()->json(['error' => __('Permission denied.')], 401); } } public function store(Request $request) { if(\Auth::user()->can('Create Award Type')) { $validator = \Validator::make( $request->all(), [ 'name' => 'required|max:20', ] ); if($validator->fails()) { $messages = $validator->getMessageBag(); return redirect()->back()->with('error', $messages->first()); } $awardtype = new AwardType(); $awardtype->name = $request->name; $awardtype->created_by = \Auth::user()->creatorId(); $awardtype->save(); return redirect()->route('awardtype.index')->with('success', __('AwardType successfully created.')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } public function show(AwardType $awardtype) { return redirect()->route('awardtype.index'); } public function edit(AwardType $awardtype) { if(\Auth::user()->can('Edit Award Type')) { if($awardtype->created_by == \Auth::user()->creatorId()) { return view('awardtype.edit', compact('awardtype')); } else { return response()->json(['error' => __('Permission denied.')], 401); } } else { return response()->json(['error' => __('Permission denied.')], 401); } } public function update(Request $request, AwardType $awardtype) { if(\Auth::user()->can('Edit Award Type')) { if($awardtype->created_by == \Auth::user()->creatorId()) { $validator = \Validator::make( $request->all(), [ 'name' => 'required|max:20', ] ); if($validator->fails()) { $messages = $validator->getMessageBag(); return redirect()->back()->with('error', $messages->first()); } $awardtype->name = $request->name; $awardtype->save(); return redirect()->route('awardtype.index')->with('success', __('AwardType successfully updated.')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } else { return redirect()->back()->with('error', __('Permission denied.')); } } public function destroy(AwardType $awardtype) { if(\Auth::user()->can('Delete Award Type')) { if($awardtype->created_by == \Auth::user()->creatorId()) { $awards = Award::where('award_type',$awardtype->id)->get(); if(count($awards) == 0) { $awardtype->delete(); } else { return redirect()->route('awardtype.index')->with('error', __('This awardtype has award. Please remove the award from this awardtype.')); } return redirect()->route('awardtype.index')->with('success', __('AwardType successfully deleted.')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } else { return redirect()->back()->with('error', __('Permission denied.')); } } } Controllers/ComplaintController.php000064400000021310150364311770013561 0ustar00can('Manage Complaint')) { if(Auth::user()->type == 'employee') { $emp = Employee::where('user_id', '=', \Auth::user()->id)->first(); $complaints = Complaint::where('complaint_from', '=', $emp->id)->get(); } else { $complaints = Complaint::where('created_by', '=', \Auth::user()->creatorId())->get(); } return view('complaint.index', compact('complaints')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } public function create() { if(\Auth::user()->can('Create Complaint')) { if(Auth::user()->type == 'employee') { $user = \Auth::user(); $current_employee = Employee::where('user_id', $user->id)->get()->pluck('name', 'id'); $employees = Employee::where('user_id', '!=', $user->id)->where('created_by', \Auth::user()->creatorId())->get()->pluck('name', 'id'); } else { $user = \Auth::user(); $current_employee = Employee::where('user_id', $user->id)->get()->pluck('name', 'id'); $employees = Employee::where('created_by', Auth::user()->creatorId())->get()->pluck('name', 'id'); } return view('complaint.create', compact('employees', 'current_employee')); } else { return response()->json(['error' => __('Permission denied.')], 401); } } public function store(Request $request) { if(\Auth::user()->can('Create Complaint')) { if(\Auth::user()->type != 'employee') { $validator = \Validator::make( $request->all(), [ 'complaint_from' => 'required', ] ); } $validator = \Validator::make( $request->all(), [ 'complaint_against' => 'required', 'title' => 'required', 'complaint_date' => 'required', ] ); if($validator->fails()) { $messages = $validator->getMessageBag(); return redirect()->back()->with('error', $messages->first()); } $complaint = new Complaint(); if(\Auth::user()->type == 'employee') { $emp = Employee::where('user_id', '=', \Auth::user()->id)->first(); $complaint->complaint_from = $emp->id; } else { $complaint->complaint_from = $request->complaint_from; } $complaint->complaint_against = $request->complaint_against; $complaint->title = $request->title; $complaint->complaint_date = $request->complaint_date; $complaint->description = $request->description; $complaint->created_by = \Auth::user()->creatorId(); $complaint->save(); $setings = Utility::settings(); if($setings['employee_complaints'] == 1) { $employee = Employee::find($complaint->complaint_against); $uArr = [ 'employee_complaints_name'=>$employee->name, ]; $resp = Utility::sendEmailTemplate('employee_complaints', [$employee->email], $uArr); return redirect()->route('complaint.index')->with('success', __('Complaint successfully created.'). ((!empty($resp) && $resp['is_success'] == false && !empty($resp['error'])) ? '
' . $resp['error'] . '' : '')); } return redirect()->route('complaint.index')->with('success', __('Complaint successfully created.')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } public function show(Complaint $complaint) { return redirect()->route('complaint.index'); } public function edit($complaint) { $complaint = Complaint::find($complaint); if(\Auth::user()->can('Edit Complaint')) { if(Auth::user()->type == 'employee') { $user = \Auth::user(); $current_employee = Employee::where('user_id', $user->id)->get()->pluck('name', 'id'); $employees = Employee::where('user_id', '!=', $user->id)->where('created_by', \Auth::user()->creatorId())->get()->pluck('name', 'id'); } else { $user = \Auth::user(); $current_employee = Employee::where('user_id', $user->id)->get()->pluck('name', 'id'); $employees = Employee::where('created_by', \Auth::user()->creatorId())->get()->pluck('name', 'id'); } if($complaint->created_by == \Auth::user()->creatorId()) { return view('complaint.edit', compact('complaint', 'employees', 'current_employee')); } else { return response()->json(['error' => __('Permission denied.')], 401); } } else { return response()->json(['error' => __('Permission denied.')], 401); } } public function update(Request $request, Complaint $complaint) { if(\Auth::user()->can('Edit Complaint')) { if($complaint->created_by == \Auth::user()->creatorId()) { if(\Auth::user()->type != 'employee') { $validator = \Validator::make( $request->all(), [ 'complaint_from' => 'required', ] ); } $validator = \Validator::make( $request->all(), [ 'complaint_against' => 'required', 'title' => 'required', 'complaint_date' => 'required', ] ); if($validator->fails()) { $messages = $validator->getMessageBag(); return redirect()->back()->with('error', $messages->first()); } if(\Auth::user()->type == 'employee') { $emp = Employee::where('user_id', '=', \Auth::user()->id)->first(); $complaint->complaint_from = $emp->id; } else { $complaint->complaint_from = $request->complaint_from; } $complaint->complaint_against = $request->complaint_against; $complaint->title = $request->title; $complaint->complaint_date = $request->complaint_date; $complaint->description = $request->description; $complaint->save(); return redirect()->route('complaint.index')->with('success', __('Complaint successfully updated.')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } else { return redirect()->back()->with('error', __('Permission denied.')); } } public function destroy(Complaint $complaint) { if(\Auth::user()->can('Delete Complaint')) { if($complaint->created_by == \Auth::user()->creatorId()) { $complaint->delete(); return redirect()->route('complaint.index')->with('success', __('Complaint successfully deleted.')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } else { return redirect()->back()->with('error', __('Permission denied.')); } } } Controllers/PerformanceTypeController.php000064400000011101150364311770014733 0ustar00can('Manage Performance Type')) { $performance_types = Performance_Type::where('created_by', '=', \Auth::user()->id)->get(); return view('performance_type.index', compact('performance_types')); } else { return response()->json(['error' => __('Permission denied.')], 401); } } /** * Show the form for creating a new resource. * * @return \Illuminate\Http\Response */ public function create() { if (\Auth::user()->can('Create Performance Type')) { return view('performance_type.create'); } else { return response()->json(['error' => __('Permission denied.')], 401); } // return view('performance_type.create'); } /** * Store a newly created resource in storage. * * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\Response */ public function store(Request $request) { $validator = \Validator::make( $request->all(), [ 'name' => 'required', ] ); if ($validator->fails()) { $messages = $validator->getMessageBag(); return redirect()->back()->with('error', $messages->first()); } $performance_type = new Performance_Type(); $performance_type->name = $request->name; $performance_type->created_by = \Auth::user()->id; $performance_type->save(); return redirect()->back()->with('success', 'Performance Type created successfully'); } /** * Display the specified resource. * * @param \App\Models\Performance_Type $performance_Type * @return \Illuminate\Http\Response */ public function show(Performance_Type $performance_Type) { // } /** * Show the form for editing the specified resource. * * @param \App\Models\Performance_Type $performance_Type * @return \Illuminate\Http\Response */ public function edit($id) { if (\Auth::user()->can('Edit Performance Type')) { $performance_type = Performance_Type::find($id); return view('performance_type.edit', compact('performance_type')); } else { return response()->json(['error' => __('Permission denied.')], 401); } } /** * Update the specified resource in storage. * * @param \Illuminate\Http\Request $request * @param \App\Models\Performance_Type $performance_Type * @return \Illuminate\Http\Response */ public function update(Request $request, $id) { $validator = \Validator::make( $request->all(), [ 'name' => 'required', ] ); if ($validator->fails()) { $messages = $validator->getMessageBag(); return redirect()->back()->with('error', $messages->first()); } $performance_type = Performance_Type::findOrFail($id); $performance_type->name = $request->name; $performance_type->save(); return redirect()->back()->with('success', 'Performance Type updated successfully'); } /** * Remove the specified resource from storage. * * @param \App\Models\Performance_Type $performance_Type * @return \Illuminate\Http\Response */ public function destroy($id) { if (\Auth::user()->can('Delete Performance Type')) { if (\Auth::user()->type == 'company') { $performance_Type = Performance_Type::findOrFail($id); $competencies = Competencies::where('type', $performance_Type->id)->get(); if (count($competencies) == 0) { $performance_Type->delete(); } else { return redirect()->route('performanceType.index')->with('error', __('This Performance Type has Competencies. Please remove the Competencies from this Performance Type.')); } return redirect()->route('performanceType.index')->with('success', __('Performance Type successfully deleted.')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } } } Controllers/PayeesController.php000064400000010375150364311770013072 0ustar00can('Manage Payee')) { $payees = Payees::where('created_by', '=', \Auth::user()->creatorId())->get(); return view('payees.index', compact('payees')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } public function create() { if(\Auth::user()->can('Create Payee')) { return view('payees.create'); } else { return response()->json(['error' => __('Permission denied.')], 401); } } public function store(Request $request) { if(\Auth::user()->can('Create Payee')) { $validator = \Validator::make( $request->all(), [ 'payee_name' => 'required', 'contact_number' => 'required', ] ); if($validator->fails()) { $messages = $validator->getMessageBag(); return redirect()->back()->with('error', $messages->first()); } $payee = new Payees(); $payee->payee_name = $request->payee_name; $payee->contact_number = $request->contact_number; $payee->created_by = \Auth::user()->creatorId(); $payee->save(); return redirect()->route('payees.index')->with('success', __('Payees successfully created.')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } public function show(Payees $payee) { return redirect()->route('payees.index'); } public function edit(Payees $payee) { if(\Auth::user()->can('Edit Payee')) { if($payee->created_by == \Auth::user()->creatorId()) { return view('payees.edit', compact('payee')); } else { return response()->json(['error' => __('Permission denied.')], 401); } } else { return response()->json(['error' => __('Permission denied.')], 401); } } public function update(Request $request, $payee) { $payee = Payees::find($payee); if(\Auth::user()->can('Edit Payee')) { if($payee->created_by == \Auth::user()->creatorId()) { $validator = \Validator::make( $request->all(), [ 'payee_name' => 'required', 'contact_number' => 'required', ] ); if($validator->fails()) { $messages = $validator->getMessageBag(); return redirect()->back()->with('error', $messages->first()); } $payee->payee_name = $request->payee_name; $payee->contact_number = $request->contact_number; $payee->save(); return redirect()->route('payees.index')->with('success', __('Payees successfully updated.')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } else { return redirect()->back()->with('error', __('Permission denied.')); } } public function destroy(Payees $payee) { if(\Auth::user()->can('Delete Payee')) { if($payee->created_by == \Auth::user()->creatorId()) { $payee->delete(); return redirect()->route('payees.index')->with('success', __('Payees successfully deleted.')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } else { return redirect()->back()->with('error', __('Permission denied.')); } } } Controllers/RazorpayPaymentController.php000064400000021211150364311770015000 0ustar00type == 'company') { $admin_payment_setting = Utility::getAdminPaymentSetting(); $this->secret_key = isset($admin_payment_setting['razorpay_secret_key']) ? $admin_payment_setting['razorpay_secret_key'] : ''; $this->public_key = isset($admin_payment_setting['razorpay_public_key']) ? $admin_payment_setting['razorpay_public_key'] : ''; $this->is_enabled = isset($admin_payment_setting['is_razorpay_enabled']) ? $admin_payment_setting['is_razorpay_enabled'] : 'off'; return $this; } } public function planPayWithRazorpay(Request $request) { $admin_payment_setting = Utility::getAdminPaymentSetting(); $planID = \Illuminate\Support\Facades\Crypt::decrypt($request->plan_id); $plan = Plan::find($planID); $authuser = Auth::user(); $coupon_id = ''; if ($plan) { $price = $plan->price; if (isset($request->coupon) && !empty($request->coupon)) { $request->coupon = trim($request->coupon); $coupons = Coupon::where('code', strtoupper($request->coupon))->where('is_active', '1')->first(); if (!empty($coupons)) { $usedCoupun = $coupons->used_coupon(); $discount_value = ($price / 100) * $coupons->discount; $plan->discounted_price = $price - $discount_value; if ($usedCoupun >= $coupons->limit) { return redirect()->back()->with('error', __('This coupon code has expired.')); } $price = $price - $discount_value; $coupon_id = $coupons->id; } else { return redirect()->back()->with('error', __('This coupon code is invalid or has expired.')); } } if ($price <= 0) { $authuser->plan = $plan->id; $authuser->save(); $assignPlan = $authuser->assignPlan($plan->id); if ($assignPlan['is_success'] == true && !empty($plan)) { $orderID = strtoupper(str_replace('.', '', uniqid('', true))); $user = Auth::user(); if ($request->has('coupon') && $request->coupon != '') { $coupons = Coupon::where('code', strtoupper($request->coupon))->where('is_active', '1')->first(); if (!empty($coupons)) { $userCoupon = new UserCoupon(); $userCoupon->user = $user->id; $userCoupon->coupon = $coupons->id; $userCoupon->order = $orderID; $userCoupon->save(); $usedCoupun = $coupons->used_coupon(); if ($coupons->limit <= $usedCoupun) { $coupons->is_active = 0; $coupons->save(); } } } Order::create( [ 'order_id' => $orderID, 'name' => null, 'email' => null, 'card_number' => null, 'card_exp_month' => null, 'card_exp_year' => null, 'plan_name' => $plan->name, 'plan_id' => $plan->id, 'price' => $price == null ? 0 : $price, 'price_currency' => !empty($admin_payment_setting['currency']) ? $admin_payment_setting['currency'] : 'USD', 'txn_id' => '', 'payment_type' => 'Razorpay', 'payment_status' => 'succeeded', 'receipt' => null, 'user_id' => $authuser->id, ] ); $res['msg'] = __("Plan successfully upgraded."); $res['flag'] = 2; return $res; } else { return Utility::error_res(__('Plan fail to upgrade.')); } } $res_data['email'] = Auth::user()->email; $res_data['total_price'] = $price; $res_data['currency'] = $admin_payment_setting['currency']; $res_data['flag'] = 1; $res_data['coupon'] = $coupon_id; return $res_data; } else { return Utility::error_res(__('Plan is deleted.')); } } public function getPaymentStatus(Request $request, $pay_id, $plan) { $payment = $this->paymentConfig(); $admin_payment_setting = Utility::getAdminPaymentSetting(); $planID = \Illuminate\Support\Facades\Crypt::decrypt($plan); $plan = Plan::find($planID); $user = Auth::user(); if ($plan) { try { $orderID = time(); $ch = curl_init('https://api.razorpay.com/v1/payments/' . $pay_id . ''); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'GET'); curl_setopt($ch, CURLOPT_USERPWD, $payment->public_key . ':' . $payment->secret_key); // Input your Razorpay Key Id and Secret Id here curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $response = json_decode(curl_exec($ch)); // check that payment is authorized by razorpay or not if ($response->status == 'authorized') { if ($request->has('coupon_id') && $request->coupon_id != '') { $coupons = Coupon::find($request->coupon_id); if (!empty($coupons)) { $userCoupon = new UserCoupon(); $userCoupon->user = $user->id; $userCoupon->coupon = $coupons->id; $userCoupon->order = $orderID; $userCoupon->save(); $usedCoupun = $coupons->used_coupon(); if ($coupons->limit <= $usedCoupun) { $coupons->is_active = 0; $coupons->save(); } } } Utility::referralTransaction($plan); $order = new Order(); $order->order_id = $orderID; $order->name = $user->name; $order->card_number = ''; $order->card_exp_month = ''; $order->card_exp_year = ''; $order->plan_name = $plan->name; $order->plan_id = $plan->id; $order->price = isset($response->amount) ? $response->amount / 100 : 0; $order->price_currency = $admin_payment_setting['currency']; $order->txn_id = isset($response->id) ? $response->id : $pay_id; $order->payment_type = __('Razorpay'); $order->payment_status = 'success'; $order->receipt = ''; $order->user_id = $user->id; $order->save(); $assignPlan = $user->assignPlan($plan->id, $request->payment_frequency); if ($assignPlan['is_success']) { return redirect()->route('plans.index')->with('success', __('Plan activated Successfully!')); } else { return redirect()->route('plans.index')->with('error', __($assignPlan['error'])); } } else { return redirect()->route('plans.index')->with('error', __('Transaction has been failed! ')); } } catch (\Exception $e) { return redirect()->route('plans.index')->with('error', __('Plan not found!')); } } } } Controllers/vendor/Chatify/Api/MessagesController.php000064400000031357150364311770017013 0ustar00user(), Auth::user(), $request['channel_name'], $request['socket_id'] ); } /** * Fetch data by id for (user/group) * * @param Request $request * @return \Illuminate\Http\JsonResponse */ public function idFetchData(Request $request) { return auth()->user(); // Favorite $favorite = Chatify::inFavorite($request['id']); // User data if ($request['type'] == 'user') { $fetch = User::where('id', $request['id'])->first(); if($fetch){ $userAvatar = Chatify::getUserWithAvatar($fetch)->avatar; } } // send the response return Response::json([ 'favorite' => $favorite, 'fetch' => $fetch ?? [], 'user_avatar' => $userAvatar ?? null, ]); } /** * This method to make a links for the attachments * to be downloadable. * * @param string $fileName * @return \Illuminate\Http\JsonResponse */ public function download($fileName) { $path = config('chatify.attachments.folder') . '/' . $fileName; if (Chatify::storage()->exists($path)) { return response()->json([ 'file_name' => $fileName, 'download_path' => Chatify::storage()->url($path) ], 200); } else { return response()->json([ 'message'=>"Sorry, File does not exist in our server or may have been deleted!" ], 404); } } /** * Send a message to database * * @param Request $request * @return JSON response */ public function send(Request $request) { // default variables $error = (object)[ 'status' => 0, 'message' => null ]; $attachment = null; $attachment_title = null; // if there is attachment [file] if ($request->hasFile('file')) { // allowed extensions $allowed_images = Chatify::getAllowedImages(); $allowed_files = Chatify::getAllowedFiles(); $allowed = array_merge($allowed_images, $allowed_files); $file = $request->file('file'); // check file size if ($file->getSize() < Chatify::getMaxUploadSize()) { if (in_array(strtolower($file->getClientOriginalExtension()), $allowed)) { // get attachment name $attachment_title = $file->getClientOriginalName(); // upload attachment and store the new name $attachment = Str::uuid() . "." . $file->getClientOriginalExtension(); $file->storeAs(config('chatify.attachments.folder'), $attachment, config('chatify.storage_disk_name')); } else { $error->status = 1; $error->message = "File extension not allowed!"; } } else { $error->status = 1; $error->message = "File size you are trying to upload is too large!"; } } if (!$error->status) { // send to database $messageID = mt_rand(9, 999999999) + time(); Chatify::newMessage([ 'id' => $messageID, 'type' => $request['type'], 'from_id' => Auth::user()->id, 'to_id' => $request['id'], 'body' => htmlentities(trim($request['message']), ENT_QUOTES, 'UTF-8'), 'attachment' => ($attachment) ? json_encode((object)[ 'new_name' => $attachment, 'old_name' => htmlentities(trim($attachment_title), ENT_QUOTES, 'UTF-8'), ]) : null, ]); // fetch message to send it with the response $messageData = Chatify::fetchMessage($messageID); // send to user using pusher Chatify::push("private-chatify.".$request['id'], 'messaging', [ 'from_id' => Auth::user()->id, 'to_id' => $request['id'], 'message' => Chatify::messageCard($messageData, 'default') ]); } // send the response return Response::json([ 'status' => '200', 'error' => $error, 'message' => $messageData ?? [], 'tempID' => $request['temporaryMsgId'], ]); } /** * fetch [user/group] messages from database * * @param Request $request * @return JSON response */ public function fetch(Request $request) { $query = Chatify::fetchMessagesQuery($request['id'])->latest(); $messages = $query->paginate($request->per_page ?? $this->perPage); $totalMessages = $messages->total(); $lastPage = $messages->lastPage(); $response = [ 'total' => $totalMessages, 'last_page' => $lastPage, 'last_message_id' => collect($messages->items())->last()->id ?? null, 'messages' => $messages->items(), ]; return Response::json($response); } /** * Make messages as seen * * @param Request $request * @return void */ public function seen(Request $request) { // make as seen $seen = Chatify::makeSeen($request['id']); // send the response return Response::json([ 'status' => $seen, ], 200); } /** * Get contacts list * * @param Request $request * @return \Illuminate\Http\JsonResponse response */ public function getContacts(Request $request) { // get all users that received/sent message from/to [Auth user] $users = Message::join('users', function ($join) { $join->on('ch_messages.from_id', '=', 'users.id') ->orOn('ch_messages.to_id', '=', 'users.id'); }) ->where(function ($q) { $q->where('ch_messages.from_id', Auth::user()->id) ->orWhere('ch_messages.to_id', Auth::user()->id); }) ->where('users.id','!=',Auth::user()->id) ->select('users.*',DB::raw('MAX(ch_messages.created_at) max_created_at')) ->orderBy('max_created_at', 'desc') ->groupBy('users.id') ->paginate($request->per_page ?? $this->perPage); return response()->json([ 'contacts' => $users->items(), 'total' => $users->total() ?? 0, 'last_page' => $users->lastPage() ?? 1, ], 200); } /** * Put a user in the favorites list * * @param Request $request * @return void */ public function favorite(Request $request) { // check action [star/unstar] if (Chatify::inFavorite($request['user_id'])) { // UnStar Chatify::makeInFavorite($request['user_id'], 0); $status = 0; } else { // Star Chatify::makeInFavorite($request['user_id'], 1); $status = 1; } // send the response return Response::json([ 'status' => @$status, ], 200); } /** * Get favorites list * * @param Request $request * @return void */ public function getFavorites(Request $request) { $favorites = Favorite::where('user_id', Auth::user()->id)->get(); foreach ($favorites as $favorite) { $favorite->user = User::where('id', $favorite->favorite_id)->first(); } return Response::json([ 'total' => count($favorites), 'favorites' => $favorites ?? [], ], 200); } /** * Search in messenger * * @param Request $request * @return \Illuminate\Http\JsonResponse */ public function search(Request $request) { $input = trim(filter_var($request['input'])); $records = User::where('id','!=',Auth::user()->id) ->where('name', 'LIKE', "%{$input}%") ->paginate($request->per_page ?? $this->perPage); foreach ($records->items() as $index => $record) { $records[$index] += Chatify::getUserWithAvatar($record); } return Response::json([ 'records' => $records->items(), 'total' => $records->total(), 'last_page' => $records->lastPage() ], 200); } /** * Get shared photos * * @param Request $request * @return \Illuminate\Http\JsonResponse */ public function sharedPhotos(Request $request) { $images = Chatify::getSharedPhotos($request['user_id']); foreach ($images as $image) { $image = asset(config('chatify.attachments.folder') . $image); } // send the response return Response::json([ 'shared' => $images ?? [], ], 200); } /** * Delete conversation * * @param Request $request * @return void */ public function deleteConversation(Request $request) { // delete $delete = Chatify::deleteConversation($request['id']); // send the response return Response::json([ 'deleted' => $delete ? 1 : 0, ], 200); } public function updateSettings(Request $request) { $msg = null; $error = $success = 0; // dark mode if ($request['dark_mode']) { $request['dark_mode'] == "dark" ? User::where('id', Auth::user()->id)->update(['dark_mode' => 1]) // Make Dark : User::where('id', Auth::user()->id)->update(['dark_mode' => 0]); // Make Light } // If messenger color selected if ($request['messengerColor']) { $messenger_color = trim(filter_var($request['messengerColor'])); User::where('id', Auth::user()->id) ->update(['messenger_color' => $messenger_color]); } // if there is a [file] if ($request->hasFile('avatar')) { // allowed extensions $allowed_images = Chatify::getAllowedImages(); $file = $request->file('avatar'); // check file size if ($file->getSize() < Chatify::getMaxUploadSize()) { if (in_array(strtolower($file->getClientOriginalExtension()), $allowed_images)) { // delete the older one if (Auth::user()->avatar != config('chatify.user_avatar.default')) { $path = Chatify::getUserAvatarUrl(Auth::user()->avatar); if (Chatify::storage()->exists($path)) { Chatify::storage()->delete($path); } } // upload $avatar = Str::uuid() . "." . $file->getClientOriginalExtension(); $update = User::where('id', Auth::user()->id)->update(['avatar' => $avatar]); $file->storeAs(config('chatify.user_avatar.folder'), $avatar, config('chatify.storage_disk_name')); $success = $update ? 1 : 0; } else { $msg = "File extension not allowed!"; $error = 1; } } else { $msg = "File size you are trying to upload is too large!"; $error = 1; } } // send the response return Response::json([ 'status' => $success ? 1 : 0, 'error' => $error ? 1 : 0, 'message' => $error ? $msg : 0, ], 200); } /** * Set user's active status * * @param Request $request * @return void */ public function setActiveStatus(Request $request) { $update = $request['status'] > 0 ? User::where('id', $request['user_id'])->update(['active_status' => 1]) : User::where('id', $request['user_id'])->update(['active_status' => 0]); // send the response return Response::json([ 'status' => $update, ], 200); } } Controllers/vendor/Chatify/MessagesController.php000064400000045424150364311770016302 0ustar00user(), Auth::user(), $request['channel_name'], $request['socket_id'] ); } /** * Returning the view of the app with the required data. * * @param int $id * @return \Illuminate\Contracts\Foundation\Application|\Illuminate\Contracts\View\Factory|\Illuminate\Contracts\View\View */ public function index($id = null) { $routeName = FacadesRequest::route()->getName(); $route = (in_array($routeName, ['user', config('chatify.routes.prefix')])) ? 'user' : $routeName; return view('Chatify::pages.app', [ 'id' => $id ?? 0, 'route' => $route, 'messengerColor' => Auth::user()->messenger_color ?? $this->messengerFallbackColor, 'dark_mode' => Auth::user()->dark_mode < 1 ? 'light' : 'dark', ]); } /** * Fetch data by id for (user/group) * * @param Request $request * @return JsonResponse */ public function idFetchData(Request $request) { // Favorite $favorite = Chatify::inFavorite($request['id']); // User data // if ($request['type'] == 'user') { $fetch = User::where('id', $request['id'])->first(); if ($fetch) { $userAvatar = Chatify::getUserWithAvatar($fetch)->avatar; } // } $profile = \App\Models\Utility::get_file('/' . config('chatify.user_avatar.folder')); // send the response return Response::json([ 'favorite' => $favorite, 'fetch' => $fetch ?? [], 'user_avatar' => $userAvatar ?? $profile . '/avatar.png', ]); } /** * This method to make a links for the attachments * to be downloadable. * * @param string $fileName * @return \Symfony\Component\HttpFoundation\StreamedResponse|void */ public function download($fileName) { if (Chatify::storage()->exists(config('chatify.attachments.folder') . '/' . $fileName)) { return Chatify::storage()->download(config('chatify.attachments.folder') . '/' . $fileName); } else { return abort(404, "Sorry, File does not exist in our server or may have been deleted!"); } } /** * Send a message to database * * @param Request $request * @return JsonResponse */ public function send(Request $request) { // default variables $error = (object)[ 'status' => 0, 'message' => null ]; $attachment = null; $attachment_title = null; // if there is attachment [file] if ($request->hasFile('file')) { // allowed extensions $allowed_images = Chatify::getAllowedImages(); $allowed_files = Chatify::getAllowedFiles(); $allowed = array_merge($allowed_images, $allowed_files); $file = $request->file('file'); // if size less than 150MB if ($file->getSize() < 150000000) { if (in_array($file->getClientOriginalExtension(), $allowed)) { // get attachment name $attachment_title = $file->getClientOriginalName(); // upload attachment and store the new name $dir = '/attachments/'; $attachment = Str::uuid() . "." . $file->getClientOriginalExtension(); $path = Utility::upload_file($request, 'file', $attachment, $dir, []); if ($path['flag'] == 1) { $url = $path['url']; } else { return redirect()->back()->with('error', __($path['msg'])); } } else { $error->status = 1; $error->message = "File extension not allowed!"; } } else { $error->status = 1; $error->message = "File extension not allowed!"; } } if (!$error->status) { // send to database $messageID = mt_rand(9, 999999999) + time(); Chatify::newMessage([ 'id' => $messageID, 'type' => $request['type'], 'from_id' => Auth::user()->id, 'to_id' => $request['id'], 'body' => htmlentities(trim($request['message']), ENT_QUOTES, 'UTF-8'), 'attachment' => ($attachment) ? json_encode((object)[ 'new_name' => $attachment, 'old_name' => htmlentities(trim($attachment_title), ENT_QUOTES, 'UTF-8'), ]) : null, ]); // fetch message to send it with the response $messageData = Chatify::fetchMessage($messageID); // send to user using pusher Chatify::push("private-chatify." . $request['id'], 'messaging', [ 'from_id' => Auth::user()->id, 'to_id' => $request['id'], 'message' => Chatify::messageCard($messageData, 'default') ]); } // send the response return Response::json([ 'status' => '200', 'error' => $error, 'message' => Chatify::messageCard(@$messageData), 'tempID' => $request['temporaryMsgId'], ]); } /** * fetch [user/group] messages from database * * @param Request $request * @return JsonResponse */ public function fetch(Request $request) { $query = Chatify::fetchMessagesQuery($request['id'])->latest(); $messages = $query->paginate($request->per_page ?? $this->perPage); $totalMessages = $messages->total(); $lastPage = $messages->lastPage(); $response = [ 'total' => $totalMessages, 'last_page' => $lastPage, 'last_message_id' => collect($messages->items())->last()->id ?? null, 'messages' => '', ]; // if there is no messages yet. if ($totalMessages < 1) { $response['messages'] = '

Say \'hi\' and start messaging

'; return Response::json($response); } if (count($messages->items()) < 1) { $response['messages'] = ''; return Response::json($response); } $allMessages = null; foreach ($messages->reverse() as $index => $message) { $allMessages .= Chatify::messageCard( Chatify::fetchMessage($message->id, $index) ); } $response['messages'] = $allMessages; return Response::json($response); } /** * Make messages as seen * * @param Request $request * @return JsonResponse|void */ public function seen(Request $request) { // make as seen $seen = Chatify::makeSeen($request['id']); // send the response return Response::json([ 'status' => $seen, ], 200); } /** * Get contacts list * * @param Request $request * @return JsonResponse */ public function getContacts(Request $request) { // get all users that received/sent message from/to [Auth user] $users = Message::join('users', function ($join) { $join->on('ch_messages.from_id', '=', 'users.id') ->orOn('ch_messages.to_id', '=', 'users.id'); }) ->where(function ($q) { $q->where('ch_messages.from_id', Auth::user()->id) ->orWhere('ch_messages.to_id', Auth::user()->id); }) ->where('users.id', '!=', Auth::user()->id) ->select('users.*', DB::raw('MAX(ch_messages.created_at) max_created_at')) ->orderBy('max_created_at', 'desc') ->groupBy('users.id') ->paginate($request->per_page ?? $this->perPage); $usersList = $users->items(); if (count($usersList) > 0) { $contacts = ''; foreach ($usersList as $user) { $contacts_message = Chatify::getContactItem($user); $contacts .= $contacts_message; } } else { $contacts = '

Your contact list is empty

'; } // Get All Memebers $objUser = Auth::user(); if ($objUser->type != 'super admin') { $members = User::where('created_by', '=', $objUser->creatorId())->where('id', '!=', Auth::user()->id)->where('type', '!=', 'super admin')->get(); } $getRecords = null; foreach ($members as $record) { $getRecords .= view( 'vendor.Chatify.layouts.listItem', [ 'get' => 'all_members', 'type' => 'user', 'user' => $record, ] )->render(); } // send the response // return Response::json( // [ // // 'contacts' => $users->count() > 0 ? $contacts : '

' . __('Your user list is empty') . '

', // // 'allUsers' => $members->count() > 0 ? $getRecords : '

' . __('Your member list is empty') . '

', // ], // 200 // ); //message unread data if ($request->type == 'custom') { if (count($usersList) > 0) { $contacts = ''; foreach ($usersList as $user) { $message_count = Chatify::countUnseenMessages($user->id); if (!empty($message_count)) { $contacts_message = Chatify::getContactItem($user); $contacts .= $contacts_message; } } } return Response::json([ 'contacts' => $contacts, ], 200); } return Response::json([ 'contacts' => $contacts, 'total' => $users->total() ?? 0, 'last_page' => $users->lastPage() ?? 1, 'allUsers' => $members->count() > 0 ? $getRecords : '

' . __('Your member list is empty') . '

', ], 200); } /** * Update user's list item data * * @param Request $request * @return JsonResponse */ public function updateContactItem(Request $request) { // Get user data $user = User::where('id', $request['user_id'])->first(); if (!$user) { return Response::json([ 'message' => 'User not found!', ], 401); } $contactItem = Chatify::getContactItem($user); // send the response return Response::json([ 'contactItem' => $contactItem, ], 200); } /** * Put a user in the favorites list * * @param Request $request * @return JsonResponse|void */ public function favorite(Request $request) { // check action [star/unstar] if (Chatify::inFavorite($request['user_id'])) { // UnStar Chatify::makeInFavorite($request['user_id'], 0); $status = 0; } else { // Star Chatify::makeInFavorite($request['user_id'], 1); $status = 1; } // send the response return Response::json([ 'status' => @$status, ], 200); } /** * Get favorites list * * @param Request $request * @return JsonResponse|void */ public function getFavorites(Request $request) { $favoritesList = null; $favorites = Favorite::where('user_id', Auth::user()->id); foreach ($favorites->get() as $favorite) { // get user data $user = User::where('id', $favorite->favorite_id)->first(); $favoritesList .= view('Chatify::layouts.favorite', [ 'user' => $user, ]); } $count = $favorites->count(); // send the response return Response::json([ 'count' => $count, 'favorites' => $count > 0 ? $favoritesList : '

Your favourite list is empty

', ], 200); } /** * Search in messenger * * @param Request $request * @return JsonResponse|void */ public function search(Request $request) { $getRecords = null; $input = trim(filter_var($request['input'])); $records = User::where('id', '!=', Auth::user()->id)->where('name', '!=', 'Super Admin') ->where('created_by', \Auth::user()->creatorId()) ->where('name', 'LIKE', "%{$input}%") ->paginate($request->per_page ?? $this->perPage); foreach ($records->items() as $record) { $getRecords .= view('Chatify::layouts.listItem', [ 'get' => 'search_item', 'type' => 'user', 'user' => Chatify::getUserWithAvatar($record), ])->render(); } if ($records->total() < 1) { $getRecords = '

Nothing to show.

'; } // send the response return Response::json([ 'records' => $getRecords, 'total' => $records->total(), 'last_page' => $records->lastPage() ], 200); } /** * Get shared photos * * @param Request $request * @return JsonResponse|void */ public function sharedPhotos(Request $request) { $shared = Chatify::getSharedPhotos($request['user_id']); $sharedPhotos = null; // shared with its template for ($i = 0; $i < count($shared); $i++) { $sharedPhotos .= view('Chatify::layouts.listItem', [ 'get' => 'sharedPhoto', 'image' => Chatify::getAttachmentUrl($shared[$i]), ])->render(); } // send the response return Response::json([ 'shared' => count($shared) > 0 ? $sharedPhotos : '

Nothing shared yet

', ], 200); } /** * Delete conversation * * @param Request $request * @return JsonResponse */ public function deleteConversation(Request $request) { // delete $delete = Chatify::deleteConversation($request['id']); // send the response return Response::json([ 'deleted' => $delete ? 1 : 0, ], 200); } /** * Delete message * * @param Request $request * @return JsonResponse */ public function deleteMessage(Request $request) { // delete $delete = Chatify::deleteMessage($request['id']); // send the response return Response::json([ 'deleted' => $delete ? 1 : 0, ], 200); } public function updateSettings(Request $request) { $msg = null; $error = $success = 0; // dark mode if ($request['dark_mode']) { $request['dark_mode'] == "dark" ? User::where('id', Auth::user()->id)->update(['dark_mode' => 1]) // Make Dark : User::where('id', Auth::user()->id)->update(['dark_mode' => 0]); // Make Light } // If messenger color selected if ($request['messengerColor']) { $messenger_color = trim(filter_var($request['messengerColor'])); User::where('id', Auth::user()->id) ->update(['messenger_color' => $messenger_color]); } // if there is a [file] if ($request->hasFile('avatar')) { // allowed extensions $allowed_images = Chatify::getAllowedImages(); $file = $request->file('avatar'); // check file size if ($file->getSize() < Chatify::getMaxUploadSize()) { if (in_array(strtolower($file->getClientOriginalExtension()), $allowed_images)) { // delete the older one if (Auth::user()->avatar != config('chatify.user_avatar.default')) { $avatar = Auth::user()->avatar; if (Chatify::storage()->exists($avatar)) { Chatify::storage()->delete($avatar); } } // upload $avatar = Str::uuid() . "." . $file->getClientOriginalExtension(); $update = User::where('id', Auth::user()->id)->update(['avatar' => $avatar]); $file->storeAs(config('chatify.user_avatar.folder'), $avatar, config('chatify.storage_disk_name')); $success = $update ? 1 : 0; } else { $msg = "File extension not allowed!"; $error = 1; } } else { $msg = "File size you are trying to upload is too large!"; $error = 1; } } // send the response return Response::json([ 'status' => $success ? 1 : 0, 'error' => $error ? 1 : 0, 'message' => $error ? $msg : 0, ], 200); } /** * Set user's active status * * @param Request $request * @return JsonResponse */ public function setActiveStatus(Request $request) { $update = $request['status'] > 0 ? User::where('id', $request['user_id'])->update(['active_status' => 1]) : User::where('id', $request['user_id'])->update(['active_status' => 0]); // send the response return Response::json([ 'status' => $update, ], 200); } } Controllers/AllowanceController.php000064400000012673150364311770013554 0ustar00creatorId())->get()->pluck('name', 'id'); $employee = Employee::find($id); $Allowancetypes =Allowance::$Allowancetype; return view('allowance.create', compact('employee', 'allowance_options','Allowancetypes')); } public function store(Request $request) { if(\Auth::user()->can('Create Allowance')) { $validator = \Validator::make( $request->all(), [ 'employee_id' => 'required', 'allowance_option' => 'required', 'title' => 'required', 'amount' => 'required', 'type' => 'required', ] ); if($validator->fails()) { $messages = $validator->getMessageBag(); return redirect()->back()->with('error', $messages->first()); } $allowance = new Allowance(); $allowance->employee_id = $request->employee_id; $allowance->allowance_option = $request->allowance_option; $allowance->title = $request->title; $allowance->amount = $request->amount; $allowance->type = $request->type; $allowance->created_by = \Auth::user()->creatorId(); $allowance->save(); if( $allowance->type == 'percentage' ) { $employee = Employee::find($allowance->employee_id); $empsal = $allowance->amount * $employee->salary / 100; } return redirect()->back()->with('success', __('Allowance successfully created.')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } public function show(Allowance $allowance) { return redirect()->route('allowance.index'); } public function edit($allowance) { $allowance = Allowance::find($allowance); if(\Auth::user()->can('Edit Allowance')) { if($allowance->created_by == \Auth::user()->creatorId()) { $allowance_options = AllowanceOption::where('created_by', \Auth::user()->creatorId())->get()->pluck('name', 'id'); $Allowancetypes =Allowance::$Allowancetype; return view('allowance.edit', compact('allowance', 'allowance_options','Allowancetypes')); } else { return response()->json(['error' => __('Permission denied.')], 401); } } else { return response()->json(['error' => __('Permission denied.')], 401); } } public function update(Request $request, Allowance $allowance) { if(\Auth::user()->can('Edit Allowance')) { if($allowance->created_by == \Auth::user()->creatorId()) { $validator = \Validator::make( $request->all(), [ 'allowance_option' => 'required', 'title' => 'required', 'amount' => 'required', ] ); if($validator->fails()) { $messages = $validator->getMessageBag(); return redirect()->back()->with('error', $messages->first()); } $allowance->allowance_option = $request->allowance_option; $allowance->title = $request->title; $allowance->type = $request->type; $allowance->amount = $request->amount; $allowance->save(); if( $allowance->type == 'percentage' ) { $employee = Employee::find($allowance->employee_id); $empsal = $allowance->amount * $employee->salary / 100; } return redirect()->back()->with('success', __('Allowance successfully updated.')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } else { return redirect()->back()->with('error', __('Permission denied.')); } } public function destroy(Allowance $allowance) { if(\Auth::user()->can('Delete Allowance')) { if($allowance->created_by == \Auth::user()->creatorId()) { $allowance->delete(); return redirect()->back()->with('success', __('Allowance successfully deleted.')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } else { return redirect()->back()->with('error', __('Permission denied.')); } } } Controllers/AamarpayController.php000064400000025700150364311770013375 0ustar00plan_id); $authuser = \Auth::user(); $plan = Plan::find($planID); if ($plan) { $get_amount = $plan->price; // if (Auth::user()->phone == null) { // return redirect()->back()->with('failed', __('Please add phone number to your profile.')); // } try { if (!empty($request->coupon)) { $coupons = Coupon::where('code', strtoupper($request->coupon))->where('is_active', '1')->first(); if (!empty($coupons)) { $usedCoupun = $coupons->used_coupon(); $discount_value = ($plan->price / 100) * $coupons->discount; $get_amount = $plan->price - $discount_value; if ($coupons->limit == $usedCoupun) { return redirect()->back()->with('error', __('This coupon code has expired.')); } if ($get_amount <= 0) { $authuser = \Auth::user(); $authuser->plan = $plan->id; $authuser->save(); $assignPlan = $authuser->assignPlan($plan->id); if ($assignPlan['is_success'] == true && !empty($plan)) { if (!empty($authuser->payment_subscription_id) && $authuser->payment_subscription_id != '') { try { $authuser->cancel_subscription($authuser->id); } catch (\Exception $exception) { \Log::debug($exception->getMessage()); } } $orderID = strtoupper(str_replace('.', '', uniqid('', true))); $userCoupon = new UserCoupon(); $userCoupon->user = $authuser->id; $userCoupon->coupon = $coupons->id; $userCoupon->order = $orderID; $userCoupon->save(); Order::create( [ 'order_id' => $orderID, 'name' => null, 'email' => null, 'card_number' => null, 'card_exp_month' => null, 'card_exp_year' => null, 'plan_name' => $plan->name, 'plan_id' => $plan->id, 'price' => $get_amount == null ? 0 : $get_amount, 'price_currency' => !empty($payment_setting['currency']) ? $payment_setting['currency'] : 'USD', 'txn_id' => '', 'payment_type' => 'Aamarpay', 'payment_status' => 'success', 'receipt' => null, 'user_id' => $authuser->id, ] ); $assignPlan = $authuser->assignPlan($plan->id); return redirect()->route('plans.index')->with('success', __('Plan Successfully Activated')); } } } else { return redirect()->back()->with('error', __('This coupon code is invalid or has expired.')); } } $coupon = (empty($request->coupon)) ? "0" : $request->coupon; $orderID = strtoupper(str_replace('.', '', uniqid('', true))); $fields = array( 'store_id' => $aamarpay_store_id, //store id will be aamarpay, contact integration@aamarpay.com for test/live id 'amount' => $get_amount, //transaction amount 'payment_type' => '', //no need to change 'currency' => $currency, //currenct will be USD/BDT 'tran_id' => $orderID, //transaction id must be unique from your end 'cus_name' => $authuser->name, //customer name 'cus_email' => $authuser->email, //customer email address 'cus_add1' => '', //customer address 'cus_add2' => '', //customer address 'cus_city' => '', //customer city 'cus_state' => '', //state 'cus_postcode' => '', //postcode or zipcode 'cus_country' => '', //country 'cus_phone' => '1234567890', //customer phone number 'success_url' => route('pay.aamarpay.success', Crypt::encrypt(['response' => 'success', 'coupon' => $coupon, 'plan_id' => $plan->id, 'price' => $get_amount, 'order_id' => $orderID])), //your success route 'fail_url' => route('pay.aamarpay.success', Crypt::encrypt(['response' => 'failure', 'coupon' => $coupon, 'plan_id' => $plan->id, 'price' => $get_amount, 'order_id' => $orderID])), //your fail route 'cancel_url' => route('pay.aamarpay.success', Crypt::encrypt(['response' => 'cancel'])), //your cancel url 'signature_key' => $aamarpay_signature_key, 'desc' => $aamarpay_description, ); //signature key will provided aamarpay, contact integration@aamarpay.com for test/live signature key $fields_string = http_build_query($fields); $ch = curl_init(); curl_setopt($ch, CURLOPT_VERBOSE, true); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_POSTFIELDS, $fields_string); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); $url_forward = str_replace('"', '', stripslashes(curl_exec($ch))); curl_close($ch); $this->redirect_to_merchant($url_forward); } catch (\Exception $e) { return redirect()->back()->with('error', $e); } } else { return redirect()->route('plans.index')->with('error', __('Plan is deleted.')); } } function redirect_to_merchant($url) { $token = csrf_token(); ?>
where('is_active', '1')->first(); $request['coupon_id'] = $coupons->id; } else { $coupons = null; } Utility::referralTransaction($plan); $order = new Order(); $order->order_id = $orderID; $order->name = $user->name; $order->card_number = ''; $order->card_exp_month = ''; $order->card_exp_year = ''; $order->plan_name = $plan->name; $order->plan_id = $plan->id; $order->price = $getAmount; $order->price_currency = !empty($payment_setting['currency']) ? $payment_setting['currency'] : 'USD'; $order->payment_type = __('Aamarpay'); $order->payment_status = 'success'; $order->txn_id = ''; $order->receipt = ''; $order->user_id = $user->id; $order->save(); $assignPlan = $user->assignPlan($plan->id); $coupons = Coupon::find($request->coupon_id); if (!empty($request->coupon_id)) { if (!empty($coupons)) { $userCoupon = new UserCoupon(); $userCoupon->user = $user->id; $userCoupon->coupon = $coupons->id; $userCoupon->order = $orderID; $userCoupon->save(); $usedCoupun = $coupons->used_coupon(); if ($coupons->limit <= $usedCoupun) { $coupons->is_active = 0; $coupons->save(); } } } if ($assignPlan['is_success']) { return redirect()->route('plans.index')->with('success', __('Plan activated Successfully.')); } else { return redirect()->route('plans.index')->with('error', __($assignPlan['error'])); } } elseif ($data['response'] == "cancel") { return redirect()->route('plans.index')->with('error', __('Your payment is cancel')); } else { return redirect()->route('plans.index')->with('error', __('Your Transaction is fail please try again')); } } } Controllers/PayslipTypeController.php000064400000011115150364311770014120 0ustar00can('Manage Payslip Type')) { $paysliptypes = PayslipType::where('created_by', '=', \Auth::user()->creatorId())->get(); return view('paysliptype.index', compact('paysliptypes')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } public function create() { if(\Auth::user()->can('Create Payslip Type')) { return view('paysliptype.create'); } else { return response()->json(['error' => __('Permission denied.')], 401); } } public function store(Request $request) { if(\Auth::user()->can('Create Payslip Type')) { $validator = \Validator::make( $request->all(), [ 'name' => 'required|max:20', ] ); if($validator->fails()) { $messages = $validator->getMessageBag(); return redirect()->back()->with('error', $messages->first()); } $paysliptype = new PayslipType(); $paysliptype->name = $request->name; $paysliptype->created_by = \Auth::user()->creatorId(); $paysliptype->save(); return redirect()->route('paysliptype.index')->with('success', __('PayslipType successfully created.')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } public function show(PayslipType $paysliptype) { return redirect()->route('paysliptype.index'); } public function edit(PayslipType $paysliptype) { if(\Auth::user()->can('Edit Payslip Type')) { if($paysliptype->created_by == \Auth::user()->creatorId()) { return view('paysliptype.edit', compact('paysliptype')); } else { return response()->json(['error' => __('Permission denied.')], 401); } } else { return response()->json(['error' => __('Permission denied.')], 401); } } public function update(Request $request, PayslipType $paysliptype) { if(\Auth::user()->can('Edit Payslip Type')) { if($paysliptype->created_by == \Auth::user()->creatorId()) { $validator = \Validator::make( $request->all(), [ 'name' => 'required|max:20', ] ); if($validator->fails()) { $messages = $validator->getMessageBag(); return redirect()->back()->with('error', $messages->first()); } $paysliptype->name = $request->name; $paysliptype->save(); return redirect()->route('paysliptype.index')->with('success', __('PayslipType successfully updated.')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } else { return redirect()->back()->with('error', __('Permission denied.')); } } public function destroy(PayslipType $paysliptype) { if(\Auth::user()->can('Delete Payslip Type')) { if($paysliptype->created_by == \Auth::user()->creatorId()) { $employee = Employee::where('salary_type',$paysliptype->id)->get(); if(count($employee) == 0) { $paysliptype->delete(); } else { return redirect()->route('paysliptype.index')->with('error', __('This Payslip Type has Set Salary. Please remove the Set Salary from this Payslip Type.')); } return redirect()->route('paysliptype.index')->with('success', __('PayslipType successfully deleted.')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } else { return redirect()->back()->with('error', __('Permission denied.')); } } } Controllers/NepalstePaymnetController.php000064400000017061150364311770014754 0ustar00plan_id); $plan = Plan::find($planID); $orderID = strtoupper(str_replace('.', '', uniqid('', true))); $user = Auth::user(); if ($plan) { $get_amount = $plan->price; if (!empty($request->coupon)) { $coupons = Coupon::where('code', strtoupper($request->coupon))->where('is_active', '1')->first(); if (!empty($coupons)) { $usedCoupun = $coupons->used_coupon(); $discount_value = ($plan->price / 100) * $coupons->discount; $get_amount = $plan->price - $discount_value; if ($coupons->limit == $usedCoupun) { return redirect()->back()->with('error', __('This coupon code has expired.')); } if ($get_amount <= 0) { $authuser = Auth::user(); $authuser->plan = $plan->id; $authuser->save(); $assignPlan = $authuser->assignPlan($plan->id); if ($assignPlan['is_success'] == true && !empty($plan)) { $orderID = strtoupper(str_replace('.', '', uniqid('', true))); $userCoupon = new UserCoupon(); $userCoupon->user = $authuser->id; $userCoupon->coupon = $coupons->id; $userCoupon->order = $orderID; $userCoupon->save(); Order::create( [ 'order_id' => $orderID, 'name' => null, 'email' => null, 'card_number' => null, 'card_exp_month' => null, 'card_exp_year' => null, 'plan_name' => $plan->name, 'plan_id' => $plan->id, 'price' => $get_amount == null ? 0 : $get_amount, 'price_currency' => $currency, 'txn_id' => '', 'payment_type' => 'Nepalste', 'payment_status' => 'success', 'receipt' => null, 'user_id' => $authuser->id, ] ); $assignPlan = $authuser->assignPlan($plan->id); return redirect()->route('plans.index')->with('success', __('Plan Successfully Activated')); } } } else { return redirect()->back()->with('error', __('This coupon code is invalid or has expired.')); } } } if (!empty($request->coupon)) { $response = ['get_amount' => $get_amount, 'plan' => $plan, 'coupon_id' => $coupons->id]; } else { $response = ['get_amount' => $get_amount, 'plan' => $plan]; } $parameters = [ 'identifier' => 'DFU80XZIKS', 'currency' => $currency, 'amount' => $get_amount, 'details' => $plan->name, 'ipn_url' => route('nepalste.status', $response), 'cancel_url' => route('nepalste.cancel'), 'success_url' => route('nepalste.status', $response), 'public_key' => $api_key, 'site_logo' => 'https://nepalste.com.np/assets/images/logoIcon/logo.png', 'checkout_theme' => 'dark', 'customer_name' => 'John Doe', 'customer_email' => 'john@mail.com', ]; //live end point // $url = "https://nepalste.com.np/payment/initiate"; //test end point // $url = "https://nepalste.com.np/sandbox/payment/initiate"; //live end point if($payment_setting['nepalste_mode'] == 'live'){ $url = "https://nepalste.com.np/payment/initiate"; }else{ $url = "https://nepalste.com.np/sandbox/payment/initiate"; } $ch = curl_init(); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_POSTFIELDS, $parameters); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $result = curl_exec($ch); curl_close($ch); $result = json_decode($result, true); if (isset($result['success'])) { return redirect($result['url']); } else { return redirect()->back()->with('error', __($result['message'])); } } public function planGetNepalsteStatus(Request $request) { $payment_setting = Utility::getAdminPaymentSetting(); $currency = isset($payment_setting['currency']) ? $payment_setting['currency'] : ''; $orderID = strtoupper(str_replace('.', '', uniqid('', true))); $getAmount = $request->get_amount; $authuser = Auth::user(); $plan = Plan::find($request->plan); Utility::referralTransaction($plan); $order = new Order(); $order->order_id = $orderID; $order->name = $authuser->name; $order->card_number = ''; $order->card_exp_month = ''; $order->card_exp_year = ''; $order->plan_name = $plan->name; $order->plan_id = $plan->id; $order->price = $getAmount; $order->price_currency = $currency; $order->txn_id = $orderID; $order->payment_type = __('Neplaste'); $order->payment_status = 'success'; $order->txn_id = ''; $order->receipt = ''; $order->user_id = $authuser->id; $order->save(); $assignPlan = $authuser->assignPlan($plan->id); $coupons = Coupon::find($request->coupon_id); if (!empty($request->coupon_id)) { if (!empty($coupons)) { $userCoupon = new UserCoupon(); $userCoupon->user = $authuser->id; $userCoupon->coupon = $coupons->id; $userCoupon->order = $orderID; $userCoupon->save(); $usedCoupun = $coupons->used_coupon(); if ($coupons->limit <= $usedCoupun) { $coupons->is_active = 0; $coupons->save(); } } } if ($assignPlan['is_success']) { return redirect()->route('plans.index')->with('success', __('Plan activated Successfully.')); } else { return redirect()->route('plans.index')->with('error', __($assignPlan['error'])); } } public function planGetNepalsteCancel(Request $request) { return redirect()->back()->with('error', __('Transaction has failed')); } } Controllers/AllowanceOptionController.php000064400000011406150364311770014736 0ustar00can('Manage Allowance Option')) { $allowanceoptions = AllowanceOption::where('created_by', '=', \Auth::user()->creatorId())->get(); return view('allowanceoption.index', compact('allowanceoptions')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } public function create() { if(\Auth::user()->can('Create Allowance Option')) { return view('allowanceoption.create'); } else { return response()->json(['error' => __('Permission denied.')], 401); } } public function store(Request $request) { if(\Auth::user()->can('Create Allowance Option')) { $validator = \Validator::make( $request->all(), [ 'name' => 'required|max:20', ] ); if($validator->fails()) { $messages = $validator->getMessageBag(); return redirect()->back()->with('error', $messages->first()); } $allowanceoption = new AllowanceOption(); $allowanceoption->name = $request->name; $allowanceoption->created_by = \Auth::user()->creatorId(); $allowanceoption->save(); return redirect()->route('allowanceoption.index')->with('success', __('AllowanceOption successfully created.')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } public function show(AllowanceOption $allowanceoption) { return redirect()->route('allowanceoption.index'); } public function edit(AllowanceOption $allowanceoption) { if(\Auth::user()->can('Edit Allowance Option')) { if($allowanceoption->created_by == \Auth::user()->creatorId()) { return view('allowanceoption.edit', compact('allowanceoption')); } else { return response()->json(['error' => __('Permission denied.')], 401); } } else { return response()->json(['error' => __('Permission denied.')], 401); } } public function update(Request $request, AllowanceOption $allowanceoption) { if(\Auth::user()->can('Edit Allowance Option')) { if($allowanceoption->created_by == \Auth::user()->creatorId()) { $validator = \Validator::make( $request->all(), [ 'name' => 'required|max:20', ] ); if($validator->fails()) { $messages = $validator->getMessageBag(); return redirect()->back()->with('error', $messages->first()); } $allowanceoption->name = $request->name; $allowanceoption->save(); return redirect()->route('allowanceoption.index')->with('success', __('AllowanceOption successfully updated.')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } else { return redirect()->back()->with('error', __('Permission denied.')); } } public function destroy(AllowanceOption $allowanceoption) { if(\Auth::user()->can('Delete Allowance Option')) { if($allowanceoption->created_by == \Auth::user()->creatorId()) { $allowance = Allowance::where('allowance_option',$allowanceoption->id)->get(); if(count($allowance) == 0) { $allowanceoption->delete(); } else { return redirect()->route('allowanceoption.index')->with('error', __('This Allowance Option has Allowance. Please remove the Allowance from this Allowance option.')); } return redirect()->route('allowanceoption.index')->with('success', __('AllowanceOption successfully deleted.')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } else { return redirect()->back()->with('error', __('Permission denied.')); } } } Controllers/PaytmPaymentController.php000064400000022150150364311770014266 0ustar00type == 'company') { $admin_payment_setting = Utility::getAdminPaymentSetting(); config( [ 'services.paytm-wallet.env' => isset($admin_payment_setting['paytm_mode']) ? $admin_payment_setting['paytm_mode'] : '', 'services.paytm-wallet.merchant_id' => isset($admin_payment_setting['paytm_merchant_id']) ? $admin_payment_setting['paytm_merchant_id'] : '', 'services.paytm-wallet.merchant_key' => isset($admin_payment_setting['paytm_merchant_key']) ? $admin_payment_setting['paytm_merchant_key'] : '', 'services.paytm-wallet.merchant_website' => 'WEBSTAGING', 'services.paytm-wallet.channel' => 'WEB', 'services.paytm-wallet.industry_type' => isset($admin_payment_setting['paytm_industry_type']) ? $admin_payment_setting['paytm_industry_type'] : '', ] ); } } public function planPayWithPaytm(Request $request) { $payment = $this->paymentConfig(); $planID = \Illuminate\Support\Facades\Crypt::decrypt($request->plan_id); $plan = Plan::find($planID); $authuser = \Auth::user(); $coupons_id = ''; if ($plan) { $price = $plan->price; if (isset($request->coupon) && !empty($request->coupon)) { $request->coupon = trim($request->coupon); $coupons = Coupon::where('code', strtoupper($request->coupon))->where('is_active', '1')->first(); if (!empty($coupons)) { $usedCoupun = $coupons->used_coupon(); $discount_value = ($price / 100) * $coupons->discount; $plan->discounted_price = $price - $discount_value; $coupons_id = $coupons->id; if ($usedCoupun >= $coupons->limit) { return Utility::error_res(__('This coupon code has expired.')); } $price = $price - $discount_value; } else { return Utility::error_res(__('This coupon code is invalid or has expired.')); } } if ($price <= 0) { $authuser->plan = $plan->id; $authuser->save(); $assignPlan = $authuser->assignPlan($plan->id); if ($assignPlan['is_success'] == true && !empty($plan)) { $orderID = strtoupper(str_replace('.', '', uniqid('', true))); $user = Auth::user(); if ($request->has('coupon') && $request->coupon != '') { $coupons = Coupon::where('code', strtoupper($request->coupon))->where('is_active', '1')->first(); if (!empty($coupons)) { $userCoupon = new UserCoupon(); $userCoupon->user = $user->id; $userCoupon->coupon = $coupons->id; $userCoupon->order = $orderID; $userCoupon->save(); $usedCoupun = $coupons->used_coupon(); if ($coupons->limit <= $usedCoupun) { $coupons->is_active = 0; $coupons->save(); } } } Order::create( [ 'order_id' => $orderID, 'name' => null, 'email' => null, 'card_number' => null, 'card_exp_month' => null, 'card_exp_year' => null, 'plan_name' => $plan->name, 'plan_id' => $plan->id, 'price' => $price == null ? 0 : $price, 'price_currency' => !empty($admin_payment_setting['currency']) ? $admin_payment_setting['currency'] : 'USD', 'txn_id' => '', 'payment_type' => 'Paytm', 'payment_status' => 'succeeded', 'receipt' => null, 'user_id' => $authuser->id, ] ); if ($assignPlan['is_success']) { return redirect()->route('plans.index')->with('success', __('Plan activated Successfully!')); } else { return redirect()->route('plans.index')->with('error', __($assignPlan['error'])); } } else { return Utility::error_res(__('Plan fail to upgrade.')); } } $call_back = route( 'plan.paytm', [ $request->plan_id, 'coupon_id=' . $coupons_id, ] ); $payment = PaytmWallet::with('receive'); $payment->prepare( [ 'order' => date('Y-m-d') . '-' . strtotime(date('Y-m-d H:i:s')), 'user' => Auth::user()->id, 'mobile_number' => $request->mobile, 'email' => Auth::user()->email, 'amount' => $price, 'plan' => $plan->id, 'callback_url' => $call_back, ] ); return $payment->receive(); } else { return Utility::error_res(__('Plan is deleted.')); } } public function getPaymentStatus(Request $request, $plan) { $transaction = $this->paymentConfig(); $planID = \Illuminate\Support\Facades\Crypt::decrypt($plan); $plan = Plan::find($planID); $user = Auth::user(); $orderID = time(); if ($plan) { try { $transaction = PaytmWallet::with('receive'); $response = $transaction->response(); if ($transaction->isSuccessful()) { if ($request->has('coupon_id') && $request->coupon_id != '') { $coupons = Coupon::find($request->coupon_id); if (!empty($coupons)) { $userCoupon = new UserCoupon(); $userCoupon->user = $user->id; $userCoupon->coupon = $coupons->id; $userCoupon->order = $orderID; $userCoupon->save(); $usedCoupun = $coupons->used_coupon(); if ($coupons->limit <= $usedCoupun) { $coupons->is_active = 0; $coupons->save(); } } } Utility::referralTransaction($plan); $order = new Order(); $order->order_id = $orderID; $order->name = $user->name; $order->card_number = ''; $order->card_exp_month = ''; $order->card_exp_year = ''; $order->plan_name = $plan->name; $order->plan_id = $plan->id; $order->price = isset($request->TXNAMOUNT) ? $request->TXNAMOUNT : 0; $order->price_currency = isset($request->CURRENCY) ? $request->CURRENCY : 'USD'; $order->txn_id = isset($request->TXNID) ? $request->TXNID : ''; $order->payment_type = __('paytm'); $order->payment_status = 'success'; $order->receipt = ''; $order->user_id = $user->id; $order->save(); $assignPlan = $user->assignPlan($plan->id, $request->payment_frequency); if ($assignPlan['is_success']) { return redirect()->route('plans.index')->with('success', __('Plan activated Successfully!')); } else { return redirect()->route('plans.index')->with('error', __($assignPlan['error'])); } } else { return redirect()->route('plans.index')->with('error', __('Transaction has been failed! ')); } } catch (\Exception $e) { return redirect()->route('plans.index')->with('error', __('Plan not found!')); } } } } Controllers/CompanyPolicyController.php000064400000023421150364311770014426 0ustar00can('Manage Company Policy')) { $companyPolicy = CompanyPolicy::where('created_by', '=', \Auth::user()->creatorId())->with('branches')->get(); return view('companyPolicy.index', compact('companyPolicy')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } public function create() { if (\Auth::user()->can('Create Company Policy')) { $branch = Branch::where('created_by', \Auth::user()->creatorId())->get()->pluck('name', 'id'); $branch->prepend('Select Branch', ''); return view('companyPolicy.create', compact('branch')); } else { return response()->json(['error' => __('Permission denied.')], 401); } } public function store(Request $request) { if (\Auth::user()->can('Create Company Policy')) { $validator = \Validator::make( $request->all(), [ 'branch' => 'required', 'title' => 'required', 'attachment' => 'required', ] ); if ($validator->fails()) { $messages = $validator->getMessageBag(); return redirect()->back()->with('error', $messages->first()); } $policy = new CompanyPolicy(); $policy->branch = $request->branch; $policy->title = $request->title; $policy->description = !empty($request->description) ? $request->description : ''; $policy->created_by = \Auth::user()->creatorId(); if (!empty($request->attachment)) { $image_size = $request->file('attachment')->getSize(); $result = Utility::updateStorageLimit(\Auth::user()->creatorId(), $image_size); if ($result == 1) { $filenameWithExt = $request->file('attachment')->getClientOriginalName(); $filename = pathinfo($filenameWithExt, PATHINFO_FILENAME); $extension = $request->file('attachment')->getClientOriginalExtension(); $fileNameToStore = $filename . '_' . time() . '.' . $extension; $dir = 'uploads/companyPolicy/'; $image_path = $dir . $fileNameToStore; $url = ''; $path = Utility::upload_file($request, 'attachment', $fileNameToStore, $dir, []); $policy->attachment = !empty($request->attachment) ? $fileNameToStore : ''; if ($path['flag'] == 1) { $url = $path['url']; } else { return redirect()->back()->with('error', __($path['msg'])); } } } $policy->save(); // slack $setting = Utility::settings(\Auth::user()->creatorId()); $branch = Branch::find($request->branch); if (isset($setting['company_policy_notification']) && $setting['company_policy_notification'] == 1) { // $msg = $request->title . ' ' . __("for") . ' ' . $branch->name . ' ' . __("created") . '.'; $uArr = [ 'company_policy_name' => $request->title, 'branch_name' => $branch->name, ]; Utility::send_slack_msg('new_company_policy', $uArr); } // telegram $setting = Utility::settings(\Auth::user()->creatorId()); $branch = Branch::find($request->branch); if (isset($setting['telegram_company_policy_notification']) && $setting['telegram_company_policy_notification'] == 1) { // $msg = $request->title . ' ' . __("for") . ' ' . $branch->name . ' ' . __("created") . '.'; $uArr = [ 'company_policy_name' => $request->title, 'branch_name' => $branch->name, ]; Utility::send_telegram_msg('new_company_policy', $uArr); } //webhook $module = 'New Company Policy'; $webhook = Utility::webhookSetting($module); if ($webhook) { $parameter = json_encode($policy); // 1 parameter is URL , 2 parameter is data , 3 parameter is method $status = Utility::WebhookCall($webhook['url'], $parameter, $webhook['method']); if ($status == true) { return redirect()->back()->with('success', __('Company policy successfully created.')); } else { return redirect()->back()->with('error', __('Webhook call failed.')); } } // return redirect()->route('company-policy.index')->with('success', __('Company policy successfully created.')); return redirect()->route('company-policy.index')->with('success', __('Company policy successfully created.') . ((isset($result) && $result != 1) ? '
' . $result . '' : '')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } public function show(CompanyPolicy $companyPolicy) { // } public function edit(CompanyPolicy $companyPolicy) { if (\Auth::user()->can('Edit Company Policy')) { $branch = Branch::where('created_by', \Auth::user()->creatorId())->get()->pluck('name', 'id'); $branch->prepend('Select Branch', ''); return view('companyPolicy.edit', compact('branch', 'companyPolicy')); } else { return response()->json(['error' => __('Permission denied.')], 401); } } public function update(Request $request, CompanyPolicy $companyPolicy) { if (\Auth::user()->can('Create Company Policy')) { $validator = \Validator::make( $request->all(), [ 'branch' => 'required', 'title' => 'required', 'attachment' => 'required', ] ); if ($validator->fails()) { $messages = $validator->getMessageBag(); return redirect()->back()->with('error', $messages->first()); } $companyPolicy->branch = $request->branch; $companyPolicy->title = $request->title; $companyPolicy->description = $request->description; $companyPolicy->created_by = \Auth::user()->creatorId(); if (isset($request->attachment)) { $dir = 'uploads/companyPolicy/'; $file_path = $dir . $companyPolicy->attachment; $image_size = $request->file('attachment')->getSize(); $result = Utility::updateStorageLimit(\Auth::user()->creatorId(), $image_size); if ($result == 1) { Utility::changeStorageLimit(\Auth::user()->creatorId(), $file_path); $filenameWithExt = $request->file('attachment')->getClientOriginalName(); $filename = pathinfo($filenameWithExt, PATHINFO_FILENAME); $extension = $request->file('attachment')->getClientOriginalExtension(); $fileNameToStore = $filename . '_' . time() . '.' . $extension; $dir = 'uploads/companyPolicy/'; $image_path = $dir . $fileNameToStore; $url = ''; $path = Utility::upload_file($request, 'attachment', $fileNameToStore, $dir, []); $companyPolicy->attachment = $fileNameToStore; if ($path['flag'] == 1) { $url = $path['url']; } else { return redirect()->back()->with('error', __($path['msg'])); } } } $companyPolicy->save(); // return redirect()->route('company-policy.index')->with('success', __('Company policy successfully updated.')); return redirect()->route('company-policy.index')->with('success', __('Company policy successfully updated.') . ((isset($result) && $result != 1) ? '
' . $result . '' : '')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } public function destroy(CompanyPolicy $companyPolicy) { if (\Auth::user()->can('Delete Document')) { if ($companyPolicy->created_by == \Auth::user()->creatorId()) { $companyPolicy->delete(); // $dir = storage_path('uploads/companyPolicy/'); if (!empty($companyPolicy->attachment)) { //storage limit $file_path = 'uploads/companyPolicy/' . $companyPolicy->attachment; $result = Utility::changeStorageLimit(\Auth::user()->creatorId(), $file_path); // unlink($dir . $companyPolicy->attachment); } return redirect()->route('company-policy.index')->with('success', __('Company policy successfully deleted.')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } else { return redirect()->back()->with('error', __('Permission denied.')); } } } Controllers/PlanController.php000064400000033743150364311770012542 0ustar00can('Manage Plan')) { if (\Auth::user()->type == 'super admin') { $plans = Plan::get(); } else { $plans = Plan::where('is_disable', 1)->get(); } $admin_payment_setting = Utility::getAdminPaymentSetting(); return view('plan.index', compact('plans', 'admin_payment_setting')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } public function create() { if (\Auth::user()->can('Create Plan')) { $arrDuration = Plan::$arrDuration; return view('plan.create', compact('arrDuration')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } public function store(Request $request) { if (\Auth::user()->can('Create Plan')) { $admin_payment_setting = Utility::getAdminPaymentSetting(); if (!empty($admin_payment_setting) && ($admin_payment_setting['is_manually_enabled'] == 'on' || $admin_payment_setting['is_banktransfer_enabled'] == 'on' || $admin_payment_setting['is_stripe_enabled'] == 'on' || $admin_payment_setting['is_paypal_enabled'] == 'on' || $admin_payment_setting['is_paystack_enabled'] == 'on' || $admin_payment_setting['is_flutterwave_enabled'] == 'on' || $admin_payment_setting['is_razorpay_enabled'] == 'on' || $admin_payment_setting['is_mercado_enabled'] == 'on' || $admin_payment_setting['is_paytm_enabled'] == 'on' || $admin_payment_setting['is_mollie_enabled'] == 'on' || $admin_payment_setting['is_skrill_enabled'] == 'on' || $admin_payment_setting['is_coingate_enabled'] == 'on' || $admin_payment_setting['is_paymentwall_enabled'] == 'on' || $admin_payment_setting['is_toyyibpay_enabled'] == 'on' || $admin_payment_setting['is_payfast_enabled'] == 'on' || $admin_payment_setting['is_iyzipay_enabled'] == 'on' || $admin_payment_setting['is_sspay_enabled'] == 'on' || $admin_payment_setting['is_paytab_enabled'] == 'on' || $admin_payment_setting['is_benefit_enabled'] == 'on' || $admin_payment_setting['is_cashfree_enabled'] == 'on' || $admin_payment_setting['is_aamarpay_enabled'] == 'on' || $admin_payment_setting['is_paytr_enabled'] == 'on' || $admin_payment_setting['is_yookassa_enabled'] == 'on' || $admin_payment_setting['is_midtrans_enabled'] == 'on' || $admin_payment_setting['is_xendit_enabled'] == 'on' || $admin_payment_setting['is_nepalste_enabled'] == 'on' || $admin_payment_setting['is_paiementpro_enabled'] == 'on' || $admin_payment_setting['is_fedapay_enabled'] == 'on' || $admin_payment_setting['is_payhere_enabled'] == 'on' || $admin_payment_setting['is_cinetpay_enabled'] == 'on')) { $validator = \Validator::make( $request->all(), [ 'name' => 'required|unique:plans', 'price' => 'required|numeric|min:0', 'duration' => 'required', 'max_users' => 'required|numeric', 'max_employees' => 'required|numeric', 'storage_limit' => 'required', ] ); if ($validator->fails()) { $messages = $validator->getMessageBag(); return redirect()->back()->with('error', $messages->first()); } $post = $request->all(); if (!isset($request->enable_chatgpt)) { $post['enable_chatgpt'] = 'off'; } if ($request->trial == 1) { $post['trial_days'] = !empty($post['trial_days']) ? $post['trial_days'] : 0; } if (Plan::create($post)) { return redirect()->back()->with('success', __('Plan Successfully created.')); } else { return redirect()->back()->with('error', __('Something is wrong.')); } } else { return redirect()->back()->with('error', __('Please set stripe/paypal api key & secret key for add new plan')); } } else { return redirect()->back()->with('error', __('Permission denied.')); } } public function edit($plan_id) { if (\Auth::user()->can('Edit Plan')) { $arrDuration = Plan::$arrDuration; $plan = Plan::find($plan_id); return view('plan.edit', compact('plan', 'arrDuration')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } public function update(Request $request, $plan_id) { if (\Auth::user()->can('Edit Plan')) { $admin_payment_setting = Utility::getAdminPaymentSetting(); if (!empty($admin_payment_setting) && ($admin_payment_setting['is_manually_enabled'] == 'on' || $admin_payment_setting['is_banktransfer_enabled'] == 'on' || $admin_payment_setting['is_stripe_enabled'] == 'on' || $admin_payment_setting['is_paypal_enabled'] == 'on' || $admin_payment_setting['is_paystack_enabled'] == 'on' || $admin_payment_setting['is_flutterwave_enabled'] == 'on' || $admin_payment_setting['is_razorpay_enabled'] == 'on' || $admin_payment_setting['is_mercado_enabled'] == 'on' || $admin_payment_setting['is_paytm_enabled'] == 'on' || $admin_payment_setting['is_mollie_enabled'] == 'on' || $admin_payment_setting['is_skrill_enabled'] == 'on' || $admin_payment_setting['is_coingate_enabled'] == 'on' || $admin_payment_setting['is_paymentwall_enabled'] == 'on' || $admin_payment_setting['is_toyyibpay_enabled'] == 'on' || $admin_payment_setting['is_payfast_enabled'] == 'on' || $admin_payment_setting['is_iyzipay_enabled'] == 'on' || $admin_payment_setting['is_sspay_enabled'] == 'on' || $admin_payment_setting['is_paytab_enabled'] == 'on' || $admin_payment_setting['is_benefit_enabled'] == 'on' || $admin_payment_setting['is_cashfree_enabled'] == 'on' || $admin_payment_setting['is_aamarpay_enabled'] == 'on' || $admin_payment_setting['is_paytr_enabled'] == 'on' || $admin_payment_setting['is_yookassa_enabled'] == 'on' || $admin_payment_setting['is_midtrans_enabled'] == 'on' || $admin_payment_setting['is_xendit_enabled'] == 'on' || $admin_payment_setting['is_nepalste_enabled'] == 'on' || $admin_payment_setting['is_paiementpro_enabled'] == 'on' || $admin_payment_setting['is_fedapay_enabled'] == 'on' || $admin_payment_setting['is_payhere_enabled'] == 'on' || $admin_payment_setting['is_cinetpay_enabled'] == 'on')) { $plan = Plan::find($plan_id); if (!empty($plan)) { $rules = [ 'name' => 'required|unique:plans,name,' . $plan_id, 'max_users' => 'required|numeric', 'max_employees' => 'required|numeric', 'storage_limit' => 'required', ]; if ($plan_id != 1) { $rules['duration'] = [ 'required', ]; } $validator = \Validator::make( $request->all(), $rules ); if ($validator->fails()) { $messages = $validator->getMessageBag(); return redirect()->back()->with('error', $messages->first()); } $post = $request->all(); if (!isset($request->enable_chatgpt)) { $post['enable_chatgpt'] = 'off'; } if ($request->trial == 1) { $post['trial_days'] = !empty($post['trial_days']) ? $post['trial_days'] : 0; } else { $post['trial'] = 0; $post['trial_days'] = 0; } if ($plan->update($post)) { return redirect()->back()->with('success', __('Plan successfully updated.')); } else { return redirect()->back()->with('error', __('Something is wrong.')); } } else { return redirect()->back()->with('error', __('Plan not found.')); } } else { return redirect()->back()->with('error', __('Please set stripe/paypal api key & secret key for add new plan')); } } else { return redirect()->back()->with('error', __('Permission denied.')); } } // public function destroy($id) // { // $user = \Auth::user(); // $user = User::where('id', '=', $user->id)->first(); // $user->requested_plan = "0"; // $user->save(); // $plan = Plan::findOrFail($id); // PlanRequest::where('plan_id', $plan->id)->where('user_id', '=', $user->id)->delete(); // return redirect()->route('plans.index')->with('success', 'Plan request successfully deleted.'); // } public function destroy($id) { $userPlan = User::where('plan', $id)->first(); if ($userPlan != null) { return redirect()->back()->with('error', __('The company has subscribed to this plan, so it cannot be deleted.')); } $plan = Plan::find($id); if ($plan->id == $id) { $plan->delete(); return redirect()->back()->with('success', __('Plan deleted successfully')); } else { return redirect()->back()->with('error', __('Something went wrong')); } } public function plan_request($code) { $objUser = \Auth::user(); $plan_id = \Illuminate\Support\Facades\Crypt::decrypt($code); $plan = Plan::find($plan_id); $plan_request_check_user = PlanRequest::where('user_id', '=', $objUser->id)->first(); if ($plan_request_check_user) { return redirect()->back()->with('error', __('you already request sended for plan.')); } else { $planRequest = new PlanRequest(); $planRequest['user_id'] = $objUser->id; $planRequest['plan_id'] = $plan->id; $planRequest['duration'] = $plan->duration; $planRequest->save(); $objUser['requested_plan'] = $plan->id; $objUser->save(); return redirect()->back()->with('success', __('Plan request successfully sended.')); } } public function userPlan(Request $request) { if (\Auth::user()->can('Buy Plan')) { $objUser = \Auth::user(); $planID = \Illuminate\Support\Facades\Crypt::decrypt($request->code); $plan = Plan::find($planID); if ($plan) { if ($plan->price <= 0) { $objUser->assignPlan($plan->id); return redirect()->route('plans.index')->with('success', __('Plan successfully activated.')); } else { return redirect()->back()->with('error', __('Something is wrong.')); } } else { return redirect()->back()->with('error', __('Plan not found.')); } } else { return redirect()->back()->with('error', __('Permission denied.')); } } public function OrderDestroy(Request $request, $id) { if (\Auth::user()->type == 'super admin') { $order = Order::find($id); $file = $order->receipt; if (File::exists(storage_path('uploads/order/' . $file))) { File::delete(storage_path('uploads/order/' . $file)); } $order->delete(); return redirect()->route('order.index')->with('success', __('Order successfully deleted.')); } } public function PlanTrial($id) { if (\Auth::user()->can('Buy Plan') && \Auth::user()->type != 'super admin') { if (\Auth::user()->is_trial_done == false) { try { $id = Crypt::decrypt($id); } catch (\Throwable $th) { return redirect()->back()->with('error', __('Plan Not Found.')); } $plan = Plan::find($id); $user = User::where('id', \Auth::user()->id)->first(); $currentDate = date('Y-m-d'); $numberOfDaysToAdd = $plan->trial_days; $newDate = date('Y-m-d', strtotime($currentDate . ' + ' . $numberOfDaysToAdd . ' days')); if (!empty($plan->trial) == 1) { $user->assignPlan($plan->id); $user->trial_plan = $id; $user->trial_expire_date = $newDate; $user->save(); } return redirect()->back()->with('success', 'Your trial has been started.'); } else { return redirect()->back()->with('error', __('Your Plan trial already done.')); } } else { return redirect()->back()->with('error', __('Permission denied.')); } } public function planDisable(Request $request) { $userPlan = User::where('plan', $request->id)->first(); if ($userPlan != null) { return response()->json(['error' => __('The company has subscribed to this plan, so it cannot be disabled.')]); } Plan::where('id', $request->id)->update(['is_disable' => $request->is_disable]); if ($request->is_disable == 1) { return response()->json(['success' => __('Plan successfully enable.')]); } else { return response()->json(['success' => __('Plan successfully disable.')]); } } } Controllers/UserController.php000064400000044736150364311770012572 0ustar00can('Manage User')) { $user = \Auth::user(); if (\Auth::user()->type == 'super admin') { $users = User::where('created_by', '=', $user->creatorId())->where('type', '=', 'company')->with('currentPlan')->get(); $CountUser = User::where('created_by')->get(); } else { $users = User::where('created_by', '=', $user->creatorId())->where('type', '!=', 'employee')->get(); } return view('user.index', compact('users')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } public function create() { if (\Auth::user()->can('Create User')) { $user = \Auth::user(); $roles = Role::where('created_by', '=', $user->creatorId())->where('name', '!=', 'employee')->get()->pluck('name', 'id'); $roles->prepend('Select Role', ''); return view('user.create', compact('roles')); } else { return response()->json(['error' => __('Permission denied.')], 401); } } public function store(Request $request) { if (\Auth::user()->can('Create User')) { $default_language = DB::table('settings')->select('value')->where('name', 'default_language')->where('created_by', \Auth::user()->creatorId())->first(); // new company default language if ($default_language == null) { $default_language = DB::table('settings')->select('value')->where('name', 'default_language')->first(); } $validator = \Validator::make( $request->all(), [ 'name' => 'required', 'email' => 'required|unique:users', // 'password' => 'required', ] ); if ($validator->fails()) { $messages = $validator->getMessageBag(); return redirect()->back()->with('error', $messages->first()); } if (!empty($request->password_switch) && $request->password_switch == 'on') { $validator = \Validator::make( $request->all(), ['password' => 'required|min:6'] ); if ($validator->fails()) { return redirect()->back()->with('error', $validator->errors()->first()); } } do { $code = rand(100000, 999999); } while (User::where('referral_code', $code)->exists()); if (\Auth::user()->type == 'super admin') { $date = date("Y-m-d H:i:s"); $userpassword = $request->input('password'); $user = User::create( [ 'name' => $request['name'], 'email' => $request['email'], 'is_login_enable' => !empty($request->password_switch) && $request->password_switch == 'on' ? 1 : 0, 'password' => !empty($userpassword) ? Hash::make($userpassword) : null, 'type' => 'company', 'plan' => $plan = Plan::where('price', '<=', 0)->first()->id, 'lang' => !empty($default_language) ? $default_language->value : 'en', 'referral_code' => $code, 'created_by' => \Auth::user()->id, 'email_verified_at' => $date, ] ); $user->assignRole('Company'); $user->userDefaultData(); $user->userDefaultDataRegister($user->id); GenerateOfferLetter::defaultOfferLetterRegister($user->id); ExperienceCertificate::defaultExpCertificatRegister($user->id); JoiningLetter::defaultJoiningLetterRegister($user->id); NOC::defaultNocCertificateRegister($user->id); Utility::jobStage($user->id); $role_r = Role::findById(2); //create company default roles Utility::MakeRole($user->id); } else { $objUser = \Auth::user()->creatorId(); $objUser = User::find($objUser); $total_user = $objUser->countUsers(); $plan = Plan::find($objUser->plan); $userpassword = $request->input('password'); if ($total_user < $plan->max_users || $plan->max_users == -1) { $role_r = Role::findById($request->role); $date = date("Y-m-d H:i:s"); $user = User::create( [ 'name' => $request['name'], 'email' => $request['email'], 'is_login_enable' => !empty($request->password_switch) && $request->password_switch == 'on' ? 1 : 0, 'password' => !empty($userpassword) ? Hash::make($userpassword) : null, 'type' => $role_r->name, 'lang' => !empty($default_language) ? $default_language->value : 'en', 'created_by' => \Auth::user()->creatorId(), 'email_verified_at' => $date, ] ); $user->assignRole($role_r); } else { return redirect()->back()->with('error', __('Your user limit is over, Please upgrade plan.')); } } $setings = Utility::settings(); if ($setings['new_user'] == 1) { $uArr = [ 'email' => $user->email, 'password' => $request->password, ]; $resp = Utility::sendEmailTemplate('new_user', [$user->id => $user->email], $uArr); return redirect()->route('user.index')->with('success', __('User successfully created.') . ((!empty($resp) && $resp['is_success'] == false && !empty($resp['error'])) ? '
' . $resp['error'] . '' : '')); } return redirect()->route('user.index')->with('success', __('User successfully created.')); } else { return response()->json(['error' => __('Permission denied.')], 401); } } public function show(User $user) { return view('profile.index'); } public function edit($id) { if (\Auth::user()->can('Edit User')) { $user = User::find($id); $roles = Role::where('created_by', '=', $user->creatorId())->where('name', '!=', 'employee')->get()->pluck('name', 'id'); $roles->prepend('Select Role', ''); return view('user.edit', compact('user', 'roles')); } else { return response()->json(['error' => __('Permission denied.')], 401); } } public function update(Request $request, $id) { $validator = \Validator::make( $request->all(), [ 'name' => 'required', 'email' => 'unique:users,email,' . $id, ] ); if ($validator->fails()) { $messages = $validator->getMessageBag(); return redirect()->back()->with('error', $messages->first()); } if (\Auth::user()->type == 'super admin') { $user = User::findOrFail($id); $input = $request->all(); $user->fill($input)->save(); } else { $user = User::findOrFail($id); $role = Role::findById($request->role); $input = $request->all(); $input['type'] = $role->name; $user->fill($input)->save(); $user->assignRole($role); } return redirect()->route('user.index')->with('success', 'User successfully updated.'); } public function destroy($id) { if (\Auth::user()->can('Delete User')) { $user = User::findOrFail($id); $sub_employee = Employee::where('created_by', $user->id)->delete(); $sub_user = User::where('created_by', $user->id)->delete(); $user->delete(); return redirect()->route('user.index')->with('success', 'User successfully deleted.'); } else { return redirect()->back()->with('error', __('Permission denied.')); } } public function profile() { $userDetail = \Auth::user(); return view('user.profile')->with('userDetail', $userDetail); } public function editprofile(Request $request) { $userDetail = \Auth::user(); $user = User::findOrFail($userDetail['id']); $validator = \Validator::make( $request->all(), [ 'name' => 'required|max:120', 'email' => 'required|email|unique:users,email,' . $userDetail['id'], // 'profile' => 'required', ] ); if ($validator->fails()) { $messages = $validator->getMessageBag(); return redirect()->back()->with('error', $messages->first()); } if ($request->hasFile('profile')) { $filenameWithExt = $request->file('profile')->getClientOriginalName(); $filename = pathinfo($filenameWithExt, PATHINFO_FILENAME); $extension = $request->file('profile')->getClientOriginalExtension(); $fileNameToStore = $filename . '_' . time() . '.' . $extension; $dir = 'uploads/avatar'; $image_path = $dir . $userDetail['avatar']; if (File::exists($image_path)) { File::delete($image_path); } $url = ''; $path = Utility::upload_file($request, 'profile', $fileNameToStore, $dir, []); if ($path['flag'] == 1) { $url = $path['url']; } else { return redirect()->route('profile', \Auth::user()->id)->with('error', __($path['msg'])); } } if (!empty($request->profile)) { $user['avatar'] = $fileNameToStore; } $user['name'] = $request['name']; $user['email'] = $request['email']; $user->save(); if (\Auth::user()->type == 'employee') { $employee = Employee::where('user_id', $user->id)->first(); $employee->email = $request['email']; $employee->save(); } return redirect()->back()->with( 'success', 'Profile successfully updated.' ); } public function LoginManage($id) { $eId = \Crypt::decrypt($id); $user = User::find($eId); if ($user->is_login_enable == 1) { $user->is_login_enable = 0; $user->save(); return redirect()->route('user.index')->with('success', 'User login disable successfully.'); } else { $user->is_login_enable = 1; $user->save(); return redirect()->route('user.index')->with('success', 'User login enable successfully.'); } } public function userPassword($id) { $eId = \Crypt::decrypt($id); $user = User::find($eId); $employee = User::where('id', $eId)->first(); return view('user.reset', compact('user', 'employee')); } public function userPasswordReset(Request $request, $id) { $validator = \Validator::make( $request->all(), [ 'password' => 'required|confirmed|same:password_confirmation', ] ); if ($validator->fails()) { $messages = $validator->getMessageBag(); return redirect()->back()->with('error', $messages->first()); } $user = User::where('id', $id)->first(); $user->forceFill([ 'password' => Hash::make($request->password), 'is_login_enable' => 1, ])->save(); return redirect()->route('user.index')->with( 'success', 'User Password successfully updated.' ); } public function updatePassword(Request $request) { if (\Auth::Check()) { $request->validate( [ 'current_password' => 'required', 'new_password' => 'required|min:6', 'confirm_password' => 'required|same:new_password', ] ); $objUser = Auth::user(); $request_data = $request->All(); $current_password = $objUser->password; if (Hash::check($request_data['current_password'], $current_password)) { $user_id = Auth::User()->id; $obj_user = User::find($user_id); $obj_user->password = Hash::make($request_data['new_password']);; $obj_user->save(); return redirect()->route('profile', $objUser->id)->with('success', __('Password successfully updated.')); } else { return redirect()->route('profile', $objUser->id)->with('error', __('Please enter correct current password.')); } } else { return redirect()->route('profile', \Auth::user()->id)->with('error', __('Something is wrong.')); } } public function upgradePlan($user_id) { $user = User::find($user_id); $plans = Plan::where('is_disable', 1)->get(); return view('user.plan', compact('user', 'plans')); } public function activePlan($user_id, $plan_id) { $admin_payment_setting = Utility::getAdminPaymentSetting(); $user = User::find($user_id); $assignPlan = $user->assignPlan($plan_id); $plan = Plan::find($plan_id); if ($assignPlan['is_success'] == true && !empty($plan)) { $orderID = strtoupper(str_replace('.', '', uniqid('', true))); Order::create( [ 'order_id' => $orderID, 'name' => null, 'card_number' => null, 'card_exp_month' => null, 'card_exp_year' => null, 'plan_name' => $plan->name, 'plan_id' => $plan->id, 'price' => $plan->price, 'price_currency' => !empty($admin_payment_setting['currency']) ? $admin_payment_setting['currency'] : '$', 'txn_id' => '', 'payment_status' => 'succeeded', 'receipt' => null, 'user_id' => $user->id, ] ); return redirect()->back()->with('success', 'Plan successfully upgraded.'); } else { return redirect()->back()->with('error', 'Plan fail to upgrade.'); } } public function notificationSeen($user_id) { Notification::where('user_id', '=', $user_id)->update(['is_read' => 1]); return response()->json(['is_success' => true], 200); } public function LoginWithCompany(Request $request, User $user, $id) { $user = User::find($id); if ($user && auth()->check()) { Impersonate::take($request->user(), $user); return redirect('/dashboard'); } } public function ExitCompany(Request $request) { \Auth::user()->leaveImpersonation($request->user()); return redirect('/dashboard'); } public function CompnayInfo($id) { if (!empty($id)) { $data = $this->userCounter($id); if ($data['is_success']) { $users_data = $data['response']['users_data']; return view('user.companyinfo', compact('id', 'users_data')); } } else { return response()->json(['error' => __('Permission denied.')], 401); } } public function UserUnable(Request $request) { if (!empty($request->id) && !empty($request->company_id)) { if ($request->name == 'user') { User::where('id', $request->id)->update(['is_disable' => $request->is_disable]); $data = $this->userCounter($request->company_id); } if ($data['is_success']) { $users_data = $data['response']['users_data']; } if ($request->is_disable == 1) { return response()->json(['success' => __('Successfully Unable.'), 'users_data' => $users_data]); } else { return response()->json(['success' => __('Successfully Disable.'), 'users_data' => $users_data]); } } return response()->json('error'); } public function userCounter($id) { $response = []; if (!empty($id)) { $users = User::where('created_by', $id) ->selectRaw('COUNT(*) as total_users, SUM(CASE WHEN is_disable = 0 THEN 1 ELSE 0 END) as disable_users, SUM(CASE WHEN is_disable = 1 THEN 1 ELSE 0 END) as active_users') ->first(); $users_data = [ 'user_id' => !empty($id) ? $id : 0, 'total_users' => !empty($users->total_users) ? $users->total_users : 0, 'disable_users' => !empty($users->disable_users) ? $users->disable_users : 0, 'active_users' => !empty($users->active_users) ? $users->active_users : 0, ]; $response['users_data'] = $users_data; return [ 'is_success' => true, 'response' => $response, ]; } return [ 'is_success' => false, 'error' => 'User ID is invalid.', ]; } } Controllers/CoingatePaymentController.php000064400000023344150364311770014733 0ustar00type == 'company') { $admin_payment_setting = Utility::getAdminPaymentSetting(); $this->coingate_auth_token = isset($admin_payment_setting['coingate_auth_token']) ? $admin_payment_setting['coingate_auth_token'] : ''; $this->mode = isset($admin_payment_setting['coingate_mode']) ? $admin_payment_setting['coingate_mode'] : 'off'; $this->is_enabled = isset($admin_payment_setting['is_coingate_enabled']) ? $admin_payment_setting['is_coingate_enabled'] : 'off'; return $this; } } public function planPayWithCoingate(Request $request) { $admin_payment_setting = Utility::getAdminPaymentSetting(); $payment = $this->paymentConfig(); $planID = \Illuminate\Support\Facades\Crypt::decrypt($request->plan_id); $plan = Plan::find($planID); $authuser = Auth::user(); $coupons_id = ''; if ($plan) { $price = $plan->price; if (isset($request->coupon) && !empty($request->coupon)) { $request->coupon = trim($request->coupon); $coupons = Coupon::where('code', strtoupper($request->coupon))->where('is_active', '1')->first(); if (!empty($coupons)) { $usedCoupun = $coupons->used_coupon(); $discount_value = ($price / 100) * $coupons->discount; $plan->discounted_price = $price - $discount_value; $coupons_id = $coupons->id; if ($usedCoupun >= $coupons->limit) { return redirect()->back()->with('error', __('This coupon code has expired.')); } $price = $price - $discount_value; } else { return redirect()->back()->with('error', __('This coupon code is invalid or has expired.')); } } if ($price <= 0) { $authuser->plan = $plan->id; $authuser->save(); $assignPlan = $authuser->assignPlan($plan->id); if ($assignPlan['is_success'] == true && !empty($plan)) { $orderID = time(); $user = Auth::user(); if ($request->has('coupon') && $request->coupon != '') { $coupons = Coupon::where('code', strtoupper($request->coupon))->where('is_active', '1')->first(); if (!empty($coupons)) { $userCoupon = new UserCoupon(); $userCoupon->user = $user->id; $userCoupon->coupon = $coupons->id; $userCoupon->order = $orderID; $userCoupon->save(); $usedCoupun = $coupons->used_coupon(); if ($coupons->limit <= $usedCoupun) { $coupons->is_active = 0; $coupons->save(); } } } Order::create( [ 'order_id' => $orderID, 'name' => null, 'email' => null, 'card_number' => null, 'card_exp_month' => null, 'card_exp_year' => null, 'plan_name' => $plan->name, 'plan_id' => $plan->id, 'price' => $price == null ? 0 : $price, 'price_currency' => !empty($admin_payment_setting['currency']) ? $admin_payment_setting['currency'] : 'USD', 'txn_id' => '', 'payment_type' => 'coingate', 'payment_status' => 'succeeded', 'receipt' => null, 'user_id' => $authuser->id, ] ); $assignPlan = $authuser->assignPlan($plan->id); return redirect()->route('plans.index')->with('success', __('Plan activated Successfully!')); } else { return redirect()->back()->with('error', __('Plan fail to upgrade.')); } } CoinGate::config( array( 'environment' => $payment->mode, 'auth_token' => $payment->coingate_auth_token, 'curlopt_ssl_verifypeer' => FALSE, ) ); $post_params = array( 'order_id' => time(), 'price_amount' => $price, 'price_currency' => $admin_payment_setting['currency'], 'receive_currency' => $admin_payment_setting['currency'], 'callback_url' => route( 'plan.coingate', [ $request->plan_id, 'coupon_id=' . $coupons_id, 'price' => $price, ] ), 'cancel_url' => route('stripe', [$request->plan_id]), 'success_url' => route( 'plan.coingate', [ $request->plan_id, 'coupon_id=' . $coupons_id, 'price' => $price, ] ), 'title' => 'Plan #' . time(), ); try { $order = \CoinGate\Merchant\Order::create($post_params); } catch (\Exception $e) { return redirect()->back()->with('error', __('BadAuthToken Auth Token is not valid.')); } if ($order) { return redirect($order->payment_url); } else { return redirect()->back()->with('error', __('opps something wren wrong.')); } } else { return redirect()->back()->with('error', 'Plan is deleted.'); } } public function getPaymentStatus(Request $request, $plan) { $this->paymentConfig(); // $user = Auth::user(); // $plan_id = $request->plan_id; // $admin_payment_setting = Utility::getAdminPaymentSetting(); // $planID = \Illuminate\Support\Facades\Crypt::decrypt($plan); // $plan = Plan::find($plan_id); // $price = !empty($plan->price) ? $plan->price : ''; $admin_payment_setting = Utility::getAdminPaymentSetting(); $planID = \Illuminate\Support\Facades\Crypt::decrypt($plan); $plan = Plan::find($planID); $user = Auth::user(); $orderID = time(); if ($plan) { try { $orderID = time(); if ($request->has('coupon_id') && $request->coupon_id != '') { $coupons = Coupon::find($request->coupon_id); if (!empty($coupons)) { $userCoupon = new UserCoupon(); $userCoupon->user = $user->id; $userCoupon->coupon = $coupons->id; $userCoupon->order = $orderID; $userCoupon->save(); $usedCoupun = $coupons->used_coupon(); if ($coupons->limit <= $usedCoupun) { $coupons->is_active = 0; $coupons->save(); } } } Utility::referralTransaction($plan); $order = new Order(); $order->order_id = $orderID; $order->name = $user->name; $order->card_number = ''; $order->card_exp_month = ''; $order->card_exp_year = ''; $order->plan_name = $plan->name; $order->plan_id = $plan->id; $order->price = $request->price ? $request->price : 0; $order->price_currency = $admin_payment_setting['currency']; $order->txn_id = isset($request->transaction_id) ? $request->transaction_id : ''; $order->payment_type = __('Coingate'); $order->payment_status = 'success'; $order->receipt = ''; $order->user_id = $user->id; $order->save(); $assignPlan = $user->assignPlan($plan->id); if ($assignPlan['is_success']) { return redirect()->route('plans.index')->with('success', __('Plan activated Successfully.')); } else { return redirect()->route('plans.index')->with('error', $assignPlan['error']); } } catch (\Exception $e) { return redirect()->route('plans.index')->with('error', __('Transaction has been failed.')); } } else { return redirect()->route('plans.index')->with('error', __('Plan is deleted.')); } } } Controllers/CustomQuestionController.php000064400000006410150364311770014641 0ustar00can('Manage Custom Question')) { $questions = CustomQuestion::where('created_by', \Auth::user()->creatorId())->get(); return view('customQuestion.index', compact('questions')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } public function create() { $is_required = CustomQuestion::$is_required; return view('customQuestion.create', compact('is_required')); } public function store(Request $request) { if(\Auth::user()->can('Create Custom Question')) { $validator = \Validator::make( $request->all(), [ 'question' => 'required', ] ); if($validator->fails()) { $messages = $validator->getMessageBag(); return redirect()->back()->with('error', $messages->first()); } $question = new CustomQuestion(); $question->question = $request->question; $question->is_required = $request->is_required; $question->created_by = \Auth::user()->creatorId(); $question->save(); return redirect()->back()->with('success', __('Question successfully created.')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } public function show(CustomQuestion $customQuestion) { // } public function edit(CustomQuestion $customQuestion) { $is_required = CustomQuestion::$is_required; return view('customQuestion.edit', compact('customQuestion','is_required')); } public function update(Request $request, CustomQuestion $customQuestion) { if(\Auth::user()->can('Edit Custom Question')) { $validator = \Validator::make( $request->all(), [ 'question' => 'required', ] ); if($validator->fails()) { $messages = $validator->getMessageBag(); return redirect()->back()->with('error', $messages->first()); } $customQuestion->question = $request->question; $customQuestion->is_required = $request->is_required; $customQuestion->save(); return redirect()->back()->with('success', __('Question successfully updated.')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } public function destroy(CustomQuestion $customQuestion) { if(\Auth::user()->can('Delete Custom Question')) { $customQuestion->delete(); return redirect()->back()->with('success', __('Question successfully deleted.')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } } Controllers/AttendanceEmployeeController.php000064400000130272150364311770015411 0ustar00can('Manage Attendance')) { $branch = Branch::where('created_by', \Auth::user()->creatorId())->get()->pluck('name', 'id'); $branch->prepend('All', ''); $department = Department::where('created_by', \Auth::user()->creatorId())->get()->pluck('name', 'id'); $department->prepend('All', ''); if (\Auth::user()->type == 'employee') { $emp = !empty(\Auth::user()->employee) ? \Auth::user()->employee->id : 0; $attendanceEmployee = AttendanceEmployee::where('employee_id', $emp); if ($request->type == 'monthly' && !empty($request->month)) { $month = date('m', strtotime($request->month)); $year = date('Y', strtotime($request->month)); $start_date = date($year . '-' . $month . '-01'); $end_date = date('Y-m-t', strtotime('01-' . $month . '-' . $year)); // old date // $end_date = date($year . '-' . $month . '-t'); $attendanceEmployee->whereBetween( 'date', [ $start_date, $end_date, ] ); } elseif ($request->type == 'daily' && !empty($request->date)) { $attendanceEmployee->where('date', $request->date); } else { $month = date('m'); $year = date('Y'); $start_date = date($year . '-' . $month . '-01'); $end_date = date('Y-m-t', strtotime('01-' . $month . '-' . $year)); // old date // $end_date = date($year . '-' . $month . '-t'); $attendanceEmployee->whereBetween( 'date', [ $start_date, $end_date, ] ); } $attendanceEmployee = $attendanceEmployee->get(); } else { $employee = Employee::select('id')->where('created_by', \Auth::user()->creatorId()); if (!empty($request->branch)) { $employee->where('branch_id', $request->branch); } if (!empty($request->department)) { $employee->where('department_id', $request->department); } $employee = $employee->get()->pluck('id'); $attendanceEmployee = AttendanceEmployee::whereIn('employee_id', $employee); if ($request->type == 'monthly' && !empty($request->month)) { $month = date('m', strtotime($request->month)); $year = date('Y', strtotime($request->month)); $start_date = date($year . '-' . $month . '-01'); $end_date = date('Y-m-t', strtotime('01-' . $month . '-' . $year)); // old date // $end_date = date($year . '-' . $month . '-t'); $attendanceEmployee->whereBetween( 'date', [ $start_date, $end_date, ] ); } elseif ($request->type == 'daily' && !empty($request->date)) { $attendanceEmployee->where('date', $request->date); } else { $month = date('m'); $year = date('Y'); $start_date = date($year . '-' . $month . '-01'); $end_date = date('Y-m-t', strtotime('01-' . $month . '-' . $year)); // old date // $end_date = date($year . '-' . $month . '-t'); $attendanceEmployee->whereBetween( 'date', [ $start_date, $end_date, ] ); } $attendanceEmployee = $attendanceEmployee->get(); } return view('attendance.index', compact('attendanceEmployee', 'branch', 'department')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } public function create() { if (\Auth::user()->can('Create Attendance')) { $employees = User::where('created_by', '=', Auth::user()->creatorId())->where('type', '=', "employee")->get()->pluck('name', 'id'); return view('attendance.create', compact('employees')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } public function store(Request $request) { if (\Auth::user()->can('Create Attendance')) { $validator = \Validator::make( $request->all(), [ 'employee_id' => 'required', 'date' => 'required', 'clock_in' => 'required', 'clock_out' => 'required', ] ); if ($validator->fails()) { $messages = $validator->getMessageBag(); return redirect()->back()->with('error', $messages->first()); } $startTime = Utility::getValByName('company_start_time'); $endTime = Utility::getValByName('company_end_time'); $attendance = AttendanceEmployee::where('employee_id', '=', $request->employee_id)->where('date', '=', $request->date)->where('clock_out', '=', '00:00:00')->get()->toArray(); if ($attendance) { return redirect()->route('attendanceemployee.index')->with('error', __('Employee Attendance Already Created.')); } else { $date = date("Y-m-d"); $totalLateSeconds = strtotime($request->clock_in) - strtotime($date . $startTime); $hours = floor($totalLateSeconds / 3600); $mins = floor($totalLateSeconds / 60 % 60); $secs = floor($totalLateSeconds % 60); $late = sprintf('%02d:%02d:%02d', $hours, $mins, $secs); //early Leaving $totalEarlyLeavingSeconds = strtotime($date . $endTime) - strtotime($request->clock_out); $hours = floor($totalEarlyLeavingSeconds / 3600); $mins = floor($totalEarlyLeavingSeconds / 60 % 60); $secs = floor($totalEarlyLeavingSeconds % 60); $earlyLeaving = sprintf('%02d:%02d:%02d', $hours, $mins, $secs); if (strtotime($request->clock_out) > strtotime($date . $endTime)) { //Overtime $totalOvertimeSeconds = strtotime($request->clock_out) - strtotime($date . $endTime); $hours = floor($totalOvertimeSeconds / 3600); $mins = floor($totalOvertimeSeconds / 60 % 60); $secs = floor($totalOvertimeSeconds % 60); $overtime = sprintf('%02d:%02d:%02d', $hours, $mins, $secs); } else { $overtime = '00:00:00'; } $employeeAttendance = new AttendanceEmployee(); $employeeAttendance->employee_id = $request->employee_id; $employeeAttendance->date = $request->date; $employeeAttendance->status = 'Present'; $employeeAttendance->clock_in = $request->clock_in . ':00'; $employeeAttendance->clock_out = $request->clock_out . ':00'; $employeeAttendance->late = $late; $employeeAttendance->early_leaving = $earlyLeaving; $employeeAttendance->overtime = $overtime; $employeeAttendance->total_rest = '00:00:00'; $employeeAttendance->created_by = \Auth::user()->creatorId(); $employeeAttendance->save(); return redirect()->route('attendanceemployee.index')->with('success', __('Employee attendance successfully created.')); } } else { return redirect()->back()->with('error', __('Permission denied.')); } } public function show(Request $request) { // return redirect()->back(); return redirect()->route('attendanceemployee.index'); } public function edit($id) { if (\Auth::user()->can('Edit Attendance')) { $attendanceEmployee = AttendanceEmployee::where('id', $id)->first(); $employees = Employee::where('created_by', '=', \Auth::user()->creatorId())->get()->pluck('name', 'id'); return view('attendance.edit', compact('attendanceEmployee', 'employees')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } // public function update(Request $request, $id) // { // if (\Auth::user()->type == 'company' || \Auth::user()->type == 'hr') { // $employeeId = AttendanceEmployee::where('employee_id', $request->employee_id)->first(); // $check = AttendanceEmployee::where('employee_id', '=', $request->employee_id)->where('date', $request->date)->first(); // $startTime = Utility::getValByName('company_start_time'); // $endTime = Utility::getValByName('company_end_time'); // $clockIn = $request->clock_in; // $clockOut = $request->clock_out; // if ($clockIn) { // $status = "present"; // } else { // $status = "leave"; // } // $totalLateSeconds = strtotime($clockIn) - strtotime($startTime); // $hours = floor($totalLateSeconds / 3600); // $mins = floor($totalLateSeconds / 60 % 60); // $secs = floor($totalLateSeconds % 60); // $late = sprintf('%02d:%02d:%02d', $hours, $mins, $secs); // $totalEarlyLeavingSeconds = strtotime($endTime) - strtotime($clockOut); // $hours = floor($totalEarlyLeavingSeconds / 3600); // $mins = floor($totalEarlyLeavingSeconds / 60 % 60); // $secs = floor($totalEarlyLeavingSeconds % 60); // $earlyLeaving = sprintf('%02d:%02d:%02d', $hours, $mins, $secs); // if (strtotime($clockOut) > strtotime($endTime)) { // //Overtime // $totalOvertimeSeconds = strtotime($clockOut) - strtotime($endTime); // $hours = floor($totalOvertimeSeconds / 3600); // $mins = floor($totalOvertimeSeconds / 60 % 60); // $secs = floor($totalOvertimeSeconds % 60); // $overtime = sprintf('%02d:%02d:%02d', $hours, $mins, $secs); // } else { // $overtime = '00:00:00'; // } // if ($check->date == date('Y-m-d')) { // $check->update([ // 'late' => $late, // 'early_leaving' => ($earlyLeaving > 0) ? $earlyLeaving : '00:00:00', // 'overtime' => $overtime, // 'clock_in' => $clockIn, // 'clock_out' => $clockOut // ]); // return redirect()->route('attendanceemployee.index')->with('success', __('Employee attendance successfully updated.')); // } else { // return redirect()->route('attendanceemployee.index')->with('error', __('You can only update current day attendance')); // } // } // $employeeId = !empty(\Auth::user()->employee) ? \Auth::user()->employee->id : 0; // $todayAttendance = AttendanceEmployee::where('employee_id', '=', $employeeId)->where('date', date('Y-m-d'))->first(); // if (!empty($todayAttendance) && $todayAttendance->clock_out == '00:00:00') { // $startTime = Utility::getValByName('company_start_time'); // $endTime = Utility::getValByName('company_end_time'); // if (Auth::user()->type == 'employee') { // $date = date("Y-m-d"); // $time = date("H:i:s"); // //early Leaving // $totalEarlyLeavingSeconds = strtotime($date . $endTime) - time(); // $hours = floor($totalEarlyLeavingSeconds / 3600); // $mins = floor($totalEarlyLeavingSeconds / 60 % 60); // $secs = floor($totalEarlyLeavingSeconds % 60); // $earlyLeaving = sprintf('%02d:%02d:%02d', $hours, $mins, $secs); // if (time() > strtotime($date . $endTime)) { // //Overtime // $totalOvertimeSeconds = time() - strtotime($date . $endTime); // $hours = floor($totalOvertimeSeconds / 3600); // $mins = floor($totalOvertimeSeconds / 60 % 60); // $secs = floor($totalOvertimeSeconds % 60); // $overtime = sprintf('%02d:%02d:%02d', $hours, $mins, $secs); // } else { // $overtime = '00:00:00'; // } // $attendanceEmployee = AttendanceEmployee::find($id); // $attendanceEmployee->clock_out = $time; // $attendanceEmployee->early_leaving = $earlyLeaving; // $attendanceEmployee->overtime = $overtime; // $attendanceEmployee->save(); // return redirect()->route('dashboard')->with('success', __('Employee successfully clock Out.')); // } else { // $date = date("Y-m-d"); // //late // $totalLateSeconds = strtotime($request->clock_in) - strtotime($date . $startTime); // $hours = floor($totalLateSeconds / 3600); // $mins = floor($totalLateSeconds / 60 % 60); // $secs = floor($totalLateSeconds % 60); // $late = sprintf('%02d:%02d:%02d', $hours, $mins, $secs); // //early Leaving // $totalEarlyLeavingSeconds = strtotime($date . $endTime) - strtotime($request->clock_out); // $hours = floor($totalEarlyLeavingSeconds / 3600); // $mins = floor($totalEarlyLeavingSeconds / 60 % 60); // $secs = floor($totalEarlyLeavingSeconds % 60); // $earlyLeaving = sprintf('%02d:%02d:%02d', $hours, $mins, $secs); // if (strtotime($request->clock_out) > strtotime($date . $endTime)) { // //Overtime // $totalOvertimeSeconds = strtotime($request->clock_out) - strtotime($date . $endTime); // $hours = floor($totalOvertimeSeconds / 3600); // $mins = floor($totalOvertimeSeconds / 60 % 60); // $secs = floor($totalOvertimeSeconds % 60); // $overtime = sprintf('%02d:%02d:%02d', $hours, $mins, $secs); // } else { // $overtime = '00:00:00'; // } // $attendanceEmployee = AttendanceEmployee::find($id); // $attendanceEmployee->employee_id = $request->employee_id; // $attendanceEmployee->date = $request->date; // $attendanceEmployee->clock_in = $request->clock_in; // $attendanceEmployee->clock_out = $request->clock_out; // $attendanceEmployee->late = $late; // $attendanceEmployee->early_leaving = $earlyLeaving; // $attendanceEmployee->overtime = $overtime; // $attendanceEmployee->total_rest = '00:00:00'; // $attendanceEmployee->save(); // return redirect()->route('attendanceemployee.index')->with('success', __('Employee attendance successfully updated.')); // } // } else { // return redirect()->back()->with('error', __('Employee are not allow multiple time clock in & clock for every day.')); // } // } public function update(Request $request, $id) { if (\Auth::user()->type == 'company' || \Auth::user()->type == 'hr') { $employeeId = AttendanceEmployee::where('employee_id', $request->employee_id)->first(); $check = AttendanceEmployee::where('id', '=', $id)->where('employee_id', '=', $request->employee_id)->where('date', $request->date)->first(); $startTime = Utility::getValByName('company_start_time'); $endTime = Utility::getValByName('company_end_time'); $clockIn = $request->clock_in; $clockOut = $request->clock_out; if ($clockIn) { $status = "present"; } else { $status = "leave"; } $totalLateSeconds = strtotime($clockIn) - strtotime($startTime); $hours = floor($totalLateSeconds / 3600); $mins = floor($totalLateSeconds / 60 % 60); $secs = floor($totalLateSeconds % 60); $late = sprintf('%02d:%02d:%02d', $hours, $mins, $secs); $totalEarlyLeavingSeconds = strtotime($endTime) - strtotime($clockOut); $hours = floor($totalEarlyLeavingSeconds / 3600); $mins = floor($totalEarlyLeavingSeconds / 60 % 60); $secs = floor($totalEarlyLeavingSeconds % 60); $earlyLeaving = sprintf('%02d:%02d:%02d', $hours, $mins, $secs); if (strtotime($clockOut) > strtotime($endTime)) { //Overtime $totalOvertimeSeconds = strtotime($clockOut) - strtotime($endTime); $hours = floor($totalOvertimeSeconds / 3600); $mins = floor($totalOvertimeSeconds / 60 % 60); $secs = floor($totalOvertimeSeconds % 60); $overtime = sprintf('%02d:%02d:%02d', $hours, $mins, $secs); } else { $overtime = '00:00:00'; } if ($check->date == date('Y-m-d')) { $check->update([ 'late' => $late, 'early_leaving' => ($earlyLeaving > 0) ? $earlyLeaving : '00:00:00', 'overtime' => $overtime, 'clock_in' => $clockIn, 'clock_out' => $clockOut ]); return redirect()->route('attendanceemployee.index')->with('success', __('Employee attendance successfully updated.')); } else { return redirect()->route('attendanceemployee.index')->with('error', __('You can only update current day attendance.')); } } $employeeId = !empty(\Auth::user()->employee) ? \Auth::user()->employee->id : 0; $todayAttendance = AttendanceEmployee::where('employee_id', '=', $employeeId)->where('date', date('Y-m-d'))->first(); $startTime = Utility::getValByName('company_start_time'); $endTime = Utility::getValByName('company_end_time'); if (Auth::user()->type == 'employee') { $date = date("Y-m-d"); $time = date("H:i:s"); //early Leaving $totalEarlyLeavingSeconds = strtotime($date . $endTime) - time(); $hours = floor($totalEarlyLeavingSeconds / 3600); $mins = floor($totalEarlyLeavingSeconds / 60 % 60); $secs = floor($totalEarlyLeavingSeconds % 60); $earlyLeaving = sprintf('%02d:%02d:%02d', $hours, $mins, $secs); if (time() > strtotime($date . $endTime)) { //Overtime $totalOvertimeSeconds = time() - strtotime($date . $endTime); $hours = floor($totalOvertimeSeconds / 3600); $mins = floor($totalOvertimeSeconds / 60 % 60); $secs = floor($totalOvertimeSeconds % 60); $overtime = sprintf('%02d:%02d:%02d', $hours, $mins, $secs); } else { $overtime = '00:00:00'; } $attendanceEmployee['clock_out'] = $time; $attendanceEmployee['early_leaving'] = $earlyLeaving; $attendanceEmployee['overtime'] = $overtime; if (!empty($request->date)) { $attendanceEmployee['date'] = $request->date; } AttendanceEmployee::where('id', $id)->update($attendanceEmployee); return redirect()->route('dashboard')->with('success', __('Employee successfully clock Out.')); } else { $date = date("Y-m-d"); $clockout_time = date("H:i:s"); //late $totalLateSeconds = strtotime($clockout_time) - strtotime($date . $startTime); $hours = abs(floor($totalLateSeconds / 3600)); $mins = abs(floor($totalLateSeconds / 60 % 60)); $secs = abs(floor($totalLateSeconds % 60)); $late = sprintf('%02d:%02d:%02d', $hours, $mins, $secs); //early Leaving $totalEarlyLeavingSeconds = strtotime($date . $endTime) - strtotime($clockout_time); $hours = floor($totalEarlyLeavingSeconds / 3600); $mins = floor($totalEarlyLeavingSeconds / 60 % 60); $secs = floor($totalEarlyLeavingSeconds % 60); $earlyLeaving = sprintf('%02d:%02d:%02d', $hours, $mins, $secs); if (strtotime($clockout_time) > strtotime($date . $endTime)) { //Overtime $totalOvertimeSeconds = strtotime($clockout_time) - strtotime($date . $endTime); $hours = floor($totalOvertimeSeconds / 3600); $mins = floor($totalOvertimeSeconds / 60 % 60); $secs = floor($totalOvertimeSeconds % 60); $overtime = sprintf('%02d:%02d:%02d', $hours, $mins, $secs); } else { $overtime = '00:00:00'; } $attendanceEmployee = AttendanceEmployee::find($id); $attendanceEmployee->clock_out = $clockout_time; $attendanceEmployee->late = $late; $attendanceEmployee->early_leaving = $earlyLeaving; $attendanceEmployee->overtime = $overtime; $attendanceEmployee->total_rest = '00:00:00'; $attendanceEmployee->save(); return redirect()->back()->with('success', __('Employee attendance successfully updated.')); } } public function destroy($id) { if (\Auth::user()->can('Delete Attendance')) { $attendance = AttendanceEmployee::where('id', $id)->first(); $attendance->delete(); return redirect()->route('attendanceemployee.index')->with('success', __('Attendance successfully deleted.')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } // public function attendance(Request $request) // { // $settings = Utility::settings(); // if ($settings['ip_restrict'] == 'on') { // $userIp = request()->ip(); // $ip = IpRestrict::where('created_by', \Auth::user()->creatorId())->whereIn('ip', [$userIp])->first(); // if (!empty($ip)) { // return redirect()->back()->with('error', __('this ip is not allowed to clock in & clock out.')); // } // } // $employeeId = !empty(\Auth::user()->employee) ? \Auth::user()->employee->id : 0; // $todayAttendance = AttendanceEmployee::where('employee_id', '=', $employeeId)->where('date', date('Y-m-d'))->first(); // if (empty($todayAttendance)) { // $startTime = Utility::getValByName('company_start_time'); // $endTime = Utility::getValByName('company_end_time'); // $attendance = AttendanceEmployee::orderBy('id', 'desc')->where('employee_id', '=', $employeeId)->where('clock_out', '=', '00:00:00')->first(); // if ($attendance != null) { // $attendance = AttendanceEmployee::find($attendance->id); // $attendance->clock_out = $endTime; // $attendance->save(); // } // $date = date("Y-m-d"); // $time = date("H:i:s"); // //late // $totalLateSeconds = time() - strtotime($date . $startTime); // $hours = floor($totalLateSeconds / 3600); // $mins = floor($totalLateSeconds / 60 % 60); // $secs = floor($totalLateSeconds % 60); // $late = sprintf('%02d:%02d:%02d', $hours, $mins, $secs); // $checkDb = AttendanceEmployee::where('employee_id', '=', \Auth::user()->id)->get()->toArray(); // if (empty($checkDb)) { // $employeeAttendance = new AttendanceEmployee(); // $employeeAttendance->employee_id = $employeeId; // $employeeAttendance->date = $date; // $employeeAttendance->status = 'Present'; // $employeeAttendance->clock_in = $time; // $employeeAttendance->clock_out = '00:00:00'; // $employeeAttendance->late = $late; // $employeeAttendance->early_leaving = '00:00:00'; // $employeeAttendance->overtime = '00:00:00'; // $employeeAttendance->total_rest = '00:00:00'; // $employeeAttendance->created_by = \Auth::user()->id; // $employeeAttendance->save(); // return redirect()->route('dashboard')->with('success', __('Employee Successfully Clock In.')); // } // foreach ($checkDb as $check) { // $employeeAttendance = new AttendanceEmployee(); // $employeeAttendance->employee_id = $employeeId; // $employeeAttendance->date = $date; // $employeeAttendance->status = 'Present'; // $employeeAttendance->clock_in = $time; // $employeeAttendance->clock_out = '00:00:00'; // $employeeAttendance->late = $late; // $employeeAttendance->early_leaving = '00:00:00'; // $employeeAttendance->overtime = '00:00:00'; // $employeeAttendance->total_rest = '00:00:00'; // $employeeAttendance->created_by = \Auth::user()->id; // $employeeAttendance->save(); // return redirect()->route('dashboard')->with('success', __('Employee Successfully Clock In.')); // } // } else { // return redirect()->back()->with('error', __('Employee are not allow multiple time clock in & clock for every day.')); // } // } public function attendance(Request $request) { $settings = Utility::settings(); if (!empty($settings['ip_restrict']) && $settings['ip_restrict'] == 'on') { $userIp = request()->ip(); $ip = IpRestrict::where('created_by', Auth::user()->creatorId())->whereIn('ip', [$userIp])->first(); if (empty($ip)) { return redirect()->back()->with('error', __('This IP is not allowed to clock in & clock out.')); } } $employeeId = !empty(\Auth::user()->employee) ? \Auth::user()->employee->id : 0; $startTime = Utility::getValByName('company_start_time'); $endTime = Utility::getValByName('company_end_time'); // Find the last clocked out entry for the employee $lastClockOutEntry = AttendanceEmployee::orderBy('id', 'desc') ->where('employee_id', '=', $employeeId) ->where('clock_out', '!=', '00:00:00') ->where('date', '=', date('Y-m-d')) ->first(); $date = date("Y-m-d"); $time = date("H:i:s"); if ($lastClockOutEntry != null) { // Calculate late based on the difference between the last clock-out time and the current clock-in time $lastClockOutTime = $lastClockOutEntry->clock_out; $actualClockInTime = $date . ' ' . $time; $totalLateSeconds = strtotime($actualClockInTime) - strtotime($date . ' ' . $lastClockOutTime); // Ensure late time is non-negative $totalLateSeconds = max($totalLateSeconds, 0); $hours = abs(floor($totalLateSeconds / 3600)); $mins = abs(floor($totalLateSeconds / 60 % 60)); $secs = abs(floor($totalLateSeconds % 60)); $late = sprintf('%02d:%02d:%02d', $hours, $mins, $secs); } else { // If there is no previous clock-out entry, assume no lateness $expectedStartTime = $date . ' ' . $startTime; $actualClockInTime = $date . ' ' . $time; $totalLateSeconds = strtotime($actualClockInTime) - strtotime($expectedStartTime); // Ensure late time is non-negative $totalLateSeconds = max($totalLateSeconds, 0); $hours = abs(floor($totalLateSeconds / 3600)); $mins = abs(floor($totalLateSeconds / 60 % 60)); $secs = abs(floor($totalLateSeconds % 60)); $late = sprintf('%02d:%02d:%02d', $hours, $mins, $secs); } $checkDb = AttendanceEmployee::where('employee_id', '=', \Auth::user()->id)->get()->toArray(); if (empty($checkDb)) { $employeeAttendance = new AttendanceEmployee(); $employeeAttendance->employee_id = $employeeId; $employeeAttendance->date = $date; $employeeAttendance->status = 'Present'; $employeeAttendance->clock_in = $time; $employeeAttendance->clock_out = '00:00:00'; $employeeAttendance->late = $late; $employeeAttendance->early_leaving = '00:00:00'; $employeeAttendance->overtime = '00:00:00'; $employeeAttendance->total_rest = '00:00:00'; $employeeAttendance->created_by = \Auth::user()->id; $employeeAttendance->save(); return redirect()->back()->with('success', __('Employee Successfully Clock In.')); } foreach ($checkDb as $check) { $employeeAttendance = new AttendanceEmployee(); $employeeAttendance->employee_id = $employeeId; $employeeAttendance->date = $date; $employeeAttendance->status = 'Present'; $employeeAttendance->clock_in = $time; $employeeAttendance->clock_out = '00:00:00'; $employeeAttendance->late = $late; $employeeAttendance->early_leaving = '00:00:00'; $employeeAttendance->overtime = '00:00:00'; $employeeAttendance->total_rest = '00:00:00'; $employeeAttendance->created_by = \Auth::user()->id; $employeeAttendance->save(); return redirect()->back()->with('success', __('Employee Successfully Clock In.')); } } public function bulkAttendance(Request $request) { if (\Auth::user()->can('Create Attendance')) { $branch = Branch::where('created_by', \Auth::user()->creatorId())->get()->pluck('name', 'id'); $branch->prepend('Select Branch', ''); $department = Department::where('created_by', \Auth::user()->creatorId())->get()->pluck('name', 'id'); $department->prepend('Select Department', ''); $employees = []; if (!empty($request->branch) && !empty($request->department)) { $employees = Employee::where('created_by', \Auth::user()->creatorId())->where('branch_id', $request->branch)->where('department_id', $request->department)->get(); } return view('attendance.bulk', compact('employees', 'branch', 'department')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } public function bulkAttendanceData(Request $request) { if (\Auth::user()->can('Create Attendance')) { if (!empty($request->branch) && !empty($request->department)) { $startTime = Utility::getValByName('company_start_time'); $endTime = Utility::getValByName('company_end_time'); $date = $request->date; $employees = $request->employee_id; $atte = []; foreach ($employees as $employee) { $present = 'present-' . $employee; $in = 'in-' . $employee; $out = 'out-' . $employee; $atte[] = $present; if ($request->$present == 'on') { $in = date("H:i:s", strtotime($request->$in)); $out = date("H:i:s", strtotime($request->$out)); $totalLateSeconds = strtotime($in) - strtotime($startTime); $hours = floor($totalLateSeconds / 3600); $mins = floor($totalLateSeconds / 60 % 60); $secs = floor($totalLateSeconds % 60); $late = sprintf('%02d:%02d:%02d', $hours, $mins, $secs); //early Leaving $totalEarlyLeavingSeconds = strtotime($endTime) - strtotime($out); $hours = floor($totalEarlyLeavingSeconds / 3600); $mins = floor($totalEarlyLeavingSeconds / 60 % 60); $secs = floor($totalEarlyLeavingSeconds % 60); $earlyLeaving = sprintf('%02d:%02d:%02d', $hours, $mins, $secs); if (strtotime($out) > strtotime($endTime)) { //Overtime $totalOvertimeSeconds = strtotime($out) - strtotime($endTime); $hours = floor($totalOvertimeSeconds / 3600); $mins = floor($totalOvertimeSeconds / 60 % 60); $secs = floor($totalOvertimeSeconds % 60); $overtime = sprintf('%02d:%02d:%02d', $hours, $mins, $secs); } else { $overtime = '00:00:00'; } $attendance = AttendanceEmployee::where('employee_id', '=', $employee)->where('date', '=', $request->date)->first(); if (!empty($attendance)) { $employeeAttendance = $attendance; } else { $employeeAttendance = new AttendanceEmployee(); $employeeAttendance->employee_id = $employee; $employeeAttendance->created_by = \Auth::user()->creatorId(); } $employeeAttendance->date = $request->date; $employeeAttendance->status = 'Present'; $employeeAttendance->clock_in = $in; $employeeAttendance->clock_out = $out; $employeeAttendance->late = $late; $employeeAttendance->early_leaving = ($earlyLeaving > 0) ? $earlyLeaving : '00:00:00'; $employeeAttendance->overtime = $overtime; $employeeAttendance->total_rest = '00:00:00'; $employeeAttendance->save(); } else { $attendance = AttendanceEmployee::where('employee_id', '=', $employee)->where('date', '=', $request->date)->first(); if (!empty($attendance)) { $employeeAttendance = $attendance; } else { $employeeAttendance = new AttendanceEmployee(); $employeeAttendance->employee_id = $employee; $employeeAttendance->created_by = \Auth::user()->creatorId(); } $employeeAttendance->status = 'Leave'; $employeeAttendance->date = $request->date; $employeeAttendance->clock_in = '00:00:00'; $employeeAttendance->clock_out = '00:00:00'; $employeeAttendance->late = '00:00:00'; $employeeAttendance->early_leaving = '00:00:00'; $employeeAttendance->overtime = '00:00:00'; $employeeAttendance->total_rest = '00:00:00'; $employeeAttendance->save(); } } return redirect()->back()->with('success', __('Employee attendance successfully created.')); } else { return redirect()->back()->with('error', __('Branch & department field required.')); } } else { return redirect()->back()->with('error', __('Permission denied.')); } } public function importFile() { return view('attendance.import'); } public function import(Request $request) { $rules = [ 'file' => 'required|mimes:csv,txt,xlsx', ]; $validator = \Validator::make($request->all(), $rules); if ($validator->fails()) { $messages = $validator->getMessageBag(); return redirect()->back()->with('error', $messages->first()); } $attendance = (new AttendanceImport())->toArray(request()->file('file'))[0]; $email_data = []; foreach ($attendance as $key => $employee) { if ($key != 0) { echo "
";
                if ($employee != null && Employee::where('email', $employee[0])->where('created_by', \Auth::user()->creatorId())->exists()) {
                    $email = $employee[0];
                } else {
                    $email_data[] = $employee[0];
                }
            }
        }
        $totalattendance = count($attendance) - 1;
        $errorArray    = [];

        $startTime = Utility::getValByName('company_start_time');
        $endTime   = Utility::getValByName('company_end_time');

        if (!empty($attendanceData)) {
            $errorArray[] = $attendanceData;
        } else {
            foreach ($attendance as $key => $value) {
                if ($key != 0) {
                    $employeeData = Employee::where('email', $value[0])->where('created_by', \Auth::user()->creatorId())->first();
                    // $employeeId = 0;
                    if (!empty($employeeData)) {
                        $employeeId = $employeeData->id;


                        $clockIn = $value[2];
                        $clockOut = $value[3];

                        if ($clockIn) {
                            $status = "present";
                        } else {
                            $status = "leave";
                        }

                        $totalLateSeconds = strtotime($clockIn) - strtotime($startTime);

                        $hours = floor($totalLateSeconds / 3600);
                        $mins  = floor($totalLateSeconds / 60 % 60);
                        $secs  = floor($totalLateSeconds % 60);
                        $late  = sprintf('%02d:%02d:%02d', $hours, $mins, $secs);

                        $totalEarlyLeavingSeconds = strtotime($endTime) - strtotime($clockOut);
                        $hours                    = floor($totalEarlyLeavingSeconds / 3600);
                        $mins                     = floor($totalEarlyLeavingSeconds / 60 % 60);
                        $secs                     = floor($totalEarlyLeavingSeconds % 60);
                        $earlyLeaving             = sprintf('%02d:%02d:%02d', $hours, $mins, $secs);

                        if (strtotime($clockOut) > strtotime($endTime)) {
                            //Overtime
                            $totalOvertimeSeconds = strtotime($clockOut) - strtotime($endTime);
                            $hours                = floor($totalOvertimeSeconds / 3600);
                            $mins                 = floor($totalOvertimeSeconds / 60 % 60);
                            $secs                 = floor($totalOvertimeSeconds % 60);
                            $overtime             = sprintf('%02d:%02d:%02d', $hours, $mins, $secs);
                        } else {
                            $overtime = '00:00:00';
                        }

                        $check = AttendanceEmployee::where('employee_id', $employeeId)->where('date', $value[1])->first();
                        if ($check) {
                            $check->update([
                                'late' => $late,
                                'early_leaving' => ($earlyLeaving > 0) ? $earlyLeaving : '00:00:00',
                                'overtime' => $overtime,
                                'clock_in' => $value[2],
                                'clock_out' => $value[3]
                            ]);
                        } else {
                            $time_sheet = AttendanceEmployee::create([
                                'employee_id' => $employeeId,
                                'date' => $value[1],
                                'status' => $status,
                                'late' => $late,
                                'early_leaving' => ($earlyLeaving > 0) ? $earlyLeaving : '00:00:00',
                                'overtime' => $overtime,
                                'clock_in' => $value[2],
                                'clock_out' => $value[3],
                                'created_by' => \Auth::user()->id,
                            ]);
                        }
                    }
                } else {
                    $email_data = implode(' And ', $email_data);
                }
            }
            if (!empty($email_data)) {
                return redirect()->back()->with('status', 'this record is not import. ' . '
' . $email_data); } else { if (empty($errorArray)) { $data['status'] = 'success'; $data['msg'] = __('Record successfully imported'); } else { $data['status'] = 'error'; $data['msg'] = count($errorArray) . ' ' . __('Record imported fail out of' . ' ' . $totalattendance . ' ' . 'record'); foreach ($errorArray as $errorData) { $errorRecord[] = implode(',', $errorData->toArray()); } \Session::put('errorArray', $errorRecord); } return redirect()->back()->with($data['status'], $data['msg']); } } } } Controllers/ZoomMeetingController.php000064400000026053150364311770014101 0ustar00can('Manage Zoom meeting')) { if (\Auth::user()->type == 'company' || \Auth::user()->type == 'hr') { $created_by = \Auth::user()->creatorId(); $ZoomMeetings = LocalZoomMeeting::where('created_by', $created_by)->get(); // $this->statusUpdate(); return view('zoom_meeting.index', compact('ZoomMeetings')); } elseif (\Auth::user()->type == 'employee') { $created_by = Auth::user()->creatorId(); $ZoomMeetings = LocalZoomMeeting::where('user_id', \Auth::user()->id)->get(); // $this->statusUpdate(); return view('zoom_meeting.index', compact('ZoomMeetings')); }else { $created_by = Auth::user()->creatorId(); $ZoomMeetings = LocalZoomMeeting::where('user_id', \Auth::user()->id)->get(); // $this->statusUpdate(); return view('zoom_meeting.index', compact('ZoomMeetings')); } } else { return redirect()->back()->with('error', __('Permission denied.')); } } public function create() { if (\Auth::user()->can('Create Zoom meeting')) { $created_by = \Auth::user()->creatorId(); $employee_option = User::where('created_by', $created_by)->pluck('name', 'id'); return view('zoom_meeting.create', compact('employee_option')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } public function store(Request $request) { if (\Auth::user()->can('Create Zoom meeting')) { $settings = \App\Models\Utility::settings(); if ($settings['zoom_account_id'] != "" && $settings['zoom_client_id'] != "" && $settings['zoom_client_secret'] != "") { $data['topic'] = $request->title; $data['start_time'] = date('y:m:d H:i:s', strtotime($request->start_date)); $data['duration'] = (int)$request->duration; $data['password'] = $request->password; $data['host_video'] = 0; $data['participant_video'] = 0; try { $meeting_create = $this->createmitting($data); } catch (\Exception $e) { return redirect()->back()->with('error', __('Invalid access token.')); } \Log::info('Meeting'); \Log::info((array)$meeting_create); if (isset($meeting_create['success']) && $meeting_create['success'] == true) { $meeting_id = isset($meeting_create['data']['id']) ? $meeting_create['data']['id'] : 0; $start_url = isset($meeting_create['data']['start_url']) ? $meeting_create['data']['start_url'] : ''; $join_url = isset($meeting_create['data']['join_url']) ? $meeting_create['data']['join_url'] : ''; $status = isset($meeting_create['data']['status']) ? $meeting_create['data']['status'] : ''; $created_by = \Auth::user()->creatorId(); $validator = \Validator::make( $request->all(), [ 'title' => 'required', 'user_id' => 'required', 'start_date' => 'required', 'duration' => 'required', ] ); if ($validator->fails()) { $messages = $validator->getMessageBag(); return redirect()->back()->with('error', $messages->first()); } $user_id = 0; if (!empty($request->user_id)) { $user_id = implode(',', $request->user_id); } $ZoomMeeting = new LocalZoomMeeting(); $ZoomMeeting->title = $request->title; $ZoomMeeting->meeting_id = $meeting_id; $ZoomMeeting->user_id = $user_id; $ZoomMeeting->password = $request->password; $ZoomMeeting->join_url = $join_url; $ZoomMeeting->start_date = $request->start_date; $ZoomMeeting->duration = $request->duration; $ZoomMeeting->start_url = $start_url; $ZoomMeeting->status = $status; $ZoomMeeting->created_by = $created_by; $ZoomMeeting->save(); // Google celander if ($request->get('synchronize_type') == 'google_calender') { $type = 'zoom_meeting'; $request1 = new GoogleEvent(); $request1->title = $request->title; $request1->start_date = $request->start_date; $request1->end_date = $request->start_date; Utility::addCalendarData($request1, $type); } return redirect()->back()->with('success', __('Meeting created successfully.')); } else { return redirect()->back()->with('error', __('Meeting not created.')); } } else { return redirect()->back()->with('error', __('Please Add Zoom Settings')); } } else { return redirect()->back()->with('error', __('Permission denied.')); } } public function show(LocalZoomMeeting $ZoomMeeting) { if (\Auth::user()->can('Show Zoom meeting')) { if ($ZoomMeeting->created_by == \Auth::user()->creatorId()) { return view('zoom_meeting.view', compact('ZoomMeeting')); } else { return redirect()->back()->with('error', 'permission Denied'); } } else { return redirect()->back()->with('error', __('Permission denied.')); } } public function edit(LocalZoomMeeting $ZoomMeeting) { $created_by = \Auth::user()->creatorId(); $employee_option = User::where('created_by', $created_by)->pluck('name', 'id'); return view('zoom_meeting.edit', compact('employee_option', 'ZoomMeeting')); } public function update(Request $request, LocalZoomMeeting $ZoomMeeting) { $created_by = \Auth::user()->creatorId(); $validator = \Validator::make( $request->all(), [ 'title' => 'required', 'user_id' => 'required', // 'password' => 'required', 'start_date' => 'required', 'duration' => 'required', ] ); if ($validator->fails()) { $messages = $validator->getMessageBag(); return redirect()->back()->with('error', $messages->first()); } $ZoomMeeting = new LocalZoomMeeting(); $ZoomMeeting->title = $request->title; $ZoomMeeting->user_id = $request->user_id; $ZoomMeeting->password = $request->password; $ZoomMeeting->start_date = $request->start_date; $ZoomMeeting->duration = $request->duration; $ZoomMeeting->created_by = $created_by; $ZoomMeeting->save(); return redirect()->back()->with('success', __('Zoom Meeting update Successfully')); } public function destroy(LocalZoomMeeting $ZoomMeeting) { if (\Auth::user()->can('Delete Zoom meeting')) { $ZoomMeeting->delete(); return redirect()->back()->with('success', __('Zoom Meeting Delete Succsefully')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } public function statusUpdate() { $meetings = LocalZoomMeeting::where('created_by', \Auth::user()->id)->pluck('meeting_id'); foreach ($meetings as $meeting) { $data = $this->get($meeting); if (isset($data['data']) && !empty($data['data'])) { $meeting = LocalZoomMeeting::where('meeting_id', $meeting)->update(['status' => $data['data']['status']]); } } } public function calender() { $created_by = Auth::user()->creatorId(); $ZoomMeetings = LocalZoomMeeting::where('created_by', $created_by)->get(); $today_date = date('m'); $current_month_event = LocalZoomMeeting::where('created_by', \Auth::user()->creatorId())->select('id', 'start_date', 'title', 'created_at')->whereRaw('MONTH(start_date)=' . $today_date)->get(); $arrMeeting = []; foreach ($ZoomMeetings as $zoommeeting) { $arr['id'] = $zoommeeting['id']; $arr['title'] = $zoommeeting['title']; $arr['start'] = date('Y-m-d', strtotime($zoommeeting['start_date'])); // $arr['start'] =date('Y-m-d',strtotime($zoommeeting['start_date'])).'T'.date('h:m:s',strtotime($zoommeeting['start_date'])); $arr['className'] = 'event-primary'; $arr['url'] = route('zoom-meeting.show', $zoommeeting['id']); $arrMeeting[] = $arr; } $calandar = array_merge($arrMeeting); //$calandar = str_replace('"[', '[', str_replace(']"', ']', json_encode($calandar))); $calandar = json_encode($calandar); return view('zoom_meeting.calendar', compact('calandar', 'current_month_event')); } public function get_zoom_meeting_data(Request $request) { $arrayJson = []; if ($request->get('calender_type') == 'google_calender') { $type = 'zoom_meeting'; $arrayJson = Utility::getCalendarData($type); } else { $data = LocalZoomMeeting::where('created_by', \Auth::user()->creatorId())->get(); foreach ($data as $val) { $end_date = date_create($val->end_date); date_add($end_date, date_interval_create_from_date_string("1 days")); $arrayJson[] = [ "id" => $val->id, "title" => $val->title, "start" => $val->start_date, "end" => date_format($end_date, "Y-m-d H:i:s"), "className" => $val->color, "textColor" => '#FFF', "allDay" => true, "url" => route('zoom-meeting.show', $val['id']), ]; } } return $arrayJson; } } Controllers/DesignationController.php000064400000014540150364311770014106 0ustar00can('Manage Designation')) { $designations = Designation::where('created_by', '=', \Auth::user()->creatorId())->with('department')->get(); return view('designation.index', compact('designations')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } public function create() { if (\Auth::user()->can('Create Designation')) { $branchs = Branch::where('created_by', '=', \Auth::user()->creatorId())->get()->pluck('name', 'id'); $branchs->prepend('Select Branch', ''); $departments = Department::where('created_by', '=', \Auth::user()->creatorId())->get()->pluck('name', 'id'); $departments->prepend('Select Department', ''); return view('designation.create', compact('branchs', 'departments')); } else { return response()->json(['error' => __('Permission denied.')], 401); } } public function store(Request $request) { if (\Auth::user()->can('Create Designation')) { $validator = \Validator::make( $request->all(), [ 'branch_id' => 'required', 'department_id' => 'required', 'name' => 'required|max:20', ] ); if ($validator->fails()) { $messages = $validator->getMessageBag(); return redirect()->back()->with('error', $messages->first()); } try { $branch = Department::where('id', $request->department_id)->where('created_by', '=', Auth::user()->creatorId())->first()->branch->id; } catch (Exception $e) { $branch = null; } $designation = new Designation(); $designation->branch_id = $branch; $designation->department_id = $request->department_id; $designation->name = $request->name; $designation->created_by = \Auth::user()->creatorId(); $designation->save(); return redirect()->route('designation.index')->with('success', __('Designation successfully created.')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } public function show(Designation $designation) { return redirect()->route('designation.index'); } public function edit(Designation $designation) { if (\Auth::user()->can('Edit Designation')) { if ($designation->created_by == \Auth::user()->creatorId()) { if (!empty($designation->branch_id)) { $branchs = Branch::where('id', $designation->branch_id)->first()->pluck('name', 'id'); $branchs->prepend('Select Branch', ''); } else { $branchs = Branch::where('created_by', '=', \Auth::user()->creatorId())->get()->pluck('name', 'id'); $branchs->prepend('Select Branch', ''); } $departments = Department::where('id', $designation->department_id)->first()->pluck('name', 'id'); $departments->prepend('Select Department', ''); return view('designation.edit', compact('designation', 'departments', 'branchs')); } else { return response()->json(['error' => __('Permission denied.')], 401); } } else { return response()->json(['error' => __('Permission denied.')], 401); } } public function update(Request $request, Designation $designation) { if (\Auth::user()->can('Edit Designation')) { if ($designation->created_by == \Auth::user()->creatorId()) { $validator = \Validator::make( $request->all(), [ 'branch_id' => 'required', 'department_id' => 'required', 'name' => 'required|max:20', ] ); if ($validator->fails()) { $messages = $validator->getMessageBag(); return redirect()->back()->with('error', $messages->first()); } try { $branch = Department::where('id', $request->department_id)->where('created_by', '=', Auth::user()->creatorId())->first()->branch->id; } catch (Exception $e) { $branch = null; } $designation->name = $request->name; $designation->branch_id = $branch; $designation->department_id = $request->department_id; $designation->save(); return redirect()->route('designation.index')->with('success', __('Designation successfully updated.')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } else { return redirect()->back()->with('error', __('Permission denied.')); } } public function destroy(Designation $designation) { if (\Auth::user()->can('Delete Designation')) { $employee = Employee::where('designation_id', $designation->id)->get(); if (count($employee) == 0) { if ($designation->created_by == \Auth::user()->creatorId()) { $designation->delete(); return redirect()->route('designation.index')->with('success', __('Designation successfully deleted.')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } else { return redirect()->route('designation.index')->with('error', __('This designation has employees. Please remove the employee from this designation.')); } } else { return redirect()->back()->with('error', __('Permission denied.')); } } } Controllers/EmployeeController.php000064400000121624150364311770013423 0ustar00can('Manage Employee')) { if (Auth::user()->type == 'employee') { $employees = Employee::where('user_id', '=', Auth::user()->id)->get(); } else { $employees = Employee::where('created_by', \Auth::user()->creatorId())->with(['branch', 'department', 'designation', 'user'])->get(); } return view('employee.index', compact('employees')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } public function create() { if (\Auth::user()->can('Create Employee')) { $company_settings = Utility::settings(); $documents = Document::where('created_by', \Auth::user()->creatorId())->get(); $branches = Branch::where('created_by', \Auth::user()->creatorId())->get()->pluck('name', 'id'); $branches->prepend('Select Branch', ''); $departments = Department::where('created_by', \Auth::user()->creatorId())->get()->pluck('name', 'id'); $departments->prepend('Select Department', ''); $designations = Designation::where('created_by', \Auth::user()->creatorId())->get()->pluck('name', 'id'); $designations->prepend('Select Designation', ''); $employees = User::where('created_by', \Auth::user()->creatorId())->get(); $employeesId = \Auth::user()->employeeIdFormat($this->employeeNumber()); return view('employee.create', compact('employees', 'employeesId', 'departments', 'designations', 'documents', 'branches', 'company_settings')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } public function store(Request $request) { if (\Auth::user()->can('Create Employee')) { $rules = [ 'name' => 'required', 'dob' => 'required', 'gender' => 'required', 'phone' => 'required', 'address' => 'required', 'email' => 'required|unique:users', 'password' => 'required', 'branch_id' => 'required', 'department_id' => 'required', 'designation_id' => 'required', 'document.*' => 'required', ]; $rules['biometric_emp_id'] = [ 'required', Rule::unique('employees')->where(function ($query) { return $query->where('created_by', Auth::user()->creatorId()); }) ]; $validator = \Validator::make( $request->all(), $rules ); if ($validator->fails()) { $messages = $validator->getMessageBag(); return redirect()->back()->withInput()->with('error', $messages->first()); } $objUser = User::find(\Auth::user()->creatorId()); $total_employee = $objUser->countEmployees(); $plan = Plan::find($objUser->plan); $date = date("Y-m-d H:i:s"); $default_language = DB::table('settings')->select('value')->where('name', 'default_language')->where('created_by', \Auth::user()->creatorId())->first(); // new company default language if ($default_language == null) { $default_language = DB::table('settings')->select('value')->where('name', 'default_language')->first(); } if ($request->hasFile('document')) { foreach ($request->document as $key => $document) { $image_size = $request->file('document')[$key]->getSize(); $result = Utility::updateStorageLimit(\Auth::user()->creatorId(), $image_size); if ($result == 1) { $filenameWithExt = $request->file('document')[$key]->getClientOriginalName(); $filename = pathinfo($filenameWithExt, PATHINFO_FILENAME); $extension = $request->file('document')[$key]->getClientOriginalExtension(); $fileNameToStore = $filename . '_' . time() . '.' . $extension; $dir = 'uploads/document/'; $image_path = $dir . $fileNameToStore; $path = \App\Models\Utility::upload_coustom_file($request, 'document', $fileNameToStore, $dir, $key, []); if ($path['flag'] == 1) { $url = $path['url']; } else { // return redirect()->back()->with('error', __($path['msg'])); return redirect()->back()->with('error', __($path['msg'])); } } } } if ($total_employee < $plan->max_employees || $plan->max_employees == -1) { $user = User::create( [ 'name' => $request['name'], 'email' => $request['email'], 'password' => Hash::make($request['password']), 'type' => 'employee', 'lang' => !empty($default_language) ? $default_language->value : 'en', 'created_by' => \Auth::user()->creatorId(), 'email_verified_at' => $date, ] ); $user->save(); $user->assignRole('Employee'); } else { return redirect()->back()->with('error', __('Your employee limit is over, Please upgrade plan.')); } if (!empty($request->document) && !is_null($request->document)) { $document_implode = implode(',', array_keys($request->document)); } else { $document_implode = null; } $employee = Employee::create( [ 'user_id' => $user->id, 'name' => $request['name'], 'dob' => $request['dob'], 'gender' => $request['gender'], 'phone' => $request['phone'], 'address' => $request['address'], 'email' => $request['email'], 'password' => Hash::make($request['password']), 'employee_id' => $this->employeeNumber(), 'biometric_emp_id' => !empty($request['biometric_emp_id']) ? $request['biometric_emp_id'] : '', 'branch_id' => $request['branch_id'], 'department_id' => $request['department_id'], 'designation_id' => $request['designation_id'], 'company_doj' => $request['company_doj'], 'documents' => $document_implode, 'account_holder_name' => $request['account_holder_name'], 'account_number' => $request['account_number'], 'bank_name' => $request['bank_name'], 'bank_identifier_code' => $request['bank_identifier_code'], 'branch_location' => $request['branch_location'], 'tax_payer_id' => $request['tax_payer_id'], 'created_by' => \Auth::user()->creatorId(), ] ); if ($request->hasFile('document')) { foreach ($request->document as $key => $document) { $image_size = $request->file('document')[$key]->getSize(); $result = Utility::updateStorageLimit(\Auth::user()->creatorId(), $image_size); if ($result == 1) { $filenameWithExt = $request->file('document')[$key]->getClientOriginalName(); $filename = pathinfo($filenameWithExt, PATHINFO_FILENAME); $extension = $request->file('document')[$key]->getClientOriginalExtension(); $fileNameToStore = $filename . '_' . time() . '.' . $extension; $dir = 'uploads/document/'; $image_path = $dir . $fileNameToStore; $path = \App\Models\Utility::upload_coustom_file($request, 'document', $fileNameToStore, $dir, $key, []); if ($path['flag'] == 1) { $url = $path['url']; } else { return redirect()->back()->with('error', __($path['msg'])); } $employee_document = EmployeeDocument::create( [ 'employee_id' => $employee['employee_id'], 'document_id' => $key, 'document_value' => $path['url'], 'created_by' => \Auth::user()->creatorId(), ] ); $employee_document->save(); } } } $setings = \App\Models\Utility::settings(); if ($setings['new_employee'] == 1) { $department = Department::find($request['department_id']); $branch = Branch::find($request['branch_id']); $designation = Designation::find($request['designation_id']); $uArr = [ 'employee_email' => $user->email, 'employee_password' => $request->password, 'employee_name' => $request['name'], 'employee_branch' => !empty($branch->name) ? $branch->name : '', 'department_id' => !empty($department->name) ? $department->name : '', 'designation_id' => !empty($designation->name) ? $designation->name : '', ]; $resp = \App\Models\Utility::sendEmailTemplate('new_employee', [$user->id => $user->email], $uArr); return redirect()->route('employee.index')->with('success', __('Employee successfully created.') . ((!empty($resp) && $resp['is_success'] == false && !empty($resp['error'])) ? '
' . $resp['error'] . '' : '') . ((isset($result) && $result != 1) ? '
' . $result . '' : '')); } return redirect()->route('employee.index')->with('success', __('Employee successfully created.')); // return redirect()->route('employee.index')->with('success', __('Employee successfully created.') . ((isset($result) && $result != 1) ? '
' . $result . '' : '')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } public function edit($id) { $id = Crypt::decrypt($id); if (\Auth::user()->can('Edit Employee')) { $documents = Document::where('created_by', \Auth::user()->creatorId())->get(); $branches = Branch::where('created_by', \Auth::user()->creatorId())->get()->pluck('name', 'id'); $departments = Department::where('created_by', \Auth::user()->creatorId())->get()->pluck('name', 'id'); $designations = Designation::where('created_by', \Auth::user()->creatorId())->get()->pluck('name', 'id'); $employee = Employee::find($id); $employeesId = \Auth::user()->employeeIdFormat($employee->employee_id); return view('employee.edit', compact('employee', 'employeesId', 'branches', 'departments', 'designations', 'documents')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } public function update(Request $request, $id) { if (\Auth::user()->can('Edit Employee')) { $employee = Employee::findOrFail($id); $rules = [ 'name' => 'required', 'dob' => 'required', 'gender' => 'required', 'phone' => 'required', 'address' => 'required', ]; if ($request->has('biometric_emp_id') && $employee->biometric_emp_id != $request->biometric_emp_id) { $rules['biometric_emp_id'] = [ 'required', Rule::unique('employees')->where(function ($query) { return $query->where('created_by', Auth::user()->creatorId()); }) ]; } $validator = \Validator::make( $request->all(), $rules ); if ($validator->fails()) { $messages = $validator->getMessageBag(); return redirect()->back()->with('error', $messages->first()); } if ($request->document) { foreach ($request->document as $key => $document) { $employee_document = EmployeeDocument::where('employee_id', $employee->employee_id)->where('document_id', $key)->first(); if (!empty($document)) { //storage limit $dir = 'uploads/document/'; if (!empty($employee_document)) { $file_path = $dir . $employee_document->document_value; } $image_size = $request->file('document')[$key]->getSize(); $result = Utility::updateStorageLimit(\Auth::user()->creatorId(), $image_size); if ($result == 1) { if (!empty($$file_path)) { Utility::changeStorageLimit(\Auth::user()->creatorId(), $file_path); } $filenameWithExt = $request->file('document')[$key]->getClientOriginalName(); $filename = pathinfo($filenameWithExt, PATHINFO_FILENAME); $extension = $request->file('document')[$key]->getClientOriginalExtension(); $fileNameToStore = $filename . '_' . time() . '.' . $extension; $dir = 'uploads/document/'; $image_path = $dir . $fileNameToStore; $path = \App\Models\Utility::upload_coustom_file($request, 'document', $fileNameToStore, $dir, $key, []); if (!empty($employee_document)) { if ($employee_document->document_value) { \File::delete(storage_path('uploads/document/' . $employee_document->document_value)); } $employee_document->document_value = $fileNameToStore; $employee_document->save(); } else { $employee_document = new EmployeeDocument(); $employee_document->employee_id = $employee->employee_id; $employee_document->document_id = $key; $employee_document->document_value = $fileNameToStore; $employee_document->save(); } if ($path['flag'] == 1) { $url = $path['url']; } else { return redirect()->back()->with('error', __($path['msg'])); } } // $employee_document = EmployeeDocument::where('employee_id', $employee->employee_id)->where('document_id', $key)->first(); // if (!empty($employee_document)) { // if ($employee_document->document_value) { // \File::delete(storage_path('uploads/document/' . $employee_document->document_value)); // } // // $employee_document->document_value = $fileNameToStore; // $employee_document->save(); // } else { // $employee_document = new EmployeeDocument(); // $employee_document->employee_id = $employee->employee_id; // $employee_document->document_id = $key; // $employee_document->document_value = $fileNameToStore; // $employee_document->save(); // } } } } if (!empty($request->document) && !is_null($request->document)) { $document_implode = implode(',', array_keys($request->document)); } else { $document_implode = null; } $employee = Employee::findOrFail($id); $input = $request->all(); $input['documents'] = $document_implode; $employee->fill($input)->save(); if ($request->salary) { return redirect()->route('setsalary.index')->with('success', 'Employee successfully updated.'); } if (\Auth::user()->type != 'employee') { // return redirect()->route('employee.index')->with('success', 'Employee successfully updated.'); return redirect()->route('employee.index')->with('success', __('Employee successfully updated.') . ((isset($result) && $result != 1) ? '
' . $result . '' : '')); } else { return redirect()->route('employee.show', \Illuminate\Support\Facades\Crypt::encrypt($employee->id))->with('success', __('Employee successfully updated.') . ((isset($result) && $result != 1) ? '
' . $result . '' : '')); } } else { return redirect()->back()->with('error', __('Permission denied.')); } } public function destroy($id) { if (Auth::user()->can('Delete Employee')) { $employee = Employee::findOrFail($id); $user = User::where('id', '=', $employee->user_id)->first(); $emp_documents = EmployeeDocument::where('employee_id', $employee->employee_id)->get(); $ContractEmployee = Contract::where('employee_name', '=', $employee->user_id)->get(); $payslips = PaySlip::where('employee_id', $id)->get(); $employee->delete(); $user->delete(); foreach ($ContractEmployee as $contractdelete) { $contractdelete->delete(); } foreach ($payslips as $payslip) { $payslip->delete(); } $dir = storage_path('uploads/document/'); foreach ($emp_documents as $emp_document) { $emp_document->delete(); // \File::delete(storage_path('uploads/document/' . $emp_document->document_value)); if (!empty($emp_document->document_value)) { $file_path = 'uploads/document/' . $emp_document->document_value; $result = Utility::changeStorageLimit(\Auth::user()->creatorId(), $file_path); // unlink($dir . $emp_document->document_value); } } return redirect()->route('employee.index')->with('success', 'Employee successfully deleted.'); } else { return redirect()->back()->with('error', __('Permission denied.')); } } public function show($id) { if (\Auth::user()->can('Show Employee')) { try { $empId = \Illuminate\Support\Facades\Crypt::decrypt($id); } catch (\RuntimeException $e) { return redirect()->back()->with('error', __('Employee not avaliable')); } $documents = Document::where('created_by', \Auth::user()->creatorId())->get(); $branches = Branch::where('created_by', \Auth::user()->creatorId())->get()->pluck('name', 'id'); $departments = Department::where('created_by', \Auth::user()->creatorId())->get()->pluck('name', 'id'); $designations = Designation::where('created_by', \Auth::user()->creatorId())->get()->pluck('name', 'id'); $employee = Employee::find($empId); $employeesId = \Auth::user()->employeeIdFormat($employee->employee_id); $empId = Crypt::decrypt($id); // $employee = Employee::find($empId); // $branch= Branch::where('created_by', \Auth::user()->creatorId())->get()->pluck('name', 'id'); return view('employee.show', compact('employee', 'employeesId', 'branches', 'departments', 'designations', 'documents')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } function employeeNumber() { $latest = Employee::where('created_by', '=', \Auth::user()->creatorId())->latest('id')->first(); if (!$latest) { return 1; } return $latest->id + 1; } public function export() { $name = 'employee_' . date('Y-m-d i:h:s'); $data = Excel::download(new EmployeesExport(), $name . '.xlsx'); return $data; } public function importFile() { return view('employee.import'); } public function import(Request $request) { $rules = [ 'file' => 'required|mimes:csv,txt', ]; $validator = \Validator::make($request->all(), $rules); if ($validator->fails()) { $messages = $validator->getMessageBag(); return redirect()->back()->with('error', $messages->first()); } $employees = (new EmployeesImport())->toArray(request()->file('file'))[0]; $totalCustomer = count($employees) - 1; $errorArray = []; for ($i = 1; $i <= count($employees) - 1; $i++) { $employee = $employees[$i]; $employeeByEmail = Employee::where('email', $employee[5])->first(); $userByEmail = User::where('email', $employee[5])->first(); if (!empty($employeeByEmail) && !empty($userByEmail)) { $employeeData = $employeeByEmail; } else { $user = new User(); $user->name = $employee[0]; $user->email = $employee[5]; $user->password = Hash::make($employee[6]); $user->type = 'employee'; $user->lang = 'en'; $user->created_by = \Auth::user()->creatorId(); $user->email_verified_at = date("Y-m-d H:i:s"); $user->save(); $user->assignRole('Employee'); $employeeData = new Employee(); $employeeData->employee_id = $this->employeeNumber(); $employeeData->user_id = $user->id; } $employeeData->name = $employee[0]; $employeeData->dob = $employee[1]; $employeeData->gender = $employee[2]; $employeeData->phone = $employee[3]; $employeeData->address = $employee[4]; $employeeData->email = $employee[5]; $employeeData->password = \Hash::make($employee[6]); $employeeData->employee_id = $this->employeeNumber(); $employeeData->branch_id = $employee[8]; $employeeData->department_id = $employee[9]; $employeeData->designation_id = $employee[10]; $employeeData->company_doj = $employee[11]; $employeeData->account_holder_name = $employee[12]; $employeeData->account_number = $employee[13]; $employeeData->bank_name = $employee[14]; $employeeData->bank_identifier_code = $employee[15]; $employeeData->branch_location = $employee[16]; $employeeData->tax_payer_id = $employee[17]; $employeeData->created_by = \Auth::user()->creatorId(); if (empty($employeeData)) { $errorArray[] = $employeeData; } else { $employeeData->save(); } } $errorRecord = []; if (empty($errorArray)) { $data['status'] = 'success'; $data['msg'] = __('Record successfully imported'); } else { $data['status'] = 'error'; $data['msg'] = count($errorArray) . ' ' . __('Record imported fail out of' . ' ' . $totalCustomer . ' ' . 'record'); foreach ($errorArray as $errorData) { $errorRecord[] = implode(',', $errorData); } \Session::put('errorArray', $errorRecord); } return redirect()->back()->with($data['status'], $data['msg']); } // public function json(Request $request) // { // $designations = Designation::where('department_id', $request->department_id)->get()->pluck('name', 'id')->toArray(); // return response()->json($designations); // } public function profile(Request $request) { if (\Auth::user()->can('Manage Employee Profile')) { $employees = Employee::where('created_by', \Auth::user()->creatorId())->with(['designation', 'user']); if (!empty($request->branch)) { $employees->where('branch_id', $request->branch); } if (!empty($request->department)) { $employees->where('department_id', $request->department); } if (!empty($request->designation)) { $employees->where('designation_id', $request->designation); } $employees = $employees->get(); $brances = Branch::where('created_by', \Auth::user()->creatorId())->get()->pluck('name', 'id'); $brances->prepend('All', ''); $departments = Department::where('created_by', \Auth::user()->creatorId())->get()->pluck('name', 'id'); $departments->prepend('All', ''); $designations = Designation::where('created_by', \Auth::user()->creatorId())->get()->pluck('name', 'id'); $designations->prepend('All', ''); return view('employee.profile', compact('employees', 'departments', 'designations', 'brances')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } public function profileShow($id) { if (\Auth::user()->can('Show Employee Profile')) { $empId = Crypt::decrypt($id); $documents = Document::where('created_by', \Auth::user()->creatorId())->get(); $branches = Branch::where('created_by', \Auth::user()->creatorId())->get()->pluck('name', 'id'); $departments = Department::where('created_by', \Auth::user()->creatorId())->get()->pluck('name', 'id'); $designations = Designation::where('created_by', \Auth::user()->creatorId())->get()->pluck('name', 'id'); $employee = Employee::find($empId); if ($employee == null) { $employee = Employee::where('user_id', $empId)->first(); } $employeesId = \Auth::user()->employeeIdFormat($employee->employee_id); return view('employee.show', compact('employee', 'employeesId', 'branches', 'departments', 'designations', 'documents')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } public function lastLogin(Request $request) { $users = User::where('created_by', \Auth::user()->creatorId())->get(); $time = date_create($request->month); $firstDayofMOnth = (date_format($time, 'Y-m-d')); $lastDayofMonth = \Carbon\Carbon::parse($request->month)->endOfMonth()->toDateString(); $objUser = \Auth::user(); $usersList = User::where('created_by', '=', $objUser->creatorId()) ->whereNotIn('type', ['super admin', 'company'])->get()->pluck('name', 'id'); $usersList->prepend('All', ''); if ($request->month == null) { $userdetails = DB::table('login_details') ->join('users', 'login_details.user_id', '=', 'users.id') ->select(DB::raw('login_details.*, users.id as user_id , users.name as user_name , users.email as user_email ,users.type as user_type')) ->where(['login_details.created_by' => \Auth::user()->creatorId()]) ->whereMonth('date', date('m'))->whereYear('date', date('Y')); } else { $userdetails = DB::table('login_details') ->join('users', 'login_details.user_id', '=', 'users.id') ->select(DB::raw('login_details.*, users.id as user_id , users.name as user_name , users.email as user_email ,users.type as user_type')) ->where(['login_details.created_by' => \Auth::user()->creatorId()]); } if (!empty($request->month)) { $userdetails->where('date', '>=', $firstDayofMOnth); $userdetails->where('date', '<=', $lastDayofMonth); } if (!empty($request->employee)) { $userdetails->where(['user_id' => $request->employee]); } $userdetails = $userdetails->get(); return view('employee.lastLogin', compact('users', 'usersList', 'userdetails')); } public function employeeJson(Request $request) { $employees = Employee::where('branch_id', $request->branch)->get()->pluck('name', 'id')->toArray(); return response()->json($employees); } public function joiningletterPdf($id) { $users = \Auth::user(); $currantLang = $users->currentLanguage(); $joiningletter = JoiningLetter::where('lang', $currantLang)->where('created_by', \Auth::user()->creatorId())->first(); $date = date('Y-m-d'); $employees = Employee::where('id', $id)->where('created_by', \Auth::user()->creatorId())->first(); $settings = \App\Models\Utility::settings(); $secs = strtotime($settings['company_start_time']) - strtotime("00:00"); $result = date("H:i", strtotime($settings['company_end_time']) - $secs); $obj = [ 'date' => \Auth::user()->dateFormat($date), 'app_name' => env('APP_NAME'), 'employee_name' => $employees->name, 'address' => !empty($employees->address) ? $employees->address : '', 'designation' => !empty($employees->designation->name) ? $employees->designation->name : '', 'start_date' => !empty($employees->company_doj) ? $employees->company_doj : '', 'branch' => !empty($employees->Branch->name) ? $employees->Branch->name : '', 'start_time' => !empty($settings['company_start_time']) ? $settings['company_start_time'] : '', 'end_time' => !empty($settings['company_end_time']) ? $settings['company_end_time'] : '', 'total_hours' => $result, ]; $joiningletter->content = JoiningLetter::replaceVariable($joiningletter->content, $obj); return view('employee.template.joiningletterpdf', compact('joiningletter', 'employees')); } public function joiningletterDoc($id) { $users = \Auth::user(); $currantLang = $users->currentLanguage(); $joiningletter = JoiningLetter::where('lang', $currantLang)->where('created_by', \Auth::user()->creatorId())->first(); $date = date('Y-m-d'); $employees = Employee::where('id', $id)->where('created_by', \Auth::user()->creatorId())->first(); $settings = \App\Models\Utility::settings(); $secs = strtotime($settings['company_start_time']) - strtotime("00:00"); $result = date("H:i", strtotime($settings['company_end_time']) - $secs); $obj = [ 'date' => \Auth::user()->dateFormat($date), 'app_name' => env('APP_NAME'), 'employee_name' => $employees->name, 'address' => !empty($employees->address) ? $employees->address : '', 'designation' => !empty($employees->designation->name) ? $employees->designation->name : '', 'start_date' => !empty($employees->company_doj) ? $employees->company_doj : '', 'branch' => !empty($employees->Branch->name) ? $employees->Branch->name : '', 'start_time' => !empty($settings['company_start_time']) ? $settings['company_start_time'] : '', 'end_time' => !empty($settings['company_end_time']) ? $settings['company_end_time'] : '', 'total_hours' => $result, // ]; $joiningletter->content = JoiningLetter::replaceVariable($joiningletter->content, $obj); return view('employee.template.joiningletterdocx', compact('joiningletter', 'employees')); } public function ExpCertificatePdf($id) { $currantLang = \Cookie::get('LANGUAGE'); if (!isset($currantLang)) { $currantLang = 'en'; } $termination = Termination::where('employee_id', $id)->where('created_by', \Auth::user()->creatorId())->first(); $experience_certificate = ExperienceCertificate::where('lang', $currantLang)->where('created_by', \Auth::user()->creatorId())->first(); $date = date('Y-m-d'); $employees = Employee::where('id', $id)->where('created_by', \Auth::user()->creatorId())->first(); $settings = \App\Models\Utility::settings(); $secs = strtotime($settings['company_start_time']) - strtotime("00:00"); $result = date("H:i", strtotime($settings['company_end_time']) - $secs); $date1 = date_create($employees->company_doj); $date2 = date_create($employees->termination_date); $diff = date_diff($date1, $date2); $duration = $diff->format("%a days"); if (!empty($termination->termination_date)) { $obj = [ 'date' => \Auth::user()->dateFormat($date), 'app_name' => env('APP_NAME'), 'employee_name' => $employees->name, 'payroll' => !empty($employees->salaryType->name) ? $employees->salaryType->name : '', 'duration' => $duration, 'designation' => !empty($employees->designation->name) ? $employees->designation->name : '', ]; } else { return redirect()->back()->with('error', __('Termination date is required.')); } $experience_certificate->content = ExperienceCertificate::replaceVariable($experience_certificate->content, $obj); return view('employee.template.ExpCertificatepdf', compact('experience_certificate', 'employees')); } public function ExpCertificateDoc($id) { $currantLang = \Cookie::get('LANGUAGE'); if (!isset($currantLang)) { $currantLang = 'en'; } $termination = Termination::where('employee_id', $id)->where('created_by', \Auth::user()->creatorId())->first(); $experience_certificate = ExperienceCertificate::where('lang', $currantLang)->where('created_by', \Auth::user()->creatorId())->first(); $date = date('Y-m-d'); $employees = Employee::where('id', $id)->where('created_by', \Auth::user()->creatorId())->first();; $settings = \App\Models\Utility::settings(); $secs = strtotime($settings['company_start_time']) - strtotime("00:00"); $result = date("H:i", strtotime($settings['company_end_time']) - $secs); $date1 = date_create($employees->company_doj); $date2 = date_create($employees->termination_date); $diff = date_diff($date1, $date2); $duration = $diff->format("%a days"); if (!empty($termination->termination_date)) { $obj = [ 'date' => \Auth::user()->dateFormat($date), 'app_name' => env('APP_NAME'), 'employee_name' => $employees->name, 'payroll' => !empty($employees->salaryType->name) ? $employees->salaryType->name : '', 'duration' => $duration, 'designation' => !empty($employees->designation->name) ? $employees->designation->name : '', ]; } else { return redirect()->back()->with('error', __('Termination date is required.')); } $experience_certificate->content = ExperienceCertificate::replaceVariable($experience_certificate->content, $obj); return view('employee.template.ExpCertificatedocx', compact('experience_certificate', 'employees')); } public function NocPdf($id) { $users = \Auth::user(); $currantLang = $users->currentLanguage(); $noc_certificate = NOC::where('lang', $currantLang)->where('created_by', \Auth::user()->creatorId())->first(); $date = date('Y-m-d'); $employees = Employee::where('id', $id)->where('created_by', \Auth::user()->creatorId())->first(); $settings = \App\Models\Utility::settings(); $secs = strtotime($settings['company_start_time']) - strtotime("00:00"); $result = date("H:i", strtotime($settings['company_end_time']) - $secs); $obj = [ 'date' => \Auth::user()->dateFormat($date), 'employee_name' => $employees->name, 'designation' => !empty($employees->designation->name) ? $employees->designation->name : '', 'app_name' => env('APP_NAME'), ]; $noc_certificate->content = NOC::replaceVariable($noc_certificate->content, $obj); return view('employee.template.Nocpdf', compact('noc_certificate', 'employees')); } public function NocDoc($id) { $users = \Auth::user(); $currantLang = $users->currentLanguage(); $noc_certificate = NOC::where('lang', $currantLang)->where('created_by', \Auth::user()->creatorId())->first(); $date = date('Y-m-d'); $employees = Employee::where('id', $id)->where('created_by', \Auth::user()->creatorId())->first(); $settings = \App\Models\Utility::settings(); $secs = strtotime($settings['company_start_time']) - strtotime("00:00"); $result = date("H:i", strtotime($settings['company_end_time']) - $secs); $obj = [ 'date' => \Auth::user()->dateFormat($date), 'employee_name' => $employees->name, 'designation' => !empty($employees->designation->name) ? $employees->designation->name : '', 'app_name' => env('APP_NAME'), ]; $noc_certificate->content = NOC::replaceVariable($noc_certificate->content, $obj); return view('employee.template.Nocdocx', compact('noc_certificate', 'employees')); } public function getdepartment(Request $request) { if ($request->branch_id == 0) { $departments = Department::where('created_by', '=', \Auth::user()->creatorId())->get()->pluck('name', 'id')->toArray(); } else { $departments = Department::where('created_by', '=', \Auth::user()->creatorId())->where('branch_id', $request->branch_id)->get()->pluck('name', 'id')->toArray(); } return response()->json($departments); } public function json(Request $request) { if ($request->department_id == 0) { $designations = Designation::where('created_by', '=', \Auth::user()->creatorId())->get()->pluck('name', 'id')->toArray(); } $designations = Designation::where('department_id', $request->department_id)->get()->pluck('name', 'id')->toArray(); return response()->json($designations); } public function view($id) { $users = LoginDetail::find($id); return view('employee.user_log', compact('users')); } public function logindestroy($id) { $employee = LoginDetail::where('user_id', $id)->delete(); return redirect()->back()->with('success', 'Employee successfully deleted.'); } } Controllers/ReferralProgramController.php000064400000012441150364311770014732 0ustar00id)->first(); $payRequests = TransactionOrder::where('status', 1)->get(); $transactions = ReferralTransaction::get(); return view('referral-program.index', compact('setting', 'payRequests', 'transactions')); } public function store(Request $request) { $validator = \Validator::make( $request->all(), [ 'percentage' => 'required', 'minimum_threshold_amount' => 'required', 'guideline' => 'required', ] ); if ($validator->fails()) { $messages = $validator->getMessageBag(); return redirect()->back()->with('error', $messages->first()); } if ($request->has('is_enable') && $request->is_enable == 'on') { $is_enable = 1; } else { $is_enable = 0; } $setting = ReferralSetting::where('created_by', \Auth::user()->id)->first(); if ($setting == null) { $setting = new ReferralSetting(); } $setting->percentage = $request->percentage; $setting->minimum_threshold_amount = $request->minimum_threshold_amount; $setting->is_enable = $is_enable; $setting->guideline = $request->guideline; $setting->created_by = \Auth::user()->creatorId(); $setting->save(); return redirect()->route('referral-program.index')->with('success', __('Referral Program Setting successfully Updated.')); } public function companyIndex() { $setting = ReferralSetting::where('created_by', 1)->first(); $objUser = \Auth::user(); $transactions = ReferralTransaction::where('referral_code', $objUser->referral_code)->get(); $transactionsOrder = TransactionOrder::where('req_user_id', $objUser->id)->get(); $paidAmount = $transactionsOrder->where('status', 2)->sum('req_amount'); $paymentRequest = TransactionOrder::where('status', 1)->where('req_user_id', $objUser->id)->first(); return view('referral-program.company', compact('setting', 'transactions', 'paidAmount', 'transactionsOrder', 'paymentRequest')); } public function requestedAmountSent($id) { $id = \Illuminate\Support\Facades\Crypt::decrypt($id); $paidAmount = TransactionOrder::where('req_user_id', \Auth::user()->id)->where('status', 2)->sum('req_amount'); $user = User::find(\Auth::user()->id); $netAmount = $user->commission_amount - $paidAmount; return view('referral-program.request_amount', compact('id', 'netAmount')); } public function requestCancel($id) { $transaction = TransactionOrder::where('req_user_id', $id)->orderBy('id', 'desc')->first(); // $transaction->status = 0; // $transaction->req_user_id = \Auth::user()->id; $transaction->delete(); return redirect()->route('referral-program.company')->with('success', __('Request Cancel Successfully.')); } public function requestedAmountStore(Request $request, $id) { $order = new TransactionOrder(); $order->req_amount = $request->request_amount; $order->req_user_id = \Auth::user()->id; $order->status = 1; $order->date = date('Y-m-d'); $order->save(); return redirect()->route('referral-program.company')->with('success', __('Request Send Successfully.')); } public function requestedAmount($id, $status) { $setting = ReferralSetting::where('created_by', 1)->first(); $transaction = TransactionOrder::find($id); $paidAmount = TransactionOrder::where('req_user_id', $transaction->req_user_id)->where('status', 2)->sum('req_amount'); $user = User::find($transaction->req_user_id); $netAmount = $user->commission_amount - $paidAmount; $minAmount = isset($setting) ? $setting->minimum_threshold_amount : 0; if($status == 0) { $transaction->status = 0; $transaction->save(); return redirect()->route('referral-program.index')->with('error', __('Request Rejected Successfully.')); } elseif($transaction->req_amount > $netAmount) { $transaction->status = 0; $transaction->save(); return redirect()->route('referral-program.index')->with('error', __('This request cannot be accepted because it exceeds the commission amount.')); } elseif($transaction->req_amount < $minAmount) { $transaction->status = 0; $transaction->save(); return redirect()->route('referral-program.index')->with('error', __('This request cannot be accepted because it less than the threshold amount.')); } else { $transaction->status = 2; $transaction->save(); return redirect()->route('referral-program.index')->with('success', __('Request Aceepted Successfully.')); } } } Controllers/PayfastController.php000064400000012607150364311770013253 0ustar00plan_id); $plan = Plan::find($planID); if ($plan) { $plan_amount = $plan->price; $order_id = strtoupper(str_replace('.', '', uniqid('', true))); $user = Auth::user(); if ($request->coupon_amount > 0 && $request->coupon_code != null) { $coupons = Coupon::where('code', $request->coupon_code)->first(); if (!empty($coupons)) { $userCoupon = new UserCoupon(); $userCoupon->user = $user->id; $userCoupon->coupon = $coupons->id; $userCoupon->order = $order_id; $userCoupon->save(); $usedCoupun = $coupons->used_coupon(); if ($coupons->limit <= $usedCoupun) { $coupons->is_active = 0; $coupons->save(); } $plan_amount = $plan_amount - $request->coupon_amount; } } $success = Crypt::encrypt([ 'plan' => $plan->toArray(), 'order_id' => $order_id, 'plan_amount' => $plan_amount ]); $data = array( // Merchant details 'merchant_id' => !empty($payment_setting['payfast_merchant_id']) ? $payment_setting['payfast_merchant_id'] : '', 'merchant_key' => !empty($payment_setting['payfast_merchant_key']) ? $payment_setting['payfast_merchant_key'] : '', 'return_url' => route('payfast.payment.success', $success), 'cancel_url' => route('plans.index'), 'notify_url' => route('plans.index'), // Buyer details 'name_first' => $user->name, 'name_last' => '', 'email_address' => $user->email, // Transaction details 'm_payment_id' => $order_id, //Unique payment ID to pass through to notify_url 'amount' => number_format(sprintf('%.2f', $plan_amount), 2, '.', ''), 'item_name' => $plan->name, ); $passphrase = !empty($payment_setting['payfast_signature']) ? $payment_setting['payfast_signature'] : ''; $signature = $this->generateSignature($data, $passphrase); $data['signature'] = $signature; $htmlForm = ''; foreach ($data as $name => $value) { $htmlForm .= ''; } return response()->json([ 'success' => true, 'inputs' => $htmlForm, ]); } } } public function generateSignature($data, $passPhrase = null) { $pfOutput = ''; foreach ($data as $key => $val) { if ($val !== '') { $pfOutput .= $key . '=' . urlencode(trim($val)) . '&'; } } $getString = substr($pfOutput, 0, -1); if ($passPhrase !== null) { $getString .= '&passphrase=' . urlencode(trim($passPhrase)); } return md5($getString); } public function success($success) { $payment_setting = Utility::getAdminPaymentSetting(); try { $user = Auth::user(); $data = Crypt::decrypt($success); $plan = Plan::find($data['plan']['id']); Utility::referralTransaction($plan); $order = new Order(); $order->order_id = $data['order_id']; $order->name = $user->name; $order->card_number = ''; $order->card_exp_month = ''; $order->card_exp_year = ''; $order->plan_name = $data['plan']['name']; $order->plan_id = $data['plan']['id']; $order->price = $data['plan_amount']; $order->price_currency = $payment_setting['currency']; $order->txn_id = $data['order_id']; $order->payment_type = __('PayFast'); $order->payment_status = 'success'; $order->txn_id = ''; $order->receipt = ''; $order->user_id = $user->id; $order->save(); $assignPlan = $user->assignPlan($data['plan']['id']); if ($assignPlan['is_success']) { return redirect()->route('plans.index')->with('success', __('Plan activated Successfully.')); } else { return redirect()->route('plans.index')->with('error', __($assignPlan['error'])); } } catch (Exception $e) { return redirect()->route('plans.index')->with('error', __($e)); } } } Controllers/LoanController.php000064400000013303150364311770012527 0ustar00creatorId())->get()->pluck('name', 'id'); $loan =loan::$Loantypes; return view('loan.create', compact('employee','loan_options','loan')); } public function store(Request $request) { if(\Auth::user()->can('Create Loan')) { $validator = \Validator::make( $request->all(), [ 'employee_id' => 'required', 'loan_option' => 'required', 'title' => 'required', 'amount' => 'required', // 'start_date' => 'required', // 'end_date' => 'required', 'reason' => 'required', ] ); if($validator->fails()) { $messages = $validator->getMessageBag(); return redirect()->back()->with('error', $messages->first()); } $loan = new Loan(); $loan->employee_id = $request->employee_id; $loan->loan_option = $request->loan_option; $loan->title = $request->title; $loan->amount = $request->amount; $loan->type = $request->type; // $loan->start_date = $request->start_date; // $loan->end_date = $request->end_date; $loan->reason = $request->reason; $loan->created_by = \Auth::user()->creatorId(); $loan->save(); if( $loan->type == 'percentage' ) { $employee = Employee::find($loan->employee_id); $loansal = $loan->amount * $employee->salary / 100; } return redirect()->back()->with('success', __('Loan successfully created.')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } public function show(Loan $loan) { return redirect()->route('commision.index'); } public function edit($loan) { $loan = Loan::find($loan); if(\Auth::user()->can('Edit Loan')) { if($loan->created_by == \Auth::user()->creatorId()) { $loan_options = LoanOption::where('created_by', \Auth::user()->creatorId())->get()->pluck('name', 'id'); $loans =loan::$Loantypes; return view('loan.edit', compact('loan', 'loan_options','loans')); } else { return response()->json(['error' => __('Permission denied.')], 401); } } else { return response()->json(['error' => __('Permission denied.')], 401); } } public function update(Request $request, Loan $loan) { if(\Auth::user()->can('Edit Loan')) { if($loan->created_by == \Auth::user()->creatorId()) { $validator = \Validator::make( $request->all(), [ 'loan_option' => 'required', 'title' => 'required', 'amount' => 'required', // 'start_date' => 'required', // 'end_date' => 'required', 'reason' => 'required', ] ); if($validator->fails()) { $messages = $validator->getMessageBag(); return redirect()->back()->with('error', $messages->first()); } $loan->loan_option = $request->loan_option; $loan->title = $request->title; $loan->type = $request->type; $loan->amount = $request->amount; // $loan->start_date = $request->start_date; // $loan->end_date = $request->end_date; $loan->reason = $request->reason; $loan->save(); if( $loan->type == 'percentage' ) { $employee = Employee::find($loan->employee_id); $loansal = $loan->amount * $employee->salary / 100; } return redirect()->back()->with('success', __('Loan successfully updated.')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } else { return redirect()->back()->with('error', __('Permission denied.')); } } public function destroy(Loan $loan) { if(\Auth::user()->can('Delete Loan')) { if($loan->created_by == \Auth::user()->creatorId()) { $loan->delete(); return redirect()->back()->with('success', __('Loan successfully deleted.')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } else { return redirect()->back()->with('error', __('Permission denied.')); } } } Controllers/TrainingController.php000064400000017167150364311770013425 0ustar00can('Manage Training')) { $trainings = Training::where('created_by', '=', \Auth::user()->creatorId())->with(['branches', 'types', 'employees', 'trainers'])->get(); $status = Training::$Status; return view('training.index', compact('trainings', 'status')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } public function create() { if (\Auth::user()->can('Create Training')) { $branches = Branch::where('created_by', \Auth::user()->creatorId())->get()->pluck('name', 'id'); $branches->prepend('Select Branch', ''); $trainingTypes = TrainingType::where('created_by', \Auth::user()->creatorId())->get()->pluck('name', 'id'); $trainers = Trainer::where('created_by', \Auth::user()->creatorId())->get()->pluck('firstname', 'id'); $employees = Employee::where('created_by', \Auth::user()->creatorId())->get()->pluck('name', 'id'); $options = Training::$options; return view('training.create', compact('branches', 'trainingTypes', 'trainers', 'employees', 'options')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } public function store(Request $request) { if (\Auth::user()->can('Create Training')) { $validator = \Validator::make( $request->all(), [ 'branch' => 'required', 'training_type' => 'required', 'training_cost' => 'required', 'employee' => 'required', 'start_date' => 'required', 'end_date' => 'required', ] ); if ($validator->fails()) { $messages = $validator->getMessageBag(); return redirect()->back()->with('error', $messages->first()); } $training = new Training(); $training->branch = $request->branch; $training->trainer_option = $request->trainer_option; $training->training_type = $request->training_type; $training->trainer = $request->trainer; $training->training_cost = $request->training_cost; $training->employee = $request->employee; $training->start_date = $request->start_date; $training->end_date = $request->end_date; $training->description = $request->description; $training->created_by = \Auth::user()->creatorId(); $training->save(); return redirect()->route('training.index')->with('success', __('Training successfully created.')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } public function show($id) { $traId = Crypt::decrypt($id); $training = Training::find($traId); $performance = Training::$performance; $status = Training::$Status; return view('training.show', compact('training', 'performance', 'status')); } public function edit(Training $training) { if (\Auth::user()->can('Create Training')) { $branches = Branch::where('created_by', \Auth::user()->creatorId())->get()->pluck('name', 'id'); $trainingTypes = TrainingType::where('created_by', \Auth::user()->creatorId())->get()->pluck('name', 'id'); $trainers = Trainer::where('created_by', \Auth::user()->creatorId())->get()->pluck('firstname', 'id'); $employees = Employee::where('created_by', \Auth::user()->creatorId())->get()->pluck('name', 'id'); $options = Training::$options; return view('training.edit', compact('branches', 'trainingTypes', 'trainers', 'employees', 'options', 'training')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } public function update(Request $request, Training $training) { if (\Auth::user()->can('Edit Training')) { $validator = \Validator::make( $request->all(), [ 'branch' => 'required', 'training_type' => 'required', 'training_cost' => 'required', 'employee' => 'required', 'start_date' => 'required', 'end_date' => 'required', ] ); if ($validator->fails()) { $messages = $validator->getMessageBag(); return redirect()->back()->with('error', $messages->first()); } $training->branch = $request->branch; $training->trainer_option = $request->trainer_option; $training->training_type = $request->training_type; $training->trainer = $request->trainer; $training->training_cost = $request->training_cost; $training->employee = $request->employee; $training->start_date = $request->start_date; $training->end_date = $request->end_date; $training->description = $request->description; $training->save(); return redirect()->route('training.index')->with('success', __('Training successfully updated.')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } public function destroy(Training $training) { if (\Auth::user()->can('Delete Training')) { if ($training->created_by == \Auth::user()->creatorId()) { $training->delete(); return redirect()->route('training.index')->with('success', __('Training successfully deleted.')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } else { return redirect()->back()->with('error', __('Permission denied.')); } } public function export() { $name = 'training_' . date('Y-m-d i:h:s'); $data = Excel::download(new TrainingExport(), $name . '.xlsx'); return $data; } public function updateStatus(Request $request) { $training = Training::find($request->id); $training->performance = $request->performance; $training->status = $request->status; $training->remarks = $request->remarks; $training->save(); return redirect()->route('training.index')->with('success', __('Training status successfully updated.')); } public function getemployee(Request $request) { if ($request->branch_id == 0) { $employees = Employee::where('created_by', '=', \Auth::user()->creatorId())->get()->pluck('name', 'id')->toArray(); } else { $employees = Employee::where('created_by', '=', \Auth::user()->creatorId())->where('branch_id', $request->branch_id)->get()->pluck('name', 'id')->toArray(); } return response()->json($employees); } } Controllers/TransferBalanceController.php000064400000016312150364311770014673 0ustar00can('Manage Transfer Balance')) { $transferbalances = TransferBalance::where('created_by', '=', Auth::user()->creatorId())->get(); return view('transferbalance.index', compact('transferbalances')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } public function create() { if(\Auth::user()->can('Create Transfer Balance')) { $transferbalances = TransferBalance::where('created_by', '=', \Auth::user()->creatorId())->get(); $accounts = AccountList::where('created_by', '=', \Auth::user()->creatorId())->get()->pluck('account_name', 'id'); $paymentTypes = PaymentType::where('created_by', '=', \Auth::user()->creatorId())->get()->pluck('name', 'id'); return view('transferbalance.create', compact('transferbalances', 'accounts', 'paymentTypes')); } else { return response()->json(['error' => __('Permission denied.')], 401); } } public function store(Request $request) { if(\Auth::user()->can('Create Transfer Balance')) { $validator = \Validator::make( $request->all(), [ 'from_account_id' => 'required', 'to_account_id' => 'required', 'date' => 'required', 'amount' => 'required', 'payment_type_id' => 'required', ] ); if($validator->fails()) { $messages = $validator->getMessageBag(); return redirect()->back()->with('error', $messages->first()); } $transferbalance = new TransferBalance(); $transferbalance->from_account_id = $request->from_account_id; $transferbalance->to_account_id = $request->to_account_id; $transferbalance->date = $request->date; $transferbalance->amount = $request->amount; $transferbalance->payment_type_id = $request->payment_type_id; $transferbalance->referal_id = $request->referal_id; $transferbalance->description = $request->description; $transferbalance->created_by = \Auth::user()->creatorId(); $transferbalance->save(); AccountList::transfer_Balance($request->from_account_id, $request->to_account_id, $request->amount); return redirect()->route('transferbalance.index')->with('success', __('TransferBalance successfully created.')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } public function show(TransferBalance $transferbalance) { return redirect()->route('transferbalance.index'); } public function edit(TransferBalance $transferbalance) { if(\Auth::user()->can('Edit Transfer Balance')) { if($transferbalance->created_by == \Auth::user()->creatorId()) { $transferbalances = TransferBalance::where('created_by', '=', \Auth::user()->creatorId())->get(); $accounts = AccountList::where('created_by', '=', \Auth::user()->creatorId())->get()->pluck('account_name', 'id'); $incomeCategory = IncomeType::where('created_by', '=', \Auth::user()->creatorId())->get()->pluck('name', 'id'); $paymentTypes = PaymentType::where('created_by', '=', \Auth::user()->creatorId())->get()->pluck('name', 'id'); return view('transferbalance.edit', compact('transferbalance', 'accounts', 'incomeCategory', 'paymentTypes')); } else { return response()->json(['error' => __('Permission denied.')], 401); } } else { return response()->json(['error' => __('Permission denied.')], 401); } } public function update(Request $request, TransferBalance $transferbalance) { if(\Auth::user()->can('Edit Transfer Balance')) { if($transferbalance->created_by == \Auth::user()->creatorId()) { $validator = \Validator::make( $request->all(), [ 'from_account_id' => 'required', 'to_account_id' => 'required', 'date' => 'required', 'amount' => 'required', 'payment_type_id' => 'required', ] ); if($validator->fails()) { $messages = $validator->getMessageBag(); return redirect()->back()->with('error', $messages->first()); } $transferbalance->from_account_id = $request->from_account_id; $transferbalance->to_account_id = $request->to_account_id; $transferbalance->date = $request->date; $transferbalance->amount = $request->amount; $transferbalance->payment_type_id = $request->payment_type_id; $transferbalance->referal_id = $request->referal_id; $transferbalance->description = $request->description; $transferbalance->save(); return redirect()->route('transferbalance.index')->with('success', __('TransferBalance successfully updated.')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } else { return redirect()->back()->with('error', __('Permission denied.')); } } public function destroy(TransferBalance $transferbalance) { if(\Auth::user()->can('Delete Transfer Balance')) { if($transferbalance->created_by == \Auth::user()->creatorId()) { $transferbalance->delete(); return redirect()->route('transferbalance.index')->with('success', __('TransferBalance successfully deleted.')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } else { return redirect()->back()->with('error', __('Permission denied.')); } } public function export(Request $request) { $name = 'TransferBalance_' . date('Y-m-d i:h:s'); $data = Excel::download(new TransferBalanceExport(), $name . '.xlsx'); return $data; } } Controllers/MercadoPaymentController.php000064400000026340150364311770014553 0ustar00type == 'company') { $payment_setting = Utility::getAdminPaymentSetting(); $this->currancy = !empty($payment_setting['currency']) ? $payment_setting['currency'] : 'USD'; $this->token = isset($payment_setting['mercado_access_token']) ? $payment_setting['mercado_access_token'] : ''; $this->mode = isset($payment_setting['mercado_mode']) ? $payment_setting['mercado_mode'] : ''; $this->is_enabled = isset($payment_setting['is_mercado_enabled']) ? $payment_setting['is_mercado_enabled'] : 'off'; return $this; } } public function planPayWithMercado(Request $request) { $this->setPaymentDetail(); $planID = \Illuminate\Support\Facades\Crypt::decrypt($request->plan_id); $plan = Plan::find($planID); $authuser = Auth::user(); $coupons_id = 0; if ($plan) { /* Check for code usage */ $plan->discounted_price = false; $price = $plan->price; if (isset($request->coupon) && !empty($request->coupon)) { $request->coupon = trim($request->coupon); $coupons = Coupon::where('code', strtoupper($request->coupon))->where('is_active', '1')->first(); if (!empty($coupons)) { $usedCoupun = $coupons->used_coupon(); $discount_value = ($price / 100) * $coupons->discount; $plan->discounted_price = $price - $discount_value; $coupons_id = $coupons->id; if ($usedCoupun >= $coupons->limit) { return redirect()->back()->with('error', __('This coupon code has expired.')); } $price = $price - $discount_value; } else { return redirect()->back()->with('error', __('This coupon code is invalid or has expired.')); } } if ($price <= 0) { $authuser->plan = $plan->id; $authuser->save(); $assignPlan = $authuser->assignPlan($plan->id); if ($assignPlan['is_success'] == true && !empty($plan)) { $orderID = time(); $user = Auth::user(); if ($request->has('coupon') && $request->coupon != '') { $coupons = Coupon::where('code', strtoupper($request->coupon))->where('is_active', '1')->first(); if (!empty($coupons)) { $userCoupon = new UserCoupon(); $userCoupon->user = $user->id; $userCoupon->coupon = $coupons->id; $userCoupon->order = $orderID; $userCoupon->save(); $usedCoupun = $coupons->used_coupon(); if ($coupons->limit <= $usedCoupun) { $coupons->is_active = 0; $coupons->save(); } } } Order::create( [ 'order_id' => $orderID, 'name' => null, 'email' => null, 'card_number' => null, 'card_exp_month' => null, 'card_exp_year' => null, 'plan_name' => $plan->name, 'plan_id' => $plan->id, 'price' => $price == null ? 0 : $price, 'price_currency' => !empty($this->currancy) ? $this->currancy : 'USD', 'txn_id' => '', 'payment_type' => 'Mercado Pago', 'payment_status' => 'succeeded', 'receipt' => null, 'user_id' => $authuser->id, ] ); // $res['msg'] = __("Plan successfully upgraded."); // $res['flag'] = 2; return redirect()->route('plans.index')->with('success', __('Plan activated Successfully!')); // return $res; } else { return Utility::error_res(__('Plan fail to upgrade.')); } } $payment_setting = Utility::getAdminPaymentSetting(); $this->token = isset($payment_setting['mercado_access_token']) ? $payment_setting['mercado_access_token'] : ''; $this->mode = isset($payment_setting['mercado_mode']) ? $payment_setting['mercado_mode'] : ''; $this->is_enabled = isset($payment_setting['is_mercado_enabled']) ? $payment_setting['is_mercado_enabled'] : 'off'; \MercadoPago\SDK::setAccessToken($this->token); try { // Create a preference object $preference = new \MercadoPago\Preference(); // Create an item in the preference $item = new \MercadoPago\Item(); $item->title = "Plan : " . $plan->name; $item->quantity = 1; $item->unit_price = (float)$price; $preference->items = array($item); $success_url = route('plan.mercado', [$request->plan_id, 'payment_frequency=' . $request->mercado_payment_frequency, 'coupon_id=' . $coupons_id, 'flag' => 'success', 'price' => $price]); $failure_url = route('plan.mercado', [$request->plan_id, 'flag' => 'failure']); $pending_url = route('plan.mercado', [$request->plan_id, 'flag' => 'pending']); $preference->back_urls = array( "success" => $success_url, "failure" => $failure_url, "pending" => $pending_url ); $preference->auto_return = "approved"; $preference->save(); // Create a customer object $payer = new \MercadoPago\Payer(); // Create payer information $payer->name = \Auth::user()->name; $payer->email = \Auth::user()->email; $payer->address = array( "street_name" => '' ); if ($this->mode == 'live') { $redirectUrl = $preference->init_point; } else { $redirectUrl = $preference->sandbox_init_point; } return redirect($redirectUrl); } catch (\Exception $e) { return redirect()->back()->with('error', $e->getMessage()); } // callback url : domain.com/plan/mercado } else { return redirect()->back()->with('error', 'Plan is deleted.'); } } public function getPaymentStatus(Request $request, $plan) { $this->setPaymentDetail(); $payment_setting = Utility::getAdminPaymentSetting(); $planID = \Illuminate\Support\Facades\Crypt::decrypt($plan); $plan = Plan::find($planID); $user = Auth::user(); $orderID = time(); if ($plan) { try { // dd($plan, $request->all()); if ($plan && $request->has('status')) { if ($request->status == 'approved' && $request->flag == 'success') { if (!empty($user->payment_subscription_id) && $user->payment_subscription_id != '') { try { $user->cancel_subscription($user->id); } catch (\Exception $exception) { \Log::debug($exception->getMessage()); } } if ($request->has('coupon_id') && $request->coupon_id != '') { $coupons = Coupon::find($request->coupon_id); if (!empty($coupons)) { $userCoupon = new UserCoupon(); $userCoupon->user = $user->id; $userCoupon->coupon = $coupons->id; $userCoupon->order = $orderID; $userCoupon->save(); $usedCoupun = $coupons->used_coupon(); if ($coupons->limit <= $usedCoupun) { $coupons->is_active = 0; $coupons->save(); } } } Utility::referralTransaction($plan); $order = new Order(); $order->order_id = $orderID; $order->name = $user->name; $order->card_number = ''; $order->card_exp_month = ''; $order->card_exp_year = ''; $order->plan_name = $plan->name; $order->plan_id = $plan->id; $order->price = $request->price ? $request->price : 0; $order->price_currency = $payment_setting['currency']; $order->txn_id = $request->has('preference_id') ? $request->preference_id : ''; $order->payment_type = 'Mercado Pago'; $order->payment_status = 'succeeded'; $order->receipt = ''; $order->user_id = $user->id; $order->save(); $assignPlan = $user->assignPlan($plan->id, $request->payment_frequency); if ($assignPlan['is_success']) { return redirect()->route('plans.index')->with('success', __('Plan activated Successfully!')); } else { return redirect()->route('plans.index')->with('error', __($assignPlan['error'])); } } else { return redirect()->route('plans.index')->with('error', __('Transaction has been failed! ')); } } else { return redirect()->route('plans.index')->with('error', __('Transaction has been failed! ')); } } catch (\Exception $e) { return redirect()->route('plans.index')->with('error', __('Plan not found!')); } } } } Controllers/AssetController.php000064400000016564150364311770012731 0ustar00can('Manage Assets')) { $assets = Asset::where('created_by', '=', \Auth::user()->creatorId())->get(); return view('assets.index', compact('assets')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } public function create() { if (\Auth::user()->can('Create Assets')) { $employee = Employee::where('created_by', '=', \Auth::user()->creatorId())->get()->pluck('name', 'id'); return view('assets.create',compact('employee')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } public function store(Request $request) { if (\Auth::user()->can('Create Assets')) { $validator = \Validator::make( $request->all(), [ 'employee_id'=>'required', 'name' => 'required', 'purchase_date' => 'required', 'supported_date' => 'required', 'amount' => 'required', ] ); if ($validator->fails()) { $messages = $validator->getMessageBag(); return redirect()->back()->with('error', $messages->first()); } $employee_id = 0; if (!empty($request->employee_id)) { $employee_id = implode(',', $request->employee_id); } $assets = new Asset(); $assets->employee_id = $employee_id; $assets->name = $request->name; $assets->purchase_date = $request->purchase_date; $assets->supported_date = $request->supported_date; $assets->amount = $request->amount; $assets->description = $request->description; $assets->created_by = \Auth::user()->creatorId(); $assets->save(); return redirect()->route('account-assets.index')->with('success', __('Assets successfully created.')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } public function show(Asset $asset) { // } public function edit($id) { if (\Auth::user()->can('Edit Assets')) { $asset = Asset::find($id); $employee = Employee::where('created_by', '=', \Auth::user()->creatorId())->get()->pluck('name', 'id'); return view('assets.edit', compact('asset','employee')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } public function update(Request $request, $id) { if (\Auth::user()->can('Edit Assets')) { $asset = Asset::find($id); if ($asset->created_by == \Auth::user()->creatorId()) { $validator = \Validator::make( $request->all(), [ 'name' => 'required', 'purchase_date' => 'required', 'supported_date' => 'required', 'amount' => 'required', ] ); if ($validator->fails()) { $messages = $validator->getMessageBag(); return redirect()->back()->with('error', $messages->first()); } $employee_id = 0; if (!empty($request->employee_id)) { $employee_id = implode(',', $request->employee_id); } $asset->name = $request->name; $asset->employee_id = $employee_id; $asset->purchase_date = $request->purchase_date; $asset->supported_date = $request->supported_date; $asset->amount = $request->amount; $asset->description = $request->description; $asset->save(); return redirect()->route('account-assets.index')->with('success', __('Assets successfully updated.')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } else { return redirect()->back()->with('error', __('Permission denied.')); } } public function destroy($id) { if (\Auth::user()->can('Delete Assets')) { $asset = Asset::find($id); if ($asset->created_by == \Auth::user()->creatorId()) { $asset->delete(); return redirect()->route('account-assets.index')->with('success', __('Assets successfully deleted.')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } else { return redirect()->back()->with('error', __('Permission denied.')); } } public function export() { $name = 'assets_' . date('Y-m-d i:h:s'); $data = Excel::download(new AssetsExport(), $name . '.xlsx'); return $data; } public function importFile(Request $request) { return view('assets.import'); } public function import(Request $request) { $rules = [ 'file' => 'required|mimes:csv,txt', ]; $validator = \Validator::make($request->all(), $rules); if ($validator->fails()) { $messages = $validator->getMessageBag(); return redirect()->back()->with('error', $messages->first()); } $assets = (new AssetsImport())->toArray(request()->file('file'))[0]; $totalassets = count($assets) - 1; $errorArray = []; for ($i = 1; $i <= $totalassets; $i++) { $asset = $assets[$i]; $assetsData = Asset::where('name', $asset[0])->where('purchase_date', $asset[2])->first(); if (!empty($assetsData)) { $errorArray[] = $assetsData; } else { $asset_data = new Asset(); $asset_data->name=$asset[0]; $asset_data->employee_id=$asset[1]; $asset_data->purchase_date=$asset[2]; $asset_data->supported_date=$asset[3]; $asset_data->amount=$asset[4]; $asset_data->description=$asset[5]; $asset_data->created_by = Auth::user()->id; $asset_data->save(); } } if (empty($errorArray)) { $data['status'] = 'success'; $data['msg'] = __('Record successfully imported'); } else { $data['status'] = 'error'; $data['msg'] = count($errorArray) . ' ' . __('Record imported fail out of' . ' ' . $totalassets . ' ' . 'record'); foreach ($errorArray as $errorData) { $errorRecord[] = implode(',', $errorData->toArray()); } \Session::put('errorArray', $errorRecord); } return redirect()->back()->with($data['status'], $data['msg']); } } Controllers/HomeController.php000064400000022652150364311770012535 0ustar00type == 'employee') { $emp = Employee::where('user_id', '=', $user->id)->first(); $announcements = Announcement::orderBy('announcements.id', 'desc')->take(5)->leftjoin('announcement_employees', 'announcements.id', '=', 'announcement_employees.announcement_id')->where('announcement_employees.employee_id', '=', $emp->id)->orWhere( function ($q) { $q->where('announcements.department_id', 0)->where('announcements.employee_id', 0); } )->get(); $employees = Employee::get(); $meetings = Meeting::orderBy('meetings.id', 'desc')->take(5)->leftjoin('meeting_employees', 'meetings.id', '=', 'meeting_employees.meeting_id')->where('meeting_employees.employee_id', '=', $emp->id)->orWhere( function ($q) { $q->where('meetings.department_id', 0)->where('meetings.employee_id', 0); } )->get(); $events = Event::select('events.*', 'events.id as event_id', 'event_employees.*')->leftjoin('event_employees', 'events.id', '=', 'event_employees.event_id')->where('event_employees.employee_id', '=', $emp->id)->orWhere( function ($q) { $q->where('events.department_id', 0)->where('events.employee_id', 0); } )->get(); $arrEvents = []; foreach ($events as $event) { $arr['id'] = $event['event_id']; $arr['title'] = $event['title']; $arr['start'] = $event['start_date']; $arr['end'] = $event['end_date']; $arr['className'] = $event['color']; // $arr['borderColor'] = "#fff"; $arr['url'] = (!empty($event['event_id'])) ? route('eventsshow', $event['event_id']) : '0'; // $arr['url'] = (!empty($event['event_id'])) ? route('eventsshow', $event['event_id']) : '0'; // $arr['textColor'] = "white"; $arrEvents[] = $arr; } $date = date("Y-m-d"); $time = date("H:i:s"); $employeeAttendance = AttendanceEmployee::orderBy('id', 'desc')->where('employee_id', '=', !empty(\Auth::user()->employee) ? \Auth::user()->employee->id : 0)->where('date', '=', $date)->first(); $officeTime['startTime'] = Utility::getValByName('company_start_time'); $officeTime['endTime'] = Utility::getValByName('company_end_time'); return view('dashboard.dashboard', compact('arrEvents', 'announcements', 'employees', 'meetings', 'employeeAttendance', 'officeTime')); } else if ($user->type == 'super admin') { $user = \Auth::user(); $user['total_user'] = $user->countCompany(); $user['total_paid_user'] = $user->countPaidCompany(); $user['total_orders'] = Order::total_orders(); $user['total_orders_price'] = Order::total_orders_price(); $user['total_plan'] = Plan::total_plan(); $user['most_purchese_plan'] = (!empty(Plan::most_purchese_plan()) ? Plan::most_purchese_plan()->name : ''); $chartData = $this->getOrderChart(['duration' => 'week']); return view('dashboard.super_admin', compact('user', 'chartData')); } else { $events = Event::where('created_by', '=', \Auth::user()->creatorId())->get(); $arrEvents = []; foreach ($events as $event) { $arr['id'] = $event['id']; $arr['title'] = $event['title']; $arr['start'] = $event['start_date']; $arr['end'] = $event['end_date']; $arr['className'] = $event['color']; // $arr['borderColor'] = "#fff"; // $arr['textColor'] = "white"; $arr['url'] = route('event.edit', $event['id']); $arrEvents[] = $arr; } $announcements = Announcement::orderBy('announcements.id', 'desc')->take(5)->where('created_by', '=', \Auth::user()->creatorId())->get(); $employees = User::where('type', '=', 'employee')->where('created_by', '=', \Auth::user()->creatorId())->get(); $countEmployee = count($employees); $user = User::where('type', '!=', 'employee')->where('created_by', '=', \Auth::user()->creatorId())->get(); $countUser = count($user); $countTicket = Ticket::where('created_by', '=', \Auth::user()->creatorId())->count(); $countOpenTicket = Ticket::where('status', '=', 'open')->where('created_by', '=', \Auth::user()->creatorId())->count(); $countCloseTicket = Ticket::where('status', '=', 'close')->where('created_by', '=', \Auth::user()->creatorId())->count(); $currentDate = date('Y-m-d'); // $employees = User::where('type', '=', 'employee')->where('created_by', '=', \Auth::user()->creatorId())->get(); // $countEmployee = count($employees); $notClockIn = AttendanceEmployee::where('date', '=', $currentDate)->get()->pluck('employee_id'); $notClockIns = Employee::where('created_by', '=', \Auth::user()->creatorId())->whereNotIn('id', $notClockIn)->get(); $accountBalance = AccountList::where('created_by', '=', \Auth::user()->creatorId())->sum('initial_balance'); $activeJob = Job::where('status', 'active')->where('created_by', '=', \Auth::user()->creatorId())->count(); $inActiveJOb = Job::where('status', 'in_active')->where('created_by', '=', \Auth::user()->creatorId())->count(); $totalPayee = Payees::where('created_by', '=', \Auth::user()->creatorId())->count(); $totalPayer = Payer::where('created_by', '=', \Auth::user()->creatorId())->count(); $meetings = Meeting::where('created_by', '=', \Auth::user()->creatorId())->limit(8)->get(); $users = User::find(\Auth::user()->creatorId()); $plan = Plan::find($users->plan); if ($plan->storage_limit > 0) { $storage_limit = ($users->storage_limit / $plan->storage_limit) * 100; } else { $storage_limit = 0; } return view('dashboard.dashboard', compact('arrEvents', 'announcements', 'employees', 'activeJob', 'inActiveJOb', 'meetings', 'countEmployee', 'countUser', 'countTicket', 'countOpenTicket', 'countCloseTicket', 'notClockIns', 'accountBalance', 'totalPayee', 'totalPayer', 'users', 'plan', 'storage_limit')); } } else { if (!file_exists(storage_path() . "/installed")) { header('location:install'); die; } else { $settings = Utility::settings(); if ($settings['display_landing_page'] == 'on' && \Schema::hasTable('landing_page_settings')) { $plans = Plan::get(); $get_section = LandingPageSection::orderBy('section_order', 'ASC')->get(); return view('landingpage::layouts.landingpage', compact('plans', 'get_section')); } else { return redirect('login'); } } } } public function getOrderChart($arrParam) { $arrDuration = []; if ($arrParam['duration']) { if ($arrParam['duration'] == 'week') { $previous_week = strtotime("-2 week +1 day"); for ($i = 0; $i < 14; $i++) { $arrDuration[date('Y-m-d', $previous_week)] = date('d-M', $previous_week); $previous_week = strtotime(date('Y-m-d', $previous_week) . " +1 day"); } } } $arrTask = []; $arrTask['label'] = []; $arrTask['data'] = []; foreach ($arrDuration as $date => $label) { $data = Order::select(\DB::raw('count(*) as total'))->whereDate('created_at', '=', $date)->first(); $arrTask['label'][] = $label; $arrTask['data'][] = $data->total; } return $arrTask; } } Controllers/PlanRequestController.php000064400000013660150364311770014107 0ustar00type == 'super admin') { $plan_requests = PlanRequest::all(); return view('plan_request.index', compact('plan_requests')); } else { return redirect()->back()->with('error', __('Permission Denied.')); } } /* *@plan_id = Plan ID encoded */ public function requestView($plan_id) { if (Auth::user()->type != 'super admin') { $planID = \Illuminate\Support\Facades\Crypt::decrypt($plan_id); $plan = Plan::find($planID); if (!empty($plan)) { return view('plan_request.show', compact('plan')); } else { return redirect()->back()->with('error', __('Something went wrong.')); } } else { return redirect()->back()->with('error', __('Permission Denied.')); } } /* * @plan_id = Plan ID encoded * @duration = what duration is selected by user while request */ public function userRequest($plan_id) { $objUser = Auth::user(); if ($objUser->requested_plan == 0) { $planID = \Illuminate\Support\Facades\Crypt::decrypt($plan_id); $plan = Plan::where('id', $planID)->first(); if (!empty($planID)) { PlanRequest::create([ 'user_id' => $objUser->id, 'plan_id' => $planID, 'duration' => $plan->duration ]); // Update User Table $objUser['requested_plan'] = $planID; $objUser->update(); return redirect()->back()->with('success', __('Request Send Successfully.')); } else { return redirect()->back()->with('error', __('Something went wrong.')); } } else { return redirect()->back()->with('error', __('You already send request to another plan.')); } } /* * @id = Project ID * @response = 1(accept) or 0(reject) */ public function acceptRequest($id, $response) { if (Auth::user()->type == 'super admin') { $payment_setting = Utility::getAdminPaymentSetting(); $plan_request = PlanRequest::find($id); if (!empty($plan_request)) { $user = User::find($plan_request->user_id); if ($response == 1) { $user->requested_plan = $plan_request->plan_id; $user->plan = $plan_request->plan_id; $user->requested_plan = '0'; $user->save(); $plan = Plan::find($plan_request->plan_id); $assignPlan = $user->assignPlan($plan_request->plan_id, $plan_request->duration); $price = $plan->price; if ($assignPlan['is_success'] == true && !empty($plan)) { if (!empty($user->payment_subscription_id) && $user->payment_subscription_id != '') { try { $user->cancel_subscription($user->id); } catch (\Exception $exception) { \Log::debug($exception->getMessage()); } } $orderID = strtoupper(str_replace('.', '', uniqid('', true))); Order::create([ 'order_id' => $orderID, 'name' => null, 'email' => null, 'card_number' => null, 'card_exp_month' => null, 'card_exp_year' => null, 'plan_name' => $plan->name, 'plan_id' => $plan->id, 'price' => $price, 'price_currency' => !empty($payment_setting['currency']) ? $payment_setting['currency'] : 'usd', 'txn_id' => '', 'payment_type' => __('Manually Upgrade By Super Admin'), 'payment_status' => 'succeeded', 'receipt' => null, 'user_id' => $user->id, ]); $plan_request->delete(); return redirect()->back()->with('success', __('Plan successfully upgraded.')); } else { return redirect()->back()->with('error', __('Plan fail to upgrade.')); } } else { // $user->update(['requested_plan' => '0']); $user['requested_plan'] = 0; $user->update(); $plan_request->delete(); return redirect()->back()->with('success', __('Request Rejected Successfully.')); } } else { return redirect()->back()->with('error', __('Something went wrong.')); } } else { return redirect()->back()->with('error', __('Permission Denied.')); } } /* * @id = User ID */ public function cancelRequest($id) { $user = User::find($id); $user['requested_plan'] = '0'; $user->update(); PlanRequest::where('user_id', $id)->delete(); return redirect()->back()->with('success', __('Request Canceled Successfully.')); } public function show(PlanRequest $planRequest) { } } Controllers/MolliePaymentController.php000064400000023743150364311770014426 0ustar00type == 'company') { $admin_payment_setting = Utility::getAdminPaymentSetting(); $this->api_key = isset($admin_payment_setting['mollie_api_key']) ? $admin_payment_setting['mollie_api_key'] : ''; $this->profile_id = isset($admin_payment_setting['mollie_profile_id']) ? $admin_payment_setting['mollie_profile_id'] : ''; $this->partner_id = isset($admin_payment_setting['mollie_partner_id']) ? $admin_payment_setting['mollie_partner_id'] : ''; $this->is_enabled = isset($admin_payment_setting['is_mollie_enabled']) ? $admin_payment_setting['is_mollie_enabled'] : 'off'; return $this; } } public function planPayWithMollie(Request $request) { $admin_payment_setting = Utility::getAdminPaymentSetting(); $payment = $this->paymentConfig(); $planID = \Illuminate\Support\Facades\Crypt::decrypt($request->plan_id); $plan = Plan::find($planID); $authuser = Auth::user(); $coupons_id = 0; if($plan) { $price = $plan->price; if(isset($request->coupon) && !empty($request->coupon)) { $request->coupon = trim($request->coupon); $coupons = Coupon::where('code', strtoupper($request->coupon))->where('is_active', '1')->first(); if(!empty($coupons)) { $usedCoupun = $coupons->used_coupon(); $discount_value = ($price / 100) * $coupons->discount; $plan->discounted_price = $price - $discount_value; $coupons_id = $coupons->id; if($usedCoupun >= $coupons->limit) { return redirect()->back()->with('error', __('This coupon code has expired.')); } $price = $price - $discount_value; } else { return redirect()->back()->with('error', __('This coupon code is invalid or has expired.')); } } if($price <= 0) { $authuser->plan = $plan->id; $authuser->save(); $assignPlan = $authuser->assignPlan($plan->id); if($assignPlan['is_success'] == true && !empty($plan)) { $orderID = time(); $user = Auth::user(); if ($request->has('coupon') && $request->coupon != '') { $coupons = Coupon::where('code', strtoupper($request->coupon))->where('is_active', '1')->first(); if (!empty($coupons)) { $userCoupon = new UserCoupon(); $userCoupon->user = $user->id; $userCoupon->coupon = $coupons->id; $userCoupon->order = $orderID; $userCoupon->save(); $usedCoupun = $coupons->used_coupon(); if ($coupons->limit <= $usedCoupun) { $coupons->is_active = 0; $coupons->save(); } } } Order::create( [ 'order_id' => $orderID, 'name' => null, 'email' => null, 'card_number' => null, 'card_exp_month' => null, 'card_exp_year' => null, 'plan_name' => $plan->name, 'plan_id' => $plan->id, 'price' => $price == null ? 0 : $price, 'price_currency' => !empty($admin_payment_setting['currency']) ? $admin_payment_setting['currency'] : 'USD', 'txn_id' => '', 'payment_type' => __('Mollie'), 'payment_status' => 'succeeded', 'receipt' => null, 'user_id' => $authuser->id, ] ); $assignPlan = $authuser->assignPlan($plan->id); return redirect()->route('plans.index')->with('success', __('Plan activated Successfully!')); } else { return redirect()->back()->with('error', __('Plan fail to upgrade.')); } } $mollie = new \Mollie\Api\MollieApiClient(); $mollie->setApiKey($payment->api_key); $payment = $mollie->payments->create( [ "amount" => [ "currency" => $admin_payment_setting['currency'], "value" => number_format($price, 2), ], "description" => "payment for product", "redirectUrl" => route( 'plan.mollie', [ $request->plan_id, 'coupon_id=' . $coupons_id, 'price' => $price, ] ), ] ); session()->put('mollie_payment_id', $payment->id); return redirect($payment->getCheckoutUrl())->with('payment_id', $payment->id); } else { return redirect()->back()->with('error', 'Plan is deleted.'); } } public function getPaymentStatus(Request $request, $plan) { $admin_payment_setting = Utility::getAdminPaymentSetting(); $payment = $this->paymentConfig(); $planID = \Illuminate\Support\Facades\Crypt::decrypt($plan); $plan = Plan::find($planID); $user = Auth::user(); $orderID = time(); if($plan) { try { $mollie = new \Mollie\Api\MollieApiClient(); $mollie->setApiKey($payment->api_key); if(session()->has('mollie_payment_id')) { $payment = $mollie->payments->get(session()->get('mollie_payment_id')); if($payment->isPaid()) { if($request->has('coupon_id') && $request->coupon_id != '') { $coupons = Coupon::find($request->coupon_id); if(!empty($coupons)) { $userCoupon = new UserCoupon(); $userCoupon->user = $user->id; $userCoupon->coupon = $coupons->id; $userCoupon->order = $orderID; $userCoupon->save(); $usedCoupun = $coupons->used_coupon(); if($coupons->limit <= $usedCoupun) { $coupons->is_active = 0; $coupons->save(); } } } Utility::referralTransaction($plan); $order = new Order(); $order->order_id = $orderID; $order->name = $user->name; $order->card_number = ''; $order->card_exp_month = ''; $order->card_exp_year = ''; $order->plan_name = $plan->name; $order->plan_id = $plan->id; $order->price = $request->price ? $request->price : 0; $order->price_currency = $admin_payment_setting['currency']; $order->txn_id = isset($request->TXNID) ? $request->TXNID : ''; $order->payment_type = __('Mollie'); $order->payment_status = 'success'; $order->receipt = ''; $order->user_id = $user->id; $order->save(); $assignPlan = $user->assignPlan($plan->id, $request->payment_frequency); if($assignPlan['is_success']) { return redirect()->route('plans.index')->with('success', __('Plan activated Successfully!')); } else { return redirect()->route('plans.index')->with('error', __($assignPlan['error'])); } } else { return redirect()->route('plans.index')->with('error', __('Transaction has been failed! ')); } } else { return redirect()->route('plans.index')->with('error', __('Transaction has been failed! ')); } } catch(\Exception $e) { return redirect()->route('plans.index')->with('error', __('Plan not found!')); } } } } Controllers/TrainerController.php000064400000016303150364311770013245 0ustar00can('Manage Trainer')) { $trainers = Trainer::where('created_by', '=', \Auth::user()->creatorId())->get(); return view('trainer.index', compact('trainers')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } public function create() { if(\Auth::user()->can('Create Trainer')) { $branches = Branch::where('created_by', \Auth::user()->creatorId())->get()->pluck('name', 'id'); return view('trainer.create', compact('branches')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } public function store(Request $request) { if(\Auth::user()->can('Create Trainer')) { $validator = \Validator::make( $request->all(), [ 'branch' => 'required', 'firstname' => 'required', 'lastname' => 'required', 'contact' => 'required', 'email' => 'required', ] ); if($validator->fails()) { $messages = $validator->getMessageBag(); return redirect()->back()->with('error', $messages->first()); } $trainer = new Trainer(); $trainer->branch = $request->branch; $trainer->firstname = $request->firstname; $trainer->lastname = $request->lastname; $trainer->contact = $request->contact; $trainer->email = $request->email; $trainer->address = $request->address; $trainer->expertise = $request->expertise; $trainer->created_by = \Auth::user()->creatorId(); $trainer->save(); return redirect()->route('trainer.index')->with('success', __('Trainer successfully created.')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } public function show(Trainer $trainer) { return view('trainer.show', compact('trainer')); } public function edit(Trainer $trainer) { if(\Auth::user()->can('Edit Trainer')) { $branches = Branch::where('created_by', \Auth::user()->creatorId())->get()->pluck('name', 'id'); return view('trainer.edit', compact('branches', 'trainer')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } public function update(Request $request, Trainer $trainer) { if(\Auth::user()->can('Edit Trainer')) { $validator = \Validator::make( $request->all(), [ 'branch' => 'required', 'firstname' => 'required', 'lastname' => 'required', 'contact' => 'required', 'email' => 'required', ] ); if($validator->fails()) { $messages = $validator->getMessageBag(); return redirect()->back()->with('error', $messages->first()); } $trainer->branch = $request->branch; $trainer->firstname = $request->firstname; $trainer->lastname = $request->lastname; $trainer->contact = $request->contact; $trainer->email = $request->email; $trainer->address = $request->address; $trainer->expertise = $request->expertise; $trainer->save(); return redirect()->route('trainer.index')->with('success', __('Trainer successfully updated.')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } public function destroy(Trainer $trainer) { if(\Auth::user()->can('Delete Trainer')) { if($trainer->created_by == \Auth::user()->creatorId()) { $trainer->delete(); return redirect()->route('trainer.index')->with('success', __('Trainer successfully deleted.')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } else { return redirect()->back()->with('error', __('Permission denied.')); } } public function export() { $name = 'trainer_' . date('Y-m-d i:h:s'); $data = Excel::download(new TrainerExport(), $name . '.xlsx'); return $data; } public function importFile(Request $request) { return view('trainer.import'); } public function import(Request $request) { $rules = [ 'file' => 'required|mimes:csv,txt', ]; $validator = \Validator::make($request->all(), $rules); if ($validator->fails()) { $messages = $validator->getMessageBag(); return redirect()->back()->with('error', $messages->first()); } $trainer = (new TrainerImport())->toArray(request()->file('file'))[0]; $totaltrainer = count($trainer) - 1; $errorArray = []; for($i=1;$i<=$totaltrainer;$i++) { $trainers = $trainer[$i]; $trainersData=Trainer::where('email',$trainers[4])->first(); if(!empty($trainersData)) { $errorArray[]=$trainersData; } else { $trainer_data=new Trainer(); $getBranchId = Branch::where('name', $trainers[0])->first(); $trainer_data->branch= !empty($getBranchId->id) ? $getBranchId->id : ''; $trainer_data->firstname=$trainers[1]; $trainer_data->lastname=$trainers[2]; $trainer_data->contact=$trainers[3]; $trainer_data->email=$trainers[4]; $trainer_data->address=$trainers[5]; $trainer_data->expertise=$trainers[6]; $trainer_data->created_by=Auth::user()->id; $trainer_data->save(); } } if (empty($errorArray)) { $data['status'] = 'success'; $data['msg'] = __('Record successfully imported'); } else { $data['status'] = 'error'; $data['msg'] = count($errorArray) . ' ' . __('Record imported fail out of' . ' ' . $totaltrainer . ' ' . 'record'); foreach ($errorArray as $errorData) { $errorRecord[] = implode(',', $errorData->toArray()); } \Session::put('errorArray', $errorRecord); } return redirect()->back()->with($data['status'], $data['msg']); } } Controllers/DocumentController.php000064400000010420150364311770013411 0ustar00can('Manage Document Type')) { $documents = Document::where('created_by', '=', \Auth::user()->creatorId())->get(); return view('document.index', compact('documents')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } public function create() { if(\Auth::user()->can('Create Document Type')) { return view('document.create'); } else { return response()->json(['error' => __('Permission denied.')], 401); } } public function store(Request $request) { if(\Auth::user()->can('Create Document Type')) { $validator = \Validator::make( $request->all(), [ 'name' => 'required|max:20', 'is_required' => 'required', ] ); if($validator->fails()) { $messages = $validator->getMessageBag(); return redirect()->back()->with('error', $messages->first()); } $document = new Document(); $document->name = $request->name; $document->is_required = $request->is_required; $document->created_by = \Auth::user()->creatorId(); $document->save(); return redirect()->route('document.index')->with('success', __('Document type successfully created.')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } public function show(Document $document) { return redirect()->route('document.index'); } public function edit(Document $document) { if(\Auth::user()->can('Edit Document Type')) { if($document->created_by == \Auth::user()->creatorId()) { return view('document.edit', compact('document')); } else { return response()->json(['error' => __('Permission denied.')], 401); } } else { return response()->json(['error' => __('Permission denied.')], 401); } } public function update(Request $request, Document $document) { if(\Auth::user()->can('Edit Document Type')) { if($document->created_by == \Auth::user()->creatorId()) { $validator = \Validator::make( $request->all(), [ 'name' => 'required|max:20', ] ); if($validator->fails()) { $messages = $validator->getMessageBag(); return redirect()->back()->with('error', $messages->first()); } $document->name = $request->name; $document->is_required = $request->is_required; $document->save(); return redirect()->route('document.index')->with('success', __('Document type successfully updated.')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } else { return redirect()->back()->with('error', __('Permission denied.')); } } public function destroy(Document $document) { if(\Auth::user()->can('Delete Document Type')) { if($document->created_by == \Auth::user()->creatorId()) { $document->delete(); return redirect()->route('document.index')->with('success', __('Document type successfully deleted.')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } else { return redirect()->back()->with('error', __('Permission denied.')); } } } Controllers/DucumentUploadController.php000064400000020136150364311770014571 0ustar00can('Manage Document')) { if (\Auth::user()->type == 'company') { $documents = DucumentUpload::where('created_by', \Auth::user()->creatorId())->get(); } else { $userRole = \Auth::user()->roles->first(); $documents = DucumentUpload::whereIn( 'role', [ $userRole->id, 0, ] )->where('created_by', \Auth::user()->creatorId())->get(); } return view('documentUpload.index', compact('documents')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } public function create() { if (\Auth::user()->can('Create Document')) { $roles = Role::where('created_by', \Auth::user()->creatorId())->get()->pluck('name', 'id'); $roles->prepend('All', '0'); return view('documentUpload.create', compact('roles')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } public function store(Request $request) { if (\Auth::user()->can('Create Document')) { $validator = \Validator::make( $request->all(), [ 'name' => 'required', 'role' => 'required', 'documents' => 'required', ] ); if ($validator->fails()) { $messages = $validator->getMessageBag(); return redirect()->back()->with('error', $messages->first()); } $roles = $request->role; $document = new DucumentUpload(); $document->name = $request->name; $document->role = $request->role; $document->description = $request->description; $document->created_by = \Auth::user()->creatorId(); if (!empty($request->documents)) { $image_size = $request->file('documents')->getSize(); $result = Utility::updateStorageLimit(\Auth::user()->creatorId(), $image_size); if ($result == 1) { $filenameWithExt = $request->file('documents')->getClientOriginalName(); $filename = pathinfo($filenameWithExt, PATHINFO_FILENAME); $extension = $request->file('documents')->getClientOriginalExtension(); $fileNameToStore = $filename . '_' . time() . '.' . $extension; $dir = 'uploads/documentUpload/'; $image_path = $dir . $fileNameToStore; $url = ''; $path = Utility::upload_file($request, 'documents', $fileNameToStore, $dir, []); $document->document = !empty($request->documents) ? $fileNameToStore : ''; if ($path['flag'] == 1) { $url = $path['url']; } else { return redirect()->back()->with('error', __($path['msg'])); } } } $document->save(); // return redirect()->route('document-upload.index')->with('success', __('Document successfully uploaded.')); return redirect()->route('document-upload.index')->with('success', __('Document successfully uploaded.') . ((isset($result) && $result != 1) ? '
' . $result . '' : '')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } public function show(DucumentUpload $ducumentUpload) { // } public function edit($id) { if (\Auth::user()->can('Edit Document')) { $roles = Role::where('created_by', \Auth::user()->creatorId())->get()->pluck('name', 'id'); $roles->prepend('All', '0'); $ducumentUpload = DucumentUpload::find($id); return view('documentUpload.edit', compact('roles', 'ducumentUpload')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } public function update(Request $request, $id) { if (\Auth::user()->can('Edit Document')) { $validator = \Validator::make( $request->all(), [ 'name' => 'required', 'documents' => 'required', ] ); if ($validator->fails()) { $messages = $validator->getMessageBag(); return redirect()->back()->with('error', $messages->first()); } $roles = $request->role; $document = DucumentUpload::find($id); $document->name = $request->name; $document->role = $request->role; $document->description = $request->description; if (!empty($request->documents)) { //storage limit $dir = 'uploads/documentUpload/'; $file_path = $dir . $document->document; $image_size = $request->file('documents')->getSize(); $result = Utility::updateStorageLimit(\Auth::user()->creatorId(), $image_size); if ($result == 1) { Utility::changeStorageLimit(\Auth::user()->creatorId(), $file_path); $filenameWithExt = $request->file('documents')->getClientOriginalName(); $filename = pathinfo($filenameWithExt, PATHINFO_FILENAME); $extension = $request->file('documents')->getClientOriginalExtension(); $fileNameToStore = $filename . '_' . time() . '.' . $extension; $dir = 'uploads/documentUpload/'; $image_path = $dir . $fileNameToStore; $url = ''; $path = Utility::upload_file($request, 'documents', $fileNameToStore, $dir, []); $document->document = !empty($request->documents) ? $fileNameToStore : ''; if ($path['flag'] == 1) { $url = $path['url']; } else { return redirect()->back()->with('error', __($path['msg'])); } } } $document->save(); // return redirect()->route('document-upload.index')->with('success', __('Document successfully uploaded.')); return redirect()->route('document-upload.index')->with('success', __('Document successfully uploaded.') . ((isset($result) && $result != 1) ? '
' . $result . '' : '')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } public function destroy($id) { if (\Auth::user()->can('Delete Document')) { $document = DucumentUpload::find($id); if ($document->created_by == \Auth::user()->creatorId()) { $document->delete(); if (!empty($document->document)) { // $dir = storage_path('uploads/documentUpload/'); //storage limit $file_path = 'uploads/documentUpload/' . $document->document; $result = Utility::changeStorageLimit(\Auth::user()->creatorId(), $file_path); // unlink($dir . $document->document); } return redirect()->route('document-upload.index')->with('success', __('Document successfully deleted.')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } else { return redirect()->back()->with('error', __('Permission denied.')); } } } Controllers/PaymentWallPaymentController.php000064400000020405150364311770015432 0ustar00all(); $admin_payment_setting = Utility::getAdminPaymentSetting(); return view('plan.paymentwall', compact('data', 'admin_payment_setting')); } public function paymentConfig($user) { if (Auth::check()) { $user = Auth::user(); } if ($user->type == 'company') { $payment_setting = Utility::getAdminPaymentSetting(); } else { $payment_setting = Utility::getCompanyPaymentSetting(); } $this->secret_key = isset($payment_setting['paymentwall_private_key ']) ? $payment_setting['paymentwall_private_key '] : ''; $this->public_key = isset($payment_setting['paymentwall_public_key']) ? $payment_setting['paymentwall_public_key'] : ''; $this->is_enabled = isset($payment_setting['is_paymentwall_enabled']) ? $payment_setting['is_paymentwall_enabled'] : 'off'; return $this; } public function paymenterror($flag, Request $request) { if ($flag == 1) { return redirect()->route("plans.index")->with('error', __('Transaction has been Successfull! ')); } else { return redirect()->route("plans.index")->with('error', __('Transaction has been failed!')); } } public function planPayWithPaymentwall(Request $request, $plan_id) { $admin_payment_setting = Utility::getAdminPaymentSetting(); $planID = \Illuminate\Support\Facades\Crypt::decrypt($plan_id); $plan = Plan::find($planID); $authuser = Auth::user(); $coupon_id = ''; if ($plan) { $price = $plan->price; if ($price <= 0) { $authuser->plan = $plan->id; $authuser->save(); $assignPlan = $authuser->assignPlan($plan->id); if ($assignPlan['is_success'] == true && !empty($plan)) { $orderID = strtoupper(str_replace('.', '', uniqid('', true))); $user = Auth::user(); if ($request->has('coupon') && $request->coupon != '') { $coupons = Coupon::where('code', strtoupper($request->coupon))->where('is_active', '1')->first(); if (!empty($coupons)) { $userCoupon = new UserCoupon(); $userCoupon->user = $user->id; $userCoupon->coupon = $coupons->id; $userCoupon->order = $orderID; $userCoupon->save(); $usedCoupun = $coupons->used_coupon(); if ($coupons->limit <= $usedCoupun) { $coupons->is_active = 0; $coupons->save(); } } } Order::create( [ 'order_id' => $orderID, 'name' => null, 'email' => null, 'card_number' => null, 'card_exp_month' => null, 'card_exp_year' => null, 'plan_name' => $plan->name, 'plan_id' => $plan->id, 'price' => $price == null ? 0 : $price, 'price_currency' => !empty($admin_payment_setting['currency']) ? $admin_payment_setting['currency'] : 'usd', 'txn_id' => '', 'payment_type' => __('Flutterwave'), 'payment_status' => 'succeeded', 'receipt' => null, 'user_id' => $authuser->id, ] ); $res['msg'] = __("Plan successfully upgraded."); $res['flag'] = 2; return $res; } } else $orderID = time(); { \Paymentwall_Config::getInstance()->set(array( 'private_key' => 'sdrsefrszdef' )); $parameters = $request->all(); $chargeInfo = array( 'email' => $parameters['email'], 'history[registration_date]' => '1489655092', 'amount' => $price, 'currency' => !empty($this->currancy) ? $this->currancy : 'USD', 'token' => $parameters['brick_token'], 'fingerprint' => $parameters['brick_fingerprint'], 'description' => 'Order #123' ); $charge = new \Paymentwall_Charge(); $charge->create($chargeInfo); $responseData = json_decode($charge->getRawResponseData(), true); $response = $charge->getPublicData(); if ($charge->isSuccessful() and empty($responseData['secure'])) { if ($charge->isCaptured()) { if ($request->has('coupon') && $request->coupon != '') { $coupons = Coupon::find($request->coupon); if (!empty($coupons)) { $userCoupon = new UserCoupon(); $userCoupon->user = $authuser->id; $userCoupon->coupon = $coupons->id; $userCoupon->order = $orderID; $userCoupon->save(); $usedCoupun = $coupons->used_coupon(); if ($coupons->limit <= $usedCoupun) { $coupons->is_active = 0; $coupons->save(); } } } Utility::referralTransaction($plan); $orderID = time(); $order = new Order(); $order->order_id = $orderID; $order->name = $authuser->name; $order->card_number = ''; $order->card_exp_month = ''; $order->card_exp_year = ''; $order->plan_name = $plan->name; $order->plan_id = $plan->id; $order->price = isset($paydata['amount']) ? $paydata['amount'] : $price; $order->price_currency = $this->currancy; $order->txn_id = isset($paydata['txid']) ? $paydata['txid'] : 0; $order->payment_type = __('PaymentWall'); $order->payment_status = 'success'; $order->receipt = ''; $order->user_id = $authuser->id; $order->save(); $assignPlan = $authuser->assignPlan($plan->id); if ($assignPlan['is_success']) { $res['msg'] = __("Plan successfully upgraded."); $res['flag'] = 1; return $res; } } elseif ($charge->isUnderReview()) { // decide on risk charge } } elseif (!empty($responseData['secure'])) { $response = json_encode(array('secure' => $responseData['secure'])); } else { $errors = json_decode($response, true); $res['flag'] = 2; return $res; } echo $response; } } } } Controllers/SaturationDeductionController.php000064400000013600150364311770015626 0ustar00creatorId())->get()->pluck('name', 'id'); $saturationdeduc = SaturationDeduction::$saturationDeductiontype; return view('saturationdeduction.create', compact('employee', 'deduction_options','saturationdeduc')); } public function store(Request $request) { if(\Auth::user()->can('Create Saturation Deduction')) { $validator = \Validator::make( $request->all(), [ 'employee_id' => 'required', 'deduction_option' => 'required', 'title' => 'required', 'amount' => 'required', ] ); if($validator->fails()) { $messages = $validator->getMessageBag(); return redirect()->back()->with('error', $messages->first()); } $saturationdeduction = new SaturationDeduction; $saturationdeduction->employee_id = $request->employee_id; $saturationdeduction->deduction_option = $request->deduction_option; $saturationdeduction->title = $request->title; $saturationdeduction->type = $request->type; $saturationdeduction->amount = $request->amount; $saturationdeduction->created_by = \Auth::user()->creatorId(); $saturationdeduction->save(); if($saturationdeduction->type == 'percentage') { $employee = Employee::find($saturationdeduction->employee_id); $saturationdeductionsal = $saturationdeduction->amount * $employee->salary / 100; } return redirect()->back()->with('success', __('SaturationDeduction successfully created.')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } public function show(SaturationDeduction $saturationdeduction) { return redirect()->route('commision.index'); } public function edit($saturationdeduction) { $saturationdeduction = SaturationDeduction::find($saturationdeduction); if(\Auth::user()->can('Edit Saturation Deduction')) { if($saturationdeduction->created_by == \Auth::user()->creatorId()) { $deduction_options = DeductionOption::where('created_by', \Auth::user()->creatorId())->get()->pluck('name', 'id'); $saturationdeduc = SaturationDeduction::$saturationDeductiontype; return view('saturationdeduction.edit', compact('saturationdeduction', 'deduction_options','saturationdeduc')); } else { return response()->json(['error' => __('Permission denied.')], 401); } } else { return response()->json(['error' => __('Permission denied.')], 401); } } public function update(Request $request, SaturationDeduction $saturationdeduction) { if(\Auth::user()->can('Edit Saturation Deduction')) { if($saturationdeduction->created_by == \Auth::user()->creatorId()) { $validator = \Validator::make( $request->all(), [ 'deduction_option' => 'required', 'title' => 'required', 'amount' => 'required', ] ); if($validator->fails()) { $messages = $validator->getMessageBag(); return redirect()->back()->with('error', $messages->first()); } $saturationdeduction->deduction_option = $request->deduction_option; $saturationdeduction->title = $request->title; $saturationdeduction->type = $request->type; $saturationdeduction->amount = $request->amount; $saturationdeduction->save(); if($saturationdeduction->type == 'percentage') { $employee = Employee::find($saturationdeduction->employee_id); $saturationdeductionsal = $saturationdeduction->amount * $employee->salary / 100; } return redirect()->back()->with('success', __('SaturationDeduction successfully updated.')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } else { return redirect()->back()->with('error', __('Permission denied.')); } } public function destroy(SaturationDeduction $saturationdeduction) { if(\Auth::user()->can('Delete Saturation Deduction')) { if($saturationdeduction->created_by == \Auth::user()->creatorId()) { $saturationdeduction->delete(); return redirect()->back()->with('success', __('SaturationDeduction successfully deleted.')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } else { return redirect()->back()->with('error', __('Permission denied.')); } } } Controllers/ToyyibpayPaymentController.php000064400000027106150364311770015173 0ustar00secretKey = isset($admin_payment_setting['toyyibpay_secret_key']) ? $admin_payment_setting['toyyibpay_secret_key'] : ''; $this->categoryCode = isset($admin_payment_setting['toyyibpay_category_code']) ? $admin_payment_setting['toyyibpay_category_code'] : ''; $this->is_enabled = isset($admin_payment_setting['is_toyyibpay_enabled']) ? $admin_payment_setting['is_toyyibpay_enabled'] : ''; } public function charge(Request $request) { try { $planID = \Illuminate\Support\Facades\Crypt::decrypt($request->plan_id); $admin_payment_setting = Utility::getAdminPaymentSetting(); $plan = Plan::find($planID); if ($plan) { $get_amount = $plan->price; if (!empty($request->coupon)) { $coupons = Coupon::where('code', strtoupper($request->coupon))->where('is_active', '1')->first(); if (!empty($coupons)) { $usedCoupun = $coupons->used_coupon(); $discount_value = ($plan->price / 100) * $coupons->discount; $get_amount = $plan->price - $discount_value; if ($coupons->limit == $usedCoupun) { return redirect()->back()->with('error', __('This coupon code has expired.')); } } else { return redirect()->back()->with('error', __('This coupon code is invalid or has expired.')); } } if ($get_amount <= 0) { $orderID = strtoupper(str_replace('.', '', uniqid('', true))); $user = auth()->user(); $statuses = 'success'; $order = new Order(); $order->order_id = $orderID; $order->name = $user->name; $order->card_number = ''; $order->card_exp_month = ''; $order->card_exp_year = ''; $order->plan_name = $plan->name; $order->plan_id = $plan->id; $order->price = $get_amount; $order->price_currency = $admin_payment_setting['currency']; $order->payment_type = __('Toyyibpay'); $order->payment_status = $statuses; $order->receipt = ''; $order->user_id = $user->id; $order->save(); $assignPlan = $user->assignPlan($plan->id); $coupons = Coupon::find($request->coupon_id); if ($request->has('coupon') && $request->coupon != '') { $coupons = Coupon::where('code', strtoupper($request->coupon))->where('is_active', '1')->first(); if (!empty($coupons)) { $userCoupon = new UserCoupon(); $userCoupon->user = $user->id; $userCoupon->coupon = $coupons->id; $userCoupon->order = $orderID; $userCoupon->save(); $usedCoupun = $coupons->used_coupon(); if ($coupons->limit <= $usedCoupun) { $coupons->is_active = 0; $coupons->save(); } } } if ($assignPlan['is_success']) { return redirect()->route('plans.index')->with('success', __('Plan activated Successfully.')); } else { return redirect()->route('plans.index')->with('error', __($assignPlan['error'])); } } $coupon = (empty($request->coupon)) ? "0" : $request->coupon; $this->callBackUrl = route('plan.toyyibpay', [$plan->id, $get_amount, $coupon]); $this->returnUrl = route('plan.toyyibpay', [$plan->id, $get_amount, $coupon]); $Date = date('d-m-Y'); $ammount = $get_amount; $billName = $plan->name; $description = $plan->name; $billExpiryDays = 3; $billExpiryDate = date('d-m-Y', strtotime($Date . ' + 3 days')); $billContentEmail = "Thank you for purchasing our product!"; $some_data = array( 'userSecretKey' => $this->secretKey, 'categoryCode' => $this->categoryCode, 'billName' => $billName, 'billDescription' => $description, 'billPriceSetting' => 1, 'billPayorInfo' => 1, 'billAmount' => 100 * $ammount, 'billReturnUrl' => $this->returnUrl, 'billCallbackUrl' => $this->callBackUrl, 'billExternalReferenceNo' => 'AFR341DFI', 'billTo' => \Auth::user()->name, 'billEmail' => \Auth::user()->email, 'billPhone' => '0000000000', 'billSplitPayment' => 0, 'billSplitPaymentArgs' => '', 'billPaymentChannel' => '0', 'billContentEmail' => $billContentEmail, 'billChargeToCustomer' => 1, 'billExpiryDate' => $billExpiryDate, 'billExpiryDays' => $billExpiryDays ); $curl = curl_init(); curl_setopt($curl, CURLOPT_POST, 1); curl_setopt($curl, CURLOPT_URL, 'https://toyyibpay.com/index.php/api/createBill'); curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); curl_setopt($curl, CURLOPT_POSTFIELDS, $some_data); $result = curl_exec($curl); $info = curl_getinfo($curl); curl_close($curl); $obj = json_decode($result); return redirect('https://toyyibpay.com/' . $obj[0]->BillCode); } else { return redirect()->route('plans.index')->with('error', __('Plan is deleted.')); } } catch (Exception $e) { return redirect()->route('plans.index')->with('error', __($e->getMessage())); } } public function status(Request $request, $planId, $getAmount, $couponCode) { $admin_payment_setting = Utility::getAdminPaymentSetting(); if ($couponCode != 0) { $coupons = Coupon::where('code', strtoupper($couponCode))->where('is_active', '1')->first(); $request['coupon_id'] = $coupons->id; } else { $coupons = null; } $plan = Plan::find($planId); $user = auth()->user(); // $request['status_id'] = 1; // 1=success, 2=pending, 3=fail try { $orderID = strtoupper(str_replace('.', '', uniqid('', true))); if ($request->status_id == 3) { $statuses = 'Fail'; $order = new Order(); $order->order_id = $orderID; $order->name = $user->name; $order->card_number = ''; $order->card_exp_month = ''; $order->card_exp_year = ''; $order->plan_name = $plan->name; $order->plan_id = $plan->id; $order->price = $getAmount; $order->price_currency = $admin_payment_setting['currency']; $order->payment_type = __('Toyyibpay'); $order->payment_status = $statuses; $order->receipt = ''; $order->user_id = $user->id; $order->save(); return redirect()->route('plans.index')->with('error', __('Your Transaction is fail please try again')); } else if ($request->status_id == 2) { $statuses = 'pandding'; $order = new Order(); $order->order_id = $orderID; $order->name = $user->name; $order->card_number = ''; $order->card_exp_month = ''; $order->card_exp_year = ''; $order->plan_name = $plan->name; $order->plan_id = $plan->id; $order->price = $getAmount; $order->price_currency = $admin_payment_setting['currency']; $order->payment_type = __('Toyyibpay'); $order->payment_status = $statuses; $order->receipt = ''; $order->user_id = $user->id; $order->save(); return redirect()->route('plans.index')->with('success', __('Your transaction on pandding')); } else if ($request->status_id == 1) { Utility::referralTransaction($plan); $statuses = 'success'; $order = new Order(); $order->order_id = $orderID; $order->name = $user->name; $order->card_number = ''; $order->card_exp_month = ''; $order->card_exp_year = ''; $order->plan_name = $plan->name; $order->plan_id = $plan->id; $order->price = $getAmount; $order->price_currency = $admin_payment_setting['currency']; $order->payment_type = __('Toyyibpay'); $order->payment_status = $statuses; $order->receipt = ''; $order->user_id = $user->id; $order->save(); $assignPlan = $user->assignPlan($plan->id); $coupons = Coupon::find($request->coupon_id); if (!empty($request->coupon_id)) { if (!empty($coupons)) { $userCoupon = new UserCoupon(); $userCoupon->user = $user->id; $userCoupon->coupon = $coupons->id; $userCoupon->order = $orderID; $userCoupon->save(); $usedCoupun = $coupons->used_coupon(); if ($coupons->limit <= $usedCoupun) { $coupons->is_active = 0; $coupons->save(); } } } if ($assignPlan['is_success']) { return redirect()->route('plans.index')->with('success', __('Plan activated Successfully.')); } else { return redirect()->route('plans.index')->with('error', __($assignPlan['error'])); } } else { return redirect()->route('plans.index')->with('error', __('Plan is deleted.')); } } catch (Exception $e) { return redirect()->route('plans.index')->with('error', __($e->getMessage())); } } } Controllers/PaystackPaymentController.php000064400000021635150364311770014762 0ustar00type == 'company') { $admin_payment_setting = Utility::getAdminPaymentSetting(); $this->secret_key = isset($admin_payment_setting['paystack_secret_key']) ? $admin_payment_setting['paystack_secret_key'] : ''; $this->public_key = isset($admin_payment_setting['paystack_public_key']) ? $admin_payment_setting['paystack_public_key'] : ''; $this->is_enabled = isset($admin_payment_setting['is_paystack_enabled']) ? $admin_payment_setting['is_paystack_enabled'] : 'off'; return $this; } } public function planPayWithPaystack(Request $request) { $planID = \Illuminate\Support\Facades\Crypt::decrypt($request->plan_id); $admin_payment_setting = Utility::getAdminPaymentSetting(); $plan = Plan::find($planID); $authuser = \Auth::user(); $coupon_id = ''; if ($plan) { $price = $plan->price; if (isset($request->coupon) && !empty($request->coupon)) { $coupons = Coupon::where('code', strtoupper($request->coupon))->where('is_active', '1')->first(); if (!empty($coupons)) { $usedCoupun = $coupons->used_coupon(); $discount_value = ($plan->price / 100) * $coupons->discount; $price = $plan->price - $discount_value; if ($coupons->limit == $usedCoupun) { return redirect()->back()->with('error', __('This coupon code has expired.')); } $coupon_id = $coupons->id; } else { return redirect()->back()->with('error', __('This coupon code is invalid or has expired.')); } } if ($price <= 0) { $authuser->plan = $plan->id; $authuser->save(); $assignPlan = $authuser->assignPlan($plan->id); if ($assignPlan['is_success'] == true && !empty($plan)) { $orderID = strtoupper(str_replace('.', '', uniqid('', true))); $user = Auth::user(); if ($request->has('coupon') && $request->coupon != '') { $coupons = Coupon::where('code', strtoupper($request->coupon))->where('is_active', '1')->first(); if (!empty($coupons)) { $userCoupon = new UserCoupon(); $userCoupon->user = $user->id; $userCoupon->coupon = $coupons->id; $userCoupon->order = $orderID; $userCoupon->save(); $usedCoupun = $coupons->used_coupon(); if ($coupons->limit <= $usedCoupun) { $coupons->is_active = 0; $coupons->save(); } } } Order::create( [ 'order_id' => $orderID, 'name' => null, 'email' => null, 'card_number' => null, 'card_exp_month' => null, 'card_exp_year' => null, 'plan_name' => $plan->name, 'plan_id' => $plan->id, 'price' => $price, 'price_currency' => !empty($admin_payment_setting['currency']) ? $admin_payment_setting['currency'] : 'NGN', 'txn_id' => '', 'payment_type' => 'Paystack', 'payment_status' => 'succeeded', 'receipt' => null, 'user_id' => $authuser->id, ] ); $res['msg'] = __("Plan successfully upgraded."); $res['flag'] = 2; return $res; } else { return redirect()->route('plans.index')->with('error', __('Plan fail to upgrade.')); } } $res_data['email'] = \Auth::user()->email; $res_data['total_price'] = $price; $res_data['currency'] = $admin_payment_setting['currency']; $res_data['flag'] = 1; $res_data['coupon'] = $coupon_id; return $res_data; } else { return redirect()->route('plans.index')->with('error', __('Plan is deleted.')); } } public function getPaymentStatus(Request $request, $pay_id, $plan) { $payment = $this->paymentConfig(); $planID = \Illuminate\Support\Facades\Crypt::decrypt($plan); $plan = Plan::find($planID); $user = Auth::user(); $result = array(); if ($plan) { try { $orderID = strtoupper(str_replace('.', '', uniqid('', true))); //The parameter after verify/ is the transaction reference to be verified $url = "https://api.paystack.co/transaction/verify/$pay_id"; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt( $ch, CURLOPT_HTTPHEADER, [ 'Authorization: Bearer ' . $payment->secret_key, ] ); $responce = curl_exec($ch); curl_close($ch); if ($responce) { $result = json_decode($responce, true); } if (isset($result['status']) && $result['status'] == true) { $status = $result['data']['status']; if ($request->has('coupon_id') && $request->coupon_id != '') { $coupons = Coupon::find($request->coupon_id); if (!empty($coupons)) { $userCoupon = new UserCoupon(); $userCoupon->user = $user->id; $userCoupon->coupon = $coupons->id; $userCoupon->order = $orderID; $userCoupon->save(); $usedCoupun = $coupons->used_coupon(); if ($coupons->limit <= $usedCoupun) { $coupons->is_active = 0; $coupons->save(); } } } Utility::referralTransaction($plan); $order = new Order(); $order->order_id = $orderID; $order->name = $user->name; $order->card_number = ''; $order->card_exp_month = ''; $order->card_exp_year = ''; $order->plan_name = $plan->name; $order->plan_id = $plan->id; $order->price = $result['data']['amount'] / 100; $order->price_currency = !empty($admin_payment_setting['currency']) ? $admin_payment_setting['currency'] : 'NGN'; $order->txn_id = $pay_id; $order->payment_type = __('Paystack'); $order->payment_status = $result['data']['status']; $order->receipt = ''; $order->user_id = $user->id; $order->save(); $assignPlan = $user->assignPlan($plan->id); if ($assignPlan['is_success']) { return redirect()->route('plans.index')->with('success', __('Plan activated Successfully.')); } else { return redirect()->route('plans.index')->with('error', $assignPlan['error']); } } else { return redirect()->back()->with('error', __('Transaction Unsuccesfull')); } } catch (\Exception $e) { return redirect()->route('plans.index')->with('error', __('Transaction has been failed.')); } } else { return redirect()->route('plans.index')->with('error', __('Plan is deleted.')); } } } Controllers/LandingPageSectionController.php000064400000076720150364311770015350 0ustar00type == 'super admin') { $get_section = LandingPageSection::orderBy('section_order', 'ASC')->get(); return view('custom_landing_page.index', compact('get_section')); } return redirect()->back()->with('error', 'Permission denied.'); } public function setConetent(Request $request) { if(\Auth::user()->type == 'super admin') { $id = $request->id; $section_type = $request->section_type; $menu_name = $request->menu_name; $text_value = $request->text_value; $image = $request->image; $logo = $request->logo; $button = $request->button; $section_order = $request->section_order; $image_array = $request->image_array; $system_page_id = $request->system_page_id; $system_element_id = $request->system_element_id; $content_type = $request->content_type; $system_new_tab = $request->system_new_tab; $custom_class_name = $request->custom_class_name; $get_section = LandingPageSection::where(['id' => $id])->first(); if(!is_null($get_section)) { if($get_section->section_type == "section-plan") { $content = $get_section->default_content; } else { $data = []; if($get_section->content == "" || $get_section->content == null) { $get_content = $get_section->default_content; } else { $get_content = $get_section->content; } $decode_content = json_decode($get_content); foreach($decode_content as $key => $value) { if($key == "custom_class_name") { $data['custom_class_name'] = $custom_class_name; } if($key == "logo") { if($request->hasFile('logo')) { $ext = $logo->getClientOriginalExtension(); $fileName = 'logo_' . time() . rand() . '.' . $ext; $request->file('logo')->storeAs('uploads/custom_landing_page_image', $fileName); $data['logo'] = $fileName; } else { $data['logo'] = $value; } } else if($key == "image") { if($request->hasFile('image')) { $ext = $image->getClientOriginalExtension(); $fileName = 'image_' . time() . rand() . '.' . $ext; $request->file('image')->storeAs('uploads/custom_landing_page_image', $fileName); $data['image'] = $fileName; } else { $data['image'] = $value; } } else if($key == "button") { if(!is_null($button)) { foreach($button as $text_key => $text_val) { if($text_key == "text") { $btn_data['text'] = $text_val; $data['button'] = $btn_data; } else if($text_key == "href") { $btn_data['href'] = $text_val; $data['button'] = $btn_data; } } } else { $data['button'] = $value; } } else if($key == "menu") { if(!is_null($menu_name)) { foreach($menu_name as $menu_key => $menu_value) { $menu_data['menu'] = $menu_value['text']; $menu_data['href'] = $menu_value['href']; $data['menu'][] = $menu_data; } } else { $data['menu'] = $value; } } else if($key == "text") { if(!is_null($text_value)) { $no = 1; foreach($text_value as $text_key => $text_val) { $text_data['text-' . $no] = $text_val; $data['text'] = $text_data; $no++; } } else { $data['text'] = $value; } } else if($key == "image_array") { $no = 1; if(!is_null($image_array)) { foreach($image_array as $image_array_key => $image_array_val) { foreach($value as $val_key => $val_data) { if($val_data->id == $image_array_key) { $ext = $image_array_val->getClientOriginalExtension(); $fileName = 'logo_' . $no . '_' . time() . rand() . '.' . $ext; $image_array_val->storeAs('uploads/custom_landing_page_image', $fileName); $val_data->image = $fileName; } } } $data['image_array'] = $value; } else { $data['image_array'] = $value; } } else if($key == "system") { if($content_type == "new_tab") { $sys_data['id'] = count($value) + 1; $sys_data['name'] = $system_new_tab; $sys_data['data'] = []; $value[] = $sys_data; $data['system'] = $value; } else if($content_type == "update_tab_content") { $system_data = []; foreach($value as $key => $sys_value) { $system_inner_data = []; if($sys_value->id == $system_element_id) { foreach($sys_value->data as $data_key => $data_value) { if($data_value->data_id == $system_page_id) { $no = 1; $data_text = []; foreach($text_value as $text_key => $text_val) { $data_text['text_' . $no] = $text_val; $no++; } $data_value->text = $data_text; $data_value->button->text = $button['text']; $data_value->button->href = $button['href']; if($request->hasFile('image')) { $ext = $image->getClientOriginalExtension(); $fileName = 'image_' . time() . rand() . '.' . $ext; $request->file('image')->storeAs('uploads/custom_landing_page_image', $fileName); $data_value->image = $fileName; } } $system_inner_data[] = $data_value; } $sys_value->data = $system_inner_data; $system_data[] = $sys_value; } else { $system_data[] = $sys_value; } $data['system'] = $system_data; } } else if($content_type == "new_tab_content") { $system_inner_data = []; foreach($value as $key => $sys_value) { if($sys_value->id == $system_element_id) { $no = 1; $data_text = []; foreach($text_value as $text_key => $text_val) { $data_text['text_' . $no] = $text_val; $no++; } $data_value['data_id'] = count($sys_value->data) + 1; $data_value['text'] = $data_text; $data_value['button']['text'] = $button['text']; $data_value['button']['href'] = $button['href']; if($request->hasFile('image')) { $ext = $image->getClientOriginalExtension(); $fileName = 'image_' . time() . rand() . '.' . $ext; $request->file('image')->storeAs('uploads/custom_landing_page_image', $fileName); $data_value['image'] = $fileName; } /*$system_inner_data[] = $data_value;*/ $sys_value->data[] = $data_value; } $system_inner_data[] = $sys_value; } $data['system'] = $system_inner_data; } else if($content_type == "remove_element") { foreach($value as $key => $sys_value) { if($sys_value->id == $system_element_id) { } else { $system_data[] = $sys_value; } $data['system'] = $system_data; } } else if($content_type == "remove_element_data") { $system_data = []; foreach($value as $key => $sys_value) { $system_inner_data = []; if($sys_value->id == $system_element_id) { foreach($sys_value->data as $data_key => $data_value) { if($data_value->data_id == $system_page_id) { } else { $system_inner_data[] = $data_value; } } $sys_value->data = $system_inner_data; $system_data[] = $sys_value; } else { $system_data[] = $sys_value; } $data['system'] = $system_data; } } else { $data['system'] = $value; } } else if($key == "testimonials") { $testinomial_data = []; if($content_type == "update_section") { foreach($value as $key => $test_value) { if($system_element_id == $test_value->id) { $no = 1; $data_text = []; foreach($text_value as $text_key => $text_val) { $data_text['text_' . $no] = $text_val; $no++; } $data_value['text'] = $data_text; if($request->hasFile('image')) { $ext = $image->getClientOriginalExtension(); $fileName = 'image_' . time() . rand() . '.' . $ext; $request->file('image')->storeAs('uploads/custom_landing_page_image', $fileName); $data_value['image'] = $fileName; } else { $data_value['image'] = $test_value->image; } $data_value['id'] = $test_value->id; $data['testimonials'][] = $data_value; } else { $data['testimonials'][] = $test_value; } } } else if($content_type == "new_section") { $no = 1; $data_text = []; $data_value['id'] = count($value) + 1; foreach($text_value as $text_key => $text_val) { $data_text['text_' . $no] = $text_val; $no++; } $data_value['text'] = $data_text; if($request->hasFile('image')) { $ext = $image->getClientOriginalExtension(); $fileName = 'image_' . time() . rand() . '.' . $ext; $request->file('image')->storeAs('uploads/custom_landing_page_image', $fileName); $data_value['image'] = $fileName; } else { $data_value['image'] = "default-thumbnail.jpg"; } $value[] = $data_value; $data['testimonials'] = $value; } else if($content_type == "remove_element") { foreach($value as $key => $test_value) { if($test_value->id == $system_element_id) { } else { $data['testimonials'][] = $test_value; } } } else { $data['testimonials'] = $value; } } else if($key == "footer") { $footer_data = []; if(is_null($menu_name)) { $data['footer'] = $value; } else { foreach($value as $key => $json_val) { if($key == "logo") { if($request->hasFile('logo')) { $ext = $logo->getClientOriginalExtension(); $fileName = 'logo_' . time() . rand() . '.' . $ext; $request->file('logo')->storeAs('uploads/custom_landing_page_image', $fileName); $json_val->logo = $fileName; } if(!is_null($text_value)) { $json_val->text = $text_value; } $data['footer']['logo'] = $json_val; } if($key == "footer_menu") { if(!is_null($menu_name['footer_menu'])) { $test_value = $menu_name['footer_menu']; $inner = []; foreach($test_value as $key => $val) { $inner_data = []; $inner_data['id'] = $key; $inner_data['menu'] = $val['menu']; $inner_data1 = []; foreach($val['data'] as $key => $val1) { $inner_data1['menu_name'] = $val1['text']; $inner_data1['menu_href'] = $val1['href']; $inner_data['data'][] = $inner_data1; } $inner[] = $inner_data; } $data['footer']['footer_menu'] = $inner; } else { $data['footer']['footer_menu'] = $json_val; } } if($key == "bottom_menu") { if(!is_null($menu_name['bottom_menu'])) { $test_value = $menu_name['bottom_menu']; $inner_data = []; $inner_data['id'] = $key; $inner_data['text'] = $test_value['text']; $inner_data1 = []; foreach($test_value['data'] as $key => $val) { $inner_data1['menu_name'] = $val['text']; $inner_data1['menu_href'] = $val['href']; $inner_data['data'][] = $inner_data1; } $data['footer']['bottom_menu'] = $inner_data; } else { $data['footer']['bottom_menu'] = $json_val; } } if($key == "contact_app") { if(!is_null($menu_name['contact_app'])) { $test_value = $menu_name['contact_app']; $inner_data = []; $inner_data['menu'] = $test_value['menu']; $inner_data1 = []; foreach($test_value['data'] as $key => $val) { //print_r($val['image']);die; foreach($json_val[0] as $json_key => $json_data) { if($json_key == "data") { foreach($json_data as $contact_key => $contact_data) { if($val['id'] == $contact_data->id) { if(!empty($val['image'])) { $ext = $val['image']->getClientOriginalExtension(); $fileName = 'contact_app_' . time() . $contact_key . rand() . '.' . $ext; $val['image']->storeAs('uploads/custom_landing_page_image', $fileName); $contact_data->image = $fileName; } if(!empty($val['href'])) { $contact_data->image_href = $val['href']; } $json_data = $contact_data; } } $inner_data1[] = $json_data; } } } $inner_data['data'] = $inner_data1; $data['footer']['contact_app'][] = $inner_data; } else { $data['footer']['contact_app'][] = $json_val; } } } } } } $content = json_encode($data); } $Landing_page_section = LandingPageSection::findOrfail($get_section->id); $Landing_page_section->content = $content; $Landing_page_section->save(); return $get_section; } else { return "error"; } } return redirect()->back()->with('error', 'Permission denied.'); } public function removeSection($id) { if(\Auth::user()->type == 'super admin') { $Landing_page_section = LandingPageSection::findOrfail($id); $get_alredy_exist_section = LandingPageSection::where(['section_type' => $Landing_page_section->section_type])->whereNotIn('id', [$id])->get(); if(count($get_alredy_exist_section) > 0) { $Landing_page_section->delete(); } else { $Landing_page_section->content = ''; $Landing_page_section->save(); } } return redirect()->back()->with('error', 'Permission denied.'); } public function setOrder(Request $request) { if(\Auth::user()->type == 'super admin') { $element_array = $request->element_array; $order = 1; if(count($element_array) > 0) { foreach($element_array as $key => $value) { $Landing_page_section = LandingPageSection::findOrfail($value); $Landing_page_section->section_order = $order; $Landing_page_section->save(); $order++; } } return 0; } return redirect()->back()->with('error', 'Permission denied.'); } public function copySection(Request $request) { if(\Auth::user()->type == 'super admin') { $id = $request->id; $get_section = LandingPageSection::where(['id' => $id])->first(); if(!is_null($get_section)) { $Landing_page_section = new LandingPageSection(); $Landing_page_section->section_name = $get_section->section_name; $Landing_page_section->section_order = $get_section->section_order; $Landing_page_section->default_content = $get_section->default_content; $Landing_page_section->section_name = $get_section->section_name; $Landing_page_section->content = $get_section->content; $Landing_page_section->section_demo_image = $get_section->section_demo_image; $Landing_page_section->section_blade_file_name = $get_section->section_blade_file_name; $Landing_page_section->section_type = $get_section->section_type; $Landing_page_section->save(); return 1; } else { return "error"; } } return redirect()->back()->with('error', 'Permission denied.'); } public function show(Request $request, $id) { $section_name = $request->section_name; $section_type = $request->section_type; $get_content = LandingPageSection::where(['id' => $id])->first(); if(!is_null($get_content)) { $data['id'] = $get_content->id; $data['section_name'] = $get_content->section_name; $data['section_type'] = $get_content->section_type; if($get_content->content == "" || $get_content->content == null) { $data['content'] = $get_content->default_content; } else { $data['content'] = $get_content->content; } return json_encode($data); } else { return "error"; } } } Controllers/PaytabController.php000064400000021463150364311770013064 0ustar00 isset($payment_setting['paytab_profile_id']) ? $payment_setting['paytab_profile_id'] : '', 'paytabs.server_key' => isset($payment_setting['paytab_server_key']) ? $payment_setting['paytab_server_key'] : '', 'paytabs.region' => isset($payment_setting['paytab_region']) ? $payment_setting['paytab_region'] : '', 'paytabs.currency' => !empty($payment_setting['currency']) ? $payment_setting['currency'] : 'USD', ]); } } public function planPayWithpaytab(Request $request) { try { $planID = \Illuminate\Support\Facades\Crypt::decrypt($request->plan_id); $plan = Plan::find($planID); $this->paymentconfig(); $user = \Auth::user(); if ($plan) { $get_amount = $plan->price; if (!empty($request->coupon)) { $coupons = Coupon::where('code', strtoupper($request->coupon))->where('is_active', '1')->first(); if (!empty($coupons)) { $usedCoupun = $coupons->used_coupon(); $discount_value = ($plan->price / 100) * $coupons->discount; $get_amount = $plan->price - $discount_value; if ($coupons->limit == $usedCoupun) { return redirect()->back()->with('error', __('This coupon code has expired.')); } if ($get_amount <= 0) { $authuser = \Auth::user(); $authuser->plan = $plan->id; $authuser->save(); $assignPlan = $authuser->assignPlan($plan->id); if ($assignPlan['is_success'] == true && !empty($plan)) { if (!empty($authuser->payment_subscription_id) && $authuser->payment_subscription_id != '') { try { $authuser->cancel_subscription($authuser->id); } catch (\Exception $exception) { \Log::debug($exception->getMessage()); } } $orderID = strtoupper(str_replace('.', '', uniqid('', true))); $userCoupon = new UserCoupon(); $userCoupon->user = $authuser->id; $userCoupon->coupon = $coupons->id; $userCoupon->order = $orderID; $userCoupon->save(); Order::create( [ 'order_id' => $orderID, 'name' => null, 'email' => null, 'card_number' => null, 'card_exp_month' => null, 'card_exp_year' => null, 'plan_name' => $plan->name, 'plan_id' => $plan->id, 'price' => $get_amount == null ? 0 : $get_amount, 'price_currency' => !empty($payment_setting['currency']) ? $payment_setting['currency'] : 'USD', 'txn_id' => '', 'payment_type' => 'Paytab', 'payment_status' => 'success', 'receipt' => null, 'user_id' => $authuser->id, ] ); $assignPlan = $authuser->assignPlan($plan->id); return redirect()->route('plans.index')->with('success', __('Plan Successfully Activated')); } } } else { return redirect()->back()->with('error', __('This coupon code is invalid or has expired.')); } } $coupon = (empty($request->coupon)) ? "0" : $request->coupon; $pay = paypage::sendPaymentCode('all') ->sendTransaction('sale') ->sendCart(1, $get_amount, 'plan payment') ->sendCustomerDetails(isset($user->name) ? $user->name : "", isset($user->email) ? $user->email : '', '', '', '', '', '', '', '') ->sendURLs( route('plan.paytab.success', ['success' => 1, 'data' => $request->all(), 'plan_id' => $plan->id, 'amount' => $get_amount, 'coupon' => $coupon]), route('plan.paytab.success', ['success' => 0, 'data' => $request->all(), 'plan_id' => $plan->id, 'amount' => $get_amount, 'coupon' => $coupon]) ) ->sendLanguage('en') ->sendFramed($on = false) ->create_pay_page(); return $pay; } else { return redirect()->route('plans.index')->with('error', __('Plan is deleted.')); } } catch (\Exception $e) { return redirect()->route('plans.index')->with('error', __($e->getMessage())); } } public function PaytabGetPayment(Request $request) { $planId = $request->plan_id; $couponCode = $request->coupon; $getAmount = $request->amount; if ($couponCode != 0) { $coupons = Coupon::where('code', strtoupper($couponCode))->where('is_active', '1')->first(); $request['coupon_id'] = $coupons->id; } else { $coupons = null; } $plan = Plan::find($planId); $user = auth()->user(); $orderID = strtoupper(str_replace('.', '', uniqid('', true))); try { if ($request->respMessage == "Authorised" || $request->success == 1) { Utility::referralTransaction($plan); $order = new Order(); $order->order_id = $orderID; $order->name = $user->name; $order->card_number = ''; $order->card_exp_month = ''; $order->card_exp_year = ''; $order->plan_name = $plan->name; $order->plan_id = $plan->id; $order->price = $getAmount; $order->price_currency = !empty($payment_setting['currency']) ? $payment_setting['currency'] : 'USD'; $order->payment_type = __('Paytab'); $order->payment_status = 'success'; $order->txn_id = ''; $order->receipt = ''; $order->user_id = $user->id; $order->save(); $assignPlan = $user->assignPlan($plan->id); $coupons = Coupon::find($request->coupon_id); if (!empty($request->coupon_id)) { if (!empty($coupons)) { $userCoupon = new UserCoupon(); $userCoupon->user = $user->id; $userCoupon->coupon = $coupons->id; $userCoupon->order = $orderID; $userCoupon->save(); $usedCoupun = $coupons->used_coupon(); if ($coupons->limit <= $usedCoupun) { $coupons->is_active = 0; $coupons->save(); } } } if ($assignPlan['is_success']) { return redirect()->route('plans.index')->with('success', __('Plan activated Successfully.')); } else { return redirect()->route('plans.index')->with('error', __($assignPlan['error'])); } } else { return redirect()->route('plans.index')->with('error', __('Your Transaction is fail please try again')); } } catch (\Exception $e) { return redirect()->route('plans.index')->with('error', __($e->getMessage())); } } } Controllers/FedapayController.php000064400000021573150364311770013217 0ustar00plan_id); $plan = Plan::find($planID); $orderID = strtoupper(str_replace('.', '', uniqid('', true))); $authuser = Auth::user(); if ($plan) { /* Check for code usage */ $integerValue = $plan->price; $get_amount = intval($integerValue); if (!empty($request->coupon)) { $coupons = Coupon::where('code', strtoupper($request->coupon))->where('is_active', '1')->first(); if (!empty($coupons)) { $usedCoupun = $coupons->used_coupon(); $discount_value = ($plan->price / 100) * $coupons->discount; $get_amount = $plan->price - $discount_value; if ($coupons->limit == $usedCoupun) { return redirect()->back()->with('error', __('This coupon code has expired.')); } if ($get_amount <= 0) { $authuser = Auth::user(); $authuser->plan = $plan->id; $authuser->save(); $assignPlan = $authuser->assignPlan($plan->id); if ($assignPlan['is_success'] == true && !empty($plan)) { $orderID = strtoupper(str_replace('.', '', uniqid('', true))); $userCoupon = new UserCoupon(); $userCoupon->user = $authuser->id; $userCoupon->coupon = $coupons->id; $userCoupon->order = $orderID; $userCoupon->save(); Order::create( [ 'order_id' => $orderID, 'name' => null, 'email' => null, 'card_number' => null, 'card_exp_month' => null, 'card_exp_year' => null, 'plan_name' => $plan->name, 'plan_id' => $plan->id, 'price' => $get_amount == null ? 0 : $get_amount, 'price_currency' => $currency, 'txn_id' => '', 'payment_type' => __('Paiement Pro'), 'payment_status' => 'success', 'receipt' => null, 'user_id' => $authuser->id, ] ); $assignPlan = $authuser->assignPlan($plan->id); return redirect()->route('plans.index')->with('success', __('Plan Successfully Activated')); } } } else { return redirect()->back()->with('error', __('This coupon code is invalid or has expired.')); } } try { \FedaPay\FedaPay::setApiKey($fedapay); \FedaPay\FedaPay::setEnvironment($fedapay_mode); $orderID = strtoupper(str_replace('.', '', uniqid('', true))); $coupons = Coupon::where('code', strtoupper($request->coupon))->where('is_active', '1')->first(); $transaction = \FedaPay\Transaction::create([ "description" => "Fedapay Payment", "amount" => $get_amount, "currency" => ["iso" => $currency], "callback_url" => route('fedapay.status', [ 'order_id' => $orderID, 'plan_id' => $plan->id, "amount" => $get_amount, "coupon_id" => !empty($coupons->id) ? $coupons->id : '', 'coupon_code' => !empty($request->coupon) ? $request->coupon : '', ]), "cancel_url" => route('fedapay.status', [ 'order_id' => $orderID, 'plan_id' => $plan->id, "amount" => $get_amount, "coupon_id" => !empty($coupons->id) ? $coupons->id : '', 'coupon_code' => !empty($request->coupon) ? $request->coupon : '', ]), ]); Order::create( [ 'order_id' => $orderID, 'name' => null, 'email' => null, 'card_number' => null, 'card_exp_month' => null, 'card_exp_year' => null, 'plan_name' => !empty($plan->name) ? $plan->name : 'Basic Package', 'plan_id' => $plan->id, 'price' => !empty($get_amount) ? $get_amount : 0, 'price_currency' => $currency, 'txn_id' => '', 'payment_type' => __('Fedapay'), 'payment_status' => 'pending', 'receipt' => null, 'user_id' => $authuser->id, ] ); $token = $transaction->generateToken(); return redirect($token->url); } catch (\Exception $e) { return redirect()->route('plans.index')->with('error', $e->getMessage()); } } else { return redirect()->route('plans.index')->with('error', __('Plan is deleted.')); } } public function planGetFedapayStatus(Request $request) { $payment_setting = Utility::getAdminPaymentSetting(); $currency = isset($payment_setting['currency']) ? $payment_setting['currency'] : ''; $orderID = strtoupper(str_replace('.', '', uniqid('', true))); $getAmount = $request->amount; $authuser = Auth::user(); $plan = Plan::find($request->plan_id); Utility::referralTransaction($plan); try { if ($request->status == 'approved') { $order = new Order(); $order->order_id = $orderID; $order->name = $authuser->name; $order->card_number = ''; $order->card_exp_month = ''; $order->card_exp_year = ''; $order->plan_name = $plan->name; $order->plan_id = $plan->id; $order->price = $getAmount; $order->price_currency = $currency; $order->txn_id = $orderID; $order->payment_type = __('Fedapay'); $order->payment_status = 'success'; $order->receipt = ''; $order->user_id = $authuser->id; $order->save(); $assignPlan = $authuser->assignPlan($plan->id); } else { return redirect()->back()->with('error', __('Transaction Unsuccesfull')); } $coupons = Coupon::find($request->coupon_id); if (!empty($request->coupon_id)) { if (!empty($coupons)) { $userCoupon = new UserCoupon(); $userCoupon->user = $authuser->id; $userCoupon->coupon = $coupons->id; $userCoupon->order = $orderID; $userCoupon->save(); $usedCoupun = $coupons->used_coupon(); if ($coupons->limit <= $usedCoupun) { $coupons->is_active = 0; $coupons->save(); } } } if ($assignPlan['is_success']) { return redirect()->route('plans.index')->with('success', __('Plan activated Successfully!')); } else { return redirect()->route('plans.index')->with('error', __($assignPlan['error'])); } } catch (\Exception $e) { return redirect()->route('plans.index')->with('error', $e->getMessage()); } } } Controllers/CommissionController.php000064400000011356150364311770013764 0ustar00can('Create Commission')) { $validator = \Validator::make( $request->all(), [ 'employee_id' => 'required', 'title' => 'required', 'amount' => 'required', ] ); if($validator->fails()) { $messages = $validator->getMessageBag(); return redirect()->back()->with('error', $messages->first()); } $commission = new Commission(); $commission->employee_id = $request->employee_id; $commission->title = $request->title; $commission->type = $request->type; $commission->amount = $request->amount; $commission->created_by = \Auth::user()->creatorId(); $commission->save(); if( $commission->type == 'percentage' ) { $employee = Employee::find($commission->employee_id); $comsal = $commission->amount * $employee->salary / 100; } return redirect()->back()->with('success', __('Commission successfully created.')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } public function show(Commission $commission) { return redirect()->route('commision.index'); } public function edit($commission) { $commission = Commission::find($commission); if(\Auth::user()->can('Edit Commission')) { if($commission->created_by == \Auth::user()->creatorId()) { $commissions =Commission::$commissiontype; return view('commission.edit', compact('commission','commissions')); } else { return response()->json(['error' => __('Permission denied.')], 401); } } else { return response()->json(['error' => __('Permission denied.')], 401); } } public function update(Request $request, Commission $commission) { if(\Auth::user()->can('Edit Commission')) { if($commission->created_by == \Auth::user()->creatorId()) { $validator = \Validator::make( $request->all(), [ 'title' => 'required', 'amount' => 'required', ] ); if($validator->fails()) { $messages = $validator->getMessageBag(); return redirect()->back()->with('error', $messages->first()); } $commission->title = $request->title; $commission->type = $request->type; $commission->amount = $request->amount; $commission->save(); if( $commission->type == 'percentage' ) { $employee = Employee::find($commission->employee_id); $comsal = $commission->amount * $employee->salary / 100; } return redirect()->back()->with('success', __('Commission successfully updated.')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } else { return redirect()->back()->with('error', __('Permission denied.')); } } public function destroy(Commission $commission) { if(\Auth::user()->can('Delete Commission')) { if($commission->created_by == \Auth::user()->creatorId()) { $commission->delete(); return redirect()->back()->with('success', __('Commission successfully deleted.')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } else { return redirect()->back()->with('error', __('Permission denied.')); } } } Controllers/DeductionOptionController.php000064400000011546150364311770014754 0ustar00can('Manage Deduction Option')) { $deductionoptions = DeductionOption::where('created_by', '=', \Auth::user()->creatorId())->get(); return view('deductionoption.index', compact('deductionoptions')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } public function create() { if(\Auth::user()->can('Create Deduction Option')) { return view('deductionoption.create'); } else { return response()->json(['error' => __('Permission denied.')], 401); } } public function store(Request $request) { if(\Auth::user()->can('Create Deduction Option')) { $validator = \Validator::make( $request->all(), [ 'name' => 'required', ] ); if($validator->fails()) { $messages = $validator->getMessageBag(); return redirect()->back()->with('error', $messages->first()); } $deductionoption = new DeductionOption(); $deductionoption->name = $request->name; $deductionoption->created_by = \Auth::user()->creatorId(); $deductionoption->save(); return redirect()->route('deductionoption.index')->with('success', __('DeductionOption successfully created.')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } public function show(DeductionOption $deductionoption) { return redirect()->route('deductionoption.index'); } public function edit($deductionoption) { $deductionoption = DeductionOption::find($deductionoption); if(\Auth::user()->can('Edit Deduction Option')) { if($deductionoption->created_by == \Auth::user()->creatorId()) { return view('deductionoption.edit', compact('deductionoption')); } else { return response()->json(['error' => __('Permission denied.')], 401); } } else { return response()->json(['error' => __('Permission denied.')], 401); } } public function update(Request $request, DeductionOption $deductionoption) { if(\Auth::user()->can('Edit Deduction Option')) { if($deductionoption->created_by == \Auth::user()->creatorId()) { $validator = \Validator::make( $request->all(), [ 'name' => 'required', ] ); if($validator->fails()) { $messages = $validator->getMessageBag(); return redirect()->back()->with('error', $messages->first()); } $deductionoption->name = $request->name; $deductionoption->save(); return redirect()->route('deductionoption.index')->with('success', __('DeductionOption successfully updated.')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } else { return redirect()->back()->with('error', __('Permission denied.')); } } public function destroy(DeductionOption $deductionoption) { if(\Auth::user()->can('Delete Deduction Option')) { if($deductionoption->created_by == \Auth::user()->creatorId()) { $saturationdeduction = SaturationDeduction::where('deduction_option',$deductionoption->id)->get(); if(count($saturationdeduction) == 0) { $deductionoption->delete(); } else { return redirect()->route('deductionoption.index')->with('error', __('This Deduction Option has Saturation Deduction. Please remove the Saturation Deduction from this Deduction option.')); } return redirect()->route('deductionoption.index')->with('success', __('DeductionOption successfully deleted.')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } else { return redirect()->back()->with('error', __('Permission denied.')); } } } Controllers/CouponController.php000064400000014473150364311770013112 0ustar00can('manage coupon')) { $coupons = Coupon::get(); return view('coupon.index', compact('coupons')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } public function create() { if (\Auth::user()->can('create coupon')) { return view('coupon.create'); } else { return redirect()->back()->with('error', __('Permission denied.')); } } public function store(Request $request) { if (\Auth::user()->can('create coupon')) { $validator = \Validator::make( $request->all(), [ 'name' => 'required', 'discount' => 'required|numeric', 'limit' => 'required|numeric', ] ); if ($validator->fails()) { $messages = $validator->getMessageBag(); return redirect()->back()->with('error', $messages->first()); } if (empty($request->manualCode) && empty($request->autoCode)) { return redirect()->back()->with('error', 'Coupon code is required'); } $coupon = new Coupon(); $coupon->name = $request->name; $coupon->discount = $request->discount; $coupon->limit = $request->limit; if (!empty($request->manualCode)) { $coupon->code = strtoupper($request->manualCode); } if (!empty($request->autoCode)) { $coupon->code = $request->autoCode; } $coupon->save(); return redirect()->route('coupons.index')->with('success', __('Coupon successfully created.')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } public function show(Coupon $coupon) { $userCoupons = UserCoupon::where('coupon', $coupon->id)->get(); return view('coupon.view', compact('userCoupons')); } public function edit(Coupon $coupon) { if (\Auth::user()->can('edit coupon')) { return view('coupon.edit', compact('coupon')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } public function update(Request $request, Coupon $coupon) { if (\Auth::user()->can('edit coupon')) { $validator = \Validator::make( $request->all(), [ 'name' => 'required', 'discount' => 'required|numeric', 'limit' => 'required|numeric', 'code' => 'required', ] ); if ($validator->fails()) { $messages = $validator->getMessageBag(); return redirect()->back()->with('error', $messages->first()); } $coupon = Coupon::find($coupon->id); $coupon->name = $request->name; $coupon->discount = $request->discount; $coupon->limit = $request->limit; $coupon->code = $request->code; $coupon->save(); return redirect()->route('coupons.index')->with('success', __('Coupon successfully updated.')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } public function destroy(Coupon $coupon) { if (\Auth::user()->can('delete coupon')) { $coupon->delete(); return redirect()->route('coupons.index')->with('success', __('Coupon successfully deleted.')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } public function applyCoupon(Request $request) { $plan = Plan::find(\Illuminate\Support\Facades\Crypt::decrypt($request->plan_id)); if ($plan && $request->coupon != '') { $original_price = self::formatPrice($plan->price); $coupons = Coupon::where('code', strtoupper($request->coupon))->where('is_active', '1')->first(); if (!empty($coupons)) { $usedCoupun = $coupons->used_coupon(); if ($coupons->limit == $usedCoupun) { return response()->json( [ 'is_success' => false, 'final_price' => $original_price, 'price' => number_format($plan->price, 2), 'message' => __('This coupon code has expired.'), ] ); } else { $discount_value = ($plan->price / 100) * $coupons->discount; $plan_price = $plan->price - $discount_value; $price = self::formatPrice($plan->price - $discount_value); $discount_value = '-' . self::formatPrice($discount_value); return response()->json( [ 'is_success' => true, 'discount_price' => $discount_value, 'final_price' => $price, 'price' => number_format($plan_price, 2), 'message' => __('Coupon code has applied successfully.'), ] ); } } else { return response()->json( [ 'is_success' => false, 'final_price' => $original_price, 'price' => number_format($plan->price, 2), 'message' => __('This coupon code is invalid or has expired.'), ] ); } } } public function formatPrice($price) { $admin_payment_setting = Utility::getAdminPaymentSetting(); return $admin_payment_setting['currency_symbol'] . number_format($price); } } Controllers/PaytrController.php000064400000026462150364311770012747 0ustar00plan_id); $authuser = \Auth::user(); $plan = Plan::find($planID); if ($plan) { $get_amount = $plan->price; if (!empty($request->coupon)) { $coupons = Coupon::where('code', strtoupper($request->coupon))->where('is_active', '1')->first(); if (!empty($coupons)) { $usedCoupun = $coupons->used_coupon(); $discount_value = ($plan->price / 100) * $coupons->discount; $get_amount = $plan->price - $discount_value; if ($coupons->limit == $usedCoupun) { return redirect()->back()->with('error', __('This coupon code has expired.')); } if ($get_amount <= 0) { $authuser = \Auth::user(); $authuser->plan = $plan->id; $authuser->save(); $assignPlan = $authuser->assignPlan($plan->id); if ($assignPlan['is_success'] == true && !empty($plan)) { if (!empty($authuser->payment_subscription_id) && $authuser->payment_subscription_id != '') { try { $authuser->cancel_subscription($authuser->id); } catch (\Exception $exception) { \Log::debug($exception->getMessage()); } } $orderID = strtoupper(str_replace('.', '', uniqid('', true))); $userCoupon = new UserCoupon(); $userCoupon->user = $authuser->id; $userCoupon->coupon = $coupons->id; $userCoupon->order = $orderID; $userCoupon->save(); Order::create( [ 'order_id' => $orderID, 'name' => null, 'email' => null, 'card_number' => null, 'card_exp_month' => null, 'card_exp_year' => null, 'plan_name' => $plan->name, 'plan_id' => $plan->id, 'price' => $get_amount == null ? 0 : $get_amount, 'price_currency' => !empty($payment_setting['currency']) ? $payment_setting['currency'] : 'TL', 'txn_id' => '', 'payment_type' => 'PayTR', 'payment_status' => 'success', 'receipt' => null, 'user_id' => $authuser->id, ] ); $assignPlan = $authuser->assignPlan($plan->id); return redirect()->route('plans.index')->with('success', __('Plan Successfully Activated')); } } } else { return redirect()->back()->with('error', __('This coupon code is invalid or has expired.')); } } try { $coupon = (empty($request->coupon)) ? "0" : $request->coupon; $merchant_id = $paytr_merchant_id; $merchant_key = $paytr_merchant_key; $merchant_salt = $paytr_merchant_salt; $orderID = strtoupper(str_replace('.', '', uniqid('', true))); $email = $authuser->email; $payment_amount = $plan->price; $merchant_oid = $orderID; $user_name = $authuser->name; $user_address = 'no address'; $user_phone = '0000000000'; $user_basket = base64_encode(json_encode(array( array("Plan", $payment_amount, 1), ))); if (isset($_SERVER["HTTP_CLIENT_IP"])) { $ip = $_SERVER["HTTP_CLIENT_IP"]; } elseif (isset($_SERVER["HTTP_X_FORWARDED_FOR"])) { $ip = $_SERVER["HTTP_X_FORWARDED_FOR"]; } else { $ip = $_SERVER["REMOTE_ADDR"]; } $user_ip = $ip; $timeout_limit = "30"; $debug_on = 1; $test_mode = 0; $no_installment = 0; $max_installment = 0; $currency = !empty($payment_setting['currency']) ? $payment_setting['currency'] : 'TL'; $payment_amount = $payment_amount*100; $hash_str = $merchant_id . $user_ip . $merchant_oid . $email . $payment_amount . $user_basket . $no_installment . $max_installment . $currency . $test_mode; $paytr_token = base64_encode(hash_hmac('sha256', $hash_str . $merchant_salt, $merchant_key, true)); $request['orderID'] = $orderID; $request['plan_id'] = $plan->id; $request['price'] = $get_amount; $request['payment_status'] = 'failed'; $payment_failed = $request->all(); $request['payment_status'] = 'success'; $payment_success = $request->all(); $post_vals = array( 'merchant_id' => $merchant_id, 'user_ip' => $user_ip, 'merchant_oid' => $merchant_oid, 'email' => $email, 'payment_amount' => $payment_amount, 'paytr_token' => $paytr_token, 'user_basket' => $user_basket, 'debug_on' => $debug_on, 'no_installment' => $no_installment, 'max_installment' => $max_installment, 'user_name' => $user_name, 'user_address' => $user_address, 'user_phone' => $user_phone, 'merchant_ok_url' => route('pay.paytr.success', $payment_success), 'merchant_fail_url' => route('pay.paytr.success', $payment_failed), 'timeout_limit' => $timeout_limit, 'currency' => $currency, 'test_mode' => $test_mode ); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, "https://www.paytr.com/odeme/api/get-token"); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $post_vals); curl_setopt($ch, CURLOPT_FRESH_CONNECT, true); curl_setopt($ch, CURLOPT_TIMEOUT, 20); $result = @curl_exec($ch); if (curl_errno($ch)) { die("PAYTR IFRAME connection error. err:" . curl_error($ch)); } curl_close($ch); $result = json_decode($result, 1); if ($result['status'] == 'success') { $token = $result['token']; } else { return redirect()->route('plans.index')->with('error', $result['reason']); } return view('plan.paytr_payment', compact('token')); } catch (\Throwable $th) { return redirect()->route('plans.index')->with('error', $th->getMessage()); } } } public function paytrsuccess(Request $request) { if ($request->payment_status == "success") { try { $user = \Auth::user(); $planID = $request->plan_id; $plan = Plan::find($planID); $couponCode = $request->coupon; $getAmount = $request->price; if ($couponCode != 0) { $coupons = Coupon::where('code', strtoupper($couponCode))->where('is_active', '1')->first(); $request['coupon_id'] = $coupons->id; } else { $coupons = null; } Utility::referralTransaction($plan); $order = new Order(); $order->order_id = $request->orderID; $order->name = $user->name; $order->card_number = ''; $order->card_exp_month = ''; $order->card_exp_year = ''; $order->plan_name = $plan->name; $order->plan_id = $plan->id; $order->price = $getAmount; $order->price_currency = !empty($payment_setting['currency']) ? $payment_setting['currency'] : 'TL'; $order->txn_id = $request->orderID; $order->payment_type = __('PayTR'); $order->payment_status = 'success'; $order->txn_id = ''; $order->receipt = ''; $order->user_id = $user->id; $order->save(); $assignPlan = $user->assignPlan($plan->id); $coupons = Coupon::find($request->coupon_id); if (!empty($request->coupon_id)) { if (!empty($coupons)) { $userCoupon = new UserCoupon(); $userCoupon->user = $user->id; $userCoupon->coupon = $coupons->id; $userCoupon->order = $request->orderID; $userCoupon->save(); $usedCoupun = $coupons->used_coupon(); if ($coupons->limit <= $usedCoupun) { $coupons->is_active = 0; $coupons->save(); } } } if ($assignPlan['is_success']) { return redirect()->route('plans.index')->with('success', __('Plan activated Successfully.')); } else { return redirect()->route('plans.index')->with('error', __($assignPlan['error'])); } } catch (\Exception $e) { return redirect()->route('plans.index')->with('error', __($e)); } } else { return redirect()->route('plans.index')->with('success', __('Your Transaction is fail please try again.')); } } } Controllers/JobApplicationController.php000064400000070505150364311770014543 0ustar00can('Manage Job Application')) { $stages = JobStage::where('created_by', '=', \Auth::user()->creatorId())->orderBy('order', 'asc')->get(); $jobs = Job::where('created_by', \Auth::user()->creatorId())->get()->pluck('title', 'id'); $jobs->prepend('All', ''); if (isset($request->start_date) && !empty($request->start_date)) { $filter['start_date'] = $request->start_date; } else { $filter['start_date'] = date("Y-m-d", strtotime("-1 month")); } if (isset($request->end_date) && !empty($request->end_date)) { $filter['end_date'] = $request->end_date; } else { $filter['end_date'] = date("Y-m-d H:i:s", strtotime("+1 hours")); } if (isset($request->job) && !empty($request->job)) { $filter['job'] = $request->job; } else { $filter['job'] = ''; } return view('jobApplication.index', compact('stages', 'jobs', 'filter')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } public function create() { $jobs = Job::where('created_by', \Auth::user()->creatorId())->get()->pluck('title', 'id'); $jobs->prepend('--', ''); $questions = CustomQuestion::where('created_by', \Auth::user()->creatorId())->get(); return view('jobApplication.create', compact('jobs', 'questions')); } public function store(Request $request) { if (\Auth::user()->can('Create Job Application')) { $validator = \Validator::make( $request->all(), [ 'job' => 'required', 'name' => 'required', 'email' => 'required', 'phone' => 'required', ] ); if ($validator->fails()) { $messages = $validator->getMessageBag(); return redirect()->back()->with('error', $messages->first()); } $stage = JobStage::where('created_by', \Auth::user()->creatorId())->first(); $job = new JobApplication(); $job->job = $request->job; $job->name = $request->name; $job->email = $request->email; $job->phone = $request->phone; $job->cover_letter = $request->cover_letter; $job->dob = $request->dob; $job->gender = $request->gender; $job->address = $request->address; $job->country = $request->country; $job->state = $request->state; $job->stage = $stage->id; $job->city = $request->city; $job->zip_code = $request->zip_code; $job->custom_question = json_encode($request->question); $job->created_by = \Auth::user()->creatorId(); if (!empty($request->profile)) { $image_size = $request->file('profile')->getSize(); $result = Utility::updateStorageLimit(\Auth::user()->creatorId(), $image_size); if ($result == 1) { $filenameWithExt = $request->file('profile')->getClientOriginalName(); $filename = pathinfo($filenameWithExt, PATHINFO_FILENAME); $extension = $request->file('profile')->getClientOriginalExtension(); $fileNameToStore = $filename . '_' . time() . '.' . $extension; $dir = 'uploads/job/profile'; $image_path = $dir . $filenameWithExt; $url = ''; $path = Utility::upload_file($request, 'profile', $fileNameToStore, $dir, []); $job->profile = !empty($request->profile) ? $fileNameToStore : ''; if ($path['flag'] == 1) { $url = $path['url']; } else { return redirect()->back()->with('error', __($path['msg'])); } } } if (!empty($request->resume)) { $image_size = $request->file('resume')->getSize(); $result = Utility::updateStorageLimit(\Auth::user()->creatorId(), $image_size); if ($result == 1) { $filenameWithExt1 = $request->file('resume')->getClientOriginalName(); $filename1 = pathinfo($filenameWithExt1, PATHINFO_FILENAME); $extension1 = $request->file('resume')->getClientOriginalExtension(); $fileNameToStore1 = $filename1 . '_' . time() . '.' . $extension1; $dir = 'uploads/job/resume'; $image_path = $dir . $filenameWithExt1; if (\File::exists($image_path)) { \File::delete($image_path); } $url = ''; $path = Utility::upload_file($request, 'resume', $fileNameToStore1, $dir, []); $job->resume = !empty($request->resume) ? $fileNameToStore1 : ''; if ($path['flag'] == 1) { $url = $path['url']; } else { return redirect()->back()->with('error', __($path['msg'])); } } } $job->save(); // return redirect()->route('job-application.index')->with('success', __('Job application successfully created.')); return redirect()->route('job-application.index')->with('success', __('Job application successfully created.') . ((isset($result) && $result != 1) ? '
' . $result . '' : '')); } else { return redirect()->route('job-application.index')->with('error', __('Permission denied.')); } } public function show($ids) { if (\Auth::user()->can('Show Job Application')) { $id = Crypt::decrypt($ids); $jobApplication = JobApplication::find($id); $notes = JobApplicationNote::where('application_id', $id)->get(); $stages = JobStage::where('created_by', \Auth::user()->creatorId())->get(); return view('jobApplication.show', compact('jobApplication', 'notes', 'stages')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } public function destroy(JobApplication $jobApplication) { if (\Auth::user()->can('Delete Job Application')) { $jobApplication->delete(); if (!empty($jobApplication->profile)) { //storage limit $file_path = 'uploads/job/profile/' . $jobApplication->profile; $result = Utility::changeStorageLimit(\Auth::user()->creatorId(), $file_path); } if (!empty($jobApplication->resume)) { //storage limit $file_path = 'uploads/job/resume/' . $jobApplication->resume; $result = Utility::changeStorageLimit(\Auth::user()->creatorId(), $file_path); } return redirect()->route('job-application.index')->with('success', __('Job application successfully deleted.')); } else { return redirect()->route('job-application.index')->with('error', __('Permission denied.')); } } public function order(Request $request) { if (\Auth::user()->can('Move Job Application')) { $post = $request->all(); foreach ($post['order'] as $key => $item) { $application = JobApplication::where('id', '=', $item)->first(); $application->order = $key; $application->stage = $post['stage_id']; $application->save(); } } else { return redirect()->route('job-application.index')->with('error', __('Permission denied.')); } } public function addSkill(Request $request, $id) { if (\Auth::user()->can('Add Job Application Skill')) { $validator = \Validator::make( $request->all(), [ 'skill' => 'required', ] ); if ($validator->fails()) { $messages = $validator->getMessageBag(); return redirect()->back()->with('error', $messages->first()); } $job = JobApplication::find($id); $job->skill = $request->skill; $job->save(); return redirect()->back()->with('success', __('Job application skill successfully added.')); } else { return redirect()->route('job-application.index')->with('error', __('Permission denied.')); } } public function addNote(Request $request, $id) { if (\Auth::user()->can('Add Job Application Note')) { $validator = \Validator::make( $request->all(), [ 'note' => 'required', ] ); if ($validator->fails()) { $messages = $validator->getMessageBag(); return redirect()->back()->with('error', $messages->first()); } $note = new JobApplicationNote(); $note->application_id = $id; $note->note = $request->note; $note->note_created = \Auth::user()->id; $note->created_by = \Auth::user()->creatorId(); $note->save(); return redirect()->back()->with('success', __('Job application notes successfully added.')); } else { return redirect()->route('job-application.index')->with('error', __('Permission denied.')); } } public function destroyNote($id) { if (\Auth::user()->can('Delete Job Application Note')) { $note = JobApplicationNote::find($id); $note->delete(); return redirect()->back()->with('success', __('Job application notes successfully deleted.')); } else { return redirect()->route('job-application.index')->with('error', __('Permission denied.')); } } public function rating(Request $request, $id) { $jobApplication = JobApplication::find($id); $jobApplication->rating = $request->rating; $jobApplication->save(); } public function archive($id) { $jobApplication = JobApplication::find($id); if ($jobApplication->is_archive == 0) { $jobApplication->is_archive = 1; $jobApplication->save(); return redirect()->route('job.application.candidate')->with('success', __('Job application successfully added to archive.')); } else { $jobApplication->is_archive = 0; $jobApplication->save(); return redirect()->route('job-application.index')->with('success', __('Job application successfully remove to archive.')); } } public function candidate() { if (\Auth::user()->can('Manage Job OnBoard')) { $archive_application = JobApplication::where('created_by', \Auth::user()->creatorId())->where('is_archive', 1)->with('jobs')->get(); return view('jobApplication.candidate', compact('archive_application')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } // -----------------------Job OnBoard-----------------------------_ public function jobBoardCreate($id) { $status = JobOnBoard::$status; $job_type = JobOnBoard::$job_type; $salary_duration = JobOnBoard::$salary_duration; $salary_type = PayslipType::where('created_by', \Auth::user()->creatorId())->get()->pluck('name', 'id'); $applications = InterviewSchedule::select('interview_schedules.*', 'job_applications.name')->join('job_applications', 'interview_schedules.candidate', '=', 'job_applications.id')->where('interview_schedules.created_by', \Auth::user()->creatorId())->get()->pluck('name', 'candidate'); $applications->prepend('-', ''); return view('jobApplication.onboardCreate', compact('id', 'status', 'applications', 'job_type', 'salary_type', 'salary_duration')); } public function jobOnBoard() { if (\Auth::user()->can('Manage Job OnBoard')) { $jobOnBoards = JobOnBoard::where('created_by', \Auth::user()->creatorId())->with('applications')->get(); return view('jobApplication.onboard', compact('jobOnBoards')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } public function jobBoardStore(Request $request, $id) { $validator = \Validator::make( $request->all(), [ 'joining_date' => 'required', 'job_type' => 'required', 'days_of_week' => 'required|gt:0', 'salary' => 'required|gt:0', 'salary_type' => 'required', 'salary_duration' => 'required', 'status' => 'required', ] ); if ($validator->fails()) { $messages = $validator->getMessageBag(); return redirect()->back()->with('error', $messages->first()); } $id = ($id == 0) ? $request->application : $id; $jobBoard = new JobOnBoard(); $jobBoard->application = $id; $jobBoard->joining_date = $request->joining_date; $jobBoard->job_type = $request->job_type; $jobBoard->days_of_week = $request->days_of_week; $jobBoard->salary = $request->salary; $jobBoard->salary_type = $request->salary_type; $jobBoard->salary_duration = $request->salary_duration; $jobBoard->status = $request->status; $jobBoard->created_by = \Auth::user()->creatorId(); $jobBoard->save(); $interview = InterviewSchedule::where('candidate', $id)->first(); if (!empty($interview)) { $interview->delete(); } return redirect()->route('job.on.board')->with('success', __('Candidate succefully added in job board.')); } public function jobBoardUpdate(Request $request, $id) { $validator = \Validator::make( $request->all(), [ 'joining_date' => 'required', 'job_type' => 'required', 'days_of_week' => 'required', 'salary' => 'required', 'salary_type' => 'required', 'salary_duration' => 'required', 'status' => 'required', ] ); if ($validator->fails()) { $messages = $validator->getMessageBag(); return redirect()->back()->with('error', $messages->first()); } $jobBoard = JobOnBoard::find($id); $jobBoard->joining_date = $request->joining_date; $jobBoard->job_type = $request->job_type; $jobBoard->days_of_week = $request->days_of_week; $jobBoard->salary = $request->salary; $jobBoard->salary_type = $request->salary_type; $jobBoard->salary_duration = $request->salary_duration; $jobBoard->status = $request->status; $jobBoard->save(); return redirect()->route('job.on.board')->with('success', __('Job board Candidate succefully updated.')); } public function jobBoardEdit($id) { $jobOnBoard = JobOnBoard::find($id); $status = JobOnBoard::$status; $job_type = JobOnBoard::$job_type; $salary_duration = JobOnBoard::$salary_duration; $salary_type = PayslipType::where('created_by', \Auth::user()->creatorId())->get()->pluck('name', 'id'); return view('jobApplication.onboardEdit', compact('jobOnBoard', 'status', 'job_type', 'salary_type', 'salary_duration')); } public function jobBoardDelete($id) { $jobBoard = JobOnBoard::find($id); $jobBoard->delete(); return redirect()->route('job.on.board')->with('success', __('Job onBoard successfully deleted.')); } public function jobBoardConvert($id) { $jobOnBoard = JobOnBoard::find($id); $company_settings = Utility::settings(); $documents = Document::where('created_by', \Auth::user()->creatorId())->get(); $branches = Branch::where('created_by', \Auth::user()->creatorId())->get()->pluck('name', 'id'); $branches->prepend('Select Branch', ''); $departments = Department::where('created_by', \Auth::user()->creatorId())->get()->pluck('name', 'id'); $designations = Designation::where('created_by', \Auth::user()->creatorId())->get()->pluck('name', 'id'); $employees = User::where('created_by', \Auth::user()->creatorId())->get(); $employeesId = \Auth::user()->employeeIdFormat($this->employeeNumber()); return view('jobApplication.convert', compact('jobOnBoard', 'employees', 'employeesId', 'departments', 'designations', 'documents', 'branches', 'company_settings')); } public function jobBoardConvertData(Request $request, $id) { $validator = \Validator::make( $request->all(), [ 'name' => 'required', 'dob' => 'required', 'gender' => 'required', 'phone' => 'required', 'address' => 'required', 'email' => 'required|unique:users', 'password' => 'required', 'department_id' => 'required', 'designation_id' => 'required', 'document.*' => 'mimes:jpeg,png,jpg,gif,svg,pdf,doc,zip|max:20480', ] ); if ($validator->fails()) { $messages = $validator->getMessageBag(); return redirect()->back()->withInput()->with('error', $messages->first()); } $objUser = User::find(\Auth::user()->creatorId()); $total_employee = $objUser->countEmployees(); $plan = Plan::find($objUser->plan); if ($total_employee < $plan->max_employees || $plan->max_employees == -1) { $user = User::create( [ 'name' => $request['name'], 'email' => $request['email'], 'password' => Hash::make($request['password']), 'type' => 'employee', 'lang' => 'en', 'created_by' => \Auth::user()->creatorId(), ] ); $user->save(); $user->assignRole('Employee'); } else { return redirect()->back()->with('error', __('Your employee limit is over, Please upgrade plan.')); } if (!empty($request->document) && !is_null($request->document)) { $document_implode = implode(',', array_keys($request->document)); } else { $document_implode = null; } $employee = Employee::create( [ 'user_id' => $user->id, 'name' => $request['name'], 'dob' => $request['dob'], 'gender' => $request['gender'], 'phone' => $request['phone'], 'address' => $request['address'], 'email' => $request['email'], 'password' => Hash::make($request['password']), 'employee_id' => $this->employeeNumber(), 'branch_id' => $request['branch_id'], 'department_id' => $request['department_id'], 'designation_id' => $request['designation_id'], 'company_doj' => $request['company_doj'], 'documents' => $document_implode, 'account_holder_name' => $request['account_holder_name'], 'account_number' => $request['account_number'], 'bank_name' => $request['bank_name'], 'bank_identifier_code' => $request['bank_identifier_code'], 'branch_location' => $request['branch_location'], 'tax_payer_id' => $request['tax_payer_id'], 'created_by' => \Auth::user()->creatorId(), ] ); if (!empty($employee)) { $JobOnBoard = JobOnBoard::find($id); $JobOnBoard->convert_to_employee = $employee->id; $JobOnBoard->save(); } if ($request->hasFile('document')) { foreach ($request->document as $key => $document) { $image_size = $request->file('document')[$key]->getSize(); $result = Utility::updateStorageLimit(\Auth::user()->creatorId(), $image_size); if ($result == 1) { $filenameWithExt = $request->file('document')[$key]->getClientOriginalName(); $filename = pathinfo($filenameWithExt, PATHINFO_FILENAME); $extension = $request->file('document')[$key]->getClientOriginalExtension(); $fileNameToStore = $filename . '_' . time() . '.' . $extension; $dir = storage_path('uploads/document/'); $image_path = $dir . $filenameWithExt; if (!file_exists($dir)) { mkdir($dir, 0777, true); } $path = $request->file('document')[$key]->storeAs('uploads/document/', $fileNameToStore); $employee_document = EmployeeDocument::create( [ 'employee_id' => $employee['employee_id'], 'document_id' => $key, 'document_value' => $fileNameToStore, 'created_by' => \Auth::user()->creatorId(), ] ); $employee_document->save(); } } } $setings = Utility::settings(); if ($setings['new_employee'] == 1) { $user->type = 'employee'; $user->password = $request['password']; try { Mail::to($user->email)->send(new UserCreate($user)); } catch (\Exception $e) { $smtp_error = __('E-Mail has been not sent due to SMTP configuration'); } return redirect()->back()->with('success', __('Application successfully converted to employee.') . (isset($smtp_error) ? $smtp_error : '') . ((isset($result) && $result != 1) ? '
' . $result . '' : '')); } return redirect()->back()->with('success', __('Application successfully converted to employee.')); // return redirect()->back()->with('success', __('Application successfully converted to employee.') . ((isset($result) && $result != 1) ? '
' . $result . '' : '')); } function employeeNumber() { $latest = Employee::where('created_by', '=', \Auth::user()->creatorId())->latest()->first(); if (!$latest) { return 1; } return $latest->employee_id + 1; } public function getByJob(Request $request) { $job = Job::find($request->id); if ($job != null) { $job->applicant = !empty($job->applicant) ? explode(',', $job->applicant) : ''; $job->visibility = !empty($job->visibility) ? explode(',', $job->visibility) : ''; $job->custom_question = !empty($job->custom_question) ? explode(',', $job->custom_question) : ''; return json_encode($job); } } public function stageChange(Request $request) { $application = JobApplication::where('id', '=', $request->schedule_id)->first(); $application->stage = $request->stage; $application->save(); return response()->json( [ 'success' => __('This candidate stage successfully changed.'), ], 200 ); } public function offerletterPdf($id) { $users = \Auth::user(); $currantLang = $users->currentLanguage(); $Offerletter = GenerateOfferLetter::where(['lang' => $currantLang, 'created_by' => \Auth::user()->creatorId()])->first(); $job = JobApplication::find($id); $Onboard = JobOnBoard::find($id); $name = JobApplication::find($Onboard->application); $job_title = job::find($name->job); $salary = PayslipType::find($Onboard->salary_type); $obj = [ 'applicant_name' => $name->name, 'app_name' => env('APP_NAME'), 'job_title' => $job_title->title, 'job_type' => !empty($Onboard->job_type) ? $Onboard->job_type : '', 'start_date' => $Onboard->joining_date, 'workplace_location' => !empty($job->jobs->branches->name) ? $job->jobs->branches->name : '', 'days_of_week' => !empty($Onboard->days_of_week) ? $Onboard->days_of_week : '', 'salary' => !empty($Onboard->salary) ? $Onboard->salary : '', 'salary_type' => !empty($salary->name) ? $salary->name : '', 'salary_duration' => !empty($Onboard->salary_duration) ? $Onboard->salary_duration : '', 'offer_expiration_date' => !empty($Onboard->joining_date) ? $Onboard->joining_date : '', ]; $Offerletter->content = GenerateOfferLetter::replaceVariable($Offerletter->content, $obj); return view('jobApplication.template.offerletterpdf', compact('Offerletter', 'name')); } public function offerletterDoc($id) { $users = \Auth::user(); $currantLang = $users->currentLanguage(); $Offerletter = GenerateOfferLetter::where(['lang' => $currantLang, 'created_by' => \Auth::user()->creatorId()])->first(); // ['lang' => $currantLang,'created_by' => \Auth::user()->id] $job = JobApplication::find($id); $Onboard = JobOnBoard::find($id); $name = JobApplication::find($Onboard->application); $job_title = job::find($name->job); $salary = PayslipType::find($Onboard->salary_type); $obj = [ 'applicant_name' => $name->name, 'app_name' => env('APP_NAME'), 'job_title' => $job_title->title, 'job_type' => !empty($Onboard->job_type) ? $Onboard->job_type : '', 'start_date' => $Onboard->joining_date, 'workplace_location' => !empty($job->jobs->branches->name) ? $job->jobs->branches->name : '', 'days_of_week' => !empty($Onboard->days_of_week) ? $Onboard->days_of_week : '', 'salary' => !empty($Onboard->salary) ? $Onboard->salary : '', 'salary_type' => !empty($salary->name) ? $salary->name : '', 'salary_duration' => !empty($Onboard->salary_duration) ? $Onboard->salary_duration : '', 'offer_expiration_date' => !empty($Onboard->joining_date) ? $Onboard->joining_date : '', ]; $Offerletter->content = GenerateOfferLetter::replaceVariable($Offerletter->content, $obj); return view('jobApplication.template.offerletterdocx', compact('Offerletter', 'name')); } } Controllers/TerminationController.php000064400000016520150364311770014133 0ustar00can('Manage Termination')) { if(Auth::user()->type == 'employee') { $emp = Employee::where('user_id', '=', \Auth::user()->id)->first(); $terminations = Termination::where('created_by', '=', \Auth::user()->creatorId())->where('employee_id', '=', $emp->id)->get(); } else { $terminations = Termination::where('created_by', '=', \Auth::user()->creatorId())->with(['employee', 'terminationType'])->get(); } return view('termination.index', compact('terminations')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } public function create() { if(\Auth::user()->can('Create Termination')) { $employees = Employee::where('created_by', \Auth::user()->creatorId())->get()->pluck('name', 'id'); $terminationtypes = TerminationType::where('created_by', '=', \Auth::user()->creatorId())->get()->pluck('name', 'id'); return view('termination.create', compact('employees', 'terminationtypes')); } else { return response()->json(['error' => __('Permission denied.')], 401); } } public function store(Request $request) { if(\Auth::user()->can('Create Termination')) { $validator = \Validator::make( $request->all(), [ 'employee_id' => 'required', 'termination_type' => 'required', 'notice_date' => 'required', 'termination_date' => 'required|after_or_equal:notice_date', ] ); if($validator->fails()) { $messages = $validator->getMessageBag(); return redirect()->back()->with('error', $messages->first()); } $termination = new Termination(); $termination->employee_id = $request->employee_id; $termination->termination_type = $request->termination_type; $termination->notice_date = $request->notice_date; $termination->termination_date = $request->termination_date; $termination->description = $request->description; $termination->created_by = \Auth::user()->creatorId(); $termination->save(); $setings = Utility::settings(); if($setings['employee_termination'] == 1) { $employee = Employee::find($termination->employee_id); $uArr = [ 'employee_termination_name'=>$employee->name, 'notice_date'=>$request->notice_date, 'termination_date'=>$request->termination_date, 'termination_type'=>$request->termination_type, ]; $resp = Utility::sendEmailTemplate('employee_termination', [$employee->email], $uArr); return redirect()->route('termination.index')->with('success', __('Termination successfully created.'). ((!empty($resp) && $resp['is_success'] == false && !empty($resp['error'])) ? '
' . $resp['error'] . '' : '')); } return redirect()->route('termination.index')->with('success', __('Termination successfully created.')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } public function show(Termination $termination) { return redirect()->route('termination.index'); } public function edit(Termination $termination) { if(\Auth::user()->can('Edit Termination')) { $employees = Employee::where('created_by', \Auth::user()->creatorId())->get()->pluck('name', 'id'); $terminationtypes = TerminationType::where('created_by', '=', \Auth::user()->creatorId())->get()->pluck('name', 'id'); if($termination->created_by == \Auth::user()->creatorId()) { return view('termination.edit', compact('termination', 'employees', 'terminationtypes')); } else { return response()->json(['error' => __('Permission denied.')], 401); } } else { return response()->json(['error' => __('Permission denied.')], 401); } } public function update(Request $request, Termination $termination) { if(\Auth::user()->can('Edit Termination')) { if($termination->created_by == \Auth::user()->creatorId()) { $validator = \Validator::make( $request->all(), [ 'employee_id' => 'required', 'termination_type' => 'required', 'notice_date' => 'required', 'termination_date' => 'required', ] ); if($validator->fails()) { $messages = $validator->getMessageBag(); return redirect()->back()->with('error', $messages->first()); } $termination->employee_id = $request->employee_id; $termination->termination_type = $request->termination_type; $termination->notice_date = $request->notice_date; $termination->termination_date = $request->termination_date; $termination->description = $request->description; $termination->save(); return redirect()->route('termination.index')->with('success', __('Termination successfully updated.')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } else { return redirect()->back()->with('error', __('Permission denied.')); } } public function destroy(Termination $termination) { if(\Auth::user()->can('Delete Termination')) { if($termination->created_by == \Auth::user()->creatorId()) { $termination->delete(); return redirect()->route('termination.index')->with('success', __('Termination successfully deleted.')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } else { return redirect()->back()->with('error', __('Permission denied.')); } } public function description($id) { $termination = Termination::find($id); return view('termination.description', compact('termination')); } } Controllers/BankTransferController.php000064400000012455150364311770014225 0ustar00all(), [ 'payment_receipt' => 'required', ] ); if ($validator->fails()) { $messages = $validator->getMessageBag(); return redirect()->back()->with('error', $messages->first()); } $planID = \Illuminate\Support\Facades\Crypt::decrypt($request->plan_id); $plan = Plan::find($planID); $authuser = \Auth::user(); // $order = Order::where('plan_id' , $plan->id)->where('payment_status' , 'Pending')->first(); $order = Order::where('plan_id',$planID)->where('payment_status','Pending')->where('user_id',$authuser->id)->first(); if($order){ return redirect()->route('plans.index')->with('error', __('You already send Payment request to this plan.')); } $coupon_id = ''; if ($plan) { $price = $plan->price; if (isset($request->coupon) && !empty($request->coupon)) { $coupons = Coupon::where('code', strtoupper($request->coupon))->where('is_active', '1')->first(); if (!empty($coupons)) { $usedCoupun = $coupons->used_coupon(); $discount_value = ($plan->price / 100) * $coupons->discount; $price = $plan->price - $discount_value; if ($coupons->limit == $usedCoupun) { return redirect()->back()->with('error', __('This coupon code has expired.')); } $coupon_id = $coupons->id; } else { return redirect()->back()->with('error', __('This coupon code is invalid or has expired.')); } } $orderID = strtoupper(str_replace('.', '', uniqid('', true))); if (!empty($request->payment_receipt)) { $fileName = time() . "_" . $request->payment_receipt->getClientOriginalName(); $dir = 'uploads/order'; $path = Utility::upload_file($request, 'payment_receipt', $fileName, $dir, []); } Order::create( [ 'order_id' => $orderID, 'name' => null, 'email' => null, 'card_number' => null, 'card_exp_month' => null, 'card_exp_year' => null, 'plan_name' => $plan->name, 'plan_id' => $plan->id, 'price' => $price, 'price_currency' => !empty($payment_setting['currency']) ? $payment_setting['currency'] : 'USD', 'txn_id' => '', 'payment_type' => 'Bank Transfer', 'payment_status' => 'Pending', 'receipt' => $fileName, 'user_id' => $authuser->id, ] ); if (!empty($request->coupon)) { $userCoupon = new UserCoupon(); $userCoupon->user = $authuser->id; $userCoupon->coupon = $coupons->id; $userCoupon->order = $orderID; $userCoupon->save(); $usedCoupun = $coupons->used_coupon(); if ($coupons->limit <= $usedCoupun) { $coupons->is_active = 0; $coupons->save(); } } return redirect()->route('plans.index')->with('success', __('Plan payment request send successfully')); } else { return redirect()->route('plans.index')->with('error', __('Plan is deleted.')); } } public function action($id) { $order = Order::find($id); $user = User::find($order->user_id); $bank_details = Utility::getAdminPaymentSetting()['bank_details']; return view('order.show', compact('user', 'order', 'bank_details')); } public function changeaction(Request $request, $id) { if ($request->status == 'Approved') { $order = Order::find($request->order_id); $user = User::find($order->user_id); $pn = Plan::find($order->plan_id); $user->plan = $order->plan_id; $user->save(); $order->payment_status = 'Approved'; $order->save(); $assignPlan = $user->assignPlan($order->plan_id, $pn->duration); Utility::referralTransaction($pn , $user); return redirect()->route('order.index')->with('success', __('Plan payment successfully updated.')); } elseif ($request->status == 'Reject') { $order = Order::find($request->order_id); $order->payment_status = 'Rejected'; $order->save(); return redirect()->route('order.index')->with('success', __('Plan payment successfully updated.')); } } } Controllers/HolidayController.php000064400000032117150364311770013233 0ustar00can('Manage Holiday')) { $holidays = LocalHoliday::where('created_by', '=', \Auth::user()->creatorId()); if (!empty($request->start_date)) { $holidays->where('start_date', '>=', $request->start_date); } if (!empty($request->end_date)) { $holidays->where('end_date', '<=', $request->end_date); } $holidays = $holidays->get(); return view('holiday.index', compact('holidays')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } public function create() { if (\Auth::user()->can('Create Holiday')) { return view('holiday.create'); } else { return redirect()->back()->with('error', __('Permission denied.')); } } public function store(Request $request) { if (\Auth::user()->can('Create Holiday')) { $validator = \Validator::make( $request->all(), [ 'occasion' => 'required', 'start_date' => 'required', 'end_date' => 'required', ] ); if ($validator->fails()) { $messages = $validator->getMessageBag(); return redirect()->back()->with('error', $messages->first()); } $holiday = new LocalHoliday(); $holiday->occasion = $request->occasion; $holiday->start_date = $request->start_date; $holiday->end_date = $request->end_date; $holiday->created_by = \Auth::user()->creatorId(); $holiday->save(); // slack $setting = Utility::settings(\Auth::user()->creatorId()); if (isset($setting['Holiday_notification']) && $setting['Holiday_notification'] == 1) { // $msg = $request->occasion . ' ' . __("on") . ' ' . $request->start_date . ' ' . __("to") . ' ' . $request->end_date; $uArr = [ 'occasion_name' => $request->occasion, 'start_date' => $request->start_date, 'end_date' => $request->end_date, ]; Utility::send_slack_msg('new_holidays', $uArr); } // telegram $setting = Utility::settings(\Auth::user()->creatorId()); if (isset($setting['telegram_Holiday_notification']) && $setting['telegram_Holiday_notification'] == 1) { // $msg = $request->occasion . ' ' . __("on") . ' ' . $request->date . '.'; $uArr = [ 'occasion_name' => $request->occasion, 'start_date' => $request->start_date, 'end_date' => $request->end_date, ]; Utility::send_telegram_msg('new_holidays', $uArr); } // google calendar if ($request->get('synchronize_type') == 'google_calender') { $type = 'holiday'; $request1 = new GoogleEvent(); $request1->title = $request->occasion; $request1->start_date = $request->start_date; $request1->end_date = $request->end_date; Utility::addCalendarData($request1, $type); } //webhook $module = 'New Holidays'; $webhook = Utility::webhookSetting($module); if ($webhook) { $parameter = json_encode($holiday); // 1 parameter is URL , 2 parameter is data , 3 parameter is method $status = Utility::WebhookCall($webhook['url'], $parameter, $webhook['method']); if ($status == true) { return redirect()->back()->with('success', __('Holiday successfully created.')); } else { return redirect()->back()->with('error', __('Webhook call failed.')); } } return redirect()->route('holiday.index')->with('success', 'Holiday successfully created.'); } else { return redirect()->back()->with('error', __('Permission denied.')); } } public function show($id) { $holidays = LocalHoliday::where('id', $id)->first(); return view('holiday.show', compact('holidays')); } public function edit(LocalHoliday $holiday) { if (\Auth::user()->can('Edit Holiday')) { return view('holiday.edit', compact('holiday')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } public function update(Request $request, LocalHoliday $holiday) { if (\Auth::user()->can('Edit Holiday')) { $validator = \Validator::make( $request->all(), [ 'occasion' => 'required', 'start_date' => 'required', 'end_date' => 'required', ] ); if ($validator->fails()) { $messages = $validator->getMessageBag(); return redirect()->back()->with('error', $messages->first()); } $holiday->occasion = $request->occasion; $holiday->start_date = $request->start_date; $holiday->end_date = $request->end_date; $holiday->save(); return redirect()->route('holiday.index')->with( 'success', 'Holiday successfully updated.' ); } else { return redirect()->back()->with('error', __('Permission denied.')); } } public function destroy(LocalHoliday $holiday) { if (\Auth::user()->can('Delete Holiday')) { $holiday->delete(); return redirect()->route('holiday.index')->with( 'success', 'Holiday successfully deleted.' ); } else { return redirect()->back()->with('error', __('Permission denied.')); } } // public function calender(Request $request) // { // if (\Auth::user()->can('Manage Holiday')) { // $holidays = LocalHoliday::where('created_by', '=', \Auth::user()->creatorId()); // $today_date = date('m'); // // $current_month_event = Holiday::select( 'occasion','start_date','end_date', 'created_at')->whereRaw('MONTH(start_date)=' . $today_date,'MONTH(end_date)=' . $today_date)->get(); // $current_month_event = LocalHoliday::where('created_by', \Auth::user()->creatorId())->select('occasion', 'start_date', 'end_date', 'created_at')->whereNotNull(['start_date', 'end_date'])->whereMonth('start_date', $today_date)->whereMonth('end_date', $today_date)->get(); // if (!empty($request->start_date)) { // $holidays->where('start_date', '>=', $request->start_date); // } // if (!empty($request->end_date)) { // $holidays->where('end_date', '<=', $request->end_date); // } // $holidays = $holidays->get(); // $arrHolidays = []; // foreach ($holidays as $holiday) { // $arr['id'] = $holiday['id']; // $arr['title'] = $holiday['occasion']; // $arr['start'] = $holiday['start_date']; // $arr['end'] = $holiday['end_date']; // $arr['className'] = 'event-primary'; // $arr['url'] = route('holiday.edit', $holiday['id']); // $arrHolidays[] = $arr; // } // // $arrHolidays = str_replace('"[', '[', str_replace(']"', ']', json_encode($arrHolidays))); // $arrHolidays = json_encode($arrHolidays); // return view('holiday.calender', compact('arrHolidays', 'current_month_event','holidays')); // } else { // return redirect()->back()->with('error', __('Permission denied.')); // } // } public function calender(Request $request) { if (\Auth::user()->can('Manage Holiday')) { $transdate = date('Y-m-d', time()); $holidays = LocalHoliday::where('created_by', '=', \Auth::user()->creatorId()); if (!empty($request->start_date)) { $holidays->where('start_date', '>=', $request->start_date); } if (!empty($request->end_date)) { $holidays->where('end_date', '<=', $request->end_date); } $holidays = $holidays->get(); $arrHolidays = []; foreach ($holidays as $holiday) { $arr['id'] = $holiday['id']; $arr['title'] = $holiday['occasion']; $arr['start'] = $holiday['date']; $arr['end'] = $holiday['end_date']; $arr['className'] = 'event-primary'; $arr['url'] = route('holiday.edit', $holiday['id']); $arrHolidays[] = $arr; } $arrHolidays = str_replace('"[', '[', str_replace(']"', ']', json_encode($arrHolidays))); return view('holiday.calender', compact('arrHolidays', 'transdate', 'holidays')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } public function export(Request $request) { $name = 'holidays_' . date('Y-m-d i:h:s'); $data = Excel::download(new HolidayExport(), $name . '.xlsx'); return $data; } public function importFile(Request $request) { return view('holiday.import'); } public function import(Request $request) { $rules = [ 'file' => 'required|mimes:csv,txt', ]; $validator = \Validator::make($request->all(), $rules); if ($validator->fails()) { $messages = $validator->getMessageBag(); return redirect()->back()->with('error', $messages->first()); } $holidays = (new HolidayImport())->toArray(request()->file('file'))[0]; $totalholiday = count($holidays); $errorArray = []; foreach ($holidays as $holiday) { $holiydayData = LocalHoliday::whereDate('start_date', $holiday['start_date'])->whereDate('end_date', $holiday['end_date'])->where('occasion', $holiday['occasion'])->first(); if (!empty($holiydayData)) { $errorArray[] = $holiydayData; } else { $holidays_data = new LocalHoliday(); $holidays_data->start_date = $holiday['start_date']; $holidays_data->end_date = $holiday['end_date']; $holidays_data->occasion = $holiday['occasion']; $holidays_data->created_by = Auth::user()->id; $holidays_data->save(); } } if (empty($errorArray)) { $data['status'] = 'success'; $data['msg'] = __('Record successfully imported'); } else { $data['status'] = 'error'; $data['msg'] = count($errorArray) . ' ' . __('Record imported fail out of' . ' ' . $totalholiday . ' ' . 'record'); foreach ($errorArray as $errorData) { $errorRecord[] = implode(',', $errorData->toArray()); } \Session::put('errorArray', $errorRecord); } return redirect()->back()->with($data['status'], $data['msg']); } public function get_holiday_data(Request $request) { $arrayJson = []; if ($request->get('calender_type') == 'google_calender') { $type = 'holiday'; $arrayJson = Utility::getCalendarData($type); } else { $data = LocalHoliday::where('created_by', \Auth::user()->creatorId())->get(); foreach ($data as $val) { if (Auth::user()->type == 'employee') { $url = route('holiday.show', $val['id']); } else { $url = route('holiday.edit', $val['id']); } $end_date = date_create($val->end_date); date_add($end_date, date_interval_create_from_date_string("1 days")); $arrayJson[] = [ "id" => $val->id, "title" => $val->occasion, "start" => $val->start_date, "end" => date_format($end_date, "Y-m-d H:i:s"), "className" => $val->color, "textColor" => '#FFF', "allDay" => true, "url" => $url, ]; } } return $arrayJson; } } Requests/Auth/LoginRequest.php000064400000007367150364311770012436 0ustar00 ['required', 'string', 'email'], 'password' => ['required', 'string'], ]; } /** * Attempt to authenticate the request's credentials. * * @return void * * @throws \Illuminate\Validation\ValidationException */ // public function authenticate() // { // $this->ensureIsNotRateLimited(); // if (! Auth::attempt($this->only('email', 'password'), $this->boolean('remember'))) { // RateLimiter::hit($this->throttleKey()); // throw ValidationException::withMessages([ // 'email' => trans('auth.failed'), // ]); // } // RateLimiter::clear($this->throttleKey()); // } public function authenticate() { // custom login $users = User::where('email',$this->email)->get(); $id = 0; if(count($users) > 0) { foreach ($users as $key => $user) { if(password_verify($this->password,$user->password)) { if($user->is_active != 1 || $user->is_disable != 1 && $user->type != "super admin") { throw ValidationException::withMessages([ 'email' => __("Your Account is disable, please contact your Administrate."), ]); }elseif ($user->is_login_enable != 1) { throw ValidationException::withMessages([ 'email' => __("Your account is disabled from company."), ]); } $id = $user->id; break; } } } else { throw ValidationException::withMessages([ 'email' => __("this email doesn't match"), ]); } if (! Auth::attempt(['email' =>$this->email, 'password' =>$this->password,'id'=>$id], $this->boolean('remember'))) { RateLimiter::hit($this->throttleKey()); throw ValidationException::withMessages([ 'email' => __('These credentials do not match our records.'), ]); } RateLimiter::clear($this->throttleKey()); } /** * Ensure the login request is not rate limited. * * @return void * * @throws \Illuminate\Validation\ValidationException */ public function ensureIsNotRateLimited() { if (! RateLimiter::tooManyAttempts($this->throttleKey(), 5)) { return; } event(new Lockout($this)); $seconds = RateLimiter::availableIn($this->throttleKey()); throw ValidationException::withMessages([ 'email' => trans('auth.throttle', [ 'seconds' => $seconds, 'minutes' => ceil($seconds / 60), ]), ]); } /** * Get the rate limiting throttle key for the request. * * @return string */ public function throttleKey() { return Str::lower($this->input('email')).'|'.$this->ip(); } } Middleware/VerifyCsrfToken.php000064400000000722150364311770012425 0ustar00expectsJson()) { return route('login'); } } } Middleware/EncryptCookies.php000064400000000446150364311770012306 0ustar00allSubdomainsOfApplicationUrl(), ]; } } Middleware/getPusherSettings.php000064400000002323150364311770013030 0ustar00 isset($settings['pusher_app_key']) ? $settings['pusher_app_key'] : '', 'chatify.pusher.secret' => isset($settings['pusher_app_secret']) ? $settings['pusher_app_secret'] : '', 'chatify.pusher.app_id' => isset($settings['pusher_app_id']) ? $settings['pusher_app_id'] : '', 'chatify.pusher.options.cluster' => isset($settings['pusher_app_cluster']) ? $settings['pusher_app_cluster'] : '', ]); } } return $next($request); } } Middleware/XSS.php000064400000004556150364311770010030 0ustar00lang); if (\Auth::user()->type == 'super admin') { if (Schema::hasTable('ch_messages')) { if (Schema::hasColumn('ch_messages', 'type') == false) { Schema::drop('ch_messages'); \DB::table('migrations')->where('migration', 'like', '%ch_messages%')->delete(); } } // $migrations = $this->getMigrations(); // $dbMigrations = $this->getExecutedMigrations(); // // $numberOfUpdatesPending = (count($migrations) + 6) - count($dbMigrations); // $numberOfUpdatesPending = (count($migrations)) - count($dbMigrations); $migrations = $this->getMigrations(); $messengerMigration = Utility::get_messenger_packages_migration(); $dbMigrations = $this->getExecutedMigrations(); $Modulemigrations = glob(base_path() . '/Modules/LandingPage/Database' . DIRECTORY_SEPARATOR . 'Migrations' . DIRECTORY_SEPARATOR . '*.php'); $numberOfUpdatesPending = (count($migrations) + count($Modulemigrations) + $messengerMigration) - count($dbMigrations); if ($numberOfUpdatesPending > 0) { // run code like seeder only when new migration Utility::addNewData(); return redirect()->route('LaravelUpdater::welcome'); } } } return $next($request); } } Middleware/RedirectIfAuthenticated.php000064400000001336150364311770014067 0ustar00check()) { return redirect(RouteServiceProvider::HOME); } } return $next($request); } } Middleware/TrimStrings.php000064400000000560150364311770011627 0ustar00