<link rel="stylesheet" href="css/new_mxerp.css">
<script>
	function displatPeriod(){
		if(document.getElementById("getperiod").style.display!='block'){
			document.getElementById("getperiod").style.display="block";
			
			document.getElementById("getparty").style.display="none";
			document.getElementById("gettech").style.display="none";
		}
		else if(document.getElementById("getparty").style.display!='block'){alert('hi 2');
			document.getElementById("getparty").style.display="block";
			
			document.getElementById("getperiod").style.display="none";
			document.getElementById("gettech").style.display="none";
		}
		else if(document.getElementById("gettech").style.display!='block'){alert('hi 3');
			document.getElementById("gettech").style.display="block";
			
			document.getElementById("getperiod").style.display="none";
			document.getElementById("getparty").style.display="none";
		}
		else{
		
		}
		
	}
	
</script>
<?php error_reporting(FALSE);
if($_REQUEST['Search']){

	$fromdate=$_REQUEST['fromdate'];
	$fromDateBrk=explode("/",$fromdate);
	$fromDate=$fromDateBrk[0];
	$fromMonth=$fromDateBrk[1];
	$fromYear=$fromDateBrk[2];
	$From=$fromYear."-".$fromMonth."-".$fromDate;
	
	$todate=$_REQUEST['todate'];
	$toDateBrk=explode("/",$todate);
	$toDate=$toDateBrk[0];
	$toMonth=$toDateBrk[1];
	$toYear=$toDateBrk[2];
	$To=$toYear."-".$toMonth."-".$toDate;
	
	if($todate!='' && $fromdate!=''){
		$filter[]="ttDate between '".$From."' and '".$To."'";
	}
	
	if($filter!=''){
		$filter1=implode(" and ",$filter);
		 $sql = "Select * from trouble_ticket_creation where $filter1";
		$GetPeriodData= DB_query($sql,$db);
	}else{
		$sql = "Select * from trouble_ticket_creation";
		$GetPeriodData= DB_query($sql,$db);
	}
}
?>
<div class="body_contain">
  <div class="tab_div">
    <form action="" method="post">
      <table width="100%" border="0" cellpadding="3" cellspacing="0" style="border-collapse:collapse;">
        <tr style="border:#999999;">
          <td class="tabledata1" nowrap="nowrap" scope="row">From Date : </td>
          <td nowrap="nowrap"><input name="fromdate" id="fromdate" type="text"  class="datepicker" style="width:150px;" value="<?php echo $_REQUEST['fromdate'];?>" /></td>
          <td class="tabledata1" nowrap="nowrap" scope="row">To Date : </td>
          <td nowrap="nowrap"><input name="todate" id="todate" type="text"  class="datepicker" style="width:150px;"  value="<?php echo $_REQUEST['todate'];?>" /></td>
		  <td><input type="submit" name="Search" value="Search" class="bottonsview" /></td>
        </tr>
      </table>
    </form>
    <?php if($_REQUEST['Search']=='Search'){?>
      	<table width="100%" border="1" cellpadding="3" cellspacing="0" style="border-collapse:collapse; border:#666666 solid 1px;">
        <tr>
          <td class="tabledata">S. No.</td>
          <td class="tabledata">Date</td>
          <td class="tabledata">TT No </td>
          <td class="tabledata">Party Name </td>
          <td class="tabledata">Product Name</td>
          <td class="tabledata">Problem Description </td>
          <td class="tabledata">Expected</td>
          <td class="tabledata">Closer Date </td>
          <td class="tabledata">Assigned User</td>
          <td class="tabledata">Status</td>
        </tr>
        <?php $i=1;
	  	if(DB_num_rows($GetPeriodData)>0){
		while($mainRow1=DB_fetch_array($GetPeriodData))
		{
		?>
				<tr bgcolor="#c1c1c1">
				  <td><?php echo $i;?> </td>
				  <td><?php echo ConvertSQLDate($mainRow1['ttDate']);?></td>
				  <td><?php echo $mainRow1['ticket_number'];?> </td>
				  <td><?php echo $part_name= $s->GetFieldValue('clientmaster', 'id="'.$mainRow1['part_name'].'"','c_name');?></td>
				  <td><?php $item = DB_query("SELECT item_name FROM item_master where id='".$mainRow1['product_name']."' ",$db);
				  $Item_name = DB_fetch_array($item);
				  echo $Item_name['item_name'];?></td>
				  <td><?php echo $mainRow1['prob_desc'];?> </td>
				  <td><?php echo  $mainRow1['expire_date'];?></td>
				  <td><?php echo $mainRow1['closer_date'];?> </td>
				  <td><?php 
				  	$assige_user = $s->GetFieldValue('trouble_ticket_creation_assignment', 'ttid="'.$mainRow1['id'].'"', 'technician_id');
					echo $s->GetFieldValue('technicians', 'id="'.$assige_user.'"', 'technician'); ?></td>
				  <td><?php echo $mainRow1['is_assign'];?></td>
				</tr>
				<?php
		$i++;	
		}
		}else{
	?>
		<tr bgcolor="#c1c1c1">
				  <td colspan="10">No Results Found</td>
				</tr>
		<?php } ?>
      </table>
    <?php } ?>
  </div>
</div>
