3 changed files with 393 additions and 47 deletions
@ -0,0 +1,250 @@ |
|||
<?php |
|||
ini_set('display_errors', 'on'); |
|||
include "./header.php"; |
|||
|
|||
// 設置一個空陣列來放資料 |
|||
$data = array(); |
|||
// sql語法存在變數中 |
|||
$sql = "select * from rib_business "; |
|||
|
|||
// 是否為會計 阿娥 |
|||
if ($user_id == 'M0056') { |
|||
$sql .= "WHERE ((CurrentState =1) or (CreatorId= '$user_id')or (PersonId= '$user_id'))"; |
|||
$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 ((PersonId in $column_str) or (CreatorId in $column_str))"; |
|||
} else { |
|||
$sql .= "WHERE ((PersonId= '$user_id') or (CreatorId= '$user_id'))"; |
|||
}; |
|||
$data = mysqli_query($link, $sql); |
|||
} |
|||
$DeptName = array(); |
|||
// 連線T8MASADA |
|||
try { |
|||
$conn = new PDO("sqlsrv:Server=60.244.87.101;Database=T8MASADA", "masada", "ZXCVasdf1234"); |
|||
if ($conn) { |
|||
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); |
|||
$member = array(); |
|||
//取得人員名單與使用者的部門 |
|||
$sql_mydept = "SELECT UserId, Username FROM capMembership"; |
|||
$deptmem = $conn->query($sql_mydept); |
|||
foreach ($deptmem as $mem) { |
|||
$userid = $mem['UserId']; |
|||
$username = $mem['Username']; |
|||
$member["$userid"] = [$username]; |
|||
}; |
|||
$sql_dept = "SELECT DeptId, PersonId FROM comPerson WHERE DeptId!='0001'"; |
|||
$allpeople = $conn->query($sql_dept); |
|||
foreach ($allpeople as $man) { |
|||
if ($man['PersonId'] == $user_id) { |
|||
$mydepart = $man['DeptId']; |
|||
} |
|||
$personid = $man['PersonId']; |
|||
$depart = $man['DeptId']; |
|||
if (isset($member["$personid"])) { |
|||
array_push($member["$personid"], "$depart"); |
|||
}; |
|||
} |
|||
|
|||
//取得部門代碼 |
|||
$sql_department = "SELECT DeptId,DeptName FROM comDepartment WHERE DeptId!='0001'"; |
|||
$deptype = $conn->query($sql_department); |
|||
foreach ($deptype as $dept) { |
|||
$deptid = $dept['DeptId']; |
|||
$deptname = $dept['DeptName']; |
|||
$DeptName[$deptid] = $deptname; |
|||
} |
|||
//取得供應商 |
|||
$sql_Biz = "SELECT comBusinessPartner.BizPartnerId, comBusinessPartner.BizPartnerName FROM comBusinessPartner INNER JOIN comSupplier ON comBusinessPartner.BizPartnerId=comSupplier.BizPartnerId WHERE comBusinessPartner.BizPartnerId !='V0001'"; |
|||
$BizPartner = $conn->query($sql_Biz); |
|||
foreach($BizPartner as $partner){ |
|||
$partnerid = $partner['BizPartnerId']; |
|||
$partnername = $partner['BizPartnerName']; |
|||
$Supplier[$partnerid]= $partnername; |
|||
} |
|||
$conn = null; |
|||
} |
|||
} catch (PDOException $e) { |
|||
echo "fail"; |
|||
echo $e->getMessage(); |
|||
} |
|||
?> |
|||
<!-- |
|||
新增單據 --> |
|||
<p> |
|||
<a href="rib01-business-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> |
|||
<th style="width: 8%;">狀態</th> |
|||
<th style="width: 7%;">功能</th> |
|||
</tr> |
|||
</thead> |
|||
<tbody> |
|||
|
|||
<?php foreach ($data as $data) : ?> |
|||
<tr> |
|||
<td><?php echo $data['BillNo']; ?></td> |
|||
<td><?php echo substr($data['BillDate'], 0, 10); ?></td> |
|||
<td><?php $supp= $data['BizPartnerId']; |
|||
echo $Supplier[$supp]; ?></td> |
|||
<td><?php echo accountidToName($data['PersonId']); ?></td> |
|||
<td><?php $depid = $data['DeptId']; |
|||
echo $DeptName[$depid] ?></td> |
|||
<td><?php if ($data['CurrId'] == "USD") : echo "美金"; |
|||
elseif ($data['CurrId'] == "TWD") : echo "台幣"; |
|||
elseif ($data['CurrId'] == "CNY") : echo "人民幣"; |
|||
elseif ($data['CurrId'] == "HKD") : echo "港幣"; |
|||
elseif ($data['CurrId'] == "EUR") : echo "歐元"; |
|||
endif; ?> </td> |
|||
<td><?php echo $data['total_OAmount']; ?> </td> |
|||
<td><?php if ($data['CurrentState'] == 0) : echo "草稿"; |
|||
elseif ($data['CurrentState'] == 1) : echo "審核中"; |
|||
elseif ($data['CurrentState'] == 2) : echo "通過"; |
|||
elseif ($data['CurrentState'] == 3) : echo "作廢"; |
|||
elseif ($data['CurrentState'] == 5) : echo "退回"; |
|||
else : echo "結案"; |
|||
endif ?> |
|||
</td> |
|||
<td> |
|||
<p> |
|||
<?php if ($user_id == 'M0056' && $data['CurrentState'] == 1) { |
|||
?> |
|||
<a href="rib01-check.php?BillNo=<?php echo $data['BillNo'] ?>&state=1&<?= $token_link ?>" class="btn btn-success btn-sm"> |
|||
<span class="glyphicon glyphicon-pawn"></span> |
|||
</a> |
|||
<?php |
|||
} else { ?> |
|||
<?php if ($data['CurrentState'] == 0) : ?> |
|||
<a href="rib01-business-check.php?BillNo=<?php echo $data['BillNo'] ?>&state=0&<?= $token_link ?>" class="btn btn-warning btn-sm"> |
|||
<span class="glyphicon glyphicon-pencil"></span> |
|||
</a> |
|||
<?php elseif ($data['CurrentState'] == 1) : ?> |
|||
<a href="rib01-check.php?BillNo=<?php echo $data['BillNo'] ?>&state=1&<?= $token_link ?>" class="btn btn-primary btn-sm"> |
|||
<span class=" glyphicon glyphicon-search"></span> |
|||
</a> |
|||
<button type="button" onclick="download(<?= $data['BillNo'] ?>)" class="btn btn-info btn-sm"><span class="glyphicon glyphicon-download-alt"></span></button> |
|||
<!-- <a href="rib03-download.php?id=<?php echo $data['BillNo'] ?>&<?= $token_link ?>" class="btn btn-info btn-sm">
|
|||
<span class="glyphicon glyphicon-download-alt"></span> |
|||
</a> --> |
|||
<?php elseif ($data['CurrentState'] == 2) : ?> |
|||
<a href="rib01-check.php?BillNo=<?php echo $data['BillNo'] ?>&state=2&<?= $token_link ?>" class="btn btn-info btn-sm"> |
|||
<span class=" glyphicon glyphicon-ok"></span> |
|||
</a> |
|||
<?php elseif ($data['CurrentState'] == 3) : ?> |
|||
<a href="rib01-check.php?BillNo=<?php echo $data['BillNo'] ?>&state=2&<?= $token_link ?>" class="btn btn-primary btn-sm"> |
|||
<span class="glyphicon glyphicon-search"></span> |
|||
</a> |
|||
<?php elseif ($data['CurrentState'] == 5) : ?> |
|||
<a href="rib01-check.php?BillNo=<?php echo $data['BillNo'] ?>&state=2&<?= $token_link ?>" class="btn btn-primary btn-sm"> |
|||
<span class="glyphicon glyphicon-search"></span> |
|||
</a> |
|||
<?php endif; |
|||
} ?> |
|||
|
|||
</p> |
|||
</td> |
|||
</tr> |
|||
<?php endforeach; ?> |
|||
</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"; |
|||
?> |
Loading…
Reference in new issue