You are not logged in.

Announcement

 Téléchargez la dernière version stable de GLPI      -     Et vous, que pouvez vous faire pour le projet GLPI ? :  Contribuer
 Download last stable version of GLPI                      -     What can you do for GLPI ? :  Contribute

#1 2023-12-22 16:47:27

GLPIdev
Member
Registered: 2023-12-22
Posts: 1

Open Modal Window from a plugin option

Dears,

I read much much topics here and elsewhere, but didn't find any answer to my question.

I achieved to create each page with data i wanted.
Except that data appear in a new tab, whereas i would like to be appearing in the same tab in a modal window/popup where each link clicked in this window would load in the background window.

hook.php
function plugin_ETM_postinit() {
   global $CFG_GLPI, $PLUGIN_HOOKS;

   foreach ($PLUGIN_HOOKS['plugin_ETM'] as $type => $typeETM) {
      CommonGLPI::registerStandardTab($type, $typeETM);
   }
}


function plugin_ETM_MassiveActions($type) {
   global $PLUGIN_HOOKS;

   switch ($type) {
      default :
         if (isset($PLUGIN_HOOKS['plugin_ETM'][$type])) {
            return ['PluginETMCommon'.MassiveAction::CLASS_ACTION_SEPARATOR.'DoIt'
                     => __('Afficher le TM', 'ETM')];
         }
   }
   return [];
}


function plugin_ETM_install() {
   global $DB;

   $migration = new Migration('1.0.0');
   $DB->runFile(GLPI_ROOT . "/plugins/ETM/sql/empty-1.0.sql");

   include_once(Plugin::getPhpDir('ETM')."/inc/profile.class.php");



   return true;
}
in plugins/ETM/inc/common.class.php
 static function showMassiveActionsSubForm(MassiveAction $ma) {

      switch ($ma->getAction()) {
         case 'DoIt':
                $cont = $ma->POST['container'];
<...>
                echo Html::submit(_sx('button', 'Post'), $opt);
                return true;
      }
   }

   static function processMassiveActionsForOneItemtype(MassiveAction $ma, CommonDBTM $item,
                                                       array $ids) {
      global $DB;
      switch ($ma->getAction()) {
        case 'DoIt' :
            $input = $ma->getInput();
<...php page generation with data from $ids>
}

I tried some addings in $opt variable with different modal options as 'modal' => true, but nothing worked well.

Would anyone have an idea to open such a modal window in PHP through GLPI plugin ?

Thanks a lot for your help.

technical : GLPI 9.5.11 / Php 7.2

Last edited by GLPIdev (2023-12-22 16:53:58)

Offline

Board footer

Powered by FluxBB