<?php

use yii\helpers\Html;
use myresto\models\SyncConfig;
use yii\bootstrap\ActiveForm;
use kartik\select2\Select2;

$payments = $model->getPaymentData();
$accounts = $model->getAccountData();
$paymentAccounts = $model->getPaymentAccountData();

$this->title = 'Configuration';
$this->params['breadcrumbs'][] = ['label' => 'Account Configuration', 'url' => ['index']];
// $this->params['breadcrumbs'][] = ['label' => $model->payment_fpkey, 'url' => ['view', 'id' => $model->payment_fpkey]];
$this->params['breadcrumbs'][] = 'Update';
?>
<div class="content-page config">
    <div class="content-page-header"><?= Html::encode($this->title) ?></div>
    <div class="content-page-content config-content container-fluid">

    <?php $form = ActiveForm::begin(); ?>
        <div class="row">
            <div class="config-content-left col-md-3">Payment Method</div>
            <div class="config-content-right col-md-9">
                <div class="config-content-right-header row">
                    <div class="col-xs-6">Payment</div>
                    <div class="col-xs-6">Account</div>
                </div>
                <?php
                foreach ($payments as $key => $payment) {
                    ?>
                    <div class="config-content-right-payacc row">
                        <div class="col-xs-6">
                            <div class="config-content-right-payacc-payment">
                                <?= $payment ?>
                            </div>
                        </div>
                        <div class="config-content-right-payacc-account col-xs-6">
                            <?php
                            echo Select2::widget([
                                'name' => "accountPayments[$key]",
                                'data' => $accounts,
                                'value' => $paymentAccounts[$key],
                                'options' => [
                                    'placeholder' => 'Select Account',
                                    'required' => true,
                                ]
                            ]);
                            ?>
                        </div>
                    </div>
                    <?php
                }
                ?>
            </div>
        </div>

    </div>
    <div class="content-page-footer text-right">
        <?= Html::submitButton('Save', ['class' => 'btn btn-primary']) ?>
        <?php ActiveForm::end(); ?>
    </div>
</div>
