<?php
$operator_id = $this->session->userdata('admin')['operator_id'];
$user_id = $this->session->userdata('admin_id');
?>
<?php $this->load->view('site/layout'); ?>
<?php $this->load->view('site/navbar'); ?>

<div class="kt-content  kt-grid__item kt-grid__item--fluid kt-grid kt-grid--hor" id="kt_content">
    <!-- begin:: Content Head -->
    <div class="kt-subheader  kt-grid__item" id="kt_subheader">
        <div class="kt-container  kt-container--fluid ">
            <div class="kt-subheader__main">
                <h3 class="kt-subheader__title"><a href="<?php echo base_url() ?>Dashboard/"><?php echo $this->lang->line('dashboard'); ?></a></h3>
                <span class="kt-subheader__separator kt-subheader__separator--v"></span>
                <span class="kt-subheader__desc"><?php echo $this->lang->line('points'); ?></span>
            </div>

        </div>
    </div>

    <div class="kt-portlet kt-portlet--mobile">
        <div class="kt-portlet__head kt-portlet__head--lg">
            <div class="kt-portlet__head-label">
                <span class="kt-portlet__head-icon">
                    <i class="kt-font-brand flaticon2-line-chart"></i>
                </span>
                <h3 class="kt-portlet__head-title">
                    <?php echo $title ?>
                </h3>
            </div>
        </div>
        <div class="kt-portlet__body">


            <?php if (validation_errors()) { ?>

                <div class="m-alert m-alert--outline alert alert-success alert-dismissible fade show" role="alert">
                    <button type="button" class="close" data-dismiss="alert" aria-label="Close"></button>
                    <?php echo validation_errors(); ?>
                </div>
            <?php } ?>
            <form method="post" action="<?php echo base_url('points/student/award'); ?>" enctype="multipart/form-data" > 

                <?php if (get_ap('members_all', $operator_id) == 1) { ?>
                    <div class="input-box">
                        <div class="row">
                            <label class="col-md-3"><?php echo $this->lang->line('members_name'); ?></label>
                            <div class="col-md-7">
                                <select class="form-control" name="member_id" required="">
                                    <option value=""><?php echo $this->lang->line('members'); ?></option>
                                    <?php
                                    if ($members) {
                                        foreach ($members as $key => $value) {
                                            ?>
                                            <?php $selected2 = $value->id == @$_POST['member_id'] ? "selected" : ""; ?>
                                            <option value="<?php echo $value->id; ?>" <?php echo $selected2; ?> ><?php echo $value->firstname; ?></option>
                                            <?php
                                        }
                                    }
                                    ?>
                                </select>

                            </div> 
                        </div>
                    </div> 
                <?php } else { ?>
                    <input type="hidden" name="member_id" value="<?php echo $user_id; ?>">
<?php } ?> 


                <div class="form-group row">
                    <label class="col-md-3"><?php echo $this->lang->line('students'); ?></label>
                    <div class="col-md-7">

                        <select class="form-control" id="student_id" name="stud_id[]" multiple="" >
                            <?php
                            if ($student)
                                foreach ($student as $key => $result) {
                                    ?>
                                    <option value="<?php echo $result->id ?>" <?php //echo $list[$result->id] ? "selected" : ""; ?> ><?php echo $result->username ?></option>
    <?php } ?>
                            ?>
                        </select>


                    </div>
                </div>


                <div class="form-group row">
                    <label class="col-md-3"><?php echo $this->lang->line('award'); ?></label>
                    <div class="col-md-7">
                        <select name="award_id" class="form-control" required="">
                            <option value=""><?php echo $this->lang->line('award'); ?></option>
                            <?php
                            if ($award) {
                                foreach ($award as $key => $award_value) {
                                    ?>
                                    <option value="<?php echo $award_value->id; ?>"><?php echo $award_value->award_name; ?></option>
                                <?php
                                }
                            }
                            ?> 
                        </select>
                    </div>
                </div>

                <div class="form-group row">
                    <label class="col-md-3"><?php echo $this->lang->line('notes'); ?></label>
                    <div class="col-md-7">
                        <textarea class="form-control" name="memo"></textarea>
                    </div>
                </div>

                <div class="offset-md-4">
                    <button class="btn btn-success"><span><?php echo $this->lang->line('submit'); ?></span></button>
                    <a href="<?php echo base_url('points/student'); ?>" class="btn btn-danger"><span>Cancel</span></a>
                </div>

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

<?php $this->load->view('site/footer_2'); ?>
<script type="text/javascript">
    $("#student_id").select2();
</script>
