added.php 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. <?php /** Created by Anton on 06.03.2020. */
  2. $id = (int)$_GET['id'];
  3. $tmc = \app\models\entity\Tmc::findOne($id);
  4. $storage = \app\models\entity\Storage::findOne(['tmc' => $tmc->id]);
  5. function myQRcode($data, $matrixPointSize = 7, $errorCorrectionLevel = 'L')
  6. {
  7. $PNG_TEMP_DIR = 'temp' . DIRECTORY_SEPARATOR;
  8. $PNG_WEB_DIR = 'temp/';
  9. require "phpqrcode/qrlib.php";
  10. if (!file_exists($PNG_TEMP_DIR))
  11. mkdir($PNG_TEMP_DIR);
  12. if (in_array($errorCorrectionLevel, array('L', 'M', 'Q', 'H'))) {
  13. $matrixPointSize = min(max((int)$matrixPointSize, 1), 10);
  14. $data = intval($data);
  15. if ($data > 0) {
  16. $filename = $PNG_TEMP_DIR . $data . md5("tmc_inv_num|$data|$errorCorrectionLevel|$matrixPointSize") . '.png';
  17. QRcode::png("tmc_inv_$data", $filename, $errorCorrectionLevel, $matrixPointSize, 2);
  18. // QRcode::png("tmc_inv_$data", false, $errorCorrectionLevel, $matrixPointSize, 2);
  19. echo '<img src="' . $PNG_WEB_DIR . basename($filename) . '" /><br>';
  20. }
  21. }
  22. }
  23. ?>
  24. <div class="divContentScroll loco-scrol-blue">
  25. <div id="contentBox" class="contentBox">
  26. <p class="crumbs">Список устройств</p>
  27. <h2 class="contentHeader">Детали устройства</h2>
  28. <form action="/tmc/api/add_tmc.php" method="post">
  29. <fieldset>
  30. <?php
  31. myQRcode($tmc->inventory_num);
  32. ?>
  33. Вид устройства:
  34. <label class="info"><?= explode(' ', $tmc->title)[0] ?></label>
  35. <br clear="all">
  36. Инвентарный номер:
  37. <br>
  38. <label class="info"><?= $tmc->inventory_num ?></label>
  39. <br>
  40. <?php if ($tmc->ip): ?>
  41. IP:
  42. <br>
  43. <label class="info"><?= $tmc->ip ?></label>
  44. <br>
  45. <?php endif; ?>
  46. <?php if ($tmc->mac): ?>
  47. MAC-адрес:
  48. <br>
  49. <label class="info"><?= $tmc->mac ?></label>
  50. <br>
  51. <?php endif; ?>
  52. <?php if ($storage->title): ?>
  53. Место хранения:
  54. <label class="info" ><?= $storage->title ?></label>
  55. <br clear="all">
  56. <?php endif; ?>
  57. <?php if ($tmc->desc): ?>
  58. Примечание:<br>
  59. <textarea name="desc" disabled><?= $tmc->desc ?></textarea>
  60. <?php endif; ?>
  61. </fieldset>
  62. </form>
  63. </div>
  64. </div>
  65. <style>
  66. form {
  67. min-width: 350px;
  68. }
  69. .info {
  70. height: 50px;
  71. /*border: 1px solid #000;*/
  72. /*border-radius: 3px;*/
  73. /*border-color: #D1D1D1;*/
  74. font: bold 18px/22px "Neue Haas Unica W1G";
  75. padding: 12px 0;
  76. }
  77. form textarea {
  78. border: 0;
  79. }
  80. </style>