diff --git a/.gitignore b/.gitignore
index 098a9a18..74665935 100644
--- a/.gitignore
+++ b/.gitignore
@@ -17,3 +17,7 @@ wms/database.php
workflow/log/
wms/header.php
wms/loginapi.php
+wms/excel/gary_test.xlsx
+wms/excel/wipwholeintall.xlsx
+wms/excel/estimated_shipping_date_report.xlsx
+*.docx
diff --git a/wms/cont/sign_form.php b/wms/cont/sign_form.php
index c0f18d9e..97e92175 100644
--- a/wms/cont/sign_form.php
+++ b/wms/cont/sign_form.php
@@ -475,7 +475,7 @@ function get_sequnece_no($seq_name = '', $p_yyyymm = '')
-
+
diff --git a/wms/crm/crmm01-index.php b/wms/crm/crmm01-index.php
index 06fd0f02..f770edb9 100644
--- a/wms/crm/crmm01-index.php
+++ b/wms/crm/crmm01-index.php
@@ -41,8 +41,8 @@ $salesman = empty($_GET['salesman']) ? "%" : $_GET['salesman'];
$where .= " and salesman_name like '$salesman'";
$sql_cmd = sql_myself($user_id, "salesman");
-// max,許紓晴,林慧珊
-if (in_array($user_department_id, $depart_arr) || $user_id == "M0060" || $user_id == "M0107" || $user_id == "M0193") $sql_cmd = "";
+// max,許紓晴,林慧珊,鄭伊岑
+if (in_array($user_department_id, $depart_arr) || $user_id == "M0060" || $user_id == "M0107" || $user_id == "M0193" || $user_id == "M0149") $sql_cmd = "";
if (!empty($sql_cmd)) $where .= " and ".str_replace("where", "", $sql_cmd);
/*
$checkAll = ['p0044', 'M0007'];
diff --git a/wms/crm/crmm02-index.php b/wms/crm/crmm02-index.php
index a93fc9bb..671b7b2f 100644
--- a/wms/crm/crmm02-index.php
+++ b/wms/crm/crmm02-index.php
@@ -42,7 +42,7 @@ $where .= " and salesman like '$salesman'";
$lm_name = empty($_GET['linkman']) ? "%" : $_GET['linkman'];
$where .= " and linkman like '$lm_name'";
$sql_cmd = sql_myself($user_id, "salesman");
-if (in_array($user_department_id, $depart_arr) || $user_id == "M0060") $sql_cmd = ""; // M0060:Max
+if (in_array($user_department_id, $depart_arr) || $user_id == "M0060" || $user_id == "M0149") $sql_cmd = ""; // M0060:Max,鄭伊岑
if (!empty($sql_cmd)) $where .= " and ".str_replace("where", "", $sql_cmd);
$sql = "SELECT vol_no,customer,manager,f_return_content('customer_source',source ) source,
diff --git a/wms/estimated_shipping_date_report.php b/wms/estimated_shipping_date_report.php
index 9872d265..a428e639 100644
--- a/wms/estimated_shipping_date_report.php
+++ b/wms/estimated_shipping_date_report.php
@@ -29,6 +29,8 @@ $sql = "
w.contract_type
FROM wipwholestatus AS w
WHERE status = '1'
+ AND real_contract_arrival_date >= '$start_y-$start_m-1'
+ AND real_contract_arrival_date <= '$end_y-$end_m-31'
) AS this_order
WHERE 1 = 1
GROUP BY this_order.contract_type,
@@ -41,7 +43,7 @@ $data = [];
while ($row = $result->fetch_assoc()) {
$data[] = $row;
}
-// print_r($data);
+
function findData($data, $searchData)
{
foreach ($data as $item) {
@@ -115,7 +117,6 @@ function findAllDataByYearMonth($data, $searchData)
&& $item['date_year'] == $i
&& $item['date_month'] == str_pad($j, 2, '0', STR_PAD_LEFT)
) {
- // echo $item['facility_count']." ";
$count += $item['facility_count'];
}
}
@@ -134,8 +135,9 @@ $sql = "
FROM wipwholestatus AS w
WHERE 1=1
AND status = '1'
- AND real_contract_arrival_date >= '$start_y-$start_m-0'
- AND real_contract_arrival_date <= '$end_y-$end_m-0'
+ AND contract_type = 'A'
+ AND real_contract_arrival_date >= '$start_y-$start_m-1'
+ AND real_contract_arrival_date <= '$end_y-$end_m-31'
) AS new_order
WHERE 1 = 1
GROUP BY new_order.facility_kind
@@ -175,8 +177,8 @@ $sql = "
FROM wipwholestatus AS w
WHERE 1=1
AND status = '1'
- AND real_contract_arrival_date >= '$start_y-$start_m-0'
- AND real_contract_arrival_date <= '$end_y-$end_m-0'
+ AND real_contract_arrival_date >= '$start_y-$start_m-1'
+ AND real_contract_arrival_date <= '$end_y-$end_m-31'
AND contract_type = 'B'
";
$result = mysqli_query($link, $sql);
@@ -184,28 +186,42 @@ $data3 = [];
while ($row = $result->fetch_assoc()) {
$data3[] = $row;
}
-$M1 = 0;
-$M2 = 0;
-$M3 = 0;
-$M4 = 0;
-$MA = 0;
-$M_count = 0;
+
+// 分開計算
+
+// $M1 = 0;
+// $M2 = 0;
+// $M3 = 0;
+// $M4 = 0;
+// $MA = 0;
+// $M_count = 0;
+// foreach ($data3 as $row) {
+// $renovate_type_arr = json_decode($row['renovate_type']);
+// foreach ($renovate_type_arr as $row2) {
+// if ($row2 == 'M1')
+// $M1++;
+// if ($row2 == 'M2')
+// $M2++;
+// if ($row2 == 'M3')
+// $M3++;
+// if ($row2 == 'M4')
+// $M4++;
+// if ($row2 == 'MA')
+// $MA++;
+// }
+// }
+// $M_count = $M1 + $M2 + $M3 + $M4 + $MA;
+
+$M_count = count($data3);
+$m_type_arr = [];
+$m_type_arr[''] = 0;
+foreach ($data3 as $row) {
+ $m_type_arr[implode("+", json_decode($row['renovate_type']))] = 0;
+}
foreach ($data3 as $row) {
- $renovate_type_arr = json_decode($row['renovate_type']);
- foreach ($renovate_type_arr as $row2) {
- if ($row2 == 'M1')
- $M1++;
- if ($row2 == 'M2')
- $M2++;
- if ($row2 == 'M3')
- $M3++;
- if ($row2 == 'M4')
- $M4++;
- if ($row2 == 'MA')
- $MA++;
- }
+ $m_type_arr[implode("+", json_decode($row['renovate_type']))]++;
}
-$M_count = $M1 + $M2 + $M3 + $M4 + $MA;
+
//數字轉英文(0=>A、1=>B、26=>AA...以此類推)
function num2alpha($n)
@@ -224,264 +240,259 @@ function alpha2num($a)
$n = $n * 26 + ord($a[$i]) - 0x40;
return $n - 1;
}
+if($_SERVER["REQUEST_METHOD"] == 'POST'){
+ if ($_POST['excel_output'] == 'excel_output') {
+ $spreadsheet = new Spreadsheet();
+ $sheet = $spreadsheet->getActiveSheet();
+ $sheet->setTitle('出貨總表');
-if ($_POST['excel_output'] == 'excel_output') {
- $spreadsheet = new Spreadsheet();
- $sheet = $spreadsheet->getActiveSheet();
- $sheet->setTitle('出貨總表');
-
- $title_col_num = 3;
- for ($i = $start_y; $i <= $end_y; $i++) {
- $this_start_m = $i == $start_y ? $start_m : 1;
- $this_end_m = $i == $start_y ? 12 : $end_m;
- for ($j = $this_start_m; $j <= $this_end_m; $j++) {
- $title_col_num += 2;
- if ($i == $end_y && $j == ($end_m + 1)) {
- break;
+ $title_col_num = 3;
+ for ($i = $start_y; $i <= $end_y; $i++) {
+ $this_start_m = $i == $start_y ? $start_m : 1;
+ $this_end_m = $i == $start_y ? 12 : $end_m;
+ for ($j = $this_start_m; $j <= $this_end_m; $j++) {
+ $title_col_num += 2;
+ if ($i == $end_y && $j == ($end_m + 1)) {
+ break;
+ }
}
}
- }
- $sheet->mergeCells('A1:' . num2alpha($title_col_num) . '1');
- $sheet->setCellValue('A1', '出貨地區預定明細');
+ $sheet->mergeCells('A1:' . num2alpha($title_col_num) . '1');
+ $sheet->setCellValue('A1', '出貨地區預定明細');
- $title_col_num = 0;
- $sheet->setCellValue(num2alpha($title_col_num) . '2', '');
- $title_col_num++;
- $sheet->setCellValue(num2alpha($title_col_num) . '2', '');
- $title_col_num++;
+ $title_col_num = 0;
+ $sheet->setCellValue(num2alpha($title_col_num) . '2', '');
+ $title_col_num++;
+ $sheet->setCellValue(num2alpha($title_col_num) . '2', '');
+ $title_col_num++;
- for ($i = $start_y; $i <= $end_y; $i++) {
- $this_start_m = $i == $start_y ? $start_m : 1;
- $this_end_m = $i == $start_y ? 12 : $end_m;
- for ($j = $this_start_m; $j <= $this_end_m; $j++) {
- if ($i == $end_y && $j == ($end_m + 1))
- break;
- $sheet->mergeCells(num2alpha($title_col_num) . '2:' . num2alpha($title_col_num + 1) . '2');
- $sheet->setCellValue(num2alpha($title_col_num) . '2', $i . '年' . $j . '月');
- $title_col_num += 2;
+ for ($i = $start_y; $i <= $end_y; $i++) {
+ $this_start_m = $i == $start_y ? $start_m : 1;
+ $this_end_m = $i == $start_y ? 12 : $end_m;
+ for ($j = $this_start_m; $j <= $this_end_m; $j++) {
+ if ($i == $end_y && $j == ($end_m + 1))
+ break;
+ $sheet->mergeCells(num2alpha($title_col_num) . '2:' . num2alpha($title_col_num + 1) . '2');
+ $sheet->setCellValue(num2alpha($title_col_num) . '2', $i . '年' . $j . '月');
+ $title_col_num += 2;
+ }
}
- }
- $sheet->setCellValue(num2alpha($title_col_num) . '2', '累計台數');
- $title_col_num++;
- $sheet->setCellValue(num2alpha($title_col_num) . '2', '累計台數');
- $title_col_num++;
+ $sheet->setCellValue(num2alpha($title_col_num) . '2', '累計台數');
+ $title_col_num++;
+ $sheet->setCellValue(num2alpha($title_col_num) . '2', '累計台數');
+ $title_col_num++;
- $title_col_num = 0;
- $sheet->setCellValue(num2alpha($title_col_num) . '3', '區域');
- $title_col_num = 2;
+ $title_col_num = 0;
+ $sheet->setCellValue(num2alpha($title_col_num) . '3', '區域');
+ $title_col_num = 2;
- for ($i = $start_y; $i <= $end_y; $i++) {
- $this_start_m = $i == $start_y ? $start_m : 1;
- $this_end_m = $i == $start_y ? 12 : $end_m;
- for ($j = $this_start_m; $j <= $this_end_m; $j++) {
- if ($i == $end_y && $j == ($end_m + 1)) {
- break;
+ for ($i = $start_y; $i <= $end_y; $i++) {
+ $this_start_m = $i == $start_y ? $start_m : 1;
+ $this_end_m = $i == $start_y ? 12 : $end_m;
+ for ($j = $this_start_m; $j <= $this_end_m; $j++) {
+ if ($i == $end_y && $j == ($end_m + 1)) {
+ break;
+ }
+ $sheet->setCellValue(num2alpha($title_col_num) . '3', '新梯');
+ $title_col_num++;
+ $sheet->setCellValue(num2alpha($title_col_num) . '3', '汰改');
+ $title_col_num++;
}
- $sheet->setCellValue(num2alpha($title_col_num) . '3', '新梯');
+ }
+ $sheet->setCellValue(num2alpha($title_col_num) . '3', '新梯');
+ $title_col_num++;
+ $sheet->setCellValue(num2alpha($title_col_num) . '3', '汰改');
+ $title_col_num++;
+
+ $area_arr = [
+ [4, 6, '台北'],
+ [7, 9, '桃竹苗'],
+ [10, 13, '中部'],
+ [14, 17, '南部'],
+ [18, 20, '宜花東'],
+ [21, 21, '未分類']
+ ];
+ foreach ($area_arr as $row) {
+ $title_col_num = 0;
+ $sheet->mergeCells(num2alpha($title_col_num) . $row[0] . ':' . num2alpha($title_col_num) . $row[1]);
+ $sheet->setCellValue(num2alpha($title_col_num) . $row[0], $row[2]);
+ }
+
+ $area_arr = [
+ [4, '台北'],
+ [5, '新北'],
+ [6, '基隆'],
+ [7, '桃園'],
+ [8, '新竹'],
+ [9, '苗栗'],
+ [10, '台中'],
+ [11, '南投'],
+ [12, '彰化'],
+ [13, '雲林'],
+ [14, '嘉義'],
+ [15, '台南'],
+ [16, '高雄'],
+ [17, '屏東'],
+ [18, '宜蘭'],
+ [19, '花蓮'],
+ [20, '台東'],
+ [21, '']
+ ];
+ foreach ($area_arr as $row) {
+ $title_col_num = 0;
+ $title_col_num++;
+ $sheet->setCellValue(num2alpha($title_col_num) . $row[0], $row[1]);
+ for ($i = $start_y; $i <= $end_y; $i++) {
+ $this_start_m = $i == $start_y ? $start_m : 1;
+ $this_end_m = $i == $start_y ? 12 : $end_m;
+ for ($j = $this_start_m; $j <= $this_end_m; $j++) {
+ if ($i == $end_y && $j == ($end_m + 1)) {
+ break;
+ }
+ $tmp_arr = array(
+ 'date_year' => $i,
+ 'date_month' => str_pad($j, 2, '0', STR_PAD_LEFT),
+ 'sub_address' => $row[1],
+ 'contract_type' => 'A',
+ );
+ $title_col_num++;
+ $sheet->setCellValue(num2alpha($title_col_num) . $row[0], findData($data, $tmp_arr));
+ $tmp_arr['contract_type'] = 'B';
+ $title_col_num++;
+ $sheet->setCellValue(num2alpha($title_col_num) . $row[0], findData($data, $tmp_arr));
+ }
+ }
+ $tmp_arr = array(
+ 'start_y' => $start_y,
+ 'end_y' => $end_y,
+ 'start_m' => $start_m,
+ 'end_m' => $end_m,
+ 'sub_address' => $row[1],
+ 'contract_type' => 'A',
+ );
$title_col_num++;
- $sheet->setCellValue(num2alpha($title_col_num) . '3', '汰改');
+ $sheet->setCellValue(num2alpha($title_col_num) . $row[0], findDataByCity($data, $tmp_arr));
+ $tmp_arr['contract_type'] = 'B';
$title_col_num++;
+ $sheet->setCellValue(num2alpha($title_col_num) . $row[0], findDataByCity($data, $tmp_arr));
}
- }
- $sheet->setCellValue(num2alpha($title_col_num) . '3', '新梯');
- $title_col_num++;
- $sheet->setCellValue(num2alpha($title_col_num) . '3', '汰改');
- $title_col_num++;
- $area_arr = [
- [4, 6, '台北'],
- [7, 9, '桃竹苗'],
- [10, 13, '中部'],
- [14, 17, '南部'],
- [18, 20, '宜花東'],
- [21, 21, '未分類']
- ];
- foreach ($area_arr as $row) {
- $title_col_num = 0;
- $sheet->mergeCells(num2alpha($title_col_num) . $row[0] . ':' . num2alpha($title_col_num) . $row[1]);
- $sheet->setCellValue(num2alpha($title_col_num) . $row[0], $row[2]);
- }
- $area_arr = [
- [4, '台北'],
- [5, '新北'],
- [6, '基隆'],
- [7, '桃園'],
- [8, '新竹'],
- [9, '苗栗'],
- [10, '台中'],
- [11, '南投'],
- [12, '彰化'],
- [13, '雲林'],
- [14, '嘉義'],
- [15, '台南'],
- [16, '高雄'],
- [17, '屏東'],
- [18, '宜蘭'],
- [19, '花蓮'],
- [20, '台東'],
- [21, '']
- ];
- foreach ($area_arr as $row) {
$title_col_num = 0;
$title_col_num++;
- $sheet->setCellValue(num2alpha($title_col_num) . $row[0], $row[1]);
+ $sheet->setCellValue(num2alpha($title_col_num) . '22', "合計");
for ($i = $start_y; $i <= $end_y; $i++) {
$this_start_m = $i == $start_y ? $start_m : 1;
$this_end_m = $i == $start_y ? 12 : $end_m;
for ($j = $this_start_m; $j <= $this_end_m; $j++) {
- if ($i == $end_y && $j == ($end_m + 1)) {
+ if ($i == $end_y && $j == ($end_m + 1))
break;
- }
$tmp_arr = array(
'date_year' => $i,
'date_month' => str_pad($j, 2, '0', STR_PAD_LEFT),
- 'sub_address' => $row[1],
'contract_type' => 'A',
);
$title_col_num++;
- $sheet->setCellValue(num2alpha($title_col_num) . $row[0], findData($data, $tmp_arr));
+ $sheet->setCellValue(num2alpha($title_col_num) . '22', findDataByYearMonth($data, $tmp_arr));
$tmp_arr['contract_type'] = 'B';
$title_col_num++;
- $sheet->setCellValue(num2alpha($title_col_num) . $row[0], findData($data, $tmp_arr));
+ $sheet->setCellValue(num2alpha($title_col_num) . '22', findDataByYearMonth($data, $tmp_arr));
}
}
$tmp_arr = array(
'start_y' => $start_y,
- 'end_y' => $end_y,
- 'start_m' => $start_m,
+ 'end_y' => $end_y,
+ 'start_m' => $start_m,
'end_m' => $end_m,
- 'sub_address' => $row[1],
'contract_type' => 'A',
);
$title_col_num++;
- $sheet->setCellValue(num2alpha($title_col_num) . $row[0], findDataByCity($data, $tmp_arr));
+ $sheet->setCellValue(num2alpha($title_col_num) . '22', findAllDataByYearMonth($data, $tmp_arr));
$tmp_arr['contract_type'] = 'B';
$title_col_num++;
- $sheet->setCellValue(num2alpha($title_col_num) . $row[0], findDataByCity($data, $tmp_arr));
- }
-
-
- $title_col_num = 0;
- $title_col_num++;
- $sheet->setCellValue(num2alpha($title_col_num) . '22', "合計");
- for ($i = $start_y; $i <= $end_y; $i++) {
- $this_start_m = $i == $start_y ? $start_m : 1;
- $this_end_m = $i == $start_y ? 12 : $end_m;
- for ($j = $this_start_m; $j <= $this_end_m; $j++) {
- if ($i == $end_y && $j == ($end_m + 1))
- break;
- $tmp_arr = array(
- 'date_year' => $i,
- 'date_month' => str_pad($j, 2, '0', STR_PAD_LEFT),
- 'contract_type' => 'A',
- );
- $title_col_num++;
- $sheet->setCellValue(num2alpha($title_col_num) . '22', findDataByYearMonth($data, $tmp_arr));
- $tmp_arr['contract_type'] = 'B';
- $title_col_num++;
- $sheet->setCellValue(num2alpha($title_col_num) . '22', findDataByYearMonth($data, $tmp_arr));
- }
- }
- $tmp_arr = array(
- 'start_y' => $start_y,
- 'end_y' => $end_y,
- 'start_m' => $start_m,
- 'end_m' => $end_m,
- 'contract_type' => 'A',
- );
- $title_col_num++;
- $sheet->setCellValue(num2alpha($title_col_num) . '22', findAllDataByYearMonth($data, $tmp_arr));
- $tmp_arr['contract_type'] = 'B';
- $title_col_num++;
- $sheet->setCellValue(num2alpha($title_col_num) . '22', findAllDataByYearMonth($data, $tmp_arr));
+ $sheet->setCellValue(num2alpha($title_col_num) . '22', findAllDataByYearMonth($data, $tmp_arr));
- $sheet->mergeCells('A25:I25');
- $sheet->setCellValue('A25', '受定規格分析');
+ $sheet->mergeCells('A25:I25');
+ $sheet->setCellValue('A25', '受定規格分析');
- $title_col_num = 0;
- $sheet->setCellValue(num2alpha($title_col_num) . '26', "代碼");
- foreach ($data2 as $row) {
- $title_col_num++;
- $sheet->setCellValue(num2alpha($title_col_num) . '26', $row['facility_kind']);
- }
+ $title_col_num = 0;
+ $sheet->setCellValue(num2alpha($title_col_num) . '26', "代碼");
+ foreach ($data2 as $row) {
+ $title_col_num++;
+ $sheet->setCellValue(num2alpha($title_col_num) . '26', $row['facility_kind']);
+ }
- $title_col_num = 0;
- $sheet->setCellValue(num2alpha($title_col_num) . '27', "機種");
- foreach ($data2 as $row) {
+ $title_col_num = 0;
+ $sheet->setCellValue(num2alpha($title_col_num) . '27', "機種");
+ foreach ($data2 as $row) {
+ $title_col_num++;
+ $sheet->setCellValue(num2alpha($title_col_num) . '27', getFacilityNamebyType($row['facility_kind']));
+ }
$title_col_num++;
- $sheet->setCellValue(num2alpha($title_col_num) . '27', getFacilityNamebyType($row['facility_kind']));
- }
- $title_col_num++;
- $sheet->setCellValue(num2alpha($title_col_num) . '27', "合計");
+ $sheet->setCellValue(num2alpha($title_col_num) . '27', "合計");
- $title_col_num = 0;
- $sheet->setCellValue(num2alpha($title_col_num) . '28', "數量");
- foreach ($data2 as $row) {
+ $title_col_num = 0;
+ $sheet->setCellValue(num2alpha($title_col_num) . '28', "數量");
+ foreach ($data2 as $row) {
+ $title_col_num++;
+ $sheet->setCellValue(num2alpha($title_col_num) . '28', $row['facility_count']);
+ }
$title_col_num++;
- $sheet->setCellValue(num2alpha($title_col_num) . '28', $row['facility_count']);
- }
- $title_col_num++;
- $sheet->setCellValue(num2alpha($title_col_num) . '28', findFacilityTypeAllCount($data2));
+ $sheet->setCellValue(num2alpha($title_col_num) . '28', findFacilityTypeAllCount($data2));
- $title_col_num = 0;
- $sheet->setCellValue(num2alpha($title_col_num) . '29', "百分比");
- foreach ($data2 as $row) {
+ $title_col_num = 0;
+ $sheet->setCellValue(num2alpha($title_col_num) . '29', "百分比");
+ foreach ($data2 as $row) {
+ $title_col_num++;
+ $sheet->setCellValue(num2alpha($title_col_num) . '29', (round($row['facility_count'] / findFacilityTypeAllCount($data2), 4) * 100) . "%");
+ }
$title_col_num++;
- $sheet->setCellValue(num2alpha($title_col_num) . '29', (round($row['facility_count'] / findFacilityTypeAllCount($data2), 4) * 100) . "%");
- }
- $title_col_num++;
- $sheet->setCellValue(num2alpha($title_col_num) . '29', "100%");
+ $sheet->setCellValue(num2alpha($title_col_num) . '29', "100%");
- $sheet->mergeCells('A32:G32');
- $sheet->setCellValue('G25', '舊改受訂規格分析');
+ $sheet->mergeCells('A32:G32');
+ $sheet->setCellValue('G25', '舊改受訂規格分析');
- $title_col_num = 0;
- $sheet->setCellValue(num2alpha($title_col_num++) . '33', "類型");
- $sheet->setCellValue(num2alpha($title_col_num++) . '33', "M1");
- $sheet->setCellValue(num2alpha($title_col_num++) . '33', "M2");
- $sheet->setCellValue(num2alpha($title_col_num++) . '33', "M3");
- $sheet->setCellValue(num2alpha($title_col_num++) . '33', "M4");
- $sheet->setCellValue(num2alpha($title_col_num++) . '33', "MA");
- $sheet->setCellValue(num2alpha($title_col_num++) . '33', "合計");
+ $title_col_num = 0;
+ $sheet->setCellValue(num2alpha($title_col_num++) . '33', "類型");
+ foreach ($m_type_arr as $key => $val) {
+ $title_tmp = empty($key) ? '未分類' : $key;
+ $sheet->setCellValue(num2alpha($title_col_num++) . '33', $title_tmp);
+ }
+ $sheet->setCellValue(num2alpha($title_col_num++) . '33', "合計");
- $title_col_num = 0;
- $sheet->setCellValue(num2alpha($title_col_num++) . '34', "數量");
- $sheet->setCellValue(num2alpha($title_col_num++) . '34', $M1);
- $sheet->setCellValue(num2alpha($title_col_num++) . '34', $M2);
- $sheet->setCellValue(num2alpha($title_col_num++) . '34', $M3);
- $sheet->setCellValue(num2alpha($title_col_num++) . '34', $M4);
- $sheet->setCellValue(num2alpha($title_col_num++) . '34', $MA);
- $sheet->setCellValue(num2alpha($title_col_num++) . '34', $M_count);
+ $title_col_num = 0;
+ $sheet->setCellValue(num2alpha($title_col_num++) . '34', "數量");
+ foreach ($m_type_arr as $key => $val) {
+ $sheet->setCellValue(num2alpha($title_col_num++) . '34', $val);
+ }
+ $sheet->setCellValue(num2alpha($title_col_num++) . '34', $M_count);
- $title_col_num = 0;
- $sheet->setCellValue(num2alpha($title_col_num++) . '34', "百分比");
- $sheet->setCellValue(num2alpha($title_col_num++) . '34', (round($M1 / $M_count, 4) * 100) . "%");
- $sheet->setCellValue(num2alpha($title_col_num++) . '34', (round($M2 / $M_count, 4) * 100) . "%");
- $sheet->setCellValue(num2alpha($title_col_num++) . '34', (round($M3 / $M_count, 4) * 100) . "%");
- $sheet->setCellValue(num2alpha($title_col_num++) . '34', (round($M4 / $M_count, 4) * 100) . "%");
- $sheet->setCellValue(num2alpha($title_col_num++) . '34', (round($MA / $M_count, 4) * 100) . "%");
- $sheet->setCellValue(num2alpha($title_col_num++) . '34', "100%");
+ $title_col_num = 0;
+ $sheet->setCellValue(num2alpha($title_col_num++) . '35', "百分比");
+ foreach ($m_type_arr as $key => $val) {
+ $sheet->setCellValue(num2alpha($title_col_num++) . '35', (round($val / $M_count, 4) * 100) . "%");
+ }
+ $sheet->setCellValue(num2alpha($title_col_num++) . '35', "100%");
- $writer = new Xlsx($spreadsheet);
- $file_path = dirname(__DIR__) . '/wms/excel/' . 'estimated_shipping_date_report.xlsx';
- try {
- $writer->save($file_path);
- // 回傳檔案路徑給 JavaScript
- echo $file_path;
- } catch (Exception $e) {
- echo 'Error: ' . $e->getMessage();
+ $writer = new Xlsx($spreadsheet);
+ $file_path = dirname(__DIR__) . '/wms/excel/' . 'estimated_shipping_date_report.xlsx';
+ try {
+ $writer->save($file_path);
+ // 回傳檔案路徑給 JavaScript
+ echo $file_path;
+ } catch (Exception $e) {
+ echo 'Error: ' . $e->getMessage();
+ }
+ exit();
}
- exit();
}
-
?>