2021-09-16 17:10:06 +02: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 22:16:48 +01:00
* Copyright ( C ) 2024 - 2025 MDW < mdeweerd @ users . noreply . github . com >
2021-09-16 17:10:06 +02: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 />.
*/
// 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 23:08:15 +01:00
exit ( 1 );
2021-09-16 17:10:06 +02:00
}
2022-03-01 17:39:38 +01:00
print " <!-- BEGIN PHP TEMPLATE mrp/tpl/linkedobjectblock.tpl.php --> \n " ;
2021-09-16 17:10:06 +02:00
2022-09-16 18:28:16 +02:00
global $user , $db , $hookmanager ;
2021-09-16 17:10:06 +02:00
global $noMoreLinkedObjectBlockAfter ;
$langs = $GLOBALS [ 'langs' ];
2024-09-16 01:49:38 +02:00
'@phan-var-force Translate $langs' ;
2021-09-16 17:10:06 +02:00
$linkedObjectBlock = $GLOBALS [ 'linkedObjectBlock' ];
2024-10-05 18:55:36 +02:00
'@phan-var-force array<CommonObject> $linkedObjectBlock' ;
2022-02-15 11:46:30 +01:00
$object = $GLOBALS [ 'object' ];
2021-09-16 17:10:06 +02:00
// Load translation files required by the page
$langs -> load ( " bom " );
$total = 0 ;
$ilink = 0 ;
2022-02-15 11:46:30 +01:00
2022-11-08 09:55:25 +01:00
if ( $object -> element == 'mo' ) {
2022-11-04 11:51:47 +01:00
$mo_static = new Mo ( $db );
$res = $mo_static -> fetch ( $object -> id );
$TMoChilds = $mo_static -> getMoChilds ();
2024-10-05 18:55:36 +02:00
'@phan-var-force Mo[] $TMoChilds' ;
2022-02-15 11:46:30 +01:00
2024-10-05 18:55:36 +02:00
$hookmanager -> initHooks ( array ( 'LinesLinkedObjectBlock' ));
2022-11-16 20:35:29 +01: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 . '" >' ;
2022-12-30 13:27:12 +01:00
echo '<td class="linkedcol-element tdoverflowmax100">' . $langs -> trans ( " ManufacturingOrder " );
2022-11-16 20:35:29 +01:00
if ( ! empty ( $showImportButton ) && $conf -> global -> MAIN_ENABLE_IMPORT_LINKED_OBJECT_LINES ) {
2025-02-06 22:16:48 +01: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 20:35:29 +01:00
}
echo '</td>' ;
echo '<td class="linkedcol-name nowraponall" >' . $objectlink -> getNomUrl ( 1 ) . '</td>' ;
2022-12-30 13:27:12 +01:00
echo '<td class="linkedcol-ref center">' ;
2022-11-16 20:35:29 +01:00
// $result = $product_static->fetch($objectlink->fk_product);
print '</td>' ;
2022-12-30 13:27:12 +01:00
echo '<td class="linkedcol-date center">' . dol_print_date ( $objectlink -> date_creation , 'day' ) . '</td>' ;
2022-11-16 20:35:29 +01: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 13:46:42 +01:00
if ( $obj -> rowid && $obj -> rowid > 0 ) {
$k = $obj -> rowid ;
}
2022-11-16 20:35:29 +01: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 11:51:47 +01:00
}
2021-09-16 17:10:06 +02:00
}
2022-11-04 11:51:47 +01:00
} else {
$linkedObjectBlock = dol_sort_array ( $linkedObjectBlock , 'date' , 'desc' , 0 , 0 , 1 );
2024-10-05 18:55:36 +02:00
'@phan-var-force array<CommonObject> $linkedObjectBlock' ;
2022-11-04 11:51:47 +01:00
$total = 0 ;
$ilink = 0 ;
foreach ( $linkedObjectBlock as $key => $objectlink ) {
2022-09-16 18:28:16 +02:00
$ilink ++ ;
2022-02-15 11:46:30 +01:00
2022-09-16 18:28:16 +02:00
$trclass = 'oddeven' ;
2022-11-04 11:51:47 +01: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 03:10:37 +01:00
print '<td class="linkedcol-element tdoverflowmax100">' . $langs -> trans ( " ManufacturingOrder " );
2022-09-16 18:28:16 +02:00
if ( ! empty ( $showImportButton ) && $conf -> global -> MAIN_ENABLE_IMPORT_LINKED_OBJECT_LINES ) {
2022-11-04 11:51:47 +01:00
$url = DOL_URL_ROOT . '/mrp/mo_card.php?id=' . $objectlink -> id ;
2024-10-03 16:19:04 +02: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 18:28:16 +02:00
}
print '</td>' ;
2022-09-21 11:02:00 +02:00
2022-12-30 03:10:37 +01:00
print '<td class="linkedcol-name tdoverflowmax150">' . $objectlink -> getNomUrl ( 1 ) . '</td>' ;
2022-11-04 11:51:47 +01:00
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 " ;
2021-09-16 17:10:06 +02:00
}
}
2022-09-21 11:02:00 +02:00
2021-09-16 17:10:06 +02:00
echo " <!-- END PHP TEMPLATE --> \n " ;