dolibarr  7.0.0-beta
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@capnetworks.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 <http://www.gnu.org/licenses/>.
17  * or see http://www.gnu.org/
18  */
19 
31 function contract_prepare_head(Contrat $object)
32 {
33  global $db, $langs, $conf;
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  {
45  $nbContact = count($object->liste_contact(-1,'internal')) + count($object->liste_contact(-1,'external'));
46  $head[$h][0] = DOL_URL_ROOT.'/contrat/contact.php?id='.$object->id;
47  $head[$h][1] = $langs->trans("ContactsAddresses");
48  if ($nbContact > 0) $head[$h][1].= ' <span class="badge">'.$nbContact.'</span>';
49  $head[$h][2] = 'contact';
50  $h++;
51  }
52 
53  // Show more tabs from modules
54  // Entries must be declared in modules descriptor with line
55  // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
56  // $this->tabs = array('entity:-tabname); to remove a tab
57  complete_head_from_modules($conf,$langs,$object,$head,$h,'contract');
58 
59  if (empty($conf->global->MAIN_DISABLE_NOTES_TAB))
60  {
61  $nbNote = 0;
62  if(!empty($object->note_private)) $nbNote++;
63  if(!empty($object->note_public)) $nbNote++;
64  $head[$h][0] = DOL_URL_ROOT.'/contrat/note.php?id='.$object->id;
65  $head[$h][1] = $langs->trans("Notes");
66  if ($nbNote > 0) $head[$h][1].= ' <span class="badge">'.$nbNote.'</span>';
67  $head[$h][2] = 'note';
68  $h++;
69  }
70 
71  require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
72  require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php';
73  $upload_dir = $conf->contrat->dir_output . "/" . dol_sanitizeFileName($object->ref);
74  $nbFiles = count(dol_dir_list($upload_dir,'files',0,'','(\.meta|_preview.*\.png)$'));
75  $nbLinks=Link::count($db, $object->element, $object->id);
76  $head[$h][0] = DOL_URL_ROOT.'/contrat/document.php?id='.$object->id;
77  $head[$h][1] = $langs->trans("Documents");
78  if (($nbFiles+$nbLinks) > 0) $head[$h][1].= ' <span class="badge">'.($nbFiles+$nbLinks).'</span>';
79  $head[$h][2] = 'documents';
80  $h++;
81 
82  $head[$h][0] = DOL_URL_ROOT.'/contrat/info.php?id='.$object->id;
83  $head[$h][1] = $langs->trans("Info");
84  $head[$h][2] = 'info';
85  $h++;
86 
87  complete_head_from_modules($conf,$langs,$object,$head,$h,'contract','remove');
88 
89  return $head;
90 }
91 
98 {
99  global $langs, $conf, $user;
100 
101  $h = 0;
102  $head = array();
103 
104  $head[$h][0] = DOL_URL_ROOT."/admin/contract.php";
105  $head[$h][1] = $langs->trans("Contracts");
106  $head[$h][2] = 'contract';
107  $h++;
108 
109  // Show more tabs from modules
110  // Entries must be declared in modules descriptor with line
111  // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
112  // $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to remove a tab
113  complete_head_from_modules($conf,$langs,null,$head,$h,'contract_admin');
114 
115  $head[$h][0] = DOL_URL_ROOT.'/contrat/admin/contract_extrafields.php';
116  $head[$h][1] = $langs->trans("ExtraFields");
117  $head[$h][2] = 'attributes';
118  $h++;
119 
120  $head[$h][0] = DOL_URL_ROOT.'/contrat/admin/contractdet_extrafields.php';
121  $head[$h][1] = $langs->trans("ExtraFieldsLines");
122  $head[$h][2] = 'attributeslines';
123  $h++;
124 
125 
126 
127  complete_head_from_modules($conf,$langs,null,$head,$h,'contract_admin','remove');
128 
129  return $head;
130 }
131 
contract_admin_prepare_head()
Return array head with list of tabs to view object informations.
complete_head_from_modules($conf, $langs, $object, &$head, &$h, $type, $mode='add')
Complete or removed entries into a head array (used to build tabs).
dol_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
Class to manage contracts.
contract_prepare_head(Contrat $object)
Prepare array with list of tabs.
dol_dir_list($path, $types="all", $recursive=0, $filter="", $excludefilter=null, $sortcriteria="name", $sortorder=SORT_ASC, $mode=0, $nohook=0, $relativename="")
Scan a directory and return a list of files/directories.
Definition: files.lib.php:58
liste_contact($statut=-1, $source='external', $list=0, $code='')
Get array of all contacts for an object.