updated customer profile. added maps

This commit is contained in:
2024-11-20 18:00:17 -05:00
parent b62d45da5d
commit bf49bf5711
19 changed files with 1157 additions and 313 deletions

View File

@@ -3,7 +3,7 @@ import DeliveryCreate from "./create.vue";
import DeliveryEdit from './edit.vue';
import DeliveryOrder from './view.vue';
import deliveryTicketsMissing from './update_tickets/missing_data_home.vue';
import finalizeTicket from './update_tickets/finalize_ticket.vue';
import deliveryPending from './viewstatus/pending.vue';
import deliveryCancelled from './viewstatus/cancelled.vue';
import deliveryIssue from './viewstatus/issue.vue';
@@ -12,6 +12,8 @@ import deliveryOutForDelivery from './viewstatus/todaysdeliveries.vue';
import deliveryWaiting from './viewstatus/waiting.vue';
import deliveryFinalized from './viewstatus/finalized.vue'
import deliveryTommorrow from './viewstatus/tommorrow.vue'
import finalizeTicket from './update_tickets/finalize_ticket.vue';
import finalizeTicketAuto from './update_tickets/finalize_ticket_auto.vue';
const deliveryRoutes = [
{
@@ -44,11 +46,7 @@ const deliveryRoutes = [
name: 'deliveryTicketsMissing',
component: deliveryTicketsMissing,
},
{
path: '/delivery/tickets/finalize/:id',
name: 'finalizeTicket',
component: finalizeTicket,
},
{
path: '/delivery/cancelled',
name: 'deliveryCancelled',
@@ -84,6 +82,16 @@ const deliveryRoutes = [
name: 'deliveryFinalized',
component: deliveryFinalized,
},
{
path: '/delivery/tickets/finalize/:id',
name: 'finalizeTicket',
component: finalizeTicket,
},
{
path: '/delivery/tickets/finalize/auto/:id',
name: 'finalizeTicketAuto',
component: finalizeTicketAuto,
},
]
export default deliveryRoutes

View File

@@ -0,0 +1,530 @@
<template>
<Header />
<div class="flex">
<div class="">
<SideBar />
</div>
<div class=" w-full px-10 ">
<div class="text-sm breadcrumbs mb-10">
<ul>
<li>
<router-link :to="{ name: 'home' }">
Home
</router-link>
</li>
<li>
<router-link :to="{ name: 'customer' }">
Customers
</router-link>
</li>
</ul>
</div>
<div class="text-2xl border-b border-gray-500">
Auto Delivery # {{ autoDelivery.id }}
</div>
<div class="flex justify-end" v-if="customer.id > 0">
<router-link :to="{ name: 'customerProfile', params: { id: customer.id } }">
<button class="btn btn-sm btn-secondary">Customer Profile</button>
</router-link>
</div>
<div class="grid grid-cols-12 " >
<div class="col-span-6 ">
<div class="col-span-12 font-bold">
Customer
</div>
<div class="col-span-12 p-5 ">
<div class="grid grid-cols-12 mb-2">
<div class="col-span-12 font-bold flex">
{{ customer.customer_first_name }}
{{ customer.customer_last_name }}
</div>
<div class="col-span-12 font-bold ">{{customer.customer_address}}</div>
<div class="col-span-12 font-bold flex">
<div class="pr-2">
{{ customer.customer_town }},
</div>
<div class="pr-2">
<div v-if="customer.customer_state == 0">Massachusetts</div>
<div v-else-if="customer.customer_state == 1">Rhode Island</div>
<div v-else-if="customer.customer_state == 2">New Hampshire</div>
<div v-else-if="customer.customer_state == 3">Maine</div>
<div v-else-if="customer.customer_state == 4">Vermont</div>
<div v-else-if="customer.customer_state == 5">Maine</div>
<div v-else-if="customer.customer_state == 6">New York</div>
<div v-else>Unknown state</div>
</div>
<div class="pr-2">
{{ customer.customer_zip }}
</div>
</div>
<div class="col-span-12 font-bold flex" v-if="customer.customer_apt !== 'None'">
{{ customer.customer_apt }}
</div>
<div class="col-span-12 font-bold flex">
<div v-if="customer.customer_home_type == 0">Residential</div>
<div v-else-if="customer.customer_home_type == 1">apartment</div>
<div v-else-if="customer.customer_home_type == 2">condo</div>
<div v-else-if="customer.customer_home_type == 3">commercial</div>
<div v-else-if="customer.customer_home_type == 4">business</div>
<div v-else-if="customer.customer_home_type == 5">construction</div>
<div v-else-if="customer.customer_home_type == 6">container</div>
</div>
<div class="col-span-12 font-bold flex">
{{ customer.customer_phone_number }}
</div>
</div>
</div>
<div class="col-span-12 mt-5">
<div class="col-span-12 font-bold">
<div class="grid grid-cols-12 mb-5">
<div class="col-span-12 ">
Price / Gallon
</div>
<div class="col-span-12 pl-5">
{{ today_oil_price }}
</div>
<div class="col-span-12 py-5 ">
<div class="flex" v-if="userCardfound">
<div class="rounded-md border-2 bg-accent">
<div class="flex p-2">
{{ userCard.type_of_card }}
</div>
<div class="flex p-1 pl-4">
{{ userCard.name_on_card }}
</div>
<div class="flex p-1 pl-4">
{{ userCard.card_number }}
</div>
<div class="flex p-1 pl-4">
{{ userCard.expiration_month }}/ {{ userCard.expiration_year }}
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="col-span-6">
<form class="rounded-md px-8 pb-8 mb-4 w-full" enctype="multipart/form-data" @submit.prevent="onSubmit">
<div class="grid grid-cols-12">
<div class="col-span-12 mb-4">
<label class="block text-white text-sm font-bold mb-2">Gallons Delivered</label>
<input v-model="FinalizeOilOrderForm.gallons_delivered"
class="input input-bordered input-sm w-full max-w-xs" id="title" type="text"
placeholder="# gallons" />
</div>
<div class="col-span-12 md:col-span-12 flex mt-5 mb-5">
<button class="btn btn-secondary btn-sm">
Finalize Delivery
</button>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
<Footer />
</template>
<script lang="ts">
import { defineComponent } from 'vue'
import axios from 'axios'
import authHeader from '../../../services/auth.header'
import Header from '../../../layouts/headers/headerauth.vue'
import SideBar from '../../../layouts/sidebar/sidebar.vue'
import Footer from '../../../layouts/footers/footer.vue'
import useValidate from "@vuelidate/core";
import { notify } from "@kyvg/vue3-notification"
export default defineComponent({
name: 'finalizeTicketAuto',
components: {
Header,
SideBar,
Footer,
},
data() {
return {
v$: useValidate(),
loaded: false,
user: {
id: 0
},
userCardfound: false,
deliveryStatus: [],
userCards: [],
deliveryNotesDriver: [],
today_oil_price: 0,
FinalizeOilOrderForm: {
fill_location: 0,
check_number: 0,
delivery_status: 10,
userCards: [],
credit_card_id: 0,
driver: 0,
gallons_delivered: '',
customer_filled: false,
prime: false,
same_day: false,
emergency: false,
},
CreateOilOrderForm: {
basicInfo: {
gallons_delivered: '',
userCards: []
},
},
userCard: {
date_added: '',
user_id: '',
card_number: '',
last_four_digits: '',
name_on_card: '',
expiration_month: '',
expiration_year: '',
type_of_card: '',
security_number: '',
accepted_or_declined: '',
main_card: '',
},
customer: {
id: 0,
user_id: 0,
customer_address: '',
customer_first_name: '',
customer_last_name: '',
customer_town: '',
customer_state: 0,
customer_zip: '',
customer_apt: '',
customer_home_type: 0,
customer_phone_number: '',
},
customerDescription: {
customer_id: 0,
account_number: '',
company_id: 0,
fill_location: 0,
description: '',
},
autoDelivery: {
id: 0,
customer_id: '',
account_number: '',
customer_town: '',
customer_state: '',
customer_address: '',
customer_zip: '',
customer_full_name: '',
last_fill: '',
days_since_last_fill: 0,
last_updated: '',
estimated_gallons_left: '',
estimated_gallons_left_prev_day: '',
tank_height: '',
tank_size: '',
house_factor: '',
auto_status: '',
},
}
},
created() {
this.userStatus()
},
watch: {
$route() {
this.today_price_oil();
this.getAutoDelivery(this.$route.params.id);
},
},
mounted() {
this.today_price_oil();
this.getAutoDelivery(this.$route.params.id);
},
methods: {
userStatus() {
let path = import.meta.env.VITE_BASE_URL + '/auth/whoami';
axios({
method: 'get',
url: path,
withCredentials: true,
headers: authHeader(),
})
.then((response: any) => {
if (response.data.ok) {
this.user = response.data.user;
this.user.id = response.data.user_id;
}
})
},
getPaymentCard(card_id: any) {
let path = import.meta.env.VITE_BASE_URL + "/payment/card/" + card_id;
axios({
method: "get",
url: path,
withCredentials: true,
})
.then((response: any) => {
if (response.data.userCard.card_number === ''){
this.userCard === null;
this.userCardfound = false;
}
else{
this.userCard = response.data;
this.userCardfound = true;
}
this.FinalizeOilOrderForm.userCards = response.data.id
})
.catch(() => {
});
},
getPaymentCards(user_id: any) {
let path = import.meta.env.VITE_BASE_URL + "/payment/cards/" + user_id;
axios({
method: "get",
url: path,
withCredentials: true,
})
.then((response: any) => {
this.userCards = response.data;
})
.catch(() => {
});
},
getCustomer(user_id: any) {
let path = import.meta.env.VITE_BASE_URL + "/customer/" + user_id;
axios({
method: "get",
url: path,
withCredentials: true,
})
.then((response: any) => {
this.customer = response.data;
})
.catch(() => {
notify({
title: "Error",
text: "Could not find customer",
type: "error",
});
});
},
getCustomerDescription(user_id: any) {
let path = import.meta.env.VITE_BASE_URL + "/customer/description/" + user_id;
axios({
method: "get",
url: path,
withCredentials: true,
})
.then((response: any) => {
this.customerDescription = response.data;
this.loaded = true
})
.catch(() => {
notify({
title: "Error",
text: "Could not find customer",
type: "error",
});
});
},
getAutoDelivery(delivery_id: any) {
let path = import.meta.env.VITE_AUTO_URL + "/delivery/" + delivery_id;
axios({
method: "get",
url: path,
withCredentials: true,
})
.then((response: any) => {
this.autoDelivery = response.data;
this.getCustomer(this.autoDelivery.customer_id)
this.getCustomerDescription(this.autoDelivery.customer_id)
})
.catch(() => {
notify({
title: "Error",
text: "Could not get automatic",
type: "error",
});
});
},
today_price_oil() {
let path = import.meta.env.VITE_BASE_URL + '/info/price/oil'
axios({
method: "get",
url: path,
withCredentials: true,
headers: authHeader(),
})
.then((response: any) => {
this.today_oil_price = response.data.price_for_customer;
})
},
UpdateAuto(payload: {
gallons: string,
delivery_id: string,
}) {
let path = import.meta.env.VITE_AUTO_URL + "/confirm/delivery"
axios({
method: "put",
url: path,
data: payload,
withCredentials: true,
headers: authHeader(),
})
.then((response: any) => {
if (response.data.ok) {
notify({
text: 'Update',
type: 'postive',
title: 'top'
})
this.$router.push({ name: "DeliveryHome" });
}
else {
notify({
text: 'Auto Failure',
type: 'negative',
title: 'Update'
})
}
})
},
ConfirmAuto(payload: {
gallons_delivered: string,
}) {
let path = import.meta.env.VITE_AUTO_URL + "/confirm/auto/create/" + this.autoDelivery.id;
axios({
method: "post",
url: path,
data: payload,
withCredentials: true,
headers: authHeader(),
})
.then((response: any) => {
if (response.data) {
notify({
title: "Success",
text: "Auto Delivered",
type: "success",
});
this.CreateTransaction(response.data['0']['auto_ticket_id'])
this.$router.push({ name: "auto" });
}
if (response.data.error) {
notify({
title: "Error",
text: "Could not finalize auto",
type: "error",
});
this.$router.push("auto");
}
})
},
UpdateDeliveredAuto(payload: {
gallons_delivered: string,
}) {
let path = import.meta.env.VITE_AUTO_URL + "/confirm/auto/update/" + this.autoDelivery.id;
axios({
method: "put",
url: path,
data: payload,
withCredentials: true,
headers: authHeader(),
})
.then((response: any) => {
if (response.data) {
notify({
title: "Success",
text: "Auto Updated",
type: "success",
});
}
})
},
CreateTransaction(auto_ticket_id: string,) {
let path = import.meta.env.VITE_MONEY_URL + "/delivery/add/auto/" + auto_ticket_id;
axios({
method: "post",
url: path,
withCredentials: true,
headers: authHeader(),
})
.then((response: any) => {
if (response.status == 201) {
notify({
message: 'Confirmed Transaction',
type: 'positive',
position: 'top'
})
this.$router.push({ name: "today" });
}
else {
notify({
message: 'Form Error',
type: 'negative',
position: 'top'
})
}
})
},
onSubmit() {
let payload = {
gallons_delivered: this.FinalizeOilOrderForm.gallons_delivered,
};
this.UpdateDeliveredAuto(payload);
this.ConfirmAuto(payload);
},
},
})
</script>
<style scoped></style>

View File

@@ -26,9 +26,9 @@
<tr>
<th>Name</th>
<th>Status</th>
<th>Town</th>
<th>Address</th>
<th>Town</th>
<th>Gallons</th>
<th>Date</th>
<th>Automatic</th>
@@ -55,9 +55,9 @@
</td>
<td>{{ oil['customer_address'] }}</td>
<td>{{ oil['customer_town'] }}</td>
<td>{{ oil['customer_address'] }}</td>
<td>
<div v-if="oil['customer_asked_for_fill'] == 1">Fill</div>
<div v-else> {{ oil['gallons_ordered'] }}</div>

View File

@@ -26,8 +26,9 @@
<tr>
<th>Name</th>
<th>Status</th>
<th>Town</th>
<th>Address</th>
<th>Town</th>
<th>Gallons</th>
<th>Date</th>
<th>Automatic</th>
@@ -55,8 +56,9 @@
</td>
<td>{{ oil['customer_address'] }}</td>
<td>{{ oil['customer_town'] }}</td>
<td>{{ oil['customer_address'] }}</td>
<td>
<div v-if="oil['customer_asked_for_fill'] == 1">Fill</div>
<div v-else> {{ oil['gallons_ordered'] }}</div>

View File

@@ -27,8 +27,9 @@
<th>Ticket Id</th>
<th>Name</th>
<th>Status</th>
<th>Town</th>
<th>Address</th>
<th>Town</th>
<th>Gallons</th>
<th>Date</th>
<th>Automatic</th>
@@ -57,8 +58,9 @@
</td>
<td>{{ oil['customer_town'] }}</td>
<td>{{ oil['customer_address'] }}</td>
<td>{{ oil['customer_town'] }}</td>
<td>
<div v-if="oil['customer_asked_for_fill'] == 1">Fill</div>
<div v-else> {{ oil['gallons_ordered'] }}</div>

View File

@@ -26,8 +26,9 @@
<th>Ticket Id</th>
<th>Name</th>
<th>Status</th>
<th>Town</th>
<th>Address</th>
<th>Town</th>
<th>Gallons</th>
<th>Date</th>
<th>Automatic</th>
@@ -57,8 +58,9 @@
</td>
<td>{{ oil['customer_town'] }}</td>
<td>{{ oil['customer_address'] }}</td>
<td>{{ oil['customer_town'] }}</td>
<td>
<div v-if="oil['customer_asked_for_fill'] == 1">Fill</div>
<div v-else> {{ oil['gallons_ordered'] }}</div>

View File

@@ -28,8 +28,9 @@
<th>Id</th>
<th>Name</th>
<th>Status</th>
<th>Town</th>
<th>Address</th>
<th>Town</th>
<th>Gallons</th>
<th>Date</th>
<th>Auto</th>
@@ -64,8 +65,9 @@
</td>
<td>{{ oil['customer_town'] }}</td>
<td>{{ oil['customer_address'] }}</td>
<td>{{ oil['customer_town'] }}</td>
<td>
<div v-if="oil['customer_asked_for_fill'] == 1">Fill</div>
<div v-else> {{ oil['gallons_ordered'] }}</div>

View File

@@ -44,13 +44,13 @@
<!-- row 1 -->
<tr v-for="oil in deliveries" :key="oil['id']">
<td>{{ oil['id'] }} </td>
<router-link :to="{ name: 'customerProfile', params: { id: oil['customer_id'] } }">
<td>
<div class="hover:text-accent">{{ oil['customer_name'] }} </div>
</td>
</router-link>
</router-link>
<td>
<div v-if="oil['delivery_status'] == 0">Waiting</div>
<div v-else-if="oil['delivery_status'] == 1">cancelled</div>
@@ -61,7 +61,7 @@
<div v-else-if="oil['delivery_status'] == 10" class="bg-green-600">Finalized</div>
<div v-else></div>
</td>
<td>{{ oil['customer_town'] }}</td>
@@ -88,7 +88,7 @@
<div v-else class="text-red-600">Yes</div>
</td>
<td>
<div v-if="oil['payment_type'] == 0">Cash</div>
<div v-else-if="oil['payment_type'] == 1">CC</div>
<div v-else-if="oil['payment_type'] == 2">Cash/CC</div>
@@ -106,11 +106,10 @@
<router-link :to="{ name: 'deliveryEdit', params: { id: oil['id'] } }">
<button class="btn btn-secondary btn-sm">Edit Delivery</button>
</router-link>
<router-link :to="{ name: 'finalizeTicket', params: { id: oil['id'] } }">
<button class="btn btn-secondary btn-sm">Finalize</button>
</router-link>
<router-link :to="{ name: 'Ticket', params: { id: oil['id'] } }">
<router-link :to="{ name: 'finalizeTicket', params: { id: oil['id'] } }">
<button class="btn btn-secondary btn-sm">Finalize</button>
</router-link>
<router-link :to="{ name: 'Ticket', params: { id: oil['id'] } }">
<button class="btn btn-success btn-sm">
Print Ticket
</button>
@@ -124,9 +123,10 @@
</table>
</div>
<pagination @paginate="getPage" :records="recordsLength" v-model="page" :per-page="50" :options="options" class="mt-10">
</pagination>
<div class="flex justify-center mb-10"> {{ recordsLength }} items Found</div>
<pagination @paginate="getPage" :records="recordsLength" v-model="page" :per-page="50" :options="options"
class="mt-10">
</pagination>
<div class="flex justify-center mb-10"> {{ recordsLength }} items Found</div>
</div>
</div>

View File

@@ -26,11 +26,12 @@
<!-- head -->
<thead>
<tr>
<th>Ticket Id</th>
<th>Account Id</th>
<th>Name</th>
<th>Status</th>
<th>Town</th>
<th>Address</th>
<th>Town</th>
<th>Gallons</th>
<th>Date</th>
<th>Automatic</th>
@@ -59,8 +60,9 @@
<div v-else></div>
</td>
<td>{{ oil['customer_town'] }}</td>
<td>{{ oil['customer_address'] }}</td>
<td>{{ oil['customer_town'] }}</td>
<td>
<div v-if="oil['customer_asked_for_fill'] == 1">Fill</div>
<div v-else> {{ oil['gallons_ordered'] }}</div>
@@ -101,7 +103,7 @@
</div>
<pagination @paginate="getPage" :records="recordsLength" v-model="page" :per-page="50" :options="options" class="mt-10">
</pagination>
<div class="flex justify-center mb-10"> {{ recordsLength }} items Found</div>
<!-- <div class="flex justify-center mb-10"> {{ recordsLength }} items Found</div> -->
</div>
</div>

View File

@@ -25,11 +25,12 @@
<!-- head -->
<thead>
<tr>
<th>Ticket Id</th>
<th>Account Id</th>
<th>Name</th>
<th>Status</th>
<th>Town</th>
<th>Address</th>
<th>Town</th>
<th>Gallons</th>
<th>Date</th>
<th>Automatic</th>
@@ -57,8 +58,9 @@
<div v-else></div>
</td>
<td>{{ oil['customer_town'] }}</td>
<td>{{ oil['customer_address'] }}</td>
<td>{{ oil['customer_town'] }}</td>
<td>
<div v-if="oil['customer_asked_for_fill'] == 1">Fill</div>
<div v-else> {{ oil['gallons_ordered'] }}</div>