get_user_devices.php 1.2 KB

1234567891011121314151617181920212223242526272829303132333435
  1. <?php /** Created by Anton on 29.01.2020. */
  2. use yii\db\Query;
  3. use app\models\entity\UserDevice;
  4. use app\models\entity\Log;
  5. use app\models\entity\Tmc;
  6. require '../yiiInit.php';
  7. $userId = (int) Yii::$app->request->get('userId');
  8. $query = new Query();
  9. $query->select('tlog.tmc, tt.title as device, tlog.issue_date')
  10. ->from(UserDevice::tableName() . ' tud')
  11. ->leftJoin(Log::tableName() . ' tlog',
  12. 'tlog.id = tud.camera or tlog.id = tud.oil_meter or tlog.id = tud.phone')
  13. ->leftJoin(Tmc::tableName(). ' tt', 'tlog.tmc = tt.id')
  14. ->where(['tud.employee' => $userId])
  15. ;
  16. $devices = $query->all();
  17. foreach ($devices as $device): ?>
  18. <div style="display:flex">
  19. <div class="loco_grey" style="width:33.3%">
  20. <h5 style="padding-top: 18px;"><?= $device['device'] ?></h5>
  21. </div>
  22. <div class="loco_grey" style="width:33.3%; padding-top: 18px;">
  23. <?= $device['issue_date'] ?>
  24. </div>
  25. <div style="width:33.3%">
  26. <button type="submit" name="deviceId" class="" style="float:right" value="<?= $device['tmc'] ?>">
  27. Принять устройство
  28. </button>
  29. </div>
  30. </div>
  31. <? endforeach;