<?php
$translate = $this->plugin('translate');
$escape = $this->plugin('escapeHtml');
$form->prepare();
$this->htmlElement('body')->appendAttribute('class', 'batch-edit users');
?>
<?php echo $this->pageTitle($translate('Batch edit users')); ?>

<?php $this->trigger('view.batch_edit.before'); ?>

<?php echo $this->form()->openTag($form); ?>

<?php foreach ($resources as $resource): ?>
<input type="hidden" name="resource_ids[]" value="<?php echo $resource->id(); ?>">
<?php endforeach; ?>
<input type="hidden" name="query" value="<?php echo $this->escapeHtml(json_encode($query)); ?>">

<div id="page-actions">
    <input type="submit" name="batch_update" value="<?php echo $this->escapeHtml($translate('Save')); ?>">
</div>

<?php echo $this->formCollection($form, false); ?>
<?php echo $this->form()->closeTag(); ?>

<div class="sidebar always-open">
    <h3><?php echo $translate('Affected users'); ?></h3>
    <?php if ($resources): ?>
    <p><?php echo sprintf($translate('You are editing the following %s users:'), count($resources)); ?></p>
    <ul class="batch-selected">
        <?php foreach ($resources as $resource): ?>
        <li><?php echo $resource->link($resource->email(), null, ['target' => '_blank']); ?></li>
        <?php endforeach; ?>
    </ul>
    <?php else: ?>
    <p><?php echo sprintf($translate('You are editing %s users (except yourself).'), $this->hyperlink(number_format($count), $this->url(null, ['action' => 'browse'], ['query' => $query], true), ['target' => '_blank'])); ?></p>
    <?php endif; ?>
</div>

<?php $this->trigger('view.batch_edit.after'); ?>
