public function weeklystatsAction()
 {
     $this->disableLayout();
     $this->disableViewAutoRender();
     $type = $this->getParam('type');
     $end = new Zend_Date();
     $end->setTime('23:59:59');
     $date = new Zend_Date();
     $date->sub(6, Zend_Date::DAY);
     $date->setTime('00:00:01');
     //Build reference array
     $i = 0;
     //echo $end->getTimestamp(); echo "<br>";
     while ($i <= 6) {
         $referencearray[$date->get('dd-MM-YYYY')] = 0;
         $date->add(1, Zend_Date::DAY);
         $i++;
     }
     //Get the results array
     $start = new Zend_date();
     $start->sub(6, Zend_Date::DAY);
     $start->setTime('00:00:01');
     $stat = new \Object\Stats();
     $results = $stat->getStatistics($this->selectedLocation->getId(), $start, $end);
     $startoftheweek = $start->get('dd-MM-YYYY');
     //echo $start->getTimestamp(); echo "<br>";exit;
     foreach ($this->selectedLocation->getServings() as $serving) {
         //initiate orderarray and seatsarray
         $orderarray = $referencearray;
         $seatsarray = $referencearray;
         foreach ($results as $result) {
             $datein = date("d-m-Y", $result["date_start"]);
             if ($serving->getId() == $result['serving_id']) {
                 $servingid = $result['serving_id'];
                 if (array_key_exists($datein, $referencearray)) {
                     $orderarray[$datein] = $result["nbre"];
                     $seatsarray[$datein] = $result["couverts"];
                 }
             }
         }
         if ($type == 'seats') {
             $servingarray[$serving->getTitle()] = $seatsarray;
         } else {
             $servingarray[$serving->getTitle()] = $orderarray;
         }
     }
     $reponse = new Reponse();
     $reponse->data = $servingarray;
     $reponse->message = "TXT_STATS_SENT";
     $reponse->success = true;
     $this->render($reponse);
 }
 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);
     }
 }
Beispiel #3
0
 /**
  * (non-PHPdoc)
  * @see Oara/Network/Oara_Network_Base#getPaymentHistory()
  */
 public function getPaymentHistory()
 {
     $paymentHistory = array();
     $valuesFromExport = $this->_exportPaymentParameters;
     $urls = array();
     $urls[] = new Oara_Curl_Request('https://admin.omgpm.com/v2/finance/affiliate/view_payments.aspx?', array());
     $exportReport = $this->_client->get($urls);
     /*** load the html into the object ***/
     $doc = new DOMDocument();
     libxml_use_internal_errors(true);
     $doc->validateOnParse = true;
     $doc->loadHTML($exportReport[0]);
     $hiddenList = $doc->getElementsByTagName('input');
     for ($i = 0; $i < $hiddenList->length; $i++) {
         $attrs = $hiddenList->item($i)->attributes;
         if ($attrs->getNamedItem("type")->nodeValue == 'hidden') {
             //we are adding the hidden parameters
             $valuesFromExport[] = new Oara_Curl_Parameter($attrs->getNamedItem("name")->nodeValue, $attrs->getNamedItem("value")->nodeValue);
         }
     }
     $yearSelect = $doc->getElementById('ctl00_ContentPlaceHolder1_ddlYear')->childNodes;
     $yearStart = (int) $yearSelect->item($yearSelect->length - 1)->attributes->getNamedItem("value")->nodeValue;
     $nowDays = new Zend_Date();
     $yearEnd = (int) $nowDays->get(Zend_Date::YEAR);
     $urls = array();
     for ($i = $yearStart; $i <= $yearEnd; $i++) {
         $requestValuesFromExport = Oara_Utilities::cloneArray($valuesFromExport);
         $requestValuesFromExport[] = new Oara_Curl_Parameter('ctl00$ContentPlaceHolder1$ddlYear', (string) $i);
         $urls[] = new Oara_Curl_Request('https://admin.omgpm.com/v2/finance/affiliate/view_payments.aspx?', $requestValuesFromExport);
     }
     $exportReport = $this->_client->post($urls);
     for ($i = 0; $i < count($exportReport); $i++) {
         if (!preg_match("/No Results for this criteria/i", $exportReport[$i])) {
             $doc = new DOMDocument();
             libxml_use_internal_errors(true);
             $doc->validateOnParse = true;
             $doc->loadHTML($exportReport[$i]);
             $table = $doc->getElementById('ctl00_ContentPlaceHolder1_gvSummary');
             $paymentList = $table->childNodes;
             for ($j = 1; $j < $paymentList->length; $j++) {
                 $paymentData = $paymentList->item($j)->childNodes;
                 $obj = array();
                 $obj['value'] = Oara_Utilities::parseDouble($paymentData->item(5)->nodeValue);
                 if ($obj['value'] != null) {
                     $date = new Zend_date($paymentData->item(8)->nodeValue, "dd/MM/yyyy HH:mm:ss");
                     $obj['date'] = $date->toString("yyyy-MM-dd HH:mm:ss");
                     $obj['pid'] = $paymentData->item(2)->nodeValue;
                     $ass = $paymentData->item(5)->nodeValue;
                     $obj['method'] = 'BACS';
                     $paymentHistory[] = $obj;
                 }
             }
         }
     }
     return $paymentHistory;
 }
Beispiel #4
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 
Beispiel #5
0
 /**
  * Checks necessity of rotation
  *
  * @return bool
  */
 protected function _isNeedRotation()
 {
     return $this->_mdate instanceof Zend_Date && Zend_date::now()->toString("yyyyMMdd") > $this->_mdate->toString("yyyyMMdd");
 }
Beispiel #6
0
 /**
  * (non-PHPdoc)
  *
  * @see library/Oara/Network/Oara_Network_Publisher_Base#getTransactionList($merchantId, $dStartDate, $dEndDate)
  */
 public function getTransactionList($merchantList = null, Zend_Date $dStartDate = null, Zend_Date $dEndDate = null, $merchantMap = null)
 {
     $totalTransactions = array();
     $dEndDate->addDay(1);
     $valuesFormExport = Oara_Utilities::cloneArray($this->_exportTransactionParameters);
     $valuesFormExport[] = new Oara_Curl_Parameter('pDate1', $dStartDate->toString("MM/d/yyyy"));
     $valuesFormExport[] = new Oara_Curl_Parameter('pDate2', $dEndDate->toString("MM/d/yyyy"));
     $urls = array();
     $urls[] = new Oara_Curl_Request('https://www.auto-europe.co.uk/afftools/iatareport_popup.cfm?', $valuesFormExport);
     $exportReport = $this->_client->post($urls);
     $xmlTransactionList = self::readTransactions($exportReport[0]);
     foreach ($xmlTransactionList as $xmlTransaction) {
         $transaction = array();
         $transaction['merchantId'] = 1;
         $date = new Zend_date($xmlTransaction['Booked'], "MM/dd/yyyy");
         $transaction['date'] = $date->toString("yyyy-MM-dd 00:00:00");
         $transaction['amount'] = (double) $xmlTransaction['commissionValue'];
         $transaction['commission'] = (double) $xmlTransaction['commission'];
         $transaction['status'] = Oara_Utilities::STATUS_CONFIRMED;
         $transaction['unique_id'] = $xmlTransaction['Res #'];
         if (isset($xmlTransaction['Affiliate1']) && isset($xmlTransaction['Affiliate2'])) {
             $customId = (string) $xmlTransaction['Affiliate1'] . (string) $xmlTransaction['Affiliate2'];
             $customId = "afal-" . current(unpack('H*', base64_decode(str_replace(array(".", "-"), array("/", "+"), $customId))));
             $transaction['custom_id'] = $customId;
         }
         $totalTransactions[] = $transaction;
     }
     return $totalTransactions;
 }
 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);
 }