예제 #1
0
   <tr>
     <td colspan="2" bgcolor="#999999">
     <font size="2" color="white"><b>Deactivated Events</b></font>
     </td>
   </tr>
 </table>
 <Table>
 ';
   while ($calendar_deactive_old = mysql_fetch_array($r_calendar['deactive_old'])) {
       print "<TR><TD width=\"130\" align=right valign=\"top\"><font color=\"#FF0000\" size=1>( old )</font> " . format_db_date($calendar_deactive_old['eventtime']) . "</TD><TD width=\"200\"valign=\"top\"> " . strip_tags($calendar_deactive_old['eventsubject']) . " </TD><TD>[ <A HREF=\"calendar.php?session={$session}&action=edit&event={$calendar_deactive_old['eventid']}\">Edit</A> ] [ <A HREF=\"calendar.php?session={$session}&action=delete&event={$calendar_deactive_old['eventid']}\">Delete</a> ]</TD><TD WIDTH=\"100\">{$calendar_deactive_old['username']}</TD></TR>";
   }
   while ($calendar_deactive_today = mysql_fetch_array($r_calendar['deactive_today'])) {
       print "<TR><TD width=\"130\" align=right valign=\"top\"><font color=\"#000080\" size=1>( today )</font> " . format_db_date($calendar_deactive_today['eventtime']) . "</TD><TD width=\"200\"valign=\"top\"> " . strip_tags($calendar_deactive_today['eventsubject']) . " </TD><TD>[ <A HREF=\"calendar.php?session={$session}&action=edit&event={$calendar_deactive_today['eventid']}\">Edit</A> ] [ <A HREF=\"calendar.php?session={$session}&action=delete&event={$calendar_deactive_today['eventid']}\">Delete</a> ]</TD><TD WIDTH=\"100\">{$calendar_deactive_today['username']}</TD></TR>";
   }
   while ($calendar_deactive = mysql_fetch_array($r_calendar['deactive'])) {
       print "<TR><TD width=\"130\" align=right valign=\"top\">" . format_db_date($calendar_deactive['eventtime']) . "</TD><TD width=\"200\"valign=\"top\"> " . strip_tags($calendar_deactive['eventsubject']) . " </TD><TD>[ <A HREF=\"calendar.php?session={$session}&action=edit&event={$calendar_deactive['eventid']}\">Edit</A> ] [ <A HREF=\"calendar.php?session={$session}&action=delete&event={$calendar_deactive['eventid']}\">Delete</a> ]</TD><TD WIDTH=\"100\">{$calendar_deactive['username']}</TD></TR>";
   }
   print '
 </TABLE><BR>
 <table width="100%" border="0" cellspacing="1" cellpadding="3">
     <tr>
       <td colspan="2" bgcolor="#999999">
         <font size="2" color="white"><b>New Event</b></font>
       </td>
     </tr>
 </table>
 <form action="calendar.php?session=' . $session . '&action=add" method="post">
 <Table border=0 cellspacing=0>
 <TR><TD><B>Date :</B></TD></TR>
 <TR><TD><input class="tbinput" type="Text" name="newdate[day]" size="3" maxlength="2">.<input class="tbinput" type="text" name="newdate[month]" size="3" maxlength="2">.<input class="tbinput" type="text" name="newdate[year]" size="5" maxlength="4"></TD></TR>
 <TR><TD><B>Subject :</B></TD></TR>
예제 #2
0
<p>Converts a date from english (e.g. mm/dd/yyyy) to db format (e.g yyyy-mm-dd). The default delimiter parameter is <strong>'/'</strong>.</p>

<pre class="brush: php">
english_to_db_format('01/01/2010', 12, 10, 0);
// returns <?php 
echo english_to_db_format('01/01/2010', 12, 10, 0);
?>
</pre>


<h2>format_db_date(<var>[y]</var>, <var>[m]</var>, <var>[d]</var>, <var>[h]</var>, <var>[i]</var>, <var>[s]</var>)</h2>
<p>Formats a date for the database in (yyyy-mm-dd hh:mm:ss) format. If a value is left out, it will return the current date/time value for that slot.</p>
<pre class="brush: php">
format_db_date(2010, 1, 1, 12, 10, 10);
// returns <?php 
echo format_db_date(2010, 1, 1, 12, 10, 10);
?>
</pre>


<h2>date_range_string(<var>date1</var>, <var>date2</var>)</h2>
<p>Creates a date range string (e.g. January 1-10, 2010).</p>

<pre class="brush: php">
date_range_string('2010-08-01', '2010-08-05');
// returns <?php 
echo date_range_string(time() - 24 * 60 * 60, time());
?>
</pre>

예제 #3
0
function get_bookings_for_export()
{
    global $wpdb;
    $sql = "SELECT booking_no,  p.post_title, room_price, b.date_in, b.date_out, b.no_of_night, b.no_of_room, amount, amount_paid, b.no_of_adult, b.no_of_child,  CONCAT(b.salutation, '. ', b.first_name,' ', b.middle_name, ' ', b.last_name) as guest_name, b.birth_date, b.email_address, b.primary_phone, b.country, b.address_1, b.address_2, b.province, b.city, b.zipcode, b.nationality, b.booking_status, b.payment_status, b.date_booked  FROM " . $wpdb->prefix . "bookings b  JOIN " . $wpdb->prefix . "posts p  ON p.ID = b.room_type_ID WHERE 1 = 1";
    if (($s = browser_request('s')) != '') {
        $sql .= " AND ( booking_no = '" . $s . "' OR p.post_title LIKE '%" . $s . "%' OR b.first_name LIKE '%" . $s . "%' OR b.last_name LIKE '%" . $s . "%' ) ";
    }
    if (($status = browser_request('status')) != '') {
        $sql .= " AND (b.booking_status = '" . $status . "' ) ";
    }
    if (($status = browser_request('filter_payment_status')) != '') {
        $sql .= " AND (b.payment_status = '" . $status . "' ) ";
    }
    if (($room_type_ID = browser_request('filter_room_ID')) != '') {
        $sql .= " AND (b.room_type_ID = '" . $room_type_ID . "' ) ";
    }
    if (($checkin = browser_request('filter_date_in')) != '' && ($checkout = browser_request('filter_date_out')) != '') {
        $sql .= " AND (date_in >= '" . format_db_date($checkin, 'Y-m-d') . "' AND  date_out <= '" . format_db_date($checkout, 'Y-m-d') . "'  ) ";
    }
    $results = $wpdb->get_results($sql, ARRAY_A);
    return $results;
}
예제 #4
0
          terms of the GNU General Public License as
          published by the Free Software Foundation;
          either  version 2 of  the License,  or (at
          your option) any later version.
        ==============================================
*/
define('THWB_NOSESSION_PAGE', true);
function format_db_date($string_date)
{
    if ($string_date == '') {
        $output = "<B>Error :</B> Bad Time String !";
    } else {
        $output = substr($string_date, 8, 2) . "." . substr($string_date, 5, 2) . "." . substr($string_date, 0, 4);
    }
    return $output;
}
include "./inc/header.inc.php";
$Tshowevent = new Template("templates/" . $style['styletemplate'] . "/showevent.html");
if (!isset($event['eventtime']) || !isset($event['eventsubject']) || !isset($event['eventtext'])) {
    die("denied.");
}
// Searching Event
$r_calendar = mysql_query("SELECT calendar.*, user.username FROM " . $pref . "calendar AS calendar LEFT JOIN " . $pref . "user AS user ON calendar.userid=user.userid WHERE eventid = '" . addslashes($event) . "'");
$calendar = mysql_fetch_array($r_calendar);
if ($calendar['userid'] > 0) {
    $calendar['user'] = "******"" . build_link("v_profile.php?user[userid]={$calendar['userid']}") . "\" target=\"_blank\">" . parse_code($calendar['username']) . "</a>{$style['smallfontend']}";
}
$calendar['eventtime'] = format_db_date($calendar['eventtime']);
$calendar['eventsubject'] = parse_code($calendar['eventsubject']);
$calendar['eventtext'] = parse_code($calendar['eventtext'], 1, 1, 1);
eval($Tshowevent->GetTemplate());
예제 #5
0
</pre>

<h2>english_date_to_db_format(<var>date</var>, <var>[hour]</var>, <var>[min]</var>, <var>[sec]</var>, <var>[ampm]</var>, <var>[delimiter]</var>)</h2>
<p>Converts a date from english (e.g. mm/dd/yyyy) to db format (e.g yyyy-mm-dd). The default delimiter parameter is <strong>'/'</strong>.</p>

<pre class="brush: php">
english_date_to_db_format('01/01/2010', 12, 10, 0);
// returns <?=english_date_to_db_format('01/01/2010', 12, 10, 0)?>
</pre>


<h2>format_db_date(<var>[y]</var>, <var>[m]</var>, <var>[d]</var>, <var>[h]</var>, <var>[i]</var>, <var>[s]</var>)</h2>
<p>Formats a date for the database in (yyyy-mm-dd hh:mm:ss) format. If a value is left out, it will return the current date/time value for that slot.</p>
<pre class="brush: php">
format_db_date(2010, 1, 1, 12, 10, 10);
// returns <?=format_db_date(2010, 1, 1, 12, 10, 10)?>
</pre>


<h2>date_range_string(<var>date1</var>, <var>date2</var>)</h2>
<p>Creates a date range string (e.g. January 1-10, 2010).</p>

<pre class="brush: php">
date_range_string('2010-08-01', '2010-08-05');
// returns <?=date_range_string((time() - (24*60*60)), time())?>
</pre>


<h2>pretty_date(<var>timestamp</var>, <var>use_gmt</var>)</h2>
<p>Creates a string based on how long from the current time the date provided.</p>
예제 #6
0
 /**
  * custom_init()
  * 
  * Process booking post data
  * 
  * @param none
  * @return none
  */
 public function custom_init()
 {
     $action = browser_request('action');
     if ($action != '') {
         switch ($action) {
             case 'check_availability':
                 $data = $_POST;
                 push_to_booking_session(array('date_in' => array_data($data, 'date_in', date('Y-m-d')), 'date_out' => array_data($data, 'date_out', add_days_to_date(date('Y-m-d'), 1)), 'no_of_adult' => array_data($data, 'no_of_adult', 1), 'no_of_room' => array_data($data, 'no_of_room', 0), 'type' => 'BOOKING', 'no_of_child' => array_data($data, 'no_of_child', 0)));
                 redirect_by_page_path('rooms');
                 break;
             case 'book_room':
                 $data = $_POST;
                 if (array_data($data, 'room_type_ID', '') == '' || !is_bookable($data['room_type_ID'])) {
                     add_this_notices('error', 'Selected room is Out of Order.');
                     return;
                 }
                 if (is_date_and_room_not_available($data['room_type_ID'], format_db_date($data['date_in']), format_db_date($data['date_out']))) {
                     return;
                 }
                 if (!has_sufficient_room($data)) {
                     return;
                 }
                 $nights = count_nights($data['date_in'], $data['date_out']);
                 $room_price = get_room_price_with_nights($data['room_type_ID'], $data['date_in'], $data['date_out']);
                 $total_amount = calculate_total_amount($data['room_type_ID'], $data['date_in'], $data['date_out'], $data['no_of_room']);
                 push_to_booking_session(array('date_in' => $data['date_in'], 'date_out' => $data['date_out'], 'no_of_adult' => $data['no_of_adult'], 'no_of_child' => array_data($data, 'no_of_child', 0), 'room_type_ID' => $data['room_type_ID'], 'no_of_night' => $nights, 'no_of_room' => $data['no_of_room'], 'room_price' => $room_price, 'amount' => $total_amount, 'booking_ID' => 0, 'amount_paid' => 0, 'payment_status' => PAYMENT_DEFAULT_STATUS, 'booking_status' => BOOKING_DEFAULT_STATUS));
                 redirect_by_page_path('review');
                 break;
             case 'make_reservation':
                 if (is_empty_booking()) {
                     add_this_notices('error', 'Please select date.');
                     redirect_by_page_path('/');
                     return;
                 }
                 $data = get_booking_session();
                 if (!is_bookable($data['room_type_ID'])) {
                     add_this_notices('error', 'Selected room is Out of Order.');
                     return;
                 }
                 $data = push_to_booking_session(array_merge($data, $_POST, array('date_booked' => date('Y-m-d H:i:s'))));
                 if ($this->process($data)) {
                     redirect_by_page_path('success');
                 }
                 break;
             case 'save_booking':
                 if (isset($_POST['save_booking_field']) && wp_verify_nonce($_POST['save_booking_field'], 'save_booking_action')) {
                     $info = get_booking_by_id(browser_request('bid', 0));
                     $post = array_merge((array) $info, $_POST);
                     $post['no_of_night'] = count_nights($post['date_in'], $post['date_out']);
                     $post['room_price'] = get_room_price_with_nights($post['room_type_ID'], $post['date_in'], $post['date_out']);
                     $post['amount'] = calculate_total_amount($post['room_type_ID'], $post['date_in'], $post['date_out'], $post['no_of_room']);
                     $post['date_booked'] = array_data($info, 'date_booked', date('Y-m-d H:i:s'));
                     $post['type'] = 'RESERVATION';
                     $post['room_code'] = room_code($post['room_type_ID']);
                     if (($bid = $this->process($post)) != false) {
                         exit(wp_redirect('admin.php?page=edit-booking&bid=' . $bid));
                     }
                 }
                 break;
             case 'export-bookings':
                 $results = get_bookings_for_export();
                 // When executed in a browser, this script will prompt for download
                 // of 'test.xls' which can then be opened by Excel or OpenOffice.
                 require_class('php-export-data.class.php');
                 // 'browser' tells the library to stream the data directly to the browser.
                 // other options are 'file' or 'string'
                 // 'test.xls' is the filename that the browser will use when attempting to
                 // save the download
                 $exporter = new ExportDataExcel('browser', 'reports.xls');
                 $exporter->initialize();
                 // starts streaming data to web browser
                 $exporter->addRow(array('BOOKING NO', 'ROOM TYPE', 'ROOM PRICE', 'CHECK IN', 'CHECK OUT', 'NO OF NIGHTS', 'NO OF ROOMS', 'TOTAL AMOUNT', 'AMOUNT PAID', 'NO OF ADULT', 'NO OF CHILD', 'BOOKED BY', 'BIRTHDATE', 'EMAIL ADDRESS', 'PHONE', 'COUNTRY', 'ADDRESS 1', 'ADDRESS 2', 'PROVINCE', 'CITY', 'ZIPCODE', 'NATIONALITY', 'BOOKING STATUS', 'PAYMENT STATUS', 'DATE BOOKED'));
                 foreach ($results as $i => $r) {
                     // pass addRow() an array and it converts it to Excel XML format and sends
                     // it to the browser
                     $exporter->addRow($r);
                 }
                 $exporter->finalize();
                 // writes the footer, flushes remaining data to browser.
                 exit;
                 // all done
                 break;
         }
     }
 }
예제 #7
0
function is_date_and_room_not_available($room_ID, $from, $to, $booking_ID = 0)
{
    $range = get_dates_from_date_range($from, $to);
    foreach ($range as $i => $k) {
        if (is_selected_date_and_room_not_available($room_ID, format_db_date($k), $booking_ID) > 0) {
            add_this_notices('error', 'Selected room is not available on that date. Please check calendar to see availability.');
            return true;
        }
    }
    return false;
}