mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/exchange-2.0.git
synced 2026-08-19 04:23:55 +00:00
Merge branch 'white-form-list-upload-bank-slips' of gitlab.com:CIEFWorldwideSdnBhd/exchange-2.0 into vapor/production
# Conflicts: # app/Console/Kernel.php
This commit is contained in:
+79
-1
@@ -1122,6 +1122,7 @@ Route::get('/show-white-form-transactions-in-date-range/{from_date}/{to_date}',
|
||||
echo '<th style="border: 1px solid black;">PO approve date</th>';
|
||||
echo '<th style="border: 1px solid black;">Remark</th>';
|
||||
echo '<th style="border: 1px solid black;">Add Remarks</th>';
|
||||
echo '<th style="border: 1px solid black;">Upload Bank Slip</th>';
|
||||
echo '</tr>';
|
||||
echo '</thead>';
|
||||
echo '<tbody>';
|
||||
@@ -1139,7 +1140,7 @@ Route::get('/show-white-form-transactions-in-date-range/{from_date}/{to_date}',
|
||||
echo '<td style="border: 1px solid black;">' . $bill->created_at->format('d-m-Y h:i A') . '</td>';
|
||||
echo '<td style="border: 1px solid black;">' . $bill->issuerCompany->name . '</td>';
|
||||
echo '<td style="border: 1px solid black; color: '.($bill->status === ApprovalStatus::APPROVED ? "green" : "red").';">' . ($bill->status === ApprovalStatus::APPROVED ? $bill->updated_at->format('d-m-Y h:i A') : 'Pending Upload') . '</td>';
|
||||
echo '<td style="border: 1px solid black; color: '.($po ? "green" : "red").';">' . ($po ? $po->updated_at->format('d-m-Y h:i A') : 'Pending Submission') . '</td>';
|
||||
echo '<td style="border: 1px solid black; color: '.($po ? "green" : "red").';">' . ($po ? $po->updated_at->format('d-m-Y h:i A') : '<a href="' . \route('booking.details', $bill->owner->owner->marking) . '" target="_blank">Pending Submission</a>') . '</td>';
|
||||
echo '<td style="border: 1px solid black;">' . ($po ? ($po->status === ApprovalStatus::APPROVED ? $po->updated_at->format('d-m-Y h:i A') : '' ) : '' ). '</td>';
|
||||
$remarks = $bill->remarks;
|
||||
echo '<td style="border: 1px solid black;">';
|
||||
@@ -1156,11 +1157,88 @@ Route::get('/show-white-form-transactions-in-date-range/{from_date}/{to_date}',
|
||||
echo csrf_field();
|
||||
echo '</form>';
|
||||
echo '</td>';
|
||||
echo '<td style="border: 1px solid black;">' ;
|
||||
if ($bill->status !== ApprovalStatus::APPROVED) {
|
||||
echo '<form id="uploadForm-'.$bill->id.'" enctype="multipart/form-data" style="display:flex; margin: 10px">';
|
||||
echo '<input type="file" name="files[]" multiple required>';
|
||||
echo '<button type="button" onclick="uploadFiles('.$bill->id.')">Upload</button>';
|
||||
echo csrf_field();
|
||||
echo '</form>';
|
||||
}
|
||||
echo '</td>';
|
||||
echo '</tr>';
|
||||
}
|
||||
|
||||
echo '</tbody>';
|
||||
echo '</table>';
|
||||
// script
|
||||
echo '<script>
|
||||
function uploadFiles(billId) {
|
||||
const form = document.getElementById("uploadForm-" + billId);
|
||||
const fileInput = form.querySelector("input[type=\'file\']");
|
||||
const files = fileInput.files;
|
||||
const userToken = localStorage.getItem("user-token");
|
||||
|
||||
if (files.length === 0) {
|
||||
alert("Please select at least one file to upload.");
|
||||
return;
|
||||
}
|
||||
|
||||
const fileReaders = [];
|
||||
let totalFiles = files.length;
|
||||
|
||||
// Create a promise for each file to read it as Base64
|
||||
Array.from(files).forEach((file) => {
|
||||
const reader = new FileReader();
|
||||
|
||||
// Create a promise that resolves when the file is read
|
||||
const fileReadPromise = new Promise((resolve, reject) => {
|
||||
reader.onload = (event) => {
|
||||
resolve(event.target.result);
|
||||
};
|
||||
|
||||
reader.onerror = (error) => {
|
||||
reject(error);
|
||||
};
|
||||
|
||||
reader.readAsDataURL(file); // Read the file as Data URL (Base64)
|
||||
});
|
||||
|
||||
fileReaders.push(fileReadPromise);
|
||||
});
|
||||
|
||||
// Wait for all files to be read
|
||||
Promise.all(fileReaders)
|
||||
.then((fileData) => {
|
||||
const payload = {
|
||||
files: fileData, // Array of objects with name, type, and Base64 content
|
||||
};
|
||||
|
||||
// Send the payload as JSON
|
||||
return fetch(`/api/v1/transactions/${billId}/bill/verification`, {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Authorization": "Bearer " + userToken,
|
||||
"Content-Type": "application/json" // Sending JSON payload
|
||||
},
|
||||
body: JSON.stringify(payload),
|
||||
});
|
||||
})
|
||||
.then(response => {
|
||||
console.log(response);
|
||||
if (response.ok) {
|
||||
alert("Files uploaded successfully!");
|
||||
location.reload();
|
||||
} else {
|
||||
alert("Upload failed");
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
console.error("Error:", error);
|
||||
alert("An error occurred during the upload.");
|
||||
});
|
||||
}
|
||||
</script>';
|
||||
});
|
||||
|
||||
Route::get('check-duplicate-refunds', function () {
|
||||
|
||||
Reference in New Issue
Block a user