Main application form restructuring(WIP)

parent 7ab03641
......@@ -123,7 +123,7 @@ class CASLogin extends ControllerBase
}
$attributes = phpCAS::getAttributes();
/*
/*
$isAllowed = true;
$att1 = $attributes[$this->allowed1];
$att2 = $attributes[$this->allowed2];
......@@ -150,8 +150,8 @@ class CASLogin extends ControllerBase
}
if (!$found1 || !$found2) {
$isAllowed = false;
}
}
if (!$isAllowed) {
$response = new Response();
$response->setContent(t('Access is allowed only to official school accounts'));
......@@ -302,4 +302,4 @@ class CASLogin extends ControllerBase
return false;
}
}
\ No newline at end of file
}
......@@ -68,6 +68,7 @@ class ApplicationSubmit extends ControllerBase {
], Response::HTTP_FORBIDDEN);
}
$student = array(
'langcode' => 'el',
'student_record_id' => 0,
......@@ -94,9 +95,10 @@ class ApplicationSubmit extends ControllerBase {
'certificatetype' => $applicationForm[0]['certificatetype'],
'graduation_year' => $applicationForm[0]['graduation_year'],
'lastschool_registrynumber' => $applicationForm[0]['lastschool_registrynumber'],
'lastschool_unittypeid' => $applicationForm[0]['lastschool_unittypeid'],
'lastschool_schoolname' => $applicationForm[0]['lastschool_schoolname'],
'lastschool_schoolyear' => $applicationForm[0]['lastschool_schoolyear'],
'lastschool_class' => $applicationForm[0]['lastschool_class'],
'currentepal' => $applicationForm[0]['currentepal'],
'currentclass' => $applicationForm[0]['currentclass'],
'guardian_name' => $applicationForm[0]['cu_name'],
'guardian_surname' => $applicationForm[0]['cu_surname'],
......@@ -111,6 +113,22 @@ class ApplicationSubmit extends ControllerBase {
return $this->respondWithStatus([
"error_code" => $errorCode ], Response::HTTP_OK);
}
$lastSchoolRegistryNumber = $student['lastschool_registrynumber'];
$lastSchoolYear = (int)(substr($student['lastschool_schoolyear'], -4));
if ((int)date("Y") === $lastSchoolYear && (int)$student['lastschool_unittypeid'] === 5) {
$epalSchools = $this->entityTypeManager->getStorage('eepal_school')->loadByProperties(array('registry_no' => $lastSchoolRegistryNumber));
$epalSchool = reset($epalSchools);
if (!$epalSchool){
return $this->respondWithStatus([
"error_code" => 4004
], Response::HTTP_FORBIDDEN);
} else {
$student['currentepal'] = $epalSchool->id();
}
} else {
$student['currentepal'] = 0;
}
$entity_storage_student = $this->entityTypeManager->getStorage('epal_student');
$entity_object = $entity_storage_student->create($student);
$entity_storage_student->save($entity_object);
......@@ -176,6 +194,9 @@ class ApplicationSubmit extends ControllerBase {
if(!$student["agreement"]) {
return 1001;
}
if(!$student["lastschool_schoolyear"] || strlen($student["lastschool_schoolyear"]) !== 9) {
return 1002;
}
return 0;
}
}
......@@ -1138,6 +1138,46 @@ class EpalStudent extends ContentEntityBase implements EpalStudentInterface
->setDisplayConfigurable('form', true)
->setDisplayConfigurable('view', true);
$fields['lastschool_unittypeid'] = BaseFieldDefinition::create('integer')
->setLabel(t('Τύπος τελευταίου σχολείου'))
->setDescription(t('Τύπος τελευταίου σχολείου'))
->setSettings(array(
'max_length' => 3,
'text_processing' => 0,
))
->setRequired(true)
->setDisplayOptions('view', array(
'label' => 'above',
'type' => 'string',
'weight' => -4,
))
->setDisplayOptions('form', array(
'type' => 'integer',
'weight' => -4,
))
->setDisplayConfigurable('form', true)
->setDisplayConfigurable('view', true);
$fields['lastschool_schoolname'] = BaseFieldDefinition::create('string')
->setLabel(t('Ονομασία τελευταίου σχολείου'))
->setDescription(t('Ονομασία τελευταίου σχολείου'))
->setSettings(array(
'max_length' => 200,
'text_processing' => 0,
))
->setRequired(true)
->setDisplayOptions('view', array(
'label' => 'above',
'type' => 'string',
'weight' => -4,
))
->setDisplayOptions('form', array(
'type' => 'string_textfield',
'weight' => -4,
))
->setDisplayConfigurable('form', true)
->setDisplayConfigurable('view', true);
$fields['lastschool_schoolyear'] = BaseFieldDefinition::create('string')
->setLabel(t('Σχολικό έτος φοίτησης τελευταίου σχολείου'))
->setDescription(t('Σχολικό έτος φοίτησης τελευταίου σχολείου'))
......
......@@ -7,6 +7,7 @@ import { NgReduxModule, DevToolsExtension, NgRedux } from 'ng2-redux';
import {BrowserModule} from '@angular/platform-browser';
import { CookieModule } from 'ngx-cookie';
import { MyDatePickerModule } from 'mydatepicker';
import { NguiAutoCompleteModule } from '@ngui/auto-complete';
import {
FormsModule,
ReactiveFormsModule,
......@@ -22,7 +23,6 @@ import {
} from '@angular/common';
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import Main from './containers/main';
import { APP_ROUTER_PROVIDERS, APP_DECLARATIONS } from './app.routes';
......@@ -60,6 +60,7 @@ class MyLocalization extends NgLocalization {
BrowserModule,
MyDatePickerModule,
FormsModule,
NguiAutoCompleteModule,
RouterModule,
ReactiveFormsModule,
APP_ROUTER_PROVIDERS,
......
import { Component, OnInit, OnDestroy } from '@angular/core';
import { BehaviorSubject, Subscription } from 'rxjs/Rx';
import { BehaviorSubject, Subscription, Observable } from 'rxjs/Rx';
import { Injectable } from "@angular/core";
import { Router } from '@angular/router';
import { NgRedux, select } from 'ng2-redux';
......@@ -8,12 +8,14 @@ import { IStudentDataFields } from '../../store/studentdatafields/studentdatafie
import { CriteriaActions } from '../../actions/criteria.actions';
import { ICriter } from '../../store/criteria/criteria.types';
import { IAppState } from '../../store/store';
import { VALID_NAMES_PATTERN, VALID_ADDRESS_PATTERN, VALID_ADDRESSTK_PATTERN, VALID_DIGITS_PATTERN, VALID_DATE_PATTERN } from '../../constants';
import { VALID_NAMES_PATTERN, VALID_ADDRESS_PATTERN, VALID_ADDRESSTK_PATTERN, VALID_DIGITS_PATTERN,
VALID_DATE_PATTERN, FIRST_SCHOOL_YEAR, VALID_YEAR_PATTERN, VALID_TELEPHONE_PATTERN } from '../../constants';
import { STUDENT_DATA_FIELDS_INITIAL_STATE } from '../../store/studentdatafields/studentdatafields.initial-state';
import { CRITERIA_INITIAL_STATE } from '../../store/criteria/criteria.initial-state';
import { ILoginInfo, ILoginInfoToken } from '../../store/logininfo/logininfo.types';
import { LOGININFO_INITIAL_STATE } from '../../store/logininfo/logininfo.initial-state';
import {IMyDpOptions} from 'mydatepicker';
import {Http, RequestOptions} from '@angular/http';
import {
FormBuilder,
......@@ -44,6 +46,8 @@ import {
private modalTitle: BehaviorSubject<string>;
private modalText: BehaviorSubject<string>;
private modalHeader: BehaviorSubject<string>;
private schoolyears: string[];
private graduationyears: string[];
private rss = new FormArray([]);
......@@ -54,11 +58,27 @@ import {
dateFormat: 'dd/mm/yyyy',
};
private observableSource = (keyword: any): Observable<any[]> => {
let url: string = 'https://mm.sch.gr/api/units?name='+keyword;
if (keyword) {
return this.http.get(url)
.map(res => {
let json = res.json();
return json.data;
})
} else {
return Observable.of([]);
}
}
constructor(private fb: FormBuilder,
private _sdfa: StudentDataFieldsActions,
private _sdfb: CriteriaActions,
private _ngRedux: NgRedux<IAppState>,
private router: Router) {
private router: Router,
private http: Http) {
this.populateSchoolyears();
this.populateGraduationyears();
this.loginInfo$ = new BehaviorSubject(LOGININFO_INITIAL_STATE);
this.modalTitle = new BehaviorSubject("");
this.modalText = new BehaviorSubject("");
......@@ -80,9 +100,14 @@ import {
regionarea: ['', [Validators.pattern(VALID_NAMES_PATTERN),Validators.required]],
certificatetype: ['', this.checkChoice],
relationtostudent: ['', this.checkChoice],
telnum: ['', [Validators.pattern(VALID_DIGITS_PATTERN),Validators.required]],
telnum: ['', [Validators.pattern(VALID_TELEPHONE_PATTERN),Validators.required]],
graduation_year: ['', this.checkChoice],
lastschool_schoolname: ['', [Validators.pattern(VALID_ADDRESS_PATTERN),Validators.required]],
lastschool_schoolyear: ['', this.checkChoice],
lastschool_class: ['', this.checkChoice],
});
/* this.studentCriteriaGroup = this.fb.group({
formArray: this.rss,
}); */
......@@ -105,6 +130,7 @@ import {
this.studentDataFieldsSub = this._ngRedux.select(state => {
if (state.studentDataFields.size > 0) {
state.studentDataFields.reduce(({}, studentDataField) => {
this.studentDataGroup.controls['name'].setValue(studentDataField.name);
this.studentDataGroup.controls['studentsurname'].setValue(studentDataField.studentsurname);
this.studentDataGroup.controls['fatherfirstname'].setValue(studentDataField.fatherfirstname);
......@@ -113,6 +139,10 @@ import {
this.studentDataGroup.controls['regiontk'].setValue(studentDataField.regiontk);
this.studentDataGroup.controls['regionarea'].setValue(studentDataField.regionarea);
this.studentDataGroup.controls['certificatetype'].setValue(studentDataField.certificatetype);
this.studentDataGroup.controls['graduation_year'].setValue(studentDataField.graduation_year);
this.studentDataGroup.controls['lastschool_schoolname'].setValue(studentDataField.lastschool_schoolname);
this.studentDataGroup.controls['lastschool_schoolyear'].setValue(studentDataField.lastschool_schoolyear);
this.studentDataGroup.controls['lastschool_class'].setValue(studentDataField.lastschool_class);
this.studentDataGroup.controls['relationtostudent'].setValue(studentDataField.relationtostudent);
this.studentDataGroup.controls['telnum'].setValue(studentDataField.telnum);
this.studentDataGroup.controls['studentbirthdate'].setValue(this.populateDate(studentDataField.studentbirthdate));
......@@ -122,6 +152,8 @@ import {
return state.studentDataFields;
}).subscribe(this.studentDataFields$);
/* this._sdfb.getCriteria(true);
this.criteriaSub = this._ngRedux.select(state => {
if (state.criter.size > 0) {
......@@ -138,7 +170,7 @@ import {
return state.criter;
}).subscribe(this.criteria$); */
}
};
ngOnDestroy() {
(<any>$('#applicationFormNotice')).remove();
......@@ -181,12 +213,7 @@ import {
}
checkChoice(c: FormControl) {
if (c.value === "" ) {
return {status: true}
}
else
// Null means valid, believe it or not
return null;
return (c.value === "" ) ? {status: true} : null;
}
populateDate(d) {
......@@ -205,6 +232,22 @@ import {
}
}
private populateSchoolyears(): void {
let endYear = new Date().getFullYear();
this.schoolyears = new Array();
for (let i=endYear; i>FIRST_SCHOOL_YEAR; i--) {
this.schoolyears.push((i-1) + "-" + i);
}
};
private populateGraduationyears(): void {
let endYear = new Date().getFullYear();
this.graduationyears = new Array();
for (let i=endYear; i>FIRST_SCHOOL_YEAR; i--) {
this.graduationyears.push(i + "");
}
};
setDate() {
let date = new Date();
return { date: {
......@@ -226,4 +269,16 @@ import {
(<any>$('#applicationFormNotice')).modal('hide');
}
lastSchoolListFormatter(data: any): string {
return data.name;
};
lastSchoolValueFormatter(data: any): string {
return data.name;
};
lastSchoolValueChanged(e: any): void {
// console.log(this.studentDataGroup.controls['lastschool_schoolname'].value);
};
}
......@@ -82,15 +82,24 @@ import { HelperDataService } from '../../services/helper-data-service';
<div class="row evenin" style="margin: 20px 2px 10px 2px; line-height: 2em;">
<div class="col-md-12" style="font-size: 1.5em; font-weight: bold; text-align: center;">Στοιχεία μαθητή</div>
</div>
<div><label for="name">Όνομα μαθητή</label> <p class="form-control" id="name" style="border:1px solid #eceeef;"> {{studentDataField$.name}} </p> </div>
<div><label for="studentsurname">Επώνυμο μαθητή</label> <p class="form-control" id = "studentsurname" style="border:1px solid #eceeef;"> {{studentDataField$.studentsurname}} </p></div>
<div><label for="fatherfirstname">Όνομα Πατέρα</label> <p class="form-control" id = "fatherfirstname" style="border:1px solid #eceeef;"> {{studentDataField$.fatherfirstname}} </p></div>
<div><label for="motherfirstname">Όνομα Μητέρας</label> <p class="form-control" id = "motherfirstname" style="border:1px solid #eceeef;"> {{studentDataField$.motherfirstname}} </p></div>
<div><label for="birthdate">Ημερομηνία Γέννησης</label> <p class="form-control" id = "birthdate" style="border:1px solid #eceeef;"> {{studentDataField$.studentbirthdate}} </p></div>
<div><label for="name">Όνομα μαθητή</label> <p class="form-control" style="border:1px solid #eceeef;"> {{studentDataField$.name}} </p> </div>
<div><label for="studentsurname">Επώνυμο μαθητή</label> <p class="form-control" style="border:1px solid #eceeef;"> {{studentDataField$.studentsurname}} </p></div>
<div><label for="fatherfirstname">Όνομα Πατέρα</label> <p class="form-control" style="border:1px solid #eceeef;"> {{studentDataField$.fatherfirstname}} </p></div>
<div><label for="motherfirstname">Όνομα Μητέρας</label> <p class="form-control" style="border:1px solid #eceeef;"> {{studentDataField$.motherfirstname}} </p></div>
<div><label for="birthdate">Ημερομηνία Γέννησης</label> <p class="form-control" style="border:1px solid #eceeef;"> {{studentDataField$.studentbirthdate}} </p></div>
<div><label for="certificatetype">Τύπος απολυτηρίου</label> <p class="form-control" id = "certificatetype" style="border:1px solid #eceeef;"> {{studentDataField$.certificatetype}} </p></div>
<div><label for="telnum">Τηλέφωνο επικοινωνίας</label> <p class="form-control" id = "telnum" style="border:1px solid #eceeef;"> {{studentDataField$.telnum}} </p></div>
<div><label for="relationtostudent">Η αίτηση γίνεται από</label> <p class="form-control" id = "relationtostudent" style="border:1px solid #eceeef;"> {{studentDataField$.relationtostudent}} </p></div>
<div><label for="certificatetype">Τύπος απολυτηρίου</label> <p class="form-control" style="border:1px solid #eceeef;"> {{studentDataField$.certificatetype}} </p></div>
<div><label for="graduation_year">Έτος κτήσης απολυτηρίου</label> <p class="form-control" style="border:1px solid #eceeef;"> {{studentDataField$.graduation_year}} </p></div>
<div><label for="lastschool_schoolname">Σχολείο τελευταίας φοίτησης</label> <p class="form-control" style="border:1px solid #eceeef;"> {{studentDataField$.lastschool_schoolname.name}} </p></div>
<div><label for="lastschool_schoolyear">Σχολικό έτος τελευταίας φοίτησης</label> <p class="form-control" style="border:1px solid #eceeef;"> {{studentDataField$.lastschool_schoolyear}} </p></div>
<div *ngIf="studentDataField$.lastschool_class === 1"><label for="lastschool_class">Τάξη τελευταίας φοίτησης</label> <p class="form-control" style="border:1px solid #eceeef;">Α'</p></div>
<div *ngIf="studentDataField$.lastschool_class === 2"><label for="lastschool_class">Τάξη τελευταίας φοίτησης</label> <p class="form-control" style="border:1px solid #eceeef;">Β'</p></div>
<div *ngIf="studentDataField$.lastschool_class === 3"><label for="lastschool_class">Τάξη τελευταίας φοίτησης</label> <p class="form-control" style="border:1px solid #eceeef;">Γ'</p></div>
<div *ngIf="studentDataField$.lastschool_class === 4"><label for="lastschool_class">Τάξη τελευταίας φοίτησης</label> <p class="form-control" style="border:1px solid #eceeef;">Δ'</p></div>
<div><label for="telnum">Τηλέφωνο επικοινωνίας</label> <p class="form-control" style="border:1px solid #eceeef;"> {{studentDataField$.telnum}} </p></div>
<div><label for="relationtostudent">Η αίτηση γίνεται από</label> <p class="form-control" style="border:1px solid #eceeef;"> {{studentDataField$.relationtostudent}} </p></div>
</div>
<div class="row" style="margin-top: 20px; margin-bottom: 20px;">
......@@ -285,11 +294,13 @@ import { HelperDataService } from '../../services/helper-data-service';
// aitisiObj[0].lastschool_class = std.lastschool_class;
// aitisiObj[0].currentepal = std.currentepal;
aitisiObj[0].graduation_year = 0;
aitisiObj[0].lastschool_registrynumber = '';
aitisiObj[0].lastschool_schoolyear = '2015-2016';
aitisiObj[0].lastschool_class = '1';
aitisiObj[0].currentepal = 154;
aitisiObj[0].graduation_year = std.graduation_year;
aitisiObj[0].lastschool_registrynumber = std.lastschool_schoolname.registry_no;
aitisiObj[0].lastschool_schoolname = std.lastschool_schoolname.name;
aitisiObj[0].lastschool_schoolyear = std.lastschool_schoolyear;
aitisiObj[0].lastschool_unittypeid = std.lastschool_schoolname.unit_type_id;
aitisiObj[0].lastschool_class = std.lastschool_class;
// aitisiObj[0].currentepal = 154;
aitisiObj[0].relationtostudent = std.relationtostudent;
aitisiObj[0].telnum = std.telnum;
......@@ -387,8 +398,10 @@ import { HelperDataService } from '../../services/helper-data-service';
public hideModal():void {
console.log("going to post-submit from hide()");
(<any>$('#studentFormSentNotice')).modal('hide');
//(<any>$('.modal-backdrop')).remove();
this.router.navigate(['/post-submit']);
if (this.modalHeader.getValue() === "modal-header-success") {
this.router.navigate(['/post-submit']);
}
}
public onHidden():void {
......
......@@ -40,7 +40,9 @@ export const VALID_NAMES_PATTERN = '[A-Za-zΑ-ΩΆΈΉΊΙΎΌΏα-ωάέήίΐ
export const VALID_ADDRESS_PATTERN = '[0-9A-Za-zΑ-ΩΆΈΉΊΎΌΏα-ωάέήίύόώ ]*$';
export const VALID_ADDRESSTK_PATTERN = '[0-9 ]*$';
// export const VALID_DIGITS_PATTERN = '69[0-9]*$';
export const VALID_DIGITS_PATTERN = '2[0-9]*$';
export const VALID_DIGITS_PATTERN = '[0-9]*$';
export const VALID_TELEPHONE_PATTERN = '2[0-9]*$';
export const VALID_YEAR_PATTERN = '[0-9]*$';
export const VALID_EMAIL_PATTERN = '[A-Z0-9a-z._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,64}';
......@@ -58,3 +60,4 @@ export const STUDENT_ROLE = 'student';
export const PDE_ROLE = 'pde';
export const DIDE_ROLE = 'dide';
export const MINISTRY_ROLE = 'supervisor';
export const FIRST_SCHOOL_YEAR = 1950;
......@@ -20,7 +20,12 @@ export function deimmutifyStudentDataFields(state: IStudentDataFields): IStudent
motherfirstname: studentdataField.motherfirstname, mothersurname: studentdataField.mothersurname,
studentamka: studentdataField.studentamka, regionaddress: studentdataField.regionaddress,
regiontk: studentdataField.regiontk,regionarea: studentdataField.regionarea,
certificatetype: studentdataField.certificatetype, relationtostudent: studentdataField.relationtostudent,
certificatetype: studentdataField.certificatetype,
graduation_year: studentdataField.graduation_year,
lastschool_schoolname: studentdataField.lastschool_schoolname,
lastschool_schoolyear: studentdataField.lastschool_schoolyear,
lastschool_class: studentdataField.lastschool_class,
relationtostudent: studentdataField.relationtostudent,
currentclass: studentdataField.currentclass, points: studentdataField.points
});
});
......
......@@ -28,6 +28,10 @@ export interface IStudentDataField {
regiontk: string;
regionarea: string;
certificatetype: string;
graduation_year: number;
lastschool_schoolname: any;
lastschool_schoolyear: string;
lastschool_class: string;
relationtostudent: string;
currentclass: string;
points: number;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment