<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>{{ title }}</title> <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> <script> var PR_Form_number = '{{PR_Form_number}}'; console.log("PR_Form_number: " + PR_Form_number); var USER_NAME = '{{user_name}}'; console.log("USER_NAME: " + USER_NAME); var PR_PERSON = '{{PR_person}}'; console.log("PR_PERSON: " + PR_PERSON); var RFQ_MANAGER = '{{RFQ_manager}}'; console.log("RFQ_MANAGER: " + RFQ_MANAGER); var FORM_STATUS = '{{form_status}}'; var data_id = []; // 存放此資料表所有的內部料號 // 取得現在時間 紀錄請購備註時使用 var Today = new Date(); // 整理請購主管下屬清單 var staff_data = '{{staff_data}}' console.log("staff_data: " + staff_data + typeof(staff_data)) var PR_person_staff = []; // 顯示零件名稱標題用 var tr_title_id_target = '00000000'; window.onload = function(){ if (FORM_STATUS != '請購核可中') { [].forEach.call(document.querySelectorAll('.status-visible'), function (el) { el.style.visibility = 'hidden'; }); [].forEach.call(document.querySelectorAll('.status-display'), function (el) { el.style.display = 'none'; }); [].forEach.call(document.querySelectorAll('.status-disabled'), function (el) { el.disabled = true; }); } } </script> <style> .input-cond-delete { background: #E43030; border: 1px solid #CFCFCF; box-sizing: border-box; border-radius: 5px; margin-left: 5px; width: auto; height: 33px; font-size: 16px; text-align: center; line-height: 16px; color: #FFFFFF; } .input-cond-add { background: #008CBA; border: 1px solid #CFCFCF; box-sizing: border-box; border-radius: 5px; margin-left: 5px; width: auto; /* width: 65px; */ height: 33px; font-size: 16px; text-align: center; line-height: 16px; color: #FFFFFF; } .input-cond-action { background: #FFBD00; /* #6BF178 #53DD6C #FFBD00*/ border: 1px solid #CFCFCF; box-sizing: border-box; border-radius: 5px; margin-left: 5px; width: auto; height: 33px; font-size: 16px; text-align: center; line-height: 16px; color: #000000; font-weight: bold; } .table-tr-title { background-color:rgb(0, 131, 72); color: #FFFFFF; font-weight: bold; } .table-tr-data { background-color:rgb(236, 247, 242); } .table-tr-newdata { background-color:rgb(245, 245, 245); } </style> </head> <body> <div id="ERP_header"> <!-- 匯入共同使用的 header.html 內容 --> {% include 'ERP_header.html' %} </div> {% for staff in staff_data %} <script> PR_person_staff.push('{{staff}}') </script> {% endfor %} <center><h6 style="margin: 20px;">新增請購單</h6></center> 目前使用者:{{user_name}}<br> 請購單號:<span>{{PR_Form_number}}</span><br> 表單狀態:{{form_status}}<br> 用途:<input type="text" id="{{PR_Form_number}}_purpose" value="{{form_purpose}}" style="height: 25px; width: 50%;"> <input type="button" id="{{PR_Form_number}}_savepurpose" value="儲存用途" onclick="update_purpose('{{PR_Form_number}}')"> <br> <table class="table table-bordered" style="margin-top: 10px;"> {% for datas in PR_data %} <thead> <tr class="table-tr-title" id="{{datas[0]}}_tr_title"></tr> <script type="text/javascript"> var tr_title_id_now = '{{datas[0]}}'.substring(0, 8) if (tr_title_id_now != tr_title_id_target) { tr_title_id_target = tr_title_id_now var target_tr = document.getElementById('{{datas[0]}}_tr_title'); var target_td = '<td colspan="11">' + '{{datas[1]}}' + '</td>' target_tr.insertAdjacentHTML('beforeend', target_td); } </script> </thead> <tbody> <!-- 請購單標題 --> <tr class="table-tr-data"> <th>內部料號</th> <th>名稱</th> <th>原廠料號</th> <th>數量</th> <th>單位</th> <th>圖片</th> <th>供應商</th> <th>連結</th> <th>請購人</th> <!-- <th>核可</th> <th>請購備註</th> --> <th> <p class="status-visible">改/刪</p> </th> </tr> <!-- 請購單內容:現有資料 --> <!-- <div id="result"> --> <script> // 取得所有內部料號 data_id.push('{{datas[0]}}') </script> <tr class="table-tr-data"> <td id="{{datas[0]}}_id">{{datas[0]}}</td> <td id="{{datas[0]}}_name">{{datas[1]}}</td> <td id="{{datas[0]}}_type">{{datas[2]}}</td> <td id="{{datas[0]}}_amount">{{datas[3]}}</td> <td id="{{datas[0]}}_unit">{{datas[4]}}</td> <td id="{{datas[0]}}_picture">{{datas[5]}}</td> <td id="{{datas[0]}}_supplier">{{datas[6]}}</td> <td id="{{datas[0]}}_hyperlink">{{datas[7]}}</td> <td id="{{datas[0]}}_PRperson">{{datas[8]}}</td> <!-- <td>核可</td> --> <!-- <td>請購備註</td> --> <td> <input type="button" class="input-cond-add status-visible" value="修改" onclick="update_PR_item('{{datas[0]}}')"><br> <input type="button" class="input-cond-delete status-visible" value="刪除" onclick="delete_PR_item('{{datas[0]}}')"> </td> </tr> <tr> <th colspan="1"> 請購核可 : {% if datas[9] == 1 %} <input type="checkbox" id="{{datas[0]}}_PRcheck" class="status-disabled" onclick="checkbox_check('{{datas[0]}}')" checked> {% else %} <input type="checkbox" id="{{datas[0]}}_PRcheck" class="status-disabled" onclick="checkbox_check('{{datas[0]}}')"> {% endif %} <br> {% if form_status == "請購詢價完成" %} 採購核可 : {% if datas[11] == 1 %} <input type="checkbox" id="{{datas[0]}}_RFQcheck" class="status-disabled" checked> {% else %} <input type="checkbox" id="{{datas[0]}}_RFQcheck" class="status-disabled" > {% endif %} {% endif %} </th> <td colspan="9"> <span style="font-weight: bold;">請購備註 : </span> <input type="text" id="{{datas[0]}}_new_PRremark" style="height: 25px; width: 50%;"> <input type="button" id="PR_new_PRremark" value="新增備註" style="height: auto;" onclick="insert_new_PRremark('{{datas[0]}}')"> <br> <span id="{{datas[0]}}_PRremark">{{datas[10]|safe}}</span> <!-- <hr> <span id="{{datas[0]}}_PRremark_t">Rita (2022/02/11 11:50:49) 說:111<br>Rita (2022/02/11 11:52:35) 說:222</span> --> </td> </tr> </tbody> {% endfor %} <!-- </div> --> <!-- 請購單內容:新增資料 --> {% if PR_Form_number[-2:] == 'xx' %} <thead class="status-display"> <tr class="table-tr-title"> <td colspan="11">新增零件</td> </tr> </thead> <tbody class="status-display"> <tr class="table-tr-newdata"> <th>內部料號</th> <th>名稱</th> <th>原廠料號</th> <th>數量</th> <th>單位</th> <th>圖片</th> <th>供應商</th> <th>連結</th> <th>請購人</th> <!-- <th>核可</th> <th>請購備註</th> --> <th>新增</th> </tr> <tr class="table-tr-newdata"> <td> <!-- 內部料號 --> <input list="insert_PR_id_item" id="PR_id" style="height: 25px;" value="" onChange="get_id_standard(this.id)"> <datalist id="insert_PR_id_item"> {% for data in Component_id_name_salesnum %} {% if data[2] == '' or data[2] == None %} <option value="{{data[0]}}">{{data[1]}}, (無原廠料號)</option> {% else %} <option value="{{data[0]}}">{{data[1]}}, {{data[2]}}</option> {% endif %} {% endfor %} </datalist> </td> <td> <!-- 名稱 --> <span id="new_PR_name">——</span> </td> <td> <!-- 原廠料號 --> <span id="new_PR_type">——</span> </td> <td> <!-- 數量 --> <input id="PR_amount" value="" style="height: 25px; width: 50px"> </td> <td> <!-- 單位 --> <span id="new_PR_unit">——</span> </td> <td> <!-- 照片 --> <span id="new_PR_picture">——</span> </td> <td> <!-- 供應商 --> <span id="new_PR_supplier">——</span> </td> <td> <!-- 超連結 --> <input id="PR_hyperlink" value="" style="height: 25px; width: 100px"> </td> <td> <!-- 請購人 --> <!-- <input type="text" id="PR_PRperson" value="" style="height: 25px; width: 90px;"> --> <select id="PR_PRperson"> {% for staff in staff_data %} <option>{{staff}}</option> {% endfor %} </select> </td> <!-- <td> 請購核可 <input type="checkbox" id="PR_PRcheck" value="" checked> </td> <td> 請購人備註 <input type="text" id="PR_PRremark" value="" style="height: 25px; width: 90px;"> </td> --> <td rowspan="2" style="vertical-align: middle;"> <!-- OK, 新增下一筆 --> <input type="button" class="input-cond-add" value="新增" onclick="insert_PR_item()"> </td> </tr> <tr class="table-tr-newdata"> <th colspan="1"> 請購核可 : <input type="checkbox" id="PR_PRcheck" value="" checked disabled> </th> <th colspan="9"> 請購備註 : <input type="text" id="PR_PRremark" value="" style="height: 25px; width: 50%;"> </td> </tr> </tbody> {% endif %} <tr> <td> {% if form_status == "請購核可中" %} <input type="button" class="input-cond-action status-visible" value="←駁回" onclick="PRmanager_to_user()"> {% endif %} </td> <td colspan="8"></td> <td> {% if form_status == "請購核可中" %} <input type="button" class="input-cond-action status-visible" value="詢價→" onclick="PR_to_RFQmanager()"> {% endif %} </td> </tr> <script> // 新增零件時, 選擇內部料號後, 出現規格表相關內容 function get_id_standard(id) { var new_PR_id = document.getElementById(id).value; // alert("get_id_standard Test: " + new_PR_id) sql = 'SELECT 零件表.名稱, `原廠料號`, `單位`, `圖片`, 零件表.供應商' + ' FROM 零件表' + ' INNER JOIN 規格表' + ' ON 零件表.內部料號 = 規格表.內部料號' + ' WHERE 零件表.內部料號 = "' + new_PR_id + '"'; var sql_data = { "sql":sql }; $.ajax({ type:"GET", url:"/sql_get", dataType:"JSON", data:sql_data, async:false, success:function (res) { if (res.labels == '') { alert(new_PR_id + " 無此零件") document.getElementById('PR_id').value = ''; document.getElementById('new_PR_name').innerText = ''; document.getElementById('new_PR_type').innerText = ''; document.getElementById('new_PR_unit').innerText = ''; document.getElementById('new_PR_picture').innerText = ''; document.getElementById('new_PR_supplier').innerText = ''; } else { // 名稱 document.getElementById('new_PR_name').innerText = res.labels[0][0]; // 原廠料號 document.getElementById('new_PR_type').innerText = res.labels[0][1]; // 單位 document.getElementById('new_PR_unit').innerText = res.labels[0][2]; // 圖片 document.getElementById('new_PR_picture').innerText = res.labels[0][3]; // 供應商 document.getElementById('new_PR_supplier').innerText = res.labels[0][4]; } }, error: function (thrownError) { if (thrownError.statusText == "INTERNAL SERVER ERROR") { alert("新增零件取值 : " + new_PR_id + " 未成功") } else { alert("新增零件取值 thrownError" + thrownError) } } }) } // 主管駁回 function PRmanager_to_user() { var confirm_to_user = confirm('本表單將駁回給請購人, 請點選[確定]送出通知') if (confirm_to_user) { // 狀態更新為 請購申請中 sql = "UPDATE `表單詳細資料` SET `表單狀態` = '請購申請中' " + "WHERE `表單詳細資料`.`請購草稿單號` = '" + PR_Form_number + "';"; sql_data = { "sql":sql }; console.log("PRmanager_to_user[sql]:" + sql) $.ajax({ type:"GET", url:"/sql_get", dataType:"JSON", data:sql_data, async:false, success:function (res) { alert("調整狀態為\"請購申請中\"") }, error: function (thrownError) { if (thrownError.statusText == "INTERNAL SERVER ERROR") { alert("送出調整狀態 未成功") } else { alert("送出調整狀態 thrownError" + thrownError) } } }) // 通知 sql = "INSERT INTO `通知列表`(`通知對象`,`表單單號`, `內容`) VALUES ('" + PR_PERSON + "','" + PR_Form_number + "','" + USER_NAME + " 已駁回')"; sql_data = { "sql":sql }; console.log("PRmanager_to_user[sql]:" + sql) $.ajax({ type:"GET", url:"/sql_get", dataType:"JSON", data:sql_data, async:false, success:function (res) { alert("已通知請購人") window.location.assign("/PR_list") }, error: function (thrownError) { if (thrownError.statusText == "INTERNAL SERVER ERROR") { alert("駁回通知 未成功") } else { alert("駁回通知 thrownError" + thrownError) } } }) } } // 主管核可後, 開始詢價 function PR_to_RFQmanager() { for (let i = 0; i < data_id.length; i++) { var checkbox_is_check = $('#' + data_id[i] + '_PRcheck').prop("checked") console.log("checkbox_is_check: " + checkbox_is_check) if (!checkbox_is_check) { alert('內部料號 ' + data_id[i] + ' 未核可, 全數核可才可詢價') return false } } // 狀態更新為 採購公司設定 sql = "UPDATE `表單詳細資料` SET `表單狀態` = '採購公司設定' " + "WHERE `表單詳細資料`.`請購草稿單號` = '" + PR_Form_number + "';"; sql_data = { "sql":sql }; console.log("PRuser_to_manager[sql]:" + sql) $.ajax({ type:"GET", url:"/sql_get", dataType:"JSON", data:sql_data, async:false, success:function (res) { alert("調整狀態為\"採購公司設定\"") }, error: function (thrownError) { if (thrownError.statusText == "INTERNAL SERVER ERROR") { alert("送出調整狀態 未成功") } else { alert("送出調整狀態 thrownError" + thrownError) } } }) // 通知採購主管 sql = "INSERT INTO `通知列表`(`通知對象`,`表單單號`, `內容`) VALUES ('" + RFQ_MANAGER + "','" + PR_Form_number + "','" + USER_NAME + " 送出請購單')"; sql_data = { "sql":sql }; console.log("PR_to_RFQmanager[sql]:" + sql) $.ajax({ type:"GET", url:"/sql_get", dataType:"JSON", data:sql_data, async:false, success:function (res) { alert("已通知採購主管") window.location.assign("/PR_list") }, error: function (thrownError) { if (thrownError.statusText == "INTERNAL SERVER ERROR") { alert("送出通知 未成功") } else { alert("送出通知 thrownError" + thrownError) } } }) } // 把日期數字變成兩位數 function two(params) { var date_num = parseInt(params) if ( date_num < 10) { new_date_num = '0' + String(date_num) } else { new_date_num = String(date_num) } return new_date_num } // function insert_new_PRremark(id){ // 取得原本的請購備註內容 var old_remark = document.getElementById(id + '_PRremark'); var old_remark_data = old_remark.innerHTML; console.log("old_remark_data: " + old_remark_data) // 取得新增的請購備註內容 var new_remark = document.getElementById(id + '_new_PRremark').value; console.log("new_remark: " + new_remark) // 組合文字 Rita (2022/02/10 17:55:00) 說:急, 缺, 一定要買! var new_remark_data = USER_NAME + " (" + Today.getFullYear()+ "/" + two((Today.getMonth()+1)) + "/" + two(Today.getDate()) + " " + two(Today.getHours()) + ":" + two(Today.getMinutes()) + ":" + two(Today.getSeconds()) + ") 說:" + new_remark; console.log("new_remark_data: " + new_remark_data) sql = 'UPDATE ' + PR_Form_number + ' SET `請購備註`="' + old_remark_data + new_remark_data + '<br>' + '"' + ' WHERE `內部料號`="' + id + '";'; console.log("[insert_new_PRremark]sql: " + sql) var sql_data = { "sql":sql }; $.ajax({ type:"GET", url:"/sql_get", dataType:"JSON", data:sql_data, async:false, success:function (res) { alert("請購單 " + PR_Form_number + " : " + id + " 請購備註修改成功 !") location.reload() }, error: function (thrownError) { if (thrownError.statusText == "INTERNAL SERVER ERROR") { alert("請購單 " + PR_Form_number + " : " + PR_id + " 請購備註未修改") } else { alert("修改請購單請購備註內容 thrownError" + thrownError) } } }) } // function update_PR_item(id) { console.log("修改: " + id) console.log("PR_person_staff: " + PR_person_staff) var PR_title_list = ['id', 'name', 'type', 'amount', 'unit', 'picture', 'supplier', 'hyperlink', 'PRperson', 'check', 'PRremark'] for (let i = 1; i < PR_title_list.length; i++) { if (i == 3 || i == 7 || i == 8) { // i != 1 && i != 2 && i != 5 && i != 6 var target_id = document.getElementById(id + '_' + PR_title_list[i]); var old_name = target_id.innerText; console.log('old_name: ', old_name) target_id.innerHTML = ""; if (PR_title_list[i] == 'hyperlink') { textarea = '<input id="'+ id + '_' + PR_title_list[i] + '_ta' + '" value="' + old_name + '" style="height: 25px; width: 100px">'; } else if (PR_title_list[i] == 'PRperson'){ textarea = '<select id="'+ id + '_' + PR_title_list[i] + '_ta' + '">'; for (let i = 0; i < PR_person_staff.length; i++) { textarea += '<option>' + PR_person_staff[i] + '</option>' } textarea += '</select>' } else { textarea = '<input id="'+ id + '_' + PR_title_list[i] + '_ta' + '" value="' + old_name + '" style="height: 25px; width: 50px">'; } if (PR_title_list[i] == 'PRperson') { textarea += '<input type="button" value="OK" onclick="update_comfirm_PR_item(\'' + id + '\')">'; } target_id.insertAdjacentHTML('beforeend', textarea); } if (PR_title_list[i] == 'PRperson') { $("#" + id + "_PRperson_ta").val(old_name); } } } // 修改請購單內項目 確認 function update_comfirm_PR_item(id) { console.log("修改: " + id) var new_amount_value = $('#' + id + '_amount_ta').val(); var new_unit_value = $('#' + id + '_unit_ta').val(); var new_hyperlink_value = $('#' + id + '_hyperlink_ta').val(); // var new_PRremark_value = $('#' + id + '_PRremark_ta').val(); var new_PRperson_value = $('#' + id + '_PRperson_ta').val(); sql = 'UPDATE ' + PR_Form_number + ' SET `數量`="' + new_amount_value + '"' + ', `單位`="' + new_unit_value + '"' + ', `連結`="' + new_hyperlink_value + '"' + // ', `請購備註`="' + new_PRremark_value + '"' + ', `請購人`="' + new_PRperson_value + '"' + ' WHERE `內部料號`="' + id + '";'; console.log('sql: ' + sql) var sql_data = { "sql":sql }; $.ajax({ type:"GET", url:"/sql_get", dataType:"JSON", data:sql_data, async:false, success:function (res) { alert("請購單 " + PR_Form_number + " : " + id + " 項目修改成功 !") location.reload() }, error: function (thrownError) { if (thrownError.statusText == "INTERNAL SERVER ERROR") { alert("請購單 " + PR_Form_number + " : " + PR_id + " 項目未修改") } else { alert("修改請購單項目內容 thrownError" + thrownError) } } }) } // 刪除請購單內項目 function delete_PR_item(id) { console.log("刪除: " + id) var comfirm_delete_PR_item = confirm("確定要刪除 " + id + " 零件嗎?") if (comfirm_delete_PR_item) { sql = 'DELETE FROM ' + PR_Form_number + ' WHERE 內部料號 = "' + id + '";' sql_data = { "sql":sql }; console.log("delete_PR_item[sql]:" + sql) $.ajax({ type:"GET", url:"/sql_get", dataType:"JSON", data:sql_data, async:false, success:function (res) { alert("請購單 " + PR_Form_number + " : " + id + " 刪除成功 !") location.reload() }, error: function (thrownError) { if (thrownError.statusText == "INTERNAL SERVER ERROR") { alert("請購單 " + PR_document_companyid + ":" + PR_id + " 未刪除") } else { alert("刪除請購單內容 thrownError" + thrownError) } } }) } } </script> </table> <!-- {% if PR_Form_number[-2:] == 'xx' %} <input type="button" class="input-cond-add" value="送出" style="width: auto;" onclick="PR_to_Purchase()"> <input type="button" class="input-cond-add" value="採購人員修改採購公司" style="width: auto;" onclick="Purchase_update_sup()"> {% elif PR_Form_number[-2:] == '01' or PR_Form_number[-2:] == '02' %} <input type="button" class="input-cond-add" value="製作請購單 PDF" style="width: auto;" onclick=""> <input type="button" class="input-cond-add" value="建立詢購單" style="width: auto;" onclick=""> {% endif %} --> <script> // 儲存 用途 function update_purpose(companyid) { var PR_purpose = $("#" + companyid + "_purpose").val() console.log("PR_purpose: " + PR_purpose) sql = "UPDATE `表單詳細資料` SET `用途` = '" + PR_purpose + "' " + "WHERE `表單詳細資料`.`請購草稿單號` = '" + companyid + "';"; var sql_data = { "sql":sql }; console.log("sql") $.ajax({ type:"GET", url:"/sql_get", dataType:"JSON", data:sql_data, async:false, success:function (res) { alert("請購單 " + PR_Form_number + " 請購用途修改成功 !") location.reload() }, error: function (thrownError) { if (thrownError.statusText == "INTERNAL SERVER ERROR") { alert("請購單 " + PR_Form_number + " 請購用途未修改") } else { alert("修改請購用途 thrownError" + thrownError) } } }) } function checkbox_check(id) { var checkbox_id = $('#' + id + '_PRcheck').prop("checked"); // console.log("checkbox_id: " + checkbox_id) if (checkbox_id == true) { // 主管勾選核可 從空白到勾選 var checkbox_confirm_true = prompt("[勾選 " + id + "]\n若要改變核可狀態, 請輸入請購備註:") console.log("checkbox_confirm_true: " + checkbox_confirm_true) if (checkbox_confirm_true == '') { $('#' + id + '_PRcheck').prop('checked', false); alert("未輸入內容, 核可狀態未修改") } else if (checkbox_confirm_true == null) { $('#' + id + '_PRcheck').prop('checked', false); alert("取消, 核可狀態未修改") } else { var old_remark = document.getElementById(id + '_PRremark'); var old_remark_data = old_remark.innerHTML; var new_remark_data = USER_NAME + " (" + Today.getFullYear()+ "/" + two((Today.getMonth()+1)) + "/" + two(Today.getDate()) + " " + two(Today.getHours()) + ":" + two(Today.getMinutes()) + ":" + two(Today.getSeconds()) + ") 說:" + "[核可勾選] " + checkbox_confirm_true; sql = 'UPDATE ' + PR_Form_number + ' SET `請購核可`="1"' + ', `請購備註`="' + old_remark_data + new_remark_data + '<br>' + '"' + ' WHERE `內部料號`="' + id + '";'; var sql_data = { "sql":sql }; console.log("sql") $.ajax({ type:"GET", url:"/sql_get", dataType:"JSON", data:sql_data, async:false, success:function (res) { alert("請購單 " + PR_Form_number + " : " + id + " 請購備註修改成功 !") location.reload() }, error: function (thrownError) { if (thrownError.statusText == "INTERNAL SERVER ERROR") { alert("請購單 " + PR_Form_number + " : " + PR_id + " 請購備註未修改") } else { alert("修改請購單請購備註內容 thrownError" + thrownError) } } }) } } else { // 主管不核可 從勾選到空白 var checkbox_confirm_false = prompt("[取消 " + id + "]\n若要改變核可狀態, 請輸入請購備註:") console.log("checkbox_confirm_false: " + checkbox_confirm_false) if (checkbox_confirm_false == '') { $('#' + id + '_PRcheck').prop('checked', true); alert("未輸入內容, 核可狀態未修改") } else if (checkbox_confirm_false == null) { $('#' + id + '_PRcheck').prop('checked', true); alert("取消, 核可狀態未修改") } else { var old_remark = document.getElementById(id + '_PRremark'); var old_remark_data = old_remark.innerHTML; var new_remark_data = USER_NAME + " (" + Today.getFullYear()+ "/" + two((Today.getMonth()+1)) + "/" + two(Today.getDate()) + " " + two(Today.getHours()) + ":" + two(Today.getMinutes()) + ":" + two(Today.getSeconds()) + ") 說:" + "[核可取消] " + checkbox_confirm_false; sql = 'UPDATE ' + PR_Form_number + ' SET `請購核可`="0"' + ', `請購備註`="' + old_remark_data + new_remark_data + '<br>' + '"' + ' WHERE `內部料號`="' + id + '";'; var sql_data = { "sql":sql }; console.log("sql") $.ajax({ type:"GET", url:"/sql_get", dataType:"JSON", data:sql_data, async:false, success:function (res) { alert("請購單 " + PR_Form_number + " : " + id + " 請購備註修改成功 !") location.reload() }, error: function (thrownError) { if (thrownError.statusText == "INTERNAL SERVER ERROR") { alert("請購單 " + PR_Form_number + " : " + PR_id + " 請購備註未修改") } else { alert("修改請購單請購備註內容 thrownError" + thrownError) } } }) } } } // 採購人員 修改採購公司 function Purchase_update_sup() { var purchase_company = prompt("請注意 ! 輸入採購公司後將無法修改 ! \n\n請輸入採購公司 :\nT01 : 金子進\nT02 : 瑞智") console.log("purchase_company: " + purchase_company) var new_PR_companyid = PR_Form_number.substring(0, 8) + purchase_company; console.log("new_PR_companyid: " + new_PR_companyid) sql = "RENAME TABLE `" + PR_Form_number + "` TO `" + new_PR_companyid + "`"; sql_data = { "sql":sql }; console.log("Purchase_update_sup[sql]:" + sql) $.ajax({ type:"GET", url:"/sql_get", dataType:"JSON", data:sql_data, async:false, success:function (res) { alert("已將請購單更名為 " + new_PR_companyid + "") window.location.assign("/PR_user_" + new_PR_companyid) }, error: function (thrownError) { if (thrownError.statusText == "INTERNAL SERVER ERROR") { alert("請購單 " + PR_Form_number + ": 已存在") } else { alert("請購單更名錯誤 thrownError" + thrownError) } } }) } function insert_PR_item() { // var PR_title_list = ['id', 'name', 'type', 'amount', 'unit', 'picture', 'supplier', 'hyperlink', 'PRperson', 'check', 'PRremark'] var PR_id = $("#PR_id").val() var PR_amount = $("#PR_amount").val() var PR_unit = $("#PR_unit").val() var PR_supplier = $("#PR_supplier").val() var PR_hyperlink = $("#PR_hyperlink").val() var PR_PRremark = $("#PR_PRremark").val() var PR_PRperson = $("#PR_PRperson").val() var PR_PRremark_data = USER_NAME + " (" + Today.getFullYear()+ "/" + two((Today.getMonth()+1)) + "/" + two(Today.getDate()) + " " + two(Today.getHours()) + ":" + two(Today.getMinutes()) + ":" + two(Today.getSeconds()) + ") 說:" + "[新增零件, 指派請購人為 " + PR_PRperson + " ] " + PR_PRremark + "<br>"; console.log("PR_id: " + PR_id) console.log("PR_amount: " + PR_amount) console.log("PR_unit: " + PR_unit) console.log("PR_supplier: " + PR_supplier) console.log("PR_hyperlink: " + PR_hyperlink) console.log("PR_PRremark_data: " + PR_PRremark_data) console.log("PR_PRperson: " + PR_PRperson) if (PR_id == "") { alert("新增時, 內部料號不可空白 !") } else { var sql = 'INSERT INTO `' + PR_Form_number + '` (內部料號, 日期, 數量, 連結, 請購人, 請購核可, 請購備註)' + ' VALUES ("' + PR_id + '", current_timestamp(), "' + PR_amount + '", "' + PR_hyperlink + '", "' + PR_PRperson + '", "' + '1' + '", "' + PR_PRremark_data + '");'; var sql_data = { "sql":sql }; console.log("insert_PR_item[sql]:" + sql) $.ajax({ type:"GET", url:"/sql_get", dataType:"JSON", data:sql_data, async:false, success:function (res) { console.log("res.sql_data: " + res.sql_data) if (res.sql_data != '') { alert(res.sql_data) } else { alert("請購單 " + PR_Form_number + " : " + PR_id + " 新增成功 !") location.reload() } }, error: function (thrownError) { if (thrownError.statusText == "INTERNAL SERVER ERROR") { alert("請購單 " + PR_Form_number + " : " + PR_id + " 未新增") } else { alert("新增請購單內容 thrownError" + thrownError) } } }) } } </script> </body> </html>