submited.aplication.preview.ts 5.99 KB
Newer Older
Open Source Developer's avatar
tranfer    
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
5
6
7
8
9
10
11
12
let jsPDF = require('jspdf');
import { Injectable } from "@angular/core";
import { AppSettings } from '../../app.settings';
import { HelperDataService } from '../../services/helper-data-service';
import {Observable} from "rxjs/Observable";
import {IStudentDataFields, IStudentDataField} from '../../store/studentdatafields';
import {Http, Headers, RequestOptions} from '@angular/http';
import {Removetags} from '../../pipes/removehtmltags';
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
13
14
import {Router, ActivatedRoute, Params} from '@angular/router';
import { BehaviorSubject, Subscription } from 'rxjs/Rx';
Open Source Developer's avatar
Open Source Developer committed
15
16


Open Source Developer's avatar
styles    
Open Source Developer committed
17
@Component({ 
Open Source Developer's avatar
Open Source Developer committed
18
19
    selector: 'submited-preview',
    template: `
Open Source Developer's avatar
styles    
Open Source Developer committed
20
         <div class="row"> 
Open Source Developer's avatar
commit    
Open Source Developer committed
21
22
             <breadcrubs></breadcrubs>
        </div>
23
            Έχει υποβληθεί αίτηση για εγγραφή στην Επαγγελματική Εκπαίδευση των παρακάτω ατόμων:
Open Source Developer's avatar
styles    
Open Source Developer committed
24
25
26
27
28
29
30
31
32
33
34
           
              <ul class="list-group main-view">
               <div *ngFor="let UserData$  of SubmitedApplic$ | async; let i=index; let isOdd=odd; let isEven=even"  >
                 <li class="list-group-item isclickable" [class.oddout]="isOdd" 
                 [class.evenout]="isEven" (click)="setActiveUser(UserData$.id)" [class.selectedout]="userActive === UserData$.id" >
                  <h5> {{UserData$.name}}&nbsp;{{UserData$.studentsurname}} </h5>
                   </li>
                  <div id = "target">
               


Open Source Developer's avatar
trans    
Open Source Developer committed
35
                  <div *ngFor="let StudentDetails$  of SubmitedDetails$ | async" [hidden]="UserData$.id !== userActive" >
Open Source Developer's avatar
trans    
Open Source Developer committed
36
37
38


                 <strong> Όνομα:</strong>    <p id="name" style="border:1px solid #eceeef;">    {{StudentDetails$.name}} </p>
Open Source Developer's avatar
styles    
Open Source Developer committed
39
40
41
42
43
44
45
46
                 <strong> Επώνυμο:</strong>    <p style="border:1px solid #eceeef;">    {{StudentDetails$.studentsurname}} </p>
                 <strong> Όνομα Πατέρα:</strong>  <p style="border:1px solid #eceeef;"> {{StudentDetails$.fatherfirstname}}</p>
                 <strong> Επώνυμο Πατέρα:</strong> <p style="border:1px solid #eceeef;">{{StudentDetails$.fathersurname}}</p>
                 <strong> Όνομα Μητέρας:</strong>  <p style="border:1px solid #eceeef;">{{StudentDetails$.motherfirstname}}</p>
                 <strong> Επώνυμο Μητέρας:</strong> <p style="border:1px solid #eceeef;">{{StudentDetails$.mothersurname}}</p>
                 <strong> Ημερομηνία Γέννησης:</strong> <p style="border:1px solid #eceeef;">{{StudentDetails$.birthdate}}</p>
                 <p><b>Επιλογές ΕΠΑΛ</b> </p>
                 <br>
Open Source Developer's avatar
trans    
Open Source Developer committed
47
               </div>
Open Source Developer's avatar
styles    
Open Source Developer committed
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
                
                <div *ngFor="let epalChoices$  of EpalChosen$ | async" [hidden]="UserData$.id !== userActive">
                     Σχολείο: {{epalChoices$.epal_id}}
                     Σειρά Προτίμισης:{{epalChoices$.choice_no}}
                </div>

            </div>
            


            
                </div>
              </ul>
              <br>
              <button type="button" (click)="createPdf()">Εξαγωγή σε PDF</button>
63

Open Source Developer's avatar
Open Source Developer committed
64
65
66
   `
})

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

69

Open Source Developer's avatar
Open Source Developer committed
70
71
    private SubmitedApplic$: BehaviorSubject<any>;
    private SubmitedUsersSub: Subscription;
Open Source Developer's avatar
styles    
Open Source Developer committed
72
73
74
75
76
    private SubmitedDetails$: BehaviorSubject<any>;
    private SubmitedDetailsSub: Subscription;

    private EpalChosen$: BehaviorSubject<any>;
    private EpalChosenSub: Subscription;
Open Source Developer's avatar
trans    
Open Source Developer committed
77
 
Open Source Developer's avatar
styles    
Open Source Developer committed
78

Open Source Developer's avatar
Open Source Developer committed
79
    public StudentId;
Open Source Developer's avatar
styles    
Open Source Developer committed
80
    private userActive = <number>-1;
81
82

    constructor(private _hds: HelperDataService,
Open Source Developer's avatar
Open Source Developer committed
83
                private activatedRoute: ActivatedRoute,
Open Source Developer's avatar
trans    
Open Source Developer committed
84
                private router: Router ,
Open Source Developer's avatar
trans    
Open Source Developer committed
85
              )
Open Source Developer's avatar
Open Source Developer committed
86
    {
Open Source Developer's avatar
Open Source Developer committed
87
       this.SubmitedApplic$ = new BehaviorSubject([{}]);
Open Source Developer's avatar
styles    
Open Source Developer committed
88
89
       this.SubmitedDetails$ = new BehaviorSubject([{}]);
       this.EpalChosen$ = new BehaviorSubject([{}]);
Open Source Developer's avatar
Open Source Developer committed
90
91
    }

Open Source Developer's avatar
tranfer    
Open Source Developer committed
92
93
    ngOnDestroy()
    {
Open Source Developer's avatar
Open Source Developer committed
94
95
        if (this.SubmitedUsersSub)
            this.SubmitedUsersSub.unsubscribe();
Open Source Developer's avatar
styles    
Open Source Developer committed
96
97
98
99
100
101
        if (this.SubmitedDetailsSub)
            this.SubmitedDetailsSub.unsubscribe();
        if (this.EpalChosenSub)
            this.EpalChosenSub.unsubscribe();
        this.SubmitedDetails$.unsubscribe();
        this.EpalChosen$.unsubscribe();
102
        this.SubmitedApplic$.unsubscribe();
Open Source Developer's avatar
Open Source Developer committed
103

Open Source Developer's avatar
tranfer    
Open Source Developer committed
104
    }
Open Source Developer's avatar
Open Source Developer committed
105
 
Open Source Developer's avatar
Open Source Developer committed
106
    ngOnInit() {
107

Open Source Developer's avatar
Open Source Developer committed
108

Open Source Developer's avatar
styles    
Open Source Developer committed
109
110
111
112
113
114
115
        this.SubmitedUsersSub = this._hds.getSubmittedPreviw().subscribe(data => {
          this.SubmitedApplic$.next(data)},
            error => {
                this.SubmitedApplic$.next([{}]);
                console.log("Error Getting Schools");
            },
            () => console.log("Getting Schools"));
Open Source Developer's avatar
Open Source Developer committed
116
        console.log(this.SubmitedApplic$);
117
118


Open Source Developer's avatar
styles    
Open Source Developer committed
119
120
121
    


Open Source Developer's avatar
Open Source Developer committed
122
123
124

    }

Open Source Developer's avatar
styles    
Open Source Developer committed
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
   


  setActiveUser(ind,i) 
  {
    ind = +ind;
    
      console.log(this.userActive,"RA",ind);
      if (ind === this.userActive){
        ind = -1;
      }
      ind--;
      this.userActive = ind+1 ;
      this.SubmitedDetailsSub = this._hds.getStudentDetails(this.userActive+1).subscribe(data => {
        this.SubmitedDetails$.next(data)},
            error => {
                this.SubmitedDetails$.next([{}]);
                console.log("Error Getting Schools");
            },
             () => console.log("Getting Schools"));
      this.EpalChosenSub = this._hds.getEpalchosen(this.userActive+1).subscribe(data => {
        this.EpalChosen$.next(data)},
            error => {
                this.EpalChosen$.next([{}]);
                console.log("Error Getting Schools");
            },
             () => console.log("Getting Schools"));


   }

 createPdf()
Open Source Developer's avatar
Open Source Developer committed
157
    {
Open Source Developer's avatar
styles    
Open Source Developer committed
158
159
160
161
162
163
164
165
        
       html2canvas(document.getElementById("target")).then(function(canvas)
        {
            var img = canvas.toDataURL();
            var doc = new jsPDF('p', 'mm');
            doc.addImage(img, 'PNG', 10, 10);
            doc.save('applications.pdf');
        });
Open Source Developer's avatar
Open Source Developer committed
166
    }
167
}