dolibarr 19.0.3
linkedobjectblock.tpl.php
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 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <https://www.gnu.org/licenses/>.
19 */
20
21// Protection to avoid direct call of template
22if (empty($conf) || !is_object($conf)) {
23 print "Error, template page can't be called as URL";
24 exit;
25}
26
27print "<!-- BEGIN PHP TEMPLATE mrp/tpl/linkedobjectblock.tpl.php -->\n";
28
29global $user, $db, $hookmanager;
30global $noMoreLinkedObjectBlockAfter;
31
32$langs = $GLOBALS['langs'];
33$linkedObjectBlock = $GLOBALS['linkedObjectBlock'];
34$object = $GLOBALS['object'];
35
36// Load translation files required by the page
37$langs->load("bom");
38
39$total = 0;
40$ilink = 0;
41
42if ($object->element == 'mo') {
43 $mo_static = new Mo($db);
44 $res = $mo_static->fetch($object->id);
45 $TMoChilds = $mo_static->getMoChilds();
46
47 $hookmanager->initHooks('LinesLinkedObjectBlock');
48 $parameters = array('TMoChilds' => $TMoChilds);
49 $reshook = $hookmanager->executeHooks('LinesLinkedObjectBlock', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
50 if (empty($reshook)) {
51 foreach ($TMoChilds as $key => $objectlink) {
52 $ilink++;
53
54 $trclass = 'oddeven';
55
56 echo '<tr class="' . $trclass . '" >';
57 echo '<td class="linkedcol-element tdoverflowmax100">' . $langs->trans("ManufacturingOrder");
58 if (!empty($showImportButton) && $conf->global->MAIN_ENABLE_IMPORT_LINKED_OBJECT_LINES) {
59 print '<a class="objectlinked_importbtn" href="' . $objectlink->getNomUrl(0, '', 0, 1) . '&amp;action=selectlines" data-element="' . $objectlink->element . '" data-id="' . $objectlink->id . '" > <i class="fa fa-indent"></i> </a';
60 }
61 echo '</td>';
62 echo '<td class="linkedcol-name nowraponall" >' . $objectlink->getNomUrl(1) . '</td>';
63
64 echo '<td class="linkedcol-ref center">';
65 // $result = $product_static->fetch($objectlink->fk_product);
66 print '</td>';
67 echo '<td class="linkedcol-date center">' . dol_print_date($objectlink->date_creation, 'day') . '</td>';
68 echo '<td class="linkedcol-amount right">-</td>';
69 echo '<td class="linkedcol-statut right">' . $objectlink->getLibStatut(3) . '</td>';
70 echo '<td class="linkedcol-action right">';
71
72 // we want to make the link via element_element for delete action
73 $sql = " Select rowid from " . MAIN_DB_PREFIX . "element_element";
74 $sql .= " WHERE fk_source = " . (int) $object->id . " and fk_target = '" . dol_escape_htmltag($key) . "'";
75
76 $resql = $db->query($sql);
77 $k = 0;
78 if ($resql) {
79 $obj = $db->fetch_object($resql);
80 if ($obj->rowid && $obj->rowid > 0) {
81 $k = $obj->rowid;
82 }
83 }
84 echo '<a class="reposition" href="' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '&action=dellink&token=' . newToken() . '&dellinkid=' . $k . '">' . img_picto($langs->transnoentitiesnoconv("RemoveLink"), 'unlink') . '</a>';
85 echo '</td>';
86 echo "</tr>\n";
87 }
88 }
89} else {
90 $linkedObjectBlock = dol_sort_array($linkedObjectBlock, 'date', 'desc', 0, 0, 1);
91
92 $total = 0;
93 $ilink = 0;
94 foreach ($linkedObjectBlock as $key => $objectlink) {
95 $ilink++;
96
97 $trclass = 'oddeven';
98 if ($ilink == count($linkedObjectBlock) && empty($noMoreLinkedObjectBlockAfter) && count($linkedObjectBlock) <= 1) {
99 $trclass .= ' liste_sub_total';
100 }
101 print '<tr class="'.$trclass.'" data-element="'.$objectlink->element.'" data-id="'.$objectlink->id.'" >';
102 print '<td class="linkedcol-element tdoverflowmax100">'.$langs->trans("ManufacturingOrder");
103 if (!empty($showImportButton) && $conf->global->MAIN_ENABLE_IMPORT_LINKED_OBJECT_LINES) {
104 $url = DOL_URL_ROOT.'/mrp/mo_card.php?id='.$objectlink->id;
105 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>';
106 }
107 print '</td>';
108
109 print '<td class="linkedcol-name tdoverflowmax150">'.$objectlink->getNomUrl(1).'</td>';
110 print '<td class="linkedcol-ref" >'.$objectlink->ref_client.'</td>';
111 print '<td class="linkedcol-date center">'.dol_print_date($objectlink->date_start_planned, 'day').'</td>';
112 print '<td class="linkedcol-amount right">-</td>';
113 print '<td class="linkedcol-statut right">'.$objectlink->getLibStatut(3).'</td>';
114 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>';
115 print "</tr>\n";
116 }
117}
118
119echo "<!-- END PHP TEMPLATE -->\n";
Class for Mo.
Definition mo.class.php:34
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
dol_sort_array(&$array, $index, $order='asc', $natsort=0, $case_sensitive=0, $keepindex=0)
Advanced sort array by second index function, which produces ascending (default) or descending output...
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...