<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')); ?>">

<?php $__env->startSection('content'); ?>
<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-lg-12">
                        <div class=" po-sum" style="border-radius: 15px;">
                             <div class="boxings po-sum" style="border-radius: 15px;">
                                  
                                    
                                  <div class="purchase-order">
                                     <div class="order-id d-flex justify-content-end">
                                         <h4>Order ID <span class="green-order" ><?php echo e($details->po_id); ?></span></h4>
                                     </div>
                                     <div class="order-id d-flex justify-content-end">
                                  <?php if($details->proc_dispatch == 1): ?>
                                  <p style="color:red;">Status:
                                      Dispatched  from Procurement
                                  </p>
                                  <?php elseif($details->proc_dispatch == 2): ?>
                                  <p style="color:red;">Status:
                                     Received
                                  </p>
                                  <?php else: ?>
                                     
                                  <?php endif; ?>
                              </p>

                            </div>

                                     <div class="product_details-grd">
                                         <div class="product-image">
                                            <?php if(!empty($details->photo)): ?>
                                            <img src="<?php echo e(url('product_files')); ?>/<?php echo e($details->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($details->product_name)); ?></h4></li>
                                                 <li><label class="p-o-label">Product Code</label>: <span><?php echo e($details->product_code); ?></span></li>
                                                 <li><label class="p-o-label">Equipment Id</label>: <span><?php echo e($details->id); ?></span></li>
                                                 <li><label class="p-o-label">Tender Number</label>: <span><?php echo e($details->tender_number); ?></span></li>
                                                 <li><label class="p-o-label">Delivery Days</label>: <span><?php echo e($details->delivery_days); ?> days</span></li>
                                                 <li><label class="p-o-label">Price</label>: <span><?php echo e($details->price); ?> INR</span></li>
                                                
                                             </ul>
            
                                         <!-- Barcode Modal -->

                                             <?php if(($details->proc_dispatch == 1)||($details->proc_dispatch == 2)): ?>

                                             <h4 class="product-name">Dispatched Details</h4>
                                             <ul>
                                              
                                              <li><label class="p-o-label">Vehicle Number</label>: <span><?php echo e($details->proc_dispatch_vehicleno); ?></span></li>
                                              <li><label class="p-o-label">Dispatched Date & Time</label>: <span><?php echo e($details->issue_datetime); ?></span></li>
                                             </ul>
                                             <?php endif; ?>
                                              
                                         </div>
                                     </div>
                                     <div class="product-description">
                                         <label class="p-o-label" >Product Description</label>
                                         <p><?php echo e(ucfirst($details->product_description)); ?></p>
                                         <p> <button class="btn medd-buttons medd-blue rounded"
                                          onclick="generatebarcode('<?php echo e($details->barcode); ?>')">View Barcode</button></p>
                                     </div>

                                    
                                 </div>  
                           </div>
              
 <div class="modal fade  new-modal" id="ins-fail" 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="alert-popup">
              <div class="img-badge d-flex justify-content-center">
                   <img src="<?php echo e(url('assets/images/fail.svg')); ?>">
                </div>
              <h4 class="text-center" >Inventory Product Rejected</h4> 
              <input type="hidden" name="preorderid_fail" id="preorderid_fail">
              <input type="hidden" name="orderid_fail" id="orderid_fail">
              <input type="hidden" name="vendorid_fail" id="vendorid_fail">
            </div>
        </div>
          <div class="modal-footer">
              <div class="d-flex align-items-center justify-content-end w-100">
                   <button style="min-width: 120px;"  class="btn medd-buttons medd-blue rounded" onclick="inspectionfail_submits()">OK</button>
              </div>
          </div>
      </div>
    </div>
  </div> 
                            
 <div class="modal fade  new-modal" id="ins-pass" 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="alert-popup">
              <div class="img-badge d-flex justify-content-center">
                   <img src="<?php echo e(url('assets/images/success.svg')); ?>">
                </div>
              <h4 class="text-center" >Product added to Inventory Product Accepted</h4> 
            </div>
        </div>
          <div class="modal-footer">
              <div class="d-flex align-items-center justify-content-end w-100">
                   <button style="min-width: 120px;" data-dismiss="modal" class="btn medd-buttons medd-blue rounded">OK</button>
              </div>
          </div>
      </div>
    </div>
  </div> 

         <!-- 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>

  <!-- Modal -->
<div class="modal fade  new-modal" id="approve" 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;?>">

            <input type="hidden" name="order_id" id="order_id" value="">
            <input type="hidden" name="preorder_id" id="preorder_id" value="">
            <input type="hidden" name="vendor_id" id="vendor_id" value="">    
            <div class="otp-dflex" id="otp-screen">
              <input type="text" placeholder="0" maxlength="1" id="otp1">
              <input type="text" placeholder="0" maxlength="1" id="otp2">
              <input type="text" placeholder="0" maxlength="1" id="otp3">
              <input type="text" placeholder="0" maxlength="1" id="otp4">
              <input type="text" placeholder="0" maxlength="1" id="otp5">
              <input type="text" placeholder="0" maxlength="1" id="otp6">
            </div>
            
          </div>
          <div class="medd-pop-buttons">
            <button class="btn medd-blue medd-buttons" id="otpverify" >Verify</button>  
          </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 type="text/javascript" charset="utf8"
src="https://cdnjs.cloudflare.com/ajax/libs/jsbarcode/3.5.9/JsBarcode.all.min.js"></script>
<script> 

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

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

                }
$(document).ready(function() {

//Print Button
  $("#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);


                });

  
    //OTP VERIFICATION
   $('#otpverify').on('click', function(event) {
        var preorderid= $("#preorder_id").val();  
         event.preventDefault();
        if(($('#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 otp =  $('#otp1').val()+$('#otp2').val()+$('#otp3').val()+$('#otp4').val()+$('#otp5').val()+$('#otp6').val();
                    var APP_URL = <?php echo json_encode(url('/verifyotpuser_inspection')); ?> ;
                    var saveData = $.ajax({
                    type: 'GET',
                    url: APP_URL+'/'+email+'/'+phoneno+'/'+otp+'/'+preorderid,
                    data: { email: email,phoneno: phoneno, _token: '<?php echo e(csrf_token()); ?>',preorderid:preorderid},
                    dataType: "text",
                        success: function(resultData) {
                          if(resultData == '1'){

                              swal({
                                title: "",
                                text: "OTP is verified successfully",
                                type: "success",
                              }, function () {
                                window.location = baseurl + 'buyers/inspection_status/';                            
                              });

                              }else if(resultData == '0'){
                              swal("", "Please Enter a valid OTP", "warning");
                                //alert('Please Enter a valid otp');
                              }else{

                              swal("", "Please Enter a valid OTP", "warning");
                                // alert('Please Enter a valid otp');
                              }
                         
                    }
                    });
        
       }


                 
    });

    $('#approvepo').on('click', function() {
                $(".pageloader").show();

                 var oid=$(this).data("orderid");
                 var preorderid =$(this).data("preorderid");
                 var vendorid   =$(this).data("vendorid");


                 $("#orderid").val(oid);
                 $("#preorder_id").val(preorderid);
                 $("#vendorid").val(vendorid);

                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')); ?> ;
                var saveData = $.ajax({
                type: 'GET',
                url: APP_URL+'/'+email+'/'+phoneno+'/'+otp,
                data: { email: email,phoneno: phoneno,otp: otp, _token: '<?php echo e(csrf_token()); ?>' },
                dataType: "text",
                    success: function(resultData) {
                        console.log(resultData);
                        /*if(resultData == 'success'){
                            alert('success');
                        }*/
                    }
                });
                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();

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


            });

});

<?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>
    $(document).ready(function(){
    $('.otp-dflex input').on("input", function(){
        if($(this).val().length==$(this).attr("maxlength")){
            $(this).next().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/inspection_details.blade.php ENDPATH**/ ?>