<?php require_once '../../masterpage/webservice_master.php'; 
	
	header("Access-Control-Allow-Origin: *");
		$operative_ID =$_POST['operative_ID'];
	$cond = "operative_ID='".$operative_ID."' AND surveyType_ID=1 AND isActive = 1 AND isDelete = 0 AND isCompletedByOperative=0 ";
	$rows = $obj->fetchRowall('lfs_asign_survey_operative',$cond);
	
	$row_arr=array();
	$d=0;
	$row = array();
	if($rows){
	foreach ($rows as $rowvalue) {
		$conds = "project_ID='".$rowvalue['project_ID']."' AND isActive = 1 AND isDelete = 0 ";
		$rows = $obj->fetchRowall('lfs_projects',$conds);
		$row_arr[$i]=$rows[0]['project_ID'];
		$project_id=$rowvalue['project_ID'];
		//----------------------------------

		$conddoor = "project_ID='".$rowvalue['project_ID']."' AND isActive = 1 AND isDelete = 0 ";
		$rowsmainarr = $obj->fetchRowall('lfs_fire_door_installation_survey',$conddoor);

		if($rowsmainarr){
		//$row[$d]=$rowsmainarr;
		$m=0;
		
		foreach ($rowsmainarr  as $key => $value) {
			$l=0;
		 foreach ($value  as $keys => $values) {

		 				$row[$d][$key][$keys]=$values;
		 			//echo 'cont_ass_fire_add_image1 =='. "'".$keys."'<br>";
		 			if("$keys" == 'ext_img'){
		 				if($values!=''){
		 			
				 		$image_url = file_get_contents('../../../images/door_images/'.$values);
						$row[$d][$key][$keys]=base64_encode($image_url);
				 		}
				 	}
				 	if("$keys" == 'int_img'){
						if($values!=''){
		 				$image_url1 =file_get_contents('../../../images/door_images/'.$values); 

		 				$row[$d][$key][$keys]=base64_encode($image_url1);
		 				}
		 		   }
		 		    if("$keys" == 'ext_img1'){
		 				if($values!='' ){
		 			
		 				$image_url3 = file_get_contents('../../../images/door_images/'.$values);
						$row[$d][$key][$keys]= base64_encode($image_url3);
		 				}
		 					
		 			}
		 			 if("$keys" == 'int_img1'){
		 				if($values!=''){
		 						
		 				 $image_url4 =file_get_contents('../../../images/door_images/'.$values);
						$row[$d][$key][$keys]= base64_encode($image_url4);
		 				}
		 			}

		 			if("$keys" == 'signed_resident'){
		 				if($values!=''){
		 						
		 				 $image_url5 =file_get_contents('../../../images/sing/'.$values);
						$row[$d][$key][$keys]= base64_encode($image_url5);
		 				}
		 			}
		 			if("$keys" == 'signed_supervisor'){
		 				if($values!=''){
		 						
		 				 $image_url6 =file_get_contents('../../../images/sing/'.$values);
						$row[$d][$key][$keys]= base64_encode($image_url6);
		 				}
		 			}
		 			if("$keys" == 'signed_installer'){
		 				if($values!=''){
		 						
		 				 $image_url7 =file_get_contents('../../../images/sing/'.$values);
						$row[$d][$key][$keys]= base64_encode($image_url7);
		 				}
		 			}

		 			if("$keys" == 'firestopping_external'){
		 				if($values!='' ){
		 			
		 				$image_url8 = file_get_contents('../../../images/door_images/'.$values);
						$row[$d][$key][$keys]= base64_encode($image_url8);
		 				}
		 					
		 			}
		 			 if("$keys" == 'firestopping_internal'){
		 				if($values!=''){
		 						
		 				 $image_url9 =file_get_contents('../../../images/door_images/'.$values);
						$row[$d][$key][$keys]= base64_encode($image_url9);
		 				}
		 			}
// 		 				

		 			$l++;
		 		
		 }


	$m++;

		}
		$d++;
	}

	
}

}
// echo "<pre>";
// print_r($row);
// exit();
	if(!empty($row)){
		echo json_encode($row);
	}
	else
	{
		echo json_encode(0);
	}

?>
