public function personsListAction() { //get societe/location and serving $reponse = new Reponse(); $societe = $this->societe; $persons = $societe->getPersons(); //we check if we are in the Editor if ($_POST['action']) { //if REMOVE if ($_POST['action'] == "remove") { foreach ($_POST['id'] as $id) { $person = Object_Person::getById($id, 1); if ($person instanceof \Object\Person) { $person->delete(); } } $reponse->message = 'TXT_RESERVATION_LIST'; $reponse->success = true; $reponse->data = ''; } //if EDIT if ($_POST['action'] == "edit") { $person = \Object\Person::getById($_POST['id']); if ($person instanceof Object_Person) { $person->setFirstname($_POST['data']['firstname']); $person->setLastname($_POST['data']['lastname']); $person->setEmail($_POST['data']['email']); $person->setPhone($_POST['data']['phone']); $person->setPermits($_POST['data']['permits']); $location = Object\Location::getById($_POST['data']['locationid'], 1); $person->setLocation($location); $person->setPassword(md5($_POST['data']['password'])); $person->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") { $row['firstname'] = $_POST['data']['firstname']; $row['lastname'] = $_POST['data']['lastname']; $row['email'] = $_POST['data']['email']; $row['phone'] = $_POST['data']['phone']; $row['permits'] = $_POST['data']['permits']; $location = Object\Location::getById($_POST['data']['locationid'], 1); $row['location'] = $location; $row['password'] = md5($_POST['data']['password']); $current = Object\Person::getByEmail($row['email'], 1); if ($current instanceof Object\Person) { $error['name'] = "email"; $error['status'] = "Email already exists"; $reponse->fieldErrors = array($error); } else { $result = $societe->createPerson($row); if ($result instanceof \Object\Person) { $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 ($persons as $key => $person) { $i++; $array = array(); $array = $person->toArray(); $array['id'] = $person->getId(); $array['DT_RowId'] = $person->getId(); array_push($data, $array); } $reponse->message = 'TXT_RESERVATION_LIST'; $reponse->success = true; $reponse->data = $data; } $this->render($reponse); }
public function sendConfirmation($array) { $email = $array['email']; $sellocation = Object\Location::getById($array['locationid'], 1); $parameters = array('bookingref' => $array['id'], 'partysize' => $array['partysize'], 'serving' => $array['servingtitle'], 'location' => $array['locationname'], 'date' => $array['start']->get('dd-MM-YYYY'), 'slot' => $array['start']->get('HH:mm'), 'locationaddress' => $sellocation->getAddress(), 'locationzip' => $sellocation->getZip(), 'locationcity' => $sellocation->getCity(), 'locationtel' => $sellocation->getTel(), 'locationemail' => $sellocation->getEmail(), 'locationcity' => $sellocation->getCity(), 'locationurl' => $sellocation->getUrl(), 'guestname' => $array['firstlastname']); $mail = new Pimcore_Mail(); $subject = 'Reservation confirmation'; $mail->setParams($parameters); $mail->setReplyTo('*****@*****.**', $name = NULL); $mail->setSubject($subject); $mail->setDocument('/fr/booking/reservation-confirmation'); // $mail->setBody($body); $mail->addTo($email); $mail->addBcc('*****@*****.**'); $mail->Send(); }
/** * destroy */ public function destroy() { $res = new Reponse(); $rec = Object\Location::getById($this->id); if ($rec) { $rec->delete(); $res->success = true; $res->message = 'Destroyed'; } else { $res->message = "Failed to destroy"; } return $res; }
public function getListAction() { //get list of reservations $reponse = new Reponse(); $mylocationid = $this->getParam('locationid'); $myservingid = $this->getParam('servingid'); $calendar = $this->getParam('calendar'); $guestid = $this->getParam('guestid'); $cancelled = $this->getParam('cancelled'); $arrived = $this->getParam('arrived'); $mylocation = Object\Location::getById($mylocationid, 1); $myserving = Object\Serving::getById($myservingid, 1); $myguest = Object\Guest::getById($guestid, 1); if ($mylocation instanceof Object\Location || $myserving instanceof Object\Serving || $guest instanceof Object\Guest) { //we check if we are in the Editor if ($_POST['action']) { //if REMOVE if ($_POST['action'] == "remove") { foreach ($_POST['id'] as $id) { $myreservation = Object\Reservation::getById($id, 1); if ($myreservation instanceof Object\Reservation) { $myreservation->SetStatus('Cancelled'); $myreservation->save(); } } $reponse->message = 'TXT_RESERVATION_LIST'; $reponse->success = true; $reponse->data = ''; } //if EDIT if ($_POST['action'] == "edit") { $myreservation = Object_Reservation::getById($_POST['data']['id'], 1); if ($_POST['data']['guestid']) { $guest = Object_Guest::getById($_POST['data']['guestid'], 1); if ($guest instanceof Object_Guest) { $guest->setLastname($_POST['data']['guestname']); $guest->setTel($_POST['data']['guesttel']); $guest->setBookingnotes($_POST['data']['bookingnotes']); $guest->setPreferredlanguage($_POST['data']['preferredlanguage']); $guest->setNewsLetter($_POST['data']['newsLetter']); $guest->save(); } } //date update needs to be reworked $daystart = $myreservation->getStart()->get('dd-MM-YYYY'); $newdatestart = new Zend_Date($daystart . ' ' . $_POST['data']['start'] . ':00', 'dd-MM-YYYY HH:mm:ss'); $myreservation->setBookingref($_POST['data']['bookingref']); $myreservation->setBookingnotes($_POST['data']['bookingnotes']); if ($_POST['data']['status'] == 'Annulé') { $_POST['data']['status'] = "Cancelled"; } $myreservation->setStatus($_POST['data']['status']); if ($_POST['data']['arrived'] == '1') { $arrived = 1; } else { $arrived = 0; } if ($arrived == 1) { $myreservation->setActualpartysize($_POST['data']['partysize']); $myreservation->setPartysize($myreservation->getPartysize()); $myreservation->setActualstart($newdatestart); $myreservation->setStart($myreservation->getStart()); } else { $myreservation->setPartysize($_POST['data']['partysize']); $myreservation->setStart($newdatestart); } //Prework Table input $tableids = explode(',', $_POST['data']['table']); $tablearray = array(); foreach ($tableids as $tableid) { $variable = explode('-', $tableid); $table = $this->selectedLocation->getResource()->getTable($variable[0], $variable[1]); if ($table instanceof Object\Table) { array_push($tablearray, $table); } } $myreservation->setTable($tablearray); $myreservation->setArrived($arrived); $myreservation->save(); $data = $_POST['data']; if ($myreservation->getLocation() instanceof Object_Location) { $data['locationid'] = $myreservation->getLocation()->getId(); $data['locationname'] = $myreservation->getLocation()->getName(); } $data['DT_RowId'] = "row_" . $_POST['data']['id']; $reponse->message = 'TXT_RESERVATION_LIST'; $reponse->success = true; $reponse->row = $data; $reponse->debug = $tablearray; } } else { if (!$calendar) { $date = new Zend_Date(); $calendar = $date->get('dd-MM-YYYY'); } $calendarstart = $calendar . ' ' . '00:00:00'; $calendarend = $calendar . ' ' . '23:59:59'; $calendarstart = new Zend_Date($calendarstart, 'dd-MM-YYYY HH:mm:ss'); $calendarend = new Zend_Date($calendarend, 'dd-MM-YYYY HH:mm:ss'); if ($guestid == '') { if ($myservingid == '') { $reservations = $mylocation->getResource()->getReservationsByDate($calendarstart->getTimestamp(), $calendarend->getTimestamp()); } else { if ($myserving instanceof Object\Serving) { $reservations = $myserving->getReservationsByDate($calendarstart->getTimestamp(), $calendarend->getTimestamp()); } } } else { if ($myguest instanceof Object\Guest) { $reservations = $myguest->getReservationsByGuest($calendarstart->getTimestamp()); } } $data = array(); $i = 0; foreach ($reservations as $key => $reservation) { $i++; $resa = $this->formatReservation($reservation); array_push($data, $resa); } $reponse->message = 'TXT_RESERVATION_LIST'; $reponse->success = true; $reponse->data = $data; } } else { $data = array(); $reponse->message = 'TXT_NOT_RESERVATION_LIST'; $reponse->success = false; $reponse->data = $data; $reponse->debug = 'debug:' . $this->getParam('q'); } $this->render($reponse); }