|
@@ -1,4 +1,8 @@
|
|
|
+import { ActivatedRoute, Params } from '@angular/router';
|
|
|
+import { AuthServiceService } from './../../../shared/auth-service.service';
|
|
|
+import { HttpClient } from '@angular/common/http';
|
|
|
import { Component, OnInit } from '@angular/core';
|
|
|
+import { ToastrService } from 'ngx-toastr';
|
|
|
|
|
|
@Component({
|
|
|
selector: 'app-vehicle-movement-report',
|
|
@@ -7,9 +11,80 @@ import { Component, OnInit } from '@angular/core';
|
|
|
})
|
|
|
export class VehicleMovementReportComponent implements OnInit {
|
|
|
|
|
|
- constructor() { }
|
|
|
+ constructor(private http: HttpClient,
|
|
|
+ private toastr: ToastrService,
|
|
|
+ private route : ActivatedRoute,
|
|
|
+ private authSer: AuthServiceService) { }
|
|
|
|
|
|
+ searchData: string = '';
|
|
|
+ showTableData: boolean = false;
|
|
|
+ vehicleData = [];
|
|
|
+ typeReport:string = '';
|
|
|
+ typeReportPage:string = '';
|
|
|
ngOnInit() {
|
|
|
+ this.route.params.subscribe(
|
|
|
+ (params: Params) => {
|
|
|
+ this.typeReport = params['typeReport'];
|
|
|
+ }
|
|
|
+ );
|
|
|
+
|
|
|
+ if(this.typeReport == 'Movement') {
|
|
|
+ this.typeReportPage = 'تقارير حركه المركبات';
|
|
|
+ } else if(this.typeReport == 'General') {
|
|
|
+ this.typeReportPage = 'تقرير عام عن المركبه';
|
|
|
+ } else {
|
|
|
+ console.log('error');
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ onGetData() {
|
|
|
+ this.vehicleData = [];
|
|
|
+ if(this.typeReport == 'Movement') {
|
|
|
+ this.http.get(this.authSer.pathApi + '/report_vehicle_movement/' + this.searchData).subscribe(
|
|
|
+ (responce) => {
|
|
|
+ console.log(responce);
|
|
|
+ this.vehicleData.push(responce['vehicle']);
|
|
|
+ console.log(this.vehicleData);
|
|
|
+ if(this.vehicleData[0] == null) {
|
|
|
+ this.toastr.warning('لا يوجد بيانات لهذا المركبه');
|
|
|
+ this.showTableData = false;
|
|
|
+ } else {
|
|
|
+ this.showTableData = true;
|
|
|
+ }
|
|
|
+
|
|
|
+ },
|
|
|
+ (error) => {
|
|
|
+ console.log(error);
|
|
|
+ this.toastr.error('خطأ في البحث ، حاول ثانيه');
|
|
|
+ }
|
|
|
+ );
|
|
|
+ } else if(this.typeReport == 'General') {
|
|
|
+ this.http.get(this.authSer.pathApi + '/report_general_on_vehicle/' + this.searchData).subscribe(
|
|
|
+ (responce) => {
|
|
|
+ console.log(responce);
|
|
|
+ this.vehicleData.push(responce['vehicle']);
|
|
|
+ console.log(this.vehicleData);
|
|
|
+ if(this.vehicleData[0] == null) {
|
|
|
+ this.toastr.warning('لا يوجد بيانات لهذا المركبه');
|
|
|
+ this.showTableData = false;
|
|
|
+ } else {
|
|
|
+ this.showTableData = true;
|
|
|
+ }
|
|
|
+
|
|
|
+ },
|
|
|
+ (error) => {
|
|
|
+ console.log(error);
|
|
|
+ this.toastr.error('خطأ في البحث ، حاول ثانيه');
|
|
|
+ }
|
|
|
+ );
|
|
|
+ } else {
|
|
|
+
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
+ //print function
|
|
|
+ onPrint() {
|
|
|
+ window.print();
|
|
|
}
|
|
|
|
|
|
}
|