
 <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">Add Pitches</h4>
               </div>
               <span class="table-add float-right mb-3 mr-2">
                  <a href="<?php echo base_url(); ?>Pitches/" 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 Added Your Data!</strong>
                </div>
                <div class="alert alert-danger Adderror" style="display: none;">
                    <strong>Duplicate Entry!</strong>
                </div>
                <form role="form" method="post" id="addfrm">
                <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 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"><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)"><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"><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>
                        </div>
                    </div>
                    
                </div>
                </form>
            </div>
         </div>
      </div>
   </div>
</div>
<script>
// just for the demos, avoids form submit
jQuery.validator.setDefaults({
success: "valid"
});
$("#addfrm").validate({
rules: {
d_code: {
required: true
}
}
});
</script>
<script>
$(document).ready(function(e) {
$("#addfrm").on('submit', function(e) {
e.preventDefault();
var formStatus = $('#addfrm').validate().form();
if (true == formStatus) {
$.ajax({
type: 'POST',
url: '<?php echo base_url(); ?>Pitches/save',
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);
}
else
{
$(".Adderror").show();
$('.Adderror').delay(3000).hide(200);
$('.addbtn').show();
$('.addload').hide();

}
}
});
}
});
});
</script>
<script>
$( "#cat_id" ).change(function() {
var cat_id=$( "#cat_id" ).val();
$.ajax({
type: "POST",
url: "<?php echo base_url(); ?>product/get_sub_cat/",
data: {cat_id : cat_id }, 
success: function(html) {
$('.sub_category').html(html);
}
});
});
</script>
                    