public function resaserveringsAction()
 {
     $this->disableLayout();
     if ($this->getParam('locationid')) {
         $locationid = $this->getParam('locationid');
     } else {
         //get default location from URL !!!! should be linked to societe
         $locationid = 55;
     }
     $location = Object_Location::getById($locationid, 1);
     if ($location instanceof Object_Location) {
         $servings = $location->getServings();
         $unit = $location->getResaunit();
         $reponse = new Reponse();
         $array = array();
         //			foreach( $servings as $serving ){
         //				array_push($array, $serving->toArray());
         //			}
         //			$reponse->data=$array;
         //			$reponse->message="TXT_LOCATIONS_SENT";
         //			$reponse->success=true;
         //		    $this->render($reponse);
         $resatime = array();
         foreach ($servings as $myserving) {
             if ($myserving instanceof Object_Serving) {
                 $mealduration = (int) $myserving->getMealduration();
                 $timestart = strtotime($myserving->getTimestartmonday());
                 $timeend = strtotime($myserving->getTimeendmonday());
                 $unit = $unit * 60;
                 $mealduration = $mealduration * 60;
                 $slots = 0;
                 while ($timestart + $slots < $timeend - $mealduration) {
                     $timeslotunix = new Zend_date($timestart + $slots);
                     $timeslot = $timeslotunix->get(Zend_Date::HOUR) . ":" . $timeslotunix->get(Zend_Date::MINUTE);
                     array_push($resatime, $timeslot);
                     $slots = $slots + $unit;
                 }
             }
         }
         $reponse = new Reponse();
         $reponse->data = $resatime;
         $reponse->message = "TXT_LOCATIONS_SENT";
         $reponse->success = true;
         $this->render($reponse);
     }
 }
Esempio n. 2
0
?>
" class="no-display">
								</span>
							</div>
							<div id="calendarbox">
								<h4><span class="text-bold"><?php 
echo $this->translate('TXT_SELECT_DATE');
?>
</span></h4>
								<div class="col-md-12">
									<input id="mycalendar" name="calendar" type="text" data-date-format="dd-mm-yyyy" data-date-viewmode="years" class="form-control date-picker mycalendar no-display" value="<?php 
if ($this->resachange) {
    echo $this->start->get('dd-MM-YYYY');
} else {
    $date = new \Zend_date();
    echo $date->get('dd-MM-yyyy');
}
?>
" style="width:205px">
									<div id="fullcalendar" style="margin-left:-15px; margin-right:-15px"></div>
								</div>
							</div>
							<div id="partybox" class="no-display">
								<h4><span class="text-bold"><?php 
echo $this->translate('TXT_SELECT_PARTY');
?>
</span></h4>
								<input id="party" class="no-display">
								<div class="col-md-12 form-group lessthanseven" style="margin-top:10px">
									<?php 
$i = 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->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);
                 }
                 $myreservation->setArrived($arrived);
                 $myreservation->save();
                 $data = $_POST['data'];
                 $data['DT_RowId'] = "row_" . $_POST['data']['id'];
                 $reponse->message = 'TXT_RESERVATION_LIST';
                 $reponse->success = true;
                 $reponse->row = $data;
                 $reponse->debug = $this->reformatDate($_POST['data']);
             }
         } 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);
 }