Exemplo n.º 1
0
              <!-- promotions by room -->
              <?php 
        if (isset($data['promotions'][$k])) {
            ?>
                <?php 
            foreach ($data['promotions'][$k] as $p) {
                ?>
                <tr>
                <th colspan="2"><?php 
                echo $p['promotion_name'];
                ?>
</th>
                  <?php 
                foreach ($room['prices'] as $day => $price) {
                    $available = promotion_available($day, $p['id'], $price['room_id']);
                    if ($available) {
                        $stoped = (@$price['stoped_arrival'] == '1' or $available['stoped'] == '1') ? 'class="promotion tdRed"' : 'class="promotion tdGreen"';
                        //set discount price
                        if (@$price['price_type'] == '1') {
                            $roomPrice = $price['base_price'];
                        } else {
                            $roomPrice = @$price['double_price'];
                        }
                        $roomPrice = $roomPrice - $roomPrice / 100 * $p['promotion_discount'];
                        echo '<td ' . $stoped . ' data-room-name="' . $room['name'] . '" data-room-id="' . $price['room_id'] . '" data-promo-id="' . $p['id'] . '" data-promo-name="' . $p['promotion_name'] . '" data-available="' . $available['available'] . '" data-stoped=' . $available['stoped'] . ' data-day="' . $day . '">
                    ' . $roomPrice . '
                    </td>';
                    } else {
                        echo '<td class="promotion" data-room-name="' . $room['name'] . '" data-room-id="' . $price['room_id'] . '" data-promo-id="' . $p['id'] . '" data-promo-name="' . $p['promotion_name'] . '"  data-day="' . $day . '">N/A</td>';
                    }
Exemplo n.º 2
0
 function set_promotion_rules($promotions)
 {
     $new_arr = $promotions;
     foreach ($promotions as $rid => $promo) {
         foreach ($promo as $pid => $p) {
             //standart rules
             //check promotion dates
             if ($p['promotion_type'] != 4) {
                 if (strtotime(date('Y-m-d')) < strtotime($p['start_date']) or strtotime(date('Y-m-d')) > strtotime($p['end_date'])) {
                     $new_arr[$rid][$pid]['rule'] = 0;
                 }
             }
             /*
              * TODO:
              * Burası için algoritma değişecek
              * Seçilen tarihlerde 1 tane stoped varsa hiç gösterilmiyor promotion
              * Fiyat hesaplarken stoped olmayan tarihler yerine normal fiyat üzerinden hesaplanacak
              */
             //check room availibity or stoped values for reservation dates
             foreach (date_range($this->start_date, $this->end_date) as $d => $date) {
                 $available = promotion_available($date, $pid, $rid);
                 if (!$available or $available['available'] < 1 or $available['stoped'] == 1) {
                     $new_arr[$rid][$pid]['rule'] = 0;
                 }
             }
             /* TODO  END*/
             //minimum stay rules
             if ($p['promotion_type'] == 2) {
                 //check total nights for minimum stay
                 if ($this->nights < $p['min_stay']) {
                     $new_arr[$rid][$pid]['rule'] = 0;
                 }
             }
             //early booker rules
             if ($p['promotion_type'] == 3) {
                 //booking days for reservation
                 if (strtotime($this->start_date) < strtotime($p['booking_start']) or strtotime($this->end_date) > strtotime($p['booking_end'])) {
                     $new_arr[$rid][$pid]['rule'] = 0;
                 }
             }
             if ($p['promotion_type'] == 4) {
                 //if reservation dates are not between promo dates, disable promo
                 if (strtotime($this->start_date) < strtotime($p['start_date']) or strtotime($this->start_date) > strtotime($p['end_date'])) {
                     $new_arr[$rid][$pid]['rule'] = 0;
                 }
                 $promo_starts = date('Y-m-d H:i:s', strtotime("-" . $p['last_min_qty'] . ' ' . $p['last_min_val'], strtotime($this->start_date . ' 00:00:00')));
                 //if today is lower than promo start, disable promo
                 if (strtotime(date('Y-m-d H:i:s')) <= strtotime($promo_starts)) {
                     $new_arr[$rid][$pid]['rule'] = 0;
                 }
                 $new_arr[$rid][$pid]['promo_start'] = $promo_starts;
             }
             //24h rules
             if ($p['promotion_type'] == 5) {
                 //$new_arr[$rid][$pid]['rule'] = strtotime($p['twentyfour_date'].' 23:59:59');
                 //$p['twentyfour_date'];
                 //booking days for reservation
                 if (strtotime(date('Y-m-d H:i:s')) >= strtotime($p['twentyfour_date'] . ' 23:59:59')) {
                     $new_arr[$rid][$pid]['rule'] = 0;
                 }
             }
         }
     }
     return $new_arr;
 }