1 | <?php |
||||
2 | |||||
3 | /* Copyright (C) 2003-2005 Rodolphe Quiedeville <[email protected]> |
||||
4 | * Copyright (C) 2005-2010 Laurent Destailleur <[email protected]> |
||||
5 | * Copyright (C) 2005 Simon TOSSER <[email protected]> |
||||
6 | * Copyright (C) 2005-2014 Regis Houssin <[email protected]> |
||||
7 | * Copyright (C) 2007 Franky Van Liedekerke <[email protected]> |
||||
8 | * Copyright (C) 2013 Florian Henry <[email protected]> |
||||
9 | * Copyright (C) 2015 Claudio Aschieri <[email protected]> |
||||
10 | * Copyright (C) 2024 Rafael San José <[email protected]> |
||||
11 | * |
||||
12 | * This program is free software; you can redistribute it and/or modify |
||||
13 | * it under the terms of the GNU General Public License as published by |
||||
14 | * the Free Software Foundation; either version 3 of the License, or |
||||
15 | * (at your option) any later version. |
||||
16 | * |
||||
17 | * This program is distributed in the hope that it will be useful, |
||||
18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
20 | * GNU General Public License for more details. |
||||
21 | * |
||||
22 | * You should have received a copy of the GNU General Public License |
||||
23 | * along with this program. If not, see <https://www.gnu.org/licenses/>. |
||||
24 | */ |
||||
25 | |||||
26 | use Dolibarr\Code\Comm\Classes\Propal; |
||||
27 | use Dolibarr\Code\Commande\Classes\Commande; |
||||
28 | use Dolibarr\Code\Core\Classes\ExtraFields; |
||||
29 | use Dolibarr\Code\Core\Classes\Form; |
||||
30 | use Dolibarr\Code\Core\Classes\FormFile; |
||||
31 | use Dolibarr\Code\Core\Classes\Translate; |
||||
32 | use Dolibarr\Code\Delivery\Classes\Delivery; |
||||
33 | use Dolibarr\Code\Delivery\Classes\DeliveryLine; |
||||
34 | use Dolibarr\Code\Expedition\Classes\Expedition; |
||||
35 | use Dolibarr\Code\Expedition\Classes\ExpeditionLigne; |
||||
36 | use Dolibarr\Code\Product\Classes\Entrepot; |
||||
37 | use Dolibarr\Code\Product\Classes\Product; |
||||
38 | use Dolibarr\Code\Projet\Classes\Project; |
||||
39 | use Dolibarr\Code\Societe\Classes\Societe; |
||||
40 | use Dolibarr\Lib\ViewMain; |
||||
41 | |||||
42 | /** |
||||
43 | * \file htdocs/delivery/card.php |
||||
44 | * \ingroup livraison |
||||
45 | * \brief Page to describe a delivery receipt |
||||
46 | */ |
||||
47 | |||||
48 | // Load Dolibarr environment |
||||
49 | require constant('DOL_DOCUMENT_ROOT') . '/main.inc.php'; |
||||
50 | require_once constant('DOL_DOCUMENT_ROOT') . '/core/lib/sendings.lib.php'; |
||||
51 | |||||
52 | // Load translation files required by the page |
||||
53 | $langs->loadLangs(array('bills', 'deliveries', 'orders', 'sendings')); |
||||
54 | |||||
55 | if (isModEnabled('incoterm')) { |
||||
56 | $langs->load('incoterm'); |
||||
57 | } |
||||
58 | |||||
59 | $action = GETPOST('action', 'aZ09'); |
||||
60 | $confirm = GETPOST('confirm', 'alpha'); |
||||
61 | $backtopage = GETPOST('backtopage', 'alpha'); |
||||
62 | |||||
63 | // Security check |
||||
64 | $id = GETPOSTINT('id'); |
||||
65 | if ($user->socid) { |
||||
66 | $socid = $user->socid; |
||||
67 | } |
||||
68 | $result = restrictedArea($user, 'expedition', $id, 'delivery', 'delivery'); |
||||
69 | |||||
70 | $object = new Delivery($db); |
||||
71 | $extrafields = new ExtraFields($db); |
||||
72 | |||||
73 | // fetch optionals attributes and labels |
||||
74 | $extrafields->fetch_name_optionals_label($object->table_element); |
||||
75 | |||||
76 | // fetch optionals attributes lines and labels |
||||
77 | $extrafields->fetch_name_optionals_label($object->table_element_line); |
||||
78 | |||||
79 | // Load object. Make an object->fetch |
||||
80 | include DOL_DOCUMENT_ROOT . '/core/actions_fetchobject.inc.php'; // Must be include, not include_once |
||||
81 | |||||
82 | // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context |
||||
83 | $hookmanager->initHooks(array('deliverycard', 'globalcard')); |
||||
84 | |||||
85 | $error = 0; |
||||
86 | |||||
87 | |||||
88 | /* |
||||
89 | * Actions |
||||
90 | */ |
||||
91 | |||||
92 | $parameters = array(); |
||||
93 | $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks |
||||
94 | // Delete Link |
||||
95 | $permissiondellink = $user->hasRight('expedition', 'delivery', 'supprimer'); // Used by the include of actions_dellink.inc.php |
||||
96 | include DOL_DOCUMENT_ROOT . '/core/actions_dellink.inc.php'; // Must be include, not include_once |
||||
97 | |||||
98 | if ($action == 'add') { |
||||
99 | $db->begin(); |
||||
100 | |||||
101 | $object->date_delivery = dol_now(); |
||||
102 | $object->note = GETPOST("note", 'restricthtml'); |
||||
0 ignored issues
–
show
The property
Dolibarr\Core\Base\CommonObject::$note has been deprecated: Use $note_private 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. ![]() |
|||||
103 | $object->note_private = GETPOST("note", 'restricthtml'); |
||||
0 ignored issues
–
show
It seems like
GETPOST('note', 'restricthtml') can also be of type array or array or array . However, the property $note_private is declared as type string . Maybe add an additional type check?
Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a mixed type is assigned to a property that is type hinted more strictly. For example, imagine you have a variable Either this assignment is in error or a type check should be added for that assignment. class Id
{
public $id;
public function __construct($id)
{
$this->id = $id;
}
}
class Account
{
/** @var Id $id */
public $id;
}
$account_id = false;
if (starsAreRight()) {
$account_id = new Id(42);
}
$account = new Account();
if ($account instanceof Id)
{
$account->id = $account_id;
}
![]() |
|||||
104 | $object->commande_id = GETPOSTINT("commande_id"); |
||||
105 | $object->fk_incoterms = GETPOSTINT('incoterm_id'); |
||||
106 | |||||
107 | /* ->entrepot_id seems to not exists |
||||
108 | if (!getDolGlobalInt('MAIN_SUBMODULE_EXPEDITION') && isModEnabled('stock')) { |
||||
109 | $object->entrepot_id = GETPOST('entrepot_id', 'int'); |
||||
110 | }*/ |
||||
111 | |||||
112 | // We loop on each line of order to complete object delivery with qty to delivery |
||||
113 | $commande = new Commande($db); |
||||
114 | $commande->fetch($object->commande_id); |
||||
115 | $commande->fetch_lines(); |
||||
116 | $num = count($commande->lines); |
||||
117 | for ($i = 0; $i < $num; $i++) { |
||||
118 | $qty = "qtyl" . $i; |
||||
119 | $idl = "idl" . $i; |
||||
120 | $qtytouse = price2num(GETPOST($qty)); |
||||
121 | if ($qtytouse > 0) { |
||||
122 | $object->addline(GETPOST($idl), price2num($qtytouse), $arrayoptions); |
||||
123 | } |
||||
124 | } |
||||
125 | |||||
126 | $ret = $object->create($user); |
||||
127 | if ($ret > 0) { |
||||
128 | $db->commit(); |
||||
129 | header("Location: " . $_SERVER['PHP_SELF'] . "?id=" . $object->id); |
||||
130 | exit; |
||||
131 | } else { |
||||
132 | setEventMessages($object->error, $object->errors, 'errors'); |
||||
133 | $db->rollback(); |
||||
134 | |||||
135 | $action = 'create'; |
||||
136 | } |
||||
137 | } elseif ( |
||||
138 | $action == 'confirm_valid' && |
||||
139 | $confirm == 'yes' && |
||||
140 | ((!getDolGlobalString('MAIN_USE_ADVANCED_PERMS') && |
||||
141 | $user->hasRight('expedition', 'delivery', 'creer')) || |
||||
142 | (getDolGlobalString('MAIN_USE_ADVANCED_PERMS') && |
||||
143 | $user->hasRight('expedition', 'delivery_advance', 'validate'))) |
||||
144 | ) { |
||||
145 | $result = $object->valid($user); |
||||
146 | |||||
147 | // Define output language |
||||
148 | if (!getDolGlobalString('MAIN_DISABLE_PDF_AUTOUPDATE')) { |
||||
149 | $outputlangs = $langs; |
||||
150 | $newlang = ''; |
||||
151 | if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang) && GETPOST('lang_id', 'aZ09')) { |
||||
152 | $newlang = GETPOST('lang_id', 'aZ09'); |
||||
153 | } |
||||
154 | if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang)) { |
||||
155 | $newlang = $object->thirdparty->default_lang; |
||||
156 | } |
||||
157 | if (!empty($newlang)) { |
||||
158 | $outputlangs = new Translate("", $conf); |
||||
159 | $outputlangs->setDefaultLang($newlang); |
||||
160 | } |
||||
161 | $model = $object->model_pdf; |
||||
162 | $ret = $object->fetch($id); // Reload to get new records |
||||
163 | |||||
164 | $result = $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); |
||||
165 | if ($result < 0) { |
||||
166 | dol_print_error($db, $result); |
||||
167 | } |
||||
168 | } |
||||
169 | } |
||||
170 | |||||
171 | if ($action == 'confirm_delete' && $confirm == 'yes' && $user->hasRight('expedition', 'delivery', 'supprimer')) { |
||||
172 | $db->begin(); |
||||
173 | $result = $object->delete($user); |
||||
174 | |||||
175 | if ($result > 0) { |
||||
176 | $db->commit(); |
||||
177 | if (!empty($backtopage)) { |
||||
178 | header("Location: " . $backtopage); |
||||
179 | } else { |
||||
180 | header("Location: " . constant('BASE_URL') . '/expedition/list.php?restore_lastsearch_values=1'); |
||||
181 | } |
||||
182 | exit; |
||||
183 | } else { |
||||
184 | $db->rollback(); |
||||
185 | } |
||||
186 | } |
||||
187 | |||||
188 | if ($action == 'setdate_delivery' && $user->hasRight('expedition', 'delivery', 'creer')) { |
||||
189 | $datedelivery = dol_mktime(GETPOSTINT('liv_hour'), GETPOSTINT('liv_min'), 0, GETPOSTINT('liv_month'), GETPOSTINT('liv_day'), GETPOSTINT('liv_year')); |
||||
190 | $result = $object->setDeliveryDate($user, $datedelivery); |
||||
191 | if ($result < 0) { |
||||
192 | $mesg = '<div class="error">' . $object->error . '</div>'; |
||||
193 | } |
||||
194 | } elseif ($action == 'set_incoterms' && isModEnabled('incoterm')) { |
||||
195 | // Set incoterm |
||||
196 | $result = $object->setIncoterms(GETPOSTINT('incoterm_id'), GETPOSTINT('location_incoterms')); |
||||
197 | } |
||||
198 | |||||
199 | // Update extrafields |
||||
200 | if ($action == 'update_extras') { |
||||
201 | $object->oldcopy = dol_clone($object, 2); |
||||
202 | |||||
203 | // Fill array 'array_options' with data from update form |
||||
204 | $ret = $extrafields->setOptionalsFromPost(null, $object, GETPOST('attribute', 'restricthtml')); |
||||
205 | if ($ret < 0) { |
||||
206 | $error++; |
||||
207 | } |
||||
208 | |||||
209 | if (!$error) { |
||||
210 | // Actions on extra fields |
||||
211 | $result = $object->insertExtraFields('DELIVERY_MODIFY'); |
||||
212 | if ($result < 0) { |
||||
213 | setEventMessages($object->error, $object->errors, 'errors'); |
||||
214 | $error++; |
||||
215 | } |
||||
216 | } |
||||
217 | |||||
218 | if ($error) { |
||||
219 | $action = 'edit_extras'; |
||||
220 | } |
||||
221 | } |
||||
222 | |||||
223 | // Extrafields line |
||||
224 | if ($action == 'update_extras_line') { |
||||
225 | $array_options = array(); |
||||
226 | $num = count($object->lines); |
||||
227 | |||||
228 | for ($i = 0; $i < $num; $i++) { |
||||
229 | // Extrafields |
||||
230 | $extralabelsline = $extrafields->fetch_name_optionals_label($object->table_element_line); |
||||
231 | $array_options[$i] = $extrafields->getOptionalsFromPost($extralabelsline, $i); |
||||
232 | // Unset extrafield |
||||
233 | if (is_array($extralabelsline)) { |
||||
234 | // Get extra fields |
||||
235 | foreach ($extralabelsline as $key => $value) { |
||||
236 | unset($_POST["options_" . $key]); |
||||
237 | } |
||||
238 | } |
||||
239 | |||||
240 | $ret = $object->update_line($object->lines[$i]->id, $array_options[$i]); // extrafields update |
||||
241 | if ($ret < 0) { |
||||
242 | $mesg = '<div class="error">' . $object->error . '</div>'; |
||||
243 | $error++; |
||||
244 | } |
||||
245 | } |
||||
246 | } |
||||
247 | |||||
248 | |||||
249 | // Actions to build doc |
||||
250 | $upload_dir = $conf->expedition->dir_output . '/receipt'; |
||||
251 | $permissiontoadd = $user->hasRight('expedition', 'creer'); |
||||
252 | include DOL_DOCUMENT_ROOT . '/core/actions_builddoc.inc.php'; |
||||
253 | |||||
254 | include DOL_DOCUMENT_ROOT . '/core/actions_printing.inc.php'; |
||||
255 | |||||
256 | |||||
257 | /* |
||||
258 | * View |
||||
259 | */ |
||||
260 | |||||
261 | $title = $langs->trans('Delivery'); |
||||
262 | |||||
263 | ViewMain::llxHeader('', $title, 'Livraison', '', 0, 0, '', '', '', 'mod-delivery page-card'); |
||||
264 | |||||
265 | $form = new Form($db); |
||||
266 | $formfile = new FormFile($db); |
||||
267 | |||||
268 | if ($action == 'create') { |
||||
269 | // Create. Seems to no be used |
||||
270 | } else { |
||||
271 | // View |
||||
272 | if ($object->id > 0) { |
||||
273 | // Origin of a 'livraison' (delivery receipt) is ALWAYS 'expedition' (shipment). |
||||
274 | // However, origin of shipment in future may differs (commande, proposal, ...) |
||||
275 | $expedition = new Expedition($db); |
||||
276 | $result = $expedition->fetch($object->origin_id); |
||||
277 | $typeobject = $expedition->origin; // example: commande |
||||
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. ![]() |
|||||
278 | if ($object->origin_id > 0) { |
||||
279 | $object->fetch_origin(); |
||||
280 | } |
||||
281 | |||||
282 | if ($object->id > 0) { |
||||
283 | $soc = new Societe($db); |
||||
284 | $soc->fetch($object->socid); |
||||
285 | |||||
286 | $head = delivery_prepare_head($object); |
||||
287 | |||||
288 | print '<form action="' . $_SERVER["PHP_SELF"] . '" method="post">'; |
||||
289 | print '<input type="hidden" name="token" value="' . newToken() . '">'; |
||||
290 | print '<input type="hidden" name="action" value="update_extras_line">'; |
||||
291 | print '<input type="hidden" name="origin" value="' . $object->origin . '">'; |
||||
292 | print '<input type="hidden" name="id" value="' . $object->id . '">'; |
||||
293 | print '<input type="hidden" name="ref" value="' . $object->ref . '">'; |
||||
294 | |||||
295 | print dol_get_fiche_head($head, 'delivery', $langs->trans("Shipment"), -1, 'dolly'); |
||||
296 | |||||
297 | /* |
||||
298 | * Confirmation de la suppression |
||||
299 | * |
||||
300 | */ |
||||
301 | if ($action == 'delete') { |
||||
302 | $expedition_id = GETPOST("expid"); |
||||
303 | print $form->formconfirm($_SERVER['PHP_SELF'] . '?id=' . $object->id . '&expid=' . $expedition_id . '&backtopage=' . urlencode($backtopage), $langs->trans("DeleteDeliveryReceipt"), $langs->trans("DeleteDeliveryReceiptConfirm", $object->ref), 'confirm_delete', '', '', 1); |
||||
304 | } |
||||
305 | |||||
306 | /* |
||||
307 | * Confirmation de la validation |
||||
308 | */ |
||||
309 | if ($action == 'valid') { |
||||
310 | print $form->formconfirm($_SERVER['PHP_SELF'] . '?id=' . $object->id, $langs->trans("ValidateDeliveryReceipt"), $langs->trans("ValidateDeliveryReceiptConfirm", $object->ref), 'confirm_valid', '', '', 1); |
||||
311 | } |
||||
312 | |||||
313 | |||||
314 | /* |
||||
315 | * Delivery |
||||
316 | */ |
||||
317 | |||||
318 | if ($typeobject == 'commande' && $expedition->origin_id > 0 && isModEnabled('order')) { |
||||
319 | $objectsrc = new Commande($db); |
||||
320 | $objectsrc->fetch($expedition->origin_id); |
||||
321 | } |
||||
322 | if ($typeobject == 'propal' && $expedition->origin_id > 0 && isModEnabled("propal")) { |
||||
323 | $objectsrc = new Propal($db); |
||||
324 | $objectsrc->fetch($expedition->origin_id); |
||||
325 | } |
||||
326 | |||||
327 | // Shipment card |
||||
328 | $linkback = '<a href="' . constant('BASE_URL') . '/expedition/list.php?restore_lastsearch_values=1' . (!empty($socid) ? '&socid=' . $socid : '') . '">' . $langs->trans("BackToList") . '</a>'; |
||||
329 | |||||
330 | $morehtmlref = '<div class="refidno">'; |
||||
331 | // Ref customer shipment |
||||
332 | $morehtmlref .= $form->editfieldkey("RefCustomer", '', $expedition->ref_customer, $expedition, $user->hasRight('expedition', 'creer'), 'string', '', 0, 1); |
||||
333 | $morehtmlref .= $form->editfieldval("RefCustomer", '', $expedition->ref_customer, $expedition, $user->hasRight('expedition', 'creer'), 'string' . (getDolGlobalString('THIRDPARTY_REF_INPUT_SIZE') ? ':' . getDolGlobalString('THIRDPARTY_REF_INPUT_SIZE') : ''), '', null, null, '', 1); |
||||
334 | $morehtmlref .= '<br>' . $langs->trans("RefDeliveryReceipt") . ' : ' . $object->ref; |
||||
335 | // Thirdparty |
||||
336 | $morehtmlref .= '<br>' . $expedition->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. ![]() |
|||||
337 | // Project |
||||
338 | if (isModEnabled('project')) { |
||||
339 | $langs->load("projects"); |
||||
340 | $morehtmlref .= '<br>'; |
||||
341 | if (0) { // Do not change on shipment |
||||
342 | $morehtmlref .= img_picto($langs->trans("Project"), 'project', 'class="pictofixedwidth"'); |
||||
343 | if ($action != 'classify') { |
||||
344 | $morehtmlref .= '<a class="editfielda" href="' . $_SERVER['PHP_SELF'] . '?action=classify&token=' . newToken() . '&id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> '; |
||||
345 | } |
||||
346 | $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $objectsrc->socid, $objectsrc->fk_project, ($action == 'classify' ? 'projectid' : 'none'), 0, 0, 0, 1, '', 'maxwidth300'); |
||||
347 | } else { |
||||
348 | if (!empty($objectsrc->fk_project)) { |
||||
349 | $proj = new Project($db); |
||||
350 | $proj->fetch($objectsrc->fk_project); |
||||
351 | $morehtmlref .= $proj->getNomUrl(1); |
||||
352 | if ($proj->title) { |
||||
353 | $morehtmlref .= '<span class="opacitymedium"> - ' . dol_escape_htmltag($proj->title) . '</span>'; |
||||
354 | } |
||||
355 | } |
||||
356 | } |
||||
357 | } |
||||
358 | $morehtmlref .= '</div>'; |
||||
359 | |||||
360 | $morehtmlstatus = $langs->trans("StatusReceipt") . ' : ' . $object->getLibStatut(6) . '<br><br class="small">'; |
||||
361 | |||||
362 | dol_banner_tab($expedition, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref, '', 0, '', $morehtmlstatus); |
||||
363 | |||||
364 | |||||
365 | print '<div class="fichecenter">'; |
||||
366 | print '<div class="underbanner clearboth"></div>'; |
||||
367 | |||||
368 | print '<table class="border tableforfield" width="100%">'; |
||||
369 | |||||
370 | // Shipment |
||||
371 | /* |
||||
372 | if (($object->origin == 'shipment' || $object->origin == 'expedition') && $object->origin_id > 0) |
||||
373 | { |
||||
374 | $linkback = '<a href="'.DOL_URL_ROOT.'/expedition/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>'; |
||||
375 | |||||
376 | // Ref |
||||
377 | print '<tr><td width="20%">'.$langs->trans("RefSending").'</td>'; |
||||
378 | print '<td colspan="3">'; |
||||
379 | // Nav is hidden because on a delivery receipt of a shipment, if we go on next shipment, we may find no tab (a shipment may not have delivery receipt yet) |
||||
380 | //print $form->showrefnav($expedition, 'refshipment', $linkback, 1, 'ref', 'ref'); |
||||
381 | print $form->showrefnav($expedition, 'refshipment', $linkback, 0, 'ref', 'ref'); |
||||
382 | print '</td></tr>'; |
||||
383 | } |
||||
384 | |||||
385 | // Ref |
||||
386 | print '<tr><td width="20%">'.$langs->trans("Ref").'</td>'; |
||||
387 | print '<td colspan="3">'; |
||||
388 | print $object->ref; |
||||
389 | print '</td></tr>'; |
||||
390 | |||||
391 | // Client |
||||
392 | print '<tr><td width="20%">'.$langs->trans("Customer").'</td>'; |
||||
393 | print '<td colspan="3">'.$soc->getNomUrl(1).'</td>'; |
||||
394 | print "</tr>"; |
||||
395 | */ |
||||
396 | |||||
397 | // Document origine |
||||
398 | if ($typeobject == 'commande' && $expedition->origin_id && isModEnabled('order')) { |
||||
399 | print '<tr><td class="titlefield">' . $langs->trans("RefOrder") . '</td>'; |
||||
400 | $order = new Commande($db); |
||||
401 | $order->fetch($expedition->origin_id); |
||||
402 | print '<td colspan="3">'; |
||||
403 | print $order->getNomUrl(1, 'commande'); |
||||
404 | print "</td>\n"; |
||||
405 | print '</tr>'; |
||||
406 | } |
||||
407 | if ($typeobject == 'propal' && $expedition->origin_id && isModEnabled("propal")) { |
||||
408 | $propal = new Propal($db); |
||||
409 | $propal->fetch($expedition->origin_id); |
||||
410 | print '<tr><td class="titlefield">' . $langs->trans("RefProposal") . '</td>'; |
||||
411 | print '<td colspan="3">'; |
||||
412 | print $propal->getNomUrl(1, 'expedition'); |
||||
413 | print "</td>\n"; |
||||
414 | print '</tr>'; |
||||
415 | } |
||||
416 | |||||
417 | // Date |
||||
418 | print '<tr><td class="titlefield">' . $langs->trans("DateCreation") . '</td>'; |
||||
419 | print '<td colspan="3">' . dol_print_date($object->date_creation, 'dayhour') . "</td>\n"; |
||||
420 | print '</tr>'; |
||||
421 | |||||
422 | // Date delivery real / Received |
||||
423 | print '<tr><td height="10">'; |
||||
424 | print '<table class="nobordernopadding" width="100%"><tr><td>'; |
||||
425 | print $langs->trans('DateReceived'); |
||||
426 | print '</td>'; |
||||
427 | |||||
428 | if ($action != 'editdate_delivery') { |
||||
429 | print '<td class="right"><a class="editfielda" href="' . $_SERVER["PHP_SELF"] . '?action=editdate_delivery&token=' . newToken() . '&id=' . $object->id . '">' . img_edit($langs->trans('SetDeliveryDate'), 1) . '</a></td>'; |
||||
430 | } |
||||
431 | print '</tr></table>'; |
||||
432 | print '</td><td colspan="2">'; |
||||
433 | if ($action == 'editdate_delivery') { |
||||
434 | print '<form name="setdate_delivery" action="' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '" method="post">'; |
||||
435 | print '<input type="hidden" name="token" value="' . newToken() . '">'; |
||||
436 | print '<input type="hidden" name="action" value="setdate_delivery">'; |
||||
437 | print $form->selectDate($object->date_delivery ? $object->date_delivery : -1, 'liv_', 1, 1, 0, "setdate_delivery", 1, 1); |
||||
438 | print '<input type="submit" class="button button-edit" value="' . $langs->trans('Modify') . '">'; |
||||
439 | print '</form>'; |
||||
440 | } else { |
||||
441 | print $object->date_delivery ? dol_print_date($object->date_delivery, 'dayhour') : ' '; |
||||
442 | } |
||||
443 | print '</td>'; |
||||
444 | print '</tr>'; |
||||
445 | |||||
446 | // Incoterms |
||||
447 | if (isModEnabled('incoterm')) { |
||||
448 | print '<tr><td>'; |
||||
449 | print '<table class="centpercent nobordernopadding"><tr><td>'; |
||||
450 | print $langs->trans('IncotermLabel'); |
||||
451 | print '<td><td class="right">'; |
||||
452 | if ($user->hasRight('expedition', 'delivery', 'creer')) { |
||||
453 | print '<a class="editfielda" href="' . constant('BASE_URL') . '/delivery/card.php?id=' . $object->id . '&action=editincoterm&token=' . newToken() . '">' . img_edit() . '</a>'; |
||||
454 | } else { |
||||
455 | print ' '; |
||||
456 | } |
||||
457 | print '</td></tr></table>'; |
||||
458 | print '</td>'; |
||||
459 | print '<td colspan="3">'; |
||||
460 | if ($action != 'editincoterm') { |
||||
461 | print $form->textwithpicto($object->display_incoterms(), $object->label_incoterms, 1); |
||||
462 | } else { |
||||
463 | print $form->select_incoterms((!empty($object->fk_incoterms) ? $object->fk_incoterms : ''), (!empty($object->location_incoterms) ? $object->location_incoterms : ''), $_SERVER['PHP_SELF'] . '?id=' . $object->id); |
||||
464 | } |
||||
465 | print '</td></tr>'; |
||||
466 | } |
||||
467 | |||||
468 | /* A delivery note should be just more properties of a shipment, so notes are on shipment |
||||
469 | // Note Public |
||||
470 | print '<tr><td>'.$langs->trans("NotePublic").'</td>'; |
||||
471 | print '<td colspan="3">'; |
||||
472 | print dol_string_onlythesehtmltags(dol_htmlcleanlastbr($object->note_public)); |
||||
473 | print "</td></tr>"; |
||||
474 | |||||
475 | // Note Private |
||||
476 | print '<tr><td>'.$langs->trans("NotePrivate").'</td>'; |
||||
477 | print '<td colspan="3">'; |
||||
478 | print dol_string_onlythesehtmltags(dol_htmlcleanlastbr($object->note_private)); |
||||
479 | print "</td></tr>"; |
||||
480 | */ |
||||
481 | |||||
482 | // Statut |
||||
483 | /*print '<tr><td>'.$langs->trans("Status").'</td>'; |
||||
484 | print '<td colspan="3">'.$object->getLibStatut(4)."</td>\n"; |
||||
485 | print '</tr>';*/ |
||||
486 | |||||
487 | |||||
488 | if (!getDolGlobalInt('MAIN_SUBMODULE_EXPEDITION') && isModEnabled('stock')) { |
||||
489 | // Entrepot |
||||
490 | $entrepot = new Entrepot($db); |
||||
491 | $entrepot->fetch($expedition->entrepot_id); |
||||
492 | print '<tr><td width="20%">' . $langs->trans("Warehouse") . '</td>'; |
||||
493 | print '<td colspan="3"><a href="' . constant('BASE_URL') . '/product/stock/card.php?id=' . $entrepot->id . '">' . $entrepot->label . '</a></td>'; |
||||
494 | print '</tr>'; |
||||
495 | } |
||||
496 | |||||
497 | // Other attributes |
||||
498 | if ($action == 'create_delivery') { |
||||
499 | // copy from expedition |
||||
500 | $extrafields->fetch_name_optionals_label($expedition->table_element); |
||||
501 | if ($expedition->fetch_optionals() > 0) { |
||||
502 | $object->array_options = array_merge($object->array_options, $expedition->array_options); |
||||
503 | } |
||||
504 | } |
||||
505 | $cols = 2; |
||||
506 | include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php'; |
||||
507 | |||||
508 | print "</table><br>\n"; |
||||
509 | |||||
510 | print '</div>'; |
||||
511 | |||||
512 | /* |
||||
513 | * Products lines |
||||
514 | */ |
||||
515 | |||||
516 | $num_prod = count($object->lines); |
||||
517 | $i = 0; |
||||
518 | $total = 0; |
||||
519 | |||||
520 | print '<table class="noborder centpercent">'; |
||||
521 | |||||
522 | if ($num_prod) { |
||||
523 | $i = 0; |
||||
524 | |||||
525 | print '<tr class="liste_titre">'; |
||||
526 | print '<td>' . $langs->trans("Products") . '</td>'; |
||||
527 | print '<td class="center">' . $langs->trans("QtyOrdered") . '</td>'; |
||||
528 | print '<td class="center">' . $langs->trans("QtyReceived") . '</td>'; |
||||
529 | print "</tr>\n"; |
||||
530 | } |
||||
531 | while ($i < $num_prod) { |
||||
532 | $parameters = array('i' => $i, 'line' => $object->lines[$i], 'num' => $num_prod); |
||||
533 | $reshook = $hookmanager->executeHooks('printObjectLine', $parameters, $object, $action); |
||||
534 | if ($reshook < 0) { |
||||
535 | setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); |
||||
536 | } |
||||
537 | |||||
538 | if (empty($reshook)) { |
||||
539 | print '<tr class="oddeven">'; |
||||
540 | if ($object->lines[$i]->fk_product > 0) { |
||||
541 | $product = new Product($db); |
||||
542 | $product->fetch($object->lines[$i]->fk_product); |
||||
543 | |||||
544 | // Define output language |
||||
545 | if (getDolGlobalInt('MAIN_MULTILANGS') && getDolGlobalString('PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE')) { |
||||
546 | $outputlangs = $langs; |
||||
547 | $newlang = ''; |
||||
548 | if (empty($newlang) && GETPOST('lang_id', 'aZ09')) { |
||||
549 | $newlang = GETPOST('lang_id', 'aZ09'); |
||||
550 | } |
||||
551 | if (empty($newlang)) { |
||||
552 | $newlang = $object->thirdparty->default_lang; |
||||
553 | } |
||||
554 | if (!empty($newlang)) { |
||||
555 | $outputlangs = new Translate("", $conf); |
||||
556 | $outputlangs->setDefaultLang($newlang); |
||||
557 | } |
||||
558 | |||||
559 | $label = (!empty($product->multilangs[$outputlangs->defaultlang]["label"])) ? $product->multilangs[$outputlangs->defaultlang]["label"] : $object->lines[$i]->product_label; |
||||
560 | } else { |
||||
561 | $label = (!empty($object->lines[$i]->label) ? $object->lines[$i]->label : $object->lines[$i]->product_label); |
||||
562 | } |
||||
563 | |||||
564 | print '<td>'; |
||||
565 | |||||
566 | // Affiche ligne produit |
||||
567 | $text = '<a href="' . constant('BASE_URL') . '/product/card.php?id=' . $object->lines[$i]->fk_product . '">'; |
||||
568 | if ($object->lines[$i]->fk_product_type == 1) { |
||||
569 | $text .= img_object($langs->trans('ShowService'), 'service'); |
||||
570 | } else { |
||||
571 | $text .= img_object($langs->trans('ShowProduct'), 'product'); |
||||
572 | } |
||||
573 | $text .= ' ' . $object->lines[$i]->product_ref . '</a>'; |
||||
574 | $text .= ' - ' . $label; |
||||
575 | $description = (getDolGlobalInt('PRODUIT_DESC_IN_FORM_ACCORDING_TO_DEVICE') ? '' : dol_htmlentitiesbr($object->lines[$i]->description)); |
||||
576 | //print $description; |
||||
577 | print $form->textwithtooltip($text, $description, 3, '', '', $i); |
||||
578 | //print_date_range($object->lines[$i]->date_start, $object->lines[$i]->date_end); |
||||
579 | if (getDolGlobalInt('PRODUIT_DESC_IN_FORM_ACCORDING_TO_DEVICE')) { |
||||
580 | print (!empty($object->lines[$i]->description) && $object->lines[$i]->description != $object->lines[$i]->product_label) ? '<br>' . dol_htmlentitiesbr($object->lines[$i]->description) : ''; |
||||
581 | } |
||||
582 | } else { |
||||
583 | print "<td>"; |
||||
584 | if ($object->lines[$i]->fk_product_type == 1) { |
||||
585 | $text = img_object($langs->trans('Service'), 'service'); |
||||
586 | } else { |
||||
587 | $text = img_object($langs->trans('Product'), 'product'); |
||||
588 | } |
||||
589 | |||||
590 | if (!empty($object->lines[$i]->label)) { |
||||
591 | $text .= ' <strong>' . $object->lines[$i]->label . '</strong>'; |
||||
592 | print $form->textwithtooltip($text, $object->lines[$i]->description, 3, '', '', $i); |
||||
593 | } else { |
||||
594 | print $text . ' ' . nl2br($object->lines[$i]->description); |
||||
595 | } |
||||
596 | |||||
597 | //print_date_range($objp->date_start, $objp->date_end); |
||||
598 | print "</td>\n"; |
||||
599 | } |
||||
600 | |||||
601 | print '<td class="center">' . $object->lines[$i]->qty_asked . '</td>'; |
||||
602 | print '<td class="center">' . $object->lines[$i]->qty_shipped . '</td>'; |
||||
603 | |||||
604 | print "</tr>"; |
||||
605 | |||||
606 | // Display lines extrafields |
||||
607 | //if (!empty($extrafields)) { |
||||
608 | $colspan = 2; |
||||
609 | $mode = ($object->statut == 0) ? 'edit' : 'view'; |
||||
610 | |||||
611 | $object->lines[$i]->fetch_optionals(); |
||||
612 | |||||
613 | if ($action == 'create_delivery') { |
||||
614 | $srcLine = new ExpeditionLigne($db); |
||||
615 | |||||
616 | $extrafields->fetch_name_optionals_label($srcLine->table_element); |
||||
617 | $srcLine->id = $expedition->lines[$i]->id; |
||||
618 | $srcLine->fetch_optionals(); |
||||
619 | |||||
620 | $object->lines[$i]->array_options = array_merge($object->lines[$i]->array_options, $srcLine->array_options); |
||||
621 | } else { |
||||
622 | $srcLine = new DeliveryLine($db); |
||||
623 | $extrafields->fetch_name_optionals_label($srcLine->table_element); |
||||
624 | } |
||||
625 | print $object->lines[$i]->showOptionals($extrafields, $mode, array('style' => 'class="oddeven"', 'colspan' => $colspan), ''); |
||||
626 | //} |
||||
627 | } |
||||
628 | |||||
629 | $i++; |
||||
630 | } |
||||
631 | |||||
632 | print "</table>\n"; |
||||
633 | |||||
634 | print dol_get_fiche_end(); |
||||
635 | |||||
636 | //if ($object->statut == 0) // only if draft |
||||
637 | // print $form->buttonsSaveCancel("Save", ''); |
||||
638 | |||||
639 | print '</form>'; |
||||
640 | |||||
641 | |||||
642 | /* |
||||
643 | * Boutons actions |
||||
644 | */ |
||||
645 | |||||
646 | if ($user->socid == 0) { |
||||
647 | print '<div class="tabsAction">'; |
||||
648 | |||||
649 | if ($object->statut == 0 && $num_prod > 0) { |
||||
650 | if ( |
||||
651 | (!getDolGlobalString('MAIN_USE_ADVANCED_PERMS') && $user->hasRight('expedition', 'delivery', 'creer')) |
||||
652 | || (getDolGlobalString('MAIN_USE_ADVANCED_PERMS') && $user->hasRight('expedition', 'delivery_advance', 'validate')) |
||||
653 | ) { |
||||
654 | print dolGetButtonAction('', $langs->trans('Validate'), 'default', $_SERVER["PHP_SELF"] . '?action=valid&token=' . newToken() . '&id=' . $object->id, ''); |
||||
655 | } |
||||
656 | } |
||||
657 | |||||
658 | if ($user->hasRight('expedition', 'delivery', 'supprimer')) { |
||||
659 | if (getDolGlobalInt('MAIN_SUBMODULE_EXPEDITION')) { |
||||
660 | print dolGetButtonAction('', $langs->trans('Delete'), 'delete', $_SERVER["PHP_SELF"] . '?id=' . $object->id . '&expid=' . $object->origin_id . '&action=delete&token=' . newToken() . '&backtopage=' . urlencode(constant('BASE_URL') . '/expedition/card.php?id=' . $object->origin_id), ''); |
||||
661 | } else { |
||||
662 | print dolGetButtonAction('', $langs->trans('Delete'), 'delete', $_SERVER["PHP_SELF"] . '?action=delete&token=' . newToken() . '&id=' . $object->id, ''); |
||||
663 | } |
||||
664 | } |
||||
665 | |||||
666 | print '</div>'; |
||||
667 | } |
||||
668 | print "\n"; |
||||
669 | |||||
670 | print '<div class="fichecenter"><div class="fichehalfleft">'; |
||||
671 | |||||
672 | /* |
||||
673 | * Documents generated |
||||
674 | */ |
||||
675 | |||||
676 | $objectref = dol_sanitizeFileName($object->ref); |
||||
677 | $filedir = $conf->expedition->dir_output . "/receipt/" . $objectref; |
||||
678 | $urlsource = $_SERVER["PHP_SELF"] . "?id=" . $object->id; |
||||
679 | |||||
680 | $genallowed = $user->hasRight('expedition', 'delivery', 'lire'); |
||||
681 | $delallowed = $user->hasRight('expedition', 'delivery', 'creer'); |
||||
682 | |||||
683 | print $formfile->showdocuments('delivery', $objectref, $filedir, $urlsource, $genallowed, $delallowed, $object->model_pdf, 1, 0, 0, 28, 0, '', '', '', $soc->default_lang); |
||||
684 | |||||
685 | /* |
||||
686 | * Linked object block (of linked shipment) |
||||
687 | */ |
||||
688 | if ($object->origin == 'expedition') { |
||||
689 | $shipment = new Expedition($db); |
||||
690 | $shipment->fetch($object->origin_id); |
||||
691 | |||||
692 | // Show links to link elements |
||||
693 | //$linktoelem = $form->showLinkToObjectBlock($object, null, array('order')); |
||||
694 | $somethingshown = $form->showLinkedObjectBlock($object, ''); |
||||
695 | } |
||||
696 | |||||
697 | |||||
698 | print '</div><div class="fichehalfright">'; |
||||
699 | |||||
700 | // Nothing on right |
||||
701 | |||||
702 | print '</div></div>'; |
||||
703 | } else { |
||||
704 | /* Expedition non trouvee */ |
||||
705 | print "Expedition inexistante ou access refuse"; |
||||
706 | } |
||||
707 | } else { |
||||
708 | /* Expedition non trouvee */ |
||||
709 | print "Expedition inexistante ou access refuse"; |
||||
710 | } |
||||
711 | } |
||||
712 | |||||
713 | // End of page |
||||
714 | ViewMain::llxFooter(); |
||||
715 | $db->close(); |
||||
716 |
Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a mixed type is assigned to a property that is type hinted more strictly.
For example, imagine you have a variable
$accountId
that can either hold an Id object or false (if there is no account id yet). Your code now assigns that value to theid
property of an instance of theAccount
class. This class holds a proper account, so the id value must no longer be false.Either this assignment is in error or a type check should be added for that assignment.