user.php 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. <?php /** Created by Anton on 03.03.2020. */
  2. use app\models\entity\Accounts;
  3. use app\models\entity\Log;
  4. use app\models\entity\Tmc;
  5. use app\models\entity\TmcStatus;
  6. use app\models\entity\TmcType;
  7. use app\models\entity\UserDevice;
  8. use yii\db\Query;
  9. require '../yiiInit.php';
  10. $user = Accounts::findOne((int)$_GET['id']);
  11. $query = new Query();
  12. $query->select('ts.title as status, tt.title as type, t.receipt_date, tl.issue_date, t.id as tmc')
  13. ->from(Tmc::tableName() . ' t')
  14. ->leftJoin(TmcType::tableName() . ' tt', 'tt.id = t.tmc_type')
  15. ->leftJoin(TmcStatus::tableName() . ' ts', 'ts.id = t.status')
  16. ->leftJoin(UserDevice::tableName() . ' tud', 'tud.employee = t.employee')
  17. ->leftJoin(Log::tableName() . ' tl', 'tl.id = tud.camera or tl.id = tud.oil_meter or tl.id = tud.phone')
  18. ->where(['t.employee' => $user->id])
  19. ->groupBy('t.id')
  20. ;
  21. $devices = $query->all();
  22. ?>
  23. <!doctype html>
  24. <html lang="ru">
  25. <head>
  26. <meta charset="UTF-8">
  27. <meta name="viewport"
  28. content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
  29. <meta http-equiv="X-UA-Compatible" content="ie=edge">
  30. <link rel="stylesheet" href="../../ProSysNew/bootstrap.css">
  31. <title>Пользователь <?= $user->id ?></title>
  32. </head>
  33. <body>
  34. <div class="container" style="max-width: 400px">
  35. <h3 class="text-center"><?= $user['name'] ?></h3>
  36. <?php foreach ($devices as $device): ?>
  37. <table class="table text-center">
  38. <thead>
  39. <tr>
  40. <td colspan="2">
  41. <h4><?= $device['type'] ?></h4>
  42. </td>
  43. </tr>
  44. </thead>
  45. <tr>
  46. <td>ID</td>
  47. <td><?= $device['tmc'] ?></td>
  48. </tr>
  49. <tr>
  50. <td>Статус</td>
  51. <td><?= $device['status'] ?></td>
  52. </tr>
  53. <tr>
  54. <td>Дата выдачи</td>
  55. <td><?= $device['issue_date'] ?></td>
  56. </tr>
  57. <?php endforeach; ?>
  58. </div>
  59. </body>
  60. </html>