Skip to content

Commit

Permalink
Merge pull request #1685 from Evarisk/develop
Browse files Browse the repository at this point in the history
1.10.0
  • Loading branch information
nicolas-eoxia authored Jan 19, 2024
2 parents 71829a6 + dc8b509 commit c06f3b9
Show file tree
Hide file tree
Showing 41 changed files with 3,259 additions and 1,749 deletions.
11 changes: 7 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,25 @@
## Informations

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

### Version

- Version : 1.9.1
- Compatibilité : Dolibarr 16.0.0 - 18.0.4
- Version : 1.10.0
- PHP : 7.4.33
- Compatibilité : Dolibarr 17.0.0 - 18.0.4
- Saturne Framework : 1.2.1

## Liens

- Support & Assistance : [Forum dolibarr.fr](https://dolibarr.fr) / Par mail à [email protected]
- Demo : [Demo DigiQuali](https://demodoli.digirisk.com) - ID: demo - Password: demo
- Documentation : [Wiki DigiQuali](https://wiki.dolibarr.org/index.php/Module_DigiQuali)
- Projet Github : [Projet DigiQuali](https://github.com/Evarisk/digiquali/projects?type=classic)
- Projet Github : [Projet DigiQuali](https://github.com/Evarisk/digiquali/projects?query=is%3Aopen)
- Saturne Framework : [Télécharger Saturne](https://dolistore.com/fr/modules/1906-Saturne.html)
- D'autres modules développés par Evarisk disponibles sur [Dolistore.com](https://dolistore.com)

Expand All @@ -45,6 +46,8 @@ Contrôle qualité des éléments de Dolibarr :

Génération du rapport de contrôle

Réalisation de contrôle avec une PWA

## Traductions

- Français
Expand Down
69 changes: 65 additions & 4 deletions admin/sheet.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
// Load Dolibarr libraries.
require_once DOL_DOCUMENT_ROOT . '/core/lib/admin.lib.php';
require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php';
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formother.class.php';

// Load DigiQuali libraries.
require_once __DIR__ . '/../lib/digiquali.lib.php';
Expand All @@ -56,7 +57,8 @@
$tags = new Categorie($db);

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

// List of supported format.
$tmptype2label = ExtraFields::$type2label;
Expand Down Expand Up @@ -141,6 +143,38 @@
dolibarr_set_const($db, 'DIGIQUALI_SHEET_TAGS_SET', 1, 'integer', 0, '', $conf->entity);
}

if ($action == 'generate_main_categories') {
$tagParentID = saturne_create_category($langs->transnoentities('Control'), 'sheet');

saturne_create_category($langs->transnoentities('Quality'), 'sheet', $tagParentID, 'pictogram_Quality_64px.png');

$tagID = saturne_create_category($langs->transnoentities('HealthSecurity'), 'sheet', $tagParentID, 'pictogram_HealthSecurity_64px.png');
saturne_create_category($langs->transnoentities('FirstAidKits'), 'sheet', $tagID, 'pictogram_FirstAidKits_64px.png');

$tagID = saturne_create_category($langs->transnoentities('Materials'), 'sheet', $tagParentID, 'pictogram_Materials_64px.png');
saturne_create_category($langs->transnoentities('Mask'), 'sheet', $tagID, 'pictogram_Mask_64px.png');

$tagID = saturne_create_category($langs->transnoentities('Vehicles'), 'sheet', $tagParentID, 'pictogram_Vehicles_64px.png');
saturne_create_category($langs->transnoentities('Car'), 'sheet', $tagID, 'pictogram_Car_64px.png');
saturne_create_category($langs->transnoentities('IndustrialVehicles'), 'sheet', $tagID, 'pictogram_IndustrialVehicles_64px.png');

dolibarr_set_const($db, 'DIGIQUALI_SHEET_MAIN_CATEGORY', $tagParentID, 'integer', 0, '', $conf->entity);
dolibarr_set_const($db, 'DIGIQUALI_SHEET_MAIN_CATEGORIES_SET', 1, 'integer', 0, '', $conf->entity);

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

if ($action == 'set_main_category') {
$categoryID = GETPOST('main_category');
dolibarr_set_const($db, 'DIGIQUALI_SHEET_MAIN_CATEGORY', $categoryID, 'integer', 0, '', $conf->entity);

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

/*
* View
*/
Expand Down Expand Up @@ -198,11 +232,38 @@
print '<td class="center">';
print $conf->global->DIGIQUALI_SHEET_TAGS_SET ? '<a type="" class=" butActionRefused" value="">'.$langs->trans('Create') . '</a>' : '<input type="submit" class="button" value="'. $langs->trans('Create') .'">' ;
print '</td>';

print '<td class="center">';
print $form->textwithpicto('', $langs->trans('CategoriesGeneration'));
print '</td>';
print '</tr>';
print '</td></tr>';
print '</form>';

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

print '<tr class="oddeven"><td>' . $langs->transnoentities('GenerateMainSheetCategories') . '</td>';
print '<td class="center">';
print $conf->global->DIGIQUALI_SHEET_MAIN_CATEGORIES_SET ? $langs->transnoentities('AlreadyGenerated') : $langs->transnoentities('NotCreated');
print '</td><td class="center">';
print $conf->global->DIGIQUALI_SHEET_MAIN_CATEGORIES_SET ? '<a type="" class=" butActionRefused" value="">' . $langs->transnoentities('Create') . '</a>' : '<input type="submit" class="button" value="' . $langs->transnoentities('Create') . '">';
print '</td><td class="center">';
print $form->textwithpicto('', $langs->trans('MainSheetCategoriesDescription'));
print '</td></tr>';
print '</form>';

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

// Set default main category
print '<tr class="oddeven"><td>' . $langs->transnoentities('SheetMainCategory') . '</td>';
print '<td class="center">';
print $formOther->select_categories('sheet', $conf->global->DIGIQUALI_SHEET_MAIN_CATEGORY, 'main_category');
print '</td><td class="center">';
print '<div><input type="submit" class="butAction" name="save" value="' . $langs->trans('Save') . '"></div>';
print '</td><td class="center">';
print $form->textwithpicto('', $langs->trans('SheetMainCategoryDescription'));
print '</td></tr>';
print '</form>';
print '</table>';

Expand Down
45 changes: 33 additions & 12 deletions class/actions_digiquali.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public function constructCategory($parameters, &$object)
{
$error = 0; // Error counter

if (($parameters['currentcontext'] == 'category')) {
if (strpos($parameters['context'], 'category') !== false) {
$tags = [
'question' => [
'id' => 436301001,
Expand Down Expand Up @@ -119,7 +119,7 @@ public function doActions(array $parameters, $object, string $action): int

$error = 0; // Error counter

if (preg_match('/categorycard/', $parameters['context'])) {
if (strpos($parameters['context'], 'categorycard') !== false) {
require_once __DIR__ . '/../class/question.class.php';
require_once __DIR__ . '/../class/sheet.class.php';
require_once __DIR__ . '/../class/control.class.php';
Expand All @@ -135,6 +135,27 @@ public function doActions(array $parameters, $object, string $action): int
}
}

/**
* Overloading the addHtmlHeader function : replacing the parent's function with the one below
*
* @param array $parameters Hook metadata (context, etc...)
* @return int 0 < on error, 0 on success, 1 to replace standard code
*/
public function addHtmlHeader(array $parameters): int
{
if (strpos($_SERVER['PHP_SELF'], 'digiquali') !== false) {
?>
<script>
$('link[rel="manifest"]').remove();
</script>
<?php

$this->resprints = '<link rel="manifest" href="' . DOL_URL_ROOT . '/custom/digiquali/manifest.json.php' . '" />';
}

return 0; // or return 1 to replace standard code-->
}

/**
* Overloading the printCommonFooter function : replacing the parent's function with the one below
*
Expand All @@ -147,9 +168,9 @@ public function printCommonFooter($parameters)

$error = 0; // Error counter

if (preg_match('/categoryindex/', $parameters['context'])) { // do something only for the context 'somecontext1' or 'somecontext2'
if (strpos($parameters['context'], 'categoryindex') !== false) { // do something only for the context 'somecontext1' or 'somecontext2'
print '<script src="../custom/digiquali/js/digiquali.js"></script>';
} elseif ($parameters['currentcontext'] == 'productlotcard') {
} elseif (strpos($parameters['context'], 'productlotcard') !== false) {
$productLot = new ProductLot($this->db);
$productLot->fetch(GETPOST('id'));
$objectB64 = $productLot->array_options['options_control_history_link'];
Expand All @@ -173,7 +194,7 @@ public function printCommonFooter($parameters)
if (!empty($linkableElements)) {
foreach($linkableElements as $linkableElement) {
if ($linkableElement['link_name'] == $object->element) {
if ($parameters['currentcontext'] == $linkableElement['hook_name_card']) {
if (strpos($parameters['context'], $linkableElement['hook_name_card']) !== false) {
$picto = img_picto('', 'fontawesome_fa-clipboard-check_fas_#d35968', 'class="pictofixedwidth"');
$extrafieldsNames = ['qc_frequency', 'control_history_link'];
foreach ($extrafieldsNames as $extrafieldsName) {
Expand All @@ -184,7 +205,7 @@ public function printCommonFooter($parameters)
</script>
<?php
}
} elseif (in_array($parameters['currentcontext'], [$linkableElement['hook_name_list'], 'projecttaskscard']) || preg_match('/' . $linkableElement['hook_name_list'] . '/', $parameters['context'])) {
} elseif (preg_match('/' . $linkableElement['hook_name_list'] . '|projecttaskscard/', $parameters['context'])) {
$picto = img_picto('', 'fontawesome_fa-clipboard-check_fas_#d35968', 'class="pictofixedwidth"');
$extrafieldsNames = ['qc_frequency', 'control_history_link'];
foreach ($extrafieldsNames as $extrafieldsName) { ?>
Expand Down Expand Up @@ -218,7 +239,7 @@ public function printCommonFooter($parameters)
* @return void
*/
public function formObjectOptions(array $parameters, object $object) {
if ($parameters['currentcontext'] == 'productlotcard') {
if (strpos($parameters['context'], 'productlotcard') !== false) {
$objectData = ['type' => $object->element, 'id' => $object->id];

$objectDataJson = json_encode($objectData);
Expand All @@ -241,7 +262,7 @@ public function redirectAfterConnection($parameters)
{
global $conf;

if ($parameters['currentcontext'] == 'mainloginpage') {
if (strpos($parameters['context'], 'mainloginpage') !== false) {
if ($conf->global->DIGIQUALI_REDIRECT_AFTER_CONNECTION) {
$value = dol_buildpath('/custom/digiquali/digiqualiindex.php?mainmenu=digiquali', 1);
} else {
Expand Down Expand Up @@ -270,7 +291,7 @@ public function saturneBannerTab(array $parameters, CommonObject $object): int
global $conf, $langs;

// Do something only for the current context.
if (preg_match('/controlcard/', $parameters['context'])) {
if (strpos($parameters['context'], 'controlcard') !== false) {
if ($conf->browser->layout == 'phone') {
$morehtmlref = '<br><div>' . img_picto('', 'fontawesome_fa-caret-square-down_far_#966EA2F2_fa-2em', 'class="toggleControlInfo pictofixedwidth valignmiddle" style="width: 35px;"') . $langs->trans('DisplayMoreInfo') . '</div>';
} else {
Expand All @@ -294,7 +315,7 @@ public function printMainArea(array $parameters): int
global $conf, $mysoc;

// Do something only for the current context.
if (in_array($parameters['currentcontext'], ['publiccontrol', 'publicsurvey', 'publiccontrolhistory'])) {
if (preg_match('/publiccontrol|publicsurvey|publiccontrolhistory/', $parameters['context'])) {
if (!empty($conf->global->SATURNE_SHOW_COMPANY_LOGO)) {
// Define logo and logoSmall.
$logoSmall = $mysoc->logo_small;
Expand Down Expand Up @@ -328,7 +349,7 @@ public function printMainArea(array $parameters): int
public function saturneAdminDocumentData(array $parameters): int
{
// Do something only for the current context.
if ($parameters['currentcontext'] == 'digiqualiadmindocuments') {
if (strpos($parameters['context'], 'digiqualiadmindocuments') !== false) {
$types = [
'ControlDocument' => [
'documentType' => 'controldocument',
Expand All @@ -350,7 +371,7 @@ public function saturneAdminDocumentData(array $parameters): int
public function saturneAdminObjectConst(array $parameters): int
{
// Do something only for the current context.
if ($parameters['currentcontext'] == 'digiqualiadmindocuments') {
if (strpos($parameters['context'], 'digiqualiadmindocuments') !== false) {
$constArray['digiquali'] = [
'controldocument' => [
'name' => 'ControlDocumentDisplayMedias',
Expand Down
Loading

0 comments on commit c06f3b9

Please sign in to comment.