dolibarr  16.0.5
contract.lib.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2006-2012 Laurent Destailleur <eldy@users.sourceforge.net>
3  * Copyright (C) 2009-2012 Regis Houssin <regis.houssin@inodbox.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 <https://www.gnu.org/licenses/>.
17  * or see https://www.gnu.org/
18  */
19 
31 function contract_prepare_head(Contrat $object)
32 {
33  global $db, $langs, $conf, $user;
34 
35  $h = 0;
36  $head = array();
37 
38  $head[$h][0] = DOL_URL_ROOT.'/contrat/card.php?id='.$object->id;
39  $head[$h][1] = $langs->trans("ContractCard");
40  $head[$h][2] = 'card';
41  $h++;
42 
43  if (empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) {
44  $nbContact = count($object->liste_contact(-1, 'internal')) + count($object->liste_contact(-1, 'external'));
45  $head[$h][0] = DOL_URL_ROOT.'/contrat/contact.php?id='.$object->id;
46  $head[$h][1] = $langs->trans("ContactsAddresses");
47  if ($nbContact > 0) {
48  $head[$h][1] .= '<span class="badge marginleftonlyshort">'.$nbContact.'</span>';
49  }
50  $head[$h][2] = 'contact';
51  $h++;
52  }
53 
54  // Show more tabs from modules
55  // Entries must be declared in modules descriptor with line
56  // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
57  // $this->tabs = array('entity:-tabname); to remove a tab
58  complete_head_from_modules($conf, $langs, $object, $head, $h, 'contract');
59 
60  if (empty($conf->global->MAIN_DISABLE_NOTES_TAB)) {
61  $nbNote = 0;
62  if (!empty($object->note_private)) {
63  $nbNote++;
64  }
65  if (!empty($object->note_public)) {
66  $nbNote++;
67  }
68  $head[$h][0] = DOL_URL_ROOT.'/contrat/note.php?id='.$object->id;
69  $head[$h][1] = $langs->trans("Notes");
70  if ($nbNote > 0) {
71  $head[$h][1] .= '<span class="badge marginleftonlyshort">'.$nbNote.'</span>';
72  }
73  $head[$h][2] = 'note';
74  $h++;
75  }
76 
77  require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
78  require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php';
79  $upload_dir = $conf->contrat->multidir_output[$object->entity]."/".dol_sanitizeFileName($object->ref);
80  $nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$'));
81  $nbLinks = Link::count($db, $object->element, $object->id);
82  $head[$h][0] = DOL_URL_ROOT.'/contrat/document.php?id='.$object->id;
83  $head[$h][1] = $langs->trans("Documents");
84  if (($nbFiles + $nbLinks) > 0) {
85  $head[$h][1] .= '<span class="badge marginleftonlyshort">'.($nbFiles + $nbLinks).'</span>';
86  }
87  $head[$h][2] = 'documents';
88  $h++;
89 
90  $head[$h][0] = DOL_URL_ROOT.'/contrat/agenda.php?id='.$object->id;
91  $head[$h][1] .= $langs->trans("Events");
92  if (isModEnabled('agenda') && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read))) {
93  $head[$h][1] .= '/';
94  $head[$h][1] .= $langs->trans("Agenda");
95  }
96  $head[$h][2] = 'agenda';
97  $h++;
98 
99  complete_head_from_modules($conf, $langs, $object, $head, $h, 'contract', 'remove');
100 
101  return $head;
102 }
103 
110 {
111  global $langs, $conf;
112 
113  $h = 0;
114  $head = array();
115 
116  $head[$h][0] = DOL_URL_ROOT."/admin/contract.php";
117  $head[$h][1] = $langs->trans("Contracts");
118  $head[$h][2] = 'contract';
119  $h++;
120 
121  // Show more tabs from modules
122  // Entries must be declared in modules descriptor with line
123  // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
124  // $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to remove a tab
125  complete_head_from_modules($conf, $langs, null, $head, $h, 'contract_admin');
126 
127  $head[$h][0] = DOL_URL_ROOT.'/contrat/admin/contract_extrafields.php';
128  $head[$h][1] = $langs->trans("ExtraFields");
129  $head[$h][2] = 'attributes';
130  $h++;
131 
132  $head[$h][0] = DOL_URL_ROOT.'/contrat/admin/contractdet_extrafields.php';
133  $head[$h][1] = $langs->trans("ExtraFieldsLines");
134  $head[$h][2] = 'attributeslines';
135  $h++;
136 
137  complete_head_from_modules($conf, $langs, null, $head, $h, 'contract_admin', 'remove');
138 
139  return $head;
140 }
dol_sanitizeFileName
dol_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
Definition: functions.lib.php:1226
dol_dir_list
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
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
contract_admin_prepare_head
contract_admin_prepare_head()
Return array head with list of tabs to view object informations.
Definition: contract.lib.php:109
isModEnabled
isModEnabled($module)
Is Dolibarr module enabled.
Definition: functions.lib.php:105
Contrat
Class to manage contracts.
Definition: contrat.class.php:43
contract_prepare_head
contract_prepare_head(Contrat $object)
Prepare array with list of tabs.
Definition: contract.lib.php:31