asusg_dayplan.php 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. <?php
  2. $str = "select * from asusg_dayplan where company=$companyID and day >= cast((now() - interval 0 day) as date)";
  3. $query = mysqli_query($link, $str);
  4. while ($res = mysqli_fetch_object($query))
  5. {
  6. $dayplans[] = $res;
  7. }
  8. ?>
  9. <form onsubmit="return false;">
  10. <div class="activity">
  11. <input type="text" id="datepicker" value="Выберите дату">
  12. <input type="hidden" id="company" value="<?= $companyID ?>">
  13. <input id="loco_number" type="number" min="1" placeholder="Номер локомотива">
  14. <input id="priority" type="number" min="0" placeholder="Приоритет (целое число)">
  15. <select id="letter">
  16. <option><Выберите букву секции></option>
  17. <option value="А">А</option>
  18. <option value="Б">Б</option>
  19. <option value="В">В</option>
  20. </select>
  21. <button id="add">Добавить</button>
  22. </div>
  23. <div class="dayplans">
  24. <select name="letter[]" id="letters" multiple>
  25. <?php foreach ($dayplans as $plan): ?>
  26. <option value="<?= $plan->id ?>"><?php echo "Номер локомотива: $plan->loco_num; Дата: $plan->day Буква: $plan->letter Приоритет: $plan->priority" ?></option>
  27. <?php endforeach; ?>
  28. </select>
  29. </div>
  30. <button id="clear">Очистить план на сегодня</button>
  31. <button id="clearall">Очистить всё</button>
  32. </form>
  33. <div id="content"></div>
  34. <script type="application/javascript">
  35. $(document).ready(function() {
  36. //Инициализация datapicker
  37. $('#datepicker').datetimepicker({
  38. format: 'Y-m-d',
  39. lang: 'ru',
  40. timepicker: false
  41. });
  42. $('#clear').on('click', function() {
  43. var dict = new Object();
  44. dict[ 'dayplan_clear' ] = 1;
  45. sendAjax('content', dict, Reload, "loco_response.php");
  46. });
  47. $('#clearall').on('click', function() {
  48. var dict = new Object();
  49. dict[ 'dayplan_clear_all' ] = 1;
  50. sendAjax('content', dict, Reload, "loco_response.php");
  51. });
  52. $('#add').on('click', function() {
  53. $('.loader').css('display', 'inline-block');
  54. $.ajax({
  55. type: 'GET',
  56. url: 'loco_response.php',
  57. data: {
  58. dayplan: 1,
  59. date: $('#datepicker').val(),
  60. letter: $('#letter').val(),
  61. loco_number: $('#loco_number').val(),
  62. company: $('#company').val(),
  63. priority: $('#priority').val()
  64. },
  65. success: function (data) {
  66. $('#content').html(data);
  67. $('.loader').css('display', 'none');
  68. window.location.reload();
  69. }
  70. });
  71. });
  72. });
  73. </script>
  74. <link rel="stylesheet" href="css/preloader.css">
  75. <style type="text/css">
  76. .main_content {
  77. overflow: unset;
  78. }
  79. form {
  80. display: flex;
  81. }
  82. .activity, .positions {
  83. border: 1px solid #aaa;
  84. border-radius: 5px;
  85. padding: 10px;
  86. margin: 5px;
  87. position: relative;
  88. }
  89. .activity input, .activity select, .activity button {
  90. margin: 5px;
  91. }
  92. .activity button {
  93. display: block;
  94. margin: 7px auto 0;
  95. }
  96. .loader {
  97. left: 137px;
  98. bottom: 42px;
  99. margin: 0;
  100. }
  101. #positions {
  102. float: left;
  103. margin: 0;
  104. }
  105. .positions button {
  106. display: block;
  107. }
  108. .buttons {
  109. display: inline-block;
  110. }
  111. #draw-positions {
  112. margin-left: 10px;
  113. }
  114. .print {
  115. margin: 0 auto;
  116. }
  117. @-moz-document url-prefix() {
  118. .print {
  119. left: 160px;
  120. }
  121. }
  122. @media print {
  123. .lc, .top_nav, form, .generate {
  124. display: none;
  125. }
  126. .main_content {
  127. top: 0;
  128. left: 30px;
  129. padding-top: 0;
  130. }
  131. }
  132. </style>