regester.component.ts 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633
  1. import { Modal } from 'ngx-modialog/plugins/bootstrap';
  2. import { Observable } from 'rxjs/Observable';
  3. import { AuthServiceService } from '../../shared/auth-service.service';
  4. import { UserService } from '../../shared/user.service';
  5. import { Component, OnInit, Injectable } from '@angular/core';
  6. import { NgForm, FormGroup, FormControl, Validators, FormControlName } from '@angular/forms';
  7. import { Router, ActivatedRoute, Params } from '@angular/router';
  8. import { ToastrService } from 'ngx-toastr';
  9. import { NgxSpinnerService } from 'ngx-spinner';
  10. import {
  11. NgbDate,NgbDateStruct, NgbCalendar, NgbCalendarIslamicUmalqura, NgbDatepickerI18n
  12. } from '@ng-bootstrap/ng-bootstrap';
  13. const WEEKDAYS = ['ن', 'ث', 'ر', 'خ', 'ج', 'س', 'ح'];
  14. const MONTHS = ['محرم', 'صفر', 'ربيع الأول', 'ربيع الآخر', 'جمادى الأولى', 'جمادى الآخرة', 'رجب', 'شعبان', 'رمضان', 'شوال',
  15. 'ذو القعدة', 'ذو الحجة'];
  16. @Injectable()
  17. export class IslamicI18n extends NgbDatepickerI18n {
  18. getWeekdayShortName(weekday: number) {
  19. return WEEKDAYS[weekday - 1];
  20. }
  21. getMonthShortName(month: number) {
  22. return MONTHS[month - 1];
  23. }
  24. getMonthFullName(month: number) {
  25. return MONTHS[month - 1];
  26. }
  27. getDayAriaLabel(date: NgbDateStruct): string {
  28. return `${date.day}-${date.month}-${date.year}`;
  29. }
  30. }
  31. @Component({
  32. selector: 'app-regester',
  33. templateUrl: './regester.component.html',
  34. styleUrls: ['./regester.component.css'],
  35. providers: [
  36. {provide: NgbCalendar, useClass: NgbCalendarIslamicUmalqura},
  37. {provide: NgbDatepickerI18n, useClass: IslamicI18n}
  38. ]
  39. })
  40. export class RegesterComponent implements OnInit {
  41. constructor(private userService: UserService,
  42. public authSer: AuthServiceService,
  43. private router: Router,
  44. private toastr: ToastrService,
  45. private spinner: NgxSpinnerService,
  46. private modal: Modal,
  47. private route: ActivatedRoute) { }
  48. files:any;
  49. regesterForm: FormGroup;
  50. myInnerHeight = window.innerHeight;
  51. min = '1990-01-31';
  52. adminstration = [];
  53. countries = [];
  54. jobTitils = [];
  55. specializations = [];
  56. contracts = [];
  57. staffs = [];
  58. departments = [];
  59. identities = [];
  60. urlImg: string = '../../../../assets/image/Group 299.png';
  61. showDepart: boolean = false;
  62. showStatus: boolean = false;
  63. checkChangeImage: boolean = false;
  64. imageBase64: string = '';
  65. photoType: string = '';
  66. userProfileId: number;
  67. identity_id: number = 0;
  68. identity_type: number;
  69. number_identitiy:number;
  70. year: any;
  71. month:any;
  72. day:any;
  73. checkShowSpanRequired: boolean = true;
  74. changesSave:boolean = false;
  75. typeMode:boolean = false;
  76. checkUserType:number;
  77. showTypeInput:boolean = true; //to show visitor or employee
  78. typeTitle:string = '';
  79. bindingDateSplit: any;
  80. data = {
  81. name: ''
  82. }
  83. ngOnInit() {
  84. this.authSer.showSearchHeader = false;
  85. this.authSer.notificationLogin = false;
  86. this.authSer.showDashboardHeader = true;
  87. this.authSer.arabicTemplate = true;
  88. this.typeTitle = 'تسجيل الدخول';
  89. this.route.params.subscribe(
  90. (params:Params) => {
  91. this.userProfileId = params['idProfile'];
  92. if(this.userProfileId) {
  93. this.showTypeInput = false;
  94. } else {
  95. this.showTypeInput = true;
  96. }
  97. }
  98. );
  99. //start regester form with default employee
  100. this.regesterForm = new FormGroup({
  101. name: new FormControl(null, Validators.required),
  102. type: new FormControl('0'),
  103. identity_type_id: new FormControl(null, [Validators.required]),
  104. identity_number: new FormControl(null, Validators.required),
  105. position: new FormControl(null, Validators.required),
  106. email: new FormControl(null, [Validators.required,Validators.email]),
  107. password: new FormControl(null, [Validators.required, Validators.minLength(6)]),
  108. password_confirmation: new FormControl(null, [Validators.required, Validators.minLength(6)]),
  109. phone: new FormControl(null, Validators.required),
  110. gender: new FormControl(null, Validators.required),
  111. birthday: new FormControl(null, Validators.required),
  112. adminstration_id: new FormControl(null, Validators.required),
  113. department_id: new FormControl(null, Validators.required),
  114. nationality_id: new FormControl(null, Validators.required),
  115. date_of_employment_gre: new FormControl(null, Validators.required),
  116. date_of_employment_hij: new FormControl(null,Validators.required),
  117. job_title_id: new FormControl(null),
  118. specialization_id: new FormControl(null),
  119. functional_number: new FormControl(null, Validators.required),
  120. contract_type_id: new FormControl(null),
  121. staff_id: new FormControl(null),
  122. });
  123. //get adminstration
  124. this.userService.getAdministration().subscribe(
  125. (responce) => {
  126. console.log(responce);
  127. this.adminstration = responce['adminstrations'];
  128. },
  129. (error) => {console.log(error)}
  130. );
  131. //get nationality
  132. this.userService.getNationality().subscribe(
  133. (responce) => {
  134. console.log(responce);
  135. this.countries = responce['countries'];
  136. },
  137. (error) => {
  138. console.log(error);
  139. }
  140. );
  141. //get job titile
  142. this.userService.getJobTitle().subscribe(
  143. (responce) => {
  144. console.log(responce);
  145. this.jobTitils = responce['job_titles'];
  146. },
  147. (error) =>{console.log(error)}
  148. );
  149. //get specialization
  150. this.userService.getSpecialization().subscribe(
  151. (responce) => {
  152. console.log(responce);
  153. this.specializations = responce['specialization'];
  154. },
  155. (error) => {
  156. console.log(error);
  157. }
  158. );
  159. //get contract list
  160. this.userService.getContract().subscribe(
  161. (responce) => {
  162. console.log(responce);
  163. this.contracts = responce['contract_types'];
  164. }
  165. );
  166. //get staff list
  167. this.userService.getStaff().subscribe(
  168. (responce) => {
  169. console.log(responce);
  170. this.staffs = responce['staff'];
  171. }
  172. );
  173. //get identites
  174. this.userService.onGetIdentities().subscribe(
  175. (responce) => {
  176. this.identities = responce['identities'];
  177. console.log('idddentiiiesssssssssss', this.identities);
  178. },
  179. (error) => {
  180. console.log(error);
  181. }
  182. );
  183. //profile edit
  184. if(this.userProfileId) {
  185. this.typeTitle = 'صفحتي';
  186. //show / hide notification search in header
  187. this.checkShowSpanRequired = false;
  188. this.authSer.notificationLogin = true;
  189. this.authSer.showSearchHeader = false;
  190. this.authSer.showHeaderLogin = false;
  191. this.authSer.showHeaderDashBoard = true;
  192. this.authSer.showDashboardHeader = true;
  193. this.authSer.internalHeader = false;
  194. this.showStatus = false;
  195. this.typeMode = true;
  196. this.authSer.notificationLogin = true;
  197. this.spinner.show();
  198. this.userService.onGetUserData(this.userProfileId, 'editUs').subscribe(
  199. (responce) => {
  200. console.log('userDataaaa', responce['user']);
  201. this.data.name = responce['user'].name;
  202. if(responce['user'].type == 1) {
  203. //visitor case
  204. this.regesterForm = new FormGroup({
  205. name: new FormControl(null, Validators.required),
  206. type: new FormControl('1'),
  207. identity_type_id: new FormControl(null, [Validators.required]),
  208. identity_number: new FormControl(null, Validators.required),
  209. email: new FormControl(null, [Validators.required,Validators.email]),
  210. phone: new FormControl(null,Validators.required),
  211. password: new FormControl(null, [Validators.required, Validators.minLength(6)]),
  212. password_confirmation: new FormControl(null, [Validators.required, Validators.minLength(6)]),
  213. gender: new FormControl(null, Validators.required),
  214. birthday: new FormControl(null, Validators.required),
  215. nationality_id: new FormControl(null, Validators.required),
  216. });
  217. this.regesterForm.patchValue({
  218. name: responce['user'].name,
  219. type: responce['user'].type,
  220. identity_type_id: responce['user'].identity_type_id,
  221. identity_number: responce['user'].identity_number,
  222. email: responce['user'].email,
  223. gender: responce['user'].gender,
  224. birthday: responce['user'].birthday,
  225. nationality_id: responce['user'].nationality_id,
  226. phone: responce['user'].phone,
  227. });
  228. console.log('image profile' , this.authSer.pathImg + responce['user'].photo);
  229. this.urlImg = responce['user'].photo ? this.authSer.pathImg + responce['user'].photo : '../../assets/image/avatar.png';
  230. this.spinner.hide();
  231. } else if(responce['user'].type == 0){
  232. //employee case
  233. this.regesterForm = new FormGroup({
  234. name: new FormControl(null, Validators.required),
  235. type: new FormControl('1'),
  236. identity_type_id: new FormControl(null, [Validators.required]),
  237. identity_number: new FormControl(null, Validators.required),
  238. position: new FormControl(null, Validators.required),
  239. email: new FormControl(null, [Validators.required,Validators.email]),
  240. password: new FormControl(null, [Validators.minLength(6)]),
  241. password_confirmation: new FormControl(null, [Validators.minLength(6)]),
  242. phone: new FormControl(null,Validators.required),
  243. gender: new FormControl(null, Validators.required),
  244. birthday: new FormControl(null, Validators.required),
  245. adminstration_id: new FormControl(null, Validators.required),
  246. department_id: new FormControl(null, Validators.required),
  247. nationality_id: new FormControl(null, Validators.required),
  248. date_of_employment_gre: new FormControl(null, Validators.required),
  249. date_of_employment_hij: new FormControl(null,Validators.required),
  250. job_title_id: new FormControl(null),
  251. specialization_id: new FormControl(null),
  252. functional_number: new FormControl(null, Validators.required),
  253. contract_type_id: new FormControl(null),
  254. staff_id: new FormControl(null),
  255. status: new FormControl(null, Validators.required),
  256. });
  257. const date = responce['user'].date_of_employment_hij.split('-');
  258. this.bindingDateSplit = {
  259. 'year': parseInt(date[0]),
  260. 'month': parseInt(date[1]),
  261. 'day': parseInt(date[2])
  262. };
  263. console.log('vaaaaaaaaal', this.bindingDateSplit);
  264. this.regesterForm.patchValue({
  265. name: responce['user'].name,
  266. type: responce['user'].type,
  267. identity_type_id: responce['user'].identity_type_id,
  268. identity_number: responce['user'].identity_number,
  269. email: responce['user'].email,
  270. position: responce['user'].position,
  271. phone: responce['user'].phone,
  272. gender: responce['user'].gender,
  273. birthday: responce['user'].birthday,
  274. adminstration_id: responce['user'].adminstration_id,
  275. department_id: responce['user'].department_id,
  276. nationality_id: responce['user'].nationality_id,
  277. date_of_employment_gre: responce['user'].date_of_employment_gre,
  278. job_title_id: responce['user'].job_title_id,
  279. specialization_id: responce['user'].specialization_id,
  280. contract_type_id: responce['user'].contract_type_id,
  281. staff_id: responce['user'].staff_id,
  282. functional_number: responce['user'].functional_number,
  283. status: responce['user'].status,
  284. date_of_employment_hij: this.bindingDateSplit, //responce['user'].date_of_employment_hij//
  285. });
  286. console.log(this.bindingDateSplit);
  287. this.getDepartment();
  288. console.log('image profile' , this.authSer.pathImg + responce['user'].photo);
  289. this.urlImg = responce['user'].photo ? this.authSer.pathImg + responce['user'].photo : '../../assets/image/avatar.png';
  290. this.spinner.hide();
  291. }
  292. },
  293. (error) => {
  294. console.log(error);
  295. }
  296. )
  297. };
  298. }
  299. //get departmants
  300. getDepartment() {
  301. const adminstrationId = this.regesterForm.get('adminstration_id').value;
  302. console.log(adminstrationId);
  303. this.userService.getDepartments(adminstrationId).subscribe(
  304. (responce) => {
  305. console.log(responce);
  306. this.departments = responce['departments'];
  307. this.showDepart = true;
  308. }
  309. );
  310. }
  311. getSelectedOptionText(event){
  312. console.log(event.target.value);
  313. this.identity_id = event.target.value;
  314. this.identity_type = event.target.value;
  315. }
  316. //validatiors return funcrtion
  317. get password() {
  318. return this.regesterForm.get('password');
  319. }
  320. //validatiors return funcrtion
  321. get phone() {
  322. return this.regesterForm.get('phone');
  323. }
  324. get repeatPassword() {
  325. return this.regesterForm.get('password_confirmation');
  326. }
  327. get identityNumber() {
  328. return this.regesterForm.get('identity_number');
  329. }
  330. onFileChanges(event) {
  331. console.log(event);
  332. this.imageBase64 = event[0].base64;
  333. this.photoType = event[0].type.split('/');
  334. console.log(this.photoType[1]);
  335. console.log(this.imageBase64);
  336. this.checkChangeImage = true;
  337. }
  338. getUrl(event) {
  339. if (event.target.files && event.target.files[0]) {
  340. var reader = new FileReader();
  341. reader.readAsDataURL(event.target.files[0]); // read file as data url
  342. reader.onload = (event) => { // called once readAsDataURL is completed
  343. this.urlImg = event.target['result'];
  344. }
  345. }
  346. }
  347. //identitiy input change
  348. onIdentitiyChange(event) {
  349. if(event.length >= 10) {
  350. this.identity_id = 0;
  351. } else {
  352. this.identity_id = this.identity_type;
  353. }
  354. }
  355. checkTypeUser(typeUser) {
  356. console.log(typeUser.target.value);
  357. this.checkUserType = typeUser.target.value;
  358. if(typeUser.target.value == 1) {
  359. this.regesterForm = new FormGroup({
  360. name: new FormControl(null, Validators.required),
  361. type: new FormControl('1'),
  362. identity_type_id: new FormControl(null, [Validators.required]),
  363. identity_number: new FormControl(null, Validators.required),
  364. email: new FormControl(null, [Validators.required,Validators.email]),
  365. password: new FormControl(null, [Validators.required, Validators.minLength(6)]),
  366. password_confirmation: new FormControl(null, [Validators.required, Validators.minLength(6)]),
  367. gender: new FormControl(null, Validators.required),
  368. birthday: new FormControl(null, Validators.required),
  369. nationality_id: new FormControl(null, Validators.required),
  370. phone: new FormControl(null, Validators.required),
  371. });
  372. } else {
  373. this.regesterForm = new FormGroup({
  374. name: new FormControl(null, Validators.required),
  375. type: new FormControl('0'),
  376. identity_type_id: new FormControl(null, [Validators.required]),
  377. identity_number: new FormControl(null, Validators.required),
  378. position: new FormControl(null, Validators.required),
  379. email: new FormControl(null, [Validators.required,Validators.email]),
  380. password: new FormControl(null, [Validators.required, Validators.minLength(6)]),
  381. password_confirmation: new FormControl(null, [Validators.required, Validators.minLength(6)]),
  382. phone: new FormControl(null, Validators.required),
  383. gender: new FormControl(null, Validators.required),
  384. birthday: new FormControl(null, Validators.required),
  385. adminstration_id: new FormControl(null, Validators.required),
  386. department_id: new FormControl(null, Validators.required),
  387. nationality_id: new FormControl(null, Validators.required),
  388. date_of_employment_gre: new FormControl(null, Validators.required),
  389. date_of_employment_hij: new FormControl(null,Validators.required),
  390. job_title_id: new FormControl(null),
  391. specialization_id: new FormControl(null),
  392. functional_number: new FormControl(null, Validators.required),
  393. contract_type_id: new FormControl(null),
  394. staff_id: new FormControl(null),
  395. });
  396. }
  397. }
  398. //submitted form
  399. onSubmittedForm() {
  400. this.changesSave = true;
  401. const userDataRegester = this.regesterForm.value;
  402. let joinJobDate;
  403. if(userDataRegester['type'] == '0') {
  404. userDataRegester['date_of_employment_hij'] = userDataRegester['date_of_employment_hij'].year + '-' + userDataRegester['date_of_employment_hij'].month + '-' + userDataRegester['date_of_employment_hij'].day;
  405. joinJobDate = userDataRegester['date_of_employment_gre'].split('-')[0];
  406. }
  407. userDataRegester['identity_number'] = userDataRegester['identity_number'].toString();
  408. console.log('valueee' , userDataRegester);
  409. const birthDate = userDataRegester['birthday'].split('-')[0];
  410. if(this.checkChangeImage) {
  411. userDataRegester['photo'] = this.imageBase64;
  412. userDataRegester['photo_type'] = this.photoType[1];
  413. }
  414. console.log(userDataRegester);
  415. if(this.userProfileId) {
  416. userDataRegester['id'] = this.userProfileId;
  417. console.log('dataaaaaaaaaaaa', userDataRegester);
  418. if(this.checkUserType == 1) {
  419. //edit profile visitor submited
  420. if(this.regesterForm.get('password').value != this.regesterForm.get('password_confirmation').value){
  421. this.toastr.warning(' من فضلك , تأكد أن كلمه المورو نفس تأكيد كلمه المرور!');
  422. }else if(this.regesterForm.get('identity_number').value.substring(0,1) != 1 && this.regesterForm.get('identity_type_id').value == 1){
  423. this.toastr.warning('رقم الهويه يجب ان يبدأ ب رقم 1');
  424. } else if(this.regesterForm.get('identity_number').value.substring(0,1) != 2 && this.regesterForm.get('identity_type_id').value == 3){
  425. this.toastr.warning('رقم الهويه يجب ان يبدأ ب رقم 2');
  426. } else if(this.regesterForm.get('phone').value.substring(0,2) != '05') {
  427. this.toastr.warning('رقم الجوال يجب أن يبدأ ب 05');
  428. } else {
  429. this.userService.onEditProfile(userDataRegester).subscribe(
  430. (responce) => {
  431. console.log(responce);
  432. this.toastr.success('تم التعديل بنجاح');
  433. },
  434. (error) => {
  435. console.log(error);
  436. this.toastr.error('فشل التعديل');
  437. if(error.error['error'].email) {
  438. this.toastr.warning('الايميل تم التسجيل به من قبل !');
  439. } else if(error.error['error'].identity_number) {
  440. this.toastr.warning('رقم الهويه تم التسجيل به من قبل !');
  441. }
  442. }
  443. );
  444. }
  445. } else {
  446. //edit profile employee submited
  447. if(this.regesterForm.get('password').value != this.regesterForm.get('password_confirmation').value){
  448. this.toastr.warning(' من فضلك , تأكد أن كلمه المورو نفس تأكيد كلمه المرور!');
  449. }else if(this.regesterForm.get('identity_number').value.substring(0,1) != 1 && this.regesterForm.get('identity_type_id').value == 1){
  450. this.toastr.warning('رقم الهويه يجب ان يبدأ ب رقم 1');
  451. } else if(this.regesterForm.get('identity_number').value.substring(0,1) != 2 && this.regesterForm.get('identity_type_id').value == 3){
  452. this.toastr.warning('رقم الهويه يجب ان يبدأ ب رقم 2');
  453. } else if(birthDate > joinJobDate) {
  454. this.toastr.warning('تارخ الميلاد أكبر من تاريخ التوظيف الميلادي !');
  455. } else if(this.regesterForm.get('phone').value.substring(0,2) != '05') {
  456. this.toastr.warning('رقم الجوال يجب أن يبدأ ب 05');
  457. } else {
  458. this.userService.onEditProfile(userDataRegester).subscribe(
  459. (responce) => {
  460. console.log(responce);
  461. this.toastr.success('تم التعديل بنجاح');
  462. },
  463. (error) => {
  464. console.log(error);
  465. this.toastr.error('فشل التعديل');
  466. if(error.error['error'].email) {
  467. this.toastr.warning('الايميل تم التسجيل به من قبل !');
  468. } else if(error.error['error'].identity_number) {
  469. this.toastr.warning('رقم الهويه تم التسجيل به من قبل !');
  470. }
  471. }
  472. );
  473. }
  474. }
  475. } else {
  476. userDataRegester['photo'] = this.imageBase64;
  477. userDataRegester['photo_type'] = this.photoType[1];
  478. console.log('dataaaaaaaaaaaa', userDataRegester);
  479. if(this.checkUserType == 1) {
  480. //visitor added submited
  481. if(this.regesterForm.get('password').value != this.regesterForm.get('password_confirmation').value){
  482. this.toastr.warning(' من فضلك تأكد أن كلمه المرور نفس تأكيد كلمه المرور !');
  483. } else if(this.imageBase64 == '') {
  484. this.toastr.warning('قم بإختيار صوره شخصيه !');
  485. } else if(this.regesterForm.get('phone').value.substring(0,2) != '05') {
  486. this.toastr.warning('رقم الجوال يجب أن يبدأ ب 05');
  487. } else if(userDataRegester['identity_number'].substring(0,1) != 1 && this.regesterForm.get('identity_type_id').value == 1){
  488. this.toastr.warning('رقم الهويه يجب ان يبدأ ب رقم 1');
  489. } else if(userDataRegester['identity_number'].substring(0,1) != 2 && this.regesterForm.get('identity_type_id').value == 3){
  490. this.toastr.warning('رقم الهويه يجب ان يبدأ ب رقم 2');
  491. } else {
  492. this.authSer.signUp(userDataRegester).subscribe(
  493. (responce) => {
  494. console.log(responce);
  495. this.toastr.success('تم اضافتك بنجاح ، من فضلك سجل الدخول')
  496. this.router.navigate(['auth/login']);
  497. },
  498. (error) => {
  499. console.log(error);
  500. if(error.error['error'].email) {
  501. this.toastr.warning('الايميل تم التسجيل به من قبل !');
  502. } else if(error.error['error'].identity_number) {
  503. this.toastr.warning('رقم الهويه تم التسجيل به من قبل !');
  504. }
  505. }
  506. );
  507. }
  508. } else {
  509. //employee added submited
  510. if(this.regesterForm.get('password').value != this.regesterForm.get('password_confirmation').value){
  511. this.toastr.warning(' من فضلك تأكد أن كلمه المرور نفس تأكيد كلمه المرور !');
  512. } else if(this.imageBase64 == '') {
  513. this.toastr.warning('قم بإختيار صوره شخصيه !');
  514. } else if(userDataRegester['identity_number'].substring(0,1) != 1 && this.regesterForm.get('identity_type_id').value == 1){
  515. this.toastr.warning('رقم الهويه يجب ان يبدأ ب رقم 1');
  516. } else if(userDataRegester['identity_number'].substring(0,1) != 2 && this.regesterForm.get('identity_type_id').value == 3){
  517. this.toastr.warning('رقم الهويه يجب ان يبدأ ب رقم 2');
  518. } else if(birthDate > joinJobDate) {
  519. this.toastr.warning('تارخ الميلاد أكبر من تاريخ التوظيف الميلادي !');
  520. } else if(this.regesterForm.get('phone').value.substring(0,2) != '05') {
  521. this.toastr.warning('رقم الجوال يجب أن يبدأ ب 05');
  522. }
  523. else {
  524. this.authSer.signUp(userDataRegester).subscribe(
  525. (responce) => {
  526. console.log(responce);
  527. this.toastr.success('تم اضافتك بنجاح ، من فضلك سجل الدخول')
  528. this.router.navigate(['auth/login']);
  529. },
  530. (error) => {
  531. console.log(error);
  532. if(error.error['error'].email) {
  533. this.toastr.warning('الايميل تم التسجيل به من قبل !');
  534. } else if(error.error['error'].identity_number) {
  535. this.toastr.warning('رقم الهويه تم التسجيل به من قبل !');
  536. }
  537. }
  538. );
  539. }
  540. }
  541. }
  542. }
  543. }