export trainings
This commit is contained in:
38
_include/include_export_trainings.php
Normal file
38
_include/include_export_trainings.php
Normal file
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
$trainingAssocArray = $sql->assoc_array("
|
||||
SELECT
|
||||
tr_id 'Azonosító',
|
||||
substring(tr_date,1,16) 'Időpont',
|
||||
trt_name 'Típus',
|
||||
GROUP_CONCAT(DISTINCT ua_name) 'Edzők',
|
||||
COUNT(pr_id) 'Létszám'
|
||||
FROM
|
||||
training
|
||||
JOIN
|
||||
training_type ON trt_id = tr_training_type_trt_id
|
||||
JOIN
|
||||
training_coach ON trc_training_tr_id = tr_id
|
||||
JOIN
|
||||
user_coach ON ua_id = trc_coach_uc_id
|
||||
JOIN
|
||||
presence ON pr_training_tr_id = tr_id
|
||||
WHERE
|
||||
tr_deleted = 0
|
||||
GROUP BY tr_id
|
||||
ORDER BY tr_date ASC;
|
||||
");
|
||||
|
||||
$filename = "edzeslista.csv";
|
||||
$fp = fopen('php://output', 'w');
|
||||
|
||||
ob_end_clean();
|
||||
fputcsv($fp, array_keys(reset($trainingAssocArray)), ';');
|
||||
|
||||
header('Content-type: application/csv');
|
||||
header('Content-Disposition: attachment; filename='.$filename);
|
||||
|
||||
foreach($trainingAssocArray as $row) {
|
||||
fputcsv($fp, $row, ';');
|
||||
}
|
||||
exit(1);
|
||||
Reference in New Issue
Block a user