Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.

index.php 4.0KB

8 lat temu
8 lat temu
8 lat temu
8 lat temu
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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) {
  27. $html = $model['credit'].' € ' ;
  28. $html = '<div class="input-group">
  29. <input type="text" class="form-control input-credit" readonly="readonly" value="'.$model['credit'].' €" placeholder="">
  30. <span class="input-group-btn">
  31. '.Html::a(
  32. '<span class="glyphicon glyphicon-euro"></span> Crédit',
  33. Yii::$app->urlManager->createUrl(['user/credit','id' => $model['id']]),
  34. [
  35. 'title' => 'Crédit',
  36. 'class' => 'btn btn-default'
  37. ]
  38. ).'
  39. </span>
  40. </div>' ;
  41. /*$html = '<div class="btn-group" role="group" aria-label="">
  42. <input type="text" readonly="readonly" class="btn btn-default">'.$model['credit'].' € </button>
  43. '.Html::a(
  44. '<span class="glyphicon glyphicon-euro"></span> Créditer',
  45. Yii::$app->urlManager->createUrl(['user/credit','id' => $model['id']]),
  46. [
  47. 'title' => 'Créditer',
  48. 'class' => 'btn btn-default'
  49. ]
  50. ).'
  51. </div>' ;*/
  52. /*$html .= Html::a(
  53. '<span class="glyphicon glyphicon-euro"></span> Créditer',
  54. Yii::$app->urlManager->createUrl(['user/credit','id' => $model['id']]),
  55. [
  56. 'title' => 'Créditer',
  57. 'class' => 'btn btn-default btn-xs'
  58. ]
  59. ) ;*/
  60. return $html ;
  61. }
  62. ],
  63. [
  64. 'class' => 'yii\grid\ActionColumn',
  65. 'template' => '{update}',
  66. 'headerOptions' => ['class' => 'actions'],
  67. 'buttons' => [
  68. 'update' => function ($url, $model) {
  69. $url = Yii::$app->urlManager->createUrl(['user/update','id' => $model['id']]) ;
  70. $user = User::find()->with('userEtablissement')->where(['id' => $model['id']])->one() ;
  71. if(count($user->userEtablissement) == 1)
  72. {
  73. return Html::a('<span class="glyphicon glyphicon-pencil"></span> Modifier', $url, [
  74. 'title' => Yii::t('app', 'Modifier'), 'class' => 'btn btn-default'
  75. ]);
  76. }
  77. else {
  78. 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>' ;
  79. }
  80. },
  81. ],
  82. ],
  83. ],
  84. ]); ?>
  85. </div>