<?php
$form = is_array($form ?? null) ? $form : [];
$errors = is_array($errors ?? null) ? $errors : [];
$validationSummaryErrors = is_array($validationSummaryErrors ?? null) ? $validationSummaryErrors : [];
$closeTarget = $closeTarget ?? 'security/templates';
?>
<div class="app-wizard-content">
  <div class="app-wizard-header">
    <a href="<?php e(lurl($closeTarget)); ?>" class="app-wizard-back" data-tooltip="<?php e(t('Back to list')); ?>">
      <i class="bi bi-arrow-left"></i>
    </a>
    <h1 class="app-wizard-title"><?php e(t('New check template')); ?></h1>
  </div>

  <?php if ($validationSummaryErrors): ?>
    <?php require templatePath('partials/app-details-validation-summary.phtml'); ?>
  <?php endif; ?>

  <div class="app-wizard-card">
    <form method="post" id="security-template-create-form">
      <h2 class="app-wizard-card-heading"><?php e(t('Create a check template')); ?></h2>
      <p class="app-wizard-card-description"><?php e(t('A template represents one software product and its technical checklist. You can add checklist items after creating it.')); ?></p>

      <div class="app-wizard-field-group">
        <label for="security-template-code"><?php e(t('Product code')); ?> <span class="security-form-required">*</span></label>
        <input type="text" id="security-template-code" name="product_code" value="<?php e($form['product_code'] ?? ''); ?>"
               placeholder="<?php e(t('e.g. intranet, mysyde-cms')); ?>" autocomplete="off">
        <?php if (!empty($errors['product_code'])): ?>
          <p class="field-error"><?php e($errors['product_code']); ?></p>
        <?php endif; ?>
      </div>

      <div class="app-wizard-field-group">
        <label for="security-template-name"><?php e(t('Product name')); ?> <span class="security-form-required">*</span></label>
        <input type="text" id="security-template-name" name="product_name" value="<?php e($form['product_name'] ?? ''); ?>"
               placeholder="<?php e(t('e.g. Intranet, Mysyde CMS')); ?>" autocomplete="off">
        <?php if (!empty($errors['product_name'])): ?>
          <p class="field-error"><?php e($errors['product_name']); ?></p>
        <?php endif; ?>
      </div>

      <?php \MintyPHP\Session::getCsrfInput(); ?>

      <div class="app-wizard-actions">
        <a href="<?php e(lurl($closeTarget)); ?>" role="button" class="outline secondary"><?php e(t('Cancel')); ?></a>
        <button type="submit" class="primary"><?php e(t('Create template')); ?></button>
      </div>
    </form>
  </div>
</div>
