Location: PHPKode > projects > ConPortal > conportal/inc/shift_draw/display.php
<?
/*
 *  ConPortal - Pomona College ITS scheduling appplication
 *  Copyright (C) 2005-2006  Pomona College
 *
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of version 2 of the GNU General Public License
 *  as published by the Free Software Foundation.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 */

function print_shift_draw_info()
{
    // Not in a shift group, so there can be no shift draw
    if (is_null($_SESSION['shift_shiftgroup']))
        return;

/*FIXME - using ceil() is a hack - it fixes the 11:00pm-11:59pm giving some long 
decimal value bug, but it's predicated on the assumption that we don't let shifts
be non-integer values.  This is an OK assumption for now, but may bite us
in the ass someday.  

A solution might be to subtract just the part in front of the decimal point, and do some if statements on what range that falls into... 
sprintf("%d") or sprintf("%0f") is likely the key....
*/ 
    $available = drawTimeTotal($_SESSION['pid'],
                               $_SESSION['shift_shiftgroup']) / 3600;

    $drawn = ceil(drawTotalWeekTime($_SESSION['pid'],
                               $_SESSION['shift_timestamp']) / 3600);

    $drawnToday = ceil(drawTotalDayTime($_SESSION['pid'],
                               $_SESSION['shift_timestamp']) / 3600);	
		
    if ($available > 0) {
?>
    <div id="shift_draw_message">
        <b>Shift Draw Information:</b>
        You currently have drawn <b><?= $drawn ?></b> out of
        <b><?= $available ?></b> available weekly hours, and <b><?= $drawnToday ?></b> out of <b>8</b> available daily hours. 
    </div>
<?php
    } else {
?>
<div id="shift_draw_message">
    <b>Shift Draw has not started for this date.</b>
</div>
<?php
    }
}

function printShiftPickStartTimes()
{
	$shiftdata = getShiftPickStartTimes();
	?>
	Remember, the Seniority Level includes everyone of that seniority and above.  Everyone allows everyone in that user group - oftentimes leaders and regular students are in different user groups!<br />
	<table class='shift_history'><tr>
	<th>User group</th><th>Shiftgroup</th><th>Seniority Level</th><th>Starting on</th><th>Hours per week</th><th>Delete?</th></tr>
	<?
	$row = array();

	if($shiftdata != NULL)
	{
		foreach($shiftdata as $row)
		{
			echo "<tr><td>" . $row['usergroup'] . "</td><td>" . $row['shiftgroup'] . "</td><td>" .
			$row['senlevel'] . "</td><td>" . $row['starttime'] . "</td><td>" . $row['hours'] . 
			"</td><td><a href=\"" . BASE_URL . "delete_pick_start_time.php?pid=" . 
							$row['pid'] . "\">Delete!</a></td></tr>";
		}
		echo "</table>";
	}
	else
	{
		echo "</table><br />There are no results to display.";
	}
}

// Set the Hours per week, shift start date, and seniority level, all in one fell swoop
function printSetShiftPickStartTimesForm()
{
// get lists of Shiftgroups and Groups
$shiftgroups = getShiftgroupsPidsAndNames();
$groups = getPrimaryGroups();
$sen_levels = getSeniorityLevels();

?>

<form method='post' action='redirects/set_pick_start_time.php' id='shift_draw_info'><div>
<table>
	<tr>
		<td>Shift Group:</td>
		<td><select name='shift_group'>
		<?
		foreach ($shiftgroups as $shift)
		{
		echo "<option value='" .$shift['pid']."'>".$shift['name']."</option>\n";
		}
		?>
		</select></td>
	</tr>
	<tr>
		<td>User Group:</td>
		<td><select name='group' id='group'>	
		<?
    		foreach ($groups as $g) {
       		$i = getGroupDetails($g);
		echo "\n    <option value='$g'>" . $i['description']."</option>";
   		 }
		?>		
		</select></td>
	</tr>
	<tr>
		<td>Hours per week:</td>
		<td><input type='text' name='hours' id='hours' size='4'/>
		</td>
	</tr>
	<tr>
		<td>Seniority Level:</td>
		<td><select name='seniority' id='seniority'>
		<?
		foreach ($sen_levels as $level) {
		echo "<option value='" . $level['pid']."'>" . $level['description'] . "</option>\n";
		}
		?>
		</select></td>
	</tr>
	<tr>
		<td>Start taking hours on:</td>
		<td><input type='text' name='start_time' id='start_time' size='16' value='<?
		print_timestamp_rightnow(); 
		?>'/>
		</td> 	
	</tr>

</table>
<input type="submit" value="Set the hours-per-week & start time for employees."/>
<?

}


Return current item: ConPortal