dolibarr  13.0.2
zapier_hook.lib.php
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 
30 function myobjectPrepareHead($object)
31 {
32  global $db, $langs, $conf;
33 
34  $langs->load("mymodule@mymodule");
35 
36  $h = 0;
37  $head = array();
38 
39  $head[$h][0] = dol_buildpath("/mymodule/myobject_card.php", 1).'?id='.$object->id;
40  $head[$h][1] = $langs->trans("Card");
41  $head[$h][2] = 'card';
42  $h++;
43 
44  if (isset($object->fields['note_public']) || isset($object->fields['note_private'])) {
45  $nbNote = 0;
46  if (!empty($object->note_private)) $nbNote++;
47  if (!empty($object->note_public)) $nbNote++;
48  $head[$h][0] = dol_buildpath('/mymodule/myobject_note.php', 1).'?id='.$object->id;
49  $head[$h][1] = $langs->trans('Notes');
50  if ($nbNote > 0) $head[$h][1] .= '<span class="badge marginleftonlyshort">'.$nbNote.'</span>';
51  $head[$h][2] = 'note';
52  $h++;
53  }
54 
55  require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
56  require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php';
57  $upload_dir = $conf->mymodule->dir_output."/myobject/".dol_sanitizeFileName($object->ref);
58  $nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$'));
59  $nbLinks = Link::count($db, $object->element, $object->id);
60  $head[$h][0] = dol_buildpath("/mymodule/myobject_document.php", 1).'?id='.$object->id;
61  $head[$h][1] = $langs->trans('Documents');
62  if (($nbFiles + $nbLinks) > 0) $head[$h][1] .= '<span class="badge marginleftonlyshort">'.($nbFiles + $nbLinks).'</span>';
63  $head[$h][2] = 'document';
64  $h++;
65 
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 
71  // Show more tabs from modules
72  // Entries must be declared in modules descriptor with line
73  //$this->tabs = array(
74  // 'entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'
75  //); // to add new tab
76  //$this->tabs = array(
77  // 'entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'
78  //); // to remove a tab
79  complete_head_from_modules($conf, $langs, $object, $head, $h, 'myobject@mymodule');
80 
81  return $head;
82 }
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
myobjectPrepareHead($object)
Prepare array of tabs for MyObject.
dol_sanitizeFileName($str, $newstr= '_', $unaccent=1)
Clean a string to use it as a file name.
dol_dir_list($path, $types="all", $recursive=0, $filter="", $excludefilter=null, $sortcriteria="name", $sortorder=SORT_ASC, $mode=0, $nohook=0, $relativename="", $donotfollowsymlinks=0)
Scan a directory and return a list of files/directories.
Definition: files.lib.php:60
complete_head_from_modules($conf, $langs, $object, &$head, &$h, $type, $mode= 'add')
Complete or removed entries into a head array (used to build tabs).