csv export by type

parent d2c4451c
......@@ -4,8 +4,8 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
"This file is @generated automatically"
],
"hash": "57854ff2516737b353c5103c6c9748d4",
"content-hash": "f2bbb452cc9452c72a69af9712855e2d",
"hash": "812cfc6593bb27fbed207f05a05b7d4e",
"content-hash": "fbae2eefa1a02627fffa864a1fc9614a",
"packages": [
{
"name": "container-interop/container-interop",
......@@ -77,16 +77,16 @@
},
{
"name": "guzzlehttp/guzzle",
"version": "6.1.1",
"version": "6.2.0",
"source": {
"type": "git",
"url": "https://github.com/guzzle/guzzle.git",
"reference": "c6851d6e48f63b69357cbfa55bca116448140e0c"
"reference": "d094e337976dff9d8e2424e8485872194e768662"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/guzzle/guzzle/zipball/c6851d6e48f63b69357cbfa55bca116448140e0c",
"reference": "c6851d6e48f63b69357cbfa55bca116448140e0c",
"url": "https://api.github.com/repos/guzzle/guzzle/zipball/d094e337976dff9d8e2424e8485872194e768662",
"reference": "d094e337976dff9d8e2424e8485872194e768662",
"shasum": ""
},
"require": {
......@@ -102,7 +102,7 @@
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "6.1-dev"
"dev-master": "6.2-dev"
}
},
"autoload": {
......@@ -135,7 +135,7 @@
"rest",
"web service"
],
"time": "2015-11-23 00:47:50"
"time": "2016-03-21 20:02:09"
},
{
"name": "guzzlehttp/promises",
......@@ -494,18 +494,75 @@
],
"time": "2016-01-20 09:08:28"
},
{
"name": "league/csv",
"version": "8.0.0",
"source": {
"type": "git",
"url": "https://github.com/thephpleague/csv.git",
"reference": "0a1b535df48507f58ed3c7ab44e72272b11163ac"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/thephpleague/csv/zipball/0a1b535df48507f58ed3c7ab44e72272b11163ac",
"reference": "0a1b535df48507f58ed3c7ab44e72272b11163ac",
"shasum": ""
},
"require": {
"ext-mbstring": "*",
"php": ">=5.5.0"
},
"require-dev": {
"fabpot/php-cs-fixer": "^1.9",
"phpunit/phpunit": "^4.0"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "8.0-dev"
}
},
"autoload": {
"psr-4": {
"League\\Csv\\": "src"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Ignace Nyamagana Butera",
"email": "nyamsprod@gmail.com",
"homepage": "https://github.com/nyamsprod/",
"role": "Developer"
}
],
"description": "Csv data manipulation made easy in PHP",
"homepage": "http://csv.thephpleague.com",
"keywords": [
"csv",
"export",
"filter",
"import",
"read",
"write"
],
"time": "2015-12-11 09:28:14"
},
{
"name": "monolog/monolog",
"version": "1.18.1",
"version": "1.18.2",
"source": {
"type": "git",
"url": "https://github.com/Seldaek/monolog.git",
"reference": "a5f2734e8c16f3aa21b3da09715d10e15b4d2d45"
"reference": "064b38c16790249488e7a8b987acf1c9d7383c09"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/Seldaek/monolog/zipball/a5f2734e8c16f3aa21b3da09715d10e15b4d2d45",
"reference": "a5f2734e8c16f3aa21b3da09715d10e15b4d2d45",
"url": "https://api.github.com/repos/Seldaek/monolog/zipball/064b38c16790249488e7a8b987acf1c9d7383c09",
"reference": "064b38c16790249488e7a8b987acf1c9d7383c09",
"shasum": ""
},
"require": {
......@@ -520,13 +577,13 @@
"doctrine/couchdb": "~1.0@dev",
"graylog2/gelf-php": "~1.0",
"jakub-onderka/php-parallel-lint": "0.9",
"php-amqplib/php-amqplib": "~2.4",
"php-console/php-console": "^3.1.3",
"phpunit/phpunit": "~4.5",
"phpunit/phpunit-mock-objects": "2.3.0",
"raven/raven": "^0.13",
"ruflin/elastica": ">=0.90 <3.0",
"swiftmailer/swiftmailer": "~5.3",
"videlalvaro/php-amqplib": "~2.4"
"swiftmailer/swiftmailer": "~5.3"
},
"suggest": {
"aws/aws-sdk-php": "Allow sending log messages to AWS services like DynamoDB",
......@@ -535,11 +592,11 @@
"ext-mongo": "Allow sending log messages to a MongoDB server",
"graylog2/gelf-php": "Allow sending log messages to a GrayLog2 server",
"mongodb/mongodb": "Allow sending log messages to a MongoDB server via PHP Driver",
"php-amqplib/php-amqplib": "Allow sending log messages to an AMQP server using php-amqplib",
"php-console/php-console": "Allow sending log messages to Google Chrome",
"raven/raven": "Allow sending log messages to a Sentry server",
"rollbar/rollbar": "Allow sending log messages to Rollbar",
"ruflin/elastica": "Allow sending log messages to an Elastic Search server",
"videlalvaro/php-amqplib": "Allow sending log messages to an AMQP server using php-amqplib"
"ruflin/elastica": "Allow sending log messages to an Elastic Search server"
},
"type": "library",
"extra": {
......@@ -570,7 +627,7 @@
"logging",
"psr-3"
],
"time": "2016-03-13 16:08:35"
"time": "2016-04-02 13:12:58"
},
{
"name": "nikic/fast-route",
......@@ -617,16 +674,16 @@
},
{
"name": "paragonie/random_compat",
"version": "v1.2.2",
"version": "v1.4.1",
"source": {
"type": "git",
"url": "https://github.com/paragonie/random_compat.git",
"reference": "b3313b618f4edd76523572531d5d7e22fe747430"
"reference": "c7e26a21ba357863de030f0b9e701c7d04593774"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/paragonie/random_compat/zipball/b3313b618f4edd76523572531d5d7e22fe747430",
"reference": "b3313b618f4edd76523572531d5d7e22fe747430",
"url": "https://api.github.com/repos/paragonie/random_compat/zipball/c7e26a21ba357863de030f0b9e701c7d04593774",
"reference": "c7e26a21ba357863de030f0b9e701c7d04593774",
"shasum": ""
},
"require": {
......@@ -661,7 +718,7 @@
"pseudorandom",
"random"
],
"time": "2016-03-11 19:54:08"
"time": "2016-03-18 20:34:03"
},
{
"name": "pimple/pimple",
......@@ -2885,16 +2942,16 @@
},
{
"name": "symfony/config",
"version": "v3.0.3",
"version": "v3.0.4",
"source": {
"type": "git",
"url": "https://github.com/symfony/config.git",
"reference": "79a97025f7bf4bbf8352b5df1905aa136a531066"
"reference": "980ee40c28f00acff8906c11b778aab5f0db74c2"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/config/zipball/79a97025f7bf4bbf8352b5df1905aa136a531066",
"reference": "79a97025f7bf4bbf8352b5df1905aa136a531066",
"url": "https://api.github.com/repos/symfony/config/zipball/980ee40c28f00acff8906c11b778aab5f0db74c2",
"reference": "980ee40c28f00acff8906c11b778aab5f0db74c2",
"shasum": ""
},
"require": {
......@@ -2934,20 +2991,20 @@
],
"description": "Symfony Config Component",
"homepage": "https://symfony.com",
"time": "2016-02-23 15:16:06"
"time": "2016-03-04 07:55:57"
},
{
"name": "symfony/console",
"version": "v2.8.3",
"version": "v2.8.4",
"source": {
"type": "git",
"url": "https://github.com/symfony/console.git",
"reference": "56cc5caf051189720b8de974e4746090aaa10d44"
"reference": "9a5aef5fc0d4eff86853d44202b02be8d5a20154"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/console/zipball/56cc5caf051189720b8de974e4746090aaa10d44",
"reference": "56cc5caf051189720b8de974e4746090aaa10d44",
"url": "https://api.github.com/repos/symfony/console/zipball/9a5aef5fc0d4eff86853d44202b02be8d5a20154",
"reference": "9a5aef5fc0d4eff86853d44202b02be8d5a20154",
"shasum": ""
},
"require": {
......@@ -2994,20 +3051,20 @@
],
"description": "Symfony Console Component",
"homepage": "https://symfony.com",
"time": "2016-02-28 16:20:50"
"time": "2016-03-17 09:19:04"
},
{
"name": "symfony/event-dispatcher",
"version": "v3.0.3",
"version": "v3.0.4",
"source": {
"type": "git",
"url": "https://github.com/symfony/event-dispatcher.git",
"reference": "4dd5df31a28c0f82b41cb1e1599b74b5dcdbdafa"
"reference": "9002dcf018d884d294b1ef20a6f968efc1128f39"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/4dd5df31a28c0f82b41cb1e1599b74b5dcdbdafa",
"reference": "4dd5df31a28c0f82b41cb1e1599b74b5dcdbdafa",
"url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/9002dcf018d884d294b1ef20a6f968efc1128f39",
"reference": "9002dcf018d884d294b1ef20a6f968efc1128f39",
"shasum": ""
},
"require": {
......@@ -3054,20 +3111,20 @@
],
"description": "Symfony EventDispatcher Component",
"homepage": "https://symfony.com",
"time": "2016-01-27 05:14:46"
"time": "2016-03-10 10:34:12"
},
{
"name": "symfony/filesystem",
"version": "v3.0.3",
"version": "v3.0.4",
"source": {
"type": "git",
"url": "https://github.com/symfony/filesystem.git",
"reference": "23ae8f9648d0a7fe94a47c8e20e5bf37c489a451"
"reference": "f82499a459dcade2ea56df94cc58b19c8bde3d20"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/filesystem/zipball/23ae8f9648d0a7fe94a47c8e20e5bf37c489a451",
"reference": "23ae8f9648d0a7fe94a47c8e20e5bf37c489a451",
"url": "https://api.github.com/repos/symfony/filesystem/zipball/f82499a459dcade2ea56df94cc58b19c8bde3d20",
"reference": "f82499a459dcade2ea56df94cc58b19c8bde3d20",
"shasum": ""
},
"require": {
......@@ -3103,20 +3160,20 @@
],
"description": "Symfony Filesystem Component",
"homepage": "https://symfony.com",
"time": "2016-02-23 15:16:06"
"time": "2016-03-27 10:24:39"
},
{
"name": "symfony/finder",
"version": "v3.0.3",
"version": "v3.0.4",
"source": {
"type": "git",
"url": "https://github.com/symfony/finder.git",
"reference": "623bda0abd9aa29e529c8e9c08b3b84171914723"
"reference": "c54e407b35bc098916704e9fd090da21da4c4f52"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/finder/zipball/623bda0abd9aa29e529c8e9c08b3b84171914723",
"reference": "623bda0abd9aa29e529c8e9c08b3b84171914723",
"url": "https://api.github.com/repos/symfony/finder/zipball/c54e407b35bc098916704e9fd090da21da4c4f52",
"reference": "c54e407b35bc098916704e9fd090da21da4c4f52",
"shasum": ""
},
"require": {
......@@ -3152,7 +3209,7 @@
],
"description": "Symfony Finder Component",
"homepage": "https://symfony.com",
"time": "2016-01-27 05:14:46"
"time": "2016-03-10 11:13:05"
},
{
"name": "symfony/polyfill-mbstring",
......@@ -3215,16 +3272,16 @@
},
{
"name": "symfony/process",
"version": "v3.0.3",
"version": "v3.0.4",
"source": {
"type": "git",
"url": "https://github.com/symfony/process.git",
"reference": "dfecef47506179db2501430e732adbf3793099c8"
"reference": "e6f1f98bbd355d209a992bfff45e7edfbd4a0776"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/process/zipball/dfecef47506179db2501430e732adbf3793099c8",
"reference": "dfecef47506179db2501430e732adbf3793099c8",
"url": "https://api.github.com/repos/symfony/process/zipball/e6f1f98bbd355d209a992bfff45e7edfbd4a0776",
"reference": "e6f1f98bbd355d209a992bfff45e7edfbd4a0776",
"shasum": ""
},
"require": {
......@@ -3260,20 +3317,20 @@
],
"description": "Symfony Process Component",
"homepage": "https://symfony.com",
"time": "2016-02-02 13:44:19"
"time": "2016-03-30 10:41:14"
},
{
"name": "symfony/stopwatch",
"version": "v3.0.3",
"version": "v3.0.4",
"source": {
"type": "git",
"url": "https://github.com/symfony/stopwatch.git",
"reference": "4a204804952ff267ace88cf499e0b4bb302a475e"
"reference": "6015187088421e9499d8f8316bdb396f8b806c06"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/stopwatch/zipball/4a204804952ff267ace88cf499e0b4bb302a475e",
"reference": "4a204804952ff267ace88cf499e0b4bb302a475e",
"url": "https://api.github.com/repos/symfony/stopwatch/zipball/6015187088421e9499d8f8316bdb396f8b806c06",
"reference": "6015187088421e9499d8f8316bdb396f8b806c06",
"shasum": ""
},
"require": {
......@@ -3309,20 +3366,20 @@
],
"description": "Symfony Stopwatch Component",
"homepage": "https://symfony.com",
"time": "2016-01-03 15:35:16"
"time": "2016-03-04 07:55:57"
},
{
"name": "symfony/yaml",
"version": "v3.0.3",
"version": "v3.0.4",
"source": {
"type": "git",
"url": "https://github.com/symfony/yaml.git",
"reference": "b5ba64cd67ecd6887f63868fa781ca094bd1377c"
"reference": "0047c8366744a16de7516622c5b7355336afae96"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/yaml/zipball/b5ba64cd67ecd6887f63868fa781ca094bd1377c",
"reference": "b5ba64cd67ecd6887f63868fa781ca094bd1377c",
"url": "https://api.github.com/repos/symfony/yaml/zipball/0047c8366744a16de7516622c5b7355336afae96",
"reference": "0047c8366744a16de7516622c5b7355336afae96",
"shasum": ""
},
"require": {
......@@ -3358,7 +3415,7 @@
],
"description": "Symfony Yaml Component",
"homepage": "https://symfony.com",
"time": "2016-02-23 15:16:06"
"time": "2016-03-04 07:55:57"
},
{
"name": "theseer/fdomdocument",
......
......@@ -23,7 +23,7 @@ return [
'module/tpe_survey/bootstrap.php',
'module/in_numbers/bootstrap.php',
'module/in_numbers_mm/bootstrap.php',
'module/export/bootstrap.php',
'module/csv_export/bootstrap.php',
],
'cache_config' => 'data/cache/config/settings.php',
];
......@@ -36,6 +36,7 @@ return [
['/forum', ['guest', 'user'], ['get']],
['/sch_sync/sync', ['school'], ['get']],
['/in_numbers', ['guest', 'user'], ['get']],
['/export/csv/edulabs_{type}.csv', ['guest', 'user'], ['get']],
],
],
],
......
<?php
use League\Csv\Reader;
use League\Csv\Writer;
use RedBeanPHP\R;
use Slim\App;
use Slim\Container;
use Slim\Http\Request;
use Slim\Http\Response;
/**
* gredu_labs.
*
* @link https://github.com/eellak/gredu_labs for the canonical source repository
*
* @copyright Copyright (c) 2008-2015 Greek Free/Open Source Software Society (https://gfoss.ellak.gr/)
* @license GNU GPLv3 http://www.gnu.org/licenses/gpl-3.0-standalone.html
*/
return function (App $app) {
$container = $app->getContainer();
$events = $container['events'];
$events('on', 'app.services', function (Container $c) {
$c['csv_export_config'] = function ($c) {
return [
'schools' => [
'data_callback' => 'csv_export_schools',
'headers' => [
'Κωδικός μονάδας',
'Ονομασία',
'Τύπος μονάδας',
'Περιφερειακή ενότητα',
'Διεύθυνση εκπαίδευσης',
'Περιφερειακή διεύθυνση εκπαίδευσης',
'Βαθμίδα εκπαίδευσης',
],
],
'labs' => [
'data_callback' => 'csv_export_labs',
'headers' => [
'ID',
'Κωδικός σχολείου',
'Ονομασία σχολείου',
'Ονομασία χώρου',
'Τύπος χώρου',
'Ειδικότητα υπευθύνου',
'Νέος χώρος',
'Επιφάνεια (m^2)',
'Σύνδεση στο δίκτυο',
'Διαθέτει server',
'Μαθήματα',
'Χρήση στα πλαίσια μαθημάτων',
'Χρήση για δραστηριότητες εκτός εκπαιδευτικού προγράμματος',
],
],
'assets' => [
'data_callback' => 'csv_export_assets',
'headers' => [
'Είδος',
'Πλήθος ',
'Έτος κτήσης',
'ID χώρου',
'Τύπος χώρου',
'Κωδικός σχολείου',
'Ονομασία σχολείου',
'Σχόλια - Παρατηρήσεις',
],
],
'appforms' => [
'data_callback' => 'csv_export_appforms',
'headers' => [
'ID',
'Κωδικός σχολείου',
'Ονομασία σχολείου',
'Ημερομηνία υποβολής',
'Σχόλια - Παρατηρήσεις',
],
],
'appforms_items' => [
'data_callback' => 'csv_export_appforms_items',
'headers' => [
'ID',
'Κωδικός σχολείου',
'Ονομασία σχολείου',
'Ημερομηνία υποβολής',
'ID χώρου',
'Τύπος χώρου',
'Νέος χώρος',
'Είδος',
'Πλήθος ',
'Αιτιολογία χρήσης',
],
],
];
};
$c['csv_export_csv_response'] = function ($c) {
return function ($res, callable $dataCallback, array $headers, $filename) use ($c) {
$csvFactory = $c['csv_export_csv_factory'];
$csv = $csvFactory($dataCallback(), $headers);
$res = $res->withHeader('Content-Type', 'application/octet-stream');
$res = $res->withHeader('Content-Transfer-Encoding', 'binary');
$res = $res->withHeader('Content-Disposition', 'attachment; filename=' . $filename);
$res->write($csv);
return $res;
};
};
$c['csv_export_csv_factory'] = function ($c) {
return function (array $data, array $headers = null) {
$csv = Writer::createFromFileObject(new SplTempFileObject());
$csv->setOutputBOM(Reader::BOM_UTF8);
$csv->addFormatter(function ($row) {
return array_map(function ($value) {
return str_replace(["\n", "\r"], ' ', $value);
}, $row);
});
if (null !== $headers) {
$csv->insertOne($headers);
}
$csv->insertAll($data);
return $csv;
};
};
$c['csv_export_schools'] = function ($c) {
return function () {
$sql = 'SELECT school.registry_no AS registry_no, '
. ' school.name AS school_name, '
. ' schooltype.name as school_type, '
. ' prefecture.name AS prefecture, '
. ' eduadmin.name AS eduadmin, '
. ' regioneduadmin.name AS region_edu_admin, '
. ' educationlevel.name AS education_level '
. ' FROM school '
. ' LEFT JOIN eduadmin ON school.eduadmin_id = eduadmin.id '
. ' LEFT JOIN regioneduadmin ON eduadmin.regioneduadmin_id = regioneduadmin.id '
. ' LEFT JOIN educationlevel ON school.educationlevel_id = educationlevel.id '
. ' LEFT JOIN schooltype ON school.schooltype_id = schooltype.id '
. ' LEFT JOIN prefecture ON school.prefecture_id = prefecture.id '
. ' GROUP BY school.id '
. ' ORDER BY school_name';
$schools = R::getAll($sql);
return $schools;
};
};
$c['csv_export_labs'] = function ($c) {
return function () {
$sql = 'SELECT lab.id AS id, '
. ' school.registry_no AS school_registry_no, '
. ' school.name AS school_name, '
. ' TRIM(lab.name) AS name, '
. ' TRIM(labtype.name) AS type, '
. ' branch.name AS responsible_branch, '
. ' IF(lab.is_new = 1, "ΝΑΙ", "ΟΧΙ") AS is_new, '
. ' lab.area AS area, '
. ' lab.has_network AS has_network, '
. ' lab.has_server AS has_server, '
. ' GROUP_CONCAT(lesson.name SEPARATOR ", ") AS lessons, '
. ' TRIM(lab.use_in_program) AS use_in_program, '
. ' TRIM(lab.use_ext_program) AS use_ext_program '
. ' FROM lab '
. ' LEFT JOIN labtype ON lab.labtype_id = labtype.id '
. ' LEFT JOIN school ON lab.school_id = school.id '
. ' LEFT JOIN lab_lesson ON lab_lesson.lab_id = lab.id '
. ' LEFT JOIN lesson ON lab_lesson.lesson_id = lesson.id '
. ' LEFT JOIN teacher ON lab.responsible_id = teacher.id '
. ' LEFT JOIN branch ON branch.id = teacher.branch_id '
. ' GROUP BY lab.id '
. ' ORDER BY school_name ' ;
$labs = R::getAll($sql);
return $labs;
};
};
$c['csv_export_assets'] = function ($c) {
return function () {
$sql = 'SELECT TRIM(itemcategory.name) AS category, '
. ' schoolasset.qty AS qty, '
. ' schoolasset.acquisition_year AS acquisition_year, '
. ' lab.id AS lab_id, '
. ' TRIM(labtype.name) AS lab_type, '
. ' school.registry_no AS school_registry_no, '
. ' school.name AS school_name, '
. ' schoolasset.comments AS comments '
. ' FROM schoolasset '
. ' LEFT JOIN itemcategory ON schoolasset.itemcategory_id = itemcategory.id '
. ' LEFT JOIN school ON schoolasset.school_id = school.id '
. ' LEFT JOIN lab ON schoolasset.lab_id = lab.id '
. ' LEFT JOIN labtype ON lab.labtype_id = labtype.id '
. ' GROUP BY schoolasset.id '
. ' ORDER BY lab.id';
$assets = R::getAll($sql);
return $assets;
};
};
$c['csv_export_appforms'] = function ($c) {
return function () {
$sql = 'SELECT applicationform.id AS id, '
. ' school.registry_no AS school_registry_no, '
. ' school.name AS school_name, '
. ' FROM_UNIXTIME(applicationform.submitted) AS submitted, '
. ' TRIM(applicationform.comments) AS comments '
. ' FROM applicationform '
. ' LEFT JOIN school ON applicationform.school_id = school.id '
. ' GROUP BY school.id '
. ' HAVING MAX(applicationform.submitted)';
$appForms = R::getAll($sql);
return $appForms;
};
};
$c['csv_export_appforms_items'] = function ($c) {
return function () {
$appFormIdsSql = 'SELECT applicationform.id '
. ' FROM applicationform '
. ' GROUP BY school_id '
. ' HAVING MAX(applicationform.submitted)';
$appFormIds = R::getCol($appFormIdsSql);
$in = implode(',', array_fill(0, count($appFormIds), '?'));
$sql = 'SELECT applicationform.id AS id, '
. ' school.registry_no AS school_registry_no, '
. ' school.name AS school_name, '
. ' FROM_UNIXTIME(applicationform.submitted) AS submitted, '
. ' lab.id AS lab_id, '
. ' TRIM(labtype.name) AS lab_type, '
. ' IF(lab.is_new = 1, "ΝΑΙ", "ΟΧΙ") AS is_new, '
. ' TRIM(itemcategory.name) AS category, '
. ' applicationformitem.qty AS qty, '
. ' TRIM(applicationformitem.reasons) AS reasons '
. ' FROM applicationformitem '
. ' LEFT JOIN applicationform ON applicationformitem.applicationform_id = applicationform.id '
. ' LEFT JOIN school ON applicationform.school_id = school.id '
. ' LEFT JOIN itemcategory ON applicationformitem.itemcategory_id = itemcategory.id '
. ' LEFT JOIN lab ON applicationformitem.lab_id = lab.id '
. ' LEFT JOIN labtype ON lab.labtype_id = labtype.id '
. ' WHERE applicationform.id IN(' . $in . ') ';
$appForms = R::getAll($sql, $appFormIds);
return $appForms;
};
};
});
$events('on', 'app.bootstrap', function (App $app, Container $c) {
$app->get('/export/csv/edulabs_{type}.csv', function (Request $req, Response $res, array $args) use ($c) {
$type = $args['type'];
$config = $c['csv_export_config'];
if (!array_key_exists($type, $config)) {
return $res->withStatus(404);
}
$typeConfig = $config[$type];
$csvResponse = $c['csv_export_csv_response'];
return $csvResponse($res, $c[$typeConfig['data_callback']], $typeConfig['headers'], 'edulabs_' . $type . '.csv');