<?php
include("../public/impOpreation.php");
$do = $_GET['do'];
$today = date("Y-m-d H:i:s");
$date = date("Y-m-d");
if (empty($do)) {  
    $smarty->display("header.html");
    $smarty->display("realestateunitsalertsemptysview/show.html");
    $smarty->display("footer.html");
} else if ($do == "getdata") { 
    $realestateid = filter_input(INPUT_POST, 'realestateid');  
    $realestateunitid = filter_input(INPUT_POST, 'realestateunitid');
    $searchQuery = '';
    $searchQuery2 = '';
    if($realestateid != ''){
       $searchQuery .=' and realestates.id  = ' . $realestateid . ' ';
    }

    if($realestateunitid != ''){
       $searchQuery2 .=' and realestatesunits.id  = ' . $realestateunitid . ' ';
    }
    $srealestates = R::findAll('realestates', "where del < 2 and realestates.savaible = 0 $searchQuery ");
    $crealestates = R::findAll('realestates', "where del < 2  $searchQuery ");
    foreach($crealestates as $crealestate){
      $realestatesunits = R::findAll('realestatesunits',"realestateid = $crealestate->id and realestatesunits.cavaible = 0 and del < 2  $searchQuery2");
      $crealestate->realestatesunits = $realestatesunits;
    }
    $smarty->assign('srealestates', $srealestates);
    $smarty->assign('crealestates', $crealestates);
    $smarty->display("realestateunitsalertsemptysview/getdata.html");  
}
?>