dolibarr 18.0.6
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 ($object->statut == Reception::STATUS_DRAFT || ($object->statut == Reception::STATUS_VALIDATED && empty($conf->global->STOCK_CALCULATE_ON_RECEPTION))) {
50 $head[$h][0] = DOL_URL_ROOT."/reception/dispatch.php?id=".$object->id;
51 $head[$h][1] = $langs->trans("ReceptionDistribution");
52 $head[$h][2] = 'dispatch';
53 $h++;
54 }
55
56 if (empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) {
57 $objectsrc = $object;
58 if ($object->origin == 'supplier_order' && $object->origin_id > 0) {
59 $objectsrc = new CommandeFournisseur($db);
60 $objectsrc->fetch($object->origin_id);
61 }
62 $nbContact = count($objectsrc->liste_contact(-1, 'internal')) + count($objectsrc->liste_contact(-1, 'external'));
63 $head[$h][0] = DOL_URL_ROOT."/reception/contact.php?id=".$object->id;
64 $head[$h][1] = $langs->trans("ContactsAddresses");
65 if ($nbContact > 0) {
66 $head[$h][1] .= '<span class="badge marginleftonlyshort">'.$nbContact.'</span>';
67 }
68 $head[$h][2] = 'contact';
69 $h++;
70 }
71
72 // Show more tabs from modules
73 // Entries must be declared in modules descriptor with line
74 // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
75 // $this->tabs = array('entity:-tabname); to remove a tab
76 complete_head_from_modules($conf, $langs, $object, $head, $h, 'reception', 'add', 'core');
77
78 require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
79 require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php';
80 $upload_dir = $conf->reception->dir_output."/".dol_sanitizeFileName($object->ref);
81 $nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$'));
82 $nbLinks = Link::count($db, $object->element, $object->id);
83 $head[$h][0] = DOL_URL_ROOT.'/reception/document.php?id='.$object->id;
84 $head[$h][1] = $langs->trans('Documents');
85 if (($nbFiles + $nbLinks) > 0) {
86 $head[$h][1] .= '<span class="badge marginleftonlyshort">'.($nbFiles + $nbLinks).'</span>';
87 }
88 $head[$h][2] = 'documents';
89 $h++;
90
91 $nbNote = 0;
92 if (!empty($object->note_private)) {
93 $nbNote++;
94 }
95 if (!empty($object->note_public)) {
96 $nbNote++;
97 }
98 $head[$h][0] = DOL_URL_ROOT."/reception/note.php?id=".$object->id;
99 $head[$h][1] = $langs->trans("Notes");
100 if ($nbNote > 0) {
101 $head[$h][1] .= '<span class="badge marginleftonlyshort">'.$nbNote.'</span>';
102 }
103 $head[$h][2] = 'note';
104 $h++;
105
106 complete_head_from_modules($conf, $langs, $object, $head, $h, 'reception', 'add', 'external');
107
108 complete_head_from_modules($conf, $langs, $object, $head, $h, 'reception', 'remove');
109
110 return $head;
111}
112
119{
120 global $langs, $conf, $user, $db;
121 $langs->load("receptions");
122
123 $extrafields = new ExtraFields($db);
124 $extrafields->fetch_name_optionals_label('reception');
125 $extrafields->fetch_name_optionals_label('commande_fournisseur_dispatch');
126
127 $h = 0;
128 $head = array();
129
130 $head[$h][0] = DOL_URL_ROOT."/admin/reception_setup.php";
131 $head[$h][1] = $langs->trans("Reception");
132 $head[$h][2] = 'reception';
133 $h++;
134
135 complete_head_from_modules($conf, $langs, null, $head, $h, 'reception_admin');
136
137 if (!empty($conf->global->MAIN_SUBMODULE_RECEPTION)) {
138 $head[$h][0] = DOL_URL_ROOT.'/admin/reception_extrafields.php';
139 $head[$h][1] = $langs->trans("ExtraFields");
140 $nbExtrafields = $extrafields->attributes['reception']['count'];
141 if ($nbExtrafields > 0) {
142 $head[$h][1] .= '<span class="badge marginleftonlyshort">'.$nbExtrafields.'</span>';
143 }
144 $head[$h][2] = 'attributes_reception';
145 $h++;
146 }
147
148 if (!empty($conf->global->MAIN_SUBMODULE_RECEPTION)) {
149 $head[$h][0] = DOL_URL_ROOT.'/admin/commande_fournisseur_dispatch_extrafields.php';
150 $head[$h][1] = $langs->trans("ExtraFieldsLines");
151 $nbExtrafields = $extrafields->attributes['commande_fournisseur_dispatch']['count'];
152 if ($nbExtrafields > 0) {
153 $head[$h][1] .= '<span class="badge marginleftonlyshort">'.$nbExtrafields.'</span>';
154 }
155 $head[$h][2] = 'attributeslines_reception';
156 $h++;
157 }
158
159 complete_head_from_modules($conf, $langs, null, $head, $h, 'reception_admin', 'remove');
160
161 return $head;
162}
Class to manage predefined suppliers products.
Class to manage standard extra fields.
Class to manage receptions.
dol_dir_list($path, $types="all", $recursive=0, $filter="", $excludefilter=null, $sortcriteria="name", $sortorder=SORT_ASC, $mode=0, $nohook=0, $relativename="", $donotfollowsymlinks=0, $nbsecondsold=0)
Scan a directory and return a list of files/directories.
Definition files.lib.php:62
dol_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
complete_head_from_modules($conf, $langs, $object, &$head, &$h, $type, $mode='add', $filterorigmodule='')
Complete or removed entries into a head array (used to build tabs).
reception_admin_prepare_head()
Return array head with list of tabs to view object informations.
reception_prepare_head(Reception $object)
Prepare array with list of tabs.