dolibarr 24.0.0-beta
linkedobjectblock.tpl.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2010-2011 Regis Houssin <regis.houssin@inodbox.com>
3 * Copyright (C) 2013 Juanjo Menent <jmenent@2byte.es>
4 * Copyright (C) 2014 Marcos García <marcosgdf@gmail.com>
5 * Copyright (C) 2013-2020 Charlene BENKE <charlie@patas-monkey.com>
6 * Copyright (C) 2024-2025 MDW <mdeweerd@users.noreply.github.com>
7 * Copyright (C) 2025 Frédéric France <frederic.france@free.fr>
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 3 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program. If not, see <https://www.gnu.org/licenses/>.
21 */
22
43// Protection to avoid direct call of template
44if (empty($conf) || !is_object($conf)) {
45 print "Error, template page can't be called as URL";
46 exit(1);
47}
48
49print "<!-- BEGIN PHP TEMPLATE mrp/tpl/linkedobjectblock.tpl.php -->\n";
50
51// Load translation files required by the page
52$langs->load("bom");
53
54$total = 0;
55$ilink = 0;
56
57if ($object->element == 'mo') {
58 $mo_static = new Mo($db);
59 $res = $mo_static->fetch($object->id);
60 $TMoChilds = $mo_static->getMoChilds();
61 '@phan-var-force Mo[] $TMoChilds';
62
63 $hookmanager->initHooks(array('LinesLinkedObjectBlock'));
64 $parameters = array('TMoChilds' => $TMoChilds);
65 $reshook = $hookmanager->executeHooks('LinesLinkedObjectBlock', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
66 if (empty($reshook)) {
67 foreach ($TMoChilds as $key => $objectlink) {
68 $ilink++;
69
70 $trclass = 'oddeven';
71
72 echo '<tr class="' . $trclass . '" >';
73 echo '<td class="linkedcol-element tdoverflowmax125">' . $langs->trans("ManufacturingOrder");
74 if (!empty($showImportButton) && getDolGlobalInt('MAIN_ENABLE_IMPORT_LINKED_OBJECT_LINES')) {
75 print '<a class="objectlinked_importbtn" href="' . $objectlink->getNomUrl(0, '', 0, '1') . '&amp;action=selectlines&amp;token='.newToken().'" data-element="' . $objectlink->element . '" data-id="' . $objectlink->id . '" > <i class="fa fa-indent"></i> </a';
76 }
77 echo '</td>';
78 echo '<td class="linkedcol-name nowraponall" >' . $objectlink->getNomUrl(1) . '</td>';
79
80 echo '<td class="linkedcol-ref center">';
81 // $result = $product_static->fetch($objectlink->fk_product);
82 print '</td>';
83 echo '<td class="linkedcol-date center">' . dol_print_date($objectlink->date_creation, 'day') . '</td>';
84 echo '<td class="linkedcol-amount right">-</td>';
85 echo '<td class="linkedcol-statut right">' . $objectlink->getLibStatut(3) . '</td>';
86 echo '<td class="linkedcol-action right">';
87
88 // we want to make the link via element_element for delete action
89 $sql = " Select rowid from " . MAIN_DB_PREFIX . "element_element";
90 $sql .= " WHERE fk_source = " . (int) $object->id . " and fk_target = '" . dol_escape_htmltag($key) . "'";
91
92 $resql = $db->query($sql);
93 $k = 0;
94 if ($resql) {
95 $obj = $db->fetch_object($resql);
96 if ($obj->rowid && $obj->rowid > 0) {
97 $k = $obj->rowid;
98 }
99 }
100 echo '<a class="reposition" href="' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '&action=dellink&token=' . newToken() . '&dellinkid=' . $k . '">' . img_picto($langs->transnoentitiesnoconv("RemoveLink"), 'unlink') . '</a>';
101 echo '</td>';
102 echo "</tr>\n";
103 }
104 }
105} else {
106 $linkedObjectBlock = dol_sort_array($linkedObjectBlock, 'date,ref', 'desc', 0, 0, 1);
107 '@phan-var-force array<CommonObject> $linkedObjectBlock';
108
109 $total = 0;
110 $ilink = 0;
111 foreach ($linkedObjectBlock as $key => $objectlink) {
112 $ilink++;
113 $refWithThirdparty = $objectlink->ref_client ? dolPrintHTML($objectlink->ref_client).'<br>' : '';
114
115 $objectlink->fetch_thirdparty();
116
117 $refWithThirdparty = '<span class="small">'.$refWithThirdparty;
118 $refWithThirdparty .= !empty($objectlink->thirdparty) ? $objectlink->thirdparty->getNomUrl(1) : '';
119 $refWithThirdparty .= '</span>';
120
121 $trclass = 'oddeven';
122 if ($ilink == count($linkedObjectBlock) && empty($noMoreLinkedObjectBlockAfter) && count($linkedObjectBlock) <= 1) {
123 $trclass .= ' liste_sub_total';
124 }
125 print '<tr class="'.$trclass.'" data-element="'.$objectlink->element.'" data-id="'.$objectlink->id.'" >';
126 print '<td class="linkedcol-element tdoverflowmax100">'.$langs->trans("ManufacturingOrder");
127 if (!empty($showImportButton) && getDolGlobalInt('MAIN_ENABLE_IMPORT_LINKED_OBJECT_LINES')) {
128 $url = DOL_URL_ROOT.'/mrp/mo_card.php?id='.$objectlink->id;
129 print '<a class="objectlinked_importbtn" href="'.$url.'&amp;action=selectlines&amp;token='.newToken().'" data-element="'.$objectlink->element.'" data-id="'.$objectlink->id.'" > <i class="fa fa-indent"></i> </a>';
130 }
131 print '</td>';
132
133 print '<td class="linkedcol-name tdoverflowmax150">'.$objectlink->getNomUrl(1).'</td>';
134 print '<td class="linkedcol-ref tdoverflowmax150 nopaddingtopimp nopaddingbottomimp" title="'.dolPrintHTMLForAttribute($objectlink->ref_client).'">'.$refWithThirdparty.'</td>';
135 print '<td class="linkedcol-date center">'.dol_print_date($objectlink->date_start_planned, 'day').'</td>';
136 print '<td class="linkedcol-amount right">-</td>';
137 print '<td class="linkedcol-statut right">'.$objectlink->getLibStatut(3).'</td>';
138 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>';
139 print "</tr>\n";
140 }
141}
142
143echo "<!-- END PHP TEMPLATE -->\n";
if(! $sortfield) if(! $sortorder) $object
Definition account.php:100
Class for Mo.
Definition mo.class.php:35
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $conf
The main.inc.php has been included so the following variable are now defined:
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $db
API class for accounts.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2, $allowothertags=array())
Show picto whatever it's its name (generic function)
dolPrintHTML($s, $allowiframe=0, $moreallowedtags=array())
Return a string (that can be on several lines) ready to be output on a HTML page.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
dol_sort_array(&$array, $index, $order='asc', $natsort=0, $case_sensitive=0, $keepindex=0)
Advanced sort array by the value of a given key, which produces ascending (default) or descending out...
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false, $decorate=0)
Output date in a string format according to outputlangs (or langs if not defined).
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input f...