load_department.blade.php 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. @extends('admin.sub_contents.base')
  2. @section('main')
  3. @foreach($departments as $row)
  4. <div class="mt-2 single_edit_item" style="border-bottom: 1px solid #e8eef1;">
  5. <div style="display: flex; margin-top:2px;">
  6. <div class="left" style="width: 80%;">
  7. <span class="title" style="font-size:11px;">{{$row->name}}</span>
  8. </div>
  9. <div class="right" style="width: 20%;">
  10. <span class="title" style="font-size:11px; font-weight: 600;">
  11. <button type="button" class="btn btn2 edit_department mb-1" data-id="{{$row->id}}" style="padding: 2px 5px !important; font-size: 11px;"><i class="fa fa-pencil"></i></button>
  12. </span>
  13. <span class="title" style="font-size:11px; font-weight: 600;">
  14. <button type="button" class="btn btn2 delete_department mb-1" data-id="{{$row->id}}" style="padding: 2px 5px !important; font-size: 11px;"><i class="fa fa-trash" style="margin-left:2px;"></i></button>
  15. </span>
  16. </div>
  17. </div>
  18. </div>
  19. @endforeach
  20. @endsection
  21. <script>
  22. $(function(){
  23. var form_row_added=false;
  24. $('.edit_department').on('click', function(){
  25. if(form_row_added){
  26. $('.open_department_info_div').remove();
  27. form_row_added=false;
  28. }
  29. var self=$(this);
  30. var self_tr=self.closest('.single_edit_item');
  31. var dep_id=self.data('id');
  32. form_row_added=true;
  33. self_tr.after(
  34. "<div class='open_department_info_div'><div class='open_department_edit_info_div_inner'></div></div>"
  35. );
  36. fetch_sub_content(
  37. '.open_department_edit_info_div_inner',
  38. "{{ route('sub-content', ['name'=>'edit_department_form']) }}?dep_id="+dep_id
  39. );
  40. });
  41. $('.delete_department').on('click', function(){
  42. var id = $(this).attr("data-id");
  43. var form_data={
  44. _token: "{{ csrf_token() }}",
  45. delete_id: id,
  46. }
  47. swal({
  48. title: "Are you sure?",
  49. text: "You will not be able to recover this data!",
  50. type: "warning",
  51. showCancelButton: true,
  52. confirmButtonClass: "btn-danger",
  53. cancelButtonClass: "btn-info",
  54. confirmButtonText: "Yes, delete!",
  55. cancelButtonText: "No, cancel!",
  56. }, function(isConfirm){
  57. if(isConfirm){
  58. $.post("{{ route('ajax-post', ['name'=>'delete_department_info']) }}",form_data
  59. ).done(function(res){
  60. pop_up_msg(res.msg);
  61. $('#load_department').empty();
  62. fetch_sub_content(
  63. '#load_department',
  64. "{{ route('sub-content', ['name'=>'load_department']) }}"
  65. );
  66. }).fail(function(err){
  67. pop_up_msg(err_msg(err), 'error');
  68. });
  69. }
  70. });
  71. });
  72. });
  73. </script>