Example #1
0
        if (data.cards[e.id]) {
            e.card = data.cards[e.id];
        }
        return e;
    })};
}
JSCODE;
echo \app\backend\widgets\Select2Ajax::widget(['initialData' => [$model->customer_id => null !== $model->customer ? $model->customer->first_name : 'New customer'], 'model' => $model, 'modelAttribute' => 'customer_id', 'form' => $form, 'multiple' => false, 'searchUrl' => \yii\helpers\Url::toRoute(['ajax-customer', 'template' => 'simple']), 'pluginOptions' => ['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)]]]);
?>
        <?php 
echo Html::tag('div', Html::a(Yii::t('app', 'Create customer'), Url::toRoute(['/shop/backend-customer/create']), ['target' => '_blank', 'class' => 'btn btn-xs btn-info new_customer']) . Html::a(Yii::t('app', 'Edit customer'), Url::toRoute(['/shop/backend-customer/index']), ['target' => '_blank', 'class' => 'btn btn-xs btn-info edit_customer']), ['class' => 'btn-group col-md-offset-2']);
?>
        <hr />
        <div id="div_customer">
        <?php 
echo \app\modules\shop\widgets\Customer::widget(['viewFile' => 'customer/backend_list', 'model' => $model->customer]);
?>
        </div>
        <?php 
BackendWidget::end();
?>

        <?php 
BackendWidget::begin(['icon' => 'user', 'title' => Yii::t('app', 'Contragent')]);
?>
        <?php 
$_jsTemplateResultFunc = <<<'JSCODE'
function (data) {
    if (data.loading) return data.text;
    var tpl = '<div class="s2contragent-result">' +
        '<strong>' + (data.type || '') + '</strong>' +
 /**
  * @return array
  */
 public function actionAjaxCustomer($template = null)
 {
     \Yii::$app->response->format = \yii\web\Response::FORMAT_JSON;
     $result = ['more' => false, 'results' => []];
     $search = \Yii::$app->request->get('search', []);
     $user_id = isset($search['user']) && User::USER_GUEST !== intval($search['user']) ? intval($search['user']) : User::USER_GUEST;
     if (!empty($search['term'])) {
         $query = Customer::find()->select('id, first_name, middle_name, last_name, email, phone')->where(['user_id' => $user_id])->andWhere('first_name LIKE :term1 OR middle_name LIKE :term2 OR last_name LIKE :term3 OR email LIKE :term4 OR phone LIKE :term5', [':term1' => '%' . trim($search['term']) . '%', ':term2' => '%' . trim($search['term']) . '%', ':term3' => '%' . trim($search['term']) . '%', ':term4' => '%' . trim($search['term']) . '%', ':term5' => '%' . trim($search['term']) . '%'])->asArray();
         $result['results'] = array_values($query->all());
     }
     if (!empty($result['results']) && 'simple' === $template) {
         $result['cards'] = array_reduce($result['results'], function ($result, $item) {
             /** @var array $item */
             $result[$item['id']] = \app\modules\shop\widgets\Customer::widget(['viewFile' => 'customer/backend_list', 'model' => Customer::findOne(['id' => $item['id']])]);
             return $result;
         }, []);
     }
     return $result;
 }
Example #3
0
<?php

/**
 * @var \yii\web\View $this
 */
if (Yii::$app->user->isGuest) {
    echo '<p>' . Yii::t('app', 'Please register to save your profile') . '</p>';
} else {
    $customer = null === \app\modules\shop\models\Customer::getCustomerByUserId(Yii::$app->user->id) ? \app\modules\shop\models\Customer::createEmptyCustomer(Yii::$app->user->id, false) : \app\modules\shop\models\Customer::getCustomerByUserId(Yii::$app->user->id);
    echo \app\modules\shop\widgets\Customer::widget(['viewFile' => 'customer/profile', 'model' => $customer, 'formAction' => \yii\helpers\Url::toRoute(['/shop/cabinet/update'], true)]);
}
        '<strong>' + (data.username || '') + '</strong>' +
        '<div>' + (data.first_name || '') + ' (' + (data.email || '') + ')</div>' +
        '</div>';
    return tpl;
}
JSCODE;
$_jsDataFunc = <<<'JSCODE'
function (term, page) {
    return {
        search: {term:term.term, user:$('select#order-user_id').val()}
    };
}
JSCODE;
echo \app\backend\widgets\Select2Ajax::widget(['initialData' => [$model->customer_id => null !== $model->customer ? $model->customer->first_name : 'New customer'], '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;}'), 'ajax' => ['data' => new \yii\web\JsExpression($_jsDataFunc)]]]);
echo Html::tag('div', Html::a(Yii::t('app', 'Clear'), '#clear', ['data-sel' => 'order-customer_id', 'class' => 'col-md-offset-2']));
echo Html::tag('div', \app\modules\shop\widgets\Customer::widget(['viewFile' => 'customer/inherit_form', 'form' => $form, 'model' => $customer = \app\modules\shop\models\Customer::createEmptyCustomer(0)]), ['id' => 'div_customer']);
?>
    </div>

    <div class="col-md-4">
<?php 
$_jsTemplateResultFunc = <<<'JSCODE'
function (data) {
    if (data.loading) return data.text;
    var tpl = '<div class="s2customer-result">' +
        '<strong>' + (data.type || '') + '</strong>' +
        '</div>';
    return tpl;
}
JSCODE;
$_jsDataFunc = <<<'JSCODE'
Example #5
0
    <?php 
echo $this->render('_items', ['model' => $order, 'items' => $order->items]);
?>

    <?php 
echo \app\modules\shop\widgets\OrderTransaction::widget(['model' => $order, 'immutable' => $orderIsImmutable]);
?>

    <?php 
$form = \yii\bootstrap\ActiveForm::begin(['id' => 'order-details-form', 'action' => \yii\helpers\Url::to(['/shop/cabinet/update-order', 'hash' => $order->hash]), 'layout' => 'horizontal']);
echo \yii\helpers\Html::hiddenInput('orderId', $order->id);
?>
<div class="panel panel-default">
    <div class="panel-body">
    <?php 
echo \app\modules\shop\widgets\Customer::widget(['viewFile' => 'customer/inherit_form', 'model' => $order->customer, 'form' => $form, 'immutable' => $orderIsImmutable]);
?>

    <?php 
echo \app\modules\shop\widgets\Contragent::widget(['viewFile' => 'contragent/inherit_form', 'model' => $order->contragent, 'form' => $form, 'immutable' => $orderIsImmutable]);
?>

    <?php 
echo \app\modules\shop\widgets\Delivery::widget(['viewFile' => 'delivery/inherit_form', 'deliveryInformation' => !empty($order->contragent) ? $order->contragent->deliveryInformation : null, 'orderDeliveryInformation' => $order->orderDeliveryInformation, 'form' => $form, 'immutable' => $orderIsImmutable]);
?>
    </div>
    <?php 
echo $orderIsImmutable ? '' : \yii\helpers\Html::tag('div', \yii\helpers\Html::submitButton(Yii::t('app', 'Save'), ['class' => 'btn btn-primary']), ['class' => 'panel-footer']);
?>
</div>
    <?php 
Example #6
0
        <div class="row">
<?php 
$form = \yii\bootstrap\ActiveForm::begin(['id' => 'customer-form', 'action' => \yii\helpers\Url::toRoute(['edit', 'id' => $model->id]), 'layout' => 'horizontal']);
BackendWidget::begin(['icon' => 'user', 'title' => Yii::t('app', 'Customer 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="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) {
Example #7
0
<?php

/**
 * @var \yii\web\View $this
 * @var \app\modules\shop\models\Customer $model
 */
use app\backend\widgets\BackendWidget;
$this->title = Yii::t('app', 'Customer edit');
$this->params['breadcrumbs'][] = ['label' => Yii::t('app', 'Customers'), 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;
$form = \yii\bootstrap\ActiveForm::begin(['id' => 'customer-form', 'action' => \yii\helpers\Url::toRoute(['create']), 'layout' => 'horizontal']);
BackendWidget::begin(['icon' => 'user', 'title' => Yii::t('app', 'Customer create'), '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="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]);
BackendWidget::end();
$form->end();