/
home
/
sjslayjy
/
public_html
/
assets
/
resources
/
views
/
circle-store
/
omc
/
Upload File
HOME
@extends('layout.master') @push('plugin-styles') <!-- {!! Html::style('/assets/plugins/plugin.css') !!} --> {!! Html::style('//cdn.datatables.net/1.10.23/css/jquery.dataTables.min.css') !!} @endpush @section('content') <div class="row"> <div class="col-lg-12 grid-margin"> <div class="card"> <div class="card-body"> <div class="row grid-margin"> <div style ="display:flex;" class="col-lg-8"> <h4 class="card-title">My OMC Requests</h4> <!--Button to open the popup form --> <button style="margin-left:150px;" id="openButton">Give Edit OMC/OMR Authorization</button> </div> <div class="col-lg-4"> <select class="form-control mr" onchange="get_omc_request_of_warehouse(this)"> @foreach($warehouses as $warehouse) <option value="{{$warehouse}}" {{ $current_warehouse == $warehouse ? 'selected' : ''}} >{{$warehouse}}</option> @endforeach </select> </div> </div> <div class="table-responsive" style="overflow-y:scroll; height: 650px;"> <table class="table table-striped myTable"> <thead> <tr> <th> MR No. </th> <th> PO No.</th> <th> Warehouse</th> <th> Request By</th> <th> Status </th> <th> Action </th> </tr> </thead> <tbody id="my_omc_request"> @foreach($omc_requests as $key => $omc_request) <tr> <td>{{$omc_request->mr_no}}</td> <td>{{$omc_request->po_no}}</td> <td>{{$omc_request->warehouse}}</td> <td>{{$omc_request->request_by}}</td> <td> @if ($omc_request->status == 'request') <span class="badge bg-warning">Requested</span> @elseif ($omc_request->status == 'authorize' || $omc_request->status == 'Authorized') <span class="badge bg-success">Authorized</span> @elseif ($omc_request->status == 'rejected' || $omc_request->status == 'reject') <span class="badge bg-danger">Rejected</span> @endif </td> <td> @if ($omc_request->edit_permission == 1 && $omc_request->status == 'request') <a class="btn btn-sm" style="background-color:#34E89E" href="{{url('circle-store/view-omcr/'.$omc_request->id)}}"><i class="fa fa-eye" style="font-size:15px"></i></a> <a class="btn btn-sm btn-primary" href="{{url('circle-store/edit-omc-requests/'.$omc_request->id)}}"><i class="fa fa-edit" style="font-size:15px"></i></a> <a class="btn btn-sm btn-danger" href="{{url('circle-store/revert-omc/'.$omc_request->id)}}"><i class="fa fa-undo" style="font-size:15px"></i></a> @else <a class="btn btn-sm" style="background-color:#34E89E" href="{{url('circle-store/view-omcr/'.$omc_request->id)}}"><i class="fa fa-eye" style="font-size:15px"></i></a> @endif </td> </tr> @endforeach </tbody> </table> </div> </div> </div> </div> </div> <!-- The popup form -----------------------------------------------------> <div class="popup" id="popup"> <span id="closeButton" onclick="closePopup()" style="border: 1px solid #ccc; width: 35px; height: 35px; margin: 0px 20px 0px 0px; text-align: center; padding: 0px 0px 35px 0px; border-radius:50%; background-color:#FFFFFF">×</span> <h4 class="stn">Edit OMC/OMR Authorization</h4> <div class="horizontal-line"></div> <!-- Horizontal line after the heading --> <form method="post" action="{{ url('circle-store/update-omc-permission') }}" onsubmit="return validateForm()"> @csrf <label for="stn_id">MR No:</label> <input type="text" name="mr_no" id="mr_no" placeholder="Enter OMR No."> <span class="text-danger">@error('mr_no'){{$message}}@enderror</span> <div class="checkbox-label"> <input type="checkbox" name="edit_permission" id="edit_permission" value="1"> <label for="edit_permission">Edit Permission:</label> <span class="text-danger">@error('edit_permission'){{$message}}@enderror</span> </div> <input type="submit" value="Submit"> </form> </form> </div> <!---------------------------------------------------------------------------> @endsection @push('plugin-scripts') {!! Html::script('/assets/plugins/chartjs/chart.min.js') !!} {!! Html::script('/assets/plugins/jquery-sparkline/jquery.sparkline.min.js') !!} @endpush @push('custom-scripts') {!! Html::script('/assets/js/dashboard.js') !!} {!! Html::script('//cdn.datatables.net/1.10.23/js/jquery.dataTables.min.js') !!} <script type="text/javascript"> $(document).ready( function () { var myTable = $('.myTable').dataTable(); } ); </script> <script type="text/javascript"> function get_omc_request_of_warehouse(t){ var warehouse = $(t).val(); if(warehouse != ""){ var url = window.location.origin + "/circle-store/get-omc-request-of-warehouse"; var data = { warehouse: warehouse, _token: "{{ csrf_token() }}" }; $('#loaderAction').show(); $.ajax({ type: "POST", url: url, data: data, success: function(res){ if(res.success == true){ var html = ""; $.each(res.omc_requests, function(k, val){ html += `<tr> <td>` + val.mr_no + `</td> <td>` + val.po_no + `</td> <td>` + val.warehouse + `</td> <td>` + val.request_by + `</td> <td><label class="badge badge-info">` + val.status + `</label></td> <td>`; if(val.edit_permission == 1 && val.status == 'request'){ html += `<a class="btn btn-sm" style="background-color:#34E89E" href="` + window.location.origin + `/circle-store/view-omcr/` + val.id + `"><i class="fa fa-eye" style="font-size:15px"></i></a> <a class="btn btn-sm btn-primary" href="` + window.location.origin + `/circle-store/edit-omc-requests/` + val.id + `"><i class="fa fa-edit" style="font-size:15px"></i></a> <a class="btn btn-sm btn-danger" href="` + window.location.origin + `/circle-store/revert-omc/` + val.id + `"><i class="fa fa-trash" style="font-size:15px"></i></a>`; } else { html += `<a class="btn btn-sm" style="background-color:#34E89E" href="` + window.location.origin + `/circle-store/view-omcr/` + val.id + `"><i class="fa fa-eye" style="font-size:15px"></i></a>`; } html += `</td></tr>`; }); $('#my_omc_request').html(html); } else { swal(res.msg, { icon: "error" }); } $('#loaderAction').hide(); }, error: function(error){ console.log(error); }, dataType: 'json' }); } } </script> <script> // Get references to the button and popup elements var openButton = document.getElementById("openButton"); var popup = document.getElementById("popup"); // Function to open the popup openButton.onclick = function () { popup.style.display = "block"; }; // Function to close the popup function closePopup() { popup.style.display = "none"; } </script> <script> // Check if the session variable indicates success var sweetAlertMessage = "{{ session('sweet_alert_success', '') }}"; // Display a SweetAlert with the appropriate message and icon if (sweetAlertMessage) { if (sweetAlertMessage.indexOf("Sorry") !== -1) { swal("Sorry!", sweetAlertMessage, "error"); } else { swal("Granted Permission Successfully!", sweetAlertMessage, "success"); } } </script> <script> function validateForm() { var mrNo = document.getElementById("mr_no").value; var editPermission = document.getElementById("edit_permission").checked; if (mrNo === "" || !editPermission) { Swal.fire({ icon: 'Error', title: 'Validation Error', text: 'Both STN no. & Edit Permission fields are required.', }); return false; // Prevent form submission } // If both fields are filled, continue with form submission return true; } </script> @endpush