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

#4276 [TicketPublic] add: ticket summary on public interface #4299

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion js/digiriskdolibarr.min.js

Large diffs are not rendered by default.

43 changes: 43 additions & 0 deletions js/modules/ticket.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,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('change', '#ticket-form input, #ticket-form textarea, #ticket-form select', window.digiriskdolibarr.ticket.displayTicketSummary);
};

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

/**
* Display the ticket summary
*
* @since 10.3.0
* @version 10.3.0
*
* @return {void}
*/
window.digiriskdolibarr.ticket.displayTicketSummary = function() {
if ($('#ticket-summary').length == 0) {
return;
}
let message = $('#ticket-form #message').val();
let service = $('#ticket-form #options_digiriskdolibarr_ticket_service option:selected').text();
let serviceId = $('#ticket-form #options_digiriskdolibarr_ticket_service').val();
let last_name = $('#ticket-form #options_digiriskdolibarr_ticket_lastname').val();
let first_name = $('#ticket-form #options_digiriskdolibarr_ticket_firstname').val();
let location = $('#ticket-form #options_digiriskdolibarr_ticket_location').val();
let date = $('#ticket-form #options_digiriskdolibarr_ticket_date').val();

if (message && service && serviceId != -1 && last_name && first_name && location && date) {
$('#ticket-summary').show();
$('#ticket-summary #ticket-summmary-name').text(first_name + ' ' + last_name);
$('#ticket-summary #ticket-summmary-location').text(location);
$('#ticket-summary #ticket-summmary-service').text(service);
$('#ticket-summary #ticket-summmary-message').text(message);

date = new Date(date);
let day = String(date.getDate()).padStart(2, '0');
let month = String(date.getMonth() + 1).padStart(2, '0');
let year = date.getFullYear();
let hours = String(date.getHours()).padStart(2, '0');
let minutes = String(date.getMinutes()).padStart(2, '0');

let formattedDate = `${day}/${month}/${year} ${hours}:${minutes}`;

$('#ticket-summary #ticket-summmary-date').text(formattedDate);
} else {
$('#ticket-summary').hide();
}
}
4 changes: 4 additions & 0 deletions langs/fr_FR/digiriskdolibarr.lang
Original file line number Diff line number Diff line change
Expand Up @@ -1352,6 +1352,10 @@ FkTicket = Ticket lié
PublicTicket = Interface publique des tickets
TicketPublicInterfaceForbidden = Accès interdit à l'interface publique des tickets
WHSRegister = Registre SST
ITheUndersigned = Je soussiégné(e)
DeclareThe = Déclarer le
OnTheSite = Sur le site
RegardingTheService = Concernant le service

#Public interface - Interface publique
TicketPublicInterfaceShowCategoryDescription = Afficher la description des catégories de ticket dans l'interface publique
Expand Down
11 changes: 10 additions & 1 deletion public/ticket/create_ticket.php
Original file line number Diff line number Diff line change
Expand Up @@ -516,7 +516,7 @@
}

if (GETPOSTISSET('parentCategory') || GETPOSTISSET('parentCategory') && GETPOSTISSET('subCategory')) : ?>
<div class="wpeo-form tableforinputfields">
<div class="wpeo-form tableforinputfields" id="ticket-form">
<div class="wpeo-gridlayout grid-2">
<?php $visible = getDolGlobalInt('DIGIRISKDOLIBARR_TICKET_PUBLIC_INTERFACE_SHOW_CATEGORY_DESCRIPTION') || (!getDolGlobalInt('DIGIRISKDOLIBARR_TICKET_PUBLIC_INTERFACE_SHOW_CATEGORY_DESCRIPTION') && $mainCategoryChildrenExtrafields->show_description)
|| (!getDolGlobalInt('DIGIRISKDOLIBARR_TICKET_PUBLIC_INTERFACE_SHOW_CATEGORY_DESCRIPTION') && $mainCategoryChildrenExtrafields->show_description == NUll && $subCategoryExtrafields->show_description);
Expand Down Expand Up @@ -652,6 +652,15 @@
$previousStatus = $object->status;
$object->status = $object::STATUS_READ; // Special case because public answer need draft status object to complete question
$moreParams['moreCSS'] = 'hidden'; // Needed for prevent click on signature button action

print '<div class="hidden" id="ticket-summary" style="margin-top: 1em;">';
print '<span>' . $langs->transnoentities('ITheUndersigned') . ' : <strong id="ticket-summmary-name">' . $user->firstname . ' ' . $user->lastname . '</strong> ' . $langs->transnoentities('DeclareThe') . ' : <strong id="ticket-summmary-date"></strong></span>';
print '<br><br>';
print '<span><strong id="ticket-summmary-message"></strong></span>';
print '<br><br>';
print '<span>' . $langs->transnoentities('OnTheSite') . ' : <strong id="ticket-summmary-location"></strong>. ' . $langs->transnoentities('RegardingTheService') . ' : <strong id="ticket-summmary-service"></strong></span>';
print '</div>';

print '<div style="margin-top: 2em;">';
require_once __DIR__ . '/../../../saturne/core/tpl/signature/public_signature_view.tpl.php';
print '</div>';
Expand Down