123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191 |
- <!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">
-
- </head>
- <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_ID = '{{user_id}}';
- console.log("USER_ID: " + USER_ID);
- var USER_MANAGER = '{{user_manager}}';
- console.log("USER_MANAGER: " + USER_MANAGER);
- var next_PR_companyid = '0711' + '{{new_PR_companyid}}' + 'Txx';
- console.log("next_PR_companyid: " + next_PR_companyid)
- // $(document).ready(function() {
- // // $('#create_PR_table').attr("href", "/PR_user_" + next_PR_companyid);
- // });
- </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>
- <body>
- <div id="ERP_header">
- <!-- 匯入共同使用的 header.html 內容 -->
- {% include 'ERP_header.html' %}
- </div>
- <center><h6 style="margin: 20px;">請購單列表</h6></center>
- 目前使用者:{{user_name}}
-
- {% if notice_list != () %}
- <a href="/notice" target="_blank" style="color: #E43030;">
- <img src="../static/img/notice.png" style="vertical-align: super;" width="12" alt="有未讀的訊息!">
- </a>
- {% endif %}
- <br>
- <br>
- <input type="button" class="input-cond-action" id="create_PR_table" value="建立新請購單草稿" onclick="create_PR_table();"><br>
- <table class="table table-bordered" style="margin-top: 10px;">
- <tr>
- <th>現有請購單草稿</th>
- <th>狀態</th>
- <th>請購人</th>
- </tr>
- {% for table in PR_tables %}
- <tr>
- <!-- `請購草稿單號`,`表單狀態`,`員工列表`.`員工英文名字` -->
- <td><a href="/PR_user_{{table[0].replace('t', 'T')}}" target="_blank">{{table[0].replace('t', 'T')}}</a></td>
- <td>{{table[1]}}</td>
- <td>{{table[2]}}</td>
- </tr>
- {% endfor %}
- </table>
- </body>
- <script>
- var next_PR_companyid;
- var sql = "";
- function create_PR_table() {
- sql = "INSERT INTO `表單詳細資料`(`請購草稿單號`, `表單狀態`, `請購人員工編號`, `請購主管員工編號`, `採購主管員工編號`) " +
- "VALUES (" +
- "'" + next_PR_companyid + "'," +
- "'" + "請購申請中" + "'," +
- "'" + USER_ID + "'," +
- "'" + USER_MANAGER + "'," +
- "'" + "HRMA0001T01" + "')";
- var sql_data = { "sql":sql };
- console.log("sql: " + sql)
- $.ajax({
- type:"GET",
- url:"/sql_get",
- dataType:"JSON",
- data:sql_data,
- async:false,
- success:function (res) {
- alert("表單詳細資料建置完成, 將移動到請購單 : " + next_PR_companyid + "...")
- },
- error: function (thrownError) {
- if (thrownError.statusText == "INTERNAL SERVER ERROR") {
- alert("建立表單詳細資料 " + next_PR_companyid + " 未成功")
- } else {
- alert("建立表單詳細資料 thrownError" + next_PR_companyid)
- }
- }
- })
- sql = "CREATE TABLE `" + next_PR_companyid + "` ( " +
- "`內部料號` varchar(11) NOT NULL, " +
- "`日期` timestamp NOT NULL DEFAULT current_timestamp(), " +
- "`數量` varchar(11) NULL DEFAULT '', " +
- "`連結` varchar(2048) NULL DEFAULT '', " +
- "`採購公司` varchar(5) NULL DEFAULT '', " +
- "`請購備註` varchar(2048) NULL DEFAULT '', " +
- "`請購人` varchar(50) NULL DEFAULT '', " +
- "`請購核可` tinyint(1) NULL DEFAULT 1, " +
- "`單價` varchar(11) NULL DEFAULT '', " +
- "`幣別` varchar(10) NOT NULL DEFAULT 'TWD', " +
- "`營業稅` varchar(11) NULL DEFAULT '', " +
- "`總金額` varchar(11) NULL DEFAULT '', " +
- "`交期` varchar(11) NULL DEFAULT '', " +
- "`詢價備註` varchar(2048) NULL DEFAULT '', " +
- "`詢價單單號` varchar(11) NULL DEFAULT '', " +
- "`供應商報價單號` varchar(11) NULL DEFAULT '', " +
- "`採購主管核可` tinyint(1) NOT NULL DEFAULT 1, " +
- "`採購單號` varchar(11) NULL DEFAULT '', " +
- "PRIMARY KEY (內部料號)" +
- ") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;";
- var sql_data = { "sql":sql };
- console.log("sql: " + sql)
- $.ajax({
- type:"GET",
- url:"/sql_get",
- dataType:"JSON",
- data:sql_data,
- async:false,
- success:function (res) {
- window.location.href = '/PR_user_' + next_PR_companyid;
- },
- error: function (thrownError) {
- if (thrownError.statusText == "INTERNAL SERVER ERROR") {
- alert("建立請購單草稿 " + next_PR_companyid + " 未成功")
- } else {
- alert("建立請購單草稿 thrownError" + thrownError)
- }
- }
- })
- }
- </script>
- </html>
|