<script type="text/javascript">

function validate_feature(){
	
    if($("#feature_speciality_id").val()==''){
        $("#feature_speciality_id").addClass('error');
        $("#feature_speciality_id").focus();
        $("#msg_feature_speciality_id").html('Please select speciality').show();
        return false;
    }else{
        $("#feature_speciality_id").removeClass('error');
        $("#msg_feature_speciality_id").hide();
    }

    if($("#feature_name").val()==''){
        $("#feature_name").addClass('error');
        $("#feature_name").focus();
        $("#msg_feature_name").html('Please enter name').show();
        return false;
    }else{
        $("#feature_name").removeClass('error');
        $("#msg_feature_name").hide();
    }
    if($("#feature_desc").val()==''){
        $("#feature_desc").addClass('error');
        $("#feature_desc").focus();
        $("#msg_feature_desc").html('Please enter desc').show();
        return false;
    }else{
        $("#feature_desc").removeClass('error');
        $("#msg_feature_desc").hide();
    }
}

</script>


<div class="breadcrumb">
    <h1>Features</h1>
    <ul>
        <li><a href="<?php echo SITE_URL.ADMIN_DIR ?>">Dashboard</a></li>
        <li>Add New Feature</li>

    </ul>
</div>


<div class="separator-breadcrumb border-top"></div>

<div class="row">
    <div class="col-md-12">
        <div class="card mb-4">
            <div class="card-body">
                <div class="card-title mb-3">Add New Feature</div>
                <form action="" method="post" onsubmit="return validate_feature();" enctype="multipart/form-data">

                    <?php if(isset($featureDetail->feature_id) && $featureDetail->feature_id!=0) { ?>
                            <input type="hidden" id="feature_id" name="feature_id" value="<?php echo $featureDetail->feature_id ?>" />
                    <?php } ?>

                    <div class="row">

                    	<div class="col-md-6 form-group mb-3">
                            <label for="feature_speciality_id">Speciality <span class="asterisk">*</span></label>
                            <select class="form-control" id="feature_speciality_id" name="feature_speciality_id">
                                <option value="">Select Speciality</option>
                                <?php if($allspecialities && count($allspecialities) > 0){ foreach($allspecialities as $speciality){ ?>
                                <option value="<?php echo $speciality->speciality_id; ?>" <?php echo (isset($featureDetail) && $featureDetail->feature_speciality_id == $speciality->speciality_id) ? "selected='selected'" : ""; ?>><?php echo $speciality->speciality_name; ?></option>
                                <?php } } ?>
                            </select>    
                            <div class="invalid-tooltip" id="msg_feature_speciality_id"></div>
                        </div>

                    	<div class="col-md-6 form-group mb-3">
                        </div>                        

                        <div class="col-md-6 form-group mb-3">
                            <label for="feature_name">Feature Name <span class="asterisk">*</span></label>
                            <input type="text" class="form-control" id="feature_name" name="feature_name" value="<?php echo $featureDetail->feature_name; ?>" placeholder="Enter feature name">
                            <div class="invalid-tooltip" id="msg_feature_name"></div>
                        </div>
                        <div class="col-md-6 form-group mb-3">
                            <label for="feature_desc">Feature Description <span class="asterisk">*</span></label>
                            <input type="text" class="form-control" id="feature_desc" name="feature_desc" value="<?php echo $featureDetail->feature_desc; ?>" placeholder="Enter feature name">
                            <div class="invalid-tooltip" id="msg_feature_desc"></div>
                        </div>
		
                        <div class="col-md-12 form-group mb-3">
                            <label class="control-label">Status</label>
                            <div class="controls">
                              <label class="switch switch-primary mr-3">
                                <input type="checkbox" id="feature_status" name="feature_status" <?php echo ($featureDetail->feature_status=='1') ? "checked='checked'" : "" ?>>
                                <span class="slider"></span>
                             </label>
                            </div>
    	                  </div>

                        <div class="col-md-12">
                            <button class="btn btn-primary" id="submit" name="submit">Submit</button>
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>