<?php include_once("class/class.MySQL.php");
$db	=new MySQL();

$wk=$_POST['pageId'];
$userid=$_POST['user'];


			 $jcnt=0; $pcnt=0; $projects_act_list = $db->fetchQuery("SELECT * FROM project_plan_activity   where e_id='$userid' and week_no='$wk' and (flag1=0 || flag1=2)"); 
 $vcount=count($projects_act_list);

if($vcount > 0)
{

$HTML.='<table  class="list-leaves add-activity"  style="width:107px !important;">
	<tr><td>SlNo:</td>
	<td>Project ID</td>
<td>Project Name</td>
	<td>Date</td>
	<td>Activities Planned</td>

	<td>Hours Planned</td>
	
	<td>Task Details</td>
	<td>Hours Taken</td>
	</tr>';

}
		foreach($projects_act_list as $act_done_list){ 
        $pcnt=$pcnt+1;
		
		//echo "SELECT * FROM project_activity_done  where p_act_id='$act_done_list[id]' and status_proj !=1";
		$projects_stat = mysql_query("SELECT * FROM project_activity_done  where p_act_id='$act_done_list[id]' and status_proj !=1");
        $projects_stat_cn = mysql_num_rows($projects_stat);
		/*if($projects_stat_cn > 0){*/
		$jcnt=$jcnt+1;
	
	$projects_current = $db->fetchQuery("SELECT * FROM project_table where id='$act_done_list[project_id]' order by id desc ");
	$projects_all = $db->fetchQuery("SELECT * FROM project_table where id='$act_done_list[project_id]' order by id desc ");
	
	 $HTML.='<tr class="m_tr" id="m_tr0"><input type="hidden" name="p_main_id[]" class="p_main_id" value="'.$act_done_list['id'].'"  />
<td id="slnoo0" class="activity-slno">'.$pcnt.'</td>
<td><div  class="sel_p_id"><select name="proj_ids[]" id="proj_ids'.$jcnt.'" style="width:136px;">	
<option value="">Select Project Id</option>	';		
 foreach($projects_current as $all_proj){
	 if($all_proj['id']==$act_done_list['project_id'])
	 {
$HTML.='<option value="'.$all_proj['id'].'" selected="selected" >'.$all_proj['proj_id'].'</option>';
	 }
	 else
	 {
$HTML.='<option value="'.$all_proj['id'].'" >'.$all_proj['proj_id'].'</option>';		 
	 }
 } 
$HTML.='</select></div></td>
<td>	<div  class="sel_div">
		<select name="proj_name[]" id="proj_name'.$jcnt.'" style="width:136px;">
			<option value="">Select Project Name</option>	';			
 foreach($projects_all as $all_projts){
 if($all_projts['id']==$act_done_list['project_id'])
	 {
$HTML.='<option value="'.$all_projts['id'].'" selected="selected">'.$all_projts['proj_name'].'</option>';		 
	 }
	 else
	 {
$HTML.='<option value="'.$all_projts['id'].'">'.$all_projts['proj_name'].'</option>';
	 }
 } 
$HTML.='</select></div></td>
<td>	<div class="form_div_3_activitiesdone datesdiv" id="sel_divcxz">


				</div></td>
<td><input type="text" name="task_detail[]" id="task_detail" value="'.$act_done_list['activities'].'" readonly class="task_read"></td>



<td>
<select name="hurs[]" id="hurs'.$jcnt.'" style="width:135px;" class="hrs" disabled="disabled">
<option value="">Select</option>';
 for($r=1;$r<=24;$r++){
   if($act_done_list['hourss']==$r)
   {
$HTML.='<option value="'.$r.'" selected="selected">'.$r.'hr</option>';
  }
  else
  {
  $HTML.='<option value="'.$r.'">'.$r.'hr</option>';
  }
}
$HTML.='</select>

</td>
<td><input type="text" name="act_vity[]" id="act_vity'.$jcnt.'" value="" class="actss"></td>
<td>
<select name="hurs_task[]" id="hurs_task'.$jcnt.'" style="width:135px;" class="hrss">
<option value="">Select</option>';
 for($r=1;$r<=24;$r++){

  $HTML.='<option value="'.$r.'">'.$r.'hr</option>';

}
$HTML.='</select>

</td>

</tr>';


				


	
	
/*}*/
}
	$HTML.='</table>';
	
		$HTML.='<hr>	<div class="button_position">';
		if($jcnt > 0){
			
													$HTML.='<div class="add_more_img" style="margin-top: 3px !important;width: 79px  !important;">
				<a href="javascript:void(0)" onClick="clone_dv();"><img src="images/demo_1.jpg"></a>
				</div>	<div class="add_projects"><button type="button" class="add_projects" id="savclick" name="savclick" onClick="save_proj_done();">Submit</button></div><input type="hidden" name="cnt_hid" id="cnt_hid" value="'.$jcnt.'">';
				}					
				 $HTML.=' </div>';
if($jcnt==0)
{
$HTML.='<table  class="list-leaves add-activity"  style="width:107px !important;">
	<tr><td>SlNo:</td>
	<td>Project ID</td>
<td>Project Name</td>
	<td>Date</td>
	<td>Activities Planned</td>

	<td>Hours Planned</td>
	
	<td>Task Details</td>
	<td>Hours Taken</td>
	</tr>';
      
       // $pcnt=$pcnt+1;
		
	
		/*if($projects_stat_cn > 0){*/
		$jcnt=$jcnt+1;
	
	$projects_current = $db->fetchQuery("SELECT * FROM project_table  order by id desc ");
	$projects_all = $db->fetchQuery("SELECT * FROM project_table  order by id desc ");
	
	 $HTML.='<tr class="m_tr" id="m_tr0"><input type="hidden" name="p_main_id[]" class="p_main_id" value="'.$act_done_list['id'].'"  />
<td id="slnoo0" class="activity-slno">'.$jcnt.'</td>
<td><div  class="sel_p_id"><select name="proj_ids[]" id="proj_ids'.$jcnt.'" style="width:136px;" onchange="get_proj(this,'.$jcnt.')">	
<option value="">Select Project Id</option>	';		
 foreach($projects_current as $all_proj){
	 if($all_proj['id']==$act_done_list['project_id'])
	 {
$HTML.='<option value="'.$all_proj['id'].'" selected="selected" >'.$all_proj['proj_id'].'</option>';
	 }
	 else
	 {
$HTML.='<option value="'.$all_proj['id'].'" >'.$all_proj['proj_id'].'</option>';		 
	 }
 } 
$HTML.='</select></div></td>
<td>	<div  class="sel_div">
		<select name="proj_name[]" id="proj_name'.$jcnt.'" style="width:136px;" onchange="get_proj(this,'.$jcnt.')">
			<option value="">Select Project Name</option>	';			
 foreach($projects_all as $all_projts){
 if($all_projts['id']==$act_done_list['project_id'])
	 {
$HTML.='<option value="'.$all_projts['id'].'" selected="selected">'.$all_projts['proj_name'].'</option>';		 
	 }
	 else
	 {
$HTML.='<option value="'.$all_projts['id'].'">'.$all_projts['proj_name'].'</option>';
	 }
 } 
$HTML.='</select></div></td>
<td>	<div class="form_div_3_activitiesdone datesdiv" id="sel_divcxz">


				</div></td>
<td><input type="text" name="task_detail[]" id="task_detail" value="'.$act_done_list['activities'].'"  class="task_read"></td>



<td>
<select name="hurs[]" id="hurs'.$jcnt.'" style="width:135px;" class="hrs" >
<option value="">Select</option>';
 for($r=1;$r<=24;$r++){
   if($act_done_list['hourss']==$r)
   {
$HTML.='<option value="'.$r.'" selected="selected">'.$r.'hr</option>';
  }
  else
  {
  $HTML.='<option value="'.$r.'">'.$r.'hr</option>';
  }
}
$HTML.='</select>

</td>
<td><input type="text" name="act_vity[]" id="act_vity'.$jcnt.'" value="" class="actss"></td>
<td>
<select name="hurs_task[]" id="hurs_task'.$jcnt.'" style="width:135px;" class="hrss">
<option value="">Select</option>';
 for($r=1;$r<=24;$r++){

  $HTML.='<option value="'.$r.'">'.$r.'hr</option>';

}
$HTML.='</select>

</td>

</tr>';


				
	$HTML.='</table>';
	
		$HTML.='<hr>	<div class="button_position">';
		if($jcnt > 0){
			
													$HTML.='<div class="add_more_img" style="margin-top: 3px !important;width: 79px  !important;">
				<a href="javascript:void(0)" onClick="clone_dv();"><img src="images/demo_1.jpg"></a>
				</div>	<div class="add_projects"><button type="button" class="add_projects" id="savclick" name="savclick" onClick="save_proj_done();">Submit</button></div><input type="hidden" name="cnt_hid" id="cnt_hid" value="'.$jcnt.'">';
				}					
				 $HTML.=' </div>';
echo $HTML;
	
	
/*}*/

}
else
{
echo $HTML;
}

?>