<?php echo $this->partial('template/menu.phtml', array('menu' => 'utenti')); ?>

<div class="row">
    <div class="span6">
        <h4>Lista Utenti</h4>
    </div>
    <div class="span6">
        <p class="text-right">
            <a class="btn btn-success"
               href="<?php echo $this->url('admin_utenti/default', array('action' => 'aggiungi')); ?>">
                <i class="icon-plus icon-white"></i> Aggiungi Utente
            </a>
        </p>
    </div>
</div>


<div class="row">
    <div class="span12">

        <?php if ($this->message): ?>
            <div class="alert alert-success">
                <?php echo $this->message[0]; ?>
            </div>
        <?php endif; ?>

        <?php if (count($this->utenti) > 0): ?>
            <table class="table table-bordered">
                <thead>
                <tr>
                    <th>Utente</th>
                    <th>Ruolo</th>
                    <th>Account</th>
                    <th>Programma Modalità</th>
                    <th>Modifica</th>
                    <th>Cancella</th>
                </tr>
                </thead>
                <tbody>
                <?php foreach ($this->utenti as $row): ?>
                    <tr>
                        <td><?php echo $this->escapehtml($row['nome']); ?> <?php echo $this->escapehtml($row['cognome']); ?></td>
                        <td><?php echo $this->escapehtml($row['nome_ruolo']); ?></td>
                        <td><?php echo $this->status_helper($row['status']); ?></td>

                        <?php if ($row['nome_ruolo'] != \Application\Model\Ruoli::RUOLO_SUPER_AMMINISTRATORE && $row['nome_ruolo'] != \Application\Model\Ruoli::RUOLO_AMMINISTRATORE): ?>
                            <td>
                                <a class="btn btn-primary"
                                   href="<?php echo $this->url('programma_modalita/default', array('action' => 'index', 'utente' => $row['id'])); ?>"><i
                                        class="icon-edit icon-white"></i> Programma</a>
                            </td>
                        <?php else: ?>
                            <td>-</td>
                        <?php endif; ?>

                        <td>
                            <a class="btn btn-warning"
                               href="<?php echo $this->url('admin_utenti/default', array('action' => 'modifica', 'id' => $row['id'])); ?>"><i
                                    class="icon-edit icon-white"></i> Modifica</a>
                        </td>
                        <td>
                            <a class="btn btn-danger"
                               href="#deleteModal-<?php echo $this->escapehtml($row['id']); ?>" data-toggle="modal"><i
                                    class="icon-trash icon-white"></i> Cancella</a>
                            <div id="deleteModal-<?php echo $this->escapehtml($row['id']); ?>" class="modal hide fade" tabindex="-1" role="dialog" aria-hidden="true">
                                <div class="modal-header">
                                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">x</button>
                                    <h3 id="myModalLabel">Cancella</h3>
                                </div>
                                <div class="modal-body">
                                    <p>Sei sicuro di voler eliminare questo record?</p>
                                </div>
                                <div class="modal-footer">
                                    <a class="btn btn-danger" href="<?php echo $this->url('admin_utenti/default', array('action' => 'elimina', 'id' => $row['id'])); ?>">SI</a>
                                </div>
                            </div>
                        </td>
                    </tr>
                <?php endforeach; ?>
                </tbody>
            </table>
        <?php endif ?>
    </div>
</div>