Ejemplo n.º 1
0
} else {
    $approver = FALSE;
}
if (user_permission($sit[2], 22)) {
    $adminuser = TRUE;
} else {
    $adminuser = FALSE;
}
// Holiday types (for reference)
// 1 = Holiday
// 2 = Sickness
// 3 = Working Away
// 4 = Training
// 5 - Compassionate/Free
// check to see if there is a holiday on this day already, if there is retrieve it
list($dtype, $dlength, $dapproved, $dapprovedby) = user_holiday($user, 0, $year, $month, $day, FALSE);
// allow approver (or admin) to unbook holidays already approved
if ($length == '0' and ($approver == TRUE and ($dapprovedby = $sit[2] or $adminuser == TRUE) or $user == $sit[2] and mysql2date("{$year}-{$month}-{$day}") >= $today)) {
    // Delete the holiday
    $sql = "DELETE FROM `{$dbHolidays}` ";
    $sql .= "WHERE userid='{$user}' AND `date` = '{$year}-{$month}-{$day}' ";
    $sql .= "AND type='{$type}' ";
    if (!$adminuser) {
        $sql .= "AND (approvedby='{$sit[2]}' OR userid={$sit[2]}) ";
    }
    $result = mysql_query($sql);
    // echo $sql;
    if (mysql_error()) {
        trigger_error("MySQL Query Error " . mysql_error(), E_USER_ERROR);
    }
    $dlength = 0;
Ejemplo n.º 2
0
/**
    * @author Ivan Lucas
*/
function draw_calendar($nmonth, $nyear)
{
    global $type, $user, $selectedday, $selectedmonth, $selectedyear, $CONFIG;
    // Get the current date/time for the users timezone
    $timebase = gmmktime() + $timezone * 3600;
    if (!$nday) {
        $nday = date('d', $timebase);
    }
    if (!$nmonth) {
        $nmonth = date('m', $timebase);
    }
    if (!$nyear) {
        $nyear = date('Y', $timebase);
    }
    # get the first day of the week!
    $firstday = date('w', mktime(0, 0, 0, $nmonth, 1, $nyear));
    # have to perform a loop to test from 31 backwards using this
    # to see which is the last day of the month
    $lastday = 31;
    do {
        # This should probably be recursed, but it works as it is
        $monthOrig = date('m', mktime(0, 0, 0, $nmonth, 1, $nyear));
        $monthTest = date('m', mktime(0, 0, 0, $nmonth, $lastday, $nyear));
        if ($monthTest != $monthOrig) {
            $lastday -= 1;
        }
    } while ($monthTest != $monthOrig);
    $monthName = ldate('F', gmmktime(0, 0, 0, $nmonth, 1, $nyear));
    if ($CONFIG['debug']) {
        debug_log("first day of the first week of {$nmonth} {$nyear} is {$firstday} (from 0 to 6)");
        debug_log("The last day of {$nmonth} {$nyear} is {$lastday}");
    }
    $days[0] = $GLOBALS['strSun'];
    $days[1] = $GLOBALS['strMon'];
    $days[2] = $GLOBALS['strTue'];
    $days[3] = $GLOBALS['strWed'];
    $days[4] = $GLOBALS['strThu'];
    $days[5] = $GLOBALS['strFri'];
    $days[6] = $GLOBALS['strSat'];
    $dayRow = 0;
    echo "\n<table summary='{$monthName} {$nyear}'>";
    /* Make navigation control for months */
    if ($nmonth >= 1) {
        $prevmonth = $nmonth - 1;
        $prevyear = $nyear;
        $nextmonth = $nmonth + 1;
    }
    if ($nmonth == 1) {
        $prevmonth = 12;
        $prevyear = $nyear - 1;
    }
    if ($nmonth < 12) {
        // $nextmonth=nmonth+1;
        $nextyear = $nyear;
    }
    if ($nmonth == 12) {
        $nextmonth = 1;
        $nextyear = $nyear + 1;
    }
    echo "<tr><th colspan='7'>";
    //       echo "<small><a href=\"blank.php?nmonth=".date('m',$timebase)."&nyear=".date('Y',$timebase)."&nday=".date('d',$timebase)."&sid=$sid\" title=\"jump to today\">".date('D jS M Y')."</a></small><br /> ";
    //       echo "<a href=\"blank.php?nmonth=$prevmonth&nyear=$prevyear&sid=$sid\" title=\"Previous Month\"><img src=\"images/arrow_left.gif\" height=\"9\" width=\"6\" border=\"0\"></a>&nbsp;";
    /* Print Current Month */
    echo "<a href='{$_SERVER['PHP_SELF']}?display=month&amp;year={$nyear}&amp;month={$nmonth}'>{$monthName} {$nyear}</a>";
    //    echo "&nbsp;<a href=\"blank.php?nmonth=$nextmonth&amp;nyear=$nextyear&amp;sid=$sid\" title=\"Next Month\"><img src=\"images/arrow_right.gif\" height=\"9\" width=\"6\" border=\"0\" /></a>";
    echo "</th></tr>\n";
    echo "<tr>\n";
    for ($i = 0; $i <= 6; $i++) {
        echo "<td ";
        if ($i == 0 || $i == 6) {
            echo "class='expired'";
        } else {
            echo "class='shade1'";
        }
        echo ">{$days[$i]}</td>";
    }
    echo "</tr>\n";
    echo "<tr>\n";
    while ($dayRow < $firstday) {
        echo "<td><!-- This day in last month --></td>";
        $dayRow += 1;
    }
    $day = 0;
    while ($day < $lastday) {
        if ($dayRow % 7 == 0 and $dayRow > 0) {
            echo "</tr>\n<tr>\n";
        }
        $adjusted_day = $day + 1;
        $bold = '';
        $notbold = '';
        // Colour Today in Red
        if ($adjusted_day == date('d') && $nmonth == date('m') && $nyear == date('Y')) {
            $bold = "<span style='color: red'>";
            $notbold = "</span>";
        }
        if (strlen($adjusted_day) == 1) {
            $calday = "0{$adjusted_day}";
        } else {
            $calday = $adjusted_day;
        }
        if (strlen($nmonth) == 1) {
            $nmonth = "0{$nmonth}";
        } else {
            $nmonth = $nmonth;
        }
        $rowcount = 0;
        if ($rowcount > 0) {
            $calnicedate = date("l jS F Y", mktime(0, 0, 0, $nmonth, $calday, $nyear));
            echo "<td id=\"id{$calday}\" class=\"calendar\"><a href=\"daymessages.php?month={$nmonth}&amp;day={$calday}&amp;year={$nyear}&amp;sid={$sid}\" title=\"{$rowcount} messages\">{$bold}{$adjusted_day}{$notbold}</a></td>";
        } else {
            if ($dayRow % 7 == 0 || $dayRow % 7 == 6) {
                echo "<td class='expired'>";
                echo "{$adjusted_day}</td>";
            } else {
                /////////////////////////////////
                // colors and shading
                $halfday = '';
                $style = '';
                // Get the holiday information for a single day
                list($dtype, $dlength, $approved, $approvedby) = user_holiday($user, $type, $nyear, $nmonth, $calday, false);
                if ($dlength == 'pm') {
                    $halfday = "style=\"background-image: url(images/halfday-pm.gif); background-repeat: no-repeat;\" ";
                    $style = "background-image: url(images/halfday-pm.gif); background-repeat: no-repeat; ";
                }
                if ($dlength == 'am') {
                    $halfday = "style=\"background-image: url(images/halfday-am.gif); background-position: bottom right; background-repeat: no-repeat;\" ";
                    $style = "background-image: url(images/halfday-am.gif); background-position: bottom right; background-repeat: no-repeat;";
                }
                if ($calday == $selectedday && $selectedmonth == $nmonth && $selectedyear == $nyear) {
                    // consider a border color to indicate the selected cell
                    $style .= "border: 1px red dashed; ";
                    // $shade="critical";
                }
                // idle = green
                // critical = red
                // urgent = pink
                // expired = grey
                // mainshade = white
                switch ($dtype) {
                    case 1:
                        $shade = "mainshade";
                        if ($approved == 1) {
                            $shade = 'idle';
                        }
                        if ($approved == 2) {
                            $shade = 'urgent';
                        }
                        break;
                    case 2:
                        $shade = "mainshade";
                        if ($approved == 1) {
                            $shade = 'idle';
                        }
                        if ($approved == 2) {
                            $shade = 'urgent';
                        }
                        break;
                    case 3:
                        $shade = "mainshade";
                        if ($approved == 1) {
                            $shade = 'idle';
                        }
                        if ($approved == 2) {
                            $shade = 'urgent';
                        }
                        break;
                    case 4:
                        $shade = "mainshade";
                        if ($approved == 1) {
                            $shade = 'idle';
                        }
                        if ($approved == 2) {
                            $shade = 'urgent';
                        }
                        break;
                    case 5:
                        $shade = "mainshade";
                        if ($approved == 1) {
                            $shade = 'idle';
                            $style = "border: 1px dotted magenta; ";
                        }
                        if ($approved == 2) {
                            $shade = 'urgent';
                        }
                        break;
                    case 10:
                        // public holidays
                        $style = "background: #D6D6D6;";
                        $shade = 'shade1';
                        break;
                    default:
                        $shade = "shade2";
                        break;
                }
                if ($dtype == 1 || $dtype == '' || $dtype == 5 || $dtype == 3 || $dtype == 2 || $dtype == 4) {
                    echo "<td class=\"{$shade}\" style=\"width: 15px; {$style}\">";
                    echo "<a href=\"holiday_add.php?type={$type}&amp;user={$user}&amp;year={$nyear}&amp;month={$nmonth}&amp;day={$calday}\"  title=\"{$celltitle}\">{$bold}{$adjusted_day}{$notbold}</a></td>";
                } else {
                    echo "<td class=\"{$shade}\" style=\"width:15px; {$style}\">{$bold}{$adjusted_day}{$notbold}</td>";
                }
            }
        }
        $day += 1;
        $dayRow += 1;
    }
    echo "\n</tr>\n</table>\n";
}
Ejemplo n.º 3
0
            // FIXME i18n ALL these
            case 'am':
                echo "You can make it <a href='holiday_add.php?type={$type}&amp;user={$user}&amp;year={$selectedyear}&amp;month={$selectedmonth}&amp;day={$selectedday}&amp;length=pm'>the afternoon instead</a>, or select the <a href='holiday_add.php?type={$type}&amp;user={$user}&amp;year={$selectedyear}&amp;month={$selectedmonth}&amp;day={$selectedday}&amp;length=day'>full day</a>. ";
                break;
            case 'pm':
                echo "You can make it <a href='holiday_add.php?type={$type}&amp;user={$user}&amp;year={$selectedyear}&amp;month={$selectedmonth}&amp;day={$selectedday}&amp;length=am'>the morning</a> instead, or select the <a href='holiday_add.php?type={$type}&amp;user={$user}&amp;year={$selectedyear}&amp;month={$selectedmonth}&amp;day={$selectedday}&amp;length=day'>full day</a>. ";
                break;
            case 'day':
                echo "You can make it <a href='holiday_add.php?type={$type}&amp;user={$user}&amp;year={$selectedyear}&amp;month={$selectedmonth}&amp;day={$selectedday}&amp;length=am'>the morning</a>, or <a href='holiday_add.php?type={$type}&amp;user={$user}&amp;year={$selectedyear}&amp;month={$selectedmonth}&amp;day={$selectedday}&amp;length=pm'>the afternoon</a> instead. ";
        }
        if ($length != '0') {
            echo "Or you can <a href='holiday_add.php?type={$type}&amp;user={$user}&amp;year={$selectedyear}&amp;month={$selectedmonth}&amp;day={$selectedday}&amp;length=0'>deselect</a> it. ";
            echo "<a href='calendar.php?type={$type}&amp;user={$user}' title='Clear this message'>Okay</a>.";
        }
    } elseif ($approved == 1) {
        list($xtype, $xlength, $xapproved, $xapprovedby) = user_holiday($user, $type, $selectedyear, $selectedmonth, $selectedday, FALSE);
        echo "Approved by " . user_realname($xapprovedby) . ".";
        if ($length != '0' && $approver == TRUE && $sit[2] == $xapprovedby) {
            echo "&nbsp;As approver for this holiday you can <a href='holiday_add.php?type={$type}&amp;user={$user}&amp;year={$selectedyear}&amp;month={$selectedmonth}&amp;day={$selectedday}&amp;length=0'>deselect</a> it.";
            // FIXME i18n
        }
    } else {
        echo "<span class='error'>Declined</span>.  You should <a href='holiday_add.php?type={$type}&amp;user={$user}&amp;year={$selectedyear}&amp;month={$selectedmonth}&amp;day={$selectedday}&amp;length=0'>deselect</a> it.";
        // FIXME i18n
    }
} else {
    echo $strClickOnDayToSelect;
}
echo "</p>\n";
echo "<h2>{$strYearView}</h2>";
$pdate = mktime(0, 0, 0, $month, $day, $year - 1);