Skip to content

Commit

Permalink
#27 [Admin] fix: move generate_ticket_categories in admin tools
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolas-eoxia committed Jul 23, 2024
1 parent 9290f5e commit 03fbc7f
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 18 deletions.
48 changes: 48 additions & 0 deletions admin/setup.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,21 @@
exit;
}

if ($action == 'generate_ticket_categories' && isModEnabled('categorie')) {
$tagParentID = saturne_create_category($langs->transnoentities('GMAO'), 'ticket', 0, 'pictogram_GMAO_64px.png');

saturne_create_category($langs->transnoentities('Preventive'), 'ticket', $tagParentID, 'pictogram_Preventive_64px.png');
saturne_create_category($langs->transnoentities('Curative'), 'ticket', $tagParentID, 'pictogram_Curative_64px.png');
saturne_create_category($langs->transnoentities('Improvement'), 'ticket', $tagParentID, 'pictogram_Improvement_64px.png');

dolibarr_set_const($db, 'GMAO_TICKET_MAIN_CATEGORY', $tagParentID, 'integer', 0, '', $conf->entity);
dolibarr_set_const($db, 'GMAO_TICKET_CATEGORIES_SET', 1, 'integer', 0, '', $conf->entity);

setEventMessage('SavedConfig');
header('Location: ' . $_SERVER['PHP_SELF']);
exit;
}

/*
* View
*/
Expand Down Expand Up @@ -117,6 +132,39 @@
];
require __DIR__ . '/../../saturne/core/tpl/admin/object/object_const_view.tpl.php';

// Generate categories
print load_fiche_titre($langs->trans('ConfigGMAOTicketCategories'), '', '');

print '<form method="POST" action="' . $_SERVER['PHP_SELF'] . '">';
print '<input type="hidden" name="token" value="' . newToken() . '">';
print '<input type="hidden" name="action" value="generate_ticket_categories">';

print '<table class="noborder centpercent">';
print '<tr class="liste_titre">';
print '<td>' . $langs->trans('Name') . '</td>';
print '<td class="center">' . $langs->trans('Status') . '</td>';
print '<td class="center">' . $langs->trans('Action') . '</td>';
print '<td class="center">' . $langs->trans('ShortInfo') . '</td>';
print '</tr>';

if (!isModEnabled('categorie')) {
print '<tr><td>' . $langs->trans('GenerateGMAOTicketCategories') . '</td>';
print '<td class="center">';
print getDolGlobalInt('GMAO_TICKET_CATEGORIES_SET') ? $langs->trans('AlreadyGenerated') : $langs->trans('NotCreated');
print '</td>';
print '<td class="center">';
print getDolGlobalInt('GMAO_TICKET_CATEGORIES_SET') ? '<a class="butActionRefused">' . $langs->trans('Create') . '</a>' : '<input type="submit" class="button" value="' . $langs->trans('Create') . '">';
print '</td>';
print '<td class="center">';
print $form->textwithpicto('', $langs->trans('GenerateGMAOTicketCategoriesDescription'));
print '</td></tr>';
} else {
print '<tr><td colspan="4">' . $langs->trans('EnableCategory') . '</td></tr>';
}

print '</table>';
print '</form>';

// Page end
print dol_get_fiche_end();
$db->close();
Expand Down
13 changes: 1 addition & 12 deletions core/modules/modGMAO.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ public function __construct($db)
$this->hidden = false;

// List of module class names as string that must be enabled if this module is enabled. Example: array('always1'=>'modModuleToEnable1','always2'=>'modModuleToEnable2', 'FR1'=>'modModuleToEnableFR'...)
$this->depends = ['modSociete', 'modService', 'modProjet', 'modPropale', 'modTicket', 'modSaturne'];
$this->depends = ['modSociete', 'modService', 'modProjet', 'modPropale', 'modTicket', 'modSaturne', 'modCategorie'];
$this->requiredby = []; // List of module class names as string to disable if this one is disabled. Example: array('modModuleToDisable1', ...)
$this->conflictwith = []; // List of module class names as string this module is in conflict with. Example: array('modModuleToDisable1', ...)

Expand Down Expand Up @@ -284,17 +284,6 @@ public function init($options = ''): int

addDocumentModel('gmaoticketdocument_odt', 'gmaoticketdocument', 'ODT templates', 'GMAO_GMAOTICKETDOCUMENT_ADDON_ODT_PATH');

if (getDolGlobalInt('GMAO_TICKET_MAIN_CATEGORIES_SET') == 0) {
$tagParentID = saturne_create_category($langs->transnoentities('GMAO'), 'ticket', 0, 'pictogram_GMAO_64px.png');

saturne_create_category($langs->transnoentities('Preventive'), 'ticket', $tagParentID, 'pictogram_Preventive_64px.png');
saturne_create_category($langs->transnoentities('Curative'), 'ticket', $tagParentID, 'pictogram_Curative_64px.png');
saturne_create_category($langs->transnoentities('Improvement'), 'ticket', $tagParentID, 'pictogram_Improvement_64px.png');

dolibarr_set_const($db, 'GMAO_TICKET_MAIN_CATEGORY', $tagParentID, 'integer', 0, '', $conf->entity);
dolibarr_set_const($db, 'GMAO_TICKET_MAIN_CATEGORIES_SET', 1, 'integer', 0, '', $conf->entity);
}

return $this->_init($sql, $options);
}

Expand Down
16 changes: 10 additions & 6 deletions langs/fr_FR/gmao.lang
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ ModuleGMAOName = GMAO
ModuleGMAODesc = Gestion de maintenance au travers des tickets
GMAODescription = Gestion de maintenance au travers des tickets
GMAODescriptionLong = Gestion de maintenance au travers des tickets
EnableGmao = Veuillez activer le module GMAO pour accéder à cette page

# Tags - Catégories
Preventive = Préventive
Expand All @@ -35,12 +36,15 @@ Improvement = Amélioration
#

# Setup - Réglages
ProposalService = Service de la proposition commerciale GMAO
EnableTicketProposal = Activer la création d'une proposition commerciale depuis un ticket
EnableTicketProposalDescription = Cette option permet de créer une proposition commerciale depuis un ticket en récupérant le tiers et le projet associé au ticket
EnableTicketProposalGMAO = Activer la création d'une proposition commerciale de maintenance depuis un ticket
EnableTicketProposalGMAODescription = Cette option permet de créer une proposition commerciale depuis un ticket en récupérant le tiers et le projet associé au ticket.<br>De plus, si l'option du service de la proposition commerciale est configurée, elle va ajouter une ligne de service directement sur la proposition.

ProposalService = Service de la proposition commerciale GMAO
EnableTicketProposal = Activer la création d'une proposition commerciale depuis un ticket
EnableTicketProposalDescription = Cette option permet de créer une proposition commerciale depuis un ticket en récupérant le tiers et le projet associé au ticket
EnableTicketProposalGMAO = Activer la création d'une proposition commerciale de maintenance depuis un ticket
EnableTicketProposalGMAODescription = Cette option permet de créer une proposition commerciale depuis un ticket en récupérant le tiers et le projet associé au ticket.<br>De plus, si l'option du service de la proposition commerciale est configurée, elle va ajouter une ligne de service directement sur la proposition.
ConfigGMAOTicketCategories = Configurations des catégories tickets GMAO
GenerateGMAOTicketCategories = Génération des catégories de ticket GMAO par défaut
GenerateGMAOTicketCategoriesDescription = Cette option permet la génération des catégories par défaut des tickets. Les catégories créées seront : <br> - GMAO <br> - - Préventive, Curative, Amélioration
EnableCategory = Veuillez activer le module Category pour accéder à cette fonctionnalité


#
Expand Down

0 comments on commit 03fbc7f

Please sign in to comment.