You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
232 lines
10 KiB
232 lines
10 KiB
<?php
|
|
ini_set('display_errors', 'on');
|
|
include "./header.php";
|
|
|
|
// 設置一個空陣列來放資料
|
|
$data = array();
|
|
// sql語法存在變數中
|
|
$sql = "select * from rib ";
|
|
|
|
// 是否為會計 阿娥
|
|
if (($user_id == "M0056" || $user_id == "M0209")) {
|
|
$sql .= "WHERE ((CurrentState =1) or (TransactId= '$user_id') or (WriteOffId='$user_id') or (GatheringPersonId='$user_id')) ORDER BY BillDate DESC ";
|
|
$query_data = mysqli_query($link, $sql);
|
|
} else {
|
|
|
|
// 找下屬
|
|
$follower = [];
|
|
$follower = find_follow('$user_id');
|
|
|
|
if (count($follower) > 0) {
|
|
echo "有下屬";
|
|
$column_str = "('$user_id'" . ",'";
|
|
$column_str .= implode("','", $follower);
|
|
$column_str .= "')";
|
|
$sql .= "WHERE ((TransactId in $column_str) or (WriteOffId in $column_str) or (GatheringPersonId in $column_str)) ORDER BY BillDate DESC ";
|
|
} else {
|
|
|
|
$sql .= "WHERE ((TransactId= '$user_id') or (WriteOffId='$user_id') or (GatheringPersonId='$user_id')) ORDER BY BillDate DESC ";
|
|
};
|
|
$query_data = mysqli_query($link, $sql);
|
|
}
|
|
// 取得部門代碼
|
|
$sql_depid = "SELECT department_id, name from department";
|
|
$dept_query = mysqli_query($link, $sql_depid);
|
|
$deptype = mysqli_fetch_all($dept_query, MYSQLI_ASSOC);
|
|
// $data = mysqli_fetch_all($query_data, MYSQLI_ASSOC);
|
|
for($i = 0; $i < mysqli_num_rows($query_data); $i++) {
|
|
$data[$i] = mysqli_fetch_assoc($query_data);
|
|
}
|
|
|
|
?>
|
|
<!--
|
|
新增單據 -->
|
|
<p>
|
|
<a href="rib01-create.php?<?php echo $token_link; ?>" class="btn btn-info btn-sm">
|
|
<span class="glyphicon glyphicon-plus"></span>
|
|
</a>
|
|
</p>
|
|
|
|
<?php
|
|
if ($data) :
|
|
?>
|
|
|
|
<style>
|
|
table {
|
|
table-layout: fixed;
|
|
width: 100%;
|
|
}
|
|
|
|
td {
|
|
word-wrap: break-word;
|
|
}
|
|
|
|
img {
|
|
width: 125px;
|
|
}
|
|
|
|
.width_style_1 {
|
|
width: 125px;
|
|
}
|
|
|
|
table {
|
|
width: 100%;
|
|
}
|
|
|
|
#table_index_filter {
|
|
float: right;
|
|
}
|
|
|
|
#table_index_paginate {
|
|
float: right;
|
|
}
|
|
|
|
label {
|
|
display: inline-flex;
|
|
margin-bottom: .5rem;
|
|
margin-top: .5rem;
|
|
|
|
}
|
|
</style>
|
|
<div style="width:98% ;margin: 1%">
|
|
<table id="table_index" class="table table-striped table-bordered" style="width:100%">
|
|
<thead>
|
|
<tr>
|
|
<th>單據編號</th>
|
|
<th>單據日期</th>
|
|
<th>付款方式</th>
|
|
<th>經辦人</th>
|
|
<th>報銷部門</th>
|
|
<th>報銷人</th>
|
|
<th>幣別</th>
|
|
<?php
|
|
if (($user_id == "M0056" || $user_id == "M0209")) { ?>
|
|
<th>報銷金額</th>
|
|
<?php } ?>
|
|
<th style="width: 8%;">狀態</th>
|
|
<th style="width: 7%;">功能</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
|
|
<?php
|
|
if (is_iterable($data)) {
|
|
for($i = 0; $i < count($data); $i++) {
|
|
// foreach ($data as $data) : ?>
|
|
<tr>
|
|
<td><?php echo $data[$i]['BillNo']; ?></td>
|
|
<td><?php echo substr($data[$i]['BillDate'], 0, 10); ?></td>
|
|
<td><?php if ($data[$i]['pay_type'] == 0) {
|
|
echo "現金";
|
|
} elseif ($data[$i]['pay_type'] == 1) {
|
|
echo "銀行轉帳";
|
|
}; ?></td>
|
|
<td><?php echo accountidToName($data[$i]['TransactId']); ?></td>
|
|
<td><?php
|
|
if (is_iterable($deptype)) {
|
|
foreach ($deptype as $dept) {
|
|
if ($data[$i]["DeptId"] == $dept['department_id']) {
|
|
echo $dept['name'];
|
|
break;
|
|
}
|
|
}
|
|
} ?></td>
|
|
<td><?php echo accountidToName($data[$i]['WriteOffId']); ?></td>
|
|
<td><?php if ($data[$i]['CurrId'] == "USD") : echo "美金";
|
|
elseif ($data[$i]['CurrId'] == "TWD") : echo "台幣";
|
|
elseif ($data[$i]['CurrId'] == "CNY") : echo "人民幣";
|
|
elseif ($data[$i]['CurrId'] == "HKD") : echo "港幣";
|
|
elseif ($data[$i]['CurrId'] == "EUR") : echo "歐元";
|
|
endif; ?> </td>
|
|
<?php
|
|
if (($user_id == "M0056" || $user_id == "M0209")) { ?>
|
|
<td><?php echo $data[$i]['OAmountWithTax']; ?> </td>
|
|
<?php } ?>
|
|
<td><?php if ($data[$i]['CurrentState'] == 0) : echo "草稿";
|
|
elseif ($data[$i]['CurrentState'] == 1) : echo "審核中";
|
|
elseif ($data[$i]['CurrentState'] == 2) : echo "通過";
|
|
elseif ($data[$i]['CurrentState'] == 3) : echo "作廢";
|
|
elseif ($data[$i]['CurrentState'] == 5) : echo "退回";
|
|
else : echo "結案";
|
|
endif ?>
|
|
</td>
|
|
<td>
|
|
<p>
|
|
<?php if (($user_id == "M0056" || $user_id == "M0209") && $data[$i]['CurrentState'] == 1) {
|
|
?>
|
|
<a href="rib01-check.php?id=<?php echo $data[$i]['rib_id'] ?>&state=1&<?= $token_link ?>" class="btn btn-success btn-sm">
|
|
<span class="glyphicon glyphicon-pawn"></span>
|
|
</a>
|
|
<?php
|
|
} else { ?>
|
|
<?php if ($data[$i]['CurrentState'] == 0) : ?>
|
|
<a href="rib01-check.php?id=<?php echo $data[$i]['rib_id'] ?>&state=0&<?= $token_link ?>" class="btn btn-warning btn-sm">
|
|
<span class="glyphicon glyphicon-pencil"></span>
|
|
</a>
|
|
<?php elseif ($data[$i]['CurrentState'] == 1) : ?>
|
|
<a href="rib01-check.php?id=<?php echo $data[$i]['rib_id'] ?>&state=1&<?= $token_link ?>" class="btn btn-primary btn-sm">
|
|
<span class=" glyphicon glyphicon-search"></span>
|
|
</a>
|
|
<button type="button" onclick="download(<?= $data[$i]['rib_id'] ?>)" class="btn btn-info btn-sm"><span class="glyphicon glyphicon-download-alt"></span></button>
|
|
<!-- <a href="rib03-download.php?id=<?php echo $data[$i]['rib_id'] ?>&<?= $token_link ?>" class="btn btn-info btn-sm">
|
|
<span class="glyphicon glyphicon-download-alt"></span>
|
|
</a> -->
|
|
<?php elseif ($data[$i]['CurrentState'] == 2) : ?>
|
|
<a href="rib01-check.php?id=<?php echo $data[$i]['rib_id'] ?>&state=2&<?= $token_link ?>" class="btn btn-info btn-sm">
|
|
<span class=" glyphicon glyphicon-ok"></span>
|
|
</a>
|
|
<?php elseif ($data[$i]['CurrentState'] == 3) : ?>
|
|
<a href="rib01-check.php?id=<?php echo $data[$i]['rib_id'] ?>&state=2&<?= $token_link ?>" class="btn btn-primary btn-sm">
|
|
<span class="glyphicon glyphicon-search"></span>
|
|
</a>
|
|
<?php elseif ($data[$i]['CurrentState'] == 5) : ?>
|
|
<a href="rib01-check.php?id=<?php echo $data[$i]['rib_id'] ?>&state=2&<?= $token_link ?>" class="btn btn-primary btn-sm">
|
|
<span class="glyphicon glyphicon-search"></span>
|
|
</a>
|
|
<?php endif;
|
|
} ?>
|
|
|
|
</p>
|
|
</td>
|
|
</tr>
|
|
<?php };
|
|
} ?>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
<script>
|
|
function download(ribid) {
|
|
var xhr = new XMLHttpRequest();
|
|
var url = window.location.origin + "/wms/rib03-download.php?ribid=" + ribid + "&<?= $token_link ?>";
|
|
xhr.open('GET', url, true);
|
|
xhr.send();
|
|
xhr.responseType = 'text';
|
|
xhr.onload = function() {
|
|
if (xhr.status === 200) {
|
|
console.log("ok");
|
|
var file_path = xhr.responseText;
|
|
var link = document.createElement('a');
|
|
link.setAttribute('href', window.location.origin + "/wms/WriteOff.xlsx");
|
|
link.setAttribute('download', '費用報銷單.xlsx');
|
|
link.style.display = 'none';
|
|
document.body.appendChild(link);
|
|
link.click();
|
|
document.body.removeChild(link);
|
|
// window.open('rib-test.php','-----');
|
|
}
|
|
};
|
|
|
|
}
|
|
// function openpdf(ribid){
|
|
// window.open('rib-test.php','-----');
|
|
|
|
// }
|
|
</script>
|
|
|
|
<?php
|
|
else :
|
|
echo "<h2>There is no record!</h2>";
|
|
endif;
|
|
|
|
include "./footer.php";
|
|
?>
|