<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/delivery_challan_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 return_close()
{
window.location.href="main_fram.php?file=return_form_list";
window.location.reaload(true);
}

/*************************** Get job card number ************************************************/
var sm = jQuery.noConflict();
sm().ready(function() 
{ 
	sm("#job_no").autocomplete("include/autocomplete/return_jobcard_auto.php", {
	width: 250,
	matchContains: true,
	selectFirst: true
	});	
});
</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");	
$from_date=$_POST['from_date'];
$to_date=$_POST['to_date'];
/******************** Auto Generated ID*********************************************/
	$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;

if(!isset($_GET['return_no']))
{
	$rs1=mysql_query("select return_no from  return_form_main where cr_date>='$start_year' and cr_date<='$end_year' order by id desc");
	if($res1=mysql_fetch_assoc($rs1))
	{
		$pur_array=explode('-',$res1['return_no']);
	    $year1=$pur_array[1];
        $year2=substr($year1, 0, 2);
	    $year='20'.$year2;
		$return_no=$pur_array[2];
	}
	if($return_no=='')
		$return_nos='RT-'.$datee.'-0001';
	else
	{
		$return_no+=1;
		$return_nos='RT-'.$datee.'-'.str_pad($return_no, 4, '0', STR_PAD_LEFT);
	}
}
$edit_id=$_GET['edit_id'];
ob_start();
session_start();

if($_GET['edit_id']!='')
{
$table_display_styles1='style="display:inline;"';
} 
else
{
$table_display_stylesss='style="display:none;"';
}
   
  $edit_id1=$_GET['edit_id'];
  $sql="select * from return_form_main where 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;
	   $id=$rsdata['id'];
	   $return_no=$rsdata['return_no'];
	   $date_time=$rsdata['date_time'];
	   $job_no=$rsdata['job_no'];
	   $created_by=$rsdata['created_by'];
	   $customer_name=$rsdata['customer_name'];
	   $style_no=$rsdata['style_no'];
	   $style_name=$rsdata['style_name'];
	   $combo=$rsdata['combo'];
       $customer_po_no=$rsdata['customer_po_no'];
	   $job_type=$rsdata['job_type'];
	   $fabric_type=$rsdata['fabric_type'];
	   $remarks=$rsdata['remarks'];
	   $total_qty=$rsdata['total_qty'];
	   $deliv_status=$rsdata['deliv_status'];
  }
?>

<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;color:#080;letter-spacing: 1px;padding:10px; background-color:#f7f7f7;}
.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;}
.style11{font-family:Verdana, Arial, Helvetica, sans-serif; font-size:14px;}

</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"><div class="style9">Return Form</div></tr>
<td width="12%" align="left"><img src="img/wrong.png" name="add_button" id="add_button" title="Cancel Booking Order"  onclick="javascript:return_close()" align="top" width="30" height="30" border="0" tabindex="4" style="cursor:pointer; margin-left:96%; margin-top:-34px;" class="button green-button" >
</td>
<tr></tr></table>
<table width="100%"  cellpadding="0" cellspacing="0" border="0">
<tr height="10px;">
  <td ></td>
  <td ></td>
  <td width="299" ></td>
  <td width="1" ></td>
  <td ></td>
  <td colspan="2"></td>
  <td ></td>
  <td ></td>
</tr>
<tr>
  <td width="32" height="42" align="left" class="txt"></td>
  <td width="140" height="42" align="left"  class="style11">Return No </td>
  <td align="left"  class="style7"><input type="hidden"  name="return_no" id="return_no" class="text_box" style="font-size:14px" value="<?php if($edit_id!='') { echo $return_no; } else{ echo $return_nos;  } ?>"/>
    <strong>
   <span style="color:#390;"> <?php if($edit_id!='') { echo $return_no; } else{ echo $return_nos; } ?></span>
    </strong></td>
  <td colspan="2" align="left" valign="top" class="style11">&nbsp;</td>
  <td colspan="2" align="left" valign="top" class="style7">&nbsp;</td>
  <td width="103" align="left"  class="style11">Date &amp; Time</td>
  <td width="263" align="center" >
  <input type="datetime-local"  name="date_time" id="date_time" class="types_class1"  <?php if($_SESSION['user_type']!=1) { ?> readonly <?php } ?>   tabindex="1"  onKeyUp="enterevent(event,'job_no','date_time')"   style="height:25px; width:215px;" value="<?php if($edit_id!='') { echo $date_time; }  else{ echo  date('Y-m-d').'T'.date('H:i'); }?>">
  </td>
  <td width="24" align="left" valign="top">&nbsp;</td>
</tr>
<tr>
  <td height="34" align="left" class="txt"></td>
  <td height="34" align="left"  class="style11">Jobcard No<span style="color:#FF0000"> *</span></td>
  <td align="left"  class="style11"><input type="text" class="types_class1" name="job_no" id="job_no"  autofocus  style="width:250px; height:20px;" tabindex="1" onFocus="get_jobcard_details2(this.value)" value="<?php if($edit_id1!='') { echo $job_no; } else { } ?>" onKeyUp="get_jobcard_details2(job_no.value),challan_clear_validation(this.value),enterevent(event,'return_dates','job_no')"><div id="delivery_challan_validation_div" style="color:#F00"></div></td>
  <td colspan="2" align="center" valign="top" class="style7">&nbsp;</td>
  <td colspan="2" align="left" valign="top" class="style7">&nbsp;</td>
  <td align="left"  class="style11">Created By</td>
  <td align="center" ><div id="return_created_by_div"><input type="text" readonly class="types_class1" name="created_by" id="created_by" style="width:215px; height:20px;"   value="<?php if($edit_id1!='') { echo $created_by; } else { } ?>" ></div></td>
  <td align="left" valign="top">&nbsp;</td>
</tr>
<tr>
  <td height="34" align="left" class="txt"></td>
  <td height="34" align="left"  class="style11">Customer Name</td>
  <td align="left"  class="style7"><div id="return_cust_name"><input type="text" class="types_class1" name="customer_name" id="customer_name" style="width:250px; height:20px;"   value="<?php if($edit_id1!='') { echo $customer_name; } else { } ?>" readonly ></div></td>
  <td colspan="2" align="left"  class="style11">&nbsp;</td>
  <td colspan="2" align="left" valign="top" class="style7">&nbsp;</td>
  <td align="right"  class="style11">&nbsp;</td>
  <td align="right" valign="top">&nbsp;</td>
  <td align="left" valign="top">&nbsp;</td>
</tr>
<tr>
  <td height="34" align="left" class="txt"></td>
  <td height="34" align="left"  class="style11">Style No</td>
  <td align="left"  class="style7"><div id="return_style_no_div"><input type="text" class="types_class1" name="style_no" id="style_no" style="width:250px; height:20px;"   value="<?php if($edit_id1!='') { echo $style_no; } else { } ?>" readonly></div></td>
  <td colspan="2" align="left"  class="style11">Style Name</td>
  <td colspan="2" align="left"  class="style7"><div id="return_style_name_div"><input type="text" class="types_class1" name="style_name" id="style_name" style="width:200px; height:20px;"  value="<?php if($edit_id1!='') { echo $style_name; } else { } ?>" readonly></div></td>
  <td align="left"  class="style11">Combo</td>
  <td align="center" ><div id="return_combo_type_div"><input type="text" class="types_class1" name="combo" id="combo" style="width:215px; height:20px;"  value="<?php if($edit_id1!='') { echo $combo; } else { } ?>"readonly ></div></td>
  <td align="left" valign="top">&nbsp;</td>
</tr>
<tr>
  <td height="45" align="left" class="txt"></td>
  <td height="45" align="left"  class="style11">Customer PO No</td>
  <td align="left"  ><div id="return_customer_po_div">
    <input type="text" class="types_class1" name="cust_po_no" id="cust_po_no" style="width:250px; height:20px;"   value="<?php if($edit_id1!='') { echo $customer_po_no; } else { } ?>" readonly></div>
 </td>
  <td colspan="2" align="left" class="style11">Job Type</td>
  <td colspan="2" align="left"  ><div id="return_job_types_div">
  <input type="text" class="types_class1" name="job_type" id="job_type" readonly style="width:200px; height:20px;"  value="<?php if($edit_id1!='') { echo $job_type; } else { } ?>" >
</div></td>
  <td align="left" class="style11">Fabric Type</td>
  <td align="center" ><div id="return_fabric_type_div">
  <input type="text" class="types_class1" name="fabric_type" id="fabric_type" style="width:200px; height:20px;"  value="<?php if($edit_id1!='') { echo $fabric_type; } else { } ?>" readonly>
  </div></td>
  <td align="left" >&nbsp;</td>
</tr>
<tr>
  <td colspan="10" align="left" class="txt"></td>
</tr>
<tr>
  <td colspan="10" class="style7" align="center"><div id="return_sublist_div"><?php include("return_sublist.php"); ?></div></td>
</tr>
<tr>
  <td class="style7"  align="center">&nbsp;</td>
  <td class="style11"  align="center">Remarks :</td>
  <td colspan="2"  align="left" class="style7"><textarea name="remarks" id="remarks" cols="50" rows="6" class="types_class" tabindex="7"  style="width:300px; height:75px;" onKeyUp="enterevent(event,'action','remarks')"><?php if($_GET['edit_id']!='') { echo $remarks; } ?>
          </textarea>
   </td>
  <td width="105"  align="center" class="style7">&nbsp;</td>
  <td width="134"  align="left" class="style11">&nbsp;</td>
  <td colspan="2"  align="center" class="style7"></td>
  <td  align="left" class="style7"></td>
  <td  align="left" class="style7">&nbsp;</td>
</tr>
<tr>
  <td colspan="10" class="style7"  align="center"><input type="button" class="add_button" name="action"  id="action" tabindex="8" value="<?php if($_GET['edit_id']!='') { echo "Edit";  } else { echo "Save"; } ?>" style="height:30px; width:100px; font-size:16px; background-color: #87BB07;color: #fff;border: 0px" onClick="return_add(return_no.value,date_time.value,job_no.value,created_by.value,customer_name.value,style_no.value,style_name.value,combo.value,cust_po_no.value,job_type.value,fabric_type.value,remarks.value,overal_qty11.value,'<?php echo $edit_id;?>',this.value)"  /></td>
</tr>
</table>
<!--Design End--></td>
  </tr>
</table>
</form>
</div>
</div>
</div>
</div>