Skip to content

Commit

Permalink
Evarisk#3984 [Conf] remove js + use multiple forms
Browse files Browse the repository at this point in the history
  • Loading branch information
evarisk-francois committed Aug 30, 2024
1 parent 95fc818 commit 91d80cb
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 38 deletions.
48 changes: 27 additions & 21 deletions admin/ticket/ticket.php
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@
exit;
}

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

Expand All @@ -294,7 +294,7 @@
exit;
}

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

Expand All @@ -303,7 +303,7 @@
exit;
}

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

Expand Down Expand Up @@ -343,40 +343,46 @@
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><form method="POST" action="' . $_SERVER['PHP_SELF'] . '">';
print '<input type="hidden" name="token" value="' . newToken() . '">';
print '<input type="hidden" name="action" value="set_ticket_creation_option">';
print '<input type="hidden" name="page_y">';
print '<input type="radio" name="ticketCreationOption" value="default_redirection_url"' . (getDolGlobalString('DIGIRISKDOLIBARR_TICKET_CREATION_OPTION') == 'default_redirection_url' ? 'checked="checked"' : '') . ' onchange="this.form.submit()"/>';
print '</form></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 '<tr class="oddeven">';
print '<td><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="action" value="set_ticket_creation_option">';
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 '<input type="radio" name="ticketCreationOption" value="external_redirection_url"' . (getDolGlobalString('DIGIRISKDOLIBARR_TICKET_CREATION_OPTION') == 'external_redirection_url' ? 'checked="checked"' : '') . ' onchange="this.form.submit()"/>';
print '</form></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 '<td><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="action" value="set_external_redirection_url">';
print '<input type="hidden" name="page_y">';
print '<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') . '">';
print '</form></td>';
print '</tr>';

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><form method="POST" action="' . $_SERVER['PHP_SELF'] . '">';
print '<input type="hidden" name="token" value="' . newToken() . '">';
print '<input type="hidden" name="action" value="set_ticket_creation_option">';
print '<input type="hidden" name="page_y">';
print '<input type="radio" name="ticketCreationOption" value="shortcut_redirection_url"' . (getDolGlobalString('DIGIRISKDOLIBARR_TICKET_CREATION_OPTION') == 'shortcut_redirection_url' ? 'checked="checked"' : '') . ' onchange="this.form.submit()"/>';
print '</form></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 '<td><a class="button reposition" href="' . $_SERVER['PHP_SELF'] . '?action=generate_shortcut_url&token=' . newToken() . '&page_y=' . $pageY . '">' . $langs->transnoentities('Generate') . '</a></td>';
print '</tr>';

print '</form>';

print '</table>';


Expand Down
2 changes: 1 addition & 1 deletion js/digiriskdolibarr.min.js

Large diffs are not rendered by default.

16 changes: 0 additions & 16 deletions js/modules/ticket.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ 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 @@ -271,18 +270,3 @@ 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()
};

0 comments on commit 91d80cb

Please sign in to comment.