<?php 
date_default_timezone_set("America/Caracas" );
 require_once('mpdf/mpdf2.php');

$mpdf = new mPDF('es');
$mpdf = new mPDF('win-1252', 'letter','','',5,5,5,5,5,5,'P');
$mpdf -> useOnlyCoreFonts=true;
$mpdf -> watermark_font = 'Arial';
$mpdf=new mPDF();


//$fecha=date("d/m/Y");

                                             include("conexion.php");

$id_pedido=$_REQUEST['id'];
$id_supplier=$_REQUEST['id_supplier'];
$tape=$_REQUEST['tape'];
$packing=$_REQUEST['packing'];
$mix=$_REQUEST['mix'];
$container=$_REQUEST['container'];
$samples=$_REQUEST['samples'];
$lenght_per=$_REQUEST['lenght_per'];

$packing_det1=$_REQUEST['packing_det1'];
$packing_det2=$_REQUEST['packing_det2'];
$container2=$_REQUEST['container2'];
$mix_det2=$_REQUEST['mix_det2'];





$query="SELECT `id_pedido`, `orden`, `fecha_pedido`, `fecha_final`, `cliente`, `forma_pago`, `embalaje`, nombre, ciudad, telefono, nit, direccion, pais, contacto FROM `pedidos` inner join  clientes on id=cliente WHERE id_pedido='$id_pedido'";
$result=$conexion-> query ($query);
$row=$result->fetch_assoc();

  $fecha_pedido=$row["fecha_pedido"];
$nombre_cliente=strtoupper($row["nombre"]);
$orden=$row["orden"];
$telefono=$row["telefono"];
$nit=$row["nit"];
$ciudad=$row["ciudad"];
$direccion=$row["direccion"];
$contacto=$row["contacto"];
$pais=$row["pais"];



//style=" Background-color:#ECEAEA; border-width: 3px;border-right: solid; border-color:#FFFFFF;font-size:18px "

$html .=' 



<html>
<head>
<title>Packing Instruccion Order # '.$orden.'</title>
<style type="text/css">
.table-striped > tbody > tr:nth-of-type(odd) {
  background-color: #f9f9f9;
}
</style>
</head>

<body>
 <div style="position: absolute; right: 2.5em; top:2em; left: 2.5em; font-size:10px;">
<table width=100% border=1 style="border-collapse:collapse;">
<tr align=center>
<td align=center colspan=2>
<span style="font-size:18px;width:100%; text-align:center">
<b>'. $nombre_cliente .' INSTRUCCION</b>
</span>
</td>
</tr>

<tr>
<td align=center colspan=2>
<span style="font-size:12px;width:100%; text-align:center">
<b>TO CONSIDER WITHIN THESE ORDER:</b>
</span>
</td>
</tr>

<tr>

<td>
<span style="text-align:justify; font-size:10px">
1.       See our label position, must be end of roll for both side. The label must be inside of polybag
</span>
</td>
<td>
<img alt="img" src="img/img1_etiq.png" height="10%" width="10%">
</td>

</tr>

<tr>

<td>
<span style="text-align:justify; font-size:10px">
2.       '.$tape.'</span>
</td>
<td>
<img alt="img" src="img/img2_etiq.png" height="10%" width="10%">
</td>

</tr>






';

 $cant_color=0;
$servicios="";
$i=0;
$pedido=$_GET['id'];

$consulta="SELECT `id_item`, `orden_pedido`, `descripcion`, `supplier`, `um`, `width`, `weight`, `meter`, `quantity`, `precio_compra`, `price_usd`, `fob`, `cap_hq`, `porc_ocup`, `seis_ocho`, `cent`, `cent_usd`, `com_colim`, `total_com`, `bon_fab`, `total_bon_fab`, `total_ganac`, `fecha_prod`, `remark`, nombre_ref, tela_etiqueta FROM `pedidos_items` inner join referencias on descripcion=id_ref where supplier='$id_supplier' and orden_pedido ='$id_pedido' order by descripcion";


$resultado2=$conexion-> query ($consulta);


     while ($row1=$resultado2->fetch_assoc()){



  $nombre=$row1["tela_etiqueta"];

if (strtoupper($row1["um"]=='KILOS') ||  strtoupper($row1["um"]=='KILO'))  {

$imprimir="<tr><td colspan=2>Quantity ( In Kilos ):</td>  </tr>  <tr><td colspan=2>Quantity ( In Meters ):</td>  </tr>";
}
else
{
  $imprimir="  <tr><td colspan=2>Quantity ( In Meters ):</td>  </tr>";
}

  $servicios.="

  <table style='border-collapse:collapse;border-top: 1px black; margin-top:5px; margin-left:5px; margin-right:5px; margin-bottom:5px'>
  <tr>
  <td>PI Order No:</td>
  <td style='text-align:left'><span style='color:red'>".strtoupper($orden)."</span></td>
  </tr>
  <tr>
  <td>Item Name:</td>
  <td style='text-align:left'><span style='color:red'>".strtoupper($nombre)."</span></td>
  </tr>
  <tr>
  <td>Roll No:</td>
  <td></td>
  </tr>
  <tr>
  <td>Color:</td>
  <td></td>
  </tr>
  <tr>
  <td>Lot No:</td>
  <td></td>
  </tr>
  
  ".$imprimir."
  

  </table>
  <div style='Background-color:white; width:100%'>____________________________________________________________</div>
";
 
}



$packing_det1=$_REQUEST['packing_det1'];
$packing_det2=$_REQUEST['packing_det2'];
$container2=$_REQUEST['container2'];

 $html.= "
 <tr>

 <td>
 <span style='text-align:justify; font-size:10px'>

3. EACH ROLL MUST HAVE TWO LABELS, EACH ONE IN EACH SIDE OF IT, THEY MUST INCLUDE: OUR COMPANY NAME, PI ORDER NUMBER (this is not your PI number, pls issue your PI to me ,then I will tell you which PI order number you have to put), ITEM NAME(pls issue your PI ,then I will tell you which item name you should put), ROLL No, COLOR NAME ( you have to write the color exactly),  and LENGTH IN Kilos By NET Weight and also IN MTS.   Pls send layout for approval before print.     <span style='color:red'>WARNING: PLS DO NOT MARK OR WRITE DOWN FABRIC COMPOSITON OR GSM WEIGHT IN LABEL,SHIPPING MARK OR ANYWHERE ELSE </span>
</span>

</td>

<td>
". $servicios."
</td>

</tr>
</table>
<table width=100% border=1 style='border-collapse:collapse;'>

<tr>

<td colspan=2>
<span style='text-align:justify; font-size:10px' >
4.  Each roll need ".$packing_det1.". ".$packing_det2.". ". $mix_det2.", all will be ship in ".$container2." Container.<br><br>

</span>
</td>

</tr>
<tr>

<td colspan=2>
<span style='text-align:justify; font-size:10px' >
5.       Shipping Samples Details </span><br><br>

". $samples."
<br>
<span style='text-align:center; font-size:10px' >
here below is customer address for you to send the parcel, pls must use Fedex and do not put value more than $9 ,otherwise, buyer needs to pay $100 for fine.</span>

<br>
<br>


<table width=100% align=right>
<tr style='border:none'>
<td width=30%></td>

<td style='border:none'>

<span style='color:red'>ADDRESS IN COLOMBIA</span><br>
<span style='text-align:justify; font-size:9px' >
Address: Carrera 56 B #49-40 Piso 2  <br>      
Company name: Textiles Prontamoda S.A  <br>     
Contact person: Juan Sierra     <br>
Tel: (57-4) 5114720   <br>
City: Medellin       <br>
Country: Colombia    <br>
</span>


</td>

<td style='border:none'>

<span style='color:red'>ADDRESS IN CHINA</span><br>
<img alt='img' src='img/img3_etiq.png' height='10%' width='30%'>

</td>

</tr>
</table>



</td>


</tr>
</table>
<table width=100% border=1 style='border-collapse:collapse;'>
<tr>

<td colspan=2>
<span style='text-align:justify; font-size:10px' >
6.  ABOUT ". $lenght_per." LENGTH PER EACH ROLL, <span style='color:red; text-decoration:underline'>
ROLLS SHOULD BE A COMPLETE PIECE, WITHOUT JOINTS.</span> THE TUBE FOR EACH ROLL SHOULD BE LONG AS FABRIC WIDTH AND STRONG TO NOT GET BROKEN EASY DURING TRANSPORTATION.</span>
</td>

</tr>

<tr>

<td colspan=2>
<span style='text-align:justify; font-size:10px' >
7. IMPORTANT ASPECTS TO CONSIDER DURING INSPECTION:<br>
<ul>
      <li> THE QUALITY SHOULD BE THE SAME ONE AS THE SAMPLE THAT HAS BEEN APPROVED                               </li>
      <li> THE  COMPOSITION AND CONSTRUCTION OF THE ORDER, SHOULD BE THE SAME ONE AS THE GIVEN SAMPLE                                </li>
      <li> DESIGNS AND COLORS  FABRICS ORDER SHOULD BE THE SAME ONES  AS THE SAMPLE THAT HAS BEEN APPROVED                                 </li>

</ul>

</span>
</td>

</tr>

 </table>

 </div>
 <div style='position: absolute; right: 2.5em; bottom:1em; left: 2.5em; font-size:10px;'>


 <div style='Background-color:white; width:100%'>_______________________________________________________________________________________________________________________________________________________________________________</div>

<table width=100% style='font-size:12px'>
<tr>
<td>
<b> QINGDAO QIXIANG INTERNATIONAL TRADING CO., LIMITED</b><br> 
<b> #19128, B BUILDING ,WONDER PLAZA,KEQIAO,, SHAOXING, ZHEJIANG, CHINA  </b><br>

</td>
</tr>
</table>
</div>
</div>
 </body>
 </html>
";

 $mpdf->WriteHTML($html);
 /// D descargar, I ver en linea
 $nombre="Purchase No ".$orden.".pdf";
$mpdf->Output($nombre,'I');
exit;
 ?>