Problems in find() Cakephp

Asked

Viewed 16 times

1

Good afternoon, I’m making one find() to check if in the period chosen by the user the feature he will use is available, the only problem I found in it was that if I have an event at 10:00 to 15:00 using a dell projector, and another user tries to create another event at 09:00 to 15:00 of the same day, it allows the creation of the event. If it tries the same time it shows that the feature is not available, or that it starts after and ends after it works perfectly it just doesn’t work when the event is before an already registered.

public function getRecursosMesmaData($evento)
{
    $start = $evento['Agenda']['start'];
    $end = $evento['Agenda']['end'];

    $eventos = $this->Agenda->find('all', ['conditions' => ['OR' => ['AND' =>['Agenda.start >=' => $start,'Agenda.start <=' => $end],'AND' =>['Agenda.end >=' => $start,'Agenda.end <=' => $end],]],]);
    if ($eventos) {
        foreach ($eventos as $dado) {
            if ($dado['Agenda']['id_recurso'] == $evento['Agenda']['id_recurso']) {
                return true;
            }
        }
    }
    return false;
}
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.