@@ -14,7 +14,7 @@ |
||
14 | 14 | */ |
15 | 15 | protected function redirectTo($request) |
16 | 16 | { |
17 | - if (! $request->expectsJson()) { |
|
17 | + if (!$request->expectsJson()) { |
|
18 | 18 | return route('login'); |
19 | 19 | } |
20 | 20 | } |
@@ -16,11 +16,11 @@ |
||
16 | 16 | public function handle($request, Closure $next) |
17 | 17 | { |
18 | 18 | // dd($request->user()->permissions); |
19 | - if ($request->user() && (!($request->user()->permissions->isEmpty())) && $request->user()->permissions[0]->roles && $request->user()->permissions[0]->roles->code === 'HOMEROOM_TEACHER') { |
|
19 | + if ($request->user() && (!($request->user()->permissions->isEmpty())) && $request->user()->permissions[0]->roles && $request->user()->permissions[0]->roles->code === 'HOMEROOM_TEACHER') { |
|
20 | 20 | return $next($request); |
21 | - }elseif($request->user() && (!($request->user()->principal->isEmpty())) && $request->user()->principal[0]->roles && $request->user()->principal[0]->roles->code === 'PRINCIPAL'){ |
|
21 | + }elseif ($request->user() && (!($request->user()->principal->isEmpty())) && $request->user()->principal[0]->roles && $request->user()->principal[0]->roles->code === 'PRINCIPAL') { |
|
22 | 22 | return $next($request); |
23 | - }elseif($request->user() && (!($request->user()->zonal_cordinator->isEmpty())) && $request->user()->zonal_cordinator[0]->roles && $request->user()->zonal_cordinator[0]->roles->code === 'PRINCIPAL'){ |
|
23 | + }elseif ($request->user() && (!($request->user()->zonal_cordinator->isEmpty())) && $request->user()->zonal_cordinator[0]->roles && $request->user()->zonal_cordinator[0]->roles->code === 'PRINCIPAL') { |
|
24 | 24 | return $next($request); |
25 | 25 | } |
26 | 26 | return redirect('/login')->with('status', 'Your dont have access for upload data. Please get assign your to the class and try'); |
@@ -18,9 +18,9 @@ |
||
18 | 18 | // dd($request->user()->permissions); |
19 | 19 | if ($request->user() && (!($request->user()->permissions->isEmpty())) && $request->user()->permissions[0]->roles && $request->user()->permissions[0]->roles->code === 'HOMEROOM_TEACHER') { |
20 | 20 | return $next($request); |
21 | - }elseif($request->user() && (!($request->user()->principal->isEmpty())) && $request->user()->principal[0]->roles && $request->user()->principal[0]->roles->code === 'PRINCIPAL'){ |
|
21 | + } elseif($request->user() && (!($request->user()->principal->isEmpty())) && $request->user()->principal[0]->roles && $request->user()->principal[0]->roles->code === 'PRINCIPAL'){ |
|
22 | 22 | return $next($request); |
23 | - }elseif($request->user() && (!($request->user()->zonal_cordinator->isEmpty())) && $request->user()->zonal_cordinator[0]->roles && $request->user()->zonal_cordinator[0]->roles->code === 'PRINCIPAL'){ |
|
23 | + } elseif($request->user() && (!($request->user()->zonal_cordinator->isEmpty())) && $request->user()->zonal_cordinator[0]->roles && $request->user()->zonal_cordinator[0]->roles->code === 'PRINCIPAL'){ |
|
24 | 24 | return $next($request); |
25 | 25 | } |
26 | 26 | return redirect('/login')->with('status', 'Your dont have access for upload data. Please get assign your to the class and try'); |
@@ -74,7 +74,7 @@ |
||
74 | 74 | ->editColumn('filename', function ($data) { |
75 | 75 | return '<a href='.env('APP_URL').'/download_file/'.$data->filename.'>'.substr($data->classRoom->name, 0, 10).'</a>'; |
76 | 76 | }) |
77 | - ->editColumn('error', function ($data) { |
|
77 | + ->editColumn('error', function ($data) { |
|
78 | 78 | return '<a href='.env('APP_URL').'/download/'.$data->filename.'>'.substr($data->classRoom->name, 0, 10).'</a>'; |
79 | 79 | })->editColumn('actions', function ($data) { |
80 | 80 |
@@ -13,89 +13,89 @@ |
||
13 | 13 | |
14 | 14 | public function index() |
15 | 15 | { |
16 | - return Datatables::of(Upload::with(['classRoom'])->where('security_user_id','=',Auth::user()->id)) |
|
17 | - ->editColumn('is_processed', function ($data) { |
|
16 | + return Datatables::of(Upload::with(['classRoom'])->where('security_user_id', '=', Auth::user()->id)) |
|
17 | + ->editColumn('is_processed', function($data) { |
|
18 | 18 | |
19 | 19 | $nowTime = \Carbon\Carbon::now(); |
20 | 20 | $to = \Carbon\Carbon::createFromFormat('Y-m-d H:s:i', $nowTime); |
21 | 21 | $from = \Carbon\Carbon::createFromFormat('Y-m-d H:s:i', $data->updated_at); |
22 | 22 | $diff_in_hours = $to->diffInHours($from); |
23 | 23 | |
24 | - if($diff_in_hours >= 2 && $data->is_processed == 3){ |
|
24 | + if ($diff_in_hours >= 2 && $data->is_processed == 3) { |
|
25 | 25 | return "Terminated"; |
26 | 26 | } |
27 | 27 | elseif ($data->is_processed === 1) { |
28 | 28 | return "Success"; |
29 | - }elseif ($data->is_processed === 2){ |
|
29 | + }elseif ($data->is_processed === 2) { |
|
30 | 30 | return "Failed"; |
31 | - }elseif($diff_in_hours < 2 && $data->is_processed == 3){ |
|
31 | + }elseif ($diff_in_hours < 2 && $data->is_processed == 3) { |
|
32 | 32 | return "Processing"; |
33 | - }elseif ($data->is_processed == 4){ |
|
33 | + }elseif ($data->is_processed == 4) { |
|
34 | 34 | return "Process Paused"; |
35 | - }else{ |
|
35 | + }else { |
|
36 | 36 | return 'Pending'; |
37 | 37 | }; |
38 | 38 | |
39 | 39 | }) |
40 | - ->editColumn('is_email_sent', function ($data) { |
|
40 | + ->editColumn('is_email_sent', function($data) { |
|
41 | 41 | if ($data->is_email_sent === 1) { |
42 | 42 | return "Success"; |
43 | - }elseif($data->is_email_sent === 2 ){ |
|
43 | + }elseif ($data->is_email_sent === 2) { |
|
44 | 44 | return 'Failed'; |
45 | - }else{ |
|
45 | + }else { |
|
46 | 46 | return 'Pending'; |
47 | 47 | }; |
48 | 48 | |
49 | 49 | }) |
50 | - ->editColumn('update', function ($data) { |
|
50 | + ->editColumn('update', function($data) { |
|
51 | 51 | if ($data->update === 0) { |
52 | 52 | return "No Processes"; |
53 | - }elseif($data->update === 1 ){ |
|
53 | + }elseif ($data->update === 1) { |
|
54 | 54 | return 'Success'; |
55 | - }elseif($data->update === 3 ){ |
|
55 | + }elseif ($data->update === 3) { |
|
56 | 56 | return 'Partial Success'; |
57 | - }else{ |
|
57 | + }else { |
|
58 | 58 | return 'Failed'; |
59 | 59 | }; |
60 | 60 | |
61 | 61 | }) |
62 | - ->editColumn('insert', function ($data) { |
|
62 | + ->editColumn('insert', function($data) { |
|
63 | 63 | if ($data->insert === 0) { |
64 | 64 | return "No Processes"; |
65 | - }elseif($data->insert === 1 ){ |
|
65 | + }elseif ($data->insert === 1) { |
|
66 | 66 | return 'Success'; |
67 | - }elseif($data->insert === 3 ){ |
|
67 | + }elseif ($data->insert === 3) { |
|
68 | 68 | return 'Partial Success'; |
69 | - }else{ |
|
69 | + }else { |
|
70 | 70 | return 'Failed'; |
71 | 71 | }; |
72 | 72 | |
73 | 73 | }) |
74 | - ->editColumn('filename', function ($data) { |
|
74 | + ->editColumn('filename', function($data) { |
|
75 | 75 | return '<a href='.env('APP_URL').'/download_file/'.$data->filename.'>'.substr($data->classRoom->name, 0, 10).'</a>'; |
76 | 76 | }) |
77 | - ->editColumn('error', function ($data) { |
|
77 | + ->editColumn('error', function($data) { |
|
78 | 78 | return '<a href='.env('APP_URL').'/download/'.$data->filename.'>'.substr($data->classRoom->name, 0, 10).'</a>'; |
79 | - })->editColumn('actions', function ($data) { |
|
79 | + })->editColumn('actions', function($data) { |
|
80 | 80 | |
81 | 81 | $nowTime = \Carbon\Carbon::now(); |
82 | 82 | $to = \Carbon\Carbon::createFromFormat('Y-m-d H:s:i', $nowTime); |
83 | 83 | $from = \Carbon\Carbon::createFromFormat('Y-m-d H:s:i', $data->updated_at); |
84 | 84 | $diff_in_hours = $to->diffInHours($from); |
85 | 85 | |
86 | - if($diff_in_hours >= 2 && $data->is_processed == 3){ |
|
86 | + if ($diff_in_hours >= 2 && $data->is_processed == 3) { |
|
87 | 87 | return '<button onclick="updateProcess('.($data->id).',100)" class="btn btn-primary text-uppercase">reprocess</button>'; |
88 | - }elseif ($data->is_processed == 1){ |
|
88 | + }elseif ($data->is_processed == 1) { |
|
89 | 89 | return '<div><h6>Processing <span class="badge badge-success text-uppercase">Successful</span></h6></div>'; |
90 | - }elseif ($data->is_processed == 2){ |
|
90 | + }elseif ($data->is_processed == 2) { |
|
91 | 91 | return '<div><h6>Processing <span class="badge badge-danger text-uppercase">Failed</span></h6></div>'; |
92 | - }elseif ($data->is_processed == 0){ |
|
92 | + }elseif ($data->is_processed == 0) { |
|
93 | 93 | return '<button onclick="updateProcess('.($data->id).',200)" class="btn btn-block btn-warning text-uppercase">pause</button>'; |
94 | - }elseif ($data->is_processed == 4){ |
|
94 | + }elseif ($data->is_processed == 4) { |
|
95 | 95 | return '<button onclick="updateProcess('.($data->id).',100)" class="btn btn-block btn-success text-uppercase">resume</button>'; |
96 | 96 | } |
97 | 97 | }) |
98 | - ->rawColumns(['filename','error','actions']) |
|
98 | + ->rawColumns(['filename', 'error', 'actions']) |
|
99 | 99 | ->make(true); |
100 | 100 | } |
101 | 101 |
@@ -23,16 +23,15 @@ discard block |
||
23 | 23 | |
24 | 24 | if($diff_in_hours >= 2 && $data->is_processed == 3){ |
25 | 25 | return "Terminated"; |
26 | - } |
|
27 | - elseif ($data->is_processed === 1) { |
|
26 | + } elseif ($data->is_processed === 1) { |
|
28 | 27 | return "Success"; |
29 | - }elseif ($data->is_processed === 2){ |
|
28 | + } elseif ($data->is_processed === 2){ |
|
30 | 29 | return "Failed"; |
31 | - }elseif($diff_in_hours < 2 && $data->is_processed == 3){ |
|
30 | + } elseif($diff_in_hours < 2 && $data->is_processed == 3){ |
|
32 | 31 | return "Processing"; |
33 | - }elseif ($data->is_processed == 4){ |
|
32 | + } elseif ($data->is_processed == 4){ |
|
34 | 33 | return "Process Paused"; |
35 | - }else{ |
|
34 | + } else{ |
|
36 | 35 | return 'Pending'; |
37 | 36 | }; |
38 | 37 | |
@@ -40,9 +39,9 @@ discard block |
||
40 | 39 | ->editColumn('is_email_sent', function ($data) { |
41 | 40 | if ($data->is_email_sent === 1) { |
42 | 41 | return "Success"; |
43 | - }elseif($data->is_email_sent === 2 ){ |
|
42 | + } elseif($data->is_email_sent === 2 ){ |
|
44 | 43 | return 'Failed'; |
45 | - }else{ |
|
44 | + } else{ |
|
46 | 45 | return 'Pending'; |
47 | 46 | }; |
48 | 47 | |
@@ -50,11 +49,11 @@ discard block |
||
50 | 49 | ->editColumn('update', function ($data) { |
51 | 50 | if ($data->update === 0) { |
52 | 51 | return "No Processes"; |
53 | - }elseif($data->update === 1 ){ |
|
52 | + } elseif($data->update === 1 ){ |
|
54 | 53 | return 'Success'; |
55 | - }elseif($data->update === 3 ){ |
|
54 | + } elseif($data->update === 3 ){ |
|
56 | 55 | return 'Partial Success'; |
57 | - }else{ |
|
56 | + } else{ |
|
58 | 57 | return 'Failed'; |
59 | 58 | }; |
60 | 59 | |
@@ -62,11 +61,11 @@ discard block |
||
62 | 61 | ->editColumn('insert', function ($data) { |
63 | 62 | if ($data->insert === 0) { |
64 | 63 | return "No Processes"; |
65 | - }elseif($data->insert === 1 ){ |
|
64 | + } elseif($data->insert === 1 ){ |
|
66 | 65 | return 'Success'; |
67 | - }elseif($data->insert === 3 ){ |
|
66 | + } elseif($data->insert === 3 ){ |
|
68 | 67 | return 'Partial Success'; |
69 | - }else{ |
|
68 | + } else{ |
|
70 | 69 | return 'Failed'; |
71 | 70 | }; |
72 | 71 | |
@@ -85,13 +84,13 @@ discard block |
||
85 | 84 | |
86 | 85 | if($diff_in_hours >= 2 && $data->is_processed == 3){ |
87 | 86 | return '<button onclick="updateProcess('.($data->id).',100)" class="btn btn-primary text-uppercase">reprocess</button>'; |
88 | - }elseif ($data->is_processed == 1){ |
|
87 | + } elseif ($data->is_processed == 1){ |
|
89 | 88 | return '<div><h6>Processing <span class="badge badge-success text-uppercase">Successful</span></h6></div>'; |
90 | - }elseif ($data->is_processed == 2){ |
|
89 | + } elseif ($data->is_processed == 2){ |
|
91 | 90 | return '<div><h6>Processing <span class="badge badge-danger text-uppercase">Failed</span></h6></div>'; |
92 | - }elseif ($data->is_processed == 0){ |
|
91 | + } elseif ($data->is_processed == 0){ |
|
93 | 92 | return '<button onclick="updateProcess('.($data->id).',200)" class="btn btn-block btn-warning text-uppercase">pause</button>'; |
94 | - }elseif ($data->is_processed == 4){ |
|
93 | + } elseif ($data->is_processed == 4){ |
|
95 | 94 | return '<button onclick="updateProcess('.($data->id).',100)" class="btn btn-block btn-success text-uppercase">resume</button>'; |
96 | 95 | } |
97 | 96 | }) |
@@ -29,9 +29,9 @@ discard block |
||
29 | 29 | |
30 | 30 | } |
31 | 31 | |
32 | - /** |
|
33 | - * @return \Illuminate\Support\Collection |
|
34 | - */ |
|
32 | + /** |
|
33 | + * @return \Illuminate\Support\Collection |
|
34 | + */ |
|
35 | 35 | public function importExportView() |
36 | 36 | { |
37 | 37 | $classes = (!Auth::user()->permissions->isEmpty()) ? Auth::user()->permissions[0]->staff_class : Auth::user()->principal[0]->security_group_institution->institution_classes; |
@@ -42,11 +42,11 @@ discard block |
||
42 | 42 | |
43 | 43 | |
44 | 44 | /** |
45 | - * @return \Illuminate\Support\Collection |
|
46 | - */ |
|
45 | + * @return \Illuminate\Support\Collection |
|
46 | + */ |
|
47 | 47 | public function export(Request $request) |
48 | 48 | { |
49 | - $request->validate([ |
|
49 | + $request->validate([ |
|
50 | 50 | 'class' => 'required' |
51 | 51 | ]); |
52 | 52 | return Excel::download(new UsersExport($request->input('class')), 'users.xlsx'); |
@@ -55,8 +55,8 @@ discard block |
||
55 | 55 | |
56 | 56 | |
57 | 57 | /** |
58 | - * @return \Illuminate\Support\Collection |
|
59 | - */ |
|
58 | + * @return \Illuminate\Support\Collection |
|
59 | + */ |
|
60 | 60 | public function import(Request $request) |
61 | 61 | { |
62 | 62 |
@@ -34,9 +34,9 @@ discard block |
||
34 | 34 | */ |
35 | 35 | public function importExportView() |
36 | 36 | { |
37 | - $classes = (!Auth::user()->permissions->isEmpty()) ? Auth::user()->permissions[0]->staff_class : Auth::user()->principal[0]->security_group_institution->institution_classes; |
|
37 | + $classes = (!Auth::user()->permissions->isEmpty()) ? Auth::user()->permissions[0]->staff_class : Auth::user()->principal[0]->security_group_institution->institution_classes; |
|
38 | 38 | |
39 | - return view('importExport')->with('classes',$classes); |
|
39 | + return view('importExport')->with('classes', $classes); |
|
40 | 40 | } |
41 | 41 | |
42 | 42 | |
@@ -70,9 +70,9 @@ discard block |
||
70 | 70 | |
71 | 71 | |
72 | 72 | $import = new UsersImport(); |
73 | - try{ |
|
73 | + try { |
|
74 | 74 | $files = Storage::disk('sis-bulk-data-files')->allFiles(); |
75 | - Excel::import($import,request()->file('import_file')); |
|
75 | + Excel::import($import, request()->file('import_file')); |
|
76 | 76 | }catch (\Maatwebsite\Excel\Validators\ValidationException $e) { |
77 | 77 | $failures = $e->failures(); |
78 | 78 |
@@ -73,7 +73,7 @@ |
||
73 | 73 | try{ |
74 | 74 | $files = Storage::disk('sis-bulk-data-files')->allFiles(); |
75 | 75 | Excel::import($import,request()->file('import_file')); |
76 | - }catch (\Maatwebsite\Excel\Validators\ValidationException $e) { |
|
76 | + } catch (\Maatwebsite\Excel\Validators\ValidationException $e) { |
|
77 | 77 | $failures = $e->failures(); |
78 | 78 | |
79 | 79 | foreach ($failures as $failure) { |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | * @param Request $request |
35 | 35 | * @return \Illuminate\Http\JsonResponse |
36 | 36 | */ |
37 | - public function upload(Request $request){ |
|
37 | + public function upload(Request $request) { |
|
38 | 38 | |
39 | 39 | |
40 | 40 | |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | $institution = auth()->user()->permissions->isEmpty() ? auth()->user()->principal[0]->institution_group[0]->institution->code : auth()->user()->permissions[0]->institution_staff->institution->code; |
77 | 77 | |
78 | 78 | |
79 | - $fileName = time().'_'.$institution.'_'.str_replace(' ','_', clean($class->name)).'_'.auth()->user()->openemis_no.'_student_bulk_data.xlsx'; |
|
79 | + $fileName = time().'_'.$institution.'_'.str_replace(' ', '_', clean($class->name)).'_'.auth()->user()->openemis_no.'_student_bulk_data.xlsx'; |
|
80 | 80 | Storage::disk('local')->putFileAs( |
81 | 81 | 'sis-bulk-data-files/', |
82 | 82 | $uploadFile, |
@@ -84,7 +84,7 @@ discard block |
||
84 | 84 | ); |
85 | 85 | |
86 | 86 | $upload = new Upload; |
87 | - $upload->fileName =$fileName; |
|
87 | + $upload->fileName = $fileName; |
|
88 | 88 | $upload->model = 'Student'; |
89 | 89 | $upload->node = 'None'; |
90 | 90 | $upload->institution_class_id = $class->id; |
@@ -95,8 +95,8 @@ discard block |
||
95 | 95 | return redirect('/')->withSuccess('The file is uploaded, we will process and let you know by your email'); |
96 | 96 | } |
97 | 97 | |
98 | - public function updateQueueWithUnprocessedFiles($id, $action){ |
|
99 | - if($action == 100){ |
|
98 | + public function updateQueueWithUnprocessedFiles($id, $action) { |
|
99 | + if ($action == 100) { |
|
100 | 100 | DB::table('uploads') |
101 | 101 | ->where('id', $id) |
102 | 102 | ->update(['is_processed' => 0]); |
@@ -108,14 +108,14 @@ discard block |
||
108 | 108 | } |
109 | 109 | |
110 | 110 | |
111 | - public function downloadTemplate(){ |
|
111 | + public function downloadTemplate() { |
|
112 | 112 | $filename = 'censusNo_className_sis_students_bulk_upload'; |
113 | 113 | $version = '2007_V1.7_20200510.xlsx'; |
114 | - $file_path = storage_path() .'/app/public/'. $filename.'_'.$version;; |
|
114 | + $file_path = storage_path().'/app/public/'.$filename.'_'.$version; ; |
|
115 | 115 | if (file_exists($file_path)) |
116 | 116 | { |
117 | 117 | return Response::download($file_path, Auth::user()->openemis_no.'_'.$filename.$version, [ |
118 | - 'Content-Length: '. filesize($file_path) |
|
118 | + 'Content-Length: '.filesize($file_path) |
|
119 | 119 | ]); |
120 | 120 | } |
121 | 121 | else |
@@ -129,13 +129,13 @@ discard block |
||
129 | 129 | * @param $filename |
130 | 130 | * @return Processed excel file with error |
131 | 131 | */ |
132 | - public function downloadErrorFile($filename){ |
|
132 | + public function downloadErrorFile($filename) { |
|
133 | 133 | |
134 | - $file_path = storage_path().'/app/sis-bulk-data-files/processed/'. $filename; |
|
134 | + $file_path = storage_path().'/app/sis-bulk-data-files/processed/'.$filename; |
|
135 | 135 | if (file_exists($file_path)) |
136 | 136 | { |
137 | 137 | return Response::download($file_path, $filename, [ |
138 | - 'Content-Length: '. filesize($file_path) |
|
138 | + 'Content-Length: '.filesize($file_path) |
|
139 | 139 | ]); |
140 | 140 | } |
141 | 141 | else |
@@ -145,12 +145,12 @@ discard block |
||
145 | 145 | } |
146 | 146 | |
147 | 147 | |
148 | - public function downloadFile($filename){ |
|
149 | - $file_path = storage_path().'/app/sis-bulk-data-files/'. $filename; |
|
148 | + public function downloadFile($filename) { |
|
149 | + $file_path = storage_path().'/app/sis-bulk-data-files/'.$filename; |
|
150 | 150 | if (file_exists($file_path)) |
151 | 151 | { |
152 | 152 | return Response::download($file_path, $filename, [ |
153 | - 'Content-Length: '. filesize($file_path) |
|
153 | + 'Content-Length: '.filesize($file_path) |
|
154 | 154 | ]); |
155 | 155 | } |
156 | 156 | else |
@@ -100,7 +100,7 @@ discard block |
||
100 | 100 | DB::table('uploads') |
101 | 101 | ->where('id', $id) |
102 | 102 | ->update(['is_processed' => 0]); |
103 | - }elseif ($action == 200) { |
|
103 | + } elseif ($action == 200) { |
|
104 | 104 | DB::table('uploads') |
105 | 105 | ->where('id', $id) |
106 | 106 | ->update(['is_processed' => 4]); |
@@ -117,8 +117,7 @@ discard block |
||
117 | 117 | return Response::download($file_path, Auth::user()->openemis_no.'_'.$filename.$version, [ |
118 | 118 | 'Content-Length: '. filesize($file_path) |
119 | 119 | ]); |
120 | - } |
|
121 | - else |
|
120 | + } else |
|
122 | 121 | { |
123 | 122 | return View::make('errors.404'); |
124 | 123 | } |
@@ -137,8 +136,7 @@ discard block |
||
137 | 136 | return Response::download($file_path, $filename, [ |
138 | 137 | 'Content-Length: '. filesize($file_path) |
139 | 138 | ]); |
140 | - } |
|
141 | - else |
|
139 | + } else |
|
142 | 140 | { |
143 | 141 | abort(404, 'We did not found an error file.'); |
144 | 142 | } |
@@ -152,8 +150,7 @@ discard block |
||
152 | 150 | return Response::download($file_path, $filename, [ |
153 | 151 | 'Content-Length: '. filesize($file_path) |
154 | 152 | ]); |
155 | - } |
|
156 | - else |
|
153 | + } else |
|
157 | 154 | { |
158 | 155 | |
159 | 156 | abort(404, 'We did not found an error file.'); |
@@ -54,10 +54,10 @@ discard block |
||
54 | 54 | /** |
55 | 55 | * @return string |
56 | 56 | */ |
57 | - public function findUsername(){ |
|
57 | + public function findUsername() { |
|
58 | 58 | $login = request()->input('username'); |
59 | 59 | |
60 | - $fieldType = filter_var($login,FILTER_VALIDATE_EMAIL) ? 'email' : 'username'; |
|
60 | + $fieldType = filter_var($login, FILTER_VALIDATE_EMAIL) ? 'email' : 'username'; |
|
61 | 61 | |
62 | 62 | request()->merge([$fieldType => $login]); |
63 | 63 | |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | /** |
68 | 68 | * @return string |
69 | 69 | */ |
70 | - public function username(){ |
|
70 | + public function username() { |
|
71 | 71 | return $this->username; |
72 | 72 | } |
73 | 73 | } |
@@ -7,12 +7,12 @@ |
||
7 | 7 | |
8 | 8 | trait HasPermissionsTrait |
9 | 9 | { |
10 | - public function roles(){ |
|
11 | - return $this->belongsToMany(Security_group_user::class,'security_group_users'); |
|
10 | + public function roles() { |
|
11 | + return $this->belongsToMany(Security_group_user::class, 'security_group_users'); |
|
12 | 12 | } |
13 | 13 | |
14 | 14 | |
15 | - public function hasRole( ... $roles ) { |
|
15 | + public function hasRole(... $roles) { |
|
16 | 16 | foreach ($roles as $role) { |
17 | 17 | if ($this->roles->contains('code', $role)) { |
18 | 18 | return true; |
@@ -100,9 +100,9 @@ discard block |
||
100 | 100 | |
101 | 101 | $this->isValidSheet = false; |
102 | 102 | $error = \Illuminate\Validation\ValidationException::withMessages([]); |
103 | - $failure = new Failure(3, 'remark', [0 => 'Template is not valid for upload, use the template given in the system'], [null]); |
|
104 | - $failures = [0 => $failure]; |
|
105 | - throw new \Maatwebsite\Excel\Validators\ValidationException($error, $failures); |
|
103 | + $failure = new Failure(3, 'remark', [0 => 'Template is not valid for upload, use the template given in the system'], [null]); |
|
104 | + $failures = [0 => $failure]; |
|
105 | + throw new \Maatwebsite\Excel\Validators\ValidationException($error, $failures); |
|
106 | 106 | } |
107 | 107 | } |
108 | 108 | |
@@ -194,9 +194,9 @@ discard block |
||
194 | 194 | } |
195 | 195 | |
196 | 196 | protected function checkKeys($key,$count,$row){ |
197 | - if(array_key_exists($key,$row)){ |
|
198 | - return true; |
|
199 | - }else{ |
|
197 | + if(array_key_exists($key,$row)){ |
|
198 | + return true; |
|
199 | + }else{ |
|
200 | 200 | $error = \Illuminate\Validation\ValidationException::withMessages([]); |
201 | 201 | $failure = new Failure($count, 'remark', [0 => 'Template is not valid for upload, use the template given in the system'. $key ,' Is missing form the template'], [null]); |
202 | 202 | $failures = [0 => $failure]; |
@@ -216,7 +216,7 @@ discard block |
||
216 | 216 | */ |
217 | 217 | public function map($row): array { |
218 | 218 | try { |
219 | - $row = $this->mapFields($row); |
|
219 | + $row = $this->mapFields($row); |
|
220 | 220 | } catch (\Maatwebsite\Excel\Validators\ValidationException $e) { |
221 | 221 | $error = \Illuminate\Validation\ValidationException::withMessages([]); |
222 | 222 | $failure = new Failure(3, 'remark', [0 => 'Template is not valid for upload, use the template given in the system'], [null]); |
@@ -84,10 +84,10 @@ discard block |
||
84 | 84 | $highestColumn = $this->worksheet->getHighestDataColumn(3); |
85 | 85 | $higestRow = 0; |
86 | 86 | for ($row = $this->startRow(); $row <= $this->highestRow; $row++) { |
87 | - $rowData = $this->worksheet->rangeToArray('A' . $row . ':' . $highestColumn . $row, NULL, TRUE, FALSE); |
|
87 | + $rowData = $this->worksheet->rangeToArray('A'.$row.':'.$highestColumn.$row, NULL, TRUE, FALSE); |
|
88 | 88 | if (isEmptyRow(reset($rowData))) { |
89 | 89 | continue; |
90 | - } else { |
|
90 | + }else { |
|
91 | 91 | $higestRow += 1; |
92 | 92 | } |
93 | 93 | } |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | |
97 | 97 | public function validateColumns($column) { |
98 | 98 | $columns = Config::get('excel.columns'); |
99 | - if ( ($column !== "") && (!in_array($column,$columns))) { |
|
99 | + if (($column !== "") && (!in_array($column, $columns))) { |
|
100 | 100 | |
101 | 101 | $this->isValidSheet = false; |
102 | 102 | $error = \Illuminate\Validation\ValidationException::withMessages([]); |
@@ -111,16 +111,16 @@ discard block |
||
111 | 111 | $highestColumn = $this->worksheet->getHighestDataColumn(3); |
112 | 112 | $higestRow = 1; |
113 | 113 | for ($row = $this->startRow(); $row <= $this->highestRow; $row++) { |
114 | - $rowData = $this->worksheet->rangeToArray('A' . $row . ':' . $highestColumn . $row, NULL, TRUE, FALSE); |
|
114 | + $rowData = $this->worksheet->rangeToArray('A'.$row.':'.$highestColumn.$row, NULL, TRUE, FALSE); |
|
115 | 115 | if (isEmptyRow(reset($rowData))) { |
116 | 116 | continue; |
117 | - } else { |
|
117 | + }else { |
|
118 | 118 | $higestRow += 1; |
119 | 119 | } |
120 | 120 | } |
121 | 121 | if ($higestRow == 0) { |
122 | 122 | exit; |
123 | - } else { |
|
123 | + }else { |
|
124 | 124 | return $higestRow; |
125 | 125 | } |
126 | 126 | } |
@@ -135,22 +135,22 @@ discard block |
||
135 | 135 | } |
136 | 136 | |
137 | 137 | |
138 | - protected function formateDate($row,$column,$format = 'Y-m-d'){ |
|
138 | + protected function formateDate($row, $column, $format = 'Y-m-d') { |
|
139 | 139 | try { |
140 | - if(!empty($row[$column]) && ($row[$column] !== null)){ |
|
141 | - switch (gettype($row[$column])){ |
|
140 | + if (!empty($row[$column]) && ($row[$column] !== null)) { |
|
141 | + switch (gettype($row[$column])) { |
|
142 | 142 | case 'string': |
143 | 143 | $row[$column] = preg_replace('/[^A-Za-z0-9\-]/', '-', $row[$column]); |
144 | 144 | $row[$column] = date($format, strtotime($row[$column])); //date($row[$column]); |
145 | - $row[$column] = \Carbon\Carbon::createFromFormat($format, $row[$column]); |
|
145 | + $row[$column] = \Carbon\Carbon::createFromFormat($format, $row[$column]); |
|
146 | 146 | break; |
147 | 147 | case 'double'; |
148 | - $row[$column] = \PhpOffice\PhpSpreadsheet\Shared\Date::excelToDateTimeObject($row[$column]); |
|
148 | + $row[$column] = \PhpOffice\PhpSpreadsheet\Shared\Date::excelToDateTimeObject($row[$column]); |
|
149 | 149 | break; |
150 | 150 | } |
151 | 151 | } |
152 | 152 | return $row; |
153 | - }catch (Exception $e){ |
|
153 | + }catch (Exception $e) { |
|
154 | 154 | $error = \Illuminate\Validation\ValidationException::withMessages([]); |
155 | 155 | $failure = new Failure(3, 'remark', [0 => 'Template is not valid for upload, use the template given in the system'], [null]); |
156 | 156 | $failures = [0 => $failure]; |
@@ -160,32 +160,32 @@ discard block |
||
160 | 160 | } |
161 | 161 | |
162 | 162 | |
163 | - protected function mapFields($row){ |
|
163 | + protected function mapFields($row) { |
|
164 | 164 | |
165 | 165 | $keys = array_keys($row); |
166 | 166 | |
167 | - array_walk($keys,array($this,'validateColumns')); |
|
168 | - $row = $this->formateDate($row,'date_of_birth_yyyy_mm_dd'); |
|
169 | - $row = $this->formateDate($row,'bmi_date_yyyy_mm_dd'); |
|
170 | - $row = $this->formateDate($row,'start_date_yyyy_mm_dd'); |
|
171 | - $row = $this->formateDate($row,'fathers_date_of_birth_yyyy_mm_dd'); |
|
172 | - $row = $this->formateDate($row,'mothers_date_of_birth_yyyy_mm_dd'); |
|
173 | - $row = $this->formateDate($row,'guardians_date_of_birth_yyyy_mm_dd'); |
|
167 | + array_walk($keys, array($this, 'validateColumns')); |
|
168 | + $row = $this->formateDate($row, 'date_of_birth_yyyy_mm_dd'); |
|
169 | + $row = $this->formateDate($row, 'bmi_date_yyyy_mm_dd'); |
|
170 | + $row = $this->formateDate($row, 'start_date_yyyy_mm_dd'); |
|
171 | + $row = $this->formateDate($row, 'fathers_date_of_birth_yyyy_mm_dd'); |
|
172 | + $row = $this->formateDate($row, 'mothers_date_of_birth_yyyy_mm_dd'); |
|
173 | + $row = $this->formateDate($row, 'guardians_date_of_birth_yyyy_mm_dd'); |
|
174 | 174 | $columns = Config::get('excel.columns'); |
175 | - if(!$this->template) { |
|
175 | + if (!$this->template) { |
|
176 | 176 | array_walk($columns, array($this, 'checkKeys'), $row); |
177 | 177 | $this->template = true; |
178 | 178 | } |
179 | - $row['admission_no'] = str_pad($row['admission_no'], 4, '0', STR_PAD_LEFT); |
|
179 | + $row['admission_no'] = str_pad($row['admission_no'], 4, '0', STR_PAD_LEFT); |
|
180 | 180 | if ($row['identity_type'] == 'BC' && (!empty($row['birth_divisional_secretariat'])) && ($row['identity_number'] !== null) && $row['date_of_birth_yyyy_mm_dd'] !== null) { |
181 | - $row['identity_number'] = str_pad($row['identity_number'], 4, '0', STR_PAD_LEFT); |
|
181 | + $row['identity_number'] = str_pad($row['identity_number'], 4, '0', STR_PAD_LEFT); |
|
182 | 182 | // dd(($row['date_of_birth_yyyy_mm_dd'])); |
183 | - $BirthDivision = Area_administrative::where('name', 'like', '%' . $row['birth_divisional_secretariat'] . '%')->where('area_administrative_level_id', '=', 5)->first(); |
|
183 | + $BirthDivision = Area_administrative::where('name', 'like', '%'.$row['birth_divisional_secretariat'].'%')->where('area_administrative_level_id', '=', 5)->first(); |
|
184 | 184 | if ($BirthDivision !== null) { |
185 | - $BirthArea = Area_administrative::where('name', 'like', '%' . $row['birth_registrar_office_as_in_birth_certificate'] . '%') |
|
185 | + $BirthArea = Area_administrative::where('name', 'like', '%'.$row['birth_registrar_office_as_in_birth_certificate'].'%') |
|
186 | 186 | ->where('parent_id', '=', $BirthDivision->id)->first(); |
187 | 187 | if ($BirthArea !== null) { |
188 | - $row['identity_number'] = $BirthArea->id . '' . $row['identity_number'] . '' . substr($row['date_of_birth_yyyy_mm_dd']->format("yy"), -2) . '' . $row['date_of_birth_yyyy_mm_dd']->format("m"); |
|
188 | + $row['identity_number'] = $BirthArea->id.''.$row['identity_number'].''.substr($row['date_of_birth_yyyy_mm_dd']->format("yy"), -2).''.$row['date_of_birth_yyyy_mm_dd']->format("m"); |
|
189 | 189 | } |
190 | 190 | } |
191 | 191 | } |
@@ -193,12 +193,12 @@ discard block |
||
193 | 193 | return $row; |
194 | 194 | } |
195 | 195 | |
196 | - protected function checkKeys($key,$count,$row){ |
|
197 | - if(array_key_exists($key,$row)){ |
|
196 | + protected function checkKeys($key, $count, $row) { |
|
197 | + if (array_key_exists($key, $row)) { |
|
198 | 198 | return true; |
199 | - }else{ |
|
199 | + }else { |
|
200 | 200 | $error = \Illuminate\Validation\ValidationException::withMessages([]); |
201 | - $failure = new Failure($count, 'remark', [0 => 'Template is not valid for upload, use the template given in the system'. $key ,' Is missing form the template'], [null]); |
|
201 | + $failure = new Failure($count, 'remark', [0 => 'Template is not valid for upload, use the template given in the system'.$key, ' Is missing form the template'], [null]); |
|
202 | 202 | $failures = [0 => $failure]; |
203 | 203 | new \Maatwebsite\Excel\Validators\ValidationException($error, $failures); |
204 | 204 | }; |
@@ -217,7 +217,7 @@ discard block |
||
217 | 217 | public function map($row): array { |
218 | 218 | try { |
219 | 219 | $row = $this->mapFields($row); |
220 | - } catch (\Maatwebsite\Excel\Validators\ValidationException $e) { |
|
220 | + }catch (\Maatwebsite\Excel\Validators\ValidationException $e) { |
|
221 | 221 | $error = \Illuminate\Validation\ValidationException::withMessages([]); |
222 | 222 | $failure = new Failure(3, 'remark', [0 => 'Template is not valid for upload, use the template given in the system'], [null]); |
223 | 223 | $failures = [0 => $failure]; |
@@ -239,19 +239,19 @@ discard block |
||
239 | 239 | if ($exceededStudents == true) { |
240 | 240 | try { |
241 | 241 | $error = \Illuminate\Validation\ValidationException::withMessages([]); |
242 | - $failure = new Failure(3, 'remark', [3 => 'Class student count exceeded! Max number of students is' . $institutionClass->no_of_students], [null]); |
|
242 | + $failure = new Failure(3, 'remark', [3 => 'Class student count exceeded! Max number of students is'.$institutionClass->no_of_students], [null]); |
|
243 | 243 | $failures = [0 => $failure]; |
244 | 244 | throw new \Maatwebsite\Excel\Validators\ValidationException($error, $failures); |
245 | 245 | Log::info('email-sent', [$this->file]); |
246 | - } catch (Exception $e) { |
|
246 | + }catch (Exception $e) { |
|
247 | 247 | Log::info('email-sending-failed', [$e]); |
248 | 248 | } |
249 | - } else { |
|
249 | + }else { |
|
250 | 250 | return true; |
251 | 251 | } |
252 | 252 | } |
253 | 253 | |
254 | - public function getNode(){ |
|
254 | + public function getNode() { |
|
255 | 255 | return $this->file['node']; |
256 | 256 | } |
257 | 257 | |
@@ -305,7 +305,7 @@ discard block |
||
305 | 305 | /** |
306 | 306 | * |
307 | 307 | */ |
308 | - protected function setStudentSubjects($subject){ |
|
308 | + protected function setStudentSubjects($subject) { |
|
309 | 309 | return [ |
310 | 310 | 'id' => (string) Uuid::generate(4), |
311 | 311 | 'student_id' => $this->student->student_id, |
@@ -321,8 +321,8 @@ discard block |
||
321 | 321 | ]; |
322 | 322 | } |
323 | 323 | |
324 | - protected function insertSubject($subject){ |
|
325 | - if(!Institution_subject_student::isDuplicated($subject)){ |
|
324 | + protected function insertSubject($subject) { |
|
325 | + if (!Institution_subject_student::isDuplicated($subject)) { |
|
326 | 326 | Institution_subject_student::updateOrInsert($subject); |
327 | 327 | } |
328 | 328 | } |
@@ -150,7 +150,7 @@ discard block |
||
150 | 150 | } |
151 | 151 | } |
152 | 152 | return $row; |
153 | - }catch (Exception $e){ |
|
153 | + } catch (Exception $e){ |
|
154 | 154 | $error = \Illuminate\Validation\ValidationException::withMessages([]); |
155 | 155 | $failure = new Failure(3, 'remark', [0 => 'Template is not valid for upload, use the template given in the system'], [null]); |
156 | 156 | $failures = [0 => $failure]; |
@@ -196,7 +196,7 @@ discard block |
||
196 | 196 | protected function checkKeys($key,$count,$row){ |
197 | 197 | if(array_key_exists($key,$row)){ |
198 | 198 | return true; |
199 | - }else{ |
|
199 | + } else{ |
|
200 | 200 | $error = \Illuminate\Validation\ValidationException::withMessages([]); |
201 | 201 | $failure = new Failure($count, 'remark', [0 => 'Template is not valid for upload, use the template given in the system'. $key ,' Is missing form the template'], [null]); |
202 | 202 | $failures = [0 => $failure]; |
@@ -60,9 +60,9 @@ discard block |
||
60 | 60 | use Maatwebsite\Excel\Exceptions\ConcernConflictException; |
61 | 61 | use Mohamednizar\MoeUuid\MoeUuid; |
62 | 62 | |
63 | -class UsersImport extends Import Implements ToModel, WithStartRow, WithHeadingRow, WithMultipleSheets, WithEvents, WithMapping, WithLimit, WithBatchInserts, WithValidation ,SkipsOnFailure ,SkipsOnError { |
|
63 | +class UsersImport extends Import Implements ToModel, WithStartRow, WithHeadingRow, WithMultipleSheets, WithEvents, WithMapping, WithLimit, WithBatchInserts, WithValidation, SkipsOnFailure, SkipsOnError { |
|
64 | 64 | |
65 | - use Importable, SkipsFailures , SkipsErrors; |
|
65 | + use Importable, SkipsFailures, SkipsErrors; |
|
66 | 66 | |
67 | 67 | |
68 | 68 | public function sheets(): array { |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | throw new \Maatwebsite\Excel\Validators\ValidationException($error, $failures); |
87 | 87 | } |
88 | 88 | }, |
89 | - BeforeImport::class => function (BeforeImport $event) { |
|
89 | + BeforeImport::class => function(BeforeImport $event) { |
|
90 | 90 | $this->highestRow = ($event->getReader()->getDelegate()->getActiveSheet()->getHighestDataRow('C')); |
91 | 91 | if ($this->highestRow < 3) { |
92 | 92 | $error = \Illuminate\Validation\ValidationException::withMessages([]); |
@@ -122,9 +122,9 @@ discard block |
||
122 | 122 | break; |
123 | 123 | } |
124 | 124 | |
125 | - $BirthArea = Area_administrative::where('name', 'like', '%' . $row['birth_registrar_office_as_in_birth_certificate'] . '%')->first(); |
|
126 | - $nationalityId = Nationality::where('name', 'like', '%' . $row['nationality'] . '%')->first(); |
|
127 | - $identityType = Identity_type::where('national_code', 'like', '%' . $row['identity_type'] . '%')->first(); |
|
125 | + $BirthArea = Area_administrative::where('name', 'like', '%'.$row['birth_registrar_office_as_in_birth_certificate'].'%')->first(); |
|
126 | + $nationalityId = Nationality::where('name', 'like', '%'.$row['nationality'].'%')->first(); |
|
127 | + $identityType = Identity_type::where('national_code', 'like', '%'.$row['identity_type'].'%')->first(); |
|
128 | 128 | $academicPeriod = Academic_period::where('name', '=', $row['academic_period'])->first(); |
129 | 129 | |
130 | 130 | |
@@ -140,8 +140,8 @@ discard block |
||
140 | 140 | |
141 | 141 | $openemisStudent = MoeUuid::getUniqueAlphanumeric(3); |
142 | 142 | \Log::debug('Security_user'); |
143 | - $student = Security_user::create([ |
|
144 | - 'username' => str_replace('-','',$openemisStudent), |
|
143 | + $student = Security_user::create([ |
|
144 | + 'username' => str_replace('-', '', $openemisStudent), |
|
145 | 145 | 'openemis_no' => $openemisStudent, |
146 | 146 | 'first_name' => $row['full_name'], // here we save full name in the column of first name. re reduce breaks of the system. |
147 | 147 | 'last_name' => genNameWithInitials($row['full_name']), |
@@ -234,12 +234,12 @@ discard block |
||
234 | 234 | } |
235 | 235 | |
236 | 236 | |
237 | - if(!empty($row['bmi_weight']) && !empty($row['bmi_weight']) && !empty($row['bmi_date_yyyy_mm_dd'])){ |
|
237 | + if (!empty($row['bmi_weight']) && !empty($row['bmi_weight']) && !empty($row['bmi_date_yyyy_mm_dd'])) { |
|
238 | 238 | // convert Meeter to CM |
239 | - $hight = $row['bmi_height'] / 100; |
|
239 | + $hight = $row['bmi_height']/100; |
|
240 | 240 | |
241 | 241 | //calculate BMI |
242 | - $bodyMass = ($row['bmi_weight']) / pow($hight, 2); |
|
242 | + $bodyMass = ($row['bmi_weight'])/pow($hight, 2); |
|
243 | 243 | |
244 | 244 | $bmiAcademic = Academic_period::where('name', '=', $row['bmi_academic_period'])->first(); |
245 | 245 | |
@@ -258,9 +258,9 @@ discard block |
||
258 | 258 | |
259 | 259 | if (!empty($row['fathers_full_name']) && ($row['fathers_date_of_birth_yyyy_mm_dd'] !== null)) { |
260 | 260 | |
261 | - $AddressArea = Area_administrative::where('name', 'like', '%' . $row['fathers_address_area'] . '%')->first(); |
|
262 | - $nationalityId = Nationality::where('name', 'like', '%' . $row['fathers_nationality'] . '%')->first(); |
|
263 | - $identityType = Identity_type::where('national_code', 'like', '%' . $row['fathers_identity_type'] . '%')->first(); |
|
261 | + $AddressArea = Area_administrative::where('name', 'like', '%'.$row['fathers_address_area'].'%')->first(); |
|
262 | + $nationalityId = Nationality::where('name', 'like', '%'.$row['fathers_nationality'].'%')->first(); |
|
263 | + $identityType = Identity_type::where('national_code', 'like', '%'.$row['fathers_identity_type'].'%')->first(); |
|
264 | 264 | $openemisFather = MoeUuid::getUniqueAlphanumeric(4); |
265 | 265 | |
266 | 266 | $identityType = ($identityType !== null) ? $identityType->id : null; |
@@ -276,7 +276,7 @@ discard block |
||
276 | 276 | if ($father === null) { |
277 | 277 | |
278 | 278 | $father = Security_user::create([ |
279 | - 'username' => str_replace('-','',$openemisFather), |
|
279 | + 'username' => str_replace('-', '', $openemisFather), |
|
280 | 280 | 'openemis_no' => $openemisFather, |
281 | 281 | 'first_name' => $row['fathers_full_name'], // here we save full name in the column of first name. re reduce breaks of the system. |
282 | 282 | 'last_name' => genNameWithInitials($row['fathers_full_name']), |
@@ -295,25 +295,25 @@ discard block |
||
295 | 295 | $father['guardian_relation_id'] = 1; |
296 | 296 | if (array_key_exists('fathers_phone', $row)) { |
297 | 297 | $father['contact'] = $row['fathers_phone']; |
298 | - User_contact::createOrUpdate($father,$this->file['security_user_id']); |
|
298 | + User_contact::createOrUpdate($father, $this->file['security_user_id']); |
|
299 | 299 | } |
300 | 300 | Student_guardian::createStudentGuardian($student, $father, $this->file['security_user_id']); |
301 | - } else { |
|
301 | + }else { |
|
302 | 302 | Security_user::where('id', '=', $father->id) |
303 | 303 | ->update(['is_guardian' => 1]); |
304 | 304 | $father['guardian_relation_id'] = 1; |
305 | 305 | if (array_key_exists('fathers_phone', $row)) { |
306 | 306 | $father['contact'] = $row['fathers_phone']; |
307 | - User_contact::createOrUpdate($father,$this->file['security_user_id']); |
|
307 | + User_contact::createOrUpdate($father, $this->file['security_user_id']); |
|
308 | 308 | } |
309 | 309 | Student_guardian::createStudentGuardian($student, $father, $this->file['security_user_id']); |
310 | 310 | } |
311 | 311 | } |
312 | 312 | |
313 | 313 | if (!empty($row['mothers_full_name']) && ($row['mothers_date_of_birth_yyyy_mm_dd'] !== null)) { |
314 | - $AddressArea = Area_administrative::where('name', 'like', '%' . $row['mothers_address_area'] . '%')->first(); |
|
315 | - $nationalityId = Nationality::where('name', 'like', '%' . $row['mothers_nationality'] . '%')->first(); |
|
316 | - $identityType = Identity_type::where('national_code', 'like', '%' . $row['mothers_identity_type'] . '%')->first(); |
|
314 | + $AddressArea = Area_administrative::where('name', 'like', '%'.$row['mothers_address_area'].'%')->first(); |
|
315 | + $nationalityId = Nationality::where('name', 'like', '%'.$row['mothers_nationality'].'%')->first(); |
|
316 | + $identityType = Identity_type::where('national_code', 'like', '%'.$row['mothers_identity_type'].'%')->first(); |
|
317 | 317 | $openemisMother = MoeUuid::getUniqueAlphanumeric(4); |
318 | 318 | |
319 | 319 | $identityType = $identityType !== null ? $identityType->id : null; |
@@ -328,7 +328,7 @@ discard block |
||
328 | 328 | |
329 | 329 | if ($mother === null) { |
330 | 330 | $mother = Security_user::create([ |
331 | - 'username' => str_replace('-','',$openemisMother), |
|
331 | + 'username' => str_replace('-', '', $openemisMother), |
|
332 | 332 | 'openemis_no' => $openemisMother, |
333 | 333 | 'first_name' => $row['mothers_full_name'], // here we save full name in the column of first name. re reduce breaks of the system. |
334 | 334 | 'last_name' => genNameWithInitials($row['mothers_full_name']), |
@@ -355,16 +355,16 @@ discard block |
||
355 | 355 | $mother['guardian_relation_id'] = 2; |
356 | 356 | if (array_key_exists('mothers_phone', $row)) { |
357 | 357 | $mother['contact'] = $row['mothers_phone']; |
358 | - User_contact::createOrUpdate($mother,$this->file['security_user_id']); |
|
358 | + User_contact::createOrUpdate($mother, $this->file['security_user_id']); |
|
359 | 359 | } |
360 | 360 | Student_guardian::createStudentGuardian($student, $mother, $this->file['security_user_id']); |
361 | - } else { |
|
361 | + }else { |
|
362 | 362 | Security_user::where('id', '=', $mother->id) |
363 | 363 | ->update(['is_guardian' => 1]); |
364 | 364 | $mother['guardian_relation_id'] = 2; |
365 | 365 | if (array_key_exists('mothers_phone', $row)) { |
366 | 366 | $mother['contact'] = $row['mothers_phone']; |
367 | - User_contact::createOrUpdate($mother,$this->file['security_user_id']); |
|
367 | + User_contact::createOrUpdate($mother, $this->file['security_user_id']); |
|
368 | 368 | } |
369 | 369 | Student_guardian::createStudentGuardian($student, $mother, $this->file['security_user_id']); |
370 | 370 | } |
@@ -373,9 +373,9 @@ discard block |
||
373 | 373 | |
374 | 374 | if (!empty($row['guardians_full_name']) && ($row['guardians_date_of_birth_yyyy_mm_dd'] !== null)) { |
375 | 375 | $genderId = $row['guardians_gender_mf'] == 'M' ? 1 : 2; |
376 | - $AddressArea = Area_administrative::where('name', 'like', '%' . $row['guardians_address_area'] . '%')->first(); |
|
377 | - $nationalityId = Nationality::where('name', 'like', '%' . $row['guardians_nationality'] . '%')->first(); |
|
378 | - $identityType = Identity_type::where('national_code', 'like', '%' . $row['guardians_identity_type'] . '%')->first(); |
|
376 | + $AddressArea = Area_administrative::where('name', 'like', '%'.$row['guardians_address_area'].'%')->first(); |
|
377 | + $nationalityId = Nationality::where('name', 'like', '%'.$row['guardians_nationality'].'%')->first(); |
|
378 | + $identityType = Identity_type::where('national_code', 'like', '%'.$row['guardians_identity_type'].'%')->first(); |
|
379 | 379 | $openemisGuardian = MoeUuid::getUniqueAlphanumeric(4); |
380 | 380 | |
381 | 381 | $identityType = $identityType !== null ? $identityType->id : null; |
@@ -390,7 +390,7 @@ discard block |
||
390 | 390 | |
391 | 391 | if ($guardian === null) { |
392 | 392 | $guardian = Security_user::create([ |
393 | - 'username' => str_replace('-','',$openemisGuardian), |
|
393 | + 'username' => str_replace('-', '', $openemisGuardian), |
|
394 | 394 | 'openemis_no' => $openemisGuardian, |
395 | 395 | 'first_name' => $row['guardians_full_name'], // here we save full name in the column of first name. re reduce breaks of the system. |
396 | 396 | 'last_name' => genNameWithInitials($row['guardians_full_name']), |
@@ -417,16 +417,16 @@ discard block |
||
417 | 417 | $guardian['guardian_relation_id'] = 3; |
418 | 418 | if (array_key_exists('guardians_phone', $row)) { |
419 | 419 | $guardian['contact'] = $row['guardians_phone']; |
420 | - User_contact::createOrUpdate($guardian,$this->file['security_user_id']); |
|
420 | + User_contact::createOrUpdate($guardian, $this->file['security_user_id']); |
|
421 | 421 | } |
422 | 422 | Student_guardian::createStudentGuardian($student, $guardian, $this->file['security_user_id']); |
423 | - } else { |
|
423 | + }else { |
|
424 | 424 | Security_user::where('id', '=', $guardian->id) |
425 | 425 | ->update(['is_guardian' => 1]); |
426 | 426 | $guardian['guardian_relation_id'] = 3; |
427 | 427 | if (array_key_exists('guardians_phone', $row)) { |
428 | 428 | $guardian['contact'] = $row['guardians_phone']; |
429 | - User_contact::createOrUpdate($guardian,$this->file['security_user_id']); |
|
429 | + User_contact::createOrUpdate($guardian, $this->file['security_user_id']); |
|
430 | 430 | } |
431 | 431 | Student_guardian::createStudentGuardian($student, $guardian, $this->file['security_user_id']); |
432 | 432 | } |
@@ -439,12 +439,12 @@ discard block |
||
439 | 439 | if (!empty($allSubjects)) { |
440 | 440 | $allSubjects = unique_multidim_array($allSubjects, 'institution_subject_id'); |
441 | 441 | $this->student = $student; |
442 | - $allSubjects = array_map(array($this,'setStudentSubjects'),$allSubjects); |
|
442 | + $allSubjects = array_map(array($this, 'setStudentSubjects'), $allSubjects); |
|
443 | 443 | // $allSubjects = array_unique($allSubjects,SORT_REGULAR); |
444 | 444 | // $allSubjects = unique_multidim_array($allSubjects, 'education_subject_id'); |
445 | 445 | // array_walk($allSubjects,array($this,'insertSubject')); |
446 | 446 | $allSubjects = unique_multidim_array($allSubjects, 'education_subject_id'); |
447 | - array_walk($allSubjects,array($this,'insertSubject')); |
|
447 | + array_walk($allSubjects, array($this, 'insertSubject')); |
|
448 | 448 | // Institution_subject_student::insert((array) $allSubjects); |
449 | 449 | } |
450 | 450 | |
@@ -454,7 +454,7 @@ discard block |
||
454 | 454 | |
455 | 455 | if ($totalStudents['total'] > $institutionClass->no_of_students) { |
456 | 456 | $error = \Illuminate\Validation\ValidationException::withMessages([]); |
457 | - $failure = new Failure(3, 'rows', [3 => 'Class student count exceeded! Max number of students is ' . $institutionClass->no_of_students], [null]); |
|
457 | + $failure = new Failure(3, 'rows', [3 => 'Class student count exceeded! Max number of students is '.$institutionClass->no_of_students], [null]); |
|
458 | 458 | $failures = [0 => $failure]; |
459 | 459 | throw new \Maatwebsite\Excel\Validators\ValidationException($error, $failures); |
460 | 460 | Log::info('email-sent', [$this->file]); |
@@ -465,7 +465,7 @@ discard block |
||
465 | 465 | 'total_male_students' => $totalStudents['total_male_students'], |
466 | 466 | 'total_female_students' => $totalStudents['total_female_students']]); |
467 | 467 | } |
468 | - } catch (\Maatwebsite\Excel\Validators\ValidationException $e) { |
|
468 | + }catch (\Maatwebsite\Excel\Validators\ValidationException $e) { |
|
469 | 469 | $error = \Illuminate\Validation\ValidationException::withMessages([]); |
470 | 470 | // $failure = new Failure(3, 'remark', [3 => ], [null]); |
471 | 471 | $failures = $e->failures(); |
@@ -479,7 +479,7 @@ discard block |
||
479 | 479 | return [ |
480 | 480 | '*.full_name' => 'required|regex:/^[\pL\s\-]+$/u|max:100', |
481 | 481 | '*.gender_mf' => 'required|in:M,F', |
482 | - '*.date_of_birth_yyyy_mm_dd' => 'date|required|admission_age:' . $this->file['institution_class_id'], |
|
482 | + '*.date_of_birth_yyyy_mm_dd' => 'date|required|admission_age:'.$this->file['institution_class_id'], |
|
483 | 483 | '*.address' => 'nullable', |
484 | 484 | '*.birth_registrar_office_as_in_birth_certificate' => 'nullable|exists:area_administratives,name|required_if:identity_type,BC|birth_place', |
485 | 485 | '*.birth_divisional_secretariat' => 'nullable|exists:area_administratives,name|required_with:birth_registrar_office_as_in_birth_certificate', |
@@ -489,14 +489,14 @@ discard block |
||
489 | 489 | '*.academic_period' => 'required|exists:academic_periods,name', |
490 | 490 | '*.education_grade' => 'required', |
491 | 491 | '*.option_*' => 'nullable|exists:education_subjects,name', |
492 | - '*.bmi_height' => 'bail|bmi:'. $this->file['institution_class_id'], |
|
493 | - '*.bmi_weight' => 'bail|bmi:'. $this->file['institution_class_id'], |
|
494 | - '*.bmi_date_yyyy_mm_dd' => 'bail|bmi:'. $this->file['institution_class_id'].'date', |
|
495 | - '*.bmi_academic_period' => 'bail|bmi:'. $this->file['institution_class_id'].'exists:academic_periods,name', |
|
492 | + '*.bmi_height' => 'bail|bmi:'.$this->file['institution_class_id'], |
|
493 | + '*.bmi_weight' => 'bail|bmi:'.$this->file['institution_class_id'], |
|
494 | + '*.bmi_date_yyyy_mm_dd' => 'bail|bmi:'.$this->file['institution_class_id'].'date', |
|
495 | + '*.bmi_academic_period' => 'bail|bmi:'.$this->file['institution_class_id'].'exists:academic_periods,name', |
|
496 | 496 | '*.admission_no' => 'required|max:12|min:1', |
497 | 497 | '*.start_date_yyyy_mm_dd' => 'required', |
498 | 498 | '*.special_need_type' => 'nullable', |
499 | - '*.special_need' => 'nullable|exists:special_need_difficulties,name|required_if:special_need_type,Differantly Able',//|exists:special_need_difficulties,name', |
|
499 | + '*.special_need' => 'nullable|exists:special_need_difficulties,name|required_if:special_need_type,Differantly Able', //|exists:special_need_difficulties,name', |
|
500 | 500 | '*.fathers_full_name' => 'nullable|regex:/^[\pL\s\-]+$/u', |
501 | 501 | '*.fathers_date_of_birth_yyyy_mm_dd' => 'required_with:fathers_full_name', |
502 | 502 | '*.fathers_address' => 'required_with:fathers_full_name', |