123 lines
3.5 KiB
PHP
123 lines
3.5 KiB
PHP
|
|
<?php
|
||
|
|
//Iniciar sessions
|
||
|
|
require_once "sessionManager.php";
|
||
|
|
|
||
|
|
// Require config
|
||
|
|
require_once "config.php";
|
||
|
|
|
||
|
|
// Require composer autoload
|
||
|
|
require_once __DIR__ . '/vendor/autoload.php';
|
||
|
|
|
||
|
|
// Require conexion
|
||
|
|
global $link;
|
||
|
|
dbConnect();
|
||
|
|
$constancia = [];
|
||
|
|
$course = [];
|
||
|
|
|
||
|
|
// Query data Constancia
|
||
|
|
$sqlConstanciaData = "SELECT
|
||
|
|
c.firma,
|
||
|
|
c.representante,
|
||
|
|
c.cargo_rep as cargo,
|
||
|
|
c.fondo,
|
||
|
|
c.habilitado_fondo,
|
||
|
|
c.logo,
|
||
|
|
c.align_logo,
|
||
|
|
c.align_content,
|
||
|
|
c.habilitado_logo
|
||
|
|
FROM
|
||
|
|
constancias as c
|
||
|
|
WHERE
|
||
|
|
c.habilitado = 1";
|
||
|
|
|
||
|
|
|
||
|
|
$result = mysqli_query($link, $sqlConstanciaData);
|
||
|
|
if ( mysqli_num_rows($result) <= 0 ) {
|
||
|
|
$constancia = array('fondo' => '' , 'align_content' => 'center', 'representante' => '', 'cargo' => '' );
|
||
|
|
}else{
|
||
|
|
while ($row = mysqli_fetch_assoc ($result)){
|
||
|
|
$constancia = $row;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
//Get data user
|
||
|
|
$user = json_decode($_SESSION['usersession']);
|
||
|
|
|
||
|
|
//get data course
|
||
|
|
if ($_GET['idcourse'] != '') {
|
||
|
|
$idcourse = $_GET['idcourse'];
|
||
|
|
|
||
|
|
$sql = "SELECT
|
||
|
|
nombre
|
||
|
|
FROM
|
||
|
|
categoria
|
||
|
|
WHERE
|
||
|
|
id = $idcourse";
|
||
|
|
|
||
|
|
$result = mysqli_query($link, $sql);
|
||
|
|
if ( mysqli_num_rows($result) <= 0 ) {
|
||
|
|
$course = array('nombre' => 'Cargando...');
|
||
|
|
}else{
|
||
|
|
while ($row = mysqli_fetch_assoc ($result)){
|
||
|
|
$nombre = $row['nombre'];
|
||
|
|
}
|
||
|
|
$course = array('nombre' => $nombre);
|
||
|
|
}
|
||
|
|
}else{
|
||
|
|
$course = array('nombre' => 'Nombre del Curso');
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
// Create an instance of the class:
|
||
|
|
$mpdf = new \Mpdf\Mpdf([
|
||
|
|
'mode' => 'utf-8',
|
||
|
|
'format' => 'letter',
|
||
|
|
'orientation' => 'L'
|
||
|
|
]);
|
||
|
|
|
||
|
|
//Titulo Documento
|
||
|
|
$mpdf->SetTitle('CONSTANCIA');
|
||
|
|
|
||
|
|
// Buffer the following html with PHP so we can store it to a variable later
|
||
|
|
ob_start();
|
||
|
|
|
||
|
|
// Now collect the output buffer into a variable
|
||
|
|
$html = ob_get_contents();
|
||
|
|
ob_end_clean();
|
||
|
|
|
||
|
|
//CSS
|
||
|
|
$stylesheet = file_get_contents('certificado/certificado.css');
|
||
|
|
$mpdf->WriteHTML($stylesheet,\Mpdf\HTMLParserMode::HEADER_CSS);
|
||
|
|
$mpdf->WriteHTML($html,\Mpdf\HTMLParserMode::HTML_BODY);
|
||
|
|
|
||
|
|
//BODY
|
||
|
|
$html = '';
|
||
|
|
if ($constancia['habilitado_fondo'] == '1') {
|
||
|
|
$html .= '<body style="background:url('.$constancia['fondo'].') no-repeat;">';
|
||
|
|
}else{
|
||
|
|
$html .= '<body>';
|
||
|
|
}
|
||
|
|
if ($constancia['habilitado_logo'] == '1') {
|
||
|
|
$html .= '<div class="titulo" style="text-align:'.$constancia['align_logo'].';"><h1><img with="100" src="'.$constancia['logo'].'"/></h1></div>';
|
||
|
|
}
|
||
|
|
$html .= '<div class="text1" style="text-align:'.$constancia['align_content'].';"><h2>Otorga la presente</h2></div>';
|
||
|
|
$html .= '<div class="text2" style="text-align:'.$constancia['align_content'].';"><h1>CONSTANCIA A</h1></div>';
|
||
|
|
$html .= '<div class="name" style="text-align:'.$constancia['align_content'].';"><h1>'.$user->nombre.' '.$user->apellido.'</h1></div>';
|
||
|
|
$html .= '<div class="text3" style="text-align:'.$constancia['align_content'].';"><h3>por haber acreditado el curso de:</h3></div>';
|
||
|
|
$html .= '<div class="course" style="text-align:'.$constancia['align_content'].';"><h1>'.$course['nombre'].'</h1></div>';
|
||
|
|
if ($constancia['firma'] != '') {
|
||
|
|
$html .= '<div class="firma"><div class="firma_sig"><img with="10px" src="'.$constancia['firma'].'"/></div></div>';
|
||
|
|
}
|
||
|
|
$html .= '<div class="line"><p><b>____________________________________________</b></p></div>';
|
||
|
|
$html .= '<div class="nameresponsable"><p>'.$constancia['representante'].'</p></div>';
|
||
|
|
$html .= '<div class="cargoresponsable"><p><b>'.$constancia['cargo'].'</b></p></div></body>';
|
||
|
|
|
||
|
|
|
||
|
|
// Write some HTML code:
|
||
|
|
$mpdf->WriteHTML($html);
|
||
|
|
|
||
|
|
// Output a PDF file directly to the browser
|
||
|
|
//$mpdf->Output();
|
||
|
|
$mpdf->Output('Constancia.pdf', 'I') ;
|
||
|
|
|
||
|
|
?>
|