Files
oberstufe-alt/typo3conf/ext/if_oberstufenplaner/Classes/PDF/Pdf.php
2018-04-02 08:07:38 +02:00

147 lines
7.8 KiB
PHP

<?php
namespace Internetfabrik\IfOberstufenplaner\PDF;
use HeikoHardt\HhdevFpdi\Fpdi;
use Internetfabrik\IfOberstufenplaner\Domain\Model\Fach;
use TYPO3\CMS\Core\Utility\GeneralUtility;
include_once(\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath('t3_tcpdf').'/tcpdf/tcpdf.php');
include_once(\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath('t3_tcpdf').'/tcpdf/tcpdf_import.php');
//include_once(\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath('hhdev_fpdi').'/Classes/fpdi.php');
/**
* Class Pdf
* @package Internetfabrik\IfOberstufenplaner\PDF
* @{@inheritdoc}
*/
class Pdf extends \TCPDF {
protected $customFonts = array();
protected $extFontPath;
protected $cellmarginLeft = 2;
protected $currentX = 0;
protected $currentY = 5;
protected $lineHeight = 0.6;
protected $marginX = 0.075;
protected $marginY = 0.075;
protected $nameCellWidth = 6;
protected $dataCellWidth = 2;
protected $tableTitleFontSize = 8;
protected $tableCellFontSize = 10;
protected $footerText = 'Der Fächerplaner versucht, Ihre Auswahl durch Hinweise und automatische Eingrenzung der Auwahlmöglichkeiten bestmöglich zu unterstützen. Trotzdem kann keine Garantie übernommen werden, dass die von Ihnen getroffene Wahl zulässig oder an Ihrer Schule möglich ist. Er ersetzt nicht die schulspezifische Information bzw. die Regelungen in der Schulordnung für die Gymnasien in Bayern (GSO).
Bitte beachten Sie, dass keine Schule in der Lage ist, alle Fächer des Wahlpflicht- bzw. des Profilbereichs anzubieten. Auch das Seminarangebot orientiert sich an den Möglichkeiten bzw. den Schwerpunktsetzungen des einzelnen Gymnasiums. Die Schulen treffen daher eine Auswahl, stellen diese zur Wahl und richten die durch ausreichendes Wahlinteresse gesicherten Kurse und Seminare ein.
Bei Fragen hilft Ihnen der Oberstufenkoordinator Ihrer Schule gerne weiter.';
//// public function __construct($orientation='P', $unit='mm', $format='A4', $unicode=true, $encoding='UTF-8', $diskcache=false, $pdfa=false)
// public function __construct($file)
// {
// parent::__construct();
////// $pageCount = $this->setSourceFile(\TYPO3\CMS\Core\Utility\GeneralUtility::getFileAbsFileName('EXT:if_oberstufenplaner/Resources/Public/pdf/maxim.pdf'));
////// $tplIdx = $this->importPage(1);
////// $this->addPage();
////// $this->useTemplate($tplIdx, 10, 10, 90);
//// parent::__construct(\TYPO3\CMS\Core\Utility\GeneralUtility::getFileAbsFileName('EXT:if_oberstufenplaner/Resources/Public/pdf/maxim.pdf'));
//// $this->importPDF($file);
// }
public function configureFonts($extFontPath) {
$this->customFonts['openSansRegularFont'] = \TCPDF_FONTS::addTTFfont(GeneralUtility::getFileAbsFileName($extFontPath.'OpenSans-Regular.ttf'));
}
public function getCustomFont($name) {
if (isset($this->customFonts[$name])) {
return $this->customFonts[$name];
}
throw new \Exception('Font '.$name.' not found');
}
public function pdfDrawFaecherTitel($title) {
$this->SetFont($this->getCustomFont('openSansRegularFont'), '', $this->tableTitleFontSize);
$this->currentX = 0;
$this->SetTextColor(0, 0, 0);
$this->SetFillColor(255, 255, 255);
$this->setCellMargins($this->cellmarginLeft);
$this->MultiCell($this->nameCellWidth, $this->lineHeight*2, $title, 0, 'L', false, 0, $this->currentX, $this->currentY);
$this->currentX += ($this->nameCellWidth + $this->marginX);
$this->MultiCell($this->dataCellWidth*2+$this->marginX, $this->lineHeight, 'Wochenstunden', 0, 'C', false, 0, $this->currentX, $this->currentY);
$this->MultiCell($this->dataCellWidth+$this->marginX, $this->lineHeight, '11', 0, 'C', false, 0, $this->currentX, $this->currentY+($this->lineHeight+$this->marginY));
$this->MultiCell($this->dataCellWidth+$this->marginX, $this->lineHeight, '12', 0, 'C', false, 0, ($this->currentX+$this->dataCellWidth+$this->marginX), ($this->currentY+($this->lineHeight+$this->marginY)));
$this->currentX += ($this->dataCellWidth + $this->marginX)*2;
$this->MultiCell($this->dataCellWidth, $this->lineHeight*2, "Jahres-\nWochenstd.", 0, 'C', false, 0, $this->currentX, $this->currentY);
$this->currentX += ($this->dataCellWidth + $this->marginX);
$this->MultiCell($this->dataCellWidth, $this->lineHeight*2, "Einbringung\nHalbjahre", 0, 'C', false, 0, $this->currentX, $this->currentY);
$this->currentX += ($this->dataCellWidth + $this->marginX);
$this->MultiCell($this->dataCellWidth, $this->lineHeight*2, "Abitur-\nPrüfungsfach", 0, 'C', false, 0, $this->currentX, $this->currentY);
$this->currentY += ($this->lineHeight+$this->marginY)*2;
$this->SetY($this->currentY);
}
public function pdfDrawFachLine(Fach $fach) {
$this->SetFont($this->getCustomFont('openSansRegularFont'), '', $this->tableCellFontSize);
$this->currentX = 0;
$this->SetTextColor(0, 0, 0);
// list($col1, $col2, $col3) = $fach->getRgbColor();
// $this->SetFillColor($col1, $col2, $col3);
$fillColor1 = array(217, 217, 217);
$fillColor2 = array(238, 238, 238);
$this->setCellMargins($this->cellmarginLeft);
$this->SetX($this->currentX);
$this->SetY($this->currentY);
$this->SetFillColor($fillColor1[0], $fillColor1[1], $fillColor1[2]);
$this->Cell($this->nameCellWidth, $this->lineHeight, $fach->getName(), 0, 0, 'L', true);
$this->currentX += ($this->nameCellWidth + $this->marginX); $this->setX($this->currentX);
$this->SetFillColor($fillColor2[0], $fillColor2[1], $fillColor2[2]);
$this->Cell($this->dataCellWidth, $this->lineHeight, $fach->getWochenStunden11(), 0, 0, 'C', true);
$this->currentX += ($this->dataCellWidth + $this->marginX); $this->setX($this->currentX);
$this->Cell($this->dataCellWidth, $this->lineHeight, $fach->getWochenStunden12(), 0, 0, 'C', true);
$this->currentX += ($this->dataCellWidth + $this->marginX); $this->setX($this->currentX);
$this->Cell($this->dataCellWidth, $this->lineHeight, $fach->getJahreswochenstunden(), 0, 0, 'C', true);
$this->currentX += ($this->dataCellWidth + $this->marginX); $this->setX($this->currentX);
$this->Cell($this->dataCellWidth, $this->lineHeight, $fach->getHalbjahresleistungen(), 0, 0, 'C', true);
$this->currentX += ($this->dataCellWidth + $this->marginX); $this->setX($this->currentX);
$this->Cell($this->dataCellWidth, $this->lineHeight, strtoupper($fach->getPruefung()), 0, 0, 'C', true);
$this->currentY += ($this->lineHeight+$this->marginY);
$this->SetY($this->currentY);
}
function Header() {
if ($_SERVER['REMOTE_ADDR'] == '127.0.0.1') {
$this->Image(PATH_site . 'fileadmin/templates/faecherplaner/img/wappen-ministerium.png', 3, 1, 16, 2.11, 'PNG', '', '', true); // Angaben in cm
// $this->Image($GLOBALS['TSFE']->baseUrl . 'fileadmin/templates/faecherplaner/img/wappen-ministerium.png', 3, 0, 16, 2.11, 'PNG', '', '', true); // Angaben in cm
} else {
// $this->Image($GLOBALS['TSFE']->baseUrl . 'fileadmin/templates/img/wappen-ministerium.png', 3, 1, 16, 2.11, 'PNG', '', '', true); // Angaben in cm
$this->Image(PATH_site . 'fileadmin/templates/img/wappen-ministerium.png', 3, 1, 16, 2.11, 'PNG', '', '', true); // Angaben in cm
}
}
function Footer() {
$lineHeight = 0.4;
$footerHeight = 3.8;
//left
$this->SetXY(1.25, -$footerHeight);
$this->SetTextColor(0, 0, 0);
$this->SetFont($this->getCustomFont('openSansRegularFont'),'',8);
$this->MultiCell(21-(1.25*2), $lineHeight, $this->footerText, 0, 'L', false, 0); $this->SetX(1.25);
// $this->MultiCell(20, $lineHeight, $this->footerText, 0, 1, 'L', false); $this->SetX(1.25);
}
}