switch.php 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. <?php
  2. use yii\bootstrap\ActiveForm;
  3. use yii\bootstrap\Html;
  4. use yii\debug\UserswitchAsset;
  5. use yii\grid\GridView;
  6. /* @var $this \yii\web\View */
  7. /* @var $panel yii\debug\panels\UserPanel */
  8. UserswitchAsset::register($this);
  9. echo '<h2>Switch user</h2>';
  10. ?>
  11. <div class="row">
  12. <div class="col-sm-7">
  13. <?php $formSet = ActiveForm::begin([
  14. 'action' => \yii\helpers\Url::to(['user/set-identity']),
  15. 'layout' => 'horizontal',
  16. 'options' => [
  17. 'id' => 'debug-userswitch__set-identity',
  18. 'style' => $panel->canSearchUsers() ? 'display:none' : ''
  19. ]
  20. ]);
  21. echo $formSet->field(
  22. $panel->userSwitch,
  23. 'user[id]', ['options' => ['class' => '']])
  24. ->textInput(['id' => 'user_id', 'name' => 'user_id'])
  25. ->label('Switch User');
  26. echo Html::submitButton('Switch', ['class' => 'btn btn-primary']);
  27. ActiveForm::end();
  28. ?>
  29. </div>
  30. <div class="col-sm-5">
  31. <?php
  32. if (!$panel->userSwitch->isMainUser()) {
  33. $formReset = ActiveForm::begin([
  34. 'action' => \yii\helpers\Url::to(['user/reset-identity']),
  35. 'options' => [
  36. 'id' => 'debug-userswitch__reset-identity',
  37. ]
  38. ]);
  39. echo Html::submitButton('Reset to <span class="yii-debug-toolbar__label yii-debug-toolbar__label_info">' .
  40. $panel->userSwitch->getMainUser()->getId() .
  41. '</span>', ['class' => 'btn btn-default']);
  42. ActiveForm::end();
  43. }
  44. ?>
  45. </div>
  46. </div>
  47. <?php
  48. if ($panel->canSearchUsers()) {
  49. \yii\widgets\Pjax::begin(['id' => 'debug-userswitch__filter', 'timeout' => false]);
  50. echo GridView::widget([
  51. 'dataProvider' => $panel->getUserDataProvider(),
  52. 'filterModel' => $panel->getUsersFilterModel(),
  53. 'tableOptions' => [
  54. 'class' => 'table table-bordered table-responsive table-hover table-pointer'
  55. ],
  56. 'columns' => $panel->filterColumns
  57. ]);
  58. \yii\widgets\Pjax::end();
  59. }