import { Component, OnInit, OnDestroy, ElementRef, ViewChild} from "@angular/core"; import { Injectable } from "@angular/core"; import { AppSettings } from '../../app.settings'; import { HelperDataService } from '../../services/helper-data-service'; import {Observable} from "rxjs/Observable"; import {Http, Headers, RequestOptions} from '@angular/http'; import { NgRedux, select } from 'ng2-redux'; import { IAppState } from '../../store/store'; import {Router, ActivatedRoute, Params} from '@angular/router'; import { BehaviorSubject, Subscription } from 'rxjs/Rx'; import { ILoginInfo } from '../../store/logininfo/logininfo.types'; import { VALID_CAPACITY_PATTERN} from '../../constants'; import {maxValue} from '../../constants'; import {minValue} from '../../constants'; import { FormBuilder, FormGroup, FormControl, FormArray, Validators, } from '@angular/forms'; @Component({ selector: 'director-classcapacity', template: `

H παρακάτω λίστα διαμορφώνει τη δυναμική του σχολείου σας σε τμήματα με κριτήριο τον αριθμό των διαθεσίμων αιθουσών.

Παρακαλείστε να καταγράψετε τον αριθμό των τμημάτων ανά τάξη, τομέα και ειδικότητα.

Τα τμήματα του σχολείου σας.
Αριθμός Μαθητών
  • {{CoursesPerSchools$.taxi}}
    {{CoursesPerSchools$.size}}
  • {{StudentDetails$.studentsurname}}
    {{StudentDetails$.name}}

    Παρακαλούμε, αφού γίνει ο έλεγχος των στοιχείων του μαθητή επιβεβαιώστε τη δυνατότητα εγγραφής του.

     
    Αριθμός Δήλωσης Προτίμησης ΕΠΑΛ
    {{StudentDetails$.id}}
    Υποβλήθηκε
    {{StudentDetails$.created}}
    Στοιχεία αιτούμενου
    Όνομα
    {{StudentDetails$.guardian_name}}
    Επώνυμο
    {{StudentDetails$.guardian_surname}}
    Όνομα πατέρα
    {{ StudentDetails$.guardian_fathername }}
    Όνομα μητέρας
    {{ StudentDetails$.guardian_mothername }}
    Διεύθυνση
    {{StudentDetails$.regionaddress}}
    ΤΚ - Πόλη
    {{StudentDetails$.regiontk}} - {{StudentDetails$.regionarea}}
    Στοιχεία μαθητή
    Όνομα μαθητή
    {{StudentDetails$.name}}
    Επώνυμο μαθητή
    {{StudentDetails$.studentsurname}}
    Όνομα Πατέρα
    {{StudentDetails$.fatherfirstname}}
    Όνομα Μητέρας
    {{StudentDetails$.motherfirstname}}
    Ημερομηνία Γέννησης
    {{StudentDetails$.birthdate}}
    Τηλέφωνο Επικοινωνίας
    {{StudentDetails$.telnum}}
    Σχολείο τελευταίας φοίτησης
    {{StudentDetails$.lastschool_schoolname}}
    Σχολικό έτος τελευταίας φοίτησης
    {{StudentDetails$.lastschool_schoolyear}}
    Τάξη τελευταίας φοίτησης
    Α
    Β
    Γ
    Δ
    Δήλωση από:
    {{ StudentDetails$.relationtostudent }}
    Τάξη φοίτησης για το νέο σχολικό έτος
    Α
    Β
    Γ
    Δ
    Τομέας φοίτησης για το νέο σχολικό έτος
    {{StudentDetails$.currentsector}}
    Ειδικότητα φοίτησης για το νέο σχολικό έτος
    {{StudentDetails$.currentcourse}}
    ` }) @Injectable() export default class DirectorClassCapacity implements OnInit, OnDestroy { public formGroup: FormGroup; private CoursesPerSchool$: BehaviorSubject; private CoursesPerSchoolSub: Subscription; private StudentInfo$: BehaviorSubject; private StudentInfoSub: Subscription; private retrievedStudent: BehaviorSubject; private SavedStudentsSub: Subscription; private SavedStudents$: BehaviorSubject; private courseActive = -1; private StudentActive = -1; private showLoader: BehaviorSubject; private opened; private applicationId = 0; private taxi= 0; private sector = 0; private special= 0; constructor(private fb: FormBuilder, private _hds: HelperDataService, private activatedRoute: ActivatedRoute, private router: Router) { this.CoursesPerSchool$ = new BehaviorSubject([{}]); this.showLoader = new BehaviorSubject(false); this.StudentInfo$ = new BehaviorSubject([{}]); this.retrievedStudent = new BehaviorSubject(false); this.SavedStudents$ = new BehaviorSubject({}); this.opened = false; this.formGroup = this.fb.group({ }); } public showConfirmModal(): void { ($('#applicationDeleteConfirm')).modal('show'); } public showErrorModal(): void { ($('#applicationDeleteError')).modal('show'); } public hideConfirmModal(): void { ($('#applicationDeleteConfirm')).modal('hide'); } public hideErrorModal(): void { ($('#applicationDeleteError')).modal('hide'); } public showModal(popupMsgId): void { ($(popupMsgId)).modal('show'); } public hideModal(popupMsgId): void { ($(popupMsgId)).modal('hide'); } public onHidden(popupMsgId): void { } ngOnDestroy() { ($('#applicationDeleteConfirm')).remove(); ($('#applicationDeleteError')).remove(); } ngOnInit() { ($('#checksaved')).appendTo("body"); ($('#dangermodal')).appendTo("body"); ($('#emptyselection')).appendTo("body"); ($('#applicationDeleteConfirm')).appendTo("body"); ($('#applicationDeleteError')).appendTo("body"); this.showLoader.next(true); this.CoursesPerSchoolSub = this._hds.FindCoursesPerSchool().subscribe(x => { this.CoursesPerSchool$.next(x); this.showLoader.next(false); }, error => { this.CoursesPerSchool$.next([{}]); console.log("Error Getting courses perSchool"); this.showLoader.next(false); }); } findstudent(taxi, sector, special) { this.showLoader.next(true); this.retrievedStudent.next(false); this.StudentInfoSub = this._hds.getStudentPerSchool(taxi, sector, special) .subscribe(data => { this.StudentInfo$.next(data); this.retrievedStudent.next(true); this.showLoader.next(false); }, error => { this.StudentInfo$.next([{}]); console.log("Error Getting Students"); this.showLoader.next(false); this.showModal("#emptyselection"); }); } setActive(ind) { this.StudentActive = -1; if (this.courseActive == ind) { ind = -1; } this.courseActive = ind; } setActiveStudent(ind) { this.opened = true; if (this.StudentActive == ind) { ind = -1; } this.StudentActive = ind; } setActiveStudentnew(ind) { this.opened = false; if (this.StudentActive == ind) { ind = -1; } this.StudentActive = ind; } confirmStudent(student, cb, ind) { var rtype; if (cb.value == 1) rtype = '1'; if (cb.value == 2) rtype = '0'; if (cb.value == 3) rtype = null; var type = cb.value; this.showLoader.next(true); let std = this.StudentInfo$.getValue(); std[ind].checkstatus = rtype; this.SavedStudentsSub = this._hds.saveConfirmStudents(student, type).subscribe(data => { this.SavedStudents$.next(data); this.StudentInfo$.next(std); this.showLoader.next(false); this.showModal("#checksaved"); }, error => { this.SavedStudents$.next([{}]); console.log("Error saving Students"); this.showLoader.next(false); this.showModal("#dangermodal"); }); } deleteApplication(appId: number,taxi, sector, special ): void { this.applicationId = appId; this.taxi = taxi; this.sector = sector; this.special = special; this.showConfirmModal(); } deleteApplicationDo(): void { this.hideConfirmModal(); this.showLoader.next(true); this._hds.deleteApplicationforDirector(this.applicationId).then(data => { this.StudentInfoSub.unsubscribe(); this.CoursesPerSchoolSub.unsubscribe(); this.showLoader.next(false); this.StudentActive = -1; //this.courseActive = -1; this.CoursesPerSchoolSub = this._hds.FindCoursesPerSchool().subscribe(x => { this.CoursesPerSchool$.next(x); this.showLoader.next(false); }, error => { this.CoursesPerSchool$.next([{}]); console.log("Error Getting courses perSchool"); this.showLoader.next(false); }); this.StudentInfoSub = this._hds.getStudentPerSchool(this.taxi, this.sector, this.special) .subscribe(data => { this.StudentInfo$.next(data); this.retrievedStudent.next(true); this.showLoader.next(false); }, error => { this.StudentInfo$.next([{}]); console.log("Error Getting Students"); this.showLoader.next(false); this.showModal("#emptyselection"); }); }).catch(err => { this.showErrorModal(); this.showLoader.next(false); }); } }