コード例 #1
0
ファイル: dashboard_model.php プロジェクト: bogiesoft/Hotel
 function reservation_stats($today, $last_month)
 {
     $hotel_id = $this->session->userdata('hotel_id');
     //print($hotel_id); exit;
     $output = array();
     $reservation = $this->db->query("SELECT count(id) as total,sum(total_price) as total_price,currency,\n\t\t\tDATE_FORMAT(reservation_date,'%Y-%m-%d') as reservation_date\n\t\t\tFROM reservations\n\t\t\tWHERE hotel_id = {$hotel_id} and reservation_date > (CURDATE() - INTERVAL 30 DAY)\n\t\t\tGROUP BY reservation_date");
     //set reservation date as key
     $data = array();
     foreach ($reservation->result_array() as $key => $value) {
         $data[$value['reservation_date']] = $value;
     }
     foreach (date_range($last_month, $today) as $k => $date) {
         if (isset($data[$date])) {
             $output[$date] = $data[$date];
         } else {
             $output[$date]['total'] = 0;
             $output[$date]['total_price'] = 0;
             $output[$date]['currency'] = NULL;
             $output[$date]['reservation_date'] = $date;
         }
     }
     return $output;
 }
コード例 #2
0
ファイル: hotel.php プロジェクト: bogiesoft/Hotel
 function index()
 {
     $this->lang->load('reservation/hotels', 'en');
     //print_r($this->total_room_price);
     $hotel_id = $this->input->get('hotel_id');
     //if hotel id is not set return error
     if (!$hotel_id) {
         exit('Error');
     }
     //get hotel info
     $hotel = $this->front_model->hotel_info($hotel_id);
     if (!$hotel) {
         exit('Hotel not found.');
     }
     //set reservation info false
     $data['reservation'] = false;
     //if change reservation
     if ($this->input->get('res_code') or $this->session->userdata('res_code')) {
         $reservation = $this->front_model->get_reservation($this->input->get('res_code'), $hotel_id);
         if ($reservation) {
             $data['reservation'] = $reservation;
             //set user extras
             $this->session->set_userdata('user_extras', json_decode($reservation->extras, TRUE));
             $this->session->set_userdata('user_cart', json_decode($reservation->rooms, TRUE));
             //set reservation code on session
             $this->session->set_userdata('res_code', $this->input->get('res_code'));
         }
     }
     //options
     $default_lang = $this->session->userdata('default_lang') ? $this->session->userdata('default_lang') : 'en';
     $this->start_date = $this->input->get('checkin') ? $this->input->get('checkin') : date('d-m-Y');
     $this->end_date = $this->input->get('checkout') ? $this->input->get('checkout') : date('d-m-Y', strtotime('+1 day', strtotime($this->start_date)));
     $this->adults = $this->input->get('adults') ? $this->input->get('adults') : '2';
     $this->children = $this->input->get('children') ? $this->input->get('children') : '0';
     $this->currency = $hotel->currency;
     //$this->setCurrency($hotel->currency);
     //$this->user_currency = isset($this->session->userdata('currency')) ? $this->session->userdata('currency') : $this->currency;
     $this->user_currency = ($this->input->get('cur') and strlen($this->input->get('cur')) == 3) ? $this->input->get('cur') : $this->currency;
     if ($this->user_currency != $this->currency) {
         $this->currency_rate = currency_rates($this->currency, $this->user_currency);
     }
     //make dates to yy-mm-dd format
     $this->start_date = date('Y-m-d', strtotime($this->start_date));
     $this->end_date = date('Y-m-d', strtotime($this->end_date));
     //salaklar geçmişe dönük rezervasyon yapmak isterse
     if (strtotime($this->start_date) < strtotime(date('Y-m-d'))) {
         $this->start_date = date('Y-m-d');
         //exit('Checkin Date Error');
     }
     //salaklar start date'i end date'den sonrası bir tarihe girerse falan
     if (strtotime($this->start_date) >= strtotime($this->end_date)) {
         //$this->end_date = date('d-m-Y',strtotime('+1 day',strtotime($this->start_date)));
         exit('Checkout Date Error');
     }
     //clear cart
     if (NULL != $this->input->get('time')) {
         $this->session->unset_userdata('user_cart');
     }
     //load languages
     $this->lang->load('reservation/rooms', $default_lang);
     $this->lang->load('reservation/policies', $default_lang);
     //get rooms
     $search = array('child' => $this->children, 'adults' => $this->adults, 'language' => $default_lang);
     $arr = array();
     $rooms = $this->front_model->get_hotel_rooms($hotel_id, $search);
     if (FALSE === $rooms) {
         $arr['rooms'] = 0;
     } else {
         foreach (date_range($this->start_date, $this->end_date) as $k => $d) {
             $arr['dates'][$d] = $d;
             //set nights
             $this->nights = count($arr['dates']) - 1;
             foreach ($rooms as $key => $r) {
                 $arr['rooms'][$r->id]['name'] = $r->name;
                 $arr['rooms'][$r->id]['title'] = $r->title;
                 $arr['rooms'][$r->id]['content'] = $r->content;
                 $arr['rooms'][$r->id]['units'] = $r->room_units;
                 $arr['rooms'][$r->id]['included'] = $r->included;
                 $arr['rooms'][$r->id]['max_capacity'] = $r->max_capacity;
                 $arr['rooms'][$r->id]['max_adult'] = $r->max_adult;
                 $arr['rooms'][$r->id]['max_child'] = $r->max_child;
                 $arr['rooms'][$r->id]['default_policy'] = $r->default_policy;
                 $arr['rooms'][$r->id]['photos'] = $this->front_model->get_room_photos($r->id);
                 //check if price is set for the day
                 if ($this->front_model->get_bar_by_room($d, $r->id)) {
                     $arr['rooms'][$r->id]['prices'][$d] = $this->front_model->get_bar_by_room($d, $r->id);
                 } else {
                     $arr['rooms'][$r->id]['prices'][$d]['available'] = 0;
                     $arr['rooms'][$r->id]['prices'][$d]['stoped_arrival'] = 1;
                     $arr['rooms'][$r->id]['prices'][$d]['stoped_departure'] = 1;
                     $arr['rooms'][$r->id]['prices'][$d]['base_price'] = 0;
                     $arr['rooms'][$r->id]['prices'][$d]['single_price'] = 0;
                     $arr['rooms'][$r->id]['prices'][$d]['double_price'] = 0;
                     $arr['rooms'][$r->id]['prices'][$d]['triple_price'] = 0;
                     $arr['rooms'][$r->id]['prices'][$d]['extra_adult'] = 0;
                 }
                 $arr['rooms'][$r->id]['prices'][$d]['room_name'] = $r->name;
                 $arr['rooms'][$r->id]['prices'][$d]['room_id'] = $r->id;
                 $arr['rooms'][$r->id]['prices'][$d]['room_capacity'] = $r->capacity;
                 $arr['rooms'][$r->id]['prices'][$d]['room_child'] = $r->min_child;
             }
         }
     }
     //get promotions
     $promotions = $this->front_model->get_promotions($hotel_id);
     //set promotions by rooms id
     if ($promotions) {
         $promotion = array();
         foreach ($promotions as $k => $p) {
             $rooms = explode(',', $p['rooms']);
             foreach ($rooms as $r => $room) {
                 $promotion[$room][$p['id']] = $p;
                 $promotion[$room][$p['id']]['rule'] = 1;
             }
         }
         $arr['promotions'] = $promotion;
     } else {
         $arr['promotions'] = [];
     }
     $data['options'] = array('nights' => $this->nights, 'adults' => $this->adults, 'children' => $this->children, 'checkin' => $this->start_date, 'checkout' => $this->end_date, 'currency' => $this->currency, 'user_currency' => $this->user_currency, 'currency_rate' => $this->currency_rate);
     $this->session->set_userdata('options', $data['options']);
     $data['hotel_info'] = $hotel;
     $data['hotel_photos'] = $this->front_model->get_hotel_photos($hotel_id);
     //$data['rooms'] 			= array_orderby($arr['rooms'],'single_price',SORT_ASC);
     $data['rooms'] = $arr['rooms'];
     //create prices and set session
     //by rooms and promotions
     $this->calculate_room_prices($data['rooms']);
     if (is_array($arr['promotions'])) {
         $this->calculate_promo_prices($arr['promotions']);
         //set promotion rules
         $data['promotion'] = $this->set_promotion_rules($arr['promotions']);
     } else {
         $data['promotion'] = false;
     }
     //Extras
     $data['extras'] = $this->front_model->get_extras($hotel_id, $default_lang);
     $this->calculate_extra_prices($data['extras']);
     $data['prices'] = $this->session->userdata('prices_all');
     $data['user_cart'] = $this->session->userdata('user_cart');
     $data['user_extras'] = $this->session->userdata('user_extras');
     $data['guest'] = $this->session->userdata('guest');
     echo '<!--';
     echo '<pre>';
     print_r($data);
     echo '-->';
     $this->load->view('front/index', $data);
 }
コード例 #3
0
ファイル: reservation.php プロジェクト: bogiesoft/Hotel
 function prices()
 {
     //load language
     $this->lang->load('reservation/set_prices', $this->language);
     //load user agent
     $this->load->library('user_agent');
     //set max row for table
     $rowlimit = $this->agent->is_mobile() ? '5' : '14';
     //set start date
     if (empty($this->input->get('start_date'))) {
         $start_date = date('Y-m-d', strtotime('-1 day', time()));
     } else {
         $start_date = $this->input->get('start_date');
     }
     //set end date
     if (empty($this->input->get('end_date'))) {
         $end_date = date('Y-m-d', strtotime('+' . $rowlimit . ' day', time()));
     } else {
         $end_date = $this->input->get('end_date');
     }
     $data['error'] = false;
     if (strtotime($start_date) > strtotime($end_date)) {
         $data['error'] = lang('date_error');
     }
     $rooms = $this->reservation_model->get_hotel_rooms();
     $arr = array();
     foreach (date_range($start_date, $end_date) as $k => $d) {
         $arr['dates'][$d] = $d;
         foreach ($rooms as $key => $r) {
             $arr['rooms'][$r->id]['name'] = $r->name;
             $arr['rooms'][$r->id]['prices'][$d] = $this->reservation_model->get_bar_by_room($d, $r->id);
             $arr['rooms'][$r->id]['prices'][$d]['room_name'] = $r->name;
             $arr['rooms'][$r->id]['prices'][$d]['room_id'] = $r->id;
             $arr['rooms'][$r->id]['prices'][$d]['room_capacity'] = $r->capacity;
             $arr['rooms'][$r->id]['prices'][$d]['room_child'] = $r->max_child;
         }
     }
     //get promotions
     $promotions = $this->reservation_model->get_promotions();
     //set promotions by rooms id
     if ($promotions) {
         $promotion = array();
         foreach ($promotions as $k => $p) {
             $rooms = explode(',', $p['rooms']);
             foreach ($rooms as $r => $room) {
                 $promotion[$room][$p['id']] = $p;
             }
         }
         $arr['promotions'] = $promotion;
     }
     //echo '<pre>'; print_r($arr); exit;
     $data['start_date'] = $start_date;
     $data['end_date'] = $end_date;
     $data['rowlimit'] = $rowlimit;
     $data['data'] = $arr;
     $this->load->view('reservation/prices', $data);
 }
コード例 #4
0
ファイル: index.php プロジェクト: ocet/tinyos-2.x-contrib
            if ($day > 29) {
                return "Date out of range";
            }
        } elseif ($day > 28) {
            return "Date out of range";
        }
    } else {
        if ($day > 30) {
            return "Date out of range";
        } else {
            return NULL;
        }
    }
}
list($month, $day, $year) = split("/", $_POST["date"]);
$err_msg = date_range($day, $month, $year);
//setup database
$dbc = mysql_connect('diesel.cs.umass.edu', 'turtle', 'hardshell');
mysql_select_db('snapper_turtles', $dbc);
$query_var = "";
$vishost = "http://" . $_SERVER['HTTP_HOST'];
$visdir = dirname($_SERVER['PHP_SELF']);
$visfulldir = $vishost . $visdir;
if ($err_msg == NULL) {
    //select max and minimum times for date range, '2008/01/01' is so garbage readings are ignored
    $sql = "SELECT MAX(local_stamp), MIN(local_stamp) FROM GPS WHERE local_stamp > '2008/01/01';";
    $dbq = mysql_query($sql, $dbc);
    while ($row = mysql_fetch_assoc($dbq)) {
        $max = $row['MAX(local_stamp)'] . "\n";
        $min = $row['MIN(local_stamp)'] . "\n";
    }
コード例 #5
0
ファイル: RA_Controller.php プロジェクト: bogiesoft/Hotel
 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;
 }
コード例 #6
0
 $selectQ = "SELECT week_day FROM calendar WHERE week_day = :startDate";
 $new_year = true;
 try {
     $pdo = $pgc->prepare($selectQ);
     $pdo->bindValue(':startDate', $start_date);
     $pdo->execute();
     $res = $pdo->fetchAll(PDO::FETCH_NUM);
     if ($pdo->rowCount() > 0) {
         $new_year = false;
     }
 } catch (PDOException $e) {
     $pgc = NULL;
     die('error in gc function => ' . $e->getMessage());
 }
 if ($new_year) {
     $dates = date_range($start_date, $end_date, "+1 day", "Y-m-d");
     foreach ($dates as $key => $value) {
         try {
             // if day is saturtday then second and third shift is free
             if (date('N', strtotime($value)) == 6) {
                 $pdo = $pgc->prepare($insertQ);
                 $pdo->bindValue(':week_day', $value);
                 $pdo->bindValue(':shift1', false, PDO::PARAM_BOOL);
                 $pdo->bindValue(':shift2', true, PDO::PARAM_BOOL);
                 $pdo->bindValue(':shift3', true, PDO::PARAM_BOOL);
                 $pdo->bindValue(':record_time', date("Y-m-d H:i:s", strtotime(date('Y-m-d H:i:s')) - 60 * 60 * 2) . " +00:00");
                 $pdo->execute();
             } else {
                 if (date('N', strtotime($value)) == 7) {
                     $pdo = $pgc->prepare($insertQ);
                     $pdo->bindValue(':week_day', $value);
コード例 #7
0
function do_im_report($date_in, $func_in)
{
    // incident mgmt report $frm_date, $mode as params - 9/27/10
    global $types, $tick_array, $deltas, $counts, $severities, $units_str, $evenodd, $logs, $types;
    global $types, $incident, $disposition;
    // 12/7/10
    global $w_tiny, $w_small, $w_medium, $w_large;
    // 4/14/11
    $tick_array = array(0);
    $deltas = array(0, 0, 0, 0);
    // normal, medium, high, total
    $counts = array(0, 0, 0, 0);
    //
    $severities = array("", "M", "H");
    // severity symbols
    $from_to = date_range($date_in, $func_in);
    // get date range as array
    $where = " WHERE `problemstart` >= '{$from_to[0]}' AND `problemstart` < '{$from_to[1]}'";
    function do_print($row_in)
    {
        global $today, $today_ref, $line_ctr, $units_str, $severities, $evenodd;
        global $w_tiny, $w_small, $w_medium, $w_large;
        if (empty($today)) {
            $today_ref = date("z", $row_in['problemstart']);
            $today = substr(format_date($row_in['problemstart']), 0, 5);
        } else {
            if (!($today_ref == date("z", $row_in['problemstart']))) {
                // date change?
                $today_ref = date("z", $row_in['problemstart']);
                $today = substr(format_date($row_in['problemstart']), 0, 5);
            }
        }
        $def_city = get_variable('def_city');
        $def_st = get_variable('def_st');
        print "<TR CLASS = '{$evenodd[$line_ctr % 2]}'  onClick = 'open_tick_window(" . $row_in['tick_id'] . ");' >\n";
        print "<TD>{$today}</TD>\n";
        //		Date -
        $problemstart = format_date($row_in['problemstart']);
        $problemstart_sh = short_ts($problemstart);
        print "<TD onMouseover=\"Tip('{$problemstart}');\" onmouseout='UnTip();'>{$problemstart_sh}</TD>\n";
        //		start
        $problemend = format_date($row_in['problemend']);
        $problemend_sh = short_ts($problemend);
        print "<TD onMouseover=\"Tip('{$problemend}');\" onmouseout='UnTip();'>{$problemend_sh}</TD>\n";
        //		end
        $elapsed = intval($row_in['problemstart']) > 0 && intval($row_in['problemend']) > 0 ? my_date_diff($row_in['problemstart'], $row_in['problemend']) : "na";
        print "<TD>{$elapsed}</TD>\n";
        //		Ending time
        print "<TD ALIGN='center'>{$severities[$row_in['severity']]}</TD>\n";
        $scope = $row_in['tick_scope'];
        $scope_sh = shorten($row_in['tick_scope'], $w_medium);
        print "<TD onMouseover=\"Tip('{$scope}');\" onmouseout='UnTip();'>{$scope_sh}</TD>\n";
        //		Call type
        $comment = $row_in['comments'];
        $short_comment = shorten($row_in['comments'], $w_large);
        print "<TD onMouseover=\"Tip('{$comment}');\" onMouseout='UnTip();'>{$short_comment}</TD>\n";
        //		Comments/Disposition
        $facility = $row_in['facy_name'];
        $facility_sh = shorten($row_in['facy_name'], $w_small);
        print "<TD onMouseover=\"Tip('{$facility}');\" onmouseout='UnTip();'>{$facility_sh}</TD>\n";
        //		Facility
        $city = $row_in['tick_city'] == $def_city ? "" : ", {$row_in['tick_city']}";
        $st = $row_in['tick_state'] == $def_st ? "" : ", {$row_in['tick_state']}";
        $addr = "{$row_in['tick_street']}{$city}{$st}";
        $addr_sh = shorten($row_in['tick_street'] . $city . $st, $w_medium);
        print "<TD onMouseover=\"Tip('{$addr}');\" onMouseout='UnTip();'>{$addr_sh}</TD>\n";
        //		Street addr
        print "<TD>{$units_str}</TD>\n";
        //		Units responding
        print "</TR>\n\n";
        $line_ctr++;
    }
    // end function do print()
    function do_stats($in_row)
    {
        //
        global $deltas, $counts;
        if (intval($in_row['problemstart']) > 0 && intval($in_row['problemend']) > 0) {
            $deltas[$in_row['severity']] += $in_row['problemend'] - $in_row['problemstart'];
            $deltas[3] += $in_row['problemend'] - $in_row['problemstart'];
        }
        $counts[$in_row['severity']]++;
        $counts[3]++;
    }
    // end function do stats()
    // 12/7/10
    function do_print_log($ary_in)
    {
        //     ["code"]=> string(1) "3" ["info"]=>  string(14) "test test test"  ["when"]=>   string(10) "1302117158"
        global $today, $today_ref, $line_ctr, $evenodd, $types;
        global $w_tiny, $w_small, $w_medium, $w_large;
        print "<TR CLASS = '{$evenodd[$line_ctr % 2]}'>\n";
        print "<TD>{$today}</TD>\n";
        //		Date -
        $when = format_date($ary_in['when']);
        $when_sh = short_ts($when);
        print "<TD onMouseover=\"Tip('{$when}');\" onmouseout='UnTip();'>{$when_sh}</TD>\n";
        //		start
        print "<TD  COLSPAN=3></TD>\n";
        //		end	Ending time
        print "<TD><I>Log entry:</I></TD>\n";
        //		Call type
        $info = $ary_in['info'];
        $sh_info = shorten($ary_in['info'], $w_large);
        print "<TD onMouseover=\"Tip('{$info}');\" onMouseout='UnTip();'>{$sh_info}</TD>\n";
        //		Comments/Disposition
        print "<TD>{$ary_in['user']}</TD>\n";
        //		Facility
        print "<TD COLSPAN=2></TD>\n";
        //		Street addr, Units responding
        print "</TR>\n\n";
        $line_ctr++;
    }
    // end function do print_log()
    // populate global logs array
    $where_l = str_replace("problemstart", "when", $where);
    // log version - 7/22/11
    $query = "SELECT `l`.`code`, `l`.`info` AS `info`, UNIX_TIMESTAMP(`l`.`when`) AS `when`, `u`.`user`, `u`.`info` AS `user_info`\n\t\t\t\tFROM `{$GLOBALS['mysql_prefix']}log` `l`\n\t\t\t\tLEFT JOIN `{$GLOBALS['mysql_prefix']}user` u ON (`l`.who = u.id)\n\t\t\t\t{$where_l}\n\t\t\t\tAND (`code` = {$GLOBALS['LOG_COMMENT']})\n\t\t\t\tORDER BY `when` ASC";
    $result = mysql_query($query) or do_error($query, 'mysql query failed', mysql_error(), basename(__FILE__), __LINE__);
    while ($row = stripslashes_deep(mysql_fetch_assoc($result))) {
        array_push($logs, $row);
    }
    unset($result);
    function check_logs($in_time)
    {
        //  prints qualifying log entries
        global $logs;
        while (!empty($logs) && $logs[0]['when'] <= $in_time) {
            do_print_log($logs[0]);
            array_shift($logs);
            // remove 1st entry
        }
    }
    // end function check_logs()
    $query = "SELECT *, UNIX_TIMESTAMP(problemstart) AS `problemstart`,\n\t\t\t\tUNIX_TIMESTAMP(problemend) AS `problemend`,\n\t\t\t\t`a`.`id` AS `assign_id` ,\n\t\t\t\t`a`.`comments` AS `assign_comments`,\n\t\t\t\t`u`.`user` AS `theuser`, `t`.`scope` AS `tick_scope`,\n\t\t\t\t`t`.`id` AS `tick_id`,\n\t\t\t\t`t`.`description` AS `tick_descr`,\n\t\t\t\t`t`.`status` AS `tick_status`,\n\t\t\t\t`t`.`street` AS `tick_street`,\n\t\t\t\t`t`.`city` AS `tick_city`,\n\t\t\t\t`t`.`state` AS `tick_state`,\t\t\t\n\t\t\t\t`r`.`id` AS `unit_id`,\n\t\t\t\t`r`.`name` AS `unit_name` ,\n\t\t\t\t`r`.`type` AS `unit_type` ,\n\t\t\t\t`f`.`name` AS `facy_name` ,\n\t\t\t\t`a`.`as_of` AS `assign_as_of`\n\t\t\t\tFROM `{$GLOBALS['mysql_prefix']}assigns` `a`\n\t\t\t\tLEFT JOIN `{$GLOBALS['mysql_prefix']}ticket`\t `t` ON (`a`.`ticket_id` = `t`.`id`)\n\t\t\t\tLEFT JOIN `{$GLOBALS['mysql_prefix']}user`\t\t `u` ON (`a`.`user_id` = `u`.`id`)\n\t\t\t\tLEFT JOIN `{$GLOBALS['mysql_prefix']}responder`\t `r` ON (`a`.`responder_id` = `r`.`id`)\n\t\t\t\tLEFT JOIN `{$GLOBALS['mysql_prefix']}facilities` `f` ON (`a`.`facility_id` = `f`.`id`)\n\t\t\t\t{$where}\n\t\t\t\tAND `t`.`status` <> '{$GLOBALS['STATUS_RESERVED']}'\t\t\t\t\n\t\t\t\tORDER BY `problemstart` ASC";
    $result = mysql_query($query) or do_error($query, 'mysql query failed', mysql_error(), basename(__FILE__), __LINE__);
    //dump($query);
    print "<TABLE BORDER=0 ALIGN='center' cellspacing = 1 CELLPADDING = 4  ID='IM' STYLE='display:block'>";
    $to_str = $func_in == "dr" ? "" : " to {$from_to[3]} " . substr($from_to[1], 0, 4);
    print "<TR CLASS='even'><TH COLSPAN=99 ALIGN = 'center'>" . "{$incident} Management Report - " . $from_to[2] . $to_str . "</TH></TR>\n";
    print "<TR CLASS='odd'>\n\t\t\t\t\t<TD><B>Date</B></TD>\n\t\t\t\t\t<TD><B>Opened</B></TD>\n\t\t\t\t\t<TD><B>Closed</B></TD>\n\t\t\t\t\t<TD><B>Elapsed</B></TD>\n\t\t\t\t\t<TD><B>Severity</B></TD>\n\t\t\t\t\t<TD><B>Call type</B></TD>\n\t\t\t\t\t<TD><B>Comments/{$disposition}</B></TD>\n\t\t\t\t\t<TD><B>Facility</B></TD>\n\t\t\t\t\t<TD><B>Address</B></TD>\n\t\t\t\t\t<TD><B>" . get_text("Unit") . " responding</B></TD>\n\t\t\t\t\t</TR>";
    if (mysql_num_rows($result) == 0) {
        // empty?
        print "<TR CLASS = 'even'><TH COLSPAN=99>none</TH></TR>\n";
        print "<TR CLASS = 'odd'><TD COLSPAN=99><BR /><BR /></TD></TR>\n";
    } else {
        $units_str = "";
        $i = 0;
        $today = $today_ref = "";
        $buffer = "";
        $sep = ", ";
        while ($row = stripslashes_deep(mysql_fetch_assoc($result))) {
            // major while ()
            array_push($tick_array, $row['tick_id']);
            // stack them up
            if (empty($buffer)) {
                // first time
                $buffer = $row;
                $units_str = $row['unit_name'];
            } else {
                // not first time
                if ($row['tick_id'] == $buffer['tick_id']) {
                    $units_str .= $sep . $row['unit_name'];
                    // no change, collect unit names
                    //					$buffer = $row;
                } else {
                    check_logs($buffer['problemstart']);
                    // problemstart integer
                    do_print($buffer);
                    // print from buffer
                    do_stats($buffer);
                    $buffer = $row;
                    $units_str = $row['unit_name'];
                }
            }
            // end if/else
        }
        // end while(
        check_logs(time());
        // everything remaining
        do_print($buffer);
        // print from buffer
        do_stats($buffer);
    }
    // end else{}
    $tick_array2 = array_unique($tick_array);
    // delete dupes
    $tick_array3 = array_values($tick_array2);
    // compress result
    $sep = $tick_str = "";
    for ($i = 0; $i < count($tick_array3); $i++) {
        $tick_str .= $sep . $tick_array3[$i];
        $sep = ",";
    }
    $query = "SELECT *, \n\t\t\t\tUNIX_TIMESTAMP(problemstart) AS `problemstart`,\n\t\t\t\tUNIX_TIMESTAMP(problemend) AS `problemend`,\n\t\t\t\t`u`.`user` AS `theuser`,\n\t\t\t\tNULL AS `unit_name`,\n\t\t\t\t`t`.`scope` AS `tick_scope`,\n\t\t\t\t`t`.`id` AS `tick_id`,\n\t\t\t\t`t`.`description` AS `tick_descr`,\n\t\t\t\t`t`.`status` AS `tick_status`,\n\t\t\t\t`t`.`street` AS `tick_street`,\n\t\t\t\t`t`.`city` AS `tick_city`,\n\t\t\t\t`t`.`state` AS `tick_state`,\t\t\t\n\t\t\t\t`f`.`name` AS `facy_name` \n\t\t\t\tFROM `{$GLOBALS['mysql_prefix']}ticket`\t\t\t `t`\n\t\t\t\tLEFT JOIN `{$GLOBALS['mysql_prefix']}user`\t\t `u` ON (`t`.`_by` = `u`.`id`)\n\t\t\t\tLEFT JOIN `{$GLOBALS['mysql_prefix']}facilities` `f` ON (`t`.`facility` = `f`.`id`)\n\t\t\t\t{$where}\n\t\t\t\tAND `t`.`id` NOT IN ({$tick_str})\n\t\t\t\tAND `t`.`status` <> '{$GLOBALS['STATUS_RESERVED']}'\n\t\t\t\tORDER BY `problemstart` ASC";
    //		dump($query);
    $result = mysql_query($query) or do_error($query, 'mysql query failed', mysql_error(), basename(__FILE__), __LINE__);
    print "<TR><TD COLSPAN=99 ALIGN='center'><B>Not dispatched</B></TD></TR>";
    if (mysql_num_rows($result) == 0) {
        print "<TR CLASS='even'><TD COLSPAN=99 ALIGN='center'><B>none</B></TD></TR>";
    } else {
        $units_str = "";
        while ($row = stripslashes_deep(mysql_fetch_assoc($result))) {
            // incidents not dispatched
            do_print($row);
            do_stats($row);
        }
    }
    if ($counts[3] > 0) {
        // any stats?
        print "<TR><TD COLSPAN=99 ALIGN='center'><B><BR />Mean incident close times by severity:&nbsp;&nbsp;&nbsp;";
        for ($i = 0; $i < 3; $i++) {
            // each severity level
            if ($counts[$i] > 0) {
                $mean = round($deltas[$i] / $counts[$i]);
                print "<B>" . ucfirst(get_severity($i)) . "</B> ({$counts[$i]}): " . my_date_diff(0, $mean) . ",&nbsp;&nbsp;&nbsp;&nbsp;";
            }
        }
        $mean = round($deltas[3] / $counts[3]);
        // overall
        print "<B>Overall</B>  ({$counts[3]}): " . my_date_diff(0, $mean);
        print "</B></TD></TR>";
    }
    print "</TABLE>";
    return;
}
コード例 #8
0
ファイル: cms_calendar.php プロジェクト: erico-deh/ocPortal
 /**
  * Standard aed_module edit actualiser.
  *
  * @param  ID_TEXT		The entry being edited
  * @return tempcode		Description shown after editing
  */
 function edit_actualisation($_id)
 {
     $id = intval($_id);
     $rows = $GLOBALS['SITE_DB']->query_select('calendar_events', array('*'), array('id' => $id), '', 1);
     if (!array_key_exists(0, $rows)) {
         warn_exit(do_lang_tempcode('MISSING_RESOURCE'));
     }
     $event = $rows[0];
     check_edit_permission($event['e_is_public'] == 1 ? 'mid' : 'low', $event['e_submitter']);
     $delete_status = post_param('delete', '0');
     list($type, $recurrence, $_recurrences, $title, $content, $priority, $is_public, $_start_year, $_start_month, $_start_day, $_start_hour, $_start_minute, $_end_year, $_end_month, $_end_day, $_end_hour, $_end_minute, $timezone, $do_timezone_conv) = $this->get_event_parameters();
     $allow_trackbacks = post_param_integer('allow_trackbacks', fractional_edit() ? INTEGER_MAGIC_NULL : 0);
     $allow_rating = post_param_integer('allow_rating', fractional_edit() ? INTEGER_MAGIC_NULL : 0);
     $allow_comments = post_param_integer('allow_comments', fractional_edit() ? INTEGER_MAGIC_NULL : 0);
     $notes = post_param('notes', STRING_MAGIC_NULL);
     $validated = post_param_integer('validated', fractional_edit() ? INTEGER_MAGIC_NULL : 0);
     $seg_recurrences = post_param_integer('seg_recurrences', fractional_edit() ? INTEGER_MAGIC_NULL : 0);
     $fixed_past = false;
     if ($delete_status == '3' && !fractional_edit()) {
         // Fix past occurences
         $past_times = find_periods_recurrence($event['e_timezone'], 1, $event['e_start_year'], $event['e_start_month'], $event['e_start_day'], $event['e_start_hour'], $event['e_start_minute'], $event['e_end_year'], $event['e_end_month'], $event['e_end_day'], $event['e_end_hour'], $event['e_end_minute'], $event['e_recurrence'], $event['e_recurrences'], utctime_to_usertime(mktime($event['e_start_hour'], $event['e_start_minute'], 0, $event['e_start_month'], $event['e_start_day'], $event['e_start_year'])), utctime_to_usertime(time()));
         if (count($past_times) > 0) {
             foreach ($past_times as $past_time) {
                 list($start_year, $start_month, $start_day, $start_hour, $start_minute) = explode('-', date('Y-m-d-h-i', usertime_to_utctime($past_time[0])));
                 if (is_null($past_time[1])) {
                     list($end_year, $end_month, $end_day, $end_hour, $end_minute) = array(NULL, NULL, NULL, NULL, NULL);
                 } else {
                     $explode = explode('-', date('Y-m-d-h-i', usertime_to_utctime($past_time[1])));
                     $end_year = intval($explode[0]);
                     $end_month = intval($explode[1]);
                     $end_day = intval($explode[2]);
                     $end_hour = intval($explode[3]);
                     $end_minute = intval($explode[4]);
                 }
                 add_calendar_event($event['e_type'], 'none', NULL, 0, get_translated_text($event['e_title']), get_translated_text($event['e_content']), $event['e_priority'], $event['e_is_public'], intval($start_year), intval($start_month), intval($start_day), intval($start_hour), intval($start_minute), $end_year, $end_month, $end_day, $end_hour, $end_minute, $timezone, $do_timezone_conv, $validated, $allow_rating, $allow_comments, $allow_trackbacks, $notes);
             }
             if (is_null($_recurrences)) {
                 $recurrences = NULL;
             } else {
                 $recurrences = max(0, $_recurrences - count($past_times));
             }
             // Find next occurence in future
             if (count($past_times) == 0) {
                 $start_year = $_start_year;
                 $start_month = $_start_month;
                 $start_day = $_start_day;
                 $start_hour = $_start_hour;
                 $start_minute = $_start_minute;
                 $end_year = $_end_year;
                 $end_month = $_end_month;
                 $end_day = $_end_day;
                 $end_hour = $_end_hour;
                 $end_minute = $_end_minute;
             }
             $past_times = find_periods_recurrence($event['e_timezone'], 1, $start_year, $start_month, $start_day, $start_hour, $start_minute, $end_year, $end_month, $end_day, $end_hour, $end_minute, $event['e_recurrence'], 1, time());
             if (array_key_exists(0, $past_times)) {
                 $past_time = $past_times[0];
                 $explode = explode('-', date('Y-m-d-h-i', $past_time[0]));
                 $start_year = intval($explode[0]);
                 $start_month = intval($explode[1]);
                 $start_day = intval($explode[2]);
                 $start_hour = intval($explode[3]);
                 $start_minute = intval($explode[4]);
                 if (is_null($past_time[1])) {
                     list($end_year, $end_month, $end_day, $end_hour, $end_minute) = array(NULL, NULL, NULL, NULL, NULL);
                 } else {
                     $explode = explode('-', date('Y-m-d-h-i', $past_time[1]));
                     $end_year = intval($explode[0]);
                     $end_month = intval($explode[1]);
                     $end_day = intval($explode[2]);
                     $end_hour = intval($explode[3]);
                     $end_minute = intval($explode[4]);
                 }
             } else {
                 $recurrences = 0;
             }
             $fixed_past = true;
         }
     }
     if (!$fixed_past) {
         $start_year = $_start_year;
         $start_month = $_start_month;
         $start_day = $_start_day;
         $start_hour = $_start_hour;
         $start_minute = $_start_minute;
         $end_year = $_end_year;
         $end_month = $_end_month;
         $end_day = $_end_day;
         $end_hour = $_end_hour;
         $end_minute = $_end_minute;
         $recurrences = $_recurrences;
     }
     if ($validated == 1 && $GLOBALS['SITE_DB']->query_value('calendar_events', 'validated', array('id' => $id)) == 0) {
         if (has_actual_page_access($GLOBALS['FORUM_DRIVER']->get_guest_id(), 'calendar') && has_category_access($GLOBALS['FORUM_DRIVER']->get_guest_id(), 'calendar', strval($type))) {
             $_from = cal_get_start_utctime_for_event($timezone, $start_year, $start_month, $start_day, $start_hour, $start_minute, true);
             $from = cal_utctime_to_usertime($_from, $timezone, false);
             $to = mixed();
             if (!is_null($end_year) && !is_null($end_month) && !is_null($end_day)) {
                 $_to = cal_get_end_utctime_for_event($timezone, $end_year, $end_month, $end_day, $end_hour, $end_minute, true);
                 $to = cal_utctime_to_usertime($_to, $timezone, false);
             }
             $submitter = $GLOBALS['SITE_DB']->query_value('calendar_events', 'e_submitter', array('id' => $id));
             syndicate_described_activity($submitter != get_member() ? 'calendar:ACTIVITY_VALIDATE_CALENDAR_EVENT' : 'calendar:ACTIVITY_CALENDAR_EVENT', $title, date_range($from, $to, !is_null($start_hour)), '', '_SEARCH:calendar:view:' . strval($id), '', '', 'calendar', 1, NULL, true);
         }
     }
     edit_calendar_event($id, $type, $recurrence, $recurrences, $seg_recurrences, $title, $content, $priority, $is_public, $start_year, $start_month, $start_day, $start_hour, $start_minute, $end_year, $end_month, $end_day, $end_hour, $end_minute, $timezone, $do_timezone_conv, post_param('meta_keywords', STRING_MAGIC_NULL), post_param('meta_description', STRING_MAGIC_NULL), $validated, $allow_rating, $allow_comments, $allow_trackbacks, $notes);
     if (!fractional_edit()) {
         $conflicts = detect_conflicts(get_member(), $id, $start_year, $start_month, $start_day, $start_hour, $start_minute, $end_year, $end_month, $end_day, $end_hour, $end_minute, $recurrence, $recurrences);
         $_description = is_null($conflicts) ? paragraph(do_lang_tempcode('SUCCESS')) : $conflicts;
         regenerate_event_reminder_jobs($id);
     } else {
         $_description = do_lang_tempcode('SUCCESS');
     }
     $this->donext_type = $type;
     $this->donext_date = strval($start_year) . '-' . strval($start_month) . '-' . strval($start_day);
     return $_description;
 }
コード例 #9
0
     print '<div class="non-food-toggle1"></div>';
 }
 print '<div class="pn-non-food-wrapper">';
 $time_stamp_tdy = $week_begin;
 for ($day = 1; $day < 8; $day++) {
     if (date('d/m/Y', $time_stamp_tdy) == date('d/m/Y') || date('d/m/Y', $time_stamp_tdy) == date('d/m/Y', strtotime($sp_user_selected_date))) {
         $day_text = date('D', $time_stamp_tdy);
         //Day style- Class
         print '<div class="pn-non-alimenaire-today ' . $day_text . '"></div>';
     }
     $time_stamp_tdy = strtotime('+1 day', $time_stamp_tdy);
 }
 $time_stamp = $week_begin;
 $date_time = date('m/d/Y', $time_stamp);
 //Get days in the current week
 $this_week_nonfood = date_range($date_time, date('m/d/Y', strtotime('+6 days', $time_stamp)));
 $this_week_nonfood_nodes = array();
 //Get nodes which are begining in this Week of type 'non_alimentare'
 foreach ($plan_de_vente as $nid => $sales_data) {
     if ($sales_data['type'] == 'non_alimentare') {
         $date_in_range = array_intersect($this_week_nonfood, $sales_data['dates']);
         if (in_array($sales_data['dates'][0], $this_week_nonfood)) {
             $this_week_nonfood_nodes[$nid] = $sales_data;
         }
     }
 }
 //Nodes in this week
 $this_week_nonfood_node_count = 0;
 while ($this_week_nonfood_node_count != sizeof($this_week_nonfood_nodes)) {
     foreach ($this_week_nonfood_nodes as $this_week_nonfood_node) {
         $week_node_id = $this_week_nonfood_node['nid'];
コード例 #10
0
ファイル: Helpers.php プロジェクト: jaffarsolo/ci3-examples
 public function date_helper()
 {
     $this->load->helper('date');
     echo now('Australia/Victoria');
     echo "<br>";
     echo now('+8');
     echo "<br>";
     $datestring = 'Year: %Y Month: %m Day: %d - %h:%i %a';
     $time = time();
     echo mdate($datestring, $time);
     //at UTC
     echo "<br>";
     $format = 'DATE_RFC822';
     $time = time();
     echo standard_date($format, $time);
     //Deprecated
     echo "<br>";
     echo date(DATE_RFC822, time());
     echo "<br>";
     echo local_to_gmt(time());
     echo "<br>";
     $timestamp = 1140153693;
     $timezone = 'UM8';
     $daylight_saving = TRUE;
     echo gmt_to_local($timestamp, $timezone, $daylight_saving);
     echo "<br>";
     echo "<br>";
     $unix = mysql_to_unix('20061124092345');
     echo $unix;
     echo "<br>";
     echo "<br>";
     $now = time();
     echo unix_to_human($now);
     // U.S. time, no seconds
     echo "<br>";
     echo unix_to_human($now, TRUE, 'us');
     // U.S. time with seconds
     echo "<br>";
     echo unix_to_human($now, TRUE, 'eu');
     // Euro time with seconds
     echo "<br>";
     echo "<br>";
     $now = time();
     $human = unix_to_human($now);
     $unix = human_to_unix($human);
     echo $human;
     echo "<br>";
     echo $unix;
     echo "<br>";
     echo "<br>";
     echo "<br>";
     $bad_date = '199605';
     // Should Produce: 1996-05-01
     $better_date = nice_date($bad_date, 'Y-m-d');
     echo $bad_date;
     echo "<br>";
     echo $better_date;
     echo "<br>";
     echo "<br>";
     $bad_date = '9-11-2001';
     // Should Produce: 2001-09-11
     $better_date = nice_date($bad_date, 'Y-m-d');
     echo $bad_date;
     echo "<br>";
     echo $better_date;
     echo "<br>";
     echo "<br>";
     $post_date = '1079621429';
     $now = time();
     $units = 2;
     echo timespan($post_date, $now, $units);
     echo "<br>";
     echo "<br>";
     echo days_in_month(06, 2005);
     echo "<br>";
     echo "<br>";
     $range = date_range('2012-01-01', '2012-01-15');
     echo "First 15 days of 2012:";
     foreach ($range as $date) {
         echo $date . "\n";
     }
     echo "<br>";
     echo "<br>";
     echo timezones('UM5');
     echo "<br>";
     echo "<br>";
     echo timezone_menu('UM8');
     echo "<br>";
     echo "<br>";
 }
コード例 #11
0
ファイル: freeradius.php プロジェクト: Kingy/whmcs-freeradius
function collect_usage($params)
{
    $username = $params["username"];
    $serviceid = $params["serviceid"];
    $sqlhost = $params["serverip"];
    $sqlusername = $params["serverusername"];
    $sqlpassword = $params["serverpassword"];
    $sqldbname = $params["serveraccesshash"];
    $result = select_query("tblhosting", "nextduedate,billingcycle", array("id" => $serviceid));
    $data = mysql_fetch_array($result);
    $date_range = date_range($data["nextduedate"], $data["billingcycle"]);
    $startdate = $date_range["startdate"];
    $enddate = $date_range["enddate"];
    $freeradiussql = mysql_connect($sqlhost, $sqlusername, $sqlpassword);
    mysql_select_db($sqldbname);
    $query = "SELECT COUNT(*) AS logins,SUM(radacct.AcctSessionTime) AS logintime,SUM(radacct.AcctInputOctets) AS uploads,SUM(radacct.AcctOutputOctets) AS downloads,SUM(radacct.AcctOutputOctets) + SUM(radacct.AcctInputOctets) AS total FROM radacct WHERE radacct.Username='******' AND radacct.AcctStartTime>='" . $startdate . "'";
    if ($enddate) {
        $query .= " AND radacct.AcctStartTime<='" . $startdate . "'";
    }
    $query .= " ORDER BY AcctStartTime DESC";
    $result = mysql_query($query, $freeradiussql);
    $data = mysql_fetch_array($result);
    $logins = $data[0];
    $logintime = $data[1];
    $uploads = $data[2];
    $downloads = $data[3];
    $total = $data[4];
    $query = "SELECT radacct.AcctStartTime as start, radacct.AcctStopTime as stop FROM radacct WHERE radacct.Username='******' ORDER BY AcctStartTime DESC LIMIT 0,1";
    $result = mysql_query($query, $freeradiussql);
    $data = mysql_fetch_array($result);
    $sessions = mysql_num_rows($result);
    $start = $data[0];
    $end = $data[1];
    $status = "Offline";
    if ($end) {
        $status = "Logged in at " . $start;
    }
    if ($sessions < 1) {
        $status = "No logins";
    }
    freeradius_WHMCSReconnect();
    $usage_limit = 0;
    if (!empty($params["configoption2"])) {
        if (is_numeric($params["configoption2"])) {
            $usage_limit = $params["configoption2"];
        }
    }
    foreach ($params["configoptions"] as $key => $value) {
        $Megabytes = 0;
        $Gigabytes = 0;
        if ($key == 'Megabytes') {
            if (is_numeric($value)) {
                $Gigabytes = $value * 1024 * 1024;
            }
        }
        if ($key == 'Gigabytes') {
            if (is_numeric($value)) {
                $Gigabytes = $value * 1024 * 1024 * 1024;
            }
        }
        if ($Megabytes > 0 || $Gigabytes > 0) {
            $usage_limit = $Megabytes + $Gigabytes;
        }
    }
    return array('logins' => $logins, 'logintime' => $logintime, 'total' => $total, 'uploads' => $uploads, 'downloads' => $downloads, 'usage_limit' => $usage_limit, 'status' => $status);
}
コード例 #12
0
<?php

function date_range($first, $last, $number)
{
    $step = '+1 day';
    $output_format = 'd/m/Y';
    $dates = array();
    $current = strtotime($first);
    $last = strtotime($last);
    while ($current <= $last) {
        $dates[] = date($output_format, $current);
        $current = strtotime($step, $current);
    }
    $today = date('z');
    print_r(array_slice($dates, $today, $number));
}
date_range("2015-01-01", "2020-12-31", 7);
コード例 #13
0
 function price_grid_update_promo()
 {
     //load language
     $this->lang->load('reservation/set_prices', $this->language);
     $start_date = $this->input->post('start_date');
     $end_date = $this->input->post('end_date');
     if (strtotime($start_date) > strtotime($end_date)) {
         echo json_encode(array('status' => 'danger', 'message' => lang('date_error')));
         exit;
     }
     $available = $this->input->post('promo_available');
     $promotion_id = $this->input->post('promotion_id');
     $room_id = $this->input->post('promotion_room_id');
     $stoped = empty($this->input->post('promo_stoped')) ? '0' : '1';
     $arr = array('available' => $available, 'stoped' => $stoped, 'room_id' => $room_id, 'price_plan_id' => $promotion_id);
     $this->load->model('reservation_model');
     foreach (date_range($start_date, $end_date) as $key => $day) {
         $arr['price_date'] = $day;
         $update = $this->reservation_model->update_price_plan($arr);
     }
     if ($update) {
         echo json_encode(array('status' => 'success', 'message' => lang('success_message')));
     } else {
         echo json_encode(array('status' => 'danger', 'message' => lang('error_message')));
     }
 }
コード例 #14
0
 public function test_date_range()
 {
     $dates = array('29-01-2012', '30-01-2012', '31-01-2012', '01-02-2012', '02-02-2012', '03-02-2012', '04-02-2012', '05-02-2012', '06-02-2012', '07-02-2012', '08-02-2012', '09-02-2012', '10-02-2012', '11-02-2012', '12-02-2012', '13-02-2012', '14-02-2012', '15-02-2012', '16-02-2012', '17-02-2012', '18-02-2012', '19-02-2012', '20-02-2012', '21-02-2012', '22-02-2012', '23-02-2012', '24-02-2012', '25-02-2012', '26-02-2012', '27-02-2012', '28-02-2012', '29-02-2012', '01-03-2012');
     $this->assertEquals($dates, date_range(mktime(12, 0, 0, 1, 29, 2012), mktime(12, 0, 0, 3, 1, 2012), TRUE, 'd-m-Y'));
     array_pop($dates);
     $this->assertEquals($dates, date_range(mktime(12, 0, 0, 1, 29, 2012), 31, FALSE, 'd-m-Y'));
 }
コード例 #15
0
ファイル: calendar.php プロジェクト: erico-deh/ocPortal
 /**
  * Subscribe for reminders to an event.
  *
  * @return tempcode		The UI
  */
 function _subscribe_event()
 {
     $title = get_page_title('SUBSCRIBE_EVENT');
     $seconds_before = intval(floatval(post_param('hours_before')) * 3600.0);
     $id = get_param_integer('id');
     // The event ID
     $events = $GLOBALS['SITE_DB']->query_select('calendar_events', array('*'), array('id' => get_param_integer('id')), '', 1);
     $event = $events[0];
     $rem_id = $GLOBALS['SITE_DB']->query_insert('calendar_reminders', array('e_id' => $id, 'n_member_id' => get_member(), 'n_seconds_before' => $seconds_before), true);
     if (has_actual_page_access($GLOBALS['FORUM_DRIVER']->get_guest_id(), 'calendar') && has_category_access($GLOBALS['FORUM_DRIVER']->get_guest_id(), 'calendar', strval($event['e_type']))) {
         $_from = cal_get_start_utctime_for_event($event['e_timezone'], $event['e_start_year'], $event['e_start_month'], $event['e_start_day'], $event['e_start_hour'], $event['e_start_minute'], $event['e_do_timezone_conv'] == 1);
         $from = cal_utctime_to_usertime($_from, $event['e_timezone'], $event['e_do_timezone_conv'] == 1);
         $to = mixed();
         if (!is_null($event['e_end_year']) && !is_null($event['e_end_month']) && !is_null($event['e_end_day'])) {
             $_to = cal_get_end_utctime_for_event($event['e_timezone'], $event['e_end_year'], $event['e_end_month'], $event['e_end_day'], $event['e_end_hour'], $event['e_end_minute'], $event['e_do_timezone_conv'] == 1);
             $to = cal_utctime_to_usertime($_to, $event['e_timezone'], $event['e_do_timezone_conv'] == 1);
         }
         syndicate_described_activity('calendar:ACTIVITY_SUBSCRIBED_EVENT', get_translated_text($event['e_title']), date_range($from, $to, !is_null($event['e_start_hour'])), '', '_SEARCH:calendar:view:' . strval($id), '', '', 'calendar', 1, NULL, true);
     }
     // Add next reminder to job system
     $recurrences = find_periods_recurrence($event['e_timezone'], 1, $event['e_start_year'], $event['e_start_month'], $event['e_start_day'], is_null($event['e_start_hour']) ? 0 : $event['e_start_hour'], is_null($event['e_start_minute']) ? 0 : $event['e_start_minute'], $event['e_end_year'], $event['e_end_month'], $event['e_end_day'], is_null($event['e_end_hour']) ? 0 : $event['e_end_hour'], is_null($event['e_end_minute']) ? 0 : $event['e_end_minute'], $event['e_recurrence'], min(1, $event['e_recurrences']));
     if (array_key_exists(0, $recurrences)) {
         $GLOBALS['SITE_DB']->query_insert('calendar_jobs', array('j_time' => usertime_to_utctime($recurrences[0][0]) - $seconds_before, 'j_reminder_id' => $rem_id, 'j_member_id' => get_member(), 'j_event_id' => get_param_integer('id')));
     }
     $url = build_url(array('page' => '_SELF', 'type' => 'view', 'id' => get_param_integer('id')), '_SELF');
     return redirect_screen($title, $url, do_lang_tempcode('SUCCESS'));
 }
コード例 #16
0
ファイル: actions.php プロジェクト: bogiesoft/Hotel
 function room_price_info()
 {
     //print_r($this->input->post('children')); exit;
     $room_id = $this->input->post('room_id');
     $options = json_decode($this->input->post('options'), true);
     $start = $options['checkin'];
     $adults = $options['adults'];
     $rate = $options['currency_rate'];
     $discount = $this->input->post('discount');
     $child_ages = json_decode($this->input->post('children'));
     //get prices for 7 days
     $prices = $this->front_model->get_room_price_for_chart($start, $room_id);
     if ($adults == 1) {
         $type = 'single_price';
     } elseif ($adults == 2) {
         $type = 'double_price';
     } elseif ($adults >= 3) {
         $type = 'triple_price';
     }
     $data = array();
     foreach ($prices as $key => $p) {
         $total_child_price = 0;
         $adult_price = 0;
         //if price is unit price
         if (isset($p['price_type']) and $p['price_type'] == 1) {
             $adult_price += $p['base_price'];
         } else {
             //if adults more than 3
             if ($this->adults >= 4) {
                 $total_adult = $this->adults - 3;
                 $total_adult_price = $total_adult * $p['extra_adult'];
                 $adult_price += $p['triple_price'];
                 $adult_price += $total_adult_price;
             } else {
                 $adult_price += $p[$type];
             }
         }
         //calculate children prices
         if ($options['children'] != 0 and isset($p['child_price']) and count($child_ages) > 0) {
             $child_price = json_decode($p['child_price'], true);
             //print_r($child_price);
             foreach ($child_ages as $key => $age) {
                 $total_child_price += $this->get_child_price_by_age($age, $child_price);
             }
         }
         $total_price = $adult_price + $total_child_price;
         $data[$p['price_date']]['date'] = $p['price_date'];
         $price = $total_price - $total_price * $discount / 100;
         $data[$p['price_date']]['price'] = show_price($price, $rate);
     }
     //chart json data
     $chart_detail = '';
     $chart_data = array();
     foreach ($data as $date => $value) {
         $day = date('l', strtotime($date));
         $dayNum = date('d', strtotime($date));
         $class = ($day == 'Sunday' or $day == 'Saturday') ? 'weekend' : '';
         $class .= $date == date('Y-m-d') ? 'today' : '';
         $price = $value['price'];
         $ymd = date('Y-m-d', strtotime($date));
         $chart_data[$ymd] = array('dayAbr' => substr($day, 0, 1), 'dayNum' => $dayNum, 'date' => date('M d', strtotime($date)), 'ymd' => $ymd, 'price' => $price, 'cclass' => $class);
     }
     $start_date = $options['checkin'];
     $date_range = date_range($start_date, date('Y-m-d', strtotime('+30 day', strtotime($start_date))));
     $chart = array();
     foreach ($date_range as $key => $date) {
         $day = date('l', strtotime($date));
         $dayNum = date('d', strtotime($date));
         $class = ($day == 'Sunday' or $day == 'Saturday') ? 'weekend' : '';
         $class .= $date == date('Y-m-d') ? 'today' : '';
         if (!isset($chart_data[$date])) {
             $chart[] = array('dayAbr' => substr($day, 0, 1), 'dayNum' => $dayNum, 'date' => date('M d', strtotime($date)), 'price' => 0, 'cclass' => $class);
         } else {
             $chart[] = array('dayAbr' => substr($day, 0, 1), 'dayNum' => $dayNum, 'date' => date('M d', strtotime($date)), 'price' => $chart_data[$date]['price'], 'cclass' => $class);
         }
     }
     echo json_encode($chart);
     //google chart için datayuı şekillendir
     /*
     
     $rows = array();
     foreach ($data as $key => $value) {
     	$cell0["v"]=date('D-m-Y',strtotime($value['date']));
     	//$cell0["v"]=substr($cell0["v"], 0,-2);
     	$cell1["v"]=$value['price'];
     	$row["c"]=array($cell0,$cell1);
      	
      			array_push($rows,$row);
     	//$a['rows']['c'][] = array('v'=>array($value['date'])),array('v'=>array($value['price']));
     }
     
     
     $a['cols'] = array(array('label'=>'Day','type'=>'string'),array('label'=>'Price','type'=>'number'));
         	$a['rows'] = $rows;
     
     echo json_encode($a);
     */
 }
コード例 #17
0
ファイル: Users.php プロジェクト: Jheysoon/TADPS
 function get_logs()
 {
     $this->load->helper('date');
     $date_from = $this->input->post('date_from');
     $date_to = $this->input->post('date_to');
     $user = $this->input->post('user');
     $range = date_range($date_from, $date_to);
     $template = '';
     $template .= '<tr>
                         <th>Date</th>
                         <th>Time</th>
                         <th>Activity</th>
                         <th>User</th>
                     </tr>';
     foreach ($range as $date) {
         $l = $this->db->query("SELECT fname, lname, ddate, ttime, activity\n                                FROM logs a, users b\n                                WHERE b.id = a.user AND ddate = '{$date}'\n                                AND (fname LIKE '%{$user}%' OR lname LIKE '%{$user}%')")->result_array();
         foreach ($l as $logs) {
             $template .= '<tr>
                                 <td>' . $date . '</td>
                                 <td>' . $logs['ttime'] . '</td>
                                 <td>' . $logs['activity'] . '</td>
                                 <td>' . $logs['fname'] . ' ' . $logs['lname'] . '</td>
                             </tr>';
         }
     }
     echo $template;
 }