Edit File: index.blade.php
@extends('admin.layout.master') @section('css') <link rel="stylesheet" type="text/css" href="{{asset('admin/app-assets/vendors/css/tables/datatable/datatables.min.css')}}"> <link rel="stylesheet" type="text/css" href="{{asset('admin/app-assets/vendors/css/tables/datatable/extensions/dataTables.checkboxes.css')}}"> <link rel="stylesheet" type="text/css" href="{{asset('admin/app-assets/css-rtl/pages/data-list-view.css')}}"> <link rel="stylesheet" type="text/css" href="{{asset('admin/app-assets/css-rtl/core/colors/palette-gradient.css')}}"> <link rel="stylesheet" type="text/css" href="{{asset('admin/app-assets/vendors/css/extensions/sweetalert2.min.css')}}"> @endsection @section('content') <x-admin.table filter="true" addbutton="{{route('admin.plans.create')}}" deletebutton="{{route('admin.plans.deleteAll')}}"> <x-slot name="tableHead"> <th> <label class="container-checkbox"> <input type="checkbox" value="value1" name="name1" id="checkedAll"> <span class="checkmark"></span> </label> </th> <th>{{awtTrans('التاريخ')}}</th> <th>{{awtTrans('اسم الباقه')}}</th> <th>{{awtTrans('المشاهدات المتوقعه')}}</th> <th>{{awtTrans('سعر الباقه')}}</th> <th>{{awtTrans(' اللوجو ')}}</th> <th>{{awtTrans(' عرض المشتركين ')}}</th> <th>{{awtTrans('التحكم')}}</th> </x-slot> <x-slot name="tableBody"> @foreach($rows as $row) <tr class="delete_row"> <td class="text-center"> <label class="container-checkbox"> <input type="checkbox" class="checkSingle" id="{{$row->id}}"> <span class="checkmark"></span> </label> </td> <td>{{\Carbon\Carbon::parse($row->created_at)->format('d/m/Y')}}</td> <td>{{$row->name?? ''}}</td> <td>{{$row->expected_views??''}}</td> <td>{{$row->price??''}}</td> <td><img src="{{$row->logoPath??''}}" width="50px" height="50px" /></td> <td><a href="{{route('admin.plans.subscription_show' , $row->id)}}"><i class="feather icon-eye"></i></a></td> <td class="product-action"> <span class="text-primary eye-show" ><a href="{{route('admin.plans.show' , ['id' => $row->id])}}"><i class="feather icon-eye"></i></a></span> <span class="action-edit text-primary" ><a href="{{route('admin.plans.edit' , ['id' => $row->id])}}"><i class="feather icon-edit"></i></a></span> <span class="delete-row text-danger" data-url="{{url('admin/plans/'.$row->id)}}"><i class="feather icon-trash"></i></span> </td> </tr> @endforeach </x-slot> </x-admin.table > {{-- #table --}} @endsection @section('js') <script src="{{asset('admin/app-assets/vendors/js/tables/datatable/datatables.min.js')}}"></script> <script src="{{asset('admin/app-assets/vendors/js/tables/datatable/datatables.buttons.min.js')}}"></script> <script src="{{asset('admin/app-assets/vendors/js/tables/datatable/pdfmake.min.js')}}"></script> <script src="{{asset('admin/app-assets/vendors/js/tables/datatable/buttons.html5.min.js')}}"></script> <script src="{{asset('admin/app-assets/vendors/js/tables/datatable/buttons.print.min.js')}}"></script> <script src="{{asset('admin/app-assets/vendors/js/tables/datatable/buttons.bootstrap.min.js')}}"></script> <script src="{{asset('admin/app-assets/vendors/js/tables/datatable/datatables.bootstrap4.min.js')}}"></script> <script src="{{asset('admin/datatable_custom.js')}}"></script> <script src="{{asset('admin/search.js')}}"></script> <script src="{{asset('admin/app-assets/vendors/js/extensions/sweetalert2.all.min.js')}}"></script> <script src="{{asset('admin/app-assets/js/scripts/extensions/sweet-alerts.js')}}"></script> {{-- delete all script --}} <!--@include('admin.shared.deleteAll')--> {{-- delete all script --}} {{-- delete one user script --}} <!--@include('admin.shared.deleteOne')--> <script> $(document).on('click' , '.delete-row', function (e) { e.preventDefault() Swal.fire({ title: "{{__('هل تريد الاستمرار ؟')}}", text: "{{__('هل انت متأكد انك تريد استكمال عملية الحذف')}}", type: 'warning', showCancelButton: true, confirmButtonColor: '#3085d6', cancelButtonColor: '#d33', confirmButtonText: '{{awtTrans("تأكيد")}}', confirmButtonClass: 'btn btn-primary', cancelButtonText: '{{awtTrans("الغاء")}}', cancelButtonClass: 'btn btn-danger ml-1', buttonsStyling: false, }).then( (result) => { if (result.value) { $.ajax({ type: "delete", url: $(this).data('url'), data: {}, dataType: "json", success: (response) => { if(response.key == 'success'){ Swal.fire( { position: 'top-start', type: 'success', title: '{{awtTrans('تم الحذف بنجاح')}}', showConfirmButton: false, timer: 1500, confirmButtonClass: 'btn btn-primary', buttonsStyling: false, }) // toastr.error() $('.data-list-view').DataTable().row($(this).closest('td').parent('tr')).remove().draw(); } else { Swal.fire( { position: 'top-start', type: 'error', title: '{{awtTrans('لا نستطيع الحذف لأنه يوجد مشتركون في الباقه')}}', showConfirmButton: false, timer: 1500, confirmButtonClass: 'btn btn-primary', buttonsStyling: false, }) } } }); } }) }); </script> {{-- delete one user script --}} <script> $('.delete_all_button').hide() $(document).on('change','#checkedAll',function(){ if(this.checked){ // setTimeout(function (){ $(".checkSingle").each(function(index, element){ this.checked = true; $('.delete_all_button').show() }) // },500); }else{ $(".checkSingle").each(function(){ this.checked=false; $('.delete_all_button').hide() }) } }); $(document).on('click','.checkSingle',function () { if ($(this).is(":checked")){ var isAllChecked = 0; $(".checkSingle").each(function(){ if(!this.checked) isAllChecked = 1; }) if(isAllChecked == 0){ $("#checkedAll").prop("checked", true); } $('.delete_all_button').show() }else { var count = 0; $(".checkSingle").each(function(){ if(this.checked) count ++; }) if (count > 0 ) { $('.delete_all_button').show() }else{ $('.delete_all_button').hide() } $("#checkedAll").prop("checked", false); } }); $('.delete_all_button').on('click', function (e) { e.preventDefault() Swal.fire({ title: "{{__('هل تريد الاستمرار ؟')}}", text: "{{__('هل انت متأكد انك تريد استكمال عملية حذف المحدد')}}", type: 'warning', showCancelButton: true, confirmButtonColor: '#3085d6', cancelButtonColor: '#d33', confirmButtonText: '{{awtTrans("تأكيد")}}', confirmButtonClass: 'btn btn-primary', cancelButtonText: '{{awtTrans("الغاء")}}', cancelButtonClass: 'btn btn-danger ml-1', buttonsStyling: false, }).then( (result) => { if (result.value) { var usersIds = []; $('.checkSingle:checked').each(function () { var id = $(this).attr('id'); usersIds.push({ id: id, }); }); var requestData = JSON.stringify(usersIds); if (usersIds.length > 0) { e.preventDefault(); $.ajax({ type: "POST", url: $(this).data('route'), data: {data : requestData}, success: function( msg ) { if (msg == 'success') { $('.delete_all_button').hide() Swal.fire( { position: 'top-start', type: 'success', title: '{{awtTrans('تم حذف المحدد بنجاح')}}', showConfirmButton: false, timer: 1500, confirmButtonClass: 'btn btn-primary', buttonsStyling: false, }) $('.checkSingle:checked').each(function () { $('.data-list-view').DataTable().row($(this).closest('td').parent('tr')).remove().draw(); }); } else { Swal.fire( { position: 'top-start', type: 'error', title: '{{awtTrans('لا نستطيع الحذف لأنه يوجد مشتركون في الباقه')}}', showConfirmButton: false, timer: 1500, confirmButtonClass: 'btn btn-primary', buttonsStyling: false, }) } } }); } } }) }); </script> @endsection
Back to File Manager