/
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') !!} --> @endpush @section('content') <form action="{{ url('/circle-store/update-omc') }}" method="POST"> @csrf <input type="hidden" name="id" value="{{$get_omc->id}}"> <div class="row"> <div class="col-lg-12 grid-margin"> <div class="card"> <div class="card-body"> <!-- <p style="background-color:rgba(255,0,0,0.3); text-align:center; height:30px; font-weight:bold; display:flex; justify-content:center; align-items:center;"> This section for editing OMC/MR is currently under development. Please refrain from using this feature until further notice! </p> --> <h3 class="card-title">Edit Onetime Material Consumption Request (OMCR)</h3> <div class="row"> <div class="col-lg-3"> <small>Ware House<span class="text-danger">*</span></small> <select class="form-control mr" name="warehouse" id="warehouse" @if($userInfo->warehouseCode != 'SERPNT') onchange="get_ware_house(this)" @endif> <option value=""> -- Select Warehouse --</option> @foreach($assigned_warehouses as $assigned_warehouse) <option value="{{$assigned_warehouse}}">{{$assigned_warehouse}}</option> @endforeach <!-- <option value="Scrap Zone">Scrap Zone</option> --> </select> </div> <div class="col-lg-3"> <small>Customer Code and Name<span class="text-danger">*</span></small> <select onchange="getCustomerCodeInfo(this)" name="customer_code_and_name" class="form-control select2 mr" id="customer_code_and_name"> <option value="">Select Customer Code</option> @foreach($customers as $customer) <option value="{{$customer->Cust_Code}} -- {{$customer->Cust_Name}}">{{$customer->Cust_Code}} -- {{$customer->Cust_Name}}</option> @endforeach </select> </div> <div class="col-lg-3"> <small>Customer PO Number<span class="text-danger">*</span></small> <input type="text" id="customer_po" name="customer-po" onkeyup="get_cutomer_po(this)" class="form-control" value="{{$all_omc['po_no']}}" /> </div> <div class="col-lg-3"> <small>Customer PO Date</small> <input type="date" id="cutomer_po_date" name="customer-po-date" onchange="get_cutomer_po_date(this)" class="form-control" value="{{$all_omc['cutomer_po_date']}}" /> </div> </div> <div class="row"> <div class="col-lg-3"> <small>Invoice No</small> <input type="text" id="invoice_no" name="invoice_no-po" onkeyup="get_invoice_no(this)" class="form-control" value="{{$all_omc['invoice_no']}}" /> </div> <div class="col-lg-3"> <small>Invoice Date</small> <input type="date" id="invoice_date" name="invoice_date" onchange="get_invoice_date(this)" class="form-control" value="{{$all_omc['invoice_date']}}" /> </div> <div class="col-lg-3"> <small>Invoice Basic Value</small> <input type="text" id="invoice_basic_value" name="invoice_basic_value" onkeyup="get_invoice_basic_value(this)" class="form-control" value="{{$all_omc['invoice_basic_value']}}" /> </div> <div class="col-lg-3"> <small>Site ID</small> <input type="text" id="site_id" name="site_id" onkeyup="get_site_id(this)" class="form-control" value="{{$all_omc['site_id']}}" /> </div> </div> <div class="row"> <div class="col-lg-3"> <small>Site Name</small> <input type="text" id="site_name" name="site_name" onkeyup="get_site_name(this)" class="form-control" value="{{$all_omc['site_name']}}" /> </div> <div class="col-lg-3"> <small>Complaint Closure Date</small> <input type="date" id="complaint_closure_date" name="complaint_closure_date" onchange="get_complaint_closure_date(this)" class="form-control" value="{{$all_omc['complaint_closure_date']}}" /> </div> <div class="col-lg-3"> <small>Customer Open PO Status</small> <select class="form-control mr" id="cust_open_po_status" onchange="get_cust_open_po_status(this)" name="cust_open_po_status"> <option value="">Select Status</option> <option value="open" {{ $all_omc['cust_open_po_status'] == 'open' ? 'selected' : '' }}>Open</option> <option value="closed" {{ $all_omc['cust_open_po_status'] == 'closed' ? 'selected' : '' }}>Closed</option> </select> </div> <div class="col-lg-3"> <small>Open PO Amount</small> <div class="input-group"> <span class="input-group-text px-3 py-1 bg-light border border-secondary">₹</span> <input type="text" id="open_po_amount" name="open_po_amount" oninput="formatIndianCurrency(this)" class="form-control border border-secondary" onchange="get_open_po_amount(this)" value="{{$all_omc['open_po_amount']}}"> </div> </div> </div> <div class="row"> <div class="col-lg-3"> <small>Invoice Value</small> <input type="number" id="invoice_value" name="invoice_value" onkeyup="get_invoice_value(this)" class="form-control" onchange="get_invoice_value" value="{{$all_omc['invoice_value']}}"/> </div> <div class="col-lg-3"> <small>OMC Type<span class="text-danger">*</span></small> <select class="form-control mr" name="omc_type" onchange="get_omc_type(this)"> <option value="">-- Select OMC Type--</option> @foreach ($omc_types as $omc_type) <option value="{{ $omc_type->omc_names }}" {{ old('omc_type') == $omc_type->omc_names ? 'selected' : '' }}> {{ $omc_type->omc_names == 'pt' ? 'PT' : ($omc_type->omc_names == 'amc' ? 'AMC' : $omc_type->omc_names)}} </option> @endforeach </select> </div> <div class="col-lg-3"> <small>Select Stock<span class="text-danger">*</span></small> <select class="form-control mr" name="stock_type" id="stock_type" onchange="get_stock_type(this)"> <option value="">Select Stock</option> <option value="circle_stock">Circle Stock</option> <option value="pt_stock">PT Stock</option> </select> </div> </div> </div> </div> </div> <div class="col-lg-12 grid-margin"> <div class="card"> <div class="card-body"> <div class="row grid-margin"> <div class="col-lg-4"> <h4 class="card-title">Spare Parts List</h4> </div> </div> <div class="table-responsive"> <table class="table table-striped table-bordered"> <thead> <tr> <th style="width: 141px;"> Item Code</th> <th style="width: 441px;"> Description</th> <th style="width: 69px;"> UOM</th> <th style="width: 0px;margin-right: -30px;"> Category</th> <th style="width: 127px;"> Fresh Qty</th> <th> Repaired Qty</th> <th> --- </th> </tr> </thead> <tbody id="tbody"> <p id="error" style="color:red;"></p> </tbody> </table> <table class="table table-striped table-bordered"> <tbody id="tbody"> @foreach($get_omc_items as $get_omc_item) <tr class="row" data-id="{{ $get_omc_item->id }}"> <td class="font-weight-medium" style="width:153px;">{{ $get_omc_item->spare_code }}</td> <td style="width:442px;">{{ $get_omc_item->spare_description }}</td> <td style="width:68px;">{{ $get_omc_item->spare_uom }}</td> <td style="width:89px;">{{ $get_omc_item->spare_category ?? 'NULL' }}</td> <td style="width:127px;"> <input type="text" name="qty" onkeyup="calculate(this,{{ $get_omc_item->id }})" onblur="is_blank(this)" style="width: 80px;" value="{{ $get_omc_item->fresh_qty }}"> </td> <td style="width:134px;"> <input type="text" name="rqty" onkeyup="rcalculate(this,{{ $get_omc_item->id }})" onblur="is_blank(this)" style="width: 80px;" value="{{ $get_omc_item->repaired_qty }}"> </td> <td style="width:55px;"> <a href="#" onclick="removeItem(this)"><i class="mdi mdi-delete-forever"></i></a> </td> </tr> @endforeach </tbody> </table> <div id="loaderAction"> <div class="loader"></div> </div> </div> </div> </div> </div> <div class="col-lg-12 grid-margin"> <div class="card"> <div class="card-body"> <div class="row"> <div class="col-lg-9"> </div> <div class="col-lg-3"><button style="margin-left:150px;" type="button" id="placeOmc" onclick="update_now()" class="btn btn-warning btn-fw">Update Now</button></div> </div> </div> </div> </div> </div> </form> @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') !!} <script type="text/javascript"> function init_cart() { var omcRequest = {}; omcRequest.items = []; omcRequest.customer_po = ""; omcRequest.warehouse = "{{$current_warehouse}}"; omcRequest.customer_code_and_name = ""; omcRequest.cutomer_po_date = ""; omcRequest.invoice_no = ""; omcRequest.invoice_date = ""; omcRequest.invoice_basic_value = ""; omcRequest.site_id = ""; omcRequest.site_name = ""; omcRequest.complaint_closure_date = ""; omcRequest.cust_open_po_status = ""; omcRequest.open_po_amount = ""; omcRequest.invoice_value = ""; omcRequest.stock_type = ""; localStorage.setItem('omcRequest', JSON.stringify(omcRequest)); //-----------------------------Defining our localstorage------------ var editOmc = {}; editOmc.id = ''; editOmc.items = []; editOmc.customer_code_and_name = ''; editOmc.cutomer_po_date = ''; editOmc.invoice_no = ''; editOmc.invoice_date = ''; editOmc.invoice_basic_value = ''; editOmc.site_id = ''; editOmc.site_name = ''; editOmc.complaint_closure_date = ''; editOmc.cust_open_po_status = ''; editOmc.open_po_amount = ''; editOmc.invoice_value = ''; localStorage.setItem('editOmc', JSON.stringify(editOmc)); } //-----Getting the value sent from backend & assignning them in a variable-- function edit_omc() { var spare_part = @json($get_omc_items); var id = @json($id); console.log("id is " + id); var customer_code_and_name = @json($get_omc->customer_code_and_name); var cutomer_po_date = @json($get_omc->cutomer_po_date); var invoice_no = @json($get_omc->invoice_no); var invoice_date = @json($get_omc->invoice_date); var invoice_basic_value = @json($get_omc->invoice_basic_value); var site_id = @json($get_omc->site_id); var site_name = @json($get_omc->site_name); var complaint_closure_date = @json($get_omc->complaint_closure_date); var cust_open_po_status = @json($get_omc->cust_open_po_status); var open_po_amount = @json($get_omc->open_po_amount); var invoice_value = @json($get_omc->invoice_value); var is_added = false; var editOmc = JSON.parse(localStorage.getItem('editOmc')); console.log('Edit Omc is', editOmc); editOmc.id = id; editOmc.customer_code_and_name = customer_code_and_name; editOmc.cutomer_po_date = cutomer_po_date; editOmc.invoice_no = invoice_no; editOmc.invoice_date = invoice_date; editOmc.invoice_basic_value = invoice_basic_value; editOmc.site_id = site_id; editOmc.site_name = site_name; editOmc.complaint_closure_date = complaint_closure_date; editOmc.cust_open_po_status = cust_open_po_status; editOmc.open_po_amount = open_po_amount; editOmc.invoice_value = invoice_value; if (localStorage.getItem('editOmc') != null) { $.each(editOmc.items, function (key, val) { if (parseInt(val.id) == spare_part.id) { is_added = true; } }); } if (is_added == false) { var sparts = spare_part; $.each(sparts, function (key, val) { val.qty = val.fresh_qty; val.rqty = val.repaired_qty; editOmc.items.push(val); }); } else { console.log("is added"); } //--------Setting them into the localStorage----------------------- localStorage.setItem('editOmc', JSON.stringify(editOmc)); } init_cart(); edit_omc(); // function addselectedItem(){ // var code = $('#spareCode').val(); // var warehouse = $('#warehouse').val(); // var stock_type = $('#stock_type').val(); // if(code != "" && warehouse !="" && stock_type !=""){ // var url = window.location.origin+"/circle-store/get-spare-part-from-pt-stock" // var data = {}; // data.code = code; // data.warehouse = warehouse; // data.stock_type = stock_type; // data._token = "{{ csrf_token() }}"; // $('#loaderAction').show(); // $.ajax({ // type: "POST", // url: url, // data: data, // success:function(res){ // if(res.success == true){ // $('#warehouse').attr('disabled',true); // var spare_part = res.spare_part; // var omcRequest = JSON.parse(localStorage.getItem('omcRequest')); // omcRequest.warehouse = warehouse; // var is_added = false; // $.each(omcRequest.items,function(key,val){ // if(parseInt(val.id) == spare_part.id){ // is_added = true; // } // }); // if(is_added == false){ // var sparts = spare_part; // var pt_sock = res.pt_sock; // sparts.qty = pt_sock.fresh_qty; // sparts.rqty = pt_sock.repaired_qty; // omcRequest.items.push(spare_part); // if(sparts.qty == 0 && sparts.rqty == 0){ // swal('Spare not in stock.', { icon: "error", }); // }else{ // omcRequest.items.push(spare_part); // } // }else{ // console.log("is added"); // } // localStorage.setItem('omcRequest',JSON.stringify(omcRequest)); // showSelectedItems(); // }else{ // swal(res.msg, { icon: "error", }); // } // $('#loaderAction').hide(); // }, // error:function(error){ // console.log(error); // }, // dataType: 'json' // }); // }else{ // swal("Please Enter Spare Code in Textbox and Select Warehouse !", { icon: "error", }); // } // } function showSelectedItems() { var omcRequest = JSON.parse(localStorage.getItem('omcRequest')); console.log('Show Selected Item is', omcRequest); var html = ''; var n = 0; $.each(omcRequest.items, function (key, spare_part) { html += `<tr class="row_` + spare_part.id + `"> <td class="font-weight-medium">`+ spare_part.code + `</td> <td>`+ spare_part.description + `</td> <td>`+ spare_part.uom + `</td> <td>`+ spare_part.category + `</td>`; if (spare_part.qty == 0) { html += `<td><input type="text" name="qty" onkeyup="calculate(this,` + spare_part.id + `)" onblur="is_blank(this)" style="width: 80px;" value="` + spare_part.qty + `" disabled/></td>`; } else { html += `<td><input type="text" name="qty" onkeyup="calculate(this,` + spare_part.id + `)" style="width: 80px;" onblur="is_blank(this)" value="` + spare_part.qty + `"/></td>`; } if (spare_part.rqty == 0) { html += `<td><input type="text" name="qty" onkeyup="rcalculate(this,` + spare_part.id + `)" style="width: 80px;" value="` + spare_part.rqty + `" disabled/></td>`; } else { html += `<td><input type="text" name="qty" onkeyup="rcalculate(this,` + spare_part.id + `)" style="width: 80px;" value="` + spare_part.rqty + `"/></td>`; } html += `<td><a href="#" onclick="removeItem(` + spare_part.id + `)"><i class="mdi mdi-delete-forever"></i></a></td> </tr>`; }); $('#tbody').html(html); } function get_stock_type(t) { var editOmc = JSON.parse(localStorage.getItem('editOmc')); editOmc.stock_type = $(t).val(); localStorage.setItem('editOmc', JSON.stringify(editOmc)); } function get_cutomer_po(t) { var editOmc = JSON.parse(localStorage.getItem('editOmc')); editOmc.customer_po = $(t).val(); localStorage.setItem('editOmc', JSON.stringify(editOmc)); } function get_invoice_date(t) { var editOmc = JSON.parse(localStorage.getItem('editOmc')); editOmc.invoice_date = $(t).val(); localStorage.setItem('editOmc', JSON.stringify(editOmc)); } function get_invoice_basic_value(t) { var editOmc = JSON.parse(localStorage.getItem('editOmc')); editOmc.invoice_basic_value = $(t).val(); localStorage.setItem('editOmc', JSON.stringify(editOmc)); } function get_site_id(t) { var editOmc = JSON.parse(localStorage.getItem('editOmc')); editOmc.site_id = $(t).val(); localStorage.setItem('editOmc', JSON.stringify(editOmc)); } function get_site_name(t) { var editOmc = JSON.parse(localStorage.getItem('editOmc')); editOmc.site_name = $(t).val(); localStorage.setItem('editOmc', JSON.stringify(editOmc)); } function get_complaint_closure_date(t){ var editOmc = JSON.parse(localStorage.getItem('editOmc')); editOmc.complaint_closure_date = $(t).val(); localStorage.setItem('editOmc',JSON.stringify(editOmc)); } function get_cust_open_po_status(t){ var editOmc = JSON.parse(localStorage.getItem('editOmc')); editOmc.cust_open_po_status = $(t).val(); localStorage.setItem('editOmc',JSON.stringify(editOmc)); } function get_open_po_amount(t){ var editOmc = JSON.parse(localStorage.getItem('editOmc')); editOmc.open_po_amount = $(t).val(); localStorage.setItem('editOmc',JSON.stringify(editOmc)); } function get_invoice_value(t){ var editOmc = JSON.parse(localStorage.getItem('editOmc')); editOmc.invoice_value = $(t).val(); localStorage.setItem('editOmc',JSON.stringify(editOmc)); } function get_ware_house(t) { var editOmc = JSON.parse(localStorage.getItem('editOmc')); editOmc.warehouse = $(t).val(); localStorage.setItem('editOmc', JSON.stringify(editOmc)); console.log("OMC warehouse is", editOmc.warehouse); if (editOmc.warehouse != "") { var url = window.location.origin + "/circle-store/get-customers-of-warehouse"; var data = {}; data.warehouse = editOmc.warehouse; data._token = "{{ csrf_token() }}"; $('#loaderAction').show(); $.ajax({ type: "POST", url: url, data: data, success: function (res) { if (res.success == true) { var html = '<option value="">-- Select Customer -- </option>'; $.each(res.customers, function (key, val) { html += `<option value="` + val.Cust_Code + ` -- ` + val.Cust_Name + `">` + val.Cust_Code + ` -- ` + val.Cust_Name + `</option>`; }); $('#customer_code_and_name').html(html); } $('#loaderAction').hide(); }, error: function (error) { console.log(error); }, dataType: 'json' }); } } function getCustomerCodeInfo(t) { var editOmc = JSON.parse(localStorage.getItem('editOmc')); editOmc.customer_code_and_name = $(t).val(); localStorage.setItem('editOmc', JSON.stringify(editOmc)); } function get_omc_type(t) { var editOmc = JSON.parse(localStorage.getItem('editOmc')); editOmc.omc_type = $(t).val(); localStorage.setItem('editOmc', JSON.stringify(editOmc)); } function get_cutomer_po_date(t) { var editOmc = JSON.parse(localStorage.getItem('editOmc')); editOmc.cutomer_po_date = $(t).val(); localStorage.setItem('editOmc', JSON.stringify(editOmc)); } function get_invoice_no(t) { var editOmc = JSON.parse(localStorage.getItem('editOmc')); editOmc.invoice_no = $(t).val(); localStorage.setItem('editOmc', JSON.stringify(editOmc)); } function removeItem(link) { // Get the row element var row = link.closest('tr'); // Find the closest row to the clicked link var itemId = row.getAttribute('data-id'); // Get the ID from data attribute // Debugging console.log("My Delete Item id is", itemId); if (!itemId) { console.error("Item ID is undefined. Check the data-id attribute in the row."); return; // Exit if the ID is not found } // Remove the row from the DOM row.remove(); // Debugging console.log("Row with id", itemId, "has been removed from the DOM."); // Optional: Manage localStorage if needed var editOmc = JSON.parse(localStorage.getItem('editOmc')); if (editOmc && editOmc.items) { // Find the item index to remove from localStorage var items = editOmc.items; var indexToRemove = items.findIndex(item => item.id == itemId); if (indexToRemove !== -1) { // Remove the item from localStorage items.splice(indexToRemove, 1); console.log("Item with id", itemId, "has been removed from localStorage."); // Update localStorage editOmc.items = items; localStorage.setItem('editOmc', JSON.stringify(editOmc)); } else { console.error("Item with id", itemId, "not found in localStorage items."); } } else { console.error("No items found in localStorage or 'editOmc' not found."); } } // function calculate(t,id,code){ // var qty = $(t).val(); // if(qty != "" && qty != null){ // var qty = parseInt(qty); // addCartValueInKey(id,'qty',qty); // }else{ // addCartValueInKey(id,'qty',0); // } // } function calculate(t, id) { var qty = $(t).val(); if (qty != "" && qty != null) { var qty = parseFloat(qty); addCartValueInKey(id, 'qty', qty); } else { addCartValueInKey(id, 'qty', 0); } } // function rcalculate(t,id,code){ // var rqty = $(t).val(); // if(rqty != "" && rqty != null){ // var rqty = parseInt(rqty); // addCartValueInKey(id,'rqty',rqty); // }else{ // addCartValueInKey(id,'rqty',0); // } // } function rcalculate(t, id) { var rqty = $(t).val(); if (rqty != "" && rqty != null) { var rqty = parseFloat(rqty); addCartValueInKey(id, 'rqty', rqty); } else { addCartValueInKey(id, 'rqty', 0); } } function is_blank(t) { if ($(t).val() == "") { $(t).val(0); calculate(); rcalculate(); } } function validate_qty(params) { var url = window.location.origin + "/circle-store/validate-omc-req-qty"; var data = { "_token": "{{ csrf_token() }}", "code": params.code, "qty": params.qty, "type": params.type, "warehouse": params.warehouse } $.ajax({ url: url, type: 'post', data: data, dataType: 'json', success: function (res) { if (res.success == false) { $('#' + res.type).val('0'); $('#error').html(res.msg); addCartValueInKey(params.id, params.type1, 0); } else { $('#error').html(''); addCartValueInKey(params.id, params.type1, params.qty); } } }); } function addCartValueInKey(id, key, value) { var editOmc = JSON.parse(localStorage.getItem('editOmc')); $.each(editOmc.items, function (k, val) { if (parseInt(val.id) == id) { editOmc.items[k][key] = value; } }); localStorage.setItem('editOmc', JSON.stringify(editOmc)); } function is_valid() { var omcRequest = JSON.parse(localStorage.getItem('omcRequest')); var check = true; $.each(omcRequest.items, function (key, val) { if (val.qty == 0 && val.rqty == 0) { check = false; return false; } }); if (check == false) { return false } else { return true; } } function update_now() { var omcRequest = JSON.parse(localStorage.getItem('editOmc')); console.log('Value of Omc testing Request is', omcRequest.items); const requiredFields = { items: omcRequest.items.length > 0, warehouse: omcRequest.warehouse, customer_po: omcRequest.customer_po, cutomer_po_date: omcRequest.cutomer_po_date, invoice_no: omcRequest.invoice_no, invoice_date: omcRequest.invoice_date, invoice_basic_value: omcRequest.invoice_basic_value, site_id: omcRequest.site_id, site_name: omcRequest.site_name, complaint_closure_date: omcRequest.complaint_closure_date, cust_open_po_status: omcRequest.cust_open_po_status, open_po_amount: omcRequest.open_po_amount, invoice_value: omcRequest.invoice_value, customer_code_and_name: omcRequest.customer_code_and_name, stock_type: omcRequest.stock_type }; // Find missing fields let missingFields = Object.keys(requiredFields).filter(key => !requiredFields[key]); if (missingFields.length > 0) { swal(`Please fill all required fields: ${missingFields.join(', ')}`, { icon: "error" }); } else if (!is_valid()) { swal("Zero quantity is not allowed for the Item.", { icon: "error" }); } else { swal({ title: "Is Your Spare Parts Verified ?", text: "if you verified your items then press 'Ok',otherwise press 'Cancel' and check again.", icon: "warning", buttons: true, dangerMode: true, }).then((willDelete) => { if (willDelete) { var url = window.location.origin + "/circle-store/update-omc" omcRequest._token = "{{ csrf_token() }}"; $('#loaderAction').show(); var requestTimeout; var ajaxRequest = $.ajax({ type: "POST", url: url, data: { _token: omcRequest._token, omcRequest: JSON.stringify(omcRequest) }, timeout: 20000, // Set the timeout to 5 seconds (5000 milliseconds) success: function (res) { clearTimeout(requestTimeout); console.log(res); if (res.success == true) { swal(res.msg, { icon: "success", }); init_cart(); showSelectedItems(); // Enable the button for re-submit placeOmc.disabled = false; // Reset the button text placeOmc.innerHTML = 'Place OMC Request'; } else { swal(res.msg, { icon: "error", }); } $('#loaderAction').hide(); placeOmc.disabled = res.success !== true; // placeAmcButton.innerHTML = 'AMC Request Placed !';; }, error: function (xhr, status, error) { var requestTimeout = setTimeout(function () { $('#loaderAction').hide(); swal("Process has been cancelled due to exceeding the execution time!", { icon: "error" }); ajaxRequest.abort(); }, 20000); console.log(error); placeOmc.disabled = true; placeOmc.innerHTML = '<span class="spinner-border spinner-border-sm" role="status" aria-hidden="true"></span> <span class="animated-text">Please wait, request is under process...</span>'; // Clear the timeout on error clearTimeout(requestTimeout); }, dataType: 'json' }); // Set the timeout for the request requestTimeout = setTimeout(function () { $('#loaderAction').hide(); swal("Process has been cancelled due to exceeding the execution time!", { icon: "error" }); ajaxRequest.abort(); // Enable the button for re-submit placeOmc.disabled = false; // Reset the button text placeOmc.innerHTML = 'Place OMC Request'; }, 20000); } }); } } // function update_omc_request(){ // var omcRequest = JSON.parse(localStorage.getItem('editOmc')); // console.log("Value of OMC testing request is:",omcRequest.items); // if(omcRequest.warehouse == "" || omcRequest.customer_po == "" || omcRequest.cutomer_po_date == "" || omcRequest.invoice_no == "" || omcRequest.invoice_date == "" || omcRequest.customer_code_and_name == "" || omcRequest.stock_type == ""){ // swal("Please add Spare Items and all field is required !!", { icon: "error", }); // }else if(!is_valid()){ // swal("Zero quantity is not allowed for the Item.", { icon: "error", }); // }else{ // swal({ // title: "Is Your Spare Parts Verified ?", // text: "if you verified your items then press 'Ok',otherwise press 'Cancel' and check again.", // icon: "warning", // buttons: true, // dangerMode: true, // }).then((willDelete) => { // if (willDelete) { // var url = window.location.origin+"/circle-store/update-omc" // omcRequest._token = "{{ csrf_token() }}"; // $('#loaderAction').show(); // var requestTimeout; // var ajaxRequest = $.ajax({ // type: "POST", // url: url, // data: omcRequest, // timeout: 20000, // Set the timeout to 5 seconds (5000 milliseconds) // success:function(res){ // clearTimeout(requestTimeout); // console.log(res); // if(res.success == true){ // swal(res.msg, { icon: "success", }); // init_cart(); // showSelectedItems(); // // Enable the button for re-submit // placeOmc.disabled = false; // // Reset the button text // placeOmc.innerHTML = 'Place OMC Request'; // }else{ // swal(res.msg, { icon: "error", }); // } // $('#loaderAction').hide(); // placeOmc.disabled = res.success !== true; // // placeAmcButton.innerHTML = 'AMC Request Placed !';; // }, // error:function(xhr, status, error){ // var requestTimeout = setTimeout(function () { // $('#loaderAction').hide(); // swal("Process has been cancelled due to exceeding the execution time!", { icon: "error" }); // ajaxRequest.abort(); // }, 20000); // console.log(error); // placeOmc.disabled = true; // placeOmc.innerHTML = '<span class="spinner-border spinner-border-sm" role="status" aria-hidden="true"></span> <span class="animated-text">Please wait, request is under process...</span>'; // // Clear the timeout on error // clearTimeout(requestTimeout); // }, // dataType: 'json' // }); // // Set the timeout for the request // requestTimeout = setTimeout(function() { // $('#loaderAction').hide(); // swal("Process has been cancelled due to exceeding the execution time!", { icon: "error" }); // ajaxRequest.abort(); // // Enable the button for re-submit // placeOmc.disabled = false; // // Reset the button text // placeOmc.innerHTML = 'Place OMC Request'; // }, 20000); // } // }); // } // } // function place_omc_request() // { // var omcRequest = JSON.parse(localStorage.getItem('omcRequest')); // if(omcRequest.items.length < 1 || omcRequest.warehouse == "" || omcRequest.customer_po == "" || omcRequest.cutomer_po_date == "" || omcRequest.invoice_no == "" || omcRequest.invoice_date == "" || omcRequest.customer_code_and_name == ""){ // swal("Please add Spare Items and all field is required !!", { icon: "error", }); // }else if(!is_valid()){ // swal("Zero quantity is not allowed for the Item.", { icon: "error", }); // }else{ // swal({ // title: "Is Your Spare Parts Verified ?", // text: "if you verified your items then press 'Ok',otherwise press 'Cancel' and check again.", // icon: "warning", // buttons: true, // dangerMode: true, // }).then((willDelete) => { // if (willDelete) { // var url = window.location.origin+"/circle-store/place-omc-request" // omcRequest._token = "{{ csrf_token() }}"; // $('#loaderAction').show(); // $.ajax({ // type: "POST", // url: url, // data: omcRequest, // success:function(res){ // // const button = document.getElementById('placeOmc'); // // button.disabled = true; // // // Change the text of the button // // button.innerHTML = 'OMC Request Placed'; // console.log(res); // if(res.success == true){ // swal(res.msg, { icon: "success", }); // init_cart(); // showSelectedItems(); // }else{ // swal(res.msg, { icon: "error", }); // } // $('#loaderAction').hide(); // }, // error:function(error){ // console.log(error); // }, // dataType: 'json' // }); // } // }); // } // } $(document).ready(function () { $('.select2').select2(); }); </script> @endpush