dolibarr 19.0.4
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@inodbox.com>
5 * Copyright (C) 2023 Christian Foellmann <christian@foellmann.de>
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// Load Dolibarr environment
28require '../main.inc.php';
29require_once DOL_DOCUMENT_ROOT.'/expedition/class/expedition.class.php';
30require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
31require_once DOL_DOCUMENT_ROOT.'/core/lib/sendings.lib.php';
32require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
33require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
34if (isModEnabled('project')) {
35 require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
36 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php';
37}
38
39// Load translation files required by the page
40$langs->loadLangs(array('orders', 'sendings', 'companies'));
41
42$id = GETPOST('id', 'int');
43$ref = GETPOST('ref', 'alpha');
44$action = GETPOST('action', 'aZ09');
45
46$object = new Expedition($db);
47if ($id > 0 || !empty($ref)) {
48 $object->fetch($id, $ref);
49 $object->fetch_thirdparty();
50
51 if (!empty($object->origin)) {
52 $typeobject = $object->origin;
53 $origin = $object->origin;
54 $object->fetch_origin();
55 }
56
57 // Linked documents
58 if ($typeobject == 'commande' && $object->$typeobject->id && isModEnabled('commande')) {
59 $objectsrc = new Commande($db);
60 $objectsrc->fetch($object->$typeobject->id);
61 }
62 if ($typeobject == 'propal' && $object->$typeobject->id && isModEnabled("propal")) {
63 $objectsrc = new Propal($db);
64 $objectsrc->fetch($object->$typeobject->id);
65 }
66}
67
68// Security check
69if ($user->socid) {
70 $socid = $user->socid;
71}
72$result = restrictedArea($user, 'expedition', $object->id, '');
73$hookmanager->initHooks(array('shipmentcontactcard', 'globalcard'));
74
75/*
76 * Actions
77 */
78
79$parameters = array('id'=>$id);
80$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action);
81if ($reshook < 0) {
82 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
83}
84
85if (empty($reshook)) {
86 if ($action == 'addcontact' && $user->hasRight('expedition', 'creer')) {
87 if ($result > 0 && $id > 0) {
88 $contactid = (GETPOST('userid', 'int') ? GETPOST('userid', 'int') : GETPOST('contactid', 'int'));
89 $typeid = (GETPOST('typecontact') ? GETPOST('typecontact') : GETPOST('type'));
90 $result = $objectsrc->add_contact($contactid, $typeid, GETPOST("source", 'aZ09'));
91 }
92
93 if ($result >= 0) {
94 header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id);
95 exit;
96 } else {
97 if ($objectsrc->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') {
98 $langs->load("errors");
99 $mesg = $langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType");
100 } else {
101 $mesg = $objectsrc->error;
102 $mesgs = $objectsrc->errors;
103 }
104 setEventMessages($mesg, $mesgs, 'errors');
105 }
106 } elseif ($action == 'swapstatut' && $user->hasRight('expedition', 'creer')) {
107 // bascule du statut d'un contact
108 $result = $objectsrc->swapContactStatus(GETPOST('ligne', 'int'));
109 } elseif ($action == 'deletecontact' && $user->hasRight('expedition', 'creer')) {
110 // Efface un contact
111 $result = $objectsrc->delete_contact(GETPOST("lineid", 'int'));
112
113 if ($result >= 0) {
114 header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id);
115 exit;
116 } else {
117 dol_print_error($db);
118 }
119 }
120}
121
122/*
123 * View
124 */
125
126
127$help_url = 'EN:Module_Shipments|FR:Module_Expéditions|ES:M&oacute;dulo_Expediciones|DE:Modul_Lieferungen';
128
129llxHeader('', $langs->trans('Order'), $help_url);
130
131$form = new Form($db);
132$formcompany = new FormCompany($db);
133$formother = new FormOther($db);
134$contactstatic = new Contact($db);
135$userstatic = new User($db);
136
137
138/* *************************************************************************** */
139/* */
140/* Mode vue et edition */
141/* */
142/* *************************************************************************** */
143
144if ($id > 0 || !empty($ref)) {
145 $langs->trans("OrderCard");
146
147 $head = shipping_prepare_head($object);
148 print dol_get_fiche_head($head, 'contact', $langs->trans("Shipment"), -1, $object->picto);
149
150
151 // Shipment card
152 $linkback = '<a href="'.DOL_URL_ROOT.'/expedition/list.php?restore_lastsearch_values=1'.(!empty($socid) ? '&socid='.$socid : '').'">'.$langs->trans("BackToList").'</a>';
153
154 $morehtmlref = '<div class="refidno">';
155 // Ref customer shipment
156 $morehtmlref .= $form->editfieldkey("RefCustomer", '', $object->ref_customer, $object, $user->hasRight('expedition', 'creer'), 'string', '', 0, 1);
157 $morehtmlref .= $form->editfieldval("RefCustomer", '', $object->ref_customer, $object, $user->hasRight('expedition', 'creer'), 'string', '', null, null, '', 1);
158 // Thirdparty
159 $morehtmlref .= '<br>'.$object->thirdparty->getNomUrl(1);
160 // Project
161 if (isModEnabled('project')) {
162 $langs->load("projects");
163 $morehtmlref .= '<br>';
164 if (0) { // Do not change on shipment
165 $morehtmlref .= img_picto($langs->trans("Project"), 'project', 'class="pictofixedwidth"');
166 if ($action != 'classify') {
167 $morehtmlref .= '<a class="editfielda" href="'.$_SERVER['PHP_SELF'].'?action=classify&token='.newToken().'&id='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('SetProject')).'</a> ';
168 }
169 $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $objectsrc->socid, $objectsrc->fk_project, ($action == 'classify' ? 'projectid' : 'none'), 0, 0, 0, 1, '', 'maxwidth300');
170 } else {
171 if (!empty($objectsrc) && !empty($objectsrc->fk_project)) {
172 $proj = new Project($db);
173 $proj->fetch($objectsrc->fk_project);
174 $morehtmlref .= $proj->getNomUrl(1);
175 if ($proj->title) {
176 $morehtmlref .= '<span class="opacitymedium"> - '.dol_escape_htmltag($proj->title).'</span>';
177 }
178 }
179 }
180 }
181 $morehtmlref .= '</div>';
182
183
184 dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
185
186
187 print '<div class="fichecenter">';
188 //print '<div class="fichehalfleft">';
189 print '<div class="underbanner clearboth"></div>';
190
191 print '<table class="border centpercent tableforfield">';
192
193 // Linked documents
194 if ($typeobject == 'commande' && $object->$typeobject->id && isModEnabled('commande')) {
195 print '<tr><td class="titlefield">';
196 $objectsrc = new Commande($db);
197 $objectsrc->fetch($object->$typeobject->id);
198 print $langs->trans("RefOrder").'</td>';
199 print '<td colspan="3">';
200 print $objectsrc->getNomUrl(1, 'commande');
201 print "</td>\n";
202 print '</tr>';
203 }
204 if ($typeobject == 'propal' && $object->$typeobject->id && isModEnabled("propal")) {
205 print '<tr><td class="titlefield">';
206 $objectsrc = new Propal($db);
207 $objectsrc->fetch($object->$typeobject->id);
208 print $langs->trans("RefProposal").'</td>';
209 print '<td colspan="3">';
210 print $objectsrc->getNomUrl(1, 'expedition');
211 print "</td>\n";
212 print '</tr>';
213 }
214
215 print "</table>";
216
217
218 //print '</div>';
219 //print '<div class="fichehalfright">';
220 //print '<div class="underbanner clearboth"></div>';
221
222
223 //print '</div>';
224 print '</div>';
225
226 print '<div class="clearboth"></div>';
227
228
229 print dol_get_fiche_end();
230
231 // Lines of contacts
232 echo '<br>';
233
234 // Contacts lines (modules that overwrite templates must declare this into descriptor)
235 $dirtpls = array_merge($conf->modules_parts['tpl'], array('/core/tpl'));
236 $preselectedtypeofcontact = dol_getIdFromCode($db, 'SHIPPING', 'c_type_contact', 'code', 'rowid');
237 foreach ($dirtpls as $reldir) {
238 $res = @include dol_buildpath($reldir.'/contacts.tpl.php');
239 if ($res) {
240 break;
241 }
242 }
243}
244
245// End of page
246llxFooter();
247$db->close();
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 customers orders.
Class to manage shipments.
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.
Classe permettant la generation de composants html autre Only common components are here.
Class to manage projects.
Class to manage proposals.
Class to manage Dolibarr users.
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.
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_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
dol_get_fiche_end($notab=0)
Return tab footer of a card.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
dol_getIdFromCode($db, $key, $tablename, $fieldkey='code', $fieldid='id', $entityfilter=0, $filters='')
Return an id or code from a code or id.
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.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
img_edit($titlealt='default', $float=0, $other='')
Show logo editer/modifier fiche.
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.
shipping_prepare_head($object)
Prepare array with list of tabs.
Contact()
Old copy.
Definition index.php:572