diff --git a/wms/contract/api/postContractNewApplyData.php b/wms/contract/api/postContractNewApplyData.php
index 5396cef2..d7e3c107 100644
--- a/wms/contract/api/postContractNewApplyData.php
+++ b/wms/contract/api/postContractNewApplyData.php
@@ -1,11 +1,16 @@
bindParam(':created_by', $created_by);
$stmt ->execute();
}
-
+ // -----處理檔案上傳 START-----
+ if(!empty($files)){
+ $englisharr = range('a', 'z');
+ $files = $_FILES['files'];
+ $newfiles = [];
+ foreach( $files as $file ){
+ $i = 0; //新陣列的索引編號
+ foreach( $file as $key => $val ){
+ $newfiles[$i]['name'] = $files['name'][$key];
+ $newfiles[$i]['type'] = $files['type'][$key];
+ $newfiles[$i]['tmp_name'] = $files['tmp_name'][$key];
+ $newfiles[$i]['error'] = $files['error'][$key];
+ $newfiles[$i]['size'] = $files['size'][$key];
+ $i++;
+ } //foreach 第2層 end
+ }
+ $max_size = 4096*4096; //設定允許上傳檔案容量的最大值(1M)
+ $allow_ext = array('jpeg', 'jpg', 'png','JPG','JPEG','PNG','GIF', 'docx', 'doc', 'pdf'); //設定允許上傳檔案的類型
+ $path = '../images/contracts_new_files/';
+ if (!file_exists($path)): mkdir($path); endif;
+ $msg_result = ''; //負責接收所有檔案檢測後的回傳訊息
+ $datetime = (string)date('YmdHis');
+ $files_id = 'm' . $datetime; // 保養=>b + 日期時間
+ foreach( $newfiles as $key => $file ){
+ $randNum = rand(1000,9999);
+ $randEnglish = $englisharr[rand(0,25)];
+ $file_name = 'm' . (string)date('YmdHis') . $randNum . $randEnglish . $randNum.$file['name'];
+ $msg = upload_chk( $file,$path, $max_size, $allow_ext, $file_name );
+ if($msg==1){
+ $msg = '檔案傳送成功!';
+ $sql_str = "INSERT INTO contract_apply_files (contract_id, contract_type, file_name, file_mime, file_size, created_at, created_by) VALUES (:contract_id, :contract_type, :file_name, :file_mime, :file_size, :created_at, :created_by)";
+ $stmt = $conn -> prepare($sql_str);
+ $stmt -> bindParam(':contract_id' ,$contract_apply_id);
+ $stmt -> bindParam(':contract_type' ,$contract_type);
+ $stmt -> bindParam(':file_name' ,$file_name);
+ $stmt -> bindParam(':file_mime' ,$file['type']);
+ $stmt -> bindParam(':file_size' ,$file['size']);
+ $stmt -> bindParam(':created_at' ,$created_at);
+ $stmt -> bindParam(':created_by' ,$created_by);
+ $stmt ->execute();
+ }else{
+ throw new PDOException('檔案上傳失敗:' . $msg);
+ }
+ $msg_result .= '第' . ($key+1) . '個上傳檔案的結果:' . $msg . '
';
+ $src_name = $path.$file['name'];
+ if( file_exists($src_name) ){
+ //副檔名
+ $extname = pathinfo($src_name, PATHINFO_EXTENSION);
+ //主檔名
+ $basename = basename($src_name, '.'.$extname);
+ }
+ }
+ }
+ // -----處理檔案上傳 END-----
header("HTTP/1.1 201 success!");
$conn->commit();
}else{
diff --git a/wms/contract/contract-new-apply.php b/wms/contract/contract-new-apply.php
index 1aef484b..d53c5e62 100644
--- a/wms/contract/contract-new-apply.php
+++ b/wms/contract/contract-new-apply.php
@@ -46,6 +46,7 @@ if(empty($contract_new_apply)){
$stmt->execute();
$items = $stmt->fetchAll(PDO::FETCH_ASSOC);
$total_items = 0;
+ print_r($items);
foreach($items as $item){
$total_items += $item['item_qty'];
}
@@ -94,6 +95,7 @@ if(empty($contract_new_apply)){
$secondPayDeadline = $contract['secondPayDeadline'] ?? 0;
$status = isset($contract['status']) ? $contract['status'] : -1;
$person = $contract['person'];
+
?>
@@ -167,17 +169,17 @@ $person = $contract['person'];
未填寫
未填寫
未填寫
未填寫
未填寫
未填寫
第二期款交貨期限(日) | +
+
+ 未填寫 + |
+
+ 附件上傳+ |
+ |||||||||
第二期款交貨期限(日) | -+ | 附件上傳 | ++ + |