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.
 
 
 
 
 
 

89 lines
2.9 KiB

<?php
include "purchase-function.php";
$start_date = empty($_POST['date_start']) ? null : $_POST['date_start'];
$end_date = empty($_POST['date_end']) ? null : $_POST['date_end'];
$add_sql = "";
$follower = find_follow($user_id);
if ((!in_array($user_id, array('M0056', 'M0108', 'M0209'))) && (!in_array(accountidToDepartId($user_id), array('220', '210')))) {
$add_sql .= "AND (main.PersonId = '$user_id' ";
if (count($follower) > 0) {
$column_str = "('$user_id'" . ",'";
$column_str .= implode("','", $follower);
$column_str .= "')";
$add_sql .= " OR main.PersonId IN $column_str)";
} else {
$add_sql .= ")";
};
}
if (!is_null($start_date)) {
$start_date = (int)date('Ymd', strtotime($start_date));
$add_sql .= " AND main.BillDate >= $start_date ";
}
if (!is_null($end_date)) {
$end_date = (int)date('Ymd', strtotime($end_date));
$add_sql .= " AND main.BillDate <= $end_date ";
}
$main = get_purchaseApply_index($conn, $add_sql);
// print_r($main);
?>
<script defer src="./contract/js/alpinejs/cdn.min.js"></script>
<h2 class="text-center"><strong>採購費用申請單 (對廠商付款)</strong></h2>
<p>
<a href="purchase-apply-create.php?<?php echo $token_link; ?>" class="btn btn-info btn-sm">
<span class="glyphicon glyphicon-plus"></span>
</a>
</p>
<div class="purchase-apply-index" x-data="purchaseApplies">
<div style="width:98% ;margin: 1%">
<table class="table table-striped table-bordered" style="width:100%;">
<thead>
<tr>
<th>單號</th>
<th>申請日期</th>
<?php if (in_array(accountidToDepartId($user_id), array('220', '210'))) { ?>
<th>申請部門</th>
<?php } ?>
<th>申請人</th>
<th>幣別</th>
<th>含稅金額</th>
</tr>
</thead>
<tbody>
<template x-if="purchaseApplies.length <=0">
<tr>
<td colspan="2">無資料</td>
</tr>
</template>
<template x-for="purchaseApply in purchaseApplies">
<tr>
<td x-text="purchaseApply.BillNo"></td>
<td x-text="formatDate(purchaseApply.BillDate)"></td>
<?php if (in_array(accountidToDepartId($user_id), array('220', '210'))) { ?>
<td x-text="purchaseApply.DeptName"></td>
<?php } ?>
<td x-text="purchaseApply.PersonName"></td>
<td x-text="purchaseApply.CurrId === 'TWD' ? '台幣' : (purchaseApply.CurrId === 'RMB' ? '人民幣' : purchaseApply.CurrId)"></td>
<td x-text="purchaseApply.OAmountWithTax"></td>
</tr>
</template>
</table>
</div>
</div>
<script>
const purchaseApplies = <?php echo json_encode($main); ?>
function formatDate(date) {
date = date.toString();
var year = date.substring(0, 4);
var month = date.substring(4, 6);
var day = date.substring(6, 8);
return year + '-' + month + '-' + day;
}
</script>