linkedobjectblock.tpl.php 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  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. // Protection to avoid direct call of template
  21. if (empty($conf) || !is_object($conf)) {
  22. print "Error, template page can't be called as URL";
  23. exit;
  24. }
  25. print "<!-- BEGIN PHP TEMPLATE mrp/tpl/linkedobjectblock.tpl.php -->\n";
  26. global $user, $db, $hookmanager;
  27. global $noMoreLinkedObjectBlockAfter;
  28. $langs = $GLOBALS['langs'];
  29. $linkedObjectBlock = $GLOBALS['linkedObjectBlock'];
  30. $object = $GLOBALS['object'];
  31. // Load translation files required by the page
  32. $langs->load("bom");
  33. $total = 0;
  34. $ilink = 0;
  35. if ($object->element == 'mo') {
  36. $mo_static = new Mo($db);
  37. $res = $mo_static->fetch($object->id);
  38. $TMoChilds = $mo_static->getMoChilds();
  39. $hookmanager->initHooks('LinesLinkedObjectBlock');
  40. $parameters = array('TMoChilds' => $TMoChilds);
  41. $reshook = $hookmanager->executeHooks('LinesLinkedObjectBlock', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
  42. if (empty($reshook)) {
  43. foreach ($TMoChilds as $key => $objectlink) {
  44. $ilink++;
  45. $trclass = 'oddeven';
  46. echo '<tr class="' . $trclass . '" >';
  47. echo '<td class="linkedcol-element tdoverflowmax100">' . $langs->trans("ManufacturingOrder");
  48. if (!empty($showImportButton) && $conf->global->MAIN_ENABLE_IMPORT_LINKED_OBJECT_LINES) {
  49. 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';
  50. }
  51. echo '</td>';
  52. echo '<td class="linkedcol-name nowraponall" >' . $objectlink->getNomUrl(1) . '</td>';
  53. echo '<td class="linkedcol-ref center">';
  54. // $result = $product_static->fetch($objectlink->fk_product);
  55. print '</td>';
  56. echo '<td class="linkedcol-date center">' . dol_print_date($objectlink->date_creation, 'day') . '</td>';
  57. echo '<td class="linkedcol-amount right">-</td>';
  58. echo '<td class="linkedcol-statut right">' . $objectlink->getLibStatut(3) . '</td>';
  59. echo '<td class="linkedcol-action right">';
  60. // we want to make the link via element_element for delete action
  61. $sql = " Select rowid from " . MAIN_DB_PREFIX . "element_element";
  62. $sql .= " WHERE fk_source = " . (int) $object->id . " and fk_target = '" . dol_escape_htmltag($key) . "'";
  63. $resql = $db->query($sql);
  64. $k = 0;
  65. if ($resql) {
  66. $obj = $db->fetch_object($resql);
  67. if ($obj->rowid && $obj->rowid > 0) $k = $obj->rowid;
  68. }
  69. echo '<a class="reposition" href="' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '&action=dellink&token=' . newToken() . '&dellinkid=' . $k . '">' . img_picto($langs->transnoentitiesnoconv("RemoveLink"), 'unlink') . '</a>';
  70. echo '</td>';
  71. echo "</tr>\n";
  72. }
  73. }
  74. } else {
  75. $linkedObjectBlock = dol_sort_array($linkedObjectBlock, 'date', 'desc', 0, 0, 1);
  76. $total = 0;
  77. $ilink = 0;
  78. foreach ($linkedObjectBlock as $key => $objectlink) {
  79. $ilink++;
  80. $trclass = 'oddeven';
  81. if ($ilink == count($linkedObjectBlock) && empty($noMoreLinkedObjectBlockAfter) && count($linkedObjectBlock) <= 1) {
  82. $trclass .= ' liste_sub_total';
  83. }
  84. print '<tr class="'.$trclass.'" data-element="'.$objectlink->element.'" data-id="'.$objectlink->id.'" >';
  85. print '<td class="linkedcol-element tdoverflowmax100">'.$langs->trans("ManufacturingOrder");
  86. if (!empty($showImportButton) && $conf->global->MAIN_ENABLE_IMPORT_LINKED_OBJECT_LINES) {
  87. $url = DOL_URL_ROOT.'/mrp/mo_card.php?id='.$objectlink->id;
  88. 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>';
  89. }
  90. print '</td>';
  91. print '<td class="linkedcol-name tdoverflowmax150">'.$objectlink->getNomUrl(1).'</td>';
  92. print '<td class="linkedcol-ref" >'.$objectlink->ref_client.'</td>';
  93. print '<td class="linkedcol-date center">'.dol_print_date($objectlink->date_start_planned, 'day').'</td>';
  94. print '<td class="linkedcol-amount right">-</td>';
  95. print '<td class="linkedcol-statut right">'.$objectlink->getLibStatut(3).'</td>';
  96. 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>';
  97. print "</tr>\n";
  98. }
  99. }
  100. echo "<!-- END PHP TEMPLATE -->\n";