propal.lib.php 4.9 KB

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