<script type="text/javascript">
function validate_carrier(){
    var isValid = true;
    
    if($("#type").val()==''){
        $("#type").addClass('error');
        $("#type").focus();
        $("#msg_type").html('Please select type').show();
        isValid = false;
    }else{
        $("#type").removeClass('error');
        $("#msg_type").hide();
    }
    
    if($("#title").val()==''){
        $("#title").addClass('error');
        if(isValid) $("#title").focus();
        $("#msg_title").html('Please enter title').show();
        isValid = false;
    }else{
        $("#title").removeClass('error');
        $("#msg_title").hide();
    }
    
    if($("#description").val()==''){
        $("#description").addClass('error');
        if(isValid) $("#description").focus();
        $("#msg_description").html('Please enter description').show();
        isValid = false;
    }else{
        $("#description").removeClass('error');
        $("#msg_description").hide();
    }
    
    return isValid;
}

</script>

<div class="breadcrumb">
    <h1>Insurance Carrier</h1>
    <ul>
        <li><a href="<?php echo SITE_URL.ADMIN_DIR ?>">Dashboard</a></li>
        <li><a href="insuranceCarrierlist.php">Insurance Carrier List</a></li>
        <li><?php echo isset($carrierDetail->id) ? 'Edit' : 'Add New'; ?> Insurance Carrier</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"><?php echo isset($carrierDetail->id) ? 'Edit' : 'Add New'; ?> Insurance Carrier</div>
                <form action="" method="post" onsubmit="return validate_carrier();" enctype="multipart/form-data">
                    <?php if(isset($carrierDetail->id) && $carrierDetail->id!=0) { ?>
                    <input type="hidden" id="id" name="id" value="<?php echo $carrierDetail->id ?>" />
                    <?php } ?>
                    <div class="row">
                        <div class="col-md-6 form-group mb-3">
                            <label for="type">Type <span class="asterisk">*</span></label>
                            <select class="form-control" id="type" name="type">
                                <option value="">Select Type</option>
                                <option value="government" <?php echo (isset($carrierDetail->type) && $carrierDetail->type == 'government') ? 'selected' : ''; ?>>Government</option>
                                <option value="group" <?php echo (isset($carrierDetail->type) && $carrierDetail->type == 'group') ? 'selected' : ''; ?>>Group</option>
                                <option value="individual" <?php echo (isset($carrierDetail->type) && $carrierDetail->type == 'individual') ? 'selected' : ''; ?>>Individual</option>
                            </select>
                            <div class="invalid-tooltip" id="msg_type"></div>
                        </div>
                        
                        <div class="col-md-6 form-group mb-3">
                            <label for="title">Title <span class="asterisk">*</span></label>
                            <input type="text" class="form-control" id="title" name="title" value="<?php echo isset($carrierDetail->title) ? $carrierDetail->title : ''; ?>" placeholder="Enter title">
                            <div class="invalid-tooltip" id="msg_title"></div>
                        </div>
                        
                        <div class="col-md-12 form-group mb-3">
                            <label for="description">Description <span class="asterisk">*</span></label>
                            <textarea class="form-control" id="description" name="description" rows="5" placeholder="Enter description"><?php echo isset($carrierDetail->description) ? $carrierDetail->description : ''; ?></textarea>
                            <div class="invalid-tooltip" id="msg_description"></div>
                        </div>
                        
                        <div class="col-md-12">
                            <button class="btn btn-primary" id="submit" name="submit">Submit</button>
                            <a href="insuranceCarrierlist.php" class="btn btn-secondary">Cancel</a>
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>

