Add support for "new customer" when creating new custorder
This commit is contained in:
parent
25a019cc12
commit
d933dd2723
4 changed files with 283 additions and 35 deletions
|
@ -333,19 +333,84 @@
|
|||
|
||||
<br />
|
||||
<div class="field">
|
||||
<b-radio v-model="contactIsKnown" disabled
|
||||
<b-radio v-model="contactIsKnown"
|
||||
:native-value="false">
|
||||
Customer is not yet in the system.
|
||||
</b-radio>
|
||||
</div>
|
||||
|
||||
<div v-if="!contactIsKnown">
|
||||
<b-field label="Customer Name" horizontal>
|
||||
<b-input v-model="customerName"></b-input>
|
||||
</b-field>
|
||||
<b-field label="Phone Number" horizontal>
|
||||
<b-input v-model="phoneNumber"></b-input>
|
||||
</b-field>
|
||||
<div v-if="!contactIsKnown"
|
||||
style="padding-left: 10rem; display: flex;">
|
||||
<div>
|
||||
<b-field label="Customer Name">
|
||||
<span>{{ newCustomerName }}</span>
|
||||
</b-field>
|
||||
<b-field grouped>
|
||||
<b-field label="Phone Number">
|
||||
<span>{{ newCustomerPhone }}</span>
|
||||
</b-field>
|
||||
<b-field label="Email Address">
|
||||
<span>{{ newCustomerEmail }}</span>
|
||||
</b-field>
|
||||
</b-field>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<b-button type="is-primary"
|
||||
@click="editNewCustomerInit()"
|
||||
icon-pack="fas"
|
||||
icon-left="edit">
|
||||
Edit New Customer
|
||||
</b-button>
|
||||
</div>
|
||||
|
||||
<div style="margin-left: 1rem;">
|
||||
<b-notification type="is-warning"
|
||||
:closable="false">
|
||||
<p>Duplicate records can be difficult to clean up!</p>
|
||||
<p>Please be sure the customer is not already in the system.</p>
|
||||
</b-notification>
|
||||
</div>
|
||||
|
||||
<b-modal has-modal-card
|
||||
:active.sync="editNewCustomerShowDialog">
|
||||
<div class="modal-card">
|
||||
|
||||
<header class="modal-card-head">
|
||||
<p class="modal-card-title">Edit New Customer</p>
|
||||
</header>
|
||||
|
||||
<section class="modal-card-body">
|
||||
<b-field label="Customer Name">
|
||||
<b-input v-model="editNewCustomerName"
|
||||
ref="editNewCustomerInput">
|
||||
</b-input>
|
||||
</b-field>
|
||||
<b-field grouped>
|
||||
<b-field label="Phone Number">
|
||||
<b-input v-model="editNewCustomerPhone"></b-input>
|
||||
</b-field>
|
||||
<b-field label="Email Address">
|
||||
<b-input v-model="editNewCustomerEmail"></b-input>
|
||||
</b-field>
|
||||
</b-field>
|
||||
</section>
|
||||
|
||||
<footer class="modal-card-foot">
|
||||
<b-button type="is-primary"
|
||||
icon-pack="fas"
|
||||
icon-left="save"
|
||||
:disabled="editNewCustomerSaveDisabled"
|
||||
@click="editNewCustomerSave()">
|
||||
{{ editNewCustomerSaveText }}
|
||||
</b-button>
|
||||
<b-button @click="editNewCustomerShowDialog = false">
|
||||
Cancel
|
||||
</b-button>
|
||||
</footer>
|
||||
</div>
|
||||
</b-modal>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
@ -577,7 +642,7 @@
|
|||
batchTotalPriceDisplay: ${json.dumps(normalized_batch['total_price_display'])|n},
|
||||
|
||||
customerPanelOpen: false,
|
||||
contactIsKnown: true,
|
||||
contactIsKnown: ${json.dumps(contact_is_known)|n},
|
||||
% if new_order_requires_customer:
|
||||
contactUUID: ${json.dumps(batch.customer_uuid)|n},
|
||||
% else:
|
||||
|
@ -609,10 +674,17 @@
|
|||
|
||||
% endif
|
||||
|
||||
customerName: null,
|
||||
phoneNumber: null,
|
||||
newCustomerName: ${json.dumps(new_customer_name)|n},
|
||||
newCustomerPhone: ${json.dumps(new_customer_phone)|n},
|
||||
newCustomerEmail: ${json.dumps(new_customer_email)|n},
|
||||
contactNotes: ${json.dumps(contact_notes)|n},
|
||||
|
||||
editNewCustomerShowDialog: false,
|
||||
editNewCustomerName: null,
|
||||
editNewCustomerPhone: null,
|
||||
editNewCustomerEmail: null,
|
||||
editNewCustomerSaving: false,
|
||||
|
||||
items: ${json.dumps(order_items)|n},
|
||||
editingItem: null,
|
||||
showingItemDialog: false,
|
||||
|
@ -646,8 +718,8 @@
|
|||
}
|
||||
}
|
||||
} else {
|
||||
if (this.customerName) {
|
||||
text = "Customer: " + this.customerName
|
||||
if (this.newCustomerName) {
|
||||
text = "Customer: " + this.newCustomerName
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -700,19 +772,19 @@
|
|||
}
|
||||
phoneNumber = this.orderPhoneNumber
|
||||
} else { // customer is not known
|
||||
if (!this.customerName) {
|
||||
if (!this.newCustomerName) {
|
||||
return {
|
||||
type: 'is-danger',
|
||||
text: "Please identify the customer.",
|
||||
}
|
||||
}
|
||||
if (!this.phoneNumber) {
|
||||
if (!this.newCustomerPhone) {
|
||||
return {
|
||||
type: 'is-warning',
|
||||
text: "Please provide a phone number for the customer.",
|
||||
}
|
||||
}
|
||||
phoneNumber = this.phoneNumber
|
||||
phoneNumber = this.newCustomerPhone
|
||||
}
|
||||
|
||||
let phoneDigits = phoneNumber.replace(/\D/g, '')
|
||||
|
@ -774,6 +846,26 @@
|
|||
|
||||
% endif
|
||||
|
||||
editNewCustomerSaveDisabled() {
|
||||
if (this.editNewCustomerSaving) {
|
||||
return true
|
||||
}
|
||||
if (!this.editNewCustomerName) {
|
||||
return true
|
||||
}
|
||||
if (!(this.editNewCustomerPhone || this.editNewCustomerEmail)) {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
},
|
||||
|
||||
editNewCustomerSaveText() {
|
||||
if (this.editNewCustomerSaving) {
|
||||
return "Working, please wait..."
|
||||
}
|
||||
return "Save"
|
||||
},
|
||||
|
||||
itemsPanelHeader() {
|
||||
let text = "Items"
|
||||
|
||||
|
@ -1044,6 +1136,46 @@
|
|||
|
||||
% endif
|
||||
|
||||
editNewCustomerInit() {
|
||||
this.editNewCustomerName = this.newCustomerName
|
||||
this.editNewCustomerPhone = this.newCustomerPhone
|
||||
this.editNewCustomerEmail = this.newCustomerEmail
|
||||
this.editNewCustomerShowDialog = true
|
||||
this.$nextTick(() => {
|
||||
this.$refs.editNewCustomerInput.focus()
|
||||
})
|
||||
},
|
||||
|
||||
editNewCustomerSave() {
|
||||
this.editNewCustomerSaving = true
|
||||
|
||||
let params = {
|
||||
action: 'update_pending_customer',
|
||||
display_name: this.editNewCustomerName,
|
||||
phone_number: this.editNewCustomerPhone,
|
||||
email_address: this.editNewCustomerEmail,
|
||||
}
|
||||
|
||||
this.submitBatchData(params, response => {
|
||||
if (response.data.success) {
|
||||
this.newCustomerName = response.data.new_customer_name
|
||||
this.newCustomerPhone = response.data.phone_number
|
||||
this.orderPhoneNumber = response.data.phone_number
|
||||
this.newCustomerEmail = response.data.email_address
|
||||
this.orderEmailAddress = response.data.email_address
|
||||
this.editNewCustomerShowDialog = false
|
||||
} else {
|
||||
this.$buefy.toast.open({
|
||||
message: "Save failed: " + (response.data.error || "(unknown error)"),
|
||||
type: 'is-danger',
|
||||
duration: 2000, // 2 seconds
|
||||
})
|
||||
}
|
||||
this.editNewCustomerSaving = false
|
||||
})
|
||||
|
||||
},
|
||||
|
||||
showAddItemDialog() {
|
||||
this.customerPanelOpen = false
|
||||
this.editingItem = null
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue