简体   繁体   中英

jQuery booking calendar

I need a calendar for booking.
I made this calendar but this is not workinf correctly
Example: http://bestinvest.ge/?view=10

Can anyone help me with booking calendar?

I need 3 statuses in the Calender

Reserved, Pending, Free

And when I click from [free][res][res][res][res][free] first Free and again click last free I want javascript to give an error:

"You must only choose free periods, your chosen period includes reserved dates."

I know I have an error in my PHP file but I can't find where:

function getmonthdays($m,$y) {
 return cal_days_in_month(CAL_GREGORIAN, $m, $y);
}

   <?php 
    for($i = 1; $i <= 31; $i++) {
        if($i <10) { $day = "0".$i; }else { $day = $i; }
    echo "<th>". $day . "</th>";
    } ?>
    </tr>
    <?php 
    $thismonth = date("m");
    $thisyear = date("Y");
    $nextyear = date("Y",strtotime("+1 year"));
    $countmonths = getmonthcount("$thismonth");
    $tdid=0;
    for($i = $thismonth; $i <= 12; $i++) {

    echo "<tr><td class='month'>". getmonth($i) ."</td>";
        for($x = 1; $x <= getmonthdays($i,$thisyear); $x++) {
            $tdid++;
        echo "<td id='cl". $tdid ."' class='". checkav($thisyear,$i,$x) ."' alt='$thisyear-". $i ."-". $x ."'></td>";
        }
    echo "</tr>";
    }
     ?>

Instead of hard coding a calendar structure in PHP, its much more versatile to create the calendar in Javascript/jQuery and set the beginning of the calendar to the current month.

Generating the calendar client side in the browser is lightweight and more responsive. Load the current bookings via AJAX from the site server into the calendar and also insert new bookings via a form submit (AJAX) back to the server, with a round trip refresh of the updated bookings from the Server database.

See my full code example on StackOverlow here with my answer to my dateformat issue: JavaScript Render Logic : Horizontal Dynamic Booking Calendar

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM