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

#3984 [Conf] add: external & shortcut url #4051

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 71 additions & 1 deletion admin/ticket/ticket.php
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,28 @@
exit;
}

if ($action == 'setExternalRedirectionUrl') {
$externalRedirectionUrl = GETPOST('externalRedirectionUrl', 'none');
dolibarr_set_const($db, 'DIGIRISKDOLIBARR_TICKET_CREATION_EXTERNAL_REDIRECTION_URL', $externalRedirectionUrl, 'chaine', 0, '', $conf->entity);

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

if ($action == 'setTicketCreationOption') {
$ticketCreationOption = GETPOST('ticketCreationOption', 'alpha');
dolibarr_set_const($db, 'DIGIRISKDOLIBARR_TICKET_CREATION_OPTION', $ticketCreationOption, 'chaine', 0, '', $conf->entity);

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

if ($action == 'generateShortcutUrl') {
// @todo generate shortcut url
}

/*
* View
*/
Expand All @@ -308,7 +330,55 @@
print '<hr>';
print load_fiche_titre($langs->transnoentities("PublicInterface"), '', '');

print '<span class="opacitymedium">' . $langs->transnoentities("DigiriskTicketPublicAccess") . '</span> : <a class="wordbreak" href="' . dol_buildpath('/custom/digiriskdolibarr/public/ticket/create_ticket.php?entity=' . $conf->entity, 1) . '" target="_blank" >' . dol_buildpath('/custom/digiriskdolibarr/public/ticket/create_ticket.php?entity=' . $conf->entity, 2) . '</a>';
print '<span class="opacitymedium">' . $langs->transnoentities("DigiriskTicketPublicAccess") . ' : </span>';

print '<br/><br/>';

print '<table class="noborder">';
print '<tr class="liste_titre">';
print '<td></td>';
print '<td>' . $langs->transnoentities("Option") . '</td>';
print '<td>' . $langs->transnoentities("Value") . '</td>';
print '<td>' . $langs->transnoentities("Action") . '</td>';
print '</tr>';

print '<tr class="oddeven">';
print '<td><input type="radio" name="ticketCreationOption" value="default_redirection_url"' . (getDolGlobalString('DIGIRISKDOLIBARR_TICKET_CREATION_OPTION') == 'default_redirection_url' ? 'checked="checked"' : '') . '/></td>';
print '<td><span class="opacitymedium">' . $langs->trans('TicketCreationDefaultURL') . '</span></td>';
print '<td><a class="wordbreak" href="' . dol_buildpath('/custom/digiriskdolibarr/public/ticket/create_ticket.php?entity=' . $conf->entity, 1) . '" target="_blank" >' . dol_buildpath('/custom/digiriskdolibarr/public/ticket/create_ticket.php?entity=' . $conf->entity, 2) . '</a></td>';
print '<td></td>';
print '</tr>';

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

print '<tr class="oddeven">';
print '<td><input type="radio" name="ticketCreationOption" value="external_redirection_url"' . (getDolGlobalString('DIGIRISKDOLIBARR_TICKET_CREATION_OPTION') == 'external_redirection_url' ? 'checked="checked"' : '') . '/></td>';
print '<td><span class="opacitymedium">' . $langs->trans('TicketCreationExternalURL') . '</span></td>';
print '<td><input class="centpercent" type="text" name="externalRedirectionUrl" value="' . getDolGlobalString('DIGIRISKDOLIBARR_TICKET_CREATION_EXTERNAL_REDIRECTION_URL') . '"></td>';
print '<td><input type="submit" class="button reposition" value="'. $langs->transnoentities('Save') . '"></td>';
print '</tr>';

print '</form>';

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

print '<tr class="oddeven">';
print '<td><input type="radio" name="ticketCreationOption" value="shortcut_redirection_url"' . (getDolGlobalString('DIGIRISKDOLIBARR_TICKET_CREATION_OPTION') == 'shortcut_redirection_url' ? 'checked="checked"' : '') . '/></td>';
print '<td><span class="opacitymedium">' . $langs->trans('TicketCreationShortcutURL') . '</span></td>';
print '<td></td>'; // @todo display shortcut url
print '<td><input type="submit" class="button reposition" value="'. $langs->transnoentities('Generate') . '"></td>';
print '</tr>';

print '</form>';

print '</table>';


if (isModEnabled('multicompany')) {
print load_fiche_titre($langs->transnoentities("MultiEntityPublicInterface"), '', '');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,19 @@ public function write_file(SaturneDocuments $objectDocument, Translate $outputLa
$userTmp->fetch($responsibleResources->id[0]);

// @todo The keyword "signature" is needed because we want the image to be cropped to fit in the table
$tmpArray['helpUrl'] = DOL_MAIN_URL_ROOT . '/custom/digiriskdolibarr/public/ticket/create_ticket.php';
$ticketCreationOption = dolibarr_get_const($this->db, 'DIGIRISKDOLIBARR_TICKET_CREATION_OPTION', $conf->entity);
switch ($ticketCreationOption) {
case 'default_redirection_url':
$tmpArray['helpUrl'] = DOL_MAIN_URL_ROOT . '/custom/digiriskdolibarr/public/ticket/create_ticket.php';
break;
case 'external_redirection_url':
$tmpArray['helpUrl'] = dolibarr_get_const($this->db, 'DIGIRISKDOLIBARR_TICKET_CREATION_EXTERNAL_REDIRECTION_URL', $conf->entity);
break;
case 'shortcut_redirection_url':
// @todo Add the shortcut url
break;
}

$tmpArray['signatureQRCodeTicket'] = $QRCodeImagePath;
$tmpArray['securityResponsible'] = (!empty($userTmp) ? dol_strtoupper($userTmp->lastname) . ' ' . ucfirst($userTmp->firstname) : '');

Expand Down
2 changes: 2 additions & 0 deletions core/modules/modDigiriskDolibarr.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -776,6 +776,8 @@ public function __construct($db)
$i++ => ['DIGIRISKDOLIBARR_TICKET_DATE_VISIBLE', 'integer', 1, '', 0, 'current'],
$i++ => ['DIGIRISKDOLIBARR_TICKET_DATE_REQUIRED', 'integer', 1, '', 0, 'current'],
$i++ => ['DIGIRISKDOLIBARR_TICKET_STATISTICS_ACCIDENT_TIME_RANGE', 'chaine', '{"'. $langs->transnoentities("WithoutWorkStop") .'":"less:1:days", "'. $langs->transnoentities("LessThanFourDays") .'":"less:4:days","'. $langs->transnoentities("LessThanTwentyOneDays") .'":"less:21:days","'. $langs->transnoentities("LessThanThreeMonth") .'":"less:3:months","'. $langs->transnoentities("LessThanSixMonths") .'":"less:6:months","'. $langs->transnoentities("LongTimeWorkStop") .'":"more:6:months"}', '', 0, 'current'],
$i++ => ['DIGIRISKDOLIBARR_TICKET_CREATION_EXTERNAL_REDIRECTION_URL', 'chaine', '', '', 0, 'current'],
$i++ => ['DIGIRISKDOLIBARR_TICKET_CREATION_OPTION', 'chaine', 'default_redirection_link', '', 0, 'current'],

// CONST MODULE
$i++ => ['DIGIRISKDOLIBARR_SUBPERMCATEGORY_FOR_DOCUMENTS', 'integer', 1, '', 0, 'current'],
Expand Down
2 changes: 1 addition & 1 deletion js/digiriskdolibarr.min.js

Large diffs are not rendered by default.

16 changes: 16 additions & 0 deletions js/modules/ticket.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ window.digiriskdolibarr.ticket.event = function() {
$( document ).on( 'click', '.close-dashboard-info', window.digiriskdolibarr.ticket.closeDashBoardTicketInfo );
$( document ).on( 'keyup', '.email', window.digiriskdolibarr.ticket.checkValidEmail );
$( document ).on( 'keyup', '.options_digiriskdolibarr_ticket_phone', window.digiriskdolibarr.ticket.checkValidPhone );
$( document ).on( 'click', 'input[name="ticketCreationOption"]', window.digiriskdolibarr.ticket.toggleTicketCreationOption );
};

/**
Expand Down Expand Up @@ -270,3 +271,18 @@ window.digiriskdolibarr.ticket.checkValidPhone = function() {
$(this).css("border", "3px solid green");
}
};

/**
* Toggle ticket creation option
*
* @since 10.3.0
* @version 10.3.0
*
* @return {void}
*/
window.digiriskdolibarr.ticket.toggleTicketCreationOption = function() {
let token = window.saturne.toolbox.getToken()
let querySeparator = window.saturne.toolbox.getQuerySeparator(document.URL)

window.location.href = document.URL + querySeparator + 'action=setTicketCreationOption&token=' + token + '&ticketCreationOption=' + $(this).val()
};
3 changes: 3 additions & 0 deletions langs/fr_FR/digiriskdolibarr.lang
Original file line number Diff line number Diff line change
Expand Up @@ -1353,6 +1353,9 @@ FkTicket = Ticket lié
PublicTicket = Interface publique des tickets
TicketPublicInterfaceForbidden = Accès interdit à l'interface publique des tickets
WHSRegister = Registre SST
TicketCreationDefaultURL = URL par défaut
TicketCreationExternalURL = URL externe
TicketCreationShortcutURL = URL raccourcie

# Stats - Statistiques
TicketStatistics = Statistiques des tickets
Expand Down