<?php use app\backend\widgets\BackendWidget; use app\components\Helper; use yii\helpers\Html; /** * @var \yii\web\View $this * @var \app\modules\shop\models\Contragent $model */ $this->title = Yii::t('app', 'Contragent edit'); $this->params['breadcrumbs'][] = ['label' => Yii::t('app', 'Contragents'), 'url' => ['index']]; $this->params['breadcrumbs'][] = $this->title; $form = \yii\bootstrap\ActiveForm::begin(['id' => 'contragent-form', 'action' => \yii\helpers\Url::toRoute(['create', 'customer' => $model->customer_id]), 'layout' => 'horizontal']); BackendWidget::begin(['icon' => 'user', 'title' => Yii::t('app', 'Contragent edit'), 'footer' => \yii\helpers\Html::submitButton(Yii::t('app', 'Save'), ['class' => 'btn btn-success'])]); $_jsTemplateResultFunc = <<<'JSCODE' function (data) { if (data.loading) return data.text; var tpl = '<div class="s2contragent-result">' + '<strong>' + (data.first_name || '') + ' ' + (data.middle_name || '') + ' ' + (data.last_name || '') + ' ' + '</strong>' + '<div>' + (data.email || '') + ' (' + (data.phone || '') + ')</div>' + '</div>'; return tpl; } JSCODE; echo \app\backend\widgets\Select2Ajax::widget(['initialData' => [$model->customer_id => null !== $model->customer ? $model->customer->first_name : 'Guest'], 'model' => $model, 'modelAttribute' => 'customer_id', 'form' => $form, 'multiple' => false, 'searchUrl' => \yii\helpers\Url::toRoute(['ajax-customer']), 'pluginOptions' => ['allowClear' => false, 'escapeMarkup' => new \yii\web\JsExpression('function (markup) {return markup;}'), 'templateResult' => new \yii\web\JsExpression($_jsTemplateResultFunc), 'templateSelection' => new \yii\web\JsExpression('function (data) {return data.first_name || data.text;}')]]); echo \app\modules\shop\widgets\Contragent::widget(['viewFile' => 'contragent/inherit_form', 'model' => $model, 'form' => $form, 'additional' => ['hideHeader' => true]]); BackendWidget::end(); $form->end();
$('div#div_contragent').html(data.card); } if (data.id) { $('a.edit_contragent').attr('href', '/shop/backend-contragent/edit?id=' + data.id); } return data.type || data.text; } JSCODE; $_jsDataFunc = <<<'JSCODE' function (term, page) { return { search: {customer:$('select#order-customer_id').val()} }; } JSCODE; echo \app\backend\widgets\Select2Ajax::widget(['initialData' => [$model->contragent_id => null !== $model->contragent ? $model->contragent->type : 'New contragent'], 'model' => $model, 'modelAttribute' => 'contragent_id', 'form' => $form, 'multiple' => false, 'searchUrl' => \yii\helpers\Url::toRoute(['ajax-contragent', 'template' => 'simple']), 'pluginOptions' => ['minimumInputLength' => null, 'allowClear' => false, 'escapeMarkup' => new \yii\web\JsExpression('function (markup) {return markup;}'), 'templateResult' => new \yii\web\JsExpression($_jsTemplateResultFunc), 'templateSelection' => new \yii\web\JsExpression($_jsSelectionFunc), 'ajax' => ['data' => new \yii\web\JsExpression($_jsDataFunc), 'processResults' => new \yii\web\JsExpression($_jsProcessResultsFunc), 'cache' => true]]]); ?> <?php echo Html::tag('div', Html::a(Yii::t('app', 'Create contragent'), Url::toRoute(['/shop/backend-contragent/create']), ['target' => '_blank', 'class' => 'btn btn-xs btn-info new_contragent']) . Html::a(Yii::t('app', 'Edit contragent'), Url::toRoute(['/shop/backend-contragent/index']), ['target' => '_blank', 'class' => 'btn btn-xs btn-info edit_contragent']), ['class' => 'btn-group col-md-offset-2']); ?> <hr /> <div id="div_contragent"> <?php echo \app\modules\shop\widgets\Contragent::widget(['viewFile' => 'contragent/backend_list', 'model' => $model->contragent]); ?> </div> <?php BackendWidget::end(); ?> <?php
<?php /** * @var $attribute_name string * @var $form \yii\widgets\ActiveForm * @var $label string * @var $model \app\properties\AbstractModel * @var $multiple boolean * @var $property_id integer * @var $property_key string * @var $this \yii\web\View * @var $values \app\properties\PropertyValue */ use app\modules\shop\models\Product; use yii\helpers\ArrayHelper; $productIds = ArrayHelper::getColumn($values->values, 'value'); $data = []; foreach ($values->values as $value) { $product = Product::findById($value['value']); if (is_object($product)) { $data[$product->id] = $product->name; } } ?> <?php echo \app\backend\widgets\Select2Ajax::widget(['initialData' => $data, 'form' => $form, 'model' => $model, 'modelAttribute' => $property_key, 'multiple' => $multiple === 1, 'searchUrl' => '/shop/backend-product/ajax-related-product', 'additional' => ['placeholder' => Yii::t('app', 'Search')]]);
echo $form->field($model, 'price', ['addon' => ['append' => ['content' => Html::activeDropDownList($model, 'currency_id', app\modules\shop\models\Currency::getSelection())]]]); ?> <?php echo $form->field($model, 'old_price'); ?> <?php echo $form->field(app\models\ViewObject::getByModel($model, true), 'view_id')->dropDownList(app\models\View::getAllAsArray()); ?> <?php if (!$model->isNewRecord && is_array($model->relatedProductsArray)) { $data = \yii\helpers\ArrayHelper::map($model->relatedProducts, 'id', 'name'); ?> <?php echo \app\backend\widgets\Select2Ajax::widget(['initialData' => $data, 'form' => $form, 'model' => $model, 'modelAttribute' => 'relatedProductsArray', 'multiple' => true, 'searchUrl' => '/shop/backend-product/ajax-related-product', 'additional' => ['placeholder' => 'Поиск продуктов ...']]); ?> <?php } ?> <?php echo $form->field($model, 'measure_id')->dropDownList(\app\components\Helper::getModelMap(\app\modules\shop\models\Measure::className(), 'id', 'name')); ?> <?php BackendWidget::end(); ?>
use app\modules\shop\widgets\AddonsListWidget; /** * @var \yii\web\View $this * @var \app\models\Object $object * @var \yii\db\ActiveRecord $model * @var array $addAddonTree * @var array $bindedAddons */ /** @var \app\modules\shop\models\AddonCategory $addonCategories */ /** @var app\backend\components\ActiveForm $form */ /** @var app\modules\shop\models\AddAddonModel $addAddonModel */ ?> <?php BackendWidget::begin(['title' => Yii::t('app', 'Addons'), 'icon' => 'cart-plus', 'footer' => $this->blocks['submit']]); echo \app\backend\widgets\Select2Ajax::widget(['initialData' => [], 'form' => $form, 'model' => $addAddonModel, 'modelAttribute' => 'addon_id', 'multiple' => false, 'searchUrl' => \yii\helpers\Url::to(['/shop/backend-addons/ajax-search-addons']), 'additional' => ['placeholder' => Yii::t('app', 'Search addons...')]]); ?> <div class="addons-widget"> <?php echo AddonsListWidget::widget(['object_id' => $object->id, 'object_model_id' => $model->id, 'bindedAddons' => $bindedAddons]); ?> </div> <?php BackendWidget::end(); $url = \yii\helpers\Json::encode(Url::to(['/shop/backend-addons/add-addon-binding', 'object_id' => $object->id, 'object_model_id' => $model->id])); $reorderUrl = \yii\helpers\Json::encode(Url::to(['/shop/backend-addons/reorder', 'object_id' => $object->id, 'object_model_id' => $model->id])); $js = <<<JS \$("#addaddonmodel-addon_id").on('change', function(){ var val = \$(this).val(); if (val === '' || val === '0') { return;
echo \app\backend\components\Helper::saveButtons($model); $this->endBlock(); ?> <section id="widget-grid"> <div class="row"> <article class="col-xs-12 col-sm-6 col-md-6 col-lg-6"> <?php BackendWidget::begin(['title' => Yii::t('app', 'Addon'), 'icon' => 'cart-plus', 'footer' => $this->blocks['submit']]); ?> <?php echo \app\backend\widgets\Select2Ajax::widget(['initialData' => $model->is_product_id > 0 ? [$model->is_product_id => \app\modules\shop\models\Product::findById($model->is_product_id)->name] : [], 'form' => $form, 'model' => $model, 'modelAttribute' => 'is_product_id', 'multiple' => false, 'searchUrl' => '/shop/backend-product/ajax-related-product', 'additional' => ['placeholder' => 'Поиск продуктов ...']]); ?> <?php echo $form->field($model, 'name'); ?> <?php echo $form->field($model, 'price', ['addon' => ['append' => ['content' => Html::activeDropDownList($model, 'currency_id', app\modules\shop\models\Currency::getSelection())]]]); ?> <?php echo $form->field($model, 'price_is_multiplier')->widget(\kartik\switchinput\SwitchInput::className()); ?> <?php
return { search: {term:term.term, object:$('select#review-object_id').val()} }; } JSCODE; $_jsTemplateResultFunc = <<<'JSCODE' function (data) { if (data.loading) return data.text; var tpl = '<div class="s2object-result">' + '<strong>' + (data.name || '') + '</strong>' + '<a href="' + (data.url || '#') + '">ссылка</a>' + '</div>'; return tpl; } JSCODE; echo \app\backend\widgets\Select2Ajax::widget(['initialData' => null !== $review->targetObjectModel ? [[$review->targetObjectModel->id => $review->targetObjectModel->name]] : [], 'form' => $form, 'model' => $review, 'modelAttribute' => 'object_model_id', 'multiple' => false, 'searchUrl' => \yii\helpers\Url::to(['ajax-search']), 'additional' => ['placeholder' => 'Поиск ...'], 'pluginOptions' => ['escapeMarkup' => new \yii\web\JsExpression('function (markup) {return markup;}'), 'templateResult' => new \yii\web\JsExpression($_jsTemplateResultFunc), 'templateSelection' => new \yii\web\JsExpression('function (data) {return data.name || data.text;}'), 'ajax' => ['data' => new \yii\web\JsExpression($_jsDataFunc), 'delay' => 500]]]); ?> <?php echo $form->field($review, 'author_email'); ?> <?php echo $form->field($review, 'review_text')->widget(Yii::$app->getModule('core')->wysiwyg_class_name(), Yii::$app->getModule('core')->wysiwyg_params()); ?> <?php echo $form->field($review, 'status')->dropDownList(Review::getStatuses()); ?> <?php BackendWidget::end(); ?> </article>