<?php
    include("../include/session.php");
    if(!$session->isAdmin()) {
        header("Location: ../main.php");
    }
    else {
    	include("../reportHeader.php");
//        include("../include/db.php");
		$section = mysql_real_escape_string($_POST['section']);
		$q = "SELECT empId, empRate FROM employees WHERE empSection = '$section'";
		$result = execsql($q);
		$num = mysql_num_rows($result);
		$i = 0;
		$cost = 0;
		$dd = date("d");
		$mm = date("m");
		$yy = date("Y");
		$c = 0;
		$sundays = 0;
	    $notSunday = 0;
		while($c < $dd) {
			if(date("l", mktime(0,0,0,$mm, date("d")+$c, $yy)) == "Sunday") {
				$sundays++;
			}
			$c++;
		}
	
	    $days = $dd - ($sundays*2);
	    $cost = 1;
	    while($i < $num){
	    	$cost += (mysql_result($result, $i, "empRate") * 8)*$days;
	    	$i++;
	    }
	    
		echo 'Cost of '. $section . ' so far this month: '. $cost;
	    
    }
?>		
