/
home
/
sjslayjy
/
public_html
/
assets
/
storage
/
framework
/
views
/
Upload File
HOME
<?php $__env->startPush('plugin-styles'); ?> <!-- <?php echo Html::style('/assets/plugins/plugin.css'); ?> --> <?php $__env->stopPush(); ?> <?php $__env->startSection('content'); ?> <div class="row"> <div class="col-lg-12 grid-margin"> <div class="card"> <div class="card-body"> <h3 class="card-title">Onetime Material Consumption Request (OMCR)</h3> <div class="row"> <div class="col-lg-3"> <small>Ware House</small> <select class="form-control mr select2" id="warehouse" onchange="get_ware_house(this)"> <option value=""> -- Select Warehouse --</option> <?php $__currentLoopData = $assigned_warehouses; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $assigned_warehouse): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?> <option value="<?php echo e($assigned_warehouse); ?>" <?php echo e($current_warehouse == $assigned_warehouse ? 'selected' : ''); ?>> <?php echo e($assigned_warehouse); ?></option> <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?> </select> </div> <div class="col-lg-3"> <small>Customer Code and Name</small> <select onchange="getCustomerCodeInfo(this)" class="form-control mr" id="customer_code_and_name"> <option value="">Select Customer Code</option> <?php $__currentLoopData = $customers; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $customer): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?> <option value="<?php echo e($customer->Cust_Code); ?> -- <?php echo e($customer->Cust_Name); ?>"><?php echo e($customer->Cust_Code); ?> -- <?php echo e($customer->Cust_Name); ?></option> <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?> </select> </div> <div class="col-lg-3"> <small>Customer PO Number</small> <input type="text" id="customer_po" name="customer-po" onkeyup="get_cutomer_po(this)" class="form-control" /> </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" /> </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" /> </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" /> </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" /> </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" /> </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" /> </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" /> </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)"> <option value="">Select Status</option> <option value="open">Open</option> <option value="closed">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)"> </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" /> </div> <div class="col-lg-3"> <small>OMC Type<span class="text-danger">*</span></small> <select class="form-control mr" onchange="get_omc_type(this)"> <option value="">-- Select OMC Type--</option> <?php $__currentLoopData = $omc_types; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $omc_type): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?> <option value="<?php echo e($omc_type->omc_names); ?>" <?php echo e(old('omc_type') == $omc_type->omc_names ? 'selected' : ''); ?>> <?php echo e($omc_type->omc_names == 'pt' ? 'PT' : ($omc_type->omc_names == 'amc' ? 'AMC' : $omc_type->omc_names)); ?> </option> <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?> </select> </div> <div class="col-lg-3"> <small>Select Stock<span class="text-danger">*</span></small> <select class="form-control mr" 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 class="col-lg-6"> <input type="text" class="form-control" id="spareCode" placeholder="Enter Spare Code"> </div> <div class="col-lg-2"> <button type="button" class="btn btn-success btn-fw" onclick="addselectedItem()">Add Item</button> </div> </div> <div class="table-responsive"> <table class="table table-striped table-bordered"> <thead> <tr> <th> Item Code</th> <th> Description</th> <th> UOM</th> <th> Category</th> <th> Rate</th> <th> Fresh Qty</th> <th> Repaired Qty</th> <th> --- </th> </tr> </thead> <tbody id="tbody"> <p id="error" style="color:red;"></p> </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 type="button" id="omcBtn" onclick="place_omc_request()" class="btn btn-warning btn-fw">Place OMC Request</button></div> </div> </div> </div> </div> </div> <?php $__env->stopSection(); ?> <?php $__env->startPush('plugin-scripts'); ?> <?php echo Html::script('/assets/plugins/chartjs/chart.min.js'); ?> <?php echo Html::script('/assets/plugins/jquery-sparkline/jquery.sparkline.min.js'); ?> <?php $__env->stopPush(); ?> <?php $__env->startPush('custom-scripts'); ?> <?php echo Html::script('/assets/js/dashboard.js'); ?> <script type="text/javascript"> function init_cart() { var omcRequest = {}; omcRequest.items = []; omcRequest.customer_po = ""; omcRequest.warehouse = "<?php echo e($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 = ""; localStorage.setItem('omcRequest', JSON.stringify(omcRequest)); } init_cart(); function get_stock_type(t) { var omcRequest = JSON.parse(localStorage.getItem('omcRequest')); omcRequest.stock_type = $(t).val(); localStorage.setItem('omcRequest', JSON.stringify(omcRequest)); omcRequest.items = []; localStorage.setItem('omcRequest', JSON.stringify(omcRequest)); showSelectedItems(); } function get_cutomer_po(t) { var omcRequest = JSON.parse(localStorage.getItem('omcRequest')); omcRequest.customer_po = $(t).val(); localStorage.setItem('omcRequest', JSON.stringify(omcRequest)); } function get_invoice_basic_value(t) { var omcRequest = JSON.parse(localStorage.getItem('omcRequest')); omcRequest.invoice_basic_value = $(t).val(); localStorage.setItem('omcRequest', JSON.stringify(omcRequest)); } function get_site_id(t) { var omcRequest = JSON.parse(localStorage.getItem('omcRequest')); omcRequest.site_id = $(t).val(); localStorage.setItem('omcRequest', JSON.stringify(omcRequest)); } function get_site_name(t) { var omcRequest = JSON.parse(localStorage.getItem('omcRequest')); omcRequest.site_name = $(t).val(); localStorage.setItem('omcRequest', JSON.stringify(omcRequest)); } function get_complaint_closure_date(t){ var omcRequest = JSON.parse(localStorage.getItem('omcRequest')); omcRequest.complaint_closure_date = $(t).val(); localStorage.setItem('omcRequest',JSON.stringify(omcRequest)); } function get_cust_open_po_status(t){ var omcRequest = JSON.parse(localStorage.getItem('omcRequest')); omcRequest.cust_open_po_status = $(t).val(); localStorage.setItem('omcRequest',JSON.stringify(omcRequest)); } function get_open_po_amount(t){ var omcRequest = JSON.parse(localStorage.getItem('omcRequest')); omcRequest.open_po_amount = $(t).val(); localStorage.setItem('omcRequest',JSON.stringify(omcRequest)); } function get_invoice_value(t){ var omcRequest = JSON.parse(localStorage.getItem('omcRequest')); omcRequest.invoice_value = $(t).val(); localStorage.setItem('omcRequest',JSON.stringify(omcRequest)); } function get_invoice_date(t) { var omcRequest = JSON.parse(localStorage.getItem('omcRequest')); omcRequest.invoice_date = $(t).val(); localStorage.setItem('omcRequest', JSON.stringify(omcRequest)); } function get_ware_house(t) { var omcRequest = JSON.parse(localStorage.getItem('omcRequest')); omcRequest.warehouse = $(t).val(); localStorage.setItem('omcRequest', JSON.stringify(omcRequest)); if (omcRequest.warehouse != "") { var url = window.location.origin + "/circle-store/get-customers-of-warehouse"; var data = {}; data.warehouse = omcRequest.warehouse; data._token = "<?php echo e(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 omcRequest = JSON.parse(localStorage.getItem('omcRequest')); omcRequest.customer_code_and_name = $(t).val(); localStorage.setItem('omcRequest', JSON.stringify(omcRequest)); } function get_omc_type(t) { var omcRequest = JSON.parse(localStorage.getItem('omcRequest')); omcRequest.omc_type = $(t).val(); localStorage.setItem('omcRequest', JSON.stringify(omcRequest)); } function get_cutomer_po_date(t) { var omcRequest = JSON.parse(localStorage.getItem('omcRequest')); omcRequest.cutomer_po_date = $(t).val(); localStorage.setItem('omcRequest', JSON.stringify(omcRequest)); } function get_invoice_no(t) { var omcRequest = JSON.parse(localStorage.getItem('omcRequest')); omcRequest.invoice_no = $(t).val(); localStorage.setItem('omcRequest', JSON.stringify(omcRequest)); } function removeItem(id) { var omcRequest = JSON.parse(localStorage.getItem('omcRequest')); var items = omcRequest.items; $(items).each(function (index) { if (items[index].id == id) { items.splice(index, 1); // This will remove the object that first name equals to Test1 return false; // This will stop the execution of jQuery each loop. } }); omcRequest.items = items; localStorage.setItem('omcRequest', JSON.stringify(omcRequest)); showSelectedItems(); } 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 = "<?php echo e(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')); 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); } 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')); 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> <td>`+ spare_part.rate + `</td>`; if (spare_part.qty == 0) { html += `<td><input type="text" name="qty" id="fresh_qty" onkeyup="calculate(this,` + spare_part.id + `,'` + spare_part.code + `')" onblur="is_blank(this)" style="width: 80px;" value="` + spare_part.qty + `" disabled/></td>`; } else { html += `<td><input type="text" name="qty" id="fresh_qty" onkeyup="calculate(this,` + spare_part.id + `,'` + spare_part.code + `')" style="width: 80px;" onblur="is_blank(this)" value="` + spare_part.qty + `"/></td>`; } if (spare_part.rqty == 0) { html += `<td><input type="text" name="qty" id="repaired_qty" onkeyup="rcalculate(this,` + spare_part.id + `,'` + spare_part.code + `')" onblur="is_blank(this)" style="width: 80px;" value="` + spare_part.rqty + `" disabled/></td>`; } else { html += `<td><input type="text" name="qty" id="repaired_qty" onkeyup="rcalculate(this,` + spare_part.id + `,'` + spare_part.code + `')" onblur="is_blank(this)" 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 calculate(t,id){ // 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, code) { var qty = $(t).val(); if (qty != "" && qty != null) { var qty = parseInt(qty); var warehouse = $('#warehouse').val(); var params = { 'code': code, 'qty': qty, 'type': 'fresh_qty', 'type1': 'qty', 'warehouse': warehouse, 'id': id } validate_qty(params); } else { addCartValueInKey(id, 'qty', 0); } } // function rcalculate(t,id){ // 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, code) { var rqty = $(t).val(); if (rqty != "" && rqty != null) { var rqty = parseInt(rqty); var warehouse = $('#warehouse').val(); var params = { 'code': code, 'qty': rqty, 'type': 'repaired_qty', 'type1': 'rqty', 'warehouse': warehouse, 'id': id, } validate_qty(params); } 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": "<?php echo e(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 omcRequest = JSON.parse(localStorage.getItem('omcRequest')); $.each(omcRequest.items, function (k, val) { if (parseInt(val.id) == id) { omcRequest.items[k][key] = value; } }); localStorage.setItem('omcRequest', JSON.stringify(omcRequest)); } 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 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 == "" || omcRequest.stock_type == "" || 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 == "") { 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 = "<?php echo e(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 omcBtn.disabled = false; // Reset the button text omcBtn.innerHTML = 'Place OMC Request'; } else { swal(res.msg, { icon: "error", }); } $('#loaderAction').hide(); omcBtn.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); omcBtn.disabled = true; omcBtn.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 omcBtn.disabled = false; // Reset the button text omcBtn.innerHTML = 'Place OMC Request'; }, 20000); } }); } } $(document).ready(function () { }); function formatIndianCurrency(input) { let value = input.value.replace(/,/g, ''); // Remove existing commas if (value === "" || isNaN(value)) return; // Return if empty or non-numeric let number = parseFloat(value); input.value = number.toLocaleString('en-IN'); // Format as Indian currency } </script> <script> $(document).ready(function () { $('.select2').select2({ placeholder: 'Search Warehouses', allowClear: false, language: { noResults: function () { return '<span class="no-results">No results found!</span>'; } }, escapeMarkup: function (markup) { return markup; } }); }); </script> <?php $__env->stopPush(); ?> <?php echo $__env->make('layout.master', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH /var/www/assets/resources/views/circle-store/omc/omc-request.blade.php ENDPATH**/ ?>