PR_new.html 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555
  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. var table_row_num = 0;
  11. </script>
  12. <style>
  13. .input-cond-delete {
  14. background: #E43030;
  15. border: 1px solid #CFCFCF;
  16. box-sizing: border-box;
  17. border-radius: 5px;
  18. margin-left: 5px;
  19. width: 65px;
  20. height: 33px;
  21. font-size: 16px;
  22. text-align: center;
  23. line-height: 16px;
  24. color: #FFFFFF;
  25. }
  26. .input-cond-add {
  27. background: #008CBA;
  28. border: 1px solid #CFCFCF;
  29. box-sizing: border-box;
  30. border-radius: 5px;
  31. margin-left: 5px;
  32. width: 65px;
  33. height: 33px;
  34. font-size: 16px;
  35. text-align: center;
  36. line-height: 16px;
  37. color: #FFFFFF;
  38. }
  39. </style>
  40. <body>
  41. <div id="ERP_header">
  42. <!-- 匯入共同使用的 header.html 內容 -->
  43. {% include 'ERP_header.html' %}
  44. </div>
  45. <center><h6 style="margin: 20px;">建立請購單</h6></center>
  46. <table class="table table-bordered" id="PR_table" style="margin-top: 10px;">
  47. <tr>
  48. <td colspan="5">
  49. 日期 :
  50. <span id="PR_datetime">(系統代入)</span>
  51. </td>
  52. </tr>
  53. <tr>
  54. <td colspan="5">
  55. 請購單號 :
  56. <span id="PR_document_companyid">{{PR_Form_number}}</span>
  57. </td>
  58. </tr>
  59. <!-- 請購單標題 -->
  60. <tr>
  61. <th>內部料號</th>
  62. <th>數量</th>
  63. <th>單位</th>
  64. <th>連結</th>
  65. <!-- <th>單價</th>
  66. <th>關稅</th>
  67. <th>運費</th>
  68. <th>總金額</th>
  69. <th>付款狀況</th> -->
  70. <th>備註</th>
  71. </tr>
  72. <!-- </div> -->
  73. <!-- 請購單內容:新增資料 -->
  74. <tr>
  75. <td>
  76. <!-- 內部料號 -->
  77. <input list="insert_PR_id_item" id="PR_id_0" style="height: 25px;" onChange="">
  78. <datalist id="insert_PR_id_item">
  79. {% for data in Component_id_name_salesnum %}
  80. {% if data[2] == '' or data[2] == None %}
  81. <option value="{{data[0]}}">{{data[1]}}, (無原廠料號)</option>
  82. {% else %}
  83. <option value="{{data[0]}}">{{data[1]}}, {{data[2]}}</option>
  84. {% endif %}
  85. {% endfor %}
  86. </datalist>
  87. </td>
  88. <td>
  89. <!-- 數量 -->
  90. <input type="text" id="PR_amount_0" value="1" style="height: 25px; width: 50px">
  91. </td>
  92. <td>
  93. <!-- 單位 -->
  94. <input type="text" id="PR_unit_0" value="件" style="height: 25px; width: 50px">
  95. </td>
  96. <td>
  97. <input type="text" id="PR_hyperlink_0" value="www" style="height: 25px; width: 200px">
  98. </td>
  99. <!-- <td> -->
  100. <!-- 單價 -->
  101. <!-- <input type="text" id="PR_unitprice_0" value="11" style="height: 25px; width: 70px">
  102. </td>
  103. <td> -->
  104. <!-- 關稅 -->
  105. <!-- <input type="text" id="PR_tariff_0" value="12" style="height: 25px; width: 70px">
  106. </td>
  107. <td> -->
  108. <!-- 運費 -->
  109. <!-- <input type="text" id="PR_shippingfee_0" value="13" style="height: 25px; width: 70px">
  110. </td>
  111. <td> -->
  112. <!-- 總金額 -->
  113. <!-- <input type="text" id="PR_totalprice_0" value="135" style="height: 25px; width: 90px">
  114. </td>
  115. <td> -->
  116. <!-- 付款狀況 -->
  117. <!-- <input id="PR_payment" value="代墊" style="height: 25px; width: 70px"> -->
  118. <!-- <select id="PR_payment_0">
  119. <option value="未付款">未付款</option>
  120. <option value="已付款">已付款</option>
  121. </select>
  122. </td> -->
  123. <td>
  124. <!-- 備註 -->
  125. <input type="text" id="PR_remark_0" value="備註" style="height: 25px; width: 90px; margin-right: 20px;">
  126. <input type="button" value="新增下一筆" onclick="table_add_rows()">
  127. </td>
  128. </tr>
  129. <script>
  130. // // 修改請購單內項目
  131. // function update_PR_item(id) {
  132. // console.log("修改: " + id)
  133. // var PR_title_list = ['id', 'amount', 'unit', 'supplier', 'unitprice', 'tariff', 'shippingfee', 'totalprice', 'payment']
  134. // for (let i = 1; i < 9; i++) {
  135. // var target_id = document.getElementById(id + '_' + PR_title_list[i]);
  136. // var old_name = target_id.innerText;
  137. // console.log('old_name: ', old_name)
  138. // target_id.innerHTML = "";
  139. // textarea = '<input id="'+ id + '_' + PR_title_list[i] + '_ta' + '" value="' + old_name + '" style="height: 25px; width: 60px">';
  140. // if (i == 8) {
  141. // textarea += '<input type="button" value="OK" onclick="update_comfirm_PR_item(\'' + id + '\')">';
  142. // }
  143. // target_id.insertAdjacentHTML('beforeend', textarea);
  144. // }
  145. // // target_id.insertAdjacentHTML('beforeend', textarea);
  146. // // $(".insert_BOM_person_module").find("option:contains(" + old_name + ")").attr("selected",true);
  147. // }
  148. // // 修改請購單內項目 確認
  149. // function update_comfirm_PR_item(id) {
  150. // console.log("修改: " + id)
  151. // var new_amount_value = $('#' + id + '_amount_ta').val();
  152. // var new_unit_value = $('#' + id + '_unit_ta').val();
  153. // // var new_supplier_value = $('#' + id + '_supplier_ta').val();
  154. // var new_unitprice_value = $('#' + id + '_unitprice_ta').val();
  155. // var new_tariff_value = $('#' + id + '_tariff_ta').val();
  156. // var new_shippingfee_value = $('#' + id + '_shippingfee_ta').val();
  157. // var new_totalprice_value = $('#' + id + '_totalprice_ta').val();
  158. // var new_payment_value = $('#' + id + '_payment_ta').val();
  159. // sql = 'UPDATE ' + PR_Form_number + ' SET `數量` = "' + new_amount_value + '"' +
  160. // ', `單位` = "' + new_unit_value + '"' +
  161. // // ', `供應商` = "' + new_supplier_value + '"' +
  162. // // ', `專案` = "' + new_reason_value + '"' +
  163. // // ', `用途` = "' + new_person_value + '"' +
  164. // ', `單價` = "' + new_unitprice_value + '"' +
  165. // ', `關稅` = "' + new_tariff_value + '"' +
  166. // ', `運費` = "' + new_shippingfee_value + '"' +
  167. // ', `總金額` = "' + new_totalprice_value + '"' +
  168. // ', `付款狀況` = "' + new_payment_value + '"' +
  169. // // ', `備註` = "' + new_person_value + '"' +
  170. // // ', `請購人` = "' + new_person_value + '"' +
  171. // ' WHERE `內部料號` = "' + id + '";';
  172. // console.log('sql: ' + sql)
  173. // var sql_data = { "sql":sql };
  174. // $.ajax({
  175. // type:"GET",
  176. // url:"/sql_get",
  177. // dataType:"JSON",
  178. // data:sql_data,
  179. // success:function (res) {
  180. // alert("請購單 " + PR_Form_number + ":" + id + " 項目修改成功 !")
  181. // location.reload()
  182. // },
  183. // error: function (thrownError) {
  184. // if (thrownError.statusText == "INTERNAL SERVER ERROR") {
  185. // alert("請購單 " + PR_document_companyid + ":" + PR_id + " 項目未修改")
  186. // } else {
  187. // alert("修改請購單項目內容 thrownError" + thrownError)
  188. // }
  189. // }
  190. // })
  191. // }
  192. // // 刪除請購單內項目
  193. // function delete_PR_item(id) {
  194. // console.log("刪除: " + id)
  195. // var comfirm_delete_PR_item = confirm("確定要刪除 " + id + " 零件嗎?")
  196. // if (comfirm_delete_PR_item) {
  197. // sql = 'DELETE FROM ' + PR_Form_number + ' WHERE 內部料號 = "' + id + '";'
  198. // sql_data = { "sql":sql };
  199. // console.log("delete_PR_item[sql]:" + sql)
  200. // $.ajax({
  201. // type:"GET",
  202. // url:"/sql_get",
  203. // dataType:"JSON",
  204. // data:sql_data,
  205. // success:function (res) {
  206. // alert("請購單 " + PR_Form_number + ":" + id + " 刪除成功 !")
  207. // location.reload()
  208. // },
  209. // error: function (thrownError) {
  210. // if (thrownError.statusText == "INTERNAL SERVER ERROR") {
  211. // alert("請購單 " + PR_document_companyid + ":" + PR_id + " 未刪除")
  212. // } else {
  213. // alert("刪除請購單內容 thrownError" + thrownError)
  214. // }
  215. // }
  216. // })
  217. // }
  218. // }
  219. //
  220. function PR_change() {
  221. // get_Value();
  222. var PR_document_companyid_select = $("#PR_document_companyid_select").val()
  223. console.log("PR_document_companyid_select: " + PR_document_companyid_select)
  224. var sql = 'SELECT 內部料號 FROM `' + PR_document_companyid_select + '`' ;
  225. var sql_data = { "sql":sql };
  226. $.ajax({
  227. type:"GET",
  228. url:"/sql_get",
  229. dataType:"JSON",
  230. data:sql_data,
  231. success:function (res) {
  232. if (res.labels.length != 0) {
  233. for (let items = 0; items < res.labels.length; items++) {
  234. var data = '<tr>';
  235. for (let item = 0; item < res.labels[items].length; item++) {
  236. console.log("res.labels[items][item]: ", res.labels[items][item], typeof(res.labels[items][item]))
  237. if (res.labels[items][item] == null) {
  238. data += '<td id="' + res.labels[items][0] + '_' + item + '">' + '' + '</td>';
  239. } else {
  240. data += '<td id="' + res.labels[items][0] + '_' + item + '">' + res.labels[items][item] + '</td>';
  241. }
  242. };
  243. // data += '<td><input type="button" class="input-cond-add" value="修改" onclick="update_standard(\'' + res.labels[items][0] + '\')"></td>';
  244. data += '</tr>';
  245. };
  246. var sectorSelect = document.getElementById("result");
  247. sectorSelect.innerHTML = data;
  248. }
  249. },
  250. error: function (thrownError) {
  251. if (thrownError.statusText == "INTERNAL SERVER ERROR") {
  252. alert("請購單 " + PR_document_companyid + ":" + PR_id + " 未新增")
  253. } else {
  254. alert("新增請購單內容 thrownError" + thrownError)
  255. }
  256. }
  257. })
  258. }
  259. </script>
  260. <tr>
  261. <td>
  262. 請購 :
  263. <!-- <span id="PR_requisition_person"></span> -->
  264. <!-- <input list="insert_PR_person" id="PR_person" style="height: 25px;" onChange="">
  265. <datalist id="insert_PR_person">
  266. </datalist> -->
  267. <select id="PR_person">
  268. <option value=""></option>
  269. <option value="Andrey">Andrey</option>
  270. <option value="Amy">Amy</option>
  271. <option value="Allen">Allen</option>
  272. <option value="Gina">Gina</option>
  273. <option value="FatWolf">FatWolf</option>
  274. <option value="Rita">Rita</option>
  275. </select>
  276. </td>
  277. <td>
  278. 倉管 :
  279. <span id="PR_warehouse_person"></span>
  280. </td>
  281. <td>
  282. 管理 :
  283. <span id="PR_management_person"></span>
  284. </td>
  285. </tr>
  286. </table>
  287. <br>
  288. <input type="button" value="取值測試" onclick="get_Value();">
  289. <input type="button" class="input-cond-add" value="儲存" onclick="create_PR_table(PR_Form_number);">
  290. <div id="result"></div>
  291. <br>
  292. <script>
  293. var sql = '';
  294. var sql_data = { "sql":sql };
  295. // 建立請購單 Table + 建立項目
  296. function create_PR_table(PR_conpany_id) {
  297. console.log("create_PR_table PR_conpany_id: " + PR_conpany_id)
  298. PR_insert_items = [];
  299. // 取值組合成 SQL 語法
  300. // 亦當作未輸入之空格
  301. for (let row = 0; row <= table_row_num; row++) {
  302. data = '(';
  303. for (let item = 0; item < PR_title_list.length; item++) {
  304. var PR_value = document.getElementById("PR_" + PR_title_list[item] + "_" + row).value;
  305. console.log("PR_" + PR_title_list[item] + "_" + row + ": " + PR_value)
  306. // (內部料號, 數量, 單位, 單價, 關稅, 運費, 總金額, 付款狀況, 備註,
  307. data += '"' + PR_value + '", ';
  308. }
  309. // 請購人)
  310. var PR_person_value = document.getElementById("PR_person").value;
  311. console.log("PR_person: " + PR_person_value)
  312. data += '"' + PR_person_value + '")';
  313. PR_insert_items.push(data);
  314. }
  315. console.log("PR_insert_items: " + PR_insert_items)
  316. // 建立請購單 Table
  317. sql = 'CREATE TABLE `' + PR_conpany_id + '` (' +
  318. '`內部料號` varchar(11) NOT NULL, ' +
  319. '`建立日期` TIMESTAMP NOT NULL DEFAULT current_timestamp(), ' +
  320. '`數量` varchar(4) NOT NULL, ' +
  321. '`單位` varchar(10) NULL, ' +
  322. '`連結` varchar(500) NULL, ' +
  323. // '`單價` varchar(10) NULL, ' +
  324. // '`關稅` varchar(10) NULL, ' +
  325. // '`運費` varchar(10) NULL, ' +
  326. // '`總金額` varchar(10) NULL, ' +
  327. // '`付款狀況` varchar(10) NULL, ' +
  328. '`備註` varchar(100) NULL, ' +
  329. '`請購人` varchar(10) NULL, ' +
  330. 'PRIMARY KEY (內部料號)' +
  331. ');';
  332. console.log("sql: " + sql)
  333. sql_data = { "sql":sql }
  334. $.ajax({
  335. type:"GET",
  336. url:"/sql_get",
  337. dataType:"JSON",
  338. data:sql_data,
  339. async:false,
  340. success:function (res) {
  341. alert("請購單 " + PR_conpany_id + ": 建立成功!")
  342. },
  343. error: function (thrownError) {
  344. if (thrownError.statusText == "INTERNAL SERVER ERROR") {
  345. alert("請購單 " + PR_conpany_id + " 未成功")
  346. } else {
  347. alert("請購單建立錯誤: " + thrownError)
  348. }
  349. }
  350. })
  351. // 建立請購單項目
  352. // sql = 'INSERT INTO `' + PR_conpany_id + '` (內部料號, 數量, 單位, 單價, 關稅, 運費, 總金額, 付款狀況, 備註, 請購人) ' +
  353. // 'VALUES ' + PR_insert_items.join(', ');
  354. sql = 'INSERT INTO `' + PR_conpany_id + '` (內部料號, 數量, 單位, 連結, 備註, 請購人) ' +
  355. 'VALUES ' + PR_insert_items.join(', ');
  356. console.log("sql: " + sql)
  357. sql_data = { "sql":sql }
  358. $.ajax({
  359. type:"GET",
  360. url:"/sql_get",
  361. dataType:"JSON",
  362. data:sql_data,
  363. async:false,
  364. success:function (res) {
  365. alert("請購單 " + PR_conpany_id + ": 項目建立成功!")
  366. window.location.assign("/PR_user_" + PR_conpany_id)
  367. },
  368. error: function (thrownError) {
  369. if (thrownError.statusText == "INTERNAL SERVER ERROR") {
  370. alert("請購單 " + PR_conpany_id + " 項目建立未成功")
  371. } else {
  372. alert("請購單項目建立錯誤: " + thrownError)
  373. }
  374. }
  375. })
  376. }
  377. // var PR_title_list = ['id', 'amount', 'unit', 'unitprice', 'tariff', 'shippingfee', 'totalprice', 'payment', 'remark']
  378. var PR_title_list = ['id', 'amount', 'unit', 'hyperlink', 'remark']
  379. var data = '';
  380. // 取得欄位值
  381. function get_Value() {
  382. console.log("get_Value")
  383. var PR_insert_items = [];
  384. for (let row = 0; row <= table_row_num; row++) {
  385. data = '(';
  386. for (let item = 0; item < PR_title_list.length; item++) {
  387. var PR_value = document.getElementById("PR_" + PR_title_list[item] + "_" + row).value;
  388. console.log("PR_" + PR_title_list[item] + "_" + row + ": " + PR_value)
  389. // (內部料號, 數量, 單位, 單價, 關稅, 運費, 總金額, 付款狀況, 備註, 請購人)
  390. data += '"' + PR_value + '", ';
  391. }
  392. var PR_person_value = document.getElementById("PR_person").value;
  393. console.log("PR_person: " + PR_person_value)
  394. data += '"' + PR_person_value + '")';
  395. PR_insert_items.push(data);
  396. }
  397. var selector = document.getElementById("result");
  398. selector.innerHTML = PR_insert_items.join(', ');
  399. }
  400. function table_add_rows() {
  401. table_row_num++;
  402. var table_name = document.getElementById("PR_table");
  403. var table_add_row = table_name.insertRow(table_name.rows.length-1);
  404. // var table_add_row = table_name.insertRow(table_name.rows.length); // 最後一行
  405. // var PR_title_add_list = ['id', 'amount', 'unit', 'unitprice', 'tariff', 'shippingfee', 'totalprice', 'payment', 'remark']
  406. for (let i = 0; i < PR_title_list.length; i++) {
  407. var cell = table_add_row.insertCell();
  408. if (i == 0) {
  409. // 內部料號
  410. data = '<input list="insert_PR_id_item" id="PR_id_' + table_row_num + '" style="height: 25px;" onChange="">' +
  411. '<datalist id="insert_PR_id_item">' +
  412. '{% for data in Component_id_name_salesnum %}' +
  413. '{% if data[2] == "" or data[2] == None %}' +
  414. '<option value="{{data[0]}}">{{data[1]}}, (無原廠料號)</option>' +
  415. '{% else %}' +
  416. '<option value="{{data[0]}}">{{data[1]}}, {{data[2]}}</option>' +
  417. '{% endif %}' +
  418. '{% endfor %}' +
  419. '</datalist>' ;
  420. cell.innerHTML = data;
  421. // } else if (i == 1 || i == 2 || i == 5) {
  422. // // 名稱 型號/規格 供應商
  423. // // data = '—' ;
  424. // // cell.innerHTML = data;
  425. } else if (i == 1) {
  426. // 數量
  427. data = '<input type="text" id="PR_' + PR_title_list[i] + '_' + table_row_num + '" value="" style="height: 25px; width: 50px">' ;
  428. cell.innerHTML = data;
  429. } else if (i == 2) {
  430. // 單位
  431. data = '<input type="text" id="PR_' + PR_title_list[i] + '_' + table_row_num + '" value="" style="height: 25px; width: 50px">' ;
  432. cell.innerHTML = data;
  433. // } else if (i == 3) {
  434. // // 單價
  435. // data = '<input type="text" id="PR_' + PR_title_list[i] + '_' + table_row_num + '" value="" style="height: 25px; width: 70px">' ;
  436. // cell.innerHTML = data;
  437. // } else if (i == 4) {
  438. // // 關稅
  439. // data = '<input type="text" id="PR_' + PR_title_list[i] + '_' + table_row_num + '" value="" style="height: 25px; width: 70px">' ;
  440. // cell.innerHTML = data;
  441. // } else if (i == 5) {
  442. // // 運費
  443. // data = '<input type="text" id="PR_' + PR_title_list[i] + '_' + table_row_num + '" value="" style="height: 25px; width: 70px">' ;
  444. // cell.innerHTML = data;
  445. // } else if (i == 6) {
  446. // // 總金額
  447. // data = '<input type="text" id="PR_' + PR_title_list[i] + '_' + table_row_num + '" value="" style="height: 25px; width: 90px">' ;
  448. // cell.innerHTML = data;
  449. // } else if (i == 7) {
  450. // // 付款狀況
  451. // data = '<select id="PR_' + PR_title_list[i] + '_' + table_row_num + '">' +
  452. // '<option value="未付款">未付款</option>' +
  453. // '<option value="已付款">已付款</option>' +
  454. // '</select>';
  455. // cell.innerHTML = data;
  456. } else if (i == 3) {
  457. // 連結
  458. data = '<input type="text" id="PR_' + PR_title_list[i] + '_' + table_row_num + '" value="" style="height: 25px; width: 200px;">';
  459. cell.innerHTML = data;
  460. } else if (i == 4) {
  461. // 備註
  462. data = '<input type="text" id="PR_' + PR_title_list[i] + '_' + table_row_num + '" value="" style="height: 25px; width: 90px;">';
  463. cell.innerHTML = data;
  464. } else {
  465. cell.innerHTML = i;
  466. }
  467. }
  468. }
  469. function insert_PR_item() {
  470. var PR_document_companyid = $("#PR_document_companyid").text()
  471. var PR_document_companyid_select = $("#PR_document_companyid_select").val()
  472. var PR_id = $("#PR_id").val()
  473. var PR_amount = $("#PR_amount").val()
  474. var PR_unit = $("#PR_unit").val()
  475. var PR_supplier = $("#PR_supplier").val()
  476. var PR_unitprice = $("#PR_unitprice").val()
  477. var PR_tariff = $("#PR_tariff").val()
  478. var PR_shippingfee = $("#PR_shippingfee").val()
  479. var PR_totalprice = $("#PR_totalprice").val()
  480. var PR_payment = $("#PR_payment").val()
  481. var PR_remark_project= $("#PR_remark_project").val()
  482. var PR_requisition_person = $("#PR_requisition_person").text()
  483. console.log("PR_document_companyid: " + PR_document_companyid)
  484. console.log("PR_document_companyid_select: " + PR_document_companyid_select)
  485. console.log("PR_id: " + PR_id)
  486. console.log("PR_amount: " + PR_amount)
  487. console.log("PR_unit: " + PR_unit)
  488. console.log("PR_supplier: " + PR_supplier)
  489. console.log("PR_unitprice: " + PR_unitprice)
  490. console.log("PR_tariff: " + PR_tariff)
  491. console.log("PR_shippingfee: " + PR_shippingfee)
  492. console.log("PR_totalprice: " + PR_totalprice)
  493. console.log("PR_payment: " + PR_payment)
  494. console.log("PR_remark_project: " + PR_remark_project)
  495. console.log("PR_requisition_person: " + PR_requisition_person)
  496. // TODO !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  497. var sql = 'INSERT INTO `' + PR_Form_number + '`' +
  498. ' VALUES ("' + PR_id + '", current_timestamp(), "' + PR_amount + '", "' + PR_unit + '", "' +
  499. PR_supplier + '", "' +
  500. PR_unitprice + '", "' + PR_tariff + '", "' + PR_shippingfee + '", "' +
  501. PR_totalprice + '", "' + PR_payment + '", "' + PR_remark_project + '", "' + PR_requisition_person + '");';
  502. var sql_data = { "sql":sql };
  503. console.log("insert_PR_item[sql]:" + sql)
  504. $.ajax({
  505. type:"GET",
  506. url:"/sql_get",
  507. dataType:"JSON",
  508. data:sql_data,
  509. success:function (res) {
  510. alert("請購單 " + PR_document_companyid + ":" + PR_id + " 新增成功 !")
  511. location.reload()
  512. },
  513. error: function (thrownError) {
  514. if (thrownError.statusText == "INTERNAL SERVER ERROR") {
  515. alert("請購單 " + PR_document_companyid + ":" + PR_id + " 未新增")
  516. } else {
  517. alert("新增請購單內容 thrownError" + thrownError)
  518. }
  519. }
  520. })
  521. }
  522. </script>
  523. </body>
  524. </html>