<?php

use yii\helpers\Html;
use yii\widgets\ActiveForm;
//Models
use backend\models\Accounts;
use backend\models\Attributesvalues;

/**
 * @var yii\web\View $this
 * @var PortalPeople\shippingcosts\models\Shippingcosts $model
 * @var yii\widgets\ActiveForm $form
 */


?>

<div class="shippingcosts-form">
    <?php $form = ActiveForm::begin(); ?>
    <div class="card">
        <div class="card-header">
        </div>
        <div class="card-body">
            <div class="row">
                <div class="col-md-8 col-12">
                    <?= $form->field($model, 'postcodes')->textarea(['rows' => 10]) ?>
                </div>

                <div class="col-md-4 col-12">
                    <div class="row">
                        <div class="col-12">
                            <?= $form->field($model, 'status')->dropdownlist(Attributesvalues::formArray('sys_status'), ['prompt' => 'Please Select']) ?>
                            <?= Yii::$app->controller->action->id == 'update' ? $form->field($model, 'regen')->checkbox() : null ?>
                            <?= Yii::$app->controller->action->id == 'create' 
                                ? $form->field($model, 'types')->checkboxList(Attributesvalues::formArray('shipping_types'), ['prompt' => 'Please Select']) 
                                : $form->field($model, 'type')->dropdownlist(Attributesvalues::formArray('shipping_types'), ['prompt' => 'Please Select']) ?>
                            <?= $form->field($model, 'haulierid')->dropdownlist(Accounts::intids('haulier'), ['prompt' => 'Please Select']); ?>
                            <?= $form->field($model, 'no_of_prices')->dropdownlist([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10], ['prompt' => 'Please Select']); ?>

                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <div class="card">
        <div class="card-header">
            Pricing
        </div>
        <div class="card-body">
            <div class="row d-flex">
                <table class="table table-bordered table-sm">
                    <?php $fields = ['label', 'qty', 'size', 'price']; ?>
                    <?php foreach ($fields as $field) { ?>
                        <tr>
                            <th><?= ucfirst($field); ?></th>
                            <?php foreach ($pricing as $key => $object) { ?>
                                <td class="p-0">
                                    <?= $form->field($object, "[$key]" . $field)->textInput()->label(false); ?>
                                </td>
                            <?php } ?>
                        </tr>
                    <?php } ?>
                </table>
            </div>
        </div>
    </div>
    <div class="form-group">
        <?= Html::submitButton('Save', ['class' => 'btn btn-primary']) ?>
    </div>
    <?php ActiveForm::end(); ?>
</div>