Jump to content

imfromio

New Members
  • Posts

    2
  • Joined

  • Last visited

Profile Information

  • Gender
    Not Telling

imfromio's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Thanks...but I don't need to create a database table. I'm using the available_main_array to check availability. My problem is the winter season spans two years (i.e. 11/1/09-4/30/10). The code to check that is (I think) where I'm going wrong: function availableArray($date) { global $available_main_array; foreach($available_main_array as $season_array) { $start = $season_array['start']; $end = $season_array['end']; if(strtotime($end)<strtotime($start)) { $end .= ', '.(date('Y')+1); } else { $end .= ', '.date('Y'); } $start .= ', '.date('Y'); if($date>=strtotime($start)&&$date<=strtotime($end)) { return $season_array['schedule']; } Now that it's 2010, this code is saying the available dates during the winter season are 11/1/10-4/30/11. So people trying to book dates on say 2/14/10 get an error...
  2. Hello, I have some code for restaurant reservations that will check to see (among other things) if the restaurant is open that day. I have a schedule of open days: //Restuarant Open Times $available_main_array = array( 'Summer' => array( 'start' => 'May 1', 'end' => 'October 31', 'schedule' => array( 'Sunday' => array( array('17:00','24:00')), 'Monday' => array( array('17:00','24:00')), 'Tuesday' => array( array('17:00','24:00')), 'Wednesday' => array( array('17:00','24:00')), 'Thursday' => array( array('17:00','24:00')), 'Friday' => array( array('17:00','24:00')), 'Saturday' => array( array('17:00','24:00')))), 'Winter' => array( 'start' => 'November 1', 'end' => 'April 30', 'schedule' => array( 'Sunday' => array( array('17:00','24:00')), 'Friday' => array( array('17:00','24:00')), 'Saturday' => array( array('17:00','24:00'))))); And these checks: //Check Database Functions function available($array) { //return array('false',gmdate('g:i a',$array['etime'])); $week_schedule = availableArray($array['date']); $schedule = $week_schedule[date('l',$array['date'])]; if(is_array($schedule)) { foreach($schedule as $timespan) { if(gmdate('H:i',$array['stime'])<$timespan[0]) { return array('false','Sorry, we are not available at your starting time.'); } if(gmdate('H:i',$array['etime']-1)<$timespan[0]) { return array('false','Sorry, you cannot place an online reservation this late at night. Please call 920-854-9070 to place this reservation.'); } } return array('yay'); } else { return array('false','Sorry, we are not available on that day.'); } } function availableArray($date) { global $available_main_array; foreach($available_main_array as $season_array) { $start = $season_array['start']; $end = $season_array['end']; if(strtotime($end)<strtotime($start)) { $end .= ', '.(date('Y')+1); } else { $end .= ', '.date('Y'); } $start .= ', '.date('Y'); if($date>=strtotime($start)&&$date<=strtotime($end)) { return $season_array['schedule']; } } } The problem is, any dates entered from today (in the winter season) until May 1 (the start of the summer season) return the error 'Sorry, we are not available on that day.' So I think the problem is is how I'm advancing the year (in the avaiableArray function) when the winter season goes from say 12/31/09 to 1/1/10. But for the life of me, I can't find the error in the code. Can anyone help?
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.