dolibarr 24.0.0-beta
contact.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@inodbox.com>
3 * Copyright (C) 2007-2009 Laurent Destailleur <eldy@users.sourceforge.net>
4 * Copyright (C) 2012 Juanjo Menent <jmenent@2byte.es>
5 * Copyright (C) 2024-2026 Frédéric France <frederic.france@free.fr>
6 * Copyright (C) 2025 MDW <mdeweerd@users.noreply.github.com>
7 * Copyright (C) 2026 Alexandre Spangaro <alexandre@inovea-conseil.com>
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 3 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program. If not, see <https://www.gnu.org/licenses/>.
21 */
22
29// Load Dolibarr environment
30require '../main.inc.php';
39require_once DOL_DOCUMENT_ROOT.'/fichinter/class/fichinter.class.php';
40require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
41require_once DOL_DOCUMENT_ROOT.'/core/lib/fichinter.lib.php';
42require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
43require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php';
44require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
45
46// Load translation files required by the page
47$langs->loadLangs(array('interventions', 'sendings', 'companies'));
48
49$id = GETPOSTINT('id');
50$ref = GETPOST('ref', 'alpha');
51$action = GETPOST('action', 'aZ09');
52
53// Security check
54if ($user->isExternalUser()) {
55 $socid = $user->isExternalUser();
56}
57$result = restrictedArea($user, 'ficheinter', $id, 'fichinter');
58
59$object = new Fichinter($db);
60$result = $object->fetch($id, $ref);
61if (!$result) {
62 print 'Record not found';
63 exit;
64}
65
66$usercancreate = $user->hasRight('ficheinter', 'creer');
67
68
69/*
70 * Adding a new contact
71 */
72
73if ($action == 'addcontact' && $user->hasRight('ficheinter', 'creer')) {
74 if ($result > 0 && $id > 0) {
75 $contactid = (GETPOSTINT('userid') ? GETPOSTINT('userid') : GETPOSTINT('contactid'));
76 $typeid = (GETPOST('typecontact') ? GETPOST('typecontact') : GETPOST('type'));
77 $result = $object->add_contact($contactid, $typeid, GETPOST("source", 'aZ09'));
78 }
79
80 if ($result >= 0) {
81 header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id);
82 exit;
83 } else {
84 if ($object->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') {
85 $langs->load("errors");
86 $mesg = $langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType");
87 } else {
88 $mesg = $object->error;
89 }
90
91 setEventMessages($mesg, null, 'errors');
92 }
93} elseif ($action == 'swapstatut' && $user->hasRight('ficheinter', 'creer')) {
94 // Toggle the status of a contact
95 $result = $object->swapContactStatus(GETPOSTINT('ligne'));
96} elseif ($action == 'deletecontact' && $user->hasRight('ficheinter', 'creer')) {
97 // Deletes a contact
98 $result = $object->delete_contact(GETPOSTINT('lineid'));
99
100 if ($result >= 0) {
101 header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id);
102 exit;
103 } else {
105 }
106}
107
108
109/*
110 * View
111 */
112
113$form = new Form($db);
114$formcompany = new FormCompany($db);
115$contactstatic = new Contact($db);
116$userstatic = new User($db);
117$formproject = new FormProjets($db);
118
119$title = $object->ref . " - " . $langs->trans('ContactsAddresses');
120$help_url = 'EN:Module_Interventions|FR:Module_Fiches_d\'interventions';
121
122llxHeader('', $title, $help_url, '', 0, 0, '', '', '', 'mod-fichinter page-card_contact');
123
124// Mode vue et edition
125
126if ($id > 0 || !empty($ref)) {
127 $object->fetch_thirdparty();
128
129 $head = fichinter_prepare_head($object);
130 print dol_get_fiche_head($head, 'contact', $langs->trans("InterventionCard"), -1, $object->picto);
131
132
133 // Intervention card
134 $linkback = '<a href="'.DOL_URL_ROOT.'/fichinter/list.php?restore_lastsearch_values=1'.(!empty($socid) ? '&socid='.$socid : '').'">'.$langs->trans("BackToList").'</a>';
135
136
137 $morehtmlref = '<div class="refidno">';
138 // Ref customer
139 //$morehtmlref.=$form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, $user->rights->ficheinter->creer, 'string', '', 0, 1);
140 //$morehtmlref.=$form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, $user->rights->ficheinter->creer, 'string', '', null, null, '', 1);
141 $morehtmlref .= $form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', 0, 1);
142 $morehtmlref .= $form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', null, null, '', 1);
143 // Thirdparty
144 $morehtmlref .= '<br>'.$object->thirdparty->getNomUrl(1, 'customer');
145 // Project
146 if (isModEnabled('project')) {
147 $langs->load("projects");
148 $morehtmlref .= '<br>';
149 if ($usercancreate && 0) {
150 $morehtmlref .= img_picto($langs->trans("Project"), 'project', 'class="pictofixedwidth"');
151 if ($action != 'classify') {
152 $morehtmlref .= '<a class="editfielda" href="'.dolBuildUrl($_SERVER['PHP_SELF'], ['action' => 'classify', 'id' => $object->id], true).'">'.img_edit($langs->transnoentitiesnoconv('SetProject')).'</a> ';
153 }
154 $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, (string) $object->fk_project, ($action == 'classify' ? 'projectid' : 'none'), 0, 0, 0, 1, '', 'maxwidth300');
155 } else {
156 if (!empty($object->fk_project)) {
157 $proj = new Project($db);
158 $proj->fetch($object->fk_project);
159 $morehtmlref .= $proj->getNomUrl(1);
160 if ($proj->title) {
161 $morehtmlref .= '<span class="opacitymedium"> - '.dol_escape_htmltag($proj->title).'</span>';
162 }
163 }
164 }
165 }
166 $morehtmlref .= '</div>';
167
168 dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref, '', 0, '', '', 1);
169
170 print dol_get_fiche_end();
171
172 print '<br>';
173
174 if (getDolGlobalString('FICHINTER_HIDE_ADD_CONTACT_USER')) {
175 $hideaddcontactforuser = 1;
176 }
177 if (getDolGlobalString('FICHINTER_HIDE_ADD_CONTACT_THIPARTY')) {
178 $hideaddcontactforthirdparty = 1;
179 }
180
181 // Contacts lines (modules that overwrite templates must declare this into descriptor)
182 $dirtpls = array_merge($conf->modules_parts['tpl'], array('/core/tpl'));
183 foreach ($dirtpls as $reldir) {
184 $file = dol_buildpath($reldir.'/contacts.tpl.php');
185 if (file_exists($file)) {
186 $res = @include $file;
187 if ($res) {
188 break;
189 }
190 }
191 }
192}
193
194
195llxFooter();
196$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 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 manage building of HTML components.
Class to manage projects.
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.
fichinter_prepare_head($object)
Prepare array with list of tabs.
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.
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.