vijayram 0 Newbie Poster

Hey everyone.

the following are my jquery coding.i maked the code for user onclick the schedule date display schedule.what is the error for following code.onlick no display event.

plz help me.

correct the code.

$(document).ready(function(){

    $(".calendar").click(function() {

        if ($(this).attr('days')) {

            $.ajax({
                url: $("#url_view_schedule").val(),
                data: "personalId="+$("#personal_id").val()+"&day="+$(this).attr("days"),
                dataType: "json",
                success: function(list) {
                    events = list["events"];
                    notes = list["notes"];

                    if (events.length != 0 || notes.length != 0) {
                        $("#schedule").show();

                        var html = "";
                        var event, itinerary, time_print;

                        for (key in events) {
                            event = events[key];
                            html += 
                                "<div class='event-item'>" +
                                    "<div class='float-left border-right text-align-center' style='min-height:265.5px;width:238px;'>" +
                                        "<br />" +
                                        "<img src='" + $("#url_personal_image_display").val().replace(/PRIMARY_ALBUM_ID/g, event["primary_album_id"]).replace(/PROFILE_PICTURE/g, event["profile_picture"]) + "' alt='" + event["full_name"] + "' style='width:160px;' /><br />" +
                                        "About the PLAN:<br /><br />" +
                                        event["description"] +
                                    "</div>" +
                                    "<div class='float-left text-align-center' style='width:250px;'>" +
                                        "<br />" +
                                        event["personal_full_name"] + "'s Event<br />" +
                                        event["type_reformat"] + " - " + event["title"] + "<br /><br />";

                            for (key2 in event["itineraries"]) {
                                itinerary = event["itineraries"][key2];
                                html += itinerary["time_reformat"] + "<br />" +
                                        itinerary["occasion"] + " @ " + itinerary["place"] + "<br /><br />";
                            }

                            html += "</div>" +
                                    "<div class='float-left border-left text-align-center' style='width:260px;'>" +
                                        "People Attending:<br />" +
                                        "<div id='friend-list' class='text-align-left' style='min-height:250px;overflow-y:scroll;'>";

                            for (key2 in event["friends"]) {
                                friend = event["friends"][key2];
                                html +=     "<a href='" + $("#url_personal_homepage").val() + "?personal_id=" + friend["id"] + "'>" +
                                                "<img src='" + $("#url_personal_image_display").val().replace(/PRIMARY_ALBUM_ID/g, friend["primary_album_id"]).replace(/PROFILE_PICTURE/g, friend["profile_picture"]) + "' alt='" + friend["full_name"] + "' style='width:80px;' />" +
                                            "</a> ";
                            }

                            html +=     "</div>" +
                                    "</div>" +
                                    "<div class='clear-both'></div>" +
                                "</div>"
                                ;
                        }

                        html += "<div class='clear-both'><h1 class='title'>Your Note(s)</h1></div>";

                        for (key in notes) {
                            note = notes[key];
                            time_print = "";
                            if (note["time"] != null) time_print = note["time"] + "<br />";

                            html += 
                                "<div id='note-item-" + note["id"] + "' class='note-item text-align-center' style='width:100px;'>" +
                                    note["subject"] + "<br />" +
                                    time_print +
                                    note["place"] + "<br />" +
                                    note["description"] + "<br />" +
                                    "<a href='#note' onclick='editNote(\"" + note["id"] + "\")'>[Edit Note]</a>" +
                                    "<div class='clear-both'></div>" +
                                    "<input type='hidden' id='note-subject-" + note["id"] + "' value='" + note["subject"] + "'>" +
                                    "<input type='hidden' id='note-date-" + note["id"] + "' value='" + note["date"] + "'>" +
                                    "<input type='hidden' id='note-time-" + note["id"] + "' value='" + note["time"] + "'>" +
                                    "<input type='hidden' id='note-place-" + note["id"] + "' value='" + note["place"] + "'>" +
                                    "<textarea style='display:none' id='note-description-" + note["id"] + "'>" + note["description"] + "</textarea>" +
                                "</div>"
                            ;
                        }

                        $("#event-list").html(html)
                    }
                    else {
                        alert("No event on that date.");
                    }
                },
                error: function(xhr) {
                    alert ("Ooops... something has gone wrong when we try to view MySchedule.");
                }


            });

        }


    });



php code

<?php use_javascript('schedule') ?>
<?php use_javascript("editProfile") ?>
<?php slot("js") ?>
<script type="text/javascript">
$(document).ready(function () {
  $('.calendar').load('schedule');
});

function prev_month(month, year) {
if(month-1=='0')
{
  month = 13;
  year = year-1;
}
  $.ajax({url:("#schedule"),
    data:'month='+ (month-1) +'&year=' + year,
    dataType: 'html',
    success: function (data) {
      $('.calendar').html(data);
    }
  });
}
function next_month(month, year) {
if(month+1=='13')
{
  month = 0;
  year = year + 1;
}
  $.ajax({url:("#schedule"),
    data:'month='+ (month+1) +'&year=' + year,
    dataType: 'html',
    success: function (data) {
      $('calendar').html(data);
    }
  });
   url: $("#url_view_schedule")
}
</script>
<div id="calendar" >

        <h1 class="title" style="float:left;">MyPlan</h1>&nbsp&nbsp;

    </div>
     <div id="unfinishedbussiness" >
    <div style="float:left"></div>

    <a href="<?php echo url_for("@make_note")?>">UnfinishedBussiness</a>
    </div>
          <div class="clear-both"></div>



   <?php   





      $month = date('m', time());
$year = date('Y', time());
$calendar = getCalendar($month,$year);

function getCalendar($month,$year)
{
    // Use the PHP time() function to find out the timestamp for the current time
    $current_time = time();

    // Get the first day of the month
    $month_start = mktime(0,0,0,$month, 1, $year); 

    // Get the name of the month
    $month_name = date('F', $month_start); 

    // Figure out which day of the week the month starts on.
    $first_day = date('D', $month_start);

    // Assign an offset to decide which number of day of the week the month starts on.
    switch($first_day)
    {
    case "Sun":
        $offset = 0;
        break;
    case "Mon":
        $offset = 1;
        break;
    case "Tue":
        $offset = 2;
        break;
    case "Wed":
        $offset = 3;
        break;
    case "Thu":
        $offset = 4;
        break;
    case "Fri":
        $offset = 5;
        break;
    case "Sat":
        $offset = 6;
        break;
    } 

    // determine how many days were in last month.
    //  Note: The cal_days_in_month() function returns the number of days in a month for the specified year and calendar.

    if($month == 1)
        $num_days_last = cal_days_in_month(CAL_GREGORIAN, 12, ($year -1));
    else
        $num_days_last = cal_days_in_month(CAL_GREGORIAN, ($month - 1), $year);

    // determine how many days are in the this month.
    $num_days_current = cal_days_in_month(CAL_GREGORIAN, $month, $year); 

    // Count through the days of the current month -- building an array
    for($i = 0; $i < $num_days_current; $i++)
    {
        $num_days_array[] = $i+1;
    } 



    // Count through the days of last month -- building an array
    for($i = 0; $i < $num_days_last; $i++)
    {
        $num_days_last_array[] = '';
    }

    if($offset > 0){ 
        $offset_correction = array_slice($num_days_last_array, -$offset, $offset);
        $new_count = array_merge($offset_correction, $num_days_array);
        $offset_count = count($offset_correction);
    }
    else
    { 
        $new_count = $num_days_array;
    }

    // How many days do we now have?
    $current_num = count($new_count); 

    // Our display is to be 35 cells so if we have less than that we need to dip into next month
    if($current_num > 35)
    {
        $num_weeks = 6;
        $outset = (42 - $current_num);
    }
    else if($current_num < 35)
    {
        $num_weeks = 5;
        $outset = (35 - $current_num);
    }
    if($current_num == 35)
    {
        $num_weeks = 5;
        $outset = 0;
    }

    // Outset Correction
    for($i = 1; $i <= $outset; $i++)
    {
        $new_count[] = '';
    }

    // Now let's "chunk" the $new_count array
    // into weeks. Each week has 7 days
    // so we will array_chunk it into 7 days.
    $weeks = array_chunk($new_count, 7);

    // Start the output buffer so we can output our calendar nicely
    ob_start();

    $last_month = $month == 1 ? 12 : $month - 1;
    $next_month = $month == 12 ? 1 : $month + 1;

    // Build the heading portion of the calendar table
    echo <<<EOS
    <table id="calendar">
    <tr>
        <td><a href="#" class="monthnav" onclick="prev_month(month, year);return false;"> << Prev</a></td>
        <td colspan=5 class="month">$month_name $year</b></td>
        <td><a href="#" class="monthnav" onclick="next_month(month, year);return false;">Next >></a></td>
    </tr>
    <tr class="daynames"> 
        <td>S</td><td>M</td><td>T</td><td>W</td><td>T</td><td>F</td><td>S</td>
    </tr>
EOS;

    foreach($weeks AS $week){
        echo '<tr class="week">'; 
        foreach($week as $day)
        {
            if($day == date('d', $current_time) && $month == date('m', $current_time) && $year == date('Y', $current_time))
                echo '<td class="today">'.$day.'</td>';
            else
                echo '<td class="days">'.$day.'</td>';
        }
        echo '</tr>';
    }

    foreach($scheduleDates as $scheduleDate){
    echo '<tr class="scheduleDate>';
      foreach($scheduleDate as $day)
      {
       if($day==date('d',$current_time) && $month==date('m',$current_time) && $year==date('Y',$current_time))
        echo' <td class="scheduleDate">'.$day.'</td>';
    }
    echo '</tr>';
    }
    foreach($noteDates as $noteDate){
    echo '<tr class="noteDate>';
      foreach($noteDate as $day)
      {
       if($day==date('d',$current_time) && $month==date('m',$current_time) && $year==date('Y',$current_time))
        echo '<td class="noteDate">'.$day.'</td>';
    }
    echo '</tr>';
    }

    echo '</table>';

    return ob_get_clean();
}

?>

<div id="calendar" style=" width: 500px;"> <div style="float:right"></div><?php echo @$calendar ?></div>

<h1 class="title" style="float:left;"><?php echo date("d  'F 'y") ?></h1><br>  <br>

<div class="clear-both"></div>



<div id="schedule" style="display:none;">
     <a onclick="closeSchedule()" class="float-right">[Close]</a>
          <div class="clear-both"></div>
    <div id="event-list"></div>
    </div>


<div class="clear-both"></div>

<div id="note">
    <?php if($sf_user->hasFlash("notice_make_note")): ?>
        <div class="notice"><?php echo $sf_user->getFlash("notice_make_note") ?><?php echo $sf_user->setFlash("notice_make_note","") ?></div>
    <?php endif?>
    <form id="note-form" action="<?php echo url_for("@make_note") ?>" method="post">
        <h1 id="note-title" class="title">ADD NOTE</h1><br>
        </hr>
        <div class="field">
            <span class="field-label">*Subject:</span>
            <input id="note_subject" name="note[subject]" value="<?php if (isset($note["subject"])) echo $note["subject"] ?>" />
            <span id="note_subject_error" class="field-error"><?php if (isset($error["subject"])) echo $error["subject"] ?></span>
        </div>
        <div class="field">
            <span class="field-label">*Date:</span>
            <select id="note_day" name="note[day]">
                <option value="">[DD]</option>
                <?php for ($i = 1; $i <= 31; $i++): ?>
                <?php $display = $i < 10 ? "0" . $i : $i ?>
                <option value="<?php echo $display ?>" <?php if (isset($note["day"]) && $note["day"] == $display) echo "selected" ?>><?php echo $i ?></option>
                <?php endfor; ?>
            </select>
            /
            <select id="note_month" name="note[month]" class="js-date-select">
                <option value="">[MM]</option>
                <?php for ($i = 1; $i <= 12; $i++): ?>
                <?php $display = $i < 10 ? "0" . $i : $i ?>
                <option value="<?php echo $display ?>" <?php if (isset($note["month"]) && $note["month"] == $display) echo "selected" ?>><?php echo $i ?></option>
                <?php endfor; ?>
            </select>
            /
            <select id="note_year" name="note[year]" class="js-date-select">
                <option value="">[YYYY]</option>
                <?php for ($i = date("Y"); $i < intval(date("Y"))+10; $i++): ?>
                <option value="<?php echo $i ?>" <?php if (isset($note["year"]) && $note["year"] == $i) echo "selected" ?>><?php echo $i ?></option>
                <?php endfor; ?>
            </select>
            <span id="note_date_error" class="field-error"><?php if (isset($error["date"])) echo $error["date"] ?></span>
        </div>
        <div class='field'>
            <span class="field-label">Time:</span>
            <select id="note_hour" name="note[hour]">
                <option value="">[Hour]</option>
                <?php for ($i=0;$i<24;$i++): ?>
                    <?php $display = $i < 10 ? "0" . $i : $i ?>
                    <option value="<?php echo $display ?>" <?php if (isset($note["hour"]) && $note["hour"] == $display . "") echo "selected" ?>><?php echo $display ?></option>
                <?php endfor ?>
            </select>
            :
            <select id="note_minute" name="note[minute]">
                <option value="">[Minute]</option>
                <?php for ($i=0;$i<60;$i+=5): ?>
                    <?php $display = $i < 10 ? "0" . $i : $i ?>
                    <option value="<?php echo $display ?>" <?php if (isset($note["minute"]) && $note["minute"] == $display . "") echo "selected" ?>><?php echo $display ?></option>
                <?php endfor ?>
            </select>
            <span id="note_time_error" class="field-error"><?php if (isset($error["time"])) echo $error["time"] ?></span>
        </div>
        <div class="field">
            <span class="field-label">Place:</span>
            <input id="note_place" name="note[place]" value="<?php if (isset($note["place"])) echo $note["place"] ?>" />
        </div>
        <div class="field">
            <span class="field-label">Description:</span>
            <textarea id="note_description" name="note[description]" rows="5" cols="40"><?php if (isset($note["description"])) echo $note["description"] ?></textarea>
        </div>
        <a onClick="cleanNote()">[Clean Note]</a>
        <input type="image" alt="[Make Note]" />
        <input type="hidden" id="note_id" name="note[id]" value="<?php echo $note["id"] ?>" />
    </form>
</div>



<input type="hidden" id="personal_id" value="<?php echo $personal->getId() ?>" />
<input type="hidden" id="url_view_schedule" value="<?php echo url_for("url_view_schedule") ?>" />
<input type="hidden" id="url_personal_homepage" value="<?php echo url_for("@personal_homepage") ?>" />
<input type="hidden" id="url_personal_image_display" value="<?php echo url_for("@personal_image_display?type=".PictureTable::FOLDER_THUMB."&albumId_thumbName=PRIMARY_ALBUM_ID_PROFILE_PICTURE", true); ?>" />
<input type="hidden" id="select_date_id" value="note" />