|
@@ -7350,11 +7350,11 @@ class Procuremen extends Backend
|
|
|
|
|
|
|
|
$spreadsheet = new Spreadsheet();
|
|
$spreadsheet = new Spreadsheet();
|
|
|
$sheet = $spreadsheet->getActiveSheet();
|
|
$sheet = $spreadsheet->getActiveSheet();
|
|
|
- $sheet->setTitle('协助明细');
|
|
|
|
|
|
|
+ $sheet->setTitle('外协加工明细');
|
|
|
|
|
|
|
|
$mon = (int)substr($ym, 5, 2);
|
|
$mon = (int)substr($ym, 5, 2);
|
|
|
$sheet->mergeCells('A1:H1');
|
|
$sheet->mergeCells('A1:H1');
|
|
|
- $sheet->setCellValue('A1', $mon . '月协助明细');
|
|
|
|
|
|
|
+ $sheet->setCellValue('A1', $mon . '月份外协加工明细');
|
|
|
$sheet->getStyle('A1')->getFont()->setBold(true)->setSize(14);
|
|
$sheet->getStyle('A1')->getFont()->setBold(true)->setSize(14);
|
|
|
$sheet->getStyle('A1')->getAlignment()
|
|
$sheet->getStyle('A1')->getAlignment()
|
|
|
->setHorizontal(Alignment::HORIZONTAL_CENTER)
|
|
->setHorizontal(Alignment::HORIZONTAL_CENTER)
|
|
@@ -7372,6 +7372,7 @@ class Procuremen extends Backend
|
|
|
$rowNum = 3;
|
|
$rowNum = 3;
|
|
|
$sumSubtotalCounts = 0;
|
|
$sumSubtotalCounts = 0;
|
|
|
$grandAmount = 0.0;
|
|
$grandAmount = 0.0;
|
|
|
|
|
+ $globalSeq = 0;
|
|
|
|
|
|
|
|
if ($groups === []) {
|
|
if ($groups === []) {
|
|
|
$sheet->mergeCells('A3:H3');
|
|
$sheet->mergeCells('A3:H3');
|
|
@@ -7385,14 +7386,13 @@ class Procuremen extends Backend
|
|
|
}
|
|
}
|
|
|
$groupLineCount = count($items);
|
|
$groupLineCount = count($items);
|
|
|
$subAmount = 0.0;
|
|
$subAmount = 0.0;
|
|
|
- $i = 0;
|
|
|
|
|
foreach ($items as $line) {
|
|
foreach ($items as $line) {
|
|
|
- $i++;
|
|
|
|
|
|
|
+ $globalSeq++;
|
|
|
$dr = $line['detail'];
|
|
$dr = $line['detail'];
|
|
|
$amt = $this->procuremenExportAmount($dr);
|
|
$amt = $this->procuremenExportAmount($dr);
|
|
|
$subAmount += $amt;
|
|
$subAmount += $amt;
|
|
|
|
|
|
|
|
- $sheet->setCellValue('A' . $rowNum, $i);
|
|
|
|
|
|
|
+ $sheet->setCellValue('A' . $rowNum, $globalSeq);
|
|
|
$sheet->setCellValue('B' . $rowNum, $line['CCYDH']);
|
|
$sheet->setCellValue('B' . $rowNum, $line['CCYDH']);
|
|
|
$sheet->setCellValue('C' . $rowNum, $line['CYJMC']);
|
|
$sheet->setCellValue('C' . $rowNum, $line['CYJMC']);
|
|
|
$sheet->setCellValue('D' . $rowNum, $line['company_name']);
|
|
$sheet->setCellValue('D' . $rowNum, $line['company_name']);
|
|
@@ -7407,11 +7407,10 @@ class Procuremen extends Backend
|
|
|
$sumSubtotalCounts += $groupLineCount;
|
|
$sumSubtotalCounts += $groupLineCount;
|
|
|
$grandAmount += $subAmount;
|
|
$grandAmount += $subAmount;
|
|
|
|
|
|
|
|
- $sheet->setCellValue('A' . $rowNum, $groupLineCount);
|
|
|
|
|
$sheet->mergeCells('G' . $rowNum . ':H' . $rowNum);
|
|
$sheet->mergeCells('G' . $rowNum . ':H' . $rowNum);
|
|
|
$sheet->setCellValue('G' . $rowNum, '¥ ' . number_format($subAmount, 2, '.', ','));
|
|
$sheet->setCellValue('G' . $rowNum, '¥ ' . number_format($subAmount, 2, '.', ','));
|
|
|
$sheet->getStyle('G' . $rowNum)->getAlignment()
|
|
$sheet->getStyle('G' . $rowNum)->getAlignment()
|
|
|
- ->setHorizontal(Alignment::HORIZONTAL_RIGHT)
|
|
|
|
|
|
|
+ ->setHorizontal(Alignment::HORIZONTAL_LEFT)
|
|
|
->setVertical(Alignment::VERTICAL_CENTER);
|
|
->setVertical(Alignment::VERTICAL_CENTER);
|
|
|
$rowNum++;
|
|
$rowNum++;
|
|
|
}
|
|
}
|
|
@@ -7422,7 +7421,7 @@ class Procuremen extends Backend
|
|
|
$sheet->mergeCells('G' . $rowNum . ':H' . $rowNum);
|
|
$sheet->mergeCells('G' . $rowNum . ':H' . $rowNum);
|
|
|
$sheet->setCellValue('G' . $rowNum, '¥ ' . number_format($grandAmount, 2, '.', ','));
|
|
$sheet->setCellValue('G' . $rowNum, '¥ ' . number_format($grandAmount, 2, '.', ','));
|
|
|
$sheet->getStyle('A' . $rowNum . ':H' . $rowNum)->getFont()->setBold(true);
|
|
$sheet->getStyle('A' . $rowNum . ':H' . $rowNum)->getFont()->setBold(true);
|
|
|
- $sheet->getStyle('G' . $rowNum)->getAlignment()->setHorizontal(Alignment::HORIZONTAL_RIGHT);
|
|
|
|
|
|
|
+ $sheet->getStyle('G' . $rowNum)->getAlignment()->setHorizontal(Alignment::HORIZONTAL_LEFT);
|
|
|
|
|
|
|
|
$lastRow = $rowNum;
|
|
$lastRow = $rowNum;
|
|
|
$sheet->getStyle('A1:H' . $lastRow)->applyFromArray([
|
|
$sheet->getStyle('A1:H' . $lastRow)->applyFromArray([
|
|
@@ -7440,6 +7439,7 @@ class Procuremen extends Backend
|
|
|
$sheet->getStyle('F3:F' . $lastRow)->getAlignment()->setWrapText(true)->setVertical(Alignment::VERTICAL_TOP);
|
|
$sheet->getStyle('F3:F' . $lastRow)->getAlignment()->setWrapText(true)->setVertical(Alignment::VERTICAL_TOP);
|
|
|
$sheet->getStyle('G3:G' . $lastRow)->getAlignment()->setWrapText(true)->setVertical(Alignment::VERTICAL_TOP);
|
|
$sheet->getStyle('G3:G' . $lastRow)->getAlignment()->setWrapText(true)->setVertical(Alignment::VERTICAL_TOP);
|
|
|
}
|
|
}
|
|
|
|
|
+ $this->applyMonthExportTableAlignment($sheet, 2, 3, $lastRow, 'H');
|
|
|
$sheet->getColumnDimension('A')->setWidth(7);
|
|
$sheet->getColumnDimension('A')->setWidth(7);
|
|
|
$sheet->getColumnDimension('B')->setWidth(16);
|
|
$sheet->getColumnDimension('B')->setWidth(16);
|
|
|
$sheet->getColumnDimension('C')->setWidth(52);
|
|
$sheet->getColumnDimension('C')->setWidth(52);
|
|
@@ -7457,7 +7457,8 @@ class Procuremen extends Backend
|
|
|
$sheet->getColumnDimension('E')->setWidth(28);
|
|
$sheet->getColumnDimension('E')->setWidth(28);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- $fileBase = '协助明细_' . str_replace('-', '', $ym);
|
|
|
|
|
|
|
+ $ymCompact = str_replace('-', '', $ym);
|
|
|
|
|
+ $fileBase = $mon . '月份外协加工明细_' . $ymCompact;
|
|
|
$filename = $fileBase . '.xlsx';
|
|
$filename = $fileBase . '.xlsx';
|
|
|
|
|
|
|
|
try {
|
|
try {
|
|
@@ -7478,7 +7479,7 @@ class Procuremen extends Backend
|
|
|
if (ob_get_length()) {
|
|
if (ob_get_length()) {
|
|
|
ob_end_clean();
|
|
ob_end_clean();
|
|
|
}
|
|
}
|
|
|
- $asciiName = 'outward_' . str_replace('-', '', $ym) . '.xlsx';
|
|
|
|
|
|
|
+ $asciiName = 'wxjgmx_' . $ymCompact . '.xlsx';
|
|
|
header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
|
|
header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
|
|
|
header('Content-Disposition: attachment;filename="' . $asciiName . '"; filename*=UTF-8\'\'' . rawurlencode($filename));
|
|
header('Content-Disposition: attachment;filename="' . $asciiName . '"; filename*=UTF-8\'\'' . rawurlencode($filename));
|
|
|
header('Cache-Control: max-age=0');
|
|
header('Cache-Control: max-age=0');
|
|
@@ -7579,20 +7580,40 @@ class Procuremen extends Backend
|
|
|
'picked' => $picked,
|
|
'picked' => $picked,
|
|
|
];
|
|
];
|
|
|
}
|
|
}
|
|
|
- usort($lines, function ($a, $b) {
|
|
|
|
|
|
|
+ $winnerSupplierByOrder = [];
|
|
|
|
|
+ foreach ($lines as $line) {
|
|
|
|
|
+ $dh = trim((string)($line['CCYDH'] ?? ''));
|
|
|
|
|
+ $cn = trim((string)($line['company_name'] ?? ''));
|
|
|
|
|
+ if ($dh !== '' && $cn !== '' && !empty($line['picked'])) {
|
|
|
|
|
+ $winnerSupplierByOrder[$dh][$cn] = true;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ usort($lines, function ($a, $b) use ($winnerSupplierByOrder) {
|
|
|
$c = strcmp((string)($a['CCYDH'] ?? ''), (string)($b['CCYDH'] ?? ''));
|
|
$c = strcmp((string)($a['CCYDH'] ?? ''), (string)($b['CCYDH'] ?? ''));
|
|
|
if ($c !== 0) {
|
|
if ($c !== 0) {
|
|
|
return $c;
|
|
return $c;
|
|
|
}
|
|
}
|
|
|
- $c = strcmp((string)($a['gx'] ?? ''), (string)($b['gx'] ?? ''));
|
|
|
|
|
|
|
+ $dh = trim((string)($a['CCYDH'] ?? ''));
|
|
|
|
|
+ $aCn = trim((string)($a['company_name'] ?? ''));
|
|
|
|
|
+ $bCn = trim((string)($b['company_name'] ?? ''));
|
|
|
|
|
+ $aSupplierWin = ($dh !== '' && $aCn !== '' && !empty($winnerSupplierByOrder[$dh][$aCn]));
|
|
|
|
|
+ $bSupplierWin = ($dh !== '' && $bCn !== '' && !empty($winnerSupplierByOrder[$dh][$bCn]));
|
|
|
|
|
+ if ($aSupplierWin !== $bSupplierWin) {
|
|
|
|
|
+ return $aSupplierWin ? -1 : 1;
|
|
|
|
|
+ }
|
|
|
|
|
+ $c = strcmp($aCn, $bCn);
|
|
|
if ($c !== 0) {
|
|
if ($c !== 0) {
|
|
|
return $c;
|
|
return $c;
|
|
|
}
|
|
}
|
|
|
if (!empty($a['picked']) !== !empty($b['picked'])) {
|
|
if (!empty($a['picked']) !== !empty($b['picked'])) {
|
|
|
return !empty($a['picked']) ? -1 : 1;
|
|
return !empty($a['picked']) ? -1 : 1;
|
|
|
}
|
|
}
|
|
|
|
|
+ $c = strcmp((string)($a['gx'] ?? ''), (string)($b['gx'] ?? ''));
|
|
|
|
|
+ if ($c !== 0) {
|
|
|
|
|
+ return $c;
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- return strcmp((string)($a['company_name'] ?? ''), (string)($b['company_name'] ?? ''));
|
|
|
|
|
|
|
+ return 0;
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
return $lines;
|
|
return $lines;
|
|
@@ -7671,11 +7692,35 @@ class Procuremen extends Backend
|
|
|
$sheet->getStyle('D' . $dataStartRow . ':D' . $lastRow)->getAlignment()->setWrapText(true)->setVertical(Alignment::VERTICAL_TOP);
|
|
$sheet->getStyle('D' . $dataStartRow . ':D' . $lastRow)->getAlignment()->setWrapText(true)->setVertical(Alignment::VERTICAL_TOP);
|
|
|
$sheet->getStyle('E' . $dataStartRow . ':E' . $lastRow)->getAlignment()->setWrapText(true)->setVertical(Alignment::VERTICAL_TOP);
|
|
$sheet->getStyle('E' . $dataStartRow . ':E' . $lastRow)->getAlignment()->setWrapText(true)->setVertical(Alignment::VERTICAL_TOP);
|
|
|
$sheet->getRowDimension($titleRow)->setRowHeight(28);
|
|
$sheet->getRowDimension($titleRow)->setRowHeight(28);
|
|
|
|
|
+ if ($lastRow >= $dataStartRow) {
|
|
|
|
|
+ $this->applyMonthExportTableAlignment($sheet, $headerRow, $dataStartRow, $lastRow, 'H');
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
return $lastRow;
|
|
return $lastRow;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 月度导出表格对齐:表头居中、序号列居中、其余列居左
|
|
|
|
|
+ */
|
|
|
|
|
+ protected function applyMonthExportTableAlignment(Worksheet $sheet, int $headerRow, int $dataStartRow, int $lastRow, string $lastCol = 'H'): void
|
|
|
|
|
+ {
|
|
|
|
|
+ if ($lastRow < $dataStartRow || $headerRow < 1) {
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ $sheet->getStyle('A' . $headerRow . ':' . $lastCol . $headerRow)->getAlignment()
|
|
|
|
|
+ ->setHorizontal(Alignment::HORIZONTAL_CENTER)
|
|
|
|
|
+ ->setVertical(Alignment::VERTICAL_CENTER);
|
|
|
|
|
+ $sheet->getStyle('A' . $dataStartRow . ':A' . $lastRow)->getAlignment()
|
|
|
|
|
+ ->setHorizontal(Alignment::HORIZONTAL_CENTER)
|
|
|
|
|
+ ->setVertical(Alignment::VERTICAL_CENTER);
|
|
|
|
|
+ if ($lastCol > 'B') {
|
|
|
|
|
+ $sheet->getStyle('B' . $dataStartRow . ':' . $lastCol . $lastRow)->getAlignment()
|
|
|
|
|
+ ->setHorizontal(Alignment::HORIZONTAL_LEFT)
|
|
|
|
|
+ ->setVertical(Alignment::VERTICAL_CENTER);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* 订单号等用于 PDF 文件名片段(去掉路径非法字符)
|
|
* 订单号等用于 PDF 文件名片段(去掉路径非法字符)
|
|
|
*/
|
|
*/
|