director-view.ts 26.2 KB
Newer Older
Open Source Developer's avatar
Open Source Developer committed
1
import { Component, OnInit, OnDestroy, ElementRef, ViewChild} from "@angular/core";
Open Source Developer's avatar
Open Source Developer committed
2 3 4
import { Injectable } from "@angular/core";
import { AppSettings } from '../../app.settings';
import { HelperDataService } from '../../services/helper-data-service';
Open Source Developer's avatar
Open Source Developer committed
5 6
import {Observable} from "rxjs/Observable";
import {Http, Headers, RequestOptions} from '@angular/http';
7
import { NgRedux, select } from '@angular-redux/store';
Open Source Developer's avatar
Open Source Developer committed
8
import { IAppState } from '../../store/store';
Open Source Developer's avatar
Open Source Developer committed
9
import {Router, ActivatedRoute, Params} from '@angular/router';
Open Source Developer's avatar
Open Source Developer committed
10
import { BehaviorSubject, Subscription } from 'rxjs/Rx';
Open Source Developer's avatar
transf  
Open Source Developer committed
11
import { ILoginInfo } from '../../store/logininfo/logininfo.types';
Open Source Developer's avatar
Open Source Developer committed
12 13 14 15
import { VALID_CAPACITY_PATTERN} from '../../constants';
import {maxValue} from '../../constants';
import {minValue} from '../../constants';

Open Source Developer's avatar
trans  
Open Source Developer committed
16

Open Source Developer's avatar
trans  
Open Source Developer committed
17 18 19 20 21 22 23
import {
    FormBuilder,
    FormGroup,
    FormControl,
    FormArray,
    Validators,
} from '@angular/forms';
Open Source Developer's avatar
Open Source Developer committed
24
@Component({
Open Source Developer's avatar
Open Source Developer committed
25
    selector: 'director-classcapacity',
Open Source Developer's avatar
Open Source Developer committed
26
    template: `
Open Source Developer's avatar
delete  
Open Source Developer committed
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66


      <div id="applicationDeleteConfirm" (onHidden)="onHidden()" class="modal" tabindex="-1" role="dialog" aria-hidden="true" data-backdrop="static" data-keyboard="false">
      <div class="modal-dialog modal-lg">
        <div class="modal-content">
          <div class="modal-header modal-header-danger">
              <h3 class="modal-title pull-left"><i class="fa fa-close"></i>&nbsp;&nbsp;Διαγραφή Δήλωσης Προτίμησης ΕΠΑΛ</h3>
            <button type="button" class="close pull-right" aria-label="Close" (click)="hideModal()">
              <span aria-hidden="true"><i class="fa fa-times"></i></span>
            </button>
          </div>
          <div class="modal-body">
              <p>Επιλέξατε να διαγράψετε τη δήλωση προτίμησης ΕΠΑΛ. Παρακαλούμε επιλέξτε Επιβεβαίωση</p>
          </div>
          <div class="modal-footer">
            <button type="button" class="btn btn-default pull-left" data-dismiss="modal" (click)="hideConfirmModal()">Ακύρωση</button>
            <button type="button" class="btn btn-default pull-left" data-dismiss="modal" (click)="deleteApplicationDo()">Επιβεβαίωση</button>
          </div>
        </div>
      </div>
    </div>

    <div id="applicationDeleteError" (onHidden)="onHidden()" class="modal" tabindex="-1" role="dialog" aria-hidden="true" data-backdrop="static" data-keyboard="false">
      <div class="modal-dialog modal-lg">
        <div class="modal-content">
          <div class="modal-header modal-header-danger">
              <h3 class="modal-title pull-left"><i class="fa fa-ban"></i>&nbsp;&nbsp;Αποτυχία Διαγραφής Δήλωσης Προτίμησης ΕΠΑΛ</h3>
            <button type="button" class="close pull-right" aria-label="Close" (click)="hideModal()">
              <span aria-hidden="true"><i class="fa fa-times"></i></span>
            </button>
          </div>
          <div class="modal-body">
              <p>Η δήλωσή δεν διαγράφηκε. Δεν μπορείτε να διαγράψετε τη δήλωσή μαθητή εαν έχετε κάνει την επιβεβαίωση εγγραφής.</p>
          </div>
          <div class="modal-footer">
            <button type="button" class="btn btn-default pull-right" data-dismiss="modal" (click)="hideErrorModal()">Κλείσιμο</button>
          </div>
        </div>
      </div>
    </div>
Open Source Developer's avatar
Open Source Developer committed
67
    <div class = "loading" *ngIf="(showLoader | async) === true"></div>
68
    <div style="min-height: 500px;">
Open Source Developer's avatar
Open Source Developer committed
69 70
    <form [formGroup]="formGroup">

Open Source Developer's avatar
bugs  
Open Source Developer committed
71 72
       <p style="margin-top: 20px; line-height: 2em;"> H παρακάτω λίστα διαμορφώνει τη δυναμική του σχολείου σας σε τμήματα με κριτήριο τον αριθμό των διαθεσίμων αιθουσών.  </p>
       <p style="margin-top: 20px; line-height: 2em;"> Παρακαλείστε να καταγράψετε τον αριθμό των τμημάτων ανά τάξη, τομέα και ειδικότητα.  </p>
73

74 75 76
      <div class="row">
         <div class="col-md-10" style="font-weight: bold;"> Τα τμήματα του σχολείου σας.</div>
         <div class="col-md-2" style="font-weight: bold;"> <span class="pull-right" style="text-align: right; padding-right: 2px;">Αριθμός Μαθητών</span></div>
Open Source Developer's avatar
Open Source Developer committed
77
      </div>
Open Source Developer's avatar
Open Source Developer committed
78
      <div *ngFor="let CoursesPerSchools$  of CoursesPerSchool$ | async; let i=index; let isOdd=odd; let isEven=even" >
79 80 81
                <li class="list-group-item isclickable" (click)="setActive(i)"
                (click)="findstudent(CoursesPerSchools$.class, CoursesPerSchools$.newsector, CoursesPerSchools$.newspecialit)"
                [class.changelistcolor]= "CoursesPerSchools$.size < CoursesPerSchools$.limitdown"
Open Source Developer's avatar
Open Source Developer committed
82
                [class.oddout]="isOdd" [class.evenout]="isEven"  [class.selectedout]="courseActive === i" >
83 84 85 86
                <div class="row"  style="line-height: 2em;">
                  <div class="col-md-10" style="font-weight: bold;" >{{CoursesPerSchools$.taxi}}</div>
                  <div class="col-md-2" style="font-weight: bold;" ><span class="pull-right" style="text-align: right; padding-right: 2px;">{{CoursesPerSchools$.size}}</span></div>
                </div>
Open Source Developer's avatar
Open Source Developer committed
87
                </li>
88

Open Source Developer's avatar
Open Source Developer committed
89
               <div [hidden]="courseActive !== i" *ngIf="(retrievedStudent | async)">
90 91
                 <div *ngFor="let StudentDetails$  of StudentInfo$ | async; let j=index; let isOdd=odd; let isEven=even" class="row list-group-item isclickable"
                 [class.selectedappout]="StudentActive === j"
Open Source Developer's avatar
Open Source Developer committed
92
                 [class.confirmed]="StudentDetails$.checkstatus === '1'"
93
                 [class.notconfirmed]="StudentDetails$.checkstatus === '0'"
Open Source Developer's avatar
Open Source Developer committed
94 95
                 [class.notchecked]="(StudentDetails$.checkstatus !== '1') && (StudentDetails$.checkstatus !== '0')"
                 [class.oddout]="isOdd" [class.evenout]="isEven" style="margin: 0px 2px 0px 2px;">
96 97
                    <div class="col-md-5" style="font-size: 0.8em; font-weight: bold;" (click) ="setActiveStudent(j)" >{{StudentDetails$.studentsurname}}</div>
                    <div class="col-md-5" style="font-size: 0.8em; font-weight: bold;" (click) ="setActiveStudent(j)">{{StudentDetails$.name}}</div>
Open Source Developer's avatar
delete  
Open Source Developer committed
98 99
                    <div class="col-md-2" style="font-size: 1.5em; font-weight: bold;"><i class="fa fa-trash isclickable" (click)="deleteApplication(StudentDetails$.id, CoursesPerSchools$.class, CoursesPerSchools$.newsector, CoursesPerSchools$.newspecialit)"></i></div>

100
                    <div [hidden]="StudentActive !== j" class="col-md-2 pull-right" style="color: black;" > <span aria-hidden="true"><button type="button" class="btn-primary btn-sm pull-right" (click) ="setActiveStudentnew(j)">Κλείσιμο</button></span>  </div>
Open Source Developer's avatar
paging  
Open Source Developer committed
101

Open Source Developer's avatar
Open Source Developer committed
102 103
                    <div style="width: 100%; color: #000000;">
                    <div [hidden]="StudentActive !== j"  style="margin: 20px 10px 10px 10px;">
104

105
                     <p style="margin-top: 10px; margin-bottom: 5px; line-height: 2em;"> Παρακαλούμε, αφού γίνει ο έλεγχος των στοιχείων του μαθητή επιβεβαιώστε τη δυνατότητα εγγραφής του.</p>
106 107

                     <div class="row" style="margin-bottom: 20px;">
108 109
                     <div class="col-md-8">&nbsp;</div>
                     <div class="col-md-4">
Open Source Developer's avatar
trans  
Open Source Developer committed
110
                      <strong><label>Επιβεβαίωση Εγγραφής:</label> </strong>
111
                      <select class="form-control pull-right" #cb name="{{StudentDetails$.id}}" (change)="confirmStudent(StudentDetails$.id, cb, j)">
112 113
                          <option value="1" [selected]="StudentDetails$.checkstatus === '1' ">Ναι</option>
                          <option value="2" [selected]="StudentDetails$.checkstatus === '0' ">Όχι</option>
114
                          <option value="3" [selected]="StudentDetails$.checkstatus != '0' && StudentDetails$.checkstatus != '1'">Δεν ελέγχθηκε</option>
Open Source Developer's avatar
trans  
Open Source Developer committed
115
                      </select>
116
                      </div>
117
<!--                      <div class="col-md-2">
Open Source Developer's avatar
Open Source Developer committed
118
                      <button type="button" class="btn-primary btn-sm pull-right" (click)="confirmStudent(StudentDetails$.id, cb, j)">
Open Source Developer's avatar
Open Source Developer committed
119
                           Ενημέρωση
Open Source Developer's avatar
trans  
Open Source Developer committed
120
                       </button>
121
                     </div> -->
122 123
                     </div>

124 125 126 127 128 129
                     <div class="row oddin" style="margin: 0px 2px 0px 2px; line-height: 2em;">
                         <div class="col-md-3" style="font-size: 0.8em;">Αριθμός Δήλωσης Προτίμησης ΕΠΑΛ</div>
                         <div class="col-md-3" style="font-size: 0.8em; font-weight: bold">{{StudentDetails$.id}}</div>
                         <div class="col-md-3" style="font-size: 0.8em;">Υποβλήθηκε</div>
                         <div class="col-md-3" style="font-size: 0.8em; font-weight: bold">{{StudentDetails$.created}}</div>
                     </div>
130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151

                       <div class="row evenin" style="margin: 0px 2px 0px 2px; line-height: 2em;">
                           <div class="col-md-12" style="font-size: 1em; font-weight: bold; text-align: center;">Στοιχεία αιτούμενου</div>
                       </div>
                       <div class="row oddin" style="margin: 0px 2px 0px 2px; line-height: 2em;">
                           <div class="col-md-3" style="font-size: 0.8em;">Όνομα</div>
                           <div class="col-md-3" style="font-size: 0.8em; font-weight: bold">{{StudentDetails$.guardian_name}}</div>
                           <div class="col-md-3" style="font-size: 0.8em;">Επώνυμο</div>
                           <div class="col-md-3" style="font-size: 0.8em; font-weight: bold">{{StudentDetails$.guardian_surname}}</div>
                       </div>
                       <div class="row oddin" style="margin: 0px 2px 0px 2px; line-height: 2em;">
                           <div class="col-md-3" style="font-size: 0.8em;">Όνομα πατέρα</div>
                           <div class="col-md-3" style="font-size: 0.8em; font-weight: bold">{{ StudentDetails$.guardian_fathername }}</div>
                           <div class="col-md-3" style="font-size: 0.8em;">Όνομα μητέρας</div>
                           <div class="col-md-3" style="font-size: 0.8em; font-weight: bold">{{ StudentDetails$.guardian_mothername }}</div>
                       </div>
                       <div class="row oddin" style="margin: 0px 2px 0px 2px; line-height: 2em;">
                           <div class="col-md-3" style="font-size: 0.8em;">Διεύθυνση</div>
                           <div class="col-md-3" style="font-size: 0.8em; font-weight: bold">{{StudentDetails$.regionaddress}}</div>
                           <div class="col-md-3" style="font-size: 0.8em;">ΤΚ - Πόλη</div>
                           <div class="col-md-3" style="font-size: 0.8em; font-weight: bold">{{StudentDetails$.regiontk}} - {{StudentDetails$.regionarea}}</div>
                       </div>
152 153 154 155

                       <div class="row evenin" style="margin: 0px 2px 0px 2px; line-height: 2em;">
                           <div class="col-md-12" style="font-size: 1em; font-weight: bold; text-align: center;">Στοιχεία μαθητή</div>
                       </div>
156 157 158 159 160 161 162 163 164 165 166 167 168 169
                       <div class="row oddin" style="margin: 0px 2px 0px 2px; line-height: 2em;">
                           <div class="col-md-3" style="font-size: 0.8em;">Όνομα μαθητή</div>
                           <div class="col-md-3" style="font-size: 0.8em; font-weight: bold">{{StudentDetails$.name}}</div>
                           <div class="col-md-3" style="font-size: 0.8em;">Επώνυμο μαθητή</div>
                           <div class="col-md-3" style="font-size: 0.8em; font-weight: bold">{{StudentDetails$.studentsurname}}</div>
                       </div>
                       <div class="row oddin" style="margin: 0px 2px 0px 2px; line-height: 2em;">
                           <div class="col-md-3" style="font-size: 0.8em;">Όνομα Πατέρα</div>
                           <div class="col-md-3" style="font-size: 0.8em; font-weight: bold">{{StudentDetails$.fatherfirstname}}</div>
                           <div class="col-md-3" style="font-size: 0.8em;">Όνομα Μητέρας</div>
                           <div class="col-md-3" style="font-size: 0.8em; font-weight: bold">{{StudentDetails$.motherfirstname}}</div>
                       </div>
                       <div class="row oddin" style="margin: 0px 2px 0px 2px; line-height: 2em;">
                           <div class="col-md-3" style="font-size: 0.8em;">Ημερομηνία Γέννησης</div>
170 171 172
                           <div class="col-md-3" style="font-size: 0.8em; font-weight: bold">{{StudentDetails$.birthdate}}</div>
                           <div class="col-md-3" style="font-size: 0.8em;">Τηλέφωνο Επικοινωνίας</div>
                           <div class="col-md-3" style="font-size: 0.8em; font-weight: bold">{{StudentDetails$.telnum}}</div>
173 174 175 176 177
                       </div>

                       <div class="row oddin" style="margin: 0px 2px 0px 2px; line-height: 2em;">
                           <div class="col-md-3" style="font-size: 0.8em;">Σχολείο τελευταίας φοίτησης</div>
                           <div class="col-md-3" style="font-size: 0.8em; font-weight: bold">{{StudentDetails$.lastschool_schoolname}}</div>
178 179
                           <div class="col-md-3" style="font-size: 0.8em;">Σχολικό έτος τελευταίας φοίτησης</div>
                           <div class="col-md-3" style="font-size: 0.8em; font-weight: bold">{{StudentDetails$.lastschool_schoolyear}}</div>
180
                       </div>
181
                       <div class="row oddin" style="margin: 0px 2px 0px 2px; line-height: 2em;">
182
                           <div class="col-md-3" style="font-size: 0.8em;">Τάξη τελευταίας φοίτησης</div>
183 184 185 186 187 188 189 190 191 192
                           <div *ngIf="StudentDetails$.lastschool_class === '1'" class="col-md-9" style="font-size: 0.8em; font-weight: bold">Α</div>
                           <div *ngIf="StudentDetails$.lastschool_class === '2'" class="col-md-9" style="font-size: 0.8em; font-weight: bold">Β</div>
                           <div *ngIf="StudentDetails$.lastschool_class === '3'" class="col-md-9" style="font-size: 0.8em; font-weight: bold">Γ</div>
                           <div *ngIf="StudentDetails$.lastschool_class === '4'" class="col-md-9" style="font-size: 0.8em; font-weight: bold">Δ</div>
                       </div>
                       <div class="row oddin" style="margin: 0px 2px 0px 2px; line-height: 2em;">
                           <div class="col-md-3" style="font-size: 0.8em;">Δήλωση από:</div>
                           <div class="col-md-9" style="font-size: 0.8em; font-weight: bold">{{ StudentDetails$.relationtostudent }}</div>
                       </div>
                       <div class="row oddin" style="margin: 0px 2px 0px 2px; line-height: 2em;">
193
                           <div class="col-md-3" style="font-size: 0.8em;">Τάξη φοίτησης για το νέο σχολικό έτος</div>
194 195 196 197
                           <div *ngIf="StudentDetails$.currentclass === '1'" class="col-md-9" style="font-size: 0.8em; font-weight: bold">Α</div>
                           <div *ngIf="StudentDetails$.currentclass === '2'" class="col-md-9" style="font-size: 0.8em; font-weight: bold">Β</div>
                           <div *ngIf="StudentDetails$.currentclass === '3'" class="col-md-9" style="font-size: 0.8em; font-weight: bold">Γ</div>
                           <div *ngIf="StudentDetails$.currentclass === '4'" class="col-md-9" style="font-size: 0.8em; font-weight: bold">Δ</div>
198 199
                       </div>
                       <div *ngIf="StudentDetails$.currentclass === '2'" class="row oddin" style="margin: 0px 2px 0px 2px; line-height: 2em;">
200 201
                           <div class="col-md-3" style="font-size: 0.8em;">Τομέας φοίτησης για το νέο σχολικό έτος</div>
                           <div class="col-md-9" style="font-size: 0.8em; font-weight: bold">{{StudentDetails$.currentsector}}</div>
202 203
                       </div>
                       <div *ngIf="StudentDetails$.currentclass === '3' || StudentDetails$.currentclass === '4'" class="row oddin" style="margin: 0px 2px 0px 2px; line-height: 2em;">
204 205
                           <div class="col-md-3" style="font-size: 0.8em;">Ειδικότητα φοίτησης για το νέο σχολικό έτος</div>
                           <div class="col-md-9" style="font-size: 0.8em; font-weight: bold">{{StudentDetails$.currentcourse}}</div>
206
                       </div>
Open Source Developer's avatar
trans  
Open Source Developer committed
207

Open Source Developer's avatar
trans  
Open Source Developer committed
208
                 </div>
209
                 </div>
210

211

Open Source Developer's avatar
Open Source Developer committed
212 213 214 215 216 217 218 219 220 221 222
                 </div>
               </div>
       </div>
      </form>
      </div>


  <div id="checksaved" (onHidden)="onHidden('#checksaved')"
    class="modal fade" tabindex="-1" role="dialog" aria-hidden="true">
      <div class="modal-dialog modal-lg">
        <div class="modal-content">
Open Source Developer's avatar
others  
Open Source Developer committed
223
          <div class="modal-header modal-header-success">
Open Source Developer's avatar
Open Source Developer committed
224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244
            <h3 class="modal-title pull-left"><i class="fa fa-check-square-o"></i>&nbsp;&nbsp;Η επιλογή σας έχει αποθηκευτεί</h3>
            <button type="button" class="close pull-right" aria-label="Close" (click)="hideModal('#checksaved')">
              <span aria-hidden="true"><i class="fa fa-times"></i></span>
            </button>
          </div>
          <div class="modal-body">
            <p>Η επιλογή σας έχει αποθηκευτεί</p>
          </div>
          <div class="modal-footer">
            <button type="button" class="btn btn-default pull-left" data-dismiss="modal">Κλείσιμο</button>
          </div>
        </div>
      </div>
    </div>


<div id="dangermodal" (onHidden)="onHidden('#dangermodal')"
    class="modal fade" tabindex="-1" role="dialog" aria-hidden="true">
      <div class="modal-dialog modal-lg">
        <div class="modal-content">
          <div class="modal-header modal-header-danger">
Open Source Developer's avatar
others  
Open Source Developer committed
245
            <h3 class="modal-title pull-left"><i class="fa fa-ban"></i>&nbsp;&nbsp;Η επιλογή σας δεν έχει αποθηκευτεί</h3>
Open Source Developer's avatar
Open Source Developer committed
246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265
            <button type="button" class="close pull-right" aria-label="Close" (click)="hideModal('#dangermodal')">
              <span aria-hidden="true"><i class="fa fa-times"></i></span>
            </button>
          </div>
          <div class="modal-body">
            <p>Παρακαλώ προσπαθήστε ξανα!</p>
          </div>
          <div class="modal-footer">
            <button type="button" class="btn btn-default pull-left" data-dismiss="modal">Κλείσιμο</button>
          </div>
        </div>
      </div>
    </div>


    <div id="emptyselection" (onHidden)="onHidden('#emptyselection')"
    class="modal fade" tabindex="-1" role="dialog" aria-hidden="true">
      <div class="modal-dialog modal-lg">
        <div class="modal-content">
          <div class="modal-header modal-header-danger">
Open Source Developer's avatar
others  
Open Source Developer committed
266
            <h3 class="modal-title pull-left"><i class="fa fa-ban"></i>&nbsp;&nbsp;Δεν υπάρχουν μαθητές</h3>
Open Source Developer's avatar
Open Source Developer committed
267 268 269 270 271 272 273 274 275 276 277 278 279
            <button type="button" class="close pull-right" aria-label="Close" (click)="hideModal('#emptyselection')">
              <span aria-hidden="true"><i class="fa fa-times"></i></span>
            </button>
          </div>
          <div class="modal-body">
            <p>Δεν υπάρχουν μαθητές με δήλωση προτίμησης το συγκεκριμένο τμήμα του σχολείου σας!</p>
          </div>
          <div class="modal-footer">
            <button type="button" class="btn btn-default pull-left" data-dismiss="modal">Κλείσιμο</button>
          </div>
        </div>
      </div>
    </div>
280

Open Source Developer's avatar
paging  
Open Source Developer committed
281

Open Source Developer's avatar
Open Source Developer committed
282 283 284
   `
})

Open Source Developer's avatar
Open Source Developer committed
285
@Injectable() export default class DirectorClassCapacity implements OnInit, OnDestroy {
Open Source Developer's avatar
Open Source Developer committed
286

Open Source Developer's avatar
trans  
Open Source Developer committed
287
    public formGroup: FormGroup;
Open Source Developer's avatar
Open Source Developer committed
288 289 290

    private CoursesPerSchool$: BehaviorSubject<any>;
    private CoursesPerSchoolSub: Subscription;
Open Source Developer's avatar
trans  
Open Source Developer committed
291 292
    private StudentInfo$: BehaviorSubject<any>;
    private StudentInfoSub: Subscription;
Open Source Developer's avatar
Open Source Developer committed
293
    private retrievedStudent: BehaviorSubject<boolean>;
Open Source Developer's avatar
Open Source Developer committed
294 295
    private SavedStudentsSub: Subscription;
    private SavedStudents$: BehaviorSubject<any>;
Open Source Developer's avatar
Open Source Developer committed
296 297 298 299
    private courseActive = <number>-1;
    private StudentActive = <number>-1;
    private showLoader: BehaviorSubject<boolean>;
    private opened;
Open Source Developer's avatar
delete  
Open Source Developer committed
300
    private applicationId = <number>0;
301
    private taxi = <number>0;
Open Source Developer's avatar
delete  
Open Source Developer committed
302
    private sector = <number>0;
303
    private special = <number>0;
304

305

Open Source Developer's avatar
Open Source Developer committed
306

307 308 309
    constructor(private fb: FormBuilder,
        private _hds: HelperDataService,
        private activatedRoute: ActivatedRoute,
Open Source Developer's avatar
Open Source Developer committed
310 311 312 313 314 315 316 317
        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;
318
        this.formGroup = this.fb.group({
Open Source Developer's avatar
Open Source Developer committed
319

320
        });
321

Open Source Developer's avatar
Open Source Developer committed
322
    }
323

324

Open Source Developer's avatar
delete  
Open Source Developer committed
325 326 327 328 329 330 331 332 333 334 335 336 337 338 339
    public showConfirmModal(): void {
        (<any>$('#applicationDeleteConfirm')).modal('show');
    }

    public showErrorModal(): void {
        (<any>$('#applicationDeleteError')).modal('show');
    }

    public hideConfirmModal(): void {
        (<any>$('#applicationDeleteConfirm')).modal('hide');
    }
    public hideErrorModal(): void {
        (<any>$('#applicationDeleteError')).modal('hide');
    }

Open Source Developer's avatar
Open Source Developer committed
340

341
    public showModal(popupMsgId): void {
Open Source Developer's avatar
Open Source Developer committed
342 343
        (<any>$(popupMsgId)).modal('show');
    }
Open Source Developer's avatar
trans  
Open Source Developer committed
344

345
    public hideModal(popupMsgId): void {
346

Open Source Developer's avatar
Open Source Developer committed
347 348
        (<any>$(popupMsgId)).modal('hide');
    }
Open Source Developer's avatar
Open Source Developer committed
349

350
    public onHidden(popupMsgId): void {
351

352
    }
Open Source Developer's avatar
trans  
Open Source Developer committed
353

Open Source Developer's avatar
Open Source Developer committed
354

Open Source Developer's avatar
Open Source Developer committed
355
    ngOnDestroy() {
Open Source Developer's avatar
delete  
Open Source Developer committed
356 357
        (<any>$('#applicationDeleteConfirm')).remove();
        (<any>$('#applicationDeleteError')).remove();
Open Source Developer's avatar
Open Source Developer committed
358
    }
359

Open Source Developer's avatar
Open Source Developer committed
360
    ngOnInit() {
361 362 363
        (<any>$('#checksaved')).appendTo("body");
        (<any>$('#dangermodal')).appendTo("body");
        (<any>$('#emptyselection')).appendTo("body");
Open Source Developer's avatar
delete  
Open Source Developer committed
364 365
        (<any>$('#applicationDeleteConfirm')).appendTo("body");
        (<any>$('#applicationDeleteError')).appendTo("body");
366 367 368 369
        this.showLoader.next(true);
        this.CoursesPerSchoolSub = this._hds.FindCoursesPerSchool().subscribe(x => {
            this.CoursesPerSchool$.next(x);
            this.showLoader.next(false);
370

371 372 373 374 375
        },
            error => {
                this.CoursesPerSchool$.next([{}]);
                console.log("Error Getting courses perSchool");
                this.showLoader.next(false);
376
            });
377

Open Source Developer's avatar
Open Source Developer committed
378
    }
379 380


381 382 383 384 385 386 387 388 389
    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);
            },
Open Source Developer's avatar
Open Source Developer committed
390
            error => {
391 392 393 394
                this.StudentInfo$.next([{}]);
                console.log("Error Getting Students");
                this.showLoader.next(false);
                this.showModal("#emptyselection");
395
            });
396

Open Source Developer's avatar
trans  
Open Source Developer committed
397 398
    }

Open Source Developer's avatar
trans  
Open Source Developer committed
399

400 401 402 403 404 405
    setActive(ind) {
        this.StudentActive = -1;
        if (this.courseActive == ind) {
            ind = -1;
        }
        this.courseActive = ind;
Open Source Developer's avatar
Open Source Developer committed
406
    }
407

408 409 410 411 412 413 414
    setActiveStudent(ind) {
        this.opened = true;
        if (this.StudentActive == ind) {
            ind = -1;
        }
        this.StudentActive = ind;
    }
415

416 417 418 419 420 421 422
    setActiveStudentnew(ind) {
        this.opened = false;
        if (this.StudentActive == ind) {
            ind = -1;
        }
        this.StudentActive = ind;
    }
423

Open Source Developer's avatar
trans  
Open Source Developer committed
424

Open Source Developer's avatar
trans  
Open Source Developer committed
425

426 427
    confirmStudent(student, cb, ind) {
        var rtype;
Open Source Developer's avatar
Open Source Developer committed
428
        if (cb.value == 1)
429
            rtype = '1';
Open Source Developer's avatar
Open Source Developer committed
430
        if (cb.value == 2)
431
            rtype = '0';
Open Source Developer's avatar
Open Source Developer committed
432
        if (cb.value == 3)
433
            rtype = null;
Open Source Developer's avatar
Open Source Developer committed
434 435
        var type = cb.value;
        this.showLoader.next(true);
Open Source Developer's avatar
trans  
Open Source Developer committed
436

437 438
        let std = this.StudentInfo$.getValue();
        std[ind].checkstatus = rtype;
Open Source Developer's avatar
Open Source Developer committed
439

Open Source Developer's avatar
Open Source Developer committed
440
        this.SavedStudentsSub = this._hds.saveConfirmStudents(student, type).subscribe(data => {
Open Source Developer's avatar
Open Source Developer committed
441
            this.SavedStudents$.next(data);
Open Source Developer's avatar
Open Source Developer committed
442 443
            this.StudentInfo$.next(std);
            this.showLoader.next(false);
444
            this.showModal("#checksaved");
Open Source Developer's avatar
Open Source Developer committed
445 446 447 448
        },
            error => {
                this.SavedStudents$.next([{}]);
                console.log("Error saving Students");
Open Source Developer's avatar
Open Source Developer committed
449 450
                this.showLoader.next(false);
                this.showModal("#dangermodal");
451
            });
Open Source Developer's avatar
paging  
Open Source Developer committed
452
    }
453

Open Source Developer's avatar
delete  
Open Source Developer committed
454

455 456
    deleteApplication(appId: number, taxi, sector, special): void {

Open Source Developer's avatar
delete  
Open Source Developer committed
457 458 459 460 461 462 463 464 465 466 467
        this.applicationId = appId;
        this.taxi = taxi;
        this.sector = sector;
        this.special = special;
        this.showConfirmModal();
    }





468 469
    deleteApplicationDo(): void {

Open Source Developer's avatar
delete  
Open Source Developer committed
470 471 472
        this.hideConfirmModal();
        this.showLoader.next(true);
        this._hds.deleteApplicationforDirector(this.applicationId).then(data => {
473 474
            this.StudentInfoSub.unsubscribe();
            this.CoursesPerSchoolSub.unsubscribe();
Open Source Developer's avatar
delete  
Open Source Developer committed
475
            this.showLoader.next(false);
476 477
            this.StudentActive = -1;
            //this.courseActive = -1;
Open Source Developer's avatar
delete  
Open Source Developer committed
478

479 480
            this.CoursesPerSchoolSub = this._hds.FindCoursesPerSchool().subscribe(x => {
                this.CoursesPerSchool$.next(x);
Open Source Developer's avatar
delete  
Open Source Developer committed
481
                this.showLoader.next(false);
Open Source Developer's avatar
delete  
Open Source Developer committed
482 483

            },
484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502
                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");
                });
Open Source Developer's avatar
delete  
Open Source Developer committed
503 504 505 506 507 508 509


        }).catch(err => {
            this.showErrorModal();
            this.showLoader.next(false);
        });
    }
510
}