propal.lib.php 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  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 propal_prepare_head($object)
  31. {
  32. global $db, $langs, $conf, $user;
  33. $langs->load("propal");
  34. $langs->load("compta");
  35. $langs->load("companies");
  36. $h = 0;
  37. $head = array();
  38. $head[$h][0] = DOL_URL_ROOT.'/comm/propal/card.php?id='.$object->id;
  39. $head[$h][1] = $langs->trans('ProposalCard');
  40. $head[$h][2] = 'comm';
  41. $h++;
  42. if ((empty($conf->commande->enabled) && ((! empty($conf->expedition_bon->enabled) && $user->rights->expedition->lire)
  43. || (! empty($conf->livraison_bon->enabled) && $user->rights->expedition->livraison->lire))))
  44. {
  45. $langs->load("sendings");
  46. $head[$h][0] = DOL_URL_ROOT.'/expedition/propal.php?id='.$object->id;
  47. if ($conf->expedition_bon->enabled) $text=$langs->trans("Shipment");
  48. if ($conf->livraison_bon->enabled) $text.='/'.$langs->trans("Receivings");
  49. $head[$h][1] = $text;
  50. $head[$h][2] = 'shipping';
  51. $h++;
  52. }
  53. if (empty($conf->global->MAIN_DISABLE_CONTACTS_TAB))
  54. {
  55. $nbContact = count($object->liste_contact(-1,'internal')) + count($object->liste_contact(-1,'external'));
  56. $head[$h][0] = DOL_URL_ROOT.'/comm/propal/contact.php?id='.$object->id;
  57. $head[$h][1] = $langs->trans('ContactsAddresses');
  58. if ($nbContact > 0) $head[$h][1].= ' <span class="badge">'.$nbContact.'</span>';
  59. $head[$h][2] = 'contact';
  60. $h++;
  61. }
  62. // Show more tabs from modules
  63. // Entries must be declared in modules descriptor with line
  64. // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
  65. // $this->tabs = array('entity:-tabname); to remove a tab
  66. complete_head_from_modules($conf,$langs,$object,$head,$h,'propal');
  67. if (empty($conf->global->MAIN_DISABLE_NOTES_TAB))
  68. {
  69. $nbNote = 0;
  70. if(!empty($object->note_private)) $nbNote++;
  71. if(!empty($object->note_public)) $nbNote++;
  72. $head[$h][0] = DOL_URL_ROOT.'/comm/propal/note.php?id='.$object->id;
  73. $head[$h][1] = $langs->trans('Notes');
  74. if ($nbNote > 0) $head[$h][1].= ' <span class="badge">'.$nbNote.'</span>';
  75. $head[$h][2] = 'note';
  76. $h++;
  77. }
  78. require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
  79. require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php';
  80. $upload_dir = $conf->propal->dir_output . "/" . dol_sanitizeFileName($object->ref);
  81. $nbFiles = count(dol_dir_list($upload_dir,'files',0,'','(\.meta|_preview.*\.png)$'));
  82. $nbLinks=Link::count($db, $object->element, $object->id);
  83. $head[$h][0] = DOL_URL_ROOT.'/comm/propal/document.php?id='.$object->id;
  84. $head[$h][1] = $langs->trans('Documents');
  85. if (($nbFiles+$nbLinks) > 0) $head[$h][1].= ' <span class="badge">'.($nbFiles+$nbLinks).'</span>';
  86. $head[$h][2] = 'document';
  87. $h++;
  88. $head[$h][0] = DOL_URL_ROOT.'/comm/propal/info.php?id='.$object->id;
  89. $head[$h][1] = $langs->trans('Info');
  90. $head[$h][2] = 'info';
  91. $h++;
  92. complete_head_from_modules($conf,$langs,$object,$head,$h,'propal','remove');
  93. return $head;
  94. }
  95. /**
  96. * Return array head with list of tabs to view object informations.
  97. *
  98. * @return array head array with tabs
  99. */
  100. function propal_admin_prepare_head()
  101. {
  102. global $langs, $conf, $user;
  103. $h = 0;
  104. $head = array();
  105. $head[$h][0] = DOL_URL_ROOT.'/admin/propal.php';
  106. $head[$h][1] = $langs->trans("Miscellaneous");
  107. $head[$h][2] = 'general';
  108. $h++;
  109. // Show more tabs from modules
  110. // Entries must be declared in modules descriptor with line
  111. // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
  112. // $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to remove a tab
  113. complete_head_from_modules($conf,$langs,null,$head,$h,'propal_admin');
  114. $head[$h][0] = DOL_URL_ROOT.'/comm/admin/propal_extrafields.php';
  115. $head[$h][1] = $langs->trans("ExtraFields");
  116. $head[$h][2] = 'attributes';
  117. $h++;
  118. $head[$h][0] = DOL_URL_ROOT.'/comm/admin/propaldet_extrafields.php';
  119. $head[$h][1] = $langs->trans("ExtraFieldsLines");
  120. $head[$h][2] = 'attributeslines';
  121. $h++;
  122. complete_head_from_modules($conf,$langs,null,$head,$h,'propal_admin','remove');
  123. return $head;
  124. }