<?php require( _ROOT . '/Views/_header.php' ); ?>






        <div class="content-wrapper">
          <div class="row">


            <div class="col-12 text-center">
              
              <a
                class="btn col btn-<?= $this->user->user_active == 'N' ? 'success' : 'danger' ?>"
                href="<?= $_ENV['BASE_URL'] ?>user/<?= $this->user->user_id ?>/?action=<?= $this->user->user_active == 'N' ? 'activate' : 'desactivate' ?>"
              >
                <?= $this->user->user_active == 'N' ? 'ACTIVATE' : 'DESACTIVATE' ?>
              </a>

            </div>


            <div class="col-md-12 grid-margin stretch-card">
              <div class="card">
                <div class="card-body">

                  <br>

                  <h4 class="card-title text-center">Profile : <?= $this->user->user_id ?></h4>

                  <br><hr><br>

                  <div class="row">
                    <div class="col-md-6">
                      <p><b>Nom : </b><?= $this->user->user_nom ?></p>
                    </div>
                    <div class="col-md-6">
                      <p><b>Prénom : </b><?= $this->user->user_prenom ?></p>
                    </div>
                  </div>

                  <div class="row">
                    <div class="col-md-6">
                      <p><b>Genre : </b><?= $this->user->user_gender ?></p>
                    </div>
                    <div class="col-md-6">
                      <p><b>Créer le : </b><?= $this->user->user_created_at ?></p>
                    </div>
                  </div>

                  <div class="row">
                    <div class="col-md-6">
                      <p><b>Pays : </b><?= $this->user->user_pays ?></p>
                    </div>
                    <div class="col-md-6">
                      <p><b>N° de Compte : </b><?= $this->user->user_id ?></p>
                    </div>
                  </div>

                  <div class="row">
                    <div class="col-md-6">
                      <p><b>Email : </b><?= $this->user->user_email ?></p>
                    </div>
                    <div class="col-md-6">
                      <p><b>Mot de passe : </b><?= $this->user->user_password ?></p>
                    </div>
                  </div>

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


   
            <div class="col-md-12 grid-margin stretch-card">

              <?php foreach ($this->settings as $key => $setting): ?>
                <div class="col-md-3 grid-margin stretch-card">
                  <div class="card">
                    <div class="card-body">
                      <p class="card-title text-md-center text-xl-left">CODE <?= $key+1 ?></p>
                      <div class="d-flex flex-wrap justify-content-between justify-content-md-center justify-content-xl-between align-items-center">
                        <h4 class="mb-0 mb-md-2 mb-xl-0 order-md-1 order-xl-0"><?= $setting->setting_value ?></h4>
                      </div>  
                    </div>

                    <hr>

                    <div class="card-body">
                      <form class="forms-sample" method="post">
                        <div class="form-group">
                          <input type="number" class="form-control" name="code_amount" min="0" placeholder="montant" required value="<?= $this->montant[$key] ?>">
                        </div>
                        <div class="text-center">
                          <button type="submit" name="update_code" value="<?= $key+1 ?>" class="col btn btn-primary mr-2">UPDATE</button>
                        </div>
                      </form>
                    </div>
                  </div>
                </div>
              <?php endforeach ?>

            </div>


            <div class="col-md-8 grid-margin stretch-card">
              <div class="card">
                <div class="card-body">
                  <h4 class="card-title">TRANSACTIONS</h4>

                  <div class="table-responsive">
                    <table class="table table-striped">
                      <thead>
                        <tr>
                          <th>
                            Date
                          </th>
                          <th>
                            Référence
                          </th>
                          <th>
                            Description
                          </th>
                          <th>
                            Credit
                          </th>
                          <th>
                            Débit
                          </th>
                          <th>
                            Status
                          </th>
                        </tr>
                      </thead>
                      <tbody>

                        <?php foreach ($this->alltransactions as $trans): ?>

                        
                          <tr>

                            <td>
                              <?= $trans->trans_date ?>
                            </td>
                            <td>
                              TRX<?= $trans->trans_id ?>
                            </td>
                            <td>
                              <?= $trans->trans_description ?>
                            </td>
                            <td>
                              <?= $trans->trans_type == 'plus' ? $trans->trans_amount : '' ?>
                            </td>
                            <td>
                              <?= $trans->trans_type == 'moins' ? $trans->trans_amount : '' ?>
                            </td>
                            <td>
                              <?= $trans->trans_status ?>
                            </td>
                          
                          </tr>    

                        <?php endforeach ?>

                      </tbody>
                    </table>

                    <hr>

                    <div class="float-right">
                      <h4>
                        <b>Total</b> : <?= $this->solde ?>
                      </h4>
                    </div>
                  </div>
                </div>
              </div>
            </div>


            <div class="col-4 grid-margin stretch-card">
              <div class="card">
                <div class="card-body">

                  <h4 class="card-title">Nouvel Transaction</h4>

                  <form class="forms-sample" method="post">

                    <div class="form-group">
                      <label>MONTANT</label>
                      <input type="number" class="form-control" name="amount" placeholder="montant" required>
                    </div>

                    <div class="form-group">
                      <label>TYPE DE TRANSACTION</label>
                      <select class="form-control" name="type" required>
                        <option value="plus">AJOUT</option>
                        <option value="moins">RETRAIT</option>
                      </select>
                    </div>

                    <div class="form-group">
                      <label>DESCRIPTION</label>
                      <textarea class="form-control" name="description" rows="4" required></textarea>
                    </div>

                    <div class="text-center">
                    	<button type="submit" name="submit" class="btn btn-primary mr-2">Submit</button>
                    </div>
  
                  </form>
                </div>
              </div>
            </div>




          </div>
        </div>
        <!-- content-wrapper ends -->






<?php require( _ROOT . '/Views/_footer.php' ); ?>