<link rel="stylesheet" src="<?php echo e(URL::to('assets/calender/theme.css')); ?>">
<link rel="stylesheet" src="<?php echo e(URL::to('assets/calender/style.css')); ?>">
<style>
    .orderLists.newDesg .imgBoxs {
        height: 170px;
        object-fit: cover;
        width: 120px;
    }

    p.msg-sts {
        padding: 6px 10px !important;
    }

    button.submit-popup.create,
    button.submit-popup.createinpack.mt-3 {
        margin-top: 50px !important;
    }

    .main-popup-contents .rs-flex {
        width: 100%;
    }

    .main-popup-contents p {
        margin-bottom: 30px;
        font-weight: 600;
        font-size: 20px;
    }

    input#datepickerinproduction,
    #datepickerinpackage,
    #datepicker {
        border-radius: 30px;
    }

    /*  calender css start*/
    .buttons-container {
        display: -webkit-box;
        display: -moz-box;
        display: -ms-flexbox;
        display: -webkit-flex;
        display: flex;
        align-items: center;
        margin-bottom: 10px;
        padding-bottom: 10px;
        border-bottom: 1px solid #eee;
    }

    .buttons-container .label-container {
        display: inline-block;
        -webkit-box-flex: 1;
        -moz-box-flex: 1;
        -webkit-flex: 1;
        -ms-flex: 1;
        flex: 1;
        text-align: center;
        text-transform: uppercase;
        font-weight: bold;
    }

    .year-dropdown {
        -webkit-appearance: none;
        -moz-appearance: none;
        appearance: none;
        border: none;
        font-size: inherit;
        font-weight: inherit;
        font-family: inherit;
        padding: 5px 20px;
    }

    .prev-button,
    .next-button {
        background: transparent;
        border: none;
        padding: 10px;
    }

    .week {
        margin: 10px 0;
    }

    .week.highlight {
        border-radius: 5px;
    }

    .weeks-wrapper.header {
        border-bottom: 1px solid #eee;
    }

    .week .day.header {
        font-weight: bold;
        text-transform: uppercase;
        font-size: 120%;
    }

    .day span {
        display: inline-block;
        width: 40px;
        height: 40px;
        line-height: 40px;
        border-radius: 50%;
        vertical-align: middle;
    }

    .day.today span {
        position: relative;
        display: inline-block;
        font-size: 110%;
    }

    /* weekend */
    .week:not(.start-on-monday) .day:first-child,
    .week:not(.start-on-monday) .day:last-child {
        color: orange;
    }

    /* sunday */
    .week:not(.start-on-monday) .day:first-child {
        color: red;
    }

    /* start on monday - weekend */
    .week.start-on-monday .day:nth-child(6),
    .week.start-on-monday .day:last-child {
        color: orange;
    }

    /* start on monday - sunday */
    .week.start-on-monday .day:last-child {
        color: red;
    }

    .day.today span::after {
        content: "";
        position: absolute;
        bottom: 7px;
        left: 50%;
        transform: translateX(-50%);
        border-bottom: 2px solid orange;
        width: 10px;
        height: 1px;
    }

    .day.sunday span {
        color: #ff8a80;
    }

    .week .day.highlight span {
        color: #2196f3;
    }

    .week .day.selected span {
        background: #1565c0;
        color: white;
    }

    .week .day[disabled="disabled"] span {
        color: #aaa;
        cursor: not-allowed;
    }

    .months-wrapper .month span {
        display: inline-block;
        padding: 10px;
        text-transform: capitalize;
        margin-bottom: 10px;
    }

    .special-buttons {
        text-align: center;
        border-top: 1px solid #eee;
        padding-top: 10px;
    }

    .today-button {
        margin: 0 auto;
        background: transparent;
        border: none;
        padding: 5px;
    }

    .calendar-box {}

    .buttons-container {
        cursor: pointer;
    }

    .week {
        overflow: hidden;
    }

    .week.highlight {
        background: #efefef;
    }

    /* weekend */
    .week .day:first-child,
    .week .day:last-child {
        /*color: orange;*/
    }

    /* sunday */
    .week .day:first-child {
        /*color: red;*/
    }

    .day {
        display: inline-block;
        float: left;
        width: 14.28%;
        text-align: center;
        cursor: pointer;
        box-sizing: border-box;
    }

    .day.disabled span {
        color: #AAA;
    }

    /* vertical highlight */
    .week .day.highlight span {
        /*color: blue;*/
    }

    .day.selected span {
        /*background: orange;*/
    }

    .day.today span {
        font-weight: bold;
    }

    .months-container.hidden,
    .weeks-container.hidden {
        display: none;
    }

    .months-wrapper {
        overflow: hidden;
    }

    .months-wrapper .month {
        display: inline-block;
        float: left;
        width: 25%;
        text-align: center;
        cursor: pointer;
    }

    .months-wrapper .month.one-third {
        width: 33.33%;
    }

    /*   calender css end */
    .purchase-order {
        border: 1px solid #ccc;
        padding: 10px 0px 20px 0px;
        padding: 20px !important;
        margin-bottom: 20px !important;
        border-radius: 7px;
    }
</style>

<?php $__env->startSection('content'); ?>
    <div class="common-content">
        <div class="page-content">
            <div class="page-heading">
                <div class="headings">
                    <h6>Equipment Status</h6>
                    <input name="_token" type="hidden" id="token_po" value="<?php echo e(csrf_token()); ?>">
                </div>
            </div>

            
            <div class="dashboard-cnts">
                <div class="row">
                    <div class="col-lg-12">
                        <div class="boxings po-sum" style="border-radius: 15px;">
                           
                               
                                    <div class="purchase-order js-category-filterable" data-category="<?php echo $equipment['individual_buyerid'] ?>">
                                        <div class="order-id d-flex justify-content-end">
                                            <h4>Order ID <span class="green-order"><?php echo e($equipment['po_id']); ?></span></h4>
                                        </div>
                                        <div class="order-status">
                                            <p style="color:red;"> Product Status:<?php if($equipment['dispatch_status'] == 1): ?>
                                                   In production
                                                <?php elseif($equipment['dispatch_status'] == 2): ?>
                                               In package
                                                <?php elseif($equipment['dispatch_status'] == 3): ?>
                                               Dispatched
                                                <?php elseif($equipment['dispatch_status'] == 4): ?>
                                                 Received
                                                <?php elseif($equipment['dispatch_status'] == 5): ?>
                                                    Pre-Dispatched
                                                <?php else: ?>
                                               Pending
                                                <?php endif; ?>
                                            </p>
                                        </div>
                                        <div class="d-flexW align-items-stretch">
                                            <div class="product-image small-img">
                                            <?php if(!empty($equipment['photo'])): ?>
                                                <img src="<?php echo e(url('product_files')); ?>/<?php echo e($equipment['photo']); ?>">
                                            <?php else: ?>
                                                <img src="<?php echo e(url('assets/images/1200px-No-Image-Placeholder.svg.png')); ?>">
                                            <?php endif; ?>
                                        </div>
                                        <?php
                                            $vendordetails = App\Helpers\CustomHelper::userdetails($equipment['vendor_id']);
                                        ?>
                                        <div class="product_details-grd">
                                            <div class="product-details mr-5">
                                                <ul>
                                                    <li>
                                                        <h4 class="product-name"><?php echo e(ucfirst($equipment['product_name'])); ?> </h4>
                                                    </li>
                                                    <li><label class="p-o-label">Equipment Id</label>:
                                                        <span><?php echo e($equipment['id']); ?></span>
                                                    </li>
                                                    <li><label class="p-o-label">Product Code</label>:
                                                        <span><?php echo e($equipment['product_code']); ?></span>
                                                    </li>

                                                    <?php if($equipment['product_serial_no']!=''): ?>

                                                    <li><label class="p-o-label">Product Serial Number</label>:
                                                        <span><?php echo e($equipment['product_serial_no']); ?></span>
                                                    </li>
                                                    <?php endif; ?>
                                                    
                                                    <li><label class="p-o-label">Vendor Name</label>:
                                                        <span><?php echo e(ucfirst($vendordetails['userdetails']['name'])); ?></span>
                                                    </li>
                                                    <?php if($equipment['individual_buyerid'] != '0'): ?>
                                                    <li><label class="p-o-label">Consignee</label>: <span><?php echo e(ucfirst(App\Helpers\CustomHelper::manu_name($equipment['individual_buyerid']))); ?></span></li>
                                                    <?php endif; ?>

                                                    <?php if($vendordetails['userdetails']['address'] != ''): ?>
                                                        <li><label class="p-o-label">Vendor Address</label>:
                                                            <span><?php echo e(ucfirst($vendordetails['userdetails']['address'])); ?>

                                                                <?php if($vendordetails['userdetails']['countryname'] != ''): ?>
                                                                    <?php echo e(',' . $vendordetails['userdetails']['countryname']); ?>

                                                                    <?php endif; ?> <?php if($vendordetails['userdetails']['statename'] != ''): ?>
                                                                        <?php echo e(',' . $vendordetails['userdetails']['statename']); ?>

                                                                    <?php endif; ?>
                                                            </span>
                                                        </li>
                                                    <?php endif; ?>
                                                    <?php if($vendordetails['userdetails']['gst_no'] != ''): ?>
                                                        <li><label class="p-o-label">GST Number</label>:
                                                            <span><?php echo e($vendordetails['userdetails']['gst_no']); ?></span>
                                                        </li>
                                                    <?php endif; ?>
                                                    <li><label class="p-o-label">Order Placed on</label>: <span>
                                                            <?php echo e(date('d-m-Y', strtotime($equipment['created_at']))); ?></span></li>
                                                </ul>
                                            </div>
                                            <div class="product-details" style="    margin-top: 37px;">
                                                <ul>
                                                    
                                                    <li><label class="p-o-label">Price</label>:
                                                        <span><?php echo e($equipment['price']); ?></span>
                                                    </li>
                                                   <?php if($equipment['delivery_date']  !=''): ?>
                                                    
                                                    <li><label class="p-o-label">Delivery Date</label>:
                                                        <span><?php echo e($equipment['delivery_date']); ?></span>
                                                    </li>

                                                    <?php endif; ?>
                                                </ul>
                                            </div>
                                        </div>
                                        </div>
                                        <hr>
                                        <div class="d-flexW mt-4 align-items-stretch">
                                        <div class="product-description desc-prdt-nw">
                                            <label class="p-o-label">Product Description</label>
                                            <p><?php echo e(ucfirst($equipment['product_description'])); ?></p>
                                        </div>
                                        <?php if($equipment['prerequites_status'] == 1 && $equipment['requites_ready'] == 1): ?>
                                            <?php
                                                $preRequisites = App\Helpers\CustomHelper::getPreRequisites($equipment['id']);
                                            ?>
                                            <?php if($preRequisites != false): ?>
                                                <hr>
                                                <div class="product-description">
                                                    <label class="p-o-label">Pre-Requisites items are Ready</label>
                                                    <?php $m = ''; ?>
                                                    <?php $__currentLoopData = $preRequisites; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $key => $value): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                                        <?php $m .= $value->items . ','; ?>
                                                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                                    <p><?php echo e(rtrim($m, ',')); ?></p>
                                                </div>
                                            <?php endif; ?>
                                        <?php endif; ?>

                                        <?php if($equipment['inspection_date_status'] != 0): ?>
                                            <hr>
                                            <div class="product-description desc-prdt-nw ins">
                                                <label class="p-o-label">Inspection Details</label>
                                                 <div class="addtnl">
                                                     <p>Inspection Date:</p>
                                                     <p><?php echo e($equipment['inspection_date']); ?><p>
                                                 </div>
                                                 <div class="addtnl">
                                                     <p> Inspection Status:</p><p><?php if($equipment['inspection_date_status'] == 1): ?>
                                                        <span style="color:orange">Submitted</span>
                                                    <?php elseif($equipment['inspection_date_status'] == 2): ?>
                                                        <span style="color:green">Approved</span>
                                                    <?php elseif($equipment['inspection_date_status'] == 3): ?>
                                                        <span style="color:red">Rejected</span>
                                                    <?php else: ?>
                                                    <?php endif; ?>
                                                </p>
                                                </div>
                                                <?php if($equipment['inspection_date_status'] == 3): ?>
                                                <div class="addtnl reason">
                                                    
                                                        <P> Reason</p>
                                                        <p style="color:red">
                                                            <?php echo e(ucfirst($equipment['inspection_date_rejectreason'])); ?></p>
                                                   
                                                </div>
                                                <?php endif; ?>
                                                   
                                            </div>
                           
                                        <?php endif; ?>
 </div>
                                        <?php if($equipment['dispatch_status'] == 4): ?>

                                        <?php $printId = 1; ?>
                                            <div class="p-o-buttons">
                                                <span id='download-challan'>
                                                    <?php if($equipment['inspection_challan'] == null): ?>
                                                        <button class="btn medd-buttons medd-black generatechellan"
                                                            data-preorderid="<?php echo e($equipment['id']); ?>"
                                                            >Generate
                                                            Challan
                                                        </button>
                                                    <?php else: ?>
                                                        <button class="btn medd-buttons medd-blue rounded"
                                                            onclick="printChallan('<?php echo 'print'.$printId; ?>')">Print
                                                            Challan</button>
                                                        <iframe id="<?php echo 'print'.$printId; ?>"
                                                            style="display: none;"
                                                            src="<?php echo e(url('assets/pdf/inspection-challan/' . $equipment['inspection_challan'])); ?>"></iframe>
                                                        
                                                        <a href='<?php echo e(url('assets/pdf/inspection-challan/' . $equipment['inspection_challan'])); ?>'
                                                            target="_blank"><button
                                                                class="btn medd-buttons medd-blue rounded"> View &amp;
                                                                Download Challan</button></a>
                                                    <?php endif; ?>
                                                </span>

                                                
                                         <?php if($equipment['inspection_challan']!= null): ?>
                                                <?php if($equipment['inspection_date_status'] == 0): ?>
                                                    <button class="btn medd-buttons medd-blue"
                                                        onclick="inspection_date(<?php echo e($equipment['vendor_id']); ?>,<?php echo e($equipment['po_id']); ?>,<?php echo e($equipment['id']); ?>,<?php echo e($equipment['product_id']); ?>)">Request
                                                        Inspection Date</button>
                                                <?php endif; ?>
                                                <?php if($equipment['inspection_date_status'] == 3): ?>
                                                    <button class="btn medd-buttons medd-blue"
                                                        onclick="inspection_date_change(<?php echo e($equipment['vendor_id']); ?>,<?php echo e($equipment['po_id']); ?>,<?php echo e($equipment['id']); ?>,'<?php echo e($equipment['inspection_date']); ?>',<?php echo e($equipment['product_id']); ?>)">Change
                                                        Inspection Date</button>
                                                <?php endif; ?>
                                        <?php endif; ?>
                                                <button class="btn medd-buttons medd-blue rounded"
                                            onclick="generatebarcode('<?php echo e($equipment['barcode']); ?>')">View Barcode</button>
                                            </div>
                                        <?php endif; ?>

                                        
                                        <!-- Barcode Modal -->
                                        <div class="modal fade" id="exampleModal" tabindex="-1" role="dialog"
                                            aria-labelledby="exampleModalLabel" aria-hidden="true">
                                            <div class="modal-dialog" role="document">
                                                <div class="modal-content">
                                                    <div class="modal-header">
                                                        <h5 class="modal-title" id="exampleModalLabel">BARCODE</h5>
                                                        <button type="button" class="close" data-dismiss="modal"
                                                            aria-label="Close">
                                                            <span aria-hidden="true">&times;</span>
                                                        </button>
                                                    </div>

                                                    <div class="modal-body" id="demo">
                                                        <img id="barcode" />
                                                    </div>
                                                    <div class="modal-footer">
                                                        <button type="button" class="btn btn-secondary"
                                                            data-dismiss="modal" id="closebar">Close</button>
                                                        <button type="button" id="printBtn"
                                                            class="btn btn-primary">Print</button>
                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                       
                        </div>
                    </div>
                </div>
            </div>

            <div class="modal fade  new-modal" id="generate" tabindex="-1" aria-labelledby="exampleModalLabel"
                aria-hidden="true">
                <div class="modal-dialog">
                    <div class="modal-content">
                        <div class="modal-body">
                            <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                                <span aria-hidden="true">&times;</span>
                            </button>
                            <div class="otp">
                                <h4>OTP Verification</h4>
                                <p>Please Enter the OTP send to your Phone Number</p>

                                <input type="hidden" name="phone" id="phone_no" value="<?php echo Auth::user()->phone_no; ?>">
                                <input type="hidden" name="email" id="email" value="<?php echo Auth::user()->email; ?>">

                                <div class="otp-dflex">
                <input  min="0" max="9" pattern="\d*" type="number" onkeyup="onKeyUpEvent(1, event)" placeholder="0" maxlength="1" id="otp1">
                <input min="0" max="9" type="number" onkeyup="onKeyUpEvent(2, event)" placeholder="0" maxlength="1" id="otp2">
                <input min="0" max="9" type="number" onkeyup="onKeyUpEvent(3, event)" placeholder="0" maxlength="1" id="otp3">
                <input min="0" max="9" type="number" onkeyup="onKeyUpEvent(4, event)" placeholder="0" maxlength="1" id="otp4">
                <input min="0" max="9" type="number" onkeyup="onKeyUpEvent(5, event)" placeholder="0" maxlength="1" id="otp5">
                <input min="0" max="9" type="number" onkeyup="onKeyUpEvent(6, event)" placeholder="0" maxlength="1" id="otp6">
            </div> 
                            </div>
                            <div class="medd-pop-buttons">
                                <input type="hidden" name="preorder_id_pop" id="preorder_id_pop" value="">
                                <button class="btn medd-blue medd-buttons" id="otpverify">Verify</button>
                                <button class="btn medd-blue medd-buttons" id="resend">Resend OTP</button>
                            </div>
                        </div>
                    </div>
                </div>
            </div>

            <div class="modal fade  new-modal" id="add-date" tabindex="-1" aria-labelledby="exampleModalLabel"
                aria-hidden="true">
                <div class="modal-dialog modal-lg cutom-modal">
                    <form id="add_inspectiondate" method="POST" action="<?php echo e(url('buyers/add_inspectiondate')); ?>"
                        enctype="multipart/form-data"> <?php echo csrf_field(); ?>
                        <div class="modal-content">
                            <div class="modal-body">
                                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                                    <span aria-hidden="true">&times;</span>
                                </button>
                                <div class="p-3">
                                    Inspection Date
                                    <input id="inspection_date" name="inspection_date" data-zdp_readonly_element="false"
                                        type="text" class="form-control">
                                </div>
                                <input type="hidden" name="inspection_order_id" id="inspection_order_id">
                                <input type="hidden" name="inspection_vendor_id" id="inspection_vendor_id">
                                <input type="hidden" name="inspection_preorderid" id="inspection_preorderid">
                                <input type="hidden" name="inspection_product_id" id="inspection_product_id">
                            </div>
                            <div class="modal-footer">
                                <div class="d-flex align-items-center justify-content-end w-100">
                                    <button class="btn medd-blue medd-buttons ml-2" type="submit"
                                        style=" margin-right: 10px;">Submit</button>
                                </div>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
            <div class="modal fade  new-modal" id="add-pbg" tabindex="-1" aria-labelledby="exampleModalLabel" aria-hidden="true">
                <div class="modal-dialog modal-lg cutom-modal">
                    <div class="modal-content">
                        <div class="modal-body">
                            <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                                <span aria-hidden="true">&times;</span>
                            </button>
                            <div class="consignee-certificate">
                                <h5 class="text-center">CONSIGNEE RECEIPT CERTIFICATE</h5>
                                <p class="mt-3">The following store (s) has/have been received in good condition:</p>
                                <div class="table-responsive">
                                    <table class="table table-striped">
                                        <tbody>
                                            <tr>
                                                <th scope="row">1</th>
                                                <td>Contract no & date</td>
                                                <td id='contract_no'>HITES NOA No HITES/PCD/AIIMS-
                                                    Bibinagar/21-22/2672 dated 03 sep 2021</td>
                                            </tr>
                                            <tr>
                                                <th scope="row">2</th>
                                                <td>Supplier’s Name</td>
                                                <td id='supplier'>M/s York Scientific Industries Pvt. Ltd, 8/6E, Site IV,
                                                    Sahibabad
                                                    Industrial Area, Ghaziabad (U.P)-201010</td>
                                            </tr>
                                            <tr>
                                                <th scope="row">2a</th>
                                                <td>Supplier's Invoice Detail</td>
                                                <td id='supplier_inv_detail'>TI/21-22/204 dated 12 Oct 2021</td>
                                            </tr>
                                            <tr>
                                                <th scope="row">3</th>
                                                <td>Manufacturer Name</td>
                                                <td id='manufacturer'>All India Institute of Medical Sciences
                                                    Bibinagar, Hyderabad</td>
                                            </tr>
                                            <tr>
                                                <th scope="row">4</th>
                                                <td>Name of the item supplied</td>
                                                <td id='item'>Refrigerator (300-380L). Make : Yorco, Model: YSI-580
                                                </td>
                                            </tr>
                                            <tr>
                                                <th scope="row">5</th>
                                                <td>Quantity Supplied</td>
                                                <td id='qty'>01 No </td>
                                            </tr>
                                            <tr>
                                                <th scope="row">6</th>
                                                <td>Date of Receipt by the Consignee</td>
                                                <td id='receipt_date'>20 Dec 2021 </td>
                                            </tr>
                                            <tr>
                                                <th scope="row">7</th>
                                                <td>Name and designation of Authorized
                                                    Representative of Consignee</td>
                                                <td id='consignee_authorized_representative'> </td>
                                            </tr>
                                            <tr>
                                                <th scope="row">8</th>
                                                <td>Signature of Authorized Representative
                                                    of Consignee with date</td>
                                                <td id='consignee_authorized_representative_sign'> </td>
                                            </tr>
                                            <tr>
                                                <th scope="row">9</th>
                                                <td>Seal of the Consignee</td>
                                                <td id='consignee_seal'> </td>
                                            </tr>
                                        </tbody>
                                    </table>
                                </div>
                                <div class="d-flex align-items-center justify-content-between w-100">
                                    <div class="consignment">
                                        <h4>Department</h4>
                                        <p id='department'></p>
                                    </div>
                                    <div class="consignment consignment d-flex flex-column align-items-end">
                                        <h4>Superintendent</h4>
                                        <p id='superintendent'>AIIMS Bibinagar</p>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="modal-footer">
                            <div class="d-flex align-items-center justify-content-end w-100">
                                <span id='download-challan'></span>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        <?php $__env->stopSection(); ?>
        <?php $__env->startSection('scripts'); ?>
            <script src="<?php echo e(URL::to('assets/js/buyernew.js')); ?>"></script>
            <script src="<?php echo e(URL::to('assets/calender/calendar.min.js')); ?>"></script>
            <script>
//                <!--     OTP auto tabing script          -->
    
      function getCodeBoxElement(index) {
        return document.getElementById('otp' + index);
      }
      function onKeyUpEvent(index, event) {
        const eventCode = event.which || event.keyCode;
        if (getCodeBoxElement(index).value.length === 1) {
          if (index !== 6) {
            getCodeBoxElement(index+ 1).focus();
          } else {
            getCodeBoxElement(index).blur();
            // Submit code
            console.log('submit code ');
          }
        }
        if (eventCode === 8 && index !== 1) {
          getCodeBoxElement(index - 1).focus();
        }
      }
      function onFocusEvent(index) {
        for (item = 1; item < index; item++) {
          const currentElement = getCodeBoxElement(item);
          if (!currentElement.value) {
              currentElement.focus();
              break;
          }
        }
      }
        
    
     document.querySelectorAll('input[type="number"]').forEach(input =>{
         input.oninput = () =>{
             if(input.value.length > input.maxLength) input.value = input.value.slice(0, input.maxLength);
         };
     }) ;  
        
        
        
        
        
        
        
        
        
        
 $(".modal").on('shown.bs.modal', function () {
    $(this).find("#otp1").focus();
});   
    

$(function() {

$('#buyer_filter').change(function() {   

var $select = $(this);
if ($select.val() == 'all') {
  // No filter selected.  Show all categories
  $('.js-category-filterable').show();
  //$('.js-current-category').text('All');
} else {
    var x=0;
  $('.js-category-filterable').each(function() {
    if ($(this).data('category') == $select.val()) {  
       x=1;
      $(this).show();
    } else {
      $(this).hide();
      x=0;
     
    }

    if(x==0){
        $(".not").css("display","block");
    }
    else{
        $(".not").css("display","none");  
    }
  });
  //$('.js-current-category').text( $select.find('option:selected').text() );
}
// Reset select box so it's easier to use repeatedly.
//$select.val('');
});

});
 function downloadpdf(oid) {
                    window.location = baseurl + 'generate-pdf?id=' + oid;
                }
                $(document).ready(function() {

                    

                       //Resend OTP
                       $('#resend').on('click', function(event) {
                        $(".pageloader").show();
                        var data = {
                            _token: $('#token_po').val()
                        }
                        $.ajax({
                            url: baseurl + 'sendOTP',
                            type: "POST",
                            data: data,
                            success: function(res) {
                                if (res == true) {
                                    $(".pageloader").hide();
                                    swal({
                                        title: "",
                                        text: "OTP send to your registered Phone Number",
                                        type: "success",
                                        showCancelButton: false,
                                        dangerMode: false,
                                        confirmButtonText: 'OK'
                                    }, function() {
                                        $('#approve').modal({
                                            backdrop: 'static',
                                            keyboard: false
                                        });
                                    })
                                } else {
                                    $(".pageloader").hide();
                                    swal("", "Please try again", "warning");
                                }
                            }
                        });
                    });









                    $('#inspection_date').Zebra_DatePicker({
                        format: 'd-m-Y',
                        direction: 1
                    });
                      //OTP VERIFICATION
                      $('#otpverify').on('click', function(event) {
                        event.preventDefault();
                        var preorder_id_pop = $("#preorder_id_pop").val();
                        var otp = $('#otp1').val() + $('#otp2').val() + $('#otp3').val() + $('#otp4').val() + $(
                            '#otp5').val() + $('#otp6').val();
                        if (($('#otp1').val() == '') && ($('#otp2').val() == '') && ($('#otp3').val() == '') && ($(
                                '#otp4').val() == '') && ($('#otp5').val() == '') && ($('#otp6').val() == '')) {
                            swal("", "Please Enter a valid OTP", "warning");
                        } else {
                            var data = {
                                _token: $('#token_po').val(),
                                 otp: otp,
                                 preorder_id_pop:preorder_id_pop
                            }
                            $.ajax({
                                url: baseurl + 'verifyotp_chellan',
                                type: "POST",
                                data: data,
                                success: function(res) {
                                    if (res == '1') {
                                        $('#generate').modal('hide');
                                        swal({
                                            title: "",
                                            text: "OTP is verified successfully",
                                            type: "success",
                                        }, function() {
                                            window.location = baseurl + 'buyers/equipment_status/'+preorder_id_pop;

                                        });
                                    }
                                else {
                                        swal("", "Please Enter a valid OTP", "warning");
                                        $('#otp1').val('');
                                        $('#otp2').val('');
                                        $('#otp3').val('');
                                        $('#otp4').val('');
                                        $('#otp5').val('');
                                        $('#otp6').val('');
                                    }
                                }
                            });
                        }
                    });
                    $('.generatechellan').on('click', function() {
                        if (
                            <?php if(Auth::user()->signature == null): ?>
                                true
                            <?php else: ?>
                                false
                            <?php endif; ?> ) {
                            swal({
                                title: "",
                                text: "You need to update your profile and signature before you upload the challan",
                                type: "warning",
                            }, function() {
                                window.location = baseurl + 'userprofile/';
                            });
                        } 
                        else {

                            var preorder_id = $(this).data("preorderid");
                            $("#preorder_id_pop").val(preorder_id);
    $(".pageloader").show();
    var data = {
        _token: $('#token_po').val()
    }
                    $.ajax({
                        url: baseurl + 'sendOTP',
                        type: "POST",
                        data: data,
                        success: function(res) {
                            if (res == true) {
                                $(".pageloader").hide();
                                swal({
                                    title: "",
                                    text: "OTP send to your registered Phone Number",
                                    type: "success",
                                    showCancelButton: false,
                                    dangerMode: false,
                                    confirmButtonText: 'OK'
                                }, function() {
                                    $('#generate').modal({
                                        backdrop: 'static',
                                        keyboard: false
                                    });
                                })
                            } else {
                                $(".pageloader").hide();
                                swal("", "Please try again", "warning");
                            }
                        }
                    });
}
        });
     });
                <?php if(Session::has('message')): ?>
                    swal({
                        title: "",
                        text: "<?php echo e(Session::get('message')); ?>",
                        type: "success",
                        showCancelButton: false,
                        dangerMode: false,
                        confirmButtonText: 'OK',
                    });
                <?php endif; ?>
                <?php if(Session::has('errormessage')): ?>
                    swal({
                        title: "",
                        text: "<?php echo e(Session::get('errormessage')); ?>",
                        type: "error",
                        showCancelButton: false,
                        dangerMode: true,
                        confirmButtonText: 'OK',
                    });
                <?php endif; ?>
            </script>
            <script type="text/javascript">
                var config = `
function selectDate(date) {
  $('#calendar-wrapper').updateCalendarOptions({
    date: date
  });
  console.log(calendar.getSelectedDate());
}
var defaultConfig = {
  weekDayLength: 1,
  date: '08/05/2021',
  onClickDate: selectDate,
  showYearDropdown: true,
  startOnMonday: false,
};
var calendar = $('#calendar-wrapper').calendar(defaultConfig);
console.log(calendar.getSelectedDate());
`;
                eval(config);
                // const flask = new CodeFlask('#editor', {
                //     language: 'js',
                //     lineNumbers: true
                // });
                // flask.updateCode(config);
                // flask.onUpdate((code) => {
                //     try {
                //         eval(code);
                //     } catch (e) {}
                // });
            </script>
            <script>
                function generateChallan(dataId) {
                    $(".pageloader").show();
                    $.ajax({
                        type: "POST",
                        dataType: "json",
                        url: "<?php echo e(url('buyers/generate-challan')); ?>",
                        data: {
                            id: dataId,
                            _token: '<?php echo e(csrf_token()); ?>'
                        },
                        success: function(response) {
                            console.log(response);
                            if (response.status == true) {
                                $(".pageloader").hide();
                                swal({
                                    title: "",
                                    text: "Sucessfully Generated Chellan",
                                    type: "success",
                                }, function() {

                                    window.location = baseurl + 'buyers/equipment_status/';

                                });


                            }

                        },
                        error: function(request, status, error) {
                            console.log("ajax call went wrong:" + request.responseText);
                        }
                    });
                }

                function printChallan(id) {
                    var getMyFrame = document.getElementById(id);
                    getMyFrame.focus();
                    getMyFrame.contentWindow.print();
                }
            </script>
            <script type="text/javascript" charset="utf8"
                src="https://cdnjs.cloudflare.com/ajax/libs/jsbarcode/3.5.9/JsBarcode.all.min.js"></script>
            <script type="text/javascript">
                function closebar() {
                    $('#exampleModal').modal('hide');
                }

                function generatebarcode(data) {
                    $('#exampleModal').modal('show');
                    $('#barcode').JsBarcode(data, {
                        width: 1,
                        height: 40
                    });

                }

                $("#printBtn").click(function() {
                    var divToPrint = document.getElementById('demo');

                    var newWin = window.open('', 'Print-Window');

                    newWin.document.open();

                    newWin.document.write('<html><body onload="window.print()">' + divToPrint.innerHTML + '</body></html>');

                    newWin.document.close();

                    setTimeout(function() {
                        newWin.close();
                    }, 10);


                });
            </script>
        <!--     OTP auto tabing script          -->
    <script>
      function getCodeBoxElement(index) {
        return document.getElementById('otp' + index);
      }
      function onKeyUpEvent(index, event) {
        const eventCode = event.which || event.keyCode;
        if (getCodeBoxElement(index).value.length === 1) {
          if (index !== 6) {
            getCodeBoxElement(index+ 1).focus();
          } else {
            getCodeBoxElement(index).blur();
            // Submit code
            console.log('submit code ');
          }
        }
        if (eventCode === 8 && index !== 1) {
          getCodeBoxElement(index - 1).focus();
        }
      }
      function onFocusEvent(index) {
        for (item = 1; item < index; item++) {
          const currentElement = getCodeBoxElement(item);
          if (!currentElement.value) {
              currentElement.focus();
              break;
          }
        }
      }
        
    
     document.querySelectorAll('input[type="number"]').forEach(input =>{
         input.oninput = () =>{
             if(input.value.length > input.maxLength) input.value = input.value.slice(0, input.maxLength);
         };
     }) ;  
        
        
        
        
        
        
        
        
        
        
 $(".modal").on('shown.bs.modal', function () {
    $(this).find("#otp1").focus();
});   
        
        
    </script>
        <?php $__env->stopSection(); ?>

<?php echo $__env->make('layouts.main', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH /home/meddbot/public_html/resources/views/buyers/equipment_status.blade.php ENDPATH**/ ?>