linkedobjectblock.tpl.php 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  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. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; either version 3 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program. If not, see <https://www.gnu.org/licenses/>.
  18. */
  19. // Protection to avoid direct call of template
  20. if (empty($conf) || !is_object($conf)) {
  21. print "Error, template page can't be called as URL";
  22. exit;
  23. }
  24. print "<!-- BEGIN PHP TEMPLATE compta/facture/tpl/linkedobjectblock.tpl.php -->\n";
  25. global $user;
  26. global $noMoreLinkedObjectBlockAfter;
  27. $langs = $GLOBALS['langs'];
  28. $linkedObjectBlock = $GLOBALS['linkedObjectBlock'];
  29. $langs->load("bills");
  30. $linkedObjectBlock = dol_sort_array($linkedObjectBlock, 'date', 'desc', 0, 0, 1);
  31. $total = 0;
  32. $ilink = 0;
  33. foreach ($linkedObjectBlock as $key => $objectlink) {
  34. $ilink++;
  35. $trclass = 'oddeven';
  36. if ($ilink == count($linkedObjectBlock) && empty($noMoreLinkedObjectBlockAfter) && count($linkedObjectBlock) <= 1) {
  37. $trclass .= ' liste_sub_total';
  38. }
  39. print '<tr class="'.$trclass.'" data-element="'.$objectlink->element.'" data-id="'.$objectlink->id.'" >';
  40. print '<td class="linkedcol-element tdoverflowmax100">';
  41. switch ($objectlink->type) {
  42. case Facture::TYPE_REPLACEMENT:
  43. echo $langs->trans("InvoiceReplacement");
  44. break;
  45. case Facture::TYPE_CREDIT_NOTE:
  46. echo $langs->trans("InvoiceAvoir");
  47. break;
  48. case Facture::TYPE_DEPOSIT:
  49. echo $langs->trans("InvoiceDeposit");
  50. break;
  51. case Facture::TYPE_PROFORMA:
  52. echo $langs->trans("InvoiceProForma");
  53. break;
  54. case Facture::TYPE_SITUATION:
  55. echo $langs->trans("InvoiceSituation");
  56. break;
  57. default:
  58. echo $langs->trans("CustomerInvoice");
  59. break;
  60. }
  61. print '</td>';
  62. print '<td class="linkedcol-name tdoverflowmax150">'.$objectlink->getNomUrl(1).'</td>';
  63. print '<td class="linkedcol-ref tdoverflowmax150" title="'.dol_escape_htmltag($objectlink->ref_client).'">'.dol_escape_htmltag($objectlink->ref_client).'</td>';
  64. print '<td class="linkedcol-date center">'.dol_print_date($objectlink->date, 'day').'</td>';
  65. print '<td class="linkedcol-amount right nowraponall">';
  66. if (!empty($objectlink) && $objectlink->element == 'facture' && $user->hasRight('facture', 'lire')) {
  67. if ($objectlink->statut != 3) {
  68. // If not abandonned
  69. $total += $objectlink->total_ht;
  70. echo price($objectlink->total_ht);
  71. } else {
  72. echo '<strike>'.price($objectlink->total_ht).'</strike>';
  73. }
  74. }
  75. print '</td>';
  76. print '<td class="linkedcol-statut right">';
  77. if (method_exists($objectlink, 'getSommePaiement')) {
  78. print $objectlink->getLibStatut(3, $objectlink->getSommePaiement());
  79. } else {
  80. print $objectlink->getLibStatut(3);
  81. }
  82. print '</td>';
  83. 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>';
  84. print "</tr>\n";
  85. }
  86. if (count($linkedObjectBlock) > 1) {
  87. print '<tr class="liste_total '.(empty($noMoreLinkedObjectBlockAfter) ? 'liste_sub_total' : '').'">';
  88. print '<td>'.$langs->trans("Total").'</td>';
  89. print '<td></td>';
  90. print '<td class="center"></td>';
  91. print '<td class="center"></td>';
  92. print '<td class="right">'.price($total).'</td>';
  93. print '<td class="right"></td>';
  94. print '<td class="right"></td>';
  95. print '</tr>';
  96. }
  97. print "<!-- END PHP TEMPLATE -->\n";