contract.lib.php 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. <?php
  2. /* Copyright (C) 2006-2012 Laurent Destailleur <eldy@users.sourceforge.net>
  3. * Copyright (C) 2009-2012 Regis Houssin <regis.houssin@capnetworks.com>
  4. *
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation; either version 3 of the License, or
  8. * (at your option) any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. * or see http://www.gnu.org/
  18. */
  19. /**
  20. * \file htdocs/core/lib/contract.lib.php
  21. * \brief Ensemble de fonctions de base pour le module contrat
  22. */
  23. /**
  24. * Prepare array with list of tabs
  25. *
  26. * @param Contrat $object Object related to tabs
  27. * @return array Array of tabs to show
  28. */
  29. function contract_prepare_head(Contrat $object)
  30. {
  31. global $db, $langs, $conf;
  32. $h = 0;
  33. $head = array();
  34. $head[$h][0] = DOL_URL_ROOT.'/contrat/card.php?id='.$object->id;
  35. $head[$h][1] = $langs->trans("ContractCard");
  36. $head[$h][2] = 'card';
  37. $h++;
  38. if (empty($conf->global->MAIN_DISABLE_CONTACTS_TAB))
  39. {
  40. $nbContact = count($object->liste_contact(-1,'internal')) + count($object->liste_contact(-1,'external'));
  41. $head[$h][0] = DOL_URL_ROOT.'/contrat/contact.php?id='.$object->id;
  42. $head[$h][1] = $langs->trans("ContactsAddresses");
  43. if ($nbContact > 0) $head[$h][1].= ' <span class="badge">'.$nbContact.'</span>';
  44. $head[$h][2] = 'contact';
  45. $h++;
  46. }
  47. // Show more tabs from modules
  48. // Entries must be declared in modules descriptor with line
  49. // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
  50. // $this->tabs = array('entity:-tabname); to remove a tab
  51. complete_head_from_modules($conf,$langs,$object,$head,$h,'contract');
  52. if (empty($conf->global->MAIN_DISABLE_NOTES_TAB))
  53. {
  54. $nbNote = 0;
  55. if(!empty($object->note_private)) $nbNote++;
  56. if(!empty($object->note_public)) $nbNote++;
  57. $head[$h][0] = DOL_URL_ROOT.'/contrat/note.php?id='.$object->id;
  58. $head[$h][1] = $langs->trans("Notes");
  59. if ($nbNote > 0) $head[$h][1].= ' <span class="badge">'.$nbNote.'</span>';
  60. $head[$h][2] = 'note';
  61. $h++;
  62. }
  63. require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
  64. require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php';
  65. $upload_dir = $conf->contrat->dir_output . "/" . dol_sanitizeFileName($object->ref);
  66. $nbFiles = count(dol_dir_list($upload_dir,'files',0,'','(\.meta|_preview.*\.png)$'));
  67. $nbLinks=Link::count($db, $object->element, $object->id);
  68. $head[$h][0] = DOL_URL_ROOT.'/contrat/document.php?id='.$object->id;
  69. $head[$h][1] = $langs->trans("Documents");
  70. if (($nbFiles+$nbLinks) > 0) $head[$h][1].= ' <span class="badge">'.($nbFiles+$nbLinks).'</span>';
  71. $head[$h][2] = 'documents';
  72. $h++;
  73. $head[$h][0] = DOL_URL_ROOT.'/contrat/info.php?id='.$object->id;
  74. $head[$h][1] = $langs->trans("Info");
  75. $head[$h][2] = 'info';
  76. $h++;
  77. complete_head_from_modules($conf,$langs,$object,$head,$h,'contract','remove');
  78. return $head;
  79. }
  80. /**
  81. * Return array head with list of tabs to view object informations.
  82. *
  83. * @return array head array with tabs
  84. */
  85. function contract_admin_prepare_head()
  86. {
  87. global $langs, $conf, $user;
  88. $h = 0;
  89. $head = array();
  90. $head[$h][0] = DOL_URL_ROOT."/admin/contract.php";
  91. $head[$h][1] = $langs->trans("Contracts");
  92. $head[$h][2] = 'contract';
  93. $h++;
  94. // Show more tabs from modules
  95. // Entries must be declared in modules descriptor with line
  96. // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
  97. // $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to remove a tab
  98. complete_head_from_modules($conf,$langs,null,$head,$h,'contract_admin');
  99. $head[$h][0] = DOL_URL_ROOT.'/contrat/admin/contract_extrafields.php';
  100. $head[$h][1] = $langs->trans("ExtraFields");
  101. $head[$h][2] = 'attributes';
  102. $h++;
  103. $head[$h][0] = DOL_URL_ROOT.'/contrat/admin/contractdet_extrafields.php';
  104. $head[$h][1] = $langs->trans("ExtraFieldsLines");
  105. $head[$h][2] = 'attributeslines';
  106. $h++;
  107. complete_head_from_modules($conf,$langs,null,$head,$h,'contract_admin','remove');
  108. return $head;
  109. }