submited.aplication.preview.ts 15.2 KB
Newer Older
1
import { Component, OnInit, OnDestroy, ElementRef, ViewChild} from "@angular/core";
Open Source Developer's avatar
Open Source Developer committed
2
3
4
5
6
7
8
9
let jsPDF = require('jspdf');
import { Injectable } from "@angular/core";
import { AppSettings } from '../../app.settings';
import { HelperDataService } from '../../services/helper-data-service';
import {Http, Headers, RequestOptions} from '@angular/http';
import { NgRedux, select } from 'ng2-redux';
import { IAppState } from '../../store/store';
import { ILoginInfo } from '../../store/logininfo/logininfo.types';
Open Source Developer's avatar
Open Source Developer committed
10
11
import {Router, ActivatedRoute, Params} from '@angular/router';
import { BehaviorSubject, Subscription } from 'rxjs/Rx';
12
13


14
@Component({
Open Source Developer's avatar
Open Source Developer committed
15
16
    selector: 'submited-preview',
    template: `
17
<div style="min-height: 500px; margin-bottom: 20px;">
18
    <div class = "loading" *ngIf="(showLoader$ | async) === true"></div>
19
20
         <div class="row">
             <breadcrumbs></breadcrumbs>
Open Source Developer's avatar
commit    
Open Source Developer committed
21
        </div>
22
        <br/>
23
            Έχει υποβληθεί αίτηση για εγγραφή στην Επαγγελματική Εκπαίδευση των παρακάτω ατόμων:
24

25
26

              <div class="row list-group-item" style="margin: 0px 2px 0px 2px; background-color: #ccc;">
27
                  <div class="col-md-6" style="font-size: 1em; font-weight: bold;">Επώνυμο</div>
28
                  <div class="col-md-6" style="font-size: 1em; font-weight: bold;">Όνομα</div>
29
              </div>
30

31
               <div class="row list-group-item isclickable"  style="margin: 0px 2px 0px 2px;"
32
33
34
               [class.oddout]="isOdd"
               [class.evenout]="isEven"
               (click)="setActiveUser(UserData$.id)"
35
               [class.selectedappout]="userActive === UserData$.id"
36
37
               *ngFor="let UserData$  of SubmitedApplic$ | async; let i=index; let isOdd=odd; let isEven=even"  >
                    <div class="col-md-6" style="font-size: 0.8em; font-weight: bold;">{{UserData$.studentsurname}}</div>
38
                    <div class="col-md-6" style="font-size: 0.8em; font-weight: bold;">{{UserData$.name}}</div>
39

40
41
                    <div style="width: 100%">
                  <div *ngFor="let StudentDetails$  of SubmitedDetails$ | async" [hidden]="UserData$.id !== userActive" style="margin: 10px 10px 10px 10px;">
42

43
44
45
46
47
48
                  <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$.applicationId}}</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>
49
50
51
                  <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>
52

53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
                  <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>
71
72
73
74

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

                  <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_schoolyear}}</div>
                      <div class="col-md-3" style="font-size: 0.8em;">Τάξη τελευταίας φοίτησης</div>
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
                      <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>
125
126
127
128
129
130
131
132
133
134
135
136
                  </div>

                    <div class="row evenin" style="margin: 0px 2px 0px 2px; line-height: 2em;">
                        <div class="col-md-6" style="font-size: 1em; font-weight: bold;">Επιλογή ΕΠΑΛ</div>
                        <div class="col-md-6" 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;" *ngFor="let epalChoices$  of EpalChosen$ | async; let i=index; let isOdd=odd; let isEven=even" [hidden]="UserData$.id !== userActive">
                        <div class="col-md-6" style="font-size: 0.8em; font-weight: bold;">{{epalChoices$.epal_id}}</div>
                        <div class="col-md-6" style="font-size: 0.8em; font-weight: bold; text-align: center;">{{epalChoices$.choice_no}}</div>
                    </div>

137
                    <div class="row" style="margin-top: 20px; margin-bottom: 20px;">
138
                        <div class="col-md-12">
139
140
141
142
                            <button type="button" class="btn-primary btn-lg pull-right isclickable" style="width: 10em;" (click)="createPdfServerSide()">
                                <span style="font-size: 0.9em; font-weight: bold;">Εκτύπωση(PDF)&nbsp;&nbsp;&nbsp;</span>
                            </button>
                        </div>
143

144
145
                    </div>
                    </div>
146
                </div>
147

148
149
              </div>
              </div>
150

Open Source Developer's avatar
Open Source Developer committed
151
152
153
   `
})

154
@Injectable() export default class SubmitedPreview implements OnInit, OnDestroy {
Open Source Developer's avatar
Open Source Developer committed
155

Open Source Developer's avatar
Open Source Developer committed
156
157
    private SubmitedApplic$: BehaviorSubject<any>;
    private SubmitedUsersSub: Subscription;
Open Source Developer's avatar
styles    
Open Source Developer committed
158
159
160
161
    private SubmitedDetails$: BehaviorSubject<any>;
    private SubmitedDetailsSub: Subscription;
    private EpalChosen$: BehaviorSubject<any>;
    private EpalChosenSub: Subscription;
Open Source Developer's avatar
trans    
Open Source Developer committed
162
163
164
165
    private incomeChosen$: BehaviorSubject<any>;
    private incomeChosenSub: Subscription;
    private CritirioChosen$: BehaviorSubject<any>;
    private CritirioChosenSub: Subscription;
166
    private showLoader$: BehaviorSubject<boolean>;
Open Source Developer's avatar
styles    
Open Source Developer committed
167

Open Source Developer's avatar
Open Source Developer committed
168
    public StudentId;
Open Source Developer's avatar
styles    
Open Source Developer committed
169
    private userActive = <number>-1;
170

171
    @ViewChild('target') element: ElementRef;
Open Source Developer's avatar
trans    
Open Source Developer committed
172

173
    constructor(private _ngRedux: NgRedux<IAppState>,
174
175
176
177
178
179
180
181
182
183
184
        private _hds: HelperDataService,
        private activatedRoute: ActivatedRoute,
        private router: Router,
        /*private fb: FormBuilder,*/
    ) {
        this.SubmitedApplic$ = new BehaviorSubject([{}]);
        this.SubmitedDetails$ = new BehaviorSubject([{}]);
        this.EpalChosen$ = new BehaviorSubject([{}]);
        this.CritirioChosen$ = new BehaviorSubject([{}]);
        this.incomeChosen$ = new BehaviorSubject([{}]);
        this.showLoader$ = new BehaviorSubject(false);
185

Open Source Developer's avatar
Open Source Developer committed
186
187
    }

188
    ngOnDestroy() {
Open Source Developer's avatar
Open Source Developer committed
189
190
        if (this.SubmitedUsersSub)
            this.SubmitedUsersSub.unsubscribe();
Open Source Developer's avatar
styles    
Open Source Developer committed
191
192
193
194
        if (this.SubmitedDetailsSub)
            this.SubmitedDetailsSub.unsubscribe();
        if (this.EpalChosenSub)
            this.EpalChosenSub.unsubscribe();
Open Source Developer's avatar
trans    
Open Source Developer committed
195
196
197
198
199
        if (this.CritirioChosenSub)
            this.CritirioChosenSub.unsubscribe();
        if (this.incomeChosenSub)
            this.incomeChosenSub.unsubscribe();

Open Source Developer's avatar
styles    
Open Source Developer committed
200
201
        this.SubmitedDetails$.unsubscribe();
        this.EpalChosen$.unsubscribe();
202
        this.SubmitedApplic$.unsubscribe();
Open Source Developer's avatar
Open Source Developer committed
203

Open Source Developer's avatar
tranfer    
Open Source Developer committed
204
    }
205

Open Source Developer's avatar
Open Source Developer committed
206
    ngOnInit() {
207

208
        this.showLoader$.next(true);
Open Source Developer's avatar
Open Source Developer committed
209

210
211
212
213
214
        this.SubmitedUsersSub = this._hds.getSubmittedPreviw().subscribe(
            data => {
                this.SubmitedApplic$.next(data);
                this.showLoader$.next(false);
            },
Open Source Developer's avatar
styles    
Open Source Developer committed
215
216
            error => {
                this.SubmitedApplic$.next([{}]);
217
                this.showLoader$.next(false);
Open Source Developer's avatar
styles    
Open Source Developer committed
218
219
                console.log("Error Getting Schools");
            },
220
221
222
223
            () => {
                console.log("Getting Schools")
                this.showLoader$.next(false);
            });
224

Open Source Developer's avatar
Open Source Developer committed
225
226
    }

Open Source Developer's avatar
styles    
Open Source Developer committed
227

228
229
230
231
232
233
234
235
236
237
238
239
240
    setActiveUser(ind: number): void {
        ind = +ind;
        if (ind === this.userActive) {
            ind = -1;
            return;
        }
        ind--;
        this.userActive = ind + 1;
        this.showLoader$.next(true);
        this.SubmitedDetailsSub = this._hds.getStudentDetails(this.userActive + 1).subscribe(data => {
            this.SubmitedDetails$.next(data);
            this.showLoader$.next(false);
        },
Open Source Developer's avatar
styles    
Open Source Developer committed
241
242
243
            error => {
                this.SubmitedDetails$.next([{}]);
                console.log("Error Getting Schools");
244
                this.showLoader$.next(false);
Open Source Developer's avatar
styles    
Open Source Developer committed
245
            },
246
247
248
249
250
251
252
            () => {
                console.log("Getting Schools");
                this.showLoader$.next(false);
            });
        this.EpalChosenSub = this._hds.getEpalchosen(this.userActive + 1).subscribe(data => {
            this.EpalChosen$.next(data)
        },
Open Source Developer's avatar
styles    
Open Source Developer committed
253
254
255
256
            error => {
                this.EpalChosen$.next([{}]);
                console.log("Error Getting Schools");
            },
257
258
            () => console.log("Getting Schools"));
    }
Open Source Developer's avatar
trans    
Open Source Developer committed
259

260
261
262
    createPdfServerSide() {
        //this._hds.createPdfServerSide(this.authToken, this.role, this.userActive +1 );
        this._hds.createPdfServerSide(this.userActive + 1);
263

264
    }
265
266

}