You are not logged in.
Pages: 1
hello im making some changes in print to pdf plugin by Remi Collet, Nelly Mahu, and i have to show the name of the user and the only way to get this data is through the db, i saw the documentation but when i try to print my ticket into the pdf the page just crash but if i delete the query code it works but dont show me the user data that i need . I want to know where im wrong if someone could help me will be grateful thanks
this is my query function code:
function getuserDataDB($user_id)
{
global $DB;
$iterator = $DB->request([
'FROM' => 'glpi_users',
'WHERE' => ['id' => $user_id]
]);
$admins = [];
while ($row = $iterator->next()) {
$admins[] = [
'nombre' => $row['firstname'] ." ". $row['realname']
];
}
$regisnum=$admins[0][nombre];
return $regisnum;
}
and this the function where i call the query function:
static function pdfMain(PluginPdfSimplePDF $pdf, Ticket $job) {
$dbu = new DbUtils();
$infouser = isset($_REQUEST['item']['_inforequester_']);
$Id_user = $job->getField('id');
$titulo = $job->getfield('name');
$descripcion = $job->getfield('content');
$recepcion = $job->getfield('users_id_recipient');
$fechacreacion = $job->getfield('date');
$reception = $job->getfield('users_id_recipient');
$user = getuserDataDB($Id_user);
if (!$job->can($ID, READ)) {
return false;
}
// Establece el tamaño de la columna al 100% del ancho disponible
$pdf->setColumnsSize(100);
$pdf->displaySpace(0.2);
// Añade el número de ticket
$ticketNumber = $job->fields['id'];
$pdf->displayTitle("<h2><b>No. Ticket: $ID</b></h2>");
// Añade el asunto
$asunto = $job->fields['name'];
$pdf->displayTitle("<h3>$asunto</h3>");
$pdf->displaySpace(0.5);
// Añade la fecha de apertura
$date_creation = Html::convDateTime($job->fields['date']);
$pdf->displayTitle("<b>Fecha de Apertura:</b> $date_creation");
$pdf->displaySpace(0.2);
// Añade la descripción
$descripcion = $job->fields['content'];
$pdf->displayText("", $descripcion);
$pdf->displayLine("========================");
$pdf->displayTitle("<b>Recive:</b>");
$pdf->displayTitle($user);
}
Offline
Check your GLPI logs in the files/_log folder.
GLPI Collaborator and Plugin Developer.
My non-English comments are automated translations. Sorry for any confusion that causes.
Mes commentaires non anglais sont des traductions automatiques. Désolé pour toute confusion qui cause.
Mis comentarios que no están en inglés son traducciones automáticas. Perdón por cualquier confusión que cause.
Offline
Pages: 1