|
@@ -42,7 +42,9 @@
|
|
|
<div v-if="isLoggedIn">
|
|
<div v-if="isLoggedIn">
|
|
|
<NavigationTabs
|
|
<NavigationTabs
|
|
|
:active-section="activeSection"
|
|
:active-section="activeSection"
|
|
|
|
|
+ :current-user="currentUser"
|
|
|
@section-change="activeSection = $event"
|
|
@section-change="activeSection = $event"
|
|
|
|
|
+ @logout="logout"
|
|
|
/>
|
|
/>
|
|
|
|
|
|
|
|
<!-- Items Section -->
|
|
<!-- Items Section -->
|
|
@@ -247,6 +249,22 @@
|
|
|
v-if="activeSection === 'tasks'"
|
|
v-if="activeSection === 'tasks'"
|
|
|
:active-section="activeSection"
|
|
:active-section="activeSection"
|
|
|
/>
|
|
/>
|
|
|
|
|
+
|
|
|
|
|
+ <!-- User Management Section (Admin Only) -->
|
|
|
|
|
+ <UserManagement
|
|
|
|
|
+ v-if="activeSection === 'user-management' && currentUser && currentUser.role === 'admin'"
|
|
|
|
|
+ :current-user="currentUser"
|
|
|
|
|
+ @success="showSuccess"
|
|
|
|
|
+ @error="showError"
|
|
|
|
|
+ />
|
|
|
|
|
+
|
|
|
|
|
+ <!-- Profile Management Section (All Users) -->
|
|
|
|
|
+ <ProfileManagement
|
|
|
|
|
+ v-if="activeSection === 'profile' && currentUser"
|
|
|
|
|
+ :current-user="currentUser"
|
|
|
|
|
+ @success="showSuccess"
|
|
|
|
|
+ @error="showError"
|
|
|
|
|
+ />
|
|
|
</div>
|
|
</div>
|
|
|
</div>
|
|
</div>
|
|
|
</header>
|
|
</header>
|
|
@@ -1473,7 +1491,7 @@
|
|
|
</template>
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
<script>
|
|
|
-import axios from './api/axios'
|
|
|
|
|
|
|
+import api from './api/axios'
|
|
|
import { formatDate, formatCurrency, formatDateTime } from './utils/locale.js'
|
|
import { formatDate, formatCurrency, formatDateTime } from './utils/locale.js'
|
|
|
import NavigationTabs from './components/common/NavigationTabs.vue'
|
|
import NavigationTabs from './components/common/NavigationTabs.vue'
|
|
|
import ProjectsSection from './components/projects/ProjectsSection.vue'
|
|
import ProjectsSection from './components/projects/ProjectsSection.vue'
|
|
@@ -1484,6 +1502,8 @@ import ExcelAccountingSection from './components/accounting/ExcelAccountingSecti
|
|
|
import TuloslaskelmaSection from './components/accounting/TuloslaskelmaSection.vue'
|
|
import TuloslaskelmaSection from './components/accounting/TuloslaskelmaSection.vue'
|
|
|
import ALVLaskentaSection from './components/accounting/ALVLaskentaSection.vue'
|
|
import ALVLaskentaSection from './components/accounting/ALVLaskentaSection.vue'
|
|
|
import TaskManagementSection from './components/projects/TaskManagementSection.vue'
|
|
import TaskManagementSection from './components/projects/TaskManagementSection.vue'
|
|
|
|
|
+import UserManagement from './components/UserManagement.vue'
|
|
|
|
|
+import ProfileManagement from './components/ProfileManagement.vue'
|
|
|
|
|
|
|
|
export default {
|
|
export default {
|
|
|
name: 'App',
|
|
name: 'App',
|
|
@@ -1496,7 +1516,9 @@ export default {
|
|
|
ExcelAccountingSection,
|
|
ExcelAccountingSection,
|
|
|
TuloslaskelmaSection,
|
|
TuloslaskelmaSection,
|
|
|
ALVLaskentaSection,
|
|
ALVLaskentaSection,
|
|
|
- TaskManagementSection
|
|
|
|
|
|
|
+ TaskManagementSection,
|
|
|
|
|
+ UserManagement,
|
|
|
|
|
+ ProfileManagement
|
|
|
},
|
|
},
|
|
|
data() {
|
|
data() {
|
|
|
return {
|
|
return {
|
|
@@ -1698,7 +1720,7 @@ export default {
|
|
|
async fetchItems() {
|
|
async fetchItems() {
|
|
|
this.loading = true
|
|
this.loading = true
|
|
|
try {
|
|
try {
|
|
|
- const response = await axios.get('/api/items.php')
|
|
|
|
|
|
|
+ const response = await api.get('/items.php')
|
|
|
this.items = response.data.records || []
|
|
this.items = response.data.records || []
|
|
|
} catch (error) {
|
|
} catch (error) {
|
|
|
this.showMessage('Error fetching items: ' + error.message, 'error')
|
|
this.showMessage('Error fetching items: ' + error.message, 'error')
|
|
@@ -1710,10 +1732,10 @@ export default {
|
|
|
async saveItem() {
|
|
async saveItem() {
|
|
|
try {
|
|
try {
|
|
|
if (this.isEditing) {
|
|
if (this.isEditing) {
|
|
|
- await axios.put('/api/items.php', this.formData)
|
|
|
|
|
|
|
+ await api.put('/items.php', this.formData)
|
|
|
this.showMessage('Item updated successfully!', 'success')
|
|
this.showMessage('Item updated successfully!', 'success')
|
|
|
} else {
|
|
} else {
|
|
|
- await axios.post('/api/items.php', this.formData)
|
|
|
|
|
|
|
+ await api.post('/items.php', this.formData)
|
|
|
this.showMessage('Item added successfully!', 'success')
|
|
this.showMessage('Item added successfully!', 'success')
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -1730,13 +1752,22 @@ export default {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
try {
|
|
try {
|
|
|
- await axios.delete(`/api/items.php?id=${id}`)
|
|
|
|
|
|
|
+ await api.delete(`/items.php?id=${id}`)
|
|
|
this.showMessage('Item deleted successfully!', 'success')
|
|
this.showMessage('Item deleted successfully!', 'success')
|
|
|
this.fetchItems()
|
|
this.fetchItems()
|
|
|
} catch (error) {
|
|
} catch (error) {
|
|
|
this.showMessage('Error deleting item: ' + error.message, 'error')
|
|
this.showMessage('Error deleting item: ' + error.message, 'error')
|
|
|
}
|
|
}
|
|
|
},
|
|
},
|
|
|
|
|
+
|
|
|
|
|
+ // User management methods
|
|
|
|
|
+ showSuccess(message) {
|
|
|
|
|
+ this.showMessage(message, 'success')
|
|
|
|
|
+ },
|
|
|
|
|
+
|
|
|
|
|
+ showError(message) {
|
|
|
|
|
+ this.showMessage(message, 'error')
|
|
|
|
|
+ },
|
|
|
|
|
|
|
|
showAddModal() {
|
|
showAddModal() {
|
|
|
this.isEditing = false
|
|
this.isEditing = false
|
|
@@ -1789,7 +1820,7 @@ export default {
|
|
|
formData.append('picture', file)
|
|
formData.append('picture', file)
|
|
|
|
|
|
|
|
try {
|
|
try {
|
|
|
- const response = await axios.post('/api/upload.php', formData, {
|
|
|
|
|
|
|
+ const response = await api.post('/upload.php', formData, {
|
|
|
headers: {
|
|
headers: {
|
|
|
'Content-Type': 'multipart/form-data'
|
|
'Content-Type': 'multipart/form-data'
|
|
|
}
|
|
}
|
|
@@ -1838,7 +1869,7 @@ export default {
|
|
|
|
|
|
|
|
async fetchRentalPrices(itemId) {
|
|
async fetchRentalPrices(itemId) {
|
|
|
try {
|
|
try {
|
|
|
- const response = await axios.get(`/api/rental_prices.php?item_id=${itemId}`)
|
|
|
|
|
|
|
+ const response = await api.get(`/api/rental_prices.php?item_id=${itemId}`)
|
|
|
this.rentalPrices = response.data.records || []
|
|
this.rentalPrices = response.data.records || []
|
|
|
} catch (error) {
|
|
} catch (error) {
|
|
|
this.showMessage('Error fetching rental prices: ' + error.message, 'error')
|
|
this.showMessage('Error fetching rental prices: ' + error.message, 'error')
|
|
@@ -1847,7 +1878,7 @@ export default {
|
|
|
|
|
|
|
|
async fetchAttachments(itemId) {
|
|
async fetchAttachments(itemId) {
|
|
|
try {
|
|
try {
|
|
|
- const response = await axios.get(`/api/attachments.php?item_id=${itemId}`)
|
|
|
|
|
|
|
+ const response = await api.get(`/api/attachments.php?item_id=${itemId}`)
|
|
|
this.attachments = response.data.records || []
|
|
this.attachments = response.data.records || []
|
|
|
} catch (error) {
|
|
} catch (error) {
|
|
|
this.showMessage('Error fetching attachments: ' + error.message, 'error')
|
|
this.showMessage('Error fetching attachments: ' + error.message, 'error')
|
|
@@ -1878,7 +1909,7 @@ export default {
|
|
|
|
|
|
|
|
async saveRentalPrice() {
|
|
async saveRentalPrice() {
|
|
|
try {
|
|
try {
|
|
|
- await axios.post('/api/rental_prices.php', this.rentalForm)
|
|
|
|
|
|
|
+ await api.post('/api/rental_prices.php', this.rentalForm)
|
|
|
this.showMessage('Rental price added successfully!', 'success')
|
|
this.showMessage('Rental price added successfully!', 'success')
|
|
|
this.closeRentalModal()
|
|
this.closeRentalModal()
|
|
|
await this.fetchRentalPrices(this.selectedItem.id)
|
|
await this.fetchRentalPrices(this.selectedItem.id)
|
|
@@ -1893,7 +1924,7 @@ export default {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
try {
|
|
try {
|
|
|
- await axios.delete(`/api/rental_prices.php?id=${id}`)
|
|
|
|
|
|
|
+ await api.delete(`/api/rental_prices.php?id=${id}`)
|
|
|
this.showMessage('Rental price deleted successfully!', 'success')
|
|
this.showMessage('Rental price deleted successfully!', 'success')
|
|
|
await this.fetchRentalPrices(this.selectedItem.id)
|
|
await this.fetchRentalPrices(this.selectedItem.id)
|
|
|
} catch (error) {
|
|
} catch (error) {
|
|
@@ -1935,7 +1966,7 @@ export default {
|
|
|
formData.append('item_id', this.attachmentForm.item_id)
|
|
formData.append('item_id', this.attachmentForm.item_id)
|
|
|
formData.append('file_type', this.attachmentForm.file_type)
|
|
formData.append('file_type', this.attachmentForm.file_type)
|
|
|
|
|
|
|
|
- await axios.post('/api/attachments.php', formData, {
|
|
|
|
|
|
|
+ await api.post('/api/attachments.php', formData, {
|
|
|
headers: {
|
|
headers: {
|
|
|
'Content-Type': 'multipart/form-data'
|
|
'Content-Type': 'multipart/form-data'
|
|
|
}
|
|
}
|
|
@@ -1955,7 +1986,7 @@ export default {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
try {
|
|
try {
|
|
|
- await axios.delete(`/api/attachments.php?id=${id}`)
|
|
|
|
|
|
|
+ await api.delete(`/api/attachments.php?id=${id}`)
|
|
|
this.showMessage('Attachment deleted successfully!', 'success')
|
|
this.showMessage('Attachment deleted successfully!', 'success')
|
|
|
await this.fetchAttachments(this.selectedItem.id)
|
|
await this.fetchAttachments(this.selectedItem.id)
|
|
|
} catch (error) {
|
|
} catch (error) {
|
|
@@ -1982,7 +2013,7 @@ export default {
|
|
|
async fetchClients() {
|
|
async fetchClients() {
|
|
|
this.clientsLoading = true
|
|
this.clientsLoading = true
|
|
|
try {
|
|
try {
|
|
|
- const response = await axios.get('/api/clients.php')
|
|
|
|
|
|
|
+ const response = await api.get('/clients.php')
|
|
|
this.clients = response.data.records || []
|
|
this.clients = response.data.records || []
|
|
|
} catch (error) {
|
|
} catch (error) {
|
|
|
this.showMessage('Error fetching clients: ' + error.message, 'error')
|
|
this.showMessage('Error fetching clients: ' + error.message, 'error')
|
|
@@ -1999,7 +2030,7 @@ export default {
|
|
|
|
|
|
|
|
this.clientsLoading = true
|
|
this.clientsLoading = true
|
|
|
try {
|
|
try {
|
|
|
- const response = await axios.get(`/api/clients.php?search=${this.clientSearch}`)
|
|
|
|
|
|
|
+ const response = await api.get(`/api/clients.php?search=${this.clientSearch}`)
|
|
|
this.clients = response.data.records || []
|
|
this.clients = response.data.records || []
|
|
|
} catch (error) {
|
|
} catch (error) {
|
|
|
this.showMessage('Error searching clients: ' + error.message, 'error')
|
|
this.showMessage('Error searching clients: ' + error.message, 'error')
|
|
@@ -2073,10 +2104,10 @@ export default {
|
|
|
async saveClient() {
|
|
async saveClient() {
|
|
|
try {
|
|
try {
|
|
|
if (this.isEditingClient) {
|
|
if (this.isEditingClient) {
|
|
|
- await axios.put('/api/clients.php', this.clientForm)
|
|
|
|
|
|
|
+ await api.put('/api/clients.php', this.clientForm)
|
|
|
this.showMessage('Client updated successfully!', 'success')
|
|
this.showMessage('Client updated successfully!', 'success')
|
|
|
} else {
|
|
} else {
|
|
|
- await axios.post('/api/clients.php', this.clientForm)
|
|
|
|
|
|
|
+ await api.post('/api/clients.php', this.clientForm)
|
|
|
this.showMessage('Client added successfully!', 'success')
|
|
this.showMessage('Client added successfully!', 'success')
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -2093,7 +2124,7 @@ export default {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
try {
|
|
try {
|
|
|
- await axios.delete(`/api/clients.php?id=${id}`)
|
|
|
|
|
|
|
+ await api.delete(`/api/clients.php?id=${id}`)
|
|
|
this.showMessage('Client deleted successfully!', 'success')
|
|
this.showMessage('Client deleted successfully!', 'success')
|
|
|
await this.fetchClients()
|
|
await this.fetchClients()
|
|
|
} catch (error) {
|
|
} catch (error) {
|
|
@@ -2109,7 +2140,7 @@ export default {
|
|
|
async fetchContactPersons(customerId) {
|
|
async fetchContactPersons(customerId) {
|
|
|
this.contactPersonsLoading = true
|
|
this.contactPersonsLoading = true
|
|
|
try {
|
|
try {
|
|
|
- const response = await axios.get(`/api/contact_persons.php?client_id=${customerId}`)
|
|
|
|
|
|
|
+ const response = await api.get(`/api/contact_persons.php?client_id=${customerId}`)
|
|
|
this.contactPersons = response.data.records || []
|
|
this.contactPersons = response.data.records || []
|
|
|
} catch (error) {
|
|
} catch (error) {
|
|
|
this.showMessage('Error fetching contact persons: ' + error.message, 'error')
|
|
this.showMessage('Error fetching contact persons: ' + error.message, 'error')
|
|
@@ -2165,10 +2196,10 @@ export default {
|
|
|
async saveContactPerson() {
|
|
async saveContactPerson() {
|
|
|
try {
|
|
try {
|
|
|
if (this.isEditingContactPerson) {
|
|
if (this.isEditingContactPerson) {
|
|
|
- await axios.put('/api/contact_persons.php', this.contactPersonForm)
|
|
|
|
|
|
|
+ await api.put('/api/contact_persons.php', this.contactPersonForm)
|
|
|
this.showMessage('Contact person updated successfully!', 'success')
|
|
this.showMessage('Contact person updated successfully!', 'success')
|
|
|
} else {
|
|
} else {
|
|
|
- await axios.post('/api/contact_persons.php', this.contactPersonForm)
|
|
|
|
|
|
|
+ await api.post('/api/contact_persons.php', this.contactPersonForm)
|
|
|
this.showMessage('Contact person added successfully!', 'success')
|
|
this.showMessage('Contact person added successfully!', 'success')
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -2185,7 +2216,7 @@ export default {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
try {
|
|
try {
|
|
|
- await axios.delete(`/api/contact_persons.php?id=${id}`)
|
|
|
|
|
|
|
+ await api.delete(`/api/contact_persons.php?id=${id}`)
|
|
|
this.showMessage('Contact person deleted successfully!', 'success')
|
|
this.showMessage('Contact person deleted successfully!', 'success')
|
|
|
await this.fetchContactPersons(this.selectedClient ? this.selectedClient.id : null)
|
|
await this.fetchContactPersons(this.selectedClient ? this.selectedClient.id : null)
|
|
|
} catch (error) {
|
|
} catch (error) {
|
|
@@ -2197,7 +2228,7 @@ export default {
|
|
|
async fetchInvoices() {
|
|
async fetchInvoices() {
|
|
|
this.invoicesLoading = true
|
|
this.invoicesLoading = true
|
|
|
try {
|
|
try {
|
|
|
- const response = await axios.get('/api/invoices.php')
|
|
|
|
|
|
|
+ const response = await api.get('/api/invoices.php')
|
|
|
this.invoices = response.data.records || []
|
|
this.invoices = response.data.records || []
|
|
|
} catch (error) {
|
|
} catch (error) {
|
|
|
this.showMessage('Error fetching invoices: ' + error.message, 'error')
|
|
this.showMessage('Error fetching invoices: ' + error.message, 'error')
|
|
@@ -2214,7 +2245,7 @@ export default {
|
|
|
|
|
|
|
|
this.invoicesLoading = true
|
|
this.invoicesLoading = true
|
|
|
try {
|
|
try {
|
|
|
- const response = await axios.get(`/api/invoices.php?search=${this.invoiceSearch}`)
|
|
|
|
|
|
|
+ const response = await api.get(`/api/invoices.php?search=${this.invoiceSearch}`)
|
|
|
this.invoices = response.data.records || []
|
|
this.invoices = response.data.records || []
|
|
|
} catch (error) {
|
|
} catch (error) {
|
|
|
this.showMessage('Error searching invoices: ' + error.message, 'error')
|
|
this.showMessage('Error searching invoices: ' + error.message, 'error')
|
|
@@ -2276,10 +2307,10 @@ export default {
|
|
|
async saveInvoice() {
|
|
async saveInvoice() {
|
|
|
try {
|
|
try {
|
|
|
if (this.isEditingInvoice) {
|
|
if (this.isEditingInvoice) {
|
|
|
- await axios.put('/api/invoices.php', this.invoiceForm)
|
|
|
|
|
|
|
+ await api.put('/api/invoices.php', this.invoiceForm)
|
|
|
this.showMessage('Invoice updated successfully!', 'success')
|
|
this.showMessage('Invoice updated successfully!', 'success')
|
|
|
} else {
|
|
} else {
|
|
|
- await axios.post('/api/invoices.php', this.invoiceForm)
|
|
|
|
|
|
|
+ await api.post('/api/invoices.php', this.invoiceForm)
|
|
|
this.showMessage('Invoice created successfully!', 'success')
|
|
this.showMessage('Invoice created successfully!', 'success')
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -2296,7 +2327,7 @@ export default {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
try {
|
|
try {
|
|
|
- await axios.delete(`/api/invoices.php?id=${id}`)
|
|
|
|
|
|
|
+ await api.delete(`/api/invoices.php?id=${id}`)
|
|
|
this.showMessage('Invoice deleted successfully!', 'success')
|
|
this.showMessage('Invoice deleted successfully!', 'success')
|
|
|
await this.fetchInvoices()
|
|
await this.fetchInvoices()
|
|
|
} catch (error) {
|
|
} catch (error) {
|
|
@@ -2318,10 +2349,10 @@ export default {
|
|
|
async saveInvoiceItem() {
|
|
async saveInvoiceItem() {
|
|
|
try {
|
|
try {
|
|
|
if (this.invoiceItemsForm.id) {
|
|
if (this.invoiceItemsForm.id) {
|
|
|
- await axios.put('/api/invoice_items.php', this.invoiceItemsForm)
|
|
|
|
|
|
|
+ await api.put('/api/invoice_items.php', this.invoiceItemsForm)
|
|
|
this.showMessage('Invoice item updated successfully!', 'success')
|
|
this.showMessage('Invoice item updated successfully!', 'success')
|
|
|
} else {
|
|
} else {
|
|
|
- await axios.post('/api/invoice_items.php', this.invoiceItemsForm)
|
|
|
|
|
|
|
+ await api.post('/api/invoice_items.php', this.invoiceItemsForm)
|
|
|
this.showMessage('Invoice item added successfully!', 'success')
|
|
this.showMessage('Invoice item added successfully!', 'success')
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -2338,7 +2369,7 @@ export default {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
try {
|
|
try {
|
|
|
- await axios.delete(`/api/invoice_items.php?id=${id}`)
|
|
|
|
|
|
|
+ await api.delete(`/api/invoice_items.php?id=${id}`)
|
|
|
this.showMessage('Invoice item deleted successfully!', 'success')
|
|
this.showMessage('Invoice item deleted successfully!', 'success')
|
|
|
await this.viewInvoice(this.selectedInvoice)
|
|
await this.viewInvoice(this.selectedInvoice)
|
|
|
} catch (error) {
|
|
} catch (error) {
|
|
@@ -2351,7 +2382,7 @@ export default {
|
|
|
this.loginError = ''
|
|
this.loginError = ''
|
|
|
|
|
|
|
|
try {
|
|
try {
|
|
|
- const response = await axios.post('/api/auth.php', {
|
|
|
|
|
|
|
+ const response = await api.post('/auth.php', {
|
|
|
action: 'login',
|
|
action: 'login',
|
|
|
username: this.loginForm.username,
|
|
username: this.loginForm.username,
|
|
|
password: this.loginForm.password
|
|
password: this.loginForm.password
|
|
@@ -2375,15 +2406,46 @@ export default {
|
|
|
}
|
|
}
|
|
|
},
|
|
},
|
|
|
|
|
|
|
|
- logout() {
|
|
|
|
|
- this.isLoggedIn = false
|
|
|
|
|
- this.currentUser = null
|
|
|
|
|
- this.showMessage('Logged out successfully!', 'success')
|
|
|
|
|
|
|
+ async logout() {
|
|
|
|
|
+ try {
|
|
|
|
|
+ // Call backend logout endpoint to clear PHP session
|
|
|
|
|
+ await api.post('/auth.php', { action: 'logout' })
|
|
|
|
|
+
|
|
|
|
|
+ // Clear frontend data
|
|
|
|
|
+ this.isLoggedIn = false
|
|
|
|
|
+ this.currentUser = null
|
|
|
|
|
+
|
|
|
|
|
+ // Clear any stored authentication data
|
|
|
|
|
+ localStorage.removeItem('authToken')
|
|
|
|
|
+ sessionStorage.removeItem('authToken')
|
|
|
|
|
+ sessionStorage.removeItem('currentUser')
|
|
|
|
|
+
|
|
|
|
|
+ // Clear application data
|
|
|
|
|
+ this.items = []
|
|
|
|
|
+ this.clients = []
|
|
|
|
|
+ this.projects = []
|
|
|
|
|
+ this.users = []
|
|
|
|
|
+ this.invoices = []
|
|
|
|
|
+ this.accounts = []
|
|
|
|
|
+ this.journalEntries = []
|
|
|
|
|
+ this.transactions = []
|
|
|
|
|
+
|
|
|
|
|
+ this.showMessage('Logged out successfully!', 'success')
|
|
|
|
|
+ } catch (error) {
|
|
|
|
|
+ console.error('Logout error:', error)
|
|
|
|
|
+ // Still clear frontend data even if backend call fails
|
|
|
|
|
+ this.isLoggedIn = false
|
|
|
|
|
+ this.currentUser = null
|
|
|
|
|
+ localStorage.removeItem('authToken')
|
|
|
|
|
+ sessionStorage.removeItem('authToken')
|
|
|
|
|
+ sessionStorage.removeItem('currentUser')
|
|
|
|
|
+ this.showMessage('Logged out successfully!', 'success')
|
|
|
|
|
+ }
|
|
|
},
|
|
},
|
|
|
|
|
|
|
|
async checkAuthStatus() {
|
|
async checkAuthStatus() {
|
|
|
try {
|
|
try {
|
|
|
- const response = await axios.get('/api/auth.php?action=status')
|
|
|
|
|
|
|
+ const response = await api.get('/auth.php?action=status')
|
|
|
if (response.status === 200 && response.data.user) {
|
|
if (response.status === 200 && response.data.user) {
|
|
|
this.isLoggedIn = true
|
|
this.isLoggedIn = true
|
|
|
this.currentUser = response.data.user
|
|
this.currentUser = response.data.user
|
|
@@ -2431,7 +2493,7 @@ export default {
|
|
|
async fetchProjects() {
|
|
async fetchProjects() {
|
|
|
this.projectsLoading = true
|
|
this.projectsLoading = true
|
|
|
try {
|
|
try {
|
|
|
- const response = await axios.get('/api/projects.php')
|
|
|
|
|
|
|
+ const response = await api.get('/projects.php')
|
|
|
this.projects = response.data.records || []
|
|
this.projects = response.data.records || []
|
|
|
} catch (error) {
|
|
} catch (error) {
|
|
|
this.showMessage('Error fetching projects: ' + error.message, 'error')
|
|
this.showMessage('Error fetching projects: ' + error.message, 'error')
|
|
@@ -2444,7 +2506,7 @@ export default {
|
|
|
this.projectSearch = searchTerm
|
|
this.projectSearch = searchTerm
|
|
|
this.projectsLoading = true
|
|
this.projectsLoading = true
|
|
|
try {
|
|
try {
|
|
|
- const response = await axios.get(`/api/projects.php?search=${this.projectSearch}`)
|
|
|
|
|
|
|
+ const response = await api.get(`/api/projects.php?search=${this.projectSearch}`)
|
|
|
this.projects = response.data.records || []
|
|
this.projects = response.data.records || []
|
|
|
} catch (error) {
|
|
} catch (error) {
|
|
|
this.showMessage('Error searching projects: ' + error.message, 'error')
|
|
this.showMessage('Error searching projects: ' + error.message, 'error')
|
|
@@ -2485,7 +2547,7 @@ export default {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
try {
|
|
try {
|
|
|
- await axios.delete(`/api/projects.php?id=${id}`)
|
|
|
|
|
|
|
+ await api.delete(`/api/projects.php?id=${id}`)
|
|
|
this.showMessage('Project deleted successfully!', 'success')
|
|
this.showMessage('Project deleted successfully!', 'success')
|
|
|
this.fetchProjects()
|
|
this.fetchProjects()
|
|
|
} catch (error) {
|
|
} catch (error) {
|
|
@@ -2497,7 +2559,7 @@ export default {
|
|
|
async fetchUsers() {
|
|
async fetchUsers() {
|
|
|
this.usersLoading = true
|
|
this.usersLoading = true
|
|
|
try {
|
|
try {
|
|
|
- const response = await axios.get('/api/users.php')
|
|
|
|
|
|
|
+ const response = await api.get('/api/users.php')
|
|
|
this.users = response.data.records || []
|
|
this.users = response.data.records || []
|
|
|
} catch (error) {
|
|
} catch (error) {
|
|
|
this.showMessage('Error fetching users: ' + error.message, 'error')
|
|
this.showMessage('Error fetching users: ' + error.message, 'error')
|
|
@@ -2510,7 +2572,7 @@ export default {
|
|
|
this.userSearch = searchTerm
|
|
this.userSearch = searchTerm
|
|
|
this.usersLoading = true
|
|
this.usersLoading = true
|
|
|
try {
|
|
try {
|
|
|
- const response = await axios.get(`/api/users.php?search=${this.userSearch}`)
|
|
|
|
|
|
|
+ const response = await api.get(`/api/users.php?search=${this.userSearch}`)
|
|
|
this.users = response.data.records || []
|
|
this.users = response.data.records || []
|
|
|
} catch (error) {
|
|
} catch (error) {
|
|
|
this.showMessage('Error searching users: ' + error.message, 'error')
|
|
this.showMessage('Error searching users: ' + error.message, 'error')
|
|
@@ -2559,7 +2621,7 @@ export default {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
try {
|
|
try {
|
|
|
- await axios.delete(`/api/users.php?id=${id}`)
|
|
|
|
|
|
|
+ await api.delete(`/api/users.php?id=${id}`)
|
|
|
this.showMessage('User deleted successfully!', 'success')
|
|
this.showMessage('User deleted successfully!', 'success')
|
|
|
this.fetchUsers()
|
|
this.fetchUsers()
|
|
|
} catch (error) {
|
|
} catch (error) {
|
|
@@ -2602,11 +2664,11 @@ export default {
|
|
|
let response
|
|
let response
|
|
|
if (this.userForm.id) {
|
|
if (this.userForm.id) {
|
|
|
// Update existing user
|
|
// Update existing user
|
|
|
- response = await axios.put(`/api/users.php?id=${this.userForm.id}`, userData)
|
|
|
|
|
|
|
+ response = await api.put(`/api/users.php?id=${this.userForm.id}`, userData)
|
|
|
this.showMessage('User updated successfully!', 'success')
|
|
this.showMessage('User updated successfully!', 'success')
|
|
|
} else {
|
|
} else {
|
|
|
// Create new user
|
|
// Create new user
|
|
|
- response = await axios.post('/api/users.php', userData)
|
|
|
|
|
|
|
+ response = await api.post('/api/users.php', userData)
|
|
|
this.showMessage('User created successfully!', 'success')
|
|
this.showMessage('User created successfully!', 'success')
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -2648,11 +2710,11 @@ export default {
|
|
|
let response
|
|
let response
|
|
|
if (this.projectForm.id) {
|
|
if (this.projectForm.id) {
|
|
|
// Update existing project
|
|
// Update existing project
|
|
|
- response = await axios.put(`/api/projects.php?id=${this.projectForm.id}`, projectData)
|
|
|
|
|
|
|
+ response = await api.put(`/api/projects.php?id=${this.projectForm.id}`, projectData)
|
|
|
this.showMessage('Project updated successfully!', 'success')
|
|
this.showMessage('Project updated successfully!', 'success')
|
|
|
} else {
|
|
} else {
|
|
|
// Create new project
|
|
// Create new project
|
|
|
- response = await axios.post('/api/projects.php', projectData)
|
|
|
|
|
|
|
+ response = await api.post('/api/projects.php', projectData)
|
|
|
this.showMessage('Project created successfully!', 'success')
|
|
this.showMessage('Project created successfully!', 'success')
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -2682,7 +2744,7 @@ export default {
|
|
|
|
|
|
|
|
async fetchCustomerContacts(customerId) {
|
|
async fetchCustomerContacts(customerId) {
|
|
|
try {
|
|
try {
|
|
|
- const response = await axios.get(`/api/contact_persons.php?client_id=${customerId}`)
|
|
|
|
|
|
|
+ const response = await api.get(`/api/contact_persons.php?client_id=${customerId}`)
|
|
|
this.customerContacts = response.data.records || []
|
|
this.customerContacts = response.data.records || []
|
|
|
} catch (error) {
|
|
} catch (error) {
|
|
|
this.showMessage('Error fetching contacts: ' + error.message, 'error')
|
|
this.showMessage('Error fetching contacts: ' + error.message, 'error')
|
|
@@ -2703,7 +2765,7 @@ export default {
|
|
|
notes: this.contactForm.notes
|
|
notes: this.contactForm.notes
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- await axios.post('/api/contact_persons.php', contactData)
|
|
|
|
|
|
|
+ await api.post('/api/contact_persons.php', contactData)
|
|
|
this.showMessage('Contact added successfully!', 'success')
|
|
this.showMessage('Contact added successfully!', 'success')
|
|
|
this.resetContactForm()
|
|
this.resetContactForm()
|
|
|
await this.fetchCustomerContacts(this.selectedCustomer.id)
|
|
await this.fetchCustomerContacts(this.selectedCustomer.id)
|
|
@@ -2732,7 +2794,7 @@ export default {
|
|
|
notes: this.contactForm.notes
|
|
notes: this.contactForm.notes
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- await axios.put(`/api/contact_persons.php?id=${this.contactForm.id}`, contactData)
|
|
|
|
|
|
|
+ await api.put(`/api/contact_persons.php?id=${this.contactForm.id}`, contactData)
|
|
|
this.showMessage('Contact updated successfully!', 'success')
|
|
this.showMessage('Contact updated successfully!', 'success')
|
|
|
this.resetContactForm()
|
|
this.resetContactForm()
|
|
|
await this.fetchCustomerContacts(this.selectedCustomer.id)
|
|
await this.fetchCustomerContacts(this.selectedCustomer.id)
|
|
@@ -2748,7 +2810,7 @@ export default {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
try {
|
|
try {
|
|
|
- await axios.delete(`/api/contact_persons.php?id=${contactId}`)
|
|
|
|
|
|
|
+ await api.delete(`/api/contact_persons.php?id=${contactId}`)
|
|
|
this.showMessage('Contact deleted successfully!', 'success')
|
|
this.showMessage('Contact deleted successfully!', 'success')
|
|
|
await this.fetchCustomerContacts(this.selectedCustomer.id)
|
|
await this.fetchCustomerContacts(this.selectedCustomer.id)
|
|
|
await this.fetchClients()
|
|
await this.fetchClients()
|
|
@@ -2783,7 +2845,7 @@ export default {
|
|
|
async fetchAccounts() {
|
|
async fetchAccounts() {
|
|
|
this.accountsLoading = true
|
|
this.accountsLoading = true
|
|
|
try {
|
|
try {
|
|
|
- const response = await axios.get('/api/chart_of_accounts.php')
|
|
|
|
|
|
|
+ const response = await api.get('/api/chart_of_accounts.php')
|
|
|
this.accounts = response.data.records || []
|
|
this.accounts = response.data.records || []
|
|
|
} catch (error) {
|
|
} catch (error) {
|
|
|
this.showMessage('Error fetching accounts: ' + error.message, 'error')
|
|
this.showMessage('Error fetching accounts: ' + error.message, 'error')
|
|
@@ -2796,7 +2858,7 @@ export default {
|
|
|
this.accountSearch = searchTerm
|
|
this.accountSearch = searchTerm
|
|
|
this.accountsLoading = true
|
|
this.accountsLoading = true
|
|
|
try {
|
|
try {
|
|
|
- const response = await axios.get(`/api/chart_of_accounts.php?search=${this.accountSearch}`)
|
|
|
|
|
|
|
+ const response = await api.get(`/api/chart_of_accounts.php?search=${this.accountSearch}`)
|
|
|
this.accounts = response.data.records || []
|
|
this.accounts = response.data.records || []
|
|
|
} catch (error) {
|
|
} catch (error) {
|
|
|
this.showMessage('Error searching accounts: ' + error.message, 'error')
|
|
this.showMessage('Error searching accounts: ' + error.message, 'error')
|
|
@@ -2837,7 +2899,7 @@ export default {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
try {
|
|
try {
|
|
|
- await axios.delete(`/api/chart_of_accounts.php?id=${id}`)
|
|
|
|
|
|
|
+ await api.delete(`/api/chart_of_accounts.php?id=${id}`)
|
|
|
this.showMessage('Account deleted successfully!', 'success')
|
|
this.showMessage('Account deleted successfully!', 'success')
|
|
|
this.fetchAccounts()
|
|
this.fetchAccounts()
|
|
|
} catch (error) {
|
|
} catch (error) {
|
|
@@ -2849,7 +2911,7 @@ export default {
|
|
|
async fetchJournalEntries() {
|
|
async fetchJournalEntries() {
|
|
|
this.journalEntriesLoading = true
|
|
this.journalEntriesLoading = true
|
|
|
try {
|
|
try {
|
|
|
- const response = await axios.get('/api/journal_entries.php')
|
|
|
|
|
|
|
+ const response = await api.get('/api/journal_entries.php')
|
|
|
this.journalEntries = response.data.records || []
|
|
this.journalEntries = response.data.records || []
|
|
|
} catch (error) {
|
|
} catch (error) {
|
|
|
this.showMessage('Error fetching journal entries: ' + error.message, 'error')
|
|
this.showMessage('Error fetching journal entries: ' + error.message, 'error')
|
|
@@ -2862,7 +2924,7 @@ export default {
|
|
|
async fetchTransactions() {
|
|
async fetchTransactions() {
|
|
|
this.transactionsLoading = true
|
|
this.transactionsLoading = true
|
|
|
try {
|
|
try {
|
|
|
- const response = await axios.get('/api/account_transactions.php')
|
|
|
|
|
|
|
+ const response = await api.get('/api/account_transactions.php')
|
|
|
this.transactions = response.data.records || []
|
|
this.transactions = response.data.records || []
|
|
|
} catch (error) {
|
|
} catch (error) {
|
|
|
this.showMessage('Error fetching transactions: ' + error.message, 'error')
|
|
this.showMessage('Error fetching transactions: ' + error.message, 'error')
|
|
@@ -2895,7 +2957,7 @@ export default {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
try {
|
|
try {
|
|
|
- await axios.delete(`/api/journal_entries.php?id=${id}`)
|
|
|
|
|
|
|
+ await api.delete(`/api/journal_entries.php?id=${id}`)
|
|
|
this.showMessage('Journal entry deleted successfully!', 'success')
|
|
this.showMessage('Journal entry deleted successfully!', 'success')
|
|
|
this.fetchJournalEntries()
|
|
this.fetchJournalEntries()
|
|
|
} catch (error) {
|
|
} catch (error) {
|