<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;
    }

    span.no-d {
        display: none;
    }
</style>

<?php $__env->startSection('content'); ?>
    <?php $printId = 1; ?>
    <div class="common-content">
        <div class="page-content">
            <div class="page-heading">
                <div class="headings">
                    <h6>Purchase Order Summary</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-12">
                        <div class="boxings po-sum" style="border-radius: 15px;">
                            <div class="tab-content meddbot-tabcontent">
                                <div id="home" class="tab-pane fade in active show">
                                    <?php if(count($po_productlist) != 0): ?>
                                        <?php $__currentLoopData = $po_productlist; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $key => $summary): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                            <div class="purchase-order js-category-filterable"
                                                data-category="<?php echo $summary->individual_buyerid; ?>">
                                                <div class="order-id d-flex justify-content-end">
                                                    <h4>Order ID <span class="green-order"><?php echo e($summary->po_id); ?></span>
                                                    </h4>
                                                </div>
                                                <div class="product_details-grd">
                                                    <div class="product-image">
                                                        <?php if(!empty($summary->photo)): ?>
                                                            <img src="<?php echo e(url('product_files')); ?>/<?php echo e($summary->photo); ?>">
                                                        <?php else: ?>
                                                            <img src="<?php echo e(url('assets/images/1200px-No-Image-Placeholder.svg.png')); ?>">
                                                        <?php endif; ?>
                                                    </div>
                                                    <div class="product-details">
                                                        <ul>
                                                            <li>
                                                                <h4 class="product-name">
                                                                    <?php echo e(ucfirst($summary->product_name)); ?></h4>
                                                            </li>
                                                            </h4>
                                                            </li>
                                                            <li><label class="p-o-label">Product Code</label>:
                                                                <span><?php echo e($summary->product_code); ?></span>
                                                            </li>
                                                            <li><label class="p-o-label">Delivery Days</label>:
                                                                <span><?php echo e($summary->delivery_days); ?></span>
                                                            </li>
                                                            <li><label class="p-o-label">Quantity</label>:
                                                                <span><?php echo e($summary->quantity); ?></span>
                                                            </li>
                                                            <li><label class="p-o-label">Dispatch To</label>:
                                                                <span><?php if($summary->dispatch_to==1): ?> Single <?php else: ?> Batch <?php endif; ?></span>
                                                            </li>
                                                            <li><label class="p-o-label">Price per quantity</label>:
                                                                <span><?php echo e($summary->price); ?> INR</span>
                                                            </li>
                                                            <li><label class="p-o-label">Tax</label>:
                                                                <span><?php echo e($summary->tax); ?>%</span>
                                                            </li>
                                                            <li><label class="p-o-label">Total Price (Including
                                                                    tax)</label>:
                                                                <span><?php echo e(number_format(($summary->price + $summary->price * ($summary->tax / 100)) * $summary->quantity, 2)); ?>

                                                                    INR</span>
                                                            </li>
                                                        </ul>
                                                   
                                                </div>
                                                <div class="product-description">
                                                    <label class="p-o-label">Product Description</label>
                                                    <p><?php echo e($summary->product_description); ?></p>
                                                </div>

                                                <p>
                                                <?php
                                                        $processstatus = App\Helpers\CustomHelper::dispatch_process($summary->id);
                                                ?>
                                     <?php if($summary->dispatch_to==1): ?>


                                                    <?php if($summary->quantity ==1): ?>


                                                            <?php if($processstatus['process_completed'] !=0): ?>
                                                            <span class="p_completed" style="color:green">Process Completed</span>
                                                            
                                                                        <?php if($processstatus['paymentapproved']!=0): ?>

                                                                        <span class="payment_approved" style="color:green">Payment Approved</span>
                    
                                                                        <?php else: ?>
                    
                                                                        <span class="payment_pending" style="color:red">Payment Approved Pending</span>
                    
                                                                        <?php endif; ?>

                                                            <?php else: ?>
                                                            <span class="p_pending" style="color:red">Process Pending</span>
                                                            <?php endif; ?>


                                                    <?php else: ?>

                                                            <span class="p_completed" style="color:green">Process Completed:<b class="ml-1" ><?php echo e($processstatus['process_completed']); ?></b></span>
                                                    <span class="p_pending" style="color:red">Process Pending:<b class="ml-1" ><?php echo e($processstatus['process_pending']); ?></b></span>

                                                    <span class="payment_approved" style="color:green">Payment Approved:<b class="ml-1" ><?php echo e($processstatus['paymentapproved']); ?></b></span>

                                                    <span class="payment_pending" style="color:red">Payment Approved Pending:<b class="ml-1" ><?php echo e($summary->quantity - $processstatus['paymentapproved']); ?></b></span>

                                                    <?php endif; ?>


                                    <?php else: ?>

                                                    <?php if($processstatus['process_completed'] !=0): ?>
                                                    <span class="p_completed" style="color:green">Process Completed</span>
                                                            <?php if($processstatus['paymentapproved']!=0): ?>

                                                            <span class="payment_approved" style="color:green">Payment Approved</span>
        
                                                            <?php else: ?>
        
                                                            <span class="payment_pending" style="color:red">Payment Approved Pending</span>

                                                           
        
                                                            <?php endif; ?>

                                                  <?php else: ?>
                                                  <span class="p_pending" style="color:red">Process Pending</span>
                                                  <?php endif; ?>

                                                <?php endif; ?>

                                                </p>





                                            </div>
                                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                    <?php else: ?>
                                        <div class="col-lg-12 col-md-6 col-sm-12 col-xs-12">
                                            <div class="product-display">
                                                <ul>
                                                    <li>
                                                        <div class="details">
                                                            <div>
                                                                <h6>
                                                                    No Products available
                                                                </h6>
                                                            </div>
                                                        </div>
                                                    </li>
                                                </ul>
                                            </div>
                                        </div>
                                    <?php endif; ?>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            
            <div class="modal new-modal fade" id="barcodeModal" tabindex="-1" role="dialog"
                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">×</span>
                            </button>
                            <div class="otp">
                                <h4>BARCODE</h4>
                                <p class="mb-0">Select Barcode</p>
                                <div class="modal-body imageArea" id="demo">
                                    <div class="form-group">
                                        <select class="form-control" id='barcode_view_options' onchange="renderBarcode()"></select>
                                    </div>
                                    <div id='print_barcode'>
                                        <img style="text-align: center;    border: 1px solid #ccc;     padding: 48px 2px;   margin: 0 auto;display: block;"
                                        id="barcode" />
                                    </div>
                                </div>
                            </div>
                            <div class="medd-pop-buttons justify-content-center">
                                <input type="hidden" name="order_id" id="order_id" value="">
                                <button class="btn medd-blue medd-buttons" id="printBtn">Print</button>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            
            
            <div class="modal new-modal fade" id="inProductionModal" tabindex="-1" role="dialog"
                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">×</span>
                            </button>
                            <div class="otp">
                                <h4>BARCODE</h4>
                                <p class="mb-0">Select barcode</p>
                                <div class="modal-body imageArea" id="demo">
                                    <div class="form-group">
                                        <select class="form-control" id='in_production_options' onchange="renderBarcode()"></select>
                                    </div>
                                </div>
                            </div>
                            <div class="medd-pop-buttons justify-content-center">
                                <input type="hidden" name="order_id" id="order_id" value="">
                                <button class="btn medd-blue medd-buttons" id="printBtn">Print</button>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            

            
        <div class="modal new-modal fade" id="equipmentModal" tabindex="-1" role="dialog"
            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">×</span>
                        </button>
                        <div class="otp">
                           
                            <p class="mb-0">Select barcode</p>
                            <div class="modal-body imageArea" id="demo">
                                <div class="form-group">
                                    <select class="form-control" id='barcode_view_options_sold' onchange="renderBarcode()"></select>
                                </div>
                            </div>
                        </div>
                        <div class="medd-pop-buttons justify-content-center">
                            <input type="hidden" name="order_id" id="order_id" value="">
                            <button class="btn medd-blue medd-buttons" id="equipment">Equipment Status</button>
                        </div>
                    </div>
                </div>
            </div>
        </div>

        <?php $__env->stopSection(); ?>
        <?php $__env->startSection('scripts'); ?>
            <script type="text/javascript" charset="utf8"
                src="https://cdnjs.cloudflare.com/ajax/libs/jsbarcode/3.5.9/JsBarcode.all.min.js"></script>
            <script src="<?php echo e(URL::to('assets/js/buyernew.js')); ?>"></script>
            <script>
                $(function() {
                    $("#equipment").click(function() {
                        var poproductsitemsid= $("#barcode_view_options_sold").val();
                        var poproductsitemsid= $("#barcode_view_options_sold").val();
                        window.location      = baseurl + 'buyers/equipment_status/' + poproductsitemsid;

                    });



                    
                    $('#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");
                                }
                            });
                        }
                    });
                });
                function downloadpdf(oid) {
                    window.location = baseurl + 'generate-pdf?id=' + oid;
                }

                function renderBarcode() {
                    $('#barcode').JsBarcode(document.getElementById("barcode_view_options").value, {
                        width: 1,
                        height: 40
                    });
                }
                function openInProductionModal(items) {
                    var str = '';
                    for (let item of items) {
                        str += "<option>" + item + "</option>"
                    }
                    document.getElementById("in_production_options").innerHTML = str;
                    $('#inProductionModal').modal({
                        backdrop: 'static',
                        keyboard: false
                    });
                }

                function openEquipmentModal(items){
                    var str = '';
                    for (let item of items) {
                        var arr=item.split('-',2);
                        str += "<option value='"+arr[1]+"'>" + arr[0] + "</option>"
                    }

                    console.log(str);
                    document.getElementById("barcode_view_options_sold").innerHTML = str;
                    //renderBarcode();
                    
                    $('#equipmentModal').modal({
                        backdrop: 'static',
                        keyboard: false
                    });
                }

                function openBarcodeModal(items) {
                    var str = '';
                    for (let item of items) {
                        str += "<option>" + item + "</option>"
                    }
                    document.getElementById("barcode_view_options").innerHTML = str;
                    renderBarcode();
                    $('#barcodeModal').modal({
                        backdrop: 'static',
                        keyboard: false
                    });
                }
                $(document).ready(function() {
                    //OTP VERIFICATION
                    $('#otpverify').on('click', function(event) {
                        var oid = $("#order_id").val();
                        event.preventDefault();
                        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 if (newotp != otp) {
                            $('#otp1').val('');
                            $('#otp2').val('');
                            $('#otp3').val('');
                            $('#otp4').val('');
                            $('#otp5').val('');
                            $('#otp6').val('');
                            swal("", "Please Enter a valid OTP", "warning");
                        } else {
                            var email = $('#email').val();
                            var phoneno = $('#phone_no').val();
                            var APP_URL = <?php echo json_encode(url('/verifyotpuser')); ?>;
                            var saveData = $.ajax({
                                type: 'GET',
                                url: APP_URL + '/' + email + '/' + phoneno + '/' + otp + '/' + oid,
                                data: {
                                    email: email,
                                    phoneno: phoneno,
                                    _token: '<?php echo e(csrf_token()); ?>',
                                    oid: oid
                                },
                                dataType: "text",
                                success: function(resultData) {
                                    swal({
                                        title: "",
                                        text: "OTP is verified successfully",
                                        type: "success",
                                    }, function() {
                                        window.location = baseurl + 'buyers/order_summary/';
                                    });
                                }
                            });
                        }
                    });
                    $('.approvepo').on('click', function() {
                        $(".pageloader").show();
                        var oid = $(this).data("orderid");
                        $("#order_id").val(oid);
                        var email = $('#email').val();
                        var phoneno = $('#phone_no').val();
                        var otp = Math.floor(100000 + Math.random() * 900000);
                        var APP_URL = <?php echo json_encode(url('/setotpuser')); ?>;
                        newotp = otp;
                        var SMS_URL = 'https://www.meddbot.com/twiliosms/';
                        var saveData = $.ajax({
                            type: 'POST',
                            url: SMS_URL,
                            data: {
                                phoneno: phoneno,
                                otp: otp,
                                _token: '<?php echo e(csrf_token()); ?>'
                            },
                            dataType: "text",
                            success: function(resultData) {
                                $(".pageloader").hide();
                                console.log(otp);
                                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
                                    });
                                    $(".pageloader").hide();
                                })
                            }
                        });
                    });
                });
                <?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>
                function generateBarcode(data) {
                    $('#barcode').JsBarcode(data, {
                        width: 1,
                        height: 40
                    });
                    $('#barcodeModal').modal('show');
                }
                $(document).ready(function() {
                    $("#printBtn").click(function() {
                        var divToPrint = document.getElementById('print_barcode');
                        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);
                    });
                });

                function printPdf(id) {
                    var getMyFrame = document.getElementById(id);
                    getMyFrame.focus();
                    getMyFrame.contentWindow.print();
                }
            </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/po_products_accounts.blade.php ENDPATH**/ ?>