-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathexportPDF.php
More file actions
550 lines (170 loc) · 6.07 KB
/
exportPDF.php
File metadata and controls
550 lines (170 loc) · 6.07 KB
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
162
163
164
165
166
167
168
169
170
171
172
173
174
<?php
/**
* Classe exportPDF.php
* @author Stefano Bianchini
*
* Esporta la Bacheca del progetto in formato PDF
*/
require("startup.php");
//Se non e' loggato, lo rimando alla pagina iniziale
if(!($user->isLogged())) {
header("Location: index.php");
exit();
}
//Carico le librerie neccessarie
require_once('engine/tcpdf/config/lang/ita.php');
require_once('engine/tcpdf/tcpdf.php');
// create new PDF document
$pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
// set document information
$pdf->SetCreator(PDF_CREATOR);
$pdf->SetAuthor('Architeka');
$pdf->SetTitle('Bacheca di Progetto');
$pdf->SetSubject('Architeka');
//$pdf->SetKeywords('TCPDF, PDF, example, test, guide');
// set default header data
$pdf->SetHeaderData('', '', '', '');
// set header and footer fonts
$pdf->setHeaderFont(Array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN));
$pdf->setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA));
// set default monospaced font
$pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
//set margins
$pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
$pdf->SetHeaderMargin(PDF_MARGIN_HEADER);
$pdf->SetFooterMargin(PDF_MARGIN_FOOTER);
//set auto page breaks
$pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
//set image scale factor
$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
//set some language-dependent strings
$pdf->setLanguageArray($l);
// ---------------------------------------------------------
// set font
$pdf->SetFont('dejavusans', '', 10);
// add a page
$pdf->AddPage();
/*
* Qui inizio caricamento dati
*/
/*
* Creazione oggetti
*/
$e = new entry($registry);
$p=new project($registry);
$filter="";
//!QUA FARE TUTTI I CONTROLLI DI DIRITTI PER IL PROGETTO SELEZIONATO
//e' un cliente, non puo' stampare il progetto in pdf (puo' solo l'architetto)
if($user->clientOf()>0) {
$filter=' AND 0';
} else {
//non e' un cliente, e' il professionista
//Controllo che il professionista sia il project_authorid
if($session->data['idproject']>0) {
if($p->getAuthorId($session->data['idproject'])==$user->getId()) {
$filter=" AND entry_project_id='".$session->data['idproject']."'";
}
else $filter=' AND 0';
}
}
$entryArray = $e->getAllEntry($filter,'');
$nome_progetto = $p->getName($session->data['idproject']);$professionista = $user->getTitle().' '.$user->getFirstname().' '.$user->getLastname();$listaClienti=$p->getClients($session->data['idproject']);
/*
* Strutturo l'array delle entry
*/
foreach($entryArray as $entry) {
$entries[] = array(
'content'=>$e->elaborateContent($entry['entry_content'],$entry['entry_type']),
'originalContent'=>$entry['entry_content'],
'type'=>$entry['entry_type'],
'entry_id'=>$entry['entry_id'],
'photo'=>$entry['photo'],
'description'=>$entry['entry_description'],
'author'=> $entry['title'].' '.$entry['firstname'].' '.$entry['lastname'], //$e->getAuthorName($entry['entry_author_id']),
'author_id'=>$entry['entry_author_id'],
'publish_time'=>$entry['entry_publish_time'],
'publish_date'=>$e->getPublishDate($entry['entry_publish_date']),
'comments_list'=>$e->getComments($entry['entry_id'])
);
}
ob_start();?><style>.rigabassa {border-bottom: 1px solid #cccccc;}</style><h2>Nome progetto: <i><?php echo $nome_progetto;?></i></h2><h3>Eseguito da <?php echo $professionista?></h3>Clienti: <?php foreach($listaClienti as $cliente) { echo $cliente['title'].' '.$cliente['firstname'].' '.$cliente['lastname'].'<br/>';} ?><div class="rigabassa"> </div><?php
foreach($entries as $entry) {?>
<table id="post">
<thead id="post">
<tr>
<td>
<h3><?php echo $entry['author'] ?> </h3>
</td>
<td>
<p><?php echo $entry['publish_date'] ?>, <?php echo $entry['publish_time'] ?></p>
</td>
</tr>
</thead>
<tbody>
<tr>
<td valign="top"> <?php if(file_exists(DIR_IMAGE.$entry['photo'])) echo '<img src="'.DIR_IMAGE.$entry['photo'].'.jpg" />'; else echo ' '; ?> </td>
<td>
<blockquote><span><?php echo $entry['description'] ?></span></blockquote>
<?php if ($entry['type']!=1) echo $entry['content']."<br/>"; else if(file_exists(DIR_IMAGE.$session->data['idproject'].'/'.$entry['originalContent'])) { echo '<img src="'.DIR_IMAGE.$session->data['idproject'].'/'.$entry['originalContent'].'"/>'; } ?>
<!-- commenti -->
<div class="comment_box"><?php
if($entry['comments_list']!=NULL)
foreach($entry['comments_list'] as $comment) {
?>
<div class="comment_post">
<span class="title_post"><?php echo LANG_COMMENT_OF;?> <a href="profile.php?userid=<?php echo $comment['comment_author_id'] ?>"><?php echo $comment['comment_author'] ?></a></span>
<span class="data_post"><?php echo LANG_ATTIME;?> <?php echo $comment['comment_time'] ?> <?php echo LANG_OFDAY;?> <?php echo $comment['comment_date'] ?></span>
<p><span class="content_post"><?php echo $comment['comment_content'] ?></span></p>
</div>
<?php } ?>
</div>
<!-- fine commenti -->
</td>
</tr>
</tbody>
</table>
<?php
}
$html = ob_get_contents();
ob_end_clean();
/*
* Fine caricamento dati
*/
// output the HTML content
$pdf->writeHTML($html, true, false, true, false, '');
// reset pointer to the last page
$pdf->lastPage();
// ---------------------------------------------------------
//Close and output PDF document
$pdf->Output('architekaProject.pdf', 'I');
//============================================================+
// END OF FILE
//============================================================+