dolibarr  16.0.5
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  *
7  * This program is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program. If not, see <https://www.gnu.org/licenses/>.
19  */
20 
27 require '../main.inc.php';
28 require_once DOL_DOCUMENT_ROOT.'/reception/class/reception.class.php';
29 require_once DOL_DOCUMENT_ROOT.'/core/lib/reception.lib.php';
30 dol_include_once('/fourn/class/fournisseur.commande.class.php');
31 if (!empty($conf->project->enabled)) {
32  require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
33  require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php';
34 }
35 
36 $langs->loadLangs(array("receptions", "companies", "bills", 'deliveries', 'orders', 'stocks', 'other', 'propal'));
37 
38 $id = (GETPOST('id', 'int') ?GETPOST('id', 'int') : GETPOST('facid', 'int')); // For backward compatibility
39 $ref = GETPOST('ref', 'alpha');
40 $action = GETPOST('action', 'aZ09');
41 
42 $object = new Reception($db);
43 if ($id > 0 || !empty($ref)) {
44  $object->fetch($id, $ref);
45  $object->fetch_thirdparty();
46 
47  if (!empty($object->origin)) {
48  $typeobject = $object->origin;
49  $origin = $object->origin;
50  $object->fetch_origin();
51  }
52 
53  // Linked documents
54  if ($typeobject == 'commande' && $object->$typeobject->id && !empty($conf->commande->enabled)) {
55  $objectsrc = new Commande($db);
56  $objectsrc->fetch($object->$typeobject->id);
57  }
58  if ($typeobject == 'propal' && $object->$typeobject->id && !empty($conf->propal->enabled)) {
59  $objectsrc = new Propal($db);
60  $objectsrc->fetch($object->$typeobject->id);
61  }
62 }
63 
64 $permissionnote = $user->rights->reception->creer; // Used by the include of actions_setnotes.inc.php
65 
66 // Security check
67 if ($user->socid > 0) {
68  $socid = $user->socid;
69 }
70 
71 
72 // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
73 $hookmanager->initHooks(array('receptionnote'));
74 
75 if ($origin == 'reception') {
76  $result = restrictedArea($user, $origin, $object->id);
77 } else {
78  if ($origin == 'reception') {
79  $result = restrictedArea($user, $origin, $object->id);
80  } else {
81  if ($origin == 'supplierorder' || $origin == 'order_supplier') {
82  $result = restrictedArea($user, 'fournisseur', $origin_id, 'commande_fournisseur', 'commande');
83  } elseif (empty($user->rights->{$origin}->lire) && empty($user->rights->{$origin}->read)) {
85  }
86  }
87 }
88 
89 
90 
91 /*
92  * Actions
93  */
94 
95 $reshook = $hookmanager->executeHooks('doActions', array(), $object, $action); // Note that $action and $object may have been modified by some hooks
96 if ($reshook < 0) {
97  setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
98 }
99 if (empty($reshook)) {
100  include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, not include_once
101 }
102 
103 
104 /*
105  * View
106  */
107 
108 llxHeader('', 'Reception');
109 
110 $form = new Form($db);
111 
112 if ($id > 0 || !empty($ref)) {
113  $head = reception_prepare_head($object);
114  print dol_get_fiche_head($head, 'note', $langs->trans("Reception"), -1, 'dollyrevert');
115 
116 
117  // Reception card
118  $linkback = '<a href="'.DOL_URL_ROOT.'/reception/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
119 
120  $morehtmlref = '<div class="refidno">';
121  // Ref customer reception
122  $morehtmlref .= $form->editfieldkey("RefSupplier", '', $object->ref_supplier, $object, $user->rights->reception->creer, 'string', '', 0, 1);
123  $morehtmlref .= $form->editfieldval("RefSupplier", '', $object->ref_supplier, $object, $user->rights->reception->creer, 'string', '', null, null, '', 1);
124  // Thirdparty
125  $morehtmlref .= '<br>'.$langs->trans('ThirdParty').' : '.$object->thirdparty->getNomUrl(1);
126  // Project
127  if (!empty($conf->project->enabled)) {
128  $langs->load("projects");
129  $morehtmlref .= '<br>'.$langs->trans('Project').' ';
130  if (0) { // Do not change on reception
131  if ($action != 'classify') {
132  $morehtmlref .= '<a class="editfielda" href="'.$_SERVER['PHP_SELF'].'?action=classify&token='.newToken().'&id='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('SetProject')).'</a> : ';
133  }
134  if ($action == 'classify') {
135  // $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1);
136  $morehtmlref .= '<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">';
137  $morehtmlref .= '<input type="hidden" name="action" value="classin">';
138  $morehtmlref .= '<input type="hidden" name="token" value="'.newToken().'">';
139  $morehtmlref .= $formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1);
140  $morehtmlref .= '<input type="submit" class="button button-edit" value="'.$langs->trans("Modify").'">';
141  $morehtmlref .= '</form>';
142  } else {
143  $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1);
144  }
145  } else {
146  // We don't have project on reception, so we will use the project or source object instead
147  // TODO Add project on reception
148  $morehtmlref .= ' : ';
149  if (!empty($objectsrc->fk_project)) {
150  $proj = new Project($db);
151  $proj->fetch($objectsrc->fk_project);
152  $morehtmlref .= ' : '.$proj->getNomUrl(1);
153  if ($proj->title) {
154  $morehtmlref .= ' - '.$proj->title;
155  }
156  } else {
157  $morehtmlref .= '';
158  }
159  }
160  }
161  $morehtmlref .= '</div>';
162 
163  dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
164 
165 
166  print '<div class="underbanner clearboth"></div>';
167 
168  $cssclass = 'titlefield';
169  include DOL_DOCUMENT_ROOT.'/core/tpl/notes.tpl.php';
170 
171  print dol_get_fiche_end();
172 }
173 
174 
175 llxFooter();
176 
177 $db->close();
Reception
Class to manage receptions.
Definition: reception.class.php:49
restrictedArea
restrictedArea($user, $features, $objectid=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.
Definition: security.lib.php:234
llxFooter
llxFooter()
Empty footer.
Definition: wrapper.php:73
Project
Class to manage projects.
Definition: project.class.php:35
GETPOST
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
Definition: functions.lib.php:484
dol_include_once
if(!function_exists('dol_getprefix')) dol_include_once($relpath, $classname='')
Make an include_once using default root and alternate root if it fails.
Definition: functions.lib.php:1033
$form
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
Definition: card.php:142
img_edit
img_edit($titlealt='default', $float=0, $other='')
Show logo editer/modifier fiche.
Definition: functions.lib.php:4389
dol_banner_tab
dol_banner_tab($object, $paramid, $morehtml='', $shownav=1, $fieldid='rowid', $fieldref='ref', $morehtmlref='', $moreparam='', $nodbprefix=0, $morehtmlleft='', $morehtmlstatus='', $onlybanner=0, $morehtmlright='')
Show tab footer of a card.
Definition: functions.lib.php:2046
Commande
Class to manage customers orders.
Definition: commande.class.php:46
dol_get_fiche_head
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='')
Show tabs of a record.
Definition: functions.lib.php:1822
newToken
newToken()
Return the value of token currently saved into session with name 'newtoken'.
Definition: functions.lib.php:10878
dol_get_fiche_end
dol_get_fiche_end($notab=0)
Return tab footer of a card.
Definition: functions.lib.php:2018
reception_prepare_head
reception_prepare_head(Reception $object)
Prepare array with list of tabs.
Definition: reception.lib.php:35
Form
Class to manage generation of HTML components Only common components must be here.
Definition: html.form.class.php:52
setEventMessages
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='')
Set event messages in dol_events session object.
Definition: functions.lib.php:8137
accessforbidden
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program Calling this function terminate execution ...
Definition: security.lib.php:933
Propal
Class to manage proposals.
Definition: propal.class.php:52
llxHeader
if(!defined('NOREQUIRESOC')) if(!defined('NOREQUIRETRAN')) if(!defined('NOCSRFCHECK')) if(!defined('NOTOKENRENEWAL')) if(!defined('NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) llxHeader()
Empty header.
Definition: wrapper.php:59