dolibarr 20.0.0
note.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3 * Copyright (C) 2004-2008 Laurent Destailleur <eldy@users.sourceforge.net>
4 * Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com>
5 * Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro>
6 * Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
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 */
21
28// Load Dolibarr environment
29require '../main.inc.php';
30require_once DOL_DOCUMENT_ROOT.'/reception/class/reception.class.php';
31require_once DOL_DOCUMENT_ROOT.'/core/lib/reception.lib.php';
32if (isModEnabled('project')) {
33 require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
34 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php';
35}
36require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php';
37require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.dispatch.class.php';
38
39$langs->loadLangs(array("receptions", "companies", "bills", 'deliveries', 'orders', 'stocks', 'other', 'propal'));
40
41$id = (GETPOSTINT('id') ? GETPOSTINT('id') : GETPOSTINT('facid')); // For backward compatibility
42$ref = GETPOST('ref', 'alpha');
43$action = GETPOST('action', 'aZ09');
44
45$object = new Reception($db);
46if ($id > 0 || !empty($ref)) {
47 $object->fetch($id, $ref);
48 $object->fetch_thirdparty();
49
50 if (!empty($object->origin)) {
51 $origin = $object->origin;
52 $typeobject = $object->origin;
53
54 $object->fetch_origin();
55 }
56
57 // Linked documents
58 if ($origin == 'order_supplier' && $object->origin_object->id && isModEnabled("supplier_order")) {
59 $objectsrc = new CommandeFournisseur($db);
60 $objectsrc->fetch($object->origin_object->id);
61 }
62}
63
64// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
65$hookmanager->initHooks(array('receptionnote'));
66
67// Security check
68if ($user->socid > 0) {
69 $socid = $user->socid;
70}
71
72if (isModEnabled("reception")) {
73 $permissiontoread = $user->hasRight('reception', 'lire');
74 $permissiontoadd = $user->hasRight('reception', 'creer');
75 $permissiondellink = $user->hasRight('reception', 'creer'); // Used by the include of actions_dellink.inc.php
76 $permissiontovalidate = ((!getDolGlobalString('MAIN_USE_ADVANCED_PERMS') && $user->hasRight('reception', 'creer')) || (getDolGlobalString('MAIN_USE_ADVANCED_PERMS') && $user->hasRight('reception', 'reception_advance', 'validate')));
77 $permissiontodelete = $user->hasRight('reception', 'supprimer');
78} else {
79 $permissiontoread = $user->hasRight('fournisseur', 'commande', 'receptionner');
80 $permissiontoadd = $user->hasRight('fournisseur', 'commande', 'receptionner');
81 $permissiondellink = $user->hasRight('fournisseur', 'commande', 'receptionner'); // Used by the include of actions_dellink.inc.php
82 $permissiontovalidate = ((!getDolGlobalString('MAIN_USE_ADVANCED_PERMS') && $user->hasRight('fournisseur', 'commande', 'receptionner')) || (getDolGlobalString('MAIN_USE_ADVANCED_PERMS') && $user->hasRight('fournisseur', 'commande_advance', 'check')));
83 $permissiontodelete = $user->hasRight('fournisseur', 'commande', 'receptionner');
84}
85$permissionnote = $user->hasRight('reception', 'creer'); // Used by the include of actions_setnotes.inc.php
86
87// TODO Test on reception module on only
88if ($origin == 'reception') {
89 $result = restrictedArea($user, $origin, $object->id);
90} else {
91 if ($origin == 'supplierorder' || $origin == 'order_supplier') {
92 $result = restrictedArea($user, 'fournisseur', $object, 'commande_fournisseur', 'commande');
93 } elseif (!$user->hasRight($origin, 'lire') && !$user->hasRight($origin, 'read')) {
95 }
96}
97
98
99/*
100 * Actions
101 */
102
103$parameters = array();
104$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
105if ($reshook < 0) {
106 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
107}
108if (empty($reshook)) {
109 include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, not include_once
110}
111
112
113/*
114 * View
115 */
116
117llxHeader('', $langs->trans('Reception'), '', '', 0, 0, $morejs, '', '', 'mod-reception page-card_notes');
118
119$form = new Form($db);
120
121if ($id > 0 || !empty($ref)) {
122 $head = reception_prepare_head($object);
123 print dol_get_fiche_head($head, 'note', $langs->trans("Reception"), -1, 'dollyrevert');
124
125
126 // Reception card
127 $linkback = '<a href="'.DOL_URL_ROOT.'/reception/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
128
129 $morehtmlref = '<div class="refidno">';
130 // Ref customer reception
131 $morehtmlref .= $form->editfieldkey("RefSupplier", '', $object->ref_supplier, $object, $user->hasRight('reception', 'creer'), 'string', '', 0, 1);
132 $morehtmlref .= $form->editfieldval("RefSupplier", '', $object->ref_supplier, $object, $user->hasRight('reception', 'creer'), 'string', '', null, null, '', 1);
133 // Thirdparty
134 $morehtmlref .= '<br>'.$object->thirdparty->getNomUrl(1);
135 // Project
136 if (isModEnabled('project')) {
137 $langs->load("projects");
138 $morehtmlref .= '<br>';
139 if (0) { // Do not change on reception
140 $morehtmlref .= img_picto($langs->trans("Project"), 'project', 'class="pictofixedwidth"');
141 if ($action != 'classify' && $permissiontoadd) {
142 $morehtmlref .= '<a class="editfielda" href="'.$_SERVER['PHP_SELF'].'?action=classify&token='.newToken().'&id='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('SetProject')).'</a> ';
143 }
144 $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, (!getDolGlobalString('PROJECT_CAN_ALWAYS_LINK_TO_ALL_SUPPLIERS') ? $object->socid : -1), $object->fk_project, ($action == 'classify' ? 'projectid' : 'none'), 0, 0, 0, 1, '', 'maxwidth300');
145 } else {
146 if (!empty($objectsrc) && !empty($objectsrc->fk_project)) {
147 $proj = new Project($db);
148 $proj->fetch($objectsrc->fk_project);
149 $morehtmlref .= $proj->getNomUrl(1);
150 if ($proj->title) {
151 $morehtmlref .= '<span class="opacitymedium"> - '.dol_escape_htmltag($proj->title).'</span>';
152 }
153 }
154 }
155 }
156 $morehtmlref .= '</div>';
157
158 dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
159
160
161 print '<div class="underbanner clearboth"></div>';
162
163 $cssclass = 'titlefield';
164 include DOL_DOCUMENT_ROOT.'/core/tpl/notes.tpl.php';
165
166 print dol_get_fiche_end();
167}
168
169
170llxFooter();
171
172$db->close();
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
Definition card.php:58
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader()
Empty header.
Definition wrapper.php:55
llxFooter()
Empty footer.
Definition wrapper.php:69
Class to manage predefined suppliers products.
Class to manage generation of HTML components Only common components must be here.
Class to manage projects.
Class to manage receptions.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0)
Show tabs of a record.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
newToken()
Return the value of token currently saved into session with name 'newtoken'.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
img_edit($titlealt='default', $float=0, $other='')
Show logo edit/modify fiche.
reception_prepare_head(Reception $object)
Prepare array with list of tabs.
restrictedArea(User $user, $features, $object=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $mode=0)
Check permissions of a user to show a page and an object.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.