<div class="content-header">
    <div class="container-fluid">
        <div class="row mb-2">
            <div class="col-sm-6">
                <!-- <h1 class="m-0">Member Transfer</h1> -->
            </div>
            <div class="col-sm-6">
                <ol class="breadcrumb float-sm-right">
                    <li class="breadcrumb-item"><a href="#">Member</a></li>
                    <li class="breadcrumb-item active">Member Transfer</li>
                </ol>
            </div>
        </div>
    </div>
</div>




<section class="content">
    <div class="container-fluid">




        <div class="row">

            <section class="col-lg-12 connectedSortable">

                <div class="card">
                    <div class="card-header" style="background-color:#31708e;;color:white">
                        <h3 class="card-title">
                            Member Transfer
                        </h3>
                        <div class="card-tools">
                            <ul class="nav nav-pills ml-auto">
                            </ul>
                        </div>
                    </div>
                    <div class="card-body">
                        <div class="tab-content p-0">




                            <?php if (isset($_SESSION['mem_add']) && $_SESSION['mem_add'] != "") {?>
                                <div class="alert alert-success">
                                    <strong><?php echo $_SESSION['mem_add']; ?></strong>
                                </div>
                            <?php $_SESSION['mem_add'] = "";
}?>
                            <form method="post" action="<?php echo base_url(); ?>index.php/Member/transfer" id="member_transfer" enctype='multipart/form-data'>
                                <div class="row mt-3 ml-10">
                                <div class="col-sm-2 "></div>
                                    <div class="col-sm-2 "><b>Member Name:</b> </div>
                                    <div class="col-sm-5 ">
                                        <select name="me_no" id="me_no" onchange="get_division_section();" class="form-control">
                                            <option value="">Select Member</option>
                                            <?php foreach ($members as $mem) {?>
                                                <option value="<?php echo $mem['me_no']; ?>"><?php echo $mem['me_no'] . "/" . $mem['mem_name']; ?></option>
                                            <?php }?>
                                        </select>
                                    </div>
                                </div><br><br><br>
                                <div class="row mt-3" style="margin-left: 30px;">
                                <div class="col-sm-1 "></div>
                                    <div class="col-sm-5 ">
                                        <div class="card" style="width: 35rem;">
                                            <h3 class="text-center bg-info">Current</h3>
                                            <div class="card-body">
                                                <h5 class="card-title"></h5>
                                                <p class="card-text">
                                                <div class="row mt-3">
                                                    <div class="col-sm-2"><b>Division</b></div>
                                                    <div class="col-sm-10">
                                                        <input type="text" class="form-control" id="division" disabled>
                                                    </div>
                                                </div><br>
                                                <div class="row mt-3">
                                                    <div class="col-sm-2"><b>Section</b></div>
                                                    <div class="col-sm-10">
                                                        <input type="text" class="form-control" id="section" disabled>


                                                    </div>
                                                </div>
                                                </p>

                                            </div>
                                        </div>
                                    </div>

                                    <!--<input type="hidden" name="id">-->

                                    <br>
                                    <div class="col-sm-6" style="left: 44px;">
                                        <div class="card" style="width: 35rem;">
                                            <h3 class="text-center bg-info">Transfered To</h3>
                                            <div class="card-body">
                                                <h5 class="card-title"></h5>
                                                <p class="card-text">
                                                <div class="row mt-3">
                                                    <div class="col-sm-2"><b>Division</b></div>
                                                    <div class="col-sm-10">
                                                        <select name="division" id="division_id" class="form-control">
                                                            <option value="">Select</option>
                                                            <?php foreach ($divisions as $division) {?>
                                                                <option value="<?php echo $division['division']; ?>"><?php echo $division['division']; ?></option>
                                                            <?php }?>
                                                        </select>
                                                    </div>
                                                </div><br>
                                                <div class="row mt-3">
                                                    <div class="col-sm-2"><b>Section</b></div>
                                                    <div class="col-sm-10">
                                                        <select name="section" id="section_id" class="form-control">
                                                            <option value="">Select</option>
                                                            <?php foreach ($sections as $section) {?>
                                                                <option value="<?php echo $section['section']; ?>"><?php echo $section['section']; ?></option>
                                                            <?php }?>
                                                        </select>
                                                    </div>
                                                </div>
                                                </p>

                                            </div>
                                        </div>
                                    </div>
                                    <!--<input type="hidden" name="id">-->
                                    <br>
                                </div>

                                <div class="col-sm-12 text-center">
                                        <center>
                                            <button type="button" onclick="transfer_validate();" class="btn btn-primary col-sm-2;">Save</button>
                                            <center>
                                    </div>
                                </div>
                            </form>






                        </div>
                    </div>
                </div>
        </div>
</section>
</div>
</div>
</section>


<script>
    $(document).ready(function() {
        $('.alert').fadeOut(3000);
    });

    $(".buttons-html5").addClass("btn btn-primary");
    $('.dt-buttons').addClass("pt-3 pb-0");

    function get_division_section() {
        var me_no = $('#me_no').val();
        $.ajax({
            type: 'POST',
            url: "<?php echo base_url() ?>index.php/Member/get_division_section",
            data: {
                me_no: me_no
            },
            dataType: 'json',
            success: function(data) {
                $('#division').val(data.division);
                $('#section').val(data.section);
            }
        });
    }

    function transfer_validate() {
        var me_no = $('#me_no').val();
        var division = $('#division_id').val();
        var section = $('#section_id').val();
        if (me_no == "") {
            alert("Member Number Must Be Filled Out");
            return false;
        }
        if (division == "") {
            alert("Division Cannot Be Empty");
            return false;
        }
        if (section == "") {
            alert("Section Cannot Be Empty");
            return false;
        }
        $('#member_transfer').submit();
    }
    $('#division_id').on('change', function() {
        var division = this.value;
        $.ajax({
            type: 'POST',
            url: "<?php echo base_url() ?>index.php/Member/getsection",
            data: {
                division: division
            },
            dataType: 'html',
            success: function(data) {

                $('#section_id').html(data);
            }
        });
    });
</script>