dolibarr  16.0.5
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
22 if (empty($conf) || !is_object($conf)) {
23  print "Error, template page can't be called as URL";
24  exit;
25 }
26 
27 print "<!-- BEGIN PHP TEMPLATE mrp/tpl/linkedobjectblock.tpl.php -->\n";
28 
29 global $user, $db;
30 global $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 
42 if ($object->element == 'mo') {
43  $mo_static = new Mo($db);
44  $res = $mo_static->fetch($object->id);
45  $TMoChilds = $mo_static->getMoChilds();
46 
47 
48  foreach ($TMoChilds as $key => $objectlink) {
49  $ilink++;
50 
51  $trclass = 'oddeven';
52 
53  echo '<tr class="' . $trclass . '" >';
54  echo '<td class="linkedcol-element tdoverflowmax100">' . $langs->trans("ManufacturingOrder");
55  if (!empty($showImportButton) && $conf->global->MAIN_ENABLE_IMPORT_LINKED_OBJECT_LINES) {
56  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';
57  }
58  echo '</td>';
59  echo '<td class="linkedcol-name tdoverflowmax150">' . $objectlink->getNomUrl(1) . '</td>';
60 
61  echo '<td class="linkedcol-ref center">';
62  // $result = $product_static->fetch($objectlink->fk_product);
63  print '</td>';
64  echo '<td class="linkedcol-date center">' . dol_print_date($objectlink->date_creation, 'day') . '</td>';
65  echo '<td class="linkedcol-amount right">-</td>';
66  echo '<td class="linkedcol-statut right">' . $objectlink->getLibStatut(3) . '</td>';
67  echo '<td class="linkedcol-action right">';
68 
69  // we want to make the link via element_element for delete action
70  $sql = " Select rowid from " . MAIN_DB_PREFIX . "element_element";
71  $sql .= " WHERE fk_source = " . (int) $object->id . " and fk_target = '" . dol_escape_htmltag($key) . "'";
72 
73  $resql = $db->query($sql);
74  $k = 0;
75  if ($resql) {
76  $obj = $db->fetch_object($resql);
77  if ($obj->rowid && $obj->rowid > 0) $k = $obj->rowid;
78  }
79  echo '<a class="reposition" href="' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '&action=dellink&token=' . newToken() . '&dellinkid=' . $k . '">' . img_picto($langs->transnoentitiesnoconv("RemoveLink"), 'unlink') . '</a>';
80  echo '</td>';
81  echo "</tr>\n";
82  }
83 } else {
84  $linkedObjectBlock = dol_sort_array($linkedObjectBlock, 'date', 'desc', 0, 0, 1);
85 
86  $total = 0;
87  $ilink = 0;
88  foreach ($linkedObjectBlock as $key => $objectlink) {
89  $ilink++;
90 
91  $trclass = 'oddeven';
92  if ($ilink == count($linkedObjectBlock) && empty($noMoreLinkedObjectBlockAfter) && count($linkedObjectBlock) <= 1) {
93  $trclass .= ' liste_sub_total';
94  }
95  print '<tr class="'.$trclass.'" data-element="'.$objectlink->element.'" data-id="'.$objectlink->id.'" >';
96  print '<td class="linkedcol-element tdoverflowmax100">'.$langs->trans("ManufacturingOrder");
97  if (!empty($showImportButton) && $conf->global->MAIN_ENABLE_IMPORT_LINKED_OBJECT_LINES) {
98  $url = DOL_URL_ROOT.'/mrp/mo_card.php?id='.$objectlink->id;
99  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>';
100  }
101  print '</td>';
102 
103  print '<td class="linkedcol-name tdoverflowmax150">'.$objectlink->getNomUrl(1).'</td>';
104  print '<td class="linkedcol-ref" >'.$objectlink->ref_client.'</td>';
105  print '<td class="linkedcol-date center">'.dol_print_date($objectlink->date_start_planned, 'day').'</td>';
106  print '<td class="linkedcol-amount right">-</td>';
107  print '<td class="linkedcol-statut right">'.$objectlink->getLibStatut(3).'</td>';
108  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>';
109  print "</tr>\n";
110  }
111 }
112 
113 echo "<!-- END PHP TEMPLATE -->\n";
dol_escape_htmltag
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0)
Returns text escaped for inclusion in HTML alt or title tags, or into values of HTML input fields.
Definition: functions.lib.php:1468
dol_sort_array
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...
Definition: functions.lib.php:8385
Mo
Class for Mo.
Definition: mo.class.php:35
dol_print_date
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
Definition: functions.lib.php:2514
img_picto
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
Definition: functions.lib.php:3880
newToken
newToken()
Return the value of token currently saved into session with name 'newtoken'.
Definition: functions.lib.php:10878
$resql
if(isModEnabled('facture') &&!empty($user->rights->facture->lire)) if((isModEnabled('fournisseur') &&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->rights->fournisseur->facture->lire)||(isModEnabled('supplier_invoice') && $user->rights->supplier_invoice->lire)) if(isModEnabled('don') &&!empty($user->rights->don->lire)) if(isModEnabled('tax') &&!empty($user->rights->tax->charges->lire)) if(isModEnabled('facture') &&isModEnabled('commande') && $user->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $resql
Social contributions to pay.
Definition: index.php:742