コード例 #1
0
 /**
  * @return string
  * @throws \yii\web\ServerErrorHttpException
  */
 public function actionIndex()
 {
     $searchModelConfig = ['model' => Contragent::className(), 'additionalConditions' => []];
     /** @var SearchModel $searchModel */
     $searchModel = new SearchModel($searchModelConfig);
     $dataProvider = $searchModel->search(\Yii::$app->request->queryParams);
     return $this->render('index', ['dataProvider' => $dataProvider, 'searchModel' => $searchModel]);
 }
コード例 #2
0
ファイル: Order.php プロジェクト: tqsq2005/dotplant2
 public function getContragent()
 {
     return $this->hasOne(Contragent::className(), ['id' => 'contragent_id']);
 }
コード例 #3
0
ファイル: Customer.php プロジェクト: tqsq2005/dotplant2
 /**
  * @return Contragent|null
  */
 public function getContragent()
 {
     return $this->hasOne(Contragent::className(), ['customer_id' => 'id'])->orderBy(['id' => SORT_ASC]);
 }
コード例 #4
0
ファイル: edit.php プロジェクト: tqsq2005/dotplant2
function (data) {
    if (data.loading) return data.text;
    var tpl = '<div class="s2customer-result">' +
        '<strong>' + (data.username || '') + '</strong>' +
        '<div>' + (data.first_name || '') + ' (' + (data.email || '') + ')</div>' +
        '</div>';
    return tpl;
}
JSCODE;
echo \app\backend\widgets\Select2Ajax::widget(['initialData' => [$model->user_id => null !== $model->user ? $model->user->username : '******'], 'model' => $model, 'modelAttribute' => 'user_id', 'form' => $form, 'multiple' => false, 'searchUrl' => \yii\helpers\Url::toRoute(['ajax-user']), '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.username || data.text;}')]]);
echo \app\modules\shop\widgets\Customer::widget(['viewFile' => 'customer/inherit_form', 'form' => $form, 'model' => $model, 'additional' => ['hideHeader' => true]]);
BackendWidget::end();
$form->end();
/*******  CONTRAGENTS LIST  *******/
echo Html::a('', '#', ['name' => 'contragents']);
$searchModelConfig = ['model' => \app\modules\shop\models\Contragent::className(), 'additionalConditions' => [['customer_id' => $model->id]]];
/** @var \app\components\SearchModel $searchModel */
$searchModel = new \app\components\SearchModel($searchModelConfig);
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
echo \kartik\dynagrid\DynaGrid::widget(['options' => ['id' => 'contragents-index-grid'], 'theme' => 'panel-default', 'gridOptions' => ['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'hover' => true, 'panel' => ['heading' => Html::tag('h3', $this->title, ['class' => 'panel-title']), 'after' => Html::a(\kartik\icons\Icon::show('plus') . Yii::t('app', 'Add'), ['/shop/backend-contragent/create', 'customer' => $model->id, 'returnUrl' => \app\backend\components\Helper::getReturnUrl()], ['class' => 'btn btn-success'])], 'rowOptions' => function ($model, $key, $index, $grid) {
    /** @var \app\modules\shop\models\Contragent $model */
    if (null === $model->customer) {
        return ['class' => 'danger'];
    }
    return [];
}], 'columns' => ['id', 'type', ['label' => Yii::t('app', 'Additional information'), 'value' => function ($model, $key, $index, $column) {
    /** @var \app\modules\shop\models\Contragent $contragent */
    /** @var \app\properties\AbstractModel $abstractModel */
    $abstractModel = $model->getAbstractModel();
    $abstractModel->setArrayMode(false);
    $props = '';