supplier_proposal.lib.php 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. <?php
  2. /* Copyright (C) 2006-2010 Laurent Destailleur <eldy@users.sourceforge.net>
  3. * Copyright (C) 2005-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/propal.lib.php
  21. * \brief Ensemble de fonctions de base pour le module propal
  22. * \ingroup propal
  23. */
  24. /**
  25. * Prepare array with list of tabs
  26. *
  27. * @param object $object Object related to tabs
  28. * @return array Array of tabs to show
  29. */
  30. function supplier_proposal_prepare_head($object)
  31. {
  32. global $db, $langs, $conf, $user;
  33. $langs->load("supplier_proposal");
  34. $langs->load("compta");
  35. $h = 0;
  36. $head = array();
  37. $head[$h][0] = DOL_URL_ROOT.'/supplier_proposal/card.php?id='.$object->id;
  38. $head[$h][1] = $langs->trans('SupplierProposalCard');
  39. $head[$h][2] = 'comm';
  40. $h++;
  41. // Show more tabs from modules
  42. // Entries must be declared in modules descriptor with line
  43. // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
  44. // $this->tabs = array('entity:-tabname); to remove a tab
  45. complete_head_from_modules($conf,$langs,$object,$head,$h,'supplier_proposal');
  46. if (empty($conf->global->MAIN_DISABLE_NOTES_TAB))
  47. {
  48. $nbNote = 0;
  49. if(!empty($object->note_private)) $nbNote++;
  50. if(!empty($object->note_public)) $nbNote++;
  51. $head[$h][0] = DOL_URL_ROOT.'/supplier_proposal/note.php?id='.$object->id;
  52. $head[$h][1] = $langs->trans('Notes');
  53. if ($nbNote > 0) $head[$h][1].= ' <span class="badge">'.$nbNote.'</span>';
  54. $head[$h][2] = 'note';
  55. $h++;
  56. }
  57. require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
  58. require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php';
  59. $upload_dir = $conf->supplier_proposal->dir_output . "/" . dol_sanitizeFileName($object->ref);
  60. $nbFiles = count(dol_dir_list($upload_dir,'files',0,'','(\.meta|_preview.*\.png)$'));
  61. $nbLinks=Link::count($db, $object->element, $object->id);
  62. $head[$h][0] = DOL_URL_ROOT.'/supplier_proposal/document.php?id='.$object->id;
  63. $head[$h][1] = $langs->trans('Documents');
  64. if (($nbFiles+$nbLinks) > 0) $head[$h][1].= ' <span class="badge">'.($nbFiles+$nbLinks).'</span>';
  65. $head[$h][2] = 'document';
  66. $h++;
  67. $head[$h][0] = DOL_URL_ROOT.'/supplier_proposal/info.php?id='.$object->id;
  68. $head[$h][1] = $langs->trans('Info');
  69. $head[$h][2] = 'info';
  70. $h++;
  71. complete_head_from_modules($conf,$langs,$object,$head,$h,'supplier_proposal','remove');
  72. return $head;
  73. }
  74. /**
  75. * Return array head with list of tabs to view object informations.
  76. *
  77. * @return array head array with tabs
  78. */
  79. function supplier_proposal_admin_prepare_head()
  80. {
  81. global $langs, $conf, $user;
  82. $h = 0;
  83. $head = array();
  84. $head[$h][0] = DOL_URL_ROOT.'/admin/supplier_proposal.php';
  85. $head[$h][1] = $langs->trans("Miscellaneous");
  86. $head[$h][2] = 'general';
  87. $h++;
  88. // Show more tabs from modules
  89. // Entries must be declared in modules descriptor with line
  90. // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
  91. // $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to remove a tab
  92. complete_head_from_modules($conf,$langs,null,$head,$h,'supplier_proposal_admin');
  93. $head[$h][0] = DOL_URL_ROOT.'/supplier_proposal/admin/supplier_proposal_extrafields.php';
  94. $head[$h][1] = $langs->trans("ExtraFields");
  95. $head[$h][2] = 'attributes';
  96. $h++;
  97. $head[$h][0] = DOL_URL_ROOT.'/supplier_proposal/admin/supplier_proposaldet_extrafields.php';
  98. $head[$h][1] = $langs->trans("ExtraFieldsLines");
  99. $head[$h][2] = 'attributeslines';
  100. $h++;
  101. complete_head_from_modules($conf,$langs,null,$head,$h,'supplier_proposal_admin','remove');
  102. return $head;
  103. }