<?php
if (isset($Query_Group))
{

}
else {
    $Query_Group=0;
}
?>
<script type="text/javascript">
    window.onload=function(){
        $(".sidebar-menu li").attr("class","");
        $(".sidebar-menu #menu_manifest").attr("class","start active");
        $("#manifest_group_list  a").attr("style","color:red !important");
        $("#manifest_group_list").attr("class","active");
    }
</script>
<div class="content-wrapper">
    <!-- Content Header (Page header) -->
    <section class="content-header">
        <h1>Edit Group List
            <small>Manifest</small>
        </h1>
        <ol class="breadcrumb">
            <li><a href="#"><i class="fa fa-dashboard"></i> Home</a></li>
            <li><a href="#">Manifest</a></li>
            <li class="active">Edit Group List</li>
        </ol>
    </section>
    <!-- Main content -->
    <section class="content">
        <div class="row">
            <div class="col-xs-12">
                <div class="box">
                    <div class="box-header">
                        <h3 class="box-title">Edit Group List</h3>
                    </div><!-- /.box-header -->
                    <form class="form-horizontal" method="post" id="FormInput" action="">
                    <div class="box-body">
                        <div class="col-md-12">
                            <div class="form-group">
                                <label class="col-sm-2 control-label">Product Code</label>
                                <div class="col-sm-4">
                                    <input required="required" value="<?php echo set_value('product_code', $Query_Group['product_code']); ?>" type="text" class="form-control" name="product_code" placeholder="Product Code" disabled>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-2 control-label">Name of Manifest</label>
                                <div class="col-sm-4">
                                    <input required="required" value="<?php echo set_value('manifest_name', $Query_Group['manifest_name']); ?>" type="text" class="form-control" name="manifest_name" placeholder="Name of Manifest" disabled>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-2 control-label">Name of Group</label>
                                <div class="col-sm-4">
                                    <input required="required" value="<?php echo set_value('group_list_name', $Query_Group['group_list_name']); ?>" type="text" class="form-control" name="group_list_name" placeholder="Name of Group" disabled>
                                </div>
                            </div>
                        </div>
                        <div class="box-header">
                            <h3 class="box-title">List of Document</h3>
                        </div>
                        <div id="uDocument" class="col-md-12">
                            <script type="text/javascript">
                                $(function() {
                                    $('#callbacks').multiSelect({
                                        afterSelect: function (values) {
                                            //alert("Select value: " + values);
                                            $('#uDocument').load('<?php echo base_url('manifest/insert_member_group'); ?>' + '/' + values + '/' + <?php echo $Query_Group['group_list_id'] ?>);
                                        },
                                        afterDeselect: function (values) {
                                            //alert("Deselect value: " + values);
                                            $('#uDocument').load('<?php echo base_url('manifest/remove_member_group'); ?>' + '/' + values + '/' + <?php echo $Query_Group['group_list_id'] ?>);
                                        }
                                    });
                                });
                            </script>
                            <select multiple="multiple" id="callbacks" name="callbacks[]">
                                <?php
                                foreach ($data_document as $row) {
                                    if($row->group_list_id != 0) {
                                        if ($Query_Group['group_list_id'] == $row->group_list_id) {
                                            echo '<option selected="true"';
                                            echo 'value="' . $row->document_id . '">' . $row->document_full_name . ': ' . $row->document_sex . '</option>';
                                        }
                                    } else {
                                        echo '<option value="'.$row->document_id.'">'.$row->document_full_name.': '.$row->document_sex.'</option>';
                                    }
                                } ?>
                            </select>
                        </div>
                        <div class="col-md-6">
                            <label>Noted: This record will be auto save to database and move to the right. If you want to remove from data, please click on the right list until move to the left list.</label>
                        </div>
                        <hr>
                        <div class="form-group">
                            <div class="col-sm-10">
                                <a title="Close" onclick=self.history.back() class="btn btn-danger btn-lg"><i class="fa fa-power-off"></i></a>
                            </div>
                        </div>
                    </div><!-- /.box-body -->
                    </form>
                </div><!-- /.box -->
            </div>
        </div>
    </section><!-- /.content -->
</div>