<style type="text/css">
.style20 {
	font-family: Verdana;
	font-size: 12px;
}
.style5 {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 14px;
}
.style10{ border-top:dashed 1px; border-top-color:#000000;}
.style4 {font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 13px;
}
.style23 {
	font-family: Verdana, Arial, Helvetica, sans-serif;
	font-weight: bold;
}
.text {font-family: Verdana; font-size:13px;}
.styleright
{
	border-right:1px solid #000000;
}
.left
{
	border-left:1px solid #000000;
}


.stylebottom
{	
	border-bottom:1px dashed #000000;
}	
</style>
<div class="row-fluid">
<div class="span12">
<div class="table-responsive">
<div class="CSSTableGenerator">
<?php 
  include ("../../include/db.php");
error_reporting(0);
ob_start();
session_start();
$session_branch=$_SESSION['branch'];
$session_user_type=$_SESSION['user_type'];
  $branch_name=$_GET['branch_name'];

function get_categ_branch_id($branch_name)
{
$sql_query11="select * from branch_creation where branch_id='$branch_name' and delete_status!='1'";
$rs11=mysql_query($sql_query11);
 while($rsdata11=mysql_fetch_object($rs11))
 {
 $id=$rsdata11->branch_name;
 } 
	return $id;
 }
 function get_total_quants12($job_card_no)
{
 $sql="select sum(qty) as qty from jobcard_sublist where jobcard_no='$job_card_no'";
$rs11=mysql_query($sql);
 while($rsdata=mysql_fetch_array($rs11))
 {
$qty1=$rsdata['qty'];
}
return $qty1;
}

 $bran_name=get_categ_branch_id($branch_name);
if($session_user_type!=1)
{
$query="select * from branch_creation  WHERE branch_id='$session_branch'";
}
$rs=mysql_query($query);						 
                                                $i=0;
                                                while($list=mysql_fetch_array($rs))
                                                {
                                                $i=$i+1;
												$branch_address=$list['branch_address'];
												$head_off=$list['head_off'];
												$branch_off=$list['branch_off'];
												$branch_ph=$list['branch_ph'];
												$delivery_ph=$list['delivery_ph'];
												$delivery_off=$list['delivery_off'];
											    }
											 ?>
<table width="980px" height="30" border="0" align="center"  cellpadding="0" cellspacing="0">
<tr style="height:60">
<td width="137" height="106" align="left" style="font-size:12px; border-bottom:1px solid #999;"><img src="../../img/logo_image.png" width="157" height="146"/></td>
<td width="711" colspan="5" align="center" valign="top" style="border-bottom:1px solid #999;"><strong style="font-size: 30px; color: #06F; padding-top: 5px; width: 80px; font-family: Verdana, sans-serif">SRI AMMAN DIGITAL PRINTS</strong><br />
        <span width="80%" class="title1" style="font-size:14px;font-family:Verdana, sans-serif; font-weight:bold"><b></b> DOOR No: 1/2,1/3  KOMBAI THOTTAM MAIN ROAD,</span><br />
       <span width="80%" class="title0" style="font-size:14px;font-family:Verdana, sans-serif; font-weight:bold"><b></b>SELLANDIAMMAN THURAI ROAD,</span><br />
       <span width="80%" class="title0" style="font-size:14px;font-family:Verdana, sans-serif; font-weight:bold"><b></b>TIRUPPUR-641604 TAMILNADU STATE INDIA,</span><br/>
       <span width="80%" class="title00" style="font-size:14px;font-family:Verdana, sans-serif; font-weight:bold"><b></b>Contact Office: 0421-4355333,+91 83442-33555,+91 83442-33888,</span><br/>
       <span width="80%" class="title0" style="font-size:14px;font-family:Verdana, sans-serif; font-weight:bold"><b></b>Email Id : sriammandigitalprints@gmail.com/yahoo.com.</span><br/>
       <br/>
    
   <span width="80%" class="title1" style="font-size:18px;font-family:Verdana, sans-serif; font-weight:bold"><b></b>Printer Jobcard wise Report</span></p></td>
  </tr>
  </tr>

<tr>
  <td align="center" colspan="2" class="style5 style23" ></td>
</tr>
</table>
<table width="980px" align="center" height="40" border="0"  cellpadding="0" cellspacing="0">
<tr>

<td colspan="4" align="right" class="style4" scope="col"><strong>Jobcard No :</strong> </td>
 <td width="79%" colspan="4" align="left" class="style4" scope="col"> <?php if($_GET['job_card_no']!=''){  echo ucfirst($_GET['job_card_no']);} else { echo ""; }?>&nbsp;</td>
</tr></table>
<table  width="980" align="center"  cellpadding="0" cellspacing="0" >
      <tr>
      <td width="35" height="26" align="center" class="stylebottom style10  style20 "  ><strong>S.No</strong></td>
      <td width="85" align="left"   scope="col" class="stylebottom style10  style20"><strong>&nbsp;Date</strong><strong>&nbsp;</strong></td>
      <td width="97" align="left"   scope="col" class="stylebottom style10  style20"><strong>&nbsp;Jobcard No</strong></td>
      <td width="96" scope="col" align="left" class="stylebottom style10  style20" ><strong>&nbsp;Date</strong>&nbsp;</td>
      <td width="96" scope="col" align="left" class="stylebottom style10  style20" ><strong>&nbsp;Shift</strong></td>
      <td width="97"   align="left" scope="col" class="stylebottom style10  style20" ><strong>&nbsp;Machine No</strong></td>
      <td width="86"   align="left"  class="stylebottom style10  style20"  scope="col"><strong>Operator</strong></td>
      <td width="86"  align="left"   class="stylebottom style10  style20"  scope="col">&nbsp;&nbsp;<strong>Particular</strong>&nbsp;</td>
      <td width="111"   align="right"  class="stylebottom style10  style20" scope="col"><strong>Order Qty</strong>&nbsp;</td>
      <td width="129"   align="right"  class="stylebottom style10  style20" scope="col"><strong>Product Qty</strong>&nbsp;</td>
      <td width="126"   align="right"  class="stylebottom style10  style20" scope="col"><strong>Balance Qty&nbsp;</strong>&nbsp;</td>
  </tr>
  <?php
include("../../include/db.php"); 
date_default_timezone_set('Asia/Kolkata');
function get_operator_names($ope_name)
{
	$entity11="select * from operator_creation where id='$ope_name'";
$rs11=mysql_query($entity11);
 while($trips=mysql_fetch_array($rs11))
 {
$operator_namess=$trips['operator_name'];

}
return $operator_namess;
}
function get_machine_name_job($machine_no)
{
	
  $sql_query11="select * from machine_creation where id='$machine_no' and  mach_type='printer'";
$rs11=mysql_query($sql_query11);
 while($rsdata11=mysql_fetch_object($rs11))
 {
 $machine_no=$rsdata11->machine_no;
 } 
return $machine_no;
}

function get_shift_name_from_job($shift_time)
{
$sql_query11="select * from shift_creation where id='$shift_time' ";
$rs11=mysql_query($sql_query11);
 while($rsdata11=mysql_fetch_object($rs11))
 {
 $from_time=$rsdata11->from_time;
  $to_time=$rsdata11->to_time;
 $shift_name=$rsdata11->shift_name;

 } 
 $tot_shift=array($from_time,$to_time,$shift_name);
return $tot_shift;
}


function get_order_qty($job_card_no,$prod_size)
{
	$sql_query="select * from printer_production_sublist where job_card_no='$job_card_no' and prod_size='$prod_size' ";
    $rs=mysql_query($sql_query);
    $rscount=mysql_num_rows($rs);
	return $rscount;
 }
 
 
 function get_max_order_qty($job_card_no,$prod_size)
{
$sql_query="select max(total_qty) as total_qty from printer_production_sublist where job_card_no='$job_card_no' and prod_size='$prod_size' ";
    $rs11=mysql_query($sql_query);
 while($rsdata=mysql_fetch_array($rs11))
 {
$total_qty=$rsdata['total_qty'];
}
return $total_qty;
}

 function get_order_qty1($job_card_no,$prod_size,$pr_id)
{
 $sql_query="select total_qty from printer_production_sublist where job_card_no='$job_card_no' and prod_size='$prod_size' and pr_id='$pr_id' ";
    $rs11=mysql_query($sql_query);
 while($rsdata=mysql_fetch_array($rs11))
 {
$total_qty=$rsdata['total_qty'];
}
return $total_qty;
}

$job_card_no=$_GET['job_card_no'];
if($job_card_no!='')
{
 $sql="select * from printer_production_main where job_card_no='$job_card_no'";
}
    $rs=mysql_query($sql);
	$s_no=0;
   		while($rsdata=mysql_fetch_array($rs))
  			{
   				 $s_no=$s_no+1;
				 $from=$from+1;
                 $id=$rsdata['p_id'];
                 $job_card_no=$rsdata['job_card_no'];
				 $operator_name2=get_operator_names($ope_name);
				 $print_date=$rsdata['print_date'];
				 $cust_name=$rsdata['cust_name'];
				 $job_type=$rsdata['job_type'];
				 $billed_status=$rsdata['billed_status'];
				 $fabric_type=$rsdata['fabric_type'];
				 $printed_qty=$rsdata['printed_qty'];
	             $total_quant=get_total_quants12($job_card_no);

				 
 ?>
    <tr>
    <td width="35"  align="center" class="   style20 ">&nbsp;<?php echo $from; ?></td>
    <td width="85" align="left" class="   style20">&nbsp;<?php echo date("d-m-Y",strtotime($print_date));?></td>
    <td width="97" align="left" class="   style20">&nbsp;<?php echo $job_card_no; ?></td>

      <td colspan="8"  align="right" class="   style20"><table width="100%" cellpadding="0" cellspacing="0" style="border:0px; color:#000">
   <tbody>   <?php
   if($job_card_no!='')
{
	$entity11="select * from printer_production_sublist where job_card_no='$job_card_no' order by prod_size ASC";
}
	$rs11=mysql_query($entity11);
 while($trips=mysql_fetch_array($rs11))
 {
$pr_id=$trips['pr_id'];	 
$machine_no=$trips['machine_no'];
$operator_name=$trips['operator_name'];
 $operator_name2=get_operator_names($operator_name);
$shift_time=$trips['shift_time'];
$prod_size=$trips['prod_size'];
$prod_qty=$trips['prod_qty'];		
$production_time=$trips['production_time'];	
$total_qty=$trips['total_qty'];
$balance_qty=$trips['balance_qty'];
$job_card_no=$trips['job_card_no'];

$mach_no=get_machine_name_job($machine_no);
list($frm_ti,$to_ti,$type)=get_shift_name_from_job($shift_time);

	$count_order_qty = get_order_qty($job_card_no,$prod_size); 
	 $max_order_qty = get_max_order_qty($job_card_no,$prod_size);
	 $qty=  get_order_qty1($job_card_no,$prod_size,$pr_id);
	if($max_order_qty==$qty)
	{
		$qty=$max_order_qty;
	}
	else
	{
				$qty='';

		}
	?>
    <tr>
      <td width="13%" align="left" class="style20  "><?php echo date('d-m-y h:m a',strtotime($production_time)); ?>&nbsp;</td>
    <td width="13%" align="left" class="style20  ">&nbsp;<?php echo $type; ?></td>
    <td width="12%" align="left" class="style20  ">&nbsp;<?php echo $mach_no; ?></td>
    <td width="13%" align="left" class="style20 ">&nbsp;<?php echo $operator_name2; ?></td>
        <td width="12%" align="left" class="style20 ">&nbsp;<?php echo $prod_size; ?></td>
        <td width="15%" align="right" class="style20 ">&nbsp;<?php echo $qty; ?></td>

        <td width="16%" align="right" class="style20 "><?php echo $prod_qty; ?>&nbsp;</td>
        <td width="19%" align="right" class="style20 "><?php echo number_format($balance_qty,2); ?>&nbsp;</td>
    </tr>
    <?php 
	$total1+=$qty; 
	$total2+=$prod_qty; 
	$total3+=$balance_qty;
		 $qty1+= $qty;
	 }  ?>
    </tbody></table></td>
    </tr>
  <?php } ?>
  <tr>
   <td colspan="8" align="right" class="style20 style10"><strong>Total</strong></td>
   <td align="right" class="style20 style10"><strong><?php echo $qty1 ?></strong></td>
      <td align="right" class="style20 style10"><strong><?php echo number_format($total2,2); ?>&nbsp;</strong></td>

   <td align="right" class="style20 style10"><strong><?php echo number_format($total1-$total2,2); ?>&nbsp;</strong></td>
    </tr>
  </thead>
  <tr>
       <td height="30" colspan="11" align="right" class="stylebottom style10 style20  "><strong><br>Printed Date : <?php echo $curdate=date('d-m-Y');?>&nbsp;&nbsp;&nbsp;&nbsp;<br>Printed Time : <?php echo $current_time=date('h:i:s A');?>&nbsp;&nbsp;<br>IP Address   : <?php echo $ip_address = $_SERVER['REMOTE_ADDR'];?>&nbsp;</strong></p></td></tr>
</table>
