<?php
include 'class/ClassForm.php';
$query = "select distinct * from inv_template where Client_id = '".$_SESSION['user_id']."'";
$result = $ClassForm->Fetch_Result_Set($query);
?>
<div class="content">
    <div class="col-12">
        <div class="row">
            <div class="col-12">
                <div class="form-group row">
                    <label class="control-label col-lg-4">Select Template <em class="required">&nbsp;*</em></label>
                    <div class="col-lg-4">
                        <select name="template_select" id="template_select" class="form-control col-lg-12">
                            <option selected value="0">Please Select Template </option>
                            <?php 
                            while ($row = mysqli_fetch_assoc($result)){
                                ?>
                            <option value="<?php echo $row['id']; ?>"><?php echo $row['template_name']; ?> </option>
                            <?php
                            }
                            ?>
                        </select>
                    </div>
                </div>
            </div>
        </div>
        <div class="row" >
            <div class="col-12" id="form_display">
            </div>
        </div>
    </div>
</div>
<script>
$('#template_select').change(function(){
    if($('#template_select option:selected').text().toLowerCase().indexOf('domestic') > -1){        
        loadDomestic($(this).val());
    }
    else if($('#template_select option:selected').text().toLowerCase().indexOf('export') > -1){
        swal('export');
    }
    else{
        resetFn();
    }
});
function loadDomestic(option){    
    $.ajax({
        url : 'Pages/domestic/domestic_form.php?id='+option,
        method : 'GET',
        // data: {id : option},
        contentType: false,
        processData: false,
        //dataType: 'json',
        success: function(response){
            $('#form_display').html(response);
        }
    })
}
function resetFn(){
    $('#form_display').html('');
}
</script>
<script src="https://unpkg.com/sweetalert/dist/sweetalert.min.js"></script>

