

<div class="middleSec catbyMdl">
    <form role="form" method="post" id="editfrm">
        <div class="headingD">
            <i class="fa fa-pencil" aria-hidden="true"></i> Edit Vehicle
            <a href="<?php echo base_url(); ?>vehicle/" class="btn btn-default pull-right"><i class="fa fa-arrow-left" aria-hidden="true"></i> Back</a>&emsp;
        </div>
        <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>
        <div class="addPageSec catbyMdl">
            <div class="container-fluid">
                <div class="row">
                    <!-- <div class="form-group">
                        <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
                            <label>Equipment ID</label>
                            <input type="text" name="equipment_id" id="equipment_id" class="form-control" value="<?php echo $row->equipment_id; ?>"  placeholder="Enter Equipment ID"><br>
                        </div>
                    </div> -->
                    <div class="form-group">
                        <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
                            <label>Equipment Name</label>
                            <input type="text" name="equipment_name" id="equipment_name" class="form-control" value="<?php echo $row->equipment_name; ?>"  placeholder="Enter Equipment Name" ><br>
                            <input type="hidden" name="vehicle_id" value="<?php echo $row->vehicle_id; ?>">
                        </div>
                    </div>
                    <div class="form-group">
                        <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
                            <label>Equipment Model</label>
                            <input type="text" name="equipment_model" id="equipment_model" class="form-control" value="<?php echo $row->equipment_model; ?>" required="" placeholder="Enter Equipment Model"><br>
                        </div>
                    </div>
                    <div class="form-group">
                        <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
                            <label>Vehicle Type</label>
                            <select class="form-control" name="vt_id" required>
                                <option value="">Vehicle Type</option>
                                <?php foreach ($recordSet as $key => $vehicle_type) {
                                 ?>
                                <option value="<?php echo  $vehicle_type['vt_id']; ?>" <?php if ($row->vt_id==$vehicle_type['vt_id']) { echo 'selected'; } ?>><?php echo  $vehicle_type['vehicle_type']; ?></option>
                            <?php } ?>
                            </select>
                            <br>
                        </div>
                    </div>
                    
                    <div class="form-group">
                        <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
                            <label>Capacity </label>
                            <input type="text" name="capacity" id="capacity" value="<?php echo $row->capacity; ?>" class="form-control" required="" placeholder="Enter Capacity"><br>
                        </div>
                    </div>
                    
                    <div class="form-group">
                        <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
                            <label>Project</label>
                            <select class="form-control" name="project_id" required>
                                <option value="">Project</option>
                                <?php foreach ($project as $key => $project_data) {
                                 ?>
                                <option value="<?php echo  $project_data['project_id']; ?>" <?php if ($row->project_id==$project_data['project_id']) { echo 'selected'; } ?>><?php echo  $project_data['project_code']; ?></option>
                            <?php } ?>
                            </select>
                            <br>
                        </div>
                    </div>
                    <div class="form-group">
                      
                        <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12" align="right">
                            <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>
            </div>
        </div>
        
    </form>
</div>

<script>
// just for the demos, avoids form submit
jQuery.validator.setDefaults({
success: "valid"
});
$("#editfrm").validate({
rules: {
project_name: {
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(); ?>vehicle/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);

}
else
{
$(".Adderror").show();
$('.Adderror').delay(3000).hide(200);
$('.addbtn').show();
$('.addload').hide();

}
}
});
}
});
});
</script>