Replaced alert messages with toasts

This commit is contained in:
Gopi Katwala 2019-07-14 01:07:11 -04:00
parent 6b6e5fd791
commit 8266c8e85e
7 changed files with 265 additions and 225 deletions

View File

@ -1,5 +1,6 @@
import {Component, OnInit} from '@angular/core'; import {Component, OnInit} from '@angular/core';
import {AstuteClientService} from '../services/astute-client-service'; import {AstuteClientService} from '../services/astute-client-service';
import {ToastManagerService} from "../services/toast-manager/toast-service.service";
@Component({ @Component({
selector: 'app-customer', selector: 'app-customer',
@ -109,7 +110,7 @@ export class CustomerComponent implements OnInit {
// title: "Manager" // title: "Manager"
// workPhone: 1231231233 // workPhone: 1231231233
constructor(protected astuteClientService: AstuteClientService) { constructor(protected astuteClientService: AstuteClientService, protected toastService: ToastManagerService) {
} }
ngOnInit() { ngOnInit() {
@ -124,11 +125,11 @@ export class CustomerComponent implements OnInit {
// wrappers for customer service methods // wrappers for customer service methods
addCustomer(customerId, name, billTo, add1, add2, city, state, zip, zip4, email, phone, phExt, fax, ref) { addCustomer(customerId, name, billTo, add1, add2, city, state, zip, zip4, email, phone, phExt, fax, ref) {
if (fax.length > 0 && fax.length < 14) { if (fax.length > 0 && fax.length < 14) {
alert('Invalid fax.'); this.notif('Invalid fax.');
} else if (phone.length > 0 && phone.length < 14) { } else if (phone.length > 0 && phone.length < 14) {
alert('Invalid phone.'); this.notif('Invalid phone.');
} else if (email.length > 0 && /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(email) === false) { } else if (email.length > 0 && /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(email) === false) {
alert('You have entered an invalid email address!'); this.notif('You have entered an invalid email address!');
} else { } else {
const customerData = { const customerData = {
'customerId': customerId, 'customerId': customerId,
@ -150,20 +151,20 @@ export class CustomerComponent implements OnInit {
this.refreshData(); this.refreshData();
ref.close(); ref.close();
} else { } else {
alert('Customer Creation Failed, Check Input Fields'); this.notif('Customer Creation Failed, Check Input Fields');
} }
}, (reason) => { }, (reason) => {
alert('Add customer failed: ' + reason); this.notif('Add customer failed: ' + reason);
}); });
} }
} }
editCustomer(id, name, billTo, add1, add2, city, state, zip, zip4, email, phone, phExt, fax, ref) { editCustomer(id, name, billTo, add1, add2, city, state, zip, zip4, email, phone, phExt, fax, ref) {
if (fax.length > 0 && fax.length < 14) { if (fax.length > 0 && fax.length < 14) {
alert('Invalid fax.'); this.notif('Invalid fax.');
} else if (phone.length > 0 && phone.length < 14) { } else if (phone.length > 0 && phone.length < 14) {
alert('Invalid phone.'); this.notif('Invalid phone.');
} else if (email.length > 0 && /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(email) === false) { } else if (email.length > 0 && /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(email) === false) {
alert('You have entered an invalid email address!'); this.notif('You have entered an invalid email address!');
} else { } else {
const customerData = { const customerData = {
'customerId': id, 'customerId': id,
@ -186,10 +187,10 @@ export class CustomerComponent implements OnInit {
this.refreshData(); this.refreshData();
ref.close(); ref.close();
} else { } else {
alert('Customer Updating Failed, Check Input Fields'); this.notif('Customer Updating Failed, Check Input Fields');
} }
}, (reason) => { }, (reason) => {
alert('Update customer failed: ' + reason); this.notif('Update customer failed: ' + reason);
}); });
} }
} }
@ -201,12 +202,12 @@ export class CustomerComponent implements OnInit {
console.log('Customer, ' + customerId + ' successfully deleted'); console.log('Customer, ' + customerId + ' successfully deleted');
this.refreshData(); this.refreshData();
} else { } else {
alert('Error in deleting; Customer, ' + customerId + ' has not been deleted'); this.notif('Error in deleting; Customer, ' + customerId + ' has not been deleted');
} }
}); });
} }
} else { } else {
alert('Choose a customer first!'); this.notif('Choose a customer first!');
} }
} }
@ -226,12 +227,12 @@ export class CustomerComponent implements OnInit {
console.log(newContactData); console.log(newContactData);
this.astuteClientService.createCustomerContact(newContactData).then ((data) => { this.astuteClientService.createCustomerContact(newContactData).then ((data) => {
if (!data) { if (!data) {
alert('Contact Creation Failed, Check Input Fields'); this.notif('Contact Creation Failed, Check Input Fields');
} else { } else {
this.refreshContactData(this.selected.customerId); this.refreshContactData(this.selected.customerId);
} }
}, (reason) => { }, (reason) => {
alert('Create customer failed: ' + reason); this.notif('Create customer failed: ' + reason);
}); });
} }
deleteContact() { deleteContact() {
@ -243,14 +244,14 @@ export class CustomerComponent implements OnInit {
if (data) { if (data) {
this.refreshContactData(selec.customerId); this.refreshContactData(selec.customerId);
} else { } else {
alert('Contact Deletion Failed, Check Input Fields'); this.notif('Contact Deletion Failed, Check Input Fields');
} }
}, (reason) => { }, (reason) => {
alert('Delete customer failed: ' + reason); this.notif('Delete customer failed: ' + reason);
}); });
} }
} else { } else {
alert('Choose a contact first!'); this.notif('Choose a contact first!');
} }
} }
@ -260,21 +261,21 @@ export class CustomerComponent implements OnInit {
console.log(eventData); console.log(eventData);
if (eventData.fax.length > 0 && eventData.fax.length < 14) { if (eventData.fax.length > 0 && eventData.fax.length < 14) {
this.refreshData(); this.refreshData();
alert('Invalid fax.'); this.notif('Invalid fax.');
} else if (eventData.phone.length > 0 && eventData.phone.length < 14) { } else if (eventData.phone.length > 0 && eventData.phone.length < 14) {
this.refreshData(); this.refreshData();
alert('Invalid phone.'); this.notif('Invalid phone.');
} else if (eventData.email.length > 0 && /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(eventData.email) === false) { } else if (eventData.email.length > 0 && /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(eventData.email) === false) {
this.refreshData(); this.refreshData();
alert('You have entered an invalid email address!'); this.notif('You have entered an invalid email address!');
} else { } else {
this.astuteClientService.updateCustomer(eventData.customerId, eventData).then((data) => { this.astuteClientService.updateCustomer(eventData.customerId, eventData).then((data) => {
if (!data) { if (!data) {
this.refreshData(); this.refreshData();
alert('Customer Updating Failed, Check Input Fields'); this.notif('Customer Updating Failed, Check Input Fields');
} }
}, (reason) => { }, (reason) => {
alert('Update customer failed: ' + reason); this.notif('Update customer failed: ' + reason);
}); });
} }
} }
@ -283,23 +284,23 @@ export class CustomerComponent implements OnInit {
const eventData = event.data; const eventData = event.data;
// if (eventData.fax % 10 < 14) { // if (eventData.fax % 10 < 14) {
// alert('Invalid fax.'); // this.notif('Invalid fax.');
// } else if (eventData.mobile % 10 < 14) { // } else if (eventData.mobile % 10 < 14) {
// alert('Invalid phone.'); // this.notif('Invalid phone.');
// } else if (eventData.workPhone % 10 < 14) { // } else if (eventData.workPhone % 10 < 14) {
// alert('Invalid work phone.'); // this.notif('Invalid work phone.');
// } else // } else
if (eventData.email.length > 0 && /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(eventData.email) === false) { if (eventData.email.length > 0 && /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(eventData.email) === false) {
this.contactsData = this.astuteClientService.getCustomerContacts(eventData.customerId); this.contactsData = this.astuteClientService.getCustomerContacts(eventData.customerId);
alert('You have entered an invalid email address!'); this.notif('You have entered an invalid email address!');
} else { } else {
this.astuteClientService.updateCustomerContact(eventData.customerId, eventData).then((data) => { this.astuteClientService.updateCustomerContact(eventData.customerId, eventData).then((data) => {
if (!data) { if (!data) {
this.contactsData = this.astuteClientService.getCustomerContacts(eventData.customerId); this.contactsData = this.astuteClientService.getCustomerContacts(eventData.customerId);
// alert('Customer Updating Failed, Check Input Fields'); // this.notif('Customer Updating Failed, Check Input Fields');
} }
}, (reason) => { }, (reason) => {
alert('Update customer failed: ' + reason); this.notif('Update customer failed: ' + reason);
}); });
} }
} }
@ -340,4 +341,10 @@ export class CustomerComponent implements OnInit {
resizeColumns(evt) { resizeColumns(evt) {
evt.columnApi.autoSizeAllColumns(); evt.columnApi.autoSizeAllColumns();
} }
// ** toast notification method
notif(text: string) {
this.toastService.show(text, {classname: 'bg-danger text-light'});
}
} }

View File

@ -1,6 +1,7 @@
import {Component, ElementRef, OnInit, ViewChild} from '@angular/core'; import {Component, ElementRef, OnInit, ViewChild} from '@angular/core';
import {AstuteClientService} from '../services/astute-client-service'; import {AstuteClientService} from '../services/astute-client-service';
import {formatCurrency} from '@angular/common'; import {formatCurrency} from '@angular/common';
import {ToastManagerService} from "../services/toast-manager/toast-service.service";
declare var html2pdf: any; declare var html2pdf: any;
declare var html2canvas: any; declare var html2canvas: any;
@ -44,7 +45,7 @@ export class InvoiceGenComponent implements OnInit {
notes; notes;
cert; cert;
constructor(protected astuteClientService: AstuteClientService) { constructor(protected astuteClientService: AstuteClientService, protected toastService: ToastManagerService) {
// console.log('********** ' + this.astuteClientService.getInvoiceGen('123').then()); // console.log('********** ' + this.astuteClientService.getInvoiceGen('123').then());
} }
@ -411,8 +412,12 @@ export class InvoiceGenComponent implements OnInit {
// $.get('http://localhost/ws/service.asmx/HelloWord', function(response) { // $.get('http://localhost/ws/service.asmx/HelloWord', function(response) {
// data = response; // data = response;
// }).error(function(){ // }).error(function(){
// alert('Sorry could not proceed'); // this.notif('Sorry could not proceed');
// }); // });
// ** toast notification method
notif(text: string) {
this.toastService.show(text, {classname: 'bg-danger text-light'});
}
} }

View File

@ -1,6 +1,7 @@
import {Component, OnInit, ViewChild} from '@angular/core'; import {Component, OnInit, ViewChild} from '@angular/core';
import {AstuteClientService} from '../services/astute-client-service'; import {AstuteClientService} from '../services/astute-client-service';
import {formatCurrency} from "@angular/common"; import {formatCurrency} from "@angular/common";
import {ToastManagerService} from "../services/toast-manager/toast-service.service";
@Component({ @Component({
selector: 'app-invoice-payment', selector: 'app-invoice-payment',
@ -27,7 +28,7 @@ export class InvoicePaymentComponent implements OnInit {
]; ];
constructor(protected astuteClientService: AstuteClientService) { constructor(protected astuteClientService: AstuteClientService, protected toastService: ToastManagerService) {
} }
ngOnInit() { ngOnInit() {
@ -66,10 +67,10 @@ export class InvoicePaymentComponent implements OnInit {
this.refreshData(); this.refreshData();
ref.close(); ref.close();
} else { } else {
alert("Adding Invoice Payment Failed, Check Input Fields") this.notif("Adding Invoice Payment Failed, Check Input Fields")
} }
}, (reason) => { }, (reason) => {
alert("Adding Invoice Payment failed for " + reason); this.notif("Adding Invoice Payment failed for " + reason);
}); });
} }
@ -89,10 +90,10 @@ export class InvoicePaymentComponent implements OnInit {
this.refreshData(); this.refreshData();
ref.close(); ref.close();
} else { } else {
alert("Updating Invoice Payment Failed, Check Input Fields") this.notif("Updating Invoice Payment Failed, Check Input Fields")
} }
}, (reason) => { }, (reason) => {
alert("Updating Invoice Payment failed for " + reason); this.notif("Updating Invoice Payment failed for " + reason);
}); });
} }
@ -125,4 +126,9 @@ export class InvoicePaymentComponent implements OnInit {
this.invoicePaymentData = data; this.invoicePaymentData = data;
}); });
} }
// ** toast notification method
notif(text: string) {
this.toastService.show(text, {classname: 'bg-danger text-light'});
}
} }

View File

@ -2,6 +2,7 @@ import {Component, OnInit, ViewChild} from '@angular/core';
import {AstuteClientService} from '../services/astute-client-service'; import {AstuteClientService} from '../services/astute-client-service';
import {formatCurrency} from "@angular/common"; import {formatCurrency} from "@angular/common";
import {PrintInvoiceService} from '../services/print-invoice.service'; import {PrintInvoiceService} from '../services/print-invoice.service';
import {ToastManagerService} from "../services/toast-manager/toast-service.service";
declare var $: any; declare var $: any;
@ -76,7 +77,8 @@ export class InvoiceComponent implements OnInit {
constructor(protected astuteClientService: AstuteClientService, constructor(protected astuteClientService: AstuteClientService,
protected printService: PrintInvoiceService) { protected printService: PrintInvoiceService,
protected toastService: ToastManagerService) {
} }
customerDropdownChange(index) { customerDropdownChange(index) {
@ -105,14 +107,14 @@ export class InvoiceComponent implements OnInit {
// 'remainingQty': 0 // 'remainingQty': 0
// }; // };
// } else { // } else {
// alert('get PO detail failed!'); // this.notif('get PO detail failed!');
// } // }
// }); // });
this.astuteClientService.generateInvoiceNumber(ponum).then((data) => { this.astuteClientService.generateInvoiceNumber(ponum).then((data) => {
if (data) { if (data) {
this.generatedInvoiceNumber = data; this.generatedInvoiceNumber = data;
} else { } else {
alert('gen inv num failed!'); this.notif('gen inv num failed!');
} }
}); });
} }
@ -125,10 +127,10 @@ export class InvoiceComponent implements OnInit {
this.serviceNames.push(type.serviceTypeDesc); this.serviceNames.push(type.serviceTypeDesc);
}); });
} else { } else {
alert ('Get service types failed'); this.notif ('Get service types failed');
} }
}, reason => { }, reason => {
alert('Get service type failed: ' + reason); this.notif('Get service type failed: ' + reason);
}); });
this.astuteClientService.getRateTypes().then((d) => { this.astuteClientService.getRateTypes().then((d) => {
if (d) { if (d) {
@ -137,19 +139,19 @@ export class InvoiceComponent implements OnInit {
this.rateNames.push(type.feeTypeDesc); this.rateNames.push(type.feeTypeDesc);
}); });
} else { } else {
alert ('Get rate types failed'); this.notif ('Get rate types failed');
} }
}, reason => { }, reason => {
alert('Get rate type failed: ' + reason); this.notif('Get rate type failed: ' + reason);
}); });
this.astuteClientService.getCustomers().then((customers) => { this.astuteClientService.getCustomers().then((customers) => {
if (customers) { if (customers) {
this.customers = customers; this.customers = customers;
} else { } else {
alert('Get Customers Failed!'); this.notif('Get Customers Failed!');
} }
}, (reason) => { }, (reason) => {
alert('Get Customers Failed: ' + reason); this.notif('Get Customers Failed: ' + reason);
}); });
this.astuteClientService.getPOs().then((data) => { this.astuteClientService.getPOs().then((data) => {
if (data) { if (data) {
@ -162,18 +164,18 @@ export class InvoiceComponent implements OnInit {
}); });
// console.log(this.allPODetails); // console.log(this.allPODetails);
} else { } else {
alert('Get PO Detail for ' + po.ponum + ' failed!'); this.notif('Get PO Detail for ' + po.ponum + ' failed!');
} }
}, (reason) => { }, (reason) => {
alert('Get PO Detail for ' + po.ponum + ' failed: ' + reason); this.notif('Get PO Detail for ' + po.ponum + ' failed: ' + reason);
}); });
}); });
} else { } else {
alert ('Get PO failed'); this.notif ('Get PO failed');
} }
}, (reason) => { }, (reason) => {
alert('Get SOs Failed: ' + reason); this.notif('Get SOs Failed: ' + reason);
}); });
this.refreshData(); this.refreshData();
} }
@ -188,7 +190,7 @@ export class InvoiceComponent implements OnInit {
row.outstandingBalanceString = formatCurrency(row.outstandingBalance, 'en-US', '$', 'USD'); row.outstandingBalanceString = formatCurrency(row.outstandingBalance, 'en-US', '$', 'USD');
}); });
} else { } else {
alert('Get Invoices failed!'); this.notif('Get Invoices failed!');
} }
}); });
} }
@ -207,10 +209,10 @@ export class InvoiceComponent implements OnInit {
this.astuteClientService.updateInvoice(eventData.invoiceNumber, eventData).then((data) => { this.astuteClientService.updateInvoice(eventData.invoiceNumber, eventData).then((data) => {
if (!data) { if (!data) {
this.refreshData(); this.refreshData();
alert('Invoice Updating Failed, Check Input Fields'); this.notif('Invoice Updating Failed, Check Input Fields');
} }
}, (reason) => { }, (reason) => {
alert('Update invoice failed: ' + reason); this.notif('Update invoice failed: ' + reason);
}); });
// this.refreshData(); // this.refreshData();
} }
@ -220,12 +222,12 @@ export class InvoiceComponent implements OnInit {
this.astuteClientService.updateInvoiceDetail(eventData.invoiceNum, eventData.lineItemNum, eventData).then((data) => { this.astuteClientService.updateInvoiceDetail(eventData.invoiceNum, eventData.lineItemNum, eventData).then((data) => {
if (!data) { if (!data) {
this.refreshDetailsOfSelected(); this.refreshDetailsOfSelected();
alert('Detail Updating Failed, Check Input Fields'); this.notif('Detail Updating Failed, Check Input Fields');
} else { } else {
this.updateSelectedBillAmt(); this.updateSelectedBillAmt();
} }
}, (reason) => { }, (reason) => {
alert('Update Detail failed: ' + reason); this.notif('Update Detail failed: ' + reason);
}); });
} }
@ -268,7 +270,7 @@ export class InvoiceComponent implements OnInit {
this.updateSelectedBillAmt(); this.updateSelectedBillAmt();
return data; return data;
} else { } else {
alert('get Inv detail failed!'); this.notif('get Inv detail failed!');
} }
}); });
this.pos.forEach((po) => { this.pos.forEach((po) => {
@ -361,11 +363,11 @@ export class InvoiceComponent implements OnInit {
// } // }
// }); // });
// } else { // } else {
// alert("get Inv detail failed!"); // this.notif("get Inv detail failed!");
// } // }
// }); // });
// } else { // } else {
// alert("get PO detail failed!") // this.notif("get PO detail failed!")
// } // }
// }); // });
// this.pos.forEach((po) => { // this.pos.forEach((po) => {
@ -445,7 +447,7 @@ export class InvoiceComponent implements OnInit {
console.log('Invoice, ' + invoiceNum + ' successfully deleted'); console.log('Invoice, ' + invoiceNum + ' successfully deleted');
this.refreshData(); this.refreshData();
} else { } else {
alert ('Error in deleting; Invoice, ' + invoiceNum + ' has not been deleted'); this.notif ('Error in deleting; Invoice, ' + invoiceNum + ' has not been deleted');
} }
}); });
} }
@ -484,7 +486,7 @@ export class InvoiceComponent implements OnInit {
// this.addInvoiceDetail(this.newInDetails); // this.addInvoiceDetail(this.newInDetails);
ref.close(); ref.close();
} else { } else {
alert('Invoice Creation Failed, Check Input Fields'); this.notif('Invoice Creation Failed, Check Input Fields');
} }
}); });
} }
@ -516,12 +518,12 @@ export class InvoiceComponent implements OnInit {
}) })
.then((data) => { .then((data) => {
if (data) { if (data) {
alert("invoice " + invoiceNumber + " updated!"); this.notif("invoice " + invoiceNumber + " updated!");
console.log("fulfilled: " + data); console.log("fulfilled: " + data);
// this.source[this.chosenInv] = invData; // this.source[this.chosenInv] = invData;
this.refreshData(); this.refreshData();
} else { } else {
alert("Invoice Update Failed, Check Input Fields") this.notif("Invoice Update Failed, Check Input Fields")
} }
}); });
} }
@ -531,7 +533,7 @@ export class InvoiceComponent implements OnInit {
if (data) { if (data) {
this.refreshData(); this.refreshData();
} else { } else {
alert('void invoice failed.'); this.notif('void invoice failed.');
} }
}); });
} }
@ -541,7 +543,7 @@ export class InvoiceComponent implements OnInit {
if (data) { if (data) {
this.refreshData(); this.refreshData();
} else { } else {
alert('submit invoice failed.'); this.notif('submit invoice failed.');
} }
}); });
} }
@ -572,11 +574,11 @@ export class InvoiceComponent implements OnInit {
this.astuteClientService.createInvoiceDetail(emptyData).then((data) => { this.astuteClientService.createInvoiceDetail(emptyData).then((data) => {
if (!data) { if (!data) {
alert('Creating SO detailed failed!'); this.notif('Creating SO detailed failed!');
} }
this.refreshDetailsOfSelected(); this.refreshDetailsOfSelected();
}, (reason) => { }, (reason) => {
alert('Creating SO detailed failed: ' + reason); this.notif('Creating SO detailed failed: ' + reason);
}); });
} }
@ -589,7 +591,7 @@ export class InvoiceComponent implements OnInit {
// details.splice(0, 1); // details.splice(0, 1);
// this.addInvoiceDetail(details); // this.addInvoiceDetail(details);
// } else { // } else {
// alert('add inv detail failed'); // this.notif('add inv detail failed');
// } // }
// }); // });
// // } else { // // } else {
@ -618,7 +620,7 @@ export class InvoiceComponent implements OnInit {
// // if (d) { // // if (d) {
// // console.log (d); // // console.log (d);
// // } else { // // } else {
// // alert('create custom PO failed.'); // // this.notif('create custom PO failed.');
// // } // // }
// // }); // // });
// // } // // }
@ -683,4 +685,10 @@ export class InvoiceComponent implements OnInit {
resizeColumns(evt) { resizeColumns(evt) {
evt.columnApi.autoSizeAllColumns(); evt.columnApi.autoSizeAllColumns();
} }
// ** toast notification method
notif(text: string) {
this.toastService.show(text, {classname: 'bg-danger text-light'});
}
} }

View File

@ -2,6 +2,7 @@ import {Component, OnInit, ViewEncapsulation} from '@angular/core';
import {NgForm} from '@angular/forms'; import {NgForm} from '@angular/forms';
import {Router} from '@angular/router'; import {Router} from '@angular/router';
import {AstuteClientService} from '../services/astute-client-service'; import {AstuteClientService} from '../services/astute-client-service';
import {ToastManagerService} from "../services/toast-manager/toast-service.service";
@Component({ @Component({
selector: 'app-login', selector: 'app-login',
@ -11,7 +12,7 @@ import {AstuteClientService} from '../services/astute-client-service';
}) })
export class LoginComponent implements OnInit { export class LoginComponent implements OnInit {
constructor(protected astuteClientService: AstuteClientService, constructor(protected astuteClientService: AstuteClientService, protected toastService: ToastManagerService,
private router: Router) {} private router: Router) {}
ngOnInit() { ngOnInit() {
@ -27,8 +28,14 @@ export class LoginComponent implements OnInit {
if (data) { if (data) {
this.router.navigate(['/homepage']); this.router.navigate(['/homepage']);
} else { } else {
alert('login failed, checked credentials'); this.notif('login failed, checked credentials');
} }
}) })
} }
// ** toast notification method
notif(text: string) {
this.toastService.show(text, {classname: 'bg-danger text-light'});
}
} }

View File

@ -1,6 +1,7 @@
import {Component, OnInit, ViewChild} from '@angular/core'; import {Component, OnInit, ViewChild} from '@angular/core';
import {AstuteClientService} from '../services/astute-client-service'; import {AstuteClientService} from '../services/astute-client-service';
import {formatCurrency} from '@angular/common'; import {formatCurrency} from '@angular/common';
import {ToastManagerService} from "../services/toast-manager/toast-service.service";
@Component({ @Component({
selector: 'app-sales-order', selector: 'app-sales-order',
@ -63,7 +64,7 @@ export class SalesOrderComponent implements OnInit {
]; ];
contractAmount = 0; // used to show total amount contractAmount = 0; // used to show total amount
constructor(private astuteClientService: AstuteClientService) { constructor(private astuteClientService: AstuteClientService, protected toastService: ToastManagerService) {
} }
ngOnInit() { ngOnInit() {
@ -75,10 +76,10 @@ export class SalesOrderComponent implements OnInit {
}); });
// console.log(this.serviceNames); // console.log(this.serviceNames);
} else { } else {
alert ('Get service types failed'); this.notif ('Get service types failed');
} }
}, reason => { }, reason => {
alert('Get service type failed: ' + reason); this.notif('Get service type failed: ' + reason);
}); });
this.astuteClientService.getRateTypes().then((d) => { this.astuteClientService.getRateTypes().then((d) => {
if (d) { if (d) {
@ -87,19 +88,19 @@ export class SalesOrderComponent implements OnInit {
this.rateNames.push(type.feeTypeDesc); this.rateNames.push(type.feeTypeDesc);
}); });
} else { } else {
alert ('Get rate types failed'); this.notif ('Get rate types failed');
} }
}, reason => { }, reason => {
alert('Get rate type failed: ' + reason); this.notif('Get rate type failed: ' + reason);
}); });
this.astuteClientService.getCustomers().then((customers) => { this.astuteClientService.getCustomers().then((customers) => {
if (customers) { if (customers) {
this.customers = customers; this.customers = customers;
} else { } else {
alert('Get Customers Failed!'); this.notif('Get Customers Failed!');
} }
}, (reason) => { }, (reason) => {
alert('Get Customers Failed: ' + reason); this.notif('Get Customers Failed: ' + reason);
}); });
this.refreshData(); this.refreshData();
} }
@ -120,10 +121,10 @@ export class SalesOrderComponent implements OnInit {
this.updateContractAmt(); this.updateContractAmt();
return data; return data;
} else { } else {
alert('Get SO detail failed!'); this.notif('Get SO detail failed!');
} }
}, (reason) => { }, (reason) => {
alert('Get SO detail failed: ' + reason); this.notif('Get SO detail failed: ' + reason);
}); });
} }
@ -134,11 +135,11 @@ export class SalesOrderComponent implements OnInit {
this.astuteClientService.updatePO(eventData.poNum, eventData).then((data) => { this.astuteClientService.updatePO(eventData.poNum, eventData).then((data) => {
if (!data) { if (!data) {
alert('SO updating failed, check input fields'); this.notif('SO updating failed, check input fields');
this.refreshData(); this.refreshData();
} }
}, (reason) => { }, (reason) => {
alert('Update SO failed: ' + reason); this.notif('Update SO failed: ' + reason);
}); });
// this.refreshData(); // this.refreshData();
} }
@ -148,19 +149,19 @@ export class SalesOrderComponent implements OnInit {
event.data.serviceTypeId = this.getServiceIdFromName(event.data.serviceTypeName); event.data.serviceTypeId = this.getServiceIdFromName(event.data.serviceTypeName);
event.data.feeTypeId = this.getFeeIdFromName(event.data.rateTypeName); event.data.feeTypeId = this.getFeeIdFromName(event.data.rateTypeName);
if (event.data.feeTypeId === 1 && event.data.qty > 1) { // fixed fee and qty > 1 if (event.data.feeTypeId === 1 && event.data.qty > 1) { // fixed fee and qty > 1
alert('Cannot have a quantity greater than 1 for fixed fee rate type.'); this.notif('Cannot have a quantity greater than 1 for fixed fee rate type.');
this.refreshDetailsOfSelected(); this.refreshDetailsOfSelected();
} else { } else {
// console.log(event.data.serviceTypeId); // console.log(event.data.serviceTypeId);
this.astuteClientService.updatePODetail(eventData.poNum, eventData.lineItemNo, eventData).then((data) => { this.astuteClientService.updatePODetail(eventData.poNum, eventData.lineItemNo, eventData).then((data) => {
if (!data) { if (!data) {
alert('SO Detail updating failed, check input fields'); this.notif('SO Detail updating failed, check input fields');
this.refreshDetailsOfSelected(); this.refreshDetailsOfSelected();
} else { } else {
this.updateContractAmt(); this.updateContractAmt();
} }
}, (reason) => { }, (reason) => {
alert('Update SO Detail failed: ' + reason); this.notif('Update SO Detail failed: ' + reason);
}); });
// this.refreshData(); // this.refreshData();
} }
@ -185,10 +186,10 @@ export class SalesOrderComponent implements OnInit {
// this.addPODetail(this.newPODetail); // this.addPODetail(this.newPODetail);
ref.close(); ref.close();
} else { } else {
alert('SO Creation failed, check input fields'); this.notif('SO Creation failed, check input fields');
} }
}, (reason) => { }, (reason) => {
alert('Add SO failed for ' + reason); this.notif('Add SO failed for ' + reason);
}); });
} }
editPo(projNum, ponum, podate, contractnum, contractamt, title, notes, ref) { editPo(projNum, ponum, podate, contractnum, contractamt, title, notes, ref) {
@ -208,22 +209,22 @@ export class SalesOrderComponent implements OnInit {
// this.editPODetail(this.selectedPODetail); // this.editPODetail(this.selectedPODetail);
ref.close(); ref.close();
} else { } else {
alert('SO updating failed, check input fields'); this.notif('SO updating failed, check input fields');
} }
}, (reason) => { }, (reason) => {
alert('Update SO failed for ' + reason); this.notif('Update SO failed for ' + reason);
}); });
} }
finalizePO(ponum) { finalizePO(ponum) {
this.astuteClientService.finalizePO(ponum).then((data) => { this.astuteClientService.finalizePO(ponum).then((data) => {
if (data) { if (data) {
this.refreshData(); this.refreshData();
alert('SO is now final and ready to be used, you can\'t delete it anymore!'); this.notif('SO is now final and ready to be used, you can\'t delete it anymore!');
} else { } else {
alert('Finalizing SO failed, check input fields'); this.notif('Finalizing SO failed, check input fields');
} }
}, reason => { }, reason => {
alert('Finalizing SO failed: ' + reason); this.notif('Finalizing SO failed: ' + reason);
}); });
} }
deletePO(ponum) { deletePO(ponum) {
@ -232,10 +233,10 @@ export class SalesOrderComponent implements OnInit {
if (data) { if (data) {
this.refreshData(); this.refreshData();
} else { } else {
alert('Deleting SO failed, check input fields'); this.notif('Deleting SO failed, check input fields');
} }
}, (reason) => { }, (reason) => {
alert('Deleting SO failed: ' + reason); this.notif('Deleting SO failed: ' + reason);
}); });
} }
@ -264,11 +265,11 @@ export class SalesOrderComponent implements OnInit {
// Double remainingQuantity; // Double remainingQuantity;
this.astuteClientService.createPODetail(emptyData).then((data) => { this.astuteClientService.createPODetail(emptyData).then((data) => {
if (!data) { if (!data) {
alert('Creating SO detailed failed!'); this.notif('Creating SO detailed failed!');
} }
this.refreshDetailsOfSelected(); this.refreshDetailsOfSelected();
}, (reason) => { }, (reason) => {
alert('Creating SO detailed failed: ' + reason); this.notif('Creating SO detailed failed: ' + reason);
}); });
} }
@ -304,10 +305,10 @@ export class SalesOrderComponent implements OnInit {
// this.updateNewContractAmt(); // this.updateNewContractAmt();
// this.updateEditContractAmt(); // this.updateEditContractAmt();
// } else { // } else {
// alert('Get SO\'s Failed!'); // this.notif('Get SO\'s Failed!');
// } // }
// }, (reason) => { // }, (reason) => {
// alert('Get SO\'s Failed: ' + reason); // this.notif('Get SO\'s Failed: ' + reason);
// }); // });
this.rowData = this.astuteClientService.getPOs().then((data) => { this.rowData = this.astuteClientService.getPOs().then((data) => {
if (data) { if (data) {
@ -321,10 +322,10 @@ export class SalesOrderComponent implements OnInit {
this.contractAmount = 0; this.contractAmount = 0;
return data; return data;
} else { } else {
alert('Get SO\'s Failed!'); this.notif('Get SO\'s Failed!');
} }
}, (reason) => { }, (reason) => {
alert('Get SO\'s Failed: ' + reason); this.notif('Get SO\'s Failed: ' + reason);
}); });
} }
refreshDetailsOfSelected() { refreshDetailsOfSelected() {
@ -400,4 +401,10 @@ export class SalesOrderComponent implements OnInit {
resizeColumns(evt) { resizeColumns(evt) {
evt.columnApi.autoSizeAllColumns(); evt.columnApi.autoSizeAllColumns();
} }
// ** toast notification method
notif(text: string) {
this.toastService.show(text, {classname: 'bg-danger text-light'});
}
} }

View File

@ -108,13 +108,13 @@ export class AstuteClientService {
} else if (message.includes('login')) { } else if (message.includes('login')) {
this.notif('Please login again!'); this.notif('Please login again!');
} else { } else {
alert('Update Customer Failed: ' + message); this.notif('Update Customer Failed: ' + message);
} }
}, (reason) => { }, (reason) => {
alert('Update Customer Failed: ' + reason); this.notif('Update Customer Failed: ' + reason);
}) })
.catch( error => { .catch( error => {
alert(error); this.notif(error);
}); });
} }
public createCustomer(data: any): Promise<any> { public createCustomer(data: any): Promise<any> {
@ -129,15 +129,15 @@ export class AstuteClientService {
console.log(response['entity']); console.log(response['entity']);
return response['entity']; return response['entity'];
} else if (message.includes('login')) { } else if (message.includes('login')) {
alert('Please login again!'); this.notif('Please login again!');
} else { } else {
alert('Create Customer Failed: ' + message); this.notif('Create Customer Failed: ' + message);
} }
}, (reason) => { }, (reason) => {
alert('Create Customer Failed: ' + reason); this.notif('Create Customer Failed: ' + reason);
}) })
.catch( error => { .catch( error => {
alert(error); this.notif(error);
}); });
} }
public deleteCustomer(customerId) { public deleteCustomer(customerId) {
@ -152,15 +152,15 @@ export class AstuteClientService {
console.log(response['entity']); console.log(response['entity']);
return response['entity']; return response['entity'];
} else if (message.includes('login')) { } else if (message.includes('login')) {
alert('Please login again!'); this.notif('Please login again!');
} else { } else {
alert('Delete Customer Failed: ' + message); this.notif('Delete Customer Failed: ' + message);
} }
}, (reason) => { }, (reason) => {
alert('Delete Customer Failed: ' + reason); this.notif('Delete Customer Failed: ' + reason);
}) })
.catch( error => { .catch( error => {
alert(error); this.notif(error);
}); });
} }
@ -177,15 +177,15 @@ export class AstuteClientService {
console.log(response['entity']); console.log(response['entity']);
return response['entity']; return response['entity'];
} else if (message.includes('login')) { } else if (message.includes('login')) {
alert('Please login again!'); this.notif('Please login again!');
} else { } else {
alert('Get Customer Contacts Failed: ' + message); this.notif('Get Customer Contacts Failed: ' + message);
} }
}, (reason) => { }, (reason) => {
alert('Get Customer Contacts Failed: ' + reason); this.notif('Get Customer Contacts Failed: ' + reason);
}) })
.catch( error => { .catch( error => {
alert(error); this.notif(error);
}); });
} }
public updateCustomerContact(customerId: string, data: any): Promise<any> { public updateCustomerContact(customerId: string, data: any): Promise<any> {
@ -200,15 +200,15 @@ export class AstuteClientService {
console.log(response['entity']); console.log(response['entity']);
return response['entity']; return response['entity'];
} else if (message.includes('login')) { } else if (message.includes('login')) {
alert('Please login again!'); this.notif('Please login again!');
} else { } else {
alert('Update Customer Contacts Failed: ' + message); this.notif('Update Customer Contacts Failed: ' + message);
} }
}, (reason) => { }, (reason) => {
alert('Update Customer Contacts Failed: ' + reason); this.notif('Update Customer Contacts Failed: ' + reason);
}) })
.catch( error => { .catch( error => {
alert(error); this.notif(error);
}); });
} }
public deleteCustomerContact(customerId: string, contactId: number): Promise<any> { public deleteCustomerContact(customerId: string, contactId: number): Promise<any> {
@ -223,15 +223,15 @@ export class AstuteClientService {
console.log(response['entity']); console.log(response['entity']);
return response['entity']; return response['entity'];
} else if (message.includes('login')) { } else if (message.includes('login')) {
alert('Please login again!'); this.notif('Please login again!');
} else { } else {
alert('Delete Customer Contacts Failed: ' + message); this.notif('Delete Customer Contacts Failed: ' + message);
} }
}, (reason) => { }, (reason) => {
alert('Delete Customer Contacts Failed: ' + reason); this.notif('Delete Customer Contacts Failed: ' + reason);
}) })
.catch( error => { .catch( error => {
alert(error); this.notif(error);
}); });
} }
public createCustomerContact(data: any): Promise<any> { public createCustomerContact(data: any): Promise<any> {
@ -246,15 +246,15 @@ export class AstuteClientService {
console.log(response['entity']); console.log(response['entity']);
return response['entity']; return response['entity'];
} else if (message.includes('login')) { } else if (message.includes('login')) {
alert('Please login again!'); this.notif('Please login again!');
} else { } else {
alert('Create Customer Contacts Failed: ' + message); this.notif('Create Customer Contacts Failed: ' + message);
} }
}, (reason) => { }, (reason) => {
alert('Create Customer Contacts Failed: ' + reason); this.notif('Create Customer Contacts Failed: ' + reason);
}) })
.catch( error => { .catch( error => {
alert(error); this.notif(error);
}); });
} }
@ -317,15 +317,15 @@ export class AstuteClientService {
console.log(response['entity']); console.log(response['entity']);
return response['entity']; return response['entity'];
} else if (message.includes('login')) { } else if (message.includes('login')) {
alert('Please login again!'); this.notif('Please login again!');
} else { } else {
alert('Get Customers Failed: ' + message); this.notif('Get Customers Failed: ' + message);
} }
}, (reason) => { }, (reason) => {
alert('Update Sales Order Failed: ' + reason); this.notif('Update Sales Order Failed: ' + reason);
}) })
.catch( error => { .catch( error => {
alert(error); this.notif(error);
}); });
} }
public createPO(data: any): Promise<any> { public createPO(data: any): Promise<any> {
@ -340,15 +340,15 @@ export class AstuteClientService {
console.log(response['entity']); console.log(response['entity']);
return response['entity']; return response['entity'];
} else if (message.includes('login')) { } else if (message.includes('login')) {
alert('Please login again!'); this.notif('Please login again!');
} else { } else {
alert('Get Customers Failed: ' + message); this.notif('Get Customers Failed: ' + message);
} }
}, (reason) => { }, (reason) => {
alert('Create Sales Order Failed: ' + reason); this.notif('Create Sales Order Failed: ' + reason);
}) })
.catch( error => { .catch( error => {
alert(error); this.notif(error);
}); });
} }
public updatePODetail(ponum, lineItemNo, data) { public updatePODetail(ponum, lineItemNo, data) {
@ -364,15 +364,15 @@ export class AstuteClientService {
console.log(response['entity']); console.log(response['entity']);
return response['entity']; return response['entity'];
} else if (message.includes('login')) { } else if (message.includes('login')) {
alert('Please login again!'); this.notif('Please login again!');
} else { } else {
alert('Get Customers Failed: ' + message); this.notif('Get Customers Failed: ' + message);
} }
}, (reason) => { }, (reason) => {
alert('Update Sales Order Details Failed: ' + reason); this.notif('Update Sales Order Details Failed: ' + reason);
}) })
.catch( error => { .catch( error => {
alert(error); this.notif(error);
}); });
} }
public createPODetail(data) { public createPODetail(data) {
@ -387,15 +387,15 @@ export class AstuteClientService {
console.log(response['entity']); console.log(response['entity']);
return response['entity']; return response['entity'];
} else if (message.includes('login')) { } else if (message.includes('login')) {
alert('Please login again!'); this.notif('Please login again!');
} else { } else {
alert('Get Customers Failed: ' + message); this.notif('Get Customers Failed: ' + message);
} }
}, (reason) => { }, (reason) => {
alert('Create Sales Order Failed: ' + reason); this.notif('Create Sales Order Failed: ' + reason);
}) })
.catch( error => { .catch( error => {
alert(error); this.notif(error);
}); });
} }
public finalizePO(ponum: string) { public finalizePO(ponum: string) {
@ -410,15 +410,15 @@ export class AstuteClientService {
console.log(response['entity']); console.log(response['entity']);
return response['entity']; return response['entity'];
} else if (message.includes('login')) { } else if (message.includes('login')) {
alert('Please login again!'); this.notif('Please login again!');
} else { } else {
alert('Get Customers Failed: ' + message); this.notif('Get Customers Failed: ' + message);
} }
}, (reason) => { }, (reason) => {
alert('Finalize Sales Order Failed: ' + reason); this.notif('Finalize Sales Order Failed: ' + reason);
}) })
.catch( error => { .catch( error => {
alert(error); this.notif(error);
}); });
} }
public deletePO(ponum: string) { public deletePO(ponum: string) {
@ -433,15 +433,15 @@ export class AstuteClientService {
console.log(response['entity']); console.log(response['entity']);
return response['entity']; return response['entity'];
} else if (message.includes('login')) { } else if (message.includes('login')) {
alert('Please login again!'); this.notif('Please login again!');
} else { } else {
alert('Get Customers Failed: ' + message); this.notif('Get Customers Failed: ' + message);
} }
}, (reason) => { }, (reason) => {
alert('Delete Sales Order Failed: ' + reason); this.notif('Delete Sales Order Failed: ' + reason);
}) })
.catch( error => { .catch( error => {
alert(error); this.notif(error);
}); });
} }
public getRateTypes(): Promise<any> { public getRateTypes(): Promise<any> {
@ -456,15 +456,15 @@ export class AstuteClientService {
console.log(response['entity']); console.log(response['entity']);
return response['entity']; return response['entity'];
} else if (message.includes('login')) { } else if (message.includes('login')) {
alert('Please login again!'); this.notif('Please login again!');
} else { } else {
alert('Get Customers Failed: ' + message); this.notif('Get Customers Failed: ' + message);
} }
}, (reason) => { }, (reason) => {
alert('Get Rate Types Failed: ' + reason); this.notif('Get Rate Types Failed: ' + reason);
}) })
.catch( error => { .catch( error => {
alert(error); this.notif(error);
}); });
} }
@ -481,15 +481,15 @@ export class AstuteClientService {
console.log(response['entity']); console.log(response['entity']);
return response['entity']; return response['entity'];
} else if (message.includes('login')) { } else if (message.includes('login')) {
alert('Please login again!'); this.notif('Please login again!');
} else { } else {
alert('Get Customers Failed: ' + message); this.notif('Get Customers Failed: ' + message);
} }
}, (reason) => { }, (reason) => {
alert('Submit Invoice Failed: ' + reason); this.notif('Submit Invoice Failed: ' + reason);
}) })
.catch( error => { .catch( error => {
alert(error); this.notif(error);
}); });
} }
public voidInvoice (invoiceNumber) { public voidInvoice (invoiceNumber) {
@ -504,15 +504,15 @@ export class AstuteClientService {
console.log(response['entity']); console.log(response['entity']);
return response['entity']; return response['entity'];
} else if (message.includes('login')) { } else if (message.includes('login')) {
alert('Please login again!'); this.notif('Please login again!');
} else { } else {
alert('Get Customers Failed: ' + message); this.notif('Get Customers Failed: ' + message);
} }
}, (reason) => { }, (reason) => {
alert('Void Invoice Failed: ' + reason); this.notif('Void Invoice Failed: ' + reason);
}) })
.catch( error => { .catch( error => {
alert(error); this.notif(error);
}); });
} }
public deleteInvoice (invoiceNumber) { public deleteInvoice (invoiceNumber) {
@ -527,15 +527,15 @@ export class AstuteClientService {
console.log(response['entity']); console.log(response['entity']);
return response['entity']; return response['entity'];
} else if (message.includes('login')) { } else if (message.includes('login')) {
alert('Please login again!'); this.notif('Please login again!');
} else { } else {
alert('Get Customers Failed: ' + message); this.notif('Get Customers Failed: ' + message);
} }
}, (reason) => { }, (reason) => {
alert('Delete Invoice Failed: ' + reason); this.notif('Delete Invoice Failed: ' + reason);
}) })
.catch( error => { .catch( error => {
alert(error); this.notif(error);
}); });
} }
public generateInvoiceNumber (ponum) { public generateInvoiceNumber (ponum) {
@ -550,15 +550,15 @@ export class AstuteClientService {
console.log(response['entity']); console.log(response['entity']);
return response['entity']; return response['entity'];
} else if (message.includes('login')) { } else if (message.includes('login')) {
alert('Please login again!'); this.notif('Please login again!');
} else { } else {
alert('Get Customers Failed: ' + message); this.notif('Get Customers Failed: ' + message);
} }
}, (reason) => { }, (reason) => {
alert('Generate Invoice Failed: ' + reason); this.notif('Generate Invoice Failed: ' + reason);
}) })
.catch( error => { .catch( error => {
alert(error); this.notif(error);
}); });
} }
public getInvoices(): Promise<any> { public getInvoices(): Promise<any> {
@ -596,15 +596,15 @@ export class AstuteClientService {
console.log(response['entity']); console.log(response['entity']);
return response['entity']; return response['entity'];
} else if (message.includes('login')) { } else if (message.includes('login')) {
alert('Please login again!'); this.notif('Please login again!');
} else { } else {
alert('Get Customers Failed: ' + message); this.notif('Get Customers Failed: ' + message);
} }
}, (reason) => { }, (reason) => {
alert('Get Invoice Details Failed: ' + reason); this.notif('Get Invoice Details Failed: ' + reason);
}) })
.catch( error => { .catch( error => {
alert(error); this.notif(error);
}); });
} }
public getInvoiceGen (invoiceId: string): Promise<any> { public getInvoiceGen (invoiceId: string): Promise<any> {
@ -619,15 +619,15 @@ export class AstuteClientService {
console.log(response['entity']); console.log(response['entity']);
return response['entity']; return response['entity'];
} else if (message.includes('login')) { } else if (message.includes('login')) {
alert('Please login again!'); this.notif('Please login again!');
} else { } else {
alert('Get Customers Failed: ' + message); this.notif('Get Customers Failed: ' + message);
} }
}, (reason) => { }, (reason) => {
alert('Get Generated Invoice Failed: ' + reason); this.notif('Get Generated Invoice Failed: ' + reason);
}) })
.catch( error => { .catch( error => {
alert(error); this.notif(error);
}); });
} }
public updateInvoice(invoiceNumber: string, data: any): Promise<any> { public updateInvoice(invoiceNumber: string, data: any): Promise<any> {
@ -642,15 +642,15 @@ export class AstuteClientService {
console.log(response['entity']); console.log(response['entity']);
return response['entity']; return response['entity'];
} else if (message.includes('login')) { } else if (message.includes('login')) {
alert('Please login again!'); this.notif('Please login again!');
} else { } else {
alert('Get Customers Failed: ' + message); this.notif('Get Customers Failed: ' + message);
} }
}, (reason) => { }, (reason) => {
alert('Update Invoice Failed: ' + reason); this.notif('Update Invoice Failed: ' + reason);
}) })
.catch( error => { .catch( error => {
alert(error); this.notif(error);
}); });
} }
public createInvoice(data: any): Promise<any> { public createInvoice(data: any): Promise<any> {
@ -665,15 +665,15 @@ export class AstuteClientService {
console.log(response['entity']); console.log(response['entity']);
return response['entity']; return response['entity'];
} else if (message.includes('login')) { } else if (message.includes('login')) {
alert('Please login again!'); this.notif('Please login again!');
} else { } else {
alert('Get Customers Failed: ' + message); this.notif('Get Customers Failed: ' + message);
} }
}, (reason) => { }, (reason) => {
alert('Create Invoice Failed: ' + reason); this.notif('Create Invoice Failed: ' + reason);
}) })
.catch( error => { .catch( error => {
alert(error); this.notif(error);
}); });
} }
public updateInvoiceDetail(invNum, lineItemNo, data) { public updateInvoiceDetail(invNum, lineItemNo, data) {
@ -688,15 +688,15 @@ export class AstuteClientService {
console.log(response['entity']); console.log(response['entity']);
return response['entity']; return response['entity'];
} else if (message.includes('login')) { } else if (message.includes('login')) {
alert('Please login again!'); this.notif('Please login again!');
} else { } else {
alert('Get Customers Failed: ' + message); this.notif('Get Customers Failed: ' + message);
} }
}, (reason) => { }, (reason) => {
alert('Update Invoice Detail Failed: ' + reason); this.notif('Update Invoice Detail Failed: ' + reason);
}) })
.catch( error => { .catch( error => {
alert(error); this.notif(error);
}); });
} }
public createInvoiceDetail(data) { public createInvoiceDetail(data) {
@ -711,15 +711,15 @@ export class AstuteClientService {
console.log(response['entity']); console.log(response['entity']);
return response['entity']; return response['entity'];
} else if (message.includes('login')) { } else if (message.includes('login')) {
alert('Please login again!'); this.notif('Please login again!');
} else { } else {
alert('Get Customers Failed: ' + message); this.notif('Get Customers Failed: ' + message);
} }
}, (reason) => { }, (reason) => {
alert('Create Invoice Detail Failed: ' + reason); this.notif('Create Invoice Detail Failed: ' + reason);
}) })
.catch( error => { .catch( error => {
alert(error); this.notif(error);
}); });
} }
@ -737,15 +737,15 @@ export class AstuteClientService {
console.log(response['entity']); console.log(response['entity']);
return response['entity']; return response['entity'];
} else if (message.includes('login')) { } else if (message.includes('login')) {
alert('Please login again!'); this.notif('Please login again!');
} else { } else {
alert('Get Customers Failed: ' + message); this.notif('Get Customers Failed: ' + message);
} }
}, (reason) => { }, (reason) => {
alert('Get Submitted Invoices Failed: ' + reason); this.notif('Get Submitted Invoices Failed: ' + reason);
}) })
.catch( error => { .catch( error => {
alert(error); this.notif(error);
}); });
} }
public getInvoicePaymentTypes(): Promise<any> { public getInvoicePaymentTypes(): Promise<any> {
@ -760,15 +760,15 @@ export class AstuteClientService {
console.log(response['entity']); console.log(response['entity']);
return response['entity']; return response['entity'];
} else if (message.includes('login')) { } else if (message.includes('login')) {
alert('Please login again!'); this.notif('Please login again!');
} else { } else {
alert('Get Customers Failed: ' + message); this.notif('Get Customers Failed: ' + message);
} }
}, (reason) => { }, (reason) => {
alert('Get Invoice Payment Types Failed: ' + reason); this.notif('Get Invoice Payment Types Failed: ' + reason);
}) })
.catch( error => { .catch( error => {
alert(error); this.notif(error);
}); });
} }
public getInvoicePayments(): Promise<any> { public getInvoicePayments(): Promise<any> {
@ -783,15 +783,15 @@ export class AstuteClientService {
console.log(response['entity']); console.log(response['entity']);
return response['entity']; return response['entity'];
} else if (message.includes('login')) { } else if (message.includes('login')) {
alert('Please login again!'); this.notif('Please login again!');
} else { } else {
alert('Get Customers Failed: ' + message); this.notif('Get Customers Failed: ' + message);
} }
}, (reason) => { }, (reason) => {
alert('Get Invoice Payments Failed: ' + reason); this.notif('Get Invoice Payments Failed: ' + reason);
}) })
.catch( error => { .catch( error => {
alert(error); this.notif(error);
}); });
} }
public updateInvoicePayment(invoiceNumber: string, invoicePaymentId: string, data: any): Promise<any> { public updateInvoicePayment(invoiceNumber: string, invoicePaymentId: string, data: any): Promise<any> {
@ -807,15 +807,15 @@ export class AstuteClientService {
console.log(response['entity']); console.log(response['entity']);
return response['entity']; return response['entity'];
} else if (message.includes('login')) { } else if (message.includes('login')) {
alert('Please login again!'); this.notif('Please login again!');
} else { } else {
alert('Get Customers Failed: ' + message); this.notif('Get Customers Failed: ' + message);
} }
}, (reason) => { }, (reason) => {
alert('Update Invoice Payment Failed: ' + reason); this.notif('Update Invoice Payment Failed: ' + reason);
}) })
.catch( error => { .catch( error => {
alert(error); this.notif(error);
}); });
} }
public addInvoicePayment(data: any): Promise<any> { public addInvoicePayment(data: any): Promise<any> {
@ -830,15 +830,15 @@ export class AstuteClientService {
console.log(response['entity']); console.log(response['entity']);
return response['entity']; return response['entity'];
} else if (message.includes('login')) { } else if (message.includes('login')) {
alert('Please login again!'); this.notif('Please login again!');
} else { } else {
alert('Get Customers Failed: ' + message); this.notif('Get Customers Failed: ' + message);
} }
}, (reason) => { }, (reason) => {
alert('Add Invoice Payment Failed: ' + reason); this.notif('Add Invoice Payment Failed: ' + reason);
}) })
.catch( error => { .catch( error => {
alert(error); this.notif(error);
}); });
} }
@ -855,15 +855,15 @@ export class AstuteClientService {
console.log(response['entity']); console.log(response['entity']);
return response['entity']; return response['entity'];
} else if (message.includes('login')) { } else if (message.includes('login')) {
alert('Please login again!'); this.notif('Please login again!');
} else { } else {
alert('Get Customers Failed: ' + message); this.notif('Get Customers Failed: ' + message);
} }
}, (reason) => { }, (reason) => {
alert('Get Service Types Failed: ' + reason); this.notif('Get Service Types Failed: ' + reason);
}) })
.catch( error => { .catch( error => {
alert(error); this.notif(error);
}); });
} }
public updateServiceType(serviceTypeId, data: any): Promise<any> { public updateServiceType(serviceTypeId, data: any): Promise<any> {
@ -879,15 +879,15 @@ export class AstuteClientService {
console.log(response['entity']); console.log(response['entity']);
return response['entity']; return response['entity'];
} else if (message.includes('login')) { } else if (message.includes('login')) {
alert('Please login again!'); this.notif('Please login again!');
} else { } else {
alert('Get Customers Failed: ' + message); this.notif('Get Customers Failed: ' + message);
} }
}, (reason) => { }, (reason) => {
alert('Update Service Type Failed: ' + reason); this.notif('Update Service Type Failed: ' + reason);
}) })
.catch( error => { .catch( error => {
alert(error); this.notif(error);
}); });
} }
public createServiceType(data: any): Promise<any> { public createServiceType(data: any): Promise<any> {
@ -902,15 +902,15 @@ export class AstuteClientService {
console.log(response['entity']); console.log(response['entity']);
return response['entity']; return response['entity'];
} else if (message.includes('login')) { } else if (message.includes('login')) {
alert('Please login again!'); this.notif('Please login again!');
} else { } else {
alert('Get Customers Failed: ' + message); this.notif('Get Customers Failed: ' + message);
} }
}, (reason) => { }, (reason) => {
alert('Create Service Type Failed: ' + reason); this.notif('Create Service Type Failed: ' + reason);
}) })
.catch( error => { .catch( error => {
alert(error); this.notif(error);
}); });
} }