dolibarr 21.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 Frédéric France <frederic.france@free.fr>
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.'/fichinter/class/fichinter.class.php';
30require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
31require_once DOL_DOCUMENT_ROOT.'/core/lib/fichinter.lib.php';
32require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
33require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php';
34require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
35
44// Load translation files required by the page
45$langs->loadLangs(array('interventions', 'sendings', 'companies'));
46
47$id = GETPOSTINT('id');
48$ref = GETPOST('ref', 'alpha');
49$action = GETPOST('action', 'aZ09');
50
51// Security check
52if ($user->socid) {
53 $socid = $user->socid;
54}
55$result = restrictedArea($user, 'ficheinter', $id, 'fichinter');
56
57$object = new Fichinter($db);
58$result = $object->fetch($id, $ref);
59if (!$result) {
60 print 'Record not found';
61 exit;
62}
63
64$usercancreate = $user->hasRight('ficheinter', 'creer');
65
66
67/*
68 * Adding a new contact
69 */
70
71if ($action == 'addcontact' && $user->hasRight('ficheinter', 'creer')) {
72 if ($result > 0 && $id > 0) {
73 $contactid = (GETPOSTINT('userid') ? GETPOSTINT('userid') : GETPOSTINT('contactid'));
74 $typeid = (GETPOST('typecontact') ? GETPOST('typecontact') : GETPOST('type'));
75 $result = $object->add_contact($contactid, $typeid, GETPOST("source", 'aZ09'));
76 }
77
78 if ($result >= 0) {
79 header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id);
80 exit;
81 } else {
82 if ($object->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') {
83 $langs->load("errors");
84 $mesg = $langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType");
85 } else {
86 $mesg = $object->error;
87 }
88
89 setEventMessages($mesg, null, 'errors');
90 }
91} elseif ($action == 'swapstatut' && $user->hasRight('ficheinter', 'creer')) {
92 // Toggle the status of a contact
93 $result = $object->swapContactStatus(GETPOSTINT('ligne'));
94} elseif ($action == 'deletecontact' && $user->hasRight('ficheinter', 'creer')) {
95 // Deletes a contact
96 $result = $object->delete_contact(GETPOSTINT('lineid'));
97
98 if ($result >= 0) {
99 header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id);
100 exit;
101 } else {
102 dol_print_error($db);
103 }
104}
105
106
107/*
108 * View
109 */
110
111$form = new Form($db);
112$formcompany = new FormCompany($db);
113$contactstatic = new Contact($db);
114$userstatic = new User($db);
115$formproject = new FormProjets($db);
116
117llxHeader('', $langs->trans("Intervention"), '', '', 0, 0, '', '', '', 'mod-fichinter page-card_contact');
118
119// Mode vue et edition
120
121if ($id > 0 || !empty($ref)) {
122 $object->fetch_thirdparty();
123
124 $head = fichinter_prepare_head($object);
125 print dol_get_fiche_head($head, 'contact', $langs->trans("InterventionCard"), -1, 'intervention');
126
127
128 // Intervention card
129 $linkback = '<a href="'.DOL_URL_ROOT.'/fichinter/list.php?restore_lastsearch_values=1'.(!empty($socid) ? '&socid='.$socid : '').'">'.$langs->trans("BackToList").'</a>';
130
131
132 $morehtmlref = '<div class="refidno">';
133 // Ref customer
134 //$morehtmlref.=$form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, $user->rights->ficheinter->creer, 'string', '', 0, 1);
135 //$morehtmlref.=$form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, $user->rights->ficheinter->creer, 'string', '', null, null, '', 1);
136 $morehtmlref.=$form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', 0, 1);
137 $morehtmlref.=$form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', null, null, '', 1);
138 // Thirdparty
139 $morehtmlref .= '<br>'.$object->thirdparty->getNomUrl(1, 'customer');
140 // Project
141 if (isModEnabled('project')) {
142 $langs->load("projects");
143 $morehtmlref .= '<br>';
144 if ($usercancreate && 0) {
145 $morehtmlref .= img_picto($langs->trans("Project"), 'project', 'class="pictofixedwidth"');
146 if ($action != 'classify') {
147 $morehtmlref .= '<a class="editfielda" href="'.$_SERVER['PHP_SELF'].'?action=classify&token='.newToken().'&id='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('SetProject')).'</a> ';
148 }
149 $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, ($action == 'classify' ? 'projectid' : 'none'), 0, 0, 0, 1, '', 'maxwidth300');
150 } else {
151 if (!empty($object->fk_project)) {
152 $proj = new Project($db);
153 $proj->fetch($object->fk_project);
154 $morehtmlref .= $proj->getNomUrl(1);
155 if ($proj->title) {
156 $morehtmlref .= '<span class="opacitymedium"> - '.dol_escape_htmltag($proj->title).'</span>';
157 }
158 }
159 }
160 }
161 $morehtmlref .= '</div>';
162
163 dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref, '', 0, '', '', 1);
164
165 print dol_get_fiche_end();
166
167 print '<br>';
168
169 if (getDolGlobalString('FICHINTER_HIDE_ADD_CONTACT_USER')) {
170 $hideaddcontactforuser = 1;
171 }
172 if (getDolGlobalString('FICHINTER_HIDE_ADD_CONTACT_THIPARTY')) {
173 $hideaddcontactforthirdparty = 1;
174 }
175
176 // Contacts lines (modules that overwrite templates must declare this into descriptor)
177 $dirtpls = array_merge($conf->modules_parts['tpl'], array('/core/tpl'));
178 foreach ($dirtpls as $reldir) {
179 $res = @include dol_buildpath($reldir.'/contacts.tpl.php');
180 if ($res) {
181 break;
182 }
183 }
184}
185
186
187llxFooter();
188$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 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.
llxFooter()
Footer empty.
Definition document.php:107
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)
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
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.