<!DOCTYPE html>
<html lang="zxx">
<head>
    <title>Slip</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta charset="UTF-8">

    <!-- External CSS libraries -->
    <link type="text/css" rel="stylesheet" href="main/assets/css/bootstrap.min.css">
    <link type="text/css" rel="stylesheet" href="main/assets/fonts/font-awesome/css/font-awesome.min.css">

    <!-- Favicon icon -->
    <link rel="shortcut icon" href="images/logos/small png logo.png" type="image/x-icon" >

    <!-- Google fonts -->
    <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
    <link rel="stylesheet" type="text/css" href="https://fonts.googleapis.com/css?family=Poppins:100,200,300,400,500,600,700,800,900">

    <!-- Custom Stylesheet -->
    <link type="text/css" rel="stylesheet" href="main/assets/css/style.css">
       <script type="text/javascript">
            var testDivElement = document.getElementById('someHtml');

            function savePDF() {
                var imgData;
                html2canvas($("#someHtml"), {
                    useCORS: true,
                    onrendered: function (canvas) {
                        imgData = canvas.toDataURL(
                           'image/png');
                        var doc = new jsPDF('p', 'pt', 'a4');
                        doc.addImage(imgData, 'PNG', 10, 10);
                        doc.save('sample-file.pdf');
                        window.open(imgData);
                    }
                });
            }


        </script>
</head>
<body>


<!-- Invoice 1 start -->
<div class="invoice-1 invoice-content">
    <div class="container">
        <div class="row">
            <div class="col-lg-12">
                <div class="invoice-inner clearfix">
                    <div class="invoice-info clearfix" id="invoice_wrapper">
                        <div class="invoice-headar">
                            <div class="row g-0">
                                <div class="col-sm-6">
                                    <div class="invoice-logo">
                                        <!-- logo started -->
                                        <!--<div class="logo">
                                            <img src="images/logos/PIRKANI-BROTHERS-logo.png" alt="logo">
                                        </div>-->
                                        <div class="logo">
                                         <img style="height:70px;" src="images/logos/PIRKANI-BROTHERS-logo.png" alt="logo">
                                         </div>
                                        <!-- logo ended -->
                                    </div>
                                </div>
                                  <?php
          
          $id =$_GET['id'];
    include('includes/config.php');
      $no=0;
     $results = mysqli_query($con, "SELECT * FROM `shipment` as s JOIN materials as m ON s.material_id = m.m_id JOIN vendors as v ON s.vendor_id = v.v_id JOIN measurements as ms ON s.measure_id = ms.ms_id JOIN vehicles as vs ON ms.vehicle_id = vs.vehicle_id join user_info as u ON s.user_id = u.user_id
 WHERE s.sh_id='$id' ORDER BY s.sh_id ASC");
     
       while($rows = mysqli_fetch_assoc($results)) {
       $no++        
          
  ?>      
                                <div  class="col-sm-6 invoice-id">
                                    <div  class="info">
                                      
                                        <h1 class="color-white inv-header-1">Slip</h1>
                                        <p class="color-white mb-1">Slip Number <span>#<?php echo $rows['slip_no']; ?></span></p>
                                        <p class="color-white mb-0">Date <span><?php
                     $ordate = $rows['s_date']; $ordates =date("D-M-j-Y",strtotime($ordate)); echo $ordates; ?></span></p>
                                        
                                   
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="invoice-top">
                            <div class="row">
                                <div class="col-sm-6">
                                    <div class="invoice-number mb-30">
                                        <h4 class="inv-title-1">Invoice To</h4>
                                        <h2 class="name mb-10">Vendor <?php echo $rows['company_name']; ?></h2>
                                        <p class="invo-addr-1">
                                            <!--Theme Vessel <br/>
                                            info@themevessel.com <br/>-->
                                          Site Address <?php echo $rows['company_address']; ?> <br/>
                                        </p>
                                    </div>
                                </div>
                                <div class="col-sm-6">
                                   <!-- <div class="invoice-number mb-30">
                                        <div class="invoice-number-inner">
                                            <h4 class="inv-title-1">Invoice From</h4>
                                            <h2 class="name mb-10">Animas Roky</h2>
                                            <p class="invo-addr-1">
                                                Apexo Inc  <br/>
                                                billing@apexo.com <br/>
                                                169 Teroghoria, Bangladesh <br/>
                                            </p>
                                        </div>
                                    </div>-->
                                </div>
                            </div>
                        </div>
                        <?php } ?>
                        <div class="invoice-center">
                            <div class="table-responsive">
                                <table class="table mb-0 table-striped invoice-table">
                                    <thead class="bg-active">
                                    <tr class="tr">
                                        <th>No.</th>
                                        <th class="pl0 text-start">Item Description</th>
                                        <th class="text-center">Price</th>
                                        <th class="text-center">Quantity</th>
                                        <th class="text-end">Amount</th>
                                    </tr>
                                    </thead>
                                    <tbody>
                                         
  <?php
          
             $id =$_GET['id'];
    include('includes/config.php');
      $no=0;
  
   $result = mysqli_query($con, "SELECT * FROM `shipment` as s JOIN materials as m ON s.material_id = m.m_id JOIN vendors as v ON s.vendor_id = v.v_id JOIN measurements as ms ON s.measure_id = ms.ms_id JOIN vehicles as vs ON ms.vehicle_id = vs.vehicle_id join user_info as u ON s.user_id = u.user_id
 WHERE s.sh_id='$id' ORDER BY s.sh_id ASC");
     

       while($row = mysqli_fetch_assoc($result)) {
       $no++;        
          $delqty = $row['del_qty'];
          $customer_id =$row['customer_id'];
          
          $saleqty = $row['d_qty'];
           $rate  =$row['sale_rate']; 
           $total = $saleqty * $rate;
           $subtotal +=$total;
           $prebalance = $row['invoice_previous_balance'];
           
           $grandtotal = $subtotal +$prebalance;
           
           $fmt = new NumberFormatter( 'de_pkr', NumberFormatter::CURRENCY );
           $subtotalformat =$fmt->formatCurrency($subtotal, "PKR")."\n";
           $prebalanceformat = $fmt->formatCurrency($prebalance, "PKR")."\n";
           $grandtotalformat= $fmt->formatCurrency($grandtotal, "PKR")."\n";
  ?>               
  
                                    <tr class="tr">
                                        <td>
                                            <div class="item-desc-1">
                                                <span>01</span>
                                            </div>
                                        </td>
                                        <td class="pl0"><?php echo $row['m_name']; ?></td>
                                        <td class="text-center"><?php echo $row['s_rate']; ?></td>
                                        <td class="text-center"><?php echo $row['qty']; ?></td>
                                        <td class="text-end"><?php echo  $row['ship_total'];?></td>
                                        
                                   
                                    </tr>
                                  
                                 <?php } ?>
                                   
                                  <!--  <tr class="tr2">
                                        <td></td>
                                        <td></td>
                                        <td></td>
                                        <td class="text-center">Tax</td>
                                        <td class="text-end">$85.99</td>
                                    </tr>
                                    <tr class="tr2">
                                        <td></td>
                                        <td></td>
                                        <td></td>
                                        <td class="text-center f-w-600 active-color">Grand Total</td>
                                        <td class="f-w-600 text-end active-color">$795.99</td>
                                    </tr>-->
                                    </tbody>
                                </table>
                            </div>
                        </div>
                        <div class="invoice-bottom">
                            <div class="row">
                                <div class="col-lg-6 col-md-8 col-sm-7">
                                    <div class="mb-30 dear-client">
                                        <!--<h3 class="inv-title-1">Terms & Conditions</h3>
                                        <p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been typesetting industry. Lorem Ipsum</p>
                                    -->
                                    </div>
                                </div>
                                <div class="col-lg-6 col-md-4 col-sm-5">
                                    <div class="mb-30 payment-method">
                                        <!--<h3 class="inv-title-1">Payment Method</h3>
                                        <ul class="payment-method-list-1 text-14">
                                            <li><strong>Account No:</strong> 00 123 647 840</li>
                                            <li><strong>Account Name:</strong> Jhon Doe</li>
                                            <li><strong>Branch Name:</strong> xyz</li>
                                        </ul>-->
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="invoice-contact clearfix">
                            <div class="row g-0">
                                <div class="col-lg-9 col-md-11 col-sm-12">
                                    <div class="contact-info">
                                        <!--<a href="tel:+55-4XX-634-7071"><i class="fa fa-phone"></i> +00 123 647 840</a>
                                        <a href="tel:info@themevessel.com"><i class="fa fa-envelope"></i> info@themevessel.com</a>
                                        <a href="tel:info@themevessel.com" class="mr-0 d-none-580"><i class="fa fa-map-marker"></i> 169 Teroghoria, Bangladesh</a>
                                   -->
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="invoice-btn-section clearfix d-print-none">
                        <a href="javascript:window.print()" class="btn btn-lg btn-print">
                            <i class="fa fa-print"></i> Print Invoice
                        </a>
                        <a id="invoice_download_btn" class="btn btn-lg btn-download btn-theme">
                            <i class="fa fa-download"></i> Download Invoice
                        </a>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<!-- Invoice 1 end -->
   


<script src="main/assets/js/jspdf.min.js"></script>
<script src="main/assets/js/html2canvas.js"></script>
<script src="main/assets/js/app.js"></script>
</body>
</html>
