1 | <?php |
||||
2 | |||||
3 | /* Copyright (C) 2005 Patrick Rouillon <[email protected]> |
||||
4 | * Copyright (C) 2005-2011 Laurent Destailleur <[email protected]> |
||||
5 | * Copyright (C) 2005-2012 Regis Houssin <[email protected]> |
||||
6 | * Copyright (C) 2024 MDW <[email protected]> |
||||
7 | * Copyright (C) 2024 Rafael San José <[email protected]> |
||||
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 | |||||
23 | use Dolibarr\Code\Comm\Classes\Propal; |
||||
24 | use Dolibarr\Code\Contact\Classes\Contact; |
||||
25 | use Dolibarr\Code\Core\Classes\Form; |
||||
26 | use Dolibarr\Code\Core\Classes\FormCompany; |
||||
27 | use Dolibarr\Code\Core\Classes\FormOther; |
||||
28 | use Dolibarr\Code\Fourn\Classes\CommandeFournisseur; |
||||
29 | use Dolibarr\Code\Projet\Classes\Project; |
||||
30 | use Dolibarr\Code\Reception\Classes\Reception; |
||||
31 | use Dolibarr\Code\User\Classes\User; |
||||
32 | use Dolibarr\Lib\ViewMain; |
||||
33 | |||||
34 | /** |
||||
35 | * \file htdocs/reception/contact.php |
||||
36 | * \ingroup reception |
||||
37 | * \brief Onglet de gestion des contacts de reception |
||||
38 | */ |
||||
39 | |||||
40 | // Load Dolibarr environment |
||||
41 | require constant('DOL_DOCUMENT_ROOT') . '/main.inc.php'; |
||||
42 | require_once constant('DOL_DOCUMENT_ROOT') . '/core/lib/reception.lib.php'; |
||||
43 | |||||
44 | $langs->loadLangs(array("orders", "receptions", "companies")); |
||||
45 | |||||
46 | $id = GETPOSTINT('id'); |
||||
47 | $ref = GETPOST('ref', 'alpha'); |
||||
48 | $action = GETPOST('action', 'aZ09'); |
||||
49 | |||||
50 | $object = new Reception($db); |
||||
51 | if ($id > 0 || !empty($ref)) { |
||||
52 | $object->fetch($id, $ref); |
||||
53 | $object->fetch_thirdparty(); |
||||
54 | |||||
55 | if (!empty($object->origin)) { |
||||
0 ignored issues
–
show
|
|||||
56 | $origin = $object->origin; |
||||
0 ignored issues
–
show
The property
Dolibarr\Core\Base\CommonObject::$origin has been deprecated: Use $origin_type and $origin_id instead.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This property has been deprecated. The supplier of the class has supplied an explanatory message. The explanatory message should give you some clue as to whether and when the property will be removed from the class and what other property to use instead. ![]() |
|||||
57 | $typeobject = $object->origin; |
||||
0 ignored issues
–
show
The property
Dolibarr\Core\Base\CommonObject::$origin has been deprecated: Use $origin_type and $origin_id instead.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This property has been deprecated. The supplier of the class has supplied an explanatory message. The explanatory message should give you some clue as to whether and when the property will be removed from the class and what other property to use instead. ![]() |
|||||
58 | |||||
59 | $object->fetch_origin(); |
||||
60 | } |
||||
61 | |||||
62 | // Linked documents |
||||
63 | if ($origin == 'order_supplier' && $object->origin_object->id && isModEnabled("supplier_order")) { |
||||
64 | $objectsrc = new CommandeFournisseur($db); |
||||
65 | $objectsrc->fetch($object->origin_object->id); |
||||
66 | } |
||||
67 | } |
||||
68 | |||||
69 | // Security check |
||||
70 | if ($user->socid > 0) { |
||||
71 | $socid = $user->socid; |
||||
72 | } |
||||
73 | |||||
74 | // TODO Test on reception module on only |
||||
75 | if ($origin == 'reception') { |
||||
76 | $result = restrictedArea($user, $origin, $object->id); |
||||
77 | } else { |
||||
78 | if ($origin == 'supplierorder' || $origin == 'order_supplier') { |
||||
79 | $result = restrictedArea($user, 'fournisseur', $object, 'commande_fournisseur', 'commande'); |
||||
80 | } elseif (!$user->hasRight($origin, 'lire') && !$user->hasRight($origin, 'read')) { |
||||
81 | accessforbidden(); |
||||
82 | } |
||||
83 | } |
||||
84 | |||||
85 | if (isModEnabled("reception")) { |
||||
86 | $permissiontoread = $user->hasRight('reception', 'lire'); |
||||
87 | $permissiontoadd = $user->hasRight('reception', 'creer'); |
||||
88 | $permissiondellink = $user->hasRight('reception', 'creer'); // Used by the include of actions_dellink.inc.php |
||||
89 | $permissiontovalidate = ((!getDolGlobalString('MAIN_USE_ADVANCED_PERMS') && $user->hasRight('reception', 'creer')) || (getDolGlobalString('MAIN_USE_ADVANCED_PERMS') && $user->hasRight('reception', 'reception_advance', 'validate'))); |
||||
90 | $permissiontodelete = $user->hasRight('reception', 'supprimer'); |
||||
91 | } else { |
||||
92 | $permissiontoread = $user->hasRight('fournisseur', 'commande', 'receptionner'); |
||||
93 | $permissiontoadd = $user->hasRight('fournisseur', 'commande', 'receptionner'); |
||||
94 | $permissiondellink = $user->hasRight('fournisseur', 'commande', 'receptionner'); // Used by the include of actions_dellink.inc.php |
||||
95 | $permissiontovalidate = ((!getDolGlobalString('MAIN_USE_ADVANCED_PERMS') && $user->hasRight('fournisseur', 'commande', 'receptionner')) || (getDolGlobalString('MAIN_USE_ADVANCED_PERMS') && $user->hasRight('fournisseur', 'commande_advance', 'check'))); |
||||
96 | $permissiontodelete = $user->hasRight('fournisseur', 'commande', 'receptionner'); |
||||
97 | } |
||||
98 | |||||
99 | /* |
||||
100 | * Actions |
||||
101 | */ |
||||
102 | |||||
103 | if ($action == 'addcontact' && $user->hasRight('reception', 'creer')) { |
||||
104 | if ($result > 0 && $id > 0) { |
||||
105 | $contactid = (GETPOSTINT('userid') ? GETPOSTINT('userid') : GETPOSTINT('contactid')); |
||||
106 | $typeid = (GETPOST('typecontact') ? GETPOST('typecontact') : GETPOST('type')); |
||||
107 | $result = $objectsrc->add_contact($contactid, $typeid, GETPOST("source", 'aZ09')); |
||||
108 | } |
||||
109 | |||||
110 | if ($result >= 0) { |
||||
111 | header("Location: " . $_SERVER['PHP_SELF'] . "?id=" . $object->id); |
||||
112 | exit; |
||||
113 | } else { |
||||
114 | if ($objectsrc->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') { |
||||
115 | $langs->load("errors"); |
||||
116 | $mesg = $langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType"); |
||||
117 | } else { |
||||
118 | $mesg = $objectsrc->error; |
||||
119 | $mesgs = $objectsrc->errors; |
||||
120 | } |
||||
121 | setEventMessages($mesg, $mesgs, 'errors'); |
||||
122 | } |
||||
123 | } elseif ($action == 'swapstatut' && $user->hasRight('reception', 'creer')) { |
||||
124 | // bascule du statut d'un contact |
||||
125 | $result = $objectsrc->swapContactStatus(GETPOSTINT('ligne')); |
||||
126 | } elseif ($action == 'deletecontact' && $user->hasRight('reception', 'creer')) { |
||||
127 | // Efface un contact |
||||
128 | $result = $objectsrc->delete_contact(GETPOSTINT("lineid")); |
||||
129 | |||||
130 | if ($result >= 0) { |
||||
131 | header("Location: " . $_SERVER['PHP_SELF'] . "?id=" . $object->id); |
||||
132 | exit; |
||||
133 | } else { |
||||
134 | dol_print_error($db); |
||||
135 | } |
||||
136 | } |
||||
137 | |||||
138 | |||||
139 | /* |
||||
140 | * View |
||||
141 | */ |
||||
142 | |||||
143 | $help_url = 'EN:Customers_Orders|FR:receptions_Clients|ES:Pedidos de clientes'; |
||||
144 | ViewMain::llxHeader('', $langs->trans('Reception'), $help_url, '', 0, 0, '', '', '', 'mod-reception page-card_contact'); |
||||
145 | |||||
146 | $form = new Form($db); |
||||
147 | $formcompany = new FormCompany($db); |
||||
148 | $formother = new FormOther($db); |
||||
149 | $contactstatic = new Contact($db); |
||||
150 | $userstatic = new User($db); |
||||
151 | |||||
152 | // View mode |
||||
153 | |||||
154 | if ($id > 0 || !empty($ref)) { |
||||
155 | $langs->trans("OrderCard"); |
||||
156 | |||||
157 | $head = reception_prepare_head($object); |
||||
158 | print dol_get_fiche_head($head, 'contact', $langs->trans("Reception"), -1, 'dollyrevert'); |
||||
159 | |||||
160 | |||||
161 | // Reception card |
||||
162 | $linkback = '<a href="' . constant('BASE_URL') . 'reception/list.php?restore_lastsearch_values=1">' . $langs->trans("BackToList") . '</a>'; |
||||
163 | |||||
164 | $morehtmlref = '<div class="refidno">'; |
||||
165 | // Ref customer reception |
||||
166 | $morehtmlref .= $form->editfieldkey("RefSupplier", '', $object->ref_supplier, $object, $user->hasRight('reception', 'creer'), 'string', '', 0, 1); |
||||
167 | $morehtmlref .= $form->editfieldval("RefSupplier", '', $object->ref_supplier, $object, $user->hasRight('reception', 'creer'), 'string', '', null, null, '', 1); |
||||
168 | // Thirdparty |
||||
169 | $morehtmlref .= '<br>' . $object->thirdparty->getNomUrl(1); |
||||
0 ignored issues
–
show
The method
getNomUrl() does not exist on null .
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
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. ![]() |
|||||
170 | // Project |
||||
171 | if (isModEnabled('project')) { |
||||
172 | $langs->load("projects"); |
||||
173 | $morehtmlref .= '<br>'; |
||||
174 | if (0) { // Do not change on reception |
||||
175 | $morehtmlref .= img_picto($langs->trans("Project"), 'project', 'class="pictofixedwidth"'); |
||||
176 | if ($action != 'classify' && $permissiontoadd) { |
||||
177 | $morehtmlref .= '<a class="editfielda" href="' . $_SERVER['PHP_SELF'] . '?action=classify&token=' . newToken() . '&id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> '; |
||||
178 | } |
||||
179 | $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'); |
||||
180 | } else { |
||||
181 | if (!empty($objectsrc) && !empty($objectsrc->fk_project)) { |
||||
182 | $proj = new Project($db); |
||||
183 | $proj->fetch($objectsrc->fk_project); |
||||
184 | $morehtmlref .= $proj->getNomUrl(1); |
||||
185 | if ($proj->title) { |
||||
186 | $morehtmlref .= '<span class="opacitymedium"> - ' . dol_escape_htmltag($proj->title) . '</span>'; |
||||
187 | } |
||||
188 | } |
||||
189 | } |
||||
190 | } |
||||
191 | $morehtmlref .= '</div>'; |
||||
192 | |||||
193 | dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref); |
||||
194 | |||||
195 | |||||
196 | print '<div class="fichecenter">'; |
||||
197 | //print '<div class="fichehalfleft">'; |
||||
198 | print '<div class="underbanner clearboth"></div>'; |
||||
199 | |||||
200 | print '<table class="border centpercent tableforfield">'; |
||||
201 | // Linked documents |
||||
202 | if ($origin == 'order_supplier' && $object->origin_object->id && isModEnabled("supplier_order")) { |
||||
203 | print '<tr><td class="titlefield">'; |
||||
204 | $objectsrc = new CommandeFournisseur($db); |
||||
205 | $objectsrc->fetch($object->origin_object->id); |
||||
206 | print $langs->trans("RefOrder") . '</td>'; |
||||
207 | print '<td colspan="3">'; |
||||
208 | print $objectsrc->getNomUrl(1, 'commande'); |
||||
209 | print "</td>\n"; |
||||
210 | print '</tr>'; |
||||
211 | } |
||||
212 | if ($typeobject == 'propal' && $object->origin_object->id && isModEnabled("propal")) { |
||||
213 | print '<tr><td class="titlefield">'; |
||||
214 | $objectsrc = new Propal($db); |
||||
215 | $objectsrc->fetch($object->origin_object->id); |
||||
216 | print $langs->trans("RefProposal") . '</td>'; |
||||
217 | print '<td colspan="3">'; |
||||
218 | print $objectsrc->getNomUrl(1, 'reception'); |
||||
219 | print "</td>\n"; |
||||
220 | print '</tr>'; |
||||
221 | } |
||||
222 | |||||
223 | print "</table>"; |
||||
224 | |||||
225 | |||||
226 | //print '</div>'; |
||||
227 | //print '<div class="fichehalfright">'; |
||||
228 | //print '<div class="underbanner clearboth"></div>'; |
||||
229 | |||||
230 | |||||
231 | //print '</div>'; |
||||
232 | print '</div>'; |
||||
233 | |||||
234 | print '<div class="clearboth"></div>'; |
||||
235 | |||||
236 | |||||
237 | print dol_get_fiche_end(); |
||||
238 | |||||
239 | // Lines of contacts |
||||
240 | echo '<br>'; |
||||
241 | |||||
242 | // Contacts lines (modules that overwrite templates must declare this into descriptor) |
||||
243 | $dirtpls = array_merge($conf->modules_parts['tpl'], array('/core/tpl')); |
||||
244 | foreach ($dirtpls as $reldir) { |
||||
245 | $res = @include dol_buildpath($reldir . '/contacts.tpl.php'); |
||||
246 | if ($res) { |
||||
247 | break; |
||||
248 | } |
||||
249 | } |
||||
250 | } |
||||
251 | |||||
252 | ViewMain::llxFooter(); |
||||
253 | |||||
254 | $db->close(); |
||||
255 |
This property has been deprecated. The supplier of the class has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the property will be removed from the class and what other property to use instead.