Hi,
I have been poking around the code in order to allow same day reservation. So far I got it working but of course, it opens another problem.
So the solution goes as follows:
In TastyIgniter\extensions\reservation_module\controllers\Reservation_module.php I changed the following lines
[php]public function _validate_date($str) {
if (strtotime($str) < time()) {
$this->form_validation->set_message('_validate_date', $this->lang->line('error_invalid_date'));
return FALSE;
} else {
return TRUE;
}
}[/php]
For those
[php]public function _validate_date($str) {
if (strtotime($str) >= strtotime(date("Y/m/d"))) {
$reserve_date = strtotime(urldecode($str)); //For keeping the reserve_date alive for the time validation
return TRUE;
} else {
$this->form_validation->set_message('_validate_date', $this->lang->line('error_invalid_date'));
return FALSE;
}
}[/php]
Now I have same day reservation. But, I figured that I needed to make sure that it was past the current time... So, I also mdifyed the time validation process as such:
[php]public function _validate_time($str) {
if (!empty($str)) {
$reserve_time = strtotime(urldecode($str));
if ($hour = $this->Locations_model->getOpeningHourByDay(urldecode($this->input->get('location')), $this->input->get('reserve_date'))) {
if ($hour['status'] === '1' AND (strtotime($hour['open']) <= $reserve_time AND strtotime($hour['close']) >= $reserve_time)
// My non working code
AND if( $reserve_date = strtotime(date("Y/m/d")) || $reserve_time > strtotime(date("h:i:sa")))
//
) {
return TRUE;
}
}
$this->form_validation->set_message('_validate_time', $this->lang->line('error_invalid_time'));
return FALSE;[/php]
To make sure that the reservation hour was past current time, but only for today (in prior attempts, I made it impossible to book anything before the current time regardless of the date chosen...).
Unfortunately, my code does not work. The logic seems right, if today (and only today), then make sure the reserve time is after now.
But that does not work.
Any ideas ?