
 
<style> .alert-successs{background-color: #1eaf59;color: white;display: none}
            .required{color: #FF0000;}
            .error-message{font-size: 12px;color: red;display: none;}
            .col-md-6{margin: 12px;}
            h3 {color: #093dfb;}
    </style>
    
    <?php 
$student_main_info="";
$search="";
$update_date= date("d-m-Y");

if(isset($_POST['search'])){
    $search= $_POST["admission"];
  
    $result=mysqli_query($con, "SELECT * FROM `student_main_info_view` WHERE `id_admission` = '$search' ");
    }

    $student_main=mysqli_query($con, "SELECT * FROM `student_main_info` WHERE `id` = '$search'");
    $row=mysqli_fetch_assoc($result);
    $student_main_row=mysqli_fetch_assoc($student_main);

?> 
        
<?php 
$id_form=mysqli_query($con,"SELECT id_admission FROM `student`  order by id_admission desc limit 1");
$id_form_row= mysqli_fetch_assoc($id_form);

$yearf=mysqli_query($con,"SELECT year FROM `academic_year`  order by year desc limit 1");
$year_row= mysqli_fetch_assoc($yearf);
$uniqid= uniqid();
if (isset($_POST['submit'])){
    $id                 =$_POST['id'];
    $comment_st         =$_POST['comment_st'];
    $comment_st_date    =$_POST['comment_st_date'];
       $off                =$_POST['off'];
$year=$_POST['year'];
  $img          = $_FILES['student_img']; 
    $tmp_name     = $img['tmp_name']; 
    $file_name    = $uniqid.$img['name'];




$update= mysqli_query($con, "UPDATE `student_main_info` SET  off='$off', comment_st='$comment_st', comment_st_date='$comment_st_date' WHERE id='$id'  ");
$update_month= mysqli_query($con, "UPDATE `student_monthlyfee_new` SET  off_student='$off' WHERE student_id='$id' AND admissionyear='$year' ");


if($img['size'] > 1){ 
    if(file_exists("student_img/".$row['student_img']) && !empty($row['student_img'])){ 
        unlink("student_img/".$row['student_img']);
}
move_uploaded_file($tmp_name, "student_img/".$file_name); 
$update_sql = "UPDATE student SET student_img='$file_name' WHERE id='$id' ";



}else{ 
$update_sql = "UPDATE student SET update_date='$update_date'  WHERE id='$id' ";


}
$update_result = mysqli_query($con, $update_sql);
$updat = mysqli_query($con, $update);

if (mysqli_query($con,$update_result)===TRUE){
  
echo '<div class="alert alert-danger" role="alert">সংরক্ষণ হয় নাই</div>';
}else {
    echo '<div class="alert alert-success" role="alert">Data is successful saved !</div>';
}


if($updat==true){   
echo '<meta http-equiv="refresh" content="1">';
}

if($update_result==true){ 
echo '<meta http-equiv="refresh" content="1">';
}
}

?>
<br>
    
    <form action="" method="POST" enctype="multipart/form-data">

   
  <div class="col-xs-1" style="width: 203px;">
    <input style="color:red" type="text" class="form-control" name="admission" value="<?php echo isset($search) ? $search:'' ?>" placeholder="দাখিলা">
    <input type="hidden" class="form-control" name="id" value="<?php echo $row['id']?>">
  </div>
  <div class="col-xs-4">
  <button type="submit" name="search" class="btn btn-primary">খোঁজ করুন</button>
  </div>
</div>
<br>
<div class="alert alert-successs" id="successMessage">Data is successful saved !</div>
      <div class="row">
        <div class="col-md-12">
         
         <div class="row">
    <div class="col-md-4 col-sm-4 col-xs-4" >
<style>
  .red_color{color: red;}
</style>
<!-- /.from -->
<script>
function validateForm() {
  var x = document.forms["myForm"]["fname"].value;
  if (x == "") {
    alert("Name must be filled out");
    return false;
  }
}
</script>
<form me="myForm" onsubmit="return validateForm()" method="POST" action="" enctype="multipart/form-data">
        <table class="table-condensed"> 
            <tr>
                <td><strong><?=_name?> </strong></td><td><input type="text" name="fname"  id="name" class="form-control" value="<?php echo $row['name']?>" readonly="readonly"  tabindex="1"></td>           
            </tr>
            <tr>
                <td><strong><?= father?></strong></td><td><input type="text" name="father" id="father" class="form-control" value="<?php echo $row['father']?>" readonly="readonly" tabindex="2"></td>
            </tr>
            <tr>
                <td><strong><?= comment_st?></strong></td><td><input type="text" name="comment_st" id="comment_st"  value="<?php echo $row['comment_st']?>" class="form-control"  tabindex="2" ></td>
            </tr>      
        </table><br><br><br>
        
        <td><strong>চালু </strong></td><td>
            <label class="switch3">
              <input type="radio" name="off" value="0"<?php if($row['off']=='0'){
                                    echo 'checked';
                                } ?>  >
              <span class="slider3 round"></span>
            </label>
       
       
            <td><strong>বন্ধ</strong></td><td>
            <label class="switch">
              <input type="radio" name="off" value="1"<?php if($row['off']=='1'){
                                    echo 'checked';
                                } ?> >
              <span class="slider2 round"></span>
            </label></td>

    </div>




        <div class="col-md-4 col-sm-6 col-xs-12">
         <table  class="table-condensed">
            <tr>
                <td><strong><?= _Class?> </strong></td><td><input type="text" name="class_name" value="<?php echo $row['class_name']?>" id="class_name" readonly="readonly" class="form-control" ></td>
            </tr>
             <tr>
                <td><strong><?= Village?> </strong></td><td><input type="text" name="village" value="<?php echo $row['village']?>" id="village" readonly="readonly" class="form-control" ></td>
            </tr>           
             <tr>
                <td><strong><?= _date?> </strong></td><td><input type="date" name="comment_st_date"  id="comment_st_date"  class="form-control" ></td>
            </tr>
            </table>
    
     <div class="col-md-4 col-sm-6 col-xs-12">  
   <table  class="table-condensed">

   <td>    <?php 
                  if ($row['student_img']=="") {
                    echo '<img src="student_img/gr man.png" class="img-rounded img-thumbnail img-responsive" style="height: 100px;" id="apli_photo_image" >';
                  }else{
                    echo '<img src="student_img/'.$row['student_img'].'" class="img-rounded img-thumbnail img-responsive" style="    height: 100px;" id="apli_photo_image" >';
                  }
                  
                  ?>

        <input type="file" name="student_img" id="student_img" accept="image/jpeg, image/gif, image/png"/> 
        </table>

   <table  class="table-condensed">
           
        </table>
    </div>
</div>


        <div class="col-md-4 col-sm-6 col-xs-12">
      
        <table  class="table-condensed">
       


          
        </table></table></div>
        
<br><br><br><br><br><br><br><br><br><br><br><br><br>
        <button type="submit" name="submit" class="btn btn-md btn btn-info btn-block text-uppercase" tabindex="22"><span class="fa fa-plus"></span>  সম্পাদনা</button><br><br>
    
        <div class="col-md-4 col-sm-6 col-xs-12">

        </form>
        
    </div>
  </div>
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script type="text/javascript">
    
   
</form>
</div>
              
        <div class="col-md-6">
          <div class="box box-info">
            <div class="box-header with-border">
              <i class="fa fa-fw fa-eye text-green"></i>
              <h3 class="box-title"><?php echo _Classes;?></h3>
            </div>          

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


      
            
    <!-- Latest compiled and minified JavaScript -->
<script src="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js" integrity="sha384-aJ21OjlMXNL5UyIl/XNwTMqvzeRMZH2w8c5cRVpzpU8Y5bApTppSuUkhZXN0VxHd" crossorigin="anonymous"></script>                  
              </div>
              <!-- /.tab-pane -->
            </div>
            <!-- /.tab-content -->
          </div>
          <!-- nav-tabs-custom -->
        </div>
</div>



