<?php
include_once '../src/inc/db/function.php';
?>
<!DOCTYPE html>

<head>
  <meta charset="utf-8">
  <meta content="width=device-width, initial-scale=1.0" name="viewport">

  <title>網路安全政策  </title>
  <?php include_once "admin_css.php";?>
  <!-- Change Password -->
  <script>
    showSidebar("sidebar", "webSecurity");
    
    window.onload = function() {
      // 检查 PHP 变量是否包含错误消息
      var errorMessage = "<?php echo $error; ?>";
      // 如果错误消息不为空，则显示警报消息
      if (errorMessage !== '') {
        alert(errorMessage);
      }
    };
 
    function escapeHtml(unsafe) {
      return unsafe
        .replace(/&/g, "&amp;")
        .replace(/</g, "&lt;")
        .replace(/>/g, "&gt;")
        .replace(/"/g, "&quot;")
        .replace(/'/g, "&#039;");
    }

    $(document).ready(function() {

      if ($("#rid").val() > 0) { // 如果是修改模式
        $("#saveButton").val("update");
        $("#deleteButton").css("display", "block");
      } else { // 如果是新增模式
        $("#saveButton").val("insert");
        $("#deleteButton").css("display", "none");
      }

    });
  </script>
</head>

<body>

  <!--BEGIN HEADER-->
  <?php include_once "template_header.php"; ?>
  <!--END HEADER-->

  <!--BEGIN SIDEBAR-->
  <?php include_once "template_sidebar.php"; ?>
  <!--END SIDEBAR-->

  <main id="main" class="main">

    <div class="pagetitle">
      <h1>網路安全政策</h1>
      <!--BEGIN BREADCRUMB-->
      <nav>
        <ol class="breadcrumb">
          <li class="breadcrumb-item active"><a href="webSecurity.php">網路安全政策</a></li>
        </ol>
      </nav>
      <!--END BREADCRUMB-->
    </div><!-- End Page Title -->

    <section class="section dashboard">
      <div class="card info-card sales-card">
        <div class="card-body">
          <form method="POST" action="" class="mt-4 mb-4" id="form1">
            <input type="hidden" id="act" name="act" value="" />
            <input type='hidden' id="rid" name='rid' value=''>            
            <input type="hidden" name="csrfToken" value="">
            <div class="row mb-3">
              <label for="txt_mod_code" class="col-md-2 col-form-label">名稱</label>
              <div class="col-md-10">
                <input type="text" class="form-control" id="txt_mod_code" name="mod_code" required>
              </div>
            </div>

            <div class="row mb-3">
              <label for="txt_mod_name" class="col-md-2 col-form-label">發布日期</label>
              <div class="col-md-10">
                <input type="password" class="form-control" id="txt_mod_name" name="mod_name" required>
              </div>
            </div>

            <div class="row mb-3">
              <label for="txt_mod_name" class="col-md-2 col-form-label">版本</label>
              <div class="col-md-10">
                <input type="password" class="form-control" id="txt_mod_name" name="mod_name" required>
              </div>
            </div>

            <div class="row mb-3">
              <label for="txt_mod_path" class="col-md-2 col-form-label">執行單位</label>
              <div class="col-md-10">
                <input type="text" class="form-control" id="txt_mod_path" name="mod_path" required>
              </div>
            </div>

            <div class="row mb-3">
              <label for="txt_mod_status" class="col-md-2 col-form-label">顯示狀態</label>
              <div class="col-md-4">
                <select class="form-select" id="txt_mod_status" name="mod_status">
                  <option value="Y">是</option>
                  <option value="N">否</option>
                </select>
              </div>
           
              <label for="txt_mod_icon" class="col-md-2 col-form-label">內容</label>
              <div class="col-md-4">
                <input type="text" class="form-control" id="txt_mod_icon" name="mod_icon">
              </div>
            </div>

            <?php //if ($add == "update") { ?>
              <div class="row mb-3 ">
                <label for="txt_ModiUser" class="col-md-2 col-form-label">操作員：</label>
                <div class="col-md-4">
                  <input class="form-control" type="text" id="txt_ModiUser" name="ModiUser" readonly />
                </div>
                <label for="txt_ModiUser" class="col-md-2 col-form-label">異動時間：</label>
                <div class="col-md-4">
                  <input class="form-control" type="text" id="txt_ModiDate" name="ModiDate" readonly />
                </div>
              </div>
            <?php //} ?>
            <hr>
            <div class="row ">
              <div class="col-md-3">
                <a class="btn btn-secondary w-100" id="cancelButton" href="webSecurity.php" role="button">取消</a>
              </div>
              <div class="col-md-3">
                  <button type="button add" id="deleteButton" name="action" value="" class="btn btn-danger" onclick="deleteDialog()">
                    刪除
                  </button>
              </div>
              <div class="col-md-6 text-center">
                <button type="submit" id="saveButton" name="action" value="" class="btn btn-info">
                  儲存
                </button>
              </div>
            </div>

          </form>
        </div>
      </div>
    </section>

  </main><!-- End #main -->

  <!--BEGIN FOOTER-->
  <?php include_once "template_footer.php"; ?>
  <!--END FOOTER-->

  <a href="#" class="back-to-top d-flex align-items-center justify-content-center"><i class="bi bi-arrow-up-short"></i></a>

  <!-- Template Main JS File -->
  <script src="../assets/js/main.js"></script>

  <script>
    // 確認是否刪除
    function deleteDialog(id) 
    {
      if (id < 0) {

        return false;

      }
      if (confirm(" 是否確定刪除?") == false) {

        return false;
        
      } else {

        var saveButton = document.getElementById('deleteButton');
        saveButton.value = 'delete';

        // 提交表单
        document.getElementById('form1').submit();

      }

    }
  </script>

</body>

</html>