<?php
include('connection.php');
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']);
  //... start validating



  if ($fn === null) {
    $errors['fullname'] = 'The fullname field is required';
  } else if ($gd === '---SELECT---') {
    $errors['fullname'] = 'Please select gender fisrt';
  } else if ($lp === '---SELECT---') {
    $errors['fullname'] = 'Please select live place';
  } else if ($cl === '---SELECT---') {
    $errors['fullname'] = 'Please select class';
  } else if ($st === '---SELECT---') {
    $errors['fullname'] = 'Please select student Status';
  } else {

    $query = "INSERT INTO students(fn,gd,cl,lp,st,dt,ud,ud_b,jan,jan_b,apr,apr_b,jul,jul_b,sep,sep_b,others,others_b,sta,sta_b,tour,tour_b) VALUES ('$fn','$gd','$cl','$lp','$st','$dt','$u','$ub','$j','$jb','$a','$ab','$jl','$jlb','$s','$sp','$ot','$otb','$staa','$stab','$toura','$tourb')";

    $query_run = mysqli_query($conn, $query);
    $query_run = 1;
    $errors['sms'] = 'Data Uploaded Successfully';
  }
}

?>



<?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 Registration 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>
          <?php if (isset($errors['fullname'])) : ?>
            <div class="field item form-group">
              <label class="col-form-label col-md-3 col-sm-3  label-align"><span class="required"></span></label>
              <div class="col-md-6 col-sm-6">
                <button class="btn btn-danger"><?php echo $errors['fullname']; ?></button>
              </div>
            </div>
          <?php endif ?>
          <?php if (isset($errors['sms'])) : ?>
            <div class="field item form-group">
              <label class="col-form-label col-md-3 col-sm-3  label-align"><span class="required"></span></label>
              <div class="col-md-6 col-sm-6">
                <button class="btn btn-success"><?php echo $errors['sms']; ?></button>
              </div>
            </div>
          <?php endif ?>
          <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 if (isset($fn)) {
                                                        echo $fn;
                                                      } ?>" data-validate-length-range="6" data-validate-words="2" name="fn" placeholder="ex. John f. Kennedy" required="required" />
                </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>---Select---</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>---Select---</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>---Select---</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>---Select---</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">
                    <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%;">Uniform and Development</h4>
              <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 if (isset($u)) {
                                                                                  echo $u;
                                                                                } ?>" name="ud" data-validate-minmax="10,100" required='required' 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></option>
                    <option value="NMB">NMB</option>
                    <option value="CRDB">CRDB</option>
                    <option value="TPB">TPB</option>
                  </select>
                </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 if (isset($j)) {
                                                                                  echo $j;
                                                                                } ?>" name="jan" data-validate-minmax="10,100" required='required' 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></option>
                    <option value="NMB">NMB</option>
                    <option value="CRDB">CRDB</option>
                    <option value="TPB">TPB</option>
                  </select>
                </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" data-validate-minmax="10,100" required='required' 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></option>
                    <option value="NMB">NMB</option>
                    <option value="CRDB">CRDB</option>
                    <option value="TPB">TPB</option>
                  </select>
                </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 if (isset($jl)) {
                                                                                  echo $jl;
                                                                                } ?>" name="jul" data-validate-minmax="10,100" required='required' 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></option>
                    <option value="NMB">NMB</option>
                    <option value="CRDB">CRDB</option>
                    <option value="TPB">TPB</option>
                  </select>
                </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 if (isset($s)) {
                                                                                  echo $s;
                                                                                } ?>" name="sep" data-validate-minmax="10,100" required='required' 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></option>
                    <option value="NMB">NMB</option>
                    <option value="CRDB">CRDB</option>
                    <option value="TPB">TPB</option>
                  </select>
                </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 if (isset($ot)) {
                                                                                  echo $ot;
                                                                                } ?>" name="others" data-validate-minmax="10,100" required='required' 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></option>
                    <option value="NMB">NMB</option>
                    <option value="CRDB">CRDB</option>
                    <option value="TPB">TPB</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 Payment<span class="required">*</span></label>
                <div class="col-md-6 col-sm-6">
                  <input class="form-control" type="text" class='number' value="<?php if (isset($staa)) {
                                                                                  echo $staa;
                                                                                } ?>" name="sta" data-validate-minmax="10,100" required='required' 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="sta_b">
                    <option></option>
                    <option value="NMB">NMB</option>
                    <option value="CRDB">CRDB</option>
                    <option value="TPB">TPB</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 Payment<span class="required">*</span></label>
                <div class="col-md-6 col-sm-6">
                  <input class="form-control" type="text" class='number' value="<?php if (isset($toura)) {
                                                                                  echo $toura;
                                                                                } ?>" name="tour" data-validate-minmax="10,100" required='required' 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></option>
                    <option value="NMB">NMB</option>
                    <option value="CRDB">CRDB</option>
                    <option value="TPB">TPB</option>
                  </select>
                </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'; ?>