|
@@ -37,7 +37,7 @@ export class MaintenanceCommunicationEditComponent implements OnInit {
|
|
//reopen object
|
|
//reopen object
|
|
reOpenReasonObject = {
|
|
reOpenReasonObject = {
|
|
communication_id: null,
|
|
communication_id: null,
|
|
- reopen_closed_communication: '',
|
|
|
|
|
|
+ reopen_status_reason: '',
|
|
}
|
|
}
|
|
|
|
|
|
selectedAll: any;
|
|
selectedAll: any;
|
|
@@ -54,7 +54,7 @@ export class MaintenanceCommunicationEditComponent implements OnInit {
|
|
maintenance_notes: '',
|
|
maintenance_notes: '',
|
|
status: null,
|
|
status: null,
|
|
closed_status_reason: '',
|
|
closed_status_reason: '',
|
|
- urgent_communication: '',
|
|
|
|
|
|
+ urgent_communication: null,
|
|
};
|
|
};
|
|
|
|
|
|
countries = [];
|
|
countries = [];
|
|
@@ -93,9 +93,6 @@ export class MaintenanceCommunicationEditComponent implements OnInit {
|
|
location.reload();
|
|
location.reload();
|
|
},180000);
|
|
},180000);
|
|
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
this.counter$ = timer(0,1000).pipe(
|
|
this.counter$ = timer(0,1000).pipe(
|
|
take(this.counter),
|
|
take(this.counter),
|
|
map(() => --this.counter)
|
|
map(() => --this.counter)
|
|
@@ -116,7 +113,6 @@ export class MaintenanceCommunicationEditComponent implements OnInit {
|
|
//get nationality data
|
|
//get nationality data
|
|
this.userSer.getNationality().subscribe(
|
|
this.userSer.getNationality().subscribe(
|
|
(responce) => {
|
|
(responce) => {
|
|
- console.log(responce);
|
|
|
|
this.countries = responce['countries'];
|
|
this.countries = responce['countries'];
|
|
},
|
|
},
|
|
(error) => {
|
|
(error) => {
|
|
@@ -128,7 +124,6 @@ export class MaintenanceCommunicationEditComponent implements OnInit {
|
|
this.userSer.onGetIdentities().subscribe(
|
|
this.userSer.onGetIdentities().subscribe(
|
|
(responce) => {
|
|
(responce) => {
|
|
this.identities = responce['identities'];
|
|
this.identities = responce['identities'];
|
|
- console.log('idddentiiiesssssssssss', this.identities);
|
|
|
|
},
|
|
},
|
|
(error) => {
|
|
(error) => {
|
|
console.log(error);
|
|
console.log(error);
|
|
@@ -139,7 +134,6 @@ export class MaintenanceCommunicationEditComponent implements OnInit {
|
|
//get parent_categories_list
|
|
//get parent_categories_list
|
|
this.http.get(this.authSer.pathApi + '/parent_categories_list').subscribe(
|
|
this.http.get(this.authSer.pathApi + '/parent_categories_list').subscribe(
|
|
(responce) => {
|
|
(responce) => {
|
|
- console.log('parent_categories_list', responce);
|
|
|
|
this.parentCategoriesList = responce['categories'];
|
|
this.parentCategoriesList = responce['categories'];
|
|
},
|
|
},
|
|
(error) => {
|
|
(error) => {
|
|
@@ -147,23 +141,34 @@ export class MaintenanceCommunicationEditComponent implements OnInit {
|
|
}
|
|
}
|
|
);
|
|
);
|
|
|
|
|
|
|
|
+
|
|
//get maintanence data by id
|
|
//get maintanence data by id
|
|
this.dashBoardSer.getItemData(this.pageId, 'maintenance').subscribe(
|
|
this.dashBoardSer.getItemData(this.pageId, 'maintenance').subscribe(
|
|
(responce) => {
|
|
(responce) => {
|
|
|
|
|
|
this.maintData = responce['communication'];
|
|
this.maintData = responce['communication'];
|
|
- console.log('main data ', this.maintData);
|
|
|
|
|
|
+ console.log('main data request ', this.maintData);
|
|
|
|
+ this.maintData.adminstrations.map(admin => admin.id = admin.adminstration_id);
|
|
|
|
+ console.log('after ediiiiiiiiiiiiiiit', this.maintData);
|
|
this.communicationData.maintenance_notes = this.maintData.maintenance_notes;
|
|
this.communicationData.maintenance_notes = this.maintData.maintenance_notes;
|
|
this.communicationData.status = this.maintData.status == 'closed' ? this.maintData.status : false;
|
|
this.communicationData.status = this.maintData.status == 'closed' ? this.maintData.status : false;
|
|
this.communicationData.time_period_id = this.maintData.time_period_id;
|
|
this.communicationData.time_period_id = this.maintData.time_period_id;
|
|
this.communicationData.closed_status_reason = this.maintData.closed_status_reason ? this.maintData.closed_status_reason : '';
|
|
this.communicationData.closed_status_reason = this.maintData.closed_status_reason ? this.maintData.closed_status_reason : '';
|
|
|
|
+
|
|
this.communicationData.parent_category_id = this.maintData.parent_category_id;
|
|
this.communicationData.parent_category_id = this.maintData.parent_category_id;
|
|
- this.getChildGategories(this.communicationData.parent_category_id);
|
|
|
|
- this.communicationData.child_category_id = this.maintData.child_category_id;
|
|
|
|
|
|
+ if(this.communicationData.parent_category_id) {
|
|
|
|
+ this.getChildGategories(this.communicationData.parent_category_id);
|
|
|
|
+ this.communicationData.child_category_id = this.maintData.child_category_id;
|
|
|
|
+ }
|
|
|
|
+
|
|
//get main_location_id
|
|
//get main_location_id
|
|
this.mainLocationVal = this.maintData.main_location_id;
|
|
this.mainLocationVal = this.maintData.main_location_id;
|
|
- this.getSublocationList(this.mainLocationVal);
|
|
|
|
- this.subLocationVal = this.maintData.sub_location_id;
|
|
|
|
|
|
+
|
|
|
|
+ if(this.mainLocationVal) {
|
|
|
|
+ this.getSublocationList(this.mainLocationVal);
|
|
|
|
+ this.subLocationVal = this.maintData.sub_location_id;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
|
|
this.returnEditData();
|
|
this.returnEditData();
|
|
|
|
|
|
@@ -174,20 +179,23 @@ export class MaintenanceCommunicationEditComponent implements OnInit {
|
|
this.checkStatusClosed = false;
|
|
this.checkStatusClosed = false;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ //make selected adminstarations is true in checkbox and full array of selectedAdminstrations
|
|
this.selectedAdminstrations = [];
|
|
this.selectedAdminstrations = [];
|
|
if(this.maintData.adminstrations.length > 0) {
|
|
if(this.maintData.adminstrations.length > 0) {
|
|
for(let i = 0; i < this.maintData.adminstrations.length; i++) {
|
|
for(let i = 0; i < this.maintData.adminstrations.length; i++) {
|
|
this.selectedAdminstrations.push(this.maintData.adminstrations[i]);
|
|
this.selectedAdminstrations.push(this.maintData.adminstrations[i]);
|
|
for(let j = 0; j < this.adminstrations.length; j++) {
|
|
for(let j = 0; j < this.adminstrations.length; j++) {
|
|
- if(this.maintData.adminstrations[i].id == this.adminstrations[j].id) {
|
|
|
|
- this.adminstrations[i].selected = true;
|
|
|
|
|
|
+ if(this.maintData.adminstrations[i].adminstration_id == this.adminstrations[j].id) {
|
|
|
|
+ this.adminstrations[j].selected = true;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- console.log('selected adminstrations', this.selectedAdminstrations);
|
|
|
|
- console.log('adminstrations ids ', this.adminstrationsIds);
|
|
|
|
|
|
|
|
this.bindingDateSplitEnd = {
|
|
this.bindingDateSplitEnd = {
|
|
year: parseInt(this.maintData.created_date.split('-')[0]),
|
|
year: parseInt(this.maintData.created_date.split('-')[0]),
|
|
@@ -197,13 +205,11 @@ export class MaintenanceCommunicationEditComponent implements OnInit {
|
|
|
|
|
|
this.userData = responce['communication']['user'];
|
|
this.userData = responce['communication']['user'];
|
|
this.spinner.hide();
|
|
this.spinner.hide();
|
|
- console.log('gggg', this.maintData);
|
|
|
|
if(this.maintData['files'].length > 0) {
|
|
if(this.maintData['files'].length > 0) {
|
|
this.showAttachements = true;
|
|
this.showAttachements = true;
|
|
} else {
|
|
} else {
|
|
this.showAttachements = false;
|
|
this.showAttachements = false;
|
|
}
|
|
}
|
|
- console.log('user data ', this.userData);
|
|
|
|
},
|
|
},
|
|
(error) => {
|
|
(error) => {
|
|
console.log(error);
|
|
console.log(error);
|
|
@@ -213,7 +219,6 @@ export class MaintenanceCommunicationEditComponent implements OnInit {
|
|
//get time period
|
|
//get time period
|
|
this.http.get(this.authSer.pathApi + '/page_list/53/1/1000/for_communication').subscribe(
|
|
this.http.get(this.authSer.pathApi + '/page_list/53/1/1000/for_communication').subscribe(
|
|
(response) => {
|
|
(response) => {
|
|
- console.log('time period', response);
|
|
|
|
this.times = response['time_periods'];
|
|
this.times = response['time_periods'];
|
|
},
|
|
},
|
|
(error) => {
|
|
(error) => {
|
|
@@ -225,7 +230,6 @@ export class MaintenanceCommunicationEditComponent implements OnInit {
|
|
this.http.get(this.authSer.pathApi + '/parent_locations_list').subscribe(
|
|
this.http.get(this.authSer.pathApi + '/parent_locations_list').subscribe(
|
|
(response) => {
|
|
(response) => {
|
|
this.locationList = response['locations'];
|
|
this.locationList = response['locations'];
|
|
- console.log('parent location' , this.locationList);
|
|
|
|
},
|
|
},
|
|
(error) => {
|
|
(error) => {
|
|
console.log(error);
|
|
console.log(error);
|
|
@@ -235,16 +239,15 @@ export class MaintenanceCommunicationEditComponent implements OnInit {
|
|
}
|
|
}
|
|
|
|
|
|
changeParentCategory(event) {
|
|
changeParentCategory(event) {
|
|
- console.log(event.target.value);
|
|
|
|
this.getChildGategories(event.target.value);
|
|
this.getChildGategories(event.target.value);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
//get child gategories
|
|
//get child gategories
|
|
getChildGategories(parentId: number) {
|
|
getChildGategories(parentId: number) {
|
|
|
|
+ this.communicationData.parent_category_id = parentId;
|
|
this.http.get(this.authSer.pathApi + '/childs_categories_list_by_parent_id/' + parentId).subscribe(
|
|
this.http.get(this.authSer.pathApi + '/childs_categories_list_by_parent_id/' + parentId).subscribe(
|
|
(responce) => {
|
|
(responce) => {
|
|
- console.log('childs_categories_list_by_parent_id', responce);
|
|
|
|
this.childsCategoriesList = responce['categories'];
|
|
this.childsCategoriesList = responce['categories'];
|
|
},
|
|
},
|
|
(error) => {
|
|
(error) => {
|
|
@@ -253,12 +256,15 @@ export class MaintenanceCommunicationEditComponent implements OnInit {
|
|
);
|
|
);
|
|
};
|
|
};
|
|
|
|
|
|
|
|
+ getChildGategoriesVal(event) {
|
|
|
|
+ this.communicationData.child_category_id = event.target.value;
|
|
|
|
+ }
|
|
|
|
+
|
|
onChangemainLocation(event){
|
|
onChangemainLocation(event){
|
|
const id = event.target.value
|
|
const id = event.target.value
|
|
this.mainLocationVal = id;
|
|
this.mainLocationVal = id;
|
|
this.http.get(this.authSer.pathApi + '/childs_locations_list_by_parent_id/' + id).subscribe(
|
|
this.http.get(this.authSer.pathApi + '/childs_locations_list_by_parent_id/' + id).subscribe(
|
|
(response) => {
|
|
(response) => {
|
|
- console.log(id);
|
|
|
|
this.subLocationList = response['locations'];
|
|
this.subLocationList = response['locations'];
|
|
},
|
|
},
|
|
(error) => {
|
|
(error) => {
|
|
@@ -269,7 +275,6 @@ export class MaintenanceCommunicationEditComponent implements OnInit {
|
|
|
|
|
|
|
|
|
|
changeSubLocation(event){
|
|
changeSubLocation(event){
|
|
- console.log(event.target.value);
|
|
|
|
this.subLocationVal = event.target.value;
|
|
this.subLocationVal = event.target.value;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -279,8 +284,8 @@ export class MaintenanceCommunicationEditComponent implements OnInit {
|
|
|
|
|
|
this.http.get(this.authSer.pathApi + '/page_list/3/1/1000/all' + searchKey).subscribe(
|
|
this.http.get(this.authSer.pathApi + '/page_list/3/1/1000/all' + searchKey).subscribe(
|
|
(responce) => {
|
|
(responce) => {
|
|
- console.log('adminstraitions', responce);
|
|
|
|
this.adminstrations = responce['adminstrations'];
|
|
this.adminstrations = responce['adminstrations'];
|
|
|
|
+ console.log('adminstrationnns', this.adminstrations);
|
|
},
|
|
},
|
|
(error) => {
|
|
(error) => {
|
|
console.log(error);
|
|
console.log(error);
|
|
@@ -291,7 +296,6 @@ export class MaintenanceCommunicationEditComponent implements OnInit {
|
|
//search function
|
|
//search function
|
|
filtterFunc(event) {
|
|
filtterFunc(event) {
|
|
this.adminstrations = [];
|
|
this.adminstrations = [];
|
|
- console.log(event.target.value);
|
|
|
|
this.getAdminstrationList(event.target.value);
|
|
this.getAdminstrationList(event.target.value);
|
|
}
|
|
}
|
|
|
|
|
|
@@ -320,8 +324,9 @@ export class MaintenanceCommunicationEditComponent implements OnInit {
|
|
this.selectedAdminstrations.push(this.adminstrations[i]);
|
|
this.selectedAdminstrations.push(this.adminstrations[i]);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- console.log(this.adminstrationsIds);
|
|
|
|
- console.log(this.selectedAdminstrations);
|
|
|
|
|
|
+
|
|
|
|
+ console.log('adminstartion id', this.adminstrationsIds);
|
|
|
|
+ console.log('selectedAdminstrations', this.selectedAdminstrations);
|
|
}
|
|
}
|
|
|
|
|
|
//get sub location list
|
|
//get sub location list
|
|
@@ -329,7 +334,6 @@ export class MaintenanceCommunicationEditComponent implements OnInit {
|
|
this.http.get(this.authSer.pathApi + '/childs_locations_list_by_parent_id/' + parentId).subscribe(
|
|
this.http.get(this.authSer.pathApi + '/childs_locations_list_by_parent_id/' + parentId).subscribe(
|
|
(response) => {
|
|
(response) => {
|
|
this.subLocationList = response['locations'];
|
|
this.subLocationList = response['locations'];
|
|
- console.log('sub Location', this.subLocationList);
|
|
|
|
},
|
|
},
|
|
(error) => {
|
|
(error) => {
|
|
console.log(error)
|
|
console.log(error)
|
|
@@ -339,31 +343,30 @@ export class MaintenanceCommunicationEditComponent implements OnInit {
|
|
|
|
|
|
//get value of reason reOpen
|
|
//get value of reason reOpen
|
|
getReopenReason(event) {
|
|
getReopenReason(event) {
|
|
- console.log(event.target.value);
|
|
|
|
- console.log(this.reOpenReasonObject);
|
|
|
|
- this.reOpenReasonObject.reopen_closed_communication = event.target.value;
|
|
|
|
|
|
+ this.reOpenReasonObject.reopen_status_reason = event.target.value;
|
|
}
|
|
}
|
|
|
|
|
|
//reOpen mentainence function
|
|
//reOpen mentainence function
|
|
reOpenMaintenance() {
|
|
reOpenMaintenance() {
|
|
- this.http.post(this.authSer.pathApi + '/reopen_closed_communication', this.reOpenReasonObject).subscribe(
|
|
|
|
- (responce) => {
|
|
|
|
- console.log(responce);
|
|
|
|
- this.toastr.success('تم إعاده الفتح بنجاح');
|
|
|
|
- this.location.back();
|
|
|
|
- },
|
|
|
|
- (error) => {
|
|
|
|
- console.log(error);
|
|
|
|
- this.toastr.error('حدث خطا في الحفظ ، حاول لاحقاً');
|
|
|
|
- this.location.back();
|
|
|
|
- }
|
|
|
|
- );
|
|
|
|
|
|
+ if(!this.reOpenReasonObject.reopen_status_reason){
|
|
|
|
+ this.toastr.warning('أدخل إعاده سبب فتح البلاغ !');
|
|
|
|
+ } else {
|
|
|
|
+ this.http.post(this.authSer.pathApi + '/reopen_closed_communication', this.reOpenReasonObject).subscribe(
|
|
|
|
+ (responce) => {
|
|
|
|
+ this.toastr.success('تم إعاده الفتح بنجاح');
|
|
|
|
+ this.location.back();
|
|
|
|
+ },
|
|
|
|
+ (error) => {
|
|
|
|
+ console.log(error);
|
|
|
|
+ this.toastr.error('حدث خطا في الحفظ ، حاول لاحقاً');
|
|
|
|
+ }
|
|
|
|
+ );
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
//remove remove selected adminsration
|
|
//remove remove selected adminsration
|
|
removeSelectedAdminsration(adminstrationData) {
|
|
removeSelectedAdminsration(adminstrationData) {
|
|
- console.log(adminstrationData);
|
|
|
|
|
|
|
|
//to remove checked from adminstrations list
|
|
//to remove checked from adminstrations list
|
|
for(let j = 0; j < this.adminstrations.length; j++) {
|
|
for(let j = 0; j < this.adminstrations.length; j++) {
|
|
@@ -375,14 +378,12 @@ export class MaintenanceCommunicationEditComponent implements OnInit {
|
|
const index = this.selectedAdminstrations.indexOf(adminstrationData);
|
|
const index = this.selectedAdminstrations.indexOf(adminstrationData);
|
|
this.selectedAdminstrations.splice(index, 1);
|
|
this.selectedAdminstrations.splice(index, 1);
|
|
|
|
|
|
- console.log(index);
|
|
|
|
}
|
|
}
|
|
|
|
|
|
//return substring of subject and check negaive and positive time
|
|
//return substring of subject and check negaive and positive time
|
|
returnEditData() {
|
|
returnEditData() {
|
|
for(let i = 0; i < this.maintData['adminstrations'].length; i++) {
|
|
for(let i = 0; i < this.maintData['adminstrations'].length; i++) {
|
|
this.maintData['adminstrations'][i].countdown = this.maintData['adminstrations'][i].countdown ? this.dashBoardSer.secondsToDhms(this.maintData['adminstrations'][i].countdown) : '-';
|
|
this.maintData['adminstrations'][i].countdown = this.maintData['adminstrations'][i].countdown ? this.dashBoardSer.secondsToDhms(this.maintData['adminstrations'][i].countdown) : '-';
|
|
- console.log(this.maintData['adminstrations'][i].countdown);
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -424,9 +425,10 @@ onPrint(): void {
|
|
|
|
|
|
if(this.communicationData.urgent_communication) {
|
|
if(this.communicationData.urgent_communication) {
|
|
this.communicationData.urgent_communication = '1';
|
|
this.communicationData.urgent_communication = '1';
|
|
- } else {
|
|
|
|
- this.communicationData.urgent_communication = '0';
|
|
|
|
}
|
|
}
|
|
|
|
+ // } else {
|
|
|
|
+ // this.communicationData.urgent_communication = '0';
|
|
|
|
+ // }
|
|
|
|
|
|
for(let i = 0; i < this.selectedAdminstrations.length; i++) {
|
|
for(let i = 0; i < this.selectedAdminstrations.length; i++) {
|
|
this.adminstrationsIds.push(this.selectedAdminstrations[i].id);
|
|
this.adminstrationsIds.push(this.selectedAdminstrations[i].id);
|
|
@@ -434,15 +436,19 @@ onPrint(): void {
|
|
|
|
|
|
this.communicationData['adminstrations_ids'] = this.adminstrationsIds;
|
|
this.communicationData['adminstrations_ids'] = this.adminstrationsIds;
|
|
|
|
|
|
- console.log(this.communicationData);
|
|
|
|
|
|
|
|
if(this.adminstrationsIds.length == 0 && this.communicationData.urgent_communication == '1') {
|
|
if(this.adminstrationsIds.length == 0 && this.communicationData.urgent_communication == '1') {
|
|
this.toastr.warning('قم بإختيار الإدارات');
|
|
this.toastr.warning('قم بإختيار الإدارات');
|
|
this.checkSaveClick = false;
|
|
this.checkSaveClick = false;
|
|
|
|
+ }else if( this.communicationData.status == 'closed' && !this.communicationData.closed_status_reason){
|
|
|
|
+ this.toastr.warning('قم بإختيار سبب غلق البلاغ !');
|
|
|
|
+ this.checkSaveClick = false;
|
|
} else {
|
|
} else {
|
|
|
|
+ if(this.communicationData.urgent_communication != '1'){
|
|
|
|
+ this.communicationData.urgent_communication = '0';
|
|
|
|
+ }
|
|
this.http.post(this.authSer.pathApi + '/maintenance_handle_communication', this.communicationData).subscribe(
|
|
this.http.post(this.authSer.pathApi + '/maintenance_handle_communication', this.communicationData).subscribe(
|
|
(responce) => {
|
|
(responce) => {
|
|
- console.log(responce['status']);
|
|
|
|
if(responce['status'] == 'some adminstrations didnt closed yet') {
|
|
if(responce['status'] == 'some adminstrations didnt closed yet') {
|
|
this.toastr.warning('بعض الإدارات لم تقم بإغلاق البلاغ بعد !');
|
|
this.toastr.warning('بعض الإدارات لم تقم بإغلاق البلاغ بعد !');
|
|
} else {
|
|
} else {
|
|
@@ -452,6 +458,7 @@ onPrint(): void {
|
|
},
|
|
},
|
|
(error) => {
|
|
(error) => {
|
|
console.log(error);
|
|
console.log(error);
|
|
|
|
+ this.checkSaveClick = false;
|
|
this.toastr.error('خطأ في الحفظ حاول لاحقاً');
|
|
this.toastr.error('خطأ في الحفظ حاول لاحقاً');
|
|
}
|
|
}
|
|
);
|
|
);
|