<?php
require('../head2Alts.php');
?>
<label id="main_title">WELCOME TO BUDA RENTING HOUSES CENTER</label><p/>
<?php

 if (isset($_POST['owniD']) && isset($_POST['roomid']) &&  isset($_POST['house_no'])) {
 $post=$_POST['post'];	   
 $ownID=$_POST['owniD'];
 $house_no=$_POST['house_no'];
 $roomid=$_POST['roomid'];
 $receiverid=$ownID;

 $hs=$hcon->getThisHousesDetail($house_no);
 if ($hs->rowCount()>0) {
  
   $hD=$hs->fetch();


$hMG=$hcon->getHousesPImg($house_no);
if($hMG->rowCount()>0)
             {
               $img=$hMG->fetch();
               $pMG= $img['directory'];
              }
              else
              {
$pMG='../houseimages/defaultP.jpg';
              }


   ?>
 

<table border="1" width="100%">
 <td colspan="2">
    <ul>
               <li>
                     <form action="getThisHouseDetailIn.php" method="post">

                      <input class="hi" type="text" name="owniD"  value="<?php echo $ownID;?>">


                      <input class="hi" type="text" name="house_no"  value="<?php echo $house_no;?>">

 

                      <input  id="item" type="submit" value="House detail" name="post"  >

                 </form>
               </li>  

                 <li id="lipad">
      
                   <form action="getThisRoomDetailIn.php" method="post">

                      <input class="hi" type="hidden" name="owniD"  value="<?php echo $ownID;?>">


                      <input class="hi" type="hidden" name="roomid"  value="<?php echo $roomid;?>">


                      <input class="hi" type="hidden" name="house_no"  value="<?php echo $house_no;?>">

 

                      <input  id="item" type="submit" value="Reload" name="post"  >

                 </form>
             </li>
  </ul>
  </td>
</tr>
<tr>

 <td   width="35%" valign="top">
		

	 <b> <?php echo $hD['house_title'] ?> images</b><br/>
          <img id="picR" src="<?php echo $pMG?>">
	  
 <br/>Register on:
		         <small><i> 
                       <?php echo $hD['regdate'];?> 
				</i> </small>
		    
     

	 
  

	
	<p/> <b><?php echo "Room no:" .$roomid;?> profile  summmary</b>
      

		
      
		 
      
		<?php
		//$profile=$itm['profileimages'];
	    $rD=$hcon->getHousesThisRoom($house_no,$roomid);
        if ($rD->rowCount()>0)
         {
   	        $Dr=$rD->fetch();

			  ?>
			
		 
	     <ul style="padding-top:0% padding-left:0%;">
				<li style="padding-top:2%; text-align:top; padding-left:2%;">
				 <?php echo "Room id:<hr>".$Dr['roomid']."</hr>"; ?></li>
				 <li style="padding-top:2%; text-align:top; padding-left:2%;">
				 <?php echo "Category:<hr>". $Dr['category']."</hr>"; ?></li>

				 <li style="padding-top:2%; text-align:top; padding-left:2%;">
				 <?php echo "Monthly Cost<hr>:". $Dr['cost']."</hr>"; ?></li>
                <li style="padding-top:2%; text-align:top; padding-left:2%;">
				 <?php echo "Contract duration:<hr>". $Dr['contract_duration']."</hr>"; ?></li>
                <li style="padding-top:2%; text-align:top; padding-left:2%;">
				 <?php echo "Status:<hr>". $Dr['status']."</hr>"; ?></li>
                 
			</ul>
      <p/><i>Finishing description</i><br>
 
  
      <?php echo $Dr['finishingdisc'];?>
		 
		</td>
		
	  
     <td width="65%"   align="justify" height="auto" valign="top" >
     	 <?php echo  "Call owner:(<b>".$hD['phone_no'] ."</b>)";?>
    <ul>
    <?php
     $Ri=$hcon->getThisRoomImages($house_no,$roomid);
   
   if ($Ri->rowCount()>0) {
   	 $fri=$Ri->fetchAll();
   	 foreach ($fri as $key => $rG) {
   	 	 ?>
       <li id="dlir"> 
	       <b><?php echo $rG['imgdesc'];?></b><p/>
	           <img id="liR" src="<?php echo $rG['directory'];?>"><br><i>Room id:</i><b><?php echo $rG['roomid'];?>	</b>	
       </li>
   	 	 <?php
   	  }
      ?>
     </ul>
    <?php
     }
     else{
    	echo "No image found!..<p/><p/>";
       }
    ?> 
    <b>People previous reside in this room</b><p/>

    	<ul>
    		 <?php
		//$profile=$itm['profileimages'];
	    $rD=$hcon->getThisMyHouseRoomInquirySender($house_no ,$roomid,$receiverid);
        if ($rD->rowCount()>0)
         {
   	        $rRD=$rD->fetchAll();
			
        foreach ($rRD as $key =>$Dr)
         { 
        ?>
			<li style=" ">
			<?php

      $ownIDC=$Dr['senderid'];
	     $oD=$con->getMyProfileForContract($ownIDC);
         $oN=$oD->fetch();
        echo "<b><small>".$rFN=$oN['fname']." ".$oN['mname']." ".$oN['lname']."</b></small><p>";
	    
                		 $ownIDS=$Dr['receiverid'];
                     $contractid=$Dr['contractid'];
	                    $oD=$con->getMyProfileForContract($ownIDS);
                        $oN=$oD->fetch();
                        echo "<small>Send to:".$oN['lname']."<i>:Posted:".$Dr['postDate']."</i></small><br>".$Dr['inquiry']."<br>"; 
                 
    	      ?>
          </li>
            <?php
           }
    	    ?>
          </ul>
            <?php
    	    if ($post=="Send") 
             {

          			 	$rentorid=$_POST['rentorid'];
          			 	$contractid=$_POST['contractid'];
          			 	$senderid=$_POST['owniD'];
          			 	$mesage=$_POST['message'];
          			 	if(isset($_POST['message']))
                     {
			 	               $G=$hcon->addRoomInquiryPost($house_no,$rentorid,$roomid,$contractid,$senderid,$mesage);
        //print_r($G);
			 	               if ($G->rowCount()>0) 
                             {
			 		                  echo "<font color='blue'>Message sent!..</font>";
			 	                      }
			 	                 else{
			 	                  echo "<font color='red'>Send failed!..</font>";
			 	                    }
			 	             }
			 	             else
                    {
			 	            echo "<font color='red'>Message required!..</font>";
			 	            }
            }
          	   ?>
          	   <sup id="mg"></sup><br/>
               Reply here:
               <section style="width:100%;  vertical-align: text-top;">
                <form id="upload_form" action="getMyQnOnThisRoomDetailIn.php" method="post">

                      <input class="hi" type="hidden" name="owniD"  value="<?php echo $ownID;?>">


                      <input class="hi" type="hidden" name="roomid"  value="<?php echo $roomid;?>">


                      <input class="hi" type="hidden" name="house_no"  value="<?php echo $house_no;?>">
                      <input class="hi" type="hidden" name="contractid"  value="<?php echo $contractid;?>">
                      <input class="hi" type="hidden" name="rentorid"  value="<?php echo  $ownIDC;?>">
                     
                     <textarea id="message" name="message" class="smsbox"></textarea>

                      <input  style="border-radius:8px; width:20%;font-weight:bold; height:30px;margin-top:0px;" type="submit" value="Send" name="post"  >

                 </form>
               </section>
              </details>
    	 
        <?php
    	  
    	 }
    	 else{
    	    echo "<li>No previous reside record!.</li>";
    	  }
    	 

    }
    else
        {
        ?>
            <ul>
    				<li> 
    				 The room not found!..
    				</li>
    			 </ul>
    		   <?php
    		 
     } 
?>
 </ul>
  </td>
  </tr>
</table>
<?php
}
else
{
	?>
 
		Not  yet uploaded house for rent!..
			
	
	<?php
 

} 

}
 else
{
 	 echo "Some thing went wrong while processi the page!..";
}

?>
 <script type="text/javascript"> 
$(document).ready(function() {

  
  $(" #upload_form").on('submit',(function(e){
    // e.preventDefault();  
var message= document.getElementById('message').value;
if (message=="") 
    {
   e.preventDefault();
    document.getElementById('mg').innerHTML="Message is required!..";
    }
    else
    {

    document.getElementById('mg').innerHTML="";
    }
                                                         //TITLE VALIDATION
 
 
 
  })); 
   
}); 
</script>
<?php
 require_once('../footerIns.php');
?>