<?php

use yii\helpers\Html;
use yii\widgets\ActiveForm;

/* @var yii\web\View $this */
/* @var \PortalPeople\gforce\models\RateUploadForm $form */

$this->title = 'Import GForce Rate Sheet';
$this->params['breadcrumbs'][] = $this->title;

if (!isset($form)) {
    $form = new \PortalPeople\gforce\models\RateUploadForm();
}
?>
<div class="gforce-rate-upload">

    <?php if (Yii::$app->session->hasFlash('error')) { ?>
        <div class="alert alert-danger">
            <?= Html::encode((string) Yii::$app->session->getFlash('error')) ?>
        </div>
    <?php } ?>

    <div class="card mb-3">
        <div class="card-header">
            <h4 class="mb-0">Import GForce Rate Sheet</h4>
        </div>
        <div class="card-body">

            <p class="text-muted mb-3">
                Upload a GForce pricing spreadsheet (<code>.xlsx</code> / <code>.xls</code>).
                You will see a preview screen first showing what will be created or updated before saving.
            </p>

            <div class="alert alert-info">
                <strong>Expected column layout:</strong>
                <code>
                    Provider | ERPID | Service | PostCode | [Concat] | Micro | Mini QP | Qtr | &hellip;
                </code>
                <ul class="mb-0 mt-1 small">
                    <li>The header row is detected automatically.</li>
                    <li>Price cells containing <em>N/A</em> or blank are skipped.</li>
                    <li>PostCode ranges (e.g. <code>AB1-5</code>) are expanded to individual postcodes.</li>
                </ul>
            </div>

            <?php $activeForm = ActiveForm::begin(['options' => ['enctype' => 'multipart/form-data']]) ?>

                <?= $activeForm->field($form, 'priceFile')->fileInput(['accept' => '.xlsx,.xls']) ?>

                <div class="mt-3">
                    <?= Html::submitButton('Upload &amp; Preview', ['class' => 'btn btn-primary']) ?>
                </div>

            <?php ActiveForm::end() ?>

        </div>
    </div>

</div>
