dolibarr  16.0.5
webhook_target.lib.php
Go to the documentation of this file.
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 <https://www.gnu.org/licenses/>.
16  */
17 
29 function targetPrepareHead($object)
30 {
31  global $db, $langs, $conf;
32 
33  $langs->load("webhook@webhook");
34 
35  $h = 0;
36  $head = array();
37 
38  $head[$h][0] = dol_buildpath("/webhook/target_card.php", 1).'?id='.$object->id;
39  $head[$h][1] = $langs->trans("Card");
40  $head[$h][2] = 'card';
41  $h++;
42 
43  if (isset($object->fields['note_public']) || isset($object->fields['note_private'])) {
44  $nbNote = 0;
45  if (!empty($object->note_private)) {
46  $nbNote++;
47  }
48  if (!empty($object->note_public)) {
49  $nbNote++;
50  }
51  $head[$h][0] = dol_buildpath('/webhook/target_note.php', 1).'?id='.$object->id;
52  $head[$h][1] = $langs->trans('Notes');
53  if ($nbNote > 0) {
54  $head[$h][1] .= (empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER) ? '<span class="badge marginleftonlyshort">'.$nbNote.'</span>' : '');
55  }
56  $head[$h][2] = 'note';
57  $h++;
58  }
59 
60  /*require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
61  require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php';
62  $upload_dir = $conf->webhook->dir_output."/target/".dol_sanitizeFileName($object->ref);
63  $nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$'));
64  $nbLinks = Link::count($db, $object->element, $object->id);
65  $head[$h][0] = dol_buildpath("/webhook/target_document.php", 1).'?id='.$object->id;
66  $head[$h][1] = $langs->trans('Documents');
67  if (($nbFiles + $nbLinks) > 0) {
68  $head[$h][1] .= '<span class="badge marginleftonlyshort">'.($nbFiles + $nbLinks).'</span>';
69  }
70  $head[$h][2] = 'document';
71  $h++;*/
72 
73  /*$head[$h][0] = dol_buildpath("/webhook/target_agenda.php", 1).'?id='.$object->id;
74  $head[$h][1] = $langs->trans("Events");
75  $head[$h][2] = 'agenda';
76  $h++;*/
77 
78  // Show more tabs from modules
79  // Entries must be declared in modules descriptor with line
80  //$this->tabs = array(
81  // 'entity:+tabname:Title:@webhook:/webhook/mypage.php?id=__ID__'
82  //); // to add new tab
83  //$this->tabs = array(
84  // 'entity:-tabname:Title:@webhook:/webhook/mypage.php?id=__ID__'
85  //); // to remove a tab
86  complete_head_from_modules($conf, $langs, $object, $head, $h, 'target@webhook');
87 
88  complete_head_from_modules($conf, $langs, $object, $head, $h, 'target@webhook', 'remove');
89 
90  return $head;
91 }
dol_buildpath
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
Definition: functions.lib.php:1062
complete_head_from_modules
complete_head_from_modules($conf, $langs, $object, &$head, &$h, $type, $mode='add')
Complete or removed entries into a head array (used to build tabs).
Definition: functions.lib.php:9038
targetPrepareHead
targetPrepareHead($object)
Prepare array of tabs for Target.
Definition: webhook_target.lib.php:29