director-view.ts 25.7 KB
Newer Older
1
import { Component, OnInit, OnDestroy, ElementRef, ViewChild, Renderer } 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';
5 6
import { Observable } from "rxjs/Observable";
import { Http, Headers, RequestOptions } from '@angular/http';
Open Source Developer's avatar
tran  
Open Source Developer committed
7
import { NgRedux, select } from 'ng2-redux';
Open Source Developer's avatar
Open Source Developer committed
8
import { IAppState } from '../../store/store';
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
Open Source Developer committed
11
import { ILoginInfo } from '../../store/logininfo/logininfo.types';
Open Source Developer's avatar
trans  
Open Source Developer committed
12

Open Source Developer's avatar
trans  
Open Source Developer committed
13 14 15 16 17 18 19
import {
    FormBuilder,
    FormGroup,
    FormControl,
    FormArray,
    Validators,
} from '@angular/forms';
Open Source Developer's avatar
Open Source Developer committed
20 21 22
@Component({
    selector: 'director-view',
    template: `
23
    <div style="min-height: 500px;">
Open Source Developer's avatar
trans  
Open Source Developer committed
24
  <form [formGroup]="formGroup">
25

Open Source Developer's avatar
Open Source Developer committed
26

Open Source Developer's avatar
trans  
Open Source Developer committed
27 28 29 30 31 32
      <label for="taxi">Τάξη</label><br/>
      <div class="form-group">
            <select #txoption  class="form-control" (change)="verifyclass(txoption)" formControlName="taxi">
              <option value="1" >Α' Λυκείου</option>
              <option value="2" >Β' Λυκείου</option>
              <option value="3" >Γ' Λυκείου</option>
Open Source Developer's avatar
Open Source Developer committed
33
              <option *ngIf="(selectiontype | async)" value="4" >Δ' Λυκείου</option>
Open Source Developer's avatar
trans  
Open Source Developer committed
34
            </select>
35
      </div>
Open Source Developer's avatar
trans  
Open Source Developer committed
36
      <div class="form-group">
Open Source Developer's avatar
trans  
Open Source Developer committed
37
            <select #tmop class="form-control" *ngIf="(selectionBClass | async)" (change)="checkbclass(tmop,txoption)" formControlName="tomeas">
Open Source Developer's avatar
trans  
Open Source Developer committed
38
              <option *ngFor="let SectorSelection$  of StudentSelected$ | async; let i=index" [value] = "SectorSelection$.id"> {{SectorSelection$.sector_id}} </option>
Open Source Developer's avatar
trans  
Open Source Developer committed
39 40 41
            </select>
      </div>
      <div class="form-group">
Open Source Developer's avatar
trans  
Open Source Developer committed
42 43
            <select #spop class="form-control" *ngIf="(selectionCClass | async)" (change) ="checkcclass()" formControlName="specialit">
              <option *ngFor="let SpecialSelection$  of StudentSelectedSpecial$ | async; let i=index" [value] = "SpecialSelection$.id"> {{SpecialSelection$.specialty_id}} </option>
Open Source Developer's avatar
trans  
Open Source Developer committed
44 45
            </select>
      </div>
Open Source Developer's avatar
trans  
Open Source Developer committed
46
             <button type="button" class="btn-primary btn-sm pull-right" (click)="findstudent(txoption,1)">
Open Source Developer's avatar
trans  
Open Source Developer committed
47 48
                Αναζήτηση
             </button>
Open Source Developer's avatar
trans  
Open Source Developer committed
49 50
             <br>
             <br>
Open Source Developer's avatar
trans  
Open Source Developer committed
51
              <div *ngIf="(retrievedStudent | async)">
52 53 54 55 56
                 <div *ngFor="let StudentDetails$  of StudentInfo$ | async; let i=index; let isOdd=odd; let isEven=even" class="row list-group-item isclickable" [class.oddout]="isOdd" [class.evenout]="isEven" (click)="setActiveUser(StudentDetails$.i)"
                  [class.selectedappout]="userActive === StudentDetails$.i" [class.confirmed]="StudentDetails$.checkstatus === '1'"
                  [class.notconfirmed]="StudentDetails$.checkstatus === '0'" [class.notchecked]="(StudentDetails$.checkstatus !== '1') && (StudentDetails$.checkstatus !== '0')" style="margin: 0px 2px 0px 2px;">
                  <div class="col-md-6" style="font-size: 0.8em; font-weight: bold;">{{StudentDetails$.studentsurname}}</div>
                  <div class="col-md-6" style="font-size: 0.8em; font-weight: bold;">{{StudentDetails$.name}}</div>
Open Source Developer's avatar
trans  
Open Source Developer committed
57

58 59
                <div style="width: 100%; color: #000000;">
                    <div [hidden]="userActive !== StudentDetails$.i"  style="margin: 20px 10px 10px 10px;">
60 61 62 63 64

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

                     <div class="row" style="margin-bottom: 20px;">
                     <div class="col-md-6">
Open Source Developer's avatar
trans  
Open Source Developer committed
65 66
                      <strong><label>Επιβεβαίωση Εγγραφής:</label> </strong>
                      <select #cb name="{{StudentDetails$.id}}" (change)="updateCheckedOptions(StudentDetails$.id, cb)" >
67 68 69
                          <option value="1" [selected]="StudentDetails$.checkstatus === '1' ">Ναι</option>
                          <option value="2" [selected]="StudentDetails$.checkstatus === '0' ">Όχι</option>
                          <option value="3" [selected]="StudentDetails$.checkstatus != '0' && StudentDetails$.checkstatus != '1'"></option>
Open Source Developer's avatar
trans  
Open Source Developer committed
70
                      </select>
71 72
                      </div>
                      <div class="col-md-6">
Open Source Developer's avatar
Open Source Developer committed
73
                      <button type="button" class="btn-primary btn-sm pull-right" (click)="confirmStudent(txoption)">
Open Source Developer's avatar
trans  
Open Source Developer committed
74 75
                           Επιβεβαίωση Εγγραφής
                       </button>
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100
                     </div>
                     </div>


                       <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>
101 102 103 104

                       <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>
105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130
                       <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>
                           <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$.certificatetype}}</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$.graduation_year}}</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$.lastschool_schoolname}}</div>
                       </div>

131
                       <div class="row oddin" style="margin: 0px 2px 0px 2px; line-height: 2em;">
132 133 134
                           <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>
                           <div class="col-md-3" style="font-size: 0.8em;">Τάξη τελευταίας φοίτησης</div>
135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154
                           <div *ngIf="StudentDetails$.lastschool_class === '1'" class="col-md-3" style="font-size: 0.8em; font-weight: bold">Α</div>
                           <div *ngIf="StudentDetails$.lastschool_class === '2'" class="col-md-3" style="font-size: 0.8em; font-weight: bold">Β</div>
                           <div *ngIf="StudentDetails$.lastschool_class === '3'" class="col-md-3" style="font-size: 0.8em; font-weight: bold">Γ</div>
                           <div *ngIf="StudentDetails$.lastschool_class === '4'" class="col-md-3" 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-6" style="font-size: 0.8em;">Τάξη φοίτησης για το νέο σχολικό έτος</div>
                           <div *ngIf="StudentDetails$.currentclass === '1'" class="col-md-6" style="font-size: 0.8em; font-weight: bold">Α</div>
                           <div *ngIf="StudentDetails$.currentclass === '2'" class="col-md-6" style="font-size: 0.8em; font-weight: bold">Β</div>
                           <div *ngIf="StudentDetails$.currentclass === '3'" class="col-md-6" style="font-size: 0.8em; font-weight: bold">Γ</div>
                           <div *ngIf="StudentDetails$.currentclass === '4'" class="col-md-6" style="font-size: 0.8em; font-weight: bold">Δ</div>
                       </div>
                       <div *ngIf="StudentDetails$.currentclass === '2'" class="row oddin" style="margin: 0px 2px 0px 2px; line-height: 2em;">
                           <div class="col-md-6" style="font-size: 0.8em;">Τομέας φοίτησης για το νέο σχολικό έτος</div>
                           <div class="col-md-6" style="font-size: 0.8em; font-weight: bold">{{StudentDetails$.currentsector}}</div>
                       </div>
                       <div *ngIf="StudentDetails$.currentclass === '3' || StudentDetails$.currentclass === '4'" class="row oddin" style="margin: 0px 2px 0px 2px; line-height: 2em;">
                           <div class="col-md-6" style="font-size: 0.8em;">Ειδικότητα φοίτησης για το νέο σχολικό έτος</div>
                           <div class="col-md-6" style="font-size: 0.8em; font-weight: bold">{{StudentDetails$.currentcourse}}</div>
155
                       </div>
Open Source Developer's avatar
trans  
Open Source Developer committed
156

Open Source Developer's avatar
trans  
Open Source Developer committed
157
                 </div>
158
                 </div>
Open Source Developer's avatar
trans  
Open Source Developer committed
159
             </div>
160
             </div>
Open Source Developer's avatar
Open Source Developer committed
161 162
          <br>
          <br>
Open Source Developer's avatar
Open Source Developer committed
163
          <div *ngIf="(retrievedStudent | async)">
Open Source Developer's avatar
Open Source Developer committed
164 165 166 167
         <div class="form-group" class="row">
          Βρίσκεστε στη σελίδα:
          <div class="col-1">
           <input #pageno type="text" class="form-control" placeholder=".col-1" formControlName="pageno">
168 169
          </div>
           απο
Open Source Developer's avatar
Open Source Developer committed
170 171
           <div class="col-1">
           <input #maxpage type="text" class="form-control" placeholder=".col-1" formControlName="maxpage">
172
           </div>
Open Source Developer's avatar
Open Source Developer committed
173
         </div>
Open Source Developer's avatar
trans  
Open Source Developer committed
174

Open Source Developer's avatar
Open Source Developer committed
175 176 177 178 179 180 181 182 183 184
             <br>
             <nav aria-label="pagination">
              <ul class="pagination justify-content-center">
                <li class="page-item " >
                  <button class="page-link" (click)="prevpage(txoption)">Προηγούμενη</button>
                </li>
                <li class="page-item">
                  <button class="page-link" (click) ="nextpage(txoption,maxpage) ">Επόμενη</button>
                </li>
              </ul>
185

Open Source Developer's avatar
Open Source Developer committed
186
            </nav>
Open Source Developer's avatar
Open Source Developer committed
187
            </div>
188

189 190 191
            </form>
            </div>

Open Source Developer's avatar
Open Source Developer committed
192

Open Source Developer's avatar
Open Source Developer committed
193 194 195
   `
})

Open Source Developer's avatar
Open Source Developer committed
196

197
@Injectable() export default class DirectorView implements OnInit, OnDestroy {
Open Source Developer's avatar
Open Source Developer committed
198

Open Source Developer's avatar
trans  
Open Source Developer committed
199
    public formGroup: FormGroup;
Open Source Developer's avatar
Open Source Developer committed
200 201
    private StudentSelected$: BehaviorSubject<any>;
    private StudentSelectedSub: Subscription;
Open Source Developer's avatar
trans  
Open Source Developer committed
202 203
    private School$: BehaviorSubject<any>;
    private SchoolSub: Subscription;
Open Source Developer's avatar
trans  
Open Source Developer committed
204 205
    private StudentInfo$: BehaviorSubject<any>;
    private StudentInfoSub: Subscription;
Open Source Developer's avatar
Open Source Developer committed
206
    private StudentsSize$: BehaviorSubject<any>;
Open Source Developer's avatar
Open Source Developer committed
207 208
    private SavedStudentsSub: Subscription;
    private SavedStudents$: BehaviorSubject<any>;
Open Source Developer's avatar
Open Source Developer committed
209
    private StudentsSizeSub: Subscription;
Open Source Developer's avatar
trans  
Open Source Developer committed
210 211
    private StudentSelectedSpecial$: BehaviorSubject<any>;
    private StudentSelectedSpecialSub: Subscription;
Open Source Developer's avatar
trans  
Open Source Developer committed
212 213
    private SubmitedDetails$: BehaviorSubject<any>;
    private SubmitedDetailsSub: Subscription;
Open Source Developer's avatar
trans  
Open Source Developer committed
214
    private retrievedStudent: BehaviorSubject<boolean>;
Open Source Developer's avatar
trans  
Open Source Developer committed
215
    private selectionBClass: BehaviorSubject<boolean>;
Open Source Developer's avatar
Open Source Developer committed
216
    private selectiontype: BehaviorSubject<boolean>;
Open Source Developer's avatar
trans  
Open Source Developer committed
217
    private selectionCClass: BehaviorSubject<boolean>;
218 219
    private limitsSub: Subscription;
    private limits$: BehaviorSubject<any>;
220
    private SchoolId;
Open Source Developer's avatar
trans  
Open Source Developer committed
221
    private currentclass: Number;
222
    private saved: Array<number> = new Array();
223
    private limitdown = 0;
Open Source Developer's avatar
Open Source Developer committed
224
    private limitup = 5;
Open Source Developer's avatar
Open Source Developer committed
225
    private pageno = 1;
226
    public totallimit;
Open Source Developer's avatar
trans  
Open Source Developer committed
227
    private userActive = <number>-1;
Open Source Developer's avatar
trans  
Open Source Developer committed
228
    private type: Number;
229
    public tot_pages: number;
230 231


232
    @ViewChild('fileInput') fileInput: ElementRef;
Open Source Developer's avatar
Open Source Developer committed
233

234 235 236
    constructor(private fb: FormBuilder,
        private _hds: HelperDataService,
        private activatedRoute: ActivatedRoute,
Open Source Developer's avatar
Open Source Developer committed
237
        private router: Router,
238
        private renderer: Renderer) {
239 240 241
        this.StudentSelected$ = new BehaviorSubject([{}]);
        this.StudentSelectedSpecial$ = new BehaviorSubject([{}]);
        this.StudentInfo$ = new BehaviorSubject([{}]);
Open Source Developer's avatar
Open Source Developer committed
242
        this.StudentsSize$ = new BehaviorSubject({});
Open Source Developer's avatar
Open Source Developer committed
243
        this.SavedStudents$ = new BehaviorSubject({});
Open Source Developer's avatar
trans  
Open Source Developer committed
244
        this.SubmitedDetails$ = new BehaviorSubject([{}]);
245
        this.limits$ = new BehaviorSubject([{}]);
246 247 248
        this.retrievedStudent = new BehaviorSubject(false);
        this.selectionBClass = new BehaviorSubject(false);
        this.selectionCClass = new BehaviorSubject(false);
249
        //this.outoflimits = new BehaviorSubject(false);
Open Source Developer's avatar
trans  
Open Source Developer committed
250
        this.School$ = new BehaviorSubject([{}]);
Open Source Developer's avatar
Open Source Developer committed
251
        this.selectiontype = new BehaviorSubject(true);
Open Source Developer's avatar
trans  
Open Source Developer committed
252 253


254 255 256 257
        this.formGroup = this.fb.group({
            tomeas: ['', []],
            taxi: ['', []],
            specialit: ['', []],
258 259
            maxpage: [{ value: '', disabled: true }, []],
            pageno: [{ value: '', disabled: true }, []],
260
        });
261

Open Source Developer's avatar
Open Source Developer committed
262 263
    }

264

265
    ngOnDestroy() {
Open Source Developer's avatar
Open Source Developer committed
266 267
        if (this.StudentSelectedSub)
            this.StudentSelectedSub.unsubscribe();
Open Source Developer's avatar
trans  
Open Source Developer committed
268 269
        if (this.StudentSelectedSpecialSub)
            this.StudentSelectedSpecialSub.unsubscribe();
Open Source Developer's avatar
trans  
Open Source Developer committed
270 271 272
        if (this.selectionBClass)
            this.selectionBClass.unsubscribe();
        if (this.selectionCClass)
273
            this.selectionCClass.unsubscribe();
274
        if (this.retrievedStudent)
Open Source Developer's avatar
Open Source Developer committed
275
            this.retrievedStudent.unsubscribe();
Open Source Developer's avatar
trans  
Open Source Developer committed
276 277
        if (this.SubmitedDetailsSub)
            this.SubmitedDetailsSub.unsubscribe();
278

Open Source Developer's avatar
Open Source Developer committed
279
    }
280

281

Open Source Developer's avatar
Open Source Developer committed
282 283
    ngOnInit() {

Open Source Developer's avatar
Open Source Developer committed
284

285 286 287 288 289 290 291
        this.SchoolSub = this._hds.gettypeofschool().subscribe(x => {
            this.School$.next(x);
            console.log(x[0].type, "schoolid!");
            this.SchoolId = x[0].type;
            if (this.SchoolId == 'ΗΜΕΡΗΣΙΟ') {
                this.selectiontype.next(false);
            }
Open Source Developer's avatar
trans  
Open Source Developer committed
292

293 294 295 296 297 298
        },
            error => {
                this.School$.next([{}]);
                console.log("Error Getting School");
            },
            () => console.log("Getting School "));
Open Source Developer's avatar
Open Source Developer committed
299

300

301
    }
Open Source Developer's avatar
trans  
Open Source Developer committed
302

Open Source Developer's avatar
Open Source Developer committed
303

304
    verifyclass(txop) {
305 306 307
        this.limitdown = 0;
        this.limitup = 5;
        console.log(this.SchoolId, "schoolida");
Open Source Developer's avatar
Open Source Developer committed
308
        this.pageno = 1;
309 310 311 312
        this.retrievedStudent.next(false);
        if (txop.value === "1") {
            this.selectionBClass.next(false);
            this.selectionCClass.next(false);
Open Source Developer's avatar
trans  
Open Source Developer committed
313

314 315
        }
        else if (txop.value === "2") {
Open Source Developer's avatar
Open Source Developer committed
316
            this.StudentSelectedSub = this._hds.getSectorPerSchool().subscribe(data => {
Open Source Developer's avatar
trans  
Open Source Developer committed
317
                this.selectionBClass.next(true);
Open Source Developer's avatar
trans  
Open Source Developer committed
318
                this.selectionCClass.next(false);
319 320 321 322 323 324 325 326 327
                this.StudentSelected$.next(data);

            },
                error => {
                    this.StudentSelected$.next([{}]);
                    console.log("Error Getting StudentSelectedSpecial");
                },
                () => console.log("Getting StudentSelectedSpecial"));
        }
Open Source Developer's avatar
Open Source Developer committed
328
        else if (txop.value === "3" || txop.value === "4") {
329
            var sectorint = +this.formGroup.value.tomeas;
330
            if (this.formGroup.value.tomeas != '') {
331 332
                var sectorint = +this.formGroup.value.tomeas;

Open Source Developer's avatar
Open Source Developer committed
333
                this.StudentSelectedSpecialSub = this._hds.getSpecialityPerSchool(sectorint).subscribe(data => {
334 335 336 337 338 339 340
                    this.StudentSelectedSpecial$.next(data);
                },
                    error => {
                        this.StudentSelectedSpecial$.next([{}]);
                        console.log("Error Getting StudentSelectedSpecial");
                    },
                    () => console.log("Getting StudentSelectedSpecial"));
341
            }
342

Open Source Developer's avatar
Open Source Developer committed
343
            this.StudentSelectedSub = this._hds.getSectorPerSchool().subscribe(data => {
344 345 346 347 348 349 350 351 352 353
                this.StudentSelected$.next(data);
                this.selectionBClass.next(true);
                this.selectionCClass.next(true);
            },
                error => {
                    this.StudentSelected$.next([{}]);
                    console.log("Error Getting StudentSelected");
                },
                () => console.log("Getting StudentSelected"));
        }
Open Source Developer's avatar
trans  
Open Source Developer committed
354 355
    }

Open Source Developer's avatar
Open Source Developer committed
356

357
    checkbclass(tmop, txop) {
358
        console.log(this.SchoolId, "schoolidn");
Open Source Developer's avatar
Open Source Developer committed
359
        this.pageno = 1;
Open Source Developer's avatar
trans  
Open Source Developer committed
360 361
        this.retrievedStudent.next(false);
        var sectorint = +this.formGroup.value.tomeas;
362
        console.log(sectorint, "tomeas");
Open Source Developer's avatar
Open Source Developer committed
363
        if (txop.value === "3" || txop.value === "4") {
364
            //            this.StudentSelectedSpecial$ = new BehaviorSubject([{}]);
Open Source Developer's avatar
Open Source Developer committed
365
            this.StudentSelectedSpecialSub = this._hds.getSpecialityPerSchool(sectorint).subscribe(data => {
366 367 368 369 370 371 372 373
                this.StudentSelectedSpecial$.next(data);

            },
                error => {
                    this.StudentSelectedSpecial$.next([{}]);
                    console.log("Error Getting StudentSelectedSpecial");
                },
                () => console.log("Getting StudentSelectedSpecial"));
Open Source Developer's avatar
trans  
Open Source Developer committed
374 375 376
        }
    }

Open Source Developer's avatar
Open Source Developer committed
377
    findstudent(txop, pageno) {
378

379
        let sectorint = +this.formGroup.value.tomeas;
380
        this.currentclass = +txop.value;
381

382 383
        this.formGroup.get('pageno').setValue(this.pageno);
        if (this.pageno == 1) {
384 385

            console.log("mphkepage = 1");
386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433
            this.StudentsSizeSub = this._hds.getStudentPerSchool(sectorint, this.currentclass, 0, 0)
                .subscribe(x => {
                    this.StudentsSize$.next(x);
                    this.totallimit = x.id;

                    this.limitsSub = this._hds.getlimitsofcourse(this.currentclass).subscribe(data => {
                        this.limits$.next(data);
                        console.log(this.totallimit, data[0].limitdown, "oria");
                        this.tot_pages = Math.floor(x.id / 5);
                        if (x.id % 5 > 0) {
                            // this.tot_pages = (x.id - (x.id % 5)) / 5 + 1;
                            this.tot_pages += 1;
                        }
                        console.log(this.tot_pages, "totpages")
                        if (isNaN(this.tot_pages)) {
                            this.retrievedStudent.next(false);
                            this.tot_pages = 0;
                        }
                        if ((x.id < parseInt(data[0].limitdown)) || (isNaN(this.tot_pages))) {
                            console.log("mphkeprwto!")
                            this.retrievedStudent.next(false);
                            this.tot_pages = 0;
                            this.formGroup.get('maxpage').setValue(this.tot_pages);
                            //this.outoflimits.next(true);
                        } else {
                            // this.outoflimits.next(false);
                            this.formGroup.get('maxpage').setValue(this.tot_pages);
                            console.log(this.tot_pages, "mazeuw mathites");
                            this.StudentInfoSub = this._hds.getStudentPerSchool(sectorint, this.currentclass, this.limitdown, this.limitup)
                                .subscribe(data => {
                                    this.StudentInfo$.next(data);
                                    console.log("tot.pages", this.formGroup.value.maxpage, "max1", this.tot_pages);
                                    this.retrievedStudent.next(true);
                                },
                                error => {
                                    this.StudentInfo$.next([{}]);
                                    console.log("Error Getting Students");
                                },
                                () => console.log("Getting Students")
                                );
                        }
                    },
                        error => {
                            this.limits$.next([{}]);
                            console.log("Error Getting limits");
                        },
                        () => console.log("Getting limits")
                    );
434

435
                });
436 437

        }
438 439
        else {
            console.log("eisai edw", this.tot_pages);
440 441


442 443 444 445 446 447
            if (this.tot_pages == 0) {
                console.log("mphke1", this.formGroup.value.maxpage, this.tot_pages);
                this.retrievedStudent.next(false);
            }
            else {
                console.log(this.tot_pages, "mazeuw mathites");
448
                this.StudentInfoSub = this._hds.getStudentPerSchool(sectorint, this.currentclass, this.limitdown, this.limitup).subscribe(data => {
449
                    this.StudentInfo$.next(data);
450

451 452
                    console.log("tot.pages", this.formGroup.value.maxpage, "max1", this.tot_pages);
                    this.retrievedStudent.next(true);
453

454 455 456 457 458 459 460
                },
                    error => {
                        this.StudentInfo$.next([{}]);
                        console.log("Error Getting Students");
                    },
                    () => console.log("Getting Students"));
            }
461
        }
462

Open Source Developer's avatar
trans  
Open Source Developer committed
463 464
    }

Open Source Developer's avatar
trans  
Open Source Developer committed
465
    updateCheckedOptions(id, cbvalue) {
Open Source Developer's avatar
Open Source Developer committed
466
        let i = 0;
Open Source Developer's avatar
trans  
Open Source Developer committed
467

Open Source Developer's avatar
trans  
Open Source Developer committed
468
        if (cbvalue.value === '1') {
469 470 471
            this.saved[i] = id;
            this.type = 1;

472
        }
Open Source Developer's avatar
trans  
Open Source Developer committed
473
        else if (cbvalue.value === '2') {
474
            this.saved[i] = id;
Open Source Developer's avatar
trans  
Open Source Developer committed
475
            this.type = 2;
476

477
            console.log("not confirmed")
Open Source Developer's avatar
trans  
Open Source Developer committed
478 479
        }
        else if (cbvalue.value === '3') {
480

Open Source Developer's avatar
trans  
Open Source Developer committed
481
        }
482
    }
Open Source Developer's avatar
trans  
Open Source Developer committed
483

Open Source Developer's avatar
trans  
Open Source Developer committed
484 485


Open Source Developer's avatar
Open Source Developer committed
486
    confirmStudent(txop) {
Open Source Developer's avatar
Open Source Developer committed
487

488
        this.SavedStudentsSub = this._hds.saveConfirmStudents(this.saved, this.type).subscribe(data => {
Open Source Developer's avatar
Open Source Developer committed
489
            this.SavedStudents$.next(data);
490

Open Source Developer's avatar
Open Source Developer committed
491 492 493 494 495 496
        },
            error => {
                this.SavedStudents$.next([{}]);
                console.log("Error saving Students");
            },
            () => {
497 498 499
                console.log("saved Students");
                this.findstudent(txop, this.pageno);
            });
500 501 502



503
    }
Open Source Developer's avatar
trans  
Open Source Developer committed
504

505
    checkcclass() {
Open Source Developer's avatar
Open Source Developer committed
506
        this.pageno = 1;
507 508
        this.retrievedStudent.next(false);
    }
Open Source Developer's avatar
trans  
Open Source Developer committed
509

510 511 512 513 514 515 516 517
    nextpage(txop, maxpage) {
        console.log(maxpage.value);
        if (this.pageno < maxpage.value) {
            this.pageno = this.pageno + 1;
            this.limitdown = (this.pageno - 1) * 5;
            this.limitup = this.pageno * 5;
            this.findstudent(txop, this.pageno)
        }
Open Source Developer's avatar
Open Source Developer committed
518 519
    }

520 521 522 523 524 525 526 527
    prevpage(txop) {
        console.log(this.pageno, "pageno");
        if (this.pageno > 1) {
            this.pageno = this.pageno - 1;
            this.limitdown = (this.pageno - 1) * 5;
            this.limitup = this.pageno * 5;
            this.findstudent(txop, this.pageno)
        }
Open Source Developer's avatar
Open Source Developer committed
528 529 530 531

    }


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

533 534 535 536 537 538 539 540 541
    setActiveUser(ind) {
        ind = +ind;
        console.log(this.userActive, "RA", ind);
        if (ind === this.userActive) {
            ind = -1;
        }
        ind--;
        this.userActive = ind + 1;

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

543
    }
Open Source Developer's avatar
trans  
Open Source Developer committed
544 545


546
}