|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace App\Presenters; |
|
4
|
|
|
|
|
5
|
|
|
use App\Models\ExportModel; |
|
6
|
|
|
use App\Models\ProgramModel; |
|
7
|
|
|
use App\Models\BlockModel; |
|
8
|
|
|
use App\Models\MealModel; |
|
9
|
|
|
use App\Factories\ExcelFactory; |
|
10
|
|
|
use App\Factories\PdfFactory; |
|
11
|
|
|
use App\Components\RegistrationGraphControl; |
|
12
|
|
|
use App\Components\MaterialsControl; |
|
13
|
|
|
use App\Components\MealControl; |
|
14
|
|
|
use Nette\Utils\Strings; |
|
15
|
|
|
use Tracy\Debugger; |
|
16
|
|
|
use Mpdf\Mpdf; |
|
17
|
|
|
|
|
18
|
|
|
/** |
|
19
|
|
|
* Export Controller |
|
20
|
|
|
* |
|
21
|
|
|
* This file handles the retrieval and serving of exports |
|
22
|
|
|
*/ |
|
23
|
|
|
class ExportPresenter extends BasePresenter |
|
24
|
|
|
{ |
|
25
|
|
|
|
|
26
|
|
|
const TEMPLATE_DIR = __DIR__ . '/../templates/Export/'; |
|
27
|
|
|
const TEMPLATE_EXT = 'latte'; |
|
28
|
|
|
|
|
29
|
|
|
/** |
|
30
|
|
|
* @var ProgramModel |
|
31
|
|
|
*/ |
|
32
|
|
|
protected $programModel; |
|
33
|
|
|
|
|
34
|
|
|
protected $blockModel; |
|
35
|
|
|
|
|
36
|
|
|
/** |
|
37
|
|
|
* @var Mpdf\Mpdf |
|
38
|
|
|
*/ |
|
39
|
|
|
protected $pdf; |
|
40
|
|
|
|
|
41
|
|
|
/** |
|
42
|
|
|
* @var PHPExcel |
|
43
|
|
|
*/ |
|
44
|
|
|
protected $excel; |
|
45
|
|
|
|
|
46
|
|
|
protected $filename; |
|
47
|
|
|
|
|
48
|
|
|
/** |
|
49
|
|
|
* @var RegistrationGraphControl |
|
50
|
|
|
*/ |
|
51
|
|
|
private $registrationGraphControl; |
|
52
|
|
|
|
|
53
|
|
|
/** |
|
54
|
|
|
* @var MaterialsControl |
|
55
|
|
|
*/ |
|
56
|
|
|
private $materialControl; |
|
57
|
|
|
|
|
58
|
|
|
/** |
|
59
|
|
|
* @var MealControl |
|
60
|
|
|
*/ |
|
61
|
|
|
private $mealControl; |
|
62
|
|
|
|
|
63
|
|
|
/** |
|
64
|
|
|
* @param ExportModel $export |
|
65
|
|
|
* @param ProgramModel $program |
|
66
|
|
|
* @param ExcelFactory $excel |
|
67
|
|
|
* @param PdfFactory $pdf |
|
68
|
|
|
* @param RegistrationGraphControl $control |
|
69
|
|
|
* @param MaterialsControl $materialControl |
|
70
|
|
|
*/ |
|
71
|
|
|
public function __construct( |
|
72
|
|
|
ExportModel $export, |
|
73
|
|
|
ProgramModel $program, |
|
74
|
|
|
BlockModel $block, |
|
75
|
|
|
ExcelFactory $excel, |
|
76
|
|
|
PdfFactory $pdf, |
|
77
|
|
|
RegistrationGraphControl $control, |
|
78
|
|
|
MaterialsControl $materialControl, |
|
79
|
|
|
MealControl $mealControl |
|
80
|
|
|
) { |
|
81
|
|
|
$this->setModel($export); |
|
|
|
|
|
|
82
|
|
|
$this->setProgramModel($program); |
|
83
|
|
|
$this->setBlockModel($block); |
|
84
|
|
|
$this->setExcel($excel->create()); |
|
85
|
|
|
$this->setPdf($pdf->create()); |
|
86
|
|
|
$this->setRegistrationGraphControl($control); |
|
87
|
|
|
$this->setMaterialControl($materialControl); |
|
88
|
|
|
$this->setMealControl($mealControl); |
|
89
|
|
|
} |
|
90
|
|
|
|
|
91
|
|
|
/** |
|
92
|
|
|
* @return void |
|
93
|
|
|
*/ |
|
94
|
|
|
public function startup() |
|
95
|
|
|
{ |
|
96
|
|
|
parent::startup(); |
|
97
|
|
|
|
|
98
|
|
|
$this->getProgramModel()->setMeetingId($this->getMeetingId()); |
|
99
|
|
|
} |
|
100
|
|
|
|
|
101
|
|
|
/** |
|
102
|
|
|
* @return void |
|
103
|
|
|
*/ |
|
104
|
|
|
public function renderDefault() |
|
105
|
|
|
{ |
|
106
|
|
|
$settingsModel = $this->getModel(); |
|
107
|
|
|
$template = $this->getTemplate(); |
|
108
|
|
|
|
|
109
|
|
|
$template->graphHeight = $this->calculateGraphHeight(); |
|
|
|
|
|
|
110
|
|
|
$template->account = $settingsModel->getMoney('account'); |
|
|
|
|
|
|
111
|
|
|
$template->balance = $settingsModel->getMoney('balance'); |
|
|
|
|
|
|
112
|
|
|
$template->suma = $settingsModel->getMoney('suma'); |
|
|
|
|
|
|
113
|
|
|
$template->programs = $this->getProgramModel()->renderExportPrograms(); |
|
|
|
|
|
|
114
|
|
|
$template->meals = MealModel::$dayMeal; |
|
|
|
|
|
|
115
|
|
|
} |
|
116
|
|
|
|
|
117
|
|
|
public function renderEvidence($type, $id = null) |
|
118
|
|
|
{ |
|
119
|
|
|
$this->filename = 'faktura.pdf'; |
|
120
|
|
|
|
|
121
|
|
|
// summary header |
|
122
|
|
|
$hkvsHeader = "Junák - český skaut, Kapitanát vodních skautů, z. s. | "; |
|
123
|
|
|
$hkvsHeader .= "Senovážné náměstí 977/24, Praha 1, 110 00 | "; |
|
124
|
|
|
$hkvsHeader .= "IČ: 65991753, ČÚ: 2300183549/2010"; |
|
125
|
|
|
|
|
126
|
|
|
$evidences = $this->getModel()->evidence($id); |
|
127
|
|
|
|
|
128
|
|
|
if(!$evidences) { |
|
129
|
|
|
Debugger::log('No data for evidence export.', Debugger::ERROR); |
|
130
|
|
|
$this->flashMessage('No data.'); |
|
131
|
|
|
$this->redirect('Export:listing'); |
|
132
|
|
|
} |
|
133
|
|
|
|
|
134
|
|
|
switch($type){ |
|
135
|
|
|
case "summary": |
|
136
|
|
|
$templateName = 'evidence_summary'; |
|
137
|
|
|
// specific mPDF settings |
|
138
|
|
|
$this->getPdf()->defaultfooterfontsize = 16; |
|
139
|
|
|
$this->getPdf()->defaultfooterfontstyle = 'B'; |
|
140
|
|
|
$this->getPdf()->SetHeader($hkvsHeader); |
|
141
|
|
|
break; |
|
142
|
|
|
case "confirm": |
|
143
|
|
|
$templateName = 'evidence_confirm'; |
|
144
|
|
|
break; |
|
145
|
|
|
default: |
|
146
|
|
|
$templateName = 'evidence'; |
|
147
|
|
|
break; |
|
148
|
|
|
} |
|
149
|
|
|
|
|
150
|
|
|
$parameters = [ |
|
151
|
|
|
'result' => $evidences, |
|
152
|
|
|
]; |
|
153
|
|
|
|
|
154
|
|
|
$this->forgeView($templateName, $parameters); |
|
155
|
|
|
$this->publish(); |
|
156
|
|
|
} |
|
157
|
|
|
|
|
158
|
|
|
/** |
|
159
|
|
|
* Print Attendance into PDF file |
|
160
|
|
|
* |
|
161
|
|
|
* @param void |
|
162
|
|
|
* @return file PDF file |
|
163
|
|
|
*/ |
|
164
|
|
View Code Duplication |
public function renderAttendance() |
|
|
|
|
|
|
165
|
|
|
{ |
|
166
|
|
|
// output file name |
|
167
|
|
|
$this->filename = "attendance_list.pdf"; |
|
168
|
|
|
$templateName = 'attendance'; |
|
169
|
|
|
|
|
170
|
|
|
$attendances = $this->getModel()->attendance(); |
|
171
|
|
|
|
|
172
|
|
|
// prepare header |
|
173
|
|
|
$attendanceHeader = $attendances[0]['place'] . ' ' . $attendances[0]['year']; |
|
174
|
|
|
|
|
175
|
|
|
// set header |
|
176
|
|
|
$this->getPdf()->SetHeader($attendanceHeader.'|sraz VS|Prezenční listina'); |
|
177
|
|
|
|
|
178
|
|
|
$parameters = [ |
|
179
|
|
|
'result' => $attendances, |
|
180
|
|
|
]; |
|
181
|
|
|
|
|
182
|
|
|
$this->forgeView($templateName, $parameters); |
|
183
|
|
|
$this->publish(); |
|
184
|
|
|
} |
|
185
|
|
|
|
|
186
|
|
|
/** |
|
187
|
|
|
* Print meal tickets into PDF file |
|
188
|
|
|
* |
|
189
|
|
|
* @param void |
|
190
|
|
|
* @return file PDF file |
|
191
|
|
|
*/ |
|
192
|
|
View Code Duplication |
public function renderMealTicket() |
|
|
|
|
|
|
193
|
|
|
{ |
|
194
|
|
|
// output file name |
|
195
|
|
|
$this->filename= 'vlastni_stravenky.pdf'; |
|
196
|
|
|
$templateName = 'meal_ticket'; |
|
197
|
|
|
|
|
198
|
|
|
$mealTickets = $this->getModel()->mealTicket(); |
|
199
|
|
|
|
|
200
|
|
|
$parameters = [ |
|
201
|
|
|
'result' => $mealTickets, |
|
202
|
|
|
]; |
|
203
|
|
|
|
|
204
|
|
|
$this->forgeView($templateName, $parameters); |
|
205
|
|
|
$this->publish(); |
|
206
|
|
|
} |
|
207
|
|
|
|
|
208
|
|
|
/** |
|
209
|
|
|
* Print name list into PDF file |
|
210
|
|
|
* |
|
211
|
|
|
* @param void |
|
212
|
|
|
* @return file PDF file |
|
213
|
|
|
*/ |
|
214
|
|
View Code Duplication |
public function renderNameList() |
|
|
|
|
|
|
215
|
|
|
{ |
|
216
|
|
|
// output file name |
|
217
|
|
|
$this->filename = 'name_list.pdf'; |
|
218
|
|
|
$templateName = 'name_list'; |
|
219
|
|
|
|
|
220
|
|
|
$nameList = $this->getModel()->nameList(); |
|
221
|
|
|
|
|
222
|
|
|
// prepare header |
|
223
|
|
|
$namelistHeader = $nameList[0]['place'] . " " . $nameList[0]['year']; |
|
224
|
|
|
|
|
225
|
|
|
// set header |
|
226
|
|
|
$this->getPdf()->SetHeader($namelistHeader.'|sraz VS|Jméno, Příjmení, Přezdívka'); |
|
227
|
|
|
|
|
228
|
|
|
$parameters = [ |
|
229
|
|
|
'result' => $nameList, |
|
230
|
|
|
]; |
|
231
|
|
|
|
|
232
|
|
|
$this->forgeView($templateName, $parameters); |
|
233
|
|
|
$this->publish(); |
|
234
|
|
|
} |
|
235
|
|
|
|
|
236
|
|
|
/** |
|
237
|
|
|
* @param string $type |
|
238
|
|
|
* @param integer $id |
|
239
|
|
|
* @return void |
|
240
|
|
|
*/ |
|
241
|
|
|
public function renderProgram($type, $id) |
|
242
|
|
|
{ |
|
243
|
|
|
$programMethod = 'renderProgram' . Strings::firstUpper($type); |
|
244
|
|
|
|
|
245
|
|
|
call_user_func([$this, $programMethod], $id); |
|
246
|
|
|
} |
|
247
|
|
|
|
|
248
|
|
|
/** |
|
249
|
|
|
* Print program cards into PDF file |
|
250
|
|
|
* |
|
251
|
|
|
* @param void |
|
252
|
|
|
* @return file PDF file |
|
253
|
|
|
*/ |
|
254
|
|
|
protected function renderProgramCards() |
|
255
|
|
|
{ |
|
256
|
|
|
$this->filename = 'vlastni_programy.pdf'; |
|
257
|
|
|
$templateName = 'program_cards'; |
|
258
|
|
|
|
|
259
|
|
|
$this->getPdf()->SetWatermarkImage(IMG_DIR . 'logos/watermark.jpg', 0.1, ''); |
|
260
|
|
|
$this->getPdf()->showWatermarkImage = true; |
|
261
|
|
|
|
|
262
|
|
|
$parameters = [ |
|
263
|
|
|
'result' => $this->getModel()->programCards(), |
|
264
|
|
|
]; |
|
265
|
|
|
|
|
266
|
|
|
$this->forgeView($templateName, $parameters); |
|
267
|
|
|
$this->publish(); |
|
268
|
|
|
} |
|
269
|
|
|
|
|
270
|
|
|
/** |
|
271
|
|
|
* Print large program into PDF file |
|
272
|
|
|
* |
|
273
|
|
|
* @param voide |
|
274
|
|
|
* @return file PDF file |
|
275
|
|
|
*/ |
|
276
|
|
View Code Duplication |
protected function renderProgramLarge() |
|
|
|
|
|
|
277
|
|
|
{ |
|
278
|
|
|
$largeProgram = $this->getModel()->largeProgram(); |
|
279
|
|
|
|
|
280
|
|
|
$this->filename = Strings::toAscii($largeProgram['place'] . $largeProgram['year'] . '-program') . '.pdf'; |
|
281
|
|
|
$templateName = 'program_large'; |
|
282
|
|
|
|
|
283
|
|
|
$meetingHeader = $largeProgram['place']." ".$largeProgram['year']; |
|
284
|
|
|
|
|
285
|
|
|
$this->getPdf()->paperFormat = 'B1'; |
|
286
|
|
|
|
|
287
|
|
|
$parameters = [ |
|
288
|
|
|
'header' => $meetingHeader, |
|
289
|
|
|
'export' => $this->getModel(), |
|
290
|
|
|
'program' => $this->getProgramModel(), |
|
291
|
|
|
]; |
|
292
|
|
|
|
|
293
|
|
|
$this->forgeView($templateName, $parameters); |
|
294
|
|
|
$this->publish(); |
|
295
|
|
|
|
|
296
|
|
|
} |
|
297
|
|
|
|
|
298
|
|
|
/** |
|
299
|
|
|
* Print public program into PDF file |
|
300
|
|
|
* |
|
301
|
|
|
* @param void |
|
302
|
|
|
* @return file PDF file |
|
303
|
|
|
*/ |
|
304
|
|
View Code Duplication |
protected function renderProgramPublic() |
|
|
|
|
|
|
305
|
|
|
{ |
|
306
|
|
|
$templateName = 'program_public'; |
|
307
|
|
|
$publicProgram = $this->getModel()->publicProgram(); |
|
308
|
|
|
$this->filename = Strings::toAscii($publicProgram['place'] . $publicProgram['year'] . '-program' . '.pdf'); |
|
309
|
|
|
|
|
310
|
|
|
$meetingHeader = $publicProgram['place'] . ' ' . $publicProgram['year']; |
|
311
|
|
|
|
|
312
|
|
|
$parameters = [ |
|
313
|
|
|
'header' => $meetingHeader, |
|
314
|
|
|
'export' => $this->getModel(), |
|
315
|
|
|
'program' => $this->getProgramModel(), |
|
316
|
|
|
]; |
|
317
|
|
|
|
|
318
|
|
|
$this->forgeView($templateName, $parameters); |
|
319
|
|
|
$this->publish(); |
|
320
|
|
|
} |
|
321
|
|
|
|
|
322
|
|
|
/** |
|
323
|
|
|
* Print program badges into PDF file |
|
324
|
|
|
* |
|
325
|
|
|
* @param void |
|
326
|
|
|
* @return file PDF file |
|
327
|
|
|
*/ |
|
328
|
|
|
protected function renderProgramBadges() |
|
329
|
|
|
{ |
|
330
|
|
|
$this->filename = 'program-badge.pdf'; |
|
331
|
|
|
$templateName = 'program_badge'; |
|
332
|
|
|
|
|
333
|
|
|
$programBadges = $this->getModel()->programBadges(); |
|
334
|
|
|
|
|
335
|
|
|
$this->getPdf()->setMargins(5, 5, 9, 5); |
|
336
|
|
|
|
|
337
|
|
|
$days = [ |
|
338
|
|
|
'PÁTEK', |
|
339
|
|
|
'SOBOTA', |
|
340
|
|
|
'NEDĚLE', |
|
341
|
|
|
]; |
|
342
|
|
|
|
|
343
|
|
|
$exportBlocks = []; |
|
344
|
|
|
foreach ($days as $day) { |
|
345
|
|
|
$exportBlocks[$day] = $this->getBlockModel()->getExportBlocks($this->meetingId, $day); |
|
346
|
|
|
} |
|
347
|
|
|
|
|
348
|
|
|
$parameters = [ |
|
349
|
|
|
'meeting_id' => $this->meetingId, |
|
350
|
|
|
'result' => $programBadges, |
|
351
|
|
|
'days' => $days, |
|
352
|
|
|
'exportBlocks' => $exportBlocks, |
|
353
|
|
|
]; |
|
354
|
|
|
|
|
355
|
|
|
$this->forgeView($templateName, $parameters); |
|
356
|
|
|
$this->publish(); |
|
357
|
|
|
} |
|
358
|
|
|
|
|
359
|
|
|
/** |
|
360
|
|
|
* Print visitors on program into PDF file |
|
361
|
|
|
* |
|
362
|
|
|
* @param int program id |
|
363
|
|
|
* @return file PDF file |
|
364
|
|
|
*/ |
|
365
|
|
|
protected function renderProgramVisitors($id) |
|
366
|
|
|
{ |
|
367
|
|
|
$this->filename = 'ucastnici-programu.pdf'; |
|
368
|
|
|
$templateName = 'program_visitors'; |
|
369
|
|
|
|
|
370
|
|
|
$programs = $this->getModel()->programVisitors($id); |
|
371
|
|
|
|
|
372
|
|
|
$programHeader = $programs[0]['program']; |
|
373
|
|
|
|
|
374
|
|
|
$this->getPdf()->SetHeader($programHeader.'|sraz VS|Účastnící programu'); |
|
375
|
|
|
|
|
376
|
|
|
$parameters = [ |
|
377
|
|
|
'result' => $programs, |
|
378
|
|
|
]; |
|
379
|
|
|
|
|
380
|
|
|
$this->forgeView($templateName, $parameters); |
|
381
|
|
|
$this->publish(); |
|
382
|
|
|
} |
|
383
|
|
|
|
|
384
|
|
|
/** |
|
385
|
|
|
* Print details of program into PDF file |
|
386
|
|
|
* |
|
387
|
|
|
* @param void |
|
388
|
|
|
* @return file PDF file |
|
389
|
|
|
*/ |
|
390
|
|
View Code Duplication |
protected function renderProgramDetails() |
|
|
|
|
|
|
391
|
|
|
{ |
|
392
|
|
|
$this->filename = 'vypis-programu.pdf'; |
|
393
|
|
|
$templateName = 'program_details'; |
|
394
|
|
|
|
|
395
|
|
|
$programDetails = $this->getModel()->programDetails(); |
|
396
|
|
|
|
|
397
|
|
|
$this->getPdf()->SetHeader('Výpis programů|sraz VS'); |
|
398
|
|
|
|
|
399
|
|
|
$parameters = [ |
|
400
|
|
|
'result' => $programDetails, |
|
401
|
|
|
]; |
|
402
|
|
|
|
|
403
|
|
|
$this->forgeView($templateName, $parameters); |
|
404
|
|
|
$this->publish(); |
|
405
|
|
|
} |
|
406
|
|
|
|
|
407
|
|
|
/** |
|
408
|
|
|
* @return void |
|
409
|
|
|
*/ |
|
410
|
|
|
public function actionNameBadges() |
|
411
|
|
|
{ |
|
412
|
|
|
$names = $this->getHttpRequest()->getPost()['names']; |
|
413
|
|
|
$this->renderNameBadges($names); |
|
414
|
|
|
} |
|
415
|
|
|
|
|
416
|
|
|
/** |
|
417
|
|
|
* Print name badges into PDF file |
|
418
|
|
|
* |
|
419
|
|
|
* @param string comma separated values |
|
420
|
|
|
* @return file PDF file |
|
421
|
|
|
*/ |
|
422
|
|
|
public function renderNameBadges($namesStringified) |
|
423
|
|
|
{ |
|
424
|
|
|
$this->filename = 'jmenovky.pdf'; |
|
425
|
|
|
$templateName = 'name_badge'; |
|
426
|
|
|
|
|
427
|
|
|
$badges = []; |
|
428
|
|
|
if(!$namesStringified) { |
|
429
|
|
|
$badges = $this->getModel()->nameBadges(); |
|
430
|
|
|
} else { |
|
431
|
|
|
$namesStringified = preg_replace('/\s+/','',$namesStringified); |
|
432
|
|
|
|
|
433
|
|
|
$names = explode(',',$namesStringified); |
|
434
|
|
|
foreach($names as $name) { |
|
435
|
|
|
$badge['nick'] = $name; |
|
|
|
|
|
|
436
|
|
|
$badges[] = $badge; |
|
437
|
|
|
} |
|
438
|
|
|
} |
|
439
|
|
|
|
|
440
|
|
|
$this->getPdf()->setMargins(15, 15, 10, 5); |
|
441
|
|
|
$this->getPdf()->SetWatermarkImage(IMG_DIR . 'logos/watermark-waves.jpg', 0.1, ''); |
|
442
|
|
|
$this->getPdf()->showWatermarkImage = TRUE; |
|
443
|
|
|
|
|
444
|
|
|
$parameters = [ |
|
445
|
|
|
'result' => $badges, |
|
446
|
|
|
]; |
|
447
|
|
|
|
|
448
|
|
|
$this->forgeView($templateName, $parameters); |
|
449
|
|
|
$this->publish(); |
|
450
|
|
|
} |
|
451
|
|
|
|
|
452
|
|
|
/** |
|
453
|
|
|
* Print data of visitors into excel file |
|
454
|
|
|
* |
|
455
|
|
|
* @return file *.xlsx file type |
|
456
|
|
|
*/ |
|
457
|
|
|
public function renderVisitorsExcel() |
|
458
|
|
|
{ |
|
459
|
|
|
$excel = $this->getExcel(); |
|
460
|
|
|
|
|
461
|
|
|
$excel->getProperties()->setCreator("HKVS Srazy K + K")->setTitle("Návštěvníci"); |
|
462
|
|
|
|
|
463
|
|
|
// Zde si vyvoláme aktivní list (nastavený nahoře) a vyplníme buňky A1 a A2 |
|
464
|
|
|
$list = $excel->setActiveSheetIndex(0); |
|
465
|
|
|
|
|
466
|
|
|
$cells = [ |
|
467
|
|
|
'A1' => 'ID', |
|
468
|
|
|
'B1' => 'symbol', |
|
469
|
|
|
'C1' => 'Jméno', |
|
470
|
|
|
'D1' => 'Příjmení', |
|
471
|
|
|
'E1' => 'Přezdívka', |
|
472
|
|
|
'F1' => 'Narození', |
|
473
|
|
|
'G1' => 'E-mail', |
|
474
|
|
|
'H1' => 'Adresa', |
|
475
|
|
|
'I1' => 'Město', |
|
476
|
|
|
'J1' => 'PSČ', |
|
477
|
|
|
'K1' => 'Kraj', |
|
478
|
|
|
'L1' => 'Evidence', |
|
479
|
|
|
'M1' => 'Středisko/Přístav', |
|
480
|
|
|
'N1' => 'Oddíl', |
|
481
|
|
|
'O1' => 'Účet', |
|
482
|
|
|
'P1' => 'Připomínky', |
|
483
|
|
|
'Q1' => 'Příjezd', |
|
484
|
|
|
'R1' => 'Odjezd', |
|
485
|
|
|
'S1' => 'Otázka', |
|
486
|
|
|
]; |
|
487
|
|
|
|
|
488
|
|
|
foreach($cells as $key => $value) { |
|
489
|
|
|
$list->setCellValue($key, $value); |
|
490
|
|
|
} |
|
491
|
|
|
|
|
492
|
|
|
$excel->getActiveSheet()->getStyle('A1:Z1')->getFont()->setBold(true); |
|
493
|
|
|
|
|
494
|
|
|
$dimensions = [ |
|
495
|
|
|
'C' => 15, |
|
496
|
|
|
'D' => 15, |
|
497
|
|
|
'F' => 15, |
|
498
|
|
|
'G' => 30, |
|
499
|
|
|
'H' => 20, |
|
500
|
|
|
'I' => 15, |
|
501
|
|
|
'K' => 20, |
|
502
|
|
|
'M' => 30, |
|
503
|
|
|
'N' => 20, |
|
504
|
|
|
'P' => 20, |
|
505
|
|
|
'Q' => 20, |
|
506
|
|
|
'R' => 20, |
|
507
|
|
|
'S' => 20, |
|
508
|
|
|
]; |
|
509
|
|
|
|
|
510
|
|
|
foreach($dimensions as $key => $value) { |
|
511
|
|
|
$excel->getActiveSheet()->getColumnDimension($key)->setWidth($value); |
|
512
|
|
|
} |
|
513
|
|
|
|
|
514
|
|
|
$visitors = $this->getModel()->visitorsExcel(); |
|
515
|
|
|
|
|
516
|
|
|
$cellValues = [ |
|
517
|
|
|
'A' => 'id', |
|
518
|
|
|
'B' => 'code', |
|
519
|
|
|
'C' => 'name', |
|
520
|
|
|
'D' => 'surname', |
|
521
|
|
|
'E' => 'nick', |
|
522
|
|
|
'F' => 'birthday', |
|
523
|
|
|
'G' => 'email', |
|
524
|
|
|
'H' => 'street', |
|
525
|
|
|
'I' => 'city', |
|
526
|
|
|
'J' => 'postal_code', |
|
527
|
|
|
'K' => 'province', |
|
528
|
|
|
'L' => 'group_num', |
|
529
|
|
|
'M' => 'group_name', |
|
530
|
|
|
'N' => 'troop_name', |
|
531
|
|
|
'O' => 'bill', |
|
532
|
|
|
'P' => 'comment', |
|
533
|
|
|
'Q' => 'arrival', |
|
534
|
|
|
'R' => 'departure', |
|
535
|
|
|
'S' => 'question', |
|
536
|
|
|
'S' => 'question2', |
|
537
|
|
|
'T' => 'all', |
|
538
|
|
|
'U' => 'fry_dinner', |
|
539
|
|
|
'V' => 'sat_breakfast', |
|
540
|
|
|
'W' => 'sat_lunch', |
|
541
|
|
|
'X' => 'sat_dinner', |
|
542
|
|
|
'Y' => 'sun_breakfast', |
|
543
|
|
|
'Z' => 'sun_lunch', |
|
544
|
|
|
]; |
|
545
|
|
|
|
|
546
|
|
|
$i = 2; |
|
547
|
|
|
foreach($visitors as $data) { |
|
548
|
|
|
foreach($cellValues as $cell => $value) { |
|
549
|
|
|
$list->setCellValue($cell . $i, $data[$value]); |
|
550
|
|
|
} |
|
551
|
|
|
$i++; |
|
552
|
|
|
} |
|
553
|
|
|
|
|
554
|
|
|
// stahnuti souboru |
|
555
|
|
|
$filename = 'export-MS-'.date('Y-m-d',time()).'.xlsx'; |
|
556
|
|
|
|
|
557
|
|
|
$excel->setActiveSheetIndex(0); |
|
558
|
|
|
|
|
559
|
|
|
header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'); |
|
560
|
|
|
header('Content-Disposition: attachment;filename="'.$filename.'"'); |
|
561
|
|
|
header('Cache-Control: max-age=0'); |
|
562
|
|
|
|
|
563
|
|
|
// If you're serving to IE over SSL, then the following may be needed |
|
564
|
|
|
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); // Date in the past |
|
565
|
|
|
header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT'); // always modified |
|
566
|
|
|
header('Cache-Control: cache, must-revalidate'); // HTTP/1.1 |
|
567
|
|
|
header('Pragma: public'); // HTTP/1.0 |
|
568
|
|
|
|
|
569
|
|
|
$ExcelWriter = \PHPExcel_IOFactory::createWriter($excel, 'Excel2007'); |
|
570
|
|
|
$ExcelWriter->save('php://output'); |
|
571
|
|
|
exit; |
|
572
|
|
|
} |
|
573
|
|
|
|
|
574
|
|
|
/** |
|
575
|
|
|
* @param string $name |
|
576
|
|
|
* @param array $parameters |
|
577
|
|
|
* @return self |
|
578
|
|
|
*/ |
|
579
|
|
|
protected function forgeView($name = '', array $parameters = []) |
|
580
|
|
|
{ |
|
581
|
|
|
$template = $this->getTemplate(); |
|
582
|
|
|
|
|
583
|
|
|
foreach ($parameters as $parameter => $value) { |
|
584
|
|
|
$template->{$parameter} = $value; |
|
585
|
|
|
} |
|
586
|
|
|
|
|
587
|
|
|
$this->setView($name); |
|
588
|
|
|
$template->setFile( |
|
589
|
|
|
sprintf( |
|
590
|
|
|
'%s%s.%s', |
|
591
|
|
|
self::TEMPLATE_DIR, |
|
592
|
|
|
$name, |
|
593
|
|
|
self::TEMPLATE_EXT |
|
594
|
|
|
) |
|
595
|
|
|
); |
|
596
|
|
|
|
|
597
|
|
|
return $this; |
|
598
|
|
|
} |
|
599
|
|
|
|
|
600
|
|
|
protected function publish() |
|
601
|
|
|
{ |
|
602
|
|
|
$template = $this->getTemplate(); |
|
603
|
|
|
|
|
604
|
|
|
/* debugging */ |
|
605
|
|
|
if($this->debugMode){ |
|
606
|
|
|
echo $template; |
|
607
|
|
|
exit('DEBUG_MODE'); |
|
608
|
|
|
} else { |
|
609
|
|
|
// write html |
|
610
|
|
|
$this->getPdf()->WriteHTML((string) $template, 0); |
|
611
|
|
|
// download |
|
612
|
|
|
$this->getPdf()->Output($this->filename, "D"); |
|
613
|
|
|
exit; |
|
614
|
|
|
} |
|
615
|
|
|
} |
|
616
|
|
|
|
|
617
|
|
|
/** |
|
618
|
|
|
* @return RegistrationGraphControl |
|
619
|
|
|
*/ |
|
620
|
|
|
protected function createComponentRegistrationGraph() |
|
621
|
|
|
{ |
|
622
|
|
|
return $this->registrationGraphControl->setMeetingId($this->getMeetingId()); |
|
623
|
|
|
} |
|
624
|
|
|
|
|
625
|
|
|
/** |
|
626
|
|
|
* @param RegistrationGraphControl $control |
|
627
|
|
|
* @return $this |
|
628
|
|
|
*/ |
|
629
|
|
|
protected function setRegistrationGraphControl(RegistrationGraphControl $control) |
|
630
|
|
|
{ |
|
631
|
|
|
$this->registrationGraphControl = $control; |
|
632
|
|
|
|
|
633
|
|
|
return $this; |
|
634
|
|
|
} |
|
635
|
|
|
|
|
636
|
|
|
/** |
|
637
|
|
|
* @return MaterialControl |
|
638
|
|
|
*/ |
|
639
|
|
|
protected function createComponentMaterials() |
|
640
|
|
|
{ |
|
641
|
|
|
return $this->materialControl->setMeetingId($this->getMeetingId()); |
|
642
|
|
|
} |
|
643
|
|
|
|
|
644
|
|
|
/** |
|
645
|
|
|
* @param MaterialControl $control |
|
646
|
|
|
* @return $this |
|
647
|
|
|
*/ |
|
648
|
|
|
protected function setMaterialControl(MaterialsControl $control) |
|
649
|
|
|
{ |
|
650
|
|
|
$this->materialControl = $control; |
|
651
|
|
|
|
|
652
|
|
|
return $this; |
|
653
|
|
|
} |
|
654
|
|
|
|
|
655
|
|
|
/** |
|
656
|
|
|
* @return MealControl |
|
657
|
|
|
*/ |
|
658
|
|
|
protected function createComponentMeal() |
|
659
|
|
|
{ |
|
660
|
|
|
return $this->mealControl->setMeetingId($this->getMeetingId()); |
|
661
|
|
|
} |
|
662
|
|
|
|
|
663
|
|
|
/** |
|
664
|
|
|
* @param MealControl $control |
|
665
|
|
|
* @return $this |
|
666
|
|
|
*/ |
|
667
|
|
|
protected function setMealControl(MealControl $control) |
|
668
|
|
|
{ |
|
669
|
|
|
$this->mealControl = $control; |
|
670
|
|
|
|
|
671
|
|
|
return $this; |
|
672
|
|
|
} |
|
673
|
|
|
|
|
674
|
|
|
/** |
|
675
|
|
|
* @return integer |
|
676
|
|
|
*/ |
|
677
|
|
|
protected function calculateGraphHeight() |
|
678
|
|
|
{ |
|
679
|
|
|
$graphHeight = RegistrationGraphControl::GRAPH_HEIGHT_INIT; |
|
680
|
|
|
|
|
681
|
|
|
foreach($this->getModel()->graph() as $graph) { |
|
682
|
|
|
$graphHeight += RegistrationGraphControl::GRAPH_HEIGHT_STEP; |
|
683
|
|
|
} |
|
684
|
|
|
|
|
685
|
|
|
if($graphHeight < RegistrationGraphControl::GRAPH_HEIGHT_MIN) { |
|
686
|
|
|
$graphHeight = RegistrationGraphControl::GRAPH_HEIGHT_MIN; |
|
687
|
|
|
} |
|
688
|
|
|
|
|
689
|
|
|
return $graphHeight; |
|
690
|
|
|
} |
|
691
|
|
|
|
|
692
|
|
|
/** |
|
693
|
|
|
* @return ProgramModel |
|
694
|
|
|
*/ |
|
695
|
|
|
protected function getProgramModel() |
|
696
|
|
|
{ |
|
697
|
|
|
return $this->programModel; |
|
698
|
|
|
} |
|
699
|
|
|
|
|
700
|
|
|
/** |
|
701
|
|
|
* @param BlockModel $model |
|
702
|
|
|
* @return $this |
|
703
|
|
|
*/ |
|
704
|
|
|
protected function setBlockModel(BlockModel $model) |
|
705
|
|
|
{ |
|
706
|
|
|
$this->blockModel = $model; |
|
707
|
|
|
return $this; |
|
708
|
|
|
} |
|
709
|
|
|
|
|
710
|
|
|
/** |
|
711
|
|
|
* @return BlockModel |
|
712
|
|
|
*/ |
|
713
|
|
|
protected function getBlockModel() |
|
714
|
|
|
{ |
|
715
|
|
|
return $this->blockModel; |
|
716
|
|
|
} |
|
717
|
|
|
|
|
718
|
|
|
/** |
|
719
|
|
|
* @param ProgramModel $model |
|
720
|
|
|
* @return $this |
|
721
|
|
|
*/ |
|
722
|
|
|
protected function setProgramModel(ProgramModel $model) |
|
723
|
|
|
{ |
|
724
|
|
|
$this->programModel = $model; |
|
725
|
|
|
return $this; |
|
726
|
|
|
} |
|
727
|
|
|
|
|
728
|
|
|
|
|
729
|
|
|
/** |
|
730
|
|
|
* @return PHPExcel |
|
731
|
|
|
*/ |
|
732
|
|
|
protected function getExcel() |
|
733
|
|
|
{ |
|
734
|
|
|
return $this->excel; |
|
735
|
|
|
} |
|
736
|
|
|
|
|
737
|
|
|
/** |
|
738
|
|
|
* @param PHPExcel $excel |
|
739
|
|
|
* @return $this |
|
740
|
|
|
*/ |
|
741
|
|
|
protected function setExcel(\PHPExcel $excel) |
|
742
|
|
|
{ |
|
743
|
|
|
$this->excel = $excel; |
|
|
|
|
|
|
744
|
|
|
return $this; |
|
745
|
|
|
} |
|
746
|
|
|
|
|
747
|
|
|
/** |
|
748
|
|
|
* @return mPDF |
|
749
|
|
|
*/ |
|
750
|
|
|
protected function getPdf() |
|
751
|
|
|
{ |
|
752
|
|
|
return $this->pdf; |
|
753
|
|
|
} |
|
754
|
|
|
|
|
755
|
|
|
/** |
|
756
|
|
|
* @param Mpdf $pdf |
|
757
|
|
|
* @return self |
|
758
|
|
|
*/ |
|
759
|
|
|
protected function setPdf(Mpdf $pdf) |
|
760
|
|
|
{ |
|
761
|
|
|
$this->pdf = $pdf; |
|
|
|
|
|
|
762
|
|
|
return $this; |
|
763
|
|
|
} |
|
764
|
|
|
|
|
765
|
|
|
} |
|
766
|
|
|
|
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: