diff --git a/.gitignore b/.gitignore index 1ae4b51..e62f8c8 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,4 @@ /public_html/js /node_modules /backup +/tmp \ No newline at end of file diff --git a/composer.json b/composer.json index 48161df..4970e9e 100644 --- a/composer.json +++ b/composer.json @@ -27,6 +27,8 @@ "require": { "phpoffice/phpspreadsheet": "^1.1", "phpstan/phpstan": "^0.9.2", - "ifsnop/mysqldump-php": "2.*" + "ifsnop/mysqldump-php": "2.*", + "setasign/fpdf": "1.8.1", + "mpdf/mpdf": "^7.0" } } diff --git a/composer.lock b/composer.lock index fb9984d..ea913c3 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "content-hash": "28e31e7da9313d9726a26a4f36bf06a3", + "content-hash": "d300af5ed297b7cdfbfda9d2604a8f95", "packages": [ { "name": "ifsnop/mysqldump-php", @@ -109,6 +109,73 @@ ], "time": "2018-01-21T13:54:22+00:00" }, + { + "name": "mpdf/mpdf", + "version": "v7.0.3", + "source": { + "type": "git", + "url": "https://github.com/mpdf/mpdf.git", + "reference": "5681a0cae1eea197143d5d27f06e19b0523cd8d6" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/mpdf/mpdf/zipball/5681a0cae1eea197143d5d27f06e19b0523cd8d6", + "reference": "5681a0cae1eea197143d5d27f06e19b0523cd8d6", + "shasum": "" + }, + "require": { + "ext-gd": "*", + "ext-mbstring": "*", + "paragonie/random_compat": "^1.4|^2.0", + "php": "^5.6 || ~7.0.0 || ~7.1.0 || ~7.2.0", + "psr/log": "^1.0", + "setasign/fpdi": "1.6.*" + }, + "require-dev": { + "mockery/mockery": "^0.9.5", + "phpunit/phpunit": "^5.0", + "squizlabs/php_codesniffer": "^2.7.0", + "tracy/tracy": "^2.4" + }, + "suggest": { + "ext-bcmath": "Needed for generation of some types of barcodes", + "ext-xml": "Needed mainly for SVG manipulation", + "ext-zlib": "Needed for compression of embedded resources, such as fonts" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-development": "7.0-dev" + } + }, + "autoload": { + "psr-4": { + "Mpdf\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "GPL-2.0" + ], + "authors": [ + { + "name": "Matěj Humpál", + "role": "Developer, maintainer" + }, + { + "name": "Ian Back", + "role": "Developer (retired)" + } + ], + "description": "A PHP class to generate PDF files from HTML with Unicode/UTF-8 and CJK support", + "homepage": "https://mpdf.github.io", + "keywords": [ + "pdf", + "php", + "utf-8" + ], + "time": "2018-01-03T07:32:36+00:00" + }, { "name": "nette/bootstrap", "version": "v2.4.5", @@ -673,6 +740,54 @@ "description": "Composer plugin that provides efficient querying for installed package versions (no runtime IO)", "time": "2018-02-05T13:05:30+00:00" }, + { + "name": "paragonie/random_compat", + "version": "v2.0.11", + "source": { + "type": "git", + "url": "https://github.com/paragonie/random_compat.git", + "reference": "5da4d3c796c275c55f057af5a643ae297d96b4d8" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/paragonie/random_compat/zipball/5da4d3c796c275c55f057af5a643ae297d96b4d8", + "reference": "5da4d3c796c275c55f057af5a643ae297d96b4d8", + "shasum": "" + }, + "require": { + "php": ">=5.2.0" + }, + "require-dev": { + "phpunit/phpunit": "4.*|5.*" + }, + "suggest": { + "ext-libsodium": "Provides a modern crypto API that can be used to generate random bytes." + }, + "type": "library", + "autoload": { + "files": [ + "lib/random.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Paragon Initiative Enterprises", + "email": "security@paragonie.com", + "homepage": "https://paragonie.com" + } + ], + "description": "PHP 5.x polyfill for random_bytes() and random_int() from PHP 7", + "keywords": [ + "csprng", + "pseudorandom", + "random" + ], + "time": "2017-09-27T21:40:39+00:00" + }, { "name": "phpoffice/phpspreadsheet", "version": "1.2.0", @@ -867,6 +982,53 @@ "description": "PHPStan - PHP Static Analysis Tool", "time": "2018-01-28T13:22:19+00:00" }, + { + "name": "psr/log", + "version": "1.0.2", + "source": { + "type": "git", + "url": "https://github.com/php-fig/log.git", + "reference": "4ebe3a8bf773a19edfe0a84b6585ba3d401b724d" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/log/zipball/4ebe3a8bf773a19edfe0a84b6585ba3d401b724d", + "reference": "4ebe3a8bf773a19edfe0a84b6585ba3d401b724d", + "shasum": "" + }, + "require": { + "php": ">=5.3.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Psr\\Log\\": "Psr/Log/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "http://www.php-fig.org/" + } + ], + "description": "Common interface for logging libraries", + "homepage": "https://github.com/php-fig/log", + "keywords": [ + "log", + "psr", + "psr-3" + ], + "time": "2016-10-10T12:19:37+00:00" + }, { "name": "psr/simple-cache", "version": "1.0.1", @@ -915,6 +1077,94 @@ ], "time": "2017-10-23T01:57:42+00:00" }, + { + "name": "setasign/fpdf", + "version": "1.8.1", + "source": { + "type": "git", + "url": "https://github.com/Setasign/FPDF.git", + "reference": "2c68c9e6c034ac3187d25968790139a73184cdb1" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/Setasign/FPDF/zipball/2c68c9e6c034ac3187d25968790139a73184cdb1", + "reference": "2c68c9e6c034ac3187d25968790139a73184cdb1", + "shasum": "" + }, + "type": "library", + "autoload": { + "classmap": [ + "fpdf.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "no usage restriction" + ], + "authors": [ + { + "name": "Olivier Plathey", + "email": "oliver@fpdf.org", + "homepage": "http://fpdf.org/" + } + ], + "description": "FPDF is a PHP class which allows to generate PDF files with pure PHP. F from FPDF stands for Free: you may use it for any kind of usage and modify it to suit your needs.", + "homepage": "http://www.fpdf.org", + "keywords": [ + "fpdf", + "pdf" + ], + "time": "2016-01-01T17:47:15+00:00" + }, + { + "name": "setasign/fpdi", + "version": "1.6.2", + "source": { + "type": "git", + "url": "https://github.com/Setasign/FPDI.git", + "reference": "a6ad58897a6d97cc2d2cd2adaeda343b25a368ea" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/Setasign/FPDI/zipball/a6ad58897a6d97cc2d2cd2adaeda343b25a368ea", + "reference": "a6ad58897a6d97cc2d2cd2adaeda343b25a368ea", + "shasum": "" + }, + "suggest": { + "setasign/fpdf": "FPDI will extend this class but as it is also possible to use \"tecnickcom/tcpdf\" as an alternative there's no fixed dependency configured.", + "setasign/fpdi-fpdf": "Use this package to automatically evaluate dependencies to FPDF.", + "setasign/fpdi-tcpdf": "Use this package to automatically evaluate dependencies to TCPDF." + }, + "type": "library", + "autoload": { + "classmap": [ + "filters/", + "fpdi.php", + "fpdf_tpl.php", + "fpdi_pdf_parser.php", + "pdf_context.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Jan Slabon", + "email": "jan.slabon@setasign.com", + "homepage": "https://www.setasign.com" + } + ], + "description": "FPDI is a collection of PHP classes facilitating developers to read pages from existing PDF documents and use them as templates in FPDF. Because it is also possible to use FPDI with TCPDF, there are no fixed dependencies defined. Please see suggestions for packages which evaluates the dependencies automatically.", + "homepage": "https://www.setasign.com/fpdi", + "keywords": [ + "fpdf", + "fpdi", + "pdf" + ], + "time": "2017-05-11T14:25:49+00:00" + }, { "name": "symfony/console", "version": "v4.0.6", diff --git a/public_html/font/FiraSans-Regular.ttf b/public_html/font/FiraSans-Regular.ttf new file mode 100644 index 0000000..d9fdc0e Binary files /dev/null and b/public_html/font/FiraSans-Regular.ttf differ diff --git a/public_html/pdf.php b/public_html/pdf.php new file mode 100644 index 0000000..fb8453d --- /dev/null +++ b/public_html/pdf.php @@ -0,0 +1,231 @@ +getDefaults(); + $fontDirs = $defaultConfig['fontDir']; + + /* (2) Get Font data */ + $defaultFontConfig = (new Mpdf\Config\FontVariables())->getDefaults(); + $fontData = $defaultFontConfig['fontdata']; + + /* (3) Create PDF file */ + $pdf = new \Mpdf\Mpdf([ + 'mode' => 'utf-8', + 'defaultCssFile' => __PUBLIC__.'/css/pdf.css', + 'tempDir' => __ROOT__.'/tmp', + 'fontDir' => array_merge($fontDirs, [ __PUBLIC__.'/font/' ]), + 'fontdata' => $fontData + [ + 'Fira Sans' => [ + 'R' => 'FiraSans-Regular.ttf' + ] + ], + 'default_font' => 'Fira Sans' + ]); + + /* (4) Set PDF title */ + $pdf->SetTitle('Some PDF title'); + + /* (5) Store SVG */ + $svg_warning = ' + + '; + + + + + /* (2) Set Header|Footer + ---------------------------------------------------------*/ + /* (1) Set Header content (Left, Right) */ + $header_content = [ + 'C' => [ 'color' => '#aaa', 'content' => 'Fiche enseignant Sophie Gouardères (sgouarde)' ], + 'line' => 1 + ]; + + /* (2) Apply Header */ + $pdf->setHeader([ + 'odd' => $header_content, + 'even' => $header_content + ]); + + /* (1) Set Footer content (Left, Right) */ + $footer_content = [ + 'L' => [ 'color' => '#aaa', 'content' => 'Généré le @date_création' ], + 'R' => [ 'color' => '#aaa', 'content' => 'Page {PAGENO} sur {nbpg}' ], + 'line' => 1 + ]; + + /* (2) Apply Footer */ + $pdf->setFooter([ + 'odd' => $footer_content, + 'even' => $footer_content + ]); + + + + + + /* (3) Page 1 - Récapitulatif + ---------------------------------------------------------*/ + /* (1) Initialize page */ + $pdf->AddPage(); + + /* (2) Write content */ + $pdf->WriteHTML('
+

1. Récapitulatif

+
+ +
+

+ Mollitia quo ullam voluptas quia delectus nihil ab. (cliquer ici) Temporibus voluptatum et adipisci dolores aut ut. Aliquid et non quaerat ipsa accusantium quis doloribus minus. Omnis cupiditate iste id a quisquam sunt officia. Architecto ut id non et deleniti et. Veritatis in consectetur ut +

+ +
+ Mollitia quo ullam voluptas quia delectus nihil ab. Temporibus voluptatum et adipisci dolores aut ut. Aliquid et non quaerat ipsa accusantium quis doloribus minus. Omnis cupiditate iste id a quisquam sunt officia. Architecto ut id non et deleniti et. Veritatis in consectetur ut +
+ +

+ Mollitia quo ullam voluptas quia delectus nihil ab. (cliquer ici) Temporibus voluptatum et adipisci dolores aut ut. Aliquid et non quaerat ipsa accusantium quis doloribus minus. Omnis cupiditate iste id a quisquam sunt officia. Architecto ut id non et deleniti et. Veritatis in consectetur ut +

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
DonnéeValeur
Heures à faire192 h
Equivalents TD241.41 h
Heures programmées217.5 h
Heures manquantes'.$svg_warning.' 10 h
Heures sup.0
+
+ + '); + + + + /* (4) Page 2 - Enseignements + ---------------------------------------------------------*/ + /* (1) Initialize page */ + $pdf->AddPage(); + + /* (2) Write content */ + $pdf->WriteHTML('
+

2. Enseignements

+
+ +
+

+ Mollitia quo ullam voluptas quia delectus nihil ab. (cliquer ici) Temporibus voluptatum et adipisci dolores aut ut. Aliquid et non quaerat ipsa accusantium quis doloribus minus. Omnis cupiditate iste id a quisquam sunt officia. Architecto ut id non et deleniti et. Veritatis in consectetur ut +

+ +
+ Mollitia quo ullam voluptas quia delectus nihil ab. Temporibus voluptatum et adipisci dolores aut ut. Aliquid et non quaerat ipsa accusantium quis doloribus minus. Omnis cupiditate iste id a quisquam sunt officia. Architecto ut id non et deleniti et. Veritatis in consectetur ut +
+ +

+ Mollitia quo ullam voluptas quia delectus nihil ab. (cliquer ici) Temporibus voluptatum et adipisci dolores aut ut. Aliquid et non quaerat ipsa accusantium quis doloribus minus. Omnis cupiditate iste id a quisquam sunt officia. Architecto ut id non et deleniti et. Veritatis in consectetur ut +

+ +


+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Liste des enseignements programmés
Code UENom UEPrestationvolume horaireformations
T0XALA2VAlgorithmique avancéeCours13.5 heures
    +
  • MIASHS
  • +
  • L1 INFO (S2)
  • +
T0XALA2VAlgorithmique avancéeTD22 heures
    +
  • L1 INFO (S2)
  • +
T0XALA2VAlgorithmique avancéeTP5 heures
    +
  • MIASHS
  • +
  • L1 INFO (S2)
  • +
  • L2 INFO (S2)
  • +
T0MSAP3UAlgorithmique et programmation avancéeTP12 heures
    +
  • MIASHS
  • +
  • L1 INFO (S2)
  • +
  • L2 INFO (S2)
  • +
+
+ + + '); + + + + + /* (N) Print out PDF file + ---------------------------------------------------------*/ + + $pdf->Output(); + + diff --git a/webpack/scss/pdf.scss b/webpack/scss/pdf.scss new file mode 100644 index 0000000..2af9558 --- /dev/null +++ b/webpack/scss/pdf.scss @@ -0,0 +1,95 @@ +/* (1) Reset +---------------------------------------------------------*/ +*{ + margin: 0; + padding: 0; +} + +body{ + background-color: #fff; + + font-size: 16px; + color: #444; +} + + +/* (2) Basic layout +---------------------------------------------------------*/ +article{ + + // Titles + h3{ + color: #555; + } + + // Titles' separators + hr{ + display: block; + border-style: solid; + border-width: 1px; + } + + // paragraphs + p{ + text-indent: 2em; + } + + // links + a{ + color: #2d92cc; + text-decoration: underline; + } + + // quotes + blockquote{ + margin-left: 0; + padding-left: 1em; + + border-left: 2px solid #eee; + + color: #999; + } + + // tables + table{ + + border-collapse: collapse; + + color: #555; + + tr{ + + td{ + + padding: .2em 1em; + + border: 1px dotted rgb(221, 221, 221); + + background-color: #fff; + + } + + // each other row is darker + &:nth-child(2n) td{ + background-color: #eee; + } + + } + + // table headers bold revert + thead tr th{ + font-weight: normal; + } + + thead tr td.color, + thead tr th.color{ + background-color: rgb(75, 189, 209); + color: #fff; + } + + td.ar{ text-align: right; } + td.ac{ text-align: center; } + td.al{ text-align: left; } + } + +} \ No newline at end of file