donation.lib.php 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. <?php
  2. /* Copyright (C) 2015 Alexandre Spangaro <aspangaro.dolibarr@gmail.com>
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License as published by
  6. * the Free Software Foundation; either version 3 of the License, or
  7. * (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  16. */
  17. /**
  18. * \file htdocs/core/lib/donation.lib.php
  19. * \ingroup Donation
  20. * \brief Library of donation functions
  21. */
  22. /**
  23. * Prepare array with list of admin tabs
  24. *
  25. * @return array Array of tabs to show
  26. */
  27. function donation_admin_prepare_head()
  28. {
  29. global $langs, $conf;
  30. $h = 0;
  31. $head = array();
  32. $head[$h][0] = DOL_URL_ROOT . '/don/admin/donation.php';
  33. $head[$h][1] = $langs->trans("Miscellaneous");
  34. $head[$h][2] = 'general';
  35. $h ++;
  36. // Show more tabs from modules
  37. // Entries must be declared in modules descriptor with line
  38. // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
  39. // $this->tabs = array('entity:-tabname); to remove a tab
  40. complete_head_from_modules($conf, $langs, null, $head, $h, 'donation_admin');
  41. $head[$h][0] = DOL_URL_ROOT . '/don/admin/donation_extrafields.php';
  42. $head[$h][1] = $langs->trans("ExtraFields");
  43. $head[$h][2] = 'attributes';
  44. $h++;
  45. complete_head_from_modules($conf, $langs, null, $head, $h, 'donation_admin', 'remove');
  46. return $head;
  47. }
  48. /**
  49. * Prepare array with list of tabs
  50. *
  51. * @param Donation $object Donation
  52. * @return array Array of tabs to show
  53. */
  54. function donation_prepare_head($object)
  55. {
  56. global $db, $langs, $conf;
  57. $h = 0;
  58. $head = array();
  59. $head[$h][0] = DOL_URL_ROOT . '/don/card.php?id=' . $object->id;
  60. $head[$h][1] = $langs->trans("Card");
  61. $head[$h][2] = 'card';
  62. $h ++;
  63. // Show more tabs from modules
  64. // Entries must be declared in modules descriptor with line
  65. // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
  66. // $this->tabs = array('entity:-tabname); to remove a tab
  67. complete_head_from_modules($conf, $langs, $object, $head, $h, 'donation');
  68. require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
  69. require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php';
  70. $upload_dir = $conf->don->dir_output . '/' . get_exdir($filename,2,0,1,$object,'donation'). '/'. dol_sanitizeFileName($object->ref);
  71. $nbFiles = count(dol_dir_list($upload_dir,'files',0,'','(\.meta|_preview.*\.png)$'));
  72. $nbLinks=Link::count($db, $object->element, $object->id);
  73. $head[$h][0] = DOL_URL_ROOT.'/don/document.php?id='.$object->id;
  74. $head[$h][1] = $langs->trans('Documents');
  75. if (($nbFiles+$nbLinks) > 0) $head[$h][1].= ' <span class="badge">'.($nbFiles+$nbLinks).'</span>';
  76. $head[$h][2] = 'documents';
  77. $h++;
  78. $nbNote = 0;
  79. if(!empty($object->note_private)) $nbNote++;
  80. if(!empty($object->note_public)) $nbNote++;
  81. $head[$h][0] = DOL_URL_ROOT.'/don/note.php?id='.$object->id;
  82. $head[$h][1] = $langs->trans("Notes");
  83. if ($nbNote > 0) $head[$h][1].= ' <span class="badge">'.$nbNote.'</span>';
  84. $head[$h][2] = 'note';
  85. $h++;
  86. $head[$h][0] = DOL_URL_ROOT . '/don/info.php?id=' . $object->id;
  87. $head[$h][1] = $langs->trans("Info");
  88. $head[$h][2] = 'info';
  89. $h++;
  90. complete_head_from_modules($conf, $langs, $object, $head, $h, 'donation', 'remove');
  91. return $head;
  92. }