123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788 |
- <!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 USER_MANAGER = '{{user_manager}}'
- console.log("user_manager: " + USER_MANAGER);
- var FORM_STATUS = '{{form_status}}';
- var data_id = []; // 存放此資料表所有的內部料號
- // 取得現在時間 紀錄請購備註時使用
- var Today = new Date();
- // 顯示零件名稱標題用
- 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>
- <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;" 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>
- <!-- 請購人 -->
- {{user_name}}
- <!-- <input type="text" id="PR_PRperson" value="" style="height: 25px; width: 90px;"> -->
- </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 colspan="9"></td>
- <td>
- <input type="button" class="input-cond-action status-visible" value="送出→" onclick="PRuser_to_manager()">
- </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 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)
- 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) {
- 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 {
- textarea = '<input id="'+ id + '_' + PR_title_list[i] + '_ta' + '" value="' + old_name + '" style="height: 25px; width: 50px">';
- }
- if (PR_title_list[i] == 'hyperlink') {
- textarea += '<input type="button" value="OK" onclick="update_comfirm_PR_item(\'' + id + '\')">';
- }
- target_id.insertAdjacentHTML('beforeend', textarea);
- }
- }
- }
- // 修改請購單內項目 確認
- function update_comfirm_PR_item(id) {
- console.log("修改: " + id)
- var new_amount_value = $('#' + id + '_amount_ta').val();
- var new_hyperlink_value = $('#' + id + '_hyperlink_ta').val();
- sql = 'UPDATE ' + PR_Form_number + ' SET' +
- ' `數量`="' + new_amount_value + '"' +
- ', `連結`="' + new_hyperlink_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 PRuser_to_manager() {
- 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) {
- var confirm_check = confirm('內部料號 ' + data_id[i] + ' 未核可, 確定要繼續嗎 ?')
- if (!confirm_check) {
- return false;
- }
- }
- }
- var confirm_to_manager = confirm('本表單即將送出給直屬主管, 請點選[確定]送出表單')
- if (confirm_to_manager) {
- // 狀態更新為 請購核可中
- 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 ('" +
- USER_MANAGER + "','" +
- PR_Form_number + "','" +
- USER_NAME + " 已送出')";
- 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("已通知部門主管")
- window.location.assign("/PR_list")
- },
- error: function (thrownError) {
- if (thrownError.statusText == "INTERNAL SERVER ERROR") {
- alert("送出通知 未成功")
- } else {
- alert("送出通知 thrownError" + thrownError)
- }
- }
- })
- } else {
- alert("送出取消")
- }
-
- }
- // 採購人員 修改採購公司
- 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_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 + '", "' +
- USER_NAME + '", "' +
- '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>
|