private function storeLocation() { if ($this->mySessionSite->selectedLocation) { \Zend_Registry::set("selectedLocation", $this->mySessionSite->selectedLocation); } if ($this->_getParam("selectedLocationId")) { $location = \Object\Location::getById($this->_getParam("selectedLocationId")); \Zend_Registry::set("selectedLocation", $location); $this->mySessionSite->selectedLocation = $location; } if (\Zend_Registry::isRegistered("selectedLocation")) { $location = \Zend_Registry::get("selectedLocation"); } else { $location = $this->societe->getDefaultLocation(); \Zend_Registry::set("selectedLocation", $location); } if ($this->person->getPermits() == 2) { $this->view->selectedLocation = $this->selectedLocation = $this->person->getLocation(); } else { if ($location->getSociete()->getName() == $this->person->getSociete()->getName()) { $this->view->selectedLocation = $this->selectedLocation = $location; } else { $locations = $this->person->getSociete()->getLocations(); $this->view->selectedLocation = $this->selectedLocation = $locations[0]; } } }
public function getDefaultLocation() { $loc = false; if ($this->model->getId() > 0) { $sql = sprintf(" SELECT distinct r.src_id FROM `object_relations_9` r join object_query_9 o on o.oo_id=r.src_id WHERE r.`dest_id` = '%d' AND r.`fieldname` = 'societe' ", $this->model->getId()); $row = $this->db->FetchRow($sql); $loc = \Object\Location::getById($row["src_id"]); } return $loc; }
public function locationSetupAction() { $societe = $this->societe; if ($this->person->getPermits() != 1) { $this->_forward('error', 'booking', null, array('error' => 'TXT_NO_ACCESS_SCREEN')); } //GET SELECTEDLOCATION if ($this->getParam('selectedLocationId')) { $locationid = $this->getParam('selectedLocationId'); } else { die("you need to specify a location"); } $mylocation = \Object\Location::getById($locationid, 1); if ($mylocation instanceof \Object\Location) { //CHEK IF AUTHORISATION if (!in_array($mylocation, $societe->getLocations())) { $this->_forward('error', 'booking', null, array('error' => 'TXT_NO_ACCESS_LOCATION')); } $mylocationarray = $mylocation->toArray(); foreach ($mylocationarray as $key => $val) { if ($key == "geolocalisation") { if ($val instanceof \Pimcore\Model\Object\Data\Geopoint) { $this->view->lat = $val->getLatitude(); } else { $this->view->lat = 2; } } if ($key == "geolocalisation") { if ($val instanceof \Pimcore\Model\Object\Data\Geopoint) { $this->view->long = $val->getLongitude(); } else { $this->view->long = 48; } } $this->view->{$key} = $val; } } else { die("Incorrect location"); } $this->layout()->setLayout('portal'); $this->view->headScript()->appendFile(PIMCORE_WEBSITE_LAYOUTS . '/assets/plugins/gmaps/gmaps.js'); $this->view->headScript()->appendFile(PIMCORE_WEBSITE_LAYOUTS . '/assets/js/locationform-validation.js'); $this->view->headScript()->appendFile(PIMCORE_WEBSITE_LAYOUTS . '/assets/js/locationform-geolocation.js'); $this->view->headScript()->appendFile(PIMCORE_WEBSITE_LAYOUTS . '/assets/js/timepicker-form-elements.js'); $this->view->headScript()->appendFile(PIMCORE_WEBSITE_LAYOUTS . '/assets/plugins/autosize/jquery.autosize.min.js'); $this->view->inlineScript()->appendScript('jQuery(document).ready(function() { Maps.init(); Main.init(); TimePickerFormElements.init(); LocationFormValidator.init(); SVExamples.init(); PagesUserProfile.init(); });', 'text/javascript', array('noescape' => true)); }
private function storeLocation() { if ($this->mySessionSite->selectedLocation) { \Zend_Registry::set("selectedLocation", $this->mySessionSite->selectedLocation); } if ($this->_getParam("selectedLocationId")) { $location = \Object\Location::getById($this->_getParam("selectedLocationId")); \Zend_Registry::set("selectedLocation", $location); $this->mySessionSite->selectedLocation = $location; } if (\Zend_Registry::isRegistered("selectedLocation")) { $location = \Zend_Registry::get("selectedLocation"); } else { $location = $this->societe->getDefaultLocation(); \Zend_Registry::set("selectedLocation", $location); } if ($this->person->getPermits() == 2) { $this->view->selectedLocation = $this->selectedLocation = $this->person->getLocation(); } elseif ($this->person->getPermits() == 3) { $accesslocationsidarray = explode('|', $this->person->getAccesslocations()); $locations = array(); foreach ($accesslocationsidarray as $accesslocationid) { $locationitem = \Object\Location::getById($accesslocationid); if ($locationitem instanceof \Object\Location) { array_push($locations, $locationitem); } } $this->view->locations = $locations; $this->view->accesslocationsidarray = $accesslocationsidarray; if (in_array($location, $locations)) { $this->view->selectedLocation = $this->selectedLocation = $location; } } else { if ($location->getSociete()->getName() == $this->person->getSociete()->getName()) { $this->view->selectedLocation = $this->selectedLocation = $location; } else { $locations = $this->person->getSociete()->getLocations(); $this->view->selectedLocation = $this->selectedLocation = $locations[0]; } } }
public function formatData($data) { $date = \Zend_Date::now(); $timestart = new \Zend_Date($data['calendar'] . ' ' . $data['slotinput'] . ':00', 'dd-MM-YYYY HH:mm:ss'); //$timestart = \Zend_Date::now(); $location = \Object\Location::getById($data['locationid'], 1); if ($location instanceof \Object\Location) { $societe = $location->getSociete(); $serving = \Object\Serving::getById($data['servinginput'], 1); if ($serving instanceof \Object\Serving) { $mealduration = $serving->getMealduration(); } $end = $timestart->getTimestamp() + $mealduration * 60; $timeend = new \Zend_Date($end); $guest = \Object\Guest::getByEmail($data['email'], 1); if (!$guest instanceof \Object\Guest) { $guest = new \Object\Guest(); $guest->updateData(array('tel' => $data['tel'], 'email' => $data['email'], 'lastname' => $data['lastname'], 'societe' => $societe, 'dateregister' => $date, 'location' => $location)); } } $result = array(); $result['id'] = $data['id']; $result['method'] = $data['method']; $result['tel'] = $data['tel']; $result['email'] = $data['email']; $result['lastname'] = $data['lastname']; $result['partysize'] = $data['partysize']; $result['person'] = $data['person']; $result['societe'] = $societe; $result['location'] = $location; $result['guest'] = $guest; $result['serving'] = $serving; $result['start'] = $timestart; $result['datereservation'] = $timestart; $result['end'] = $timeend; return $result; }
public function locationsListAction() { //get societe/location and serving $reponse = new Reponse(); $societe = $this->societe; $locations = $societe->getLocations(); //we check if we are in the Editor if ($_POST['action']) { //if REMOVE if ($_POST['action'] == "remove") { foreach ($_POST['id'] as $id) { $location = \Object_Location::getById($id, 1); if ($location instanceof Object\Location) { $location->delete(); } } $reponse->message = 'TXT_RESERVATION_LIST'; $reponse->success = true; $reponse->data = ''; } //if EDIT if ($_POST['action'] == "edit") { $location = \Object\Location::getById($_POST['id'], 1); if ($location instanceof \Object\Location) { $location->setName($_POST['data']['name']); $location->setMaxSeats($_POST['data']['maxSeats']); $location->setMaxTables($_POST['data']['maxTables']); $location->setResaUnit($_POST['data']['resaUnit']); $location->setMaxResaPerUnit($_POST['data']['maxResaPerUnit']); $location->save(); } $data = $_POST['data']; $data['DT_RowId'] = "row_" . $_POST['data']['id']; $reponse->message = 'TXT_RESERVATION_LIST'; $reponse->success = true; $reponse->row = $data; } //if CREATE if ($_POST['action'] == "create") { $societe = $this->societe; //SET DEFAULT DATA FROM SOCIETE $row['address'] = $societe->getAddress(); $row['zip'] = $societe->getZip(); $row['city'] = $societe->getCity(); $row['email'] = $societe->getEmail(); $row['tel'] = $societe->getTel(); $row['fax'] = $societe->getFax(); $row['email'] = $societe->getEmail(); $row['maxSeats'] = $societe->getMaxSeats(); $row['maxTables'] = $societe->getMaxTables(); $row['maxResaPerUnit'] = $societe->getMaxResaPerUnit(); $row['mealduration'] = $societe->getMealduration(); $row['resaUnit'] = $societe->getResaUnit(); $row['description'] = $societe->getDescription(); //COLECT DATA FROM DATATABLE EDITOR $row['name'] = $_POST['data']['name']; //CREATE THE LOCATION $result = $societe->createLocation($row); if ($result instanceof \Object\Location) { //CREATE NEW SERVING $newserving['title'] = 'Nouveau Service'; $newserving['maxseats'] = $societe->getMaxSeats(); $newserving['maxtables'] = $societe->getMaxTables(); $newserving['mealduration'] = $societe->getMealduration(); $serving = $result->createServing($newserving); $row['DT_RowId'] = $result->getId(); $row['id'] = $result->getId(); $reponse->success = true; $reponse->message = "TXT_CREATE_OK"; $reponse->row = $row; $reponse->debug = $data; } else { $reponse->success = false; $reponse->message = "TXT_CREATE_ERROR"; $reponse->row = $result; $reponse->debug = $result; } } } else { $data = array(); foreach ($locations as $key => $location) { $i++; $array = array(); $array = $location->toArray(); $servingarray = array(); foreach ($location->getServings() as $serving) { array_push($servingarray, $serving->getTitle() . '----' . $serving->getId()); } $array['servings'] = implode('____', $servingarray); $array['id'] = $location->getId(); $array['DT_RowId'] = $location->getId(); array_push($data, $array); } $reponse->message = 'TXT_RESERVATION_LIST'; $reponse->success = true; $reponse->data = $data; } $this->render($reponse); }
public function formatData($data) { $data['tel'] = preg_replace("/[^0-9]/", "", $data['tel']); if ($data['datereservation']) { $datereservation = self::parseDateTime($data['datereservation'], 'dd-MM-YYYY'); $start = self::parseDateTime($data['reservationdate'] . ' ' . $data['start'], 'dd-MM-YYYY HH:mm'); if ($data['arrived'] == 1) { $actualstart = self::parseDateTime($data['reservationdate'] . ' ' . $data['start'], 'dd-MM-YYYY HH:mm'); } } else { $chosenresa = Object\Reservation::getById($data['id'], 1); $chosenday = $chosenresa->getStart()->get('dd-MM-YYYY'); $start = self::parseDateTime($chosenday . ' ' . $data['start'], 'dd-MM-YYYY HH:mm'); if ($data['arrived'] == 1) { $actualstart = self::parseDateTime($data['reservationdate'] . ' ' . $data['start'], 'dd-MM-YYYY HH:mm'); } } if ($data['arrived'] == 1) { $data['actualpartysize'] = $data['partysize']; $data['actualstart'] = $data['start']; } $location = \Object\Location::getById($data['locationid'], 1); if ($location instanceof \Object\Location) { $societe = $location->getSociete(); $serving = \Object\Serving::getById($data['servinginput'], 1); if ($serving instanceof \Object\Serving) { $mealduration = $serving->getMealduration(); } $end = new \Zend_date($start->getTimeStamp() + $mealduration * 60); if ($data['tel']) { $guest = \Object\Guest::getByTel($data['tel'], 1); if (!$guest instanceof \Object\Guest) { $guest = new \Object\Guest(); $guest->updateData(array('tel' => $data['tel'], 'email' => $data['email'], 'lastname' => $data['lastname'], 'societe' => $societe, 'dateregister' => $date, 'location' => $location, 'bookingnotes' => $data['bookingnotes'], 'countrycode' => $data['countrycode'])); } } } $result = array(); $result['id'] = $data['id']; $result['method'] = $data['method']; $result['tel'] = $data['tel']; $result['countrycode'] = $data['countrycode']; $result['email'] = $data['email']; $result['lastname'] = $data['lastname']; $result['actualpartysize'] = $data['actualpartysize']; $result['partysize'] = $data['partysize']; $result['status'] = $data['status']; $result['arrived'] = $data['arrived']; $result['person'] = $data['person']; $result['societe'] = $societe; $result['location'] = $location; $result['guest'] = $guest; $result['serving'] = $serving; $result['actualstart'] = $actualstart; $result['start'] = $start; $result['datereservation'] = $datereservation; $result['end'] = $end; $result['bookingref'] = $data['bookingref']; $result['bookingnotes'] = $data['bookingnotes']; 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\Location::getById($data['id']); } elseif ($data['o_id'] > 0 and $data['o_id'] != "") { $object = \Object\Location::getById($data['o_id']); } else { $object = $this->model; $date = new \Zend_Date(); $object->setCreationDate($date->get()); //todo $object->setUserOwner(1); $object->setUserModification(1); if (method_exists($object, "setDateRegister")) { $object->setDateRegister($date->get()); } $object->setPublished(1); } if ($object instanceof \Object\Location) { $object->setValues($data); $date = new \Zend_Date(); $object->setModificationDate($date); if (!$object->getO_key()) { $folder = $this->getFolderRoot(); $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; } }
public function servingListAction() { $reponse = new Reponse(); $locationid = $this->getParam('locationid'); $location = \Object\Location::getById($locationid, 1); if ($location instanceof \Object\Location) { $servings = $location->getServings(); if ($_POST['action']) { //if REMOVE if ($_POST['action'] == "remove") { foreach ($_POST['id'] as $id) { $serving = \Object\Serving::getById($id, 1); if ($serving instanceof \Object\Serving) { $serving->delete(); } } $reponse->message = 'TXT_RESERVATION_LIST'; $reponse->success = true; $reponse->data = ''; } //if EDIT if ($_POST['action'] == "edit") { $serving = \Object\Serving::getById($_POST['id'], 1); if ($serving instanceof \Object\Serving) { $serving->setTitle($_POST['data']['title']); $serving->setMaxSeats($_POST['data']['maxseats']); $serving->setMaxTables($_POST['data']['maxtables']); $serving->setMealduration($_POST['data']['mealduration']); $serving->save(); } $data = $_POST['data']; $data['DT_RowId'] = "row_" . $_POST['data']['id']; $reponse->message = 'TXT_SERVING_LIST'; $reponse->success = true; $reponse->row = $data; } //if CREATE if ($_POST['action'] == "create") { //SET DEFAULT DATA FROM LOCATION $row['maxseats'] = $location->getMaxSeats(); $row['maxseatsmonday'] = $location->getMaxSeats(); $row['maxseatstuesday'] = $location->getMaxSeats(); $row['maxseatswednesday'] = $location->getMaxSeats(); $row['maxseatsthursday'] = $location->getMaxSeats(); $row['maxseatsfriday'] = $location->getMaxSeats(); $row['maxseatssaturday'] = $location->getMaxSeats(); $row['maxseatssunday'] = $location->getMaxSeats(); $row['maxtables'] = $location->getMaxTables(); $row['maxtablesmonday'] = $location->getMaxTables(); $row['maxtablestuesday'] = $location->getMaxTables(); $row['maxtableswednesday'] = $location->getMaxTables(); $row['maxtablesthursday'] = $location->getMaxTables(); $row['maxtablesfriday'] = $location->getMaxTables(); $row['maxtablessaturday'] = $location->getMaxTables(); $row['maxtablessunday'] = $location->getMaxTables(); $row['mealduration'] = $location->getMealduration(); //COLECT DATA FROM DATATABLE EDITOR $row['title'] = $_POST['data']['title']; $result = $location->createServing($row); if ($result instanceof \Object\Serving) { $row['DT_RowId'] = $result->getId(); $row['id'] = $result->getId(); $reponse->success = true; $reponse->message = "TXT_CREATE_OK"; $reponse->row = $row; $reponse->debug = $data; } else { $reponse->success = false; $reponse->message = "TXT_CREATE_ERROR"; $reponse->row = $result; $reponse->debug = $result; } } } else { $data = array(); foreach ($servings as $key => $serving) { $i++; $array = array(); $array = $serving->toArray(); $array['id'] = $serving->getId(); $array['DT_RowId'] = $serving->getId(); array_push($data, $array); } $reponse->message = 'TXT_SERVING_LIST'; $reponse->success = true; $reponse->data = $data; } } else { $reponse->message = 'TXT_SERVING_LIST'; $reponse->success = false; $reponse->data = $data; } $this->render($reponse); }
public function tableListAction() { $reponse = new Reponse(); $locationid = $this->getParam('locationid'); $location = \Object\Location::getById($locationid, 1); if (!$location instanceof \Object\Location) { $location = $this->selectedLocation; } if ($location instanceof \Object\Location) { $tables = $location->getTables(); if ($_GET['action'] == "resatable") { $data = array(); $resaid = $this->getParam('reservationid'); $resa = Object\Reservation::getById($resaid, 1); //echo $resa->getStart()->getTimestamp(); echo "===="; //echo $resa->getEnd()->getTimestamp(); echo "===="; if ($resa instanceof Object\Reservation) { $reservations = $this->selectedLocation->getResource()->getReservationsByDateForTables($resa->getStart()->getTimestamp(), $resa->getEnd()->getTimestamp(), $resa->getStart()->getTimestamp(), $resa->getEnd()->getTimestamp()); $bookedtables = array(); $completetables = array(); foreach ($reservations as $reservation) { //if( $reservation->getTable() ){ //echo $reservation->getStart()->getTimestamp();echo "////"; foreach ($reservation->getTable() as $table) { $bookedtables[$reservation->getId()] = $table->getId(); } //} } //exit; foreach ($tables as $key => $table) { $i++; $array = array(); $array = $table->toArray(); $key = array_search($table->getId(), $bookedtables); if ($key !== false) { $array['booked'] = 'yes'; $array['reservationid'] = $key; } else { $array['booked'] = 'no'; $array['reservationid'] = 0; } $array['id'] = $table->getId(); $array['DT_RowId'] = $table->getId(); array_push($data, $array); array_push($completetables, $table->getId()); } // var_dump($bookedtables); echo "---------------------"; // var_dump($completetables); echo "////////////////////"; // var_dump(array_diff($completetables,$bookedtables)); echo "====================="; // var_dump($data); exit; $reponse->message = 'TXT_TABLE_LIST'; $reponse->success = true; $reponse->data = $data; } } else { if ($_POST['action']) { //if REMOVE if ($_POST['action'] == "remove") { foreach ($_POST['id'] as $id) { $table = \Object\Table::getById($id, 1); if ($table instanceof \Object\Table) { $table->delete(); } } $reponse->message = 'TXT_TABLE_LIST'; $reponse->success = true; $reponse->data = ''; } //if EDIT if ($_POST['action'] == "edit") { $table = \Object\Table::getById($_POST['id'], 1); if ($table instanceof \Object\Table) { $table->setSalle($_POST['data']['salle']); $table->setTable($_POST['data']['table']); $table->setSeats($_POST['data']['seats']); $table->setDescription($_POST['data']['description']); $table->save(); } $data = $_POST['data']; $data['DT_RowId'] = "row_" . $_POST['data']['id']; $reponse->message = 'TXT_TABLE_LIST'; $reponse->success = true; $reponse->row = $data; } //if CREATE if ($_POST['action'] == "create") { //SET DEFAULT DATA FROM LOCATION $row['salle'] = $_POST['data']['salle']; $row['table'] = $_POST['data']['table']; $row['seats'] = $_POST['data']['seats']; $row['description'] = $_POST['data']['description']; if ($this->selectedLocation->getResource()->checkTable($row['salle'], $row['table'])) { $error['table'] = "table"; $error['status'] = "Table already exists"; $reponse->error = "Table already exists/Cette table existe déjà"; $reponse->success = false; $reponse->message = "TXT_CREATE_ERROR"; $reponse->row = $result; $reponse->debug = $result; } else { $result = $location->createTable($row); if ($result instanceof \Object\Table) { $row['DT_RowId'] = $result->getId(); $row['id'] = $result->getId(); $row['locationid'] = $result->getLocation()->getId(); $row['locationname'] = $result->getLocation()->getName(); $reponse->success = true; $reponse->message = "TXT_CREATE_OK"; $reponse->row = $row; $reponse->debug = $data; } else { $reponse->success = false; $reponse->message = "TXT_CREATE_ERROR"; $reponse->row = $result; $reponse->debug = $result; } } } } else { $data = array(); foreach ($tables as $key => $table) { $i++; $array = array(); $array = $table->toArray(); $array['id'] = $table->getId(); $array['DT_RowId'] = $table->getId(); array_push($data, $array); } $reponse->message = 'TXT_TABLE_LIST'; $reponse->success = true; $reponse->data = $data; } } } else { $reponse->message = 'TXT_TABLE_LIST'; $reponse->success = false; $reponse->data = $data; } $this->render($reponse); }