<script type="text/javascript">

function validate_question(){
	
   

    if($("#question_type").val()==''){
        $("#question_type").addClass('error');
        $("#question_type").focus();
        $("#msg_question_type").html('Please select type').show();
        return false;
    }else{
        $("#question_type").removeClass('error');
        $("#msg_question_type").hide();
    }
    if($("#question_title").val()==''){
        $("#question_title").addClass('error');
        $("#question_title").focus();
        $("#msg_question_title").html('Please enter title').show();
        return false;
    }else{
        $("#question_title").removeClass('error');
        $("#msg_question_title").hide();
    }
    if($("#question_example").val()==''){
        $("#question_example").addClass('error');
        $("#question_example").focus();
        $("#msg_question_example").html('Please enter desc').show();
        return false;
    }else{
        $("#question_example").removeClass('error');
        $("#msg_question_example").hide();
    }
}

</script>


<div class="breadcrumb">
    <h1>Questions</h1>
    <ul>
        <li><a href="<?php echo SITE_URL.ADMIN_DIR ?>">Dashboard</a></li>
        <li>Add New Question</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 Question</div>
                <form action="" method="post" onsubmit="return validate_question();" enctype="multipart/form-data">

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

                    <div class="row">

                    	<div class="col-md-6 form-group mb-3">
                            <label for="question_type">Type <span class="asterisk">*</span></label>
                            <select class="form-control" id="question_type" name="question_type">
                                <option value="clinic" <?php echo ($questionDetail->question_type=="clinic")?'selected="selected"':"" ?>>Clinic</option>
                                <option value="doctor" <?php echo ($questionDetail->question_type=="doctor")?'selected="selected"':"" ?>>Doctor</option>
                            </select>    
                            <div class="invalid-tooltip" id="msg_question_type"></div>
                        </div>
                        <div class="col-md-6 form-group mb-3">
                            <label for="question_title">Question title <span class="asterisk">*</span></label>
                            <input type="text" class="form-control" name="question_title" id="question_title"  value="<?php echo $questionDetail->question_title; ?>" placeholder="Enter question title">
                            <div class="invalid-tooltip" id="msg_question_title"></div>
                        </div>
                        <div class="col-md-6 form-group mb-3">
                            <label for="question_example">Question Example <span class="asterisk">*</span></label>
                            <textarea  rows="5" name="question_example" placeholder="Enter question title" class="form-control" id="question_example"><?php echo $questionDetail->question_example; ?></textarea>
                            <div class="invalid-tooltip" id="msg_question_example"></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" name="question_status" id="question_status" title="question_status" <?php echo ($questionDetail->question_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" title="submit">Submit</button>
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>