Skip to content

Commit

Permalink
Evarisk#1929 [PublicControl] fix: WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
evarisk-kilyan committed Jan 9, 2025
1 parent 7523396 commit e76553e
Show file tree
Hide file tree
Showing 7 changed files with 116 additions and 213 deletions.
118 changes: 32 additions & 86 deletions core/tpl/digiquali_public_control.tpl.php
Original file line number Diff line number Diff line change
@@ -1,92 +1,38 @@
<div class="signature-container" style="max-width: 1000px;">
<div class="wpeo-gridlayout grid-2">
<div style="display: flex; justify-content: center; align-items: center;"><?php print saturne_show_medias_linked('digiquali', $conf->digiquali->multidir_output[$conf->entity] . '/' . $object->element . '/'. $object->ref . '/photos/', 'small', '', 0, 0, 0, 200, 200, 0, 0, 1, $object->element . '/'. $object->ref . '/photos/', $object, 'photo', 0, 0,0, 1); ?></div>
<div class="informations">
<?php foreach ($elementArray as $linkableObjectType => $linkableObject) {
if ($linkableObject['conf'] > 0 && (!empty($object->linkedObjectsIds[$linkableObject['link_name']]))) {
<div class="flex" style="gap: 10px;">
<div style="display: flex; justify-content: center; align-items: center;"><?php print saturne_show_medias_linked('digiquali', $conf->digiquali->multidir_output[$conf->entity] . '/' . $object->element . '/'. $object->ref . '/photos/', 'small', '', 0, 0, 0, 100, 100, 0, 0, 1, $object->element . '/'. $object->ref . '/photos/', $object, 'photo', 0, 0,0, 1); ?></div>

$className = $linkableObject['className'];
$linkedObject = new $className($db);

$linkedObjectKey = array_key_first($object->linkedObjectsIds[$linkableObject['link_name']]);
$linkedObjectId = $object->linkedObjectsIds[$linkableObject['link_name']][$linkedObjectKey];

$result = $linkedObject->fetch($linkedObjectId);
if ($result > 0) {
$linkedObject->fetch_optionals();

$objectName = '';
$objectNameField = $linkableObject['name_field'];

if (strstr($objectNameField, ',')) {
$nameFields = explode(', ', $objectNameField);
if (is_array($nameFields) && !empty($nameFields)) {
foreach ($nameFields as $subnameField) {
$objectName .= $linkedObject->$subnameField . ' ';
}
}
<div>
<div>
<div style="margin-bottom: 10px"><strong style="color: #4B77D3;"><?php print $langs->transnoentities($linkedObjectsData['langs']); ?></strong></div>
<?php
foreach ($object->linkedObjects as $linkableType => $linkableObject) {
foreach ($linkableObject as $objectItem) {
if ($linkableType == 'productbatch') {
?>
<div><strong><?php print img_picto('', $elementArray['productlot']['picto'], 'class="pictofixedwidth"') . $objectItem->batch; ?></strong></div>
<?php
require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
$product = new Product($db);
$product->fetch($objectItem->fk_product);
?>
<div><strong><?php print img_picto('', $elementArray['product']['picto'], 'class="pictofixedwidth"') . $product->ref; ?></strong></div>
<?php
} else {
$objectName = $linkedObject->$objectNameField;
} ?>

<div style="margin-bottom: 10px"><strong><?php print img_picto('', $linkableObject['picto'], 'class="pictofixedwidth"') . $langs->transnoentities($linkableObject['langs']); ?></strong></div>
<table class="centpercent" style="background: rgba(0,0,0,.05); padding: 10px;">
<tr><td class="tdoverflowmax200" style="min-width: 125px;">
<?php print img_picto('', $linkableObject['picto'], 'class="pictofixedwidth"') . $objectName . '<br><i class="far fa-check-circle pictofixedwidth"></i>' . $langs->trans('VerdictObject'); ?>
<?php if ($linkedObject->array_options['options_qc_frequency'] > 0 && getDolGlobalInt('DIGIQUALI_SHOW_QC_FREQUENCY_PUBLIC_INTERFACE')) {
print '<br>' . $langs->transnoentities('QcFrequency') . ' : ' . $linkedObject->array_options['options_qc_frequency'];
} ?>
</td>
<td class="tdoverflowmax200 center">
<?php if ($object->status == $object::STATUS_DRAFT) {
$verdictObjectColor = 'primary';
$pictoObjectColor = 'hourglass-start';
} elseif ($object->status == $object::STATUS_VALIDATED) {
$verdictObjectColor = 'primary';
$pictoObjectColor = 'hourglass-half';
} elseif (!empty($object->next_control_date) && $object->next_control_date - dol_now() < 0) {
$verdictObjectColor = 'red';
$pictoObjectColor = 'exclamation';
} elseif ($object->verdict > 1) {
$verdictObjectColor = 'red';
$pictoObjectColor = 'exclamation';
} else {
$verdictObjectColor = 'green';
$pictoObjectColor = 'check';
}
print '<div class="wpeo-button button-' . $verdictObjectColor . ' button-square-60"><i class="fas fa-2x fa-' . $pictoObjectColor . ' button-icon"></i></div><br>'; ?>
</td></tr>
</table>
<?php }
}
} ?>
<br><div style="margin-bottom: 10px"><strong><?php print $object->getNomUrl(1); ?></strong></div>
<table class="centpercent" style="background: rgba(0,0,0,.05); padding: 10px;">
<tr><td class="tdoverflowmax200">
<?php print $langs->trans('BasedOnModel') . ' : <br>' . $sheet->getNomUrl(1, '', 0, '', -1, 1) . '<br>';
print '<i class="far fa-check-circle"></i> ' . $langs->trans('Verdict') . '<br>';
print '<div style="margin-top: 10px">' . saturne_show_medias_linked('digiquali', $conf->digiquali->multidir_output[$conf->entity] . '/control/' . $object->ref . '/qrcode/', 'small', 1, 0, 0, 0, 70, 70, 0, 0, 1, 'control/'. $object->ref . '/qrcode/', $object, '', 0, 0) . '</div>'; ?>
</td>
<td class="tdoverflowmax200 center">
<?php $verdictColor = $object->verdict == 1 ? 'green' : ($object->verdict == 2 ? 'red' : 'grey');
if ($object->status < $object::STATUS_LOCKED) {
print $object->getLibStatut(5);
print '<br>';
print '<i class="fas fa-exclamation-triangle"></i> ' . $langs->trans('NonFinalVerdict');
} else {
print '<div class="wpeo-button button-' . $verdictColor . ' button-square-60">' . $object->fields['verdict']['arrayofkeyval'][(!empty($object->verdict)) ? $object->verdict : 3] . '</div>';
?>
<div><strong><?php print img_picto('', $elementArray[$linkableType]['picto'], 'class="pictofixedwidth"') . $objectItem->ref; ?></strong></div>
<?php
}
}
if (!empty($object->next_control_date)) {
print '<hr><div style="font-size: 8px; font-weight: bold">' . $langs->trans('NextControl') . '<br>';
$nextControl = floor(($object->next_control_date - dol_now())/(3600 * 24));
$nextControlColor = $nextControl < 0 ? 'red' : ($nextControl <= 30 ? 'orange' : ($nextControl <= 60 ? 'yellow' : 'green'));
print dol_print_date($object->next_control_date, 'day') . '<br>' . $langs->trans('Remain') . '<br>';
print '</div>';
print '<div class="wpeo-button button-' . $nextControlColor . '" style="padding: 0; font-size: 10px;">' . $nextControl . ' ' . $langs->trans('Days') . '</div>';
} ?>
</td></tr>
</table>
}
$objectState = 1; // TODO
?>
<div><strong><i class="far fa-check-circle opacitymedium"></i> <?php print $langs->transnoentities('ObjectState') ?> <span class="badge" style="color: #fff; background-color: <?php print ($objectState ? '#47e58e' : '#e05353') ?>;"><?php print $langs->transnoentities($objectState ? 'OK' : 'KO');?></span></strong></div>
</div>
<div>
<div><strong><i class="fa fa-history opacitymedium"></i> <?php print $langs->transnoentities('ControlPeriodicity') . ' : ' . $objectLinked->qc_frequency . ' ' . $langs->transnoentities('days') ; ?></strong></div>
<div><strong><i class="far fa-calendar opacitymedium"></i> <?php print $langs->transnoentities('LastControl') . ' : ' . dol_print_date($object->control_date, 'day') ; ?></strong></div>
<div><strong><i class="far fa-calendar opacitymedium"></i> <?php print $langs->transnoentities('NextControl') . ' : ' . dol_print_date(dol_time_plus_duree($object->control_date, $objectLinked->qc_frequency, 'd'), 'day') ; ?></strong></div>
<div><i class="far fa-calendar" style="opacity: 0;"></i> <span style="color: #47e58e;"><?php print $langs->transnoentities('In') . ' ' . num_between_day(dol_now(), dol_time_plus_duree($object->control_date, $objectLinked->qc_frequency, 'd')) . ' ' . $langs->transnoentities('days'); ?></span></div>
</div>
</div>
</div>

11 changes: 11 additions & 0 deletions core/tpl/digiquali_public_control_documentation.tpl.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<div class="flex flex-col" style="gap: 10px;">
<div style="padding: 10px; border-radius: 0.5em; background-color: #4F46F4; color: white;">
<strong><i class="fa fa-file"></i> <?php print $langs->transnoentities('Documentations'); ?></strong>
</div>
<div style="padding: 10px; border-radius: 0.5em; border-width: 0.15em; border-color: #E38433; border-style: solid; color: #E38433;">
<strong><i class="fas fa-tasks"></i> <?php print $langs->transnoentities('SiteInspectionSheets'); ?></strong>
</div>
<div style="padding: 10px; border-radius: 0.5em; border-width: 0.15em; border-color: #DF4941; border-style: solid; color: #DF4941;">
<strong><i class="fas fa-play" style="color: #DF4941;"></i> <?php print $langs->transnoentities('VideoLinks'); ?></strong>
</div>
</div>
35 changes: 35 additions & 0 deletions core/tpl/digiquali_public_control_item.tpl.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<div class="flex" style="justify-content: space-between; align-items: center; border-radius: 0.7em; border-width: 2px; border-color: #F6F9FD; border-style: solid; padding: 10px; box-shadow: 0px 4px 2px 0px #D4E2F4">
<div class="flex" style="gap: 10px;">
<div>
<div style="display: flex; justify-content: center; align-items: center;"><?php print saturne_show_medias_linked('digiquali', $conf->digiquali->multidir_output[$conf->entity] . '/' . $object->element . '/'. $object->ref . '/photos/', 'small', '', 0, 0, 0, 100, 100, 0, 0, 1, $object->element . '/'. $object->ref . '/photos/', $object, 'photo', 0, 0,0, 1); ?></div>
</div>
<div class="flex flex-col justify-center">
<?php if (isset($displayLastControl) && !empty($displayLastControl)) { ?>
<div style="margin-bottom: 10px"><strong style="color: #4B77D3;"><?php print $langs->transnoentities('LastControl'); ?></strong></div>
<?php } ?>
<div><strong><i class="fas fa-tasks" style="color: #D55954;"></i> <?php print $object->ref ?></strong></div>
<div><strong><i class="far fa-calendar opacitymedium"></i> <?php print dol_print_date($object->control_date, 'day'); ?></strong></div>
</div>
</div>
<div class="flex" style="gap: 10px">
<?php if ($object->status == $object::STATUS_DRAFT) {
$verdictObjectColor = 'primary';
$pictoObjectColor = 'hourglass-start';
} elseif ($object->status == $object::STATUS_VALIDATED) {
$verdictObjectColor = 'primary';
$pictoObjectColor = 'hourglass-half';
} elseif (!empty($object->next_control_date) && $object->next_control_date - dol_now() < 0) {
$verdictObjectColor = 'red';
$pictoObjectColor = 'exclamation';
} elseif ($object->verdict > 1) {
$verdictObjectColor = 'red';
$pictoObjectColor = 'exclamation';
} else {
$verdictObjectColor = 'green';
$pictoObjectColor = 'check';
}
print '<div class="wpeo-button button-' . $verdictObjectColor . ' button-square-60" style="line-height: inherit !important;"><div>' . $langs->transnoentities('VerdictObject') . '</div><i class="fas fa-' . $pictoObjectColor . ' fa-2x"></i></div><br>';
print '<a href="' . dol_buildpath('/digiquali/view/control/control_card.php', 1) . '?id=' . $object->id . '" target="_blank" class="wpeo-button button-blue button-square-60" style="line-height: inherit !important;"><div>' . $langs->transnoentities('Watch') . '</div><i class="fas fa-eye fa-2x"></i></a><br>';
?>
</div>
</div>
Loading

0 comments on commit e76553e

Please sign in to comment.