/
home
/
sjslayjy
/
public_html
/
cropnet
/
resources
/
views
/
admin
/
master
/
Upload File
HOME
@extends('admin.layouts.app') @section('title','MCC') @section('style') <meta name="csrf-token" content="{{ csrf_token() }}"> {{-- {{Html::style("assets/css/bootstrap-datepicker3.min.css")}} --}} @endsection @section('content') <!-- Content Wrapper. Contains page content --> <div class="content-wrapper"> <div class="container-full"> <!-- Header Dynamic --> <div class="content-header"> <div class="d-flex align-items-center"> <div class="me-auto"> <h4 class="page-title">Master</h4> <div class="d-inline-block align-items-center"> <nav> <ol class="breadcrumb"> <li class="breadcrumb-item"><a href="#"><i class="fa fa-home"></i></a></li> <li class="breadcrumb-item active" aria-current="page">MCC</li> </ol> </nav> </div> </div> </div> </div> <!-- End Header Dynamic --> <!-- Main content --> <section class="content"> <div class="row"> <div class="col-12"> <div class="box"> <div class="box-header with-border"> <div class="clearfix"> <div class="row"> <div class="col-sm-6"> <a href="{{url('/admin/download-mcc-format')}}" class="btn btn-sm btn-default pull-left">Download Format</a> </div> <div class="col-sm-6"> <button type="button" class="btn-sm waves-effect waves-light md-5 btn bg-gradient-success pull-right" data-bs-toggle="modal" data-bs-target="#importMccModal">Import</button> </div> </div> </div> </div> <!-- /.box-header --> <!-- /.box-header --> <div class="box-body"> <div class="table-responsive"> <table id="dynamic-table" class="table table-bordered table-hover display nowrap margin-top-10 w-p100 text-center"> <thead> <tr> <th style="text-align: center;">S.N.</th> <th style="text-align: center;">MCC Code</th> <th style="text-align: center;">MCC Name</th> <th style="text-align: center;">Status</th> <th style="text-align: center;">Action</th> </tr> </thead> <tbody> @php $sr=1; @endphp @foreach($mccs as $mcc) <tr> <td>{{$sr}}</td> <td>{{$mcc->code}}</td> <td>{{$mcc->name}}</td> <td>@if($mcc->is_active==1)<span class="badge badge-success">Active</span>@else <span class="badge badge-danger">Inactive</span>@endif</td> <td><a class="btn btn-xs btn-primary" onclick="getEdit({{$mcc->id}})" title="Edit"><i class="ace-icon fa fa-edit bigger-120" ></i></a> <a class="btn btn-xs btn-danger" onclick="deleteMcc({{$mcc->id}})" title="Delete"><i class="ace-icon fa fa-trash bigger-120" ></i></a></td> </tr> @php $sr++@endphp @endforeach </tbody> <tfoot> </tfoot> </table> </div> </div> <!-- /.box-body --> <!-- /.box-body --> </div> <!-- /.box --> </div> </div> </section> <!-- /.content --> </div> </div> <!--- import modal start--> <div id="importMccModal" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true"> <div class="modal-dialog"> <div class="modal-content"> <div class="modal-header"> <h4 class="modal-title" id="myModalLabel">Import Mcc</h4> <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button> </div> <div class="modal-body"> <form action="{{url('/admin/import-mcc')}}" role="form" id="importMccForm" method="POST" enctype="multipart/form-data" > {{csrf_field()}} <div class="row"> <div class="col-md-12"> <div class="form-group"> <label class="form-label" for="import_mcc_file">File</label> <input type="file" class="form-control" name="import_mcc_file" id="import_mcc_file"> <span class="label label-danger" id="import_mcc_file_error" style="display: none;"></span> </div> </div> </div> </div> <!-- /.box-body --> <div class="box-footer text-end"> <button type="button" class="btn btn-danger me-1" data-bs-dismiss="modal"> <i class="ti-trash"></i> Cancel </button> <button id="importMccBtn" type="button" class="btn btn-success"> <i class="ti-save-alt"></i> Save </button> </div> </form> </div> <!-- /.box --> </div> </div> <!-- /.modal-content --> </div> <!--- import modal end--> <!-- /edit modal --> <div id="editMccModal" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true"> <div class="modal-dialog modal-sm"> <div class="modal-content"> <div class="modal-header"> <h4 class="modal-title" id="myModalLabel">Edit Mcc</h4> <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button> </div> <div class="modal-body" id="EditBody"> </div> <!--<div class="modal-footer">--> <!-- <button type="button" class="btn btn-danger" data-bs-dismiss="modal">Close</button>--> <!--</div>--> </div> <!-- /.modal-content --> </div> <!-- /.modal-dialog --> </div> <!-- /edit modal --> @endsection @section('script') {{-- <script src="{{asset("src/js/pages/patients.js")}}"></script> --}} <script src="../src/js/pages/validation.js"></script> <script src="../src/js/pages/form-validation.js"></script> <script> $(document).ready(function() { $("#importMccBtn").click(function(e){ e.preventDefault(); $.ajaxSetup({ headers : { 'X_CSRF_TOKEN' : $("meta[name='_token']").attr('content') } }); var form_data = new FormData(document.getElementById("importMccForm")); $.ajax({ url : $('#importMccForm').attr('action'), type : 'POST', data : form_data, cache:false, contentType: false, processData: false, success : function(data){ if(!data.flag){ showError('import_mcc_file_error', data.errors.import_mcc_file); }else{ Swal.fire({ title: "Success!", text: data.message, icon: 'success', }).then(function() { window.location.reload(); }); } } }); }); }); function showError(id, error) { if (typeof(error) === "undefined") { $('#' + id).hide(); } else { $('#' + id).show(); $('#' + id).text(error); } } function getEdit(id) { if (id == "") { Swal.fire('Error', 'Mcc id is missing', 'warning'); } else { $.ajax({ url: "{{url('/admin/edit-mcc')}}" + "/" + id, type: 'GET', success: function(data) { $('#EditBody').html(data); $('#editMccModal').modal('toggle'); } }); } } function updateMcc() { $.ajaxSetup({ headers: { 'X-CSRF-TOKEN': $('meta[name="_token"]').attr('content') } }); var url=$('#editMccForm').attr('action'); var form_data = new FormData(document.getElementById("editMccForm")); $.ajax({ url: url, method: 'POST', data: form_data, cache:false, contentType: false, processData: false, success: function(data) { console.log(data); if (!data.flag) { showError('add_name_error', data.errors.name); showError('add_code_error', data.errors.code); } else { Swal.fire({ title: "Success!", text: data.message, icon: "success" }).then(function() { window.location.reload(); }); } } }); } function deleteMcc(id){ if(id == ""){ swal('Error','Mcc id is missing','warning'); }else{ swal({ title: "Are you sure?", text: "You will not be able to recover this imaginary file!", type: "warning", showCancelButton: true, confirmButtonColor: "#DD6B55", confirmButtonText: "Yes, delete it!", closeOnConfirm: false }).then(function() { $.ajax({ url: "{{url('/admin/delete-mcc/')}}"+"/"+id, type: 'GET', success:function(data){ if(data.flag){ // $('#tr_'+id).remove(); Swal.fire({ title: "Success!", text: data.message, icon: "success" }).then(function() { window.location.reload(); }); }else{ swal("Error", data.message, "error"); } } }); }); } } </script> @endsection