You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

index.php 2.9KB

8 years ago
8 years ago
8 years ago
8 years ago
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. <?php
  2. use yii\helpers\Html;
  3. use yii\grid\GridView;
  4. use common\models\User ;
  5. /* @var $this yii\web\View */
  6. /* @var $dataProvider yii\data\ActiveDataProvider */
  7. $this->title = 'Utilisateurs';
  8. $this->params['breadcrumbs'][] = $this->title;
  9. ?>
  10. <div class="user-index">
  11. <h1>
  12. <?= Html::encode($this->title) ?>
  13. <?= Html::a('Ajouter', ['create'], ['class' => 'btn btn-primary']) ?>
  14. <?= Html::a('<span class="glyphicon glyphicon-envelope"></span> Liste des emails', ['mail'], ['class' => 'btn btn-default']) ?>
  15. </h1>
  16. <?= GridView::widget([
  17. 'dataProvider' => $dataProvider,
  18. 'columns' => [
  19. 'nom',
  20. 'prenom',
  21. 'telephone',
  22. 'email',
  23. [
  24. 'attribute' => 'credit',
  25. 'format' => 'raw',
  26. 'value' => function($model) use($etablissement) {
  27. $html = '<div class="input-group">
  28. <input type="text" class="form-control input-credit" readonly="readonly" value="'.number_format($model['credit'],2).' €" placeholder="">
  29. <span class="input-group-btn">
  30. '.Html::a(
  31. '<span class="glyphicon glyphicon-euro"></span> Crédit',
  32. Yii::$app->urlManager->createUrl(['user/credit','id' => $model['id']]),
  33. [
  34. 'title' => 'Crédit',
  35. 'class' => 'btn btn-default'
  36. ]
  37. ).'
  38. </span>
  39. </div>' ;
  40. return $html ;
  41. }
  42. ],
  43. [
  44. 'class' => 'yii\grid\ActionColumn',
  45. 'template' => '{update}',
  46. 'headerOptions' => ['class' => 'actions'],
  47. 'buttons' => [
  48. 'update' => function ($url, $model) {
  49. $url = Yii::$app->urlManager->createUrl(['user/update','id' => $model['id']]) ;
  50. $user = User::find()->with('userEtablissement')->where(['id' => $model['id']])->one() ;
  51. if(count($user->userEtablissement) <= 1)
  52. {
  53. return Html::a('<span class="glyphicon glyphicon-pencil"></span> Modifier', $url, [
  54. 'title' => Yii::t('app', 'Modifier'), 'class' => 'btn btn-default'
  55. ]);
  56. }
  57. else {
  58. return '<span data-toggle="tooltip" data-placement="top" title="Vous ne pouvez pas modifier les utilisateurs qui appartiennent à plusieurs boulangeries."><span class="glyphicon glyphicon-remove-sign"></span> Non modifiable</span>' ;
  59. }
  60. },
  61. ],
  62. ],
  63. ],
  64. ]); ?>
  65. </div>