| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122 |
- <?php
- require_once DOL_DOCUMENT_ROOT . '/custom/eventwizard/class/eventlocation.class.php';
- class BookingAgendaHelper
- {
- public $db;
- public function __construct($db)
- {
- $this->db = $db;
- }
- function getEventdayDates($year, $month, $day)
- {
- $dates = [];
- $eventday = $year . '-';
- $eventday .= (int) $month < 10 ? '0' : '';
- $eventday .= $month . '-';
- $eventday .= (int) $day < 10 ? '0' : '';
- $eventday .= $day;
- $eventday = str_replace("-00", "-0", $eventday);
- $dates['eventday'] = $eventday;
- $dates['eventdayprint'] = date("Y M d", strtotime($eventday));
- $dates['from'] = $eventday . ' 00:00:00';
- $dates['to'] = $eventday . ' 23:59:59';
- return $dates;
- }
- /* function getMaxNumFromEVENT($eventarray){
- foreach($eventarray as $event){
- return $event['max_num'];
- }
- } */
- function getsumReservation($eventsArray, $eventday, $hourText)
- {
- $count = 0;
- $from = strtotime($eventday . ' ' . $hourText . ':00:00');
- $to = strtotime($eventday . ' ' . $hourText . ':59:59');
- foreach ($eventsArray as $event) {
- $event_from = strtotime($event['datep']);
- $event_to = strtotime($event['datep2']);
- if (($from <= $event_from && $to >= $event_from) || $from >= $event_from && $to + 1 <= $event_to) {
- //print $eventday . ' ' . $fromtime . ' - ' . $eventday . ' ' . $totime . '<br>';
- //print ' - ' . $event['datep'] . ' - ' . $event['datep2'] . '<br>';
- $count = $count + (int)$event['participants'];
- }
-
- }
- return $count > 0 ? $count : '-';
- }
- function getsumOccupied($eventsArray, $eventday, $hourText)
- {
- $count = 0;
- $from = strtotime($eventday . ' ' . $hourText . ':00:00');
- $to = strtotime($eventday . ' ' . $hourText . ':59:59');
- foreach ($eventsArray as $event) {
- $event_from = strtotime($event['datep']);
- $event_to = strtotime($event['datep2']);
- if($from == $event_to){
- $count = $count + (int)$event['participants'];
- }
- if (($from <= $event_from && $to >= $event_from) || $from >= $event_from && $to + 1 <= $event_to) {
- $count = $count + (int)$event['participants'];
- }
-
- }
- return $count > 0 ? $count : '-';
- }
- function getsumService($eventsArray, $eventday, $hourText)
- {
- $count = 0;
- $from = strtotime($eventday . ' ' . $hourText . ':00:00');
- foreach ($eventsArray as $event) {
- $event_to = strtotime($event['datep2']);
- if($from == $event_to){
- $count = $count + (int)$event['participants'];
- }
- }
- return $count > 0 ? $count : '-';
- }
- function getlocations(){
- $locationArray = [];
- $eventwizardLocationsObj = new EventLocation($this->db);
- $result = $eventwizardLocationsObj->fetchAll('ASC', 'label', 0, 0);
- if(count($result) > 0){
- foreach($result as $location){
- $locationArray[$location->id] = $location->label;
- }
- }
- return $locationArray;
- }
- function getLocationLabel($event){
- foreach($event as $eventDetail){
- return $eventDetail['fk_elventlocation_departure'];
- }
- }
- function getOneColumnFromTable($sql, $array, $column)
- {
- $eventData = $this->db->query($sql);
- if ($this->db->num_rows($eventData) > 0) {
- while ($row = $this->db->fetch_object($eventData)) {
- $array[$row->fk_elventlocation_departure][$row->$column] = (array) $row;
- }
- }
- return $array;
- }
- function getBGColor($rowcolorCounter){
- return $rowcolorCounter % 2 ? 'white' : 'Gainsboro';
- }
-
- function getHourText($hour){
- return $hour < 10 ? '0' . $hour : $hour;
- }
- }
|