<div class="container-fluid">
   <div class="row">
      <div class="col-sm-12 col-lg-12">
         <div class="iq-card">
            <div class="iq-card-header d-flex justify-content-between">
               <div class="iq-header-title">
                  <h4 class="card-title">Edit Pitches - <?= $pitches['name'] ?></h4>
               </div>
               <span class="table-add float-right mb-3 mr-2">
                  <a href="<?php echo base_url(); ?>doctor/" class="btn btn-default pull-right"><i class="fa fa-arrow-left" aria-hidden="true"></i> Back</a>&emsp;
               </span>
            </div>
            <div class="iq-card-body">
               <div class="alert alert-success Add" style="display: none;">
                    <strong>Successfully Edited Your Data!</strong>
                </div>
                <div class="alert alert-danger Adderror" style="display: none;">
                    <strong>Duplicate Entry!</strong>
                </div>
                <form role="form" method="post" id="editfrm">
                <div class="row">
                    <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
                        <div class="form-group">
                            <label>Game</label>
                            <select class="form-control" name="sport_id" required>
                                <option value="">Select Game</option>
                                <?php foreach ($category as $key => $category_data) {
                                 ?>
                                <option value="<?php echo  $category_data['id']; ?>" <?php if($pitches['sport_id']==$category_data['id']){ echo 'selected'; } ?>><?php echo  $category_data['name']; ?></option>
                            <?php } ?>
                            </select>
                            <br>
                        </div>
                    </div>
                    <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
                        <div class="form-group">
                            <label>Pitch Name</label>
                            <input type="text" name="name" id="name" class="form-control" required="" placeholder="Enter Pitch Name" value="<?= $pitches['name'] ?>"><br>
                        </div>
                    </div>
                    <div class="col-lg-6 col-md-6 col-sm-6 col-xs-12">
                        <div class="form-group">
                            <label>Slot step (minutes) </label>
                            <input type="number" name="slot_step_minutes" id="slot_step_minutes" class="form-control" required="" placeholder="Enter Slot step (minutes)" value="<?= $pitches['slot_step_minutes'] ?>"><br>
                        </div>
                    </div>
                    <div class="col-lg-6 col-md-6 col-sm-6 col-xs-12">
                        <div class="form-group">
                            <label>Max Advance Days </label>
                            <input type="number" name="max_advance_days" id="max_advance_days" class="form-control" required="" placeholder="Enter Max Advance Days" value="<?= $pitches['max_advance_days'] ?>"><br>
                        </div>
                    </div>
                    
                    
                    <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12" align="right">
                        <div class="form-group">
                            <button type="reset" class="btn btn-default"><i class="fa fa-repeat" aria-hidden="true"></i> Reset</button>
                            <button type="submit" class="btn btn-primary addbtn"><i class="fa fa-floppy-o" aria-hidden="true"></i> Save</button>
                            <button class="btn btn-primary addload buttonload" style="display: none;"><i class="fa fa-spinner fa-spin" style=" margin-left: -12px; margin-right: 8px;"></i>Please Wait</button>
                            <input type="hidden" name="id" value="<?= $pitches['id'] ?>">
                        </div>
                    </div>
                    
                </div>
                </form>
            </div>
         </div>
      </div>
   </div>
</div>
<script>
// just for the demos, avoids form submit
jQuery.validator.setDefaults({
success: "valid"
});
$("#editfrm").validate({
rules: {
d_code: {
required: true
}
}
});
</script>
<script>
$(document).ready(function(e) {
$("#editfrm").on('submit', function(e) {
e.preventDefault();
var formStatus = $('#editfrm').validate().form();
if (true == formStatus) {
$.ajax({
type: 'POST',
url: '<?php echo base_url(); ?>Pitches/Edit_data/',
data: new FormData(this),
contentType: false,
cache: false,
processData: false,
beforeSend: function() {
$('.addbtn').hide();
$('.addload').show();
},
success: function(msg) {
if (msg == 'success') {
$(".Add").show();
$('.Add').delay(3000).hide(200);
$('.addbtn').show();
        $('.addload').hide();
setInterval(function() {
location.reload();
}, 3000);
}
}
});
}
});
});
</script>