<body id="page-top">

    <!-- Sidebar -->
    <?php $this->load->view('restricted/layout/sidebar_admin'); ?>
    <!-- Sidebar -->

    <div id="content-wrapper" class="d-flex flex-column">
        <div id="content">

            <!-- NavBar -->
            <?php $this->load->view('restricted/layout/navbar'); ?>
            <!-- Navbar -->

            <!-- Container Fluid-->
            <div class="container-fluid" id="container-wrapper">
                <div class="d-sm-flex align-items-center justify-content-between mb-4">
                    <h1 class="h3 mb-0 text-purple"><?php echo $title; ?></h1>
                    <ol class="breadcrumb">
                        <li class="breadcrumb-item"><a href="./">Home</a></li>
                        <li class="breadcrumb-item active" aria-current="page"><?php echo $title; ?></li>
                    </ol>
                </div>


                <!--  -->
                <?php

                // $attributes = array(
                //   'name' => 'form_core',
                // );

                if (isset($user)) {
                  $user_id = $user->id;
                } else {
                  $user_id = '';
                }
                ?>
                <!--  -->

                <div class="row mb-3">
                    <!-- Pending Requests Card Example -->
                    <div class="col-xl-10 col-md-10 mb-4" style="margin: 0 auto;">
                    <div class="d-flex flex-row align-items-center justify-content-between mb-2">
                        <p></p>
                        <a href="<?php echo base_url('restricted/admin/users/index'); ?>" class="btn btn-primary"><i class="fas fa-arrow-left"></i>&nbsp;&nbsp;Voltar</a>
                    </div>
                        <div class="card">
                            <div class="card-body">
                                
                            <?php echo form_open('restricted/admin/users/core/' . $user_id); ?>
                                <div class="form-group row">
                                    <div class="col-sm-4">
                                        <label for="first_name">Nome</label>
                                        <input type="text" class="form-control" name="first_name" id="first_name"  placeholder="Nome..." value="<?php echo isset($user) ? $user->first_name : set_value('first_name'); ?> ">
                                        <?php echo form_error('first_name', '<div class="text-danger">', '</div>'); ?>
                                    </div>
                                    <div class="col-sm-4">
                                        <label for="last_name">Sobrenome</label>
                                        <input type="text" class="form-control" name="last_name" id="last_name"  placeholder="Sobrenome..." value="<?php echo isset($user) ? $user->last_name : set_value('last_name'); ?>">
                                        <?php echo form_error('last_name', '<div class="text-danger">', '</div>'); ?>
                                    </div>
                                    <div class="col-sm-4">
                                        <label for="email">Email</label>
                                        <input type="email" class="form-control" name="email" id="email"  placeholder="Email..." value="<?php echo isset($user) ? $user->email : set_value('email'); ?>">
                                        <?php echo form_error('email', '<div class="text-danger">', '</div>'); ?>
                                    </div>
                                </div>
                                <div class="form-group row">
                                    <div class="col-sm-4">
                                        <label for="password">Telefone</label>
                                        <input type="text" class="form-control phone_with_ddd" name="phone" id="phone"  placeholder="Telefone..." value="<?php echo isset($user) ? $user->phone : set_value('phone'); ?>">
                                        <?php echo form_error('phone', '<div class="text-danger">', '</div>'); ?>
                                    </div>
                                    <div class="col-sm-2">
                                        <label for="password">Senha</label>
                                        <input type="password" class="form-control" name="password" id="password"  placeholder="Senha...">
                                        <?php echo form_error('password', '<div class="text-danger">', '</div>'); ?>
                                    </div>
                                    <div class="col-sm-2">
                                        <label for="check_password">Confirme a senha</label>
                                        <input type="password" class="form-control" name="confirm_password" id="confirm_password"  placeholder="Confirme a senha...">
                                        <?php echo form_error('confirm_password', '<div class="text-danger">', '</div>'); ?>
                                    </div>
                                    <div class="col-sm-3">
                                        <label for="group">Grupo</label>
                                        <select class="form-control" name="group">
                                            <!--  -->
                                            <?php foreach ($groups as $group) : ?>
                                            <?php if (isset($user)) : ?>
                                                <option value="<?php echo $group->id; ?>" <?php echo ($group->id == $profile->id) ? 'selected' : '' ?>> <?php echo $group->description; ?></option>
                                            <?php else : ?>
                                                <option value="<?php echo $group->id; ?>"> <?php echo $group->description; ?></option>
                                            <?php endif; ?>
                                            <?php endforeach; ?>
                                            <!--  -->
                                        </select>
                                    </div>
                                </div>

                                <!--  -->
                                <?php if (isset($user)) : ?>
                                    <input type="hidden" name="user_id" value="<?php echo $user->id ?>">
                                <?php endif; ?>
                                <!--  -->

                                <button class="btn btn-primary">Cadastrar</button>
                            <?php echo form_close(); ?>

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

                </div><!--/Row-->

                <!-- Modal Logout -->
                <?php $this->load->view('restricted/layout/modal_logout'); ?>
                <!-- /Modal -->

            </div><!--- /Container Fluid-->
        </div><!-- /Content -->
