public function getReservationsByDate($start, $end) { $result = array(); if ($this->model->getId() > 0) { $sql = sprintf(" SELECT distinct r.src_id FROM `object_relations_11` r join object_query_11 o on o.oo_id=r.src_id WHERE r.`dest_id` = '%d' AND o.`start`>= '%e' AND o.`start`<= '%f' AND r.`fieldname` = 'serving' ", $this->model->getId(), $start, $end); $data = $this->db->FetchAll($sql); } foreach ($data as $key => $row) { $loc = \Object\Reservation::getById($row["src_id"]); if ($loc instanceof \Object\Reservation) { $result[] = $loc; } } return $result; }
public function replace($data = array()) { try { if ($this->model->getId() > 0) { $object = $this->model; } elseif ($data['id'] > 0 and $data['id'] != "") { $object = \Object\Reservation::getById($data['id']); } elseif ($data['o_id'] > 0 and $data['o_id'] != "") { $object = \Object\Reservation::getById($data['o_id']); } else { $object = $this->model; $date = new \Zend_Date(); $object->setCreationDate($date->get()); $object->setUserOwner(1); $object->setUserModification(1); if (method_exists($object, "setDateregister")) { $object->setDateregister($date->get()); } $object->setPublished(1); } if ($object instanceof \Object\Reservation) { $object->setValues($data); $date = new \Zend_Date(); $object->setModificationDate($date); if (!$object->getO_key()) { $folder = $this->getFolderDay(); $object->setParent($folder); $key1 = $this->model->getClassName(); $numero = $date->get(\Zend_Date::TIMESTAMP); $object_key = $this->correctClassname($key1) . '-' . $numero; $object->setO_key(strtolower($object_key)); } return $object; } else { \Logger::warning("Erreur : Classe de l'objet erronnée"); return false; } } catch (\Exception $e) { \Logger::warning($e->getMessage()); return false; } }
/** * update */ public function update() { $res = new Reponse(); $data = $this->requete->params; if ($this->person) { $data['person'] = $this->person; } $formattedData = \Object\Reservation::formatData($data); $reservation = Object\Reservation::getById($data['id']); if ($reservation instanceof Object\Reservation) { $reservation->setValues($formattedData); $reservation->save(); $res->data = $reservation->toArray(); $res->success = true; $res->message = "TXT_UPDATE_OK"; $res->debug = $formattedData; } else { $res->data = $this->requete->params; $res->success = false; $res->message = "TXT_UPDATE_ERROR"; } return $res; }
/** * create */ public function create() { $res = new Reponse(); $data = $this->requete->params; $rec = new \Object\Reservation(); $formattedData = \Object\Reservation::formatData($data); $result = $rec->updateData($formattedData); if ($result instanceof \Object\Reservation) { $res->success = true; $res->message = "TXT_CREATE_OK"; $res->data = $result; $res->debug = $formattedData; } else { $res->message = "TXT_CREATE_ERROR"; $res->data = $result; $res->debug = $formattedData; } return $res; }