<?php
function get_children($parent)
{	
global $db;$rurl="modid=".$_REQUEST['modid']."&frmid=".$_REQUEST['frmid'];  
$query = DB_query('SELECT * FROM master_boq WHERE parentid = '.$parent, $db);
if(DB_num_rows($query) > 0)
{		 	
	while($row =DB_fetch_array($query))
	{		
	 $count2=DB_query("select start_date,end_date,durations  from pms_monthly where boq_id='".$row['id']."'",$db);	
	$count3=DB_fetch_array($count2);		
	?>
	<tr>
    <td><?php echo $row['group_title']; ?> </td>
    <td><?php echo $row['qty']; ?></td>
    <td><strong><?php echo $count3['start_date']; ?></strong></td>
	<td><strong><?php echo $count3['end_date']; ?></strong></td>
	<td><strong><?php echo $count3['durations']; ?></strong></td>
  </tr>
  <?php	} }} ?>
<link href="css/tender_project.css" rel="stylesheet" type="text/css" />
<div class="tender_main_page">
<h1>Project Progress Bar</h1>
<!-- Body Content Start
<div id="body_content">
<div class="left_part">
  <!--left table 1 start 
    <!--left table 1 close 
<div style="border:#93959c solid 1px; width:260px; overflow:auto; height:300px;">
<table width="100%" border="1" >
  <tr><th>Task Name</th><th>Qty</th><th>Start Date</th><th>End Date</th><th>Durations</th></tr>
  <?php   
  $query = DB_query('SELECT * FROM master_boq  where parentid=0',$db);
  if(DB_num_rows($query)>0)
   { 		
	while($row =DB_fetch_array($query)) 
	{	
	$count=DB_query("select sum(qty) as qty  from master_boq where parentid='".$row['id']."'",$db);	
	$count1=DB_fetch_array($count);
	$count2=DB_query("select start_date,end_date,durations  from pms_monthly where boq_id='".$row['id']."'",$db);	
	$count3=DB_fetch_array($count2);
	?>
	<tr>
	<td><strong><?php echo $row['group_title'];  ?></strong></td>
	<td><strong><?php echo $count1['qty']; ?></strong></td>
	<td><strong><?php echo $count3['start_date']; ?></strong></td>
	<td><strong><?php echo $count3['end_date']; ?></strong></td>
	<td><strong><?php echo $count3['durations']; ?></strong></td>
	</tr>
	<?php get_children($row['id']) ;	?>  
	<?php }}	else echo 'No Items';  ?>  
</table>  	
  </div>
    </div> Close Left Part   
<div class="right_part">  </div>
<!-- Right Table 1 start <div>-->
	<a href="#" onclick='popup("jpgraph-3.0.7/src/Examples/ganttcolumnfontsex01.php",1000,1000)' style="text-decoration: none;">
		Click For Large View</a>
<div>
<?php
$name=array();
$startdate=array();
$enddate=array();
$data5=array();
$qtydata=array();
$data6=array();
$dura=array();
$sql1=DB_query("select * from master_boq where parentid=0",$db);
while($sqldata=DB_fetch_array($sql1))
{
$name[]=$sqldata['group_title'];
$count2=DB_query("select start_date,end_date,durations  from pms_monthly where boq_id='".$sqldata['id']."'",$db);	
$count3=DB_fetch_array($count2);
if($count3['start_date']!='0000-00-00' && $count3['start_date']!='')
{	
$startdate[]=$count3['start_date'];
$enddate[]=$count3['end_date'];
$dura[]=$count3['durations'];
}
$count=DB_query("select sum(qty) as qty  from master_boq where parentid='".$sqldata['id']."'",$db);	
$count1=DB_fetch_array($count);
$qtydata[]=$count1['qty'];
$sql2=DB_query("select * from master_boq where parentid='".$sqldata['id']."'",$db);
while($sqldata1=DB_fetch_array($sql2))
{

//echo "select start_date,end_date,durations  from pms_monthly where boq_id='".$sqldata1['id']."'";
$count2=DB_query("select start_date,end_date,durations  from pms_monthly where boq_id='".$sqldata1['id']."'",$db);	
$count3=DB_fetch_array($count2);
if($count3['start_date']!='0000-00-00' && $count3['start_date']!='')
{
	$name[]=substr($sqldata1['group_title'],0,10);	
$startdate[]=$count3['start_date'];
$enddate[]=$count3['end_date'];
$dura[]=$count3['durations'];
}
$qtydata[]=$sqldata1['qty'];
}
}
for($i=0;$i<count($startdate);$i++)
{

$data5[]=$i;
$data5[]=$name[$i];
$data5[]=$startdate[$i];
$data5[]=$enddate[$i];
$data5[]=$dura[$i];
}
//print_r($data5);
$data6=array_chunk($data5,5); 
//print_r($data6);
//print_r($startdate);
$_SESSION['data']=$data6;
?>  
<iframe src="jpgraph-3.0.7/src/Examples/ganttcolumnfontsex01.php" style="width:800px; height:300px" ></iframe>
  
</div>

<!-- Right Table 2 Close-->
</div><!-- Close Right Part -->
  <div class="cl"></div>
</div>
<!-- Body Content Close -->
<div style="height:30px;"></div>
</div>


