<?php
    include('session.php');
?>

<?php

    date_default_timezone_set('Asia/Singapore');

    $month = date('m');
    $day = date('d');
    $strmonth = date('m');
    $year = date('Y');

    $todaydate =  date('Y') . '-' . date('m') . '-' . date('d');
    $todaydatedisplay =  date('d') . '-' . date('m') . '-' . date('Y');
    
    $d = cal_days_in_month(CAL_GREGORIAN,date('m'),date('Y'));

    $begindate = date('Y') . '-' . date('m') . '-' .'01';
    $begindate = date('Y') . '-' . "01" . '-' .'01';
    $enddate = date('Y') . '-' . date('m') . '-' .$d;

    $displaybegindate = "01-". date('m') . '-' . date('Y');
    $displayenddate = $d."-". date('m') . '-' . date('Y') ;

?>

<?php
     if($_SERVER["REQUEST_METHOD"] == "POST")
    {
          if (isset($_POST['savePayment']))
          {
              $strpayment = strtoupper($_POST['payment']);
              $tmpuserid = $login_index;
              
              $sql = "INSERT INTO $tblpayments (Description, UserID) VALUES (?, ?)";

              $stmt = mysqli_prepare($conn, $sql);

              mysqli_stmt_bind_param($stmt, "ss", $strpayment, $tmpuserid);
              
              if (mysqli_stmt_execute($stmt)) {
                  $msg = "Payment Record Saved!";
                  $_SESSION['status_message'] = $msg;
                  echo "<script>alert('" . $msg . "');</script>";
              } else {
                  $msg = "ERROR : Save Payment Record!";
                  $_SESSION['status_message'] = $msg;
                  echo "<script>alert('" . $msg . "');</script>";
              }

              mysqli_stmt_close($stmt);

            }
            else if (isset($_POST['updatePayment']))
              {
                  $strcodeid = mysqli_real_escape_string($conn,strtoupper($_POST['recordid']));
                  $strpayment = mysqli_real_escape_string($conn,strtoupper($_POST['payment']));

                  $tmpuserid = $login_index;
                
                  $sql = "SELECT * FROM $tblpayments WHERE AutoIndex = '$strcodeid'";

                  $result = mysqli_query($conn, $sql);
                  $num_rows = mysqli_num_rows($result);

                  if ($num_rows <= 0)
                  {
                      $msg = "ERROR : Payment Record ID : $strcodeid NOT EXIST!";
                      $_SESSION['status_message'] = $msg;
                      echo "<script>alert('" . $msg . "');</script>";
                  }
                  else
                  {
                      
                  $tmpuserid = $login_session;
                      
                      $sql = "UPDATE $tblpayments SET Description = '$strpayment' WHERE AutoIndex LIKE '$strcodeid'";
                      
                      if ($conn->query($sql) === TRUE) {
                          $msg = "Payment Record Updated!";
                          $_SESSION['status_message'] = $msg;
                          echo "<script>alert('" . $msg . "');</script>";
                      } else {
                          $msg = "ERROR : Update Payment Record!";
                          $_SESSION['status_message'] = $msg;
                          echo "<script>alert('" . $msg . "');</script>";
                      }
                  }
                  
              }
            else if (isset($_POST['deletePayment']))
              {
                  $strcodeid = strtoupper($_POST['recordid']);
                  
                  $sql=mysqli_query($conn,"SELECT * FROM $tblpayments WHERE AutoIndex LIKE '$strcodeid'");

                  $num_rows = mysqli_num_rows($sql);

                  if ($num_rows <= 0)
                  {
                      $msg = "ERROR : Payment Record ID : $strcodeid NOT EXIST!";
                      $_SESSION['status_message'] = $msg;
                      echo "<script>alert('" . $msg . "');</script>";
                  }
                  else
                  {
                      
                      $tmpuserid = $login_session;
                      
                      $sql = "DELETE FROM $tblpayments WHERE AutoIndex LIKE '$strcodeid'";
                      
                      if ($conn->query($sql) === TRUE) {
                          $msg = "Payment Record Deleted!";
                          $_SESSION['status_message'] = $msg;
                          echo "<script>alert('" . $msg . "');</script>";
                      } else {
                          $msg = "ERROR : Delete Payment Record!";
                          $_SESSION['status_message'] = $msg;
                          echo "<script>alert('" . $msg . "');</script>";
                      }
                  }
              }
            else if (isset($_POST['saveWA']))
            {
                $strwa = strtoupper($_POST['wadesc']);
                $tmpuserid = $login_index;
                
                $sql = "INSERT INTO $tblwtanalysis (Description, UserID) VALUES (?, ?)";

                $stmt = mysqli_prepare($conn, $sql);

                mysqli_stmt_bind_param($stmt, "ss", $strwa, $tmpuserid);
                
                if (mysqli_stmt_execute($stmt)) {
                    $msg = "Weight & Analysis Record Saved!";
                    $_SESSION['status_message'] = $msg;
                    echo "<script>alert('" . $msg . "');</script>";
                } else {
                    $msg = "ERROR : Save Weight & Analysis Record!";
                    $_SESSION['status_message'] = $msg;
                    echo "<script>alert('" . $msg . "');</script>";
                }

                mysqli_stmt_close($stmt);

              }
            else if (isset($_POST['updateWA']))
              {
                  $strcodeid = mysqli_real_escape_string($conn,strtoupper($_POST['recordid']));
                  $strwa = mysqli_real_escape_string($conn,strtoupper($_POST['wadesc']));

                  $tmpuserid = $login_index;
                
                  $sql = "SELECT * FROM $tblwtanalysis WHERE AutoIndex = '$strcodeid'";

                  $result = mysqli_query($conn, $sql);
                  $num_rows = mysqli_num_rows($result);

                  if ($num_rows <= 0)
                  {
                      $msg = "ERROR : Weight & Analysis Record ID : $strcodeid NOT EXIST!";
                      $_SESSION['status_message'] = $msg;
                      echo "<script>alert('" . $msg . "');</script>";
                  }
                  else
                  {
                      
                  $tmpuserid = $login_session;
                      
                      $sql = "UPDATE $tblwtanalysis SET Description = '$strwa' WHERE AutoIndex LIKE '$strcodeid'";
                      
                      if ($conn->query($sql) === TRUE) {
                          $msg = "Weight & Analysis Record Updated!";
                          $_SESSION['status_message'] = $msg;
                          echo "<script>alert('" . $msg . "');</script>";
                      } else {
                          $msg = "ERROR : Update Weight & Analysis Record!";
                          $_SESSION['status_message'] = $msg;
                          echo "<script>alert('" . $msg . "');</script>";
                      }
                  }
                  
              }
            else if (isset($_POST['deleteWA']))
              {
                  $strcodeid = strtoupper($_POST['recordid']);
                  
                  $sql=mysqli_query($conn,"SELECT * FROM $tblwtanalysis WHERE AutoIndex LIKE '$strcodeid'");

                  $num_rows = mysqli_num_rows($sql);

                  if ($num_rows <= 0)
                  {
                      $msg = "ERROR : Weight & Analysis Record ID : $strcodeid NOT EXIST!";
                      $_SESSION['status_message'] = $msg;
                      echo "<script>alert('" . $msg . "');</script>";
                  }
                  else
                  {
                      
                      $tmpuserid = $login_session;
                      
                      $sql = "DELETE FROM $tblwtanalysis WHERE AutoIndex LIKE '$strcodeid'";
                      
                      if ($conn->query($sql) === TRUE) {
                          $msg = "Weight & Analysis Record Deleted!";
                          $_SESSION['status_message'] = $msg;
                          echo "<script>alert('" . $msg . "');</script>";
                      } else {
                          $msg = "ERROR : Delete Weight & Analysis Record!";
                          $_SESSION['status_message'] = $msg;
                          echo "<script>alert('" . $msg . "');</script>";
                      }
                  }
              }
     }

?>



<!DOCTYPE html>
<html lang="en" class="h-100">
	<head>
		<meta charset="utf-8">
		<meta http-equiv="X-UA-Compatible" content="IE=edge">
		<meta name="viewport" content="width=device-width, shrink-to-fit=9">
		<meta name="description" content="STC Digital">
		<meta name="author" content="STC Digital">
        <title><?php echo $sitetitle ?></title>
		
		<!-- Favicon Icon -->
        <link rel="icon" type="image/png" href="images/logo.png">
		
        <!-- Stylesheets -->
        <?php include 'plugincss.php' ?>
        <link rel="stylesheet" href="https://cdn.datatables.net/1.10.24/css/jquery.dataTables.min.css">


	</head>

<body class="d-flex flex-column h-100">

    <!-- Payment-->
    <div class="modal fade" id="AddPayment" tabindex="-1" aria-labelledby="AddPaymentLabel" aria-hidden="false">
        <div class="modal-dialog modal-lg">
            <div class="modal-content">
                <div class="modal-header">
                    <h5 class="modal-title" id="AddRecordsLabel">Payment Description</h5>
                    <button type="button" class="close-model-btn" data-bs-dismiss="modal" aria-label="Close"><i class="uil uil-multiply"></i></button>
                </div>
                <form class="form" method="post" action="">
                    <div class="modal-body">
                        <div class="model-content main-form">
                            <div class="row">
                                <div class="model-content main-form">
                                    <div class="row">
                                        <div class="col-lg-12 col-md-12">
                                            <div class="form-group mt-4">
                                                <label class="form-label">Description</label>
                                                <input class="form-control h_40" id="payment" name="payment" type="text">
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="modal-footer">
                            <input type="hidden" name="action" id="action" value="savePayment" />
                            <button type="button" class="btn btn-warning" data-bs-toggle="modal" data-bs-dismiss="modal"><i class="fa-solid fa-cancel me-3"></i>Cancel</button>
                            <button type="submit" class="btn btn-success" id = "savePayment" name = "savePayment"><i class="fa-solid fa-save me-3"></i>Save</button>
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>

    <!-- WA-->
    <div class="modal fade" id="AddWA" tabindex="-1" aria-labelledby="AddWALabel" aria-hidden="false">
        <div class="modal-dialog modal-lg">
            <div class="modal-content">
                <div class="modal-header">
                    <h5 class="modal-title" id="AddWALabel">Weight & Analysis Description</h5>
                    <button type="button" class="close-model-btn" data-bs-dismiss="modal" aria-label="Close"><i class="uil uil-multiply"></i></button>
                </div>
                <form class="form" method="post" action="">
                    <div class="modal-body">
                        <div class="model-content main-form">
                            <div class="row">
                                <div class="model-content main-form">
                                    <div class="row">
                                        <div class="col-lg-12 col-md-12">
                                            <div class="form-group mt-4">
                                                <label class="form-label">Description</label>
                                                <input class="form-control h_40" id="wadesc" name="wadesc" type="text">
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="modal-footer">
                            <input type="hidden" name="action" id="action" value="saveWA" />
                            <button type="button" class="btn btn-warning" data-bs-toggle="modal" data-bs-dismiss="modal"><i class="fa-solid fa-cancel me-3"></i>Cancel</button>
                            <button type="submit" class="btn btn-success" id = "saveWA" name = "saveWA"><i class="fa-solid fa-save me-3"></i>Save</button>
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>



	<!-- Add Organisation Model End-->
	<!-- Header Start-->
	<header class="header">
        <?php include 'topmenu.php' ?>
	</header>
	<!-- Header End-->
	<!-- Left Sidebar Start -->
	<nav class="vertical_nav">
        <?php include 'sidemenu-cms.php' ?>
	</nav>



	<!-- Left Sidebar End -->
	<!-- Body Start -->
	<div class="wrapper wrapper-body">
		<div class="dashboard-body">
			<div class="container-fluid">
				<div class="row">
					<div class="col-md-12">
						<div class="d-main-title">
							<h3>Settings</h3>
						</div>
					</div>

                    <h1></h1>
                    <h1></h1>
                    <br>

                        <div class="col-md-12">
                            <div class="d-md-flex flex-wrap align-items-center">
                                <h4>Payments</h4>
                                <div class="rs ms-auto mt_r4">
                                    <button class="btn btn-success" data-bs-toggle="modal" data-bs-target="#AddPayment">New</button>
                                </div>

                            </div>
                        </div>

                        <div class="event-list">
                            <div class="tab-content">
                                <div class="tab-pane fade show active" id="orders-tab" role="tabpanel">
                                    <div class="table-card mt-4">
                                        <div class="main-table">
                                            <div class="table-responsive">
                                                <table id="dataTable" class="table">
                                                    <thead class="thead-dark">
                                                        <tr>
                                                            <th scope="col" style="width: 10%;">#</th>
                                                            <th scope="col" style="width: 80%;">Description</th>
                                                            <th scope="col" style="width: 10%;">Action</th>
                                                        </tr>
                                                    </thead>
                                                    <tbody>
                                                        <?php
                                                                $i=0;

                                                                $sql = "SELECT * FROM $tblpayments ORDER BY AutoIndex DESC";


                                                                   if($result=mysqli_query($conn,$sql)){
                                                                        while ($row=mysqli_fetch_array($result)){
                                                                            $i=$i+1;
                                                                        
                                                                    ?>
                                                                        <tr>
                                                                            <td align = "left"><?php echo $i?></td>
                                                                            <td align = "left"><?php echo $row['Description'] ;?></td>
                                                                            
                                                                            <td align ="left">
                                                                            <button type="button" id = "btnView" name = "btnView" class="btn btn-secondary" data-bs-toggle="modal" data-bs-target="#viewPayment<?php echo $row['AutoIndex']?>"><i class="fa-regular fa-eye"></i></button>
                                                                            
                                                                            <button type="button" id = "btnUpdate" name = "btnUpdate" class="btn btn-secondary" data-bs-toggle="modal" data-bs-target="#editPayment<?php echo $row['AutoIndex']?>"><i class="fa-regular fa-pen"></i></button>
                                                                             
                                                                            <!-- Create Coupon Model Start-->
                                                                            <div class="modal fade" id="viewPayment<?php echo $row['AutoIndex']?>" tabindex="-1" aria-labelledby="viewPaymentLabel<?php echo $row['AutoIndex']?>" aria-hidden="false">
                                                                                <div class="modal-dialog modal-lg">
                                                                                    <div class="modal-content">
                                                                                        <div class="modal-header">
                                                                                            <h5 class="modal-title" id="editPaymentLabel<?php echo $row['AutoIndex']?>">Payment</h5>
                                                                                            <button type="button" class="close-model-btn" data-bs-dismiss="modal" aria-label="Close"><i class="uil uil-multiply"></i></button>
                                                                                        </div>
                                                                                            <form class="form" method="post" action="">
                                                                                                <div class="modal-body">
                                                                                                    <div class="model-content main-form">
                                                                                                        <div class="row">
                                                                                                                <div class="model-content main-form">
                                                                                                                    <div class="row">
                                                                                                                        <div class="form-group mt-4">
                                                                                                                            <input class="form-control h_40" id="recordid" name="recordid" type="hidden" value="<?php echo $row['AutoIndex'];?>">
                                                                                                                        </div>
                                                                                                                        <div class="col-lg-12 col-md-12">
                                                                                                                            <div class="form-group mt-4">
                                                                                                                                <label class="form-label">Description</label>
                                                                                                                                <input class="form-control h_40" id="payment" name="payment" type="text" value="<?php echo $row['Description'];?>" readonly>
                                                                                                                            </div>
                                                                                                                        </div>
                                                                                                                        

                                                                                                                    </div>
                                                                                                                </div>
                                                                                                            </div>
                                                                                                        </div>
                                                                                                        <div class="modal-footer">
                                                                                                            <input type="hidden" name="action" id="action" value="saveRecord" />
                                                                                                            <button type="button" class="btn btn-warning" data-bs-toggle="modal" data-bs-dismiss="modal"><i class="fa-solid fa-cancel me-3"></i>Cancel</button>
                                                                                                        </div>
                                                                                                    </div>
                                                                                                </div>
                                                                                                </form>
                                                                                                </div>
                                                                                            </div>
                                                                                            </div>
                                                                            
                                                                                <!-- Create Coupon Model Start-->
                                                                                <div class="modal fade" id="editPayment<?php echo $row['AutoIndex']?>" tabindex="-1" aria-labelledby="editPaymentLabel<?php echo $row['AutoIndex']?>" aria-hidden="false">
                                                                                    <div class="modal-dialog modal-lg">
                                                                                        <div class="modal-content">
                                                                                            <div class="modal-header">
                                                                                                <h5 class="modal-title" id="editPaymentLabel<?php echo $row['AutoIndex']?>">Payment</h5>
                                                                                                <button type="button" class="close-model-btn" data-bs-dismiss="modal" aria-label="Close"><i class="uil uil-multiply"></i></button>
                                                                                            </div>
                                                                                                    <form class="form" method="post" action="">
                                                                                                        <div class="modal-body">
                                                                                                            <div class="model-content main-form">
                                                                                                                <div class="row">
                                                                                                                        <div class="model-content main-form">
                                                                                                                            <div class="row">
                                                                                                                                    <div class="form-group mt-4">
                                                                                                                                        <input class="form-control h_40" id="recordid" name="recordid" type="hidden" value="<?php echo $row['AutoIndex'];?>">
                                                                                                                                    </div>
                                                                                                                                    <div class="col-lg-12 col-md-12">
                                                                                                                                        <div class="form-group mt-4">
                                                                                                                                            <label class="form-label">Description</label>
                                                                                                                                            <input class="form-control h_40" id="payment" name="payment" type="text" value="<?php echo $row['Description'];?>">
                                                                                                                                        </div>
                                                                                                                                    </div>
                                                                                                                                    
                                                                                                                            </div>
                                                                                                                        </div>
                                                                                                                    </div>
                                                                                                                </div>
                                                                                                                <div class="modal-footer">
                                                                                                                    <button type="button" class="btn btn-warning" data-bs-toggle="modal" data-bs-dismiss="modal"><i class="fa-solid fa-cancel me-3"></i>Cancel</button>
                                                                                                                    <button type="submit" class="btn btn-danger" id = "deletePayment" name = "deletePayment"><i class="fa-solid fa-trash me-3"></i>Delete</button>
                                                                                                                    <button type="submit" class="btn btn-success" id = "updatePayment" name = "updatePayment"><i class="fa-solid fa-save me-3"></i>Update</button>
                                                                                                                </div>
                                                                                                            </div>
                                                                                                        </div>
                                                                                                    </form>
                                                                                    </div>
                                                                                </div>
                                                                                </div>
                                                                            
                                                                            </td>
                                                                        </tr>
                                                                <?php
                                                                }
                                                                   }

                                                                ?>
                                                       </tbody>
                                                    <tfoot>
                                                        <tr>
                                                            <th scope="col" style="width: 10%;">#</th>
                                                            <th scope="col" style="width: 80%;">Description</th>
                                                            <th scope="col" style="width: 10%;">Action</th>
                                                        </tr>
                                                    </tfoot>

                                                </table>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>

                        <h1></h1>
                        <h1></h1>
                        <br>
                        
                        <div class="col-md-12">
                            <div class="d-md-flex flex-wrap align-items-center">
                                <h4>Weight & Analysis</h4>
                                <div class="rs ms-auto mt_r4">
                                    <button class="btn btn-success" data-bs-toggle="modal" data-bs-target="#AddWA">New</button>
                                </div>

                            </div>
                        </div>

                        <div class="event-list">
                            <div class="tab-content">
                                <div class="tab-pane fade show active" id="orders-tab" role="tabpanel">
                                    <div class="table-card mt-4">
                                        <div class="main-table">
                                            <div class="table-responsive">
                                                <table id="dataTable" class="table">
                                                    <thead class="thead-dark">
                                                        <tr>
                                                            <th scope="col" style="width: 10%;">#</th>
                                                            <th scope="col" style="width: 80%;">Description</th>
                                                            <th scope="col" style="width: 10%;">Action</th>
                                                        </tr>
                                                    </thead>
                                                    <tbody>
                                                        <?php
                                                                $i=0;

                                                                $sql = "SELECT * FROM $tblwtanalysis ORDER BY AutoIndex DESC";
                                                                    
                                                                   if($result=mysqli_query($conn,$sql)){
                                                                        while ($row=mysqli_fetch_array($result)){
                                                                            $i=$i+1;
                                                                        
                                                                    ?>
                                                                        <tr>
                                                                            <td align = "left"><?php echo $i?></td>
                                                                            <td align = "left"><?php echo $row['Description'] ;?></td>
                                                                            
                                                                            <td align ="left">
                                                                            <button type="button" id = "btnView" name = "btnView" class="btn btn-secondary" data-bs-toggle="modal" data-bs-target="#viewWA<?php echo $row['AutoIndex']?>"><i class="fa-regular fa-eye"></i></button>
                                                                            
                                                                            <button type="button" id = "btnUpdate" name = "btnUpdate" class="btn btn-secondary" data-bs-toggle="modal" data-bs-target="#editWA<?php echo $row['AutoIndex']?>"><i class="fa-regular fa-pen"></i></button>
                                                                             
                                                                            <!-- Create Coupon Model Start-->
                                                                            <div class="modal fade" id="viewWA<?php echo $row['AutoIndex']?>" tabindex="-1" aria-labelledby="viewWALabel<?php echo $row['AutoIndex']?>" aria-hidden="false">
                                                                                <div class="modal-dialog modal-lg">
                                                                                    <div class="modal-content">
                                                                                        <div class="modal-header">
                                                                                            <h5 class="modal-title" id="viewWALabel<?php echo $row['AutoIndex']?>">Weight & Analysis</h5>
                                                                                            <button type="button" class="close-model-btn" data-bs-dismiss="modal" aria-label="Close"><i class="uil uil-multiply"></i></button>
                                                                                        </div>
                                                                                            <form class="form" method="post" action="">
                                                                                                <div class="modal-body">
                                                                                                    <div class="model-content main-form">
                                                                                                        <div class="row">
                                                                                                                <div class="model-content main-form">
                                                                                                                    <div class="row">
                                                                                                                        <div class="form-group mt-4">
                                                                                                                            <input class="form-control h_40" id="recordid" name="recordid" type="hidden" value="<?php echo $row['AutoIndex'];?>">
                                                                                                                        </div>
                                                                                                                        <div class="col-lg-12 col-md-12">
                                                                                                                            <div class="form-group mt-4">
                                                                                                                                <label class="form-label">Description</label>
                                                                                                                                <input class="form-control h_40" id="wadesc" name="wadesc" type="text" value="<?php echo $row['Description'];?>" readonly>
                                                                                                                            </div>
                                                                                                                        </div>
                                                                                                                    </div>
                                                                                                                </div>
                                                                                                            </div>
                                                                                                        </div>
                                                                                                        <div class="modal-footer">
                                                                                                            <input type="hidden" name="action" id="action" value="saveRecord" />
                                                                                                            <button type="button" class="btn btn-warning" data-bs-toggle="modal" data-bs-dismiss="modal"><i class="fa-solid fa-cancel me-3"></i>Cancel</button>
                                                                                                        </div>
                                                                                                    </div>
                                                                                                </div>
                                                                                                </form>
                                                                                                </div>
                                                                                            </div>
                                                                                            </div>
                                                                            
                                                                                <!-- Create Coupon Model Start-->
                                                                                <div class="modal fade" id="editWA<?php echo $row['AutoIndex']?>" tabindex="-1" aria-labelledby="editWALabel<?php echo $row['AutoIndex']?>" aria-hidden="false">
                                                                                    <div class="modal-dialog modal-lg">
                                                                                        <div class="modal-content">
                                                                                            <div class="modal-header">
                                                                                                <h5 class="modal-title" id="editRecordLabel<?php echo $row['AutoIndex']?>">Weight & Analysis</h5>
                                                                                                <button type="button" class="close-model-btn" data-bs-dismiss="modal" aria-label="Close"><i class="uil uil-multiply"></i></button>
                                                                                            </div>
                                                                                                    <form class="form" method="post" action="">
                                                                                                        <div class="modal-body">
                                                                                                            <div class="model-content main-form">
                                                                                                                <div class="row">
                                                                                                                        <div class="model-content main-form">
                                                                                                                            <div class="row">
                                                                                                                                    <div class="form-group mt-4">
                                                                                                                                        <input class="form-control h_40" id="recordid" name="recordid" type="hidden" value="<?php echo $row['AutoIndex'];?>">
                                                                                                                                    </div>
                                                                                                                                    <div class="col-lg-12 col-md-12">
                                                                                                                                        <div class="form-group mt-4">
                                                                                                                                            <label class="form-label">Description</label>
                                                                                                                                            <input class="form-control h_40" id="wadesc" name="wadesc" type="text" value="<?php echo $row['Description'];?>">
                                                                                                                                        </div>
                                                                                                                                    </div>
                                                                                                                                    
                                                                                                                            </div>
                                                                                                                        </div>
                                                                                                                    </div>
                                                                                                                </div>
                                                                                                                <div class="modal-footer">
                                                                                                                    <button type="button" class="btn btn-warning" data-bs-toggle="modal" data-bs-dismiss="modal"><i class="fa-solid fa-cancel me-3"></i>Cancel</button>
                                                                                                                    <button type="submit" class="btn btn-danger" id = "deleteWA" name = "deleteWA"><i class="fa-solid fa-trash me-3"></i>Delete</button>
                                                                                                                    <button type="submit" class="btn btn-success" id = "updateWA" name = "updateWA"><i class="fa-solid fa-save me-3"></i>Update</button>
                                                                                                                </div>
                                                                                                            </div>
                                                                                                        </div>
                                                                                                    </form>
                                                                                    </div>
                                                                                </div>
                                                                                </div>
                                                                            
                                                                            </td>
                                                                        </tr>
                                                                <?php
                                                                }
                                                                   }

                                                                ?>
                                                       </tbody>
                                                    <tfoot>
                                                        <tr>
                                                            <th scope="col" style="width: 10%;">#</th>
                                                            <th scope="col" style="width: 80%;">Description</th>
                                                            <th scope="col" style="width: 10%;">Action</th>
                                                        </tr>
                                                    </tfoot>

                                                </table>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>

                        <h1></h1>
                        <h1></h1>
                        <br>

                        <div class="col-md-12">
                            <div class="d-md-flex flex-wrap align-items-center">
                                <h4>Company Stamp</h4>
                                <div class="rs ms-auto mt_r4">
                                    <button class="btn btn-success" data-bs-toggle="modal" data-bs-target="#AddStamp" hidden>New</button>
                                </div>

                            </div>
                        </div>

                        <div class="event-list">
                            <div class="tab-content">
                                <div class="tab-pane fade show active" id="orders-tab" role="tabpanel">
                                    <div class="table-card mt-4">
                                        <div class="main-table">
                                            <div class="table-responsive">
                                                <table id="dataTable" class="table">
                                                    <thead class="thead-dark">
                                                        <tr>
                                                            <th scope="col" style="width: 10%;">#</th>
                                                            <th scope="col" style="width: 80%;">Stamp</th>
                                                            <th scope="col" style="width: 10%;">Action</th>
                                                        </tr>
                                                    </thead>
                                                    <tbody>
                                                        <?php
                                                                $i=0;

                                                                    $sql = "SELECT * FROM $tblseal ORDER BY AutoIndex DESC";

                                                                   if($result=mysqli_query($conn,$sql)){
                                                                        while ($row=mysqli_fetch_array($result)){
                                                                            $i=$i+1;
                                                                        
                                                                    ?>
                                                                        <tr>
                                                                            <td align = "left"><?php echo $i?></td>
                                                                            <td align = "left"><?php echo $row['FilePath'] ;?></td>
                                                                           
                                                                            
                                                                            <td align ="left">
                                                                            <button type="button" id = "btnView" name = "btnView" class="btn btn-secondary" data-bs-toggle="modal" data-bs-target="#viewStamp<?php echo $row['AutoIndex']?>"><i class="fa-regular fa-eye"></i></button>
                                                                            
                                                                            <button type="button" id = "btnUpdate" name = "btnUpdate" class="btn btn-secondary" data-bs-toggle="modal" data-bs-target="#editStamp<?php echo $row['AutoIndex']?>"><i class="fa-regular fa-pen"></i></button>
                                                                             
                                                                            <!-- Create Coupon Model Start-->
                                                                            <div class="modal fade" id="viewStamp<?php echo $row['AutoIndex']?>" tabindex="-1" aria-labelledby="viewStampLabel<?php echo $row['AutoIndex']?>" aria-hidden="false">
                                                                                <div class="modal-dialog modal-lg">
                                                                                    <div class="modal-content">
                                                                                        <div class="modal-header">
                                                                                            <h5 class="modal-title" id="editStampLabel<?php echo $row['AutoIndex']?>">Stamp URL</h5>
                                                                                            <button type="button" class="close-model-btn" data-bs-dismiss="modal" aria-label="Close"><i class="uil uil-multiply"></i></button>
                                                                                        </div>
                                                                                            <form class="form" method="post" action="">
                                                                                                <div class="modal-body">
                                                                                                    <div class="model-content main-form">
                                                                                                        <div class="row">
                                                                                                                <div class="model-content main-form">
                                                                                                                    <div class="row">
                                                                                                                        <div class="form-group mt-4">
                                                                                                                            <input class="form-control h_40" id="recordid" name="recordid" type="hidden" value="<?php echo $row['AutoIndex'];?>">
                                                                                                                        </div>
                                                                                                                        <div class="col-lg-12 col-md-12">
                                                                                                                            <div class="form-group mt-4">
                                                                                                                                <label class="form-label">Stamp URL</label>
                                                                                                                                <input class="form-control h_40" id="stampdesc" name="stampdesc" type="text" value="<?php echo $row['FilePath'];?>" readonly>
                                                                                                                            </div>
                                                                                                                        </div>
                                                                                                                    </div>
                                                                                                                </div>
                                                                                                            </div>
                                                                                                        </div>
                                                                                                        <div class="modal-footer">
                                                                                                            <input type="hidden" name="action" id="action" value="saveRecord" />
                                                                                                            <button type="button" class="btn btn-warning" data-bs-toggle="modal" data-bs-dismiss="modal"><i class="fa-solid fa-cancel me-3"></i>Cancel</button>
                                                                                                        </div>
                                                                                                    </div>
                                                                                                </div>
                                                                                                </form>
                                                                                                </div>
                                                                                            </div>
                                                                                            </div>
                                                                            
                                                                                <!-- Create Coupon Model Start-->
                                                                                <div class="modal fade" id="editStamp<?php echo $row['AutoIndex']?>" tabindex="-1" aria-labelledby="editStampLabel<?php echo $row['AutoIndex']?>" aria-hidden="false">
                                                                                    <div class="modal-dialog modal-lg">
                                                                                        <div class="modal-content">
                                                                                            <div class="modal-header">
                                                                                                <h5 class="modal-title" id="editStampLabel<?php echo $row['AutoIndex']?>">Stamp Details</h5>
                                                                                                <button type="button" class="close-model-btn" data-bs-dismiss="modal" aria-label="Close"><i class="uil uil-multiply"></i></button>
                                                                                            </div>
                                                                                                    <form class="form" method="post" action="">
                                                                                                        <div class="modal-body">
                                                                                                            <div class="model-content main-form">
                                                                                                                <div class="row">
                                                                                                                        <div class="model-content main-form">
                                                                                                                            <div class="row">
                                                                                                                                    <div class="form-group mt-4">
                                                                                                                                        <input class="form-control h_40" id="recordid" name="recordid" type="hidden" value="<?php echo $row['AutoIndex'];?>">
                                                                                                                                    </div>
                                                                                                                                    <div class="col-lg-12 col-md-12">
                                                                                                                                        <div class="form-group mt-12">
                                                                                                                                            <label class="form-label">Stamp URL</label>
                                                                                                                                            <input class="form-control h_40" id="stampdesc" name="stampdesc" type="text" value="<?php echo $row['FilePath'];?>">
                                                                                                                                        </div>
                                                                                                                                    </div>
                                                                                                                            </div>
                                                                                                                        </div>
                                                                                                                    </div>
                                                                                                                </div>
                                                                                                                <div class="modal-footer">
                                                                                                                    <button type="button" class="btn btn-warning" data-bs-toggle="modal" data-bs-dismiss="modal"><i class="fa-solid fa-cancel me-3"></i>Cancel</button>
                                                                                                                    <button type="submit" class="btn btn-danger" id = "deleteStamp" name = "deleteStamp"><i class="fa-solid fa-trash me-3"></i>Delete</button>
                                                                                                                    <button type="submit" class="btn btn-success" id = "updateStamp" name = "updateStamp"><i class="fa-solid fa-save me-3"></i>Save</button>
                                                                                                                </div>
                                                                                                            </div>
                                                                                                        </div>
                                                                                                    </form>
                                                                                    </div>
                                                                                </div>
                                                                                </div>
                                                                            
                                                                            </td>
                                                                        </tr>
                                                                <?php
                                                                }
                                                                   }

                                                                ?>
                                                       </tbody>
                                                    <tfoot>
                                                        <tr>
                                                            <th scope="col" style="width: 10%;">#</th>
                                                            <th scope="col" style="width: 80%;">Stamp</th>
                                                            <th scope="col" style="width: 10%;">Action</th>
                                                        </tr>
                                                    </tfoot>

                                                </table>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>

                </div>
            </div>
        </div>
    </div>
	
    <div class="copyright-footer">
        <?php echo $copyrights ?>
    </div>

    <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
    <!-- Include DataTable JS -->
    <script src="https://cdn.datatables.net/1.10.24/js/jquery.dataTables.min.js"></script>
    <script>
        // Initialize DataTable
        $(document).ready(function() {
          $('#dataTable').DataTable({
                  "ordering": false,
                  "searching": false,
                  "lengthChange": false,
                  "pageLength": 10 // Set the number of rows per page
              });
        });
    </script>

	<!-- Body End -->
    <?php include 'pluginjs.php' ?>

</body>
</html>
