<style>
.style15 {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 14px;
font-weight: bold;
}
</style>
<script>
function edit_ink_details(edit_id,ink_entry_no)
{
window.location.href="main_fram.php?file=ink_entry_form&edit_id="+ edit_id + "&ink_entry_no=" + ink_entry_no;
}
function print_ink(url)
{	
onmouseover10= window.open(url,'onmouseover10','height=500,width=1100,scrollbars=no,resizable=no,left=50,top=50,toolbar=no,location=no,directories=no,status=no');	
}
</script>

<?php error_reporting(0);
/***************************** PREVIOUS NEXT CODING ****************************************/
include ("../../include/db.php");
ob_start();
session_start();
$user_id = $_SESSION['login_user_id'];


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;
}

$login_user_name=$_SESSION['login_user_name'];
$login_pass_word=$_SESSION['login_pass_word'];
$book_branch=$_SESSION['branch'];
$get_user_type=get_user_type1($login_user_name,$login_pass_word);

$show = 20;
$num_links = 19;
$from = $_GET['from'];
if (empty($from))
	 {
		$from = "0";
	 } 
else 
	{
	$html_query = $html_query. "&from=$from";
	}
	
$from_date=$_GET['from_date'];
$to_date=$_GET['to_date'];
$current_date=date('Y-m-d');

if($from_date!=""){ $from_date1= "DATE_FORMAT(ink_date,'%Y-%m-%d')>='$from_date'"; }else{$from_date1="DATE_FORMAT(ink_date,'%Y-%m-%d')='$cur_dates'"; }
if($to_date!=""){ $to_date1 = "DATE_FORMAT(ink_date,'%Y-%m-%d')<='$to_date'";}else{$to_date1="DATE_FORMAT(ink_date,'%Y-%m-%d')='$cur_dates'";}

$all_value10 = $from_date1."@".$to_date1;
$all_array10 = explode('@',$all_value10);
foreach($all_array10 as $value10)
{ 
if($value10!='')
{
$get_query102 .= $value10." AND ";
}
}	  

	if(($from_date=='')&&($to_date==''))
  {
   $sql="select * from  ink_main where  DATE_FORMAT(ink_date,'%Y-%m-%d')='$current_date'  order by ink_entry_no DESC";
  } 
  else
  {
   $sql="select * from  ink_main where $get_query102 ink_id!=''  order by ink_entry_no DESC";
  }

$html_query = "main_fram.php?file=ink_entry";
$result=mysql_query($sql);
$num_results=mysql_num_rows($result);
if ($num_results == 0) 
{
 $confirmation = "No Records!";
} 
elseif ($num_results == 1) 
{
$confirmation = "Found 1 Record.";
} 
else 
{
$confirmation = "Found $num_results Records.";
} 
?>
<style type="text/css">
<!--
.style1 {font-size: 16px}
-->
</style>
<table width="100%">
   <tr>
<td width="1%">&nbsp;</td>
<td width="7%" class="style15">&nbsp;</td> 
<td width="13%" align="center">&nbsp;</td>
<td width="1%">&nbsp;</td>
<td width="6%" class="style15">&nbsp;</td>
<td width="14%" align="center"  class="style15">&nbsp;</td>
<td width="2%">&nbsp;</td>
<td width="11%" class="style15">&nbsp;</td>
<td width="24%" align="left" >&nbsp;</td>
<td width="8%" align="center">&nbsp;</td>
<td width="2%"></td>
<td width="7%" align="center"><a href="javascript:print_ink('consumable/ink_entry/ink_main_print.php?from_date=<?php echo $_GET['from_date'];?>&to_date=<?php echo $_GET['to_date'];?>');" style="text-decoration:none;"><img src="img/PrinterBlack.png" width="35" height="35" title="Print" value="Print"/></a></td>
  </tr>
</table>
<div class="row-fluid">
<div class="span12">
<div class="table-responsive">
<div class="CSSTableGenerator">  
<table width="99%" border="0" align="center"  cellpadding="0" cellspacing="0" style="border:2px solid #eaeaea;border:1px solid #ddd"  >
      <tr>
      <th align="center" style="border:1px solid #ddd" >S.No</th>
      <th scope="col" align="left" style="border:1px solid #ddd" >&nbsp;Date</th>
      <th width="212" align="left" style="border:1px solid #ddd" scope="col" >&nbsp;&nbsp;Ink Entry No</th>
      <th scope="col" align="left" style="border:1px solid #ddd" >Total</th>
 
       <?php if(($user_id=='1')||($user_id=='3'))
	 { ?>
	<th width="77" align="center" scope="col" style="border:1px solid #ddd" >Edit</th>
      <th width="78" align="center" scope="col" style="border:1px solid #ddd" >Delete</th>
      <?Php } ?>
      </tr>
  <?php
include ("../../include/db.php");  
function get_tot_qty($job_card_no)
{$sql="select sum(tot_req_by) as tot from  ink_sub_list where job_card_no='$job_card_no' ";

    $rs=mysql_query($sql);
	$sno=0;
   		while($rsdata=mysql_fetch_array($rs))
  			{
   				
   				$tot=$rsdata['tot'];
			}
			return $tot;
}
$from_date=$_GET['from_date'];
$to_date=$_GET['to_date'];
$cur_dates=date('Y-m-d');


if($from_date!=""){ $from_date1= "DATE_FORMAT(ink_date,'%Y-%m-%d' )>='$from_date'"; }else{$from_date1="DATE_FORMAT(ink_date,'%Y-%m-%d' )='$cur_dates'"; }
if($to_date!=""){ $to_date1 = "DATE_FORMAT(ink_date,'%Y-%m-%d' )<='$to_date'";}else{$to_date1="DATE_FORMAT(ink_date,'%Y-%m-%d' )='$cur_dates'";}
$all_value10 = $customer_name1.";".$from_date1.";".$to_date1.";".$jobtype1;
$all_array10 = explode(';',$all_value10);
foreach($all_array10 as $value10)
{ 
if($value10!='')
{
$get_query102 .= $value10." AND ";
}
}	  
 
  
  if(($from_date=='')&&($to_date==''))
  {
   $sql="select * from  ink_main where  DATE_FORMAT(ink_date,'%Y-%m-%d')='$cur_dates' order by ink_entry_no DESC";
   //"select * from  ink_main where  DATE_FORMAT(ink_date,'%Y-%m-%d')='$cur_dates' order by ink_entry_no DESC LIMIT $from,20";
  } 
  else
  {
    $sql="select * from  ink_main where $get_query102 ink_id!='' order by ink_entry_no DESC";
    //"select * from  ink_main where $get_query102 ink_id!='' order by ink_entry_no DESC  LIMIT $from,20 ";
  }
 // echo $sql;
    $rs=mysql_query($sql);
	$sno=0;
   		while($rsdata=mysql_fetch_array($rs))
  			{
   				$sno=$sno+1;
				$from=$from+1;
				 $ink_id=$rsdata['ink_id'];
   			    $ink_entry_no=$rsdata['ink_entry_no'];
                $ink_date=$rsdata['ink_date'];
                $tot_prod=$rsdata['tot_prod'];
                
               
                $cr_date=date('Y-m-d');
				
  ?>
  <tr>
    <td width="69"  align="center" style="border:1px solid #ddd"><?php echo $from; ?></td>
    <td width="182" align="left" style="border:1px solid #ddd">&nbsp;&nbsp;<?php echo date("d-m-Y",strtotime($ink_date));?></td>
    <td align="left" style="border:1px solid #ddd">&nbsp;&nbsp;&nbsp;&nbsp;<?php echo $ink_entry_no;?></td>
    <td width="233" align="left" style="border:1px solid #ddd">&nbsp;&nbsp;<?php echo number_format($tot_prod,2);?></td>
     <?php if(($user_id=='1')||($user_id=='3'))
	 { ?>
	 <td align="center" style="cursor:pointer; border:1px solid #ddd"><img src="img/edit.png" width="17" height="20" title="EDIT" onclick="javascript:edit_ink_details('<?php echo $ink_id;?>','<?php echo $ink_entry_no;?>');"/></td>
    <td align="center" style="border:1px solid #ddd" ><img src="img/trash.png" style="cursor:pointer" onClick="delete_ink_main('<?php echo $ink_entry_no;?>')" width="20px" height="22px"></td><?php } ?> 
   <!--<td width="462"></td>-->
   </tr>
  <?php
$total_qty+=$tot_prod;
} ?>
  <tr>
       <th height="28" colspan="3" align="right" style="border:1px solid #ddd" ><strong>Total&nbsp;&nbsp;</strong></th>
          
          <th width="87" align="right" style="border:1px solid #ddd;color:red" ><strong><?php  echo number_format($total_qty,2); ?>&nbsp;&nbsp;</strong></th>
    </tr>
</table>
</div>
<table border="0" width="99%"  align="center" cellpadding="0" cellspacing="0" >

 <tr>
    <th height="19" align="left" style="font-size:12px; font-family:sans-serif; padding-top:10px;" scope="col"><?php echo $confirmation;?></th>
	<th scope="cols" width="8%" align="right"><?php  
			  if ($num_results > $show) 
			  { 			  $show;
			include("footer_links.php");
			  }
	?></th>
 </tr>
</table>
</div>
</div>