<style>
.style15 {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 14px;
font-weight: bold;
}
</style>
<script>
function edit_job_details(edit_id,jobcard_no)
{
window.location.href="main_fram.php?file=jobcard_quotation&main_id=" + edit_id + "&jobcard_no=" + jobcard_no;
}
function job_quot_confrm(jobcard_no,source)
{
window.location.href="main_fram.php?file=jobcard_quotation&jobcard_no=" + jobcard_no + "&source=quotation_confirm";
}
</script>

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

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


if($cust_name!=""){ $customer_name1= "cust_name='$cust_name'"; }else{$customer_name1=''; }
if($from_date!=""){ $from_date1= "DATE_FORMAT( entry_date,'%Y-%m-%d' )>='$from_date'"; }else{$from_date1="DATE_FORMAT(entry_date,'%Y-%m-%d' )='$cur_dates'"; }
if($to_date!=""){ $to_date1 = "DATE_FORMAT(entry_date,'%Y-%m-%d' )<='$to_date'";}else{$to_date1="DATE_FORMAT(entry_date,'%Y-%m-%d' )='$cur_dates'";}
if($status!=""){ $jobtype1 = "job_type='$status'";}else{$jobtype1='';}
if($quotation_no!=""){ $quotation_no1 = "jobcard_quot_no='$quotation_no'";}else{$quotation_no1='';}

$all_value10 = $customer_name1.";".$from_date1.";".$to_date1.";".$jobtype1.";".$quotation_no1;
$all_array10 = explode(';',$all_value10);
foreach($all_array10 as $value10)
{ 
if($value10!='')
{
$get_query102 .= $value10." AND ";
}
}	  
 
if(($from_date=='')&&($to_date==''))
  {
   $sql="select * from  jobcard_quotation where  DATE_FORMAT( entry_date,  '%Y-%m-%d' )='$current_date'  order by jobcard_quot_no ASC ";
  } 
  else
  {
   $sql="select * from  jobcard_quotation where $get_query102 	main_id!='' order by jobcard_quot_no ASC ";
  }

$html_query = "main_fram.php?file=jobcard_creation_list";
$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_jobcard_quot('jobcard/quotation_jobcard/jobcard_quot_main_print.php?customer_name=<?php echo $_GET['customer_name'];?>&from_date=<?php echo $_GET['from_date'];?>&to_date=<?php echo $_GET['to_date'];?>&jobtype=<?php echo $status; ?>&quotation_no=<?php echo $quotation_no; ?>');" 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="120" align="left" style="border:1px solid #ddd" scope="col" >&nbsp;&nbsp;Quotation No</th>
      <th scope="col" align="left" style="border:1px solid #ddd" >Created By</th>
      <th width="255" align="left" scope="col" style="border:1px solid #ddd" >Customer Name</th>
      <th width="131" align="left" scope="col" style="border:1px solid #ddd" >Job Type</th>
      <th width="120" align="left" style="border:1px solid #ddd" scope="col" >&nbsp;&nbsp;Fabric Type</th>
       <th width="108" align="right" scope="col" style="border:1px solid #ddd" >Total Qty&nbsp;</th>
      <th width="90" align="right" scope="col" style="border:1px solid #ddd" >Total Value&nbsp;</th>
         
      <th width="85" align="center" scope="col" style="border:1px solid #ddd" >View</th>
      <?php if(($user_id=='1')||($user_id=='3'))
	 { 
	 ?>
      <th width="45" align="center" scope="col" style="border:1px solid #ddd" >Edit</th>
      <th width="69" align="center" scope="col" style="border:1px solid #ddd" >Delete</th>
	<?php } ?>
      </tr>
  <?php
  include ("../../include/db.php");
  
  function place_branch_name($book_branch)
  {
	$sql_user="select * from branch_creation where branch_id='$book_branch' and delete_status!='1' ";
	$rs_user=mysql_query($sql_user);
	while($rsdata_user=mysql_fetch_object($rs_user))
	{ 
	$branch_name=$rsdata_user->branch_name;
	}
	return $branch_name;
  }
 function get_tot_qty_jobcard_quot($jobcard_no)
  {
	$sql_user="select sum(qty) as qty from jobcard_quotation_sub where jobcard_quot_no='$jobcard_no'";
	$rs_user=mysql_query($sql_user);
	while($rsdata_user=mysql_fetch_object($rs_user))
	{ 
	$qty12=$rsdata_user->qty;
	}
	return $qty12;
  }
 
  function book_place_names($book_place)
  {
	$sql_user="select * from place_creation where id='$book_place'";
	$rs_user=mysql_query($sql_user);
	while($rsdata_user=mysql_fetch_object($rs_user))
	{ 
	$location=$rsdata_user->location;
	}
	return $location;
  }
  
  function gets_book_count($booking_no)
  {
	  $sql_user="select * from booking_sub_list where book_no='$booking_no'";
	  $rs_user=mysql_query($sql_user);
	  $rs_count=mysql_num_rows($rs_user); 
	  return $rs_count;
  }
  

$cust_name=$_GET['customer_name'];
$from_date=$_GET['from_date'];
$to_date=$_GET['to_date'];
$status=$_GET['jobtype'];
$current_date=date('Y-m-d');
$quotation_no=$_GET['quotation_no'];

if($cust_name!=""){ $customer_name1= "cust_name='$cust_name'"; }else{$customer_name1=''; }
if($from_date!=""){ $from_date1= "DATE_FORMAT( entry_date,'%Y-%m-%d' )>='$from_date'"; }else{$from_date1="DATE_FORMAT(entry_date,'%Y-%m-%d' )='$cur_dates'"; }
if($to_date!=""){ $to_date1 = "DATE_FORMAT(entry_date,'%Y-%m-%d' )<='$to_date'";}else{$to_date1="DATE_FORMAT(entry_date,'%Y-%m-%d' )='$cur_dates'";}
if($status!=""){ $jobtype1 = "job_type='$status'";}else{$jobtype1='';}
if($quotation_no!=""){ $quotation_no1 = "jobcard_quot_no='$quotation_no'";}else{$quotation_no1='';}

$all_value10 = $customer_name1.";".$from_date1.";".$to_date1.";".$jobtype1.";".$quotation_no1;
$all_array10 = explode(';',$all_value10);
foreach($all_array10 as $value10)
{ 
if($value10!='')
{
 $get_query103 .= $value10." AND ";
}
}	  


if(($from_date=='')&&($to_date==''))
  {
   $sql="select * from  jobcard_quotation where  DATE_FORMAT( entry_date, '%Y-%m-%d' )='$current_date'  order by jobcard_quot_no  ASC LIMIT $from,20";
  } 
  else
  {
   $sql="select * from  jobcard_quotation where $get_query103 main_id!='' order by jobcard_quot_no ASC LIMIT $from,20";
  }
	$rs=mysql_query($sql);
	$sno=0;
   		while($rsdata=mysql_fetch_array($rs))
  			{
   				$sno=$sno+1;
				$from=$from+1;
   				$main_id=$rsdata['main_id'];
   				$jobcard_no=$rsdata['jobcard_quot_no'];
				$created_by=$rsdata['created_by'];
	   			$cust_name=$rsdata['cust_name'];
				$book_place_names=book_place_names($book_place);
	   			$entry_date=$rsdata['entry_date'];
				$book_branch_names=place_branch_name($book_branch);
				$job_type=$rsdata['job_type'];
	   			$fabric_type=$rsdata['fabric_type'];
	   			$overall_value=$rsdata['overall_value'];
	   			$net_total=$rsdata['net_total'];
				$item_image=$rsdata['item_image'];
				$tot_qty=get_tot_qty_jobcard_quot($jobcard_no);
  ?>
  <tr>
    <td width="55"  align="center" style="border:1px solid #ddd"><?php echo $from; ?></td>
    <td width="93" align="left" style="border:1px solid #ddd">&nbsp;&nbsp;<?php echo date("d-m-Y",strtotime($entry_date));?></td>
    <td align="left" style="border:1px solid #ddd">&nbsp;&nbsp;&nbsp;&nbsp;<?php echo $jobcard_no;?></td>
    <td width="125" align="left" style="border:1px solid #ddd">&nbsp;&nbsp;<?php echo $created_by;?></td>
    <td align="left" style="border:1px solid #ddd">&nbsp;&nbsp;<?php echo $cust_name;?></td>
    <td align="left" style="border:1px solid #ddd">&nbsp;<?php echo $job_type;?></td>
    <td align="left" style="border:1px solid #ddd">&nbsp;&nbsp;<?php echo $fabric_type;?></td>
     <td align="right" style="border:1px solid #ddd"><?php echo number_format($tot_qty,2);?>&nbsp;</td>
    <td align="right" style="border:1px solid #ddd"><?php echo number_format($net_total,2);?>&nbsp;</td>
   
    <td align="center" style="cursor:pointer; border:1px solid #ddd"><a href="javascript:individual_print_jobcard('jobcard/quotation_jobcard/jobcard_quot_view_print.php?jobcard_quot_no=<?php echo $jobcard_no;?>&cust_name=<?php echo $cust_name;?>&item_image=<?php echo $item_image;?>');" style="text-decoration:none;"><img src="img/PrinterBlack.png" width="30" height="30" title="Print" value="Print"/></a></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_job_details('<?php echo $main_id;?>','<?php echo $jobcard_no;?>');"/></td> 

    <td align="center" style="border:1px solid #ddd" ><img src="img/trash.png" style="cursor:pointer" onClick="del_job_main_quot('<?php echo $main_id;?>','<?php echo  $jobcard_no;?>')" width="20px" height="22px">
    </td><?php } ?>
   </tr>
  <?php } ?>
</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_links1.php");
			  }
	?></th>
 </tr>
</table>
</div>
</div>
</div>

