|
@@ -6,6 +6,7 @@ import { ActivatedRoute, Params } from '@angular/router';
|
|
import { Component, OnInit, ViewChild } from '@angular/core';
|
|
import { Component, OnInit, ViewChild } from '@angular/core';
|
|
import { NgForm } from '@angular/forms';
|
|
import { NgForm } from '@angular/forms';
|
|
import { ToastrService } from 'ngx-toastr';
|
|
import { ToastrService } from 'ngx-toastr';
|
|
|
|
+import { Location } from '@angular/common';
|
|
|
|
|
|
@Component({
|
|
@Component({
|
|
selector: 'app-add-request',
|
|
selector: 'app-add-request',
|
|
@@ -19,12 +20,14 @@ export class AddRequestComponent implements OnInit {
|
|
private toastr: ToastrService,
|
|
private toastr: ToastrService,
|
|
private dashBoardSer: DashboardService,
|
|
private dashBoardSer: DashboardService,
|
|
private spiner: NgxSpinnerService,
|
|
private spiner: NgxSpinnerService,
|
|
|
|
+ private location: Location,
|
|
private authService: AuthServiceService) { }
|
|
private authService: AuthServiceService) { }
|
|
|
|
|
|
visitorId: number;
|
|
visitorId: number;
|
|
departments = [];
|
|
departments = [];
|
|
departmentsId = [];
|
|
departmentsId = [];
|
|
checkSaveClick: boolean = false;
|
|
checkSaveClick: boolean = false;
|
|
|
|
+ editMode:boolean = false;
|
|
requestId: number;
|
|
requestId: number;
|
|
|
|
|
|
@ViewChild('f') addRequestFrom: NgForm;
|
|
@ViewChild('f') addRequestFrom: NgForm;
|
|
@@ -45,16 +48,23 @@ export class AddRequestComponent implements OnInit {
|
|
department1: '',
|
|
department1: '',
|
|
department2: '',
|
|
department2: '',
|
|
department3: '',
|
|
department3: '',
|
|
- }
|
|
|
|
|
|
+ };
|
|
|
|
|
|
files = [{
|
|
files = [{
|
|
title : '',
|
|
title : '',
|
|
file: '',
|
|
file: '',
|
|
file_type: '',
|
|
file_type: '',
|
|
nameFile: '',
|
|
nameFile: '',
|
|
- }]
|
|
|
|
|
|
+ id: null,
|
|
|
|
+ }];
|
|
|
|
+
|
|
|
|
+
|
|
|
|
|
|
attachments_ids = []; //for edit mode;
|
|
attachments_ids = []; //for edit mode;
|
|
|
|
+ departmentsIds = []; //attachemnts id edit
|
|
|
|
+ disabledInput:boolean = false; //disabled button of row in edit mode
|
|
|
|
+ editButtonShow:boolean = false; //show edit button in edit mode
|
|
|
|
+ saveButtonShow:boolean = false; //show save button in edit mode
|
|
|
|
|
|
ngOnInit() {
|
|
ngOnInit() {
|
|
|
|
|
|
@@ -81,6 +91,10 @@ export class AddRequestComponent implements OnInit {
|
|
this.requestId = params['requestId'];
|
|
this.requestId = params['requestId'];
|
|
if(this.requestId) {
|
|
if(this.requestId) {
|
|
this.spiner.show();
|
|
this.spiner.show();
|
|
|
|
+ this.files = [];
|
|
|
|
+ this.editButtonShow = true;
|
|
|
|
+ this.disabledInput = true;
|
|
|
|
+ this.editMode = true;
|
|
this.http.get(this.authService.pathApi + '/get_request/' + this.requestId).subscribe(
|
|
this.http.get(this.authService.pathApi + '/get_request/' + this.requestId).subscribe(
|
|
(responce) => {
|
|
(responce) => {
|
|
console.log(responce);
|
|
console.log(responce);
|
|
@@ -89,23 +103,40 @@ export class AddRequestComponent implements OnInit {
|
|
this.dataForm.specific_specialization = responce['data']['request'].specific_specialization;
|
|
this.dataForm.specific_specialization = responce['data']['request'].specific_specialization;
|
|
this.dataForm.university = responce['data']['request'].university;
|
|
this.dataForm.university = responce['data']['request'].university;
|
|
this.dataForm.level = responce['data']['request'].level;
|
|
this.dataForm.level = responce['data']['request'].level;
|
|
- this.dataForm.training_period = responce['data']['request'].training_period;
|
|
|
|
-
|
|
|
|
|
|
+ this.dataForm.registration_number = responce['data']['request'].registration_number ? responce['data']['request'].registration_number : '';
|
|
|
|
+ this.dataForm.contract_type = responce['data']['request'].contract_type ? responce['data']['request'].contract_type : '';
|
|
|
|
+ this.dataForm.functional_number = responce['data']['request'].functional_number ? responce['data']['request'].functional_number : '';
|
|
|
|
+ this.dataForm.level = responce['data']['request'].level ? responce['data']['request'].level : '';
|
|
|
|
+ this.dataForm.training_period = responce['data']['request'].training_period ? responce['data']['request'].training_period : '';
|
|
|
|
+ this.dataForm.organization_affiliated_with = responce['data']['request'].organization_affiliated_with ? responce['data']['request'].organization_affiliated_with : '';
|
|
|
|
+ this.dataForm.authority_card_number = responce['data']['request'].authority_card_number ? responce['data']['request'].authority_card_number : '';
|
|
|
|
+
|
|
|
|
+ //add departmrnts ids
|
|
if(responce['data']['request'].departments.length > 0) {
|
|
if(responce['data']['request'].departments.length > 0) {
|
|
- if(responce['data']['request'].departments[0].department_id) {
|
|
|
|
- this.dataForm.department1 = responce['data']['request'].departments[0].department_id;
|
|
|
|
- }
|
|
|
|
- if(responce['data']['request'].departments[1].department_id) {
|
|
|
|
- this.dataForm.department2 = responce['data']['request'].departments[1].department_id;
|
|
|
|
- }
|
|
|
|
- if(responce['data']['request'].departments[2].department_id) {
|
|
|
|
- this.dataForm.department3 = responce['data']['request'].departments[2].department_id;
|
|
|
|
|
|
+ for(let i = 0; i < responce['data']['request'].departments.length; i++) {
|
|
|
|
+ if(i == 0) {
|
|
|
|
+ this.dataForm.department1 = responce['data']['request'].departments[0].department_id;
|
|
|
|
+ this.departmentsId[i] = responce['data']['request'].departments[i].department_id;
|
|
|
|
+ } else if(i == 1) {
|
|
|
|
+ this.dataForm.department2 = responce['data']['request'].departments[i].department_id;
|
|
|
|
+ this.departmentsId[i] = responce['data']['request'].departments[i].department_id;
|
|
|
|
+ } else if(i == 2) {
|
|
|
|
+ this.dataForm.department3 = responce['data']['request'].departments[i].department_id;
|
|
|
|
+ this.departmentsId[i] = responce['data']['request'].departments[i].department_id;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ }
|
|
|
|
|
|
if(responce['data']['request'].attachments.length > 0) {
|
|
if(responce['data']['request'].attachments.length > 0) {
|
|
for(let i = 0; i < responce['data']['request'].attachments.length; i++) {
|
|
for(let i = 0; i < responce['data']['request'].attachments.length; i++) {
|
|
this.attachments_ids.push(responce['data']['request'].attachments[i].id);
|
|
this.attachments_ids.push(responce['data']['request'].attachments[i].id);
|
|
|
|
+ this.files.push({
|
|
|
|
+ title: responce['data']['request'].attachments[i].title,
|
|
|
|
+ file: '',
|
|
|
|
+ nameFile: responce['data']['request'].attachments[i].file,
|
|
|
|
+ file_type: '',
|
|
|
|
+ id: responce['data']['request'].attachments[i].id,
|
|
|
|
+ })
|
|
}
|
|
}
|
|
console.log('attachements ids', this.attachments_ids);
|
|
console.log('attachements ids', this.attachments_ids);
|
|
} else {
|
|
} else {
|
|
@@ -117,7 +148,7 @@ export class AddRequestComponent implements OnInit {
|
|
(error) => {
|
|
(error) => {
|
|
console.log(error);
|
|
console.log(error);
|
|
}
|
|
}
|
|
- )
|
|
|
|
|
|
+ );
|
|
}
|
|
}
|
|
}
|
|
}
|
|
);
|
|
);
|
|
@@ -142,25 +173,42 @@ export class AddRequestComponent implements OnInit {
|
|
file: '',
|
|
file: '',
|
|
file_type: '',
|
|
file_type: '',
|
|
nameFile: '',
|
|
nameFile: '',
|
|
|
|
+ id: null,
|
|
});
|
|
});
|
|
- console.log(this.files);
|
|
|
|
|
|
+ console.log('files after plus ', this.files);
|
|
}
|
|
}
|
|
|
|
|
|
onFileChanges(event, index:number) {
|
|
onFileChanges(event, index:number) {
|
|
console.log(event);
|
|
console.log(event);
|
|
console.log(index);
|
|
console.log(index);
|
|
- this.files[index].nameFile = event[0].name.substring(0,20) + '....';
|
|
|
|
- this.files[index].file = event[0].base64;
|
|
|
|
- this.files[index].file_type = event[0].type.split('/')[1];
|
|
|
|
- console.log(this.files);
|
|
|
|
- }
|
|
|
|
|
|
+ this.files[index].nameFile = event[0].name.substring(0,20) + '....';
|
|
|
|
+ this.files[index].file = event[0].base64;
|
|
|
|
+ this.files[index].file_type = event[0].type.split('/')[1];
|
|
|
|
+ if(this.editMode) {
|
|
|
|
+ //validate in pdf type file in edit mode
|
|
|
|
+ if(this.files[index].file_type != '') {
|
|
|
|
+ if(this.files[index].file_type != 'pdf') {
|
|
|
|
+ this.toastr.warning('يجب أن تكون صيغه الملف pdf !');
|
|
|
|
+ this.checkSaveClick = true;
|
|
|
|
+ } else {
|
|
|
|
+ this.checkSaveClick = false;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
|
|
- onDeleteFile(fileData, index:number) {
|
|
|
|
- console.log(fileData);
|
|
|
|
- console.log(index);
|
|
|
|
- this.files.splice(index , 1);
|
|
|
|
|
|
+ } else {
|
|
|
|
+ //validate in pdf type file in create mode
|
|
|
|
+ if(this.files[index].file_type != 'pdf') {
|
|
|
|
+ this.toastr.warning('يجب أن تكون صيفه الملف pdf !');
|
|
|
|
+ this.checkSaveClick = true;
|
|
|
|
+ } else {
|
|
|
|
+ this.checkSaveClick = false;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ console.log('files after change ',this.files);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+
|
|
|
|
+
|
|
changeDepartment(event, typeSelect) {
|
|
changeDepartment(event, typeSelect) {
|
|
console.log(event.target.value);
|
|
console.log(event.target.value);
|
|
if(typeSelect == 1) {
|
|
if(typeSelect == 1) {
|
|
@@ -190,47 +238,75 @@ export class AddRequestComponent implements OnInit {
|
|
console.log(this.dataForm.type);
|
|
console.log(this.dataForm.type);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ //delete row from table
|
|
|
|
+ onDeleteRow(index:number) {
|
|
|
|
+ this.files.splice(index , 1);
|
|
|
|
+ if(this.attachments_ids.length > 0) {
|
|
|
|
+ this.attachments_ids.splice(index, 1);
|
|
|
|
+ }
|
|
|
|
+ console.log('files after delete ',this.files);
|
|
|
|
+ console.log('attachements ids', this.attachments_ids);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
onSubmitted() {
|
|
onSubmitted() {
|
|
|
|
|
|
- //remove fileName from files and remove file is empty
|
|
|
|
|
|
+ this.addRequestFrom.value['departments_ids'] = [];
|
|
|
|
+
|
|
|
|
+ for(let i = 0; i < this.departmentsId.length; i++) {
|
|
|
|
+ this.addRequestFrom.value['departments_ids'][i] = this.departmentsId[i];
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ const editAttachements = [];
|
|
|
|
+
|
|
|
|
+ if(this.editMode) {
|
|
|
|
+
|
|
|
|
+ for(let i = 0; i < this.files.length; i++) {
|
|
|
|
+ for(let j = 0; j < this.attachments_ids.length; j++) {
|
|
|
|
+ if(this.files[i].id == this.attachments_ids[j]) {
|
|
|
|
+ editAttachements[i] = this.files[i];
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ } else {
|
|
|
|
+ //remove fileName from files and remove file is empty
|
|
for(let i = 0; i < this.files.length; i++) {
|
|
for(let i = 0; i < this.files.length; i++) {
|
|
- delete this.files[i].nameFile;
|
|
|
|
- if(this.files[i].file_type){
|
|
|
|
|
|
+ //delete this.files[i].nameFile;
|
|
|
|
+ if(this.files[i].file_type){
|
|
this.files[i].file_type = this.files[i].file_type.toLowerCase();
|
|
this.files[i].file_type = this.files[i].file_type.toLowerCase();
|
|
- }
|
|
|
|
- if(this.files[i].file == '') {
|
|
|
|
|
|
+ }
|
|
|
|
+ if(this.files[i].file == '') {
|
|
//this.files.splice(this.files.indexOf(this.files[i], 1));
|
|
//this.files.splice(this.files.indexOf(this.files[i], 1));
|
|
console.log('empty number ' , i);
|
|
console.log('empty number ' , i);
|
|
this.files.splice(i , 1);
|
|
this.files.splice(i , 1);
|
|
- }
|
|
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
+ console.log('after submitted form ', this.files);
|
|
|
|
+ this.addRequestFrom.value['attachments'] = this.files; //add files to form json
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
|
|
- console.log(this.files);
|
|
|
|
- this.addRequestFrom.value['attachments'] = this.files;
|
|
|
|
|
|
|
|
- //store departments in object save
|
|
|
|
- this.addRequestFrom.value['departments_ids'] = [];
|
|
|
|
|
|
|
|
- if(this.addRequestFrom.value['department1']) {
|
|
|
|
- console.log('1');
|
|
|
|
- this.addRequestFrom.value['departments_ids'].push(this.addRequestFrom.value['department1']);
|
|
|
|
- //delete this.addRequestFrom.value['department1'];
|
|
|
|
- }
|
|
|
|
- if(this.addRequestFrom.value['department2']) {
|
|
|
|
- console.log('2');
|
|
|
|
- this.addRequestFrom.value['departments_ids'].push(this.addRequestFrom.value['department2']);
|
|
|
|
- //delete this.addRequestFrom.value['department2'];
|
|
|
|
- }
|
|
|
|
- if(this.addRequestFrom.value['department3']) {
|
|
|
|
- console.log('3');
|
|
|
|
- this.addRequestFrom.value['departments_ids'].push(this.addRequestFrom.value['department3']);
|
|
|
|
- //delete this.addRequestFrom.value['department3'];
|
|
|
|
- }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
if(this.requestId) {
|
|
if(this.requestId) {
|
|
|
|
+ console.log('attachements ids after submitted' , this.attachments_ids);
|
|
|
|
+
|
|
//edit mode
|
|
//edit mode
|
|
- if(this.addRequestFrom.value['departments_ids'].length == 0 ) {
|
|
|
|
|
|
+ if(this.departmentsId.length == 0) {
|
|
this.toastr.warning('من فضلك ، قم بإختيار قسم كحد أدني !');
|
|
this.toastr.warning('من فضلك ، قم بإختيار قسم كحد أدني !');
|
|
} else if(this.addRequestFrom.value['type'] == 'fellowship' && this.addRequestFrom.value['registration_number'] == '') {
|
|
} else if(this.addRequestFrom.value['type'] == 'fellowship' && this.addRequestFrom.value['registration_number'] == '') {
|
|
this.toastr.warning('قم بإختيار رقم التسجيل !');
|
|
this.toastr.warning('قم بإختيار رقم التسجيل !');
|
|
@@ -242,52 +318,66 @@ export class AddRequestComponent implements OnInit {
|
|
this.toastr.warning('قم بإختيار نوع العقد !');
|
|
this.toastr.warning('قم بإختيار نوع العقد !');
|
|
} else if(this.addRequestFrom.value['type'] == 'fellowship' && this.addRequestFrom.value['organization_affiliated_with'] == '') {
|
|
} else if(this.addRequestFrom.value['type'] == 'fellowship' && this.addRequestFrom.value['organization_affiliated_with'] == '') {
|
|
this.toastr.warning('الجهه التابع لها المتدرب !');
|
|
this.toastr.warning('الجهه التابع لها المتدرب !');
|
|
- } else if(this.addRequestFrom.value['attachments'].length > 0){
|
|
|
|
- for(let i = 0; i < this.addRequestFrom.value['attachments'].length; i++) {
|
|
|
|
- if(this.addRequestFrom.value['attachments'][i].file_type != 'pdf' || this.addRequestFrom.value['attachments'][i].title == "") {
|
|
|
|
- this.toastr.warning( ' ان يكون صيغه الملف ' + 'PDF' + (i+1) );
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- delete this.addRequestFrom.value['department1'];
|
|
|
|
- delete this.addRequestFrom.value['department2'];
|
|
|
|
- delete this.addRequestFrom.value['department3'];
|
|
|
|
- console.log('successsss edit ' , this.addRequestFrom.value);
|
|
|
|
- // this.dashBoardSer.addItem(this.addRequestFrom.value,'request').subscribe(
|
|
|
|
- // (responce) => {
|
|
|
|
- // console.log(responce);
|
|
|
|
- // this.toastr.success('تم التعديل بنحاج');
|
|
|
|
- // },
|
|
|
|
- // (error) => {
|
|
|
|
- // console.log(error);
|
|
|
|
- // this.toastr.error('خطأ في التعديل !');
|
|
|
|
- // }
|
|
|
|
- // );
|
|
|
|
} else {
|
|
} else {
|
|
|
|
+ //store departments in object save
|
|
delete this.addRequestFrom.value['department1'];
|
|
delete this.addRequestFrom.value['department1'];
|
|
delete this.addRequestFrom.value['department2'];
|
|
delete this.addRequestFrom.value['department2'];
|
|
delete this.addRequestFrom.value['department3'];
|
|
delete this.addRequestFrom.value['department3'];
|
|
- console.log('successsss edit ' , this.addRequestFrom.value);
|
|
|
|
- // this.dashBoardSer.editItem(this.requestId, this.addRequestFrom.value,'request').subscribe(
|
|
|
|
- // (responce) => {
|
|
|
|
- // console.log(responce);
|
|
|
|
- // this.toastr.success('تم التعديل بنحاج');
|
|
|
|
- // },
|
|
|
|
- // (error) => {
|
|
|
|
- // console.log(error);
|
|
|
|
- // console.log(error.error['error']);
|
|
|
|
- // if(error.error['error'] == 'can not add new request untill old one done') {
|
|
|
|
- // this.toastr.warning('لا يمكن التعديل طلب جديد ، حتي يتم إجراءات علي الطلب السابق ، شكراً');
|
|
|
|
- // } else {
|
|
|
|
- // this.toastr.error('يوجد مشكله في السرفر ، سيتم معالجتها لاحقاً');
|
|
|
|
- // }
|
|
|
|
- // }
|
|
|
|
- // );
|
|
|
|
|
|
+ //access edit object of edit attachements (delete the increase data if user not hcnage file )
|
|
|
|
+ for(let i = 0; i < editAttachements.length; i++) {
|
|
|
|
+ if(editAttachements[i].file_type == '') {
|
|
|
|
+ delete editAttachements[i].file;
|
|
|
|
+ delete editAttachements[i].file_type;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ for(let i = 0; i < editAttachements.length; i++) {
|
|
|
|
+ delete editAttachements[i].nameFile;
|
|
|
|
+ }
|
|
|
|
+ this.addRequestFrom.value['editable_attachments'] = editAttachements;
|
|
|
|
+ for(let i = 0; i < editAttachements.length; i++) {
|
|
|
|
+ for(let j = 0; j < this.files.length; j++) {
|
|
|
|
+ if(editAttachements[i].id == this.files[j].id) {
|
|
|
|
+ this.files.splice(j , 1);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ this.addRequestFrom.value['editable_attachments'] = editAttachements;
|
|
|
|
+ this.addRequestFrom.value['attachments'] = this.files;
|
|
|
|
+ this.addRequestFrom.value['attachments_ids'] = this.attachments_ids;
|
|
|
|
+
|
|
|
|
+ console.log('attachements ids', this.attachments_ids);
|
|
|
|
+ console.log('fillllllllllllllllles ', this.files);
|
|
|
|
+ console.log('ediiiiiit fillllllles', editAttachements);
|
|
|
|
+ console.log('ediiiiiiiiiiiiiiiiiiiite filllles ', editAttachements);
|
|
|
|
+ console.log('form value ', this.addRequestFrom.value);
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ this.dashBoardSer.editItem(this.requestId, this.addRequestFrom.value,'request').subscribe(
|
|
|
|
+ (responce) => {
|
|
|
|
+ console.log(responce);
|
|
|
|
+ this.toastr.success('تم التعديل بنحاج');
|
|
|
|
+ this.location.back();
|
|
|
|
+ },
|
|
|
|
+ (error) => {
|
|
|
|
+ console.log(error);
|
|
|
|
+ console.log(error.error['error']);
|
|
|
|
+ if(error.error['error'] == 'can not add new request untill old one done') {
|
|
|
|
+ this.toastr.warning('لا يمكن التعديل طلب جديد ، حتي يتم إجراءات علي الطلب السابق ، شكراً');
|
|
|
|
+
|
|
|
|
+ } else {
|
|
|
|
+ this.toastr.error('يوجد مشكله في السرفر ، سيتم معالجتها لاحقاً');
|
|
|
|
+ this.location.back();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ );
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
|
|
|
|
this.addRequestFrom.value['user_id'] = this.visitorId;//add id of user in object
|
|
this.addRequestFrom.value['user_id'] = this.visitorId;//add id of user in object
|
|
//add mode
|
|
//add mode
|
|
- if(this.addRequestFrom.value['departments_ids'].length == 0 ) {
|
|
|
|
|
|
+ if(this.departmentsId.length == 0) {
|
|
this.toastr.warning('من فضلك ، قم بإختيار قسم كحد أدني !');
|
|
this.toastr.warning('من فضلك ، قم بإختيار قسم كحد أدني !');
|
|
} else if(this.addRequestFrom.value['type'] == 'fellowship' && this.addRequestFrom.value['registration_number'] == '') {
|
|
} else if(this.addRequestFrom.value['type'] == 'fellowship' && this.addRequestFrom.value['registration_number'] == '') {
|
|
this.toastr.warning('قم بإختيار رقم التسجيل !');
|
|
this.toastr.warning('قم بإختيار رقم التسجيل !');
|
|
@@ -299,27 +389,9 @@ export class AddRequestComponent implements OnInit {
|
|
this.toastr.warning('قم بإختيار نوع العقد !');
|
|
this.toastr.warning('قم بإختيار نوع العقد !');
|
|
} else if(this.addRequestFrom.value['type'] == 'fellowship' && this.addRequestFrom.value['organization_affiliated_with'] == '') {
|
|
} else if(this.addRequestFrom.value['type'] == 'fellowship' && this.addRequestFrom.value['organization_affiliated_with'] == '') {
|
|
this.toastr.warning('الجهه التابع لها المتدرب !');
|
|
this.toastr.warning('الجهه التابع لها المتدرب !');
|
|
- } else if(this.addRequestFrom.value['attachments'].length > 0){
|
|
|
|
- for(let i = 0; i < this.addRequestFrom.value['attachments'].length; i++) {
|
|
|
|
- if(this.addRequestFrom.value['attachments'][i].file_type != 'pdf' || this.addRequestFrom.value['attachments'][i].title == "") {
|
|
|
|
- this.toastr.warning( ' ان يكون صيغه الملف ' + 'PDF' + (i+1) );
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- delete this.addRequestFrom.value['department1'];
|
|
|
|
- delete this.addRequestFrom.value['department2'];
|
|
|
|
- delete this.addRequestFrom.value['department3'];
|
|
|
|
- console.log('successsss save ' , this.addRequestFrom.value);
|
|
|
|
- this.dashBoardSer.addItem(this.addRequestFrom.value,'request').subscribe(
|
|
|
|
- (responce) => {
|
|
|
|
- console.log(responce);
|
|
|
|
- this.toastr.success('تم الإضافه بنحاج');
|
|
|
|
- },
|
|
|
|
- (error) => {
|
|
|
|
- console.log(error);
|
|
|
|
- this.toastr.error('خطأ في الإضافه !');
|
|
|
|
- }
|
|
|
|
- );
|
|
|
|
} else {
|
|
} else {
|
|
|
|
+
|
|
|
|
+ //store departments in object save
|
|
delete this.addRequestFrom.value['department1'];
|
|
delete this.addRequestFrom.value['department1'];
|
|
delete this.addRequestFrom.value['department2'];
|
|
delete this.addRequestFrom.value['department2'];
|
|
delete this.addRequestFrom.value['department3'];
|
|
delete this.addRequestFrom.value['department3'];
|
|
@@ -328,6 +400,8 @@ export class AddRequestComponent implements OnInit {
|
|
(responce) => {
|
|
(responce) => {
|
|
console.log(responce);
|
|
console.log(responce);
|
|
this.toastr.success('تم الإضافه بنحاج');
|
|
this.toastr.success('تم الإضافه بنحاج');
|
|
|
|
+ this.addRequestFrom.reset();
|
|
|
|
+ this.location.back();
|
|
},
|
|
},
|
|
(error) => {
|
|
(error) => {
|
|
console.log(error);
|
|
console.log(error);
|