<script type="text/javascript">

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

    if($("#appointmenttype_name").val()==''){
        $("#appointmenttype_name").addClass('error');
        $("#appointmenttype_name").focus();
        $("#msg_appointmenttype_name").html('Please enter first name').show();
        return false;
    }else{
        $("#appointmenttype_name").removeClass('error');
        $("#msg_appointmenttype_name").hide();
    }
    if($("#appointmenttype_duration").val()==''){
        $("#appointmenttype_duration").addClass('error');
        $("#appointmenttype_duration").focus();
        $("#msg_appointmenttype_duration").html('Please enter default duration').show();
        return false;
    }else{
        $("#appointmenttype_duration").removeClass('error');
        $("#msg_appointmenttype_duration").hide();
    }
}

</script>


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

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

                    <div class="row">

                    	<div class="col-md-6 form-group mb-3">
                            <label for="appointmenttype_speciality_id">Speciality <span class="asterisk">*</span></label>
                            <select class="form-control" id="appointmenttype_speciality_id" name="appointmenttype_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($appointmenttypeDetail) && $appointmenttypeDetail->appointmenttype_speciality_id == $speciality->speciality_id) ? "selected='selected'" : ""; ?>><?php echo $speciality->speciality_name; ?></option>
                                <?php } } ?>
                            </select>    
                            <div class="invalid-tooltip" id="msg_appointmenttype_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="appointmenttype_name">Appointment Type Name <span class="asterisk">*</span></label>
                            <input type="text" class="form-control" id="appointmenttype_name" name="appointmenttype_name" value="<?php echo $appointmenttypeDetail->appointmenttype_name; ?>" placeholder="Enter appointment type name">
                            <div class="invalid-tooltip" id="msg_appointmenttype_name"></div>
                        </div>
                        <div class="col-md-6 form-group mb-3">
                            <label for="appointmenttype_duration">Appointment Type Duration (Doctor can change in his/her profile)<span class="asterisk">*</span></label>
                            <input type="text" class="form-control" id="appointmenttype_duration" name="appointmenttype_duration" value="<?php echo $appointmenttypeDetail->appointmenttype_duration; ?>" placeholder="Enter default duration">
                            <div class="invalid-tooltip" id="msg_appointmenttype_duration"></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="appointmenttype_status" name="appointmenttype_status" <?php echo ($appointmenttypeDetail->appointmenttype_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>