Browse Source

Modification d'un document : figer l'utilisateur #166

refactoring
Guillaume Bourgeois 4 years ago
parent
commit
0077612481
1 changed files with 30 additions and 19 deletions
  1. +30
    -19
      backend/views/document/_form.php

+ 30
- 19
backend/views/document/_form.php View File

@@ -63,25 +63,36 @@ use common\models\Producer;
<?= Html::hiddenInput('idDocument',$model->id, ['id' => 'id-document']) ?>
<?php endif; ?>
<?= $form->field($model, 'name')->label('Nom du document') ?>
<?php $usersArray = User::findBy()->all(); ?>
<?= $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}',
])
->dropDownList(
ArrayHelper::map($usersArray, 'user_id', function ($model) {
if(isset($model['name_legal_person']) && strlen($model['name_legal_person'])) {
return $model['name_legal_person'] ;
}
else {
return $model['lastname'] . ' ' . $model['name'];
}
}),
[
'@change' => 'changeUser',
'prompt' => '--',
'v-model' => 'idUser',
]
); ?>

<?php if($action == 'update'): ?>
<?= $form->field($model, 'id_user', [
'template' => '{label} <div>{input}</div>'.$model->user->getUsername(),
])->hiddenInput(); ?>
<?php else: ?>
<?php
$usersArray = User::findBy()->all();
?>
<?= $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}',
])
->dropDownList(
ArrayHelper::map($usersArray, 'user_id', function ($model) {
if(isset($model['name_legal_person']) && strlen($model['name_legal_person'])) {
return $model['name_legal_person'] ;
}
else {
return $model['lastname'] . ' ' . $model['name'];
}
}),
[
'@change' => 'changeUser',
'prompt' => '--',
'v-model' => 'idUser',
]
); ?>
<?php endif; ?>


<?= $form->field($model, 'address')->textarea(['rows' => 2, 'v-model' => 'document.address']) ?>
<?php if ($action == 'update'): ?>
<?= $form->field($model, 'comment')->textarea(['rows' => 2])->hint('Affiché en bas de la facture') ?>

Loading…
Cancel
Save