dolibarr 24.0.0-beta
contact.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2005 Patrick Rouillon <patrick@rouillon.net>
3 * Copyright (C) 2005-2011 Laurent Destailleur <eldy@users.sourceforge.net>
4 * Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com>
5 * Copyright (C) 2024-2026 MDW <mdeweerd@users.noreply.github.com>
6 * Copyright (C) 2024-2025 Frédéric France <frederic.france@free.fr>
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.'/fourn/class/fournisseur.commande.class.php';
32require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
33require_once DOL_DOCUMENT_ROOT.'/core/lib/reception.lib.php';
34require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
35require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
36if (isModEnabled('project')) {
37 require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
38 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php';
39}
40require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php';
41require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.dispatch.class.php';
42
51$langs->loadLangs(array("orders", "receptions", "companies"));
52
53$id = GETPOSTINT('id');
54$ref = GETPOST('ref', 'alpha');
55$action = GETPOST('action', 'aZ09');
56
57$object = new Reception($db);
58$typeobject = '';
59$origin = '';
60$objectsrc = null;
61if ($id > 0 || !empty($ref)) {
62 $object->fetch($id, $ref);
63 $object->fetch_thirdparty();
64
65 if (!empty($object->origin)) {
66 $origin = (string) $object->origin;
67 $typeobject = $object->origin;
68
69 $object->fetch_origin();
70 }
71
72 // Linked documents
73 if ($origin == 'order_supplier' && $object->origin_object->id && isModEnabled("supplier_order")) {
74 $objectsrc = new CommandeFournisseur($db);
75 $objectsrc->fetch($object->origin_object->id);
76 }
77}
78
79// Security check
80if ($user->socid > 0) {
81 $socid = $user->socid;
82}
83
84// TODO Test on reception module on only
85$result = -1;
86if (isModEnabled("reception") || $origin == 'reception' || empty($origin)) {
87 $result = restrictedArea($user, 'reception', $object->id);
88} else {
89 if ($origin == 'supplierorder' || $origin == 'order_supplier') {
90 $result = restrictedArea($user, 'fournisseur', $object->origin_id, 'commande_fournisseur', 'commande');
91 } elseif (!$user->hasRight($origin, 'lire') && !$user->hasRight($origin, 'read')) {
93 }
94}
95
96if (isModEnabled("reception")) {
97 $permissiontoread = $user->hasRight('reception', 'lire');
98 $permissiontoadd = $user->hasRight('reception', 'creer');
99 $permissiondellink = $user->hasRight('reception', 'creer'); // Used by the include of actions_dellink.inc.php
100 $permissiontovalidate = ((!getDolGlobalString('MAIN_USE_ADVANCED_PERMS') && $user->hasRight('reception', 'creer')) || (getDolGlobalString('MAIN_USE_ADVANCED_PERMS') && $user->hasRight('reception', 'reception_advance', 'validate')));
101 $permissiontodelete = $user->hasRight('reception', 'supprimer');
102} else {
103 $permissiontoread = $user->hasRight('fournisseur', 'commande', 'receptionner');
104 $permissiontoadd = $user->hasRight('fournisseur', 'commande', 'receptionner');
105 $permissiondellink = $user->hasRight('fournisseur', 'commande', 'receptionner'); // Used by the include of actions_dellink.inc.php
106 $permissiontovalidate = ((!getDolGlobalString('MAIN_USE_ADVANCED_PERMS') && $user->hasRight('fournisseur', 'commande', 'receptionner')) || (getDolGlobalString('MAIN_USE_ADVANCED_PERMS') && $user->hasRight('fournisseur', 'commande_advance', 'check')));
107 $permissiontodelete = $user->hasRight('fournisseur', 'commande', 'receptionner');
108}
109
110
111/*
112 * Actions
113 */
114
115if ($action == 'addcontact' && $user->hasRight('reception', 'creer')) {
116 if ($result > 0 && $id > 0) {
117 $contactid = (GETPOSTINT('userid') ? GETPOSTINT('userid') : GETPOSTINT('contactid'));
118 $typeid = (GETPOST('typecontact') ? GETPOST('typecontact') : GETPOST('type'));
119 $result = $objectsrc->add_contact($contactid, $typeid, GETPOST("source", 'aZ09'));
120 }
121
122 if ($result >= 0) {
123 header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id);
124 exit;
125 } elseif ($objectsrc !== null) {
126 $mesgs = array();
127 if ($objectsrc->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') {
128 $langs->load("errors");
129 $mesg = $langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType");
130 } else {
131 $mesg = $objectsrc->error;
132 $mesgs = $objectsrc->errors;
133 }
134 setEventMessages($mesg, $mesgs, 'errors');
135 }
136} elseif ($action == 'swapstatut' && $user->hasRight('reception', 'creer') && $objectsrc !== null) {
137 // bascule du statut d'un contact
138 $result = $objectsrc->swapContactStatus(GETPOSTINT('ligne'));
139} elseif ($action == 'deletecontact' && $user->hasRight('reception', 'creer') && $objectsrc !== null) {
140 // Efface un contact
141 $result = $objectsrc->delete_contact(GETPOSTINT("lineid"));
142
143 if ($result >= 0) {
144 header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id);
145 exit;
146 } else {
148 }
149}
150
151
152/*
153 * View
154 */
155
156$help_url = 'EN:Customers_Orders|FR:receptions_Clients|ES:Pedidos de clientes';
157llxHeader('', $langs->trans('Reception'), $help_url, '', 0, 0, '', '', '', 'mod-reception page-card_contact');
158
159$form = new Form($db);
160$formcompany = new FormCompany($db);
161$formother = new FormOther($db);
162$contactstatic = new Contact($db);
163$userstatic = new User($db);
164
165
166// View mode
167
168if ($id > 0 || !empty($ref)) {
169 $langs->trans("OrderCard");
170
171 $head = reception_prepare_head($object);
172 print dol_get_fiche_head($head, 'contact', $langs->trans("Reception"), -1, 'dollyrevert');
173
174
175 // Reception card
176 $linkback = '<a href="'.DOL_URL_ROOT.'/reception/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
177
178 $morehtmlref = '<div class="refidno">';
179 // Ref customer reception
180 $morehtmlref .= $form->editfieldkey("RefSupplier", '', $object->ref_supplier, $object, $user->hasRight('reception', 'creer'), 'string', '', 0, 1);
181 $morehtmlref .= $form->editfieldval("RefSupplier", '', $object->ref_supplier, $object, $user->hasRight('reception', 'creer'), 'string', '', null, null, '', 1);
182 // Thirdparty
183 $morehtmlref .= '<br>'.$object->thirdparty->getNomUrl(1);
184 // Project
185 if (isModEnabled('project')) {
186 $langs->load("projects");
187 $morehtmlref .= '<br>';
188 if (0) { // @phpstan-ignore-line Do not change on reception
189 $morehtmlref .= img_picto($langs->trans("Project"), 'project', 'class="pictofixedwidth"');
190 if ($action != 'classify' && $permissiontoadd) {
191 $morehtmlref .= '<a class="editfielda" href="'.dolBuildUrl($_SERVER['PHP_SELF'], ['action' => 'classify', 'id' => $object->id], true).'">'.img_edit($langs->transnoentitiesnoconv('SetProject')).'</a> ';
192 }
193 $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, (!getDolGlobalString('PROJECT_CAN_ALWAYS_LINK_TO_ALL_SUPPLIERS') ? $object->socid : -1), (string) $object->fk_project, ($action == 'classify' ? 'projectid' : 'none'), 0, 0, 0, 1, '', 'maxwidth300');
194 } else {
195 if ($objectsrc !== null && !empty($objectsrc->fk_project)) {
196 $proj = new Project($db);
197 $proj->fetch($objectsrc->fk_project);
198 $morehtmlref .= $proj->getNomUrl(1);
199 if ($proj->title) {
200 $morehtmlref .= '<span class="opacitymedium"> - '.dol_escape_htmltag($proj->title).'</span>';
201 }
202 }
203 }
204 }
205 $morehtmlref .= '</div>';
206
207 dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
208
209
210 print '<div class="fichecenter">';
211 //print '<div class="fichehalfleft">';
212 print '<div class="underbanner clearboth"></div>';
213
214 print '<table class="border centpercent tableforfield">';
215 // Linked documents
216 if ($origin == 'order_supplier' && $object->origin_object->id && isModEnabled("supplier_order")) {
217 print '<tr><td class="titlefield">';
218 $objectsrc = new CommandeFournisseur($db);
219 $objectsrc->fetch($object->origin_object->id);
220 print $langs->trans("RefOrder").'</td>';
221 print '<td colspan="3">';
222 print $objectsrc->getNomUrl(1, 'commande');
223 print "</td>\n";
224 print '</tr>';
225 }
226 if ($typeobject == 'propal' && $object->origin_object->id && isModEnabled("propal")) {
227 print '<tr><td class="titlefield">';
228 $objectsrc = new Propal($db);
229 $objectsrc->fetch($object->origin_object->id);
230 print $langs->trans("RefProposal").'</td>';
231 print '<td colspan="3">';
232 print $objectsrc->getNomUrl(1, 'reception');
233 print "</td>\n";
234 print '</tr>';
235 }
236
237 print "</table>";
238
239
240 //print '</div>';
241 //print '<div class="fichehalfright">';
242 //print '<div class="underbanner clearboth"></div>';
243
244
245 //print '</div>';
246 print '</div>';
247
248 print '<div class="clearboth"></div>';
249
250
251 print dol_get_fiche_end();
252
253 // Lines of contacts
254 echo '<br>';
255
256 // Contacts lines (modules that overwrite templates must declare this into descriptor)
257 $dirtpls = array_merge($conf->modules_parts['tpl'], array('/core/tpl'));
258 foreach ($dirtpls as $reldir) {
259 $file = dol_buildpath($reldir.'/contacts.tpl.php');
260 if (file_exists($file)) {
261 $res = @include $file;
262 if ($res) {
263 break;
264 }
265 }
266 }
267}
268
269llxFooter();
270
271$db->close();
$id
Support class for third parties, contacts, members, users or resources.
Definition account.php:47
if(! $sortfield) if(! $sortorder) $object
Definition account.php:100
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
Definition wrapper.php:91
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
Definition wrapper.php:73
Class to manage predefined suppliers products.
Class to manage contact/addresses.
Class to build HTML component for third parties management Only common components are here.
Class to manage generation of HTML components Only common components must be here.
Class to help generate other html components Only common components are here.
Class to manage projects.
Class to manage proposals.
Class to manage receptions.
Class to manage Dolibarr users.
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $conf
The main.inc.php has been included so the following variable are now defined:
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $db
API class for accounts.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2, $allowothertags=array())
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, $morecssdiv='')
Show tabs of a record.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
img_edit($titlealt='default', $float=0, $other='')
Show logo edit/modify fiche.
print $langs trans("Show") . '< td style="' . $timeColor . '" align="center"> s</td > badge status0 badge status4 badge status3 Error badge status8< td align="center">< span class="badge ' . $badge . '"></span ></td >< td align="center">< a href="#" class="button button-small" onclick="openLogModal(this)" data-req="' . dol_escape_htmltag($reqSafe) . '" data-res="' . dol_escape_htmltag($resSafe) . '" data-err="' . dol_escape_htmltag($errSafe) . '">< span class="fa fa-search-plus"></span ></a ></td ></tr >< tr >< td colspan="' . $colspan . '" class="opacitymedium"></td ></tr ></table ></div ></form > logModal none logModal none s a JSON string
buildzip.php
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.