<div class="content-header">
    <div class="container-fluid">
        <div class="row mb-2">
            <div class="col-sm-6">
                <!-- <h1 class="m-0">Deactive Member </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">Edit Member</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">
                            Edit Member Details
                        </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">
                            <!-- File: src/Template/Articles/add.ctp -->
                            <a href="<?php echo base_url() ?>index.php/Member/member_details/" class="text-center btn btn-lg btn-light  float-left">Back</a>
                            <h1 class="text-center">Edit Member</h1><br><br>
                            <form method="post" action="<?php echo base_url(); ?>index.php/Member/update_member" id="member_add_" enctype='multipart/form-data'>
                                <!--<input type="hidden" class="form-control" name="ent_fees" id="ent_fees" value="100"> -->
                                <div class="row mt-3">
                                    <div class="col-sm-5 ml-5">
                                        <div class="row mt-3">
                                            <div class="col-sm-6"><b>Member Number</b></div>
                                            <div class="col-sm-6">
                                                <input type="text" class="form-control" name="me_no" id="mem_no" readonly value="<?php echo $member['me_no']; ?>">
                                            </div>
                                        </div><br>
                                        <div class="row mt-3">
                                            <div class="col-sm-6"><b>Member Photo</b></div>
                                            <div class="col-sm-6">
                                                <input type="file" class="form-control" name="mem_image" id="mem_image">
                                            </div>
                                        </div><br>
                                        <div class="row mt-3">
                                            <div class="col-sm-6"><b>Member Name</b></div>
                                            <div class="col-sm-6">
                                                <input type="text" class="form-control" value="<?php echo $member['mem_name']; ?>" name="mem_name" id="mem_name">
                                            </div>
                                        </div><br>
                                        <div class="row mt-3">
                                            <div class="col-sm-6"><b>Father Name</b></div>
                                            <div class="col-sm-6">
                                                <input type="text" class="form-control" value="<?php echo $member['f_name']; ?>" name="f_name" id="father_name">
                                            </div>
                                        </div><br>
                                        <div class="row mt-3">
                                            <div class="col-sm-6"><b>Date Of Birth</b></div>
                                            <div class="col-sm-6">
                                                <input type="date" class="form-control" name="mem_dob" id="mem_dob" value="<?php echo $member['mem_dob']; ?>" placeholder="DD-MM-YYYY" style="padding-right:44px" />

                                            </div>
                                        </div><br>
                                        <!-- <div class="row mt-3">
                <div class="col-sm-6"><b>Age</b></div>
                <div class="col-sm-6">
                    <input type="text" class="form-control" readonly value="<!?php echo $member['mem_age']; ?>" name="mem_age" id="age">
                </div>
            </div><br> -->
                                        <div class="row mt-3">
                                            <div class="col-sm-6"><b>Gender</b></div>
                                            <div class="col-sm-6">
                                                <input type="radio" <?php if ($member['mem_gender'] == "male") {
                                                                        echo "checked";
                                                                    } ?> name="mem_gender" value="male"> Male&nbsp;&nbsp;
                                                <input type="radio" <?php if ($member['mem_gender'] == "female") {
                                                                        echo "checked";
                                                                    } ?> name="mem_gender" value="female">&nbsp; Female&nbsp;&nbsp;
                                                <input type="radio" <?php if ($member['mem_gender'] == "other") {
                                                                        echo "checked";
                                                                    } ?> name="mem_gender" value="other"> &nbsp; Others
                                            </div>
                                        </div><br>
                                        <div class="row mt-3">
                                            <div class="col-sm-6"><b>Caste</b></div>
                                            <div class="col-sm-6">
                                                <select name="mem_caste" id="cast" class="form-control">
                                                    <option value="">Select</option>
                                                    <?php foreach ($castes as $caste) { ?>
                                                        <option <?php if ($member['mem_caste'] == $caste['mem_caste']) {
                                                                    echo "selected";
                                                                } ?> value="<?php echo $caste['mem_caste']; ?>"><?php echo $caste['mem_caste']; ?></option>
                                                    <?php } ?>
                                                </select>
                                            </div>
                                        </div><br>
                                        <div class="row mt-3">
                                            <div class="col-sm-6"><b>Designation</b></div>
                                            <div class="col-sm-6">
                                                <select name="mem_desig" id="designation" class="form-control">
                                                    <option value="">Select</option>
                                                    <?php foreach ($design as $key => $value) { ?>
                                                        <option <?php if ($member['mem_desig'] == $value['designation']) {
                                                                    echo "selected";
                                                                } ?> value="<?php echo $value['designation']; ?>"><?php echo $value['designation']; ?></option>
                                                    <?php } ?>
                                                </select>

                                            </div>
                                        </div><br>
                                        <div class="row mt-3">
                                            <div class="col-sm-6"><b>Address</b></div>
                                            <div class="col-sm-6">
                                                <textarea class="form-control" rows="4" name="mem_add" id="mem_add"><?php echo $member['mem_add']; ?></textarea>
                                            </div>
                                        </div><br>
                                        <div class="row mt-3">
                                            <div class="col-sm-6"><b>District</b></div>
                                            <div class="col-sm-6">
                                                <input type="text" class="form-control" value="<?php echo $member['mem_dist']; ?>" name="mem_dist" id="mem_dist">
                                            </div>
                                        </div><br>
                                        <div class="row mt-3">
                                            <div class="col-sm-6"><b>Pincode</b></div>
                                            <div class="col-sm-6">
                                                <input type="text" class="form-control" value="<?php echo $member['mem_pin']; ?>" name="mem_pin" id="pincode">
                                            </div>
                                        </div><br>
                                        <div class="row mt-3">
                                            <div class="col-sm-6"><b>Mobile Number</b></div>
                                            <div class="col-sm-6">
                                                <input type="text" class="form-control" value="<?php echo $member['mem_mob']; ?>" name="mem_mob" id="phone">
                                            </div>
                                        </div><br>
                                        <div class="row mt-3">
                                            <div class="col-sm-6"><b>Nominee Name</b></div>
                                            <div class="col-sm-6">
                                                <input type="text" class="form-control" value="<?php echo $member['n_name']; ?>" name="n_name" id="nominee_name">
                                            </div>
                                        </div><br>
                                        <div class="row mt-3">
                                            <div class="col-sm-6"><b>Relationship</b></div>
                                            <div class="col-sm-6">
                                                <select name="n_relation" id="n_relation" class="form-control">
                                                    <option value="">Select</option>
                                                    <?php foreach ($relationships as $relationship) { ?>
                                                        <option <?php if ($member['n_relation'] == $relationship['n_relation']) {
                                                                    echo "selected";
                                                                } ?> value="<?php echo $relationship['n_relation']; ?>"><?php echo $relationship['n_relation']; ?></option>
                                                    <?php } ?>
                                                </select>
                                            </div>
                                        </div>
                                    </div>
                                    <div class="col-sm-5 ml-5">

                                        <div class="row mt-3">
                                            <div class="col-sm-6"><b>Division</b></div>
                                            <div class="col-sm-6">
                                                <select name="division" id="division_id" class="form-control">
                                                    <option value="">Select</option>
                                                    <?php foreach ($divisions as $division) { ?>
                                                        <option <?php if ($member['division'] == $division['division']) {
                                                                    echo "selected";
                                                                } ?> value="<?php echo $division['division']; ?>"><?php echo $division['division']; ?></option>
                                                    <?php } ?>
                                                </select>
                                            </div>
                                        </div><br>
                                        <div class="row mt-3">
                                            <div class="col-sm-6"><b>Section</b></div>
                                            <div class="col-sm-6">
                                                <select name="section" id="section_id" class="form-control">
                                                    <option value="">Select</option>
                                                    <?php foreach ($sections as $section) { ?>
                                                        <option <?php if ($member['section'] == $section['section']) {
                                                                    echo "selected";
                                                                } ?> value="<?php echo $section['section']; ?>"><?php echo $section['section']; ?></option>
                                                    <?php } ?>
                                                </select>
                                            </div>
                                        </div><br>
                                        <div class="row mt-3">
                                            <div class="col-sm-6"><b>Bank Name 1</b></div>
                                            <div class="col-sm-6">
                                                <input type="text" class="form-control" value="<?php echo $member['b1_name']; ?>" name="b1_name" id="b1_name">
                                            </div>
                                        </div><br>
                                        <div class="row mt-3">
                                            <div class="col-sm-6"><b>Account Number</b></div>
                                            <div class="col-sm-6">
                                                <input type="text" class="form-control" value="<?php echo $member['b1_acc_no']; ?>" name="b1_acc_no" id="b1_acc_no">
                                            </div>
                                        </div><br>
                                        <div class="row mt-3">
                                            <div class="col-sm-6"><b>Branch</b></div>
                                            <div class="col-sm-6">
                                                <input type="text" class="form-control" value="<?php echo $member['b1_br']; ?>" name="b1_br" id="b1_br">
                                            </div>
                                        </div><br>
                                        <div class="row mt-3">
                                            <div class="col-sm-6"><b>IFSC</b></div>
                                            <div class="col-sm-6">
                                                <input type="text" class="form-control" value="<?php echo $member['b1_ifsc']; ?>" name="b1_ifsc" id="b1_ifsc">
                                            </div>
                                        </div><br>
                                        <div class="row mt-3">
                                            <div class="col-sm-6"><b>Bank Name 2</b></div>
                                            <div class="col-sm-6">
                                                <input type="text" class="form-control" value="<?php echo $member['b2_name']; ?>" name="b2_name" id="b2_name">
                                            </div>
                                        </div><br>
                                        <div class="row mt-3">
                                            <div class="col-sm-6"><b>Account Number</b></div>
                                            <div class="col-sm-6">
                                                <input type="text" class="form-control" value="<?php echo $member['b2_acc_no']; ?>" name="b2_acc_no" id="b2_acc_no">
                                            </div>
                                        </div><br>
                                        <div class="row mt-3">
                                            <div class="col-sm-6"><b>Branch</b></div>
                                            <div class="col-sm-6">
                                                <input type="text" class="form-control" value="<?php echo $member['b2_br']; ?>" name="b2_br" id="b2_br">
                                            </div>
                                        </div><br>
                                        <div class="row mt-3">
                                            <div class="col-sm-6"><b>IFSC</b></div>
                                            <div class="col-sm-6">
                                                <input type="text" class="form-control" value="<?php echo $member['b2_ifsc']; ?>" name="b2_ifsc" id="b2_ifsc">
                                            </div>
                                        </div><br>
                                        <div class="row mt-3">
                                            <div class="col-sm-6"><b>Adhar Card</b></div>
                                            <div class="col-sm-6">
                                                <input type="text" class="form-control" value="<?php echo $member['adhar_no']; ?>" name="adhar_no" id="adhar_no">
                                            </div>
                                        </div><br>
                                        <div class="row mt-3">
                                            <div class="col-sm-6"><b>Pan Card</b></div>
                                            <div class="col-sm-6">
                                                <input type="text" class="form-control" value="<?php echo $member['pan_no']; ?>" name="pan_no" id="pan_no">
                                            </div>
                                        </div><br>
                                        <div class="row mt-3">
                                            <div class="col-sm-6"><b>GPF No.</b></div>
                                            <div class="col-sm-6">
                                                <input type="text" class="form-control" value="<?php echo $member['gpf_no']; ?>" name="gpf_no" id="gpf_no">
                                            </div>
                                        </div><br>
                                        <div class="row mt-3">
                                            <div class="col-sm-6"><b>Ration No.</b></div>
                                            <div class="col-sm-6">
                                                <input type="text" class="form-control" value="<?php echo $member['ration_no']; ?>" name="ration_no" id="ration_no">
                                            </div>
                                        </div><br>
                                        <div class="row mt-3">
                                            <div class="col-sm-6"><b>Join Date in Society</b></div>
                                            <div class="col-sm-6">
                                                <input type="text" class="form-control" name="scty_doj" id="scty_doj" value="<?php echo date("d-m-Y", strtotime($member['scty_doj'])); ?>" placeholder="DD-MM-YYYY" />
                                                <!-- <span class="input-group-addon add-on"><span class="glyphicon glyphicon-calendar"></span></span> -->
                                            </div>
                                        </div><br>
                                        <div class="row mt-3">
                                            <div class="col-sm-6"><b>Join Date in Department</b></div>
                                            <div class="col-sm-6">
                                                <input type="text" class="form-control" value="<?php echo date("d-m-Y", strtotime($member['mem_doj'])); ?>" placeholder="DD-MM-YYYY" name="mem_doj" id="mem_doj" readonly />
                                                <!-- <span class="input-group-addon add-on"><span class="glyphicon glyphicon-calendar"></span></span> -->
                                            </div>
                                        </div><br>
                                        <div class="row mt-3">
                                            <div class="col-sm-6"><b>Retirement Date</b></div>
                                            <div class="col-sm-6">
                                                <input type="text" class="form-control" value="<?php echo date("d-m-Y", strtotime($member['mem_dor'])); ?>" placeholder="DD-MM-YYYY" name="mem_dor" id="mem_dor" />
                                                <!-- <span class="input-group-addon add-on"><span class="glyphicon glyphicon-calendar"></span></span> -->
                                            </div>
                                        </div><br>
                                    </div>
                                </div>
                                <br>
                                <div class='row'>
                                    <div class='col-sm-5'></div>
                                    <button type="button" onclick="member_validate();" class="btn btn-primary col-sm-2">Save</button>
                                </div>
                            </form>




                        </div>
                    </div>
                </div>
        </div>
</section>
</div>
</div>
</section>
<script>
    $(document).ready(function() {
        $('.datePicker')
            .datepicker({
                format: 'dd-mm-yyyy'
            })
            .on('changeDate', function(e) {

            });
        $('.alert').hide();
    });

    function member_validate() {
        var name = $('#mem_name').val();
        var division = $('#division_id').val();
        var section = $('#section_id').val();
        var phone = $('#phone').val();
        if (name == "") {
            alert("Name Must Be Filled Out");
            return false;
        }
        if (division == "") {
            alert("Division Cannot Be Empty");
            return false;
        }
        if (section == "") {
            alert("Section Cannot Be Empty");
            return false;
        }
        if (phone != "" && phone.length != 10) {
            alert("Mobile Number Must Be 10 Digits");
            return false;
        }
        $('#member_add_').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>
<script>
    $('#mem_dob').on('change', function() {
        var d1 = $("#mem_dob").val();
        d1 = d1.split("-");
        d1 = new Date(d1[2], d1[1] - 1, d1[0]);
        var d2 = new Date();
        var diff = d2.getTime() - d1.getTime();
        $("#mem_age").val(Math.floor(diff / (1000 * 60 * 60 * 24 * 365.25)));
    });
</script>
<script type="text/javascript" src="http://www.google.com/jsapi"></script>

<script type="text/javascript">
    // Load the Google Transliteration API
    google.load("elements", "1", {
        packages: "transliteration"
    });

    function onLoad() {
        var options = {
            sourceLanguage: 'en',
            destinationLanguage: ['ta'],
            shortcutKey: 'ctrl+m',
            transliterationEnabled: true
        }

        // Create an instance on TransliterationControl with the required options.
        var control = new google.elements.transliteration.TransliterationControl(options);

        // Enable transliteration in the textfields with the given ids.
        var ids = ["mem_name"];
        control.makeTransliteratable(ids);

        // Show the transliteration control which can be used to toggle between English and Hindi and also choose other destination language.
        control.showControl('translControl');
    }

    google.setOnLoadCallback(onLoad);
</script>