Your IP : 216.73.217.79


Current Path : /var/www/cesa.co.za/ccmadmin/
Upload File :
Current File : /var/www/cesa.co.za/ccmadmin/changementor.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 "CCMUsersinfo.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 include "header.php" ?>
    <h1>Change Mentor</h1>
<?php
$conn = mysql_connect(EW_CONN_HOST, EW_CONN_USER, EW_CONN_PASS);
mysql_select_db(EW_CONN_DB);

if (isset($_POST["go"]) && ($_POST["go"]==1)) {

	$sql="insert into CCMMilestones (CCMStudentID, DateUpdated, MilestoneNum, StepType, StepData, StepFile)
	select ".$_POST["tomentor"].", DateUpdated, MilestoneNum, StepType, StepData, StepFile
	from CCMMilestones where CCMStudentID=".$_POST["frommentor"];
	mysql_query($sql);

	$sql="insert into CCMMilestoneStepsData (CCMMilestoneStepID, CCMStudentID, CCMForStudentID, StepData, StepFile)
	select CCMMilestoneStepID, ".$_POST["tomentor"].", ".$_POST["candidate"].", StepData, StepFile
	from CCMMilestoneStepsData where CCMStudentID=".$_POST["frommentor"]." and CCMForStudentID=".$_POST["candidate"];
	mysql_query($sql);

	$sql="insert into CCMMentorChanged (CCMStudentID, CCMFromMentorID, CCMToMentorID, MentorChangedDate)
	values (".$_POST["candidate"].", ".$_POST["frommentor"].", ".$_POST["tomentor"].", '".date("Y-m-d H:i:s")."')";
	mysql_query($sql);
	
	$sql="update CCMStudents SET MentorID=".$_POST["tomentor"]." WHERE CCMStudentID=".$_POST["candidate"];
	mysql_query($sql);
	
	echo "<p><b>The mentor has been changed, and the existing milestone steps copied across.</b></p>";

} else {
?>    
    <form action="changementor.php" method="post" name="form1" id="form1">
    <input type="hidden" name="go" value="1" />
    <input type="hidden" name="candidate" value="<?php echo $_GET["candidate"]; ?>">
      <table border="0" cellspacing="0" cellpadding="5">
        <tr>
          <td width="72">Candidate:</td>
          <td><?php
          	$iMentorID=0;
          	$sql="SELECT MentorID, FirstName, Surname, Organisation FROM CCMStudents WHERE CCMStudentID=".$_GET["candidate"];
          	$rec=mysql_query($sql);
          	if ($row=mysql_fetch_assoc($rec)) {
          		echo $row["FirstName"]." ".$row["Surname"].": ".$row["Organisation"];
          		$iMentorID=$row["MentorID"];
          	}
          	?></td>
        </tr>
        <tr>
          <td>Old / current mentor:</td>
          <td><?php
          	$sql="SELECT FirstName, Surname, Organisation FROM CCMMentors WHERE CCMMentorID=".$iMentorID;
          	$rec=mysql_query($sql);
          	if ($row=mysql_fetch_assoc($rec)) {
          		echo $row["FirstName"]." ".$row["Surname"].": ".$row["Organisation"];
          		echo "<input type='hidden' name='frommentor' value='".$iMentorID."'>";
          	}
          	?></td>
        </tr>
        <tr>
          <td>New mentor:</td>
          <td><select name="tomentor"><?php
          	$sql="SELECT CCMMentorID, FirstName, Surname, Organisation FROM CCMMentors WHERE CCMMentorID<>".$iMentorID." AND Archived=0 ORDER BY Surname, FirstName";
          	$rec=mysql_query($sql);
          	while ($row=mysql_fetch_assoc($rec)) {
          	?><option value="<?php echo $row["CCMMentorID"]; ?>"><?php echo $row["FirstName"]." ".$row["Surname"].": ".$row["Organisation"]; ?></option>
          	<?php
          	}
          	?></select></td>
        </tr>
      </table>
      <p>
        <label>
        <input type="submit" name="button" id="button" value="Update" />
        </label>
      </p>
    </form>
<?php
}
?>    
    <p>&nbsp;</p>

<?php include "footer.php" ?>