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.
 
 
 
 
 
 

407 lines
18 KiB

<?php
include "./header.php";
$rib_id = isset($_GET['id']) ? $_GET['id'] : NULL;
$BillNo = isset($_GET['BillNo']) ? $_GET['BillNo'] : NULL;
// 取得 rib WHERE rib_id 的資料
$db_query = "SELECT * from rib where rib_id='$rib_id'";
if (empty($rib_id)) {
$db_query = "SELECT * from rib where BillNo='$BillNo'";
}
$res = mysqli_query($link, $db_query);
$state = $_GET['state'];
$CurrId = "";
foreach ($res as $dat) {
$CurrId = $dat['CurrId'];
$rib_id = $dat['rib_id'];
$BillNo = $dat['BillNo'];
}
//取得 rib_sub的資料
$pay_data = array();
$pay_sql = "select * from rib_sub where rib_id = $rib_id";
$pay_data = mysqli_query($link, $pay_sql);
$totalOAmount = 0;
$CurrLAmount = 0;
if ($pay_data) {
foreach ($pay_data as $pdat) {
$totalOAmount += $pdat['OAmount'];
$CurrLAmount = $pdat['CurrentLAmount'];
}
}
// 連線T8MASADA
$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);
?>
<div style="width: 90%;">
<div style="padding-left: 2rem; padding-bottom: 1rem;">
<a href="rib01-index.php?<?php echo $token_link; ?>" class="btn btn-default btn-lg">
<span class="glyphicon glyphicon-home"></span>
</a>
</div>
</div>
<?php
if ($state == 0) :
?>
<div style="width: 90%;">
<div style="padding-left: 2rem;">
<a href="rib03-submit.php?id=<?= $rib_id ?>&state=1&<?php echo $token_link; ?>" class="btn btn-success btn-lg pull-right">
提交並列印報銷黏存單 <span class="glyphicon glyphicon-send"></span>
</a>
</div>
</div>
<div style="padding-left: 2rem;">
<p>
<a href="rib01-delete.php?id=<?= $rib_id ?>&<?php echo $token_link; ?>" class="btn btn-danger btn-lg">
<span class="glyphicon glyphicon-trash"></span>
</a>
</p>
</div>
<?php
elseif ($state == 1 && ($user_id == "M0056" || $user_id == "M0209")) :
?>
<div style="width: 90%;">
<div style="padding-left: 2rem;">
<a href="rib03-submit.php?id=<?= $rib_id ?>&state=2&<?php echo $token_link; ?>" class="btn btn-success btn-lg pull-right">
核准並上傳T8 <span class="glyphicon glyphicon-cloud-upload"></span>
</a>
</div>
</div>
<div style="padding-left: 2rem;">
<p>
<a href="rib01-delete.php?id=<?= $rib_id ?>&state=1&<?php echo $token_link; ?>" class="btn btn-danger btn-lg">
<span class="glyphicon glyphicon-remove-sign"> 退回</span>
</a>
</p>
</div>
<?php
elseif ($state == 1) :
?>
<div style="padding-left: 2rem;">
<p>
<a href="rib01-delete.php?id=<?= $rib_id ?>&state=1&<?php echo $token_link; ?>" class="btn btn-danger btn-lg">
<span class="glyphicon glyphicon-remove-sign"> 撤回</span>
</a>
</p>
</div>
<?php
endif
?>
<div class="container" id="accountedit">
<div class="text-center">
<h3>報銷單據</h3>
</div>
<form class="form-horizontal" name="ribedit" method="POST" action="rib01-edit.php?id=<?php echo $data['rib_id'] ?>&state=0&<?= $token_link ?>" enctype="multipart/form-data">
<?php
foreach ($res as $data) :; ?>
<div class="form-group">
<div class="col-md-3">
<label for="BillNo">單據編號</label>
<input class="form-control" type="text" name="BillNo" id="BillNo" value="<?php echo $data['BillNo'] ?>" required disabled>
</div>
<div class="col-md-3">
<label for="BillDate">單據日期</label>
<!-- <textarea class="form-control" name="rib_title" id="rib_title" required></textarea> -->
<input class="form-control" type="number" name="BillDate" id="BillDate" value=<?= $data['BillDate'] ?> required disabled>
</div>
<div class="col-md-3">
<label for="CurrId">幣別</label>
<select name="CurrId" class="form-control" disabled>
<option value="TWD" <?php if ($data['CurrId'] === "TWD") {
echo "selected";
} ?>>台幣</option>
<option value="CNY" <?php if ($data['CurrId'] === "CNY") {
echo "selected";
} ?>>人民幣</option>
<option value="EUR" <?php if ($data['CurrId'] === "EUR") {
echo "selected";
} ?>>歐元</option>
<option value="HKD" <?php if ($data['CurrId'] === "HKD") {
echo "selected";
} ?>>港幣</option>
<option value="USD" <?php if ($data['CurrId'] === "USD") {
echo "selected";
} ?>>美元</option>
</select>
</div>
<div class="col-md-3">
<label for="TransactId">經辦人</label>
<select name="TransactId" id="TransactId" class="form-control" disabled>
<?php
foreach ($member as $key => $value) { ?>
<option value="<?php echo $key; ?>" <?php if ($key == $data['TransactId']) {
echo "selected";
} ?>> <?php echo $value[0]; ?> </option>
<?php }; ?>
</select>
</div>
</div>
<div class="form-group">
<div class="col-md-3">
<label for="DeptId">報銷單位</label>
<select name="DeptId" id="DeptId" class="form-control" required disabled>
<?php
foreach ($deptype as $dept) { ?>
<option value="<?php echo $dept['DeptId']; ?>" <?php
if ($dept['DeptId'] == $data['DeptId']) {
echo "selected";
} ?>><?php echo $dept['DeptName']; ?></option>
<?php };
?>
</select>
</div>
<div class="col-md-3">
<label for="WriteOffId">報銷人</label>
<select name="WriteOffId" id="WriteOffId" class="form-control" required disabled>
<?php
foreach ($member as $key => $value) { ?>
<option value="<?php echo $key; ?>" style="display:none" id="<?= 'WriteOff' . $value[1] . $value[0] ?>" <?php if ($key == $data['WriteOffId']) {
echo "selected";
} ?>> <?php echo $value[0]; ?> </option>
<?php }
?>
</select>
</div>
<div class="col-md-3">
<label for="pay_type">付款方式</label>
<select class="form-control" name="pay_type" id="pay_type" disabled>
<option value=0 <?php if ($data['pay_type'] == 0) {
echo "selected";
} ?>>現金</option>
<option value=1 <?php if ($data['pay_type'] == 1) {
echo "selected";
} ?>>銀行轉帳</option>
</select>
</div>
<div class="col-md-3">
<label for="GatheringPersonId">收款人</label>
<select name="GatheringPersonId" id="GatheringPersonId" class="form-control" required disabled>
<?php
foreach ($member as $key => $value) {
?>
<option value="<?php echo $key; ?>" id="<?= 'Gathering' . $value[1] . $value[0] ?>" <?php if ($key == $data['GatheringPersonId']) {
echo "selected";
} ?>> <?php echo $value[0]; ?> </option>
<?php }; ?>
</select>
</div>
</div>
<?php
if (($user_id == "M0056" || $user_id == "M0209") && $state == 1) { ?>
<div class="form-group">
<div class="col-md-3">
<label for="WriteOffAmount">報銷金額 (原幣)</label>
<input name="WriteOffAmount" id="WriteOffAmount" class="form-control" type="number" value="<?= round($data['WriteOffAmount']) ?>" disabled>
</div>
<div class="col-md-3">
<label for="OAmount">未稅報銷金額 (原幣)</label>
<input name="OAmount" id="OAmount" class="form-control" value="<?= round($data['OAmount']) ?>" disabled>
</div>
<div class="col-md-3">
<label for="OTax">稅金 (原幣)</label>
<input name="OTax" id="OTax" class="form-control" value="<?= round($data['OTax']) ?>" disabled>
</div>
<div class="col-md-3">
<label for="CurrentLAmount">匯率</label>
<input name="CurrentLAmount" id="CurrentLAmount" class="form-control" value="<?= round($CurrLAmount) ?>" disabled>
</div>
</div>
<div class="form-group">
<div class="col-md-3">
<label for="LAmountWithTax">本幣報銷金額</label>
<input name="LAmountWithTax" id="LAmountWithTax" class="form-control" type="number" value="<?= round($data['LAmountWithTax']) ?>" disabled>
</div>
<div class="col-md-3">
<label for="LAmount">本幣未稅報銷金額</label>
<input name="LAmount" id="LAmount" class="form-control" value="<?= round($data['LAmount']) ?>" disabled>
</div>
<div class="col-md-3">
<label for="LTax">本幣稅金</label>
<input name="LTax" id="LTax" class="form-control" value="<?= round($data['LTax']) ?>" disabled>
</div>
</div>
<?php
} else { ?>
<div class="form-group">
<div class="col-md-3">
<label for="totalOAmount">報銷金額 (原幣)</label>
<input name="totalOAmount" id="totalOAmount" class="form-control" type="number" value="<?= round($totalOAmount) ?>" disabled>
</div>
</div>
<?php
} ?>
<div class="form-group">
<input type="hidden" name="token" value="<?php echo $token; ?>">
<input type="hidden" name="type" id="type" value="rib">
<input type="hidden" name="rib_id" id="rib_id" value="<?= $rib_id ?>">
</div>
<?php
endforeach;
if ($state == 0) :
?>
<div class="form-group">
<div class="col-md-7">
</div>
<a href="rib01-edit.php?id=<?php echo $rib_id ?>&state=0&<?= $token_link ?>" class="btn btn-primary btn-lg pull-right">
修改報銷單
</a>
</div>
<?php
elseif ($state == 1 && ($user_id == "M0056" || $user_id == "M0209")) :
?>
<div class="form-group">
<div class="col-md-7">
</div>
<a href="rib01-edit.php?id=<?php echo $rib_id ?>&state=1&<?= $token_link ?>" class="btn btn-primary btn-lg pull-right">
修改報銷單
</a>
</div>
<?php
endif
?>
</form>
</div>
<?php
include "./footer.php";
$RowCode = 1;
if ($pay_data) {
$RowCode += mysqli_num_rows($pay_data);
};
//取得費用項目代碼
$sql_feetype = "SELECT * from feetype";
$feetype_query = mysqli_query($link, $sql_feetype);
$feetype = mysqli_fetch_all($feetype_query, MYSQLI_ASSOC);
?>
<div style="margin: 1%;display:flex; justify-content:center;">
<?php
if ($pay_data) :
?>
<div style="width: 80%;">
<?php
if (($state == 0)||($user_id=='M0056') || $user_id=='M0209') :
?>
<a href="rib02-create.php?id=<?php echo $data['rib_id'] ?>&RowCode=<?= $RowCode ?>&CurrId=<?= $CurrId ?>&<?= $token_link ?>" class="btn btn-info btn-lg pull-right" style="margin: 1 rem;">
<span class=" glyphicon glyphicon-plus"></span>
</a>
<?php
endif;
?>
<table 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: 10%;">功能</th>
</tr>
</thead>
<tbody>
<?php
foreach ($pay_data as $pay) : ?>
<tr>
<td><?= $pay['FeeDate'] ?></td>
<td><?= round($pay['Quantity']) ?></td>
<td><?= round($pay['Price']) ?></td>
<td><?php foreach ($feetype as $feetyp) {
if ($feetyp['FeeTypeId'] == $pay['FeeTypeId']) {
echo $feetyp['FeeTypeName'];
}
} ?></td>
<td><?= round($pay['OAmount']) ?></td>
<td><?= $pay['FeeNoteShow'] ?></td>
<td><?= $pay['InvoiceNo'] ?></td>
<?php if ($state == 0) { ?>
<td> <a href="rib02-edit.php?id=<?php echo $pay['ribsub_id'] ?>&state=0&<?= $token_link ?>" class="btn btn-warning btn-sm">
<span class=" glyphicon glyphicon-pencil"></span>
</a>
<a href="rib02-delete.php?ribsub_id=<?php echo $pay['ribsub_id'] ?>&rib_id=<?php echo $pay['rib_id'] ?>&<?= $token_link ?>" class="btn btn-danger btn-sm">
<span class=" glyphicon glyphicon-trash"></span>
</a>
</td>
<?php } elseif ($state == 1 && ($user_id == "M0056" || $user_id == "M0209")) { ?>
<td><a href="rib02-edit.php?id=<?php echo $pay['ribsub_id'] ?>&state=1&<?= $token_link ?>" class="btn btn-warning btn-sm">
<span class=" glyphicon glyphicon-pencil"></span>
</a>
<a href="rib02-delete.php?ribsub_id=<?php echo $pay['ribsub_id'] ?>&rib_id=<?php echo $pay['rib_id'] ?>&<?= $token_link ?>" class="btn btn-danger btn-sm">
<span class=" glyphicon glyphicon-trash"></span>
</a>
</td>
<?php } else { ?>
<td> <a href="rib02-check.php?id=<?php echo $pay['ribsub_id'] ?>&<?= $token_link ?>" class="btn btn-primary btn-sm">
<span class="glyphicon glyphicon-search"></span>
</a>
</td>
<?php
} ?>
</tr>
<?php endforeach ?>
</tbody>
</table>
</div>
<?php
endif;
?>
</div>