Commit 446b26d3 authored by Bertrand Gauthier's avatar Bertrand Gauthier
Browse files

wip extraction formation

parent d77c3d03
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -64,7 +64,9 @@
        "unicaen/search": "dev-master",
        "unicaen/sql": "dev-master",
        "unicaen/sygal-api": "dev-master",
        "unicaen/utilisateur": "^6.3"
        "unicaen/utilisateur": "^6.3",
        "phpoffice/phpspreadsheet": "^2.1",
        "svrnm/exceldatatables": "^0.3.0"
    },
    "minimum-stability": "dev",
    "prefer-stable": true,
+379 −0
Original line number Diff line number Diff line
@@ -470,6 +470,85 @@
            },
            "time": "2021-12-14T00:20:41+00:00"
        },
        {
            "name": "composer/pcre",
            "version": "3.3.2",
            "source": {
                "type": "git",
                "url": "https://github.com/composer/pcre.git",
                "reference": "b2bed4734f0cc156ee1fe9c0da2550420d99a21e"
            },
            "dist": {
                "type": "zip",
                "url": "https://api.github.com/repos/composer/pcre/zipball/b2bed4734f0cc156ee1fe9c0da2550420d99a21e",
                "reference": "b2bed4734f0cc156ee1fe9c0da2550420d99a21e",
                "shasum": ""
            },
            "require": {
                "php": "^7.4 || ^8.0"
            },
            "conflict": {
                "phpstan/phpstan": "<1.11.10"
            },
            "require-dev": {
                "phpstan/phpstan": "^1.12 || ^2",
                "phpstan/phpstan-strict-rules": "^1 || ^2",
                "phpunit/phpunit": "^8 || ^9"
            },
            "type": "library",
            "extra": {
                "phpstan": {
                    "includes": [
                        "extension.neon"
                    ]
                },
                "branch-alias": {
                    "dev-main": "3.x-dev"
                }
            },
            "autoload": {
                "psr-4": {
                    "Composer\\Pcre\\": "src"
                }
            },
            "notification-url": "https://packagist.org/downloads/",
            "license": [
                "MIT"
            ],
            "authors": [
                {
                    "name": "Jordi Boggiano",
                    "email": "j.boggiano@seld.be",
                    "homepage": "http://seld.be"
                }
            ],
            "description": "PCRE wrapping library that offers type-safe preg_* replacements.",
            "keywords": [
                "PCRE",
                "preg",
                "regex",
                "regular expression"
            ],
            "support": {
                "issues": "https://github.com/composer/pcre/issues",
                "source": "https://github.com/composer/pcre/tree/3.3.2"
            },
            "funding": [
                {
                    "url": "https://packagist.com",
                    "type": "custom"
                },
                {
                    "url": "https://github.com/composer",
                    "type": "github"
                },
                {
                    "url": "https://tidelift.com/funding/github/packagist/composer/composer",
                    "type": "tidelift"
                }
            ],
            "time": "2024-11-12T16:29:46+00:00"
        },
        {
            "name": "devizzent/cebe-php-openapi",
            "version": "1.1.4",
@@ -7450,6 +7529,84 @@
            ],
            "time": "2021-06-28T04:27:21+00:00"
        },
      {
        "name": "maennchen/zipstream-php",
        "version": "2.4.0",
        "source": {
          "type": "git",
          "url": "https://github.com/maennchen/ZipStream-PHP.git",
          "reference": "3fa72e4c71a43f9e9118752a5c90e476a8dc9eb3"
        },
        "dist": {
          "type": "zip",
          "url": "https://api.github.com/repos/maennchen/ZipStream-PHP/zipball/3fa72e4c71a43f9e9118752a5c90e476a8dc9eb3",
          "reference": "3fa72e4c71a43f9e9118752a5c90e476a8dc9eb3",
          "shasum": ""
        },
        "require": {
          "ext-mbstring": "*",
          "myclabs/php-enum": "^1.5",
          "php": "^8.0",
          "psr/http-message": "^1.0"
        },
        "require-dev": {
          "ext-zip": "*",
          "friendsofphp/php-cs-fixer": "^3.9",
          "guzzlehttp/guzzle": "^6.5.3 || ^7.2.0",
          "mikey179/vfsstream": "^1.6",
          "php-coveralls/php-coveralls": "^2.4",
          "phpunit/phpunit": "^8.5.8 || ^9.4.2",
          "vimeo/psalm": "^5.0"
        },
        "type": "library",
        "autoload": {
          "psr-4": {
            "ZipStream\\": "src/"
          }
        },
        "notification-url": "https://packagist.org/downloads/",
        "license": [
          "MIT"
        ],
        "authors": [
          {
            "name": "Paul Duncan",
            "email": "pabs@pablotron.org"
          },
          {
            "name": "Jonatan Männchen",
            "email": "jonatan@maennchen.ch"
          },
          {
            "name": "Jesse Donat",
            "email": "donatj@gmail.com"
          },
          {
            "name": "András Kolesár",
            "email": "kolesar@kolesar.hu"
          }
        ],
        "description": "ZipStream is a library for dynamically streaming dynamic zip files from PHP without writing to the disk at all on the server.",
        "keywords": [
          "stream",
          "zip"
        ],
        "support": {
          "issues": "https://github.com/maennchen/ZipStream-PHP/issues",
          "source": "https://github.com/maennchen/ZipStream-PHP/tree/2.4.0"
        },
        "funding": [
          {
            "url": "https://github.com/maennchen",
            "type": "github"
          },
          {
            "url": "https://opencollective.com/zipstream",
            "type": "open_collective"
          }
        ],
        "time": "2022-12-08T12:29:14+00:00"
      },
        {
            "name": "marc-mabe/php-enum",
            "version": "v4.7.1",
@@ -7977,6 +8134,69 @@
            ],
            "time": "2025-04-29T12:36:36+00:00"
        },
        {
            "name": "myclabs/php-enum",
            "version": "1.8.5",
            "source": {
                "type": "git",
                "url": "https://github.com/myclabs/php-enum.git",
                "reference": "e7be26966b7398204a234f8673fdad5ac6277802"
            },
            "dist": {
                "type": "zip",
                "url": "https://api.github.com/repos/myclabs/php-enum/zipball/e7be26966b7398204a234f8673fdad5ac6277802",
                "reference": "e7be26966b7398204a234f8673fdad5ac6277802",
                "shasum": ""
            },
            "require": {
                "ext-json": "*",
                "php": "^7.3 || ^8.0"
            },
            "require-dev": {
                "phpunit/phpunit": "^9.5",
                "squizlabs/php_codesniffer": "1.*",
                "vimeo/psalm": "^4.6.2 || ^5.2"
            },
            "type": "library",
            "autoload": {
                "psr-4": {
                    "MyCLabs\\Enum\\": "src/"
                },
                "classmap": [
                    "stubs/Stringable.php"
                ]
            },
            "notification-url": "https://packagist.org/downloads/",
            "license": [
                "MIT"
            ],
            "authors": [
                {
                    "name": "PHP Enum contributors",
                    "homepage": "https://github.com/myclabs/php-enum/graphs/contributors"
                }
            ],
            "description": "PHP Enum implementation",
            "homepage": "https://github.com/myclabs/php-enum",
            "keywords": [
                "enum"
            ],
            "support": {
                "issues": "https://github.com/myclabs/php-enum/issues",
                "source": "https://github.com/myclabs/php-enum/tree/1.8.5"
            },
            "funding": [
                {
                    "url": "https://github.com/mnapoli",
                    "type": "github"
                },
                {
                    "url": "https://tidelift.com/funding/github/packagist/myclabs/php-enum",
                    "type": "tidelift"
                }
            ],
            "time": "2025-01-14T11:49:03+00:00"
        },
        {
            "name": "nikic/php-parser",
            "version": "v5.4.0",
@@ -8085,6 +8305,112 @@
            },
            "time": "2020-10-15T08:29:30+00:00"
        },
        {
            "name": "phpoffice/phpspreadsheet",
            "version": "2.1.8",
            "source": {
                "type": "git",
                "url": "https://github.com/PHPOffice/PhpSpreadsheet.git",
                "reference": "8be52afdacac097057f8e165b1427cb8789dde92"
            },
            "dist": {
                "type": "zip",
                "url": "https://api.github.com/repos/PHPOffice/PhpSpreadsheet/zipball/8be52afdacac097057f8e165b1427cb8789dde92",
                "reference": "8be52afdacac097057f8e165b1427cb8789dde92",
                "shasum": ""
            },
            "require": {
                "composer/pcre": "^3.2",
                "ext-ctype": "*",
                "ext-dom": "*",
                "ext-fileinfo": "*",
                "ext-gd": "*",
                "ext-iconv": "*",
                "ext-libxml": "*",
                "ext-mbstring": "*",
                "ext-simplexml": "*",
                "ext-xml": "*",
                "ext-xmlreader": "*",
                "ext-xmlwriter": "*",
                "ext-zip": "*",
                "ext-zlib": "*",
                "maennchen/zipstream-php": "^2.1 || ^3.0",
                "markbaker/complex": "^3.0",
                "markbaker/matrix": "^3.0",
                "php": "^8.0",
                "psr/http-client": "^1.0",
                "psr/http-factory": "^1.0",
                "psr/simple-cache": "^1.0 || ^2.0 || ^3.0"
            },
            "require-dev": {
                "dealerdirect/phpcodesniffer-composer-installer": "dev-main",
                "dompdf/dompdf": "^2.0 || ^3.0",
                "friendsofphp/php-cs-fixer": "^3.2",
                "mitoteam/jpgraph": "^10.3",
                "mpdf/mpdf": "^8.1.1",
                "phpcompatibility/php-compatibility": "^9.3",
                "phpstan/phpstan": "^1.1",
                "phpstan/phpstan-phpunit": "^1.0",
                "phpunit/phpunit": "^9.6",
                "squizlabs/php_codesniffer": "^3.7",
                "symfony/process": "^5",
                "tecnickcom/tcpdf": "^6.5"
            },
            "suggest": {
                "dompdf/dompdf": "Option for rendering PDF with PDF Writer",
                "ext-intl": "PHP Internationalization Functions",
                "mitoteam/jpgraph": "Option for rendering charts, or including charts with PDF or HTML Writers",
                "mpdf/mpdf": "Option for rendering PDF with PDF Writer",
                "tecnickcom/tcpdf": "Option for rendering PDF with PDF Writer"
            },
            "type": "library",
            "autoload": {
                "psr-4": {
                    "PhpOffice\\PhpSpreadsheet\\": "src/PhpSpreadsheet"
                }
            },
            "notification-url": "https://packagist.org/downloads/",
            "license": [
                "MIT"
            ],
            "authors": [
                {
                    "name": "Maarten Balliauw",
                    "homepage": "https://blog.maartenballiauw.be"
                },
                {
                    "name": "Mark Baker",
                    "homepage": "https://markbakeruk.net"
                },
                {
                    "name": "Franck Lefevre",
                    "homepage": "https://rootslabs.net"
                },
                {
                    "name": "Erik Tilt"
                },
                {
                    "name": "Adrien Crivelli"
                }
            ],
            "description": "PHPSpreadsheet - Read, Create and Write Spreadsheet documents in PHP - Spreadsheet engine",
            "homepage": "https://github.com/PHPOffice/PhpSpreadsheet",
            "keywords": [
                "OpenXML",
                "excel",
                "gnumeric",
                "ods",
                "php",
                "spreadsheet",
                "xls",
                "xlsx"
            ],
            "support": {
                "issues": "https://github.com/PHPOffice/PhpSpreadsheet/issues",
                "source": "https://github.com/PHPOffice/PhpSpreadsheet/tree/2.1.8"
            },
            "time": "2025-01-26T04:51:58+00:00"
        },
        {
            "name": "psr/cache",
            "version": "1.0.1",
@@ -9562,6 +9888,59 @@
            ],
            "time": "2025-02-05T13:22:35+00:00"
        },
        {
            "name": "svrnm/exceldatatables",
            "version": "v0.3.0",
            "source": {
                "type": "git",
                "url": "https://github.com/svrnm/exceldatatables.git",
                "reference": "a276c370ff1e8c17f0b281e8e0bf705c3fa2efe6"
            },
            "dist": {
                "type": "zip",
                "url": "https://api.github.com/repos/svrnm/exceldatatables/zipball/a276c370ff1e8c17f0b281e8e0bf705c3fa2efe6",
                "reference": "a276c370ff1e8c17f0b281e8e0bf705c3fa2efe6",
                "shasum": ""
            },
            "require": {
                "php": ">=7.0.0"
            },
            "require-dev": {
                "mikey179/vfsstream": "1.3.*@dev",
                "phpspec/phpspec": "~2.0"
            },
            "type": "library",
            "autoload": {
                "psr-0": {
                    "Svrnm\\ExcelDataTables": "src/"
                }
            },
            "notification-url": "https://packagist.org/downloads/",
            "license": [
                "Apache-2.0"
            ],
            "authors": [
                {
                    "name": "Severin Neumann",
                    "email": "severin.neumann@altmuehlnet.de"
                }
            ],
            "description": "Replace a worksheet within an Excel workbook (.xlsx) without changing any other properties of the file",
            "keywords": [
                "datatables",
                "excel",
                "php",
                "spreadsheet",
                "workbook",
                "worksheet",
                "xls"
            ],
            "support": {
                "issues": "https://github.com/svrnm/exceldatatables/issues",
                "source": "https://github.com/svrnm/exceldatatables/tree/v0.3.0"
            },
            "time": "2024-07-10T14:07:41+00:00"
        },
        {
            "name": "symfony/console",
            "version": "v6.4.21",
+104 −0
Original line number Diff line number Diff line
--
-- 9.3.1
--

insert into unicaen_privilege_privilege(ID, CATEGORIE_ID, CODE, LIBELLE, ORDRE)
select nextval('privilege_id_seq'), cp.id, 'exporter-xls', 'Générer un export Excel des formations', 7
from unicaen_privilege_categorie cp
where cp.CODE = 'formation_formation'
on conflict do nothing;

select privilege__grant_privileges_to_profiles('formation_formation', ARRAY['index', 'afficher', 'exporter-xls'], ARRAY['ADMIN_TECH', 'BDD', 'GEST_FORM']);
select privilege__revoke_privileges_to_profiles('formation_formation', ARRAY['index', 'afficher', 'exporter-xls'], ARRAY['GEST_ED', 'RESP_ED']);


-- vues extraction

drop view if exists v_formation_export ;
create or replace view v_formation_export as
SELECT f.id AS formation_id,
       f.libelle AS formation_titre,
       sess.id AS session_id,
       ( SELECT string_agg((if.nom_patronymique::text || ' '::text) || if.prenom1::text, ','::text || chr(10)) AS string_agg
         FROM formation_formateur ff
                  JOIN individu if ON if.id = ff.individu_id
         WHERE ff.histo_destruction IS NULL AND sess.id = ff.session_id) AS session_intervenants,
       sess.modalite AS session_modalite,
       sess.type AS session_type,
       ( SELECT string_agg(COALESCE(fsvs.sigle, fsvs.code)::text, ','::text || chr(10)) AS string_agg
         FROM formation_session_structure_valide fsv
                  JOIN structure fsvs ON fsv.structure_id = fsvs.id
         WHERE sess.id = fsv.session_id AND fsv.histo_destruction IS NULL) AS session_structures_valides,
       ssr.sigle AS session_etab_orga,
       COALESCE((sir.nom_patronymique::text || ' '::text) || sir.prenom1::text, (fir.nom_patronymique::text || ' '::text) || fir.prenom1::text) AS session_responsable,
       ( SELECT count(fi.id) AS count
         FROM formation_inscription fi
         WHERE sess.id = fi.session_id AND fi.histo_destruction IS NULL AND fi.liste IS NULL) AS session_nb_nonclasses,
       ( SELECT count(fi.id) AS count
         FROM formation_inscription fi
         WHERE sess.id = fi.session_id AND fi.histo_destruction IS NULL AND fi.liste::text = 'P'::text) AS session_nb_liste_princ,
       ( SELECT count(fi.id) AS count
         FROM formation_inscription fi
         WHERE sess.id = fi.session_id AND fi.histo_destruction IS NULL AND fi.liste::text = 'C'::text) AS session_nb_liste_compl,
       sea.id AS seance_id,
       EXTRACT(year FROM sea.debut) AS seance_annee_debut,
       to_char(sea.debut, 'DD/MM/YYYY HH24:MI'::text) AS seance_debut,
       to_char(sea.fin, 'DD/MM/YYYY HH24:MI'::text) AS seance_fin,
       date_part('hour'::text, sea.fin - sea.debut) + date_part('min'::text, sea.fin - sea.debut) / 60::double precision AS seance_nb_h,
       ( SELECT count(fp.id) AS count
         FROM formation_presence fp
         WHERE fp.seance_id = sea.id AND fp.histo_destruction IS NULL AND fp.temoin::text = 'O'::text) AS seance_nb_presents,
       (( SELECT count(fi.id) AS count
          FROM formation_inscription fi
          WHERE sess.id = fi.session_id AND fi.histo_destruction IS NULL AND fi.liste::text = 'P'::text)) - (( SELECT count(fp.id) AS count
                                                                                                               FROM formation_presence fp
                                                                                                               WHERE sea.id = fp.seance_id AND fp.histo_destruction IS NULL AND fp.temoin::text = 'O'::text)) AS seance_nb_absents,
       ( SELECT string_agg(tmp.str, ','::text || chr(10)) AS string_agg
         FROM ( SELECT (des.sigle::text || ':'::text) || count(*) AS str
                FROM formation_presence fp
                         JOIN formation_inscription fi ON fp.inscription_id = fi.id AND fi.histo_destruction IS NULL
                         JOIN doctorant d ON fi.doctorant_id = d.id
                         JOIN etablissement de ON d.etablissement_id = de.id
                         JOIN structure des ON de.structure_id = des.id
                WHERE fp.temoin::text = 'O'::text AND fp.seance_id = sea.id
                GROUP BY des.sigle, fp.temoin
                ORDER BY des.sigle) tmp) AS seance_nb_presents_etab
FROM formation_seance sea
         JOIN formation_session sess ON sea.session_id = sess.id AND sess.histo_destruction IS NULL
         JOIN formation_formation f ON sess.formation_id = f.id AND f.histo_destruction IS NULL
         JOIN structure ssr ON ssr.id = sess.site_id
         LEFT JOIN individu fir ON fir.id = f.responsable_id
         LEFT JOIN individu sir ON sir.id = sess.responsable_id
WHERE sea.histo_destruction IS NULL
ORDER BY f.id desc, f.libelle, sea.debut;

-- select * from v_formation_export
-- where formation_id >= 200;

drop view if exists v_formation_enquete_export ;
create or replace view v_formation_enquete_export as
select fs.formation_id,
       ff.libelle as formation_libelle,
       fs.id as session_id,
       ec.libelle as question_categorie,
       eq.libelle as question_libelle,
       er.niveau as reponse_niveau,
       er.description as reponse_commentaire,
       to_char(coalesce(er.histo_modification, er.histo_creation), 'DD/MM/YYYY') reponse_date
from formation_enquete_reponse er
         join formation_inscription fi on er.inscription_id = fi.id and fi.histo_destruction is null
         join formation_session fs on fi.session_id = fs.id and fs.histo_destruction is null
         join formation_formation ff on fs.formation_id = ff.id and ff.histo_destruction is null
         join formation_enquete_question eq on er.question_id = eq.id and eq.histo_destruction is null
         join formation_enquete_categorie ec on eq.categorie_id = ec.id and eq.histo_destruction is null
where er.histo_destruction is null
--and er.description is not null and trim(er.description) <> ''
order by fs.formation_id desc, ec.libelle, eq.libelle
;

-- dernier onglet Par doctroant

-- > Nombre d'heures suivies. Si le doctorant n'est pas présent à toutes les séances, indique le nombre d'heures des séances suivies :
-- déjà qqpart dans sygal (cf. attestation de présence/suivi).
-- > D1, D2, etc : cf. liste inscription.
-- > inscrit le : cf. liste inscription
+22 −1
Original line number Diff line number Diff line
@@ -2,10 +2,31 @@

use Application\Controller\ExportController;
use Application\Controller\Factory\ExportControllerFactory;
use Application\Export\Xlsx\Writer\ExcelDataTables\ExcelDataTablesXlsxWriter;
use Application\Export\Xlsx\Writer\PhpOffice\PhpOfficeXlsxWriter;
use Application\Export\Xlsx\Writer\XlsxWriterManager;
use Application\Export\Xlsx\Writer\XlsxWriterManagerFactory;
use Laminas\ServiceManager\Factory\InvokableFactory;
use These\Provider\Privilege\ThesePrivileges;
use UnicaenPrivilege\Guard\PrivilegeController;

return [
    'xlsx_writer' => [
        'factories' => [
            // Cf. https://github.com/PHPOffice/PhpSpreadsheet
            // Attention : détruit les éventuels tableaux croisés existants !
            PhpOfficeXlsxWriter::class => InvokableFactory::class,
            // Cf. https://github.com/svrnm/exceldatatables
            // Injection de données brutes dans un .xlsx contenant des tableaux dynamiques.
            ExcelDataTablesXlsxWriter::class => InvokableFactory::class,
        ],
    ],
    'xlsx_export' => [
        'factories' => [],
        'aliases' => [],
        'config' => [],
    ],

    'bjyauthorize'    => [
        'guards' => [
            PrivilegeController::class => [
@@ -47,7 +68,7 @@ return [
    ],
    'service_manager' => [
        'factories' => [
//            'ExportService' => ::class,
            XlsxWriterManager::class => XlsxWriterManagerFactory::class,
        ],
    ],
    'controllers'     => [
+193 −0

File added.

Preview size limit exceeded, changes collapsed.

Loading