<?php

	/*echo md5('');*/

	include_once 'includes/functions.php';

/*	$st = 0;
	//Test case for  migrating from SED-CRS (242) to CRS-SED (1)
	//$r = mysql_query("SELECT * FROM `students_nce` WHERE programme_id = 242");//242 to be changed
	$r = mysql_query("SELECT * FROM `students_nce` WHERE `number` LIKE 'VE/SOS-SED/18/%' ORDER by `number` ASC");//242 to be changed
	if(mysql_num_rows($r) > 0 )
	{
		while($row = mysql_fetch_array($r, MYSQL_ASSOC))
		{
			//get matric
			$stud_id = $row['id'];
			$pt = 2;
			//change this variables value 
		
			/*$total_in_programme = get_total_programme_students($pt,$sch,$prog,$level = 'I');
						   
			$total_in_programme = $total_in_programme + 1; 
			
			$mat_no = substr($row['number'],2);
			$new_code = 'AS';
			echo $new_mat_no = $new_code.$mat_no;
				
			//the student new matric no 
			// $new_mat_no = generate_matric_number($pt, $sch, $prog, $level = 'I', $total_in_programme);

			//echo $new_mat_no ;
			/*exit();

			//change as required
			$r2 =mysql_query("UPDATE `students_nce` SET  `number` = '$new_mat_no' , `username` = '$new_mat_no' 
				WHERE  id = '$stud_id'");//change 242
			
			if ($r2) {
				$st++;
			}
			
		}
	}else{
		echo 'No Records<br>';
	}
	*/

$st = 0;
	//Test case for  migrating from SED-CRS (228) to CRS-SED (1)
	$r = mysql_query("SELECT * FROM `students_prence` WHERE programme_id = 228");//228 to be changed
	if(mysql_num_rows($r) > 0 )
	{
		while($row = mysql_fetch_array($r, MYSQL_ASSOC))
		{
			//get matric
			$stud_id = $row['id'];
			$pt = 1;
			//change this variables value 
			$sch = 3;
			$dept = 14;
			$prog = 121;

			//$total_in_programme = get_total_programme_students($pt,$sch,$prog,$level = 'I');
			
			$total_in_programme = get_total_programme_students_prence($pt,$sch,$prog,$level = 'PRE');			   
			$total_in_programme = $total_in_programme + 1; 
					
			//the student new matric no 
			//$new_mat_no = generate_matric_number($pt, $sch, $prog, $level = 'I', $total_in_programme);
            $new_mat_no = generate_matric_number_prence($pt, $sch, $prog, $level = 'PRE', $total_in_programme);

			echo $new_mat_no.'<br>';
			//exit();

			//change as required
			$r2 =mysql_query("UPDATE `students_prence` SET  `school_id` = '$sch', `school_applied_for` = '$sch', `department_id` = '$dept',  `department_applied_for` = '$dept',`programme_id` = '$prog', `programme_applied_for` = '$prog' , `number` = '$new_mat_no' , `username` = '$new_mat_no' 
				WHERE `programme_id` = 228 AND id = '$stud_id'");//change 228
			
			if ($r2) {
				$st++;
			}
			
		}
	}else{
		echo 'No Records<br>';
	}
	

	
	



	echo 'Total Success= '.$st;

?>