<?php

use yii\helpers\Html;
use yii\helpers\Url;
use yii\widgets\ActiveForm;
use kartik\time\TimePicker;
use kartik\select2\Select2;
use kartik\file\FileInput;

$lang = Yii::$app->language;

$this->title = Yii::t('app', 'Adjust System Configurations');
$this->params['breadcrumbs'][] = $this->title;

?>
<h1><?= Yii::t('app', 'System Configuations')?></h1>
<?php

    if(Yii::$app->session->hasFlash('updated')){
        echo "<div class='alert alert-success'>";
        echo Yii::$app->session->getFlash('updated');
        echo "</div>";
    }
    
?>
<br>
<div class="system-configurations-form" autocomplete="off">

    <?php $form = ActiveForm::begin(); ?>
        <div class="row">
            <div class="col-md-8">
                <div class="row">
                    <div class="col-md-6">
                        <?= $form->field($options, 'max_var_num')->textInput(['type' => 'number', 'min' => 1 ,'maxlength' => true]) ?>
                    </div>
                    <div class="col-md-6">
                        <?= $form->field($options, 'max_item_images')->textInput(['type' => 'number', 'min' => 1 ,'maxlength' => true]) ?>
                    </div>
                </div>
                <div class="row">
                    <div class="col-md-6">
                    <?= $form->field($options, 'currency')->textInput(['maxlength' => true]) ?>
                    </div>
                    <div class="col-md-6">
                    <?= $form->field($options, 'currency_ar')->textInput(['maxlength' => true]) ?>
                    </div>
                </div>
                
                <div class="row">
                    <div class="col-md-12">
                        <?= $form->field($options, 'arabic_about')->textArea(['maxlength' => true, 'rows' => 7, 'style' => 'resize:none;']) ?>
                    </div>
                </div>
               
                <div class="row">
                    <div class="col-md-12">
                        <?= $form->field($options, 'english_about')->textArea(['maxlength' => true, 'rows' => 7, 'style' => 'resize:none;']) ?>
                    </div>
                </div>
                <div class="row">
                    <div class="col-md-12">
                        <?= $form->field($options, 'facebook_link')->textInput(['maxlength' => true]) ?>
                    </div>
                </div>
                <div class="row">
                    <div class="col-md-12">
                        <?= $form->field($options, 'whatsapp_link')->textInput(['maxlength' => true]) ?>
                    </div>
                </div>
                <div class="row">
                    <div class="col-md-12">
                        <?= $form->field($options, 'instagram_link')->textInput(['maxlength' => true]) ?>
                    </div>
                </div>
                <div class="row">
                    <div class="col-md-12">
                        <?= $form->field($options, 'messenger_link')->textInput(['maxlength' => true]) ?>
                    </div>
                </div>
                <div class="row">
                    <div class="col-md-12">
                        <?= $form->field($options, 'twitter_link')->textInput(['maxlength' => true]) ?>
                    </div>
                </div>
            </div>
            <div class="col-md-4 ">
                <div class="row">
                    <?php if ($options->logo != null) : ?>
                        <div class="col-md-12">
                            <?= $form->field($options, 'logo')->widget(FileInput::classname(), [
                                'options' => ['multiple' => false, 'accept' => 'image/*'],
                                'pluginOptions' => [
                                    'maxFileCount' => 1,
                                    'initialPreviewAsData'=>true,
                                    'initialPreview'=>[
                                        Url::base() . '/' . $options->logo,
                                    ],
                                    'initialPreviewConfig' => [
                                        ['showRemove' => false],
                                    ],
                                    'showRemove' => false,
                                    'showUpload' => false,
                                ]
                            ]) ?>
                        </div>
                    <?php else : ?>
                        <div class="col-md-12">
                            <?= $form->field($options, 'logo')->widget(FileInput::classname(), [
                                'options' => ['multiple' => false, 'accept' => 'image/*'],
                                'pluginOptions' => [
                                    'maxFileCount' => 1,
                                    'showRemove' => false,
                                    'showUpload' => false,
                                ]
                            ]) ?>
                        </div>
                    <?php endif; ?>
                </div>
            </div>
            <div class="col-md-4">
                <div class="row">
                <?php if ($options->restaurant_image != null) : ?>
                        <div class="col-md-12">
                            <?= $form->field($options, 'restaurant_image')->widget(FileInput::classname(), [
                                'options' => ['multiple' => false, 'accept' => 'image/*'],
                                'pluginOptions' => [
                                    'maxFileCount' => 1,
                                    'initialPreviewAsData'=>true,
                                    'initialPreview'=>[
                                        Url::base() . '/' . $options->restaurant_image,
                                    ],
                                    'initialPreviewConfig' => [
                                        ['showRemove' => false],
                                    ],
                                    'showRemove' => false,
                                    'showUpload' => false,
                                ]
                            ]) ?>
                        </div>
                    <?php else : ?>
                        <div class="col-md-12">
                            <?= $form->field($options, 'restaurant_image')->widget(FileInput::classname(), [
                                'options' => ['multiple' => false, 'accept' => 'image/*'],
                                'pluginOptions' => [
                                    'maxFileCount' => 1,
                                    'showRemove' => false,
                                    'showUpload' => false,
                                ]
                            ]) ?>
                        </div>
                    <?php endif; ?>
                </div>
                </div>
            </div>
        </div>
       
    <div class="form-group">
        <?= Html::submitButton(Yii::t('app', 'Save'), ['class' => 'btn btn-success']) ?>
    </div>

    <?php ActiveForm::end(); ?>

</div>