Пример #1
0
 public function getguestAction()
 {
     $reponse = new Reponse();
     $this->disableLayout();
     $tel = $this->getParam('tel');
     $guest = Object\Guest::getByTel($tel, 1);
     if ($guest instanceof Object\Guest) {
         $data = $guest->toArray();
         if ($data) {
             $reponse->message = 'TXT_GUEST_LIST';
             $reponse->success = true;
             $reponse->data = $data;
             $reponse->debug = $this->getParam("q");
         } else {
             $reponse->message = 'TXT_NO_GUEST';
             $reponse->success = false;
             $reponse->data = $data;
         }
     } else {
         $reponse->message = 'TXT_NO_GUEST';
         $reponse->success = false;
         $reponse->data = $data;
     }
     $this->render($reponse);
 }
Пример #2
0
 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);
 }