Browse Source

ébauche de génération du pdf

master
Bastien 8 years ago
committed by Squiz
parent
commit
283ecb964a
3 changed files with 73 additions and 0 deletions
  1. +3
    -0
      config
  2. +51
    -0
      modules/catalogue/mvc.php
  3. +19
    -0
      modules/catalogue/templates/pdf.html

+ 3
- 0
config View File

@ -36,3 +36,6 @@ max_days_account_not_validated = 10
display_only_not_canceled = true
display_only_not_terminated = true
[module_catalogue]
pdflatex_path = /usr/local/bin/pdflatex
pdf_path = pdf/

+ 51
- 0
modules/catalogue/mvc.php View File

@ -0,0 +1,51 @@
<?php
class catalogue_model extends model {
}
class catalogue_view extends view {
public function formation_list_pdf($liste_formations, $return_string = false) {
$formations = array();
foreach($liste_formations as $formation) {
$formations[] = array (
'label' => $formation->label,
'type' => $formation->type->label,
'department' => $formation->category->department->label
);
}
$this->tpl->assign('formations', $formations);
return $this->tpl->draw('modules/catalogue/templates/pdf', $return_string);
}
}
class catalogue_controler extends controler {
public function __construct(database $database, RainTPL $tpl) {
$this->model = new catalogue_model($this, $database);
$this->view = new catalogue_view($this, $tpl);
$this->dependences = array(
'formation' => array('load' => true),
'session' => array('load' => true)
);
$this->route = array(
'generate_pdf' => array('function' => 'controler_generate_pdf', 'filter_url' => array(), 'action_cron' => true)
);
$this->load_dependences($database, $tpl);
}
public function install() {
}
public function uninstall() {
}
public function install_cron() {
}
public function uninstall_cron() {
}
public function controler_generate_pdf() {
$liste = $this->dependences['formation']['ptr']->model->formation_list($only_validated = true, $page = +1, $order_by = 'id', $order_by_asc = true, $nb_item_per_page = -1);
$tex = $this->view->formation_list_pdf($liste, $return_string = true);
echo shell_exec('cd "'.config::read_config('module_catalogue', 'pdf_path').'"; echo "'.$tex.'" > liste.tex; pdflatex liste.tex; '.config::read_config('module_catalogue', 'pdflatex_path').' liste.tex');
}
}

+ 19
- 0
modules/catalogue/templates/pdf.html View File

@ -0,0 +1,19 @@
\\documentclass[11pt,a4paper]{article}
\\usepackage[utf8,utf8x]{inputenc}
\\usepackage{CJKutf8}
\\usepackage[francais]{babel}
\\usepackage[T1]{fontenc}
\\usepackage{lmodern}
\\usepackage{marvosym}
\\pagestyle{empty}
\\usepackage[scale=0.9]{geometry}
\\\begin{document}
{loop="formations"}
\\section{{$value.label}}
type~: {$value.type} \\\\\\\\
département~: {$value.department}
{/loop}
\\end{document}

Loading…
Cancel
Save