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

<?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('Submit')); ?>">
</div>

<?php echo $this->formCollectionElementGroups($form, false); ?>
<?php echo $this->partial('common/property-form-batch-edit.phtml', ['resourceType' => 'items']); ?>
<?php echo $this->form()->closeTag(); ?>

<div class="sidebar always-open">
    <h3><?php echo $translate('Affected items'); ?></h3>
    <?php if ($resources): ?>
    <p><?php echo sprintf($translate('You are editing the following %s items:'), count($resources)); ?></p>
    <ul class="batch-selected">
        <?php foreach ($resources as $resource): ?>
        <li><?php echo $resource->link($resource->displayTitle(), null, ['target' => '_blank']); ?></li>
        <?php endforeach; ?>
    </ul>
    <?php else: ?>
    <p><?php echo sprintf($translate('You are editing %s items.'), $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'); ?>
