1 | <?php |
||
2 | |||
3 | /* Copyright (C) 2005-2012 Regis Houssin <[email protected]> |
||
4 | * Copyright (C) 2007-2009 Laurent Destailleur <[email protected]> |
||
5 | * Copyright (C) 2012 Juanjo Menent <[email protected]> |
||
6 | * Copyright (C) 2024 Rafael San José <[email protected]> |
||
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 | |||
22 | use Dolibarr\Code\Core\Classes\Form; |
||
23 | use Dolibarr\Lib\ViewMain; |
||
24 | |||
25 | /** |
||
26 | * \file htdocs/fichinter/contact.php |
||
27 | * \ingroup fichinter |
||
28 | * \brief Onglet de gestion des contacts de fiche d'intervention |
||
29 | */ |
||
30 | |||
31 | use Dolibarr\Code\Contact\Classes\Contact; |
||
32 | use Dolibarr\Code\Core\Classes\FormCompany; |
||
33 | use Dolibarr\Code\Core\Classes\FormProjets; |
||
34 | use Dolibarr\Code\FichInter\Classes\Fichinter; |
||
35 | use Dolibarr\Code\Projet\Classes\Project; |
||
36 | use Dolibarr\Code\User\Classes\User; |
||
37 | |||
38 | // Load Dolibarr environment |
||
39 | require constant('DOL_DOCUMENT_ROOT') . '/main.inc.php'; |
||
40 | require_once constant('DOL_DOCUMENT_ROOT') . '/core/lib/fichinter.lib.php'; |
||
41 | |||
42 | // Load translation files required by the page |
||
43 | $langs->loadLangs(array('interventions', 'sendings', 'companies')); |
||
44 | |||
45 | $id = GETPOSTINT('id'); |
||
46 | $ref = GETPOST('ref', 'alpha'); |
||
47 | $action = GETPOST('action', 'aZ09'); |
||
48 | |||
49 | // Security check |
||
50 | if ($user->socid) { |
||
51 | $socid = $user->socid; |
||
52 | } |
||
53 | $result = restrictedArea($user, 'ficheinter', $id, 'fichinter'); |
||
54 | |||
55 | $object = new Fichinter($db); |
||
56 | $result = $object->fetch($id, $ref); |
||
57 | if (!$result) { |
||
58 | print 'Record not found'; |
||
59 | exit; |
||
60 | } |
||
61 | |||
62 | $usercancreate = $user->hasRight('ficheinter', 'creer'); |
||
63 | |||
64 | /* |
||
65 | * Adding a new contact |
||
66 | */ |
||
67 | |||
68 | if ($action == 'addcontact' && $user->hasRight('ficheinter', 'creer')) { |
||
69 | if ($result > 0 && $id > 0) { |
||
70 | $contactid = (GETPOSTINT('userid') ? GETPOSTINT('userid') : GETPOSTINT('contactid')); |
||
71 | $typeid = (GETPOST('typecontact') ? GETPOST('typecontact') : GETPOST('type')); |
||
72 | $result = $object->add_contact($contactid, $typeid, GETPOST("source", 'aZ09')); |
||
73 | } |
||
74 | |||
75 | if ($result >= 0) { |
||
76 | header("Location: " . $_SERVER['PHP_SELF'] . "?id=" . $object->id); |
||
77 | exit; |
||
78 | } else { |
||
79 | if ($object->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') { |
||
80 | $langs->load("errors"); |
||
81 | $mesg = $langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType"); |
||
82 | } else { |
||
83 | $mesg = $object->error; |
||
84 | } |
||
85 | |||
86 | setEventMessages($mesg, null, 'errors'); |
||
87 | } |
||
88 | } elseif ($action == 'swapstatut' && $user->hasRight('ficheinter', 'creer')) { |
||
89 | // Toggle the status of a contact |
||
90 | $result = $object->swapContactStatus(GETPOSTINT('ligne')); |
||
91 | } elseif ($action == 'deletecontact' && $user->hasRight('ficheinter', 'creer')) { |
||
92 | // Deletes a contact |
||
93 | $result = $object->delete_contact(GETPOSTINT('lineid')); |
||
94 | |||
95 | if ($result >= 0) { |
||
96 | header("Location: " . $_SERVER['PHP_SELF'] . "?id=" . $object->id); |
||
97 | exit; |
||
98 | } else { |
||
99 | dol_print_error($db); |
||
100 | } |
||
101 | } |
||
102 | |||
103 | /* |
||
104 | * View |
||
105 | */ |
||
106 | |||
107 | $form = new Form($db); |
||
108 | $formcompany = new FormCompany($db); |
||
109 | $contactstatic = new Contact($db); |
||
110 | $userstatic = new User($db); |
||
111 | $formproject = new FormProjets($db); |
||
112 | |||
113 | ViewMain::llxHeader('', $langs->trans("Intervention")); |
||
114 | |||
115 | // Mode vue et edition |
||
116 | |||
117 | if ($id > 0 || !empty($ref)) { |
||
118 | $object->fetch_thirdparty(); |
||
119 | |||
120 | $head = fichinter_prepare_head($object); |
||
121 | print dol_get_fiche_head($head, 'contact', $langs->trans("InterventionCard"), -1, 'intervention'); |
||
122 | |||
123 | |||
124 | // Intervention card |
||
125 | $linkback = '<a href="' . constant('BASE_URL') . '/fichinter/list.php?restore_lastsearch_values=1' . (!empty($socid) ? '&socid=' . $socid : '') . '">' . $langs->trans("BackToList") . '</a>'; |
||
126 | |||
127 | |||
128 | $morehtmlref = '<div class="refidno">'; |
||
129 | // Ref customer |
||
130 | //$morehtmlref.=$form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, $user->rights->ficheinter->creer, 'string', '', 0, 1); |
||
131 | //$morehtmlref.=$form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, $user->rights->ficheinter->creer, 'string', '', null, null, '', 1); |
||
132 | $morehtmlref .= $form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', 0, 1); |
||
133 | $morehtmlref .= $form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', null, null, '', 1); |
||
134 | // Thirdparty |
||
135 | $morehtmlref .= '<br>' . $object->thirdparty->getNomUrl(1, 'customer'); |
||
0 ignored issues
–
show
|
|||
136 | // Project |
||
137 | if (isModEnabled('project')) { |
||
138 | $langs->load("projects"); |
||
139 | $morehtmlref .= '<br>'; |
||
140 | if ($usercancreate && 0) { |
||
141 | $morehtmlref .= img_picto($langs->trans("Project"), 'project', 'class="pictofixedwidth"'); |
||
142 | if ($action != 'classify') { |
||
143 | $morehtmlref .= '<a class="editfielda" href="' . $_SERVER['PHP_SELF'] . '?action=classify&token=' . newToken() . '&id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> '; |
||
144 | } |
||
145 | $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, ($action == 'classify' ? 'projectid' : 'none'), 0, 0, 0, 1, '', 'maxwidth300'); |
||
146 | } else { |
||
147 | if (!empty($object->fk_project)) { |
||
148 | $proj = new Project($db); |
||
149 | $proj->fetch($object->fk_project); |
||
150 | $morehtmlref .= $proj->getNomUrl(1); |
||
151 | if ($proj->title) { |
||
152 | $morehtmlref .= '<span class="opacitymedium"> - ' . dol_escape_htmltag($proj->title) . '</span>'; |
||
153 | } |
||
154 | } |
||
155 | } |
||
156 | } |
||
157 | $morehtmlref .= '</div>'; |
||
158 | |||
159 | dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref, '', 0, '', '', 1); |
||
160 | |||
161 | print dol_get_fiche_end(); |
||
162 | |||
163 | print '<br>'; |
||
164 | |||
165 | if (getDolGlobalString('FICHINTER_HIDE_ADD_CONTACT_USER')) { |
||
166 | $hideaddcontactforuser = 1; |
||
167 | } |
||
168 | if (getDolGlobalString('FICHINTER_HIDE_ADD_CONTACT_THIPARTY')) { |
||
169 | $hideaddcontactforthirdparty = 1; |
||
170 | } |
||
171 | |||
172 | // Contacts lines (modules that overwrite templates must declare this into descriptor) |
||
173 | $dirtpls = array_merge($conf->modules_parts['tpl'], array('/core/tpl')); |
||
174 | foreach ($dirtpls as $reldir) { |
||
175 | $res = @include dol_buildpath($reldir . '/contacts.tpl.php'); |
||
176 | if ($res) { |
||
177 | break; |
||
178 | } |
||
179 | } |
||
180 | } |
||
181 | |||
182 | |||
183 | ViewMain::llxFooter(); |
||
184 | $db->close(); |
||
185 |
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.