<html>
<head>
<link rel="stylesheet" href="../../css/jquery-ui.css" />
<link rel="stylesheet" href="../../css/jquery.autocomplete.css" type="text/css" />
<link rel="stylesheet" href="../../css/font.css" type="text/css" />
<script type="text/javascript" src="../../js/jobcard_creation_ajax.js"></script>
<script src="../../js/jquery/jquery.js" type="text/javascript"></script>
<script src="../../js/jquery/jquery-1.8.2.js"></script>
<script src="../../js/jquery/jquery-ui.js"></script>
<script type="text/javascript" src="../../js/jquery/autocomplete_jquery_plugin.js"></script>
<script src="../../js/shortcut.js"  type="text/javascript"></script>
<script type="text/javascript" src="../../js/enter_event_ajax.js"></script>

<script>
function validation()
{
 var a = document.getElementById("billing_type").value;
	if(a=='')
	{
		alert("Enter Billing Type");
		document.getElementById("billing_type").focus();
		return false;
	}
}
function validation_jobcard_sub()
{
 var jobcard_no_billing = document.getElementById("jobcard_no_billing").value;
	if(jobcard_no_billing =='')
	{
		alert("Select JobCard No");
		document.getElementById("jobcard_no_billing").focus();
		return false;
	}
}
 function billing_conform(jobcard_no,entry_date,refer,billing_type,frieght,payment_terms,tax_type,remarks,hsn_code,description,jobcard_number,action)
 {
  
 if((billing_type!=''))
{
  jQuery.ajax({
  type: "POST",
  url: "billing_conform_db.php",
  data: "jobcard_no="+jobcard_no+"&entry_date="+entry_date+"&refer="+refer+"&billing_type="+billing_type+"&frieght="+frieght+"&payment_terms="+payment_terms+"&tax_type="+tax_type+"&remarks="+remarks+"&hsn_code="+hsn_code+"&description="+description+"&jobcard_number="+jobcard_number+"&action=bill_conform",
  success: function(msg){ //alert(msg);
    jQuery("#unbill_main_list_div").html(msg);
 alert("Billed Successfully");
 window.close();
 window.opener.location.reload(true);
 }
    });
}
else
{
	validation();
}
}
 
 
function add_jobcard_sub(jobcard_no_billing,jobcard_number)
{
if((jobcard_no_billing!=''))
{
  jQuery.ajax({
  type:"POST",
  url:"billing_conform_db.php",
  data:"jobcard_no_billing="+jobcard_no_billing+"&jobcard_number="+jobcard_number+"&action=add_jobcard_sub",
  success: function(msg){jQuery("#jobcard_sublist_div").html(msg);
 }
});
}
else
{
	validation_jobcard_sub();
}
}



function delete_jobcard_sub(id,jobcard_no,jobcard_number)
{
  jQuery.ajax({
  type:"POST",
  url:"billing_conform_db.php",
  data:"id="+id+"&jobcard_no="+jobcard_no+"&jobcard_number="+jobcard_number+"&action=delete_jobcard_sub",
  success: function(msg){jQuery("#jobcard_sublist_div").html(msg);
 }
});

}
</script>
<style> 
.someclass{ 
background:url(img/plus.png) no-repeat 0 0 ; 
} 
  .types_class1 { 
    height: 25px; 
    width: 250px; 
    background-color: transparent;  
    border-style: solid;  
    border-width: 0px 0px 1px 0px;  
    border-color:#CCC; 
    outline:0;
	font-size:13px;
	font-family:Verdana;
	
  }
  input:focus {  border-color:#87BB07; }
select:focus {  border-color:#87BB07; } 
textarea:focus {  border-color:#87BB07; } 
</style> 
<?php
error_reporting(0);
include ("../../include/db.php");	
ob_start();
session_start();
$user_id = $_SESSION['login_user_id'];
  $sql="select * from jobcard_main where jobcard_no='$_GET[jobcard_no]'";
  $rs=mysql_query($sql);
  $rscount=mysql_num_rows($rs);
  while($rsdata=mysql_fetch_array($rs))
  {
	   $sno=$sno+1;
	   $from=$from+1;
	   $id=$rsdata['id'];
	   $jobcard_no=$rsdata['jobcard_no'];
	   $entry_date=$rsdata['entry_date'];
	   $created_by=$rsdata['created_by'];
	   $cust_name=$rsdata['cust_name'];
	   $style_no=$rsdata['style_no'];
	   $style_name=$rsdata['style_name'];
	   $cust_po_no=$rsdata['cust_po_no'];
	   $job_type=$rsdata['job_type'];
       $fabric_type=$rsdata['fabric_type'];
	   $combo=$rsdata['combo'];
	   $overall_value=$rsdata['overall_value'];
	   $tax=$rsdata['tax'];
	   $net_total=$rsdata['net_total'];
	   
  }
?>

<style type="text/css">.style9{ text-align:left;font-family:Tahoma, Arial, Helvetica, sans-serif; font-size: 15px; padding:0px; font-weight: 600;color:#080;letter-spacing: 1px;padding:10px; background-color:#f7f7f7;}
.text {font-family: Verdana; font-size:13px;}

</style>
<div class="container">
<div class="row-fluid">
<div class="span12">
<div class="table-responsive">
<form name="company_form"  id="company_form" method="post" action=""  enctype="multipart/form-data">
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0" style="border-top:solid 1px; color:#ddd;">
<tr align="left" style="font-size:14px"><div class="style9">Billing Conform Form</div></tr>
<td width="12%" align="left"></td>
<tr></tr></table>
<table width="100%" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF" >
         
           <tr>
    <td width="8%" height="38" rowspan="2">&nbsp;</td>
    <td width="17%" rowspan="2" align="center" class="text" style="font-size:14px; color:#080;">&nbsp;<strong><span style="color: #F00">J</span>obcard No</strong></td>
    <td width="30%" height="61" align="center" class="heading "><select id="jobcard_no_billing" name="jobcard_no_billing" style="width:200px; height:30px;" class="types_class1" autofocus>
      <option value="">--Select--</option>
   <?php
   if($_GET['refer']=='Fusing')
   {
	$sql_user=" select * from fusing_production_main where billed_status='0' and cust_name='$_GET[customer_name]' order by job_card_no DESC";
   }
   if($_GET['refer']=='Printer')
   {
	//$sql_user="select * from printer_production_main where billed_status='0' and job_type='sticker' and cust_name='$_GET[customer_name]' order by job_card_no DESC";//~query (v1 - 21-06-2022)
	
	$sql_user="select * from printer_production_main where billed_status='0' and cust_name='$_GET[customer_name]' order by job_card_no DESC"; //~edited query (v1 - 21-06-2022)
   }
		$rs_user=mysql_query($sql_user);
			while($rsdata_user=mysql_fetch_object($rs_user))
			{ 
			$job_card_no=$rsdata_user->job_card_no;
	?>
    <option value="<?php echo $job_card_no;?>"><?php echo $job_card_no;?></option>
    <?php } ?> 
    </select> &nbsp;&nbsp;&nbsp;&nbsp;<img src="../../img/plus.png" name="add_button" id="add_button" title="Add jobCard" onclick="add_jobcard_sub(jobcard_no_billing.value,'<?php echo $_GET['jobcard_number']; ?>')" align="top" width="35" height="35" border="0" tabindex="4" style="cursor:pointer; margin-left:96%; margin-top:-34px;" class="button green-button"> </td>
    <td width="13%" rowspan="2" align="right" valign="bottom" class="text" style="font-size: 14px;">Date&nbsp;&nbsp;</td>
    <td width="32%" rowspan="2" valign="bottom" class="heading "><input type="date"  name="entry_date" id="entry_date" class="types_class1" tabindex="1" style="font-size:12px; height:25px; width:170px; " value="<?php if($edit_id!='') { echo $entry_date; }  else{ echo  date('Y-m-d'); }?>"></td></tr>
           <tr>
             <td height="44" class="heading"><div id="jobcard_sublist_div">
               <?php include("jobcard_sublist.php");?>
             </div></td>
           </tr>
  <tr>
    <td height="43">&nbsp;</td>
  <td  align="right" class="text" style="padding-left:15px;font-size: 14px;">Customer Name&nbsp;&nbsp;</td>
    <td  class="text">&nbsp;&nbsp;<strong><?php echo $_GET['customer_name'];?></strong> </td>
    <td align="right" class="text" style="font-size: 14px;">Style No&nbsp;&nbsp;</td>
    <td  class="text"><strong><?php echo $style_no;?></strong></td>
  </tr>
        <tr>
    <td height="41">&nbsp;</td>
    <td class="text" align="right" style="font-size: 14px;">Job Created By&nbsp;&nbsp;</td>
    <td class="text">&nbsp;&nbsp;<strong><?php echo $created_by;?></strong></td>
    <td align="right" class="text" style="font-size: 14px;">Style Name&nbsp;&nbsp;</td>
    <td  class="text"><strong><?php echo $style_name;?></strong></td>
  </tr>

  <tr>
    <td height="35">&nbsp;</td>
    <td align="right" class="text" style="font-size: 14px;">Customer Po No&nbsp;&nbsp;</td>
    <td  class="text">&nbsp;&nbsp;<strong><?php echo $cust_po_no;?></strong></td>
    <td align="right" class="text" style="font-size: 14px;">Combo&nbsp;&nbsp;</td>
    <td  class="text"><strong><?php echo $combo;?></strong></td>
  </tr>

  <tr>
    <td height="34">&nbsp;</td>
    <td align="right" class="text" style="font-size: 14px;">Jobtype &nbsp;&nbsp; </td>
    <td  class="text">&nbsp;&nbsp;<strong><?php echo $job_type;?></strong></td>
    <td align="right">&nbsp;&nbsp;</td>
    <td></td>
  </tr>
  
    <tr>
    <td height="39">&nbsp;</td>
  <td align="right" class="text"><?php if($fabric_type!='') { ?> Fabric Type <?php } ?></td>
    <td style="padding-left:10px;" class="text"><strong><?php if($fabric_type!='') { echo $fabric_type; }?></strong></td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
  <tr>
      <td>&nbsp;</td>
  <td colspan="4" align="center"><div id="jobcard_sublist_div"></div></td>
  </tr>
  </table>
  <table width="100%">
     <tr style="padding-top:10px;">
   <td width="22%" height="44"   align="right" class="text" style="font-size: 14px; font-weight: bold;">Payment Terms</td>
    <td width="4%" align="center"><span class="text" style="font-size: 14px;"><strong><strong>:</strong></strong></span></td>
    <td width="34%" align="left" class="text" style="font-size: 14px;"><select id="payment_terms" name="payment_terms" style="width:200px; height:26px;" class="types_class1">
    <option value="">--Select--</option>
    <?php
	$sql_user="select * from  payment_terms ";
		$rs_user=mysql_query($sql_user);
			while($rsdata_user=mysql_fetch_object($rs_user))
			{ 
			$payment_terms_name=$rsdata_user->payment_terms_name;
	?>
    <option value="<?php echo $payment_terms_name;?>"<?php if($payment_terms==$payment_terms_name) {?> selected <?php } ?>><?php echo $payment_terms_name;?></option>
    <?php } ?> 
    </select></td>
        <td width="13%" class="text" style="font-size: 14px;"><strong>Frieght Charges</strong></td>
    <td width="27%"><input type="text" name="frieght" id="frieght" class="types_class1" value="" onKeyPress="if ((event.keyCode &lt; 46) || (event.keyCode &gt; 57)) event.returnValue = false,enterevent(event,'pho_no','mob_no')"  style="width:124px; font-weight:bold; font-size: 18px"></td>
   </tr>
     <tr style="padding-top:10px;">
   <td   align="right" class="text" style="font-size: 14px; font-weight: bold;">Billing Type</td>
    <td width="4%" align="center"><span class="text" style="font-size: 14px;"><strong><strong>:</strong></strong></span></td>
    <td width="34%" align="left" class="text" style="font-size: 14px;">
    <select id="billing_type" name="billing_type" style="font-family:Verdana, sans-serif; font-size:14px; width:150px; height:30px;">
    <option value="">Select</option>
    
    <option value="Estimate">Estimate</option>
    <option value="Billing">Billing</option>
    <?php if($user_id=='1'){?>
    <option value="Proforma Invoice">Proforma Invoice</option>
    <option value="Re Production Mistake">Re Production Mistake</option>
    <?php  } ?>
    </select>
    </td>
        <td width="13%" class="text" style="font-size: 14px;"><strong>Net Total</strong></td>
    <td width="27%"><input type="text" name="net_amt" id="net_amt" class="types_class1" value="<?php echo $net_total;?>" readonly style="width:124px; font-weight:bold; font-size: 18px"></td>
   </tr>
     <tr>
       <td align="right"><span class="text" style="font-size: 14px; font-weight: bold;">Tax Type</span></td>
       <td align="center" style="font-weight: bold">:</td>
       <td><select id="tax_type" name="tax_type" style="font-family:Verdana, sans-serif; font-size:14px; width:150px; height:30px;">
    <option value="">Select</option>
    <option value="IGST">IGST</option>
    <option value="IGST 18%">IGST 18%</option>
    <option value="UTGST">UTGST</option>
    <option value="GST 5%">GST 5%</option>
    <option value="GST 18%">GST 18%</option>
    <option value="GST 12%">GST 12%</option>
    </select>&nbsp;</td>
       <td class="text" style="font-size: 14px; font-weight: bold;">&nbsp;Remarks</td>
       <td>&nbsp;<textarea name="remarks" id="remarks"></textarea></td>
     </tr>
     <tr>
      <td align="right"><span class="text" style="font-size: 14px; font-weight: bold;">HSN Code</span></td>
       <td align="center" style="font-weight: bold">:</td>
       <td><select id="hsn_code" name="hsn_code" style="font-family:Verdana, sans-serif; font-size:14px; width:150px; height:30px;">
         <option value="">Select</option>
    <option value="998821">998821</option>
    <option value="4801">4801</option>
    </select>&nbsp;</td>
       
       <td class="text" style="font-size: 14px; font-weight: bold;">&nbsp;Description</td>
       <td>&nbsp;<textarea name="description" id="description"></textarea></td>
     </tr>
     <tr>
  <td colspan="5">&nbsp;</td>
   </tr>
    <tr>
   <td align="center" colspan="5"><input type="button" name="submit" tabindex="20" id="submit" style="background-color: #87BB07;    color: #fff;    border: 0px; font-family:verdana; font-size:14px; width:120px; height:27px; " value="Conform" class="button" onClick="billing_conform('<?php echo $_GET[jobcard_no];?>',entry_date.value,'<?php echo $_GET[refer];?>',billing_type.value,frieght.value,payment_terms.value,tax_type.value,remarks.value,hsn_code.value,description.value,'<?php echo $_GET['jobcard_number'];?>',this.value)"></td>
          </tr>
        </table>
</form>
</div>
</div>
</div>
</div>
