forked from wattnpapa/wp-dienstplan
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpdf.php
161 lines (149 loc) · 5.35 KB
/
pdf.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
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
67
68
69
70
71
72
73
74
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
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
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
157
158
159
160
161
<?php
require('fpdf17/fpdf.php');
class PDF extends FPDF {
function Header(){
global $wpdb;
$table_name_meta = $wpdb->prefix . "dienstplan_meta";
$row = $wpdb->get_results("select * from $table_name_meta");
//include("config.inc");
//$bereich_id = $_GET['bereich'];
global $wpdb;
$table_name_gruppen = $wpdb->prefix . "dienstplan_gruppen";
$table_name_dienst = $wpdb->prefix . "dienstplan_dienste";
$term_id = $_GET['pdfdienstplan'];
$bereich = $wpdb->get_var("Select name from $wpdb->terms where term_id = $term_id");
//$query = "select bereich_name from bereich where bereich_id = '".$bereich_id."'";
//$quelle = mysql_query($query);
//$row = mysql_fetch_assoc($quelle);
//echo $config_feuerwehrname_gemeinde;
//Logo
//$this->Image('css/wappenstadt.jpg',20,10,33);
//$this->Image('css/wappenff.jpg',170,10,33);
//Arial bold 15
$this->SetFont('Times','B',15);
//Move to the right
$this->Ln();
//Title
$this->Ln(8);
$this->SetY(15);
$this->Cell(0,0,$row[0]->text_oben,0,0,'C');
$this->Ln(10);
$this->Cell(0,0,'- '.$row[0]->text_unten.' -',0,2,'C');
$this->Ln(10);
$this->Cell(0,0,$bereich,0,0,'C');
$this->Ln(10);
$this->Cell(0,0,'Dienstplan',0,2,'C');
$this->Ln(20);
}
function LoadData(){
//Read file lines
//$lines=file($file);
/*$data=array();
$bereich_id = $_GET['bereich'];
$query = " select
d.dienst_id
,d.dienst_datum_zeit
,d.dienst_beschreibung
,d.dienst_ort
,d.bereich_id
from
dienst d
where
d.bereich_id = '".$bereich_id."'
and d.dienst_datum_zeit > NOW()
order by
d.dienst_datum_zeit
";
$quelle = mysql_query($query);
while($row = mysql_fetch_assoc($quelle)){
$data[] = $row;
}
return $data;*/
}
function FancyTable($data){
//print_r($data);
//Colors, line width and bold font
$this->SetFillColor(255,0,0);
$this->SetTextColor(255);
$this->SetDrawColor(128,0,0);
$this->SetLineWidth(.1);
$this->SetFont('Arial','B');
//Header
//w=array(0,5,10,15,20,25,30,35,40,45,50,55,60,65,70);
/*for($i=0;$i<count($header);$i++)
$this->Cell($w[$i],7,$header[$i],1,0,'C',true);*/
$this->Ln();
//Color and font restoration
$this->SetFillColor(224,235,255);
$this->SetTextColor(0);
$this->SetFont('Arial','',10);
//Data
$fill=false;
$ersterlauf = 1;
$monat = '';
$start_page_y = $this->GetY();
//echo $start_page_y;
foreach($data as $row){
$y2 = 0;
$this->SetX(20);
if($this->GetY() > 260){
$this->AddPage();
$ersterlauf = 1;
}
if($ersterlauf == 1){
$ersterlauf = 0;
$monat = substr(date_mysql2german($row['dienst_datum_zeit']),3,2);
$this->Cell(20,6,html_entity_decode(monat($row['dienst_datum_zeit'],1)),0,0,'L');
$this->Ln();
}
else{
$monatneu = substr(date_mysql2german($row['dienst_datum_zeit']),3,2);
if($monatneu != $monat){
$monat = $monatneu;
$this->Ln(10);
$this->Cell(20,6,html_entity_decode(monat($row['dienst_datum_zeit'],1)),0,0,'L');
$this->Ln();
}
}
$this->SetX(20);
$y = $this->GetY();
//$this->Cell(20,6,$this->GetY(),0,0,'L');
$this->Cell(20,6,date_mysql2german(substr($row['dienst_datum_zeit'],0,10)),0,0,'L');
$this->SetX(40);
$zeit = substr($row['dienst_datum_zeit'],11,5);
if($zeit == "00:00"){
$zeit = "";
}
$this->Cell(15,6,$zeit,0,0,'L');
$this->SetXY(50,$y);
$this->MultiCell(30,6,read_dienstgruppe_dienst($row['dienst_id'],1),0,'L');
if($this->GetY() > $y2){
//echo "1";
$y2 = $this->GetY();
}
$this->SetXY(85,$y);
$this->MultiCell(75,6,html_entity_decode($row['dienst_beschreibung']),0,'L');
if($this->GetY() > $y2){
$y2 = $this->GetY();
}
$this->SetXY(160,$y);
$this->MultiCell(40,6,html_entity_decode($row['dienst_ort']),0,'L');
if($this->GetY() > $y2){
$y2 = $this->GetY();
}
$this->SetXY(160,$y2);
//$this->Ln();
//$fill=!$fill;
}
//$this->Cell(array_sum($w),0,'');
}
//Page footer
function Footer(){
//Position at 1.5 cm from bottom
$this->SetY(-15);
//Arial italic 8
$this->SetFont('Arial','I',8);
//Page number
//$this->Cell(0,10,'Page '.$this->PageNo().'/{nb}',0,0,'C');
}
}