zapier_hook.lib.php 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. <?php
  2. /* Copyright (C) ---Put here your own copyright and developer email---
  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/modulebuilder/template/lib/mymodule_myobject.lib.php
  19. * \ingroup mymodule
  20. * \brief Library files with common functions for MyObject
  21. */
  22. /**
  23. * Prepare array of tabs for MyObject
  24. *
  25. * @param MyObject $object MyObject
  26. * @return array Array of tabs
  27. */
  28. function myobjectPrepareHead($object)
  29. {
  30. global $db, $langs, $conf;
  31. $langs->load("mymodule@mymodule");
  32. $h = 0;
  33. $head = array();
  34. $head[$h][0] = dol_buildpath("/mymodule/myobject_card.php", 1).'?id='.$object->id;
  35. $head[$h][1] = $langs->trans("Card");
  36. $head[$h][2] = 'card';
  37. $h++;
  38. if (isset($object->fields['note_public']) || isset($object->fields['note_private'])) {
  39. $nbNote = 0;
  40. if (!empty($object->note_private)) {
  41. $nbNote++;
  42. }
  43. if (!empty($object->note_public)) {
  44. $nbNote++;
  45. }
  46. $head[$h][0] = dol_buildpath('/mymodule/myobject_note.php', 1).'?id='.$object->id;
  47. $head[$h][1] = $langs->trans('Notes');
  48. if ($nbNote > 0) {
  49. $head[$h][1] .= '<span class="badge marginleftonlyshort">'.$nbNote.'</span>';
  50. }
  51. $head[$h][2] = 'note';
  52. $h++;
  53. }
  54. require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
  55. require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php';
  56. $upload_dir = $conf->mymodule->dir_output."/myobject/".dol_sanitizeFileName($object->ref);
  57. $nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$'));
  58. $nbLinks = Link::count($db, $object->element, $object->id);
  59. $head[$h][0] = dol_buildpath("/mymodule/myobject_document.php", 1).'?id='.$object->id;
  60. $head[$h][1] = $langs->trans('Documents');
  61. if (($nbFiles + $nbLinks) > 0) {
  62. $head[$h][1] .= '<span class="badge marginleftonlyshort">'.($nbFiles + $nbLinks).'</span>';
  63. }
  64. $head[$h][2] = 'document';
  65. $h++;
  66. $head[$h][0] = dol_buildpath("/mymodule/myobject_agenda.php", 1).'?id='.$object->id;
  67. $head[$h][1] = $langs->trans("Events");
  68. $head[$h][2] = 'agenda';
  69. $h++;
  70. // Show more tabs from modules
  71. // Entries must be declared in modules descriptor with line
  72. //$this->tabs = array(
  73. // 'entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'
  74. //); // to add new tab
  75. //$this->tabs = array(
  76. // 'entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'
  77. //); // to remove a tab
  78. complete_head_from_modules($conf, $langs, $object, $head, $h, 'myobject@mymodule');
  79. return $head;
  80. }