<?php
//header('refresh: 2');
include('connection.php');
$key = $_GET['key'];
$select = "SELECT * FROM students WHERE id='$key'";
$sql = mysqli_query($conn, $select);
$fetch = mysqli_fetch_object($sql);
if (isset($_POST['submit'])) {
  $errors = [];
  $fn = strtoupper($_POST['fn']);
  $gd = strtoupper($_POST['gd']);
  $cl = strtoupper($_POST['cl']);
  $lp = strtoupper($_POST['lp']);
  $st = strtoupper($_POST['st']);
  $dt = strtoupper($_POST['dt']);
  $u = strtoupper($_POST['ud']);
  $ub = strtoupper($_POST['ud_b']);
  $j = strtoupper($_POST['jan']);
  $jb = strtoupper($_POST['jan_b']);
  $a = strtoupper($_POST['apr']);
  $ab = strtoupper($_POST['apr_b']);
  $jl = strtoupper($_POST['jul']);
  $jlb = strtoupper($_POST['jul_b']);
  $s = strtoupper($_POST['sep']);
  $sp = strtoupper($_POST['sep_b']);
  $ot = strtoupper($_POST['others']);
  $otb = strtoupper($_POST['others_b']);
  $staa = strtoupper($_POST['sta']);
  $stab = strtoupper($_POST['sta_b']);
  $toura = strtoupper($_POST['tour']);
  $tourb = strtoupper($_POST['tour_b']);

  //date fields
  $date_ud = strtoupper($_POST['ud_d']);
  $date_jan = strtoupper($_POST['dt_d']);
  $date_apr = strtoupper($_POST['apr_d']);
  $date_jul = strtoupper($_POST['jul_d']);
  $date_sep = strtoupper($_POST['sep_d']);
  $date_o = strtoupper($_POST['o_d']);
  //end date fields
  //... start validating




  $query = "UPDATE students SET fn = '$fn', gd = '$gd', cl= '$cl', lp = '$lp',st= '$st', dt='$dt',ud='$u',ud_b='$ub',jan='$j',jan_b='$jb',apr='$a',apr_b='$ab',jul='$jl',jul_b='$jlb',sep='$s',sep_b='$sp',others='$ot',others_b='$otb',sta='$staa',sta_b='$stab',tour='$toura',tour_b='$tourb',dt='$date_jan',date_ud='$date_ud',date_apr='$date_apr',date_jul='$date_jul',date_sep='$date_sep',date_o='$date_o' WHERE id='$key'";
  echo $query;
  $query_run = mysqli_query($conn, $query);
  if ($query_run) {
    header("location:standard5.php");
  } else {
    echo "wrong";
  }
}

?>



<?php include 'includes/header.php'; ?>

<?php include 'includes/sidebar.php'; ?>
<?php include 'includes/topbar.php'; ?>


<!-- page content -->
<div class="right_col" role="main">
  <div class="">
    <div class="clearfix"></div>

    <div class="row">
      <div class="col-md-12 col-sm-12">
        <div class="x_panel">
          <div class="x_title">
            <h2>Student Payment Update Form</h2>
            <ul class="nav navbar-right panel_toolbox">
              <li><a class="collapse-link"><i class="fa fa-chevron-up"></i></a>
              </li>
            </ul>
            <div class="clearfix"></div>
          </div>
          <div class="x_content">
            <form class="" action="" method="post" novalidate>
                <div class="field item form-group">
                <label class="col-form-label col-md-3 col-sm-3  label-align">Full Name<span class="required">*</span></label>
                <div class="col-md-6 col-sm-6">
                  <input class="form-control" value="<?php echo $fetch->fn; ?>" name="fn" data-validate-minmax="10,100" data-validate-length-range="6" data-validate-words="2"required='required' autocomplete="off" >
                </div>
              </div>
              <div class="field item form-group">
                <label class="col-form-label col-md-3 col-sm-3  label-align">Gender</label>
                <div class="col-md-6 col-sm-6">
                  <select class="form-control" name="gd">
                   <option value="<?php echo $fetch->gd ?>"><?php echo $fetch->gd ?></option>
                    <option value="Male">Male</option>
                    <option value="Female">Female</option>
                  </select>
                </div>
              </div>
              <div class="field item form-group">
                <label class="col-form-label col-md-3 col-sm-3  label-align">Select Class</label>
                <div class="col-md-6 col-sm-6">
                  <select class="form-control" name="cl">
                   <option value="<?php echo $fetch->cl ?>"><?php echo $fetch->cl ?></option>
                    <option value="Nursery">Nursery</option>
                    <option value="STD I">STD I</option>
                    <option value="STD II">STD II</option>
                    <option value="STD III">STD III</option>
                    <option value="STD IV">STD IV</option>
                    <option value="STD V">STD V</option>
                    <option value="STD VI">STD VI</option>
                    <option value="STD VII">STD VII</option>
                  </select>
                </div>
              </div>
              <div class="field item form-group">
                <label class="col-form-label col-md-3 col-sm-3  label-align">Live Place</label>
                <div class="col-md-6 col-sm-6">
                  <select class="form-control" name="lp">
                   <option value="<?php echo $fetch->lp ?>"><?php echo $fetch->lp ?></option>
                    <option value="Day">Day</option>
                    <option value="Bording">Boarding</option>
                  </select>
                </div>
              </div>
              <div class="field item form-group">
                <label class="col-form-label col-md-3 col-sm-3  label-align">Status</label>
                <div class="col-md-6 col-sm-6">
                  <select class="form-control" name="st">
                    <option value="<?php echo $fetch->st ?>"><?php echo $fetch->st ?></option>
                    <option value="New">New</option>
                    <option value="Old">Old</option>
                  </select>
                </div>
              </div>
              <div class="control-group field item form-group">
                <label class="col-form-label col-md-3 col-sm-3  label-align">Date<span class="required">*</span></label>
                <div class="controls">
                  <div class="col-md-12 col-mx-12 col-sm-6">
                    <input name="dt" type="text" class="form-control has-feedback-left" id="single_cal2" aria-describedby="inputSuccess2Status2" value="<?php echo $fetch->dt; ?>" data-validate-minmax="10,100" required='required' autocomplete="off" onkeydown='return (event.which >= 48 && event.which <= 57)  || event.which == 8 || event.which == 46'>
                    <span class="fa fa-calendar-o form-control-feedback left" aria-hidden="true"></span>
                    <span id="inputSuccess2Status2" class="sr-only">(success)</span>
                  </div>
                </div>
              </div>
          
              <hr>
              <div class="field item form-group">
                <label class="col-form-label col-md-3 col-sm-3  label-align">Uniform &amp; Development <span class="required">*</span></label>
                <div class="col-md-6 col-sm-6">
                  <input class="form-control" type="text" class='number' value="<?php echo $fetch->ud; ?>" name="ud" data-validate-minmax="10,100" required='required' autocomplete="off" onkeydown='return (event.which >= 48 && event.which <= 57)  || event.which == 8 || event.which == 46'></div>
              </div>
              <div class="field item form-group">
                <label class="col-form-label col-md-3 col-sm-3  label-align">Bank Paid</label>
                <div class="col-md-6 col-sm-6">
                  <select class="form-control" name="ud_b">
                    <option value="<?php echo $fetch->ud_b ?>"><?php echo $fetch->ud_b ?></option>
                    <option value="NMB">NMB</option>
                    <option value="CRDB">CRDB</option>
                    <option value="TPB">CASH</option>
                  </select>
                </div>
              </div>

              <div class="control-group field item form-group">
                <label class="col-form-label col-md-3 col-sm-3  label-align">Date<span class="required">*</span></label>
                <div class="controls">
                  <div class="col-md-12 col-mx-12 col-sm-6">
                    <input type="text" class="form-control has-feedback-left" name="ud_d" value="<?php echo $fetch->date_ud; ?>" aria-describedby="inputSuccess2Status2">
                    <span class="fa fa-calendar-o form-control-feedback left" aria-hidden="true"></span>
                    <span id="inputSuccess2Status2" class="sr-only">(success)</span>
                  </div>
                </div>
              </div>

              <hr>
              <h4 style="margin-left: 20%;">School Fees In Term</h4>
              <hr>
              <div class="field item form-group">
                <label class="col-form-label col-md-3 col-sm-3  label-align">Junuary Amount<span class="required">*</span></label>
                <div class="col-md-6 col-sm-6">
                  <input class="form-control" type="text" class='number' value="<?php echo $fetch->jan ?>" name="jan" data-validate-minmax="10,100" required='required' autocomplete="off" onkeydown='return (event.which >= 48 && event.which <= 57)  || event.which == 8 || event.which == 46'></div>
              </div>
              <div class="field item form-group">
                <label class="col-form-label col-md-3 col-sm-3  label-align">Bank Paid</label>
                <div class="col-md-6 col-sm-6">
                  <select class="form-control" name="jan_b">
                    <option value="<?php echo $fetch->jan_b ?>"><?php echo $fetch->jan_b ?></option>
                    <option value="NMB">NMB</option>
                    <option value="CRDB">CRDB</option>
                    <option value="TPB">CASH</option>
                  </select>
                </div>
              </div>

              <div class="control-group field item form-group">
                <label class="col-form-label col-md-3 col-sm-3  label-align">Date<span class="required">*</span></label>
                <div class="controls">
                  <div class="col-md-12 col-mx-12 col-sm-6">
                    <input type="text" class="form-control has-feedback-left"  name="dt_d" value="<?php echo $fetch->dt; ?>" aria-describedby="inputSuccess2Status2">
                    <span class="fa fa-calendar-o form-control-feedback left" aria-hidden="true"></span>
                    <span id="inputSuccess2Status2" class="sr-only">(success)</span>
                  </div>
                </div>
              </div>
              <hr>
              <div class="field item form-group">
                <label class="col-form-label col-md-3 col-sm-3  label-align">April Amount<span class="required">*</span></label>
                <div class="col-md-6 col-sm-6">
                  <input class="form-control" type="text" class='number' name="apr" value="<?php echo $fetch->apr ?>" data-validate-minmax="10,100" required='required' autocomplete="off" onkeydown='return (event.which >= 48 && event.which <= 57)  || event.which == 8 || event.which == 46'></div>
              </div>
              <div class="field item form-group">
                <label class="col-form-label col-md-3 col-sm-3  label-align">Bank Paid</label>
                <div class="col-md-6 col-sm-6">
                  <select class="form-control" name="apr_b">
                    <option value="<?php echo $fetch->apr_b ?>"><?php echo $fetch->apr_b ?></option>
                    <option value="NMB">NMB</option>
                    <option value="CRDB">CRDB</option>
                    <option value="TPB">CASH</option>
                  </select>
                </div>
              </div>
              <div class="control-group field item form-group">
                <label class="col-form-label col-md-3 col-sm-3  label-align">Date<span class="required">*</span></label>
                <div class="controls">
                  <div class="col-md-12 col-mx-12 col-sm-6">
                    <input type="text" class="form-control has-feedback-left"  name="apr_d" value="<?php echo $fetch->date_apr; ?>" aria-describedby="inputSuccess2Status2">
                    <span class="fa fa-calendar-o form-control-feedback left" aria-hidden="true"></span>
                    <span id="inputSuccess2Status2" class="sr-only">(success)</span>
                  </div>
                </div>
              </div>
              <hr>
              <div class="field item form-group">
                <label class="col-form-label col-md-3 col-sm-3  label-align">July Amount<span class="required">*</span></label>
                <div class="col-md-6 col-sm-6">
                  <input class="form-control" type="text" class='number' value="<?php echo $fetch->jul ?>" name="jul" data-validate-minmax="10,100" required='required' autocomplete="off" onkeydown='return (event.which >= 48 && event.which <= 57)  || event.which == 8 || event.which == 46'></div>
              </div>
              <div class="field item form-group">
                <label class="col-form-label col-md-3 col-sm-3  label-align">Bank Paid</label>
                <div class="col-md-6 col-sm-6">
                  <select class="form-control" name="jul_b">
                    <option value="<?php echo $fetch->jul_b ?>"><?php echo $fetch->jul_b ?></option>
                    <option value="NMB">NMB</option>
                    <option value="CRDB">CRDB</option>
                    <option value="TPB">CASH</option>
                  </select>
                </div>
              </div>

              <div class="control-group field item form-group">
                <label class="col-form-label col-md-3 col-sm-3  label-align">Date<span class="required">*</span></label>
                <div class="controls">
                  <div class="col-md-12 col-mx-12 col-sm-6">
                    <input type="text" class="form-control has-feedback-left"  name="jul_d" value="<?php echo $fetch->date_jul; ?>" aria-describedby="inputSuccess2Status2">
                    <span class="fa fa-calendar-o form-control-feedback left" aria-hidden="true"></span>
                    <span id="inputSuccess2Status2" class="sr-only">(success)</span>
                  </div>
                </div>
              </div>
              <hr>
              <div class="field item form-group">
                <label class="col-form-label col-md-3 col-sm-3  label-align">september Amount<span class="required">*</span></label>
                <div class="col-md-6 col-sm-6">
                  <input class="form-control" type="text" class='number' value="<?php echo $fetch->sep ?>" name="sep" data-validate-minmax="10,100" required='required' autocomplete="off" onkeydown='return (event.which >= 48 && event.which <= 57)  || event.which == 8 || event.which == 46'></div>
              </div>
              <div class="field item form-group">
                <label class="col-form-label col-md-3 col-sm-3  label-align">Bank Paid</label>
                <div class="col-md-6 col-sm-6">
                  <select class="form-control" name="sep_b">
                    <option value="<?php echo $fetch->sep_b ?>"><?php echo $fetch->sep_b ?></option>
                    <option value="NMB">NMB</option>
                    <option value="CRDB">CRDB</option>
                    <option value="TPB">CASH</option>
                  </select>
                </div>
              </div>

              <div class="control-group field item form-group">
                <label class="col-form-label col-md-3 col-sm-3  label-align">Date<span class="required">*</span></label>
                <div class="controls">
                  <div class="col-md-12 col-mx-12 col-sm-6">
                    <input type="text" class="form-control has-feedback-left"  name="sep_d" value="<?php echo $fetch->date_sep; ?>" aria-describedby="inputSuccess2Status2">
                    <span class="fa fa-calendar-o form-control-feedback left" aria-hidden="true"></span>
                    <span id="inputSuccess2Status2" class="sr-only">(success)</span>
                  </div>
                </div>
              </div>
              <hr>
              <div class="field item form-group">
                <label class="col-form-label col-md-3 col-sm-3  label-align">Others Payment<span class="required">*</span></label>
                <div class="col-md-6 col-sm-6">
                  <input class="form-control" type="text" class='number' value="<?php echo $fetch->others ?>" name="others" data-validate-minmax="10,100" required='required' autocomplete="off" onkeydown='return (event.which >= 48 && event.which <= 57)  || event.which == 8 || event.which == 46'></div>
              </div>
              <div class="field item form-group">
                <label class="col-form-label col-md-3 col-sm-3  label-align">Bank Paid</label>
                <div class="col-md-6 col-sm-6">
                  <select class="form-control" name="others_b">
                    <option value="<?php echo $fetch->others_b ?>"><?php echo $fetch->others_b ?></option>
                    <option value="NMB">NMB</option>
                    <option value="CRDB">CRDB</option>
                    <option value="TPB">CASH</option>
                  </select>
                </div>
              </div>
                    <hr>
              <div class="field item form-group">
                <label class="col-form-label col-md-3 col-sm-3  label-align">Stationery Payments<span class="required">*</span></label>
                <div class="col-md-6 col-sm-6">
                  <input class="form-control" type="text" class='number' value="<?php echo $fetch->sta ?>" name="sta" data-validate-minmax="10,100" required='required' autocomplete="off" onkeydown='return (event.which >= 48 && event.which <= 57)  || event.which == 8 || event.which == 46'></div>
              </div>
              <div class="field item form-group">
                <label class="col-form-label col-md-3 col-sm-3  label-align">Bank Paid</label>
                <div class="col-md-6 col-sm-6">
                  <select class="form-control" name="others_b">
                    <option value="<?php echo $fetch->sta_b ?>"><?php echo $fetch->others_b ?></option>
                    <option value="NMB">NMB</option>
                    <option value="CRDB">CRDB</option>
                    <option value="TPB">CASH</option>
                  </select>
                </div>
              </div>
                    <hr>
              <div class="field item form-group">
                <label class="col-form-label col-md-3 col-sm-3  label-align">Tour&Outry Payments<span class="required">*</span></label>
                <div class="col-md-6 col-sm-6">
                  <input class="form-control" type="text" class='number' value="<?php echo $fetch->tour ?>" name="tour" data-validate-minmax="10,100" required='required' autocomplete="off" onkeydown='return (event.which >= 48 && event.which <= 57)  || event.which == 8 || event.which == 46'></div>
              </div>
              <div class="field item form-group">
                <label class="col-form-label col-md-3 col-sm-3  label-align">Bank Paid</label>
                <div class="col-md-6 col-sm-6">
                  <select class="form-control" name="tour_b">
                    <option value="<?php echo $fetch->tour_b ?>"><?php echo $fetch->others_b ?></option>
                    <option value="NMB">NMB</option>
                    <option value="CRDB">CRDB</option>
                    <option value="TPB">CASH</option>
                  </select>
                </div>
              </div>

              <div class="control-group field item form-group">
                <label class="col-form-label col-md-3 col-sm-3  label-align">Date<span class="required">*</span></label>
                <div class="controls">
                  <div class="col-md-12 col-mx-12 col-sm-6">
                    <input type="text" class="form-control has-feedback-left"  name="o_d" value="<?php echo $fetch->date_o; ?>" aria-describedby="inputSuccess2Status2">
                    <span class="fa fa-calendar-o form-control-feedback left" aria-hidden="true"></span>
                    <span id="inputSuccess2Status2" class="sr-only">(success)</span>
                  </div>
                </div>
              </div>
              <div class="">
                <div class="form-group">
                  <div class="col-md-6 offset-md-3">
                    <button type='submit' name="submit" class="btn btn-primary">Submit</button>
                    <button type='reset' class="btn btn-success">Reset</button>
                  </div>
                </div>
              </div>
            </form>
          </div>
        </div>
      </div>
    </div>
  </div>
</div>
<!-- /page content -->


<?php include 'includes/footer.php'; ?>