|
@@ -36,6 +36,7 @@ export class ViewMyFemaleRequestsAddComponent implements OnInit {
|
|
|
refusedCheak = false;
|
|
|
statusAccept : boolean;
|
|
|
statusrefu: boolean;
|
|
|
+ comfoe: string = 'جديد';
|
|
|
toster: string;
|
|
|
tookDes = false;
|
|
|
employeeId: string;
|
|
@@ -46,6 +47,9 @@ export class ViewMyFemaleRequestsAddComponent implements OnInit {
|
|
|
isBuilding: boolean = false;
|
|
|
isComplex: boolean = false;
|
|
|
isBuildingType: boolean = false;
|
|
|
+ userInfo: any;
|
|
|
+ addNew: boolean = false;
|
|
|
+ page__title: string;
|
|
|
constructor(
|
|
|
private dashBoardSer: DashboardService,
|
|
|
private toastr: ToastrService,
|
|
@@ -91,6 +95,7 @@ export class ViewMyFemaleRequestsAddComponent implements OnInit {
|
|
|
}
|
|
|
|
|
|
ngOnInit() {
|
|
|
+ this.spinner.show()
|
|
|
//init the values of permision boolean
|
|
|
this.authSer.showAddBtn = false;
|
|
|
this.authSer.showDeleteBtn = false;
|
|
@@ -113,13 +118,13 @@ export class ViewMyFemaleRequestsAddComponent implements OnInit {
|
|
|
(params: Params) => {
|
|
|
this.editPageId = +params['editPageId'];
|
|
|
this.whoIsComing = params['type'];
|
|
|
+
|
|
|
console.log(this.editPageId);
|
|
|
|
|
|
}
|
|
|
);
|
|
|
- if(this.whoIsComing == 'AD74'){
|
|
|
- this.isAdmin = true;
|
|
|
- }
|
|
|
+
|
|
|
+
|
|
|
|
|
|
console.log('current page',this.pageId)
|
|
|
this.dashBoardSer.getRequestTypesList( 1 ,10000 , 'all', 'all', 'all').subscribe(
|
|
@@ -131,9 +136,13 @@ export class ViewMyFemaleRequestsAddComponent implements OnInit {
|
|
|
if (this.editPageId) {
|
|
|
this.spinner.show();
|
|
|
this.isEdit = true;
|
|
|
+ this.page__title = 'عرض طلباتي'
|
|
|
+
|
|
|
this.typePage = 'تعديل';
|
|
|
if(this.isAdmin){
|
|
|
this.typePage = 'عرض تفاصيل الطلب'
|
|
|
+ this.page__title = 'عرض طلبات المستأجر للأدارة'
|
|
|
+
|
|
|
|
|
|
}
|
|
|
this.dashBoardSer.getItemData(this.editPageId, 'femalesRequest' ).subscribe(
|
|
@@ -146,16 +155,30 @@ export class ViewMyFemaleRequestsAddComponent implements OnInit {
|
|
|
if(this.isAdmin){
|
|
|
this.adminForm.request_id = data.id;
|
|
|
}
|
|
|
+
|
|
|
this.adminForm.status = data.status;
|
|
|
if(this.adminForm.status != 'new'){
|
|
|
+ this.addNew = false;
|
|
|
this.tookDes = true;
|
|
|
- if(this.adminForm.status == 'accepted'){
|
|
|
+ if(this.adminForm.status == 'accepted' || this.adminForm.status == 'confirmed'){
|
|
|
this.statusAccept = true;
|
|
|
+ if(this.adminForm.status == 'accepted'){
|
|
|
+ this.comfoe = 'مقبول'
|
|
|
+ }else{
|
|
|
+ this.comfoe = 'مؤكد'
|
|
|
+ }
|
|
|
}else if(this.adminForm.status == 'refused'){
|
|
|
this.adminForm.status_description = data.status_description;
|
|
|
this.statusAccept = false;
|
|
|
this.statusrefu = true;
|
|
|
this.refusedCheak = true;
|
|
|
+ this.comfoe = 'مرفوض'
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ this.comfoe = 'جديد'
|
|
|
+ if(this.whoIsComing == 'AD74'){
|
|
|
+ this.isAdmin = true;
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
this.employeeId = data.employee_id;
|
|
@@ -167,7 +190,7 @@ export class ViewMyFemaleRequestsAddComponent implements OnInit {
|
|
|
this.userData.functional_number = res['user'].functional_number;
|
|
|
this.userData.phone = res['user'].phone;
|
|
|
this.userData.email = res['user'].email;
|
|
|
-
|
|
|
+
|
|
|
},
|
|
|
err =>{
|
|
|
console.log(err);
|
|
@@ -194,8 +217,8 @@ export class ViewMyFemaleRequestsAddComponent implements OnInit {
|
|
|
console.log(this.unitInformation.housing_complex_id );
|
|
|
this.getBuildingType(this.unitInformation.housing_complex_id);
|
|
|
this.unitInformation.building_type_id = unitInfo.building_type_id;
|
|
|
- this.getBuilding(this.unitInformation.building_type_id);
|
|
|
this.unitInformation.building_id = unitInfo.building_id;
|
|
|
+ this.getBuilding(this.unitInformation.building_type_id);
|
|
|
this.unitInformation.unit_id = unitInfo.unit_id;
|
|
|
|
|
|
},
|
|
@@ -205,6 +228,18 @@ export class ViewMyFemaleRequestsAddComponent implements OnInit {
|
|
|
);
|
|
|
}else {
|
|
|
this.typePage = 'اضافة';
|
|
|
+ this.page__title = 'عرض طلباتي'
|
|
|
+ this.addNew = true;
|
|
|
+ this.tookDes = false;
|
|
|
+ this.userInfo= localStorage.getItem('userData')
|
|
|
+ this.userInfo = JSON.parse(this.userInfo);
|
|
|
+ console.log('user ',this.userInfo);
|
|
|
+ this.userData.name = this.userInfo.name;
|
|
|
+ this.userData.identity_number = this.userInfo.identity_number;
|
|
|
+ this.userData.functional_number = this.userInfo.functional_number;
|
|
|
+ this.userData.phone = this.userInfo.phone;
|
|
|
+ this.userData.email = this.userInfo.email;
|
|
|
+
|
|
|
}
|
|
|
|
|
|
this.spinner.hide();
|
|
@@ -369,7 +404,23 @@ getUnit(event){
|
|
|
|
|
|
|
|
|
this.disable = true;
|
|
|
-
|
|
|
+ if(this.addNew){
|
|
|
+ for (let i = 0; i < this.files.length; i++) {
|
|
|
+ if(this.files[i].file_type){
|
|
|
+ this.files[i].file_type = this.files[i].file_type.toLowerCase();
|
|
|
+ }
|
|
|
+ if(!this.files[i].file){
|
|
|
+ this.files.splice(i , 1);
|
|
|
+ }
|
|
|
+ else if(!this.files[i].title){
|
|
|
+ this.toastr.warning('ادخل عنوان الملف رقم ' + (i+1) );
|
|
|
+ return 0;
|
|
|
+ } else {
|
|
|
+ delete this.files[i].nameFile;
|
|
|
+ this.formData.files.push(this.files[i]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
if(this.isAdmin){
|
|
|
|
|
|
console.log(this.adminForm);
|
|
@@ -390,17 +441,7 @@ getUnit(event){
|
|
|
);
|
|
|
|
|
|
}else{
|
|
|
- if(this.files.length > 0){
|
|
|
- this.formData.files = this.files
|
|
|
- }
|
|
|
- if(this.require_attachments == '1'){
|
|
|
- if(this.formData.files.length <= 0){
|
|
|
- this.toastr.warning('يجب اضافة مرفق')
|
|
|
- this.disable = false;
|
|
|
-
|
|
|
- return 0;
|
|
|
- }
|
|
|
- }
|
|
|
+
|
|
|
if(this.require_date == '1'){
|
|
|
if(this.formData.return_date == null || this.formData.return_time == null){
|
|
|
this.toastr.warning('يجب اضافة وقت و تاريخ العوده')
|
|
@@ -415,6 +456,17 @@ getUnit(event){
|
|
|
}
|
|
|
}
|
|
|
if(this.editPageId) {
|
|
|
+ if(this.files.length > 0){
|
|
|
+ this.formData.files = this.files
|
|
|
+ }
|
|
|
+ if(this.require_attachments == '1'){
|
|
|
+ if(this.formData.files.length <= 0){
|
|
|
+ this.toastr.warning('يجب اضافة مرفق')
|
|
|
+ this.disable = false;
|
|
|
+
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+ }
|
|
|
this.dashBoardSer.editItem(this.editPageId, this.formData, 'editFemaleRequest').subscribe(
|
|
|
(responce) => {
|
|
|
this.disable = true;
|
|
@@ -429,6 +481,7 @@ getUnit(event){
|
|
|
}
|
|
|
)
|
|
|
} else {
|
|
|
+
|
|
|
this.dashBoardSer.addItem( this.formData , 'addFemaleRequest').subscribe(
|
|
|
(responce) => {
|
|
|
console.log('ADD',responce);
|
|
@@ -437,9 +490,12 @@ getUnit(event){
|
|
|
this.location.back();
|
|
|
},
|
|
|
(error) => {
|
|
|
- console.log(error);
|
|
|
+
|
|
|
this.checkSaveclick = false;
|
|
|
this.disable = false;
|
|
|
+ if (true) {
|
|
|
+
|
|
|
+ }
|
|
|
|
|
|
this.toastr.error('خطأ في الخادم ، حاول لاحقا');
|
|
|
}
|