This commit is contained in:
bitbucket 2023-09-22 11:01:27 +05:30
commit 10e3744f5d
36 changed files with 5684 additions and 33909 deletions

37655
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -54,7 +54,7 @@
"core-js": "2.5.1", "core-js": "2.5.1",
"echarts": "^4.9.0", "echarts": "^4.9.0",
"eva-icons": "^1.1.3", "eva-icons": "^1.1.3",
"firebase-admin": "^11.10.1", "file-saver": "^2.0.5",
"html2pdf.js": "^0.10.1", "html2pdf.js": "^0.10.1",
"intl": "1.2.5", "intl": "1.2.5",
"ionicons": "2.0.1", "ionicons": "2.0.1",
@ -80,6 +80,8 @@
"tslib": "^2.3.1", "tslib": "^2.3.1",
"typeface-exo": "0.0.22", "typeface-exo": "0.0.22",
"web-animations-js": "^2.3.2", "web-animations-js": "^2.3.2",
"ws": "^8.14.0",
"xlsx": "^0.18.5",
"zone.js": "~0.11.4" "zone.js": "~0.11.4"
}, },
"devDependencies": { "devDependencies": {
@ -95,10 +97,12 @@
"@compodoc/compodoc": "1.0.1", "@compodoc/compodoc": "1.0.1",
"@fortawesome/fontawesome-free": "^5.2.0", "@fortawesome/fontawesome-free": "^5.2.0",
"@types/d3-color": "1.0.5", "@types/d3-color": "1.0.5",
"@types/file-saver": "^2.0.5",
"@types/jasmine": "~3.3.0", "@types/jasmine": "~3.3.0",
"@types/jasminewd2": "2.0.3", "@types/jasminewd2": "2.0.3",
"@types/leaflet": "1.2.3", "@types/leaflet": "1.2.3",
"@types/node": "^12.12.70", "@types/node": "^12.12.70",
"@types/ws": "^8.5.5",
"@typescript-eslint/eslint-plugin": "^5.36.2", "@typescript-eslint/eslint-plugin": "^5.36.2",
"@typescript-eslint/parser": "^5.36.2", "@typescript-eslint/parser": "^5.36.2",
"codelyzer": "^6.0.2", "codelyzer": "^6.0.2",

View File

@ -0,0 +1,16 @@
import { TestBed } from '@angular/core/testing';
import { OrderDGuard } from './order-d.guard';
describe('OrderDGuard', () => {
let guard: OrderDGuard;
beforeEach(() => {
TestBed.configureTestingModule({});
guard = TestBed.inject(OrderDGuard);
});
it('should be created', () => {
expect(guard).toBeTruthy();
});
});

View File

@ -0,0 +1,38 @@
import { Injectable } from '@angular/core';
import { ActivatedRouteSnapshot, CanActivate, Router, RouterStateSnapshot, UrlTree } from '@angular/router';
import { Observable } from 'rxjs';
@Injectable({
providedIn: 'root'
})
export class OrderDGuard implements CanActivate {
constructor(private router: Router) {}
canActivate(): boolean {
// Implement your logic to decide whether to redirect or not.
// For example, you can check if a certain condition is met.
// const shouldRedirect = false
let shouldRedirect = localStorage.getItem('graud')
if (shouldRedirect == '1') {
console.log('shouldRedirect','In')
// Redirect to the desired route upon browser refresh
this.router.navigate(['/pages/order']);
return false; // Prevent navigation to the original route
}
console.log('shouldRedirect','out')
return true; // Allow navigation to the original route
// console.log('canActivate')
// // Add your logic here to determine if a refresh should redirect to another page
// let dd = localStorage.getItem('gruad')
// if(dd == '1'){
// console.log('dd')
// console.log('shouldRedirect')
// this.router.navigate(['../']); // Redirect to the desired page
// return false;
// }
// return true;
}
}

View File

@ -12,6 +12,10 @@ export class AuthService {
private apiUrl = environment.apiEndpoint; private apiUrl = environment.apiEndpoint;
constructor(private _http: HttpClient) { } constructor(private _http: HttpClient) { }
update_token(params): Observable<any> {
console.log(params.id)
return this._http.post<any>(this.apiUrl + "updateToken",params)
}
getLoginToken(params): Observable<any> { getLoginToken(params): Observable<any> {
console.log(params.email) console.log(params.email)
@ -21,7 +25,7 @@ export class AuthService {
getForgotToken(params): Observable<any> { getForgotToken(params): Observable<any> {
console.log(params.email) console.log(params.email)
return this._http.post<any>(this.apiUrl + "forget-password",{'email':params.email,'password':params.password}) return this._http.post<any>(this.apiUrl + "_api",{'email':params.email,'password':params.password})
} }

View File

@ -69,9 +69,13 @@ export class LoginComponent implements OnInit {
localStorage.setItem('email',JSON.stringify(auth)) localStorage.setItem('email',JSON.stringify(auth))
this.disable= true this.disable= true
this.showToast('success', 'Login Successfully', 'Welcome..!'); this.showToast('success', 'Login Successfully', 'Welcome..!');
setTimeout(() => {
if(res.role == 'FRONT-OFFICE'){
this.router.navigate(['/home']) this.router.navigate(['/home'])
}, 500); }else{
this.router.navigate(['/pages/dashboard'])
}
} }

View File

@ -96,6 +96,7 @@
<input formControlName="pincode" nbInput id="pincode" type="text" [status]="userForm.get('pincode').invalid && userForm.get('pincode').touched? 'danger' : 'basic'"> <input formControlName="pincode" nbInput id="pincode" type="text" [status]="userForm.get('pincode').invalid && userForm.get('pincode').touched? 'danger' : 'basic'">
<ng-container nbInputErrorMessage> <ng-container nbInputErrorMessage>
<div style="color:#7c0e0e" *ngIf="userForm.get('pincode').hasError('required') && userForm.get('pincode').touched">Pincode is required.</div> <div style="color:#7c0e0e" *ngIf="userForm.get('pincode').hasError('required') && userForm.get('pincode').touched">Pincode is required.</div>
<div style="color: #7c0e0e" *ngIf="userForm.get('pincode').hasError('pattern') && userForm.get('pincode').touched">Pincode must be a 6-digit number.</div>
</ng-container> </ng-container>
</nb-form-field> </nb-form-field>
</div> </div>

View File

@ -45,7 +45,10 @@ export class CustomerFormComponent implements OnInit {
address_1: new FormControl('', [Validators.required]), address_1: new FormControl('', [Validators.required]),
state: new FormControl('', [Validators.required]), state: new FormControl('', [Validators.required]),
city: new FormControl('', [Validators.required]), city: new FormControl('', [Validators.required]),
pincode: new FormControl('', [Validators.required]), pincode: new FormControl('', [
Validators.required,
Validators.pattern('^[0-9]{6}$'), // Allow only 6 digits
]),
cusType: new FormControl('', [Validators.required]), cusType: new FormControl('', [Validators.required]),
}); });

View File

@ -3,7 +3,7 @@
<div class="row show-grid"> <div class="row show-grid">
<div class="col-md-6"> <div class="col-md-5">
<div> <nb-icon icon="people-outline"></nb-icon> Customer Management</div> <div> <nb-icon icon="people-outline"></nb-icon> Customer Management</div>
</div> </div>
<div class="col-md-4"> <div class="col-md-4">
@ -15,7 +15,7 @@
</div> </div>
</div> </div>
<div class="col-md-2"> <div class="col-md-3">
<div style=" text-align: end;"> <div style=" text-align: end;">
<!-- <button (click)="Assign()" nbButton status="primary" hero> <!-- <button (click)="Assign()" nbButton status="primary" hero>
Assign Driver Assign Driver

View File

@ -0,0 +1,16 @@
import { TestBed } from '@angular/core/testing';
import { ExcelExportService } from './excel-export.service';
describe('ExcelExportService', () => {
let service: ExcelExportService;
beforeEach(() => {
TestBed.configureTestingModule({});
service = TestBed.inject(ExcelExportService);
});
it('should be created', () => {
expect(service).toBeTruthy();
});
});

View File

@ -0,0 +1,56 @@
import { Injectable } from '@angular/core';
import * as FileSaver from 'file-saver';
import * as XLSX from 'xlsx';
@Injectable({
providedIn: 'root'
})
export class ExcelExportService {
constructor() { }
fileType = 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=UTF-8';
fileExtension = '.xlsx';
public exportExcel(jsonData: any, fileName: string): void {
console.log(jsonData)
if(jsonData instanceof Array ){
const ws: XLSX.WorkSheet = XLSX.utils.json_to_sheet(jsonData);
const wb: XLSX.WorkBook = { Sheets: { 'data': ws }, SheetNames: ['data'] };
const excelBuffer: any = XLSX.write(wb, { bookType: 'xlsx', type: 'array' });
this.saveExcelFile(excelBuffer, fileName);
}else{
let wb = XLSX.utils.table_to_book(jsonData);
console.log(wb)
const excelBuffer: any = XLSX.write(wb, { bookType: 'xlsx', type: 'array' });
this.saveExcelFile(excelBuffer, fileName);
// XLSX.writeFile(wb, fileName + this.fileExtension);
}
/* table id is passed over here */
// console.log(jsonData, typeof(jsonData),jsonData.getElementsByTagName('mat-icon'))
// let temp = jsonData.getElementsByClassName('mat-icon')
// temp.innerHTML = ''
// console.log(temp)
// // jsonData.removeChild()
// const ws: XLSX.WorkSheet =XLSX.utils.table_to_sheet(jsonData);
// /* generate workbook and add the worksheet */
// const wb: XLSX.WorkBook = XLSX.utils.book_new();
// XLSX.utils.book_append_sheet(wb, ws, 'Sheet1');
// const excelBuffer: any = XLSX.write(wb, { bookType: 'xlsx', type: 'array' });
// this.saveExcelFile(excelBuffer, fileName);
// /* save to file */
// XLSX.writeFile(wb, this.fileName);
}
private saveExcelFile(buffer: any, fileName: string): void {
const data: Blob = new Blob([buffer], {type: this.fileType});
FileSaver.saveAs(data, fileName + this.fileExtension);
}
}

View File

@ -56,7 +56,7 @@
<div> <div>
<!-- <label for="subject" style=" font-weight: 600;">{{ fieldGroup.qty }}</label> --> <!-- <label for="subject" style=" font-weight: 600;">{{ fieldGroup.qty }}</label> -->
<input nbInput style="width: 50%;" [(ngModel)]="fieldGroup.qty" type="number"> <input nbInput style="width: 70%;" [(ngModel)]="fieldGroup.qty" type="number" min="1">
</div> </div>
</div> </div>

View File

@ -10,15 +10,13 @@
<div style="text-align: end;"> <div style="text-align: end;">
<button nbTooltip="Back" nbTooltipPlacement="top" (click)="back()" nbButton status="warning" hero> <button nbTooltip="Back" nbTooltipPlacement="top" (click)="back()" nbButton status="warning" hero>
<nb-icon icon="corner-down-left-outline"></nb-icon> <nb-icon icon="corner-down-left-outline"></nb-icon>
</button> </button>
<button nbTooltip="Edit" nbTooltipPlacement="top" *ngIf=" fieldTitle != 'Edit Order'" style=" margin-left: 2rem;" (click)="edit()" nbButton status="primary" hero> <button nbTooltip="Edit" nbTooltipPlacement="top" *ngIf=" fieldTitle != 'Edit Order' && this.selectStatus != 'Delivered' && addFormBtn != 0" style=" margin-left: 2rem;" (click)="edit()" nbButton status="primary" hero>
<nb-icon icon="edit-outline"></nb-icon> <nb-icon icon="edit-outline"></nb-icon>
</button> </button>
<button nbTooltip="Download" nbTooltipPlacement="top" style=" margin-left: 2rem;"(click)="generatePDF('download')" nbButton status="success" hero> <button nbTooltip="Download" nbTooltipPlacement="top" *ngIf=" fieldTitle != 'Edit Order' && addFormBtn != 0" style=" margin-left: 2rem;"(click)="generatePDF('download')" nbButton status="success" hero>
<nb-icon icon="download-outline"></nb-icon> <nb-icon icon="download-outline"></nb-icon>
</button> </button>
</div> </div>
@ -29,7 +27,7 @@
<nb-card-body> <nb-card-body>
<div class="row show-grid"> <div class="row show-grid">
<div class="col-6 col-md-4"> <div class="col-6 col-md-5">
<div> <div>
<label for="exampleInputEmail1" class="label">Customer</label> <br /> <label for="exampleInputEmail1" class="label">Customer</label> <br />
<span *ngIf="fieldTitle == 'View Order'">{{selectCustomer}}</span> <span *ngIf="fieldTitle == 'View Order'">{{selectCustomer}}</span>
@ -45,26 +43,26 @@
<hr> <hr>
<div style="font-size: larger;margin-top: 1rem;;margin-bottom: 1rem;"> Shipping Information</div> <div style="font-size: larger;margin-top: 1rem;;margin-bottom: 1rem;"> Shipping Information</div>
<div class="row show-grid" *ngIf="product.length>0"> <div class="row show-grid" *ngIf="product.length>0">
<div class="col-6 col-md-3"> <div class="col-6 col-md-4">
<div> <div>
<label for="subject" style=" font-weight: 500;">{{selectCustomerData['CusDetails.address_1']}} , {{selectCustomerData['CusDetails.city']}},<br />Contact No-({{selectCustomerData['CusDetails.phoneNo']}}) </label> <label for="subject" style=" font-weight: 500;">{{selectCustomerData['CusDetails.address_1']}} , {{selectCustomerData['CusDetails.city']}}, {{selectCustomerData['CusDetails.pincode']}}<br />Contact No-({{selectCustomerData['CusDetails.phoneNo']}}) </label>
</div> </div>
</div> </div>
<div class="col-6 col-md-2"> <!-- <div class="col-6 col-md-1">
<!-- <div> <div>
<label for="subject" style=" font-weight: 600;width: 30%;">Qty:</label> <label for="subject" style=" font-weight: 600;width: 30%;">Qty:</label>
</div> --> </div>
</div> </div>
<div class="col-6 col-md-4"> <div class="col-6 col-md-4">
<!-- <div> <div>
<label for="subject" style=" font-weight: 600;"></label> <label for="subject" style=" font-weight: 600;"></label>
</div> -->
</div> </div>
</div> -->
</div> </div>
<!-- <input type="text" nbInput fullWidth placeholder="Project">--> <!-- <input type="text" nbInput fullWidth placeholder="Project">-->
</div> </div>
</div> </div>
<div class="col-6 col-md-4"> <div class="col-6 col-md-3">
<div> <div>
<!-- <nb-select selected="DRIVER" > <!-- <nb-select selected="DRIVER" >
<nb-option value="DRIVER">DRIVER</nb-option> <nb-option value="DRIVER">DRIVER</nb-option>
@ -78,8 +76,8 @@
<p> {{setData.orderId}} </p> <br /> <p> {{setData.orderId}} </p> <br />
<div style="font-size: larger;font-weight: 600;"> Status</div> <div style="font-size: larger;font-weight: 600;"> Status</div>
<p style="text-transform: capitalize;" *ngIf="fieldTitle == 'View Order' " [ngStyle] = "{'color':setData.status =='ordered'?'#1f1dc9f5':setData.status =='Delivered' ?'green':'red' }" > ({{setData.status}}) </p> <p style="text-transform: capitalize;" *ngIf="fieldTitle == 'View Order' " [ngStyle] = "{'color':setData.status =='ordered'?'#1f1dc9f5':setData.status =='Delivered' ?'green':'red' }" > {{setData.status}} <br> <span *ngIf="setData.status == 'Delivered' || setData.status == 'Out For Delivery'" style="color: black;">({{setData['UserDetails.userName']}}) </span></p>
<nb-select selected="" *ngIf="fieldTitle != 'View Order' " placeholder="Change Status" clearable style="width: 57% !important;margin-top: 1rem;" [(ngModel)]="selectStatus" > <nb-select selected="" *ngIf="fieldTitle != 'View Order'" (ngModelChange)="onSelectChange($event)" placeholder="Change Status" clearable style="width: 57% !important;margin-top: 1rem;" [(ngModel)]="selectStatus" >
<!-- <nb-option value="">Change Status</nb-option> --> <!-- <nb-option value="">Change Status</nb-option> -->
<nb-option value="ordered" >Ordered</nb-option> <nb-option value="ordered" >Ordered</nb-option>
<nb-option value="In Progress" >In Progresss</nb-option> <nb-option value="In Progress" >In Progresss</nb-option>
@ -90,7 +88,7 @@
</nb-select> </nb-select>
<nb-select selected="" placeholder="Select Drivers" *ngIf="fieldTitle != 'View Order' && selectStatus == 'Out For Delivery'" [(ngModel)]="selectDriver" style="width: 57% !important;margin-right: 1rem;margin-top: 1rem;" > <nb-select (ngModelChange)="onSelectChange1($event)" selected="" placeholder="Select Drivers" *ngIf="fieldTitle != 'View Order' && selectStatus == 'Out For Delivery'" [(ngModel)]="selectDriver" style="width: 57% !important;margin-right: 1rem;margin-top: 1rem;" >
<!-- <nb-option value="">Select Drivers</nb-option> --> <!-- <nb-option value="">Select Drivers</nb-option> -->
<nb-option *ngFor="let user of drivers; index as i; first as isFirst " [value]="user.id <nb-option *ngFor="let user of drivers; index as i; first as isFirst " [value]="user.id
@ -99,7 +97,7 @@
</nb-select> </nb-select>
<input nbInput *ngIf="fieldTitle != 'View Order' && selectStatus == 'Cancelled'" [(ngModel)]="CancelReason" placeholder="Reason" style=" margin-right: 2%;margin-top: 1rem;" id="text"> <br /> <input nbInput *ngIf="fieldTitle != 'View Order' && selectStatus == 'Cancelled'" [(ngModel)]="CancelReason" placeholder="Reason" style=" margin-right: 2%;margin-top: 1rem;" id="text"> <br />
<button *ngIf="fieldTitle != 'View Order' " (click)="onSubmit2()" style="margin-top: 1rem;" type="submit" nbButton status="success" hero> <button *ngIf="fieldTitle != 'View Order'" [disabled]="hiddenBtn" (click)="onSubmit2()" style="margin-top: 1rem;" type="submit" nbButton status="success" hero>
Save Save
</button> </button>
<span *ngIf="setData.status =='Cancelled'">Reason: {{setData.reason}} </span> <span *ngIf="setData.status =='Cancelled'">Reason: {{setData.reason}} </span>
@ -147,6 +145,7 @@
<label for="subject" style=" font-weight: 600;"> </label> <label for="subject" style=" font-weight: 600;"> </label>
</div> </div>
</div> </div>
<nb-action icon="plus-circle-outline" class="custom-action-icon" [nbTooltip]="'Add'" (click)="addInputFieldGroup()" *ngIf="inputFieldGroups.length == 0"></nb-action>
</div> </div>
@ -161,11 +160,11 @@
<div class="row show-grid" *ngIf="product.length>0" > <div class="row show-grid" *ngIf="product.length>0" >
<div class="col-6 col-md-3"> <div class="col-6 col-md-3">
<div > <div >
<nb-select placeholder="Select Product" [(ngModel)]="fieldGroup.id" style="width: 100% !important;margin-right: 1rem;" > <nb-select placeholder="Select Product" [(ngModel)]="fieldGroup.id" style="width: 100% !important;margin-right: 1rem;" [disabled]="fieldTitle == 'Edit Order' ? !fieldGroup.isNew : false">
<!-- <nb-option value="">Select Drivers</nb-option> --> <!-- <nb-option value="">Select Drivers</nb-option> -->
<!-- (click)="onProductSelect(user.id,user.productName)" -->
<nb-option *ngFor="let user of product; index as i; first as isFirst " [value]="user.id <nb-option *ngFor="let user of checkProductArray(); index as i; first as isFirst" [value]="user.id"
">{{user.productName }}({{user.skuId }} )</nb-option> >{{user.productName }}({{user.skuId }} )</nb-option>
</nb-select> </nb-select>
@ -194,10 +193,11 @@
<nb-actions size="medium" *ngIf="fieldTitle != 'View Order'"> <nb-actions size="medium" *ngIf="fieldTitle != 'View Order'">
<nb-action icon="plus-circle-outline" class="custom-action-icon" [nbTooltip]="'Add'" (click)="addInputFieldGroup()"></nb-action> <nb-action icon="plus-circle-outline" class="custom-action-icon" [nbTooltip]="'Add'" (click)="addInputFieldGroup()"></nb-action>
<nb-action icon="minus-circle-outline" *ngIf="i !=0" [nbTooltip]="'Remove'" (click)="removeInputFieldGroup(i)"></nb-action> <nb-action icon="minus-circle-outline" [nbTooltip]="'Remove'" (click)="removeInputFieldGroup(i)"></nb-action>
</nb-actions> </nb-actions>
<!-- <button nbButton status="success" (click)="addInputFieldGroup()" style="margin-right: 1rem;"> Add </button> --> <!-- <button nbButton status="success" (click)="addInputFieldGroup()" style="margin-right: 1rem;"> Add </button> -->
<!-- <button nbButton status="danger" (click)="removeInputFieldGroup(i)">Remove</button> --> <!-- <button nbButton status="danger" *ngIf="i !=0" (click)="removeInputFieldGroup(i)">Remove</button> -->
</div> </div>
</div> </div>

View File

@ -56,20 +56,35 @@ fieldTitle:any =' New Order'
inputFieldGroups:any = [{id:'', qty: '1', productSpec: '' }]; inputFieldGroups:any = [{id:'', qty: '1', productSpec: '' }];
selectCustomerData :any =[];selectStatus:any =[];CancelReason:any =[];selectDriver:any =[];drivers:any =[]; selectCustomerData :any =[];selectStatus:any =[];CancelReason:any =[];selectDriver:any =[];drivers:any =[];
invoice = new Invoice(); invoice = new Invoice();
hiddenBtn= false;
delArr:any=[]
selectedProductId: number | undefined = null;
addFormBtn: any;
constructor(private dialogService: NbDialogService,private route :ActivatedRoute,private router: Router,public _api:PageapiService,private toastrService: NbToastrService,private service: SmartTableData ,private windowService: NbWindowService) { constructor(private dialogService: NbDialogService,private route :ActivatedRoute,private router: Router,public _api:PageapiService,private toastrService: NbToastrService,private service: SmartTableData ,private windowService: NbWindowService) {
this._api.orderDetails_observable$.subscribe((res) => { this._api.orderDetails_observable$.subscribe((res) => {
console.log('booked', res); console.log('booked', res);
if(res){ if(res){
this.addFormBtn = 1
this. setData = res this. setData = res
console.log(this.setData)
this.selectStatus = res.status this.selectStatus = res.status
console.log(this.selectStatus)
// res.name = res.productName // res.name = res.productName
// res.qty = parseInt(res.qty) // res.qty = parseInt(res.qty)
// res.price = this.setData['OrderDetails.CusDetails.cusType'] // res.price = this.setData['OrderDetails.CusDetails.cusType']
// this.invoice.additionalDetails = 'https://vnms.in/services/' // this.invoice.additionalDetails = 'https://vnms.in/services/'
// this.invoice.products.push(res) // this.invoice.products.push(res)
setTimeout(() => {
localStorage.setItem('graud','1')
}, 1300);
}else{
console.log('else')
this.addFormBtn = 0
localStorage.setItem('graud','0')
} }
}) })
@ -101,6 +116,8 @@ fieldTitle:any =' New Order'
console.log(p) console.log(p)
} }
ngOnInit() { ngOnInit() {
this.getDriverlistApi() this.getDriverlistApi()
console.log(this.setData) console.log(this.setData)
if(this.setData != undefined){ if(this.setData != undefined){
@ -133,7 +150,7 @@ fieldTitle:any =' New Order'
let passData = res.data let passData = res.data
let customer = passData.filter(arr=>{return arr.role == 'CUSTOMER'}) let customer = passData.filter(arr=>{return arr.role == 'CUSTOMER' && arr.isActive == 1})
customer.forEach((element:any, index) => { customer.forEach((element:any, index) => {
element.index = index +1 element.index = index +1
@ -145,7 +162,7 @@ fieldTitle:any =' New Order'
localStorage.setItem('driverId',this.setData.driverId) localStorage.setItem('driverId',this.setData.driverId)
this.selectCustomer = this.setData['OrderDetails.CusDetails.cusName'] this.selectCustomer = this.setData['OrderDetails.CusDetails.cusName']
this.invoice.customerName = this.selectCustomer this.invoice.customerName = this.selectCustomer
this.invoice.address = this.setData['OrderDetails.CusDetails.address_1'] this.invoice.address = ""+this.setData['OrderDetails.CusDetails.address_1']+","+this.setData['OrderDetails.CusDetails.city']+"-"+this.setData['OrderDetails.CusDetails.pincode']+""
this.invoice.email = this.setData['OrderDetails.CusDetails.email'] this.invoice.email = this.setData['OrderDetails.CusDetails.email']
this.invoice.contactNo = this.setData['OrderDetails.CusDetails.phoneNo'] this.invoice.contactNo = this.setData['OrderDetails.CusDetails.phoneNo']
@ -176,14 +193,32 @@ fieldTitle:any =' New Order'
} }
getProductlistApi(param){ getProductlistApi(param){
let data ={type : param} console.log(this.fieldTitle, param)
let data
if(this.fieldTitle != 'New Order'){
data ={}
}else {
data ={type : param}
}
console.log(data)
this.getProductlistApi2(param) this.getProductlistApi2(param)
this._api.getProducts(data).subscribe(res => { this._api.getProducts(data).subscribe(res => {
console.log(res) console.log(res)
if(res.status == 200){ if(res.status == 200){
let passData = res.data let passData = res.data
let product = passData let product
if(this.fieldTitle != 'New Order'){
let UniqueProducts = this.getUniqueProducts(passData, 'productName');
let filteredProducts = UniqueProducts.filter(product => product.productCategory === param);
product = filteredProducts
} else{
product = passData
}
console.log(product) console.log(product)
product.forEach((element:any, index) => { product.forEach((element:any, index) => {
element.index = index +1 element.index = index +1
@ -193,6 +228,8 @@ console.log(product)
}); });
this.product = product this.product = product
console.log(this.product)
// this.productfull = product // this.productfull = product
if(this.setData != undefined){ if(this.setData != undefined){
if( Object.keys(this.setData).length != 0){ if( Object.keys(this.setData).length != 0){
@ -214,6 +251,22 @@ console.log(product)
} }
getUniqueProducts(products: any[], propertyName: string): any[] {
const uniqueProducts = [];
const seen = new Set();
for (const product of products) {
const value = product[propertyName];
if (!seen.has(value)) {
seen.add(value);
uniqueProducts.push(product);
}
}
return uniqueProducts;
}
getProductlistApi2(param){ getProductlistApi2(param){
let data ={type : param} let data ={type : param}
this._api.getProducts(data).subscribe(res => { this._api.getProducts(data).subscribe(res => {
@ -312,14 +365,35 @@ console.log(product)
} }
} }
// onProductSelect(event: any,prod:any) {
// if(prod != 'Mixed Gas')
// {
// // this.selectedProductId = event;
// this.product = this.product.filter((item) => item.id !== event);
// }
// }
onProductSelect(selectedProductId: number) {
// Find the selected product index
const selectedIndex = this.product.findIndex(product => product.id === selectedProductId);
if (selectedIndex !== -1) {
// Remove the selected product from the array
this.product.splice(selectedIndex, 1);
}
}
saveNew(){ saveNew(){
let data = { 'id' : this.delArr}
this._api.delOrder(data).subscribe(res => { console.log( "success");
})
console.log(this.selectCustomer,this.inputFieldGroups, this.product) console.log(this.selectCustomer,this.inputFieldGroups, this.product)
this.inputFieldGroups.forEach((element:any) => { this.inputFieldGroups.forEach((element:any) => {
delete element.isNew;
this.product.forEach(e => { this.product.forEach(e => {
@ -361,7 +435,15 @@ this.invoice.products =[];
// }); // });
// } // }
// } // }
// let mixedProductGas = this.inputFieldGroups.filter((arr:any)=>{return arr.name == 'Mixed Gas'})
// console.log(mixedProductGas)
const filteredItems = this.inputFieldGroups.filter(item => item.name === 'Mixed Gas' && item.productSpec === '');
console.log(filteredItems)
if (filteredItems.length > 0) {
this.showToast('warning', 'Please Fill Mixed Gas Fields...!', '');
return;
} else{
const buttonsConfig: NbWindowControlButtonsConfig = { const buttonsConfig: NbWindowControlButtonsConfig = {
minimize: this.minimize, minimize: this.minimize,
@ -377,8 +459,14 @@ this.invoice.products =[];
let results = [ ...this.mixedGas, ...mixProd]; let results = [ ...this.mixedGas, ...mixProd];
console.log(results)
if(results.length>0){ const filteredItems = results.filter(item => !item.hasOwnProperty('name'));
console.log(filteredItems)
if(results.length>0 && filteredItems.length == 0){
@ -406,6 +494,10 @@ this.invoice.products =[];
}else{ }else{
this.showToast('warning', 'Please Fill Request Fields...!', ''); this.showToast('warning', 'Please Fill Request Fields...!', '');
} }
}
} }
private showToast(type: NbComponentStatus, title: string, body: string) { private showToast(type: NbComponentStatus, title: string, body: string) {
const config = { const config = {
@ -431,35 +523,22 @@ this.invoice.products =[];
generatePDF(action = 'open') { generatePDF(action = 'open') {
console.log(this.setData)
this.inputFieldGroups.forEach((element:any) => { this.inputFieldGroups.forEach((element:any) => {
this.productfull.forEach(e => { this.productfull.forEach(e => {
if(e.id === element.id){ if(e.id === element.id){
element.name = e.productName +"-("+e.skuId+")" element.name = e.productName +"-("+e.skuId+")"
} }
}); });
}); });
console.log( this.inputFieldGroups ) console.log( this.inputFieldGroups )
this.invoice.products =[]; this.invoice.products =[];
this.inputFieldGroups.forEach((res:any) => { this.inputFieldGroups.forEach((res:any) => {
res.name = res.name res.name = res.name
res.qty = parseInt(res.qty) res.qty = parseInt(res.qty)
res.price = this.setData['OrderDetails.CusDetails.cusType'] res.price = this.setData['OrderDetails.CusDetails.cusType']
this.invoice.additionalDetails = 'https://vnms.in/services/' this.invoice.additionalDetails = 'https://vnms.in/services/'
this.invoice.products.push(res) this.invoice.products.push(res)
}) })
this.invoice.products = this.invoice.products.filter(arr=>{return arr.qty != 0}) this.invoice.products = this.invoice.products.filter(arr=>{return arr.qty != 0})
let docDefinition = { let docDefinition = {
@ -505,7 +584,7 @@ this.invoice.products =[];
alignment: 'right' alignment: 'right'
}, },
{ {
text: `Date: ${new Date(this.setData.createdAt).toLocaleString()}`, text: `Date: ${new Date(this.setData.createdAt).toLocaleDateString('en-GB')}, ${new Date(this.setData.createdAt).toLocaleTimeString('en-US', { hour: '2-digit', minute: '2-digit', hour12: true })}`,
alignment: 'right' alignment: 'right'
}, },
{ {
@ -577,7 +656,7 @@ this.invoice.products =[];
}; };
if(action==='download'){ if(action==='download'){
console.log(this.selectCustomer , this.setData.orderId)
let name= this.selectCustomer+"-"+this.setData.orderId let name= this.selectCustomer+"-"+this.setData.orderId
pdfMake.createPdf(docDefinition).download(name); pdfMake.createPdf(docDefinition).download(name);
@ -697,15 +776,16 @@ edit(){
} }
cancelData(){ cancelData(){
localStorage.setItem('viewOrder','1') this.router.navigate(['../'], { relativeTo: this.route });
let result = localStorage.getItem('viewOrder') // localStorage.setItem('viewOrder','1')
if(result == '1'){ // let result = localStorage.getItem('viewOrder')
this.fieldTitle = 'View Order' // if(result == '1'){
this._api.orderDetails.next( this. setData) // this.fieldTitle = 'View Order'
}else{ // this._api.orderDetails.next( this.setData)
this.fieldTitle = 'Edit Order' // }else{
} // this.fieldTitle = 'Edit Order'
console.log(this.fieldTitle) // }
// console.log(this.fieldTitle)
} }
getDriverlistApi(){ getDriverlistApi(){
@ -736,6 +816,29 @@ getDriverlistApi(){
}) })
} }
onSelectChange(newValue: string) {
// Handle the selected value change here
this.selectDriver = []
console.log(newValue);
if(newValue == 'Out For Delivery'){
this.hiddenBtn = true;
}
else{
this.hiddenBtn = false;
}
}
onSelectChange1(newValue: string) {
// Handle the selected value change here
console.log(newValue);
if(!newValue){
this.hiddenBtn = true;
}
else{
this.hiddenBtn = false;
}
}
onSubmit2(){ onSubmit2(){
@ -802,15 +905,55 @@ this.onCreateConfirm()
// } // }
// }) // })
}
checkProductArray() {
console.log(this.inputFieldGroups)
const hasNullId = this.inputFieldGroups.some((group) => group.id === null);
console.log(hasNullId)
if (!hasNullId) {
// There's an object with id = null in the inputFieldGroups array
console.log('There is an object with id = null');
return this.product;
} else {
// There is no object with id = null in the inputFieldGroups array
// Filter products based on the condition (productName !== 'Mixed Gas' in inputFieldGroups)
const filteredProducts = this.product.filter((product) => {
const isSelected = this.inputFieldGroups.some((group) => group.id === product.id);
return product.productName === 'Mixed Gas' || !isSelected;
});
return filteredProducts;
}
} }
addInputFieldGroup() { addInputFieldGroup() {
this.inputFieldGroups.push({id:null, qty: '0', productSpec: '' }); // Add a new input field group to the array if(this.fieldTitle != 'New Order'){
console.log(this.product)
let activeProductList = this.product.filter(item => item.isActive == '1')
console.log(activeProductList)
this.product = activeProductList
}
// this.inputFieldGroups.push({id:null, qty: '1', productSpec: '' });
// Add a new input field group to the array
const newGroup = { id: null, qty: 1, productSpec: '', isNew: true };
this.inputFieldGroups.push(newGroup);
//this.childButtonEvent.emit( this.inputFieldGroups); //this.childButtonEvent.emit( this.inputFieldGroups);
} }
removeInputFieldGroup(index: number) { isReadOnly(param,index: number) {
console.log(this.inputFieldGroups) console.log(this.inputFieldGroups)
console.log(param,index)
// You can add your condition here to determine if the option should be readonly.
// For example, if you want to make options at index 2 and 3 readonly:
// return index === 2 || index === 3;
}
removeInputFieldGroup(index: number) {
console.log( this.inputFieldGroups[index].primaryId)
this.delArr.push(this.inputFieldGroups[index].primaryId)
this.inputFieldGroups.splice(index, 1); // Remove the input field group at the specified index this.inputFieldGroups.splice(index, 1); // Remove the input field group at the specified index
//this.childButtonEvent.emit( this.inputFieldGroups); //this.childButtonEvent.emit( this.inputFieldGroups);
} }
@ -870,4 +1013,20 @@ onCreateConfirm() {
}); });
} }
// getProduct(param){
// console.log(param)
// if(param == 'Others'){
// this.mixedBTN = true
// }else{
// this.mixedBTN = false
// }
// }
// isProductSpecValid(): boolean {
// console.log(this.inputFieldGroups )
// return !!this.inputFieldGroups.find((fieldGroup) => fieldGroup.productSpec);
// }
} }

View File

@ -70,7 +70,7 @@
<div class="col-6"> <div class="col-6">
<div> <div>
<button nbButton status="success" (click)="save()" type="submit" >Confirm</button> <button nbButton status="success" (click)="save()" type="submit" [disabled]="submitBtn">Confirm</button>
</div> </div>
</div> </div>
</div> </div>

View File

@ -11,6 +11,7 @@ export class OrderSummaryFormComponent implements OnInit {
customer:any =[]; customer:any =[];
product:any =[]; product:any =[];
setData:any =[]; setData:any =[];
submitBtn: boolean= false;
constructor(@Inject(NB_WINDOW_CONTEXT) public data: any,public _api:PageapiService,private windowService: NbWindowService, private windowRef: NbWindowRef) { constructor(@Inject(NB_WINDOW_CONTEXT) public data: any,public _api:PageapiService,private windowService: NbWindowService, private windowRef: NbWindowRef) {
console.log(this.data) console.log(this.data)
@ -38,6 +39,7 @@ export class OrderSummaryFormComponent implements OnInit {
} }
save(){ save(){
this.submitBtn = true
console.log(this.data,this.setData) console.log(this.data,this.setData)
let cus = this.data.customerData['CusDetails.id'] let cus = this.data.customerData['CusDetails.id']
let role = localStorage.getItem('user_role') let role = localStorage.getItem('user_role')
@ -45,6 +47,8 @@ export class OrderSummaryFormComponent implements OnInit {
element.productName = element.name element.productName = element.name
if(element.hasOwnProperty('primaryId')){ if(element.hasOwnProperty('primaryId')){
element.productId = element.id
element.id = element.primaryId element.id = element.primaryId
}else{ }else{
element.pid = element.id element.pid = element.id

View File

@ -50,7 +50,7 @@
<nb-icon icon="plus-circle-outline"></nb-icon> <nb-icon icon="plus-circle-outline"></nb-icon>
</button> </button>
<button style=" margin-left: 1rem;" nbButton nbTooltip="Download" nbTooltipPlacement="top" (click)="download()" nbButton status="success" hero> <button style=" margin-left: 1rem;" nbButton nbTooltip="Download" nbTooltipPlacement="top" (click)="exportExcelData()" nbButton status="success" hero>
<nb-icon icon="download-outline"></nb-icon> <nb-icon icon="download-outline"></nb-icon>
</button> </button>
</div> </div>
@ -62,7 +62,6 @@
<!-- <ng2-smart-table [settings]="settings" (userRowSelect)="onUserRowSelect($event)" [source]="source" (edit)="onSaveConfirm($event)" <!-- <ng2-smart-table [settings]="settings" (userRowSelect)="onUserRowSelect($event)" [source]="source" (edit)="onSaveConfirm($event)"
(create)="onCreateConfirm($event)" (delete)="onDeleteConfirm($event)"> (create)="onCreateConfirm($event)" (delete)="onDeleteConfirm($event)">
</ng2-smart-table> --> </ng2-smart-table> -->
<ng-data-table <ng-data-table
[id]="'i'" [id]="'i'"
[items]=orders [items]=orders
@ -224,7 +223,7 @@
</span> </span>
<span [ngStyle] = "{'color':row.item.status =='ordered'?'#1f1dc9f5':row.item.status =='Delivered' ?'green':'red' }" class="checkTxt" *ngIf="row.item.status !='Out For Delivery'" > <span [ngStyle] = "{'color':row.item.status =='ordered'?'#1f1dc9f5':row.item.status =='Delivered' ?'green':'red' }" class="checkTxt" *ngIf="row.item.status !='Out For Delivery'" >
{{row.item.status}} {{row.item.status}} <p class="checkTxt" *ngIf="row.item.status == 'Delivered'">({{row.item['UserDetails.userName']}})</p>
</span> </span>
</div> </div>
@ -273,6 +272,7 @@
</ng-data-table> </ng-data-table>
</nb-card-body> </nb-card-body>
@ -294,7 +294,7 @@
<nb-option value="Out For Delivery" >Out For Delivery</nb-option> <nb-option value="Out For Delivery" >Out For Delivery</nb-option>
<!-- <nb-option value="Delivered" >Delivered</nb-option> --> <!-- <nb-option value="Delivered" >Delivered</nb-option> -->
<nb-option value="Cancelled" >Cancelled</nb-option> <!-- <nb-option value="Cancelled" >Cancelled</nb-option> -->
</nb-select> </nb-select>
<!-- <label for="subject">Drivers:</label> <br /> --> <!-- <label for="subject">Drivers:</label> <br /> -->
@ -333,4 +333,123 @@
<!-- </form> --> <!-- </form> -->
</nb-card-footer> </nb-card-footer>
<div id="orderExcel" hidden>
<ng-data-table
[id]="'i'"
[items]=orders
[minContentWidth]="600"
[showColumnSelector]="true"
[showHeader]="false"
>
<ng-data-table-column
[field]="'index'"
[sortable]="false"
[title]="'ID'"
[filterable]="false"
[width]="2">
</ng-data-table-column>
<ng-data-table-column
[field]="'orderId'"
[sortable]="false"
[title]="'Order ID'"
[filterable]="false"
[width]="4">
<ng-template #ngDataTableCell let-row="row">
<td (click)="onViewConfirm(row.item)">
<div style="display: flex; align-items: center;">
<span class="checkTxt" >
{{row.item.orderId }}
</span>
</div>
</td>
</ng-template>
</ng-data-table-column>
<ng-data-table-column
[field]="'customer'"
[sortable]="false"
[title]="'Customer Name'"
[filterable]="false"
[width]="4">
<ng-template #ngDataTableCell let-row="row">
<td (click)="onViewConfirm(row.item)">
<div style="display: flex; align-items: center;">
<span class="checkTxt" >
{{row.item.customer }}
</span>
</div>
</td>
</ng-template>
</ng-data-table-column>
<ng-data-table-column
[field]="'address'"
[sortable]="false"
[title]="'Address'"
[filterable]="false"
[width]="6">
<ng-template #ngDataTableCell let-row="row">
<td (click)="onViewConfirm(row.item)">
<div style="display: flex; align-items: center;">
<span class="checkTxt" >
{{row.item.address }}
</span>
</div>
</td>
</ng-template>
</ng-data-table-column>
<ng-data-table-column
[field]="'orderDate'"
[sortable]="false"
[title]="'Order Date'"
[filterable]="false"
[width]="4">
<ng-template #ngDataTableCell let-row="row">
<td (click)="onViewConfirm(row.item)">
<div style="display: flex; align-items: center;">
<span class="checkTxt" >
{{row.item.updatedAt | date :'dd/MM/yy hh:mm:ss'}}
</span>
</div>
</td>
</ng-template>
</ng-data-table-column>
<ng-data-table-column
[field]="'status'"
[title]="'Status'"
[sortable]="false"
[width]="5">
<ng-template #ngDataTableCell let-row="row">
<td (click)="onViewConfirm(row.item)">
<div style="display: flex; align-items: center;">
<span [ngStyle] = "{'color':row.item.status =='Out For Delivery'?'blue':'' }" class="checkTxt" *ngIf="row.item.status =='Out For Delivery'" >
{{row.item.status}} <p class="checkTxt" >({{row.item['UserDetails.userName']}}) <nb-icon icon="done-all-outline" style="color:#08d992" [nbTooltip]="'Driver seen at ' + (row.item.seenTime | date:'dd/MM/yyyy, h:mm a')" *ngIf="row.item.seenStatus == 1" ></nb-icon>
<nb-icon icon="done-all-outline" nbTooltip="Not Seen" style="color: rgb(159, 167, 170);" *ngIf="row.item.seenStatus == 0" ></nb-icon> </p>
</span>
<span [ngStyle] = "{'color':row.item.status =='ordered'?'#1f1dc9f5':row.item.status =='Delivered' ?'green':'red' }" class="checkTxt" *ngIf="row.item.status !='Out For Delivery'" >
{{row.item.status}} <p class="checkTxt" *ngIf="row.item.status == 'Delivered'">({{row.item['UserDetails.userName']}})</p>
</span>
</div>
</td>
</ng-template>
</ng-data-table-column>
</ng-data-table>
</div>
</nb-card> </nb-card>

File diff suppressed because one or more lines are too long

View File

@ -112,17 +112,27 @@ public mixDetails_observable$ = this.mixDetails.asObservable();
} }
delOrder(addParams): Observable<any> {
return this._http.post(this.apiUrl + 'delOrderCatogary', addParams)
}
getProductList(addParams): Observable<any> { getProductList(addParams): Observable<any> {
return this._http.post(this.apiUrl + 'getProductList', addParams) return this._http.post(this.apiUrl + 'getProductList', addParams)
} }
getProductDropdownList(addParams): Observable<any> {
return this._http.post(this.apiUrl + 'getProductDropdownList', addParams)
}
CreateReturn(addParams:any): Observable<any> { CreateReturn(addParams:any): Observable<any> {
return this._http.post(this.apiUrl + 'CreateReturn', addParams) return this._http.post(this.apiUrl + 'CreateReturn', addParams)
} }
notification(addParams:any): Observable<any> { Notification(addParams:any): Observable<any> {
return this._http.post(this.apiUrl + 'sendNotification', addParams) return this._http.post(this.apiUrl + 'sendNotification', addParams)
} }

View File

@ -16,6 +16,7 @@ import { SummaryDetailsComponent } from './summary-list/summary-details/summary-
import { EmailComponent } from './email/email.component'; import { EmailComponent } from './email/email.component';
import { DriverySheetComponent } from './drivery-sheet/drivery-sheet.component'; import { DriverySheetComponent } from './drivery-sheet/drivery-sheet.component';
import { ReturnSheetComponent } from './return-sheet/return-sheet.component'; import { ReturnSheetComponent } from './return-sheet/return-sheet.component';
import { OrderDGuard } from './_guard/order-d.guard';
const routes: Routes = [{ const routes: Routes = [{
path: '', path: '',
@ -59,6 +60,7 @@ const routes: Routes = [{
{ {
path: 'order/add', path: 'order/add',
component: OrderFormComponent, component: OrderFormComponent,
canActivate: [OrderDGuard]
},{ },{
path: 'summary', path: 'summary',
component:SummaryListComponent component:SummaryListComponent

View File

@ -19,22 +19,16 @@ export class PagesComponent {
menu = MENU_ITEMS; menu = MENU_ITEMS;
constructor(private router: Router){ constructor(private router: Router){}
let role = localStorage.getItem('user_role')
console.log(role)
if(role == "FRONT-OFFICE"){ ngOnInit() {
this.menu = this.menu.filter(arr=>{return arr.title != 'Users'}) const role = localStorage.getItem('user_role');
console.log(role);
if (role === 'FRONT-OFFICE') {
this.menu = this.menu.filter((item) => item.title !== 'Users');
} }
console.log(this.menu);
console.log(this.menu)
this.router.navigate(['/pages/dashboard']);
} }
} }

View File

@ -46,7 +46,7 @@
<ng-container nbInputErrorMessage> <ng-container nbInputErrorMessage>
<div style="color:#7c0e0e" *ngIf="userForm.get('skuId').hasError('required') && userForm.get('description').touched">skuId is required.</div> <div style="color:#7c0e0e" *ngIf="userForm.get('skuId').hasError('required') && userForm.get('description').touched">skuId is required.</div>
<div style="color:#7c0e0e" *ngIf="userForm.get('skuId').errors?.usernameTaken && userForm.get('skuId').dirty">skuId already exists...</div>
</ng-container> </ng-container>
<nb-card-footer> <nb-card-footer>
<button type="button" class="cancel" nbButton status="danger" (click)="cancel()">Cancel</button> <button type="button" class="cancel" nbButton status="danger" (click)="cancel()">Cancel</button>

View File

@ -2,6 +2,9 @@ import { Component, Inject, OnInit } from '@angular/core';
import { FormControl, FormGroup, Validators } from '@angular/forms'; import { FormControl, FormGroup, Validators } from '@angular/forms';
import { PageapiService } from '../../pageapi.service'; import { PageapiService } from '../../pageapi.service';
import { NbWindowService ,NbWindowRef, NB_WINDOW_CONTEXT } from '@nebular/theme'; import { NbWindowService ,NbWindowRef, NB_WINDOW_CONTEXT } from '@nebular/theme';
import { map } from 'rxjs/internal/operators/map';
import { HttpClient } from '@angular/common/http';
import { environment } from '../../../../environments/environment.prod';
@Component({ @Component({
selector: 'ngx-product-form', selector: 'ngx-product-form',
@ -10,23 +13,24 @@ import { NbWindowService ,NbWindowRef, NB_WINDOW_CONTEXT } from '@nebular/theme'
}) })
export class ProductFormComponent implements OnInit { export class ProductFormComponent implements OnInit {
userForm: FormGroup | any; formData:any =[] userForm: FormGroup | any; formData:any =[]
constructor(@Inject(NB_WINDOW_CONTEXT) public data: any,public _api:PageapiService,private windowService: NbWindowService, private windowRef: NbWindowRef) { action: any;
private apiUrl = environment.apiEndpoint;
constructor(private http: HttpClient,@Inject(NB_WINDOW_CONTEXT) public data: any,public _api:PageapiService,private windowService: NbWindowService, private windowRef: NbWindowRef) {
console.log(this.data) console.log(this.data)
this.action = this.data.action;
console.log(this.action)
} }
ngOnInit(): void { ngOnInit(): void {
let valData = [this.validateUsernameAvailability.bind(this)]
this.userForm = new FormGroup({ this.userForm = new FormGroup({
productCategory: new FormControl('', [Validators.required]), productCategory: new FormControl('', [Validators.required]),
productType: new FormControl('', [Validators.required]), productType: new FormControl('', [Validators.required]),
productName: new FormControl('', [Validators.required]), productName: new FormControl('', [Validators.required]),
description:new FormControl('', [Validators.required]), description:new FormControl('', [Validators.required]),
skuId:new FormControl('', [Validators.required]), skuId:new FormControl('', [Validators.required],valData),
}); });
if(this.data.hasOwnProperty('id')){ if(this.data.hasOwnProperty('id')){
@ -36,6 +40,41 @@ export class ProductFormComponent implements OnInit {
this.userForm.patchValue(this.data) this.userForm.patchValue(this.data)
} }
validateUsernameAvailability(control: FormControl) {
let param ={}
return this.http.post<any[]>(this.apiUrl+ "getProducts",param)
.pipe(
map((response:any) => {
console.log('edit',response)
let productData
if(this.action == 'Add'){
console.log('add')
productData = response.data
}else{
console.log('edit',this.data.skuId)
let listData = response.data
const newArray = listData.filter(item => item.skuId !== this.data.skuId);
console.log(newArray)
productData = newArray
}
console.log(productData)
let response1 = productData
let tmp=[];
if(response1 instanceof Array){
productData.forEach(element => {
tmp.push(element.skuId)
});
console.log(tmp,`${control.value}`);
return !tmp.includes(`${control.value}`) ? null : { usernameTaken: true };
}else{
return null
}
})
);
}
cancel(){ cancel(){
this.windowService this.windowService
console.log( this.windowService) console.log( this.windowService)

View File

@ -138,7 +138,9 @@ export class ProductComponent {
width: '500px', width: '500px',
height: '300px', height: '300px',
} }
const windowRef: NbWindowRef = this.windowService.open(ProductFormComponent, { title: `New Product`, buttons: buttonsConfig , }); let data:any = {action:'Add'}
const windowRef: NbWindowRef = this.windowService.open(ProductFormComponent, { title: `New Product`, buttons: buttonsConfig ,context: data });
// Subscribe to the afterClosed event // Subscribe to the afterClosed event
windowRef.onClose.subscribe((data) => { windowRef.onClose.subscribe((data) => {
@ -157,7 +159,7 @@ export class ProductComponent {
onSaveConfirm(event) { onSaveConfirm(event) {
console.log("Edit Event In Console") console.log("Edit Event In Console")
console.log(event); console.log(event);
// event = {action:'Edit'}
const buttonsConfig: NbWindowControlButtonsConfig = { const buttonsConfig: NbWindowControlButtonsConfig = {
minimize: this.minimize, minimize: this.minimize,
maximize: this.maximize, maximize: this.maximize,

View File

@ -1,5 +1,5 @@
<nb-card> <nb-card style="width: 55rem;height: 30rem;">
<nb-card-header> <!-- <nb-card-header>
<div class="row show-grid"> <div class="row show-grid">
@ -12,13 +12,13 @@
Back Back
</button> </button>
<!-- <button style=" margin-left: 2rem;"(click)="generatePDF('print')" nbButton status="primary" hero> <button style=" margin-left: 2rem;"(click)="generatePDF('print')" nbButton status="primary" hero>
Print Print
</button> --> </button>
</div> </div>
</div> </div>
</div> </div>
</nb-card-header> </nb-card-header> -->
<nb-card-header> <nb-card-header>

View File

@ -169,4 +169,3 @@ color: red !important;
::ng-deep .md-drppicker.double { ::ng-deep .md-drppicker.double {
width: 640px !important; width: 640px !important;
} }

View File

@ -1,7 +1,8 @@
import { Component, OnInit } from '@angular/core'; import { Component, Inject, OnInit } from '@angular/core';
import * as moment from 'moment'; import * as moment from 'moment';
import { PageapiService } from '../../pageapi.service'; import { PageapiService } from '../../pageapi.service';
import { ActivatedRoute, Router } from '@angular/router'; import { ActivatedRoute, Router } from '@angular/router';
import { NB_WINDOW_CONTEXT } from '@nebular/theme';
@Component({ @Component({
selector: 'ngx-summary-details', selector: 'ngx-summary-details',
templateUrl: './summary-details.component.html', templateUrl: './summary-details.component.html',
@ -22,12 +23,13 @@ export class SummaryDetailsComponent implements OnInit {
}; };
productlistReturn:any =[];orderId:any=[];cusName:any =[]; productlistReturn:any =[];orderId:any=[];cusName:any =[];
selectedDateRange:any =[];drivers:any =[];summaryaData:any=[];driverval:any=[];returnSummary:any =[];productlist:any=[]; selectedDateRange:any =[];drivers:any =[];summaryaData:any=[];driverval:any=[];returnSummary:any =[];productlist:any=[];
constructor(public _api:PageapiService,private route: ActivatedRoute, private router:Router) { constructor(@Inject(NB_WINDOW_CONTEXT) public data: any,public _api:PageapiService,private route: ActivatedRoute, private router:Router) {
console.log(data)
this.route.params.subscribe(params => { // this.route.params.subscribe(params => {
console.log(params) //log the entire params object console.log(data) //log the entire params object
console.log(params['orderId']) //log the value of id console.log(data.orderID) //log the value of id
let orderId = params['orderId'] let orderId = data.orderID
this.orderId = orderId this.orderId = orderId
this._api.getProductListSummary({orderId:orderId}).subscribe(res => { this._api.getProductListSummary({orderId:orderId}).subscribe(res => {
console.log(res) console.log(res)
@ -52,7 +54,7 @@ this.orderId = orderId
}) })
}); // });
} }
@ -67,6 +69,7 @@ this.orderId = orderId
back(){ back(){
// let data = { 'date' : localStorage.getItem('dDate') , 'id' : localStorage.getItem('dId') }
this.router.navigate(['/pages/summary']) this.router.navigate(['/pages/summary'])
} }
save(){ save(){

View File

@ -26,6 +26,7 @@
<div class="row show-grid"> <div class="row show-grid">
<div class="col-md-12"> <div class="col-md-12">
<div> <div>
<!-- [(ngModel)]="dDate" -->
<input nbInput placeholder="Pick Date" [nbDatepicker]="dateTimePicker" > <input nbInput placeholder="Pick Date" [nbDatepicker]="dateTimePicker" >
<nb-datepicker #dateTimePicker (dateChange)="onStartDateChanged($event)" ></nb-datepicker> <nb-datepicker #dateTimePicker (dateChange)="onStartDateChanged($event)" ></nb-datepicker>
<!-- <input nbInput class="fx-date-range" type="text" <!-- <input nbInput class="fx-date-range" type="text"
@ -45,7 +46,7 @@
name="daterange" placeholder="Fliter Date Wise" (change)="dateWiseFilter()"/> --> name="daterange" placeholder="Fliter Date Wise" (change)="dateWiseFilter()"/> -->
<nb-select selected="" style="width: 100% !important;margin-left: 2rem;" > <nb-select selected="" style="width: 100% !important;margin-left: 2rem;" >
<nb-option value="">Select Drivers</nb-option> <nb-option value="">Select Drivers</nb-option>
<!-- [(ngModel)]="dId" -->
<nb-option *ngFor="let user of drivers; index as i; first as isFirst " (click)="val(user)" [value]="user.id <nb-option *ngFor="let user of drivers; index as i; first as isFirst " (click)="val(user)" [value]="user.id
">{{user.userName }}</nb-option> ">{{user.userName }}</nb-option>

View File

@ -3,12 +3,16 @@ import * as moment from 'moment';
import { PageapiService } from '../pageapi.service'; import { PageapiService } from '../pageapi.service';
import { Router } from '@angular/router'; import { Router } from '@angular/router';
import * as html2pdf from 'html2pdf.js' import * as html2pdf from 'html2pdf.js'
import { NbDialogService, NbToastrService, NbWindowControlButtonsConfig, NbWindowRef, NbWindowService } from '@nebular/theme';
import { SummaryDetailsComponent } from './summary-details/summary-details.component';
@Component({ @Component({
selector: 'ngx-summary-list', selector: 'ngx-summary-list',
templateUrl: './summary-list.component.html', templateUrl: './summary-list.component.html',
styleUrls: ['./summary-list.component.scss'] styleUrls: ['./summary-list.component.scss']
}) })
export class SummaryListComponent implements OnInit { export class SummaryListComponent implements OnInit {
dDate: string | null = this.reduceDate(localStorage.getItem('dDate'));
dId: string | null = localStorage.getItem('dId');
ranges: any = { ranges: any = {
'Today': [moment(), moment()], 'Today': [moment(), moment()],
// 'Yesterday': [moment().subtract(1, 'days'), moment().subtract(1, 'days')], // 'Yesterday': [moment().subtract(1, 'days'), moment().subtract(1, 'days')],
@ -21,7 +25,18 @@ export class SummaryListComponent implements OnInit {
// ] // ]
};selectDate:any =[];driverId:any =[];DateDisplay:any =[];driverName:any =[]; };selectDate:any =[];driverId:any =[];DateDisplay:any =[];driverName:any =[];
selectedDateRange:any =[];drivers:any =[];summaryaData:any=[];driverval:any=[];returnSummary:any =[]; selectedDateRange:any =[];drivers:any =[];summaryaData:any=[];driverval:any=[];returnSummary:any =[];
constructor(public _api:PageapiService, private router:Router) { }
minimize = false;
maximize = false;
fullScreen = true;
close = true;
constructor(public _api:PageapiService, private router:Router,private windowService: NbWindowService,) {
if(localStorage.getItem('dDate'))
{
this.dDate = this.reduceDate(localStorage.getItem('dDate'));
this.dId = localStorage.getItem('dId');
}
}
ngOnInit(): void { ngOnInit(): void {
this.selectedDateRange =[]; this.selectedDateRange =[];
@ -30,6 +45,19 @@ export class SummaryListComponent implements OnInit {
this.getDriverlistApi() this.getDriverlistApi()
} }
reduceDate(date){
// Create a Date object from the input date string
const inputDate = new Date(date);
// Subtract one day (24 hours) from the input date
const newDate = new Date(inputDate.getTime() - 24 * 60 * 60 * 1000);
// Format the new date as a string
const formattedDate = newDate.toString();
return formattedDate;
}
back(){ back(){
@ -131,10 +159,10 @@ console.log(result)
} }
view(data,name){ // view(data,name){
localStorage.setItem('cusName',name) // localStorage.setItem('cusName',name)
this.router.navigate(['/pages/summary/'+data]) // this.router.navigate(['/pages/summary/'+data])
} // }
onStartDateChanged(data){ onStartDateChanged(data){
@ -156,7 +184,8 @@ console.log(result)
// Convert the updated date to a UTC string // Convert the updated date to a UTC string
const updatedUtcDate = utcDate.toISOString(); const updatedUtcDate = utcDate.toISOString();
console.log(updatedUtcDate) console.log(updatedUtcDate)
localStorage.setItem('dDate' , updatedUtcDate);
localStorage.setItem('dId' , this.driverId);
let param ={date:new Date( updatedUtcDate),id:this.driverId} let param ={date:new Date( updatedUtcDate),id:this.driverId}
this._api.getDriverSummaryAdminList(param).subscribe(res => { this._api.getDriverSummaryAdminList(param).subscribe(res => {
console.log(res) console.log(res)
@ -198,6 +227,58 @@ console.log(result)
}) })
}
view(param,name){
const buttonsConfig: NbWindowControlButtonsConfig = {
minimize: this.minimize,
maximize: this.maximize,
fullScreen: this.fullScreen,
close: this.close,
};
let config= {
hasBackdrop: true,
width: '500px',
height: '300px',
}
console.log(param,name)
localStorage.setItem('cusName',name)
let data:any = {orderID:param,title:'Summary Product List'}
// let passData = {name:this.selectCustomer,product:results,customerData:this.selectCustomerData}
const windowRef: NbWindowRef = this.windowService.open(SummaryDetailsComponent,
{
title: `Summary Product List`,
context:data,buttons: buttonsConfig ,
});
// Subscribe to the afterClosed event
windowRef.onClose.subscribe((data) => {
})
// const dialogRef = this.dialogService.open(SummaryDetailsComponent, {
// hasBackdrop: true,
// dialogClass: 'custom-dialog-class', // Add your custom CSS class here
// context: data
// });
// dialogRef.onClose.subscribe((result) => {
// // Execute custom logic when the dialog is closed
// console.log(result);
// // if(result == 1){
// // this.getBranchDetails()
// // this.toastrService.success('Branch Added Successfully','Branch');
// // console.log('Window closed 123');
// // }else if(result == 0){
// // this.toastrService.success('Somthing is Wrong...!', 'Add Branch Failed..!');
// // }
// });
} }
download(){ download(){

View File

@ -9,7 +9,7 @@
</ng-container> </ng-container>
<label for="subject">E-mail:</label> <label for="subject">E-mail:</label>
<input formControlName="email" nbInput id="email" type="text" [status]="userForm.get('email').invalid && userForm.get('email').touched? 'danger' : 'basic'"> <input formControlName="email" nbInput id="email" type="email" [status]="userForm.get('email').invalid && userForm.get('email').touched? 'danger' : 'basic'">
<ng-container nbInputErrorMessage> <ng-container nbInputErrorMessage>
<div style="color:#7c0e0e" *ngIf="userForm.get('email').hasError('required') && userForm.get('email').touched">Email is required.</div> <div style="color:#7c0e0e" *ngIf="userForm.get('email').hasError('required') && userForm.get('email').touched">Email is required.</div>

View File

@ -29,7 +29,7 @@ export class UserFormComponent implements OnInit {
mobileNo: new FormControl('', [Validators.required, Validators.minLength(10),Validators.maxLength(10)]), mobileNo: new FormControl('', [Validators.required, Validators.minLength(10),Validators.maxLength(10)]),
// lastName: new FormControl('', [Validators.required, Validators.maxLength(20)]), // lastName: new FormControl('', [Validators.required, Validators.maxLength(20)]),
email: new FormControl('', [Validators.required, Validators.email,Validators.pattern( email: new FormControl('', [Validators.required, Validators.email,Validators.pattern(
'[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+.[a-zA-Z]{2,63}$', /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,63}$/
)]), )]),
// password: new FormControl('', [Validators.required, Validators.minLength(6)]), // password: new FormControl('', [Validators.required, Validators.minLength(6)]),
password: new FormControl('', [Validators.required,Validators.pattern( password: new FormControl('', [Validators.required,Validators.pattern(

View File

@ -81,6 +81,7 @@ export class UsersComponent {
destroyByClick = true; destroyByClick = true;
duration = 2000; duration = 2000;
hasIcon = true; hasIcon = true;
logUser = JSON.parse(localStorage.getItem('email')).email;
admin:any =[]; admin:any =[];
position: NbGlobalPosition = NbGlobalPhysicalPosition.TOP_RIGHT; position: NbGlobalPosition = NbGlobalPhysicalPosition.TOP_RIGHT;
preventDuplicates = false; preventDuplicates = false;
@ -195,7 +196,7 @@ export class UsersComponent {
if(res.status == 200){ if(res.status == 200){
let passData = res.data let passData = res.data
let admin = passData.filter(arr=>{return arr.role == 'ADMIN' || arr.role == 'FRONT-OFFICE'}) let admin = passData.filter(arr=>{return ( arr.role == 'ADMIN' || arr.role == 'FRONT-OFFICE' ) && arr.email != this.logUser })
admin.forEach((element:any, index) => { admin.forEach((element:any, index) => {
element.index = index +1 element.index = index +1

View File

@ -5,5 +5,6 @@
*/ */
export const environment = { export const environment = {
apiEndpoint:'https://dev.venbait.in/vnms/api/', apiEndpoint:'https://dev.venbait.in/vnms/api/',
mailUrl:'',
production: true, production: true,
}; };

View File

@ -9,10 +9,8 @@
// The list of which env maps to which file can be found in `.angular-cli.json`. // The list of which env maps to which file can be found in `.angular-cli.json`.
export const environment = { export const environment = {
// apiEndpoint:'https://dev.venbait.in/vnms/api/', apiEndpoint:'https://dev.venbait.in/vnms/api/',
apiEndpoint:'http://localhost:8081/api/', // apiEndpoint:'http://localhost:8081/api/',
// apiEndpoint:'http://192.168.1.17:8081/api/',
mailUrl:'', mailUrl:'',
production: false, production: false,
}; };

View File

@ -9,6 +9,7 @@
"moduleResolution": "node", "moduleResolution": "node",
"experimentalDecorators": true, "experimentalDecorators": true,
"target": "es2020", "target": "es2020",
"types": ["node"],
"typeRoots": [ "typeRoots": [
"node_modules/@types" "node_modules/@types"
], ],