Invoices can be uploaded
This commit is contained in:
23
resources/js/components/InvoiceUploadChecks.js
Normal file
23
resources/js/components/InvoiceUploadChecks.js
Normal file
@@ -0,0 +1,23 @@
|
||||
export function checkFilesize(fieldId) {
|
||||
const maxFileSize = 64;
|
||||
|
||||
|
||||
if (document.getElementById(fieldId).files[0].size <= maxFileSize * 1024 * 1024) {
|
||||
return true;
|
||||
} else {
|
||||
alert('Die hochzuladende Datei darf die Größe von 64 MB nicht überschreiten');
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
export function invoiceCheckContactName() {
|
||||
const contact_name_val = document.getElementById('contact_name').value.trim() !== '';
|
||||
const payment = document.getElementById('confirm_payment');
|
||||
|
||||
if (contact_name_val && document.getElementById('account_owner').value === '') {
|
||||
document.getElementById('account_owner').value = document.getElementById('contact_name').value.trim();
|
||||
|
||||
} else {
|
||||
payment.style.display = 'none';
|
||||
}
|
||||
}
|
||||
@@ -8,6 +8,8 @@ export function useAjax() {
|
||||
|
||||
async function request(url, options = {}) {
|
||||
loading.value = true
|
||||
const isFormData = options.body instanceof FormData
|
||||
|
||||
error.value = null
|
||||
data.value = null
|
||||
|
||||
@@ -15,14 +17,19 @@ export function useAjax() {
|
||||
const response = await fetch(url, {
|
||||
method: options.method || "GET",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
'X-CSRF-TOKEN': csrfToken,
|
||||
...(isFormData ? {} : { 'Content-Type': 'application/json' }),
|
||||
...(options.headers || {}),
|
||||
},
|
||||
body: options.body ? JSON.stringify(options.body) : null,
|
||||
body: isFormData
|
||||
? options.body // ✅ FormData direkt
|
||||
: options.body
|
||||
? JSON.stringify(options.body)
|
||||
: null,
|
||||
})
|
||||
|
||||
if (!response.ok) throw new Error(`HTTP ${response.status}`)
|
||||
|
||||
const result = await response.json()
|
||||
data.value = result
|
||||
return result
|
||||
@@ -35,6 +42,7 @@ export function useAjax() {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
async function download(url, options = {}) {
|
||||
loading.value = true
|
||||
error.value = null
|
||||
|
||||
@@ -18,14 +18,26 @@ const globalProps = reactive({
|
||||
user: null,
|
||||
currentPath: '/',
|
||||
errors: {},
|
||||
availableLocalGroups: []
|
||||
availableLocalGroups: [],
|
||||
message: ''
|
||||
});
|
||||
|
||||
|
||||
onMounted(async () => {
|
||||
const response = await fetch('/api/v1/retreive-global-data');
|
||||
const response = await fetch('/api/v1/core/retrieve-global-data');
|
||||
const data = await response.json();
|
||||
Object.assign(globalProps, data);
|
||||
|
||||
const messageResponse = await request('/api/v1/core/retrieve-messages', {
|
||||
method: 'GET',
|
||||
})
|
||||
|
||||
if (messageResponse.message !== '') {
|
||||
if (messageResponse.messageType === 'success') {
|
||||
toast.success(messageResponse.message)
|
||||
} else {
|
||||
toast.error(messageResponse.message)
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
<link rel="stylesheet" href="/css/elements.css" />
|
||||
<link rel="stylesheet" href="/css/modalBox.css" />
|
||||
<link rel="stylesheet" href="/css/costunits.css" />
|
||||
<link rel="stylesheet" href="/css/invoices.css" />
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<meta name="csrf-token" content="{{ csrf_token() }}">
|
||||
|
||||
Reference in New Issue
Block a user