<head>
<?php
$supply_id = $_GET['supply_id'];
?>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<!--design only--><link rel="stylesheet" type="text/css" href="../css/main.css" />

<?php
$br1=34;
$br2=35;
$br3=80;
$br4=81;
$br5=127;
$br6=128;

$table_name = $_SESSION['db_prefix']."_supply_customer_lines";
$trusses_query = "SELECT job_no, truss_type, timber_type, quantity, user FROM $table_name WHERE supply_id = '".$supply_id."' AND timber_type = 'Trusses' ";
$trusses_result = mySQL_query($trusses_query);
$trusses_num = mysql_num_rows($trusses_result);

$table_name = $_SESSION['db_prefix']."_supply_customer_lines";
$summary_query = "SELECT * FROM $table_name WHERE supply_id = '".$supply_id."' AND truss_type = 'bracing'  ";
$summary_result = mySQL_query($summary_query);
$summary_num = mysql_num_rows($summary_result);
//echo '<br>'.$summary_query;

$table_name = $_SESSION['db_prefix']."_supply_customer_lines";
$summary2_query = "SELECT * FROM $table_name WHERE supply_id = '".$supply_id."' AND truss_type = 'sundries'  ";
$summary2_result = mySQL_query($summary2_query);
$summary2_num = mysql_num_rows($summary2_result);
//echo '<br>'.$summary_query;

$table_name = $_SESSION['db_prefix']."_supply_customer_lines";
$mitek_query = "SELECT job_no, truss_type, store_item_id, timber_type, quantity, user FROM $table_name WHERE supply_id = '".$supply_id."' AND truss_type = 'Mitek'";

$mitek_result = mySQL_query($mitek_query);
$mitek_num = mysql_num_rows($mitek_result);

$table_name = $_SESSION['db_prefix']."_supply_customer_lines";
$additional_query = "SELECT job_no, truss_type, store_item_id, timber_type, quantity, user FROM $table_name WHERE supply_id = '".$supply_id."' AND truss_type = 'Additional' ";
$additional_result = mySQL_query($additional_query);
$additional_num = mysql_num_rows($additional_result);


$table_name = $_SESSION['db_prefix']."_supply_customer_lines";
$cash_query = "SELECT * FROM $table_name WHERE supply_id = '".$supply_id."' AND truss_type = 'Cash'  ";
$cash_result = mySQL_query($cash_query);
$cash_num = mysql_num_rows($cash_result);
?>
<?php 
include ('del_note_header.php');
?>

</head>






<div style="float:left;"><br>
<?php $line_no=0; ?>
<?php if ($trusses_num!=0) { ?>
<table width="646" align="left" id="table_details_display_grey" > 
              <tr >
                <td width="456" align="left" valign="top"><b>
                  <label class="label_plain">Item</label>
                </b></td>
                <td width="77" align="left" valign="top">&nbsp;</td>
                <td width="97" align="left" valign="top"><label class="label_plain">Quantity</label></td>
              </tr>
</table>
</div>
<div style="float:left;">
  <table width="646" align="left" id="table_details_display" > 
              <tr style="border-bottom-style:double;">
                <td colspan="2" align="left" valign="top"><label class="label_plain">Trusses:</label><?php $line_no = $line_no+1?>></td>
              </tr>
              <?php 
				  $i=0;
				  
				  while ($i<$trusses_num) {
				  		$f1 = mysql_result($trusses_result, $i, "truss_type");
						$f2 = mysql_result($trusses_result, $i, "quantity"); 			
				 ?>
              <tr style=" <?php if (($line_no==$br1) OR ($line_no==$br3) OR ($line_no==$br5)) { ?> page-break-after:always;<?php }?>"  >
             <?php
			  
			 if (($line_no==$br2) OR ($line_no==$br4) OR ($line_no==$br6)) { ?>
             <td colspan="2" style="border-left:hidden; border-right:hidden;"><br><?php $line_no = $line_no+1?>
               <br>  
              <label class="label_plain" style="font-size:10px"><?php if ($line_no==$br2+1) {echo 'Page 2';}  if ($line_no==$br4+1) {echo 'Page 3';} if ($line_no==$br6+1) {echo 'Page 4';}?></label>&nbsp;&nbsp;&nbsp;&nbsp;
               
                            <img src="../images/logo_tlhomeso.png" width="111" height="54">&nbsp;&nbsp;<label class="label_plain" style="font-size:14px;">delivery note: <?php echo $a3 ?></label>
               &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<label class="label_plain" style="font-size:10px"><?php if ($line_no==$br2+1) {echo 'Continued from page 1';}  if ($line_no==$br4+1) {echo 'Continued from page 2';} if ($line_no==$br6+1) {echo 'Continued from page 3';}?></label></td>
             </tr>
             <tr> 
             <td width="456" ><?php echo $f1; ?></td>
             <td width="92"><?php echo $f2; ?>
               no<?php $line_no = $line_no+1?>
               </td>
             <?php 
			 }
			 else { 
			 if (($line_no==$br1) OR ($line_no==$br3) OR ($line_no==$br5)) {
				 ?>
                 <td colspan="2"  style="border-bottom:hidden; border-left:hidden; border-right:hidden;">
                  <label class="label_plain" style="font-size:10px;"><?php if ($line_no==$br1) { echo 'Page 1';} if ($line_no==$br3) { echo 'Page2';} if ($line_no==$br5) { echo 'Page 3';} ?> </label>
				<div align="right">  <label class="label_plain" style="font-size:10px;"><?php if ($line_no==$br1) { echo 'Continued on page 2';} if ($line_no==$br3) { echo 'Continued on page 3';} if ($line_no==$br5) { echo 'Continued on page 4';} ?> </label></div> </td>
                  <?php
			 }
			 else
				  { ?>
             <td width="456" ><?php echo $f1; ?></td>
             <td width="92"><?php echo $f2; ?>
               no
			   
			   <?php 
				  }?>
               </td>
             <?php }
			 $line_no = $line_no+1;
			 if (($line_no==$br2) OR ($line_no==$br4) OR ($line_no==$br6)) { $i=$i-1; };
			    ?>
             </tr>
            
              <?php
             
			  $i++;
             }
             ?>
               
  </table>
</div>
<?php }
 if ($summary_num!=0) { ?>
<div style="float:left; ">
<br>

  <table width="646" align="left" id="table_details_display" >
    <tr style="border-bottom-style:double;">
      <td colspan="3" align="left" valign="top" ><label class="label_plain">Bracing timber:</label><?php $line_no = $line_no+1?></td>
    </tr>
    <?php 
				  $k=0;
				  $temp_name='';
				  while ($k<$summary_num) { 
					    $c1 = mysql_result($summary_result, $k, "timber_type");
						$c2 = mysql_result($summary_result, $k, "store_item_id");
						$table_name = $_SESSION['db_prefix']."_store_items";
							$name_query = "SELECT length FROM $table_name WHERE  store_item_id = '".$c2."' ";
							$name_result = mySQL_query($name_query);
							$c2a = mysql_result($name_result, 0, "length");
						$c3 = mysql_result($summary_result, $k, "tot_length"); 
						$c4 = mysql_result($summary_result, $k, "quantity");  
						
						
				 ?>
    <tr style=" <?php if (($line_no==$br1) OR ($line_no==$br3) OR ($line_no==$br5)) { ?> page-break-after:always;<?php  }?>" >
             <?php
			  
			 if (($line_no==$br2) OR ($line_no==$br4) OR ($line_no==$br6))  { ?>
             <td colspan="3" width="456" style="border-left:hidden; border-right:hidden;"><br>
               <?php $line_no = $line_no+1?>
               <br>  
              <label class="label_plain" style="font-size:10px"><?php if ($line_no==$br2+1) {echo 'Page 2';}  if ($line_no==$br4+1) {echo 'Page 3';} if ($line_no==$br6+1) {echo 'Page 4';}?></label>&nbsp;&nbsp;&nbsp;&nbsp;
               <img src="../images/logo_tlhomeso.png" width="111" height="54">&nbsp;&nbsp;
               <label class="label_plain" style="font-size:14px;">delivery note: <?php echo $a3 ?></label>
              
               &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
               <label class="label_plain" style="font-size:10px">
                 <?php if ($line_no==$br2+1) {echo 'Continued from page 1';}  if ($line_no==$br4+1) {echo 'Continued from page 2';} if ($line_no==$br6+1) {echo 'Continued from page 3';}?>
        </label></td>
    </tr>
             <tr> 
             <td width="456" ><?php echo $c1.' - '.$c2a ?></td>
             <td width="92"><?php echo $c4; ?>
              <?php $line_no = $line_no+1?> 
              </td>
             <?php 
			 }
			 else { 
              if (($line_no==$br1) OR ($line_no==$br3) OR ($line_no==$br5)) {
				 ?>
                 <td colspan="3" align="right" style="border-bottom:hidden; border-left:hidden; border-right:hidden;">
				  <label class="label_plain" style="font-size:10px;"><?php if ($line_no==$br1) { echo 'Continued on page 2';} if ($line_no==$br3) { echo 'Continued on page 3';} if ($line_no==$br5) { echo 'Continued on page 4';} ?></label><?php $line_no = $line_no+1; ?> </td>
                  <?php
			 }
			 else
				  { ?>
             <td width="456" ><?php echo $c1.' - '.$c2a ?></td>
             <td width="92"><?php echo $c4; ?>
               no
			   
			   <?php $line_no = $line_no+1;
				  }?>
               </td>
             <?php }
			    ?>
             </tr>
    <?php
			  $k++;
             }
             ?>
  </table>
</div>
<?php }
 if ($summary2_num!=0) { ?>
<div style="float:left;"><br>

 <table width="646" align="left" id="table_details_display" >
   <tr  style="border-bottom-style:double;">
     <td colspan="3" align="left" valign="top"><label class="label_plain">Sundries timber:</label><?php $line_no = $line_no+1?>
      </td>
   </tr>
   <?php 
				  $k=0;
				  $temp_name='';
				   while ($k<$summary2_num) { 
					    $c1 = mysql_result($summary2_result, $k, "timber_type");
						$c2 = mysql_result($summary2_result, $k, "store_item_id");
						$table_name = $_SESSION['db_prefix']."_store_items";
							$name_query = "SELECT length FROM $table_name WHERE  store_item_id = '".$c2."' ";
							$name_result = mySQL_query($name_query);
							$c2a = mysql_result($name_result, 0, "length");
						$c3 = mysql_result($summary2_result, $k, "tot_length"); 
						$c4 = mysql_result($summary2_result, $k, "quantity");  
						
				 ?>
   <tr style=" <?php if (($line_no==$br1) OR ($line_no==$br3) OR ($line_no==$br5)) { ?> page-break-after:always;<?php  }?>"  >
             <?php
			  
			 if (($line_no==$br2) OR ($line_no==$br4) OR ($line_no==$br6)) { ?>
             <td colspan="3" width="456" style="border-left:hidden; border-right:hidden;"><br>
               <?php $line_no = $line_no+1?>
               <br>  
              <label class="label_plain" style="font-size:10px"><?php if ($line_no==$br2+1) {echo 'Page 2';}  if ($line_no==$br4+1) {echo 'Page 3';} if ($line_no==$br6+1) {echo 'Page 4';}?></label>&nbsp;&nbsp;&nbsp;&nbsp;<br>
               <img src="../images/logo_tlhomeso.png" width="111" height="54">&nbsp;&nbsp;
               <label class="label_plain" style="font-size:14px;">delivery note: <?php echo $a3 ?></label>
              
               &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
               <label class="label_plain" style="font-size:10px">
                 <?php if ($line_no==$br2+1) {echo 'Continued from page 1';}  if ($line_no==$br4+1) {echo 'Continued from page 2';} if ($line_no==$br6+1) {echo 'Continued from page 3';}?>
             </label></td>
             
    </tr>
             <tr> 
             <td width="456" ><?php echo $c1.' - '.$c2a?></td>
             <td width="92"><?php echo $c4; ?>
               <?php $line_no = $line_no+1?>
               </td>
             <?php 
			 }
			 else { 
              if (($line_no==$br1) OR ($line_no==$br3) OR ($line_no==$br5)) {
				 ?>
               <td colspan="3" align="right" style="border-bottom:hidden; border-left:hidden; border-right:hidden;">
				  <label class="label_plain" style="font-size:10px;">
				    <?php if ($line_no==$br1) { echo 'Continued on page 2';} if ($line_no==$br3) { echo 'Continued on page 3';} if ($line_no==$br5) { echo 'Continued on page 4 of niet';} ?>
		       </label><?php $line_no = $line_no+1; ?> </td>
                  <?php
			 }
			 else
				  { ?>
             <td width="456" ><?php echo $c1.' - '.$c2a; ?></td>
             <td width="92"><?php echo $c4; ?>
               no
			  
			   <?php $line_no = $line_no+1;
				  }?>
               </td>
             <?php }
			    ?>
             </tr>
   <?php
			  $k++;
             }
             ?>
 </table>
</div>
<?php }
if ($mitek_num!=0) { ?>
<div style="float:left;"><br>

    <table width="646" align="left" id="table_details_display" > 
              <tr style="border-bottom-style:double;">
                <td colspan="2" align="left" valign="top"><label class="label_plain">Mitek products:</label><?php $line_no = $line_no+1?>
               </td>
              </tr>
               <?php 
				  $j=0;
				  while ($j<$mitek_num) { 
					    $e1 = mysql_result($mitek_result, $j, "timber_type");
						$e2 = mysql_result($mitek_result, $j, "store_item_id");
						$table_name = $_SESSION['db_prefix']."_store_items";
							$name_query = "SELECT item_name, unit FROM $table_name WHERE  store_item_id = '".$e2."' ";
							$name_result = mySQL_query($name_query);
							$e2a = mysql_result($name_result, 0, "item_name");
							$e4 = mysql_result($name_result, 0, "unit");
						$e3 = mysql_result($mitek_result, $j, "quantity");  
						
				 ?>
                 
                
             <?php if (($line_no==$br1) OR ($line_no==$br3) OR ($line_no==$br5)) { ?>    
             <tr  style="  page-break-after:after;" >
                 <td colspan="3" align="right" style="border-bottom:hidden; border-left:hidden; border-right:hidden;">
				  <label class="label_plain" style="font-size:10px;"><?php if ($line_no==$br1) { echo 'Continued on page 2';} if ($line_no==$br3) { echo 'Continued on page 3';} if ($line_no==$br5) { echo 'Continued on page 4';} ?></label><?php $line_no = $line_no+1; ?> </td>
              </tr>
             <?php }
			 
			    ?>
             
             
             <?php     
             if (($line_no==$br2) OR ($line_no==$br4) OR ($line_no==$br6)) { ?>
             <tr  >
             <td colspan="3" width="456" style="border-left:hidden; border-right:hidden;"><?php echo $line_no ?><br>
               
               <br>  
              <label class="label_plain" style="font-size:10px"><?php if ($line_no==$br2) {echo 'Page 2';}  if ($line_no==$br4) {echo 'Page 3';} if ($line_no==$br6) {echo 'Page 4';}?></label>&nbsp;&nbsp;&nbsp;&nbsp;
               <img src="../images/logo_tlhomeso.png" width="111" height="54">&nbsp;&nbsp;
               <label class="label_plain" style="font-size:14px;">delivery note: <?php echo $a3 ?></label>
               
               &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
               <label class="label_plain" style="font-size:10px">
                 <?php if ($line_no==$br2+1) {echo 'Continued from page 1';}  if ($line_no==$br4+1) {echo 'Continued from page 2';} if ($line_no==$br6+1) {echo 'Continued from page 3';}?>
               </label>               <br>
             </td>
             </tr>
              
             <?php }
			 
			    ?>
             <tr> 
             <td width="456" ><?php echo $line_no ?><?php echo $e2a ?></td>
             <td width="92"><?php echo $e3.'&nbsp;&nbsp;'.$e4; ?>
               <?php $line_no = $line_no+1?>
               </td>
               </tr>
              <?php
				
			  $j++;
             }
             ?>
  </table></div>
<?php }
 if ($additional_num!=0) { ?>  
    
  <div style="float:left;"><br>

 <table width="646" align="left" id="table_details_display" > 
              <tr style="border-bottom-style:double; ">
                <td colspan="2" align="left" valign="top"><label class="label_plain">Additional sundries:</label></td>
              </tr>
               <?php 
				  $n=0;
				  while ($n<$additional_num) { 
					    $g1 = mysql_result($additional_result, $n, "timber_type");
						$g2 = mysql_result($additional_result, $n, "store_item_id");
						$table_name = $_SESSION['db_prefix']."_store_items";
							$name_query = "SELECT item_name, unit FROM $table_name WHERE  store_item_id = '".$g2."' ";
							$name_result = mySQL_query($name_query);
							$g2a = mysql_result($name_result, 0, "item_name");
							$g4 = mysql_result($name_result, 0, "unit");
						$g3 = mysql_result($additional_result, $n, "quantity");  
						
				 ?>
                 
             <tr style=" <?php if (($line_no==$br1) OR ($line_no==$br3) OR ($line_no==$br5)) { ?> page-break-after:always;<?php  }?>"   >
             <?php
			  
			 if (($line_no==$br2) OR ($line_no==$br4) OR ($line_no==$br6)) { ?>
             <td colspan="3" width="456" style="border-left:hidden; border-right:hidden;"><br>
               <?php echo $line_no ?><?php $line_no = $line_no+1?>
               <br>  
              <label class="label_plain" style="font-size:10px"><?php if ($line_no==$br2+1) {echo 'Page 2';}  if ($line_no==$br4+1) {echo 'Page 3';} if ($line_no==$br6+1) {echo 'Page 4';}?></label>&nbsp;&nbsp;&nbsp;&nbsp;
               <img src="../images/logo_tlhomeso.png" width="111" height="54">&nbsp;&nbsp;
               <label class="label_plain" style="font-size:14px;">delivery note: <?php echo $a3 ?></label>
               
               &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
               <label class="label_plain" style="font-size:10px">
                 <?php if ($line_no==$br2+1) {echo 'Continued from page 1';}  if ($line_no==$br4+1) {echo 'Continued from page 2';} if ($line_no==$br6+1) {echo 'Continued from page 3';}?>
               </label>               <br></td>
             </tr>
             <tr> 
             <td width="456" ><?php echo $line_no ?><?php echo $g2a ?></td>
             <td width="92"><?php echo $g3.'&nbsp;&nbsp;'.$g4; ?>
               <?php $line_no = $line_no+1?>
              </td>
             <?php 
			 }
			 else { 
			  if (($line_no==$br1) OR ($line_no==$br3) OR ($line_no==$br5)) {
				 ?>
                 <td colspan="3" align="right" style="border-bottom:hidden; border-left:hidden; border-right:hidden;">
				  <label class="label_plain" style="font-size:10px;"><?php if ($line_no==$br1) { echo 'Continued on page 2';} if ($line_no==$br3) { echo 'Continued on page 3';} if ($line_no==$br5) { echo 'Continued on page 4';} ?></label><?php $line_no = $line_no+1; ?> </td>
                  <?php
			 }
			 else
				  { ?>
             <td width="456" ><?php echo $line_no ?><?php echo $g2a; ?></td>
             <td width="92"><?php echo $g3.'&nbsp;&nbsp;'.$g4; ?>
               <?php $line_no = $line_no+1;
				  }?>
               </td>
             <?php }
			    ?>
             </tr>
              <?php
				
			  $n++;
             }
             ?>
    </table>
</div>
<?php }
 if ($cash_num!=0) { ?>  
    
  <div style="float:left;"><br>

 <table width="646" align="left" id="table_details_display" > 
              <tr style="border-bottom-style:double; ">
                <td align="left" valign="top"><label class="label_plain">Item</label></td>
                <td align="left" valign="top"><label class="label_plain">Qty</label></td>
              </tr>
               <?php 
				  $n=0;
				  while ($n<$cash_num) { 
					    $g1 = mysql_result($cash_result, $n, "timber_type");
						$g2 = mysql_result($cash_result, $n, "store_item_id");
						$table_name = $_SESSION['db_prefix']."_store_items";
							$name_query = "SELECT item_name, unit FROM $table_name WHERE  store_item_id = '".$g2."' ";
							$name_result = mySQL_query($name_query);
							$g2a = mysql_result($name_result, 0, "item_name");
							$g4 = mysql_result($name_result, 0, "unit");
						$g3 = mysql_result($cash_result, $n, "quantity");  
						
				 ?>
                 
             <tr style=" <?php if (($line_no==$br1) OR ($line_no==$br3) OR ($line_no==$br5)) { ?> page-break-after:always;<?php }?>"   >
             <?php
			  
			 if (($line_no==$br2) OR ($line_no==$br4) OR ($line_no==$br6)) { ?>
             <td width="456" style="border-left:hidden; border-right:hidden;"><br>
               <br>               <img src="../images/logo_tlhomeso.png" width="111" height="54">&nbsp;&nbsp;<label class="label_plain">delivery note: <?php echo $a3 ?></label>
               <br>
               <br>
              <br></td>
             <td style="border-right:hidden;"><?php if ($line_no==$br2+1) {echo 'Continued from page 1';}  if ($line_no==$br4+1) {echo 'Continued from page 2';} if ($line_no==$br6+1) {echo 'Continued from page 3';}?></td>
             </tr>
             <tr> 
             <td width="456" ><?php echo $g2a ?></td>
             <td width="92"><?php echo $g3.'&nbsp;&nbsp;'.$g4; ?>
               <?php $line_no = $line_no+1?>
              </td>
             <?php 
			 }
			 else { 
			  if (($line_no==$br1) OR ($line_no==$br3) OR ($line_no==$br5)) {
				 ?>
                 <td colspan="2" align="right" style="border-bottom:hidden; border-left:hidden; border-right:hidden;">
				  <label class="label_plain" style="font-size:10px;">hier<?php if ($line_no==$br1) { echo 'Continued on page 2';} if ($line_no==$br3) { echo 'Continued on page 3';} if ($line_no==$br5) { echo 'Continued on page 4';} ?></label><?php $line_no = $line_no+1; ?> </td>
                  <?php
			 }
			 else
				  { ?>
             <td width="456" ><?php echo $g2a; ?></td>
             <td width="92"><?php echo $g3.'&nbsp;&nbsp;'.$g4; ?>
               <?php $line_no = $line_no+1;
				  }?>
               </td>
             <?php }
			    ?>
             </tr>
              <?php
				
			  $n++;
             }
             ?>
    </table>
</div>
          <?php } ?>
          
</body>          
              
<?php
include ('del_note_footer.php')
?>
<br />

 
</html>