<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/ink_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_media(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_media").autocomplete("include/autocomplete/jobcard_no_media_autocomplete.php", {
	width: 250,
	matchContains: true,
	selectFirst: true
	});	
});

 function ink_ent_close()
{
window.location.href="main_fram.php?file=ink_entry_list";
window.location.reaload(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);
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_type1($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_names3($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_type1($login_user_name,$login_pass_word);
$get_branch_names=get_branch_names3($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 ink_main where ink_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;
	  $ink_entry_no=$rsdata['ink_entry_no'];
      $ink_date=$rsdata['ink_date'];
      $shift_time=$rsdata['shift_time'];
      $machine_no=$rsdata['machine_no'];
      $operator_name=$rsdata['operator_name'];
      $prod_size=$rsdata['prod_size'];
      $total_qty=$rsdata['total_qty'];
      $prod_qty=$rsdata['prod_qty'];
      $cr_date=date('Y-m-d');
  }
  
  	$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 ink_entry_no from ink_main where cr_date>='$start_year' and cr_date<='$end_year' order by ink_id desc");
	if($res1=mysql_fetch_assoc($rs1))
	{
		$media_array=explode('-',$res1['ink_entry_no']);
	    $year1=$media_array[1];
        $year2=substr($year1, 0, 2);
	    $year='20'.$year2;
		$invoice_no=$media_array[2];
	}
	if($invoice_no=='')
		$invoice_number1='INK-'.$datee.'-0001';
	
	else
	{
		$invoice_no+=1;
		$invoice_number1='INK-'.$datee.'-'.str_pad($invoice_no, 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="ink_main_list_div">
<div class="container">
<div class="row-fluid">
<div class="span12">
<div class="table-responsive">
<form name="ink_form"  id="ink_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">Ink Entry Form</div></tr>
<td width="12%" align="left"><img src="img/wrong.png" name="add_button" id="add_button" title="Media Close"  onclick="javascript:ink_ent_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="58" height="35"></td>
            <td width="191" align="right" class="text" style="padding-right: 50px; font-size: 14px; color:#F03;">&nbsp;<span style="color: #C30"><strong>Invoice No</strong></span><strong> *</strong></td>
           
            <td><span class="text" style="font-size:14px;" >
               <input type="hidden" class="types_class1" name="ink_no" id="ink_no" autofocus  value="<?php if($in_edit_id!='') { echo $ink_entry_no; } else{ echo $invoice_number1; } ?>"><strong> <?php if($in_edit_id!='') { echo $ink_entry_no; } else{ echo $invoice_number1; } ?></strong></span>&nbsp;&nbsp;
            </td>
            
            <td width="270" align="right" class="text" style="padding-right: 50px; font-size: 14px;">Date &amp; Time</td>
            <td width="353" align="left" class="txt">
              <input type="datetime-local"  name="ink_date" id="ink_date"  <?php if($_SESSION['user_type']!=1) { ?> readonly <?php } ?>  class="types_class1" onKeyUp="enterevent(event,'customer_dc_no','ink_date')"  tabindex="1" style="font-size:12px; height:25px; width:190px; " value="<?php if($in_edit_id!='') { echo $ink_date; }  else{ echo  date('Y-m-d').'T'.date('H:i'); }?>"></td>
          </tr>
                   <tr>
            <td height="327" colspan="5" align="center" ><div id="ink_sub_list_div"><?php include('ink_sublist.php');?></div></td>
            </tr>
          <tr>
            <td height="65" colspan="5" align="center" valign="bottom"><p>
              <input type="button" name="submit_edit"  id="submit_edit" 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="ink_main_list(ink_no.value,ink_date.value,tot_prod.value,tot_bal.vale,'<?php echo $edit_id;?>',this.value)">
            </p></td>
          </tr>
          </table>
          
</form>
</div>
</div>
</div>
</div>
</div>