public function __construct() { | public function __construct() { | ||||
parent::__construct() ; | parent::__construct() ; | ||||
$dirJquery = 'js/jquery-ui-1.12.1.custom'; | |||||
$dirSelect2 = 'js/select2-4.0.13'; | |||||
// css | // css | ||||
$this->addAsset('css','js/jquery-ui-1.12.1.custom/jquery-ui.min.css'); | |||||
$this->addAsset('css','js/jquery-ui-1.12.1.custom/jquery-ui.theme.min.css') ; | |||||
$this->addAsset('css',$dirJquery.'/jquery-ui.min.css'); | |||||
$this->addAsset('css',$dirJquery.'/jquery-ui.theme.min.css') ; | |||||
$this->addAsset('css',$dirSelect2.'/css/select2.min.css') ; | |||||
$this->addAsset('css','css/site.css') ; | $this->addAsset('css','css/site.css') ; | ||||
$this->addAsset('css','css/screen.css') ; | $this->addAsset('css','css/screen.css') ; | ||||
// js | // js | ||||
$this->addAsset('js','js/jquery-ui-1.12.1.custom/jquery-ui.min.js') ; | |||||
$this->addAsset('js',$dirJquery.'/jquery-ui.min.js') ; | |||||
$this->addAsset('js',$dirSelect2.'/js/select2.min.js') ; | |||||
$this->addAsset('js','js/backend.js') ; | $this->addAsset('js','js/backend.js') ; | ||||
} | } | ||||
} | } |
</div> | </div> | ||||
<div class="panel-body"> | <div class="panel-body"> | ||||
<?php $form = ActiveForm::begin(); ?> | <?php $form = ActiveForm::begin(); ?> | ||||
<?= $form->field($modelAccessUserProducerForm, 'id_user') | |||||
->dropDownList(ArrayHelper::map($usersArray, 'id', function($model) { return $model->lastname.' '.$model->name; })) | |||||
->label(''); ?> | |||||
<?= $form->field($modelAccessUserProducerForm, 'id_user')->dropDownList(User::populateDropdownList(), ['class' => 'select2'])->label(''); ?> | |||||
<?= Html::submitButton('Ajouter', ['class' => 'btn btn-success']) ?> | <?= Html::submitButton('Ajouter', ['class' => 'btn btn-success']) ?> | ||||
<?php ActiveForm::end(); ?> | <?php ActiveForm::end(); ?> | ||||
</div> | </div> |
<label class="control-label" for="select-id-user"> | <label class="control-label" for="select-id-user"> | ||||
Utilisateur | Utilisateur | ||||
</label> | </label> | ||||
<select class="form-control" v-model="order.id_user" @change="userChange"> | |||||
<select class="form-control select2-order-form" v-model="order.id_user" @change="userChange"> | |||||
<option value="0">--</option> | <option value="0">--</option> | ||||
<option v-for="user in users" :value="user.id_user"> | <option v-for="user in users" :value="user.id_user"> | ||||
<template v-if="user.name_legal_person && user.name_legal_person.length"> | <template v-if="user.name_legal_person && user.name_legal_person.length"> |
'template' => '{label} <div>{input}</div>' . $model->user->getUsername(), | 'template' => '{label} <div>{input}</div>' . $model->user->getUsername(), | ||||
])->hiddenInput(); ?> | ])->hiddenInput(); ?> | ||||
<?php else: ?> | <?php else: ?> | ||||
<?php | |||||
$usersArray = User::findBy()->orderBy('type DESC, name_legal_person ASC, lastname ASC, name ASC')->all(); | |||||
?> | |||||
<?= $form->field($model, 'id_user', [ | <?= $form->field($model, 'id_user', [ | ||||
'template' => '{label} <a href="' . Yii::$app->urlManager->createUrl(['user/create']) . '" class="btn btn-xs btn-default">Nouvel utilisateur <span class="glyphicon glyphicon-plus"></span></a><div>{input}</div>{hint}', | 'template' => '{label} <a href="' . Yii::$app->urlManager->createUrl(['user/create']) . '" class="btn btn-xs btn-default">Nouvel utilisateur <span class="glyphicon glyphicon-plus"></span></a><div>{input}</div>{hint}', | ||||
]) | ]) | ||||
->dropDownList( | ->dropDownList( | ||||
ArrayHelper::map($usersArray, 'user_id', function ($model) { | |||||
if (isset($model['name_legal_person']) && strlen($model['name_legal_person'])) { | |||||
return 'Personne morale / ' . $model['name_legal_person']; | |||||
} else { | |||||
return $model['lastname'] . ' ' . $model['name']; | |||||
} | |||||
}), | |||||
User::populateDropdownList(), | |||||
[ | [ | ||||
'@change' => 'changeUser', | '@change' => 'changeUser', | ||||
'prompt' => '--', | |||||
'v-model' => 'idUser', | 'v-model' => 'idUser', | ||||
'class' => 'select2' | |||||
] | ] | ||||
); ?> | ); ?> | ||||
<?php endif; ?> | <?php endif; ?> |
<?= $form->field($model, 'id_user', [ | <?= $form->field($model, 'id_user', [ | ||||
'template' => '{label} <a href="' . Yii::$app->urlManager->createUrl(['user/create']) . '" class="btn btn-xs btn-default">Nouvel utilisateur <span class="glyphicon glyphicon-plus"></span></a><div>{input}</div>{hint}', | 'template' => '{label} <a href="' . Yii::$app->urlManager->createUrl(['user/create']) . '" class="btn btn-xs btn-default">Nouvel utilisateur <span class="glyphicon glyphicon-plus"></span></a><div>{input}</div>{hint}', | ||||
]) | ]) | ||||
->dropDownList( | |||||
ArrayHelper::map(User::findBy()->orderBy('type DESC')->all(), 'user_id', function ($model) { | |||||
if(strlen($model['name_legal_person'])) { | |||||
return 'Personne morale / '.$model['name_legal_person'] ; | |||||
} | |||||
else { | |||||
return $model['lastname'] . ' ' . $model['name']; | |||||
} | |||||
}), | |||||
[ | |||||
'prompt' => '--', | |||||
] | |||||
)->hint('Utilisé lors de la facturation'); ?> | |||||
->dropDownList(User::populateDropdownList(), ['class' => 'select2']) | |||||
->hint('Utilisé lors de la facturation'); ?> | |||||
<?php | <?php | ||||
$addHintCredit = ''; | $addHintCredit = ''; |
<?= $form->field($model, 'id')->hiddenInput() ?> | <?= $form->field($model, 'id')->hiddenInput() ?> | ||||
<?php endif; ?> | <?php endif; ?> | ||||
<div class="col-md-5" id="bloc-select-user"> | <div class="col-md-5" id="bloc-select-user"> | ||||
<?= $form->field($model, 'id_user')->dropDownList( ArrayHelper::map(User::find()->joinWith('userProducer')->where('user_producer.id_producer = '.GlobalParam::getCurrentProducerId())->andWhere('user_producer.active = 1')->orderBy('lastname ASC, name ASC')->all(), 'id', function($model, $defaultValue) { | |||||
if (isset($model['name_legal_person']) && strlen($model['name_legal_person'])) { | |||||
return 'Personne morale / '.$model['name_legal_person']; | |||||
} else { | |||||
return $model['lastname'] . ' ' . $model['name']; | |||||
} | |||||
}), ['prompt' => '--','class' => 'form-control user-id', ]) ?> | |||||
<?= $form->field($model, 'id_user')->dropDownList(User::populateDropdownList(), ['class' => 'select2']); ?> | |||||
</div> | </div> | ||||
<div class="col-md-1" id="or-user"> | <div class="col-md-1" id="or-user"> | ||||
<span>OU</span> | <span>OU</span> |