<?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('users/') ?>"><?php echo $this->lang->line('users') ?></a></span>
            </div>
        </div>
    </div>
    <?php if (isset($msg) || validation_errors() !== ''): ?>
        <div class="alert alert-warning alert-dismissible">
            <button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
            <h4><i class="icon fa-warning"></i> Alert!</h4>
            <?= validation_errors(); ?>
            <?= isset($msg) ? $msg : ''; ?>
        </div>
    <?php endif; ?> 
    
    <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('users') ?>
                </h3>
            </div>
        </div>
        
        <?php if ($this->session->flashdata('msg')): ?>
        <div class="alert alert-success alert-dismissible">
            <button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
            <h4>Success!</h4>
            <?= $this->session->flashdata('msg') ?>
        </div>
    <?php endif; ?> 
        <!--begin::Form-->
        <!-- <?php echo form_open_multipart(base_url('' . $thispage . '/add/')); ?> -->
        <form class="kt-form kt-form--label-right" method="post" action="">
            <div class="kt-portlet__body">
                <div class="form-group row">
                    <label for="example-text-input" class="col-2 col-form-label"><?php echo $this->lang->line('member') ?> <?php echo $this->lang->line('name') ?></label>
                    <div class="col-10">
                        <input type="text" class="form-control" id="exampleInputEmail1" placeholder="<?php echo $this->lang->line('the-name') ?> " name="name" required autofocus value="<?= $edit['name'] ?>">
                    </div>
                </div>
                <div class="form-group row">
                    <label for="example-search-input" class="col-2 col-form-label"> <?php echo $this->lang->line('the-name-of-the-member') ?>   </label>
                    <div class="col-10">
                        <input type="text" class="form-control" id="exampleInputPassword1" placeholder=" <?php echo $this->lang->line('name') ?> " name="mosma" value="<?= $edit['mosma'] ?>">
                    </div>
                </div>

                <div class="form-group row">
                    <label for="example-email-input" class="col-2 col-form-label"> <?php echo $this->lang->line('e-mail') ?></label>
                    <div class="col-10">
                        <input type="email" class="form-control" id="exampleInputPassword1" placeholder=" <?php echo $this->lang->line('e-mail') ?> " name="email" required value="<?= $edit['email'] ?>">
                    </div>
                </div>
                <div class="form-group row">
                    <label for="example-url-input" class="col-2 col-form-label"><?php echo $this->lang->line('the-phone') ?></label>
                    <div class="col-10">
                        <input type="text" class="form-control" id="exampleInputPassword1" placeholder=" <?php echo $this->lang->line('the-phone') ?> " name="phone" value="<?= $edit['phone'] ?>">
                    </div>
                </div>

                <?php if (!$this->session->userdata('teacher_id') && get_ap('member_edit', $this->operator_id)) { ?>
                    <?php $role = $this->db->get('groups')->result(); ?>

                    <div class="form-group row">
                        <label for="example-tel-input" class="col-2 col-form-label"><?php echo $this->lang->line('select') ?> <?php echo $this->lang->line('role') ?></label>
                        <div class="col-10">
                            <select name="role" required class="form-control">
                                <option><?php echo $this->lang->line('select') ?> <?php echo $this->lang->line('role') ?></option>
                                <?php
                                foreach ($role as $row) {
                                    $selected = '';
                                    if ($edit['operator_id'] == $row->id) {
                                        $selected = 'selected';
                                    }
                                    ?>
                                    <option <?= $selected ?> value="<?php echo $row->id ?>"><?php echo $row->groups ?></option>
                                <?php } ?>
                            </select>
                        </div>
                    </div>
                <?php } ?>
                <div class="form-group row">
                    <label for="example-password-input" class="col-2 col-form-label"><?php echo $this->lang->line('describe') ?></label>
                    <div class="col-10">
                        <textarea class="form-control" rows="3" placeholder="<?php echo $this->lang->line('describe') ?>..." name="userInfo"><?= $edit['name'] ?></textarea>
                    </div>
                </div>

                <div class="form-group row">
                    <label for="example-email-input" class="col-2 col-form-label"></label>
                    <div class="col-10" style="margin-top: 10px">
                        <a onclick="show_password()" style="cursor: pointer;color: blue"><?= $this->lang->line('change_password') ?> </a>
                    </div>
                </div>

                <div class="form-group row" id="new_pass">
                    <label for="example-email-input" class="col-2 col-form-label"> <?php echo $this->lang->line('new_password') ?></label>
                    <div class="col-10">
                        <input type="password" class="form-control form-control-solid" value="" name="new_password" placeholder="<?= $this->lang->line('enter') . ' ' . $this->lang->line('new_password') ?>" />
                    </div>
                </div>

            </div>
            <div class="kt-portlet__foot">
                <div class="kt-form__actions">
                    <div class="row">
                        <div class="col-2">
                        </div>
                        <div class="col-10">
                            <button type="submit" class="btn btn-primary" name="submit" value="pl"><?php echo $this->lang->line('modification') ?></button>
                            <!-- <button type="reset" class="btn btn-secondary">Cancel</button> -->
                        </div>
                    </div>
                </div>
            </div>
        </form>
    </div>
    <?php $this->load->view('site/footer'); ?>

    <script>
        $(function () {
            $("#new_pass").hide();
        });
        function show_password() {
            $("#new_pass").show();
        }
    </script>

