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

#1720 [PublicAnswer] add: workflow, photo and total nb of questions #1765

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
10 changes: 10 additions & 0 deletions admin/publicinterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,16 @@
print ajax_constantonoff('DIGIQUALI_ANSWER_PUBLIC_INTERFACE_USE_SIGNATORY');
print '</td><td></td></tr>';

// Use public workflow
print '<tr class="oddeven"><td>';
print $langs->transnoentities('AnswerPublicInterfaceUseWorkflow');
print '</td><td>';
print $langs->transnoentities('AnswerPublicInterfaceUseWorkflowDescription');
print '</td>';
print '<td class="center">';
print ajax_constantonoff('DIGIQUALI_ANSWER_PUBLIC_INTERFACE_USE_WORKFLOW');
print '</td><td></td></tr>';

print '</table>';
print $form->buttonsSaveCancel('Save', '');
print '</form>';
Expand Down
6 changes: 5 additions & 1 deletion core/tpl/digiquali_answers_save_action.tpl.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,12 @@
}
}

if (GETPOSTISSET('cancel_action')) {
$object->setDraft($user);
}

$object->call_trigger('OBJECT_SAVEANSWER', $user);
setEventMessages($langs->trans('AnswerSaved'), []);
header('Location: ' . $_SERVER['PHP_SELF'] . (GETPOSTISSET('track_id') ? '?track_id=' . GETPOST('track_id', 'alpha') . '&object_type=' . GETPOST('object_type', 'alpha') . '&document_type=' . GETPOST('document_type', 'alpha') . '&entity=' . $conf->entity : '?id=' . GETPOST('id', 'int')));
header('Location: ' . $_SERVER['PHP_SELF'] . (GETPOSTISSET('track_id') ? '?track_id=' . GETPOST('track_id', 'alpha') . '&object_type=' . GETPOST('object_type', 'alpha') . '&document_type=' . GETPOST('document_type', 'alpha') . '&submit=' . GETPOST('submit', 'int') . '&entity=' . $conf->entity : '?id=' . GETPOST('id', 'int')));
exit;
}
9 changes: 5 additions & 4 deletions langs/fr_FR/digiquali.lang
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,11 @@ DisplaySurveyMediasSampleDescription = Afficher les médias d'exemple des questi
ExtrafieldsSurveyManagement = Gestion des attributs supplémentaires des questionnaires

# Public interface - Interface publique
AnswerPublicInterface = Interface publique de réponse aux questions pour __OBJECT_ELEMENT_REF__
AnswerPublicInterfaceTitle = Titre de l'interface publique de réponse aux questions
AnswerPublicInterfaceSubstitution = Traduction générique "TheObject" __REF__

AnswerPublicInterface = Interface publique de réponse aux questions pour __OBJECT_ELEMENT_REF__
AnswerPublicInterfaceTitle = Titre de l'interface publique de réponse aux questions
AnswerPublicInterfaceSubstitution = Traduction générique "TheObject" __REF__
AnswerPublicInterfaceUseWorkflow = Utiliser un workflow de validation sur l'interface publique
AnswerPublicInterfaceUseWorkflowDescription = Permet d'afficher un bouton "Modifier" et "Valider" après avoir soumis ses réponses dans l'interface publique.


#
Expand Down
38 changes: 34 additions & 4 deletions public/public_answer.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
$documentType = GETPOST('document_type', 'alpha');

// Load Saturne libraries
if (getDolGlobalInt('DIGIQUALI_ANSWER_PUBLIC_INTERFACE_USE_SIGNATORY')) {
if (getDolGlobalInt('DIGIQUALI_ANSWER_PUBLIC_INTERFACE_USE_SIGNATORY') || getDolGlobalInt('DIGIQUALI_ANSWER_PUBLIC_INTERFACE_USE_WORKFLOW')) {
require_once __DIR__ . '/../../saturne/class/saturnesignature.class.php';
}

Expand Down Expand Up @@ -150,7 +150,23 @@

saturne_header(1,'', $title, '', '', 0, 0, $moreJS, [], '', 'page-public-card page-signature');

print '<form method="POST" action="' . $_SERVER['PHP_SELF'] . '?action=save&id=' . $object->id . '&track_id=' . $trackID . '&object_type=' . $object->element . '&document_type=' . $documentType . '&entity=' . $conf->entity . '" id="saveObject" enctype="multipart/form-data">';
print '<div class="wpeo-gridlayout grid-4">';
$logosPath = DOL_DATA_ROOT . ($conf->entity > 1 ? '/' . $conf->entity . '/' : '/') . 'mycompany/logos/thumbs/';
$logosList = dol_dir_list($logosPath);
if (is_array($logosList) && !empty($logosList)) {
$logo = array_pop($logosList);
$logoSrc = DOL_URL_ROOT . '/viewimage.php?modulepart=mycompany&entity=' . $conf->entity . '&file=' . urlencode('logos/thumbs/' . $logo['name']);
} else {
$logoSrc = DOL_URL_ROOT.'/public/theme/common/nophoto.png';
}

print '<div class="card" style="height: 200px">';
print '<br>';
print '<img src="' . $logoSrc . '" alt="SocietyLogo" style="width:40%">';
print '</div>';
print '</div>';

print '<form method="POST" action="' . $_SERVER['PHP_SELF'] . '?action=save&id=' . $object->id . '&track_id=' . $trackID . '&object_type=' . $object->element . '&document_type=' . $documentType . '&submit=1&entity=' . $conf->entity . '" id="saveObject" enctype="multipart/form-data">';
print '<input type="hidden" name="token" value="' . newToken() . '">';
print '<input type="hidden" name="public_interface" value="true">';
print '<input type="hidden" name="action" value="save">';
Expand All @@ -163,6 +179,8 @@
print '<br>';
$publicInterface = true;
$sheet->fetchObjectLinked($object->fk_sheet, 'digiquali_' . $sheet->element, null, '', 'OR', 1, 'position');
$questionCount = (is_array($sheet->linkedObjects['digiquali_question']) && !empty($sheet->linkedObjects['digiquali_question']) ? count($sheet->linkedObjects['digiquali_question']) : 0);
print '<div class="badge badge-status8">' . $langs->trans('NbQuestions') . ': ' . $questionCount . '</div><div><br></div>';
require_once __DIR__ . '/../core/tpl/digiquali_answers.tpl.php';
if (getDolGlobalInt('DIGIQUALI_ANSWER_PUBLIC_INTERFACE_USE_SIGNATORY') && $signatory->id > 0) {
$previousStatus = $object->status;
Expand All @@ -173,10 +191,22 @@
print '</div>';
$object->status = $previousStatus;
}
if ($object->status == $object::STATUS_DRAFT) {
print '<div class="public-card__footer" style="margin-top: 2em;">';
print '<div class="public-card__footer center" style="margin-top: 2em;">';
if ($object->status == $object::STATUS_DRAFT && !getDolGlobalInt('DIGIQUALI_ANSWER_PUBLIC_INTERFACE_USE_WORKFLOW')) {
print '<button type="submit" class="wpeo-button save-public-answer ' . (getDolGlobalInt('DIGIQUALI_ANSWER_PUBLIC_INTERFACE_USE_SIGNATORY') && $signatory->id > 0 ? 'signature-validate button-disable' : '') . '">' . $langs->trans('Submit') . '</button>';
print '</div>';
} else if (getDolGlobalInt('DIGIQUALI_ANSWER_PUBLIC_INTERFACE_USE_WORKFLOW')) {
$submit = GETPOST('submit', 'int');

if ($submit == 0 && $object->status == $object::STATUS_DRAFT) {
print '<button type="submit" class="wpeo-button save-public-answer ' . (getDolGlobalInt('DIGIQUALI_ANSWER_PUBLIC_INTERFACE_USE_SIGNATORY') && $signatory->id > 0 ? 'signature-validate button-disable' : '') . '">' . $langs->trans('Submit') . '</button>';
}
print '</form>';
if ($submit == 1) {
print '<div class="inline-block"><a class="wpeo-button" style="margin-right: 2em;" href="' . $_SERVER['PHP_SELF'] . '?action=save&cancel_action=true&id=' . $object->id . '&track_id=' . $trackID . '&object_type=' . $object->element . '&document_type=' . $documentType . '&submit=0&entity=' . $conf->entity . '">' . $langs->trans('Modify') . '</a></div>';
print '<div class="inline-block"><a class="wpeo-button" href="' . $_SERVER['PHP_SELF'] . '?action=save&public_interface=true&id=' . $object->id . '&track_id=' . $trackID . '&object_type=' . $object->element . '&document_type=' . $documentType . '&entity=' . $conf->entity . '">' . $langs->trans('Save') . '</a></div>';
}
print '</div>';
}
print '</div>';
print '</form>';
Expand Down