<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/inward_entry_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 print_inward(url)
{	
onmouseover10= window.open(url,'onmouseover10','height=400,width=650,scrollbars=no,resizable=no,left=50,top=50,toolbar=no,location=no,directories=no,status=no');	
}

var sm = jQuery.noConflict();
sm().ready(function() 
{ 
	sm("#in_jobcard_no").autocomplete("include/autocomplete/jobcard_no_autocomplete.php", {
	width: 250,
	matchContains: true,
	selectFirst: true
	});	
});


 function order_entry_search(from_date,to_date,customer_name)
 {
  jQuery.ajax({
  type: "POST",
  url: "order/order_entry/order_entry_list.php",
  data: "from_date="+from_date+"&to_date="+to_date+"&customer_name="+customer_name,
  success: function(msg){jQuery("#order_main_list_div").html(msg);
 }
    });
 }
 
 function inward_close()
{
window.location.href="main_fram.php?file=inward_enrty_list";
window.location.reaload(true);
}

function reload_div() 
{
	jQuery("#reload_div").load(location.href + " #reload_div");
}
</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);
date_default_timezone_set('Asia/Kolkata');
include ("include/db.php");	
$from_date=$_POST['from_date'];
$to_date=$_POST['to_date'];
/******************** Auto Generated ID*********************************************/
$date=date("Y");
$st_date=substr($date,2);
$month=date("m");	   
$datee=$st_date.$month;
$edit_id=$_GET['edit_id'];
ob_start();
session_start();
function get_user_type($login_user_name,$login_pass_word)
{
    $sql_user="select * from  user_creation where user_name='$login_user_name' and password='$login_pass_word'";
	$rs_user=mysql_query($sql_user);
	while($rsdata_user=mysql_fetch_object($rs_user))
	{ 
	$user_type=$rsdata_user->user_type;
	}
	return $user_type;
}

function get_branch_names2($book_branchs1)
{
    $sql_user="select * from  branch_creation where branch_id='$book_branchs1'";
	$rs_user=mysql_query($sql_user);
	while($rsdata_user=mysql_fetch_object($rs_user))
	{ 
	$branch_name=$rsdata_user->branch_name;
	}
	return $branch_name;
}

$login_user_name=$_SESSION['login_user_name'];
$login_pass_word=$_SESSION['login_pass_word'];
$book_branchs1=$_SESSION['branch'];
$get_user_type=get_user_type($login_user_name,$login_pass_word);
$get_branch_names=get_branch_names2($book_branchs1);


function get_branch_place_names($branch_places12)
{
    $sql_user="select * from  place_creation where id='$branch_places12'";
	$rs_user=mysql_query($sql_user);
	while($rsdata_user=mysql_fetch_object($rs_user))
	{ 
	$location=$rsdata_user->location;
	}
	return $location;
}

if($_GET['edit_id']!='')
{
$table_display_styles1='style="display:inline;"';
} 
else
{
$table_display_stylesss='style="display:none;"';
}

  $in_edit_id=$_GET['edit_id'];
  $sql="select * from inward_main where main_id='$_GET[edit_id]'";
  $rs=mysql_query($sql);
  $rscount=mysql_num_rows($rs);
 
  while($rsdata=mysql_fetch_array($rs))
  {
	   $sno=$sno+1;
	   $from=$from+1;
	   $main_id=$rsdata['main_id'];
	   $jobcard_nos=$rsdata['jobcard_no'];
	   $entry_dates=$rsdata['entry_date'];
	   $created_bys=$rsdata['created_by'];
	   $cust_names=$rsdata['cust_name'];
	   $style_nos=$rsdata['style_no'];
	   $style_names=$rsdata['style_name'];
	   $cust_po_nos=$rsdata['cust_po_no'];
	   $job_types=$rsdata['job_type'];
       $fabric_types=$rsdata['fabric_type'];
	   $combos=$rsdata['combo'];
	   $overall_values=$rsdata['overall_value'];
	   $total_pieces=$rsdata['total_piece'];
	   $customer_dc_nos=$rsdata['customer_dc_no'];
	   $receipt11=$rsdata['receipt'];
	   $invoice_nos1=$rsdata['invoice_no'];
	    $delivery_through11=$rsdata['delivery_through'];
		$vehicle_no11=$rsdata['vehicle_no'];
  }
  
$date=date("Y");
$st_date=substr($date,2);
$month=date("m");	   
$datee=$st_date.$month;

	$rs1=mysql_query("select customer_dc_no from  inward_main order by main_id desc");
	if($res1=mysql_fetch_assoc($rs1))
	{
		$inward_array=explode('-',$res1['customer_dc_no']);
	    $year1=$inward_array[1];
        $year2=substr($year1, 0, 2);
	    $year='20'.$year2;
		$invoice_no=$inward_array[2];
	}
	if($invoice_no=='')
		$invoice_number='INV-'.$datee.'-0001';
	else
	{
		$invoice_no+=1;
		$invoice_number='INV-'.$datee.'-'.str_pad($invoice_no, 4, '0', STR_PAD_LEFT);
	}
	
	$fulldate=date("Y-m-d");
		  $fyear=date("Y");
		  $current_date=$fulldate;
		  $cur_year=$fyear;
	  
		  $acc_from=$cur_year."-04-01"; 
		  if($acc_from<=$current_date)
		  { 
		    	$fyear=date("Y");
		    	$eyear=date("Y")+1;
		  }
		  if($acc_from>$current_date)
		  {
		 		$fyear=date("Y")-1;
		 		$eyear=date("Y");
		  }
		 $start_year=$fyear."-04-01"; 
		 $end_year=$eyear."-03-31"; 

$curyear=date('Y');
$curmon=date('m');
$next_year=$curyear+1;

if(($curmon>=4)&&($curyear==$curyear-1)||($curmon<=3)&&($curyear==$curyear))
{
	$academic=$curyear-1;
}
else
{
	$academic=$curyear;
}

	$date=date("Y");
$st_date=substr($date,2);
$month=date("m");	   
$datee=$st_date.$month;

	$rs1=mysql_query("select invoice_no from  inward_main  where createdate>='$start_year' and createdate<='$end_year' order by main_id desc");
	if($res1=mysql_fetch_assoc($rs1))
	{
		$inward_array=explode('-',$res1['invoice_no']);
	    $year1=$inward_array[1];
        $year2=substr($year1, 0, 2);
	    $year='20'.$year2;
		$invoice_no1=$inward_array[2];
	}
	if($invoice_no1=='')
		$invoice_number1='GRN-'.$datee.'-0001';
	else
	{
		$invoice_no1+=1;
		$invoice_number1='GRN-'.$datee.'-'.str_pad($invoice_no1, 4, '0', STR_PAD_LEFT);
	}
?>

<style type="text/css">
.style2 {color: #FF0000}
.style7{font-family: Tahoma, Arial, Helvetica, sans-serif;font-size: 13px;}
.style8{ text-align:center;font-family:Tahoma, Arial, Helvetica, sans-serif; font-size: 15px; padding:40px; font-weight: 500;color:#32328e;letter-spacing: 1px;}
.style9{ text-align:left;font-family:Tahoma, Arial, Helvetica, sans-serif; font-size: 15px; padding:0px; font-weight: 600;letter-spacing: 1px;padding:10px; background-color:#f7f7f7; color:#000;}
.style4 {border-bottom: solid 1px;border-bottom-color: #CCCCCC;}
.style5 {border-left: solid 1px;border-left-color: #CCCCCC;}
.text {font-family: Verdana; font-size:13px;}

</style>
<div class="container">
<div class="row-fluid">
<div class="span12">
<div class="table-responsive">
<form name="inward_form"  id="inward_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; color:#000"><div class="style9">Inward Entry Form</div></tr>
<td width="12%" align="left"><img src="img/wrong.png" name="add_button" id="add_button" title="Inward Close"  onclick="javascript:inward_close()" align="top" width="30" height="30" border="0"  style="cursor:pointer; margin-left:96%; margin-top:-34px;" class="button green-button" >
</td>
<tr></tr></table>
<table width="100%" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF" >
          <tr>
            <td width="89" height="35"></td>
            <td width="252" align="right" class="text" style="padding-right: 50px; font-size: 14px; color:#F03;">&nbsp;<span style="color: #C30"><strong>Jobcard No</strong></span><strong> *</strong></td>
            <td width="397" style="padding-left:30px;"><span class="text" style="font-size:14px; color:#080;">
              <input type="text" class="types_class1" name="in_jobcard_no" id="in_jobcard_no" style="width:250px; height:20px; font-size:14px;" autofocus  value="<?php if($in_edit_id!='') { echo $jobcard_nos; } else { } ?>" onKeyUp="get_customer_inward(this.value),get_created_by(this.value),get_style_no(this.value),get_customer_po(this.value),get_style_name(this.value),get_combo(this.value),get_job_type(this.value),get_fabric_types(this.value),inward_main_clear_validation(this.value),get_inward_jobcard(this.value),get_total_piece(this.value),get_particulars(this.value),enterevent(event,'inward_date','in_jobcard_no');"
              onfocus="get_customer_inward(this.value),get_created_by(this.value),get_style_no(this.value),get_customer_po(this.value),get_style_name(this.value),get_combo(this.value),get_job_type(this.value),get_fabric_types(this.value),inward_main_clear_validation(this.value),get_inward_jobcard(this.value),get_total_piece(this.value),get_particulars(this.value);"   tabindex="1"></span><div id="in_jobcard_no_validation_div" style="color:#F00; font-size:14px; font-family:Verdana, sans-serif;"></div></td>
            <td width="292" align="right" class="text" style="padding-right: 50px; font-size: 14px;">Date &amp; Time</td>
            <td width="293" align="left" class="txt">
              <input type="datetime-local"  name="inward_date"  <?php if($_SESSION['user_type']!=1) { ?> readonly <?php } ?>  id="inward_date" class="types_class1" onKeyUp="enterevent(event,'customer_dc_no','inward_date')"  tabindex="1" style="font-size:12px; height:25px; width:190px; " value="<?php if($in_edit_id!='') { echo $entry_dates; }  else{ echo  date('Y-m-d').'T'.date('H:i'); }?>"></td>
          </tr>
          <tr>
            <td height="32"></td>
            <td align="right" class="text" style="padding-right: 50px; font-size: 14px;">Customer Name</td>
            <td style="padding-left:30px;">
          <div id="inward_customer"> <input type="hidden" class="types_class1" name="in_cust_name" id="in_cust_name" onKeyUp="inward_sub_clear_validation(this.id),enterevent(event,'created_by','in_cust_name')" style="width:250px; height:20px;"   value="<?php if($in_edit_id!='') { echo $cust_names; } else { } ?>" ><span style="font-family: Verdana, sans-serif; font-size:14px ;font-weight:bold"><?php if($in_edit_id!='') { echo $cust_names; } else { } ?></span></div>
           <div id="in_cust_name_validation_div" style="color:#F00"></div></td>
            <td class="text" align="right" style="padding-right: 50px; font-size: 14px;">Entry Created By</td>
            <td align="left" class="txt"><div id="created_by_div"><input type="hidden" class="types_class1" name="created_by" id="created_by" onKeyUp=",enterevent(event,'customer_po','created_by')"  style="width:250px; height:20px;" value="<?php if($in_edit_id!='') { echo $created_bys; }  ?>" ><span style="font-family: Verdana, sans-serif; font-size:14px ;font-weight:bold"><?php if($in_edit_id!='') { echo $created_bys; }  ?></span></div></td>
          </tr>
          <tr>
            <td height="31"></td>
          <td align="right" class="text" style="padding-right: 50px; font-family: Verdana; font-size: 14px;">Customer PO NO</td>
            <td style="padding-left:30px;"><div id="customer_po_div"><input type="hidden" class="types_class1" name="customer_po" id="customer_po" value="<?php if($in_edit_id!='') { echo $cust_po_nos; } else { } ?>" style="width:250px; height:20px;"><span style="font-family: Verdana, sans-serif; font-size:14px ;font-weight:bold"><?php if($in_edit_id!='') { echo $cust_po_nos; } else { } ?></span></div></td>
            <td class="text" align="right" style="padding-right: 50px; font-size: 14px;">&nbsp;Style No</td>
            <td align="left" class="txt"><div id="style_no_div"><input type="hidden" class="types_class1" name="style_no" id="style_no" value="<?php if($in_edit_id!='') { echo $style_nos; } else { } ?>" style="width:250px; height:20px;"><span style="font-family: Verdana, sans-serif; font-size:14px ;font-weight:bold"><?php if($in_edit_id!='') { echo $style_nos; } else { } ?></span></div></td>
          </tr>
          <tr>
            <td height="37"></td>
            <td align="right" class="text" style="padding-right: 50px; font-size: 14px;">Job Type </td>
            <td style="padding-left:30px;"><div id="job_types_div"><input type="hidden" class="types_class1" name="job_types" id="job_types" value="<?php if($in_edit_id!='') { echo $job_types; } else { } ?>" style="width:250px; height:20px;"><span style="font-family: Verdana, sans-serif; font-size:14px ;font-weight:bold"><?php if($in_edit_id!='') { echo $job_types; } else { } ?></span></div></td>
            <td class="text" align="right" style="padding-right: 50px; font-size: 14px;">&nbsp;Style Name</td>
            <td>
              <div id="style_name_div"><input type="hidden" class="types_class1" name="style_name" id="style_name" value="<?php if($in_edit_id!='') { echo $style_names; } else { } ?>" style="width:250px; height:20px;"><span style="font-family: Verdana, sans-serif; font-size:14px ;font-weight:bold"><?php if($in_edit_id!='') { echo $style_names; } else { } ?></span></div></td>
          </tr>
          <tr>
            <td height="35" >&nbsp;</td>
            <td align="right" class="text" style="padding-right: 50px; font-size: 14px;">Fabric Type</td>
            <td align="left"   class="text" style="padding-left:28px;"><div id="fabric_type_div"><input type="hidden" class="types_class1" name="fabric_type" id="fabric_type" value="<?php if($in_edit_id!='') { echo $fabric_types; } else { } ?>" style="width:250px; height:20px;"><span style="font-family: Verdana, sans-serif; font-size:14px ;font-weight:bold"><?php if($in_edit_id!='') { echo $fabric_types; } else { } ?></span></div></td>
            <td align="right"  class="text" style="padding-right: 50px; font-size: 14px;">Combo</td>
            <td align="left"  class="text" ><div id="combo_type_div"><input type="hidden" class="types_class1" name="combo_type" id="combo_type" value="<?php if($in_edit_id!='') { echo $combos; } else { } ?>" style="width:250px; height:20px;"><span style="font-family: Verdana, sans-serif; font-size:14px ;font-weight:bold"><?php if($in_edit_id!='') { echo $combos; } else { } ?></span></div></td>
            </tr>
          <tr>
            <td height="37" align="center" >&nbsp;</td>
            <td height="37" align="right" class="text" style="padding-right: 50px; font-size: 14px;">Total Piece</td>
            <td height="37" align="left"   class="text" style="padding-left:28px;" ><div id="total_piece_div"><input type="hidden" class="types_class1" name="total_piece" id="total_piece" value="<?php if($in_edit_id!='') { echo $total_pieces; } else { } ?>" style="width:250px; height:20px;"><span style="font-family: Verdana, sans-serif; font-size:14px ;font-weight:bold"><?php if($in_edit_id!='') { echo $total_pieces; } else { } ?></span></div></td>
          
            <td align="right"  class="text" style="padding-right: 50px; font-size: 14px;">Customer DC Number</td>
            <td align="left"  class="text" ><input type="text"  name="customer_dc_no" id="customer_dc_no" class="types_class1" style="font-size:12px ;height:25px; width:190px;" onKeyPress="enterevent(event,'receipt','customer_dc_no')"  value="<?php    	 echo $customer_dc_nos; ?>"></td>
            <tr>
            <td>&nbsp;</td>
            <td height="37" align="right" class="text" style="padding-right: 50px; font-size: 14px;">Invoice No</td>
           <td><input type="hidden"  name="invoice_no" id="invoice_no" class="text_box" style="font-size:12px" value="<?php if($in_edit_id!='') { echo $invoice_nos1; } else { echo $invoice_number1;  } ?>"><span style="color:#FF0000; font-size:14px; font-family:Verdana, sans-serif; font-weight:bold;"><?php if($in_edit_id!='') { echo $invoice_nos1; } else{ echo $invoice_number1; } ?></span>&nbsp;&nbsp;</td>
            <td align="right"  class="text" style="padding-right: 50px; font-size: 14px;">Receipt Through</td>

            <td align="left"  class="text" ><input type="text" onKeyPress="enterevent(event,'entrydates','receipt')"  name="receipt" id="receipt" class="types_class1" style="font-size:12px ;height:25px; width:190px;"  value="<?php echo $receipt11  ?>"></td>
            
            
            
            </tr>
             
          </tr>
          <tr>
            <td height="327" colspan="5" align="center" ><div id="inward_sub_list_div"><?php include('inward_sublist.php');?></div></td>
            </tr>
            <tr><td>&nbsp;</td>
  <td class="text"  align="center" style=" font-size: 14px;"> Delivery Through<span style="color:#FF0000"> *</span></td>
  <td  align="left" class="style7"><input type="text" class="types_class1" name="delivery_through" id="delivery_through" style="width:250px; height:20px;"   value="<?php if($in_edit_id!='') { echo $delivery_through11; } else { } ?>" onKeyUp="inward_main_clear_validation(this.value)" >&nbsp;<div id="delivery_through_inward_validation_div" style="color:#F00"></div></td>
 
  <td   align="center" class="text" style="font-size: 14px;">Vehicle No<span style="color:#FF0000"> *</span></td>
  <td class="style7"  align="left"><input type="text" class="types_class1" name="vehicle_no" id="vehicle_no" style="width:250px; height:20px;"   value="<?php if($in_edit_id!='') { echo $vehicle_no11; } else { } ?>" onKeyUp="inward_main_clear_validation(this.value)"  >&nbsp;<div id="vehicleno_inward_validation_div" style="color:#F00"></div></td>
  <td class="style7"  align="center">&nbsp;</td>
</tr>

          <tr>
            <td height="65" colspan="5" align="center" valign="bottom"><p>
              <input type="button" name="submit"  id="submit" style="background-color: #87BB07;    color: #fff;    border: 0px; font-family:verdana; font-size:14px; width:120px; height:27px; " value="<?php if($_GET['edit_id']!='') { echo "UPDATE";  } else { echo "SUBMIT"; } ?>" tabindex="7" class="button" onClick="inward_main_list(in_jobcard_no.value,inward_date.value,in_cust_name.value,style_no.value,created_by.value,style_name.value,customer_po.value,combo_type.value,job_types.value,fabric_type.value,overall_qty.value,total_piece.value,customer_dc_no.value,receipt.value,invoice_no.value,delivery_through.value,vehicle_no.value,'<?php echo $edit_id;?>',this.value)">
            </p></td>
          </tr>
          </table>
</form>
</div>
</div>
</div>
</div>