Browse Source

Login Timezone

Mostafijur Rahman 1 year ago
parent
commit
7605cfef73

+ 3 - 3
app/Helpers/functions.php

@@ -155,12 +155,12 @@ if(!function_exists('profile_permission')){
 }
 
 
-function local_tz(\App\User $user=NULL, $default='UTC'){
+function local_tz($user=NULL, $default='UTC'){
 
     if(empty($user)) $user=\Auth::user();
 
-    if($user && $user->last_timezone){
-        return $user->last_timezone;
+    if($user && $user->last_logged_timezone){
+        return $user->last_logged_timezone;
     }
 
     return $default;

+ 5 - 2
app/Http/Controllers/Admin/AdminController.php

@@ -77,7 +77,9 @@ class AdminController extends Controller
             'user_type',1
         )->orderBy('id','DESC')->get();
 
-        $application = StudentProposal::orderBy('id','DESC')->get();
+        $application = StudentProposal::where(
+            'proposal_submit_status',1
+        )->orderBy('id','DESC')->get(); 
 
         $data =[
           'register_active_teachers_list'=>$register_active_teachers_list,
@@ -86,7 +88,8 @@ class AdminController extends Controller
           'refer_users'=>$student_refer_friend_list,
           'invited_registered_list'=>$invited_registered_list,
           'application'=>$application,
-          'landing_wishlist'=>$landing_wishlist
+          'landing_wishlist'=>$landing_wishlist,
+          'admin'=>$admin
         ];
         return view('admin.admin_profile',$data);
     }

+ 3 - 1
app/Http/Controllers/AdminAuth/LoginController.php

@@ -48,7 +48,9 @@ class LoginController extends Controller
             ];
             
             if (Auth::guard('admin')->attempt($credentials)){
-
+                $admin->last_logged_timezone=$request->last_logged_timezone;
+                $admin->last_logged_at=now();
+                $admin->update();
                 return redirect('admin/dashboard');
 
             }else{

+ 4 - 0
app/Http/Controllers/Auth/LoginController.php

@@ -76,6 +76,10 @@ class LoginController extends Controller
 
                 if (Auth::attempt($credentials)) {
 
+                    $student->last_logged_timezone=$request->last_logged_timezone;
+                    $student->last_logged_at=now();
+                    $student->update();
+
                     return redirect('home');
                   }
                   else{

+ 6 - 2
app/Http/Controllers/TeacherAuth/LoginController.php

@@ -58,13 +58,13 @@ class LoginController extends Controller
             'user_type',2
         )->where(
             'email',$request->email
-        )->first();
+        )->first(); 
 
         if(!$teacher){
             return redirect('/login-v2')->with('error','Unknown Email address!');
         }else{
             if($teacher->apply_status == 0){
-                return redirect('/login-v2')->with('error', 'Account Approve Status is not Activated!');
+                return redirect('/login-v2')->with('error', 'Your account is still under review.');
             }
             else{
                 $credentials = [
@@ -76,6 +76,10 @@ class LoginController extends Controller
 
                 if (Auth::guard('teacher')->attempt($credentials)) {
 
+                    $teacher->last_logged_timezone=$request->last_logged_timezone;
+                    $teacher->last_logged_at=now();
+                    $teacher->update(); 
+
                     return redirect('teacher_profile');
                   }
                   else{

+ 5 - 1
app/Http/Controllers/TeacherHomeController.php

@@ -20,7 +20,11 @@ class TeacherHomeController extends Controller
    } 
     public function teacher_profile(Request $request)
     {   $user = Auth::guard('teacher')->user(); 
-        $students = StudentProposal::where('teacher_id',$user->id)->get(); 
+        $students = StudentProposal::where(
+            'teacher_id',$user->id
+        )->where(
+            'proposal_submit_status',1
+        )->get(); 
         $departments =Department::where('status',1)->orderBy('name','ASC')->get();
        // $refer_users =ReferUser::where('teacher_id',$user->id)->orderBy('id','DESC')->get();
         $refer_users =User::where(

+ 2 - 0
app/User.php

@@ -47,6 +47,8 @@ class User extends Authenticatable
         'email_verified_at',
         'registered_date',
         'invitation_date',
+        'last_logged_timezone',
+        'last_logged_at',
     ];
 
     /**

File diff suppressed because it is too large
+ 0 - 0
public/css/moment-timezone/builds/moment-timezone-with-data.min.js


File diff suppressed because it is too large
+ 0 - 0
public/css/moment/min/moment-with-locales.min.js


+ 4 - 0
resources/views/admin/admin_profile.blade.php

@@ -901,6 +901,10 @@ tbody, td, tfoot, th, thead, tr {
                                                                                             @else
                                                                                                 {{ cn($row, 'department_name.name','') }}
                                                                                             @endif
+                                                                                            <br>
+                                                                                            @if($row->last_logged_at)
+                                                                                            {{utc_to_ltz($row->last_logged_at, 'd M Y g:i A', local_tz($admin))}}
+                                                                                            @endif
                                                                                         </td>
                                                                                         <td style="font-size: 11px; width: 9%;">
                                                                                             <div class="single_glance_row mt-1" style="display: flex;">

+ 11 - 1
resources/views/admin/auth/admin_login.blade.php

@@ -142,6 +142,7 @@
                                 <h6 class="mt-5 pt-5" style="color: white; margin-top:7.5rem !important;">Please log-in to your account</h6>
                                     <form method="POST" action="{{route('create-login')}}">
                                         @csrf
+                                        <input type="hidden" id="last_logged_timezone" name="last_logged_timezone" value=""/>
                                         @if ($message = Session::get('success'))
                                             <div class="row mb-1">
                                                 <div class="col-md-12">
@@ -188,6 +189,7 @@
         <!-- Hero End -->
 
         <!-- javascript -->
+        <script src="{{ asset('css/jquery.min.js') }}"></script>
         <script src="{{asset('web/js/bootstrap.bundle.min.js')}}"></script>
         <!-- tobii js -->
         <script src="{{asset('web/js/tobii.min.js')}}"></script>
@@ -200,9 +202,11 @@
         <script src="{{asset('web/js/app.js')}}"></script>
         <script src="{{ asset('css/jquery-form/dist/jquery.form.min.js') }}"></script>
         <script src="{{ asset('css/noty/lib/noty.min.js') }}"></script>
+        <script src="{{ asset('css/moment/min/moment-with-locales.min.js') }}"></script>
+        <script src="{{ asset('css/moment-timezone/builds/moment-timezone-with-data.min.js') }}"></script>
 
        
-        @if ($message = Session::get('error'))
+            @if ($message = Session::get('error'))
             <script type="text/javascript">
                 $(document).ready(function(){
                     var msg = "{{ $message }}";
@@ -210,6 +214,12 @@
                 });
             </script>
             @endif
+
+            <script>
+                $(function(){
+                  $('#last_logged_timezone').val(moment.tz.guess());
+                });
+            </script>
        
         </body>
   </html>

+ 12 - 2
resources/views/auth/login.blade.php

@@ -209,6 +209,7 @@
                                             <h6 class="card-title text-start" style="color: black;">Please log-in to your account</h6>  
                                             <form method="POST" action="{{ route('student-login') }}"> 
                                                     @csrf
+                                                    <input type="hidden" id="last_logged_timezone" name="last_logged_timezone"/>
                                                     @if ($message = Session::get('error'))
                                                     <div class="row">
                                                         <div class="col-md-12">
@@ -277,6 +278,7 @@
             </div><!--end container fluid-->
         </section><!--end section-->
        <!-- javascript -->
+       <script src="{{ asset('css/jquery.min.js') }}"></script>
        <script src="{{asset('web/js/bootstrap.bundle.min.js')}}"></script>
         <!-- tobii js -->
         <script src="{{asset('web/js/tobii.min.js')}}"></script>
@@ -287,5 +289,13 @@
         <!-- Main Js -->
         <script src="{{asset('web/js/plugins.init.js')}}"></script>
         <script src="{{asset('web/js/app.js')}}"></script>
-        </body>
-  </html>
+        <script src="{{ asset('css/moment/min/moment-with-locales.min.js') }}"></script>
+        <script src="{{ asset('css/moment-timezone/builds/moment-timezone-with-data.min.js') }}"></script>
+
+        <script>
+            $(function(){
+              $('#last_logged_timezone').val(moment.tz.guess());
+            });
+        </script>
+    </body>
+</html>

+ 12 - 2
resources/views/login-v2.blade.php

@@ -206,6 +206,7 @@
                                              <h6 style="color: white;">Please log-in to your account</h6>
                                             <form method="POST" action="{{ route('teacher-login') }}">
                                                 @csrf
+                                                <input type="hidden" id="last_logged_timezone" name="last_logged_timezone" value=""/>
                                                 @if ($message = Session::get('success'))
                                                     <div class="row">
                                                         <div class="col-md-12">
@@ -261,6 +262,7 @@
             </div><!--end container fluid-->
         </section><!--end section-->
         <!-- javascript -->
+        <script src="{{ asset('css/jquery.min.js') }}"></script>
         <script src="{{asset('web/js/bootstrap.bundle.min.js')}}"></script>
         <!-- tobii js -->
         <script src="{{asset('web/js/tobii.min.js')}}"></script>
@@ -273,5 +275,13 @@
         <script src="{{asset('web/js/app.js')}}"></script>
         <script src="{{ asset('css/pnotify/pnotify.js') }}"></script>
         <script src="{{ asset('css/noty/lib/noty.min.js') }}"></script>
-        </body>
-  </html>
+        <script src="{{ asset('css/moment/min/moment-with-locales.min.js') }}"></script>
+        <script src="{{ asset('css/moment-timezone/builds/moment-timezone-with-data.min.js') }}"></script>
+         
+        <script>
+            $(function(){
+              $('#last_logged_timezone').val(moment.tz.guess());
+            });
+        </script>
+    </body>
+</html>

+ 17 - 11
resources/views/teacher_profile.blade.php

@@ -587,7 +587,7 @@ tbody, td, tfoot, th, thead, tr {
                                                     <a href="" class="" style="color: black;"><span class="label_badge_work"> {{$row->student_apply_ref ?? "N/A"}} </span></a>
                                                 </div>
                                                 <div style="font-size: 11px;">
-                                                    <span style="color: black;">{{ date("d M, Y", strtotime(cn($row,'student_details.dob','')))}}</span>
+                                                    <span style="color: black;">@if(!empty($row->student_details->dob)){{ date("d M, Y", strtotime(cn($row,'student_details.dob','')))}} @else @endif</span>
                                                 </div>
                                             </td>
                                             <td style="font-size: 11px;">
@@ -595,7 +595,7 @@ tbody, td, tfoot, th, thead, tr {
                                                     <span style="color: black;">{{cn($row,'institutes.institution','')}}</span>
                                                 </div>
                                                 <div style="font-size: 11px;">
-                                                    <span style="color: black;">{{date('M Y',strtotime(cn($row,'institutes.start_date','N/A')))}} - {{date('M Y',strtotime(cn($row,'institutes.end_date','N/A')))}}</span>
+                                                    <span style="color: black;">@if(!empty($row->institutes->start_date)) {{date('M Y',strtotime(cn($row,'institutes.start_date','N/A')))}} @else @endif  @if(!empty($row->institutes->end_date)) - {{date('M Y',strtotime(cn($row,'institutes.end_date','N/A')))}} @else @endif</span>
                                                 </div>
                                                 <div class="mt-1" style="font-size: 11px;">
                                                     <span class="label_badge_gpa">{{cn($row,'institutes.result','')}} (GPA)</span>
@@ -644,17 +644,23 @@ tbody, td, tfoot, th, thead, tr {
                                                 <div class="inner_right">
                                                     <a href="{{ url('teacher/student-proposal-details') }}/{{$row->id}}"><strong style="font-size:11px; color:black;">{{cn($row,'proposal.title','')}}</strong></a></br>
                                                     <span style="color:black;">{{cn($row,'proposal.methology','')}}</span>
-                                                    <span>.</span>
                                                     @php
-                                                       $proposal =\DB::table('proposal')->where(
-                                                        'student_id',$row->student_id
-                                                       )->first();
-
-                                                       $department =\DB::table('departments')->where(
-                                                        'id',$proposal->department
-                                                       )->first();
+                                                        $proposal =\DB::table('proposal')->where(
+                                                           'student_id',$row->student_id
+                                                           )->first();
+
+                                                        if(isset($proposal)){
+                                                            $department =\DB::table('departments')->where(
+                                                               'id',$proposal->department
+                                                               )->first();
+                                                        } 
                                                     @endphp
-                                                    <span style="color:black;">{{ $department->name ?? ''}}</span>
+                                                    @if(isset($department))
+                                                    <span>.</span>
+                                                    <span style="color:black;"> 
+                                                        {{ $department->name }} 
+                                                    </span>
+                                                    @endif
                                                     <span>.</span>
                                                     <span style="color:black;">{{cn($row,'proposal.status','')}}</span>
                                                 </div>

+ 10 - 1
sql/update.sql

@@ -220,4 +220,13 @@ ALTER TABLE `student_proposals`
 	CHANGE COLUMN `proposal_status` `proposal_status` TINYINT(4) NULL DEFAULT '1' COMMENT '1=New,2=Reviewing,3=Pause, 4=Hold, , 5=Interested ,6=Rejected' AFTER `concept`;
 
 ALTER TABLE `student_proposals`
-	ADD COLUMN `draft_status` TINYINT(4) NULL DEFAULT '0' COMMENT '1=drafy_q_from' AFTER `submitted_date`;
+	ADD COLUMN `draft_status` TINYINT(4) NULL DEFAULT '0' COMMENT '1=drafy_q_from' AFTER `submitted_date`;
+
+ALTER TABLE `users`
+	ADD COLUMN `last_logged_timezone` VARCHAR(255) NULL DEFAULT NULL AFTER `register_type`;
+
+ALTER TABLE `users`
+	ADD COLUMN `last_logged_at` DATETIME NULL DEFAULT NULL AFTER `last_logged_timezone`;
+
+ALTER TABLE `admins`
+	ADD COLUMN `last_logged_at` DATETIME NULL DEFAULT NULL AFTER `last_logged_timezone`;

Some files were not shown because too many files changed in this diff