<?
//*****************************************************************
// CALC AVAILABILITY
//
//*****************************************************************
$outlet_closeday=array();
$outlet_closeday_text="";
// Request for availability: $now_reserved & $now_tables
$query = "SELECT * FROM outlets WHERE outlet_id=$reservation_outlet_id";
$result = mysql_query($query);
// *** Read out Capacity
while($row = mysql_fetch_object($result)) {
$outlet_max_capacity= $row->outlet_max_capacity;
$outlet_max_tables= $row->outlet_max_tables;
$outlet_closeday_text= $row->outlet_closeday;
}
$closeday = explode (",",$outlet_closeday_text);
// *** Define day off
for ($i=0; $i < count($closeday); $i++) {
if ($closeday[$i] == $closeday_today && $closeday[$i]!=""){
$now_full=1;
}
}
/*foreach ($outlet_closeday as $closeday) {
if ((int)$closeday == (int)$closeday_today && $closeday!=""){
$now_full=1;
}
}*/
// ***** Change Capacity *****
// ********************************
//
$outlet_new_capacity=0;
$outlet_new_tables=0;
$query = "SELECT * FROM maitre WHERE maitre_outlet_id=$reservation_outlet_id AND maitre_date='".$booking_date."'";
$result = mysql_query($query) or die (mysql_error());
while($row = mysql_fetch_object($result)) {
$outlet_new_capacity=$row->outlet_child_capacity;
$outlet_new_tables=$row->outlet_child_tables;
}
$outlet_max_capacity= $outlet_max_capacity+$outlet_new_capacity;
$outlet_max_tables= $outlet_max_tables+$outlet_new_tables;
$mysqlabfr = "SELECT SUM(reservation_pax) FROM reservations WHERE reservation_wait=0 AND reservation_hidden=0 AND reservation_outlet_id=".$reservation_outlet_id." AND reservation_date='".$booking_date."'";
$mysqlerg = mysql_query($mysqlabfr) or die (mysql_error());
$now_reserved=mysql_result($mysqlerg,0);
$mysqlabfr2 = "SELECT COUNT(reservation_pax) FROM reservations WHERE reservation_wait=0 AND reservation_hidden=0 AND reservation_outlet_id=".$reservation_outlet_id." AND reservation_date='".$booking_date."'";
$mysqlerg2 = mysql_query($mysqlabfr2) or die (mysql_error());
$now_tables= mysql_result($mysqlerg2,0);
// Last Table 1 pax >> make 2 pax
if ($outlet_max_capacity-$now_reserved===1 AND $now_tables<$outlet_max_tables){
$now_reserved--;
}
// Add to reservation the actual added if it is a new reservation
$now_reserved=$now_reserved+$reservation_pax;
$now_tables=$now_tables++;
//Request if full or not
//$now_full is the value which is stored in reservation_wait
if ($now_reserved>=$outlet_max_capacity || $now_tables>=$outlet_max_tables){
$now_full=1; }
//
// ********************************
?>