<?php  
	require "commonincludefiles.php";
	
	if($_SESSION["VedantnrCollegeId"]!="" && isset($_SESSION["VedantnrCollegeId"]))
	{
		/* start new code */
		$objUserMgmt = new UserMgmt();
		$branch_id 		= $_POST['branch_hidden'];	
		$semester_id 	= $_POST['semester_hidden'];
		
		
		$username	= explode(",",substr($_REQUEST['username'],0,-1));
		$student_id 	= explode(",",substr($_REQUEST['student_id'],0,-1));
		$password 		= explode(",",substr($_REQUEST['password'],0,-1));
		
		$sql_select = "SELECT * FROM cms_usermaster WHERE student_id IN(".substr($_REQUEST['student_id'],0,-1).") ";
		$res_select = dbQuery($sql_select);
		
		if(dbRows($res_select) > 0){
			$sql_delete = "DELETE FROM cms_usermaster WHERE student_id IN(".substr($_REQUEST['student_id'],0,-1).") ";
			$res_delete = dbQuery($sql_delete);
		}
		
		
		
		$objUserMgmt->user_role	 = 'Student';
		$objUserMgmt->college_id	 = $_SESSION["VedantnrCollegeId"];
		$objUserMgmt->menu_ids		 = '9';
		$objUserMgmt->module_ids	 = '1';
		$objUserMgmt->page_ids	 ='77,78,79';
		
		
		for($i = 0; $i < count($student_id); $i++)
		{
			if(trim($username[$i]) != "" && trim($password[$i]) != "")
			{
			$objUserMgmt->student_id	= $student_id[$i];
			$objUserMgmt->user_name	= $username[$i];
			$objUserMgmt->user_password	= $password[$i];
		
			$objUserMgmt->add();
			}
		}
		/* end new code */
		
		echo '{"success":"true"}';
	}
	else
	{
		echo '{"success":"false","msg":"session expiry"}';
	}
?>