<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/consumable_return_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=consumable_return_form_list";
window.location.reaload(true);
}

/*************************** Get job card number ************************************************/
var media_ink = jQuery.noConflict();
media_ink().ready(function() 
{ 
	media_ink("#job_card_nos").autocomplete("include/autocomplete/media_ink_no.php", {
	width: 250,
	matchContains: true,
	selectFirst: true
	});	
});



function get_tot_mtr_consumable(qty,mtr_roll)
{
	var total_meters = qty*mtr_roll;
	document.getElementById("tot_mtr").value = total_meters;
}
</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*********************************************/

	$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;
$up_id=$_POST['update_id'];
$main_idss=$_GET['main_id'];

if(!isset($_GET['return_no']))
{
	
	$get_resss=mysql_query("select * from  return_media_purchase where create_date>='$start_year' and create_date<='$end_year' order by id desc");
	if($res11=mysql_fetch_assoc($get_resss))
	{
		 $pur_array=explode('-',$res11['return_no']);
	    $year1=$pur_array[1];
        $year2=substr($year1, 0, 2);
	    $year='20'.$year2;
		 $return_no=$pur_array[2];
	}
	if($return_no=='')
		$return_nos='CRT-'.$datee.'-0001';

	else
	{
		$return_no+=1;
		$return_nos='CRT-'.$datee.'-'.str_pad($return_no, 4, '0', STR_PAD_LEFT);
	}
}
$edit_id=$_GET['main_id'];
ob_start();
session_start();

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

$_GET['purchase_no'];
   
  $edit_id1=$_GET['edit_id'];
  $sql="select * from return_media_purchase where id='$_GET[main_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'];
	   $media_ink_time=$rsdata['media_ink_time'];
		   


  }
?>

<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">Consumable Return Form</div></tr>
<td width="12%" align="left"><img src="img/wrong.png" name="add_button" id="add_button" title="Cancel Return Form"  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 $_GET['return_no']; } else{ echo $return_nos;  } ?>"/>
    <strong>
   <span style="color:#390;"> <?php if($_GET['main_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"    style="height:25px; width:215px;" value="<?php if($_GET['main_id']!='') { echo $media_ink_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">Purchase No<span style="color:#FF0000"> *</span></td>
  <td align="left"  class="style11"><input type="text" class="types_class1" name="job_card_nos" id="job_card_nos"  autofocus  style="width:250px; height:20px;" tabindex="1"  value="<?php if($_GET['main_id']!='') { echo $_GET['purchase_no']; } else { } ?>" onKeyUp="card_details(job_card_nos.value,return_no.value),cons_ret_main_clear_valid(this.value)" onFocus="card_details(job_card_nos.value,return_no.value)"><div id="purchase_no_con_ret_valid_div" style="color:#F00;"></div></td>
  
</tr>

<tr>
  <td colspan="10" align="left" class="txt"></td>
</tr>
<tr>
  <td colspan="10" class="style7" align="center"><div id="consumable_return_sublist_div"><?php include("consumable_return_sublist.php"); ?></div>
    <div id="return_ink" style="display:none"><?php include("ink_sublist.php"); ?></div>

  </td>
</tr>
<tr>
  <td class="style7"  align="center">&nbsp;</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['main_id']!='') { echo "UPDATE";  } else { echo "SAVE"; } ?>" style="height:30px; width:100px; font-size:16px; background-color: #87BB07;color: #fff;border: 0px" onClick="return_add_main(return_no.value,date_time.value,job_card_nos.value,total.value,'<?php echo $edit_id;?>',ink_total_res.value,this.value)"  /></td>
</tr>
</table>
<!--Design End--></td>
  </tr>
</table>
</form>
</div>
</div>
</div>
</div>