diff --git a/view/control/control_card.php b/view/control/control_card.php index 19ba3012..515e021e 100644 --- a/view/control/control_card.php +++ b/view/control/control_card.php @@ -534,6 +534,11 @@ $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))) . ($object->verdict == 2 ? '
' . $langs->transnoentities('BeCarefullVerdictKO') : ''), '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))) { // Define confirmation messages @@ -869,8 +874,8 @@ // Archive $displayButton = $onPhone ? '' : '' . ' ' . $langs->trans('Archive'); - if ($object->status == Control::STATUS_LOCKED && !empty(dol_dir_list($upload_dir . '/' . $object->element . 'document/' . dol_sanitizeFileName($object->ref)))) { - print '' . $displayButton . ''; + if ($object->status == Control::STATUS_LOCKED) { + print '' . $displayButton . ''; } else { print '' . $displayButton . ''; } @@ -925,7 +930,7 @@ $fileDir = $upload_dir . '/' . $dirFiles; $urlSource = $_SERVER['PHP_SELF'] . '?id=' . $object->id; - print saturne_show_documents('digiquali:' . ucfirst($object->element) . 'Document', $dirFiles, $fileDir, $urlSource, $permissiontoadd, $permissiontodelete, $conf->global->DIGIQUALI_CONTROLDOCUMENT_DEFAULT_MODEL, 1, 0, 0, 0, '', '', '', $langs->defaultlang, '', $object, 0, 'remove_file', (($object->status > CONTROL::STATUS_DRAFT) ? 1 : 0), $langs->trans('ObjectMustBeValidatedToGenerate', ucfirst($langs->transnoentities('The' . ucfirst($object->element))))); + print saturne_show_documents('digiquali:' . ucfirst($object->element) . 'Document', $dirFiles, $fileDir, $urlSource, $permissiontoadd, $permissiontodelete, $conf->global->DIGIQUALI_CONTROLDOCUMENT_DEFAULT_MODEL, 1, 0, 0, 0, '', '', '', $langs->defaultlang, '', $object, 0, 'remove_file', (($object->status > CONTROL::STATUS_DRAFT && $object->status != CONTROL::STATUS_ARCHIVED) ? 1 : 0), $langs->trans('ObjectMustBeValidatedToGenerate', ucfirst($langs->transnoentities('The' . ucfirst($object->element))))); print ''; print '
'; diff --git a/view/question/question_card.php b/view/question/question_card.php index 0ef99d1c..752d85c8 100644 --- a/view/question/question_card.php +++ b/view/question/question_card.php @@ -664,43 +664,8 @@ // Actions cancel, add, update, update_extras, confirm_validate, confirm_delete, confirm_deleteline, confirm_clone, confirm_close, confirm_setdraft, confirm_reopen include DOL_DOCUMENT_ROOT.'/core/actions_addupdatedelete.inc.php'; - // Action to set status STATUS_LOCKED - if ($action == 'confirm_lock') { - $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 == 'confirm_archive' && $permissiontoadd) { - $object->fetch($id); - if (!$error) { - $result = $object->setArchived($user); - 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; - } elseif (!empty($object->errors)) { // Set Archived KO - setEventMessages('', $object->errors, 'errors'); - } else { - setEventMessages($object->error, [], 'errors'); - } - } - } + // Action confirm_lock, confirm_archive. + require_once __DIR__ . '/../../../saturne/core/tpl/actions/object_workflow_actions.tpl.php'; } /* @@ -985,6 +950,11 @@ $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)), $object->ref), 'confirm_clone', $formquestionclone, 'yes', 'actionButtonClone', 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, $langs->trans('ArchiveObject', $langs->transnoentities('The' . ucfirst($object->element))), $langs->trans('ConfirmArchiveObject', $langs->transnoentities('The' . ucfirst($object->element))), 'confirm_archive', '', 'yes', 'actionButtonArchive', 350, 600); + } + // Confirmation to delete if ($action == 'delete') { $formconfirm = $form->formconfirm($_SERVER['PHP_SELF'] . '?id=' . $object->id, $langs->trans('Delete') . ' ' . $langs->transnoentities('The' . ucfirst($object->element)), $langs->trans('ConfirmDeleteObject', $langs->transnoentities('The' . ucfirst($object->element))), 'confirm_delete', '', 'yes', 1); @@ -1110,7 +1080,7 @@ // Archive if ($object->status == $object::STATUS_LOCKED) { - print ' ' . $langs->trans('Archive') . ''; + print ' ' . $langs->trans('Archive') . ''; } else { print ' ' . $langs->trans('Archive') . ''; } diff --git a/view/sheet/sheet_card.php b/view/sheet/sheet_card.php index afa22db3..f28b7c17 100644 --- a/view/sheet/sheet_card.php +++ b/view/sheet/sheet_card.php @@ -238,54 +238,8 @@ // Actions cancel, add, update, update_extras, confirm_validate, confirm_delete, confirm_deleteline, confirm_clone, confirm_close, confirm_setdraft, confirm_reopen include DOL_DOCUMENT_ROOT.'/core/actions_addupdatedelete.inc.php'; - // Action to set status STATUS_LOCKED - if ($action == 'confirm_lock' && $permissiontoadd) { - $object->fetch($id); - if ( ! $error) { - $result = $object->setLocked($user, false); - if ($result > 0) { - // Need update question status because import allow STATUS_VALIDATED prohibed single add - if ($object->import_key > 0) { - $object->fetchObjectLinked($id, 'digiquali_' . $object->element); - if (is_array($object->linkedObjects['digiquali_question']) && !empty($object->linkedObjects['digiquali_question'])) { - foreach ($object->linkedObjects['digiquali_question'] as $question) { - if ($question->status == Question::STATUS_VALIDATED) { - $question->setLocked($user, false); - } - } - } - } - // 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 == 'confirm_archive' && $permissiontoadd) { - $object->fetch($id); - if (!$error) { - $result = $object->setArchived($user); - 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; - } elseif (!empty($object->errors)) { // Set Archived KO. - setEventMessages('', $object->errors, 'errors'); - } else { - setEventMessages($object->error, [], 'errors'); - } - } - } + // Action confirm_lock, confirm_archive. + require_once __DIR__ . '/../../../saturne/core/tpl/actions/object_workflow_actions.tpl.php'; if ($action == 'set_mandatory' && $permissiontoadd) { $questionId = GETPOST('questionId', 'int'); @@ -511,6 +465,11 @@ $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)), $object->ref), 'confirm_clone', '', 'yes', 'actionButtonClone', 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); + } + // Confirmation to delete if ($action == 'delete') { $formconfirm = $form->formconfirm($_SERVER['PHP_SELF'] . '?id=' . $object->id, $langs->trans('Delete') . ' ' . $langs->transnoentities('The' . ucfirst($object->element)), $langs->trans('ConfirmDeleteObject', $langs->transnoentities('The' . ucfirst($object->element))), 'confirm_delete', '', 'yes', 1); @@ -651,7 +610,7 @@ // Archive if ($object->status == $object::STATUS_LOCKED) { - print ' ' . $langs->trans('Archive') . ''; + print ' ' . $langs->trans('Archive') . ''; } else { print ' ' . $langs->trans('Archive') . ''; } diff --git a/view/survey/survey_card.php b/view/survey/survey_card.php index 7a21a691..c9cde631 100644 --- a/view/survey/survey_card.php +++ b/view/survey/survey_card.php @@ -386,6 +386,11 @@ $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))) { // Define confirmation messages @@ -665,8 +670,8 @@ // Archive $displayButton = $onPhone ? '' : '' . ' ' . $langs->trans('Archive'); - if ($object->status == Survey::STATUS_LOCKED && !empty(dol_dir_list($upload_dir . '/'. $object->element . 'document/' . dol_sanitizeFileName($object->ref)))) { - print '' . $displayButton . ''; + if ($object->status == Survey::STATUS_LOCKED) { + print '' . $displayButton . ''; } else { print '' . $displayButton . ''; } @@ -721,7 +726,7 @@ $fileDir = $upload_dir . '/' . $dirFiles; $urlSource = $_SERVER['PHP_SELF'] . '?id=' . $object->id; - print saturne_show_documents('digiquali:' . ucfirst($object->element) . 'Document', $dirFiles, $fileDir, $urlSource, $permissiontoadd, $permissiontodelete, $conf->global->DIGIQUALI_SURVEYDOCUMENT_DEFAULT_MODEL, 1, 0, 0, 0, '', '', '', $langs->defaultlang, '', $object, 0, 'remove_file', (($object->status > Survey::STATUS_DRAFT) ? 1 : 0), $langs->trans('ObjectMustBeValidatedToGenerate', ucfirst($langs->transnoentities('The' . ucfirst($object->element))))); + print saturne_show_documents('digiquali:' . ucfirst($object->element) . 'Document', $dirFiles, $fileDir, $urlSource, $permissiontoadd, $permissiontodelete, $conf->global->DIGIQUALI_SURVEYDOCUMENT_DEFAULT_MODEL, 1, 0, 0, 0, '', '', '', $langs->defaultlang, '', $object, 0, 'remove_file', (($object->status > Survey::STATUS_DRAFT && $object->status != Survey::STATUS_ARCHIVED) ? 1 : 0), $langs->trans('ObjectMustBeValidatedToGenerate', ucfirst($langs->transnoentities('The' . ucfirst($object->element))))); print '
';