<?php
error_reporting(0);
include ("../../include/db.php");
ob_start();
session_start();
$user_id = $_SESSION['login_user_id'];
?>
<table width="850px" border="0" align="center" cellpadding="0" cellspacing="0" style="border:1px solid #999;">
<tr style="height:60">
<td width="137" height="106" align="left" style="font-size:12px; border-bottom:1px solid #999;"><img src="../../img/logo_image.png" width="126" height="130"/></td>
<td width="711" colspan="5" align="center" valign="top" style="border-bottom:1px solid #999;"><strong style="font-size: 30px; color: #06F; padding-top: 5px; width: 80px; font-family: Verdana, sans-serif">SRI AMMAN DIGITAL PRINTS</strong><br />
        <span width="80%" class="title1" style="font-size:14px;font-family:Verdana, sans-serif; font-weight:bold"><b></b> DOOR No: 1/2,1/3  KOMBAI THOTTAM MAIN ROAD,</span><br />
       <span width="80%" class="title0" style="font-size:14px;font-family:Verdana, sans-serif; font-weight:bold"><b></b>SELLANDIAMMAN THURAI ROAD,</span><br />
       <span width="80%" class="title0" style="font-size:14px;font-family:Verdana, sans-serif; font-weight:bold"><b></b>TIRUPPUR-641604 TAMILNADU STATE INDIA,</span><br/>
       <span width="80%" class="title00" style="font-size:14px;font-family:Verdana, sans-serif; font-weight:bold"><b></b>Contact Office: 0421-4355333,+91 83442-33555,+91 83442-3388,</span><br/>
       <span width="80%" class="title0" style="font-size:14px;font-family:Verdana, sans-serif; font-weight:bold"><b></b>Email Id : sriammandigitalprints@gmail.com/yahoo.com.</span><br/>
       <span width="80%" class="title0" style="font-size:14px;font-family:Verdana, sans-serif; font-weight:bold"><b></b>GSTIN : 33ADDFS1470L1Z1, PAN NO : ADDFS1470L.</span><br/>
       <br/></td>
  </tr>
  <tr>
    <td colspan="2"><table width="100%" border="0" cellpadding="0" cellspacing="0" >
       <tr>
        <td width="543" height="20"  style="padding:3px; font-family:Verdana, sans-serif; font-size:12px; font-weight:bold;border-right:1px solid #999;"><strong>Customer Details</strong></td>
        <td width="95" colspan="-2" style="font-family:Verdana; font-size:12px;">&nbsp;Jobcard No</td>
        <td width="20" colspan="-2" align="center">:</td>
        <td width="192" colspan="-2" style="font-family:Verdana, sans-serif; font-size:12px;">&nbsp;<?php echo $_GET['jobcard_no']; ?></td>
      </tr>
     <?PHP 
	$cust_name=$_GET['cust_name'];
    $sql="select * from   party_creation where party_name='$cust_name' and `party_type`='Customer' and delete_status!='1'   order by party_name ASC ";
    $rs=mysql_query($sql);
	$sno=0;
   		while($rsdata=mysql_fetch_array($rs))
  			{ 
   				$sno=$sno+1;
   				$party_name=$rsdata['party_name'];
     			$mobile_no=$rsdata['mobile_no'];
				$address=$rsdata['address'];
   				$city=$rsdata['city'];
			}

?>  

 <?PHP 
	$jobcard_no=$_GET['jobcard_no'];
    $sql="select * from   jobcard_main where jobcard_no='$jobcard_no'";
    $rs=mysql_query($sql);
   		while($rsdata=mysql_fetch_array($rs))
  			{ 
   				$style_no=$rsdata['style_no'];
     			$style_name=$rsdata['style_name'];
				$job_type=$rsdata['job_type'];
   				$fabric_type=$rsdata['fabric_type'];
				$combo2=$rsdata['combo'];
				$entry_date=$rsdata['entry_date'];
				$order_by=$rsdata['order_by'];
				$cust_po_no=$rsdata['cust_po_no'];
				$hsn_code=$rsdata['hsn_code'];
			}

?>  
      <tr>
        <td rowspan="4" valign="top"  style="font-family:Verdana; font-size:12px;  letter-spacing:1px;line-height:16px; padding-left:10px;border-right:1px solid #999;">To.M/S&nbsp;<?php echo $_GET['cust_name'];?>,<br /><?php echo $address;?>&nbsp;<br /><?php echo $city;?>&nbsp;<br /></td>
        <td height="19" colspan="-2" valign="top"  style="font-family:Verdana; font-size:12px;">&nbsp;Date</td>
        <td width="20" colspan="-2" align="center" valign="top" >:</td>
        <td colspan="-2"  align="left" valign="top"  style="font-family:Verdana; font-size:12px;">&nbsp;<?php  echo date('d-m-Y',strtotime($entry_date)); ?>
          </td>
      </tr>
      <tr>
        <td height="19" colspan="-2" valign="top"  style="font-family:Verdana; font-size:12px;"> &nbsp;Job Type</td>
        <td width="20" colspan="-2" align="center" valign="top" >:</td>
        <td colspan="-2"  align="left" valign="top"  style="font-family:Verdana; font-size:12px;">&nbsp;<?php echo $job_type;?></td>
      </tr>
      <tr>
        <td height="19" colspan="-2" valign="top"  style="font-family:Verdana; font-size:12px;">&nbsp;Fabric Type</td>
        <td width="20" colspan="-2" align="center" valign="top" >:</td>
        <td colspan="-2"  align="left" valign="top"  style="font-family:Verdana; font-size:12px;">&nbsp;<?php echo $fabric_type;?></td>
      </tr>
      <tr>
        <td height="19" colspan="-2" valign="top"  style="font-family:Verdana; font-size:12px;">&nbsp;Style No</td>
        <td width="20" colspan="-2" align="center" valign="top" >:</td>
        <td colspan="-2"  align="left" valign="top"  style="font-family:Verdana; font-size:12px;">&nbsp;<?php echo $style_no;?></td>
      </tr>
      <tr>
        <td valign="top" style="font-family:Verdana; font-size:12px;border-right:1px solid #999;">&nbsp;&nbsp;</td>
        <td height="18" style="font-family:Verdana; font-size:12px;">&nbsp;Style Name</td>
        <td align="center" style="font-family:Verdana; font-size:12px;">:</td>
        <td style="font-family:Verdana; font-size:12px;">&nbsp;<?php echo $style_name;?></td>
      </tr>
      <tr>
        <td valign="top" style="font-family:Verdana; font-size:12px;border-right:1px solid #999;">&nbsp;&nbsp;Order By : <?php echo $order_by;?>
        
        &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;HSN Code &nbsp;: &nbsp;<?php echo $hsn_code; ?>
        </td>
        <td height="18" style="font-family:Verdana; font-size:12px;">&nbsp;Combo</td>
        <td align="center" style="font-family:Verdana; font-size:12px;">:</td>
        <td style="font-family:Verdana; font-size:12px;">&nbsp;<?php echo $combo2;?></td>
      </tr>
        <tr>
        <td valign="top" style="font-family:Verdana; font-size:12px;border-right:1px solid #999;">&nbsp;&nbsp;</td>
        <td height="18" style="font-family:Verdana; font-size:12px;">&nbsp;Po.No</td>
        <td align="center" style="font-family:Verdana; font-size:12px;">:</td>
        <td style="font-family:Verdana; font-size:12px;">&nbsp;<?php echo $cust_po_no;?></td>
      </tr>
     <?php if(($user_id=='1')||($user_id=='3'))
	 { 
	 ?>
      <tr>
        <td colspan="10" height="220" valign="top">
          <table width="100%" border="0" align="center" cellpadding="0" cellspacing="0"> 
           <tr>
       <td width="34" height="21" align="center"  style="font-family:Verdana; font-size:12px; font-weight:bold; border-bottom:1px solid #999; border-top:1px solid #999;border-right:1px solid #999;">S.No</td>
       <td width="178"  align="left"  style="font-family:Verdana; font-size:12px;font-weight:bold; border-bottom:1px solid #999; border-top:1px solid #999;border-right:1px solid #999;">&nbsp;&nbsp;Particulars</td>
              <td width="85"  align="center" style="font-family:Verdana; font-size:12px;font-weight:bold; border-bottom:1px solid #999; border-top:1px solid #999;border-right:1px solid #999;">&nbsp;Width</td>
              <td width="89"  align="center" style="font-family:Verdana; font-size:12px;font-weight:bold; border-bottom:1px solid #999; border-top:1px solid #999;border-right:1px solid #999;">&nbsp;Height</td>
              <td width="93"  align="right" style="font-family:Verdana; font-size:12px;font-weight:bold; border-bottom:1px solid #999; border-top:1px solid #999;border-right:1px solid #999;">Rate&nbsp;</td>
              <td width="87"  align="right" style="font-family:Verdana; font-size:12px;font-weight:bold; border-bottom:1px solid #999; border-top:1px solid #999;border-right:1px solid #999;">Amount&nbsp;</td>
              <td width="87"  align="right" style="font-family:Verdana; font-size:12px;font-weight:bold; border-bottom:1px solid #999; border-top:1px solid #999;border-right:1px solid #999;">ConForm Rate&nbsp;</td>
              <td width="105"  align="right" style="font-family:Verdana; font-size:12px;font-weight:bold; border-bottom:1px solid #999; border-top:1px solid #999;border-right:1px solid #999;">ConForm Amt&nbsp;</td>
              <td width="83"  align="right" style="font-family:Verdana; font-size:12px;font-weight:bold; border-bottom:1px solid #999; border-top:1px solid #999;border-right:1px solid #999;">Qty&nbsp;</td>
              <td width="94"  align="right" style="font-family:Verdana; font-size:12px;font-weight:bold; border-bottom:1px solid #999; border-top:1px solid #999">Value&nbsp;</td>
              </tr>
              <?PHP 
	$jobcard_no=$_GET['jobcard_no'];

    $sql="select * from   jobcard_sublist where jobcard_no='$jobcard_no'";
    $rs=mysql_query($sql);
	$sno=0;
   		while($rsdata=mysql_fetch_array($rs))
  			{ 
   				$sno=$sno+1;
   				$job_id=$rsdata['job_id'];
     			$jobcard_no=$rsdata['jobcard_no'];
				$particulars=$rsdata['particulars'];
   				$width=$rsdata['width'];
				$height=$rsdata['height'];
				$rate=$rsdata['rate'];
				$amount=$rsdata['amount'];
				$conformed_amt=$rsdata['conformed_amt'];
				$qty=$rsdata['qty'];
				$jobcard_values=$rsdata['jobcard_values'];
				if($weight_kg=="0.00")
				{
					$weight_kg_res='';
				}
				else
				{
					$weight_kg_res=$weight_kg;
				}
				$kg_rate=$rsdata['kg_rate'];
				
				if($kg_rate=="0.00")
				{
					$kg_rate_res='';
				}
				else
				{
					$kg_rate_res=$kg_rate;
				}
				$frieght_charge=$rsdata['frieght_charge'];
      $conformed_rate=($conformed_amt)/($width*$height);
?>
              <tr>
              <td width="34" height="26" align="center"  style="font-family:Verdana; font-size:12px;border-right:1px solid #999;border-bottom:1px solid #999;"><?php echo $sno; ?>&nbsp;</td>
              <td width="178" align="left"  style="font-family:Verdana; font-size:12px;border-right:1px solid #999;border-bottom:1px solid #999;">&nbsp;&nbsp;<?php echo $particulars; ?>&nbsp;</td>
              <td width="85" align="center" style="font-family:Verdana; font-size:12px;border-right:1px solid #999;border-bottom:1px solid #999;"><?php echo $width; ?>&nbsp;</td>
              <td width="89" align="center" style="font-family:Verdana; font-size:12px;border-right:1px solid #999;border-bottom:1px solid #999;"><?php echo $height; ?>&nbsp;</td>
              <td width="93" align="right" style="font-family:Verdana; font-size:12px;border-right:1px solid #999;border-bottom:1px solid #999;"><?php echo number_format($rate,4); ?>&nbsp;</td>
              <td width="87" align="right"  style=";font-family:Verdana; font-size:12px;border-right:1px solid #999;border-bottom:1px solid #999;"><?php echo number_format($amount,2); ?>&nbsp;&nbsp;</td>
              <td width="105" align="right" style="font-family:Verdana; font-size:12px;border-right:1px solid #999;border-bottom:1px solid #999;"><?php echo number_format($conformed_rate,4); ?>&nbsp;</td>
              <td width="105" align="right" style="font-family:Verdana; font-size:12px;border-right:1px solid #999;border-bottom:1px solid #999;"><?php echo number_format($conformed_amt,2); ?>&nbsp;</td>
              <td width="83" align="right"  style="font-family:Verdana; font-size:12px;border-right:1px solid #999;border-bottom:1px solid #999;"><?php echo $qty; ?>&nbsp;</td>
              <td width="94" align="right" style="font-family:Verdana; font-size:12px;border-bottom:1px solid #999;"><?php echo number_format($jobcard_values,2); ?>&nbsp;</td>
              </tr>
              <?php $overall_values+= $jobcard_values;
			  $qtys+= $qty;
			  } ?>
  </table>
          </td>
      </tr>
      <?php } else { ?>
          <tr>
        <td colspan="10" height="220" valign="top">
          <table width="100%" border="0" align="center" cellpadding="0" cellspacing="0"> 
           <tr>
       <td width="34" height="21" align="center"  style="font-family:Verdana; font-size:12px; font-weight:bold; border-bottom:1px solid #999; border-top:1px solid #999;border-right:1px solid #999;">S.No</td>
       <td width="178"  align="left"  style="font-family:Verdana; font-size:12px;font-weight:bold; border-bottom:1px solid #999; border-top:1px solid #999;border-right:1px solid #999;">&nbsp;&nbsp;Particulars</td>
              <td width="85"  align="center" style="font-family:Verdana; font-size:12px;font-weight:bold; border-bottom:1px solid #999; border-top:1px solid #999;border-right:1px solid #999;">&nbsp;Width</td>
              <td width="89"  align="center" style="font-family:Verdana; font-size:12px;font-weight:bold; border-bottom:1px solid #999; border-top:1px solid #999;border-right:1px solid #999;">&nbsp;Height</td>
              <td width="83"  align="right" style="font-family:Verdana; font-size:12px;font-weight:bold; border-bottom:1px solid #999; border-top:1px solid #999;border-right:1px solid #999;">Qty&nbsp;</td>
              </tr>
              <?PHP 
	$jobcard_no=$_GET['jobcard_no'];
    $sql="select * from   jobcard_sublist where jobcard_no='$jobcard_no'";
    $rs=mysql_query($sql);
	$sno=0;
   		while($rsdata=mysql_fetch_array($rs))
  			{ 
   				$sno=$sno+1;
   				$job_id=$rsdata['job_id'];
     			$jobcard_no=$rsdata['jobcard_no'];
				$particulars=$rsdata['particulars'];
   				$width=$rsdata['width'];
				$height=$rsdata['height'];
				$rate=$rsdata['rate'];
				$amount=$rsdata['amount'];
				$conformed_amt=$rsdata['conformed_amt'];
				$qty=$rsdata['qty'];
				$jobcard_values=$rsdata['jobcard_values'];
				if($weight_kg=="0.00")
				{
					$weight_kg_res='';
				}
				else
				{
					$weight_kg_res=$weight_kg;
				}
				$kg_rate=$rsdata['kg_rate'];
				
				if($kg_rate=="0.00")
				{
					$kg_rate_res='';
				}
				else
				{
					$kg_rate_res=$kg_rate;
				}
				$frieght_charge=$rsdata['frieght_charge'];
?>
              <tr>
              <td width="34" height="26" align="center"  style="font-family:Verdana; font-size:12px;border-right:1px solid #999;border-bottom:1px solid #999;"><?php echo $sno; ?>&nbsp;</td>
              <td width="178" align="left"  style="font-family:Verdana; font-size:12px;border-right:1px solid #999;border-bottom:1px solid #999;">&nbsp;&nbsp;<?php echo $particulars; ?>&nbsp;</td>
              <td width="85" align="center" style="font-family:Verdana; font-size:12px;border-right:1px solid #999;border-bottom:1px solid #999;"><?php echo $width; ?>&nbsp;</td>
              <td width="89" align="center" style="font-family:Verdana; font-size:12px;border-right:1px solid #999;border-bottom:1px solid #999;"><?php echo $height; ?>&nbsp;</td>
              <td width="83" align="right"  style="font-family:Verdana; font-size:12px;border-right:1px solid #999;border-bottom:1px solid #999;"><?php echo $qty; ?>&nbsp;</td>
              </tr>
              <?php $overall_values+= $jobcard_values;
			  $qtys+= $qty;
			  } ?>
  </table>
          </td>
      </tr>
      <?php } ?>
    </table>
    </td>
  </tr>
  <tr>
 <td>
</td>
</tr>
<?php if(($user_id=='1')||($user_id=='3'))
	 { 
	 ?>
  <tr>
    <td height="34" colspan="2"> <table width="100%" border="0" cellpadding="0" cellspacing="0" >
      <tr >
        <td width="564" height="34"   style="font-family: Verdana; font-size: 12px; border-top: 1px solid #999;  font-weight: bold;">&nbsp;&nbsp; <?php echo convert_number($overall_values);?>&nbsp;Only.<strong>&nbsp;</strong></td>
        <td width="86" align="center"   style="font-family:Verdana; font-size:12px;border-top:1px solid #999;"><span style="font-weight: bold">Qty</span> &nbsp;&nbsp;&nbsp;</td>
        <td width="87" align="left"   style="font-family:Verdana; font-size:12px;border-top:1px solid #999;border-right:1px solid #999;"><?php echo number_format($qtys,2); ?></td>
        <td width="77"  style="font-family: Verdana; font-size: 12px; border-top: 1px solid #999; font-weight: bold;">&nbsp;&nbsp;Amt</td>
        <td width="34"  style="font-family:Verdana; font-size:12px;border-top:1px solid #999;"><span style="padding-right:10px;"><?php echo number_format($overall_values,2); ?></span></td>
      </tr>
    </table></td>
  </tr>
  <?php } else { ?>
  <tr>
    <td height="34" colspan="2"> <table width="100%" border="0" cellpadding="0" cellspacing="0" >
      <tr>
        <td width="564" height="34"   style="font-family: Verdana; font-size: 12px; border-top: 1px solid #999;  font-weight: bold;">&nbsp;</td>
        <td width="86" align="center"   style="font-family:Verdana; font-size:12px;border-top:1px solid #999;"><span style="font-weight: bold">Qty</span> &nbsp;&nbsp;&nbsp;</td>
        <td width="87" align="left"   style="font-family:Verdana; font-size:12px;border-top:1px solid #999;border-right:1px solid #999;"><?php echo number_format($qtys,2); ?></td>
        </tr>
    </table></td>
  </tr>
  <?php } ?>
  <tr>
    <td colspan="2"><table width="100%" border="0" cellpadding="0" cellspacing="0" align="center">
    <tr>
    <td width="37%" style="border-top:1px solid #999;" ><?php 
	  $sql="select * from  file_upload_jobcard where job_card_no='$_GET[jobcard_no]'";
    $rs=mysql_query($sql);
	$fcount=mysql_num_rows($rs);
	$sno=0;
   		while($rsdata=mysql_fetch_array($rs))
  			{ 
   				
   				$file_id=$rsdata['file_id'];
     			$file_name=$rsdata['file_name'];
			}
			if(($fcount==1)||($fcount==0)||($fcount==''))
			{
if($file_name!='')
{
?>
<img  src="../../upload/<?php echo $file_name;?>" width="130" height="105"/>
<?php } 
else 
{ ?>
<img  src="../../img/images.jpg" width="130" height="105"/>
<?php } }?>
</td>
   <td width="17%" align="center"  valign="bottom" style="border-top:1px solid #999;border-right:1px solid #999;border-left:1px solid #999;font-family:Verdana; font-size:12px;padding:3px; font-weight:bold;" >&nbsp;&nbsp;Manager</td>
   <td width="19%" align="center"  valign="bottom" style="border-top:1px solid #999;border-right:1px solid #999;font-family:Verdana; font-size:12px;padding:3px; font-weight:bold;" >Designer Signature</td>
   <td width="27%" align="center" valign="bottom"   style="font-family: Verdana; font-size: 12px; padding: 3px; border-top: 1px solid #999; font-weight: bold;"><strong>For <span style="color: #06F">SRI AMMAN DIGITAL PRINTS</span>&nbsp;</strong>
          <p>&nbsp;</p>
          <p>Authorised Signature</p></td>
      </tr>
    </table></td>
  </tr>
</table> 
<br/><br/>
<table border="0" cellpadding="0" cellspacing="0" align="center" >
 <tr>  
 <?php
  $sql="select * from  file_upload_jobcard where job_card_no='$_GET[jobcard_no]'";
    $rs=mysql_query($sql);
	$fcount=mysql_num_rows($rs);
	$sno=0;
   		while($rsdata=mysql_fetch_array($rs))
  			{ 
			$sno=$sno+1;
?>
<td valign="bottom" style="text-align:center; font-family:Verdana, sans-serif; font-size:14px; font-weight:bold;"><?php echo  $sno;?>
</td>
<?php } ?>
</tr>
   <tr>  
 <?php
  $sql="select * from  file_upload_jobcard where job_card_no='$_GET[jobcard_no]'";
    $rs=mysql_query($sql);
	$fcount=mysql_num_rows($rs);
	$sno=0;
   		while($rsdata=mysql_fetch_array($rs))
  			{ 
   				
   				$file_id=$rsdata['file_id'];
     			$file_name=$rsdata['file_name'];
?>
<td>
<div class="box left <?php echo $val[0]; ?> leftmargin"  style="width:50%;">
<img  src="../../upload/<?php echo  $file_name;?>" width="60" height="60"/></div>
</td>
<?php } ?>
</tr>
</table>

<style>




.title {
	color: #444;
	text-align: center;
}

.section {
	margin-bottom: 1%;
}

.red {
	background: #F6B89E;
}
.green {
	background: #AFD19F;
}
.left {
	float: left;
}

.leftmargin {
	margin-right: 1%;
}

.right {
	float: right;
}
.center {
	text-align:center;
 
}


.rightmargin {
	margin-left: 1%;
}

.box {
	height: 125px;
	width:125px;
	padding-top:60px;
	padding-right:6px;
	padding-left:15px;
	padding-bottom:30px;
}

.cf {
	clear: both;
}



</style>


<?php 
function convert_number($number) 
{ 
    if (($number < 0) || ($number >99999999)) 
    { 
    throw new Exception("Number is out of range");
    } 
    $Gn = floor($number / 10000000); 
    $number -= $Gn * 1000000; 
	$ln = floor($number / 100000);  
    $number -= $ln * 100000; 
    $kn = floor($number / 1000);   
    $number -= $kn * 1000; 
    $Hn = floor($number / 100);    
    $number -= $Hn * 100; 
    $Dn = floor($number / 10);      
    $n = $number % 10;               

    $res = ""; 

    if ($Gn) 
    { 
        $res .= convert_number($Gn) . " Crores"; 
    } 
  if ($ln) 
    { 
        $res .= (empty($res) ? "" : " ") . 
            convert_number($ln) . " Laksh"; 
    } 
    if ($kn) 
    { 
        $res .= (empty($res) ? "" : " ") . 
            convert_number($kn) . " Thousand"; 
    } 

    if ($Hn) 
    { 
        $res .= (empty($res) ? "" : " ") . 
            convert_number($Hn) . " Hundred"; 
    } 

    $ones = array("", "One", "Two", "Three", "Four", "Five", "Six", 
        "Seven", "Eight", "Nine", "Ten", "Eleven", "Twelve", "Thirteen", 
        "Fourteen", "Fifteen", "Sixteen", "Seventeen", "Eightteen", 
        "Nineteen"); 
    $tens = array("", "", "Twenty", "Thirty", "Fourty", "Fifty", "Sixty", 
        "Seventy", "Eigthy", "Ninety"); 

    if ($Dn || $n) 
    { 
        if (!empty($res)) 
        { 
            $res .= " and "; 
        } 

        if ($Dn < 2) 
        { 
            $res .= $ones[$Dn * 10 + $n]; 
        } 
        else 
        { 
            $res .= $tens[$Dn]; 

            if ($n) 
            { 
                $res .= " " . $ones[$n]; 
            } 
        } 
    } 
    if (empty($res)) 
    { 
        $res = "zero"; 
    } 
    return $res; 
} 
?>       		