Example #1
0
function draw_payperiod_length_form() {
	$pplength = get_payperiod_length()/86400;
?>
	<form class='form' role="form" action='' method="post">
		<?php echo 'Payperiod Length (in days): '.$pplength; ?>
		<div class="form-group">
			<div class="input-group">
            	<input type="text" style="border-style:dotted;"class="form-control col-md-2" placeholder="(Struggling with making this smaller...)" name="pp-length"><span class="input-group-addon">Days</span>
        	</div>
    	</div>
		
		<input type='hidden' name='pp-length-submit' value='true'>
		<button type='button' class="btn btn-default" onclick='submit()'>Update</button>
	</form>
	<?
}
function get_number_of_payperiods()
{
    //How many seconds in a year
    $yearlength = 31536000;
    //if we're in a leap year, add a day to that length
    if (date('L')) {
        $yearlength += 86400;
    }
    //Return the length of the year divided by the length of a payperiod.
    $out = intval($yearlength / get_payperiod_length());
    return $out;
}