<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>
<?php
error_reporting(0);
include("../../include/db.php");
ob_start();
session_start();
$username=$_SESSION['login_user_name'];

 function get_user11($usertype_id)
{
	$sql_user="select * from  user_type where user_type_id='$usertype_id'";
	$rs_user=mysql_query($sql_user);
	while($rsdata_user=mysql_fetch_object($rs_user))
	{ 
	$user_type=$rsdata_user->user_type;
	}
	return $user_type;
}
/************************************USER TYPE ID*********************************/
function get_usertype11($username)
{
	$sql_user="select * from  user_creation where user_name='$username'";
	$rs_user=mysql_query($sql_user);
	while($rsdata_user=mysql_fetch_object($rs_user))
	{ 
	$user_type=$rsdata_user->user_type;
	}
	return $user_type;
}

 $usertype_id=get_usertype11($username);
 $usertype=get_user11($usertype_id);
function get_permissionss($pur_party_name,$usertype)
{
    $sql_user="select * from  user_permissions where box_name='$pur_party_name' and user_type_id='$usertype'";
	$rs_user=mysql_query($sql_user);
	while($rsdata_user=mysql_fetch_object($rs_user))
	{ 
    $permission=$rsdata_user->permission;
	}
	return $permission;
} 
?>
<style type="text/css">
.txt{ font-family: Verdana, Arial, Helvetica, sans-serif; font-size:13px;}
.headings{ font-family:verdana; font-size:10px;}
.form-style-6 ul{
    font: 95% Arial, Helvetica, sans-serif;
    max-width: 200px;
    margin-left: 10px;
    padding: 36px;
}
.form-style-6 li h1{
    background: #777777;
    font-size: 140%;
    font-weight: 300;
    text-align: center;
    color: #fff;
	padding:20px;
}
.form-style-7{
    font: 95% Arial, Helvetica, sans-serif;
    max-width: 200px;
    padding: 36px;
}
.form-style-7 h2{
    background: #777777;
    font-size: 140%;
    font-weight: 300;
    text-align: center;
    color: #fff;
	padding:20px;
}
.pad{margin-right:2px}

</style>
 <table width="100%" height="100%" >
 <tr>
     <td width="1075" align="left" valign="top">
     
    <?php $rights=get_permissionss('Printing',$usertype); if($rights=='1'){?> 
     <div style="border-bottom:1px solid #CCC; font-family:Verdana, sans-serif; font-size:14px; font-weight:bold; color:#87BB07;">Printing Production Pending</div>
<div style="height:150px; width:100%;padding-left:0px;overflow-x:hidden;overflow-y:scroll;white-space:nowrap;"><br/>
<table width="100%" border="0" align="center"  cellpadding="0" cellspacing="0" >
       <tr>
         <td width="31" height="23"  align="center" style="font-size: 12px;  font-family: Verdana, Arial, Helvetica, sans-serif;font-weight:bold">&nbsp;Sno</td>
         <td width="97" align="left" style="font-size: 12px;  font-family: Verdana, Arial, Helvetica, sans-serif;font-weight:bold">&nbsp;Jobcard No</td>
                  <td width="104" align="left" style="font-size: 12px;  font-family: Verdana, Arial, Helvetica, sans-serif;font-weight:bold">&nbsp;Cust Name</td>

         <td width="92" align="left" style="font-size: 12px;font-family: Verdana, Arial, Helvetica, sans-serif;font-weight:bold">&nbsp;Job Type</td>
         <td width="88" align="left" style="font-size: 12px;  font-family: Verdana, Arial, Helvetica, sans-serif;font-weight:bold">Particulars</td>
         <td width="68" align="left" style="font-size: 12px;  font-family: Verdana, Arial, Helvetica, sans-serif;font-weight:bold">T.Qty</td>
         <td width="58" align="right" style="font-size: 12px;  font-family: Verdana, Arial, Helvetica, sans-serif;font-weight:bold">P.Qty</td>
                  <td width="70" align="right" style="font-size: 12px;  font-family: Verdana, Arial, Helvetica, sans-serif;font-weight:bold">Balance</td>

         <td width="127" align="center" style="font-size: 12px;  font-family: Verdana, Arial, Helvetica, sans-serif;font-weight:bold">Pending/Running</td>

       </tr>
       <?php
	function get_customer_details($job_card_no)
	{
	$entry=mysql_query("select * from printer_production_main where job_card_no='$job_card_no'");
	while($trip=mysql_fetch_array($entry))
		{
		 $cust_name=$trip['cust_name'];
		  $job_type=$trip['job_type'];
		}
		return array($cust_name,$job_type);
	}
if(($_GET['from_date']!='')&&($_GET['to_date']!=''))
{
 $from_date=date('Y-m-d',strtotime($_GET['from_date']));
 $to_date=date('Y-m-d',strtotime($_GET['to_date']));
}
$current_date=date('Y-m-d');
if($from_date!=""){ $from_date1= "DATE_FORMAT(production_time,'%Y-%m-%d')>='$from_date'"; }else{$from_date1="DATE_FORMAT(production_time,'%Y-%m-%d')='$current_date'"; }
if($to_date!=""){ $to_date1 = "DATE_FORMAT(production_time,'%Y-%m-%d')<='$to_date'";}else{$to_date1="DATE_FORMAT(production_time,'%Y-%m-%d')='$current_date'";}
{
$all_value102 = $from_date1.",".$to_date1;
}
$all_array102 = explode(',',$all_value102);
foreach($all_array102 as $value102)
{ 
if($value102!='')
{
  $get_query103 .= $value102." AND ";
}
}	  
if($from_date!='')
{
  $sql="select * from  printer_production_sublist where $get_query103 pr_id!=''  and deliv_status='0' ";
}
else
{  
  $sql="select * from  printer_production_sublist  where DATE_FORMAT(production_time,'%Y-%m-%d')='$current_date'  and deliv_status='0' ";
}
    $rs=mysql_query($sql);
	$s_no=0;
   		while($rsdata=mysql_fetch_array($rs))
  			{
   				 $s_no=$s_no+1;
				 $from=$from+1;
                 $id=$rsdata['pr_id'];
                 $job_card_no=$rsdata['job_card_no'];
				 $print_date=$rsdata['production_time'];
				 $prod_size=$rsdata['prod_size'];
				list($customer_name,$job_type1)=get_customer_details($job_card_no);
				 $prod_qty=$rsdata['prod_qty'];
				 $total_qty=$rsdata['total_qty'];
				 $balance_qty=$rsdata['balance_qty'];
				 $printed_qty=$rsdata['printed_qty'];

?>
       <tr height="27">
       <td align="center" style="font-size: 12px;font-family: Verdana, Arial, Helvetica, sans-serif;color:#666;">&nbsp;<?php echo $s_no;?></td>
       <td align="left" style="font-size: 12px;font-family: Verdana, Arial, Helvetica, sans-serif;color:#666;">&nbsp;<?php echo $job_card_no;?></td>       <td align="left" style="font-size: 12px;font-family: Verdana, Arial, Helvetica, sans-serif;color:#666;">&nbsp;<?php echo $customer_name;?></td>

       <td align="left" style="font-size: 12px;font-family: Verdana, Arial, Helvetica, sans-serif;color:#666;">&nbsp;<?php echo $job_type1;?></td>
       <td align="left" style="font-size: 12px;font-family: Verdana, Arial, Helvetica, sans-serif;color:#666;">&nbsp;<?php echo $prod_size;?></td>
       <td align="left" style="font-size: 12px;font-family: Verdana, Arial, Helvetica, sans-serif;color:#666;">&nbsp;<?php echo $total_qty;?></td>
       <td align="right" style="font-size: 12px;font-family: Verdana, Arial, Helvetica, sans-serif;color:#666;">&nbsp;<?php echo $prod_qty;?></td>
        <td align="right" style="font-size: 12px;font-family: Verdana, Arial, Helvetica, sans-serif;color:#666;">&nbsp;<?php echo $balance_qty;?></td>

      <td align="center" style="font-size: 12px;font-family: Verdana, Arial, Helvetica, sans-serif;color:#666;" ><?php if($total_qty==$balance_qty) { echo "PENDING"; } else { echo "RUNNING"; } ?></td>
       </tr>
       <?php } ?>
     </table><br/></div>
</a> <?php } ?>  <?php $rights=get_permissionss('Fusing',$usertype); if($rights=='1'){?> 
<div style="border-bottom:1px solid #CCC; font-family:Verdana, sans-serif; font-size:14px; font-weight:bold; color:#87BB07;">Fusing Production Pending</div>
  <div style="height:150px; width:100%;padding-left:0px;overflow-x:hidden;overflow-y:scroll;white-space:nowrap;">
  <table width="100%" border="0" align="center"  cellpadding="0" cellspacing="0" >
    <tr>
   <td width="31" height="23"  align="center" style="font-size: 12px;  font-family: Verdana, Arial, Helvetica, sans-serif;font-weight:bold">&nbsp;Sno</td>
         <td width="97" align="left" style="font-size: 12px;  font-family: Verdana, Arial, Helvetica, sans-serif;font-weight:bold">&nbsp;Jobcard No</td>
                  <td width="104" align="left" style="font-size: 12px;  font-family: Verdana, Arial, Helvetica, sans-serif;font-weight:bold">&nbsp;Cust Name</td>

         <td width="92" align="left" style="font-size: 12px;font-family: Verdana, Arial, Helvetica, sans-serif;font-weight:bold">&nbsp;Job Type</td>
         <td width="88" align="left" style="font-size: 12px;  font-family: Verdana, Arial, Helvetica, sans-serif;font-weight:bold">Particulars</td>
         <td width="68" align="left" style="font-size: 12px;  font-family: Verdana, Arial, Helvetica, sans-serif;font-weight:bold">T.Qty</td>
         <td width="58" align="right" style="font-size: 12px;  font-family: Verdana, Arial, Helvetica, sans-serif;font-weight:bold">P.Qty</td>
                  <td width="70" align="right" style="font-size: 12px;  font-family: Verdana, Arial, Helvetica, sans-serif;font-weight:bold">Balance</td>

         <td width="127" align="center" style="font-size: 12px;  font-family: Verdana, Arial, Helvetica, sans-serif;font-weight:bold">Pending/Running</td>
    </tr>
  <?php
  function get_customer_details_fuse($job_card_no)
	{
	$entry=mysql_query("select * from fusing_production_main where job_card_no='$job_card_no'");
	while($trip=mysql_fetch_array($entry))
		{
		 $cust_name=$trip['cust_name'];
		  $job_type=$trip['job_type'];
		}
		return array($cust_name,$job_type);
	}
if(($_GET['from_date']!='')&&($_GET['to_date']!=''))
{
 $from_date=date('Y-m-d',strtotime($_GET['from_date']));
 $to_date=date('Y-m-d',strtotime($_GET['to_date']));
}
$current_date=date('Y-m-d');
if($from_date!=""){ $from_date1= " DATE_FORMAT(production_time,'%Y-%m-%d')>='$from_date'"; }else{$from_date1="production_time='$current_date'"; }
if($to_date!=""){ $to_date1 = " DATE_FORMAT(production_time,'%Y-%m-%d')<='$to_date'";}else{$to_date1="production_time='$current_date'";}
{
$all_value102 = $from_date1.",".$to_date1;
}
$all_array102 = explode(',',$all_value102);
foreach($all_array102 as $value1022)
{ 
if($value1022!='')
{
  $get_query103 .= $value1022." AND ";
}
}	  
if($from_date!='')
{
  $sql="select *  from  fusing_production_sublist where $get_query103 pr_id!=''  and deliv_status='0' ";
}
else
{  
 $sql="select * from  fusing_production_sublist  where  DATE_FORMAT(production_time,'%Y-%m-%d')='$current_date'  and deliv_status='0' ";
}
    $rs=mysql_query($sql);
	$s_no=0;
   		while($rsdata=mysql_fetch_array($rs))
  			{
   				 $s_no=$s_no+1;
				 $from=$from+1;
                 $id=$rsdata['pr_id'];
                 $job_card_no=$rsdata['job_card_no'];
				 $print_date=$rsdata['production_time'];
				 $prod_size=$rsdata['prod_size'];
				list($customer_name,$job_type1)=get_customer_details_fuse($job_card_no);
				 $prod_qty=$rsdata['prod_qty'];
				 $total_qty=$rsdata['total_qty'];
				 $balance_qty=$rsdata['balance_qty'];
				 $printed_qty=$rsdata['printed_qty'];

?>
  <tr height="27">
   <td align="center" style="font-size: 12px;font-family: Verdana, Arial, Helvetica, sans-serif;color:#666;">&nbsp;<?php echo $s_no;?></td>
       <td align="left" style="font-size: 12px;font-family: Verdana, Arial, Helvetica, sans-serif;color:#666;">&nbsp;<?php echo $job_card_no;?></td>       <td align="left" style="font-size: 12px;font-family: Verdana, Arial, Helvetica, sans-serif;color:#666;">&nbsp;<?php echo $customer_name;?></td>

       <td align="left" style="font-size: 12px;font-family: Verdana, Arial, Helvetica, sans-serif;color:#666;">&nbsp;<?php echo $job_type1;?></td>
       <td align="left" style="font-size: 12px;font-family: Verdana, Arial, Helvetica, sans-serif;color:#666;">&nbsp;<?php echo $prod_size;?></td>
       <td align="left" style="font-size: 12px;font-family: Verdana, Arial, Helvetica, sans-serif;color:#666;">&nbsp;<?php echo $total_qty;?></td>
       <td align="right" style="font-size: 12px;font-family: Verdana, Arial, Helvetica, sans-serif;color:#666;">&nbsp;<?php echo $prod_qty;?></td>
        <td align="right" style="font-size: 12px;font-family: Verdana, Arial, Helvetica, sans-serif;color:#666;">&nbsp;<?php echo $balance_qty;?></td>

      <td align="center" style="font-size: 12px;font-family: Verdana, Arial, Helvetica, sans-serif;color:#666;" ><?php if($total_qty==$balance_qty) { echo "PENDING"; } else { echo "RUNNING"; } ?></td>
  </tr>
  <?php } ?>
</table></div><?php } ?>  <?php $rights=get_permissionss('Delivery',$usertype); if($rights=='1'){?> 
  <div style="border-bottom:1px solid #CCC; font-family:Verdana, sans-serif; font-size:14px; font-weight:bold; color:#87BB07;">Delivery    </div>
  <div style="height:150px; width:100%;padding-left:0px;overflow-x:hidden;overflow-y:scroll;white-space:nowrap;">
    <table width="100%" border="0" align="center"  cellpadding="0" cellspacing="0" >
      <tr>
         <td width="37" height="23"  align="center" style="font-size: 12px;  font-family: Verdana, Arial, Helvetica, sans-serif;font-weight:bold">&nbsp;Sno</td>
         <td width="97" align="left" style="font-size: 12px;  font-family: Verdana, Arial, Helvetica, sans-serif;font-weight:bold">&nbsp;Jobcard No</td>
                  <td width="102" align="left" style="font-size: 12px;  font-family: Verdana, Arial, Helvetica, sans-serif;font-weight:bold">&nbsp;Cust Name</td>

         <td width="97" align="left" style="font-size: 12px;font-family: Verdana, Arial, Helvetica, sans-serif;font-weight:bold">&nbsp;Job Type</td>
         <td width="92" align="left" style="font-size: 12px;  font-family: Verdana, Arial, Helvetica, sans-serif;font-weight:bold">Particulars</td>
         <td width="63" align="left" style="font-size: 12px;  font-family: Verdana, Arial, Helvetica, sans-serif;font-weight:bold">T.Qty</td>
         <td width="50" align="right" style="font-size: 12px;  font-family: Verdana, Arial, Helvetica, sans-serif;font-weight:bold">P.Qty</td>
                  <td width="70" align="right" style="font-size: 12px;  font-family: Verdana, Arial, Helvetica, sans-serif;font-weight:bold">Balance</td>

         <td width="127" align="center" style="font-size: 12px;  font-family: Verdana, Arial, Helvetica, sans-serif;font-weight:bold">Pending/Running</td>
      </tr>
      <?php
	    function get_tot_qty_deliv($job_card_no)
	{
	$entry=mysql_query("select * from delivery_challan_main where job_no='$job_card_no'");
	while($trip=mysql_fetch_array($entry))
		{
		$total_qty=$trip['total_qty'];
		  $deliv_status=$trip['deliv_status'];
		}
		return array($total_qty,$deliv_status);
	}
if(($_GET['from_date']!='')&&($_GET['to_date']!=''))
{
 $from_date=date('Y-m-d',strtotime($_GET['from_date']));
 $to_date=date('Y-m-d',strtotime($_GET['to_date']));
}
$current_date=date('Y-m-d');
if($from_date!=""){ $from_date1= "delivery_date>='$from_date'"; }else{$from_date1="delivery_date='$current_date'"; }
if($to_date!=""){ $to_date1 = "delivery_date<='$to_date'";}else{$to_date1="delivery_date='$current_date'";}
{
$all_value102 = $from_date1.",".$to_date1;
}
$all_array102 = explode(',',$all_value102);
foreach($all_array102 as $value1022)
{ 
if($value1022!='')
{
  $get_query109 .= $value1022." AND ";
}
}	  
if($from_date!='')
{
  $sql="select *  from  delivery_challan_sub where $get_query109 sub_id!='' order by sub_id asc";
}
else
{  
 $sql="select * from  delivery_challan_sub where ddelivery_date='$current_date' order by sub_id asc";
}
    $rs=mysql_query($sql);
	$s_no=0;
   		while($rsdata=mysql_fetch_array($rs))
  			{
   				 $s_no=$s_no+1;
				 $from=$from+1;
                 $id=$rsdata['sub_id'];
                 $job_card_no=$rsdata['job_no'];
				 $print_date=$rsdata['delivery_date'];
				 $cust_name=$rsdata['cust_name'];
				 $fabric_type=$rsdata['fabric_type'];
				 	list($tot_qty1,$deliv_status)=get_tot_qty_deliv($job_card_no);
				
				 $particulars=$rsdata['particulars'];
				 $job_type=$rsdata['job_type'];
				 $qty=$rsdata['qty'];
				 $bal_qty=$tot_qty1-$qty;

?>
      <tr height="27">
        <td align="center" style="font-size: 12px;font-family: Verdana, Arial, Helvetica, sans-serif;color:#666;">&nbsp;<?php echo $s_no;?></td>
       <td align="left" style="font-size: 12px;font-family: Verdana, Arial, Helvetica, sans-serif;color:#666;">&nbsp;<?php echo $job_card_no;?></td>       <td align="left" style="font-size: 12px;font-family: Verdana, Arial, Helvetica, sans-serif;color:#666;">&nbsp;<?php echo $cust_name;?></td>

       <td align="left" style="font-size: 12px;font-family: Verdana, Arial, Helvetica, sans-serif;color:#666;">&nbsp;<?php echo $job_type;?></td>
       <td align="left" style="font-size: 12px;font-family: Verdana, Arial, Helvetica, sans-serif;color:#666;">&nbsp;<?php echo $particulars;?></td>
       <td align="left" style="font-size: 12px;font-family: Verdana, Arial, Helvetica, sans-serif;color:#666;">&nbsp;<?php echo $tot_qty1;?></td>
       <td align="right" style="font-size: 12px;font-family: Verdana, Arial, Helvetica, sans-serif;color:#666;">&nbsp;<?php echo $qty;?></td>
        <td align="right" style="font-size: 12px;font-family: Verdana, Arial, Helvetica, sans-serif;color:#666;">&nbsp;<?php echo $bal_qty;?></td>

      <td align="center" style="font-size: 12px;font-family: Verdana, Arial, Helvetica, sans-serif;color:#666;" ><?php if($tot_qty1==$bal_qty) { echo "PENDING"; } else { echo "RUNNING"; } ?></td>
      </tr>
      <?php } ?>
    </table>
  </div><?php } ?></td>
<td width="232" height="152" align="left" valign="top">&nbsp;</td>
   </tr>
 </table>