2021-09-16 15:10:06 +00:00
< ? php
/* Copyright ( C ) 2010 - 2011 Regis Houssin < regis . houssin @ inodbox . com >
* Copyright ( C ) 2013 Juanjo Menent < jmenent @ 2 byte . es >
* Copyright ( C ) 2014 Marcos García < marcosgdf @ gmail . com >
* Copyright ( C ) 2013 - 2020 Charlene BENKE < charlie @ patas - monkey . com >
2025-02-06 21:16:48 +00:00
* Copyright ( C ) 2024 - 2025 MDW < mdeweerd @ users . noreply . github . com >
2025-08-16 23:29:53 +00:00
* Copyright ( C ) 2025 Frédéric France < frederic . france @ free . fr >
2021-09-16 15:10:06 +00:00
*
* This program is free software ; you can redistribute it and / or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation ; either version 3 of the License , or
* ( at your option ) any later version .
*
* This program is distributed in the hope that it will be useful ,
* but WITHOUT ANY WARRANTY ; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
* GNU General Public License for more details .
*
* You should have received a copy of the GNU General Public License
* along with this program . If not , see < https :// www . gnu . org / licenses />.
*/
2026-01-05 13:36:23 +00:00
/**
* \file htdocs / mrp / tpl / linkedobjectblock . tpl . php
* \ingroup mrp
* \brief Template to show objects linked to MO
*/
/**
* @ var Translate $langs
* @ var Conf $conf
* @ var DoliDB $db
2026-01-05 16:52:57 +00:00
* @ var HookManager $hookmanager
2026-01-05 13:36:23 +00:00
* @ var User $user
*
* @ var CommonObject $object
* @ var int $noMoreLinkedObjectBlockAfter
* @ var int $showImportButton
* @ var CommonObject [] $linkedObjectBlock
2026-01-05 15:43:00 +00:00
* @ var string $action
2026-01-05 13:36:23 +00:00
*/
2021-09-16 15:10:06 +00:00
// Protection to avoid direct call of template
if ( empty ( $conf ) || ! is_object ( $conf )) {
print " Error, template page can't be called as URL " ;
2024-03-16 22:08:15 +00:00
exit ( 1 );
2021-09-16 15:10:06 +00:00
}
2022-03-01 16:39:38 +00:00
print " <!-- BEGIN PHP TEMPLATE mrp/tpl/linkedobjectblock.tpl.php --> \n " ;
2021-09-16 15:10:06 +00:00
// Load translation files required by the page
$langs -> load ( " bom " );
$total = 0 ;
$ilink = 0 ;
2022-02-15 10:46:30 +00:00
2022-11-08 08:55:25 +00:00
if ( $object -> element == 'mo' ) {
2022-11-04 10:51:47 +00:00
$mo_static = new Mo ( $db );
$res = $mo_static -> fetch ( $object -> id );
$TMoChilds = $mo_static -> getMoChilds ();
2024-10-05 16:55:36 +00:00
'@phan-var-force Mo[] $TMoChilds' ;
2022-02-15 10:46:30 +00:00
2024-10-05 16:55:36 +00:00
$hookmanager -> initHooks ( array ( 'LinesLinkedObjectBlock' ));
2022-11-16 19:35:29 +00:00
$parameters = array ( 'TMoChilds' => $TMoChilds );
$reshook = $hookmanager -> executeHooks ( 'LinesLinkedObjectBlock' , $parameters , $object , $action ); // Note that $action and $object may have been modified by hook
if ( empty ( $reshook )) {
foreach ( $TMoChilds as $key => $objectlink ) {
$ilink ++ ;
$trclass = 'oddeven' ;
echo '<tr class="' . $trclass . '" >' ;
2026-01-05 13:36:23 +00:00
echo '<td class="linkedcol-element tdoverflowmax125">' . $langs -> trans ( " ManufacturingOrder " );
2025-08-16 23:29:53 +00:00
if ( ! empty ( $showImportButton ) && getDolGlobalInt ( 'MAIN_ENABLE_IMPORT_LINKED_OBJECT_LINES' )) {
2025-02-06 21:16:48 +00:00
print '<a class="objectlinked_importbtn" href="' . $objectlink -> getNomUrl ( 0 , '' , 0 , '1' ) . '&action=selectlines&token=' . newToken () . '" data-element="' . $objectlink -> element . '" data-id="' . $objectlink -> id . '" > <i class="fa fa-indent"></i> </a' ;
2022-11-16 19:35:29 +00:00
}
echo '</td>' ;
echo '<td class="linkedcol-name nowraponall" >' . $objectlink -> getNomUrl ( 1 ) . '</td>' ;
2022-12-30 12:27:12 +00:00
echo '<td class="linkedcol-ref center">' ;
2022-11-16 19:35:29 +00:00
// $result = $product_static->fetch($objectlink->fk_product);
print '</td>' ;
2022-12-30 12:27:12 +00:00
echo '<td class="linkedcol-date center">' . dol_print_date ( $objectlink -> date_creation , 'day' ) . '</td>' ;
2022-11-16 19:35:29 +00:00
echo '<td class="linkedcol-amount right">-</td>' ;
echo '<td class="linkedcol-statut right">' . $objectlink -> getLibStatut ( 3 ) . '</td>' ;
echo '<td class="linkedcol-action right">' ;
// we want to make the link via element_element for delete action
$sql = " Select rowid from " . MAIN_DB_PREFIX . " element_element " ;
$sql .= " WHERE fk_source = " . ( int ) $object -> id . " and fk_target = ' " . dol_escape_htmltag ( $key ) . " ' " ;
$resql = $db -> query ( $sql );
$k = 0 ;
if ( $resql ) {
$obj = $db -> fetch_object ( $resql );
2023-12-04 12:46:42 +00:00
if ( $obj -> rowid && $obj -> rowid > 0 ) {
$k = $obj -> rowid ;
}
2022-11-16 19:35:29 +00:00
}
echo '<a class="reposition" href="' . $_SERVER [ " PHP_SELF " ] . '?id=' . $object -> id . '&action=dellink&token=' . newToken () . '&dellinkid=' . $k . '">' . img_picto ( $langs -> transnoentitiesnoconv ( " RemoveLink " ), 'unlink' ) . '</a>' ;
echo '</td>' ;
echo " </tr> \n " ;
2022-11-04 10:51:47 +00:00
}
2021-09-16 15:10:06 +00:00
}
2022-11-04 10:51:47 +00:00
} else {
2025-09-15 17:28:38 +00:00
$linkedObjectBlock = dol_sort_array ( $linkedObjectBlock , 'date,ref' , 'desc' , 0 , 0 , 1 );
2024-10-05 16:55:36 +00:00
'@phan-var-force array<CommonObject> $linkedObjectBlock' ;
2026-01-05 13:36:23 +00:00
2022-11-04 10:51:47 +00:00
$total = 0 ;
$ilink = 0 ;
foreach ( $linkedObjectBlock as $key => $objectlink ) {
2022-09-16 16:28:16 +00:00
$ilink ++ ;
2026-04-19 13:59:45 +00:00
$refWithThirdparty = $objectlink -> ref_client ? dolPrintHTML ( $objectlink -> ref_client ) . '<br>' : '' ;
$objectlink -> fetch_thirdparty ();
$refWithThirdparty = '<span class="small">' . $refWithThirdparty ;
$refWithThirdparty .= ! empty ( $objectlink -> thirdparty ) ? $objectlink -> thirdparty -> getNomUrl ( 1 ) : '' ;
$refWithThirdparty .= '</span>' ;
2022-02-15 10:46:30 +00:00
2022-09-16 16:28:16 +00:00
$trclass = 'oddeven' ;
2022-11-04 10:51:47 +00:00
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 . '" >' ;
2022-12-30 02:10:37 +00:00
print '<td class="linkedcol-element tdoverflowmax100">' . $langs -> trans ( " ManufacturingOrder " );
2025-08-16 23:29:53 +00:00
if ( ! empty ( $showImportButton ) && getDolGlobalInt ( 'MAIN_ENABLE_IMPORT_LINKED_OBJECT_LINES' )) {
2022-11-04 10:51:47 +00:00
$url = DOL_URL_ROOT . '/mrp/mo_card.php?id=' . $objectlink -> id ;
2024-10-03 14:19:04 +00:00
print '<a class="objectlinked_importbtn" href="' . $url . '&action=selectlines&token=' . newToken () . '" data-element="' . $objectlink -> element . '" data-id="' . $objectlink -> id . '" > <i class="fa fa-indent"></i> </a>' ;
2022-09-16 16:28:16 +00:00
}
print '</td>' ;
2022-09-21 09:02:00 +00:00
2022-12-30 02:10:37 +00:00
print '<td class="linkedcol-name tdoverflowmax150">' . $objectlink -> getNomUrl ( 1 ) . '</td>' ;
2026-04-19 13:59:45 +00:00
print '<td class="linkedcol-ref tdoverflowmax150 nopaddingtopimp nopaddingbottomimp" title="' . dolPrintHTMLForAttribute ( $objectlink -> ref_client ) . '">' . $refWithThirdparty . '</td>' ;
2022-11-04 10:51:47 +00:00
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 " ;
2021-09-16 15:10:06 +00:00
}
}
2022-09-21 09:02:00 +00:00
2021-09-16 15:10:06 +00:00
echo " <!-- END PHP TEMPLATE --> \n " ;