dolibarr 21.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 MDW <mdeweerd@users.noreply.github.com>
6 * Copyright (C) 2024 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);
58if ($id > 0 || !empty($ref)) {
59 $object->fetch($id, $ref);
60 $object->fetch_thirdparty();
61
62 if (!empty($object->origin)) {
63 $origin = $object->origin;
64 $typeobject = $object->origin;
65
66 $object->fetch_origin();
67 }
68
69 // Linked documents
70 if ($origin == 'order_supplier' && $object->origin_object->id && isModEnabled("supplier_order")) {
71 $objectsrc = new CommandeFournisseur($db);
72 $objectsrc->fetch($object->origin_object->id);
73 }
74}
75
76// Security check
77if ($user->socid > 0) {
78 $socid = $user->socid;
79}
80
81// TODO Test on reception module on only
82if ($origin == 'reception') {
83 $result = restrictedArea($user, $origin, $object->id);
84} else {
85 if ($origin == 'supplierorder' || $origin == 'order_supplier') {
86 $result = restrictedArea($user, 'fournisseur', $object, 'commande_fournisseur', 'commande');
87 } elseif (!$user->hasRight($origin, 'lire') && !$user->hasRight($origin, 'read')) {
89 }
90}
91
92if (isModEnabled("reception")) {
93 $permissiontoread = $user->hasRight('reception', 'lire');
94 $permissiontoadd = $user->hasRight('reception', 'creer');
95 $permissiondellink = $user->hasRight('reception', 'creer'); // Used by the include of actions_dellink.inc.php
96 $permissiontovalidate = ((!getDolGlobalString('MAIN_USE_ADVANCED_PERMS') && $user->hasRight('reception', 'creer')) || (getDolGlobalString('MAIN_USE_ADVANCED_PERMS') && $user->hasRight('reception', 'reception_advance', 'validate')));
97 $permissiontodelete = $user->hasRight('reception', 'supprimer');
98} else {
99 $permissiontoread = $user->hasRight('fournisseur', 'commande', 'receptionner');
100 $permissiontoadd = $user->hasRight('fournisseur', 'commande', 'receptionner');
101 $permissiondellink = $user->hasRight('fournisseur', 'commande', 'receptionner'); // Used by the include of actions_dellink.inc.php
102 $permissiontovalidate = ((!getDolGlobalString('MAIN_USE_ADVANCED_PERMS') && $user->hasRight('fournisseur', 'commande', 'receptionner')) || (getDolGlobalString('MAIN_USE_ADVANCED_PERMS') && $user->hasRight('fournisseur', 'commande_advance', 'check')));
103 $permissiontodelete = $user->hasRight('fournisseur', 'commande', 'receptionner');
104}
105
106
107/*
108 * Actions
109 */
110
111if ($action == 'addcontact' && $user->hasRight('reception', 'creer')) {
112 if ($result > 0 && $id > 0) {
113 $contactid = (GETPOSTINT('userid') ? GETPOSTINT('userid') : GETPOSTINT('contactid'));
114 $typeid = (GETPOST('typecontact') ? GETPOST('typecontact') : GETPOST('type'));
115 $result = $objectsrc->add_contact($contactid, $typeid, GETPOST("source", 'aZ09'));
116 }
117
118 if ($result >= 0) {
119 header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id);
120 exit;
121 } else {
122 if ($objectsrc->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') {
123 $langs->load("errors");
124 $mesg = $langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType");
125 } else {
126 $mesg = $objectsrc->error;
127 $mesgs = $objectsrc->errors;
128 }
129 setEventMessages($mesg, $mesgs, 'errors');
130 }
131} elseif ($action == 'swapstatut' && $user->hasRight('reception', 'creer')) {
132 // bascule du statut d'un contact
133 $result = $objectsrc->swapContactStatus(GETPOSTINT('ligne'));
134} elseif ($action == 'deletecontact' && $user->hasRight('reception', 'creer')) {
135 // Efface un contact
136 $result = $objectsrc->delete_contact(GETPOSTINT("lineid"));
137
138 if ($result >= 0) {
139 header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id);
140 exit;
141 } else {
142 dol_print_error($db);
143 }
144}
145
146
147/*
148 * View
149 */
150
151$help_url = 'EN:Customers_Orders|FR:receptions_Clients|ES:Pedidos de clientes';
152llxHeader('', $langs->trans('Reception'), $help_url, '', 0, 0, '', '', '', 'mod-reception page-card_contact');
153
154$form = new Form($db);
155$formcompany = new FormCompany($db);
156$formother = new FormOther($db);
157$contactstatic = new Contact($db);
158$userstatic = new User($db);
159
160
161// View mode
162
163if ($id > 0 || !empty($ref)) {
164 $langs->trans("OrderCard");
165
166 $head = reception_prepare_head($object);
167 print dol_get_fiche_head($head, 'contact', $langs->trans("Reception"), -1, 'dollyrevert');
168
169
170 // Reception card
171 $linkback = '<a href="'.DOL_URL_ROOT.'/reception/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
172
173 $morehtmlref = '<div class="refidno">';
174 // Ref customer reception
175 $morehtmlref .= $form->editfieldkey("RefSupplier", '', $object->ref_supplier, $object, $user->hasRight('reception', 'creer'), 'string', '', 0, 1);
176 $morehtmlref .= $form->editfieldval("RefSupplier", '', $object->ref_supplier, $object, $user->hasRight('reception', 'creer'), 'string', '', null, null, '', 1);
177 // Thirdparty
178 $morehtmlref .= '<br>'.$object->thirdparty->getNomUrl(1);
179 // Project
180 if (isModEnabled('project')) {
181 $langs->load("projects");
182 $morehtmlref .= '<br>';
183 if (0) { // Do not change on reception
184 $morehtmlref .= img_picto($langs->trans("Project"), 'project', 'class="pictofixedwidth"');
185 if ($action != 'classify' && $permissiontoadd) {
186 $morehtmlref .= '<a class="editfielda" href="'.$_SERVER['PHP_SELF'].'?action=classify&token='.newToken().'&id='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('SetProject')).'</a> ';
187 }
188 $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');
189 } else {
190 if (!empty($objectsrc) && !empty($objectsrc->fk_project)) {
191 $proj = new Project($db);
192 $proj->fetch($objectsrc->fk_project);
193 $morehtmlref .= $proj->getNomUrl(1);
194 if ($proj->title) {
195 $morehtmlref .= '<span class="opacitymedium"> - '.dol_escape_htmltag($proj->title).'</span>';
196 }
197 }
198 }
199 }
200 $morehtmlref .= '</div>';
201
202 dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
203
204
205 print '<div class="fichecenter">';
206 //print '<div class="fichehalfleft">';
207 print '<div class="underbanner clearboth"></div>';
208
209 print '<table class="border centpercent tableforfield">';
210 // Linked documents
211 if ($origin == 'order_supplier' && $object->origin_object->id && isModEnabled("supplier_order")) {
212 print '<tr><td class="titlefield">';
213 $objectsrc = new CommandeFournisseur($db);
214 $objectsrc->fetch($object->origin_object->id);
215 print $langs->trans("RefOrder").'</td>';
216 print '<td colspan="3">';
217 print $objectsrc->getNomUrl(1, 'commande');
218 print "</td>\n";
219 print '</tr>';
220 }
221 if ($typeobject == 'propal' && $object->origin_object->id && isModEnabled("propal")) {
222 print '<tr><td class="titlefield">';
223 $objectsrc = new Propal($db);
224 $objectsrc->fetch($object->origin_object->id);
225 print $langs->trans("RefProposal").'</td>';
226 print '<td colspan="3">';
227 print $objectsrc->getNomUrl(1, 'reception');
228 print "</td>\n";
229 print '</tr>';
230 }
231
232 print "</table>";
233
234
235 //print '</div>';
236 //print '<div class="fichehalfright">';
237 //print '<div class="underbanner clearboth"></div>';
238
239
240 //print '</div>';
241 print '</div>';
242
243 print '<div class="clearboth"></div>';
244
245
246 print dol_get_fiche_end();
247
248 // Lines of contacts
249 echo '<br>';
250
251 // Contacts lines (modules that overwrite templates must declare this into descriptor)
252 $dirtpls = array_merge($conf->modules_parts['tpl'], array('/core/tpl'));
253 foreach ($dirtpls as $reldir) {
254 $res = @include dol_buildpath($reldir.'/contacts.tpl.php');
255 if ($res) {
256 break;
257 }
258 }
259}
260
261llxFooter();
262
263$db->close();
$id
Definition account.php:48
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
Definition card.php:66
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:71
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 permettant la generation de composants html autre Only common components are here.
Class to manage projects.
Class to manage proposals.
Class to manage receptions.
Class to manage Dolibarr users.
llxFooter()
Footer empty.
Definition document.php:107
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)
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.
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.
img_edit($titlealt='default', $float=0, $other='')
Show logo edit/modify fiche.
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
Definition member.php:79
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.