Skip to content

Commit

Permalink
Merge pull request #1759 from Evarisk/develop
Browse files Browse the repository at this point in the history
1.11.0
  • Loading branch information
nicolas-eoxia authored Mar 12, 2024
2 parents bad91a8 + da60f9f commit 3504174
Show file tree
Hide file tree
Showing 79 changed files with 5,446 additions and 2,041 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,18 @@
## Informations

- Numéro du module : 436301
- Dernière mise à jour : 15/01/2023
- Dernière mise à jour : 07/03/2023
- Éditeur : [Evarisk](https://evarisk.com)
- Thème : Eldy Menu
- Licence : GPLv3
- Disponible sur : Windows - MacOS - Linux

### Version

- Version : 1.10.0
- Version : 1.11.0
- PHP : 7.4.33
- Compatibilité : Dolibarr 17.0.0 - 18.0.4
- Saturne Framework : 1.2.1
- Compatibilité : Dolibarr 17.0.0 - 18.0.5
- Saturne Framework : 1.3.0

## Liens

Expand Down
232 changes: 35 additions & 197 deletions admin/control.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php
/* Copyright (C) 2022-2023 EVARISK <[email protected]>
/* Copyright (C) 2022-2024 EVARISK <[email protected]>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand All @@ -18,33 +18,31 @@
/**
* \file admin/control.php
* \ingroup digiquali
* \brief DigiQuali control config page.
* \brief DigiQuali control config page
*/

// Load DigiQuali environment
if (file_exists('../digiquali.main.inc.php')) {
require_once __DIR__ . '/../digiquali.main.inc.php';
require_once __DIR__ . '/../digiquali.main.inc.php';
} elseif (file_exists('../../digiquali.main.inc.php')) {
require_once __DIR__ . '/../../digiquali.main.inc.php';
require_once __DIR__ . '/../../digiquali.main.inc.php';
} else {
die('Include of digiquali main fails');
die('Include of digiquali main fails');
}

// Libraries
// Load Dolibarr libraries
require_once DOL_DOCUMENT_ROOT . '/core/lib/admin.lib.php';

require_once __DIR__ . '/../lib/digiquali.lib.php';
// Load DigiQuali libraries
require_once __DIR__ . '/../class/control.class.php';
require_once __DIR__ . '/../lib/digiquali.lib.php';

// Global variables definitions
global $conf, $db, $langs, $user;
global $conf, $db, $hookmanager, $langs, $moduleName, $moduleNameLowerCase, $user;

// Load translation files required by the page
saturne_load_langs(['admin']);

// Initialize view objects
$form = new Form($db);

// Get parameters
$action = GETPOST('action', 'alpha');
$backtopage = GETPOST('backtopage', 'alpha');
Expand All @@ -55,19 +53,18 @@
$tmptype2label = ExtraFields::$type2label;
$type2label = [''];
foreach ($tmptype2label as $key => $val) {
$type2label[$key] = $langs->transnoentitiesnoconv($val);
$type2label[$key] = $langs->transnoentitiesnoconv($val);
}

// Initialize objects
$object = new Control($db);
$elementType = $object->element;
$objectType = $object->element;
$elementtype = $moduleNameLowerCase . '_' . $objectType; // Must be the $table_element of the class that manage extrafield.
$object = new Control($db);

$hookmanager->initHooks(['controladmin', 'globalcard']); // Note that conf->hooks_modules contains array

$error = 0; //Error counter
$elementtype = $moduleNameLowerCase . '_' . $object->element; // Must be the $table_element of the class that manage extrafield

// Security check - Protection if external user
$permissiontoread = $user->rights->digiquali->adminpage->read;
$permissiontoread = $user->rights->$moduleNameLowerCase->adminpage->read;
saturne_check_access($permissiontoread);

/*
Expand All @@ -77,18 +74,6 @@
//Extrafields actions
require DOL_DOCUMENT_ROOT . '/core/actions_extrafields.inc.php';

//Set numering modele for control object
if ($action == 'setmod') {
$constforval = 'DIGIQUALI_' . strtoupper('control') . '_ADDON';
dolibarr_set_const($db, $constforval, $value, 'chaine', 0, '', $conf->entity);
}

//Set numering modele for controldet object
if ($action == 'setmodControlDet') {
$constforval = 'DIGIQUALI_' . strtoupper('controldet') . '_ADDON';
dolibarr_set_const($db, $constforval, $value, 'chaine', 0, '', $conf->entity);
}

if ($action == 'update_control_reminder') {
$reminderFrequency = GETPOST('control_reminder_frequency');
$reminderType = GETPOST('control_reminder_type');
Expand All @@ -97,17 +82,10 @@
dolibarr_set_const($db, 'DIGIQUALI_CONTROL_REMINDER_TYPE', $reminderType, 'chaine', 0, '', $conf->entity);

setEventMessage('SavedConfig');
header('Location: ' . $_SERVER['PHP_SELF']);
exit;
}

if ($action == 'update_public_survey_title') {
$publicSurveyTitle = GETPOST('public_survey_title');

dolibarr_set_const($db, 'DIGIQUALI_PUBLIC_SURVEY_TITLE', $publicSurveyTitle, 'chaine', 0, '', $conf->entity);

setEventMessage('SavedConfig');
}


/*
* View
*/
Expand All @@ -123,7 +101,7 @@

// Configuration header
$head = digiquali_admin_prepare_head();
print dol_get_fiche_head($head, 'control', $title, -1, 'digiquali_color@digiquali');
print dol_get_fiche_head($head, $object->element, $title, -1, 'digiquali_color@digiquali');

/*
* Numbering module
Expand All @@ -133,158 +111,15 @@

require __DIR__ . '/../../saturne/core/tpl/admin/object/object_const_view.tpl.php';

//Control data
print load_fiche_titre($langs->trans('ConfigData', $langs->transnoentities('ControlsMin')), '', '');

print '<table class="noborder centpercent">';
print '<tr class="liste_titre">';
print '<td>' . $langs->trans('Name') . '</td>';
print '<td>' . $langs->trans('Description') . '</td>';
print '<td class="center">' . $langs->trans('Status') . '</td>';
print '</tr>';

//Display medias conf
print '<tr><td>';
print $langs->trans('DisplayMedias');
print '</td><td>';
print $langs->trans('DisplayMediasDescription');
print '</td>';

print '<td class="center">';
print ajax_constantonoff('DIGIQUALI_CONTROL_DISPLAY_MEDIAS');
print '</td>';
print '</tr>';

//Use large size media in gallery
print '<tr><td>';
print $langs->trans('UseLargeSizeMedia');
print '</td><td>';
print $langs->trans('UseLargeSizeMediaDescription');
print '</td>';

print '<td class="center">';
print ajax_constantonoff('DIGIQUALI_CONTROL_USE_LARGE_MEDIA_IN_GALLERY');
print '</td>';
print '</tr>';

//Lock control if DMD/DLUO outdated
print '<tr><td>';
print $langs->trans('LockControlOutdatedEquipment');
print '</td><td>';
print $langs->trans('LockControlOutdatedEquipmentDescription');
print '</td>';

print '<td class="center">';
print ajax_constantonoff('DIGIQUALI_LOCK_CONTROL_OUTDATED_EQUIPMENT');
print '</td>';
print '</tr>';
print '</table>';
/*
* Numbering module line
*/

$object = new ControlLine($db);

require __DIR__ . '/../../saturne/core/tpl/admin/object/object_numbering_module_view.tpl.php';

require __DIR__ . '/../../saturne/core/tpl/admin/object/object_const_view.tpl.php';

//Control data
print load_fiche_titre($langs->trans('ConfigData', $langs->transnoentities('ControlsMin')), '', '');

print '<table class="noborder centpercent">';
print '<tr class="liste_titre">';
print '<td>' . $langs->trans('Name') . '</td>';
print '<td>' . $langs->trans('Description') . '</td>';
print '<td class="center">' . $langs->trans('Status') . '</td>';
print '</tr>';

//Display medias conf
print '<tr><td>';
print $langs->trans('DisplayMedias');
print '</td><td>';
print $langs->trans('DisplayMediasDescription');
print '</td>';

print '<td class="center">';
print ajax_constantonoff('DIGIQUALI_CONTROL_DISPLAY_MEDIAS');
print '</td>';
print '</tr>';

//Use large size media in gallery
print '<tr><td>';
print $langs->trans('UseLargeSizeMedia');
print '</td><td>';
print $langs->trans('UseLargeSizeMediaDescription');
print '</td>';

print '<td class="center">';
print ajax_constantonoff('DIGIQUALI_CONTROL_USE_LARGE_MEDIA_IN_GALLERY');
print '</td>';
print '</tr>';

// Auto-save action on question answer
print '<tr><td>';
print $langs->trans('AutoSaveActionQuestionAnswer');
print '</td><td>';
print $langs->trans('AutoSaveActionQuestionAnswerDescription');
print '</td>';

print '<td class="center">';
print ajax_constantonoff('DIGIQUALI_CONTROLDET_AUTO_SAVE_ACTION');
print '</td>';
print '</tr>';

print '<form method="POST" action="' . $_SERVER['PHP_SELF'] . '">';
print '<input type="hidden" name="token" value="' . newToken() . '">';
print '<input type="hidden" name="action" value="update_public_survey_title">';

print '<tr class="oddeven"><td>';
print $langs->trans('PublicSurveyTitle');
print '</td><td>';
print $langs->trans('PublicSurveyTitleDescription');
print '</td>';

print '<td class="center">';
print '<input type="text" name="public_survey_title" value="' . $conf->global->DIGIQUALI_PUBLIC_SURVEY_TITLE . '">';
print '</td></tr>';

print '<tr><td>';
print $langs->trans('EnablePublicControlHistory');
print '</td><td>';
print $langs->trans('EnablePublicControlHistoryDescription');
print '</td>';

print '<td class="center">';
print ajax_constantonoff('DIGIQUALI_ENABLE_PUBLIC_CONTROL_HISTORY');
print '</td>';
print '</tr>';

print '<tr><td>';
print $langs->trans('ShowQcFrequencyPublicInterface');
print '</td><td>';
print $langs->trans('ShowQcFrequencyPublicInterfaceDescription');
print '</td>';

print '<td class="center">';
print ajax_constantonoff('DIGIQUALI_SHOW_QC_FREQUENCY_PUBLIC_INTERFACE');
print '</td>';
print '</tr>';

print '<tr><td>';
print $langs->trans('ShowLastControlFirstOnPublicHistory');
print '</td><td>';
print $langs->trans('ShowLastControlFirstOnPublicHistoryDescription');
print '</td>';

print '<td class="center">';
print ajax_constantonoff('DIGIQUALI_SHOW_LAST_CONTROL_FIRST_ON_PUBLIC_HISTORY');
print '</td>';
print '</tr>';

print '</table>';

print '<div class="tabsAction"><input type="submit" class="butAction" name="save" value="' . $langs->trans('Save') . '"></div>';

print '</form>';

// Control reminder
print load_fiche_titre($langs->trans('ControlReminder'), '', '');

print '<form method="POST" action="' . $_SERVER['PHP_SELF'] . '">';
Expand All @@ -297,6 +132,7 @@
print '<td class="center">' . $langs->trans('Value') . '</td>';
print '</tr>';

// Enable control reminder
print '<tr class="oddeven"><td>';
print $langs->trans('ControlReminder');
print '</td><td>';
Expand All @@ -307,6 +143,7 @@
print ajax_constantonoff('DIGIQUALI_CONTROL_REMINDER_ENABLED');
print '</td></tr>';

// Define control reminder frequency in days (ex: 30,60,90)
print '<tr class="oddeven"><td>';
print $langs->trans('ControlReminderFrequency');
print '</td><td>';
Expand All @@ -317,6 +154,7 @@
print '<input type="text" name="control_reminder_frequency" value="' . $conf->global->DIGIQUALI_CONTROL_REMINDER_FREQUENCY . '">';
print '</td></tr>';

// Define control reminder type
print '<tr class="oddeven"><td>';
print $langs->trans('ControlReminderType');
print '</td><td>';
Expand All @@ -333,32 +171,32 @@
print '</form>';
print '</table>';

//Extrafields control management
// Extrafields control management
print load_fiche_titre($langs->trans('ExtrafieldsControlManagement'), '', '');

require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_view.tpl.php';
$textobject = dol_strtolower($langs->transnoentities('Control'));
require DOL_DOCUMENT_ROOT . '/core/tpl/admin_extrafields_view.tpl.php';

// Buttons
if ($action != 'create' && $action != 'edit') {
print '<div class="tabsAction">';
print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER['PHP_SELF'].'?action=create">'.$langs->trans('NewAttribute').'</a></div>';
print '</div>';
print '<div class="tabsAction">';
print '<div class="inline-block divButAction"><a class="butAction" href="' . $_SERVER['PHP_SELF'] . '?action=create">' . $langs->trans('NewAttribute') . '</a></div>';
print '</div>';
}

// Creation of an optional field
if ($action == 'create') {
print load_fiche_titre($langs->trans('NewAttribute'));
require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php';
print load_fiche_titre($langs->trans('NewAttribute'));
require DOL_DOCUMENT_ROOT . '/core/tpl/admin_extrafields_add.tpl.php';
}

// Edition of an optional field
if ($action == 'edit' && !empty($attrname)) {
print load_fiche_titre($langs->trans('FieldEdition', $attrname));
require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_edit.tpl.php';
print load_fiche_titre($langs->trans('FieldEdition', $attrname));
require DOL_DOCUMENT_ROOT . '/core/tpl/admin_extrafields_edit.tpl.php';
}

// Page end
print dol_get_fiche_end();
llxFooter();
$db->close();

Loading

0 comments on commit 3504174

Please sign in to comment.