dolibarr 21.0.0-beta
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 * Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 3 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program. If not, see <https://www.gnu.org/licenses/>.
21 * or see https://www.gnu.org/
22 */
23
37{
38 global $db, $langs, $conf, $user;
39
40 $langs->loadLangs(array("sendings", "deliveries"));
41
42 $h = 0;
43 $head = array();
44
45 $head[$h][0] = DOL_URL_ROOT."/reception/card.php?id=".$object->id;
46 $head[$h][1] = $langs->trans("ReceptionCard");
47 $head[$h][2] = 'reception';
48 $h++;
49
50 if ($object->statut == Reception::STATUS_DRAFT || ($object->statut == Reception::STATUS_VALIDATED && !getDolGlobalString('STOCK_CALCULATE_ON_RECEPTION'))) {
51 $head[$h][0] = DOL_URL_ROOT."/reception/dispatch.php?id=".$object->id;
52 $head[$h][1] = $langs->trans("ReceptionDistribution");
53 $head[$h][2] = 'dispatch';
54 $h++;
55 }
56
57 if (!getDolGlobalString('MAIN_DISABLE_CONTACTS_TAB')) {
58 $objectsrc = $object;
59 if ($object->origin == 'supplier_order' && $object->origin_id > 0) {
60 $objectsrc = new CommandeFournisseur($db);
61 $objectsrc->fetch($object->origin_id);
62 }
63 $nbContact = count($objectsrc->liste_contact(-1, 'internal')) + count($objectsrc->liste_contact(-1, 'external'));
64 $head[$h][0] = DOL_URL_ROOT."/reception/contact.php?id=".$object->id;
65 $head[$h][1] = $langs->trans("ContactsAddresses");
66 if ($nbContact > 0) {
67 $head[$h][1] .= '<span class="badge marginleftonlyshort">'.$nbContact.'</span>';
68 }
69 $head[$h][2] = 'contact';
70 $h++;
71 }
72
73 // Show more tabs from modules
74 // Entries must be declared in modules descriptor with line
75 // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
76 // $this->tabs = array('entity:-tabname); to remove a tab
77 complete_head_from_modules($conf, $langs, $object, $head, $h, 'reception', 'add', 'core');
78
79 require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
80 require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php';
81 $upload_dir = $conf->reception->dir_output."/".dol_sanitizeFileName($object->ref);
82 $nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$'));
83 $nbLinks = Link::count($db, $object->element, $object->id);
84 $head[$h][0] = DOL_URL_ROOT.'/reception/document.php?id='.$object->id;
85 $head[$h][1] = $langs->trans('Documents');
86 if (($nbFiles + $nbLinks) > 0) {
87 $head[$h][1] .= '<span class="badge marginleftonlyshort">'.($nbFiles + $nbLinks).'</span>';
88 }
89 $head[$h][2] = 'documents';
90 $h++;
91
92 $nbNote = 0;
93 if (!empty($object->note_private)) {
94 $nbNote++;
95 }
96 if (!empty($object->note_public)) {
97 $nbNote++;
98 }
99 $head[$h][0] = DOL_URL_ROOT."/reception/note.php?id=".$object->id;
100 $head[$h][1] = $langs->trans("Notes");
101 if ($nbNote > 0) {
102 $head[$h][1] .= '<span class="badge marginleftonlyshort">'.$nbNote.'</span>';
103 }
104 $head[$h][2] = 'note';
105 $h++;
106
107 complete_head_from_modules($conf, $langs, $object, $head, $h, 'reception', 'add', 'external');
108
109 complete_head_from_modules($conf, $langs, $object, $head, $h, 'reception', 'remove');
110
111 return $head;
112}
113
120{
121 global $langs, $conf, $user, $db;
122 $langs->load("receptions");
123
124 $extrafields = new ExtraFields($db);
125 $extrafields->fetch_name_optionals_label('reception');
126 $extrafields->fetch_name_optionals_label('receptiondet_batch');
127
128 $h = 0;
129 $head = array();
130
131 $head[$h][0] = DOL_URL_ROOT."/admin/reception_setup.php";
132 $head[$h][1] = $langs->trans("Reception");
133 $head[$h][2] = 'reception';
134 $h++;
135
136 complete_head_from_modules($conf, $langs, null, $head, $h, 'reception_admin');
137
138 if (getDolGlobalString('MAIN_SUBMODULE_RECEPTION')) {
139 $head[$h][0] = DOL_URL_ROOT.'/admin/reception_extrafields.php';
140 $head[$h][1] = $langs->trans("ExtraFields");
141 $nbExtrafields = $extrafields->attributes['reception']['count'];
142 if ($nbExtrafields > 0) {
143 $head[$h][1] .= '<span class="badge marginleftonlyshort">'.$nbExtrafields.'</span>';
144 }
145 $head[$h][2] = 'attributes_reception';
146 $h++;
147 }
148
149 if (getDolGlobalString('MAIN_SUBMODULE_RECEPTION')) {
150 $head[$h][0] = DOL_URL_ROOT.'/admin/receptiondet_batch_extrafields.php';
151 $head[$h][1] = $langs->trans("ExtraFieldsLines");
152 $nbExtrafields = $extrafields->attributes['receptiondet_batch']['count'];
153 if ($nbExtrafields > 0) {
154 $head[$h][1] .= '<span class="badge marginleftonlyshort">'.$nbExtrafields.'</span>';
155 }
156 $head[$h][2] = 'attributeslines_reception';
157 $h++;
158 }
159
160 complete_head_from_modules($conf, $langs, null, $head, $h, 'reception_admin', 'remove');
161
162 return $head;
163}
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
Definition card.php:66
Class to manage predefined suppliers products.
Class to manage standard extra fields.
Class to manage receptions.
dol_dir_list($utf8_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:63
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).
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
Definition member.php:79
reception_admin_prepare_head()
Return array head with list of tabs to view object information.
reception_prepare_head(Reception $object)
Prepare array with list of tabs.