Guest User

Untitled

a guest
Oct 16th, 2017
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.89 KB | None | 0 0
  1. <?php
  2.  
  3. use yii\helpers\Html;
  4. use yii\widgets\DetailView;
  5. use yii\grid\GridView;
  6. use yii\bootstrap\Modal;
  7. use yii\helpers\Url;
  8. use yii\widgets\Pjax;
  9. use common\models\RecordHelpers;
  10.  
  11. /* @var $this yii\web\View */
  12. /* @var $model frontend\models\Project */
  13.  
  14. $this->title = $model->name;
  15. $this->params['breadcrumbs'][] = ['label' => 'Projects', 'url' => ['index']];
  16. $this->params['breadcrumbs'][] = $this->title;
  17. ?>
  18. <div class="project-view">
  19.  
  20. <h1><?= Html::encode($this->title) ?></h1>
  21.  
  22. <p>
  23. <?= Html::a('Update', ['update', 'id' => $model->id], ['class' => 'btn btn-primary']) ?>
  24. <?= Html::a('Delete', ['delete', 'id' => $model->id], [
  25. 'class' => 'btn btn-danger',
  26. 'data' => [
  27. 'confirm' => 'Are you sure you want to delete this item?',
  28. 'method' => 'post',
  29. ],
  30. ]) ?>
  31. <?= Html::a('Assign User', ['project-user/create', 'project_id' => $model->id], ['class' => 'btn btn-info']) ?>
  32. </p>
  33.  
  34. <?= DetailView::widget([
  35. 'model' => $model,
  36. 'attributes' => [
  37. //'id',
  38. 'name',
  39. 'description:ntext',
  40. 'created_at',
  41. 'updated_at',
  42. [
  43. 'label' => 'Created By',
  44. 'value' => RecordHelpers::getUserName($model->created_by)
  45. ],
  46. [
  47. 'label' => 'Updated By',
  48. 'value' => RecordHelpers::getUserName($model->updated_by)
  49. ],
  50. ],
  51. ]) ?>
  52.  
  53. <?= Html::a('Create Task', '#', [
  54. 'id' => 'activity-index-link',
  55. 'class' => 'btn btn-success',
  56. 'data-toggle' => 'modal',
  57. 'data-target' => '#modal',
  58. 'data-url' => Url::to(['task/create?project_id='.$model->id]),
  59. 'data-pjax' => '0',
  60. ]); ?>
  61.  
  62. <?php Pjax::begin() ?>
  63. <?= GridView::widget([
  64. 'dataProvider' => $dataProvider,
  65. 'filterModel' => $searchModel,
  66. 'id' => 'task-grid',
  67. 'columns' => [
  68. ['class' => 'yii\grid\SerialColumn'],
  69.  
  70. //'id',
  71. 'name',
  72. 'description:ntext',
  73. [
  74. 'attribute' => 'statusDescription',
  75. 'filter' => $searchModel->getStatusesList()
  76. ],
  77. [
  78. 'attribute' => 'ownerName',
  79. ],
  80. [
  81. 'attribute' => 'requesterName',
  82. ],
  83. // 'created_at',
  84. // 'updated_at',
  85. // 'created_by',
  86. // 'updated_by',
  87.  
  88. [
  89. 'class' => 'yii\grid\ActionColumn',
  90. 'template' => '{view}{update}{delete}',
  91. 'controller' => 'task',
  92. 'buttons' => [
  93. 'view' => function ($url, $model, $key) {
  94. return Html::a('<span class="glyphicon glyphicon-eye-open"></span>', '#', [
  95. 'id' => 'activity-index-link',
  96. 'title' => Yii::t('app', 'View'),
  97. 'data-toggle' => 'modal',
  98. 'data-target' => '#modal',
  99. 'data-url' => Url::to(['task/view', 'id' => $model->id]),
  100. 'data-pjax' => '0',
  101. ]);
  102. },
  103. 'update' => function ($url, $model, $key) {
  104. return Html::a('<span class="glyphicon glyphicon-pencil"></span>', '#', [
  105. 'id' => 'activity-index-link',
  106. 'title' => Yii::t('app', 'Update'),
  107. 'data-toggle' => 'modal',
  108. 'data-target' => '#modal',
  109. 'data-url' => Url::to(['task/update', 'id' => $model->id]),
  110. 'data-pjax' => '0',
  111. ]);
  112. },
  113. 'delete' => function ($url, $model, $key)
  114. {
  115. return Html::a('<span class="glyphicon glyphicon-trash"></span>', $url, [
  116. 'title' => Yii::t('yii', 'Delete'),
  117. 'data-confirm' => Yii::t('yii', 'Are you sure you want to delete this item?'),
  118. 'data-method' => 'post',
  119. ]);
  120. },
  121. ]
  122. ],
  123. ],
  124. ]); ?>
  125. <?php Pjax::end() ?>
  126.  
  127. <?php
  128. $this->registerJs(
  129. "$(document).on('click', '#activity-index-link', (function() {
  130. $.get(
  131. $(this).data('url'),
  132. function (data) {
  133. $('.modal-body').html(data);
  134. $('#modal').modal();
  135. }
  136. );
  137. }));"
  138. ); ?>
  139.  
  140. <?php
  141. Modal::begin([
  142. 'id' => 'modal',
  143. 'header' => '<h4 class="modal-title">Complete</h4>',
  144. 'footer' => '<a href="#" class="btn btn-primary" data-dismiss="modal">Cerrar</a>',
  145. ]);
  146.  
  147. echo "<div class='well'></div>";
  148.  
  149. Modal::end();
  150. ?>
  151.  
  152. </div>
Add Comment
Please, Sign In to add comment