<?php 
$pgMod="driver";
$pgAct="view";
if(isset($_GET['action']) && trim($_GET['action'])!='')
		$pgAct=strtolower($_GET['action']);

if(isset($_SESSION['msg']) && $_SESSION['msg']!="")
{
	?>
	<div class="alert alert-success">
	  <a class="close" data-dismiss="alert">×</a>
	  <i class="icon icon-thumbs-up-alt"></i> <b>Notice</b><?php echo $_SESSION['msg'] ?></i>
	</div>
	<?php
	unset($_SESSION["msg"]);
}
if(is_array($alert_err) && count($alert_err)>0)
{
	?>
	<div class="alert alert-error">
	  <a class="close" data-dismiss="alert">×</a>
	  <i class="icon icon-warning-sign"></i> <b>Notice</b> <?php echo $alert_err[0] ?></i>
	</div>
	<?php
}
?>
<!-- Forms --> 
<style>.top-bar-minimize{display:none;}
thead, tfoot {display: table-header-group;}
.top-bar+.well,.accordion .accordion-heading+.accordion-body{display: inline-block !important;width: 96.7% !important;overflow: inherit !important;} 
.classList{cursor:pointer;text-decoration:none;display:block;border:1px solid #666;margin: 5px 0;padding: 5px 11px;}
.selected{background-color: #ccc;color: #fff;font-weight: bolder;box-shadow: 5px 5px 16px #000;}
.imgs{float:left;height: 60px;margin-right: 10px;}
.classList span{color:#F00; font-weight:bolder;}
.driverDetail { border: 1px solid #000;padding: 5px 10px;background-color: #ccc;box-shadow: 0 0 10px #2B2929;font-weight: bolder;font-size: 14px;margin: 10px 5px;}
</style>
<form method="post" action="" enctype="multipart/form-data">
     <div class="row-fluid">
        <div class="span12">
            <div class="top-bar">
                <h3><i class="icon-cog"></i> Migrate</h3>
                <button style="float:right; margin-top:5px" onClick="ProcessToMigrate()" class="btn" type="button">Migrate Admin</button>
            </div>
            <div class="well">
			<!-- Forms: Box -->
			<div class="span3">

				<!-- Forms: Top Bar -->
				<div class="top-bar">
                    <h3><i class="icon-cog"></i> Admin</h3>
                </div>
				<!-- / Forms: Top Bar -->

				<!-- Forms: Content -->
				<div class="well no-padding">
                    <div class="control-group">
                    	<select>
        					<option value="" >Admin List</option>
                        </select>
    				</div>
				</div>
               
				<!-- / Forms: Top Bar -->

				<!-- Forms: Content -->
			
				<!-- / Forms: Content -->
				<div class="top-bar">
                    <h3><i class="icon-cog"></i> Select Next Session</h3>
                </div>
				<!-- / Forms: Top Bar -->

				<!-- Forms: Content -->
				<div class="well no-padding">

						
                        
                        <div class="control-group">
                        	<select name="session" id="session">
							<?php 
								$class=$db->getRows("select * from session  where school_id='".$_SESSION["admin"]["school_id"]."'  order by session");
								foreach($class as $cla){
									?>
									<option value="<?php echo $cla["session"] ?>">
										<?php echo $cla["session"] ?>
									</option>
									<?php
								}
							?>
                            </select>
						</div>
                          
                        
						
				</div>
				<!-- / Forms: Content -->
			</div>
			<!-- / Forms: Box -->
			<!-- Forms: Box -->
			<div class="span9">

				<!-- Forms: Top Bar -->
				
				<!-- / Forms: Top Bar -->

				<!-- Forms: Content -->
				<div class="well no-padding">

					<!-- Forms: Form -->
                        <div class="control-group" id="fetchStudent">
						<table class="table">
                        	<tr>
                                <th></th>
                                <th>Name</th>
                                <th>User ID</th>
                                <th>Password</th>
                                <th>Mobile</th>
                                <th>Role</th>
                            </tr>
                        	<?php
                        	$allstudent=$db->getRows("select * from admin where school_id='".$_SESSION["admin"]["school_id"]."' and session='".$_SESSION["admin"]["session"]."' ");
                        	if(is_array($allstudent) && count($allstudent)>0){
                        		foreach($allstudent as $allS){
                        			?>
                        			<tr>
                                    	<td><input type="checkbox" name="student" value="<?php echo $allS["id"] ?>" checked="checked" /></td>
                                        <td><?php echo $allS["name"] ?></td>
                                        <td><?php echo $allS["login_id"] ?></td>
                                        <td><?php echo $allS["password"] ?></td>
                                        <td><?php echo $allS["mobile"] ?></td>
                                        <td><?php echo $db->getVal("select name from tbl_roll where school_id='".$_SESSION["admin"]["school_id"]."' and id='".$allS["role_id"]."'");?></td>
                                    </tr>
                        			<?php
                        		}
                        	}else{
                        		?><tr>
                                <td colspan="4">No Student Found</td>
                                </tr><?php
                        	}
                        	//echo "<pre>";print_r($allstudent);echo $db->getErMsg();echo "</pre>";
                    	?></table>
						</div>
						<!-- Forms: Form Actions -->
						
						<!-- / Forms: Form Actions -->
	 
					<!-- / Forms: Form -->           

				</div>
				<!-- / Forms: Content -->

			</div>
			<!-- / Forms: Box -->
            
            </div>
        </div>
        
	</div>
</form>
<!-- / Forms -->
<script>
var root='<?php echo URL_ROOT; ?>';

function ProcessToMigrate(){
//	if(confirm("This Process can done only single time \n you cannot migrate same class on next time...")){
		if(confirm( "Are you sure \n Do you want to process ???")){
			var bodi=$("body").html();
			var i=0;var teacher="";
			$('input:checked').each(function() {i++;
				if(i!=1)teacher+=",";
				//student+=($(this).attr("name") + this.id);
				teacher+=this.value;
			});
		   
			
			var session=$("#session").val();
		
			$("body").html('<br /><br /><br /><center><img src="'+root+'assets/icon/load.gif" /></center>');
			if(teacher==""){
				alert("Please select atleast one admin to migrate session.");
				$("body").html(bodi); 
			}
			else{
				$.post( "<?php echo URL_ROOT ?>Promote/ajax.php", { 
							type: "Migrateadmin", 
							session: session,
							teacher: teacher
				} , function( data ) {
// 			alert(data);
					window.location='?src=Promote&page_id=admin_migrate'; 
				});
			}
		}
	//}
}
</script>
