Browse Source

Merge branch 'kaiyu'

gary
Ellin 1 year ago
parent
commit
0c1d041458
  1. 46
      wms/account-receivable-excel.php
  2. 30
      wms/account-receivable-index.php
  3. BIN
      wms/account-receivable.xlsx

46
wms/account-receivable-excel.php

@ -0,0 +1,46 @@
<?php
include "./header.php";
require_once dirname(__DIR__) . '/common/composer/vendor/autoload.php';
use PhpOffice\PhpSpreadsheet\Spreadsheet;
use PhpOffice\PhpSpreadsheet\Writer\Xlsx;
$Bill = $_POST['Bill'];
$array_data = array();
$Bill = json_decode($Bill, true);
foreach($Bill as $key=>$value){
for ($i = 0; $i < 17; $i++) {
$value[$i] = (isset($value[$i])) ? $value[$i] : 0;
}
$array_data[$key][0] = $value[0];
$array_data[$key][1] = $value[1];
$array_data[$key][2] = $value[2];
$array_data[$key][3] = $value[3];
$array_data[$key][4] = $value[4];
$array_data[$key][5] = $value[15];
$array_data[$key][6] = $value[16];
$array_data[$key][7] = $value[14];
$array_data[$key][8] = $value[5];
$array_data[$key][9] = $value[6];
$array_data[$key][10] = $value[7];
$array_data[$key][11] = $value[8];
$array_data[$key][12] = $value[9];
$array_data[$key][13] = $value[10];
$array_data[$key][14] = $value[11];
$array_data[$key][15] = $value[12];
$array_data[$key][16] = str_replace('<br>','\n',$value[13]);
}
$spreadsheet = new Spreadsheet();
$sheet = $spreadsheet->getActiveSheet();
$colomnHeader = ['合約號','部門','經理','營業員','客戶名稱','統一編號','聯絡地址','抬頭','簽約款',
'二次款','貨抵工地款','安裝款','試車款','官檢款','交車款','目前應收','作番狀態'];
$sheet->fromArray($colomnHeader,NULL,'A1');
$rowIndex = 2;
foreach($array_data as $key => $value){
$sheet->fromArray([$value], NULL, 'A' . $rowIndex);
$rowIndex++;
}
$writer = new Xlsx($spreadsheet);
$excelFileName = 'account-receivable.xlsx';
$writer->save($excelFileName);
echo "Excel 文件已生成:{$excelFileName}";
?>

30
wms/account-receivable-index.php

@ -121,6 +121,7 @@ foreach ($contract as $cont) {
} }
foreach ($arrayData as $key => $value) { foreach ($arrayData as $key => $value) {
if (array_key_exists($key, $arrayData) && isset($arrayData[$key])) {
$sql = "SELECT $sql = "SELECT
tmp2.*, tmp2.*,
d.name AS depart_name d.name AS depart_name
@ -162,13 +163,15 @@ ON d.department_id = tmp2.department_id";
$tryrun_num = 0; $tryrun_num = 0;
$delivery_num = 0; $delivery_num = 0;
$official_num = 0; $official_num = 0;
$value[16]='';
$value[17]='';
$wipwhole_array = mysqli_query($link, $sql); $wipwhole_array = mysqli_query($link, $sql);
foreach ($wipwhole_array as $wip) { foreach ($wipwhole_array as $wip) {
$value[0] = $wip['depart_name']; $value[0] = $wip['depart_name'];
$value[1] = $wip['manager_name']; $value[1] = $wip['manager_name'];
$value[2] = $wip['name']; $value[2] = $wip['name'];
$value[16] = isset($wip['department_id']) ? $wip['department_id'] : ''; $value[16] = is_null($wip['department_id']) ? '' : $wip['department_id'];
$value[17] = isset($wip['salesid']) ? $wip['salesid'] : ''; $value[17] = is_null($wip['salesid']) ? '' : $wip['salesid'];
if ($wip['delivery_date'] != NULL) { if ($wip['delivery_date'] != NULL) {
$facitities .= $wip['facilityno'] . " (" . $wip['delivery_date'] . "已移交) <br>"; $facitities .= $wip['facilityno'] . " (" . $wip['delivery_date'] . "已移交) <br>";
$total_facility_num += 1; $total_facility_num += 1;
@ -244,6 +247,7 @@ ON d.department_id = tmp2.department_id";
]; ];
} }
}
} }
$data = json_encode($receivable_array); $data = json_encode($receivable_array);
@ -353,13 +357,29 @@ $data = json_encode($receivable_array);
</table> </table>
</div> </div>
<script> <script>
// function sendData(BillNo) {
// console.log(BillNo);
// var BillData = <?= $data ?>;
// var Bill = BillData[BillNo];
// var form = document.createElement("form");
// form.method = 'POST';
// form.action = "account-receivable-excel.php?<?= $token_link ?>";
// var input = document.createElement("input");
// input.type = "hidden";
// input.name = "Bill";
// input.value = JSON.stringify(Bill);
// form.appendChild(input);
// document.body.appendChild(form);
// form.submit();
// }
function sendData(BillNo) { function sendData(BillNo) {
console.log(BillNo);
var BillData = <?= $data ?>; var BillData = <?= $data ?>;
var Bill = BillData[BillNo]; var Bill = BillData;
var form = document.createElement("form"); var form = document.createElement("form");
form.method = 'POST'; form.method = 'POST';
form.action = "account-receivable-check.php?<?= $token_link ?>"; form.action = "account-receivable-excel.php?<?= $token_link ?>";
var input = document.createElement("input"); var input = document.createElement("input");
input.type = "hidden"; input.type = "hidden";
input.name = "Bill"; input.name = "Bill";

BIN
wms/account-receivable.xlsx

Binary file not shown.
Loading…
Cancel
Save