contract.lib.php 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  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 Object $object Object related to tabs
  27. * @return array Array of tabs to shoc
  28. */
  29. function contract_prepare_head($object)
  30. {
  31. global $langs, $conf;
  32. $h = 0;
  33. $head = array();
  34. $head[$h][0] = DOL_URL_ROOT.'/contrat/fiche.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. $head[$h][0] = DOL_URL_ROOT.'/contrat/contact.php?id='.$object->id;
  41. $head[$h][1] = $langs->trans("ContactsAddresses");
  42. $head[$h][2] = 'contact';
  43. $h++;
  44. }
  45. // Show more tabs from modules
  46. // Entries must be declared in modules descriptor with line
  47. // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
  48. // $this->tabs = array('entity:-tabname); to remove a tab
  49. complete_head_from_modules($conf,$langs,$object,$head,$h,'contract');
  50. if (empty($conf->global->MAIN_DISABLE_NOTES_TAB))
  51. {
  52. $nbNote = 0;
  53. if(!empty($object->note_private)) $nbNote++;
  54. if(!empty($object->note_public)) $nbNote++;
  55. $head[$h][0] = DOL_URL_ROOT.'/contrat/note.php?id='.$object->id;
  56. $head[$h][1] = $langs->trans("Notes");
  57. if($nbNote > 0) $head[$h][1].= ' ('.$nbNote.')';
  58. $head[$h][2] = 'note';
  59. $h++;
  60. }
  61. require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
  62. $upload_dir = $conf->contrat->dir_output . "/" . dol_sanitizeFileName($object->ref);
  63. $nbFiles = count(dol_dir_list($upload_dir,'files',0,'','(\.meta|_preview\.png)$'));
  64. $head[$h][0] = DOL_URL_ROOT.'/contrat/document.php?id='.$object->id;
  65. $head[$h][1] = $langs->trans("Documents");
  66. if($nbFiles > 0) $head[$h][1].= ' ('.$nbFiles.')';
  67. $head[$h][2] = 'documents';
  68. $h++;
  69. $head[$h][0] = DOL_URL_ROOT.'/contrat/info.php?id='.$object->id;
  70. $head[$h][1] = $langs->trans("Info");
  71. $head[$h][2] = 'info';
  72. $h++;
  73. complete_head_from_modules($conf,$langs,$object,$head,$h,'contract','remove');
  74. return $head;
  75. }
  76. /**
  77. * Return array head with list of tabs to view object informations.
  78. *
  79. * @return array head array with tabs
  80. */
  81. function contract_admin_prepare_head()
  82. {
  83. global $langs, $conf, $user;
  84. $h = 0;
  85. $head = array();
  86. $head[$h][0] = DOL_URL_ROOT."/admin/contract.php";
  87. $head[$h][1] = $langs->trans("Contracts");
  88. $head[$h][2] = 'contract';
  89. $h++;
  90. // Show more tabs from modules
  91. // Entries must be declared in modules descriptor with line
  92. // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
  93. // $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to remove a tab
  94. complete_head_from_modules($conf,$langs,null,$head,$h,'contract_admin');
  95. $head[$h][0] = DOL_URL_ROOT.'/contrat/admin/contract_extrafields.php';
  96. $head[$h][1] = $langs->trans("ExtraFields");
  97. $head[$h][2] = 'attributes';
  98. $h++;
  99. complete_head_from_modules($conf,$langs,null,$head,$h,'contract_admin','remove');
  100. return $head;
  101. }