yllen / pdf

GNU Affero General Public License v3.0
14 stars 14 forks source link

Include fields plugin with values #48

Closed miguelanruiz closed 10 months ago

miguelanruiz commented 12 months ago

Hi there,

I noticed that the additionalfields related to equipment aren't currently being included in the reports.

It would be immensely beneficial for community and potentially other users if these fields could be incorporated into the report generation. The additionalfields provide critical context and data that would enhance the quality and comprehensiveness of the reports.

I understand that there are various considerations when updating functionalities, and I'd be happy to provide further details or examples if needed.

Thank you for your continuous efforts and dedication to improving the tool. I appreciate any consideration you can give to this request.

miguelanruiz commented 12 months ago

PR https://github.com/yllen/pdf/pull/49

yllen commented 10 months ago

I can't manage all others plugins. Each plugin must define what it wants to display in PDF, the plugin allow it.

How to do in Fields plugin: in setup add

$PLUGIN_HOOKS['plugin_pdf']['PluginFields] = 'NameOfYourClassPDF';

in inc/NameOfYourClassPDF

`class PluginGeststockReservationPDF extends PluginPdfCommon {

function __construct(CommonGLPI $obj=NULL) {

  $this->obj = ($obj ? $obj : new PluginFieldsClassYouWantToDisplay());

}

function defineAllTabsPDF($options=[]) {

  $onglets = parent::defineAllTabs($options);
  return $onglets;

}

static function displayTabContentForPDF(PluginPdfSimplePDF $pdf, CommonGLPI $item, $tab) {

  switch ($tab) {
     case 'nameItemDisplayedByGLPI'  (normally PluginFieldsClassYouWantToDisplay$main' :
        fonctionToCall(;
        break;

     case 'nameItemDisplayedByGLPI' :
        functionToCall;
        break;

     default :
        return false;
  }
  return true;

} }`

To help you: https://github.com/yllen/geststock