$sql = "SELECT *, h.id AS holidayid FROM `{$dbHolidays}` AS h, `{$dbUsers}` AS u "; $sql .= "WHERE h.userid = u.id AND h.type={$type} "; if (!empty($user) and $user != 'all') { $sql .= "AND u.id='{$user}' "; } $sql .= "ORDER BY date DESC"; $result = mysql_query($sql); if (mysql_error()) { trigger_error("MySQL Query Error " . mysql_error(), E_USER_WARNING); } if (mysql_num_rows($result)) { echo "<table align='center'>"; echo "<tr><th>{$GLOBALS['strType']}</th><th>{$GLOBALS['strUser']}</th><th>{$GLOBALS['strDate']}</th><th>{$GLOBALS['strStatus']}</th><th>{$GLOBALS['strOperation']}</th></tr>\n"; $shade = 'shade1'; while ($dates = mysql_fetch_array($result)) { echo "<tr class='{$shade}'><td>" . holiday_type($dates['type']) . "</td>"; echo "<td>{$dates['realname']}</td>"; echo "<td>" . date('l jS F Y', mysql2date($dates['date'])); if ($dates['length'] == 'am') { echo " {$strMorning}"; } if ($dates['length'] == 'pm') { echo " {$strAfternoon}"; } echo "</td>"; echo "<td>"; if (empty($dates['approvedby'])) { echo " <em>{$strNotRequested}</em>"; } else { echo "<strong>" . holiday_approval_status($dates['approved']) . "</strong>"; }
echo "{$selectedday}/{$selectedmonth}/{$selectedyear} is "; switch ($length) { case 'am': echo "selected for the <strong>morning"; break; case 'pm': echo "selected for the <strong>afternoon"; break; case 'day': echo "selected for the <strong>full day"; break; default: echo "<strong>not selected"; } echo "</strong> "; echo " as " . holiday_type($type) . ". "; if ($approved == 0) { switch ($length) { // FIXME i18n ALL these case 'am': echo "You can make it <a href='holiday_add.php?type={$type}&user={$user}&year={$selectedyear}&month={$selectedmonth}&day={$selectedday}&length=pm'>the afternoon instead</a>, or select the <a href='holiday_add.php?type={$type}&user={$user}&year={$selectedyear}&month={$selectedmonth}&day={$selectedday}&length=day'>full day</a>. "; break; case 'pm': echo "You can make it <a href='holiday_add.php?type={$type}&user={$user}&year={$selectedyear}&month={$selectedmonth}&day={$selectedday}&length=am'>the morning</a> instead, or select the <a href='holiday_add.php?type={$type}&user={$user}&year={$selectedyear}&month={$selectedmonth}&day={$selectedday}&length=day'>full day</a>. "; break; case 'day': echo "You can make it <a href='holiday_add.php?type={$type}&user={$user}&year={$selectedyear}&month={$selectedmonth}&day={$selectedday}&length=am'>the morning</a>, or <a href='holiday_add.php?type={$type}&user={$user}&year={$selectedyear}&month={$selectedmonth}&day={$selectedday}&length=pm'>the afternoon</a> instead. "; } if ($length != '0') { echo "Or you can <a href='holiday_add.php?type={$type}&user={$user}&year={$selectedyear}&month={$selectedmonth}&day={$selectedday}&length=0'>deselect</a> it. "; echo "<a href='calendar.php?type={$type}&user={$user}' title='Clear this message'>Okay</a>.";
function display_holiday_table($result) { global $CONFIG, $user, $approver, $mode, $sit; echo "<table align='center'>"; echo "<tr>"; if ($user == 'all' && $approver == TRUE) { echo "<th>{$GLOBALS['strName']}</th>"; } echo "<th>{$GLOBALS['strDate']}</th><th>{$GLOBALS['strLength']}</th><th>{$GLOBALS['strType']}</th>"; if ($approver and $mode == 'approval') { echo "<th>{$GLOBALS['strOperation']}</th><th>{$GLOBALS['strGroupMembersAway']}</th>"; } // else // { // echo "<th>{$GLOBALS['strStatus']}</th>"; // } echo "</tr>"; while ($holiday = mysql_fetch_object($result)) { echo "<tr class='shade2'>"; if ($user == 'all' && $approver == TRUE) { echo "<td><a href='{$_SERVER['PHP_SELF']}?user={$holiday->userid}&mode=approval'>"; echo user_realname($holiday->userid, TRUE); echo "</a></td>"; } echo "<td>" . ldate($CONFIG['dateformat_longdate'], mysql2date($holiday->date, TRUE)) . "</td>"; echo "<td>"; if ($holiday->length == 'am') { echo $GLOBALS['strMorning']; } if ($holiday->length == 'pm') { echo $GLOBALS['strAfternoon']; } if ($holiday->length == 'day') { echo $GLOBALS['strFullDay']; } echo "</td>"; echo "<td>" . holiday_type($holiday->type) . "</td>"; if ($approver == TRUE) { if ($sit[2] != $holiday->userid and $mode == 'approval') { echo "<td>"; $approvetext = $GLOBALS['strApprove']; if ($holiday->type == HOL_SICKNESS) { $approvetext = $GLOBALS['strAcknowledge']; } echo "<a href=\"holiday_approve.php?approve=TRUE&user={$holiday->userid}&view={$user}&startdate={$holiday->date}&type={$holiday->type}&length={$holiday->length}\">{$approvetext}</a> | "; echo "<a href=\"holiday_approve.php?approve=FALSE&user={$holiday->userid}&view={$user}&startdate={$holiday->date}&type={$holiday->type}&length={$holiday->length}\">{$GLOBALS['strDecline']}</a>"; if ($holiday->type == HOL_HOLIDAY) { echo " | <a href=\"holiday_approve.php?approve=FREE&user={$holiday->userid}&view={$user}&startdate={$holiday->date}&type={$holiday->type}&length={$holiday->length}\">{$GLOBALS['strApproveFree']}</a>"; } echo "</td>"; } else { echo "<td>"; if ($holiday->approvedby > 0) { echo sprintf($GLOBALS['strRequestSentToX'], user_realname($holiday->approvedby, TRUE)); } else { echo $GLOBALS['strRequestNotSent']; $waiting = TRUE; } echo "</td>"; } if ($approver == TRUE and $mode == 'approval') { echo "<td>"; echo check_group_holiday($holiday->userid, $holiday->date, $holiday->length); echo "</td>"; } } echo "</tr>\n"; } echo "</table>\n"; }
$daynumber = 1; $options = 0; // if ($end==$start) $end += 86400; // ensure we still loop for single day bookings by setting end to next day for ($day = $start; $day < $end; $day = $day + 86400) { if (date('D', $day) != 'Sat' && date('D', $day) != 'Sun') { $sql = "SELECT * FROM `{$dbHolidays}` WHERE `date` = FROM_UNIXTIME({$day}, '%Y-%m-%d') AND userid={$user}"; $result = mysql_query($sql); if (mysql_error()) { trigger_error("MySQL Query Error " . mysql_error(), E_USER_WARNING); } // need to do something different when there are more than one row if (mysql_num_rows($result) > 0) { while ($existing_holiday = mysql_fetch_array($result)) { $holiday_type = holiday_type($existing_holiday['type']); $holiday_legend = strtoupper(substr($holiday_type, 0, 1)); echo "<tr>"; echo "<td class='shade2' align='right'> " . ldate('l jS M y', $day) . " </td>"; echo "<td class='shade1' align='center'>"; if ($existing_holiday['length'] == 'day') { echo "<input type='radio' name='dummy{$daynumber}' value='day' disabled='disabled' />"; } else { echo "<input type='radio' name='length{$daynumber}' value='none' checked='checked' />"; } echo "</td>"; echo "<td class='shade1' align='center'>"; if ($existing_holiday['length'] == 'day') { echo $holiday_legend; } else { echo "<input type='radio' name='dummy{$daynumber}' value='day' disabled='disabled' />";