diff --git a/class/actions_digiquali.class.php b/class/actions_digiquali.class.php index 14014f87..1a80de64 100644 --- a/class/actions_digiquali.class.php +++ b/class/actions_digiquali.class.php @@ -132,6 +132,27 @@ public function doActions(array $parameters, $object, string $action): int require_once __DIR__ . '/../class/survey.class.php'; } + if (strpos($parameters['context'], 'controlpublicsignature') !== false) { + if ($action == 'add_signature') { + $data = json_decode(file_get_contents('php://input'), true); + $subControlList = $object->fetchAll('', '', 0, 0, ['fk_control' => $object->id]); + + if(is_array($subControlList) && !empty($subControlList)) { + foreach ($subControlList as $subControl) { + $signatory = new SaturneSignature($this->db, 'digiquali', 'control'); + $signatory->fetch(0, '', ' AND fk_object =' . "'" . $subControl->id . "' AND object_type='control'"); + $signatory->signature = $data['signature']; + $signatory->signature_date = dol_now(); + + $result = $signatory->update($user, true); + if ($result > 0) { + $signatory->setSigned($user, false, 'public'); + } + } + } + } + } + if (!$error) { $this->results = array('myreturn' => 999); $this->resprints = 'A text to show'; diff --git a/class/control.class.php b/class/control.class.php index c6c1dcc8..d893151b 100644 --- a/class/control.class.php +++ b/class/control.class.php @@ -128,6 +128,8 @@ class Control extends SaturneObject 'verdict' => ['type' => 'smallint', 'label' => 'Verdict', 'enabled' => 1, 'position' => 110, 'notnull' => 0, 'visible' => 5, 'showinpwa' => 1, 'index' => 1, 'positioncard' => 20, 'arrayofkeyval' => [0 => '', 1 => 'OK', 2 => 'KO', 3 => 'N/A']], 'photo' => ['type' => 'text', 'label' => 'Photo', 'enabled' => 1, 'position' => 120, 'notnull' => 0, 'visible' => 0, 'showinpwa' => 0], 'track_id' => ['type' => 'text', 'label' => 'TrackID', 'enabled' => 1, 'position' => 125, 'notnull' => 0, 'visible' => 2, 'showinpwa' => 0], + 'mass_control' => ['type' => 'boolean', 'label' => 'MassControl', 'enabled' => 1, 'position' => 126, 'notnull' => 0, 'visible' => 0, 'showinpwa' => 0], + 'fk_control' => ['type' => 'integer:Control:digiquali/class/control.class.php', 'label' => 'Control', 'picto' => 'control', 'enabled' => 1, 'position' => 127, 'notnull' => 0, 'visible' => 0, 'showinpwa' => 0, 'foreignkey' => 'digiquali_control.rowid'], 'fk_user_creat' => ['type' => 'integer:User:user/class/user.class.php', 'label' => 'UserAuthor', 'picto' => 'user', 'enabled' => 1, 'position' => 130, 'notnull' => 1, 'visible' => 0, 'showinpwa' => 0, 'foreignkey' => 'user.rowid'], 'fk_user_modif' => ['type' => 'integer:User:user/class/user.class.php', 'label' => 'UserModif', 'picto' => 'user', 'enabled' => 1, 'position' => 140, 'notnull' => 0, 'visible' => 0, 'showinpwa' => 0, 'foreignkey' => 'user.rowid'], 'fk_sheet' => ['type' => 'integer:Sheet:digiquali/class/sheet.class.php', 'label' => 'Sheet', 'picto' => 'fontawesome_fa-list_fas_#d35968', 'enabled' => 1, 'position' => 12, 'notnull' => 1, 'visible' => 5, 'showinpwa' => 0, 'index' => 1, 'css' => 'maxwidth500 widthcentpercentminusxx', 'foreignkey' => 'digiquali_sheet.rowid'], @@ -235,6 +237,16 @@ class Control extends SaturneObject */ public int $fk_sheet; + /** + * @var int Control ID. + */ + public $fk_control; + + /** + * @var bool Mass control. + */ + public $mass_control; + /** * @var int|string|null User ID. */ @@ -586,6 +598,7 @@ public function createFromClone(User $user, int $fromID, array $options): int } $object->context = 'createfromclone'; + $object->fk_control = $options['fk_control']; $object->fetchObjectLinked('','', $object->id, 'digiquali_' . $object->element, 'OR', 1, 'sourcetype', 0); diff --git a/core/modules/digiquali/digiqualidocuments/controldocument/doc_controldocument_odt.modules.php b/core/modules/digiquali/digiqualidocuments/controldocument/doc_controldocument_odt.modules.php index 404563e2..5a0b2f8f 100644 --- a/core/modules/digiquali/digiqualidocuments/controldocument/doc_controldocument_odt.modules.php +++ b/core/modules/digiquali/digiqualidocuments/controldocument/doc_controldocument_odt.modules.php @@ -199,6 +199,7 @@ public function fillTagsLines(Odf $odfHandler, Translate $outputLangs, array $mo } $odfHandler->mergeSegment($listLines); } + } } @@ -289,6 +290,75 @@ public function fillTagsLines(Odf $odfHandler, Translate $outputLangs, array $mo } $odfHandler->mergeSegment($listLines); } + + // Get sub control list. + $foundTagForLines = 1; + try { + $listLines = $odfHandler->setSegment('subcontrols'); + + } catch (OdfException|OdfExceptionSegmentNotFound $e) { + // We may arrive here if tags for lines not present into template. + $foundTagForLines = 0; + $listLines = ''; + dol_syslog($e->getMessage()); + } + + // Loop on previous photos array. + if ($foundTagForLines) { + if($object->mass_control > 0) { + $linkableElements = get_sheet_linkable_objects(); + + if (is_array($linkableElements) && !empty($linkableElements)) { + foreach ($linkableElements as $linkableElement) { + $nameField[$linkableElement['link_name']] = $linkableElement['name_field']; + $objectInfo[$linkableElement['link_name']] = [ + 'title' => $linkableElement['langs'], + 'className' => $linkableElement['className'] + ]; + } + } + $subControlList = $object->fetchAll('', '', 0, 0, ['fk_control' => $object->id]); + if (is_array($subControlList) && !empty($subControlList)) { + foreach ($subControlList as $subControl) { + $subControl->fetchObjectLinked($subControl->fk_sheet, 'digiquali_sheet', null, '', 'OR', 1, 'position', 0); + $tmpArray['subcontrol_ref'] = $subControl->ref; + $tmpArray['subcontrol_note'] = $subControl->note_public; + $tmpArray['subcontrol_verdict'] = ($subControl->verdict == 1) ? 'OK' : 'KO'; + //get object linked + $subControl->fetchObjectLinked('', '', $subControl->id, 'digiquali_control', 'OR', 1, 'sourcetype', 0); + if (is_array($subControl->linkedObjectsIds) && !empty($subControl->linkedObjectsIds)) { + foreach($subControl->linkedObjectsIds as $linkedObjectType => $linkedObjectId) { + $className = $objectInfo[$linkedObjectType]['className']; + $linkedObject = new $className($this->db); + $linkedObjectId = array_shift($linkedObjectId); + $result = $linkedObject->fetch($linkedObjectId); + if ($result > 0) { + $objectNameField = $nameField[$linkedObjectType]; + if (strstr($objectNameField, ',')) { + $nameFields = explode(', ', $objectNameField); + if (is_array($nameFields) && !empty($nameFields)) { + foreach ($nameFields as $subnameField) { + $objectName = $linkedObject->$subnameField . chr(0x0A); + } + } + } else { + $objectName = $linkedObject->$objectNameField . chr(0x0A); + } + } + $tmpArray['subcontrol_object_label'] = rtrim($objectName, chr(0x0A)); + $tmpArray['subcontrol_object_ref'] = $linkedObject->ref; + } + + } + $this->setTmpArrayVars($tmpArray, $listLines, $outputLangs); + + } + } + } + $odfHandler->mergeSegment($listLines); + } + + } catch (OdfException $e) { $this->error = $e->getMessage(); dol_syslog($this->error, LOG_WARNING); @@ -317,87 +387,133 @@ public function write_file(SaturneDocuments $objectDocument, Translate $outputLa $object = $moreParam['object']; if (!empty($object->photo)) { - $path = $conf->digiquali->multidir_output[$conf->entity] . '/control/' . $object->ref . '/photos'; + $path = $conf->digiquali->multidir_output[$conf->entity] . '/control/' . $object->ref . '/photos'; $fileSmall = saturne_get_thumb_name($object->photo, getDolGlobalString('DIGIQUALI_DOCUMENT_MEDIA_VIGNETTE_USED')); - $image = $path . '/thumbs/' . $fileSmall; + $image = $path . '/thumbs/' . $fileSmall; $tmpArray['photoDefault'] = $image; } else { - $noPhoto = '/public/theme/common/nophoto.png'; + $noPhoto = '/public/theme/common/nophoto.png'; $tmpArray['photoDefault'] = DOL_DOCUMENT_ROOT . $noPhoto; } $outputLangs->loadLangs(['products', 'bills', 'orders', 'contracts', 'projects', 'companies']); - $sheet = new Sheet($this->db); - $usertmp = new User($this->db); + $sheet = new Sheet($this->db); + $usertmp = new User($this->db); $projecttmp = new Project($this->db); $sheet->fetch($object->fk_sheet); $usertmp->fetch($object->fk_user_controller); $projecttmp->fetch($object->projectid); - $object->fetchObjectLinked('', '', $object->id, 'digiquali_control', 'OR', 1, 'sourcetype', 0); - $linkableElements = get_sheet_linkable_objects(); - - if (is_array($linkableElements) && !empty($linkableElements)) { - foreach ($linkableElements as $linkableElement) { - $nameField[$linkableElement['link_name']] = $linkableElement['name_field']; - $objectInfo[$linkableElement['link_name']] = [ - 'title' => $linkableElement['langs'], - 'className' => $linkableElement['className'] - ]; - } - foreach ($object->linkedObjectsIds as $linkedObjectType => $linkedObjectsIds) { - $className = $objectInfo[$linkedObjectType]['className']; - $linkedObject = new $className($this->db); - $result = $linkedObject->fetch(array_shift($object->linkedObjectsIds[$linkedObjectType])); - if ($result > 0) { - $objectName = ''; - $objectNameField = $nameField[$linkedObjectType]; - if (strstr($objectNameField, ',')) { - $nameFields = explode(', ', $objectNameField); - if (is_array($nameFields) && !empty($nameFields)) { - foreach ($nameFields as $subnameField) { - $objectName .= $linkedObject->$subnameField . ' '; - } - } - } else { - $objectName = $linkedObject->$objectNameField; - } - $tmpArray['object_label_ref'] .= $objectName . chr(0x0A); - $tmpArray['object_type'] = $outputLangs->transnoentities($objectInfo[$linkedObjectType]['title']) . ' : '; - } - } - } - - $tmpArray['control_ref'] = $object->ref; - $tmpArray['object_label_ref'] = rtrim($tmpArray['object_label_ref'], chr(0x0A)); - $tmpArray['control_date'] = dol_print_date($object->date_creation, 'dayhour', 'tzuser'); - $tmpArray['project_label'] = $projecttmp->ref . ' - ' . $projecttmp->title; - $tmpArray['sheet_ref'] = $sheet->ref; - $tmpArray['sheet_label'] = $sheet->label; - - switch ($object->verdict) { - case 1: - $tmpArray['verdict'] = 'OK'; - break; - case 2: - $tmpArray['verdict'] = 'KO'; - break; - default: - $tmpArray['verdict'] = ''; - break; - } + $object->fetchObjectLinked('', '', $object->id, 'digiquali_control', 'OR', 1, 'sourcetype', 0); + $linkableElements = get_sheet_linkable_objects(); - $tmpArray['public_note'] = $object->note_public; + if (is_array($linkableElements) && !empty($linkableElements)) { + foreach ($linkableElements as $linkableElement) { + $nameField[$linkableElement['link_name']] = $linkableElement['name_field']; + $objectInfo[$linkableElement['link_name']] = [ + 'title' => $linkableElement['langs'], + 'className' => $linkableElement['className'] + ]; + } + foreach ($object->linkedObjectsIds as $linkedObjectType => $linkedObjectsIds) { + $className = $objectInfo[$linkedObjectType]['className']; + $linkedObject = new $className($this->db); + $objectName = ''; + if (is_array($object->linkedObjectsIds[$linkedObjectType]) && !empty($object->linkedObjectsIds[$linkedObjectType])) { + foreach ($object->linkedObjectsIds[$linkedObjectType] as $linkedObjectId) { + $result = $linkedObject->fetch($linkedObjectId); + if ($result > 0) { + $objectNameField = $nameField[$linkedObjectType]; + if (strstr($objectNameField, ',')) { + $nameFields = explode(', ', $objectNameField); + if (is_array($nameFields) && !empty($nameFields)) { + foreach ($nameFields as $subnameField) { + $objectName .= $linkedObject->$subnameField . chr(0x0A); + } + } + } else { + $objectName .= $linkedObject->$objectNameField . chr(0x0A); + } + } + } - $tmpArray['mycompany_name'] = $conf->global->MAIN_INFO_SOCIETE_NOM; - $tmpArray['mycompany_address'] = (!empty($conf->global->MAIN_INFO_SOCIETE_ADRESS) ? ' - ' . $conf->global->MAIN_INFO_SOCIETE_ADRESS : ''); - $tmpArray['mycompany_website'] = (!empty($conf->global->MAIN_INFO_SOCIETE_WEBSITE) ? ' - ' . $conf->global->MAIN_INFO_SOCIETE_WEBSITE : ''); - $tmpArray['mycompany_mail'] = (!empty($conf->global->MAIN_INFO_SOCIETE_MAIL) ? ' - ' . $conf->global->MAIN_INFO_SOCIETE_MAIL : ''); - $tmpArray['mycompany_phone'] = (!empty($conf->global->MAIN_INFO_SOCIETE_PHONE) ? ' - ' . $conf->global->MAIN_INFO_SOCIETE_PHONE : ''); + $tmpArray['object_label_ref'] .= $objectName; + $tmpArray['object_type'] = $outputLangs->transnoentities($objectInfo[$linkedObjectType]['title']) . ' : '; + } - $moreParam['tmparray'] = $tmpArray; + } + if ($object->mass_control > 0) { + $subControlSheet = new Sheet($this->db); + $subControlList = $object->fetchAll('', '', 0, 0, ['fk_control' => $object->id]); + if (is_array($subControlList) && !empty($subControlList)) { + foreach ($subControlList as $subControl) { + $subControlSheet->fetch($subControl->fk_sheet); + $subControl->fetchObjectLinked('', '', $subControl->id, 'digiquali_control', 'OR', 1, 'sourcetype', 0); + if (is_array($subControl->linkedObjectsIds) && !empty($subControl->linkedObjectsIds)) { + foreach ($subControl->linkedObjectsIds as $linkedObjectType => $linkedObjectsIds) { + $className = $objectInfo[$linkedObjectType]['className']; + $linkedObject = new $className($this->db); + $objectName = ''; + if (is_array($subControl->linkedObjectsIds[$linkedObjectType]) && !empty($subControl->linkedObjectsIds[$linkedObjectType])) { + foreach ($subControl->linkedObjectsIds[$linkedObjectType] as $linkedObjectId) { + $result = $linkedObject->fetch($linkedObjectId); + if ($result > 0) { + $objectNameField = $nameField[$linkedObjectType]; + if (strstr($objectNameField, ',')) { + $nameFields = explode(', ', $objectNameField); + if (is_array($nameFields) && !empty($nameFields)) { + foreach ($nameFields as $subnameField) { + $objectName .= $linkedObject->$subnameField . chr(0x0A); + } + } + } else { + $objectName .= $linkedObject->$objectNameField . chr(0x0A); + } + } + } + + $tmpArray['object_label_ref'] .= $objectName; + $tmpArray['object_type'] = $outputLangs->transnoentities($objectInfo[$linkedObjectType]['title']) . ' : '; + + $tmpArray['subcontrol_sheet_ref'] = $subControlSheet->ref; + $tmpArray['subcontrol_sheet_label'] = $subControlSheet->label; + } + } + } + } + } + } + $tmpArray['control_ref'] = $object->ref; + $tmpArray['object_label_ref'] = rtrim($tmpArray['object_label_ref'], chr(0x0A)); + $tmpArray['control_date'] = dol_print_date($object->date_creation, 'dayhour', 'tzuser'); + $tmpArray['project_label'] = $projecttmp->ref . ' - ' . $projecttmp->title; + $tmpArray['sheet_ref'] = $sheet->ref; + $tmpArray['sheet_label'] = $sheet->label; + + switch ($object->verdict) { + case 1: + $tmpArray['verdict'] = 'OK'; + break; + case 2: + $tmpArray['verdict'] = 'KO'; + break; + default: + $tmpArray['verdict'] = ''; + break; + } + + $tmpArray['public_note'] = $object->note_public; - return parent::write_file($objectDocument, $outputLangs, $srcTemplatePath, $hideDetails, $hideDesc, $hideRef, $moreParam); + $tmpArray['mycompany_name'] = $conf->global->MAIN_INFO_SOCIETE_NOM; + $tmpArray['mycompany_address'] = (!empty($conf->global->MAIN_INFO_SOCIETE_ADRESS) ? ' - ' . $conf->global->MAIN_INFO_SOCIETE_ADRESS : ''); + $tmpArray['mycompany_website'] = (!empty($conf->global->MAIN_INFO_SOCIETE_WEBSITE) ? ' - ' . $conf->global->MAIN_INFO_SOCIETE_WEBSITE : ''); + $tmpArray['mycompany_mail'] = (!empty($conf->global->MAIN_INFO_SOCIETE_MAIL) ? ' - ' . $conf->global->MAIN_INFO_SOCIETE_MAIL : ''); + $tmpArray['mycompany_phone'] = (!empty($conf->global->MAIN_INFO_SOCIETE_PHONE) ? ' - ' . $conf->global->MAIN_INFO_SOCIETE_PHONE : ''); + + $moreParam['tmparray'] = $tmpArray; + + return parent::write_file($objectDocument, $outputLangs, $srcTemplatePath, $hideDetails, $hideDesc, $hideRef, $moreParam); + } } } diff --git a/core/modules/modDigiQuali.class.php b/core/modules/modDigiQuali.class.php index 46e9664d..e3e9eb2b 100644 --- a/core/modules/modDigiQuali.class.php +++ b/core/modules/modDigiQuali.class.php @@ -129,6 +129,7 @@ public function __construct($db) 'main', 'controladmin', 'surveyadmin', + 'controlpublicsignature' ], // Set this to 1 if features of module are opened to external users 'moduleforexternal' => 0, @@ -234,7 +235,8 @@ public function __construct($db) $i++ => ['DIGIQUALI_CONTROLDOCUMENT_ADDON', 'chaine', 'mod_controldocument_standard', '', 0, 'current'], $i++ => ['DIGIQUALI_CONTROLDOCUMENT_ADDON_ODT_PATH', 'chaine', 'DOL_DOCUMENT_ROOT/custom/digiquali/documents/doctemplates/controldocument/', '', 0, 'current'], $i++ => ['DIGIQUALI_CONTROLDOCUMENT_CUSTOM_ADDON_ODT_PATH', 'chaine', 'DOL_DATA_ROOT' . (($conf->entity == 1 ) ? '/' : '/' . $conf->entity . '/') . 'ecm/digiquali/controldocument/', '', 0, 'current'], - $i++ => ['DIGIQUALI_CONTROLDOCUMENT_DEFAULT_MODEL', 'chaine', 'template_controldocument_photo' ,'', 0, 'current'], + $i++ => ['DIGIQUALI_CONTROLDOCUMENT_DEFAULT_MODEL', 'chaine', 'template_controldocument_photo' ,'', 0, 'current'], + $i++ => ['DIGIQUALI_MASSCONTROLDOCUMENT_DEFAULT_MODEL', 'chaine', 'template_masscontroldocument' ,'', 0, 'current'], $i++ => ['DIGIQUALI_DOCUMENT_MEDIA_VIGNETTE_USED', 'chaine', 'small','', 0, 'current'], //CONST SURVEY DOCUMENT diff --git a/core/tpl/digiquali_answers.tpl.php b/core/tpl/digiquali_answers.tpl.php index b6b95084..a1a80fff 100644 --- a/core/tpl/digiquali_answers.tpl.php +++ b/core/tpl/digiquali_answers.tpl.php @@ -31,17 +31,20 @@ if (is_array($sheet->linkedObjects['digiquali_question']) && !empty($sheet->linkedObjects['digiquali_question'])) { foreach ($sheet->linkedObjects['digiquali_question'] as $question) { + $questionAnswer = ''; $comment = ''; $result = $objectLine->fetchFromParentWithQuestion($object->id, $question->id); + if (is_array($result) && !empty($result)) { $objectLine = array_shift($result); $questionAnswer = $objectLine->answer; $comment = $objectLine->comment; } + if (!$user->conf->DIGIQUALI_SHOW_ONLY_QUESTIONS_WITH_NO_ANSWER or empty($questionAnswer)) { ?> -
+
diff --git a/core/tpl/digiquali_mass_control_list.tpl.php b/core/tpl/digiquali_mass_control_list.tpl.php new file mode 100644 index 00000000..21165f92 --- /dev/null +++ b/core/tpl/digiquali_mass_control_list.tpl.php @@ -0,0 +1,175 @@ +fetchAll('', '', 0, 0, ['fk_control' => $object->id]); + +print '
'; + +print load_fiche_titre($langs->trans('LinkedControlList'), '', ''); + +print '
'; + +$tableHeaders = [ + $langs->trans('Name'), + $langs->trans('Status'), + $langs->trans('ControlledObject'), + $langs->trans('Verdict'), + $langs->trans('NoteControl'), + $langs->trans('Answers'), + $langs->trans('Document'), + $langs->trans('Action'), +]; + +print '
'; +$i = 0; +foreach ($tableHeaders as $header) { + print '
' . $header . '
'; + $i++; +} +print '
'; + +$mainControlId = $object->id; +$sheet = new Sheet($db); +$mainControl = $object; + +// Check if there are any mass controls and print them +if (is_array($subControlList) && !empty($subControlList)) { + foreach ($subControlList as $subControl) { + $answersDisabled = $subControl->status == $subControl::STATUS_LOCKED || $mainControl->status >= $mainControl::STATUS_VALIDATED; + $object = $subControl; + $sheet->fetch($subControl->fk_sheet); + $sheet->fetch_optionals(); + + $sheet->fetchObjectLinked($object->fk_sheet, 'digiquali_' . $sheet->element); + $subControl->fetch_optionals(); + $subControl->fetchLines(); + $subControl->fetchObjectLinked('', '', $subControl->id, 'digiquali_control', 'OR', 1, 'sourcetype', 0); + $linkableElements = get_sheet_linkable_objects(); + + print '
'; + print '
' . $subControl->getNomUrl(1) . '
'; + print '
' . $subControl->getLibStatut(5) . '
'; + print '
'; + foreach ($linkableElements as $linkableElementType => $linkableElement) { + if ($linkableElement['conf'] > 0 && (!empty($object->linkedObjectsIds[$linkableElement['link_name']]))) { + $className = $linkableElement['className']; + $linkedObject = new $className($db); + foreach($object->linkedObjectsIds[$linkableElement['link_name']] as $linkedObjectId) { + $linkedObject->fetch($linkedObjectId); + + print $linkedObject->getNomUrl(1, 0, '', 'maxwidth200'); + + if ($linkedObject->array_options['options_qc_frequency'] > 0) { + print ' '; + print ''; + print $langs->transnoentities('QcFrequency') . ' : ' . $linkedObject->array_options['options_qc_frequency']; + print ''; + } + print '
'; + } + } + } + print '
'; + + print '
'; + print '
'; + print ''; + print ''; + print '
'; + print '
'; + + print '
'; + + print '
'; + $questionCounter = 0; + if (!empty($sheet->linkedObjects['digiquali_question'])) { + $questionCounter = count($sheet->linkedObjects['digiquali_question']); + } + + $answerCounter = 0; + if (is_array($subControl->lines) && !empty($subControl->lines)) { + foreach ($subControl->lines as $subControlLine) { + if (dol_strlen($subControlLine->answer) > 0) { + $answerCounter++; + } + } + } + + print '' . $answerCounter . '/' . $questionCounter . ''; + print ''; + print '
'; + + $documenturl = DOL_URL_ROOT . '/document.php'; + print '
'; + $documentList = dol_dir_list($conf->digiquali->multidir_output[$subControl->entity ?: 1] . '/controldocument/' . $subControl->ref . '/'); + if (!empty($documentList)) { + $lastDocument = $documentList[count($documentList) - 1]; + $lastDocumentPath = $lastDocument['relativename']; + print ''; + print ''; + print ''; + } + + print '
'; + print '
'; + if (!$answersDisabled) { + if ($subControl->status == $subControl::STATUS_VALIDATED) { + $displayButton = $onPhone ? '' : '' . ' ' . $langs->trans('Lock'); + print '' . $displayButton . ''; + $displayButton = $onPhone ? '' : '' . ' ' . $langs->trans('ReOpenDoli'); + print '' . $displayButton . ''; + } else { + $validateButtonDisabled = !(dol_strlen($subControl->verdict) && $answerCounter == $questionCounter); + $displayButton = $onPhone ? '' : '' . ' ' . $langs->trans('Validate'); + print '' . $displayButton . ''; + $displayButton = $onPhone ? '' : '' . ' ' . $langs->trans('Save'); + print '' . $displayButton . ''; + } + } else if ($subControl->status != $subControl::STATUS_LOCKED) { + print $langs->trans('MainControlMustBeDraftToEditSubControls'); + } else { + print ''; + } + + print '
'; + + print '
'; + print ''; + print '
'; + print '
'; + } +} else { + print '
'; + print '
' . $langs->trans('NoSubControlFound') . '
'; + print '
'; +} + +$object->fetch($mainControlId); + +?> diff --git a/core/triggers/interface_99_modDigiQuali_DigiQualiTriggers.class.php b/core/triggers/interface_99_modDigiQuali_DigiQualiTriggers.class.php index 66bc32fd..a83b8552 100644 --- a/core/triggers/interface_99_modDigiQuali_DigiQualiTriggers.class.php +++ b/core/triggers/interface_99_modDigiQuali_DigiQualiTriggers.class.php @@ -131,8 +131,13 @@ public function runTrigger($action, $object, User $user, Translate $langs, Conf case 'CONTROL_CREATE' : // Load Digiquali libraries require_once __DIR__ . '/../../class/sheet.class.php'; + require_once __DIR__ . '/../../class/control.class.php'; + + // Load Saturne libraries. + require_once __DIR__ . '/../../../saturne/class/saturnesignature.class.php'; $sheet = new Sheet($this->db); + $signatory = new SaturneSignature($this->db, 'digiquali'); $sheet->fetch($object->fk_sheet); if ($sheet->success_rate > 0) { @@ -140,19 +145,40 @@ public function runTrigger($action, $object, User $user, Translate $langs, Conf $object->setValueFrom('success_rate', $object->success_rate, '', '', 'text', '', $user); } - $elementArray = []; + $isMassControl = $object->mass_control; + if ($object->context != 'createfromclone') { - $elementArray = get_sheet_linkable_objects(); + $elementArray = get_sheet_linkable_objects(); + if (!empty($elementArray)) { - foreach ($elementArray as $linkableElementType => $linkableElement) { - if (!empty(GETPOST($linkableElement['post_name'])) && GETPOST($linkableElement['post_name']) > 0) { - $object->add_object_linked($linkableElement['link_name'], GETPOST($linkableElement['post_name'])); + foreach ($elementArray as $linkableElement) { + $post = GETPOST('multi_' . $linkableElement['post_name'], 'array'); + if (!empty($post) && $post > 0) { + + foreach($post as $postElement) { + if ($isMassControl) { + $control = new Control($this->db); + + $control->status = $control::STATUS_DRAFT; + $control->label = $object->label; + $control->fk_sheet = GETPOST('fk_sub_controls_sheet'); + $control->fk_user_controller = $object->fk_user_controller; + $control->fk_control = $object->id; + + $controlId = $control->create($user, true); + + $control->fetch($controlId); + $control->add_object_linked($linkableElement['link_name'], $postElement); + + $signatory->setSignatory($control->id, $control->element, 'user', [$control->fk_user_controller], 'Controller', 1); + } else { + $object->add_object_linked($linkableElement['link_name'], $postElement); + } + } } } } - // Load Saturne libraries. - require_once __DIR__ . '/../../../saturne/class/saturnesignature.class.php'; $signatory = new SaturneSignature($this->db, 'digiquali'); $signatory->setSignatory($object->id, $object->element, 'user', [$object->fk_user_controller], 'Controller', 1); diff --git a/css/digiquali.min.css b/css/digiquali.min.css index 33acca0a..a47924da 100644 --- a/css/digiquali.min.css +++ b/css/digiquali.min.css @@ -1 +1 @@ -.question-answer-container *{box-sizing:border-box}.question-answer-container.multiselect{margin-top:-60px}.question-answer-container.multiselect>.wpeo-table{background:none !important}.question-answer-container.multiselect .table-cell{padding-top:0}.question-answer-container .wpeo-table.table-flex .table-row:not(.table-header):nth-of-type(odd){background:none}.question-answer-container .table-cell{margin-top:0 !important}.question-answer-container>.wpeo-table{border-bottom:1px solid rgba(0,0,0,.2)}.question-answer-container>.wpeo-table:nth-of-type(odd){background:rgba(38,60,92,.15)}.question-answer-container>.wpeo-table .cell-photo-check{text-align:right}@media(max-width: 600px){.question-answer-container>.wpeo-table .cell-photo-check{text-align:center}}.question-answer-container>.wpeo-table .question-photo-check{margin:0 4px;display:inline-block;position:relative}.question-answer-container>.wpeo-table .question-photo-check img{display:block;margin:0;width:200px;height:200px;background-size:cover}.question-answer-container>.wpeo-table .question-photo-check i{position:absolute;bottom:10px;right:10px;font-size:35px}.question-answer-container>.wpeo-table .question-photo-check.ko i{color:#e05353}.question-answer-container>.wpeo-table .question-photo-check.ok i{color:#47e58e}.question-answer-container>.wpeo-table .photo{margin:0 4px}.question-answer-container>.wpeo-table .photo.photo-ok{border:5px solid #47e58e}.question-answer-container>.wpeo-table .photo.photo-ko{border:5px solid #e05353}.question-answer-container>.wpeo-table .linked-medias{display:flex;gap:0 10px;flex-wrap:wrap}.question-answer-container>.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){.question-answer-container>.wpeo-table .answer{width:60px;height:60px;line-height:60px;font-size:25px}}.question-answer-container>.wpeo-table .answer.square{border-radius:10%}.question-answer-container>.wpeo-table .answer:hover{cursor:pointer}.question-answer-container>.wpeo-table .answer.active{color:#fff !important}.question-answer-container>.wpeo-table .question-comment-container{margin-top:10px}.question-answer-container>.wpeo-table .question-comment-container .question-ref{font-size:13px;font-weight:700}.question-answer-container>.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}.element-list-medias .question-section{display:block;margin-bottom:20px}.element-list-medias .question-section::after{display:block;content:"";clear:both}.element-list-medias .question-ref{font-weight:800;display:block;clear:both}.element-list-medias .media-container{display:block;float:left;margin-right:10px;margin-bottom:10px}.element-list-medias .media-container a{transition:all .2s ease-out}.element-list-medias .media-container a:hover{opacity:.8}.element-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}.progress-info{display:flex;align-items:center}.progress-info .progress-bar{width:100%;height:20px;background-color:#ddd;border-radius:5px}.progress-info .progress{width:50%;height:100%;border-radius:5px;transition:width .3s}.sheet-images-container .sheet-grid-images{display:flex;flex-wrap:wrap;gap:.8em}.sheet-images-container .sheet-grid-images img{object-fit:cover;border:3px solid #fff;transition:all .2s ease-out}.sheet-images-container .sheet-grid-images img:hover{cursor:pointer;opacity:.6}.preview-photo{z-index:2100 !important}.dropdown-toggle::after{display:none}.favorite-photo{border:5px solid #0d8aff} \ No newline at end of file +.question-answer-container *{box-sizing:border-box}.question-answer-container.multiselect{margin-top:-60px}.question-answer-container.multiselect>.wpeo-table{background:none !important}.question-answer-container.multiselect .table-cell{padding-top:0}.question-answer-container .wpeo-table.table-flex .table-row:not(.table-header):nth-of-type(odd){background:none}.question-answer-container .table-cell{margin-top:0 !important}.question-answer-container>.wpeo-table{border-bottom:1px solid rgba(0,0,0,.2)}.question-answer-container>.wpeo-table:nth-of-type(odd){background:rgba(38,60,92,.15)}.question-answer-container>.wpeo-table .cell-photo-check{text-align:right}@media(max-width: 600px){.question-answer-container>.wpeo-table .cell-photo-check{text-align:center}}.question-answer-container>.wpeo-table .question-photo-check{margin:0 4px;display:inline-block;position:relative}.question-answer-container>.wpeo-table .question-photo-check img{display:block;margin:0;width:200px;height:200px;background-size:cover}.question-answer-container>.wpeo-table .question-photo-check i{position:absolute;bottom:10px;right:10px;font-size:35px}.question-answer-container>.wpeo-table .question-photo-check.ko i{color:#e05353}.question-answer-container>.wpeo-table .question-photo-check.ok i{color:#47e58e}.question-answer-container>.wpeo-table .photo{margin:0 4px}.question-answer-container>.wpeo-table .photo.photo-ok{border:5px solid #47e58e}.question-answer-container>.wpeo-table .photo.photo-ko{border:5px solid #e05353}.question-answer-container>.wpeo-table .linked-medias{display:flex;gap:0 10px;flex-wrap:wrap}.question-answer-container>.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){.question-answer-container>.wpeo-table .answer{width:60px;height:60px;line-height:60px;font-size:25px}}.question-answer-container>.wpeo-table .answer.square{border-radius:10%}.question-answer-container>.wpeo-table .answer:hover{cursor:pointer}.question-answer-container>.wpeo-table .answer.active{color:#fff !important}.question-answer-container>.wpeo-table .question-comment-container{margin-top:10px}.question-answer-container>.wpeo-table .question-comment-container .question-ref{font-size:13px;font-weight:700}.question-answer-container>.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}.verdict-container{display:flex;gap:10px;justify-content:center}.verdict-option input[type=radio]{display:none}.verdict-box{width:60px;height:60px;display:flex;align-items:center;justify-content:center;border:2px solid rgba(0,0,0,0);border-radius:5px;font-weight:bold;cursor:pointer;transition:background-color .3s,border-color .3s}.verdict-ok{background-color:#e0f7e9;color:#27ae60}.verdict-ko{background-color:#fdecea;color:#c0392b}.verdict-option input[type=radio]:checked+.verdict-box{border-color:#000}.verdict-box.disabled{cursor:not-allowed;opacity:.5}.element-list-medias .question-section{display:block;margin-bottom:20px}.element-list-medias .question-section::after{display:block;content:"";clear:both}.element-list-medias .question-ref{font-weight:800;display:block;clear:both}.element-list-medias .media-container{display:block;float:left;margin-right:10px;margin-bottom:10px}.element-list-medias .media-container a{transition:all .2s ease-out}.element-list-medias .media-container a:hover{opacity:.8}.element-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}.progress-info{display:flex;align-items:center}.progress-info .progress-bar{width:100%;height:20px;background-color:#ddd;border-radius:5px}.progress-info .progress{width:50%;height:100%;border-radius:5px;transition:width .3s}.sheet-images-container .sheet-grid-images{display:flex;flex-wrap:wrap;gap:.8em}.sheet-images-container .sheet-grid-images img{object-fit:cover;border:3px solid #fff;transition:all .2s ease-out}.sheet-images-container .sheet-grid-images img:hover{cursor:pointer;opacity:.6}.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 60143cfa..30f81545 100644 --- a/css/scss/page/_control.scss +++ b/css/scss/page/_control.scss @@ -178,3 +178,44 @@ .confirmquestions input[readonly]:hover { cursor: default; } +.verdict-container { + display: flex; + gap: 10px; + justify-content: center; +} + +.verdict-option input[type="radio"] { + display: none; +} + +.verdict-box { + width: 60px; + height: 60px; + display: flex; + align-items: center; + justify-content: center; + border: 2px solid transparent; + border-radius: 5px; + font-weight: bold; + cursor: pointer; + transition: background-color 0.3s, border-color 0.3s; +} + +.verdict-ok { + background-color: #e0f7e9; + color: #27ae60; +} + +.verdict-ko { + background-color: #fdecea; + color: #c0392b; +} + +.verdict-option input[type="radio"]:checked + .verdict-box { + border-color: #000; +} + +.verdict-box.disabled { + cursor: not-allowed; + opacity: 0.5; +} diff --git a/documents/doctemplates/controldocument/template_masscontroldocument.odt b/documents/doctemplates/controldocument/template_masscontroldocument.odt new file mode 100644 index 00000000..460e2727 Binary files /dev/null and b/documents/doctemplates/controldocument/template_masscontroldocument.odt differ diff --git a/js/digiquali.min.js b/js/digiquali.min.js index e32ab982..96668a2e 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 t=void 0,e=void 0;for(t in window.digiquali)for(e in window.digiquali[t].init&&window.digiquali[t].init(),window.digiquali[t])window.digiquali[t]&&window.digiquali[t][e]&&window.digiquali[t][e].init&&window.digiquali[t][e].init();window.digiquali.scriptsLoaded=!0}},window.digiquali.refresh=function(){var t=void 0,e=void 0;for(t in window.digiquali)for(e in window.digiquali[t].refresh&&window.digiquali[t].refresh(),window.digiquali[t])window.digiquali[t]&&window.digiquali[t][e]&&window.digiquali[t][e].refresh&&window.digiquali[t][e].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",".validateButton",window.digiquali.control.getAnswerCounter),$(document).on("change","#fk_sheet",window.digiquali.control.showSelectObjectLinked),$(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),$(document).on("click",".photo-sheet-category",window.digiquali.control.getSheetCategoryID),$(document).on("click",".photo-sheet-sub-category",window.digiquali.control.getSheetSubCategoryID),$(document).on("click",".photo-sheet",window.digiquali.control.getSheetID)},window.digiquali.control.getAnswerCounter=function(t){let e=0;jQuery("#tablelines").children().each(function(){0<$(this).find(".answer.active").length&&(e+=1)}),document.cookie="answerCounter="+e},window.digiquali.control.showSelectObjectLinked=function(){var t=$(this).val(),e=window.saturne.toolbox.getToken(),i=window.saturne.toolbox.getQuerySeparator(document.URL),i=document.URL+i+"fk_sheet="+t+"&token="+e;window.saturne.loader.display($(".linked-objects")),$.ajax({url:i,type:"POST",processData:!1,contentType:!1,success:function(t){$(".linked-objects").replaceWith($(t).find(".linked-objects"))},error:function(){}})},window.digiquali.control.copyToClipboard=function(t){var e=$(".copy-to-clipboard").attr("value");navigator.clipboard.writeText(e).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(t){var e=document.getElementById("add_control_equipment"),e=new FormData(e),i=window.saturne.toolbox.getToken(),e=e.get("productId"),i=document.URL+"&token="+i;i+="&fk_product="+e,window.saturne.loader.display($(".product-lot")),$.ajax({url:i,type:"POST",processData:!1,contentType:!1,success:function(t){$(".product-lot").replaceWith($(t).find(".product-lot"))},error:function(){}})},window.digiquali.control.switchPublicControlView=function(t){var e=$(this).find(".public-control-view").val(),i=window.saturne.toolbox.getToken();let o=document.URL+"&token="+i;o+=0==e?"&show_control_list=1":"&show_last_control=1",window.saturne.loader.display($(".signature-container")),$.ajax({url:o,type:"POST",processData:!1,contentType:!1,success:function(t){$("#publicControlHistory").replaceWith($(t).find("#publicControlHistory"))},error:function(){}})},window.digiquali.control.showOnlyQuestionsWithNoAnswer=function(){var t=window.saturne.toolbox.getQuerySeparator(document.URL),e=window.saturne.toolbox.getToken();let i;i=$(this).hasClass("fa-toggle-off")?1:0,window.saturne.loader.display($(this)),$.ajax({url:document.URL+t+"action=show_only_questions_with_no_answer&token="+e,type:"POST",processData:!1,data:JSON.stringify({showOnlyQuestionsWithNoAnswer:i}),contentType:!1,success:function(t){$(".progress-info").replaceWith($(t).find(".progress-info")),$(".question-answer-container").replaceWith($(t).find(".question-answer-container"))},error:function(){}})},window.digiquali.control.getSheetCategoryID=function(){let e=$(this).attr("value");var t=window.saturne.toolbox.getToken(),i=window.saturne.toolbox.getQuerySeparator(document.URL);window.saturne.loader.display($(".sheet-images-container")),$.ajax({url:document.URL+i+"sheetCategoryID="+e+"&token="+t,type:"POST",processData:!1,contentType:!1,success:function(t){$(".sheet-images-container").replaceWith($(t).find(".sheet-images-container")),$(".photo-sheet-category[value="+e+"]").css("border","3px solid #0d8aff"),$(".photo-sheet-category[value="+e+"]").addClass("photo-sheet-category-active"),$(".linked-objects").replaceWith($(t).find(".linked-objects"))},error:function(){}})},window.digiquali.control.getSheetSubCategoryID=function(){let e=$(".photo-sheet-category-active").attr("value"),i=$(this).attr("value");var t=window.saturne.toolbox.getToken(),o=window.saturne.toolbox.getQuerySeparator(document.URL);window.saturne.loader.display($(".sheet-images-container")),$.ajax({url:document.URL+o+"sheetCategoryID="+e+"&sheetSubCategoryID="+i+"&token="+t,type:"POST",processData:!1,contentType:!1,success:function(t){$(".sheet-images-container").replaceWith($(t).find(".sheet-images-container")),$(".photo-sheet-category[value="+e+"]").css("border","3px solid #0d8aff"),$(".photo-sheet-category[value="+e+"]").addClass("photo-sheet-category-active"),$(".photo-sheet-sub-category[value="+i+"]").css("border","3px solid #0d8aff"),$(".photo-sheet-sub-category[value="+i+"]").addClass("photo-sheet-sub-category-active"),$(".linked-objects").replaceWith($(t).find(".linked-objects"))},error:function(){}})},window.digiquali.control.getSheetID=function(){let e=$(this).attr("data-object-id");var t=$(".photo-sheet-category-active").attr("value"),i=$(".photo-sheet-sub-category-active").attr("value"),o=window.saturne.toolbox.getToken(),n=window.saturne.toolbox.getQuerySeparator(document.URL);window.saturne.loader.display($(".sheet-elements")),window.saturne.loader.display($(".linked-objects")),$.ajax({url:document.URL+n+"fk_sheet="+e+"&sheetCategoryID="+t+"&sheetSubCategoryID="+i+"&token="+o,type:"POST",processData:!1,contentType:!1,success:function(t){$(".sheet-elements").replaceWith($(t).find(".sheet-elements")),$(".photo-sheet[data-object-id="+e+"]").css("border","3px solid #0d8aff"),$(".linked-objects").replaceWith($(t).find(".linked-objects"))},error:function(){}})},window.digiquali.object={},window.digiquali.object.init=function(){window.digiquali.object.event()},window.digiquali.object.event=function(){$(document).on("change",".object-table.linked-objects select",window.digiquali.object.disableOtherSelectors),$(document).on("click",".answer:not(.disable)",window.digiquali.object.selectAnswer),$(document).on("input",".input-answer:not(.disable)",window.digiquali.object.selectAnswer),$(document).on("keyup",".question-comment",window.digiquali.object.showCommentUnsaved)},window.digiquali.object.disableOtherSelectors=function(){var t=document.getElementById("createObjectForm"),t=new FormData(t),e=$(this).attr("id");0<=t.get(e)?$(".object-table.linked-objects").find("select").not("#"+e).attr("disabled",1):$(".object-table.linked-objects").find("select").not("#"+e).removeAttr("disabled")},window.digiquali.object.selectAnswer=function(){var e=$(this).closest(".select-answer.answer-cell"),t=e.attr("data-questionId"),i=$(this).closest(".table-id-"+t).attr("data-publicInterface"),o=$(this).closest(".table-id-"+t).attr("data-autoSave");let n="";var a=$(this).hasClass("answer")?$(this).attr("value"):$(this).val(),s=$(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 t=[];e.find(".multiple-answers.active").each(function(){t.push($(this).attr("value"))}),n=t}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"),n=a;$(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(n)}i||1!=o||$(this).hasClass("multiple-answers")?window.digiquali.object.updateButtonsStatus():window.digiquali.object.saveAnswer(t,n,s)},window.digiquali.object.showCommentUnsaved=function(){$(this).hasClass("show-comment-unsaved-message")||($(this).after('

Commentaire non enregistré

'),$(this).addClass("show-comment-unsaved-message")),window.digiquali.object.updateButtonsStatus()},window.digiquali.object.updateButtonsStatus=function(){$("#saveButton").removeClass("butActionRefused"),$("#saveButton").addClass("butAction"),$("#saveButton").css("background","#0d8aff"),$(".fa-circle").css("display","inline"),$("#saveButton").attr("onclick",'$("#saveObject").submit()'),$(".validateButton").removeClass("butAction"),$("#dialog-confirm-actionButtonValidate").removeAttr("id"),$(".validateButton").addClass("butActionRefused")},window.digiquali.object.saveAnswer=function(t,e,i){var o=window.saturne.toolbox.getToken(),n=window.saturne.toolbox.getQuerySeparator(document.URL);window.saturne.loader.display($(".table-id-"+t)),$.ajax({url:document.URL+n+"action=save&token="+o,type:"POST",data:JSON.stringify({autoSave:!0,questionId:t,answer:e,comment:i}),processData:!1,contentType:!1,success:function(t){$(".fiche").replaceWith($(t).find(".fiche"))},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(t){$(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(t){$("#dialogforpopup").attr("style","border:")},window.digiquali.question.showPhoto=function(){var t=$(this).closest(".question-table").find(".linked-medias");t.hasClass("hidden")?(t.attr("style",""),t.removeClass("hidden")):(t.attr("style","display:none"),t.addClass("hidden"))},window.digiquali.question.selectAnswerPicto=function(t){var e=$(this).closest(".wpeo-dropdown");$(this).closest(".content").removeClass("active"),e.find(".dropdown-toggle span").hide(),e.find(".dropdown-toggle.button-picto").html($(this).closest(".wpeo-tooltip-event").html()),e.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 t=void 0,o=void 0;for(t in window.digiquali)for(o in window.digiquali[t].init&&window.digiquali[t].init(),window.digiquali[t])window.digiquali[t]&&window.digiquali[t][o]&&window.digiquali[t][o].init&&window.digiquali[t][o].init();window.digiquali.scriptsLoaded=!0}},window.digiquali.refresh=function(){var t=void 0,o=void 0;for(t in window.digiquali)for(o in window.digiquali[t].refresh&&window.digiquali[t].refresh(),window.digiquali[t])window.digiquali[t]&&window.digiquali[t][o]&&window.digiquali[t][o].refresh&&window.digiquali[t][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",".validateButton",window.digiquali.control.getAnswerCounter),$(document).on("change","#fk_sheet",window.digiquali.control.showSelectObjectLinked),$(document).on("click",".clipboard-copy",window.digiquali.control.copyToClipboard),$(document).on("change","#productId",window.digiquali.control.refreshLotSelector),$(document).on("change",'[name="mass_control"]',window.digiquali.control.showSubControlsModel),$(document).on("click",".switch-public-control-view",window.digiquali.control.switchPublicControlView),$(document).on("click",".show-only-questions-with-no-answer",window.digiquali.control.showOnlyQuestionsWithNoAnswer),$(document).on("click",".photo-sheet-category",window.digiquali.control.getSheetCategoryID),$(document).on("click",".photo-sheet-sub-category",window.digiquali.control.getSheetSubCategoryID),$(document).on("click",".photo-sheet",window.digiquali.control.getSheetID),$(document).on("click",".saveSubControl:not(.butActionRefused)",window.digiquali.control.saveSubControl),$(document).on("click",".validateSubControl:not(.butActionRefused)",window.digiquali.control.validateSubControl),$(document).on("click",".reopenSubControl:not(.butActionRefused)",window.digiquali.control.reopenSubControl),$(document).on("click",".lockSubControl:not(.butActionRefused)",window.digiquali.control.lockSubControl),$(document).on("click",".saveSubControlAnswers",window.digiquali.control.saveSubControlAnswers),$(document).ready(function(){$(".verdict-box").on("click",function(t){$(this).hasClass("disabled")&&(t.stopPropagation(),t.preventDefault())})})},window.digiquali.control.getAnswerCounter=function(t){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(){var t=$(this).val(),o=window.saturne.toolbox.getToken(),e=window.saturne.toolbox.getQuerySeparator(document.URL),e=document.URL+e+"fk_sheet="+t+"&token="+o;window.saturne.loader.display($(".linked-objects")),$.ajax({url:e,type:"POST",processData:!1,contentType:!1,success:function(t){$(".linked-objects").replaceWith($(t).find(".linked-objects"))},error:function(){}})},window.digiquali.control.copyToClipboard=function(t){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(t){var o=document.getElementById("add_control_equipment"),o=new FormData(o),e=window.saturne.toolbox.getToken(),o=o.get("productId"),e=document.URL+"&token="+e;e+="&fk_product="+o,window.saturne.loader.display($(".product-lot")),$.ajax({url:e,type:"POST",processData:!1,contentType:!1,success:function(t){$(".product-lot").replaceWith($(t).find(".product-lot"))},error:function(){}})},window.digiquali.control.switchPublicControlView=function(t){var o=$(this).find(".public-control-view").val(),e=window.saturne.toolbox.getToken();let i=document.URL+"&token="+e;i+=0==o?"&show_control_list=1":"&show_last_control=1",window.saturne.loader.display($(".signature-container")),$.ajax({url:i,type:"POST",processData:!1,contentType:!1,success:function(t){$("#publicControlHistory").replaceWith($(t).find("#publicControlHistory"))},error:function(){}})},window.digiquali.control.showOnlyQuestionsWithNoAnswer=function(){var t=window.saturne.toolbox.getQuerySeparator(document.URL),o=window.saturne.toolbox.getToken();let e;e=$(this).hasClass("fa-toggle-off")?1:0,window.saturne.loader.display($(this)),$.ajax({url:document.URL+t+"action=show_only_questions_with_no_answer&token="+o,type:"POST",processData:!1,data:JSON.stringify({showOnlyQuestionsWithNoAnswer:e}),contentType:!1,success:function(t){$(".progress-info").replaceWith($(t).find(".progress-info")),$(".question-answer-container").replaceWith($(t).find(".question-answer-container"))},error:function(){}})},window.digiquali.control.getSheetCategoryID=function(){let o=$(this).attr("value");var t=window.saturne.toolbox.getToken(),e=window.saturne.toolbox.getQuerySeparator(document.URL);window.saturne.loader.display($(".sheet-images-container")),$.ajax({url:document.URL+e+"sheetCategoryID="+o+"&token="+t,type:"POST",processData:!1,contentType:!1,success:function(t){$(".sheet-images-container").replaceWith($(t).find(".sheet-images-container")),$(".photo-sheet-category[value="+o+"]").css("border","3px solid #0d8aff"),$(".photo-sheet-category[value="+o+"]").addClass("photo-sheet-category-active"),$(".linked-objects").replaceWith($(t).find(".linked-objects"))},error:function(){}})},window.digiquali.control.getSheetSubCategoryID=function(){let o=$(".photo-sheet-category-active").attr("value"),e=$(this).attr("value");var t=window.saturne.toolbox.getToken(),i=window.saturne.toolbox.getQuerySeparator(document.URL);window.saturne.loader.display($(".sheet-images-container")),$.ajax({url:document.URL+i+"sheetCategoryID="+o+"&sheetSubCategoryID="+e+"&token="+t,type:"POST",processData:!1,contentType:!1,success:function(t){$(".sheet-images-container").replaceWith($(t).find(".sheet-images-container")),$(".photo-sheet-category[value="+o+"]").css("border","3px solid #0d8aff"),$(".photo-sheet-category[value="+o+"]").addClass("photo-sheet-category-active"),$(".photo-sheet-sub-category[value="+e+"]").css("border","3px solid #0d8aff"),$(".photo-sheet-sub-category[value="+e+"]").addClass("photo-sheet-sub-category-active"),$(".linked-objects").replaceWith($(t).find(".linked-objects"))},error:function(){}})},window.digiquali.control.getSheetID=function(){let o=$(this).attr("data-object-id");var t=$(".photo-sheet-category-active").attr("value"),e=$(".photo-sheet-sub-category-active").attr("value"),i=window.saturne.toolbox.getToken(),n=window.saturne.toolbox.getQuerySeparator(document.URL);window.saturne.loader.display($(".sheet-elements")),window.saturne.loader.display($(".linked-objects")),$.ajax({url:document.URL+n+"fk_sheet="+o+"&sheetCategoryID="+t+"&sheetSubCategoryID="+e+"&token="+i,type:"POST",processData:!1,contentType:!1,success:function(t){$(".sheet-elements").replaceWith($(t).find(".sheet-elements")),$(".photo-sheet[data-object-id="+o+"]").css("border","3px solid #0d8aff"),$(".linked-objects").replaceWith($(t).find(".linked-objects"))},error:function(){}})},window.digiquali.control.saveSubControl=function(){let a=$(this).attr("data-control-id"),s=$(this).attr("data-main-control-id");var t=$(this).closest(".table-row").find(".note-public").val();let d=[];$(this).closest(".table-row").find(".select-answer").each(function(){var t=$(this).attr("data-questionid"),o=$(this).find(".question-answer").val(),e=$(this).closest(".wpeo-table").find(".question-comment").val();d[t]={answer:o,comment:e}});var o=$(this).closest(".table-row").find('.verdict-option input[type="radio"]:checked').val();let c=window.saturne.toolbox.getToken();window.saturne.loader.display($(this).closest(".table-row"));var e=document.URL.replace(/id=\d+/,"id="+a);$.ajax({url:e+"&token="+c+"&action=confirm_setVerdict&verdict="+o+"¬eControl="+t,type:"POST",processData:!1,contentType:!1,data:[],success:async function(t){for(var[o,e]of Object.entries(d)){var i=document.URL.replace(/id=\d+/,"id="+a);await window.digiquali.object.saveAnswer(o,e.answer,e.comment,i+"&action=save&token="+c)}var n=document.URL.replace(/id=\d+/,"id="+s);$.ajax({url:n,type:"GET",processData:!1,contentType:!1,data:[],success:function(t){$(".wpeo-loader").removeClass("wpeo-loader"),$(".sub-control-"+a).replaceWith($(t).find(".sub-control-"+a))}})},error:function(){}})},window.digiquali.control.lockSubControl=function(){let o=$(this).attr("data-control-id"),e=$(this).attr("data-main-control-id");var t=window.saturne.toolbox.getToken(),i=(window.saturne.loader.display($(this).closest(".table-row")),document.URL.replace(/id=\d+/,"id="+o));$.ajax({url:i+"&token="+t+"&action=confirm_lock",type:"POST",processData:!1,contentType:!1,data:[],success:function(){var t=document.URL.replace(/id=\d+/,"id="+e);$.ajax({url:t,type:"GET",processData:!1,contentType:!1,data:[],success:function(t){$(".sub-control-"+o).replaceWith($(t).find(".sub-control-"+o))}})},error:function(){}})},window.digiquali.control.validateSubControl=function(){let o=$(this).attr("data-control-id"),e=$(this).attr("data-main-control-id");var t=window.saturne.toolbox.getToken(),i=(window.saturne.loader.display($(this).closest(".table-row")),document.URL.replace(/id=\d+/,"id="+o));$.ajax({url:i+"&token="+t+"&action=confirm_validate&confirm=yes",type:"POST",processData:!1,contentType:!1,data:[],success:function(){var t=document.URL.replace(/id=\d+/,"id="+e);$.ajax({url:t,type:"GET",processData:!1,contentType:!1,data:[],success:function(t){$(".sub-control-"+o).replaceWith($(t).find(".sub-control-"+o))}})},error:function(){}})},window.digiquali.control.reopenSubControl=function(){let o=$(this).attr("data-control-id"),e=$(this).attr("data-main-control-id");var t=window.saturne.toolbox.getToken(),i=(window.saturne.loader.display($(this).closest(".table-row")),document.URL.replace(/id=\d+/,"id="+o));$.ajax({url:i+"&token="+t+"&action=confirm_set_reopen&confirm=yes",type:"POST",processData:!1,contentType:!1,data:[],success:function(){var t=document.URL.replace(/id=\d+/,"id="+e);$.ajax({url:t,type:"GET",processData:!1,contentType:!1,data:[],success:function(t){$(".sub-control-"+o).replaceWith($(t).find(".sub-control-"+o))}})},error:function(){}})},window.digiquali.control.saveSubControlAnswers=async function(){let o=$(this).attr("data-control-id");var t=$(this).attr("data-main-control-id");window.saturne.loader.display($(this));let i=[];$(this).closest(".table-row").find(".select-answer").each(function(){var t=$(this).attr("data-questionid"),o=$(this).find(".question-answer").val(),e=$(this).closest(".wpeo-table").find(".question-comment").val();i[t]={answer:o,comment:e}});var e,n,a=window.saturne.toolbox.getToken();let s=document.URL.replace(/id=\d+/,"id="+o);for([e,n]of Object.entries(i))await window.digiquali.object.saveAnswer(e,n.answer,n.comment,s+"&action=save&token="+a);s=document.URL.replace(/id=\d+/,"id="+t),$.ajax({url:s,type:"GET",processData:!1,contentType:!1,data:[],success:function(t){$(".sub-control-"+o).replaceWith($(t).find(".sub-control-"+o)),$(".wpeo-loader").removeClass("wpeo-loader")}})},window.digiquali.control.showSubControlsModel=function(){$(".sub-controls-model").attr("style",""),$(".sub-controls-model").find(".select2-container").css("width","500px")},window.digiquali.object={},window.digiquali.object.init=function(){window.digiquali.object.event()},window.digiquali.object.event=function(){$(document).on("change",".object-table.linked-objects select",window.digiquali.object.disableOtherSelectors),$(document).on("click",".answer:not(.disable)",window.digiquali.object.selectAnswer),$(document).on("input",".input-answer:not(.disable)",window.digiquali.object.selectAnswer),$(document).on("keyup",".question-comment",window.digiquali.object.showCommentUnsaved),$(document).on("click",".verdict-box",window.digiquali.object.updateButtonsStatus)},window.digiquali.object.disableOtherSelectors=function(){var t=document.getElementById("createObjectForm"),t=new FormData(t),o=$(this).attr("id");0<=t.get(o)?$(".object-table.linked-objects").find("select").not("#"+o).attr("disabled",1):$(".object-table.linked-objects").find("select").not("#"+o).removeAttr("disabled")},window.digiquali.object.selectAnswer=function(){var o=$(this).closest(".select-answer.answer-cell"),t=o.attr("data-questionId"),e=$(this).closest(".table-id-"+t).attr("data-publicInterface"),i=$(this).closest(".table-id-"+t).attr("data-autoSave");let n="";var a=$(this).hasClass("answer")?$(this).attr("value"):$(this).val(),s=$(this).closest(".table-id-"+t).find("#comment"+t).val(),d=$(this).closest(".table-id-"+t).attr("data-control-id");if($(this).closest(".table-cell").hasClass("select-answer")){if($(this).hasClass("multiple-answers")){$(this).closest("span").toggleClass("active");let t=[];o.find(".multiple-answers.active").each(function(){t.push($(this).attr("value"))}),n=t}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"),n=a;$(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(n)}e||1!=i||$(this).hasClass("multiple-answers")?window.digiquali.object.updateButtonsStatus(d):window.digiquali.object.saveAnswer(t,n,s)},window.digiquali.object.showCommentUnsaved=function(){$(this).hasClass("show-comment-unsaved-message")||($(this).after('

Commentaire non enregistré

'),$(this).addClass("show-comment-unsaved-message")),window.digiquali.object.updateButtonsStatus()},window.digiquali.object.updateButtonsStatus=function(t){t=stringIsInteger(t)?t:$(this).attr("data-control-id"),$("#saveButton"+t).removeClass("butActionRefused"),$("#saveButton"+t).addClass("butAction"),$(".fa-circle").css("display","inline"),$("#saveButton"+t).attr("onclick",'$("#saveObject'+t+'").submit()'),$(".validateButton"+t).removeClass("butAction"),$("#dialog-confirm-actionButtonValidate"+t).removeAttr("id"),$(".validateButton"+t).addClass("butActionRefused")},window.digiquali.object.saveAnswer=function(t,o,e,i=""){var n=window.saturne.toolbox.getToken(),a=window.saturne.toolbox.getQuerySeparator(document.URL),a=i||document.URL+a+"action=save&token="+n;i.length<1&&window.saturne.loader.display($(".table-id-"+t)),$.ajax({url:a,type:"POST",data:JSON.stringify({autoSave:!0,questionId:t,answer:o,comment:e}),processData:!1,contentType:!1,success:function(t){i.length<1&&$(".fiche").replaceWith($(t).find(".fiche"))},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(t){$(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(t){$("#dialogforpopup").attr("style","border:")},window.digiquali.question.showPhoto=function(){var t=$(this).closest(".question-table").find(".linked-medias");t.hasClass("hidden")?(t.attr("style",""),t.removeClass("hidden")):(t.attr("style","display:none"),t.addClass("hidden"))},window.digiquali.question.selectAnswerPicto=function(t){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 9d23e407..a46f61a8 100644 --- a/js/modules/control.js +++ b/js/modules/control.js @@ -32,11 +32,27 @@ window.digiquali.control.event = function() { $( document ).on( 'change', '#fk_sheet', window.digiquali.control.showSelectObjectLinked); $( document ).on( 'click', '.clipboard-copy', window.digiquali.control.copyToClipboard ); $( document ).on( 'change', '#productId', window.digiquali.control.refreshLotSelector ); + $( document ).on( 'change', '[name="mass_control"]', window.digiquali.control.showSubControlsModel ); $( document ).on( 'click', '.switch-public-control-view', window.digiquali.control.switchPublicControlView ); $(document).on('click', '.show-only-questions-with-no-answer', window.digiquali.control.showOnlyQuestionsWithNoAnswer); $(document).on('click', '.photo-sheet-category', window.digiquali.control.getSheetCategoryID); $(document).on('click', '.photo-sheet-sub-category', window.digiquali.control.getSheetSubCategoryID); $(document).on('click', '.photo-sheet', window.digiquali.control.getSheetID); + $(document).on('click', '.saveSubControl:not(.butActionRefused)', window.digiquali.control.saveSubControl); + $(document).on('click', '.validateSubControl:not(.butActionRefused)', window.digiquali.control.validateSubControl); + $(document).on('click', '.reopenSubControl:not(.butActionRefused)', window.digiquali.control.reopenSubControl); + $(document).on('click', '.lockSubControl:not(.butActionRefused)', window.digiquali.control.lockSubControl); + $(document).on('click', '.saveSubControlAnswers', window.digiquali.control.saveSubControlAnswers); + $(document).ready(function() { + $('.verdict-box').on('click', function(event) { + if ($(this).hasClass('disabled')) { + event.stopPropagation(); + event.preventDefault(); + } + }); + }); + + }; /** @@ -311,3 +327,245 @@ window.digiquali.control.getSheetID = function() { error: function() {} }); }; + +/** + * Save sub control + * + * @since 1.15.0 + * @version 1.15.0 + * + * @return {void} + */ +window.digiquali.control.saveSubControl = function() { + let subControlID = $(this).attr('data-control-id'); + let mainControlId = $(this).attr('data-main-control-id'); + let notePublic = $(this).closest('.table-row').find('.note-public').val(); + + let questionIds = []; + $(this).closest('.table-row').find('.select-answer').each(function() { + let questionId = $(this).attr('data-questionid'); + + let answer = $(this).find('.question-answer').val(); + let comment = $(this).closest('.wpeo-table').find('.question-comment').val(); + + questionIds[questionId] = { + 'answer': answer, + 'comment': comment + }; + }); + + let verdict = $(this).closest('.table-row').find('.verdict-option input[type="radio"]:checked').val(); + let token = window.saturne.toolbox.getToken(); + + window.saturne.loader.display($(this).closest('.table-row')); + let url = document.URL.replace(/id=\d+/, 'id=' + subControlID); + $.ajax({ + url: url + '&token=' + token + '&action=confirm_setVerdict&verdict=' + verdict + '¬eControl=' + notePublic, + type: 'POST', + processData: false, + contentType: false, + data: [], + success: async function(resp) { + for (const [questionId, answer] of Object.entries(questionIds)) { + let url = document.URL.replace(/id=\d+/, 'id=' + subControlID); + await window.digiquali.object.saveAnswer(questionId, answer.answer, answer.comment, url + '&action=save&token=' + token); + } + + let url = document.URL.replace(/id=\d+/, 'id=' + mainControlId); + $.ajax({ + url: url, + type: 'GET', + processData: false, + contentType: false, + data: [], + success: function (resp) { + $('.wpeo-loader').removeClass('wpeo-loader') + $('.sub-control-' + subControlID).replaceWith($(resp).find('.sub-control-' + subControlID)); + } + }); + }, + error: function() {} + }); +} + +/** + * Lock sub control + * + * @since 1.15.0 + * @version 1.15.0 + * + * @return {void} + */ +window.digiquali.control.lockSubControl = function() { + let subControlID = $(this).attr('data-control-id'); + let mainControlId = $(this).attr('data-main-control-id'); + let token = window.saturne.toolbox.getToken(); + + window.saturne.loader.display($(this).closest('.table-row')); + + let url = document.URL.replace(/id=\d+/, 'id=' + subControlID); + $.ajax({ + url: url + '&token=' + token + '&action=confirm_lock', + type: 'POST', + processData: false, + contentType: false, + data: [], + success: function () { + let url = document.URL.replace(/id=\d+/, 'id=' + mainControlId); + $.ajax({ + url: url, + type: 'GET', + processData: false, + contentType: false, + data: [], + success: function (resp) { + $('.sub-control-' + subControlID).replaceWith($(resp).find('.sub-control-' + subControlID)); + } + }); + }, + error: function () { + } + }); +} + +/** + * Validate sub control + * + * @since 1.15.0 + * @version 1.15.0 + * + * @return {void} + */ +window.digiquali.control.validateSubControl = function() { + let subControlID = $(this).attr('data-control-id'); + let mainControlId = $(this).attr('data-main-control-id'); + let token = window.saturne.toolbox.getToken(); + + window.saturne.loader.display($(this).closest('.table-row')); + + let url = document.URL.replace(/id=\d+/, 'id=' + subControlID); + $.ajax({ + url: url + '&token=' + token + '&action=confirm_validate&confirm=yes', + type: 'POST', + processData: false, + contentType: false, + data: [], + success: function () { + let url = document.URL.replace(/id=\d+/, 'id=' + mainControlId); + $.ajax({ + url: url, + type: 'GET', + processData: false, + contentType: false, + data: [], + success: function (resp) { + $('.sub-control-' + subControlID).replaceWith($(resp).find('.sub-control-' + subControlID)); + } + }); + }, + error: function () { + } + }); +} + +/** + * Reopen sub control + * + * @since 1.15.0 + * @version 1.15.0 + * + * @return {void} + */ +window.digiquali.control.reopenSubControl = function() { + let subControlID = $(this).attr('data-control-id'); + let mainControlId = $(this).attr('data-main-control-id'); + let token = window.saturne.toolbox.getToken(); + + window.saturne.loader.display($(this).closest('.table-row')); + + let url = document.URL.replace(/id=\d+/, 'id=' + subControlID); + $.ajax({ + url: url + '&token=' + token + '&action=confirm_set_reopen&confirm=yes', + type: 'POST', + processData: false, + contentType: false, + data: [], + success: function () { + let url = document.URL.replace(/id=\d+/, 'id=' + mainControlId); + $.ajax({ + url: url, + type: 'GET', + processData: false, + contentType: false, + data: [], + success: function (resp) { + $('.sub-control-' + subControlID).replaceWith($(resp).find('.sub-control-' + subControlID)); + } + }); + }, + error: function () { + } + }); +} + +/** + * Save sub control answers + * + * @since 1.15.0 + * @version 1.15.0 + * + * @return {void} + */ +window.digiquali.control.saveSubControlAnswers = async function() { + let subControlID = $(this).attr('data-control-id'); + let mainControlId = $(this).attr('data-main-control-id'); + + window.saturne.loader.display($(this)); + + let questionIds = []; + $(this).closest('.table-row').find('.select-answer').each(function () { + let questionId = $(this).attr('data-questionid'); + + let answer = $(this).find('.question-answer').val(); + let comment = $(this).closest('.wpeo-table').find('.question-comment').val(); + + questionIds[questionId] = { + 'answer': answer, + 'comment': comment + }; + }); + + let token = window.saturne.toolbox.getToken(); + + let url = document.URL.replace(/id=\d+/, 'id=' + subControlID); + + for (const [questionId, answer] of Object.entries(questionIds)) { + await window.digiquali.object.saveAnswer(questionId, answer.answer, answer.comment, url + '&action=save&token=' + token); + } + + url = document.URL.replace(/id=\d+/, 'id=' + mainControlId); + $.ajax({ + url: url, + type: 'GET', + processData: false, + contentType: false, + data: [], + success: function (resp) { + $('.sub-control-' + subControlID).replaceWith($(resp).find('.sub-control-' + subControlID)); + $('.wpeo-loader').removeClass('wpeo-loader'); + } + }); +} + +/** + * Show sub controls model + * + * @since 1.15.0 + * @version 1.15.0 + * + * @return {void} + */ +window.digiquali.control.showSubControlsModel = function() { + $('.sub-controls-model').attr('style', ''); + $('.sub-controls-model').find('.select2-container').css('width', '500px') +} diff --git a/js/modules/object.js b/js/modules/object.js index 433acd99..7069aebf 100644 --- a/js/modules/object.js +++ b/js/modules/object.js @@ -63,6 +63,7 @@ window.digiquali.object.event = function() { $(document).on( 'click', '.answer:not(.disable)', window.digiquali.object.selectAnswer); $(document).on( 'input', '.input-answer:not(.disable)', window.digiquali.object.selectAnswer); $(document).on( 'keyup', '.question-comment', window.digiquali.object.showCommentUnsaved); + $(document).on( 'click', '.verdict-box', window.digiquali.object.updateButtonsStatus); }; /** @@ -103,6 +104,7 @@ window.digiquali.object.selectAnswer = function() { let answer = ''; let answerValue = $(this).hasClass('answer') ? $(this).attr('value') : $(this).val(); let comment = $(this).closest('.table-id-' + questionId).find('#comment' + questionId).val(); + let controlId = $(this).closest('.table-id-' + questionId).attr('data-control-id'); if ($(this).closest('.table-cell').hasClass('select-answer')) { if ($(this).hasClass('multiple-answers')) { $(this).closest('span').toggleClass('active'); @@ -130,7 +132,7 @@ window.digiquali.object.selectAnswer = function() { if (!publicInterface && autoSave == 1 && !$(this).hasClass('multiple-answers')) { window.digiquali.object.saveAnswer(questionId, answer, comment); } else { - window.digiquali.object.updateButtonsStatus(); + window.digiquali.object.updateButtonsStatus(controlId); } }; @@ -158,16 +160,16 @@ window.digiquali.object.showCommentUnsaved = function() { * * @return {void} */ -window.digiquali.object.updateButtonsStatus = function() { - $('#saveButton').removeClass('butActionRefused'); - $('#saveButton').addClass('butAction'); - $('#saveButton').css('background', '#0d8aff'); +window.digiquali.object.updateButtonsStatus = function(controlId) { + controlId = stringIsInteger(controlId) ? controlId : $(this).attr('data-control-id'); + $('#saveButton' + controlId).removeClass('butActionRefused'); + $('#saveButton' + controlId).addClass('butAction'); $('.fa-circle').css('display', 'inline'); - $('#saveButton').attr('onclick','$("#saveObject").submit()'); + $('#saveButton' + controlId).attr('onclick','$("#saveObject'+controlId+'").submit()'); - $('.validateButton').removeClass('butAction'); - $('#dialog-confirm-actionButtonValidate').removeAttr('id'); - $('.validateButton').addClass('butActionRefused'); + $('.validateButton' + controlId).removeClass('butAction'); + $('#dialog-confirm-actionButtonValidate' + controlId).removeAttr('id'); + $('.validateButton' + controlId).addClass('butActionRefused'); }; /** @@ -179,15 +181,20 @@ window.digiquali.object.updateButtonsStatus = function() { * @param {int} questionId Question ID * @param {string} answer Answer value * @param {string} comment Comment value + * @param {string} customUrl URL to save answer * @return {void} */ -window.digiquali.object.saveAnswer = function(questionId, answer, comment) { +window.digiquali.object.saveAnswer = function(questionId, answer, comment, customUrl = '') { let token = window.saturne.toolbox.getToken(); let querySeparator = window.saturne.toolbox.getQuerySeparator(document.URL); - window.saturne.loader.display($('.table-id-' + questionId)); + let url = customUrl ? customUrl : document.URL + querySeparator + 'action=save&token=' + token + + if (customUrl.length < 1) { + window.saturne.loader.display($('.table-id-' + questionId)); + } $.ajax({ - url: document.URL + querySeparator + 'action=save&token=' + token, + url: url, type: 'POST', data: JSON.stringify({ autoSave: true, @@ -198,7 +205,9 @@ window.digiquali.object.saveAnswer = function(questionId, answer, comment) { processData: false, contentType: false, success: function(resp) { - $('.fiche').replaceWith($(resp).find('.fiche')); + if (customUrl.length < 1) { + $('.fiche').replaceWith($(resp).find('.fiche')); + } }, error: function() {} }); diff --git a/langs/fr_FR/digiquali.lang b/langs/fr_FR/digiquali.lang index 1d6bc92e..faaf5a93 100644 --- a/langs/fr_FR/digiquali.lang +++ b/langs/fr_FR/digiquali.lang @@ -349,6 +349,17 @@ QuestionAnswered = Réponse/Question LastStatusDate = Dernières dates de statut ValidationDate = Date de validation ReOpenDate = Date de réouverture +MassControl = Contrôle en masse +LinkedControlList = Liste des contrôles liés +NewMassControl = Nouveau contrôle en masse +ControlledObject = Objet contrôlé +SubControlSheet = Modèle des sous-contrôles +AddAnObjectToControl = Ajouter un objet à contrôler +SubControlsMustBeLockedToSetVerdict = Les sous-contrôles doivent être verrouillés pour définir le verdict +MainControlMustBeDraftToEditSubControls = Le contrôle principal doit être brouillon pour éditer les sous-contrôles +ParentControl = Contrôle parent +NoSubControlFound = Aucun sous-contrôle trouvé + # # ControlDet @@ -362,6 +373,7 @@ 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 NoObjectLineAnswersPhoto = Pas de photos sur les réponses du %s +Answers = Réponses # # ControlDocument - Fiche de Contrôle @@ -378,6 +390,8 @@ controldocument = fiche de controle controldocument.odt = Fiche de Contrôle controldocument_photo.odt = Fiche de Contrôle avec photos controldocument_photo = fiche de controle avec photos +masscontroldocument = Fiche de Contrôle en masse +masscontroldocument.odt = Fiche de Contrôle en masse @@ -441,3 +455,4 @@ Remain = reste InProgressAndLocked = -- (En cours + verrouillé) -- NoObservations = Pas d'observations BasedOnModel = Basé sur le modèle +ShowDocument = Afficher le document diff --git a/lib/digiquali_control.lib.php b/lib/digiquali_control.lib.php index d1815940..2468cd15 100644 --- a/lib/digiquali_control.lib.php +++ b/lib/digiquali_control.lib.php @@ -58,5 +58,5 @@ function control_prepare_head(Control $object): array $moreparam['documentType'] = 'ControlDocument'; $moreparam['attendantTableMode'] = 'simple'; - return saturne_object_prepare_head($object, $head, $moreparam, true); + return saturne_object_prepare_head($object, $head, $moreparam, !($object->fk_control > 0)); } diff --git a/sql/control/llx_digiquali_control.key.sql b/sql/control/llx_digiquali_control.key.sql index 43a4909b..de696059 100644 --- a/sql/control/llx_digiquali_control.key.sql +++ b/sql/control/llx_digiquali_control.key.sql @@ -21,3 +21,4 @@ ALTER TABLE llx_digiquali_control ADD INDEX idx_digiquali_control_fk_user_contro ALTER TABLE llx_digiquali_control ADD INDEX idx_digiquali_control_fk_projectid (projectid); ALTER TABLE llx_digiquali_control ADD UNIQUE INDEX uk_digiquali_control_ref (ref, entity); ALTER TABLE llx_digiquali_control ADD CONSTRAINT llx_digiquali_control_fk_user_creat FOREIGN KEY (fk_user_creat) REFERENCES llx_user(rowid); +ALTER TABLE llx_digiquali_control ADD CONSTRAINT llx_digiquali_control_fk_control FOREIGN KEY (fk_control) REFERENCES llx_digiquali_control(rowid); diff --git a/sql/control/llx_digiquali_control.sql b/sql/control/llx_digiquali_control.sql index 8c2d0d52..5abff4f0 100644 --- a/sql/control/llx_digiquali_control.sql +++ b/sql/control/llx_digiquali_control.sql @@ -32,6 +32,8 @@ CREATE TABLE llx_digiquali_control( control_date datetime, next_control_date datetime, success_rate double(24,8), + mass_control boolean, + fk_control integer, fk_user_creat integer NOT NULL, fk_user_modif integer, fk_sheet integer NOT NULL, diff --git a/sql/update.sql b/sql/update.sql index f9b2a97b..b9e16e34 100644 --- a/sql/update.sql +++ b/sql/update.sql @@ -127,3 +127,8 @@ ALTER TABLE `llx_digiquali_survey` ADD `success_rate` DOUBLE(24,8) NULL AFTER `p -- 1.13.0 ALTER TABLE `llx_digiquali_control` ADD `label` VARCHAR(255) NULL AFTER `status`; + +-- 1.15.0 +ALTER TABLE `llx_digiquali_control` ADD `mass_control` BOOLEAN NULL AFTER `success_rate`; +ALTER TABLE `llx_digiquali_control` ADD `fk_control` INTEGER NULL AFTER `mass_control`; +ALTER TABLE llx_digiquali_control ADD CONSTRAINT llx_digiquali_control_fk_control FOREIGN KEY (fk_control) REFERENCES llx_digiquali_control(rowid); diff --git a/view/control/control_card.php b/view/control/control_card.php index 19ba3012..55ff4d65 100644 --- a/view/control/control_card.php +++ b/view/control/control_card.php @@ -90,6 +90,7 @@ $ecmfile = new EcmFiles($db); $ecmdir = new EcmDirectory($db); $category = new Categorie($db); +$parentControl = new Control($db); // View objects $form = new Form($db); @@ -151,6 +152,13 @@ $options['photos'] = GETPOST('clone_photos'); if ($object->id > 0) { $result = $object->createFromClone($user, $object->id, $options); + $subControlList = $object->fetchAll('', '', 0, 0, ['fk_control' => $object->id]); + if (is_array($subControlList) && !empty($subControlList)) { + foreach ($subControlList as $subControl) { + $options['fk_control'] = $result; + $subControl->createFromClone($user, $subControl->id, $options); + } + } if ($result > 0) { header("Location: " . $_SERVER['PHP_SELF'] . '?id=' . $result); exit(); @@ -167,8 +175,11 @@ if (!empty($linkableElements)) { foreach ($linkableElements as $linkableElementType => $linkableElement) { - if (!empty(GETPOST($linkableElement['post_name'])) && GETPOST($linkableElement['post_name']) > 0) { - $controlledObjectSelected++; + $post = GETPOST('multi_' . $linkableElement['post_name'], 'array'); + if (is_array($post) && !empty($post)) { + foreach($post as $postSingle) { + $controlledObjectSelected++; + } } } } @@ -221,7 +232,7 @@ if ($action == 'confirm_setVerdict' && $permissiontosetverdict && !GETPOST('cancel', 'alpha')) { $object->fetch($id); if (!$error) { - $object->verdict = GETPOST('verdict', 'int'); + $object->verdict = GETPOST('verdict', 'int') ?: null; $object->note_public .= (!empty($object->note_public) ? chr(0x0A) : '') . GETPOST('noteControl'); $result = $object->update($user); if ($result > 0) { @@ -260,6 +271,35 @@ } } + //Action to add sub controls + if ($action == 'mass_control_add_object') { + $object->fetch($id); + $linkableElements = get_sheet_linkable_objects(); + $controlledObjectSelected = 0; + + if (!empty($linkableElements)) { + foreach ($linkableElements as $linkableElementType => $linkableElement) { + $post = GETPOST($linkableElement['post_name']); + if (!empty($post)) { + $objectType = $linkableElement['link_name']; + $objectId = $post; + + $controlToCreate = new Control($db); + + $controlToCreate->fk_sheet = GETPOST('fk_sub_controls_sheet'); + $controlToCreate->label = $object->label; + $controlToCreate->status = $object::STATUS_DRAFT; + $controlToCreate->fk_user_controller = $object->fk_user_controller; + $controlToCreate->fk_control = $object->id; + + $controlId = $controlToCreate->create($user, true); + + $controlToCreate->add_object_linked($linkableElement['link_name'], $objectId); + } + } + } + } + // Actions confirm_lock, confirm_archive require_once __DIR__ . '/../../../saturne/core/tpl/actions/object_workflow_actions.tpl.php'; @@ -398,6 +438,20 @@ print ''; } + // Mass control + print '' . ($source != 'pwa' ? $langs->trans('MassControl') : img_picto('', 'fontawesome_fa-tasks_fas_#000000_2em', 'class="pictofixedwidth"')) . ''; + print ($source != 'pwa' ? img_picto('', 'fontawesome_fa-tasks_fas_#000000', 'class="pictofixedwidth"') : ''); + print ''; + print ''; + + //FK SHEET + print '' . ($source != 'pwa' ? $langs->trans('SubControlSheet') : img_picto('', $sheet->picto . '_2em', 'class="pictofixedwidth"')) . ''; + print ($source != 'pwa' ? img_picto('', $sheet->picto, 'class="pictofixedwidth"') : '') . $sheet->selectSheetList(GETPOST('fk_sub_controls_sheet'), 'fk_sub_controls_sheet', 's.type = ' . '"' . $object->element . '" AND s.status = ' . Sheet::STATUS_LOCKED); + if ($source != 'pwa') { + print ''; + } + print ''; + print ''; print '
'; @@ -439,7 +493,7 @@ print '' . ($source != 'pwa' ? $langs->transnoentities($linkableElement['langs']) : img_picto('', $linkableElement['picto'], 'class="pictofixedwidth fa-3x"')) . ''; print($source != 'pwa' ? img_picto('', $linkableElement['picto'], 'class="pictofixedwidth"') : ''); - print $form->selectArray($objectPostName, $objectArray, $objectPost, $langs->trans('Select') . ' ' . strtolower($langs->trans($linkableElement['langs'])), 0, 0, '', 0, 0, dol_strlen(GETPOST('fromtype')) > 0 && GETPOST('fromtype') != $linkableElement['link_name'], '', 'maxwidth500 widthcentpercentminusxx'); + print $form->multiselectarray('multi_' . $objectPostName, $objectArray, [$objectPost], $langs->trans('Select') . ' ' . strtolower($langs->trans($linkableElement['langs'])), 0, 0, '', 0, 0, dol_strlen(GETPOST('fromtype')) > 0 && GETPOST('fromtype') != $linkableElement['link_name']); if ($source != 'pwa') { print ''; } @@ -521,7 +575,7 @@ } $questionConfirmInfo .= '

' . $langs->trans('ConfirmValidateControl') . ''; - $formConfirm .= $form->formconfirm($_SERVER['PHP_SELF'] . '?id=' . $object->id, $langs->trans('ValidateControl'), $questionConfirmInfo, 'confirm_validate', '', 'yes', 'actionButtonValidate', 250); + $formConfirm .= $form->formconfirm($_SERVER['PHP_SELF'] . '?id=' . $object->id, $langs->trans('ValidateControl'), $questionConfirmInfo, 'confirm_validate', '', 'yes', 'actionButtonValidate' . $object->id, 250); } // Draft confirmation @@ -604,6 +658,15 @@ print $form->editfieldval('NextControlDate', 'next_control_date', $object->next_control_date, $object, $permissiontoadd && $object->status < Control::STATUS_LOCKED, 'datepicker', '', null, null, "id=$object->id"); print ''; + if ($object->fk_control > 0) { + print ''; + print $langs->trans('ParentControl'); + print ''; + $parentControl->fetch($object->fk_control); + print $parentControl->getNomUrl(1); + print ''; + } + print ''; print $langs->trans('Verdict'); print ''; @@ -651,17 +714,14 @@ if ($linkableElement['conf'] > 0 && (!empty($object->linkedObjectsIds[$linkableElement['link_name']]))) { $className = $linkableElement['className']; $linkedObject = new $className($db); + print ''; + print $langs->trans($linkableElement['langs']); + print ''; + print ''; - $linkedObjectKey = array_key_first($object->linkedObjectsIds[$linkableElement['link_name']]); - $linkedObjectId = $object->linkedObjectsIds[$linkableElement['link_name']][$linkedObjectKey]; + foreach($object->linkedObjectsIds[$linkableElement['link_name']] as $linkedObjectId) { + $linkedObject->fetch($linkedObjectId); - $result = $linkedObject->fetch($linkedObjectId); - - if ($result > 0) { - print ''; - print $langs->trans($linkableElement['langs']); - print ''; - print ''; print $linkedObject->getNomUrl(1); @@ -672,8 +732,10 @@ print ''; } - print ''; + print '
'; } + print ''; + print ''; } } @@ -780,7 +842,7 @@
id . '" id="saveObject" enctype="multipart/form-data">'; + print '
'; print ''; print ''; @@ -797,7 +859,7 @@ // Save question answer $displayButton = $onPhone ? '' : '' . ' ' . $langs->trans('Save'); if ($object->status == Control::STATUS_DRAFT) { - print '' . $displayButton . ' '; + print '' . $displayButton . ' '; } else { print '' . $displayButton . ''; } @@ -805,7 +867,7 @@ // Validate $displayButton = $onPhone ? '' : '' . ' ' . $langs->trans('Validate'); if ($object->status == $object::STATUS_DRAFT && empty($cantValidateControl) && !$equipmentOutdated) { - print '' . $displayButton . ''; + print '' . $displayButton . ''; } else if ($cantValidateControl > 0) { print '' . $displayButton . ''; } else if ($equipmentOutdated) { @@ -824,7 +886,20 @@ // Set verdict control $displayButton = $onPhone ? '' : '' . ' ' . $langs->trans('SetOK/KO'); - if ($object->status == $object::STATUS_VALIDATED && $object->verdict == null && !$equipmentOutdated) { + $permissionToSetVerdict = 1; + if ($object->mass_control == 1) { + $subControlList = $object->fetchAll('', '', 0, 0, ['fk_control' => $object->id, 'status >= 0']); + if (is_array($subControlList) && !empty($subControlList)) { + foreach($subControlList as $subControl) { + if ($subControl->status != $object::STATUS_LOCKED) { + $permissionToSetVerdict = 0; + break; + } + } + } + } + + if ($object->status == $object::STATUS_VALIDATED && $object->verdict == null && !$equipmentOutdated && $permissionToSetVerdict) { if ($permissiontosetverdict) { print '' . $displayButton . ''; } @@ -832,6 +907,8 @@ print '' . $displayButton . ''; } else if ($equipmentOutdated) { print '' . $displayButton . ''; + } else if(!$permissionToSetVerdict) { + print '' . $displayButton . ''; } else { print '' . $displayButton . ''; } @@ -906,7 +983,7 @@ } ?>
-conf->DIGIQUALI_SHOW_ONLY_QUESTIONS_WITH_NO_ANSWER || $answerCounter != $questionCounter) { + conf->DIGIQUALI_SHOW_ONLY_QUESTIONS_WITH_NO_ANSWER || $answerCounter != $questionCounter) { print load_fiche_titre($langs->trans('LinkedQuestionsList'), '', ''); print '
'; require_once __DIR__ . '/../../core/tpl/digiquali_answers.tpl.php'; @@ -915,6 +992,11 @@ print '
'; print ''; + + if ($object->mass_control) { + require_once __DIR__ . '/../../core/tpl/digiquali_mass_control_list.tpl.php'; + } + print dol_get_fiche_end(); if ($action != 'presend') { @@ -925,6 +1007,9 @@ $fileDir = $upload_dir . '/' . $dirFiles; $urlSource = $_SERVER['PHP_SELF'] . '?id=' . $object->id; + $conf->global->DIGIQUALI_CONTROLDOCUMENT_DEFAULT_MODEL = $object->mass_control > 0 ? $conf->global->DIGIQUALI_MASSCONTROLDOCUMENT_DEFAULT_MODEL : $conf->global->DIGIQUALI_CONTROLDOCUMENT_DEFAULT_MODEL; + + print saturne_show_documents('digiquali:' . ucfirst($object->element) . 'Document', $dirFiles, $fileDir, $urlSource, $permissiontoadd, $permissiontodelete, $conf->global->DIGIQUALI_CONTROLDOCUMENT_DEFAULT_MODEL, 1, 0, 0, 0, '', '', '', $langs->defaultlang, '', $object, 0, 'remove_file', (($object->status > CONTROL::STATUS_DRAFT) ? 1 : 0), $langs->trans('ObjectMustBeValidatedToGenerate', ucfirst($langs->transnoentities('The' . ucfirst($object->element))))); print '
'; diff --git a/view/sheet/sheet_card.php b/view/sheet/sheet_card.php index afa22db3..1864e8ea 100644 --- a/view/sheet/sheet_card.php +++ b/view/sheet/sheet_card.php @@ -627,9 +627,11 @@ if (empty($reshook) && $permissiontoadd) { // Create object depending on sheet type if ($object->status == $object::STATUS_LOCKED) { - print ' ' . $langs->trans('New' . ucfirst($object->type)) . ''; + print ' ' . $langs->trans('NewMass' . ucfirst($object->type)) . ''; + print ' ' . $langs->trans('New' . ucfirst($object->type)) . ''; } else { - print ' ' . $langs->trans('New' . ucfirst($object->type)) . ''; + print ' ' . $langs->trans('NewMass' . ucfirst($object->type)) . ''; + print ' ' . $langs->trans('New' . ucfirst($object->type)) . ''; } // Modify