Browse Source

admin profile

Mostafijur Rahman 1 year ago
parent
commit
2c3ad7e2e2

+ 11 - 0
app/Http/Controllers/Admin/SubContentController.php

@@ -47,6 +47,17 @@ class SubContentController extends Controller
 		}elseif($name=="load_research_interest"){
 			$tuser=Auth::guard('teacher')->user();
 			$data['resarch'] =ResearchInterest::where('teacher_id',$tuser->id)->orderBy('id','DESC')->get();
+		}elseif($name=="edit_university_load"){ 
+			$user=Auth::guard('admin')->user();
+			$data['edit_data'] =University::find($req->edit_id); 
+			$data['market_countries'] = MarketCountry::where( 
+                'status', 1
+            )->select(
+                'market_countries.*', \DB::raw('(SELECT name FROM countries WHERE market_countries.country_id = countries.id ) as sort')
+            )->orderBy('sort')->get();
+
+		}elseif($name=="edit_department_form"){
+			$data['edit_dept'] =Department::find($req->dep_id);
 		}else $name='default';  
 		//$data['page_sl']=new PageSL($data['chapter_details']); 
 		return view("admin.sub_contents.{$name}", $data);

+ 56 - 1
app/Http/Controllers/AjaxController.php

@@ -237,6 +237,61 @@ class AjaxController extends Controller
             return response(
                 ['msg'=>'Saved successfully.']
             );
-        }  
+        }elseif($name=="edit_university_save"){
+            $user=Auth::guard('admin')->user();
+            $validator=\Validator::make($req->all(), [
+                'country_id'=>'required', 
+                'university_name'=>'required', 
+                'university_website'=>'required', 
+            ]); 
+
+            if($validator->fails()){
+                $errors=$validator->errors()->all();
+                return response(['msg'=>$errors[0]], 422);
+            } 
+            
+			$data =University::find($req->edit_id);
+            $data->country_id =$req->country_id;
+            $data->name =$req->university_name;
+            $data->web_address =$req->university_website;
+            $data->update();
+
+            return response([
+                'msg'=>'Update Successfully.'
+            ]);
+
+        }elseif($name=="delete_university_info"){
+            $user=Auth::guard('admin')->user(); 
+            $data =University::find($req->delete_id);
+            $data->delete();
+            return response([
+                'msg'=>'Successfully Deleted'
+            ]);
+        
+        }elseif($name=="delete_department_info"){
+            $user=Auth::guard('admin')->user(); 
+            $data =Department::find($req->delete_id);
+            $data->delete();
+            return response([
+                'msg'=>'Successfully Deleted'
+            ]);
+        }elseif($name=="edit_department_save"){
+            $user=Auth::guard('admin')->user(); 
+            $validator=\Validator::make($req->all(), [
+                'department'=>'required', 
+            ]); 
+
+            if($validator->fails()){
+                $errors=$validator->errors()->all();
+                return response(['msg'=>$errors[0]], 422);
+            }
+
+            $data =Department::find($req->edit_id);
+            $data->name =$req->department; 
+            $data->update();
+            return response([
+                'msg'=>'Successfully updated.'
+            ]);
+        } 
 	}
 }

+ 58 - 19
resources/views/admin/admin_profile.blade.php

@@ -872,25 +872,10 @@ tbody, td, tfoot, th, thead, tr {
                                                     </div>
                                                 </div>
                                                     <div class="single_glance_row mt-5">
-                                                        <div id="load_department"></div>
-                                                        {{-- <div style="display: flex">
-                                                        <div class="left" style="width: 80%;">
-                                                            <span class="title" style="font-size:11px;">Math</span>
-                                                        </div>
-                                                        <div class="right" style="width: 20%;">
-                                                            <span class="title" style="font-size:11px; font-weight: 600;">
-                                                                <a role="button" data-bs-toggle="collapse" data-bs-parent="#collapse" href="#collapse1" aria-expanded="true" aria-controls="collapse1">
-                                                                    <button type="button" class="btn btn2" data-toggle="collapse" data-target="#demo16" style="padding: 2px 5px !important; font-size: 11px;"><i class="fa fa-pencil"></i></button>
-                                                                </a>
-                                                            </span>
-                                                            <span class="title" style="font-size:11px; font-weight: 600;">
-                                                                <button type="button" class="btn btn2" style="padding: 2px 5px !important; font-size: 11px;"><i class="fa fa-trash"></i></button>
-                                                            </span>
-                                                        </div>
-                                                        </div> --}}
-                                                                <!-- Tab -->
-                                                        <div class="col-md-12">
-                                                            <div id="demo16" class="collapse mt-2">
+                                                        <div id="load_department"></div> 
+                                                        <!-- Tab -->
+                                                        <div class="col-md-12 d-none">
+                                                            <div id="" class="mt-2">
                                                                 <div class="panel-body" style="padding:10px; background-color: #4b4c6824; border: 1px solid #e9e5e5; border-radius: 5px;">
                                                                     <form method="POST" action="">
                                                                         <div class="row">
@@ -1104,6 +1089,58 @@ tbody, td, tfoot, th, thead, tr {
 
         }
 
+        function ajax_form(form, cllback=null, config={spinner: true}){
+
+            $('.btn-submit').prop('disabled', true);
+            var redirect=$(form).data('redirect');
+
+            if(typeof config=='object'){
+
+            if(config.spinner) wait_me($(form));
+
+            }
+            
+            $(form).ajaxSubmit({
+            success:function(res){
+
+                wait_me($(form), 'hide');
+
+                if(res.msg){
+
+                pop_up_msg(res.msg, 'success', function(){
+
+                    //$('.btn-submit').prop('disabled', false);
+
+                    if(redirect) window.location.replace(redirect);
+                    else if(typeof cllback=='function'){
+                    cllback(form);
+                    }
+
+                });
+
+                }
+
+                //$.notify(res.msg, 'success');
+            },
+            error:function(res){
+
+                wait_me($(form), 'hide');
+
+                var msg="Request failed to process, try again later.";
+
+                if(res.responseJSON && res.responseJSON.msg){
+                msg=res.responseJSON.msg;
+                }
+
+                pop_up_msg(msg, 'error');
+                $('.btn-submit').prop('disabled', false);
+
+            }
+
+            });
+
+        } //End of ajax form definition
+
         $(function(){ 
 
             $('.status_change').on('click', function(e){  
@@ -1211,6 +1248,8 @@ tbody, td, tfoot, th, thead, tr {
 
                 }); 
             });
+
+            
         });
       </script>
 </body>

+ 71 - 4
resources/views/admin/sub_contents/country_wise_university.blade.php

@@ -18,9 +18,18 @@
             <td style="font-size: 11px;">{{cn($row,'country.name','')}}</td>
             <td style="font-size: 11px;">{{$row->name}}</td>
             <td style="font-size: 11px;">{{$row->web_address}}</td>
-            <td style="font-size: 11px; text-align: center;">
-                <i class="fa fa-edit"></i>
-                <i class="fa fa-trash ms-1"></i>
+            <td style="font-size: 11px; text-align: center;"> 
+                <span class="edit_uni_info" data-id="{{$row->id}}" style="cursor: pointer;"><i class="fa fa-edit" ></i></span>
+                <span class="delete_uni_info" data-id="{{$row->id}}" style="cursor: pointer;"><i class="fa fa-trash ms-1" ></i></span>
+                 
+            </td>
+        </tr>
+        <?php 
+            $edit_cls_name = "edit_cls_".$row->id;
+        ?>
+        <tr class="edit_data {{$edit_cls_name}} d-none">
+            <td colspan="5">
+                <div class="edit_university_load"></div>
             </td>
         </tr>
         @endforeach
@@ -28,4 +37,62 @@
 </table>
 @endif
  
-@endsection
+@endsection
+
+<script>
+    $(function(){
+        $('.edit_uni_info').on('click', function(){  
+
+            $('.edit_university_load').empty();
+            var self = $(this);
+            var id = self.attr("data-id"); 
+            var edit_cls = "edit_cls_"+id; 
+            $('.edit_data').addClass('d-none'); 
+            $("."+edit_cls).removeClass('d-none'); 
+            var edit_university_load = self.closest('tbody').find('.edit_university_load');
+
+            fetch_sub_content(
+                edit_university_load,
+                "{!! route('sub-content', ['name'=>'edit_university_load','action'=>'edit']) !!}&edit_id="+id
+            );
+        });
+
+        $('.delete_uni_info').on('click', function(){ 
+            var id = $(this).attr("data-id"); 
+            var form_data={
+                _token: "{{ csrf_token() }}",  
+                delete_id: id,
+            }  
+            swal({
+                title: "Are you sure?",
+                text: "You will not be able to recover this data!",
+                type: "warning",
+                showCancelButton: true,
+                confirmButtonClass: "btn-danger",
+                cancelButtonClass: "btn-info",
+                confirmButtonText: "Yes, delete!",
+                cancelButtonText: "No, cancel!",
+
+            }, function(isConfirm){
+
+                if(isConfirm){  
+                    $.post("{{ route('ajax-post', ['name'=>'delete_university_info']) }}",form_data
+                    ).done(function(res){
+
+                        pop_up_msg(res.msg);
+                        
+                        $('#country_wise_university').empty();
+                        fetch_sub_content(
+                            '#country_wise_university',
+                            "{{ route('sub-content', ['name'=>'country_wise_university']) }}"
+                        );
+
+                    }).fail(function(err){ 
+                        pop_up_msg(err_msg(err), 'error'); 
+                    }); 
+                } 
+            }); 
+                        
+        });
+    });
+</script>

+ 44 - 0
resources/views/admin/sub_contents/edit_department_form.blade.php

@@ -0,0 +1,44 @@
+ 
+<form method="POST" action="{{route('ajax-post', ['name'=>'edit_department_save'])}}" class="edit_dep_info_form"> 
+    <input type="hidden" name="_token" value="{{ csrf_token() }}" />
+    <input type="hidden" name="edit_id" value="{{$edit_dept->id}}">
+    <div class="col-md-12">
+        <div class="mb-2">
+            <label class="form-label config"></label>
+            <div class="form-icon position-relative">
+                <input type="text" class="form-control" placeholder="Department" name="department" value="{{$edit_dept->name}}" required="" style="font-size: 13px;">
+            </div>
+        </div>
+    </div>     
+    <div class="col-md-12">
+        <div class="text-end">
+            <button type="button" class="btn cancel_button mr-1 btn-cancel close_form" >
+                <i aria-hidden="true" class="fa fa-refresh"></i>
+            </button>
+            <button class="btn btn2">Update</button>                      
+        </div>
+    </div>
+     
+</form>  
+ 
+
+<script>
+    $(function(){
+        $('.edit_dep_info_form').on('submit', function(event){
+            event.preventDefault();
+            var self = $(this); 
+            ajax_form(self, function(self){
+                $('#load_department').empty();
+                fetch_sub_content(
+                    '#load_department',
+                    "{{ route('sub-content', ['name'=>'load_department']) }}"
+                );  
+            });
+        });
+         
+
+        $('.btn-cancel').on('click', function(){ 
+            $('.open_department_edit_info_div_inner').addClass('d-none')
+        });
+    });
+</script>

+ 70 - 0
resources/views/admin/sub_contents/edit_university_load.blade.php

@@ -0,0 +1,70 @@
+<form method="POST" action="{{route('ajax-post', ['name'=>'edit_university_save'])}}" class="edit_university_info_form">   
+    <input type="hidden" name="_token" value="{{ csrf_token() }}" />
+    <input type="hidden" name="edit_id" value="{{$edit_data->id}}">
+    <input type="hidden" name="action" value="edit"> 
+    <div class="panel-body" style="padding:10px; background-color: #4b4c6824; border: 1px solid #e9e5e5; border-radius: 5px;">
+    
+        <div class="row">
+            <div class="col-md-4">
+                <div class="mb-2">
+                    <label class="form-label config">Destination</label>
+                    <div class="form-icon position-relative"> 
+                        <select name="country_id" id="country_id" class="form-control" required="" style="font-size: 13px;">
+                            <option value="" selected disabled>Select</option>
+                            @foreach($market_countries as $row)
+                                <option value="{{$row->country_id}}" @if($row->country_id==$edit_data->country_id) selected @endif>{{ cn($row, 'country.name','')}}</option>
+                            @endforeach
+                        </select>
+                    </div>
+                </div>
+            </div>
+            <div class="col-md-4">
+                <div class="mb-2">
+                    <label class="form-label config">University Name</label>
+                    <div class="form-icon position-relative">
+                        <input type="text" class="form-control" placeholder="University Name" id="university_name" name="university_name" value="{{$edit_data->name}}" required="" style="font-size: 13px;">
+                    </div>
+                </div>
+            </div>
+            <div class="col-md-4">
+                <div class="mb-2">
+                    <label class="form-label config">University Website</label>
+                    <div class="form-icon position-relative">
+                        <input type="text" class="form-control" placeholder="University Website" id="university_website" name="university_website" value="{{$edit_data->web_address}}" required="" style="font-size: 13px;">
+                    </div>
+                </div>
+            </div>
+        </div>  
+        <div class="row">
+            <div class="col-md-12">
+                <div class="text-end">
+                    <button type="button" class="btn cancel_button mr-1 btn-cancel close_form" >
+                        <i aria-hidden="true" class="fa fa-refresh"></i>
+                    </button>
+                    <button class="btn btn2" id="submit_uni">Update</button>                                                                                                                
+                </div>
+            </div> 
+        </div>  
+    </div>
+      
+</form>
+
+<script>
+    $(function(){
+        $('.edit_university_info_form').on('submit', function(event){
+                event.preventDefault();
+                var self = $(this); 
+                ajax_form(self, function(self){
+                    $('#country_wise_university').empty();
+                    fetch_sub_content(
+                        '#country_wise_university',
+                        "{{ route('sub-content', ['name'=>'country_wise_university']) }}"
+                    );  
+                });
+        });
+    });
+
+    $('.btn-cancel').on('click', function(){ 
+        $('.edit_data').addClass('d-none')
+    });
+</script>

+ 74 - 7
resources/views/admin/sub_contents/load_department.blade.php

@@ -1,23 +1,90 @@
 @extends('admin.sub_contents.base')  
 @section('main') 
 @foreach($departments as $row)
-<div class="mt-2" style="border-bottom: 1px solid #e8eef1;">
+<div class="mt-2 single_edit_item" style="border-bottom: 1px solid #e8eef1;">
 <div style="display: flex; margin-top:2px;">
     <div class="left" style="width: 80%;">
         <span class="title" style="font-size:11px;">{{$row->name}}</span>
     </div>
     <div class="right" style="width: 20%;">
-        <span class="title" style="font-size:11px; font-weight: 600;">
-            <a role="button" data-bs-toggle="collapse" data-bs-parent="#collapse" href="#collapse1" aria-expanded="true" aria-controls="collapse1">
-                <button type="button" class="btn btn2" data-toggle="collapse" data-target="#demo16" style="padding: 2px 5px !important; font-size: 11px;"><i class="fa fa-pencil"></i></button>
-            </a>
+        <span class="title" style="font-size:11px; font-weight: 600;"> 
+            <button type="button" class="btn btn2 edit_department" data-id="{{$row->id}}" style="padding: 2px 5px !important; font-size: 11px;"><i class="fa fa-pencil"></i></button>
+           
         </span>
         <span class="title" style="font-size:11px; font-weight: 600;">
-            <button type="button" class="btn btn2" style="padding: 2px 5px !important; font-size: 11px;"><i class="fa fa-trash"></i></button>
+            <button type="button" class="btn btn2 delete_department" data-id="{{$row->id}}" style="padding: 2px 5px !important; font-size: 11px;"><i class="fa fa-trash"></i></button>
         </span>
     </div>
 </div>      
 </div>      
 @endforeach  
  
-@endsection
+@endsection
+
+<script>
+    $(function(){
+        
+        var form_row_added=false;
+
+        $('.edit_department').on('click', function(){ 
+            if(form_row_added){ 
+                $('.open_department_info_div').remove();
+                form_row_added=false;
+            } 
+            var self=$(this);  
+            var self_tr=self.closest('.single_edit_item');
+
+            var dep_id=self.data('id');
+
+            form_row_added=true;
+
+            self_tr.after( 
+             "<div class='open_department_info_div'><div class='open_department_edit_info_div_inner'></div></div>"
+            );
+
+            fetch_sub_content(
+                '.open_department_edit_info_div_inner',
+                "{{ route('sub-content', ['name'=>'edit_department_form']) }}?dep_id="+dep_id
+            ); 
+             
+        });
+
+        $('.delete_department').on('click', function(){ 
+            var id = $(this).attr("data-id"); 
+            var form_data={
+                _token: "{{ csrf_token() }}",  
+                delete_id: id,
+            }  
+            swal({
+                title: "Are you sure?",
+                text: "You will not be able to recover this data!",
+                type: "warning",
+                showCancelButton: true,
+                confirmButtonClass: "btn-danger",
+                cancelButtonClass: "btn-info",
+                confirmButtonText: "Yes, delete!",
+                cancelButtonText: "No, cancel!",
+
+            }, function(isConfirm){
+
+                if(isConfirm){  
+                    $.post("{{ route('ajax-post', ['name'=>'delete_department_info']) }}",form_data
+                    ).done(function(res){
+
+                        pop_up_msg(res.msg);
+                        
+                        $('#load_department').empty();
+                        fetch_sub_content(
+                            '#load_department',
+                            "{{ route('sub-content', ['name'=>'load_department']) }}"
+                        );
+
+                    }).fail(function(err){ 
+                        pop_up_msg(err_msg(err), 'error'); 
+                    }); 
+                } 
+            }); 
+                        
+        });
+    });
+</script>