<?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">
    <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"><a href="<?= base_url('user/') ?>"><?php echo $this->lang->line('the-students') ?></a></span>
            </div>
        </div>
    </div>
    <div class="kt-portlet">
        <div class="kt-portlet__head">
            <div class="kt-portlet__head-label">
                <h3 class="kt-portlet__head-title">
                    <?php echo $this->lang->line('the-students') ?>
                </h3>
            </div>
        </div>
        <?php if ($this->session->flashdata('success')): ?>
            <div class="alert alert-success alert-dismissible">
                <button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
                <h4><i class="icon fa-warning"></i> Success!</h4>&nbsp;
                <?= $this->lang->line('op_success'); ?>
            </div>
        <?php endif; ?> 
        <!--begin::Form-->
        <?php echo form_open_multipart(base_url($thispage . '/fields_settings')); ?> 
        <!--  <form class="kt-form kt-form--label-right" method="post" action="">  -->
        <div class="kt-portlet__body">
            <div class="form-group row">
                <div class="col-12">
                    <div class="form-group row">

                        <div class="col-12">
                            <?php
                            $fields_arr = array('username' => $this->lang->line('name') ,
                                //'name' => $this->lang->line('name'),
                                'cid_user' => $this->lang->line('civil-no'), 'email' => $this->lang->line('e-mail'), 'password' => $this->lang->line('password'),
                                'phone' => $this->lang->line('students') . ' ' . $this->lang->line('mobile'),
                                'phone_father' => $this->lang->line('guardian') . ' ' . $this->lang->line('mobile'), 'country' => $this->lang->line('nationality'),
                                'city' => $this->lang->line('region'), 'blocks' => $this->lang->line('block_address'), 'street' => $this->lang->line('street'), 'jadah' => $this->lang->line('jadah'),
                                'building_num' => $this->lang->line('building_num'), 'floor' => $this->lang->line('floor'), 'door_no' => $this->lang->line('door-number'), 'address_link' => $this->lang->line('address-link'),
                                //'title' => $this->lang->line('title'),
                                'age' => $this->lang->line('date-of-birth'), 'sex' => $this->lang->line('sex'), 'father_work' => $this->lang->line('father_work'), 'mother_work' => $this->lang->line('mother_work'),
                                'social_status' => $this->lang->line('social_status'), 'note' => $this->lang->line('note'),
                                'profile' => $this->lang->line('customer-image'), 'imageuser' => $this->lang->line('other_attachments'));
                            //$this->lang->line('customer-image'),$this->lang->line('other_attachments')
                            $old_show_arr = explode(',', $data->show_customer_fields);
                            $old_req_arr = explode(',', $data->customer_fields);
                            $old_profile_arr = explode(',', $data->student_profile_customer_fields);
                            $old_edit_arr = explode(',', $data->student_can_edit_customer_fields);
                            ?>
                            <table class="table table-bordered table-hover">
                                <thead>
                                <th><?= $this->lang->line('field') ?></th>
                                <th class="text-center"><?= $this->lang->line('show_fields') ?></th>
                                <th class="text-center"><?= $this->lang->line('required_fields') ?></th>
                                <th class="text-center"><?= $this->lang->line('student_profile') ?></th>
                                <th class="text-center"><?= $this->lang->line('student_can_edit') ?></th>
                                </thead>
                                <tbody>
                                    <?php foreach ($fields_arr as $key => $val) { ?>
                                        <tr class="table_row">
                                            <td><?= $val ?></td>
                                            <td class="text-center"><input type="checkbox" name="show[]" value="<?= $key ?>" <?= in_array($key, $old_show_arr) ? 'checked' : '' ?> class="show_checkbox" /></td>
                                            <td class="text-center"><input type="checkbox" name="required[]" value="<?= $key ?>" <?= in_array($key, $old_req_arr) ? 'checked' : '' ?> class="checkbox" /></td>
                                            <td class="text-center"><input type="checkbox" name="profile[]" value="<?= $key ?>" <?= in_array($key, $old_profile_arr) ? 'checked' : '' ?> class="checkbox" /></td>
                                            <td class="text-center"><input type="checkbox" name="edit[]" value="<?= $key ?>" <?= in_array($key, $old_edit_arr) ? 'checked' : '' ?> class="checkbox" /></td>
                                        </tr>
                                    <?php } ?>
                                </tbody>
                            </table>

<!--                            <select multiple data-multi-select-plugin name="fields[]" class="topnav form-control" id="fields" >
                            <?php //foreach ($fields_arr as $key => $val) { ?>
        <option <?php //echo in_array($key, $data_arr) ? 'selected' : ''          ?> value="<?php //echo $val          ?>"><?php //echo $val          ?></option>
                            <?php //} ?>
</select> -->
                        </div>
                    </div>
                </div>
            </div>

        </div>
        <div class="kt-portlet__foot">
            <div class="kt-form__actions">
                <div class="row">

                    <div class="col-10">
                        <button type="submit" class="btn btn-primary" name="submit" value="pl"><?php echo $this->lang->line('addition') ?></button>
                        <button type="reset" class="btn btn-secondary">Cancel</button>
                    </div>
                </div>
            </div>
        </div>
        <?php echo form_close(); ?>
    </div>
</div>
<?php $this->load->view('site/footer_2') ?>

<script>
    $(function () {
        $(".show_checkbox").change(function () {
            if ($(this).prop('checked')) {
                $(this).parent().parent().find('.checkbox').prop("disabled", false);
            } else {
                $(this).parent().parent().find('.checkbox').prop("checked", false);
                $(this).parent().parent().find('.checkbox').prop("disabled", true);
            }
        });

        $(".show_checkbox").each(function () {
            $(".show_checkbox").change();
        });
    });
</script>



