Example #1
0
 * @var \app\models\Form $searchModel
 */
use kartik\dynagrid\DynaGrid;
use kartik\helpers\Html;
$this->title = Yii::t('app', 'Currencies');
$this->params['breadcrumbs'][] = $this->title;
?>

<?php 
echo app\widgets\Alert::widget(['id' => 'alert']);
$this->beginBlock('add-button');
echo \yii\helpers\Html::a(\kartik\icons\Icon::show('plus') . ' ' . Yii::t('app', 'Add'), ['edit', 'returnUrl' => \app\backend\components\Helper::getReturnUrl()], ['class' => 'btn btn-success']);
echo \app\backend\widgets\RemoveAllButton::widget(['url' => 'remove-all', 'gridSelector' => '.grid-view', 'htmlOptions' => ['class' => 'btn btn-danger pull-right']]);
$this->endBlock();
?>



<div class="row">
    <div class="col-md-12">
        <?php 
echo DynaGrid::widget(['options' => ['id' => 'currencies-grid'], 'columns' => [['class' => \app\backend\columns\CheckboxColumn::className()], 'id', 'name', 'iso_code', 'convert_nominal', 'convert_rate', ['attribute' => 'currency_rate_provider_id', 'class' => \kartik\grid\EditableColumn::className(), 'editableOptions' => ['data' => [0 => '-'] + \app\components\Helper::getModelMap(\app\modules\shop\models\CurrencyRateProvider::className(), 'id', 'name'), 'inputType' => 'dropDownList', 'placement' => 'left', 'formOptions' => ['action' => 'update-editable']], 'filter' => \app\components\Helper::getModelMap(\app\modules\shop\models\CurrencyRateProvider::className(), 'id', 'name'), 'format' => 'raw', 'value' => function ($model, $key, $index, $column) {
    if ($model === null || $model->rateProvider === null) {
        return null;
    }
    return Html::tag('div', $model->rateProvider->name, ['class' => $model->rateProvider->name]);
}], ['class' => \app\backend\components\ActionColumn::className()]], 'theme' => 'panel-default', 'gridOptions' => ['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'hover' => true, 'panel' => ['heading' => $this->render('_tabs', ['currencies' => true]), 'after' => $this->blocks['add-button']]]]);
?>
    </div>
</div>
Example #2
0
 /**
  * Relation to CurrencyRateProvider model
  * @return \yii\db\ActiveQuery
  */
 public function getRateProvider()
 {
     return $this->hasOne(CurrencyRateProvider::className(), ['id' => 'currency_rate_provider_id']);
 }
 /**
  * @inheritdoc
  */
 public function actions()
 {
     return ['remove-all' => ['class' => MultipleDelete::className(), 'modelName' => CurrencyRateProvider::className()], 'delete' => ['class' => DeleteOne::className(), 'modelName' => CurrencyRateProvider::className()]];
 }
Example #4
0
BackendWidget::begin(['icon' => 'gear', 'title' => Yii::t('app', 'Currency'), 'footer' => Html::a(Icon::show('arrow-circle-left') . Yii::t('app', 'Back'), Yii::$app->request->get('returnUrl', ['/backend/currencies/index', 'id' => $model->id]), ['class' => 'btn btn-danger']) . ' ' . ($model->isNewRecord ? Html::submitButton(Icon::show('save') . Yii::t('app', 'Save & Go next'), ['class' => 'btn btn-success', 'name' => 'action', 'value' => 'next']) : '') . ' ' . Html::submitButton(Icon::show('save') . Yii::t('app', 'Save & Go back'), ['class' => 'btn btn-warning', 'name' => 'action', 'value' => 'back']) . ' ' . Html::submitButton(Icon::show('save') . Yii::t('app', 'Save'), ['class' => 'btn btn-primary', 'name' => 'action', 'value' => 'save'])]);
?>
            <?php 
echo $form->field($model, 'name')->textInput(['maxlength' => 255]);
?>
            <?php 
echo $form->field($model, 'iso_code')->textInput(['maxlength' => 4]);
?>
            <?php 
echo $form->field($model, 'is_main')->textInput()->widget(\kartik\widgets\SwitchInput::className());
?>
            <?php 
echo $form->field($model, 'convert_nominal');
?>
            <?php 
echo $form->field($model, 'currency_rate_provider_id')->dropDownList([0 => '-'] + app\components\Helper::getModelMap(\app\modules\shop\models\CurrencyRateProvider::className(), 'id', 'name'));
?>
            <?php 
echo $form->field($model, 'convert_rate', ['addon' => ['append' => ['content' => Html::a(Icon::show('question-circle'), '#', ['data-toggle' => 'popover', 'data-trigger' => 'focus', 'data-content' => Yii::t('app', 'Convert rate is updated automatically if currency rate provider is set and includes additional rate and nominal.')])]]]);
?>

            <?php 
echo $form->field($model, 'additional_rate');
?>
            <?php 
echo $form->field($model, 'additional_nominal');
?>

            <?php 
echo $form->field($model, 'sort_order');
?>