Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[GLPI 10.0.11] Pb lors ajout automatique du technicien lors d'un suivi #95

Open
Aurelien5135 opened this issue Jan 19, 2024 · 10 comments
Open
Assignees
Labels
bug Something isn't working
Milestone

Comments

@Aurelien5135
Copy link

Bonjour,

nous avons activer l'option "Ajout du technicien connecté à l'ajout d'un suivi", et depuis le passage en GLPI 10.0.11, lors de l'ajout de suivi nous avons une erreur 500.
Par contre nous avons aussi activer l'option "Ajout du technicien connecté à la résolution/clôture d'un ticket" et tout fonctionne sans message d'erreur.

j'ai l'impression (sans aucune certitude) que le problème vient de "itilfollowup.class.php" à la ligne 50 "if ($ticket_user->fields['users_id'] <> Session::getLoginUserID())"

GLPI : 10.0.11
Behaviors : 2.7.3

yllen added a commit that referenced this issue Mar 6, 2024
@yllen yllen self-assigned this Mar 6, 2024
@yllen yllen added the bug Something isn't working label Mar 6, 2024
@Aurelien5135
Copy link
Author

Bonjour,
Suite à l'ajout de la modif, je n'ai plus l'erreur 500 mais le technicien ne s'ajoute pas en automatique.
J'ai bien l'option "Ajout du technicien connecté à l'ajout d'un suivi" à "oui"

@yllen yllen added this to the 2.7.4 milestone Apr 16, 2024
@yllen
Copy link
Owner

yllen commented Apr 16, 2024

Je viens de refaire des tests et je n'arrive pas à reproduire ; pour moi le technicien est bien ajouté après la validation du ticket.
Avez-vous bien vérifié que la personne connectée à les droits d'être en charge d'un ticket ?

@Aurelien5135
Copy link
Author

Bonjour,
j'ai essaye de changer de version de glpi en installant 10.0.17 et j'ai toujours le même problème.
le technicien ne s'ajoute pas automatique à la validation d'un suivi lorsque que le ticket est en statut "nouveau"

infos complémentaire (au cas ou), j'utilise aussi le plugin Form Creator
je n'ai aucun message d'erreurs dans les logs.

je ne trouve pas de solution, au moins je n'ai plus le message d'erreur.

merci

@jbtele29
Copy link

jbtele29 commented Dec 30, 2024

Bonjour,

J'avais le même soucis avec glpi 10.017 mais j'ai remis le fichier inc/itilfollowup.class.php comme avant le commit 5d21ecf
avec cette ligne seulement
if ($ticket_user->fields['users_id'] <> Session::getLoginUserID()) {

Maintenant j'ai mon user qui est bien ajouté sur le suivi du ticket.

Edit: je pense que j'ai toujours le problème
dans le fichier php-errors j'ai ça encore

glpiphplog.WARNING:   *** PHP Warning (2): Undefined array key "users_id" in /var/www/html/glpi/marketplace/behaviors/inc/itilfollowup.class.php at line 50
  Backtrace :
  src/Plugin.php:1713                                PluginBehaviorsITILFollowup::beforeAdd()
  src/CommonDBTM.php:1301                            Plugin::doHook()
  front/itilfollowup.form.php:58                     CommonDBTM->add()
  public/index.php:82                                require() 

Merci

@Aurelien5135
Copy link
Author

bonjour,
merci de votre réponse.

en ajoutant son correctif, je n'ai plus l'erreur mais l'ajout du tech ne s'effectue pas.
nous avons les droits de prendre en charge le ticket, nous effectuons manuellement (petit bonhomme ou le nom dans le champs puis sauvegarde).

lorsque je n'ai pas le correctif, j'ai l'erreur 500 et dans les logs
[2025-01-06 21:27:51] glpiphplog.WARNING: *** PHP Warning (2): Undefined array key "groups_id" in J:\appli\glpi\10.0.16\plugins\behaviors\inc\itilfollowup.class.php at line 55
Backtrace :
src\Plugin.php:1713 PluginBehaviorsITILFollowup::beforeAdd()
src\CommonDBTM.php:1294 Plugin::doHook()
front\itilfollowup.form.php:58 CommonDBTM->add()

[2025-01-06 21:34:06] glpiphplog.WARNING: *** PHP Warning (2): Undefined array key "groups_id" in J:\appli\glpi\10.0.16\plugins\behaviors\inc\itilfollowup.class.php at line 56
Backtrace :
src\Plugin.php:1713 PluginBehaviorsITILFollowup::beforeAdd()
src\CommonDBTM.php:1294 Plugin::doHook()
front\itilfollowup.form.php:58 CommonDBTM->add()

@jbtele29
Copy link

jbtele29 commented Jan 7, 2025

Bonjour,

Au final j'ai mis ça dans le fichier itilfollowup.class.php et je n'ai plus l'erreur et le technicien s'ajoute bien sur les nouveaux tickets

            if (!isset($ticket_user->fields['users_id']) 
                || $ticket_user->fields['users_id'] <> Session::getLoginUserID()) {

Merci

@Aurelien5135
Copy link
Author

merci, avec la modif ci dessus, je n'ai plus le message d'erreur sur le user_id mais j'ai toujours le message d'erreur sur le group_id

glpiphplog.WARNING: *** PHP Warning (2): Undefined array key "groups_id"
Backtrace :
src\Plugin.php:1713 PluginBehaviorsITILFollowup::beforeAdd()
src\CommonDBTM.php:1294 Plugin::doHook()
front\itilfollowup.form.php:58 CommonDBTM->add()

@jbtele29
Copy link

jbtele29 commented Jan 7, 2025

Bonjour,

J'ai ça dans mon fichier et ensuite j'ai download l'archive master du repo et j'ai modifié mon setup.php aussi

class PluginBehaviorsITILFollowup {

   static function beforeAdd(ITILFollowup $fup) {

      $ticket = new Ticket();
      $config = PluginBehaviorsConfig::getInstance();

      if ($ticket->getFromDB($fup->input['items_id'])
         && $fup->input['itemtype'] == 'Ticket') {

         if ($config->getField('addfup_updatetech')
             && Session::haveRight('ticket', UPDATE)) {

            $ticket_user = new Ticket_User();
            $ticket_user->getFromDBByCrit(['tickets_id' => $ticket->getID(),
                                           'type'       => CommonITILActor::ASSIGN]);

            if (!isset($ticket_user->fields['users_id']) 
                || $ticket_user->fields['users_id'] <> Session::getLoginUserID()) {
               $group_ticket = new Group_Ticket();
               $group_ticket->getFromDBByCrit(['tickets_id' => $ticket->getID(),
                                               'type'       => CommonITILActor::ASSIGN]);
               $usergroup = Group_User::getGroupUsers($group_ticket->fields['groups_id']);
               $users = [];
               foreach ($usergroup as $user) {
                  $users[$user['id']] = $user['id'];
               }
               if (!in_array(Session::getLoginUserID(), $users)) {
                  $ticket_user = new Ticket_User();
                  $ticket_user->add(['tickets_id' => $ticket->getID(),
                                     'users_id'   => Session::getLoginUserID(),
                                     'type'       => CommonITILActor::ASSIGN]);
               }
            }
         }
      }
   }
}

setup.php

<?php
/**
 -------------------------------------------------------------------------

 LICENSE

 This file is part of Behaviors plugin for GLPI.

 Behaviors is free software: you can redistribute it and/or modify
 it under the terms of the GNU Affero General Public License as published by
 the Free Software Foundation, either version 3 of the License, or
 (at your option) any later version.

 Behaviors is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 GNU Affero General Public License for more details.

 You should have received a copy of the GNU Affero General Public License
 along with Behaviors. If not, see <http://www.gnu.org/licenses/>.

 @package   behaviors
 @author    Remi Collet, Nelly Mahu-Lasson
 @copyright Copyright (c) 2010-2023 Behaviors plugin team
 @license   AGPL License 3.0 or (at your option) any later version
            http://www.gnu.org/licenses/agpl-3.0-standalone.html
 @link      https://forge.glpi-project.org/projects/behaviors
 @link      http://www.glpi-project.org/
 @since     2010

 --------------------------------------------------------------------------
 */

// Init the hooks of the plugins -Needed
function plugin_init_behaviors() {
   global $PLUGIN_HOOKS, $CFG_GLPI;

   Plugin::registerClass('PluginBehaviorsConfig', ['addtabon' => 'Config']);
   $PLUGIN_HOOKS['config_page']['behaviors'] = 'front/config.form.php';

   $PLUGIN_HOOKS['item_add']['behaviors'] =
      ['Ticket_User'        => ['PluginBehaviorsTicket_User',       'afterAdd'],
       'Group_Ticket'       => ['PluginBehaviorsGroup_Ticket',      'afterAdd'],
       'Supplier_Ticket'    => ['PluginBehaviorsSupplier_Ticket',   'afterAdd'],
       'Document_Item'      => ['PluginBehaviorsDocument_Item',     'afterAdd'],
       'ITILFollowup'       => ['PluginBehaviorsITILFollowup',      'afterAdd']];

   $PLUGIN_HOOKS['item_update']['behaviors'] =
      ['Ticket'             => ['PluginBehaviorsTicket',            'afterUpdate']];

   $PLUGIN_HOOKS['pre_item_add']['behaviors'] =
      ['Ticket'             => ['PluginBehaviorsTicket',            'beforeAdd'],
       'ITILSolution'       => ['PluginBehaviorsITILSolution',      'beforeAdd'],
       'TicketTask'         => ['PluginBehaviorsTickettask',        'beforeAdd'],
       'Change'             => ['PluginBehaviorsChange',            'beforeAdd'],
       'ITILFollowup'       => ['PluginBehaviorsITILFollowup',      'beforeAdd']];

   $PLUGIN_HOOKS['post_prepareadd']['behaviors'] =
      ['Ticket'             => ['PluginBehaviorsTicket',            'afterPrepareAdd']];

   $PLUGIN_HOOKS['pre_item_update']['behaviors'] =
      ['Problem'            => ['PluginBehaviorsProblem',           'beforeUpdate'],
       'Ticket'             => ['PluginBehaviorsTicket',            'beforeUpdate'],
       'Change'             => ['PluginBehaviorsChange',            'beforeUpdate'],
       'ITILSolution'       => ['PluginBehaviorsITILSolution',      'beforeUpdate'],
       'TicketTask'         => ['PluginBehaviorsTickettask',        'beforeUpdate'],
       'ChangeTask'         => ['PluginBehaviorsChangetask',        'beforeUpdate'],
       'ProblemTask'        => ['PluginBehaviorsProblemtask',       'beforeUpdate']];

   $PLUGIN_HOOKS['pre_item_purge']['behaviors'] =
      ['Computer'           => ['PluginBehaviorsComputer',          'beforePurge']];

   $PLUGIN_HOOKS['item_purge']['behaviors'] =
      ['Document_Item'      => ['PluginBehaviorsDocument_Item',     'afterPurge']];

   // Notifications
   $PLUGIN_HOOKS['item_get_events']['behaviors'] =
      ['NotificationTargetTicket' => ['PluginBehaviorsTicket',      'addEvents']];

   $PLUGIN_HOOKS['item_add_targets']['behaviors'] =
      ['NotificationTargetTicket' => ['PluginBehaviorsTicket',      'addTargets']];

   $PLUGIN_HOOKS['item_action_targets']['behaviors'] =
      ['NotificationTargetTicket' => ['PluginBehaviorsTicket',      'addActionTargets']];

   $PLUGIN_HOOKS['pre_item_form']['behaviors'] = [PluginBehaviorsCommon::class, 'messageWarning'];
   $PLUGIN_HOOKS['post_item_form']['behaviors'] = [PluginBehaviorsCommon::class, 'deleteAddSolutionButton'];

   // End init, when all types are registered
   $PLUGIN_HOOKS['post_init']['behaviors'] = ['PluginBehaviorsCommon', 'postInit'];

   $PLUGIN_HOOKS['csrf_compliant']['behaviors'] = true;

   foreach ($CFG_GLPI["asset_types"] as $type) {
      $PLUGIN_HOOKS['item_can']['behaviors'][$type] = [$type => ['PluginBehaviorsConfig', 'item_can']];
   }

   $PLUGIN_HOOKS['add_default_where']['behaviors'] = ['PluginBehaviorsConfig', 'add_default_where'];

}


function plugin_version_behaviors() {

   return ['name'           => __('Behaviours', 'behaviors'),
           'version'        => '2.7.3',
           'license'        => 'AGPLv3+',
           'author'         => 'Remi Collet, Nelly Mahu-Lasson',
           'homepage'       => 'https://github.com/yllen/behaviors',
           'minGlpiVersion' => '10.0.5',
           'requirements'   => ['glpi' => ['min' => '10.0.5',
                                           'max' => '10.1.0']]];
}

// Check configuration process for plugin : need to return true if succeeded
// Can display a message only if failure and $verbose is true
function plugin_behaviors_check_config($verbose=false) {
   return true;
}

Merci

@Aurelien5135
Copy link
Author

je n'avais pas modifié le setup.php
le problème reste identique sur groups_id.
merci de tes réponses, je vais continuer à chercher.

glpiphplog.WARNING: *** PHP Warning (2): Undefined array key "groups_id" in J:\appli\glpi\10.0.16\plugins\behaviors\inc\itilfollowup.class.php at line 56
Backtrace :
src\Plugin.php:1713 PluginBehaviorsITILFollowup::beforeAdd()
src\CommonDBTM.php:1294 Plugin::doHook()
front\itilfollowup.form.php:58 CommonDBTM->add()

@Aurelien5135
Copy link
Author

j'ai réussi à rendre fonctionnel en mettant en commantaire la partie liée "groups_id" dans itilfollowup.class.php
Bonne journée

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants