<style type="text/css">
.header{
	font-family: Cambria, "Hoefler Text", "Liberation Serif", Times, "Times New Roman", serif;
	font-size: 55px;
	color: #06F;
}
.headersub{line-height:25px;color:#333333;}
.padleft{padding-left:15px;}
.title00{
	color: #000033;
	font-family: Segoe, "Segoe UI", "DejaVu Sans", "Trebuchet MS", Verdana, sans-serif;
	font-size: 17px;
}
.style34{font-size: 15px; font-style: normal; font-weight: bold;}
.title0{color:#000033;font-family:Calibri;font-size:16px;}
.title1{color: #000033;font-family:Calibri;font-size: 17px;}
.title20{font-style:normal;color:#000033;padding-left:5px}
.title2a{
	font-style: normal;
	color: #000033;
	padding-left: 5px;
	font-size: 17px;
}

.title2{font-style:normal;color:#000033;font-weight:bold;padding-left:5px}
.title3{text-align:top;font-size:1px;font-family:Verdana, Arial, Helvetica, sans-serif;}
.title4{font-style:normal;color:#000033;padding-left:15px;font-size:15px;font-family:Verdana, Arial, Helvetica, sans-serif;}
.title5{font-style:normal;color:#000033;font-weight:bold;padding-right:15px;font-size:15px;text-align:center;font-family:Verdana, Arial, Helvetica, sans-serif;}
.title6{font-style:normal;color:#000033;padding-left:15px;font-size:15px;line-height:18px;font-family:Verdana, Arial, Helvetica, sans-serif;}
.title7{font-style:normal;color:#000033;padding-left:15px;font-size:15px;font-family:Verdana, Arial, Helvetica, sans-serif;font-weight:bold;}
.style1{ border-top:solid 1px; border-color:#000000; }
.style2 {border-left:solid 1px;  border-color:#000000;}
.style3 {border-bottom:solid 1px;  border-color:#000000;}
.style31 {border-bottom:solid 1px #999999 ;}
.style32 {border-right:solid 1px #999999 ;}
.style33 {border-left:solid 1px #999999 ;}
.style4 {border-right:solid 1px;  border-color:#000000;}
.stylelg {border-left:solid 1px;  border-color:#D3D3D3;}
.styleg {border-left:solid 1px;  border-color:#808080;}
.styleri {border-right:solid 1px ; border-color:#000000;}
.stylele {border-left:solid 1px ; border-color:#000000;}
.text_goods{color:#000033;font-family:Calibri;font-size:14px;}
</style>
    <?php 
include ("../../include/db.php");

function convert_number($number) 
{ 
    if (($number < 0) || ($number >99999999)) 
    { 
    throw new Exception("Number is out of range");
    } 
    $Gn = floor($number / 10000000);  /* Crores (giga) */ 
    $number -= $Gn * 1000000; 
	$ln = floor($number / 100000);   /* laksh (giga1) */ 
    $number -= $ln * 100000; 
    $kn = floor($number / 1000);     /* Thousands (kilo) */ 
    $number -= $kn * 1000; 
    $Hn = floor($number / 100);      /* Hundreds (hecto) */ 
    $number -= $Hn * 100; 
    $Dn = floor($number / 10);       /* Tens (deca) */ 
    $n = $number % 10;               /* Ones */ 

    $res = ""; 

    if ($Gn) 
    { 
        $res .= convert_number($Gn) . " Crores"; 
    } 
  if ($ln) 
    { 
        $res .= (empty($res) ? "" : " ") . 
            convert_number($ln) . " Lakhs"; 
    } 
    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", "Eighteen", 
        "Nineteen"); 
    $tens = array("", "", "Twenty", "Thirty", "Fourty", "Fifty", "Sixty", 
        "Seventy", "Eighty", "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; 
	
} 

function get_inward_dc_no($jobcard_no1)
  {
	$sql_user="select * from inward_main where jobcard_no='$jobcard_no1' ";
	$rs_user=mysql_query($sql_user);
	while($rsdata_user=mysql_fetch_object($rs_user))
	{ 
	$customer_dc_no=$rsdata_user->customer_dc_no;
	}
	return $customer_dc_no;
 } 
 
 
 
 function get_estimate_type11($jobcard_no1)
  {
	  $sql_user="select billing_type as billing_type,remarks as remarks,description as description from fusing_production_main where job_card_no='$jobcard_no1' and billing_type!=''  union select billing_type as billing_type,remarks as remarks,description as description from printer_production_main where job_card_no='$jobcard_no1' and billing_type!=''";
	$rs_user=mysql_query($sql_user);
	while($rsdata_user=mysql_fetch_object($rs_user))
	{ 
	$billing_type=$rsdata_user->billing_type;
	$remarks=$rsdata_user->remarks;
	$description=$rsdata_user->description;
	}
	return array($billing_type,$remarks,$description);
 } 
 
 
 function get_invoice_no($jobcard_no1)
  {
	$sql_user="select invoice_no as invoice_no from fusing_production_main where job_card_no='$jobcard_no1' and invoice_no!='' union select invoice_no as invoice_no from printer_production_main where job_card_no='$jobcard_no1' and invoice_no!=''";
	$rs_user=mysql_query($sql_user);
	while($rsdata_user=mysql_fetch_object($rs_user))
	{ 
	$invoice_no=$rsdata_user->invoice_no;
	}
	return $invoice_no;
 } 
  
 function get_created_dates($jobcard_no1)
  {
	$sql_user="select bill_date as bill_date from fusing_production_main where job_card_no='$jobcard_no1' and invoice_no!='' union select bill_date as bill_date from printer_production_main where job_card_no='$jobcard_no1' and invoice_no!=''";
	$rs_user=mysql_query($sql_user);
	while($rsdata_user=mysql_fetch_object($rs_user))
	{ 
	$bill_date=$rsdata_user->bill_date;
	}
	return $bill_date;
 } 
 
    $job_card_no=$_GET['job_card_no'];
    $sql="select * from jobcard_main where jobcard_no='$job_card_no' ";
	$rs=mysql_query($sql);
	$sno=0;
	$from=0;
   		while($rsdata=mysql_fetch_array($rs))		
		{
   				$sno=$sno+1;
				$from=$from+1;
           	    $jobcard_no1=$rsdata['jobcard_no'];
			    $createdate=$rsdata['createdate'];
			    $print_date=$rsdata['print_date'];
	   		    $job_created=$rsdata['job_created'];
			    $cust_name=$rsdata['cust_name'];
	   		    $cust_po=$rsdata['cust_po'];
	   			$style_no=$rsdata['style_no'];
	   			$style_name=$rsdata['style_name'];
				$combo=$rsdata['combo'];
	   			$printed_qty=$rsdata['printed_qty'];
				$billed_status=$rsdata['billed_status'];
		    	$job_type=$rsdata['job_type'];
				$amount=$rsdata['amount'];
				$cust_po_no=$rsdata['cust_po_no'];
				$qty =$rsdata['qty'];
				$jobcard_values=$rsdata['jobcard_values'];
				$inward_dc_no = get_inward_dc_no($jobcard_no1);
			    list($estimate_type,$remark,$desc) = get_estimate_type11($jobcard_no1);
				$invoice_no = get_invoice_no($jobcard_no1);
				$dates=get_created_dates($jobcard_no1);
				}
  
     $sql="select * from party_creation where party_name='$cust_name' and delete_status!='1'  order by party_name ASC ";
	 $rs1=mysql_query($sql);
   		while($rsdata=mysql_fetch_array($rs1))		
		{
           	    $party_no=$rsdata['party_no'];
			    $party_name1=$rsdata['party_name'];
			    $mobile_no=$rsdata['mobile_no'];
	   		    $phone_no=$rsdata['phone_no'];
			    $address=$rsdata['address'];
	   		    $city=$rsdata['city'];
	   			$cst_no=$rsdata['cst_no'];
	   			$tin_no=$rsdata['tin_no'];
}
?><table width="850" align="center" border="0" cellspacing="0" cellpadding="0" class="style1 style2  style4">
  <tr>
    <td colspan="5"><table width="100%" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td height="23" colspan="3"><span class="title1"><b>&nbsp;&nbsp;To,</b></span></td>
        <td width="38%" align="right" valign="bottom" class="style2">&nbsp;</td>
          <td width="38%" align="right" valign="bottom" class="style2">&nbsp;</td>
      </tr>
      <tr>
        <td height="23" colspan="3" valign="top" ><span class="title1"><b>&nbsp;&nbsp;M/s :</b>&nbsp;<span style="color:#06F; font-weight:bold;"><?php  echo $party_name1; ?></span>
        </span></td>
        <td  align="left" valign="bottom" class="title0 style2"><b> &nbsp;Estimate No</b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:&nbsp; &nbsp;<?php echo $invoice_no; ?></td>
          <td width="38%" align="right" valign="bottom" class="style2">&nbsp;</td>
      </tr>
      <tr>
        <td height="22" colspan="3" valign="top" class="padleft"><span class="title1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
          <?php  echo $address; ?>
        </span></td>
        <td  align="left" valign="bottom" class="title0 style2"><b>&nbsp;Estimate Date</b>&nbsp;&nbsp;:&nbsp;  <?php  echo date("d-m-Y",strtotime($dates)); ?></td>  <td width="38%" align="right" valign="bottom" class="style2">&nbsp;</td>
        </tr>
      <tr>
        <td height="22" colspan="2" valign="top" class="padleft" ><span class=" title1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
          <?php  echo $city; ?>
        </span></td>
        <td width="45%" height="22" align="left" valign="top" class=" title1"></td>
        <td  align="left" valign="bottom" class="title0 style2"><b>&nbsp;Jobcard No</b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;:&nbsp;<?php echo $job_card_no;?></td>  <td width="38%" align="right" valign="bottom" class="style2">&nbsp;</td>
        </tr>
    
    </table></td>
  </tr>
  <tr height="" class="style32">
    <td height="" colspan="5" valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td height="35" align="center" bgcolor="#CCCCCC"  class="style1 style3 title0 style4"><b>OUR <br>
        DC NO</b></td>
        <td align="left" bgcolor="#CCCCCC" class="style1 style3  title0" style="text-align: center"><b>&nbsp;DESCRIPTION OF PRINT</b></td>
        <td align="right" bgcolor="#CCCCCC" class="style1 style3 style2 title0 style4" style="text-align: center"><span style="font-family: Calibri; text-align: center;"><b>QTY</b></span><b>&nbsp;</b></td>
        <td align="right" bgcolor="#CCCCCC" class="style1 style3  title0 style4" style="text-align: center"><b><span style="text-align: center"></span>RATE&nbsp;</b></td>
        <td align="right" bgcolor="#CCCCCC" class="style1 style3  title0 " style="text-align: center"><b>AMOUNT&nbsp;</b></td>
      </tr>
      <?php $job_card_no=$_GET['job_card_no'];
	  
	  function get_dc_no($jobcard_no)
  {
	$sql_user="select * from delivery_challan_main where job_no='$jobcard_no' ";
	$rs_user=mysql_query($sql_user);
	while($rsdata_user=mysql_fetch_object($rs_user))
	{ 
	$delivery_no=$rsdata_user->delivery_no;
	}
	return $delivery_no;
 } 
 
 
       function get_freight_charges($jobcard_no)
  {
   $sql="select frieght_charges as frieght from printer_production_main where job_card_no='$jobcard_no' union select frieght_charges as frieght from fusing_production_main where job_card_no='$jobcard_no'";
 $rs1=mysql_query($sql);
 while($rsdata=mysql_fetch_array($rs1))		
		{
		$frieght_charges=$rsdata['frieght'];
		}
 return $frieght_charges;
 } 
 $frieght_charges=get_freight_charges($job_card_no);
   $sql="select * from jobcard_sublist where jobcard_no='$job_card_no'";
   $sno=0;
	 $rs=mysql_query($sql);
	  $rscount=mysql_num_rows($rs);
   		while($rsdata=mysql_fetch_array($rs))		
		{
	    $sno=$sno+1;
		$conformed_amt=$rsdata['conformed_amt'];
		$jobcard_no=$rsdata['jobcard_no'];
	    $qty =$rsdata['qty'];
		$dc_nos=get_dc_no($jobcard_no);
		$jobcard_values=$rsdata['jobcard_values'];
		$particulars=$rsdata['particulars'];
	   
		?>
      <tr height="20px">
        <td  width="81" align="center" class=" style31 title0 style4">&nbsp;<?php echo $dc_nos; ?></td>
        <td class="style31  text_goods" width="515" align="left">&nbsp;<?php echo $particulars; ?> <?php echo "- Sublimation Printing Charges"; ?></td>
        <td class="style31 style32 title0 style33" width="72" align="right"><span><?php echo $qty; ?>&nbsp;</span></td>
        <td class="style31 style32 title0" width="84" align="right"><span ><?php echo number_format($conformed_amt,2); ?>&nbsp;</span></td>
        <td class="style31 title0" width="95" align="right"><?php echo number_format($jobcard_values,2); ?>&nbsp;</td>
      </tr>
      <?php  
	  $total+=$jobcard_values;
	  $qtys+=$qty;
	  }
	  if($rscount=='33')
			{
				$height='125px';
			}
	if($rscount=='32')
			{
				$height='135px';
			}
	  if($rscount=='31')
			{
				$height='155px';
			}
	  
	  if($rscount=='30')
			{
				$height='170px';
			}
	  if($rscount=='29')
			{
				$height='185px';
			}
	   if($rscount=='28')
			{
				$height='205px';
			} 
	     if($rscount=='27')
			{
				$height='215px';
			} 
	      if($rscount=='26')
			{
				$height='225px';
			} 
	      if($rscount=='25')
			{
				$height='235px';
			} 
	       if($rscount=='24')
			{
				$height='245px';
			} 
	   		if($rscount=='23')
			{
				$height='345px';
			} 
			 if($rscount=='22')
			{
				$height='250px';
			} 
			 if($rscount=='21')
			{
				$height='365px';
			} 
			 if($rscount=='20')
			{
				$height='370px';
			} 
	  		 if($rscount=='19')
			{
				$height='380px';
			} 
			 if($rscount=='18')
			{
				$height='385px';
			} 
	  		 if($rscount=='17')
			{
				$height='350px';
			} 
	 		 if($rscount=='16')
			{
				$height='465px';
			} 
	   		if($rscount=='15')
			{
				$height='475px';
			} 
			if($rscount=='14')
			{
				$height='490px';
			} 
			if($rscount=='13')
			{
				$height='370px';
			} 
			if($rscount=='12')
			{
				$height='380px';
			} 
			if($rscount=='11')
			{
				$height='490px';
			}
	  	    if($rscount=='10')
			{
				$height='520px';
			}
				if($rscount=='9')
			{
				$height='480px';
			}
			if($rscount=='8')
			{
				$height='500px';
			}
			if($rscount=='7')
			{
			$height='480px';
			}	
			if($rscount=='6')
			{
				$height='500px';
			}	
			if($rscount=='5')
			{
				$height='540px';
			}	
			if($rscount=='4')
			{
				$height='580px';
			}	
			if($rscount=='3')
			{
			$height='590px';
			}	
			if($rscount=='2')
			{
			$height='620px';
			}	
			if($rscount=='1')
			{
			$height='650px;';
			}	
				?>
                 <?php if($frieght_charges!='') { ?>
             <tr height="20px">
              <td  width="81"  align="left" class=" style31 style32 title0">&nbsp;</td>
              <td class="style31   title0 style32" width="515" align="left">&nbsp;Freight Charges</td>
              <td class="style31  title0 style32" width="72" align="right"><span>&nbsp;</span></td>
              <td class="style31  title0 style32" width="84" align="right"><span style="color:black;">&nbsp;</span></td>
              <td class="style31  title0 " width="95" align="right" style="color:black"><?php echo number_format($frieght_charges,2); ?>&nbsp;</td>
            </tr> <?php } ?>
            <tr height="<?php echo $height;?>">
              <td  width="81" height="19"  align="left" class=" style32 title0">&nbsp;</td>
              <td class="title0 style32" width="515" align="left">&nbsp;</td>
              <td class="title0 style32" width="72" align="right"><span>&nbsp;</span></td>
              <td class="title0 style32" width="84" align="right"><span style="color:black;">&nbsp;</span></td>
              <td class="title0 " width="95" align="right" style="color:black">&nbsp;</td>
            </tr>   
            <tr >
   
        <td width="81" rowspan="2" class="style3 style32">&nbsp;</td>
        <td width="515" align="left" valign="bottom" class=" title2a title0">&nbsp;&nbsp;<?php echo $remark; ?><br/>
        &nbsp;&nbsp;<?php echo $desc; ?><br/>
          STYLE No&nbsp;&nbsp;:&nbsp;&nbsp;<?php echo $style_no; ?><br/>
          COMBO&nbsp;&nbsp;:</b>&nbsp;&nbsp;<?php echo $combo; ?><br/>
          DESIGN NAME&nbsp;&nbsp;:&nbsp;&nbsp;<?php echo $style_name; ?> <br/>
          PARTY DC No&nbsp;&nbsp;:&nbsp;&nbsp;<?php echo $inward_dc_no; ?> <br/>
          </span></td>
        <td width="72" align="left" valign="bottom" class="style32 title2 title0 style33">&nbsp;</td>
        <td width="84" align="left" valign="bottom" class="style32 title2 title0">&nbsp;</td>
        <td width="95" align="left" valign="bottom" class="title2 title0">&nbsp;</td>
      </tr>
      <tr>
        <td colspan="4" class="style2 style3"></td>
        <td width="1" class=" "></td>
      </tr>
      <tr height="40px">
        <td height="43" class="style3 style4"><span class="title00" style="color: #000; font-weight:bold;">&nbsp;&nbsp;Amount &nbsp;</span></td>
        <td height="43"  class="title0 style3 " style="color:black;font-size:16px;"> &nbsp;&nbsp;&nbsp;<?php echo convert_number(($total+$frieght_charges));?>&nbsp; <span>Rupees Only</span></td>
        <td align="right" class="style3 style4 title4" style=" font-size: 14px; font-weight: bold;"><?php echo $qtys; ?>&nbsp;&nbsp;</td>
        <td align="center" class="style3 style4"><span class="title0" style="text-align:right"><b>TOTAL</b></span></td>
        <td align="right" class="style3 "><span class="title4" style="padding-left: 40px; font-size: 14px; font-weight: bold;"><?php $a=round($total+$frieght_charges);
		echo number_format($a,2); ?></span>&nbsp;&nbsp;</td>
        </tr>
 </table></td></tr>
      
  
  <tr>
    <td width="299" height="116" class="style3" valign="bottom"><span class="title0" style="text-align:inherit"><b>&nbsp;Received by</b></span></td>
    <td width="265" colspan="0"  class=" style3 style2" valign="bottom" align="center"><span class="title0"><b>Prepared by</b></span></td>
    <td width="284" colspan="0" align="center" class="style2 style3 title0" style="padding-top:30px" ><p style="font-size: 14px;"></p>
     <p><br/><br/><br/>
    <span class="title0" style="line-height:25px;text-align:cenetr;" >Authorized Signatory</span></p></td>
  </tr>
</table>