From 783676f7f66300c0900bfffec179035b042a7c98 Mon Sep 17 00:00:00 2001 From: evarisk-kilyan Date: Fri, 13 Sep 2024 09:29:50 +0200 Subject: [PATCH 1/3] #4086 [Cards] fix: use saturne for lock and archive --- .../accidentinvestigation_card.php | 4 +- view/firepermit/firepermit_card.php | 43 ++----------------- view/preventionplan/preventionplan_card.php | 43 ++----------------- 3 files changed, 10 insertions(+), 80 deletions(-) diff --git a/view/accidentinvestigation/accidentinvestigation_card.php b/view/accidentinvestigation/accidentinvestigation_card.php index 740a4cdb8..e0e2dede2 100644 --- a/view/accidentinvestigation/accidentinvestigation_card.php +++ b/view/accidentinvestigation/accidentinvestigation_card.php @@ -197,7 +197,7 @@ require_once __DIR__ . '/../../../saturne/core/tpl/documents/saturne_manual_pdf_generation_action.tpl.php'; // Action confirm_lock, confirm_archive. - require_once __DIR__ . '/../../../saturne/core/tpl/signature/signature_action_workflow.tpl.php'; + require_once __DIR__ . '/../../../saturne/core/tpl/actions/object_workflow_actions.tpl.php'; // Actions to send emails. $triggersendname = strtoupper($object->element) . '_SENTBYMAIL'; @@ -300,7 +300,7 @@ } // Archive confirmation if (($action == 'set_archive' && (empty($conf->use_javascript_ajax) || !empty($conf->dol_use_jmobile))) || (!empty($conf->use_javascript_ajax) && empty($conf->dol_use_jmobile))) { - $formConfirm .= $form->formconfirm($_SERVER['PHP_SELF'] . '?id=' . $object->id, $langs->trans('ArchiveObject', $langs->transnoentities('The' . ucfirst($object->element))), $langs->trans('ConfirmArchiveObject', $langs->transnoentities('The' . ucfirst($object->element))), 'confirm_archive', '', 'yes', 'actionButtonArchive', 350, 600); + $formConfirm .= $form->formconfirm($_SERVER['PHP_SELF'] . '?id=' . $object->id . '&forcebuilddoc=true', $langs->trans('ArchiveObject', $langs->transnoentities('The' . ucfirst($object->element))), $langs->trans('ConfirmArchiveObject', $langs->transnoentities('The' . ucfirst($object->element))), 'confirm_archive', '', 'yes', 'actionButtonArchive', 350, 600); } // Clone confirmation if (($action == 'clone' && (empty($conf->use_javascript_ajax) || !empty($conf->dol_use_jmobile))) || (!empty($conf->use_javascript_ajax) && empty($conf->dol_use_jmobile))) { diff --git a/view/firepermit/firepermit_card.php b/view/firepermit/firepermit_card.php index 1afb4d9ae..3ba1293f4 100644 --- a/view/firepermit/firepermit_card.php +++ b/view/firepermit/firepermit_card.php @@ -547,43 +547,8 @@ } } - // Action to set status STATUS_LOCKED - if ($action == 'confirm_setLocked') { - $object->fetch($id); - if ( ! $error) { - $result = $object->setLocked($user, false); - if ($result > 0) { - // Set locked OK - $urltogo = str_replace('__ID__', $result, $backtopage); - $urltogo = preg_replace('/--IDFORBACKTOPAGE--/', $id, $urltogo); // New method to autoselect project after a New on another form object creation - header("Location: " . $urltogo); - exit; - } else { - // Set locked KO - if ( ! empty($object->errors)) setEventMessages(null, $object->errors, 'errors'); - else setEventMessages($object->error, null, 'errors'); - } - } - } - - // Action to set status STATUS_ARCHIVED - if ($action == 'setArchived') { - $object->fetch($id); - if ( ! $error) { - $result = $object->setArchived($user, false); - if ($result > 0) { - // Set Archived OK - $urltogo = str_replace('__ID__', $result, $backtopage); - $urltogo = preg_replace('/--IDFORBACKTOPAGE--/', $id, $urltogo); // New method to autoselect project after a New on another form object creation - header("Location: " . $urltogo); - exit; - } else { - // Set Archived KO - if ( ! empty($object->errors)) setEventMessages(null, $object->errors, 'errors'); - else setEventMessages($object->error, null, 'errors'); - } - } - } + // Action confirm_lock, confirm_archive. + require_once __DIR__ . '/../../../saturne/core/tpl/actions/object_workflow_actions.tpl.php'; // Action clone object if ($action == 'confirm_clone' && $confirm == 'yes') { @@ -921,7 +886,7 @@ // SetLocked confirmation if (($action == 'setLocked' && (empty($conf->use_javascript_ajax) || ! empty($conf->dol_use_jmobile))) // Output when action = clone if jmobile or no js || ( ! empty($conf->use_javascript_ajax) && empty($conf->dol_use_jmobile))) { // Always output when not jmobile nor js - $formconfirm .= $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('LockObject', $langs->transnoentities('The' . ucfirst($object->element))), $langs->trans('ConfirmLockObject', $langs->transnoentities('The' . ucfirst($object->element))), 'confirm_setLocked', '', 'yes', 'actionButtonLock', 350, 600); + $formconfirm .= $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('LockObject', $langs->transnoentities('The' . ucfirst($object->element))), $langs->trans('ConfirmLockObject', $langs->transnoentities('The' . ucfirst($object->element))), 'confirm_lock', '', 'yes', 'actionButtonLock', 350, 600); } // setPendingSignature confirmation @@ -1140,7 +1105,7 @@ // Archive $displayButton = $onPhone ? '' : '' . ' ' . $langs->trans('Archive'); if ($object->status == $object::STATUS_LOCKED) { - print '' . $displayButton . ''; + print '' . $displayButton . ''; } else { print '' . $displayButton . ''; } diff --git a/view/preventionplan/preventionplan_card.php b/view/preventionplan/preventionplan_card.php index 1bd54459e..be782e187 100644 --- a/view/preventionplan/preventionplan_card.php +++ b/view/preventionplan/preventionplan_card.php @@ -554,43 +554,8 @@ } } - // Action to set status STATUS_LOCKED - if ($action == 'confirm_setLocked') { - $object->fetch($id); - if ( ! $error) { - $result = $object->setLocked($user, false); - if ($result > 0) { - // Set locked OK - $urltogo = str_replace('__ID__', $result, $backtopage); - $urltogo = preg_replace('/--IDFORBACKTOPAGE--/', $id, $urltogo); // New method to autoselect project after a New on another form object creation - header("Location: " . $urltogo); - exit; - } else { - // Set locked KO - if ( ! empty($object->errors)) setEventMessages(null, $object->errors, 'errors'); - else setEventMessages($object->error, null, 'errors'); - } - } - } - - // Action to set status STATUS_ARCHIVED - if ($action == 'setArchived') { - $object->fetch($id); - if ( ! $error) { - $result = $object->setArchived($user, false); - if ($result > 0) { - // Set Archived OK - $urltogo = str_replace('__ID__', $result, $backtopage); - $urltogo = preg_replace('/--IDFORBACKTOPAGE--/', $id, $urltogo); // New method to autoselect project after a New on another form object creation - header("Location: " . $urltogo); - exit; - } else { - // Set Archived KO - if ( ! empty($object->errors)) setEventMessages(null, $object->errors, 'errors'); - else setEventMessages($object->error, null, 'errors'); - } - } - } + // Action confirm_lock, confirm_archive. + require_once __DIR__ . '/../../../saturne/core/tpl/actions/object_workflow_actions.tpl.php'; // Action clone object if ($action == 'confirm_clone' && $confirm == 'yes') { @@ -963,7 +928,7 @@ // SetLocked confirmation if (($action == 'setLocked' && (empty($conf->use_javascript_ajax) || ! empty($conf->dol_use_jmobile))) // Output when action = clone if jmobile or no js || ( ! empty($conf->use_javascript_ajax) && empty($conf->dol_use_jmobile))) { // Always output when not jmobile nor js - $formconfirm .= $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('LockObject', $langs->transnoentities('The' . ucfirst($object->element))), $langs->trans('ConfirmLockObject', $langs->transnoentities('The' . ucfirst($object->element))), 'confirm_setLocked', '', 'yes', 'actionButtonLock', 350, 600); + $formconfirm .= $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('LockObject', $langs->transnoentities('The' . ucfirst($object->element))), $langs->trans('ConfirmLockObject', $langs->transnoentities('The' . ucfirst($object->element))), 'confirm_lock', '', 'yes', 'actionButtonLock', 350, 600); } // setPendingSignature confirmation @@ -1210,7 +1175,7 @@ // Archive $displayButton = $onPhone ? '' : '' . ' ' . $langs->trans('Archive'); if ($object->status == $object::STATUS_LOCKED) { - print '' . $displayButton . ''; + print '' . $displayButton . ''; } else { print '' . $displayButton . ''; } From bc0108685e6d54a8539a8d1f504b48b353f10839 Mon Sep 17 00:00:00 2001 From: evarisk-kilyan Date: Tue, 17 Sep 2024 09:56:52 +0200 Subject: [PATCH 2/3] #4086 [Cards] add: confirm box on archive and add delete button --- class/accidentinvestigation.class.php | 6 ++--- langs/fr_FR/digiriskdolibarr.lang | 2 +- view/accident/accident_card.php | 16 ++++++++++--- .../accidentinvestigation_card.php | 2 +- view/firepermit/firepermit_card.php | 23 +++++++++++++------ view/preventionplan/preventionplan_card.php | 12 ++++++++-- 6 files changed, 44 insertions(+), 17 deletions(-) diff --git a/class/accidentinvestigation.class.php b/class/accidentinvestigation.class.php index 3f58ade92..050883631 100644 --- a/class/accidentinvestigation.class.php +++ b/class/accidentinvestigation.class.php @@ -119,8 +119,8 @@ class AccidentInvestigation extends SaturneObject 'import_key' => ['type' => 'varchar(14)', 'label' => 'ImportId', 'enabled' => 1, 'position' => 60, 'notnull' => 0, 'visible' => 0, 'index' => 0], 'status' => ['type' => 'smallint', 'label' => 'Status', 'enabled' => 1, 'position' => 70, 'notnull' => 1, 'visible' => 2, 'noteditable' => 1, 'default' => 0, 'index' => 0, 'arrayofkeyval' => [0 => 'StatusDraft', 1 => 'Validated', 2 => 'Locked', 3 => 'Archived']], 'seniority_in_position' => ['type' => 'varchar(255)', 'label' => 'SeniorityInPosition', 'enabled' => 1, 'position' => 80, 'notnull' => 0, 'visible' => 1, 'css' => 'maxwidth200'], - 'date_start' => ['type' => 'datetime', 'label' => 'StartDate', 'enabled' => 1, 'position' => 90, 'notnull' => 0, 'visible' => 1,], - 'date_end' => ['type' => 'datetime', 'label' => 'EndDate', 'enabled' => 1, 'position' => 100, 'notnull' => 0, 'visible' => 1,], + 'date_start' => ['type' => 'datetime', 'label' => 'StartDate', 'enabled' => 1, 'position' => 90, 'notnull' => 1, 'visible' => 1,], + 'date_end' => ['type' => 'datetime', 'label' => 'EndDate', 'enabled' => 1, 'position' => 100, 'notnull' => 1, 'visible' => 1,], 'note_public' => ['type' => 'html', 'label' => 'NotePublic', 'enabled' => 1, 'position' => 110, 'notnull' => 0, 'visible' => -1,], 'note_private' => ['type' => 'html', 'label' => 'NotePrivate', 'enabled' => 1, 'position' => 120, 'notnull' => 0, 'visible' => 0,], 'victim_skills' => ['type' => 'html', 'label' => 'VictimSkills', 'enabled' => 1, 'position' => 130, 'notnull' => 0, 'visible' => -1,], @@ -128,7 +128,7 @@ class AccidentInvestigation extends SaturneObject 'individual_equipment' => ['type' => 'html', 'label' => 'IndividualEquipment', 'enabled' => 1, 'position' => 150, 'notnull' => 0, 'visible' => -1,], 'circumstances' => ['type' => 'html', 'label' => 'Circumstances', 'enabled' => 1, 'position' => 160, 'notnull' => 0, 'visible' => -1,], 'causality_tree' => ['type' => 'text', 'label' => 'CausalityTree', 'enabled' => 1, 'position' => 170, 'notnull' => 0, 'visible' => 0,], - 'fk_accident' => ['type' => 'integer:Accident:digiriskdolibarr/class/accident/accident.class.php', 'label' => 'Accident', 'picto' => 'fontawesome_fa-user-injured_fas' ,'enabled' => 1, 'position' => 11, 'notnull' => 1, 'visible' => 1, 'foreignkey' => 'digiriskdolibarr_accident.rowid', 'css' => 'maxwidth300'], + 'fk_accident' => ['type' => 'integer:Accident@digiriskdolibarr:digiriskdolibarr/class/accident/accident.class.php', 'label' => 'Accident', 'picto' => 'fontawesome_fa-user-injured_fas' ,'enabled' => 1, 'position' => 11, 'notnull' => 1, 'visible' => 1, 'foreignkey' => 'digiriskdolibarr_accident.rowid', 'css' => 'maxwidth300'], 'fk_task' => ['type' => 'integer:Task:projet/class/task.class.php', 'label' => 'Task', 'picto' => 'task', 'enabled' => 1, 'position' => 12, 'notnull' => 1, 'visible' => 5, 'noteditable' => 1, 'default' => 0, 'foreignkey' => 'projet_task.rowid', 'help' => 'TaskWillBeCreatedAfterValidation'], 'fk_project' => ['type' => 'integer:Project:projet/class/project.class.php', 'label' => 'Project', 'picto' => 'project', 'enabled' => 1, 'position' => 13, 'notnull' => 1, 'visible' => 0,], 'fk_user_creat' => ['type' => 'integer:User:user/class/user.class.php', 'label' => 'UserAuthor', 'picto' => 'user', 'enabled' => 1, 'position' => 190, 'notnull' => 1, 'visible' => 0, 'foreignkey' => 'user.rowid'], diff --git a/langs/fr_FR/digiriskdolibarr.lang b/langs/fr_FR/digiriskdolibarr.lang index eceee7b78..b0506d7b1 100644 --- a/langs/fr_FR/digiriskdolibarr.lang +++ b/langs/fr_FR/digiriskdolibarr.lang @@ -723,7 +723,7 @@ ActionPreventionCompletedTaskDone = Les actions soldées AppliedOn = Actif sur : RiskAssessmentDocumentMethod = * Étape 1 : Récupération des informations
- Visite des locaux
- Récupération des données du personnel

* Étape 2 : Définition de la méthodologie et de document
- Validation des fiches d'unité de travail standard
- Validation de l'arborescence des unités

* Étape 3 : Réalisation de l'étude de risques
- Sensibilisation des personnels aux risques et aux dangers
- Création des unités de travail avec le personnel et le ou les responsables
- Évaluations des risques par unités de travail avec le personnel

* Étape 4
- Traitement et rédaction du document unique RiskAssessmentDocumentSources = La sensibilisation des risques est définie dans l'ED840 édité par L'INRS.
Dans ce document vous trouverez:
- La définition d'un risque, d'un danger et un schéma explicatif
- Les explications concernant les différentes méthodes d'évaluation -RiskAssessmentDocumentImportantNote = Notes importantes :
Vous pouvez lire la documentation de DigiRisk ici
https://wiki.dolibarr.org/index.php?title=Module_Digirisk
Vous pouvez suivre le projet ici :
https://github.com/Evarisk/Digirisk/projects?type=classic
Reporter un bug ici
https://github.com/Evarisk/Digirisk/issues +RiskAssessmentDocumentImportantNote = Notes importantes :
Vous pouvez lire la documentation de DigiRisk ici
https://wiki.dolibarr.org/index.php?title=Module_Digirisk
Vous pouvez suivre le projet ici :
https://github.com/Evarisk/Digirisk/projects?query=is%3Aopen
Reporter un bug ici
https://github.com/Evarisk/Digirisk/issues GenerateZipArchiveWithDigiriskElementDocuments = Génération d'une archive ZIP avec le Document Unique GenerateZipArchiveWithDigiriskElementDocumentsDescription = Génération automatique d'une archive ZIP contenant le Document Unique et toutes les fiches de poste lors de la génération du Document Unique RiskAssessmentDocumentDescription = Plan d'action Document Unique diff --git a/view/accident/accident_card.php b/view/accident/accident_card.php index 3f02511b3..dbb1326e1 100644 --- a/view/accident/accident_card.php +++ b/view/accident/accident_card.php @@ -590,7 +590,7 @@ include_once __DIR__ . '/../../core/tpl/accident/digiriskdolibarr_accident_lesion_actions.tpl.php'; // Action confirm_lock, confirm_archive. - require_once __DIR__ . '/../../../saturne/core/tpl/signature/signature_action_workflow.tpl.php'; + require_once __DIR__ . '/../../../saturne/core/tpl/actions/object_workflow_actions.tpl.php'; // Actions set_thirdparty, set_project require_once __DIR__ . '/../../../saturne/core/tpl/actions/banner_actions.tpl.php'; @@ -938,7 +938,17 @@ $formConfirm .= $form->formconfirm($_SERVER['PHP_SELF'] . '?id=' . $object->id, $langs->trans('LockObject', $langs->transnoentities('The' . ucfirst($object->element))), $langs->trans('ConfirmLockObject', $langs->transnoentities('The' . ucfirst($object->element))), 'confirm_lock', '', 'yes', 'actionButtonLock', 350, 600); } - // Call Hook formConfirm. + // Archive confirmation + if (($action == 'set_archive' && (empty($conf->use_javascript_ajax) || !empty($conf->dol_use_jmobile))) || (!empty($conf->use_javascript_ajax) && empty($conf->dol_use_jmobile))) { + $formConfirm .= $form->formconfirm($_SERVER['PHP_SELF'] . '?id=' . $object->id . '&forcebuilddoc=true', $langs->trans('ArchiveObject', $langs->transnoentities('The' . ucfirst($object->element))), $langs->trans('ConfirmArchiveObject', $langs->transnoentities('The' . ucfirst($object->element))), 'confirm_archive', '', 'yes', 'actionButtonArchive', 350, 600); + } + + // Delete (need delete permission, or if draft, just need create/modify permission). + $displayButton = $onPhone ? '' : '' . ' ' . $langs->trans('Delete'); + print dolGetButtonAction($displayButton, '', 'delete', $_SERVER['PHP_SELF'] . '?id=' . $object->id . '&action=delete&token=' . newToken(), '', $permissiontodelete || ($object->status == AccidentInvestigation::STATUS_DRAFT)); + + + // Call Hook formConfirm. $parameters = ['formConfirm' => $formConfirm]; $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook. @@ -1161,7 +1171,7 @@ // Archive $displayButton = $onPhone ? '' : '' . ' ' . $langs->trans('Archive'); if ($object->status == Accident::STATUS_LOCKED) { - print '' . $displayButton . ''; + print '' . $displayButton . ''; } else { print '' . $displayButton . ''; } diff --git a/view/accidentinvestigation/accidentinvestigation_card.php b/view/accidentinvestigation/accidentinvestigation_card.php index e0e2dede2..5c58c80e9 100644 --- a/view/accidentinvestigation/accidentinvestigation_card.php +++ b/view/accidentinvestigation/accidentinvestigation_card.php @@ -429,7 +429,7 @@ // Delete (need delete permission, or if draft, just need create/modify permission). $displayButton = $onPhone ? '' : '' . ' ' . $langs->trans('Delete'); - print dolGetButtonAction($displayButton, '', 'delete', $_SERVER['PHP_SELF'] . '?id=' . $object->id . '&action=delete&token=' . newToken(), '', $permissiontodelete || ($object->status == AccidentInvestigation::STATUS_DRAFT)); + print dolGetButtonAction($displayButton, '', 'delete', $_SERVER['PHP_SELF'] . '?id=' . $object->id . '&action=delete&token=' . newToken(), '', $permissiontodelete || ($object->status == AccidentInvestigation::STATUS_DRAFT)); print ''; } diff --git a/view/firepermit/firepermit_card.php b/view/firepermit/firepermit_card.php index 3ba1293f4..19e372710 100644 --- a/view/firepermit/firepermit_card.php +++ b/view/firepermit/firepermit_card.php @@ -901,6 +901,11 @@ $formconfirm .= $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('ReOpenFirePermit'), $langs->trans('ConfirmReOpenFirePermit', $object->ref), 'confirm_setInProgress', '', 'yes', 'actionButtonInProgress', 350, 600); } +// Archive confirmation +if (($action == 'set_archive' && (empty($conf->use_javascript_ajax) || !empty($conf->dol_use_jmobile))) || (!empty($conf->use_javascript_ajax) && empty($conf->dol_use_jmobile))) { + $formconfirm .= $form->formconfirm($_SERVER['PHP_SELF'] . '?id=' . $object->id . '&forcebuilddoc=true', $langs->trans('ArchiveObject', $langs->transnoentities('The' . ucfirst($object->element))), $langs->trans('ConfirmArchiveObject', $langs->transnoentities('The' . ucfirst($object->element))), 'confirm_archive', '', 'yes', 'actionButtonArchive', 350, 600); +} + // Clone confirmation if (($action == 'clone' && (empty($conf->use_javascript_ajax) || ! empty($conf->dol_use_jmobile))) // Output when action = clone if jmobile or no js || ( ! empty($conf->use_javascript_ajax) && empty($conf->dol_use_jmobile))) { // Always output when not jmobile nor js @@ -1103,17 +1108,21 @@ } // Archive - $displayButton = $onPhone ? '' : '' . ' ' . $langs->trans('Archive'); - if ($object->status == $object::STATUS_LOCKED) { - print '' . $displayButton . ''; - } else { - print '' . $displayButton . ''; - } + $displayButton = $onPhone ? '' : '' . ' ' . $langs->trans('Archive'); + if ($object->status == $object::STATUS_LOCKED) { + print '' . $displayButton . ''; + } else { + print '' . $displayButton . ''; + } // Clone $displayButton = $onPhone ? '' : '' . ' ' . $langs->trans('ToClone'); print '' . $displayButton . ''; - } + + // Delete (need delete permission, or if draft, just need create/modify permission). + $displayButton = $onPhone ? '' : '' . ' ' . $langs->trans('Delete'); + print dolGetButtonAction($displayButton, '', 'delete', $_SERVER['PHP_SELF'] . '?id=' . $object->id . '&action=delete&token=' . newToken(), '', $permissiontodelete || ($object->status == AccidentInvestigation::STATUS_DRAFT)); + } print ''; diff --git a/view/preventionplan/preventionplan_card.php b/view/preventionplan/preventionplan_card.php index be782e187..09711a6e3 100644 --- a/view/preventionplan/preventionplan_card.php +++ b/view/preventionplan/preventionplan_card.php @@ -943,6 +943,11 @@ $formconfirm .= $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('ReOpenPreventionPlan'), $langs->trans('ConfirmReOpenPreventionPlan', $object->ref), 'confirm_setInProgress', '', 'yes', 'actionButtonInProgress', 350, 600); } +// Archive confirmation +if (($action == 'set_archive' && (empty($conf->use_javascript_ajax) || !empty($conf->dol_use_jmobile))) || (!empty($conf->use_javascript_ajax) && empty($conf->dol_use_jmobile))) { + $formconfirm .= $form->formconfirm($_SERVER['PHP_SELF'] . '?id=' . $object->id . '&forcebuilddoc=true', $langs->trans('ArchiveObject', $langs->transnoentities('The' . ucfirst($object->element))), $langs->trans('ConfirmArchiveObject', $langs->transnoentities('The' . ucfirst($object->element))), 'confirm_archive', '', 'yes', 'actionButtonArchive', 350, 600); +} + // Clone confirmation if (($action == 'clone' && (empty($conf->use_javascript_ajax) || ! empty($conf->dol_use_jmobile))) // Output when action = clone if jmobile or no js || ( ! empty($conf->use_javascript_ajax) && empty($conf->dol_use_jmobile))) { // Always output when not jmobile nor js @@ -1175,7 +1180,7 @@ // Archive $displayButton = $onPhone ? '' : '' . ' ' . $langs->trans('Archive'); if ($object->status == $object::STATUS_LOCKED) { - print '' . $displayButton . ''; + print '' . $displayButton . ''; } else { print '' . $displayButton . ''; } @@ -1183,7 +1188,10 @@ // Clone $displayButton = $onPhone ? '' : '' . ' ' . $langs->trans('ToClone'); print '' . $displayButton . ''; - } + + $displayButton = $onPhone ? '' : '' . ' ' . $langs->trans('Delete'); + print dolGetButtonAction($displayButton, '', 'delete', $_SERVER['PHP_SELF'] . '?id=' . $object->id . '&action=delete&token=' . newToken(), '', $permissiontodelete || ($object->status == AccidentInvestigation::STATUS_DRAFT)); + } print ''; // PREVENTIONPLAN LINES From 10f4af3ecdf368b3e27513b7943c0912bea6b401 Mon Sep 17 00:00:00 2001 From: Nicolas Domenech Date: Thu, 17 Oct 2024 18:28:43 +0200 Subject: [PATCH 3/3] #4086 [Cards] fix: implement saturneForm --- langs/fr_FR/digiriskdolibarr.lang | 22 -- view/accident/accident_card.php | 167 ++--------- .../accidentinvestigation_card.php | 143 ++-------- view/firepermit/firepermit_card.php | 267 ++++-------------- view/preventionplan/preventionplan_card.php | 266 ++++------------- 5 files changed, 149 insertions(+), 716 deletions(-) diff --git a/langs/fr_FR/digiriskdolibarr.lang b/langs/fr_FR/digiriskdolibarr.lang index b0506d7b1..d9064dbc4 100644 --- a/langs/fr_FR/digiriskdolibarr.lang +++ b/langs/fr_FR/digiriskdolibarr.lang @@ -247,10 +247,8 @@ PriorVisitText = Note de l'inspection CSSCTIntervention = Intervention du CSSCT CSSCTInterventionText = Intervention du CSSCT ? MasterWorker = Responsable de l'Entreprise Utilisatrice -MasterWorker = Responsable de l'Entreprise Utilisatrice ExtSociety = Entreprise Extérieure ExtSocietyResponsible = Responsable de l'Entreprise Extérieure -ExtSocietyResponsible = Responsable de l'Entreprise Extérieure ExtSocietyAttendant = Intervenant de l'Entreprise Extérieure ActionsDescription = Description des actions INRSRisk = Risque (INRS) @@ -261,13 +259,6 @@ ModifyPreventionPlan = Modifier le plan de pré ActionsDescriptionTooltip = Description des actions réalisées par l'intervenant INRSRiskTooltip = Liste des catégories de risques proposée dans le référentiel de l'INRS PreventionMethodTooltip = Moyen de prévention à mettre en place pour limiter le risque -LockPreventionPlan = Verrouiller le plan de prévention -ConfirmLockPreventionPlan = Êtes-vous sûr de vouloir verrouiller le plan de prévention ?
Ce verrouillage permet de figer les données et la génération du document. -AllSignatoriesMustHaveSigned = Tous les participants doivent avoir signé pour verrouiller l'objet -ValidatePreventionPlan = Valider le plan de prévention -ConfirmValidatePreventionPlan = Êtes-vous sûr de vouloir valider le plan de prévention ?
La validation permet aux participants de signer le document mais empêche l'ajout de nouveaux participants ou la modification du plan de prévention . -ReOpenPreventionPlan = Ouvrir à nouveau le plan de prévention -ConfirmReOpenPreventionPlan = Êtes-vous sûr de vouloir rouvrir le plan de prévention ? La réouverture permet la modification du plan de prévention et l'ajout de nouveaux participants mais toutes les signatures du document seront perdues. PreventionPlanRiskList = Liste des risques du plan de prévention ActionsPreventionPlanRisk = Actions PreventionPlanDescription = Projet des plans de prévention @@ -278,9 +269,6 @@ DeletePreventionPlanLine = Suppression du risque PreventionPlanDet = Risque du plan de prévention Preventionplandet = Risque du plan de prévention PreventionPlanMessage = au plan de prévention -PreventionPlanMustBeValidated = Le plan de prévention doit être validé pour le rouvrir -PreventionPlanMustBeInProgress = Le plan de prévention doit être en cours pour accéder à cette fonctionnalité -PreventionPlanMustBeInProgressToValidate = Le plan de prévention est déjà validé CSEMustBeAlerted3DaysBeforeVisit = Le CSE doit être prévenu 3 jours avant l'inspection commune préalable (art. R. 4514-1 1°, R. 4514-3 et R. 4514-9 du Code du travail) PreventionPlanData = Données du Plan de prévention MasterWorkerDescription = L'utilisateur utilisé par défaut comme Responsable de l'Entreprise Utilisatrice @@ -293,12 +281,10 @@ NewLabelForClonePreventionPlan = Libellé du nouveau plan ClonePreventionPlanRisk = Cloner les risques du plan de prévention CloneAttendantsPreventionPlan = Cloner les participants du plan de prévention CloneSchedulePreventionPlan = Cloner les horaires du plan de prévention -ConfirmClonePreventionPlan = Êtes-vous sûr de vouloir cloner le plan de prévention %s ? preventionplandocument.odt = Plan de prévention preventionplandocument_custom.odt = Plan de prévention personnalisé ErrorThirdPartyHasAtLeastOneChildOfTypePreventionPlan = Le tiers est lié à au moins un enfant de type Plan de Prévention : ErrorContactHasAtLeastOneChildOfTypePreventionPlan = Le contact est lié à au moins un enfant de type Plan de Prévention : -ConfirmDeletePreventionPlan = Êtes-vous sûr de vouloir supprimer ce plan de prévention ? PreventionPlanRole = Les rôles du plan de prévention # Email - Mail @@ -356,15 +342,10 @@ DeleteFirePermitLine = Suppression du risque FirePermitMessage = au permis de feu UsedMaterialTooltip = Matériel à utiliser pour limiter le risque ActionsFirePermitRisk = Actions -ConfirmValidateFirePermit = Êtes-vous sûr de vouloir valider le permis de feu ?
La validation permet aux participants de signer le document mais empêche l'ajout de nouveaux participants ou la modification du permis de feu . -ConfirmReOpenFirePermit = Êtes-vous sûr de vouloir rouvrir le permis de feu ? La réouverture permet la modification du permsi de feu et l'ajout de nouveaux participants mais toutes les signatures du document seront perdues. -ConfirmLockFirePermit = Êtes-vous sûr de vouloir verrouiller le permis de feu ?
Ce verrouillage permet de figer les données et la génération du document. -FirePermitMustBeInProgress = Le permis de feu doit être en cours pour accéder à cette fonctionnalité NewLabelForCloneFirePermit = Libellé du nouveau permis de feu CloneFirePermitRisk = Cloner les risques du permis de feu CloneAttendantsFirePermit = Cloner les participants du permis de feu CloneScheduleFirePermit = Cloner les horaires du permis de feu -ConfirmCloneFirePermit = Êtes-vous sûr de vouloir cloner le permis de feu %s ? FirePermitDescription = Projet des permis de feu FirePermitData = Données du Permis de feu FirePermitManagement = Gestion des permis de feu @@ -375,7 +356,6 @@ firepermitdocument_custom.odt = Permis de feu personnalisé UsedEquipment = Matériel utilisé ErrorThirdPartyHasAtLeastOneChildOfTypeFirePermit = Le tiers est lié à au moins un enfant de type Permis de Feu : ErrorContactHasAtLeastOneChildOfTypeFirePermit = Le contact est lié à au moins un enfant de type Permis de Feu : -ConfirmDeleteFirePermit = Êtes-vous sûr de vouloir supprimer ce permis de feu ? FirePermitRole = Les rôles du permis de feu FirepermitSchedules = Horaires du permis de feu LinkDigiriskdolibarr_firepermit = Activer le lien avec les permis de feu @@ -528,7 +508,6 @@ DocumentsMetaData = Fichiers joints complémentaires WorkStopDocument = Déclaration d'arrêt de travail AccidentMetaDataSave = Les données complémentaires de l'accident ont bien été enregistrées ErrorFieldNotEmpty = Erreur : le champ '%s' ne peut pas être vide -ConfirmDeleteAccidentWorkStop = Êtes-vous sûr de vouloir supprimer l'arrêt de travail %s sur l'accident ? AccidentMetaDataLesion = Données complémentaires des lésions TotalWorkStopDays = Nombre total de jours d'arrêt de travail RegisterAccident = Accident bénin @@ -551,7 +530,6 @@ NbPresquAccidents = Nombre de presqu'accidents NbAccidentInvestigations = Nombre d'enquête accidents AccidentInvestigationsMin = enquêtes accident NbWorkedHours = Nombre d\'heures travaillées -ConfirmDeleteAccident = Êtes-vous sûr de vouloir supprimer l'accident ? TheAccident = l'accident AccidentInvestigation = Enquête accident Accident_investigation = Enquête accident diff --git a/view/accident/accident_card.php b/view/accident/accident_card.php index dbb1326e1..667554278 100644 --- a/view/accident/accident_card.php +++ b/view/accident/accident_card.php @@ -38,6 +38,7 @@ require_once DOL_DOCUMENT_ROOT . '/core/lib/images.lib.php'; require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; +require_once __DIR__ . '/../../../saturne/class/saturneform.class.php'; require_once __DIR__ . '/../../class/digiriskelement.class.php'; require_once __DIR__ . '/../../class/accident.class.php'; require_once __DIR__ . '/../../class/digiriskstandard.class.php'; @@ -589,7 +590,7 @@ include_once __DIR__ . '/../../core/tpl/accident/digiriskdolibarr_accident_lesion_actions.tpl.php'; - // Action confirm_lock, confirm_archive. + // Action confirm_lock, confirm_archive require_once __DIR__ . '/../../../saturne/core/tpl/actions/object_workflow_actions.tpl.php'; // Actions set_thirdparty, set_project @@ -893,73 +894,23 @@ $object->fetch($id); saturne_banner_tab($object, 'id', '', 1, 'rowid', 'ref', $moreHtmlRef, dol_strlen($object->photo) > 0, $moreParams); - $formConfirm = ''; + $formQuestionClone = [ + ['type' => 'text', 'name' => 'clone_label', 'label' => $langs->trans('NewLabelForClone', $langs->transnoentities('The' . ucfirst($object->element))), 'value' => $langs->trans('CopyOf') . ' ' . $object->ref, 'size' => 24], + ['type' => 'checkbox', 'name' => 'clone_workstop', 'label' => $langs->trans('CloneWorkStop'), 'value' => 1], + ['type' => 'checkbox', 'name' => 'clone_metadata', 'label' => $langs->trans('CloneMetadata'), 'value' => 1], + ['type' => 'checkbox', 'name' => 'clone_lesion', 'label' => $langs->trans('CloneLesion'), 'value' => 1], + ['type' => 'checkbox', 'name' => 'clone_photos', 'label' => $langs->trans('ClonePhotos'), 'value' => 1], + ['type' => 'checkbox', 'name' => 'clone_categories', 'label' => $langs->trans('CloneCategories'), 'value' => 1], + ['type' => 'checkbox', 'name' => 'clone_attendants', 'label' => $langs->trans('CloneAttendants'), 'value' => 1] + ]; - // Confirmation to delete - if ($action == 'delete' && $permissiontodelete) { - $formConfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id=' . $object->id, $langs->trans('DeleteAccident'), $langs->trans('ConfirmDeleteAccident'), 'confirm_delete', '', 0, 1); - } - - // Confirmation to delete line - if ($action == 'deleteline') { - $objectline->fetch($lineid); - $formConfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id . '&lineid=' . $lineid, $langs->trans('DeleteAccidentWorkStop'), $langs->trans('ConfirmDeleteAccidentWorkStop', $objectline->ref), 'confirm_deleteLine', '', 0, 1); - } + $moreParams['cloneConfirmation'] = ['formQuestion' => $formQuestionClone, 'width' => 600]; + $moreParams['validateConfirmation'] = ['question' => $langs->transnoentities('ConfirmValidateObject', $langs->transnoentities('The' . ucfirst($object->element)), $langs->transnoentities('LesionsOrWorkStop'))]; - // Clone confirmation - if (($action == 'clone' && (empty($conf->use_javascript_ajax) || !empty($conf->dol_use_jmobile))) || (!empty($conf->use_javascript_ajax) && empty($conf->dol_use_jmobile))) { - $formQuestionClone = [ - ['type' => 'text', 'name' => 'clone_label', 'label' => $langs->trans('NewLabelForClone', $langs->transnoentities('The' . ucfirst($object->element))), 'value' => $langs->trans('CopyOf') . ' ' . $object->ref, 'size' => 24], - ['type' => 'checkbox', 'name' => 'clone_workstop', 'label' => $langs->trans('CloneWorkStop'), 'value' => 1], - ['type' => 'checkbox', 'name' => 'clone_metadata', 'label' => $langs->trans('CloneMetadata'), 'value' => 1], - ['type' => 'checkbox', 'name' => 'clone_lesion', 'label' => $langs->trans('CloneLesion'), 'value' => 1], - ['type' => 'checkbox', 'name' => 'clone_photos', 'label' => $langs->trans('ClonePhotos'), 'value' => 1], - ['type' => 'checkbox', 'name' => 'clone_categories', 'label' => $langs->trans('CloneCategories'), 'value' => 1], - ['type' => 'checkbox', 'name' => 'clone_attendants', 'label' => $langs->trans('CloneAttendants'), 'value' => 1] - ]; - - $formConfirm .= $form->formconfirm($_SERVER['PHP_SELF'] . '?id=' . $object->id, $langs->trans('CloneObject', $langs->transnoentities('The' . ucfirst($object->element))), $langs->trans('ConfirmCloneObject', $langs->transnoentities('The' . ucfirst($object->element))), 'confirm_clone', $formQuestionClone, 'yes', 'actionButtonClone', 350, 600); - } + $formConfirm = saturneForm::actionConfirmation($action, $moreParams); - // SetValidated confirmation - if (($action == 'setValidated' && (empty($conf->use_javascript_ajax) || !empty($conf->dol_use_jmobile))) || (!empty($conf->use_javascript_ajax) && empty($conf->dol_use_jmobile))) { - $questionConfirmInfo = $langs->trans('ConfirmValidateObject', $langs->trans('TheAccident'), $langs->transnoentities('LesionsOrWorkStop')); - $formConfirm .= $form->formconfirm($_SERVER['PHP_SELF'] . '?id=' . $object->id, $langs->trans('ValidateObject', $langs->trans('TheAccident')), $questionConfirmInfo, 'confirm_validate', '', 'yes', 'actionButtonValidate', 250); - } - - // SetReOpen confirmation - if (($action == 'setReOpen' && (empty($conf->use_javascript_ajax) || !empty($conf->dol_use_jmobile))) || (!empty($conf->use_javascript_ajax) && empty($conf->dol_use_jmobile))) { - $questionConfirmInfo = $langs->trans('ConfirmReOpenObject', $langs->trans('TheAccident')); - $formConfirm .= $form->formconfirm($_SERVER['PHP_SELF'] . '?id=' . $object->id, $langs->trans('ReOpenObject', $langs->trans('TheAccident')), $questionConfirmInfo, 'confirm_setdraft', '', 'yes', 'actionButtonReOpen', 250); - } - - // Confirmation to lock - if (($action == 'lock' && (empty($conf->use_javascript_ajax) || !empty($conf->dol_use_jmobile))) || (!empty($conf->use_javascript_ajax) && empty($conf->dol_use_jmobile))) { - $formConfirm .= $form->formconfirm($_SERVER['PHP_SELF'] . '?id=' . $object->id, $langs->trans('LockObject', $langs->transnoentities('The' . ucfirst($object->element))), $langs->trans('ConfirmLockObject', $langs->transnoentities('The' . ucfirst($object->element))), 'confirm_lock', '', 'yes', 'actionButtonLock', 350, 600); - } - - // Archive confirmation - if (($action == 'set_archive' && (empty($conf->use_javascript_ajax) || !empty($conf->dol_use_jmobile))) || (!empty($conf->use_javascript_ajax) && empty($conf->dol_use_jmobile))) { - $formConfirm .= $form->formconfirm($_SERVER['PHP_SELF'] . '?id=' . $object->id . '&forcebuilddoc=true', $langs->trans('ArchiveObject', $langs->transnoentities('The' . ucfirst($object->element))), $langs->trans('ConfirmArchiveObject', $langs->transnoentities('The' . ucfirst($object->element))), 'confirm_archive', '', 'yes', 'actionButtonArchive', 350, 600); - } - - // Delete (need delete permission, or if draft, just need create/modify permission). - $displayButton = $onPhone ? '' : '' . ' ' . $langs->trans('Delete'); - print dolGetButtonAction($displayButton, '', 'delete', $_SERVER['PHP_SELF'] . '?id=' . $object->id . '&action=delete&token=' . newToken(), '', $permissiontodelete || ($object->status == AccidentInvestigation::STATUS_DRAFT)); - - - // Call Hook formConfirm. - $parameters = ['formConfirm' => $formConfirm]; - $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook. - - if (empty($reshook)) { - $formConfirm .= $hookmanager->resPrint; - } elseif ($reshook > 0) { - $formConfirm = $hookmanager->resPrint; - } - - // Print form confirm - print $formConfirm; + // Print form confirm + print $formConfirm; print '
'; print '
'; @@ -1108,83 +1059,19 @@ print '
'; print dol_get_fiche_end(); - if ($object->id > 0) { - // Buttons for actions - print '
'; - $parameters = []; - $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook - if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); - - if (empty($reshook)) { - $allSigned = $signatory->checkSignatoriesSignatures($id, $object->element); - - // Edit - $displayButton = $onPhone ? '' : '' . ' ' . $langs->trans('Modify'); - if ($object->status == $object::STATUS_DRAFT) { - print '' . $displayButton . ''; - } else { - print '' . $displayButton . ''; - } - - // Validate - $displayButton = $onPhone ? '' : '' . ' ' . $langs->trans('Validate'); - if ($object->status == $object::STATUS_DRAFT) { - print '' . $displayButton . ''; - } else { - print '' . $displayButton . ''; - } + if ($object->id > 0) { + // Buttons for actions + print '
'; - // ReOpen - $displayButton = $onPhone ? '' : '' . ' ' . $langs->trans('ReOpenDoli'); - if ($object->status == $object::STATUS_VALIDATED) { - print '' . $displayButton . ''; - } else { - print '' . $displayButton . ''; - } - - // Sign. - $displayButton = $onPhone ? '' : '' . ' ' . $langs->trans('Sign'); - if ($object->status == Accident::STATUS_VALIDATED && !$allSigned) { - print '' . $displayButton . ''; - } else { - print '' . $displayButton . ''; - } - - // Lock. - $displayButton = $onPhone ? '' : '' . ' ' . $langs->trans('Lock'); - if ($object->status == Accident::STATUS_VALIDATED && $allSigned) { - print '' . $displayButton . ''; - } else if ($object->status < Accident::STATUS_VALIDATED) { - print '' . $displayButton . ''; - } else { - print '' . $displayButton . ''; - } - - // Create Investigation. - $displayButton = $onPhone ? '' : ' ' . $langs->trans('AccidentInvestigation'); - if ($object->status == $object::STATUS_LOCKED) { - print '' . $displayButton . ''; - } else { - print '' . $displayButton . ''; - } - - // Archive - $displayButton = $onPhone ? '' : '' . ' ' . $langs->trans('Archive'); - if ($object->status == Accident::STATUS_LOCKED) { - print '' . $displayButton . ''; - } else { - print '' . $displayButton . ''; - } + $displayButton = $conf->browser->layout != 'classic' ? '' : ' ' . $langs->trans('AccidentInvestigation'); + if ($object->status == $object::STATUS_LOCKED) { + print '' . $displayButton . ''; + } - // Clone. - $displayButton = $onPhone ? '' : '' . ' ' . $langs->trans('ToClone'); - print '' . $displayButton . ''; + $moreParams['overrideShowSendEmailButton'] = true; + saturneForm::showButtons($object, $action, $moreParams); - // Delete (need delete permission, or if draft, just need create/modify permission). - $displayButton = $onPhone ? '' : '' . ' ' . $langs->trans('Delete'); - print dolGetButtonAction($displayButton, '', 'delete', $_SERVER['PHP_SELF'] . '?id=' . $object->id . '&action=delete&token=' . newToken(), '', $permissiontodelete); - } - print '
'; + print '
'; // Accident lesions include_once __DIR__ . '/../../core/tpl/accident/digiriskdolibarr_accident_lesion.tpl.php'; @@ -1193,7 +1080,7 @@ $accidentWorkstops = $objectline->fetchFromParent($object->id); // ACCIDENT LINES - print '
'; + print '
'; print load_fiche_titre($langs->trans("AccidentRiskList"), '', ''); print ''; diff --git a/view/accidentinvestigation/accidentinvestigation_card.php b/view/accidentinvestigation/accidentinvestigation_card.php index 5c58c80e9..1db22a036 100644 --- a/view/accidentinvestigation/accidentinvestigation_card.php +++ b/view/accidentinvestigation/accidentinvestigation_card.php @@ -40,6 +40,7 @@ require_once DOL_DOCUMENT_ROOT . '/core/lib/images.lib.php'; // Load Saturne libraries. +require_once __DIR__ . '/../../../saturne/class/saturneform.class.php'; require_once __DIR__ . '/../../../saturne/class/saturnesignature.class.php'; require_once __DIR__ . '/../../../saturne/class/task/saturnetask.class.php'; @@ -131,7 +132,7 @@ } } - if ($action == 'confirm_set_validate') { + if ($action == 'confirm_validate') { $result = $object->validate($user); if ($result > 0) { @@ -187,17 +188,17 @@ // Actions cancel, add, update, update_extras, confirm_validate, confirm_delete, confirm_deleteline, confirm_clone, confirm_close, confirm_setdraft, confirm_reopen require_once DOL_DOCUMENT_ROOT . '/core/actions_addupdatedelete.inc.php'; - // Actions save_project. + // Actions set_thirdparty, set_project require_once __DIR__ . '/../../../saturne/core/tpl/actions/banner_actions.tpl.php'; - // Actions builddoc, forcebuilddoc, remove_file. - require_once __DIR__ . '/../../../saturne/core/tpl/documents/documents_action.tpl.php'; + // Action confirm_lock, confirm_archive + require_once __DIR__ . '/../../../saturne/core/tpl/actions/object_workflow_actions.tpl.php'; - // Action to generate pdf from odt file. - require_once __DIR__ . '/../../../saturne/core/tpl/documents/saturne_manual_pdf_generation_action.tpl.php'; + // Actions builddoc, forcebuilddoc, remove_file + require_once __DIR__ . '/../../../saturne/core/tpl/documents/documents_action.tpl.php'; - // Action confirm_lock, confirm_archive. - require_once __DIR__ . '/../../../saturne/core/tpl/actions/object_workflow_actions.tpl.php'; + // Action to generate pdf from odt file + require_once __DIR__ . '/../../../saturne/core/tpl/documents/saturne_manual_pdf_generation_action.tpl.php'; // Actions to send emails. $triggersendname = strtoupper($object->element) . '_SENTBYMAIL'; @@ -284,48 +285,10 @@ saturne_get_fiche_head($object, 'card', $title); saturne_banner_tab($object); - $formConfirm = ''; + $formConfirm = saturneForm::actionConfirmation($action); - // Draft confirmation. - if (($action == 'set_draft' && (empty($conf->use_javascript_ajax) || !empty($conf->dol_use_jmobile))) || (!empty($conf->use_javascript_ajax) && empty($conf->dol_use_jmobile))) { - $formConfirm .= $form->formconfirm($_SERVER['PHP_SELF'] . '?id=' . $object->id, $langs->trans('ReOpenObject', $langs->transnoentities('The' . ucfirst($object->element))), $langs->trans('ConfirmReOpenObject', $langs->transnoentities('The' . ucfirst($object->element)), $langs->transnoentities('The' . ucfirst($object->element))), 'confirm_setdraft', '', 'yes', 'actionButtonInProgress', 350, 600); - } - // Validate confirmation - if (($action == 'set_validate' && (empty($conf->use_javascript_ajax) || !empty($conf->dol_use_jmobile))) || (!empty($conf->use_javascript_ajax) && empty($conf->dol_use_jmobile))) { - $formConfirm .= $form->formconfirm($_SERVER['PHP_SELF'] . '?id=' . $object->id, $langs->trans('ValidateObject', $langs->transnoentities('The' . ucfirst($object->element))), $langs->trans('ConfirmValidateObject', $langs->transnoentities('The' . ucfirst($object->element)), $langs->transnoentities('The' . ucfirst($object->element))), 'confirm_set_validate', '', 'yes', 'actionButtonValidate', 350, 600); - } - // Lock confirmation - if (($action == 'lock' && (empty($conf->use_javascript_ajax) || !empty($conf->dol_use_jmobile))) || (!empty($conf->use_javascript_ajax) && empty($conf->dol_use_jmobile))) { - $formConfirm .= $form->formconfirm($_SERVER['PHP_SELF'] . '?id=' . $object->id, $langs->trans('LockObject', $langs->transnoentities('The' . ucfirst($object->element))), $langs->trans('ConfirmLockObject', $langs->transnoentities('The' . ucfirst($object->element))), 'confirm_lock', '', 'yes', 'actionButtonLock', 350, 600); - } - // Archive confirmation - if (($action == 'set_archive' && (empty($conf->use_javascript_ajax) || !empty($conf->dol_use_jmobile))) || (!empty($conf->use_javascript_ajax) && empty($conf->dol_use_jmobile))) { - $formConfirm .= $form->formconfirm($_SERVER['PHP_SELF'] . '?id=' . $object->id . '&forcebuilddoc=true', $langs->trans('ArchiveObject', $langs->transnoentities('The' . ucfirst($object->element))), $langs->trans('ConfirmArchiveObject', $langs->transnoentities('The' . ucfirst($object->element))), 'confirm_archive', '', 'yes', 'actionButtonArchive', 350, 600); - } - // Clone confirmation - if (($action == 'clone' && (empty($conf->use_javascript_ajax) || !empty($conf->dol_use_jmobile))) || (!empty($conf->use_javascript_ajax) && empty($conf->dol_use_jmobile))) { - $formConfirm .= $form->formconfirm($_SERVER['PHP_SELF'] . '?id=' . $object->id, $langs->trans('CloneObject', $langs->transnoentities('The' . ucfirst($object->element))), $langs->trans('ConfirmCloneObject', $langs->transnoentities('The' . ucfirst($object->element))), 'confirm_clone', '', 'yes', 'actionButtonClone', 350, 600); - } - // Delete confirmation - if ($action == 'delete') { - $formConfirm .= $form->formconfirm($_SERVER['PHP_SELF'] . '?id=' . $object->id, $langs->trans('DeleteObject', $langs->transnoentities('The' . ucfirst($object->element))), $langs->trans('ConfirmDeleteObject', $langs->transnoentities('The' . ucfirst($object->element))), 'confirm_delete', '', 'yes', 1); - } - // Remove file confirmation - if ($action == 'removefile') { - $formConfirm .= $form->formconfirm($_SERVER['PHP_SELF'] . '?id=' . $object->id . '&file=' . GETPOST('file') . '&entity=' . $conf->entity, $langs->trans('RemoveFileObject'), $langs->trans('ConfirmRemoveFileObject', GETPOST('file')), 'remove_file', '', 'yes', 1, 350, 600); - } - - // Call Hook formConfirm. - $parameters = ['formConfirm' => $formConfirm]; - $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook. - if (empty($reshook)) { - $formConfirm .= $hookmanager->resPrint; - } elseif ($reshook > 0) { - $formConfirm = $hookmanager->resPrint; - } - - // Print form confirm. - print $formConfirm; + // Print form confirm + print $formConfirm; print '
'; print '
'; @@ -361,83 +324,11 @@ print '
'; - if ($action != 'presend') { - $allSigned = $signatory->checkSignatoriesSignatures($id, $object->element); - print '
'; - - // Edit - $displayButton = $onPhone ? '' : '' . ' ' . $langs->trans('Modify'); - if ($object->status == AccidentInvestigation::STATUS_DRAFT) { - print '' . $displayButton . ''; - } else { - print '' . $displayButton . ''; - } - - // Validate. - $displayButton = $onPhone ? '' : '' . ' ' . $langs->trans('Validate'); - if ($object->status == AccidentInvestigation::STATUS_DRAFT) { - print '' . $displayButton . ''; - } else { - print '' . $displayButton . ''; - } - - // Re-Open. - $displayButton = $onPhone ? '' : '' . ' ' . $langs->trans('ReOpenDoli'); - if ($object->status == AccidentInvestigation::STATUS_VALIDATED && !$allSigned) { - print '' . $displayButton . ''; - } else { - print '' . $displayButton . ''; - } - - // Sign. - $displayButton = $onPhone ? '' : '' . ' ' . $langs->trans('Sign'); - if ($object->status == AccidentInvestigation::STATUS_VALIDATED && !$allSigned) { - print '' . $displayButton . ''; - } else { - print '' . $displayButton . ''; - } - - // Lock. - $displayButton = $onPhone ? '' : '' . ' ' . $langs->trans('Lock'); - if ($object->status == AccidentInvestigation::STATUS_VALIDATED && $allSigned) { - print '' . $displayButton . ''; - } else if ($object->status < AccidentInvestigation::STATUS_VALIDATED) { - print '' . $displayButton . ''; - } else { - print '' . $displayButton . ''; - } - - // Send email. - $displayButton = $onPhone ? '' : '' . ' ' . $langs->trans('SendMail') . ' '; - if ($object->status >= AccidentInvestigation::STATUS_VALIDATED) { - print dolGetButtonAction($displayButton, '', 'default', $_SERVER['PHP_SELF'] . '?id=' . $object->id . '&action=presend&mode=init#formmailbeforetitle'); - } else { - print '' . $displayButton . ''; - } - - // Archive. - $displayButton = $onPhone ? '' : '' . ' ' . $langs->trans('Archive'); - if ($object->status == AccidentInvestigation::STATUS_LOCKED) { - print '' . $displayButton . ''; - } else { - print '' . $displayButton . ''; - } - - // Clone. - $displayButton = $onPhone ? '' : '' . ' ' . $langs->trans('ToClone'); - print '' . $displayButton . ''; - - // Delete (need delete permission, or if draft, just need create/modify permission). - $displayButton = $onPhone ? '' : '' . ' ' . $langs->trans('Delete'); - print dolGetButtonAction($displayButton, '', 'delete', $_SERVER['PHP_SELF'] . '?id=' . $object->id . '&action=delete&token=' . newToken(), '', $permissiontodelete || ($object->status == AccidentInvestigation::STATUS_DRAFT)); - - print '
'; - } - - // Select mail models is same action as presend. - if (GETPOST('modelselected')) { - $action = 'presend'; - } + if ($action != 'presend') { + print '
'; + saturneForm::showButtons($object, $action); + print '
'; + } if ($action != 'presend') { print '
'; diff --git a/view/firepermit/firepermit_card.php b/view/firepermit/firepermit_card.php index 19e372710..f85dafcb7 100644 --- a/view/firepermit/firepermit_card.php +++ b/view/firepermit/firepermit_card.php @@ -36,6 +36,7 @@ require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php'; // Load Saturne libraries. +require_once __DIR__ . '/../../../saturne/class/saturneform.class.php'; require_once __DIR__ . '/../../../saturne/class/saturnesignature.class.php'; // Load DigiriskDolibarr libraries. @@ -500,79 +501,44 @@ } } - // Actions set_thirdparty, set_project - require_once __DIR__ . '/../../../saturne/core/tpl/actions/banner_actions.tpl.php'; - - // Actions builddoc, forcebuilddoc, remove_file. - require_once __DIR__ . '/../../../saturne/core/tpl/documents/documents_action.tpl.php'; + // Action clone object + if ($action == 'confirm_clone' && $confirm == 'yes') { + $options['clone_label'] = GETPOST('clone_label'); + $options['firepermit_risk'] = GETPOST('clone_firepermit_risk'); + $options['attendants'] = GETPOST('clone_attendants'); + $options['schedule'] = GETPOST('clone_schedule'); + $options['categories'] = GETPOST('clone_categories'); - // Action to generate pdf from odt file - require_once __DIR__ . '/../../../saturne/core/tpl/documents/saturne_manual_pdf_generation_action.tpl.php'; + if (1 == 0 && ! GETPOST('clone_firepermit_risk') && ! GETPOST('clone_attendants') && ! GETPOST('clone_schedule')) { + setEventMessages($langs->trans("NoCloneOptionsSpecified"), null, 'errors'); + } else { + if ($object->id > 0) { + $result = $object->createFromClone($user, $object->id, $options); + if ($result > 0) { + header("Location: " . $_SERVER['PHP_SELF'] . '?id=' . $result); + exit(); + } else { + setEventMessages($object->error, $object->errors, 'errors'); + $action = ''; + } + } + } + } - // Action to set status STATUS_INPROGRESS - if ($action == 'confirm_setInProgress') { - $object->fetch($id); - if ( ! $error) { - $result = $object->setInProgress($user, false); - if ($result > 0) { - // Set In progress OK - $urltogo = str_replace('__ID__', $result, $backtopage); - $urltogo = preg_replace('/--IDFORBACKTOPAGE--/', $id, $urltogo); // New method to autoselect project after a New on another form object creation - header("Location: " . $urltogo); - exit; - } else { - // Set In progress KO - if ( ! empty($object->errors)) setEventMessages(null, $object->errors, 'errors'); - else setEventMessages($object->error, null, 'errors'); - } - } - } + // Actions cancel, add, update, update_extras, confirm_validate, confirm_delete, confirm_deleteline, confirm_clone, confirm_close, confirm_setdraft, confirm_reopen + require_once DOL_DOCUMENT_ROOT . '/core/actions_addupdatedelete.inc.php'; - // Action to set status STATUS_VALIDATED - if ($action == 'confirm_setPendingSignature') { - $object->fetch($id); - if ( ! $error) { - $result = $object->setPendingSignature($user, false); - if ($result > 0) { - // Set pending signature OK - $urltogo = str_replace('__ID__', $result, $backtopage); - $urltogo = preg_replace('/--IDFORBACKTOPAGE--/', $id, $urltogo); // New method to autoselect project after a New on another form object creation - header("Location: " . $urltogo); - exit; - } else { - // Set pending signature KO - if ( ! empty($object->errors)) setEventMessages(null, $object->errors, 'errors'); - else setEventMessages($object->error, null, 'errors'); - } - } - } + // Actions set_thirdparty, set_project + require_once __DIR__ . '/../../../saturne/core/tpl/actions/banner_actions.tpl.php'; - // Action confirm_lock, confirm_archive. + // Action confirm_lock, confirm_archive require_once __DIR__ . '/../../../saturne/core/tpl/actions/object_workflow_actions.tpl.php'; - // Action clone object - if ($action == 'confirm_clone' && $confirm == 'yes') { - $options['clone_label'] = GETPOST('clone_label'); - $options['firepermit_risk'] = GETPOST('clone_firepermit_risk'); - $options['attendants'] = GETPOST('clone_attendants'); - $options['schedule'] = GETPOST('clone_schedule'); - $options['categories'] = GETPOST('clone_categories'); + // Actions builddoc, forcebuilddoc, remove_file + require_once __DIR__ . '/../../../saturne/core/tpl/documents/documents_action.tpl.php'; - if (1 == 0 && ! GETPOST('clone_firepermit_risk') && ! GETPOST('clone_attendants') && ! GETPOST('clone_schedule')) { - setEventMessages($langs->trans("NoCloneOptionsSpecified"), null, 'errors'); - } else { - if ($object->id > 0) { - $result = $object->createFromClone($user, $object->id, $options); - if ($result > 0) { - header("Location: " . $_SERVER['PHP_SELF'] . '?id=' . $result); - exit(); - } else { - setEventMessages($object->error, $object->errors, 'errors'); - $action = ''; - } - } - } - } + // Action to generate pdf from odt file + require_once __DIR__ . '/../../../saturne/core/tpl/documents/saturne_manual_pdf_generation_action.tpl.php'; // Actions to send emails $triggersendname = 'FIREPERMIT_SENTBYMAIL'; @@ -881,60 +847,6 @@ print ''; } -$formconfirm = ''; - -// SetLocked confirmation -if (($action == 'setLocked' && (empty($conf->use_javascript_ajax) || ! empty($conf->dol_use_jmobile))) // Output when action = clone if jmobile or no js - || ( ! empty($conf->use_javascript_ajax) && empty($conf->dol_use_jmobile))) { // Always output when not jmobile nor js - $formconfirm .= $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('LockObject', $langs->transnoentities('The' . ucfirst($object->element))), $langs->trans('ConfirmLockObject', $langs->transnoentities('The' . ucfirst($object->element))), 'confirm_lock', '', 'yes', 'actionButtonLock', 350, 600); -} - -// setPendingSignature confirmation -if (($action == 'setPendingSignature' && (empty($conf->use_javascript_ajax) || ! empty($conf->dol_use_jmobile))) // Output when action = clone if jmobile or no js - || ( ! empty($conf->use_javascript_ajax) && empty($conf->dol_use_jmobile))) { // Always output when not jmobile nor js - $formconfirm .= $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('ValidateObject', $langs->transnoentities('The' . ucfirst($object->element))), $langs->trans('ConfirmValidateFirePermit', $object->ref), 'confirm_setPendingSignature', '', 'yes', 'actionButtonPendingSignature', 350, 600); -} - -// setInProgress confirmation -if (($action == 'setInProgress' && (empty($conf->use_javascript_ajax) || ! empty($conf->dol_use_jmobile))) // Output when action = clone if jmobile or no js - || ( ! empty($conf->use_javascript_ajax) && empty($conf->dol_use_jmobile))) { // Always output when not jmobile nor js - $formconfirm .= $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('ReOpenFirePermit'), $langs->trans('ConfirmReOpenFirePermit', $object->ref), 'confirm_setInProgress', '', 'yes', 'actionButtonInProgress', 350, 600); -} - -// Archive confirmation -if (($action == 'set_archive' && (empty($conf->use_javascript_ajax) || !empty($conf->dol_use_jmobile))) || (!empty($conf->use_javascript_ajax) && empty($conf->dol_use_jmobile))) { - $formconfirm .= $form->formconfirm($_SERVER['PHP_SELF'] . '?id=' . $object->id . '&forcebuilddoc=true', $langs->trans('ArchiveObject', $langs->transnoentities('The' . ucfirst($object->element))), $langs->trans('ConfirmArchiveObject', $langs->transnoentities('The' . ucfirst($object->element))), 'confirm_archive', '', 'yes', 'actionButtonArchive', 350, 600); -} - -// Clone confirmation -if (($action == 'clone' && (empty($conf->use_javascript_ajax) || ! empty($conf->dol_use_jmobile))) // Output when action = clone if jmobile or no js - || ( ! empty($conf->use_javascript_ajax) && empty($conf->dol_use_jmobile))) { // Always output when not jmobile nor js - // Define confirmation messages - $formquestionclone = ['text' => $langs->trans("ConfirmClone"), - ['type' => 'text', 'name' => 'clone_label', 'label' => $langs->trans("NewLabelForCloneFirePermit"), 'value' => empty($tmpcode) ? $langs->trans("CopyOf") . ' ' . $object->ref : $tmpcode, 'size' => 24], - ['type' => 'checkbox', 'name' => 'clone_firepermit_risk', 'label' => $langs->trans("CloneFirePermitRisk"), 'value' => 1], - ['type' => 'checkbox', 'name' => 'clone_attendants', 'label' => $langs->trans("CloneAttendantsFirePermit"), 'value' => 1], - ['type' => 'checkbox', 'name' => 'clone_schedule', 'label' => $langs->trans("CloneScheduleFirePermit"), 'value' => 1], - ['type' => 'checkbox', 'name' => 'clone_categories', 'label' => $langs->trans('CloneCategories'), 'value' => 1] - ]; - - $formconfirm .= $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('ToClone'), $langs->trans('ConfirmCloneFirePermit', $object->ref), 'confirm_clone', $formquestionclone, 'yes', 'actionButtonClone', 350, 600); -} - -// Confirmation to delete -if ($action == 'delete' && $permissiontodelete) { - $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('DeleteFirePermit'), $langs->trans('ConfirmDeleteFirePermit'), 'confirm_delete', '', 0, 1); -} - -// Call Hook formConfirm -$parameters = array('formConfirm' => $formconfirm, 'object' => $object); -$reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook -if (empty($reshook)) $formconfirm .= $hookmanager->resPrint; -elseif ($reshook > 0) $formconfirm = $hookmanager->resPrint; - -// Print form confirm -print $formconfirm; - // Part to show record if ((empty($action) || ($action != 'create' && $action != 'edit'))) { // Object card @@ -943,6 +855,21 @@ saturne_get_fiche_head($object, 'card', $title); + $formQuestionClone = ['text' => $langs->trans('ConfirmClone'), + ['type' => 'text', 'name' => 'clone_label', 'label' => $langs->trans('NewLabelForCloneFirePermit'), 'value' => $langs->trans('CopyOf') . ' ' . $object->ref, 'size' => 24], + ['type' => 'checkbox', 'name' => 'clone_firepermit_risk', 'label' => $langs->trans('CloneFirePermitRisk'), 'value' => 1], + ['type' => 'checkbox', 'name' => 'clone_attendants', 'label' => $langs->trans('CloneAttendantsFirePermit'), 'value' => 1], + ['type' => 'checkbox', 'name' => 'clone_schedule', 'label' => $langs->trans('CloneScheduleFirePermit'), 'value' => 1], + ['type' => 'checkbox', 'name' => 'clone_categories', 'label' => $langs->trans('CloneCategories'), 'value' => 1] + ]; + + $moreParams['cloneConfirmation'] = ['formQuestion' => $formQuestionClone, 'width' => 600]; + + $formConfirm = saturneForm::actionConfirmation($action, $moreParams); + + // Print form confirm + print $formConfirm; + // External Society -- Société extérieure $extSociety = $digiriskresources->fetchResourcesFromObject('ExtSociety', $object); $moreHtmlRef = $langs->trans('ExtSociety') . ' : ' . $extSociety->getNomUrl(1) . '
'; @@ -1017,20 +944,6 @@ } print ''; - //Attendants -- Participants - print '
'; - print ''; - // Categories if ($conf->categorie->enabled) { print ''; - //Attendants -- Participants - print ''; - print ''; - // Categories if ($conf->categorie->enabled) { print '
'; - print $langs->trans("Attendants"); - print ''; - $attendants = count($signatory->fetchSignatory('MasterWorker', $object->id, 'firepermit')); - $attendants += count($signatory->fetchSignatory('ExtSocietyResponsible', $object->id, 'firepermit')); - $attendants += count($signatory->fetchSignatory('ExtSocietyAttendant', $object->id, 'firepermit')); - $url = dol_buildpath('/custom/saturne/view/saturne_attendants.php?id=' . $object->id . '&module_name=DigiriskDolibarr&object_type=' . $object->element . '&document_type=FirePermitDocument', 3); - $displayButton = $onPhone ? '' : ' ' . $langs->trans('AddAttendants'); - print 'status == 1 ? 'href="' . $url . '"' : '') . '">' . $attendants; - print '' . $displayButton . ''; - print '
'.$langs->trans("Categories").''; @@ -1044,87 +957,11 @@ print dol_get_fiche_end(); - if ($object->id > 0) { - // Buttons for actions - print '
'; - $parameters = array(); - $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook - if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); - - if (empty($reshook) && $permissiontoadd) { - // Modify - $displayButton = $onPhone ? '' : '' . ' ' . $langs->trans('Modify'); - if ($object->status == $object::STATUS_DRAFT) { - print '' . $displayButton . ''; - } else { - print '' . $displayButton . ''; - } - - // Validate - $displayButton = $onPhone ? '' : '' . ' ' . $langs->trans('Validate'); - if ($object->status == $object::STATUS_DRAFT) { - print '' . $displayButton . ''; - } else { - print '' . $displayButton . ''; - } - - // ReOpen - $displayButton = $onPhone ? '' : '' . ' ' . $langs->trans('ReOpenDoli'); - if ($object->status == $object::STATUS_VALIDATED) { - print '' . $displayButton . ''; - } else { - print '' . $displayButton . ''; - } - - // Sign - $displayButton = $onPhone ? '' : '' . ' ' . $langs->trans('Sign'); - if ($object->status == $object::STATUS_VALIDATED && !$signatory->checkSignatoriesSignatures($object->id, $object->element)) { - print '' . $displayButton . ''; - } else { - print '' . $displayButton . ''; - } - - // Lock - $displayButton = $onPhone ? '' : '' . ' ' . $langs->trans('Lock'); - if ($object->status == $object::STATUS_VALIDATED && $signatory->checkSignatoriesSignatures($object->id, $object->element)) { - print '' . $displayButton . ''; - } else { - print '' . $displayButton . ''; - } - - // Send email - $displayButton = $onPhone ? '' : '' . ' ' . $langs->trans('SendMail') . ' '; - if ($object->status == FirePermit::STATUS_LOCKED) { - $fileParams = dol_most_recent_file($upload_dir . '/' . $object->element . 'document' . '/' . $object->ref); - $file = $fileParams['fullname']; - if (file_exists($file) && !strstr($fileParams['name'], 'specimen')) { - $forcebuilddoc = 0; - } else { - $forcebuilddoc = 1; - } - print dolGetButtonAction($displayButton, '', 'default', $_SERVER['PHP_SELF'] . '?id=' . $object->id . '&action=presend&forcebuilddoc=' . $forcebuilddoc . '&mode=init#formmailbeforetitle'); - } else { - print '' . $displayButton . ''; - } - - // Archive - $displayButton = $onPhone ? '' : '' . ' ' . $langs->trans('Archive'); - if ($object->status == $object::STATUS_LOCKED) { - print '' . $displayButton . ''; - } else { - print '' . $displayButton . ''; - } - - // Clone - $displayButton = $onPhone ? '' : '' . ' ' . $langs->trans('ToClone'); - print '' . $displayButton . ''; - - // Delete (need delete permission, or if draft, just need create/modify permission). - $displayButton = $onPhone ? '' : '' . ' ' . $langs->trans('Delete'); - print dolGetButtonAction($displayButton, '', 'delete', $_SERVER['PHP_SELF'] . '?id=' . $object->id . '&action=delete&token=' . newToken(), '', $permissiontodelete || ($object->status == AccidentInvestigation::STATUS_DRAFT)); - } - print '
'; - + if ($object->id > 0) { + // Buttons for actions + print '
'; + saturneForm::showButtons($object, $action); + print '
'; // PREVENTIONPLAN LINES print '
'; diff --git a/view/preventionplan/preventionplan_card.php b/view/preventionplan/preventionplan_card.php index 09711a6e3..058906e94 100644 --- a/view/preventionplan/preventionplan_card.php +++ b/view/preventionplan/preventionplan_card.php @@ -38,6 +38,7 @@ require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php'; // Load Saturne libraries. +require_once __DIR__ . '/../../../saturne/class/saturneform.class.php'; require_once __DIR__ . '/../../../saturne/class/saturnesignature.class.php'; // Load DigiriskDolibarr libraries. @@ -507,79 +508,44 @@ } } - // Actions set_thirdparty, set_project - require_once __DIR__ . '/../../../saturne/core/tpl/actions/banner_actions.tpl.php'; + // Action clone object + if ($action == 'confirm_clone' && $confirm == 'yes') { + $options['clone_label'] = GETPOST('clone_label'); + $options['preventionplan_risk'] = GETPOST('clone_preventionplan_risk'); + $options['attendants'] = GETPOST('clone_attendants'); + $options['schedule'] = GETPOST('clone_schedule'); + $options['categories'] = GETPOST('clone_categories'); - // Actions builddoc, forcebuilddoc, remove_file. - require_once __DIR__ . '/../../../saturne/core/tpl/documents/documents_action.tpl.php'; + if (1 == 0 && ! GETPOST('clone_preventionplan_risk') && ! GETPOST('clone_attendants') && ! GETPOST('clone_schedule')) { + setEventMessages($langs->trans("NoCloneOptionsSpecified"), null, 'errors'); + } else { + if ($object->id > 0) { + $result = $object->createFromClone($user, $object->id, $options); + if ($result > 0) { + header("Location: " . $_SERVER['PHP_SELF'] . '?id=' . $result); + exit(); + } else { + setEventMessages($object->error, $object->errors, 'errors'); + $action = ''; + } + } + } + } - // Action to generate pdf from odt file - require_once __DIR__ . '/../../../saturne/core/tpl/documents/saturne_manual_pdf_generation_action.tpl.php'; + // Actions cancel, add, update, update_extras, confirm_validate, confirm_delete, confirm_deleteline, confirm_clone, confirm_close, confirm_setdraft, confirm_reopen + require_once DOL_DOCUMENT_ROOT . '/core/actions_addupdatedelete.inc.php'; - // Action to set status STATUS_INPROGRESS - if ($action == 'confirm_setInProgress') { - $object->fetch($id); - if ( ! $error) { - $result = $object->setInProgress($user, false); - if ($result > 0) { - // Set In progress OK - $urltogo = str_replace('__ID__', $result, $backtopage); - $urltogo = preg_replace('/--IDFORBACKTOPAGE--/', $id, $urltogo); // New method to autoselect project after a New on another form object creation - header("Location: " . $urltogo); - exit; - } else { - // Set In progress KO - if ( ! empty($object->errors)) setEventMessages(null, $object->errors, 'errors'); - else setEventMessages($object->error, null, 'errors'); - } - } - } - - // Action to set status STATUS_VALIDATED - if ($action == 'confirm_setPendingSignature') { - $object->fetch($id); - if ( ! $error) { - $result = $object->setPendingSignature($user, false); - if ($result > 0) { - // Set pending signature OK - $urltogo = str_replace('__ID__', $result, $backtopage); - $urltogo = preg_replace('/--IDFORBACKTOPAGE--/', $id, $urltogo); // New method to autoselect project after a New on another form object creation - header("Location: " . $urltogo); - exit; - } else { - // Set pending signature KO - if ( ! empty($object->errors)) setEventMessages(null, $object->errors, 'errors'); - else setEventMessages($object->error, null, 'errors'); - } - } - } + // Actions set_thirdparty, set_project + require_once __DIR__ . '/../../../saturne/core/tpl/actions/banner_actions.tpl.php'; - // Action confirm_lock, confirm_archive. + // Action confirm_lock, confirm_archive require_once __DIR__ . '/../../../saturne/core/tpl/actions/object_workflow_actions.tpl.php'; - // Action clone object - if ($action == 'confirm_clone' && $confirm == 'yes') { - $options['clone_label'] = GETPOST('clone_label'); - $options['preventionplan_risk'] = GETPOST('clone_preventionplan_risk'); - $options['attendants'] = GETPOST('clone_attendants'); - $options['schedule'] = GETPOST('clone_schedule'); - $options['categories'] = GETPOST('clone_categories'); + // Actions builddoc, forcebuilddoc, remove_file + require_once __DIR__ . '/../../../saturne/core/tpl/documents/documents_action.tpl.php'; - if (1 == 0 && ! GETPOST('clone_preventionplan_risk') && ! GETPOST('clone_attendants') && ! GETPOST('clone_schedule')) { - setEventMessages($langs->trans("NoCloneOptionsSpecified"), null, 'errors'); - } else { - if ($object->id > 0) { - $result = $object->createFromClone($user, $object->id, $options); - if ($result > 0) { - header("Location: " . $_SERVER['PHP_SELF'] . '?id=' . $result); - exit(); - } else { - setEventMessages($object->error, $object->errors, 'errors'); - $action = ''; - } - } - } - } + // Action to generate pdf from odt file + require_once __DIR__ . '/../../../saturne/core/tpl/documents/saturne_manual_pdf_generation_action.tpl.php'; // Actions to send emails $triggersendname = 'PREVENTIONPLAN_SENTBYMAIL'; @@ -923,60 +889,6 @@ print ''; } -$formconfirm = ''; - -// SetLocked confirmation -if (($action == 'setLocked' && (empty($conf->use_javascript_ajax) || ! empty($conf->dol_use_jmobile))) // Output when action = clone if jmobile or no js - || ( ! empty($conf->use_javascript_ajax) && empty($conf->dol_use_jmobile))) { // Always output when not jmobile nor js - $formconfirm .= $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('LockObject', $langs->transnoentities('The' . ucfirst($object->element))), $langs->trans('ConfirmLockObject', $langs->transnoentities('The' . ucfirst($object->element))), 'confirm_lock', '', 'yes', 'actionButtonLock', 350, 600); -} - -// setPendingSignature confirmation -if (($action == 'setPendingSignature' && (empty($conf->use_javascript_ajax) || ! empty($conf->dol_use_jmobile))) // Output when action = clone if jmobile or no js - || ( ! empty($conf->use_javascript_ajax) && empty($conf->dol_use_jmobile))) { // Always output when not jmobile nor js - $formconfirm .= $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('ValidatePreventionPlan'), $langs->trans('ConfirmValidatePreventionPlan', $object->ref), 'confirm_setPendingSignature', '', 'yes', 'actionButtonPendingSignature', 350, 600); -} - -// setInProgress confirmation -if (($action == 'setInProgress' && (empty($conf->use_javascript_ajax) || ! empty($conf->dol_use_jmobile))) // Output when action = clone if jmobile or no js - || ( ! empty($conf->use_javascript_ajax) && empty($conf->dol_use_jmobile))) { // Always output when not jmobile nor js - $formconfirm .= $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('ReOpenPreventionPlan'), $langs->trans('ConfirmReOpenPreventionPlan', $object->ref), 'confirm_setInProgress', '', 'yes', 'actionButtonInProgress', 350, 600); -} - -// Archive confirmation -if (($action == 'set_archive' && (empty($conf->use_javascript_ajax) || !empty($conf->dol_use_jmobile))) || (!empty($conf->use_javascript_ajax) && empty($conf->dol_use_jmobile))) { - $formconfirm .= $form->formconfirm($_SERVER['PHP_SELF'] . '?id=' . $object->id . '&forcebuilddoc=true', $langs->trans('ArchiveObject', $langs->transnoentities('The' . ucfirst($object->element))), $langs->trans('ConfirmArchiveObject', $langs->transnoentities('The' . ucfirst($object->element))), 'confirm_archive', '', 'yes', 'actionButtonArchive', 350, 600); -} - -// Clone confirmation -if (($action == 'clone' && (empty($conf->use_javascript_ajax) || ! empty($conf->dol_use_jmobile))) // Output when action = clone if jmobile or no js - || ( ! empty($conf->use_javascript_ajax) && empty($conf->dol_use_jmobile))) { // Always output when not jmobile nor js - // Define confirmation messages - $formquestionclone = ['text' => $langs->trans("ConfirmClone"), - ['type' => 'text', 'name' => 'clone_label', 'label' => $langs->trans("NewLabelForClonePreventionPlan"), 'value' => empty($tmpcode) ? $langs->trans("CopyOf") . ' ' . $object->ref : $tmpcode, 'size' => 24], - ['type' => 'checkbox', 'name' => 'clone_preventionplan_risk', 'label' => $langs->trans("ClonePreventionPlanRisk"), 'value' => 1], - ['type' => 'checkbox', 'name' => 'clone_attendants', 'label' => $langs->trans("CloneAttendantsPreventionPlan"), 'value' => 1], - ['type' => 'checkbox', 'name' => 'clone_schedule', 'label' => $langs->trans("CloneSchedulePreventionPlan"), 'value' => 1], - ['type' => 'checkbox', 'name' => 'clone_categories', 'label' => $langs->trans('CloneCategories'), 'value' => 1] - ]; - - $formconfirm .= $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('ToClone'), $langs->trans('ConfirmClonePreventionPlan', $object->ref), 'confirm_clone', $formquestionclone, 'yes', 'actionButtonClone', 350, 600); -} - -// Delete confirmation -if ($action == 'delete' && $permissiontodelete) { - $formconfirm .= $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$object->id, $langs->trans("DeletePreventionPlan"), $langs->trans('ConfirmDeletePreventionPlan'), "confirm_delete", '', '', 1); -} - -// Call Hook formConfirm -$parameters = array('formConfirm' => $formconfirm, 'object' => $object); -$reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook -if (empty($reshook)) $formconfirm .= $hookmanager->resPrint; -elseif ($reshook > 0) $formconfirm = $hookmanager->resPrint; - -// Print form confirm -print $formconfirm; - // Part to show record if ((empty($action) || ($action != 'create' && $action != 'edit'))) { // Object card @@ -986,6 +898,22 @@ saturne_get_fiche_head($object, 'card', $title); + $formQuestionClone = ['text' => $langs->trans('ConfirmClone'), + ['type' => 'text', 'name' => 'clone_label', 'label' => $langs->trans('NewLabelForClonePreventionPlan'), 'value' => $langs->trans('CopyOf') . ' ' . $object->ref, 'size' => 24], + ['type' => 'checkbox', 'name' => 'clone_preventionplan_risk', 'label' => $langs->trans('ClonePreventionPlanRisk'), 'value' => 1], + ['type' => 'checkbox', 'name' => 'clone_attendants', 'label' => $langs->trans('CloneAttendantsPreventionPlan'), 'value' => 1], + ['type' => 'checkbox', 'name' => 'clone_schedule', 'label' => $langs->trans('CloneSchedulePreventionPlan'), 'value' => 1], + ['type' => 'checkbox', 'name' => 'clone_categories', 'label' => $langs->trans('CloneCategories'), 'value' => 1] + ]; + + $moreParams['cloneConfirmation'] = ['formQuestion' => $formQuestionClone, 'width' => 600]; + + $formConfirm = saturneForm::actionConfirmation($action, $moreParams); + + // Print form confirm + print $formConfirm; + + // External Society -- Société extérieure $extSociety = $digiriskresources->fetchResourcesFromObject('ExtSociety', $object); $moreHtmlRef = $langs->trans('ExtSociety') . ' : ' . $extSociety->getNomUrl(1) . '
'; @@ -1087,20 +1015,6 @@ } print '
'; - print $langs->trans("Attendants"); - print ''; - $attendants = count($signatory->fetchSignatory('MasterWorker', $object->id, 'preventionplan')); - $attendants += count($signatory->fetchSignatory('ExtSocietyResponsible', $object->id, 'preventionplan')); - $attendants += count($signatory->fetchSignatory('ExtSocietyAttendant', $object->id, 'preventionplan')); - $url = dol_buildpath('/custom/saturne/view/saturne_attendants.php?id=' . $object->id . '&module_name=DigiriskDolibarr&object_type=' . $object->element . '&document_type=PreventionPlanDocument', 3); - $displayButton = $onPhone ? '' : ' ' . $langs->trans('AddAttendants'); - print 'status == 1 ? 'href="' . $url . '"' : '') . '">' . $attendants; - print '' . $displayButton . ''; - print '
'.$langs->trans("Categories").''; @@ -1114,85 +1028,11 @@ print dol_get_fiche_end(); - if ($object->id > 0) { - // Buttons for actions - print '
'; - $parameters = array(); - $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook - if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); - - if (empty($reshook) && $permissiontoadd) { - // Modify - $displayButton = $onPhone ? '' : '' . ' ' . $langs->trans('Modify'); - if ($object->status == $object::STATUS_DRAFT) { - print '' . $displayButton . ''; - } else { - print '' . $displayButton . ''; - } - - // Validate - $displayButton = $onPhone ? '' : '' . ' ' . $langs->trans('Validate'); - if ($object->status == $object::STATUS_DRAFT) { - print '' . $displayButton . ''; - } else { - print '' . $displayButton . ''; - } - - // ReOpen - $displayButton = $onPhone ? '' : '' . ' ' . $langs->trans('ReOpenDoli'); - if ($object->status == $object::STATUS_VALIDATED) { - print '' . $displayButton . ''; - } else { - print '' . $displayButton . ''; - } - - // Sign - $displayButton = $onPhone ? '' : '' . ' ' . $langs->trans('Sign'); - if ($object->status == $object::STATUS_VALIDATED && !$signatory->checkSignatoriesSignatures($object->id, $object->element)) { - print '' . $displayButton . ''; - } else { - print '' . $displayButton . ''; - } - - // Lock - $displayButton = $onPhone ? '' : '' . ' ' . $langs->trans('Lock'); - if ($object->status == $object::STATUS_VALIDATED && $signatory->checkSignatoriesSignatures($object->id, $object->element)) { - print '' . $displayButton . ''; - } else { - print '' . $displayButton . ''; - } - - // Send email - $displayButton = $onPhone ? '' : '' . ' ' . $langs->trans('SendMail') . ' '; - if ($object->status == PreventionPlan::STATUS_LOCKED) { - $fileParams = dol_most_recent_file($upload_dir . '/' . $object->element . 'document' . '/' . $object->ref); - $file = $fileParams['fullname']; - if (file_exists($file) && !strstr($fileParams['name'], 'specimen')) { - $forcebuilddoc = 0; - } else { - $forcebuilddoc = 1; - } - print dolGetButtonAction($displayButton, '', 'default', $_SERVER['PHP_SELF'] . '?id=' . $object->id . '&action=presend&forcebuilddoc=' . $forcebuilddoc . '&mode=init#formmailbeforetitle'); - } else { - print '' . $displayButton . ''; - } - - // Archive - $displayButton = $onPhone ? '' : '' . ' ' . $langs->trans('Archive'); - if ($object->status == $object::STATUS_LOCKED) { - print '' . $displayButton . ''; - } else { - print '' . $displayButton . ''; - } - - // Clone - $displayButton = $onPhone ? '' : '' . ' ' . $langs->trans('ToClone'); - print '' . $displayButton . ''; - - $displayButton = $onPhone ? '' : '' . ' ' . $langs->trans('Delete'); - print dolGetButtonAction($displayButton, '', 'delete', $_SERVER['PHP_SELF'] . '?id=' . $object->id . '&action=delete&token=' . newToken(), '', $permissiontodelete || ($object->status == AccidentInvestigation::STATUS_DRAFT)); - } - print '
'; + if ($object->id > 0) { + // Buttons for actions + print '
'; + saturneForm::showButtons($object, $action); + print '
'; // PREVENTIONPLAN LINES print '
';