<?php

require_once("../head2Alts.php");
if(isset($_POST["submit"])){

$post =$_POST["submit"];
}

if(isset($_POST["post"])){
  
$post =$_POST["post"];
}
  $ownID=$_POST['owniD'];

  /////// EXECUTE BY DEFAULTS////
//echo $post;
     $email=""; 

     $phoneno=""; 
  
     $ownerid=""; 

     $pobox="";

     $street="";

     $ward="";

     $district="";

     $accountId="";

     $region="";

     $country="";

     $cduration="";
 
     $distancerm="";

     $rnumber="";
    
     $hnumber="";
 

     $finishD="";

     $hcost="";

     $tcondition="";

     $popularDistination="";

     $hname="";

     $currency="";
/////////
////////  
if($post=="Submit")
{
  
     $category=$_POST["category"];
  
     $ownerid=$_POST['ownerid'];
  
     $email=$_POST['email']; 

     $phoneno=$_POST['phoneno']; 

      $tcondition=$_POST['tcondition'];

     $street=$_POST['street'];

     $ward=$_POST['ward'];

     $district=$_POST['district'];

     $region=$_POST['region']; 

     $country=$_POST['country'];

     $cduration=$_POST['cduration'];

     $distancerm=$_POST['distancerm'];

     $rnumber=$_POST['rnumber'];
    
     $hnumber=$_POST['hnumber'];

    $finishD=$_POST['finishD'];

     $hcost=$_POST['hcost'];

     $popularDistination=$_POST['popularDistination'];

     $hname=$_POST['hname'];

     $currency=$_POST["currency"];

     $accountId=$_POST['ownerid'];
      
   
     
   if(!$hcon->vcduration($cduration) ||  !$hcon->vCategory($category) ||  !$hcon->vTcondition($tcondition) ||  !$hcon->vOwnerid($ownerid) ||  !$hcon->vRnumber($rnumber) ||  !$hcon->vHcost($hcost,$currency) ||  !$hcon->vDistancerm($distancerm) || !$hcon->vHnumber($hnumber)|| !$hcon->vFinishD($finishD) || !$hcon->vPopularDistination($popularDistination) || !$hcon->vStreet($street) || !$hcon->vHname($hname) || !$hcon->vWard($ward) || !$hcon->vDistrict($district) || !$hcon->vRegion($region) || !$hcon->vCountry($country) || !$hcon->vPhoneno($phoneno) || !$hcon->vEmail($email))
         
      {
         // echo $post;
      ?><center><font color="red" ><section style="background-color:silver;width:50%;align-content: left;">

    <?php
     echo $hcon->eCategory($category)."<p/>";
     echo $hcon->ecduration($cduration)."<p/>";
     echo $hcon->eHcost($hcost,$currency)."<p//>";
     echo $hcon->eDistancerm($distancerm)."<p//>";
     echo $hcon->eHnumber($hnumber)."<p//>";
     echo $hcon->eRnumber($rnumber)."<p//>";
     echo $hcon->eFinishD($finishD)."<p//>";
     echo $hcon->eOwnerid($ownerid)."<p//>";
     echo $hcon->ePopularDistination($popularDistination)."<p//>";
     echo $hcon->eStreet($street)."<p//>";
     echo $hcon->eTcondition($tcondition)."<p//>";
     echo $hcon->eHname($hname)."<p//>";
     echo $hcon->eWard($ward)."<p//>";
     echo $hcon->eDistrict($district)."<p//>";
     echo $hcon->eRegion($region)."<p//>";
     echo $hcon->eCountry($country)."<p//>";
     echo $hcon->ePhoneno($phoneno)."<p//>";
     echo $hcon->eEmail($email)."<p//>";
?></section> </font></center><?php
        require("houseRegForm.php");
      }
   else
      {
       if(isset($_POST['owniD']))
           { 
         $OW =$con->checkIdOfemployyeeExist($accountId);
           if($OW->rowCount()<=0)
        {
        ?>
      <center><font color="red" ><section style="background-color:silver;width:50%;align-content: left;">
        <?php
          echo $accountId="User with Id ".$ownerid." not exist!..";

         ?>
  
      </section> </font></center>
     <?php
            require("houseRegForm.php");
        }
  else{
echo $OW->rowCount();
     //require("houseRegForm.php");
echo $hcon->RegisterHouse($hnumber,$ownerid,$hname,$cduration,$category,$email,$phoneno,$country,$region,$district,$ward,$street,$popularDistination,$rnumber,$distancerm,$tcondition,$hcost,$currency,$finishD);

     }
            
     

       //require("successEditHotelProfileForm.php");
           }
      }

 
     }/*
else 

!$hcon->vHcost($hcost) ||  !$hcon->vDistancerm($distancerm) || !$hcon->vHnumber($hnumber)|| !$hcon->vFinishD($finishD) || !$hcon->vPopularDistination($popularDistination) || !$hcon->vStreet($street) || !$hcon->vHname($hname) || !$hcon->vWard($ward) || !$hcon->vDistrict($district) || !$hcon->vRegion($region) || !$hcon->vCountry($country) || !$hcon->vPhoneno($phoneno) || !$hcon->vEmail($email))

     {
  echo "Error occured when saving data!..";
     }*/

     if($post=="House for rent"){

      require("houseRegForm.php");

// $house_no= 'house_no'; 
//require("uploadHouseImageForm.php");
      }
   
 require_once('../footerIns.php');
?>