|
@@ -3,16 +3,45 @@ import { Observable } from 'rxjs/Observable';
|
|
import { AuthServiceService } from './../shared/auth-service.service';
|
|
import { AuthServiceService } from './../shared/auth-service.service';
|
|
import { UserService } from './../shared/user.service';
|
|
import { UserService } from './../shared/user.service';
|
|
import { Component, OnInit, Injectable } from '@angular/core';
|
|
import { Component, OnInit, Injectable } from '@angular/core';
|
|
-import { NgForm, FormGroup, FormControl, Validators } from '@angular/forms';
|
|
|
|
|
|
+import { NgForm, FormGroup, FormControl, Validators, FormControlName } from '@angular/forms';
|
|
import { Router, ActivatedRoute, Params } from '@angular/router';
|
|
import { Router, ActivatedRoute, Params } from '@angular/router';
|
|
import { ToastrService } from 'ngx-toastr';
|
|
import { ToastrService } from 'ngx-toastr';
|
|
import { NgxSpinnerService } from 'ngx-spinner';
|
|
import { NgxSpinnerService } from 'ngx-spinner';
|
|
|
|
+import {
|
|
|
|
+ NgbDate,NgbDateStruct, NgbCalendar, NgbCalendarIslamicUmalqura, NgbDatepickerI18n
|
|
|
|
+} from '@ng-bootstrap/ng-bootstrap';
|
|
|
|
+
|
|
|
|
+const WEEKDAYS = ['ن', 'ث', 'ر', 'خ', 'ج', 'س', 'ح'];
|
|
|
|
+const MONTHS = ['محرم', 'صفر', 'ربيع الأول', 'ربيع الآخر', 'جمادى الأولى', 'جمادى الآخرة', 'رجب', 'شعبان', 'رمضان', 'شوال',
|
|
|
|
+ 'ذو القعدة', 'ذو الحجة'];
|
|
|
|
+
|
|
|
|
+ @Injectable()
|
|
|
|
+ export class IslamicI18n extends NgbDatepickerI18n {
|
|
|
|
+ getWeekdayShortName(weekday: number) {
|
|
|
|
+ return WEEKDAYS[weekday - 1];
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ getMonthShortName(month: number) {
|
|
|
|
+ return MONTHS[month - 1];
|
|
|
|
+ }
|
|
|
|
|
|
|
|
+ getMonthFullName(month: number) {
|
|
|
|
+ return MONTHS[month - 1];
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ getDayAriaLabel(date: NgbDateStruct): string {
|
|
|
|
+ return `${date.day}-${date.month}-${date.year}`;
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
|
|
@Component({
|
|
@Component({
|
|
selector: 'app-regester',
|
|
selector: 'app-regester',
|
|
templateUrl: './regester.component.html',
|
|
templateUrl: './regester.component.html',
|
|
styleUrls: ['./regester.component.css'],
|
|
styleUrls: ['./regester.component.css'],
|
|
|
|
+ providers: [
|
|
|
|
+ {provide: NgbCalendar, useClass: NgbCalendarIslamicUmalqura},
|
|
|
|
+ {provide: NgbDatepickerI18n, useClass: IslamicI18n}
|
|
|
|
+ ]
|
|
})
|
|
})
|
|
|
|
|
|
|
|
|
|
@@ -56,7 +85,6 @@ export class RegesterComponent implements OnInit {
|
|
changesSave:boolean = false;
|
|
changesSave:boolean = false;
|
|
typeMode:boolean = false;
|
|
typeMode:boolean = false;
|
|
typeTitle:string = '';
|
|
typeTitle:string = '';
|
|
- higriDateVal = "";
|
|
|
|
bindingDateSplit: any;
|
|
bindingDateSplit: any;
|
|
data = {
|
|
data = {
|
|
name: ''
|
|
name: ''
|
|
@@ -97,6 +125,7 @@ export class RegesterComponent implements OnInit {
|
|
department_id: new FormControl(null, Validators.required),
|
|
department_id: new FormControl(null, Validators.required),
|
|
nationality_id: new FormControl(null, Validators.required),
|
|
nationality_id: new FormControl(null, Validators.required),
|
|
date_of_employment_gre: new FormControl(null, Validators.required),
|
|
date_of_employment_gre: new FormControl(null, Validators.required),
|
|
|
|
+ date_of_employment_hij: new FormControl(null,Validators.required),
|
|
job_title_id: new FormControl(null),
|
|
job_title_id: new FormControl(null),
|
|
specialization_id: new FormControl(null),
|
|
specialization_id: new FormControl(null),
|
|
functional_number: new FormControl(null, Validators.required),
|
|
functional_number: new FormControl(null, Validators.required),
|
|
@@ -202,7 +231,7 @@ export class RegesterComponent implements OnInit {
|
|
department_id: new FormControl(null, Validators.required),
|
|
department_id: new FormControl(null, Validators.required),
|
|
nationality_id: new FormControl(null, Validators.required),
|
|
nationality_id: new FormControl(null, Validators.required),
|
|
date_of_employment_gre: new FormControl(null, Validators.required),
|
|
date_of_employment_gre: new FormControl(null, Validators.required),
|
|
- //date_of_employment_hij: new FormControl(null, Validators.required),
|
|
|
|
|
|
+ date_of_employment_hij: new FormControl(null,Validators.required),
|
|
job_title_id: new FormControl(null),
|
|
job_title_id: new FormControl(null),
|
|
specialization_id: new FormControl(null),
|
|
specialization_id: new FormControl(null),
|
|
functional_number: new FormControl(null, Validators.required),
|
|
functional_number: new FormControl(null, Validators.required),
|
|
@@ -219,6 +248,15 @@ export class RegesterComponent implements OnInit {
|
|
|
|
|
|
this.data.name = responce['user'].name;
|
|
this.data.name = responce['user'].name;
|
|
|
|
|
|
|
|
+ const date = responce['user'].date_of_employment_hij.split('-');
|
|
|
|
+ this.bindingDateSplit = {
|
|
|
|
+ 'year': parseInt(date[0]),
|
|
|
|
+ 'month': parseInt(date[1]),
|
|
|
|
+ 'day': parseInt(date[2])
|
|
|
|
+ };
|
|
|
|
+
|
|
|
|
+ console.log('vaaaaaaaaal', this.bindingDateSplit);
|
|
|
|
+
|
|
this.regesterForm.patchValue({
|
|
this.regesterForm.patchValue({
|
|
name: responce['user'].name,
|
|
name: responce['user'].name,
|
|
identity_type_id: responce['user'].identity_type_id,
|
|
identity_type_id: responce['user'].identity_type_id,
|
|
@@ -238,16 +276,11 @@ export class RegesterComponent implements OnInit {
|
|
staff_id: responce['user'].staff_id,
|
|
staff_id: responce['user'].staff_id,
|
|
functional_number: responce['user'].functional_number,
|
|
functional_number: responce['user'].functional_number,
|
|
status: responce['user'].status,
|
|
status: responce['user'].status,
|
|
|
|
+ date_of_employment_hij: this.bindingDateSplit, //responce['user'].date_of_employment_hij//
|
|
});
|
|
});
|
|
- const date = responce['user'].date_of_employment_hij.split('-');
|
|
|
|
-
|
|
|
|
- this.bindingDateSplit = {
|
|
|
|
- 'year': parseInt(date[0]),
|
|
|
|
- 'month': parseInt(date[1]),
|
|
|
|
- 'day': parseInt(date[2])
|
|
|
|
- };
|
|
|
|
|
|
+
|
|
|
|
|
|
- this.higriDateVal = responce['user'].date_of_employment_hij;
|
|
|
|
|
|
+ //this.higriDateVal = responce['user'].date_of_employment_hij;
|
|
console.log(this.bindingDateSplit);
|
|
console.log(this.bindingDateSplit);
|
|
|
|
|
|
this.getDepartment();
|
|
this.getDepartment();
|
|
@@ -334,11 +367,11 @@ export class RegesterComponent implements OnInit {
|
|
|
|
|
|
|
|
|
|
//get value date from child component
|
|
//get value date from child component
|
|
- public getDate(date: any):void {
|
|
|
|
- console.log( date);
|
|
|
|
- this.higriDateVal = date.year + '-' + date.month + '-' + date.day;
|
|
|
|
- console.log('higrii date', this.higriDateVal);
|
|
|
|
- }
|
|
|
|
|
|
+ // public getDate(date: any):void {
|
|
|
|
+ // console.log( date);
|
|
|
|
+ // this.higriDateVal = date.year + '-' + date.month + '-' + date.day;
|
|
|
|
+ // console.log('higrii date', this.higriDateVal);
|
|
|
|
+ // }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@@ -351,18 +384,20 @@ export class RegesterComponent implements OnInit {
|
|
this.changesSave = true;
|
|
this.changesSave = true;
|
|
console.log(this.regesterForm);
|
|
console.log(this.regesterForm);
|
|
const userDataRegester = this.regesterForm.value;
|
|
const userDataRegester = this.regesterForm.value;
|
|
- console.log(userDataRegester);
|
|
|
|
|
|
+ userDataRegester['date_of_employment_hij'] = userDataRegester['date_of_employment_hij'].year + '-' + userDataRegester['date_of_employment_hij'].month + '-' + userDataRegester['date_of_employment_hij'].day;
|
|
|
|
+ userDataRegester['identity_number'] = userDataRegester['identity_number'].toString();
|
|
|
|
+ console.log('valueee' , userDataRegester);
|
|
|
|
|
|
const birthDate = userDataRegester['birthday'].split('-')[0];
|
|
const birthDate = userDataRegester['birthday'].split('-')[0];
|
|
const joinJobDate = userDataRegester['date_of_employment_gre'].split('-')[0];
|
|
const joinJobDate = userDataRegester['date_of_employment_gre'].split('-')[0];
|
|
|
|
|
|
|
|
+
|
|
if(this.checkChangeImage) {
|
|
if(this.checkChangeImage) {
|
|
userDataRegester['photo'] = this.imageBase64;
|
|
userDataRegester['photo'] = this.imageBase64;
|
|
userDataRegester['photo_type'] = this.photoType[1];
|
|
userDataRegester['photo_type'] = this.photoType[1];
|
|
}
|
|
}
|
|
|
|
|
|
const userData = this.regesterForm.value;
|
|
const userData = this.regesterForm.value;
|
|
- userData['date_of_employment_hij'] = this.higriDateVal;
|
|
|
|
|
|
|
|
|
|
|
|
if(this.userProfileId) {
|
|
if(this.userProfileId) {
|
|
@@ -370,10 +405,7 @@ export class RegesterComponent implements OnInit {
|
|
console.log('dataaaaaaaaaaaa', userDataRegester);
|
|
console.log('dataaaaaaaaaaaa', userDataRegester);
|
|
if(this.regesterForm.get('password').value != this.regesterForm.get('password_confirmation').value){
|
|
if(this.regesterForm.get('password').value != this.regesterForm.get('password_confirmation').value){
|
|
this.toastr.warning(' من فضلك , تأكد أن كلمه المورو نفس تأكيد كلمه المرور!');
|
|
this.toastr.warning(' من فضلك , تأكد أن كلمه المورو نفس تأكيد كلمه المرور!');
|
|
- } else if(this.higriDateVal == "") {
|
|
|
|
- this.toastr.warning('من فضلك أدخل تاريخ التوظيف الهجري !');
|
|
|
|
- }
|
|
|
|
- else if(this.regesterForm.get('identity_number').value.substring(0,1) != 1 && this.regesterForm.get('identity_type_id').value == 1){
|
|
|
|
|
|
+ }else if(this.regesterForm.get('identity_number').value.substring(0,1) != 1 && this.regesterForm.get('identity_type_id').value == 1){
|
|
this.toastr.warning('رقم الهويه يجب ان يبدأ ب رقم 1');
|
|
this.toastr.warning('رقم الهويه يجب ان يبدأ ب رقم 1');
|
|
} else if(this.regesterForm.get('identity_number').value.substring(0,1) != 2 && this.regesterForm.get('identity_type_id').value == 3){
|
|
} else if(this.regesterForm.get('identity_number').value.substring(0,1) != 2 && this.regesterForm.get('identity_type_id').value == 3){
|
|
this.toastr.warning('رقم الهويه يجب ان يبدأ ب رقم 2');
|
|
this.toastr.warning('رقم الهويه يجب ان يبدأ ب رقم 2');
|
|
@@ -404,11 +436,9 @@ export class RegesterComponent implements OnInit {
|
|
console.log('dataaaaaaaaaaaa', userDataRegester);
|
|
console.log('dataaaaaaaaaaaa', userDataRegester);
|
|
if(this.regesterForm.get('password').value != this.regesterForm.get('password_confirmation').value){
|
|
if(this.regesterForm.get('password').value != this.regesterForm.get('password_confirmation').value){
|
|
this.toastr.warning(' من فضلك تأكد أن كلمه المرور نفس تأكيد كلمه المرور !');
|
|
this.toastr.warning(' من فضلك تأكد أن كلمه المرور نفس تأكيد كلمه المرور !');
|
|
- } else if(this.higriDateVal = "") {
|
|
|
|
- this.toastr.warning('من فضلك أدخل تاريخ التوظيف الهجري !');
|
|
|
|
- } else if(this.regesterForm.get('identity_number').value.substring(0,1) != 1 && this.regesterForm.get('identity_type_id').value == 1){
|
|
|
|
|
|
+ } else if(userDataRegester['identity_number'].substring(0,1) != 1 && this.regesterForm.get('identity_type_id').value == 1){
|
|
this.toastr.warning('رقم الهويه يجب ان يبدأ ب رقم 1');
|
|
this.toastr.warning('رقم الهويه يجب ان يبدأ ب رقم 1');
|
|
- } else if(this.regesterForm.get('identity_number').value.substring(0,1) != 2 && this.regesterForm.get('identity_type_id').value == 3){
|
|
|
|
|
|
+ } else if(userDataRegester['identity_number'].substring(0,1) != 2 && this.regesterForm.get('identity_type_id').value == 3){
|
|
this.toastr.warning('رقم الهويه يجب ان يبدأ ب رقم 2');
|
|
this.toastr.warning('رقم الهويه يجب ان يبدأ ب رقم 2');
|
|
} else if(birthDate > joinJobDate) {
|
|
} else if(birthDate > joinJobDate) {
|
|
this.toastr.warning('تارخ الميلاد أكبر من تاريخ التوظيف الميلادي !');
|
|
this.toastr.warning('تارخ الميلاد أكبر من تاريخ التوظيف الميلادي !');
|