dolibarr  16.0.5
reception.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) 2007 Rodolphe Quiedeville <rodolphe@quiedeville.org>
4  * Copyright (C) 2010-2012 Regis Houssin <regis.houssin@capnetworks.com>
5  * Copyright (C) 2010 Juanjo Menent <jmenent@2byte.es>
6  * Copyright (C) 2015 Claudio Aschieri <c.aschieri@19.coop>
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 3 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program. If not, see <https://www.gnu.org/licenses/>.
20  * or see https://www.gnu.org/
21  */
22 
36 {
37  global $db, $langs, $conf, $user;
38 
39  $langs->loadLangs(array("sendings", "deliveries"));
40 
41  $h = 0;
42  $head = array();
43 
44  $head[$h][0] = DOL_URL_ROOT."/reception/card.php?id=".$object->id;
45  $head[$h][1] = $langs->trans("ReceptionCard");
46  $head[$h][2] = 'reception';
47  $h++;
48 
49  if (empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) {
50  $objectsrc = $object;
51  if ($object->origin == 'supplier_order' && $object->origin_id > 0) {
52  $objectsrc = new CommandeFournisseur($db);
53  $objectsrc->fetch($object->origin_id);
54  }
55  $nbContact = count($objectsrc->liste_contact(-1, 'internal')) + count($objectsrc->liste_contact(-1, 'external'));
56  $head[$h][0] = DOL_URL_ROOT."/reception/contact.php?id=".$object->id;
57  $head[$h][1] = $langs->trans("ContactsAddresses");
58  if ($nbContact > 0) {
59  $head[$h][1] .= '<span class="badge marginleftonlyshort">'.$nbContact.'</span>';
60  }
61  $head[$h][2] = 'contact';
62  $h++;
63  }
64 
65  // Show more tabs from modules
66  // Entries must be declared in modules descriptor with line
67  // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
68  // $this->tabs = array('entity:-tabname); to remove a tab
69  complete_head_from_modules($conf, $langs, $object, $head, $h, 'reception');
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->reception->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.'/reception/document.php?id='.$object->id;
77  $head[$h][1] = $langs->trans('Documents');
78  if (($nbFiles + $nbLinks) > 0) {
79  $head[$h][1] .= '<span class="badge marginleftonlyshort">'.($nbFiles + $nbLinks).'</span>';
80  }
81  $head[$h][2] = 'documents';
82  $h++;
83 
84  $nbNote = 0;
85  if (!empty($object->note_private)) {
86  $nbNote++;
87  }
88  if (!empty($object->note_public)) {
89  $nbNote++;
90  }
91  $head[$h][0] = DOL_URL_ROOT."/reception/note.php?id=".$object->id;
92  $head[$h][1] = $langs->trans("Notes");
93  if ($nbNote > 0) {
94  $head[$h][1] .= '<span class="badge marginleftonlyshort">'.$nbNote.'</span>';
95  }
96  $head[$h][2] = 'note';
97  $h++;
98 
99  complete_head_from_modules($conf, $langs, $object, $head, $h, 'reception', 'remove');
100 
101  return $head;
102 }
103 
110 {
111  global $langs, $conf, $user;
112  $langs->load("receptions");
113 
114  $h = 0;
115  $head = array();
116 
117  $head[$h][0] = DOL_URL_ROOT."/admin/reception_setup.php";
118  $head[$h][1] = $langs->trans("Reception");
119  $head[$h][2] = 'reception';
120  $h++;
121 
122  complete_head_from_modules($conf, $langs, null, $head, $h, 'reception_admin');
123 
124  if (!empty($conf->global->MAIN_SUBMODULE_RECEPTION)) {
125  $head[$h][0] = DOL_URL_ROOT.'/admin/reception_extrafields.php';
126  $head[$h][1] = $langs->trans("ExtraFields");
127  $head[$h][2] = 'attributes_reception';
128  $h++;
129  }
130 
131  if (!empty($conf->global->MAIN_SUBMODULE_RECEPTION)) {
132  $head[$h][0] = DOL_URL_ROOT.'/admin/commande_fournisseur_dispatch_extrafields.php';
133  $head[$h][1] = $langs->trans("ExtraFieldsLines");
134  $head[$h][2] = 'attributeslines_reception';
135  $h++;
136  }
137 
138  complete_head_from_modules($conf, $langs, null, $head, $h, 'reception_admin', 'remove');
139 
140  return $head;
141 }
Reception
Class to manage receptions.
Definition: reception.class.php:49
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
reception_admin_prepare_head
reception_admin_prepare_head()
Return array head with list of tabs to view object informations.
Definition: reception.lib.php:109
reception_prepare_head
reception_prepare_head(Reception $object)
Prepare array with list of tabs.
Definition: reception.lib.php:35
CommandeFournisseur
Class to manage predefined suppliers products.
Definition: fournisseur.commande.class.php:47