PR_list.html 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <title>{{ title }}</title>
  6. <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
  7. </head>
  8. <script>
  9. var PR_Form_number = '{{PR_Form_number}}';
  10. console.log("PR_Form_number: " + PR_Form_number);
  11. var USER_NAME = '{{user_name}}';
  12. console.log("USER_NAME: " + USER_NAME);
  13. var USER_ID = '{{user_id}}';
  14. console.log("USER_ID: " + USER_ID);
  15. var USER_MANAGER = '{{user_manager}}';
  16. console.log("USER_MANAGER: " + USER_MANAGER);
  17. var next_PR_companyid = '0711' + '{{new_PR_companyid}}' + 'Txx';
  18. console.log("next_PR_companyid: " + next_PR_companyid)
  19. // $(document).ready(function() {
  20. // // $('#create_PR_table').attr("href", "/PR_user_" + next_PR_companyid);
  21. // });
  22. </script>
  23. <style>
  24. .input-cond-delete {
  25. background: #E43030;
  26. border: 1px solid #CFCFCF;
  27. box-sizing: border-box;
  28. border-radius: 5px;
  29. margin-left: 5px;
  30. width: auto;
  31. height: 33px;
  32. font-size: 16px;
  33. text-align: center;
  34. line-height: 16px;
  35. color: #FFFFFF;
  36. }
  37. .input-cond-add {
  38. background: #008CBA;
  39. border: 1px solid #CFCFCF;
  40. box-sizing: border-box;
  41. border-radius: 5px;
  42. margin-left: 5px;
  43. width: auto;
  44. /* width: 65px; */
  45. height: 33px;
  46. font-size: 16px;
  47. text-align: center;
  48. line-height: 16px;
  49. color: #FFFFFF;
  50. }
  51. .input-cond-action {
  52. background: #FFBD00;
  53. /* #6BF178 #53DD6C #FFBD00*/
  54. border: 1px solid #CFCFCF;
  55. box-sizing: border-box;
  56. border-radius: 5px;
  57. margin-left: 5px;
  58. width: auto;
  59. height: 33px;
  60. font-size: 16px;
  61. text-align: center;
  62. line-height: 16px;
  63. color: #000000;
  64. font-weight: bold;
  65. }
  66. .table-tr-title {
  67. background-color:rgb(0, 131, 72);
  68. color: #FFFFFF;
  69. font-weight: bold;
  70. }
  71. .table-tr-data {
  72. background-color:rgb(236, 247, 242);
  73. }
  74. .table-tr-newdata {
  75. background-color:rgb(245, 245, 245);
  76. }
  77. </style>
  78. <body>
  79. <div id="ERP_header">
  80. <!-- 匯入共同使用的 header.html 內容 -->
  81. {% include 'ERP_header.html' %}
  82. </div>
  83. <center><h6 style="margin: 20px;">請購單列表</h6></center>
  84. 目前使用者:{{user_name}}
  85. {% if notice_list != () %}
  86. <a href="/notice" target="_blank" style="color: #E43030;">
  87. <img src="../static/img/notice.png" style="vertical-align: super;" width="12" alt="有未讀的訊息!">
  88. </a>
  89. {% endif %}
  90. <br>
  91. <br>
  92. <input type="button" class="input-cond-action" id="create_PR_table" value="建立新請購單草稿" onclick="create_PR_table();"><br>
  93. <table class="table table-bordered" style="margin-top: 10px;">
  94. <tr>
  95. <th>現有請購單草稿</th>
  96. <th>狀態</th>
  97. <th>請購人</th>
  98. </tr>
  99. {% for table in PR_tables %}
  100. <tr>
  101. <!-- `請購草稿單號`,`表單狀態`,`員工列表`.`員工英文名字` -->
  102. <td><a href="/PR_user_{{table[0].replace('t', 'T')}}" target="_blank">{{table[0].replace('t', 'T')}}</a></td>
  103. <td>{{table[1]}}</td>
  104. <td>{{table[2]}}</td>
  105. </tr>
  106. {% endfor %}
  107. </table>
  108. </body>
  109. <script>
  110. var next_PR_companyid;
  111. var sql = "";
  112. function create_PR_table() {
  113. sql = "INSERT INTO `表單詳細資料`(`請購草稿單號`, `表單狀態`, `請購人員工編號`, `請購主管員工編號`, `採購主管員工編號`) " +
  114. "VALUES (" +
  115. "'" + next_PR_companyid + "'," +
  116. "'" + "請購申請中" + "'," +
  117. "'" + USER_ID + "'," +
  118. "'" + USER_MANAGER + "'," +
  119. "'" + "HRMA0001T01" + "')";
  120. var sql_data = { "sql":sql };
  121. console.log("sql: " + sql)
  122. $.ajax({
  123. type:"GET",
  124. url:"/sql_get",
  125. dataType:"JSON",
  126. data:sql_data,
  127. async:false,
  128. success:function (res) {
  129. alert("表單詳細資料建置完成, 將移動到請購單 : " + next_PR_companyid + "...")
  130. },
  131. error: function (thrownError) {
  132. if (thrownError.statusText == "INTERNAL SERVER ERROR") {
  133. alert("建立表單詳細資料 " + next_PR_companyid + " 未成功")
  134. } else {
  135. alert("建立表單詳細資料 thrownError" + next_PR_companyid)
  136. }
  137. }
  138. })
  139. sql = "CREATE TABLE `" + next_PR_companyid + "` ( " +
  140. "`內部料號` varchar(11) NOT NULL, " +
  141. "`日期` timestamp NOT NULL DEFAULT current_timestamp(), " +
  142. "`數量` varchar(11) NULL DEFAULT '', " +
  143. "`連結` varchar(2048) NULL DEFAULT '', " +
  144. "`採購公司` varchar(5) NULL DEFAULT '', " +
  145. "`請購備註` varchar(2048) NULL DEFAULT '', " +
  146. "`請購人` varchar(50) NULL DEFAULT '', " +
  147. "`請購核可` tinyint(1) NULL DEFAULT 1, " +
  148. "`單價` varchar(11) NULL DEFAULT '', " +
  149. "`幣別` varchar(10) NOT NULL DEFAULT 'TWD', " +
  150. "`營業稅` varchar(11) NULL DEFAULT '', " +
  151. "`總金額` varchar(11) NULL DEFAULT '', " +
  152. "`交期` varchar(11) NULL DEFAULT '', " +
  153. "`詢價備註` varchar(2048) NULL DEFAULT '', " +
  154. "`詢價單單號` varchar(11) NULL DEFAULT '', " +
  155. "`供應商報價單號` varchar(11) NULL DEFAULT '', " +
  156. "`採購主管核可` tinyint(1) NOT NULL DEFAULT 1, " +
  157. "`採購單號` varchar(11) NULL DEFAULT '', " +
  158. "PRIMARY KEY (內部料號)" +
  159. ") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;";
  160. var sql_data = { "sql":sql };
  161. console.log("sql: " + sql)
  162. $.ajax({
  163. type:"GET",
  164. url:"/sql_get",
  165. dataType:"JSON",
  166. data:sql_data,
  167. async:false,
  168. success:function (res) {
  169. window.location.href = '/PR_user_' + next_PR_companyid;
  170. },
  171. error: function (thrownError) {
  172. if (thrownError.statusText == "INTERNAL SERVER ERROR") {
  173. alert("建立請購單草稿 " + next_PR_companyid + " 未成功")
  174. } else {
  175. alert("建立請購單草稿 thrownError" + thrownError)
  176. }
  177. }
  178. })
  179. }
  180. </script>
  181. </html>