<!DOCTYPE html>

<html>

<head>

  <meta http-equiv="content-type" content="text/html; charset=UTF-8">  

  <link rel="icon" type="image/png" sizes="16x16" href="<?php echo site_url()?>/assets/images/favicon.png">

  <title>WB : Entry Print</title>

</head>

<body> 

 <link rel="stylesheet" href="<?php echo site_url();?>assets/css/invoice_print.css"> 

 <style> 

   table { page-break-inside:auto }

   div   { page-break-inside:avoid; } /* This is the key */

   thead { display:table-header-group }

   tfoot { display:table-footer-group } 

   

   table {

    border:none !important;

    border-collapse: collapse; 

    margin: 0 auto;font-size:12px; 

    font-family: Times New Roman !important;

  }
  
  .img{
  width:250px;
  height:100px;
  }



  table td, table th {

    border:none !important;

    border-collapse: collapse;

    line-height: 25px;

    padding-left: 10px;

    padding-right: 10px;

    font-size: 25px !important;

    font-family: Times New Roman !important;

  }

  h1{

    font-size: 18px !important;font-weight: bold;

    font-family: Times New Roman !important;

  }

  h3{

    font-size: 18px !important;font-weight: bold;

    font-family: Times New Roman !important;  

  }

  h5{

    font-size: 18px !important;

    font-family: Times New Roman !important;

  }

  h1,h3,h4,h5{

    margin: 1px !important;

    font-family: Times New Roman !important;

  }

  h5{

    line-height: 1.2;

    font-family: Times New Roman !important;

  }

  .tbl-cap{

    text-align:center;vertical-align:middle;display:table-cell;width: 100%;font-weight: bold; font-size: 22px !important;

    font-family: Times New Roman !important;padding-bottom: 10px;

  }

  @page {     margin: 0 !important; } 

  body{

    font-size: 12px;

  }

  .col {

    border: none !important; 

  } 

  .btn-primary{

    background-color: #ffbf00 !important;

    border-color: #ffbf00 !important;

  }

  .btn-success{

    background-color: #ffbf00 !important;

    border-color: #ffbf00 !important;

  }

  #invoice{

   



  }



  .invoice {

    position: relative;

    background-color: #FFF;

    min-height: 100%;

   

    padding-top: 0px; 

  } 



  .invoice table {

    max-width: 100%;

    border-collapse: collapse;

    border-spacing: 0;

    margin-bottom: 0px;

    table-layout:fixed;



    /*min-height: 1100px;*/

  }



  .invoice table td,.invoice table th {

    padding:5px !important; 



    overflow: hidden; 

    text-overflow: ellipsis; 

    word-wrap: break-word;

  }



  .invoice table thead,th{

    border:none !important;

    text-align: center;

  }

  .invoice table td, table tr,tfoot tr{

    border-left: solid 1px;

    border-right: solid 1px;

  }

  .invoice table th {

    white-space: nowrap;

    font-weight: bold;

    font-size: 16px



  }

  .invoice table tr{

   border:none !important;



 }



 .invoice table td h3 {

  margin: 0;

  font-weight: 400;

  color: #3989c6; 

}



.invoice table .qty,.invoice table .total,.invoice table .unit {

  text-align: left;padding:2px 2px 2px 10px;

  font-size: 20px;

}



.invoice table .no {

  color: black;

  text-align: left;padding:2px 2px 2px 10px;

}





.invoice table .total {

  color: #000000;

}





.invoice table tfoot td {

  background: 0 0;

  white-space: nowrap;

  /* text-align: right; */

  padding: 10px 20px;

}



p{

  /*line-height: 1px !important;*/

}

.invoice table tfoot {

  font-size: 12px;

  line-height: 0rem;

}



.invoice footer {

  max-width: 100%;

  text-align: center;

  color: #777;

  border-top: 1px solid #aaa;

  padding: 8px 0;

}



.col{

  border:none !important;

  padding-left: 15px;

  padding-right: 15px;

}



.invoice:last-child {

  page-break-after: auto;

}

.addr-col{

  padding: 0px !important;

}

@media print{

  body{

    font-size: 22px;

    margin-left: 0px !important;

  }

  .invoice table {

    /*min-height: 900px;*/

  } 

} 

.invoice-pdf table td, .invoice-pdf table th {

  padding:2px;

}

.def_disc{

  display: none !important;

}

.terms_txt1,.terms_txt1 p{

  margin-bottom: 0.1px !important;

  line-height: 1.2 !important;

  /*  font-size: 12px !important;

    font-family: arial !important;*/

  }



  tt1, .terms_txt1 span{

  /*  font-family: arial !important;

    font-size: 12px !important;*/

    line-height: 1.2 !important;

  }

  .hdr-cont{

   font-size: 18px !important;

   font-family: Times New Roman !important;

 }

 .tbl-cont tbody tr td{

  width: 270px;

}

</style>


<div class="invoice" id="data-cont" style="padding-top:10px;margin-top:140px">  

  <div class="row hdr-cont">  

    <div class="col-lg-12 table-responsive" style="min-height: 400px;"> 
	<table width="950px" border="0" cellspacing="0" cellpadding="0" style="margin-left:auto; margin-right:auto;">
  <tr>
    <td style="padding-left:70px"><table width="250px" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td style="text-align:center; vertical-align:bottom; padding-right:25px"><br/><br/><?=$entry['entry_no']?></td>
  </tr>
  <tr>
    <td style="text-align:right; height:80px; vertical-align:bottom;text-transform:capitalize"><?=$entry['veh_no']?></td>
  </tr>
  <tr>
    <td style="text-align:right; height:80px; vertical-align:bottom"><?=$entry['mt_name']?></td>
  </tr>
  <tr>
    <td style="text-align:right; height:100px"><?=$entry['container_no']?></td>
  </tr>
</table>
</td>
    <td valign="top" style="margin-top:170px; padding-left:190px"><table width="450px" border="0" cellspacing="0" cellpadding="0">
	<tr>
    <td style="height:100px;">&nbsp;</td>
  </tr>
  <tr>
    <td style="text-align:right; padding-top:100px; padding-bottom:80px"><?=$entry['tot_wt']?> KG</td>
  </tr>
  <tr>
    <td style="text-align:right; height:60px; padding-bottom:60px"><?=$entry['empty_wt']?> KG</td>
  </tr>
  <tr>
    <td style="text-align:right; height:50px; padding-bottom:60px"><?=$entry['net_wt']?> KG</td>
  </tr>
  <tr>
    <td style="height:35px;">&nbsp;</td>
  </tr>
  <tr>
    <td style="text-align:right; height:50px; font-size:50px; font-weight:bold">Rs <?=$entry['net_amt']?></td>
  </tr>
</table>
</td>
    <td valign="top" style="margin-top:50px;padding-left:130px" width="350px"><table width="100%" border="0" cellspacing="0" cellpadding="0">
	 <tr>
    <td style="height:20px;">&nbsp;</td>
  </tr>
  <tr>
    <td style="text-align:right; height:20px"><?=date('d-m-Y',$entry['entry_date']);?></td>
  </tr>
  <tr>
    <td style="text-align:right; height:20px"><?=date('h:i A',$entry['entry_date']);?></td>
  </tr>
  <tr>
    <td style="text-align:right;"> <?php if($entry['upload1']) { ?> 



             <img class="img" src="<?php echo base_url('uploads/entry/'.$entry['upload1'])?>" alt="" />   

           <?php } ?></td>
  </tr>
  <tr>
    <td style="text-align:right;"> <?php if($entry['upload2']) { ?> 



            <img class="img" src="<?php echo base_url('uploads/entry/'.$entry['upload2'])?>" alt="" />   

          <?php } ?></td>
  </tr>
</table>
</td>
  </tr>
</table>


     	

</div>  

</div>

 <div style="height:110px"></div>
 
  <div class="row hdr-cont">  

    <div class="col-lg-12 table-responsive" style="min-height: 400px;"> 
	<table width="950px" border="0" cellspacing="0" cellpadding="0" style="margin-left:auto; margin-right:auto;">
  <tr>
    <td style="padding-left:70px;"><table width="250px" border="0" cellspacing="0" cellpadding="0">
  <tr>
     <td style="text-align:center; vertical-align:bottom; padding-right:25px"><br/><br/><?=$entry['entry_no']?></td>
  </tr>
  <tr>
    <td style="text-align:right; height:80px; vertical-align:bottom;text-transform:capitalize"><?=$entry['veh_no']?></td>
  </tr>
  <tr>
    <td style="text-align:right; height:80px; vertical-align:bottom"><?=$entry['mt_name']?></td>
  </tr>
  <tr>
    <td style="text-align:right; height:100px"><?=$entry['container_no']?></td>
  </tr>
</table>
</td>
    <td valign="top" style="margin-top:170px; padding-left:190px"><table width="450px" border="0" cellspacing="0" cellpadding="0">
	<tr>
    <td style="height:100px;">&nbsp;</td>
  </tr>
  <tr>
    <td style="text-align:right; padding-top:100px; padding-bottom:80px"><?=$entry['tot_wt']?> KG</td>
  </tr>
  <tr>
    <td style="text-align:right; height:60px; padding-bottom:60px"><?=$entry['empty_wt']?> KG</td>
  </tr>
  <tr>
    <td style="text-align:right; height:50px; padding-bottom:60px"><?=$entry['net_wt']?> KG</td>
  </tr>
  <tr>
    <td style="height:35px;">&nbsp;</td>
  </tr>
  <tr>
    <td style="text-align:right; height:50px; font-size:50px; font-weight:bold">Rs <?=$entry['net_amt']?></td>
  </tr>
</table>
</td>
    <td valign="top" style="margin-top:50px;padding-left:130px" width="350px"><table width="100%" border="0" cellspacing="0" cellpadding="0">
	 <tr>
    <td style="height:20px;">&nbsp;</td>
  </tr>
  <tr>
    <td style="text-align:right; height:20px"><?=date('d-m-Y',$entry['entry_date']);?></td>
  </tr>
  <tr>
    <td style="text-align:right; height:20px"><?=date('h:i A',$entry['entry_date']);?></td>
  </tr>
  <tr>
    <td style="text-align:right;"> <?php if($entry['upload1']) { ?> 



             <img class="img" src="<?php echo base_url('uploads/entry/'.$entry['upload1'])?>" alt="" />   

           <?php } ?></td>
  </tr>
  <tr>
    <td style="text-align:right;"> <?php if($entry['upload2']) { ?> 



            <img class="img" src="<?php echo base_url('uploads/entry/'.$entry['upload2'])?>" alt="" />   

          <?php } ?></td>
  </tr>
</table>
</td>
  </tr>
</table>


     	

</div>  

</div>

<div style="height:110px"></div>
 
  <div class="row hdr-cont">  

    <div class="col-lg-12 table-responsive" style="min-height: 400px;"> 
	<table width="950px" border="0" cellspacing="0" cellpadding="0" style="margin-left:auto; margin-right:auto;">
  <tr>
    <td style="padding-left:60px"><table width="250px" border="0" cellspacing="0" cellpadding="0">
  <tr>
     <td style="text-align:center; vertical-align:bottom; padding-right:25px"><br/><br/><?=$entry['entry_no']?></td>
  </tr>
  <tr>
    <td style="text-align:right; height:80px; vertical-align:bottom;text-transform:capitalize"><?=$entry['veh_no']?></td>
  </tr>
  <tr>
    <td style="text-align:right; height:80px; vertical-align:bottom"><?=$entry['mt_name']?></td>
  </tr>
  <tr>
    <td style="text-align:right; height:100px"><?=$entry['container_no']?></td>
  </tr>
</table>
</td>
    <td valign="top" style="margin-top:160px; padding-left:190px"><table width="450px" border="0" cellspacing="0" cellpadding="0">
	<tr>
    <td style="height:100px;">&nbsp;</td>
  </tr>
  <tr>
    <td style="text-align:right; padding-top:100px; padding-bottom:80px"><?=$entry['tot_wt']?> KG</td>
  </tr>
  <tr>
    <td style="text-align:right; height:60px; padding-bottom:60px"><?=$entry['empty_wt']?> KG</td>
  </tr>
  <tr>
    <td style="text-align:right; height:50px; padding-bottom:60px"><?=$entry['net_wt']?> KG</td>
  </tr>
  <tr>
    <td style="height:35px;">&nbsp;</td>
  </tr>
  <tr>
    <td style="text-align:right; height:50px; font-size:50px; font-weight:bold">Rs <?=$entry['net_amt']?></td>
  </tr>
</table>
</td>
    <td valign="top" style="margin-top:50px;padding-left:130px" width="350px"><table width="100%" border="0" cellspacing="0" cellpadding="0">
	 <tr>
    <td style="height:20px;">&nbsp;</td>
  </tr>
  <tr>
    <td style="text-align:right; height:20px"><?=date('d-m-Y',$entry['entry_date']);?></td>
  </tr>
  <tr>
    <td style="text-align:right; height:20px"><?=date('h:i A',$entry['entry_date']);?></td>
  </tr>
  <tr>
    <td style="text-align:right;"> <?php if($entry['upload1']) { ?> 



             <img class="img" src="<?php echo base_url('uploads/entry/'.$entry['upload1'])?>" alt="" />   

           <?php } ?></td>
  </tr>
  <tr>
    <td style="text-align:right;"> <?php if($entry['upload2']) { ?> 



            <img class="img" src="<?php echo base_url('uploads/entry/'.$entry['upload2'])?>" alt="" />   

          <?php } ?></td>
  </tr>
</table>
</td>
  </tr>
</table>

</div>  

</div>

 

</div>
<P style="page-break-before: always">

<div class="container-fluid w-100" id="btn_div"> 

 <button style="margin-bottom: 20px;" class="btn btn-primary float-right mt-4 ml-2" id="btn_print"><i class="mdi mdi-printer mr-1"></i>Print</button>

<!--  <button style="margin-bottom: 20px;" type="button" class="btn btn-primary float-right mt-4 ml-2" onclick="tableToExcel('invoice', 'Offer Print')">Excel</button>  

 <button style="margin-bottom: 20px;" type="button" class="btn btn-primary float-right mt-4 ml-2" onclick="generatePDF();">PDF</button>   -->

</div> 

<script src="<?php echo base_url();?>assets/js/jquery.min.js"></script>

<script src="https://cdnjs.cloudflare.com/ajax/libs/html2pdf.js/0.9.2/html2pdf.bundle.min.js"></script>

<script>





  function generatePDF() {

    $('#data-cont').addClass('invoice-pdf');

    // $('#paint_sec').show();

    const element = document.getElementById("data-cont");

    var opt = {

      margin:       [0.4, 0, 0.4, 0], //top, left, buttom, right

      filename:     '<?=isset($entry['ps_quotation_no'])?$entry['ps_quotation_no']:'Proposal';?>'+'.pdf',

      html2canvas: {

        dpi: 192,

        scale:3,

        letterRendering: true,

        useCORS: true

      },

      jsPDF:        { unit: 'in', format: 'a4', orientation: 'portrait' },

      pagebreak: { mode: 'avoid-all', after: '.avoidThisRow' }

    };



    html2pdf().set(opt).from(element).save();  

    setTimeout(

      function() 

      {  

        $('#data-cont').removeClass('invoice-pdf');

        // $('#paint_sec').hide();

      }, 0);  

  } 



  $('#btn_print').click(function () { 

    let a = Popup($('.invoice')[0].outerHTML);

    function Popup(data)

    {

      return print();



    }

    console.log(a); 

  });



  (function () {



    var beforePrint = function () {

      $('#btn_div').css('display', 'none');



    };



    var afterPrint = function () {

      $('#btn_div').css('display', 'block');

                                  // console.log('Functionality to run after printing');

                                };



                                if (window.matchMedia) {

                                  var mediaQueryList = window.matchMedia('print');



                                  mediaQueryList.addListener(function (mql) {

                                      //alert($(mediaQueryList).html());



                                      if (mql.matches) {



                                        beforePrint();

                                      } else {

                                        afterPrint();

                                      }

                                    });

                                }



                                window.onbeforeprint = beforePrint;

                                window.onafterprint = afterPrint;



                              }());



  $('#btn_print').trigger('click');

  var tableToExcel = (function() {

    var uri = 'data:application/vnd.ms-excel;base64,'

    , template = '<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns="http://www.w3.org/TR/REC-html40"><head><!--[if gte mso 9]><xml><x:ExcelWorkbook><x:ExcelWorksheets><x:ExcelWorksheet><x:Name>{worksheet}</x:Name><x:WorksheetOptions><x:DisplayGridlines/></x:WorksheetOptions></x:ExcelWorksheet></x:ExcelWorksheets></x:ExcelWorkbook></xml><![endif]--><meta http-equiv="content-type" content="text/plain; charset=UTF-8"/></head><body><table>{table}</table></body></html>'

    , base64 = function(s) { return window.btoa(unescape(encodeURIComponent(s))) }

    , format = function(s, c) { return s.replace(/{(\w+)}/g, function(m, p) { return c[p]; }) }

    return function(table, name) {

      //$('#paint_sec').show();

      $src = $('.img').attr('src');

      $('.img').attr('src','');

      if (!table.nodeType) table = document.getElementById(table)

        var ctx = {worksheet: name || 'Worksheet', table: table.innerHTML}

      window.location.href = uri + base64(format(template, ctx));

     // $('#paint_sec').hide();

     $('.img').attr('src',$src); 

   }



 })()

</script>

</body>

</html>