Current File : /home/inlingua/public_html/sensoriumpsychologists.com/backup/admin/edit_student.php
<?php 
	include_once('include/include.script.php');
	include_once('include/navigation.php');
	include_once('../classes/config.php');

$id=$_GET['id'];
$result1=$query->select_where('shristi_student','student_id',$id);
$row1=$result1->fetch_assoc();

$result2=$query->select_where_field('shristi_students_details','student_id',$id,"AND status='1'");
$row2=$result2->fetch_assoc();
//echo '<pre>';print_r($row1);

$result3=$query->select_where('shristi_students_payment','student_id',$id);
$row3=$result3->fetch_assoc();
?>
<script type="text/javascript">
$(document).ready(function() {
	$('#Loading').hide();    
});
function check_username(){
	var username = $("#username").val();
	if(username.length > 2){
		$('#Loading').show();
		$.post("lib/ajaxclass.php", {
			username: $('#username').val(),
		}, function(response){
			$('#Info').fadeOut();
			 $('#Loading').hide();
			setTimeout("finishAjax('Info', '"+escape(response)+"')",450);
		});
		return false;
	}
}
function finishAjax(id, response){
   $('#'+id).html(unescape(response));
   $('#'+id).fadeIn(1000);
} 
</script>
<?php 

$msg=NULL;
extract($_REQUEST);
if(isset($submit)){
function test_input($data) {

  	$data = trim($data);
	//$data = stripslashes($data);
	$data = htmlspecialchars($data);
	$data=htmlspecialchars_decode($data);
	$data =strip_tags($data);
	$data = addslashes($data);
	return $data;
}	
$originalDate = $_POST['next_end_date'];
$next_end_date = date("Y-m-d", strtotime($originalDate));
	
	$data1=array(
		'center_id'			=>  test_input($_POST['center']),
		'courses_id'		=>  $_POST['course'],
		'join_batch'		=>  $_POST['join_batch'],
		'next_end_date'		=>	$next_end_date,
		'franchise_id'		=>  $_POST['franchise'],
		'registration_no'	=>	test_input($_POST['registration_no']),
		'fname'			=>	test_input($_POST['fname']),
		'lname'			=>	test_input($_POST['lname']),
		'email'			=>	test_input($_POST['email']),
		'join_batch_year'		=>	$join_batch_year,
		//'ip_address'			=>  $ip,
	);

$update=$query->qry_update('shristi_student','student_id',$data1,$id);	

    $data2=array(
		
		'mobile1'			=>  test_input($_POST['mobile1']),
		'dob'				=>	test_input($_POST['bod']),
		'gender'			=>	test_input($_POST['gender']),
		'father_name'		=>	test_input($_POST['father_name']),
		'mother_name'		=>	test_input($_POST['mother_name']),
		'p_address'			=>	test_input($_POST['p_address']),
		'c_address'			=>	test_input($_POST['c_address']),
		'city'				=>	test_input($_POST['city']),
		'state'				=>	test_input($_POST['state']),
		'p_code'			=>	test_input($_POST['p_code']),
		'mboard'			=>  test_input($_POST['matriculation1']),
		'myear'				=>	test_input($_POST['matriculation2']),
		'mprecentage'		=>	test_input($_POST['matriculation3']),
		'hboard'			=>	test_input($_POST['h_s1']),
		'hyear'				=>	test_input($_POST['h_s2']),
		'hprecentage'		=>	test_input($_POST['h_s3']),
		'oboard'			=>	test_input($_POST['o_q1']),
		'oyear'				=>	test_input($_POST['o_q2']),
		'oprecentage'		=>  test_input($_POST['o_q3']),
		'gboard'			=>	test_input($_POST['graduation1']),
		'gyear'				=>	test_input($_POST['graduation2']),
		'gprecentage'		=>	test_input($_POST['graduation3']),
		
	);

	

$data3=array(
		
		'amount'		=>	test_input($_POST['amount']),
		'status'		=>	test_input($_POST['payment_status']),
		
	);
		

if($update){
		$update1=$query->qry_update('shristi_students_details','student_id',$data2,$id);	
		if($update1){
			$update2=$query->qry_update('shristi_students_payment','student_id',$data3,$id);
			
			//echo $UpdateQuery="update shristi_students_payment set payment_status='paid',amount='".$_POST['amount']."' where student_id='".$id."' && assignment_id='0' ";
			//$result=$this->conn->query($UpdateQuery);
			
			if($_POST['payment_status']=='paid')
			{
				$data4=array(
		
		'final_exam_payment'		=>	'1',
		
	);
			$update2=$query->qry_update('shristi_student','student_id',$data4,$id);
			$message->success_updated();
			}else {
				$message->success_updated();
			}
				echo "<meta http-equiv=\"refresh\" content=\"1;URL=list_student.php\">";
		}
	}else{$message->error();}
  }
 ?>
<div id="main">
        <div class="container-fluid">
            <div class="page-header">
                <div class="pull-left">
                  <h3><i class="icon-ok"></i>Add Student</h3>
                </div>
                <div class="pull-right">
					<ul class="stats">
						 <li class='lightred'>
                            <i class="icon-calendar"></i>
                            <div class="details">
                                <span class="big">February 22, 2013</span>
                                <span>Wednesday, 13:56</span>
                            </div>
                        </li>
                    </ul>
                </div>
              </div>
<div class="breadcrumbs">
                <ul>
                    <li>
                        <a href="home.php">Home</a>
                        <i class="icon-angle-right"></i>
                    </li>
					<li>
                        <a href="">Add Student</a>
                    </li>
                </ul>
                <div class="close-bread">
                    <a href="#"><i class="icon-remove"></i></a>
                </div>
            </div>
<div class="row-fluid">
                <div class="span12">
                    <div class="box box-bordered box-color">
                        <div class="box-title">
                            <h3><i class="icon-th-list"></i> Student</h3>
                        </div>
                      <div class="box-content nopadding">
					<?php echo $msg;?>
                            <form method="POST" class='form-horizontal form-column form-bordered form-validate' id="bb"  enctype="multipart/form-data">
                         <div class="span12" style="background-color:#848484;">
                                    <h4 style="color:#fff; margin-left:50px;">Student information</h4></div>
                                <div class="span6">
                                   <div class="control-group">
                                        <label for="textfield" class="control-label">First Name</label>
                                        <div class="controls">
                                            <input type="text" name="fname" id="textfield1" placeholder="First Name" class="input-xlarge"  data-rule-required="true" data-rule-minlength="3" value="<?php echo $row1['fname'];?>">
                                        <span class="errors"></span>    
                                        </div>
                                    </div>
                                    <div class="control-group">
                                        <label for="password" class="control-label">Last Name</label>
                                        <div class="controls">
                                            <input type="text" name="lname" id="textfield3" placeholder="Last Name" class="input-xlarge" value="<?php echo $row1['lname'];?>"">

                                        </div>
                                    </div>
                                    <?php 
										$today = date("ymd");
										$rand = strtoupper(substr(uniqid(sha1(time())),0,4));
										$unique1 = $today . $rand;?>
								<div class="control-group">
                                        <label for="password" class="control-label">Student ID</label>
                                        <div class="controls">
                                            <input type="text" name="registration_no" id="textfield4"  class="input-xlarge" data-rule-minlength="4" data-rule-required="true" value="<?php echo $row1['registration_no'];?>" readonly>
										 </div>
									 </div>

                                    <div class="control-group">
                                        <label for="textfield" class="control-label">Father's Name</label>
                                        <div class="controls">
                                            <input type="text" name="father_name" id="textfield" placeholder="Father Name" class="input-xlarge" value="<?php echo $row2['father_name'];?>">

                                        </div>
                                    </div>
									<div class="control-group">
                                        <label for="password" class="control-label">Email</label>
                                        <div class="controls">
                                            <input type="text" name="email" id="username" placeholder="Email" class="input-xlarge" data-rule-email="true"  data-rule-minlength="5" data-rule-required="true" value="<?php echo $row1['email'];?>" onblur="return check_username();">										
                                            <div id="Info"></div>
                                            <span id="Loading"><img src="css/loader.gif" alt="" ></span>
                                        </div>
                                    </div>
                                </div>
                                <div class="span6">
                                <div class="control-group">
                                        <label for="textfield" class="control-label">Mother's Name</label>
                                        <div class="controls">
                                            <input type="text" name="mother_name" id="textfield" placeholder="Mother Name" class="input-xlarge" value="<?php echo $row2['mother_name'];?>">

                                        </div>
                                    </div>
                                    <div class="control-group">
                                        <label for="textfield" class="control-label">Contact Number</label>
                                        <div class="controls">
                                            <input type="text" name="mobile1" id="cell_one" placeholder="Contact Number" class="input-xlarge" data-rule-minlength="10" data-rule-maxlength="10"  data-rule-number="true" value="<?php echo $row2['mobile1'];?>" data-rule-required="true">
                                         <span id="mobile_status" style="color:#F00;"></span>   
                                        </div>
                                    </div>
                                    <div class="control-group">
                                        <label for="textfield" class="control-label">Gender</label>
                                        <div class="controls">
                                         <select name="gender" id="select1" class='input-large' data-rule-required="true">
                                         	<option value="<?php echo $row2['gender'];?>"><?php echo $row2['gender'];?></option>
                                          <option value="">Select Gender</option>
                                          <option value="Male">Male</option>
                                          <option value="Female">Female</option>
                                          <option value="Other">Other</option>
                                          </select>
                                        </div>
                                    </div>
									
                                    <div class="control-group">
                                        <label for="textfield" class="control-label">D.O.B</label>
                                        <div class="controls">
                                           <input type="text" name="bod" id="textfield99" class="input-medium datepick" placeholder="DD/MM/YYYY" data-rule-required="true" value="<?php echo $row2['dob'];?>">
                                        </div>
                                    </div>
                                <div class="control-group">
                                        <label for="textfield" class="control-label">Reg. End Date</label>
						<?php 
						
						$orgDate = $row1['next_end_date'];
$nextenddate = date("m/d/Y", strtotime($orgDate));

						
						?>				
                                        <div class="controls">
                                           <input type="text" name="next_end_date" id="next_end_date" class="input-medium datepick" placeholder="YYYY-MM-DD"  value="<?php echo $nextenddate;?>">
                                        </div>
                                    </div>
                                
								
								</div>
								<div class="span12" style="background-color:#848484;">
                                    <h4 style="color:#fff; margin-left:50px;">Address</h4></div>
                                <div class="span6">
                                    <div class="control-group">
                                       <label for="textfield" class="control-label">Present Address</label>
                                      <div class="controls">
                        <textarea name="p_address" placeholder="Present Address" class='input-large' data-rule-required="true"><?php echo $row2['p_address'];?></textarea>

                                        </div>
                                    </div>
									<div class="control-group">
                                        <label for="textfield" class="control-label">Communication Address</label>
                                        <div class="controls">
                                       <textarea name="c_address" placeholder="Communication Address" data-rule-required="true" class='input-large'><?php echo $row2['c_address'];?></textarea>
                                       </div>
                                    </div>
								</div>
                                <div class="span6">
                                    
                                    <div class="control-group">
                                       <label for="textfield" class="control-label">State</label>
                                        <div class="controls">
                                   
								   <select class="form-control" name="state" id="state" >
								                                           <option id="state" value="" >Select State</option>
	                                     <?php 
											$result=$query->select_where('shristi_tblstate','status','1');
											while($row=$result->fetch_assoc()){
											if($row['StateID']==$row2['state'])
											{
											$style='selected';	
											}else {
											$style='';	
											}												
												
											?>
                                            <option <?php echo $style; ?> value="<?php echo $row['StateID'];?>"><?php echo $row['StateName'];?></option>
                                            <?php }?>
                                    </select>
								   
								   

                                        </div>
                                    </div>
									<div class="control-group">
                                        <label for="textfield" class="control-label">City</label>
                                        <div class="controls">
                                    
									<select class="form-control" name="city" id="city">
									   <?php $result11=$query->select_where('shristi_tbldistrict','DistrictId',$row2['city']);
									$rowst4=$result11->fetch_assoc();
									?>
                                    <option value="<?php echo $rowst4['DistrictId'];?>"><?php echo $rowst4['DistrictName'];?></option>
                                    	<option value="">Select City</option>
                                        
                                    </select>
									
									
                                        </div>
                                    </div>
                                    
									
									<div class="control-group">
                                       <label for="textfield" class="control-label">Postal Code</label>
                                       <div class="controls">
                                   <input type="text" name="p_code" id="textfield1111" placeholder="Postal Code" class="input-xlarge" data-rule-required="true" value="<?php echo $row2['p_code'];?>">
                                        </div>
                                    </div>
								</div>
                                <div class="span12" style="background-color:#848484;">
                                    <h4 style="color:#fff; margin-left:50px;">Course Information</h4></div>
								<div class="span6">
                                    <div class="control-group">
                                        <label for="textfield" class="control-label">Course Selected</label>
                                        <div class="controls">
                                        <select name="course"  class='input-large' data-rule-required="true">
                                    <?php $result11=$query->select_where('shristi_course','courses_id',$row1['courses_id']);
									$row4=$result11->fetch_assoc();
									?>
                                    <option value="<?php echo $row4['courses_id'];?>"><?php echo $row4['name'];?></option>
                                            <option value="">Select Course</option>
                                            <?php 
											$result=$query->select_where('shristi_course','status','1');
											while($row=$result->fetch_assoc()){
											?>
                                            <option value="<?php echo $row['courses_id'];?>"><?php echo $row['name'];?></option><input type="hidden" name="amount" value="<?php echo $row['fee'];?>">
                                            <?php }?>
                                            </select>
                						</div>
                                    </div>
                                    <div class="control-group">
                                        <label for="textfield" class="control-label">Joining Batch</label>
                                        <div class="controls">
                                   <select name="join_batch"  class='input-large' data-rule-required="true">
                                   			<option value="<?php echo $row1['join_batch'];?>"><?php echo $row1['join_batch'];?></option>
                                            <option value="">Select  Batch</option>
                                            <option value="January">January</option>
                                            <option value="July">July</option>
                                   </select>
                                   <select name="join_batch_year"  class='input-large' data-rule-required="true">
                                            <option class="<?php echo $row1['join_batch_year'];?>"><?php echo $row1['join_batch_year'];?></option>
                                            <option value="">Select  Batch year</option>
                                        <?php for($i=2010;$i<2051;$i++){?>    
                                            <option value="<?php echo $i;?>"><?php echo $i;?></option>
                                         <?php }?>
                                  </select>
                                        </div>
                                     </div>
								</div>
                                <div class="span6">
                                    <div class="control-group">
                                        <label for="textfield" class="control-label">Center</label>
                                        <div class="controls">
                                        <select name="center"  class='input-large' id="center">
                                        <?php 
										$center1=$query->select_where('shristi_center','center_id',$row1['center_id']);
										$row5=$center1->fetch_assoc();
										 
										?>
                                        	<option value="<?php echo $row5['center_id'];?>"><?php echo $row5['name'];?></option>
                                            <option value="">Select Center</option>
                                            <?php $center=$query->select('shristi_center');
										while($center_row=$center->fetch_assoc()){
										?>
                                        <option value="<?php echo $center_row['center_id'];?>"><?php echo $center_row['name'];?></option><?php }?>
                                          </select>
                                       </div>
                                    </div>
                                    <div class="control-group">
                                        <label for="textfield" class="control-label">Franchise</label>
                                        <div class="controls">
                                        <select class="input-xlarge" name="franchise" data-rule-required="true" id="franchise">
										<?php 
										$franchise=$query->select_where('shristi_franchise','franchise_id',$row1['franchise_id']);
										$row6=$franchise->fetch_assoc();
										?>
                                <option value="<?php echo $row6['franchise_id'];?>"><?php echo $row6['name'];?></option>
                                      <option value="">select Franchise</option>
                                      </select>
                						</div>
                                    </div>
								</div>
								<div style="clear:both"></div>
								<div class="education_qualification">
                                <div class="span12" style="background-color:#848484;">
                                    <h4 style="color:#fff; margin-left:50px;">Educational Qualification</h4></div>
                                    <div class="span12">
                                    <div class="span3"></div>
                                    <div class="input_label"><label class="control-label"><strong>Board/University</strong></label></div>
                                                                        <div class="input_label"><label class="control-label"><strong>Year of Passing</strong></label></div>



                                    <div class="input_label"><label class="control-label"><strong>Percentage of Marks</strong></label></div>
                                   </div>
								   
									<div class="span12">
                                    <div class="control-group">
                                        <label for="textfield" class="control-label">Matriculation</label>
                                        <div class="controls">
                                            
										<select class="form-control span4" name="matriculation1" id="textfield101" >
                                        <option value="" >Select Matriculation</option>
	                                     <?php 
											$result=$query->select_where('shristi_board','status','1');
											while($row=$result->fetch_assoc()){
											if($row['id']==$row2['mboard'])
											{
											 $sty='selected';
											}else {
											$sty='';
											}
											
											
											?>
                                            <option <?php echo $sty;?> value="<?php echo $row['id'];?>"><?php echo trim($row['name']);?></option>
                                            <?php }?>
                                    </select>	
											
											
                                          
								<?php	 $currently_selected = $row2['myear']; 
$earliest_year = 1970; 
$latest_year = date('Y');
$earliest_year [1970]; 
echo  '<select class="form-control span3" name="matriculation2" id="textfield102" >';


  foreach ( range( $latest_year, $earliest_year ) as $i ) {
    
    print '<option value="'.$i.'"'.($i == $currently_selected ? 'selected' : '').'>'.$i.'</option>';
  }
  print '</select>';	?>	
											
											
											
                                            <input type="text" name="matriculation3" id="textfield103" class="input-xlarge" data-rule-required="true" value="<?php echo $row2['mprecentage'];?>">

                                        </div>
                                    </div>
                                    <div class="control-group">
                                        <label for="textfield" class="control-label">Higher Secondary</label>
                                        <div class="controls">
                                           
											<select class="form-control span4" name="h_s1" id="textfield21" >
                                        <option value="" >Select Higher Secondary</option>
	                                     <?php 
											$result=$query->select_where('shristi_board','status','1');
											while($row=$result->fetch_assoc()){
											if($row['id']==$row2['hboard'])
											{
											 $sty1='selected';
											}else {
											$sty1='';
											}
											
											
											?>
                                            <option <?php echo $sty1;?> value="<?php echo $row['id'];?>"><?php echo trim($row['name']);?></option>
                                            <?php }?>
                                    </select>
											
											
											
                                          
											<?php	 $currently_selected = $row2['hyear']; 
$earliest_year = 1970; 
$latest_year = date('Y');
$earliest_year [1970]; 
echo  '<select class="form-control span3" name="h_s2" id="textfield22" >';


  foreach ( range( $latest_year, $earliest_year ) as $i ) {
    
    print '<option value="'.$i.'"'.($i == $currently_selected ? 'selected' : '').'>'.$i.'</option>';
  }
  print '</select>';	?>	
											
											
											
                                            <input type="text" name="h_s3" id="textfield23"  class="input-xlarge" value="<?php echo $row2['hprecentage'];?>">
                                        </div>
                                    </div>
                                    <div class="control-group">
									   <label for="textfield" class="control-label">Graduation</label>
                                        <div class="controls">
                                            
                                             
											 
											 <select class="form-control span4" name="graduation1" id="textfield115" >
                                        <option value="" >Select Graduation</option>
	                                     <?php 
											$result=$query->select_where('shristi_university','status','1');
											while($row=$result->fetch_assoc()){
											if($row['id']==$row2['gboard'])
											{
											 $sty2='selected';
											}else {
											$sty2='';
											}
											
											
											?>
                                            <option <?php echo $sty2;?> value="<?php echo $row['id'];?>"><?php echo trim($row['university']);?></option>
                                            <?php }?>
                                    </select>
											
											
											
                                          
											<?php	 $currently_selected = $row2['gyear']; 
$earliest_year = 1970; 
$latest_year = date('Y');
$earliest_year [1970]; 
echo  '<select class="form-control span3" name="graduation2" id="textfield116" >';


  foreach ( range( $latest_year, $earliest_year ) as $i ) {
    
    print '<option value="'.$i.'"'.($i == $currently_selected ? 'selected' : '').'>'.$i.'</option>';
  }
  print '</select>';	?>	
											 
											 
                                             <input type="text" name="graduation3" id="textfield117"  class="input-xlarge" value="<?php echo $row2['gprecentage'];?>">
                                        </div>
                                    </div>
                                    
									<div class="control-group">
                                        <label for="textfield" class="control-label">Other Qualification</label>
						<div class="controls">
						<input type="text" name="o_q1" id="textfield"  class="input-xlarge" value="<?php echo $row2['oboard'];?>">
						<input type="text" name="o_q2" id="textfield" class="input-xlarge" value="<?php echo $row2['oyear'];?>">
						<input type="text" name="o_q3" id="textfield"  class="input-xlarge" value="<?php echo $row2['oprecentage'];?>">



                                        </div>
                                    </div>
                                 </div>



                                <div class="span12" style="background-color:#848484;">



                                    <h4 style="color:#fff; margin-left:50px;">Payment Information</h4></div>
								<div class="span6">
                                    <div class="control-group">
                                        <label for="textfield" class="control-label">Payment Status</label>
                                        <div class="controls">
                   							<select name="payment_status" id="fee" class='input-large' data-rule-required="true">
                                            <option value="<?php echo $row3['status'];?>"><?php echo $row3['status'];?></option>
                                            <option value="">Select fee</option>
											<option value="paid">Paid</option>
											<option value="unpaid">Unpaid</option>

										 </select>



                                        </div>



                                    </div>



                                </div>



                                <div class="span6">



                               		<div class="control-group">



                                        <label for="textfield" class="control-label">Total Ammount</label>



                                        <div class="controls">



                   						<input type="text"  value="<?php echo $row3['amount'];?>" id="amount" name="ammount">	



                                        </div>



                                    </div>



                                   </div>



 



                         



                               <div class="span12" style="background-color:#368ee0; padding:5px 0px 5px 20px;">



								<button type="submit" name="submit" value="submit" class="btn btn-primary">Save</button>



                                <button type="button" class="btn" id="something">Cancel</button>



                                </div>
                            </form>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    </div>
 <?php include_once('include/footer.php');?>   
<!--ajax library-->

<script type="text/javascript">
$(document).ready(function(){
    $('#center').on('change',function(){
        var centerID = $(this).val();
		//alert(centerID);
        if(centerID){
            $.ajax({
				type:'POST',
                url:'lib/ajaxclass.php',
                data:'center_id='+centerID,
                success:function(html){
                    $('#franchise').html(html);
                }
            }); 
        }else{
            $('#franchise').html('<option value="">Select Center first</option>');
        }
    });
  });
  
 $(document).ready(function(){
    $('#state').on('change',function(){
        var centerID = $(this).val();
		//alert(centerID);
        if(centerID){
            $.ajax({
				type:'POST',
                url:'../lib/ajaxclass3.php',
                data:'center_id='+centerID,
                success:function(html){
                    $('#city').html(html);
                }
            }); 
        }else{
            $('#city').html('<option value="">Select City</option>');
        }
    });
  });
   
  
</script>

		</div>
    </body>
  </html>