Merge pull request #22749 from atm-lena/16.0_FIX_LinkefObjectMO

Fix Object Linked MO Line
This commit is contained in:
Laurent Destailleur 2022-11-14 22:16:09 +01:00 committed by GitHub
commit 989dfe0b9f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 62 additions and 31 deletions

View File

@ -731,7 +731,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
// Show links to link elements // Show links to link elements
$linktoelem = $form->showLinkToObjectBlock($object, null, array('mo')); $linktoelem = $form->showLinkToObjectBlock($object, null, array('mo'));
$somethingshown = $form->showLinkedObjectBlock($object, $linktoelem, false, 'MOChild'); $somethingshown = $form->showLinkedObjectBlock($object, $linktoelem, false);
print '</div><div class="fichehalfright">'; print '</div><div class="fichehalfright">';

View File

@ -39,10 +39,12 @@ $langs->load("bom");
$total = 0; $total = 0;
$ilink = 0; $ilink = 0;
if ($object->element == 'mo') {
$mo_static = new Mo($db); $mo_static = new Mo($db);
$res = $mo_static->fetch($object->id); $res = $mo_static->fetch($object->id);
$TMoChilds = $mo_static->getMoChilds(); $TMoChilds = $mo_static->getMoChilds();
foreach ($TMoChilds as $key => $objectlink) { foreach ($TMoChilds as $key => $objectlink) {
$ilink++; $ilink++;
@ -78,5 +80,34 @@ foreach ($TMoChilds as $key => $objectlink) {
echo '</td>'; echo '</td>';
echo "</tr>\n"; echo "</tr>\n";
} }
} else {
$linkedObjectBlock = dol_sort_array($linkedObjectBlock, 'date', 'desc', 0, 0, 1);
$total = 0;
$ilink = 0;
foreach ($linkedObjectBlock as $key => $objectlink) {
$ilink++;
$trclass = 'oddeven';
if ($ilink == count($linkedObjectBlock) && empty($noMoreLinkedObjectBlockAfter) && count($linkedObjectBlock) <= 1) {
$trclass .= ' liste_sub_total';
}
print '<tr class="'.$trclass.'" data-element="'.$objectlink->element.'" data-id="'.$objectlink->id.'" >';
print '<td class="linkedcol-element" >'.$langs->trans("ManufacturingOrder");
if (!empty($showImportButton) && $conf->global->MAIN_ENABLE_IMPORT_LINKED_OBJECT_LINES) {
$url = DOL_URL_ROOT.'/mrp/mo_card.php?id='.$objectlink->id;
print '<a class="objectlinked_importbtn" href="'.$url.'&amp;action=selectlines" data-element="'.$objectlink->element.'" data-id="'.$objectlink->id.'" > <i class="fa fa-indent"></i> </a>';
}
print '</td>';
print '<td class="linkedcol-name nowraponall" >'.$objectlink->getNomUrl(1).'</td>';
print '<td class="linkedcol-ref" >'.$objectlink->ref_client.'</td>';
print '<td class="linkedcol-date center">'.dol_print_date($objectlink->date_start_planned, 'day').'</td>';
print '<td class="linkedcol-amount right">-</td>';
print '<td class="linkedcol-statut right">'.$objectlink->getLibStatut(3).'</td>';
print '<td class="linkedcol-action right"><a class="reposition" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=dellink&token='.newToken().'&dellinkid='.$key.'">'.img_picto($langs->transnoentitiesnoconv("RemoveLink"), 'unlink').'</a></td>';
print "</tr>\n";
}
}
echo "<!-- END PHP TEMPLATE -->\n"; echo "<!-- END PHP TEMPLATE -->\n";