diff --git a/README.md b/README.md index 60bd465f..aee88fbc 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ ## Informations - Numéro du module : 436301 -- Dernière mise à jour : 23/08/2023 +- Dernière mise à jour : 13/09/2023 - Éditeur : [Evarisk](https://evarisk.com) - Thème : Eldy Menu - Licence : GPLv3 @@ -11,8 +11,8 @@ ### Version -- Version : 1.8.1 -- Compatibilité : Dolibarr 16.0.0 - 17.0.3 +- Version : 1.9.0 +- Compatibilité : Dolibarr 16.0.0 - 18.0.1 - Saturne Framework : 1.1.2 ## Liens @@ -66,3 +66,4 @@ Génération du rapport de contrôle git clone https://github.com/Evarisk/digiquali.git git clone https://github.com/Evarisk/saturne.git ``` +- Activer le module dans la liste des Modules/Applications installés diff --git a/admin/control.php b/admin/control.php index cf2d61a0..a96af9a7 100644 --- a/admin/control.php +++ b/admin/control.php @@ -396,6 +396,18 @@ print ''; print ''; +// Auto-save action on question answer +print ''; +print $langs->trans('AutoSaveActionQuestionAnswer'); +print ''; +print $langs->trans('AutoSaveActionQuestionAnswerDescription'); +print ''; + +print ''; +print ajax_constantonoff('DIGIQUALI_CONTROLDET_AUTO_SAVE_ACTION'); +print ''; +print ''; + print '
'; print ''; print ''; @@ -417,7 +429,7 @@ print ''; print ''; -print ajax_constantonoff('SHOW_QC_FREQUENCY_PUBLIC_INTERFACE'); +print ajax_constantonoff('DIGIQUALI_ENABLE_PUBLIC_CONTROL_HISTORY'); print ''; print ''; @@ -428,7 +440,7 @@ print ''; print ''; -print ajax_constantonoff('DIGIQUALI_ENABLE_PUBLIC_CONTROL_HISTORY'); +print ajax_constantonoff('DIGIQUALI_SHOW_QC_FREQUENCY_PUBLIC_INTERFACE'); print ''; print ''; diff --git a/admin/setup.php b/admin/setup.php index 885a21db..21fc6146 100644 --- a/admin/setup.php +++ b/admin/setup.php @@ -36,7 +36,7 @@ require_once __DIR__ . '/../lib/digiquali.lib.php'; // Global variables definitions -global $conf, $db, $langs, $user; +global $conf, $db, $langs, $moduleName, $user; // Load translation files required by the page saturne_load_langs(['admin']); @@ -126,7 +126,7 @@ print ''; print $langs->trans('AdvancedTriggers'); print ''; -print $langs->trans('AdvancedTriggersDescription'); +print $langs->trans('AdvancedTriggersDescription', $moduleName); print ''; print ''; diff --git a/class/actions_digiquali.class.php b/class/actions_digiquali.class.php index b9778f97..0a5b7286 100644 --- a/class/actions_digiquali.class.php +++ b/class/actions_digiquali.class.php @@ -170,7 +170,7 @@ public function doActions(array $parameters, $object, string $action): int */ public function printCommonFooter($parameters) { - global $conf, $form, $langs, $user; + global $conf, $form, $langs, $object, $user; $error = 0; // Error counter @@ -284,6 +284,41 @@ public function printCommonFooter($parameters) element) { + if ($parameters['currentcontext'] == $linkableElement['hook_name_card']) { + $picto = img_picto('', 'fontawesome_fa-clipboard-check_fas_#d35968', 'class="pictofixedwidth"'); + $extrafieldsNames = ['qc_frequency', 'control_history_link']; + foreach ($extrafieldsNames as $extrafieldsName) { + $jQueryElement = 'td.' . $object->element . '_extras_' . $extrafieldsName; ?> + + + + results = array('myreturn' => 999); return 0; // or return 1 to replace standard code @@ -355,7 +390,7 @@ public function saturneBannerTab(array $parameters, CommonObject $object): int // Do something only for the current context. if (preg_match('/controlcard/', $parameters['context'])) { if ($conf->browser->layout == 'phone') { - $morehtmlref = '' . ' ' . $langs->trans('DisplayMoreInfo'); + $morehtmlref = '
' . img_picto('', 'fontawesome_fa-caret-square-down_far_#966EA2F2_fa-2em', 'class="toggleControlInfo pictofixedwidth valignmiddle" style="width: 35px;"') . $langs->trans('DisplayMoreInfo') . '
'; } else { $morehtmlref = ''; } @@ -377,7 +412,7 @@ public function printMainArea(array $parameters): int global $conf, $mysoc; // Do something only for the current context. - if (in_array($parameters['currentcontext'], ['publiccontrol', 'publicsurvey'])) { + if (in_array($parameters['currentcontext'], ['publiccontrol', 'publicsurvey', 'publiccontrolhistory'])) { if (!empty($conf->global->SATURNE_SHOW_COMPANY_LOGO)) { // Define logo and logoSmall. $logoSmall = $mysoc->logo_small; diff --git a/class/control.class.php b/class/control.class.php index c46fcce2..0aa7d467 100644 --- a/class/control.class.php +++ b/class/control.class.php @@ -118,8 +118,8 @@ class Control extends SaturneObject 'date_creation' => ['type' => 'datetime', 'label' => 'DateCreation', 'enabled' => 1, 'position' => 40, 'notnull' => 1, 'visible' => 2, 'positioncard' => 10], 'tms' => ['type' => 'timestamp', 'label' => 'DateModification', 'enabled' => 1, 'position' => 50, 'notnull' => 0, 'visible' => 0], 'import_key' => ['type' => 'varchar(14)', 'label' => 'ImportId', 'enabled' => 1, 'position' => 60, 'notnull' => 0, 'visible' => 0, 'index' => 0], - 'control_date' => ['type' => 'date', 'label' => 'ControlDate', 'enabled' => 1, 'position' => 63, 'notnull' => 0, 'visible' => 5], - 'next_control_date' => ['type' => 'date', 'label' => 'NextControlDate', 'enabled' => 1, 'position' => 65, 'notnull' => 0, 'visible' => 5], + 'control_date' => ['type' => 'date', 'label' => 'ControlDate', 'enabled' => 1, 'position' => 63, 'notnull' => 0, 'visible' => 2], + 'next_control_date' => ['type' => 'date', 'label' => 'NextControlDate', 'enabled' => 1, 'position' => 65, 'notnull' => 0, 'visible' => 2], 'status' => ['type' => 'smallint', 'label' => 'Status', 'enabled' => 1, 'position' => 70, 'notnull' => 1, 'visible' => 5, 'index' => 1, 'default' => 0, 'arrayofkeyval' => [0 => 'Draft', 1 => 'Validated', 2 => 'Locked']], 'note_public' => ['type' => 'html', 'label' => 'NotePublic', 'enabled' => 1, 'position' => 80, 'notnull' => 0, 'visible' => 0], 'note_private' => ['type' => 'html', 'label' => 'NotePrivate', 'enabled' => 1, 'position' => 90, 'notnull' => 0, 'visible' => 0], @@ -551,6 +551,9 @@ public function createFromClone(User $user, int $fromID, array $options): int if (empty($options['photos'])) { $object->photo = ''; } + if (property_exists($object, 'control_date')) { + $object->control_date = ''; + } if (property_exists($object, 'next_control_date')) { $object->next_control_date = ''; } @@ -1055,6 +1058,9 @@ public function getTriggerDescription(SaturneObject $object): string { global $db, $langs; + // Load DigiQuali libraries + require_once __DIR__ . '/../class/sheet.class.php'; + $sheet = new Sheet($db); $sheet->fetch($object->fk_sheet); diff --git a/core/modules/modDigiQuali.class.php b/core/modules/modDigiQuali.class.php index b49f8db3..a9419de3 100644 --- a/core/modules/modDigiQuali.class.php +++ b/core/modules/modDigiQuali.class.php @@ -77,7 +77,7 @@ public function __construct($db) $this->editor_url = 'https://evarisk.com/'; // Possible values for version are: 'development', 'experimental', 'dolibarr', 'dolibarr_deprecated' or a version string like 'x.y.z' - $this->version = '1.8.1'; + $this->version = '1.9.0'; // Url to the file with your last numberversion of this module //$this->url_last_version = 'http://www.example.com/versionmodule.txt'; @@ -125,7 +125,7 @@ public function __construct($db) 'publiccontrol', 'publicsurvey', 'digiqualiadmindocuments', - 'productlotcard' + 'projecttaskscard' ], // Set this to 1 if features of module are opened to external users 'moduleforexternal' => 0, @@ -148,7 +148,7 @@ public function __construct($db) // A condition to hide module $this->hidden = false; // List of module class names as string that must be enabled if this module is enabled. Example: array('always1'=>'modModuleToEnable1','always2'=>'modModuleToEnable2', 'FR1'=>'modModuleToEnableFR'...) - $this->depends = ['modFckeditor', 'modProduct', 'modProductBatch', 'modAgenda', 'modECM', 'modProjet', 'modCategorie', 'modSaturne', 'modTicket']; + $this->depends = ['modFckeditor', 'modProduct', 'modProductBatch', 'modAgenda', 'modECM', 'modProjet', 'modCategorie', 'modSaturne', 'modTicket', 'modCron']; $this->requiredby = []; // List of module class names as string to disable if this one is disabled. Example: array('modModuleToDisable1', ...) $this->conflictwith = []; // List of module class names as string this module is in conflict with. Example: array('modModuleToDisable1', ...) @@ -231,6 +231,9 @@ public function __construct($db) // CONST CONTROL LINE $i++ => ['DIGIQUALI_CONTROLDET_ADDON', 'chaine', 'mod_controldet_standard', '', 0, 'current'], + $i++ => ['DIGIQUALI_CONTROLDET_AUTO_SAVE_ACTION', 'integer', 1, '', 0, 'current'], + + // CONST CONTROL EQUIPMENT $i++ => ['DIGIQUALI_CONTROL_EQUIPMENT_ADDON', 'chaine', 'mod_control_equipment_standard', '', 0, 'current'], // CONST MODULE @@ -287,6 +290,9 @@ public function __construct($db) $objectType = $linkableElement['tab_type']; } $this->tabs[] = ['data' => $objectType . ':+control:' . $pictoDigiQuali . $langs->trans('Controls') . ':digiquali@digiquali:$user->rights->digiquali->control->read:/custom/digiquali/view/control/control_list.php?fromid=__ID__&fromtype=' . $linkableElement['link_name']]; + + $this->module_parts['hooks'][] = $linkableElement['hook_name_list']; + $this->module_parts['hooks'][] = $linkableElement['hook_name_card']; } } @@ -721,6 +727,12 @@ public function init($options = ''): int dolibarr_set_const($this->db, 'DIGIQUALI_QUESTION_BACKWARD_COMPATIBILITY', 1, 'integer', 0, '', $conf->entity); } + require_once DOL_DOCUMENT_ROOT . '/cron/class/cronjob.class.php'; + + $cronJob = new Cronjob($this->db); + $cronJob->fetch(0, 'ActionComm', 'sendEmailsReminder'); + $cronJob->reprogram_jobs($user->login, dol_now()); + return $result; } diff --git a/core/tpl/digiquali_control_answers.tpl.php b/core/tpl/digiquali_control_answers.tpl.php index 14c681bc..905f0e01 100644 --- a/core/tpl/digiquali_control_answers.tpl.php +++ b/core/tpl/digiquali_control_answers.tpl.php @@ -10,151 +10,153 @@ $questionAnswer = $itemControlDet->answer; $comment = $itemControlDet->comment; } - $item = $question; - $item->fetch($questionId); - ?> -
-
- -
-
ref . ' - ' . $item->label; ?>
-
description; ?>
-
-
- ref ) ) { - print '' . $itemControlDet->ref . ' :'; - } ?> -
- type == 'Text') : ?> -
"> - ' . $langs->trans('Answer') . ' : '; - $object->status > $object::STATUS_DRAFT ? print $questionAnswer : - print 'status > $object::STATUS_DRAFT ? 'disabled' : '') .' name="answer'. $item->id .'" id="answer'. $item->id .'"class="question-textarea input-answer ' . ($object->status > 0 ? 'disable' : '') . '" value="'. $questionAnswer .'">'; - ?> -
- - enter_comment > 0) : ?> - trans('Comment') . ' : '; ?> - - enter_comment > 0) : ?> - status > 0 ) : ?> - - - id .'" id="comment'. $item->id .'" value="'. $comment .'" '. ($object->status == 2 ? 'disabled' : '').'>'; ?> - - -
-
- - show_photo > 0) : ?> -
- global->DIGIQUALI_CONTROL_DISPLAY_MEDIAS)) : - print saturne_show_medias_linked('digiquali', $conf->digiquali->multidir_output[$conf->entity] . '/question/'. $item->ref . '/photo_ok', 'small', '', 0, 0, 0, 200, 200, 0, 0, 0, 'question/'. $item->ref . '/photo_ok', $item, 'photo_ok', 0, 0, 0,1, 'photo-ok', 0); - print saturne_show_medias_linked('digiquali', $conf->digiquali->multidir_output[$conf->entity] . '/question/'. $item->ref . '/photo_ko', 'small', '', 0, 0, 0, 200, 200, 0, 0, 0, 'question/'. $item->ref . '/photo_ko', $item, 'photo_ko', 0, 0, 0,1, 'photo-ko', 0); - endif; - ?> -
- -
-
- - authorize_answer_photo > 0) : ?> -
- status == 0 ) : ?> - - - - - - digiquali->multidir_output[$conf->entity] . '/control/'. $object->ref . '/answer_photo/' . $item->ref, 'small', '', 0, 0, 0, 50, 50, 0, 0, 0, 'control/'. $object->ref . '/answer_photo/' . $item->ref, $item, '', 0, $object->status == 0, 1); - ?> -
- - - type == 'MultipleChoices') : - $answerList = $answer->fetchAll('ASC', 'position', 0, 0, ['customsql' => 't.status > ' . Answer::STATUS_DELETED . ' AND t.fk_question = ' . $item->id]); - ?> -
status > 0) ? ' style="pointer-events: none"' : '' ?>> - conf->DIGIQUALI_SHOW_ONLY_QUESTIONS_WITH_NO_ANSWER or empty($questionAnswer)) { + $item = $question; + $item->fetch($questionId); + ?> +
+
+ +
+
getNomUrl(1, isset($publicInterface) ? 'nolink' : '', 1, '', -1, 1); ?>
+
description; ?>
+
+
+ ref ) ) { + print '' . $itemControlDet->ref . ' :'; + } ?> +
+ type == 'Text') : ?> +
"> + ' . $langs->trans('Answer') . ' : '; + $object->status > $object::STATUS_DRAFT ? print $questionAnswer : + print 'status > $object::STATUS_DRAFT ? 'disabled' : '') .' name="answer'. $item->id .'" id="answer'. $item->id .'"class="question-textarea input-answer ' . ($object->status > 0 ? 'disable' : '') . '" value="'. $questionAnswer .'">'; + ?> +
+ + enter_comment > 0) : ?> + trans('Comment') . ' : '; ?> + + enter_comment > 0) : ?> + status > 0 ) : ?> + + + id .'" id="comment'. $item->id .'" value="'. $comment .'" '. ($object->status == 2 ? 'disabled' : '').'>'; ?> + + +
+
+ + show_photo > 0) : ?> +
+ global->DIGIQUALI_CONTROL_DISPLAY_MEDIAS)) : + print saturne_show_medias_linked('digiquali', $conf->digiquali->multidir_output[$conf->entity] . '/question/'. $item->ref . '/photo_ok', 'small', '', 0, 0, 0, 200, 200, 0, 0, 0, 'question/'. $item->ref . '/photo_ok', $item, 'photo_ok', 0, 0, 0,1, 'photo-ok', 0); + print saturne_show_medias_linked('digiquali', $conf->digiquali->multidir_output[$conf->entity] . '/question/'. $item->ref . '/photo_ko', 'small', '', 0, 0, 0, 200, 200, 0, 0, 0, 'question/'. $item->ref . '/photo_ko', $item, 'photo_ko', 0, 0, 0,1, 'photo-ko', 0); + endif; + ?> +
+ +
+
+ + authorize_answer_photo > 0) : ?> +
+ status == 0 ) : ?> + + + + + + digiquali->multidir_output[$conf->entity] . '/control/'. $object->ref . '/answer_photo/' . $item->ref, 'small', '', 0, 0, 0, 50, 50, 0, 0, 0, 'control/'. $object->ref . '/answer_photo/' . $item->ref, $item, '', 0, $object->status == 0, 1); + ?> +
+ + + type == 'MultipleChoices') : + $answerList = $answer->fetchAll('ASC', 'position', 0, 0, ['customsql' => 't.status > ' . Answer::STATUS_DELETED . ' AND t.fk_question = ' . $item->id]); + ?> +
status > 0) ? ' style="pointer-events: none"' : '' ?> data-questionId="id; ?>"> + id .'" id="answer'. $item->id .'" value="0">'; - if (is_array($answerList) && !empty($answerList)) { - foreach($answerList as $answerLinked) { - print ''; - print ''; - if (!empty($answerLinked->pictogram)) { - print $pictosArray[$answerLinked->pictogram]['picto_source']; - } else { - print $answerLinked->value; - } - print ''; - } - } - ?> -
- type == 'UniqueChoice' || $item->type == 'OkKo' || $item->type == 'OkKoToFixNonApplicable') : - $answerList = $answer->fetchAll('ASC', 'position', 0, 0, ['customsql' => 't.status > ' . Answer::STATUS_DELETED . ' AND t.fk_question = ' . $item->id]); - ?> -
"> - id .'" id="answer'. $item->id .'" value="0">'; - if (is_array($answerList) && !empty($answerList)) { - foreach($answerList as $answerLinked) { - print ''; - print ''; - if (!empty($answerLinked->pictogram)) { - print $pictosArray[$answerLinked->pictogram]['picto_source']; - } else { - print $answerLinked->value; - } - print ''; - } - } - ?> -
- type == 'Percentage') : ?> -
"> - '; - print $langs->transnoentities('Answer') . ' : '; - print ''; - print ''; - print 'status > $object::STATUS_DRAFT ? 'disabled' : '') .' name="answer'. $item->id .'" id="answer'. $item->id .'" type="number" min="0" max="100" class="input-answer ' . ($object->status > 0 ? 'disable' : '') . ' ' . ($questionAnswer == $answerLinked->position ? 'active' : '') . '" value="'. $questionAnswer .'"> %'; - print ''; - ?> -
- type == 'Range') : ?> -
"> - '; - print $langs->transnoentities('Answer') . ' : '; - print ''; - print ''; - print 'status > $object::STATUS_DRAFT ? 'disabled' : '') .' name="answer'. $item->id .'" id="answer'. $item->id .'" type="number" class="input-answer ' . ($object->status > 0 ? 'disable' : '') . ' ' . ($questionAnswer == $answerLinked->position ? 'active' : '') . '" value="'. $questionAnswer .'">'; - print ''; - ?> -
- -
-
- id .'" id="answer'. $item->id .'" value="0">'; + if (is_array($answerList) && !empty($answerList)) { + foreach($answerList as $answerLinked) { + print ''; + print ''; + if (!empty($answerLinked->pictogram)) { + print $pictosArray[$answerLinked->pictogram]['picto_source']; + } else { + print $answerLinked->value; + } + print ''; + } + } + ?> +
+ type == 'UniqueChoice' || $item->type == 'OkKo' || $item->type == 'OkKoToFixNonApplicable') : + $answerList = $answer->fetchAll('ASC', 'position', 0, 0, ['customsql' => 't.status > ' . Answer::STATUS_DELETED . ' AND t.fk_question = ' . $item->id]); + ?> +
" data-questionId="id; ?>"> + id .'" id="answer'. $item->id .'" value="0">'; + if (is_array($answerList) && !empty($answerList)) { + foreach($answerList as $answerLinked) { + print ''; + print ''; + if (!empty($answerLinked->pictogram)) { + print $pictosArray[$answerLinked->pictogram]['picto_source']; + } else { + print $answerLinked->value; + } + print ''; + } + } + ?> +
+ type == 'Percentage') : ?> +
" data-questionId="id; ?>"> + '; + print $langs->transnoentities('Answer') . ' : '; + print ''; + print ''; + print 'status > $object::STATUS_DRAFT ? 'disabled' : '') .' name="answer'. $item->id .'" id="answer'. $item->id .'" type="number" min="0" max="100" class="input-answer ' . ($object->status > 0 ? 'disable' : '') . ' ' . ($questionAnswer == $answerLinked->position ? 'active' : '') . '" value="'. $questionAnswer .'"> %'; + print ''; + ?> +
+ type == 'Range') : ?> +
" data-questionId="id; ?>"> + '; + print $langs->transnoentities('Answer') . ' : '; + print ''; + print ''; + print 'status > $object::STATUS_DRAFT ? 'disabled' : '') .' name="answer'. $item->id .'" id="answer'. $item->id .'" type="number" class="input-answer ' . ($object->status > 0 ? 'disable' : '') . ' ' . ($questionAnswer == $answerLinked->position ? 'active' : '') . '" value="'. $questionAnswer .'">'; + print ''; + ?> +
+ +
+
+ fetch($object->fk_sheet); $object->fetchObjectLinked($sheet->id, 'digiquali_sheet', '', '', 'OR', 1, 'sourcetype', 0); @@ -14,14 +16,22 @@ if ($result > 0 && is_array($result)) { $controldettmp = array_shift($result); //sauvegarder réponse - $questionAnswer = GETPOST('answer'.$questionId); + if ($data['autoSave'] && $questionId == $data['questionId']) { + $questionAnswer = $data['answer']; + } else { + $questionAnswer = GETPOST('answer' . $questionId); + } if (!empty($questionAnswer)) { $controldettmp->answer = $questionAnswer; } //sauvegarder commentaire - $comment = GETPOST('comment'.$questionId); + if ($data['autoSave'] && $questionId == $data['questionId']) { + $comment = $data['comment']; + } else { + $comment = GETPOST('comment' . $questionId); + } if (dol_strlen($comment) > 0) { $controldettmp->comment = $comment; @@ -38,7 +48,11 @@ $controldettmp->fk_question = $questionId; //sauvegarder réponse - $questionAnswer = GETPOST('answer'.$questionId); + if ($data['autoSave'] && $questionId == $data['questionId']) { + $questionAnswer = $data['answer']; + } else { + $questionAnswer = GETPOST('answer' . $questionId); + } if (!empty($questionAnswer)) { $controldettmp->answer = $questionAnswer; @@ -47,7 +61,12 @@ } //sauvegarder commentaire - $comment = GETPOST('comment'.$questionId); + if ($data['autoSave'] && $questionId == $data['questionId']) { + $comment = $data['comment']; + } else { + $comment = GETPOST('comment' . $questionId); + } + if (dol_strlen($comment) > 0) { $controldettmp->comment = $comment; } else { diff --git a/core/tpl/digiquali_control_list.tpl.php b/core/tpl/digiquali_control_list.tpl.php index a9a6a7cc..5f39392b 100644 --- a/core/tpl/digiquali_control_list.tpl.php +++ b/core/tpl/digiquali_control_list.tpl.php @@ -325,7 +325,7 @@ $disableSortField = dol_strlen($fromtype) > 0 ? preg_match('/'. $invertedElementElementFields[$fromtype] .'/',$key) : 0; $cssforfield = (empty($val['csslist']) ? (empty($val['css']) ? 'maxwidthsearch' : $val['css']) : $val['csslist']); - if ($key == 'status') $cssforfield .= ($cssforfield ? ' ' : '').'center'; + if (in_array($key, ['days_remaining_before_next_control', 'status', 'verdict'])) $cssforfield .= ($cssforfield ? ' ' : '').'center'; elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'center'; elseif (in_array($val['type'], array('timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $val['label'] != 'TechnicalID') $cssforfield .= ($cssforfield ? ' ' : '').'right'; @@ -377,7 +377,7 @@ { $cssforfield = (empty($val['css']) ? '' : $val['css']); if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'center'; - elseif ($key == 'status') $cssforfield .= ($cssforfield ? ' ' : '').'center'; + elseif (in_array($key, ['days_remaining_before_next_control', 'status', 'verdict'])) $cssforfield .= ($cssforfield ? ' ' : '').'center'; if (in_array($val['type'], array('timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; elseif ($key == 'ref') $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; @@ -397,17 +397,15 @@ print $sheet->getNomUrl(1); } elseif ($key == 'verdict') { - print dol_strlen($object->$key) > 0 ? $object->fields[$key]['arrayofkeyval'][$object->$key] : "N/A"; + $verdictColor = $object->$key == 1 ? 'green' : ($object->$key == 2 ? 'red' : 'grey'); + print dol_strlen($object->$key) > 0 ? '
' . $object->fields['verdict']['arrayofkeyval'][(!empty($object->$key)) ? $object->$key : 3] . '
' : "N/A"; } elseif ($key == 'days_remaining_before_next_control') { if (dol_strlen($object->next_control_date) > 0) { $nextControl = floor(($object->next_control_date - dol_now('tzuser'))/(3600 * 24)); - } else { - $nextControl = 0; + $nextControlColor = $nextControl < 0 ? 'red' : ($nextControl <= 30 ? 'orange' : ($nextControl <= 60 ? 'yellow' : 'green')); + print '
' . $nextControl . '
'; } - $nextControlColor = $nextControl < 0 ? 'red' : ($nextControl <= 30 ? 'orange' : ($nextControl <= 60 ? 'yellow' : 'green')); - - print '
' . $nextControl . '
' . $langs->trans('Days') . '
'; } elseif (in_array($key, $revertedElementFields)) { $linkedElement = $linkNameElementCorrespondance[$elementElementFields[$key]]; diff --git a/core/tpl/digiquali_public_control.tpl.php b/core/tpl/digiquali_public_control.tpl.php index 53c9205e..14bc0640 100644 --- a/core/tpl/digiquali_public_control.tpl.php +++ b/core/tpl/digiquali_public_control.tpl.php @@ -1,6 +1,6 @@
-
digiquali->multidir_output[$conf->entity] . '/' . $object->element . '/'. $object->ref . '/photos/', 'small', '', 0, 0, 0, 200, 200, 0, 0, 1, $object->element . '/'. $object->ref . '/photos/', $object, 'photo', 0, 0,0, 1); ?>
+
digiquali->multidir_output[$conf->entity] . '/' . $object->element . '/'. $object->ref . '/photos/', 'small', '', 0, 0, 0, 200, 200, 0, 0, 1, $object->element . '/'. $object->ref . '/photos/', $object, 'photo', 0, 0,0, 1); ?>
$linkableObject) { if ($linkableObject['conf'] > 0 && (!empty($object->linkedObjectsIds[$linkableObject['link_name']]))) { @@ -29,73 +29,63 @@ $objectName = $linkedObject->$objectNameField; } ?> -
transnoentities($linkableObject['langs']); ?>
-
-
-
- ' . $langs->trans('VerdictObject'); ?> - array_options['options_qc_frequency'] > 0 && getDolGlobalInt('SHOW_QC_FREQUENCY_PUBLIC_INTERFACE')) { - print '
' . $langs->transnoentities('QcFrequency') . ' : ' . $linkedObject->array_options['options_qc_frequency']; - } ?> -
-
- status == $object::STATUS_DRAFT) { - $verdictObjectColor = 'primary'; - $pictoObjectColor = 'hourglass-start'; - } elseif ($object->status == $object::STATUS_VALIDATED) { - $verdictObjectColor = 'primary'; - $pictoObjectColor = 'hourglass-half'; - } elseif (!empty($object->next_control_date) && $object->next_control_date - dol_now() < 0) { - $verdictObjectColor = 'red'; - $pictoObjectColor = 'exclamation'; - } elseif ($object->verdict > 1) { - $verdictObjectColor = 'red'; - $pictoObjectColor = 'exclamation'; - } else { - $verdictObjectColor = 'green'; - $pictoObjectColor = 'check'; - } - print '

'; ?> -
-
-
+
transnoentities($linkableObject['langs']); ?>
+ + + +
+ ' . $langs->trans('VerdictObject'); ?> + array_options['options_qc_frequency'] > 0 && getDolGlobalInt('DIGIQUALI_SHOW_QC_FREQUENCY_PUBLIC_INTERFACE')) { + print '
' . $langs->transnoentities('QcFrequency') . ' : ' . $linkedObject->array_options['options_qc_frequency']; + } ?> +
+ status == $object::STATUS_DRAFT) { + $verdictObjectColor = 'primary'; + $pictoObjectColor = 'hourglass-start'; + } elseif ($object->status == $object::STATUS_VALIDATED) { + $verdictObjectColor = 'primary'; + $pictoObjectColor = 'hourglass-half'; + } elseif (!empty($object->next_control_date) && $object->next_control_date - dol_now() < 0) { + $verdictObjectColor = 'red'; + $pictoObjectColor = 'exclamation'; + } elseif ($object->verdict > 1) { + $verdictObjectColor = 'red'; + $pictoObjectColor = 'exclamation'; + } else { + $verdictObjectColor = 'green'; + $pictoObjectColor = 'check'; + } + print '

'; ?> +
-
getNomUrl(1, 'nolink', 0, '', -1, 1); ?>
-
-
-
- getNomUrl(1, 'nolink') . '
'; - echo ' ' . $langs->trans('Verdict') . '
'; - echo img_picto('', 'calendar', 'class="pictofixedwidth"') . $langs->trans('ControlDate'); ?> -
-
- verdict == 1 ? 'green' : ($object->verdict == 2 ? 'red' : 'grey'); - if ($object->status < $object::STATUS_LOCKED) { - print $object->getLibStatut(5); - print '
'; - print ' ' . $langs->trans('NonFinalVerdict'); - } else { - print '
' . $object->fields['verdict']['arrayofkeyval'][(!empty($object->verdict)) ? $object->verdict : 3] . '
'; - } +
getNomUrl(1, 'nolink', 1, '', -1, 1); ?>
+ + + +
+ getNomUrl(1, 'nolink', 1) . '
'; + print ' ' . $langs->trans('Verdict') . '
'; + print '
' . saturne_show_medias_linked('digiquali', $conf->digiquali->multidir_output[$conf->entity] . '/control/' . $object->ref . '/qrcode/', 'small', 1, 0, 0, 0, 70, 70, 0, 0, 1, 'control/'. $object->ref . '/qrcode/', $object, '', 0, 0) . '
'; ?> +
+ verdict == 1 ? 'green' : ($object->verdict == 2 ? 'red' : 'grey'); + if ($object->status < $object::STATUS_LOCKED) { + print $object->getLibStatut(5); print '
'; - echo dol_print_date($object->control_date, 'day'); ?> - - - next_control_date)) : ?> -
-
- picto, 'class="pictofixedwidth"') . $langs->trans('NextControl') . '
'; - echo img_picto('', 'calendar', 'class="pictofixedwidth"') . $langs->trans('NextControlDate'); ?> -
-
- next_control_date - dol_now()) > 0) ? 'badge-status4' : 'badge-status8') . '">' . floor(($object->next_control_date - dol_now())/(3600 * 24)) . ' ' . $langs->trans('Days') . '

'; - echo dol_print_date($object->next_control_date, 'day'); ?> -
- - - + print ' ' . $langs->trans('NonFinalVerdict'); + } else { + print '
' . $object->fields['verdict']['arrayofkeyval'][(!empty($object->verdict)) ? $object->verdict : 3] . '
'; + } + if (!empty($object->next_control_date)) { + print '
' . $langs->trans('NextControl') . '
'; + $nextControl = floor(($object->next_control_date - dol_now())/(3600 * 24)); + $nextControlColor = $nextControl < 0 ? 'red' : ($nextControl <= 30 ? 'orange' : ($nextControl <= 60 ? 'yellow' : 'green')); + print dol_print_date($object->next_control_date, 'day') . '
' . $langs->trans('Remain') . '
'; + print '
'; + print '
' . $nextControl . ' ' . $langs->trans('Days') . '
'; + } ?> +
diff --git a/core/triggers/interface_99_modDigiQuali_DigiQualiTriggers.class.php b/core/triggers/interface_99_modDigiQuali_DigiQualiTriggers.class.php index 0262dbfa..dea3a12e 100644 --- a/core/triggers/interface_99_modDigiQuali_DigiQualiTriggers.class.php +++ b/core/triggers/interface_99_modDigiQuali_DigiQualiTriggers.class.php @@ -49,7 +49,7 @@ public function __construct($db) $this->name = preg_replace('/^Interface/i', '', get_class($this)); $this->family = 'demo'; $this->description = 'DigiQuali triggers.'; - $this->version = '1.8.1'; + $this->version = '1.9.0'; $this->picto = 'digiquali@digiquali'; } @@ -231,7 +231,6 @@ public function runTrigger($action, $object, User $user, Translate $langs, Conf if (!empty($linkedObject->array_options['options_qc_frequency'])) { $qcFrequency = $linkedObject->array_options['options_qc_frequency']; - $object->control_date = $this->db->idate($now); if ($object->verdict == 2) { $object->next_control_date = $this->db->idate($now); } else { @@ -249,6 +248,10 @@ public function runTrigger($action, $object, User $user, Translate $langs, Conf $actioncomm->percentage = ActionComm::EVENT_TODO; $actioncommID = $actioncomm->create($user); } + if (dol_strlen($object->control_date) <= 0) { + $object->control_date = $this->db->idate($now); + $object->setValueFrom('control_date', $object->control_date, '', '', 'date', '', $user); + } } } } @@ -264,13 +267,15 @@ public function runTrigger($action, $object, User $user, Translate $langs, Conf $reminderArray = explode(',' , getDolGlobalString('DIGIQUALI_CONTROL_REMINDER_FREQUENCY')); foreach ($reminderArray as $reminder) { - $dateReminder = dol_time_plus_duree($object->next_control_date, -$reminder, 'd'); - - $actionCommReminder->dateremind = $dateReminder; - $actionCommReminder->offsetvalue = $reminder; - $actionCommReminder->offsetunit = 'd'; - $actionCommReminder->typeremind = getDolGlobalString('DIGIQUALI_CONTROL_REMINDER_TYPE'); - $actionCommReminder->create($user); + if ($qcFrequency <= $reminder) { + $dateReminder = dol_time_plus_duree(dol_stringtotime($object->next_control_date), -$reminder, 'd'); + + $actionCommReminder->dateremind = $dateReminder; + $actionCommReminder->offsetvalue = $reminder; + $actionCommReminder->offsetunit = 'd'; + $actionCommReminder->typeremind = getDolGlobalString('DIGIQUALI_CONTROL_REMINDER_TYPE'); + $actionCommReminder->create($user); + } } } break; diff --git a/css/digiquali.min.css b/css/digiquali.min.css index 051b1310..e1b38c1a 100644 --- a/css/digiquali.min.css +++ b/css/digiquali.min.css @@ -1 +1 @@ -.control-audit *{box-sizing:border-box}.control-audit.multiselect{margin-top:-60px}.control-audit.multiselect>.wpeo-table{background:none !important}.control-audit.multiselect .table-cell{padding-top:0}.control-audit .wpeo-table.table-flex .table-row:not(.table-header):nth-of-type(odd){background:none}.control-audit .table-cell{margin-top:0 !important}.control-audit>.wpeo-table{border-bottom:1px solid rgba(0,0,0,.2)}.control-audit>.wpeo-table:nth-of-type(odd){background:rgba(38,60,92,.15)}.control-audit>.wpeo-table .cell-photo-check{text-align:right}@media(max-width: 600px){.control-audit>.wpeo-table .cell-photo-check{text-align:center}}.control-audit>.wpeo-table .question-photo-check{margin:0 4px;display:inline-block;position:relative}.control-audit>.wpeo-table .question-photo-check img{display:block;margin:0;width:200px;height:200px;background-size:cover}.control-audit>.wpeo-table .question-photo-check i{position:absolute;bottom:10px;right:10px;font-size:35px}.control-audit>.wpeo-table .question-photo-check.ko i{color:#e05353}.control-audit>.wpeo-table .question-photo-check.ok i{color:#47e58e}.control-audit>.wpeo-table .photo{margin:0 4px}.control-audit>.wpeo-table .photo.photo-ok{border:5px solid #47e58e}.control-audit>.wpeo-table .photo.photo-ko{border:5px solid #e05353}.control-audit>.wpeo-table .linked-medias{display:flex;gap:0 10px;flex-wrap:wrap}.control-audit>.wpeo-table .answer{display:inline-block;width:50px;height:50px;line-height:50px;font-size:18px;margin:0 4px;text-align:center;border-radius:50%;background:#fff;border:1px solid rgba(0,0,0,.4);transition:all .2s ease-out}@media(max-width: 600px){.control-audit>.wpeo-table .answer{width:80px;height:80px;line-height:80px;font-size:30px}}.control-audit>.wpeo-table .answer.square{border-radius:10%}.control-audit>.wpeo-table .answer:hover{cursor:pointer}.control-audit>.wpeo-table .answer.active{color:#fff !important}.control-audit>.wpeo-table .question-comment-container{margin-top:10px}.control-audit>.wpeo-table .question-comment-container .question-ref{font-size:13px;font-weight:700}.control-audit>.wpeo-table .question-comment-container .question-textarea{width:100%;background:#fff;border:1px solid rgba(0,0,0,.2);padding:1em 1.4em}.confirmquestions .answer{display:inline-block;width:30px;height:30px;line-height:30px;margin:0 4px;text-align:center;border-radius:50%;background:#fff;border:1px solid rgba(0,0,0,.4);-webkit-transition:all .2s ease-out;transition:all .2s ease-out}.confirmquestions .answer:hover{cursor:pointer}.confirmquestions .answer[value="1"]{color:#47e58e}.confirmquestions .answer[value="2"]{color:#e05353}.confirmquestions .answer[value="3"]{color:#e9ad4f}.confirmquestions .answer[value="4"]{color:rgba(0,0,0,.7);font-weight:700}.confirmquestions input[readonly]{border:0;width:100%;pointer-events:none}.confirmquestions input[readonly]:hover{cursor:default}.control-list-medias .question-section{display:block;margin-bottom:20px}.control-list-medias .question-section::after{display:block;content:"";clear:both}.control-list-medias .question-ref{font-weight:800;display:block;clear:both}.control-list-medias .media-container{display:block;float:left;margin-right:10px;margin-bottom:10px}.control-list-medias .media-container a{transition:all .2s ease-out}.control-list-medias .media-container a:hover{opacity:.8}.control-list-medias .media-container .photo{width:100%;height:100%;object-fit:cover}.question-table .linked-medias-list{display:flex;gap:10px;height:auto !important}@media(max-width: 500px){.question-table .linked-medias-list{flex-wrap:wrap}}@media(max-width: 500px){div.tabBar table.border.question-table tr.linked-medias,div.tabBar table.border.question-table tr.linked-medias .linked-medias-list{height:auto !important}}div.mainmenu.digiquali{background-image:none}div.mainmenu.digiquali::before{content:""}@media(max-width: 600px){div.tabsAction>span.butAction,div.tabsAction>span.butActionRefused,div.tabsAction>a.butAction,div.tabsAction>a.butActionDelete{padding:14px}}.dashboard-control{width:40px;height:40px;border-radius:6px;text-align:center;color:#fff;font-weight:900;font-size:14px;line-height:.9;padding:7px 2px;pointer-events:none}.preview-photo{z-index:2100 !important}.dropdown-toggle::after{display:none}.favorite-photo{border:5px solid #0d8aff} +.control-audit *{box-sizing:border-box}.control-audit.multiselect{margin-top:-60px}.control-audit.multiselect>.wpeo-table{background:none !important}.control-audit.multiselect .table-cell{padding-top:0}.control-audit .wpeo-table.table-flex .table-row:not(.table-header):nth-of-type(odd){background:none}.control-audit .table-cell{margin-top:0 !important}.control-audit>.wpeo-table{border-bottom:1px solid rgba(0,0,0,.2)}.control-audit>.wpeo-table:nth-of-type(odd){background:rgba(38,60,92,.15)}.control-audit>.wpeo-table .cell-photo-check{text-align:right}@media(max-width: 600px){.control-audit>.wpeo-table .cell-photo-check{text-align:center}}.control-audit>.wpeo-table .question-photo-check{margin:0 4px;display:inline-block;position:relative}.control-audit>.wpeo-table .question-photo-check img{display:block;margin:0;width:200px;height:200px;background-size:cover}.control-audit>.wpeo-table .question-photo-check i{position:absolute;bottom:10px;right:10px;font-size:35px}.control-audit>.wpeo-table .question-photo-check.ko i{color:#e05353}.control-audit>.wpeo-table .question-photo-check.ok i{color:#47e58e}.control-audit>.wpeo-table .photo{margin:0 4px}.control-audit>.wpeo-table .photo.photo-ok{border:5px solid #47e58e}.control-audit>.wpeo-table .photo.photo-ko{border:5px solid #e05353}.control-audit>.wpeo-table .linked-medias{display:flex;gap:0 10px;flex-wrap:wrap}.control-audit>.wpeo-table .answer{display:inline-block;width:50px;height:50px;line-height:50px;font-size:18px;margin:0 4px;text-align:center;border-radius:50%;background:#fff;border:1px solid rgba(0,0,0,.4);transition:all .2s ease-out}@media(max-width: 600px){.control-audit>.wpeo-table .answer{width:60px;height:60px;line-height:60px;font-size:25px}}.control-audit>.wpeo-table .answer.square{border-radius:10%}.control-audit>.wpeo-table .answer:hover{cursor:pointer}.control-audit>.wpeo-table .answer.active{color:#fff !important}.control-audit>.wpeo-table .question-comment-container{margin-top:10px}.control-audit>.wpeo-table .question-comment-container .question-ref{font-size:13px;font-weight:700}.control-audit>.wpeo-table .question-comment-container .question-textarea{width:100%;background:#fff;border:1px solid rgba(0,0,0,.2);padding:1em 1.4em}.confirmquestions .answer{display:inline-block;width:30px;height:30px;line-height:30px;margin:0 4px;text-align:center;border-radius:50%;background:#fff;border:1px solid rgba(0,0,0,.4);-webkit-transition:all .2s ease-out;transition:all .2s ease-out}.confirmquestions .answer:hover{cursor:pointer}.confirmquestions .answer[value="1"]{color:#47e58e}.confirmquestions .answer[value="2"]{color:#e05353}.confirmquestions .answer[value="3"]{color:#e9ad4f}.confirmquestions .answer[value="4"]{color:rgba(0,0,0,.7);font-weight:700}.confirmquestions input[readonly]{border:0;width:100%;pointer-events:none}.confirmquestions input[readonly]:hover{cursor:default}.control-list-medias .question-section{display:block;margin-bottom:20px}.control-list-medias .question-section::after{display:block;content:"";clear:both}.control-list-medias .question-ref{font-weight:800;display:block;clear:both}.control-list-medias .media-container{display:block;float:left;margin-right:10px;margin-bottom:10px}.control-list-medias .media-container a{transition:all .2s ease-out}.control-list-medias .media-container a:hover{opacity:.8}.control-list-medias .media-container .photo{width:100%;height:100%;object-fit:cover}.question-table .linked-medias-list{display:flex;gap:10px;height:auto !important}@media(max-width: 500px){.question-table .linked-medias-list{flex-wrap:wrap}}@media(max-width: 500px){div.tabBar table.border.question-table tr.linked-medias,div.tabBar table.border.question-table tr.linked-medias .linked-medias-list{height:auto !important}}div.mainmenu.digiquali{background-image:none}div.mainmenu.digiquali::before{content:""}@media(max-width: 600px){div.tabsAction>span.butAction,div.tabsAction>span.butActionRefused,div.tabsAction>a.butAction,div.tabsAction>a.butActionDelete{padding:14px}}.dashboard-control{width:40px;height:40px;border-radius:6px;text-align:center;color:#fff;font-weight:900;font-size:14px;line-height:.9;padding:7px 2px;pointer-events:none}.preview-photo{z-index:2100 !important}.dropdown-toggle::after{display:none}.favorite-photo{border:5px solid #0d8aff} \ No newline at end of file diff --git a/css/scss/page/_control.scss b/css/scss/page/_control.scss index 5a614f6d..d9480b82 100644 --- a/css/scss/page/_control.scss +++ b/css/scss/page/_control.scss @@ -94,10 +94,10 @@ transition: all 0.2s ease-out; @media ( max-width: $media__small ) { - width: 80px; - height: 80px; - line-height: 80px; - font-size: 30px; + width: 60px; + height: 60px; + line-height: 60px; + font-size: 25px; } &.square { diff --git a/css/scss/variable/_colors.scss b/css/scss/variable/_colors.scss new file mode 100644 index 00000000..4a89ade2 --- /dev/null +++ b/css/scss/variable/_colors.scss @@ -0,0 +1,15 @@ +$color__text-main: #333333; + +$color__primary: #0d8aff; +$color__primary-text: #fff; + +$color__secondary: #263C5C; +$color__secondary-text: #fff; + +$color__red: #e05353; +$color__yellow: #e9ad4f; +$color__orange: #ff6900; +$color__dark: #2b2b2b; +$color__grey: #ececec; +$color__blue: #0d8aff; +$color__green: #47e58e; diff --git a/css/scss/variable/_variable.scss b/css/scss/variable/_variable.scss index 8a4e9c84..b6dfd0e7 100644 --- a/css/scss/variable/_variable.scss +++ b/css/scss/variable/_variable.scss @@ -1 +1,2 @@ +@import "colors"; @import "structure"; diff --git a/js/digiquali.min.js b/js/digiquali.min.js index 8d702186..ffa04d5a 100644 --- a/js/digiquali.min.js +++ b/js/digiquali.min.js @@ -1 +1 @@ -window.digiquali||(window.digiquali={},window.digiquali.scriptsLoaded=!1),window.digiquali.scriptsLoaded||(window.digiquali.init=function(){window.digiquali.load_list_script()},window.digiquali.load_list_script=function(){if(!window.digiquali.scriptsLoaded){var i=void 0,o=void 0;for(i in window.digiquali)for(o in window.digiquali[i].init&&window.digiquali[i].init(),window.digiquali[i])window.digiquali[i]&&window.digiquali[i][o]&&window.digiquali[i][o].init&&window.digiquali[i][o].init();window.digiquali.scriptsLoaded=!0}},window.digiquali.refresh=function(){var i=void 0,o=void 0;for(i in window.digiquali)for(o in window.digiquali[i].refresh&&window.digiquali[i].refresh(),window.digiquali[i])window.digiquali[i]&&window.digiquali[i][o]&&window.digiquali[i][o].refresh&&window.digiquali[i][o].refresh()},$(document).ready(window.digiquali.init)),window.digiquali.control={},window.digiquali.control.init=function(){window.digiquali.control.event()},window.digiquali.control.event=function(){$(document).on("click",".answer:not(.disable)",window.digiquali.control.selectAnswer),$(document).on("input",".input-answer:not(.disable)",window.digiquali.control.selectAnswer),$(document).on("keyup",".question-comment",window.digiquali.control.writeComment),$(document).on("change",".control-table.linked-objects select",window.digiquali.control.disableOtherSelectors),$(document).on("keyup",".question-comment",window.digiquali.control.showCommentUnsaved),$(document).on("click",".validateButton",window.digiquali.control.getAnswerCounter),$(document).on("change","#fk_sheet",window.digiquali.control.showSelectObjectLinked),$(document).on("click",".toggleControlInfo",window.digiquali.control.toggleControlInfo),$(document).on("click",".clipboard-copy",window.digiquali.control.copyToClipboard),$(document).on("change","#productId",window.digiquali.control.refreshLotSelector),$(document).on("click",".switch-public-control-view",window.digiquali.control.switchPublicControlView)},window.digiquali.control.selectAnswer=function(i){var o=$(this).hasClass("answer")?$(this).attr("value"):$(this).val();let t="";var e=$(this).closest(".select-answer.answer-cell");if($(this).closest(".table-cell").hasClass("select-answer")){if($(this).hasClass("multiple-answers")){$(this).closest("span").toggleClass("active");let i=[];e.find(".multiple-answers.active").each(function(){i.push($(this).attr("value"))}),t=i}else $(this).closest(".table-cell").find(".answer.active").css("background-color","#fff"),$(this).closest(".table-cell").find("span").removeClass("active"),$(this).closest("span").addClass("active"),t=o;$(this).hasClass("active")?(e=$(this).closest(".answer-cell").find(".answer-color-"+$(this).attr("value")).val(),$(this).attr("style",$(this).attr("style")+" background:"+e+";")):$(this).attr("style",$(this).attr("style")+" background:#fff;"),$(this).closest(".answer-cell").find(".question-answer").val(t)}window.digiquali.control.updateButtonsStatus()},window.digiquali.control.writeComment=function(i){var o=$(this).closest(".table-cell").find(".question-comment").attr("name"),t=$(this).closest(".table-cell").find(".question-comment").val();let e=$(this).closest(".tabBar").find(".validateButton").attr("href");e.match("&"+o+"=")&&(e=e.split("&"+o+"=")[0]),$(this).closest(".tabBar").find(".validateButton").attr("href",e+"&"+o+"="+t)},window.digiquali.control.disableOtherSelectors=function(i){var o=document.getElementById("createControlForm"),o=new FormData(o),t=$(this).attr("id");0<=o.get(t)?$(".control-table.linked-objects").find("select").not("#"+t).attr("disabled",1):$(".control-table.linked-objects").find("select").not("#"+t).removeAttr("disabled")},window.digiquali.control.showCommentUnsaved=function(i){$(this).hasClass("show-comment-unsaved-message")||($(this).after('

Commentaire non enregistré

'),$(this).addClass("show-comment-unsaved-message")),window.digiquali.control.updateButtonsStatus()},window.digiquali.control.updateButtonsStatus=function(){$("#saveButton").removeClass("butActionRefused"),$("#saveButton").addClass("butAction"),$("#saveButton").attr("onclick",'$("#saveControl").submit()'),$("#validateButton").removeClass("butAction"),$("#validateButton").addClass("butActionRefused")},window.digiquali.control.getAnswerCounter=function(i){let o=0;jQuery("#tablelines").children().each(function(){0<$(this).find(".answer.active").length&&(o+=1)}),document.cookie="answerCounter="+o},window.digiquali.control.showSelectObjectLinked=function(i){var o=document.getElementById("createControlForm"),o=new FormData(o),t=$(".id-container").find('input[name="token"]').val(),e=o.get("fk_sheet"),n=o.get("fk_user_controller"),o=o.get("fk_project"),e=(e=document.URL+(document.URL.match(/\?action=create/)?"":"?action=create")+"&fk_sheet="+e+"&token="+t)+("&fk_project="+o)+("&fk_user_controller="+n);window.saturne.loader.display($(".tabBar.tabBarWithBottom tbody")),$.ajax({url:e,type:"POST",processData:!1,contentType:!1,success:function(i){$(".tabBar.tabBarWithBottom tbody").html($(i).find(".tabBar.tabBarWithBottom tbody").children()),$(".wpeo-loader").removeClass("wpeo-loader")},error:function(){}})},window.digiquali.control.toggleControlInfo=function(i){$(this).hasClass("fa-minus-square")?($(this).removeClass("fa-minus-square").addClass("fa-caret-square-down"),$(this).closest(".fiche").find(".fichecenter.controlInfo").addClass("hidden")):($(this).removeClass("fa-caret-square-down").addClass("fa-minus-square"),$(this).closest(".fiche").find(".fichecenter.controlInfo").removeClass("hidden"))},window.digiquali.control.copyToClipboard=function(i){var o=$(".copy-to-clipboard").attr("value");navigator.clipboard.writeText(o).then(()=>{$(".clipboard-copy").animate({backgroundColor:"#59ed9c"},200,()=>{$(".clipboard-copy").attr("class","fas fa-check clipboard-copy"),$(this).tooltip({items:".clipboard-copy",content:$("#copyToClipboardTooltip").val()}),$(this).tooltip("open"),$(".clipboard-copy").attr("style","")})})},window.digiquali.control.refreshLotSelector=function(i){var o=document.getElementById("add_control_equipment"),o=new FormData(o),t=window.saturne.toolbox.getToken(),o=o.get("productId"),t=document.URL+"&token="+t;t+="&fk_product="+o,window.saturne.loader.display($(".product-lot")),$.ajax({url:t,type:"POST",processData:!1,contentType:!1,success:function(i){$(".product-lot").replaceWith($(i).find(".product-lot"))},error:function(){}})},window.digiquali.control.switchPublicControlView=function(i){var o=$(this).find(".public-control-view").val(),t=window.saturne.toolbox.getToken();let e=document.URL+"&token="+t;e+=0==o?"&show_control_list=1":"&show_last_control=1",window.saturne.loader.display($(".signature-container")),$.ajax({url:e,type:"POST",processData:!1,contentType:!1,success:function(i){$("#publicControlHistory").replaceWith($(i).find("#publicControlHistory"))},error:function(){}})},window.digiquali.question={},window.digiquali.question.init=function(){window.digiquali.question.event()},window.digiquali.question.event=function(){$(document).on("click",".clicked-photo-preview",window.digiquali.question.previewPhoto),$(document).on("click",".ui-dialog-titlebar-close",window.digiquali.question.closePreviewPhoto),$(document).on("click","#show_photo",window.digiquali.question.showPhoto),$(document).on("click",".answer-picto .item, .wpeo-table .item",window.digiquali.question.selectAnswerPicto)},window.digiquali.question.previewPhoto=function(i){$(this).hasClass("photo-ok")?$("#dialogforpopup").attr("style","border: 10px solid #47e58e"):$(this).hasClass("photo-ko")&&$("#dialogforpopup").attr("style","border: 10px solid #e05353")},window.digiquali.question.closePreviewPhoto=function(i){$("#dialogforpopup").attr("style","border:")},window.digiquali.question.showPhoto=function(){var i=$(this).closest(".question-table").find(".linked-medias");i.hasClass("hidden")?(i.attr("style",""),i.removeClass("hidden")):(i.attr("style","display:none"),i.addClass("hidden"))},window.digiquali.question.selectAnswerPicto=function(i){var o=$(this).closest(".wpeo-dropdown");$(this).closest(".content").removeClass("active"),o.find(".dropdown-toggle span").hide(),o.find(".dropdown-toggle.button-picto").html($(this).closest(".wpeo-tooltip-event").html()),o.find(".input-hidden-picto").val($(this).data("label"))},window.digiquali.sheet={},window.digiquali.sheet.init=function(){window.digiquali.sheet.event()},window.digiquali.sheet.event=function(){}; \ No newline at end of file +window.digiquali||(window.digiquali={},window.digiquali.scriptsLoaded=!1),window.digiquali.scriptsLoaded||(window.digiquali.init=function(){window.digiquali.load_list_script()},window.digiquali.load_list_script=function(){if(!window.digiquali.scriptsLoaded){var i=void 0,o=void 0;for(i in window.digiquali)for(o in window.digiquali[i].init&&window.digiquali[i].init(),window.digiquali[i])window.digiquali[i]&&window.digiquali[i][o]&&window.digiquali[i][o].init&&window.digiquali[i][o].init();window.digiquali.scriptsLoaded=!0}},window.digiquali.refresh=function(){var i=void 0,o=void 0;for(i in window.digiquali)for(o in window.digiquali[i].refresh&&window.digiquali[i].refresh(),window.digiquali[i])window.digiquali[i]&&window.digiquali[i][o]&&window.digiquali[i][o].refresh&&window.digiquali[i][o].refresh()},$(document).ready(window.digiquali.init)),window.digiquali.control={},window.digiquali.control.init=function(){window.digiquali.control.event()},window.digiquali.control.event=function(){$(document).on("click",".answer:not(.disable)",window.digiquali.control.selectAnswer),$(document).on("input",".input-answer:not(.disable)",window.digiquali.control.selectAnswer),$(document).on("change",".control-table.linked-objects select",window.digiquali.control.disableOtherSelectors),$(document).on("keyup",".question-comment",window.digiquali.control.showCommentUnsaved),$(document).on("click",".validateButton",window.digiquali.control.getAnswerCounter),$(document).on("change","#fk_sheet",window.digiquali.control.showSelectObjectLinked),$(document).on("click",".toggleControlInfo",window.digiquali.control.toggleControlInfo),$(document).on("click",".clipboard-copy",window.digiquali.control.copyToClipboard),$(document).on("change","#productId",window.digiquali.control.refreshLotSelector),$(document).on("click",".switch-public-control-view",window.digiquali.control.switchPublicControlView),$(document).on("click",".show-only-questions-with-no-answer",window.digiquali.control.showOnlyQuestionsWithNoAnswer)},window.digiquali.control.selectAnswer=function(i){var o=$(this).closest(".select-answer.answer-cell"),t=o.attr("data-questionId"),e=$(this).closest(".table-id-"+t).attr("data-publicInterface"),n=$(this).closest(".table-id-"+t).attr("data-autoSave");let a="";var s=$(this).hasClass("answer")?$(this).attr("value"):$(this).val(),l=$(this).closest(".table-id-"+t).find("#comment"+t).val();if($(this).closest(".table-cell").hasClass("select-answer")){if($(this).hasClass("multiple-answers")){$(this).closest("span").toggleClass("active");let i=[];o.find(".multiple-answers.active").each(function(){i.push($(this).attr("value"))}),a=i}else $(this).closest(".table-cell").find(".answer.active").css("background-color","#fff"),$(this).closest(".table-cell").find("span").removeClass("active"),$(this).closest("span").addClass("active"),a=s;$(this).hasClass("active")?(o=$(this).closest(".answer-cell").find(".answer-color-"+$(this).attr("value")).val(),$(this).attr("style",$(this).attr("style")+" background:"+o+";")):$(this).attr("style",$(this).attr("style")+" background:#fff;"),$(this).closest(".answer-cell").find(".question-answer").val(a)}e||1!=n||$(this).hasClass("multiple-answers")?window.digiquali.control.updateButtonsStatus():window.digiquali.control.saveAnswer(t,a,l)},window.digiquali.control.disableOtherSelectors=function(i){var o=document.getElementById("createControlForm"),o=new FormData(o),t=$(this).attr("id");0<=o.get(t)?$(".control-table.linked-objects").find("select").not("#"+t).attr("disabled",1):$(".control-table.linked-objects").find("select").not("#"+t).removeAttr("disabled")},window.digiquali.control.showCommentUnsaved=function(i){$(this).hasClass("show-comment-unsaved-message")||($(this).after('

Commentaire non enregistré

'),$(this).addClass("show-comment-unsaved-message")),window.digiquali.control.updateButtonsStatus()},window.digiquali.control.updateButtonsStatus=function(){$("#saveButton").removeClass("butActionRefused"),$("#saveButton").addClass("butAction"),$("#saveButton").css("background","#0d8aff"),$(".fa-circle").css("display","inline"),$("#saveButton").attr("onclick",'$("#saveControl").submit()'),$(".validateButton").removeClass("butAction"),$("#dialog-confirm-actionButtonValidate").removeAttr("id"),$(".validateButton").addClass("butActionRefused")},window.digiquali.control.getAnswerCounter=function(i){let o=0;jQuery("#tablelines").children().each(function(){0<$(this).find(".answer.active").length&&(o+=1)}),document.cookie="answerCounter="+o},window.digiquali.control.showSelectObjectLinked=function(i){var o=document.getElementById("createControlForm"),o=new FormData(o),t=$(".id-container").find('input[name="token"]').val(),e=o.get("fk_sheet"),n=o.get("fk_user_controller"),o=o.get("fk_project"),e=(e=document.URL+(document.URL.match(/\?action=create/)?"":"?action=create")+"&fk_sheet="+e+"&token="+t)+("&fk_project="+o)+("&fk_user_controller="+n);window.saturne.loader.display($(".tabBar.tabBarWithBottom tbody")),$.ajax({url:e,type:"POST",processData:!1,contentType:!1,success:function(i){$(".tabBar.tabBarWithBottom tbody").html($(i).find(".tabBar.tabBarWithBottom tbody").children()),$(".wpeo-loader").removeClass("wpeo-loader")},error:function(){}})},window.digiquali.control.toggleControlInfo=function(i){$(this).hasClass("fa-minus-square")?($(this).removeClass("fa-minus-square").addClass("fa-caret-square-down"),$(this).closest(".fiche").find(".fichecenter.controlInfo").addClass("hidden")):($(this).removeClass("fa-caret-square-down").addClass("fa-minus-square"),$(this).closest(".fiche").find(".fichecenter.controlInfo").removeClass("hidden"))},window.digiquali.control.copyToClipboard=function(i){var o=$(".copy-to-clipboard").attr("value");navigator.clipboard.writeText(o).then(()=>{$(".clipboard-copy").animate({backgroundColor:"#59ed9c"},200,()=>{$(".clipboard-copy").attr("class","fas fa-check clipboard-copy"),$(this).tooltip({items:".clipboard-copy",content:$("#copyToClipboardTooltip").val()}),$(this).tooltip("open"),$(".clipboard-copy").attr("style","")})})},window.digiquali.control.refreshLotSelector=function(i){var o=document.getElementById("add_control_equipment"),o=new FormData(o),t=window.saturne.toolbox.getToken(),o=o.get("productId"),t=document.URL+"&token="+t;t+="&fk_product="+o,window.saturne.loader.display($(".product-lot")),$.ajax({url:t,type:"POST",processData:!1,contentType:!1,success:function(i){$(".product-lot").replaceWith($(i).find(".product-lot"))},error:function(){}})},window.digiquali.control.switchPublicControlView=function(i){var o=$(this).find(".public-control-view").val(),t=window.saturne.toolbox.getToken();let e=document.URL+"&token="+t;e+=0==o?"&show_control_list=1":"&show_last_control=1",window.saturne.loader.display($(".signature-container")),$.ajax({url:e,type:"POST",processData:!1,contentType:!1,success:function(i){$("#publicControlHistory").replaceWith($(i).find("#publicControlHistory"))},error:function(){}})},window.digiquali.control.showOnlyQuestionsWithNoAnswer=function(){var i=window.saturne.toolbox.getQuerySeparator(document.URL),o=window.saturne.toolbox.getToken();let t;t=$(this).is(":checked")?1:0,$.ajax({url:document.URL+i+"action=show_only_questions_with_no_answer&token="+o,type:"POST",processData:!1,data:JSON.stringify({showOnlyQuestionsWithNoAnswer:t}),contentType:!1,success:function(i){$(".questionLines").replaceWith($(i).find(".questionLines"))},error:function(){}})},window.digiquali.control.saveAnswer=function(o,i,t){var e=window.saturne.toolbox.getToken(),n=window.saturne.toolbox.getQuerySeparator(document.URL);window.saturne.loader.display($(".table-id-"+o)),$.ajax({url:document.URL+n+"action=save&token="+e,type:"POST",data:JSON.stringify({autoSave:!0,questionId:o,answer:i,comment:t}),processData:!1,contentType:!1,success:function(i){$(".table-id-"+o).replaceWith($(i).find(".table-id-"+o))},error:function(){}})},window.digiquali.question={},window.digiquali.question.init=function(){window.digiquali.question.event()},window.digiquali.question.event=function(){$(document).on("click",".clicked-photo-preview",window.digiquali.question.previewPhoto),$(document).on("click",".ui-dialog-titlebar-close",window.digiquali.question.closePreviewPhoto),$(document).on("click","#show_photo",window.digiquali.question.showPhoto),$(document).on("click",".answer-picto .item, .wpeo-table .item",window.digiquali.question.selectAnswerPicto)},window.digiquali.question.previewPhoto=function(i){$(this).hasClass("photo-ok")?$("#dialogforpopup").attr("style","border: 10px solid #47e58e"):$(this).hasClass("photo-ko")&&$("#dialogforpopup").attr("style","border: 10px solid #e05353")},window.digiquali.question.closePreviewPhoto=function(i){$("#dialogforpopup").attr("style","border:")},window.digiquali.question.showPhoto=function(){var i=$(this).closest(".question-table").find(".linked-medias");i.hasClass("hidden")?(i.attr("style",""),i.removeClass("hidden")):(i.attr("style","display:none"),i.addClass("hidden"))},window.digiquali.question.selectAnswerPicto=function(i){var o=$(this).closest(".wpeo-dropdown");$(this).closest(".content").removeClass("active"),o.find(".dropdown-toggle span").hide(),o.find(".dropdown-toggle.button-picto").html($(this).closest(".wpeo-tooltip-event").html()),o.find(".input-hidden-picto").val($(this).data("label"))},window.digiquali.sheet={},window.digiquali.sheet.init=function(){window.digiquali.sheet.event()},window.digiquali.sheet.event=function(){}; \ No newline at end of file diff --git a/js/modules/control.js b/js/modules/control.js index 3d022c7e..62f8c78e 100644 --- a/js/modules/control.js +++ b/js/modules/control.js @@ -30,7 +30,6 @@ window.digiquali.control.init = function() { window.digiquali.control.event = function() { $( document ).on( 'click', '.answer:not(.disable)', window.digiquali.control.selectAnswer ); $( document ).on( 'input', '.input-answer:not(.disable)', window.digiquali.control.selectAnswer ); - $( document ).on( 'keyup', '.question-comment', window.digiquali.control.writeComment ); $( document ).on( 'change', '.control-table.linked-objects select', window.digiquali.control.disableOtherSelectors ); $( document ).on( 'keyup', '.question-comment', window.digiquali.control.showCommentUnsaved ); $( document ).on( 'click', '.validateButton', window.digiquali.control.getAnswerCounter); @@ -39,6 +38,7 @@ window.digiquali.control.event = function() { $( document ).on( 'click', '.clipboard-copy', window.digiquali.control.copyToClipboard ); $( document ).on( 'change', '#productId', window.digiquali.control.refreshLotSelector ); $( document ).on( 'click', '.switch-public-control-view', window.digiquali.control.switchPublicControlView ); + $(document).on('click', '.show-only-questions-with-no-answer', window.digiquali.control.showOnlyQuestionsWithNoAnswer); }; /** @@ -51,9 +51,13 @@ window.digiquali.control.event = function() { * @return {void} */ window.digiquali.control.selectAnswer = function ( event ) { - let answerValue = $(this).hasClass('answer') ? $(this).attr('value') : $(this).val() - let answer = ''; - let questionElement = $(this).closest('.select-answer.answer-cell') + let questionElement = $(this).closest('.select-answer.answer-cell'); + let questionId = questionElement.attr('data-questionId'); + let publicInterface = $(this).closest('.table-id-' + questionId).attr('data-publicInterface'); + let autoSave = $(this).closest('.table-id-' + questionId).attr('data-autoSave'); + let answer = ''; + let answerValue = $(this).hasClass('answer') ? $(this).attr('value') : $(this).val(); + let comment = $(this).closest('.table-id-' + questionId).find('#comment' + questionId).val(); if ($(this).closest('.table-cell').hasClass('select-answer')) { if ($(this).hasClass('multiple-answers')) { $(this).closest('span').toggleClass( 'active' ); @@ -78,29 +82,11 @@ window.digiquali.control.selectAnswer = function ( event ) { $(this).closest('.answer-cell').find('.question-answer').val(answer) } - window.digiquali.control.updateButtonsStatus() -}; - -/** - * Write a comment for a control question. - * - * @since 1.0.0 - * @version 1.0.0 - * - * @param {MouseEvent} event Les attributs lors du clic. - * @return {void} - */ -window.digiquali.control.writeComment = function ( event ) { - - let postName = $(this).closest('.table-cell').find('.question-comment').attr('name') - let postValue = $(this).closest('.table-cell').find('.question-comment').val() - let actualValidatePost = $(this).closest('.tabBar').find('.validateButton').attr('href') - - if (actualValidatePost.match('&' + postName + '=')) { - actualValidatePost = actualValidatePost.split('&' + postName + '=')[0] - } - - $(this).closest('.tabBar').find('.validateButton').attr('href', actualValidatePost + '&' + postName + '=' + postValue) + if (!publicInterface && autoSave == 1 && !$(this).hasClass('multiple-answers')) { + window.digiquali.control.saveAnswer(questionId, answer, comment); + } else { + window.digiquali.control.updateButtonsStatus() + } }; /** @@ -156,10 +142,13 @@ window.digiquali.control.showCommentUnsaved = function ( event ) { window.digiquali.control.updateButtonsStatus = function ( ) { $('#saveButton').removeClass('butActionRefused') $('#saveButton').addClass('butAction') + $('#saveButton').css('background', '#0d8aff') + $('.fa-circle').css('display', 'inline') $('#saveButton').attr('onclick','$("#saveControl").submit()'); - $('#validateButton').removeClass('butAction') - $('#validateButton').addClass('butActionRefused') + $('.validateButton').removeClass('butAction') + $('#dialog-confirm-actionButtonValidate').removeAttr('id'); + $('.validateButton').addClass('butActionRefused') }; /** @@ -331,3 +320,72 @@ window.digiquali.control.switchPublicControlView = function( event ) { }); }; +/** + * Enables/disables the configuration to display only questions with no answer + * + * @memberof DigiQuali_Control + * + * @since 1.9.0 + * @version 1.9.0 + * + * @return {void} + */ +window.digiquali.control.showOnlyQuestionsWithNoAnswer = function() { + let querySeparator = window.saturne.toolbox.getQuerySeparator(document.URL) + let token = window.saturne.toolbox.getToken() + + let showOnlyQuestionsWithNoAnswer; + if ($(this).is(':checked')) { + showOnlyQuestionsWithNoAnswer = 1; + } else { + showOnlyQuestionsWithNoAnswer = 0; + } + + $.ajax({ + url: document.URL + querySeparator + "action=show_only_questions_with_no_answer&token=" + token, + type: "POST", + processData: false, + data: JSON.stringify({ + showOnlyQuestionsWithNoAnswer: showOnlyQuestionsWithNoAnswer + }), + contentType: false, + success: function(resp) { + $('.questionLines').replaceWith($(resp).find('.questionLines')) + }, + error: function() {} + }); +}; + +/** + * Save answer after click event + * + * @since 1.9.0 + * @version 1.9.0 + * + * @param {int} questionId Question ID + * @param {string} answer Answer value + * @param {string} comment Comment value + * @return {void} + */ +window.digiquali.control.saveAnswer = function(questionId, answer, comment) { + let token = window.saturne.toolbox.getToken(); + let querySeparator = window.saturne.toolbox.getQuerySeparator(document.URL); + window.saturne.loader.display($('.table-id-' + questionId)); + + $.ajax({ + url: document.URL + querySeparator + 'action=save&token=' + token, + type: "POST", + data: JSON.stringify({ + autoSave: true, + questionId: questionId, + answer: answer, + comment: comment + }), + processData: false, + contentType: false, + success: function(resp) { + $('.table-id-' + questionId).replaceWith($(resp).find('.table-id-' + questionId)); + }, + error: function() {} + }); +}; diff --git a/langs/fr_FR/digiquali.lang b/langs/fr_FR/digiquali.lang index 577add0d..0b3ea199 100644 --- a/langs/fr_FR/digiquali.lang +++ b/langs/fr_FR/digiquali.lang @@ -29,9 +29,7 @@ DigiQualiDescriptionLong = Système de management de la qualité pour Dolibarr # Data - Donnée RedirectAfterConnection = Redirection après la connexion au site RedirectAfterConnectionDescription = Redirection sur la page de bienvenue de DigiQuali par défaut au lieu de celle de Dolibarr. -EnableDigiquali = Veuillez activer le module DigiQuali pour accéder à cette page -AdvancedTriggers = Contenu des événéments avancé -AdvancedTriggersDescription = Active une description détaillée des événements de DigiQuali +EnableDigiquali = Veuillez activer le module DigiQuali pour accéder à cette page # # Questions @@ -88,6 +86,7 @@ AnswerCreated = La réponse a été créée avec succès AnswerUpdated = La réponse a été mise à jour avec succès AnswerDeleted = La réponse a été supprimée avec succès AnswerMustBeCreated = La question %s doit avoir au moins une réponse pour passer au statut verrouillé +ShowOnlyQuestionsWithNoAnswer = Afficher uniquement les questions qui n'ont pas de réponse # # Sheet @@ -287,8 +286,6 @@ ControlReminderFrequencyDescription = Choisir la fréquence de rappel ControlReminderType = Type de rappel d'évènement de contrôle ControlReminderTypeDescription = Choisir le type de rappel d'évènement de contrôle
(par défaut : navigateur) controlled = contrôlé(e) -NextControlDateUpdated = La date de prochain contrôle a été mise à jour -ErrorUpdatingNextControlDate = La date de prochain contrôle n'a pas pu être mise à jour PublicSurvey = Interface publique de réponse au contrôle PublicSurveyTitle = Titre de l'interface publique de réponse au contrôle PublicSurveyTitleDescription = Définir le titre de l'interface publique de réponse au contrôle @@ -318,10 +315,12 @@ ShowQcFrequencyPublicInterfaceDescription = Option permettant l'affichage l # # Data - Donnée -AnswerSaved = Les réponses ont été sauvegardées -Repair = SAV -NotApplicable = NA -AnswerPhoto = Photo +AnswerSaved = Les réponses ont été sauvegardées +Repair = SAV +NotApplicable = NA +AnswerPhoto = Photo +AutoSaveActionQuestionAnswer = Sauvegarde automatique des réponses aux questions +AutoSaveActionQuestionAnswerDescription = Sauvegarde automatiquement les réponses aux questions lors du choix de la réponse # # ControlDocument - Fiche de Contrôle @@ -364,3 +363,4 @@ ImportFinishWith = L'import des %s a été terminé avec %s err SelectProducts = Sélectionner un produit SelectProductsOrServices = Sélectionner un produit / service Contact = Contact/Adresse +Remain = reste diff --git a/lib/digiquali.lib.php b/lib/digiquali.lib.php index 360b9875..4ccd8186 100644 --- a/lib/digiquali.lib.php +++ b/lib/digiquali.lib.php @@ -39,37 +39,37 @@ function digiquali_admin_prepare_head(): array $head = []; $head[$h][0] = dol_buildpath('/digiquali/admin/question.php', 1); - $head[$h][1] = '' . $langs->trans('Question'); + $head[$h][1] = $conf->browser->layout != 'phone' ? '' . $langs->trans('Question') : ''; $head[$h][2] = 'question'; $h++; $head[$h][0] = dol_buildpath('/saturne/admin/object.php', 1) . '?module_name=DigiQuali&object_type=answer'; - $head[$h][1] = '' . $langs->trans('Answer'); + $head[$h][1] = $conf->browser->layout != 'phone' ? '' . $langs->trans('Answer') : ''; $head[$h][2] = 'answer'; $h++; $head[$h][0] = dol_buildpath('/digiquali/admin/sheet.php', 1); - $head[$h][1] = '' . $langs->trans('Sheet'); + $head[$h][1] = $conf->browser->layout != 'phone' ? '' . $langs->trans('Sheet') : ''; $head[$h][2] = 'sheet'; $h++; $head[$h][0] = dol_buildpath('/digiquali/admin/control.php', 1); - $head[$h][1] = '' . $langs->trans('Control'); + $head[$h][1] = $conf->browser->layout != 'phone' ? '' . $langs->trans('Control') : ''; $head[$h][2] = 'control'; $h++; $head[$h][0] = dol_buildpath('/saturne/admin/documents.php?module_name=DigiQuali', 1); - $head[$h][1] = ' ' . $langs->trans('YourDocuments'); + $head[$h][1] = $conf->browser->layout != 'phone' ? '' . $langs->trans('YourDocuments') : ''; $head[$h][2] = 'documents'; $h++; $head[$h][0] = dol_buildpath('/digiquali/admin/setup.php', 1); - $head[$h][1] = '' . $langs->trans('ModuleSettings'); + $head[$h][1] = $conf->browser->layout != 'phone' ? '' . $langs->trans('ModuleSettings') : ''; $head[$h][2] = 'settings'; $h++; $head[$h][0] = dol_buildpath('/saturne/admin/about.php?module_name=DigiQuali', 1); - $head[$h][1] = '' . $langs->trans('About'); + $head[$h][1] = $conf->browser->layout != 'phone' ? '' . $langs->trans('About') : ''; $head[$h][2] = 'about'; $h++; diff --git a/lib/digiquali_control.lib.php b/lib/digiquali_control.lib.php index 3bc985cf..f5d283dc 100644 --- a/lib/digiquali_control.lib.php +++ b/lib/digiquali_control.lib.php @@ -34,10 +34,10 @@ function control_prepare_head(Control $object): array { // Global variables definitions. - global $db, $langs; + global $conf, $db, $langs; $head[1][0] = dol_buildpath('/digiquali/view/control/control_medias.php', 1) . '?id=' . $object->id; - $head[1][1] = '' . $langs->trans('Medias'); + $head[1][1] = $conf->browser->layout != 'phone' ? '' . $langs->trans('Medias') : ''; $head[1][2] = 'medias'; // Initialize technical objects @@ -50,9 +50,10 @@ function control_prepare_head(Control $object): array $nbEquipment = 0; } - $head[2][0] = dol_buildpath('/digiquali/view/control/control_equipment.php', 1) . '?id=' . $object->id; - $head[2][1] = '' . $langs->trans('ControlEquipment') . '' . $nbEquipment . ''; - $head[2][2] = 'equipment'; + $head[2][0] = dol_buildpath('/digiquali/view/control/control_equipment.php', 1) . '?id=' . $object->id; + $head[2][1] = $conf->browser->layout != 'phone' ? '' . $langs->trans('ControlEquipment') : ''; + $head[2][1] .= '' . $nbEquipment . ''; + $head[2][2] = 'equipment'; $moreparam['documentType'] = 'ControlDocument'; $moreparam['attendantTableMode'] = 'simple'; diff --git a/lib/digiquali_sheet.lib.php b/lib/digiquali_sheet.lib.php index 245de7fd..8487482a 100644 --- a/lib/digiquali_sheet.lib.php +++ b/lib/digiquali_sheet.lib.php @@ -33,11 +33,12 @@ */ function sheet_prepare_head(Sheet $object): array { - global $langs; + // Global variables definitions + global $conf, $langs; - $head[100][0] = dol_buildpath('/digiquali/view/sheet/sheet_export.php', 1) . '?id=' . $object->id; - $head[100][1] = '' . $langs->trans('Export'); - $head[100][2] = 'export'; + $head[2][0] = dol_buildpath('/digiquali/view/sheet/sheet_export.php', 1) . '?id=' . $object->id; + $head[2][1] = $conf->browser->layout != 'phone' ? '' . $langs->trans('Export') : ''; + $head[2][2] = 'export'; return saturne_object_prepare_head($object, $head); } @@ -71,208 +72,236 @@ function get_sheet_linkable_objects(): array if (isModEnabled('product')) { $linkableObjectTypes['product'] = [ - 'langs' => 'ProductOrService', - 'langfile' => 'products', - 'picto' => 'product', - 'className' => 'Product', - 'post_name' => 'fk_product', - 'link_name' => 'product', - 'tab_type' => 'product', - 'name_field' => 'ref', - 'create_url' => 'product/card.php', - 'class_path' => 'product/class/product.class.php', + 'langs' => 'ProductOrService', + 'langfile' => 'products', + 'picto' => 'product', + 'className' => 'Product', + 'post_name' => 'fk_product', + 'link_name' => 'product', + 'tab_type' => 'product', + 'hook_name_list' => 'productservicelist', + 'hook_name_card' => 'productcard', + 'name_field' => 'ref', + 'create_url' => 'product/card.php', + 'class_path' => 'product/class/product.class.php', ]; } if (isModEnabled('productbatch')) { $linkableObjectTypes['productlot'] = [ - 'langs' => 'Batch', - 'langfile' => 'products', - 'picto' => 'lot', - 'className' => 'ProductLot', - 'post_name' => 'fk_productlot', - 'link_name' => 'productbatch', - 'tab_type' => 'productlot', - 'name_field' => 'batch', - 'fk_parent' => 'fk_product', - 'parent_post' => 'fk_product', - 'create_url' => 'product/stock/productlot_card.php', - 'class_path' => 'product/stock/class/productlot.class.php', + 'langs' => 'Batch', + 'langfile' => 'products', + 'picto' => 'lot', + 'className' => 'ProductLot', + 'post_name' => 'fk_productlot', + 'link_name' => 'productbatch', + 'tab_type' => 'productlot', + 'hook_name_list' => 'product_lotlist', + 'hook_name_card' => 'productlotcard', + 'name_field' => 'batch', + 'fk_parent' => 'fk_product', + 'parent_post' => 'fk_product', + 'create_url' => 'product/stock/productlot_card.php', + 'class_path' => 'product/stock/class/productlot.class.php', ]; } if (isModEnabled('user')) { $linkableObjectTypes['user'] = [ - 'langs' => 'User', - 'picto' => 'user', - 'className' => 'User', - 'post_name' => 'fk_user', - 'link_name' => 'user', - 'tab_type' => 'user', - 'name_field' => 'lastname, firstname', - 'create_url' => 'user/card.php', - 'class_path' => 'user/class/user.class.php', + 'langs' => 'User', + 'picto' => 'user', + 'className' => 'User', + 'post_name' => 'fk_user', + 'link_name' => 'user', + 'tab_type' => 'user', + 'hook_name_list' => 'userlist', + 'hook_name_card' => 'usercard', + 'name_field' => 'lastname, firstname', + 'create_url' => 'user/card.php', + 'class_path' => 'user/class/user.class.php', ]; } if (isModEnabled('societe')) { $linkableObjectTypes['thirdparty'] = [ - 'langs' => 'ThirdParty', - 'langfile' => 'companies', - 'picto' => 'building', - 'className' => 'Societe', - 'post_name' => 'fk_soc', - 'link_name' => 'societe', - 'tab_type' => 'thirdparty', - 'name_field' => 'nom', - 'create_url' => 'societe/card.php', - 'class_path' => 'societe/class/societe.class.php', + 'langs' => 'ThirdParty', + 'langfile' => 'companies', + 'picto' => 'building', + 'className' => 'Societe', + 'post_name' => 'fk_soc', + 'link_name' => 'societe', + 'tab_type' => 'thirdparty', + 'hook_name_list' => 'thirdpartylist', + 'hook_name_card' => 'thirdpartycard', + 'name_field' => 'nom', + 'create_url' => 'societe/card.php', + 'class_path' => 'societe/class/societe.class.php', ]; $linkableObjectTypes['contact'] = [ - 'langs' => 'Contact', - 'langfile' => 'companies', - 'picto' => 'address', - 'className' => 'Contact', - 'post_name' => 'fk_contact', - 'link_name' => 'contact', - 'tab_type' => 'contact', - 'name_field' => 'lastname, firstname', - 'fk_parent' => 'fk_soc', - 'parent_post' => 'fk_soc', - 'create_url' => 'contact/card.php', - 'class_path' => 'contact/class/contact.class.php', + 'langs' => 'Contact', + 'langfile' => 'companies', + 'picto' => 'address', + 'className' => 'Contact', + 'post_name' => 'fk_contact', + 'link_name' => 'contact', + 'tab_type' => 'contact', + 'hook_name_list' => 'contactlist', + 'hook_name_card' => 'contactcard', + 'name_field' => 'lastname, firstname', + 'fk_parent' => 'fk_soc', + 'parent_post' => 'fk_soc', + 'create_url' => 'contact/card.php', + 'class_path' => 'contact/class/contact.class.php', ]; } if (isModEnabled('project')) { $linkableObjectTypes['project'] = [ - 'langs' => 'Project', - 'langfile' => 'projects', - 'picto' => 'project', - 'className' => 'Project', - 'post_name' => 'fk_project', - 'link_name' => 'project', - 'tab_type' => 'project', - 'name_field' => 'ref, title', - 'create_url' => 'projet/card.php', - 'class_path' => 'projet/class/project.class.php', + 'langs' => 'Project', + 'langfile' => 'projects', + 'picto' => 'project', + 'className' => 'Project', + 'post_name' => 'fk_project', + 'link_name' => 'project', + 'tab_type' => 'project', + 'hook_name_list' => 'projectlist', + 'hook_name_card' => 'projectcard', + 'name_field' => 'ref, title', + 'create_url' => 'projet/card.php', + 'class_path' => 'projet/class/project.class.php', ]; $linkableObjectTypes['task'] = [ - 'langs' => 'Task', - 'langfile' => 'projects', - 'picto' => 'projecttask', - 'className' => 'SaturneTask', - 'post_name' => 'fk_task', - 'link_name' => 'project_task', - 'tab_type' => 'task', - 'name_field' => 'label', - 'fk_parent' => 'fk_projet', - 'parent_post' => 'fk_project', - 'create_url' => 'projet/tasks.php', - 'class_path' => 'custom/saturne/class/task/saturnetask.class.php', + 'langs' => 'Task', + 'langfile' => 'projects', + 'picto' => 'projecttask', + 'className' => 'SaturneTask', + 'post_name' => 'fk_task', + 'link_name' => 'project_task', + 'tab_type' => 'task', + 'hook_name_list' => 'tasklist', + 'hook_name_card' => 'projecttaskcard', + 'name_field' => 'label', + 'fk_parent' => 'fk_projet', + 'parent_post' => 'fk_project', + 'create_url' => 'projet/tasks.php', + 'class_path' => 'custom/saturne/class/task/saturnetask.class.php', ]; } if (isModEnabled('facture')) { $linkableObjectTypes['invoice'] = [ - 'langs' => 'Invoice', - 'langfile' => 'bills', - 'picto' => 'bill', - 'className' => 'Facture', - 'post_name' => 'fk_invoice', - 'link_name' => 'facture', - 'tab_type' => 'invoice', - 'name_field' => 'ref', - 'create_url' => 'compta/facture/card.php', - 'class_path' => 'compta/facture/class/facture.class.php', + 'langs' => 'Invoice', + 'langfile' => 'bills', + 'picto' => 'bill', + 'className' => 'Facture', + 'post_name' => 'fk_invoice', + 'link_name' => 'facture', + 'tab_type' => 'invoice', + 'hook_name_list' => 'invoicelist', + 'hook_name_card' => 'invoicecard', + 'name_field' => 'ref', + 'create_url' => 'compta/facture/card.php', + 'class_path' => 'compta/facture/class/facture.class.php', ]; } if (isModEnabled('order')) { $linkableObjectTypes['order'] = [ - 'langs' => 'Order', - 'langfile' => 'orders', - 'picto' => 'order', - 'className' => 'Commande', - 'post_name' => 'fk_order', - 'link_name' => 'commande', - 'tab_type' => 'order', - 'name_field' => 'ref', - 'create_url' => 'commande/card.php', - 'class_path' => 'commande/class/commande.class.php', + 'langs' => 'Order', + 'langfile' => 'orders', + 'picto' => 'order', + 'className' => 'Commande', + 'post_name' => 'fk_order', + 'link_name' => 'commande', + 'tab_type' => 'order', + 'hook_name_list' => 'orderlist', + 'hook_name_card' => 'ordercard', + 'name_field' => 'ref', + 'create_url' => 'commande/card.php', + 'class_path' => 'commande/class/commande.class.php', ]; } if (isModEnabled('contract')) { $linkableObjectTypes['contract'] = [ - 'langs' => 'Contract', - 'langfile' => 'contracts', - 'picto' => 'contract', - 'className' => 'Contrat', - 'post_name' => 'fk_contract', - 'link_name' => 'contrat', - 'tab_type' => 'contract', - 'name_field' => 'ref', - 'create_url' => 'contrat/card.php', - 'class_path' => 'contrat/class/contrat.class.php', + 'langs' => 'Contract', + 'langfile' => 'contracts', + 'picto' => 'contract', + 'className' => 'Contrat', + 'post_name' => 'fk_contract', + 'link_name' => 'contrat', + 'tab_type' => 'contract', + 'hook_name_list' => 'contractlist', + 'hook_name_card' => 'contractcard', + 'name_field' => 'ref', + 'create_url' => 'contrat/card.php', + 'class_path' => 'contrat/class/contrat.class.php', ]; } if (isModEnabled('ticket')) { $linkableObjectTypes['ticket'] = [ - 'langs' => 'Ticket', - 'picto' => 'ticket', - 'className' => 'Ticket', - 'post_name' => 'fk_ticket', - 'link_name' => 'ticket', - 'tab_type' => 'ticket', - 'name_field' => 'ref, subject', - 'create_url' => 'ticket/card.php', - 'class_path' => 'ticket/class/ticket.class.php', + 'langs' => 'Ticket', + 'picto' => 'ticket', + 'className' => 'Ticket', + 'post_name' => 'fk_ticket', + 'link_name' => 'ticket', + 'tab_type' => 'ticket', + 'hook_name_list' => 'ticketlist', + 'hook_name_card' => 'ticketcard', + 'name_field' => 'ref, subject', + 'create_url' => 'ticket/card.php', + 'class_path' => 'ticket/class/ticket.class.php', ]; } if (isModEnabled('stock')) { $linkableObjectTypes['entrepot'] = [ - 'langs' => 'Warehouse', - 'langfile' => 'stocks', - 'picto' => 'stock', - 'className' => 'Entrepot', - 'post_name' => 'fk_entrepot', - 'link_name' => 'stock', - 'tab_type' => 'stock', - 'name_field' => 'ref', - 'create_url' => 'product/stock/entrepot/card.php', - 'class_path' => 'product/stock/class/entrepot.class.php', + 'langs' => 'Warehouse', + 'langfile' => 'stocks', + 'picto' => 'stock', + 'className' => 'Entrepot', + 'post_name' => 'fk_entrepot', + 'link_name' => 'stock', + 'tab_type' => 'stock', + 'hook_name_list' => 'stocklist', + 'hook_name_card' => 'warehousecard', + 'name_field' => 'ref', + 'create_url' => 'product/stock/entrepot/card.php', + 'class_path' => 'product/stock/class/entrepot.class.php', ]; } if (isModEnabled('expedition')) { $linkableObjectTypes['expedition'] = [ - 'langs' => 'Shipment', - 'langfile' => 'sendings', - 'picto' => 'dolly', - 'className' => 'DigiQualiExpedition', - 'post_name' => 'fk_expedition', - 'link_name' => 'expedition', - 'tab_type' => 'delivery', - 'name_field' => 'ref', - 'class_path' => 'custom/digiquali/class/dolibarrobjects/digiqualiexpedition.class.php', + 'langs' => 'Shipment', + 'langfile' => 'sendings', + 'picto' => 'dolly', + 'className' => 'DigiQualiExpedition', + 'post_name' => 'fk_expedition', + 'link_name' => 'expedition', + 'tab_type' => 'delivery', + 'hook_name_list' => 'shipmentlist', + 'hook_name_card' => 'ordershipmentcard', + 'name_field' => 'ref', + 'class_path' => 'custom/digiquali/class/dolibarrobjects/digiqualiexpedition.class.php', ]; } if (isModEnabled('propal')) { $linkableObjectTypes['propal'] = [ - 'langs' => 'Proposal', - 'langfile' => 'propal', - 'picto' => 'propal', - 'className' => 'Propal', - 'post_name' => 'fk_propal', - 'link_name' => 'propal', - 'tab_type' => 'propal', - 'name_field' => 'ref', - 'create_url' => 'comm/propal/card.php', - 'class_path' => 'comm/propal/class/propal.class.php', + 'langs' => 'Proposal', + 'langfile' => 'propal', + 'picto' => 'propal', + 'className' => 'Propal', + 'post_name' => 'fk_propal', + 'link_name' => 'propal', + 'tab_type' => 'propal', + 'hook_name_list' => 'propallist', + 'hook_name_card' => 'propalcard', + 'name_field' => 'ref', + 'create_url' => 'comm/propal/card.php', + 'class_path' => 'comm/propal/class/propal.class.php', ]; } @@ -339,22 +368,24 @@ function get_sheet_linkable_objects(): array $confCode = 'DIGIQUALI_SHEET_LINK_' . strtoupper($linkableObjectType); $linkableObjects[$linkableObjectType] = [ - 'code' => $confCode, - 'conf' => $conf->global->$confCode, - 'name' => 'Link' . ucfirst($linkableObjectType), - 'description' => 'Link' . ucfirst($linkableObjectType) . 'Description', - 'langs' => $linkableObjectInformations['langs'] ?? '', - 'langfile' => $linkableObjectInformations['langfile'] ?? '', - 'picto' => $linkableObjectInformations['picto'] ?? '', - 'className' => $linkableObjectInformations['className'] ?? '', - 'name_field' => $linkableObjectInformations['name_field'] ?? '', - 'post_name' => $linkableObjectInformations['post_name'] ?? '', - 'link_name' => $linkableObjectInformations['link_name'] ?? '', - 'tab_type' => $linkableObjectInformations['tab_type'] ?? '', - 'fk_parent' => $linkableObjectInformations['fk_parent'] ?? '', - 'parent_post' => $linkableObjectInformations['parent_post'] ?? '', - 'create_url' => $linkableObjectInformations['create_url'] ?? '', - 'class_path' => $linkableObjectInformations['class_path'] ?? '', + 'code' => $confCode, + 'conf' => $conf->global->$confCode, + 'name' => 'Link' . ucfirst($linkableObjectType), + 'description' => 'Link' . ucfirst($linkableObjectType) . 'Description', + 'langs' => $linkableObjectInformations['langs'] ?? '', + 'langfile' => $linkableObjectInformations['langfile'] ?? '', + 'picto' => $linkableObjectInformations['picto'] ?? '', + 'className' => $linkableObjectInformations['className'] ?? '', + 'name_field' => $linkableObjectInformations['name_field'] ?? '', + 'post_name' => $linkableObjectInformations['post_name'] ?? '', + 'link_name' => $linkableObjectInformations['link_name'] ?? '', + 'tab_type' => $linkableObjectInformations['tab_type'] ?? '', + 'hook_name_list' => $linkableObjectInformations['hook_name_list'] ?? '', + 'hook_name_card' => $linkableObjectInformations['hook_name_card'] ?? '', + 'fk_parent' => $linkableObjectInformations['fk_parent'] ?? '', + 'parent_post' => $linkableObjectInformations['parent_post'] ?? '', + 'create_url' => $linkableObjectInformations['create_url'] ?? '', + 'class_path' => $linkableObjectInformations['class_path'] ?? '', ]; if (!empty($linkableObjectInformations['langfile'])) { $langs->load($linkableObjectInformations['langfile']); diff --git a/public/control/public_control_history.php b/public/control/public_control_history.php index 92bde0b3..1105dffc 100644 --- a/public/control/public_control_history.php +++ b/public/control/public_control_history.php @@ -150,28 +150,32 @@ if ($showLastControlFirst == 1) { $object = array_shift($objectControlList); $object->fetchObjectLinked('', '', '', 'digiquali_control'); + $sheet->fetch($object->fk_sheet); require_once __DIR__ . '/../../core/tpl/digiquali_public_control.tpl.php'; - } else { - - print '
'; + } elseif ($conf->browser->layout != 'phone') { + print '
'; print load_fiche_titre($langs->trans('ControlList'), $objectLinked->getNomUrl(1, 'nolink'), $object->picto); print ''; print ''; - print ''; + print ''; foreach($objectControlList as $objectControl) { $verdictColor = $objectControl->verdict == 1 ? 'green' : ($objectControl->verdict == 2 ? 'red' : 'grey'); @@ -181,24 +185,74 @@ $sheet->fetch($objectControl->fk_sheet); print ''; - print ''; + if (dol_strlen($objectControl->next_control_date) > 0) { + print ''; + } else { + print ''; + } print ''; } print '
'; + print ''; print $langs->trans('Ref'); - print ''; + print ''; + print $langs->trans('QRCode'); + print ''; print $langs->trans('Controller'); - print ''; + print ''; print $langs->trans('Project'); - print ''; + print ''; print $langs->trans('Sheet'); - print ''; - print $langs->trans('ControlDate'); - print ''; + print ''; print $langs->trans('Verdict'); - print ''; - print $langs->trans('Status'); - print '
'; + print $langs->trans('ControlDate'); + print ''; + print $langs->trans('NextControl'); + print ''; + print $langs->trans('NextControlDate'); + print '
'; - print $objectControl->getNomUrl(1, 'nolink'); - print ''; + print ''; + print $objectControl->getNomUrl(1, 'nolink', 1); + $publicControlInterfaceUrl = dol_buildpath('custom/digiquali/public/control/public_control.php?track_id=' . $objectControl->track_id . '&entity=' . $conf->entity, 3); + print ' '; + print ''; + print saturne_show_medias_linked('digiquali', $conf->digiquali->multidir_output[$conf->entity] . '/control/' . $objectControl->ref . '/qrcode/', 'small', 1, 0, 0, 0, 80, 80, 0, 0, 1, 'control/'. $objectControl->ref . '/qrcode/', $objectControl, '', 0, 0); + print ''; print $user->getNomUrl(1, 'nolink'); - print ''; + print ''; print ($objectControl->projectid > 0 ? img_picto($langs->trans('Project'), 'project', 'class="pictofixedwidth"') . $project->ref : ''); - print ''; - print $sheet->getNomUrl(1, 'nolink'); - print ''; + print ''; + print $sheet->getNomUrl(1, 'nolink', 1); + print ''; + print '
' . $objectControl->fields['verdict']['arrayofkeyval'][(!empty($objectControl->verdict)) ? $objectControl->verdict : 3] . '
'; + print '
'; print dol_print_date($objectControl->control_date); - print ''; - print '
' . $objectControl->fields['verdict']['arrayofkeyval'][(!empty($objectControl->verdict)) ?: 3] . '
'; - print '
'; - print $objectControl->getLibStatut(5); + print ''; + $nextControl = floor(($objectControl->next_control_date - dol_now())/(3600 * 24)); + $nextControlColor = $nextControl < 0 ? 'red' : ($nextControl <= 30 ? 'orange' : ($nextControl <= 60 ? 'yellow' : 'green')); + print '
' . $nextControl . ' ' . $langs->trans('Days') . '
'; + print '
'; + print dol_print_date($objectControl->next_control_date); + print '
'; print '
'; + } else { + // Phone view + print '
'; + print load_fiche_titre($langs->trans('ControlList'), $objectLinked->getNomUrl(1, 'nolink'), $object->picto); + print ''; + + foreach($objectControlList as $objectControl) { + $verdictColor = $objectControl->verdict == 1 ? 'green' : ($objectControl->verdict == 2 ? 'red' : 'grey'); + + $user->fetch($objectControl->fk_user_controller); + $project->fetch($objectControl->projectid); + $sheet->fetch($objectControl->fk_sheet); + + print ''; + print ''; + } + print '
'; + print $objectControl->getNomUrl(1, 'nolink', 1); + $publicControlInterfaceUrl = dol_buildpath('custom/digiquali/public/control/public_control.php?track_id=' . $objectControl->track_id . '&entity=' . $conf->entity, 3); + print '
'; + print $user->getNomUrl(1, 'nolink') . '
'; + print ($objectControl->projectid > 0 ? img_picto($langs->trans('Project'), 'project', 'class="pictofixedwidth"') . $project->ref . '
' : ''); + print $sheet->getNomUrl(1, 'nolink', 1) . '
'; + print saturne_show_medias_linked('digiquali', $conf->digiquali->multidir_output[$conf->entity] . '/control/' . $objectControl->ref . '/qrcode/', 'small', 1, 0, 0, 0, 70, 70, 0, 0, 1, 'control/'. $objectControl->ref . '/qrcode/', $objectControl, '', 0, 0); + print '
'; + print '
' . $objectControl->fields['verdict']['arrayofkeyval'][(!empty($objectControl->verdict)) ?: 3] . '

'; + if (dol_strlen($objectControl->next_control_date) > 0) { + print '
' . $langs->trans('NextControl') . '
'; + $nextControl = floor(($objectControl->next_control_date - dol_now())/(3600 * 24)); + $nextControlColor = $nextControl < 0 ? 'red' : ($nextControl <= 30 ? 'orange' : ($nextControl <= 60 ? 'yellow' : 'green')); + print dol_print_date($objectControl->next_control_date, 'day') . '
' . $langs->trans('Remain') . '
'; + print '
'; + print '
' . $nextControl . ' ' . $langs->trans('Days') . '
'; + } + print '
'; + print '
'; } print '
'; } else { diff --git a/public/control/public_survey.php b/public/control/public_survey.php index c19921b1..ab5cad77 100644 --- a/public/control/public_survey.php +++ b/public/control/public_survey.php @@ -135,6 +135,7 @@ ' . $conf->global->DIGIQUALI_PUBLIC_SURVEY_TITLE . ''; print '
'; + $publicInterface = true; require_once __DIR__ . '/../../core/tpl/digiquali_control_answers.tpl.php'; print '
'; print '
'; diff --git a/view/control/control_card.php b/view/control/control_card.php index 7e2b115e..d3cda1fe 100644 --- a/view/control/control_card.php +++ b/view/control/control_card.php @@ -39,6 +39,7 @@ require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php'; require_once DOL_DOCUMENT_ROOT . '/core/lib/images.lib.php'; require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php'; +require_once DOL_DOCUMENT_ROOT . '/core/lib/functions2.lib.php'; // Load Saturne libraries. require_once __DIR__ . '/../../../saturne/class/saturnesignature.class.php'; @@ -123,11 +124,13 @@ * Actions */ -$parameters = array(); -$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks -if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); +$parameters = ['id' => $id]; +$resHook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks. +if ($resHook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); +} -if (empty($reshook)) { +if (empty($resHook)) { $error = 0; $backurlforlist = dol_buildpath('/digiquali/view/control/control_list.php', 1); @@ -184,7 +187,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'; - include __DIR__ . '/../../../saturne/core/tpl/actions/edit_project_action.tpl.php'; + // Actions set_thirdparty, set_project + require_once __DIR__ . '/../../../saturne/core/tpl/actions/banner_actions.tpl.php'; if ($action == 'set_categories' && $permissiontoadd) { if ($object->fetch($id) > 0) { @@ -194,24 +198,17 @@ } } - require_once __DIR__ . '/../../core/tpl/digiquali_control_answers_save_action.tpl.php'; - if ($action == 'save_next_control_date') { - $day = GETPOST('reday'); - $month = GETPOST('remonth'); - $year = GETPOST('reyear'); + if ($action == 'show_only_questions_with_no_answer') { + $data = json_decode(file_get_contents('php://input'), true); - $object->next_control_date = dol_mktime(0, 0, 0, $month, $day, $year); + $showOnlyQuestionsWithNoAnswer = $data['showOnlyQuestionsWithNoAnswer']; - $result = $object->update($user); + $tabParam['DIGIQUALI_SHOW_ONLY_QUESTIONS_WITH_NO_ANSWER'] = $showOnlyQuestionsWithNoAnswer; - if ($result > 0) { - setEventMessages($langs->trans('NextControlDateUpdated'), []); - } else { - setEventMessages($langs->trans('ErrorUpdatingNextControlDate'), [], 'errors'); - } - header('Location: ' . $_SERVER['PHP_SELF'] . '?id=' . $id); - exit; - } + dol_set_user_param($db, $conf, $user, $tabParam); + } + + require_once __DIR__ . '/../../core/tpl/digiquali_control_answers_save_action.tpl.php'; // Actions builddoc, forcebuilddoc, remove_file. require_once __DIR__ . '/../../../saturne/core/tpl/documents/documents_action.tpl.php'; @@ -498,7 +495,7 @@ } } - if ($action == 'setVerdict') { + if (($action == 'setVerdict' && (empty($conf->use_javascript_ajax) || !empty($conf->dol_use_jmobile))) || (!empty($conf->use_javascript_ajax) && empty($conf->dol_use_jmobile))) { // //Form to close proposal (signed or not) // $answersArray = $controldet->fetchFromParent($object->id); // $answerOK = 0; @@ -533,11 +530,11 @@ array('type' => 'text', 'name' => 'noteControl', 'label' => '
' . $langs->trans('NoteControl') . '
'), ); - $formconfirm .= $form->formconfirm($_SERVER['PHP_SELF'] . '?id=' . $object->id, $langs->trans('SetOK/KO'), $langs->transnoentities('BeCarefullVerdictKO'), 'confirm_setVerdict', $formquestion, '', 1, 300); + $formconfirm .= $form->formconfirm($_SERVER['PHP_SELF'] . '?id=' . $object->id, $langs->trans('SetOK/KO'), $langs->transnoentities('BeCarefullVerdictKO'), 'confirm_setVerdict', $formquestion, 'yes', 'actionButtonVerdict', 300); } // SetValidated confirmation - if ($action == 'setValidated') { + if (($action == 'setValidated' && (empty($conf->use_javascript_ajax) || !empty($conf->dol_use_jmobile))) || (!empty($conf->use_javascript_ajax) && empty($conf->dol_use_jmobile))) { $sheet->fetch($object->fk_sheet); $sheet->fetchQuestionsLinked($object->fk_sheet, 'digiquali_' . $sheet->element); $questionIds = $sheet->linkedObjectsIds['digiquali_question']; @@ -564,7 +561,7 @@ } $questionConfirmInfo .= '

' . $langs->trans('ConfirmValidateControl') . ''; - $formconfirm .= $form->formconfirm($_SERVER['PHP_SELF'] . '?id=' . $object->id, $langs->trans('ValidateControl'), $questionConfirmInfo, 'confirm_setValidated', '', '', 1, 250); + $formconfirm .= $form->formconfirm($_SERVER['PHP_SELF'] . '?id=' . $object->id, $langs->trans('ValidateControl'), $questionConfirmInfo, 'confirm_setValidated', '', 'yes', 'actionButtonValidate', 250); } // SetReopened confirmation @@ -641,28 +638,28 @@ print ''; } - include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_view.tpl.php'; + print ''; + print $form->editfieldkey('ControlDate', 'control_date', $object->control_date, $object, $permissiontoadd, 'datepicker'); + print ''; + print $form->editfieldval('ControlDate', 'control_date', $object->control_date, $object, $permissiontoadd, 'datepicker', '', null, null, "id=$object->id"); + print ''; - if ($action != 'edit_next_control_date' && $object->status < $object::STATUS_LOCKED) : - ?> - - '; - $dateSelector .= ''; - $dateSelector .= ''; - $dateSelector .= $form->selectDate($object->next_control_date, 're', 0, 0, 1, '', 1, 1); - $dateSelector .= ''; - $dateSelector .= ''; - ?> - - '; + print $form->editfieldkey('NextControlDate', 'next_control_date', $object->next_control_date, $object, $permissiontoadd, 'datepicker'); + print ''; + print $form->editfieldval('NextControlDate', 'next_control_date', $object->next_control_date, $object, $permissiontoadd, 'datepicker', '', null, null, "id=$object->id"); + print ''; + + print ''; + print $langs->trans('Verdict'); + print ''; + $verdictColor = $object->verdict == 1 ? 'green' : ($object->verdict == 2 ? 'red' : 'grey'); + print dol_strlen($object->verdict) > 0 ? '
' . $object->fields['verdict']['arrayofkeyval'][(!empty($object->verdict)) ? $object->verdict : 3] . '
' : 'N/A'; + print ''; + + unset($object->fields['verdict']); // Hide field already shown in view + + include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_view.tpl.php'; // Categories if ($conf->categorie->enabled) { @@ -732,22 +729,22 @@ $pathPhotos = $conf->digiquali->multidir_output[$conf->entity] . '/control/'. $object->ref . '/photos/'; $fileArray = dol_dir_list($pathPhotos, 'files'); ?> - status != Control::STATUS_LOCKED) ? '' : 'style="display:none"' ?>> + status < Control::STATUS_LOCKED) ? '' : 'style="display:none"' ?>>