Exemple #1
0
<select name="branch" onChange="document.filter.submit()">
' . $render_branch . '</select>
<select name="type" onChange="document.filter.submit()">
' . $render_type . '</select>
<select name="user" onChange="document.filter.submit()">
' . $render_user . '</select>';
foreach ($to_pass as $key => $val) {
    if ($key == 'branch' || $key == 'type' || $key == 'user') {
    } else {
        $render_left .= '<input type="hidden" name="' . $key . '" value="' . $val . '" />' . "\n";
    }
}
$render_left .= '
</form>
</div>
<div id="calTitleDate"><a href="' . $calendar_url . '" target="cal_iframe" title="Click to refresh calendar">' . date('l, jS \\of F Y', $Day->getTimeStamp()) . '</a></div>
' . $alldayapps . '
<div class="calendar-container" id="calendar-container"><script type="text/javascript">writeCal(\'' . $calendar_url . '\');</script></div>
';
// month browse and navigation
$render_right = '
  <div id="calMonthBrowse">
	<table align="center" cellspacing="0" cellpadding="0">
	<tr>
	<td class="calMonthSelect">
	<a href="?' . replaceQueryStringArray($query_string, array('d', 'm', 'y', 'app_highlight', 'jumpto')) . '&amp;y=' . $navPrevYear . '&amp;m=' . $Month->prevMonth() . '&amp;d=' . $Month->thisDay() . '" title="Previous Month">&laquo;</a>
	</td>
	<td colspan="5" class="calMonthSelect">
	  <form method="GET" name="monthBrowse">
		<select name="m" style="width:50px" onChange="document.monthBrowse.submit();">';
foreach ($months_short as $number => $title) {
        $end = $end[1];
        $first_app = strtotime($row['app_start']) - $daybegin;
        $start_pixel = $first_app / 60 * $zoom;
        $divs[] = array('id' => $row['followUpAppointmentId'] ?: $row['app_id'], 'start_stamp' => strtotime($row['app_start']), 'end_stamp' => strtotime($row['app_end']), 'start_offset' => round_to_nearest($start_time, 15) * $zoom, 'start' => date('H:i', strtotime(substr($start, 0, -3))), 'end' => date('H:i', strtotime(substr($end, 0, -3))), 'duration' => $duration, 'start_pixel' => $start_pixel, 'end_pixel' => $start_pixel + $duration * $zoom, 'app_height' => $duration * $zoom, 'colour' => $row['use_colour'], 'type' => $row['app_type'], 'subtype' => $row['ity_title'], 'notetype' => $row['app_notetype'], 'client' => $cli_name, 'addr' => str_replace("  ", " ", $pro_addr), 'tel' => $row['tel_number'], 'user' => $row['use_name'], 'contact' => $row['con_name'], 'attendees' => $row['app_attendees'], 'cv' => $row['d2a_cv'], 'subject' => format_overdiv($row['app_subject']), 'notes' => format_overdiv($row['note']), 'private' => $row['app_private'], 'bookedby' => $row['app_bookedby'], 'DIT' => $row['DIT']);
        unset($app_attendees, $use_colour, $pro_addr, $cli_name, $price);
    }
}
//print_r($divs);
// end sql
// need to loop every 15 minutes, consider not using Calendar class for this and going bespoke
$Day->build();
while ($Hour =& $Day->fetch()) {
    // show working hours only
    if (date('H', $Hour->getTimeStamp()) >= $default_workingday_start && date('H', $Hour->getTimeStamp()) <= $default_workingday_end) {
        // highlight current hour slot but only if viewing current day
        if (date('l, jS F, Y', $Day->getTimeStamp()) == date('l, jS F, Y')) {
            if (date('H', $Hour->getTimeStamp()) == date('H')) {
                $class = "calHourNow";
            } else {
                $class = "calHour";
            }
        } else {
            $class = "calHour";
        }
        // make the hour bar
        $hourBar .= '<div class="' . $class . '" style="height: ' . (60 * $zoom - 1) . 'px"><a name="' . date('H', $Hour->getTimeStamp()) . '"></a>' . date('H:', $Hour->getTimeStamp()) . '' . date('i', $Hour->getTimeStamp()) . '</div>' . "\n";
    }
}
/*
how do we match the divs:
if end if larger than start
/**
 * Print a tabular calendar for selecting dates for appointments
 * Based on code from the PEAR package
 *
 * @link http://pear.php.net/package/Calendar PEAR Calendar
 * @link http://pearcalendar.sourceforge.net/examples/3.php Example this code based on
 *
 * @see make_appointment()
 * @see display_time()
 *
 * @param int $respondent_id The respondent id
 * @param int $questionnaire_id The questionnaire id
 * @param bool|int $day the day of the month if selected else false
 * @param bool|int $month the month of the year if selected else false
 * @param bool|int $year the year (4 digit) if selected else false
 *
 */
function display_calendar($respondent_id, $questionnaire_id, $year = false, $month = false, $day = false)
{
    global $db;
    /**
     * PEAR Caldendar Weekday functions
     */
    include_once 'Calendar/Month/Weekdays.php';
    /**
     * PEAR Caldendar Day functions
     */
    include_once 'Calendar/Day.php';
    /**
     * See if questionnaire has shift restrictions
     */
    $restricted = is_shift_restricted($questionnaire_id);
    $rtime = strtotime(get_respondent_time($respondent_id));
    $y = date('Y', $rtime);
    $m = date('m', $rtime);
    $d = date('d', $rtime);
    if (!$year) {
        $year = $y;
    }
    if (!$month) {
        $month = $m;
    }
    if (!$day) {
        $day = $d;
    }
    $ttoday = new Calendar_Day($y, $m, $d);
    $Month = new Calendar_Month_Weekdays($year, $month);
    // Construct strings for next/previous links
    $PMonth = $Month->prevMonth('object');
    // Get previous month as object
    $prev = '?y=' . $PMonth->thisYear() . '&amp;m=' . $PMonth->thisMonth() . '&amp;d=' . $PMonth->thisDay() . '&amp;respondent_id=' . $respondent_id;
    $NMonth = $Month->nextMonth('object');
    $next = '?y=' . $NMonth->thisYear() . '&amp;m=' . $NMonth->thisMonth() . '&amp;d=' . $NMonth->thisDay() . '&amp;respondent_id=' . $respondent_id;
    // Build the days in the month
    $Month->build();
    print "<table class=\"calendar table-hover table-condensed text-center\">";
    print "<caption class=\"text-center text-primary\"><b>" . T_(date('F Y', $Month->getTimeStamp())) . "</b></caption>\r\n\t\t\t\t<thead style=\"font-weight: bolder;\">\r\n\t\t\t\t<tr>\r\n\t\t\t\t\t<td style=\"width: 50px;\">" . T_("Mon") . "</td>\r\n\t\t\t\t\t<td style=\"width: 50px;\">" . T_("Tue") . "</td>\r\n\t\t\t\t\t<td style=\"width: 50px;\">" . T_("Wed") . "</td>\r\n\t\t\t\t\t<td style=\"width: 50px;\">" . T_("Thu") . "</td>\r\n\t\t\t\t\t<td style=\"width: 50px;\">" . T_("Fri") . "</td>\r\n\t\t\t\t\t<td style=\"width: 50px;\">" . T_("Sat") . "</td>\r\n\t\t\t\t\t<td style=\"width: 50px;\">" . T_("Sun") . "</td>\r\n\t\t\t\t</tr></thead>";
    while ($Day = $Month->fetch()) {
        // Build a link string for each day
        $link = '?y=' . $Day->thisYear() . '&amp;m=' . $Day->thisMonth() . '&amp;d=' . $Day->thisDay() . '&amp;respondent_id=' . $respondent_id;
        $today = "";
        if ($year == $Day->thisYear() && $month == $Day->thisMonth() && $day == $Day->thisDay()) {
            $today = "today";
        }
        // isFirst() to find start of week
        if ($Day->isFirst()) {
            echo "<tr>\n";
        }
        if ($Day->isSelected()) {
            echo "<td class=\"selected {$today}\">" . $Day->thisDay() . "</td>\n";
        } else {
            if ($Day->isEmpty()) {
                echo "<td>&nbsp;</td>\n";
            } else {
                //if it is in the past -> unavailable
                if ($Day->getTimeStamp() < $ttoday->getTimeStamp()) {
                    echo "<td style=\"color:grey;\" class=\"notavailable\">" . $Day->thisDay() . "</td>\n";
                } else {
                    if ($restricted) {
                        $rs = $db->Execute("    SELECT s.shift_id\r\n\t\t\t\t\t\tFROM shift as s\r\n\t\t\t\t\t\tLEFT JOIN respondent as r on (r.respondent_id = '{$respondent_id}')\r\n\t\t\t\t\t\tWHERE s.questionnaire_id = '{$questionnaire_id}'\r\n\t\t\t\t\t\tAND DAY(CONVERT_TZ(s.start,'UTC',r.Time_zone_name)) = '{$Day->thisDay()}'\r\n\t\t\t\t\t\tAND MONTH(CONVERT_TZ(s.start,'UTC',r.Time_zone_name)) = '{$Day->thisMonth()}'\r\n\t\t\t\t\t\tAND YEAR(CONVERT_TZ(s.start,'UTC',r.Time_zone_name)) = '{$Day->thisYear()}'");
                        if (!empty($rs) && $rs->RecordCount() == 0) {
                            echo "<td style=\"color:grey;\" class=\"notavailable {$today}\">" . $Day->thisDay() . "</td>\n";
                        } else {
                            echo "<td class=\"{$today}\"><a class=\"btn-primary btn-block \" href=\"" . $link . "\"><b>" . $Day->thisDay() . "</b></a></td>\n";
                        }
                    } else {
                        echo "<td class=\"{$today}\"><a class=\"btn-primary btn-block \" href=\"" . $link . "\"><b>" . $Day->thisDay() . "</b></a></td>\n";
                    }
                }
            }
        }
        // isLast() to find end of week
        if ($Day->isLast()) {
            echo "</tr>\n";
        }
    }
    ?>
	<tr>
	<td>
	<a href="<?php 
    echo $prev;
    ?>
" class="prevMonth btn btn-default">&lt;&lt; </a>
	</td>
	<td colspan="5"><?php 
    print "<b class=\"text-primary\">" . date('l j F Y', mktime(0, 0, 0, $month, $day, $year)) . "</b>";
    ?>
</td>
	<td>
	<a href="<?php 
    echo $next;
    ?>
" class="nextMonth btn btn-default"> &gt;&gt;</a>
	</td>
	</tr>
	</table>
	<?php 
}