| Current Path : /var/www/cesa.co.za/ccmadmin/ |
| Current File : /var/www/cesa.co.za/ccmadmin/ReportMilestones.php |
<?php
session_start(); // Initialize Session data
ob_start(); // Turn on output buffering
?>
<?php include "ewcfg7.php" ?>
<?php include "ewmysql7.php" ?>
<?php include "phpfn7.php" ?>
<?php include "userfn7.php" ?>
<?php
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); // Always modified
header("Cache-Control: private, no-store, no-cache, must-revalidate"); // HTTP/1.1
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache"); // HTTP/1.0
?>
<?php
if (!isset($_GET["export"])) {
?>
<?php include "header.php" ?>
<?php
} else {
header('Content-Type: application/vnd.ms-excel');
header('Content-Disposition: attachment; filename=ReportMilestones.xls');
}
?>
<?php
if (!isset($_GET["export"])) {
?>
<h1><span class="phpmaker" style="white-space: nowrap;">Milestones Report</span></h1>
<p><a href="ReportMilestonesExport.php?export=excel&org=<?php echo $_POST["org"]; ?>" target="_blank"><img src='images/exportxls.gif' width='16' height='16' border='0' align='absmiddle'> Export to Excel</a></p>
<br>
<?php
}
?>
<table cellspacing="0" class="ewGrid"><tr><td class="ewGridContent">
<?php
$conn = ew_Connect();
function ShowDetails($iStudentID, $iMilestoneNum=1) {
$sql="SELECT * FROM CCMMilestones WHERE CCMStudentID=".$iStudentID." AND MilestoneNum=".$iMilestoneNum." ORDER BY StepType";
$recMS=mysql_query($sql);
while ($rowMS=mysql_fetch_assoc($recMS)) {
echo "<li>".$rowMS["StepType"].": ".$rowMS["StepData"];
if (!empty($rowMS["StepFile"])) echo ", file: <a href='milestones/".$rowMS["StepFile"]."' target='_blank'>".$rowMS["StepFile"]."</a>";
$sql="SELECT * FROM CCMStudents, CCMMilestoneSteps, CCMMilestoneStepsData WHERE CCMMilestoneStepsData.CCMStudentID='".$iStudentID."' AND CCMMilestoneStepID=CCMMilestoneSteps.id AND CCMMilestoneSteps.MilestoneNum=".$iMilestoneNum." AND CCMMilestoneSteps.InputFieldStepName='".$rowMS["StepType"]."' AND CCMStudents.CCMStudentID=CCMForStudentID";
// echo $sql;
$rec2=mysql_query($sql);
while ($row2=mysql_fetch_assoc($rec2)) {
if (!empty($row2["StepFile"]) || !empty($row2["StepData"])) {
echo ", ".$row2["FirstName"]." ".$row2["Surname"].": ";
if (!empty($row2["StepFile"])) {
echo "<a href='milestones/".$row2["StepFile"]."' target='_blank'>".$row2["StepFile"]."</a>";
} else {
echo $row2["StepData"];
}
}
}
echo "</li>";
}
}
function ShowRows($iEmployerID, $sEmployer) {
if (!empty($sEmployer)) {
?><p><b><?php echo $sEmployer; ?></b></p>
<?php
} else {
?><p><b>No Coordinator</b></p>
<?php
}
?>
<table width="740" cellspacing="0" class="ewTable ewTableSeparate" rowhighlightclass="ewTableHighlightRow" rowselectclass="ewTableSelectRow" roweditclass="ewTableEditRow"<?php if (isset($_GET["export"])) echo " border=1"; ?>>
<thead><!-- Table header -->
<tr class="ewTableHeader">
<td width="80">Type</td>
<td width="200">Name</td>
<td width="200">Contact</td>
<td width="80">Milestone</td>
<td width="80">Num Steps<br>
Completed</td>
<td width="300">Details</td>
</tr>
</thead>
<tbody>
<?php
if (!empty($sEmployer)) {
$sql="SELECT COUNT(CCMMilestones.CCMMilestoneID) AS NumSteps, CCMEmployers.CCMEmployerID, CCMEmployers.FirstName, CCMEmployers.Surname, CCMEmployers.Telephone, CCMEmployers.Cellphone, CCMEmployers.EmailAddress, CCMMilestones.MilestoneNum
FROM CCMEmployers LEFT JOIN CCMMilestones ON (CCMEmployerID=CCMStudentID)
WHERE CCMEmployers.CCMEmployerID=".$iEmployerID."
GROUP BY CCMEmployers.CCMEmployerID, CCMEmployers.FirstName, CCMEmployers.Surname, CCMEmployers.Telephone, CCMEmployers.Cellphone, CCMEmployers.EmailAddress, CCMMilestones.MilestoneNum
ORDER BY CCMEmployers.Surname, CCMEmployers.FirstName, CCMMilestones.MilestoneNum";
$recS=mysql_query($sql);
while ($rowS=mysql_fetch_assoc($recS)) {
?><tr><td>Coordinator</td><td><?php echo $rowS["FirstName"]." ".$rowS["Surname"]; ?></td>
<td><?php echo $rowS["Telephone"]."<br>".$rowS["Cellphone"]."<br>".$rowS["EmailAddress"]; ?></td>
<td><?php echo $rowS["MilestoneNum"]; ?></td><td><?php echo $rowS["NumSteps"]; ?></td>
<td><?php if ($rowS["NumSteps"]>0) { echo "<ul>"; ShowDetails($rowS["CCMEmployerID"], $rowS["MilestoneNum"]); echo "</ul>"; } ?></td>
</tr>
<?php
}
}
?>
<?php
$sql="SELECT COUNT(CCMMilestones.CCMMilestoneID) AS NumSteps, CCMStudents.MentorID, CCMStudents.CCMStudentID, CCMStudents.FirstName, CCMStudents.Surname, CCMStudents.Telephone, CCMStudents.Cellphone, CCMStudents.EmailAddress, CCMMilestones.MilestoneNum FROM CCMStudents LEFT JOIN CCMMilestones ON (CCMStudents.CCMStudentID=CCMMilestones.CCMStudentID)
WHERE ";
if (!empty($sEmployer)) {
$sql.=" CCMStudents.EmployerID=".$iEmployerID;
} else {
$sql.=" (CCMStudents.EmployerID IS NULL OR CCMStudents.EmployerID=0)";
}
$sql.="
AND CCMStudents.Archived=0
GROUP BY CCMStudents.MentorID, CCMStudents.CCMStudentID, CCMStudents.FirstName, CCMStudents.Surname, CCMStudents.Telephone, CCMStudents.Cellphone, CCMStudents.EmailAddress, CCMMilestones.MilestoneNum
ORDER BY CCMStudents.Surname, CCMStudents.FirstName, CCMMilestones.MilestoneNum";
$recS=mysql_query($sql);
while ($rowS=mysql_fetch_assoc($recS)) {
?><tr><td>Candidate</td><td><?php echo $rowS["FirstName"]." ".$rowS["Surname"]; ?><br>
(Mentor: <?php
$sql="SELECT * FROM CCMMentors WHERE CCMMentorID=".$rowS["MentorID"];
$recM=mysql_query($sql); if ($rowM=mysql_fetch_assoc($recM)) echo $rowM["FirstName"]." ".$rowM["Surname"];
mysql_free_result($recM);
?>)</td>
<td><?php echo $rowS["Telephone"]."<br>".$rowS["Cellphone"]."<br>".$rowS["EmailAddress"]; ?></td>
<td><?php echo $rowS["MilestoneNum"]; ?></td><td><?php echo $rowS["NumSteps"]; ?></td>
<td><?php if ($rowS["NumSteps"]>0) { echo "<ul>"; ShowDetails($rowS["CCMStudentID"], $rowS["MilestoneNum"]); echo "</ul>"; } ?></td>
</tr>
<?php
}
?>
<?php
$sql="SELECT COUNT(CCMMilestones.CCMMilestoneID) AS NumSteps, CCMMentors.CCMMentorID, CCMMentors.FirstName, CCMMentors.Surname, CCMMentors.Telephone, CCMMentors.Cellphone, CCMMentors.EmailAddress, CCMMilestones.MilestoneNum FROM (CCMMentors INNER JOIN CCMStudents ON (CCMMentorID=MentorID ))
LEFT JOIN CCMMilestones ON (CCMMentorID=CCMMilestones.CCMStudentID)
WHERE ";
if (!empty($sEmployer)) {
$sql.=" CCMStudents.EmployerID=".$iEmployerID;
} else {
$sql.=" (CCMStudents.EmployerID IS NULL OR CCMStudents.EmployerID=0)";
}
$sql.="
AND CCMStudents.Archived=0
AND CCMMentors.Archived=0
GROUP BY CCMMentors.CCMMentorID, CCMMentors.FirstName, CCMMentors.Surname, CCMMentors.Telephone, CCMMentors.Cellphone, CCMMentors.EmailAddress, CCMMilestones.MilestoneNum
ORDER BY CCMMentors.Surname, CCMMentors.FirstName, CCMMilestones.MilestoneNum";
$recS=mysql_query($sql);
while ($rowS=mysql_fetch_assoc($recS)) {
?><tr><td>Mentor</td><td><?php echo $rowS["FirstName"]." ".$rowS["Surname"]; ?></td>
<td><?php echo $rowS["Telephone"]."<br>".$rowS["Cellphone"]."<br>".$rowS["EmailAddress"]; ?></td>
<td><?php echo $rowS["MilestoneNum"]; ?></td><td><?php echo $rowS["NumSteps"]; ?></td>
<td><?php if ($rowS["NumSteps"]>0) { echo "<ul>"; ShowDetails($rowS["CCMMentorID"], $rowS["MilestoneNum"]); echo "</ul>"; } ?></td>
</tr>
<?php
}
?>
</tbody>
</table>
<?php
}
?>
<form method="post" action="ReportMilestones.php">
Filter by organisation: <select name="org">
<option value="All">Show All</option>
<option value="None">No Organisation</option>
<?php
$sql = "SELECT * FROM CCMEmployers WHERE Archived=0 ORDER BY Organisation";
$recE=mysql_query($sql);
while ($rowE=mysql_fetch_assoc($recE)) {
echo "<option value='".$rowE["CCMEmployerID"]."'>".$rowE["Organisation"]."</option>";
}
?>
</select><input type="submit" value="Submit">
</form>
<?php
if (!isset($_POST["org"]) || ($_POST["org"]=="All")) {
ShowRows(0, "");
$sql = "SELECT * FROM CCMEmployers WHERE Archived=0 ORDER BY Organisation";
$recE=mysql_query($sql);
while ($rowE=mysql_fetch_assoc($recE)) {
ShowRows($rowE["CCMEmployerID"], $rowE["Organisation"]);
}
} else {
if ($_POST["org"]=="None") {
ShowRows(0, "");
} else {
$sql = "SELECT * FROM CCMEmployers WHERE CCMEmployerID='".$_POST["org"]."'";
$recE=mysql_query($sql);
if ($rowE=mysql_fetch_assoc($recE)) {
ShowRows($rowE["CCMEmployerID"], $rowE["Organisation"]);
}
}
}
?>
</td></tr></table>
<?php
if (!isset($_GET["export"])) {
?>
<?php include "footer.php" ?>
<?php
}
?>