La notification par e-mail du ticket est vide avec des champs personnalisés

Bonjour à tous,

J’ai installé le module ticket avec des champs personnalisés.

Le problème est que les champs personnalisés sont affichés comme «/custom» dans l’e-mail

Y a-t-il une solution ou un code php à ajouter pour le faire fonctionner correctement?

FYI: J’ai un programmeur et je suis prêt à le faire fonctionner, je ne sais pas par où commencer à propos de ce problème merci beaucoup pour tout le monde me disant où chercher…

Merci

Savez-vous quoi il faut faire ? Merci

J’ai trouvé le code responsable du problème;

Fichier: create_ticket.php

Emplacement: \dolibarr\htdocs\public\ticket

Ligne: 241

            // Send email to TICKET_NOTIFICATION_EMAIL_TO

            $sendto = $conf->global->TICKET_NOTIFICATION_EMAIL_TO;

            if ($sendto)
            {
                $subject = '[' . $conf->global->MAIN_INFO_SOCIETE_NOM . '] ' . $langs->transnoentities('TicketNewEmailSubjectAdmin');
                $message_admin = $langs->transnoentities('TicketNewEmailBodyAdmin', $object->track_id) . "\n\n";
                $message_admin .= '<ul><li>' . $langs->trans('Title') . ' : ' . $object->subject . '</li>';
                $message_admin .= '<li>' . $langs->trans('Type') . ' : ' . $object->type_label . '</li>';
                $message_admin .= '<li>' . $langs->trans('Category') . ' : ' . $object->category_label . '</li>';
                $message_admin .= '<li>' . $langs->trans('Severity') . ' : ' . $object->severity_label . '</li>';
                $message_admin .= '<li>' . $langs->trans('From') . ' : ' . $object->origin_email . '</li>';

                if (is_array($extrafields->attributes[$object->table_element]['label']))
                {
                	foreach($extrafields->attributes[$object->table_element]['label'] as $key => $val)
                	{
                		$enabled = 1;
                		if ($qualified && isset($extrafields->attributes[$object->table_element]['list'][$key]))
                		{
                			$enabled = dol_eval($extrafields->attributes[$object->table_element]['list'][$key], 1);
                		}
                		$perms = 1;
                		if ($perms && isset($extrafields->attributes[$object->table_element]['perms'][$key]))
                		{
                			$perms = dol_eval($extrafields->attributes[$object->table_element]['perms'][$key], 1);
                		}

                		$qualified=true;
                		if (empty($enabled) || $enabled == 2) $qualified = false;
                		if (empty($perms)) $qualified = false;
                		if ($qualified) $message_admin .= '<li>' . $langs->trans($key) . ' : ' . $value . '</li>';
                	}
                }

                $message_admin .= '</ul>';
                $message_admin .= '<p>' . $langs->trans('Message') . ' : <br>' . $object->message . '</p>';
                $message_admin .= '<p><a href="' . dol_buildpath('/ticket/card.php', 2) . '?track_id=' . $object->track_id . '">' . $langs->trans('SeeThisTicketIntomanagementInterface') . '</a></p>';

                $from = $conf->global->MAIN_INFO_SOCIETE_NOM . '<' . $conf->global->TICKET_NOTIFICATION_EMAIL_FROM . '>';
                $replyto = $from;

                $message_admin = dol_nl2br($message_admin);

                if (!empty($conf->global->TICKET_DISABLE_MAIL_AUTOCOPY_TO)) {
                    $old_MAIN_MAIL_AUTOCOPY_TO = $conf->global->MAIN_MAIL_AUTOCOPY_TO;
                    $conf->global->MAIN_MAIL_AUTOCOPY_TO = '';
                }
                include_once DOL_DOCUMENT_ROOT . '/core/class/CMailFile.class.php';
                $mailfile = new CMailFile($subject, $sendto, $from, $message_admin, $filepath, $mimetype, $filename, $sendtocc, '', $deliveryreceipt, -1);
                if ($mailfile->error || $mailfile->errors) {
                    setEventMessages($mailfile->error, $mailfile->errors, 'errors');
                } else {
                    $result = $mailfile->sendfile();
                }
                if (!empty($conf->global->TICKET_DISABLE_MAIL_AUTOCOPY_TO)) {
                    $conf->global->MAIN_MAIL_AUTOCOPY_TO = $old_MAIN_MAIL_AUTOCOPY_TO;
                }
            }
        }

The solution is the code bellow in file « dolibarr\www\dolibarr\htdocs\public\ticket\create_ticket.php »

Add the code bellow and edit to fit your need at line 258 and success ! :slight_smile:

`// Send email to TICKET_NOTIFICATION_EMAIL_TO

            $sendto = $conf->global->TICKET_NOTIFICATION_EMAIL_TO;

            if ($sendto)
            {
                $subject = '[' . $conf->global->MAIN_INFO_SOCIETE_NOM . '] ' . $langs->transnoentities('TicketNewEmailSubjectAdmin');
                $message_admin = $langs->transnoentities('TicketNewEmailBodyAdmin', $object->track_id) . "\n\n";
                $message_admin .= '<ul><li>' . $langs->trans('Title') . ' : ' . $object->subject . '</li>';
                $message_admin .= '<li>' . $langs->trans('Type') . ' : ' . $object->type_label . '</li>';
                $message_admin .= '<li>' . $langs->trans('Category') . ' : ' . $object->category_label . '</li>';
                $message_admin .= '<li>' . $langs->trans('Severity') . ' : ' . $object->severity_label . '</li>';
                $message_admin .= '<li>' . $langs->trans('From') . ' : ' . $object->origin_email . '</li>';
				
				
				//SOLUTION
				$conn = mysqli_connect(localhost,dbuser,password,dbname);
				
				$querry = 'SELECT * FROM llx_ticket_extrafields WHERE fk_object = '. $id;
				$resultat = mysqli_query($conn,$querry);
				
				if ($resultat->num_rows > 0) {
					// output data of each row
					while($row = $resultat->fetch_assoc()) {
						 $message_admin .= "<li>Nom : ". $row['nom'] . "</li><li>Entreprise : ". $row['entreprise'] . "</li><li>Téléphone : ". $row['telephone'] . "</li><li>Poste : ". $row['poste']. "</li>";
					}
				}







                if (is_array($extrafields->attributes[$object->table_element]['label']))
                {
                	foreach($extrafields->attributes[$object->table_element]['label'] as $key => $val)
					{
               		$enabled = 1;
                		if ($qualified && isset($extrafields->attributes[$object->table_element]['list'][$key]))
                		{
              			$enabled = dol_eval($extrafields->attributes[$object->table_element]['list'][$key], 1);
                 		}
                 		$perms = 1;
                 		if ($perms && isset($extrafields->attributes[$object->table_element]['perms'][$key]))
                 		{
                			$perms = dol_eval($extrafields->attributes[$object->table_element]['perms'][$key], 1);
                		}

                		$qualified=true;
                		if (empty($enabled) || $enabled == 2) $qualified = false;
                		if (empty($perms)) $qualified = false;
                		if ($qualified) $message_admin .= '';
						// original = if ($qualified) $message_admin .= '<li>' . $langs->trans($key) . ' : ' . $value . '</li>';
                	}
                }

`