
    <?php
    // Don't show this container when only rendering the widget section
    if (!($render_section ?? null) && !($is_ajax ?? null)) {
    ?>
    <div class="col-md-3">
        <?php echo ($navigation ?? null); ?>
    </div>
    <div class="col-md-9">
    <?php
    }
    ?>
        <div class="row">
            <div class="col-md-12">
                <?php echo ($message ?? null);?>

                <?php
                $this->WidgetClient->clear();
                $this->WidgetClient->create($this->_('ClientManagers.accounts.boxtitle_managed_accounts', true), ['id' => 'client_managers_accounts'], ($render_section ?? null));
                $this->WidgetClient->startBody();

                if (($accounts ?? false) && (($num_accounts = count($accounts)) > 0)) {
                ?>
                <div class="table-responsive">
                    <table class="table table-curved table-striped" id="managers">
                        <thead>
                            <tr>
                                <th><a href="<?php echo $this->Html->safe($this->base_uri . 'managers/accounts/?sort=client_id_code&order=' . ($sort == 'client_id_code' ? $negate_order : $order));?>" class="ajax<?php echo $this->Html->safe($sort == 'client_id_code' ? ' ' . $order : '');?>"><?php $this->_('ClientManagers.accounts.heading_client_id');?></a></th>
                                <th><a href="<?php echo $this->Html->safe($this->base_uri . 'managers/accounts/?sort=email&order=' . ($sort == 'email' ? $negate_order : $order));?>" class="ajax<?php echo $this->Html->safe($sort == 'email' ? ' ' . $order : '');?>"><?php $this->_('ClientManagers.accounts.heading_email');?></a></th>
                                <th><a href="<?php echo $this->Html->safe($this->base_uri . 'managers/accounts/?sort=first_name&order=' . ($sort == 'first_name' ? $negate_order : $order));?>" class="ajax<?php echo $this->Html->safe($sort == 'first_name' ? ' ' . $order : '');?>"><?php $this->_('ClientManagers.accounts.heading_name');?></a></th>
                                <th><?php $this->_('ClientManagers.accounts.heading_company');?></th>
                                <th><?php $this->_('ClientManagers.accounts.heading_options');?></th>
                            </tr>
                        </thead>
                        <tbody>
                            <?php
                            // Loop through all managers
                            for ($i = 0; $i < $num_accounts; $i++) {
                            ?>
                            <tr>
                                <td><?php echo $this->Html->safe($accounts[$i]->client_id_code ?? null);?></td>
                                <td><?php echo $this->Html->safe($accounts[$i]->email ?? null);?></td>
                                <td><?php echo $this->Html->concat(' ', (isset($accounts[$i]->first_name) ? $this->Html->safe($accounts[$i]->first_name) : null), (isset($accounts[$i]->last_name) ? $this->Html->safe($accounts[$i]->last_name) : null));?></td>
                                <td><?php echo $this->Html->safe($accounts[$i]->company ?? null);?></td>
                                <td>
                                    <?php
                                    $this->Form->create($this->base_uri . 'managers/give/');
                                    $this->Form->fieldHidden('client_id', ($accounts[$i]->id ?? null));
                                    ?>
                                    <div class="btn-group">
                                        <a href="<?php echo $this->Html->safe($this->base_uri . 'managers/manage/' . (isset($accounts[$i]->id) ? $this->Html->safe($accounts[$i]->id) : null) . '/');?>"  class="btn btn-xs btn-light">
                                            <i class="fas fa-user-cog fa-fw"></i> <?php $this->_('ClientManagers.accounts.option_manage');?>
                                        </a>
                                        <button class="btn btn-xs btn-light dropdown-toggle" data-toggle="dropdown" type="button">
                                            <span class="caret"></span>
                                        </button>
                                        <div class="dropdown-menu">
                                            <a class="dropdown-item" href="<?php echo $this->Html->safe($this->base_uri . 'managers/give/' . (isset($accounts[$i]->id) ? $this->Html->safe($accounts[$i]->id) : null) . '/');?>" rel="<?php echo $this->Html->safe($this->_('ClientManagers.accounts.confirm_give_up', true));?>">
                                                <i class="fas fa-ban fa-fw"></i> <?php $this->_('ClientManagers.accounts.option_give_up_access');?>
                                            </a>
                                        </div>
                                    </div>
                                    <?php
                                    $this->Form->end();
                                    ?>
                                </td>
                            </tr>
                            <?php
                            }
                            ?>
                        </tbody>
                    </table>
                </div>
                <?php
                } else {
                ?>
                <div class="alert alert-info">
                    <p><?php $this->_('ClientManagers.accounts.no_results');?></p>
                </div>
                <?php
                }

                $this->WidgetClient->endBody();
                $this->WidgetClient->end();
                ?>
            </div>
        </div>
    <?php
    // Don't show this container when only rendering the widget section
    if (!(isset($render_section) ? $render_section : null) && !(isset($is_ajax) ? $is_ajax : null)) {
    ?>
    </div>
    <?php
    }
    ?>
<?php
$this->Javascript->setInline("
	$(document).ready(function() {
		// Handle confirmation on delete action
		$('#client_managers_accounts a[rel]').blestaModalConfirm({
			base_url: '" . $this->base_uri . "',
			submit: true
		});
	});
");
?>